@carbon/react 1.29.1 → 1.30.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/es/_virtual/_rollupPluginBabelHelpers.js +16 -5
- package/es/components/Accordion/Accordion.Skeleton.js +0 -7
- package/es/components/Accordion/Accordion.js +1 -8
- package/es/components/Accordion/AccordionItem.js +5 -19
- package/es/components/AspectRatio/AspectRatio.js +0 -5
- package/es/components/Breadcrumb/Breadcrumb.Skeleton.js +0 -3
- package/es/components/Breadcrumb/Breadcrumb.js +0 -3
- package/es/components/Breadcrumb/BreadcrumbItem.js +0 -7
- package/es/components/Button/Button.Skeleton.js +2 -7
- package/es/components/Button/Button.js +2 -36
- package/es/components/ButtonSet/ButtonSet.js +0 -2
- package/es/components/Checkbox/Checkbox.Skeleton.js +0 -1
- package/es/components/Checkbox/Checkbox.js +4 -20
- package/es/components/CheckboxGroup/CheckboxGroup.js +0 -11
- package/es/components/ClassPrefix/index.d.ts +26 -0
- package/es/components/ClassPrefix/index.js +0 -2
- package/es/components/CodeSnippet/CodeSnippet.Skeleton.js +0 -5
- package/es/components/CodeSnippet/CodeSnippet.js +6 -45
- package/es/components/ComboBox/ComboBox.js +12 -79
- package/es/components/ComboBox/tools/filter.js +0 -1
- package/es/components/ComboButton/index.js +0 -14
- package/es/components/ComposedModal/ComposedModal.js +2 -32
- package/es/components/ComposedModal/ModalFooter.js +0 -21
- package/es/components/ComposedModal/ModalHeader.js +0 -12
- package/es/components/ContainedList/ContainedList.js +5 -32
- package/es/components/ContainedList/ContainedListItem/ContainedListItem.js +0 -6
- package/es/components/ContentSwitcher/ContentSwitcher.js +11 -23
- package/es/components/ContextMenu/useContextMenu.js +1 -6
- package/es/components/Copy/Copy.js +8 -31
- package/es/components/CopyButton/CopyButton.js +0 -4
- package/es/components/DangerButton/DangerButton.js +0 -1
- package/es/components/DataTable/DataTable.js +171 -91
- package/es/components/DataTable/Table.js +0 -6
- package/es/components/DataTable/TableBatchAction.js +0 -4
- package/es/components/DataTable/TableBatchActions.js +0 -8
- package/es/components/DataTable/TableBody.js +0 -1
- package/es/components/DataTable/TableContainer.js +0 -5
- package/es/components/DataTable/TableExpandHeader.js +0 -7
- package/es/components/DataTable/TableExpandRow.js +0 -6
- package/es/components/DataTable/TableExpandedRow.js +0 -6
- package/es/components/DataTable/TableHeader.d.ts +1 -1
- package/es/components/DataTable/TableHeader.js +3 -19
- package/es/components/DataTable/TableRow.js +4 -5
- package/es/components/DataTable/TableSelectAll.js +0 -8
- package/es/components/DataTable/TableSelectRow.js +2 -10
- package/es/components/DataTable/TableToolbar.js +0 -3
- package/es/components/DataTable/TableToolbarMenu.d.ts +1 -1
- package/es/components/DataTable/TableToolbarMenu.js +3 -6
- package/es/components/DataTable/TableToolbarSearch.js +2 -30
- package/es/components/DataTable/state/getDerivedStateFromProps.js +0 -4
- package/es/components/DataTable/state/sorting.js +5 -8
- package/es/components/DataTable/tools/denormalize.js +2 -2
- package/es/components/DataTable/tools/filter.js +0 -2
- package/es/components/DataTable/tools/instanceId.js +0 -1
- package/es/components/DataTable/tools/normalize.js +10 -10
- package/es/components/DataTable/tools/sorting.js +5 -13
- package/es/components/DataTableSkeleton/DataTableSkeleton.js +5 -20
- package/es/components/DatePicker/DatePicker.Skeleton.js +0 -6
- package/es/components/DatePicker/DatePicker.js +152 -174
- package/es/components/DatePicker/plugins/appendToPlugin.js +3 -7
- package/es/components/DatePicker/plugins/fixEventsPlugin.js +14 -25
- package/es/components/DatePicker/plugins/rangePlugin.js +2 -7
- package/es/components/DatePickerInput/DatePickerInput.js +2 -28
- package/es/components/Dropdown/Dropdown.Skeleton.js +0 -2
- package/es/components/Dropdown/Dropdown.js +43 -52
- package/es/components/ErrorBoundary/ErrorBoundary.js +0 -10
- package/es/components/ErrorBoundary/ErrorBoundaryContext.js +0 -1
- package/es/components/ExpandableSearch/ExpandableSearch.js +1 -10
- package/es/components/FeatureFlags/index.js +8 -20
- package/es/components/FileUploader/FileUploader.Skeleton.js +0 -2
- package/es/components/FileUploader/FileUploader.js +3 -38
- package/es/components/FileUploader/FileUploaderButton.js +3 -24
- package/es/components/FileUploader/FileUploaderDropContainer.js +1 -28
- package/es/components/FileUploader/FileUploaderItem.js +1 -11
- package/es/components/FileUploader/Filename.js +0 -10
- package/es/components/FluidComboBox/FluidComboBox.Skeleton.js +0 -1
- package/es/components/FluidComboBox/FluidComboBox.js +0 -18
- package/es/components/FluidDatePicker/FluidDatePicker.Skeleton.js +0 -2
- package/es/components/FluidDatePicker/FluidDatePicker.js +0 -6
- package/es/components/FluidDatePickerInput/FluidDatePickerInput.js +2 -1
- package/es/components/FluidDropdown/FluidDropdown.Skeleton.js +0 -1
- package/es/components/FluidDropdown/FluidDropdown.js +0 -18
- package/es/components/FluidForm/FluidForm.js +0 -2
- package/es/components/FluidMultiSelect/FluidMultiSelect.Skeleton.js +0 -1
- package/es/components/FluidMultiSelect/FluidMultiSelect.js +0 -19
- package/es/components/FluidSelect/FluidSelect.Skeleton.js +0 -1
- package/es/components/FluidSelect/FluidSelect.js +0 -10
- package/es/components/FluidTextArea/FluidTextArea.Skeleton.js +0 -1
- package/es/components/FluidTextArea/FluidTextArea.js +0 -20
- package/es/components/FluidTextInput/FluidTextInput.Skeleton.js +0 -1
- package/es/components/FluidTextInput/FluidTextInput.js +0 -14
- package/es/components/FluidTimePicker/FluidTimePicker.Skeleton.js +0 -3
- package/es/components/FluidTimePicker/FluidTimePicker.js +1 -11
- package/es/components/FluidTimePickerSelect/FluidTimePickerSelect.js +0 -6
- package/es/components/Form/Form.d.ts +23 -0
- package/es/components/Form/Form.js +3 -6
- package/es/components/Form/index.d.ts +7 -0
- package/es/components/FormGroup/FormGroup.js +0 -7
- package/es/components/FormItem/FormItem.js +0 -2
- package/es/components/FormLabel/FormLabel.js +1 -7
- package/es/components/Grid/CSSGrid.js +2 -15
- package/es/components/Grid/Column.js +18 -59
- package/es/components/Grid/ColumnHang.js +2 -5
- package/es/components/Grid/FlexGrid.js +2 -8
- package/es/components/Grid/Grid.js +0 -8
- package/es/components/Grid/GridContext.js +1 -3
- package/es/components/Grid/Row.js +2 -7
- package/es/components/Heading/index.js +0 -4
- package/es/components/Icon/Icon.Skeleton.js +2 -2
- package/es/components/IconButton/index.js +0 -10
- package/es/components/IdPrefix/index.js +0 -2
- package/es/components/InlineCheckbox/InlineCheckbox.js +0 -14
- package/es/components/InlineLoading/InlineLoading.js +0 -12
- package/es/components/Layer/index.js +3 -6
- package/es/components/Layout/LayoutDirection.js +0 -3
- package/es/components/Layout/useLayoutDirection.js +0 -1
- package/es/components/Link/Link.js +3 -10
- package/es/components/ListBox/ListBox.js +2 -13
- package/es/components/ListBox/ListBoxField.js +0 -5
- package/es/components/ListBox/ListBoxMenuIcon.js +0 -4
- package/es/components/ListBox/ListBoxMenuItem.js +2 -6
- package/es/components/ListBox/ListBoxPropTypes.d.ts +2 -2
- package/es/components/ListBox/ListBoxSelection.js +1 -13
- package/es/components/ListBox/next/ListBoxSelection.js +1 -14
- package/es/components/ListBox/next/ListBoxTrigger.js +1 -3
- package/es/components/ListItem/ListItem.d.ts +23 -0
- package/es/components/ListItem/ListItem.js +4 -8
- package/es/components/ListItem/index.d.ts +7 -0
- package/es/components/Loading/Loading.js +0 -6
- package/es/components/Menu/Menu.js +22 -40
- package/es/components/Menu/MenuContext.js +4 -5
- package/es/components/Menu/MenuItem.js +5 -39
- package/es/components/MenuButton/index.js +0 -9
- package/es/components/Modal/Modal.js +0 -43
- package/es/components/ModalWrapper/ModalWrapper.js +2 -15
- package/es/components/MultiSelect/FilterableMultiSelect.js +2 -60
- package/es/components/MultiSelect/MultiSelect.js +22 -70
- package/es/components/MultiSelect/MultiSelectPropTypes.js +0 -1
- package/es/components/MultiSelect/index.js +0 -1
- package/es/components/MultiSelect/tools/itemToString.js +0 -2
- package/es/components/MultiSelect/tools/sorting.js +3 -4
- package/es/components/Notification/Notification.js +0 -78
- package/es/components/NumberInput/NumberInput.Skeleton.js +0 -2
- package/es/components/NumberInput/NumberInput.js +3 -60
- package/es/components/OrderedList/OrderedList.d.ts +39 -0
- package/es/components/OrderedList/OrderedList.js +7 -19
- package/es/components/{Form/index.js → OrderedList/index.d.ts} +1 -3
- package/es/components/OverflowMenu/OverflowMenu.js +65 -86
- package/es/components/OverflowMenuItem/OverflowMenuItem.js +6 -23
- package/es/components/OverflowMenuV2/index.js +0 -5
- package/es/components/Pagination/Pagination.Skeleton.js +0 -2
- package/es/components/Pagination/Pagination.js +11 -47
- package/es/components/Pagination/experimental/PageSelector.js +0 -10
- package/es/components/Pagination/experimental/Pagination.js +2 -48
- package/es/components/PaginationNav/PaginationNav.js +15 -59
- package/es/components/Popover/index.d.ts +14 -8
- package/es/components/Popover/index.js +44 -48
- package/es/components/PrimaryButton/PrimaryButton.js +0 -1
- package/es/components/ProgressBar/ProgressBar.js +0 -15
- package/es/components/ProgressIndicator/ProgressIndicator.Skeleton.js +0 -4
- package/es/components/ProgressIndicator/ProgressIndicator.js +2 -40
- package/es/components/RadioButton/RadioButton.Skeleton.js +0 -1
- package/es/components/RadioButton/RadioButton.js +0 -13
- package/es/components/RadioButtonGroup/RadioButtonGroup.js +3 -23
- package/es/components/RadioTile/RadioTile.js +0 -12
- package/es/components/Search/Search.Skeleton.js +0 -2
- package/es/components/Search/Search.js +1 -28
- package/es/components/SecondaryButton/SecondaryButton.js +0 -1
- package/es/components/Select/Select.Skeleton.js +0 -2
- package/es/components/Select/Select.d.ts +1 -1
- package/es/components/Select/Select.js +6 -33
- package/es/components/SelectItem/SelectItem.js +0 -5
- package/es/components/SelectItemGroup/SelectItemGroup.d.ts +0 -1
- package/es/components/SelectItemGroup/SelectItemGroup.js +1 -7
- package/es/components/SkeletonIcon/SkeletonIcon.js +0 -2
- package/es/components/SkeletonPlaceholder/SkeletonPlaceholder.js +0 -1
- package/es/components/SkeletonText/SkeletonText.js +0 -12
- package/es/components/Slider/Slider.Skeleton.js +0 -2
- package/es/components/Slider/Slider.d.ts +0 -1
- package/es/components/Slider/Slider.js +112 -135
- package/es/components/Stack/Stack.js +1 -8
- package/es/components/StructuredList/StructuredList.Skeleton.js +0 -5
- package/es/components/StructuredList/StructuredList.js +1 -25
- package/es/components/Switch/IconSwitch.js +0 -18
- package/es/components/Switch/Switch.js +0 -11
- package/es/components/TabContent/TabContent.js +2 -6
- package/es/components/Tabs/Tabs.Skeleton.js +0 -4
- package/es/components/Tabs/Tabs.js +135 -104
- package/es/components/Tabs/usePressable.js +18 -31
- package/es/components/Tag/Tag.Skeleton.js +0 -2
- package/es/components/Tag/Tag.js +0 -15
- package/es/components/Text/Text.js +5 -18
- package/es/components/Text/TextDirection.js +0 -3
- package/es/components/Text/TextDirectionContext.js +0 -1
- package/es/components/Text/createTextComponent.js +0 -3
- package/es/components/TextArea/TextArea.Skeleton.js +0 -2
- package/es/components/TextArea/TextArea.js +11 -33
- package/es/components/TextInput/ControlledPasswordInput.js +0 -20
- package/es/components/TextInput/PasswordInput.js +0 -25
- package/es/components/TextInput/TextInput.Skeleton.js +0 -2
- package/es/components/TextInput/TextInput.d.ts +1 -1
- package/es/components/TextInput/TextInput.js +5 -33
- package/es/components/TextInput/util.js +3 -5
- package/es/components/Theme/index.js +1 -6
- package/es/components/Tile/Tile.js +32 -59
- package/es/components/TileGroup/TileGroup.js +1 -22
- package/es/components/TimePicker/TimePicker.js +6 -32
- package/es/components/TimePickerSelect/TimePickerSelect.js +2 -5
- package/es/components/Toggle/Toggle.Skeleton.js +0 -8
- package/es/components/Toggle/Toggle.js +0 -16
- package/es/components/ToggleSmall/ToggleSmall.Skeleton.js +0 -7
- package/es/components/Toggletip/index.d.ts +148 -0
- package/es/components/Toggletip/index.js +20 -44
- package/es/components/Tooltip/DefinitionTooltip.js +0 -11
- package/es/components/Tooltip/Tooltip.d.ts +1 -1
- package/es/components/Tooltip/Tooltip.js +4 -21
- package/es/components/TreeView/TreeNode.js +21 -66
- package/es/components/TreeView/TreeView.js +11 -67
- package/es/components/UIShell/Content.js +2 -4
- package/es/components/UIShell/Header.js +0 -2
- package/es/components/UIShell/HeaderContainer.d.ts +33 -0
- package/es/components/UIShell/HeaderContainer.js +13 -11
- package/es/components/UIShell/HeaderGlobalAction.js +0 -6
- package/es/components/UIShell/HeaderGlobalBar.js +0 -1
- package/es/components/UIShell/HeaderMenu.js +32 -31
- package/es/components/UIShell/HeaderMenuButton.js +2 -4
- package/es/components/UIShell/HeaderMenuItem.js +0 -8
- package/es/components/UIShell/HeaderName.js +0 -5
- package/es/components/UIShell/HeaderNavigation.js +0 -2
- package/es/components/UIShell/HeaderPanel.js +0 -2
- package/es/components/UIShell/HeaderSideNavItems.js +0 -2
- package/es/components/UIShell/Link.js +2 -3
- package/es/components/UIShell/SideNav.d.ts +3 -1
- package/es/components/UIShell/SideNav.js +44 -36
- package/es/components/UIShell/SideNavDetails.js +0 -3
- package/es/components/UIShell/SideNavDivider.js +0 -1
- package/es/components/UIShell/SideNavFooter.js +1 -4
- package/es/components/UIShell/SideNavHeader.js +0 -4
- package/es/components/UIShell/SideNavIcon.js +0 -3
- package/es/components/UIShell/SideNavItem.js +0 -3
- package/es/components/UIShell/SideNavItems.js +2 -6
- package/es/components/UIShell/SideNavLink.js +3 -7
- package/es/components/UIShell/SideNavLinkText.js +0 -2
- package/es/components/UIShell/SideNavMenu.js +0 -16
- package/es/components/UIShell/SideNavMenuItem.js +0 -2
- package/es/components/UIShell/SideNavSwitcher.js +2 -5
- package/es/components/UIShell/SkipToContent.d.ts +32 -0
- package/es/components/UIShell/SkipToContent.js +8 -15
- package/es/components/UIShell/Switcher.js +0 -2
- package/es/components/UIShell/SwitcherDivider.js +0 -1
- package/es/components/UIShell/SwitcherItem.js +0 -3
- package/es/components/UnorderedList/UnorderedList.d.ts +34 -0
- package/es/components/UnorderedList/UnorderedList.js +6 -16
- package/es/components/UnorderedList/index.d.ts +7 -0
- package/es/index.js +7 -8
- package/es/internal/ClickListener.js +3 -13
- package/es/internal/FloatingMenu.js +57 -63
- package/es/internal/OptimizedResize.js +6 -12
- package/es/internal/Selection.js +2 -25
- package/es/internal/createClassWrapper.js +0 -2
- package/es/internal/deprecateFieldOnObject.js +0 -4
- package/es/internal/focus/index.js +0 -1
- package/es/internal/keyboard/keys.js +2 -1
- package/es/internal/keyboard/match.js +1 -6
- package/es/internal/keyboard/navigation.js +8 -7
- package/es/internal/useAnnouncer.js +0 -1
- package/es/internal/useAttachedMenu.js +1 -9
- package/es/internal/useControllableState.js +6 -13
- package/es/internal/useDelayedState.js +2 -4
- package/es/internal/useEffectOnce.js +0 -1
- package/es/internal/useEvent.js +61 -3
- package/es/internal/useId.js +2 -5
- package/es/internal/useIsomorphicEffect.js +1 -0
- package/es/internal/useMergedRefs.js +2 -2
- package/es/internal/useNoInteractiveChildren.js +2 -13
- package/es/internal/useNormalizedInputProps.js +0 -3
- package/es/internal/useSavedCallback.js +0 -1
- package/es/internal/warning.js +0 -3
- package/es/internal/wrapFocus.js +1 -8
- package/es/prop-types/deprecate.js +2 -5
- package/es/prop-types/isRequiredOneOf.js +2 -5
- package/es/prop-types/requiredIfGivenPropIsTruthy.js +0 -2
- package/es/tools/array.js +0 -3
- package/es/tools/events.js +0 -3
- package/es/tools/mergeRefs.js +0 -2
- package/es/tools/wrapComponent.js +2 -5
- package/lib/_virtual/_rollupPluginBabelHelpers.js +17 -4
- package/lib/components/Accordion/Accordion.Skeleton.js +0 -7
- package/lib/components/Accordion/Accordion.js +1 -27
- package/lib/components/Accordion/AccordionItem.js +5 -19
- package/lib/components/AspectRatio/AspectRatio.js +0 -5
- package/lib/components/Breadcrumb/Breadcrumb.Skeleton.js +0 -3
- package/lib/components/Breadcrumb/Breadcrumb.js +0 -3
- package/lib/components/Breadcrumb/BreadcrumbItem.js +0 -7
- package/lib/components/Button/Button.Skeleton.js +2 -26
- package/lib/components/Button/Button.js +2 -36
- package/lib/components/ButtonSet/ButtonSet.js +0 -2
- package/lib/components/Checkbox/Checkbox.Skeleton.js +0 -1
- package/lib/components/Checkbox/Checkbox.js +4 -20
- package/lib/components/CheckboxGroup/CheckboxGroup.js +0 -11
- package/lib/components/ClassPrefix/index.d.ts +26 -0
- package/lib/components/ClassPrefix/index.js +0 -2
- package/lib/components/CodeSnippet/CodeSnippet.Skeleton.js +0 -5
- package/lib/components/CodeSnippet/CodeSnippet.js +6 -45
- package/lib/components/ComboBox/ComboBox.js +19 -86
- package/lib/components/ComboBox/tools/filter.js +0 -1
- package/lib/components/ComboButton/index.js +0 -14
- package/lib/components/ComposedModal/ComposedModal.js +2 -32
- package/lib/components/ComposedModal/ModalFooter.js +0 -21
- package/lib/components/ComposedModal/ModalHeader.js +0 -12
- package/lib/components/ContainedList/ContainedList.js +5 -32
- package/lib/components/ContainedList/ContainedListItem/ContainedListItem.js +0 -6
- package/lib/components/ContentSwitcher/ContentSwitcher.js +11 -23
- package/lib/components/ContextMenu/useContextMenu.js +1 -6
- package/lib/components/Copy/Copy.js +8 -50
- package/lib/components/CopyButton/CopyButton.js +0 -4
- package/lib/components/DangerButton/DangerButton.js +0 -1
- package/lib/components/DataTable/DataTable.js +171 -91
- package/lib/components/DataTable/Table.js +0 -6
- package/lib/components/DataTable/TableBatchAction.js +0 -4
- package/lib/components/DataTable/TableBatchActions.js +0 -8
- package/lib/components/DataTable/TableBody.js +0 -1
- package/lib/components/DataTable/TableContainer.js +0 -5
- package/lib/components/DataTable/TableExpandHeader.js +0 -7
- package/lib/components/DataTable/TableExpandRow.js +0 -6
- package/lib/components/DataTable/TableExpandedRow.js +0 -6
- package/lib/components/DataTable/TableHeader.d.ts +1 -1
- package/lib/components/DataTable/TableHeader.js +3 -19
- package/lib/components/DataTable/TableRow.js +4 -5
- package/lib/components/DataTable/TableSelectAll.js +0 -8
- package/lib/components/DataTable/TableSelectRow.js +2 -10
- package/lib/components/DataTable/TableToolbar.js +0 -3
- package/lib/components/DataTable/TableToolbarMenu.d.ts +1 -1
- package/lib/components/DataTable/TableToolbarMenu.js +3 -6
- package/lib/components/DataTable/TableToolbarSearch.js +2 -30
- package/lib/components/DataTable/state/getDerivedStateFromProps.js +0 -4
- package/lib/components/DataTable/state/sorting.js +5 -8
- package/lib/components/DataTable/tools/denormalize.js +2 -2
- package/lib/components/DataTable/tools/filter.js +0 -2
- package/lib/components/DataTable/tools/instanceId.js +0 -1
- package/lib/components/DataTable/tools/normalize.js +10 -10
- package/lib/components/DataTable/tools/sorting.js +5 -13
- package/lib/components/DataTableSkeleton/DataTableSkeleton.js +5 -20
- package/lib/components/DatePicker/DatePicker.Skeleton.js +0 -6
- package/lib/components/DatePicker/DatePicker.js +152 -174
- package/lib/components/DatePicker/plugins/appendToPlugin.js +3 -7
- package/lib/components/DatePicker/plugins/fixEventsPlugin.js +14 -25
- package/lib/components/DatePicker/plugins/rangePlugin.js +2 -7
- package/lib/components/DatePickerInput/DatePickerInput.js +2 -28
- package/lib/components/Dropdown/Dropdown.Skeleton.js +0 -2
- package/lib/components/Dropdown/Dropdown.js +50 -59
- package/lib/components/ErrorBoundary/ErrorBoundary.js +0 -10
- package/lib/components/ErrorBoundary/ErrorBoundaryContext.js +0 -1
- package/lib/components/ExpandableSearch/ExpandableSearch.js +1 -10
- package/lib/components/FeatureFlags/index.js +8 -20
- package/lib/components/FileUploader/FileUploader.Skeleton.js +0 -2
- package/lib/components/FileUploader/FileUploader.js +3 -57
- package/lib/components/FileUploader/FileUploaderButton.js +3 -43
- package/lib/components/FileUploader/FileUploaderDropContainer.js +1 -28
- package/lib/components/FileUploader/FileUploaderItem.js +1 -30
- package/lib/components/FileUploader/Filename.js +0 -10
- package/lib/components/FluidComboBox/FluidComboBox.Skeleton.js +0 -1
- package/lib/components/FluidComboBox/FluidComboBox.js +0 -18
- package/lib/components/FluidDatePicker/FluidDatePicker.Skeleton.js +0 -2
- package/lib/components/FluidDatePicker/FluidDatePicker.js +0 -6
- package/lib/components/FluidDatePickerInput/FluidDatePickerInput.js +2 -1
- package/lib/components/FluidDropdown/FluidDropdown.Skeleton.js +0 -1
- package/lib/components/FluidDropdown/FluidDropdown.js +0 -18
- package/lib/components/FluidForm/FluidForm.js +0 -2
- package/lib/components/FluidMultiSelect/FluidMultiSelect.Skeleton.js +0 -1
- package/lib/components/FluidMultiSelect/FluidMultiSelect.js +0 -19
- package/lib/components/FluidSelect/FluidSelect.Skeleton.js +0 -1
- package/lib/components/FluidSelect/FluidSelect.js +0 -10
- package/lib/components/FluidTextArea/FluidTextArea.Skeleton.js +0 -1
- package/lib/components/FluidTextArea/FluidTextArea.js +0 -20
- package/lib/components/FluidTextInput/FluidTextInput.Skeleton.js +0 -1
- package/lib/components/FluidTextInput/FluidTextInput.js +0 -14
- package/lib/components/FluidTimePicker/FluidTimePicker.Skeleton.js +0 -3
- package/lib/components/FluidTimePicker/FluidTimePicker.js +1 -11
- package/lib/components/FluidTimePickerSelect/FluidTimePickerSelect.js +0 -6
- package/lib/components/Form/Form.d.ts +23 -0
- package/lib/components/Form/Form.js +3 -6
- package/lib/components/Form/index.d.ts +7 -0
- package/lib/components/FormGroup/FormGroup.js +0 -7
- package/lib/components/FormItem/FormItem.js +0 -2
- package/lib/components/FormLabel/FormLabel.js +1 -26
- package/lib/components/Grid/CSSGrid.js +2 -15
- package/lib/components/Grid/Column.js +18 -59
- package/lib/components/Grid/ColumnHang.js +2 -5
- package/lib/components/Grid/FlexGrid.js +2 -8
- package/lib/components/Grid/Grid.js +0 -8
- package/lib/components/Grid/GridContext.js +1 -3
- package/lib/components/Grid/Row.js +2 -7
- package/lib/components/Heading/index.js +0 -4
- package/lib/components/Icon/Icon.Skeleton.js +2 -2
- package/lib/components/IconButton/index.js +0 -10
- package/lib/components/IdPrefix/index.js +0 -2
- package/lib/components/InlineCheckbox/InlineCheckbox.js +0 -14
- package/lib/components/InlineLoading/InlineLoading.js +0 -12
- package/lib/components/Layer/index.js +3 -6
- package/lib/components/Layout/LayoutDirection.js +0 -3
- package/lib/components/Layout/useLayoutDirection.js +0 -1
- package/lib/components/Link/Link.js +3 -10
- package/lib/components/ListBox/ListBox.js +2 -13
- package/lib/components/ListBox/ListBoxField.js +0 -5
- package/lib/components/ListBox/ListBoxMenuIcon.js +0 -4
- package/lib/components/ListBox/ListBoxMenuItem.js +2 -6
- package/lib/components/ListBox/ListBoxPropTypes.d.ts +2 -2
- package/lib/components/ListBox/ListBoxSelection.js +1 -13
- package/lib/components/ListBox/next/ListBoxSelection.js +1 -14
- package/lib/components/ListBox/next/ListBoxTrigger.js +1 -3
- package/lib/components/ListItem/ListItem.d.ts +23 -0
- package/lib/components/ListItem/ListItem.js +4 -8
- package/lib/components/ListItem/index.d.ts +7 -0
- package/lib/components/Loading/Loading.js +0 -6
- package/lib/components/Menu/Menu.js +22 -40
- package/lib/components/Menu/MenuContext.js +4 -5
- package/lib/components/Menu/MenuItem.js +5 -39
- package/lib/components/MenuButton/index.js +0 -9
- package/lib/components/Modal/Modal.js +0 -43
- package/lib/components/ModalWrapper/ModalWrapper.js +2 -15
- package/lib/components/MultiSelect/FilterableMultiSelect.js +8 -66
- package/lib/components/MultiSelect/MultiSelect.js +30 -78
- package/lib/components/MultiSelect/MultiSelectPropTypes.js +0 -1
- package/lib/components/MultiSelect/index.js +0 -1
- package/lib/components/MultiSelect/tools/itemToString.js +0 -2
- package/lib/components/MultiSelect/tools/sorting.js +3 -4
- package/lib/components/Notification/Notification.js +0 -78
- package/lib/components/NumberInput/NumberInput.Skeleton.js +0 -2
- package/lib/components/NumberInput/NumberInput.js +3 -60
- package/lib/components/OrderedList/OrderedList.d.ts +39 -0
- package/lib/components/OrderedList/OrderedList.js +7 -19
- package/lib/components/OrderedList/index.d.ts +7 -0
- package/lib/components/OverflowMenu/OverflowMenu.js +65 -86
- package/lib/components/OverflowMenuItem/OverflowMenuItem.js +6 -23
- package/lib/components/OverflowMenuV2/index.js +0 -5
- package/lib/components/Pagination/Pagination.Skeleton.js +0 -2
- package/lib/components/Pagination/Pagination.js +11 -47
- package/lib/components/Pagination/experimental/PageSelector.js +0 -10
- package/lib/components/Pagination/experimental/Pagination.js +2 -67
- package/lib/components/PaginationNav/PaginationNav.js +15 -78
- package/lib/components/Popover/index.d.ts +14 -8
- package/lib/components/Popover/index.js +44 -48
- package/lib/components/PrimaryButton/PrimaryButton.js +0 -1
- package/lib/components/ProgressBar/ProgressBar.js +0 -15
- package/lib/components/ProgressIndicator/ProgressIndicator.Skeleton.js +0 -4
- package/lib/components/ProgressIndicator/ProgressIndicator.js +2 -40
- package/lib/components/RadioButton/RadioButton.Skeleton.js +0 -1
- package/lib/components/RadioButton/RadioButton.js +0 -13
- package/lib/components/RadioButtonGroup/RadioButtonGroup.js +3 -23
- package/lib/components/RadioTile/RadioTile.js +0 -12
- package/lib/components/Search/Search.Skeleton.js +0 -2
- package/lib/components/Search/Search.js +1 -28
- package/lib/components/SecondaryButton/SecondaryButton.js +0 -1
- package/lib/components/Select/Select.Skeleton.js +0 -2
- package/lib/components/Select/Select.d.ts +1 -1
- package/lib/components/Select/Select.js +6 -33
- package/lib/components/SelectItem/SelectItem.js +0 -5
- package/lib/components/SelectItemGroup/SelectItemGroup.d.ts +0 -1
- package/lib/components/SelectItemGroup/SelectItemGroup.js +1 -26
- package/lib/components/SkeletonIcon/SkeletonIcon.js +0 -2
- package/lib/components/SkeletonPlaceholder/SkeletonPlaceholder.js +0 -1
- package/lib/components/SkeletonText/SkeletonText.js +0 -12
- package/lib/components/Slider/Slider.Skeleton.js +0 -2
- package/lib/components/Slider/Slider.d.ts +0 -1
- package/lib/components/Slider/Slider.js +112 -154
- package/lib/components/Stack/Stack.js +1 -8
- package/lib/components/StructuredList/StructuredList.Skeleton.js +0 -5
- package/lib/components/StructuredList/StructuredList.js +1 -25
- package/lib/components/Switch/IconSwitch.js +0 -18
- package/lib/components/Switch/Switch.js +0 -11
- package/lib/components/TabContent/TabContent.js +2 -6
- package/lib/components/Tabs/Tabs.Skeleton.js +0 -4
- package/lib/components/Tabs/Tabs.js +133 -102
- package/lib/components/Tabs/usePressable.js +18 -31
- package/lib/components/Tag/Tag.Skeleton.js +0 -2
- package/lib/components/Tag/Tag.js +0 -15
- package/lib/components/Text/Text.js +5 -18
- package/lib/components/Text/TextDirection.js +0 -3
- package/lib/components/Text/TextDirectionContext.js +0 -1
- package/lib/components/Text/createTextComponent.js +0 -3
- package/lib/components/TextArea/TextArea.Skeleton.js +0 -2
- package/lib/components/TextArea/TextArea.js +10 -32
- package/lib/components/TextInput/ControlledPasswordInput.js +0 -20
- package/lib/components/TextInput/PasswordInput.js +0 -25
- package/lib/components/TextInput/TextInput.Skeleton.js +0 -2
- package/lib/components/TextInput/TextInput.d.ts +1 -1
- package/lib/components/TextInput/TextInput.js +5 -52
- package/lib/components/TextInput/util.js +3 -5
- package/lib/components/Theme/index.js +1 -6
- package/lib/components/Tile/Tile.js +31 -58
- package/lib/components/TileGroup/TileGroup.js +1 -22
- package/lib/components/TimePicker/TimePicker.js +6 -32
- package/lib/components/TimePickerSelect/TimePickerSelect.js +2 -5
- package/lib/components/Toggle/Toggle.Skeleton.js +0 -8
- package/lib/components/Toggle/Toggle.js +0 -16
- package/lib/components/ToggleSmall/ToggleSmall.Skeleton.js +0 -7
- package/lib/components/Toggletip/index.d.ts +148 -0
- package/lib/components/Toggletip/index.js +20 -44
- package/lib/components/Tooltip/DefinitionTooltip.js +0 -11
- package/lib/components/Tooltip/Tooltip.d.ts +1 -1
- package/lib/components/Tooltip/Tooltip.js +4 -21
- package/lib/components/TreeView/TreeNode.js +21 -66
- package/lib/components/TreeView/TreeView.js +11 -67
- package/lib/components/UIShell/Content.js +2 -4
- package/lib/components/UIShell/Header.js +0 -2
- package/lib/components/UIShell/HeaderContainer.d.ts +33 -0
- package/lib/components/UIShell/HeaderContainer.js +13 -11
- package/lib/components/UIShell/HeaderGlobalAction.js +0 -6
- package/lib/components/UIShell/HeaderGlobalBar.js +0 -1
- package/lib/components/UIShell/HeaderMenu.js +32 -31
- package/lib/components/UIShell/HeaderMenuButton.js +2 -4
- package/lib/components/UIShell/HeaderMenuItem.js +0 -8
- package/lib/components/UIShell/HeaderName.js +0 -5
- package/lib/components/UIShell/HeaderNavigation.js +0 -2
- package/lib/components/UIShell/HeaderPanel.js +0 -2
- package/lib/components/UIShell/HeaderSideNavItems.js +0 -2
- package/lib/components/UIShell/Link.js +2 -3
- package/lib/components/UIShell/SideNav.d.ts +3 -1
- package/lib/components/UIShell/SideNav.js +43 -35
- package/lib/components/UIShell/SideNavDetails.js +0 -3
- package/lib/components/UIShell/SideNavDivider.js +0 -1
- package/lib/components/UIShell/SideNavFooter.js +1 -4
- package/lib/components/UIShell/SideNavHeader.js +0 -4
- package/lib/components/UIShell/SideNavIcon.js +0 -3
- package/lib/components/UIShell/SideNavItem.js +0 -3
- package/lib/components/UIShell/SideNavItems.js +2 -6
- package/lib/components/UIShell/SideNavLink.js +3 -7
- package/lib/components/UIShell/SideNavLinkText.js +0 -2
- package/lib/components/UIShell/SideNavMenu.js +0 -16
- package/lib/components/UIShell/SideNavMenuItem.js +0 -2
- package/lib/components/UIShell/SideNavSwitcher.js +2 -5
- package/lib/components/UIShell/SkipToContent.d.ts +32 -0
- package/lib/components/UIShell/SkipToContent.js +8 -15
- package/lib/components/UIShell/Switcher.js +0 -2
- package/lib/components/UIShell/SwitcherDivider.js +0 -1
- package/lib/components/UIShell/SwitcherItem.js +0 -3
- package/lib/components/UnorderedList/UnorderedList.d.ts +34 -0
- package/lib/components/UnorderedList/UnorderedList.js +6 -16
- package/lib/components/UnorderedList/index.d.ts +7 -0
- package/lib/index.js +42 -43
- package/lib/internal/ClickListener.js +3 -13
- package/lib/internal/FloatingMenu.js +57 -63
- package/lib/internal/OptimizedResize.js +6 -12
- package/lib/internal/Selection.js +2 -25
- package/lib/internal/createClassWrapper.js +0 -2
- package/lib/internal/deprecateFieldOnObject.js +0 -4
- package/lib/internal/focus/index.js +0 -1
- package/lib/internal/keyboard/keys.js +2 -1
- package/lib/internal/keyboard/match.js +1 -6
- package/lib/internal/keyboard/navigation.js +8 -7
- package/lib/internal/useAnnouncer.js +0 -1
- package/lib/internal/useAttachedMenu.js +1 -9
- package/lib/internal/useControllableState.js +6 -13
- package/lib/internal/useDelayedState.js +2 -4
- package/lib/internal/useEffectOnce.js +0 -1
- package/lib/internal/useEvent.js +61 -2
- package/lib/internal/useId.js +2 -5
- package/lib/internal/useIsomorphicEffect.js +1 -0
- package/lib/internal/useMergedRefs.js +2 -2
- package/lib/internal/useNoInteractiveChildren.js +2 -13
- package/lib/internal/useNormalizedInputProps.js +0 -3
- package/lib/internal/useSavedCallback.js +0 -1
- package/lib/internal/warning.js +0 -3
- package/lib/internal/wrapFocus.js +1 -8
- package/lib/prop-types/deprecate.js +2 -5
- package/lib/prop-types/isRequiredOneOf.js +2 -5
- package/lib/prop-types/requiredIfGivenPropIsTruthy.js +0 -2
- package/lib/tools/array.js +0 -3
- package/lib/tools/events.js +0 -3
- package/lib/tools/mergeRefs.js +0 -2
- package/lib/tools/wrapComponent.js +2 -5
- package/package.json +9 -9
- package/es/components/Tab/Tab.js +0 -185
- package/es/components/Tab/index.js +0 -14
- package/es/components/TimePickerSelect/index.js +0 -13
- package/lib/components/Form/index.js +0 -17
- package/lib/components/Tab/Tab.js +0 -214
- package/lib/components/Tab/index.js +0 -39
- package/lib/components/TimePickerSelect/index.js +0 -38
|
@@ -10,7 +10,6 @@ import React__default, { PureComponent } from 'react';
|
|
|
10
10
|
import PropTypes from 'prop-types';
|
|
11
11
|
import cx from 'classnames';
|
|
12
12
|
import throttle from 'lodash.throttle';
|
|
13
|
-
import * as FeatureFlags from '@carbon/feature-flags';
|
|
14
13
|
import { ArrowDown, ArrowLeft, ArrowUp, ArrowRight } from '../../internal/keyboard/keys.js';
|
|
15
14
|
import { matches } from '../../internal/keyboard/match.js';
|
|
16
15
|
import { PrefixContext } from '../../internal/usePrefix.js';
|
|
@@ -21,100 +20,83 @@ import { WarningFilled, WarningAltFilled } from '@carbon/icons-react';
|
|
|
21
20
|
const defaultFormatLabel = (value, label) => {
|
|
22
21
|
return typeof label === 'function' ? label(value) : `${value}${label}`;
|
|
23
22
|
};
|
|
23
|
+
|
|
24
24
|
/**
|
|
25
25
|
* Minimum time between processed "drag" events.
|
|
26
26
|
*/
|
|
27
|
-
|
|
28
|
-
|
|
29
27
|
const EVENT_THROTTLE = 16; // ms
|
|
30
28
|
|
|
31
29
|
/**
|
|
32
30
|
* Event types that trigger "drags".
|
|
33
31
|
*/
|
|
34
|
-
|
|
35
32
|
const DRAG_EVENT_TYPES = new Set(['mousemove', 'touchmove']);
|
|
33
|
+
|
|
36
34
|
/**
|
|
37
35
|
* Event types that trigger a "drag" to stop.
|
|
38
36
|
*/
|
|
39
|
-
|
|
40
37
|
const DRAG_STOP_EVENT_TYPES = new Set(['mouseup', 'touchend', 'touchcancel']);
|
|
41
38
|
class Slider extends PureComponent {
|
|
42
39
|
constructor(props) {
|
|
43
40
|
super(props);
|
|
44
|
-
|
|
45
41
|
_defineProperty(this, "state", {
|
|
46
42
|
value: this.props.value,
|
|
47
43
|
left: 0,
|
|
48
44
|
needsOnRelease: false,
|
|
49
45
|
isValid: true
|
|
50
46
|
});
|
|
51
|
-
|
|
52
47
|
_defineProperty(this, "thumbRef", void 0);
|
|
53
|
-
|
|
54
48
|
_defineProperty(this, "filledTrackRef", void 0);
|
|
55
|
-
|
|
56
49
|
_defineProperty(this, "element", null);
|
|
57
|
-
|
|
58
50
|
_defineProperty(this, "inputId", '');
|
|
59
|
-
|
|
60
51
|
_defineProperty(this, "track", void 0);
|
|
61
|
-
|
|
62
52
|
_defineProperty(this, "onDragStart", evt => {
|
|
63
53
|
// Do nothing if component is disabled
|
|
64
54
|
if (this.props.disabled || this.props.readOnly) {
|
|
65
55
|
return;
|
|
66
|
-
}
|
|
67
|
-
|
|
56
|
+
}
|
|
68
57
|
|
|
58
|
+
// Register drag stop handlers
|
|
69
59
|
DRAG_STOP_EVENT_TYPES.forEach(element => {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
(_this$element = this.element) === null || _this$element === void 0 ? void 0 : _this$element.ownerDocument.addEventListener(element, this.onDragStop);
|
|
73
|
-
}); // Register drag handlers
|
|
60
|
+
this.element?.ownerDocument.addEventListener(element, this.onDragStop);
|
|
61
|
+
});
|
|
74
62
|
|
|
63
|
+
// Register drag handlers
|
|
75
64
|
DRAG_EVENT_TYPES.forEach(element => {
|
|
76
|
-
|
|
65
|
+
this.element?.ownerDocument.addEventListener(element, this.onDrag);
|
|
66
|
+
});
|
|
77
67
|
|
|
78
|
-
|
|
79
|
-
}); // Perform first recalculation since we probably didn't click exactly in the
|
|
68
|
+
// Perform first recalculation since we probably didn't click exactly in the
|
|
80
69
|
// middle of the thumb
|
|
81
|
-
|
|
82
70
|
this.onDrag(evt);
|
|
83
71
|
});
|
|
84
|
-
|
|
85
72
|
_defineProperty(this, "onDragStop", () => {
|
|
86
73
|
// Do nothing if component is disabled
|
|
87
74
|
if (this.props.disabled || this.props.readOnly) {
|
|
88
75
|
return;
|
|
89
|
-
}
|
|
90
|
-
|
|
76
|
+
}
|
|
91
77
|
|
|
78
|
+
// Remove drag stop handlers
|
|
92
79
|
DRAG_STOP_EVENT_TYPES.forEach(element => {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
(_this$element3 = this.element) === null || _this$element3 === void 0 ? void 0 : _this$element3.ownerDocument.removeEventListener(element, this.onDragStop);
|
|
96
|
-
}); // Remove drag handlers
|
|
80
|
+
this.element?.ownerDocument.removeEventListener(element, this.onDragStop);
|
|
81
|
+
});
|
|
97
82
|
|
|
83
|
+
// Remove drag handlers
|
|
98
84
|
DRAG_EVENT_TYPES.forEach(element => {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
(_this$element4 = this.element) === null || _this$element4 === void 0 ? void 0 : _this$element4.ownerDocument.removeEventListener(element, this.onDrag);
|
|
102
|
-
}); // Set needsOnRelease flag so event fires on next update
|
|
85
|
+
this.element?.ownerDocument.removeEventListener(element, this.onDrag);
|
|
86
|
+
});
|
|
103
87
|
|
|
88
|
+
// Set needsOnRelease flag so event fires on next update
|
|
104
89
|
this.setState({
|
|
105
90
|
needsOnRelease: true,
|
|
106
91
|
isValid: true
|
|
107
92
|
});
|
|
108
93
|
});
|
|
109
|
-
|
|
110
94
|
_defineProperty(this, "_onDrag", evt => {
|
|
111
95
|
// Do nothing if component is disabled or we have no event
|
|
112
96
|
if (this.props.disabled || this.props.readOnly || !evt) {
|
|
113
97
|
return;
|
|
114
98
|
}
|
|
115
|
-
|
|
116
99
|
let clientX;
|
|
117
|
-
|
|
118
100
|
if ('clientX' in evt) {
|
|
119
101
|
clientX = evt.clientX;
|
|
120
102
|
} else if ('touches' in evt && 0 in evt.touches && 'clientX' in evt.touches[0]) {
|
|
@@ -123,7 +105,6 @@ class Slider extends PureComponent {
|
|
|
123
105
|
// Do nothing if we have no valid clientX
|
|
124
106
|
return;
|
|
125
107
|
}
|
|
126
|
-
|
|
127
108
|
const {
|
|
128
109
|
value,
|
|
129
110
|
left
|
|
@@ -136,20 +117,16 @@ class Slider extends PureComponent {
|
|
|
136
117
|
isValid: true
|
|
137
118
|
});
|
|
138
119
|
});
|
|
139
|
-
|
|
140
120
|
_defineProperty(this, "onDrag", throttle(this._onDrag, EVENT_THROTTLE, {
|
|
141
121
|
leading: true,
|
|
142
122
|
trailing: false
|
|
143
123
|
}));
|
|
144
|
-
|
|
145
124
|
_defineProperty(this, "onKeyDown", evt => {
|
|
146
125
|
// Do nothing if component is disabled or we don't have a valid event
|
|
147
126
|
if (this.props.disabled || this.props.readOnly || !('which' in evt)) {
|
|
148
127
|
return;
|
|
149
128
|
}
|
|
150
|
-
|
|
151
129
|
let delta = 0;
|
|
152
|
-
|
|
153
130
|
if (matches(evt.which, [ArrowDown, ArrowLeft])) {
|
|
154
131
|
delta = -(this.props.step ?? Slider.defaultProps.step);
|
|
155
132
|
} else if (matches(evt.which, [ArrowUp, ArrowRight])) {
|
|
@@ -157,14 +134,13 @@ class Slider extends PureComponent {
|
|
|
157
134
|
} else {
|
|
158
135
|
// Ignore keys we don't want to handle
|
|
159
136
|
return;
|
|
160
|
-
}
|
|
161
|
-
|
|
137
|
+
}
|
|
162
138
|
|
|
139
|
+
// If shift was held, account for the stepMultiplier
|
|
163
140
|
if (evt.shiftKey) {
|
|
164
141
|
const stepMultiplier = this.props.stepMultiplier;
|
|
165
142
|
delta *= stepMultiplier ?? Slider.defaultProps.stepMultiplier;
|
|
166
143
|
}
|
|
167
|
-
|
|
168
144
|
Math.floor(this.state.value / (this.props.step ?? Slider.defaultProps.step)) * (this.props.step ?? Slider.defaultProps.step);
|
|
169
145
|
const {
|
|
170
146
|
value,
|
|
@@ -180,20 +156,19 @@ class Slider extends PureComponent {
|
|
|
180
156
|
isValid: true
|
|
181
157
|
});
|
|
182
158
|
});
|
|
183
|
-
|
|
184
159
|
_defineProperty(this, "onChange", evt => {
|
|
185
160
|
// Do nothing if component is disabled
|
|
186
161
|
if (this.props.disabled || this.props.readOnly) {
|
|
187
162
|
return;
|
|
188
|
-
}
|
|
189
|
-
|
|
163
|
+
}
|
|
190
164
|
|
|
165
|
+
// Do nothing if we have no valid event, target, or value
|
|
191
166
|
if (!evt || !('target' in evt) || typeof evt.target.value !== 'string') {
|
|
192
167
|
return;
|
|
193
168
|
}
|
|
169
|
+
const targetValue = Number.parseFloat(evt.target.value);
|
|
194
170
|
|
|
195
|
-
|
|
196
|
-
|
|
171
|
+
// Avoid calling calcValue for invalid numbers, but still update the state
|
|
197
172
|
if (isNaN(targetValue)) {
|
|
198
173
|
this.setState({
|
|
199
174
|
value: evt.target.value
|
|
@@ -212,16 +187,13 @@ class Slider extends PureComponent {
|
|
|
212
187
|
});
|
|
213
188
|
}
|
|
214
189
|
});
|
|
215
|
-
|
|
216
190
|
_defineProperty(this, "onBlur", evt => {
|
|
217
|
-
var _this$props$onBlur, _this$props;
|
|
218
|
-
|
|
219
191
|
// Do nothing if we have no valid event, target, or value
|
|
220
192
|
if (!evt || !('target' in evt) || typeof evt.target.value !== 'string') {
|
|
221
193
|
return;
|
|
222
|
-
}
|
|
223
|
-
|
|
194
|
+
}
|
|
224
195
|
|
|
196
|
+
// determine validity of input change after clicking out of input
|
|
225
197
|
const validity = evt.target.checkValidity();
|
|
226
198
|
const {
|
|
227
199
|
value
|
|
@@ -229,44 +201,39 @@ class Slider extends PureComponent {
|
|
|
229
201
|
this.setState({
|
|
230
202
|
isValid: validity
|
|
231
203
|
});
|
|
232
|
-
|
|
204
|
+
this.props.onBlur?.({
|
|
233
205
|
value
|
|
234
206
|
});
|
|
235
207
|
});
|
|
236
|
-
|
|
237
208
|
_defineProperty(this, "calcValue", _ref => {
|
|
238
|
-
var _this$element5, _this$element5$getBou;
|
|
239
|
-
|
|
240
209
|
let {
|
|
241
210
|
clientX,
|
|
242
211
|
value,
|
|
243
212
|
useRawValue = false
|
|
244
213
|
} = _ref;
|
|
245
214
|
const range = this.props.max - this.props.min;
|
|
246
|
-
const boundingRect =
|
|
215
|
+
const boundingRect = this.element?.getBoundingClientRect?.();
|
|
247
216
|
const totalSteps = range / (this.props.step ?? Slider.defaultProps.step);
|
|
248
|
-
let width = boundingRect ? boundingRect.right - boundingRect.left : 0;
|
|
217
|
+
let width = boundingRect ? boundingRect.right - boundingRect.left : 0;
|
|
249
218
|
|
|
219
|
+
// Enforce a minimum width of at least 1 for calculations
|
|
250
220
|
if (width <= 0) {
|
|
251
221
|
width = 1;
|
|
252
|
-
}
|
|
253
|
-
// use the provided value or state's value to calculate it instead.
|
|
254
|
-
|
|
222
|
+
}
|
|
255
223
|
|
|
224
|
+
// If a clientX is specified, use it to calculate the leftPercent. If not,
|
|
225
|
+
// use the provided value or state's value to calculate it instead.
|
|
256
226
|
let leftPercent;
|
|
257
|
-
|
|
258
227
|
if (clientX != null) {
|
|
259
|
-
const leftOffset = clientX - (
|
|
228
|
+
const leftOffset = clientX - (boundingRect?.left ?? 0);
|
|
260
229
|
leftPercent = leftOffset / width;
|
|
261
230
|
} else {
|
|
262
231
|
if (value == null) {
|
|
263
232
|
value = this.state.value;
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
|
|
233
|
+
}
|
|
234
|
+
// prevent NaN calculation if the range is 0
|
|
267
235
|
leftPercent = range === 0 ? 0 : (value - this.props.min) / range;
|
|
268
236
|
}
|
|
269
|
-
|
|
270
237
|
if (useRawValue) {
|
|
271
238
|
// Adjusts only for min/max of thumb position
|
|
272
239
|
return {
|
|
@@ -274,7 +241,6 @@ class Slider extends PureComponent {
|
|
|
274
241
|
left: Math.min(1, Math.max(0, leftPercent)) * 100
|
|
275
242
|
};
|
|
276
243
|
}
|
|
277
|
-
|
|
278
244
|
let steppedValue = Math.round(leftPercent * totalSteps) * (this.props.step ?? Slider.defaultProps.step);
|
|
279
245
|
const steppedPercent = this.clamp(steppedValue / range, 0, 1);
|
|
280
246
|
steppedValue = this.clamp(steppedValue + this.props.min, this.props.min, this.props.max);
|
|
@@ -283,15 +249,13 @@ class Slider extends PureComponent {
|
|
|
283
249
|
left: steppedPercent * 100
|
|
284
250
|
};
|
|
285
251
|
});
|
|
286
|
-
|
|
287
252
|
this.thumbRef = /*#__PURE__*/React__default.createRef();
|
|
288
253
|
this.filledTrackRef = /*#__PURE__*/React__default.createRef();
|
|
289
254
|
}
|
|
255
|
+
|
|
290
256
|
/**
|
|
291
257
|
* Sets up initial slider position and value in response to component mount.
|
|
292
258
|
*/
|
|
293
|
-
|
|
294
|
-
|
|
295
259
|
componentDidMount() {
|
|
296
260
|
if (this.element) {
|
|
297
261
|
const {
|
|
@@ -306,6 +270,7 @@ class Slider extends PureComponent {
|
|
|
306
270
|
});
|
|
307
271
|
}
|
|
308
272
|
}
|
|
273
|
+
|
|
309
274
|
/**
|
|
310
275
|
* Handles firing of `onChange` and `onRelease` callbacks to parent in
|
|
311
276
|
* response to state changes.
|
|
@@ -314,47 +279,44 @@ class Slider extends PureComponent {
|
|
|
314
279
|
* @param {*} prevState The previous Slider state, used to see if callbacks
|
|
315
280
|
* should be called.
|
|
316
281
|
*/
|
|
317
|
-
|
|
318
|
-
|
|
319
282
|
componentDidUpdate(prevProps, prevState) {
|
|
320
283
|
// Fire onChange event handler if present, if there's a usable value, and
|
|
321
284
|
// if the value is different from the last one
|
|
285
|
+
|
|
322
286
|
if (this.thumbRef.current) {
|
|
323
287
|
this.thumbRef.current.style.left = `${this.state.left}%`;
|
|
324
288
|
}
|
|
325
|
-
|
|
326
289
|
if (this.filledTrackRef.current) {
|
|
327
290
|
this.filledTrackRef.current.style.transform = `translate(0%, -50%) scaleX(${this.state.left / 100})`;
|
|
328
291
|
}
|
|
329
|
-
|
|
330
292
|
if (prevState.value !== this.state.value && typeof this.props.onChange === 'function') {
|
|
331
293
|
this.props.onChange({
|
|
332
294
|
value: this.state.value
|
|
333
295
|
});
|
|
334
|
-
}
|
|
335
|
-
|
|
296
|
+
}
|
|
336
297
|
|
|
298
|
+
// Fire onRelease event handler if present and if needed
|
|
337
299
|
if (this.state.needsOnRelease && typeof this.props.onRelease === 'function') {
|
|
338
300
|
this.props.onRelease({
|
|
339
301
|
value: this.state.value
|
|
340
|
-
});
|
|
341
|
-
|
|
302
|
+
});
|
|
303
|
+
// Reset the flag
|
|
342
304
|
this.setState({
|
|
343
305
|
needsOnRelease: false
|
|
344
306
|
});
|
|
345
|
-
}
|
|
346
|
-
// Otherwise, do prop -> state sync without "value capping".
|
|
347
|
-
|
|
307
|
+
}
|
|
348
308
|
|
|
309
|
+
// If value from props does not change, do nothing here.
|
|
310
|
+
// Otherwise, do prop -> state sync without "value capping".
|
|
349
311
|
if (prevProps.value === this.props.value && prevProps.max === this.props.max && prevProps.min === this.props.min) {
|
|
350
312
|
return;
|
|
351
313
|
}
|
|
352
|
-
|
|
353
314
|
this.setState(this.calcValue({
|
|
354
315
|
value: this.props.value,
|
|
355
316
|
useRawValue: true
|
|
356
317
|
}));
|
|
357
318
|
}
|
|
319
|
+
|
|
358
320
|
/**
|
|
359
321
|
* Synonymous to ECMA2017+ `Math.clamp`.
|
|
360
322
|
*
|
|
@@ -364,11 +326,10 @@ class Slider extends PureComponent {
|
|
|
364
326
|
*
|
|
365
327
|
* @returns `val` if `max>=val>=min`; `min` if `val<min`; `max` if `val>max`.
|
|
366
328
|
*/
|
|
367
|
-
|
|
368
|
-
|
|
369
329
|
clamp(val, min, max) {
|
|
370
330
|
return Math.max(min, Math.min(val, max));
|
|
371
331
|
}
|
|
332
|
+
|
|
372
333
|
/**
|
|
373
334
|
* Sets up "drag" event handlers and calls `this.onDrag` in case dragging
|
|
374
335
|
* started on somewhere other than the thumb without a corresponding "move"
|
|
@@ -377,29 +338,84 @@ class Slider extends PureComponent {
|
|
|
377
338
|
* @param {Event} evt The event.
|
|
378
339
|
*/
|
|
379
340
|
|
|
341
|
+
/**
|
|
342
|
+
* Unregisters "drag" and "drag stop" event handlers and calls sets the flag
|
|
343
|
+
* indicating that the `onRelease` callback should be called.
|
|
344
|
+
*/
|
|
345
|
+
|
|
346
|
+
/**
|
|
347
|
+
* Handles a "drag" event by recalculating the value/thumb and setting state
|
|
348
|
+
* accordingly.
|
|
349
|
+
*
|
|
350
|
+
* @param {Event} evt The event.
|
|
351
|
+
*/
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* Throttles calls to `this._onDrag` by limiting events to being processed at
|
|
355
|
+
* most once every `EVENT_THROTTLE` milliseconds.
|
|
356
|
+
*/
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* Handles a `keydown` event by recalculating the value/thumb and setting
|
|
360
|
+
* state accordingly.
|
|
361
|
+
*
|
|
362
|
+
* @param {Event} evt The event.
|
|
363
|
+
*/
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* Provides the two-way binding for the input field of the Slider. It also
|
|
367
|
+
* Handles a change to the input field by recalculating the value/thumb and
|
|
368
|
+
* setting state accordingly.
|
|
369
|
+
*
|
|
370
|
+
* @param {Event} evt The event.
|
|
371
|
+
*/
|
|
372
|
+
|
|
373
|
+
/**
|
|
374
|
+
* Checks for validity of input value after clicking out of the input. It also
|
|
375
|
+
* Handles state change to isValid state.
|
|
376
|
+
*
|
|
377
|
+
* @param {Event} evt The event.
|
|
378
|
+
*/
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* Calculates a new Slider `value` and `left` (thumb offset) given a `clientX`,
|
|
382
|
+
* `value`, or neither of those.
|
|
383
|
+
* - If `clientX` is specified, it will be used in
|
|
384
|
+
* conjunction with the Slider's bounding rectangle to calculate the new
|
|
385
|
+
* values.
|
|
386
|
+
* - If `clientX` is not specified and `value` is, it will be used to
|
|
387
|
+
* calculate new values as though it were the current value of the Slider.
|
|
388
|
+
* - If neither `clientX` nor `value` are specified, `this.props.value` will
|
|
389
|
+
* be used to calculate the new values as though it were the current value
|
|
390
|
+
* of the Slider.
|
|
391
|
+
*
|
|
392
|
+
* @param {object} params
|
|
393
|
+
* @param {number} [params.clientX] Optional clientX value expected to be from
|
|
394
|
+
* an event fired by one of the Slider's `DRAG_EVENT_TYPES` events.
|
|
395
|
+
* @param {number} [params.value] Optional value use during calculations if
|
|
396
|
+
* clientX is not provided.
|
|
397
|
+
* @param {boolean} [params.useRawValue=false] `true` to use the given value as-is.
|
|
398
|
+
*/
|
|
380
399
|
|
|
381
400
|
// syncs invalid state and prop
|
|
382
401
|
static getDerivedStateFromProps(props, state) {
|
|
383
402
|
const {
|
|
384
403
|
isValid
|
|
385
|
-
} = state;
|
|
386
|
-
|
|
404
|
+
} = state;
|
|
405
|
+
// will override state in favor of invalid prop
|
|
387
406
|
if (props.invalid === true && isValid === true) {
|
|
388
407
|
return {
|
|
389
408
|
isValid: false
|
|
390
409
|
};
|
|
391
410
|
}
|
|
392
|
-
|
|
393
411
|
if (props.invalid === false && isValid === false) {
|
|
394
412
|
return {
|
|
395
413
|
isValid: true
|
|
396
414
|
};
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
|
|
415
|
+
}
|
|
416
|
+
//if invalid prop is not provided, state will remain the same
|
|
400
417
|
return null;
|
|
401
418
|
}
|
|
402
|
-
|
|
403
419
|
render() {
|
|
404
420
|
const {
|
|
405
421
|
ariaLabelInput,
|
|
@@ -431,13 +447,6 @@ class Slider extends PureComponent {
|
|
|
431
447
|
value,
|
|
432
448
|
isValid
|
|
433
449
|
} = this.state;
|
|
434
|
-
const scope = this.context;
|
|
435
|
-
let enabled;
|
|
436
|
-
|
|
437
|
-
if (scope.enabled) {
|
|
438
|
-
enabled = scope.enabled('enable-v11-release');
|
|
439
|
-
}
|
|
440
|
-
|
|
441
450
|
return /*#__PURE__*/React__default.createElement(PrefixContext.Consumer, null, prefix => {
|
|
442
451
|
const labelId = `${id}-label`;
|
|
443
452
|
const labelClasses = cx(`${prefix}--label`, {
|
|
@@ -447,7 +456,7 @@ class Slider extends PureComponent {
|
|
|
447
456
|
[`${prefix}--slider--disabled`]: disabled
|
|
448
457
|
}, {
|
|
449
458
|
[`${prefix}--slider--readonly`]: readOnly
|
|
450
|
-
}
|
|
459
|
+
});
|
|
451
460
|
const inputClasses = cx(`${prefix}--text-input`, `${prefix}--slider-text-input`, {
|
|
452
461
|
[`${prefix}--text-input--light`]: light,
|
|
453
462
|
[`${prefix}--text-input--invalid`]: !readOnly && isValid === false,
|
|
@@ -455,7 +464,7 @@ class Slider extends PureComponent {
|
|
|
455
464
|
[`${prefix}--slider-text-input--warn`]: !readOnly && warn
|
|
456
465
|
});
|
|
457
466
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
458
|
-
className:
|
|
467
|
+
className: cx(`${prefix}--form-item`, className)
|
|
459
468
|
}, /*#__PURE__*/React__default.createElement("label", {
|
|
460
469
|
htmlFor: id,
|
|
461
470
|
className: labelClasses,
|
|
@@ -525,153 +534,123 @@ class Slider extends PureComponent {
|
|
|
525
534
|
}, warnText));
|
|
526
535
|
});
|
|
527
536
|
}
|
|
528
|
-
|
|
529
537
|
}
|
|
530
|
-
|
|
531
538
|
_defineProperty(Slider, "propTypes", {
|
|
532
539
|
/**
|
|
533
540
|
* The `ariaLabel` for the `<input>`.
|
|
534
541
|
*/
|
|
535
542
|
ariaLabelInput: PropTypes.string,
|
|
536
|
-
|
|
537
543
|
/**
|
|
538
544
|
* The child nodes.
|
|
539
545
|
*/
|
|
540
546
|
children: PropTypes.node,
|
|
541
|
-
|
|
542
547
|
/**
|
|
543
548
|
* The CSS class name for the slider.
|
|
544
549
|
*/
|
|
545
550
|
className: PropTypes.string,
|
|
546
|
-
|
|
547
551
|
/**
|
|
548
552
|
* `true` to disable this slider.
|
|
549
553
|
*/
|
|
550
554
|
disabled: PropTypes.bool,
|
|
551
|
-
|
|
552
555
|
/**
|
|
553
556
|
* The callback to format the label associated with the minimum/maximum value.
|
|
554
557
|
*/
|
|
555
558
|
formatLabel: PropTypes.func,
|
|
556
|
-
|
|
557
559
|
/**
|
|
558
560
|
* `true` to hide the number input box.
|
|
559
561
|
*/
|
|
560
562
|
hideTextInput: PropTypes.bool,
|
|
561
|
-
|
|
562
563
|
/**
|
|
563
564
|
* The ID of the `<input>`.
|
|
564
565
|
*/
|
|
565
566
|
id: PropTypes.string,
|
|
566
|
-
|
|
567
567
|
/**
|
|
568
568
|
* The `type` attribute of the `<input>`.
|
|
569
569
|
*/
|
|
570
570
|
inputType: PropTypes.string,
|
|
571
|
-
|
|
572
571
|
/**
|
|
573
572
|
* `Specify whether the Slider is currently invalid
|
|
574
573
|
*/
|
|
575
574
|
invalid: PropTypes.bool,
|
|
576
|
-
|
|
577
575
|
/**
|
|
578
576
|
* Provide the text that is displayed when the Slider is in an invalid state
|
|
579
577
|
*/
|
|
580
578
|
invalidText: PropTypes.node,
|
|
581
|
-
|
|
582
579
|
/**
|
|
583
580
|
* The label for the slider.
|
|
584
581
|
*/
|
|
585
582
|
labelText: PropTypes.node,
|
|
586
|
-
|
|
587
583
|
/**
|
|
588
584
|
* `true` to use the light version.
|
|
589
585
|
*/
|
|
590
586
|
light: deprecate(PropTypes.bool, 'The `light` prop for `Slider` 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.'),
|
|
591
|
-
|
|
592
587
|
/**
|
|
593
588
|
* The maximum value.
|
|
594
589
|
*/
|
|
595
590
|
max: PropTypes.number.isRequired,
|
|
596
|
-
|
|
597
591
|
/**
|
|
598
592
|
* The label associated with the maximum value.
|
|
599
593
|
*/
|
|
600
594
|
maxLabel: PropTypes.string,
|
|
601
|
-
|
|
602
595
|
/**
|
|
603
596
|
* The minimum value.
|
|
604
597
|
*/
|
|
605
598
|
min: PropTypes.number.isRequired,
|
|
606
|
-
|
|
607
599
|
/**
|
|
608
600
|
* The label associated with the minimum value.
|
|
609
601
|
*/
|
|
610
602
|
minLabel: PropTypes.string,
|
|
611
|
-
|
|
612
603
|
/**
|
|
613
604
|
* The `name` attribute of the `<input>`.
|
|
614
605
|
*/
|
|
615
606
|
name: PropTypes.string,
|
|
616
|
-
|
|
617
607
|
/**
|
|
618
608
|
* Provide an optional function to be called when the input element
|
|
619
609
|
* loses focus
|
|
620
610
|
*/
|
|
621
611
|
onBlur: PropTypes.func,
|
|
622
|
-
|
|
623
612
|
/**
|
|
624
613
|
* The callback to get notified of change in value.
|
|
625
614
|
*/
|
|
626
615
|
onChange: PropTypes.func,
|
|
627
|
-
|
|
628
616
|
/**
|
|
629
617
|
* Provide an optional function to be called when a key is pressed in the number input
|
|
630
618
|
*/
|
|
631
619
|
onInputKeyUp: PropTypes.func,
|
|
632
|
-
|
|
633
620
|
/**
|
|
634
621
|
* The callback to get notified of value on handle release.
|
|
635
622
|
*/
|
|
636
623
|
onRelease: PropTypes.func,
|
|
637
|
-
|
|
638
624
|
/**
|
|
639
625
|
* Whether the slider should be read-only
|
|
640
626
|
*/
|
|
641
627
|
readOnly: PropTypes.bool,
|
|
642
|
-
|
|
643
628
|
/**
|
|
644
629
|
* `true` to specify if the control is required.
|
|
645
630
|
*/
|
|
646
631
|
required: PropTypes.bool,
|
|
647
|
-
|
|
648
632
|
/**
|
|
649
633
|
* A value determining how much the value should increase/decrease by moving the thumb by mouse. If a value other than 1 is provided and the input is *not* hidden, the new step requirement should be added to a visible label. Values outside of the `step` increment will be considered invalid.
|
|
650
634
|
*/
|
|
651
635
|
step: PropTypes.number,
|
|
652
|
-
|
|
653
636
|
/**
|
|
654
637
|
* A value determining how much the value should increase/decrease by Shift+arrow keys,
|
|
655
638
|
* which will be `(max - min) / stepMultiplier`.
|
|
656
639
|
*/
|
|
657
640
|
stepMultiplier: PropTypes.number,
|
|
658
|
-
|
|
659
641
|
/**
|
|
660
642
|
* The value.
|
|
661
643
|
*/
|
|
662
644
|
value: PropTypes.number.isRequired,
|
|
663
|
-
|
|
664
645
|
/**
|
|
665
646
|
* `Specify whether the Slider is in a warn state
|
|
666
647
|
*/
|
|
667
648
|
warn: PropTypes.bool,
|
|
668
|
-
|
|
669
649
|
/**
|
|
670
650
|
* Provide the text that is displayed when the Slider is in an warn state
|
|
671
651
|
*/
|
|
672
652
|
warnText: PropTypes.node
|
|
673
653
|
});
|
|
674
|
-
|
|
675
654
|
_defineProperty(Slider, "defaultProps", {
|
|
676
655
|
hideTextInput: false,
|
|
677
656
|
step: 1,
|
|
@@ -680,10 +659,8 @@ _defineProperty(Slider, "defaultProps", {
|
|
|
680
659
|
minLabel: '',
|
|
681
660
|
maxLabel: '',
|
|
682
661
|
inputType: 'number',
|
|
683
|
-
ariaLabelInput: FeatureFlags.enabled('enable-v11-release') ? undefined : 'Slider number input',
|
|
684
662
|
readOnly: false
|
|
685
663
|
});
|
|
686
|
-
|
|
687
664
|
_defineProperty(Slider, "contextType", FeatureFlagContext);
|
|
688
665
|
|
|
689
666
|
export { Slider as default };
|