@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 PropTypes from 'prop-types';
|
|
10
10
|
import React__default, { useContext, useState, useCallback, useRef, useEffect, useImperativeHandle } from 'react';
|
|
11
11
|
import cx from 'classnames';
|
|
@@ -24,10 +24,9 @@ import { WarningFilled, WarningAltFilled } from '@carbon/icons-react';
|
|
|
24
24
|
import { match } from '../../internal/keyboard/match.js';
|
|
25
25
|
import { Escape, ArrowDown } from '../../internal/keyboard/keys.js';
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
l10n.en.weekdays.shorthand
|
|
30
|
-
var currentDay = l10n.en.weekdays.shorthand;
|
|
27
|
+
// Weekdays shorthand for english locale
|
|
28
|
+
l10n.en.weekdays.shorthand.forEach((_day, index) => {
|
|
29
|
+
const currentDay = l10n.en.weekdays.shorthand;
|
|
31
30
|
|
|
32
31
|
if (currentDay[index] === 'Thu' || currentDay[index] === 'Th') {
|
|
33
32
|
currentDay[index] = 'Th';
|
|
@@ -35,7 +34,7 @@ l10n.en.weekdays.shorthand.forEach(function (_day, index) {
|
|
|
35
34
|
currentDay[index] = currentDay[index].charAt(0);
|
|
36
35
|
}
|
|
37
36
|
});
|
|
38
|
-
|
|
37
|
+
const forEach = Array.prototype.forEach;
|
|
39
38
|
/**
|
|
40
39
|
* @param {number} monthNumber The month number.
|
|
41
40
|
* @param {boolean} shorthand `true` to use shorthand month.
|
|
@@ -43,9 +42,7 @@ var forEach = Array.prototype.forEach;
|
|
|
43
42
|
* @returns {string} The month string.
|
|
44
43
|
*/
|
|
45
44
|
|
|
46
|
-
|
|
47
|
-
return locale.months[shorthand ? 'shorthand' : 'longhand'][monthNumber];
|
|
48
|
-
};
|
|
45
|
+
const monthToStr = (monthNumber, shorthand, locale) => locale.months[shorthand ? 'shorthand' : 'longhand'][monthNumber];
|
|
49
46
|
/**
|
|
50
47
|
* @param {object} config Plugin configuration.
|
|
51
48
|
* @param {boolean} [config.shorthand] `true` to use shorthand month.
|
|
@@ -57,55 +54,50 @@ var monthToStr = function monthToStr(monthNumber, shorthand, locale) {
|
|
|
57
54
|
*/
|
|
58
55
|
|
|
59
56
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
57
|
+
const carbonFlatpickrMonthSelectPlugin = config => fp => {
|
|
58
|
+
const setupElements = () => {
|
|
59
|
+
if (!fp.monthElements) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
64
62
|
|
|
65
|
-
|
|
63
|
+
fp.monthElements.forEach(elem => {
|
|
64
|
+
if (!elem.parentNode) {
|
|
66
65
|
return;
|
|
67
66
|
}
|
|
68
67
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
monthElement.textContent = monthToStr(fp.currentMonth, config.shorthand === true, fp.l10n);
|
|
82
|
-
fp.yearElements[0].closest(config.selectorFlatpickrMonthYearContainer).insertBefore(monthElement, fp.yearElements[0].closest(config.selectorFlatpickrYearContainer));
|
|
83
|
-
return monthElement;
|
|
84
|
-
}))));
|
|
85
|
-
};
|
|
68
|
+
elem.parentNode.removeChild(elem);
|
|
69
|
+
});
|
|
70
|
+
fp.monthElements.splice(0, fp.monthElements.length, ...fp.monthElements.map(() => {
|
|
71
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
72
|
+
const monthElement = fp._createElement('span', config.classFlatpickrCurrentMonth);
|
|
73
|
+
|
|
74
|
+
monthElement.textContent = monthToStr(fp.currentMonth, config.shorthand === true, fp.l10n);
|
|
75
|
+
fp.yearElements[0].closest(config.selectorFlatpickrMonthYearContainer).insertBefore(monthElement, fp.yearElements[0].closest(config.selectorFlatpickrYearContainer));
|
|
76
|
+
return monthElement;
|
|
77
|
+
}));
|
|
78
|
+
};
|
|
86
79
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
});
|
|
80
|
+
const updateCurrentMonth = () => {
|
|
81
|
+
if (fp.monthElements) {
|
|
82
|
+
const monthStr = monthToStr(fp.currentMonth, config.shorthand === true, fp.l10n);
|
|
83
|
+
fp.yearElements.forEach(elem => {
|
|
84
|
+
const currentMonthContainer = elem.closest(config.selectorFlatpickrMonthYearContainer);
|
|
85
|
+
Array.prototype.forEach.call(currentMonthContainer.querySelectorAll('.cur-month'), monthElement => {
|
|
86
|
+
monthElement.textContent = monthStr;
|
|
95
87
|
});
|
|
96
|
-
}
|
|
97
|
-
}
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
};
|
|
98
91
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
92
|
+
const register = () => {
|
|
93
|
+
fp.loadedPlugins.push('carbonFlatpickrMonthSelectPlugin');
|
|
94
|
+
};
|
|
102
95
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
};
|
|
96
|
+
return {
|
|
97
|
+
onMonthChange: updateCurrentMonth,
|
|
98
|
+
onValueUpdate: updateCurrentMonth,
|
|
99
|
+
onOpen: updateCurrentMonth,
|
|
100
|
+
onReady: [setupElements, updateCurrentMonth, register]
|
|
109
101
|
};
|
|
110
102
|
};
|
|
111
103
|
/**
|
|
@@ -116,31 +108,33 @@ var carbonFlatpickrMonthSelectPlugin = function carbonFlatpickrMonthSelectPlugin
|
|
|
116
108
|
|
|
117
109
|
|
|
118
110
|
function isLabelTextEmpty(children) {
|
|
119
|
-
return children.every(
|
|
120
|
-
return !child.props.labelText;
|
|
121
|
-
});
|
|
111
|
+
return children.every(child => !child.props.labelText);
|
|
122
112
|
}
|
|
123
113
|
|
|
124
|
-
|
|
125
|
-
|
|
114
|
+
const rightArrowHTML = `<svg width="16px" height="16px" viewBox="0 0 16 16">
|
|
115
|
+
<polygon points="11,8 6,13 5.3,12.3 9.6,8 5.3,3.7 6,3 "/>
|
|
116
|
+
</svg>`;
|
|
117
|
+
const leftArrowHTML = `<svg width="16px" height="16px" viewBox="0 0 16 16">
|
|
118
|
+
<polygon points="5,8 10,3 10.7,3.7 6.4,8 10.7,12.3 10,13 "/>
|
|
119
|
+
</svg>`;
|
|
126
120
|
|
|
127
121
|
function updateClassNames(calendar, prefix) {
|
|
128
|
-
|
|
129
|
-
|
|
122
|
+
const calendarContainer = calendar.calendarContainer;
|
|
123
|
+
const daysContainer = calendar.days;
|
|
130
124
|
|
|
131
125
|
if (calendarContainer && daysContainer) {
|
|
132
126
|
// calendarContainer and daysContainer are undefined if flatpickr detects a mobile device
|
|
133
|
-
calendarContainer.classList.add(
|
|
134
|
-
calendarContainer.querySelector('.flatpickr-month').classList.add(
|
|
135
|
-
calendarContainer.querySelector('.flatpickr-weekdays').classList.add(
|
|
136
|
-
calendarContainer.querySelector('.flatpickr-days').classList.add(
|
|
137
|
-
forEach.call(calendarContainer.querySelectorAll('.flatpickr-weekday'),
|
|
138
|
-
|
|
127
|
+
calendarContainer.classList.add(`${prefix}--date-picker__calendar`);
|
|
128
|
+
calendarContainer.querySelector('.flatpickr-month').classList.add(`${prefix}--date-picker__month`);
|
|
129
|
+
calendarContainer.querySelector('.flatpickr-weekdays').classList.add(`${prefix}--date-picker__weekdays`);
|
|
130
|
+
calendarContainer.querySelector('.flatpickr-days').classList.add(`${prefix}--date-picker__days`);
|
|
131
|
+
forEach.call(calendarContainer.querySelectorAll('.flatpickr-weekday'), item => {
|
|
132
|
+
const currentItem = item;
|
|
139
133
|
currentItem.innerHTML = currentItem.innerHTML.replace(/\s+/g, '');
|
|
140
|
-
currentItem.classList.add(
|
|
134
|
+
currentItem.classList.add(`${prefix}--date-picker__weekday`);
|
|
141
135
|
});
|
|
142
|
-
forEach.call(daysContainer.querySelectorAll('.flatpickr-day'),
|
|
143
|
-
item.classList.add(
|
|
136
|
+
forEach.call(daysContainer.querySelectorAll('.flatpickr-day'), item => {
|
|
137
|
+
item.classList.add(`${prefix}--date-picker__day`);
|
|
144
138
|
|
|
145
139
|
if (item.classList.contains('today') && calendar.selectedDates.length > 0) {
|
|
146
140
|
item.classList.add('no-border');
|
|
@@ -151,113 +145,111 @@ function updateClassNames(calendar, prefix) {
|
|
|
151
145
|
}
|
|
152
146
|
}
|
|
153
147
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
var prefix = usePrefix();
|
|
190
|
-
|
|
191
|
-
var _useContext = useContext(FormContext),
|
|
192
|
-
isFluid = _useContext.isFluid;
|
|
193
|
-
|
|
194
|
-
var _useState = useState(false),
|
|
195
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
196
|
-
hasInput = _useState2[0],
|
|
197
|
-
setHasInput = _useState2[1];
|
|
198
|
-
|
|
199
|
-
var startInputField = useCallback(function (node) {
|
|
148
|
+
const DatePicker = /*#__PURE__*/React__default.forwardRef(function DatePicker(_ref, ref) {
|
|
149
|
+
let {
|
|
150
|
+
allowInput,
|
|
151
|
+
appendTo,
|
|
152
|
+
children,
|
|
153
|
+
className,
|
|
154
|
+
closeOnSelect = true,
|
|
155
|
+
dateFormat = 'm/d/Y',
|
|
156
|
+
datePickerType,
|
|
157
|
+
disable,
|
|
158
|
+
enable,
|
|
159
|
+
inline,
|
|
160
|
+
invalid,
|
|
161
|
+
invalidText,
|
|
162
|
+
warn,
|
|
163
|
+
warnText,
|
|
164
|
+
light = false,
|
|
165
|
+
locale = 'en',
|
|
166
|
+
maxDate,
|
|
167
|
+
minDate,
|
|
168
|
+
onChange,
|
|
169
|
+
onClose,
|
|
170
|
+
onOpen,
|
|
171
|
+
readOnly = false,
|
|
172
|
+
short = false,
|
|
173
|
+
value,
|
|
174
|
+
...rest
|
|
175
|
+
} = _ref;
|
|
176
|
+
const prefix = usePrefix();
|
|
177
|
+
const {
|
|
178
|
+
isFluid
|
|
179
|
+
} = useContext(FormContext);
|
|
180
|
+
const [hasInput, setHasInput] = useState(false);
|
|
181
|
+
const startInputField = useCallback(node => {
|
|
200
182
|
if (node !== null) {
|
|
201
183
|
startInputField.current = node;
|
|
202
184
|
setHasInput(true);
|
|
203
185
|
}
|
|
204
186
|
}, []);
|
|
205
|
-
|
|
206
|
-
var lastStartValue = useRef(''); // fix datepicker deleting the selectedDate when the calendar closes
|
|
187
|
+
const lastStartValue = useRef(''); // fix datepicker deleting the selectedDate when the calendar closes
|
|
207
188
|
|
|
208
|
-
|
|
209
|
-
setTimeout(
|
|
189
|
+
const onCalendarClose = (selectedDates, dateStr) => {
|
|
190
|
+
setTimeout(() => {
|
|
210
191
|
if (lastStartValue.current && selectedDates[0] && !startInputField.current.value) {
|
|
192
|
+
var _endInputField$curren;
|
|
193
|
+
|
|
211
194
|
startInputField.current.value = lastStartValue.current;
|
|
212
|
-
calendarRef.current.setDate([startInputField.current.value, endInputField.current.value], true, calendarRef.current.config.dateFormat);
|
|
195
|
+
calendarRef.current.setDate([startInputField.current.value, endInputField === null || endInputField === void 0 ? void 0 : (_endInputField$curren = endInputField.current) === null || _endInputField$curren === void 0 ? void 0 : _endInputField$curren.value], true, calendarRef.current.config.dateFormat);
|
|
213
196
|
}
|
|
214
197
|
|
|
215
198
|
if (onClose) {
|
|
216
199
|
onClose(calendarRef.current.selectedDates, dateStr, calendarRef.current);
|
|
217
200
|
}
|
|
218
201
|
});
|
|
219
|
-
};
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
202
|
+
}; //const savedOnOpen = useSavedCallback(onOpen);
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
const endInputField = useRef(null);
|
|
206
|
+
const calendarRef = useRef(null);
|
|
207
|
+
const savedOnChange = useSavedCallback(() => onChange);
|
|
208
|
+
const savedOnClose = useSavedCallback(datePickerType === 'range' ? onCalendarClose : onClose);
|
|
209
|
+
const savedOnOpen = useSavedCallback(() => onOpen);
|
|
210
|
+
const datePickerClasses = cx(`${prefix}--date-picker`, {
|
|
211
|
+
[`${prefix}--date-picker--short`]: short,
|
|
212
|
+
[`${prefix}--date-picker--light`]: light,
|
|
213
|
+
[`${prefix}--date-picker--simple`]: datePickerType === 'simple',
|
|
214
|
+
[`${prefix}--date-picker--single`]: datePickerType === 'single',
|
|
215
|
+
[`${prefix}--date-picker--range`]: datePickerType === 'range',
|
|
216
|
+
[`${prefix}--date-picker--nolabel`]: datePickerType === 'range' && isLabelTextEmpty(children)
|
|
217
|
+
});
|
|
218
|
+
const wrapperClasses = cx(`${prefix}--form-item`, {
|
|
219
|
+
[String(className)]: className
|
|
220
|
+
});
|
|
221
|
+
const childrenWithProps = React__default.Children.toArray(children).map((child, index) => {
|
|
228
222
|
if (index === 0 && child.type === React__default.createElement(DatePickerInput, child.props).type) {
|
|
229
223
|
return /*#__PURE__*/React__default.cloneElement(child, {
|
|
230
|
-
datePickerType
|
|
224
|
+
datePickerType,
|
|
231
225
|
ref: startInputField,
|
|
232
|
-
readOnly
|
|
226
|
+
readOnly
|
|
233
227
|
});
|
|
234
228
|
}
|
|
235
229
|
|
|
236
230
|
if (index === 1 && child.type === React__default.createElement(DatePickerInput, child.props).type) {
|
|
237
231
|
return /*#__PURE__*/React__default.cloneElement(child, {
|
|
238
|
-
datePickerType
|
|
232
|
+
datePickerType,
|
|
239
233
|
ref: endInputField,
|
|
240
|
-
readOnly
|
|
234
|
+
readOnly
|
|
241
235
|
});
|
|
242
236
|
}
|
|
243
237
|
|
|
244
238
|
if (index === 0) {
|
|
245
239
|
return /*#__PURE__*/React__default.cloneElement(child, {
|
|
246
240
|
ref: startInputField,
|
|
247
|
-
readOnly
|
|
241
|
+
readOnly
|
|
248
242
|
});
|
|
249
243
|
}
|
|
250
244
|
|
|
251
245
|
if (index === 1) {
|
|
252
246
|
return /*#__PURE__*/React__default.cloneElement(child, {
|
|
253
247
|
ref: endInputField,
|
|
254
|
-
readOnly
|
|
248
|
+
readOnly
|
|
255
249
|
});
|
|
256
250
|
}
|
|
257
251
|
});
|
|
258
|
-
useEffect(
|
|
259
|
-
var _flatpickr;
|
|
260
|
-
|
|
252
|
+
useEffect(() => {
|
|
261
253
|
if (datePickerType !== 'single' && datePickerType !== 'range') {
|
|
262
254
|
return;
|
|
263
255
|
}
|
|
@@ -266,7 +258,7 @@ var DatePicker = /*#__PURE__*/React__default.forwardRef(function DatePicker(_ref
|
|
|
266
258
|
return;
|
|
267
259
|
}
|
|
268
260
|
|
|
269
|
-
|
|
261
|
+
const onHook = (_electedDates, _dateStr, instance, prefix) => {
|
|
270
262
|
updateClassNames(instance, prefix);
|
|
271
263
|
|
|
272
264
|
if (startInputField !== null && startInputField !== void 0 && startInputField.current) {
|
|
@@ -280,8 +272,8 @@ var DatePicker = /*#__PURE__*/React__default.forwardRef(function DatePicker(_ref
|
|
|
280
272
|
// is provided, we return the default empty disabled array, allowing all dates.
|
|
281
273
|
|
|
282
274
|
|
|
283
|
-
|
|
284
|
-
|
|
275
|
+
const enableOrDisable = enable ? 'enable' : 'disable';
|
|
276
|
+
let enableOrDisableArr;
|
|
285
277
|
|
|
286
278
|
if (!enable && !disable) {
|
|
287
279
|
enableOrDisableArr = [];
|
|
@@ -291,47 +283,69 @@ var DatePicker = /*#__PURE__*/React__default.forwardRef(function DatePicker(_ref
|
|
|
291
283
|
enableOrDisableArr = disable;
|
|
292
284
|
}
|
|
293
285
|
|
|
294
|
-
|
|
286
|
+
let localeData;
|
|
295
287
|
|
|
296
|
-
if (
|
|
297
|
-
|
|
298
|
-
localeData =
|
|
288
|
+
if (typeof locale === 'object') {
|
|
289
|
+
const location = locale.locale ? locale.locale : 'en';
|
|
290
|
+
localeData = { ...l10n[location],
|
|
291
|
+
...locale
|
|
292
|
+
};
|
|
299
293
|
} else {
|
|
300
294
|
localeData = l10n[locale];
|
|
301
295
|
}
|
|
302
296
|
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
297
|
+
const {
|
|
298
|
+
current: start
|
|
299
|
+
} = startInputField;
|
|
300
|
+
const {
|
|
301
|
+
current: end
|
|
302
|
+
} = endInputField;
|
|
303
|
+
const flatpickerconfig = {
|
|
304
|
+
inline: inline ?? false,
|
|
307
305
|
disableMobile: true,
|
|
308
306
|
defaultDate: value,
|
|
309
307
|
closeOnSelect: closeOnSelect,
|
|
310
308
|
mode: datePickerType,
|
|
311
|
-
allowInput: allowInput
|
|
309
|
+
allowInput: allowInput ?? true,
|
|
312
310
|
dateFormat: dateFormat,
|
|
313
|
-
locale: localeData
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
311
|
+
locale: localeData,
|
|
312
|
+
[enableOrDisable]: enableOrDisableArr,
|
|
313
|
+
minDate: minDate,
|
|
314
|
+
maxDate: maxDate,
|
|
315
|
+
plugins: [datePickerType === 'range' ? carbonFlatpickrRangePlugin({
|
|
316
|
+
input: endInputField.current
|
|
317
|
+
}) : () => {}, appendTo ? carbonFlatpickrAppendToPlugin({
|
|
318
|
+
appendTo
|
|
319
|
+
}) : () => {}, carbonFlatpickrMonthSelectPlugin({
|
|
320
|
+
selectorFlatpickrMonthYearContainer: '.flatpickr-current-month',
|
|
321
|
+
selectorFlatpickrYearContainer: '.numInputWrapper',
|
|
322
|
+
selectorFlatpickrCurrentMonth: '.cur-month',
|
|
323
|
+
classFlatpickrCurrentMonth: 'cur-month'
|
|
324
|
+
}), carbonFlatpickrFixEventsPlugin({
|
|
325
|
+
inputFrom: startInputField.current,
|
|
326
|
+
inputTo: endInputField.current,
|
|
327
|
+
lastStartValue
|
|
328
|
+
})],
|
|
329
|
+
clickOpens: !readOnly,
|
|
330
|
+
noCalendar: readOnly,
|
|
331
|
+
nextArrow: rightArrowHTML,
|
|
332
|
+
prevArrow: leftArrowHTML,
|
|
333
|
+
onChange: function () {
|
|
334
|
+
if (savedOnChange && !readOnly) {
|
|
335
|
+
savedOnChange(...arguments);
|
|
336
|
+
}
|
|
337
|
+
},
|
|
338
|
+
onClose: savedOnClose,
|
|
339
|
+
onReady: onHook,
|
|
340
|
+
onMonthChange: onHook,
|
|
341
|
+
onYearChange: onHook,
|
|
342
|
+
onOpen: function () {
|
|
343
|
+
onHook(...arguments);
|
|
344
|
+
savedOnOpen(...arguments);
|
|
345
|
+
},
|
|
346
|
+
onValueUpdate: onHook
|
|
347
|
+
};
|
|
348
|
+
const calendar = flatpickr(start, flatpickerconfig);
|
|
335
349
|
calendarRef.current = calendar;
|
|
336
350
|
|
|
337
351
|
function handleArrowDown(event) {
|
|
@@ -340,11 +354,13 @@ var DatePicker = /*#__PURE__*/React__default.forwardRef(function DatePicker(_ref
|
|
|
340
354
|
}
|
|
341
355
|
|
|
342
356
|
if (match(event, ArrowDown)) {
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
357
|
+
const {
|
|
358
|
+
calendarContainer,
|
|
359
|
+
selectedDateElem: fpSelectedDateElem,
|
|
360
|
+
todayDateElem: fptodayDateElem
|
|
361
|
+
} = calendar;
|
|
362
|
+
const selectedDateElem = calendarContainer.querySelector('.selected') && fpSelectedDateElem;
|
|
363
|
+
const todayDateElem = calendarContainer.querySelector('.today') && fptodayDateElem;
|
|
348
364
|
(selectedDateElem || todayDateElem || calendarContainer.querySelector('.flatpickr-day[tabindex]') || calendarContainer).focus();
|
|
349
365
|
}
|
|
350
366
|
}
|
|
@@ -354,7 +370,9 @@ var DatePicker = /*#__PURE__*/React__default.forwardRef(function DatePicker(_ref
|
|
|
354
370
|
calendar.calendarContainer.classList.remove('open');
|
|
355
371
|
}
|
|
356
372
|
|
|
357
|
-
|
|
373
|
+
const {
|
|
374
|
+
target
|
|
375
|
+
} = event;
|
|
358
376
|
|
|
359
377
|
if (target === start) {
|
|
360
378
|
lastStartValue.current = start.value;
|
|
@@ -396,7 +414,7 @@ var DatePicker = /*#__PURE__*/React__default.forwardRef(function DatePicker(_ref
|
|
|
396
414
|
} //component did unmount equivalent
|
|
397
415
|
|
|
398
416
|
|
|
399
|
-
return
|
|
417
|
+
return () => {
|
|
400
418
|
// Note: if the `startInputField` ref is undefined then calendar will be
|
|
401
419
|
// of type: Array and `destroy` will not be defined
|
|
402
420
|
if (calendar && calendar.destroy) {
|
|
@@ -430,59 +448,57 @@ var DatePicker = /*#__PURE__*/React__default.forwardRef(function DatePicker(_ref
|
|
|
430
448
|
// instance for cases where functions like open() or close()
|
|
431
449
|
// need to be imperatively called on the calendar
|
|
432
450
|
|
|
433
|
-
useImperativeHandle(ref,
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
}
|
|
451
|
+
useImperativeHandle(ref, () => ({
|
|
452
|
+
get calendar() {
|
|
453
|
+
return calendarRef.current;
|
|
454
|
+
}
|
|
438
455
|
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
useEffect(function () {
|
|
456
|
+
}));
|
|
457
|
+
useEffect(() => {
|
|
442
458
|
var _calendarRef$current;
|
|
443
459
|
|
|
444
460
|
if (calendarRef !== null && calendarRef !== void 0 && (_calendarRef$current = calendarRef.current) !== null && _calendarRef$current !== void 0 && _calendarRef$current.set) {
|
|
445
461
|
calendarRef.current.set({
|
|
446
|
-
dateFormat
|
|
462
|
+
dateFormat
|
|
447
463
|
});
|
|
448
464
|
}
|
|
449
465
|
}, [dateFormat]);
|
|
450
|
-
useEffect(
|
|
466
|
+
useEffect(() => {
|
|
451
467
|
var _calendarRef$current2;
|
|
452
468
|
|
|
453
469
|
if (calendarRef !== null && calendarRef !== void 0 && (_calendarRef$current2 = calendarRef.current) !== null && _calendarRef$current2 !== void 0 && _calendarRef$current2.set) {
|
|
454
470
|
calendarRef.current.set('minDate', minDate);
|
|
455
471
|
}
|
|
456
472
|
}, [minDate]);
|
|
457
|
-
useEffect(
|
|
473
|
+
useEffect(() => {
|
|
458
474
|
var _calendarRef$current3;
|
|
459
475
|
|
|
460
476
|
if (calendarRef !== null && calendarRef !== void 0 && (_calendarRef$current3 = calendarRef.current) !== null && _calendarRef$current3 !== void 0 && _calendarRef$current3.set) {
|
|
461
477
|
calendarRef.current.set('maxDate', maxDate);
|
|
462
478
|
}
|
|
463
479
|
}, [maxDate]);
|
|
464
|
-
useEffect(
|
|
480
|
+
useEffect(() => {
|
|
465
481
|
var _calendarRef$current4;
|
|
466
482
|
|
|
467
483
|
if (calendarRef !== null && calendarRef !== void 0 && (_calendarRef$current4 = calendarRef.current) !== null && _calendarRef$current4 !== void 0 && _calendarRef$current4.set && disable) {
|
|
468
484
|
calendarRef.current.set('disable', disable);
|
|
469
485
|
}
|
|
470
486
|
}, [disable]);
|
|
471
|
-
useEffect(
|
|
487
|
+
useEffect(() => {
|
|
472
488
|
var _calendarRef$current5;
|
|
473
489
|
|
|
474
490
|
if (calendarRef !== null && calendarRef !== void 0 && (_calendarRef$current5 = calendarRef.current) !== null && _calendarRef$current5 !== void 0 && _calendarRef$current5.set && enable) {
|
|
475
491
|
calendarRef.current.set('enable', enable);
|
|
476
492
|
}
|
|
477
493
|
}, [enable]);
|
|
478
|
-
useEffect(
|
|
494
|
+
useEffect(() => {
|
|
479
495
|
var _calendarRef$current6;
|
|
480
496
|
|
|
481
497
|
if (calendarRef !== null && calendarRef !== void 0 && (_calendarRef$current6 = calendarRef.current) !== null && _calendarRef$current6 !== void 0 && _calendarRef$current6.set && inline) {
|
|
482
498
|
calendarRef.current.set('inline', inline);
|
|
483
499
|
}
|
|
484
500
|
}, [inline]);
|
|
485
|
-
useEffect(
|
|
501
|
+
useEffect(() => {
|
|
486
502
|
var _calendarRef$current7;
|
|
487
503
|
|
|
488
504
|
if (calendarRef !== null && calendarRef !== void 0 && (_calendarRef$current7 = calendarRef.current) !== null && _calendarRef$current7 !== void 0 && _calendarRef$current7.set) {
|
|
@@ -496,26 +512,26 @@ var DatePicker = /*#__PURE__*/React__default.forwardRef(function DatePicker(_ref
|
|
|
496
512
|
}
|
|
497
513
|
}, [value, prefix]); //eslint-disable-line react-hooks/exhaustive-deps
|
|
498
514
|
|
|
499
|
-
|
|
515
|
+
let fluidError;
|
|
500
516
|
|
|
501
517
|
if (isFluid) {
|
|
502
518
|
if (invalid) {
|
|
503
519
|
fluidError = /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(WarningFilled, {
|
|
504
|
-
className:
|
|
520
|
+
className: `${prefix}--date-picker__icon ${prefix}--date-picker__icon--invalid`
|
|
505
521
|
}), /*#__PURE__*/React__default.createElement("hr", {
|
|
506
|
-
className:
|
|
522
|
+
className: `${prefix}--date-picker__divider`
|
|
507
523
|
}), /*#__PURE__*/React__default.createElement("div", {
|
|
508
|
-
className:
|
|
524
|
+
className: `${prefix}--form-requirement`
|
|
509
525
|
}, invalidText));
|
|
510
526
|
}
|
|
511
527
|
|
|
512
528
|
if (warn && !invalid) {
|
|
513
529
|
fluidError = /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(WarningAltFilled, {
|
|
514
|
-
className:
|
|
530
|
+
className: `${prefix}--date-picker__icon ${prefix}--date-picker__icon--warn`
|
|
515
531
|
}), /*#__PURE__*/React__default.createElement("hr", {
|
|
516
|
-
className:
|
|
532
|
+
className: `${prefix}--date-picker__divider`
|
|
517
533
|
}), /*#__PURE__*/React__default.createElement("div", {
|
|
518
|
-
className:
|
|
534
|
+
className: `${prefix}--form-requirement`
|
|
519
535
|
}, warnText));
|
|
520
536
|
}
|
|
521
537
|
}
|
|
@@ -717,6 +733,5 @@ DatePicker.propTypes = {
|
|
|
717
733
|
*/
|
|
718
734
|
warnText: PropTypes.node
|
|
719
735
|
};
|
|
720
|
-
var DatePicker$1 = DatePicker;
|
|
721
736
|
|
|
722
|
-
export { DatePicker
|
|
737
|
+
export { DatePicker as default };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2016, 2023
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import DatePicker from './DatePicker';
|
|
8
|
+
export { default as DatePickerSkeleton, type DatePickerSkeletonProps, } from './DatePicker.Skeleton';
|
|
9
|
+
export default DatePicker;
|
|
10
|
+
export { DatePicker };
|