@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,150 +1,172 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { clamp
|
|
5
|
-
import { composeEventHandlers
|
|
6
|
-
import { createCollection
|
|
7
|
-
import { useComposedRefs
|
|
8
|
-
import { createContextScope
|
|
9
|
-
import { useDirection
|
|
10
|
-
import { DismissableLayer
|
|
11
|
-
import { useFocusGuards
|
|
12
|
-
import { FocusScope
|
|
13
|
-
import { useId
|
|
14
|
-
import { createPopperScope
|
|
15
|
-
import { Portal as $
|
|
16
|
-
import { Primitive
|
|
17
|
-
import {
|
|
18
|
-
import { useCallbackRef
|
|
19
|
-
import { useControllableState
|
|
20
|
-
import { useLayoutEffect as
|
|
21
|
-
import { usePrevious
|
|
22
|
-
import {
|
|
1
|
+
'use client';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import * as ReactDOM from 'react-dom';
|
|
4
|
+
import { clamp } from '../../number/dist/index.mjs.js';
|
|
5
|
+
import { composeEventHandlers } from '../../primitive/dist/index.mjs.js';
|
|
6
|
+
import { createCollection } from '../../react-collection/dist/index.mjs.js';
|
|
7
|
+
import { useComposedRefs } from '../../react-compose-refs/dist/index.mjs.js';
|
|
8
|
+
import { createContextScope } from '../../react-context/dist/index.mjs.js';
|
|
9
|
+
import { useDirection } from '../../react-direction/dist/index.mjs.js';
|
|
10
|
+
import { DismissableLayer } from '../../react-dismissable-layer/dist/index.mjs.js';
|
|
11
|
+
import { useFocusGuards } from '../../react-focus-guards/dist/index.mjs.js';
|
|
12
|
+
import { FocusScope } from '../../react-focus-scope/dist/index.mjs.js';
|
|
13
|
+
import { useId } from '../../react-id/dist/index.mjs.js';
|
|
14
|
+
import { createPopperScope, Anchor, Content, Arrow, Root as Root2$1 } from '../../react-popper/dist/index.mjs.js';
|
|
15
|
+
import { Portal as Portal$1 } from '../../react-portal/dist/index.mjs.js';
|
|
16
|
+
import { Primitive } from '../../react-primitive/dist/index.mjs.js';
|
|
17
|
+
import { createSlot } from '../node_modules/@radix-ui/react-slot/dist/index.mjs.js';
|
|
18
|
+
import { useCallbackRef } from '../../react-use-callback-ref/dist/index.mjs.js';
|
|
19
|
+
import { useControllableState } from '../../react-use-controllable-state/dist/index.mjs.js';
|
|
20
|
+
import { useLayoutEffect as useLayoutEffect2 } from '../../react-use-layout-effect/dist/index.mjs.js';
|
|
21
|
+
import { usePrevious } from '../../react-use-previous/dist/index.mjs.js';
|
|
22
|
+
import { VISUALLY_HIDDEN_STYLES } from '../../react-visually-hidden/dist/index.mjs.js';
|
|
23
23
|
import { hideOthers } from '../../../aria-hidden/dist/es2015/index.js';
|
|
24
24
|
import ReactRemoveScroll from '../../../react-remove-scroll/dist/es2015/Combination.js';
|
|
25
|
+
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
25
26
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
' ',
|
|
34
|
-
'Enter'
|
|
35
|
-
];
|
|
36
|
-
/* -------------------------------------------------------------------------------------------------
|
|
37
|
-
* Select
|
|
38
|
-
* -----------------------------------------------------------------------------------------------*/ const $cc7e05a45900e73f$var$SELECT_NAME = 'Select';
|
|
39
|
-
const [$cc7e05a45900e73f$var$Collection, $cc7e05a45900e73f$var$useCollection, $cc7e05a45900e73f$var$createCollectionScope] = $e02a7d9cb1dc128c$export$c74125a8e3af6bb2($cc7e05a45900e73f$var$SELECT_NAME);
|
|
40
|
-
const [$cc7e05a45900e73f$var$createSelectContext, $cc7e05a45900e73f$export$286727a75dc039bd] = $c512c27ab02ef895$export$50c7b4e9d9f19c1($cc7e05a45900e73f$var$SELECT_NAME, [
|
|
41
|
-
$cc7e05a45900e73f$var$createCollectionScope,
|
|
42
|
-
$cf1ac5d9fe0e8206$export$722aac194ae923
|
|
27
|
+
var OPEN_KEYS = [" ", "Enter", "ArrowUp", "ArrowDown"];
|
|
28
|
+
var SELECTION_KEYS = [" ", "Enter"];
|
|
29
|
+
var SELECT_NAME = "Select";
|
|
30
|
+
var [Collection, useCollection, createCollectionScope] = createCollection(SELECT_NAME);
|
|
31
|
+
var [createSelectContext, createSelectScope] = createContextScope(SELECT_NAME, [
|
|
32
|
+
createCollectionScope,
|
|
33
|
+
createPopperScope
|
|
43
34
|
]);
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
35
|
+
var usePopperScope = createPopperScope();
|
|
36
|
+
var [SelectProvider, useSelectContext] = createSelectContext(SELECT_NAME);
|
|
37
|
+
var [SelectNativeOptionsProvider, useSelectNativeOptionsContext] = createSelectContext(SELECT_NAME);
|
|
38
|
+
var Select = (props) => {
|
|
39
|
+
const {
|
|
40
|
+
__scopeSelect,
|
|
41
|
+
children,
|
|
42
|
+
open: openProp,
|
|
43
|
+
defaultOpen,
|
|
44
|
+
onOpenChange,
|
|
45
|
+
value: valueProp,
|
|
46
|
+
defaultValue,
|
|
47
|
+
onValueChange,
|
|
48
|
+
dir,
|
|
49
|
+
name,
|
|
50
|
+
autoComplete,
|
|
51
|
+
disabled,
|
|
52
|
+
required,
|
|
53
|
+
form
|
|
54
|
+
} = props;
|
|
55
|
+
const popperScope = usePopperScope(__scopeSelect);
|
|
56
|
+
const [trigger, setTrigger] = React.useState(null);
|
|
57
|
+
const [valueNode, setValueNode] = React.useState(null);
|
|
58
|
+
const [valueNodeHasChildren, setValueNodeHasChildren] = React.useState(false);
|
|
59
|
+
const direction = useDirection(dir);
|
|
60
|
+
const [open, setOpen] = useControllableState({
|
|
61
|
+
prop: openProp,
|
|
62
|
+
defaultProp: defaultOpen ?? false,
|
|
63
|
+
onChange: onOpenChange,
|
|
64
|
+
caller: SELECT_NAME
|
|
65
|
+
});
|
|
66
|
+
const [value, setValue] = useControllableState({
|
|
67
|
+
prop: valueProp,
|
|
68
|
+
defaultProp: defaultValue,
|
|
69
|
+
onChange: onValueChange,
|
|
70
|
+
caller: SELECT_NAME
|
|
71
|
+
});
|
|
72
|
+
const triggerPointerDownPosRef = React.useRef(null);
|
|
73
|
+
const isFormControl = trigger ? form || !!trigger.closest("form") : true;
|
|
74
|
+
const [nativeOptionsSet, setNativeOptionsSet] = React.useState(/* @__PURE__ */ new Set());
|
|
75
|
+
const nativeSelectKey = Array.from(nativeOptionsSet).map((option) => option.props.value).join(";");
|
|
76
|
+
return /* @__PURE__ */ jsx(Root2$1, { ...popperScope, children: /* @__PURE__ */ jsxs(
|
|
77
|
+
SelectProvider,
|
|
78
|
+
{
|
|
79
|
+
required,
|
|
80
|
+
scope: __scopeSelect,
|
|
81
|
+
trigger,
|
|
82
|
+
onTriggerChange: setTrigger,
|
|
83
|
+
valueNode,
|
|
84
|
+
onValueNodeChange: setValueNode,
|
|
85
|
+
valueNodeHasChildren,
|
|
86
|
+
onValueNodeHasChildrenChange: setValueNodeHasChildren,
|
|
87
|
+
contentId: useId(),
|
|
88
|
+
value,
|
|
89
|
+
onValueChange: setValue,
|
|
90
|
+
open,
|
|
91
|
+
onOpenChange: setOpen,
|
|
92
|
+
dir: direction,
|
|
93
|
+
triggerPointerDownPosRef,
|
|
94
|
+
disabled,
|
|
95
|
+
children: [
|
|
96
|
+
/* @__PURE__ */ jsx(Collection.Provider, { scope: __scopeSelect, children: /* @__PURE__ */ jsx(
|
|
97
|
+
SelectNativeOptionsProvider,
|
|
98
|
+
{
|
|
99
|
+
scope: props.__scopeSelect,
|
|
100
|
+
onNativeOptionAdd: React.useCallback((option) => {
|
|
101
|
+
setNativeOptionsSet((prev) => new Set(prev).add(option));
|
|
102
|
+
}, []),
|
|
103
|
+
onNativeOptionRemove: React.useCallback((option) => {
|
|
104
|
+
setNativeOptionsSet((prev) => {
|
|
100
105
|
const optionsSet = new Set(prev);
|
|
101
106
|
optionsSet.delete(option);
|
|
102
107
|
return optionsSet;
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
108
|
+
});
|
|
109
|
+
}, []),
|
|
110
|
+
children
|
|
111
|
+
}
|
|
112
|
+
) }),
|
|
113
|
+
isFormControl ? /* @__PURE__ */ jsxs(
|
|
114
|
+
SelectBubbleInput,
|
|
115
|
+
{
|
|
116
|
+
"aria-hidden": true,
|
|
117
|
+
required,
|
|
118
|
+
tabIndex: -1,
|
|
119
|
+
name,
|
|
120
|
+
autoComplete,
|
|
121
|
+
value,
|
|
122
|
+
onChange: (event) => setValue(event.target.value),
|
|
123
|
+
disabled,
|
|
124
|
+
form,
|
|
125
|
+
children: [
|
|
126
|
+
value === void 0 ? /* @__PURE__ */ jsx("option", { value: "" }) : null,
|
|
127
|
+
Array.from(nativeOptionsSet)
|
|
128
|
+
]
|
|
129
|
+
},
|
|
130
|
+
nativeSelectKey
|
|
131
|
+
) : null
|
|
132
|
+
]
|
|
133
|
+
}
|
|
134
|
+
) });
|
|
120
135
|
};
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
const { __scopeSelect
|
|
126
|
-
const popperScope =
|
|
127
|
-
const context =
|
|
136
|
+
Select.displayName = SELECT_NAME;
|
|
137
|
+
var TRIGGER_NAME = "SelectTrigger";
|
|
138
|
+
var SelectTrigger = React.forwardRef(
|
|
139
|
+
(props, forwardedRef) => {
|
|
140
|
+
const { __scopeSelect, disabled = false, ...triggerProps } = props;
|
|
141
|
+
const popperScope = usePopperScope(__scopeSelect);
|
|
142
|
+
const context = useSelectContext(TRIGGER_NAME, __scopeSelect);
|
|
128
143
|
const isDisabled = context.disabled || disabled;
|
|
129
|
-
const composedRefs =
|
|
130
|
-
const getItems =
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
144
|
+
const composedRefs = useComposedRefs(forwardedRef, context.onTriggerChange);
|
|
145
|
+
const getItems = useCollection(__scopeSelect);
|
|
146
|
+
const pointerTypeRef = React.useRef("touch");
|
|
147
|
+
const [searchRef, handleTypeaheadSearch, resetTypeahead] = useTypeaheadSearch((search) => {
|
|
148
|
+
const enabledItems = getItems().filter((item) => !item.disabled);
|
|
149
|
+
const currentItem = enabledItems.find((item) => item.value === context.value);
|
|
150
|
+
const nextItem = findNextItem(enabledItems, search, currentItem);
|
|
151
|
+
if (nextItem !== void 0) {
|
|
152
|
+
context.onValueChange(nextItem.value);
|
|
153
|
+
}
|
|
138
154
|
});
|
|
139
|
-
const handleOpen = ()=>{
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
155
|
+
const handleOpen = (pointerEvent) => {
|
|
156
|
+
if (!isDisabled) {
|
|
157
|
+
context.onOpenChange(true);
|
|
158
|
+
resetTypeahead();
|
|
159
|
+
}
|
|
160
|
+
if (pointerEvent) {
|
|
161
|
+
context.triggerPointerDownPosRef.current = {
|
|
162
|
+
x: Math.round(pointerEvent.pageX),
|
|
163
|
+
y: Math.round(pointerEvent.pageY)
|
|
164
|
+
};
|
|
165
|
+
}
|
|
144
166
|
};
|
|
145
|
-
return
|
|
146
|
-
|
|
147
|
-
|
|
167
|
+
return /* @__PURE__ */ jsx(Anchor, { asChild: true, ...popperScope, children: /* @__PURE__ */ jsx(
|
|
168
|
+
Primitive.button,
|
|
169
|
+
{
|
|
148
170
|
type: "button",
|
|
149
171
|
role: "combobox",
|
|
150
172
|
"aria-controls": context.contentId,
|
|
@@ -152,1006 +174,985 @@ const $cc7e05a45900e73f$export$3ac1e88a1c0b9f1 = /*#__PURE__*/ forwardRef((props
|
|
|
152
174
|
"aria-required": context.required,
|
|
153
175
|
"aria-autocomplete": "none",
|
|
154
176
|
dir: context.dir,
|
|
155
|
-
"data-state": context.open ?
|
|
177
|
+
"data-state": context.open ? "open" : "closed",
|
|
156
178
|
disabled: isDisabled,
|
|
157
|
-
"data-disabled": isDisabled ?
|
|
158
|
-
"data-placeholder":
|
|
159
|
-
|
|
160
|
-
ref: composedRefs
|
|
161
|
-
,
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
// because we are preventing default in `onPointerDown` so effectively
|
|
167
|
-
// this only runs for a label "click"
|
|
168
|
-
event.currentTarget.focus();
|
|
179
|
+
"data-disabled": isDisabled ? "" : void 0,
|
|
180
|
+
"data-placeholder": shouldShowPlaceholder(context.value) ? "" : void 0,
|
|
181
|
+
...triggerProps,
|
|
182
|
+
ref: composedRefs,
|
|
183
|
+
onClick: composeEventHandlers(triggerProps.onClick, (event) => {
|
|
184
|
+
event.currentTarget.focus();
|
|
185
|
+
if (pointerTypeRef.current !== "mouse") {
|
|
186
|
+
handleOpen(event);
|
|
187
|
+
}
|
|
169
188
|
}),
|
|
170
|
-
onPointerDown:
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
x: Math.round(event.pageX),
|
|
181
|
-
y: Math.round(event.pageY)
|
|
182
|
-
}; // prevent trigger from stealing focus from the active item after opening.
|
|
183
|
-
event.preventDefault();
|
|
184
|
-
}
|
|
189
|
+
onPointerDown: composeEventHandlers(triggerProps.onPointerDown, (event) => {
|
|
190
|
+
pointerTypeRef.current = event.pointerType;
|
|
191
|
+
const target = event.target;
|
|
192
|
+
if (target.hasPointerCapture(event.pointerId)) {
|
|
193
|
+
target.releasePointerCapture(event.pointerId);
|
|
194
|
+
}
|
|
195
|
+
if (event.button === 0 && event.ctrlKey === false && event.pointerType === "mouse") {
|
|
196
|
+
handleOpen(event);
|
|
197
|
+
event.preventDefault();
|
|
198
|
+
}
|
|
185
199
|
}),
|
|
186
|
-
onKeyDown:
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
200
|
+
onKeyDown: composeEventHandlers(triggerProps.onKeyDown, (event) => {
|
|
201
|
+
const isTypingAhead = searchRef.current !== "";
|
|
202
|
+
const isModifierKey = event.ctrlKey || event.altKey || event.metaKey;
|
|
203
|
+
if (!isModifierKey && event.key.length === 1) handleTypeaheadSearch(event.key);
|
|
204
|
+
if (isTypingAhead && event.key === " ") return;
|
|
205
|
+
if (OPEN_KEYS.includes(event.key)) {
|
|
206
|
+
handleOpen();
|
|
207
|
+
event.preventDefault();
|
|
208
|
+
}
|
|
195
209
|
})
|
|
196
|
-
|
|
197
|
-
});
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
const
|
|
205
|
-
const
|
|
206
|
-
const
|
|
207
|
-
const
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
,
|
|
217
|
-
style: {
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
210
|
+
}
|
|
211
|
+
) });
|
|
212
|
+
}
|
|
213
|
+
);
|
|
214
|
+
SelectTrigger.displayName = TRIGGER_NAME;
|
|
215
|
+
var VALUE_NAME = "SelectValue";
|
|
216
|
+
var SelectValue = React.forwardRef(
|
|
217
|
+
(props, forwardedRef) => {
|
|
218
|
+
const { __scopeSelect, className, style, children, placeholder = "", ...valueProps } = props;
|
|
219
|
+
const context = useSelectContext(VALUE_NAME, __scopeSelect);
|
|
220
|
+
const { onValueNodeHasChildrenChange } = context;
|
|
221
|
+
const hasChildren = children !== void 0;
|
|
222
|
+
const composedRefs = useComposedRefs(forwardedRef, context.onValueNodeChange);
|
|
223
|
+
useLayoutEffect2(() => {
|
|
224
|
+
onValueNodeHasChildrenChange(hasChildren);
|
|
225
|
+
}, [onValueNodeHasChildrenChange, hasChildren]);
|
|
226
|
+
return /* @__PURE__ */ jsx(
|
|
227
|
+
Primitive.span,
|
|
228
|
+
{
|
|
229
|
+
...valueProps,
|
|
230
|
+
ref: composedRefs,
|
|
231
|
+
style: { pointerEvents: "none" },
|
|
232
|
+
children: shouldShowPlaceholder(context.value) ? /* @__PURE__ */ jsx(Fragment, { children: placeholder }) : children
|
|
233
|
+
}
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
);
|
|
237
|
+
SelectValue.displayName = VALUE_NAME;
|
|
238
|
+
var ICON_NAME = "SelectIcon";
|
|
239
|
+
var SelectIcon = React.forwardRef(
|
|
240
|
+
(props, forwardedRef) => {
|
|
241
|
+
const { __scopeSelect, children, ...iconProps } = props;
|
|
242
|
+
return /* @__PURE__ */ jsx(Primitive.span, { "aria-hidden": true, ...iconProps, ref: forwardedRef, children: children || "\u25BC" });
|
|
243
|
+
}
|
|
244
|
+
);
|
|
245
|
+
SelectIcon.displayName = ICON_NAME;
|
|
246
|
+
var PORTAL_NAME = "SelectPortal";
|
|
247
|
+
var SelectPortal = (props) => {
|
|
248
|
+
return /* @__PURE__ */ jsx(Portal$1, { asChild: true, ...props });
|
|
234
249
|
};
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
const context =
|
|
240
|
-
const [fragment, setFragment] = useState();
|
|
241
|
-
|
|
242
|
-
|
|
250
|
+
SelectPortal.displayName = PORTAL_NAME;
|
|
251
|
+
var CONTENT_NAME = "SelectContent";
|
|
252
|
+
var SelectContent = React.forwardRef(
|
|
253
|
+
(props, forwardedRef) => {
|
|
254
|
+
const context = useSelectContext(CONTENT_NAME, props.__scopeSelect);
|
|
255
|
+
const [fragment, setFragment] = React.useState();
|
|
256
|
+
useLayoutEffect2(() => {
|
|
257
|
+
setFragment(new DocumentFragment());
|
|
243
258
|
}, []);
|
|
244
259
|
if (!context.open) {
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
}, /*#__PURE__*/ createElement("div", null, props.children))), frag) : null;
|
|
260
|
+
const frag = fragment;
|
|
261
|
+
return frag ? ReactDOM.createPortal(
|
|
262
|
+
/* @__PURE__ */ jsx(SelectContentProvider, { scope: props.__scopeSelect, children: /* @__PURE__ */ jsx(Collection.Slot, { scope: props.__scopeSelect, children: /* @__PURE__ */ jsx("div", { children: props.children }) }) }),
|
|
263
|
+
frag
|
|
264
|
+
) : null;
|
|
251
265
|
}
|
|
252
|
-
return
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
266
|
+
return /* @__PURE__ */ jsx(SelectContentImpl, { ...props, ref: forwardedRef });
|
|
267
|
+
}
|
|
268
|
+
);
|
|
269
|
+
SelectContent.displayName = CONTENT_NAME;
|
|
270
|
+
var CONTENT_MARGIN = 10;
|
|
271
|
+
var [SelectContentProvider, useSelectContentContext] = createSelectContext(CONTENT_NAME);
|
|
272
|
+
var CONTENT_IMPL_NAME = "SelectContentImpl";
|
|
273
|
+
var Slot = createSlot("SelectContent.RemoveScroll");
|
|
274
|
+
var SelectContentImpl = React.forwardRef(
|
|
275
|
+
(props, forwardedRef) => {
|
|
276
|
+
const {
|
|
277
|
+
__scopeSelect,
|
|
278
|
+
position = "item-aligned",
|
|
279
|
+
onCloseAutoFocus,
|
|
280
|
+
onEscapeKeyDown,
|
|
281
|
+
onPointerDownOutside,
|
|
282
|
+
//
|
|
283
|
+
// PopperContent props
|
|
284
|
+
side,
|
|
285
|
+
sideOffset,
|
|
286
|
+
align,
|
|
287
|
+
alignOffset,
|
|
288
|
+
arrowPadding,
|
|
289
|
+
collisionBoundary,
|
|
290
|
+
collisionPadding,
|
|
291
|
+
sticky,
|
|
292
|
+
hideWhenDetached,
|
|
293
|
+
avoidCollisions,
|
|
294
|
+
//
|
|
295
|
+
...contentProps
|
|
296
|
+
} = props;
|
|
297
|
+
const context = useSelectContext(CONTENT_NAME, __scopeSelect);
|
|
298
|
+
const [content, setContent] = React.useState(null);
|
|
299
|
+
const [viewport, setViewport] = React.useState(null);
|
|
300
|
+
const composedRefs = useComposedRefs(forwardedRef, (node) => setContent(node));
|
|
301
|
+
const [selectedItem, setSelectedItem] = React.useState(null);
|
|
302
|
+
const [selectedItemText, setSelectedItemText] = React.useState(
|
|
303
|
+
null
|
|
269
304
|
);
|
|
270
|
-
const
|
|
271
|
-
const [
|
|
272
|
-
const
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
// the last element in the DOM (because of the `Portal`)
|
|
281
|
-
$3db38b7d1fb3fe6a$export$b7ece24a22aeda8c();
|
|
282
|
-
const focusFirst = useCallback((candidates)=>{
|
|
283
|
-
const [firstItem, ...restItems] = getItems().map((item)=>item.ref.current
|
|
284
|
-
);
|
|
305
|
+
const getItems = useCollection(__scopeSelect);
|
|
306
|
+
const [isPositioned, setIsPositioned] = React.useState(false);
|
|
307
|
+
const firstValidItemFoundRef = React.useRef(false);
|
|
308
|
+
React.useEffect(() => {
|
|
309
|
+
if (content) return hideOthers(content);
|
|
310
|
+
}, [content]);
|
|
311
|
+
useFocusGuards();
|
|
312
|
+
const focusFirst = React.useCallback(
|
|
313
|
+
(candidates) => {
|
|
314
|
+
const [firstItem, ...restItems] = getItems().map((item) => item.ref.current);
|
|
285
315
|
const [lastItem] = restItems.slice(-1);
|
|
286
316
|
const PREVIOUSLY_FOCUSED_ELEMENT = document.activeElement;
|
|
287
|
-
for (const candidate of candidates){
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
if (candidate === lastItem && viewport) viewport.scrollTop = viewport.scrollHeight;
|
|
295
|
-
candidate === null || candidate === void 0 || candidate.focus();
|
|
296
|
-
if (document.activeElement !== PREVIOUSLY_FOCUSED_ELEMENT) return;
|
|
317
|
+
for (const candidate of candidates) {
|
|
318
|
+
if (candidate === PREVIOUSLY_FOCUSED_ELEMENT) return;
|
|
319
|
+
candidate?.scrollIntoView({ block: "nearest" });
|
|
320
|
+
if (candidate === firstItem && viewport) viewport.scrollTop = 0;
|
|
321
|
+
if (candidate === lastItem && viewport) viewport.scrollTop = viewport.scrollHeight;
|
|
322
|
+
candidate?.focus();
|
|
323
|
+
if (document.activeElement !== PREVIOUSLY_FOCUSED_ELEMENT) return;
|
|
297
324
|
}
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
const handlePointerMove = (event)=>{
|
|
327
|
-
var _triggerPointerDownPo, _triggerPointerDownPo2, _triggerPointerDownPo3, _triggerPointerDownPo4;
|
|
328
|
-
pointerMoveDelta = {
|
|
329
|
-
x: Math.abs(Math.round(event.pageX) - ((_triggerPointerDownPo = (_triggerPointerDownPo2 = triggerPointerDownPosRef.current) === null || _triggerPointerDownPo2 === void 0 ? void 0 : _triggerPointerDownPo2.x) !== null && _triggerPointerDownPo !== void 0 ? _triggerPointerDownPo : 0)),
|
|
330
|
-
y: Math.abs(Math.round(event.pageY) - ((_triggerPointerDownPo3 = (_triggerPointerDownPo4 = triggerPointerDownPosRef.current) === null || _triggerPointerDownPo4 === void 0 ? void 0 : _triggerPointerDownPo4.y) !== null && _triggerPointerDownPo3 !== void 0 ? _triggerPointerDownPo3 : 0))
|
|
331
|
-
};
|
|
332
|
-
};
|
|
333
|
-
const handlePointerUp = (event)=>{
|
|
334
|
-
// If the pointer hasn't moved by a certain threshold then we prevent selecting item on `pointerup`.
|
|
335
|
-
if (pointerMoveDelta.x <= 10 && pointerMoveDelta.y <= 10) event.preventDefault();
|
|
336
|
-
else // otherwise, if the event was outside the content, close.
|
|
337
|
-
if (!content.contains(event.target)) onOpenChange(false);
|
|
338
|
-
document.removeEventListener('pointermove', handlePointerMove);
|
|
339
|
-
triggerPointerDownPosRef.current = null;
|
|
340
|
-
};
|
|
341
|
-
if (triggerPointerDownPosRef.current !== null) {
|
|
342
|
-
document.addEventListener('pointermove', handlePointerMove);
|
|
343
|
-
document.addEventListener('pointerup', handlePointerUp, {
|
|
344
|
-
capture: true,
|
|
345
|
-
once: true
|
|
346
|
-
});
|
|
325
|
+
},
|
|
326
|
+
[getItems, viewport]
|
|
327
|
+
);
|
|
328
|
+
const focusSelectedItem = React.useCallback(
|
|
329
|
+
() => focusFirst([selectedItem, content]),
|
|
330
|
+
[focusFirst, selectedItem, content]
|
|
331
|
+
);
|
|
332
|
+
React.useEffect(() => {
|
|
333
|
+
if (isPositioned) {
|
|
334
|
+
focusSelectedItem();
|
|
335
|
+
}
|
|
336
|
+
}, [isPositioned, focusSelectedItem]);
|
|
337
|
+
const { onOpenChange, triggerPointerDownPosRef } = context;
|
|
338
|
+
React.useEffect(() => {
|
|
339
|
+
if (content) {
|
|
340
|
+
let pointerMoveDelta = { x: 0, y: 0 };
|
|
341
|
+
const handlePointerMove = (event) => {
|
|
342
|
+
pointerMoveDelta = {
|
|
343
|
+
x: Math.abs(Math.round(event.pageX) - (triggerPointerDownPosRef.current?.x ?? 0)),
|
|
344
|
+
y: Math.abs(Math.round(event.pageY) - (triggerPointerDownPosRef.current?.y ?? 0))
|
|
345
|
+
};
|
|
346
|
+
};
|
|
347
|
+
const handlePointerUp = (event) => {
|
|
348
|
+
if (pointerMoveDelta.x <= 10 && pointerMoveDelta.y <= 10) {
|
|
349
|
+
event.preventDefault();
|
|
350
|
+
} else {
|
|
351
|
+
if (!content.contains(event.target)) {
|
|
352
|
+
onOpenChange(false);
|
|
347
353
|
}
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
+
}
|
|
355
|
+
document.removeEventListener("pointermove", handlePointerMove);
|
|
356
|
+
triggerPointerDownPosRef.current = null;
|
|
357
|
+
};
|
|
358
|
+
if (triggerPointerDownPosRef.current !== null) {
|
|
359
|
+
document.addEventListener("pointermove", handlePointerMove);
|
|
360
|
+
document.addEventListener("pointerup", handlePointerUp, { capture: true, once: true });
|
|
354
361
|
}
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
triggerPointerDownPosRef
|
|
359
|
-
]);
|
|
360
|
-
useEffect(()=>{
|
|
361
|
-
const close = ()=>onOpenChange(false)
|
|
362
|
-
;
|
|
363
|
-
window.addEventListener('blur', close);
|
|
364
|
-
window.addEventListener('resize', close);
|
|
365
|
-
return ()=>{
|
|
366
|
-
window.removeEventListener('blur', close);
|
|
367
|
-
window.removeEventListener('resize', close);
|
|
362
|
+
return () => {
|
|
363
|
+
document.removeEventListener("pointermove", handlePointerMove);
|
|
364
|
+
document.removeEventListener("pointerup", handlePointerUp, { capture: true });
|
|
368
365
|
};
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
);
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
366
|
+
}
|
|
367
|
+
}, [content, onOpenChange, triggerPointerDownPosRef]);
|
|
368
|
+
React.useEffect(() => {
|
|
369
|
+
const close = () => onOpenChange(false);
|
|
370
|
+
window.addEventListener("blur", close);
|
|
371
|
+
window.addEventListener("resize", close);
|
|
372
|
+
return () => {
|
|
373
|
+
window.removeEventListener("blur", close);
|
|
374
|
+
window.removeEventListener("resize", close);
|
|
375
|
+
};
|
|
376
|
+
}, [onOpenChange]);
|
|
377
|
+
const [searchRef, handleTypeaheadSearch] = useTypeaheadSearch((search) => {
|
|
378
|
+
const enabledItems = getItems().filter((item) => !item.disabled);
|
|
379
|
+
const currentItem = enabledItems.find((item) => item.ref.current === document.activeElement);
|
|
380
|
+
const nextItem = findNextItem(enabledItems, search, currentItem);
|
|
381
|
+
if (nextItem) {
|
|
382
|
+
setTimeout(() => nextItem.ref.current.focus());
|
|
383
|
+
}
|
|
383
384
|
});
|
|
384
|
-
const itemRefCallback = useCallback(
|
|
385
|
+
const itemRefCallback = React.useCallback(
|
|
386
|
+
(node, value, disabled) => {
|
|
385
387
|
const isFirstValidItem = !firstValidItemFoundRef.current && !disabled;
|
|
386
|
-
const isSelectedItem = context.value !==
|
|
388
|
+
const isSelectedItem = context.value !== void 0 && context.value === value;
|
|
387
389
|
if (isSelectedItem || isFirstValidItem) {
|
|
388
|
-
|
|
389
|
-
|
|
390
|
+
setSelectedItem(node);
|
|
391
|
+
if (isFirstValidItem) firstValidItemFoundRef.current = true;
|
|
390
392
|
}
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
const handleItemLeave = useCallback(()=>
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
]);
|
|
398
|
-
const itemTextRefCallback = useCallback((node, value, disabled)=>{
|
|
393
|
+
},
|
|
394
|
+
[context.value]
|
|
395
|
+
);
|
|
396
|
+
const handleItemLeave = React.useCallback(() => content?.focus(), [content]);
|
|
397
|
+
const itemTextRefCallback = React.useCallback(
|
|
398
|
+
(node, value, disabled) => {
|
|
399
399
|
const isFirstValidItem = !firstValidItemFoundRef.current && !disabled;
|
|
400
|
-
const isSelectedItem = context.value !==
|
|
401
|
-
if (isSelectedItem || isFirstValidItem)
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
400
|
+
const isSelectedItem = context.value !== void 0 && context.value === value;
|
|
401
|
+
if (isSelectedItem || isFirstValidItem) {
|
|
402
|
+
setSelectedItemText(node);
|
|
403
|
+
}
|
|
404
|
+
},
|
|
405
|
+
[context.value]
|
|
406
|
+
);
|
|
407
|
+
const SelectPosition = position === "popper" ? SelectPopperPosition : SelectItemAlignedPosition;
|
|
408
|
+
const popperContentProps = SelectPosition === SelectPopperPosition ? {
|
|
409
|
+
side,
|
|
410
|
+
sideOffset,
|
|
411
|
+
align,
|
|
412
|
+
alignOffset,
|
|
413
|
+
arrowPadding,
|
|
414
|
+
collisionBoundary,
|
|
415
|
+
collisionPadding,
|
|
416
|
+
sticky,
|
|
417
|
+
hideWhenDetached,
|
|
418
|
+
avoidCollisions
|
|
417
419
|
} : {};
|
|
418
|
-
return
|
|
420
|
+
return /* @__PURE__ */ jsx(
|
|
421
|
+
SelectContentProvider,
|
|
422
|
+
{
|
|
419
423
|
scope: __scopeSelect,
|
|
420
|
-
content: content,
|
|
421
|
-
viewport: viewport,
|
|
422
|
-
onViewportChange: setViewport,
|
|
423
|
-
itemRefCallback: itemRefCallback,
|
|
424
|
-
selectedItem: selectedItem,
|
|
425
|
-
onItemLeave: handleItemLeave,
|
|
426
|
-
itemTextRefCallback: itemTextRefCallback,
|
|
427
|
-
focusSelectedItem: focusSelectedItem,
|
|
428
|
-
selectedItemText: selectedItemText,
|
|
429
|
-
position: position,
|
|
430
|
-
isPositioned: isPositioned,
|
|
431
|
-
searchRef: searchRef
|
|
432
|
-
}, /*#__PURE__*/ createElement(ReactRemoveScroll, {
|
|
433
|
-
as: $5e63c961fc1ce211$export$8c6ed5c666ac1360,
|
|
434
|
-
allowPinchZoom: true
|
|
435
|
-
}, /*#__PURE__*/ createElement($d3863c46a17e8a28$export$20e40289641fbbb6, {
|
|
436
|
-
asChild: true // we make sure we're not trapping once it's been closed
|
|
437
|
-
,
|
|
438
|
-
trapped: context.open,
|
|
439
|
-
onMountAutoFocus: (event)=>{
|
|
440
|
-
// we prevent open autofocus because we manually focus the selected item
|
|
441
|
-
event.preventDefault();
|
|
442
|
-
},
|
|
443
|
-
onUnmountAutoFocus: $e42e1063c40fb3ef$export$b9ecd428b558ff10(onCloseAutoFocus, (event)=>{
|
|
444
|
-
var _context$trigger;
|
|
445
|
-
(_context$trigger = context.trigger) === null || _context$trigger === void 0 || _context$trigger.focus({
|
|
446
|
-
preventScroll: true
|
|
447
|
-
});
|
|
448
|
-
event.preventDefault();
|
|
449
|
-
})
|
|
450
|
-
}, /*#__PURE__*/ createElement($5cb92bef7577960e$export$177fb62ff3ec1f22, {
|
|
451
|
-
asChild: true,
|
|
452
|
-
disableOutsidePointerEvents: true,
|
|
453
|
-
onEscapeKeyDown: onEscapeKeyDown,
|
|
454
|
-
onPointerDownOutside: onPointerDownOutside // When focus is trapped, a focusout event may still happen.
|
|
455
|
-
,
|
|
456
|
-
onFocusOutside: (event)=>event.preventDefault()
|
|
457
|
-
,
|
|
458
|
-
onDismiss: ()=>context.onOpenChange(false)
|
|
459
|
-
}, /*#__PURE__*/ createElement(SelectPosition, _extends({
|
|
460
|
-
role: "listbox",
|
|
461
|
-
id: context.contentId,
|
|
462
|
-
"data-state": context.open ? 'open' : 'closed',
|
|
463
|
-
dir: context.dir,
|
|
464
|
-
onContextMenu: (event)=>event.preventDefault()
|
|
465
|
-
}, contentProps, popperContentProps, {
|
|
466
|
-
onPlaced: ()=>setIsPositioned(true)
|
|
467
|
-
,
|
|
468
|
-
ref: composedRefs,
|
|
469
|
-
style: {
|
|
470
|
-
// flex layout so we can place the scroll buttons properly
|
|
471
|
-
display: 'flex',
|
|
472
|
-
flexDirection: 'column',
|
|
473
|
-
// reset the outline by default as the content MAY get focused
|
|
474
|
-
outline: 'none',
|
|
475
|
-
...contentProps.style
|
|
476
|
-
},
|
|
477
|
-
onKeyDown: $e42e1063c40fb3ef$export$b9ecd428b558ff10(contentProps.onKeyDown, (event)=>{
|
|
478
|
-
const isModifierKey = event.ctrlKey || event.altKey || event.metaKey; // select should not be navigated using tab key so we prevent it
|
|
479
|
-
if (event.key === 'Tab') event.preventDefault();
|
|
480
|
-
if (!isModifierKey && event.key.length === 1) handleTypeaheadSearch(event.key);
|
|
481
|
-
if ([
|
|
482
|
-
'ArrowUp',
|
|
483
|
-
'ArrowDown',
|
|
484
|
-
'Home',
|
|
485
|
-
'End'
|
|
486
|
-
].includes(event.key)) {
|
|
487
|
-
const items = getItems().filter((item)=>!item.disabled
|
|
488
|
-
);
|
|
489
|
-
let candidateNodes = items.map((item)=>item.ref.current
|
|
490
|
-
);
|
|
491
|
-
if ([
|
|
492
|
-
'ArrowUp',
|
|
493
|
-
'End'
|
|
494
|
-
].includes(event.key)) candidateNodes = candidateNodes.slice().reverse();
|
|
495
|
-
if ([
|
|
496
|
-
'ArrowUp',
|
|
497
|
-
'ArrowDown'
|
|
498
|
-
].includes(event.key)) {
|
|
499
|
-
const currentElement = event.target;
|
|
500
|
-
const currentIndex = candidateNodes.indexOf(currentElement);
|
|
501
|
-
candidateNodes = candidateNodes.slice(currentIndex + 1);
|
|
502
|
-
}
|
|
503
|
-
/**
|
|
504
|
-
* Imperative focus during keydown is risky so we prevent React's batching updates
|
|
505
|
-
* to avoid potential bugs. See: https://github.com/facebook/react/issues/20332
|
|
506
|
-
*/ setTimeout(()=>focusFirst(candidateNodes)
|
|
507
|
-
);
|
|
508
|
-
event.preventDefault();
|
|
509
|
-
}
|
|
510
|
-
})
|
|
511
|
-
}))))));
|
|
512
|
-
});
|
|
513
|
-
const $cc7e05a45900e73f$var$SelectItemAlignedPosition = /*#__PURE__*/ forwardRef((props, forwardedRef)=>{
|
|
514
|
-
const { __scopeSelect: __scopeSelect , onPlaced: onPlaced , ...popperProps } = props;
|
|
515
|
-
const context = $cc7e05a45900e73f$var$useSelectContext($cc7e05a45900e73f$var$CONTENT_NAME, __scopeSelect);
|
|
516
|
-
const contentContext = $cc7e05a45900e73f$var$useSelectContentContext($cc7e05a45900e73f$var$CONTENT_NAME, __scopeSelect);
|
|
517
|
-
const [contentWrapper, setContentWrapper] = useState(null);
|
|
518
|
-
const [content, setContent] = useState(null);
|
|
519
|
-
const composedRefs = $6ed0406888f73fc4$export$c7b2cbe3552a0d05(forwardedRef, (node)=>setContent(node)
|
|
520
|
-
);
|
|
521
|
-
const getItems = $cc7e05a45900e73f$var$useCollection(__scopeSelect);
|
|
522
|
-
const shouldExpandOnScrollRef = useRef(false);
|
|
523
|
-
const shouldRepositionRef = useRef(true);
|
|
524
|
-
const { viewport: viewport , selectedItem: selectedItem , selectedItemText: selectedItemText , focusSelectedItem: focusSelectedItem } = contentContext;
|
|
525
|
-
const position = useCallback(()=>{
|
|
526
|
-
if (context.trigger && context.valueNode && contentWrapper && content && viewport && selectedItem && selectedItemText) {
|
|
527
|
-
const triggerRect = context.trigger.getBoundingClientRect(); // -----------------------------------------------------------------------------------------
|
|
528
|
-
// Horizontal positioning
|
|
529
|
-
// -----------------------------------------------------------------------------------------
|
|
530
|
-
const contentRect = content.getBoundingClientRect();
|
|
531
|
-
const valueNodeRect = context.valueNode.getBoundingClientRect();
|
|
532
|
-
const itemTextRect = selectedItemText.getBoundingClientRect();
|
|
533
|
-
if (context.dir !== 'rtl') {
|
|
534
|
-
const itemTextOffset = itemTextRect.left - contentRect.left;
|
|
535
|
-
const left = valueNodeRect.left - itemTextOffset;
|
|
536
|
-
const leftDelta = triggerRect.left - left;
|
|
537
|
-
const minContentWidth = triggerRect.width + leftDelta;
|
|
538
|
-
const contentWidth = Math.max(minContentWidth, contentRect.width);
|
|
539
|
-
const rightEdge = window.innerWidth - $cc7e05a45900e73f$var$CONTENT_MARGIN;
|
|
540
|
-
const clampedLeft = $ae6933e535247d3d$export$7d15b64cf5a3a4c4(left, [
|
|
541
|
-
$cc7e05a45900e73f$var$CONTENT_MARGIN,
|
|
542
|
-
rightEdge - contentWidth
|
|
543
|
-
]);
|
|
544
|
-
contentWrapper.style.minWidth = minContentWidth + 'px';
|
|
545
|
-
contentWrapper.style.left = clampedLeft + 'px';
|
|
546
|
-
} else {
|
|
547
|
-
const itemTextOffset = contentRect.right - itemTextRect.right;
|
|
548
|
-
const right = window.innerWidth - valueNodeRect.right - itemTextOffset;
|
|
549
|
-
const rightDelta = window.innerWidth - triggerRect.right - right;
|
|
550
|
-
const minContentWidth = triggerRect.width + rightDelta;
|
|
551
|
-
const contentWidth = Math.max(minContentWidth, contentRect.width);
|
|
552
|
-
const leftEdge = window.innerWidth - $cc7e05a45900e73f$var$CONTENT_MARGIN;
|
|
553
|
-
const clampedRight = $ae6933e535247d3d$export$7d15b64cf5a3a4c4(right, [
|
|
554
|
-
$cc7e05a45900e73f$var$CONTENT_MARGIN,
|
|
555
|
-
leftEdge - contentWidth
|
|
556
|
-
]);
|
|
557
|
-
contentWrapper.style.minWidth = minContentWidth + 'px';
|
|
558
|
-
contentWrapper.style.right = clampedRight + 'px';
|
|
559
|
-
} // -----------------------------------------------------------------------------------------
|
|
560
|
-
// Vertical positioning
|
|
561
|
-
// -----------------------------------------------------------------------------------------
|
|
562
|
-
const items = getItems();
|
|
563
|
-
const availableHeight = window.innerHeight - $cc7e05a45900e73f$var$CONTENT_MARGIN * 2;
|
|
564
|
-
const itemsHeight = viewport.scrollHeight;
|
|
565
|
-
const contentStyles = window.getComputedStyle(content);
|
|
566
|
-
const contentBorderTopWidth = parseInt(contentStyles.borderTopWidth, 10);
|
|
567
|
-
const contentPaddingTop = parseInt(contentStyles.paddingTop, 10);
|
|
568
|
-
const contentBorderBottomWidth = parseInt(contentStyles.borderBottomWidth, 10);
|
|
569
|
-
const contentPaddingBottom = parseInt(contentStyles.paddingBottom, 10);
|
|
570
|
-
const fullContentHeight = contentBorderTopWidth + contentPaddingTop + itemsHeight + contentPaddingBottom + contentBorderBottomWidth; // prettier-ignore
|
|
571
|
-
const minContentHeight = Math.min(selectedItem.offsetHeight * 5, fullContentHeight);
|
|
572
|
-
const viewportStyles = window.getComputedStyle(viewport);
|
|
573
|
-
const viewportPaddingTop = parseInt(viewportStyles.paddingTop, 10);
|
|
574
|
-
const viewportPaddingBottom = parseInt(viewportStyles.paddingBottom, 10);
|
|
575
|
-
const topEdgeToTriggerMiddle = triggerRect.top + triggerRect.height / 2 - $cc7e05a45900e73f$var$CONTENT_MARGIN;
|
|
576
|
-
const triggerMiddleToBottomEdge = availableHeight - topEdgeToTriggerMiddle;
|
|
577
|
-
const selectedItemHalfHeight = selectedItem.offsetHeight / 2;
|
|
578
|
-
const itemOffsetMiddle = selectedItem.offsetTop + selectedItemHalfHeight;
|
|
579
|
-
const contentTopToItemMiddle = contentBorderTopWidth + contentPaddingTop + itemOffsetMiddle;
|
|
580
|
-
const itemMiddleToContentBottom = fullContentHeight - contentTopToItemMiddle;
|
|
581
|
-
const willAlignWithoutTopOverflow = contentTopToItemMiddle <= topEdgeToTriggerMiddle;
|
|
582
|
-
if (willAlignWithoutTopOverflow) {
|
|
583
|
-
const isLastItem = selectedItem === items[items.length - 1].ref.current;
|
|
584
|
-
contentWrapper.style.bottom = "0px";
|
|
585
|
-
const viewportOffsetBottom = content.clientHeight - viewport.offsetTop - viewport.offsetHeight;
|
|
586
|
-
const clampedTriggerMiddleToBottomEdge = Math.max(triggerMiddleToBottomEdge, selectedItemHalfHeight + (isLastItem ? viewportPaddingBottom : 0) + viewportOffsetBottom + contentBorderBottomWidth);
|
|
587
|
-
const height = contentTopToItemMiddle + clampedTriggerMiddleToBottomEdge;
|
|
588
|
-
contentWrapper.style.height = height + 'px';
|
|
589
|
-
} else {
|
|
590
|
-
const isFirstItem = selectedItem === items[0].ref.current;
|
|
591
|
-
contentWrapper.style.top = "0px";
|
|
592
|
-
const clampedTopEdgeToTriggerMiddle = Math.max(topEdgeToTriggerMiddle, contentBorderTopWidth + viewport.offsetTop + (isFirstItem ? viewportPaddingTop : 0) + selectedItemHalfHeight);
|
|
593
|
-
const height = clampedTopEdgeToTriggerMiddle + itemMiddleToContentBottom;
|
|
594
|
-
contentWrapper.style.height = height + 'px';
|
|
595
|
-
viewport.scrollTop = contentTopToItemMiddle - topEdgeToTriggerMiddle + viewport.offsetTop;
|
|
596
|
-
}
|
|
597
|
-
contentWrapper.style.margin = `${$cc7e05a45900e73f$var$CONTENT_MARGIN}px 0`;
|
|
598
|
-
contentWrapper.style.minHeight = minContentHeight + 'px';
|
|
599
|
-
contentWrapper.style.maxHeight = availableHeight + 'px'; // -----------------------------------------------------------------------------------------
|
|
600
|
-
onPlaced === null || onPlaced === void 0 || onPlaced(); // we don't want the initial scroll position adjustment to trigger "expand on scroll"
|
|
601
|
-
// so we explicitly turn it on only after they've registered.
|
|
602
|
-
requestAnimationFrame(()=>shouldExpandOnScrollRef.current = true
|
|
603
|
-
);
|
|
604
|
-
}
|
|
605
|
-
}, [
|
|
606
|
-
getItems,
|
|
607
|
-
context.trigger,
|
|
608
|
-
context.valueNode,
|
|
609
|
-
contentWrapper,
|
|
610
424
|
content,
|
|
611
425
|
viewport,
|
|
426
|
+
onViewportChange: setViewport,
|
|
427
|
+
itemRefCallback,
|
|
612
428
|
selectedItem,
|
|
429
|
+
onItemLeave: handleItemLeave,
|
|
430
|
+
itemTextRefCallback,
|
|
431
|
+
focusSelectedItem,
|
|
613
432
|
selectedItemText,
|
|
614
|
-
context.dir,
|
|
615
|
-
onPlaced
|
|
616
|
-
]);
|
|
617
|
-
$9f79659886946c16$export$e5c5a5f917a5871c(()=>position()
|
|
618
|
-
, [
|
|
619
|
-
position
|
|
620
|
-
]); // copy z-index from content to wrapper
|
|
621
|
-
const [contentZIndex, setContentZIndex] = useState();
|
|
622
|
-
$9f79659886946c16$export$e5c5a5f917a5871c(()=>{
|
|
623
|
-
if (content) setContentZIndex(window.getComputedStyle(content).zIndex);
|
|
624
|
-
}, [
|
|
625
|
-
content
|
|
626
|
-
]); // When the viewport becomes scrollable at the top, the scroll up button will mount.
|
|
627
|
-
// Because it is part of the normal flow, it will push down the viewport, thus throwing our
|
|
628
|
-
// trigger => selectedItem alignment off by the amount the viewport was pushed down.
|
|
629
|
-
// We wait for this to happen and then re-run the positining logic one more time to account for it.
|
|
630
|
-
const handleScrollButtonChange = useCallback((node)=>{
|
|
631
|
-
if (node && shouldRepositionRef.current === true) {
|
|
632
|
-
position();
|
|
633
|
-
focusSelectedItem === null || focusSelectedItem === void 0 || focusSelectedItem();
|
|
634
|
-
shouldRepositionRef.current = false;
|
|
635
|
-
}
|
|
636
|
-
}, [
|
|
637
433
|
position,
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
434
|
+
isPositioned,
|
|
435
|
+
searchRef,
|
|
436
|
+
children: /* @__PURE__ */ jsx(ReactRemoveScroll, { as: Slot, allowPinchZoom: true, children: /* @__PURE__ */ jsx(
|
|
437
|
+
FocusScope,
|
|
438
|
+
{
|
|
439
|
+
asChild: true,
|
|
440
|
+
trapped: context.open,
|
|
441
|
+
onMountAutoFocus: (event) => {
|
|
442
|
+
event.preventDefault();
|
|
443
|
+
},
|
|
444
|
+
onUnmountAutoFocus: composeEventHandlers(onCloseAutoFocus, (event) => {
|
|
445
|
+
context.trigger?.focus({ preventScroll: true });
|
|
446
|
+
event.preventDefault();
|
|
447
|
+
}),
|
|
448
|
+
children: /* @__PURE__ */ jsx(
|
|
449
|
+
DismissableLayer,
|
|
450
|
+
{
|
|
451
|
+
asChild: true,
|
|
452
|
+
disableOutsidePointerEvents: true,
|
|
453
|
+
onEscapeKeyDown,
|
|
454
|
+
onPointerDownOutside,
|
|
455
|
+
onFocusOutside: (event) => event.preventDefault(),
|
|
456
|
+
onDismiss: () => context.onOpenChange(false),
|
|
457
|
+
children: /* @__PURE__ */ jsx(
|
|
458
|
+
SelectPosition,
|
|
459
|
+
{
|
|
460
|
+
role: "listbox",
|
|
461
|
+
id: context.contentId,
|
|
462
|
+
"data-state": context.open ? "open" : "closed",
|
|
463
|
+
dir: context.dir,
|
|
464
|
+
onContextMenu: (event) => event.preventDefault(),
|
|
465
|
+
...contentProps,
|
|
466
|
+
...popperContentProps,
|
|
467
|
+
onPlaced: () => setIsPositioned(true),
|
|
468
|
+
ref: composedRefs,
|
|
469
|
+
style: {
|
|
470
|
+
// flex layout so we can place the scroll buttons properly
|
|
471
|
+
display: "flex",
|
|
472
|
+
flexDirection: "column",
|
|
473
|
+
// reset the outline by default as the content MAY get focused
|
|
474
|
+
outline: "none",
|
|
475
|
+
...contentProps.style
|
|
476
|
+
},
|
|
477
|
+
onKeyDown: composeEventHandlers(contentProps.onKeyDown, (event) => {
|
|
478
|
+
const isModifierKey = event.ctrlKey || event.altKey || event.metaKey;
|
|
479
|
+
if (event.key === "Tab") event.preventDefault();
|
|
480
|
+
if (!isModifierKey && event.key.length === 1) handleTypeaheadSearch(event.key);
|
|
481
|
+
if (["ArrowUp", "ArrowDown", "Home", "End"].includes(event.key)) {
|
|
482
|
+
const items = getItems().filter((item) => !item.disabled);
|
|
483
|
+
let candidateNodes = items.map((item) => item.ref.current);
|
|
484
|
+
if (["ArrowUp", "End"].includes(event.key)) {
|
|
485
|
+
candidateNodes = candidateNodes.slice().reverse();
|
|
486
|
+
}
|
|
487
|
+
if (["ArrowUp", "ArrowDown"].includes(event.key)) {
|
|
488
|
+
const currentElement = event.target;
|
|
489
|
+
const currentIndex = candidateNodes.indexOf(currentElement);
|
|
490
|
+
candidateNodes = candidateNodes.slice(currentIndex + 1);
|
|
491
|
+
}
|
|
492
|
+
setTimeout(() => focusFirst(candidateNodes));
|
|
493
|
+
event.preventDefault();
|
|
494
|
+
}
|
|
495
|
+
})
|
|
496
|
+
}
|
|
497
|
+
)
|
|
498
|
+
}
|
|
499
|
+
)
|
|
500
|
+
}
|
|
501
|
+
) })
|
|
502
|
+
}
|
|
503
|
+
);
|
|
504
|
+
}
|
|
505
|
+
);
|
|
506
|
+
SelectContentImpl.displayName = CONTENT_IMPL_NAME;
|
|
507
|
+
var ITEM_ALIGNED_POSITION_NAME = "SelectItemAlignedPosition";
|
|
508
|
+
var SelectItemAlignedPosition = React.forwardRef((props, forwardedRef) => {
|
|
509
|
+
const { __scopeSelect, onPlaced, ...popperProps } = props;
|
|
510
|
+
const context = useSelectContext(CONTENT_NAME, __scopeSelect);
|
|
511
|
+
const contentContext = useSelectContentContext(CONTENT_NAME, __scopeSelect);
|
|
512
|
+
const [contentWrapper, setContentWrapper] = React.useState(null);
|
|
513
|
+
const [content, setContent] = React.useState(null);
|
|
514
|
+
const composedRefs = useComposedRefs(forwardedRef, (node) => setContent(node));
|
|
515
|
+
const getItems = useCollection(__scopeSelect);
|
|
516
|
+
const shouldExpandOnScrollRef = React.useRef(false);
|
|
517
|
+
const shouldRepositionRef = React.useRef(true);
|
|
518
|
+
const { viewport, selectedItem, selectedItemText, focusSelectedItem } = contentContext;
|
|
519
|
+
const position = React.useCallback(() => {
|
|
520
|
+
if (context.trigger && context.valueNode && contentWrapper && content && viewport && selectedItem && selectedItemText) {
|
|
521
|
+
const triggerRect = context.trigger.getBoundingClientRect();
|
|
522
|
+
const contentRect = content.getBoundingClientRect();
|
|
523
|
+
const valueNodeRect = context.valueNode.getBoundingClientRect();
|
|
524
|
+
const itemTextRect = selectedItemText.getBoundingClientRect();
|
|
525
|
+
if (context.dir !== "rtl") {
|
|
526
|
+
const itemTextOffset = itemTextRect.left - contentRect.left;
|
|
527
|
+
const left = valueNodeRect.left - itemTextOffset;
|
|
528
|
+
const leftDelta = triggerRect.left - left;
|
|
529
|
+
const minContentWidth = triggerRect.width + leftDelta;
|
|
530
|
+
const contentWidth = Math.max(minContentWidth, contentRect.width);
|
|
531
|
+
const rightEdge = window.innerWidth - CONTENT_MARGIN;
|
|
532
|
+
const clampedLeft = clamp(left, [
|
|
533
|
+
CONTENT_MARGIN,
|
|
534
|
+
// Prevents the content from going off the starting edge of the
|
|
535
|
+
// viewport. It may still go off the ending edge, but this can be
|
|
536
|
+
// controlled by the user since they may want to manage overflow in a
|
|
537
|
+
// specific way.
|
|
538
|
+
// https://github.com/radix-ui/primitives/issues/2049
|
|
539
|
+
Math.max(CONTENT_MARGIN, rightEdge - contentWidth)
|
|
540
|
+
]);
|
|
541
|
+
contentWrapper.style.minWidth = minContentWidth + "px";
|
|
542
|
+
contentWrapper.style.left = clampedLeft + "px";
|
|
543
|
+
} else {
|
|
544
|
+
const itemTextOffset = contentRect.right - itemTextRect.right;
|
|
545
|
+
const right = window.innerWidth - valueNodeRect.right - itemTextOffset;
|
|
546
|
+
const rightDelta = window.innerWidth - triggerRect.right - right;
|
|
547
|
+
const minContentWidth = triggerRect.width + rightDelta;
|
|
548
|
+
const contentWidth = Math.max(minContentWidth, contentRect.width);
|
|
549
|
+
const leftEdge = window.innerWidth - CONTENT_MARGIN;
|
|
550
|
+
const clampedRight = clamp(right, [
|
|
551
|
+
CONTENT_MARGIN,
|
|
552
|
+
Math.max(CONTENT_MARGIN, leftEdge - contentWidth)
|
|
553
|
+
]);
|
|
554
|
+
contentWrapper.style.minWidth = minContentWidth + "px";
|
|
555
|
+
contentWrapper.style.right = clampedRight + "px";
|
|
556
|
+
}
|
|
557
|
+
const items = getItems();
|
|
558
|
+
const availableHeight = window.innerHeight - CONTENT_MARGIN * 2;
|
|
559
|
+
const itemsHeight = viewport.scrollHeight;
|
|
560
|
+
const contentStyles = window.getComputedStyle(content);
|
|
561
|
+
const contentBorderTopWidth = parseInt(contentStyles.borderTopWidth, 10);
|
|
562
|
+
const contentPaddingTop = parseInt(contentStyles.paddingTop, 10);
|
|
563
|
+
const contentBorderBottomWidth = parseInt(contentStyles.borderBottomWidth, 10);
|
|
564
|
+
const contentPaddingBottom = parseInt(contentStyles.paddingBottom, 10);
|
|
565
|
+
const fullContentHeight = contentBorderTopWidth + contentPaddingTop + itemsHeight + contentPaddingBottom + contentBorderBottomWidth;
|
|
566
|
+
const minContentHeight = Math.min(selectedItem.offsetHeight * 5, fullContentHeight);
|
|
567
|
+
const viewportStyles = window.getComputedStyle(viewport);
|
|
568
|
+
const viewportPaddingTop = parseInt(viewportStyles.paddingTop, 10);
|
|
569
|
+
const viewportPaddingBottom = parseInt(viewportStyles.paddingBottom, 10);
|
|
570
|
+
const topEdgeToTriggerMiddle = triggerRect.top + triggerRect.height / 2 - CONTENT_MARGIN;
|
|
571
|
+
const triggerMiddleToBottomEdge = availableHeight - topEdgeToTriggerMiddle;
|
|
572
|
+
const selectedItemHalfHeight = selectedItem.offsetHeight / 2;
|
|
573
|
+
const itemOffsetMiddle = selectedItem.offsetTop + selectedItemHalfHeight;
|
|
574
|
+
const contentTopToItemMiddle = contentBorderTopWidth + contentPaddingTop + itemOffsetMiddle;
|
|
575
|
+
const itemMiddleToContentBottom = fullContentHeight - contentTopToItemMiddle;
|
|
576
|
+
const willAlignWithoutTopOverflow = contentTopToItemMiddle <= topEdgeToTriggerMiddle;
|
|
577
|
+
if (willAlignWithoutTopOverflow) {
|
|
578
|
+
const isLastItem = items.length > 0 && selectedItem === items[items.length - 1].ref.current;
|
|
579
|
+
contentWrapper.style.bottom = "0px";
|
|
580
|
+
const viewportOffsetBottom = content.clientHeight - viewport.offsetTop - viewport.offsetHeight;
|
|
581
|
+
const clampedTriggerMiddleToBottomEdge = Math.max(
|
|
582
|
+
triggerMiddleToBottomEdge,
|
|
583
|
+
selectedItemHalfHeight + // viewport might have padding bottom, include it to avoid a scrollable viewport
|
|
584
|
+
(isLastItem ? viewportPaddingBottom : 0) + viewportOffsetBottom + contentBorderBottomWidth
|
|
585
|
+
);
|
|
586
|
+
const height = contentTopToItemMiddle + clampedTriggerMiddleToBottomEdge;
|
|
587
|
+
contentWrapper.style.height = height + "px";
|
|
588
|
+
} else {
|
|
589
|
+
const isFirstItem = items.length > 0 && selectedItem === items[0].ref.current;
|
|
590
|
+
contentWrapper.style.top = "0px";
|
|
591
|
+
const clampedTopEdgeToTriggerMiddle = Math.max(
|
|
592
|
+
topEdgeToTriggerMiddle,
|
|
593
|
+
contentBorderTopWidth + viewport.offsetTop + // viewport might have padding top, include it to avoid a scrollable viewport
|
|
594
|
+
(isFirstItem ? viewportPaddingTop : 0) + selectedItemHalfHeight
|
|
595
|
+
);
|
|
596
|
+
const height = clampedTopEdgeToTriggerMiddle + itemMiddleToContentBottom;
|
|
597
|
+
contentWrapper.style.height = height + "px";
|
|
598
|
+
viewport.scrollTop = contentTopToItemMiddle - topEdgeToTriggerMiddle + viewport.offsetTop;
|
|
599
|
+
}
|
|
600
|
+
contentWrapper.style.margin = `${CONTENT_MARGIN}px 0`;
|
|
601
|
+
contentWrapper.style.minHeight = minContentHeight + "px";
|
|
602
|
+
contentWrapper.style.maxHeight = availableHeight + "px";
|
|
603
|
+
onPlaced?.();
|
|
604
|
+
requestAnimationFrame(() => shouldExpandOnScrollRef.current = true);
|
|
605
|
+
}
|
|
606
|
+
}, [
|
|
607
|
+
getItems,
|
|
608
|
+
context.trigger,
|
|
609
|
+
context.valueNode,
|
|
610
|
+
contentWrapper,
|
|
611
|
+
content,
|
|
612
|
+
viewport,
|
|
613
|
+
selectedItem,
|
|
614
|
+
selectedItemText,
|
|
615
|
+
context.dir,
|
|
616
|
+
onPlaced
|
|
617
|
+
]);
|
|
618
|
+
useLayoutEffect2(() => position(), [position]);
|
|
619
|
+
const [contentZIndex, setContentZIndex] = React.useState();
|
|
620
|
+
useLayoutEffect2(() => {
|
|
621
|
+
if (content) setContentZIndex(window.getComputedStyle(content).zIndex);
|
|
622
|
+
}, [content]);
|
|
623
|
+
const handleScrollButtonChange = React.useCallback(
|
|
624
|
+
(node) => {
|
|
625
|
+
if (node && shouldRepositionRef.current === true) {
|
|
626
|
+
position();
|
|
627
|
+
focusSelectedItem?.();
|
|
628
|
+
shouldRepositionRef.current = false;
|
|
629
|
+
}
|
|
630
|
+
},
|
|
631
|
+
[position, focusSelectedItem]
|
|
632
|
+
);
|
|
633
|
+
return /* @__PURE__ */ jsx(
|
|
634
|
+
SelectViewportProvider,
|
|
635
|
+
{
|
|
636
|
+
scope: __scopeSelect,
|
|
637
|
+
contentWrapper,
|
|
638
|
+
shouldExpandOnScrollRef,
|
|
639
|
+
onScrollButtonChange: handleScrollButtonChange,
|
|
640
|
+
children: /* @__PURE__ */ jsx(
|
|
641
|
+
"div",
|
|
642
|
+
{
|
|
643
|
+
ref: setContentWrapper,
|
|
644
|
+
style: {
|
|
645
|
+
display: "flex",
|
|
646
|
+
flexDirection: "column",
|
|
647
|
+
position: "fixed",
|
|
651
648
|
zIndex: contentZIndex
|
|
649
|
+
},
|
|
650
|
+
children: /* @__PURE__ */ jsx(
|
|
651
|
+
Primitive.div,
|
|
652
|
+
{
|
|
653
|
+
...popperProps,
|
|
654
|
+
ref: composedRefs,
|
|
655
|
+
style: {
|
|
656
|
+
// When we get the height of the content, it includes borders. If we were to set
|
|
657
|
+
// the height without having `boxSizing: 'border-box'` it would be too big.
|
|
658
|
+
boxSizing: "border-box",
|
|
659
|
+
// We need to ensure the content doesn't get taller than the wrapper
|
|
660
|
+
maxHeight: "100%",
|
|
661
|
+
...popperProps.style
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
)
|
|
652
665
|
}
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
// When we get the height of the content, it includes borders. If we were to set
|
|
657
|
-
// the height without having `boxSizing: 'border-box'` it would be too big.
|
|
658
|
-
boxSizing: 'border-box',
|
|
659
|
-
// We need to ensure the content doesn't get taller than the wrapper
|
|
660
|
-
maxHeight: '100%',
|
|
661
|
-
...popperProps.style
|
|
662
|
-
}
|
|
663
|
-
}))));
|
|
666
|
+
)
|
|
667
|
+
}
|
|
668
|
+
);
|
|
664
669
|
});
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
670
|
+
SelectItemAlignedPosition.displayName = ITEM_ALIGNED_POSITION_NAME;
|
|
671
|
+
var POPPER_POSITION_NAME = "SelectPopperPosition";
|
|
672
|
+
var SelectPopperPosition = React.forwardRef((props, forwardedRef) => {
|
|
673
|
+
const {
|
|
674
|
+
__scopeSelect,
|
|
675
|
+
align = "start",
|
|
676
|
+
collisionPadding = CONTENT_MARGIN,
|
|
677
|
+
...popperProps
|
|
678
|
+
} = props;
|
|
679
|
+
const popperScope = usePopperScope(__scopeSelect);
|
|
680
|
+
return /* @__PURE__ */ jsx(
|
|
681
|
+
Content,
|
|
682
|
+
{
|
|
683
|
+
...popperScope,
|
|
684
|
+
...popperProps,
|
|
685
|
+
ref: forwardedRef,
|
|
686
|
+
align,
|
|
687
|
+
collisionPadding,
|
|
688
|
+
style: {
|
|
689
|
+
// Ensure border-box for floating-ui calculations
|
|
690
|
+
boxSizing: "border-box",
|
|
691
|
+
...popperProps.style,
|
|
692
|
+
// re-namespace exposed content custom properties
|
|
693
|
+
...{
|
|
694
|
+
"--radix-select-content-transform-origin": "var(--radix-popper-transform-origin)",
|
|
695
|
+
"--radix-select-content-available-width": "var(--radix-popper-available-width)",
|
|
696
|
+
"--radix-select-content-available-height": "var(--radix-popper-available-height)",
|
|
697
|
+
"--radix-select-trigger-width": "var(--radix-popper-anchor-width)",
|
|
698
|
+
"--radix-select-trigger-height": "var(--radix-popper-anchor-height)"
|
|
681
699
|
}
|
|
682
|
-
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
);
|
|
683
703
|
});
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
const { __scopeSelect
|
|
690
|
-
const contentContext =
|
|
691
|
-
const viewportContext =
|
|
692
|
-
const composedRefs =
|
|
693
|
-
const prevScrollTopRef = useRef(0);
|
|
694
|
-
return
|
|
695
|
-
|
|
704
|
+
SelectPopperPosition.displayName = POPPER_POSITION_NAME;
|
|
705
|
+
var [SelectViewportProvider, useSelectViewportContext] = createSelectContext(CONTENT_NAME, {});
|
|
706
|
+
var VIEWPORT_NAME = "SelectViewport";
|
|
707
|
+
var SelectViewport = React.forwardRef(
|
|
708
|
+
(props, forwardedRef) => {
|
|
709
|
+
const { __scopeSelect, nonce, ...viewportProps } = props;
|
|
710
|
+
const contentContext = useSelectContentContext(VIEWPORT_NAME, __scopeSelect);
|
|
711
|
+
const viewportContext = useSelectViewportContext(VIEWPORT_NAME, __scopeSelect);
|
|
712
|
+
const composedRefs = useComposedRefs(forwardedRef, contentContext.onViewportChange);
|
|
713
|
+
const prevScrollTopRef = React.useRef(0);
|
|
714
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
715
|
+
/* @__PURE__ */ jsx(
|
|
716
|
+
"style",
|
|
717
|
+
{
|
|
718
|
+
dangerouslySetInnerHTML: {
|
|
696
719
|
__html: `[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}`
|
|
720
|
+
},
|
|
721
|
+
nonce
|
|
697
722
|
}
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
723
|
+
),
|
|
724
|
+
/* @__PURE__ */ jsx(Collection.Slot, { scope: __scopeSelect, children: /* @__PURE__ */ jsx(
|
|
725
|
+
Primitive.div,
|
|
726
|
+
{
|
|
727
|
+
"data-radix-select-viewport": "",
|
|
728
|
+
role: "presentation",
|
|
729
|
+
...viewportProps,
|
|
730
|
+
ref: composedRefs,
|
|
731
|
+
style: {
|
|
706
732
|
// we use position: 'relative' here on the `viewport` so that when we call
|
|
707
733
|
// `selectedItem.offsetTop` in calculations, the offset is relative to the viewport
|
|
708
734
|
// (independent of the scrollUpButton).
|
|
709
|
-
position:
|
|
735
|
+
position: "relative",
|
|
710
736
|
flex: 1,
|
|
711
|
-
|
|
737
|
+
// Viewport should only be scrollable in the vertical direction.
|
|
738
|
+
// This won't work in vertical writing modes, so we'll need to
|
|
739
|
+
// revisit this if/when that is supported
|
|
740
|
+
// https://developer.chrome.com/blog/vertical-form-controls
|
|
741
|
+
overflow: "hidden auto",
|
|
712
742
|
...viewportProps.style
|
|
713
|
-
|
|
714
|
-
|
|
743
|
+
},
|
|
744
|
+
onScroll: composeEventHandlers(viewportProps.onScroll, (event) => {
|
|
715
745
|
const viewport = event.currentTarget;
|
|
716
|
-
const { contentWrapper
|
|
717
|
-
if (shouldExpandOnScrollRef
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
}
|
|
746
|
+
const { contentWrapper, shouldExpandOnScrollRef } = viewportContext;
|
|
747
|
+
if (shouldExpandOnScrollRef?.current && contentWrapper) {
|
|
748
|
+
const scrolledBy = Math.abs(prevScrollTopRef.current - viewport.scrollTop);
|
|
749
|
+
if (scrolledBy > 0) {
|
|
750
|
+
const availableHeight = window.innerHeight - CONTENT_MARGIN * 2;
|
|
751
|
+
const cssMinHeight = parseFloat(contentWrapper.style.minHeight);
|
|
752
|
+
const cssHeight = parseFloat(contentWrapper.style.height);
|
|
753
|
+
const prevHeight = Math.max(cssMinHeight, cssHeight);
|
|
754
|
+
if (prevHeight < availableHeight) {
|
|
755
|
+
const nextHeight = prevHeight + scrolledBy;
|
|
756
|
+
const clampedNextHeight = Math.min(availableHeight, nextHeight);
|
|
757
|
+
const heightDiff = nextHeight - clampedNextHeight;
|
|
758
|
+
contentWrapper.style.height = clampedNextHeight + "px";
|
|
759
|
+
if (contentWrapper.style.bottom === "0px") {
|
|
760
|
+
viewport.scrollTop = heightDiff > 0 ? heightDiff : 0;
|
|
761
|
+
contentWrapper.style.justifyContent = "flex-end";
|
|
762
|
+
}
|
|
734
763
|
}
|
|
764
|
+
}
|
|
735
765
|
}
|
|
736
766
|
prevScrollTopRef.current = viewport.scrollTop;
|
|
737
|
-
|
|
738
|
-
}))));
|
|
739
|
-
});
|
|
740
|
-
/* -------------------------------------------------------------------------------------------------
|
|
741
|
-
* SelectGroup
|
|
742
|
-
* -----------------------------------------------------------------------------------------------*/ const $cc7e05a45900e73f$var$GROUP_NAME = 'SelectGroup';
|
|
743
|
-
const [$cc7e05a45900e73f$var$SelectGroupContextProvider, $cc7e05a45900e73f$var$useSelectGroupContext] = $cc7e05a45900e73f$var$createSelectContext($cc7e05a45900e73f$var$GROUP_NAME);
|
|
744
|
-
const $cc7e05a45900e73f$export$ee25a334c55de1f4 = /*#__PURE__*/ forwardRef((props, forwardedRef)=>{
|
|
745
|
-
const { __scopeSelect: __scopeSelect , ...groupProps } = props;
|
|
746
|
-
const groupId = $1746a345f3d73bb7$export$f680877a34711e37();
|
|
747
|
-
return /*#__PURE__*/ createElement($cc7e05a45900e73f$var$SelectGroupContextProvider, {
|
|
748
|
-
scope: __scopeSelect,
|
|
749
|
-
id: groupId
|
|
750
|
-
}, /*#__PURE__*/ createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.div, _extends({
|
|
751
|
-
role: "group",
|
|
752
|
-
"aria-labelledby": groupId
|
|
753
|
-
}, groupProps, {
|
|
754
|
-
ref: forwardedRef
|
|
755
|
-
})));
|
|
756
|
-
});
|
|
757
|
-
/* -------------------------------------------------------------------------------------------------
|
|
758
|
-
* SelectLabel
|
|
759
|
-
* -----------------------------------------------------------------------------------------------*/ const $cc7e05a45900e73f$var$LABEL_NAME = 'SelectLabel';
|
|
760
|
-
const $cc7e05a45900e73f$export$f67338d29bd972f8 = /*#__PURE__*/ forwardRef((props, forwardedRef)=>{
|
|
761
|
-
const { __scopeSelect: __scopeSelect , ...labelProps } = props;
|
|
762
|
-
const groupContext = $cc7e05a45900e73f$var$useSelectGroupContext($cc7e05a45900e73f$var$LABEL_NAME, __scopeSelect);
|
|
763
|
-
return /*#__PURE__*/ createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.div, _extends({
|
|
764
|
-
id: groupContext.id
|
|
765
|
-
}, labelProps, {
|
|
766
|
-
ref: forwardedRef
|
|
767
|
-
}));
|
|
768
|
-
});
|
|
769
|
-
/* -------------------------------------------------------------------------------------------------
|
|
770
|
-
* SelectItem
|
|
771
|
-
* -----------------------------------------------------------------------------------------------*/ const $cc7e05a45900e73f$var$ITEM_NAME = 'SelectItem';
|
|
772
|
-
const [$cc7e05a45900e73f$var$SelectItemContextProvider, $cc7e05a45900e73f$var$useSelectItemContext] = $cc7e05a45900e73f$var$createSelectContext($cc7e05a45900e73f$var$ITEM_NAME);
|
|
773
|
-
const $cc7e05a45900e73f$export$13ef48a934230896 = /*#__PURE__*/ forwardRef((props, forwardedRef)=>{
|
|
774
|
-
const { __scopeSelect: __scopeSelect , value: value , disabled: disabled = false , textValue: textValueProp , ...itemProps } = props;
|
|
775
|
-
const context = $cc7e05a45900e73f$var$useSelectContext($cc7e05a45900e73f$var$ITEM_NAME, __scopeSelect);
|
|
776
|
-
const contentContext = $cc7e05a45900e73f$var$useSelectContentContext($cc7e05a45900e73f$var$ITEM_NAME, __scopeSelect);
|
|
777
|
-
const isSelected = context.value === value;
|
|
778
|
-
const [textValue, setTextValue] = useState(textValueProp !== null && textValueProp !== void 0 ? textValueProp : '');
|
|
779
|
-
const [isFocused, setIsFocused] = useState(false);
|
|
780
|
-
const composedRefs = $6ed0406888f73fc4$export$c7b2cbe3552a0d05(forwardedRef, (node)=>{
|
|
781
|
-
var _contentContext$itemR;
|
|
782
|
-
return (_contentContext$itemR = contentContext.itemRefCallback) === null || _contentContext$itemR === void 0 ? void 0 : _contentContext$itemR.call(contentContext, node, value, disabled);
|
|
783
|
-
});
|
|
784
|
-
const textId = $1746a345f3d73bb7$export$f680877a34711e37();
|
|
785
|
-
const handleSelect = ()=>{
|
|
786
|
-
if (!disabled) {
|
|
787
|
-
context.onValueChange(value);
|
|
788
|
-
context.onOpenChange(false);
|
|
767
|
+
})
|
|
789
768
|
}
|
|
769
|
+
) })
|
|
770
|
+
] });
|
|
771
|
+
}
|
|
772
|
+
);
|
|
773
|
+
SelectViewport.displayName = VIEWPORT_NAME;
|
|
774
|
+
var GROUP_NAME = "SelectGroup";
|
|
775
|
+
var [SelectGroupContextProvider, useSelectGroupContext] = createSelectContext(GROUP_NAME);
|
|
776
|
+
var SelectGroup = React.forwardRef(
|
|
777
|
+
(props, forwardedRef) => {
|
|
778
|
+
const { __scopeSelect, ...groupProps } = props;
|
|
779
|
+
const groupId = useId();
|
|
780
|
+
return /* @__PURE__ */ jsx(SelectGroupContextProvider, { scope: __scopeSelect, id: groupId, children: /* @__PURE__ */ jsx(Primitive.div, { role: "group", "aria-labelledby": groupId, ...groupProps, ref: forwardedRef }) });
|
|
781
|
+
}
|
|
782
|
+
);
|
|
783
|
+
SelectGroup.displayName = GROUP_NAME;
|
|
784
|
+
var LABEL_NAME = "SelectLabel";
|
|
785
|
+
var SelectLabel = React.forwardRef(
|
|
786
|
+
(props, forwardedRef) => {
|
|
787
|
+
const { __scopeSelect, ...labelProps } = props;
|
|
788
|
+
const groupContext = useSelectGroupContext(LABEL_NAME, __scopeSelect);
|
|
789
|
+
return /* @__PURE__ */ jsx(Primitive.div, { id: groupContext.id, ...labelProps, ref: forwardedRef });
|
|
790
|
+
}
|
|
791
|
+
);
|
|
792
|
+
SelectLabel.displayName = LABEL_NAME;
|
|
793
|
+
var ITEM_NAME = "SelectItem";
|
|
794
|
+
var [SelectItemContextProvider, useSelectItemContext] = createSelectContext(ITEM_NAME);
|
|
795
|
+
var SelectItem = React.forwardRef(
|
|
796
|
+
(props, forwardedRef) => {
|
|
797
|
+
const {
|
|
798
|
+
__scopeSelect,
|
|
799
|
+
value,
|
|
800
|
+
disabled = false,
|
|
801
|
+
textValue: textValueProp,
|
|
802
|
+
...itemProps
|
|
803
|
+
} = props;
|
|
804
|
+
const context = useSelectContext(ITEM_NAME, __scopeSelect);
|
|
805
|
+
const contentContext = useSelectContentContext(ITEM_NAME, __scopeSelect);
|
|
806
|
+
const isSelected = context.value === value;
|
|
807
|
+
const [textValue, setTextValue] = React.useState(textValueProp ?? "");
|
|
808
|
+
const [isFocused, setIsFocused] = React.useState(false);
|
|
809
|
+
const composedRefs = useComposedRefs(
|
|
810
|
+
forwardedRef,
|
|
811
|
+
(node) => contentContext.itemRefCallback?.(node, value, disabled)
|
|
812
|
+
);
|
|
813
|
+
const textId = useId();
|
|
814
|
+
const pointerTypeRef = React.useRef("touch");
|
|
815
|
+
const handleSelect = () => {
|
|
816
|
+
if (!disabled) {
|
|
817
|
+
context.onValueChange(value);
|
|
818
|
+
context.onOpenChange(false);
|
|
819
|
+
}
|
|
790
820
|
};
|
|
791
|
-
if (value ===
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
setTextValue((prevTextValue)=>{
|
|
800
|
-
var _node$textContent;
|
|
801
|
-
return prevTextValue || ((_node$textContent = node === null || node === void 0 ? void 0 : node.textContent) !== null && _node$textContent !== void 0 ? _node$textContent : '').trim();
|
|
802
|
-
});
|
|
803
|
-
}, [])
|
|
804
|
-
}, /*#__PURE__*/ createElement($cc7e05a45900e73f$var$Collection.ItemSlot, {
|
|
821
|
+
if (value === "") {
|
|
822
|
+
throw new Error(
|
|
823
|
+
"A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder."
|
|
824
|
+
);
|
|
825
|
+
}
|
|
826
|
+
return /* @__PURE__ */ jsx(
|
|
827
|
+
SelectItemContextProvider,
|
|
828
|
+
{
|
|
805
829
|
scope: __scopeSelect,
|
|
806
|
-
value
|
|
807
|
-
disabled
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
}
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
const
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
830
|
+
value,
|
|
831
|
+
disabled,
|
|
832
|
+
textId,
|
|
833
|
+
isSelected,
|
|
834
|
+
onItemTextChange: React.useCallback((node) => {
|
|
835
|
+
setTextValue((prevTextValue) => prevTextValue || (node?.textContent ?? "").trim());
|
|
836
|
+
}, []),
|
|
837
|
+
children: /* @__PURE__ */ jsx(
|
|
838
|
+
Collection.ItemSlot,
|
|
839
|
+
{
|
|
840
|
+
scope: __scopeSelect,
|
|
841
|
+
value,
|
|
842
|
+
disabled,
|
|
843
|
+
textValue,
|
|
844
|
+
children: /* @__PURE__ */ jsx(
|
|
845
|
+
Primitive.div,
|
|
846
|
+
{
|
|
847
|
+
role: "option",
|
|
848
|
+
"aria-labelledby": textId,
|
|
849
|
+
"data-highlighted": isFocused ? "" : void 0,
|
|
850
|
+
"aria-selected": isSelected && isFocused,
|
|
851
|
+
"data-state": isSelected ? "checked" : "unchecked",
|
|
852
|
+
"aria-disabled": disabled || void 0,
|
|
853
|
+
"data-disabled": disabled ? "" : void 0,
|
|
854
|
+
tabIndex: disabled ? void 0 : -1,
|
|
855
|
+
...itemProps,
|
|
856
|
+
ref: composedRefs,
|
|
857
|
+
onFocus: composeEventHandlers(itemProps.onFocus, () => setIsFocused(true)),
|
|
858
|
+
onBlur: composeEventHandlers(itemProps.onBlur, () => setIsFocused(false)),
|
|
859
|
+
onClick: composeEventHandlers(itemProps.onClick, () => {
|
|
860
|
+
if (pointerTypeRef.current !== "mouse") handleSelect();
|
|
861
|
+
}),
|
|
862
|
+
onPointerUp: composeEventHandlers(itemProps.onPointerUp, () => {
|
|
863
|
+
if (pointerTypeRef.current === "mouse") handleSelect();
|
|
864
|
+
}),
|
|
865
|
+
onPointerDown: composeEventHandlers(itemProps.onPointerDown, (event) => {
|
|
866
|
+
pointerTypeRef.current = event.pointerType;
|
|
867
|
+
}),
|
|
868
|
+
onPointerMove: composeEventHandlers(itemProps.onPointerMove, (event) => {
|
|
869
|
+
pointerTypeRef.current = event.pointerType;
|
|
870
|
+
if (disabled) {
|
|
871
|
+
contentContext.onItemLeave?.();
|
|
872
|
+
} else if (pointerTypeRef.current === "mouse") {
|
|
873
|
+
event.currentTarget.focus({ preventScroll: true });
|
|
874
|
+
}
|
|
875
|
+
}),
|
|
876
|
+
onPointerLeave: composeEventHandlers(itemProps.onPointerLeave, (event) => {
|
|
877
|
+
if (event.currentTarget === document.activeElement) {
|
|
878
|
+
contentContext.onItemLeave?.();
|
|
879
|
+
}
|
|
880
|
+
}),
|
|
881
|
+
onKeyDown: composeEventHandlers(itemProps.onKeyDown, (event) => {
|
|
882
|
+
const isTypingAhead = contentContext.searchRef?.current !== "";
|
|
883
|
+
if (isTypingAhead && event.key === " ") return;
|
|
884
|
+
if (SELECTION_KEYS.includes(event.key)) handleSelect();
|
|
885
|
+
if (event.key === " ") event.preventDefault();
|
|
886
|
+
})
|
|
887
|
+
}
|
|
888
|
+
)
|
|
889
|
+
}
|
|
890
|
+
)
|
|
891
|
+
}
|
|
892
|
+
);
|
|
893
|
+
}
|
|
894
|
+
);
|
|
895
|
+
SelectItem.displayName = ITEM_NAME;
|
|
896
|
+
var ITEM_TEXT_NAME = "SelectItemText";
|
|
897
|
+
var SelectItemText = React.forwardRef(
|
|
898
|
+
(props, forwardedRef) => {
|
|
899
|
+
const { __scopeSelect, className, style, ...itemTextProps } = props;
|
|
900
|
+
const context = useSelectContext(ITEM_TEXT_NAME, __scopeSelect);
|
|
901
|
+
const contentContext = useSelectContentContext(ITEM_TEXT_NAME, __scopeSelect);
|
|
902
|
+
const itemContext = useSelectItemContext(ITEM_TEXT_NAME, __scopeSelect);
|
|
903
|
+
const nativeOptionsContext = useSelectNativeOptionsContext(ITEM_TEXT_NAME, __scopeSelect);
|
|
904
|
+
const [itemTextNode, setItemTextNode] = React.useState(null);
|
|
905
|
+
const composedRefs = useComposedRefs(
|
|
906
|
+
forwardedRef,
|
|
907
|
+
(node) => setItemTextNode(node),
|
|
908
|
+
itemContext.onItemTextChange,
|
|
909
|
+
(node) => contentContext.itemTextRefCallback?.(node, itemContext.value, itemContext.disabled)
|
|
910
|
+
);
|
|
911
|
+
const textContent = itemTextNode?.textContent;
|
|
912
|
+
const nativeOption = React.useMemo(
|
|
913
|
+
() => /* @__PURE__ */ jsx("option", { value: itemContext.value, disabled: itemContext.disabled, children: textContent }, itemContext.value),
|
|
914
|
+
[itemContext.disabled, itemContext.value, textContent]
|
|
915
|
+
);
|
|
916
|
+
const { onNativeOptionAdd, onNativeOptionRemove } = nativeOptionsContext;
|
|
917
|
+
useLayoutEffect2(() => {
|
|
918
|
+
onNativeOptionAdd(nativeOption);
|
|
919
|
+
return () => onNativeOptionRemove(nativeOption);
|
|
920
|
+
}, [onNativeOptionAdd, onNativeOptionRemove, nativeOption]);
|
|
921
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
922
|
+
/* @__PURE__ */ jsx(Primitive.span, { id: itemContext.textId, ...itemTextProps, ref: composedRefs }),
|
|
923
|
+
itemContext.isSelected && context.valueNode && !context.valueNodeHasChildren ? ReactDOM.createPortal(itemTextProps.children, context.valueNode) : null
|
|
924
|
+
] });
|
|
925
|
+
}
|
|
926
|
+
);
|
|
927
|
+
SelectItemText.displayName = ITEM_TEXT_NAME;
|
|
928
|
+
var ITEM_INDICATOR_NAME = "SelectItemIndicator";
|
|
929
|
+
var SelectItemIndicator = React.forwardRef(
|
|
930
|
+
(props, forwardedRef) => {
|
|
931
|
+
const { __scopeSelect, ...itemIndicatorProps } = props;
|
|
932
|
+
const itemContext = useSelectItemContext(ITEM_INDICATOR_NAME, __scopeSelect);
|
|
933
|
+
return itemContext.isSelected ? /* @__PURE__ */ jsx(Primitive.span, { "aria-hidden": true, ...itemIndicatorProps, ref: forwardedRef }) : null;
|
|
934
|
+
}
|
|
935
|
+
);
|
|
936
|
+
SelectItemIndicator.displayName = ITEM_INDICATOR_NAME;
|
|
937
|
+
var SCROLL_UP_BUTTON_NAME = "SelectScrollUpButton";
|
|
938
|
+
var SelectScrollUpButton = React.forwardRef((props, forwardedRef) => {
|
|
939
|
+
const contentContext = useSelectContentContext(SCROLL_UP_BUTTON_NAME, props.__scopeSelect);
|
|
940
|
+
const viewportContext = useSelectViewportContext(SCROLL_UP_BUTTON_NAME, props.__scopeSelect);
|
|
941
|
+
const [canScrollUp, setCanScrollUp] = React.useState(false);
|
|
942
|
+
const composedRefs = useComposedRefs(forwardedRef, viewportContext.onScrollButtonChange);
|
|
943
|
+
useLayoutEffect2(() => {
|
|
944
|
+
if (contentContext.viewport && contentContext.isPositioned) {
|
|
945
|
+
let handleScroll2 = function() {
|
|
946
|
+
const canScrollUp2 = viewport.scrollTop > 0;
|
|
947
|
+
setCanScrollUp(canScrollUp2);
|
|
948
|
+
};
|
|
949
|
+
const viewport = contentContext.viewport;
|
|
950
|
+
handleScroll2();
|
|
951
|
+
viewport.addEventListener("scroll", handleScroll2);
|
|
952
|
+
return () => viewport.removeEventListener("scroll", handleScroll2);
|
|
953
|
+
}
|
|
954
|
+
}, [contentContext.viewport, contentContext.isPositioned]);
|
|
955
|
+
return canScrollUp ? /* @__PURE__ */ jsx(
|
|
956
|
+
SelectScrollButtonImpl,
|
|
957
|
+
{
|
|
958
|
+
...props,
|
|
959
|
+
ref: composedRefs,
|
|
960
|
+
onAutoScroll: () => {
|
|
961
|
+
const { viewport, selectedItem } = contentContext;
|
|
962
|
+
if (viewport && selectedItem) {
|
|
963
|
+
viewport.scrollTop = viewport.scrollTop - selectedItem.offsetHeight;
|
|
935
964
|
}
|
|
936
|
-
|
|
965
|
+
}
|
|
966
|
+
}
|
|
967
|
+
) : null;
|
|
937
968
|
});
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
const
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
const { viewport: viewport , selectedItem: selectedItem } = contentContext;
|
|
968
|
-
if (viewport && selectedItem) viewport.scrollTop = viewport.scrollTop + selectedItem.offsetHeight;
|
|
969
|
+
SelectScrollUpButton.displayName = SCROLL_UP_BUTTON_NAME;
|
|
970
|
+
var SCROLL_DOWN_BUTTON_NAME = "SelectScrollDownButton";
|
|
971
|
+
var SelectScrollDownButton = React.forwardRef((props, forwardedRef) => {
|
|
972
|
+
const contentContext = useSelectContentContext(SCROLL_DOWN_BUTTON_NAME, props.__scopeSelect);
|
|
973
|
+
const viewportContext = useSelectViewportContext(SCROLL_DOWN_BUTTON_NAME, props.__scopeSelect);
|
|
974
|
+
const [canScrollDown, setCanScrollDown] = React.useState(false);
|
|
975
|
+
const composedRefs = useComposedRefs(forwardedRef, viewportContext.onScrollButtonChange);
|
|
976
|
+
useLayoutEffect2(() => {
|
|
977
|
+
if (contentContext.viewport && contentContext.isPositioned) {
|
|
978
|
+
let handleScroll2 = function() {
|
|
979
|
+
const maxScroll = viewport.scrollHeight - viewport.clientHeight;
|
|
980
|
+
const canScrollDown2 = Math.ceil(viewport.scrollTop) < maxScroll;
|
|
981
|
+
setCanScrollDown(canScrollDown2);
|
|
982
|
+
};
|
|
983
|
+
const viewport = contentContext.viewport;
|
|
984
|
+
handleScroll2();
|
|
985
|
+
viewport.addEventListener("scroll", handleScroll2);
|
|
986
|
+
return () => viewport.removeEventListener("scroll", handleScroll2);
|
|
987
|
+
}
|
|
988
|
+
}, [contentContext.viewport, contentContext.isPositioned]);
|
|
989
|
+
return canScrollDown ? /* @__PURE__ */ jsx(
|
|
990
|
+
SelectScrollButtonImpl,
|
|
991
|
+
{
|
|
992
|
+
...props,
|
|
993
|
+
ref: composedRefs,
|
|
994
|
+
onAutoScroll: () => {
|
|
995
|
+
const { viewport, selectedItem } = contentContext;
|
|
996
|
+
if (viewport && selectedItem) {
|
|
997
|
+
viewport.scrollTop = viewport.scrollTop + selectedItem.offsetHeight;
|
|
969
998
|
}
|
|
970
|
-
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
) : null;
|
|
971
1002
|
});
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
1003
|
+
SelectScrollDownButton.displayName = SCROLL_DOWN_BUTTON_NAME;
|
|
1004
|
+
var SelectScrollButtonImpl = React.forwardRef((props, forwardedRef) => {
|
|
1005
|
+
const { __scopeSelect, onAutoScroll, ...scrollIndicatorProps } = props;
|
|
1006
|
+
const contentContext = useSelectContentContext("SelectScrollButton", __scopeSelect);
|
|
1007
|
+
const autoScrollTimerRef = React.useRef(null);
|
|
1008
|
+
const getItems = useCollection(__scopeSelect);
|
|
1009
|
+
const clearAutoScrollTimer = React.useCallback(() => {
|
|
1010
|
+
if (autoScrollTimerRef.current !== null) {
|
|
1011
|
+
window.clearInterval(autoScrollTimerRef.current);
|
|
1012
|
+
autoScrollTimerRef.current = null;
|
|
1013
|
+
}
|
|
1014
|
+
}, []);
|
|
1015
|
+
React.useEffect(() => {
|
|
1016
|
+
return () => clearAutoScrollTimer();
|
|
1017
|
+
}, [clearAutoScrollTimer]);
|
|
1018
|
+
useLayoutEffect2(() => {
|
|
1019
|
+
const activeItem = getItems().find((item) => item.ref.current === document.activeElement);
|
|
1020
|
+
activeItem?.ref.current?.scrollIntoView({ block: "nearest" });
|
|
1021
|
+
}, [getItems]);
|
|
1022
|
+
return /* @__PURE__ */ jsx(
|
|
1023
|
+
Primitive.div,
|
|
1024
|
+
{
|
|
1025
|
+
"aria-hidden": true,
|
|
1026
|
+
...scrollIndicatorProps,
|
|
1027
|
+
ref: forwardedRef,
|
|
1028
|
+
style: { flexShrink: 0, ...scrollIndicatorProps.style },
|
|
1029
|
+
onPointerDown: composeEventHandlers(scrollIndicatorProps.onPointerDown, () => {
|
|
1030
|
+
if (autoScrollTimerRef.current === null) {
|
|
1031
|
+
autoScrollTimerRef.current = window.setInterval(onAutoScroll, 50);
|
|
981
1032
|
}
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
clearAutoScrollTimer
|
|
988
|
-
]); // When the viewport becomes scrollable on either side, the relevant scroll button will mount.
|
|
989
|
-
// Because it is part of the normal flow, it will push down (top button) or shrink (bottom button)
|
|
990
|
-
// the viewport, potentially causing the active item to now be partially out of view.
|
|
991
|
-
// We re-run the `scrollIntoView` logic to make sure it stays within the viewport.
|
|
992
|
-
$9f79659886946c16$export$e5c5a5f917a5871c(()=>{
|
|
993
|
-
var _activeItem$ref$curre;
|
|
994
|
-
const activeItem = getItems().find((item)=>item.ref.current === document.activeElement
|
|
995
|
-
);
|
|
996
|
-
activeItem === null || activeItem === void 0 || (_activeItem$ref$curre = activeItem.ref.current) === null || _activeItem$ref$curre === void 0 || _activeItem$ref$curre.scrollIntoView({
|
|
997
|
-
block: 'nearest'
|
|
998
|
-
});
|
|
999
|
-
}, [
|
|
1000
|
-
getItems
|
|
1001
|
-
]);
|
|
1002
|
-
return /*#__PURE__*/ createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.div, _extends({
|
|
1003
|
-
"aria-hidden": true
|
|
1004
|
-
}, scrollIndicatorProps, {
|
|
1005
|
-
ref: forwardedRef,
|
|
1006
|
-
style: {
|
|
1007
|
-
flexShrink: 0,
|
|
1008
|
-
...scrollIndicatorProps.style
|
|
1009
|
-
},
|
|
1010
|
-
onPointerDown: $e42e1063c40fb3ef$export$b9ecd428b558ff10(scrollIndicatorProps.onPointerDown, ()=>{
|
|
1011
|
-
if (autoScrollTimerRef.current === null) autoScrollTimerRef.current = window.setInterval(onAutoScroll, 50);
|
|
1012
|
-
}),
|
|
1013
|
-
onPointerMove: $e42e1063c40fb3ef$export$b9ecd428b558ff10(scrollIndicatorProps.onPointerMove, ()=>{
|
|
1014
|
-
var _contentContext$onIte3;
|
|
1015
|
-
(_contentContext$onIte3 = contentContext.onItemLeave) === null || _contentContext$onIte3 === void 0 || _contentContext$onIte3.call(contentContext);
|
|
1016
|
-
if (autoScrollTimerRef.current === null) autoScrollTimerRef.current = window.setInterval(onAutoScroll, 50);
|
|
1017
|
-
}),
|
|
1018
|
-
onPointerLeave: $e42e1063c40fb3ef$export$b9ecd428b558ff10(scrollIndicatorProps.onPointerLeave, ()=>{
|
|
1019
|
-
clearAutoScrollTimer();
|
|
1020
|
-
})
|
|
1021
|
-
}));
|
|
1022
|
-
});
|
|
1023
|
-
const $cc7e05a45900e73f$export$eba4b1df07cb1d3 = /*#__PURE__*/ forwardRef((props, forwardedRef)=>{
|
|
1024
|
-
const { __scopeSelect: __scopeSelect , ...separatorProps } = props;
|
|
1025
|
-
return /*#__PURE__*/ createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.div, _extends({
|
|
1026
|
-
"aria-hidden": true
|
|
1027
|
-
}, separatorProps, {
|
|
1028
|
-
ref: forwardedRef
|
|
1029
|
-
}));
|
|
1030
|
-
});
|
|
1031
|
-
/* -----------------------------------------------------------------------------------------------*/ function $cc7e05a45900e73f$var$shouldShowPlaceholder(value) {
|
|
1032
|
-
return value === '' || value === undefined;
|
|
1033
|
-
}
|
|
1034
|
-
const $cc7e05a45900e73f$var$BubbleSelect = /*#__PURE__*/ forwardRef((props, forwardedRef)=>{
|
|
1035
|
-
const { value: value , ...selectProps } = props;
|
|
1036
|
-
const ref = useRef(null);
|
|
1037
|
-
const composedRefs = $6ed0406888f73fc4$export$c7b2cbe3552a0d05(forwardedRef, ref);
|
|
1038
|
-
const prevValue = $010c2913dbd2fe3d$export$5cae361ad82dce8b(value); // Bubble value change to parents (e.g form change event)
|
|
1039
|
-
useEffect(()=>{
|
|
1040
|
-
const select = ref.current;
|
|
1041
|
-
const selectProto = window.HTMLSelectElement.prototype;
|
|
1042
|
-
const descriptor = Object.getOwnPropertyDescriptor(selectProto, 'value');
|
|
1043
|
-
const setValue = descriptor.set;
|
|
1044
|
-
if (prevValue !== value && setValue) {
|
|
1045
|
-
const event = new Event('change', {
|
|
1046
|
-
bubbles: true
|
|
1047
|
-
});
|
|
1048
|
-
setValue.call(select, value);
|
|
1049
|
-
select.dispatchEvent(event);
|
|
1033
|
+
}),
|
|
1034
|
+
onPointerMove: composeEventHandlers(scrollIndicatorProps.onPointerMove, () => {
|
|
1035
|
+
contentContext.onItemLeave?.();
|
|
1036
|
+
if (autoScrollTimerRef.current === null) {
|
|
1037
|
+
autoScrollTimerRef.current = window.setInterval(onAutoScroll, 50);
|
|
1050
1038
|
}
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1039
|
+
}),
|
|
1040
|
+
onPointerLeave: composeEventHandlers(scrollIndicatorProps.onPointerLeave, () => {
|
|
1041
|
+
clearAutoScrollTimer();
|
|
1042
|
+
})
|
|
1043
|
+
}
|
|
1044
|
+
);
|
|
1045
|
+
});
|
|
1046
|
+
var SEPARATOR_NAME = "SelectSeparator";
|
|
1047
|
+
var SelectSeparator = React.forwardRef(
|
|
1048
|
+
(props, forwardedRef) => {
|
|
1049
|
+
const { __scopeSelect, ...separatorProps } = props;
|
|
1050
|
+
return /* @__PURE__ */ jsx(Primitive.div, { "aria-hidden": true, ...separatorProps, ref: forwardedRef });
|
|
1051
|
+
}
|
|
1052
|
+
);
|
|
1053
|
+
SelectSeparator.displayName = SEPARATOR_NAME;
|
|
1054
|
+
var ARROW_NAME = "SelectArrow";
|
|
1055
|
+
var SelectArrow = React.forwardRef(
|
|
1056
|
+
(props, forwardedRef) => {
|
|
1057
|
+
const { __scopeSelect, ...arrowProps } = props;
|
|
1058
|
+
const popperScope = usePopperScope(__scopeSelect);
|
|
1059
|
+
const context = useSelectContext(ARROW_NAME, __scopeSelect);
|
|
1060
|
+
const contentContext = useSelectContentContext(ARROW_NAME, __scopeSelect);
|
|
1061
|
+
return context.open && contentContext.position === "popper" ? /* @__PURE__ */ jsx(Arrow, { ...popperScope, ...arrowProps, ref: forwardedRef }) : null;
|
|
1062
|
+
}
|
|
1063
|
+
);
|
|
1064
|
+
SelectArrow.displayName = ARROW_NAME;
|
|
1065
|
+
var BUBBLE_INPUT_NAME = "SelectBubbleInput";
|
|
1066
|
+
var SelectBubbleInput = React.forwardRef(
|
|
1067
|
+
({ __scopeSelect, value, ...props }, forwardedRef) => {
|
|
1068
|
+
const ref = React.useRef(null);
|
|
1069
|
+
const composedRefs = useComposedRefs(forwardedRef, ref);
|
|
1070
|
+
const prevValue = usePrevious(value);
|
|
1071
|
+
React.useEffect(() => {
|
|
1072
|
+
const select = ref.current;
|
|
1073
|
+
if (!select) return;
|
|
1074
|
+
const selectProto = window.HTMLSelectElement.prototype;
|
|
1075
|
+
const descriptor = Object.getOwnPropertyDescriptor(
|
|
1076
|
+
selectProto,
|
|
1077
|
+
"value"
|
|
1078
|
+
);
|
|
1079
|
+
const setValue = descriptor.set;
|
|
1080
|
+
if (prevValue !== value && setValue) {
|
|
1081
|
+
const event = new Event("change", { bubbles: true });
|
|
1082
|
+
setValue.call(select, value);
|
|
1083
|
+
select.dispatchEvent(event);
|
|
1084
|
+
}
|
|
1085
|
+
}, [prevValue, value]);
|
|
1086
|
+
return /* @__PURE__ */ jsx(
|
|
1087
|
+
Primitive.select,
|
|
1088
|
+
{
|
|
1089
|
+
...props,
|
|
1090
|
+
style: { ...VISUALLY_HIDDEN_STYLES, ...props.style },
|
|
1069
1091
|
ref: composedRefs,
|
|
1070
1092
|
defaultValue: value
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
]);
|
|
1090
|
-
const resetTypeahead = useCallback(()=>{
|
|
1091
|
-
searchRef.current = '';
|
|
1093
|
+
}
|
|
1094
|
+
);
|
|
1095
|
+
}
|
|
1096
|
+
);
|
|
1097
|
+
SelectBubbleInput.displayName = BUBBLE_INPUT_NAME;
|
|
1098
|
+
function shouldShowPlaceholder(value) {
|
|
1099
|
+
return value === "" || value === void 0;
|
|
1100
|
+
}
|
|
1101
|
+
function useTypeaheadSearch(onSearchChange) {
|
|
1102
|
+
const handleSearchChange = useCallbackRef(onSearchChange);
|
|
1103
|
+
const searchRef = React.useRef("");
|
|
1104
|
+
const timerRef = React.useRef(0);
|
|
1105
|
+
const handleTypeaheadSearch = React.useCallback(
|
|
1106
|
+
(key) => {
|
|
1107
|
+
const search = searchRef.current + key;
|
|
1108
|
+
handleSearchChange(search);
|
|
1109
|
+
(function updateSearch(value) {
|
|
1110
|
+
searchRef.current = value;
|
|
1092
1111
|
window.clearTimeout(timerRef.current);
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1112
|
+
if (value !== "") timerRef.current = window.setTimeout(() => updateSearch(""), 1e3);
|
|
1113
|
+
})(search);
|
|
1114
|
+
},
|
|
1115
|
+
[handleSearchChange]
|
|
1116
|
+
);
|
|
1117
|
+
const resetTypeahead = React.useCallback(() => {
|
|
1118
|
+
searchRef.current = "";
|
|
1119
|
+
window.clearTimeout(timerRef.current);
|
|
1120
|
+
}, []);
|
|
1121
|
+
React.useEffect(() => {
|
|
1122
|
+
return () => window.clearTimeout(timerRef.current);
|
|
1123
|
+
}, []);
|
|
1124
|
+
return [searchRef, handleTypeaheadSearch, resetTypeahead];
|
|
1103
1125
|
}
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
*
|
|
1116
|
-
* Finally, if the normalized search is exactly one character, we exclude the
|
|
1117
|
-
* current item from the values because otherwise it would be the first to match always
|
|
1118
|
-
* and focus would never move. This is as opposed to the regular case, where we
|
|
1119
|
-
* don't want focus to move if the current item still matches.
|
|
1120
|
-
*/ function $cc7e05a45900e73f$var$findNextItem(items, search, currentItem) {
|
|
1121
|
-
const isRepeated = search.length > 1 && Array.from(search).every((char)=>char === search[0]
|
|
1122
|
-
);
|
|
1123
|
-
const normalizedSearch = isRepeated ? search[0] : search;
|
|
1124
|
-
const currentItemIndex = currentItem ? items.indexOf(currentItem) : -1;
|
|
1125
|
-
let wrappedItems = $cc7e05a45900e73f$var$wrapArray(items, Math.max(currentItemIndex, 0));
|
|
1126
|
-
const excludeCurrentItem = normalizedSearch.length === 1;
|
|
1127
|
-
if (excludeCurrentItem) wrappedItems = wrappedItems.filter((v)=>v !== currentItem
|
|
1128
|
-
);
|
|
1129
|
-
const nextItem = wrappedItems.find((item)=>item.textValue.toLowerCase().startsWith(normalizedSearch.toLowerCase())
|
|
1130
|
-
);
|
|
1131
|
-
return nextItem !== currentItem ? nextItem : undefined;
|
|
1126
|
+
function findNextItem(items, search, currentItem) {
|
|
1127
|
+
const isRepeated = search.length > 1 && Array.from(search).every((char) => char === search[0]);
|
|
1128
|
+
const normalizedSearch = isRepeated ? search[0] : search;
|
|
1129
|
+
const currentItemIndex = currentItem ? items.indexOf(currentItem) : -1;
|
|
1130
|
+
let wrappedItems = wrapArray(items, Math.max(currentItemIndex, 0));
|
|
1131
|
+
const excludeCurrentItem = normalizedSearch.length === 1;
|
|
1132
|
+
if (excludeCurrentItem) wrappedItems = wrappedItems.filter((v) => v !== currentItem);
|
|
1133
|
+
const nextItem = wrappedItems.find(
|
|
1134
|
+
(item) => item.textValue.toLowerCase().startsWith(normalizedSearch.toLowerCase())
|
|
1135
|
+
);
|
|
1136
|
+
return nextItem !== currentItem ? nextItem : void 0;
|
|
1132
1137
|
}
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
* Example: `wrapArray(['a', 'b', 'c', 'd'], 2) === ['c', 'd', 'a', 'b']`
|
|
1136
|
-
*/ function $cc7e05a45900e73f$var$wrapArray(array, startIndex) {
|
|
1137
|
-
return array.map((_, index)=>array[(startIndex + index) % array.length]
|
|
1138
|
-
);
|
|
1138
|
+
function wrapArray(array, startIndex) {
|
|
1139
|
+
return array.map((_, index) => array[(startIndex + index) % array.length]);
|
|
1139
1140
|
}
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1141
|
+
var Root2 = Select;
|
|
1142
|
+
var Trigger = SelectTrigger;
|
|
1143
|
+
var Value = SelectValue;
|
|
1144
|
+
var Icon = SelectIcon;
|
|
1145
|
+
var Portal = SelectPortal;
|
|
1146
|
+
var Content2 = SelectContent;
|
|
1147
|
+
var Viewport = SelectViewport;
|
|
1148
|
+
var Group = SelectGroup;
|
|
1149
|
+
var Label = SelectLabel;
|
|
1150
|
+
var Item = SelectItem;
|
|
1151
|
+
var ItemText = SelectItemText;
|
|
1152
|
+
var ItemIndicator = SelectItemIndicator;
|
|
1153
|
+
var ScrollUpButton = SelectScrollUpButton;
|
|
1154
|
+
var ScrollDownButton = SelectScrollDownButton;
|
|
1155
|
+
var Separator = SelectSeparator;
|
|
1155
1156
|
|
|
1156
|
-
export {
|
|
1157
|
+
export { Content2 as Content, Group, Icon, Item, ItemIndicator, ItemText, Label, Portal, Root2 as Root, ScrollDownButton, ScrollUpButton, Select, SelectArrow, SelectContent, SelectGroup, SelectIcon, SelectItem, SelectItemIndicator, SelectItemText, SelectLabel, SelectPortal, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, SelectViewport, Separator, Trigger, Value, Viewport, createSelectScope };
|
|
1157
1158
|
//# sourceMappingURL=index.mjs.js.map
|