@zj-dynamics/components 0.0.0-stage → 0.2.0
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/LICENSE +21 -0
- package/NOTICE.react-is +21 -0
- package/NOTICE.tabbable +22 -0
- package/README.md +31 -2
- package/compatibility.css +2 -0
- package/dist/Button.d.ts +90 -0
- package/dist/Button.js +58 -0
- package/dist/ButtonDismiss.d.ts +6 -0
- package/dist/ButtonDismiss.js +5 -0
- package/dist/Dialog.d.ts +75 -0
- package/dist/Dialog.js +59 -0
- package/dist/Icon.d.ts +20 -0
- package/dist/Icon.js +11 -0
- package/dist/InputText.d.ts +26 -0
- package/dist/InputText.js +63 -0
- package/dist/Switch.d.ts +8 -0
- package/dist/Switch.js +19 -0
- package/dist/Toast.d.ts +21 -0
- package/dist/Toast.js +58 -0
- package/dist/browserFocus.d.ts +11 -0
- package/dist/browserFocus.js +85 -0
- package/dist/browserHooks.d.ts +5 -0
- package/dist/browserHooks.js +4 -0
- package/dist/index.d.ts +100 -0
- package/dist/index.js +91 -0
- package/dist/legacyModalPortal.d.ts +1 -0
- package/dist/legacyModalPortal.js +2 -0
- package/dist/mockViewportWidth.d.ts +5 -0
- package/dist/mockViewportWidth.js +58 -0
- package/dist/slotChildren.d.ts +2 -0
- package/dist/slotChildren.js +6 -0
- package/dist/theme.d.ts +26 -0
- package/dist/theme.js +65 -0
- package/dist/unstyledPrimitives.d.ts +12 -0
- package/dist/unstyledPrimitives.js +12 -0
- package/dist/useBreakpoints.d.ts +3 -0
- package/dist/useBreakpoints.js +2 -0
- package/dist/useFocusTrap.d.ts +1 -0
- package/dist/useFocusTrap.js +1 -0
- package/dist/useInView.d.ts +1 -0
- package/dist/useInView.js +1 -0
- package/dist/useIsSmallScreen.d.ts +1 -0
- package/dist/useIsSmallScreen.js +1 -0
- package/dist/useLiveAnnounce.d.ts +1 -0
- package/dist/useLiveAnnounce.js +1 -0
- package/dist/useOnKeyDown.d.ts +1 -0
- package/dist/useOnKeyDown.js +1 -0
- package/dist/useRefocusOnActivator.d.ts +1 -0
- package/dist/useRefocusOnActivator.js +1 -0
- package/dist/useResizeObserver.d.ts +22 -0
- package/dist/useResizeObserver.js +47 -0
- package/dist/useWindowDimensions.d.ts +2 -0
- package/dist/useWindowDimensions.js +1 -0
- package/dist/viewport.d.ts +46 -0
- package/dist/viewport.js +141 -0
- package/foundation/ActivityIndicator/ActivityIndicator.d.ts +38 -0
- package/foundation/ActivityIndicator/index.d.mts +2 -0
- package/foundation/ActivityIndicator/index.mjs +6 -0
- package/foundation/ActivityIndicator-es.js +30 -0
- package/foundation/Autocomplete/Autocomplete.d.ts +8 -0
- package/foundation/Autocomplete/Autocomplete.types.d.ts +401 -0
- package/foundation/Autocomplete/hooks/useAutocompleteListNav.d.ts +30 -0
- package/foundation/Autocomplete/index.d.mts +3 -0
- package/foundation/Autocomplete/index.mjs +39 -0
- package/foundation/Autocomplete/utils/interactionUtils.d.ts +14 -0
- package/foundation/Autocomplete-es.js +1322 -0
- package/foundation/Avatar/Avatar.d.ts +77 -0
- package/foundation/Avatar/index.d.mts +1 -0
- package/foundation/Avatar/index.mjs +6 -0
- package/foundation/Avatar-es.js +80 -0
- package/foundation/Banner/Banner.d.ts +10 -0
- package/foundation/Banner/Banner.types.d.ts +165 -0
- package/foundation/Banner/index.d.mts +2 -0
- package/foundation/Banner/index.mjs +14 -0
- package/foundation/Banner-es.js +134 -0
- package/foundation/Body-es.js +45 -0
- package/foundation/BottomSheet-es.js +110 -0
- package/foundation/Box/Box.d.ts +3 -0
- package/foundation/Box/Box.types.d.ts +40 -0
- package/foundation/Box/index.d.mts +1 -0
- package/foundation/Box/index.mjs +4 -0
- package/foundation/Box-es.js +130 -0
- package/foundation/Button/Button.d.ts +17 -0
- package/foundation/Button/Button.types.d.ts +112 -0
- package/foundation/Button/ButtonInternals.d.ts +11 -0
- package/foundation/Button/ButtonProvider.d.ts +11 -0
- package/foundation/Button/index.d.mts +4 -0
- package/foundation/Button/useButtonStyles.d.ts +17 -0
- package/foundation/Button-es.js +122 -0
- package/foundation/ButtonDismiss/ButtonDismiss.d.ts +6 -0
- package/foundation/ButtonDismiss/index.d.mts +1 -0
- package/foundation/ButtonDismiss-es.js +9 -0
- package/foundation/Card/Card.d.ts +78 -0
- package/foundation/Card/cardcolors.module.d.ts +90 -0
- package/foundation/Card/index.d.mts +1 -0
- package/foundation/Card/index.mjs +37 -0
- package/foundation/Card/types.d.ts +63 -0
- package/foundation/Card-es.js +138 -0
- package/foundation/Checkbox/Checkbox.d.ts +7 -0
- package/foundation/Checkbox/Checkbox.types.d.ts +51 -0
- package/foundation/Checkbox/index.d.mts +2 -0
- package/foundation/Checkbox/index.mjs +8 -0
- package/foundation/Checkbox-es.js +57 -0
- package/foundation/Chip/Chip.d.ts +14 -0
- package/foundation/Chip/Chip.types.d.ts +70 -0
- package/foundation/Chip/components/ChipDismissible/ChipDismissible.d.ts +3 -0
- package/foundation/Chip/components/ChipPrefix/Chip.Prefix.d.ts +3 -0
- package/foundation/Chip/components/ChipSelectable/ChipSelectable.d.ts +3 -0
- package/foundation/Chip/components/ChipSuffix/Chip.Suffix.d.ts +9 -0
- package/foundation/Chip/index.d.mts +4 -0
- package/foundation/Chip/index.mjs +19 -0
- package/foundation/Chip-es.js +165 -0
- package/foundation/ChipDismissible-es.js +19 -0
- package/foundation/Chips/Chip.d.ts +9 -0
- package/foundation/Chips/ChipDismissible.d.ts +11 -0
- package/foundation/Chips/ChipTypes.d.ts +59 -0
- package/foundation/Chips/Chips.d.ts +8 -0
- package/foundation/Chips/ChipsTypes.d.ts +106 -0
- package/foundation/Chips/InternalChipButton.d.ts +11 -0
- package/foundation/Chips/index.d.mts +3 -0
- package/foundation/Chips/index.mjs +56 -0
- package/foundation/Chips-es.js +114 -0
- package/foundation/Cluster/Cluster.d.ts +3 -0
- package/foundation/Cluster/index.d.mts +2 -0
- package/foundation/Cluster/index.mjs +4 -0
- package/foundation/Cluster/types.d.ts +47 -0
- package/foundation/Cluster-es.js +12 -0
- package/foundation/Combobox/Combobox.d.ts +71 -0
- package/foundation/Combobox/Combobox.footer.d.ts +7 -0
- package/foundation/Combobox/Combobox.items.d.ts +25 -0
- package/foundation/Combobox/Combobox.selectAll.d.ts +4 -0
- package/foundation/Combobox/Combobox.slotFactory.d.ts +7 -0
- package/foundation/Combobox/Combobox.types.d.ts +168 -0
- package/foundation/Combobox/index.d.mts +2 -0
- package/foundation/Combobox/index.mjs +28 -0
- package/foundation/Combobox-es.js +782 -0
- package/foundation/ComboboxPrimitive-es.js +187 -0
- package/foundation/ComboboxSeparator-es.js +3541 -0
- package/foundation/ComponentSettingsContext/ComponentSettingsContext.d.ts +41 -0
- package/foundation/ComponentSettingsContext/index.d.mts +4 -0
- package/foundation/ComponentSettingsContext/index.mjs +5 -0
- package/foundation/ComponentSettingsContext-es.js +18 -0
- package/foundation/ConfirmationModal/ConfirmationModal.d.ts +79 -0
- package/foundation/ConfirmationModal/index.d.mts +1 -0
- package/foundation/ConfirmationModal/index.mjs +37 -0
- package/foundation/ConfirmationModal-es.js +111 -0
- package/foundation/Container/Container.d.ts +6 -0
- package/foundation/Container/index.d.mts +1 -0
- package/foundation/Container/index.mjs +3 -0
- package/foundation/Container/types.d.ts +22 -0
- package/foundation/Container-es.js +16 -0
- package/foundation/Content/Content.d.ts +22 -0
- package/foundation/Content/Spacing.module.d.ts +14 -0
- package/foundation/Content/index.d.mts +1 -0
- package/foundation/Content/index.mjs +3 -0
- package/foundation/Content-es.js +13 -0
- package/foundation/ContentBlock/ContentBlock.d.ts +3 -0
- package/foundation/ContentBlock/index.d.mts +2 -0
- package/foundation/ContentBlock/index.mjs +4 -0
- package/foundation/ContentBlock/types.d.ts +37 -0
- package/foundation/ContentBlock-es.js +29 -0
- package/foundation/Countdown/Countdown.d.ts +30 -0
- package/foundation/Countdown/index.d.mts +1 -0
- package/foundation/Countdown/index.mjs +4 -0
- package/foundation/Countdown-es.js +649 -0
- package/foundation/Cover/Cover.d.ts +6 -0
- package/foundation/Cover/index.d.mts +2 -0
- package/foundation/Cover/index.mjs +4 -0
- package/foundation/Cover/types.d.ts +34 -0
- package/foundation/Cover-es.js +14 -0
- package/foundation/DataDump/DataDump.d.ts +21 -0
- package/foundation/DataDump/index.d.mts +1 -0
- package/foundation/DataDump/index.mjs +40 -0
- package/foundation/DataDump-es.js +26 -0
- package/foundation/DataList/DataList.const.d.ts +22 -0
- package/foundation/DataList/DataList.d.ts +28 -0
- package/foundation/DataList/DataList.types.d.ts +323 -0
- package/foundation/DataList/components/DataListAction/DataListAction.d.ts +3 -0
- package/foundation/DataList/components/DataListAction/index.d.mts +1 -0
- package/foundation/DataList/components/DataListBulkActions/DataListBulkActions.d.ts +4 -0
- package/foundation/DataList/components/DataListBulkActions/index.d.mts +1 -0
- package/foundation/DataList/components/DataListEmptyState/DataListEmptyState.d.ts +4 -0
- package/foundation/DataList/components/DataListEmptyState/index.d.mts +1 -0
- package/foundation/DataList/components/DataListFilters/DataListFilters.d.ts +11 -0
- package/foundation/DataList/components/DataListFilters/index.d.mts +1 -0
- package/foundation/DataList/components/DataListItemActions/DataListItemActions.d.ts +9 -0
- package/foundation/DataList/components/DataListItemActions/index.d.mts +1 -0
- package/foundation/DataList/components/DataListLayout/DataListLayout.d.ts +3 -0
- package/foundation/DataList/components/DataListLayout/index.d.mts +1 -0
- package/foundation/DataList/components/DataListLayoutActions/DataListLayoutActions.d.ts +2 -0
- package/foundation/DataList/components/DataListLayoutActions/index.d.mts +1 -0
- package/foundation/DataList/components/DataListSearch/DataListSearch.d.ts +8 -0
- package/foundation/DataList/components/DataListSearch/index.d.mts +1 -0
- package/foundation/DataList/components/DataListStatusBar/DataListStatusBar.d.ts +11 -0
- package/foundation/DataList/components/DataListStatusBar/index.d.mts +1 -0
- package/foundation/DataList/index.d.mts +2 -0
- package/foundation/DataList/index.mjs +96 -0
- package/foundation/DataList-es.js +141 -0
- package/foundation/DataList.const-es.js +26 -0
- package/foundation/DataList.module-es.js +3 -0
- package/foundation/DataList.utils-es.js +167 -0
- package/foundation/DataListAction-es.js +43 -0
- package/foundation/DataListActions-es.js +53 -0
- package/foundation/DataListActionsMenu-es.js +52 -0
- package/foundation/DataListBulkActions-es.js +28 -0
- package/foundation/DataListContext-es.js +26 -0
- package/foundation/DataListEmptyState-es.js +54 -0
- package/foundation/DataListFilters-es.js +43 -0
- package/foundation/DataListHeader-es.js +130 -0
- package/foundation/DataListHeaderTile-es.js +86 -0
- package/foundation/DataListItem-es.js +118 -0
- package/foundation/DataListItemActions-es.js +29 -0
- package/foundation/DataListItemActionsOverflow-es.js +34 -0
- package/foundation/DataListItemClickable-es.js +45 -0
- package/foundation/DataListItems-es.js +19 -0
- package/foundation/DataListLayout-es.js +19 -0
- package/foundation/DataListLayoutActions-es.js +36 -0
- package/foundation/DataListLayoutContext-es.js +14 -0
- package/foundation/DataListLayoutContext-es2.js +8 -0
- package/foundation/DataListLoadMore-es.js +32 -0
- package/foundation/DataListLoadingState-es.js +22 -0
- package/foundation/DataListOverflowFade-es.js +22 -0
- package/foundation/DataListSearch-es.js +84 -0
- package/foundation/DataListSort-es.js +74 -0
- package/foundation/DataListSortingOptions-es.js +34 -0
- package/foundation/DataListStatusBar-es.js +22 -0
- package/foundation/DataListStickyHeader-es.js +23 -0
- package/foundation/DataListTags-es.js +62 -0
- package/foundation/DataListTotalCount-es.js +38 -0
- package/foundation/DataTable/DataTable.d.ts +74 -0
- package/foundation/DataTable/SortIcon.d.ts +11 -0
- package/foundation/DataTable/components/DataTableActions.d.ts +2 -0
- package/foundation/DataTable/components/DataTableBody.d.ts +2 -0
- package/foundation/DataTable/components/DataTableCell.d.ts +2 -0
- package/foundation/DataTable/components/DataTableContainer.d.ts +2 -0
- package/foundation/DataTable/components/DataTableFooter.d.ts +5 -0
- package/foundation/DataTable/components/DataTableHeader.d.ts +2 -0
- package/foundation/DataTable/components/DataTableHeaderCell.d.ts +5 -0
- package/foundation/DataTable/components/DataTablePagination.d.ts +5 -0
- package/foundation/DataTable/components/DataTablePaginationButton.d.ts +21 -0
- package/foundation/DataTable/components/DataTableRow.d.ts +2 -0
- package/foundation/DataTable/components/DataTableRowActions.d.ts +4 -0
- package/foundation/DataTable/components/DataTableSortableHeader.d.ts +24 -0
- package/foundation/DataTable/components/DataTableTable.d.ts +11 -0
- package/foundation/DataTable/components/index.d.mts +13 -0
- package/foundation/DataTable/index.d.mts +6 -0
- package/foundation/DataTable/index.mjs +29 -0
- package/foundation/DataTable/test-utilities/helpers.d.ts +1 -0
- package/foundation/DataTable/types.d.ts +83 -0
- package/foundation/DataTable-es.js +262 -0
- package/foundation/DataTableTable-es.js +117 -0
- package/foundation/DatePicker/DatePicker.d.ts +74 -0
- package/foundation/DatePicker/DatePickerActivator.d.ts +18 -0
- package/foundation/DatePicker/index.d.mts +1 -0
- package/foundation/DatePicker/index.mjs +26 -0
- package/foundation/DatePicker-es.js +13627 -0
- package/foundation/Dialog/dialogReturnFocus.d.ts +43 -0
- package/foundation/Disclosure/Disclosure.d.ts +68 -0
- package/foundation/Disclosure/index.d.mts +1 -0
- package/foundation/Disclosure/index.mjs +7 -0
- package/foundation/Disclosure-es.js +46 -0
- package/foundation/Divider/Divider.d.ts +39 -0
- package/foundation/Divider/DividerDirections.module.d.ts +6 -0
- package/foundation/Divider/DividerSizes.module.d.ts +8 -0
- package/foundation/Divider/index.d.mts +1 -0
- package/foundation/Divider/index.mjs +3 -0
- package/foundation/Divider-es.js +15 -0
- package/foundation/Drawer/Drawer.d.ts +14 -0
- package/foundation/Drawer/DrawerGrid.d.ts +7 -0
- package/foundation/Drawer/index.d.mts +2 -0
- package/foundation/Drawer/index.mjs +13 -0
- package/foundation/DrawerGrid-es.js +39 -0
- package/foundation/DrawerTitle-es.js +90 -0
- package/foundation/Emphasis/Emphasis.d.ts +12 -0
- package/foundation/Emphasis/index.d.mts +1 -0
- package/foundation/Emphasis/index.mjs +4 -0
- package/foundation/Emphasis-es.js +13 -0
- package/foundation/FeatureSwitch/FeatureSwitch.d.ts +52 -0
- package/foundation/FeatureSwitch/index.d.mts +1 -0
- package/foundation/FeatureSwitch/index.mjs +20 -0
- package/foundation/FeatureSwitch-es.js +66 -0
- package/foundation/FieldDescription-es.js +859 -0
- package/foundation/FilterPicker/FilterPicker.d.ts +11 -0
- package/foundation/FilterPicker/FilterPicker.types.d.ts +282 -0
- package/foundation/FilterPicker/FilterPickerProvider.d.ts +18 -0
- package/foundation/FilterPicker/components/FilterPickerAction/FilterPickerAction.d.ts +3 -0
- package/foundation/FilterPicker/components/FilterPickerAction/index.d.mts +1 -0
- package/foundation/FilterPicker/components/FilterPickerActivator/FilterPickerActivator.d.ts +3 -0
- package/foundation/FilterPicker/components/FilterPickerActivator/index.d.mts +1 -0
- package/foundation/FilterPicker/components/FilterPickerOption/FilterPickerOption.d.ts +3 -0
- package/foundation/FilterPicker/index.d.mts +3 -0
- package/foundation/FilterPicker/index.mjs +49 -0
- package/foundation/FilterPicker-es.js +110 -0
- package/foundation/FilterPicker.messages-es.js +56 -0
- package/foundation/FilterPickerAction-es.js +30 -0
- package/foundation/FilterPickerActivator-es.js +36 -0
- package/foundation/FilterPickerContent-es.js +180 -0
- package/foundation/FilterPickerContentHeader-es.js +23 -0
- package/foundation/FilterPickerContentList-es.js +74 -0
- package/foundation/FilterPickerContentSearch-es.js +35 -0
- package/foundation/FilterPickerLoadMore-es.js +14 -0
- package/foundation/FilterPickerOption-es.js +29 -0
- package/foundation/FilterPickerProvider-es.js +10 -0
- package/foundation/FilterPickerTrigger-es.js +19 -0
- package/foundation/Flex/Flex.d.ts +33 -0
- package/foundation/Flex/Flex.types.d.ts +6 -0
- package/foundation/Flex/index.d.mts +1 -0
- package/foundation/Flex/index.mjs +3 -0
- package/foundation/Flex-es.js +28 -0
- package/foundation/FormField/FormFieldAffix.d.ts +19 -0
- package/foundation/FormField/FormFieldTypes.d.ts +185 -0
- package/foundation/FormField/FormFieldWrapper.d.ts +57 -0
- package/foundation/FormField/hooks/useFormFieldName.d.ts +6 -0
- package/foundation/FormField/hooks/useFormFieldWrapperStyles.d.ts +35 -0
- package/foundation/FormField/index.d.mts +5 -0
- package/foundation/FormField/index.mjs +17 -0
- package/foundation/FormFieldPostFix-es.js +13 -0
- package/foundation/FormFieldWrapper-es.js +233 -0
- package/foundation/FormatFile/FormatFile.d.ts +42 -0
- package/foundation/FormatFile/index.d.mts +4 -0
- package/foundation/FormatFile/index.mjs +42 -0
- package/foundation/FormatFile/types.d.ts +27 -0
- package/foundation/FormatFile/useFormatFile.d.ts +5 -0
- package/foundation/FormatFile/useFormatFileStyles.d.ts +10 -0
- package/foundation/FormatFile-es.js +137 -0
- package/foundation/Frame/Frame.d.ts +3 -0
- package/foundation/Frame/index.d.mts +2 -0
- package/foundation/Frame/index.mjs +3 -0
- package/foundation/Frame/types.d.ts +24 -0
- package/foundation/Frame-es.js +10 -0
- package/foundation/Gallery/Gallery.d.ts +3 -0
- package/foundation/Gallery/GalleryTypes.d.ts +36 -0
- package/foundation/Gallery/index.d.mts +3 -0
- package/foundation/Gallery/index.mjs +64 -0
- package/foundation/Gallery-es.js +88 -0
- package/foundation/Glimmer/Glimmer.d.ts +71 -0
- package/foundation/Glimmer/index.d.mts +1 -0
- package/foundation/Glimmer/index.mjs +5 -0
- package/foundation/Glimmer/style/Shape.module.d.ts +9 -0
- package/foundation/Glimmer/style/Sizes.module.d.ts +10 -0
- package/foundation/Glimmer/style/Timing.module.d.ts +6 -0
- package/foundation/Glimmer-es.js +53 -0
- package/foundation/Grid/Grid.d.ts +32 -0
- package/foundation/Grid/GridAlign.module.d.ts +8 -0
- package/foundation/Grid/GridCell/GridCell.d.ts +23 -0
- package/foundation/Grid/GridCell/index.d.mts +1 -0
- package/foundation/Grid/index.d.mts +1 -0
- package/foundation/Grid/index.mjs +5 -0
- package/foundation/Grid-es.js +30 -0
- package/foundation/GridCell-es.js +34 -0
- package/foundation/Heading/Heading.d.ts +41 -0
- package/foundation/Heading/index.d.mts +2 -0
- package/foundation/Heading/index.mjs +4 -0
- package/foundation/Heading-es.js +55 -0
- package/foundation/HelperText-es.js +19 -0
- package/foundation/Icon/Icon.d.ts +47 -0
- package/foundation/Icon/index.d.mts +1 -0
- package/foundation/Icon-es.js +22 -0
- package/foundation/InlineLabel/InlineLabel.d.ts +18 -0
- package/foundation/InlineLabel/index.d.mts +1 -0
- package/foundation/InlineLabel/index.mjs +4 -0
- package/foundation/InlineLabel-es.js +19 -0
- package/foundation/InputAvatar/InputAvatar.d.ts +23 -0
- package/foundation/InputAvatar/index.d.mts +1 -0
- package/foundation/InputAvatar/index.mjs +22 -0
- package/foundation/InputAvatar-es.js +64 -0
- package/foundation/InputDate/InputDate.d.ts +3 -0
- package/foundation/InputDate/InputDate.types.d.ts +36 -0
- package/foundation/InputDate/index.d.mts +2 -0
- package/foundation/InputDate/index.mjs +39 -0
- package/foundation/InputDate-es.js +104 -0
- package/foundation/InputEmail/InputEmail.d.ts +3 -0
- package/foundation/InputEmail/InputEmail.types.d.ts +16 -0
- package/foundation/InputEmail/index.d.mts +2 -0
- package/foundation/InputEmail/index.mjs +22 -0
- package/foundation/InputEmail-es.js +105 -0
- package/foundation/InputFile/FileTypes.d.ts +17 -0
- package/foundation/InputFile/InputFile.d.ts +187 -0
- package/foundation/InputFile/InputFileButton.d.ts +6 -0
- package/foundation/InputFile/InputFileContentContext.d.ts +12 -0
- package/foundation/InputFile/InputFileDescription.d.ts +4 -0
- package/foundation/InputFile/InputFileDropzoneWrapper.d.ts +4 -0
- package/foundation/InputFile/InputFileHintText.d.ts +4 -0
- package/foundation/InputFile/index.d.mts +3 -0
- package/foundation/InputFile/index.mjs +16 -0
- package/foundation/InputFile-es.js +1780 -0
- package/foundation/InputGroup/InputGroup.d.ts +12 -0
- package/foundation/InputGroup/index.d.mts +1 -0
- package/foundation/InputGroup/index.mjs +3 -0
- package/foundation/InputGroup-es.js +26 -0
- package/foundation/InputNumber/InputNumber.d.ts +77 -0
- package/foundation/InputNumber/index.d.mts +2 -0
- package/foundation/InputNumber/index.mjs +33 -0
- package/foundation/InputNumber/types.d.ts +197 -0
- package/foundation/InputNumber-es.js +348 -0
- package/foundation/InputPhoneNumber/InputPhoneNumber.d.ts +3 -0
- package/foundation/InputPhoneNumber/InputPhoneNumber.types.d.ts +24 -0
- package/foundation/InputPhoneNumber/index.d.mts +2 -0
- package/foundation/InputPhoneNumber/index.mjs +22 -0
- package/foundation/InputPhoneNumber-es.js +188 -0
- package/foundation/InputText/InputText.d.ts +3 -0
- package/foundation/InputText/InputText.types.d.ts +58 -0
- package/foundation/InputText/index.d.mts +2 -0
- package/foundation/InputText/index.mjs +23 -0
- package/foundation/InputText-es.js +196 -0
- package/foundation/InputTime/InputTime.d.ts +3 -0
- package/foundation/InputTime/InputTime.types.d.ts +34 -0
- package/foundation/InputTime/index.d.mts +2 -0
- package/foundation/InputTime/index.mjs +23 -0
- package/foundation/InputTime-es.js +297 -0
- package/foundation/InputValidation/InputValidation.d.ts +10 -0
- package/foundation/InputValidation/index.d.mts +1 -0
- package/foundation/InputValidation/index.mjs +8 -0
- package/foundation/InputValidation-es.js +22 -0
- package/foundation/InternalChipDismissible-es.js +68 -0
- package/foundation/LICENSE +21 -0
- package/foundation/LegacySelect/LegacySelect.d.ts +7 -0
- package/foundation/LegacySelect/LegacySelect.types.d.ts +18 -0
- package/foundation/LegacySelect/Option.d.ts +18 -0
- package/foundation/LegacySelect/OptionGroup.d.ts +29 -0
- package/foundation/LegacySelect/index.d.mts +3 -0
- package/foundation/LegacySelect/index.mjs +23 -0
- package/foundation/LegacySelect-es.js +76 -0
- package/foundation/LegacyThemeContext/LegacyThemeContext.d.ts +5 -0
- package/foundation/LegacyThemeContext/index.d.mts +3 -0
- package/foundation/LegacyThemeContext/index.mjs +12 -0
- package/foundation/LegacyThemeContext/types.d.ts +59 -0
- package/foundation/LegacyThemeContext/updateTheme.d.ts +7 -0
- package/foundation/LegacyThemeContext-es.js +457 -0
- package/foundation/LightBox/LightBox.d.ts +165 -0
- package/foundation/LightBox/LightBox.types.d.ts +153 -0
- package/foundation/LightBox/LightBoxContext.d.ts +5 -0
- package/foundation/LightBox/index.d.mts +3 -0
- package/foundation/LightBox/index.mjs +50 -0
- package/foundation/LightBox-es.js +454 -0
- package/foundation/Link/Link.d.ts +9 -0
- package/foundation/Link/index.d.mts +2 -0
- package/foundation/Link/index.mjs +2 -0
- package/foundation/Link-es.js +12 -0
- package/foundation/List/List.d.ts +41 -0
- package/foundation/List/ListItem.d.ts +59 -0
- package/foundation/List/index.d.mts +2 -0
- package/foundation/List/index.mjs +22 -0
- package/foundation/List-es.js +199 -0
- package/foundation/Markdown/Markdown.d.ts +24 -0
- package/foundation/Markdown/index.d.mts +1 -0
- package/foundation/Markdown/index.mjs +10 -0
- package/foundation/Markdown-es.js +20558 -0
- package/foundation/Menu/Menu.d.ts +89 -0
- package/foundation/Menu/Menu.types.d.ts +105 -0
- package/foundation/Menu/index.d.mts +2 -0
- package/foundation/Menu/index.mjs +35 -0
- package/foundation/Menu/menuComposableTypes.d.ts +103 -0
- package/foundation/Menu-es.js +1033 -0
- package/foundation/MenuSubmenuTrigger-es.js +3088 -0
- package/foundation/Modal/Modal.rebuilt.d.ts +16 -0
- package/foundation/Modal/Modal.types.d.ts +138 -0
- package/foundation/Modal/ModalContext.rebuilt.d.ts +19 -0
- package/foundation/Modal/ModalSizes.module.d.ts +7 -0
- package/foundation/Modal/index.d.mts +17 -0
- package/foundation/Modal/index.mjs +302 -0
- package/foundation/Modal/useModalStyles.d.ts +12 -0
- package/foundation/MultiSelect/MultiSelect.d.ts +30 -0
- package/foundation/MultiSelect/index.d.mts +1 -0
- package/foundation/MultiSelect/index.mjs +9 -0
- package/foundation/MultiSelect/types.d.ts +13 -0
- package/foundation/MultiSelect-es.js +172 -0
- package/foundation/OverlaySeparator-es.js +13 -0
- package/foundation/Page/Page.d.ts +74 -0
- package/foundation/Page/index.d.mts +2 -0
- package/foundation/Page/index.mjs +42 -0
- package/foundation/Page/types.d.ts +123 -0
- package/foundation/Page-es.js +196 -0
- package/foundation/Popover/Popover.d.ts +9 -0
- package/foundation/Popover/Popover.types.d.ts +109 -0
- package/foundation/Popover/PopoverContext.d.ts +18 -0
- package/foundation/Popover/index.d.mts +4 -0
- package/foundation/Popover/index.mjs +27 -0
- package/foundation/Popover/usePopoverStyles.d.ts +5 -0
- package/foundation/Popover-es.js +166 -0
- package/foundation/ProgressBar/ProgressBar.d.ts +41 -0
- package/foundation/ProgressBar/ProgressBarSizes.module.d.ts +7 -0
- package/foundation/ProgressBar/index.d.mts +1 -0
- package/foundation/ProgressBar/index.mjs +5 -0
- package/foundation/ProgressBar-es.js +48 -0
- package/foundation/ProgressIndicator/ProgressIndicator.d.ts +60 -0
- package/foundation/ProgressIndicator/index.d.mts +1 -0
- package/foundation/ProgressIndicator/index.mjs +3 -0
- package/foundation/ProgressIndicator-es.js +41 -0
- package/foundation/RadioGroup/RadioGroup.d.ts +33 -0
- package/foundation/RadioGroup/RadioOption.d.ts +48 -0
- package/foundation/RadioGroup/index.d.mts +2 -0
- package/foundation/RadioGroup/index.mjs +5 -0
- package/foundation/RadioGroup-es.js +42 -0
- package/foundation/ResponsiveSwitcher/ResponsiveSwitcher.d.ts +3 -0
- package/foundation/ResponsiveSwitcher/index.d.mts +2 -0
- package/foundation/ResponsiveSwitcher/index.mjs +4 -0
- package/foundation/ResponsiveSwitcher/types.d.ts +26 -0
- package/foundation/ResponsiveSwitcher-es.js +11 -0
- package/foundation/RulnarPortalContent-es.js +1 -0
- package/foundation/ScrollAreaViewport-es.js +3959 -0
- package/foundation/SegmentedControl/SegmentedControl.d.ts +39 -0
- package/foundation/SegmentedControl/SegmentedControlBase.d.ts +7 -0
- package/foundation/SegmentedControl/SegmentedControlOption.d.ts +15 -0
- package/foundation/SegmentedControl/SegmentedControlProvider.d.ts +17 -0
- package/foundation/SegmentedControl/index.d.mts +2 -0
- package/foundation/SegmentedControl/index.mjs +3 -0
- package/foundation/SegmentedControl-es.js +64 -0
- package/foundation/Select/Select.d.ts +31 -0
- package/foundation/Select/Select.types.d.ts +145 -0
- package/foundation/Select/index.d.mts +2 -0
- package/foundation/Select/index.mjs +29 -0
- package/foundation/Select-es.js +227 -0
- package/foundation/SelectGroupLabel-es.js +1763 -0
- package/foundation/SelectPrimitive-es.js +126 -0
- package/foundation/Separator-es.js +33 -0
- package/foundation/SideDrawer/SideDrawer.d.ts +56 -0
- package/foundation/SideDrawer/SideDrawerActions.d.ts +3 -0
- package/foundation/SideDrawer/SideDrawerBackButton.d.ts +3 -0
- package/foundation/SideDrawer/SideDrawerFooter.d.ts +3 -0
- package/foundation/SideDrawer/SideDrawerTitle.d.ts +3 -0
- package/foundation/SideDrawer/SideDrawerToolbar.d.ts +2 -0
- package/foundation/SideDrawer/index.d.mts +1 -0
- package/foundation/SideDrawer/index.mjs +16 -0
- package/foundation/SideDrawer-es.js +198 -0
- package/foundation/SideKick/SideKick.d.ts +3 -0
- package/foundation/SideKick/index.d.mts +2 -0
- package/foundation/SideKick/index.mjs +4 -0
- package/foundation/SideKick/types.d.ts +35 -0
- package/foundation/SideKick-es.js +15 -0
- package/foundation/Spinner/Spinner.d.ts +22 -0
- package/foundation/Spinner/index.d.mts +1 -0
- package/foundation/Spinner/index.mjs +6 -0
- package/foundation/Spinner-es.js +21 -0
- package/foundation/Stack/Stack.d.ts +3 -0
- package/foundation/Stack/index.d.mts +2 -0
- package/foundation/Stack/index.mjs +4 -0
- package/foundation/Stack/types.d.ts +32 -0
- package/foundation/Stack-es.js +13 -0
- package/foundation/StatusIndicator/StatusIndicator.d.ts +7 -0
- package/foundation/StatusIndicator/StatusIndicator.type.d.ts +1 -0
- package/foundation/StatusIndicator/index.d.mts +2 -0
- package/foundation/StatusIndicator/index.mjs +2 -0
- package/foundation/StatusIndicator-es.js +9 -0
- package/foundation/StatusLabel/StatusLabel.d.ts +26 -0
- package/foundation/StatusLabel/index.d.mts +1 -0
- package/foundation/StatusLabel/index.mjs +5 -0
- package/foundation/StatusLabel-es.js +16 -0
- package/foundation/Table/Body.d.ts +7 -0
- package/foundation/Table/Cells/Cell.d.ts +8 -0
- package/foundation/Table/Cells/CellCurrency.d.ts +9 -0
- package/foundation/Table/Cells/CellNumeric.d.ts +5 -0
- package/foundation/Table/Footer.d.ts +7 -0
- package/foundation/Table/Header.d.ts +7 -0
- package/foundation/Table/Row.d.ts +7 -0
- package/foundation/Table/Table.d.ts +7 -0
- package/foundation/Table/index.d.mts +8 -0
- package/foundation/Table/index.mjs +4 -0
- package/foundation/Tabs/Tabs.d.ts +38 -0
- package/foundation/Tabs/index.d.mts +1 -0
- package/foundation/Tabs/index.mjs +8 -0
- package/foundation/Tabs-es.js +227 -0
- package/foundation/Text/Text.d.ts +29 -0
- package/foundation/Text/index.d.mts +2 -0
- package/foundation/Text/index.mjs +4 -0
- package/foundation/Text-es.js +25 -0
- package/foundation/Thumbnail/Thumbnail.d.ts +25 -0
- package/foundation/Thumbnail/index.d.mts +1 -0
- package/foundation/Thumbnail/index.mjs +9 -0
- package/foundation/Thumbnail-es.js +119 -0
- package/foundation/Tiles/Tiles.d.ts +3 -0
- package/foundation/Tiles/index.d.mts +2 -0
- package/foundation/Tiles/index.mjs +4 -0
- package/foundation/Tiles/types.d.ts +34 -0
- package/foundation/Tiles-es.js +11 -0
- package/foundation/Tooltip/Tooltip.d.ts +18 -0
- package/foundation/Tooltip/Tooltip.types.d.ts +1 -0
- package/foundation/Tooltip/index.d.mts +1 -0
- package/foundation/Tooltip/index.mjs +8 -0
- package/foundation/Tooltip-es.js +137 -0
- package/foundation/Typography/Typography.d.ts +64 -0
- package/foundation/Typography/css/Emphasis.module.d.ts +6 -0
- package/foundation/Typography/css/FontFamilies.module.d.ts +6 -0
- package/foundation/Typography/css/FontSizes.module.d.ts +12 -0
- package/foundation/Typography/css/FontWeights.module.d.ts +10 -0
- package/foundation/Typography/css/TextAlignment.module.d.ts +7 -0
- package/foundation/Typography/css/TextCases.module.d.ts +8 -0
- package/foundation/Typography/css/TextColors.module.d.ts +69 -0
- package/foundation/Typography/index.d.mts +1 -0
- package/foundation/Typography/index.mjs +3 -0
- package/foundation/Typography/types.d.ts +7 -0
- package/foundation/Typography-es.js +53 -0
- package/foundation/_baseAssignValue-es.js +29 -0
- package/foundation/_baseEach-es.js +1028 -0
- package/foundation/_baseFlatten-es.js +65 -0
- package/foundation/_baseFor-es.js +45 -0
- package/foundation/_commonjsHelpers-es.js +7 -0
- package/foundation/_getAllKeys-es.js +506 -0
- package/foundation/_getTag-es.js +133 -0
- package/foundation/_isIterateeCall-es.js +55 -0
- package/foundation/_setToString-es.js +168 -0
- package/foundation/buttonRenderAdapter-es.js +52 -0
- package/foundation/buttonStyles.d.mts +1 -0
- package/foundation/buttonStyles.mjs +1 -0
- package/foundation/clearable.d.ts +1 -0
- package/foundation/common.messages-es.js +18 -0
- package/foundation/compatHooks.mjs +2 -0
- package/foundation/constants-es.js +3 -0
- package/foundation/dateLocale-es.js +1142 -0
- package/foundation/debounce-es.js +329 -0
- package/foundation/dialogFocus.d.mts +1 -0
- package/foundation/dialogFocus.mjs +66 -0
- package/foundation/filterDataAttributes-es.js +24 -0
- package/foundation/floating-ui.react-es.js +6174 -0
- package/foundation/getMappedSpaceToken-es.js +18 -0
- package/foundation/helpers-es.js +15 -0
- package/foundation/identity-es.js +809 -0
- package/foundation/imageTypes.d.mts +1 -0
- package/foundation/imageTypes.mjs +1 -0
- package/foundation/index-es.js +1186 -0
- package/foundation/isObjectLike-es.js +190 -0
- package/foundation/isSymbol-es.js +33 -0
- package/foundation/isTypedArray-es.js +589 -0
- package/foundation/keysIn-es.js +385 -0
- package/foundation/linkEvents.d.mts +1 -0
- package/foundation/linkEvents.mjs +9 -0
- package/foundation/maxHeight-es.js +22 -0
- package/foundation/mergeClassName-es.js +10 -0
- package/foundation/mergeRefs-es.js +18 -0
- package/foundation/nestedEscape-es.js +91 -0
- package/foundation/noop-es.js +24 -0
- package/foundation/primitives/BottomSheet/BottomSheet.d.ts +37 -0
- package/foundation/primitives/BottomSheet/BottomSheet.types.d.ts +36 -0
- package/foundation/primitives/BottomSheet/index.d.mts +2 -0
- package/foundation/primitives/ComboboxPrimitive/ComboboxPrimitive.d.ts +32 -0
- package/foundation/primitives/ComboboxPrimitive/ComboboxPrimitive.types.d.ts +30 -0
- package/foundation/primitives/ComboboxPrimitive/index.d.mts +2 -0
- package/foundation/primitives/HelperText/HelperText.d.ts +25 -0
- package/foundation/primitives/HelperText/index.d.mts +1 -0
- package/foundation/primitives/OverlaySeparator/OverlaySeparator.d.ts +6 -0
- package/foundation/primitives/OverlaySeparator/index.d.mts +1 -0
- package/foundation/primitives/SelectPrimitive/SelectPrimitive.d.ts +74 -0
- package/foundation/primitives/SelectPrimitive/index.d.mts +2 -0
- package/foundation/primitives/SelectPrimitive/types.d.ts +31 -0
- package/foundation/primitives/index.d.mts +12 -0
- package/foundation/primitives/index.mjs +29 -0
- package/foundation/routerLink.d.mts +3 -0
- package/foundation/routerLink.mjs +1 -0
- package/foundation/scrollEdges-es.js +64 -0
- package/foundation/scrollable-es.js +54 -0
- package/foundation/sharedHelpers/getMappedBreakpointWidth.d.ts +8 -0
- package/foundation/sharedHelpers/types.d.ts +254 -0
- package/foundation/stringifyLocale-es.js +11 -0
- package/foundation/styles.css +16646 -0
- package/foundation/tslib.es6-es.js +97 -0
- package/foundation/unstyledPrimitives/index.d.mts +22 -0
- package/foundation/useActiveLayout-es.js +14 -0
- package/foundation/useBatchSelect-es.js +36 -0
- package/foundation/useChildComponent-es.js +15 -0
- package/foundation/useComponentMessages-es.js +86 -0
- package/foundation/useCompositeListItem-es.js +3955 -0
- package/foundation/useFormFieldFocus-es.js +37 -0
- package/foundation/useFormFieldName-es.js +11 -0
- package/foundation/useLabel-es.js +81 -0
- package/foundation/useRenderElement-es.js +628 -0
- package/foundation/useResponsiveSizing-es.js +8 -0
- package/foundation/useScrollLock-es.js +5746 -0
- package/foundation/useScrollToActive-es.js +581 -0
- package/foundation/utils/isNormalClick.d.ts +6 -0
- package/foundation/utils/isPreviewableImage.d.ts +1 -0
- package/foundation/utils/meta/meta.json +298 -0
- package/foundation.css +67 -0
- package/package.json +540 -4
- package/src/styles.css +181 -0
|
@@ -0,0 +1,1763 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { v as useControlled, s as useTransitionStatus, R as useOpenInteractionType, U as useStore, w as useValueAsRef, d as useStableCallback, c as useIsoLayoutEffect, L as useValueChanged, l as useOpenChangeComplete, V as useClick, W as useDismiss, F as FOCUSABLE_POPUP_PROPS, h as createChangeEventDetails, z as none, B as visuallyHiddenInput, C as visuallyHidden, X as ReactStore, Y as focusOut, Z as outsidePress, _ as pressableTriggerOpenStateMapping, f as useButton, q as useTimeout, $ as getFloatingFocusElement, a0 as contains, o as ownerDocument, a1 as cancelOpen, a2 as FloatingPortal, a3 as InternalBackdrop, a4 as inertValue, a5 as DROPDOWN_COLLISION_AVOIDANCE, a6 as popupStateMapping, t as transitionStatusMapping, a7 as useDirection, a8 as useAnimationFrame, I as getWindow, a9 as webkit, y as addEventListener, n as FloatingFocusManager, aa as rectToClientRect, ab as windowResize, ac as isVirtualClick, ad as itemPress, u as useBaseUiId } from './useScrollLock-es.js';
|
|
3
|
+
import { f as formatErrorMessage, a as useRefWithInit, m as mergeProps, E as EMPTY_OBJECT, b as useMergedRefs, c as EMPTY_ARRAY, u as useRenderElement } from './useRenderElement-es.js';
|
|
4
|
+
import { s as stringifyAsValue, h as hasNullItemLabel, e as compareItemEquality, a as useFormContext, b as useFieldRootContext, c as useLabelableId, d as useRegisterFieldControl, g as findItemIndex, i as useFloatingRootContext, j as useListNavigation, k as useTypeahead, l as useOnFirstRender, m as defaultItemEquality, n as stringifyAsLabel, o as areArraysEqual, f as fieldValidityMapping, u as useLabelableContext, r as resolveAriaLabelledBy, p as isMouseWithinBounds, q as resolveMultipleLabels, t as resolveSelectedLabel, v as useAnchoredPopupScrollLock, w as useAnchorPositioning, x as usePositioner, C as CompositeList, y as platform, z as getDisabledMountTransitionStyles, A as useCompositeListItem, B as removeItem } from './useCompositeListItem-es.js';
|
|
5
|
+
import { g as getMaxScrollOffset, n as normalizeScrollOffset, u as useCSPContext, c as clamp, S as SCROLL_EDGE_TOLERANCE_PX, C as COMPOSITE_KEYS, s as styleDisableScrollbar } from './scrollEdges-es.js';
|
|
6
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
7
|
+
|
|
8
|
+
const ToolbarRootContext = /*#__PURE__*/React.createContext(undefined);
|
|
9
|
+
if (process.env.NODE_ENV !== "production") ToolbarRootContext.displayName = "ToolbarRootContext";
|
|
10
|
+
function useToolbarRootContext(optional) {
|
|
11
|
+
const context = React.useContext(ToolbarRootContext);
|
|
12
|
+
if (context === undefined && !optional) {
|
|
13
|
+
throw new Error(process.env.NODE_ENV !== "production" ? 'Base UI: ToolbarRootContext is missing. Toolbar parts must be placed within <Toolbar.Root>.' : formatErrorMessage(69));
|
|
14
|
+
}
|
|
15
|
+
return context;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Returns a previous value of its argument.
|
|
20
|
+
* @param value Current value.
|
|
21
|
+
* @returns Previous value, or null if there is no previous value.
|
|
22
|
+
*/
|
|
23
|
+
function usePreviousValue(value) {
|
|
24
|
+
const [state, setState] = React.useState({
|
|
25
|
+
current: value,
|
|
26
|
+
previous: null
|
|
27
|
+
});
|
|
28
|
+
if (!Object.is(value, state.current)) {
|
|
29
|
+
setState({
|
|
30
|
+
current: value,
|
|
31
|
+
previous: state.current
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
return state.previous;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function isElementDisabled(element) {
|
|
38
|
+
return element == null || element.hasAttribute('disabled') || element.getAttribute('aria-disabled') === 'true';
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const SelectRootContext = /*#__PURE__*/React.createContext(null);
|
|
42
|
+
if (process.env.NODE_ENV !== "production") SelectRootContext.displayName = "SelectRootContext";
|
|
43
|
+
function useSelectRootContext() {
|
|
44
|
+
const context = React.useContext(SelectRootContext);
|
|
45
|
+
if (context === null) {
|
|
46
|
+
throw new Error(process.env.NODE_ENV !== "production" ? 'Base UI: SelectRootContext is missing. Select parts must be placed within <Select.Root>.' : formatErrorMessage(60));
|
|
47
|
+
}
|
|
48
|
+
return context;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const selectors = {
|
|
52
|
+
id: state => state.id,
|
|
53
|
+
labelId: state => state.labelId,
|
|
54
|
+
modal: state => state.modal,
|
|
55
|
+
items: state => state.items,
|
|
56
|
+
itemToStringLabel: state => state.itemToStringLabel,
|
|
57
|
+
isItemEqualToValue: state => state.isItemEqualToValue,
|
|
58
|
+
value: state => state.value,
|
|
59
|
+
hasSelectedValue: state => {
|
|
60
|
+
const {
|
|
61
|
+
value,
|
|
62
|
+
multiple,
|
|
63
|
+
itemToStringValue
|
|
64
|
+
} = state;
|
|
65
|
+
if (value == null) {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
if (multiple && Array.isArray(value)) {
|
|
69
|
+
return value.length > 0;
|
|
70
|
+
}
|
|
71
|
+
return stringifyAsValue(value, itemToStringValue) !== '';
|
|
72
|
+
},
|
|
73
|
+
hasNullItemLabel: (state, enabled) => {
|
|
74
|
+
return enabled ? hasNullItemLabel(state.items) : false;
|
|
75
|
+
},
|
|
76
|
+
open: state => state.open,
|
|
77
|
+
mounted: state => state.mounted,
|
|
78
|
+
forceMount: state => state.forceMount,
|
|
79
|
+
transitionStatus: state => state.transitionStatus,
|
|
80
|
+
openMethod: state => state.openMethod,
|
|
81
|
+
activeIndex: state => state.activeIndex,
|
|
82
|
+
selectedIndex: state => state.selectedIndex,
|
|
83
|
+
isActive: (state, index) => state.activeIndex === index,
|
|
84
|
+
isSelected: (state, itemValue) => {
|
|
85
|
+
const comparer = state.isItemEqualToValue;
|
|
86
|
+
const storeValue = state.value;
|
|
87
|
+
if (state.multiple) {
|
|
88
|
+
return Array.isArray(storeValue) && storeValue.some(selectedItem => compareItemEquality(itemValue, selectedItem, comparer));
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// The value is the source of truth: a stale `selectedIndex` (e.g. the controlled
|
|
92
|
+
// value changes while the popup is open, where the index sync is deferred) must not
|
|
93
|
+
// keep a previously selected item marked as selected.
|
|
94
|
+
return compareItemEquality(itemValue, storeValue, comparer);
|
|
95
|
+
},
|
|
96
|
+
isSelectedByFocus: (state, index) => {
|
|
97
|
+
return state.selectedIndex === index;
|
|
98
|
+
},
|
|
99
|
+
popupProps: state => state.popupProps,
|
|
100
|
+
triggerProps: state => state.triggerProps,
|
|
101
|
+
triggerElement: state => state.triggerElement,
|
|
102
|
+
positionerElement: state => state.positionerElement,
|
|
103
|
+
listElement: state => state.listElement,
|
|
104
|
+
popupSide: state => state.popupSide,
|
|
105
|
+
scrollUpArrowVisible: state => state.scrollUpArrowVisible,
|
|
106
|
+
scrollDownArrowVisible: state => state.scrollDownArrowVisible,
|
|
107
|
+
hasScrollArrows: state => state.hasScrollArrows
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
function SelectRoot(props) {
|
|
111
|
+
const {
|
|
112
|
+
id,
|
|
113
|
+
value: valueProp,
|
|
114
|
+
defaultValue = null,
|
|
115
|
+
onValueChange,
|
|
116
|
+
open: openProp,
|
|
117
|
+
defaultOpen = false,
|
|
118
|
+
onOpenChange,
|
|
119
|
+
name: nameProp,
|
|
120
|
+
form,
|
|
121
|
+
autoComplete,
|
|
122
|
+
disabled: disabledProp = false,
|
|
123
|
+
readOnly = false,
|
|
124
|
+
required = false,
|
|
125
|
+
modal = true,
|
|
126
|
+
actionsRef,
|
|
127
|
+
inputRef,
|
|
128
|
+
onOpenChangeComplete,
|
|
129
|
+
items,
|
|
130
|
+
multiple = false,
|
|
131
|
+
itemToStringLabel,
|
|
132
|
+
itemToStringValue,
|
|
133
|
+
isItemEqualToValue = defaultItemEquality,
|
|
134
|
+
highlightItemOnHover = true,
|
|
135
|
+
children
|
|
136
|
+
} = props;
|
|
137
|
+
const {
|
|
138
|
+
clearErrors
|
|
139
|
+
} = useFormContext();
|
|
140
|
+
const {
|
|
141
|
+
setDirty,
|
|
142
|
+
setTouched,
|
|
143
|
+
setFocused,
|
|
144
|
+
validityData,
|
|
145
|
+
setFilled,
|
|
146
|
+
name: fieldName,
|
|
147
|
+
disabled: fieldDisabled,
|
|
148
|
+
validation,
|
|
149
|
+
validationMode
|
|
150
|
+
} = useFieldRootContext();
|
|
151
|
+
const generatedId = useLabelableId({
|
|
152
|
+
id
|
|
153
|
+
});
|
|
154
|
+
const disabled = fieldDisabled || disabledProp;
|
|
155
|
+
const name = fieldName ?? nameProp;
|
|
156
|
+
const [value, setValueUnwrapped] = useControlled({
|
|
157
|
+
controlled: valueProp,
|
|
158
|
+
default: multiple ? defaultValue ?? EMPTY_ARRAY : defaultValue,
|
|
159
|
+
name: 'Select',
|
|
160
|
+
state: 'value'
|
|
161
|
+
});
|
|
162
|
+
const [open, setOpenUnwrapped] = useControlled({
|
|
163
|
+
controlled: openProp,
|
|
164
|
+
default: defaultOpen,
|
|
165
|
+
name: 'Select',
|
|
166
|
+
state: 'open'
|
|
167
|
+
});
|
|
168
|
+
const listRef = React.useRef([]);
|
|
169
|
+
const labelsRef = React.useRef([]);
|
|
170
|
+
const popupRef = React.useRef(null);
|
|
171
|
+
const scrollHandlerRef = React.useRef(null);
|
|
172
|
+
const scrollArrowsMountedCountRef = React.useRef(0);
|
|
173
|
+
const valueRef = React.useRef(null);
|
|
174
|
+
const valuesRef = React.useRef([]);
|
|
175
|
+
const typingRef = React.useRef(false);
|
|
176
|
+
const firstItemTextRef = React.useRef(null);
|
|
177
|
+
const selectedItemTextRef = React.useRef(null);
|
|
178
|
+
const selectionRef = React.useRef({
|
|
179
|
+
allowSelectedMouseUp: false,
|
|
180
|
+
allowUnselectedMouseUp: false,
|
|
181
|
+
dragY: 0
|
|
182
|
+
});
|
|
183
|
+
const alignItemWithTriggerActiveRef = React.useRef(false);
|
|
184
|
+
const {
|
|
185
|
+
mounted,
|
|
186
|
+
setMounted,
|
|
187
|
+
transitionStatus
|
|
188
|
+
} = useTransitionStatus(open);
|
|
189
|
+
const {
|
|
190
|
+
openMethod,
|
|
191
|
+
triggerProps: interactionTypeProps
|
|
192
|
+
} = useOpenInteractionType(open);
|
|
193
|
+
const store = useRefWithInit(() => new ReactStore({
|
|
194
|
+
id: generatedId,
|
|
195
|
+
labelId: undefined,
|
|
196
|
+
modal,
|
|
197
|
+
multiple,
|
|
198
|
+
itemToStringLabel,
|
|
199
|
+
itemToStringValue,
|
|
200
|
+
isItemEqualToValue,
|
|
201
|
+
value,
|
|
202
|
+
open,
|
|
203
|
+
mounted,
|
|
204
|
+
transitionStatus,
|
|
205
|
+
items,
|
|
206
|
+
forceMount: false,
|
|
207
|
+
openMethod: null,
|
|
208
|
+
activeIndex: null,
|
|
209
|
+
selectedIndex: null,
|
|
210
|
+
popupProps: {},
|
|
211
|
+
triggerProps: {},
|
|
212
|
+
triggerElement: null,
|
|
213
|
+
positionerElement: null,
|
|
214
|
+
listElement: null,
|
|
215
|
+
popupSide: null,
|
|
216
|
+
scrollUpArrowVisible: false,
|
|
217
|
+
scrollDownArrowVisible: false,
|
|
218
|
+
hasScrollArrows: false
|
|
219
|
+
})).current;
|
|
220
|
+
const activeIndex = useStore(store, selectors.activeIndex);
|
|
221
|
+
const selectedIndex = useStore(store, selectors.selectedIndex);
|
|
222
|
+
const triggerElement = useStore(store, selectors.triggerElement);
|
|
223
|
+
const positionerElement = useStore(store, selectors.positionerElement);
|
|
224
|
+
const previousOpenMethod = usePreviousValue(openMethod);
|
|
225
|
+
const renderedOpenMethod = openMethod ?? previousOpenMethod;
|
|
226
|
+
const serializedValue = React.useMemo(() => {
|
|
227
|
+
// In multiple mode the shared input is nameless; per-value entries are submitted via
|
|
228
|
+
// `hiddenInputs`. Its value is therefore irrelevant, and passing the whole array to
|
|
229
|
+
// `stringifyAsValue` would invoke a user `itemToStringValue` with an array it doesn't expect.
|
|
230
|
+
if (multiple) {
|
|
231
|
+
return '';
|
|
232
|
+
}
|
|
233
|
+
return stringifyAsValue(value, itemToStringValue);
|
|
234
|
+
}, [multiple, value, itemToStringValue]);
|
|
235
|
+
const fieldStringValue = React.useMemo(() => {
|
|
236
|
+
if (multiple && Array.isArray(value)) {
|
|
237
|
+
return value.map(currentValue => stringifyAsValue(currentValue, itemToStringValue));
|
|
238
|
+
}
|
|
239
|
+
return stringifyAsValue(value, itemToStringValue);
|
|
240
|
+
}, [multiple, value, itemToStringValue]);
|
|
241
|
+
const controlRef = useValueAsRef(triggerElement);
|
|
242
|
+
const getStringifiedValueForForm = useStableCallback(() => fieldStringValue);
|
|
243
|
+
useRegisterFieldControl(controlRef, generatedId, value, getStringifiedValueForForm, !disabled, nameProp);
|
|
244
|
+
const initialValueRef = React.useRef(value);
|
|
245
|
+
// Mirror the `hasSelectedValue` store selector so the Field's filled state agrees with the
|
|
246
|
+
// trigger/value placeholder semantics (a value serializing to `''` counts as empty).
|
|
247
|
+
const hasSelectedValue = multiple ? Array.isArray(value) && value.length > 0 : value != null && serializedValue !== '';
|
|
248
|
+
useIsoLayoutEffect(() => {
|
|
249
|
+
setFilled(hasSelectedValue);
|
|
250
|
+
}, [hasSelectedValue, setFilled]);
|
|
251
|
+
useIsoLayoutEffect(function syncSelectedIndex() {
|
|
252
|
+
let target = value;
|
|
253
|
+
let empty = false;
|
|
254
|
+
if (multiple) {
|
|
255
|
+
const currentValue = Array.isArray(value) ? value : [];
|
|
256
|
+
empty = currentValue.length === 0;
|
|
257
|
+
target = currentValue[currentValue.length - 1];
|
|
258
|
+
}
|
|
259
|
+
const index = empty ? -1 : findItemIndex(valuesRef.current, target, isItemEqualToValue);
|
|
260
|
+
const nextIndex = index === -1 ? null : index;
|
|
261
|
+
if (nextIndex === null) {
|
|
262
|
+
selectedItemTextRef.current = null;
|
|
263
|
+
}
|
|
264
|
+
if (open) {
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
store.set('selectedIndex', nextIndex);
|
|
268
|
+
}, [multiple, open, value, isItemEqualToValue, store]);
|
|
269
|
+
function isSelectedValueDirty(currentValue) {
|
|
270
|
+
const initialValue = validityData.initialValue;
|
|
271
|
+
if (Array.isArray(currentValue) && Array.isArray(initialValue)) {
|
|
272
|
+
return !areArraysEqual(currentValue, initialValue, (itemValue, initialItemValue) => compareItemEquality(itemValue, initialItemValue, isItemEqualToValue));
|
|
273
|
+
}
|
|
274
|
+
return currentValue !== initialValue;
|
|
275
|
+
}
|
|
276
|
+
useValueChanged(value, () => {
|
|
277
|
+
clearErrors(name);
|
|
278
|
+
setDirty(isSelectedValueDirty(value));
|
|
279
|
+
validation.change(value);
|
|
280
|
+
});
|
|
281
|
+
const setOpen = useStableCallback((nextOpen, eventDetails) => {
|
|
282
|
+
onOpenChange?.(nextOpen, eventDetails);
|
|
283
|
+
if (eventDetails.isCanceled) {
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
setOpenUnwrapped(nextOpen);
|
|
287
|
+
if (!nextOpen && (eventDetails.reason === focusOut || eventDetails.reason === outsidePress)) {
|
|
288
|
+
setTouched(true);
|
|
289
|
+
setFocused(false);
|
|
290
|
+
if (validationMode === 'onBlur') {
|
|
291
|
+
validation.commit(value);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
});
|
|
295
|
+
const handleUnmount = useStableCallback(() => {
|
|
296
|
+
setMounted(false);
|
|
297
|
+
store.update({
|
|
298
|
+
activeIndex: null,
|
|
299
|
+
openMethod: null,
|
|
300
|
+
scrollUpArrowVisible: false,
|
|
301
|
+
scrollDownArrowVisible: false
|
|
302
|
+
});
|
|
303
|
+
onOpenChangeComplete?.(false);
|
|
304
|
+
});
|
|
305
|
+
useOpenChangeComplete({
|
|
306
|
+
enabled: !actionsRef,
|
|
307
|
+
open,
|
|
308
|
+
ref: popupRef,
|
|
309
|
+
onComplete() {
|
|
310
|
+
if (!open) {
|
|
311
|
+
handleUnmount();
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
});
|
|
315
|
+
React.useImperativeHandle(actionsRef, () => ({
|
|
316
|
+
unmount: handleUnmount
|
|
317
|
+
}), [handleUnmount]);
|
|
318
|
+
const setValue = useStableCallback((nextValue, eventDetails) => {
|
|
319
|
+
onValueChange?.(nextValue, eventDetails);
|
|
320
|
+
if (eventDetails.isCanceled) {
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
setValueUnwrapped(nextValue);
|
|
324
|
+
});
|
|
325
|
+
const handleScrollArrowVisibility = useStableCallback(scroller => {
|
|
326
|
+
const maxScrollTop = getMaxScrollOffset(scroller.scrollHeight, scroller.clientHeight);
|
|
327
|
+
const scrollTop = normalizeScrollOffset(scroller.scrollTop, maxScrollTop);
|
|
328
|
+
const shouldShowUp = scrollTop > 0;
|
|
329
|
+
const shouldShowDown = scrollTop < maxScrollTop;
|
|
330
|
+
store.set('scrollUpArrowVisible', shouldShowUp);
|
|
331
|
+
store.set('scrollDownArrowVisible', shouldShowDown);
|
|
332
|
+
});
|
|
333
|
+
const floatingContext = useFloatingRootContext({
|
|
334
|
+
open,
|
|
335
|
+
onOpenChange: setOpen,
|
|
336
|
+
elements: {
|
|
337
|
+
reference: triggerElement,
|
|
338
|
+
floating: positionerElement
|
|
339
|
+
}
|
|
340
|
+
});
|
|
341
|
+
const click = useClick(floatingContext, {
|
|
342
|
+
enabled: !readOnly && !disabled,
|
|
343
|
+
event: 'mousedown'
|
|
344
|
+
});
|
|
345
|
+
const dismiss = useDismiss(floatingContext);
|
|
346
|
+
const listNavigation = useListNavigation(floatingContext, {
|
|
347
|
+
enabled: !readOnly && !disabled,
|
|
348
|
+
listRef,
|
|
349
|
+
activeIndex,
|
|
350
|
+
selectedIndex,
|
|
351
|
+
disabledIndices: EMPTY_ARRAY,
|
|
352
|
+
onNavigate(nextActiveIndex) {
|
|
353
|
+
// Retain the highlight while transitioning out.
|
|
354
|
+
if (nextActiveIndex === null && !open) {
|
|
355
|
+
return;
|
|
356
|
+
}
|
|
357
|
+
store.set('activeIndex', nextActiveIndex);
|
|
358
|
+
},
|
|
359
|
+
focusItemOnHover: highlightItemOnHover
|
|
360
|
+
});
|
|
361
|
+
const typeahead = useTypeahead(floatingContext, {
|
|
362
|
+
enabled: !readOnly && !disabled && (open || !multiple),
|
|
363
|
+
listRef: labelsRef,
|
|
364
|
+
activeIndex,
|
|
365
|
+
selectedIndex,
|
|
366
|
+
// Skip disabled items while matching so typeahead advances to the next selectable item
|
|
367
|
+
// (a click can never select a disabled item and native `<select>` skips them too). Resolve
|
|
368
|
+
// the disabled state from the element via the attribute-only `isElementDisabled` so the
|
|
369
|
+
// hidden, force-mounted items used for closed-trigger typeahead aren't dropped by the
|
|
370
|
+
// `elementsRef`/visibility filter that `disabledIndices` deliberately sidesteps.
|
|
371
|
+
disabledIndices: index => isElementDisabled(listRef.current[index]),
|
|
372
|
+
onMatch(index) {
|
|
373
|
+
if (open) {
|
|
374
|
+
store.set('activeIndex', index);
|
|
375
|
+
} else {
|
|
376
|
+
setValue(valuesRef.current[index], createChangeEventDetails(none));
|
|
377
|
+
}
|
|
378
|
+
},
|
|
379
|
+
onTyping(typing) {
|
|
380
|
+
typingRef.current = typing;
|
|
381
|
+
}
|
|
382
|
+
});
|
|
383
|
+
|
|
384
|
+
// `Select.Trigger` applies the id itself from the store, so it's deliberately not merged here.
|
|
385
|
+
const mergedTriggerProps = React.useMemo(() => mergeProps(typeahead.reference, listNavigation.reference, dismiss.reference, click.reference, interactionTypeProps), [click.reference, typeahead.reference, listNavigation.reference, dismiss.reference, interactionTypeProps]);
|
|
386
|
+
const popupProps = React.useMemo(() => mergeProps(FOCUSABLE_POPUP_PROPS, typeahead.floating, listNavigation.floating, dismiss.floating), [typeahead.floating, listNavigation.floating, dismiss.floating]);
|
|
387
|
+
const itemProps = listNavigation.item ?? EMPTY_OBJECT;
|
|
388
|
+
useOnFirstRender(() => {
|
|
389
|
+
store.update({
|
|
390
|
+
popupProps,
|
|
391
|
+
triggerProps: mergedTriggerProps
|
|
392
|
+
});
|
|
393
|
+
});
|
|
394
|
+
store.useSyncedValues({
|
|
395
|
+
id: generatedId,
|
|
396
|
+
modal,
|
|
397
|
+
multiple,
|
|
398
|
+
value,
|
|
399
|
+
open,
|
|
400
|
+
mounted,
|
|
401
|
+
transitionStatus,
|
|
402
|
+
popupProps,
|
|
403
|
+
triggerProps: mergedTriggerProps,
|
|
404
|
+
items,
|
|
405
|
+
itemToStringLabel,
|
|
406
|
+
itemToStringValue,
|
|
407
|
+
isItemEqualToValue,
|
|
408
|
+
openMethod: renderedOpenMethod
|
|
409
|
+
});
|
|
410
|
+
const contextValue = React.useMemo(() => ({
|
|
411
|
+
store,
|
|
412
|
+
floatingContext,
|
|
413
|
+
required,
|
|
414
|
+
disabled,
|
|
415
|
+
readOnly,
|
|
416
|
+
multiple,
|
|
417
|
+
highlightItemOnHover,
|
|
418
|
+
setValue,
|
|
419
|
+
setOpen,
|
|
420
|
+
listRef,
|
|
421
|
+
popupRef,
|
|
422
|
+
scrollHandlerRef,
|
|
423
|
+
handleScrollArrowVisibility,
|
|
424
|
+
scrollArrowsMountedCountRef,
|
|
425
|
+
itemProps,
|
|
426
|
+
valueRef,
|
|
427
|
+
valuesRef,
|
|
428
|
+
labelsRef,
|
|
429
|
+
typingRef,
|
|
430
|
+
selectionRef,
|
|
431
|
+
firstItemTextRef,
|
|
432
|
+
selectedItemTextRef,
|
|
433
|
+
validation,
|
|
434
|
+
onOpenChangeComplete,
|
|
435
|
+
alignItemWithTriggerActiveRef,
|
|
436
|
+
initialValueRef
|
|
437
|
+
}), [store, floatingContext, required, disabled, readOnly, multiple, highlightItemOnHover, setValue, setOpen, itemProps, validation, onOpenChangeComplete, handleScrollArrowVisibility]);
|
|
438
|
+
const ref = useMergedRefs(inputRef, validation.inputRef);
|
|
439
|
+
const hiddenInputName = multiple ? undefined : name;
|
|
440
|
+
const hiddenInputs = React.useMemo(() => {
|
|
441
|
+
if (!multiple || !Array.isArray(value) || !name) {
|
|
442
|
+
return null;
|
|
443
|
+
}
|
|
444
|
+
return value.map(v => {
|
|
445
|
+
const currentSerializedValue = stringifyAsValue(v, itemToStringValue);
|
|
446
|
+
return /*#__PURE__*/jsx("input", {
|
|
447
|
+
type: "hidden",
|
|
448
|
+
form: form,
|
|
449
|
+
name: name,
|
|
450
|
+
value: currentSerializedValue,
|
|
451
|
+
disabled: disabled
|
|
452
|
+
}, currentSerializedValue);
|
|
453
|
+
});
|
|
454
|
+
}, [multiple, value, form, name, itemToStringValue, disabled]);
|
|
455
|
+
return /*#__PURE__*/jsxs(SelectRootContext.Provider, {
|
|
456
|
+
value: contextValue,
|
|
457
|
+
children: [children, /*#__PURE__*/jsx("input", {
|
|
458
|
+
...validation.getValidationProps(disabled, {
|
|
459
|
+
onFocus() {
|
|
460
|
+
// Move focus to the trigger element when the hidden input is focused.
|
|
461
|
+
store.state.triggerElement?.focus({
|
|
462
|
+
// Supported in Chrome from 144 (January 2026)
|
|
463
|
+
focusVisible: true
|
|
464
|
+
});
|
|
465
|
+
},
|
|
466
|
+
// Handle browser autofill.
|
|
467
|
+
onChange(event) {
|
|
468
|
+
// Workaround for https://github.com/react/react/issues/9023
|
|
469
|
+
if (event.nativeEvent.defaultPrevented || disabled || readOnly) {
|
|
470
|
+
return;
|
|
471
|
+
}
|
|
472
|
+
const nextValue = event.currentTarget.value;
|
|
473
|
+
const details = createChangeEventDetails(none, event.nativeEvent);
|
|
474
|
+
function handleChange() {
|
|
475
|
+
if (multiple) {
|
|
476
|
+
// Browser autofill only writes a single scalar value.
|
|
477
|
+
return;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
// Preserve the original serialized matching, then fall back to rendered text,
|
|
481
|
+
// which browsers can autofill for primitive values like `value="US">United States`.
|
|
482
|
+
const nextValueLower = nextValue.toLowerCase();
|
|
483
|
+
let matchingIndex = valuesRef.current.findIndex(candidate => stringifyAsValue(candidate, itemToStringValue).toLowerCase() === nextValueLower || stringifyAsLabel(candidate, itemToStringLabel).toLowerCase() === nextValueLower);
|
|
484
|
+
if (matchingIndex === -1) {
|
|
485
|
+
matchingIndex = valuesRef.current.findIndex((_, index) => {
|
|
486
|
+
const renderedLabel = labelsRef.current[index];
|
|
487
|
+
return renderedLabel != null && renderedLabel.toLowerCase() === nextValueLower;
|
|
488
|
+
});
|
|
489
|
+
}
|
|
490
|
+
const matchingValue = valuesRef.current[matchingIndex];
|
|
491
|
+
if (matchingValue != null) {
|
|
492
|
+
// `setValue` may be canceled by `onValueChange`; rely on `useValueChanged` to
|
|
493
|
+
// mark the field dirty and run validation only when the value actually changes.
|
|
494
|
+
setValue(matchingValue, details);
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
store.set('forceMount', true);
|
|
498
|
+
queueMicrotask(handleChange);
|
|
499
|
+
}
|
|
500
|
+
}),
|
|
501
|
+
id: generatedId && hiddenInputName == null ? `${generatedId}-hidden-input` : undefined,
|
|
502
|
+
form: form,
|
|
503
|
+
name: hiddenInputName,
|
|
504
|
+
autoComplete: autoComplete,
|
|
505
|
+
value: serializedValue,
|
|
506
|
+
disabled: disabled,
|
|
507
|
+
required: required && !(multiple && hasSelectedValue),
|
|
508
|
+
readOnly: readOnly,
|
|
509
|
+
ref: ref,
|
|
510
|
+
style: name ? visuallyHiddenInput : visuallyHidden,
|
|
511
|
+
tabIndex: -1,
|
|
512
|
+
"aria-hidden": true,
|
|
513
|
+
suppressHydrationWarning: true
|
|
514
|
+
}), hiddenInputs]
|
|
515
|
+
});
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
const SELECTED_DELAY = 400;
|
|
519
|
+
const stateAttributesMapping$2 = {
|
|
520
|
+
...pressableTriggerOpenStateMapping,
|
|
521
|
+
...fieldValidityMapping,
|
|
522
|
+
popupSide: side => side ? {
|
|
523
|
+
'data-popup-side': side
|
|
524
|
+
} : null,
|
|
525
|
+
value: () => null
|
|
526
|
+
};
|
|
527
|
+
|
|
528
|
+
/**
|
|
529
|
+
* A button that opens the select popup.
|
|
530
|
+
* Renders a `<button>` element.
|
|
531
|
+
*
|
|
532
|
+
* Documentation: [Base UI Select](https://base-ui.com/react/components/select)
|
|
533
|
+
*/
|
|
534
|
+
const SelectTrigger = /*#__PURE__*/React.forwardRef(function SelectTrigger(componentProps, forwardedRef) {
|
|
535
|
+
const {
|
|
536
|
+
render,
|
|
537
|
+
className,
|
|
538
|
+
id: idProp,
|
|
539
|
+
disabled: disabledProp = false,
|
|
540
|
+
nativeButton = true,
|
|
541
|
+
style,
|
|
542
|
+
...elementProps
|
|
543
|
+
} = componentProps;
|
|
544
|
+
const {
|
|
545
|
+
setTouched,
|
|
546
|
+
setFocused,
|
|
547
|
+
validationMode,
|
|
548
|
+
state: fieldState,
|
|
549
|
+
disabled: fieldDisabled
|
|
550
|
+
} = useFieldRootContext();
|
|
551
|
+
const {
|
|
552
|
+
labelId: fieldLabelId
|
|
553
|
+
} = useLabelableContext();
|
|
554
|
+
const {
|
|
555
|
+
store,
|
|
556
|
+
setOpen,
|
|
557
|
+
selectionRef,
|
|
558
|
+
validation,
|
|
559
|
+
readOnly,
|
|
560
|
+
required,
|
|
561
|
+
alignItemWithTriggerActiveRef,
|
|
562
|
+
disabled: selectDisabled
|
|
563
|
+
} = useSelectRootContext();
|
|
564
|
+
const disabled = fieldDisabled || selectDisabled || disabledProp;
|
|
565
|
+
const open = useStore(store, selectors.open);
|
|
566
|
+
const mounted = useStore(store, selectors.mounted);
|
|
567
|
+
const value = useStore(store, selectors.value);
|
|
568
|
+
const triggerProps = useStore(store, selectors.triggerProps);
|
|
569
|
+
const positionerElement = useStore(store, selectors.positionerElement);
|
|
570
|
+
const listElement = useStore(store, selectors.listElement);
|
|
571
|
+
const popupSideValue = useStore(store, selectors.popupSide);
|
|
572
|
+
const rootId = useStore(store, selectors.id);
|
|
573
|
+
const selectLabelId = useStore(store, selectors.labelId);
|
|
574
|
+
const hasSelectedValue = useStore(store, selectors.hasSelectedValue);
|
|
575
|
+
const popupSide = mounted && positionerElement ? popupSideValue : null;
|
|
576
|
+
const id = idProp ?? rootId;
|
|
577
|
+
const ariaLabelledBy = resolveAriaLabelledBy(fieldLabelId, selectLabelId);
|
|
578
|
+
useLabelableId({
|
|
579
|
+
id
|
|
580
|
+
});
|
|
581
|
+
const positionerRef = useValueAsRef(positionerElement);
|
|
582
|
+
const triggerRef = React.useRef(null);
|
|
583
|
+
const {
|
|
584
|
+
getButtonProps,
|
|
585
|
+
buttonRef
|
|
586
|
+
} = useButton({
|
|
587
|
+
disabled,
|
|
588
|
+
native: nativeButton
|
|
589
|
+
});
|
|
590
|
+
const setTriggerElement = store.useStateSetter('triggerElement');
|
|
591
|
+
const timeoutFocus = useTimeout();
|
|
592
|
+
const timeoutMouseDown = useTimeout();
|
|
593
|
+
const selectedDelayTimeout = useTimeout();
|
|
594
|
+
React.useEffect(() => {
|
|
595
|
+
if (open) {
|
|
596
|
+
// A mousedown on the trigger can open the popup under the cursor. Keep mouseup selection
|
|
597
|
+
// disabled briefly so releasing over either the selected item or a neighboring item doesn't
|
|
598
|
+
// commit an accidental selection. SelectItem can still opt into unselected mouseup sooner
|
|
599
|
+
// after a real drag over the item.
|
|
600
|
+
selectedDelayTimeout.start(SELECTED_DELAY, () => {
|
|
601
|
+
selectionRef.current.allowUnselectedMouseUp = true;
|
|
602
|
+
selectionRef.current.allowSelectedMouseUp = true;
|
|
603
|
+
});
|
|
604
|
+
return () => {
|
|
605
|
+
selectedDelayTimeout.clear();
|
|
606
|
+
};
|
|
607
|
+
}
|
|
608
|
+
selectionRef.current = {
|
|
609
|
+
allowSelectedMouseUp: false,
|
|
610
|
+
allowUnselectedMouseUp: false,
|
|
611
|
+
dragY: 0
|
|
612
|
+
};
|
|
613
|
+
timeoutMouseDown.clear();
|
|
614
|
+
return undefined;
|
|
615
|
+
}, [open, selectionRef, timeoutMouseDown, selectedDelayTimeout]);
|
|
616
|
+
const mergedProps = mergeProps(triggerProps, {
|
|
617
|
+
id,
|
|
618
|
+
role: 'combobox',
|
|
619
|
+
'aria-expanded': open,
|
|
620
|
+
'aria-haspopup': 'listbox',
|
|
621
|
+
'aria-controls': open ? listElement?.id ?? getFloatingFocusElement(positionerElement)?.id : undefined,
|
|
622
|
+
'aria-labelledby': ariaLabelledBy,
|
|
623
|
+
'aria-readonly': readOnly || undefined,
|
|
624
|
+
'aria-required': required || undefined,
|
|
625
|
+
tabIndex: disabled ? -1 : 0,
|
|
626
|
+
onFocus(event) {
|
|
627
|
+
setFocused(true);
|
|
628
|
+
|
|
629
|
+
// The popup element shouldn't obscure the focused trigger.
|
|
630
|
+
if (open && alignItemWithTriggerActiveRef.current) {
|
|
631
|
+
setOpen(false, createChangeEventDetails(none, event.nativeEvent));
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
// Saves a re-render on initial click: `forceMount === true` mounts
|
|
635
|
+
// the items before `open === true`. We could sync those cycles better
|
|
636
|
+
// without a timeout, but this is enough for now.
|
|
637
|
+
timeoutFocus.start(0, () => {
|
|
638
|
+
store.set('forceMount', true);
|
|
639
|
+
});
|
|
640
|
+
},
|
|
641
|
+
onBlur(event) {
|
|
642
|
+
// If focus is moving into the popup, don't count it as a blur.
|
|
643
|
+
if (contains(positionerElement, event.relatedTarget)) {
|
|
644
|
+
return;
|
|
645
|
+
}
|
|
646
|
+
setTouched(true);
|
|
647
|
+
setFocused(false);
|
|
648
|
+
if (validationMode === 'onBlur') {
|
|
649
|
+
validation.commit(value);
|
|
650
|
+
}
|
|
651
|
+
},
|
|
652
|
+
onMouseDown(event) {
|
|
653
|
+
if (open) {
|
|
654
|
+
return;
|
|
655
|
+
}
|
|
656
|
+
const doc = ownerDocument(event.currentTarget);
|
|
657
|
+
function handleMouseUp(mouseEvent) {
|
|
658
|
+
if (!triggerRef.current) {
|
|
659
|
+
return;
|
|
660
|
+
}
|
|
661
|
+
const mouseUpTarget = mouseEvent.target;
|
|
662
|
+
|
|
663
|
+
// Don't treat the release as an outside press when it lands on the trigger or inside
|
|
664
|
+
// the popup positioner (or their children).
|
|
665
|
+
if (contains(triggerRef.current, mouseUpTarget) || contains(positionerRef.current, mouseUpTarget)) {
|
|
666
|
+
return;
|
|
667
|
+
}
|
|
668
|
+
if (isMouseWithinBounds(mouseEvent, triggerRef.current)) {
|
|
669
|
+
return;
|
|
670
|
+
}
|
|
671
|
+
setOpen(false, createChangeEventDetails(cancelOpen, mouseEvent));
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
// Firefox can fire this upon mousedown
|
|
675
|
+
timeoutMouseDown.start(0, () => {
|
|
676
|
+
doc.addEventListener('mouseup', handleMouseUp, {
|
|
677
|
+
once: true
|
|
678
|
+
});
|
|
679
|
+
});
|
|
680
|
+
}
|
|
681
|
+
}, elementProps, getButtonProps);
|
|
682
|
+
const props = validation.getValidationProps(disabled, mergedProps);
|
|
683
|
+
|
|
684
|
+
// ensure nested useButton does not overwrite the combobox role:
|
|
685
|
+
// <Toolbar.Button render={<Select.Trigger />} />
|
|
686
|
+
props.role = 'combobox';
|
|
687
|
+
const state = {
|
|
688
|
+
...fieldState,
|
|
689
|
+
open,
|
|
690
|
+
disabled,
|
|
691
|
+
value,
|
|
692
|
+
readOnly,
|
|
693
|
+
popupSide,
|
|
694
|
+
placeholder: !hasSelectedValue
|
|
695
|
+
};
|
|
696
|
+
return useRenderElement('button', componentProps, {
|
|
697
|
+
ref: [forwardedRef, triggerRef, buttonRef, setTriggerElement],
|
|
698
|
+
state,
|
|
699
|
+
stateAttributesMapping: stateAttributesMapping$2,
|
|
700
|
+
props
|
|
701
|
+
});
|
|
702
|
+
});
|
|
703
|
+
if (process.env.NODE_ENV !== "production") SelectTrigger.displayName = "SelectTrigger";
|
|
704
|
+
|
|
705
|
+
const stateAttributesMapping$1 = {
|
|
706
|
+
value: () => null
|
|
707
|
+
};
|
|
708
|
+
|
|
709
|
+
/**
|
|
710
|
+
* A text label of the currently selected item.
|
|
711
|
+
* Renders a `<span>` element.
|
|
712
|
+
*
|
|
713
|
+
* Documentation: [Base UI Select](https://base-ui.com/react/components/select)
|
|
714
|
+
*/
|
|
715
|
+
const SelectValue = /*#__PURE__*/React.forwardRef(function SelectValue(componentProps, forwardedRef) {
|
|
716
|
+
const {
|
|
717
|
+
className,
|
|
718
|
+
render,
|
|
719
|
+
children: childrenProp,
|
|
720
|
+
placeholder,
|
|
721
|
+
style,
|
|
722
|
+
...elementProps
|
|
723
|
+
} = componentProps;
|
|
724
|
+
const {
|
|
725
|
+
store,
|
|
726
|
+
valueRef
|
|
727
|
+
} = useSelectRootContext();
|
|
728
|
+
const value = useStore(store, selectors.value);
|
|
729
|
+
const items = useStore(store, selectors.items);
|
|
730
|
+
const itemToStringLabel = useStore(store, selectors.itemToStringLabel);
|
|
731
|
+
const hasSelectedValue = useStore(store, selectors.hasSelectedValue);
|
|
732
|
+
const shouldCheckNullItemLabel = !hasSelectedValue && placeholder != null && childrenProp == null;
|
|
733
|
+
const hasNullLabel = useStore(store, selectors.hasNullItemLabel, shouldCheckNullItemLabel);
|
|
734
|
+
const state = {
|
|
735
|
+
value,
|
|
736
|
+
placeholder: !hasSelectedValue
|
|
737
|
+
};
|
|
738
|
+
let children = null;
|
|
739
|
+
if (typeof childrenProp === 'function') {
|
|
740
|
+
children = childrenProp(value);
|
|
741
|
+
} else if (childrenProp != null) {
|
|
742
|
+
children = childrenProp;
|
|
743
|
+
} else if (shouldCheckNullItemLabel && !hasNullLabel) {
|
|
744
|
+
children = placeholder;
|
|
745
|
+
} else if (Array.isArray(value)) {
|
|
746
|
+
children = resolveMultipleLabels(value, items, itemToStringLabel);
|
|
747
|
+
} else {
|
|
748
|
+
children = resolveSelectedLabel(value, items, itemToStringLabel);
|
|
749
|
+
}
|
|
750
|
+
const element = useRenderElement('span', componentProps, {
|
|
751
|
+
state,
|
|
752
|
+
ref: [forwardedRef, valueRef],
|
|
753
|
+
props: [{
|
|
754
|
+
children
|
|
755
|
+
}, elementProps],
|
|
756
|
+
stateAttributesMapping: stateAttributesMapping$1
|
|
757
|
+
});
|
|
758
|
+
return element;
|
|
759
|
+
});
|
|
760
|
+
if (process.env.NODE_ENV !== "production") SelectValue.displayName = "SelectValue";
|
|
761
|
+
|
|
762
|
+
const SelectPortal = /*#__PURE__*/React.forwardRef(function SelectPortal(portalProps, forwardedRef) {
|
|
763
|
+
const {
|
|
764
|
+
store
|
|
765
|
+
} = useSelectRootContext();
|
|
766
|
+
const mounted = useStore(store, selectors.mounted);
|
|
767
|
+
const forceMount = useStore(store, selectors.forceMount);
|
|
768
|
+
const shouldRender = mounted || forceMount;
|
|
769
|
+
if (!shouldRender) {
|
|
770
|
+
return null;
|
|
771
|
+
}
|
|
772
|
+
return /*#__PURE__*/jsx(FloatingPortal, {
|
|
773
|
+
ref: forwardedRef,
|
|
774
|
+
...portalProps
|
|
775
|
+
});
|
|
776
|
+
});
|
|
777
|
+
if (process.env.NODE_ENV !== "production") SelectPortal.displayName = "SelectPortal";
|
|
778
|
+
|
|
779
|
+
const SelectPositionerContext = /*#__PURE__*/React.createContext(undefined);
|
|
780
|
+
if (process.env.NODE_ENV !== "production") SelectPositionerContext.displayName = "SelectPositionerContext";
|
|
781
|
+
function useSelectPositionerContext() {
|
|
782
|
+
const context = React.useContext(SelectPositionerContext);
|
|
783
|
+
if (!context) {
|
|
784
|
+
throw new Error(process.env.NODE_ENV !== "production" ? 'Base UI: SelectPositionerContext is missing. SelectPositioner parts must be placed within <Select.Positioner>.' : formatErrorMessage(59));
|
|
785
|
+
}
|
|
786
|
+
return context;
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
function clearStyles(element, originalStyles) {
|
|
790
|
+
if (element) {
|
|
791
|
+
Object.assign(element.style, originalStyles);
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
const LIST_FUNCTIONAL_STYLES = {
|
|
795
|
+
position: 'relative',
|
|
796
|
+
maxHeight: '100%',
|
|
797
|
+
overflowX: 'hidden',
|
|
798
|
+
overflowY: 'auto'
|
|
799
|
+
};
|
|
800
|
+
|
|
801
|
+
const FIXED = {
|
|
802
|
+
position: 'fixed'
|
|
803
|
+
};
|
|
804
|
+
|
|
805
|
+
/**
|
|
806
|
+
* Positions the select popup.
|
|
807
|
+
* Renders a `<div>` element.
|
|
808
|
+
*
|
|
809
|
+
* Documentation: [Base UI Select](https://base-ui.com/react/components/select)
|
|
810
|
+
*/
|
|
811
|
+
const SelectPositioner = /*#__PURE__*/React.forwardRef(function SelectPositioner(componentProps, forwardedRef) {
|
|
812
|
+
const {
|
|
813
|
+
anchor,
|
|
814
|
+
className,
|
|
815
|
+
render,
|
|
816
|
+
// `useAnchorPositioning` applies the same defaults to the undefined values; the names
|
|
817
|
+
// remain destructured to exclude the props from `elementProps`.
|
|
818
|
+
positionMethod,
|
|
819
|
+
side,
|
|
820
|
+
align,
|
|
821
|
+
sideOffset,
|
|
822
|
+
alignOffset,
|
|
823
|
+
collisionBoundary = 'clipping-ancestors',
|
|
824
|
+
collisionPadding,
|
|
825
|
+
arrowPadding,
|
|
826
|
+
sticky,
|
|
827
|
+
disableAnchorTracking,
|
|
828
|
+
alignItemWithTrigger = true,
|
|
829
|
+
collisionAvoidance = DROPDOWN_COLLISION_AVOIDANCE,
|
|
830
|
+
style,
|
|
831
|
+
...elementProps
|
|
832
|
+
} = componentProps;
|
|
833
|
+
const {
|
|
834
|
+
store,
|
|
835
|
+
listRef,
|
|
836
|
+
labelsRef,
|
|
837
|
+
alignItemWithTriggerActiveRef,
|
|
838
|
+
selectedItemTextRef,
|
|
839
|
+
valuesRef,
|
|
840
|
+
initialValueRef,
|
|
841
|
+
popupRef,
|
|
842
|
+
setValue,
|
|
843
|
+
floatingContext: floatingRootContext
|
|
844
|
+
} = useSelectRootContext();
|
|
845
|
+
const open = useStore(store, selectors.open);
|
|
846
|
+
const mounted = useStore(store, selectors.mounted);
|
|
847
|
+
const modal = useStore(store, selectors.modal);
|
|
848
|
+
const value = useStore(store, selectors.value);
|
|
849
|
+
const openMethod = useStore(store, selectors.openMethod);
|
|
850
|
+
const positionerElement = useStore(store, selectors.positionerElement);
|
|
851
|
+
const triggerElement = useStore(store, selectors.triggerElement);
|
|
852
|
+
const isItemEqualToValue = useStore(store, selectors.isItemEqualToValue);
|
|
853
|
+
const transitionStatus = useStore(store, selectors.transitionStatus);
|
|
854
|
+
const scrollUpArrowRef = React.useRef(null);
|
|
855
|
+
const scrollDownArrowRef = React.useRef(null);
|
|
856
|
+
const [controlledAlignItemWithTrigger, setControlledAlignItemWithTrigger] = React.useState(alignItemWithTrigger);
|
|
857
|
+
const alignItemWithTriggerActive = mounted && controlledAlignItemWithTrigger && openMethod !== 'touch';
|
|
858
|
+
if (!mounted && controlledAlignItemWithTrigger !== alignItemWithTrigger) {
|
|
859
|
+
setControlledAlignItemWithTrigger(alignItemWithTrigger);
|
|
860
|
+
}
|
|
861
|
+
React.useImperativeHandle(alignItemWithTriggerActiveRef, () => alignItemWithTriggerActive);
|
|
862
|
+
useAnchoredPopupScrollLock((alignItemWithTriggerActive || modal) && open, openMethod === 'touch', positionerElement, triggerElement);
|
|
863
|
+
const positioning = useAnchorPositioning({
|
|
864
|
+
anchor,
|
|
865
|
+
floatingRootContext,
|
|
866
|
+
positionMethod,
|
|
867
|
+
mounted,
|
|
868
|
+
side,
|
|
869
|
+
sideOffset,
|
|
870
|
+
align,
|
|
871
|
+
alignOffset,
|
|
872
|
+
arrowPadding,
|
|
873
|
+
collisionBoundary,
|
|
874
|
+
collisionPadding,
|
|
875
|
+
sticky,
|
|
876
|
+
disableAnchorTracking: disableAnchorTracking ?? alignItemWithTriggerActive,
|
|
877
|
+
collisionAvoidance,
|
|
878
|
+
keepMounted: true
|
|
879
|
+
});
|
|
880
|
+
const renderedSide = alignItemWithTriggerActive ? 'none' : positioning.side;
|
|
881
|
+
const positionerStyles = alignItemWithTriggerActive ? FIXED : positioning.positionerStyles;
|
|
882
|
+
const state = {
|
|
883
|
+
open,
|
|
884
|
+
side: renderedSide,
|
|
885
|
+
align: positioning.align,
|
|
886
|
+
anchorHidden: positioning.anchorHidden
|
|
887
|
+
};
|
|
888
|
+
useIsoLayoutEffect(() => {
|
|
889
|
+
store.set('popupSide', positioning.side);
|
|
890
|
+
}, [store, positioning.side]);
|
|
891
|
+
const setPositionerElement = store.useStateSetter('positionerElement');
|
|
892
|
+
const element = usePositioner(componentProps, state, {
|
|
893
|
+
styles: positionerStyles,
|
|
894
|
+
transitionStatus,
|
|
895
|
+
props: elementProps,
|
|
896
|
+
refs: [forwardedRef, setPositionerElement],
|
|
897
|
+
hidden: !mounted,
|
|
898
|
+
inert: !open
|
|
899
|
+
});
|
|
900
|
+
const prevMapSizeRef = React.useRef(0);
|
|
901
|
+
const onMapChange = useStableCallback(map => {
|
|
902
|
+
if (valuesRef.current.length === 0) {
|
|
903
|
+
return;
|
|
904
|
+
}
|
|
905
|
+
const prevSize = prevMapSizeRef.current;
|
|
906
|
+
prevMapSizeRef.current = map.size;
|
|
907
|
+
if (map.size === prevSize) {
|
|
908
|
+
return;
|
|
909
|
+
}
|
|
910
|
+
const eventDetails = createChangeEventDetails(none);
|
|
911
|
+
if (prevSize !== 0 && !store.state.multiple && value !== null) {
|
|
912
|
+
const selectedValueIndex = findItemIndex(valuesRef.current, value, isItemEqualToValue);
|
|
913
|
+
if (selectedValueIndex === -1) {
|
|
914
|
+
const initialSelectedValue = initialValueRef.current;
|
|
915
|
+
const hasInitial = initialSelectedValue != null && findItemIndex(valuesRef.current, initialSelectedValue, isItemEqualToValue) !== -1;
|
|
916
|
+
const nextValue = hasInitial ? initialSelectedValue : null;
|
|
917
|
+
setValue(nextValue, eventDetails);
|
|
918
|
+
if (nextValue === null) {
|
|
919
|
+
store.set('selectedIndex', null);
|
|
920
|
+
selectedItemTextRef.current = null;
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
}
|
|
924
|
+
if (prevSize !== 0 && store.state.multiple && Array.isArray(value)) {
|
|
925
|
+
const nextValue = value.filter(selectedItemValue => findItemIndex(valuesRef.current, selectedItemValue, isItemEqualToValue) !== -1);
|
|
926
|
+
if (nextValue.length !== value.length) {
|
|
927
|
+
setValue(nextValue, eventDetails);
|
|
928
|
+
if (nextValue.length === 0) {
|
|
929
|
+
store.set('selectedIndex', null);
|
|
930
|
+
selectedItemTextRef.current = null;
|
|
931
|
+
}
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
if (open && alignItemWithTriggerActive) {
|
|
935
|
+
store.update({
|
|
936
|
+
scrollUpArrowVisible: false,
|
|
937
|
+
scrollDownArrowVisible: false
|
|
938
|
+
});
|
|
939
|
+
const stylesToClear = {
|
|
940
|
+
height: ''
|
|
941
|
+
};
|
|
942
|
+
clearStyles(positionerElement, stylesToClear);
|
|
943
|
+
clearStyles(popupRef.current, stylesToClear);
|
|
944
|
+
}
|
|
945
|
+
});
|
|
946
|
+
const contextValue = React.useMemo(() => ({
|
|
947
|
+
...positioning,
|
|
948
|
+
side: renderedSide,
|
|
949
|
+
alignItemWithTriggerActive,
|
|
950
|
+
setControlledAlignItemWithTrigger,
|
|
951
|
+
scrollUpArrowRef,
|
|
952
|
+
scrollDownArrowRef
|
|
953
|
+
}), [positioning, renderedSide, alignItemWithTriggerActive, setControlledAlignItemWithTrigger]);
|
|
954
|
+
return /*#__PURE__*/jsx(CompositeList, {
|
|
955
|
+
elementsRef: listRef,
|
|
956
|
+
labelsRef: labelsRef,
|
|
957
|
+
onMapChange: onMapChange,
|
|
958
|
+
children: /*#__PURE__*/jsxs(SelectPositionerContext.Provider, {
|
|
959
|
+
value: contextValue,
|
|
960
|
+
children: [mounted && modal && /*#__PURE__*/jsx(InternalBackdrop, {
|
|
961
|
+
inert: inertValue(!open),
|
|
962
|
+
cutout: triggerElement
|
|
963
|
+
}), element]
|
|
964
|
+
})
|
|
965
|
+
});
|
|
966
|
+
});
|
|
967
|
+
if (process.env.NODE_ENV !== "production") SelectPositioner.displayName = "SelectPositioner";
|
|
968
|
+
|
|
969
|
+
const stateAttributesMapping = {
|
|
970
|
+
...popupStateMapping,
|
|
971
|
+
...transitionStatusMapping
|
|
972
|
+
};
|
|
973
|
+
|
|
974
|
+
/**
|
|
975
|
+
* A container for the select list.
|
|
976
|
+
* Renders a `<div>` element.
|
|
977
|
+
*
|
|
978
|
+
* Documentation: [Base UI Select](https://base-ui.com/react/components/select)
|
|
979
|
+
*/
|
|
980
|
+
const SelectPopup = /*#__PURE__*/React.forwardRef(function SelectPopup(componentProps, forwardedRef) {
|
|
981
|
+
const {
|
|
982
|
+
render,
|
|
983
|
+
className,
|
|
984
|
+
style,
|
|
985
|
+
finalFocus,
|
|
986
|
+
...elementProps
|
|
987
|
+
} = componentProps;
|
|
988
|
+
const {
|
|
989
|
+
store,
|
|
990
|
+
popupRef,
|
|
991
|
+
onOpenChangeComplete,
|
|
992
|
+
setOpen,
|
|
993
|
+
valueRef,
|
|
994
|
+
firstItemTextRef,
|
|
995
|
+
selectedItemTextRef,
|
|
996
|
+
multiple,
|
|
997
|
+
handleScrollArrowVisibility,
|
|
998
|
+
scrollHandlerRef,
|
|
999
|
+
listRef,
|
|
1000
|
+
highlightItemOnHover,
|
|
1001
|
+
floatingContext: floatingRootContext
|
|
1002
|
+
} = useSelectRootContext();
|
|
1003
|
+
const {
|
|
1004
|
+
side,
|
|
1005
|
+
align,
|
|
1006
|
+
alignItemWithTriggerActive,
|
|
1007
|
+
isPositioned,
|
|
1008
|
+
setControlledAlignItemWithTrigger
|
|
1009
|
+
} = useSelectPositionerContext();
|
|
1010
|
+
const insideToolbar = useToolbarRootContext(true) != null;
|
|
1011
|
+
const direction = useDirection();
|
|
1012
|
+
const {
|
|
1013
|
+
nonce,
|
|
1014
|
+
disableStyleElements
|
|
1015
|
+
} = useCSPContext();
|
|
1016
|
+
const id = useStore(store, selectors.id);
|
|
1017
|
+
const open = useStore(store, selectors.open);
|
|
1018
|
+
const openMethod = useStore(store, selectors.openMethod);
|
|
1019
|
+
const mounted = useStore(store, selectors.mounted);
|
|
1020
|
+
const popupProps = useStore(store, selectors.popupProps);
|
|
1021
|
+
const transitionStatus = useStore(store, selectors.transitionStatus);
|
|
1022
|
+
const triggerElement = useStore(store, selectors.triggerElement);
|
|
1023
|
+
const positionerElement = useStore(store, selectors.positionerElement);
|
|
1024
|
+
const listElement = useStore(store, selectors.listElement);
|
|
1025
|
+
const reachedMaxHeightRef = React.useRef(false);
|
|
1026
|
+
const initialPlacedRef = React.useRef(false);
|
|
1027
|
+
const originalPositionerStylesRef = React.useRef({});
|
|
1028
|
+
const scrollArrowFrame = useAnimationFrame();
|
|
1029
|
+
const handleScroll = useStableCallback(scroller => {
|
|
1030
|
+
if (!positionerElement || !popupRef.current || !initialPlacedRef.current) {
|
|
1031
|
+
return;
|
|
1032
|
+
}
|
|
1033
|
+
const isTopPositioned = positionerElement.style.top === '0px';
|
|
1034
|
+
const isBottomPositioned = positionerElement.style.bottom === '0px';
|
|
1035
|
+
if (reachedMaxHeightRef.current || !alignItemWithTriggerActive || !isTopPositioned && !isBottomPositioned) {
|
|
1036
|
+
handleScrollArrowVisibility(scroller);
|
|
1037
|
+
return;
|
|
1038
|
+
}
|
|
1039
|
+
const scale = getScale(positionerElement);
|
|
1040
|
+
const currentHeight = normalizeSize(positionerElement.getBoundingClientRect().height, 'y', scale);
|
|
1041
|
+
const doc = ownerDocument(positionerElement);
|
|
1042
|
+
const win = getWindow(positionerElement);
|
|
1043
|
+
const positionerStyles = win.getComputedStyle(positionerElement);
|
|
1044
|
+
const marginTop = parseFloat(positionerStyles.marginTop);
|
|
1045
|
+
const marginBottom = parseFloat(positionerStyles.marginBottom);
|
|
1046
|
+
const maxPopupHeight = getMaxPopupHeight(win.getComputedStyle(popupRef.current));
|
|
1047
|
+
const maxAvailableHeight = Math.min(doc.documentElement.clientHeight - marginTop - marginBottom, maxPopupHeight);
|
|
1048
|
+
const scrollTop = scroller.scrollTop;
|
|
1049
|
+
const maxScrollTop = getMaxScrollTop(scroller);
|
|
1050
|
+
|
|
1051
|
+
// `Infinity` requests a scroll to the recomputed maximum offset.
|
|
1052
|
+
let nextScrollTop = null;
|
|
1053
|
+
const setHeight = height => {
|
|
1054
|
+
positionerElement.style.height = `${height}px`;
|
|
1055
|
+
};
|
|
1056
|
+
const diff = isTopPositioned ? maxScrollTop - scrollTop : scrollTop;
|
|
1057
|
+
const nextHeight = Math.min(currentHeight + diff, maxAvailableHeight);
|
|
1058
|
+
if (diff <= SCROLL_EDGE_TOLERANCE_PX) {
|
|
1059
|
+
const heightDelta = clamp(diff, 0, maxAvailableHeight - currentHeight);
|
|
1060
|
+
if (heightDelta > 0) {
|
|
1061
|
+
// Consume the remaining scroll in height.
|
|
1062
|
+
setHeight(currentHeight + heightDelta);
|
|
1063
|
+
}
|
|
1064
|
+
scroller.scrollTop = isTopPositioned ? maxScrollTop : 0;
|
|
1065
|
+
if (maxAvailableHeight - (currentHeight + heightDelta) <= SCROLL_EDGE_TOLERANCE_PX) {
|
|
1066
|
+
reachedMaxHeightRef.current = true;
|
|
1067
|
+
}
|
|
1068
|
+
handleScrollArrowVisibility(scroller);
|
|
1069
|
+
return;
|
|
1070
|
+
}
|
|
1071
|
+
if (maxAvailableHeight - nextHeight > SCROLL_EDGE_TOLERANCE_PX) {
|
|
1072
|
+
nextScrollTop = isTopPositioned ? Infinity : 0;
|
|
1073
|
+
} else if (isBottomPositioned && scrollTop < maxScrollTop) {
|
|
1074
|
+
const overshoot = currentHeight + diff - maxAvailableHeight;
|
|
1075
|
+
nextScrollTop = scrollTop - (diff - overshoot);
|
|
1076
|
+
}
|
|
1077
|
+
const nextPositionerHeight = Math.ceil(nextHeight);
|
|
1078
|
+
if (nextPositionerHeight !== 0) {
|
|
1079
|
+
setHeight(nextPositionerHeight);
|
|
1080
|
+
}
|
|
1081
|
+
if (nextScrollTop != null) {
|
|
1082
|
+
// Recompute bounds after resizing (clientHeight likely changed).
|
|
1083
|
+
const target = clamp(nextScrollTop, 0, getMaxScrollTop(scroller));
|
|
1084
|
+
|
|
1085
|
+
// Avoid adjustments that re-trigger scroll events forever.
|
|
1086
|
+
if (Math.abs(scroller.scrollTop - target) > SCROLL_EDGE_TOLERANCE_PX) {
|
|
1087
|
+
scroller.scrollTop = target;
|
|
1088
|
+
}
|
|
1089
|
+
}
|
|
1090
|
+
if (nextPositionerHeight >= maxAvailableHeight - SCROLL_EDGE_TOLERANCE_PX) {
|
|
1091
|
+
reachedMaxHeightRef.current = true;
|
|
1092
|
+
}
|
|
1093
|
+
handleScrollArrowVisibility(scroller);
|
|
1094
|
+
});
|
|
1095
|
+
React.useImperativeHandle(scrollHandlerRef, () => handleScroll, [handleScroll]);
|
|
1096
|
+
useOpenChangeComplete({
|
|
1097
|
+
open,
|
|
1098
|
+
ref: popupRef,
|
|
1099
|
+
onComplete() {
|
|
1100
|
+
if (open) {
|
|
1101
|
+
onOpenChangeComplete?.(true);
|
|
1102
|
+
}
|
|
1103
|
+
}
|
|
1104
|
+
});
|
|
1105
|
+
const state = {
|
|
1106
|
+
open,
|
|
1107
|
+
transitionStatus,
|
|
1108
|
+
side,
|
|
1109
|
+
align
|
|
1110
|
+
};
|
|
1111
|
+
useIsoLayoutEffect(() => {
|
|
1112
|
+
if (!positionerElement || !popupRef.current || Object.keys(originalPositionerStylesRef.current).length) {
|
|
1113
|
+
return;
|
|
1114
|
+
}
|
|
1115
|
+
originalPositionerStylesRef.current = {
|
|
1116
|
+
top: positionerElement.style.top || '0',
|
|
1117
|
+
left: positionerElement.style.left || '0',
|
|
1118
|
+
right: positionerElement.style.right,
|
|
1119
|
+
height: positionerElement.style.height,
|
|
1120
|
+
bottom: positionerElement.style.bottom,
|
|
1121
|
+
minHeight: positionerElement.style.minHeight,
|
|
1122
|
+
maxHeight: positionerElement.style.maxHeight,
|
|
1123
|
+
marginTop: positionerElement.style.marginTop,
|
|
1124
|
+
marginBottom: positionerElement.style.marginBottom
|
|
1125
|
+
};
|
|
1126
|
+
}, [popupRef, positionerElement]);
|
|
1127
|
+
useIsoLayoutEffect(() => {
|
|
1128
|
+
if (open || alignItemWithTriggerActive) {
|
|
1129
|
+
return;
|
|
1130
|
+
}
|
|
1131
|
+
initialPlacedRef.current = false;
|
|
1132
|
+
reachedMaxHeightRef.current = false;
|
|
1133
|
+
clearStyles(positionerElement, originalPositionerStylesRef.current);
|
|
1134
|
+
}, [open, alignItemWithTriggerActive, positionerElement, popupRef]);
|
|
1135
|
+
useIsoLayoutEffect(() => {
|
|
1136
|
+
const popupElement = popupRef.current;
|
|
1137
|
+
|
|
1138
|
+
// Wait for Floating UI's first positioning pass before reading DOM geometry.
|
|
1139
|
+
// We replace the final coordinates for aligned selects, but still need middleware
|
|
1140
|
+
// like `size()` to set CSS variables such as `--anchor-width`.
|
|
1141
|
+
if (!open || !triggerElement || !positionerElement || !popupElement || alignItemWithTriggerActive && !isPositioned || store.state.transitionStatus === 'ending') {
|
|
1142
|
+
return;
|
|
1143
|
+
}
|
|
1144
|
+
initialPlacedRef.current = true;
|
|
1145
|
+
popupElement.style.removeProperty('--transform-origin');
|
|
1146
|
+
if (!alignItemWithTriggerActive) {
|
|
1147
|
+
// The wrapper supplies the scroller: the list owns scrolling once it has mounted, and
|
|
1148
|
+
// this effect re-runs (cancelling the stale frame) when that happens.
|
|
1149
|
+
scrollArrowFrame.request(() => handleScrollArrowVisibility(listElement || popupElement));
|
|
1150
|
+
return;
|
|
1151
|
+
}
|
|
1152
|
+
|
|
1153
|
+
// Ensure we remove any transforms that can affect the location of the popup
|
|
1154
|
+
// and therefore the calculations.
|
|
1155
|
+
const restoreTransformStyles = unsetTransformStyles(popupElement);
|
|
1156
|
+
try {
|
|
1157
|
+
let textElement = selectedItemTextRef.current;
|
|
1158
|
+
if (!textElement?.isConnected) {
|
|
1159
|
+
const hasSelectedValue = selectors.hasSelectedValue(store.state);
|
|
1160
|
+
textElement = !hasSelectedValue && firstItemTextRef.current?.isConnected ? firstItemTextRef.current : null;
|
|
1161
|
+
}
|
|
1162
|
+
const valueElement = valueRef.current;
|
|
1163
|
+
const win = getWindow(positionerElement);
|
|
1164
|
+
const positionerStyles = win.getComputedStyle(positionerElement);
|
|
1165
|
+
const popupStyles = win.getComputedStyle(popupElement);
|
|
1166
|
+
const doc = ownerDocument(triggerElement);
|
|
1167
|
+
const scale = getScale(triggerElement);
|
|
1168
|
+
const triggerRect = normalizeRect(triggerElement.getBoundingClientRect(), scale);
|
|
1169
|
+
const positionerRect = normalizeRect(positionerElement.getBoundingClientRect(), scale);
|
|
1170
|
+
const triggerHeight = triggerRect.height;
|
|
1171
|
+
const scroller = listElement || popupElement;
|
|
1172
|
+
const scrollHeight = scroller.scrollHeight;
|
|
1173
|
+
const borderBottom = parseFloat(popupStyles.borderBottomWidth);
|
|
1174
|
+
// The `|| N` fallbacks cover an unset/`auto` value (parses to `NaN`). Note a literal `0`
|
|
1175
|
+
// also resolves to the fallback, so an explicit `margin: 0` or `min-height: 0` still takes
|
|
1176
|
+
// the default below.
|
|
1177
|
+
const marginTop = parseFloat(positionerStyles.marginTop) || 10;
|
|
1178
|
+
const marginBottom = parseFloat(positionerStyles.marginBottom) || 10;
|
|
1179
|
+
const minHeight = parseFloat(positionerStyles.minHeight) || 100;
|
|
1180
|
+
const maxPopupHeight = getMaxPopupHeight(popupStyles);
|
|
1181
|
+
const paddingLeft = 5;
|
|
1182
|
+
const paddingRight = 5;
|
|
1183
|
+
const triggerCollisionThreshold = 20;
|
|
1184
|
+
const viewportHeight = doc.documentElement.clientHeight - marginTop - marginBottom;
|
|
1185
|
+
const viewportWidth = doc.documentElement.clientWidth;
|
|
1186
|
+
const availableSpaceBeneathTrigger = viewportHeight - triggerRect.bottom + triggerHeight;
|
|
1187
|
+
let textRect;
|
|
1188
|
+
let alignedLeft = direction === 'rtl' ? triggerRect.right - positionerRect.width : triggerRect.left;
|
|
1189
|
+
let offsetY = 0;
|
|
1190
|
+
if (textElement && valueElement) {
|
|
1191
|
+
const valueRect = normalizeRect(valueElement.getBoundingClientRect(), scale);
|
|
1192
|
+
textRect = normalizeRect(textElement.getBoundingClientRect(), scale);
|
|
1193
|
+
alignedLeft = positionerRect.left + (direction === 'rtl' ? valueRect.right - textRect.right : valueRect.left - textRect.left);
|
|
1194
|
+
const valueCenterFromTriggerTop = valueRect.top - triggerRect.top + valueRect.height / 2;
|
|
1195
|
+
const textCenterFromPositionerTop = textRect.top - positionerRect.top + textRect.height / 2;
|
|
1196
|
+
offsetY = textCenterFromPositionerTop - valueCenterFromTriggerTop;
|
|
1197
|
+
}
|
|
1198
|
+
const idealHeight = availableSpaceBeneathTrigger + offsetY + marginBottom + borderBottom;
|
|
1199
|
+
let height = Math.min(viewportHeight, idealHeight);
|
|
1200
|
+
const maxHeight = viewportHeight - marginTop - marginBottom;
|
|
1201
|
+
const scrollTop = idealHeight - height;
|
|
1202
|
+
const maxRight = viewportWidth - paddingRight;
|
|
1203
|
+
positionerElement.style.left = `${clamp(alignedLeft, paddingLeft, maxRight - positionerRect.width)}px`;
|
|
1204
|
+
positionerElement.style.height = `${height}px`;
|
|
1205
|
+
// `none` (not the invalid `auto`) so the explicit height governs in align mode and isn't
|
|
1206
|
+
// clamped by a `max-height` from user CSS.
|
|
1207
|
+
positionerElement.style.maxHeight = 'none';
|
|
1208
|
+
positionerElement.style.marginTop = `${marginTop}px`;
|
|
1209
|
+
positionerElement.style.marginBottom = `${marginBottom}px`;
|
|
1210
|
+
popupElement.style.height = '100%';
|
|
1211
|
+
const maxScrollTop = getMaxScrollTop(scroller);
|
|
1212
|
+
const isTopPositioned = scrollTop >= maxScrollTop - SCROLL_EDGE_TOLERANCE_PX;
|
|
1213
|
+
if (isTopPositioned) {
|
|
1214
|
+
height = Math.min(viewportHeight, positionerRect.height) - (scrollTop - maxScrollTop);
|
|
1215
|
+
}
|
|
1216
|
+
|
|
1217
|
+
// When the trigger is too close to the top or bottom of the viewport, or the minHeight is
|
|
1218
|
+
// reached, we fallback to aligning the popup to the trigger as the UX is poor otherwise.
|
|
1219
|
+
const fallbackToAlignPopupToTrigger = triggerRect.top < triggerCollisionThreshold || triggerRect.bottom > viewportHeight - triggerCollisionThreshold || Math.ceil(height) + SCROLL_EDGE_TOLERANCE_PX < Math.min(scrollHeight, minHeight);
|
|
1220
|
+
|
|
1221
|
+
// Safari doesn't position the popup correctly when pinch-zoomed.
|
|
1222
|
+
const isPinchZoomed = (win.visualViewport?.scale ?? 1) !== 1 && webkit;
|
|
1223
|
+
if (fallbackToAlignPopupToTrigger || isPinchZoomed) {
|
|
1224
|
+
clearStyles(positionerElement, originalPositionerStylesRef.current);
|
|
1225
|
+
setControlledAlignItemWithTrigger(false);
|
|
1226
|
+
return;
|
|
1227
|
+
}
|
|
1228
|
+
const initialHeight = Math.max(minHeight, height);
|
|
1229
|
+
if (isTopPositioned) {
|
|
1230
|
+
const topOffset = Math.max(0, viewportHeight - idealHeight);
|
|
1231
|
+
positionerElement.style.top = positionerRect.height >= maxHeight ? '0' : `${topOffset}px`;
|
|
1232
|
+
positionerElement.style.height = `${height}px`;
|
|
1233
|
+
scroller.scrollTop = getMaxScrollTop(scroller);
|
|
1234
|
+
} else {
|
|
1235
|
+
positionerElement.style.bottom = '0';
|
|
1236
|
+
scroller.scrollTop = scrollTop;
|
|
1237
|
+
}
|
|
1238
|
+
if (textRect) {
|
|
1239
|
+
const popupTop = positionerRect.top;
|
|
1240
|
+
const popupHeight = positionerRect.height;
|
|
1241
|
+
const textCenterY = textRect.top + textRect.height / 2;
|
|
1242
|
+
const clampedY = clamp(popupHeight > 0 ? (textCenterY - popupTop) / popupHeight * 100 : 50, 0, 100);
|
|
1243
|
+
popupElement.style.setProperty('--transform-origin', `50% ${clampedY}%`);
|
|
1244
|
+
}
|
|
1245
|
+
if (initialHeight === viewportHeight || height >= maxPopupHeight) {
|
|
1246
|
+
reachedMaxHeightRef.current = true;
|
|
1247
|
+
}
|
|
1248
|
+
handleScrollArrowVisibility(scroller);
|
|
1249
|
+
if (highlightItemOnHover && store.state.selectedIndex === null && store.state.activeIndex === null && listRef.current[0] != null) {
|
|
1250
|
+
store.set('activeIndex', 0);
|
|
1251
|
+
}
|
|
1252
|
+
} finally {
|
|
1253
|
+
restoreTransformStyles();
|
|
1254
|
+
}
|
|
1255
|
+
}, [store, open, positionerElement, triggerElement, valueRef, firstItemTextRef, selectedItemTextRef, popupRef, handleScrollArrowVisibility, alignItemWithTriggerActive, setControlledAlignItemWithTrigger, scrollArrowFrame, listElement, listRef, highlightItemOnHover, direction, isPositioned]);
|
|
1256
|
+
React.useEffect(() => {
|
|
1257
|
+
if (!alignItemWithTriggerActive || !positionerElement || !open) {
|
|
1258
|
+
return undefined;
|
|
1259
|
+
}
|
|
1260
|
+
const win = getWindow(positionerElement);
|
|
1261
|
+
function handleResize(event) {
|
|
1262
|
+
setOpen(false, createChangeEventDetails(windowResize, event));
|
|
1263
|
+
}
|
|
1264
|
+
return addEventListener(win, 'resize', handleResize);
|
|
1265
|
+
}, [setOpen, alignItemWithTriggerActive, positionerElement, open]);
|
|
1266
|
+
const defaultProps = {
|
|
1267
|
+
...(listElement ? {
|
|
1268
|
+
role: 'presentation',
|
|
1269
|
+
'aria-orientation': undefined
|
|
1270
|
+
} : {
|
|
1271
|
+
role: 'listbox',
|
|
1272
|
+
'aria-multiselectable': multiple || undefined,
|
|
1273
|
+
id: `${id}-list`
|
|
1274
|
+
}),
|
|
1275
|
+
onKeyDown(event) {
|
|
1276
|
+
if (insideToolbar && COMPOSITE_KEYS.has(event.key)) {
|
|
1277
|
+
event.stopPropagation();
|
|
1278
|
+
}
|
|
1279
|
+
},
|
|
1280
|
+
onScroll(event) {
|
|
1281
|
+
if (listElement) {
|
|
1282
|
+
return;
|
|
1283
|
+
}
|
|
1284
|
+
handleScroll(event.currentTarget);
|
|
1285
|
+
},
|
|
1286
|
+
...(alignItemWithTriggerActive && {
|
|
1287
|
+
style: listElement ? {
|
|
1288
|
+
height: '100%'
|
|
1289
|
+
} : LIST_FUNCTIONAL_STYLES
|
|
1290
|
+
}),
|
|
1291
|
+
className: !listElement && alignItemWithTriggerActive ? styleDisableScrollbar.className : undefined
|
|
1292
|
+
};
|
|
1293
|
+
const element = useRenderElement('div', componentProps, {
|
|
1294
|
+
ref: [forwardedRef, popupRef],
|
|
1295
|
+
state,
|
|
1296
|
+
stateAttributesMapping,
|
|
1297
|
+
props: [popupProps, defaultProps, getDisabledMountTransitionStyles(transitionStatus), elementProps]
|
|
1298
|
+
});
|
|
1299
|
+
return /*#__PURE__*/jsxs(React.Fragment, {
|
|
1300
|
+
children: [!disableStyleElements && styleDisableScrollbar.getElement(nonce), /*#__PURE__*/jsx(FloatingFocusManager, {
|
|
1301
|
+
context: floatingRootContext,
|
|
1302
|
+
modal: false,
|
|
1303
|
+
disabled: !mounted,
|
|
1304
|
+
openInteractionType: openMethod,
|
|
1305
|
+
returnFocus: finalFocus,
|
|
1306
|
+
restoreFocus: true,
|
|
1307
|
+
children: element
|
|
1308
|
+
})]
|
|
1309
|
+
});
|
|
1310
|
+
});
|
|
1311
|
+
if (process.env.NODE_ENV !== "production") SelectPopup.displayName = "SelectPopup";
|
|
1312
|
+
function getMaxPopupHeight(popupStyles) {
|
|
1313
|
+
const maxHeightStyle = popupStyles.maxHeight;
|
|
1314
|
+
return maxHeightStyle.endsWith('px') ? parseFloat(maxHeightStyle) || Infinity : Infinity;
|
|
1315
|
+
}
|
|
1316
|
+
function getMaxScrollTop(scroller) {
|
|
1317
|
+
return getMaxScrollOffset(scroller.scrollHeight, scroller.clientHeight);
|
|
1318
|
+
}
|
|
1319
|
+
function getScale(element) {
|
|
1320
|
+
// The platform API is async-capable, but the DOM platform returns a plain scale object.
|
|
1321
|
+
return platform.getScale(element);
|
|
1322
|
+
}
|
|
1323
|
+
function normalizeSize(size, axis, scale) {
|
|
1324
|
+
return size / scale[axis];
|
|
1325
|
+
}
|
|
1326
|
+
function normalizeRect(rect, scale) {
|
|
1327
|
+
return rectToClientRect({
|
|
1328
|
+
x: normalizeSize(rect.x, 'x', scale),
|
|
1329
|
+
y: normalizeSize(rect.y, 'y', scale),
|
|
1330
|
+
width: normalizeSize(rect.width, 'x', scale),
|
|
1331
|
+
height: normalizeSize(rect.height, 'y', scale)
|
|
1332
|
+
});
|
|
1333
|
+
}
|
|
1334
|
+
const TRANSFORM_STYLE_RESETS = [['transform', 'none'], ['scale', '1'], ['translate', '0 0']];
|
|
1335
|
+
function unsetTransformStyles(popupElement) {
|
|
1336
|
+
const {
|
|
1337
|
+
style
|
|
1338
|
+
} = popupElement;
|
|
1339
|
+
const originalStyles = {};
|
|
1340
|
+
for (const [property, value] of TRANSFORM_STYLE_RESETS) {
|
|
1341
|
+
originalStyles[property] = style.getPropertyValue(property);
|
|
1342
|
+
style.setProperty(property, value, 'important');
|
|
1343
|
+
}
|
|
1344
|
+
return () => {
|
|
1345
|
+
for (const [property] of TRANSFORM_STYLE_RESETS) {
|
|
1346
|
+
const originalValue = originalStyles[property];
|
|
1347
|
+
if (originalValue) {
|
|
1348
|
+
style.setProperty(property, originalValue);
|
|
1349
|
+
} else {
|
|
1350
|
+
style.removeProperty(property);
|
|
1351
|
+
}
|
|
1352
|
+
}
|
|
1353
|
+
};
|
|
1354
|
+
}
|
|
1355
|
+
|
|
1356
|
+
/**
|
|
1357
|
+
* A container for the select items.
|
|
1358
|
+
* Renders a `<div>` element.
|
|
1359
|
+
*
|
|
1360
|
+
* Documentation: [Base UI Select](https://base-ui.com/react/components/select)
|
|
1361
|
+
*/
|
|
1362
|
+
const SelectList = /*#__PURE__*/React.forwardRef(function SelectList(componentProps, forwardedRef) {
|
|
1363
|
+
const {
|
|
1364
|
+
render,
|
|
1365
|
+
className,
|
|
1366
|
+
style,
|
|
1367
|
+
...elementProps
|
|
1368
|
+
} = componentProps;
|
|
1369
|
+
const {
|
|
1370
|
+
store,
|
|
1371
|
+
scrollHandlerRef,
|
|
1372
|
+
multiple
|
|
1373
|
+
} = useSelectRootContext();
|
|
1374
|
+
const {
|
|
1375
|
+
alignItemWithTriggerActive
|
|
1376
|
+
} = useSelectPositionerContext();
|
|
1377
|
+
const hasScrollArrows = useStore(store, selectors.hasScrollArrows);
|
|
1378
|
+
const openMethod = useStore(store, selectors.openMethod);
|
|
1379
|
+
const id = useStore(store, selectors.id);
|
|
1380
|
+
const defaultProps = {
|
|
1381
|
+
id: `${id}-list`,
|
|
1382
|
+
role: 'listbox',
|
|
1383
|
+
'aria-multiselectable': multiple || undefined,
|
|
1384
|
+
onScroll(event) {
|
|
1385
|
+
scrollHandlerRef.current?.(event.currentTarget);
|
|
1386
|
+
},
|
|
1387
|
+
...(alignItemWithTriggerActive && {
|
|
1388
|
+
style: LIST_FUNCTIONAL_STYLES
|
|
1389
|
+
}),
|
|
1390
|
+
className: hasScrollArrows && openMethod !== 'touch' ? styleDisableScrollbar.className : undefined
|
|
1391
|
+
};
|
|
1392
|
+
const setListElement = store.useStateSetter('listElement');
|
|
1393
|
+
return useRenderElement('div', componentProps, {
|
|
1394
|
+
ref: [forwardedRef, setListElement],
|
|
1395
|
+
props: [defaultProps, elementProps]
|
|
1396
|
+
});
|
|
1397
|
+
});
|
|
1398
|
+
if (process.env.NODE_ENV !== "production") SelectList.displayName = "SelectList";
|
|
1399
|
+
|
|
1400
|
+
const SelectItemContext = /*#__PURE__*/React.createContext(undefined);
|
|
1401
|
+
if (process.env.NODE_ENV !== "production") SelectItemContext.displayName = "SelectItemContext";
|
|
1402
|
+
function useSelectItemContext() {
|
|
1403
|
+
const context = React.useContext(SelectItemContext);
|
|
1404
|
+
if (!context) {
|
|
1405
|
+
throw new Error(process.env.NODE_ENV !== "production" ? 'Base UI: SelectItemContext is missing. SelectItem parts must be placed within <Select.Item>.' : formatErrorMessage(57));
|
|
1406
|
+
}
|
|
1407
|
+
return context;
|
|
1408
|
+
}
|
|
1409
|
+
|
|
1410
|
+
const SelectItem = /*#__PURE__*/React.memo(/*#__PURE__*/React.forwardRef(function SelectItem(componentProps, forwardedRef) {
|
|
1411
|
+
const {
|
|
1412
|
+
render,
|
|
1413
|
+
className,
|
|
1414
|
+
style,
|
|
1415
|
+
value: itemValue = null,
|
|
1416
|
+
label,
|
|
1417
|
+
disabled: disabledProp = false,
|
|
1418
|
+
nativeButton = false,
|
|
1419
|
+
...elementProps
|
|
1420
|
+
} = componentProps;
|
|
1421
|
+
const textRef = React.useRef(null);
|
|
1422
|
+
const listItem = useCompositeListItem({
|
|
1423
|
+
guess: true,
|
|
1424
|
+
label,
|
|
1425
|
+
textRef
|
|
1426
|
+
});
|
|
1427
|
+
const {
|
|
1428
|
+
store,
|
|
1429
|
+
itemProps,
|
|
1430
|
+
setOpen,
|
|
1431
|
+
setValue,
|
|
1432
|
+
selectionRef,
|
|
1433
|
+
typingRef,
|
|
1434
|
+
valuesRef,
|
|
1435
|
+
multiple,
|
|
1436
|
+
selectedItemTextRef,
|
|
1437
|
+
disabled: selectDisabled,
|
|
1438
|
+
readOnly
|
|
1439
|
+
} = useSelectRootContext();
|
|
1440
|
+
const disabled = selectDisabled || disabledProp;
|
|
1441
|
+
const highlighted = useStore(store, selectors.isActive, listItem.index);
|
|
1442
|
+
const open = useStore(store, selectors.open);
|
|
1443
|
+
const selected = useStore(store, selectors.isSelected, itemValue);
|
|
1444
|
+
const selectedByFocus = useStore(store, selectors.isSelectedByFocus, listItem.index);
|
|
1445
|
+
const isItemEqualToValue = useStore(store, selectors.isItemEqualToValue);
|
|
1446
|
+
const index = listItem.index;
|
|
1447
|
+
const itemRef = React.useRef(null);
|
|
1448
|
+
useIsoLayoutEffect(() => {
|
|
1449
|
+
const values = valuesRef.current;
|
|
1450
|
+
values[index] = itemValue;
|
|
1451
|
+
return () => {
|
|
1452
|
+
delete values[index];
|
|
1453
|
+
};
|
|
1454
|
+
}, [index, itemValue, valuesRef]);
|
|
1455
|
+
useIsoLayoutEffect(() => {
|
|
1456
|
+
const selectedValue = store.state.value;
|
|
1457
|
+
let selectedCandidate = selectedValue;
|
|
1458
|
+
if (multiple && Array.isArray(selectedValue)) {
|
|
1459
|
+
// Compare against the last selected item, or `undefined` when nothing is selected — never
|
|
1460
|
+
// the raw array, which a custom `isItemEqualToValue` isn't expected to receive.
|
|
1461
|
+
selectedCandidate = selectedValue.length > 0 ? selectedValue[selectedValue.length - 1] : undefined;
|
|
1462
|
+
}
|
|
1463
|
+
if (selectedCandidate !== undefined && compareItemEquality(itemValue, selectedCandidate, isItemEqualToValue)) {
|
|
1464
|
+
store.set('selectedIndex', index);
|
|
1465
|
+
// Make sure SelectPopup can measure the selected item on first open.
|
|
1466
|
+
// SelectItemText can still update this ref later when focus moves.
|
|
1467
|
+
if (textRef.current) {
|
|
1468
|
+
selectedItemTextRef.current = textRef.current;
|
|
1469
|
+
}
|
|
1470
|
+
}
|
|
1471
|
+
}, [index, multiple, isItemEqualToValue, store, itemValue, selectedItemTextRef]);
|
|
1472
|
+
const pointerTypeRef = React.useRef('mouse');
|
|
1473
|
+
const allowMouseSelectionRef = React.useRef(false);
|
|
1474
|
+
const {
|
|
1475
|
+
getButtonProps,
|
|
1476
|
+
buttonRef
|
|
1477
|
+
} = useButton({
|
|
1478
|
+
disabled,
|
|
1479
|
+
focusableWhenDisabled: true,
|
|
1480
|
+
native: nativeButton,
|
|
1481
|
+
composite: true
|
|
1482
|
+
});
|
|
1483
|
+
const state = {
|
|
1484
|
+
disabled,
|
|
1485
|
+
selected,
|
|
1486
|
+
highlighted
|
|
1487
|
+
};
|
|
1488
|
+
function commitSelection(event) {
|
|
1489
|
+
// A forced-open select (`open`/`defaultOpen`) can still receive item activations even
|
|
1490
|
+
// when the root is disabled or read-only, so guard the commit here too.
|
|
1491
|
+
if (selectDisabled || readOnly) {
|
|
1492
|
+
return;
|
|
1493
|
+
}
|
|
1494
|
+
const selectedValue = store.state.value;
|
|
1495
|
+
if (multiple) {
|
|
1496
|
+
const currentValue = Array.isArray(selectedValue) ? selectedValue : [];
|
|
1497
|
+
const nextValue = selected ? removeItem(currentValue, itemValue, isItemEqualToValue) : [...currentValue, itemValue];
|
|
1498
|
+
setValue(nextValue, createChangeEventDetails(itemPress, event));
|
|
1499
|
+
} else {
|
|
1500
|
+
setValue(itemValue, createChangeEventDetails(itemPress, event));
|
|
1501
|
+
setOpen(false, createChangeEventDetails(itemPress, event));
|
|
1502
|
+
}
|
|
1503
|
+
}
|
|
1504
|
+
function resetDragMovement() {
|
|
1505
|
+
selectionRef.current.dragY = 0;
|
|
1506
|
+
}
|
|
1507
|
+
const defaultProps = {
|
|
1508
|
+
role: 'option',
|
|
1509
|
+
'aria-selected': selected,
|
|
1510
|
+
tabIndex: open && highlighted ? 0 : -1,
|
|
1511
|
+
onKeyDown(event) {
|
|
1512
|
+
store.set('activeIndex', index);
|
|
1513
|
+
if (event.key === ' ' && typingRef.current) {
|
|
1514
|
+
// `useButton` skips Space activation for `role="option"` items when the keydown
|
|
1515
|
+
// is `defaultPrevented`, keeping typeahead spaces from committing a selection.
|
|
1516
|
+
event.preventDefault();
|
|
1517
|
+
}
|
|
1518
|
+
},
|
|
1519
|
+
onClick(event) {
|
|
1520
|
+
const isMouseClick = pointerTypeRef.current !== 'touch';
|
|
1521
|
+
const clickPointerType = event.nativeEvent.pointerType;
|
|
1522
|
+
const isVirtualMouseClick = isMouseClick && isVirtualClick(event.nativeEvent) && (
|
|
1523
|
+
// Generic no-pointer `detail === 0` clicks stay tied to highlight state. Virtual
|
|
1524
|
+
// clicks that carry browser pointer data, including an empty string from assistive
|
|
1525
|
+
// technology, can activate unhighlighted items.
|
|
1526
|
+
clickPointerType !== undefined || highlighted);
|
|
1527
|
+
// With alignItemWithTrigger, opening can place an item under the cursor. Real mouse
|
|
1528
|
+
// clicks must start on the item, while virtual clicks represent explicit keyboard or
|
|
1529
|
+
// assistive technology activation.
|
|
1530
|
+
const isInvalidMouseClick = isMouseClick && !isVirtualMouseClick && !allowMouseSelectionRef.current;
|
|
1531
|
+
allowMouseSelectionRef.current = false;
|
|
1532
|
+
if (disabled || isInvalidMouseClick) {
|
|
1533
|
+
return;
|
|
1534
|
+
}
|
|
1535
|
+
commitSelection(event.nativeEvent);
|
|
1536
|
+
},
|
|
1537
|
+
onPointerEnter(event) {
|
|
1538
|
+
pointerTypeRef.current = event.pointerType;
|
|
1539
|
+
},
|
|
1540
|
+
onPointerMove(event) {
|
|
1541
|
+
if (event.pointerType === 'mouse' && event.buttons === 1) {
|
|
1542
|
+
const selection = selectionRef.current;
|
|
1543
|
+
selection.dragY += event.movementY;
|
|
1544
|
+
if (selection.dragY ** 2 >= 64) {
|
|
1545
|
+
selection.allowUnselectedMouseUp = true;
|
|
1546
|
+
}
|
|
1547
|
+
}
|
|
1548
|
+
},
|
|
1549
|
+
onPointerDown(event) {
|
|
1550
|
+
pointerTypeRef.current = event.pointerType;
|
|
1551
|
+
allowMouseSelectionRef.current = true;
|
|
1552
|
+
resetDragMovement();
|
|
1553
|
+
},
|
|
1554
|
+
onMouseUp() {
|
|
1555
|
+
resetDragMovement();
|
|
1556
|
+
if (disabled || pointerTypeRef.current === 'touch') {
|
|
1557
|
+
return;
|
|
1558
|
+
}
|
|
1559
|
+
|
|
1560
|
+
// Regular clicks are committed by the click event.
|
|
1561
|
+
if (allowMouseSelectionRef.current) {
|
|
1562
|
+
return;
|
|
1563
|
+
}
|
|
1564
|
+
const disallowSelectedMouseUp = !selectionRef.current.allowSelectedMouseUp && selected;
|
|
1565
|
+
const disallowUnselectedMouseUp = !selectionRef.current.allowUnselectedMouseUp && !selected;
|
|
1566
|
+
if (disallowSelectedMouseUp || disallowUnselectedMouseUp) {
|
|
1567
|
+
return;
|
|
1568
|
+
}
|
|
1569
|
+
allowMouseSelectionRef.current = true;
|
|
1570
|
+
itemRef.current?.click();
|
|
1571
|
+
allowMouseSelectionRef.current = false;
|
|
1572
|
+
}
|
|
1573
|
+
};
|
|
1574
|
+
const element = useRenderElement('div', componentProps, {
|
|
1575
|
+
ref: [buttonRef, forwardedRef, listItem.ref, itemRef],
|
|
1576
|
+
state,
|
|
1577
|
+
props: [itemProps, defaultProps, elementProps, getButtonProps]
|
|
1578
|
+
});
|
|
1579
|
+
const contextValue = React.useMemo(() => ({
|
|
1580
|
+
selected,
|
|
1581
|
+
index,
|
|
1582
|
+
textRef,
|
|
1583
|
+
selectedByFocus
|
|
1584
|
+
}), [selected, index, textRef, selectedByFocus]);
|
|
1585
|
+
return /*#__PURE__*/jsx(SelectItemContext.Provider, {
|
|
1586
|
+
value: contextValue,
|
|
1587
|
+
children: element
|
|
1588
|
+
});
|
|
1589
|
+
}));
|
|
1590
|
+
if (process.env.NODE_ENV !== "production") SelectItem.displayName = "SelectItem";
|
|
1591
|
+
|
|
1592
|
+
const SelectItemIndicator = /*#__PURE__*/React.forwardRef(function SelectItemIndicator(componentProps, forwardedRef) {
|
|
1593
|
+
const {
|
|
1594
|
+
selected
|
|
1595
|
+
} = useSelectItemContext();
|
|
1596
|
+
const shouldRender = componentProps.keepMounted || selected;
|
|
1597
|
+
if (!shouldRender) {
|
|
1598
|
+
return null;
|
|
1599
|
+
}
|
|
1600
|
+
|
|
1601
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
1602
|
+
return /*#__PURE__*/jsx(Inner, {
|
|
1603
|
+
...componentProps,
|
|
1604
|
+
ref: forwardedRef
|
|
1605
|
+
});
|
|
1606
|
+
});
|
|
1607
|
+
|
|
1608
|
+
// Split the core implementation to avoid paying the hook costs unless the element needs to mount.
|
|
1609
|
+
if (process.env.NODE_ENV !== "production") SelectItemIndicator.displayName = "SelectItemIndicator";
|
|
1610
|
+
const Inner = /*#__PURE__*/React.memo(/*#__PURE__*/React.forwardRef((componentProps, forwardedRef) => {
|
|
1611
|
+
const {
|
|
1612
|
+
render,
|
|
1613
|
+
className,
|
|
1614
|
+
style,
|
|
1615
|
+
keepMounted,
|
|
1616
|
+
...elementProps
|
|
1617
|
+
} = componentProps;
|
|
1618
|
+
const {
|
|
1619
|
+
selected
|
|
1620
|
+
} = useSelectItemContext();
|
|
1621
|
+
const indicatorRef = React.useRef(null);
|
|
1622
|
+
const {
|
|
1623
|
+
transitionStatus,
|
|
1624
|
+
setMounted
|
|
1625
|
+
} = useTransitionStatus(selected);
|
|
1626
|
+
const state = {
|
|
1627
|
+
selected,
|
|
1628
|
+
transitionStatus
|
|
1629
|
+
};
|
|
1630
|
+
const element = useRenderElement('span', componentProps, {
|
|
1631
|
+
ref: [forwardedRef, indicatorRef],
|
|
1632
|
+
state,
|
|
1633
|
+
props: [{
|
|
1634
|
+
'aria-hidden': true,
|
|
1635
|
+
children: '✔️'
|
|
1636
|
+
}, elementProps],
|
|
1637
|
+
stateAttributesMapping: transitionStatusMapping
|
|
1638
|
+
});
|
|
1639
|
+
useOpenChangeComplete({
|
|
1640
|
+
open: selected,
|
|
1641
|
+
ref: indicatorRef,
|
|
1642
|
+
onComplete() {
|
|
1643
|
+
if (!selected) {
|
|
1644
|
+
setMounted(false);
|
|
1645
|
+
}
|
|
1646
|
+
}
|
|
1647
|
+
});
|
|
1648
|
+
return element;
|
|
1649
|
+
}));
|
|
1650
|
+
if (process.env.NODE_ENV !== "production") Inner.displayName = "Inner";
|
|
1651
|
+
|
|
1652
|
+
/**
|
|
1653
|
+
* A text label of the select item.
|
|
1654
|
+
* Renders a `<div>` element.
|
|
1655
|
+
*
|
|
1656
|
+
* Documentation: [Base UI Select](https://base-ui.com/react/components/select)
|
|
1657
|
+
*/
|
|
1658
|
+
const SelectItemText = /*#__PURE__*/React.memo(/*#__PURE__*/React.forwardRef(function SelectItemText(componentProps, forwardedRef) {
|
|
1659
|
+
const {
|
|
1660
|
+
index,
|
|
1661
|
+
textRef,
|
|
1662
|
+
selectedByFocus
|
|
1663
|
+
} = useSelectItemContext();
|
|
1664
|
+
const {
|
|
1665
|
+
firstItemTextRef,
|
|
1666
|
+
selectedItemTextRef
|
|
1667
|
+
} = useSelectRootContext();
|
|
1668
|
+
const {
|
|
1669
|
+
render,
|
|
1670
|
+
className,
|
|
1671
|
+
style,
|
|
1672
|
+
...elementProps
|
|
1673
|
+
} = componentProps;
|
|
1674
|
+
const localRef = React.useCallback(node => {
|
|
1675
|
+
if (!node) {
|
|
1676
|
+
return;
|
|
1677
|
+
}
|
|
1678
|
+
if (index === 0) {
|
|
1679
|
+
firstItemTextRef.current = node;
|
|
1680
|
+
}
|
|
1681
|
+
if (selectedByFocus) {
|
|
1682
|
+
selectedItemTextRef.current = node;
|
|
1683
|
+
}
|
|
1684
|
+
}, [firstItemTextRef, selectedItemTextRef, index, selectedByFocus]);
|
|
1685
|
+
const element = useRenderElement('div', componentProps, {
|
|
1686
|
+
ref: [localRef, forwardedRef, textRef],
|
|
1687
|
+
props: elementProps
|
|
1688
|
+
});
|
|
1689
|
+
return element;
|
|
1690
|
+
}));
|
|
1691
|
+
if (process.env.NODE_ENV !== "production") SelectItemText.displayName = "SelectItemText";
|
|
1692
|
+
|
|
1693
|
+
const SelectGroupContext = /*#__PURE__*/React.createContext(undefined);
|
|
1694
|
+
if (process.env.NODE_ENV !== "production") SelectGroupContext.displayName = "SelectGroupContext";
|
|
1695
|
+
function useSelectGroupContext() {
|
|
1696
|
+
const context = React.useContext(SelectGroupContext);
|
|
1697
|
+
if (context === undefined) {
|
|
1698
|
+
throw new Error(process.env.NODE_ENV !== "production" ? 'Base UI: SelectGroupContext is missing. SelectGroup parts must be placed within <Select.Group>.' : formatErrorMessage(56));
|
|
1699
|
+
}
|
|
1700
|
+
return context;
|
|
1701
|
+
}
|
|
1702
|
+
|
|
1703
|
+
const SelectGroup = /*#__PURE__*/React.forwardRef(function SelectGroup(componentProps, forwardedRef) {
|
|
1704
|
+
const {
|
|
1705
|
+
render,
|
|
1706
|
+
className,
|
|
1707
|
+
style,
|
|
1708
|
+
...elementProps
|
|
1709
|
+
} = componentProps;
|
|
1710
|
+
const [labelId, setLabelId] = React.useState();
|
|
1711
|
+
const contextValue = React.useMemo(() => ({
|
|
1712
|
+
labelId,
|
|
1713
|
+
setLabelId
|
|
1714
|
+
}), [labelId, setLabelId]);
|
|
1715
|
+
const element = useRenderElement('div', componentProps, {
|
|
1716
|
+
ref: forwardedRef,
|
|
1717
|
+
props: [{
|
|
1718
|
+
role: 'group',
|
|
1719
|
+
'aria-labelledby': labelId
|
|
1720
|
+
}, elementProps]
|
|
1721
|
+
});
|
|
1722
|
+
return /*#__PURE__*/jsx(SelectGroupContext.Provider, {
|
|
1723
|
+
value: contextValue,
|
|
1724
|
+
children: element
|
|
1725
|
+
});
|
|
1726
|
+
});
|
|
1727
|
+
if (process.env.NODE_ENV !== "production") SelectGroup.displayName = "SelectGroup";
|
|
1728
|
+
|
|
1729
|
+
/**
|
|
1730
|
+
* An accessible label that is automatically associated with its parent group.
|
|
1731
|
+
* Renders a `<div>` element.
|
|
1732
|
+
*
|
|
1733
|
+
* Documentation: [Base UI Select](https://base-ui.com/react/components/select)
|
|
1734
|
+
*/
|
|
1735
|
+
const SelectGroupLabel = /*#__PURE__*/React.forwardRef(function SelectGroupLabel(componentProps, forwardedRef) {
|
|
1736
|
+
const {
|
|
1737
|
+
render,
|
|
1738
|
+
className,
|
|
1739
|
+
style,
|
|
1740
|
+
id: idProp,
|
|
1741
|
+
...elementProps
|
|
1742
|
+
} = componentProps;
|
|
1743
|
+
const {
|
|
1744
|
+
setLabelId
|
|
1745
|
+
} = useSelectGroupContext();
|
|
1746
|
+
const id = useBaseUiId(idProp);
|
|
1747
|
+
useIsoLayoutEffect(() => {
|
|
1748
|
+
setLabelId(id);
|
|
1749
|
+
return () => {
|
|
1750
|
+
setLabelId(currentId => currentId === id ? undefined : currentId);
|
|
1751
|
+
};
|
|
1752
|
+
}, [id, setLabelId]);
|
|
1753
|
+
const element = useRenderElement('div', componentProps, {
|
|
1754
|
+
ref: forwardedRef,
|
|
1755
|
+
props: [{
|
|
1756
|
+
id
|
|
1757
|
+
}, elementProps]
|
|
1758
|
+
});
|
|
1759
|
+
return element;
|
|
1760
|
+
});
|
|
1761
|
+
if (process.env.NODE_ENV !== "production") SelectGroupLabel.displayName = "SelectGroupLabel";
|
|
1762
|
+
|
|
1763
|
+
export { SelectRoot as S, SelectPortal as a, SelectTrigger as b, SelectValue as c, SelectPositioner as d, SelectPopup as e, SelectList as f, SelectItem as g, SelectItemText as h, SelectItemIndicator as i, SelectGroup as j, SelectGroupLabel as k, isElementDisabled as l, usePreviousValue as m, useSelectRootContext as n, useSelectPositionerContext as o, selectors as s, useToolbarRootContext as u };
|