diff --git a/README.md b/README.md index 3aec550..1572814 100644 --- a/README.md +++ b/README.md @@ -23,15 +23,24 @@ Works on any browser and any platform. Roughly `5kb`, excluding babel-runtime an - `[onClickOutside]` - on click outside of "focus" area. (actually on any event "outside") - `[onEscapeKey]` - on Esc key pressed (and not defaultPrevented) - `[gapMode]` - the way removed ScrollBar would be _compensated_ - margin(default), or padding. See [scroll-locky documentation](https://github.com/theKashey/react-scroll-locky#gap-modes) to find the one you need. + - `[noIsolation]` - disables pointer event isolation + - `[shards]` - a list of Refs to be considered as a part of locks. ## Additional API ### Exposed from React-Focus-Lock - `AutoFocusInside` - to mark autofocusable element - `MoveFocusInside` - to move focus inside or a component mount + - `InFocusGuard` - to "guard" shard node. -### Exposed from React-Scroll-Locky - - `FocusPane` - to create a container with proper dimensions (it's more about right coordinate) set. - +See [react-focus-lock](https://github.com/theKashey/react-focus-lock) for details. + +### Exposed from React-Remove-Scroll + - `classNames.fullWidth` - "100%" width (will not change on scrollbar removal) + - `classNames.zeroRight` - "0" right (will not change on scrollbar removal) + +See [React-Remove-Scroll](https://github.com/theKashey/react-remove-scroll) for details. + +> PS: Version 1 used React-scroll-locky which was replaced by remove-scroll. # Licence MIT diff --git a/example/app.tsx b/example/app.tsx index 5558b3f..bfeacc0 100644 --- a/example/app.tsx +++ b/example/app.tsx @@ -1,53 +1,95 @@ import * as React from 'react'; import {Component} from 'react'; import {GHCorner} from 'react-gh-corner'; +import {Toggle} from 'react-powerplug'; import {AppWrapper} from './styled'; -import {FocusOn, FocusPane, AutoFocusInside, MoveFocusInside} from "../src"; +import {FocusOn, AutoFocusInside, MoveFocusInside, InFocusGuard, classNames} from "../src"; export interface AppState { enabled: boolean; } +const FocusPane = ({children}) =>
{children}
; + +const ScrollBox = React.forwardRef(({children}, ref: any) => ( +
+ + + + + +
+)); + const repoUrl = 'https://github.com/zzarcon/'; export default class App extends Component <{}, AppState> { state: AppState = { enabled: false }; + toggleRef = React.createRef(); + scrollRef = React.createRef() + toggle = () => this.setState({enabled: !this.state.enabled}); render() { return ( - - - - - outside - - inside - - - - - - - - - - Example! - { - Array(100).fill(1).map((_, x) => -
- {Array(100).fill(1).map((_, x) => *{x})} -
- ) - } -
-
+ + {({on, toggle}) => ( + + + + + outside + + + + {on &&
+ + Holala!! + + innerbox + +
} + + + outer box + + + + inside + + + + + + + + + + Example! + { + Array(100).fill(1).map((_, x) => +
+ {Array(10).fill(1).map((_, x) => *{x})} +
+ ) + } +
+
+ )} +
) } } \ No newline at end of file diff --git a/package.json b/package.json index 473bc9d..b298d62 100644 --- a/package.json +++ b/package.json @@ -19,13 +19,14 @@ "author": "Anton Korzunov ", "license": "MIT", "devDependencies": { + "react-powerplug": "^1.0.0", "size-limit": "^0.21.1", "ts-react-toolbox": "^0.1.22" }, "dependencies": { - "aria-hidden": "^1.0.0", - "react-focus-lock": "^1.17.6", - "react-scroll-locky": "^1.4.0" + "aria-hidden": "^1.1.1", + "react-focus-lock": "^1.18.2", + "react-remove-scroll": "^1.0.5" }, "engines": { "node": ">=8.5.0" diff --git a/src/InteractivityDisabler.tsx b/src/InteractivityDisabler.tsx index e69de29..afa525f 100644 --- a/src/InteractivityDisabler.tsx +++ b/src/InteractivityDisabler.tsx @@ -0,0 +1,16 @@ +import * as React from 'react'; +import {styleSinglentone} from 'react-style-singleton'; + +const Style = styleSinglentone(); + +export const focusHiddenMarker = 'data-focus-on-hidden'; + +const styles = ` + [${focusHiddenMarker}] { + pointer-events: none !important; + } +`; + +export const InteractivityDisabler: React.SFC = () => ( +