@koide-labs/ui 0.0.0 → 0.0.2
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/README.md +53 -3
- package/{src/-types.ts → dist/-types.d.ts} +1 -6
- package/dist/-types.js +1 -0
- package/dist/-utils.d.ts +19 -0
- package/dist/-utils.js +33 -0
- package/dist/Button-DrPFFzo7.js +31 -0
- package/dist/CompositeRoot-CVk5a-pR.js +233 -0
- package/dist/DirectionContext-C2o_MF_i.js +9 -0
- package/dist/FieldItemContext-DAvk99to.js +11 -0
- package/dist/FloatingPortal-tWyuKRSN.js +435 -0
- package/dist/FloatingPortalLite-DVyq6YhV.js +28 -0
- package/dist/InternalBackdrop-jYAiOJ8v.js +574 -0
- package/dist/LabelableContext-BMvjVwor.js +169 -0
- package/dist/ToolbarRootContext-CvvL0Tk1.js +9 -0
- package/dist/clamp-D0KDAQIz.js +6 -0
- package/dist/clsx-OuTLNxxd.js +16 -0
- package/dist/components/accordion/index.d.ts +12 -0
- package/dist/components/accordion/index.js +699 -0
- package/dist/components/alert-dialog/index.d.ts +26 -0
- package/dist/components/alert-dialog/index.js +136 -0
- package/dist/components/anchor/index.d.ts +8 -0
- package/dist/components/anchor/index.js +38 -0
- package/dist/components/avatar/index.d.ts +21 -0
- package/dist/components/avatar/index.js +161 -0
- package/dist/components/badge/index.d.ts +16 -0
- package/dist/components/badge/index.js +40 -0
- package/dist/components/button/index.d.ts +24 -0
- package/dist/components/button/index.js +47 -0
- package/dist/components/checkbox/index.d.ts +9 -0
- package/dist/components/checkbox/index.js +269 -0
- package/dist/components/code/index.d.ts +9 -0
- package/dist/components/code/index.js +10 -0
- package/dist/components/collapse/index.d.ts +11 -0
- package/dist/components/collapse/index.js +41 -0
- package/dist/components/command/index.d.ts +14 -0
- package/dist/components/command/index.js +1695 -0
- package/dist/components/context-menu/index.d.ts +42 -0
- package/dist/components/context-menu/index.js +1444 -0
- package/dist/components/dialog/index.d.ts +48 -0
- package/dist/components/dialog/index.js +138 -0
- package/dist/components/heading/index.d.ts +44 -0
- package/dist/components/heading/index.js +56 -0
- package/dist/components/icon/icon-names.d.ts +1 -0
- package/dist/components/icon/icon-names.js +1 -0
- package/dist/components/icon/index.d.ts +24 -0
- package/dist/components/icon/index.js +43 -0
- package/dist/components/icon-button/index.d.ts +12 -0
- package/dist/components/icon-button/index.js +45 -0
- package/dist/components/inline-code/index.d.ts +6 -0
- package/dist/components/inline-code/index.js +22 -0
- package/dist/components/input/index.d.ts +3 -0
- package/dist/components/input/index.js +119 -0
- package/dist/components/meter/index.d.ts +18 -0
- package/dist/components/meter/index.js +165 -0
- package/dist/components/multiline-input/index.d.ts +6 -0
- package/dist/components/multiline-input/index.js +100 -0
- package/dist/components/number-input/index.d.ts +10 -0
- package/dist/components/number-input/index.js +1169 -0
- package/dist/components/password-input/index.d.ts +2 -0
- package/dist/components/password-input/index.js +29 -0
- package/dist/components/pill/index.d.ts +13 -0
- package/dist/components/pill/index.js +38 -0
- package/dist/components/popover/index.d.ts +21 -0
- package/dist/components/popover/index.js +636 -0
- package/dist/components/preview-card/index.d.ts +17 -0
- package/dist/components/preview-card/index.js +402 -0
- package/dist/components/radio/index.d.ts +13 -0
- package/dist/components/radio/index.js +404 -0
- package/dist/components/search-bar/index.d.ts +12 -0
- package/dist/components/search-bar/index.js +48 -0
- package/dist/components/select/index.d.ts +16 -0
- package/dist/components/select/index.js +1263 -0
- package/dist/components/separator/index.d.ts +7 -0
- package/dist/components/separator/index.js +6 -0
- package/dist/components/slider/index.d.ts +5 -0
- package/dist/components/slider/index.js +902 -0
- package/dist/components/spinner/index.d.ts +2 -0
- package/dist/components/spinner/index.js +13 -0
- package/dist/components/stacked-avatars/index.d.ts +14 -0
- package/dist/components/stacked-avatars/index.js +92 -0
- package/dist/components/status-banner/index.d.ts +17 -0
- package/dist/components/status-banner/index.js +69 -0
- package/dist/components/surface/index.d.ts +27 -0
- package/dist/components/surface/index.js +41 -0
- package/dist/components/switch/index.d.ts +5 -0
- package/dist/components/switch/index.js +196 -0
- package/dist/components/tabs/index.d.ts +18 -0
- package/dist/components/tabs/index.js +509 -0
- package/dist/components/text/index.d.ts +26 -0
- package/dist/components/text/index.js +51 -0
- package/dist/components/theme-provider/index.d.ts +2 -0
- package/dist/components/theme-provider/index.js +6 -0
- package/dist/components/theme-provider/theme-context.d.ts +9 -0
- package/dist/components/theme-provider/theme-context.js +13 -0
- package/dist/components/theme-provider/theme-provider.d.ts +17 -0
- package/dist/components/theme-provider/theme-provider.js +30 -0
- package/dist/components/timestamp/index.d.ts +23 -0
- package/dist/components/timestamp/index.js +1392 -0
- package/dist/components/toast/index.d.ts +2 -0
- package/dist/components/toast/index.js +7 -0
- package/dist/components/toast/toast.d.ts +2 -0
- package/dist/components/toast/toast.js +878 -0
- package/dist/components/toast/use-toast-manager.d.ts +27 -0
- package/dist/components/toast/use-toast-manager.js +4 -0
- package/dist/components/tooltip/index.d.ts +14 -0
- package/dist/components/tooltip/index.js +712 -0
- package/dist/components/tooltip/tooltip-arrow.d.ts +3 -0
- package/dist/components/tooltip/tooltip-arrow.js +6 -0
- package/dist/components/view/index.d.ts +30 -0
- package/dist/components/view/index.js +84 -0
- package/dist/components/visually-hidden/index.d.ts +1 -0
- package/dist/components/visually-hidden/index.js +4 -0
- package/dist/composite-Bx7Szd_T.js +208 -0
- package/dist/composite-C9L5QmZL.js +66 -0
- package/dist/createBaseUIEventDetails-D8M2Yl-a.js +59 -0
- package/dist/detectBrowser-I-s3yzIE.js +43 -0
- package/dist/dialog.css +1 -0
- package/dist/dialog.module-BeF-6XAo.js +415 -0
- package/dist/element-CZEOj04G.js +80 -0
- package/dist/event-CKoGyQEJ.js +30 -0
- package/dist/floating-ui.utils-C7pRWMZ_.js +128 -0
- package/dist/floating-ui.utils.dom-C7FS5id0.js +135 -0
- package/dist/formatErrorMessage-BqPuTBN-.js +7 -0
- package/dist/formatNumber-1UNwjeqf.js +25 -0
- package/dist/getDisabledMountTransitionStyles-YfHPge6T.js +1510 -0
- package/dist/index-BX1XbbRk.js +1206 -0
- package/dist/index-CeuccO-T.js +109 -0
- package/dist/index-DN9Bn1qm.js +29 -0
- package/dist/index-FMoPxlJ2.js +52 -0
- package/dist/index.css +1 -0
- package/dist/index.d.ts +42 -0
- package/dist/index.js +108 -0
- package/dist/index10.css +1 -0
- package/dist/index11.css +1 -0
- package/dist/index12.css +1 -0
- package/dist/index13.css +1 -0
- package/dist/index14.css +1 -0
- package/dist/index15.css +1 -0
- package/dist/index16.css +1 -0
- package/dist/index17.css +1 -0
- package/dist/index18.css +1 -0
- package/dist/index19.css +1 -0
- package/dist/index2.css +1 -0
- package/dist/index20.css +1 -0
- package/dist/index21.css +1 -0
- package/dist/index22.css +1 -0
- package/dist/index23.css +1 -0
- package/dist/index24.css +1 -0
- package/dist/index25.css +1 -0
- package/dist/index26.css +1 -0
- package/dist/index27.css +1 -0
- package/dist/index28.css +1 -0
- package/dist/index29.css +1 -0
- package/dist/index3.css +1 -0
- package/dist/index30.css +1 -0
- package/dist/index31.css +1 -0
- package/dist/index32.css +1 -0
- package/dist/index33.css +1 -0
- package/dist/index34.css +1 -0
- package/dist/index35.css +1 -0
- package/dist/index36.css +1 -0
- package/dist/index37.css +1 -0
- package/dist/index4.css +1 -0
- package/dist/index5.css +1 -0
- package/dist/index6.css +1 -0
- package/dist/index7.css +1 -0
- package/dist/index8.css +1 -0
- package/dist/index9.css +1 -0
- package/dist/inertValue-BCYGsdmf.js +7 -0
- package/dist/input.css +1 -0
- package/dist/input.module-DDQY_Ij6.js +7 -0
- package/dist/integrations/react-markdown/index.d.ts +5 -0
- package/dist/integrations/react-markdown/index.js +6895 -0
- package/dist/integrations/remix/index.d.ts +9 -0
- package/{src/integrations/remix.ts → dist/integrations/remix/index.js} +7 -4
- package/dist/integrations/tailwind.css +1 -0
- package/dist/integrations/twemoij/index.d.ts +3 -0
- package/dist/integrations/twemoij/index.js +18 -0
- package/dist/isElementDisabled-Cbd8W9kH.js +6 -0
- package/dist/owner-rKN292Q9.js +6 -0
- package/dist/safePolygon-DWy1dGKJ.js +308 -0
- package/dist/styles/core.css +1 -0
- package/dist/styles/tokens.d.ts +400 -0
- package/{src/styles/tokens.ts → dist/styles/tokens.js} +54 -96
- package/dist/toast.css +1 -0
- package/dist/tooltip-arrow-C1qXdi5T.js +24 -0
- package/dist/tooltip-arrow.css +1 -0
- package/dist/transitions.css +1 -0
- package/dist/transitions.module-CWX8e5cx.js +1343 -0
- package/dist/use-toast-manager-Dq-44AuW.js +37 -0
- package/dist/useAnimationFrame-451ugS_6.js +68 -0
- package/dist/useBaseUiId-B7WyxtIE.js +7 -0
- package/dist/useButton-DfIwsdb8.js +127 -0
- package/dist/useCompositeListItem-OkcAim_1.js +148 -0
- package/dist/useControlled-Du4sJyMj.js +31 -0
- package/dist/useHoverReferenceInteraction-SfOBPoXM.js +264 -0
- package/dist/useId-C5kyn6tA.js +22 -0
- package/dist/useIsoLayoutEffect-CIDbvm3Q.js +6 -0
- package/dist/useLabelableId-Ci_jDvmv.js +29 -0
- package/dist/useOnMount-VRW6CK2u.js +8 -0
- package/dist/useOpenChangeComplete-Dse9kY9E.js +61 -0
- package/dist/usePopupAutoResize-CNR6Ekmx.js +85 -0
- package/dist/useRender-CLx7dR_1.js +7 -0
- package/dist/useRenderElement-DwToLA61.js +244 -0
- package/dist/useRole-oDBdbuwQ.js +77 -0
- package/dist/useStableCallback-CkTrVkNX.js +29 -0
- package/dist/useSyncedFloatingRootContext-Dorsv-jf.js +167 -0
- package/dist/useTimeout-CflX-kz3.js +32 -0
- package/dist/useTransitionStatus-CUfcuGAV.js +42 -0
- package/dist/useTypeahead-D85V2IUx.js +333 -0
- package/dist/useValueAsRef-HURLzret.js +19 -0
- package/dist/useValueChanged-DL757-yD.js +14 -0
- package/dist/valueToPercent-DaP9qN4u.js +6 -0
- package/dist/view.css +1 -0
- package/dist/view.module-DfDLgJE0.js +6 -0
- package/dist/visuallyHidden-CpJ-mhai.js +16 -0
- package/dist/warn-CKtX8MLJ.js +11 -0
- package/package.json +18 -2
- package/.husky/pre-commit +0 -1
- package/.storybook/main.ts +0 -25
- package/.storybook/preview-head.html +0 -6
- package/.storybook/preview.tsx +0 -48
- package/.storybook/vitest.setup.ts +0 -8
- package/eslint.config.mjs +0 -29
- package/lint-staged.config.js +0 -15
- package/pnpm-workspace.yaml +0 -2
- package/postcss.config.mjs +0 -7
- package/prettier.config.mjs +0 -24
- package/scripts/build-icon-types.ts +0 -38
- package/src/-utils.tsx +0 -64
- package/src/components/accordion/accordion.module.css +0 -44
- package/src/components/accordion/accordion.stories.tsx +0 -36
- package/src/components/accordion/index.tsx +0 -67
- package/src/components/alert-dialog/alert-dialog.module.css +0 -5
- package/src/components/alert-dialog/alert-dialog.stories.tsx +0 -53
- package/src/components/alert-dialog/index.tsx +0 -138
- package/src/components/anchor/anchor.module.css +0 -18
- package/src/components/anchor/anchor.stories.tsx +0 -28
- package/src/components/anchor/index.tsx +0 -45
- package/src/components/avatar/avatar.module.css +0 -56
- package/src/components/avatar/avatar.stories.tsx +0 -61
- package/src/components/avatar/index.tsx +0 -82
- package/src/components/badge/badge.module.css +0 -35
- package/src/components/badge/badge.stories.tsx +0 -60
- package/src/components/badge/index.tsx +0 -71
- package/src/components/button/button.module.css +0 -42
- package/src/components/button/button.stories.tsx +0 -108
- package/src/components/button/index.tsx +0 -63
- package/src/components/checkbox/checkbox.module.css +0 -36
- package/src/components/checkbox/checkbox.stories.tsx +0 -21
- package/src/components/checkbox/index.tsx +0 -41
- package/src/components/code/code.module.css +0 -20
- package/src/components/code/code.stories.tsx +0 -42
- package/src/components/code/index.tsx +0 -73
- package/src/components/collapse/collapse.module.css +0 -27
- package/src/components/collapse/collapse.stories.tsx +0 -27
- package/src/components/collapse/index.tsx +0 -59
- package/src/components/command/command.module.css +0 -95
- package/src/components/command/command.stories.tsx +0 -38
- package/src/components/command/index.tsx +0 -108
- package/src/components/context-menu/context-menu.module.css +0 -36
- package/src/components/context-menu/context-menu.stories.tsx +0 -99
- package/src/components/context-menu/index.tsx +0 -242
- package/src/components/dialog/dialog.module.css +0 -71
- package/src/components/dialog/dialog.stories.tsx +0 -29
- package/src/components/dialog/index.tsx +0 -148
- package/src/components/heading/heading.module.css +0 -3
- package/src/components/heading/heading.stories.tsx +0 -52
- package/src/components/heading/index.tsx +0 -112
- package/src/components/icon/icon-names.ts +0 -3189
- package/src/components/icon/icon.module.css +0 -36
- package/src/components/icon/icon.stories.tsx +0 -40
- package/src/components/icon/index.tsx +0 -60
- package/src/components/icon-button/icon-button.module.css +0 -33
- package/src/components/icon-button/icon-button.stories.tsx +0 -59
- package/src/components/icon-button/index.tsx +0 -48
- package/src/components/inline-code/index.tsx +0 -29
- package/src/components/inline-code/inline-code.module.css +0 -13
- package/src/components/inline-code/inline-code.stories.tsx +0 -31
- package/src/components/input/index.tsx +0 -22
- package/src/components/input/input.module.css +0 -23
- package/src/components/input/input.stories.tsx +0 -52
- package/src/components/meter/index.tsx +0 -55
- package/src/components/meter/meter.module.css +0 -23
- package/src/components/meter/meter.stories.tsx +0 -31
- package/src/components/multiline-input/index.tsx +0 -58
- package/src/components/multiline-input/multiline-input.stories.tsx +0 -26
- package/src/components/number-input/index.tsx +0 -74
- package/src/components/number-input/number-input.module.css +0 -41
- package/src/components/number-input/number-input.stories.tsx +0 -24
- package/src/components/password-input/index.tsx +0 -24
- package/src/components/password-input/password-input.module.css +0 -10
- package/src/components/password-input/password-input.stories.tsx +0 -24
- package/src/components/pill/index.tsx +0 -45
- package/src/components/pill/pill.module.css +0 -22
- package/src/components/pill/pill.stories.tsx +0 -83
- package/src/components/popover/index.tsx +0 -94
- package/src/components/popover/popover.module.css +0 -8
- package/src/components/popover/popover.stories.tsx +0 -53
- package/src/components/preview-card/index.tsx +0 -68
- package/src/components/preview-card/preview-card.module.css +0 -5
- package/src/components/preview-card/preview-card.stories.tsx +0 -58
- package/src/components/radio/index.tsx +0 -67
- package/src/components/radio/radio-group.module.css +0 -5
- package/src/components/radio/radio.module.css +0 -36
- package/src/components/radio/radio.stories.tsx +0 -27
- package/src/components/search-bar/index.tsx +0 -60
- package/src/components/search-bar/search-bar.module.css +0 -29
- package/src/components/search-bar/search-bar.stories.tsx +0 -37
- package/src/components/select/index.tsx +0 -132
- package/src/components/select/select.module.css +0 -63
- package/src/components/select/select.stories.tsx +0 -49
- package/src/components/separator/index.tsx +0 -28
- package/src/components/separator/separator.module.css +0 -24
- package/src/components/separator/separator.stories.tsx +0 -40
- package/src/components/slider/index.tsx +0 -28
- package/src/components/slider/slider.module.css +0 -52
- package/src/components/slider/slider.stories.tsx +0 -53
- package/src/components/spinner/index.tsx +0 -14
- package/src/components/spinner/spinner.module.css +0 -13
- package/src/components/spinner/spinner.stories.tsx +0 -17
- package/src/components/stacked-avatars/index.tsx +0 -88
- package/src/components/stacked-avatars/stacked-avatars.module.css +0 -79
- package/src/components/stacked-avatars/stacked-avatars.stories.tsx +0 -48
- package/src/components/status-banner/index.tsx +0 -96
- package/src/components/status-banner/status-banner.module.css +0 -52
- package/src/components/status-banner/status-banner.stories.tsx +0 -44
- package/src/components/surface/index.tsx +0 -83
- package/src/components/surface/surface.module.css +0 -35
- package/src/components/surface/surface.stories.tsx +0 -84
- package/src/components/switch/index.tsx +0 -23
- package/src/components/switch/switch.module.css +0 -45
- package/src/components/switch/switch.stories.tsx +0 -48
- package/src/components/tabs/index.tsx +0 -126
- package/src/components/tabs/tabs.module.css +0 -134
- package/src/components/tabs/tabs.stories.tsx +0 -88
- package/src/components/text/index.tsx +0 -69
- package/src/components/text/text.module.css +0 -76
- package/src/components/text/text.stories.tsx +0 -107
- package/src/components/theme-provider/index.ts +0 -2
- package/src/components/theme-provider/theme-context.tsx +0 -18
- package/src/components/theme-provider/theme-provider.stories.tsx +0 -47
- package/src/components/theme-provider/theme-provider.tsx +0 -77
- package/src/components/timestamp/index.tsx +0 -131
- package/src/components/timestamp/timestamp.module.css +0 -8
- package/src/components/timestamp/timestamp.stories.tsx +0 -37
- package/src/components/toast/index.ts +0 -2
- package/src/components/toast/toast.module.css +0 -163
- package/src/components/toast/toast.stories.tsx +0 -53
- package/src/components/toast/toast.tsx +0 -104
- package/src/components/toast/use-toast-manager.ts +0 -63
- package/src/components/tooltip/index.tsx +0 -61
- package/src/components/tooltip/tooltip-arrow.tsx +0 -17
- package/src/components/tooltip/tooltip.module.css +0 -44
- package/src/components/tooltip/tooltip.stories.tsx +0 -76
- package/src/components/view/index.tsx +0 -137
- package/src/components/view/view.module.css +0 -11
- package/src/components/view/view.stories.tsx +0 -131
- package/src/components/view/view_colorway.module.css +0 -280
- package/src/components/view/view_interactive.module.css +0 -127
- package/src/components/view/view_loading.module.css +0 -58
- package/src/components/visually-hidden/index.ts +0 -1
- package/src/index.ts +0 -49
- package/src/integrations/react-markdown/index.tsx +0 -134
- package/src/integrations/react-markdown/react-markdown.module.css +0 -62
- package/src/integrations/react-markdown/react-markdown.stories.tsx +0 -31
- package/src/integrations/tailwind.css +0 -173
- package/src/integrations/twemoij/index.tsx +0 -13
- package/src/integrations/twemoij/twemoji.module.css +0 -7
- package/src/integrations/twemoij/twemoji.stories.tsx +0 -40
- package/src/stories/components/all-variants.tsx +0 -40
- package/src/stories/data.ts +0 -72
- package/src/stories/utils.ts +0 -20
- package/src/styles/core.css +0 -153
- package/src/styles/themes/dark.css +0 -86
- package/src/styles/themes/light.css +0 -86
- package/src/styles/transitions.module.css +0 -31
- package/stylelint.config.mjs +0 -29
- package/tsconfig.app.json +0 -35
- package/tsconfig.json +0 -7
- package/tsconfig.node.json +0 -26
- package/vite.config.ts +0 -103
- package/vitest.shims.d.ts +0 -1
|
@@ -0,0 +1,1263 @@
|
|
|
1
|
+
import { jsx as C, jsxs as Ae } from "react/jsx-runtime";
|
|
2
|
+
import { c as jt } from "../../clsx-OuTLNxxd.js";
|
|
3
|
+
import * as n from "react";
|
|
4
|
+
import { textify as $t } from "../../-utils.js";
|
|
5
|
+
import { Icon as xt } from "../icon/index.js";
|
|
6
|
+
import { View as Yt } from "../view/index.js";
|
|
7
|
+
import { c as E, l as p, d as Xt, e as Kt, S as Gt, i as Jt, f as Zt, p as Rt, t as Qt } from "../../transitions.module-CWX8e5cx.js";
|
|
8
|
+
import { v as en } from "../../visuallyHidden-CpJ-mhai.js";
|
|
9
|
+
import { b as gt, a as tn, m as St, c as It, u as Re } from "../../useRenderElement-DwToLA61.js";
|
|
10
|
+
import { u as ht } from "../../useControlled-Du4sJyMj.js";
|
|
11
|
+
import { u as fe } from "../../useIsoLayoutEffect-CIDbvm3Q.js";
|
|
12
|
+
import { u as ye } from "../../useStableCallback-CkTrVkNX.js";
|
|
13
|
+
import { u as ct } from "../../useValueAsRef-HURLzret.js";
|
|
14
|
+
import { f as Ke } from "../../formatErrorMessage-BqPuTBN-.js";
|
|
15
|
+
import { c as nn, a as vt, u as Et, b as on, f as rn } from "../../LabelableContext-BMvjVwor.js";
|
|
16
|
+
import { u as sn } from "../../useLabelableId-Ci_jDvmv.js";
|
|
17
|
+
import { u as wt } from "../../useTransitionStatus-CUfcuGAV.js";
|
|
18
|
+
import { c as xe, n as Mt, f as ln, v as cn, w as an, x as tt } from "../../createBaseUIEventDetails-D8M2Yl-a.js";
|
|
19
|
+
import { a as at, t as At } from "../../useOpenChangeComplete-Dse9kY9E.js";
|
|
20
|
+
import { u as un } from "../../useValueChanged-DL757-yD.js";
|
|
21
|
+
import { u as dn, b as fn, a as pn, I as mn, F as gn } from "../../InternalBackdrop-jYAiOJ8v.js";
|
|
22
|
+
import { u as hn, a as bn, g as yn } from "../../getDisabledMountTransitionStyles-YfHPge6T.js";
|
|
23
|
+
import { u as xn, a as Rn } from "../../useTypeahead-D85V2IUx.js";
|
|
24
|
+
import { o as rt } from "../../owner-rKN292Q9.js";
|
|
25
|
+
import { u as _e } from "../../useTimeout-CflX-kz3.js";
|
|
26
|
+
import { u as Tt } from "../../useButton-DfIwsdb8.js";
|
|
27
|
+
import { g as Sn, f as bt } from "../../element-CZEOj04G.js";
|
|
28
|
+
import { h as In, m as vn } from "../../FloatingPortal-tWyuKRSN.js";
|
|
29
|
+
import { i as En } from "../../inertValue-BCYGsdmf.js";
|
|
30
|
+
import { C as wn, u as Mn, I as An } from "../../useCompositeListItem-OkcAim_1.js";
|
|
31
|
+
import * as Tn from "react-dom";
|
|
32
|
+
import { d as Vn } from "../../detectBrowser-I-s3yzIE.js";
|
|
33
|
+
import { u as Cn } from "../../useAnimationFrame-451ugS_6.js";
|
|
34
|
+
import { u as Nn } from "../../ToolbarRootContext-CvvL0Tk1.js";
|
|
35
|
+
import { C as _n } from "../../composite-C9L5QmZL.js";
|
|
36
|
+
import { d as yt } from "../../floating-ui.utils.dom-C7FS5id0.js";
|
|
37
|
+
import '../../index33.css';function Pn(e) {
|
|
38
|
+
const t = n.useRef(!0);
|
|
39
|
+
t.current && (t.current = !1, e());
|
|
40
|
+
}
|
|
41
|
+
const On = (e, t) => Object.is(e, t);
|
|
42
|
+
function Oe(e, t, o) {
|
|
43
|
+
return e == null || t == null ? Object.is(e, t) : o(e, t);
|
|
44
|
+
}
|
|
45
|
+
function nt(e, t, o) {
|
|
46
|
+
return !e || e.length === 0 ? !1 : e.some((s) => s === void 0 ? !1 : Oe(s, t, o));
|
|
47
|
+
}
|
|
48
|
+
function st(e, t, o) {
|
|
49
|
+
return !e || e.length === 0 ? -1 : e.findIndex((s) => s === void 0 ? !1 : Oe(s, t, o));
|
|
50
|
+
}
|
|
51
|
+
function Dn(e, t, o) {
|
|
52
|
+
return e.filter((s) => !Oe(s, t, o));
|
|
53
|
+
}
|
|
54
|
+
function it(e) {
|
|
55
|
+
if (e == null)
|
|
56
|
+
return "";
|
|
57
|
+
if (typeof e == "string")
|
|
58
|
+
return e;
|
|
59
|
+
try {
|
|
60
|
+
return JSON.stringify(e);
|
|
61
|
+
} catch {
|
|
62
|
+
return String(e);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
function Hn(e) {
|
|
66
|
+
return e != null && e.length > 0 && typeof e[0] == "object" && e[0] != null && "items" in e[0];
|
|
67
|
+
}
|
|
68
|
+
function ke(e, t) {
|
|
69
|
+
if (t && e != null)
|
|
70
|
+
return t(e) ?? "";
|
|
71
|
+
if (e && typeof e == "object") {
|
|
72
|
+
if ("label" in e && e.label != null)
|
|
73
|
+
return String(e.label);
|
|
74
|
+
if ("value" in e)
|
|
75
|
+
return String(e.value);
|
|
76
|
+
}
|
|
77
|
+
return it(e);
|
|
78
|
+
}
|
|
79
|
+
function Ne(e, t) {
|
|
80
|
+
return t && e != null ? t(e) ?? "" : e && typeof e == "object" && "value" in e && "label" in e ? it(e.value) : it(e);
|
|
81
|
+
}
|
|
82
|
+
function Fn(e, t, o) {
|
|
83
|
+
if (o && e != null)
|
|
84
|
+
return o(e);
|
|
85
|
+
if (e && typeof e == "object" && "label" in e && e.label != null)
|
|
86
|
+
return e.label;
|
|
87
|
+
if (t && !Array.isArray(t))
|
|
88
|
+
return t[e] ?? ke(e, o);
|
|
89
|
+
if (Array.isArray(t)) {
|
|
90
|
+
const s = Hn(t) ? t.flatMap((r) => r.items) : t;
|
|
91
|
+
if (e == null) {
|
|
92
|
+
const r = s.find((i) => i.value == null);
|
|
93
|
+
return r && r.label != null ? r.label : ke(e, o);
|
|
94
|
+
}
|
|
95
|
+
if (typeof e != "object") {
|
|
96
|
+
const r = s.find((i) => i && i.value === e);
|
|
97
|
+
return r && r.label != null ? r.label : ke(e, o);
|
|
98
|
+
}
|
|
99
|
+
if ("value" in e) {
|
|
100
|
+
const r = s.find((i) => i && i.value === e.value);
|
|
101
|
+
if (r && r.label != null)
|
|
102
|
+
return r.label;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return ke(e, o);
|
|
106
|
+
}
|
|
107
|
+
function Bn(e, t) {
|
|
108
|
+
return !Array.isArray(e) || e.length === 0 ? "" : e.map((o) => ke(o, t)).join(", ");
|
|
109
|
+
}
|
|
110
|
+
function Un(e) {
|
|
111
|
+
const t = e.getBoundingClientRect();
|
|
112
|
+
if (process.env.NODE_ENV === "test")
|
|
113
|
+
return t;
|
|
114
|
+
const o = window.getComputedStyle(e, "::before"), s = window.getComputedStyle(e, "::after");
|
|
115
|
+
if (!(o.content !== "none" || s.content !== "none"))
|
|
116
|
+
return t;
|
|
117
|
+
const i = parseFloat(o.width) || 0, m = parseFloat(o.height) || 0, d = parseFloat(s.width) || 0, F = parseFloat(s.height) || 0, w = Math.max(t.width, i, d), v = Math.max(t.height, m, F), R = w - t.width, b = v - t.height;
|
|
118
|
+
return {
|
|
119
|
+
left: t.left - R / 2,
|
|
120
|
+
right: t.right + R / 2,
|
|
121
|
+
top: t.top - b / 2,
|
|
122
|
+
bottom: t.bottom + b / 2
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
const $e = "base-ui-disable-scrollbar", lt = {
|
|
126
|
+
className: $e,
|
|
127
|
+
element: /* @__PURE__ */ C("style", {
|
|
128
|
+
href: $e,
|
|
129
|
+
precedence: "base-ui:low",
|
|
130
|
+
children: `.${$e}{scrollbar-width:none}.${$e}::-webkit-scrollbar{display:none}`
|
|
131
|
+
})
|
|
132
|
+
}, ut = /* @__PURE__ */ n.createContext(null);
|
|
133
|
+
process.env.NODE_ENV !== "production" && (ut.displayName = "SelectRootContext");
|
|
134
|
+
const dt = /* @__PURE__ */ n.createContext(null);
|
|
135
|
+
process.env.NODE_ENV !== "production" && (dt.displayName = "SelectFloatingContext");
|
|
136
|
+
function Se() {
|
|
137
|
+
const e = n.useContext(ut);
|
|
138
|
+
if (e === null)
|
|
139
|
+
throw new Error(process.env.NODE_ENV !== "production" ? "Base UI: SelectRootContext is missing. Select parts must be placed within <Select.Root>." : Ke(60));
|
|
140
|
+
return e;
|
|
141
|
+
}
|
|
142
|
+
function Vt() {
|
|
143
|
+
const e = n.useContext(dt);
|
|
144
|
+
if (e === null)
|
|
145
|
+
throw new Error(process.env.NODE_ENV !== "production" ? "Base UI: SelectFloatingContext is missing. Select parts must be placed within <Select.Root>." : Ke(61));
|
|
146
|
+
return e;
|
|
147
|
+
}
|
|
148
|
+
const a = {
|
|
149
|
+
id: E((e) => e.id),
|
|
150
|
+
modal: E((e) => e.modal),
|
|
151
|
+
multiple: E((e) => e.multiple),
|
|
152
|
+
items: E((e) => e.items),
|
|
153
|
+
itemToStringLabel: E((e) => e.itemToStringLabel),
|
|
154
|
+
itemToStringValue: E((e) => e.itemToStringValue),
|
|
155
|
+
isItemEqualToValue: E((e) => e.isItemEqualToValue),
|
|
156
|
+
value: E((e) => e.value),
|
|
157
|
+
open: E((e) => e.open),
|
|
158
|
+
mounted: E((e) => e.mounted),
|
|
159
|
+
forceMount: E((e) => e.forceMount),
|
|
160
|
+
transitionStatus: E((e) => e.transitionStatus),
|
|
161
|
+
openMethod: E((e) => e.openMethod),
|
|
162
|
+
activeIndex: E((e) => e.activeIndex),
|
|
163
|
+
selectedIndex: E((e) => e.selectedIndex),
|
|
164
|
+
isActive: E((e, t) => e.activeIndex === t),
|
|
165
|
+
isSelected: E((e, t, o) => {
|
|
166
|
+
const s = e.isItemEqualToValue, r = e.value;
|
|
167
|
+
return e.multiple ? Array.isArray(r) && r.some((i) => Oe(i, o, s)) : e.selectedIndex === t && e.selectedIndex !== null ? !0 : Oe(r, o, s);
|
|
168
|
+
}),
|
|
169
|
+
isSelectedByFocus: E((e, t) => e.selectedIndex === t),
|
|
170
|
+
popupProps: E((e) => e.popupProps),
|
|
171
|
+
triggerProps: E((e) => e.triggerProps),
|
|
172
|
+
triggerElement: E((e) => e.triggerElement),
|
|
173
|
+
positionerElement: E((e) => e.positionerElement),
|
|
174
|
+
listElement: E((e) => e.listElement),
|
|
175
|
+
scrollUpArrowVisible: E((e) => e.scrollUpArrowVisible),
|
|
176
|
+
scrollDownArrowVisible: E((e) => e.scrollDownArrowVisible),
|
|
177
|
+
hasScrollArrows: E((e) => e.hasScrollArrows),
|
|
178
|
+
serializedValue: E((e) => {
|
|
179
|
+
const {
|
|
180
|
+
multiple: t,
|
|
181
|
+
value: o,
|
|
182
|
+
itemToStringValue: s
|
|
183
|
+
} = e;
|
|
184
|
+
return t && Array.isArray(o) && o.length === 0 ? "" : Ne(o, s);
|
|
185
|
+
})
|
|
186
|
+
};
|
|
187
|
+
function Ln(e) {
|
|
188
|
+
const {
|
|
189
|
+
id: t,
|
|
190
|
+
value: o,
|
|
191
|
+
defaultValue: s = null,
|
|
192
|
+
onValueChange: r,
|
|
193
|
+
open: i,
|
|
194
|
+
defaultOpen: m = !1,
|
|
195
|
+
onOpenChange: d,
|
|
196
|
+
name: F,
|
|
197
|
+
disabled: w = !1,
|
|
198
|
+
readOnly: v = !1,
|
|
199
|
+
required: R = !1,
|
|
200
|
+
modal: b = !0,
|
|
201
|
+
actionsRef: q,
|
|
202
|
+
inputRef: M,
|
|
203
|
+
onOpenChangeComplete: U,
|
|
204
|
+
items: L,
|
|
205
|
+
multiple: I = !1,
|
|
206
|
+
itemToStringLabel: V,
|
|
207
|
+
itemToStringValue: f,
|
|
208
|
+
isItemEqualToValue: X = On,
|
|
209
|
+
highlightItemOnHover: se = !0,
|
|
210
|
+
children: ie
|
|
211
|
+
} = e, {
|
|
212
|
+
clearErrors: P
|
|
213
|
+
} = nn(), {
|
|
214
|
+
setDirty: N,
|
|
215
|
+
shouldValidateOnChange: ce,
|
|
216
|
+
validityData: j,
|
|
217
|
+
setFilled: S,
|
|
218
|
+
name: G,
|
|
219
|
+
disabled: $,
|
|
220
|
+
validation: y
|
|
221
|
+
} = vt(), {
|
|
222
|
+
controlId: l
|
|
223
|
+
} = Et(), A = sn({
|
|
224
|
+
id: t
|
|
225
|
+
}), B = $ || w, O = G ?? F, [u, K] = ht({
|
|
226
|
+
controlled: o,
|
|
227
|
+
default: I ? s ?? gt : s,
|
|
228
|
+
name: "Select",
|
|
229
|
+
state: "value"
|
|
230
|
+
}), [T, Q] = ht({
|
|
231
|
+
controlled: i,
|
|
232
|
+
default: m,
|
|
233
|
+
name: "Select",
|
|
234
|
+
state: "open"
|
|
235
|
+
}), ee = n.useRef([]), te = n.useRef([]), z = n.useRef(null), c = n.useRef(null), g = n.useRef(0), D = n.useRef(null), H = n.useRef([]), Z = n.useRef(!1), le = n.useRef(!1), ne = n.useRef(null), oe = n.useRef({
|
|
236
|
+
allowSelectedMouseUp: !1,
|
|
237
|
+
allowUnselectedMouseUp: !1
|
|
238
|
+
}), Ie = n.useRef(!1), {
|
|
239
|
+
mounted: re,
|
|
240
|
+
setMounted: _,
|
|
241
|
+
transitionStatus: ae
|
|
242
|
+
} = wt(T), {
|
|
243
|
+
openMethod: pe,
|
|
244
|
+
triggerProps: k,
|
|
245
|
+
reset: W
|
|
246
|
+
} = dn(T), h = tn(() => new Gt({
|
|
247
|
+
id: A,
|
|
248
|
+
modal: b,
|
|
249
|
+
multiple: I,
|
|
250
|
+
itemToStringLabel: V,
|
|
251
|
+
itemToStringValue: f,
|
|
252
|
+
isItemEqualToValue: X,
|
|
253
|
+
value: u,
|
|
254
|
+
open: T,
|
|
255
|
+
mounted: re,
|
|
256
|
+
transitionStatus: ae,
|
|
257
|
+
items: L,
|
|
258
|
+
forceMount: !1,
|
|
259
|
+
openMethod: null,
|
|
260
|
+
activeIndex: null,
|
|
261
|
+
selectedIndex: null,
|
|
262
|
+
popupProps: {},
|
|
263
|
+
triggerProps: {},
|
|
264
|
+
triggerElement: null,
|
|
265
|
+
positionerElement: null,
|
|
266
|
+
listElement: null,
|
|
267
|
+
scrollUpArrowVisible: !1,
|
|
268
|
+
scrollDownArrowVisible: !1,
|
|
269
|
+
hasScrollArrows: !1
|
|
270
|
+
})).current, ue = p(h, a.activeIndex), me = p(h, a.selectedIndex), ge = p(h, a.triggerElement), J = p(h, a.positionerElement), De = n.useMemo(() => I && Array.isArray(u) && u.length === 0 ? "" : Ne(u, f), [I, u, f]), Ge = n.useMemo(() => I && Array.isArray(u) ? u.map((x) => Ne(x, f)) : Ne(u, f), [I, u, f]), We = ct(h.state.triggerElement);
|
|
271
|
+
on({
|
|
272
|
+
id: A,
|
|
273
|
+
commit: y.commit,
|
|
274
|
+
value: u,
|
|
275
|
+
controlRef: We,
|
|
276
|
+
name: O,
|
|
277
|
+
getValue: () => Ge
|
|
278
|
+
});
|
|
279
|
+
const He = n.useRef(u);
|
|
280
|
+
fe(() => {
|
|
281
|
+
u !== He.current && h.set("forceMount", !0);
|
|
282
|
+
}, [h, u]), fe(() => {
|
|
283
|
+
S(u !== null);
|
|
284
|
+
}, [u, S]), fe(function() {
|
|
285
|
+
if (T)
|
|
286
|
+
return;
|
|
287
|
+
const Y = H.current;
|
|
288
|
+
if (I) {
|
|
289
|
+
const we = Array.isArray(u) ? u : [];
|
|
290
|
+
if (we.length === 0) {
|
|
291
|
+
h.set("selectedIndex", null);
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
const be = we[we.length - 1], je = st(Y, be, X);
|
|
295
|
+
h.set("selectedIndex", je === -1 ? null : je);
|
|
296
|
+
return;
|
|
297
|
+
}
|
|
298
|
+
const Ee = st(Y, u, X);
|
|
299
|
+
h.set("selectedIndex", Ee === -1 ? null : Ee);
|
|
300
|
+
}, [I, T, u, H, X, h]), un(u, () => {
|
|
301
|
+
P(O), N(u !== j.initialValue), ce() ? y.commit(u) : y.commit(u, !0);
|
|
302
|
+
});
|
|
303
|
+
const Te = ye((x, Y) => {
|
|
304
|
+
if (d?.(x, Y), !Y.isCanceled && (Q(x), !x && h.state.activeIndex !== null)) {
|
|
305
|
+
const Ee = ee.current[h.state.activeIndex];
|
|
306
|
+
queueMicrotask(() => {
|
|
307
|
+
Ee?.setAttribute("tabindex", "-1");
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
}), Ve = ye(() => {
|
|
311
|
+
_(!1), h.set("activeIndex", null), W(), U?.(!1);
|
|
312
|
+
});
|
|
313
|
+
at({
|
|
314
|
+
enabled: !q,
|
|
315
|
+
open: T,
|
|
316
|
+
ref: z,
|
|
317
|
+
onComplete() {
|
|
318
|
+
T || Ve();
|
|
319
|
+
}
|
|
320
|
+
}), n.useImperativeHandle(q, () => ({
|
|
321
|
+
unmount: Ve
|
|
322
|
+
}), [Ve]);
|
|
323
|
+
const ve = ye((x, Y) => {
|
|
324
|
+
r?.(x, Y), !Y.isCanceled && K(x);
|
|
325
|
+
}), de = ye(() => {
|
|
326
|
+
const x = h.state.listElement || z.current;
|
|
327
|
+
if (!x)
|
|
328
|
+
return;
|
|
329
|
+
const Y = x.scrollTop, Ee = x.scrollTop + x.clientHeight, we = Y > 1, be = Ee < x.scrollHeight - 1;
|
|
330
|
+
h.state.scrollUpArrowVisible !== we && h.set("scrollUpArrowVisible", we), h.state.scrollDownArrowVisible !== be && h.set("scrollDownArrowVisible", be);
|
|
331
|
+
}), he = hn({
|
|
332
|
+
open: T,
|
|
333
|
+
onOpenChange: Te,
|
|
334
|
+
elements: {
|
|
335
|
+
reference: ge,
|
|
336
|
+
floating: J
|
|
337
|
+
}
|
|
338
|
+
}), Fe = fn(he, {
|
|
339
|
+
enabled: !v && !B,
|
|
340
|
+
event: "mousedown"
|
|
341
|
+
}), ze = Xt(he, {
|
|
342
|
+
bubbles: !1
|
|
343
|
+
}), Je = xn(he, {
|
|
344
|
+
enabled: !v && !B,
|
|
345
|
+
listRef: ee,
|
|
346
|
+
activeIndex: ue,
|
|
347
|
+
selectedIndex: me,
|
|
348
|
+
disabledIndices: gt,
|
|
349
|
+
onNavigate(x) {
|
|
350
|
+
x === null && !T || h.set("activeIndex", x);
|
|
351
|
+
},
|
|
352
|
+
// Implement our own listeners since `onPointerLeave` on each option fires while scrolling with
|
|
353
|
+
// the `alignItemWithTrigger=true`, causing a performance issue on Chrome.
|
|
354
|
+
focusItemOnHover: !1
|
|
355
|
+
}), Ze = Rn(he, {
|
|
356
|
+
enabled: !v && !B && (T || !I),
|
|
357
|
+
listRef: te,
|
|
358
|
+
activeIndex: ue,
|
|
359
|
+
selectedIndex: me,
|
|
360
|
+
onMatch(x) {
|
|
361
|
+
T ? h.set("activeIndex", x) : ve(H.current[x], xe("none"));
|
|
362
|
+
},
|
|
363
|
+
onTypingChange(x) {
|
|
364
|
+
Z.current = x;
|
|
365
|
+
}
|
|
366
|
+
}), {
|
|
367
|
+
getReferenceProps: Be,
|
|
368
|
+
getFloatingProps: Ce,
|
|
369
|
+
getItemProps: qe
|
|
370
|
+
} = Kt([Fe, ze, Je, Ze]), Ue = n.useMemo(() => St(Be(), k), [Be, k]);
|
|
371
|
+
Pn(() => {
|
|
372
|
+
h.update({
|
|
373
|
+
popupProps: Ce(),
|
|
374
|
+
triggerProps: Ue
|
|
375
|
+
});
|
|
376
|
+
}), fe(() => {
|
|
377
|
+
h.update({
|
|
378
|
+
id: A,
|
|
379
|
+
modal: b,
|
|
380
|
+
multiple: I,
|
|
381
|
+
value: u,
|
|
382
|
+
open: T,
|
|
383
|
+
mounted: re,
|
|
384
|
+
transitionStatus: ae,
|
|
385
|
+
popupProps: Ce(),
|
|
386
|
+
triggerProps: Ue,
|
|
387
|
+
items: L,
|
|
388
|
+
itemToStringLabel: V,
|
|
389
|
+
itemToStringValue: f,
|
|
390
|
+
isItemEqualToValue: X,
|
|
391
|
+
openMethod: pe
|
|
392
|
+
});
|
|
393
|
+
}, [h, A, b, I, u, T, re, ae, Ce, Ue, L, V, f, X, pe]);
|
|
394
|
+
const Me = n.useMemo(() => ({
|
|
395
|
+
store: h,
|
|
396
|
+
name: O,
|
|
397
|
+
required: R,
|
|
398
|
+
disabled: B,
|
|
399
|
+
readOnly: v,
|
|
400
|
+
multiple: I,
|
|
401
|
+
itemToStringLabel: V,
|
|
402
|
+
itemToStringValue: f,
|
|
403
|
+
highlightItemOnHover: se,
|
|
404
|
+
setValue: ve,
|
|
405
|
+
setOpen: Te,
|
|
406
|
+
listRef: ee,
|
|
407
|
+
popupRef: z,
|
|
408
|
+
scrollHandlerRef: c,
|
|
409
|
+
handleScrollArrowVisibility: de,
|
|
410
|
+
scrollArrowsMountedCountRef: g,
|
|
411
|
+
getItemProps: qe,
|
|
412
|
+
events: he.context.events,
|
|
413
|
+
valueRef: D,
|
|
414
|
+
valuesRef: H,
|
|
415
|
+
labelsRef: te,
|
|
416
|
+
typingRef: Z,
|
|
417
|
+
selectionRef: oe,
|
|
418
|
+
selectedItemTextRef: ne,
|
|
419
|
+
validation: y,
|
|
420
|
+
onOpenChangeComplete: U,
|
|
421
|
+
keyboardActiveRef: le,
|
|
422
|
+
alignItemWithTriggerActiveRef: Ie,
|
|
423
|
+
initialValueRef: He
|
|
424
|
+
}), [h, O, R, B, v, I, V, f, se, ve, Te, qe, he.context.events, y, U, de]), Le = It(M, y.inputRef), Qe = I && Array.isArray(u) && u.length > 0, et = n.useMemo(() => !I || !Array.isArray(u) || !O ? null : u.map((x) => {
|
|
425
|
+
const Y = Ne(x, f);
|
|
426
|
+
return /* @__PURE__ */ C("input", {
|
|
427
|
+
type: "hidden",
|
|
428
|
+
name: O,
|
|
429
|
+
value: Y
|
|
430
|
+
}, Y);
|
|
431
|
+
}), [I, u, O, f]);
|
|
432
|
+
return /* @__PURE__ */ C(ut.Provider, {
|
|
433
|
+
value: Me,
|
|
434
|
+
children: /* @__PURE__ */ Ae(dt.Provider, {
|
|
435
|
+
value: he,
|
|
436
|
+
children: [ie, /* @__PURE__ */ C("input", {
|
|
437
|
+
...y.getInputValidationProps({
|
|
438
|
+
onFocus() {
|
|
439
|
+
h.state.triggerElement?.focus();
|
|
440
|
+
},
|
|
441
|
+
// Handle browser autofill.
|
|
442
|
+
onChange(x) {
|
|
443
|
+
if (x.nativeEvent.defaultPrevented)
|
|
444
|
+
return;
|
|
445
|
+
const Y = x.target.value, Ee = xe(Mt, x.nativeEvent);
|
|
446
|
+
function we() {
|
|
447
|
+
if (I)
|
|
448
|
+
return;
|
|
449
|
+
const be = H.current.find((je) => Ne(je, f).toLowerCase() === Y.toLowerCase());
|
|
450
|
+
be != null && (N(be !== j.initialValue), ve(be, Ee), ce() && y.commit(be));
|
|
451
|
+
}
|
|
452
|
+
h.set("forceMount", !0), queueMicrotask(we);
|
|
453
|
+
}
|
|
454
|
+
}),
|
|
455
|
+
id: t || l || void 0,
|
|
456
|
+
name: I ? void 0 : O,
|
|
457
|
+
value: De,
|
|
458
|
+
disabled: B,
|
|
459
|
+
required: R && !Qe,
|
|
460
|
+
readOnly: v,
|
|
461
|
+
ref: Le,
|
|
462
|
+
style: en,
|
|
463
|
+
tabIndex: -1,
|
|
464
|
+
"aria-hidden": !0
|
|
465
|
+
}), et]
|
|
466
|
+
})
|
|
467
|
+
});
|
|
468
|
+
}
|
|
469
|
+
const Ye = 2, kn = {
|
|
470
|
+
...Jt,
|
|
471
|
+
...rn,
|
|
472
|
+
value: () => null
|
|
473
|
+
}, Ct = /* @__PURE__ */ n.forwardRef(function(t, o) {
|
|
474
|
+
const {
|
|
475
|
+
render: s,
|
|
476
|
+
className: r,
|
|
477
|
+
disabled: i = !1,
|
|
478
|
+
nativeButton: m = !0,
|
|
479
|
+
...d
|
|
480
|
+
} = t, {
|
|
481
|
+
setTouched: F,
|
|
482
|
+
setFocused: w,
|
|
483
|
+
validationMode: v,
|
|
484
|
+
state: R,
|
|
485
|
+
disabled: b
|
|
486
|
+
} = vt(), {
|
|
487
|
+
labelId: q
|
|
488
|
+
} = Et(), {
|
|
489
|
+
store: M,
|
|
490
|
+
setOpen: U,
|
|
491
|
+
selectionRef: L,
|
|
492
|
+
validation: I,
|
|
493
|
+
readOnly: V,
|
|
494
|
+
alignItemWithTriggerActiveRef: f,
|
|
495
|
+
disabled: X,
|
|
496
|
+
keyboardActiveRef: se
|
|
497
|
+
} = Se(), ie = b || X || i, P = p(M, a.open), N = p(M, a.value), ce = p(M, a.triggerProps), j = p(M, a.positionerElement), S = p(M, a.listElement), G = p(M, a.serializedValue), $ = ct(j), y = n.useRef(null), l = _e(), A = _e(), {
|
|
498
|
+
getButtonProps: B,
|
|
499
|
+
buttonRef: O
|
|
500
|
+
} = Tt({
|
|
501
|
+
disabled: ie,
|
|
502
|
+
native: m
|
|
503
|
+
}), u = ye((c) => {
|
|
504
|
+
M.set("triggerElement", c);
|
|
505
|
+
}), K = It(o, y, O, u), T = _e(), Q = _e();
|
|
506
|
+
n.useEffect(() => {
|
|
507
|
+
if (P)
|
|
508
|
+
return Q.start(200, () => {
|
|
509
|
+
L.current.allowUnselectedMouseUp = !0, T.start(200, () => {
|
|
510
|
+
L.current.allowSelectedMouseUp = !0;
|
|
511
|
+
});
|
|
512
|
+
}), () => {
|
|
513
|
+
T.clear(), Q.clear();
|
|
514
|
+
};
|
|
515
|
+
L.current = {
|
|
516
|
+
allowSelectedMouseUp: !1,
|
|
517
|
+
allowUnselectedMouseUp: !1
|
|
518
|
+
}, A.clear();
|
|
519
|
+
}, [P, L, A, T, Q]);
|
|
520
|
+
const ee = n.useMemo(() => S?.id ?? Sn(j)?.id, [S, j]), te = St(ce, {
|
|
521
|
+
role: "combobox",
|
|
522
|
+
"aria-expanded": P ? "true" : "false",
|
|
523
|
+
"aria-haspopup": "listbox",
|
|
524
|
+
"aria-controls": P ? ee : void 0,
|
|
525
|
+
"aria-labelledby": q,
|
|
526
|
+
"aria-readonly": V || void 0,
|
|
527
|
+
tabIndex: ie ? -1 : 0,
|
|
528
|
+
ref: K,
|
|
529
|
+
onFocus(c) {
|
|
530
|
+
w(!0), P && f.current && U(!1, xe(ln, c.nativeEvent)), l.start(0, () => {
|
|
531
|
+
M.set("forceMount", !0);
|
|
532
|
+
});
|
|
533
|
+
},
|
|
534
|
+
onBlur() {
|
|
535
|
+
F(!0), w(!1), v === "onBlur" && I.commit(N);
|
|
536
|
+
},
|
|
537
|
+
onPointerMove() {
|
|
538
|
+
se.current = !1;
|
|
539
|
+
},
|
|
540
|
+
onKeyDown() {
|
|
541
|
+
se.current = !0;
|
|
542
|
+
},
|
|
543
|
+
onMouseDown(c) {
|
|
544
|
+
if (P)
|
|
545
|
+
return;
|
|
546
|
+
const g = rt(c.currentTarget);
|
|
547
|
+
function D(H) {
|
|
548
|
+
if (!y.current)
|
|
549
|
+
return;
|
|
550
|
+
const Z = H.target;
|
|
551
|
+
if (bt(y.current, Z) || bt($.current, Z) || Z === y.current)
|
|
552
|
+
return;
|
|
553
|
+
const le = Un(y.current);
|
|
554
|
+
H.clientX >= le.left - Ye && H.clientX <= le.right + Ye && H.clientY >= le.top - Ye && H.clientY <= le.bottom + Ye || U(!1, xe(cn, H));
|
|
555
|
+
}
|
|
556
|
+
A.start(0, () => {
|
|
557
|
+
g.addEventListener("mouseup", D, {
|
|
558
|
+
once: !0
|
|
559
|
+
});
|
|
560
|
+
});
|
|
561
|
+
}
|
|
562
|
+
}, I.getValidationProps, d, B);
|
|
563
|
+
te.role = "combobox";
|
|
564
|
+
const z = n.useMemo(() => ({
|
|
565
|
+
...R,
|
|
566
|
+
open: P,
|
|
567
|
+
disabled: ie,
|
|
568
|
+
value: N,
|
|
569
|
+
readOnly: V,
|
|
570
|
+
placeholder: !G
|
|
571
|
+
}), [R, P, ie, N, V, G]);
|
|
572
|
+
return Re("button", t, {
|
|
573
|
+
ref: [o, y],
|
|
574
|
+
state: z,
|
|
575
|
+
stateAttributesMapping: kn,
|
|
576
|
+
props: te
|
|
577
|
+
});
|
|
578
|
+
});
|
|
579
|
+
process.env.NODE_ENV !== "production" && (Ct.displayName = "SelectTrigger");
|
|
580
|
+
const Wn = {
|
|
581
|
+
value: () => null
|
|
582
|
+
}, Nt = /* @__PURE__ */ n.forwardRef(function(t, o) {
|
|
583
|
+
const {
|
|
584
|
+
className: s,
|
|
585
|
+
render: r,
|
|
586
|
+
children: i,
|
|
587
|
+
...m
|
|
588
|
+
} = t, {
|
|
589
|
+
store: d,
|
|
590
|
+
valueRef: F
|
|
591
|
+
} = Se(), w = p(d, a.value), v = p(d, a.items), R = p(d, a.itemToStringLabel), b = p(d, a.serializedValue), q = n.useMemo(() => ({
|
|
592
|
+
value: w,
|
|
593
|
+
placeholder: !b
|
|
594
|
+
}), [w, b]), M = typeof i == "function" ? i(w) : i ?? (Array.isArray(w) ? Bn(w, R) : Fn(w, v, R));
|
|
595
|
+
return Re("span", t, {
|
|
596
|
+
state: q,
|
|
597
|
+
ref: [o, F],
|
|
598
|
+
props: [{
|
|
599
|
+
children: M
|
|
600
|
+
}, m],
|
|
601
|
+
stateAttributesMapping: Wn
|
|
602
|
+
});
|
|
603
|
+
});
|
|
604
|
+
process.env.NODE_ENV !== "production" && (Nt.displayName = "SelectValue");
|
|
605
|
+
const _t = /* @__PURE__ */ n.forwardRef(function(t, o) {
|
|
606
|
+
const {
|
|
607
|
+
className: s,
|
|
608
|
+
render: r,
|
|
609
|
+
...i
|
|
610
|
+
} = t, {
|
|
611
|
+
store: m
|
|
612
|
+
} = Se(), d = p(m, a.open), F = n.useMemo(() => ({
|
|
613
|
+
open: d
|
|
614
|
+
}), [d]);
|
|
615
|
+
return Re("span", t, {
|
|
616
|
+
state: F,
|
|
617
|
+
ref: o,
|
|
618
|
+
props: [{
|
|
619
|
+
"aria-hidden": !0,
|
|
620
|
+
children: "▼"
|
|
621
|
+
}, i],
|
|
622
|
+
stateAttributesMapping: Zt
|
|
623
|
+
});
|
|
624
|
+
});
|
|
625
|
+
process.env.NODE_ENV !== "production" && (_t.displayName = "SelectIcon");
|
|
626
|
+
const Pt = /* @__PURE__ */ n.createContext(void 0);
|
|
627
|
+
process.env.NODE_ENV !== "production" && (Pt.displayName = "SelectPortalContext");
|
|
628
|
+
const Ot = /* @__PURE__ */ n.forwardRef(function(t, o) {
|
|
629
|
+
const {
|
|
630
|
+
store: s
|
|
631
|
+
} = Se(), r = p(s, a.mounted), i = p(s, a.forceMount);
|
|
632
|
+
return r || i ? /* @__PURE__ */ C(Pt.Provider, {
|
|
633
|
+
value: !0,
|
|
634
|
+
children: /* @__PURE__ */ C(In, {
|
|
635
|
+
ref: o,
|
|
636
|
+
...t
|
|
637
|
+
})
|
|
638
|
+
}) : null;
|
|
639
|
+
});
|
|
640
|
+
process.env.NODE_ENV !== "production" && (Ot.displayName = "SelectPortal");
|
|
641
|
+
const ft = /* @__PURE__ */ n.createContext(void 0);
|
|
642
|
+
process.env.NODE_ENV !== "production" && (ft.displayName = "SelectPositionerContext");
|
|
643
|
+
function Dt() {
|
|
644
|
+
const e = n.useContext(ft);
|
|
645
|
+
if (!e)
|
|
646
|
+
throw new Error(process.env.NODE_ENV !== "production" ? "Base UI: SelectPositionerContext is missing. SelectPositioner parts must be placed within <Select.Positioner>." : Ke(59));
|
|
647
|
+
return e;
|
|
648
|
+
}
|
|
649
|
+
function Xe(e, t) {
|
|
650
|
+
e && Object.assign(e.style, t);
|
|
651
|
+
}
|
|
652
|
+
const Ht = {
|
|
653
|
+
position: "relative",
|
|
654
|
+
maxHeight: "100%",
|
|
655
|
+
overflowX: "hidden",
|
|
656
|
+
overflowY: "auto"
|
|
657
|
+
}, zn = {
|
|
658
|
+
position: "fixed"
|
|
659
|
+
}, Ft = /* @__PURE__ */ n.forwardRef(function(t, o) {
|
|
660
|
+
const {
|
|
661
|
+
anchor: s,
|
|
662
|
+
positionMethod: r = "absolute",
|
|
663
|
+
className: i,
|
|
664
|
+
render: m,
|
|
665
|
+
side: d = "bottom",
|
|
666
|
+
align: F = "center",
|
|
667
|
+
sideOffset: w = 0,
|
|
668
|
+
alignOffset: v = 0,
|
|
669
|
+
collisionBoundary: R = "clipping-ancestors",
|
|
670
|
+
collisionPadding: b,
|
|
671
|
+
arrowPadding: q = 5,
|
|
672
|
+
sticky: M = !1,
|
|
673
|
+
disableAnchorTracking: U,
|
|
674
|
+
alignItemWithTrigger: L = !0,
|
|
675
|
+
collisionAvoidance: I = vn,
|
|
676
|
+
...V
|
|
677
|
+
} = t, {
|
|
678
|
+
store: f,
|
|
679
|
+
listRef: X,
|
|
680
|
+
labelsRef: se,
|
|
681
|
+
alignItemWithTriggerActiveRef: ie,
|
|
682
|
+
selectedItemTextRef: P,
|
|
683
|
+
valuesRef: N,
|
|
684
|
+
initialValueRef: ce,
|
|
685
|
+
popupRef: j,
|
|
686
|
+
setValue: S
|
|
687
|
+
} = Se(), G = Vt(), $ = p(f, a.open), y = p(f, a.mounted), l = p(f, a.modal), A = p(f, a.value), B = p(f, a.openMethod), O = p(f, a.positionerElement), u = p(f, a.triggerElement), K = p(f, a.isItemEqualToValue), T = n.useRef(null), Q = n.useRef(null), [ee, te] = n.useState(L), z = y && ee && B !== "touch";
|
|
688
|
+
!y && ee !== L && te(L), fe(() => {
|
|
689
|
+
y || (a.scrollUpArrowVisible(f.state) && f.set("scrollUpArrowVisible", !1), a.scrollDownArrowVisible(f.state) && f.set("scrollDownArrowVisible", !1));
|
|
690
|
+
}, [f, y]), n.useImperativeHandle(ie, () => z), pn((z || l) && $ && B !== "touch", u);
|
|
691
|
+
const c = bn({
|
|
692
|
+
anchor: s,
|
|
693
|
+
floatingRootContext: G,
|
|
694
|
+
positionMethod: r,
|
|
695
|
+
mounted: y,
|
|
696
|
+
side: d,
|
|
697
|
+
sideOffset: w,
|
|
698
|
+
align: F,
|
|
699
|
+
alignOffset: v,
|
|
700
|
+
arrowPadding: q,
|
|
701
|
+
collisionBoundary: R,
|
|
702
|
+
collisionPadding: b,
|
|
703
|
+
sticky: M,
|
|
704
|
+
disableAnchorTracking: U ?? z,
|
|
705
|
+
collisionAvoidance: I,
|
|
706
|
+
keepMounted: !0
|
|
707
|
+
}), g = z ? "none" : c.side, D = z ? zn : c.positionerStyles, H = n.useMemo(() => {
|
|
708
|
+
const _ = {};
|
|
709
|
+
return $ || (_.pointerEvents = "none"), {
|
|
710
|
+
role: "presentation",
|
|
711
|
+
hidden: !y,
|
|
712
|
+
style: {
|
|
713
|
+
...D,
|
|
714
|
+
..._
|
|
715
|
+
}
|
|
716
|
+
};
|
|
717
|
+
}, [$, y, D]), Z = n.useMemo(() => ({
|
|
718
|
+
open: $,
|
|
719
|
+
side: g,
|
|
720
|
+
align: c.align,
|
|
721
|
+
anchorHidden: c.anchorHidden
|
|
722
|
+
}), [$, g, c.align, c.anchorHidden]), le = ye((_) => {
|
|
723
|
+
f.set("positionerElement", _);
|
|
724
|
+
}), ne = Re("div", t, {
|
|
725
|
+
ref: [o, le],
|
|
726
|
+
state: Z,
|
|
727
|
+
stateAttributesMapping: Rt,
|
|
728
|
+
props: [H, V]
|
|
729
|
+
}), oe = n.useRef(0), Ie = ye((_) => {
|
|
730
|
+
if (_.size === 0 && oe.current === 0 || N.current.length === 0)
|
|
731
|
+
return;
|
|
732
|
+
const ae = oe.current;
|
|
733
|
+
if (oe.current = _.size, _.size === ae)
|
|
734
|
+
return;
|
|
735
|
+
const pe = xe(Mt);
|
|
736
|
+
if (ae !== 0 && !f.state.multiple && A !== null && st(N.current, A, K) === -1) {
|
|
737
|
+
const W = ce.current, ue = W != null && nt(N.current, W, K) ? W : null;
|
|
738
|
+
S(ue, pe), ue === null && (f.set("selectedIndex", null), P.current = null);
|
|
739
|
+
}
|
|
740
|
+
if (ae !== 0 && f.state.multiple && Array.isArray(A)) {
|
|
741
|
+
const k = A.filter((W) => nt(N.current, W, K));
|
|
742
|
+
(k.length !== A.length || k.some((W) => !nt(A, W, K))) && (S(k, pe), k.length === 0 && (f.set("selectedIndex", null), P.current = null));
|
|
743
|
+
}
|
|
744
|
+
if ($ && z) {
|
|
745
|
+
f.update({
|
|
746
|
+
scrollUpArrowVisible: !1,
|
|
747
|
+
scrollDownArrowVisible: !1
|
|
748
|
+
});
|
|
749
|
+
const k = {
|
|
750
|
+
height: ""
|
|
751
|
+
};
|
|
752
|
+
Xe(O, k), Xe(j.current, k);
|
|
753
|
+
}
|
|
754
|
+
}), re = n.useMemo(() => ({
|
|
755
|
+
...c,
|
|
756
|
+
side: g,
|
|
757
|
+
alignItemWithTriggerActive: z,
|
|
758
|
+
setControlledAlignItemWithTrigger: te,
|
|
759
|
+
scrollUpArrowRef: T,
|
|
760
|
+
scrollDownArrowRef: Q
|
|
761
|
+
}), [c, g, z, te]);
|
|
762
|
+
return /* @__PURE__ */ C(wn, {
|
|
763
|
+
elementsRef: X,
|
|
764
|
+
labelsRef: se,
|
|
765
|
+
onMapChange: Ie,
|
|
766
|
+
children: /* @__PURE__ */ Ae(ft.Provider, {
|
|
767
|
+
value: re,
|
|
768
|
+
children: [y && l && /* @__PURE__ */ C(mn, {
|
|
769
|
+
inert: En(!$),
|
|
770
|
+
cutout: u
|
|
771
|
+
}), ne]
|
|
772
|
+
})
|
|
773
|
+
});
|
|
774
|
+
});
|
|
775
|
+
process.env.NODE_ENV !== "production" && (Ft.displayName = "SelectPositioner");
|
|
776
|
+
function Bt(e) {
|
|
777
|
+
const t = e.currentTarget.getBoundingClientRect();
|
|
778
|
+
return t.top + 1 <= e.clientY && e.clientY <= t.bottom - 1 && t.left + 1 <= e.clientX && e.clientX <= t.right - 1;
|
|
779
|
+
}
|
|
780
|
+
const qn = {
|
|
781
|
+
...Rt,
|
|
782
|
+
...At
|
|
783
|
+
}, Ut = /* @__PURE__ */ n.forwardRef(function(t, o) {
|
|
784
|
+
const {
|
|
785
|
+
render: s,
|
|
786
|
+
className: r,
|
|
787
|
+
...i
|
|
788
|
+
} = t, {
|
|
789
|
+
store: m,
|
|
790
|
+
popupRef: d,
|
|
791
|
+
onOpenChangeComplete: F,
|
|
792
|
+
setOpen: w,
|
|
793
|
+
valueRef: v,
|
|
794
|
+
selectedItemTextRef: R,
|
|
795
|
+
keyboardActiveRef: b,
|
|
796
|
+
multiple: q,
|
|
797
|
+
handleScrollArrowVisibility: M,
|
|
798
|
+
scrollHandlerRef: U
|
|
799
|
+
} = Se(), {
|
|
800
|
+
side: L,
|
|
801
|
+
align: I,
|
|
802
|
+
alignItemWithTriggerActive: V,
|
|
803
|
+
setControlledAlignItemWithTrigger: f,
|
|
804
|
+
scrollDownArrowRef: X,
|
|
805
|
+
scrollUpArrowRef: se
|
|
806
|
+
} = Dt(), ie = Nn() != null, P = Vt(), N = _e(), ce = p(m, a.id), j = p(m, a.open), S = p(m, a.mounted), G = p(m, a.popupProps), $ = p(m, a.transitionStatus), y = p(m, a.triggerElement), l = p(m, a.positionerElement), A = p(m, a.listElement), B = n.useRef(0), O = n.useRef(!1), u = n.useRef(0), K = n.useRef(!1), T = n.useRef({}), Q = Cn(), ee = ye((g) => {
|
|
807
|
+
if (!l || !d.current || !K.current)
|
|
808
|
+
return;
|
|
809
|
+
if (O.current || !V) {
|
|
810
|
+
M();
|
|
811
|
+
return;
|
|
812
|
+
}
|
|
813
|
+
const D = l.style.top === "0px", H = l.style.bottom === "0px", Z = l.getBoundingClientRect().height, le = rt(l), ne = getComputedStyle(l), oe = parseFloat(ne.marginTop), Ie = parseFloat(ne.marginBottom), re = le.documentElement.clientHeight - oe - Ie, _ = g.scrollTop, ae = g.scrollHeight, pe = g.clientHeight, k = ae - pe;
|
|
814
|
+
let W = null, h = null, ue = !1;
|
|
815
|
+
if (D) {
|
|
816
|
+
const me = k - _, ge = Z + me, J = Math.min(ge, re);
|
|
817
|
+
W = J, J !== re ? h = k : ue = !0;
|
|
818
|
+
} else if (H) {
|
|
819
|
+
const me = _ - 0, ge = Z + me, J = Math.min(ge, re), De = ge - re;
|
|
820
|
+
W = J, J !== re ? h = 0 : (ue = !0, _ < k && (h = _ - (me - De)));
|
|
821
|
+
}
|
|
822
|
+
W != null && (l.style.height = `${W}px`), h != null && (g.scrollTop = h), ue && (O.current = !0), M();
|
|
823
|
+
});
|
|
824
|
+
n.useImperativeHandle(U, () => ee, [ee]), at({
|
|
825
|
+
open: j,
|
|
826
|
+
ref: d,
|
|
827
|
+
onComplete() {
|
|
828
|
+
j && F?.(!0);
|
|
829
|
+
}
|
|
830
|
+
});
|
|
831
|
+
const te = n.useMemo(() => ({
|
|
832
|
+
open: j,
|
|
833
|
+
transitionStatus: $,
|
|
834
|
+
side: L,
|
|
835
|
+
align: I
|
|
836
|
+
}), [j, $, L, I]);
|
|
837
|
+
fe(() => {
|
|
838
|
+
!l || !d.current || Object.keys(T.current).length || (T.current = {
|
|
839
|
+
top: l.style.top || "0",
|
|
840
|
+
left: l.style.left || "0",
|
|
841
|
+
right: l.style.right,
|
|
842
|
+
height: l.style.height,
|
|
843
|
+
bottom: l.style.bottom,
|
|
844
|
+
minHeight: l.style.minHeight,
|
|
845
|
+
maxHeight: l.style.maxHeight,
|
|
846
|
+
marginTop: l.style.marginTop,
|
|
847
|
+
marginBottom: l.style.marginBottom
|
|
848
|
+
});
|
|
849
|
+
}, [d, l]), fe(() => {
|
|
850
|
+
S || V || (K.current = !1, O.current = !1, B.current = 0, u.current = 0, Xe(l, T.current));
|
|
851
|
+
}, [S, V, l, d]), fe(() => {
|
|
852
|
+
const g = d.current;
|
|
853
|
+
if (!(!S || !y || !l || !g)) {
|
|
854
|
+
if (!V) {
|
|
855
|
+
K.current = !0, Q.request(M);
|
|
856
|
+
return;
|
|
857
|
+
}
|
|
858
|
+
queueMicrotask(() => {
|
|
859
|
+
const D = getComputedStyle(l), H = getComputedStyle(g), Z = rt(y), le = yt(l), ne = y.getBoundingClientRect(), oe = l.getBoundingClientRect(), Ie = ne.left, re = ne.height, _ = A || g, ae = _.scrollHeight, pe = parseFloat(H.borderBottomWidth), k = parseFloat(D.marginTop) || 10, W = parseFloat(D.marginBottom) || 10, h = parseFloat(D.minHeight) || 100, ue = 5, me = 5, ge = 20, J = Z.documentElement.clientHeight - k - W, De = Z.documentElement.clientWidth, Ge = J - ne.bottom + re, We = R.current, He = v.current;
|
|
860
|
+
let Te = 0, Ve = 0;
|
|
861
|
+
if (We && He) {
|
|
862
|
+
const Me = He.getBoundingClientRect(), Le = We.getBoundingClientRect(), Qe = Me.left - Ie, et = Le.left - oe.left, x = Me.top - ne.top + Me.height / 2, Y = Le.top - oe.top + Le.height / 2;
|
|
863
|
+
Te = Qe - et, Ve = Y - x;
|
|
864
|
+
}
|
|
865
|
+
const ve = Ge + Ve + W + pe;
|
|
866
|
+
let de = Math.min(J, ve);
|
|
867
|
+
const he = J - k - W, Fe = ve - de, ze = Math.max(ue, Ie + Te), Je = De - me, Ze = Math.max(0, ze + oe.width - Je);
|
|
868
|
+
l.style.left = `${ze - Ze}px`, l.style.height = `${de}px`, l.style.maxHeight = "auto", l.style.marginTop = `${k}px`, l.style.marginBottom = `${W}px`, g.style.height = "100%";
|
|
869
|
+
const Be = _.scrollHeight - _.clientHeight, Ce = Fe >= Be;
|
|
870
|
+
Ce && (de = Math.min(J, oe.height) - (Fe - Be));
|
|
871
|
+
const qe = ne.top < ge || ne.bottom > J - ge || de < Math.min(ae, h), Ue = (le.visualViewport?.scale ?? 1) !== 1 && Vn;
|
|
872
|
+
if (qe || Ue) {
|
|
873
|
+
K.current = !0, Xe(l, T.current), Tn.flushSync(() => f(!1));
|
|
874
|
+
return;
|
|
875
|
+
}
|
|
876
|
+
if (Ce) {
|
|
877
|
+
const Me = Math.max(0, J - ve);
|
|
878
|
+
l.style.top = oe.height >= he ? "0" : `${Me}px`, l.style.height = `${de}px`, _.scrollTop = _.scrollHeight - _.clientHeight, B.current = Math.max(h, de);
|
|
879
|
+
} else
|
|
880
|
+
l.style.bottom = "0", B.current = Math.max(h, de), _.scrollTop = Fe;
|
|
881
|
+
B.current === J && (O.current = !0), M(), setTimeout(() => {
|
|
882
|
+
K.current = !0;
|
|
883
|
+
});
|
|
884
|
+
});
|
|
885
|
+
}
|
|
886
|
+
}, [m, S, l, y, v, R, d, M, V, f, Q, X, se, A]), n.useEffect(() => {
|
|
887
|
+
if (!V || !l || !S)
|
|
888
|
+
return;
|
|
889
|
+
const g = yt(l);
|
|
890
|
+
function D(H) {
|
|
891
|
+
w(!1, xe(an, H));
|
|
892
|
+
}
|
|
893
|
+
return g.addEventListener("resize", D), () => {
|
|
894
|
+
g.removeEventListener("resize", D);
|
|
895
|
+
};
|
|
896
|
+
}, [w, V, l, S]);
|
|
897
|
+
const z = {
|
|
898
|
+
...A ? {
|
|
899
|
+
role: "presentation",
|
|
900
|
+
"aria-orientation": void 0
|
|
901
|
+
} : {
|
|
902
|
+
role: "listbox",
|
|
903
|
+
"aria-multiselectable": q || void 0,
|
|
904
|
+
id: `${ce}-list`
|
|
905
|
+
},
|
|
906
|
+
onKeyDown(g) {
|
|
907
|
+
b.current = !0, ie && _n.has(g.key) && g.stopPropagation();
|
|
908
|
+
},
|
|
909
|
+
onMouseMove() {
|
|
910
|
+
b.current = !1;
|
|
911
|
+
},
|
|
912
|
+
onPointerLeave(g) {
|
|
913
|
+
if (Bt(g) || g.pointerType === "touch")
|
|
914
|
+
return;
|
|
915
|
+
const D = g.currentTarget;
|
|
916
|
+
N.start(0, () => {
|
|
917
|
+
m.set("activeIndex", null), D.focus({
|
|
918
|
+
preventScroll: !0
|
|
919
|
+
});
|
|
920
|
+
});
|
|
921
|
+
},
|
|
922
|
+
onScroll(g) {
|
|
923
|
+
A || U.current?.(g.currentTarget);
|
|
924
|
+
},
|
|
925
|
+
...V && {
|
|
926
|
+
style: A ? {
|
|
927
|
+
height: "100%"
|
|
928
|
+
} : Ht
|
|
929
|
+
}
|
|
930
|
+
}, c = Re("div", t, {
|
|
931
|
+
ref: [o, d],
|
|
932
|
+
state: te,
|
|
933
|
+
stateAttributesMapping: qn,
|
|
934
|
+
props: [G, z, yn($), {
|
|
935
|
+
className: !A && V ? lt.className : void 0
|
|
936
|
+
}, i]
|
|
937
|
+
});
|
|
938
|
+
return /* @__PURE__ */ Ae(n.Fragment, {
|
|
939
|
+
children: [lt.element, /* @__PURE__ */ C(gn, {
|
|
940
|
+
context: P,
|
|
941
|
+
modal: !1,
|
|
942
|
+
disabled: !S,
|
|
943
|
+
restoreFocus: !0,
|
|
944
|
+
children: c
|
|
945
|
+
})]
|
|
946
|
+
});
|
|
947
|
+
});
|
|
948
|
+
process.env.NODE_ENV !== "production" && (Ut.displayName = "SelectPopup");
|
|
949
|
+
const Lt = /* @__PURE__ */ n.forwardRef(function(t, o) {
|
|
950
|
+
const {
|
|
951
|
+
className: s,
|
|
952
|
+
render: r,
|
|
953
|
+
...i
|
|
954
|
+
} = t, {
|
|
955
|
+
store: m,
|
|
956
|
+
scrollHandlerRef: d
|
|
957
|
+
} = Se(), {
|
|
958
|
+
alignItemWithTriggerActive: F
|
|
959
|
+
} = Dt(), w = p(m, a.hasScrollArrows), v = p(m, a.openMethod), R = p(m, a.multiple), q = {
|
|
960
|
+
id: `${p(m, a.id)}-list`,
|
|
961
|
+
role: "listbox",
|
|
962
|
+
"aria-multiselectable": R || void 0,
|
|
963
|
+
onScroll(U) {
|
|
964
|
+
d.current?.(U.currentTarget);
|
|
965
|
+
},
|
|
966
|
+
...F && {
|
|
967
|
+
style: Ht
|
|
968
|
+
},
|
|
969
|
+
className: w && v !== "touch" ? lt.className : void 0
|
|
970
|
+
}, M = ye((U) => {
|
|
971
|
+
m.set("listElement", U);
|
|
972
|
+
});
|
|
973
|
+
return Re("div", t, {
|
|
974
|
+
ref: [o, M],
|
|
975
|
+
props: [q, i]
|
|
976
|
+
});
|
|
977
|
+
});
|
|
978
|
+
process.env.NODE_ENV !== "production" && (Lt.displayName = "SelectList");
|
|
979
|
+
const pt = /* @__PURE__ */ n.createContext(void 0);
|
|
980
|
+
process.env.NODE_ENV !== "production" && (pt.displayName = "SelectItemContext");
|
|
981
|
+
function mt() {
|
|
982
|
+
const e = n.useContext(pt);
|
|
983
|
+
if (!e)
|
|
984
|
+
throw new Error(process.env.NODE_ENV !== "production" ? "Base UI: SelectItemContext is missing. SelectItem parts must be placed within <Select.Item>." : Ke(57));
|
|
985
|
+
return e;
|
|
986
|
+
}
|
|
987
|
+
const kt = /* @__PURE__ */ n.memo(/* @__PURE__ */ n.forwardRef(function(t, o) {
|
|
988
|
+
const {
|
|
989
|
+
render: s,
|
|
990
|
+
className: r,
|
|
991
|
+
value: i = null,
|
|
992
|
+
label: m,
|
|
993
|
+
disabled: d = !1,
|
|
994
|
+
nativeButton: F = !1,
|
|
995
|
+
...w
|
|
996
|
+
} = t, v = n.useRef(null), R = Mn({
|
|
997
|
+
label: m,
|
|
998
|
+
textRef: v,
|
|
999
|
+
indexGuessBehavior: An.GuessFromOrder
|
|
1000
|
+
}), {
|
|
1001
|
+
store: b,
|
|
1002
|
+
getItemProps: q,
|
|
1003
|
+
setOpen: M,
|
|
1004
|
+
setValue: U,
|
|
1005
|
+
selectionRef: L,
|
|
1006
|
+
typingRef: I,
|
|
1007
|
+
valuesRef: V,
|
|
1008
|
+
keyboardActiveRef: f,
|
|
1009
|
+
multiple: X,
|
|
1010
|
+
highlightItemOnHover: se
|
|
1011
|
+
} = Se(), ie = _e(), P = p(b, a.isActive, R.index), N = p(b, a.isSelected, R.index, i), ce = p(b, a.isSelectedByFocus, R.index), j = p(b, a.isItemEqualToValue), S = R.index, G = S !== -1, $ = n.useRef(null), y = ct(S);
|
|
1012
|
+
fe(() => {
|
|
1013
|
+
if (!G)
|
|
1014
|
+
return;
|
|
1015
|
+
const c = V.current;
|
|
1016
|
+
return c[S] = i, () => {
|
|
1017
|
+
delete c[S];
|
|
1018
|
+
};
|
|
1019
|
+
}, [G, S, i, V]), fe(() => {
|
|
1020
|
+
if (!G)
|
|
1021
|
+
return;
|
|
1022
|
+
const c = b.state.value;
|
|
1023
|
+
let g = c;
|
|
1024
|
+
X && Array.isArray(c) && c.length > 0 && (g = c[c.length - 1]), g !== void 0 && Oe(g, i, j) && b.set("selectedIndex", S);
|
|
1025
|
+
}, [G, S, X, j, b, i]);
|
|
1026
|
+
const l = n.useMemo(() => ({
|
|
1027
|
+
disabled: d,
|
|
1028
|
+
selected: N,
|
|
1029
|
+
highlighted: P
|
|
1030
|
+
}), [d, N, P]), A = q({
|
|
1031
|
+
active: P,
|
|
1032
|
+
selected: N
|
|
1033
|
+
});
|
|
1034
|
+
A.onFocus = void 0, A.id = void 0;
|
|
1035
|
+
const B = n.useRef(null), O = n.useRef("mouse"), u = n.useRef(!1), {
|
|
1036
|
+
getButtonProps: K,
|
|
1037
|
+
buttonRef: T
|
|
1038
|
+
} = Tt({
|
|
1039
|
+
disabled: d,
|
|
1040
|
+
focusableWhenDisabled: !0,
|
|
1041
|
+
native: F
|
|
1042
|
+
});
|
|
1043
|
+
function Q(c) {
|
|
1044
|
+
const g = b.state.value;
|
|
1045
|
+
if (X) {
|
|
1046
|
+
const D = Array.isArray(g) ? g : [], H = N ? Dn(D, i, j) : [...D, i];
|
|
1047
|
+
U(H, xe(tt, c));
|
|
1048
|
+
} else
|
|
1049
|
+
U(i, xe(tt, c)), M(!1, xe(tt, c));
|
|
1050
|
+
}
|
|
1051
|
+
const ee = {
|
|
1052
|
+
role: "option",
|
|
1053
|
+
"aria-selected": N,
|
|
1054
|
+
"aria-disabled": d || void 0,
|
|
1055
|
+
tabIndex: P ? 0 : -1,
|
|
1056
|
+
onFocus() {
|
|
1057
|
+
b.set("activeIndex", S);
|
|
1058
|
+
},
|
|
1059
|
+
onMouseEnter() {
|
|
1060
|
+
!f.current && b.state.selectedIndex === null && b.set("activeIndex", S);
|
|
1061
|
+
},
|
|
1062
|
+
onMouseMove() {
|
|
1063
|
+
se && b.set("activeIndex", S);
|
|
1064
|
+
},
|
|
1065
|
+
onMouseLeave(c) {
|
|
1066
|
+
!se || f.current || Bt(c) || ie.start(0, () => {
|
|
1067
|
+
b.state.activeIndex === S && b.set("activeIndex", null);
|
|
1068
|
+
});
|
|
1069
|
+
},
|
|
1070
|
+
onTouchStart() {
|
|
1071
|
+
L.current = {
|
|
1072
|
+
allowSelectedMouseUp: !1,
|
|
1073
|
+
allowUnselectedMouseUp: !1
|
|
1074
|
+
};
|
|
1075
|
+
},
|
|
1076
|
+
onKeyDown(c) {
|
|
1077
|
+
B.current = c.key, b.set("activeIndex", S);
|
|
1078
|
+
},
|
|
1079
|
+
onClick(c) {
|
|
1080
|
+
u.current = !1, !(c.type === "keydown" && B.current === null) && (d || B.current === " " && I.current || O.current !== "touch" && !P || (B.current = null, Q(c.nativeEvent)));
|
|
1081
|
+
},
|
|
1082
|
+
onPointerEnter(c) {
|
|
1083
|
+
O.current = c.pointerType;
|
|
1084
|
+
},
|
|
1085
|
+
onPointerDown(c) {
|
|
1086
|
+
O.current = c.pointerType, u.current = !0;
|
|
1087
|
+
},
|
|
1088
|
+
onMouseUp(c) {
|
|
1089
|
+
if (d)
|
|
1090
|
+
return;
|
|
1091
|
+
if (u.current) {
|
|
1092
|
+
u.current = !1;
|
|
1093
|
+
return;
|
|
1094
|
+
}
|
|
1095
|
+
const g = !L.current.allowSelectedMouseUp && N, D = !L.current.allowUnselectedMouseUp && !N;
|
|
1096
|
+
g || D || O.current !== "touch" && !P || Q(c.nativeEvent);
|
|
1097
|
+
}
|
|
1098
|
+
}, te = Re("div", t, {
|
|
1099
|
+
ref: [T, o, R.ref, $],
|
|
1100
|
+
state: l,
|
|
1101
|
+
props: [A, ee, w, K]
|
|
1102
|
+
}), z = n.useMemo(() => ({
|
|
1103
|
+
selected: N,
|
|
1104
|
+
indexRef: y,
|
|
1105
|
+
textRef: v,
|
|
1106
|
+
selectedByFocus: ce,
|
|
1107
|
+
hasRegistered: G
|
|
1108
|
+
}), [N, y, v, ce, G]);
|
|
1109
|
+
return /* @__PURE__ */ C(pt.Provider, {
|
|
1110
|
+
value: z,
|
|
1111
|
+
children: te
|
|
1112
|
+
});
|
|
1113
|
+
}));
|
|
1114
|
+
process.env.NODE_ENV !== "production" && (kt.displayName = "SelectItem");
|
|
1115
|
+
const Wt = /* @__PURE__ */ n.forwardRef(function(t, o) {
|
|
1116
|
+
const s = t.keepMounted ?? !1, {
|
|
1117
|
+
selected: r
|
|
1118
|
+
} = mt();
|
|
1119
|
+
return s || r ? /* @__PURE__ */ C(zt, {
|
|
1120
|
+
...t,
|
|
1121
|
+
ref: o
|
|
1122
|
+
}) : null;
|
|
1123
|
+
});
|
|
1124
|
+
process.env.NODE_ENV !== "production" && (Wt.displayName = "SelectItemIndicator");
|
|
1125
|
+
const zt = /* @__PURE__ */ n.memo(/* @__PURE__ */ n.forwardRef((e, t) => {
|
|
1126
|
+
const {
|
|
1127
|
+
render: o,
|
|
1128
|
+
className: s,
|
|
1129
|
+
keepMounted: r,
|
|
1130
|
+
...i
|
|
1131
|
+
} = e, {
|
|
1132
|
+
selected: m
|
|
1133
|
+
} = mt(), d = n.useRef(null), {
|
|
1134
|
+
transitionStatus: F,
|
|
1135
|
+
setMounted: w
|
|
1136
|
+
} = wt(m), v = n.useMemo(() => ({
|
|
1137
|
+
selected: m,
|
|
1138
|
+
transitionStatus: F
|
|
1139
|
+
}), [m, F]), R = Re("span", e, {
|
|
1140
|
+
ref: [t, d],
|
|
1141
|
+
state: v,
|
|
1142
|
+
props: [{
|
|
1143
|
+
"aria-hidden": !0,
|
|
1144
|
+
children: "✔️"
|
|
1145
|
+
}, i],
|
|
1146
|
+
stateAttributesMapping: At
|
|
1147
|
+
});
|
|
1148
|
+
return at({
|
|
1149
|
+
open: m,
|
|
1150
|
+
ref: d,
|
|
1151
|
+
onComplete() {
|
|
1152
|
+
m || w(!1);
|
|
1153
|
+
}
|
|
1154
|
+
}), R;
|
|
1155
|
+
}));
|
|
1156
|
+
process.env.NODE_ENV !== "production" && (zt.displayName = "Inner");
|
|
1157
|
+
const qt = /* @__PURE__ */ n.memo(/* @__PURE__ */ n.forwardRef(function(t, o) {
|
|
1158
|
+
const {
|
|
1159
|
+
indexRef: s,
|
|
1160
|
+
textRef: r,
|
|
1161
|
+
selectedByFocus: i,
|
|
1162
|
+
hasRegistered: m
|
|
1163
|
+
} = mt(), {
|
|
1164
|
+
selectedItemTextRef: d
|
|
1165
|
+
} = Se(), {
|
|
1166
|
+
className: F,
|
|
1167
|
+
render: w,
|
|
1168
|
+
...v
|
|
1169
|
+
} = t, R = n.useCallback((q) => {
|
|
1170
|
+
if (!q || !m)
|
|
1171
|
+
return;
|
|
1172
|
+
const M = d.current === null || !d.current.isConnected;
|
|
1173
|
+
(i || M && s.current === 0) && (d.current = q);
|
|
1174
|
+
}, [d, s, i, m]);
|
|
1175
|
+
return Re("div", t, {
|
|
1176
|
+
ref: [R, o, r],
|
|
1177
|
+
props: v
|
|
1178
|
+
});
|
|
1179
|
+
}));
|
|
1180
|
+
process.env.NODE_ENV !== "production" && (qt.displayName = "SelectItemText");
|
|
1181
|
+
const jn = "_select__trigger_1c25p_1", $n = "_select__list_1c25p_20", Yn = "_select__item_1c25p_32", Pe = {
|
|
1182
|
+
select__trigger: jn,
|
|
1183
|
+
"select__trigger-icon": "_select__trigger-icon_1c25p_16",
|
|
1184
|
+
select__list: $n,
|
|
1185
|
+
select__item: Yn,
|
|
1186
|
+
"select__item-indicator": "_select__item-indicator_1c25p_57",
|
|
1187
|
+
"select__item-text": "_select__item-text_1c25p_61"
|
|
1188
|
+
};
|
|
1189
|
+
function No({
|
|
1190
|
+
placeholder: e,
|
|
1191
|
+
className: t,
|
|
1192
|
+
style: o,
|
|
1193
|
+
...s
|
|
1194
|
+
}) {
|
|
1195
|
+
return /* @__PURE__ */ Ae(Ln, { ...s, children: [
|
|
1196
|
+
/* @__PURE__ */ Ae(
|
|
1197
|
+
Yt,
|
|
1198
|
+
{
|
|
1199
|
+
interactive: "fill-outline",
|
|
1200
|
+
render: /* @__PURE__ */ C(Ct, {}),
|
|
1201
|
+
style: o,
|
|
1202
|
+
className: jt(Pe.select__trigger, t),
|
|
1203
|
+
children: [
|
|
1204
|
+
/* @__PURE__ */ C(Nt, { children: Xn(e, s.items) }),
|
|
1205
|
+
/* @__PURE__ */ C(_t, { children: /* @__PURE__ */ C(
|
|
1206
|
+
xt,
|
|
1207
|
+
{
|
|
1208
|
+
name: "arrow-down-s-line",
|
|
1209
|
+
className: Pe["select__trigger-icon"]
|
|
1210
|
+
}
|
|
1211
|
+
) })
|
|
1212
|
+
]
|
|
1213
|
+
}
|
|
1214
|
+
),
|
|
1215
|
+
/* @__PURE__ */ C(Ot, { children: /* @__PURE__ */ C(Ft, { sideOffset: 4, alignItemWithTrigger: !1, children: /* @__PURE__ */ C(
|
|
1216
|
+
Ut,
|
|
1217
|
+
{
|
|
1218
|
+
className: Qt.transition_scale,
|
|
1219
|
+
children: /* @__PURE__ */ Ae(Lt, { className: Pe.select__list, children: [
|
|
1220
|
+
e && !s.multiple ? /* @__PURE__ */ C(ot, { value: null, label: e }) : null,
|
|
1221
|
+
Array.isArray(s.items) ? s.items.map(({ value: r, label: i }) => /* @__PURE__ */ C(ot, { value: r, label: i }, r)) : typeof s.items == "object" ? Object.entries(s.items).map(([r, i]) => /* @__PURE__ */ C(ot, { value: r, label: i }, r)) : null
|
|
1222
|
+
] })
|
|
1223
|
+
}
|
|
1224
|
+
) }) })
|
|
1225
|
+
] });
|
|
1226
|
+
}
|
|
1227
|
+
function ot(e) {
|
|
1228
|
+
return /* @__PURE__ */ Ae(
|
|
1229
|
+
kt,
|
|
1230
|
+
{
|
|
1231
|
+
className: Pe.select__item,
|
|
1232
|
+
value: e.value,
|
|
1233
|
+
children: [
|
|
1234
|
+
/* @__PURE__ */ C(
|
|
1235
|
+
Wt,
|
|
1236
|
+
{
|
|
1237
|
+
className: Pe["select__item-indicator"],
|
|
1238
|
+
children: /* @__PURE__ */ C(xt, { name: "check-line" })
|
|
1239
|
+
}
|
|
1240
|
+
),
|
|
1241
|
+
/* @__PURE__ */ C(qt, { className: Pe["select__item-text"], children: $t(e.label) })
|
|
1242
|
+
]
|
|
1243
|
+
}
|
|
1244
|
+
);
|
|
1245
|
+
}
|
|
1246
|
+
function Xn(e, t) {
|
|
1247
|
+
function o(r) {
|
|
1248
|
+
if (Array.isArray(t))
|
|
1249
|
+
return t.find((i) => i.value === r)?.label;
|
|
1250
|
+
if (typeof t == "object" && r in t)
|
|
1251
|
+
return t[r];
|
|
1252
|
+
}
|
|
1253
|
+
function s(r) {
|
|
1254
|
+
return !r || !t || r.length === 0 ? e : typeof r == "string" ? o(r) : [
|
|
1255
|
+
o(r[0]) || r[0],
|
|
1256
|
+
r.length > 1 ? ` (+${r.length - 1} more)` : ""
|
|
1257
|
+
];
|
|
1258
|
+
}
|
|
1259
|
+
return s;
|
|
1260
|
+
}
|
|
1261
|
+
export {
|
|
1262
|
+
No as Select
|
|
1263
|
+
};
|