@itwin/itwinui-react 2.0.0-dev.2 → 2.0.0-dev.3
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/README.md +10 -1
- package/cjs/core/Alert/Alert.js +8 -30
- package/cjs/core/Avatar/Avatar.js +10 -33
- package/cjs/core/AvatarGroup/AvatarGroup.js +18 -43
- package/cjs/core/Backdrop/Backdrop.js +6 -28
- package/cjs/core/Badge/Badge.js +13 -31
- package/cjs/core/Breadcrumbs/Breadcrumbs.js +14 -40
- package/cjs/core/ButtonGroup/ButtonGroup.js +10 -32
- package/cjs/core/Buttons/Button/Button.js +6 -28
- package/cjs/core/Buttons/DropdownButton/DropdownButton.js +14 -36
- package/cjs/core/Buttons/IconButton/IconButton.js +6 -28
- package/cjs/core/Buttons/IdeasButton/IdeasButton.js +6 -28
- package/cjs/core/Buttons/SplitButton/SplitButton.js +14 -36
- package/cjs/core/Carousel/Carousel.js +38 -63
- package/cjs/core/Carousel/CarouselContext.js +1 -1
- package/cjs/core/Carousel/CarouselDot.js +6 -28
- package/cjs/core/Carousel/CarouselDotsList.js +33 -60
- package/cjs/core/Carousel/CarouselNavigation.js +22 -44
- package/cjs/core/Carousel/CarouselSlide.js +12 -34
- package/cjs/core/Carousel/CarouselSlider.js +26 -51
- package/cjs/core/Checkbox/Checkbox.js +18 -42
- package/cjs/core/ColorPicker/ColorBuilder.js +51 -73
- package/cjs/core/ColorPicker/ColorInputPanel.js +64 -88
- package/cjs/core/ColorPicker/ColorPalette.js +26 -50
- package/cjs/core/ColorPicker/ColorPicker.js +25 -49
- package/cjs/core/ColorPicker/ColorPickerContext.js +3 -3
- package/cjs/core/ColorPicker/ColorSwatch.js +13 -34
- package/cjs/core/ComboBox/ComboBox.js +67 -93
- package/cjs/core/ComboBox/ComboBoxDropdown.d.ts +1 -1
- package/cjs/core/ComboBox/ComboBoxDropdown.js +13 -36
- package/cjs/core/ComboBox/ComboBoxEndIcon.js +12 -34
- package/cjs/core/ComboBox/ComboBoxInput.js +28 -50
- package/cjs/core/ComboBox/ComboBoxInputContainer.js +9 -31
- package/cjs/core/ComboBox/ComboBoxMenu.js +35 -60
- package/cjs/core/ComboBox/ComboBoxMenuItem.js +11 -33
- package/cjs/core/ComboBox/helpers.js +11 -19
- package/cjs/core/DatePicker/DatePicker.js +87 -111
- package/cjs/core/Dialog/Dialog.js +28 -48
- package/cjs/core/Dialog/DialogBackdrop.js +16 -35
- package/cjs/core/Dialog/DialogButtonBar.js +6 -28
- package/cjs/core/Dialog/DialogContent.js +6 -28
- package/cjs/core/Dialog/DialogContext.js +2 -2
- package/cjs/core/Dialog/DialogDragContext.js +6 -15
- package/cjs/core/Dialog/DialogMain.js +52 -59
- package/cjs/core/Dialog/DialogTitleBar.js +14 -36
- package/cjs/core/Dialog/DialogTitleBarTitle.js +6 -28
- package/cjs/core/DropdownMenu/DropdownMenu.js +14 -36
- package/cjs/core/ExpandableBlock/ExpandableBlock.js +12 -34
- package/cjs/core/Fieldset/Fieldset.js +9 -33
- package/cjs/core/FileUpload/FileUpload.js +13 -35
- package/cjs/core/FileUpload/FileUploadTemplate.js +4 -4
- package/cjs/core/Footer/Footer.js +21 -49
- package/cjs/core/Footer/FooterItem.js +6 -28
- package/cjs/core/Footer/FooterList.js +6 -28
- package/cjs/core/Footer/FooterSeparator.js +6 -28
- package/cjs/core/Header/Header.js +10 -32
- package/cjs/core/Header/HeaderBasicButton.js +6 -28
- package/cjs/core/Header/HeaderBreadcrumbs.js +9 -39
- package/cjs/core/Header/HeaderButton.js +22 -36
- package/cjs/core/Header/HeaderDropdownButton.js +14 -36
- package/cjs/core/Header/HeaderLogo.js +7 -29
- package/cjs/core/Header/HeaderSplitButton.js +13 -35
- package/cjs/core/InformationPanel/InformationPanel.js +15 -37
- package/cjs/core/InformationPanel/InformationPanelBody.js +6 -28
- package/cjs/core/InformationPanel/InformationPanelContent.js +6 -28
- package/cjs/core/InformationPanel/InformationPanelHeader.js +7 -29
- package/cjs/core/InformationPanel/InformationPanelWrapper.js +6 -28
- package/cjs/core/Input/Input.js +9 -31
- package/cjs/core/InputGroup/InputGroup.js +6 -28
- package/cjs/core/Label/Label.js +7 -29
- package/cjs/core/LabeledInput/LabeledInput.js +7 -29
- package/cjs/core/LabeledSelect/LabeledSelect.js +7 -29
- package/cjs/core/LabeledTextarea/LabeledTextarea.js +7 -29
- package/cjs/core/Menu/Menu.js +18 -40
- package/cjs/core/Menu/MenuDivider.js +6 -28
- package/cjs/core/Menu/MenuExtraContent.js +6 -28
- package/cjs/core/Menu/MenuItem.js +17 -39
- package/cjs/core/Menu/MenuItemSkeleton.js +11 -30
- package/cjs/core/Modal/Modal.js +12 -30
- package/cjs/core/Modal/ModalButtonBar.js +1 -1
- package/cjs/core/Modal/ModalContent.js +1 -1
- package/cjs/core/{ErrorPage → NonIdealState}/ErrorPage.d.ts +5 -1
- package/cjs/core/NonIdealState/ErrorPage.js +144 -0
- package/cjs/core/NonIdealState/NonIdealState.d.ts +46 -0
- package/cjs/core/NonIdealState/NonIdealState.js +32 -0
- package/{esm/core/ErrorPage → cjs/core/NonIdealState}/index.d.ts +3 -1
- package/cjs/core/{ErrorPage → NonIdealState}/index.js +4 -2
- package/cjs/core/ProgressIndicators/ProgressLinear/ProgressLinear.js +11 -34
- package/cjs/core/ProgressIndicators/ProgressRadial/ProgressRadial.js +13 -37
- package/cjs/core/Radio/Radio.js +10 -33
- package/cjs/core/RadioTiles/RadioTile.js +9 -31
- package/cjs/core/RadioTiles/RadioTileGroup.js +6 -28
- package/cjs/core/Select/Select.js +59 -72
- package/cjs/core/Select/SelectTag.js +6 -28
- package/cjs/core/SideNavigation/SideNavigation.js +14 -40
- package/cjs/core/SideNavigation/SidenavButton.js +8 -30
- package/cjs/core/SideNavigation/SidenavSubmenu.js +6 -28
- package/cjs/core/SideNavigation/SidenavSubmenuHeader.js +6 -28
- package/cjs/core/SkipToContentLink/SkipToContentLink.js +6 -28
- package/cjs/core/Slider/Slider.js +68 -96
- package/cjs/core/Slider/Thumb.js +20 -39
- package/cjs/core/Slider/Track.js +24 -44
- package/cjs/core/StatusMessage/StatusMessage.js +6 -7
- package/cjs/core/Stepper/Stepper.js +10 -34
- package/cjs/core/Stepper/StepperStep.js +15 -34
- package/cjs/core/Stepper/Wizard.js +6 -28
- package/cjs/core/Stepper/WorkflowDiagram.js +6 -28
- package/cjs/core/Stepper/WorkflowDiagramStep.js +6 -28
- package/cjs/core/Surface/Surface.js +11 -30
- package/cjs/core/Table/SubRowExpander.js +6 -6
- package/cjs/core/Table/Table.d.ts +19 -24
- package/cjs/core/Table/Table.js +189 -195
- package/cjs/core/Table/TableCell.js +29 -30
- package/cjs/core/Table/TablePaginator.js +52 -83
- package/cjs/core/Table/TableRowMemoized.d.ts +6 -10
- package/cjs/core/Table/TableRowMemoized.js +36 -60
- package/cjs/core/Table/actionHandlers/expandHandler.js +3 -3
- package/cjs/core/Table/actionHandlers/filterHandler.js +4 -4
- package/cjs/core/Table/actionHandlers/resizeHandler.js +13 -15
- package/cjs/core/Table/actionHandlers/selectHandler.js +35 -40
- package/cjs/core/Table/cells/DefaultCell.js +5 -27
- package/cjs/core/Table/cells/EditableCell.js +16 -40
- package/cjs/core/Table/columns/actionColumn.js +44 -62
- package/cjs/core/Table/columns/expanderColumn.d.ts +2 -5
- package/cjs/core/Table/columns/expanderColumn.js +12 -27
- package/cjs/core/Table/columns/selectionColumn.d.ts +2 -5
- package/cjs/core/Table/columns/selectionColumn.js +16 -37
- package/cjs/core/Table/filters/BaseFilter.js +6 -6
- package/cjs/core/Table/filters/DateRangeFilter/DatePickerInput.js +19 -41
- package/cjs/core/Table/filters/DateRangeFilter/DateRangeFilter.js +20 -31
- package/cjs/core/Table/filters/FilterButtonBar.js +8 -19
- package/cjs/core/Table/filters/FilterToggle.js +15 -37
- package/cjs/core/Table/filters/NumberRangeFilter/NumberRangeFilter.js +16 -29
- package/cjs/core/Table/filters/TextFilter/TextFilter.js +11 -11
- package/cjs/core/Table/filters/customFilterFunctions.js +11 -13
- package/cjs/core/Table/filters/defaultFilterFunctions.js +62 -64
- package/cjs/core/Table/filters/tableFilters.js +7 -18
- package/cjs/core/Table/hooks/useColumnDragAndDrop.js +41 -53
- package/cjs/core/Table/hooks/useExpanderCell.js +17 -33
- package/cjs/core/Table/hooks/useResizeColumns.js +197 -205
- package/cjs/core/Table/hooks/useScrollToRow.js +11 -12
- package/cjs/core/Table/hooks/useSelectionCell.js +7 -18
- package/cjs/core/Table/hooks/useStickyColumns.js +28 -33
- package/cjs/core/Table/hooks/useSubRowFiltering.js +37 -57
- package/cjs/core/Table/hooks/useSubRowSelection.js +10 -12
- package/cjs/core/Table/utils.js +15 -26
- package/cjs/core/Tabs/Tab.js +6 -28
- package/cjs/core/Tabs/Tabs.js +45 -67
- package/cjs/core/Tag/Tag.js +8 -30
- package/cjs/core/Tag/TagContainer.js +9 -32
- package/cjs/core/Textarea/Textarea.js +9 -31
- package/cjs/core/ThemeProvider/ThemeProvider.d.ts +1 -0
- package/cjs/core/ThemeProvider/ThemeProvider.js +16 -37
- package/cjs/core/Tile/Tile.js +29 -58
- package/cjs/core/TimePicker/TimePicker.js +59 -97
- package/cjs/core/Toast/Toast.js +45 -65
- package/cjs/core/Toast/ToastWrapper.js +13 -24
- package/cjs/core/Toast/Toaster.js +87 -137
- package/cjs/core/Toast/index.js +2 -2
- package/cjs/core/ToggleSwitch/ToggleSwitch.js +10 -32
- package/cjs/core/Tooltip/Tooltip.js +6 -28
- package/cjs/core/Tree/Tree.js +58 -80
- package/cjs/core/Tree/TreeContext.js +3 -3
- package/cjs/core/Tree/TreeNode.js +21 -43
- package/cjs/core/Tree/TreeNodeExpander.js +7 -29
- package/cjs/core/Typography/Anchor/Anchor.js +5 -28
- package/cjs/core/Typography/Blockquote/Blockquote.js +6 -28
- package/cjs/core/Typography/Body/Body.js +7 -29
- package/cjs/core/Typography/Code/Code.js +6 -28
- package/cjs/core/Typography/Headline/Headline.js +6 -28
- package/cjs/core/Typography/Kbd/Kbd.js +6 -28
- package/cjs/core/Typography/Leading/Leading.js +6 -28
- package/cjs/core/Typography/Small/Small.js +6 -28
- package/cjs/core/Typography/Subheading/Subheading.js +6 -28
- package/cjs/core/Typography/Text/Text.js +11 -34
- package/cjs/core/Typography/Title/Title.js +6 -28
- package/cjs/core/index.d.ts +2 -2
- package/cjs/core/index.js +6 -5
- package/cjs/core/utils/color/ColorValue.js +146 -156
- package/cjs/core/utils/components/FocusTrap.js +14 -14
- package/cjs/core/utils/components/InputContainer.js +12 -36
- package/cjs/core/utils/components/MiddleTextTruncation.js +15 -31
- package/cjs/core/utils/components/Popover.d.ts +1 -1
- package/cjs/core/utils/components/Popover.js +57 -60
- package/cjs/core/utils/components/Resizer.js +51 -51
- package/cjs/core/utils/components/VirtualScroll.js +72 -89
- package/cjs/core/utils/components/VisuallyHidden.js +6 -28
- package/cjs/core/utils/components/WithCSSTransition.d.ts +2 -2
- package/cjs/core/utils/components/WithCSSTransition.js +18 -40
- package/cjs/core/utils/functions/colors.js +7 -7
- package/cjs/core/utils/functions/dom.js +7 -8
- package/cjs/core/utils/functions/focusable.js +11 -15
- package/cjs/core/utils/functions/numbers.js +5 -6
- package/cjs/core/utils/functions/styles.js +3 -3
- package/cjs/core/utils/hooks/useContainerWidth.js +9 -13
- package/cjs/core/utils/hooks/useDragAndDrop.js +32 -33
- package/cjs/core/utils/hooks/useEventListener.js +7 -7
- package/cjs/core/utils/hooks/useIntersection.js +9 -12
- package/cjs/core/utils/hooks/useIsomorphicLayoutEffect.js +1 -1
- package/cjs/core/utils/hooks/useLatestRef.js +4 -4
- package/cjs/core/utils/hooks/useMediaQuery.js +9 -12
- package/cjs/core/utils/hooks/useMergedRefs.js +6 -23
- package/cjs/core/utils/hooks/useOverflow.js +26 -33
- package/cjs/core/utils/hooks/useResizeObserver.js +6 -9
- package/cjs/core/utils/hooks/useSafeContext.js +4 -4
- package/cjs/core/utils/hooks/useTheme.js +18 -20
- package/cjs/core/utils/icons/StatusIconMap.js +9 -20
- package/cjs/core/utils/icons/SvgCalendar.js +3 -14
- package/cjs/core/utils/icons/SvgCaretDownSmall.js +3 -14
- package/cjs/core/utils/icons/SvgCaretRightSmall.js +3 -14
- package/cjs/core/utils/icons/SvgCaretUpSmall.js +3 -14
- package/cjs/core/utils/icons/SvgCheckmark.js +3 -14
- package/cjs/core/utils/icons/SvgCheckmarkSmall.js +3 -14
- package/cjs/core/utils/icons/SvgChevronLeft.js +3 -14
- package/cjs/core/utils/icons/SvgChevronLeftDouble.js +3 -14
- package/cjs/core/utils/icons/SvgChevronRight.js +3 -14
- package/cjs/core/utils/icons/SvgChevronRightDouble.js +3 -14
- package/cjs/core/utils/icons/SvgClose.js +3 -14
- package/cjs/core/utils/icons/SvgCloseSmall.js +3 -14
- package/cjs/core/utils/icons/SvgColumnManager.js +3 -14
- package/cjs/core/utils/icons/SvgFilter.js +3 -14
- package/cjs/core/utils/icons/SvgFilterHollow.js +3 -14
- package/cjs/core/utils/icons/SvgImportantSmall.js +3 -14
- package/cjs/core/utils/icons/SvgInfoCircular.js +3 -14
- package/cjs/core/utils/icons/SvgMore.js +3 -14
- package/cjs/core/utils/icons/SvgMoreVertical.js +3 -14
- package/cjs/core/utils/icons/SvgNew.js +3 -14
- package/cjs/core/utils/icons/SvgSmileyHappy.js +3 -14
- package/cjs/core/utils/icons/SvgSortDown.js +3 -14
- package/cjs/core/utils/icons/SvgSortUp.js +3 -14
- package/cjs/core/utils/icons/SvgStatusError.js +3 -14
- package/cjs/core/utils/icons/SvgStatusSuccess.js +3 -14
- package/cjs/core/utils/icons/SvgStatusWarning.js +3 -14
- package/cjs/core/utils/icons/SvgSwap.js +3 -14
- package/cjs/core/utils/icons/SvgUpload.js +3 -14
- package/cjs/types/react-table-config.d.ts +1 -1
- package/esm/core/Alert/Alert.js +5 -27
- package/esm/core/Avatar/Avatar.js +9 -32
- package/esm/core/AvatarGroup/AvatarGroup.js +16 -41
- package/esm/core/Backdrop/Backdrop.js +3 -25
- package/esm/core/Badge/Badge.js +10 -28
- package/esm/core/Breadcrumbs/Breadcrumbs.js +11 -37
- package/esm/core/ButtonGroup/ButtonGroup.js +7 -29
- package/esm/core/Buttons/Button/Button.js +3 -25
- package/esm/core/Buttons/DropdownButton/DropdownButton.js +9 -31
- package/esm/core/Buttons/IconButton/IconButton.js +3 -25
- package/esm/core/Buttons/IdeasButton/IdeasButton.js +3 -25
- package/esm/core/Buttons/SplitButton/SplitButton.js +8 -30
- package/esm/core/Carousel/Carousel.js +29 -54
- package/esm/core/Carousel/CarouselContext.js +1 -1
- package/esm/core/Carousel/CarouselDot.js +4 -26
- package/esm/core/Carousel/CarouselDotsList.js +28 -55
- package/esm/core/Carousel/CarouselNavigation.js +16 -38
- package/esm/core/Carousel/CarouselSlide.js +8 -30
- package/esm/core/Carousel/CarouselSlider.js +22 -47
- package/esm/core/Checkbox/Checkbox.js +14 -38
- package/esm/core/ColorPicker/ColorBuilder.js +46 -68
- package/esm/core/ColorPicker/ColorInputPanel.js +58 -82
- package/esm/core/ColorPicker/ColorPalette.js +20 -44
- package/esm/core/ColorPicker/ColorPicker.js +21 -45
- package/esm/core/ColorPicker/ColorPickerContext.js +3 -3
- package/esm/core/ColorPicker/ColorSwatch.js +9 -30
- package/esm/core/ComboBox/ComboBox.js +55 -81
- package/esm/core/ComboBox/ComboBoxDropdown.d.ts +1 -1
- package/esm/core/ComboBox/ComboBoxDropdown.js +10 -33
- package/esm/core/ComboBox/ComboBoxEndIcon.js +8 -30
- package/esm/core/ComboBox/ComboBoxInput.js +24 -46
- package/esm/core/ComboBox/ComboBoxInputContainer.js +5 -27
- package/esm/core/ComboBox/ComboBoxMenu.js +29 -54
- package/esm/core/ComboBox/ComboBoxMenuItem.js +7 -29
- package/esm/core/ComboBox/helpers.js +13 -21
- package/esm/core/DatePicker/DatePicker.js +82 -106
- package/esm/core/Dialog/Dialog.js +19 -39
- package/esm/core/Dialog/DialogBackdrop.js +11 -30
- package/esm/core/Dialog/DialogButtonBar.js +3 -25
- package/esm/core/Dialog/DialogContent.js +3 -25
- package/esm/core/Dialog/DialogContext.js +2 -2
- package/esm/core/Dialog/DialogDragContext.js +6 -15
- package/esm/core/Dialog/DialogMain.js +45 -52
- package/esm/core/Dialog/DialogTitleBar.js +7 -29
- package/esm/core/Dialog/DialogTitleBarTitle.js +3 -25
- package/esm/core/DropdownMenu/DropdownMenu.js +11 -33
- package/esm/core/ExpandableBlock/ExpandableBlock.js +9 -31
- package/esm/core/Fieldset/Fieldset.js +6 -30
- package/esm/core/FileUpload/FileUpload.js +10 -32
- package/esm/core/FileUpload/FileUploadTemplate.js +2 -2
- package/esm/core/Footer/Footer.js +16 -44
- package/esm/core/Footer/FooterItem.js +3 -25
- package/esm/core/Footer/FooterList.js +3 -25
- package/esm/core/Footer/FooterSeparator.js +3 -25
- package/esm/core/Header/Header.js +5 -27
- package/esm/core/Header/HeaderBasicButton.js +3 -25
- package/esm/core/Header/HeaderBreadcrumbs.js +7 -37
- package/esm/core/Header/HeaderButton.js +16 -30
- package/esm/core/Header/HeaderDropdownButton.js +9 -31
- package/esm/core/Header/HeaderLogo.js +4 -26
- package/esm/core/Header/HeaderSplitButton.js +8 -30
- package/esm/core/InformationPanel/InformationPanel.js +12 -34
- package/esm/core/InformationPanel/InformationPanelBody.js +3 -25
- package/esm/core/InformationPanel/InformationPanelContent.js +3 -25
- package/esm/core/InformationPanel/InformationPanelHeader.js +3 -25
- package/esm/core/InformationPanel/InformationPanelWrapper.js +3 -25
- package/esm/core/Input/Input.js +6 -28
- package/esm/core/InputGroup/InputGroup.js +4 -26
- package/esm/core/Label/Label.js +4 -26
- package/esm/core/LabeledInput/LabeledInput.js +4 -26
- package/esm/core/LabeledSelect/LabeledSelect.js +4 -26
- package/esm/core/LabeledTextarea/LabeledTextarea.js +4 -26
- package/esm/core/Menu/Menu.js +15 -37
- package/esm/core/Menu/MenuDivider.js +3 -25
- package/esm/core/Menu/MenuExtraContent.js +3 -25
- package/esm/core/Menu/MenuItem.js +13 -35
- package/esm/core/Menu/MenuItemSkeleton.js +8 -27
- package/esm/core/Modal/Modal.js +8 -26
- package/esm/core/Modal/ModalButtonBar.js +1 -1
- package/esm/core/Modal/ModalContent.js +1 -1
- package/esm/core/{ErrorPage → NonIdealState}/ErrorPage.d.ts +5 -1
- package/esm/core/NonIdealState/ErrorPage.js +137 -0
- package/esm/core/NonIdealState/NonIdealState.d.ts +46 -0
- package/esm/core/NonIdealState/NonIdealState.js +25 -0
- package/{cjs/core/ErrorPage → esm/core/NonIdealState}/index.d.ts +3 -1
- package/esm/core/{ErrorPage → NonIdealState}/index.js +2 -1
- package/esm/core/ProgressIndicators/ProgressLinear/ProgressLinear.js +8 -31
- package/esm/core/ProgressIndicators/ProgressRadial/ProgressRadial.js +10 -34
- package/esm/core/Radio/Radio.js +7 -30
- package/esm/core/RadioTiles/RadioTile.js +6 -28
- package/esm/core/RadioTiles/RadioTileGroup.js +3 -25
- package/esm/core/Select/Select.js +53 -66
- package/esm/core/Select/SelectTag.js +3 -25
- package/esm/core/SideNavigation/SideNavigation.js +9 -35
- package/esm/core/SideNavigation/SidenavButton.js +4 -26
- package/esm/core/SideNavigation/SidenavSubmenu.js +3 -25
- package/esm/core/SideNavigation/SidenavSubmenuHeader.js +3 -25
- package/esm/core/SkipToContentLink/SkipToContentLink.js +3 -25
- package/esm/core/Slider/Slider.js +63 -91
- package/esm/core/Slider/Thumb.js +17 -36
- package/esm/core/Slider/Track.js +23 -43
- package/esm/core/StatusMessage/StatusMessage.js +3 -4
- package/esm/core/Stepper/Stepper.js +7 -31
- package/esm/core/Stepper/StepperStep.js +12 -31
- package/esm/core/Stepper/Wizard.js +3 -25
- package/esm/core/Stepper/WorkflowDiagram.js +3 -25
- package/esm/core/Stepper/WorkflowDiagramStep.js +3 -25
- package/esm/core/Surface/Surface.js +8 -27
- package/esm/core/Table/SubRowExpander.js +3 -3
- package/esm/core/Table/Table.d.ts +19 -24
- package/esm/core/Table/Table.js +177 -183
- package/esm/core/Table/TableCell.js +23 -24
- package/esm/core/Table/TablePaginator.js +46 -77
- package/esm/core/Table/TableRowMemoized.d.ts +6 -10
- package/esm/core/Table/TableRowMemoized.js +32 -56
- package/esm/core/Table/actionHandlers/expandHandler.js +3 -3
- package/esm/core/Table/actionHandlers/filterHandler.js +4 -4
- package/esm/core/Table/actionHandlers/resizeHandler.js +13 -15
- package/esm/core/Table/actionHandlers/selectHandler.js +35 -40
- package/esm/core/Table/cells/DefaultCell.js +3 -25
- package/esm/core/Table/cells/EditableCell.js +14 -38
- package/esm/core/Table/columns/actionColumn.js +34 -52
- package/esm/core/Table/columns/expanderColumn.d.ts +2 -5
- package/esm/core/Table/columns/expanderColumn.js +9 -24
- package/esm/core/Table/columns/selectionColumn.d.ts +2 -5
- package/esm/core/Table/columns/selectionColumn.js +14 -35
- package/esm/core/Table/filters/BaseFilter.js +3 -3
- package/esm/core/Table/filters/DateRangeFilter/DatePickerInput.js +14 -36
- package/esm/core/Table/filters/DateRangeFilter/DateRangeFilter.js +15 -26
- package/esm/core/Table/filters/FilterButtonBar.js +4 -15
- package/esm/core/Table/filters/FilterToggle.js +11 -33
- package/esm/core/Table/filters/NumberRangeFilter/NumberRangeFilter.js +11 -24
- package/esm/core/Table/filters/TextFilter/TextFilter.js +6 -6
- package/esm/core/Table/filters/customFilterFunctions.js +12 -14
- package/esm/core/Table/filters/defaultFilterFunctions.js +63 -65
- package/esm/core/Table/filters/tableFilters.js +4 -15
- package/esm/core/Table/hooks/useColumnDragAndDrop.js +40 -52
- package/esm/core/Table/hooks/useExpanderCell.js +15 -31
- package/esm/core/Table/hooks/useResizeColumns.js +196 -204
- package/esm/core/Table/hooks/useScrollToRow.js +10 -11
- package/esm/core/Table/hooks/useSelectionCell.js +6 -17
- package/esm/core/Table/hooks/useStickyColumns.js +27 -32
- package/esm/core/Table/hooks/useSubRowFiltering.js +35 -55
- package/esm/core/Table/hooks/useSubRowSelection.js +9 -11
- package/esm/core/Table/utils.js +15 -26
- package/esm/core/Tabs/Tab.js +3 -25
- package/esm/core/Tabs/Tabs.js +41 -63
- package/esm/core/Tag/Tag.js +4 -26
- package/esm/core/Tag/TagContainer.js +6 -29
- package/esm/core/Textarea/Textarea.js +6 -28
- package/esm/core/ThemeProvider/ThemeProvider.d.ts +1 -0
- package/esm/core/ThemeProvider/ThemeProvider.js +15 -36
- package/esm/core/Tile/Tile.js +23 -52
- package/esm/core/TimePicker/TimePicker.js +56 -94
- package/esm/core/Toast/Toast.js +41 -61
- package/esm/core/Toast/ToastWrapper.js +10 -21
- package/esm/core/Toast/Toaster.js +83 -134
- package/esm/core/Toast/index.js +1 -1
- package/esm/core/ToggleSwitch/ToggleSwitch.js +7 -29
- package/esm/core/Tooltip/Tooltip.js +3 -25
- package/esm/core/Tree/Tree.js +54 -76
- package/esm/core/Tree/TreeContext.js +3 -3
- package/esm/core/Tree/TreeNode.js +16 -38
- package/esm/core/Tree/TreeNodeExpander.js +3 -25
- package/esm/core/Typography/Anchor/Anchor.js +2 -25
- package/esm/core/Typography/Blockquote/Blockquote.js +3 -25
- package/esm/core/Typography/Body/Body.js +4 -26
- package/esm/core/Typography/Code/Code.js +3 -25
- package/esm/core/Typography/Headline/Headline.js +3 -25
- package/esm/core/Typography/Kbd/Kbd.js +4 -26
- package/esm/core/Typography/Leading/Leading.js +3 -25
- package/esm/core/Typography/Small/Small.js +3 -25
- package/esm/core/Typography/Subheading/Subheading.js +3 -25
- package/esm/core/Typography/Text/Text.js +8 -31
- package/esm/core/Typography/Title/Title.js +3 -25
- package/esm/core/index.d.ts +2 -2
- package/esm/core/index.js +1 -1
- package/esm/core/utils/color/ColorValue.js +145 -156
- package/esm/core/utils/components/FocusTrap.js +11 -11
- package/esm/core/utils/components/InputContainer.js +10 -34
- package/esm/core/utils/components/MiddleTextTruncation.js +13 -29
- package/esm/core/utils/components/Popover.d.ts +1 -1
- package/esm/core/utils/components/Popover.js +54 -57
- package/esm/core/utils/components/Resizer.js +49 -49
- package/esm/core/utils/components/VirtualScroll.js +69 -86
- package/esm/core/utils/components/VisuallyHidden.js +3 -25
- package/esm/core/utils/components/WithCSSTransition.d.ts +2 -2
- package/esm/core/utils/components/WithCSSTransition.js +16 -38
- package/esm/core/utils/functions/colors.js +8 -8
- package/esm/core/utils/functions/dom.js +7 -8
- package/esm/core/utils/functions/focusable.js +11 -15
- package/esm/core/utils/functions/numbers.js +5 -6
- package/esm/core/utils/functions/styles.js +3 -3
- package/esm/core/utils/hooks/useContainerWidth.js +6 -10
- package/esm/core/utils/hooks/useDragAndDrop.js +28 -29
- package/esm/core/utils/hooks/useEventListener.js +6 -6
- package/esm/core/utils/hooks/useIntersection.js +7 -10
- package/esm/core/utils/hooks/useIsomorphicLayoutEffect.js +1 -1
- package/esm/core/utils/hooks/useLatestRef.js +3 -3
- package/esm/core/utils/hooks/useMediaQuery.js +6 -9
- package/esm/core/utils/hooks/useMergedRefs.js +5 -22
- package/esm/core/utils/hooks/useOverflow.js +23 -30
- package/esm/core/utils/hooks/useResizeObserver.js +4 -7
- package/esm/core/utils/hooks/useSafeContext.js +3 -3
- package/esm/core/utils/hooks/useTheme.js +14 -16
- package/esm/core/utils/icons/StatusIconMap.js +5 -16
- package/esm/core/utils/icons/SvgCalendar.js +2 -13
- package/esm/core/utils/icons/SvgCaretDownSmall.js +2 -13
- package/esm/core/utils/icons/SvgCaretRightSmall.js +2 -13
- package/esm/core/utils/icons/SvgCaretUpSmall.js +2 -13
- package/esm/core/utils/icons/SvgCheckmark.js +2 -13
- package/esm/core/utils/icons/SvgCheckmarkSmall.js +2 -13
- package/esm/core/utils/icons/SvgChevronLeft.js +2 -13
- package/esm/core/utils/icons/SvgChevronLeftDouble.js +2 -13
- package/esm/core/utils/icons/SvgChevronRight.js +2 -13
- package/esm/core/utils/icons/SvgChevronRightDouble.js +2 -13
- package/esm/core/utils/icons/SvgClose.js +2 -13
- package/esm/core/utils/icons/SvgCloseSmall.js +2 -13
- package/esm/core/utils/icons/SvgColumnManager.js +2 -13
- package/esm/core/utils/icons/SvgFilter.js +2 -13
- package/esm/core/utils/icons/SvgFilterHollow.js +2 -13
- package/esm/core/utils/icons/SvgImportantSmall.js +2 -13
- package/esm/core/utils/icons/SvgInfoCircular.js +2 -13
- package/esm/core/utils/icons/SvgMore.js +2 -13
- package/esm/core/utils/icons/SvgMoreVertical.js +2 -13
- package/esm/core/utils/icons/SvgNew.js +2 -13
- package/esm/core/utils/icons/SvgSmileyHappy.js +2 -13
- package/esm/core/utils/icons/SvgSortDown.js +2 -13
- package/esm/core/utils/icons/SvgSortUp.js +2 -13
- package/esm/core/utils/icons/SvgStatusError.js +2 -13
- package/esm/core/utils/icons/SvgStatusSuccess.js +2 -13
- package/esm/core/utils/icons/SvgStatusWarning.js +2 -13
- package/esm/core/utils/icons/SvgSwap.js +2 -13
- package/esm/core/utils/icons/SvgUpload.js +2 -13
- package/esm/types/react-table-config.d.ts +1 -1
- package/package.json +3 -3
- package/cjs/core/ErrorPage/ErrorPage.js +0 -168
- package/esm/core/ErrorPage/ErrorPage.js +0 -161
|
@@ -1,25 +1,3 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
-
var t = {};
|
|
14
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
-
t[p] = s[p];
|
|
16
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
-
t[p[i]] = s[p[i]];
|
|
20
|
-
}
|
|
21
|
-
return t;
|
|
22
|
-
};
|
|
23
1
|
/*---------------------------------------------------------------------------------------------
|
|
24
2
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
25
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
@@ -30,52 +8,49 @@ import { Menu } from '../Menu';
|
|
|
30
8
|
import { Surface } from '../Surface';
|
|
31
9
|
import { useSafeContext, useMergedRefs, useVirtualization, mergeRefs, getWindow, } from '../utils';
|
|
32
10
|
import { ComboBoxStateContext, ComboBoxRefsContext } from './helpers';
|
|
33
|
-
|
|
34
|
-
var _b, _c
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
? getMenuItem(filteredOptions[index], index)
|
|
41
|
-
: children;
|
|
42
|
-
}, // Here is expected empty state content
|
|
11
|
+
const VirtualizedComboBoxMenu = React.forwardRef(({ children, className, style, ...rest }, forwardedRef) => {
|
|
12
|
+
var _a, _b, _c;
|
|
13
|
+
const { minWidth, id, filteredOptions, getMenuItem, focusedIndex, } = useSafeContext(ComboBoxStateContext);
|
|
14
|
+
const { menuRef } = useSafeContext(ComboBoxRefsContext);
|
|
15
|
+
const virtualItemRenderer = React.useCallback((index) => filteredOptions.length > 0
|
|
16
|
+
? getMenuItem(filteredOptions[index], index)
|
|
17
|
+
: children, // Here is expected empty state content
|
|
43
18
|
[filteredOptions, getMenuItem, children]);
|
|
44
|
-
|
|
19
|
+
const focusedVisibleIndex = React.useMemo(() => {
|
|
45
20
|
var _a, _b;
|
|
46
|
-
|
|
21
|
+
const currentElement = (_a = menuRef.current) === null || _a === void 0 ? void 0 : _a.querySelector(`[data-iui-index="${focusedIndex}"]`);
|
|
47
22
|
if (!currentElement) {
|
|
48
23
|
return focusedIndex;
|
|
49
24
|
}
|
|
50
25
|
return Number((_b = currentElement.getAttribute('data-iui-filtered-index')) !== null && _b !== void 0 ? _b : focusedIndex);
|
|
51
26
|
}, [focusedIndex, menuRef]);
|
|
52
|
-
|
|
27
|
+
const { outerProps, innerProps, visibleChildren } = useVirtualization({
|
|
53
28
|
// 'Fool' VirtualScroll by passing length 1
|
|
54
29
|
// whenever there is no elements, to show empty state message
|
|
55
30
|
itemsLength: filteredOptions.length || 1,
|
|
56
31
|
itemRenderer: virtualItemRenderer,
|
|
57
32
|
scrollToIndex: focusedVisibleIndex,
|
|
58
|
-
})
|
|
59
|
-
|
|
33
|
+
});
|
|
34
|
+
const overflowY = ((_c = (_b = (_a = getWindow()) === null || _a === void 0 ? void 0 : _a.CSS) === null || _b === void 0 ? void 0 : _b.supports) === null || _c === void 0 ? void 0 : _c.call(_b, 'overflow-x: overlay'))
|
|
60
35
|
? { overflowY: 'overlay' }
|
|
61
36
|
: { overflowY: 'auto' };
|
|
62
|
-
|
|
63
|
-
minWidth
|
|
64
|
-
maxWidth:
|
|
65
|
-
})
|
|
66
|
-
return (React.createElement(Surface,
|
|
67
|
-
React.createElement("div",
|
|
68
|
-
React.createElement(Menu, { id:
|
|
37
|
+
const styles = React.useMemo(() => ({
|
|
38
|
+
minWidth,
|
|
39
|
+
maxWidth: `min(${minWidth * 2}px, 90vw)`,
|
|
40
|
+
}), [minWidth]);
|
|
41
|
+
return (React.createElement(Surface, { elevation: 1, style: { ...styles, ...overflowY, ...style }, ...rest },
|
|
42
|
+
React.createElement("div", { ...outerProps },
|
|
43
|
+
React.createElement(Menu, { id: `${id}-list`, setFocus: false, role: 'listbox', ref: mergeRefs(menuRef, innerProps.ref, forwardedRef), className: cx('iui-scroll', className), style: innerProps.style }, visibleChildren))));
|
|
69
44
|
});
|
|
70
|
-
export
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
minWidth
|
|
77
|
-
maxWidth:
|
|
78
|
-
})
|
|
79
|
-
return (React.createElement(React.Fragment, null, !enableVirtualization ? (React.createElement(Menu,
|
|
45
|
+
export const ComboBoxMenu = React.forwardRef((props, forwardedRef) => {
|
|
46
|
+
const { className, style, ...rest } = props;
|
|
47
|
+
const { minWidth, id, enableVirtualization } = useSafeContext(ComboBoxStateContext);
|
|
48
|
+
const { menuRef } = useSafeContext(ComboBoxRefsContext);
|
|
49
|
+
const refs = useMergedRefs(menuRef, forwardedRef);
|
|
50
|
+
const styles = React.useMemo(() => ({
|
|
51
|
+
minWidth,
|
|
52
|
+
maxWidth: `min(${minWidth * 2}px, 90vw)`,
|
|
53
|
+
}), [minWidth]);
|
|
54
|
+
return (React.createElement(React.Fragment, null, !enableVirtualization ? (React.createElement(Menu, { id: `${id}-list`, style: { ...styles, ...style }, setFocus: false, role: 'listbox', ref: refs, className: cx('iui-scroll', className), ...rest })) : (React.createElement(VirtualizedComboBoxMenu, { ref: forwardedRef, ...props }))));
|
|
80
55
|
});
|
|
81
56
|
ComboBoxMenu.displayName = 'ComboBoxMenu';
|
|
@@ -1,25 +1,3 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
-
var t = {};
|
|
14
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
-
t[p] = s[p];
|
|
16
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
-
t[p[i]] = s[p[i]];
|
|
20
|
-
}
|
|
21
|
-
return t;
|
|
22
|
-
};
|
|
23
1
|
/*---------------------------------------------------------------------------------------------
|
|
24
2
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
25
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
@@ -28,21 +6,21 @@ import cx from 'classnames';
|
|
|
28
6
|
import React from 'react';
|
|
29
7
|
import { useSafeContext, useMergedRefs } from '../utils';
|
|
30
8
|
import { ComboBoxStateContext } from './helpers';
|
|
31
|
-
export
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
9
|
+
export const ComboBoxMenuItem = React.memo(React.forwardRef((props, forwardedRef) => {
|
|
10
|
+
const { children, isSelected, disabled, value, onClick, sublabel, size = !!sublabel ? 'large' : 'default', icon, badge, className, role = 'menuitem', index, ...rest } = props;
|
|
11
|
+
const { focusedIndex, enableVirtualization } = useSafeContext(ComboBoxStateContext);
|
|
12
|
+
const focusRef = (el) => {
|
|
35
13
|
if (!enableVirtualization && focusedIndex === index) {
|
|
36
14
|
el === null || el === void 0 ? void 0 : el.scrollIntoView({ block: 'nearest' });
|
|
37
15
|
}
|
|
38
16
|
};
|
|
39
|
-
|
|
40
|
-
return (React.createElement("li",
|
|
17
|
+
const refs = useMergedRefs(forwardedRef, focusRef);
|
|
18
|
+
return (React.createElement("li", { className: cx('iui-menu-item', {
|
|
41
19
|
'iui-large': size === 'large',
|
|
42
20
|
'iui-active': isSelected,
|
|
43
21
|
'iui-disabled': disabled,
|
|
44
22
|
'iui-focused': focusedIndex === index,
|
|
45
|
-
}, className), ref: refs, onClick:
|
|
23
|
+
}, className), ref: refs, onClick: () => !disabled && (onClick === null || onClick === void 0 ? void 0 : onClick(value)), role: role, tabIndex: disabled || role === 'presentation' ? undefined : -1, "aria-selected": isSelected, "aria-disabled": disabled, "data-iui-index": index, ...rest },
|
|
46
24
|
icon &&
|
|
47
25
|
React.cloneElement(icon, {
|
|
48
26
|
className: cx(icon.props.className, 'iui-icon'),
|
|
@@ -1,43 +1,35 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
1
|
/*---------------------------------------------------------------------------------------------
|
|
13
2
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
14
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
15
4
|
*--------------------------------------------------------------------------------------------*/
|
|
16
5
|
import React from 'react';
|
|
17
|
-
export
|
|
18
|
-
var
|
|
19
|
-
var type = _a[0], value = _a[1];
|
|
6
|
+
export const comboBoxReducer = (state, [type, value]) => {
|
|
7
|
+
var _a;
|
|
20
8
|
switch (type) {
|
|
21
9
|
case 'open': {
|
|
22
|
-
return
|
|
10
|
+
return { ...state, isOpen: true };
|
|
23
11
|
}
|
|
24
12
|
case 'close': {
|
|
25
|
-
return
|
|
13
|
+
return { ...state, isOpen: false };
|
|
26
14
|
}
|
|
27
15
|
case 'select': {
|
|
28
|
-
return
|
|
16
|
+
return {
|
|
17
|
+
...state,
|
|
18
|
+
selectedIndex: value !== null && value !== void 0 ? value : state.selectedIndex,
|
|
19
|
+
focusedIndex: value !== null && value !== void 0 ? value : state.focusedIndex,
|
|
20
|
+
};
|
|
29
21
|
}
|
|
30
22
|
case 'focus': {
|
|
31
|
-
return
|
|
23
|
+
return { ...state, focusedIndex: (_a = value !== null && value !== void 0 ? value : state.selectedIndex) !== null && _a !== void 0 ? _a : -1 };
|
|
32
24
|
}
|
|
33
25
|
default: {
|
|
34
26
|
return state;
|
|
35
27
|
}
|
|
36
28
|
}
|
|
37
29
|
};
|
|
38
|
-
export
|
|
30
|
+
export const ComboBoxRefsContext = React.createContext(undefined);
|
|
39
31
|
ComboBoxRefsContext.displayName = 'ComboBoxRefsContext';
|
|
40
|
-
export
|
|
32
|
+
export const ComboBoxStateContext = React.createContext(undefined);
|
|
41
33
|
ComboBoxStateContext.displayName = 'ComboBoxStateContext';
|
|
42
|
-
export
|
|
34
|
+
export const ComboBoxActionContext = React.createContext(undefined);
|
|
43
35
|
ComboBoxActionContext.displayName = 'ComboBoxActionContext';
|
|
@@ -1,25 +1,3 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
-
var t = {};
|
|
14
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
-
t[p] = s[p];
|
|
16
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
-
t[p[i]] = s[p[i]];
|
|
20
|
-
}
|
|
21
|
-
return t;
|
|
22
|
-
};
|
|
23
1
|
/*---------------------------------------------------------------------------------------------
|
|
24
2
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
25
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
@@ -30,41 +8,41 @@ import { useTheme, SvgChevronLeft, SvgChevronRight, SvgChevronLeftDouble, SvgChe
|
|
|
30
8
|
import '@itwin/itwinui-css/css/date-picker.css';
|
|
31
9
|
import { IconButton } from '../Buttons/IconButton';
|
|
32
10
|
import { TimePicker } from '../TimePicker';
|
|
33
|
-
|
|
11
|
+
const isSameDay = (a, b) => {
|
|
34
12
|
return (a &&
|
|
35
13
|
b &&
|
|
36
14
|
a.getFullYear() === b.getFullYear() &&
|
|
37
15
|
a.getMonth() === b.getMonth() &&
|
|
38
16
|
a.getDate() === b.getDate());
|
|
39
17
|
};
|
|
40
|
-
|
|
18
|
+
const isInDateRange = (date, startDate, endDate) => {
|
|
41
19
|
if (!date || !startDate || !endDate) {
|
|
42
20
|
return false;
|
|
43
21
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
22
|
+
const minDate = new Date(startDate);
|
|
23
|
+
const maxDate = new Date(endDate);
|
|
24
|
+
const testDate = new Date(date);
|
|
47
25
|
testDate && testDate.setHours(0, 0, 0, 0);
|
|
48
26
|
minDate && minDate.setHours(0, 0, 0, 0);
|
|
49
27
|
maxDate && maxDate.setHours(0, 0, 0, 0);
|
|
50
28
|
return testDate > minDate && testDate < maxDate;
|
|
51
29
|
};
|
|
52
30
|
// compares to see if one date is earlier than another
|
|
53
|
-
|
|
31
|
+
const isBefore = (beforeDate, afterDate) => {
|
|
54
32
|
if (!beforeDate || !afterDate) {
|
|
55
33
|
return false;
|
|
56
34
|
}
|
|
57
|
-
|
|
58
|
-
|
|
35
|
+
const firstDate = new Date(beforeDate);
|
|
36
|
+
const secondDate = new Date(afterDate);
|
|
59
37
|
firstDate && firstDate.setHours(0, 0, 0, 0);
|
|
60
38
|
secondDate && secondDate.setHours(0, 0, 0, 0);
|
|
61
39
|
return firstDate < secondDate;
|
|
62
40
|
};
|
|
63
41
|
// Type guard for multiple did not work
|
|
64
|
-
|
|
42
|
+
const isSingleOnChange = (onChange, enableRangeSelect) => {
|
|
65
43
|
return !enableRangeSelect;
|
|
66
44
|
};
|
|
67
|
-
|
|
45
|
+
const defaultMonths = [
|
|
68
46
|
'January',
|
|
69
47
|
'February',
|
|
70
48
|
'March',
|
|
@@ -78,8 +56,8 @@ var defaultMonths = [
|
|
|
78
56
|
'November',
|
|
79
57
|
'December',
|
|
80
58
|
];
|
|
81
|
-
|
|
82
|
-
|
|
59
|
+
const defaultShortDays = ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'];
|
|
60
|
+
const defaultLongDays = [
|
|
83
61
|
'Sunday',
|
|
84
62
|
'Monday',
|
|
85
63
|
'Tuesday',
|
|
@@ -92,15 +70,15 @@ var defaultLongDays = [
|
|
|
92
70
|
* Generate localized months and days strings using `Intl.DateTimeFormat` for passed locale to use in DatePicker component.
|
|
93
71
|
* If locale is not passed, browser locale will be used.
|
|
94
72
|
*/
|
|
95
|
-
export
|
|
96
|
-
|
|
73
|
+
export const generateLocalizedStrings = (locale) => {
|
|
74
|
+
const shortWeekDayFormatter = new Intl.DateTimeFormat(locale, {
|
|
97
75
|
weekday: 'short',
|
|
98
76
|
});
|
|
99
|
-
|
|
77
|
+
const longWeekDayFormatter = new Intl.DateTimeFormat(locale, {
|
|
100
78
|
weekday: 'long',
|
|
101
79
|
});
|
|
102
|
-
|
|
103
|
-
|
|
80
|
+
const monthFormatter = new Intl.DateTimeFormat(locale, { month: 'long' });
|
|
81
|
+
const months = [
|
|
104
82
|
monthFormatter.format(new Date(2020, 0, 1)),
|
|
105
83
|
monthFormatter.format(new Date(2020, 1, 1)),
|
|
106
84
|
monthFormatter.format(new Date(2020, 2, 1)),
|
|
@@ -114,7 +92,7 @@ export var generateLocalizedStrings = function (locale) {
|
|
|
114
92
|
monthFormatter.format(new Date(2020, 10, 1)),
|
|
115
93
|
monthFormatter.format(new Date(2020, 11, 1)),
|
|
116
94
|
];
|
|
117
|
-
|
|
95
|
+
const days = [
|
|
118
96
|
longWeekDayFormatter.format(new Date(2020, 10, 1)),
|
|
119
97
|
longWeekDayFormatter.format(new Date(2020, 10, 2)),
|
|
120
98
|
longWeekDayFormatter.format(new Date(2020, 10, 3)),
|
|
@@ -123,7 +101,7 @@ export var generateLocalizedStrings = function (locale) {
|
|
|
123
101
|
longWeekDayFormatter.format(new Date(2020, 10, 6)),
|
|
124
102
|
longWeekDayFormatter.format(new Date(2020, 10, 7)),
|
|
125
103
|
];
|
|
126
|
-
|
|
104
|
+
const shortDays = [
|
|
127
105
|
shortWeekDayFormatter.format(new Date(2020, 10, 1)).slice(0, 2),
|
|
128
106
|
shortWeekDayFormatter.format(new Date(2020, 10, 2)).slice(0, 2),
|
|
129
107
|
shortWeekDayFormatter.format(new Date(2020, 10, 3)).slice(0, 2),
|
|
@@ -133,9 +111,9 @@ export var generateLocalizedStrings = function (locale) {
|
|
|
133
111
|
shortWeekDayFormatter.format(new Date(2020, 10, 7)).slice(0, 2),
|
|
134
112
|
];
|
|
135
113
|
return {
|
|
136
|
-
months
|
|
137
|
-
shortDays
|
|
138
|
-
days
|
|
114
|
+
months,
|
|
115
|
+
shortDays,
|
|
116
|
+
days,
|
|
139
117
|
};
|
|
140
118
|
};
|
|
141
119
|
/**
|
|
@@ -143,36 +121,36 @@ export var generateLocalizedStrings = function (locale) {
|
|
|
143
121
|
* @example
|
|
144
122
|
* <DatePicker date={new Date()} onChange={(e) => console.log('New date value: ' + e)} />
|
|
145
123
|
*/
|
|
146
|
-
export
|
|
124
|
+
export const DatePicker = (props) => {
|
|
147
125
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
148
|
-
|
|
126
|
+
const { date, onChange, localizedNames, className, style, setFocus = false, showTime = false, use12Hours = false, precision, hourStep, minuteStep, secondStep, showYearSelection = false, enableRangeSelect = false, startDate, endDate, ...rest } = props;
|
|
149
127
|
useTheme();
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
128
|
+
const monthNames = (_a = localizedNames === null || localizedNames === void 0 ? void 0 : localizedNames.months) !== null && _a !== void 0 ? _a : defaultMonths;
|
|
129
|
+
const shortDays = (_b = localizedNames === null || localizedNames === void 0 ? void 0 : localizedNames.shortDays) !== null && _b !== void 0 ? _b : defaultShortDays;
|
|
130
|
+
const longDays = (_c = localizedNames === null || localizedNames === void 0 ? void 0 : localizedNames.days) !== null && _c !== void 0 ? _c : defaultLongDays;
|
|
131
|
+
const [selectedDay, setSelectedDay] = React.useState(date);
|
|
132
|
+
const [selectedStartDay, setSelectedStartDay] = React.useState(startDate);
|
|
133
|
+
const [selectedEndDay, setSelectedEndDay] = React.useState(endDate);
|
|
134
|
+
const [focusedDay, setFocusedDay] = React.useState((_d = selectedStartDay !== null && selectedStartDay !== void 0 ? selectedStartDay : selectedDay) !== null && _d !== void 0 ? _d : new Date());
|
|
135
|
+
const [displayedMonthIndex, setDisplayedMonthIndex] = React.useState((_f = (_e = selectedStartDay === null || selectedStartDay === void 0 ? void 0 : selectedStartDay.getMonth()) !== null && _e !== void 0 ? _e : selectedDay === null || selectedDay === void 0 ? void 0 : selectedDay.getMonth()) !== null && _f !== void 0 ? _f : new Date().getMonth());
|
|
136
|
+
const [displayedYear, setDisplayedYear] = React.useState((_h = (_g = selectedStartDay === null || selectedStartDay === void 0 ? void 0 : selectedStartDay.getFullYear()) !== null && _g !== void 0 ? _g : selectedDay === null || selectedDay === void 0 ? void 0 : selectedDay.getFullYear()) !== null && _h !== void 0 ? _h : new Date().getFullYear());
|
|
159
137
|
// boolean that toggles between the user picking the start date and end date for date range
|
|
160
|
-
|
|
138
|
+
const [isSelectingStartDate, setIsSelectingStartDate] = React.useState(true);
|
|
161
139
|
// Used to focus days only when days are changed
|
|
162
140
|
// e.g. without this, when changing months day would be focused
|
|
163
|
-
|
|
164
|
-
React.useEffect(
|
|
141
|
+
const needFocus = React.useRef(setFocus);
|
|
142
|
+
React.useEffect(() => {
|
|
165
143
|
if (needFocus.current) {
|
|
166
144
|
needFocus.current = false;
|
|
167
145
|
}
|
|
168
146
|
});
|
|
169
|
-
|
|
147
|
+
const setMonthAndYear = React.useCallback((newMonth, newYear) => {
|
|
170
148
|
setDisplayedMonthIndex(newMonth);
|
|
171
149
|
setDisplayedYear(newYear);
|
|
172
150
|
}, []);
|
|
173
|
-
React.useEffect(
|
|
151
|
+
React.useEffect(() => {
|
|
174
152
|
var _a, _b, _c, _d;
|
|
175
|
-
|
|
153
|
+
const currentDate = new Date();
|
|
176
154
|
setSelectedDay(date);
|
|
177
155
|
setSelectedStartDay(startDate);
|
|
178
156
|
setSelectedEndDay(endDate);
|
|
@@ -181,64 +159,64 @@ export var DatePicker = function (props) {
|
|
|
181
159
|
}
|
|
182
160
|
setMonthAndYear((_b = (_a = startDate === null || startDate === void 0 ? void 0 : startDate.getMonth()) !== null && _a !== void 0 ? _a : date === null || date === void 0 ? void 0 : date.getMonth()) !== null && _b !== void 0 ? _b : currentDate.getMonth(), (_d = (_c = startDate === null || startDate === void 0 ? void 0 : startDate.getFullYear()) !== null && _c !== void 0 ? _c : date === null || date === void 0 ? void 0 : date.getFullYear()) !== null && _d !== void 0 ? _d : currentDate.getFullYear());
|
|
183
161
|
}, [date, setMonthAndYear, startDate, endDate, enableRangeSelect]);
|
|
184
|
-
|
|
185
|
-
|
|
162
|
+
const days = React.useMemo(() => {
|
|
163
|
+
let offsetToFirst = new Date(displayedYear, displayedMonthIndex, 1).getDay();
|
|
186
164
|
// if its sunday, show one week before
|
|
187
165
|
if (0 === offsetToFirst) {
|
|
188
166
|
offsetToFirst = 7;
|
|
189
167
|
}
|
|
190
|
-
|
|
168
|
+
const daysInMonth = [];
|
|
191
169
|
// generate 6 weeks of dates
|
|
192
|
-
for (
|
|
193
|
-
|
|
170
|
+
for (let i = 1; i <= 42; i++) {
|
|
171
|
+
const adjustedDay = i - offsetToFirst;
|
|
194
172
|
daysInMonth.push(new Date(displayedYear, displayedMonthIndex, adjustedDay));
|
|
195
173
|
}
|
|
196
174
|
return daysInMonth;
|
|
197
175
|
}, [displayedMonthIndex, displayedYear]);
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
for (
|
|
176
|
+
const weeks = React.useMemo(() => {
|
|
177
|
+
const weeksInMonth = [];
|
|
178
|
+
const weekCount = Math.ceil(days.length / 7);
|
|
179
|
+
for (let i = 0; i < weekCount; i++) {
|
|
202
180
|
weeksInMonth.push(days.slice(i * 7, (i + 1) * 7));
|
|
203
181
|
}
|
|
204
182
|
return weeksInMonth;
|
|
205
183
|
}, [days]);
|
|
206
|
-
|
|
184
|
+
const getNewFocusedDate = (newYear, newMonth) => {
|
|
207
185
|
var _a;
|
|
208
|
-
|
|
209
|
-
|
|
186
|
+
const currentDate = (_a = selectedStartDay !== null && selectedStartDay !== void 0 ? selectedStartDay : selectedDay) !== null && _a !== void 0 ? _a : new Date();
|
|
187
|
+
const newDate = new Date(newYear, newMonth, currentDate.getDate(), currentDate.getHours(), currentDate.getMinutes(), currentDate.getSeconds());
|
|
210
188
|
return newDate;
|
|
211
189
|
};
|
|
212
|
-
|
|
213
|
-
|
|
190
|
+
const handleMoveToPreviousYear = () => {
|
|
191
|
+
const newYear = displayedYear - 1;
|
|
214
192
|
setMonthAndYear(displayedMonthIndex, newYear);
|
|
215
193
|
setFocusedDay(getNewFocusedDate(newYear, displayedMonthIndex));
|
|
216
194
|
};
|
|
217
|
-
|
|
218
|
-
|
|
195
|
+
const handleMoveToNextYear = () => {
|
|
196
|
+
const newYear = displayedYear + 1;
|
|
219
197
|
setMonthAndYear(displayedMonthIndex, newYear);
|
|
220
198
|
setFocusedDay(getNewFocusedDate(newYear, displayedMonthIndex));
|
|
221
199
|
};
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
200
|
+
const handleMoveToPreviousMonth = () => {
|
|
201
|
+
const newMonth = displayedMonthIndex !== 0 ? displayedMonthIndex - 1 : 11;
|
|
202
|
+
const newYear = displayedMonthIndex !== 0 ? displayedYear : displayedYear - 1;
|
|
225
203
|
setMonthAndYear(newMonth, newYear);
|
|
226
204
|
setFocusedDay(getNewFocusedDate(newYear, newMonth));
|
|
227
205
|
};
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
206
|
+
const handleMoveToNextMonth = () => {
|
|
207
|
+
const newMonth = displayedMonthIndex !== 11 ? displayedMonthIndex + 1 : 0;
|
|
208
|
+
const newYear = displayedMonthIndex !== 11 ? displayedYear : displayedYear + 1;
|
|
231
209
|
setMonthAndYear(newMonth, newYear);
|
|
232
210
|
setFocusedDay(getNewFocusedDate(newYear, newMonth));
|
|
233
211
|
};
|
|
234
|
-
|
|
212
|
+
const onDayClick = (day) => {
|
|
235
213
|
// single date selection
|
|
236
214
|
if (!enableRangeSelect) {
|
|
237
215
|
if (day.getMonth() !== (selectedDay === null || selectedDay === void 0 ? void 0 : selectedDay.getMonth())) {
|
|
238
216
|
setMonthAndYear(day.getMonth(), day.getFullYear());
|
|
239
217
|
}
|
|
240
|
-
|
|
241
|
-
|
|
218
|
+
const currentDate = selectedDay !== null && selectedDay !== void 0 ? selectedDay : new Date();
|
|
219
|
+
const newDate = new Date(day.getFullYear(), day.getMonth(), day.getDate(), currentDate.getHours(), currentDate.getMinutes(), currentDate.getSeconds());
|
|
242
220
|
setSelectedDay(newDate);
|
|
243
221
|
setFocusedDay(newDate);
|
|
244
222
|
isSingleOnChange(onChange, enableRangeSelect) && (onChange === null || onChange === void 0 ? void 0 : onChange(newDate));
|
|
@@ -248,8 +226,8 @@ export var DatePicker = function (props) {
|
|
|
248
226
|
if (day.getMonth() !== (selectedStartDay === null || selectedStartDay === void 0 ? void 0 : selectedStartDay.getMonth())) {
|
|
249
227
|
setMonthAndYear(day.getMonth(), day.getFullYear());
|
|
250
228
|
}
|
|
251
|
-
|
|
252
|
-
|
|
229
|
+
const currentStartDate = selectedStartDay !== null && selectedStartDay !== void 0 ? selectedStartDay : new Date();
|
|
230
|
+
const newStartDate = new Date(day.getFullYear(), day.getMonth(), day.getDate(), currentStartDate.getHours(), currentStartDate.getMinutes(), currentStartDate.getSeconds());
|
|
253
231
|
setSelectedStartDay(newStartDate);
|
|
254
232
|
setFocusedDay(newStartDate);
|
|
255
233
|
// if the start date is after the end date or the end date is undefined, reset the end date
|
|
@@ -267,8 +245,8 @@ export var DatePicker = function (props) {
|
|
|
267
245
|
if (day.getMonth() !== (selectedEndDay === null || selectedEndDay === void 0 ? void 0 : selectedEndDay.getMonth())) {
|
|
268
246
|
setMonthAndYear(day.getMonth(), day.getFullYear());
|
|
269
247
|
}
|
|
270
|
-
|
|
271
|
-
|
|
248
|
+
const currentEndDate = selectedEndDay !== null && selectedEndDay !== void 0 ? selectedEndDay : new Date();
|
|
249
|
+
const newEndDate = new Date(day.getFullYear(), day.getMonth(), day.getDate(), currentEndDate.getHours(), currentEndDate.getMinutes(), currentEndDate.getSeconds());
|
|
272
250
|
setFocusedDay(newEndDate);
|
|
273
251
|
// if the end date is before the start date, move back the start date and still have user select end date
|
|
274
252
|
if (!isBefore(newEndDate, selectedStartDay)) {
|
|
@@ -282,11 +260,11 @@ export var DatePicker = function (props) {
|
|
|
282
260
|
}
|
|
283
261
|
}
|
|
284
262
|
};
|
|
285
|
-
|
|
263
|
+
const handleCalendarKeyDown = (event) => {
|
|
286
264
|
if (!focusedDay) {
|
|
287
265
|
return;
|
|
288
266
|
}
|
|
289
|
-
|
|
267
|
+
const adjustedFocusedDay = new Date(focusedDay);
|
|
290
268
|
switch (event.key) {
|
|
291
269
|
case 'ArrowDown':
|
|
292
270
|
adjustedFocusedDay.setDate(focusedDay.getDate() + 7);
|
|
@@ -332,12 +310,12 @@ export var DatePicker = function (props) {
|
|
|
332
310
|
break;
|
|
333
311
|
}
|
|
334
312
|
};
|
|
335
|
-
|
|
313
|
+
const getDayClass = (day) => {
|
|
336
314
|
if (day.getMonth() !== displayedMonthIndex) {
|
|
337
315
|
return 'iui-calendar-day-outside-month';
|
|
338
316
|
}
|
|
339
|
-
|
|
340
|
-
|
|
317
|
+
let dayClass = 'iui-calendar-day';
|
|
318
|
+
const isSelectedDay = isSameDay(day, selectedDay) ||
|
|
341
319
|
(isSameDay(day, selectedStartDay) && isSameDay(day, selectedEndDay));
|
|
342
320
|
if (isSelectedDay) {
|
|
343
321
|
dayClass += '-selected';
|
|
@@ -359,7 +337,7 @@ export var DatePicker = function (props) {
|
|
|
359
337
|
}
|
|
360
338
|
return dayClass;
|
|
361
339
|
};
|
|
362
|
-
return (React.createElement("div",
|
|
340
|
+
return (React.createElement("div", { className: cx('iui-date-picker', className), style: style, ...rest },
|
|
363
341
|
React.createElement("div", null,
|
|
364
342
|
React.createElement("div", { className: 'iui-calendar-month-year' },
|
|
365
343
|
showYearSelection && (React.createElement(IconButton, { styleType: 'borderless', onClick: handleMoveToPreviousYear, "aria-label": 'Previous year', size: 'small' },
|
|
@@ -374,18 +352,16 @@ export var DatePicker = function (props) {
|
|
|
374
352
|
React.createElement(SvgChevronRight, null)),
|
|
375
353
|
showYearSelection && (React.createElement(IconButton, { styleType: 'borderless', onClick: handleMoveToNextYear, "aria-label": 'Next year', size: 'small' },
|
|
376
354
|
React.createElement(SvgChevronRightDouble, null)))),
|
|
377
|
-
React.createElement("div", { className: 'iui-calendar-weekdays' }, shortDays.map(
|
|
378
|
-
React.createElement("div", { onKeyDown: handleCalendarKeyDown, role: 'listbox' }, weeks.map(
|
|
379
|
-
return (React.createElement("div", { key:
|
|
380
|
-
|
|
381
|
-
return (React.createElement("div", { key:
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
(element === null || element === void 0 ? void 0 : element.focus());
|
|
385
|
-
} }, dateValue));
|
|
355
|
+
React.createElement("div", { className: 'iui-calendar-weekdays' }, shortDays.map((day, index) => (React.createElement("div", { key: day, title: longDays[index] }, day)))),
|
|
356
|
+
React.createElement("div", { onKeyDown: handleCalendarKeyDown, role: 'listbox' }, weeks.map((weekDays, weekIndex) => {
|
|
357
|
+
return (React.createElement("div", { key: `week-${displayedMonthIndex}-${weekIndex}`, className: 'iui-calendar-week' }, weekDays.map((weekDay, dayIndex) => {
|
|
358
|
+
const dateValue = weekDay.getDate();
|
|
359
|
+
return (React.createElement("div", { key: `day-${displayedMonthIndex}-${dayIndex}`, className: getDayClass(weekDay), onClick: () => onDayClick(weekDay), role: 'option', tabIndex: isSameDay(weekDay, focusedDay) ? 0 : -1, ref: (element) => isSameDay(weekDay, focusedDay) &&
|
|
360
|
+
needFocus.current &&
|
|
361
|
+
(element === null || element === void 0 ? void 0 : element.focus()) }, dateValue));
|
|
386
362
|
})));
|
|
387
363
|
}))),
|
|
388
|
-
showTime && (React.createElement(TimePicker, { date: selectedStartDay !== null && selectedStartDay !== void 0 ? selectedStartDay : selectedDay, use12Hours: use12Hours, precision: precision, hourStep: hourStep, minuteStep: minuteStep, secondStep: secondStep, onChange:
|
|
364
|
+
showTime && (React.createElement(TimePicker, { date: selectedStartDay !== null && selectedStartDay !== void 0 ? selectedStartDay : selectedDay, use12Hours: use12Hours, precision: precision, hourStep: hourStep, minuteStep: minuteStep, secondStep: secondStep, onChange: (date) => {
|
|
389
365
|
var _a, _b, _c, _d, _e, _f;
|
|
390
366
|
return isSingleOnChange(onChange, enableRangeSelect)
|
|
391
367
|
? onChange === null || onChange === void 0 ? void 0 : onChange(date)
|