@carbon/react 1.27.0 → 1.28.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 +1 -313
- package/es/components/Accordion/Accordion.Skeleton.js +28 -30
- package/es/components/Accordion/Accordion.js +18 -21
- package/es/components/Accordion/AccordionItem.js +37 -49
- package/es/components/AspectRatio/AspectRatio.js +10 -12
- package/es/components/Breadcrumb/Breadcrumb.Skeleton.js +10 -11
- package/es/components/Breadcrumb/Breadcrumb.js +14 -13
- package/es/components/Breadcrumb/BreadcrumbItem.js +24 -22
- package/es/components/Button/Button.Skeleton.js +25 -23
- package/es/components/Button/Button.js +77 -72
- package/es/components/ButtonSet/ButtonSet.js +12 -10
- package/es/components/Checkbox/Checkbox.Skeleton.js +10 -11
- package/es/components/Checkbox/Checkbox.js +55 -52
- package/es/components/CheckboxGroup/CheckboxGroup.js +33 -31
- package/es/components/ClassPrefix/index.js +4 -2
- package/es/components/CodeSnippet/CodeSnippet.Skeleton.js +15 -14
- package/es/components/CodeSnippet/CodeSnippet.js +199 -102
- package/es/components/ComboBox/ComboBox.js +349 -178
- package/es/components/ComboBox/tools/filter.js +6 -4
- package/es/components/ComboButton/index.js +38 -43
- package/es/components/ComposedModal/ComposedModal.js +187 -85
- package/es/components/ComposedModal/ModalFooter.js +54 -49
- package/es/components/ComposedModal/ModalHeader.js +39 -26
- package/es/components/ContainedList/ContainedList.js +66 -20
- package/es/components/ContainedList/ContainedListItem/ContainedListItem.js +20 -18
- package/es/components/ContentSwitcher/ContentSwitcher.js +83 -98
- package/es/components/ContentSwitcher/index.js +1 -1
- package/es/components/ContextMenu/useContextMenu.js +12 -21
- package/es/components/Copy/Copy.js +24 -29
- package/es/components/CopyButton/CopyButton.js +10 -10
- package/es/components/DangerButton/DangerButton.js +3 -5
- package/es/components/DataTable/DataTable.js +333 -359
- package/es/components/DataTable/Table.js +29 -26
- package/es/components/DataTable/TableActionList.js +2 -4
- package/es/components/DataTable/TableBatchAction.js +2 -4
- package/es/components/DataTable/TableBatchActions.js +29 -30
- package/es/components/DataTable/TableBody.js +7 -8
- package/es/components/DataTable/TableCell.js +1 -1
- package/es/components/DataTable/TableContainer.js +23 -23
- package/es/components/DataTable/TableContext.js +1 -1
- package/es/components/DataTable/TableExpandHeader.js +19 -21
- package/es/components/DataTable/TableExpandRow.js +23 -23
- package/es/components/DataTable/TableExpandedRow.js +18 -23
- package/es/components/DataTable/TableHead.js +1 -1
- package/es/components/DataTable/TableHeader.js +45 -41
- package/es/components/DataTable/TableRow.js +7 -8
- package/es/components/DataTable/TableSelectAll.js +13 -11
- package/es/components/DataTable/TableSelectRow.js +29 -21
- package/es/components/DataTable/TableToolbar.js +19 -14
- package/es/components/DataTable/TableToolbarAction.js +6 -6
- package/es/components/DataTable/TableToolbarContent.js +2 -4
- package/es/components/DataTable/TableToolbarMenu.js +11 -12
- package/es/components/DataTable/TableToolbarSearch.js +52 -71
- package/es/components/DataTable/state/getDerivedStateFromProps.js +15 -15
- package/es/components/DataTable/state/sortStates.js +1 -1
- package/es/components/DataTable/state/sorting.js +28 -20
- package/es/components/DataTable/tools/cells.js +1 -3
- package/es/components/DataTable/tools/denormalize.js +4 -17
- package/es/components/DataTable/tools/filter.js +18 -16
- package/es/components/DataTable/tools/instanceId.js +2 -2
- package/es/components/DataTable/tools/normalize.js +28 -25
- package/es/components/DataTable/tools/sorting.js +28 -25
- package/es/components/DataTableSkeleton/DataTableSkeleton.js +36 -38
- package/es/components/DatePicker/DatePicker.Skeleton.d.ts +30 -0
- package/es/components/DatePicker/DatePicker.Skeleton.js +18 -20
- package/es/components/DatePicker/DatePicker.d.ts +131 -0
- package/es/components/DatePicker/DatePicker.js +215 -200
- package/es/components/DatePicker/index.d.ts +10 -0
- package/es/components/DatePicker/index.js +1 -0
- package/es/components/DatePicker/plugins/appendToPlugin.js +45 -43
- package/es/components/DatePicker/plugins/fixEventsPlugin.js +117 -107
- package/es/components/DatePicker/plugins/rangePlugin.js +19 -11
- package/es/components/DatePickerInput/DatePickerInput.d.ts +93 -0
- package/es/components/DatePickerInput/DatePickerInput.js +83 -74
- package/es/components/Dropdown/Dropdown.Skeleton.js +13 -12
- package/es/components/Dropdown/Dropdown.js +266 -109
- package/es/components/ErrorBoundary/ErrorBoundary.js +27 -48
- package/es/components/ErrorBoundary/ErrorBoundaryContext.js +3 -2
- package/es/components/ExpandableSearch/ExpandableSearch.d.ts +14 -0
- package/es/components/ExpandableSearch/ExpandableSearch.js +19 -25
- package/es/components/FeatureFlags/index.js +25 -43
- package/es/components/FileUploader/FileUploader.Skeleton.js +8 -9
- package/es/components/FileUploader/FileUploader.js +120 -147
- package/es/components/FileUploader/FileUploaderButton.js +36 -48
- package/es/components/FileUploader/FileUploaderDropContainer.js +49 -53
- package/es/components/FileUploader/FileUploaderItem.js +30 -30
- package/es/components/FileUploader/Filename.js +13 -14
- package/es/components/FluidComboBox/FluidComboBox.Skeleton.js +11 -12
- package/es/components/FluidComboBox/FluidComboBox.js +11 -9
- package/es/components/FluidDatePicker/FluidDatePicker.Skeleton.js +18 -18
- package/es/components/FluidDatePicker/FluidDatePicker.js +20 -16
- package/es/components/FluidDatePickerInput/FluidDatePickerInput.js +3 -3
- package/es/components/FluidDropdown/FluidDropdown.Skeleton.js +11 -12
- package/es/components/FluidDropdown/FluidDropdown.js +11 -9
- package/es/components/FluidForm/FluidForm.js +9 -10
- package/es/components/FluidForm/FormContext.js +1 -1
- package/es/components/FluidMultiSelect/FluidMultiSelect.Skeleton.js +11 -12
- package/es/components/FluidMultiSelect/FluidMultiSelect.js +12 -10
- package/es/components/FluidSelect/FluidSelect.Skeleton.js +11 -12
- package/es/components/FluidSelect/FluidSelect.js +9 -9
- package/es/components/FluidTextArea/FluidTextArea.Skeleton.js +9 -10
- package/es/components/FluidTextArea/FluidTextArea.js +7 -8
- package/es/components/FluidTextInput/FluidTextInput.Skeleton.js +9 -10
- package/es/components/FluidTextInput/FluidTextInput.js +10 -9
- package/es/components/FluidTimePicker/FluidTimePicker.Skeleton.js +11 -10
- package/es/components/FluidTimePicker/FluidTimePicker.js +30 -26
- package/es/components/FluidTimePickerSelect/FluidTimePickerSelect.js +7 -7
- package/es/components/Form/Form.js +9 -10
- package/es/components/FormGroup/FormGroup.js +16 -17
- package/es/components/FormItem/FormItem.js +8 -9
- package/es/components/FormLabel/FormLabel.js +11 -10
- package/es/components/Grid/CSSGrid.js +38 -39
- package/es/components/Grid/Column.js +86 -79
- package/es/components/Grid/ColumnHang.js +12 -14
- package/es/components/Grid/FlexGrid.js +19 -21
- package/es/components/Grid/Grid.js +2 -2
- package/es/components/Grid/GridContext.js +12 -11
- package/es/components/Grid/Row.js +16 -18
- package/es/components/Heading/index.js +11 -13
- package/es/components/Icon/Icon.Skeleton.js +10 -12
- package/es/components/IconButton/index.js +19 -22
- package/es/components/IdPrefix/index.js +4 -2
- package/es/components/InlineCheckbox/InlineCheckbox.js +89 -36
- package/es/components/InlineLoading/InlineLoading.js +23 -25
- package/es/components/Layer/LayerContext.js +1 -1
- package/es/components/Layer/index.js +17 -18
- package/es/components/Layout/LayoutDirection.js +8 -10
- package/es/components/Layout/LayoutDirectionContext.js +1 -1
- package/es/components/Link/Link.js +25 -25
- package/es/components/ListBox/ListBox.js +38 -31
- package/es/components/ListBox/ListBoxField.js +9 -10
- package/es/components/ListBox/ListBoxMenu.js +9 -10
- package/es/components/ListBox/ListBoxMenuIcon.js +16 -14
- package/es/components/ListBox/ListBoxMenuItem.js +23 -26
- package/es/components/ListBox/ListBoxPropTypes.js +4 -4
- package/es/components/ListBox/ListBoxSelection.js +30 -25
- package/es/components/ListBox/index.js +1 -1
- package/es/components/ListBox/next/ListBoxSelection.js +27 -24
- package/es/components/ListBox/next/ListBoxTrigger.js +20 -19
- package/es/components/ListItem/ListItem.js +9 -10
- package/es/components/Loading/Loading.js +24 -24
- package/es/components/Menu/Menu.js +67 -80
- package/es/components/Menu/MenuContext.js +9 -12
- package/es/components/Menu/MenuItem.js +104 -128
- package/es/components/MenuButton/index.js +37 -41
- package/es/components/Modal/Modal.js +281 -120
- package/es/components/ModalWrapper/ModalWrapper.js +72 -96
- package/es/components/MultiSelect/FilterableMultiSelect.js +299 -163
- package/es/components/MultiSelect/MultiSelect.js +162 -174
- package/es/components/MultiSelect/MultiSelectPropTypes.js +1 -1
- package/es/components/MultiSelect/tools/itemToString.js +3 -4
- package/es/components/MultiSelect/tools/sorting.js +15 -13
- package/es/components/Notification/Notification.js +436 -164
- package/es/components/NumberInput/NumberInput.Skeleton.js +10 -11
- package/es/components/NumberInput/NumberInput.js +140 -139
- package/es/components/OrderedList/OrderedList.js +17 -15
- package/es/components/OverflowMenu/OverflowMenu.js +360 -227
- package/es/components/OverflowMenu/index.js +1 -1
- package/es/components/OverflowMenuItem/OverflowMenuItem.js +32 -37
- package/es/components/OverflowMenuV2/index.js +26 -28
- package/es/components/Pagination/Pagination.Skeleton.js +9 -10
- package/es/components/Pagination/Pagination.js +98 -140
- package/es/components/Pagination/experimental/PageSelector.js +16 -16
- package/es/components/Pagination/experimental/Pagination.js +73 -94
- package/es/components/PaginationNav/PaginationNav.js +98 -117
- package/es/components/Popover/index.js +74 -80
- package/es/components/PrimaryButton/PrimaryButton.js +3 -5
- package/es/components/ProgressBar/ProgressBar.js +39 -37
- package/es/components/ProgressIndicator/ProgressIndicator.Skeleton.js +15 -14
- package/es/components/ProgressIndicator/ProgressIndicator.js +71 -71
- package/es/components/RadioButton/RadioButton.Skeleton.js +9 -10
- package/es/components/RadioButton/RadioButton.js +27 -27
- package/es/components/RadioButtonGroup/RadioButtonGroup.js +55 -65
- package/es/components/RadioTile/RadioTile.js +27 -25
- package/es/components/Search/Search.Skeleton.js +16 -16
- package/es/components/Search/Search.d.ts +83 -0
- package/es/components/Search/Search.js +65 -72
- package/es/components/Search/index.d.ts +11 -0
- package/es/components/SecondaryButton/SecondaryButton.js +3 -5
- package/es/components/Select/Select.Skeleton.js +12 -13
- package/es/components/Select/Select.js +79 -73
- package/es/components/SelectItem/SelectItem.js +17 -13
- package/es/components/SelectItemGroup/SelectItemGroup.js +11 -12
- package/es/components/SkeletonIcon/SkeletonIcon.js +11 -11
- package/es/components/SkeletonPlaceholder/SkeletonPlaceholder.js +11 -11
- package/es/components/SkeletonText/SkeletonText.js +29 -29
- package/es/components/Slider/Slider.Skeleton.js +17 -18
- package/es/components/Slider/Slider.js +306 -329
- package/es/components/Slider/index.js +1 -1
- package/es/components/Stack/Stack.js +19 -20
- package/es/components/Stack/index.js +2 -2
- package/es/components/StructuredList/StructuredList.Skeleton.js +25 -24
- package/es/components/StructuredList/StructuredList.js +134 -106
- package/es/components/Switch/IconSwitch.js +48 -54
- package/es/components/Switch/Switch.js +33 -31
- package/es/components/Tab/Tab.js +77 -83
- package/es/components/Tab/index.js +1 -1
- package/es/components/TabContent/TabContent.js +16 -18
- package/es/components/Tabs/Tabs.Skeleton.js +14 -13
- package/es/components/Tabs/Tabs.js +195 -206
- package/es/components/Tabs/usePressable.js +27 -36
- package/es/components/Tag/Tag.Skeleton.js +10 -9
- package/es/components/Tag/Tag.js +34 -31
- package/es/components/Text/Text.js +20 -20
- package/es/components/Text/TextDirection.js +8 -7
- package/es/components/Text/TextDirectionContext.js +1 -1
- package/es/components/Text/index.js +1 -1
- package/es/components/TextArea/TextArea.Skeleton.js +11 -12
- package/es/components/TextArea/TextArea.js +89 -83
- package/es/components/TextInput/ControlledPasswordInput.js +79 -73
- package/es/components/TextInput/PasswordInput.js +101 -91
- package/es/components/TextInput/TextInput.Skeleton.js +11 -12
- package/es/components/TextInput/TextInput.js +104 -92
- package/es/components/TextInput/util.js +26 -28
- package/es/components/Theme/index.js +25 -20
- package/es/components/Tile/Tile.js +135 -176
- package/es/components/TileGroup/TileGroup.js +55 -70
- package/es/components/TileGroup/index.js +1 -1
- package/es/components/TimePicker/TimePicker.js +60 -67
- package/es/components/TimePickerSelect/TimePickerSelect.js +20 -18
- package/es/components/TimePickerSelect/index.js +1 -1
- package/es/components/Toggle/Toggle.Skeleton.js +63 -52
- package/es/components/Toggle/Toggle.js +44 -48
- package/es/components/ToggleSmall/ToggleSmall.Skeleton.js +56 -50
- package/es/components/Toggletip/index.js +52 -48
- package/es/components/Tooltip/DefinitionTooltip.js +24 -31
- package/es/components/Tooltip/Tooltip.js +35 -50
- package/es/components/TreeView/TreeNode.js +94 -74
- package/es/components/TreeView/TreeView.js +72 -83
- package/es/components/UIShell/Content.js +12 -14
- package/es/components/UIShell/Header.js +16 -12
- package/es/components/UIShell/HeaderContainer.js +8 -14
- package/es/components/UIShell/HeaderGlobalAction.js +26 -19
- package/es/components/UIShell/HeaderGlobalBar.js +1 -3
- package/es/components/UIShell/HeaderMenu.js +114 -129
- package/es/components/UIShell/HeaderMenuButton.js +31 -22
- package/es/components/UIShell/HeaderMenuItem.js +28 -20
- package/es/components/UIShell/HeaderName.js +19 -14
- package/es/components/UIShell/HeaderNavigation.js +19 -15
- package/es/components/UIShell/HeaderPanel.js +23 -17
- package/es/components/UIShell/HeaderSideNavItems.js +11 -9
- package/es/components/UIShell/Link.js +11 -11
- package/es/components/UIShell/SideNav.js +66 -62
- package/es/components/UIShell/SideNavDetails.js +11 -12
- package/es/components/UIShell/SideNavDivider.js +5 -3
- package/es/components/UIShell/SideNavFooter.js +13 -12
- package/es/components/UIShell/SideNavHeader.js +9 -6
- package/es/components/UIShell/SideNavIcon.js +11 -8
- package/es/components/UIShell/SideNavItem.js +11 -9
- package/es/components/UIShell/SideNavItems.js +14 -11
- package/es/components/UIShell/SideNavLink.js +19 -17
- package/es/components/UIShell/SideNavLinkText.js +8 -9
- package/es/components/UIShell/SideNavMenu.js +29 -35
- package/es/components/UIShell/SideNavMenuItem.js +14 -14
- package/es/components/UIShell/SideNavSwitcher.js +19 -19
- package/es/components/UIShell/SkipToContent.js +10 -11
- package/es/components/UIShell/Switcher.js +20 -11
- package/es/components/UIShell/SwitcherDivider.js +10 -9
- package/es/components/UIShell/SwitcherItem.js +26 -19
- package/es/components/UIShell/_utils.js +1 -1
- package/es/components/UnorderedList/UnorderedList.js +14 -14
- package/es/index.js +7 -7
- package/es/internal/ClickListener.js +49 -65
- package/es/internal/FloatingMenu.js +193 -200
- package/es/internal/OptimizedResize.js +9 -8
- package/es/internal/Selection.js +92 -111
- package/es/internal/createClassWrapper.js +2 -2
- package/es/internal/deprecateFieldOnObject.js +5 -3
- package/es/internal/environment.js +1 -1
- package/es/internal/focus/index.js +1 -1
- package/es/internal/keyboard/keys.js +11 -11
- package/es/internal/keyboard/match.js +7 -6
- package/es/internal/keyboard/navigation.js +15 -5
- package/es/internal/useAnnouncer.js +2 -2
- package/es/internal/useAttachedMenu.js +12 -20
- package/es/internal/useControllableState.js +11 -16
- package/es/internal/useDelayedState.js +9 -18
- package/es/internal/useEffectOnce.js +4 -4
- package/es/internal/useEvent.js +4 -4
- package/es/internal/useId.js +15 -19
- package/es/internal/useIdPrefix.js +1 -1
- package/es/internal/useIsomorphicEffect.js +1 -1
- package/es/internal/useMergedRefs.js +3 -3
- package/es/internal/useNoInteractiveChildren.js +8 -19
- package/es/internal/useNormalizedInputProps.js +16 -14
- package/es/internal/usePrefix.js +1 -1
- package/es/internal/useSavedCallback.js +3 -3
- package/es/internal/warning.js +4 -4
- package/es/internal/wrapFocus.js +16 -21
- package/es/prop-types/AriaPropTypes.js +1 -1
- package/es/prop-types/deprecate.js +6 -5
- package/es/prop-types/isRequiredOneOf.js +12 -25
- package/es/prop-types/requiredIfGivenPropIsTruthy.js +2 -2
- package/es/prop-types/types.js +1 -1
- package/es/tools/array.js +1 -1
- package/es/tools/events.js +21 -14
- package/es/tools/mergeRefs.js +3 -3
- package/es/tools/setupGetInstanceId.js +1 -1
- package/es/tools/uniqueId.js +3 -3
- package/es/tools/wrapComponent.js +14 -13
- package/lib/_virtual/_rollupPluginBabelHelpers.js +0 -336
- package/lib/components/Accordion/Accordion.Skeleton.js +27 -29
- package/lib/components/Accordion/Accordion.js +17 -20
- package/lib/components/Accordion/AccordionItem.js +36 -48
- package/lib/components/AspectRatio/AspectRatio.js +9 -11
- package/lib/components/Breadcrumb/Breadcrumb.Skeleton.js +9 -10
- package/lib/components/Breadcrumb/Breadcrumb.js +13 -12
- package/lib/components/Breadcrumb/BreadcrumbItem.js +23 -21
- package/lib/components/Button/Button.Skeleton.js +24 -22
- package/lib/components/Button/Button.js +76 -71
- package/lib/components/ButtonSet/ButtonSet.js +11 -9
- package/lib/components/Checkbox/Checkbox.Skeleton.js +9 -10
- package/lib/components/Checkbox/Checkbox.js +54 -51
- package/lib/components/CheckboxGroup/CheckboxGroup.js +32 -30
- package/lib/components/ClassPrefix/index.js +4 -2
- package/lib/components/CodeSnippet/CodeSnippet.Skeleton.js +14 -13
- package/lib/components/CodeSnippet/CodeSnippet.js +198 -101
- package/lib/components/ComboBox/ComboBox.js +348 -177
- package/lib/components/ComboBox/tools/filter.js +6 -4
- package/lib/components/ComboButton/index.js +37 -42
- package/lib/components/ComposedModal/ComposedModal.js +187 -85
- package/lib/components/ComposedModal/ModalFooter.js +53 -48
- package/lib/components/ComposedModal/ModalHeader.js +38 -25
- package/lib/components/ContainedList/ContainedList.js +66 -20
- package/lib/components/ContainedList/ContainedListItem/ContainedListItem.js +20 -18
- package/lib/components/ContentSwitcher/ContentSwitcher.js +82 -97
- package/lib/components/ContentSwitcher/index.js +1 -1
- package/lib/components/ContextMenu/useContextMenu.js +12 -21
- package/lib/components/Copy/Copy.js +23 -28
- package/lib/components/CopyButton/CopyButton.js +9 -9
- package/lib/components/DangerButton/DangerButton.js +3 -5
- package/lib/components/DataTable/DataTable.js +331 -357
- package/lib/components/DataTable/Table.js +28 -25
- package/lib/components/DataTable/TableActionList.js +2 -4
- package/lib/components/DataTable/TableBatchAction.js +2 -4
- package/lib/components/DataTable/TableBatchActions.js +28 -29
- package/lib/components/DataTable/TableBody.js +6 -7
- package/lib/components/DataTable/TableCell.js +1 -1
- package/lib/components/DataTable/TableContainer.js +22 -22
- package/lib/components/DataTable/TableContext.js +1 -1
- package/lib/components/DataTable/TableExpandHeader.js +18 -20
- package/lib/components/DataTable/TableExpandRow.js +22 -22
- package/lib/components/DataTable/TableExpandedRow.js +17 -22
- package/lib/components/DataTable/TableHead.js +1 -1
- package/lib/components/DataTable/TableHeader.js +43 -39
- package/lib/components/DataTable/TableRow.js +7 -8
- package/lib/components/DataTable/TableSelectAll.js +13 -11
- package/lib/components/DataTable/TableSelectRow.js +28 -20
- package/lib/components/DataTable/TableToolbar.js +18 -13
- package/lib/components/DataTable/TableToolbarAction.js +5 -5
- package/lib/components/DataTable/TableToolbarContent.js +2 -4
- package/lib/components/DataTable/TableToolbarMenu.js +10 -11
- package/lib/components/DataTable/TableToolbarSearch.js +51 -70
- package/lib/components/DataTable/state/getDerivedStateFromProps.js +15 -15
- package/lib/components/DataTable/state/sortStates.js +1 -1
- package/lib/components/DataTable/state/sorting.js +28 -20
- package/lib/components/DataTable/tools/cells.js +1 -3
- package/lib/components/DataTable/tools/denormalize.js +4 -17
- package/lib/components/DataTable/tools/filter.js +18 -16
- package/lib/components/DataTable/tools/instanceId.js +2 -2
- package/lib/components/DataTable/tools/normalize.js +28 -25
- package/lib/components/DataTable/tools/sorting.js +27 -24
- package/lib/components/DataTableSkeleton/DataTableSkeleton.js +35 -37
- package/lib/components/DatePicker/DatePicker.Skeleton.d.ts +30 -0
- package/lib/components/DatePicker/DatePicker.Skeleton.js +17 -19
- package/lib/components/DatePicker/DatePicker.d.ts +131 -0
- package/lib/components/DatePicker/DatePicker.js +214 -199
- package/lib/components/DatePicker/index.d.ts +10 -0
- package/lib/components/DatePicker/index.js +2 -0
- package/lib/components/DatePicker/plugins/appendToPlugin.js +45 -43
- package/lib/components/DatePicker/plugins/fixEventsPlugin.js +117 -107
- package/lib/components/DatePicker/plugins/rangePlugin.js +19 -11
- package/lib/components/DatePickerInput/DatePickerInput.d.ts +93 -0
- package/lib/components/DatePickerInput/DatePickerInput.js +83 -74
- package/lib/components/Dropdown/Dropdown.Skeleton.js +12 -11
- package/lib/components/Dropdown/Dropdown.js +265 -108
- package/lib/components/ErrorBoundary/ErrorBoundary.js +27 -48
- package/lib/components/ErrorBoundary/ErrorBoundaryContext.js +3 -2
- package/lib/components/ExpandableSearch/ExpandableSearch.d.ts +14 -0
- package/lib/components/ExpandableSearch/ExpandableSearch.js +18 -24
- package/lib/components/FeatureFlags/index.js +25 -43
- package/lib/components/FileUploader/FileUploader.Skeleton.js +7 -8
- package/lib/components/FileUploader/FileUploader.js +119 -146
- package/lib/components/FileUploader/FileUploaderButton.js +35 -47
- package/lib/components/FileUploader/FileUploaderDropContainer.js +48 -52
- package/lib/components/FileUploader/FileUploaderItem.js +29 -29
- package/lib/components/FileUploader/Filename.js +12 -13
- package/lib/components/FluidComboBox/FluidComboBox.Skeleton.js +10 -11
- package/lib/components/FluidComboBox/FluidComboBox.js +10 -8
- package/lib/components/FluidDatePicker/FluidDatePicker.Skeleton.js +17 -17
- package/lib/components/FluidDatePicker/FluidDatePicker.js +19 -15
- package/lib/components/FluidDatePickerInput/FluidDatePickerInput.js +3 -3
- package/lib/components/FluidDropdown/FluidDropdown.Skeleton.js +10 -11
- package/lib/components/FluidDropdown/FluidDropdown.js +10 -8
- package/lib/components/FluidForm/FluidForm.js +8 -9
- package/lib/components/FluidForm/FormContext.js +1 -1
- package/lib/components/FluidMultiSelect/FluidMultiSelect.Skeleton.js +10 -11
- package/lib/components/FluidMultiSelect/FluidMultiSelect.js +11 -9
- package/lib/components/FluidSelect/FluidSelect.Skeleton.js +10 -11
- package/lib/components/FluidSelect/FluidSelect.js +8 -8
- package/lib/components/FluidTextArea/FluidTextArea.Skeleton.js +8 -9
- package/lib/components/FluidTextArea/FluidTextArea.js +6 -7
- package/lib/components/FluidTextInput/FluidTextInput.Skeleton.js +8 -9
- package/lib/components/FluidTextInput/FluidTextInput.js +9 -8
- package/lib/components/FluidTimePicker/FluidTimePicker.Skeleton.js +10 -9
- package/lib/components/FluidTimePicker/FluidTimePicker.js +30 -26
- package/lib/components/FluidTimePickerSelect/FluidTimePickerSelect.js +6 -6
- package/lib/components/Form/Form.js +8 -9
- package/lib/components/FormGroup/FormGroup.js +15 -16
- package/lib/components/FormItem/FormItem.js +7 -8
- package/lib/components/FormLabel/FormLabel.js +10 -9
- package/lib/components/Grid/CSSGrid.js +37 -38
- package/lib/components/Grid/Column.js +85 -78
- package/lib/components/Grid/ColumnHang.js +11 -13
- package/lib/components/Grid/FlexGrid.js +19 -21
- package/lib/components/Grid/Grid.js +2 -2
- package/lib/components/Grid/GridContext.js +12 -11
- package/lib/components/Grid/Row.js +16 -18
- package/lib/components/Heading/index.js +11 -13
- package/lib/components/Icon/Icon.Skeleton.js +9 -11
- package/lib/components/IconButton/index.js +18 -21
- package/lib/components/IdPrefix/index.js +4 -2
- package/lib/components/InlineCheckbox/InlineCheckbox.js +89 -36
- package/lib/components/InlineLoading/InlineLoading.js +22 -24
- package/lib/components/Layer/LayerContext.js +1 -1
- package/lib/components/Layer/index.js +16 -17
- package/lib/components/Layout/LayoutDirection.js +7 -9
- package/lib/components/Layout/LayoutDirectionContext.js +1 -1
- package/lib/components/Link/Link.js +24 -24
- package/lib/components/ListBox/ListBox.js +37 -30
- package/lib/components/ListBox/ListBoxField.js +8 -9
- package/lib/components/ListBox/ListBoxMenu.js +8 -9
- package/lib/components/ListBox/ListBoxMenuIcon.js +16 -14
- package/lib/components/ListBox/ListBoxMenuItem.js +22 -25
- package/lib/components/ListBox/ListBoxPropTypes.js +4 -4
- package/lib/components/ListBox/ListBoxSelection.js +30 -25
- package/lib/components/ListBox/index.js +1 -1
- package/lib/components/ListBox/next/ListBoxSelection.js +26 -23
- package/lib/components/ListBox/next/ListBoxTrigger.js +19 -18
- package/lib/components/ListItem/ListItem.js +8 -9
- package/lib/components/Loading/Loading.js +23 -23
- package/lib/components/Menu/Menu.js +66 -79
- package/lib/components/Menu/MenuContext.js +9 -12
- package/lib/components/Menu/MenuItem.js +103 -127
- package/lib/components/MenuButton/index.js +36 -40
- package/lib/components/Modal/Modal.js +280 -119
- package/lib/components/ModalWrapper/ModalWrapper.js +71 -95
- package/lib/components/MultiSelect/FilterableMultiSelect.js +298 -162
- package/lib/components/MultiSelect/MultiSelect.js +163 -175
- package/lib/components/MultiSelect/MultiSelectPropTypes.js +1 -1
- package/lib/components/MultiSelect/tools/itemToString.js +3 -4
- package/lib/components/MultiSelect/tools/sorting.js +15 -13
- package/lib/components/Notification/Notification.js +434 -162
- package/lib/components/NumberInput/NumberInput.Skeleton.js +9 -10
- package/lib/components/NumberInput/NumberInput.js +139 -138
- package/lib/components/OrderedList/OrderedList.js +16 -14
- package/lib/components/OverflowMenu/OverflowMenu.js +359 -226
- package/lib/components/OverflowMenu/index.js +1 -1
- package/lib/components/OverflowMenuItem/OverflowMenuItem.js +31 -36
- package/lib/components/OverflowMenuV2/index.js +25 -27
- package/lib/components/Pagination/Pagination.Skeleton.js +8 -9
- package/lib/components/Pagination/Pagination.js +97 -139
- package/lib/components/Pagination/experimental/PageSelector.js +17 -17
- package/lib/components/Pagination/experimental/Pagination.js +72 -93
- package/lib/components/PaginationNav/PaginationNav.js +97 -116
- package/lib/components/Popover/index.js +73 -79
- package/lib/components/PrimaryButton/PrimaryButton.js +3 -5
- package/lib/components/ProgressBar/ProgressBar.js +38 -36
- package/lib/components/ProgressIndicator/ProgressIndicator.Skeleton.js +14 -13
- package/lib/components/ProgressIndicator/ProgressIndicator.js +70 -70
- package/lib/components/RadioButton/RadioButton.Skeleton.js +8 -9
- package/lib/components/RadioButton/RadioButton.js +26 -26
- package/lib/components/RadioButtonGroup/RadioButtonGroup.js +54 -64
- package/lib/components/RadioTile/RadioTile.js +26 -24
- package/lib/components/Search/Search.Skeleton.js +15 -15
- package/lib/components/Search/Search.d.ts +83 -0
- package/lib/components/Search/Search.js +62 -69
- package/lib/components/Search/index.d.ts +11 -0
- package/lib/components/SecondaryButton/SecondaryButton.js +3 -5
- package/lib/components/Select/Select.Skeleton.js +11 -12
- package/lib/components/Select/Select.js +78 -72
- package/lib/components/SelectItem/SelectItem.js +16 -12
- package/lib/components/SelectItemGroup/SelectItemGroup.js +10 -11
- package/lib/components/SkeletonIcon/SkeletonIcon.js +10 -10
- package/lib/components/SkeletonPlaceholder/SkeletonPlaceholder.js +10 -10
- package/lib/components/SkeletonText/SkeletonText.js +28 -28
- package/lib/components/Slider/Slider.Skeleton.js +16 -17
- package/lib/components/Slider/Slider.js +305 -328
- package/lib/components/Slider/index.js +1 -1
- package/lib/components/Stack/Stack.js +18 -19
- package/lib/components/Stack/index.js +2 -2
- package/lib/components/StructuredList/StructuredList.Skeleton.js +24 -23
- package/lib/components/StructuredList/StructuredList.js +133 -105
- package/lib/components/Switch/IconSwitch.js +45 -51
- package/lib/components/Switch/Switch.js +33 -31
- package/lib/components/Tab/Tab.js +76 -82
- package/lib/components/Tab/index.js +1 -1
- package/lib/components/TabContent/TabContent.js +15 -17
- package/lib/components/Tabs/Tabs.Skeleton.js +13 -12
- package/lib/components/Tabs/Tabs.js +194 -205
- package/lib/components/Tabs/usePressable.js +27 -36
- package/lib/components/Tag/Tag.Skeleton.js +9 -8
- package/lib/components/Tag/Tag.js +33 -30
- package/lib/components/Text/Text.js +19 -19
- package/lib/components/Text/TextDirection.js +8 -7
- package/lib/components/Text/TextDirectionContext.js +1 -1
- package/lib/components/Text/index.js +1 -1
- package/lib/components/TextArea/TextArea.Skeleton.js +10 -11
- package/lib/components/TextArea/TextArea.js +88 -82
- package/lib/components/TextInput/ControlledPasswordInput.js +78 -72
- package/lib/components/TextInput/PasswordInput.js +100 -90
- package/lib/components/TextInput/TextInput.Skeleton.js +10 -11
- package/lib/components/TextInput/TextInput.js +104 -92
- package/lib/components/TextInput/util.js +28 -30
- package/lib/components/Theme/index.js +24 -19
- package/lib/components/Tile/Tile.js +134 -175
- package/lib/components/TileGroup/TileGroup.js +54 -69
- package/lib/components/TileGroup/index.js +1 -1
- package/lib/components/TimePicker/TimePicker.js +59 -66
- package/lib/components/TimePickerSelect/TimePickerSelect.js +19 -17
- package/lib/components/TimePickerSelect/index.js +1 -1
- package/lib/components/Toggle/Toggle.Skeleton.js +68 -57
- package/lib/components/Toggle/Toggle.js +43 -47
- package/lib/components/ToggleSmall/ToggleSmall.Skeleton.js +60 -54
- package/lib/components/Toggletip/index.js +51 -47
- package/lib/components/Tooltip/DefinitionTooltip.js +23 -30
- package/lib/components/Tooltip/Tooltip.js +34 -49
- package/lib/components/TreeView/TreeNode.js +93 -73
- package/lib/components/TreeView/TreeView.js +71 -82
- package/lib/components/UIShell/Content.js +12 -14
- package/lib/components/UIShell/Header.js +15 -11
- package/lib/components/UIShell/HeaderContainer.js +8 -14
- package/lib/components/UIShell/HeaderGlobalAction.js +25 -18
- package/lib/components/UIShell/HeaderGlobalBar.js +1 -3
- package/lib/components/UIShell/HeaderMenu.js +113 -128
- package/lib/components/UIShell/HeaderMenuButton.js +30 -21
- package/lib/components/UIShell/HeaderMenuItem.js +27 -19
- package/lib/components/UIShell/HeaderName.js +18 -13
- package/lib/components/UIShell/HeaderNavigation.js +18 -14
- package/lib/components/UIShell/HeaderPanel.js +22 -16
- package/lib/components/UIShell/HeaderSideNavItems.js +11 -9
- package/lib/components/UIShell/Link.js +11 -11
- package/lib/components/UIShell/SideNav.js +65 -61
- package/lib/components/UIShell/SideNavDetails.js +10 -11
- package/lib/components/UIShell/SideNavDivider.js +5 -3
- package/lib/components/UIShell/SideNavFooter.js +13 -12
- package/lib/components/UIShell/SideNavHeader.js +9 -6
- package/lib/components/UIShell/SideNavIcon.js +11 -8
- package/lib/components/UIShell/SideNavItem.js +11 -9
- package/lib/components/UIShell/SideNavItems.js +14 -11
- package/lib/components/UIShell/SideNavLink.js +18 -16
- package/lib/components/UIShell/SideNavLinkText.js +7 -8
- package/lib/components/UIShell/SideNavMenu.js +29 -35
- package/lib/components/UIShell/SideNavMenuItem.js +13 -13
- package/lib/components/UIShell/SideNavSwitcher.js +19 -19
- package/lib/components/UIShell/SkipToContent.js +9 -10
- package/lib/components/UIShell/Switcher.js +19 -10
- package/lib/components/UIShell/SwitcherDivider.js +9 -8
- package/lib/components/UIShell/SwitcherItem.js +25 -18
- package/lib/components/UIShell/_utils.js +1 -1
- package/lib/components/UnorderedList/UnorderedList.js +13 -13
- package/lib/index.js +14 -14
- package/lib/internal/ClickListener.js +49 -65
- package/lib/internal/FloatingMenu.js +192 -199
- package/lib/internal/OptimizedResize.js +9 -8
- package/lib/internal/Selection.js +91 -110
- package/lib/internal/createClassWrapper.js +2 -2
- package/lib/internal/deprecateFieldOnObject.js +5 -3
- package/lib/internal/environment.js +1 -1
- package/lib/internal/focus/index.js +1 -1
- package/lib/internal/keyboard/keys.js +11 -11
- package/lib/internal/keyboard/match.js +7 -6
- package/lib/internal/keyboard/navigation.js +15 -5
- package/lib/internal/useAnnouncer.js +2 -2
- package/lib/internal/useAttachedMenu.js +12 -20
- package/lib/internal/useControllableState.js +11 -16
- package/lib/internal/useDelayedState.js +9 -18
- package/lib/internal/useEffectOnce.js +4 -4
- package/lib/internal/useEvent.js +4 -4
- package/lib/internal/useId.js +14 -18
- package/lib/internal/useIdPrefix.js +1 -1
- package/lib/internal/useIsomorphicEffect.js +1 -1
- package/lib/internal/useMergedRefs.js +3 -3
- package/lib/internal/useNoInteractiveChildren.js +8 -19
- package/lib/internal/useNormalizedInputProps.js +16 -14
- package/lib/internal/usePrefix.js +1 -1
- package/lib/internal/useSavedCallback.js +3 -3
- package/lib/internal/warning.js +4 -4
- package/lib/internal/wrapFocus.js +16 -21
- package/lib/prop-types/AriaPropTypes.js +1 -1
- package/lib/prop-types/deprecate.js +6 -5
- package/lib/prop-types/isRequiredOneOf.js +15 -28
- package/lib/prop-types/requiredIfGivenPropIsTruthy.js +2 -2
- package/lib/prop-types/types.js +1 -1
- package/lib/tools/array.js +1 -1
- package/lib/tools/events.js +21 -14
- package/lib/tools/mergeRefs.js +3 -3
- package/lib/tools/setupGetInstanceId.js +1 -1
- package/lib/tools/uniqueId.js +3 -3
- package/lib/tools/wrapComponent.js +14 -13
- package/package.json +6 -6
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
9
|
import cx from 'classnames';
|
|
10
10
|
import Downshift from 'downshift';
|
|
11
11
|
import PropTypes from 'prop-types';
|
|
@@ -27,11 +27,7 @@ import ListBoxTrigger from '../ListBox/next/ListBoxTrigger.js';
|
|
|
27
27
|
import { ListBoxSize, ListBoxType } from '../ListBox/ListBoxPropTypes.js';
|
|
28
28
|
import { Space, Enter, Escape, Home, End } from '../../internal/keyboard/keys.js';
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
var _excluded = ["aria-label", "ariaLabel", "className", "direction", "disabled", "downshiftProps", "helperText", "id", "initialSelectedItem", "invalid", "invalidText", "items", "itemToElement", "itemToString", "light", "onChange", "onInputChange", "onToggleClick", "placeholder", "readOnly", "selectedItem", "shouldFilterItem", "size", "titleText", "translateWithId", "type", "warn", "warnText", "onStateChange"];
|
|
33
|
-
|
|
34
|
-
var defaultItemToString = function defaultItemToString(item) {
|
|
30
|
+
const defaultItemToString = item => {
|
|
35
31
|
if (typeof item === 'string') {
|
|
36
32
|
return item;
|
|
37
33
|
}
|
|
@@ -39,15 +35,15 @@ var defaultItemToString = function defaultItemToString(item) {
|
|
|
39
35
|
return item && item.label;
|
|
40
36
|
};
|
|
41
37
|
|
|
42
|
-
|
|
43
|
-
return true;
|
|
44
|
-
};
|
|
38
|
+
const defaultShouldFilterItem = () => true;
|
|
45
39
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
40
|
+
const getInputValue = _ref => {
|
|
41
|
+
let {
|
|
42
|
+
initialSelectedItem,
|
|
43
|
+
inputValue,
|
|
44
|
+
itemToString,
|
|
45
|
+
selectedItem
|
|
46
|
+
} = _ref;
|
|
51
47
|
|
|
52
48
|
if (selectedItem) {
|
|
53
49
|
return itemToString(selectedItem);
|
|
@@ -60,21 +56,22 @@ var getInputValue = function getInputValue(_ref) {
|
|
|
60
56
|
return inputValue || '';
|
|
61
57
|
};
|
|
62
58
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
59
|
+
const findHighlightedIndex = (_ref2, inputValue) => {
|
|
60
|
+
let {
|
|
61
|
+
items,
|
|
62
|
+
itemToString = defaultItemToString
|
|
63
|
+
} = _ref2;
|
|
67
64
|
|
|
68
65
|
if (!inputValue) {
|
|
69
66
|
return -1;
|
|
70
67
|
}
|
|
71
68
|
|
|
72
|
-
|
|
69
|
+
const searchValue = inputValue.toLowerCase();
|
|
73
70
|
|
|
74
|
-
for (
|
|
75
|
-
|
|
71
|
+
for (let i = 0; i < items.length; i++) {
|
|
72
|
+
const item = itemToString(items[i]).toLowerCase();
|
|
76
73
|
|
|
77
|
-
if (
|
|
74
|
+
if (item.indexOf(searchValue) !== -1) {
|
|
78
75
|
return i;
|
|
79
76
|
}
|
|
80
77
|
}
|
|
@@ -82,200 +79,198 @@ var findHighlightedIndex = function findHighlightedIndex(_ref2, inputValue) {
|
|
|
82
79
|
return -1;
|
|
83
80
|
};
|
|
84
81
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
var
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
initialSelectedItem: initialSelectedItem,
|
|
82
|
+
const getInstanceId = setupGetInstanceId();
|
|
83
|
+
const ComboBox = /*#__PURE__*/React__default.forwardRef((props, ref) => {
|
|
84
|
+
var _Text;
|
|
85
|
+
|
|
86
|
+
const {
|
|
87
|
+
['aria-label']: ariaLabel,
|
|
88
|
+
ariaLabel: deprecatedAriaLabel,
|
|
89
|
+
className: containerClassName,
|
|
90
|
+
direction,
|
|
91
|
+
disabled,
|
|
92
|
+
downshiftProps,
|
|
93
|
+
helperText,
|
|
94
|
+
id,
|
|
95
|
+
initialSelectedItem,
|
|
96
|
+
invalid,
|
|
97
|
+
invalidText,
|
|
98
|
+
items,
|
|
99
|
+
itemToElement,
|
|
100
|
+
itemToString,
|
|
101
|
+
light,
|
|
102
|
+
onChange,
|
|
103
|
+
onInputChange,
|
|
104
|
+
onToggleClick,
|
|
105
|
+
placeholder,
|
|
106
|
+
readOnly,
|
|
107
|
+
selectedItem,
|
|
108
|
+
shouldFilterItem,
|
|
109
|
+
size,
|
|
110
|
+
titleText,
|
|
111
|
+
translateWithId,
|
|
112
|
+
type: _type,
|
|
113
|
+
warn,
|
|
114
|
+
warnText,
|
|
115
|
+
onStateChange: _onStateChange,
|
|
116
|
+
...rest
|
|
117
|
+
} = props;
|
|
118
|
+
const prefix = usePrefix();
|
|
119
|
+
const {
|
|
120
|
+
isFluid
|
|
121
|
+
} = useContext(FormContext);
|
|
122
|
+
const textInput = useRef(null);
|
|
123
|
+
const comboBoxInstanceId = getInstanceId();
|
|
124
|
+
const [inputValue, setInputValue] = useState(getInputValue({
|
|
125
|
+
initialSelectedItem,
|
|
130
126
|
inputValue: '',
|
|
131
|
-
itemToString
|
|
132
|
-
selectedItem
|
|
133
|
-
}))
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
var _useState3 = useState(false),
|
|
139
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
140
|
-
isFocused = _useState4[0],
|
|
141
|
-
setIsFocused = _useState4[1];
|
|
142
|
-
|
|
143
|
-
var _useState5 = useState(),
|
|
144
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
145
|
-
prevSelectedItem = _useState6[0],
|
|
146
|
-
setPrevSelectedItem = _useState6[1];
|
|
147
|
-
|
|
148
|
-
var _useState7 = useState(false),
|
|
149
|
-
_useState8 = _slicedToArray(_useState7, 2),
|
|
150
|
-
doneInitialSelectedItem = _useState8[0],
|
|
151
|
-
setDoneInitialSelectedItem = _useState8[1];
|
|
152
|
-
|
|
153
|
-
var savedOnInputChange = useRef(onInputChange);
|
|
127
|
+
itemToString,
|
|
128
|
+
selectedItem
|
|
129
|
+
}));
|
|
130
|
+
const [isFocused, setIsFocused] = useState(false);
|
|
131
|
+
const [prevSelectedItem, setPrevSelectedItem] = useState();
|
|
132
|
+
const [doneInitialSelectedItem, setDoneInitialSelectedItem] = useState(false);
|
|
133
|
+
const savedOnInputChange = useRef(onInputChange);
|
|
154
134
|
|
|
155
135
|
if (!doneInitialSelectedItem || prevSelectedItem !== selectedItem) {
|
|
156
136
|
setDoneInitialSelectedItem(true);
|
|
157
137
|
setPrevSelectedItem(selectedItem);
|
|
158
138
|
setInputValue(getInputValue({
|
|
159
|
-
initialSelectedItem
|
|
160
|
-
inputValue
|
|
161
|
-
itemToString
|
|
162
|
-
selectedItem
|
|
139
|
+
initialSelectedItem,
|
|
140
|
+
inputValue,
|
|
141
|
+
itemToString,
|
|
142
|
+
selectedItem
|
|
163
143
|
}));
|
|
164
144
|
}
|
|
165
145
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
inputValue: inputValue
|
|
172
|
-
}) : defaultShouldFilterItem();
|
|
173
|
-
});
|
|
174
|
-
};
|
|
146
|
+
const filterItems = (items, itemToString, inputValue) => items.filter(item => shouldFilterItem ? shouldFilterItem({
|
|
147
|
+
item,
|
|
148
|
+
itemToString,
|
|
149
|
+
inputValue
|
|
150
|
+
}) : defaultShouldFilterItem());
|
|
175
151
|
|
|
176
|
-
|
|
152
|
+
const handleOnChange = selectedItem => {
|
|
177
153
|
if (onChange) {
|
|
178
154
|
onChange({
|
|
179
|
-
selectedItem
|
|
155
|
+
selectedItem
|
|
180
156
|
});
|
|
181
157
|
}
|
|
182
158
|
};
|
|
183
159
|
|
|
184
|
-
|
|
160
|
+
const handleOnInputValueChange = inputValue => {
|
|
185
161
|
setInputValue(inputValue || '');
|
|
186
162
|
};
|
|
187
163
|
|
|
188
|
-
useEffect(
|
|
164
|
+
useEffect(() => {
|
|
189
165
|
savedOnInputChange.current = onInputChange;
|
|
190
166
|
}, [onInputChange]);
|
|
191
|
-
useEffect(
|
|
167
|
+
useEffect(() => {
|
|
192
168
|
if (savedOnInputChange.current) {
|
|
193
169
|
savedOnInputChange.current(inputValue);
|
|
194
170
|
}
|
|
195
171
|
}, [inputValue]);
|
|
196
172
|
|
|
197
|
-
|
|
173
|
+
const handleSelectionClear = () => {
|
|
198
174
|
if (textInput !== null && textInput !== void 0 && textInput.current) {
|
|
199
175
|
textInput.current.focus();
|
|
200
176
|
}
|
|
201
177
|
};
|
|
202
178
|
|
|
203
|
-
|
|
204
|
-
|
|
179
|
+
const handleOnStateChange = (newState, _ref3) => {
|
|
180
|
+
let {
|
|
181
|
+
setHighlightedIndex
|
|
182
|
+
} = _ref3;
|
|
205
183
|
|
|
206
184
|
if (Object.prototype.hasOwnProperty.call(newState, 'inputValue')) {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
185
|
+
const {
|
|
186
|
+
inputValue
|
|
187
|
+
} = newState;
|
|
188
|
+
const filteredItems = filterItems(items, itemToString, inputValue);
|
|
189
|
+
setHighlightedIndex(findHighlightedIndex({ ...props,
|
|
210
190
|
items: filteredItems
|
|
211
|
-
}
|
|
191
|
+
}, inputValue));
|
|
212
192
|
}
|
|
213
193
|
};
|
|
214
194
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
}
|
|
195
|
+
const handleToggleClick = isOpen => event => {
|
|
196
|
+
if (onToggleClick) {
|
|
197
|
+
onToggleClick(event);
|
|
198
|
+
}
|
|
220
199
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
};
|
|
200
|
+
if (event.target === textInput.current && isOpen) {
|
|
201
|
+
event.preventDownshiftDefault = true;
|
|
202
|
+
event.persist();
|
|
203
|
+
}
|
|
226
204
|
};
|
|
227
205
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
206
|
+
const enabled = useFeatureFlag('enable-v11-release');
|
|
207
|
+
const showWarning = !invalid && warn;
|
|
208
|
+
const className = cx(`${prefix}--combo-box`, [enabled ? null : containerClassName], {
|
|
209
|
+
[`${prefix}--list-box--up`]: direction === 'top',
|
|
210
|
+
[`${prefix}--combo-box--warning`]: showWarning,
|
|
211
|
+
[`${prefix}--combo-box--readonly`]: readOnly
|
|
212
|
+
});
|
|
213
|
+
const titleClasses = cx(`${prefix}--label`, {
|
|
214
|
+
[`${prefix}--label--disabled`]: disabled
|
|
215
|
+
});
|
|
216
|
+
const comboBoxHelperId = !helperText ? undefined : `combobox-helper-text-${comboBoxInstanceId}`;
|
|
217
|
+
const helperClasses = cx(`${prefix}--form__helper-text`, {
|
|
218
|
+
[`${prefix}--form__helper-text--disabled`]: disabled
|
|
219
|
+
});
|
|
220
|
+
const wrapperClasses = cx(`${prefix}--list-box__wrapper`, [enabled ? containerClassName : null, {
|
|
221
|
+
[`${prefix}--list-box__wrapper--fluid--invalid`]: isFluid && invalid,
|
|
222
|
+
[`${prefix}--list-box__wrapper--fluid--focus`]: isFluid && isFocused
|
|
223
|
+
}]);
|
|
224
|
+
const inputClasses = cx(`${prefix}--text-input`, {
|
|
225
|
+
[`${prefix}--text-input--empty`]: !inputValue,
|
|
226
|
+
[`${prefix}--combo-box--input--focus`]: isFocused && !isFluid
|
|
227
|
+
}); // needs to be Capitalized for react to render it correctly
|
|
228
|
+
|
|
229
|
+
const ItemToElement = itemToElement;
|
|
238
230
|
return /*#__PURE__*/React__default.createElement(Downshift, _extends({}, downshiftProps, {
|
|
239
231
|
onChange: handleOnChange,
|
|
240
232
|
onInputValueChange: handleOnInputValueChange,
|
|
241
|
-
onStateChange: function
|
|
233
|
+
onStateChange: function () {
|
|
242
234
|
var _downshiftProps$onSta;
|
|
243
235
|
|
|
244
236
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
245
237
|
args[_key] = arguments[_key];
|
|
246
238
|
}
|
|
247
239
|
|
|
248
|
-
handleOnStateChange
|
|
249
|
-
downshiftProps === null || downshiftProps === void 0 ? void 0 : (_downshiftProps$onSta = downshiftProps.onStateChange) === null || _downshiftProps$onSta === void 0 ? void 0 : _downshiftProps$onSta.call
|
|
240
|
+
handleOnStateChange(...args);
|
|
241
|
+
downshiftProps === null || downshiftProps === void 0 ? void 0 : (_downshiftProps$onSta = downshiftProps.onStateChange) === null || _downshiftProps$onSta === void 0 ? void 0 : _downshiftProps$onSta.call(downshiftProps, ...args);
|
|
250
242
|
},
|
|
251
243
|
inputValue: inputValue || '',
|
|
252
244
|
itemToString: itemToString,
|
|
253
245
|
initialSelectedItem: initialSelectedItem,
|
|
254
246
|
inputId: id,
|
|
255
247
|
selectedItem: selectedItem
|
|
256
|
-
}),
|
|
248
|
+
}), _ref4 => {
|
|
257
249
|
var _textInput$current;
|
|
258
250
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
251
|
+
let {
|
|
252
|
+
getInputProps,
|
|
253
|
+
getItemProps,
|
|
254
|
+
getLabelProps,
|
|
255
|
+
getMenuProps,
|
|
256
|
+
getRootProps,
|
|
257
|
+
getToggleButtonProps,
|
|
258
|
+
isOpen,
|
|
259
|
+
inputValue,
|
|
260
|
+
selectedItem,
|
|
261
|
+
highlightedIndex,
|
|
262
|
+
clearSelection,
|
|
263
|
+
toggleMenu
|
|
264
|
+
} = _ref4;
|
|
265
|
+
const rootProps = getRootProps( // @ts-ignore this is not supposed to be a required property
|
|
272
266
|
{}, {
|
|
273
267
|
suppressRefError: true
|
|
274
268
|
});
|
|
275
|
-
|
|
276
|
-
|
|
269
|
+
const labelProps = getLabelProps();
|
|
270
|
+
const buttonProps = getToggleButtonProps({
|
|
277
271
|
disabled: disabled || readOnly,
|
|
278
272
|
onClick: handleToggleClick(isOpen),
|
|
273
|
+
|
|
279
274
|
// When we moved the "root node" of Downshift to the <input> for
|
|
280
275
|
// ARIA 1.2 compliance, we unfortunately hit this branch for the
|
|
281
276
|
// "mouseup" event that downshift listens to:
|
|
@@ -285,21 +280,24 @@ var ComboBox = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
285
280
|
// stop the event from propagating to prevent this if the menu is already open.
|
|
286
281
|
// This allows the toggleMenu behavior for the toggleButton to correctly open and
|
|
287
282
|
// close the menu.
|
|
288
|
-
onMouseUp
|
|
283
|
+
onMouseUp(event) {
|
|
289
284
|
if (isOpen) {
|
|
290
285
|
event.stopPropagation();
|
|
291
286
|
}
|
|
292
287
|
}
|
|
288
|
+
|
|
293
289
|
});
|
|
294
|
-
|
|
290
|
+
const inputProps = getInputProps({
|
|
295
291
|
// Remove excess aria `aria-labelledby`. HTML <label for> provides this aria information.
|
|
296
292
|
'aria-labelledby': null,
|
|
297
|
-
disabled
|
|
298
|
-
placeholder
|
|
299
|
-
|
|
293
|
+
disabled,
|
|
294
|
+
placeholder,
|
|
295
|
+
|
|
296
|
+
onClick() {
|
|
300
297
|
toggleMenu();
|
|
301
298
|
},
|
|
302
|
-
|
|
299
|
+
|
|
300
|
+
onKeyDown: event => {
|
|
303
301
|
if (match(event, Space)) {
|
|
304
302
|
event.stopPropagation();
|
|
305
303
|
}
|
|
@@ -326,12 +324,12 @@ var ComboBox = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
326
324
|
}
|
|
327
325
|
});
|
|
328
326
|
|
|
329
|
-
|
|
327
|
+
const handleFocus = evt => {
|
|
330
328
|
setIsFocused(evt.type === 'focus');
|
|
331
329
|
};
|
|
332
330
|
|
|
333
|
-
|
|
334
|
-
onKeyDown:
|
|
331
|
+
const readOnlyEventHandlers = readOnly ? {
|
|
332
|
+
onKeyDown: evt => {
|
|
335
333
|
// This prevents the select from opening for the above keys
|
|
336
334
|
if (evt.key !== 'Tab') {
|
|
337
335
|
evt.preventDefault();
|
|
@@ -356,7 +354,7 @@ var ComboBox = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
356
354
|
warn: warn,
|
|
357
355
|
warnText: warnText
|
|
358
356
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
359
|
-
className:
|
|
357
|
+
className: `${prefix}--list-box__field`
|
|
360
358
|
}, /*#__PURE__*/React__default.createElement("input", _extends({
|
|
361
359
|
role: "combobox",
|
|
362
360
|
disabled: disabled,
|
|
@@ -373,9 +371,9 @@ var ComboBox = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
373
371
|
ref: mergeRefs(textInput, ref),
|
|
374
372
|
"aria-describedby": helperText && !invalid && !warn && !isFluid ? comboBoxHelperId : undefined
|
|
375
373
|
})), invalid && /*#__PURE__*/React__default.createElement(WarningFilled, {
|
|
376
|
-
className:
|
|
374
|
+
className: `${prefix}--list-box__invalid-icon`
|
|
377
375
|
}), showWarning && /*#__PURE__*/React__default.createElement(WarningAltFilled, {
|
|
378
|
-
className:
|
|
376
|
+
className: `${prefix}--list-box__invalid-icon ${prefix}--list-box__invalid-icon--warning`
|
|
379
377
|
}), inputValue && /*#__PURE__*/React__default.createElement(ListBoxSelection, {
|
|
380
378
|
clearSelection: clearSelection,
|
|
381
379
|
translateWithId: translateWithId,
|
|
@@ -387,13 +385,14 @@ var ComboBox = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
387
385
|
translateWithId: translateWithId
|
|
388
386
|
}))), /*#__PURE__*/React__default.createElement(ListBox.Menu, getMenuProps({
|
|
389
387
|
'aria-label': deprecatedAriaLabel || ariaLabel
|
|
390
|
-
}), isOpen ? filterItems(items, itemToString, inputValue).map(
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
item:
|
|
395
|
-
index:
|
|
396
|
-
|
|
388
|
+
}), isOpen ? filterItems(items, itemToString, inputValue).map((item, index) => {
|
|
389
|
+
const itemProps = getItemProps({
|
|
390
|
+
item,
|
|
391
|
+
index,
|
|
392
|
+
['aria-current']: selectedItem === item ? 'true' : 'false',
|
|
393
|
+
['aria-selected']: highlightedIndex === index ? 'true' : 'false',
|
|
394
|
+
disabled: item.disabled
|
|
395
|
+
});
|
|
397
396
|
return /*#__PURE__*/React__default.createElement(ListBox.MenuItem, _extends({
|
|
398
397
|
key: itemProps.id,
|
|
399
398
|
isActive: selectedItem === item,
|
|
@@ -405,7 +404,7 @@ var ComboBox = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
405
404
|
React__default.createElement(ItemToElement, _extends({
|
|
406
405
|
key: itemProps.id
|
|
407
406
|
}, item)) : itemToString ? itemToString(item) : defaultItemToString(item), selectedItem === item && /*#__PURE__*/React__default.createElement(Checkmark, {
|
|
408
|
-
className:
|
|
407
|
+
className: `${prefix}--list-box__menu-item__selected-icon`
|
|
409
408
|
}));
|
|
410
409
|
}) : null)), helperText && !invalid && !warn && !isFluid && (_Text || (_Text = /*#__PURE__*/React__default.createElement(Text, {
|
|
411
410
|
as: "div",
|
|
@@ -415,14 +414,186 @@ var ComboBox = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
415
414
|
});
|
|
416
415
|
});
|
|
417
416
|
ComboBox.displayName = 'ComboBox';
|
|
418
|
-
ComboBox.propTypes =
|
|
419
|
-
|
|
417
|
+
ComboBox.propTypes = {
|
|
418
|
+
/**
|
|
419
|
+
* 'aria-label' of the ListBox component.
|
|
420
|
+
* Specify a label to be read by screen readers on the container node
|
|
421
|
+
*/
|
|
422
|
+
['aria-label']: PropTypes.string,
|
|
423
|
+
|
|
424
|
+
/**
|
|
425
|
+
* Deprecated, please use `aria-label` instead.
|
|
426
|
+
* Specify a label to be read by screen readers on the container note.
|
|
427
|
+
* 'aria-label' of the ListBox component.
|
|
428
|
+
*/
|
|
429
|
+
ariaLabel: deprecate(PropTypes.string, 'This prop syntax has been deprecated. Please use the new `aria-label`.'),
|
|
430
|
+
|
|
431
|
+
/**
|
|
432
|
+
* An optional className to add to the container node
|
|
433
|
+
*/
|
|
434
|
+
className: PropTypes.string,
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
* Specify the direction of the combobox dropdown. Can be either top or bottom.
|
|
438
|
+
*/
|
|
439
|
+
direction: PropTypes.oneOf(['top', 'bottom']),
|
|
440
|
+
|
|
441
|
+
/**
|
|
442
|
+
* Specify if the control should be disabled, or not
|
|
443
|
+
*/
|
|
444
|
+
disabled: PropTypes.bool,
|
|
445
|
+
|
|
446
|
+
/**
|
|
447
|
+
* Additional props passed to Downshift
|
|
448
|
+
*/
|
|
449
|
+
// @ts-ignore
|
|
450
|
+
downshiftProps: PropTypes.shape(Downshift.propTypes),
|
|
451
|
+
|
|
452
|
+
/**
|
|
453
|
+
* Provide helper text that is used alongside the control label for
|
|
454
|
+
* additional help
|
|
455
|
+
*/
|
|
456
|
+
helperText: PropTypes.string,
|
|
457
|
+
|
|
458
|
+
/**
|
|
459
|
+
* Specify a custom `id` for the input
|
|
460
|
+
*/
|
|
461
|
+
id: PropTypes.string.isRequired,
|
|
462
|
+
|
|
463
|
+
/**
|
|
464
|
+
* Allow users to pass in an arbitrary item or a string (in case their items are an array of strings)
|
|
465
|
+
* from their collection that are pre-selected
|
|
466
|
+
*/
|
|
467
|
+
initialSelectedItem: PropTypes.oneOfType([PropTypes.object, PropTypes.string, PropTypes.number]),
|
|
468
|
+
|
|
469
|
+
/**
|
|
470
|
+
* Specify if the currently selected value is invalid.
|
|
471
|
+
*/
|
|
472
|
+
invalid: PropTypes.bool,
|
|
473
|
+
|
|
474
|
+
/**
|
|
475
|
+
* Message which is displayed if the value is invalid.
|
|
476
|
+
*/
|
|
477
|
+
invalidText: PropTypes.node,
|
|
478
|
+
|
|
479
|
+
/**
|
|
480
|
+
* Optional function to render items as custom components instead of strings.
|
|
481
|
+
* Defaults to null and is overridden by a getter
|
|
482
|
+
*/
|
|
483
|
+
itemToElement: PropTypes.func,
|
|
484
|
+
|
|
485
|
+
/**
|
|
486
|
+
* Helper function passed to downshift that allows the library to render a
|
|
487
|
+
* given item to a string label. By default, it extracts the `label` field
|
|
488
|
+
* from a given item to serve as the item label in the list
|
|
489
|
+
*/
|
|
490
|
+
itemToString: PropTypes.func,
|
|
491
|
+
|
|
492
|
+
/**
|
|
493
|
+
* We try to stay as generic as possible here to allow individuals to pass
|
|
494
|
+
* in a collection of whatever kind of data structure they prefer
|
|
495
|
+
*/
|
|
496
|
+
items: PropTypes.array.isRequired,
|
|
497
|
+
|
|
498
|
+
/**
|
|
499
|
+
* should use "light theme" (white background)?
|
|
500
|
+
*/
|
|
501
|
+
light: deprecate(PropTypes.bool, 'The `light` prop for `Combobox` has ' + 'been deprecated in favor of the new `Layer` component. It will be removed in the next major release.'),
|
|
502
|
+
|
|
503
|
+
/**
|
|
504
|
+
* `onChange` is a utility for this controlled component to communicate to a
|
|
505
|
+
* consuming component when a specific dropdown item is selected.
|
|
506
|
+
* `({ selectedItem }) => void`
|
|
507
|
+
* @param {{ selectedItem }}
|
|
508
|
+
*/
|
|
509
|
+
onChange: PropTypes.func.isRequired,
|
|
510
|
+
|
|
511
|
+
/**
|
|
512
|
+
* Callback function to notify consumer when the text input changes.
|
|
513
|
+
* This provides support to change available items based on the text.
|
|
514
|
+
* `(inputText) => void`
|
|
515
|
+
* @param {string} inputText
|
|
516
|
+
*/
|
|
517
|
+
onInputChange: PropTypes.func,
|
|
518
|
+
|
|
519
|
+
/**
|
|
520
|
+
* Helper function passed to Downshift that allows the user to observe internal
|
|
521
|
+
* state changes
|
|
522
|
+
* `(changes, stateAndHelpers) => void`
|
|
523
|
+
*/
|
|
524
|
+
onStateChange: PropTypes.func,
|
|
525
|
+
|
|
526
|
+
/**
|
|
527
|
+
* Callback function that fires when the combobox menu toggle is clicked
|
|
528
|
+
* `(evt) => void`
|
|
529
|
+
* @param {MouseEvent} event
|
|
530
|
+
*/
|
|
531
|
+
onToggleClick: PropTypes.func,
|
|
532
|
+
|
|
533
|
+
/**
|
|
534
|
+
* Used to provide a placeholder text node before a user enters any input.
|
|
535
|
+
* This is only present if the control has no items selected
|
|
536
|
+
*/
|
|
537
|
+
placeholder: PropTypes.string,
|
|
538
|
+
|
|
539
|
+
/**
|
|
540
|
+
* Is the ComboBox readonly?
|
|
541
|
+
*/
|
|
542
|
+
readOnly: PropTypes.bool,
|
|
543
|
+
|
|
544
|
+
/**
|
|
545
|
+
* For full control of the selection
|
|
546
|
+
*/
|
|
547
|
+
selectedItem: PropTypes.oneOfType([PropTypes.object, PropTypes.string, PropTypes.number]),
|
|
548
|
+
|
|
549
|
+
/**
|
|
550
|
+
* Specify your own filtering logic by passing in a `shouldFilterItem`
|
|
551
|
+
* function that takes in the current input and an item and passes back
|
|
552
|
+
* whether or not the item should be filtered.
|
|
553
|
+
*/
|
|
554
|
+
shouldFilterItem: PropTypes.func,
|
|
555
|
+
|
|
556
|
+
/**
|
|
557
|
+
* Specify the size of the ListBox. Currently supports either `sm`, `md` or `lg` as an option.
|
|
558
|
+
*/
|
|
559
|
+
size: ListBoxSize,
|
|
560
|
+
|
|
561
|
+
/**
|
|
562
|
+
* Provide text to be used in a `<label>` element that is tied to the
|
|
563
|
+
* combobox via ARIA attributes.
|
|
564
|
+
*/
|
|
565
|
+
titleText: PropTypes.node,
|
|
566
|
+
|
|
567
|
+
/**
|
|
568
|
+
* Specify a custom translation function that takes in a message identifier
|
|
569
|
+
* and returns the localized string for the message
|
|
570
|
+
*/
|
|
571
|
+
translateWithId: PropTypes.func,
|
|
572
|
+
|
|
573
|
+
/**
|
|
574
|
+
* Currently supports either the default type, or an inline variant
|
|
575
|
+
*/
|
|
576
|
+
type: ListBoxType,
|
|
577
|
+
|
|
578
|
+
/**
|
|
579
|
+
* Specify whether the control is currently in warning state
|
|
580
|
+
*/
|
|
581
|
+
warn: PropTypes.bool,
|
|
582
|
+
|
|
583
|
+
/**
|
|
584
|
+
* Provide the text that is displayed when the control is in warning state
|
|
585
|
+
*/
|
|
586
|
+
warnText: PropTypes.node
|
|
587
|
+
};
|
|
588
|
+
ComboBox.defaultProps = {
|
|
420
589
|
disabled: false,
|
|
421
590
|
itemToString: defaultItemToString,
|
|
422
591
|
itemToElement: null,
|
|
423
592
|
shouldFilterItem: defaultShouldFilterItem,
|
|
424
|
-
type: 'default'
|
|
425
|
-
|
|
593
|
+
type: 'default',
|
|
594
|
+
['aria-label']: 'Choose an item',
|
|
595
|
+
direction: 'bottom'
|
|
596
|
+
};
|
|
426
597
|
var ComboBox$1 = ComboBox;
|
|
427
598
|
|
|
428
599
|
export { ComboBox$1 as default };
|