@quantinuum/quantinuum-ui 4.0.0 → 4.0.1-fix-update-radix.1
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/dist/_virtual/index.js +4 -0
- package/dist/_virtual/index.js.map +1 -0
- package/dist/_virtual/use-sync-external-store-shim.development.js +4 -0
- package/dist/_virtual/use-sync-external-store-shim.development.js.map +1 -0
- package/dist/_virtual/use-sync-external-store-shim.production.js +4 -0
- package/dist/_virtual/use-sync-external-store-shim.production.js.map +1 -0
- package/dist/node_modules/@radix-ui/number/dist/index.mjs.js +4 -3
- package/dist/node_modules/@radix-ui/number/dist/index.mjs.js.map +1 -1
- package/dist/node_modules/@radix-ui/primitive/dist/index.mjs.js +9 -6
- package/dist/node_modules/@radix-ui/primitive/dist/index.mjs.js.map +1 -1
- package/dist/node_modules/@radix-ui/react-accordion/dist/index.mjs.js +279 -267
- package/dist/node_modules/@radix-ui/react-accordion/dist/index.mjs.js.map +1 -1
- package/dist/node_modules/@radix-ui/react-arrow/dist/index.mjs.js +26 -0
- package/dist/node_modules/@radix-ui/react-arrow/dist/index.mjs.js.map +1 -0
- package/dist/node_modules/@radix-ui/react-avatar/dist/index.mjs.js +114 -92
- package/dist/node_modules/@radix-ui/react-avatar/dist/index.mjs.js.map +1 -1
- package/dist/node_modules/@radix-ui/react-checkbox/dist/index.mjs.js +255 -138
- package/dist/node_modules/@radix-ui/react-checkbox/dist/index.mjs.js.map +1 -1
- package/dist/node_modules/@radix-ui/react-collapsible/dist/index.mjs.js +135 -130
- package/dist/node_modules/@radix-ui/react-collapsible/dist/index.mjs.js.map +1 -1
- package/dist/node_modules/@radix-ui/react-collection/dist/index.mjs.js +66 -88
- package/dist/node_modules/@radix-ui/react-collection/dist/index.mjs.js.map +1 -1
- package/dist/node_modules/@radix-ui/react-collection/node_modules/@radix-ui/react-slot/dist/index.mjs.js +81 -73
- package/dist/node_modules/@radix-ui/react-collection/node_modules/@radix-ui/react-slot/dist/index.mjs.js.map +1 -1
- package/dist/node_modules/@radix-ui/react-compose-refs/dist/index.mjs.js +34 -21
- package/dist/node_modules/@radix-ui/react-compose-refs/dist/index.mjs.js.map +1 -1
- package/dist/node_modules/@radix-ui/react-context/dist/index.mjs.js +72 -93
- package/dist/node_modules/@radix-ui/react-context/dist/index.mjs.js.map +1 -1
- package/dist/node_modules/@radix-ui/react-dialog/dist/index.mjs.js +297 -254
- package/dist/node_modules/@radix-ui/react-dialog/dist/index.mjs.js.map +1 -1
- package/dist/node_modules/@radix-ui/react-dialog/node_modules/@radix-ui/react-slot/dist/index.mjs.js +81 -73
- package/dist/node_modules/@radix-ui/react-dialog/node_modules/@radix-ui/react-slot/dist/index.mjs.js.map +1 -1
- package/dist/node_modules/@radix-ui/react-direction/dist/index.mjs.js +8 -6
- package/dist/node_modules/@radix-ui/react-direction/dist/index.mjs.js.map +1 -1
- package/dist/node_modules/@radix-ui/react-dismissable-layer/dist/index.mjs.js +190 -217
- package/dist/node_modules/@radix-ui/react-dismissable-layer/dist/index.mjs.js.map +1 -1
- package/dist/node_modules/@radix-ui/react-dropdown-menu/dist/index.mjs.js +243 -217
- package/dist/node_modules/@radix-ui/react-dropdown-menu/dist/index.mjs.js.map +1 -1
- package/dist/node_modules/@radix-ui/react-focus-guards/dist/index.mjs.js +26 -25
- package/dist/node_modules/@radix-ui/react-focus-guards/dist/index.mjs.js.map +1 -1
- package/dist/node_modules/@radix-ui/react-focus-scope/dist/index.mjs.js +191 -259
- package/dist/node_modules/@radix-ui/react-focus-scope/dist/index.mjs.js.map +1 -1
- package/dist/node_modules/@radix-ui/react-hover-card/dist/index.mjs.js +224 -205
- package/dist/node_modules/@radix-ui/react-hover-card/dist/index.mjs.js.map +1 -1
- package/dist/node_modules/@radix-ui/react-id/dist/index.mjs.js +11 -14
- package/dist/node_modules/@radix-ui/react-id/dist/index.mjs.js.map +1 -1
- package/dist/node_modules/@radix-ui/react-label/dist/index.mjs.js +22 -14
- package/dist/node_modules/@radix-ui/react-label/dist/index.mjs.js.map +1 -1
- package/dist/node_modules/@radix-ui/react-menu/dist/index.mjs.js +765 -820
- package/dist/node_modules/@radix-ui/react-menu/dist/index.mjs.js.map +1 -1
- package/dist/node_modules/@radix-ui/react-menu/node_modules/@radix-ui/react-slot/dist/index.mjs.js +81 -73
- package/dist/node_modules/@radix-ui/react-menu/node_modules/@radix-ui/react-slot/dist/index.mjs.js.map +1 -1
- package/dist/node_modules/@radix-ui/react-navigation-menu/dist/index.mjs.js +717 -730
- package/dist/node_modules/@radix-ui/react-navigation-menu/dist/index.mjs.js.map +1 -1
- package/dist/node_modules/@radix-ui/react-popover/dist/index.mjs.js +268 -199
- package/dist/node_modules/@radix-ui/react-popover/dist/index.mjs.js.map +1 -1
- package/dist/node_modules/@radix-ui/react-popover/node_modules/@radix-ui/react-slot/dist/index.mjs.js +81 -73
- package/dist/node_modules/@radix-ui/react-popover/node_modules/@radix-ui/react-slot/dist/index.mjs.js.map +1 -1
- package/dist/node_modules/@radix-ui/react-popper/dist/index.mjs.js +267 -223
- package/dist/node_modules/@radix-ui/react-popper/dist/index.mjs.js.map +1 -1
- package/dist/node_modules/@radix-ui/react-portal/dist/index.mjs.js +14 -10
- package/dist/node_modules/@radix-ui/react-portal/dist/index.mjs.js.map +1 -1
- package/dist/node_modules/@radix-ui/react-presence/dist/index.mjs.js +122 -121
- package/dist/node_modules/@radix-ui/react-presence/dist/index.mjs.js.map +1 -1
- package/dist/node_modules/@radix-ui/react-primitive/dist/index.mjs.js +39 -83
- package/dist/node_modules/@radix-ui/react-primitive/dist/index.mjs.js.map +1 -1
- package/dist/node_modules/@radix-ui/react-primitive/node_modules/@radix-ui/react-slot/dist/index.mjs.js +81 -73
- package/dist/node_modules/@radix-ui/react-primitive/node_modules/@radix-ui/react-slot/dist/index.mjs.js.map +1 -1
- package/dist/node_modules/@radix-ui/react-progress/dist/index.mjs.js +77 -78
- package/dist/node_modules/@radix-ui/react-progress/dist/index.mjs.js.map +1 -1
- package/dist/node_modules/@radix-ui/react-radio-group/dist/index.mjs.js +264 -217
- package/dist/node_modules/@radix-ui/react-radio-group/dist/index.mjs.js.map +1 -1
- package/dist/node_modules/@radix-ui/react-roving-focus/dist/index.mjs.js +204 -216
- package/dist/node_modules/@radix-ui/react-roving-focus/dist/index.mjs.js.map +1 -1
- package/dist/node_modules/@radix-ui/react-scroll-area/dist/index.mjs.js +9 -9
- package/dist/node_modules/@radix-ui/react-select/dist/index.mjs.js +1080 -1079
- package/dist/node_modules/@radix-ui/react-select/dist/index.mjs.js.map +1 -1
- package/dist/node_modules/@radix-ui/react-select/node_modules/@radix-ui/react-slot/dist/index.mjs.js +81 -73
- package/dist/node_modules/@radix-ui/react-select/node_modules/@radix-ui/react-slot/dist/index.mjs.js.map +1 -1
- package/dist/node_modules/@radix-ui/react-separator/dist/index.mjs.js +26 -43
- package/dist/node_modules/@radix-ui/react-separator/dist/index.mjs.js.map +1 -1
- package/dist/node_modules/@radix-ui/react-slot/dist/index.mjs.js +1 -1
- package/dist/node_modules/@radix-ui/react-switch/dist/index.mjs.js +140 -112
- package/dist/node_modules/@radix-ui/react-switch/dist/index.mjs.js.map +1 -1
- package/dist/node_modules/@radix-ui/react-tabs/dist/index.mjs.js +173 -141
- package/dist/node_modules/@radix-ui/react-tabs/dist/index.mjs.js.map +1 -1
- package/dist/node_modules/@radix-ui/react-toggle/dist/index.mjs.js +34 -25
- package/dist/node_modules/@radix-ui/react-toggle/dist/index.mjs.js.map +1 -1
- package/dist/node_modules/@radix-ui/react-toggle-group/dist/index.mjs.js +154 -145
- package/dist/node_modules/@radix-ui/react-toggle-group/dist/index.mjs.js.map +1 -1
- package/dist/node_modules/@radix-ui/react-tooltip/dist/index.mjs.js +462 -491
- package/dist/node_modules/@radix-ui/react-tooltip/dist/index.mjs.js.map +1 -1
- package/dist/node_modules/@radix-ui/react-tooltip/node_modules/@radix-ui/react-slot/dist/index.mjs.js +13 -78
- package/dist/node_modules/@radix-ui/react-tooltip/node_modules/@radix-ui/react-slot/dist/index.mjs.js.map +1 -1
- package/dist/node_modules/@radix-ui/react-use-callback-ref/dist/index.mjs.js +9 -15
- package/dist/node_modules/@radix-ui/react-use-callback-ref/dist/index.mjs.js.map +1 -1
- package/dist/node_modules/@radix-ui/react-use-controllable-state/dist/index.mjs.js +66 -43
- package/dist/node_modules/@radix-ui/react-use-controllable-state/dist/index.mjs.js.map +1 -1
- package/dist/node_modules/@radix-ui/react-use-escape-keydown/dist/index.mjs.js +15 -18
- package/dist/node_modules/@radix-ui/react-use-escape-keydown/dist/index.mjs.js.map +1 -1
- package/dist/node_modules/@radix-ui/react-use-is-hydrated/dist/index.mjs.js +18 -0
- package/dist/node_modules/@radix-ui/react-use-is-hydrated/dist/index.mjs.js.map +1 -0
- package/dist/node_modules/@radix-ui/react-use-layout-effect/dist/index.mjs.js +5 -9
- package/dist/node_modules/@radix-ui/react-use-layout-effect/dist/index.mjs.js.map +1 -1
- package/dist/node_modules/@radix-ui/react-use-previous/dist/index.mjs.js +12 -18
- package/dist/node_modules/@radix-ui/react-use-previous/dist/index.mjs.js.map +1 -1
- package/dist/node_modules/@radix-ui/react-use-size/dist/index.mjs.js +37 -48
- package/dist/node_modules/@radix-ui/react-use-size/dist/index.mjs.js.map +1 -1
- package/dist/node_modules/@radix-ui/react-visually-hidden/dist/index.mjs.js +32 -23
- package/dist/node_modules/@radix-ui/react-visually-hidden/dist/index.mjs.js.map +1 -1
- package/dist/node_modules/aria-hidden/dist/es2015/index.js +22 -16
- package/dist/node_modules/aria-hidden/dist/es2015/index.js.map +1 -1
- package/dist/node_modules/class-variance-authority/dist/index.mjs.js +7 -9
- package/dist/node_modules/class-variance-authority/dist/index.mjs.js.map +1 -1
- package/dist/node_modules/cmdk/dist/chunk-NZJY6EH4.mjs.js +4 -0
- package/dist/node_modules/cmdk/dist/chunk-NZJY6EH4.mjs.js.map +1 -0
- package/dist/node_modules/cmdk/dist/index.mjs.js +8 -4
- package/dist/node_modules/cmdk/dist/index.mjs.js.map +1 -1
- package/dist/node_modules/{@radix-ui/react-scroll-area → cmdk}/node_modules/@radix-ui/react-primitive/dist/index.mjs.js +1 -1
- package/dist/node_modules/cmdk/node_modules/@radix-ui/react-primitive/dist/index.mjs.js.map +1 -0
- package/dist/node_modules/input-otp/dist/index.mjs.js +1 -1
- package/dist/node_modules/input-otp/dist/index.mjs.js.map +1 -1
- package/dist/node_modules/react-remove-scroll/dist/es2015/SideEffect.js +23 -5
- package/dist/node_modules/react-remove-scroll/dist/es2015/SideEffect.js.map +1 -1
- package/dist/node_modules/react-remove-scroll/dist/es2015/UI.js +2 -2
- package/dist/node_modules/react-remove-scroll/dist/es2015/UI.js.map +1 -1
- package/dist/node_modules/react-remove-scroll/dist/es2015/handleScroll.js +18 -6
- package/dist/node_modules/react-remove-scroll/dist/es2015/handleScroll.js.map +1 -1
- package/dist/node_modules/react-remove-scroll-bar/dist/es2015/component.js +25 -5
- package/dist/node_modules/react-remove-scroll-bar/dist/es2015/component.js.map +1 -1
- package/dist/node_modules/sonner/dist/index.mjs.js +46 -26
- package/dist/node_modules/sonner/dist/index.mjs.js.map +1 -1
- package/dist/node_modules/use-callback-ref/dist/es2015/useMergeRef.js +27 -1
- package/dist/node_modules/use-callback-ref/dist/es2015/useMergeRef.js.map +1 -1
- package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js +107 -0
- package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js.map +1 -0
- package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.js +78 -0
- package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.js.map +1 -0
- package/dist/node_modules/use-sync-external-store/shim/index.js +13 -0
- package/dist/node_modules/use-sync-external-store/shim/index.js.map +1 -0
- package/dist/src/index.js +1 -1
- package/dist/src/shadcn/ui/accordion.js +7 -7
- package/dist/src/shadcn/ui/avatar.js +7 -7
- package/dist/src/shadcn/ui/checkbox.js +3 -3
- package/dist/src/shadcn/ui/command.js +15 -15
- package/dist/src/shadcn/ui/dialog.js +14 -14
- package/dist/src/shadcn/ui/dropdown-menu.js +23 -23
- package/dist/src/shadcn/ui/hover-card.js +5 -5
- package/dist/src/shadcn/ui/label.js +3 -3
- package/dist/src/shadcn/ui/navigation-menu.js +15 -15
- package/dist/src/shadcn/ui/navigation-menu.js.map +1 -1
- package/dist/src/shadcn/ui/popover.js +32 -6
- package/dist/src/shadcn/ui/popover.js.map +1 -1
- package/dist/src/shadcn/ui/progress.js +3 -3
- package/dist/src/shadcn/ui/radio-group.js +5 -5
- package/dist/src/shadcn/ui/select.js +19 -19
- package/dist/src/shadcn/ui/separator.js +3 -3
- package/dist/src/shadcn/ui/sheet.js +14 -14
- package/dist/src/shadcn/ui/switch.js +3 -3
- package/dist/src/shadcn/ui/tabs.js +8 -8
- package/dist/src/shadcn/ui/toggle-group.js +5 -5
- package/dist/src/shadcn/ui/toggle.js +3 -3
- package/dist/src/shadcn/ui/tooltip.js +7 -7
- package/dist/tailwind-manifest.js +12595 -14091
- package/dist/types/src/shadcn/ui/command.d.ts +44 -8
- package/dist/types/src/shadcn/ui/popover.d.ts +8 -4
- package/dist/types/src/shadcn/ui/sheet.d.ts +1 -1
- package/package.json +10 -31
- package/dist/node_modules/@babel/runtime/helpers/esm/extends.js +0 -12
- package/dist/node_modules/@babel/runtime/helpers/esm/extends.js.map +0 -1
- package/dist/node_modules/@radix-ui/react-scroll-area/node_modules/@radix-ui/number/dist/index.mjs.js +0 -7
- package/dist/node_modules/@radix-ui/react-scroll-area/node_modules/@radix-ui/number/dist/index.mjs.js.map +0 -1
- package/dist/node_modules/@radix-ui/react-scroll-area/node_modules/@radix-ui/primitive/dist/index.mjs.js +0 -12
- package/dist/node_modules/@radix-ui/react-scroll-area/node_modules/@radix-ui/primitive/dist/index.mjs.js.map +0 -1
- package/dist/node_modules/@radix-ui/react-scroll-area/node_modules/@radix-ui/react-compose-refs/dist/index.mjs.js +0 -40
- package/dist/node_modules/@radix-ui/react-scroll-area/node_modules/@radix-ui/react-compose-refs/dist/index.mjs.js.map +0 -1
- package/dist/node_modules/@radix-ui/react-scroll-area/node_modules/@radix-ui/react-context/dist/index.mjs.js +0 -64
- package/dist/node_modules/@radix-ui/react-scroll-area/node_modules/@radix-ui/react-context/dist/index.mjs.js.map +0 -1
- package/dist/node_modules/@radix-ui/react-scroll-area/node_modules/@radix-ui/react-direction/dist/index.mjs.js +0 -12
- package/dist/node_modules/@radix-ui/react-scroll-area/node_modules/@radix-ui/react-direction/dist/index.mjs.js.map +0 -1
- package/dist/node_modules/@radix-ui/react-scroll-area/node_modules/@radix-ui/react-presence/dist/index.mjs.js +0 -132
- package/dist/node_modules/@radix-ui/react-scroll-area/node_modules/@radix-ui/react-presence/dist/index.mjs.js.map +0 -1
- package/dist/node_modules/@radix-ui/react-scroll-area/node_modules/@radix-ui/react-primitive/dist/index.mjs.js.map +0 -1
- package/dist/node_modules/@radix-ui/react-scroll-area/node_modules/@radix-ui/react-slot/dist/index.mjs.js +0 -90
- package/dist/node_modules/@radix-ui/react-scroll-area/node_modules/@radix-ui/react-slot/dist/index.mjs.js.map +0 -1
- package/dist/node_modules/@radix-ui/react-scroll-area/node_modules/@radix-ui/react-use-callback-ref/dist/index.mjs.js +0 -13
- package/dist/node_modules/@radix-ui/react-scroll-area/node_modules/@radix-ui/react-use-callback-ref/dist/index.mjs.js.map +0 -1
- package/dist/node_modules/@radix-ui/react-scroll-area/node_modules/@radix-ui/react-use-layout-effect/dist/index.mjs.js +0 -8
- package/dist/node_modules/@radix-ui/react-scroll-area/node_modules/@radix-ui/react-use-layout-effect/dist/index.mjs.js.map +0 -1
- package/dist/node_modules/@radix-ui/react-slot/node_modules/@radix-ui/react-compose-refs/dist/index.mjs.js +0 -37
- package/dist/node_modules/@radix-ui/react-slot/node_modules/@radix-ui/react-compose-refs/dist/index.mjs.js.map +0 -1
- package/dist/node_modules/class-variance-authority/node_modules/clsx/dist/clsx.mjs.js +0 -4
- package/dist/node_modules/class-variance-authority/node_modules/clsx/dist/clsx.mjs.js.map +0 -1
- package/dist/node_modules/cmdk/node_modules/@radix-ui/primitive/dist/index.module.js +0 -9
- package/dist/node_modules/cmdk/node_modules/@radix-ui/primitive/dist/index.module.js.map +0 -1
- package/dist/node_modules/cmdk/node_modules/@radix-ui/react-compose-refs/dist/index.module.js +0 -27
- package/dist/node_modules/cmdk/node_modules/@radix-ui/react-compose-refs/dist/index.module.js.map +0 -1
- package/dist/node_modules/cmdk/node_modules/@radix-ui/react-context/dist/index.module.js +0 -101
- package/dist/node_modules/cmdk/node_modules/@radix-ui/react-context/dist/index.module.js.map +0 -1
- package/dist/node_modules/cmdk/node_modules/@radix-ui/react-dialog/dist/index.module.js +0 -214
- package/dist/node_modules/cmdk/node_modules/@radix-ui/react-dialog/dist/index.module.js.map +0 -1
- package/dist/node_modules/cmdk/node_modules/@radix-ui/react-dismissable-layer/dist/index.module.js +0 -233
- package/dist/node_modules/cmdk/node_modules/@radix-ui/react-dismissable-layer/dist/index.module.js.map +0 -1
- package/dist/node_modules/cmdk/node_modules/@radix-ui/react-focus-guards/dist/index.module.js +0 -30
- package/dist/node_modules/cmdk/node_modules/@radix-ui/react-focus-guards/dist/index.module.js.map +0 -1
- package/dist/node_modules/cmdk/node_modules/@radix-ui/react-focus-scope/dist/index.module.js +0 -252
- package/dist/node_modules/cmdk/node_modules/@radix-ui/react-focus-scope/dist/index.module.js.map +0 -1
- package/dist/node_modules/cmdk/node_modules/@radix-ui/react-id/dist/index.module.js +0 -19
- package/dist/node_modules/cmdk/node_modules/@radix-ui/react-id/dist/index.module.js.map +0 -1
- package/dist/node_modules/cmdk/node_modules/@radix-ui/react-portal/dist/index.module.js +0 -15
- package/dist/node_modules/cmdk/node_modules/@radix-ui/react-portal/dist/index.module.js.map +0 -1
- package/dist/node_modules/cmdk/node_modules/@radix-ui/react-presence/dist/index.module.js +0 -131
- package/dist/node_modules/cmdk/node_modules/@radix-ui/react-presence/dist/index.module.js.map +0 -1
- package/dist/node_modules/cmdk/node_modules/@radix-ui/react-primitive/dist/index.module.js +0 -85
- package/dist/node_modules/cmdk/node_modules/@radix-ui/react-primitive/dist/index.module.js.map +0 -1
- package/dist/node_modules/cmdk/node_modules/@radix-ui/react-slot/dist/index.module.js +0 -79
- package/dist/node_modules/cmdk/node_modules/@radix-ui/react-slot/dist/index.module.js.map +0 -1
- package/dist/node_modules/cmdk/node_modules/@radix-ui/react-use-callback-ref/dist/index.module.js +0 -19
- package/dist/node_modules/cmdk/node_modules/@radix-ui/react-use-callback-ref/dist/index.module.js.map +0 -1
- package/dist/node_modules/cmdk/node_modules/@radix-ui/react-use-controllable-state/dist/index.module.js +0 -48
- package/dist/node_modules/cmdk/node_modules/@radix-ui/react-use-controllable-state/dist/index.module.js.map +0 -1
- package/dist/node_modules/cmdk/node_modules/@radix-ui/react-use-escape-keydown/dist/index.module.js +0 -21
- package/dist/node_modules/cmdk/node_modules/@radix-ui/react-use-escape-keydown/dist/index.module.js.map +0 -1
- package/dist/node_modules/cmdk/node_modules/@radix-ui/react-use-layout-effect/dist/index.module.js +0 -12
- package/dist/node_modules/cmdk/node_modules/@radix-ui/react-use-layout-effect/dist/index.module.js.map +0 -1
- package/dist/node_modules/cmdk/node_modules/react-remove-scroll/dist/es2015/Combination.js +0 -10
- package/dist/node_modules/cmdk/node_modules/react-remove-scroll/dist/es2015/Combination.js.map +0 -1
- package/dist/node_modules/cmdk/node_modules/react-remove-scroll/dist/es2015/SideEffect.js +0 -146
- package/dist/node_modules/cmdk/node_modules/react-remove-scroll/dist/es2015/SideEffect.js.map +0 -1
- package/dist/node_modules/cmdk/node_modules/react-remove-scroll/dist/es2015/UI.js +0 -39
- package/dist/node_modules/cmdk/node_modules/react-remove-scroll/dist/es2015/UI.js.map +0 -1
- package/dist/node_modules/cmdk/node_modules/react-remove-scroll/dist/es2015/aggresiveCapture.js +0 -22
- package/dist/node_modules/cmdk/node_modules/react-remove-scroll/dist/es2015/aggresiveCapture.js.map +0 -1
- package/dist/node_modules/cmdk/node_modules/react-remove-scroll/dist/es2015/handleScroll.js +0 -97
- package/dist/node_modules/cmdk/node_modules/react-remove-scroll/dist/es2015/handleScroll.js.map +0 -1
- package/dist/node_modules/cmdk/node_modules/react-remove-scroll/dist/es2015/medium.js +0 -9
- package/dist/node_modules/cmdk/node_modules/react-remove-scroll/dist/es2015/medium.js.map +0 -1
- package/dist/node_modules/cmdk/node_modules/react-remove-scroll/dist/es2015/sidecar.js +0 -10
- package/dist/node_modules/cmdk/node_modules/react-remove-scroll/dist/es2015/sidecar.js.map +0 -1
- package/dist/node_modules/command-score/index.js +0 -138
- package/dist/node_modules/command-score/index.js.map +0 -1
|
@@ -1,277 +1,209 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import { useComposedRefs
|
|
4
|
-
import { Primitive
|
|
5
|
-
import { useCallbackRef
|
|
1
|
+
'use client';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { useComposedRefs } from '../../react-compose-refs/dist/index.mjs.js';
|
|
4
|
+
import { Primitive } from '../../react-primitive/dist/index.mjs.js';
|
|
5
|
+
import { useCallbackRef } from '../../react-use-callback-ref/dist/index.mjs.js';
|
|
6
|
+
import { jsx } from 'react/jsx-runtime';
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
const relatedTarget = event.relatedTarget; // A `focusout` event with a `null` `relatedTarget` will happen in at least two cases:
|
|
43
|
-
//
|
|
44
|
-
// 1. When the user switches app/tabs/windows/the browser itself loses focus.
|
|
45
|
-
// 2. In Google Chrome, when the focused element is removed from the DOM.
|
|
46
|
-
//
|
|
47
|
-
// We let the browser do its thing here because:
|
|
48
|
-
//
|
|
49
|
-
// 1. The browser already keeps a memory of what's focused for when the page gets refocused.
|
|
50
|
-
// 2. In Google Chrome, if we try to focus the deleted focused element (as per below), it
|
|
51
|
-
// throws the CPU to 100%, so we avoid doing anything for this reason here too.
|
|
52
|
-
if (relatedTarget === null) return; // If the focus has moved to an actual legitimate element (`relatedTarget !== null`)
|
|
53
|
-
// that is outside the container, we move focus to the last valid focused element inside.
|
|
54
|
-
if (!container1.contains(relatedTarget)) $d3863c46a17e8a28$var$focus(lastFocusedElementRef.current, {
|
|
55
|
-
select: true
|
|
56
|
-
});
|
|
57
|
-
} // When the focused element gets removed from the DOM, browsers move focus
|
|
58
|
-
// back to the document.body. In this case, we move focus to the container
|
|
59
|
-
// to keep focus trapped correctly.
|
|
60
|
-
function handleMutations(mutations) {
|
|
61
|
-
const focusedElement = document.activeElement;
|
|
62
|
-
if (focusedElement !== document.body) return;
|
|
63
|
-
for (const mutation of mutations)if (mutation.removedNodes.length > 0) $d3863c46a17e8a28$var$focus(container1);
|
|
64
|
-
}
|
|
65
|
-
document.addEventListener('focusin', handleFocusIn);
|
|
66
|
-
document.addEventListener('focusout', handleFocusOut);
|
|
67
|
-
const mutationObserver = new MutationObserver(handleMutations);
|
|
68
|
-
if (container1) mutationObserver.observe(container1, {
|
|
69
|
-
childList: true,
|
|
70
|
-
subtree: true
|
|
71
|
-
});
|
|
72
|
-
return ()=>{
|
|
73
|
-
document.removeEventListener('focusin', handleFocusIn);
|
|
74
|
-
document.removeEventListener('focusout', handleFocusOut);
|
|
75
|
-
mutationObserver.disconnect();
|
|
76
|
-
};
|
|
8
|
+
var AUTOFOCUS_ON_MOUNT = "focusScope.autoFocusOnMount";
|
|
9
|
+
var AUTOFOCUS_ON_UNMOUNT = "focusScope.autoFocusOnUnmount";
|
|
10
|
+
var EVENT_OPTIONS = { bubbles: false, cancelable: true };
|
|
11
|
+
var FOCUS_SCOPE_NAME = "FocusScope";
|
|
12
|
+
var FocusScope = React.forwardRef((props, forwardedRef) => {
|
|
13
|
+
const {
|
|
14
|
+
loop = false,
|
|
15
|
+
trapped = false,
|
|
16
|
+
onMountAutoFocus: onMountAutoFocusProp,
|
|
17
|
+
onUnmountAutoFocus: onUnmountAutoFocusProp,
|
|
18
|
+
...scopeProps
|
|
19
|
+
} = props;
|
|
20
|
+
const [container, setContainer] = React.useState(null);
|
|
21
|
+
const onMountAutoFocus = useCallbackRef(onMountAutoFocusProp);
|
|
22
|
+
const onUnmountAutoFocus = useCallbackRef(onUnmountAutoFocusProp);
|
|
23
|
+
const lastFocusedElementRef = React.useRef(null);
|
|
24
|
+
const composedRefs = useComposedRefs(forwardedRef, (node) => setContainer(node));
|
|
25
|
+
const focusScope = React.useRef({
|
|
26
|
+
paused: false,
|
|
27
|
+
pause() {
|
|
28
|
+
this.paused = true;
|
|
29
|
+
},
|
|
30
|
+
resume() {
|
|
31
|
+
this.paused = false;
|
|
32
|
+
}
|
|
33
|
+
}).current;
|
|
34
|
+
React.useEffect(() => {
|
|
35
|
+
if (trapped) {
|
|
36
|
+
let handleFocusIn2 = function(event) {
|
|
37
|
+
if (focusScope.paused || !container) return;
|
|
38
|
+
const target = event.target;
|
|
39
|
+
if (container.contains(target)) {
|
|
40
|
+
lastFocusedElementRef.current = target;
|
|
41
|
+
} else {
|
|
42
|
+
focus(lastFocusedElementRef.current, { select: true });
|
|
77
43
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
if (container1) {
|
|
85
|
-
$d3863c46a17e8a28$var$focusScopesStack.add(focusScope);
|
|
86
|
-
const previouslyFocusedElement = document.activeElement;
|
|
87
|
-
const hasFocusedCandidate = container1.contains(previouslyFocusedElement);
|
|
88
|
-
if (!hasFocusedCandidate) {
|
|
89
|
-
const mountEvent = new CustomEvent($d3863c46a17e8a28$var$AUTOFOCUS_ON_MOUNT, $d3863c46a17e8a28$var$EVENT_OPTIONS);
|
|
90
|
-
container1.addEventListener($d3863c46a17e8a28$var$AUTOFOCUS_ON_MOUNT, onMountAutoFocus);
|
|
91
|
-
container1.dispatchEvent(mountEvent);
|
|
92
|
-
if (!mountEvent.defaultPrevented) {
|
|
93
|
-
$d3863c46a17e8a28$var$focusFirst($d3863c46a17e8a28$var$removeLinks($d3863c46a17e8a28$var$getTabbableCandidates(container1)), {
|
|
94
|
-
select: true
|
|
95
|
-
});
|
|
96
|
-
if (document.activeElement === previouslyFocusedElement) $d3863c46a17e8a28$var$focus(container1);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
return ()=>{
|
|
100
|
-
container1.removeEventListener($d3863c46a17e8a28$var$AUTOFOCUS_ON_MOUNT, onMountAutoFocus); // We hit a react bug (fixed in v17) with focusing in unmount.
|
|
101
|
-
// We need to delay the focus a little to get around it for now.
|
|
102
|
-
// See: https://github.com/facebook/react/issues/17894
|
|
103
|
-
setTimeout(()=>{
|
|
104
|
-
const unmountEvent = new CustomEvent($d3863c46a17e8a28$var$AUTOFOCUS_ON_UNMOUNT, $d3863c46a17e8a28$var$EVENT_OPTIONS);
|
|
105
|
-
container1.addEventListener($d3863c46a17e8a28$var$AUTOFOCUS_ON_UNMOUNT, onUnmountAutoFocus);
|
|
106
|
-
container1.dispatchEvent(unmountEvent);
|
|
107
|
-
if (!unmountEvent.defaultPrevented) $d3863c46a17e8a28$var$focus(previouslyFocusedElement !== null && previouslyFocusedElement !== void 0 ? previouslyFocusedElement : document.body, {
|
|
108
|
-
select: true
|
|
109
|
-
});
|
|
110
|
-
// we need to remove the listener after we `dispatchEvent`
|
|
111
|
-
container1.removeEventListener($d3863c46a17e8a28$var$AUTOFOCUS_ON_UNMOUNT, onUnmountAutoFocus);
|
|
112
|
-
$d3863c46a17e8a28$var$focusScopesStack.remove(focusScope);
|
|
113
|
-
}, 0);
|
|
114
|
-
};
|
|
44
|
+
}, handleFocusOut2 = function(event) {
|
|
45
|
+
if (focusScope.paused || !container) return;
|
|
46
|
+
const relatedTarget = event.relatedTarget;
|
|
47
|
+
if (relatedTarget === null) return;
|
|
48
|
+
if (!container.contains(relatedTarget)) {
|
|
49
|
+
focus(lastFocusedElementRef.current, { select: true });
|
|
115
50
|
}
|
|
116
|
-
|
|
117
|
-
container1,
|
|
118
|
-
onMountAutoFocus,
|
|
119
|
-
onUnmountAutoFocus,
|
|
120
|
-
focusScope
|
|
121
|
-
]); // Takes care of looping focus (when tabbing whilst at the edges)
|
|
122
|
-
const handleKeyDown = useCallback((event)=>{
|
|
123
|
-
if (!loop && !trapped) return;
|
|
124
|
-
if (focusScope.paused) return;
|
|
125
|
-
const isTabKey = event.key === 'Tab' && !event.altKey && !event.ctrlKey && !event.metaKey;
|
|
51
|
+
}, handleMutations2 = function(mutations) {
|
|
126
52
|
const focusedElement = document.activeElement;
|
|
127
|
-
if (
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
const hasTabbableElementsInside = first && last; // we can only wrap focus if we have tabbable edges
|
|
131
|
-
if (!hasTabbableElementsInside) {
|
|
132
|
-
if (focusedElement === container) event.preventDefault();
|
|
133
|
-
} else {
|
|
134
|
-
if (!event.shiftKey && focusedElement === last) {
|
|
135
|
-
event.preventDefault();
|
|
136
|
-
if (loop) $d3863c46a17e8a28$var$focus(first, {
|
|
137
|
-
select: true
|
|
138
|
-
});
|
|
139
|
-
} else if (event.shiftKey && focusedElement === first) {
|
|
140
|
-
event.preventDefault();
|
|
141
|
-
if (loop) $d3863c46a17e8a28$var$focus(last, {
|
|
142
|
-
select: true
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
}
|
|
53
|
+
if (focusedElement !== document.body) return;
|
|
54
|
+
for (const mutation of mutations) {
|
|
55
|
+
if (mutation.removedNodes.length > 0) focus(container);
|
|
146
56
|
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
}));
|
|
158
|
-
});
|
|
159
|
-
/* -------------------------------------------------------------------------------------------------
|
|
160
|
-
* Utils
|
|
161
|
-
* -----------------------------------------------------------------------------------------------*/ /**
|
|
162
|
-
* Attempts focusing the first element in a list of candidates.
|
|
163
|
-
* Stops when focus has actually moved.
|
|
164
|
-
*/ function $d3863c46a17e8a28$var$focusFirst(candidates, { select: select = false } = {}) {
|
|
165
|
-
const previouslyFocusedElement = document.activeElement;
|
|
166
|
-
for (const candidate of candidates){
|
|
167
|
-
$d3863c46a17e8a28$var$focus(candidate, {
|
|
168
|
-
select: select
|
|
169
|
-
});
|
|
170
|
-
if (document.activeElement !== previouslyFocusedElement) return;
|
|
57
|
+
};
|
|
58
|
+
document.addEventListener("focusin", handleFocusIn2);
|
|
59
|
+
document.addEventListener("focusout", handleFocusOut2);
|
|
60
|
+
const mutationObserver = new MutationObserver(handleMutations2);
|
|
61
|
+
if (container) mutationObserver.observe(container, { childList: true, subtree: true });
|
|
62
|
+
return () => {
|
|
63
|
+
document.removeEventListener("focusin", handleFocusIn2);
|
|
64
|
+
document.removeEventListener("focusout", handleFocusOut2);
|
|
65
|
+
mutationObserver.disconnect();
|
|
66
|
+
};
|
|
171
67
|
}
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
* NOTE: This is only a close approximation. For example it doesn't take into account cases like when
|
|
188
|
-
* elements are not visible. This cannot be worked out easily by just reading a property, but rather
|
|
189
|
-
* necessitate runtime knowledge (computed styles, etc). We deal with these cases separately.
|
|
190
|
-
*
|
|
191
|
-
* See: https://developer.mozilla.org/en-US/docs/Web/API/TreeWalker
|
|
192
|
-
* Credit: https://github.com/discord/focus-layers/blob/master/src/util/wrapFocus.tsx#L1
|
|
193
|
-
*/ function $d3863c46a17e8a28$var$getTabbableCandidates(container) {
|
|
194
|
-
const nodes = [];
|
|
195
|
-
const walker = document.createTreeWalker(container, NodeFilter.SHOW_ELEMENT, {
|
|
196
|
-
acceptNode: (node)=>{
|
|
197
|
-
const isHiddenInput = node.tagName === 'INPUT' && node.type === 'hidden';
|
|
198
|
-
if (node.disabled || node.hidden || isHiddenInput) return NodeFilter.FILTER_SKIP; // `.tabIndex` is not the same as the `tabindex` attribute. It works on the
|
|
199
|
-
// runtime's understanding of tabbability, so this automatically accounts
|
|
200
|
-
// for any kind of element that could be tabbed to.
|
|
201
|
-
return node.tabIndex >= 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
|
|
68
|
+
}, [trapped, container, focusScope.paused]);
|
|
69
|
+
React.useEffect(() => {
|
|
70
|
+
if (container) {
|
|
71
|
+
focusScopesStack.add(focusScope);
|
|
72
|
+
const previouslyFocusedElement = document.activeElement;
|
|
73
|
+
const hasFocusedCandidate = container.contains(previouslyFocusedElement);
|
|
74
|
+
if (!hasFocusedCandidate) {
|
|
75
|
+
const mountEvent = new CustomEvent(AUTOFOCUS_ON_MOUNT, EVENT_OPTIONS);
|
|
76
|
+
container.addEventListener(AUTOFOCUS_ON_MOUNT, onMountAutoFocus);
|
|
77
|
+
container.dispatchEvent(mountEvent);
|
|
78
|
+
if (!mountEvent.defaultPrevented) {
|
|
79
|
+
focusFirst(removeLinks(getTabbableCandidates(container)), { select: true });
|
|
80
|
+
if (document.activeElement === previouslyFocusedElement) {
|
|
81
|
+
focus(container);
|
|
82
|
+
}
|
|
202
83
|
}
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
84
|
+
}
|
|
85
|
+
return () => {
|
|
86
|
+
container.removeEventListener(AUTOFOCUS_ON_MOUNT, onMountAutoFocus);
|
|
87
|
+
setTimeout(() => {
|
|
88
|
+
const unmountEvent = new CustomEvent(AUTOFOCUS_ON_UNMOUNT, EVENT_OPTIONS);
|
|
89
|
+
container.addEventListener(AUTOFOCUS_ON_UNMOUNT, onUnmountAutoFocus);
|
|
90
|
+
container.dispatchEvent(unmountEvent);
|
|
91
|
+
if (!unmountEvent.defaultPrevented) {
|
|
92
|
+
focus(previouslyFocusedElement ?? document.body, { select: true });
|
|
93
|
+
}
|
|
94
|
+
container.removeEventListener(AUTOFOCUS_ON_UNMOUNT, onUnmountAutoFocus);
|
|
95
|
+
focusScopesStack.remove(focusScope);
|
|
96
|
+
}, 0);
|
|
97
|
+
};
|
|
217
98
|
}
|
|
99
|
+
}, [container, onMountAutoFocus, onUnmountAutoFocus, focusScope]);
|
|
100
|
+
const handleKeyDown = React.useCallback(
|
|
101
|
+
(event) => {
|
|
102
|
+
if (!loop && !trapped) return;
|
|
103
|
+
if (focusScope.paused) return;
|
|
104
|
+
const isTabKey = event.key === "Tab" && !event.altKey && !event.ctrlKey && !event.metaKey;
|
|
105
|
+
const focusedElement = document.activeElement;
|
|
106
|
+
if (isTabKey && focusedElement) {
|
|
107
|
+
const container2 = event.currentTarget;
|
|
108
|
+
const [first, last] = getTabbableEdges(container2);
|
|
109
|
+
const hasTabbableElementsInside = first && last;
|
|
110
|
+
if (!hasTabbableElementsInside) {
|
|
111
|
+
if (focusedElement === container2) event.preventDefault();
|
|
112
|
+
} else {
|
|
113
|
+
if (!event.shiftKey && focusedElement === last) {
|
|
114
|
+
event.preventDefault();
|
|
115
|
+
if (loop) focus(first, { select: true });
|
|
116
|
+
} else if (event.shiftKey && focusedElement === first) {
|
|
117
|
+
event.preventDefault();
|
|
118
|
+
if (loop) focus(last, { select: true });
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
[loop, trapped, focusScope.paused]
|
|
124
|
+
);
|
|
125
|
+
return /* @__PURE__ */ jsx(Primitive.div, { tabIndex: -1, ...scopeProps, ref: composedRefs, onKeyDown: handleKeyDown });
|
|
126
|
+
});
|
|
127
|
+
FocusScope.displayName = FOCUS_SCOPE_NAME;
|
|
128
|
+
function focusFirst(candidates, { select = false } = {}) {
|
|
129
|
+
const previouslyFocusedElement = document.activeElement;
|
|
130
|
+
for (const candidate of candidates) {
|
|
131
|
+
focus(candidate, { select });
|
|
132
|
+
if (document.activeElement !== previouslyFocusedElement) return;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
function getTabbableEdges(container) {
|
|
136
|
+
const candidates = getTabbableCandidates(container);
|
|
137
|
+
const first = findVisible(candidates, container);
|
|
138
|
+
const last = findVisible(candidates.reverse(), container);
|
|
139
|
+
return [first, last];
|
|
218
140
|
}
|
|
219
|
-
function
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
141
|
+
function getTabbableCandidates(container) {
|
|
142
|
+
const nodes = [];
|
|
143
|
+
const walker = document.createTreeWalker(container, NodeFilter.SHOW_ELEMENT, {
|
|
144
|
+
acceptNode: (node) => {
|
|
145
|
+
const isHiddenInput = node.tagName === "INPUT" && node.type === "hidden";
|
|
146
|
+
if (node.disabled || node.hidden || isHiddenInput) return NodeFilter.FILTER_SKIP;
|
|
147
|
+
return node.tabIndex >= 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
|
|
226
148
|
}
|
|
227
|
-
|
|
149
|
+
});
|
|
150
|
+
while (walker.nextNode()) nodes.push(walker.currentNode);
|
|
151
|
+
return nodes;
|
|
228
152
|
}
|
|
229
|
-
function
|
|
230
|
-
|
|
153
|
+
function findVisible(elements, container) {
|
|
154
|
+
for (const element of elements) {
|
|
155
|
+
if (!isHidden(element, { upTo: container })) return element;
|
|
156
|
+
}
|
|
231
157
|
}
|
|
232
|
-
function
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
}
|
|
158
|
+
function isHidden(node, { upTo }) {
|
|
159
|
+
if (getComputedStyle(node).visibility === "hidden") return true;
|
|
160
|
+
while (node) {
|
|
161
|
+
if (upTo !== void 0 && node === upTo) return false;
|
|
162
|
+
if (getComputedStyle(node).display === "none") return true;
|
|
163
|
+
node = node.parentElement;
|
|
164
|
+
}
|
|
165
|
+
return false;
|
|
241
166
|
}
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
function
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
167
|
+
function isSelectableInput(element) {
|
|
168
|
+
return element instanceof HTMLInputElement && "select" in element;
|
|
169
|
+
}
|
|
170
|
+
function focus(element, { select = false } = {}) {
|
|
171
|
+
if (element && element.focus) {
|
|
172
|
+
const previouslyFocusedElement = document.activeElement;
|
|
173
|
+
element.focus({ preventScroll: true });
|
|
174
|
+
if (element !== previouslyFocusedElement && isSelectableInput(element) && select)
|
|
175
|
+
element.select();
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
var focusScopesStack = createFocusScopesStack();
|
|
179
|
+
function createFocusScopesStack() {
|
|
180
|
+
let stack = [];
|
|
181
|
+
return {
|
|
182
|
+
add(focusScope) {
|
|
183
|
+
const activeFocusScope = stack[0];
|
|
184
|
+
if (focusScope !== activeFocusScope) {
|
|
185
|
+
activeFocusScope?.pause();
|
|
186
|
+
}
|
|
187
|
+
stack = arrayRemove(stack, focusScope);
|
|
188
|
+
stack.unshift(focusScope);
|
|
189
|
+
},
|
|
190
|
+
remove(focusScope) {
|
|
191
|
+
stack = arrayRemove(stack, focusScope);
|
|
192
|
+
stack[0]?.resume();
|
|
193
|
+
}
|
|
194
|
+
};
|
|
262
195
|
}
|
|
263
|
-
function
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
196
|
+
function arrayRemove(array, item) {
|
|
197
|
+
const updatedArray = [...array];
|
|
198
|
+
const index = updatedArray.indexOf(item);
|
|
199
|
+
if (index !== -1) {
|
|
200
|
+
updatedArray.splice(index, 1);
|
|
201
|
+
}
|
|
202
|
+
return updatedArray;
|
|
270
203
|
}
|
|
271
|
-
function
|
|
272
|
-
|
|
273
|
-
);
|
|
204
|
+
function removeLinks(items) {
|
|
205
|
+
return items.filter((item) => item.tagName !== "A");
|
|
274
206
|
}
|
|
275
207
|
|
|
276
|
-
export {
|
|
208
|
+
export { FocusScope };
|
|
277
209
|
//# sourceMappingURL=index.mjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs.js","sources":["../../../../../node_modules/@radix-ui/react-focus-scope/dist/index.mjs"],"sourcesContent":["import $45QHv$babelruntimehelpersesmextends from \"@babel/runtime/helpers/esm/extends\";\nimport {forwardRef as $45QHv$forwardRef, useState as $45QHv$useState, useRef as $45QHv$useRef, useEffect as $45QHv$useEffect, useCallback as $45QHv$useCallback, createElement as $45QHv$createElement} from \"react\";\nimport {useComposedRefs as $45QHv$useComposedRefs} from \"@radix-ui/react-compose-refs\";\nimport {Primitive as $45QHv$Primitive} from \"@radix-ui/react-primitive\";\nimport {useCallbackRef as $45QHv$useCallbackRef} from \"@radix-ui/react-use-callback-ref\";\n\n\n\n\n\n\nconst $d3863c46a17e8a28$var$AUTOFOCUS_ON_MOUNT = 'focusScope.autoFocusOnMount';\nconst $d3863c46a17e8a28$var$AUTOFOCUS_ON_UNMOUNT = 'focusScope.autoFocusOnUnmount';\nconst $d3863c46a17e8a28$var$EVENT_OPTIONS = {\n bubbles: false,\n cancelable: true\n};\n/* -------------------------------------------------------------------------------------------------\n * FocusScope\n * -----------------------------------------------------------------------------------------------*/ const $d3863c46a17e8a28$var$FOCUS_SCOPE_NAME = 'FocusScope';\nconst $d3863c46a17e8a28$export$20e40289641fbbb6 = /*#__PURE__*/ $45QHv$forwardRef((props, forwardedRef)=>{\n const { loop: loop = false , trapped: trapped = false , onMountAutoFocus: onMountAutoFocusProp , onUnmountAutoFocus: onUnmountAutoFocusProp , ...scopeProps } = props;\n const [container1, setContainer] = $45QHv$useState(null);\n const onMountAutoFocus = $45QHv$useCallbackRef(onMountAutoFocusProp);\n const onUnmountAutoFocus = $45QHv$useCallbackRef(onUnmountAutoFocusProp);\n const lastFocusedElementRef = $45QHv$useRef(null);\n const composedRefs = $45QHv$useComposedRefs(forwardedRef, (node)=>setContainer(node)\n );\n const focusScope = $45QHv$useRef({\n paused: false,\n pause () {\n this.paused = true;\n },\n resume () {\n this.paused = false;\n }\n }).current; // Takes care of trapping focus if focus is moved outside programmatically for example\n $45QHv$useEffect(()=>{\n if (trapped) {\n function handleFocusIn(event) {\n if (focusScope.paused || !container1) return;\n const target = event.target;\n if (container1.contains(target)) lastFocusedElementRef.current = target;\n else $d3863c46a17e8a28$var$focus(lastFocusedElementRef.current, {\n select: true\n });\n }\n function handleFocusOut(event) {\n if (focusScope.paused || !container1) return;\n const relatedTarget = event.relatedTarget; // A `focusout` event with a `null` `relatedTarget` will happen in at least two cases:\n //\n // 1. When the user switches app/tabs/windows/the browser itself loses focus.\n // 2. In Google Chrome, when the focused element is removed from the DOM.\n //\n // We let the browser do its thing here because:\n //\n // 1. The browser already keeps a memory of what's focused for when the page gets refocused.\n // 2. In Google Chrome, if we try to focus the deleted focused element (as per below), it\n // throws the CPU to 100%, so we avoid doing anything for this reason here too.\n if (relatedTarget === null) return; // If the focus has moved to an actual legitimate element (`relatedTarget !== null`)\n // that is outside the container, we move focus to the last valid focused element inside.\n if (!container1.contains(relatedTarget)) $d3863c46a17e8a28$var$focus(lastFocusedElementRef.current, {\n select: true\n });\n } // When the focused element gets removed from the DOM, browsers move focus\n // back to the document.body. In this case, we move focus to the container\n // to keep focus trapped correctly.\n function handleMutations(mutations) {\n const focusedElement = document.activeElement;\n if (focusedElement !== document.body) return;\n for (const mutation of mutations)if (mutation.removedNodes.length > 0) $d3863c46a17e8a28$var$focus(container1);\n }\n document.addEventListener('focusin', handleFocusIn);\n document.addEventListener('focusout', handleFocusOut);\n const mutationObserver = new MutationObserver(handleMutations);\n if (container1) mutationObserver.observe(container1, {\n childList: true,\n subtree: true\n });\n return ()=>{\n document.removeEventListener('focusin', handleFocusIn);\n document.removeEventListener('focusout', handleFocusOut);\n mutationObserver.disconnect();\n };\n }\n }, [\n trapped,\n container1,\n focusScope.paused\n ]);\n $45QHv$useEffect(()=>{\n if (container1) {\n $d3863c46a17e8a28$var$focusScopesStack.add(focusScope);\n const previouslyFocusedElement = document.activeElement;\n const hasFocusedCandidate = container1.contains(previouslyFocusedElement);\n if (!hasFocusedCandidate) {\n const mountEvent = new CustomEvent($d3863c46a17e8a28$var$AUTOFOCUS_ON_MOUNT, $d3863c46a17e8a28$var$EVENT_OPTIONS);\n container1.addEventListener($d3863c46a17e8a28$var$AUTOFOCUS_ON_MOUNT, onMountAutoFocus);\n container1.dispatchEvent(mountEvent);\n if (!mountEvent.defaultPrevented) {\n $d3863c46a17e8a28$var$focusFirst($d3863c46a17e8a28$var$removeLinks($d3863c46a17e8a28$var$getTabbableCandidates(container1)), {\n select: true\n });\n if (document.activeElement === previouslyFocusedElement) $d3863c46a17e8a28$var$focus(container1);\n }\n }\n return ()=>{\n container1.removeEventListener($d3863c46a17e8a28$var$AUTOFOCUS_ON_MOUNT, onMountAutoFocus); // We hit a react bug (fixed in v17) with focusing in unmount.\n // We need to delay the focus a little to get around it for now.\n // See: https://github.com/facebook/react/issues/17894\n setTimeout(()=>{\n const unmountEvent = new CustomEvent($d3863c46a17e8a28$var$AUTOFOCUS_ON_UNMOUNT, $d3863c46a17e8a28$var$EVENT_OPTIONS);\n container1.addEventListener($d3863c46a17e8a28$var$AUTOFOCUS_ON_UNMOUNT, onUnmountAutoFocus);\n container1.dispatchEvent(unmountEvent);\n if (!unmountEvent.defaultPrevented) $d3863c46a17e8a28$var$focus(previouslyFocusedElement !== null && previouslyFocusedElement !== void 0 ? previouslyFocusedElement : document.body, {\n select: true\n });\n // we need to remove the listener after we `dispatchEvent`\n container1.removeEventListener($d3863c46a17e8a28$var$AUTOFOCUS_ON_UNMOUNT, onUnmountAutoFocus);\n $d3863c46a17e8a28$var$focusScopesStack.remove(focusScope);\n }, 0);\n };\n }\n }, [\n container1,\n onMountAutoFocus,\n onUnmountAutoFocus,\n focusScope\n ]); // Takes care of looping focus (when tabbing whilst at the edges)\n const handleKeyDown = $45QHv$useCallback((event)=>{\n if (!loop && !trapped) return;\n if (focusScope.paused) return;\n const isTabKey = event.key === 'Tab' && !event.altKey && !event.ctrlKey && !event.metaKey;\n const focusedElement = document.activeElement;\n if (isTabKey && focusedElement) {\n const container = event.currentTarget;\n const [first, last] = $d3863c46a17e8a28$var$getTabbableEdges(container);\n const hasTabbableElementsInside = first && last; // we can only wrap focus if we have tabbable edges\n if (!hasTabbableElementsInside) {\n if (focusedElement === container) event.preventDefault();\n } else {\n if (!event.shiftKey && focusedElement === last) {\n event.preventDefault();\n if (loop) $d3863c46a17e8a28$var$focus(first, {\n select: true\n });\n } else if (event.shiftKey && focusedElement === first) {\n event.preventDefault();\n if (loop) $d3863c46a17e8a28$var$focus(last, {\n select: true\n });\n }\n }\n }\n }, [\n loop,\n trapped,\n focusScope.paused\n ]);\n return /*#__PURE__*/ $45QHv$createElement($45QHv$Primitive.div, $45QHv$babelruntimehelpersesmextends({\n tabIndex: -1\n }, scopeProps, {\n ref: composedRefs,\n onKeyDown: handleKeyDown\n }));\n});\n/*#__PURE__*/ Object.assign($d3863c46a17e8a28$export$20e40289641fbbb6, {\n displayName: $d3863c46a17e8a28$var$FOCUS_SCOPE_NAME\n});\n/* -------------------------------------------------------------------------------------------------\n * Utils\n * -----------------------------------------------------------------------------------------------*/ /**\n * Attempts focusing the first element in a list of candidates.\n * Stops when focus has actually moved.\n */ function $d3863c46a17e8a28$var$focusFirst(candidates, { select: select = false } = {}) {\n const previouslyFocusedElement = document.activeElement;\n for (const candidate of candidates){\n $d3863c46a17e8a28$var$focus(candidate, {\n select: select\n });\n if (document.activeElement !== previouslyFocusedElement) return;\n }\n}\n/**\n * Returns the first and last tabbable elements inside a container.\n */ function $d3863c46a17e8a28$var$getTabbableEdges(container) {\n const candidates = $d3863c46a17e8a28$var$getTabbableCandidates(container);\n const first = $d3863c46a17e8a28$var$findVisible(candidates, container);\n const last = $d3863c46a17e8a28$var$findVisible(candidates.reverse(), container);\n return [\n first,\n last\n ];\n}\n/**\n * Returns a list of potential tabbable candidates.\n *\n * NOTE: This is only a close approximation. For example it doesn't take into account cases like when\n * elements are not visible. This cannot be worked out easily by just reading a property, but rather\n * necessitate runtime knowledge (computed styles, etc). We deal with these cases separately.\n *\n * See: https://developer.mozilla.org/en-US/docs/Web/API/TreeWalker\n * Credit: https://github.com/discord/focus-layers/blob/master/src/util/wrapFocus.tsx#L1\n */ function $d3863c46a17e8a28$var$getTabbableCandidates(container) {\n const nodes = [];\n const walker = document.createTreeWalker(container, NodeFilter.SHOW_ELEMENT, {\n acceptNode: (node)=>{\n const isHiddenInput = node.tagName === 'INPUT' && node.type === 'hidden';\n if (node.disabled || node.hidden || isHiddenInput) return NodeFilter.FILTER_SKIP; // `.tabIndex` is not the same as the `tabindex` attribute. It works on the\n // runtime's understanding of tabbability, so this automatically accounts\n // for any kind of element that could be tabbed to.\n return node.tabIndex >= 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;\n }\n });\n while(walker.nextNode())nodes.push(walker.currentNode); // we do not take into account the order of nodes with positive `tabIndex` as it\n // hinders accessibility to have tab order different from visual order.\n return nodes;\n}\n/**\n * Returns the first visible element in a list.\n * NOTE: Only checks visibility up to the `container`.\n */ function $d3863c46a17e8a28$var$findVisible(elements, container) {\n for (const element of elements){\n // we stop checking if it's hidden at the `container` level (excluding)\n if (!$d3863c46a17e8a28$var$isHidden(element, {\n upTo: container\n })) return element;\n }\n}\nfunction $d3863c46a17e8a28$var$isHidden(node, { upTo: upTo }) {\n if (getComputedStyle(node).visibility === 'hidden') return true;\n while(node){\n // we stop at `upTo` (excluding it)\n if (upTo !== undefined && node === upTo) return false;\n if (getComputedStyle(node).display === 'none') return true;\n node = node.parentElement;\n }\n return false;\n}\nfunction $d3863c46a17e8a28$var$isSelectableInput(element) {\n return element instanceof HTMLInputElement && 'select' in element;\n}\nfunction $d3863c46a17e8a28$var$focus(element, { select: select = false } = {}) {\n // only focus if that element is focusable\n if (element && element.focus) {\n const previouslyFocusedElement = document.activeElement; // NOTE: we prevent scrolling on focus, to minimize jarring transitions for users\n element.focus({\n preventScroll: true\n }); // only select if its not the same element, it supports selection and we need to select\n if (element !== previouslyFocusedElement && $d3863c46a17e8a28$var$isSelectableInput(element) && select) element.select();\n }\n}\n/* -------------------------------------------------------------------------------------------------\n * FocusScope stack\n * -----------------------------------------------------------------------------------------------*/ const $d3863c46a17e8a28$var$focusScopesStack = $d3863c46a17e8a28$var$createFocusScopesStack();\nfunction $d3863c46a17e8a28$var$createFocusScopesStack() {\n /** A stack of focus scopes, with the active one at the top */ let stack = [];\n return {\n add (focusScope) {\n // pause the currently active focus scope (at the top of the stack)\n const activeFocusScope = stack[0];\n if (focusScope !== activeFocusScope) activeFocusScope === null || activeFocusScope === void 0 || activeFocusScope.pause();\n // remove in case it already exists (because we'll re-add it at the top of the stack)\n stack = $d3863c46a17e8a28$var$arrayRemove(stack, focusScope);\n stack.unshift(focusScope);\n },\n remove (focusScope) {\n var _stack$;\n stack = $d3863c46a17e8a28$var$arrayRemove(stack, focusScope);\n (_stack$ = stack[0]) === null || _stack$ === void 0 || _stack$.resume();\n }\n };\n}\nfunction $d3863c46a17e8a28$var$arrayRemove(array, item) {\n const updatedArray = [\n ...array\n ];\n const index = updatedArray.indexOf(item);\n if (index !== -1) updatedArray.splice(index, 1);\n return updatedArray;\n}\nfunction $d3863c46a17e8a28$var$removeLinks(items) {\n return items.filter((item)=>item.tagName !== 'A'\n );\n}\nconst $d3863c46a17e8a28$export$be92b6f5f03c0fe9 = $d3863c46a17e8a28$export$20e40289641fbbb6;\n\n\n\n\nexport {$d3863c46a17e8a28$export$20e40289641fbbb6 as FocusScope, $d3863c46a17e8a28$export$be92b6f5f03c0fe9 as Root};\n//# sourceMappingURL=index.mjs.map\n"],"names":["$45QHv$forwardRef","$45QHv$useState","$45QHv$useCallbackRef","$45QHv$useRef","$45QHv$useComposedRefs","$45QHv$useEffect","$45QHv$useCallback","$45QHv$createElement","$45QHv$Primitive","$45QHv$babelruntimehelpersesmextends"],"mappings":";;;;;;AAWA,MAAM,wCAAwC,GAAG,6BAA6B,CAAC;AAC/E,MAAM,0CAA0C,GAAG,+BAA+B,CAAC;AACnF,MAAM,mCAAmC,GAAG;AAC5C,IAAI,OAAO,EAAE,KAAK;AAClB,IAAI,UAAU,EAAE,IAAI;AACpB,CAAC,CAAC;AAIG,MAAC,yCAAyC,iBAAiBA,UAAiB,CAAC,CAAC,KAAK,EAAE,YAAY,GAAG;AACzG,IAAI,MAAM,EAAE,IAAI,EAAE,IAAI,GAAG,KAAK,GAAG,OAAO,EAAE,OAAO,GAAG,KAAK,GAAG,gBAAgB,EAAE,oBAAoB,GAAG,kBAAkB,EAAE,sBAAsB,GAAG,GAAG,UAAU,EAAE,GAAG,KAAK,CAAC;AAC1K,IAAI,MAAM,CAAC,UAAU,EAAE,YAAY,CAAC,GAAGC,QAAe,CAAC,IAAI,CAAC,CAAC;AAC7D,IAAI,MAAM,gBAAgB,GAAGC,yCAAqB,CAAC,oBAAoB,CAAC,CAAC;AACzE,IAAI,MAAM,kBA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,EAAE,YAAY,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;AACpD,IAAI,OAAO,YAAY,CAAC;AACxB,CAAC;AACD,SAAS,iCAAiC,CAAC,KAAK,EAAE;AAClD,IAAI,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,GAAG,IAAI,CAAC,OAAO,KAAK,GAAG;AACpD,KAAK,CAAC;AACN;;;;"}
|
|
1
|
+
{"version":3,"file":"index.mjs.js","sources":["../../../../../node_modules/@radix-ui/react-focus-scope/dist/index.mjs"],"sourcesContent":["\"use client\";\n\n// src/focus-scope.tsx\nimport * as React from \"react\";\nimport { useComposedRefs } from \"@radix-ui/react-compose-refs\";\nimport { Primitive } from \"@radix-ui/react-primitive\";\nimport { useCallbackRef } from \"@radix-ui/react-use-callback-ref\";\nimport { jsx } from \"react/jsx-runtime\";\nvar AUTOFOCUS_ON_MOUNT = \"focusScope.autoFocusOnMount\";\nvar AUTOFOCUS_ON_UNMOUNT = \"focusScope.autoFocusOnUnmount\";\nvar EVENT_OPTIONS = { bubbles: false, cancelable: true };\nvar FOCUS_SCOPE_NAME = \"FocusScope\";\nvar FocusScope = React.forwardRef((props, forwardedRef) => {\n const {\n loop = false,\n trapped = false,\n onMountAutoFocus: onMountAutoFocusProp,\n onUnmountAutoFocus: onUnmountAutoFocusProp,\n ...scopeProps\n } = props;\n const [container, setContainer] = React.useState(null);\n const onMountAutoFocus = useCallbackRef(onMountAutoFocusProp);\n const onUnmountAutoFocus = useCallbackRef(onUnmountAutoFocusProp);\n const lastFocusedElementRef = React.useRef(null);\n const composedRefs = useComposedRefs(forwardedRef, (node) => setContainer(node));\n const focusScope = React.useRef({\n paused: false,\n pause() {\n this.paused = true;\n },\n resume() {\n this.paused = false;\n }\n }).current;\n React.useEffect(() => {\n if (trapped) {\n let handleFocusIn2 = function(event) {\n if (focusScope.paused || !container) return;\n const target = event.target;\n if (container.contains(target)) {\n lastFocusedElementRef.current = target;\n } else {\n focus(lastFocusedElementRef.current, { select: true });\n }\n }, handleFocusOut2 = function(event) {\n if (focusScope.paused || !container) return;\n const relatedTarget = event.relatedTarget;\n if (relatedTarget === null) return;\n if (!container.contains(relatedTarget)) {\n focus(lastFocusedElementRef.current, { select: true });\n }\n }, handleMutations2 = function(mutations) {\n const focusedElement = document.activeElement;\n if (focusedElement !== document.body) return;\n for (const mutation of mutations) {\n if (mutation.removedNodes.length > 0) focus(container);\n }\n };\n var handleFocusIn = handleFocusIn2, handleFocusOut = handleFocusOut2, handleMutations = handleMutations2;\n document.addEventListener(\"focusin\", handleFocusIn2);\n document.addEventListener(\"focusout\", handleFocusOut2);\n const mutationObserver = new MutationObserver(handleMutations2);\n if (container) mutationObserver.observe(container, { childList: true, subtree: true });\n return () => {\n document.removeEventListener(\"focusin\", handleFocusIn2);\n document.removeEventListener(\"focusout\", handleFocusOut2);\n mutationObserver.disconnect();\n };\n }\n }, [trapped, container, focusScope.paused]);\n React.useEffect(() => {\n if (container) {\n focusScopesStack.add(focusScope);\n const previouslyFocusedElement = document.activeElement;\n const hasFocusedCandidate = container.contains(previouslyFocusedElement);\n if (!hasFocusedCandidate) {\n const mountEvent = new CustomEvent(AUTOFOCUS_ON_MOUNT, EVENT_OPTIONS);\n container.addEventListener(AUTOFOCUS_ON_MOUNT, onMountAutoFocus);\n container.dispatchEvent(mountEvent);\n if (!mountEvent.defaultPrevented) {\n focusFirst(removeLinks(getTabbableCandidates(container)), { select: true });\n if (document.activeElement === previouslyFocusedElement) {\n focus(container);\n }\n }\n }\n return () => {\n container.removeEventListener(AUTOFOCUS_ON_MOUNT, onMountAutoFocus);\n setTimeout(() => {\n const unmountEvent = new CustomEvent(AUTOFOCUS_ON_UNMOUNT, EVENT_OPTIONS);\n container.addEventListener(AUTOFOCUS_ON_UNMOUNT, onUnmountAutoFocus);\n container.dispatchEvent(unmountEvent);\n if (!unmountEvent.defaultPrevented) {\n focus(previouslyFocusedElement ?? document.body, { select: true });\n }\n container.removeEventListener(AUTOFOCUS_ON_UNMOUNT, onUnmountAutoFocus);\n focusScopesStack.remove(focusScope);\n }, 0);\n };\n }\n }, [container, onMountAutoFocus, onUnmountAutoFocus, focusScope]);\n const handleKeyDown = React.useCallback(\n (event) => {\n if (!loop && !trapped) return;\n if (focusScope.paused) return;\n const isTabKey = event.key === \"Tab\" && !event.altKey && !event.ctrlKey && !event.metaKey;\n const focusedElement = document.activeElement;\n if (isTabKey && focusedElement) {\n const container2 = event.currentTarget;\n const [first, last] = getTabbableEdges(container2);\n const hasTabbableElementsInside = first && last;\n if (!hasTabbableElementsInside) {\n if (focusedElement === container2) event.preventDefault();\n } else {\n if (!event.shiftKey && focusedElement === last) {\n event.preventDefault();\n if (loop) focus(first, { select: true });\n } else if (event.shiftKey && focusedElement === first) {\n event.preventDefault();\n if (loop) focus(last, { select: true });\n }\n }\n }\n },\n [loop, trapped, focusScope.paused]\n );\n return /* @__PURE__ */ jsx(Primitive.div, { tabIndex: -1, ...scopeProps, ref: composedRefs, onKeyDown: handleKeyDown });\n});\nFocusScope.displayName = FOCUS_SCOPE_NAME;\nfunction focusFirst(candidates, { select = false } = {}) {\n const previouslyFocusedElement = document.activeElement;\n for (const candidate of candidates) {\n focus(candidate, { select });\n if (document.activeElement !== previouslyFocusedElement) return;\n }\n}\nfunction getTabbableEdges(container) {\n const candidates = getTabbableCandidates(container);\n const first = findVisible(candidates, container);\n const last = findVisible(candidates.reverse(), container);\n return [first, last];\n}\nfunction getTabbableCandidates(container) {\n const nodes = [];\n const walker = document.createTreeWalker(container, NodeFilter.SHOW_ELEMENT, {\n acceptNode: (node) => {\n const isHiddenInput = node.tagName === \"INPUT\" && node.type === \"hidden\";\n if (node.disabled || node.hidden || isHiddenInput) return NodeFilter.FILTER_SKIP;\n return node.tabIndex >= 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;\n }\n });\n while (walker.nextNode()) nodes.push(walker.currentNode);\n return nodes;\n}\nfunction findVisible(elements, container) {\n for (const element of elements) {\n if (!isHidden(element, { upTo: container })) return element;\n }\n}\nfunction isHidden(node, { upTo }) {\n if (getComputedStyle(node).visibility === \"hidden\") return true;\n while (node) {\n if (upTo !== void 0 && node === upTo) return false;\n if (getComputedStyle(node).display === \"none\") return true;\n node = node.parentElement;\n }\n return false;\n}\nfunction isSelectableInput(element) {\n return element instanceof HTMLInputElement && \"select\" in element;\n}\nfunction focus(element, { select = false } = {}) {\n if (element && element.focus) {\n const previouslyFocusedElement = document.activeElement;\n element.focus({ preventScroll: true });\n if (element !== previouslyFocusedElement && isSelectableInput(element) && select)\n element.select();\n }\n}\nvar focusScopesStack = createFocusScopesStack();\nfunction createFocusScopesStack() {\n let stack = [];\n return {\n add(focusScope) {\n const activeFocusScope = stack[0];\n if (focusScope !== activeFocusScope) {\n activeFocusScope?.pause();\n }\n stack = arrayRemove(stack, focusScope);\n stack.unshift(focusScope);\n },\n remove(focusScope) {\n stack = arrayRemove(stack, focusScope);\n stack[0]?.resume();\n }\n };\n}\nfunction arrayRemove(array, item) {\n const updatedArray = [...array];\n const index = updatedArray.indexOf(item);\n if (index !== -1) {\n updatedArray.splice(index, 1);\n }\n return updatedArray;\n}\nfunction removeLinks(items) {\n return items.filter((item) => item.tagName !== \"A\");\n}\nvar Root = FocusScope;\nexport {\n FocusScope,\n Root\n};\n//# sourceMappingURL=index.mjs.map\n"],"names":[],"mappings":";;;;;;;AAQA;AACA;AACA;AACA;AACG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;"}
|