@itwin/itwinui-react 1.44.0 → 1.46.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/README.md +2 -2
  3. package/cjs/core/Breadcrumbs/Breadcrumbs.d.ts +116 -0
  4. package/cjs/core/Breadcrumbs/Breadcrumbs.js +2 -3
  5. package/cjs/core/ButtonGroup/ButtonGroup.js +1 -1
  6. package/cjs/core/ColorPicker/ColorSwatch.d.ts +1 -1
  7. package/cjs/core/DatePicker/DatePicker.d.ts +24 -4
  8. package/cjs/core/DatePicker/DatePicker.js +116 -19
  9. package/cjs/core/Dialog/Dialog.d.ts +5 -5
  10. package/cjs/core/Dialog/Dialog.js +38 -6
  11. package/cjs/core/Dialog/DialogBackdrop.d.ts +2 -2
  12. package/cjs/core/Dialog/DialogBackdrop.js +2 -2
  13. package/cjs/core/Dialog/DialogContext.d.ts +31 -0
  14. package/cjs/core/Dialog/DialogDragContext.d.ts +8 -0
  15. package/cjs/core/Dialog/DialogDragContext.js +28 -0
  16. package/cjs/core/Dialog/DialogMain.d.ts +2 -2
  17. package/cjs/core/Dialog/DialogMain.js +46 -6
  18. package/cjs/core/Dialog/DialogTitleBar.d.ts +2 -2
  19. package/cjs/core/Dialog/DialogTitleBar.js +12 -2
  20. package/cjs/core/Modal/Modal.js +1 -1
  21. package/cjs/core/Table/Table.d.ts +9 -1
  22. package/cjs/core/Table/Table.js +51 -6
  23. package/cjs/core/Table/TableRowMemoized.d.ts +10 -2
  24. package/cjs/core/Table/TableRowMemoized.js +23 -7
  25. package/cjs/core/Table/actionHandlers/index.d.ts +1 -1
  26. package/cjs/core/Table/actionHandlers/index.js +2 -1
  27. package/cjs/core/Table/actionHandlers/resizeHandler.d.ts +2 -0
  28. package/cjs/core/Table/actionHandlers/selectHandler.d.ts +5 -0
  29. package/cjs/core/Table/actionHandlers/selectHandler.js +35 -2
  30. package/cjs/core/Table/cells/DefaultCell.d.ts +14 -1
  31. package/cjs/core/Table/cells/DefaultCell.js +10 -4
  32. package/cjs/core/index.d.ts +3 -1
  33. package/cjs/core/index.js +6 -3
  34. package/cjs/core/utils/components/MiddleTextTruncation.d.ts +15 -1
  35. package/cjs/core/utils/components/MiddleTextTruncation.js +14 -3
  36. package/cjs/core/utils/components/Resizer.d.ts +31 -0
  37. package/cjs/core/utils/components/Resizer.js +206 -0
  38. package/cjs/core/utils/components/VirtualScroll.js +26 -24
  39. package/cjs/core/utils/components/index.d.ts +1 -0
  40. package/cjs/core/utils/components/index.js +1 -0
  41. package/cjs/core/utils/functions/index.d.ts +1 -0
  42. package/cjs/core/utils/functions/index.js +1 -0
  43. package/cjs/core/utils/functions/styles.d.ts +6 -0
  44. package/cjs/core/utils/functions/styles.js +21 -0
  45. package/cjs/core/utils/hooks/useContainerWidth.d.ts +1 -1
  46. package/cjs/core/utils/hooks/useDragAndDrop.d.ts +14 -0
  47. package/cjs/core/utils/hooks/useDragAndDrop.js +110 -0
  48. package/cjs/core/utils/hooks/useEventListener.d.ts +1 -1
  49. package/cjs/core/utils/hooks/useOverflow.d.ts +1 -1
  50. package/cjs/core/utils/hooks/useResizeObserver.d.ts +1 -1
  51. package/cjs/types/react-table-config.d.ts +2 -1
  52. package/esm/core/Breadcrumbs/Breadcrumbs.d.ts +116 -0
  53. package/esm/core/Breadcrumbs/Breadcrumbs.js +2 -3
  54. package/esm/core/ButtonGroup/ButtonGroup.js +1 -1
  55. package/esm/core/ColorPicker/ColorSwatch.d.ts +1 -1
  56. package/esm/core/DatePicker/DatePicker.d.ts +24 -4
  57. package/esm/core/DatePicker/DatePicker.js +116 -19
  58. package/esm/core/Dialog/Dialog.d.ts +5 -5
  59. package/esm/core/Dialog/Dialog.js +37 -5
  60. package/esm/core/Dialog/DialogBackdrop.d.ts +2 -2
  61. package/esm/core/Dialog/DialogBackdrop.js +2 -2
  62. package/esm/core/Dialog/DialogContext.d.ts +31 -0
  63. package/esm/core/Dialog/DialogDragContext.d.ts +8 -0
  64. package/esm/core/Dialog/DialogDragContext.js +21 -0
  65. package/esm/core/Dialog/DialogMain.d.ts +2 -2
  66. package/esm/core/Dialog/DialogMain.js +47 -7
  67. package/esm/core/Dialog/DialogTitleBar.d.ts +2 -2
  68. package/esm/core/Dialog/DialogTitleBar.js +12 -2
  69. package/esm/core/Modal/Modal.js +1 -1
  70. package/esm/core/Table/Table.d.ts +9 -1
  71. package/esm/core/Table/Table.js +53 -8
  72. package/esm/core/Table/TableRowMemoized.d.ts +10 -2
  73. package/esm/core/Table/TableRowMemoized.js +23 -7
  74. package/esm/core/Table/actionHandlers/index.d.ts +1 -1
  75. package/esm/core/Table/actionHandlers/index.js +1 -1
  76. package/esm/core/Table/actionHandlers/resizeHandler.d.ts +2 -0
  77. package/esm/core/Table/actionHandlers/selectHandler.d.ts +5 -0
  78. package/esm/core/Table/actionHandlers/selectHandler.js +33 -1
  79. package/esm/core/Table/cells/DefaultCell.d.ts +14 -1
  80. package/esm/core/Table/cells/DefaultCell.js +10 -4
  81. package/esm/core/index.d.ts +3 -1
  82. package/esm/core/index.js +2 -1
  83. package/esm/core/utils/components/MiddleTextTruncation.d.ts +15 -1
  84. package/esm/core/utils/components/MiddleTextTruncation.js +14 -3
  85. package/esm/core/utils/components/Resizer.d.ts +31 -0
  86. package/esm/core/utils/components/Resizer.js +199 -0
  87. package/esm/core/utils/components/VirtualScroll.js +26 -24
  88. package/esm/core/utils/components/index.d.ts +1 -0
  89. package/esm/core/utils/components/index.js +1 -0
  90. package/esm/core/utils/functions/index.d.ts +1 -0
  91. package/esm/core/utils/functions/index.js +1 -0
  92. package/esm/core/utils/functions/styles.d.ts +6 -0
  93. package/esm/core/utils/functions/styles.js +17 -0
  94. package/esm/core/utils/hooks/useContainerWidth.d.ts +1 -1
  95. package/esm/core/utils/hooks/useDragAndDrop.d.ts +14 -0
  96. package/esm/core/utils/hooks/useDragAndDrop.js +103 -0
  97. package/esm/core/utils/hooks/useEventListener.d.ts +1 -1
  98. package/esm/core/utils/hooks/useOverflow.d.ts +1 -1
  99. package/esm/core/utils/hooks/useResizeObserver.d.ts +1 -1
  100. package/esm/types/react-table-config.d.ts +2 -1
  101. package/package.json +1 -1
