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