@carbon/react 1.103.0 → 1.104.0-rc.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/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +956 -956
- package/es/_virtual/_rolldown/runtime.js +25 -0
- package/es/components/AILabel/index.d.ts +29 -2
- package/es/components/AILabel/index.js +114 -169
- package/es/components/AISkeleton/AISkeletonIcon.js +23 -27
- package/es/components/AISkeleton/AISkeletonPlaceholder.js +19 -27
- package/es/components/AISkeleton/AISkeletonText.js +26 -39
- package/es/components/Accordion/Accordion.Skeleton.js +55 -79
- package/es/components/Accordion/Accordion.js +43 -61
- package/es/components/Accordion/AccordionItem.js +102 -156
- package/es/components/Accordion/AccordionProvider.js +18 -15
- package/es/components/AspectRatio/AspectRatio.js +41 -47
- package/es/components/BadgeIndicator/index.js +28 -33
- package/es/components/Breadcrumb/Breadcrumb.Skeleton.js +39 -50
- package/es/components/Breadcrumb/Breadcrumb.js +39 -51
- package/es/components/Breadcrumb/BreadcrumbItem.js +80 -83
- package/es/components/Button/Button.Skeleton.js +49 -58
- package/es/components/Button/Button.d.ts +1 -1
- package/es/components/Button/Button.js +146 -240
- package/es/components/Button/ButtonBase.js +82 -104
- package/es/components/Button/index.js +13 -6
- package/es/components/ButtonSet/ButtonSet.js +74 -98
- package/es/components/ButtonSet/index.js +12 -4
- package/es/components/ChatButton/ChatButton.Skeleton.js +27 -27
- package/es/components/ChatButton/ChatButton.js +64 -79
- package/es/components/Checkbox/Checkbox.Skeleton.js +26 -25
- package/es/components/Checkbox/Checkbox.js +116 -195
- package/es/components/Checkbox/index.js +13 -5
- package/es/components/CheckboxGroup/CheckboxGroup.js +100 -148
- package/es/components/ClassPrefix/index.js +21 -17
- package/es/components/CodeSnippet/CodeSnippet.Skeleton.js +45 -42
- package/es/components/CodeSnippet/CodeSnippet.js +210 -299
- package/es/components/ComboBox/ComboBox.js +621 -970
- package/es/components/ComboBox/index.js +12 -4
- package/es/components/ComboButton/index.js +172 -208
- package/es/components/ComposedModal/ComposedModal.js +311 -450
- package/es/components/ComposedModal/ComposedModalPresence.js +47 -42
- package/es/components/ComposedModal/ModalFooter.js +127 -207
- package/es/components/ComposedModal/ModalHeader.js +71 -101
- package/es/components/ComposedModal/useComposedModalState.js +21 -15
- package/es/components/ContainedList/ContainedList.js +67 -102
- package/es/components/ContainedList/ContainedListItem/ContainedListItem.js +49 -67
- package/es/components/ContainedList/ContainedListItem/index.js +12 -4
- package/es/components/ContainedList/index.js +15 -12
- package/es/components/ContentSwitcher/ContentSwitcher.js +108 -140
- package/es/components/ContextMenu/useContextMenu.js +41 -36
- package/es/components/Copy/Copy.js +97 -117
- package/es/components/Copy/index.js +12 -4
- package/es/components/CopyButton/CopyButton.js +81 -94
- package/es/components/CopyButton/index.js +12 -4
- package/es/components/DangerButton/DangerButton.js +11 -9
- package/es/components/DataTable/DataTable.d.ts +11 -11
- package/es/components/DataTable/DataTable.js +448 -630
- package/es/components/DataTable/Table.js +111 -156
- package/es/components/DataTable/TableActionList.js +14 -6
- package/es/components/DataTable/TableBatchAction.js +25 -34
- package/es/components/DataTable/TableBatchActions.js +78 -113
- package/es/components/DataTable/TableBody.js +26 -19
- package/es/components/DataTable/TableCell.js +31 -46
- package/es/components/DataTable/TableContainer.js +75 -82
- package/es/components/DataTable/TableContext.js +14 -6
- package/es/components/DataTable/TableDecoratorRow.js +30 -36
- package/es/components/DataTable/TableExpandHeader.js +53 -90
- package/es/components/DataTable/TableExpandRow.js +82 -119
- package/es/components/DataTable/TableExpandedRow.js +45 -51
- package/es/components/DataTable/TableHead.js +7 -5
- package/es/components/DataTable/TableHeader.js +138 -181
- package/es/components/DataTable/TableRow.d.ts +1 -1
- package/es/components/DataTable/TableRow.js +42 -76
- package/es/components/DataTable/TableSelectAll.js +42 -70
- package/es/components/DataTable/TableSelectRow.js +63 -98
- package/es/components/DataTable/TableSlugRow.js +35 -43
- package/es/components/DataTable/TableToolbar.js +33 -45
- package/es/components/DataTable/TableToolbarAction.js +25 -20
- package/es/components/DataTable/TableToolbarContent.js +14 -6
- package/es/components/DataTable/TableToolbarMenu.js +35 -46
- package/es/components/DataTable/TableToolbarSearch.js +97 -187
- package/es/components/DataTable/state/getDerivedStateFromProps.js +38 -43
- package/es/components/DataTable/state/sortStates.js +11 -9
- package/es/components/DataTable/state/sorting.js +53 -72
- package/es/components/DataTable/tools/cells.js +15 -7
- package/es/components/DataTable/tools/denormalize.js +27 -19
- package/es/components/DataTable/tools/filter.js +21 -22
- package/es/components/DataTable/tools/normalize.js +57 -72
- package/es/components/DataTable/tools/sorting.js +50 -71
- package/es/components/DataTableSkeleton/DataTableSkeleton.js +66 -94
- package/es/components/DatePicker/DatePicker.Skeleton.js +44 -51
- package/es/components/DatePicker/DatePicker.js +485 -752
- package/es/components/DatePicker/DatePickerLocales.js +75 -126
- package/es/components/DatePicker/index.js +13 -5
- package/es/components/DatePicker/plugins/appendToPlugin.js +31 -45
- package/es/components/DatePicker/plugins/fixEventsPlugin.js +127 -171
- package/es/components/DatePicker/plugins/rangePlugin.js +40 -48
- package/es/components/DatePicker/utils.js +11 -3
- package/es/components/DatePickerInput/DatePickerInput.js +179 -289
- package/es/components/DatePickerInput/index.js +12 -4
- package/es/components/Dialog/Dialog.js +303 -574
- package/es/components/Dialog/index.js +18 -2
- package/es/components/Dropdown/Dropdown.Skeleton.js +26 -38
- package/es/components/Dropdown/Dropdown.js +344 -535
- package/es/components/Dropdown/index.js +13 -5
- package/es/components/ErrorBoundary/ErrorBoundary.js +36 -58
- package/es/components/ErrorBoundary/ErrorBoundaryContext.js +14 -9
- package/es/components/ExpandableSearch/ExpandableSearch.js +60 -69
- package/es/components/ExpandableSearch/index.js +12 -4
- package/es/components/FeatureFlags/index.d.ts +11 -2
- package/es/components/FeatureFlags/index.js +79 -77
- package/es/components/FileUploader/FileUploader.Skeleton.js +35 -30
- package/es/components/FileUploader/FileUploader.js +269 -343
- package/es/components/FileUploader/FileUploaderButton.js +110 -160
- package/es/components/FileUploader/FileUploaderDropContainer.js +144 -221
- package/es/components/FileUploader/FileUploaderItem.js +138 -157
- package/es/components/FileUploader/Filename.d.ts +1 -1
- package/es/components/FileUploader/Filename.js +53 -72
- package/es/components/FluidComboBox/FluidComboBox.Skeleton.js +26 -28
- package/es/components/FluidComboBox/FluidComboBox.js +54 -105
- package/es/components/FluidDatePicker/FluidDatePicker.Skeleton.js +56 -53
- package/es/components/FluidDatePicker/FluidDatePicker.js +46 -68
- package/es/components/FluidDatePickerInput/FluidDatePickerInput.js +23 -16
- package/es/components/FluidDropdown/FluidDropdown.Skeleton.js +26 -28
- package/es/components/FluidDropdown/FluidDropdown.js +55 -111
- package/es/components/FluidForm/FluidForm.js +29 -31
- package/es/components/FluidForm/FormContext.js +12 -6
- package/es/components/FluidMultiSelect/FluidMultiSelect.Skeleton.js +26 -28
- package/es/components/FluidMultiSelect/FluidMultiSelect.js +67 -197
- package/es/components/FluidNumberInput/FluidNumberInput.Skeleton.js +27 -30
- package/es/components/FluidNumberInput/FluidNumberInput.js +63 -147
- package/es/components/FluidSearch/FluidSearch.Skeleton.js +27 -30
- package/es/components/FluidSearch/FluidSearch.js +41 -84
- package/es/components/FluidSelect/FluidSelect.Skeleton.js +26 -28
- package/es/components/FluidSelect/FluidSelect.js +40 -76
- package/es/components/FluidSelect/index.js +13 -5
- package/es/components/FluidTextArea/FluidTextArea.Skeleton.js +27 -30
- package/es/components/FluidTextArea/FluidTextArea.js +48 -112
- package/es/components/FluidTextInput/FluidPasswordInput.js +44 -99
- package/es/components/FluidTextInput/FluidTextInput.Skeleton.js +27 -30
- package/es/components/FluidTextInput/FluidTextInput.js +49 -104
- package/es/components/FluidTextInput/index.js +14 -6
- package/es/components/FluidTimePicker/FluidTimePicker.Skeleton.js +30 -33
- package/es/components/FluidTimePicker/FluidTimePicker.js +68 -115
- package/es/components/FluidTimePickerSelect/FluidTimePickerSelect.js +28 -47
- package/es/components/Form/Form.js +23 -25
- package/es/components/FormGroup/FormGroup.js +45 -67
- package/es/components/FormItem/FormItem.js +23 -25
- package/es/components/FormLabel/FormLabel.js +28 -34
- package/es/components/Grid/CSSGrid.d.ts +1 -1
- package/es/components/Grid/CSSGrid.js +85 -127
- package/es/components/Grid/Column.js +192 -324
- package/es/components/Grid/ColumnHang.js +28 -36
- package/es/components/Grid/FlexGrid.js +40 -60
- package/es/components/Grid/Grid.js +29 -42
- package/es/components/Grid/GridContext.js +36 -42
- package/es/components/Grid/Row.js +31 -49
- package/es/components/Heading/index.js +36 -51
- package/es/components/Icon/Icon.Skeleton.js +21 -21
- package/es/components/IconButton/index.js +117 -178
- package/es/components/IconIndicator/index.d.ts +1 -1
- package/es/components/IconIndicator/index.js +59 -60
- package/es/components/IdPrefix/index.js +21 -17
- package/es/components/InlineCheckbox/InlineCheckbox.js +69 -113
- package/es/components/InlineCheckbox/index.js +12 -4
- package/es/components/InlineLoading/InlineLoading.js +83 -100
- package/es/components/InlineLoading/index.js +12 -4
- package/es/components/Layer/LayerContext.js +12 -4
- package/es/components/Layer/LayerLevel.js +20 -4
- package/es/components/Layer/index.js +54 -66
- package/es/components/Layout/index.js +77 -109
- package/es/components/LayoutDirection/LayoutDirection.d.ts +1 -1
- package/es/components/LayoutDirection/LayoutDirection.js +33 -37
- package/es/components/LayoutDirection/LayoutDirectionContext.js +12 -6
- package/es/components/LayoutDirection/useLayoutDirection.js +15 -7
- package/es/components/Link/Link.js +63 -108
- package/es/components/Link/index.js +12 -4
- package/es/components/ListBox/ListBox.js +78 -126
- package/es/components/ListBox/ListBoxField.js +24 -43
- package/es/components/ListBox/ListBoxMenu.js +36 -42
- package/es/components/ListBox/ListBoxMenuIcon.js +39 -40
- package/es/components/ListBox/ListBoxMenuItem.js +67 -88
- package/es/components/ListBox/ListBoxPropTypes.js +17 -5
- package/es/components/ListBox/ListBoxSelection.js +71 -96
- package/es/components/ListBox/index.js +16 -14
- package/es/components/ListBox/next/ListBoxSelection.js +79 -117
- package/es/components/ListBox/next/ListBoxTrigger.js +44 -48
- package/es/components/ListItem/ListItem.js +25 -28
- package/es/components/Loading/Loading.js +64 -73
- package/es/components/Loading/index.js +12 -4
- package/es/components/Menu/Menu.js +220 -363
- package/es/components/Menu/MenuContext.d.ts +1 -1
- package/es/components/Menu/MenuContext.js +41 -38
- package/es/components/Menu/MenuItem.js +282 -413
- package/es/components/MenuButton/index.js +134 -195
- package/es/components/Modal/Modal.js +500 -660
- package/es/components/Modal/ModalPresence.js +39 -37
- package/es/components/Modal/index.js +13 -5
- package/es/components/ModalWrapper/ModalWrapper.d.ts +2 -2
- package/es/components/ModalWrapper/ModalWrapper.js +106 -130
- package/es/components/MultiSelect/FilterableMultiSelect.js +605 -918
- package/es/components/MultiSelect/MultiSelect.js +454 -716
- package/es/components/MultiSelect/MultiSelectPropTypes.js +13 -30
- package/es/components/MultiSelect/filter.js +14 -9
- package/es/components/MultiSelect/tools/sorting.js +21 -34
- package/es/components/Notification/Notification.js +508 -785
- package/es/components/NumberInput/NumberFormatPropTypes.js +69 -30
- package/es/components/NumberInput/NumberInput.Skeleton.js +29 -33
- package/es/components/NumberInput/NumberInput.js +567 -947
- package/es/components/OrderedList/OrderedList.js +31 -44
- package/es/components/OverflowMenu/OverflowMenu.js +335 -450
- package/es/components/OverflowMenu/index.js +25 -16
- package/es/components/OverflowMenu/next/index.js +154 -186
- package/es/components/OverflowMenuItem/OverflowMenuItem.js +100 -160
- package/es/components/OverflowMenuItem/index.js +12 -4
- package/es/components/OverflowMenuV2/index.js +15 -13
- package/es/components/PageHeader/PageHeader.js +297 -442
- package/es/components/PageHeader/index.js +24 -2
- package/es/components/Pagination/Pagination.Skeleton.js +34 -35
- package/es/components/Pagination/Pagination.d.ts +1 -1
- package/es/components/Pagination/Pagination.js +251 -356
- package/es/components/Pagination/experimental/PageSelector.js +38 -54
- package/es/components/Pagination/experimental/Pagination-story.d.ts +114 -0
- package/es/components/Pagination/experimental/Pagination.js +144 -196
- package/es/components/PaginationNav/PaginationNav.js +320 -426
- package/es/components/Popover/index.js +318 -437
- package/es/components/PrimaryButton/PrimaryButton.js +11 -9
- package/es/components/ProgressBar/ProgressBar.js +117 -143
- package/es/components/ProgressIndicator/ProgressIndicator.Skeleton.js +42 -38
- package/es/components/ProgressIndicator/ProgressIndicator.js +146 -243
- package/es/components/RadioButton/RadioButton.Skeleton.js +23 -25
- package/es/components/RadioButton/RadioButton.js +101 -174
- package/es/components/RadioButton/index.js +12 -4
- package/es/components/RadioButtonGroup/RadioButtonGroup.js +135 -207
- package/es/components/RadioTile/RadioTile.js +104 -168
- package/es/components/RadioTile/index.js +12 -4
- package/es/components/Search/Search.Skeleton.js +28 -33
- package/es/components/Search/Search.js +182 -278
- package/es/components/Search/index.js +13 -5
- package/es/components/Search/utils.js +11 -3
- package/es/components/SecondaryButton/SecondaryButton.js +11 -9
- package/es/components/Select/Select.Skeleton.js +27 -30
- package/es/components/Select/Select.js +178 -257
- package/es/components/Select/index.js +13 -5
- package/es/components/SelectItem/SelectItem.js +33 -48
- package/es/components/SelectItem/index.js +12 -4
- package/es/components/SelectItemGroup/SelectItemGroup.js +27 -37
- package/es/components/ShapeIndicator/index.d.ts +1 -1
- package/es/components/ShapeIndicator/index.js +74 -80
- package/es/components/SkeletonIcon/SkeletonIcon.js +21 -24
- package/es/components/SkeletonPlaceholder/SkeletonPlaceholder.js +15 -24
- package/es/components/SkeletonText/SkeletonText.js +67 -81
- package/es/components/SkeletonText/index.js +12 -4
- package/es/components/Slider/Slider.Skeleton.js +68 -91
- package/es/components/Slider/Slider.js +864 -1315
- package/es/components/Slider/SliderHandles.js +73 -66
- package/es/components/Stack/HStack.js +19 -11
- package/es/components/Stack/Stack.js +56 -80
- package/es/components/Stack/VStack.js +19 -11
- package/es/components/StructuredList/StructuredList.Skeleton.js +55 -48
- package/es/components/StructuredList/StructuredList.js +178 -317
- package/es/components/Switch/IconSwitch.js +99 -145
- package/es/components/Switch/Switch.js +66 -99
- package/es/components/TabContent/TabContent.js +28 -34
- package/es/components/Tabs/Tabs.Skeleton.js +41 -36
- package/es/components/Tabs/Tabs.js +732 -1149
- package/es/components/Tabs/usePressable.js +97 -112
- package/es/components/Tag/DismissibleTag.js +119 -156
- package/es/components/Tag/OperationalTag.js +91 -111
- package/es/components/Tag/SelectableTag.js +94 -129
- package/es/components/Tag/Tag.Skeleton.js +26 -30
- package/es/components/Tag/Tag.js +152 -200
- package/es/components/Tag/isEllipsisActive.js +13 -8
- package/es/components/Text/Text.js +66 -79
- package/es/components/Text/TextDirection.js +36 -37
- package/es/components/Text/TextDirectionContext.js +14 -8
- package/es/components/Text/createTextComponent.js +21 -20
- package/es/components/TextArea/TextArea.Skeleton.js +25 -29
- package/es/components/TextArea/TextArea.js +315 -422
- package/es/components/TextArea/index.js +13 -5
- package/es/components/TextInput/ControlledPasswordInput.js +133 -198
- package/es/components/TextInput/PasswordInput.js +196 -303
- package/es/components/TextInput/TextInput.Skeleton.js +24 -28
- package/es/components/TextInput/TextInput.js +219 -317
- package/es/components/TextInput/index.js +13 -5
- package/es/components/TextInput/util.js +21 -25
- package/es/components/Theme/index.js +79 -95
- package/es/components/Tile/Tile.js +394 -593
- package/es/components/TileGroup/TileGroup.js +70 -111
- package/es/components/TimePicker/TimePicker.d.ts +1 -1
- package/es/components/TimePicker/TimePicker.js +148 -247
- package/es/components/TimePickerSelect/TimePickerSelect.js +43 -58
- package/es/components/Toggle/Toggle.Skeleton.js +24 -22
- package/es/components/Toggle/Toggle.js +102 -171
- package/es/components/ToggleSmall/ToggleSmall.Skeleton.js +46 -51
- package/es/components/Toggletip/index.d.ts +2 -2
- package/es/components/Toggletip/index.js +170 -256
- package/es/components/Tooltip/DefinitionTooltip.js +98 -138
- package/es/components/Tooltip/Tooltip.js +188 -263
- package/es/components/TreeView/TreeContext.js +13 -5
- package/es/components/TreeView/TreeNode.js +361 -500
- package/es/components/TreeView/TreeView.js +164 -237
- package/es/components/UIShell/Content.js +23 -30
- package/es/components/UIShell/Header.js +25 -29
- package/es/components/UIShell/HeaderContainer.js +31 -40
- package/es/components/UIShell/HeaderGlobalAction.js +65 -90
- package/es/components/UIShell/HeaderGlobalBar.js +16 -9
- package/es/components/UIShell/HeaderMenu.js +141 -215
- package/es/components/UIShell/HeaderMenuButton.js +43 -66
- package/es/components/UIShell/HeaderMenuItem.js +49 -76
- package/es/components/UIShell/HeaderName.js +32 -44
- package/es/components/UIShell/HeaderNavigation.js +32 -37
- package/es/components/UIShell/HeaderPanel.js +74 -97
- package/es/components/UIShell/HeaderSideNavItems.js +27 -33
- package/es/components/UIShell/Link.js +29 -50
- package/es/components/UIShell/SideNav.js +132 -241
- package/es/components/UIShell/SideNavContext.js +21 -15
- package/es/components/UIShell/SideNavDetails.js +29 -34
- package/es/components/UIShell/SideNavDivider.js +21 -21
- package/es/components/UIShell/SideNavFooter.js +43 -52
- package/es/components/UIShell/SideNavHeader.js +26 -35
- package/es/components/UIShell/SideNavIcon.js +28 -33
- package/es/components/UIShell/SideNavItem.js +28 -33
- package/es/components/UIShell/SideNavItems.js +31 -40
- package/es/components/UIShell/SideNavLink.js +52 -79
- package/es/components/UIShell/SideNavLinkText.js +24 -25
- package/es/components/UIShell/SideNavMenu.js +102 -143
- package/es/components/UIShell/SideNavMenuItem.js +40 -52
- package/es/components/UIShell/SideNavSwitcher.js +59 -68
- package/es/components/UIShell/SkipToContent.js +28 -36
- package/es/components/UIShell/Switcher.js +69 -99
- package/es/components/UIShell/SwitcherDivider.js +16 -24
- package/es/components/UIShell/SwitcherItem.js +74 -114
- package/es/components/UnorderedList/UnorderedList.js +28 -37
- package/es/feature-flags.js +19 -10
- package/es/index.js +249 -242
- package/es/internal/FloatingMenu.js +246 -292
- package/es/internal/OptimizedResize.js +35 -46
- package/es/internal/Selection.js +99 -132
- package/es/internal/clamp.js +12 -4
- package/es/internal/defaultItemToString.js +15 -9
- package/es/internal/deprecateFieldOnObject.js +22 -14
- package/es/internal/environment.js +15 -7
- package/es/internal/getAnnouncement.js +16 -13
- package/es/internal/keyboard/keys.js +48 -48
- package/es/internal/keyboard/match.js +25 -42
- package/es/internal/keyboard/navigation.js +22 -27
- package/es/internal/noopFn.js +10 -2
- package/es/internal/useAttachedMenu.js +43 -51
- package/es/internal/useControllableState.js +43 -48
- package/es/internal/useDelayedState.js +30 -35
- package/es/internal/useEvent.js +39 -35
- package/es/internal/useId.js +51 -87
- package/es/internal/useIdPrefix.js +13 -5
- package/es/internal/useIsomorphicEffect.js +12 -4
- package/es/internal/useMatchMedia.js +29 -21
- package/es/internal/useMergedRefs.js +26 -22
- package/es/internal/useNoInteractiveChildren.js +70 -99
- package/es/internal/useNormalizedInputProps.js +47 -51
- package/es/internal/useOutsideClick.js +21 -24
- package/es/internal/useOverflowItems.js +89 -90
- package/es/internal/usePrefix.js +13 -5
- package/es/internal/usePresence.js +51 -54
- package/es/internal/usePresenceContext.js +35 -35
- package/es/internal/usePreviousValue.js +26 -18
- package/es/internal/useResizeObserver.js +57 -66
- package/es/internal/useSavedCallback.js +24 -17
- package/es/internal/utils.js +17 -9
- package/es/internal/warning.js +17 -22
- package/es/internal/wrapFocus.js +77 -98
- package/es/prop-types/AriaPropTypes.js +14 -6
- package/es/prop-types/deprecate.js +30 -27
- package/es/prop-types/deprecateComponent.js +17 -8
- package/es/prop-types/deprecateValuesWithin.js +18 -21
- package/es/prop-types/isRequiredOneOf.js +21 -24
- package/es/prop-types/requiredIfGivenPropIsTruthy.js +14 -14
- package/es/tools/events.js +17 -21
- package/es/tools/mapPopoverAlign.js +19 -18
- package/es/tools/mergeRefs.js +14 -17
- package/es/tools/setupGetInstanceId.js +16 -8
- package/es/tools/toggleClass.js +17 -9
- package/es/tools/wrapComponent.js +34 -39
- package/icons/index.d.ts +2 -1
- package/icons/index.esm.js +2 -2
- package/icons/index.js +7 -10
- package/lib/_virtual/_rolldown/runtime.js +50 -0
- package/lib/components/AILabel/index.d.ts +29 -2
- package/lib/components/AILabel/index.js +118 -171
- package/lib/components/AISkeleton/AISkeletonIcon.js +27 -31
- package/lib/components/AISkeleton/AISkeletonPlaceholder.js +29 -31
- package/lib/components/AISkeleton/AISkeletonText.js +30 -43
- package/lib/components/Accordion/Accordion.Skeleton.js +59 -84
- package/lib/components/Accordion/Accordion.js +47 -65
- package/lib/components/Accordion/AccordionItem.js +106 -160
- package/lib/components/Accordion/AccordionProvider.js +20 -17
- package/lib/components/AspectRatio/AspectRatio.js +45 -51
- package/lib/components/BadgeIndicator/index.js +33 -39
- package/lib/components/Breadcrumb/Breadcrumb.Skeleton.js +43 -55
- package/lib/components/Breadcrumb/Breadcrumb.js +43 -55
- package/lib/components/Breadcrumb/BreadcrumbItem.js +84 -87
- package/lib/components/Button/Button.Skeleton.js +53 -63
- package/lib/components/Button/Button.d.ts +1 -1
- package/lib/components/Button/Button.js +149 -244
- package/lib/components/Button/ButtonBase.js +85 -108
- package/lib/components/Button/index.js +13 -15
- package/lib/components/ButtonSet/ButtonSet.js +78 -102
- package/lib/components/ButtonSet/index.js +12 -9
- package/lib/components/ChatButton/ChatButton.Skeleton.js +31 -31
- package/lib/components/ChatButton/ChatButton.js +68 -83
- package/lib/components/Checkbox/Checkbox.Skeleton.js +30 -30
- package/lib/components/Checkbox/Checkbox.js +119 -198
- package/lib/components/Checkbox/index.js +13 -11
- package/lib/components/CheckboxGroup/CheckboxGroup.js +104 -152
- package/lib/components/ClassPrefix/index.js +24 -19
- package/lib/components/CodeSnippet/CodeSnippet.Skeleton.js +49 -47
- package/lib/components/CodeSnippet/CodeSnippet.js +215 -303
- package/lib/components/ComboBox/ComboBox.js +626 -974
- package/lib/components/ComboBox/index.js +12 -9
- package/lib/components/ComboButton/index.js +176 -210
- package/lib/components/ComposedModal/ComposedModal.js +315 -454
- package/lib/components/ComposedModal/ComposedModalPresence.js +49 -44
- package/lib/components/ComposedModal/ModalFooter.js +131 -209
- package/lib/components/ComposedModal/ModalHeader.js +75 -103
- package/lib/components/ComposedModal/useComposedModalState.js +22 -17
- package/lib/components/ContainedList/ContainedList.js +77 -106
- package/lib/components/ContainedList/ContainedListItem/ContainedListItem.js +59 -71
- package/lib/components/ContainedList/ContainedListItem/index.js +12 -9
- package/lib/components/ContainedList/index.js +18 -15
- package/lib/components/ContentSwitcher/ContentSwitcher.js +112 -142
- package/lib/components/ContextMenu/useContextMenu.js +42 -40
- package/lib/components/Copy/Copy.js +101 -121
- package/lib/components/Copy/index.js +12 -9
- package/lib/components/CopyButton/CopyButton.js +85 -98
- package/lib/components/CopyButton/index.js +12 -9
- package/lib/components/DangerButton/DangerButton.js +19 -13
- package/lib/components/DataTable/DataTable.d.ts +11 -11
- package/lib/components/DataTable/DataTable.js +474 -655
- package/lib/components/DataTable/Table.js +115 -161
- package/lib/components/DataTable/TableActionList.js +15 -11
- package/lib/components/DataTable/TableBatchAction.js +28 -38
- package/lib/components/DataTable/TableBatchActions.js +82 -117
- package/lib/components/DataTable/TableBody.js +29 -23
- package/lib/components/DataTable/TableCell.js +35 -50
- package/lib/components/DataTable/TableContainer.js +79 -86
- package/lib/components/DataTable/TableContext.js +15 -8
- package/lib/components/DataTable/TableDecoratorRow.js +34 -40
- package/lib/components/DataTable/TableExpandHeader.js +57 -94
- package/lib/components/DataTable/TableExpandRow.js +86 -123
- package/lib/components/DataTable/TableExpandedRow.js +49 -55
- package/lib/components/DataTable/TableHead.js +8 -10
- package/lib/components/DataTable/TableHeader.js +142 -185
- package/lib/components/DataTable/TableRow.d.ts +1 -1
- package/lib/components/DataTable/TableRow.js +46 -80
- package/lib/components/DataTable/TableSelectAll.js +46 -74
- package/lib/components/DataTable/TableSelectRow.js +67 -102
- package/lib/components/DataTable/TableSlugRow.js +39 -47
- package/lib/components/DataTable/TableToolbar.js +37 -49
- package/lib/components/DataTable/TableToolbarAction.js +28 -24
- package/lib/components/DataTable/TableToolbarContent.js +15 -11
- package/lib/components/DataTable/TableToolbarMenu.js +39 -50
- package/lib/components/DataTable/TableToolbarSearch.js +101 -191
- package/lib/components/DataTable/state/getDerivedStateFromProps.js +38 -47
- package/lib/components/DataTable/state/sortStates.js +11 -10
- package/lib/components/DataTable/state/sorting.js +54 -76
- package/lib/components/DataTable/tools/cells.js +15 -8
- package/lib/components/DataTable/tools/denormalize.js +27 -22
- package/lib/components/DataTable/tools/filter.js +21 -23
- package/lib/components/DataTable/tools/normalize.js +57 -76
- package/lib/components/DataTable/tools/sorting.js +50 -75
- package/lib/components/DataTableSkeleton/DataTableSkeleton.js +70 -98
- package/lib/components/DatePicker/DatePicker.Skeleton.js +48 -56
- package/lib/components/DatePicker/DatePicker.js +491 -756
- package/lib/components/DatePicker/DatePickerLocales.js +75 -127
- package/lib/components/DatePicker/index.js +13 -11
- package/lib/components/DatePicker/plugins/appendToPlugin.js +31 -46
- package/lib/components/DatePicker/plugins/fixEventsPlugin.js +127 -175
- package/lib/components/DatePicker/plugins/rangePlugin.js +42 -50
- package/lib/components/DatePicker/utils.js +11 -4
- package/lib/components/DatePickerInput/DatePickerInput.js +183 -293
- package/lib/components/DatePickerInput/index.js +12 -9
- package/lib/components/Dialog/Dialog.js +307 -576
- package/lib/components/Dialog/index.js +21 -13
- package/lib/components/Dropdown/Dropdown.Skeleton.js +30 -43
- package/lib/components/Dropdown/Dropdown.js +348 -539
- package/lib/components/Dropdown/index.js +13 -11
- package/lib/components/ErrorBoundary/ErrorBoundary.js +39 -62
- package/lib/components/ErrorBoundary/ErrorBoundaryContext.js +15 -11
- package/lib/components/ExpandableSearch/ExpandableSearch.js +63 -73
- package/lib/components/ExpandableSearch/index.js +12 -9
- package/lib/components/FeatureFlags/index.d.ts +11 -2
- package/lib/components/FeatureFlags/index.js +82 -79
- package/lib/components/FileUploader/FileUploader.Skeleton.js +39 -35
- package/lib/components/FileUploader/FileUploader.js +273 -347
- package/lib/components/FileUploader/FileUploaderButton.js +114 -164
- package/lib/components/FileUploader/FileUploaderDropContainer.js +148 -225
- package/lib/components/FileUploader/FileUploaderItem.js +142 -161
- package/lib/components/FileUploader/Filename.d.ts +1 -1
- package/lib/components/FileUploader/Filename.js +56 -76
- package/lib/components/FluidComboBox/FluidComboBox.Skeleton.js +30 -32
- package/lib/components/FluidComboBox/FluidComboBox.js +58 -109
- package/lib/components/FluidDatePicker/FluidDatePicker.Skeleton.js +60 -57
- package/lib/components/FluidDatePicker/FluidDatePicker.js +50 -72
- package/lib/components/FluidDatePickerInput/FluidDatePickerInput.js +25 -20
- package/lib/components/FluidDropdown/FluidDropdown.Skeleton.js +30 -32
- package/lib/components/FluidDropdown/FluidDropdown.js +59 -115
- package/lib/components/FluidForm/FluidForm.js +33 -35
- package/lib/components/FluidForm/FormContext.js +13 -8
- package/lib/components/FluidMultiSelect/FluidMultiSelect.Skeleton.js +30 -32
- package/lib/components/FluidMultiSelect/FluidMultiSelect.js +71 -201
- package/lib/components/FluidNumberInput/FluidNumberInput.Skeleton.js +31 -34
- package/lib/components/FluidNumberInput/FluidNumberInput.js +67 -151
- package/lib/components/FluidSearch/FluidSearch.Skeleton.js +31 -34
- package/lib/components/FluidSearch/FluidSearch.js +45 -88
- package/lib/components/FluidSelect/FluidSelect.Skeleton.js +30 -32
- package/lib/components/FluidSelect/FluidSelect.js +44 -80
- package/lib/components/FluidSelect/index.js +13 -11
- package/lib/components/FluidTextArea/FluidTextArea.Skeleton.js +31 -34
- package/lib/components/FluidTextArea/FluidTextArea.js +52 -116
- package/lib/components/FluidTextInput/FluidPasswordInput.js +48 -103
- package/lib/components/FluidTextInput/FluidTextInput.Skeleton.js +31 -34
- package/lib/components/FluidTextInput/FluidTextInput.js +53 -108
- package/lib/components/FluidTextInput/index.js +14 -13
- package/lib/components/FluidTimePicker/FluidTimePicker.Skeleton.js +34 -37
- package/lib/components/FluidTimePicker/FluidTimePicker.js +72 -119
- package/lib/components/FluidTimePickerSelect/FluidTimePickerSelect.js +31 -51
- package/lib/components/Form/Form.js +27 -29
- package/lib/components/FormGroup/FormGroup.js +49 -71
- package/lib/components/FormItem/FormItem.js +27 -29
- package/lib/components/FormLabel/FormLabel.js +32 -38
- package/lib/components/Grid/CSSGrid.d.ts +1 -1
- package/lib/components/Grid/CSSGrid.js +89 -129
- package/lib/components/Grid/Column.js +196 -328
- package/lib/components/Grid/ColumnHang.js +32 -38
- package/lib/components/Grid/FlexGrid.js +44 -62
- package/lib/components/Grid/Grid.js +32 -44
- package/lib/components/Grid/GridContext.js +39 -44
- package/lib/components/Grid/Row.js +35 -53
- package/lib/components/Heading/index.js +39 -53
- package/lib/components/Icon/Icon.Skeleton.js +25 -23
- package/lib/components/IconButton/index.js +121 -180
- package/lib/components/IconIndicator/index.d.ts +1 -1
- package/lib/components/IconIndicator/index.js +63 -63
- package/lib/components/IdPrefix/index.js +24 -19
- package/lib/components/InlineCheckbox/InlineCheckbox.js +72 -117
- package/lib/components/InlineCheckbox/index.js +12 -9
- package/lib/components/InlineLoading/InlineLoading.js +87 -104
- package/lib/components/InlineLoading/index.js +12 -9
- package/lib/components/Layer/LayerContext.js +14 -6
- package/lib/components/Layer/LayerLevel.js +20 -6
- package/lib/components/Layer/index.js +58 -68
- package/lib/components/Layout/index.js +81 -111
- package/lib/components/LayoutDirection/LayoutDirection.d.ts +1 -1
- package/lib/components/LayoutDirection/LayoutDirection.js +36 -40
- package/lib/components/LayoutDirection/LayoutDirectionContext.js +14 -8
- package/lib/components/LayoutDirection/useLayoutDirection.js +16 -9
- package/lib/components/Link/Link.js +67 -112
- package/lib/components/Link/index.js +12 -9
- package/lib/components/ListBox/ListBox.js +82 -130
- package/lib/components/ListBox/ListBoxField.js +33 -47
- package/lib/components/ListBox/ListBoxMenu.js +39 -46
- package/lib/components/ListBox/ListBoxMenuIcon.js +43 -44
- package/lib/components/ListBox/ListBoxMenuItem.js +71 -92
- package/lib/components/ListBox/ListBoxPropTypes.js +21 -9
- package/lib/components/ListBox/ListBoxSelection.js +75 -100
- package/lib/components/ListBox/index.js +17 -21
- package/lib/components/ListBox/next/ListBoxSelection.js +83 -121
- package/lib/components/ListBox/next/ListBoxTrigger.js +48 -52
- package/lib/components/ListItem/ListItem.js +29 -32
- package/lib/components/Loading/Loading.js +68 -77
- package/lib/components/Loading/index.js +12 -9
- package/lib/components/Menu/Menu.js +224 -365
- package/lib/components/Menu/MenuContext.d.ts +1 -1
- package/lib/components/Menu/MenuContext.js +42 -40
- package/lib/components/Menu/MenuItem.js +286 -415
- package/lib/components/MenuButton/index.js +138 -197
- package/lib/components/Modal/Modal.js +504 -665
- package/lib/components/Modal/ModalPresence.js +41 -39
- package/lib/components/Modal/index.js +13 -10
- package/lib/components/ModalWrapper/ModalWrapper.d.ts +2 -2
- package/lib/components/ModalWrapper/ModalWrapper.js +112 -134
- package/lib/components/MultiSelect/FilterableMultiSelect.js +611 -920
- package/lib/components/MultiSelect/MultiSelect.js +459 -718
- package/lib/components/MultiSelect/MultiSelectPropTypes.js +15 -32
- package/lib/components/MultiSelect/filter.js +14 -10
- package/lib/components/MultiSelect/tools/sorting.js +21 -35
- package/lib/components/Notification/Notification.js +514 -787
- package/lib/components/NumberInput/NumberFormatPropTypes.js +72 -33
- package/lib/components/NumberInput/NumberInput.Skeleton.js +33 -37
- package/lib/components/NumberInput/NumberInput.js +571 -950
- package/lib/components/OrderedList/OrderedList.js +35 -48
- package/lib/components/OverflowMenu/OverflowMenu.js +341 -454
- package/lib/components/OverflowMenu/index.js +27 -21
- package/lib/components/OverflowMenu/next/index.js +158 -188
- package/lib/components/OverflowMenuItem/OverflowMenuItem.js +104 -164
- package/lib/components/OverflowMenuItem/index.js +12 -9
- package/lib/components/OverflowMenuV2/index.js +25 -15
- package/lib/components/PageHeader/PageHeader.js +301 -444
- package/lib/components/PageHeader/index.js +27 -19
- package/lib/components/Pagination/Pagination.Skeleton.js +38 -37
- package/lib/components/Pagination/Pagination.d.ts +1 -1
- package/lib/components/Pagination/Pagination.js +256 -360
- package/lib/components/Pagination/experimental/PageSelector.js +48 -58
- package/lib/components/Pagination/experimental/Pagination-story.d.ts +114 -0
- package/lib/components/Pagination/experimental/Pagination.js +148 -200
- package/lib/components/PaginationNav/PaginationNav.js +324 -430
- package/lib/components/Popover/index.js +323 -440
- package/lib/components/PrimaryButton/PrimaryButton.js +19 -13
- package/lib/components/ProgressBar/ProgressBar.js +121 -147
- package/lib/components/ProgressIndicator/ProgressIndicator.Skeleton.js +46 -43
- package/lib/components/ProgressIndicator/ProgressIndicator.js +150 -245
- package/lib/components/RadioButton/RadioButton.Skeleton.js +27 -27
- package/lib/components/RadioButton/RadioButton.js +105 -178
- package/lib/components/RadioButton/index.js +12 -9
- package/lib/components/RadioButtonGroup/RadioButtonGroup.js +139 -211
- package/lib/components/RadioTile/RadioTile.js +108 -172
- package/lib/components/RadioTile/index.js +12 -9
- package/lib/components/Search/Search.Skeleton.js +32 -38
- package/lib/components/Search/Search.js +185 -281
- package/lib/components/Search/index.js +13 -11
- package/lib/components/Search/utils.js +11 -4
- package/lib/components/SecondaryButton/SecondaryButton.js +19 -13
- package/lib/components/Select/Select.Skeleton.js +31 -35
- package/lib/components/Select/Select.js +182 -261
- package/lib/components/Select/index.js +13 -11
- package/lib/components/SelectItem/SelectItem.js +37 -52
- package/lib/components/SelectItem/index.js +12 -9
- package/lib/components/SelectItemGroup/SelectItemGroup.js +31 -41
- package/lib/components/ShapeIndicator/index.d.ts +1 -1
- package/lib/components/ShapeIndicator/index.js +78 -83
- package/lib/components/SkeletonIcon/SkeletonIcon.js +25 -28
- package/lib/components/SkeletonPlaceholder/SkeletonPlaceholder.js +25 -28
- package/lib/components/SkeletonText/SkeletonText.js +71 -85
- package/lib/components/SkeletonText/index.js +12 -9
- package/lib/components/Slider/Slider.Skeleton.js +72 -95
- package/lib/components/Slider/Slider.js +868 -1319
- package/lib/components/Slider/SliderHandles.js +75 -68
- package/lib/components/Stack/HStack.js +22 -14
- package/lib/components/Stack/Stack.js +60 -82
- package/lib/components/Stack/VStack.js +22 -14
- package/lib/components/StructuredList/StructuredList.Skeleton.js +59 -52
- package/lib/components/StructuredList/StructuredList.js +182 -319
- package/lib/components/Switch/IconSwitch.js +103 -149
- package/lib/components/Switch/Switch.js +70 -103
- package/lib/components/TabContent/TabContent.js +32 -38
- package/lib/components/Tabs/Tabs.Skeleton.js +45 -41
- package/lib/components/Tabs/Tabs.js +738 -1153
- package/lib/components/Tabs/usePressable.js +98 -114
- package/lib/components/Tag/DismissibleTag.js +123 -160
- package/lib/components/Tag/OperationalTag.js +95 -115
- package/lib/components/Tag/SelectableTag.js +98 -133
- package/lib/components/Tag/Tag.Skeleton.js +30 -32
- package/lib/components/Tag/Tag.js +156 -204
- package/lib/components/Tag/isEllipsisActive.js +13 -9
- package/lib/components/Text/Text.js +69 -81
- package/lib/components/Text/TextDirection.js +39 -39
- package/lib/components/Text/TextDirectionContext.js +15 -10
- package/lib/components/Text/createTextComponent.js +29 -22
- package/lib/components/TextArea/TextArea.Skeleton.js +29 -34
- package/lib/components/TextArea/TextArea.js +319 -426
- package/lib/components/TextArea/index.js +13 -11
- package/lib/components/TextInput/ControlledPasswordInput.js +137 -202
- package/lib/components/TextInput/PasswordInput.js +200 -307
- package/lib/components/TextInput/TextInput.Skeleton.js +28 -33
- package/lib/components/TextInput/TextInput.js +223 -321
- package/lib/components/TextInput/index.js +13 -11
- package/lib/components/TextInput/util.js +21 -26
- package/lib/components/Theme/index.js +83 -97
- package/lib/components/Tile/Tile.js +398 -595
- package/lib/components/TileGroup/TileGroup.js +73 -113
- package/lib/components/TimePicker/TimePicker.d.ts +1 -1
- package/lib/components/TimePicker/TimePicker.js +152 -251
- package/lib/components/TimePickerSelect/TimePickerSelect.js +47 -62
- package/lib/components/Toggle/Toggle.Skeleton.js +28 -24
- package/lib/components/Toggle/Toggle.js +106 -176
- package/lib/components/ToggleSmall/ToggleSmall.Skeleton.js +50 -53
- package/lib/components/Toggletip/index.d.ts +2 -2
- package/lib/components/Toggletip/index.js +174 -258
- package/lib/components/Tooltip/DefinitionTooltip.js +102 -140
- package/lib/components/Tooltip/Tooltip.js +192 -265
- package/lib/components/TreeView/TreeContext.js +14 -7
- package/lib/components/TreeView/TreeNode.js +365 -504
- package/lib/components/TreeView/TreeView.js +169 -242
- package/lib/components/UIShell/Content.js +27 -34
- package/lib/components/UIShell/Header.js +29 -33
- package/lib/components/UIShell/HeaderContainer.js +34 -44
- package/lib/components/UIShell/HeaderGlobalAction.js +69 -94
- package/lib/components/UIShell/HeaderGlobalBar.js +17 -14
- package/lib/components/UIShell/HeaderMenu.js +146 -221
- package/lib/components/UIShell/HeaderMenuButton.js +47 -70
- package/lib/components/UIShell/HeaderMenuItem.js +53 -80
- package/lib/components/UIShell/HeaderName.js +36 -48
- package/lib/components/UIShell/HeaderNavigation.js +36 -41
- package/lib/components/UIShell/HeaderPanel.js +78 -101
- package/lib/components/UIShell/HeaderSideNavItems.js +31 -37
- package/lib/components/UIShell/Link.js +32 -54
- package/lib/components/UIShell/SideNav.js +136 -245
- package/lib/components/UIShell/SideNavContext.js +23 -17
- package/lib/components/UIShell/SideNavDetails.js +33 -38
- package/lib/components/UIShell/SideNavDivider.js +25 -25
- package/lib/components/UIShell/SideNavFooter.js +47 -56
- package/lib/components/UIShell/SideNavHeader.js +30 -39
- package/lib/components/UIShell/SideNavIcon.js +32 -37
- package/lib/components/UIShell/SideNavItem.js +32 -37
- package/lib/components/UIShell/SideNavItems.js +35 -44
- package/lib/components/UIShell/SideNavLink.js +56 -83
- package/lib/components/UIShell/SideNavLinkText.js +28 -29
- package/lib/components/UIShell/SideNavMenu.js +106 -148
- package/lib/components/UIShell/SideNavMenuItem.js +44 -56
- package/lib/components/UIShell/SideNavSwitcher.js +63 -72
- package/lib/components/UIShell/SkipToContent.js +32 -40
- package/lib/components/UIShell/Switcher.js +73 -103
- package/lib/components/UIShell/SwitcherDivider.js +26 -28
- package/lib/components/UIShell/SwitcherItem.js +78 -118
- package/lib/components/UnorderedList/UnorderedList.js +32 -41
- package/lib/feature-flags.js +21 -13
- package/lib/index.js +622 -602
- package/lib/internal/FloatingMenu.js +249 -296
- package/lib/internal/OptimizedResize.js +35 -47
- package/lib/internal/Selection.js +102 -134
- package/lib/internal/clamp.js +12 -5
- package/lib/internal/defaultItemToString.js +15 -10
- package/lib/internal/deprecateFieldOnObject.js +23 -16
- package/lib/internal/environment.js +15 -8
- package/lib/internal/getAnnouncement.js +16 -14
- package/lib/internal/keyboard/keys.js +48 -49
- package/lib/internal/keyboard/match.js +25 -43
- package/lib/internal/keyboard/navigation.js +22 -29
- package/lib/internal/noopFn.js +10 -3
- package/lib/internal/useAttachedMenu.js +44 -53
- package/lib/internal/useControllableState.js +44 -50
- package/lib/internal/useDelayedState.js +31 -37
- package/lib/internal/useEvent.js +40 -37
- package/lib/internal/useId.js +54 -91
- package/lib/internal/useIdPrefix.js +15 -7
- package/lib/internal/useIsomorphicEffect.js +13 -8
- package/lib/internal/useMatchMedia.js +30 -23
- package/lib/internal/useMergedRefs.js +27 -24
- package/lib/internal/useNoInteractiveChildren.js +73 -101
- package/lib/internal/useNormalizedInputProps.js +55 -53
- package/lib/internal/useOutsideClick.js +22 -26
- package/lib/internal/useOverflowItems.js +90 -94
- package/lib/internal/usePrefix.js +15 -7
- package/lib/internal/usePresence.js +52 -56
- package/lib/internal/usePresenceContext.js +36 -37
- package/lib/internal/usePreviousValue.js +27 -20
- package/lib/internal/useResizeObserver.js +58 -68
- package/lib/internal/useSavedCallback.js +25 -19
- package/lib/internal/utils.js +18 -11
- package/lib/internal/warning.js +24 -23
- package/lib/internal/wrapFocus.js +78 -100
- package/lib/prop-types/AriaPropTypes.js +17 -9
- package/lib/prop-types/deprecate.js +30 -29
- package/lib/prop-types/deprecateComponent.js +17 -10
- package/lib/prop-types/deprecateValuesWithin.js +18 -23
- package/lib/prop-types/isRequiredOneOf.js +21 -25
- package/lib/prop-types/requiredIfGivenPropIsTruthy.js +14 -15
- package/lib/tools/events.js +17 -22
- package/lib/tools/mapPopoverAlign.js +19 -19
- package/lib/tools/mergeRefs.js +14 -18
- package/lib/tools/setupGetInstanceId.js +16 -9
- package/lib/tools/toggleClass.js +17 -10
- package/lib/tools/wrapComponent.js +38 -43
- package/package.json +10 -16
- package/es/_virtual/_rollupPluginBabelHelpers.js +0 -40
- package/es/components/DataTable/stories/examples/TableToolbarFilter.d.ts +0 -54
- package/es/node_modules/es-toolkit/dist/compat/function/debounce.js +0 -55
- package/es/node_modules/es-toolkit/dist/compat/function/throttle.js +0 -23
- package/es/node_modules/es-toolkit/dist/function/debounce.js +0 -70
- package/lib/_virtual/_rollupPluginBabelHelpers.js +0 -45
- package/lib/components/DataTable/stories/examples/TableToolbarFilter.d.ts +0 -54
- package/lib/node_modules/es-toolkit/dist/compat/function/debounce.js +0 -57
- package/lib/node_modules/es-toolkit/dist/compat/function/throttle.js +0 -25
- package/lib/node_modules/es-toolkit/dist/function/debounce.js +0 -72
|
@@ -1,975 +1,595 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright IBM Corp. 2016,
|
|
2
|
+
* Copyright IBM Corp. 2016, 2026
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import { useMergedRefs } from
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import
|
|
21
|
-
import
|
|
22
|
-
import {
|
|
23
|
-
import
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
8
|
+
import { usePrefix } from "../../internal/usePrefix.js";
|
|
9
|
+
import { Text } from "../Text/Text.js";
|
|
10
|
+
import { ArrowDown, ArrowUp as ArrowUp$1 } from "../../internal/keyboard/keys.js";
|
|
11
|
+
import { match } from "../../internal/keyboard/match.js";
|
|
12
|
+
import { deprecate } from "../../prop-types/deprecate.js";
|
|
13
|
+
import { useMergedRefs } from "../../internal/useMergedRefs.js";
|
|
14
|
+
import { AILabel } from "../AILabel/index.js";
|
|
15
|
+
import { isComponentElement } from "../../internal/utils.js";
|
|
16
|
+
import { FormContext } from "../FluidForm/FormContext.js";
|
|
17
|
+
import { useNormalizedInputProps } from "../../internal/useNormalizedInputProps.js";
|
|
18
|
+
import { useControllableState } from "../../internal/useControllableState.js";
|
|
19
|
+
import { clamp } from "../../internal/clamp.js";
|
|
20
|
+
import { NumberFormatOptionsPropType } from "./NumberFormatPropTypes.js";
|
|
21
|
+
import classNames from "classnames";
|
|
22
|
+
import React, { cloneElement, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
|
|
23
|
+
import PropTypes from "prop-types";
|
|
24
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
25
|
+
import { Add, Subtract } from "@carbon/icons-react";
|
|
26
|
+
import { NumberFormatter, NumberParser } from "@carbon/utilities";
|
|
27
|
+
|
|
28
|
+
//#region src/components/NumberInput/NumberInput.tsx
|
|
29
|
+
/**
|
|
30
|
+
* Copyright IBM Corp. 2016, 2026
|
|
31
|
+
*
|
|
32
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
33
|
+
* LICENSE file in the root directory of this source tree.
|
|
34
|
+
*/
|
|
31
35
|
const translationIds = {
|
|
32
|
-
|
|
33
|
-
|
|
36
|
+
"increment.number": "increment.number",
|
|
37
|
+
"decrement.number": "decrement.number"
|
|
34
38
|
};
|
|
35
39
|
const defaultTranslations = {
|
|
36
|
-
|
|
37
|
-
|
|
40
|
+
[translationIds["increment.number"]]: "Increment number",
|
|
41
|
+
[translationIds["decrement.number"]]: "Decrement number"
|
|
38
42
|
};
|
|
39
|
-
const defaultTranslateWithId = messageId => {
|
|
40
|
-
|
|
43
|
+
const defaultTranslateWithId = (messageId) => {
|
|
44
|
+
return defaultTranslations[messageId];
|
|
41
45
|
};
|
|
42
|
-
const getSeparators = locale => {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
'\\uFF10-\\uFF19' +
|
|
57
|
-
// Fullwidth Japanese 0-9
|
|
58
|
-
'一二三四五六七八九〇零' +
|
|
59
|
-
// Kanji digits
|
|
60
|
-
']';
|
|
61
|
-
|
|
62
|
-
// Non-digit pattern that excludes ALL digit types (not just ASCII 0-9)
|
|
63
|
-
const nonDigitPattern = '[^' + '\\u0030-\\u0039' +
|
|
64
|
-
// Western
|
|
65
|
-
'\\u0660-\\u0669' +
|
|
66
|
-
// Eastern Arabic
|
|
67
|
-
'\\u0966-\\u096F' +
|
|
68
|
-
// Devanagari
|
|
69
|
-
'\\u09E6-\\u09EF' +
|
|
70
|
-
// Bengali
|
|
71
|
-
'\\uFF10-\\uFF19' +
|
|
72
|
-
// Fullwidth Japanese 0-9
|
|
73
|
-
'一二三四五六七八九〇零' +
|
|
74
|
-
// Kanji digits
|
|
75
|
-
']+';
|
|
76
|
-
|
|
77
|
-
// Extract separators using regex that handles all numeral systems
|
|
78
|
-
// Use nonDigitPattern instead of \D+ to correctly identify separators
|
|
79
|
-
const regex = new RegExp(`(${nonDigitPattern})${digitPattern}{3}(${nonDigitPattern})${digitPattern}{2}$`);
|
|
80
|
-
const match = formatted.match(regex);
|
|
81
|
-
if (match) {
|
|
82
|
-
const groupSeparator = match[1];
|
|
83
|
-
const decimalSeparator = match[2];
|
|
84
|
-
return {
|
|
85
|
-
groupSeparator,
|
|
86
|
-
decimalSeparator
|
|
87
|
-
};
|
|
88
|
-
} else {
|
|
89
|
-
return {
|
|
90
|
-
groupSeparator: null,
|
|
91
|
-
decimalSeparator: null
|
|
92
|
-
};
|
|
93
|
-
}
|
|
46
|
+
const getSeparators = (locale) => {
|
|
47
|
+
const formatted = new Intl.NumberFormat(locale).format(1234567.89);
|
|
48
|
+
const digitPattern = "[\\u0030-\\u0039\\u0660-\\u0669\\u0966-\\u096F\\u09E6-\\u09EF\\uFF10-\\uFF19一二三四五六七八九〇零]";
|
|
49
|
+
const nonDigitPattern = "[^\\u0030-\\u0039\\u0660-\\u0669\\u0966-\\u096F\\u09E6-\\u09EF\\uFF10-\\uFF19一二三四五六七八九〇零]+";
|
|
50
|
+
const regex = new RegExp(`(${nonDigitPattern})${digitPattern}{3}(${nonDigitPattern})${digitPattern}{2}$`);
|
|
51
|
+
const match = formatted.match(regex);
|
|
52
|
+
if (match) return {
|
|
53
|
+
groupSeparator: match[1],
|
|
54
|
+
decimalSeparator: match[2]
|
|
55
|
+
};
|
|
56
|
+
else return {
|
|
57
|
+
groupSeparator: null,
|
|
58
|
+
decimalSeparator: null
|
|
59
|
+
};
|
|
94
60
|
};
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
const normalizeMinus = value => value.replace(/[\u2212\u2012\u2013\u2014\uFE63\uFF0D]/g, '-');
|
|
98
|
-
const normalizeNumericInput = value => value
|
|
99
|
-
// Remove bidi / direction control characters (Arabic keyboards)
|
|
100
|
-
.replace(/[\u061C\u200E\u200F\u202A-\u202E\u2066-\u2069]/g, '')
|
|
101
|
-
// Normalize Unicode minus variants to ASCII "-"
|
|
102
|
-
.replace(/[\u2212\u2012\u2013\u2014\uFE63\uFF0D]/g, '-');
|
|
61
|
+
const normalizeMinus = (value) => value.replace(/[\u2212\u2012\u2013\u2014\uFE63\uFF0D]/g, "-");
|
|
62
|
+
const normalizeNumericInput = (value) => value.replace(/[\u061C\u200E\u200F\u202A-\u202E\u2066-\u2069]/g, "").replace(/[\u2212\u2012\u2013\u2014\uFE63\uFF0D]/g, "-");
|
|
103
63
|
/**
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
64
|
+
* Converts a string with any Unicode numeral system to a JavaScript number.
|
|
65
|
+
* Handles all numeral systems supported by Intl.NumberFormat.
|
|
66
|
+
*
|
|
67
|
+
* @param {string} input - The input string with numerals in any Unicode system
|
|
68
|
+
* @param {string} locale - The locale for parsing separators
|
|
69
|
+
* @returns {number} The parsed number, or NaN if invalid
|
|
70
|
+
*/
|
|
111
71
|
const parseNumberWithLocale = (input, locale) => {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
if (groupSeparator) {
|
|
178
|
-
if (groupSeparator?.trim() === '') {
|
|
179
|
-
normalized = normalized?.replace(/[\u00A0\u202F\s]/g, '');
|
|
180
|
-
} else {
|
|
181
|
-
if (decimalSeparator !== ',' && decimalSeparator !== '٬') {
|
|
182
|
-
normalized = normalized?.replace(/[,٬]/g, '');
|
|
183
|
-
}
|
|
184
|
-
if (groupSeparator !== ',' && groupSeparator !== '٬') {
|
|
185
|
-
const escaped = groupSeparator?.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
186
|
-
normalized = normalized?.replace(new RegExp(escaped, 'g'), '');
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
normalized = normalized.replace(/٫/g, '.');
|
|
191
|
-
if (decimalSeparator && decimalSeparator !== '.' && decimalSeparator !== '٫') {
|
|
192
|
-
const escaped = decimalSeparator.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
193
|
-
normalized = normalized.replace(new RegExp(escaped, 'g'), '.');
|
|
194
|
-
}
|
|
195
|
-
normalized = normalizeMinus(normalized);
|
|
196
|
-
return Number(normalized);
|
|
72
|
+
if (input === "" || input === void 0 || input === null) return NaN;
|
|
73
|
+
input = normalizeNumericInput(input);
|
|
74
|
+
const { groupSeparator, decimalSeparator } = getSeparators(locale);
|
|
75
|
+
const kanjiMap = {
|
|
76
|
+
零: "0",
|
|
77
|
+
〇: "0",
|
|
78
|
+
一: "1",
|
|
79
|
+
二: "2",
|
|
80
|
+
三: "3",
|
|
81
|
+
四: "4",
|
|
82
|
+
五: "5",
|
|
83
|
+
六: "6",
|
|
84
|
+
七: "7",
|
|
85
|
+
八: "8",
|
|
86
|
+
九: "9"
|
|
87
|
+
};
|
|
88
|
+
const digitRanges = [
|
|
89
|
+
{
|
|
90
|
+
start: 48,
|
|
91
|
+
end: 57,
|
|
92
|
+
base: 48
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
start: 1632,
|
|
96
|
+
end: 1641,
|
|
97
|
+
base: 1632
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
start: 2406,
|
|
101
|
+
end: 2415,
|
|
102
|
+
base: 2406
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
start: 2534,
|
|
106
|
+
end: 2543,
|
|
107
|
+
base: 2534
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
start: 65296,
|
|
111
|
+
end: 65305,
|
|
112
|
+
base: 65296
|
|
113
|
+
}
|
|
114
|
+
];
|
|
115
|
+
let normalized = Array.from(input).map((char) => {
|
|
116
|
+
if (char === "e" || char === "E" || char === "+" || char === "-") return char;
|
|
117
|
+
if (kanjiMap[char] !== void 0) return kanjiMap[char];
|
|
118
|
+
const code = char.charCodeAt(0);
|
|
119
|
+
for (const range of digitRanges) if (code >= range.start && code <= range.end) return String(code - range.start);
|
|
120
|
+
return char;
|
|
121
|
+
}).join("");
|
|
122
|
+
if (groupSeparator) if (groupSeparator?.trim() === "") normalized = normalized?.replace(/[\u00A0\u202F\s]/g, "");
|
|
123
|
+
else {
|
|
124
|
+
if (decimalSeparator !== "," && decimalSeparator !== "٬") normalized = normalized?.replace(/[,٬]/g, "");
|
|
125
|
+
if (groupSeparator !== "," && groupSeparator !== "٬") {
|
|
126
|
+
const escaped = groupSeparator?.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
127
|
+
normalized = normalized?.replace(new RegExp(escaped, "g"), "");
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
normalized = normalized.replace(/٫/g, ".");
|
|
131
|
+
if (decimalSeparator && decimalSeparator !== "." && decimalSeparator !== "٫") {
|
|
132
|
+
const escaped = decimalSeparator.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
133
|
+
normalized = normalized.replace(new RegExp(escaped, "g"), ".");
|
|
134
|
+
}
|
|
135
|
+
normalized = normalizeMinus(normalized);
|
|
136
|
+
return Number(normalized);
|
|
197
137
|
};
|
|
198
138
|
const validateNumberSeparators = (input, locale) => {
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
group = '[,٬]';
|
|
222
|
-
} else {
|
|
223
|
-
group = esc(groupSeparator);
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
// Decimal separator regex
|
|
228
|
-
let decimal = esc(decimalSeparator);
|
|
229
|
-
if (decimalSeparator === '.' || decimalSeparator === '٫') {
|
|
230
|
-
decimal = '[.٫]';
|
|
231
|
-
}
|
|
232
|
-
const sign = '[\\-\\u2212]?';
|
|
233
|
-
const scientific = `([eE][+-]?${digit}+)?`;
|
|
234
|
-
|
|
235
|
-
// Detect if grouping is used AT ALL
|
|
236
|
-
const usesGrouping = group && (groupSeparator?.trim() === '' ? /[\u00A0\u202F\s]/.test(input) : groupSeparator === ',' || groupSeparator === '٬' ? /[,٬]/.test(input) : groupSeparator ? input.includes(groupSeparator) : false);
|
|
237
|
-
const scientificMatch = input?.match(/^([^eE]+)([eE][+-]?.*)?$/);
|
|
238
|
-
const baseNumber = scientificMatch ? scientificMatch[1] : input;
|
|
239
|
-
|
|
240
|
-
// Split integer part from the base number - handle both decimal separator variants
|
|
241
|
-
let integerPart;
|
|
242
|
-
if (decimalSeparator === '.' || decimalSeparator === '٫') {
|
|
243
|
-
// Split by either . or ٫
|
|
244
|
-
integerPart = baseNumber?.split(/[.,]/)[0];
|
|
245
|
-
} else {
|
|
246
|
-
integerPart = baseNumber?.split(decimalSeparator)[0];
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
// STEP 1: strict integer validation
|
|
250
|
-
// When grouping is used, we need to handle two cases:
|
|
251
|
-
// 1. Numbers with 1-3 digits (no separator required): 1, 12, 123
|
|
252
|
-
// 2. Numbers with 4+ digits (separator required): 1,234 or 12,345 or 123,456
|
|
253
|
-
const integerRegex = usesGrouping ? new RegExp(`^${sign}(${digit}{1,3}|${digit}{1,3}(${group}${digit}{3})+)$`) : new RegExp(`^${sign}${digit}+$`);
|
|
254
|
-
if (!integerRegex.test(integerPart)) {
|
|
255
|
-
return false;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
// STEP 2: full number validation
|
|
259
|
-
const fullRegex = new RegExp(`^${sign}${digit}+` + (usesGrouping ? `(${group}${digit}{3})*` : '') + `(${decimal}${digit}+)?${scientific}$`);
|
|
260
|
-
return fullRegex.test(input);
|
|
139
|
+
if (input === "") return true;
|
|
140
|
+
input = normalizeNumericInput(input);
|
|
141
|
+
const { groupSeparator, decimalSeparator } = getSeparators(locale);
|
|
142
|
+
if (!decimalSeparator) return !isNaN(Number(input));
|
|
143
|
+
const esc = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
144
|
+
const digit = "[\\u0030-\\u0039\\u0660-\\u0669\\u0966-\\u096F\\u09E6-\\u09EF\\uFF10-\\uFF19一二三四五六七八九〇零]";
|
|
145
|
+
let group = "";
|
|
146
|
+
if (groupSeparator) if (groupSeparator?.trim() === "") group = "[\\u00A0\\u202F\\s]";
|
|
147
|
+
else if (groupSeparator === "," || groupSeparator === "٬") group = "[,٬]";
|
|
148
|
+
else group = esc(groupSeparator);
|
|
149
|
+
let decimal = esc(decimalSeparator);
|
|
150
|
+
if (decimalSeparator === "." || decimalSeparator === "٫") decimal = "[.٫]";
|
|
151
|
+
const sign = "[\\-\\u2212]?";
|
|
152
|
+
const scientific = `([eE][+-]?${digit}+)?`;
|
|
153
|
+
const usesGrouping = group && (groupSeparator?.trim() === "" ? /[\u00A0\u202F\s]/.test(input) : groupSeparator === "," || groupSeparator === "٬" ? /[,٬]/.test(input) : groupSeparator ? input.includes(groupSeparator) : false);
|
|
154
|
+
const scientificMatch = input?.match(/^([^eE]+)([eE][+-]?.*)?$/);
|
|
155
|
+
const baseNumber = scientificMatch ? scientificMatch[1] : input;
|
|
156
|
+
let integerPart;
|
|
157
|
+
if (decimalSeparator === "." || decimalSeparator === "٫") integerPart = baseNumber?.split(/[.,]/)[0];
|
|
158
|
+
else integerPart = baseNumber?.split(decimalSeparator)[0];
|
|
159
|
+
if (!(usesGrouping ? new RegExp(`^${sign}(${digit}{1,3}|${digit}{1,3}(${group}${digit}{3})+)$`) : new RegExp(`^${sign}${digit}+$`)).test(integerPart)) return false;
|
|
160
|
+
return new RegExp(`^${sign}${digit}+` + (usesGrouping ? `(${group}${digit}{3})*` : "") + `(${decimal}${digit}+)?${scientific}$`).test(input);
|
|
261
161
|
};
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
const
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
if (match(e, ArrowUp)) {
|
|
570
|
-
handleStep(e, 'up');
|
|
571
|
-
} else if (match(e, ArrowDown)) {
|
|
572
|
-
handleStep(e, 'down');
|
|
573
|
-
}
|
|
574
|
-
}
|
|
575
|
-
if (rest?.onKeyDown) {
|
|
576
|
-
rest?.onKeyDown(e);
|
|
577
|
-
}
|
|
578
|
-
},
|
|
579
|
-
onFocus: e => {
|
|
580
|
-
if (disableWheelProp) {
|
|
581
|
-
e.target.addEventListener('wheel', disableWheel);
|
|
582
|
-
}
|
|
583
|
-
if (rest.onFocus) {
|
|
584
|
-
rest.onFocus(e);
|
|
585
|
-
}
|
|
586
|
-
},
|
|
587
|
-
onBlur: e => {
|
|
588
|
-
if (disableWheelProp) {
|
|
589
|
-
e.target.removeEventListener('wheel', disableWheel);
|
|
590
|
-
}
|
|
591
|
-
let parsedValueForBlur;
|
|
592
|
-
if (type === 'text') {
|
|
593
|
-
// When isControlled, the current inputValue needs re-parsed
|
|
594
|
-
// because the consumer's onChange hasn't been called yet and
|
|
595
|
-
// the `numberValue` we have in state is the (stale) value
|
|
596
|
-
// they've passed in.
|
|
597
|
-
const _numberValue = isControlled ? numberParser.parse(inputValue) : numberValue;
|
|
598
|
-
const formattedValue = isNaN(_numberValue) ? '' : format(_numberValue);
|
|
599
|
-
const rawValue = e.target.value;
|
|
600
|
-
// Validate raw input
|
|
601
|
-
const isValid = validate ? validate(rawValue, locale) : true;
|
|
602
|
-
setInputValue(isValid ? formattedValue : rawValue);
|
|
603
|
-
// Calling format() can alter the number (such as rounding it)
|
|
604
|
-
// causing the _numberValue to mismatch the formatted value in
|
|
605
|
-
// the input. To avoid this, formattedValue is re-parsed.
|
|
606
|
-
const parsedFormattedNewValue = numberParser.parse(formattedValue);
|
|
607
|
-
parsedValueForBlur = parsedFormattedNewValue;
|
|
608
|
-
if (onChange && isValid) {
|
|
609
|
-
const state = {
|
|
610
|
-
value: parsedFormattedNewValue,
|
|
611
|
-
direction: previousNumberValue.current < parsedFormattedNewValue ? 'up' : 'down'
|
|
612
|
-
};
|
|
613
|
-
|
|
614
|
-
// If the old and new values are NaN, don't call onChange
|
|
615
|
-
// to avoid an unnecessary re-render and potential infinite
|
|
616
|
-
// loop when isControlled.
|
|
617
|
-
if (!(isNaN(previousNumberValue.current) && isNaN(parsedFormattedNewValue))) {
|
|
618
|
-
onChange(e, state);
|
|
619
|
-
}
|
|
620
|
-
}
|
|
621
|
-
|
|
622
|
-
// If the old and new values are NaN, don't set state to avoid
|
|
623
|
-
// an unnecessary re-render and potential infinite loop when
|
|
624
|
-
// isControlled.
|
|
625
|
-
if (!(isNaN(previousNumberValue.current) && isNaN(numberValue))) {
|
|
626
|
-
previousNumberValue.current = numberValue;
|
|
627
|
-
}
|
|
628
|
-
if (!(isNaN(numberValue) && isNaN(parsedFormattedNewValue))) {
|
|
629
|
-
setNumberValue(parsedFormattedNewValue);
|
|
630
|
-
}
|
|
631
|
-
}
|
|
632
|
-
if (onBlur) {
|
|
633
|
-
if (type === 'number') {
|
|
634
|
-
onBlur(e, value);
|
|
635
|
-
return;
|
|
636
|
-
}
|
|
637
|
-
const parsedTextValue = parsedValueForBlur ?? (isControlled ? numberParser.parse(inputValue) : numberValue);
|
|
638
|
-
onBlur(e, parsedTextValue);
|
|
639
|
-
}
|
|
640
|
-
},
|
|
641
|
-
pattern: pattern,
|
|
642
|
-
inputMode: inputMode,
|
|
643
|
-
readOnly: readOnly,
|
|
644
|
-
step: step,
|
|
645
|
-
type: type,
|
|
646
|
-
value: type === 'number' ? value : inputValue
|
|
647
|
-
})), slug ? normalizedDecorator : decorator ? /*#__PURE__*/React.createElement("div", {
|
|
648
|
-
className: `${prefix}--number__input-inner-wrapper--decorator`
|
|
649
|
-
}, normalizedDecorator) : '', Icon ? /*#__PURE__*/React.createElement(Icon, {
|
|
650
|
-
className: iconClasses
|
|
651
|
-
}) : null, !hideSteppers && /*#__PURE__*/React.createElement("div", {
|
|
652
|
-
className: `${prefix}--number__controls`
|
|
653
|
-
}, /*#__PURE__*/React.createElement("button", {
|
|
654
|
-
"aria-label": decrementNumLabel || iconDescription,
|
|
655
|
-
className: `${prefix}--number__control-btn down-icon`,
|
|
656
|
-
disabled: disabled || readOnly,
|
|
657
|
-
onClick: event => handleStepperClick(event, 'down'),
|
|
658
|
-
onBlur: onStepperBlur,
|
|
659
|
-
tabIndex: -1,
|
|
660
|
-
title: decrementNumLabel || iconDescription,
|
|
661
|
-
type: "button"
|
|
662
|
-
}, _Subtract || (_Subtract = /*#__PURE__*/React.createElement(Subtract, {
|
|
663
|
-
className: "down-icon"
|
|
664
|
-
}))), /*#__PURE__*/React.createElement("div", {
|
|
665
|
-
className: `${prefix}--number__rule-divider`
|
|
666
|
-
}), /*#__PURE__*/React.createElement("button", {
|
|
667
|
-
"aria-label": incrementNumLabel || iconDescription,
|
|
668
|
-
className: `${prefix}--number__control-btn up-icon`,
|
|
669
|
-
disabled: disabled || readOnly,
|
|
670
|
-
onClick: event => handleStepperClick(event, 'up'),
|
|
671
|
-
onBlur: onStepperBlur,
|
|
672
|
-
tabIndex: -1,
|
|
673
|
-
title: incrementNumLabel || iconDescription,
|
|
674
|
-
type: "button"
|
|
675
|
-
}, _Add || (_Add = /*#__PURE__*/React.createElement(Add, {
|
|
676
|
-
className: "up-icon"
|
|
677
|
-
}))), /*#__PURE__*/React.createElement("div", {
|
|
678
|
-
className: `${prefix}--number__rule-divider`
|
|
679
|
-
}))), isFluid && /*#__PURE__*/React.createElement("hr", {
|
|
680
|
-
className: `${prefix}--number-input__divider`
|
|
681
|
-
}), normalizedProps.validation ? normalizedProps.validation : /*#__PURE__*/React.createElement(HelperText, {
|
|
682
|
-
id: normalizedProps.helperId,
|
|
683
|
-
disabled: disabled,
|
|
684
|
-
description: helperText
|
|
685
|
-
})));
|
|
162
|
+
const NumberInput = React.forwardRef((props, forwardRef) => {
|
|
163
|
+
const { allowEmpty = false, className: customClassName, decorator, disabled = false, disableWheel: disableWheelProp = false, formatOptions, helperText = "", hideLabel = false, hideSteppers, iconDescription, id, inputMode = "decimal", invalid = false, invalidText, label, light, locale = "en-US", max, min, onBlur, onStepperBlur, onChange, onClick, onKeyUp, pattern = "[0-9]*", readOnly, size = "md", slug, step = 1, translateWithId: t = defaultTranslateWithId, type = "number", defaultValue = type === "number" ? 0 : NaN, validate, warn = false, warnText = "", stepStartValue = 0, value: controlledValue, ...rest } = props;
|
|
164
|
+
const prefix = usePrefix();
|
|
165
|
+
const { isFluid } = useContext(FormContext);
|
|
166
|
+
const [isFocused, setIsFocused] = useState(false);
|
|
167
|
+
/**
|
|
168
|
+
* The input value, only used when type=number
|
|
169
|
+
*/
|
|
170
|
+
const [value, setValue] = useState(() => {
|
|
171
|
+
if (controlledValue !== void 0) return controlledValue;
|
|
172
|
+
if (defaultValue !== void 0) return defaultValue;
|
|
173
|
+
if (allowEmpty) return "";
|
|
174
|
+
return 0;
|
|
175
|
+
});
|
|
176
|
+
const numberParser = useMemo(() => new NumberParser(locale, formatOptions), [locale, formatOptions]);
|
|
177
|
+
/**
|
|
178
|
+
* The currently parsed number value.
|
|
179
|
+
* Only used when type=text
|
|
180
|
+
* Updated based on the `value` as the user types.
|
|
181
|
+
*/
|
|
182
|
+
const [numberValue, setNumberValue, isControlled] = useControllableState({
|
|
183
|
+
name: "NumberInput",
|
|
184
|
+
defaultValue: typeof defaultValue === "string" ? numberParser.parse(defaultValue) : defaultValue,
|
|
185
|
+
value: typeof controlledValue === "string" ? numberParser.parse(controlledValue) : controlledValue
|
|
186
|
+
});
|
|
187
|
+
/**
|
|
188
|
+
* The number value that was previously "committed" to the input on blur
|
|
189
|
+
* Only used when type="text"
|
|
190
|
+
*/
|
|
191
|
+
const previousNumberValue = useRef(numberValue);
|
|
192
|
+
/**
|
|
193
|
+
* The current text value of the input.
|
|
194
|
+
* Only used when type=text
|
|
195
|
+
* Updated as the user types and formatted on blur.
|
|
196
|
+
*/
|
|
197
|
+
const [inputValue, setInputValue] = React.useState(() => isNaN(numberValue) ? "" : new NumberFormatter(locale, formatOptions).format(numberValue));
|
|
198
|
+
const numberingSystem = useMemo(() => numberParser.getNumberingSystem(inputValue), [numberParser, inputValue]);
|
|
199
|
+
const numberFormatter = useMemo(() => new NumberFormatter(locale, {
|
|
200
|
+
...formatOptions,
|
|
201
|
+
numberingSystem
|
|
202
|
+
}), [
|
|
203
|
+
locale,
|
|
204
|
+
formatOptions,
|
|
205
|
+
numberingSystem
|
|
206
|
+
]);
|
|
207
|
+
const format = useCallback((value) => isNaN(value) || value === null ? "" : numberFormatter.format(value), [numberFormatter]);
|
|
208
|
+
useEffect(() => {
|
|
209
|
+
if (isControlled && !(isNaN(previousNumberValue.current) && isNaN(numberValue)) && previousNumberValue.current !== numberValue) {
|
|
210
|
+
setInputValue(format(numberValue));
|
|
211
|
+
previousNumberValue.current = numberValue;
|
|
212
|
+
}
|
|
213
|
+
}, [
|
|
214
|
+
isControlled,
|
|
215
|
+
numberValue,
|
|
216
|
+
format
|
|
217
|
+
]);
|
|
218
|
+
const inputRef = useRef(null);
|
|
219
|
+
const ref = useMergedRefs([forwardRef, inputRef]);
|
|
220
|
+
const numberInputClasses = classNames({
|
|
221
|
+
[`${prefix}--number`]: true,
|
|
222
|
+
[`${prefix}--number--helpertext`]: true,
|
|
223
|
+
[`${prefix}--number--readonly`]: readOnly,
|
|
224
|
+
[`${prefix}--number--light`]: light,
|
|
225
|
+
[`${prefix}--number--nolabel`]: hideLabel,
|
|
226
|
+
[`${prefix}--number--nosteppers`]: hideSteppers,
|
|
227
|
+
[`${prefix}--number--${size}`]: size
|
|
228
|
+
});
|
|
229
|
+
const normalizedProps = useNormalizedInputProps({
|
|
230
|
+
id,
|
|
231
|
+
readOnly,
|
|
232
|
+
disabled,
|
|
233
|
+
invalid: !getInputValidity({
|
|
234
|
+
allowEmpty,
|
|
235
|
+
invalid,
|
|
236
|
+
value: validate ? inputValue : type === "number" ? value : numberValue,
|
|
237
|
+
max,
|
|
238
|
+
min,
|
|
239
|
+
validate,
|
|
240
|
+
locale
|
|
241
|
+
}),
|
|
242
|
+
invalidText,
|
|
243
|
+
warn,
|
|
244
|
+
warnText
|
|
245
|
+
});
|
|
246
|
+
const [incrementNumLabel, decrementNumLabel] = [t("increment.number"), t("decrement.number")];
|
|
247
|
+
const wrapperClasses = classNames(`${prefix}--number__input-wrapper`, {
|
|
248
|
+
[`${prefix}--number__input-wrapper--warning`]: normalizedProps.warn,
|
|
249
|
+
[`${prefix}--number__input-wrapper--slug`]: slug,
|
|
250
|
+
[`${prefix}--number__input-wrapper--decorator`]: decorator
|
|
251
|
+
});
|
|
252
|
+
const iconClasses = classNames({
|
|
253
|
+
[`${prefix}--number__invalid`]: normalizedProps.invalid || normalizedProps.warn,
|
|
254
|
+
[`${prefix}--number__invalid--warning`]: normalizedProps.warn
|
|
255
|
+
});
|
|
256
|
+
useEffect(() => {
|
|
257
|
+
if (type === "number" && controlledValue !== void 0) if (allowEmpty && controlledValue === "") setValue("");
|
|
258
|
+
else setValue(controlledValue);
|
|
259
|
+
}, [
|
|
260
|
+
controlledValue,
|
|
261
|
+
type,
|
|
262
|
+
allowEmpty
|
|
263
|
+
]);
|
|
264
|
+
let ariaDescribedBy = void 0;
|
|
265
|
+
if (normalizedProps.invalid) ariaDescribedBy = normalizedProps.invalidId;
|
|
266
|
+
if (normalizedProps.warn) ariaDescribedBy = normalizedProps.warnId;
|
|
267
|
+
if (!normalizedProps.validation) ariaDescribedBy = helperText ? normalizedProps.helperId : void 0;
|
|
268
|
+
function handleOnChange(event) {
|
|
269
|
+
if (disabled) return;
|
|
270
|
+
if (type === "number") {
|
|
271
|
+
const state = {
|
|
272
|
+
value: allowEmpty && event.target.value === "" ? "" : Number(event.target.value),
|
|
273
|
+
direction: value < event.target.value ? "up" : "down"
|
|
274
|
+
};
|
|
275
|
+
setValue(state.value);
|
|
276
|
+
if (onChange) onChange(event, state);
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
if (type === "text") {
|
|
280
|
+
const _value = allowEmpty && event.target.value === "" ? "" : event.target.value;
|
|
281
|
+
setNumberValue(numberParser.parse(_value));
|
|
282
|
+
setInputValue(_value);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
const handleFocus = (evt) => {
|
|
286
|
+
if ("type" in evt.target && evt.target.type === "button") setIsFocused(false);
|
|
287
|
+
else setIsFocused(evt.type === "focus");
|
|
288
|
+
};
|
|
289
|
+
const outerElementClasses = classNames(`${prefix}--form-item`, {
|
|
290
|
+
...customClassName ? { [customClassName]: true } : {},
|
|
291
|
+
[`${prefix}--number-input--fluid--invalid`]: isFluid && normalizedProps.invalid,
|
|
292
|
+
[`${prefix}--number-input--fluid--focus`]: isFluid && isFocused,
|
|
293
|
+
[`${prefix}--number-input--fluid--disabled`]: isFluid && disabled
|
|
294
|
+
});
|
|
295
|
+
const Icon = normalizedProps.icon;
|
|
296
|
+
const getDecimalPlaces = (num) => {
|
|
297
|
+
const parts = num.toString().split(".");
|
|
298
|
+
return parts[1] ? parts[1].length : 0;
|
|
299
|
+
};
|
|
300
|
+
const handleStep = (event, direction) => {
|
|
301
|
+
if (inputRef.current) {
|
|
302
|
+
const currentValue = type === "number" ? Number(inputRef.current.value) : numberValue;
|
|
303
|
+
let rawValue;
|
|
304
|
+
if (Number.isNaN(currentValue) || !currentValue) if (typeof stepStartValue === "number" && stepStartValue) rawValue = stepStartValue;
|
|
305
|
+
else if (min && min < 0 && max && max > 0 || !max && !min || max) {
|
|
306
|
+
if (direction === `up`) rawValue = 1;
|
|
307
|
+
if (direction === `down`) rawValue = -1;
|
|
308
|
+
} else if (min && min > 0 && max && max > 0 || min) rawValue = min;
|
|
309
|
+
else rawValue = 0;
|
|
310
|
+
else if (direction === "up") rawValue = currentValue + step;
|
|
311
|
+
else rawValue = currentValue - step;
|
|
312
|
+
const precision = Math.max(getDecimalPlaces(currentValue), getDecimalPlaces(step));
|
|
313
|
+
const newValue = clamp(parseFloat(Number(rawValue).toFixed(precision)), min ?? -Infinity, max ?? Infinity);
|
|
314
|
+
const state = {
|
|
315
|
+
value: newValue,
|
|
316
|
+
direction
|
|
317
|
+
};
|
|
318
|
+
if (type === "number") setValue(state.value);
|
|
319
|
+
if (type === "text") {
|
|
320
|
+
const formattedNewValue = format(newValue);
|
|
321
|
+
const parsedFormattedNewValue = numberParser.parse(formattedNewValue);
|
|
322
|
+
setNumberValue(parsedFormattedNewValue);
|
|
323
|
+
setInputValue(formattedNewValue);
|
|
324
|
+
previousNumberValue.current = parsedFormattedNewValue;
|
|
325
|
+
}
|
|
326
|
+
if (onChange) onChange(event, state);
|
|
327
|
+
return state;
|
|
328
|
+
}
|
|
329
|
+
};
|
|
330
|
+
const handleStepperClick = (event, direction) => {
|
|
331
|
+
if (inputRef.current) {
|
|
332
|
+
const state = handleStep(event, direction);
|
|
333
|
+
if (onClick) onClick(event, state);
|
|
334
|
+
}
|
|
335
|
+
};
|
|
336
|
+
const candidate = slug ?? decorator;
|
|
337
|
+
const normalizedDecorator = isComponentElement(candidate, AILabel) ? cloneElement(candidate, { size: "mini" }) : candidate;
|
|
338
|
+
const isRevertActive = isComponentElement(normalizedDecorator, AILabel) ? normalizedDecorator.props.revertActive : void 0;
|
|
339
|
+
useEffect(() => {
|
|
340
|
+
if (!isRevertActive && slug && defaultValue) setValue(defaultValue);
|
|
341
|
+
}, [
|
|
342
|
+
defaultValue,
|
|
343
|
+
isRevertActive,
|
|
344
|
+
slug
|
|
345
|
+
]);
|
|
346
|
+
return /* @__PURE__ */ jsx("div", {
|
|
347
|
+
className: outerElementClasses,
|
|
348
|
+
onFocus: isFluid ? handleFocus : void 0,
|
|
349
|
+
onBlur: isFluid ? handleFocus : void 0,
|
|
350
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
351
|
+
className: numberInputClasses,
|
|
352
|
+
"data-invalid": normalizedProps.invalid ? true : void 0,
|
|
353
|
+
children: [
|
|
354
|
+
/* @__PURE__ */ jsx(Label, {
|
|
355
|
+
disabled: normalizedProps.disabled,
|
|
356
|
+
hideLabel,
|
|
357
|
+
id,
|
|
358
|
+
label
|
|
359
|
+
}),
|
|
360
|
+
/* @__PURE__ */ jsxs("div", {
|
|
361
|
+
className: wrapperClasses,
|
|
362
|
+
children: [
|
|
363
|
+
/* @__PURE__ */ jsx("input", {
|
|
364
|
+
...rest,
|
|
365
|
+
"data-invalid": normalizedProps.invalid ? true : void 0,
|
|
366
|
+
"aria-invalid": normalizedProps.invalid,
|
|
367
|
+
"aria-describedby": ariaDescribedBy,
|
|
368
|
+
"aria-readonly": readOnly,
|
|
369
|
+
disabled: normalizedProps.disabled,
|
|
370
|
+
ref,
|
|
371
|
+
id,
|
|
372
|
+
max,
|
|
373
|
+
min,
|
|
374
|
+
onClick,
|
|
375
|
+
onChange: handleOnChange,
|
|
376
|
+
onKeyUp,
|
|
377
|
+
onKeyDown: (e) => {
|
|
378
|
+
if (type === "text") {
|
|
379
|
+
if (match(e, ArrowUp$1)) handleStep(e, "up");
|
|
380
|
+
else if (match(e, ArrowDown)) handleStep(e, "down");
|
|
381
|
+
}
|
|
382
|
+
if (rest?.onKeyDown) rest?.onKeyDown(e);
|
|
383
|
+
},
|
|
384
|
+
onFocus: (e) => {
|
|
385
|
+
if (disableWheelProp) e.target.addEventListener("wheel", disableWheel);
|
|
386
|
+
if (rest.onFocus) rest.onFocus(e);
|
|
387
|
+
},
|
|
388
|
+
onBlur: (e) => {
|
|
389
|
+
if (disableWheelProp) e.target.removeEventListener("wheel", disableWheel);
|
|
390
|
+
let parsedValueForBlur;
|
|
391
|
+
if (type === "text") {
|
|
392
|
+
const _numberValue = isControlled ? numberParser.parse(inputValue) : numberValue;
|
|
393
|
+
const formattedValue = isNaN(_numberValue) ? "" : format(_numberValue);
|
|
394
|
+
const rawValue = e.target.value;
|
|
395
|
+
const isValid = validate ? validate(rawValue, locale) : true;
|
|
396
|
+
setInputValue(isValid ? formattedValue : rawValue);
|
|
397
|
+
const parsedFormattedNewValue = numberParser.parse(formattedValue);
|
|
398
|
+
parsedValueForBlur = parsedFormattedNewValue;
|
|
399
|
+
if (onChange && isValid) {
|
|
400
|
+
const state = {
|
|
401
|
+
value: parsedFormattedNewValue,
|
|
402
|
+
direction: previousNumberValue.current < parsedFormattedNewValue ? "up" : "down"
|
|
403
|
+
};
|
|
404
|
+
if (!(isNaN(previousNumberValue.current) && isNaN(parsedFormattedNewValue))) onChange(e, state);
|
|
405
|
+
}
|
|
406
|
+
if (!(isNaN(previousNumberValue.current) && isNaN(numberValue))) previousNumberValue.current = numberValue;
|
|
407
|
+
if (!(isNaN(numberValue) && isNaN(parsedFormattedNewValue))) setNumberValue(parsedFormattedNewValue);
|
|
408
|
+
}
|
|
409
|
+
if (onBlur) {
|
|
410
|
+
if (type === "number") {
|
|
411
|
+
onBlur(e, value);
|
|
412
|
+
return;
|
|
413
|
+
}
|
|
414
|
+
onBlur(e, parsedValueForBlur ?? (isControlled ? numberParser.parse(inputValue) : numberValue));
|
|
415
|
+
}
|
|
416
|
+
},
|
|
417
|
+
pattern,
|
|
418
|
+
inputMode,
|
|
419
|
+
readOnly,
|
|
420
|
+
step,
|
|
421
|
+
type,
|
|
422
|
+
value: type === "number" ? value : inputValue
|
|
423
|
+
}),
|
|
424
|
+
slug ? normalizedDecorator : decorator ? /* @__PURE__ */ jsx("div", {
|
|
425
|
+
className: `${prefix}--number__input-inner-wrapper--decorator`,
|
|
426
|
+
children: normalizedDecorator
|
|
427
|
+
}) : "",
|
|
428
|
+
Icon ? /* @__PURE__ */ jsx(Icon, { className: iconClasses }) : null,
|
|
429
|
+
!hideSteppers && /* @__PURE__ */ jsxs("div", {
|
|
430
|
+
className: `${prefix}--number__controls`,
|
|
431
|
+
children: [
|
|
432
|
+
/* @__PURE__ */ jsx("button", {
|
|
433
|
+
"aria-label": decrementNumLabel || iconDescription,
|
|
434
|
+
className: `${prefix}--number__control-btn down-icon`,
|
|
435
|
+
disabled: disabled || readOnly,
|
|
436
|
+
onClick: (event) => handleStepperClick(event, "down"),
|
|
437
|
+
onBlur: onStepperBlur,
|
|
438
|
+
tabIndex: -1,
|
|
439
|
+
title: decrementNumLabel || iconDescription,
|
|
440
|
+
type: "button",
|
|
441
|
+
children: /* @__PURE__ */ jsx(Subtract, { className: "down-icon" })
|
|
442
|
+
}),
|
|
443
|
+
/* @__PURE__ */ jsx("div", { className: `${prefix}--number__rule-divider` }),
|
|
444
|
+
/* @__PURE__ */ jsx("button", {
|
|
445
|
+
"aria-label": incrementNumLabel || iconDescription,
|
|
446
|
+
className: `${prefix}--number__control-btn up-icon`,
|
|
447
|
+
disabled: disabled || readOnly,
|
|
448
|
+
onClick: (event) => handleStepperClick(event, "up"),
|
|
449
|
+
onBlur: onStepperBlur,
|
|
450
|
+
tabIndex: -1,
|
|
451
|
+
title: incrementNumLabel || iconDescription,
|
|
452
|
+
type: "button",
|
|
453
|
+
children: /* @__PURE__ */ jsx(Add, { className: "up-icon" })
|
|
454
|
+
}),
|
|
455
|
+
/* @__PURE__ */ jsx("div", { className: `${prefix}--number__rule-divider` })
|
|
456
|
+
]
|
|
457
|
+
})
|
|
458
|
+
]
|
|
459
|
+
}),
|
|
460
|
+
isFluid && /* @__PURE__ */ jsx("hr", { className: `${prefix}--number-input__divider` }),
|
|
461
|
+
normalizedProps.validation ? normalizedProps.validation : /* @__PURE__ */ jsx(HelperText, {
|
|
462
|
+
id: normalizedProps.helperId,
|
|
463
|
+
disabled,
|
|
464
|
+
description: helperText
|
|
465
|
+
})
|
|
466
|
+
]
|
|
467
|
+
})
|
|
468
|
+
});
|
|
686
469
|
});
|
|
687
470
|
NumberInput.propTypes = {
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
id: PropTypes.string.isRequired,
|
|
739
|
-
/**
|
|
740
|
-
* Instruct the browser which keyboard to display on mobile devices. Defaults
|
|
741
|
-
* to `decimal`, but note that standard numeric keyboards vary across devices
|
|
742
|
-
* and operating systems.
|
|
743
|
-
* @see https://css-tricks.com/everything-you-ever-wanted-to-know-about-inputmode/
|
|
744
|
-
*/
|
|
745
|
-
inputMode: PropTypes.oneOf(['none', 'text', 'tel', 'url', 'email', 'numeric', 'decimal', 'search']),
|
|
746
|
-
/**
|
|
747
|
-
* Specify if the currently value is invalid.
|
|
748
|
-
*/
|
|
749
|
-
invalid: PropTypes.bool,
|
|
750
|
-
/**
|
|
751
|
-
* Message which is displayed if the value is invalid.
|
|
752
|
-
*/
|
|
753
|
-
invalidText: PropTypes.node,
|
|
754
|
-
/**
|
|
755
|
-
* Generic `label` that will be used as the textual representation of what
|
|
756
|
-
* this field is for
|
|
757
|
-
*/
|
|
758
|
-
label: PropTypes.node,
|
|
759
|
-
/**
|
|
760
|
-
* `true` to use the light version.
|
|
761
|
-
*/
|
|
762
|
-
light: deprecate(PropTypes.bool, 'The `light` prop for `NumberInput` is no longer needed and has ' + 'been deprecated in v11 in favor of the new `Layer` component. It will be moved in the next major release.'),
|
|
763
|
-
/**
|
|
764
|
-
* **Experimental:** Specify a [BCP47](https://www.ietf.org/rfc/bcp/bcp47.txt)
|
|
765
|
-
* language code for parsing and formatting. Use with `type="text"`, has no
|
|
766
|
-
* effect when `type="number"`.
|
|
767
|
-
*/
|
|
768
|
-
locale: PropTypes.string,
|
|
769
|
-
/**
|
|
770
|
-
* The maximum value.
|
|
771
|
-
*/
|
|
772
|
-
max: PropTypes.number,
|
|
773
|
-
/**
|
|
774
|
-
* The minimum value.
|
|
775
|
-
*/
|
|
776
|
-
min: PropTypes.number,
|
|
777
|
-
/**
|
|
778
|
-
* Provide the value stepping should begin at when the input is empty
|
|
779
|
-
*/
|
|
780
|
-
stepStartValue: PropTypes.number,
|
|
781
|
-
/**
|
|
782
|
-
* Provide an optional handler that is called when the input is blurred.
|
|
783
|
-
*/
|
|
784
|
-
onBlur: PropTypes.func,
|
|
785
|
-
/**
|
|
786
|
-
* Provide an optional handler that is called when the stepper
|
|
787
|
-
* buttons are blurred.
|
|
788
|
-
*/
|
|
789
|
-
onStepperBlur: PropTypes.func,
|
|
790
|
-
/**
|
|
791
|
-
* Provide an optional handler that is called when the internal state of
|
|
792
|
-
* NumberInput changes. This handler is called with event and state info.
|
|
793
|
-
* When type="number", this is called on every change of the input.
|
|
794
|
-
* When type="text", this is only called on blur after the number has been
|
|
795
|
-
* parsed and formatted.
|
|
796
|
-
* `(event, { value, direction }) => void`
|
|
797
|
-
*/
|
|
798
|
-
onChange: PropTypes.func,
|
|
799
|
-
/**
|
|
800
|
-
* Provide an optional function to be called when the up/down button is clicked
|
|
801
|
-
*/
|
|
802
|
-
onClick: PropTypes.func,
|
|
803
|
-
/**
|
|
804
|
-
* Provide an optional function to be called when a key is pressed in the number input
|
|
805
|
-
*/
|
|
806
|
-
onKeyUp: PropTypes.func,
|
|
807
|
-
/**
|
|
808
|
-
* When type="text", provide an optional pattern to restrict user input. Has
|
|
809
|
-
* no effect when type="number".
|
|
810
|
-
*/
|
|
811
|
-
pattern: PropTypes.string,
|
|
812
|
-
/**
|
|
813
|
-
* Specify if the component should be read-only
|
|
814
|
-
*/
|
|
815
|
-
readOnly: PropTypes.bool,
|
|
816
|
-
/**
|
|
817
|
-
* Specify the size of the Number Input.
|
|
818
|
-
*/
|
|
819
|
-
size: PropTypes.oneOf(['sm', 'md', 'lg']),
|
|
820
|
-
/**
|
|
821
|
-
* **Experimental**: Provide a `Slug` component to be rendered inside the
|
|
822
|
-
* `NumberInput` component
|
|
823
|
-
*/
|
|
824
|
-
slug: deprecate(PropTypes.node, 'The `slug` prop for `NumberInput` is no longer needed and has ' + 'been deprecated in v11 in favor of the new `decorator` prop. It will be moved in the next major release.'),
|
|
825
|
-
/**
|
|
826
|
-
* Specify how much the values should increase/decrease upon clicking on
|
|
827
|
-
* up/down button
|
|
828
|
-
*/
|
|
829
|
-
step: PropTypes.number,
|
|
830
|
-
/**
|
|
831
|
-
* Translates component strings using your i18n tool.
|
|
832
|
-
*/
|
|
833
|
-
translateWithId: PropTypes.func,
|
|
834
|
-
/**
|
|
835
|
-
* **Experimental**: Specify if the input should be of type text or number.
|
|
836
|
-
* Use type="text" with `locale`, `formatOptions`, and guide user input with
|
|
837
|
-
* `pattern` and `inputMode`.
|
|
838
|
-
*/
|
|
839
|
-
type: PropTypes.oneOf(['number', 'text']),
|
|
840
|
-
/**
|
|
841
|
-
* Specify the value of the input
|
|
842
|
-
*/
|
|
843
|
-
value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
844
|
-
/**
|
|
845
|
-
* Specify whether the control is currently in warning state
|
|
846
|
-
*/
|
|
847
|
-
warn: PropTypes.bool,
|
|
848
|
-
/**
|
|
849
|
-
* Provide the text that is displayed when the control is in warning state
|
|
850
|
-
*/
|
|
851
|
-
warnText: PropTypes.node,
|
|
852
|
-
/**
|
|
853
|
-
* Optional validation function that is called with the input value and locale.
|
|
854
|
-
*
|
|
855
|
-
* - Return `false` to immediately fail validation.
|
|
856
|
-
* - Return `true` to pass this validation, but still run other checks (min, max, required, etc.).
|
|
857
|
-
* - Return `undefined` to defer entirely to built-in validation logic.
|
|
858
|
-
*
|
|
859
|
-
* This is called before other validations, giving consumers the ability
|
|
860
|
-
* to short-circuit or extend validation without replacing built-in rules.
|
|
861
|
-
*/
|
|
862
|
-
validate: PropTypes.func
|
|
471
|
+
allowEmpty: PropTypes.bool,
|
|
472
|
+
className: PropTypes.string,
|
|
473
|
+
decorator: PropTypes.node,
|
|
474
|
+
defaultValue: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
475
|
+
disableWheel: PropTypes.bool,
|
|
476
|
+
disabled: PropTypes.bool,
|
|
477
|
+
formatOptions: NumberFormatOptionsPropType,
|
|
478
|
+
helperText: PropTypes.node,
|
|
479
|
+
hideLabel: PropTypes.bool,
|
|
480
|
+
hideSteppers: PropTypes.bool,
|
|
481
|
+
iconDescription: PropTypes.string,
|
|
482
|
+
id: PropTypes.string.isRequired,
|
|
483
|
+
inputMode: PropTypes.oneOf([
|
|
484
|
+
"none",
|
|
485
|
+
"text",
|
|
486
|
+
"tel",
|
|
487
|
+
"url",
|
|
488
|
+
"email",
|
|
489
|
+
"numeric",
|
|
490
|
+
"decimal",
|
|
491
|
+
"search"
|
|
492
|
+
]),
|
|
493
|
+
invalid: PropTypes.bool,
|
|
494
|
+
invalidText: PropTypes.node,
|
|
495
|
+
label: PropTypes.node,
|
|
496
|
+
light: deprecate(PropTypes.bool, "The `light` prop for `NumberInput` is no longer needed and has been deprecated in v11 in favor of the new `Layer` component. It will be moved in the next major release."),
|
|
497
|
+
locale: PropTypes.string,
|
|
498
|
+
max: PropTypes.number,
|
|
499
|
+
min: PropTypes.number,
|
|
500
|
+
stepStartValue: PropTypes.number,
|
|
501
|
+
onBlur: PropTypes.func,
|
|
502
|
+
onStepperBlur: PropTypes.func,
|
|
503
|
+
onChange: PropTypes.func,
|
|
504
|
+
onClick: PropTypes.func,
|
|
505
|
+
onKeyUp: PropTypes.func,
|
|
506
|
+
pattern: PropTypes.string,
|
|
507
|
+
readOnly: PropTypes.bool,
|
|
508
|
+
size: PropTypes.oneOf([
|
|
509
|
+
"sm",
|
|
510
|
+
"md",
|
|
511
|
+
"lg"
|
|
512
|
+
]),
|
|
513
|
+
slug: deprecate(PropTypes.node, "The `slug` prop for `NumberInput` is no longer needed and has been deprecated in v11 in favor of the new `decorator` prop. It will be moved in the next major release."),
|
|
514
|
+
step: PropTypes.number,
|
|
515
|
+
translateWithId: PropTypes.func,
|
|
516
|
+
type: PropTypes.oneOf(["number", "text"]),
|
|
517
|
+
value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
518
|
+
warn: PropTypes.bool,
|
|
519
|
+
warnText: PropTypes.node,
|
|
520
|
+
validate: PropTypes.func
|
|
863
521
|
};
|
|
864
|
-
const Label = ({
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
}
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
as: "label",
|
|
879
|
-
htmlFor: id,
|
|
880
|
-
className: className
|
|
881
|
-
}, label);
|
|
882
|
-
}
|
|
883
|
-
return null;
|
|
522
|
+
const Label = ({ disabled, id, hideLabel, label }) => {
|
|
523
|
+
const prefix = usePrefix();
|
|
524
|
+
const className = classNames({
|
|
525
|
+
[`${prefix}--label`]: true,
|
|
526
|
+
[`${prefix}--label--disabled`]: disabled,
|
|
527
|
+
[`${prefix}--visually-hidden`]: hideLabel
|
|
528
|
+
});
|
|
529
|
+
if (label) return /* @__PURE__ */ jsx(Text, {
|
|
530
|
+
as: "label",
|
|
531
|
+
htmlFor: id,
|
|
532
|
+
className,
|
|
533
|
+
children: label
|
|
534
|
+
});
|
|
535
|
+
return null;
|
|
884
536
|
};
|
|
885
|
-
const HelperText = ({
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
return /*#__PURE__*/React.createElement(Text, {
|
|
896
|
-
as: "div",
|
|
897
|
-
id: id,
|
|
898
|
-
className: className
|
|
899
|
-
}, description);
|
|
900
|
-
}
|
|
901
|
-
return null;
|
|
537
|
+
const HelperText = ({ disabled, description, id }) => {
|
|
538
|
+
const prefix = usePrefix();
|
|
539
|
+
const className = classNames(`${prefix}--form__helper-text`, { [`${prefix}--form__helper-text--disabled`]: disabled });
|
|
540
|
+
if (description) return /* @__PURE__ */ jsx(Text, {
|
|
541
|
+
as: "div",
|
|
542
|
+
id,
|
|
543
|
+
className,
|
|
544
|
+
children: description
|
|
545
|
+
});
|
|
546
|
+
return null;
|
|
902
547
|
};
|
|
903
|
-
|
|
904
548
|
/**
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
function getInputValidity({
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
}
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
// Skip validation if value is empty and allowEmpty
|
|
933
|
-
if (value === '') return allowEmpty;
|
|
934
|
-
|
|
935
|
-
// Normalize the value
|
|
936
|
-
let numericValue;
|
|
937
|
-
if (typeof value === 'string') {
|
|
938
|
-
numericValue = parseNumberWithLocale(value, locale); // safe: handles Arabic, Kanji, etc.
|
|
939
|
-
} else {
|
|
940
|
-
numericValue = value;
|
|
941
|
-
}
|
|
942
|
-
|
|
943
|
-
// Use custom validate ONLY for formatting, not numeric comparison
|
|
944
|
-
if (validate && typeof value === 'string') {
|
|
945
|
-
const isFormatValid = validate(value, locale);
|
|
946
|
-
if (isFormatValid === false) {
|
|
947
|
-
return false; // invalid format
|
|
948
|
-
}
|
|
949
|
-
}
|
|
950
|
-
|
|
951
|
-
// Check min/max bounds
|
|
952
|
-
if (max !== undefined && numericValue > max) return false;
|
|
953
|
-
if (min !== undefined && numericValue < min) return false;
|
|
954
|
-
return true; // valid
|
|
549
|
+
* Determine if the given value is invalid based on the given max, min and
|
|
550
|
+
* conditions like `allowEmpty`. If `invalid` is passed through, it will default
|
|
551
|
+
* to false.
|
|
552
|
+
*
|
|
553
|
+
* @param {object} config
|
|
554
|
+
* @param {boolean} config.allowEmpty
|
|
555
|
+
* @param {boolean} config.invalid
|
|
556
|
+
* @param {number} config.value
|
|
557
|
+
* @param {number} config.max
|
|
558
|
+
* @param {number} config.min
|
|
559
|
+
* @param {Function} config.validate
|
|
560
|
+
* @param {string} config.locale
|
|
561
|
+
* @returns {boolean}
|
|
562
|
+
*/
|
|
563
|
+
function getInputValidity({ allowEmpty, invalid, value, max, min, validate, locale }) {
|
|
564
|
+
if (invalid) return false;
|
|
565
|
+
if (value === "") return allowEmpty;
|
|
566
|
+
let numericValue;
|
|
567
|
+
if (typeof value === "string") numericValue = parseNumberWithLocale(value, locale);
|
|
568
|
+
else numericValue = value;
|
|
569
|
+
if (validate && typeof value === "string") {
|
|
570
|
+
if (validate(value, locale) === false) return false;
|
|
571
|
+
}
|
|
572
|
+
if (max !== void 0 && numericValue > max) return false;
|
|
573
|
+
if (min !== void 0 && numericValue < min) return false;
|
|
574
|
+
return true;
|
|
955
575
|
}
|
|
956
|
-
|
|
957
576
|
/**
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
577
|
+
* It prevents any wheel event from emitting.
|
|
578
|
+
*
|
|
579
|
+
* We want to prevent this input field from changing by the user accidentally
|
|
580
|
+
* when the user scrolling up or down in a long form. So we prevent the default
|
|
581
|
+
* behavior of wheel events when it is focused.
|
|
582
|
+
*
|
|
583
|
+
* Because React uses passive event handler by default, we can't just call
|
|
584
|
+
* `preventDefault` in the `onWheel` event handler. So we have to get the input
|
|
585
|
+
* ref and add our event handler manually.
|
|
586
|
+
*
|
|
587
|
+
* @see https://github.com/facebook/react/pull/19654
|
|
588
|
+
* @param {WheelEvent} e A wheel event.
|
|
589
|
+
*/
|
|
971
590
|
function disableWheel(e) {
|
|
972
|
-
|
|
591
|
+
e.preventDefault();
|
|
973
592
|
}
|
|
974
593
|
|
|
975
|
-
|
|
594
|
+
//#endregion
|
|
595
|
+
export { NumberInput, validateNumberSeparators };
|