@@ -1,15 +1,39 @@
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
+ };
1
23
  /*---------------------------------------------------------------------------------------------
2
24
  * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
25
  * See LICENSE.md in the project root for license terms and full copyright notice.
4
26
  *--------------------------------------------------------------------------------------------*/
5
27
  import React from 'react';
28
+ import cx from 'classnames';
6
29
  import '@itwin/itwinui-css/css/dialog.css';
7
30
  import { DialogTitleBar } from './DialogTitleBar';
8
31
  import { DialogContent } from './DialogContent';
9
32
  import { DialogBackdrop } from './DialogBackdrop';
10
33
  import { DialogContext } from './DialogContext';
11
34
  import { DialogButtonBar } from './DialogButtonBar';
12
- import DialogMain from './DialogMain';
35
+ import { DialogMain } from './DialogMain';
36
+ import { useMergedRefs } from '../utils';
13
37
  /**
14
38
  * Dialog component.
15
39
  * @example
@@ -32,8 +56,10 @@ import DialogMain from './DialogMain';
32
56
  * </Dialog.Main>
33
57
  * </Dialog>
34
58
  */
35
- export var Dialog = Object.assign(function (props) {
36
- var children = props.children, _a = props.trapFocus, trapFocus = _a === void 0 ? false : _a, _b = props.preventDocumentScroll, preventDocumentScroll = _b === void 0 ? false : _b, _c = props.isOpen, isOpen = _c === void 0 ? false : _c, _d = props.isDismissible, isDismissible = _d === void 0 ? true : _d, _e = props.closeOnEsc, closeOnEsc = _e === void 0 ? true : _e, _f = props.closeOnExternalClick, closeOnExternalClick = _f === void 0 ? false : _f, onClose = props.onClose;
59
+ export var Dialog = Object.assign(React.forwardRef(function (props, ref) {
60
+ var children = props.children, _a = props.trapFocus, trapFocus = _a === void 0 ? false : _a, _b = props.setFocus, setFocus = _b === void 0 ? false : _b, _c = props.preventDocumentScroll, preventDocumentScroll = _c === void 0 ? false : _c, _d = props.isOpen, isOpen = _d === void 0 ? false : _d, _e = props.isDismissible, isDismissible = _e === void 0 ? true : _e, _f = props.closeOnEsc, closeOnEsc = _f === void 0 ? true : _f, _g = props.closeOnExternalClick, closeOnExternalClick = _g === void 0 ? false : _g, onClose = props.onClose, _h = props.isDraggable, isDraggable = _h === void 0 ? false : _h, _j = props.isResizable, isResizable = _j === void 0 ? false : _j, _k = props.relativeTo, relativeTo = _k === void 0 ? 'viewport' : _k, className = props.className, style = props.style, rest = __rest(props, ["children", "trapFocus", "setFocus", "preventDocumentScroll", "isOpen", "isDismissible", "closeOnEsc", "closeOnExternalClick", "onClose", "isDraggable", "isResizable", "relativeTo", "className", "style"]);
61
+ var dialogRootRef = React.useRef(null);
62
+ var refs = useMergedRefs(ref, dialogRootRef);
37
63
  return (React.createElement(DialogContext.Provider, { value: {
38
64
  isOpen: isOpen,
39
65
  onClose: onClose,
@@ -42,8 +68,14 @@ export var Dialog = Object.assign(function (props) {
42
68
  isDismissible: isDismissible,
43
69
  preventDocumentScroll: preventDocumentScroll,
44
70
  trapFocus: trapFocus,
45
- } }, children));
46
- }, {
71
+ setFocus: setFocus,
72
+ isDraggable: isDraggable,
73
+ isResizable: isResizable,
74
+ relativeTo: relativeTo,
75
+ dialogRootRef: dialogRootRef,
76
+ } },
77
+ React.createElement("div", __assign({ className: cx('iui-dialog-wrapper', className), ref: refs, style: __assign({ position: relativeTo === 'container' ? 'absolute' : 'fixed' }, style) }, rest), children)));
78
+ }), {
47
79
  Backdrop: DialogBackdrop,
48
80
  Main: DialogMain,
49
81
  TitleBar: DialogTitleBar,
@@ -1,12 +1,12 @@
1
1
  import React from 'react';
2
2
  import { BackdropProps } from '../Backdrop';
3
3
  import { DialogContextProps } from './DialogContext';
4
- export declare type DialogBackdropProps = BackdropProps & Pick<DialogContextProps, 'onClose' | 'isDismissible' | 'closeOnExternalClick'>;
4
+ export declare type DialogBackdropProps = BackdropProps & Pick<DialogContextProps, 'onClose' | 'isDismissible' | 'closeOnExternalClick' | 'relativeTo'>;
5
5
  /**
6
6
  * Backdrop component for dialog. Recommended to be used with `Dialog`
7
7
  * then its visibility is being controlled by dialog's `isOpen` prop.
8
8
  * @example
9
9
  * <Dialog.Backdrop />
10
10
  */
11
- export declare const DialogBackdrop: React.ForwardRefExoticComponent<Pick<DialogBackdropProps, "onClose" | "key" | keyof React.HTMLAttributes<HTMLDivElement> | "isVisible" | "isDismissible" | "closeOnExternalClick"> & React.RefAttributes<HTMLDivElement>>;
11
+ export declare const DialogBackdrop: React.ForwardRefExoticComponent<Pick<DialogBackdropProps, "onClose" | "key" | keyof React.HTMLAttributes<HTMLDivElement> | "isVisible" | "isDismissible" | "closeOnExternalClick" | "relativeTo"> & React.RefAttributes<HTMLDivElement>>;
12
12
  export default DialogBackdrop;
@@ -36,7 +36,7 @@ import { useDialogContext } from './DialogContext';
36
36
  */
37
37
  export var DialogBackdrop = React.forwardRef(function (props, ref) {
38
38
  var dialogContext = useDialogContext();
39
- var _a = props.isVisible, isVisible = _a === void 0 ? dialogContext.isOpen : _a, _b = props.isDismissible, isDismissible = _b === void 0 ? dialogContext.isDismissible : _b, _c = props.onClose, onClose = _c === void 0 ? dialogContext.onClose : _c, _d = props.closeOnExternalClick, closeOnExternalClick = _d === void 0 ? dialogContext.closeOnExternalClick : _d, onMouseDown = props.onMouseDown, rest = __rest(props, ["isVisible", "isDismissible", "onClose", "closeOnExternalClick", "onMouseDown"]);
39
+ var _a = props.isVisible, isVisible = _a === void 0 ? dialogContext.isOpen : _a, _b = props.isDismissible, isDismissible = _b === void 0 ? dialogContext.isDismissible : _b, _c = props.onClose, onClose = _c === void 0 ? dialogContext.onClose : _c, _d = props.closeOnExternalClick, closeOnExternalClick = _d === void 0 ? dialogContext.closeOnExternalClick : _d, _e = props.relativeTo, relativeTo = _e === void 0 ? dialogContext.relativeTo : _e, onMouseDown = props.onMouseDown, style = props.style, rest = __rest(props, ["isVisible", "isDismissible", "onClose", "closeOnExternalClick", "relativeTo", "onMouseDown", "style"]);
40
40
  var backdropRef = React.useRef(null);
41
41
  var refs = useMergedRefs(backdropRef, ref);
42
42
  var handleMouseDown = function (event) {
@@ -50,6 +50,6 @@ export var DialogBackdrop = React.forwardRef(function (props, ref) {
50
50
  }
51
51
  onMouseDown === null || onMouseDown === void 0 ? void 0 : onMouseDown(event);
52
52
  };
53
- return (React.createElement(Backdrop, __assign({ isVisible: isVisible, ref: refs, onMouseDown: handleMouseDown }, rest)));
53
+ return (React.createElement(Backdrop, __assign({ isVisible: isVisible, ref: refs, onMouseDown: handleMouseDown, style: __assign({ pointerEvents: 'auto', position: relativeTo === 'container' ? 'absolute' : 'fixed' }, style) }, rest)));
54
54
  });
55
55
  export default DialogBackdrop;
@@ -29,11 +29,42 @@ export declare type DialogContextProps = {
29
29
  * @default false
30
30
  */
31
31
  trapFocus?: boolean;
32
+ /**
33
+ * If true, focuses the dialog.
34
+ * @default false
35
+ */
36
+ setFocus?: boolean;
32
37
  /**
33
38
  * Prevents body from being scrollable. This is useful when the dialog is modal.
34
39
  * @default false
35
40
  */
36
41
  preventDocumentScroll?: boolean;
42
+ /**
43
+ * Flag whether dialog is draggable.
44
+ *
45
+ * If you want to make dialog draggable relatively to the container, you should use set `relativeTo` to `container`.
46
+ *
47
+ * @default false
48
+ */
49
+ isDraggable?: boolean;
50
+ /**
51
+ * Flag whether dialog is resizable.
52
+ * @default false
53
+ */
54
+ isResizable?: boolean;
55
+ /**
56
+ * Whether dialog should be positioned relatively to a container or the viewport.
57
+ *
58
+ * Using `'container'` will absolutely position this dialog relative to the closest positioned ancestor.
59
+ * In other words, you must place the dialog as a child of an element that has `position` set to
60
+ * something other than `static`, e.g. `position: relative`.
61
+ * @default 'viewport'
62
+ */
63
+ relativeTo?: 'container' | 'viewport';
64
+ /**
65
+ * Dialog root ref. For internal use.
66
+ */
67
+ dialogRootRef?: React.RefObject<HTMLDivElement>;
37
68
  };
38
69
  export declare const DialogContext: React.Context<DialogContextProps | undefined>;
39
70
  export declare const useDialogContext: () => DialogContextProps;
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ export declare type DialogDragContextProps = {
3
+ onPointerDown?: (e: React.PointerEvent<HTMLElement>) => void;
4
+ };
5
+ export declare const DialogDragContext: React.Context<DialogDragContextProps | undefined>;
6
+ export declare const useDialogDragContext: () => {
7
+ onPointerDown?: ((e: React.PointerEvent<HTMLElement>) => void) | undefined;
8
+ };
@@ -0,0 +1,21 @@
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
+ /*---------------------------------------------------------------------------------------------
13
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
14
+ * See LICENSE.md in the project root for license terms and full copyright notice.
15
+ *--------------------------------------------------------------------------------------------*/
16
+ import React from 'react';
17
+ export var DialogDragContext = React.createContext(undefined);
18
+ export var useDialogDragContext = function () {
19
+ var context = React.useContext(DialogDragContext);
20
+ return __assign({}, context);
21
+ };
@@ -11,7 +11,7 @@ export declare type DialogMainProps = {
11
11
  * Content of the dialog.
12
12
  */
13
13
  children: React.ReactNode;
14
- } & Omit<DialogContextProps, 'closeOnExternalClick'> & React.ComponentPropsWithRef<'div'>;
14
+ } & Omit<DialogContextProps, 'closeOnExternalClick' | 'dialogRootRef'> & React.ComponentPropsWithRef<'div'>;
15
15
  /**
16
16
  * Dialog component which can wrap any content.
17
17
  * @example
@@ -32,5 +32,5 @@ export declare type DialogMainProps = {
32
32
  * </Dialog.ButtonBar>
33
33
  * </Dialog.Main>
34
34
  */
35
- export declare const DialogMain: React.ForwardRefExoticComponent<Pick<DialogMainProps, "onClose" | "key" | keyof React.HTMLAttributes<HTMLDivElement> | "styleType" | "isOpen" | "isDismissible" | "closeOnEsc" | "trapFocus" | "preventDocumentScroll"> & React.RefAttributes<HTMLDivElement>>;
35
+ export declare const DialogMain: React.ForwardRefExoticComponent<Pick<DialogMainProps, "onClose" | "key" | keyof React.HTMLAttributes<HTMLDivElement> | "styleType" | "setFocus" | "isOpen" | "isDismissible" | "isDraggable" | "closeOnEsc" | "trapFocus" | "preventDocumentScroll" | "isResizable" | "relativeTo"> & React.RefAttributes<HTMLDivElement>>;
36
36
  export default DialogMain;
@@ -26,10 +26,12 @@ var __rest = (this && this.__rest) || function (s, e) {
26
26
  *--------------------------------------------------------------------------------------------*/
27
27
  import React from 'react';
28
28
  import cx from 'classnames';
29
- import { FocusTrap, useMergedRefs, useTheme } from '../utils';
29
+ import { FocusTrap, getTranslateValues, useLatestRef, Resizer, useMergedRefs, useTheme, } from '../utils';
30
30
  import '@itwin/itwinui-css/css/dialog.css';
31
31
  import { useDialogContext } from './DialogContext';
32
32
  import { CSSTransition } from 'react-transition-group';
33
+ import { DialogDragContext } from './DialogDragContext';
34
+ import useDragAndDrop from '../utils/hooks/useDragAndDrop';
33
35
  /**
34
36
  * Dialog component which can wrap any content.
35
37
  * @example
@@ -52,14 +54,19 @@ import { CSSTransition } from 'react-transition-group';
52
54
  */
53
55
  export var DialogMain = React.forwardRef(function (props, ref) {
54
56
  var dialogContext = useDialogContext();
55
- var className = props.className, children = props.children, _a = props.styleType, styleType = _a === void 0 ? 'default' : _a, _b = props.isOpen, isOpen = _b === void 0 ? dialogContext.isOpen : _b, _c = props.isDismissible, isDismissible = _c === void 0 ? dialogContext.isDismissible : _c, _d = props.onClose, onClose = _d === void 0 ? dialogContext.onClose : _d, _e = props.closeOnEsc, closeOnEsc = _e === void 0 ? dialogContext.closeOnEsc : _e, _f = props.trapFocus, trapFocus = _f === void 0 ? dialogContext.trapFocus : _f, _g = props.preventDocumentScroll, preventDocumentScroll = _g === void 0 ? dialogContext.preventDocumentScroll : _g, onKeyDown = props.onKeyDown, rest = __rest(props, ["className", "children", "styleType", "isOpen", "isDismissible", "onClose", "closeOnEsc", "trapFocus", "preventDocumentScroll", "onKeyDown"]);
57
+ var className = props.className, children = props.children, _a = props.styleType, styleType = _a === void 0 ? 'default' : _a, _b = props.isOpen, isOpen = _b === void 0 ? dialogContext.isOpen : _b, _c = props.isDismissible, isDismissible = _c === void 0 ? dialogContext.isDismissible : _c, _d = props.onClose, onClose = _d === void 0 ? dialogContext.onClose : _d, _e = props.closeOnEsc, closeOnEsc = _e === void 0 ? dialogContext.closeOnEsc : _e, _f = props.trapFocus, trapFocus = _f === void 0 ? dialogContext.trapFocus : _f, _g = props.setFocus, setFocus = _g === void 0 ? dialogContext.setFocus : _g, _h = props.preventDocumentScroll, preventDocumentScroll = _h === void 0 ? dialogContext.preventDocumentScroll : _h, onKeyDown = props.onKeyDown, _j = props.isDraggable, isDraggable = _j === void 0 ? dialogContext.isDraggable : _j, _k = props.isResizable, isResizable = _k === void 0 ? dialogContext.isResizable : _k, propStyle = props.style, rest = __rest(props, ["className", "children", "styleType", "isOpen", "isDismissible", "onClose", "closeOnEsc", "trapFocus", "setFocus", "preventDocumentScroll", "onKeyDown", "isDraggable", "isResizable", "style"]);
56
58
  useTheme();
59
+ var _l = React.useState(), style = _l[0], setStyle = _l[1];
57
60
  var dialogRef = React.useRef(null);
58
61
  var refs = useMergedRefs(dialogRef, ref);
59
62
  // Focuses dialog when opened and brings back focus to the previously focused element when closed.
60
63
  var previousFocusedElement = React.useRef();
64
+ var setFocusRef = useLatestRef(setFocus);
61
65
  React.useEffect(function () {
62
66
  var _a, _b, _c;
67
+ if (!setFocusRef.current) {
68
+ return;
69
+ }
63
70
  if (isOpen) {
64
71
  previousFocusedElement.current = (_a = dialogRef.current) === null || _a === void 0 ? void 0 : _a.ownerDocument.activeElement;
65
72
  (_b = dialogRef.current) === null || _b === void 0 ? void 0 : _b.focus();
@@ -73,17 +80,25 @@ export var DialogMain = React.forwardRef(function (props, ref) {
73
80
  (ref === null || ref === void 0 ? void 0 : ref.contains(document.activeElement)) &&
74
81
  ((_a = previousFocusedElement.current) === null || _a === void 0 ? void 0 : _a.focus());
75
82
  };
83
+ }, [isOpen, setFocusRef]);
84
+ var originalBodyOverflow = React.useRef('');
85
+ React.useEffect(function () {
86
+ if (isOpen) {
87
+ originalBodyOverflow.current = document.body.style.overflow;
88
+ }
76
89
  }, [isOpen]);
77
90
  // Prevents document from scrolling when the dialog is open.
78
- var originalBodyOverflow = React.useRef('');
79
91
  React.useEffect(function () {
80
92
  var _a;
81
93
  var ownerDocument = (_a = dialogRef.current) === null || _a === void 0 ? void 0 : _a.ownerDocument;
82
- if (!ownerDocument || !preventDocumentScroll) {
94
+ // If there is no `ownerDocument` or `preventDocumentScroll` is false or
95
+ // document body originally has `overflow: hidden` (possibly from other/parent dialog), then do nothing.
96
+ if (!ownerDocument ||
97
+ !preventDocumentScroll ||
98
+ originalBodyOverflow.current === 'hidden') {
83
99
  return;
84
100
  }
85
101
  if (isOpen) {
86
- originalBodyOverflow.current = ownerDocument.body.style.overflow;
87
102
  ownerDocument.body.style.overflow = 'hidden';
88
103
  }
89
104
  else {
@@ -101,13 +116,38 @@ export var DialogMain = React.forwardRef(function (props, ref) {
101
116
  }
102
117
  onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(event);
103
118
  };
119
+ var _m = useDragAndDrop(dialogRef, dialogContext.dialogRootRef, isDraggable), onPointerDown = _m.onPointerDown, transform = _m.transform;
120
+ var handlePointerDown = React.useCallback(function (event) {
121
+ if (isDraggable) {
122
+ onPointerDown(event);
123
+ }
124
+ }, [isDraggable, onPointerDown]);
125
+ // Prevents dialog from moving when window is being resized
126
+ React.useLayoutEffect(function () {
127
+ var _a;
128
+ if (!isDraggable || !isOpen) {
129
+ return;
130
+ }
131
+ var rect = (_a = dialogRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
132
+ var _b = getTranslateValues(dialogRef.current), translateX = _b[0], translateY = _b[1];
133
+ setStyle(function (oldStyle) {
134
+ var _a, _b;
135
+ return (__assign(__assign({}, oldStyle), { width: rect === null || rect === void 0 ? void 0 : rect.width, height: rect === null || rect === void 0 ? void 0 : rect.height, left: (_a = dialogRef.current) === null || _a === void 0 ? void 0 : _a.offsetLeft, top: (_b = dialogRef.current) === null || _b === void 0 ? void 0 : _b.offsetTop, transform: "translate(".concat(translateX, "px,").concat(translateY, "px)") }));
136
+ });
137
+ }, [isDraggable, isOpen]);
138
+ var setResizeStyle = React.useCallback(function (newStyle) {
139
+ setStyle(function (oldStyle) { return (__assign(__assign({}, oldStyle), newStyle)); });
140
+ }, []);
104
141
  var content = (React.createElement("div", __assign({ className: cx('iui-dialog', {
105
142
  'iui-dialog-default': styleType === 'default',
106
143
  'iui-dialog-full-page': styleType === 'fullPage',
107
144
  'iui-dialog-visible': isOpen,
108
- }, className), role: 'dialog', ref: refs, onKeyDown: handleKeyDown, tabIndex: -1 }, rest), children));
145
+ 'iui-dialog-draggable': isDraggable,
146
+ }, className), role: 'dialog', ref: refs, onKeyDown: handleKeyDown, tabIndex: -1, style: __assign(__assign({ transform: transform, overflow: 'unset' }, style), propStyle) }, rest),
147
+ isResizable && (React.createElement(Resizer, { elementRef: dialogRef, containerRef: dialogContext.dialogRootRef, onResizeEnd: setResizeStyle })),
148
+ children));
109
149
  return (React.createElement(CSSTransition, { in: isOpen, classNames: 'iui-dialog-animation', timeout: { exit: 600 }, unmountOnExit: true, nodeRef: dialogRef },
110
- React.createElement(React.Fragment, null,
150
+ React.createElement(DialogDragContext.Provider, { value: { onPointerDown: handlePointerDown } },
111
151
  trapFocus && React.createElement(FocusTrap, null, content),
112
152
  !trapFocus && content)));
113
153
  });
@@ -10,7 +10,7 @@ export declare type DialogTitleBarProps = {
10
10
  * Dialog title.
11
11
  */
12
12
  titleText?: React.ReactNode;
13
- } & Pick<DialogContextProps, 'isDismissible' | 'onClose'> & React.ComponentPropsWithRef<'div'>;
13
+ } & Pick<DialogContextProps, 'isDismissible' | 'onClose' | 'isDraggable'> & React.ComponentPropsWithRef<'div'>;
14
14
  /**
15
15
  * Dialog title bar. Recommended to be used as a child of `Dialog`.
16
16
  * @example
@@ -28,7 +28,7 @@ export declare type DialogTitleBarProps = {
28
28
  * </IconButton>
29
29
  * </Dialog.TitleBar>
30
30
  */
31
- export declare const DialogTitleBar: React.ForwardRefExoticComponent<Pick<DialogTitleBarProps, "onClose" | "key" | keyof React.HTMLAttributes<HTMLDivElement> | "isDismissible" | "titleText"> & React.RefAttributes<HTMLDivElement>> & {
31
+ export declare const DialogTitleBar: React.ForwardRefExoticComponent<Pick<DialogTitleBarProps, "onClose" | "key" | keyof React.HTMLAttributes<HTMLDivElement> | "isDismissible" | "isDraggable" | "titleText"> & React.RefAttributes<HTMLDivElement>> & {
32
32
  Title: React.ForwardRefExoticComponent<Pick<import("./DialogTitleBarTitle").DialogTitleBarTitleProps, "key" | keyof React.HTMLAttributes<HTMLDivElement>> & React.RefAttributes<HTMLDivElement>>;
33
33
  };
34
34
  export default DialogTitleBar;
@@ -32,6 +32,7 @@ import { IconButton } from '../Buttons';
32
32
  import '@itwin/itwinui-css/css/dialog.css';
33
33
  import { useDialogContext } from './DialogContext';
34
34
  import { DialogTitleBarTitle } from './DialogTitleBarTitle';
35
+ import { useDialogDragContext } from './DialogDragContext';
35
36
  /**
36
37
  * Dialog title bar. Recommended to be used as a child of `Dialog`.
37
38
  * @example
@@ -51,9 +52,18 @@ import { DialogTitleBarTitle } from './DialogTitleBarTitle';
51
52
  */
52
53
  export var DialogTitleBar = Object.assign(React.forwardRef(function (props, ref) {
53
54
  var dialogContext = useDialogContext();
54
- var children = props.children, titleText = props.titleText, _a = props.isDismissible, isDismissible = _a === void 0 ? dialogContext.isDismissible : _a, _b = props.onClose, onClose = _b === void 0 ? dialogContext.onClose : _b, className = props.className, rest = __rest(props, ["children", "titleText", "isDismissible", "onClose", "className"]);
55
+ var children = props.children, titleText = props.titleText, _a = props.isDismissible, isDismissible = _a === void 0 ? dialogContext.isDismissible : _a, _b = props.onClose, onClose = _b === void 0 ? dialogContext.onClose : _b, _c = props.isDraggable, isDraggable = _c === void 0 ? dialogContext.isDraggable : _c, className = props.className, onPointerDownProp = props.onPointerDown, rest = __rest(props, ["children", "titleText", "isDismissible", "onClose", "isDraggable", "className", "onPointerDown"]);
56
+ var onPointerDown = useDialogDragContext().onPointerDown;
57
+ var handlePointerDown = React.useCallback(function (event) {
58
+ onPointerDownProp === null || onPointerDownProp === void 0 ? void 0 : onPointerDownProp(event);
59
+ if (!event.defaultPrevented) {
60
+ onPointerDown === null || onPointerDown === void 0 ? void 0 : onPointerDown(event);
61
+ }
62
+ }, [onPointerDown, onPointerDownProp]);
55
63
  useTheme();
56
- return (React.createElement("div", __assign({ className: cx('iui-dialog-title-bar', className), ref: ref }, rest), children ? (children) : (React.createElement(React.Fragment, null,
64
+ return (React.createElement("div", __assign({ className: cx('iui-dialog-title-bar', className, {
65
+ 'iui-dialog-title-bar-filled': isDraggable,
66
+ }), ref: ref, onPointerDown: handlePointerDown }, rest), children ? (children) : (React.createElement(React.Fragment, null,
57
67
  React.createElement(DialogTitleBarTitle, null, titleText),
58
68
  isDismissible && (React.createElement(IconButton, { size: 'small', styleType: 'borderless', onClick: onClose, "aria-label": 'Close' },
59
69
  React.createElement(SvgClose, null)))))));
@@ -54,7 +54,7 @@ export var Modal = function (props) {
54
54
  var _a = props.isOpen, isOpen = _a === void 0 ? false : _a, _b = props.isDismissible, isDismissible = _b === void 0 ? true : _b, _c = props.closeOnEsc, closeOnEsc = _c === void 0 ? true : _c, _d = props.closeOnExternalClick, closeOnExternalClick = _d === void 0 ? true : _d, onClose = props.onClose, title = props.title, children = props.children, _e = props.modalRootId, modalRootId = _e === void 0 ? 'iui-react-portal-container' : _e, _f = props.ownerDocument, ownerDocument = _f === void 0 ? getDocument() : _f, rest = __rest(props, ["isOpen", "isDismissible", "closeOnEsc", "closeOnExternalClick", "onClose", "title", "children", "modalRootId", "ownerDocument"]);
55
55
  useTheme();
56
56
  var container = getContainer(modalRootId, ownerDocument);
57
- return !!container ? (ReactDOM.createPortal(React.createElement(Dialog, { isOpen: isOpen, closeOnEsc: closeOnEsc, closeOnExternalClick: closeOnExternalClick, isDismissible: isDismissible, onClose: onClose, preventDocumentScroll: true, trapFocus: true },
57
+ return !!container ? (ReactDOM.createPortal(React.createElement(Dialog, { isOpen: isOpen, closeOnEsc: closeOnEsc, closeOnExternalClick: closeOnExternalClick, isDismissible: isDismissible, onClose: onClose, preventDocumentScroll: true, trapFocus: true, setFocus: true },
58
58
  React.createElement(Dialog.Backdrop, null),
59
59
  React.createElement(Dialog.Main, __assign({ "aria-modal": true }, rest),
60
60
  React.createElement(Dialog.TitleBar, { titleText: title }),
@@ -116,6 +116,12 @@ export declare type TableProps<T extends Record<string, unknown> = Record<string
116
116
  * Must be memoized.
117
117
  */
118
118
  onFilter?: (filters: TableFilterValue<T>[], state: TableState<T>) => void;
119
+ /**
120
+ * Value used for global filtering.
121
+ * Use with `globalFilter` and/or `manualGlobalFilter` to handle filtering yourself e.g. filter in server-side.
122
+ * Must be memoized.
123
+ */
124
+ globalFilterValue?: unknown;
119
125
  /**
120
126
  * Content shown when there is no data after filtering.
121
127
  */
@@ -129,7 +135,9 @@ export declare type TableProps<T extends Record<string, unknown> = Record<string
129
135
  * Function that should return custom props passed to the each row.
130
136
  * Must be memoized.
131
137
  */
132
- rowProps?: (row: Row<T>) => React.ComponentPropsWithRef<'div'>;
138
+ rowProps?: (row: Row<T>) => React.ComponentPropsWithRef<'div'> & {
139
+ status?: 'positive' | 'warning' | 'negative';
140
+ };
133
141
  /**
134
142
  * Modify the density of the table (adjusts the row height).
135
143
  * @default 'default'
@@ -26,7 +26,7 @@ var __rest = (this && this.__rest) || function (s, e) {
26
26
  *--------------------------------------------------------------------------------------------*/
27
27
  import React from 'react';
28
28
  import cx from 'classnames';
29
- import { actions as TableActions, useFlexLayout, useFilters, useRowSelect, useSortBy, useTable, useExpanded, usePagination, useColumnOrder, } from 'react-table';
29
+ import { actions as TableActions, useFlexLayout, useFilters, useRowSelect, useSortBy, useTable, useExpanded, usePagination, useColumnOrder, useGlobalFilter, } from 'react-table';
30
30
  import { ProgressRadial } from '../ProgressIndicators';
31
31
  import { useTheme, useResizeObserver, mergeRefs } from '../utils';
32
32
  import '@itwin/itwinui-css/css/table.css';
@@ -37,10 +37,11 @@ import { TableRowMemoized } from './TableRowMemoized';
37
37
  import { FilterToggle } from './filters';
38
38
  import { customFilterFunctions } from './filters/customFilterFunctions';
39
39
  import { useExpanderCell, useSelectionCell, useSubRowFiltering, useSubRowSelection, useResizeColumns, useColumnDragAndDrop, useScrollToRow, useStickyColumns, } from './hooks';
40
- import { onExpandHandler, onFilterHandler, onSelectHandler, onSingleSelectHandler, onTableResizeEnd, onTableResizeStart, } from './actionHandlers';
40
+ import { onExpandHandler, onFilterHandler, onSelectHandler, onShiftSelectHandler, onSingleSelectHandler, onTableResizeEnd, onTableResizeStart, } from './actionHandlers';
41
41
  import VirtualScroll from '../utils/components/VirtualScroll';
42
42
  import { SELECTION_CELL_ID } from './columns';
43
43
  var singleRowSelectedAction = 'singleRowSelected';
44
+ var shiftRowSelectedAction = 'shiftRowSelected';
44
45
  export var tableResizeStartAction = 'tableResizeStart';
45
46
  var tableResizeEndAction = 'tableResizeEnd';
46
47
  var flattenColumns = function (columns) {
@@ -97,7 +98,7 @@ var flattenColumns = function (columns) {
97
98
  */
98
99
  export var Table = function (props) {
99
100
  var _a;
100
- var data = props.data, columns = props.columns, _b = props.isLoading, isLoading = _b === void 0 ? false : _b, emptyTableContent = props.emptyTableContent, className = props.className, style = props.style, id = props.id, _c = props.isSelectable, isSelectable = _c === void 0 ? false : _c, onSelect = props.onSelect, onRowClick = props.onRowClick, _d = props.selectionMode, selectionMode = _d === void 0 ? 'multi' : _d, _e = props.isSortable, isSortable = _e === void 0 ? false : _e, onSort = props.onSort, stateReducer = props.stateReducer, onBottomReached = props.onBottomReached, onRowInViewport = props.onRowInViewport, _f = props.intersectionMargin, intersectionMargin = _f === void 0 ? 300 : _f, subComponent = props.subComponent, onExpand = props.onExpand, onFilter = props.onFilter, emptyFilteredTableContent = props.emptyFilteredTableContent, filterFunctions = props.filterTypes, expanderCell = props.expanderCell, isRowDisabled = props.isRowDisabled, rowProps = props.rowProps, _g = props.density, density = _g === void 0 ? 'default' : _g, _h = props.selectSubRows, selectSubRows = _h === void 0 ? true : _h, getSubRows = props.getSubRows, _j = props.selectRowOnClick, selectRowOnClick = _j === void 0 ? true : _j, paginatorRenderer = props.paginatorRenderer, _k = props.pageSize, pageSize = _k === void 0 ? 25 : _k, _l = props.isResizable, isResizable = _l === void 0 ? false : _l, _m = props.styleType, styleType = _m === void 0 ? 'default' : _m, _o = props.enableVirtualization, enableVirtualization = _o === void 0 ? false : _o, _p = props.enableColumnReordering, enableColumnReordering = _p === void 0 ? false : _p, rest = __rest(props, ["data", "columns", "isLoading", "emptyTableContent", "className", "style", "id", "isSelectable", "onSelect", "onRowClick", "selectionMode", "isSortable", "onSort", "stateReducer", "onBottomReached", "onRowInViewport", "intersectionMargin", "subComponent", "onExpand", "onFilter", "emptyFilteredTableContent", "filterTypes", "expanderCell", "isRowDisabled", "rowProps", "density", "selectSubRows", "getSubRows", "selectRowOnClick", "paginatorRenderer", "pageSize", "isResizable", "styleType", "enableVirtualization", "enableColumnReordering"]);
101
+ var data = props.data, columns = props.columns, _b = props.isLoading, isLoading = _b === void 0 ? false : _b, emptyTableContent = props.emptyTableContent, className = props.className, style = props.style, id = props.id, _c = props.isSelectable, isSelectable = _c === void 0 ? false : _c, onSelect = props.onSelect, onRowClick = props.onRowClick, _d = props.selectionMode, selectionMode = _d === void 0 ? 'multi' : _d, _e = props.isSortable, isSortable = _e === void 0 ? false : _e, onSort = props.onSort, stateReducer = props.stateReducer, onBottomReached = props.onBottomReached, onRowInViewport = props.onRowInViewport, _f = props.intersectionMargin, intersectionMargin = _f === void 0 ? 300 : _f, subComponent = props.subComponent, onExpand = props.onExpand, onFilter = props.onFilter, globalFilterValue = props.globalFilterValue, emptyFilteredTableContent = props.emptyFilteredTableContent, filterFunctions = props.filterTypes, expanderCell = props.expanderCell, isRowDisabled = props.isRowDisabled, rowProps = props.rowProps, _g = props.density, density = _g === void 0 ? 'default' : _g, _h = props.selectSubRows, selectSubRows = _h === void 0 ? true : _h, getSubRows = props.getSubRows, _j = props.selectRowOnClick, selectRowOnClick = _j === void 0 ? true : _j, paginatorRenderer = props.paginatorRenderer, _k = props.pageSize, pageSize = _k === void 0 ? 25 : _k, _l = props.isResizable, isResizable = _l === void 0 ? false : _l, _m = props.styleType, styleType = _m === void 0 ? 'default' : _m, _o = props.enableVirtualization, enableVirtualization = _o === void 0 ? false : _o, _p = props.enableColumnReordering, enableColumnReordering = _p === void 0 ? false : _p, rest = __rest(props, ["data", "columns", "isLoading", "emptyTableContent", "className", "style", "id", "isSelectable", "onSelect", "onRowClick", "selectionMode", "isSortable", "onSort", "stateReducer", "onBottomReached", "onRowInViewport", "intersectionMargin", "subComponent", "onExpand", "onFilter", "globalFilterValue", "emptyFilteredTableContent", "filterTypes", "expanderCell", "isRowDisabled", "rowProps", "density", "selectSubRows", "getSubRows", "selectRowOnClick", "paginatorRenderer", "pageSize", "isResizable", "styleType", "enableVirtualization", "enableColumnReordering"]);
101
102
  useTheme();
102
103
  var _q = React.useState(), ownerDocument = _q[0], setOwnerDocument = _q[1];
103
104
  var defaultColumn = React.useMemo(function () { return ({
@@ -116,6 +117,34 @@ export var Table = function (props) {
116
117
  var flatColumns = flattenColumns(columns);
117
118
  return flatColumns.some(function (column) { return column.id === SELECTION_CELL_ID; });
118
119
  }, [columns]);
120
+ var disableUserSelect = React.useCallback(function (e) {
121
+ if (e.key === 'Shift') {
122
+ ownerDocument &&
123
+ (ownerDocument.documentElement.style.userSelect = 'none');
124
+ }
125
+ }, [ownerDocument]);
126
+ var enableUserSelect = React.useCallback(function (e) {
127
+ if (e.key === 'Shift') {
128
+ ownerDocument && (ownerDocument.documentElement.style.userSelect = '');
129
+ }
130
+ }, [ownerDocument]);
131
+ React.useEffect(function () {
132
+ if (!isSelectable || selectionMode !== 'multi') {
133
+ return;
134
+ }
135
+ ownerDocument === null || ownerDocument === void 0 ? void 0 : ownerDocument.addEventListener('keydown', disableUserSelect);
136
+ ownerDocument === null || ownerDocument === void 0 ? void 0 : ownerDocument.addEventListener('keyup', enableUserSelect);
137
+ return function () {
138
+ ownerDocument === null || ownerDocument === void 0 ? void 0 : ownerDocument.removeEventListener('keydown', disableUserSelect);
139
+ ownerDocument === null || ownerDocument === void 0 ? void 0 : ownerDocument.removeEventListener('keyup', enableUserSelect);
140
+ };
141
+ }, [
142
+ isSelectable,
143
+ selectionMode,
144
+ ownerDocument,
145
+ disableUserSelect,
146
+ enableUserSelect,
147
+ ]);
119
148
  var tableStateReducer = React.useCallback(function (newState, action, previousState, instance) {
120
149
  switch (action.type) {
121
150
  case TableActions.toggleSortBy:
@@ -134,6 +163,12 @@ export var Table = function (props) {
134
163
  hasManualSelectionColumn ? undefined : isRowDisabled);
135
164
  break;
136
165
  }
166
+ case shiftRowSelectedAction: {
167
+ newState = onShiftSelectHandler(newState, action, instance, onSelect,
168
+ // If it has manual selection column, then we can't check whether row is disabled
169
+ hasManualSelectionColumn ? undefined : isRowDisabled);
170
+ break;
171
+ }
137
172
  case TableActions.toggleRowSelected:
138
173
  case TableActions.toggleAllRowsSelected:
139
174
  case TableActions.toggleAllPageRowsSelected: {
@@ -171,8 +206,8 @@ export var Table = function (props) {
171
206
  return getSubRows ? getSubRows(item, index) : item.subRows;
172
207
  });
173
208
  }, [data, getSubRows]);
174
- var instance = useTable(__assign(__assign({ manualPagination: !paginatorRenderer, paginateExpandedRows: false }, props), { columns: columns, defaultColumn: defaultColumn, disableSortBy: !isSortable, stateReducer: tableStateReducer, filterTypes: filterTypes, selectSubRows: selectSubRows, data: data, getSubRows: getSubRows, initialState: __assign({ pageSize: pageSize }, props.initialState) }), useFlexLayout, useResizeColumns(ownerDocument), useFilters, useSubRowFiltering(hasAnySubRows), useSortBy, useExpanded, usePagination, useRowSelect, useSubRowSelection, useExpanderCell(subComponent, expanderCell, isRowDisabled), useSelectionCell(isSelectable, selectionMode, isRowDisabled), useColumnOrder, useColumnDragAndDrop(enableColumnReordering), useStickyColumns);
175
- var getTableProps = instance.getTableProps, rows = instance.rows, headerGroups = instance.headerGroups, getTableBodyProps = instance.getTableBodyProps, prepareRow = instance.prepareRow, state = instance.state, allColumns = instance.allColumns, filteredFlatRows = instance.filteredFlatRows, dispatch = instance.dispatch, page = instance.page, gotoPage = instance.gotoPage, setPageSize = instance.setPageSize, flatHeaders = instance.flatHeaders, visibleColumns = instance.visibleColumns;
209
+ var instance = useTable(__assign(__assign({ manualPagination: !paginatorRenderer, paginateExpandedRows: false }, props), { columns: columns, defaultColumn: defaultColumn, disableSortBy: !isSortable, stateReducer: tableStateReducer, filterTypes: filterTypes, selectSubRows: selectSubRows, data: data, getSubRows: getSubRows, initialState: __assign({ pageSize: pageSize }, props.initialState) }), useFlexLayout, useResizeColumns(ownerDocument), useFilters, useSubRowFiltering(hasAnySubRows), useGlobalFilter, useSortBy, useExpanded, usePagination, useRowSelect, useSubRowSelection, useExpanderCell(subComponent, expanderCell, isRowDisabled), useSelectionCell(isSelectable, selectionMode, isRowDisabled), useColumnOrder, useColumnDragAndDrop(enableColumnReordering), useStickyColumns);
210
+ var getTableProps = instance.getTableProps, rows = instance.rows, headerGroups = instance.headerGroups, getTableBodyProps = instance.getTableBodyProps, prepareRow = instance.prepareRow, state = instance.state, allColumns = instance.allColumns, dispatch = instance.dispatch, page = instance.page, gotoPage = instance.gotoPage, setPageSize = instance.setPageSize, flatHeaders = instance.flatHeaders, visibleColumns = instance.visibleColumns, setGlobalFilter = instance.setGlobalFilter;
176
211
  var ariaDataAttributes = Object.entries(rest).reduce(function (result, _a) {
177
212
  var key = _a[0], value = _a[1];
178
213
  if (key.startsWith('data-') || key.startsWith('aria-')) {
@@ -180,7 +215,7 @@ export var Table = function (props) {
180
215
  }
181
216
  return result;
182
217
  }, {});
183
- var areFiltersSet = allColumns.some(function (column) { return column.filterValue != null && column.filterValue !== ''; });
218
+ var areFiltersSet = allColumns.some(function (column) { return column.filterValue != null && column.filterValue !== ''; }) || !!globalFilterValue;
184
219
  var showFilterButton = function (column) {
185
220
  return (data.length !== 0 || areFiltersSet) && column.canFilter;
186
221
  };
@@ -196,7 +231,14 @@ export var Table = function (props) {
196
231
  !isDisabled &&
197
232
  selectRowOnClick &&
198
233
  !event.isDefaultPrevented()) {
199
- if (!row.isSelected && (selectionMode === 'single' || !event.ctrlKey)) {
234
+ if (selectionMode === 'multi' && event.shiftKey) {
235
+ dispatch({
236
+ type: shiftRowSelectedAction,
237
+ id: row.id,
238
+ });
239
+ }
240
+ else if (!row.isSelected &&
241
+ (selectionMode === 'single' || !event.ctrlKey)) {
200
242
  dispatch({
201
243
  type: singleRowSelectedAction,
202
244
  id: row.id,
@@ -214,6 +256,9 @@ export var Table = function (props) {
214
256
  dispatch,
215
257
  onRowClick,
216
258
  ]);
259
+ React.useEffect(function () {
260
+ setGlobalFilter(globalFilterValue);
261
+ }, [globalFilterValue, setGlobalFilter]);
217
262
  React.useEffect(function () {
218
263
  setPageSize(pageSize);
219
264
  }, [pageSize, setPageSize]);
@@ -387,7 +432,7 @@ export var Table = function (props) {
387
432
  !isLoading && data.length === 0 && !areFiltersSet && (React.createElement("div", { className: 'iui-table-empty' },
388
433
  React.createElement("div", null, emptyTableContent))),
389
434
  !isLoading &&
390
- (data.length === 0 || filteredFlatRows.length === 0) &&
435
+ (data.length === 0 || rows.length === 0) &&
391
436
  areFiltersSet && (React.createElement("div", { className: 'iui-table-empty' },
392
437
  React.createElement("div", null, emptyFilteredTableContent)))), paginatorRenderer === null || paginatorRenderer === void 0 ? void 0 :
393
438
  paginatorRenderer(paginatorRendererProps))));
@@ -8,7 +8,11 @@ import { CellProps, Row, TableInstance, TableState } from 'react-table';
8
8
  */
9
9
  export declare const TableRow: <T extends Record<string, unknown>>(props: {
10
10
  row: Row<T>;
11
- rowProps?: ((row: Row<T>) => React.ComponentPropsWithRef<'div'>) | undefined;
11
+ rowProps?: ((row: Row<T>) => Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof React.HTMLAttributes<HTMLDivElement>> & {
12
+ ref?: ((instance: HTMLDivElement | null) => void) | React.RefObject<HTMLDivElement> | null | undefined;
13
+ } & {
14
+ status?: "positive" | "warning" | "negative" | undefined;
15
+ }) | undefined;
12
16
  isLast: boolean;
13
17
  onRowInViewport: React.MutableRefObject<((rowData: T) => void) | undefined>;
14
18
  onBottomReached: React.MutableRefObject<(() => void) | undefined>;
@@ -25,7 +29,11 @@ export declare const TableRow: <T extends Record<string, unknown>>(props: {
25
29
  }) => JSX.Element;
26
30
  export declare const TableRowMemoized: <T extends Record<string, unknown>>(props: {
27
31
  row: Row<T>;
28
- rowProps?: ((row: Row<T>) => React.ComponentPropsWithRef<'div'>) | undefined;
32
+ rowProps?: ((row: Row<T>) => Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof React.HTMLAttributes<HTMLDivElement>> & {
33
+ ref?: ((instance: HTMLDivElement | null) => void) | React.RefObject<HTMLDivElement> | null | undefined;
34
+ } & {
35
+ status?: "positive" | "warning" | "negative" | undefined;
36
+ }) | undefined;
29
37
  isLast: boolean;
30
38
  onRowInViewport: React.MutableRefObject<((rowData: T) => void) | undefined>;
31
39
  onBottomReached: React.MutableRefObject<(() => void) | undefined>;
@@ -9,6 +9,17 @@ var __assign = (this && this.__assign) || function () {
9
9
  };
10
10
  return __assign.apply(this, arguments);
11
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
+ };
12
23
  /*---------------------------------------------------------------------------------------------
13
24
  * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
14
25
  * See LICENSE.md in the project root for license terms and full copyright notice.
@@ -24,6 +35,8 @@ import { TableCell } from './TableCell';
24
35
  * When adding new features check whether it changes state that affects row. If it does then add equality check to `React.memo`.
25
36
  */
26
37
  export var TableRow = function (props) {
38
+ var _a;
39
+ var _b;
27
40
  var row = props.row, rowProps = props.rowProps, isLast = props.isLast, onRowInViewport = props.onRowInViewport, onBottomReached = props.onBottomReached, intersectionMargin = props.intersectionMargin, onClick = props.onClick, subComponent = props.subComponent, isDisabled = props.isDisabled, tableHasSubRows = props.tableHasSubRows, tableInstance = props.tableInstance, expanderCell = props.expanderCell, bodyRef = props.bodyRef, tableRowRef = props.tableRowRef;
28
41
  var onIntersect = React.useCallback(function () {
29
42
  var _a, _b;
@@ -44,13 +57,16 @@ export var TableRow = function (props) {
44
57
  rootMargin: "".concat(intersectionMargin, "px"),
45
58
  root: intersectionRoot,
46
59
  });
47
- var userRowProps = rowProps === null || rowProps === void 0 ? void 0 : rowProps(row);
48
- var mergedProps = __assign(__assign(__assign({}, row.getRowProps({ style: { flex: "0 0 auto", minWidth: '100%' } })), userRowProps), {
49
- className: cx('iui-row', {
50
- 'iui-selected': row.isSelected,
51
- 'iui-row-expanded': row.isExpanded && subComponent,
52
- 'iui-disabled': isDisabled,
53
- }, userRowProps === null || userRowProps === void 0 ? void 0 : userRowProps.className),
60
+ var userRowProps = (_b = rowProps === null || rowProps === void 0 ? void 0 : rowProps(row)) !== null && _b !== void 0 ? _b : {};
61
+ var status = userRowProps.status, restUserRowProps = __rest(userRowProps, ["status"]);
62
+ var mergedProps = __assign(__assign(__assign({}, row.getRowProps({ style: { flex: "0 0 auto", minWidth: '100%' } })), restUserRowProps), {
63
+ className: cx('iui-row', (_a = {
64
+ 'iui-selected': row.isSelected,
65
+ 'iui-row-expanded': row.isExpanded && subComponent,
66
+ 'iui-disabled': isDisabled
67
+ },
68
+ _a["iui-".concat(status)] = !!status,
69
+ _a), userRowProps === null || userRowProps === void 0 ? void 0 : userRowProps.className),
54
70
  });
55
71
  var refs = useMergedRefs(intersectionRef, mergedProps.ref, tableRowRef);
56
72
  return (React.createElement(React.Fragment, null,
@@ -1,4 +1,4 @@
1
1
  export { onExpandHandler } from './expandHandler';
2
2
  export { onFilterHandler } from './filterHandler';
3
- export { onSelectHandler, onSingleSelectHandler } from './selectHandler';
3
+ export { onSelectHandler, onSingleSelectHandler, onShiftSelectHandler, } from './selectHandler';
4
4
  export { onTableResizeStart, onTableResizeEnd } from './resizeHandler';