@itwin/itwinui-react 3.0.0-dev.1 → 3.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/CHANGELOG.md +25 -0
- package/cjs/core/Alert/Alert.d.ts +47 -28
- package/cjs/core/Alert/Alert.js +73 -21
- package/cjs/core/Avatar/Avatar.js +1 -1
- package/cjs/core/AvatarGroup/AvatarGroup.js +1 -1
- package/cjs/core/Breadcrumbs/Breadcrumbs.js +2 -3
- package/cjs/core/ButtonGroup/ButtonGroup.js +1 -4
- package/cjs/core/Buttons/DropdownButton/DropdownButton.js +3 -5
- package/cjs/core/Carousel/Carousel.d.ts +2 -2
- package/cjs/core/Carousel/Carousel.js +3 -5
- package/cjs/core/Carousel/CarouselDotsList.js +8 -10
- package/cjs/core/Carousel/CarouselNavigation.d.ts +2 -2
- package/cjs/core/Carousel/CarouselNavigation.js +3 -5
- package/cjs/core/Carousel/CarouselSlider.js +10 -15
- package/cjs/core/ColorPicker/ColorBuilder.js +7 -10
- package/cjs/core/ColorPicker/ColorInputPanel.js +12 -15
- package/cjs/core/ColorPicker/ColorPalette.js +4 -6
- package/cjs/core/ColorPicker/ColorPicker.js +3 -3
- package/cjs/core/ComboBox/ComboBox.js +25 -32
- package/cjs/core/ComboBox/ComboBoxDropdown.js +1 -2
- package/cjs/core/ComboBox/ComboBoxEndIcon.js +1 -1
- package/cjs/core/ComboBox/ComboBoxInput.js +21 -20
- package/cjs/core/ComboBox/ComboBoxMenu.js +3 -4
- package/cjs/core/ComboBox/ComboBoxMenuItem.js +2 -2
- package/cjs/core/ComboBox/helpers.js +4 -5
- package/cjs/core/DatePicker/DatePicker.js +32 -32
- package/cjs/core/Dialog/Dialog.js +11 -4
- package/cjs/core/Dialog/DialogBackdrop.js +1 -1
- package/cjs/core/Dialog/DialogContext.d.ts +11 -0
- package/cjs/core/Dialog/DialogMain.js +16 -22
- package/cjs/core/DropdownMenu/DropdownMenu.js +6 -8
- package/cjs/core/ExpandableBlock/ExpandableBlock.js +2 -2
- package/cjs/core/FileUpload/FileEmptyCard.js +1 -1
- package/cjs/core/FileUpload/FileUpload.d.ts +3 -4
- package/cjs/core/FileUpload/FileUpload.js +5 -8
- package/cjs/core/FileUpload/FileUploadCard.js +9 -10
- package/cjs/core/FileUpload/FileUploadTemplate.d.ts +1 -0
- package/cjs/core/FileUpload/FileUploadTemplate.js +1 -0
- package/cjs/core/InformationPanel/InformationPanel.js +1 -4
- package/cjs/core/LabeledInput/LabeledInput.js +1 -1
- package/cjs/core/LabeledTextarea/LabeledTextarea.js +1 -1
- package/cjs/core/Menu/Menu.js +3 -4
- package/cjs/core/Menu/MenuItem.js +8 -11
- package/cjs/core/Modal/Modal.d.ts +8 -9
- package/cjs/core/Modal/Modal.js +7 -17
- package/cjs/core/SearchBox/SearchBox.js +12 -12
- package/cjs/core/Select/Select.js +12 -17
- package/cjs/core/SideNavigation/SideNavigation.js +2 -2
- package/cjs/core/Slider/Slider.js +16 -19
- package/cjs/core/Slider/Thumb.js +1 -1
- package/cjs/core/StatusMessage/StatusMessage.js +1 -1
- package/cjs/core/Stepper/Stepper.js +1 -1
- package/cjs/core/Stepper/StepperStep.js +1 -1
- package/cjs/core/Table/Table.js +15 -15
- package/cjs/core/Table/TablePaginator.js +2 -3
- package/cjs/core/Table/TableRowMemoized.js +38 -45
- package/cjs/core/Table/actionHandlers/expandHandler.js +3 -3
- package/cjs/core/Table/actionHandlers/filterHandler.js +4 -5
- package/cjs/core/Table/actionHandlers/selectHandler.js +6 -6
- package/cjs/core/Table/cells/DefaultCell.js +1 -1
- package/cjs/core/Table/cells/EditableCell.js +6 -12
- package/cjs/core/Table/columns/actionColumn.js +3 -6
- package/cjs/core/Table/columns/expanderColumn.js +3 -3
- package/cjs/core/Table/columns/selectionColumn.js +4 -4
- package/cjs/core/Table/filters/DateRangeFilter/DatePickerInput.js +2 -4
- package/cjs/core/Table/filters/DateRangeFilter/DateRangeFilter.js +2 -3
- package/cjs/core/Table/filters/NumberRangeFilter/NumberRangeFilter.js +2 -3
- package/cjs/core/Table/filters/TextFilter/TextFilter.js +1 -2
- package/cjs/core/Table/hooks/useResizeColumns.js +16 -22
- package/cjs/core/Table/hooks/useScrollToRow.js +1 -2
- package/cjs/core/Table/hooks/useStickyColumns.js +3 -5
- package/cjs/core/Table/hooks/useSubRowFiltering.js +2 -4
- package/cjs/core/Tabs/Tabs.js +13 -16
- package/cjs/core/ThemeProvider/ThemeContext.d.ts +1 -1
- package/cjs/core/ThemeProvider/ThemeProvider.d.ts +2 -3
- package/cjs/core/ThemeProvider/ThemeProvider.js +14 -13
- package/cjs/core/Tile/Tile.js +2 -3
- package/cjs/core/TimePicker/TimePicker.js +13 -13
- package/cjs/core/Toast/Toast.d.ts +5 -10
- package/cjs/core/Toast/Toast.js +17 -16
- package/cjs/core/Toast/Toaster.d.ts +24 -26
- package/cjs/core/Toast/Toaster.js +91 -121
- package/cjs/core/Toast/index.d.ts +1 -4
- package/cjs/core/Toast/index.js +3 -6
- package/cjs/core/TransferList/TransferList.js +3 -4
- package/cjs/core/Tree/Tree.js +9 -13
- package/cjs/core/Tree/TreeNode.js +9 -10
- package/cjs/core/index.d.ts +1 -2
- package/cjs/core/index.js +2 -5
- package/cjs/core/utils/color/ColorValue.js +9 -15
- package/cjs/core/utils/components/AutoclearingHiddenLiveRegion.js +2 -3
- package/cjs/core/utils/components/FocusTrap.js +4 -4
- package/cjs/core/utils/components/MiddleTextTruncation.js +1 -2
- package/cjs/core/utils/components/Popover.d.ts +1 -1
- package/cjs/core/utils/components/Popover.js +5 -8
- package/cjs/core/utils/components/Resizer.js +7 -6
- package/cjs/core/utils/components/VirtualScroll.js +14 -21
- package/cjs/core/utils/functions/dom.d.ts +0 -8
- package/cjs/core/utils/functions/dom.js +3 -26
- package/cjs/core/utils/functions/polymorphic.d.ts +1 -1
- package/cjs/core/utils/functions/polymorphic.js +1 -1
- package/cjs/core/utils/functions/supports.js +1 -1
- package/cjs/core/utils/hooks/index.d.ts +0 -1
- package/cjs/core/utils/hooks/index.js +0 -1
- package/cjs/core/utils/hooks/useContainerWidth.js +1 -1
- package/cjs/core/utils/hooks/useDragAndDrop.js +8 -10
- package/cjs/core/utils/hooks/useEventListener.js +1 -1
- package/cjs/core/utils/hooks/useGlobals.d.ts +9 -2
- package/cjs/core/utils/hooks/useGlobals.js +6 -4
- package/cjs/core/utils/hooks/useId.js +1 -2
- package/cjs/core/utils/hooks/useIntersection.js +2 -3
- package/cjs/core/utils/hooks/useMediaQuery.js +6 -8
- package/cjs/core/utils/hooks/useOverflow.js +1 -2
- package/cjs/core/utils/hooks/useResizeObserver.js +3 -4
- package/cjs/styles.js +1 -4
- package/esm/core/Alert/Alert.d.ts +47 -28
- package/esm/core/Alert/Alert.js +74 -22
- package/esm/core/Avatar/Avatar.js +1 -1
- package/esm/core/AvatarGroup/AvatarGroup.js +1 -1
- package/esm/core/Breadcrumbs/Breadcrumbs.js +2 -3
- package/esm/core/ButtonGroup/ButtonGroup.js +1 -4
- package/esm/core/Buttons/DropdownButton/DropdownButton.js +3 -5
- package/esm/core/Carousel/Carousel.d.ts +2 -2
- package/esm/core/Carousel/Carousel.js +3 -5
- package/esm/core/Carousel/CarouselDotsList.js +8 -10
- package/esm/core/Carousel/CarouselNavigation.d.ts +2 -2
- package/esm/core/Carousel/CarouselNavigation.js +3 -5
- package/esm/core/Carousel/CarouselSlider.js +10 -15
- package/esm/core/ColorPicker/ColorBuilder.js +7 -10
- package/esm/core/ColorPicker/ColorInputPanel.js +12 -15
- package/esm/core/ColorPicker/ColorPalette.js +4 -6
- package/esm/core/ColorPicker/ColorPicker.js +3 -3
- package/esm/core/ComboBox/ComboBox.js +25 -32
- package/esm/core/ComboBox/ComboBoxDropdown.js +1 -2
- package/esm/core/ComboBox/ComboBoxEndIcon.js +1 -1
- package/esm/core/ComboBox/ComboBoxInput.js +21 -20
- package/esm/core/ComboBox/ComboBoxMenu.js +3 -4
- package/esm/core/ComboBox/ComboBoxMenuItem.js +2 -2
- package/esm/core/ComboBox/helpers.js +4 -5
- package/esm/core/DatePicker/DatePicker.js +32 -32
- package/esm/core/Dialog/Dialog.js +12 -5
- package/esm/core/Dialog/DialogBackdrop.js +1 -1
- package/esm/core/Dialog/DialogContext.d.ts +11 -0
- package/esm/core/Dialog/DialogMain.js +16 -22
- package/esm/core/DropdownMenu/DropdownMenu.js +6 -8
- package/esm/core/ExpandableBlock/ExpandableBlock.js +2 -2
- package/esm/core/FileUpload/FileEmptyCard.js +1 -1
- package/esm/core/FileUpload/FileUpload.d.ts +3 -4
- package/esm/core/FileUpload/FileUpload.js +5 -8
- package/esm/core/FileUpload/FileUploadCard.js +9 -10
- package/esm/core/FileUpload/FileUploadTemplate.d.ts +1 -0
- package/esm/core/FileUpload/FileUploadTemplate.js +1 -0
- package/esm/core/InformationPanel/InformationPanel.js +1 -4
- package/esm/core/LabeledInput/LabeledInput.js +1 -1
- package/esm/core/LabeledTextarea/LabeledTextarea.js +1 -1
- package/esm/core/Menu/Menu.js +3 -4
- package/esm/core/Menu/MenuItem.js +8 -11
- package/esm/core/Modal/Modal.d.ts +8 -9
- package/esm/core/Modal/Modal.js +3 -10
- package/esm/core/SearchBox/SearchBox.js +12 -12
- package/esm/core/Select/Select.js +12 -17
- package/esm/core/SideNavigation/SideNavigation.js +2 -2
- package/esm/core/Slider/Slider.js +16 -19
- package/esm/core/Slider/Thumb.js +1 -1
- package/esm/core/StatusMessage/StatusMessage.js +1 -1
- package/esm/core/Stepper/Stepper.js +1 -1
- package/esm/core/Stepper/StepperStep.js +1 -1
- package/esm/core/Table/Table.js +15 -15
- package/esm/core/Table/TablePaginator.js +2 -3
- package/esm/core/Table/TableRowMemoized.js +38 -45
- package/esm/core/Table/actionHandlers/expandHandler.js +3 -3
- package/esm/core/Table/actionHandlers/filterHandler.js +4 -5
- package/esm/core/Table/actionHandlers/selectHandler.js +6 -6
- package/esm/core/Table/cells/DefaultCell.js +1 -1
- package/esm/core/Table/cells/EditableCell.js +6 -12
- package/esm/core/Table/columns/actionColumn.js +3 -6
- package/esm/core/Table/columns/expanderColumn.js +3 -3
- package/esm/core/Table/columns/selectionColumn.js +4 -4
- package/esm/core/Table/filters/DateRangeFilter/DatePickerInput.js +2 -4
- package/esm/core/Table/filters/DateRangeFilter/DateRangeFilter.js +2 -3
- package/esm/core/Table/filters/NumberRangeFilter/NumberRangeFilter.js +2 -3
- package/esm/core/Table/filters/TextFilter/TextFilter.js +1 -2
- package/esm/core/Table/hooks/useResizeColumns.js +16 -22
- package/esm/core/Table/hooks/useScrollToRow.js +1 -2
- package/esm/core/Table/hooks/useStickyColumns.js +3 -5
- package/esm/core/Table/hooks/useSubRowFiltering.js +2 -4
- package/esm/core/Tabs/Tabs.js +13 -16
- package/esm/core/ThemeProvider/ThemeContext.d.ts +1 -1
- package/esm/core/ThemeProvider/ThemeProvider.d.ts +2 -3
- package/esm/core/ThemeProvider/ThemeProvider.js +15 -14
- package/esm/core/Tile/Tile.js +2 -3
- package/esm/core/TimePicker/TimePicker.js +13 -13
- package/esm/core/Toast/Toast.d.ts +5 -10
- package/esm/core/Toast/Toast.js +18 -17
- package/esm/core/Toast/Toaster.d.ts +24 -26
- package/esm/core/Toast/Toaster.js +85 -121
- package/esm/core/Toast/index.d.ts +1 -4
- package/esm/core/Toast/index.js +1 -3
- package/esm/core/TransferList/TransferList.js +3 -4
- package/esm/core/Tree/Tree.js +9 -13
- package/esm/core/Tree/TreeNode.js +9 -10
- package/esm/core/index.d.ts +1 -2
- package/esm/core/index.js +1 -1
- package/esm/core/utils/color/ColorValue.js +9 -15
- package/esm/core/utils/components/AutoclearingHiddenLiveRegion.js +2 -3
- package/esm/core/utils/components/FocusTrap.js +4 -4
- package/esm/core/utils/components/MiddleTextTruncation.js +1 -2
- package/esm/core/utils/components/Popover.d.ts +1 -1
- package/esm/core/utils/components/Popover.js +5 -8
- package/esm/core/utils/components/Resizer.js +7 -6
- package/esm/core/utils/components/VirtualScroll.js +14 -21
- package/esm/core/utils/functions/dom.d.ts +0 -8
- package/esm/core/utils/functions/dom.js +2 -21
- package/esm/core/utils/functions/polymorphic.d.ts +1 -1
- package/esm/core/utils/functions/polymorphic.js +1 -1
- package/esm/core/utils/functions/supports.js +1 -1
- package/esm/core/utils/hooks/index.d.ts +0 -1
- package/esm/core/utils/hooks/index.js +0 -1
- package/esm/core/utils/hooks/useContainerWidth.js +1 -1
- package/esm/core/utils/hooks/useDragAndDrop.js +8 -10
- package/esm/core/utils/hooks/useEventListener.js +1 -1
- package/esm/core/utils/hooks/useGlobals.d.ts +9 -2
- package/esm/core/utils/hooks/useGlobals.js +6 -4
- package/esm/core/utils/hooks/useId.js +1 -2
- package/esm/core/utils/hooks/useIntersection.js +2 -3
- package/esm/core/utils/hooks/useMediaQuery.js +6 -8
- package/esm/core/utils/hooks/useOverflow.js +1 -2
- package/esm/core/utils/hooks/useResizeObserver.js +3 -4
- package/esm/styles.js +1 -4
- package/package.json +2 -2
- package/styles.css +19 -20
- package/cjs/core/Toast/ToastWrapper.d.ts +0 -10
- package/cjs/core/Toast/ToastWrapper.js +0 -49
- package/cjs/core/utils/hooks/useIsThemeAlreadySet.d.ts +0 -7
- package/cjs/core/utils/hooks/useIsThemeAlreadySet.js +0 -54
- package/esm/core/Toast/ToastWrapper.d.ts +0 -10
- package/esm/core/Toast/ToastWrapper.js +0 -20
- package/esm/core/utils/hooks/useIsThemeAlreadySet.d.ts +0 -7
- package/esm/core/utils/hooks/useIsThemeAlreadySet.js +0 -27
|
@@ -20,10 +20,9 @@ export const MenuItem = React.forwardRef((props, ref) => {
|
|
|
20
20
|
const { ref: parentMenuItemRef } = React.useContext(MenuItemContext);
|
|
21
21
|
const subMenuRef = React.useRef(null);
|
|
22
22
|
const [isSubmenuVisible, setIsSubmenuVisible] = React.useState(false);
|
|
23
|
-
const startIcon = startIconProp
|
|
24
|
-
const endIcon = endIconProp
|
|
23
|
+
const startIcon = startIconProp ?? icon;
|
|
24
|
+
const endIcon = endIconProp ?? badge;
|
|
25
25
|
const onKeyDown = (event) => {
|
|
26
|
-
var _a;
|
|
27
26
|
if (event.altKey) {
|
|
28
27
|
return;
|
|
29
28
|
}
|
|
@@ -31,7 +30,7 @@ export const MenuItem = React.forwardRef((props, ref) => {
|
|
|
31
30
|
case 'Enter':
|
|
32
31
|
case ' ':
|
|
33
32
|
case 'Spacebar': {
|
|
34
|
-
!disabled &&
|
|
33
|
+
!disabled && onClick?.(value);
|
|
35
34
|
event.preventDefault();
|
|
36
35
|
break;
|
|
37
36
|
}
|
|
@@ -44,7 +43,7 @@ export const MenuItem = React.forwardRef((props, ref) => {
|
|
|
44
43
|
break;
|
|
45
44
|
}
|
|
46
45
|
case 'ArrowLeft': {
|
|
47
|
-
|
|
46
|
+
parentMenuItemRef?.current?.focus();
|
|
48
47
|
event.stopPropagation();
|
|
49
48
|
event.preventDefault();
|
|
50
49
|
break;
|
|
@@ -53,10 +52,9 @@ export const MenuItem = React.forwardRef((props, ref) => {
|
|
|
53
52
|
break;
|
|
54
53
|
}
|
|
55
54
|
};
|
|
56
|
-
const listItem = (React.createElement(ListItem, { actionable: true, size: size, active: isSelected, disabled: disabled, onClick: () => !disabled &&
|
|
57
|
-
var _a;
|
|
55
|
+
const listItem = (React.createElement(ListItem, { actionable: true, size: size, active: isSelected, disabled: disabled, onClick: () => !disabled && onClick?.(value), ref: refs, role: role, tabIndex: disabled || role === 'presentation' ? undefined : -1, "aria-selected": isSelected, "aria-haspopup": subMenuItems.length > 0, "aria-disabled": disabled, onKeyDown: onKeyDown, onMouseEnter: () => setIsSubmenuVisible(true), onMouseLeave: (e) => {
|
|
58
56
|
if (!(e.relatedTarget instanceof Node) ||
|
|
59
|
-
!
|
|
57
|
+
!subMenuRef.current?.contains(e.relatedTarget)) {
|
|
60
58
|
setIsSubmenuVisible(false);
|
|
61
59
|
}
|
|
62
60
|
}, ...rest },
|
|
@@ -69,10 +67,9 @@ export const MenuItem = React.forwardRef((props, ref) => {
|
|
|
69
67
|
endIcon && (React.createElement(ListItem.Icon, { as: 'span', "aria-hidden": true }, endIcon))));
|
|
70
68
|
return subMenuItems.length === 0 ? (listItem) : (React.createElement(MenuItemContext.Provider, { value: { ref: menuItemRef } },
|
|
71
69
|
React.createElement(Popover, { placement: 'right-start', visible: isSubmenuVisible, appendTo: 'parent', content: React.createElement("div", { onMouseLeave: () => setIsSubmenuVisible(false), onBlur: (e) => {
|
|
72
|
-
var _a, _b;
|
|
73
70
|
!!(e.relatedTarget instanceof Node) &&
|
|
74
|
-
!
|
|
75
|
-
!
|
|
71
|
+
!subMenuRef.current?.contains(e.relatedTarget) &&
|
|
72
|
+
!subMenuRef.current?.isEqualNode(e.relatedTarget) &&
|
|
76
73
|
setIsSubmenuVisible(false);
|
|
77
74
|
} },
|
|
78
75
|
React.createElement(Menu, { ref: subMenuRef }, subMenuItems)) }, listItem)));
|
|
@@ -30,16 +30,15 @@ declare type ModalProps = {
|
|
|
30
30
|
*/
|
|
31
31
|
onKeyDown?: React.KeyboardEventHandler;
|
|
32
32
|
/**
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
* Document where the modal will be rendered.
|
|
39
|
-
* Can be specified to render in a different document (e.g. a popup window).
|
|
40
|
-
* @default document
|
|
33
|
+
* If true, the dialog will be portaled into a <div> inside the nearest `ThemeProvider`.
|
|
34
|
+
*
|
|
35
|
+
* Can be set to an object with a `to` property to portal into a specific element.
|
|
36
|
+
*
|
|
37
|
+
* @default true
|
|
41
38
|
*/
|
|
42
|
-
|
|
39
|
+
portal?: boolean | {
|
|
40
|
+
to: HTMLElement;
|
|
41
|
+
};
|
|
43
42
|
/**
|
|
44
43
|
* Content of the modal.
|
|
45
44
|
*/
|
package/esm/core/Modal/Modal.js
CHANGED
|
@@ -3,8 +3,6 @@
|
|
|
3
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
5
|
import * as React from 'react';
|
|
6
|
-
import ReactDOM from 'react-dom';
|
|
7
|
-
import { getContainer, getDocument } from '../utils/index.js';
|
|
8
6
|
import { Dialog } from '../Dialog/index.js';
|
|
9
7
|
/**
|
|
10
8
|
* Modal component which can wrap any content.
|
|
@@ -28,16 +26,11 @@ import { Dialog } from '../Dialog/index.js';
|
|
|
28
26
|
* </Modal>
|
|
29
27
|
*/
|
|
30
28
|
export const Modal = React.forwardRef((props, forwardedRef) => {
|
|
31
|
-
const { isOpen = false, isDismissible = true, closeOnEsc = true, closeOnExternalClick = true, onClose, title, children,
|
|
32
|
-
|
|
33
|
-
React.useEffect(() => {
|
|
34
|
-
setContainer(getContainer(modalRootId, ownerDocument));
|
|
35
|
-
return () => setContainer(undefined);
|
|
36
|
-
}, [ownerDocument, modalRootId]);
|
|
37
|
-
return !!container ? (ReactDOM.createPortal(React.createElement(Dialog, { isOpen: isOpen, closeOnEsc: closeOnEsc, closeOnExternalClick: closeOnExternalClick, isDismissible: isDismissible, onClose: onClose, preventDocumentScroll: true, trapFocus: true, setFocus: true, ref: forwardedRef },
|
|
29
|
+
const { isOpen = false, isDismissible = true, closeOnEsc = true, closeOnExternalClick = true, onClose, title, children, portal = true, ...rest } = props;
|
|
30
|
+
return (React.createElement(Dialog, { isOpen: isOpen, closeOnEsc: closeOnEsc, closeOnExternalClick: closeOnExternalClick, isDismissible: isDismissible, onClose: onClose, preventDocumentScroll: true, trapFocus: true, setFocus: true, ref: forwardedRef, portal: portal },
|
|
38
31
|
React.createElement(Dialog.Backdrop, null),
|
|
39
32
|
React.createElement(Dialog.Main, { "aria-modal": true, ...rest },
|
|
40
33
|
React.createElement(Dialog.TitleBar, { titleText: title }),
|
|
41
|
-
children))
|
|
34
|
+
children)));
|
|
42
35
|
});
|
|
43
36
|
export default Modal;
|
|
@@ -14,16 +14,16 @@ const SearchBoxComponent = React.forwardRef((props, ref) => {
|
|
|
14
14
|
const inputRef = React.useRef(null);
|
|
15
15
|
const openButtonRef = React.useRef(null);
|
|
16
16
|
const [localExpanded, setLocalExpanded] = React.useState(isExpandedProp);
|
|
17
|
-
const isExpanded = isExpandedProp
|
|
17
|
+
const isExpanded = isExpandedProp ?? localExpanded;
|
|
18
18
|
const onCollapse = () => {
|
|
19
19
|
setLocalExpanded(false);
|
|
20
|
-
onCollapseProp
|
|
21
|
-
queueMicrotask(() =>
|
|
20
|
+
onCollapseProp?.();
|
|
21
|
+
queueMicrotask(() => openButtonRef.current?.focus({ preventScroll: true }));
|
|
22
22
|
};
|
|
23
23
|
const onExpand = () => {
|
|
24
24
|
setLocalExpanded(true);
|
|
25
|
-
onExpandProp
|
|
26
|
-
queueMicrotask(() =>
|
|
25
|
+
onExpandProp?.();
|
|
26
|
+
queueMicrotask(() => inputRef.current?.focus({ preventScroll: true }));
|
|
27
27
|
};
|
|
28
28
|
return (React.createElement(SearchBoxContext.Provider, { value: {
|
|
29
29
|
size,
|
|
@@ -37,7 +37,7 @@ const SearchBoxComponent = React.forwardRef((props, ref) => {
|
|
|
37
37
|
isExpanded,
|
|
38
38
|
expandable,
|
|
39
39
|
} },
|
|
40
|
-
React.createElement(InputFlexContainer, { ref: ref, className: cx('iui-searchbox', { 'iui-expandable-searchbox': expandable }, className), "data-iui-size": size, isDisabled: isDisabled, "data-iui-expanded": isExpanded, ...rest }, children
|
|
40
|
+
React.createElement(InputFlexContainer, { ref: ref, className: cx('iui-searchbox', { 'iui-expandable-searchbox': expandable }, className), "data-iui-size": size, isDisabled: isDisabled, "data-iui-expanded": isExpanded, ...rest }, children ?? (React.createElement(React.Fragment, null,
|
|
41
41
|
React.createElement(SearchBoxCollapsedState, null,
|
|
42
42
|
React.createElement(SearchBoxExpandButton, null)),
|
|
43
43
|
React.createElement(SearchBoxExpandedState, null,
|
|
@@ -51,7 +51,7 @@ const SearchBoxCollapsedState = ({ children, }) => {
|
|
|
51
51
|
if (!expandable || isExpanded) {
|
|
52
52
|
return null;
|
|
53
53
|
}
|
|
54
|
-
return React.createElement(React.Fragment, null, children
|
|
54
|
+
return React.createElement(React.Fragment, null, children ?? React.createElement(SearchBoxExpandButton, null));
|
|
55
55
|
};
|
|
56
56
|
SearchBoxCollapsedState.displayName = 'SearchBox.CollapsedState';
|
|
57
57
|
// ----------------------------------------------------------------------------
|
|
@@ -66,7 +66,7 @@ SearchBoxExpandedState.displayName = 'SearchBox.ExpandedState';
|
|
|
66
66
|
// ----------------------------------------------------------------------------
|
|
67
67
|
const SearchBoxIcon = React.forwardRef((props, ref) => {
|
|
68
68
|
const { className, children, ...rest } = props;
|
|
69
|
-
return (React.createElement(Icon, { "aria-hidden": true, className: cx('iui-search-icon', className), ref: ref, ...rest }, children
|
|
69
|
+
return (React.createElement(Icon, { "aria-hidden": true, className: cx('iui-search-icon', className), ref: ref, ...rest }, children ?? React.createElement(SvgSearch, null)));
|
|
70
70
|
});
|
|
71
71
|
SearchBoxIcon.displayName = 'SearchBox.Icon';
|
|
72
72
|
// ----------------------------------------------------------------------------
|
|
@@ -78,28 +78,28 @@ const SearchBoxInput = React.forwardRef((props, ref) => {
|
|
|
78
78
|
setInputId(idProp);
|
|
79
79
|
}
|
|
80
80
|
}, [idProp, inputId, setInputId]);
|
|
81
|
-
return (React.createElement(Box, { as: 'input', id: idProp
|
|
81
|
+
return (React.createElement(Box, { as: 'input', id: idProp ?? inputId, ref: useMergedRefs(ref, inputRef), role: 'searchbox', type: 'text', className: cx('iui-search-input', className), disabled: isDisabled, ...rest }));
|
|
82
82
|
});
|
|
83
83
|
SearchBoxInput.displayName = 'SearchBox.Input';
|
|
84
84
|
// ----------------------------------------------------------------------------
|
|
85
85
|
const SearchBoxButton = React.forwardRef((props, ref) => {
|
|
86
86
|
const { children, ...rest } = props;
|
|
87
87
|
const { size: sizeContext, isDisabled } = useSafeContext(SearchBoxContext);
|
|
88
|
-
return (React.createElement(IconButton, { styleType: 'borderless', size: sizeContext, ref: ref, disabled: isDisabled, ...rest }, children
|
|
88
|
+
return (React.createElement(IconButton, { styleType: 'borderless', size: sizeContext, ref: ref, disabled: isDisabled, ...rest }, children ?? React.createElement(SvgSearch, null)));
|
|
89
89
|
});
|
|
90
90
|
SearchBoxButton.displayName = 'SearchBox.Button';
|
|
91
91
|
// ----------------------------------------------------------------------------
|
|
92
92
|
const SearchBoxCollapseButton = React.forwardRef((props, ref) => {
|
|
93
93
|
const { children, onClick: onClickProp, ...rest } = props;
|
|
94
94
|
const { onCollapse, size: sizeContext, isDisabled, } = useSafeContext(SearchBoxContext);
|
|
95
|
-
return (React.createElement(SearchBoxButton, { ref: ref, "aria-label": 'Close searchbox', size: sizeContext, disabled: isDisabled, onClick: mergeEventHandlers(onClickProp, onCollapse), ...rest }, children
|
|
95
|
+
return (React.createElement(SearchBoxButton, { ref: ref, "aria-label": 'Close searchbox', size: sizeContext, disabled: isDisabled, onClick: mergeEventHandlers(onClickProp, onCollapse), ...rest }, children ?? React.createElement(SvgCloseSmall, null)));
|
|
96
96
|
});
|
|
97
97
|
SearchBoxCollapseButton.displayName = 'SearchBox.CollapseButton';
|
|
98
98
|
// ----------------------------------------------------------------------------
|
|
99
99
|
const SearchBoxExpandButton = React.forwardRef((props, ref) => {
|
|
100
100
|
const { children, className, onClick: onClickProp, ...rest } = props;
|
|
101
101
|
const { onExpand, size: sizeContext, isDisabled, openButtonRef, } = useSafeContext(SearchBoxContext);
|
|
102
|
-
return (React.createElement(SearchBoxButton, { ref: useMergedRefs(ref, openButtonRef), className: cx('iui-searchbox-open-button', className), "aria-label": 'Expand searchbox', size: sizeContext, disabled: isDisabled, onClick: mergeEventHandlers(onClickProp, onExpand), ...rest }, children
|
|
102
|
+
return (React.createElement(SearchBoxButton, { ref: useMergedRefs(ref, openButtonRef), className: cx('iui-searchbox-open-button', className), "aria-label": 'Expand searchbox', size: sizeContext, disabled: isDisabled, onClick: mergeEventHandlers(onClickProp, onExpand), ...rest }, children ?? React.createElement(SvgSearch, null)));
|
|
103
103
|
});
|
|
104
104
|
SearchBoxExpandButton.displayName = 'SearchBox.ExpandButton';
|
|
105
105
|
// ----------------------------------------------------------------------------
|
|
@@ -65,24 +65,22 @@ const isSingleOnChange = (onChange, multiple) => {
|
|
|
65
65
|
* />
|
|
66
66
|
*/
|
|
67
67
|
export const Select = (props) => {
|
|
68
|
-
var _a;
|
|
69
68
|
const uid = useId();
|
|
70
69
|
const { options, value, onChange, placeholder, disabled = false, size, setFocus = false, itemRenderer, selectedItemRenderer, className, style, menuClassName, menuStyle, onShow, onHide, popoverProps, multiple = false, triggerProps, ...rest } = props;
|
|
71
70
|
const [isOpenState, setIsOpen] = React.useState(false);
|
|
72
|
-
const isOpen =
|
|
71
|
+
const isOpen = popoverProps?.visible ?? isOpenState;
|
|
73
72
|
const [minWidth, setMinWidth] = React.useState(0);
|
|
74
73
|
const [liveRegionSelection, setLiveRegionSelection] = React.useState('');
|
|
75
74
|
const selectRef = React.useRef(null);
|
|
76
75
|
const toggleButtonRef = React.useRef(null);
|
|
77
76
|
const onShowHandler = React.useCallback((instance) => {
|
|
78
77
|
setIsOpen(true);
|
|
79
|
-
onShow
|
|
78
|
+
onShow?.(instance);
|
|
80
79
|
}, [onShow]);
|
|
81
80
|
const onHideHandler = React.useCallback((instance) => {
|
|
82
|
-
var _a;
|
|
83
81
|
setIsOpen(false);
|
|
84
|
-
|
|
85
|
-
onHide
|
|
82
|
+
selectRef.current?.focus({ preventScroll: true }); // move focus back to select button
|
|
83
|
+
onHide?.(instance);
|
|
86
84
|
}, [onHide]);
|
|
87
85
|
React.useEffect(() => {
|
|
88
86
|
if (selectRef.current && !disabled && setFocus) {
|
|
@@ -112,13 +110,12 @@ export const Select = (props) => {
|
|
|
112
110
|
};
|
|
113
111
|
const menuItems = React.useMemo(() => {
|
|
114
112
|
return options.map((option, index) => {
|
|
115
|
-
var _a;
|
|
116
113
|
const isSelected = isMultipleEnabled(value, multiple)
|
|
117
|
-
?
|
|
114
|
+
? value?.includes(option.value) ?? false
|
|
118
115
|
: value === option.value;
|
|
119
116
|
const menuItem = itemRenderer ? (itemRenderer(option, { close: () => setIsOpen(false), isSelected })) : (React.createElement(MenuItem, null, option.label));
|
|
120
117
|
const { label, icon, startIcon: startIconProp, ...restOption } = option;
|
|
121
|
-
const startIcon = startIconProp
|
|
118
|
+
const startIcon = startIconProp ?? icon;
|
|
122
119
|
return React.cloneElement(menuItem, {
|
|
123
120
|
key: `${label}-${index}`,
|
|
124
121
|
isSelected,
|
|
@@ -128,11 +125,11 @@ export const Select = (props) => {
|
|
|
128
125
|
return;
|
|
129
126
|
}
|
|
130
127
|
if (isSingleOnChange(onChange, multiple)) {
|
|
131
|
-
onChange
|
|
128
|
+
onChange?.(option.value);
|
|
132
129
|
setIsOpen(false);
|
|
133
130
|
}
|
|
134
131
|
else {
|
|
135
|
-
onChange
|
|
132
|
+
onChange?.(option.value, isSelected ? 'removed' : 'added');
|
|
136
133
|
}
|
|
137
134
|
// update live region
|
|
138
135
|
if (isMultipleEnabled(value, multiple)) {
|
|
@@ -149,7 +146,7 @@ export const Select = (props) => {
|
|
|
149
146
|
},
|
|
150
147
|
ref: (el) => {
|
|
151
148
|
if (isSelected && !multiple) {
|
|
152
|
-
el
|
|
149
|
+
el?.scrollIntoView({ block: 'nearest' });
|
|
153
150
|
}
|
|
154
151
|
},
|
|
155
152
|
role: 'option',
|
|
@@ -175,15 +172,14 @@ export const Select = (props) => {
|
|
|
175
172
|
maxWidth: `min(${minWidth * 2}px, 90vw)`,
|
|
176
173
|
...menuStyle,
|
|
177
174
|
}, id: `${uid}-menu`, key: `${uid}-menu` }, menuItems), placement: 'bottom-start', aria: { content: null }, onShow: onShowHandler, onHide: onHideHandler, ...popoverProps, visible: isOpen, onClickOutside: (_, { target }) => {
|
|
178
|
-
|
|
179
|
-
if (!((_a = toggleButtonRef.current) === null || _a === void 0 ? void 0 : _a.contains(target))) {
|
|
175
|
+
if (!toggleButtonRef.current?.contains(target)) {
|
|
180
176
|
setIsOpen(false);
|
|
181
177
|
}
|
|
182
178
|
} },
|
|
183
179
|
React.createElement(Box, { tabIndex: 0, role: 'combobox', ref: selectRef, "data-iui-size": size, onClick: () => !disabled && setIsOpen((o) => !o), onKeyDown: (e) => !disabled && onKeyDown(e), "aria-disabled": disabled, "aria-autocomplete": 'none', "aria-expanded": isOpen, "aria-haspopup": 'listbox', "aria-controls": `${uid}-menu`, ...triggerProps, className: cx('iui-select-button', {
|
|
184
180
|
'iui-placeholder': (!selectedItems || selectedItems.length === 0) && !!placeholder,
|
|
185
181
|
'iui-disabled': disabled,
|
|
186
|
-
}, triggerProps
|
|
182
|
+
}, triggerProps?.className) },
|
|
187
183
|
(!selectedItems || selectedItems.length === 0) && (React.createElement(Box, { as: 'span', className: 'iui-content' }, placeholder)),
|
|
188
184
|
isMultipleEnabled(selectedItems, multiple) ? (React.createElement(MultipleSelectButton, { selectedItems: selectedItems, selectedItemsRenderer: selectedItemRenderer, tagRenderer: tagRenderer })) : (React.createElement(SingleSelectButton, { selectedItem: selectedItems, selectedItemRenderer: selectedItemRenderer })))),
|
|
189
185
|
React.createElement(Box, { as: 'span', "aria-hidden": true, ref: toggleButtonRef, className: cx('iui-end-icon', {
|
|
@@ -195,8 +191,7 @@ export const Select = (props) => {
|
|
|
195
191
|
multiple ? (React.createElement(AutoclearingHiddenLiveRegion, { text: liveRegionSelection })) : null));
|
|
196
192
|
};
|
|
197
193
|
const SingleSelectButton = ({ selectedItem, selectedItemRenderer, }) => {
|
|
198
|
-
|
|
199
|
-
const startIcon = (_a = selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.startIcon) !== null && _a !== void 0 ? _a : selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.icon;
|
|
194
|
+
const startIcon = selectedItem?.startIcon ?? selectedItem?.icon;
|
|
200
195
|
return (React.createElement(React.Fragment, null,
|
|
201
196
|
selectedItem &&
|
|
202
197
|
selectedItemRenderer &&
|
|
@@ -29,7 +29,7 @@ export const SideNavigation = React.forwardRef((props, forwardedRef) => {
|
|
|
29
29
|
}, [isExpanded]);
|
|
30
30
|
const ExpandButton = (React.createElement(IconButton, { className: 'iui-sidenav-button iui-expand', onClick: React.useCallback(() => {
|
|
31
31
|
_setIsExpanded((expanded) => !expanded);
|
|
32
|
-
onExpanderClick
|
|
32
|
+
onExpanderClick?.();
|
|
33
33
|
}, [onExpanderClick]) },
|
|
34
34
|
React.createElement(SvgChevronRight, null)));
|
|
35
35
|
return (React.createElement(Box, { className: cx('iui-side-navigation-wrapper', className), ref: forwardedRef, ...rest },
|
|
@@ -40,7 +40,7 @@ export const SideNavigation = React.forwardRef((props, forwardedRef) => {
|
|
|
40
40
|
expanderPlacement === 'top' && ExpandButton,
|
|
41
41
|
React.createElement(Box, { className: 'iui-sidenav-content' },
|
|
42
42
|
React.createElement(Box, { className: 'iui-top' }, items.map((sidenavButton, index) => !_isExpanded ? (React.createElement(Tooltip, { content: sidenavButton.props.children, placement: 'right', key: index }, sidenavButton)) : (sidenavButton))),
|
|
43
|
-
React.createElement(Box, { className: 'iui-bottom' }, secondaryItems
|
|
43
|
+
React.createElement(Box, { className: 'iui-bottom' }, secondaryItems?.map((sidenavButton, index) => !_isExpanded ? (React.createElement(Tooltip, { content: sidenavButton.props.children, placement: 'right', key: index }, sidenavButton)) : (sidenavButton)))),
|
|
44
44
|
expanderPlacement === 'bottom' && ExpandButton),
|
|
45
45
|
submenu && (React.createElement(WithCSSTransition, { in: isSubmenuOpen, dimension: 'width', timeout: 200, classNames: 'iui' }, submenu))));
|
|
46
46
|
});
|
|
@@ -42,10 +42,9 @@ const formatNumberValue = (value, step, numDecimals) => {
|
|
|
42
42
|
* Focus specified thumb on Slider control
|
|
43
43
|
*/
|
|
44
44
|
const focusThumb = (sliderContainer, activeIndex) => {
|
|
45
|
-
var _a;
|
|
46
45
|
const doc = sliderContainer.ownerDocument;
|
|
47
46
|
if (!sliderContainer.contains(doc.activeElement) ||
|
|
48
|
-
Number(
|
|
47
|
+
Number(doc.activeElement?.getAttribute('data-index')) !== activeIndex) {
|
|
49
48
|
const thumbToFocus = sliderContainer.querySelector(`[data-index="${activeIndex}"]`);
|
|
50
49
|
thumbToFocus && thumbToFocus.focus();
|
|
51
50
|
}
|
|
@@ -59,19 +58,18 @@ const focusThumb = (sliderContainer, activeIndex) => {
|
|
|
59
58
|
* thumbMode='allow-crossing' />
|
|
60
59
|
*/
|
|
61
60
|
export const Slider = React.forwardRef((props, ref) => {
|
|
62
|
-
var _a, _b;
|
|
63
61
|
const { min = 0, max = 100, values, step = 1, setFocus = false, tooltipProps, disabled = false, tickLabels, minLabel, maxLabel, trackDisplayMode = 'auto', thumbMode = 'inhibit-crossing', onChange, onUpdate, thumbProps, className, railContainerProps, orientation = 'horizontal', ...rest } = props;
|
|
64
62
|
const [currentValues, setCurrentValues] = React.useState(values);
|
|
65
63
|
React.useEffect(() => {
|
|
66
64
|
setCurrentValues(values);
|
|
67
65
|
}, [values]);
|
|
68
|
-
const [minValueLabel, setMinValueLabel] = React.useState(() => minLabel
|
|
66
|
+
const [minValueLabel, setMinValueLabel] = React.useState(() => minLabel ?? min.toString());
|
|
69
67
|
React.useEffect(() => {
|
|
70
|
-
setMinValueLabel(minLabel
|
|
68
|
+
setMinValueLabel(minLabel ?? min.toString());
|
|
71
69
|
}, [minLabel, min]);
|
|
72
|
-
const [maxValueLabel, setMaxValueLabel] = React.useState(() => maxLabel
|
|
70
|
+
const [maxValueLabel, setMaxValueLabel] = React.useState(() => maxLabel ?? max.toString());
|
|
73
71
|
React.useEffect(() => {
|
|
74
|
-
setMaxValueLabel(maxLabel
|
|
72
|
+
setMaxValueLabel(maxLabel ?? max.toString());
|
|
75
73
|
}, [maxLabel, max]);
|
|
76
74
|
const [trackDisplay, setTrackDisplay] = React.useState(() => getDefaultTrackDisplay(trackDisplayMode, currentValues));
|
|
77
75
|
React.useEffect(() => {
|
|
@@ -111,11 +109,11 @@ export const Slider = React.forwardRef((props, ref) => {
|
|
|
111
109
|
newValues[activeThumbIndex] = pointerValue;
|
|
112
110
|
setCurrentValues(newValues);
|
|
113
111
|
'onChange' === callbackType
|
|
114
|
-
? onChange
|
|
115
|
-
: onUpdate
|
|
112
|
+
? onChange?.(newValues)
|
|
113
|
+
: onUpdate?.(newValues);
|
|
116
114
|
}
|
|
117
115
|
else if ('onChange' === callbackType) {
|
|
118
|
-
onChange
|
|
116
|
+
onChange?.(currentValues);
|
|
119
117
|
}
|
|
120
118
|
}
|
|
121
119
|
}, [
|
|
@@ -143,12 +141,12 @@ export const Slider = React.forwardRef((props, ref) => {
|
|
|
143
141
|
return;
|
|
144
142
|
}
|
|
145
143
|
if (keyboardReleased) {
|
|
146
|
-
onChange
|
|
144
|
+
onChange?.(currentValues); // currentValues since key up should not change value but only stop continuous value selection
|
|
147
145
|
}
|
|
148
146
|
else {
|
|
149
147
|
const newValues = [...currentValues]; // newValues since key down should change value
|
|
150
148
|
newValues[index] = value;
|
|
151
|
-
onUpdate
|
|
149
|
+
onUpdate?.(newValues);
|
|
152
150
|
setCurrentValues(newValues);
|
|
153
151
|
}
|
|
154
152
|
}, [currentValues, onUpdate, onChange]);
|
|
@@ -178,8 +176,8 @@ export const Slider = React.forwardRef((props, ref) => {
|
|
|
178
176
|
const newValues = [...currentValues];
|
|
179
177
|
newValues[closestValueIndex] = pointerValue;
|
|
180
178
|
setCurrentValues(newValues);
|
|
181
|
-
onChange
|
|
182
|
-
onUpdate
|
|
179
|
+
onChange?.(newValues);
|
|
180
|
+
onUpdate?.(newValues);
|
|
183
181
|
focusThumb(containerRef.current, closestValueIndex);
|
|
184
182
|
event.preventDefault();
|
|
185
183
|
event.stopPropagation();
|
|
@@ -194,8 +192,8 @@ export const Slider = React.forwardRef((props, ref) => {
|
|
|
194
192
|
onUpdate,
|
|
195
193
|
orientation,
|
|
196
194
|
]);
|
|
197
|
-
useEventListener('pointermove', handlePointerMove,
|
|
198
|
-
useEventListener('pointerup', handlePointerUp,
|
|
195
|
+
useEventListener('pointermove', handlePointerMove, containerRef.current?.ownerDocument);
|
|
196
|
+
useEventListener('pointerup', handlePointerUp, containerRef.current?.ownerDocument);
|
|
199
197
|
const tickMarkArea = React.useMemo(() => {
|
|
200
198
|
if (!tickLabels) {
|
|
201
199
|
return null;
|
|
@@ -223,10 +221,9 @@ export const Slider = React.forwardRef((props, ref) => {
|
|
|
223
221
|
}), onPointerDown: handlePointerDownOnSlider, ...railContainerProps },
|
|
224
222
|
React.createElement(Box, { className: 'iui-slider-rail' }),
|
|
225
223
|
currentValues.map((thumbValue, index) => {
|
|
226
|
-
var _a;
|
|
227
224
|
const [minVal, maxVal] = getAllowableThumbRange(index);
|
|
228
|
-
const thisThumbProps = thumbProps
|
|
229
|
-
return (React.createElement(Thumb, { key:
|
|
225
|
+
const thisThumbProps = thumbProps?.(index);
|
|
226
|
+
return (React.createElement(Thumb, { key: thisThumbProps?.id ?? index, index: index, disabled: disabled, isActive: activeThumbIndex === index, onThumbActivated: onThumbActivated, onThumbValueChanged: onThumbValueChanged, minVal: minVal, maxVal: maxVal, value: thumbValue, tooltipProps: generateTooltipProps(index, thumbValue), thumbProps: thisThumbProps, step: step, sliderMin: min, sliderMax: max, orientation: orientation }));
|
|
230
227
|
}),
|
|
231
228
|
React.createElement(Track, { trackDisplayMode: trackDisplay, sliderMin: min, sliderMax: max, values: currentValues, orientation: orientation }),
|
|
232
229
|
tickMarkArea),
|
package/esm/core/Slider/Thumb.js
CHANGED
|
@@ -57,7 +57,7 @@ export const Thumb = (props) => {
|
|
|
57
57
|
return (100.0 * (adjustedValue - sliderMin)) / (sliderMax - sliderMin);
|
|
58
58
|
}, [adjustedValue, sliderMax, sliderMin]);
|
|
59
59
|
const { style, className, ...rest } = thumbProps || {};
|
|
60
|
-
return (React.createElement(Tooltip, { placement: 'top', trigger:
|
|
60
|
+
return (React.createElement(Tooltip, { placement: 'top', trigger: tooltipProps?.visible == null ? 'mouseenter click focus' : undefined, ...tooltipProps },
|
|
61
61
|
React.createElement(Box, { ...rest, "data-index": index, ref: thumbRef, style: {
|
|
62
62
|
...style,
|
|
63
63
|
...(orientation === 'horizontal'
|
|
@@ -11,7 +11,7 @@ import { Box, StatusIconMap } from '../utils/index.js';
|
|
|
11
11
|
* <StatusMessage startIcon={<SvgStar />}>This is the text</StatusMessage>
|
|
12
12
|
*/
|
|
13
13
|
export const StatusMessage = ({ startIcon: userStartIcon, children, status, }) => {
|
|
14
|
-
const icon = userStartIcon
|
|
14
|
+
const icon = userStartIcon ?? (status && StatusIconMap[status]());
|
|
15
15
|
return (React.createElement(React.Fragment, null,
|
|
16
16
|
!!icon ? (React.createElement(Box, { as: 'span', className: 'iui-input-icon', "aria-hidden": true }, icon)) : null,
|
|
17
17
|
React.createElement(Box, { className: 'iui-message' }, children)));
|
|
@@ -10,7 +10,7 @@ const defaultStepperLocalization = {
|
|
|
10
10
|
};
|
|
11
11
|
export const Stepper = React.forwardRef((props, ref) => {
|
|
12
12
|
const { currentStep, steps, type = 'default', localization = defaultStepperLocalization, onStepClick, ...rest } = props;
|
|
13
|
-
const boundedCurrentStep = Math.min(Math.max(0, currentStep
|
|
13
|
+
const boundedCurrentStep = Math.min(Math.max(0, currentStep ?? 0), steps.length - 1);
|
|
14
14
|
return (React.createElement(Box, { className: 'iui-stepper', ref: ref, ...rest },
|
|
15
15
|
React.createElement("ol", null, steps.map((s, index) => (React.createElement(StepperStep, { key: index, index: index, title: type === 'long' ? '' : s.name, currentStepNumber: boundedCurrentStep, totalSteps: steps.length, type: type, onClick: onStepClick, description: s.description })))),
|
|
16
16
|
type === 'long' && (React.createElement(Box, { className: 'iui-stepper-steps-label' },
|
|
@@ -13,7 +13,7 @@ export const StepperStep = React.forwardRef((props, forwardedRef) => {
|
|
|
13
13
|
const isClickable = isPast && !!onClick;
|
|
14
14
|
const onCompletedClick = () => {
|
|
15
15
|
if (isClickable) {
|
|
16
|
-
onClick
|
|
16
|
+
onClick?.(index);
|
|
17
17
|
}
|
|
18
18
|
};
|
|
19
19
|
const onKeyDown = (e) => {
|
package/esm/core/Table/Table.js
CHANGED
|
@@ -25,7 +25,7 @@ let isDev = false;
|
|
|
25
25
|
try {
|
|
26
26
|
isDev = process.env.NODE_ENV !== 'production';
|
|
27
27
|
}
|
|
28
|
-
catch
|
|
28
|
+
catch { }
|
|
29
29
|
const flattenColumns = (columns) => {
|
|
30
30
|
const flatColumns = [];
|
|
31
31
|
columns.forEach((column) => {
|
|
@@ -110,11 +110,11 @@ export const Table = (props) => {
|
|
|
110
110
|
return;
|
|
111
111
|
}
|
|
112
112
|
const ownerDoc = ownerDocument.current;
|
|
113
|
-
ownerDoc
|
|
114
|
-
ownerDoc
|
|
113
|
+
ownerDoc?.addEventListener('keydown', disableUserSelect);
|
|
114
|
+
ownerDoc?.addEventListener('keyup', enableUserSelect);
|
|
115
115
|
return () => {
|
|
116
|
-
ownerDoc
|
|
117
|
-
ownerDoc
|
|
116
|
+
ownerDoc?.removeEventListener('keydown', disableUserSelect);
|
|
117
|
+
ownerDoc?.removeEventListener('keyup', enableUserSelect);
|
|
118
118
|
};
|
|
119
119
|
}, [
|
|
120
120
|
isSelectable,
|
|
@@ -128,7 +128,7 @@ export const Table = (props) => {
|
|
|
128
128
|
const tableStateReducer = React.useCallback((newState, action, previousState, instance) => {
|
|
129
129
|
switch (action.type) {
|
|
130
130
|
case TableActions.toggleSortBy:
|
|
131
|
-
onSort
|
|
131
|
+
onSort?.(newState);
|
|
132
132
|
break;
|
|
133
133
|
case TableActions.setFilter:
|
|
134
134
|
currentFilter.current = onFilterHandler(newState, action, previousState, currentFilter.current, instance);
|
|
@@ -214,13 +214,13 @@ export const Table = (props) => {
|
|
|
214
214
|
return result;
|
|
215
215
|
}, {});
|
|
216
216
|
const areFiltersSet = allColumns.some((column) => column.filterValue != null && column.filterValue !== '') || !!globalFilterValue;
|
|
217
|
-
const showFilterButton = (column) => (data.length !== 0 || areFiltersSet) && column.canFilter;
|
|
217
|
+
const showFilterButton = (column) => (data.length !== 0 || areFiltersSet) && column.canFilter && !!column.Filter;
|
|
218
218
|
const showSortButton = (column) => data.length !== 0 && column.canSort;
|
|
219
219
|
const onRowClickHandler = React.useCallback((event, row) => {
|
|
220
|
-
const isDisabled = isRowDisabled
|
|
220
|
+
const isDisabled = isRowDisabled?.(row.original);
|
|
221
221
|
const ctrlPressed = event.ctrlKey || event.metaKey;
|
|
222
222
|
if (!isDisabled) {
|
|
223
|
-
onRowClick
|
|
223
|
+
onRowClick?.(event, row);
|
|
224
224
|
}
|
|
225
225
|
if (isSelectable &&
|
|
226
226
|
!isDisabled &&
|
|
@@ -261,7 +261,7 @@ export const Table = (props) => {
|
|
|
261
261
|
React.useEffect(() => {
|
|
262
262
|
if (previousFilter.current !== currentFilter.current) {
|
|
263
263
|
previousFilter.current = currentFilter.current;
|
|
264
|
-
onFilter
|
|
264
|
+
onFilter?.(currentFilter.current, state, instance.filteredRows);
|
|
265
265
|
}
|
|
266
266
|
}, [state, instance.filteredRows, onFilter]);
|
|
267
267
|
const lastPassedColumns = React.useRef([]);
|
|
@@ -335,7 +335,7 @@ export const Table = (props) => {
|
|
|
335
335
|
const getPreparedRow = React.useCallback((index) => {
|
|
336
336
|
const row = page[index];
|
|
337
337
|
prepareRow(row);
|
|
338
|
-
return (React.createElement(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: !!
|
|
338
|
+
return (React.createElement(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 }));
|
|
339
339
|
}, [
|
|
340
340
|
page,
|
|
341
341
|
prepareRow,
|
|
@@ -380,7 +380,7 @@ export const Table = (props) => {
|
|
|
380
380
|
const isHeaderDirectClick = React.useRef(false);
|
|
381
381
|
return (React.createElement(React.Fragment, null,
|
|
382
382
|
React.createElement(Box, { ref: (element) => {
|
|
383
|
-
ownerDocument.current = element
|
|
383
|
+
ownerDocument.current = element?.ownerDocument;
|
|
384
384
|
if (isResizable) {
|
|
385
385
|
resizeRef(element);
|
|
386
386
|
}
|
|
@@ -431,7 +431,7 @@ export const Table = (props) => {
|
|
|
431
431
|
}, onClick: (e) => {
|
|
432
432
|
// Prevents from triggering sort when resizing and mouse is released in the middle of header
|
|
433
433
|
if (isHeaderDirectClick.current) {
|
|
434
|
-
onClick
|
|
434
|
+
onClick?.(e);
|
|
435
435
|
isHeaderDirectClick.current = false;
|
|
436
436
|
}
|
|
437
437
|
}, tabIndex: showSortButton(column) ? 0 : undefined, onKeyDown: (e) => {
|
|
@@ -480,7 +480,7 @@ export const Table = (props) => {
|
|
|
480
480
|
!isLoading &&
|
|
481
481
|
(data.length === 0 || rows.length === 0) &&
|
|
482
482
|
areFiltersSet && (React.createElement(Box, { className: 'iui-table-empty' },
|
|
483
|
-
React.createElement("div", null, emptyFilteredTableContent)))),
|
|
484
|
-
paginatorRenderer(paginatorRendererProps))));
|
|
483
|
+
React.createElement("div", null, emptyFilteredTableContent)))),
|
|
484
|
+
paginatorRenderer?.(paginatorRendererProps))));
|
|
485
485
|
};
|
|
486
486
|
export default Table;
|
|
@@ -40,12 +40,11 @@ export const TablePaginator = (props) => {
|
|
|
40
40
|
const needFocus = React.useRef(false);
|
|
41
41
|
const isMounted = React.useRef(false);
|
|
42
42
|
React.useEffect(() => {
|
|
43
|
-
var _a, _b;
|
|
44
43
|
// Checking `isMounted.current` prevents from focusing on initial load.
|
|
45
44
|
// Checking `needFocus.current` prevents from focusing page when clicked on previous/next page.
|
|
46
45
|
if (isMounted.current && needFocus.current) {
|
|
47
|
-
const buttonToFocus = Array.from(
|
|
48
|
-
buttonToFocus
|
|
46
|
+
const buttonToFocus = Array.from(pageListRef.current?.querySelectorAll('.iui-table-paginator-page-button') ?? []).find((el) => el.textContent?.trim() === (focusedIndex + 1).toString());
|
|
47
|
+
buttonToFocus?.focus();
|
|
49
48
|
needFocus.current = false;
|
|
50
49
|
}
|
|
51
50
|
isMounted.current = true;
|