@carbon/react 1.29.0 → 1.30.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/_virtual/_rollupPluginBabelHelpers.js +16 -5
- package/es/components/Accordion/Accordion.Skeleton.js +0 -7
- package/es/components/Accordion/Accordion.js +1 -8
- package/es/components/Accordion/AccordionItem.js +5 -19
- package/es/components/AspectRatio/AspectRatio.js +0 -5
- package/es/components/Breadcrumb/Breadcrumb.Skeleton.js +0 -3
- package/es/components/Breadcrumb/Breadcrumb.js +0 -3
- package/es/components/Breadcrumb/BreadcrumbItem.js +0 -7
- package/es/components/Button/Button.Skeleton.js +2 -7
- package/es/components/Button/Button.js +2 -36
- package/es/components/ButtonSet/ButtonSet.js +0 -2
- package/es/components/Checkbox/Checkbox.Skeleton.js +0 -1
- package/es/components/Checkbox/Checkbox.js +4 -20
- package/es/components/CheckboxGroup/CheckboxGroup.js +0 -11
- package/es/components/ClassPrefix/index.d.ts +26 -0
- package/es/components/ClassPrefix/index.js +0 -2
- package/es/components/CodeSnippet/CodeSnippet.Skeleton.js +0 -5
- package/es/components/CodeSnippet/CodeSnippet.js +6 -45
- package/es/components/ComboBox/ComboBox.js +12 -79
- package/es/components/ComboBox/tools/filter.js +0 -1
- package/es/components/ComboButton/index.js +0 -14
- package/es/components/ComposedModal/ComposedModal.js +2 -32
- package/es/components/ComposedModal/ModalFooter.js +0 -21
- package/es/components/ComposedModal/ModalHeader.js +0 -12
- package/es/components/ContainedList/ContainedList.js +5 -32
- package/es/components/ContainedList/ContainedListItem/ContainedListItem.js +0 -6
- package/es/components/ContentSwitcher/ContentSwitcher.js +11 -23
- package/es/components/ContextMenu/useContextMenu.js +1 -6
- package/es/components/Copy/Copy.js +8 -31
- package/es/components/CopyButton/CopyButton.js +0 -4
- package/es/components/DangerButton/DangerButton.js +0 -1
- package/es/components/DataTable/DataTable.js +171 -91
- package/es/components/DataTable/Table.js +0 -6
- package/es/components/DataTable/TableBatchAction.js +0 -4
- package/es/components/DataTable/TableBatchActions.js +0 -8
- package/es/components/DataTable/TableBody.js +0 -1
- package/es/components/DataTable/TableContainer.js +0 -5
- package/es/components/DataTable/TableExpandHeader.js +0 -7
- package/es/components/DataTable/TableExpandRow.js +0 -6
- package/es/components/DataTable/TableExpandedRow.js +0 -6
- package/es/components/DataTable/TableHeader.d.ts +1 -1
- package/es/components/DataTable/TableHeader.js +3 -19
- package/es/components/DataTable/TableRow.js +4 -5
- package/es/components/DataTable/TableSelectAll.js +0 -8
- package/es/components/DataTable/TableSelectRow.js +2 -10
- package/es/components/DataTable/TableToolbar.js +0 -3
- package/es/components/DataTable/TableToolbarMenu.d.ts +1 -1
- package/es/components/DataTable/TableToolbarMenu.js +3 -6
- package/es/components/DataTable/TableToolbarSearch.js +2 -30
- package/es/components/DataTable/state/getDerivedStateFromProps.js +0 -4
- package/es/components/DataTable/state/sorting.js +5 -8
- package/es/components/DataTable/tools/denormalize.js +2 -2
- package/es/components/DataTable/tools/filter.js +0 -2
- package/es/components/DataTable/tools/instanceId.js +0 -1
- package/es/components/DataTable/tools/normalize.js +10 -10
- package/es/components/DataTable/tools/sorting.js +5 -13
- package/es/components/DataTableSkeleton/DataTableSkeleton.js +5 -20
- package/es/components/DatePicker/DatePicker.Skeleton.js +0 -6
- package/es/components/DatePicker/DatePicker.js +154 -177
- package/es/components/DatePicker/plugins/appendToPlugin.js +3 -7
- package/es/components/DatePicker/plugins/fixEventsPlugin.js +14 -25
- package/es/components/DatePicker/plugins/rangePlugin.js +2 -7
- package/es/components/DatePickerInput/DatePickerInput.js +2 -28
- package/es/components/Dropdown/Dropdown.Skeleton.js +0 -2
- package/es/components/Dropdown/Dropdown.js +43 -52
- package/es/components/ErrorBoundary/ErrorBoundary.js +0 -10
- package/es/components/ErrorBoundary/ErrorBoundaryContext.js +0 -1
- package/es/components/ExpandableSearch/ExpandableSearch.js +1 -10
- package/es/components/FeatureFlags/index.js +8 -20
- package/es/components/FileUploader/FileUploader.Skeleton.js +0 -2
- package/es/components/FileUploader/FileUploader.js +3 -38
- package/es/components/FileUploader/FileUploaderButton.js +3 -24
- package/es/components/FileUploader/FileUploaderDropContainer.js +1 -28
- package/es/components/FileUploader/FileUploaderItem.js +1 -11
- package/es/components/FileUploader/Filename.js +0 -10
- package/es/components/FluidComboBox/FluidComboBox.Skeleton.js +0 -1
- package/es/components/FluidComboBox/FluidComboBox.js +0 -18
- package/es/components/FluidDatePicker/FluidDatePicker.Skeleton.js +0 -2
- package/es/components/FluidDatePicker/FluidDatePicker.js +0 -6
- package/es/components/FluidDatePickerInput/FluidDatePickerInput.js +2 -1
- package/es/components/FluidDropdown/FluidDropdown.Skeleton.js +0 -1
- package/es/components/FluidDropdown/FluidDropdown.js +0 -18
- package/es/components/FluidForm/FluidForm.js +0 -2
- package/es/components/FluidMultiSelect/FluidMultiSelect.Skeleton.js +0 -1
- package/es/components/FluidMultiSelect/FluidMultiSelect.js +0 -19
- package/es/components/FluidSelect/FluidSelect.Skeleton.js +0 -1
- package/es/components/FluidSelect/FluidSelect.js +0 -10
- package/es/components/FluidTextArea/FluidTextArea.Skeleton.js +0 -1
- package/es/components/FluidTextArea/FluidTextArea.js +0 -20
- package/es/components/FluidTextInput/FluidTextInput.Skeleton.js +0 -1
- package/es/components/FluidTextInput/FluidTextInput.js +0 -14
- package/es/components/FluidTimePicker/FluidTimePicker.Skeleton.js +0 -3
- package/es/components/FluidTimePicker/FluidTimePicker.js +1 -11
- package/es/components/FluidTimePickerSelect/FluidTimePickerSelect.js +0 -6
- package/es/components/Form/Form.d.ts +23 -0
- package/es/components/Form/Form.js +3 -6
- package/es/components/Form/index.d.ts +7 -0
- package/es/components/FormGroup/FormGroup.js +0 -7
- package/es/components/FormItem/FormItem.js +0 -2
- package/es/components/FormLabel/FormLabel.js +1 -7
- package/es/components/Grid/CSSGrid.js +2 -15
- package/es/components/Grid/Column.js +18 -59
- package/es/components/Grid/ColumnHang.js +2 -5
- package/es/components/Grid/FlexGrid.js +2 -8
- package/es/components/Grid/Grid.js +0 -8
- package/es/components/Grid/GridContext.js +1 -3
- package/es/components/Grid/Row.js +2 -7
- package/es/components/Heading/index.js +0 -4
- package/es/components/Icon/Icon.Skeleton.js +2 -2
- package/es/components/IconButton/index.js +0 -10
- package/es/components/IdPrefix/index.js +0 -2
- package/es/components/InlineCheckbox/InlineCheckbox.js +0 -14
- package/es/components/InlineLoading/InlineLoading.js +0 -12
- package/es/components/Layer/index.js +3 -6
- package/es/components/Layout/LayoutDirection.js +0 -3
- package/es/components/Layout/useLayoutDirection.js +0 -1
- package/es/components/Link/Link.js +3 -10
- package/es/components/ListBox/ListBox.js +2 -13
- package/es/components/ListBox/ListBoxField.js +0 -5
- package/es/components/ListBox/ListBoxMenuIcon.js +0 -4
- package/es/components/ListBox/ListBoxMenuItem.js +2 -6
- package/es/components/ListBox/ListBoxPropTypes.d.ts +2 -2
- package/es/components/ListBox/ListBoxSelection.js +1 -13
- package/es/components/ListBox/next/ListBoxSelection.js +1 -14
- package/es/components/ListBox/next/ListBoxTrigger.js +1 -3
- package/es/components/ListItem/ListItem.d.ts +23 -0
- package/es/components/ListItem/ListItem.js +4 -8
- package/es/components/ListItem/index.d.ts +7 -0
- package/es/components/Loading/Loading.js +0 -6
- package/es/components/Menu/Menu.js +22 -40
- package/es/components/Menu/MenuContext.js +4 -5
- package/es/components/Menu/MenuItem.js +5 -39
- package/es/components/MenuButton/index.js +0 -9
- package/es/components/Modal/Modal.js +0 -43
- package/es/components/ModalWrapper/ModalWrapper.js +2 -15
- package/es/components/MultiSelect/FilterableMultiSelect.js +2 -60
- package/es/components/MultiSelect/MultiSelect.js +22 -70
- package/es/components/MultiSelect/MultiSelectPropTypes.js +0 -1
- package/es/components/MultiSelect/index.js +0 -1
- package/es/components/MultiSelect/tools/itemToString.js +0 -2
- package/es/components/MultiSelect/tools/sorting.js +3 -4
- package/es/components/Notification/Notification.js +0 -78
- package/es/components/NumberInput/NumberInput.Skeleton.js +0 -2
- package/es/components/NumberInput/NumberInput.js +3 -60
- package/es/components/OrderedList/OrderedList.d.ts +39 -0
- package/es/components/OrderedList/OrderedList.js +7 -19
- package/es/components/{Form/index.js → OrderedList/index.d.ts} +1 -3
- package/es/components/OverflowMenu/OverflowMenu.js +65 -86
- package/es/components/OverflowMenuItem/OverflowMenuItem.js +6 -23
- package/es/components/OverflowMenuV2/index.js +0 -5
- package/es/components/Pagination/Pagination.Skeleton.js +0 -2
- package/es/components/Pagination/Pagination.js +11 -47
- package/es/components/Pagination/experimental/PageSelector.js +0 -10
- package/es/components/Pagination/experimental/Pagination.js +2 -48
- package/es/components/PaginationNav/PaginationNav.js +15 -59
- package/es/components/Popover/index.d.ts +14 -8
- package/es/components/Popover/index.js +44 -48
- package/es/components/PrimaryButton/PrimaryButton.js +0 -1
- package/es/components/ProgressBar/ProgressBar.js +0 -15
- package/es/components/ProgressIndicator/ProgressIndicator.Skeleton.js +0 -4
- package/es/components/ProgressIndicator/ProgressIndicator.js +2 -40
- package/es/components/RadioButton/RadioButton.Skeleton.js +0 -1
- package/es/components/RadioButton/RadioButton.js +0 -13
- package/es/components/RadioButtonGroup/RadioButtonGroup.js +3 -23
- package/es/components/RadioTile/RadioTile.js +0 -12
- package/es/components/Search/Search.Skeleton.js +0 -2
- package/es/components/Search/Search.js +1 -28
- package/es/components/SecondaryButton/SecondaryButton.js +0 -1
- package/es/components/Select/Select.Skeleton.js +0 -2
- package/es/components/Select/Select.d.ts +1 -1
- package/es/components/Select/Select.js +6 -33
- package/es/components/SelectItem/SelectItem.js +0 -5
- package/es/components/SelectItemGroup/SelectItemGroup.d.ts +0 -1
- package/es/components/SelectItemGroup/SelectItemGroup.js +1 -7
- package/es/components/SkeletonIcon/SkeletonIcon.js +0 -2
- package/es/components/SkeletonPlaceholder/SkeletonPlaceholder.js +0 -1
- package/es/components/SkeletonText/SkeletonText.js +0 -12
- package/es/components/Slider/Slider.Skeleton.js +0 -2
- package/es/components/Slider/Slider.d.ts +0 -1
- package/es/components/Slider/Slider.js +112 -135
- package/es/components/Stack/Stack.js +1 -8
- package/es/components/StructuredList/StructuredList.Skeleton.js +0 -5
- package/es/components/StructuredList/StructuredList.js +1 -25
- package/es/components/Switch/IconSwitch.js +0 -18
- package/es/components/Switch/Switch.js +0 -11
- package/es/components/TabContent/TabContent.js +2 -6
- package/es/components/Tabs/Tabs.Skeleton.js +0 -4
- package/es/components/Tabs/Tabs.js +135 -104
- package/es/components/Tabs/usePressable.js +18 -31
- package/es/components/Tag/Tag.Skeleton.js +0 -2
- package/es/components/Tag/Tag.js +0 -15
- package/es/components/Text/Text.js +5 -18
- package/es/components/Text/TextDirection.js +0 -3
- package/es/components/Text/TextDirectionContext.js +0 -1
- package/es/components/Text/createTextComponent.js +0 -3
- package/es/components/TextArea/TextArea.Skeleton.js +0 -2
- package/es/components/TextArea/TextArea.js +11 -33
- package/es/components/TextInput/ControlledPasswordInput.js +0 -20
- package/es/components/TextInput/PasswordInput.js +0 -25
- package/es/components/TextInput/TextInput.Skeleton.js +0 -2
- package/es/components/TextInput/TextInput.d.ts +1 -1
- package/es/components/TextInput/TextInput.js +5 -33
- package/es/components/TextInput/util.js +3 -5
- package/es/components/Theme/index.js +1 -6
- package/es/components/Tile/Tile.js +32 -59
- package/es/components/TileGroup/TileGroup.js +1 -22
- package/es/components/TimePicker/TimePicker.js +6 -32
- package/es/components/TimePickerSelect/TimePickerSelect.js +2 -5
- package/es/components/Toggle/Toggle.Skeleton.js +0 -8
- package/es/components/Toggle/Toggle.js +0 -16
- package/es/components/ToggleSmall/ToggleSmall.Skeleton.js +0 -7
- package/es/components/Toggletip/index.d.ts +148 -0
- package/es/components/Toggletip/index.js +20 -44
- package/es/components/Tooltip/DefinitionTooltip.js +0 -11
- package/es/components/Tooltip/Tooltip.d.ts +1 -1
- package/es/components/Tooltip/Tooltip.js +4 -21
- package/es/components/TreeView/TreeNode.js +21 -66
- package/es/components/TreeView/TreeView.js +11 -67
- package/es/components/UIShell/Content.js +2 -4
- package/es/components/UIShell/Header.js +0 -2
- package/es/components/UIShell/HeaderContainer.d.ts +33 -0
- package/es/components/UIShell/HeaderContainer.js +13 -11
- package/es/components/UIShell/HeaderGlobalAction.js +0 -6
- package/es/components/UIShell/HeaderGlobalBar.js +0 -1
- package/es/components/UIShell/HeaderMenu.js +32 -31
- package/es/components/UIShell/HeaderMenuButton.js +2 -4
- package/es/components/UIShell/HeaderMenuItem.js +0 -8
- package/es/components/UIShell/HeaderName.js +0 -5
- package/es/components/UIShell/HeaderNavigation.js +0 -2
- package/es/components/UIShell/HeaderPanel.js +0 -2
- package/es/components/UIShell/HeaderSideNavItems.js +0 -2
- package/es/components/UIShell/Link.js +2 -3
- package/es/components/UIShell/SideNav.d.ts +3 -1
- package/es/components/UIShell/SideNav.js +44 -36
- package/es/components/UIShell/SideNavDetails.js +0 -3
- package/es/components/UIShell/SideNavDivider.js +0 -1
- package/es/components/UIShell/SideNavFooter.js +1 -4
- package/es/components/UIShell/SideNavHeader.js +0 -4
- package/es/components/UIShell/SideNavIcon.js +0 -3
- package/es/components/UIShell/SideNavItem.js +0 -3
- package/es/components/UIShell/SideNavItems.js +2 -6
- package/es/components/UIShell/SideNavLink.js +3 -7
- package/es/components/UIShell/SideNavLinkText.js +0 -2
- package/es/components/UIShell/SideNavMenu.js +0 -16
- package/es/components/UIShell/SideNavMenuItem.js +0 -2
- package/es/components/UIShell/SideNavSwitcher.js +2 -5
- package/es/components/UIShell/SkipToContent.d.ts +32 -0
- package/es/components/UIShell/SkipToContent.js +8 -15
- package/es/components/UIShell/Switcher.js +0 -2
- package/es/components/UIShell/SwitcherDivider.js +0 -1
- package/es/components/UIShell/SwitcherItem.js +0 -3
- package/es/components/UnorderedList/UnorderedList.d.ts +34 -0
- package/es/components/UnorderedList/UnorderedList.js +6 -16
- package/es/components/UnorderedList/index.d.ts +7 -0
- package/es/index.js +7 -8
- package/es/internal/ClickListener.js +3 -13
- package/es/internal/FloatingMenu.js +57 -63
- package/es/internal/OptimizedResize.js +6 -12
- package/es/internal/Selection.js +2 -25
- package/es/internal/createClassWrapper.js +0 -2
- package/es/internal/deprecateFieldOnObject.js +0 -4
- package/es/internal/focus/index.js +0 -1
- package/es/internal/keyboard/keys.js +2 -1
- package/es/internal/keyboard/match.js +1 -6
- package/es/internal/keyboard/navigation.js +8 -7
- package/es/internal/useAnnouncer.js +0 -1
- package/es/internal/useAttachedMenu.js +1 -9
- package/es/internal/useControllableState.js +6 -13
- package/es/internal/useDelayedState.js +2 -4
- package/es/internal/useEffectOnce.js +0 -1
- package/es/internal/useEvent.js +61 -3
- package/es/internal/useId.js +2 -5
- package/es/internal/useIsomorphicEffect.js +1 -0
- package/es/internal/useMergedRefs.js +2 -2
- package/es/internal/useNoInteractiveChildren.js +2 -13
- package/es/internal/useNormalizedInputProps.js +0 -3
- package/es/internal/useSavedCallback.js +1 -2
- package/es/internal/warning.js +0 -3
- package/es/internal/wrapFocus.js +1 -8
- package/es/prop-types/deprecate.js +2 -5
- package/es/prop-types/isRequiredOneOf.js +2 -5
- package/es/prop-types/requiredIfGivenPropIsTruthy.js +0 -2
- package/es/tools/array.js +0 -3
- package/es/tools/events.js +0 -3
- package/es/tools/mergeRefs.js +0 -2
- package/es/tools/wrapComponent.js +2 -5
- package/lib/_virtual/_rollupPluginBabelHelpers.js +17 -4
- package/lib/components/Accordion/Accordion.Skeleton.js +0 -7
- package/lib/components/Accordion/Accordion.js +1 -27
- package/lib/components/Accordion/AccordionItem.js +5 -19
- package/lib/components/AspectRatio/AspectRatio.js +0 -5
- package/lib/components/Breadcrumb/Breadcrumb.Skeleton.js +0 -3
- package/lib/components/Breadcrumb/Breadcrumb.js +0 -3
- package/lib/components/Breadcrumb/BreadcrumbItem.js +0 -7
- package/lib/components/Button/Button.Skeleton.js +2 -26
- package/lib/components/Button/Button.js +2 -36
- package/lib/components/ButtonSet/ButtonSet.js +0 -2
- package/lib/components/Checkbox/Checkbox.Skeleton.js +0 -1
- package/lib/components/Checkbox/Checkbox.js +4 -20
- package/lib/components/CheckboxGroup/CheckboxGroup.js +0 -11
- package/lib/components/ClassPrefix/index.d.ts +26 -0
- package/lib/components/ClassPrefix/index.js +0 -2
- package/lib/components/CodeSnippet/CodeSnippet.Skeleton.js +0 -5
- package/lib/components/CodeSnippet/CodeSnippet.js +6 -45
- package/lib/components/ComboBox/ComboBox.js +19 -86
- package/lib/components/ComboBox/tools/filter.js +0 -1
- package/lib/components/ComboButton/index.js +0 -14
- package/lib/components/ComposedModal/ComposedModal.js +2 -32
- package/lib/components/ComposedModal/ModalFooter.js +0 -21
- package/lib/components/ComposedModal/ModalHeader.js +0 -12
- package/lib/components/ContainedList/ContainedList.js +5 -32
- package/lib/components/ContainedList/ContainedListItem/ContainedListItem.js +0 -6
- package/lib/components/ContentSwitcher/ContentSwitcher.js +11 -23
- package/lib/components/ContextMenu/useContextMenu.js +1 -6
- package/lib/components/Copy/Copy.js +8 -50
- package/lib/components/CopyButton/CopyButton.js +0 -4
- package/lib/components/DangerButton/DangerButton.js +0 -1
- package/lib/components/DataTable/DataTable.js +171 -91
- package/lib/components/DataTable/Table.js +0 -6
- package/lib/components/DataTable/TableBatchAction.js +0 -4
- package/lib/components/DataTable/TableBatchActions.js +0 -8
- package/lib/components/DataTable/TableBody.js +0 -1
- package/lib/components/DataTable/TableContainer.js +0 -5
- package/lib/components/DataTable/TableExpandHeader.js +0 -7
- package/lib/components/DataTable/TableExpandRow.js +0 -6
- package/lib/components/DataTable/TableExpandedRow.js +0 -6
- package/lib/components/DataTable/TableHeader.d.ts +1 -1
- package/lib/components/DataTable/TableHeader.js +3 -19
- package/lib/components/DataTable/TableRow.js +4 -5
- package/lib/components/DataTable/TableSelectAll.js +0 -8
- package/lib/components/DataTable/TableSelectRow.js +2 -10
- package/lib/components/DataTable/TableToolbar.js +0 -3
- package/lib/components/DataTable/TableToolbarMenu.d.ts +1 -1
- package/lib/components/DataTable/TableToolbarMenu.js +3 -6
- package/lib/components/DataTable/TableToolbarSearch.js +2 -30
- package/lib/components/DataTable/state/getDerivedStateFromProps.js +0 -4
- package/lib/components/DataTable/state/sorting.js +5 -8
- package/lib/components/DataTable/tools/denormalize.js +2 -2
- package/lib/components/DataTable/tools/filter.js +0 -2
- package/lib/components/DataTable/tools/instanceId.js +0 -1
- package/lib/components/DataTable/tools/normalize.js +10 -10
- package/lib/components/DataTable/tools/sorting.js +5 -13
- package/lib/components/DataTableSkeleton/DataTableSkeleton.js +5 -20
- package/lib/components/DatePicker/DatePicker.Skeleton.js +0 -6
- package/lib/components/DatePicker/DatePicker.js +154 -177
- package/lib/components/DatePicker/plugins/appendToPlugin.js +3 -7
- package/lib/components/DatePicker/plugins/fixEventsPlugin.js +14 -25
- package/lib/components/DatePicker/plugins/rangePlugin.js +2 -7
- package/lib/components/DatePickerInput/DatePickerInput.js +2 -28
- package/lib/components/Dropdown/Dropdown.Skeleton.js +0 -2
- package/lib/components/Dropdown/Dropdown.js +50 -59
- package/lib/components/ErrorBoundary/ErrorBoundary.js +0 -10
- package/lib/components/ErrorBoundary/ErrorBoundaryContext.js +0 -1
- package/lib/components/ExpandableSearch/ExpandableSearch.js +1 -10
- package/lib/components/FeatureFlags/index.js +8 -20
- package/lib/components/FileUploader/FileUploader.Skeleton.js +0 -2
- package/lib/components/FileUploader/FileUploader.js +3 -57
- package/lib/components/FileUploader/FileUploaderButton.js +3 -43
- package/lib/components/FileUploader/FileUploaderDropContainer.js +1 -28
- package/lib/components/FileUploader/FileUploaderItem.js +1 -30
- package/lib/components/FileUploader/Filename.js +0 -10
- package/lib/components/FluidComboBox/FluidComboBox.Skeleton.js +0 -1
- package/lib/components/FluidComboBox/FluidComboBox.js +0 -18
- package/lib/components/FluidDatePicker/FluidDatePicker.Skeleton.js +0 -2
- package/lib/components/FluidDatePicker/FluidDatePicker.js +0 -6
- package/lib/components/FluidDatePickerInput/FluidDatePickerInput.js +2 -1
- package/lib/components/FluidDropdown/FluidDropdown.Skeleton.js +0 -1
- package/lib/components/FluidDropdown/FluidDropdown.js +0 -18
- package/lib/components/FluidForm/FluidForm.js +0 -2
- package/lib/components/FluidMultiSelect/FluidMultiSelect.Skeleton.js +0 -1
- package/lib/components/FluidMultiSelect/FluidMultiSelect.js +0 -19
- package/lib/components/FluidSelect/FluidSelect.Skeleton.js +0 -1
- package/lib/components/FluidSelect/FluidSelect.js +0 -10
- package/lib/components/FluidTextArea/FluidTextArea.Skeleton.js +0 -1
- package/lib/components/FluidTextArea/FluidTextArea.js +0 -20
- package/lib/components/FluidTextInput/FluidTextInput.Skeleton.js +0 -1
- package/lib/components/FluidTextInput/FluidTextInput.js +0 -14
- package/lib/components/FluidTimePicker/FluidTimePicker.Skeleton.js +0 -3
- package/lib/components/FluidTimePicker/FluidTimePicker.js +1 -11
- package/lib/components/FluidTimePickerSelect/FluidTimePickerSelect.js +0 -6
- package/lib/components/Form/Form.d.ts +23 -0
- package/lib/components/Form/Form.js +3 -6
- package/lib/components/Form/index.d.ts +7 -0
- package/lib/components/FormGroup/FormGroup.js +0 -7
- package/lib/components/FormItem/FormItem.js +0 -2
- package/lib/components/FormLabel/FormLabel.js +1 -26
- package/lib/components/Grid/CSSGrid.js +2 -15
- package/lib/components/Grid/Column.js +18 -59
- package/lib/components/Grid/ColumnHang.js +2 -5
- package/lib/components/Grid/FlexGrid.js +2 -8
- package/lib/components/Grid/Grid.js +0 -8
- package/lib/components/Grid/GridContext.js +1 -3
- package/lib/components/Grid/Row.js +2 -7
- package/lib/components/Heading/index.js +0 -4
- package/lib/components/Icon/Icon.Skeleton.js +2 -2
- package/lib/components/IconButton/index.js +0 -10
- package/lib/components/IdPrefix/index.js +0 -2
- package/lib/components/InlineCheckbox/InlineCheckbox.js +0 -14
- package/lib/components/InlineLoading/InlineLoading.js +0 -12
- package/lib/components/Layer/index.js +3 -6
- package/lib/components/Layout/LayoutDirection.js +0 -3
- package/lib/components/Layout/useLayoutDirection.js +0 -1
- package/lib/components/Link/Link.js +3 -10
- package/lib/components/ListBox/ListBox.js +2 -13
- package/lib/components/ListBox/ListBoxField.js +0 -5
- package/lib/components/ListBox/ListBoxMenuIcon.js +0 -4
- package/lib/components/ListBox/ListBoxMenuItem.js +2 -6
- package/lib/components/ListBox/ListBoxPropTypes.d.ts +2 -2
- package/lib/components/ListBox/ListBoxSelection.js +1 -13
- package/lib/components/ListBox/next/ListBoxSelection.js +1 -14
- package/lib/components/ListBox/next/ListBoxTrigger.js +1 -3
- package/lib/components/ListItem/ListItem.d.ts +23 -0
- package/lib/components/ListItem/ListItem.js +4 -8
- package/lib/components/ListItem/index.d.ts +7 -0
- package/lib/components/Loading/Loading.js +0 -6
- package/lib/components/Menu/Menu.js +22 -40
- package/lib/components/Menu/MenuContext.js +4 -5
- package/lib/components/Menu/MenuItem.js +5 -39
- package/lib/components/MenuButton/index.js +0 -9
- package/lib/components/Modal/Modal.js +0 -43
- package/lib/components/ModalWrapper/ModalWrapper.js +2 -15
- package/lib/components/MultiSelect/FilterableMultiSelect.js +8 -66
- package/lib/components/MultiSelect/MultiSelect.js +30 -78
- package/lib/components/MultiSelect/MultiSelectPropTypes.js +0 -1
- package/lib/components/MultiSelect/index.js +0 -1
- package/lib/components/MultiSelect/tools/itemToString.js +0 -2
- package/lib/components/MultiSelect/tools/sorting.js +3 -4
- package/lib/components/Notification/Notification.js +0 -78
- package/lib/components/NumberInput/NumberInput.Skeleton.js +0 -2
- package/lib/components/NumberInput/NumberInput.js +3 -60
- package/lib/components/OrderedList/OrderedList.d.ts +39 -0
- package/lib/components/OrderedList/OrderedList.js +7 -19
- package/lib/components/OrderedList/index.d.ts +7 -0
- package/lib/components/OverflowMenu/OverflowMenu.js +65 -86
- package/lib/components/OverflowMenuItem/OverflowMenuItem.js +6 -23
- package/lib/components/OverflowMenuV2/index.js +0 -5
- package/lib/components/Pagination/Pagination.Skeleton.js +0 -2
- package/lib/components/Pagination/Pagination.js +11 -47
- package/lib/components/Pagination/experimental/PageSelector.js +0 -10
- package/lib/components/Pagination/experimental/Pagination.js +2 -67
- package/lib/components/PaginationNav/PaginationNav.js +15 -78
- package/lib/components/Popover/index.d.ts +14 -8
- package/lib/components/Popover/index.js +44 -48
- package/lib/components/PrimaryButton/PrimaryButton.js +0 -1
- package/lib/components/ProgressBar/ProgressBar.js +0 -15
- package/lib/components/ProgressIndicator/ProgressIndicator.Skeleton.js +0 -4
- package/lib/components/ProgressIndicator/ProgressIndicator.js +2 -40
- package/lib/components/RadioButton/RadioButton.Skeleton.js +0 -1
- package/lib/components/RadioButton/RadioButton.js +0 -13
- package/lib/components/RadioButtonGroup/RadioButtonGroup.js +3 -23
- package/lib/components/RadioTile/RadioTile.js +0 -12
- package/lib/components/Search/Search.Skeleton.js +0 -2
- package/lib/components/Search/Search.js +1 -28
- package/lib/components/SecondaryButton/SecondaryButton.js +0 -1
- package/lib/components/Select/Select.Skeleton.js +0 -2
- package/lib/components/Select/Select.d.ts +1 -1
- package/lib/components/Select/Select.js +6 -33
- package/lib/components/SelectItem/SelectItem.js +0 -5
- package/lib/components/SelectItemGroup/SelectItemGroup.d.ts +0 -1
- package/lib/components/SelectItemGroup/SelectItemGroup.js +1 -26
- package/lib/components/SkeletonIcon/SkeletonIcon.js +0 -2
- package/lib/components/SkeletonPlaceholder/SkeletonPlaceholder.js +0 -1
- package/lib/components/SkeletonText/SkeletonText.js +0 -12
- package/lib/components/Slider/Slider.Skeleton.js +0 -2
- package/lib/components/Slider/Slider.d.ts +0 -1
- package/lib/components/Slider/Slider.js +112 -154
- package/lib/components/Stack/Stack.js +1 -8
- package/lib/components/StructuredList/StructuredList.Skeleton.js +0 -5
- package/lib/components/StructuredList/StructuredList.js +1 -25
- package/lib/components/Switch/IconSwitch.js +0 -18
- package/lib/components/Switch/Switch.js +0 -11
- package/lib/components/TabContent/TabContent.js +2 -6
- package/lib/components/Tabs/Tabs.Skeleton.js +0 -4
- package/lib/components/Tabs/Tabs.js +133 -102
- package/lib/components/Tabs/usePressable.js +18 -31
- package/lib/components/Tag/Tag.Skeleton.js +0 -2
- package/lib/components/Tag/Tag.js +0 -15
- package/lib/components/Text/Text.js +5 -18
- package/lib/components/Text/TextDirection.js +0 -3
- package/lib/components/Text/TextDirectionContext.js +0 -1
- package/lib/components/Text/createTextComponent.js +0 -3
- package/lib/components/TextArea/TextArea.Skeleton.js +0 -2
- package/lib/components/TextArea/TextArea.js +10 -32
- package/lib/components/TextInput/ControlledPasswordInput.js +0 -20
- package/lib/components/TextInput/PasswordInput.js +0 -25
- package/lib/components/TextInput/TextInput.Skeleton.js +0 -2
- package/lib/components/TextInput/TextInput.d.ts +1 -1
- package/lib/components/TextInput/TextInput.js +5 -52
- package/lib/components/TextInput/util.js +3 -5
- package/lib/components/Theme/index.js +1 -6
- package/lib/components/Tile/Tile.js +31 -58
- package/lib/components/TileGroup/TileGroup.js +1 -22
- package/lib/components/TimePicker/TimePicker.js +6 -32
- package/lib/components/TimePickerSelect/TimePickerSelect.js +2 -5
- package/lib/components/Toggle/Toggle.Skeleton.js +0 -8
- package/lib/components/Toggle/Toggle.js +0 -16
- package/lib/components/ToggleSmall/ToggleSmall.Skeleton.js +0 -7
- package/lib/components/Toggletip/index.d.ts +148 -0
- package/lib/components/Toggletip/index.js +20 -44
- package/lib/components/Tooltip/DefinitionTooltip.js +0 -11
- package/lib/components/Tooltip/Tooltip.d.ts +1 -1
- package/lib/components/Tooltip/Tooltip.js +4 -21
- package/lib/components/TreeView/TreeNode.js +21 -66
- package/lib/components/TreeView/TreeView.js +11 -67
- package/lib/components/UIShell/Content.js +2 -4
- package/lib/components/UIShell/Header.js +0 -2
- package/lib/components/UIShell/HeaderContainer.d.ts +33 -0
- package/lib/components/UIShell/HeaderContainer.js +13 -11
- package/lib/components/UIShell/HeaderGlobalAction.js +0 -6
- package/lib/components/UIShell/HeaderGlobalBar.js +0 -1
- package/lib/components/UIShell/HeaderMenu.js +32 -31
- package/lib/components/UIShell/HeaderMenuButton.js +2 -4
- package/lib/components/UIShell/HeaderMenuItem.js +0 -8
- package/lib/components/UIShell/HeaderName.js +0 -5
- package/lib/components/UIShell/HeaderNavigation.js +0 -2
- package/lib/components/UIShell/HeaderPanel.js +0 -2
- package/lib/components/UIShell/HeaderSideNavItems.js +0 -2
- package/lib/components/UIShell/Link.js +2 -3
- package/lib/components/UIShell/SideNav.d.ts +3 -1
- package/lib/components/UIShell/SideNav.js +43 -35
- package/lib/components/UIShell/SideNavDetails.js +0 -3
- package/lib/components/UIShell/SideNavDivider.js +0 -1
- package/lib/components/UIShell/SideNavFooter.js +1 -4
- package/lib/components/UIShell/SideNavHeader.js +0 -4
- package/lib/components/UIShell/SideNavIcon.js +0 -3
- package/lib/components/UIShell/SideNavItem.js +0 -3
- package/lib/components/UIShell/SideNavItems.js +2 -6
- package/lib/components/UIShell/SideNavLink.js +3 -7
- package/lib/components/UIShell/SideNavLinkText.js +0 -2
- package/lib/components/UIShell/SideNavMenu.js +0 -16
- package/lib/components/UIShell/SideNavMenuItem.js +0 -2
- package/lib/components/UIShell/SideNavSwitcher.js +2 -5
- package/lib/components/UIShell/SkipToContent.d.ts +32 -0
- package/lib/components/UIShell/SkipToContent.js +8 -15
- package/lib/components/UIShell/Switcher.js +0 -2
- package/lib/components/UIShell/SwitcherDivider.js +0 -1
- package/lib/components/UIShell/SwitcherItem.js +0 -3
- package/lib/components/UnorderedList/UnorderedList.d.ts +34 -0
- package/lib/components/UnorderedList/UnorderedList.js +6 -16
- package/lib/components/UnorderedList/index.d.ts +7 -0
- package/lib/index.js +42 -43
- package/lib/internal/ClickListener.js +3 -13
- package/lib/internal/FloatingMenu.js +57 -63
- package/lib/internal/OptimizedResize.js +6 -12
- package/lib/internal/Selection.js +2 -25
- package/lib/internal/createClassWrapper.js +0 -2
- package/lib/internal/deprecateFieldOnObject.js +0 -4
- package/lib/internal/focus/index.js +0 -1
- package/lib/internal/keyboard/keys.js +2 -1
- package/lib/internal/keyboard/match.js +1 -6
- package/lib/internal/keyboard/navigation.js +8 -7
- package/lib/internal/useAnnouncer.js +0 -1
- package/lib/internal/useAttachedMenu.js +1 -9
- package/lib/internal/useControllableState.js +6 -13
- package/lib/internal/useDelayedState.js +2 -4
- package/lib/internal/useEffectOnce.js +0 -1
- package/lib/internal/useEvent.js +61 -2
- package/lib/internal/useId.js +2 -5
- package/lib/internal/useIsomorphicEffect.js +1 -0
- package/lib/internal/useMergedRefs.js +2 -2
- package/lib/internal/useNoInteractiveChildren.js +2 -13
- package/lib/internal/useNormalizedInputProps.js +0 -3
- package/lib/internal/useSavedCallback.js +1 -2
- package/lib/internal/warning.js +0 -3
- package/lib/internal/wrapFocus.js +1 -8
- package/lib/prop-types/deprecate.js +2 -5
- package/lib/prop-types/isRequiredOneOf.js +2 -5
- package/lib/prop-types/requiredIfGivenPropIsTruthy.js +0 -2
- package/lib/tools/array.js +0 -3
- package/lib/tools/events.js +0 -3
- package/lib/tools/mergeRefs.js +0 -2
- package/lib/tools/wrapComponent.js +2 -5
- package/package.json +9 -9
- package/es/components/Tab/Tab.js +0 -185
- package/es/components/Tab/index.js +0 -14
- package/es/components/TimePickerSelect/index.js +0 -13
- package/lib/components/Form/index.js +0 -17
- package/lib/components/Tab/Tab.js +0 -214
- package/lib/components/Tab/index.js +0 -39
- package/lib/components/TimePickerSelect/index.js +0 -38
|
@@ -10,9 +10,7 @@ import PropTypes from 'prop-types';
|
|
|
10
10
|
import React__default, { useState, useEffect, useRef } from 'react';
|
|
11
11
|
import cx from 'classnames';
|
|
12
12
|
import { CaretRight, CaretLeft, OverflowMenuHorizontal } from '@carbon/icons-react';
|
|
13
|
-
import Button from '../Button/Button.js';
|
|
14
13
|
import { IconButton } from '../IconButton/index.js';
|
|
15
|
-
import * as FeatureFlags from '@carbon/feature-flags';
|
|
16
14
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
17
15
|
|
|
18
16
|
var _CaretRight, _CaretLeft, _option;
|
|
@@ -23,12 +21,11 @@ const translationIds = {
|
|
|
23
21
|
'carbon.pagination-nav.active': 'Active',
|
|
24
22
|
'carbon.pagination-nav.of': 'of'
|
|
25
23
|
};
|
|
26
|
-
|
|
27
24
|
function translateWithId(messageId) {
|
|
28
25
|
return translationIds[messageId];
|
|
29
|
-
}
|
|
30
|
-
|
|
26
|
+
}
|
|
31
27
|
|
|
28
|
+
// https://reactjs.org/docs/hooks-faq.html#how-to-get-the-previous-props-or-state
|
|
32
29
|
function usePrevious(value) {
|
|
33
30
|
const ref = useRef();
|
|
34
31
|
useEffect(() => {
|
|
@@ -36,37 +33,30 @@ function usePrevious(value) {
|
|
|
36
33
|
});
|
|
37
34
|
return ref.current;
|
|
38
35
|
}
|
|
39
|
-
|
|
40
36
|
function getCuts(page, totalItems, itemsThatFit) {
|
|
41
37
|
let splitPoint = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
|
|
42
|
-
|
|
43
38
|
if (itemsThatFit >= totalItems) {
|
|
44
39
|
return {
|
|
45
40
|
front: 0,
|
|
46
41
|
back: 0
|
|
47
42
|
};
|
|
48
43
|
}
|
|
49
|
-
|
|
50
44
|
const split = splitPoint || Math.ceil(itemsThatFit / 2) - 1;
|
|
51
45
|
let frontHidden = page + 1 - split;
|
|
52
46
|
let backHidden = totalItems - page - (itemsThatFit - split) + 1;
|
|
53
|
-
|
|
54
47
|
if (frontHidden <= 1) {
|
|
55
48
|
backHidden -= frontHidden <= 0 ? Math.abs(frontHidden) + 1 : 0;
|
|
56
49
|
frontHidden = 0;
|
|
57
50
|
}
|
|
58
|
-
|
|
59
51
|
if (backHidden <= 1) {
|
|
60
52
|
frontHidden -= backHidden <= 0 ? Math.abs(backHidden) + 1 : 0;
|
|
61
53
|
backHidden = 0;
|
|
62
54
|
}
|
|
63
|
-
|
|
64
55
|
return {
|
|
65
56
|
front: frontHidden,
|
|
66
57
|
back: backHidden
|
|
67
58
|
};
|
|
68
59
|
}
|
|
69
|
-
|
|
70
60
|
function DirectionButton(_ref) {
|
|
71
61
|
let {
|
|
72
62
|
direction,
|
|
@@ -75,27 +65,16 @@ function DirectionButton(_ref) {
|
|
|
75
65
|
onClick
|
|
76
66
|
} = _ref;
|
|
77
67
|
const prefix = usePrefix();
|
|
78
|
-
const icon = direction === 'forward' ? CaretRight : CaretLeft;
|
|
79
68
|
return /*#__PURE__*/React__default.createElement("li", {
|
|
80
69
|
className: `${prefix}--pagination-nav__list-item`
|
|
81
|
-
},
|
|
70
|
+
}, /*#__PURE__*/React__default.createElement(IconButton, {
|
|
82
71
|
align: "bottom",
|
|
83
72
|
disabled: disabled,
|
|
84
73
|
kind: "ghost",
|
|
85
74
|
label: label,
|
|
86
75
|
onClick: onClick
|
|
87
|
-
}, direction === 'forward' ? _CaretRight || (_CaretRight = /*#__PURE__*/React__default.createElement(CaretRight, null)) : _CaretLeft || (_CaretLeft = /*#__PURE__*/React__default.createElement(CaretLeft, null)))
|
|
88
|
-
disabled: disabled,
|
|
89
|
-
renderIcon: icon,
|
|
90
|
-
kind: "ghost",
|
|
91
|
-
hasIconOnly: true,
|
|
92
|
-
iconDescription: label,
|
|
93
|
-
tooltipAlignment: "center",
|
|
94
|
-
tooltipPosition: "bottom",
|
|
95
|
-
onClick: onClick
|
|
96
|
-
}));
|
|
76
|
+
}, direction === 'forward' ? _CaretRight || (_CaretRight = /*#__PURE__*/React__default.createElement(CaretRight, null)) : _CaretLeft || (_CaretLeft = /*#__PURE__*/React__default.createElement(CaretLeft, null))));
|
|
97
77
|
}
|
|
98
|
-
|
|
99
78
|
function PaginationItem(_ref2) {
|
|
100
79
|
let {
|
|
101
80
|
page,
|
|
@@ -119,7 +98,6 @@ function PaginationItem(_ref2) {
|
|
|
119
98
|
className: `${prefix}--pagination-nav__accessibility-label`
|
|
120
99
|
}, isActive ? `${t('carbon.pagination-nav.active')}, ${itemLabel}` : itemLabel), page));
|
|
121
100
|
}
|
|
122
|
-
|
|
123
101
|
function PaginationOverflow(_ref3) {
|
|
124
102
|
let {
|
|
125
103
|
fromIndex,
|
|
@@ -128,7 +106,6 @@ function PaginationOverflow(_ref3) {
|
|
|
128
106
|
translateWithId: t = translateWithId
|
|
129
107
|
} = _ref3;
|
|
130
108
|
const prefix = usePrefix();
|
|
131
|
-
|
|
132
109
|
if (count > 1) {
|
|
133
110
|
return /*#__PURE__*/React__default.createElement("li", {
|
|
134
111
|
className: `${prefix}--pagination-nav__list-item`
|
|
@@ -154,7 +131,6 @@ function PaginationOverflow(_ref3) {
|
|
|
154
131
|
className: `${prefix}--pagination-nav__select-icon`
|
|
155
132
|
}))));
|
|
156
133
|
}
|
|
157
|
-
|
|
158
134
|
if (count === 1) {
|
|
159
135
|
return /*#__PURE__*/React__default.createElement(PaginationItem, {
|
|
160
136
|
page: fromIndex + 1,
|
|
@@ -164,10 +140,8 @@ function PaginationOverflow(_ref3) {
|
|
|
164
140
|
}
|
|
165
141
|
});
|
|
166
142
|
}
|
|
167
|
-
|
|
168
143
|
return null;
|
|
169
144
|
}
|
|
170
|
-
|
|
171
145
|
const PaginationNav = /*#__PURE__*/React__default.forwardRef(function PaginationNav(_ref4, ref) {
|
|
172
146
|
let {
|
|
173
147
|
className,
|
|
@@ -184,17 +158,14 @@ const PaginationNav = /*#__PURE__*/React__default.forwardRef(function Pagination
|
|
|
184
158
|
const [cuts, setCuts] = useState(getCuts(currentPage, totalItems, itemsThatFit));
|
|
185
159
|
const prevPage = usePrevious(currentPage);
|
|
186
160
|
const prefix = usePrefix();
|
|
187
|
-
|
|
188
161
|
function jumpToItem(index) {
|
|
189
162
|
if (index >= 0 && index < totalItems) {
|
|
190
163
|
setCurrentPage(index);
|
|
191
164
|
onChange(index);
|
|
192
165
|
}
|
|
193
166
|
}
|
|
194
|
-
|
|
195
167
|
function jumpToNext() {
|
|
196
168
|
const nextIndex = currentPage + 1;
|
|
197
|
-
|
|
198
169
|
if (nextIndex >= totalItems) {
|
|
199
170
|
if (loop) {
|
|
200
171
|
jumpToItem(0);
|
|
@@ -203,10 +174,8 @@ const PaginationNav = /*#__PURE__*/React__default.forwardRef(function Pagination
|
|
|
203
174
|
jumpToItem(nextIndex);
|
|
204
175
|
}
|
|
205
176
|
}
|
|
206
|
-
|
|
207
177
|
function jumpToPrevious() {
|
|
208
178
|
const previousIndex = currentPage - 1;
|
|
209
|
-
|
|
210
179
|
if (previousIndex < 0) {
|
|
211
180
|
if (loop) {
|
|
212
181
|
jumpToItem(totalItems - 1);
|
|
@@ -215,29 +184,28 @@ const PaginationNav = /*#__PURE__*/React__default.forwardRef(function Pagination
|
|
|
215
184
|
jumpToItem(previousIndex);
|
|
216
185
|
}
|
|
217
186
|
}
|
|
218
|
-
|
|
219
187
|
function pageWouldBeHidden(page) {
|
|
220
188
|
const startOffset = itemsThatFit <= 4 && page > 1 ? 0 : 1;
|
|
221
189
|
const wouldBeHiddenInFront = page >= startOffset && page <= cuts.front;
|
|
222
190
|
const wouldBeHiddenInBack = page >= totalItems - cuts.back - 1 && page <= totalItems - 2;
|
|
223
191
|
return wouldBeHiddenInFront || wouldBeHiddenInBack;
|
|
224
|
-
}
|
|
225
|
-
|
|
192
|
+
}
|
|
226
193
|
|
|
194
|
+
// jump to new page if props.page is updated
|
|
227
195
|
useEffect(() => {
|
|
228
196
|
setCurrentPage(page);
|
|
229
|
-
}, [page]);
|
|
197
|
+
}, [page]);
|
|
230
198
|
|
|
199
|
+
// re-calculate cuts if props.totalItems or props.itemsShown change
|
|
231
200
|
useEffect(() => {
|
|
232
201
|
setItemsThatFit(itemsShown >= 4 ? itemsShown : 4);
|
|
233
202
|
setCuts(getCuts(currentPage, totalItems, itemsShown));
|
|
234
203
|
}, [totalItems, itemsShown]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
235
|
-
// update cuts if necessary whenever currentPage changes
|
|
236
204
|
|
|
205
|
+
// update cuts if necessary whenever currentPage changes
|
|
237
206
|
useEffect(() => {
|
|
238
207
|
if (pageWouldBeHidden(currentPage)) {
|
|
239
208
|
const delta = currentPage - prevPage || 0;
|
|
240
|
-
|
|
241
209
|
if (delta > 0) {
|
|
242
210
|
const splitPoint = itemsThatFit - 3;
|
|
243
211
|
setCuts(getCuts(currentPage, totalItems, itemsThatFit, splitPoint));
|
|
@@ -264,7 +232,8 @@ const PaginationNav = /*#__PURE__*/React__default.forwardRef(function Pagination
|
|
|
264
232
|
label: t('carbon.pagination-nav.previous'),
|
|
265
233
|
disabled: backwardButtonDisabled,
|
|
266
234
|
onClick: jumpToPrevious
|
|
267
|
-
}),
|
|
235
|
+
}),
|
|
236
|
+
// render first item if at least 5 items can be displayed or
|
|
268
237
|
// 4 items can be displayed and the current page is either 0 or 1
|
|
269
238
|
(itemsThatFit >= 5 || itemsThatFit <= 4 && currentPage <= 1) && /*#__PURE__*/React__default.createElement(PaginationItem, {
|
|
270
239
|
page: 1,
|
|
@@ -277,7 +246,8 @@ const PaginationNav = /*#__PURE__*/React__default.forwardRef(function Pagination
|
|
|
277
246
|
fromIndex: startOffset,
|
|
278
247
|
count: cuts.front,
|
|
279
248
|
onSelect: jumpToItem
|
|
280
|
-
}),
|
|
249
|
+
}),
|
|
250
|
+
// render items between overflows
|
|
281
251
|
[...Array(totalItems)].map((e, i) => i).slice(startOffset + cuts.front, (1 + cuts.back) * -1).map(item => /*#__PURE__*/React__default.createElement(PaginationItem, {
|
|
282
252
|
key: `item-${item}`,
|
|
283
253
|
page: item + 1,
|
|
@@ -290,7 +260,8 @@ const PaginationNav = /*#__PURE__*/React__default.forwardRef(function Pagination
|
|
|
290
260
|
fromIndex: totalItems - cuts.back - 1,
|
|
291
261
|
count: cuts.back,
|
|
292
262
|
onSelect: jumpToItem
|
|
293
|
-
}),
|
|
263
|
+
}),
|
|
264
|
+
// render last item unless there is only one in total
|
|
294
265
|
totalItems > 1 && /*#__PURE__*/React__default.createElement(PaginationItem, {
|
|
295
266
|
page: totalItems,
|
|
296
267
|
translateWithId: t,
|
|
@@ -314,17 +285,14 @@ DirectionButton.propTypes = {
|
|
|
314
285
|
* The direction this button represents ("forward" or "backward").
|
|
315
286
|
*/
|
|
316
287
|
direction: PropTypes.oneOf(['forward', 'backward']),
|
|
317
|
-
|
|
318
288
|
/**
|
|
319
289
|
* Whether or not the button should be disabled.
|
|
320
290
|
*/
|
|
321
291
|
disabled: PropTypes.bool,
|
|
322
|
-
|
|
323
292
|
/**
|
|
324
293
|
* The label shown in the button's tooltip.
|
|
325
294
|
*/
|
|
326
295
|
label: PropTypes.string,
|
|
327
|
-
|
|
328
296
|
/**
|
|
329
297
|
* The callback function called when the button is clicked.
|
|
330
298
|
*/
|
|
@@ -335,17 +303,14 @@ PaginationItem.propTypes = {
|
|
|
335
303
|
* Whether or not this is the currently active page.
|
|
336
304
|
*/
|
|
337
305
|
isActive: PropTypes.bool,
|
|
338
|
-
|
|
339
306
|
/**
|
|
340
307
|
* The callback function called when the item is clicked.
|
|
341
308
|
*/
|
|
342
309
|
onClick: PropTypes.func,
|
|
343
|
-
|
|
344
310
|
/**
|
|
345
311
|
* The page number this item represents.
|
|
346
312
|
*/
|
|
347
313
|
page: PropTypes.number,
|
|
348
|
-
|
|
349
314
|
/**
|
|
350
315
|
* Specify a custom translation function that takes in a message identifier
|
|
351
316
|
* and returns the localized string for the message
|
|
@@ -357,17 +322,14 @@ PaginationOverflow.propTypes = {
|
|
|
357
322
|
* How many items to display in this overflow.
|
|
358
323
|
*/
|
|
359
324
|
count: PropTypes.number,
|
|
360
|
-
|
|
361
325
|
/**
|
|
362
326
|
* From which index on this overflow should start displaying pages.
|
|
363
327
|
*/
|
|
364
328
|
fromIndex: PropTypes.number,
|
|
365
|
-
|
|
366
329
|
/**
|
|
367
330
|
* The callback function called when the user selects a page from the overflow.
|
|
368
331
|
*/
|
|
369
332
|
onSelect: PropTypes.func,
|
|
370
|
-
|
|
371
333
|
/**
|
|
372
334
|
* Specify a custom translation function that takes in a message identifier
|
|
373
335
|
* and returns the localized string for the message
|
|
@@ -380,32 +342,26 @@ PaginationNav.propTypes = {
|
|
|
380
342
|
* Additional CSS class names.
|
|
381
343
|
*/
|
|
382
344
|
className: PropTypes.string,
|
|
383
|
-
|
|
384
345
|
/**
|
|
385
346
|
* The number of items to be shown.
|
|
386
347
|
*/
|
|
387
348
|
itemsShown: PropTypes.number,
|
|
388
|
-
|
|
389
349
|
/**
|
|
390
350
|
* Whether user should be able to loop through the items when reaching first / last.
|
|
391
351
|
*/
|
|
392
352
|
loop: PropTypes.bool,
|
|
393
|
-
|
|
394
353
|
/**
|
|
395
354
|
* The callback function called when the current page changes.
|
|
396
355
|
*/
|
|
397
356
|
onChange: PropTypes.func,
|
|
398
|
-
|
|
399
357
|
/**
|
|
400
358
|
* The index of current page.
|
|
401
359
|
*/
|
|
402
360
|
page: PropTypes.number,
|
|
403
|
-
|
|
404
361
|
/**
|
|
405
362
|
* The total number of items.
|
|
406
363
|
*/
|
|
407
364
|
totalItems: PropTypes.number,
|
|
408
|
-
|
|
409
365
|
/**
|
|
410
366
|
* Specify a custom translation function that takes in a message identifier
|
|
411
367
|
* and returns the localized string for the message
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
import React from 'react';
|
|
8
|
-
import { PolymorphicProps } from '../../types/common';
|
|
7
|
+
import React, { type WeakValidationMap, type ElementType } from 'react';
|
|
8
|
+
import { type PolymorphicProps } from '../../types/common';
|
|
9
9
|
export type PopoverAlignment = 'top' | 'top-left' | 'top-right' | 'bottom' | 'bottom-left' | 'bottom-right' | 'left' | 'left-bottom' | 'left-top' | 'right' | 'right-bottom' | 'right-top';
|
|
10
10
|
interface PopoverBaseProps {
|
|
11
11
|
/**
|
|
@@ -41,15 +41,21 @@ interface PopoverBaseProps {
|
|
|
41
41
|
* Render the component using the tab tip variant
|
|
42
42
|
*/
|
|
43
43
|
isTabTip?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Specify a handler for closing popover.
|
|
46
|
+
* The handler should take care of closing the popover, e.g. changing the `open` prop.
|
|
47
|
+
*/
|
|
48
|
+
onRequestClose?: () => void;
|
|
44
49
|
/**
|
|
45
50
|
* Specify whether the component is currently open or closed
|
|
46
51
|
*/
|
|
47
52
|
open: boolean;
|
|
48
53
|
}
|
|
49
|
-
export type PopoverProps<
|
|
50
|
-
declare const Popover:
|
|
51
|
-
|
|
52
|
-
|
|
54
|
+
export type PopoverProps<E extends ElementType> = PolymorphicProps<E, PopoverBaseProps>;
|
|
55
|
+
export declare const Popover: (<E extends React.ElementType<any> = "span">(props: PopoverProps<E>) => JSX.Element) & {
|
|
56
|
+
displayName?: string | undefined;
|
|
57
|
+
propTypes?: WeakValidationMap<PopoverProps<any>> | undefined;
|
|
58
|
+
};
|
|
53
59
|
export type PopoverContentProps = React.HTMLAttributes<HTMLSpanElement>;
|
|
54
|
-
declare const PopoverContent: React.ForwardRefExoticComponent<PopoverContentProps & React.RefAttributes<HTMLSpanElement>>;
|
|
55
|
-
export {
|
|
60
|
+
export declare const PopoverContent: React.ForwardRefExoticComponent<PopoverContentProps & React.RefAttributes<HTMLSpanElement>>;
|
|
61
|
+
export {};
|
|
@@ -12,43 +12,54 @@ import React__default, { useRef, useMemo, useState } from 'react';
|
|
|
12
12
|
import useIsomorphicEffect from '../../internal/useIsomorphicEffect.js';
|
|
13
13
|
import { useMergedRefs } from '../../internal/useMergedRefs.js';
|
|
14
14
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
15
|
+
import { useWindowEvent } from '../../internal/useEvent.js';
|
|
15
16
|
|
|
16
17
|
const PopoverContext = /*#__PURE__*/React__default.createContext({
|
|
17
18
|
floating: {
|
|
18
19
|
current: null
|
|
19
20
|
}
|
|
20
21
|
});
|
|
21
|
-
|
|
22
|
+
function PopoverRenderFunction(_ref, forwardRef) {
|
|
22
23
|
let {
|
|
23
24
|
isTabTip,
|
|
24
25
|
align = isTabTip ? 'bottom-left' : 'bottom',
|
|
25
|
-
as,
|
|
26
|
+
as: BaseComponent = 'span',
|
|
26
27
|
autoAlign = false,
|
|
27
28
|
caret = isTabTip ? false : true,
|
|
28
29
|
className: customClassName,
|
|
29
30
|
children,
|
|
30
31
|
dropShadow = true,
|
|
31
32
|
highContrast = false,
|
|
33
|
+
onRequestClose,
|
|
32
34
|
open,
|
|
33
35
|
...rest
|
|
34
36
|
} = _ref;
|
|
35
37
|
const prefix = usePrefix();
|
|
36
38
|
const floating = useRef(null);
|
|
37
39
|
const popover = useRef(null);
|
|
40
|
+
|
|
41
|
+
// If the `Popover` is the last focusable item in the tab order, it should also close when the browser window loses focus (#12922)
|
|
42
|
+
useWindowEvent('blur', () => {
|
|
43
|
+
if (open) {
|
|
44
|
+
onRequestClose?.();
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
useWindowEvent('click', event => {
|
|
48
|
+
if (open && !popover?.current?.contains(event.target)) {
|
|
49
|
+
onRequestClose?.();
|
|
50
|
+
}
|
|
51
|
+
});
|
|
38
52
|
const value = useMemo(() => {
|
|
39
53
|
return {
|
|
40
54
|
floating
|
|
41
55
|
};
|
|
42
56
|
}, []);
|
|
43
|
-
|
|
44
57
|
if (isTabTip) {
|
|
45
58
|
const tabTipAlignments = ['bottom-left', 'bottom-right'];
|
|
46
|
-
|
|
47
59
|
if (!tabTipAlignments.includes(align)) {
|
|
48
60
|
align = 'bottom-left';
|
|
49
61
|
}
|
|
50
62
|
}
|
|
51
|
-
|
|
52
63
|
const ref = useMergedRefs([forwardRef, popover]);
|
|
53
64
|
const [autoAligned, setAutoAligned] = useState(false);
|
|
54
65
|
const [autoAlignment, setAutoAlignment] = useState(align);
|
|
@@ -66,104 +77,90 @@ const Popover = /*#__PURE__*/React__default.forwardRef((_ref, forwardRef) => {
|
|
|
66
77
|
if (!open) {
|
|
67
78
|
return;
|
|
68
79
|
}
|
|
69
|
-
|
|
70
80
|
if (!autoAlign || isTabTip) {
|
|
71
81
|
setAutoAligned(false);
|
|
72
82
|
return;
|
|
73
83
|
}
|
|
74
|
-
|
|
75
84
|
if (!floating.current) {
|
|
76
85
|
return;
|
|
77
86
|
}
|
|
78
|
-
|
|
79
87
|
if (autoAligned === true) {
|
|
80
88
|
return;
|
|
81
89
|
}
|
|
90
|
+
const rect = floating.current.getBoundingClientRect();
|
|
82
91
|
|
|
83
|
-
|
|
84
|
-
|
|
92
|
+
// The conditions, per side, of when the popover is not visible, excluding the popover's internal padding(16)
|
|
85
93
|
const conditions = {
|
|
86
94
|
left: rect.x < -16,
|
|
87
95
|
top: rect.y < -16,
|
|
88
96
|
right: rect.x + (rect.width - 16) > document.documentElement.clientWidth,
|
|
89
97
|
bottom: rect.y + (rect.height - 16) > document.documentElement.clientHeight
|
|
90
98
|
};
|
|
91
|
-
|
|
92
99
|
if (!conditions.left && !conditions.top && !conditions.right && !conditions.bottom) {
|
|
93
100
|
setAutoAligned(false);
|
|
94
101
|
return;
|
|
95
102
|
}
|
|
103
|
+
const alignments = ['top', 'top-left', 'right-bottom', 'right', 'right-top', 'bottom-left', 'bottom', 'bottom-right', 'left-top', 'left', 'left-bottom', 'top-right'];
|
|
96
104
|
|
|
97
|
-
|
|
98
|
-
|
|
105
|
+
// Creates the prioritized list of options depending on ideal alignment coming from `align`
|
|
99
106
|
const options = [align];
|
|
100
107
|
let option = alignments[(alignments.indexOf(align) + 1) % alignments.length];
|
|
101
|
-
|
|
102
108
|
while (option) {
|
|
103
109
|
if (options.includes(option)) {
|
|
104
110
|
break;
|
|
105
111
|
}
|
|
106
|
-
|
|
107
112
|
options.push(option);
|
|
108
113
|
option = alignments[(alignments.indexOf(option) + 1) % alignments.length];
|
|
109
114
|
}
|
|
110
|
-
|
|
111
115
|
function isVisible(alignment) {
|
|
112
116
|
if (!popover.current || !floating.current) {
|
|
113
117
|
return false;
|
|
114
118
|
}
|
|
115
|
-
|
|
116
119
|
popover.current.classList.add(`${prefix}--popover--${alignment}`);
|
|
117
|
-
const rect = floating.current.getBoundingClientRect();
|
|
120
|
+
const rect = floating.current.getBoundingClientRect();
|
|
118
121
|
|
|
122
|
+
// Check if popover is not visible to the left of the screen
|
|
119
123
|
if (rect.x < -16) {
|
|
120
124
|
popover.current.classList.remove(`${prefix}--popover--${alignment}`);
|
|
121
125
|
return false;
|
|
122
|
-
}
|
|
123
|
-
|
|
126
|
+
}
|
|
124
127
|
|
|
128
|
+
// Check if popover is not visible at the top of the screen
|
|
125
129
|
if (rect.y < -16) {
|
|
126
130
|
popover.current.classList.remove(`${prefix}--popover--${alignment}`);
|
|
127
131
|
return false;
|
|
128
|
-
}
|
|
129
|
-
|
|
132
|
+
}
|
|
130
133
|
|
|
134
|
+
// Check if popover is not visible to right of screen
|
|
131
135
|
if (rect.x + (rect.width - 16) > document.documentElement.clientWidth) {
|
|
132
136
|
popover.current.classList.remove(`${prefix}--popover--${alignment}`);
|
|
133
137
|
return false;
|
|
134
|
-
}
|
|
135
|
-
|
|
138
|
+
}
|
|
136
139
|
|
|
140
|
+
// Check if popover is not visible to bottom of screen
|
|
137
141
|
if (rect.y + (rect.height - 16) > document.documentElement.clientHeight) {
|
|
138
142
|
popover.current.classList.remove(`${prefix}--popover--${alignment}`);
|
|
139
143
|
return false;
|
|
140
144
|
}
|
|
141
|
-
|
|
142
145
|
popover.current.classList.remove(`${prefix}--popover--${alignment}`);
|
|
143
146
|
return true;
|
|
144
147
|
}
|
|
145
|
-
|
|
146
148
|
let alignment = null;
|
|
147
|
-
|
|
148
149
|
for (let i = 0; i < options.length; i++) {
|
|
149
150
|
const option = options[i];
|
|
150
|
-
|
|
151
151
|
if (isVisible(option)) {
|
|
152
152
|
alignment = option;
|
|
153
153
|
break;
|
|
154
154
|
}
|
|
155
155
|
}
|
|
156
|
-
|
|
157
156
|
if (alignment) {
|
|
158
157
|
setAutoAligned(true);
|
|
159
158
|
setAutoAlignment(alignment);
|
|
160
159
|
}
|
|
161
160
|
}, [autoAligned, align, autoAlign, prefix, open, isTabTip]);
|
|
162
|
-
const BaseComponent = as ?? 'span';
|
|
163
161
|
const mappedChildren = React__default.Children.map(children, child => {
|
|
164
162
|
const item = child;
|
|
165
|
-
|
|
166
|
-
if ((item === null || item === void 0 ? void 0 : item.type) === 'button') {
|
|
163
|
+
if (item?.type === 'button') {
|
|
167
164
|
const {
|
|
168
165
|
className
|
|
169
166
|
} = item.props;
|
|
@@ -175,73 +172,72 @@ const Popover = /*#__PURE__*/React__default.forwardRef((_ref, forwardRef) => {
|
|
|
175
172
|
return item;
|
|
176
173
|
}
|
|
177
174
|
});
|
|
175
|
+
const BaseComponentAsAny = BaseComponent;
|
|
178
176
|
return /*#__PURE__*/React__default.createElement(PopoverContext.Provider, {
|
|
179
177
|
value: value
|
|
180
|
-
}, /*#__PURE__*/React__default.createElement(
|
|
178
|
+
}, /*#__PURE__*/React__default.createElement(BaseComponentAsAny, _extends({}, rest, {
|
|
181
179
|
className: className,
|
|
182
180
|
ref: ref
|
|
183
181
|
}), isTabTip ? mappedChildren : children));
|
|
184
|
-
}
|
|
185
|
-
|
|
182
|
+
}
|
|
183
|
+
const Popover = /*#__PURE__*/React__default.forwardRef(PopoverRenderFunction);
|
|
186
184
|
|
|
185
|
+
// Note: this displayName is temporarily set so that Storybook ArgTable
|
|
186
|
+
// correctly displays the name of this component
|
|
187
187
|
if (process.env.NODE_ENV !== "production") {
|
|
188
188
|
Popover.displayName = 'Popover';
|
|
189
189
|
}
|
|
190
|
-
|
|
191
190
|
Popover.propTypes = {
|
|
192
191
|
/**
|
|
193
192
|
* Specify how the popover should align with the trigger element
|
|
194
193
|
*/
|
|
195
194
|
align: PropTypes.oneOf(['top', 'top-left', 'top-right', 'bottom', 'bottom-left', 'bottom-right', 'left', 'left-bottom', 'left-top', 'right', 'right-bottom', 'right-top']),
|
|
196
|
-
|
|
197
195
|
/**
|
|
198
196
|
* Provide a custom element or component to render the top-level node for the
|
|
199
197
|
* component.
|
|
200
198
|
*/
|
|
201
199
|
as: PropTypes.oneOfType([PropTypes.string, PropTypes.elementType]),
|
|
202
|
-
|
|
203
200
|
/**
|
|
204
201
|
* Will auto-align the popover on first render if it is not visible. This prop is currently experimental and is subject to future changes.
|
|
205
202
|
*/
|
|
206
203
|
autoAlign: PropTypes.bool,
|
|
207
|
-
|
|
208
204
|
/**
|
|
209
205
|
* Specify whether a caret should be rendered
|
|
210
206
|
*/
|
|
211
207
|
caret: PropTypes.bool,
|
|
212
|
-
|
|
213
208
|
/**
|
|
214
209
|
* Provide elements to be rendered inside of the component
|
|
215
210
|
*/
|
|
216
211
|
children: PropTypes.node,
|
|
217
|
-
|
|
218
212
|
/**
|
|
219
213
|
* Provide a custom class name to be added to the outermost node in the
|
|
220
214
|
* component
|
|
221
215
|
*/
|
|
222
216
|
className: PropTypes.string,
|
|
223
|
-
|
|
224
217
|
/**
|
|
225
218
|
* Specify whether a drop shadow should be rendered on the popover
|
|
226
219
|
*/
|
|
227
220
|
dropShadow: PropTypes.bool,
|
|
228
|
-
|
|
229
221
|
/**
|
|
230
222
|
* Render the component using the high-contrast variant
|
|
231
223
|
*/
|
|
232
224
|
highContrast: PropTypes.bool,
|
|
233
|
-
|
|
234
225
|
/**
|
|
235
226
|
* Render the component using the tab tip variant
|
|
236
227
|
*/
|
|
237
228
|
isTabTip: PropTypes.bool,
|
|
238
|
-
|
|
229
|
+
/**
|
|
230
|
+
* Specify a handler for closing popover.
|
|
231
|
+
* The handler should take care of closing the popover, e.g. changing the `open` prop.
|
|
232
|
+
*/
|
|
233
|
+
onRequestClose: PropTypes.func,
|
|
239
234
|
/**
|
|
240
235
|
* Specify whether the component is currently open or closed
|
|
241
236
|
*/
|
|
242
237
|
open: PropTypes.bool.isRequired
|
|
243
238
|
};
|
|
244
|
-
|
|
239
|
+
function PopoverContentRenderFunction( // eslint-disable-next-line react/prop-types
|
|
240
|
+
_ref2, forwardRef) {
|
|
245
241
|
let {
|
|
246
242
|
className,
|
|
247
243
|
children,
|
|
@@ -260,13 +256,13 @@ const PopoverContent = /*#__PURE__*/React__default.forwardRef(function PopoverCo
|
|
|
260
256
|
}, children), /*#__PURE__*/React__default.createElement("span", {
|
|
261
257
|
className: `${prefix}--popover-caret`
|
|
262
258
|
}));
|
|
263
|
-
}
|
|
259
|
+
}
|
|
260
|
+
const PopoverContent = /*#__PURE__*/React__default.forwardRef(PopoverContentRenderFunction);
|
|
264
261
|
PopoverContent.propTypes = {
|
|
265
262
|
/**
|
|
266
263
|
* Provide elements to be rendered inside of the component
|
|
267
264
|
*/
|
|
268
265
|
children: PropTypes.node,
|
|
269
|
-
|
|
270
266
|
/**
|
|
271
267
|
* Provide a custom class name to be added to the outermost node in the
|
|
272
268
|
* component
|