@itwin/itwinui-react 3.0.4 → 3.0.5
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/CHANGELOG.md +7 -0
- package/cjs/core/Alert/Alert.js +46 -106
- package/cjs/core/Avatar/Avatar.js +21 -58
- package/cjs/core/AvatarGroup/AvatarGroup.js +26 -64
- package/cjs/core/Backdrop/Backdrop.js +8 -16
- package/cjs/core/Badge/Badge.js +22 -39
- package/cjs/core/Breadcrumbs/Breadcrumbs.js +61 -138
- package/cjs/core/ButtonGroup/ButtonGroup.js +32 -68
- package/cjs/core/Buttons/Button.js +11 -57
- package/cjs/core/Buttons/DropdownButton.js +15 -49
- package/cjs/core/Buttons/IconButton.js +13 -53
- package/cjs/core/Buttons/IdeasButton.js +8 -20
- package/cjs/core/Buttons/SplitButton.js +43 -103
- package/cjs/core/Carousel/Carousel.js +54 -78
- package/cjs/core/Carousel/CarouselContext.js +4 -4
- package/cjs/core/Carousel/CarouselDot.js +12 -23
- package/cjs/core/Carousel/CarouselDotsList.js +92 -153
- package/cjs/core/Carousel/CarouselNavigation.js +41 -84
- package/cjs/core/Carousel/CarouselSlide.js +26 -49
- package/cjs/core/Carousel/CarouselSlider.js +47 -66
- package/cjs/core/Checkbox/Checkbox.js +32 -88
- package/cjs/core/ColorPicker/ColorBuilder.js +174 -292
- package/cjs/core/ColorPicker/ColorInputPanel.js +246 -411
- package/cjs/core/ColorPicker/ColorPalette.js +23 -47
- package/cjs/core/ColorPicker/ColorPicker.js +53 -87
- package/cjs/core/ColorPicker/ColorPickerContext.js +9 -11
- package/cjs/core/ColorPicker/ColorSwatch.js +15 -40
- package/cjs/core/ComboBox/ComboBox.js +280 -402
- package/cjs/core/ComboBox/ComboBoxEndIcon.js +12 -28
- package/cjs/core/ComboBox/ComboBoxInput.js +131 -207
- package/cjs/core/ComboBox/ComboBoxInputContainer.js +12 -35
- package/cjs/core/ComboBox/ComboBoxMenu.js +43 -87
- package/cjs/core/ComboBox/ComboBoxMenuItem.js +21 -73
- package/cjs/core/ComboBox/ComboBoxMultipleContainer.js +7 -13
- package/cjs/core/ComboBox/helpers.js +43 -47
- package/cjs/core/DatePicker/DatePicker.js +333 -569
- package/cjs/core/Dialog/Dialog.js +36 -65
- package/cjs/core/Dialog/DialogBackdrop.js +27 -47
- package/cjs/core/Dialog/DialogButtonBar.js +3 -3
- package/cjs/core/Dialog/DialogContent.js +18 -26
- package/cjs/core/Dialog/DialogContext.js +5 -5
- package/cjs/core/Dialog/DialogDragContext.js +8 -8
- package/cjs/core/Dialog/DialogMain.js +116 -183
- package/cjs/core/Dialog/DialogTitleBar.js +20 -67
- package/cjs/core/Dialog/DialogTitleBarTitle.js +3 -3
- package/cjs/core/Divider/Divider.js +8 -14
- package/cjs/core/DropdownMenu/DropdownMenu.js +46 -80
- package/cjs/core/ExpandableBlock/ExpandableBlock.js +101 -206
- package/cjs/core/Fieldset/Fieldset.js +14 -25
- package/cjs/core/FileUpload/FileEmptyCard.js +17 -43
- package/cjs/core/FileUpload/FileUpload.js +42 -88
- package/cjs/core/FileUpload/FileUploadCard.js +84 -169
- package/cjs/core/FileUpload/FileUploadTemplate.js +16 -51
- package/cjs/core/Flex/Flex.js +77 -93
- package/cjs/core/Footer/Footer.js +64 -103
- package/cjs/core/Footer/FooterItem.js +3 -3
- package/cjs/core/Footer/FooterList.js +3 -3
- package/cjs/core/Footer/FooterSeparator.js +5 -8
- package/cjs/core/Header/Header.js +22 -67
- package/cjs/core/Header/HeaderBasicButton.js +13 -24
- package/cjs/core/Header/HeaderBreadcrumbs.js +14 -38
- package/cjs/core/Header/HeaderButton.js +22 -76
- package/cjs/core/Header/HeaderDropdownButton.js +20 -48
- package/cjs/core/Header/HeaderLogo.js +11 -42
- package/cjs/core/Header/HeaderSplitButton.js +21 -66
- package/cjs/core/Icon/Icon.js +18 -32
- package/cjs/core/InformationPanel/InformationPanel.js +42 -77
- package/cjs/core/InformationPanel/InformationPanelBody.js +4 -6
- package/cjs/core/InformationPanel/InformationPanelContent.js +8 -20
- package/cjs/core/InformationPanel/InformationPanelHeader.js +14 -34
- package/cjs/core/InformationPanel/InformationPanelWrapper.js +4 -6
- package/cjs/core/Input/Input.js +10 -18
- package/cjs/core/InputGrid/InputGrid.js +8 -17
- package/cjs/core/InputGroup/InputGroup.js +25 -72
- package/cjs/core/InputWithDecorations/InputWithDecorations.js +23 -51
- package/cjs/core/Label/Label.js +11 -32
- package/cjs/core/LabeledInput/LabeledInput.js +20 -70
- package/cjs/core/LabeledSelect/LabeledSelect.js +28 -77
- package/cjs/core/LabeledTextarea/LabeledTextarea.js +7 -13
- package/cjs/core/LinkAction/LinkAction.js +3 -3
- package/cjs/core/List/List.js +3 -3
- package/cjs/core/List/ListItem.js +35 -55
- package/cjs/core/Menu/Menu.js +53 -66
- package/cjs/core/Menu/MenuDivider.js +4 -4
- package/cjs/core/Menu/MenuExtraContent.js +4 -4
- package/cjs/core/Menu/MenuItem.js +92 -168
- package/cjs/core/Menu/MenuItemSkeleton.js +19 -54
- package/cjs/core/Modal/Modal.js +11 -38
- package/cjs/core/Modal/ModalButtonBar.js +4 -7
- package/cjs/core/Modal/ModalContent.js +3 -3
- package/cjs/core/NonIdealState/ErrorPage.js +131 -187
- package/cjs/core/NonIdealState/NonIdealState.js +12 -77
- package/cjs/core/NotificationMarker/NotificationMarker.js +8 -29
- package/cjs/core/Overlay/Overlay.d.ts +20 -24
- package/cjs/core/Overlay/Overlay.js +50 -64
- package/cjs/core/Popover/Popover.js +87 -157
- package/cjs/core/ProgressIndicators/ProgressLinear.js +11 -49
- package/cjs/core/ProgressIndicators/ProgressRadial.js +19 -51
- package/cjs/core/Radio/Radio.js +12 -54
- package/cjs/core/RadioTiles/RadioTile.js +14 -80
- package/cjs/core/RadioTiles/RadioTileGroup.js +9 -16
- package/cjs/core/SearchBox/SearchBox.js +104 -221
- package/cjs/core/Select/Select.js +141 -276
- package/cjs/core/Select/SelectTag.js +9 -21
- package/cjs/core/Select/SelectTagContainer.js +14 -30
- package/cjs/core/SideNavigation/SideNavigation.js +29 -138
- package/cjs/core/SideNavigation/SidenavButton.js +8 -30
- package/cjs/core/SideNavigation/SidenavSubmenu.js +9 -23
- package/cjs/core/SideNavigation/SidenavSubmenuHeader.js +10 -29
- package/cjs/core/SkipToContentLink/SkipToContentLink.js +8 -20
- package/cjs/core/Slider/Slider.js +195 -376
- package/cjs/core/Slider/Thumb.js +57 -108
- package/cjs/core/Slider/Track.js +55 -83
- package/cjs/core/StatusMessage/StatusMessage.js +12 -34
- package/cjs/core/Stepper/Stepper.js +21 -80
- package/cjs/core/Stepper/StepperStep.js +36 -109
- package/cjs/core/Stepper/WorkflowDiagram.js +15 -38
- package/cjs/core/Stepper/WorkflowDiagramStep.js +11 -39
- package/cjs/core/Surface/Surface.js +54 -94
- package/cjs/core/Table/SubRowExpander.js +15 -37
- package/cjs/core/Table/Table.js +419 -763
- package/cjs/core/Table/TableCell.js +63 -113
- package/cjs/core/Table/TablePaginator.js +136 -312
- package/cjs/core/Table/TableRowMemoized.js +64 -137
- package/cjs/core/Table/actionHandlers/expandHandler.js +12 -12
- package/cjs/core/Table/actionHandlers/filterHandler.js +17 -25
- package/cjs/core/Table/actionHandlers/index.js +14 -56
- package/cjs/core/Table/actionHandlers/resizeHandler.js +13 -13
- package/cjs/core/Table/actionHandlers/selectHandler.js +98 -128
- package/cjs/core/Table/cells/DefaultCell.js +13 -48
- package/cjs/core/Table/cells/EditableCell.js +46 -75
- package/cjs/core/Table/cells/index.js +6 -16
- package/cjs/core/Table/columns/actionColumn.js +67 -97
- package/cjs/core/Table/columns/expanderColumn.js +32 -46
- package/cjs/core/Table/columns/index.js +11 -41
- package/cjs/core/Table/columns/selectionColumn.js +29 -57
- package/cjs/core/Table/filters/BaseFilter.js +13 -24
- package/cjs/core/Table/filters/DateRangeFilter/DatePickerInput.js +52 -120
- package/cjs/core/Table/filters/DateRangeFilter/DateRangeFilter.js +60 -120
- package/cjs/core/Table/filters/FilterButtonBar.js +16 -39
- package/cjs/core/Table/filters/FilterToggle.js +26 -62
- package/cjs/core/Table/filters/NumberRangeFilter/NumberRangeFilter.js +36 -58
- package/cjs/core/Table/filters/TextFilter/TextFilter.js +28 -40
- package/cjs/core/Table/filters/customFilterFunctions.js +14 -16
- package/cjs/core/Table/filters/defaultFilterFunctions.js +81 -86
- package/cjs/core/Table/filters/index.js +11 -35
- package/cjs/core/Table/filters/tableFilters.js +32 -44
- package/cjs/core/Table/filters/types.js +2 -2
- package/cjs/core/Table/hooks/index.js +19 -67
- package/cjs/core/Table/hooks/useColumnDragAndDrop.js +86 -101
- package/cjs/core/Table/hooks/useExpanderCell.js +25 -33
- package/cjs/core/Table/hooks/useResizeColumns.js +290 -362
- package/cjs/core/Table/hooks/useScrollToRow.js +38 -46
- package/cjs/core/Table/hooks/useSelectionCell.js +10 -17
- package/cjs/core/Table/hooks/useStickyColumns.js +62 -64
- package/cjs/core/Table/hooks/useSubRowFiltering.js +88 -95
- package/cjs/core/Table/hooks/useSubRowSelection.js +31 -32
- package/cjs/core/Table/index.js +18 -78
- package/cjs/core/Table/utils.js +40 -42
- package/cjs/core/Tabs/Tabs.js +232 -417
- package/cjs/core/Tag/Tag.js +15 -42
- package/cjs/core/Tag/TagContainer.js +11 -23
- package/cjs/core/Textarea/Textarea.js +6 -11
- package/cjs/core/ThemeProvider/ThemeContext.js +4 -4
- package/cjs/core/ThemeProvider/ThemeProvider.js +52 -105
- package/cjs/core/Tile/Tile.js +230 -410
- package/cjs/core/TimePicker/TimePicker.js +234 -458
- package/cjs/core/Toast/Toast.js +107 -204
- package/cjs/core/Toast/Toaster.js +77 -102
- package/cjs/core/ToggleSwitch/ToggleSwitch.js +23 -66
- package/cjs/core/Tooltip/Tooltip.js +91 -137
- package/cjs/core/TransferList/TransferList.js +103 -177
- package/cjs/core/Tree/Tree.js +129 -204
- package/cjs/core/Tree/TreeContext.js +9 -9
- package/cjs/core/Tree/TreeNode.js +104 -207
- package/cjs/core/Tree/TreeNodeExpander.js +12 -26
- package/cjs/core/Typography/Anchor.js +3 -3
- package/cjs/core/Typography/Blockquote.js +10 -18
- package/cjs/core/Typography/Code.js +3 -3
- package/cjs/core/Typography/Kbd.js +21 -30
- package/cjs/core/Typography/Text.js +13 -26
- package/cjs/core/VisuallyHidden/VisuallyHidden.js +8 -14
- package/cjs/core/utils/color/ColorValue.js +453 -535
- package/cjs/core/utils/color/index.js +4 -4
- package/cjs/core/utils/components/AutoclearingHiddenLiveRegion.js +13 -20
- package/cjs/core/utils/components/Box.js +3 -3
- package/cjs/core/utils/components/ButtonBase.js +20 -38
- package/cjs/core/utils/components/FocusTrap.js +38 -47
- package/cjs/core/utils/components/InputContainer.js +19 -58
- package/cjs/core/utils/components/InputFlexContainer.js +8 -24
- package/cjs/core/utils/components/MiddleTextTruncation.js +22 -32
- package/cjs/core/utils/components/Portal.js +20 -22
- package/cjs/core/utils/components/Resizer.js +196 -253
- package/cjs/core/utils/components/VirtualScroll.js +223 -304
- package/cjs/core/utils/components/WithCSSTransition.js +32 -49
- package/cjs/core/utils/components/index.js +14 -14
- package/cjs/core/utils/functions/colors.js +22 -25
- package/cjs/core/utils/functions/date.js +10 -10
- package/cjs/core/utils/functions/dev.js +14 -13
- package/cjs/core/utils/functions/dom.js +17 -24
- package/cjs/core/utils/functions/focusable.js +17 -26
- package/cjs/core/utils/functions/import.js +23 -46
- package/cjs/core/utils/functions/index.js +13 -13
- package/cjs/core/utils/functions/numbers.js +9 -9
- package/cjs/core/utils/functions/polymorphic.js +30 -43
- package/cjs/core/utils/functions/react.js +24 -26
- package/cjs/core/utils/functions/supports.js +4 -5
- package/cjs/core/utils/hooks/index.js +17 -17
- package/cjs/core/utils/hooks/useContainerWidth.js +19 -26
- package/cjs/core/utils/hooks/useControlledState.js +12 -21
- package/cjs/core/utils/hooks/useDragAndDrop.js +87 -110
- package/cjs/core/utils/hooks/useEventListener.js +22 -22
- package/cjs/core/utils/hooks/useGlobals.js +27 -33
- package/cjs/core/utils/hooks/useId.js +8 -10
- package/cjs/core/utils/hooks/useIntersection.js +24 -30
- package/cjs/core/utils/hooks/useIsClient.js +9 -9
- package/cjs/core/utils/hooks/useIsomorphicLayoutEffect.js +5 -6
- package/cjs/core/utils/hooks/useLatestRef.js +9 -9
- package/cjs/core/utils/hooks/useMediaQuery.js +31 -31
- package/cjs/core/utils/hooks/useMergedRefs.js +16 -15
- package/cjs/core/utils/hooks/useOverflow.js +57 -70
- package/cjs/core/utils/hooks/useResizeObserver.js +17 -22
- package/cjs/core/utils/hooks/useSafeContext.js +9 -9
- package/cjs/core/utils/icons/StatusIconMap.js +12 -28
- package/cjs/core/utils/icons/Svg.js +3 -3
- package/cjs/core/utils/icons/SvgCalendar.js +7 -12
- package/cjs/core/utils/icons/SvgCaretDownSmall.js +7 -12
- package/cjs/core/utils/icons/SvgCaretRightSmall.js +7 -12
- package/cjs/core/utils/icons/SvgCaretUpSmall.js +7 -12
- package/cjs/core/utils/icons/SvgCheckmark.js +7 -10
- package/cjs/core/utils/icons/SvgCheckmarkSmall.js +7 -12
- package/cjs/core/utils/icons/SvgChevronLeft.js +7 -12
- package/cjs/core/utils/icons/SvgChevronLeftDouble.js +7 -12
- package/cjs/core/utils/icons/SvgChevronRight.js +7 -12
- package/cjs/core/utils/icons/SvgChevronRightDouble.js +7 -12
- package/cjs/core/utils/icons/SvgClose.js +7 -12
- package/cjs/core/utils/icons/SvgCloseSmall.js +7 -12
- package/cjs/core/utils/icons/SvgColumnManager.js +7 -12
- package/cjs/core/utils/icons/SvgDocument.js +7 -10
- package/cjs/core/utils/icons/SvgFilter.js +7 -10
- package/cjs/core/utils/icons/SvgFilterHollow.js +7 -12
- package/cjs/core/utils/icons/SvgImportantSmall.js +7 -12
- package/cjs/core/utils/icons/SvgInfoCircular.js +7 -12
- package/cjs/core/utils/icons/SvgMore.js +7 -12
- package/cjs/core/utils/icons/SvgMoreVertical.js +7 -12
- package/cjs/core/utils/icons/SvgNew.js +7 -12
- package/cjs/core/utils/icons/SvgSearch.js +7 -12
- package/cjs/core/utils/icons/SvgSmileyHappy.js +7 -12
- package/cjs/core/utils/icons/SvgSortDown.js +7 -12
- package/cjs/core/utils/icons/SvgSortUp.js +7 -12
- package/cjs/core/utils/icons/SvgStatusError.js +7 -12
- package/cjs/core/utils/icons/SvgStatusSuccess.js +7 -12
- package/cjs/core/utils/icons/SvgStatusWarning.js +7 -12
- package/cjs/core/utils/icons/SvgSwap.js +7 -12
- package/cjs/core/utils/icons/SvgUpload.js +7 -12
- package/cjs/core/utils/icons/index.js +34 -34
- package/cjs/core/utils/index.js +10 -10
- package/cjs/core/utils/props.js +2 -2
- package/cjs/core/utils/types.js +2 -2
- package/cjs/index.js +229 -949
- package/cjs/react-table/react-table.js +2 -2
- package/cjs/styles.js +412 -425
- package/esm/core/Alert/Alert.js +39 -106
- package/esm/core/Avatar/Avatar.js +14 -42
- package/esm/core/AvatarGroup/AvatarGroup.js +20 -58
- package/esm/core/Backdrop/Backdrop.js +2 -10
- package/esm/core/Badge/Badge.js +16 -31
- package/esm/core/Breadcrumbs/Breadcrumbs.js +55 -135
- package/esm/core/ButtonGroup/ButtonGroup.js +25 -61
- package/esm/core/Buttons/Button.js +5 -45
- package/esm/core/Buttons/DropdownButton.js +7 -37
- package/esm/core/Buttons/IconButton.js +5 -40
- package/esm/core/Buttons/IdeasButton.js +2 -12
- package/esm/core/Buttons/SplitButton.js +34 -101
- package/esm/core/Carousel/Carousel.js +43 -72
- package/esm/core/Carousel/CarouselDot.js +6 -17
- package/esm/core/Carousel/CarouselDotsList.js +85 -147
- package/esm/core/Carousel/CarouselNavigation.js +32 -68
- package/esm/core/Carousel/CarouselSlide.js +19 -41
- package/esm/core/Carousel/CarouselSlider.js +41 -65
- package/esm/core/Checkbox/Checkbox.js +25 -78
- package/esm/core/ColorPicker/ColorBuilder.js +167 -280
- package/esm/core/ColorPicker/ColorInputPanel.js +237 -395
- package/esm/core/ColorPicker/ColorPalette.js +14 -35
- package/esm/core/ColorPicker/ColorPicker.js +46 -79
- package/esm/core/ColorPicker/ColorPickerContext.js +5 -7
- package/esm/core/ColorPicker/ColorSwatch.js +7 -24
- package/esm/core/ComboBox/ComboBox.js +267 -396
- package/esm/core/ComboBox/ComboBoxEndIcon.js +5 -18
- package/esm/core/ComboBox/ComboBoxInput.js +125 -197
- package/esm/core/ComboBox/ComboBoxInputContainer.js +5 -20
- package/esm/core/ComboBox/ComboBoxMenu.js +37 -77
- package/esm/core/ComboBox/ComboBoxMenuItem.js +14 -61
- package/esm/core/ComboBox/ComboBoxMultipleContainer.js +2 -6
- package/esm/core/ComboBox/helpers.js +38 -38
- package/esm/core/DatePicker/DatePicker.js +326 -555
- package/esm/core/Dialog/Dialog.js +24 -53
- package/esm/core/Dialog/DialogBackdrop.js +19 -39
- package/esm/core/Dialog/DialogContent.js +12 -20
- package/esm/core/Dialog/DialogContext.js +1 -1
- package/esm/core/Dialog/DialogDragContext.js +4 -4
- package/esm/core/Dialog/DialogMain.js +107 -177
- package/esm/core/Dialog/DialogTitleBar.js +10 -45
- package/esm/core/Divider/Divider.js +2 -8
- package/esm/core/DropdownMenu/DropdownMenu.js +40 -75
- package/esm/core/ExpandableBlock/ExpandableBlock.js +92 -193
- package/esm/core/Fieldset/Fieldset.js +8 -19
- package/esm/core/FileUpload/FileEmptyCard.js +8 -19
- package/esm/core/FileUpload/FileUpload.js +36 -72
- package/esm/core/FileUpload/FileUploadCard.js +76 -153
- package/esm/core/FileUpload/FileUploadTemplate.js +9 -37
- package/esm/core/Flex/Flex.js +71 -87
- package/esm/core/Footer/Footer.js +55 -86
- package/esm/core/Footer/FooterSeparator.js +1 -1
- package/esm/core/Header/Header.js +14 -55
- package/esm/core/Header/HeaderBasicButton.js +7 -15
- package/esm/core/Header/HeaderBreadcrumbs.js +8 -32
- package/esm/core/Header/HeaderButton.js +14 -62
- package/esm/core/Header/HeaderDropdownButton.js +13 -42
- package/esm/core/Header/HeaderLogo.js +5 -36
- package/esm/core/Header/HeaderSplitButton.js +14 -61
- package/esm/core/Icon/Icon.js +12 -26
- package/esm/core/InformationPanel/InformationPanel.js +36 -71
- package/esm/core/InformationPanel/InformationPanelContent.js +3 -17
- package/esm/core/InformationPanel/InformationPanelHeader.js +8 -32
- package/esm/core/InformationPanel/InformationPanelWrapper.js +1 -3
- package/esm/core/Input/Input.js +4 -12
- package/esm/core/InputGrid/InputGrid.js +2 -11
- package/esm/core/InputGroup/InputGroup.js +16 -57
- package/esm/core/InputWithDecorations/InputWithDecorations.js +11 -42
- package/esm/core/Label/Label.js +5 -26
- package/esm/core/LabeledInput/LabeledInput.js +10 -63
- package/esm/core/LabeledSelect/LabeledSelect.js +18 -67
- package/esm/core/LabeledTextarea/LabeledTextarea.js +2 -8
- package/esm/core/List/ListItem.js +28 -46
- package/esm/core/Menu/Menu.js +48 -64
- package/esm/core/Menu/MenuDivider.js +1 -1
- package/esm/core/Menu/MenuExtraContent.js +1 -1
- package/esm/core/Menu/MenuItem.js +84 -164
- package/esm/core/Menu/MenuItemSkeleton.js +12 -43
- package/esm/core/Modal/Modal.js +6 -33
- package/esm/core/NonIdealState/ErrorPage.js +123 -173
- package/esm/core/NonIdealState/NonIdealState.js +6 -65
- package/esm/core/NotificationMarker/NotificationMarker.js +2 -20
- package/esm/core/Overlay/Overlay.d.ts +20 -24
- package/esm/core/Overlay/Overlay.js +45 -55
- package/esm/core/Popover/Popover.js +80 -172
- package/esm/core/ProgressIndicators/ProgressLinear.js +5 -40
- package/esm/core/ProgressIndicators/ProgressRadial.js +14 -40
- package/esm/core/Radio/Radio.js +6 -45
- package/esm/core/RadioTiles/RadioTile.js +8 -62
- package/esm/core/RadioTiles/RadioTileGroup.js +3 -10
- package/esm/core/SearchBox/SearchBox.js +97 -214
- package/esm/core/Select/Select.js +130 -265
- package/esm/core/Select/SelectTag.js +3 -15
- package/esm/core/Select/SelectTagContainer.js +7 -20
- package/esm/core/SideNavigation/SideNavigation.js +21 -118
- package/esm/core/SideNavigation/SidenavButton.js +2 -24
- package/esm/core/SideNavigation/SidenavSubmenu.js +3 -14
- package/esm/core/SideNavigation/SidenavSubmenuHeader.js +4 -20
- package/esm/core/SkipToContentLink/SkipToContentLink.js +2 -11
- package/esm/core/Slider/Slider.js +187 -340
- package/esm/core/Slider/Thumb.js +50 -97
- package/esm/core/Slider/Track.js +49 -74
- package/esm/core/StatusMessage/StatusMessage.js +5 -23
- package/esm/core/Stepper/Stepper.js +14 -70
- package/esm/core/Stepper/StepperStep.js +29 -92
- package/esm/core/Stepper/WorkflowDiagram.js +8 -21
- package/esm/core/Stepper/WorkflowDiagramStep.js +4 -22
- package/esm/core/Surface/Surface.js +48 -84
- package/esm/core/Table/SubRowExpander.js +9 -31
- package/esm/core/Table/Table.js +408 -763
- package/esm/core/Table/TableCell.js +53 -87
- package/esm/core/Table/TablePaginator.js +125 -306
- package/esm/core/Table/TableRowMemoized.js +58 -129
- package/esm/core/Table/actionHandlers/expandHandler.js +10 -10
- package/esm/core/Table/actionHandlers/filterHandler.js +15 -23
- package/esm/core/Table/actionHandlers/index.js +1 -5
- package/esm/core/Table/actionHandlers/resizeHandler.js +11 -11
- package/esm/core/Table/actionHandlers/selectHandler.js +95 -122
- package/esm/core/Table/cells/DefaultCell.js +7 -42
- package/esm/core/Table/cells/EditableCell.js +41 -70
- package/esm/core/Table/columns/actionColumn.js +55 -85
- package/esm/core/Table/columns/expanderColumn.js +25 -39
- package/esm/core/Table/columns/selectionColumn.js +23 -51
- package/esm/core/Table/filters/BaseFilter.js +7 -15
- package/esm/core/Table/filters/DateRangeFilter/DatePickerInput.js +42 -107
- package/esm/core/Table/filters/DateRangeFilter/DateRangeFilter.js +52 -110
- package/esm/core/Table/filters/FilterButtonBar.js +9 -28
- package/esm/core/Table/filters/FilterToggle.js +18 -51
- package/esm/core/Table/filters/NumberRangeFilter/NumberRangeFilter.js +28 -50
- package/esm/core/Table/filters/TextFilter/TextFilter.js +20 -32
- package/esm/core/Table/filters/customFilterFunctions.js +12 -14
- package/esm/core/Table/filters/defaultFilterFunctions.js +79 -84
- package/esm/core/Table/filters/tableFilters.js +25 -34
- package/esm/core/Table/hooks/useColumnDragAndDrop.js +81 -88
- package/esm/core/Table/hooks/useExpanderCell.js +20 -26
- package/esm/core/Table/hooks/useResizeColumns.js +287 -353
- package/esm/core/Table/hooks/useScrollToRow.js +34 -42
- package/esm/core/Table/hooks/useSelectionCell.js +6 -10
- package/esm/core/Table/hooks/useStickyColumns.js +59 -61
- package/esm/core/Table/hooks/useSubRowFiltering.js +83 -90
- package/esm/core/Table/hooks/useSubRowSelection.js +27 -28
- package/esm/core/Table/index.js +1 -5
- package/esm/core/Table/utils.js +38 -40
- package/esm/core/Tabs/Tabs.js +226 -401
- package/esm/core/Tag/Tag.js +8 -35
- package/esm/core/Tag/TagContainer.js +5 -17
- package/esm/core/Textarea/Textarea.js +1 -6
- package/esm/core/ThemeProvider/ThemeProvider.js +44 -101
- package/esm/core/Tile/Tile.js +218 -386
- package/esm/core/TimePicker/TimePicker.js +228 -448
- package/esm/core/Toast/Toast.js +99 -193
- package/esm/core/Toast/Toaster.js +69 -82
- package/esm/core/ToggleSwitch/ToggleSwitch.js +17 -60
- package/esm/core/Tooltip/Tooltip.js +86 -151
- package/esm/core/TransferList/TransferList.js +93 -157
- package/esm/core/Tree/Tree.js +122 -196
- package/esm/core/Tree/TreeContext.js +5 -5
- package/esm/core/Tree/TreeNode.js +96 -195
- package/esm/core/Tree/TreeNodeExpander.js +5 -16
- package/esm/core/Typography/Blockquote.js +4 -12
- package/esm/core/Typography/Kbd.js +15 -24
- package/esm/core/Typography/Text.js +7 -20
- package/esm/core/VisuallyHidden/VisuallyHidden.js +2 -8
- package/esm/core/utils/color/ColorValue.js +449 -524
- package/esm/core/utils/components/AutoclearingHiddenLiveRegion.js +7 -11
- package/esm/core/utils/components/ButtonBase.js +13 -31
- package/esm/core/utils/components/FocusTrap.js +32 -41
- package/esm/core/utils/components/InputContainer.js +11 -50
- package/esm/core/utils/components/InputFlexContainer.js +2 -15
- package/esm/core/utils/components/MiddleTextTruncation.js +17 -27
- package/esm/core/utils/components/Portal.js +12 -12
- package/esm/core/utils/components/Resizer.js +191 -249
- package/esm/core/utils/components/VirtualScroll.js +218 -297
- package/esm/core/utils/components/WithCSSTransition.js +26 -43
- package/esm/core/utils/functions/colors.js +19 -19
- package/esm/core/utils/functions/date.js +8 -8
- package/esm/core/utils/functions/dev.js +12 -11
- package/esm/core/utils/functions/dom.js +14 -17
- package/esm/core/utils/functions/focusable.js +15 -24
- package/esm/core/utils/functions/import.js +2 -4
- package/esm/core/utils/functions/numbers.js +7 -7
- package/esm/core/utils/functions/polymorphic.js +23 -32
- package/esm/core/utils/functions/react.js +19 -21
- package/esm/core/utils/functions/supports.js +1 -2
- package/esm/core/utils/hooks/useContainerWidth.js +13 -16
- package/esm/core/utils/hooks/useControlledState.js +8 -17
- package/esm/core/utils/hooks/useDragAndDrop.js +80 -99
- package/esm/core/utils/hooks/useEventListener.js +18 -18
- package/esm/core/utils/hooks/useGlobals.js +21 -27
- package/esm/core/utils/hooks/useId.js +3 -4
- package/esm/core/utils/hooks/useIntersection.js +19 -25
- package/esm/core/utils/hooks/useIsClient.js +5 -5
- package/esm/core/utils/hooks/useIsomorphicLayoutEffect.js +1 -2
- package/esm/core/utils/hooks/useLatestRef.js +5 -5
- package/esm/core/utils/hooks/useMediaQuery.js +25 -23
- package/esm/core/utils/hooks/useMergedRefs.js +12 -11
- package/esm/core/utils/hooks/useOverflow.js +51 -63
- package/esm/core/utils/hooks/useResizeObserver.js +12 -17
- package/esm/core/utils/hooks/useSafeContext.js +5 -5
- package/esm/core/utils/icons/StatusIconMap.js +4 -8
- package/esm/core/utils/icons/SvgCalendar.js +2 -7
- package/esm/core/utils/icons/SvgCaretDownSmall.js +2 -7
- package/esm/core/utils/icons/SvgCaretRightSmall.js +2 -7
- package/esm/core/utils/icons/SvgCaretUpSmall.js +2 -7
- package/esm/core/utils/icons/SvgCheckmark.js +2 -5
- package/esm/core/utils/icons/SvgCheckmarkSmall.js +2 -7
- package/esm/core/utils/icons/SvgChevronLeft.js +2 -7
- package/esm/core/utils/icons/SvgChevronLeftDouble.js +2 -7
- package/esm/core/utils/icons/SvgChevronRight.js +2 -7
- package/esm/core/utils/icons/SvgChevronRightDouble.js +2 -7
- package/esm/core/utils/icons/SvgClose.js +2 -7
- package/esm/core/utils/icons/SvgCloseSmall.js +2 -7
- package/esm/core/utils/icons/SvgColumnManager.js +2 -7
- package/esm/core/utils/icons/SvgDocument.js +2 -5
- package/esm/core/utils/icons/SvgFilter.js +2 -5
- package/esm/core/utils/icons/SvgFilterHollow.js +2 -7
- package/esm/core/utils/icons/SvgImportantSmall.js +2 -7
- package/esm/core/utils/icons/SvgInfoCircular.js +2 -7
- package/esm/core/utils/icons/SvgMore.js +2 -7
- package/esm/core/utils/icons/SvgMoreVertical.js +2 -7
- package/esm/core/utils/icons/SvgNew.js +2 -7
- package/esm/core/utils/icons/SvgSearch.js +2 -7
- package/esm/core/utils/icons/SvgSmileyHappy.js +2 -7
- package/esm/core/utils/icons/SvgSortDown.js +2 -7
- package/esm/core/utils/icons/SvgSortUp.js +2 -7
- package/esm/core/utils/icons/SvgStatusError.js +2 -7
- package/esm/core/utils/icons/SvgStatusSuccess.js +2 -7
- package/esm/core/utils/icons/SvgStatusWarning.js +2 -7
- package/esm/core/utils/icons/SvgSwap.js +2 -7
- package/esm/core/utils/icons/SvgUpload.js +2 -7
- package/esm/index.js +3 -21
- package/esm/styles.js +414 -425
- package/package.json +2 -2
- package/styles.css +6 -6
package/cjs/core/Table/Table.js
CHANGED
|
@@ -1,41 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports,
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Table = exports.tableResizeStartAction = void 0;
|
|
4
|
-
const tslib_1 = require(
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
5
|
/*---------------------------------------------------------------------------------------------
|
|
6
6
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
7
7
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
8
8
|
*--------------------------------------------------------------------------------------------*/
|
|
9
|
-
const React = tslib_1.__importStar(require(
|
|
10
|
-
const classnames_1 = tslib_1.__importDefault(require(
|
|
11
|
-
const react_table_1 = require(
|
|
12
|
-
const ProgressRadial_js_1 = require(
|
|
13
|
-
const index_js_1 = require(
|
|
14
|
-
const utils_js_1 = require(
|
|
15
|
-
const TableRowMemoized_js_1 = require(
|
|
16
|
-
const index_js_2 = require(
|
|
17
|
-
const customFilterFunctions_js_1 = require(
|
|
18
|
-
const index_js_3 = require(
|
|
19
|
-
const index_js_4 = require(
|
|
20
|
-
const VirtualScroll_js_1 = tslib_1.__importDefault(
|
|
21
|
-
|
|
22
|
-
);
|
|
23
|
-
const index_js_5 = require('./columns/index.js');
|
|
9
|
+
const React = tslib_1.__importStar(require("react"));
|
|
10
|
+
const classnames_1 = tslib_1.__importDefault(require("classnames"));
|
|
11
|
+
const react_table_1 = require("react-table");
|
|
12
|
+
const ProgressRadial_js_1 = require("../ProgressIndicators/ProgressRadial.js");
|
|
13
|
+
const index_js_1 = require("../utils/index.js");
|
|
14
|
+
const utils_js_1 = require("./utils.js");
|
|
15
|
+
const TableRowMemoized_js_1 = require("./TableRowMemoized.js");
|
|
16
|
+
const index_js_2 = require("./filters/index.js");
|
|
17
|
+
const customFilterFunctions_js_1 = require("./filters/customFilterFunctions.js");
|
|
18
|
+
const index_js_3 = require("./hooks/index.js");
|
|
19
|
+
const index_js_4 = require("./actionHandlers/index.js");
|
|
20
|
+
const VirtualScroll_js_1 = tslib_1.__importDefault(require("../utils/components/VirtualScroll.js"));
|
|
21
|
+
const index_js_5 = require("./columns/index.js");
|
|
24
22
|
const singleRowSelectedAction = 'singleRowSelected';
|
|
25
23
|
const shiftRowSelectedAction = 'shiftRowSelected';
|
|
26
24
|
exports.tableResizeStartAction = 'tableResizeStart';
|
|
27
25
|
const tableResizeEndAction = 'tableResizeEnd';
|
|
28
26
|
const logWarningInDev = (0, index_js_1.createWarningLogger)();
|
|
29
27
|
const flattenColumns = (columns) => {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
28
|
+
const flatColumns = [];
|
|
29
|
+
columns.forEach((column) => {
|
|
30
|
+
flatColumns.push(column);
|
|
31
|
+
if ('columns' in column) {
|
|
32
|
+
// @ts-expect-error - Since nested columns are not supported from a types perspective
|
|
33
|
+
flatColumns.push(...flattenColumns(column.columns));
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
return flatColumns;
|
|
39
37
|
};
|
|
40
38
|
/**
|
|
41
39
|
* Table based on [react-table](https://react-table.tanstack.com/docs/api/overview).
|
|
@@ -75,753 +73,411 @@ const flattenColumns = (columns) => {
|
|
|
75
73
|
* />
|
|
76
74
|
*/
|
|
77
75
|
const Table = (props) => {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
filterTypes: filterFunctions,
|
|
102
|
-
expanderCell,
|
|
103
|
-
isRowDisabled,
|
|
104
|
-
rowProps,
|
|
105
|
-
density = 'default',
|
|
106
|
-
selectSubRows = true,
|
|
107
|
-
getSubRows,
|
|
108
|
-
selectRowOnClick = true,
|
|
109
|
-
paginatorRenderer,
|
|
110
|
-
pageSize = 25,
|
|
111
|
-
isResizable = false,
|
|
112
|
-
columnResizeMode = 'fit',
|
|
113
|
-
styleType = 'default',
|
|
114
|
-
enableVirtualization = false,
|
|
115
|
-
enableColumnReordering = false,
|
|
116
|
-
headerWrapperProps,
|
|
117
|
-
headerProps,
|
|
118
|
-
bodyProps,
|
|
119
|
-
emptyTableContentProps,
|
|
120
|
-
...rest
|
|
121
|
-
} = props;
|
|
122
|
-
(0, index_js_1.useGlobals)();
|
|
123
|
-
const ownerDocument = React.useRef();
|
|
124
|
-
const defaultColumn = React.useMemo(
|
|
125
|
-
() => ({
|
|
126
|
-
maxWidth: 0,
|
|
127
|
-
minWidth: 0,
|
|
128
|
-
width: 0,
|
|
129
|
-
}),
|
|
130
|
-
[],
|
|
131
|
-
);
|
|
132
|
-
// useRef prevents from rerendering when one of these callbacks changes
|
|
133
|
-
const onBottomReachedRef = React.useRef(onBottomReached);
|
|
134
|
-
const onRowInViewportRef = React.useRef(onRowInViewport);
|
|
135
|
-
React.useEffect(() => {
|
|
136
|
-
onBottomReachedRef.current = onBottomReached;
|
|
137
|
-
onRowInViewportRef.current = onRowInViewport;
|
|
138
|
-
}, [onBottomReached, onRowInViewport]);
|
|
139
|
-
const hasManualSelectionColumn = React.useMemo(() => {
|
|
140
|
-
const flatColumns = flattenColumns(columns);
|
|
141
|
-
return flatColumns.some(
|
|
142
|
-
(column) => column.id === index_js_5.SELECTION_CELL_ID,
|
|
143
|
-
);
|
|
144
|
-
}, [columns]);
|
|
145
|
-
const disableUserSelect = React.useCallback((e) => {
|
|
146
|
-
if (e.key === 'Shift') {
|
|
147
|
-
ownerDocument.current &&
|
|
148
|
-
(ownerDocument.current.documentElement.style.userSelect = 'none');
|
|
149
|
-
}
|
|
150
|
-
}, []);
|
|
151
|
-
const enableUserSelect = React.useCallback((e) => {
|
|
152
|
-
if (e.key === 'Shift') {
|
|
153
|
-
ownerDocument.current &&
|
|
154
|
-
(ownerDocument.current.documentElement.style.userSelect = '');
|
|
155
|
-
}
|
|
156
|
-
}, []);
|
|
157
|
-
React.useEffect(() => {
|
|
158
|
-
if (!isSelectable || selectionMode !== 'multi') {
|
|
159
|
-
return;
|
|
160
|
-
}
|
|
161
|
-
const ownerDoc = ownerDocument.current;
|
|
162
|
-
ownerDoc?.addEventListener('keydown', disableUserSelect);
|
|
163
|
-
ownerDoc?.addEventListener('keyup', enableUserSelect);
|
|
164
|
-
return () => {
|
|
165
|
-
ownerDoc?.removeEventListener('keydown', disableUserSelect);
|
|
166
|
-
ownerDoc?.removeEventListener('keyup', enableUserSelect);
|
|
167
|
-
};
|
|
168
|
-
}, [
|
|
169
|
-
isSelectable,
|
|
170
|
-
selectionMode,
|
|
171
|
-
ownerDocument,
|
|
172
|
-
disableUserSelect,
|
|
173
|
-
enableUserSelect,
|
|
174
|
-
]);
|
|
175
|
-
const previousFilter = React.useRef([]);
|
|
176
|
-
const currentFilter = React.useRef(previousFilter.current);
|
|
177
|
-
const tableStateReducer = React.useCallback(
|
|
178
|
-
(newState, action, previousState, instance) => {
|
|
179
|
-
switch (action.type) {
|
|
180
|
-
case react_table_1.actions.toggleSortBy:
|
|
181
|
-
onSort?.(newState);
|
|
182
|
-
break;
|
|
183
|
-
case react_table_1.actions.setFilter:
|
|
184
|
-
currentFilter.current = (0, index_js_4.onFilterHandler)(
|
|
185
|
-
newState,
|
|
186
|
-
action,
|
|
187
|
-
previousState,
|
|
188
|
-
currentFilter.current,
|
|
189
|
-
instance,
|
|
190
|
-
);
|
|
191
|
-
break;
|
|
192
|
-
case react_table_1.actions.toggleRowExpanded:
|
|
193
|
-
case react_table_1.actions.toggleAllRowsExpanded:
|
|
194
|
-
(0, index_js_4.onExpandHandler)(newState, instance, onExpand);
|
|
195
|
-
break;
|
|
196
|
-
case singleRowSelectedAction: {
|
|
197
|
-
newState = (0, index_js_4.onSingleSelectHandler)(
|
|
198
|
-
newState,
|
|
199
|
-
action,
|
|
200
|
-
instance,
|
|
201
|
-
onSelect,
|
|
202
|
-
// If it has manual selection column, then we can't check whether row is disabled
|
|
203
|
-
hasManualSelectionColumn ? undefined : isRowDisabled,
|
|
204
|
-
);
|
|
205
|
-
break;
|
|
76
|
+
const { data, columns, isLoading = false, emptyTableContent, className, style, id, isSelectable = false, onSelect, onRowClick, selectionMode = 'multi', isSortable = false, onSort, stateReducer, onBottomReached, onRowInViewport, intersectionMargin = 300, subComponent, onExpand, onFilter, globalFilterValue, emptyFilteredTableContent, filterTypes: filterFunctions, expanderCell, isRowDisabled, rowProps, density = 'default', selectSubRows = true, getSubRows, selectRowOnClick = true, paginatorRenderer, pageSize = 25, isResizable = false, columnResizeMode = 'fit', styleType = 'default', enableVirtualization = false, enableColumnReordering = false, headerWrapperProps, headerProps, bodyProps, emptyTableContentProps, ...rest } = props;
|
|
77
|
+
(0, index_js_1.useGlobals)();
|
|
78
|
+
const ownerDocument = React.useRef();
|
|
79
|
+
const defaultColumn = React.useMemo(() => ({
|
|
80
|
+
maxWidth: 0,
|
|
81
|
+
minWidth: 0,
|
|
82
|
+
width: 0,
|
|
83
|
+
}), []);
|
|
84
|
+
// useRef prevents from rerendering when one of these callbacks changes
|
|
85
|
+
const onBottomReachedRef = React.useRef(onBottomReached);
|
|
86
|
+
const onRowInViewportRef = React.useRef(onRowInViewport);
|
|
87
|
+
React.useEffect(() => {
|
|
88
|
+
onBottomReachedRef.current = onBottomReached;
|
|
89
|
+
onRowInViewportRef.current = onRowInViewport;
|
|
90
|
+
}, [onBottomReached, onRowInViewport]);
|
|
91
|
+
const hasManualSelectionColumn = React.useMemo(() => {
|
|
92
|
+
const flatColumns = flattenColumns(columns);
|
|
93
|
+
return flatColumns.some((column) => column.id === index_js_5.SELECTION_CELL_ID);
|
|
94
|
+
}, [columns]);
|
|
95
|
+
const disableUserSelect = React.useCallback((e) => {
|
|
96
|
+
if (e.key === 'Shift') {
|
|
97
|
+
ownerDocument.current &&
|
|
98
|
+
(ownerDocument.current.documentElement.style.userSelect = 'none');
|
|
206
99
|
}
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
onSelect,
|
|
213
|
-
// If it has manual selection column, then we can't check whether row is disabled
|
|
214
|
-
hasManualSelectionColumn ? undefined : isRowDisabled,
|
|
215
|
-
);
|
|
216
|
-
break;
|
|
100
|
+
}, []);
|
|
101
|
+
const enableUserSelect = React.useCallback((e) => {
|
|
102
|
+
if (e.key === 'Shift') {
|
|
103
|
+
ownerDocument.current &&
|
|
104
|
+
(ownerDocument.current.documentElement.style.userSelect = '');
|
|
217
105
|
}
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
newState,
|
|
223
|
-
action,
|
|
224
|
-
instance,
|
|
225
|
-
onSelect,
|
|
226
|
-
// If it has manual selection column, then we can't check whether row is disabled
|
|
227
|
-
hasManualSelectionColumn ? undefined : isRowDisabled,
|
|
228
|
-
);
|
|
229
|
-
break;
|
|
106
|
+
}, []);
|
|
107
|
+
React.useEffect(() => {
|
|
108
|
+
if (!isSelectable || selectionMode !== 'multi') {
|
|
109
|
+
return;
|
|
230
110
|
}
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
111
|
+
const ownerDoc = ownerDocument.current;
|
|
112
|
+
ownerDoc?.addEventListener('keydown', disableUserSelect);
|
|
113
|
+
ownerDoc?.addEventListener('keyup', enableUserSelect);
|
|
114
|
+
return () => {
|
|
115
|
+
ownerDoc?.removeEventListener('keydown', disableUserSelect);
|
|
116
|
+
ownerDoc?.removeEventListener('keyup', enableUserSelect);
|
|
117
|
+
};
|
|
118
|
+
}, [
|
|
119
|
+
isSelectable,
|
|
120
|
+
selectionMode,
|
|
121
|
+
ownerDocument,
|
|
122
|
+
disableUserSelect,
|
|
123
|
+
enableUserSelect,
|
|
124
|
+
]);
|
|
125
|
+
const previousFilter = React.useRef([]);
|
|
126
|
+
const currentFilter = React.useRef(previousFilter.current);
|
|
127
|
+
const tableStateReducer = React.useCallback((newState, action, previousState, instance) => {
|
|
128
|
+
switch (action.type) {
|
|
129
|
+
case react_table_1.actions.toggleSortBy:
|
|
130
|
+
onSort?.(newState);
|
|
131
|
+
break;
|
|
132
|
+
case react_table_1.actions.setFilter:
|
|
133
|
+
currentFilter.current = (0, index_js_4.onFilterHandler)(newState, action, previousState, currentFilter.current, instance);
|
|
134
|
+
break;
|
|
135
|
+
case react_table_1.actions.toggleRowExpanded:
|
|
136
|
+
case react_table_1.actions.toggleAllRowsExpanded:
|
|
137
|
+
(0, index_js_4.onExpandHandler)(newState, instance, onExpand);
|
|
138
|
+
break;
|
|
139
|
+
case singleRowSelectedAction: {
|
|
140
|
+
newState = (0, index_js_4.onSingleSelectHandler)(newState, action, instance, onSelect,
|
|
141
|
+
// If it has manual selection column, then we can't check whether row is disabled
|
|
142
|
+
hasManualSelectionColumn ? undefined : isRowDisabled);
|
|
143
|
+
break;
|
|
144
|
+
}
|
|
145
|
+
case shiftRowSelectedAction: {
|
|
146
|
+
newState = (0, index_js_4.onShiftSelectHandler)(newState, action, instance, onSelect,
|
|
147
|
+
// If it has manual selection column, then we can't check whether row is disabled
|
|
148
|
+
hasManualSelectionColumn ? undefined : isRowDisabled);
|
|
149
|
+
break;
|
|
150
|
+
}
|
|
151
|
+
case react_table_1.actions.toggleRowSelected:
|
|
152
|
+
case react_table_1.actions.toggleAllRowsSelected:
|
|
153
|
+
case react_table_1.actions.toggleAllPageRowsSelected: {
|
|
154
|
+
(0, index_js_4.onToggleHandler)(newState, action, instance, onSelect,
|
|
155
|
+
// If it has manual selection column, then we can't check whether row is disabled
|
|
156
|
+
hasManualSelectionColumn ? undefined : isRowDisabled);
|
|
157
|
+
break;
|
|
158
|
+
}
|
|
159
|
+
case exports.tableResizeStartAction: {
|
|
160
|
+
newState = (0, index_js_4.onTableResizeStart)(newState);
|
|
161
|
+
break;
|
|
162
|
+
}
|
|
163
|
+
case tableResizeEndAction: {
|
|
164
|
+
newState = (0, index_js_4.onTableResizeEnd)(newState, action);
|
|
165
|
+
break;
|
|
166
|
+
}
|
|
167
|
+
default:
|
|
168
|
+
break;
|
|
234
169
|
}
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
170
|
+
return stateReducer
|
|
171
|
+
? stateReducer(newState, action, previousState, instance)
|
|
172
|
+
: newState;
|
|
173
|
+
}, [
|
|
174
|
+
hasManualSelectionColumn,
|
|
175
|
+
isRowDisabled,
|
|
176
|
+
onExpand,
|
|
177
|
+
onSelect,
|
|
178
|
+
onSort,
|
|
179
|
+
stateReducer,
|
|
180
|
+
]);
|
|
181
|
+
const filterTypes = React.useMemo(() => ({ ...customFilterFunctions_js_1.customFilterFunctions, ...filterFunctions }), [filterFunctions]);
|
|
182
|
+
const hasAnySubRows = React.useMemo(() => {
|
|
183
|
+
return data.some((item, index) => getSubRows ? getSubRows(item, index) : item.subRows);
|
|
184
|
+
}, [data, getSubRows]);
|
|
185
|
+
const instance = (0, react_table_1.useTable)({
|
|
186
|
+
manualPagination: !paginatorRenderer,
|
|
187
|
+
paginateExpandedRows: false,
|
|
188
|
+
...props,
|
|
189
|
+
columns,
|
|
190
|
+
defaultColumn,
|
|
191
|
+
disableSortBy: !isSortable,
|
|
192
|
+
stateReducer: tableStateReducer,
|
|
193
|
+
filterTypes,
|
|
194
|
+
selectSubRows,
|
|
195
|
+
data,
|
|
196
|
+
getSubRows,
|
|
197
|
+
initialState: { pageSize, ...props.initialState },
|
|
198
|
+
columnResizeMode,
|
|
199
|
+
}, react_table_1.useFlexLayout, (0, index_js_3.useResizeColumns)(ownerDocument), react_table_1.useFilters, (0, index_js_3.useSubRowFiltering)(hasAnySubRows), react_table_1.useGlobalFilter, react_table_1.useSortBy, react_table_1.useExpanded, react_table_1.usePagination, react_table_1.useRowSelect, index_js_3.useSubRowSelection, (0, index_js_3.useExpanderCell)(subComponent, expanderCell, isRowDisabled), (0, index_js_3.useSelectionCell)(isSelectable, selectionMode, isRowDisabled, density), react_table_1.useColumnOrder, (0, index_js_3.useColumnDragAndDrop)(enableColumnReordering), index_js_3.useStickyColumns);
|
|
200
|
+
const { getTableProps, rows, headerGroups: _headerGroups, getTableBodyProps, prepareRow, state, allColumns, dispatch, page, gotoPage, setPageSize, flatHeaders, visibleColumns, setGlobalFilter, } = instance;
|
|
201
|
+
let headerGroups = _headerGroups;
|
|
202
|
+
if (columns.length === 1 && 'columns' in columns[0]) {
|
|
203
|
+
headerGroups = _headerGroups.slice(1);
|
|
204
|
+
logWarningInDev(`Table's \`columns\` prop should not have a top-level \`Header\` or sub-columns. They are only allowed to be passed for backwards compatibility.\n See https://github.com/iTwin/iTwinUI/wiki/iTwinUI-react-v2-migration-guide#breaking-changes`);
|
|
205
|
+
}
|
|
206
|
+
const ariaDataAttributes = Object.entries(rest).reduce((result, [key, value]) => {
|
|
207
|
+
if (key.startsWith('data-') || key.startsWith('aria-')) {
|
|
208
|
+
result[key] = value;
|
|
238
209
|
}
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
onExpand,
|
|
250
|
-
onSelect,
|
|
251
|
-
onSort,
|
|
252
|
-
stateReducer,
|
|
253
|
-
],
|
|
254
|
-
);
|
|
255
|
-
const filterTypes = React.useMemo(
|
|
256
|
-
() => ({
|
|
257
|
-
...customFilterFunctions_js_1.customFilterFunctions,
|
|
258
|
-
...filterFunctions,
|
|
259
|
-
}),
|
|
260
|
-
[filterFunctions],
|
|
261
|
-
);
|
|
262
|
-
const hasAnySubRows = React.useMemo(() => {
|
|
263
|
-
return data.some((item, index) =>
|
|
264
|
-
getSubRows ? getSubRows(item, index) : item.subRows,
|
|
265
|
-
);
|
|
266
|
-
}, [data, getSubRows]);
|
|
267
|
-
const instance = (0, react_table_1.useTable)(
|
|
268
|
-
{
|
|
269
|
-
manualPagination: !paginatorRenderer,
|
|
270
|
-
paginateExpandedRows: false,
|
|
271
|
-
...props,
|
|
272
|
-
columns,
|
|
273
|
-
defaultColumn,
|
|
274
|
-
disableSortBy: !isSortable,
|
|
275
|
-
stateReducer: tableStateReducer,
|
|
276
|
-
filterTypes,
|
|
277
|
-
selectSubRows,
|
|
278
|
-
data,
|
|
279
|
-
getSubRows,
|
|
280
|
-
initialState: { pageSize, ...props.initialState },
|
|
281
|
-
columnResizeMode,
|
|
282
|
-
},
|
|
283
|
-
react_table_1.useFlexLayout,
|
|
284
|
-
(0, index_js_3.useResizeColumns)(ownerDocument),
|
|
285
|
-
react_table_1.useFilters,
|
|
286
|
-
(0, index_js_3.useSubRowFiltering)(hasAnySubRows),
|
|
287
|
-
react_table_1.useGlobalFilter,
|
|
288
|
-
react_table_1.useSortBy,
|
|
289
|
-
react_table_1.useExpanded,
|
|
290
|
-
react_table_1.usePagination,
|
|
291
|
-
react_table_1.useRowSelect,
|
|
292
|
-
index_js_3.useSubRowSelection,
|
|
293
|
-
(0, index_js_3.useExpanderCell)(subComponent, expanderCell, isRowDisabled),
|
|
294
|
-
(0, index_js_3.useSelectionCell)(
|
|
295
|
-
isSelectable,
|
|
296
|
-
selectionMode,
|
|
297
|
-
isRowDisabled,
|
|
298
|
-
density,
|
|
299
|
-
),
|
|
300
|
-
react_table_1.useColumnOrder,
|
|
301
|
-
(0, index_js_3.useColumnDragAndDrop)(enableColumnReordering),
|
|
302
|
-
index_js_3.useStickyColumns,
|
|
303
|
-
);
|
|
304
|
-
const {
|
|
305
|
-
getTableProps,
|
|
306
|
-
rows,
|
|
307
|
-
headerGroups: _headerGroups,
|
|
308
|
-
getTableBodyProps,
|
|
309
|
-
prepareRow,
|
|
310
|
-
state,
|
|
311
|
-
allColumns,
|
|
312
|
-
dispatch,
|
|
313
|
-
page,
|
|
314
|
-
gotoPage,
|
|
315
|
-
setPageSize,
|
|
316
|
-
flatHeaders,
|
|
317
|
-
visibleColumns,
|
|
318
|
-
setGlobalFilter,
|
|
319
|
-
} = instance;
|
|
320
|
-
let headerGroups = _headerGroups;
|
|
321
|
-
if (columns.length === 1 && 'columns' in columns[0]) {
|
|
322
|
-
headerGroups = _headerGroups.slice(1);
|
|
323
|
-
logWarningInDev(
|
|
324
|
-
`Table's \`columns\` prop should not have a top-level \`Header\` or sub-columns. They are only allowed to be passed for backwards compatibility.\n See https://github.com/iTwin/iTwinUI/wiki/iTwinUI-react-v2-migration-guide#breaking-changes`,
|
|
325
|
-
);
|
|
326
|
-
}
|
|
327
|
-
const ariaDataAttributes = Object.entries(rest).reduce(
|
|
328
|
-
(result, [key, value]) => {
|
|
329
|
-
if (key.startsWith('data-') || key.startsWith('aria-')) {
|
|
330
|
-
result[key] = value;
|
|
331
|
-
}
|
|
332
|
-
return result;
|
|
333
|
-
},
|
|
334
|
-
{},
|
|
335
|
-
);
|
|
336
|
-
const areFiltersSet =
|
|
337
|
-
allColumns.some(
|
|
338
|
-
(column) => column.filterValue != null && column.filterValue !== '',
|
|
339
|
-
) || !!globalFilterValue;
|
|
340
|
-
const showFilterButton = (column) =>
|
|
341
|
-
(data.length !== 0 || areFiltersSet) && column.canFilter && !!column.Filter;
|
|
342
|
-
const showSortButton = (column) => data.length !== 0 && column.canSort;
|
|
343
|
-
const onRowClickHandler = React.useCallback(
|
|
344
|
-
(event, row) => {
|
|
345
|
-
const isDisabled = isRowDisabled?.(row.original);
|
|
346
|
-
const ctrlPressed = event.ctrlKey || event.metaKey;
|
|
347
|
-
if (!isDisabled) {
|
|
348
|
-
onRowClick?.(event, row);
|
|
349
|
-
}
|
|
350
|
-
if (
|
|
351
|
-
isSelectable &&
|
|
352
|
-
!isDisabled &&
|
|
353
|
-
selectRowOnClick &&
|
|
354
|
-
!event.isDefaultPrevented()
|
|
355
|
-
) {
|
|
356
|
-
if (selectionMode === 'multi' && event.shiftKey) {
|
|
357
|
-
dispatch({
|
|
358
|
-
type: shiftRowSelectedAction,
|
|
359
|
-
id: row.id,
|
|
360
|
-
ctrlPressed: ctrlPressed,
|
|
361
|
-
});
|
|
362
|
-
} else if (
|
|
363
|
-
!row.isSelected &&
|
|
364
|
-
(selectionMode === 'single' || !ctrlPressed)
|
|
365
|
-
) {
|
|
366
|
-
dispatch({
|
|
367
|
-
type: singleRowSelectedAction,
|
|
368
|
-
id: row.id,
|
|
369
|
-
});
|
|
370
|
-
} else {
|
|
371
|
-
row.toggleRowSelected(!row.isSelected);
|
|
210
|
+
return result;
|
|
211
|
+
}, {});
|
|
212
|
+
const areFiltersSet = allColumns.some((column) => column.filterValue != null && column.filterValue !== '') || !!globalFilterValue;
|
|
213
|
+
const showFilterButton = (column) => (data.length !== 0 || areFiltersSet) && column.canFilter && !!column.Filter;
|
|
214
|
+
const showSortButton = (column) => data.length !== 0 && column.canSort;
|
|
215
|
+
const onRowClickHandler = React.useCallback((event, row) => {
|
|
216
|
+
const isDisabled = isRowDisabled?.(row.original);
|
|
217
|
+
const ctrlPressed = event.ctrlKey || event.metaKey;
|
|
218
|
+
if (!isDisabled) {
|
|
219
|
+
onRowClick?.(event, row);
|
|
372
220
|
}
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
}
|
|
395
|
-
}, [state, instance.filteredRows, onFilter]);
|
|
396
|
-
const lastPassedColumns = React.useRef([]);
|
|
397
|
-
// Reset the column order whenever new columns are passed
|
|
398
|
-
// This is to avoid the old columnOrder from affecting the new columns' columnOrder
|
|
399
|
-
React.useEffect(() => {
|
|
400
|
-
// Check if columns have changed (by value)
|
|
401
|
-
if (JSON.stringify(lastPassedColumns.current) !== JSON.stringify(columns)) {
|
|
402
|
-
instance.setColumnOrder([]);
|
|
403
|
-
}
|
|
404
|
-
lastPassedColumns.current = columns;
|
|
405
|
-
}, [columns, instance]);
|
|
406
|
-
const paginatorRendererProps = React.useMemo(
|
|
407
|
-
() => ({
|
|
408
|
-
currentPage: state.pageIndex,
|
|
409
|
-
pageSize: state.pageSize,
|
|
410
|
-
totalRowsCount: rows.length,
|
|
411
|
-
size: density !== 'default' ? 'small' : 'default',
|
|
412
|
-
isLoading,
|
|
413
|
-
onPageChange: gotoPage,
|
|
414
|
-
onPageSizeChange: setPageSize,
|
|
415
|
-
totalSelectedRowsCount:
|
|
416
|
-
selectionMode === 'single' ? 0 : instance.selectedFlatRows.length, // 0 when selectionMode = 'single' since totalSelectedRowCount is for multi-selection mode only
|
|
417
|
-
}),
|
|
418
|
-
[
|
|
419
|
-
density,
|
|
420
|
-
gotoPage,
|
|
421
|
-
isLoading,
|
|
422
|
-
rows.length,
|
|
423
|
-
setPageSize,
|
|
424
|
-
state.pageIndex,
|
|
425
|
-
state.pageSize,
|
|
426
|
-
instance.selectedFlatRows,
|
|
427
|
-
selectionMode,
|
|
428
|
-
],
|
|
429
|
-
);
|
|
430
|
-
const { scrollToIndex, tableRowRef } = (0, index_js_3.useScrollToRow)({
|
|
431
|
-
...props,
|
|
432
|
-
page,
|
|
433
|
-
});
|
|
434
|
-
const columnRefs = React.useRef({});
|
|
435
|
-
const previousTableWidth = React.useRef(0);
|
|
436
|
-
const onTableResize = React.useCallback(
|
|
437
|
-
({ width }) => {
|
|
438
|
-
instance.tableWidth = width;
|
|
439
|
-
if (width === previousTableWidth.current) {
|
|
440
|
-
return;
|
|
441
|
-
}
|
|
442
|
-
previousTableWidth.current = width;
|
|
443
|
-
// Update column widths when table was resized
|
|
444
|
-
flatHeaders.forEach((header) => {
|
|
445
|
-
if (columnRefs.current[header.id]) {
|
|
446
|
-
header.resizeWidth =
|
|
447
|
-
columnRefs.current[header.id].getBoundingClientRect().width;
|
|
221
|
+
if (isSelectable &&
|
|
222
|
+
!isDisabled &&
|
|
223
|
+
selectRowOnClick &&
|
|
224
|
+
!event.isDefaultPrevented()) {
|
|
225
|
+
if (selectionMode === 'multi' && event.shiftKey) {
|
|
226
|
+
dispatch({
|
|
227
|
+
type: shiftRowSelectedAction,
|
|
228
|
+
id: row.id,
|
|
229
|
+
ctrlPressed: ctrlPressed,
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
else if (!row.isSelected &&
|
|
233
|
+
(selectionMode === 'single' || !ctrlPressed)) {
|
|
234
|
+
dispatch({
|
|
235
|
+
type: singleRowSelectedAction,
|
|
236
|
+
id: row.id,
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
else {
|
|
240
|
+
row.toggleRowSelected(!row.isSelected);
|
|
241
|
+
}
|
|
448
242
|
}
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
if (
|
|
465
|
-
|
|
466
|
-
|
|
243
|
+
}, [
|
|
244
|
+
isRowDisabled,
|
|
245
|
+
isSelectable,
|
|
246
|
+
selectRowOnClick,
|
|
247
|
+
selectionMode,
|
|
248
|
+
dispatch,
|
|
249
|
+
onRowClick,
|
|
250
|
+
]);
|
|
251
|
+
React.useEffect(() => {
|
|
252
|
+
setGlobalFilter(globalFilterValue);
|
|
253
|
+
}, [globalFilterValue, setGlobalFilter]);
|
|
254
|
+
React.useEffect(() => {
|
|
255
|
+
setPageSize(pageSize);
|
|
256
|
+
}, [pageSize, setPageSize]);
|
|
257
|
+
React.useEffect(() => {
|
|
258
|
+
if (previousFilter.current !== currentFilter.current) {
|
|
259
|
+
previousFilter.current = currentFilter.current;
|
|
260
|
+
onFilter?.(currentFilter.current, state, instance.filteredRows);
|
|
467
261
|
}
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
);
|
|
515
|
-
const virtualizedItemRenderer = React.useCallback(
|
|
516
|
-
(index) => getPreparedRow(index),
|
|
517
|
-
[getPreparedRow],
|
|
518
|
-
);
|
|
519
|
-
const updateStickyState = () => {
|
|
520
|
-
if (!bodyRef.current || flatHeaders.every((header) => !header.sticky)) {
|
|
521
|
-
return;
|
|
522
|
-
}
|
|
523
|
-
if (bodyRef.current.scrollLeft !== 0) {
|
|
524
|
-
dispatch({ type: react_table_1.actions.setScrolledRight, value: true });
|
|
525
|
-
} else {
|
|
526
|
-
dispatch({ type: react_table_1.actions.setScrolledRight, value: false });
|
|
527
|
-
}
|
|
528
|
-
// If scrolled a bit to the left looking from the right side
|
|
529
|
-
if (
|
|
530
|
-
bodyRef.current.scrollLeft !==
|
|
531
|
-
bodyRef.current.scrollWidth - bodyRef.current.clientWidth
|
|
532
|
-
) {
|
|
533
|
-
dispatch({ type: react_table_1.actions.setScrolledLeft, value: true });
|
|
534
|
-
} else {
|
|
535
|
-
dispatch({ type: react_table_1.actions.setScrolledLeft, value: false });
|
|
536
|
-
}
|
|
537
|
-
};
|
|
538
|
-
React.useEffect(() => {
|
|
539
|
-
updateStickyState();
|
|
540
|
-
// Call only on init
|
|
541
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
542
|
-
}, []);
|
|
543
|
-
const isHeaderDirectClick = React.useRef(false);
|
|
544
|
-
return React.createElement(
|
|
545
|
-
React.Fragment,
|
|
546
|
-
null,
|
|
547
|
-
React.createElement(
|
|
548
|
-
index_js_1.Box,
|
|
549
|
-
{
|
|
550
|
-
ref: (element) => {
|
|
551
|
-
ownerDocument.current = element?.ownerDocument;
|
|
552
|
-
if (isResizable) {
|
|
553
|
-
resizeRef(element);
|
|
554
|
-
}
|
|
555
|
-
},
|
|
556
|
-
id: id,
|
|
557
|
-
...getTableProps({
|
|
558
|
-
className: (0, classnames_1.default)('iui-table', className),
|
|
559
|
-
style: {
|
|
560
|
-
minWidth: 0,
|
|
561
|
-
...style,
|
|
562
|
-
},
|
|
563
|
-
}),
|
|
564
|
-
'data-iui-size': density === 'default' ? undefined : density,
|
|
565
|
-
...ariaDataAttributes,
|
|
566
|
-
},
|
|
567
|
-
headerGroups.map((headerGroup) => {
|
|
568
|
-
// There may be a better solution for this, but for now I'm filtering out the placeholder cells using header.id
|
|
569
|
-
headerGroup.headers = headerGroup.headers.filter(
|
|
570
|
-
(header) =>
|
|
571
|
-
!header.id.includes('iui-table-checkbox-selector_placeholder') &&
|
|
572
|
-
!header.id.includes('iui-table-expander_placeholder'),
|
|
573
|
-
);
|
|
574
|
-
const headerGroupProps = headerGroup.getHeaderGroupProps({
|
|
575
|
-
className: 'iui-table-row',
|
|
262
|
+
}, [state, instance.filteredRows, onFilter]);
|
|
263
|
+
const lastPassedColumns = React.useRef([]);
|
|
264
|
+
// Reset the column order whenever new columns are passed
|
|
265
|
+
// This is to avoid the old columnOrder from affecting the new columns' columnOrder
|
|
266
|
+
React.useEffect(() => {
|
|
267
|
+
// Check if columns have changed (by value)
|
|
268
|
+
if (JSON.stringify(lastPassedColumns.current) !== JSON.stringify(columns)) {
|
|
269
|
+
instance.setColumnOrder([]);
|
|
270
|
+
}
|
|
271
|
+
lastPassedColumns.current = columns;
|
|
272
|
+
}, [columns, instance]);
|
|
273
|
+
const paginatorRendererProps = React.useMemo(() => ({
|
|
274
|
+
currentPage: state.pageIndex,
|
|
275
|
+
pageSize: state.pageSize,
|
|
276
|
+
totalRowsCount: rows.length,
|
|
277
|
+
size: density !== 'default' ? 'small' : 'default',
|
|
278
|
+
isLoading,
|
|
279
|
+
onPageChange: gotoPage,
|
|
280
|
+
onPageSizeChange: setPageSize,
|
|
281
|
+
totalSelectedRowsCount: selectionMode === 'single' ? 0 : instance.selectedFlatRows.length, // 0 when selectionMode = 'single' since totalSelectedRowCount is for multi-selection mode only
|
|
282
|
+
}), [
|
|
283
|
+
density,
|
|
284
|
+
gotoPage,
|
|
285
|
+
isLoading,
|
|
286
|
+
rows.length,
|
|
287
|
+
setPageSize,
|
|
288
|
+
state.pageIndex,
|
|
289
|
+
state.pageSize,
|
|
290
|
+
instance.selectedFlatRows,
|
|
291
|
+
selectionMode,
|
|
292
|
+
]);
|
|
293
|
+
const { scrollToIndex, tableRowRef } = (0, index_js_3.useScrollToRow)({ ...props, page });
|
|
294
|
+
const columnRefs = React.useRef({});
|
|
295
|
+
const previousTableWidth = React.useRef(0);
|
|
296
|
+
const onTableResize = React.useCallback(({ width }) => {
|
|
297
|
+
instance.tableWidth = width;
|
|
298
|
+
if (width === previousTableWidth.current) {
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
301
|
+
previousTableWidth.current = width;
|
|
302
|
+
// Update column widths when table was resized
|
|
303
|
+
flatHeaders.forEach((header) => {
|
|
304
|
+
if (columnRefs.current[header.id]) {
|
|
305
|
+
header.resizeWidth =
|
|
306
|
+
columnRefs.current[header.id].getBoundingClientRect().width;
|
|
307
|
+
}
|
|
576
308
|
});
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
}
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
)
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
309
|
+
// If no column was resized then leave table resize handling to the flexbox
|
|
310
|
+
if (Object.keys(state.columnResizing.columnWidths).length === 0) {
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
313
|
+
dispatch({ type: exports.tableResizeStartAction });
|
|
314
|
+
}, [dispatch, state.columnResizing.columnWidths, flatHeaders, instance]);
|
|
315
|
+
const [resizeRef] = (0, index_js_1.useResizeObserver)(onTableResize);
|
|
316
|
+
// Flexbox handles columns resize so we take new column widths before browser repaints.
|
|
317
|
+
(0, index_js_1.useIsomorphicLayoutEffect)(() => {
|
|
318
|
+
if (state.isTableResizing) {
|
|
319
|
+
const newColumnWidths = {};
|
|
320
|
+
flatHeaders.forEach((column) => {
|
|
321
|
+
if (columnRefs.current[column.id]) {
|
|
322
|
+
newColumnWidths[column.id] =
|
|
323
|
+
columnRefs.current[column.id].getBoundingClientRect().width;
|
|
324
|
+
}
|
|
325
|
+
});
|
|
326
|
+
dispatch({ type: tableResizeEndAction, columnWidths: newColumnWidths });
|
|
327
|
+
}
|
|
328
|
+
});
|
|
329
|
+
const headerRef = React.useRef(null);
|
|
330
|
+
const bodyRef = React.useRef(null);
|
|
331
|
+
const getPreparedRow = React.useCallback((index) => {
|
|
332
|
+
const row = page[index];
|
|
333
|
+
prepareRow(row);
|
|
334
|
+
return (React.createElement(TableRowMemoized_js_1.TableRowMemoized, { row: row, rowProps: rowProps, isLast: index === page.length - 1, onRowInViewport: onRowInViewportRef, onBottomReached: onBottomReachedRef, intersectionMargin: intersectionMargin, state: state, key: row.getRowProps().key, onClick: onRowClickHandler, subComponent: subComponent, isDisabled: !!isRowDisabled?.(row.original), tableHasSubRows: hasAnySubRows, tableInstance: instance, expanderCell: expanderCell, bodyRef: bodyRef.current, tableRowRef: enableVirtualization ? undefined : tableRowRef(row), density: density }));
|
|
335
|
+
}, [
|
|
336
|
+
page,
|
|
337
|
+
prepareRow,
|
|
338
|
+
rowProps,
|
|
339
|
+
intersectionMargin,
|
|
340
|
+
state,
|
|
341
|
+
onRowClickHandler,
|
|
342
|
+
subComponent,
|
|
343
|
+
isRowDisabled,
|
|
344
|
+
hasAnySubRows,
|
|
345
|
+
instance,
|
|
346
|
+
expanderCell,
|
|
347
|
+
enableVirtualization,
|
|
348
|
+
tableRowRef,
|
|
349
|
+
density,
|
|
350
|
+
]);
|
|
351
|
+
const virtualizedItemRenderer = React.useCallback((index) => getPreparedRow(index), [getPreparedRow]);
|
|
352
|
+
const updateStickyState = () => {
|
|
353
|
+
if (!bodyRef.current || flatHeaders.every((header) => !header.sticky)) {
|
|
354
|
+
return;
|
|
355
|
+
}
|
|
356
|
+
if (bodyRef.current.scrollLeft !== 0) {
|
|
357
|
+
dispatch({ type: react_table_1.actions.setScrolledRight, value: true });
|
|
358
|
+
}
|
|
359
|
+
else {
|
|
360
|
+
dispatch({ type: react_table_1.actions.setScrolledRight, value: false });
|
|
361
|
+
}
|
|
362
|
+
// If scrolled a bit to the left looking from the right side
|
|
363
|
+
if (bodyRef.current.scrollLeft !==
|
|
364
|
+
bodyRef.current.scrollWidth - bodyRef.current.clientWidth) {
|
|
365
|
+
dispatch({ type: react_table_1.actions.setScrolledLeft, value: true });
|
|
366
|
+
}
|
|
367
|
+
else {
|
|
368
|
+
dispatch({ type: react_table_1.actions.setScrolledLeft, value: false });
|
|
369
|
+
}
|
|
370
|
+
};
|
|
371
|
+
React.useEffect(() => {
|
|
372
|
+
updateStickyState();
|
|
373
|
+
// Call only on init
|
|
374
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
375
|
+
}, []);
|
|
376
|
+
const isHeaderDirectClick = React.useRef(false);
|
|
377
|
+
return (React.createElement(React.Fragment, null,
|
|
378
|
+
React.createElement(index_js_1.Box, { ref: (element) => {
|
|
379
|
+
ownerDocument.current = element?.ownerDocument;
|
|
380
|
+
if (isResizable) {
|
|
381
|
+
resizeRef(element);
|
|
382
|
+
}
|
|
383
|
+
}, id: id, ...getTableProps({
|
|
384
|
+
className: (0, classnames_1.default)('iui-table', className),
|
|
385
|
+
style: {
|
|
386
|
+
minWidth: 0,
|
|
387
|
+
...style,
|
|
388
|
+
},
|
|
389
|
+
}), "data-iui-size": density === 'default' ? undefined : density, ...ariaDataAttributes },
|
|
390
|
+
headerGroups.map((headerGroup) => {
|
|
391
|
+
// There may be a better solution for this, but for now I'm filtering out the placeholder cells using header.id
|
|
392
|
+
headerGroup.headers = headerGroup.headers.filter((header) => !header.id.includes('iui-table-checkbox-selector_placeholder') &&
|
|
393
|
+
!header.id.includes('iui-table-expander_placeholder'));
|
|
394
|
+
const headerGroupProps = headerGroup.getHeaderGroupProps({
|
|
395
|
+
className: 'iui-table-row',
|
|
630
396
|
});
|
|
631
|
-
return React.createElement(
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
key:
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
React.createElement(
|
|
691
|
-
index_js_1.Box,
|
|
692
|
-
{
|
|
693
|
-
...column.getResizerProps(),
|
|
694
|
-
className: 'iui-table-resizer',
|
|
695
|
-
},
|
|
696
|
-
React.createElement(index_js_1.Box, {
|
|
697
|
-
className: 'iui-table-resizer-bar',
|
|
698
|
-
}),
|
|
699
|
-
),
|
|
700
|
-
enableColumnReordering &&
|
|
701
|
-
!column.disableReordering &&
|
|
702
|
-
React.createElement(index_js_1.Box, {
|
|
703
|
-
className: 'iui-table-reorder-bar',
|
|
704
|
-
}),
|
|
705
|
-
column.sticky === 'left' &&
|
|
706
|
-
state.sticky.isScrolledToRight &&
|
|
707
|
-
React.createElement(index_js_1.Box, {
|
|
708
|
-
className: 'iui-table-cell-shadow-right',
|
|
709
|
-
}),
|
|
710
|
-
column.sticky === 'right' &&
|
|
711
|
-
state.sticky.isScrolledToLeft &&
|
|
712
|
-
React.createElement(index_js_1.Box, {
|
|
713
|
-
className: 'iui-table-cell-shadow-left',
|
|
714
|
-
}),
|
|
715
|
-
);
|
|
716
|
-
}),
|
|
717
|
-
),
|
|
718
|
-
),
|
|
719
|
-
);
|
|
720
|
-
}),
|
|
721
|
-
React.createElement(
|
|
722
|
-
index_js_1.Box,
|
|
723
|
-
{
|
|
724
|
-
...bodyProps,
|
|
725
|
-
...getTableBodyProps({
|
|
726
|
-
className: (0, classnames_1.default)(
|
|
727
|
-
'iui-table-body',
|
|
728
|
-
{
|
|
729
|
-
'iui-zebra-striping': styleType === 'zebra-rows',
|
|
730
|
-
},
|
|
731
|
-
bodyProps?.className,
|
|
732
|
-
),
|
|
733
|
-
style: { outline: 0 },
|
|
734
|
-
}),
|
|
735
|
-
ref: bodyRef,
|
|
736
|
-
onScroll: () => {
|
|
737
|
-
if (headerRef.current && bodyRef.current) {
|
|
738
|
-
headerRef.current.scrollLeft = bodyRef.current.scrollLeft;
|
|
739
|
-
updateStickyState();
|
|
740
|
-
}
|
|
741
|
-
},
|
|
742
|
-
tabIndex: -1,
|
|
743
|
-
'aria-multiselectable':
|
|
744
|
-
(isSelectable && selectionMode === 'multi') || undefined,
|
|
745
|
-
},
|
|
746
|
-
data.length !== 0 &&
|
|
747
|
-
React.createElement(
|
|
748
|
-
React.Fragment,
|
|
749
|
-
null,
|
|
750
|
-
enableVirtualization
|
|
751
|
-
? React.createElement(VirtualScroll_js_1.default, {
|
|
752
|
-
itemsLength: page.length,
|
|
753
|
-
itemRenderer: virtualizedItemRenderer,
|
|
754
|
-
scrollToIndex: scrollToIndex,
|
|
755
|
-
})
|
|
756
|
-
: page.map((_, index) => getPreparedRow(index)),
|
|
757
|
-
),
|
|
758
|
-
isLoading &&
|
|
759
|
-
data.length === 0 &&
|
|
760
|
-
React.createElement(
|
|
761
|
-
index_js_1.Box,
|
|
762
|
-
{
|
|
763
|
-
as: 'div',
|
|
764
|
-
...emptyTableContentProps,
|
|
765
|
-
className: (0, classnames_1.default)(
|
|
766
|
-
'iui-table-empty',
|
|
767
|
-
emptyTableContentProps?.className,
|
|
768
|
-
),
|
|
769
|
-
},
|
|
770
|
-
React.createElement(ProgressRadial_js_1.ProgressRadial, {
|
|
771
|
-
indeterminate: true,
|
|
397
|
+
return (React.createElement(index_js_1.Box, { as: 'div', ref: headerRef, onScroll: () => {
|
|
398
|
+
if (headerRef.current && bodyRef.current) {
|
|
399
|
+
bodyRef.current.scrollLeft = headerRef.current.scrollLeft;
|
|
400
|
+
updateStickyState();
|
|
401
|
+
}
|
|
402
|
+
}, key: headerGroupProps.key, ...headerWrapperProps, className: (0, classnames_1.default)('iui-table-header-wrapper', headerWrapperProps?.className) },
|
|
403
|
+
React.createElement(index_js_1.Box, { as: 'div', ...headerProps, className: (0, classnames_1.default)('iui-table-header', headerProps?.className) },
|
|
404
|
+
React.createElement(index_js_1.Box, { ...headerGroupProps }, headerGroup.headers.map((column, index) => {
|
|
405
|
+
const { onClick, ...restSortProps } = column.getSortByToggleProps();
|
|
406
|
+
const columnProps = column.getHeaderProps({
|
|
407
|
+
...restSortProps,
|
|
408
|
+
className: (0, classnames_1.default)('iui-table-cell', {
|
|
409
|
+
'iui-actionable': column.canSort,
|
|
410
|
+
'iui-sorted': column.isSorted,
|
|
411
|
+
'iui-table-cell-sticky': !!column.sticky,
|
|
412
|
+
}, column.columnClassName),
|
|
413
|
+
style: {
|
|
414
|
+
...(0, utils_js_1.getCellStyle)(column, !!state.isTableResizing),
|
|
415
|
+
...(0, utils_js_1.getStickyStyle)(column, visibleColumns),
|
|
416
|
+
flexWrap: 'unset',
|
|
417
|
+
},
|
|
418
|
+
});
|
|
419
|
+
return (React.createElement(index_js_1.Box, { ...columnProps, ...column.getDragAndDropProps(), key: columnProps.key, title: undefined, ref: (el) => {
|
|
420
|
+
if (el) {
|
|
421
|
+
columnRefs.current[column.id] = el;
|
|
422
|
+
column.resizeWidth =
|
|
423
|
+
el.getBoundingClientRect().width;
|
|
424
|
+
}
|
|
425
|
+
}, onMouseDown: () => {
|
|
426
|
+
isHeaderDirectClick.current = true;
|
|
427
|
+
}, onClick: (e) => {
|
|
428
|
+
// Prevents from triggering sort when resizing and mouse is released in the middle of header
|
|
429
|
+
if (isHeaderDirectClick.current) {
|
|
430
|
+
onClick?.(e);
|
|
431
|
+
isHeaderDirectClick.current = false;
|
|
432
|
+
}
|
|
433
|
+
}, tabIndex: showSortButton(column) ? 0 : undefined, onKeyDown: (e) => {
|
|
434
|
+
if (e.key == 'Enter' && showSortButton(column)) {
|
|
435
|
+
column.toggleSortBy();
|
|
436
|
+
}
|
|
437
|
+
} },
|
|
438
|
+
column.render('Header'),
|
|
439
|
+
(showFilterButton(column) ||
|
|
440
|
+
showSortButton(column)) && (React.createElement(index_js_1.Box, { className: 'iui-table-header-actions-container' },
|
|
441
|
+
showFilterButton(column) && (React.createElement(index_js_2.FilterToggle, { column: column })),
|
|
442
|
+
showSortButton(column) && (React.createElement(index_js_1.Box, { className: 'iui-table-cell-end-icon' }, column.isSortedDesc ||
|
|
443
|
+
(!column.isSorted && column.sortDescFirst) ? (React.createElement(index_js_1.SvgSortDown, { className: 'iui-table-sort', "aria-hidden": true })) : (React.createElement(index_js_1.SvgSortUp, { className: 'iui-table-sort', "aria-hidden": true })))))),
|
|
444
|
+
isResizable &&
|
|
445
|
+
column.isResizerVisible &&
|
|
446
|
+
(index !== headerGroup.headers.length - 1 ||
|
|
447
|
+
columnResizeMode === 'expand') && (React.createElement(index_js_1.Box, { ...column.getResizerProps(), className: 'iui-table-resizer' },
|
|
448
|
+
React.createElement(index_js_1.Box, { className: 'iui-table-resizer-bar' }))),
|
|
449
|
+
enableColumnReordering &&
|
|
450
|
+
!column.disableReordering && (React.createElement(index_js_1.Box, { className: 'iui-table-reorder-bar' })),
|
|
451
|
+
column.sticky === 'left' &&
|
|
452
|
+
state.sticky.isScrolledToRight && (React.createElement(index_js_1.Box, { className: 'iui-table-cell-shadow-right' })),
|
|
453
|
+
column.sticky === 'right' &&
|
|
454
|
+
state.sticky.isScrolledToLeft && (React.createElement(index_js_1.Box, { className: 'iui-table-cell-shadow-left' }))));
|
|
455
|
+
})))));
|
|
772
456
|
}),
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
as: 'div',
|
|
798
|
-
...emptyTableContentProps,
|
|
799
|
-
className: (0, classnames_1.default)(
|
|
800
|
-
'iui-table-empty',
|
|
801
|
-
emptyTableContentProps?.className,
|
|
802
|
-
),
|
|
803
|
-
},
|
|
804
|
-
React.createElement('div', null, emptyTableContent),
|
|
805
|
-
),
|
|
806
|
-
!isLoading &&
|
|
807
|
-
(data.length === 0 || rows.length === 0) &&
|
|
808
|
-
areFiltersSet &&
|
|
809
|
-
React.createElement(
|
|
810
|
-
index_js_1.Box,
|
|
811
|
-
{
|
|
812
|
-
as: 'div',
|
|
813
|
-
...emptyTableContentProps,
|
|
814
|
-
className: (0, classnames_1.default)(
|
|
815
|
-
'iui-table-empty',
|
|
816
|
-
emptyTableContentProps?.className,
|
|
817
|
-
),
|
|
818
|
-
},
|
|
819
|
-
React.createElement('div', null, emptyFilteredTableContent),
|
|
820
|
-
),
|
|
821
|
-
),
|
|
822
|
-
paginatorRenderer?.(paginatorRendererProps),
|
|
823
|
-
),
|
|
824
|
-
);
|
|
457
|
+
React.createElement(index_js_1.Box, { ...bodyProps, ...getTableBodyProps({
|
|
458
|
+
className: (0, classnames_1.default)('iui-table-body', {
|
|
459
|
+
'iui-zebra-striping': styleType === 'zebra-rows',
|
|
460
|
+
}, bodyProps?.className),
|
|
461
|
+
style: { outline: 0 },
|
|
462
|
+
}), ref: bodyRef, onScroll: () => {
|
|
463
|
+
if (headerRef.current && bodyRef.current) {
|
|
464
|
+
headerRef.current.scrollLeft = bodyRef.current.scrollLeft;
|
|
465
|
+
updateStickyState();
|
|
466
|
+
}
|
|
467
|
+
}, tabIndex: -1, "aria-multiselectable": (isSelectable && selectionMode === 'multi') || undefined },
|
|
468
|
+
data.length !== 0 && (React.createElement(React.Fragment, null, enableVirtualization ? (React.createElement(VirtualScroll_js_1.default, { itemsLength: page.length, itemRenderer: virtualizedItemRenderer, scrollToIndex: scrollToIndex })) : (page.map((_, index) => getPreparedRow(index))))),
|
|
469
|
+
isLoading && data.length === 0 && (React.createElement(index_js_1.Box, { as: 'div', ...emptyTableContentProps, className: (0, classnames_1.default)('iui-table-empty', emptyTableContentProps?.className) },
|
|
470
|
+
React.createElement(ProgressRadial_js_1.ProgressRadial, { indeterminate: true }))),
|
|
471
|
+
isLoading && data.length !== 0 && (React.createElement(index_js_1.Box, { className: 'iui-table-row' },
|
|
472
|
+
React.createElement(index_js_1.Box, { className: 'iui-table-cell', style: { justifyContent: 'center' } },
|
|
473
|
+
React.createElement(ProgressRadial_js_1.ProgressRadial, { indeterminate: true, size: 'small' })))),
|
|
474
|
+
!isLoading && data.length === 0 && !areFiltersSet && (React.createElement(index_js_1.Box, { as: 'div', ...emptyTableContentProps, className: (0, classnames_1.default)('iui-table-empty', emptyTableContentProps?.className) },
|
|
475
|
+
React.createElement("div", null, emptyTableContent))),
|
|
476
|
+
!isLoading &&
|
|
477
|
+
(data.length === 0 || rows.length === 0) &&
|
|
478
|
+
areFiltersSet && (React.createElement(index_js_1.Box, { as: 'div', ...emptyTableContentProps, className: (0, classnames_1.default)('iui-table-empty', emptyTableContentProps?.className) },
|
|
479
|
+
React.createElement("div", null, emptyFilteredTableContent)))),
|
|
480
|
+
paginatorRenderer?.(paginatorRendererProps))));
|
|
825
481
|
};
|
|
826
482
|
exports.Table = Table;
|
|
827
483
|
exports.default = exports.Table;
|