@semcore/core 16.5.1 → 17.0.0-prerelease.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -1
- package/README.md +4 -4
- package/lib/LastInteractionType.js +22 -36
- package/lib/LastInteractionType.js.map +1 -1
- package/lib/LastInteractionType.mjs +19 -33
- package/lib/LastInteractionType.mjs.map +1 -1
- package/lib/core-types/Component.d.ts +26 -79
- package/lib/core-types/Component.js +24 -72
- package/lib/core-types/Component.js.map +1 -1
- package/lib/core-types/Component.mjs +18 -34
- package/lib/core-types/Component.mjs.map +1 -1
- package/lib/core-types/symbols.js +9 -9
- package/lib/core-types/symbols.js.map +1 -1
- package/lib/core-types/symbols.mjs +9 -9
- package/lib/core-types/symbols.mjs.map +1 -1
- package/lib/coreFactory.d.ts +6 -23
- package/lib/coreFactory.js +150 -217
- package/lib/coreFactory.js.map +1 -1
- package/lib/coreFactory.mjs +139 -194
- package/lib/coreFactory.mjs.map +1 -1
- package/lib/decorators/propsObserver.d.ts +11 -0
- package/lib/decorators/reactive.d.ts +11 -0
- package/lib/enhancement/Children.js +51 -59
- package/lib/enhancement/Children.js.map +1 -1
- package/lib/enhancement/Children.mjs +47 -41
- package/lib/enhancement/Children.mjs.map +1 -1
- package/lib/enhancement/Root.js +36 -37
- package/lib/enhancement/Root.js.map +1 -1
- package/lib/enhancement/Root.mjs +28 -18
- package/lib/enhancement/Root.mjs.map +1 -1
- package/lib/enhancement/dataName.js +7 -8
- package/lib/enhancement/dataName.js.map +1 -1
- package/lib/enhancement/dataName.mjs +5 -5
- package/lib/enhancement/dataName.mjs.map +1 -1
- package/lib/enhancement/enhance.js +6 -9
- package/lib/enhancement/enhance.js.map +1 -1
- package/lib/enhancement/enhance.mjs +5 -7
- package/lib/enhancement/enhance.mjs.map +1 -1
- package/lib/enhancement/functionDefaultProps.js +6 -6
- package/lib/enhancement/functionDefaultProps.js.map +1 -1
- package/lib/enhancement/functionDefaultProps.mjs +4 -4
- package/lib/enhancement/functionDefaultProps.mjs.map +1 -1
- package/lib/enhancement/i18n.js +13 -13
- package/lib/enhancement/i18n.js.map +1 -1
- package/lib/enhancement/i18n.mjs +10 -9
- package/lib/enhancement/i18n.mjs.map +1 -1
- package/lib/enhancement/inheritedName.js +7 -8
- package/lib/enhancement/inheritedName.js.map +1 -1
- package/lib/enhancement/inheritedName.mjs +5 -5
- package/lib/enhancement/inheritedName.mjs.map +1 -1
- package/lib/enhancement/staticChildren.js +47 -56
- package/lib/enhancement/staticChildren.js.map +1 -1
- package/lib/enhancement/staticChildren.mjs +43 -48
- package/lib/enhancement/staticChildren.mjs.map +1 -1
- package/lib/enhancement/style.js +29 -27
- package/lib/enhancement/style.js.map +1 -1
- package/lib/enhancement/style.mjs +26 -20
- package/lib/enhancement/style.mjs.map +1 -1
- package/lib/enhancement/uncontrolledProps.js +46 -64
- package/lib/enhancement/uncontrolledProps.js.map +1 -1
- package/lib/enhancement/uncontrolledProps.mjs +43 -51
- package/lib/enhancement/uncontrolledProps.mjs.map +1 -1
- package/lib/esm/LastInteractionType.mjs +19 -33
- package/lib/esm/core-types/Component.mjs +18 -34
- package/lib/esm/core-types/symbols.mjs +9 -9
- package/lib/esm/coreFactory.mjs +139 -194
- package/lib/esm/enhancement/Children.mjs +47 -41
- package/lib/esm/enhancement/Root.mjs +28 -18
- package/lib/esm/enhancement/dataName.mjs +5 -5
- package/lib/esm/enhancement/enhance.mjs +5 -7
- package/lib/esm/enhancement/functionDefaultProps.mjs +4 -4
- package/lib/esm/enhancement/i18n.mjs +10 -9
- package/lib/esm/enhancement/inheritedName.mjs +5 -5
- package/lib/esm/enhancement/staticChildren.mjs +43 -48
- package/lib/esm/enhancement/style.mjs +26 -20
- package/lib/esm/enhancement/uncontrolledProps.mjs +43 -51
- package/lib/esm/register.mjs +12 -20
- package/lib/esm/styled/reshadow-core.mjs +98 -111
- package/lib/esm/styled/sstyled.mjs +31 -41
- package/lib/esm/utils/assignProps.mjs +32 -36
- package/lib/esm/utils/enhances/WithI18n.mjs +16 -63
- package/lib/esm/utils/enhances/i18nEnhance.mjs +47 -61
- package/lib/esm/utils/logger.mjs +13 -21
- package/lib/esm/utils/pick.mjs +4 -4
- package/lib/esm/utils/ref.mjs +27 -57
- package/lib/esm/utils/use/useEnhancedEffect.mjs +1 -1
- package/lib/index.d.ts +3 -3
- package/lib/index.js +17 -17
- package/lib/index.js.map +1 -1
- package/lib/index.mjs.map +1 -1
- package/lib/register.js +17 -24
- package/lib/register.js.map +1 -1
- package/lib/register.mjs +12 -20
- package/lib/register.mjs.map +1 -1
- package/lib/styled/index.d.ts +1 -5
- package/lib/styled/index.js +4 -4
- package/lib/styled/index.js.map +1 -1
- package/lib/styled/index.mjs.map +1 -1
- package/lib/styled/reshadow-core.js +102 -104
- package/lib/styled/reshadow-core.js.map +1 -1
- package/lib/styled/reshadow-core.mjs +98 -111
- package/lib/styled/reshadow-core.mjs.map +1 -1
- package/lib/styled/sstyled.js +31 -53
- package/lib/styled/sstyled.js.map +1 -1
- package/lib/styled/sstyled.mjs +31 -41
- package/lib/styled/sstyled.mjs.map +1 -1
- package/lib/theme/processor.js +150 -222
- package/lib/theme/processor.js.map +1 -1
- package/lib/theme/processor.mjs +148 -221
- package/lib/theme/processor.mjs.map +1 -1
- package/lib/theme/themes/dark.js +2 -2
- package/lib/theme/themes/dark.js.map +1 -1
- package/lib/theme/themes/default.js +2 -2
- package/lib/theme/themes/default.js.map +1 -1
- package/lib/theme/themes/highlights-dark.js +2 -2
- package/lib/theme/themes/highlights-dark.js.map +1 -1
- package/lib/theme/themes/highlights-light.js +2 -2
- package/lib/theme/themes/highlights-light.js.map +1 -1
- package/lib/theme/themes/light.js +2 -2
- package/lib/theme/themes/light.js.map +1 -1
- package/lib/theme/utils.js +140 -215
- package/lib/theme/utils.js.map +1 -1
- package/lib/theme/utils.mjs +135 -214
- package/lib/theme/utils.mjs.map +1 -1
- package/lib/utils/CSSinJS.js +8 -10
- package/lib/utils/CSSinJS.js.map +1 -1
- package/lib/utils/CSSinJS.mjs +6 -7
- package/lib/utils/CSSinJS.mjs.map +1 -1
- package/lib/utils/ThemeProvider.js +44 -51
- package/lib/utils/ThemeProvider.js.map +1 -1
- package/lib/utils/ThemeProvider.mjs +36 -47
- package/lib/utils/ThemeProvider.mjs.map +1 -1
- package/lib/utils/addonText.js +4 -7
- package/lib/utils/addonText.js.map +1 -1
- package/lib/utils/addonText.mjs +2 -5
- package/lib/utils/addonText.mjs.map +1 -1
- package/lib/utils/addonTextChildren.js +15 -21
- package/lib/utils/addonTextChildren.js.map +1 -1
- package/lib/utils/addonTextChildren.mjs +7 -13
- package/lib/utils/addonTextChildren.mjs.map +1 -1
- package/lib/utils/ariaProps.js +7 -5
- package/lib/utils/ariaProps.js.map +1 -1
- package/lib/utils/ariaProps.mjs +7 -5
- package/lib/utils/ariaProps.mjs.map +1 -1
- package/lib/utils/assignProps.js +33 -37
- package/lib/utils/assignProps.js.map +1 -1
- package/lib/utils/assignProps.mjs +32 -36
- package/lib/utils/assignProps.mjs.map +1 -1
- package/lib/utils/canUseDOM.js +1 -1
- package/lib/utils/capitalizeFirstLetter.js +1 -1
- package/lib/utils/color.js +72 -95
- package/lib/utils/color.js.map +1 -1
- package/lib/utils/color.mjs +71 -94
- package/lib/utils/color.mjs.map +1 -1
- package/lib/utils/compose.js +3 -12
- package/lib/utils/compose.js.map +1 -1
- package/lib/utils/compose.mjs +2 -11
- package/lib/utils/compose.mjs.map +1 -1
- package/lib/utils/createUUID.js +5 -5
- package/lib/utils/createUUID.js.map +1 -1
- package/lib/utils/createUUID.mjs +4 -4
- package/lib/utils/createUUID.mjs.map +1 -1
- package/lib/utils/cssToIntDefault.js +3 -4
- package/lib/utils/cssToIntDefault.js.map +1 -1
- package/lib/utils/cssToIntDefault.mjs +2 -3
- package/lib/utils/cssToIntDefault.mjs.map +1 -1
- package/lib/utils/enhances/WithCSS.d.ts +2 -30
- package/lib/utils/enhances/WithCSS.js +13 -64
- package/lib/utils/enhances/WithCSS.js.map +1 -1
- package/lib/utils/enhances/WithCSS.mjs +9 -59
- package/lib/utils/enhances/WithCSS.mjs.map +1 -1
- package/lib/utils/enhances/WithI18n.d.ts +1 -30
- package/lib/utils/enhances/WithI18n.js +20 -76
- package/lib/utils/enhances/WithI18n.js.map +1 -1
- package/lib/utils/enhances/WithI18n.mjs +16 -63
- package/lib/utils/enhances/WithI18n.mjs.map +1 -1
- package/lib/utils/enhances/a11yEnhance.js +34 -39
- package/lib/utils/enhances/a11yEnhance.js.map +1 -1
- package/lib/utils/enhances/a11yEnhance.mjs +32 -36
- package/lib/utils/enhances/a11yEnhance.mjs.map +1 -1
- package/lib/utils/enhances/animatedSizeEnhance.d.ts +0 -4
- package/lib/utils/enhances/animatedSizeEnhance.js +55 -65
- package/lib/utils/enhances/animatedSizeEnhance.js.map +1 -1
- package/lib/utils/enhances/animatedSizeEnhance.mjs +50 -61
- package/lib/utils/enhances/animatedSizeEnhance.mjs.map +1 -1
- package/lib/utils/enhances/contextEnhance.js +12 -11
- package/lib/utils/enhances/contextEnhance.js.map +1 -1
- package/lib/utils/enhances/contextEnhance.mjs +9 -8
- package/lib/utils/enhances/contextEnhance.mjs.map +1 -1
- package/lib/utils/enhances/i18nEnhance.d.ts +0 -4
- package/lib/utils/enhances/i18nEnhance.js +51 -69
- package/lib/utils/enhances/i18nEnhance.js.map +1 -1
- package/lib/utils/enhances/i18nEnhance.mjs +47 -61
- package/lib/utils/enhances/i18nEnhance.mjs.map +1 -1
- package/lib/utils/enhances/resolveColorEnhance.js +12 -10
- package/lib/utils/enhances/resolveColorEnhance.js.map +1 -1
- package/lib/utils/enhances/resolveColorEnhance.mjs +8 -6
- package/lib/utils/enhances/resolveColorEnhance.mjs.map +1 -1
- package/lib/utils/eventEmitter.d.ts +10 -6
- package/lib/utils/eventEmitter.js +33 -32
- package/lib/utils/eventEmitter.js.map +1 -1
- package/lib/utils/eventEmitter.mjs +30 -31
- package/lib/utils/eventEmitter.mjs.map +1 -1
- package/lib/utils/findComponent.js +35 -42
- package/lib/utils/findComponent.js.map +1 -1
- package/lib/utils/findComponent.mjs +26 -33
- package/lib/utils/findComponent.mjs.map +1 -1
- package/lib/utils/fire.js +7 -13
- package/lib/utils/fire.js.map +1 -1
- package/lib/utils/fire.mjs +5 -11
- package/lib/utils/fire.mjs.map +1 -1
- package/lib/utils/focus-lock/focusBorders.js +28 -32
- package/lib/utils/focus-lock/focusBorders.js.map +1 -1
- package/lib/utils/focus-lock/focusBorders.mjs +26 -32
- package/lib/utils/focus-lock/focusBorders.mjs.map +1 -1
- package/lib/utils/focus-lock/getFocusableIn.js +4 -6
- package/lib/utils/focus-lock/getFocusableIn.js.map +1 -1
- package/lib/utils/focus-lock/getFocusableIn.mjs +3 -6
- package/lib/utils/focus-lock/getFocusableIn.mjs.map +1 -1
- package/lib/utils/focus-lock/isFocusInside.js +5 -6
- package/lib/utils/focus-lock/isFocusInside.js.map +1 -1
- package/lib/utils/focus-lock/isFocusInside.mjs +4 -6
- package/lib/utils/focus-lock/isFocusInside.mjs.map +1 -1
- package/lib/utils/focus-lock/isFocusable.js +9 -12
- package/lib/utils/focus-lock/isFocusable.js.map +1 -1
- package/lib/utils/focus-lock/isFocusable.mjs +8 -11
- package/lib/utils/focus-lock/isFocusable.mjs.map +1 -1
- package/lib/utils/focus-lock/setFocus.js +21 -27
- package/lib/utils/focus-lock/setFocus.js.map +1 -1
- package/lib/utils/focus-lock/setFocus.mjs +19 -25
- package/lib/utils/focus-lock/setFocus.mjs.map +1 -1
- package/lib/utils/getAccessibleName.js +10 -22
- package/lib/utils/getAccessibleName.js.map +1 -1
- package/lib/utils/getAccessibleName.mjs +10 -21
- package/lib/utils/getAccessibleName.mjs.map +1 -1
- package/lib/utils/getDisplayName.js +1 -1
- package/lib/utils/getDisplayName.mjs +3 -5
- package/lib/utils/getEventTarget.js +13 -32
- package/lib/utils/getEventTarget.js.map +1 -1
- package/lib/utils/getEventTarget.mjs +12 -31
- package/lib/utils/getEventTarget.mjs.map +1 -1
- package/lib/utils/getOriginChildren.js +4 -4
- package/lib/utils/getOriginChildren.js.map +1 -1
- package/lib/utils/getRandomInt.js +1 -1
- package/lib/utils/getValue.js +4 -6
- package/lib/utils/getValue.js.map +1 -1
- package/lib/utils/getValue.mjs +3 -5
- package/lib/utils/getValue.mjs.map +1 -1
- package/lib/utils/hasLabels.js +16 -27
- package/lib/utils/hasLabels.js.map +1 -1
- package/lib/utils/hasLabels.mjs +14 -24
- package/lib/utils/hasLabels.mjs.map +1 -1
- package/lib/utils/hasParent.js +3 -2
- package/lib/utils/hasParent.js.map +1 -1
- package/lib/utils/hasParent.mjs +2 -3
- package/lib/utils/hasParent.mjs.map +1 -1
- package/lib/utils/ifChildren.js +6 -4
- package/lib/utils/ifChildren.js.map +1 -1
- package/lib/utils/ifChildren.mjs +4 -2
- package/lib/utils/ifChildren.mjs.map +1 -1
- package/lib/utils/injectStyle.js +11 -13
- package/lib/utils/injectStyle.js.map +1 -1
- package/lib/utils/injectStyle.mjs +9 -10
- package/lib/utils/injectStyle.mjs.map +1 -1
- package/lib/utils/inputProps.js +5 -5
- package/lib/utils/inputProps.js.map +1 -1
- package/lib/utils/inputProps.mjs +4 -4
- package/lib/utils/inputProps.mjs.map +1 -1
- package/lib/utils/isInteractiveElement.js +7 -9
- package/lib/utils/isInteractiveElement.js.map +1 -1
- package/lib/utils/isInteractiveElement.mjs +7 -9
- package/lib/utils/isInteractiveElement.mjs.map +1 -1
- package/lib/utils/isNode.js +4 -5
- package/lib/utils/isNode.js.map +1 -1
- package/lib/utils/isNode.mjs +1 -2
- package/lib/utils/isNode.mjs.map +1 -1
- package/lib/utils/isPromise.js +1 -1
- package/lib/utils/isRetina.js +7 -2
- package/lib/utils/isRetina.js.map +1 -1
- package/lib/utils/isRetina.mjs +6 -1
- package/lib/utils/isRetina.mjs.map +1 -1
- package/lib/utils/logger.js +18 -25
- package/lib/utils/logger.js.map +1 -1
- package/lib/utils/logger.mjs +13 -21
- package/lib/utils/logger.mjs.map +1 -1
- package/lib/utils/numericChecker.js +11 -18
- package/lib/utils/numericChecker.js.map +1 -1
- package/lib/utils/numericChecker.mjs +10 -17
- package/lib/utils/numericChecker.mjs.map +1 -1
- package/lib/utils/ownerDocument.js +2 -2
- package/lib/utils/ownerDocument.js.map +1 -1
- package/lib/utils/ownerDocument.mjs +1 -1
- package/lib/utils/ownerDocument.mjs.map +1 -1
- package/lib/utils/pick.js +5 -5
- package/lib/utils/pick.js.map +1 -1
- package/lib/utils/pick.mjs +4 -4
- package/lib/utils/pick.mjs.map +1 -1
- package/lib/utils/propsForElement.js +10 -12
- package/lib/utils/propsForElement.js.map +1 -1
- package/lib/utils/propsForElement.mjs +8 -10
- package/lib/utils/propsForElement.mjs.map +1 -1
- package/lib/utils/rafTrottle.js +9 -14
- package/lib/utils/rafTrottle.js.map +1 -1
- package/lib/utils/rafTrottle.mjs +7 -12
- package/lib/utils/rafTrottle.mjs.map +1 -1
- package/lib/utils/reactToText.js +5 -8
- package/lib/utils/reactToText.js.map +1 -1
- package/lib/utils/reactToText.mjs +3 -6
- package/lib/utils/reactToText.mjs.map +1 -1
- package/lib/utils/ref.d.ts +1 -3
- package/lib/utils/ref.js +29 -61
- package/lib/utils/ref.js.map +1 -1
- package/lib/utils/ref.mjs +27 -57
- package/lib/utils/ref.mjs.map +1 -1
- package/lib/utils/setRef.js +2 -2
- package/lib/utils/setRef.js.map +1 -1
- package/lib/utils/syncScroll.js +24 -24
- package/lib/utils/syncScroll.js.map +1 -1
- package/lib/utils/syncScroll.mjs +21 -21
- package/lib/utils/syncScroll.mjs.map +1 -1
- package/lib/utils/uncontroll.js +8 -18
- package/lib/utils/uncontroll.js.map +1 -1
- package/lib/utils/uncontroll.mjs +8 -17
- package/lib/utils/uncontroll.mjs.map +1 -1
- package/lib/utils/uniqueID.d.ts +0 -4
- package/lib/utils/uniqueID.js +23 -30
- package/lib/utils/uniqueID.js.map +1 -1
- package/lib/utils/uniqueID.mjs +19 -29
- package/lib/utils/uniqueID.mjs.map +1 -1
- package/lib/utils/use/useColorResolver.js +20 -21
- package/lib/utils/use/useColorResolver.js.map +1 -1
- package/lib/utils/use/useColorResolver.mjs +16 -18
- package/lib/utils/use/useColorResolver.mjs.map +1 -1
- package/lib/utils/use/useEnhancedEffect.d.ts +1 -1
- package/lib/utils/use/useEnhancedEffect.js +4 -4
- package/lib/utils/use/useEnhancedEffect.js.map +1 -1
- package/lib/utils/use/useEnhancedEffect.mjs +1 -1
- package/lib/utils/use/useEnhancedEffect.mjs.map +1 -1
- package/lib/utils/use/useEventCallback.js +5 -10
- package/lib/utils/use/useEventCallback.js.map +1 -1
- package/lib/utils/use/useEventCallback.mjs +3 -8
- package/lib/utils/use/useEventCallback.mjs.map +1 -1
- package/lib/utils/use/useEventListener.js +11 -15
- package/lib/utils/use/useEventListener.js.map +1 -1
- package/lib/utils/use/useEventListener.mjs +7 -11
- package/lib/utils/use/useEventListener.mjs.map +1 -1
- package/lib/utils/use/useFocusLock.js +80 -94
- package/lib/utils/use/useFocusLock.js.map +1 -1
- package/lib/utils/use/useFocusLock.mjs +71 -88
- package/lib/utils/use/useFocusLock.mjs.map +1 -1
- package/lib/utils/use/usePreventScroll.js +26 -28
- package/lib/utils/use/usePreventScroll.js.map +1 -1
- package/lib/utils/use/usePreventScroll.mjs +21 -23
- package/lib/utils/use/usePreventScroll.mjs.map +1 -1
- package/lib/utils/use/useScrollBarWidth.js +8 -14
- package/lib/utils/use/useScrollBarWidth.js.map +1 -1
- package/lib/utils/use/useScrollBarWidth.mjs +8 -13
- package/lib/utils/use/useScrollBarWidth.mjs.map +1 -1
- package/lib/utils/useCssVariable.js +32 -37
- package/lib/utils/useCssVariable.js.map +1 -1
- package/lib/utils/useCssVariable.mjs +27 -34
- package/lib/utils/useCssVariable.mjs.map +1 -1
- package/lib/utils/zIndexStacking.d.ts +3 -1
- package/lib/utils/zIndexStacking.js +28 -24
- package/lib/utils/zIndexStacking.js.map +1 -1
- package/lib/utils/zIndexStacking.mjs +23 -22
- package/lib/utils/zIndexStacking.mjs.map +1 -1
- package/package.json +129 -129
- package/lib/enhancement/bindHandler.d.ts +0 -5
- package/lib/enhancement/bindHandler.js +0 -53
- package/lib/enhancement/bindHandler.js.map +0 -1
- package/lib/enhancement/bindHandler.mjs +0 -48
- package/lib/enhancement/bindHandler.mjs.map +0 -1
- package/lib/enhancement/hoistProps.d.ts +0 -10
- package/lib/enhancement/hoistProps.js +0 -95
- package/lib/enhancement/hoistProps.js.map +0 -1
- package/lib/enhancement/hoistProps.mjs +0 -78
- package/lib/enhancement/hoistProps.mjs.map +0 -1
- package/lib/esm/enhancement/bindHandler.mjs +0 -48
- package/lib/esm/enhancement/hoistProps.mjs +0 -78
- package/lib/esm/utils/createHoc.mjs +0 -42
- package/lib/esm/utils/getDisplayName.mjs +0 -6
- package/lib/utils/ScreenReaderOnly.d.ts +0 -8
- package/lib/utils/ScreenReaderOnly.js +0 -30
- package/lib/utils/ScreenReaderOnly.js.map +0 -1
- package/lib/utils/ScreenReaderOnly.mjs +0 -24
- package/lib/utils/ScreenReaderOnly.mjs.map +0 -1
- package/lib/utils/createHoc.d.ts +0 -3
- package/lib/utils/createHoc.js +0 -52
- package/lib/utils/createHoc.js.map +0 -1
- package/lib/utils/createHoc.mjs +0 -42
- package/lib/utils/createHoc.mjs.map +0 -1
- package/lib/utils/enhances/WithAutoFocus.d.ts +0 -14
- package/lib/utils/enhances/WithAutoFocus.js +0 -72
- package/lib/utils/enhances/WithAutoFocus.js.map +0 -1
- package/lib/utils/enhances/WithAutoFocus.mjs +0 -66
- package/lib/utils/enhances/WithAutoFocus.mjs.map +0 -1
- package/lib/utils/enhances/WithKeyboardFocus.d.ts +0 -46
- package/lib/utils/enhances/WithKeyboardFocus.js +0 -94
- package/lib/utils/enhances/WithKeyboardFocus.js.map +0 -1
- package/lib/utils/enhances/WithKeyboardFocus.mjs +0 -88
- package/lib/utils/enhances/WithKeyboardFocus.mjs.map +0 -1
- package/lib/utils/enhances/WithRef.d.ts +0 -3
- package/lib/utils/enhances/WithRef.js +0 -25
- package/lib/utils/enhances/WithRef.js.map +0 -1
- package/lib/utils/enhances/WithRef.mjs +0 -18
- package/lib/utils/enhances/WithRef.mjs.map +0 -1
- package/lib/utils/enhances/autoFocusEnhance.d.ts +0 -10
- package/lib/utils/enhances/autoFocusEnhance.js +0 -45
- package/lib/utils/enhances/autoFocusEnhance.js.map +0 -1
- package/lib/utils/enhances/autoFocusEnhance.mjs +0 -38
- package/lib/utils/enhances/autoFocusEnhance.mjs.map +0 -1
- package/lib/utils/enhances/keyboardFocusEnhance.d.ts +0 -27
- package/lib/utils/enhances/keyboardFocusEnhance.js +0 -63
- package/lib/utils/enhances/keyboardFocusEnhance.js.map +0 -1
- package/lib/utils/enhances/keyboardFocusEnhance.mjs +0 -57
- package/lib/utils/enhances/keyboardFocusEnhance.mjs.map +0 -1
- package/lib/utils/if.d.ts +0 -11
- package/lib/utils/if.js +0 -15
- package/lib/utils/if.js.map +0 -1
- package/lib/utils/if.mjs +0 -9
- package/lib/utils/if.mjs.map +0 -1
- package/lib/utils/use/useCss.d.ts +0 -4
- package/lib/utils/use/useCss.js +0 -19
- package/lib/utils/use/useCss.js.map +0 -1
- package/lib/utils/use/useCss.mjs +0 -12
- package/lib/utils/use/useCss.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"focusBorders.js","names":["_getFocusableIn","require","focusBordersRefs","Map","BEFORE_BORDER_ID","exports","AFTER_BORDER_ID","addFocusBorders","element","has","previousSibling","HTMLElement","dataset","id","before","document","createElement","after","set","setAttribute","style","position","addEventListener","event","
|
|
1
|
+
{"version":3,"file":"focusBorders.js","names":["_getFocusableIn","require","focusBordersRefs","Map","BEFORE_BORDER_ID","exports","AFTER_BORDER_ID","addFocusBorders","element","has","previousSibling","HTMLElement","dataset","id","before","document","createElement","after","set","setAttribute","style","position","addEventListener","event","activeElement","get","relatedTarget","focusable","getFocusableIn","length","focus","elementParent","parentElement","insertBefore","append","removeFocusBorders","focusRefs","remove","delete"],"sources":["../../../src/utils/focus-lock/focusBorders.ts"],"sourcesContent":["import { getFocusableIn } from './getFocusableIn';\n\nconst focusBordersRefs = new Map<HTMLElement, { before: HTMLElement; after: HTMLElement }>();\n\nexport const BEFORE_BORDER_ID = '__intergalactic-focus-border-before';\nexport const AFTER_BORDER_ID = '__intergalactic-focus-border-after';\n\nexport const addFocusBorders = (element: HTMLElement) => {\n if (\n !focusBordersRefs.has(element) &&\n !(\n element.previousSibling instanceof HTMLElement &&\n element.previousSibling.dataset.id === BEFORE_BORDER_ID\n )\n ) {\n const before = document.createElement('div');\n const after = document.createElement('div');\n\n focusBordersRefs.set(element, { before, after });\n\n before.setAttribute('tabindex', '0');\n before.style.position = 'fixed';\n before.dataset.id = BEFORE_BORDER_ID;\n before.addEventListener('focus', (event) => {\n if (\n document.activeElement === focusBordersRefs.get(element)?.before &&\n event.relatedTarget !== focusBordersRefs.get(element)?.after && // prevent loop\n event.relatedTarget // prevent initial focus\n ) {\n const focusable = getFocusableIn(element);\n\n if (event.relatedTarget === focusable[0]) {\n focusable[focusable.length - 1]?.focus();\n } else {\n focusable[0]?.focus();\n }\n }\n });\n\n after.setAttribute('tabindex', '0');\n after.style.position = 'fixed';\n after.dataset.id = AFTER_BORDER_ID;\n after.addEventListener('focus', (event) => {\n if (\n document.activeElement === focusBordersRefs.get(element)?.after &&\n event.relatedTarget !== focusBordersRefs.get(element)?.before && // prevent loop\n event.relatedTarget // prevent initial focus\n ) {\n const focusable = getFocusableIn(element);\n\n if (event.relatedTarget === focusable[focusable.length - 1]) {\n focusable[0]?.focus();\n } else {\n focusable[focusable.length - 1]?.focus();\n }\n }\n });\n\n const elementParent = element.parentElement;\n\n elementParent?.insertBefore(before, element);\n elementParent?.append(after);\n }\n};\nexport const removeFocusBorders = (element: HTMLElement) => {\n const focusRefs = focusBordersRefs.get(element);\n focusRefs?.before.remove();\n focusRefs?.after.remove();\n focusBordersRef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B,IAAK;EAC1D,MAAM4B,SAAS,GAAGlC,gBAAgB,CAACuB,GAAG,CAACjB,OAAO,CAAC;EAC/C4B,SAAS,EAAEtB,MAAM,CAACuB,MAAM,CAAC,CAAC;EAC1BD,SAAS,EAAEnB,KAAK,CAACoB,MAAM,CAAC,CAAC;EACzBnC,gBAAgB,CAACoC,MAAM,CAAC9B,OAAO,CAAC;AAClC,CAAC;AAACH,OAAA,CAAA8B,kBAAA,GAAAA,kBAAA","ignoreList":[]}
|
|
@@ -1,62 +1,56 @@
|
|
|
1
1
|
import { getFocusableIn } from "./getFocusableIn.mjs";
|
|
2
|
-
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
2
|
+
const focusBordersRefs = new Map();
|
|
3
|
+
export const BEFORE_BORDER_ID = '__intergalactic-focus-border-before';
|
|
4
|
+
export const AFTER_BORDER_ID = '__intergalactic-focus-border-after';
|
|
5
|
+
export const addFocusBorders = element => {
|
|
6
6
|
if (!focusBordersRefs.has(element) && !(element.previousSibling instanceof HTMLElement && element.previousSibling.dataset.id === BEFORE_BORDER_ID)) {
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
const before = document.createElement('div');
|
|
8
|
+
const after = document.createElement('div');
|
|
9
9
|
focusBordersRefs.set(element, {
|
|
10
|
-
before
|
|
11
|
-
after
|
|
10
|
+
before,
|
|
11
|
+
after
|
|
12
12
|
});
|
|
13
13
|
before.setAttribute('tabindex', '0');
|
|
14
14
|
before.style.position = 'fixed';
|
|
15
15
|
before.dataset.id = BEFORE_BORDER_ID;
|
|
16
|
-
before.addEventListener('focus',
|
|
17
|
-
|
|
18
|
-
if (document.activeElement === ((_focusBordersRefs$get = focusBordersRefs.get(element)) === null || _focusBordersRefs$get === void 0 ? void 0 : _focusBordersRefs$get.before) && event.relatedTarget !== ((_focusBordersRefs$get2 = focusBordersRefs.get(element)) === null || _focusBordersRefs$get2 === void 0 ? void 0 : _focusBordersRefs$get2.after) &&
|
|
16
|
+
before.addEventListener('focus', event => {
|
|
17
|
+
if (document.activeElement === focusBordersRefs.get(element)?.before && event.relatedTarget !== focusBordersRefs.get(element)?.after &&
|
|
19
18
|
// prevent loop
|
|
20
19
|
event.relatedTarget // prevent initial focus
|
|
21
20
|
) {
|
|
22
|
-
|
|
21
|
+
const focusable = getFocusableIn(element);
|
|
23
22
|
if (event.relatedTarget === focusable[0]) {
|
|
24
|
-
|
|
25
|
-
(_focusable = focusable[focusable.length - 1]) === null || _focusable === void 0 || _focusable.focus();
|
|
23
|
+
focusable[focusable.length - 1]?.focus();
|
|
26
24
|
} else {
|
|
27
|
-
|
|
28
|
-
(_focusable$ = focusable[0]) === null || _focusable$ === void 0 || _focusable$.focus();
|
|
25
|
+
focusable[0]?.focus();
|
|
29
26
|
}
|
|
30
27
|
}
|
|
31
28
|
});
|
|
32
29
|
after.setAttribute('tabindex', '0');
|
|
33
30
|
after.style.position = 'fixed';
|
|
34
31
|
after.dataset.id = AFTER_BORDER_ID;
|
|
35
|
-
after.addEventListener('focus',
|
|
36
|
-
|
|
37
|
-
if (document.activeElement === ((_focusBordersRefs$get3 = focusBordersRefs.get(element)) === null || _focusBordersRefs$get3 === void 0 ? void 0 : _focusBordersRefs$get3.after) && event.relatedTarget !== ((_focusBordersRefs$get4 = focusBordersRefs.get(element)) === null || _focusBordersRefs$get4 === void 0 ? void 0 : _focusBordersRefs$get4.before) &&
|
|
32
|
+
after.addEventListener('focus', event => {
|
|
33
|
+
if (document.activeElement === focusBordersRefs.get(element)?.after && event.relatedTarget !== focusBordersRefs.get(element)?.before &&
|
|
38
34
|
// prevent loop
|
|
39
35
|
event.relatedTarget // prevent initial focus
|
|
40
36
|
) {
|
|
41
|
-
|
|
37
|
+
const focusable = getFocusableIn(element);
|
|
42
38
|
if (event.relatedTarget === focusable[focusable.length - 1]) {
|
|
43
|
-
|
|
44
|
-
(_focusable$2 = focusable[0]) === null || _focusable$2 === void 0 || _focusable$2.focus();
|
|
39
|
+
focusable[0]?.focus();
|
|
45
40
|
} else {
|
|
46
|
-
|
|
47
|
-
(_focusable2 = focusable[focusable.length - 1]) === null || _focusable2 === void 0 || _focusable2.focus();
|
|
41
|
+
focusable[focusable.length - 1]?.focus();
|
|
48
42
|
}
|
|
49
43
|
}
|
|
50
44
|
});
|
|
51
|
-
|
|
52
|
-
elementParent
|
|
53
|
-
elementParent
|
|
45
|
+
const elementParent = element.parentElement;
|
|
46
|
+
elementParent?.insertBefore(before, element);
|
|
47
|
+
elementParent?.append(after);
|
|
54
48
|
}
|
|
55
49
|
};
|
|
56
|
-
export
|
|
57
|
-
|
|
58
|
-
focusRefs
|
|
59
|
-
focusRefs
|
|
60
|
-
focusBordersRefs
|
|
50
|
+
export const removeFocusBorders = element => {
|
|
51
|
+
const focusRefs = focusBordersRefs.get(element);
|
|
52
|
+
focusRefs?.before.remove();
|
|
53
|
+
focusRefs?.after.remove();
|
|
54
|
+
focusBordersRefs.delete(element);
|
|
61
55
|
};
|
|
62
56
|
//# sourceMappingURL=focusBorders.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"focusBorders.mjs","names":["getFocusableIn","focusBordersRefs","Map","BEFORE_BORDER_ID","AFTER_BORDER_ID","addFocusBorders","element","has","previousSibling","HTMLElement","dataset","id","before","document","createElement","after","set","setAttribute","style","position","addEventListener","event","
|
|
1
|
+
{"version":3,"file":"focusBorders.mjs","names":["getFocusableIn","focusBordersRefs","Map","BEFORE_BORDER_ID","AFTER_BORDER_ID","addFocusBorders","element","has","previousSibling","HTMLElement","dataset","id","before","document","createElement","after","set","setAttribute","style","position","addEventListener","event","activeElement","get","relatedTarget","focusable","length","focus","elementParent","parentElement","insertBefore","append","removeFocusBorders","focusRefs","remove","delete"],"sources":["../../../src/utils/focus-lock/focusBorders.ts"],"sourcesContent":["import { getFocusableIn } from './getFocusableIn';\n\nconst focusBordersRefs = new Map<HTMLElement, { before: HTMLElement; after: HTMLElement }>();\n\nexport const BEFORE_BORDER_ID = '__intergalactic-focus-border-before';\nexport const AFTER_BORDER_ID = '__intergalactic-focus-border-after';\n\nexport const addFocusBorders = (element: HTMLElement) => {\n if (\n !focusBordersRefs.has(element) &&\n !(\n element.previousSibling instanceof HTMLElement &&\n element.previousSibling.dataset.id === BEFORE_BORDER_ID\n )\n ) {\n const before = document.createElement('div');\n const after = document.createElement('div');\n\n focusBordersRefs.set(element, { before, after });\n\n before.setAttribute('tabindex', '0');\n before.style.position = 'fixed';\n before.dataset.id = BEFORE_BORDER_ID;\n before.addEventListener('focus', (event) => {\n if (\n document.activeElement === focusBordersRefs.get(element)?.before &&\n event.relatedTarget !== focusBordersRefs.get(element)?.after && // prevent loop\n event.relatedTarget // prevent initial focus\n ) {\n const focusable = getFocusableIn(element);\n\n if (event.relatedTarget === focusable[0]) {\n focusable[focusable.length - 1]?.focus();\n } else {\n focusable[0]?.focus();\n }\n }\n });\n\n after.setAttribute('tabindex', '0');\n after.style.position = 'fixed';\n after.dataset.id = AFTER_BORDER_ID;\n after.addEventListener('focus', (event) => {\n if (\n document.activeElement === focusBordersRefs.get(element)?.after &&\n event.relatedTarget !== focusBordersRefs.get(element)?.before && // prevent loop\n event.relatedTarget // prevent initial focus\n ) {\n const focusable = getFocusableIn(element);\n\n if (event.relatedTarget === focusable[focusable.length - 1]) {\n focusable[0]?.focus();\n } else {\n focusable[focusable.length - 1]?.focus();\n }\n }\n });\n\n const elementParent = element.parentElement;\n\n elementParent?.insertBefore(before, element);\n elementParent?.append(after);\n }\n};\nexport const removeFocusBorders = (element: HTMLElement) => {\n const focusRefs = focusBordersRefs.get(element);\n focusRefs?.before.remove();\n focusRefs?.after.remove();\n focusBordersRefs.delete(element);\n};\n"],"mappings":"AAAA,SAASA,cAAc,QAAQ,sBAAkB;AAEjD,MAAMC,gBAAgB,GAAG,IAAIC,GAAG,CAA2D,CAAC;AAE5F,OAAO,MAAMC,gBAAgB,GAAG,qCAAqC;AACrE,OAAO,MAAMC,eAAe,GAAG,oCAAoC;AAEnE,OAAO,MAAMC,e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ule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.getFocusableIn = void 0;
|
|
7
7
|
var _isFocusable = require("./isFocusable");
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
return 'ownerSVGElement' in node && node.ownerSVGElement ? NodeFilter.FILTER_REJECT : NodeFilter.FILTER_ACCEPT;
|
|
12
|
-
});
|
|
13
|
-
var result = [];
|
|
8
|
+
const getFocusableIn = node => {
|
|
9
|
+
const treeWalker = node?.ownerDocument?.createTreeWalker(node, NodeFilter.SHOW_ELEMENT, node => 'ownerSVGElement' in node && node.ownerSVGElement ? NodeFilter.FILTER_REJECT : NodeFilter.FILTER_ACCEPT);
|
|
10
|
+
const result = [];
|
|
14
11
|
if (!treeWalker) return result;
|
|
15
12
|
if ((0, _isFocusable.isFocusable)(treeWalker.currentNode)) {
|
|
16
13
|
result.push(treeWalker.currentNode);
|
|
@@ -22,4 +19,5 @@ var getFocusableIn = exports.getFocusableIn = function getFocusableIn(node) {
|
|
|
22
19
|
}
|
|
23
20
|
return result;
|
|
24
21
|
};
|
|
22
|
+
exports.getFocusableIn = getFocusableIn;
|
|
25
23
|
//# sourceMappingURL=getFocusableIn.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getFocusableIn.js","names":["_isFocusable","require","getFocusableIn","
|
|
1
|
+
{"version":3,"file":"getFocusableIn.js","names":["_isFocusable","require","getFocusableIn","node","treeWalker","ownerDocument","createTreeWalker","NodeFilter","SHOW_ELEMENT","ownerSVGElement","FILTER_REJECT","FILTER_ACCEPT","result","isFocusable","currentNode","push","nextNode","exports"],"sources":["../../../src/utils/focus-lock/getFocusableIn.ts"],"sourcesContent":["import { isFocusable } from './isFocusable';\n\nexport const getFocusableIn = (node: HTMLElement) => {\n const treeWalker = node?.ownerDocument?.createTreeWalker(node, NodeFilter.SHOW_ELEMENT, (node) =>\n 'ownerSVGElement' in node && node.ownerSVGElement\n ? NodeFilter.FILTER_REJECT\n : NodeFilter.FILTER_ACCEPT,\n );\n\n const result: HTMLElement[] = [];\n\n if (!treeWalker) return result;\n if (isFocusable(treeWalker.currentNode)) {\n result.push(treeWalker.currentNode as HTMLElement);\n }\n while (treeWalker.nextNode() !== null) {\n if (isFocusable(treeWalker.currentNode)) {\n result.push(treeWalker.currentNode as HTMLElement);\n }\n }\n\n return result;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEO,MAAMC,cAAc,GAAIC,IAAiB,IAAK;EACnD,MAAMC,UAAU,GAAGD,IAAI,EAAEE,aAAa,EAAEC,gBAAgB,CAACH,IAAI,EAAEI,UAAU,CAACC,YAAY,EAAGL,IAAI,IAC3F,iBAAiB,IAAIA,IAAI,IAAIA,IAAI,CAACM,eAAe,GAC7CF,UAAU,CAACG,aAAa,GACxBH,UAAU,CAACI,aACjB,CAAC;EAED,MAAMC,MAAqB,GAAG,EAAE;EAEhC,IAAI,CAACR,UAAU,EAAE,OAAOQ,MAAM;EAC9B,IAAI,IAAAC,wBAAW,EAACT,UAAU,CAACU,WAAW,CAAC,EAAE;IACvCF,MAAM,CAACG,IAAI,CAACX,UAAU,CAACU,WAA0B,CAAC;EACpD;EACA,OAAOV,UAAU,CAACY,QAAQ,CAAC,CAAC,KAAK,IAAI,EAAE;IACrC,IAAI,IAAAH,wBAAW,EAACT,UAAU,CAACU,WAAW,CAAC,EAAE;MACvCF,MAAM,CAACG,IAAI,CAACX,UAAU,CAACU,WAA0B,CAAC;IACpD;EACF;EAEA,OAAOF,MAAM;AACf,CAAC;AAACK,OAAA,CAAAf,cAAA,GAAAA,cAAA","ignoreList":[]}
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { isFocusable } from "./isFocusable.mjs";
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
return 'ownerSVGElement' in node && node.ownerSVGElement ? NodeFilter.FILTER_REJECT : NodeFilter.FILTER_ACCEPT;
|
|
6
|
-
});
|
|
7
|
-
var result = [];
|
|
2
|
+
export const getFocusableIn = node => {
|
|
3
|
+
const treeWalker = node?.ownerDocument?.createTreeWalker(node, NodeFilter.SHOW_ELEMENT, node => 'ownerSVGElement' in node && node.ownerSVGElement ? NodeFilter.FILTER_REJECT : NodeFilter.FILTER_ACCEPT);
|
|
4
|
+
const result = [];
|
|
8
5
|
if (!treeWalker) return result;
|
|
9
6
|
if (isFocusable(treeWalker.currentNode)) {
|
|
10
7
|
result.push(treeWalker.currentNode);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getFocusableIn.mjs","names":["isFocusable","getFocusableIn","node","
|
|
1
|
+
{"version":3,"file":"getFocusableIn.mjs","names":["isFocusable","getFocusableIn","node","treeWalker","ownerDocument","createTreeWalker","NodeFilter","SHOW_ELEMENT","ownerSVGElement","FILTER_REJECT","FILTER_ACCEPT","result","currentNode","push","nextNode"],"sources":["../../../src/utils/focus-lock/getFocusableIn.ts"],"sourcesContent":["import { isFocusable } from './isFocusable';\n\nexport const getFocusableIn = (node: HTMLElement) => {\n const treeWalker = node?.ownerDocument?.createTreeWalker(node, NodeFilter.SHOW_ELEMENT, (node) =>\n 'ownerSVGElement' in node && node.ownerSVGElement\n ? NodeFilter.FILTER_REJECT\n : NodeFilter.FILTER_ACCEPT,\n );\n\n const result: HTMLElement[] = [];\n\n if (!treeWalker) return result;\n if (isFocusable(treeWalker.currentNode)) {\n result.push(treeWalker.currentNode as HTMLElement);\n }\n while (treeWalker.nextNode() !== null) {\n if (isFocusable(treeWalker.currentNode)) {\n result.push(treeWalker.currentNode as HTMLElement);\n }\n }\n\n return result;\n};\n"],"mappings":"AAAA,SAASA,WAAW,QAAQ,mBAAe;AAE3C,OAAO,MAAMC,cAAc,GAAIC,IAAiB,IAAK;EACnD,MAAMC,UAAU,GAAGD,IAAI,EAAEE,aAAa,EAAEC,gBAAgB,CAACH,IAAI,EAAEI,UAAU,CAACC,YAAY,EAAGL,IAAI,IAC3F,iBAAiB,IAAIA,IAAI,IAAIA,IAAI,CAACM,eAAe,GAC7CF,UAAU,CAACG,aAAa,GACxBH,UAAU,CAACI,aACjB,CAAC;EAED,MAAMC,MAAqB,GAAG,EAAE;EAEhC,IAAI,CAACR,UAAU,EAAE,OAAOQ,MAAM;EAC9B,IAAIX,WAAW,CAACG,UAAU,CAACS,WAAW,CAAC,EAAE;IACvCD,MAAM,CAACE,IAAI,CAACV,UAAU,CAACS,WAA0B,CAAC;EACpD;EACA,OAAOT,UAAU,CAACW,QAAQ,CAAC,CAAC,KAAK,IAAI,EAAE;IACrC,IAAId,WAAW,CAACG,UAAU,CAACS,WAAW,CAAC,EAAE;MACvCD,MAAM,CAACE,IAAI,CAACV,UAAU,CAACS,WAA0B,CAAC;IACpD;EACF;EAEA,OAAOD,MAAM;AACf,CAAC","ignoreList":[]}
|
|
@@ -5,11 +5,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.isFocusInside = void 0;
|
|
7
7
|
var _hasParent = require("../hasParent");
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
return nodes.some(
|
|
12
|
-
return (0, _hasParent.hasParent)(activeElement, node);
|
|
13
|
-
});
|
|
8
|
+
const isFocusInside = (topNode, actualActiveElement) => {
|
|
9
|
+
const activeElement = actualActiveElement || document.activeElement;
|
|
10
|
+
const nodes = Array.isArray(topNode) ? topNode : [topNode];
|
|
11
|
+
return nodes.some(node => (0, _hasParent.hasParent)(activeElement, node));
|
|
14
12
|
};
|
|
13
|
+
exports.isFocusInside = isFocusInside;
|
|
15
14
|
//# sourceMappingURL=isFocusInside.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isFocusInside.js","names":["_hasParent","require","isFocusInside","
|
|
1
|
+
{"version":3,"file":"isFocusInside.js","names":["_hasParent","require","isFocusInside","topNode","actualActiveElement","activeElement","document","nodes","Array","isArray","some","node","hasParent","exports"],"sources":["../../../src/utils/focus-lock/isFocusInside.ts"],"sourcesContent":["import { hasParent } from '../hasParent';\n\nexport const isFocusInside = (\n topNode: HTMLElement | HTMLElement[],\n actualActiveElement?: HTMLElement,\n): boolean => {\n const activeElement = actualActiveElement || document.activeElement;\n const nodes = Array.isArray(topNode) ? topNode : [topNode];\n return nodes.some((node) => hasParent(activeElement, node));\n};\n"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AAEO,MAAMC,aAAa,GAAGA,CAC3BC,OAAoC,EACpCC,mBAAiC,KACrB;EACZ,MAAMC,aAAa,GAAGD,mBAAmB,IAAIE,QAAQ,CAACD,aAAa;EACnE,MAAME,KAAK,GAAGC,KAAK,CAACC,OAAO,CAACN,OAAO,CAAC,GAAGA,OAAO,GAAG,CAACA,OAAO,CAAC;EAC1D,OAAOI,KAAK,CAACG,IAAI,CAAEC,IAAI,IAAK,IAAAC,oBAAS,EAACP,aAAa,EAAEM,IAAI,CAAC,CAAC;AAC7D,CAAC;AAACE,OAAA,CAAAX,aAAA,GAAAA,aAAA","ignoreList":[]}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { hasParent } from "../hasParent.mjs";
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
return nodes.some(
|
|
6
|
-
return hasParent(activeElement, node);
|
|
7
|
-
});
|
|
2
|
+
export const isFocusInside = (topNode, actualActiveElement) => {
|
|
3
|
+
const activeElement = actualActiveElement || document.activeElement;
|
|
4
|
+
const nodes = Array.isArray(topNode) ? topNode : [topNode];
|
|
5
|
+
return nodes.some(node => hasParent(activeElement, node));
|
|
8
6
|
};
|
|
9
7
|
//# sourceMappingURL=isFocusInside.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isFocusInside.mjs","names":["hasParent","isFocusInside","topNode","actualActiveElement","activeElement","document","nodes","Array","isArray","some","node"],"sources":["../../../src/utils/focus-lock/isFocusInside.ts"],"sourcesContent":["import { hasParent } from '../hasParent';\n\nexport const isFocusInside = (\n topNode: HTMLElement | HTMLElement[],\n actualActiveElement?: HTMLElement,\n): boolean => {\n const activeElement = actualActiveElement || document.activeElement;\n const nodes = Array.isArray(topNode) ? topNode : [topNode];\n return nodes.some((node) => hasParent(activeElement, node));\n};\n"],"mappings":"AAAA,SAASA,SAAS,QAAQ,kBAAc;AAExC,OAAO,
|
|
1
|
+
{"version":3,"file":"isFocusInside.mjs","names":["hasParent","isFocusInside","topNode","actualActiveElement","activeElement","document","nodes","Array","isArray","some","node"],"sources":["../../../src/utils/focus-lock/isFocusInside.ts"],"sourcesContent":["import { hasParent } from '../hasParent';\n\nexport const isFocusInside = (\n topNode: HTMLElement | HTMLElement[],\n actualActiveElement?: HTMLElement,\n): boolean => {\n const activeElement = actualActiveElement || document.activeElement;\n const nodes = Array.isArray(topNode) ? topNode : [topNode];\n return nodes.some((node) => hasParent(activeElement, node));\n};\n"],"mappings":"AAAA,SAASA,SAAS,QAAQ,kBAAc;AAExC,OAAO,MAAMC,aAAa,GAAGA,CAC3BC,OAAoC,EACpCC,mBAAiC,KACrB;EACZ,MAAMC,aAAa,GAAGD,mBAAmB,IAAIE,QAAQ,CAACD,aAAa;EACnE,MAAME,KAAK,GAAGC,KAAK,CAACC,OAAO,CAACN,OAAO,CAAC,GAAGA,OAAO,GAAG,CAACA,OAAO,CAAC;EAC1D,OAAOI,KAAK,CAACG,IAAI,CAAEC,IAAI,IAAKV,SAAS,CAACI,aAAa,EAAEM,IAAI,CAAC,CAAC;AAC7D,CAAC","ignoreList":[]}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports.isFocusable = void 0;
|
|
8
|
-
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
9
7
|
var _focusBorders = require("./focusBorders");
|
|
10
|
-
|
|
8
|
+
const focusable = [['BUTTON'], ['SELECT'], ['TEXTAREA'], ['INPUT'], ['A', {
|
|
11
9
|
has: 'href'
|
|
12
10
|
}], ['AREA', {
|
|
13
11
|
has: 'href'
|
|
@@ -22,29 +20,28 @@ var focusable = [['BUTTON'], ['SELECT'], ['TEXTAREA'], ['INPUT'], ['A', {
|
|
|
22
20
|
}], [{
|
|
23
21
|
has: 'autofocus'
|
|
24
22
|
}]];
|
|
25
|
-
|
|
26
|
-
var _node$ownerDocument$d;
|
|
23
|
+
const isFocusable = node => {
|
|
27
24
|
if (!node) return false;
|
|
28
25
|
if (!node.ownerDocument) return false;
|
|
29
|
-
if (!
|
|
26
|
+
if (!node.ownerDocument.defaultView?.HTMLElement) return false;
|
|
30
27
|
if (!(node instanceof node.ownerDocument.defaultView.HTMLElement || node instanceof node.ownerDocument.defaultView.SVGElement)) return false;
|
|
31
28
|
if (node.hasAttribute('disabled')) return false;
|
|
32
29
|
if (node.getAttribute('tabindex') === '-1') return false;
|
|
33
30
|
if (node.getAttribute('hidden') !== null) return false;
|
|
34
31
|
if (node.getAttribute('data-id') === _focusBorders.BEFORE_BORDER_ID || node.getAttribute('data-id') === _focusBorders.AFTER_BORDER_ID) return false;
|
|
35
|
-
|
|
36
|
-
for (
|
|
37
|
-
|
|
38
|
-
if (params.every(function (param) {
|
|
32
|
+
const tagName = node.tagName;
|
|
33
|
+
for (const params of focusable) {
|
|
34
|
+
if (params.every(param => {
|
|
39
35
|
if (typeof param === 'string' && param === tagName) return true;
|
|
40
|
-
if (
|
|
36
|
+
if (typeof param === 'object' && param.has && node.hasAttribute(param.has)) return true;
|
|
41
37
|
return false;
|
|
42
38
|
})) {
|
|
43
|
-
|
|
39
|
+
const style = getComputedStyle(node);
|
|
44
40
|
if (style.display === 'none' || style.visibility === 'hidden') return false;
|
|
45
41
|
return true;
|
|
46
42
|
}
|
|
47
43
|
}
|
|
48
44
|
return false;
|
|
49
45
|
};
|
|
46
|
+
exports.isFocusable = isFocusable;
|
|
50
47
|
//# sourceMappingURL=isFocusable.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isFocusable.js","names":["_focusBorders","require","focusable","has","isFocusable","
|
|
1
|
+
{"version":3,"file":"isFocusable.js","names":["_focusBorders","require","focusable","has","isFocusable","node","ownerDocument","defaultView","HTMLElement","SVGElement","hasAttribute","getAttribute","BEFORE_BORDER_ID","AFTER_BORDER_ID","tagName","params","every","param","style","getComputedStyle","display","visibility","exports"],"sources":["../../../src/utils/focus-lock/isFocusable.ts"],"sourcesContent":["import { AFTER_BORDER_ID, BEFORE_BORDER_ID } from './focusBorders';\n\nconst focusable = [\n ['BUTTON'],\n ['SELECT'],\n ['TEXTAREA'],\n ['INPUT'],\n ['A', { has: 'href' }],\n ['AREA', { has: 'href' }],\n ['SUMMARY'],\n ['IFRAME'],\n ['OBJECT'],\n ['EMBED'],\n ['AUDIO', { has: 'controls' }],\n ['VIDEO', { has: 'controls' }],\n [{ has: 'tabindex' }],\n [{ has: 'contenteditable' }],\n [{ has: 'autofocus' }],\n];\n\nexport const isFocusable = (node: Node) => {\n if (!node) return false;\n if (!node.ownerDocument) return false;\n if (!node.ownerDocument.defaultView?.HTMLElement) return false;\n if (\n !(\n node instanceof node.ownerDocument.defaultView.HTMLElement ||\n node instanceof node.ownerDocument.defaultView.SVGElement\n )\n )\n return false;\n if (node.hasAttribute('disabled')) return false;\n if (node.getAttribute('tabindex') === '-1') return false;\n if (node.getAttribute('hidden') !== null) return false;\n if (\n node.getAttribute('data-id') === BEFORE_BORDER_ID ||\n node.getAttribute('data-id') === AFTER_BORDER_ID\n )\n return false;\n const tagName = node.tagName;\n for (const params of focusable) {\n if (\n params.every((param) => {\n if (typeof param === 'string' && param === tagName) return true;\n if (typeof param === 'object' && param.has && node.hasAttribute(param.has)) return true;\n return false;\n })\n ) {\n const style = getComputedStyle(node);\n if (style.display === 'none' || style.visibility === 'hidden') return false;\n\n return true;\n }\n }\n return false;\n};\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Q,CAAC,KAAK,IAAI,EAAE,OAAO,KAAK;EACtD,IACEN,IAAI,CAACM,YAAY,CAAC,SAAS,CAAC,KAAKC,8BAAgB,IACjDP,IAAI,CAACM,YAAY,CAAC,SAAS,CAAC,KAAKE,6BAAe,EAEhD,OAAO,KAAK;EACd,MAAMC,OAAO,GAAGT,IAAI,CAACS,OAAO;EAC5B,KAAK,MAAMC,MAAM,IAAIb,SAAS,EAAE;IAC9B,IACEa,MAAM,CAACC,KAAK,CAAEC,KAAK,IAAK;MACtB,IAAI,OAAOA,KAAK,KAAK,QAAQ,IAAIA,KAAK,KAAKH,OAAO,EAAE,OAAO,IAAI;MAC/D,IAAI,OAAOG,KAAK,KAAK,QAAQ,IAAIA,KAAK,CAACd,GAAG,IAAIE,IAAI,CAACK,YAAY,CAACO,KAAK,CAACd,GAAG,CAAC,EAAE,OAAO,IAAI;MACvF,OAAO,KAAK;IACd,CAAC,CAAC,EACF;MACA,MAAMe,KAAK,GAAGC,gBAAgB,CAACd,IAAI,CAAC;MACpC,IAAIa,KAAK,CAACE,OAAO,KAAK,MAAM,IAAIF,KAAK,CAACG,UAAU,KAAK,QAAQ,EAAE,OAAO,KAAK;MAE3E,OAAO,IAAI;IACb;EACF;EACA,OAAO,KAAK;AACd,CAAC;AAACC,OAAA,CAAAlB,WAAA,GAAAA,WAAA","ignoreList":[]}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
|
2
1
|
import { AFTER_BORDER_ID, BEFORE_BORDER_ID } from "./focusBorders.mjs";
|
|
3
|
-
|
|
2
|
+
const focusable = [['BUTTON'], ['SELECT'], ['TEXTAREA'], ['INPUT'], ['A', {
|
|
4
3
|
has: 'href'
|
|
5
4
|
}], ['AREA', {
|
|
6
5
|
has: 'href'
|
|
@@ -15,25 +14,23 @@ var focusable = [['BUTTON'], ['SELECT'], ['TEXTAREA'], ['INPUT'], ['A', {
|
|
|
15
14
|
}], [{
|
|
16
15
|
has: 'autofocus'
|
|
17
16
|
}]];
|
|
18
|
-
export
|
|
19
|
-
var _node$ownerDocument$d;
|
|
17
|
+
export const isFocusable = node => {
|
|
20
18
|
if (!node) return false;
|
|
21
19
|
if (!node.ownerDocument) return false;
|
|
22
|
-
if (!
|
|
20
|
+
if (!node.ownerDocument.defaultView?.HTMLElement) return false;
|
|
23
21
|
if (!(node instanceof node.ownerDocument.defaultView.HTMLElement || node instanceof node.ownerDocument.defaultView.SVGElement)) return false;
|
|
24
22
|
if (node.hasAttribute('disabled')) return false;
|
|
25
23
|
if (node.getAttribute('tabindex') === '-1') return false;
|
|
26
24
|
if (node.getAttribute('hidden') !== null) return false;
|
|
27
25
|
if (node.getAttribute('data-id') === BEFORE_BORDER_ID || node.getAttribute('data-id') === AFTER_BORDER_ID) return false;
|
|
28
|
-
|
|
29
|
-
for (
|
|
30
|
-
|
|
31
|
-
if (params.every(function (param) {
|
|
26
|
+
const tagName = node.tagName;
|
|
27
|
+
for (const params of focusable) {
|
|
28
|
+
if (params.every(param => {
|
|
32
29
|
if (typeof param === 'string' && param === tagName) return true;
|
|
33
|
-
if (
|
|
30
|
+
if (typeof param === 'object' && param.has && node.hasAttribute(param.has)) return true;
|
|
34
31
|
return false;
|
|
35
32
|
})) {
|
|
36
|
-
|
|
33
|
+
const style = getComputedStyle(node);
|
|
37
34
|
if (style.display === 'none' || style.visibility === 'hidden') return false;
|
|
38
35
|
return true;
|
|
39
36
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isFocusable.mjs","names":["AFTER_BORDER_ID","BEFORE_BORDER_ID","focusable","has","isFocusable","node","
|
|
1
|
+
{"version":3,"file":"isFocusable.mjs","names":["AFTER_BORDER_ID","BEFORE_BORDER_ID","focusable","has","isFocusable","node","ownerDocument","defaultView","HTMLElement","SVGElement","hasAttribute","getAttribute","tagName","params","every","param","style","getComputedStyle","display","visibility"],"sources":["../../../src/utils/focus-lock/isFocusable.ts"],"sourcesContent":["import { AFTER_BORDER_ID, BEFORE_BORDER_ID } from './focusBorders';\n\nconst focusable = [\n ['BUTTON'],\n ['SELECT'],\n ['TEXTAREA'],\n ['INPUT'],\n ['A', { has: 'href' }],\n ['AREA', { has: 'href' }],\n ['SUMMARY'],\n ['IFRAME'],\n ['OBJECT'],\n ['EMBED'],\n ['AUDIO', { has: 'controls' }],\n ['VIDEO', { has: 'controls' }],\n [{ has: 'tabindex' }],\n [{ has: 'contenteditable' }],\n [{ has: 'autofocus' }],\n];\n\nexport const isFocusable = (node: Node) => {\n if (!node) return false;\n if (!node.ownerDocument) return false;\n if (!node.ownerDocument.defaultView?.HTMLElement) return false;\n if (\n !(\n node instanceof node.ownerDocument.defaultView.HTMLElement ||\n node instanceof node.ownerDocument.defaultView.SVGElement\n )\n )\n return false;\n if (node.hasAttribute('disabled')) return false;\n if (node.getAttribute('tabindex') === '-1') return false;\n if (node.getAttribute('hidden') !== null) return false;\n if (\n node.getAttribute('data-id') === BEFORE_BORDER_ID ||\n node.getAttribute('data-id') === AFTER_BORDER_ID\n )\n return false;\n const tagName = node.tagName;\n for (const params of focusable) {\n if (\n params.every((param) => {\n if (typeof param === 'string' && param === tagName) return true;\n if (typeof param === 'object' && param.has && node.hasAttribute(param.has)) return true;\n return false;\n })\n ) {\n const style = getComputedStyle(node);\n if (style.display === 'none' || style.visibility === 'hidden') return false;\n\n return true;\n }\n }\n return false;\n};\n"],"mappings":"AAAA,SAASA,eAAe,EAAEC,gBAAgB,QAAQ,oBAAgB;AAElE,MAAMC,SAAS,GAAG,CAChB,CAAC,QAAQ,CAAC,EACV,CAAC,QAAQ,CAAC,EACV,CAAC,UAAU,CAAC,EACZ,CAAC,OAAO,CAAC,EACT,CAAC,GAAG,EAAE;EAAEC,GAAG,EAAE;AAAO,CAAC,CAAC,EACtB,CAAC,MAAM,EAAE;EAAEA,GAAG,EAAE;AAAO,CAAC,CAAC,EACzB,CAAC,SAAS,CAAC,EACX,CAAC,QAAQ,CAAC,EACV,CAAC,QAA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QAAQ,IAAIA,KAAK,KAAKH,OAAO,EAAE,OAAO,IAAI;MAC/D,IAAI,OAAOG,KAAK,KAAK,QAAQ,IAAIA,KAAK,CAACZ,GAAG,IAAIE,IAAI,CAACK,YAAY,CAACK,KAAK,CAACZ,GAAG,CAAC,EAAE,OAAO,IAAI;MACvF,OAAO,KAAK;IACd,CAAC,CAAC,EACF;MACA,MAAMa,KAAK,GAAGC,gBAAgB,CAACZ,IAAI,CAAC;MACpC,IAAIW,KAAK,CAACE,OAAO,KAAK,MAAM,IAAIF,KAAK,CAACG,UAAU,KAAK,QAAQ,EAAE,OAAO,KAAK;MAE3E,OAAO,IAAI;IACb;EACF;EACA,OAAO,KAAK;AACd,CAAC","ignoreList":[]}
|
|
@@ -1,48 +1,42 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.setFocus = void 0;
|
|
8
|
-
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
9
8
|
var _LastInteractionType = require("../../LastInteractionType");
|
|
10
9
|
var _canUseDOM = _interopRequireDefault(require("../canUseDOM"));
|
|
11
10
|
var _getFocusableIn = require("./getFocusableIn");
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
var focusable = (0, _getFocusableIn.getFocusableIn)(node);
|
|
17
|
-
var target = focusable[0];
|
|
11
|
+
const unsafeSetFocus = (node, previousActiveElement, actualActiveElement, focusOptions = {}) => {
|
|
12
|
+
const activeElement = actualActiveElement || document.activeElement;
|
|
13
|
+
const focusable = (0, _getFocusableIn.getFocusableIn)(node);
|
|
14
|
+
let target = focusable[0];
|
|
18
15
|
if (activeElement && previousActiveElement && previousActiveElement.compareDocumentPosition(activeElement) & Node.DOCUMENT_POSITION_PRECEDING && !(previousActiveElement.compareDocumentPosition(activeElement) & Node.DOCUMENT_POSITION_CONTAINS)) {
|
|
19
16
|
target = focusable[focusable.length - 1];
|
|
20
17
|
}
|
|
21
|
-
|
|
18
|
+
target?.focus({
|
|
22
19
|
// @ts-ignore. set focus-visible in FF and Safari
|
|
23
20
|
focusVisible: _LastInteractionType.lastInteraction.isKeyboard(),
|
|
24
|
-
preventScroll: _LastInteractionType.lastInteraction.isMouse()
|
|
25
|
-
|
|
21
|
+
preventScroll: _LastInteractionType.lastInteraction.isMouse(),
|
|
22
|
+
...focusOptions
|
|
23
|
+
});
|
|
26
24
|
};
|
|
27
25
|
|
|
28
26
|
/** "safe" focus movement means that function wrapper tries
|
|
29
27
|
* to detect focus war (when two focus locks are trying to
|
|
30
28
|
* control focus recursively) and disables it for 10 seconds
|
|
31
29
|
*/
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
30
|
+
let focusMoveRequests = [];
|
|
31
|
+
let focusMoveDisabledUntil = 0;
|
|
32
|
+
let lastUserAction = 0;
|
|
33
|
+
const safeSetFocus = (...args) => {
|
|
36
34
|
if (focusMoveDisabledUntil > Date.now()) return;
|
|
37
35
|
focusMoveRequests.push(Date.now());
|
|
38
36
|
if (focusMoveRequests.length > 10 && Date.now() - lastUserAction > 600) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
});
|
|
43
|
-
if (timeBetweenFocusMoveRequests.every(function (time) {
|
|
44
|
-
return time < 250;
|
|
45
|
-
})) {
|
|
37
|
+
const lastFocusMoveRequests = focusMoveRequests.slice(-10);
|
|
38
|
+
const timeBetweenFocusMoveRequests = lastFocusMoveRequests.slice(1).map((time, index) => Math.abs(time - lastFocusMoveRequests[index]));
|
|
39
|
+
if (timeBetweenFocusMoveRequests.every(time => time < 250)) {
|
|
46
40
|
focusMoveDisabledUntil = Date.now() + 10000;
|
|
47
41
|
focusMoveRequests = [];
|
|
48
42
|
|
|
@@ -52,19 +46,19 @@ var safeSetFocus = function safeSetFocus() {
|
|
|
52
46
|
}
|
|
53
47
|
}
|
|
54
48
|
if (focusMoveRequests.length > 500) focusMoveRequests = focusMoveRequests.slice(-10);
|
|
55
|
-
return unsafeSetFocus
|
|
49
|
+
return unsafeSetFocus(...args);
|
|
56
50
|
};
|
|
57
|
-
if ((0, _canUseDOM
|
|
58
|
-
document.addEventListener('keydown',
|
|
51
|
+
if ((0, _canUseDOM.default)()) {
|
|
52
|
+
document.addEventListener('keydown', () => {
|
|
59
53
|
lastUserAction = Date.now();
|
|
60
54
|
}, {
|
|
61
55
|
capture: true
|
|
62
56
|
});
|
|
63
|
-
document.addEventListener('mousedown',
|
|
57
|
+
document.addEventListener('mousedown', () => {
|
|
64
58
|
lastUserAction = Date.now();
|
|
65
59
|
}, {
|
|
66
60
|
capture: true
|
|
67
61
|
});
|
|
68
62
|
}
|
|
69
|
-
|
|
63
|
+
const setFocus = exports.setFocus = safeSetFocus;
|
|
70
64
|
//# sourceMappingURL=setFocus.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setFocus.js","names":["_LastInteractionType","require","_canUseDOM","_interopRequireDefault","_getFocusableIn","unsafeSetFocus","node","previousActiveElement","actualActiveElement","
|
|
1
|
+
{"version":3,"file":"setFocus.js","names":["_LastInteractionType","require","_canUseDOM","_interopRequireDefault","_getFocusableIn","unsafeSetFocus","node","previousActiveElement","actualActiveElement","focusOptions","activeElement","document","focusable","getFocusableIn","target","compareDocumentPosition","Node","DOCUMENT_POSITION_PRECEDING","DOCUMENT_POSITION_CONTAINS","length","focus","focusVisible","lastInteraction","isKeyboard","preventScroll","isMouse","focusMoveRequests","focusMoveDisabledUntil","lastUserAction","safeSetFocus","args","Date","now","push","lastFocusMoveRequests","slice","timeBetweenFocusMoveRequests","map","time","index","Math","abs","every","console","error","canUseDOM","addEventListener","capture","setFocus","exports"],"sources":["../../../src/utils/focus-lock/setFocus.ts"],"sourcesContent":["import { lastInteraction } from '../../LastInteractionType';\nimport canUseDOM from '../canUseDOM';\nimport { getFocusableIn } from './getFocusableIn';\n\nconst unsafeSetFocus = (\n node: HTMLElement,\n previousActiveElement?: HTMLElement | null,\n actualActiveElement?: HTMLElement,\n focusOptions: FocusOptions = {},\n) => {\n const activeElement = actualActiveElement || document.activeElement;\n\n const focusable = getFocusableIn(node);\n\n let target = focusable[0];\n\n if (\n activeElement &&\n previousActiveElement &&\n previousActiveElement.compareDocumentPosition(activeElement) &\n Node.DOCUMENT_POSITION_PRECEDING &&\n !(\n previousActiveElement.compareDocumentPosition(activeElement) & Node.DOCUMENT_POSITION_CONTAINS\n )\n ) {\n target = focusable[focusable.length - 1];\n }\n\n target?.focus({\n // @ts-ignore. set focus-visible in FF and Safari\n focusVisible: lastInteraction.isKeyboard(),\n preventScroll: lastInteraction.isMouse(),\n ...focusOptions,\n });\n};\n\n/** \"safe\" focus movement means that function wrapper tries\n * to detect focus war (when two focus locks are trying to\n * control focus recursively) and disables it for 10 seconds\n */\nlet focusMoveRequests: number[] = [];\nlet focusMoveDisabledUntil = 0;\nlet lastUserAction = 0;\nconst safeSetFocus: typeof unsafeSetFocus = (...args) => {\n if (focusMoveDisabledUntil > Date.now()) return;\n focusMoveRequests.push(Date.now());\n if (focusMoveRequests.length > 10 && Date.now() - lastUserAction > 600) {\n const lastFocusMoveRequests = focusMoveRequests.slice(-10);\n const timeBetweenFocusMoveRequests = lastFocusMoveRequests\n .slice(1)\n .map((time, index) => Math.abs(time - lastFocusMoveRequests[index]));\n if (timeBetweenFocusMoveRequests.every((time) => time < 250)) {\n focusMoveDisabledUntil = Date.now() + 10000;\n focusMoveRequests = [];\n\n // eslint-disable-next-line no-console\n console.error(\n '[useFocusLock] Probably the focus war was detected. It is a process when multiple browser focus control subjects are reacting to \"blur\" event on their element and are trying to get it back. Focus move function was disabled for 10 seconds. Probably your page has different focus lock systems. If you have multiple versions of Intergalactic components, updated them to the latest version (at least to 15.16.3).',\n );\n return;\n }\n }\n if (focusMoveRequests.length > 500) focusMoveRequests = focusMoveRequests.slice(-10);\n\n return unsafeSetFocus(...args);\n};\nif (canUseDOM()) {\n document.addEventListener(\n 'keydown',\n () => {\n lastUserAction = Date.now();\n },\n { capture: true },\n );\n document.addEventListener(\n 'mousedown',\n () => {\n lastUserAction = Date.now();\n },\n { capture: true },\n );\n}\n\nexport const setFocus = safeSetFocus;\n"],"mappings":";;;;;;;AAAA,IAAAA,oBAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,eAAA,GAAAH,OAAA;AAEA,MAAMI,cAAc,GAAGA,CACrBC,IAAiB,EACjBC,qBAA0C,EAC1CC,mBAAiC,EACjCC,YAA0B,GAAG,CAAC,CAAC,KAC5B;EACH,MAAMC,aAAa,GAAGF,mBAAmB,IAAIG,QAAQ,CAACD,aAAa;EAEnE,MAAME,SAAS,GAAG,IAAAC,8BAAc,EAACP,IAAI,CAAC;EAEtC,IAAIQ,MAAM,GAAGF,SAAS,CAAC,CAAC,CAAC;EAEzB,IACEF,aAAa,IACbH,qBAAqB,IACrBA,qBAAqB,CAACQ,uBAAuB,CAACL,aAAa,CAAC,GAC5DM,IAAI,CAACC,2BAA2B,IAChC,EACEV,qBAAqB,CAACQ,uBAAuB,CAACL,aAAa,CAAC,GAAGM,IAAI,CAACE,0BAA0B,CAC/F,EACD;IACAJ,MAAM,GAAGF,SAAS,CAACA,SAAS,CAACO,MAAM,GAAG,CAAC,CAAC;EAC1C;EAEAL,MAAM,EAAEM,KAAK,CAAC;IACZ;IACAC,YAAY,EAAEC,oCAAe,CAACC,UAAU,CAAC,CAAC;IAC1CC,aAAa,EAAEF,oCAAe,CAACG,OAAO,CAAC,CAAC;IACxC,GAAGhB;EACL,CAAC,CAAC;AACJ,CAAC;;AAED;AACA;AACA;AACA;AACA,IAAIiB,iBAA2B,GAAG,EAAE;AACpC,IAAIC,sBAA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