@itwin/itwinui-react 1.34.1 → 1.36.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 (136) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/cjs/core/ButtonGroup/ButtonGroup.js +1 -0
  3. package/cjs/core/Carousel/Carousel.d.ts +68 -0
  4. package/cjs/core/Carousel/Carousel.js +130 -0
  5. package/cjs/core/Carousel/CarouselContext.d.ts +37 -0
  6. package/cjs/core/Carousel/CarouselContext.js +12 -0
  7. package/cjs/core/Carousel/CarouselDot.d.ts +13 -0
  8. package/cjs/core/Carousel/CarouselDot.js +46 -0
  9. package/cjs/core/Carousel/CarouselDotsList.d.ts +32 -0
  10. package/cjs/core/Carousel/CarouselDotsList.js +132 -0
  11. package/cjs/core/Carousel/CarouselNavigation.d.ts +15 -0
  12. package/cjs/core/Carousel/CarouselNavigation.js +88 -0
  13. package/cjs/core/Carousel/CarouselSlide.d.ts +14 -0
  14. package/cjs/core/Carousel/CarouselSlide.js +63 -0
  15. package/cjs/core/Carousel/CarouselSlider.d.ts +5 -0
  16. package/cjs/core/Carousel/CarouselSlider.js +94 -0
  17. package/cjs/core/Carousel/index.d.ts +4 -0
  18. package/cjs/core/Carousel/index.js +10 -0
  19. package/cjs/core/ColorPicker/ColorSwatch.d.ts +1 -1
  20. package/cjs/core/DatePicker/DatePicker.d.ts +5 -0
  21. package/cjs/core/DatePicker/DatePicker.js +38 -13
  22. package/cjs/core/Menu/Menu.js +8 -3
  23. package/cjs/core/Modal/Modal.d.ts +5 -0
  24. package/cjs/core/Modal/Modal.js +11 -9
  25. package/cjs/core/Modal/ModalContent.d.ts +14 -0
  26. package/cjs/core/Modal/ModalContent.js +46 -0
  27. package/cjs/core/Modal/index.d.ts +2 -0
  28. package/cjs/core/Modal/index.js +3 -1
  29. package/cjs/core/Table/Table.d.ts +1 -0
  30. package/cjs/core/Table/Table.js +34 -20
  31. package/cjs/core/Table/TableCell.js +3 -3
  32. package/cjs/core/Table/TableRowMemoized.js +12 -7
  33. package/cjs/core/Table/actionHandlers/index.d.ts +2 -1
  34. package/cjs/core/Table/actionHandlers/index.js +5 -1
  35. package/cjs/core/Table/cells/DefaultCell.d.ts +1 -1
  36. package/cjs/core/Table/cells/DefaultCell.js +5 -2
  37. package/cjs/core/Table/columns/actionColumn.d.ts +35 -0
  38. package/cjs/core/Table/columns/actionColumn.js +91 -0
  39. package/cjs/core/Table/columns/expanderColumn.d.ts +47 -0
  40. package/cjs/core/Table/columns/expanderColumn.js +81 -0
  41. package/cjs/core/Table/columns/index.d.ts +3 -0
  42. package/cjs/core/Table/columns/index.js +15 -0
  43. package/cjs/core/Table/columns/selectionColumn.d.ts +35 -0
  44. package/cjs/core/Table/columns/selectionColumn.js +67 -0
  45. package/cjs/core/Table/filters/DateRangeFilter/DateRangeFilter.js +18 -2
  46. package/cjs/core/Table/hooks/index.d.ts +2 -2
  47. package/cjs/core/Table/hooks/index.js +1 -3
  48. package/cjs/core/Table/hooks/useExpanderCell.d.ts +0 -1
  49. package/cjs/core/Table/hooks/useExpanderCell.js +25 -39
  50. package/cjs/core/Table/hooks/useResizeColumns.js +8 -2
  51. package/cjs/core/Table/hooks/useSelectionCell.d.ts +0 -1
  52. package/cjs/core/Table/hooks/useSelectionCell.js +6 -52
  53. package/cjs/core/Table/index.d.ts +1 -0
  54. package/cjs/core/Table/index.js +5 -1
  55. package/cjs/core/Table/utils.js +1 -1
  56. package/cjs/core/Toast/Toast.js +1 -1
  57. package/cjs/core/Typography/Anchor/Anchor.d.ts +1 -0
  58. package/cjs/core/Typography/Anchor/Anchor.js +1 -0
  59. package/cjs/core/index.d.ts +5 -3
  60. package/cjs/core/index.js +9 -2
  61. package/cjs/core/utils/components/Popover.js +13 -1
  62. package/cjs/core/utils/hooks/index.d.ts +1 -0
  63. package/cjs/core/utils/hooks/index.js +1 -0
  64. package/cjs/core/utils/hooks/useMediaQuery.d.ts +2 -0
  65. package/cjs/core/utils/hooks/useMediaQuery.js +46 -0
  66. package/cjs/core/utils/hooks/useTheme.d.ts +5 -0
  67. package/cjs/core/utils/hooks/useTheme.js +20 -14
  68. package/cjs/types/react-table-config.d.ts +18 -0
  69. package/esm/core/ButtonGroup/ButtonGroup.js +1 -0
  70. package/esm/core/Carousel/Carousel.d.ts +68 -0
  71. package/esm/core/Carousel/Carousel.js +124 -0
  72. package/esm/core/Carousel/CarouselContext.d.ts +37 -0
  73. package/esm/core/Carousel/CarouselContext.js +6 -0
  74. package/esm/core/Carousel/CarouselDot.d.ts +13 -0
  75. package/esm/core/Carousel/CarouselDot.js +40 -0
  76. package/esm/core/Carousel/CarouselDotsList.d.ts +32 -0
  77. package/esm/core/Carousel/CarouselDotsList.js +126 -0
  78. package/esm/core/Carousel/CarouselNavigation.d.ts +15 -0
  79. package/esm/core/Carousel/CarouselNavigation.js +82 -0
  80. package/esm/core/Carousel/CarouselSlide.d.ts +14 -0
  81. package/esm/core/Carousel/CarouselSlide.js +57 -0
  82. package/esm/core/Carousel/CarouselSlider.d.ts +5 -0
  83. package/esm/core/Carousel/CarouselSlider.js +88 -0
  84. package/esm/core/Carousel/index.d.ts +4 -0
  85. package/esm/core/Carousel/index.js +6 -0
  86. package/esm/core/ColorPicker/ColorSwatch.d.ts +1 -1
  87. package/esm/core/DatePicker/DatePicker.d.ts +5 -0
  88. package/esm/core/DatePicker/DatePicker.js +38 -13
  89. package/esm/core/Menu/Menu.js +8 -3
  90. package/esm/core/Modal/Modal.d.ts +5 -0
  91. package/esm/core/Modal/Modal.js +11 -9
  92. package/esm/core/Modal/ModalContent.d.ts +14 -0
  93. package/esm/core/Modal/ModalContent.js +39 -0
  94. package/esm/core/Modal/index.d.ts +2 -0
  95. package/esm/core/Modal/index.js +1 -0
  96. package/esm/core/Table/Table.d.ts +1 -0
  97. package/esm/core/Table/Table.js +30 -16
  98. package/esm/core/Table/TableCell.js +2 -2
  99. package/esm/core/Table/TableRowMemoized.js +12 -7
  100. package/esm/core/Table/actionHandlers/index.d.ts +2 -1
  101. package/esm/core/Table/actionHandlers/index.js +2 -1
  102. package/esm/core/Table/cells/DefaultCell.d.ts +1 -1
  103. package/esm/core/Table/cells/DefaultCell.js +5 -2
  104. package/esm/core/Table/columns/actionColumn.d.ts +35 -0
  105. package/esm/core/Table/columns/actionColumn.js +84 -0
  106. package/esm/core/Table/columns/expanderColumn.d.ts +47 -0
  107. package/esm/core/Table/columns/expanderColumn.js +74 -0
  108. package/esm/core/Table/columns/index.d.ts +3 -0
  109. package/esm/core/Table/columns/index.js +7 -0
  110. package/esm/core/Table/columns/selectionColumn.d.ts +35 -0
  111. package/esm/core/Table/columns/selectionColumn.js +60 -0
  112. package/esm/core/Table/filters/DateRangeFilter/DateRangeFilter.js +18 -2
  113. package/esm/core/Table/hooks/index.d.ts +2 -2
  114. package/esm/core/Table/hooks/index.js +2 -2
  115. package/esm/core/Table/hooks/useExpanderCell.d.ts +0 -1
  116. package/esm/core/Table/hooks/useExpanderCell.js +24 -35
  117. package/esm/core/Table/hooks/useResizeColumns.js +8 -2
  118. package/esm/core/Table/hooks/useSelectionCell.d.ts +0 -1
  119. package/esm/core/Table/hooks/useSelectionCell.js +5 -48
  120. package/esm/core/Table/index.d.ts +1 -0
  121. package/esm/core/Table/index.js +1 -0
  122. package/esm/core/Table/utils.js +1 -1
  123. package/esm/core/Toast/Toast.js +1 -1
  124. package/esm/core/Typography/Anchor/Anchor.d.ts +1 -0
  125. package/esm/core/Typography/Anchor/Anchor.js +1 -0
  126. package/esm/core/index.d.ts +5 -3
  127. package/esm/core/index.js +3 -2
  128. package/esm/core/utils/components/Popover.js +13 -1
  129. package/esm/core/utils/hooks/index.d.ts +1 -0
  130. package/esm/core/utils/hooks/index.js +1 -0
  131. package/esm/core/utils/hooks/useMediaQuery.d.ts +2 -0
  132. package/esm/core/utils/hooks/useMediaQuery.js +39 -0
  133. package/esm/core/utils/hooks/useTheme.d.ts +5 -0
  134. package/esm/core/utils/hooks/useTheme.js +20 -14
  135. package/esm/types/react-table-config.d.ts +18 -0
  136. package/package.json +3 -2
@@ -2,8 +2,8 @@
2
2
  * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
3
  * See LICENSE.md in the project root for license terms and full copyright notice.
4
4
  *--------------------------------------------------------------------------------------------*/
5
- export { EXPANDER_CELL_ID, useExpanderCell } from './useExpanderCell';
6
- export { SELECTION_CELL_ID, useSelectionCell } from './useSelectionCell';
5
+ export { useExpanderCell } from './useExpanderCell';
6
+ export { useSelectionCell } from './useSelectionCell';
7
7
  export { useSubRowFiltering } from './useSubRowFiltering';
8
8
  export { useSubRowSelection } from './useSubRowSelection';
9
9
  export { useResizeColumns } from './useResizeColumns';
@@ -1,4 +1,3 @@
1
1
  import React from 'react';
2
2
  import { CellProps, Hooks, Row } from 'react-table';
3
- export declare const EXPANDER_CELL_ID = "iui-table-expander";
4
3
  export declare const useExpanderCell: <T extends Record<string, unknown>>(subComponent?: ((row: Row<T>) => React.ReactNode) | undefined, expanderCell?: ((cellProps: CellProps<T, any>) => React.ReactNode) | undefined, isRowDisabled?: ((rowData: T) => boolean) | undefined) => (hooks: Hooks<T>) => void;
@@ -1,3 +1,14 @@
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
+ };
1
12
  var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
2
13
  if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
3
14
  if (ar || !(i in from)) {
@@ -7,44 +18,22 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
7
18
  }
8
19
  return to.concat(ar || Array.prototype.slice.call(from));
9
20
  };
10
- /*---------------------------------------------------------------------------------------------
11
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
12
- * See LICENSE.md in the project root for license terms and full copyright notice.
13
- *--------------------------------------------------------------------------------------------*/
14
- import SvgChevronRight from '@itwin/itwinui-icons-react/cjs/icons/ChevronRight';
15
- import React from 'react';
16
- import { IconButton } from '../../Buttons';
17
- export var EXPANDER_CELL_ID = 'iui-table-expander';
21
+ import { ExpanderColumn, EXPANDER_CELL_ID } from '../columns';
18
22
  export var useExpanderCell = function (subComponent, expanderCell, isRowDisabled) { return function (hooks) {
19
23
  if (!subComponent) {
20
24
  return;
21
25
  }
22
- hooks.allColumns.push(function (columns) { return __spreadArray([
23
- {
24
- id: EXPANDER_CELL_ID,
25
- disableResizing: true,
26
- disableGroupBy: true,
27
- minWidth: 48,
28
- width: 48,
29
- maxWidth: 48,
30
- columnClassName: 'iui-slot',
31
- cellClassName: 'iui-slot',
32
- disableReordering: true,
33
- Cell: function (props) {
34
- var row = props.row;
35
- if (!subComponent(row)) {
36
- return null;
37
- }
38
- else if (expanderCell) {
39
- return expanderCell(props);
40
- }
41
- else {
42
- return (React.createElement(IconButton, { className: 'iui-row-expander', styleType: 'borderless', size: 'small', onClick: function (e) {
43
- e.stopPropagation();
44
- row.toggleRowExpanded();
45
- }, disabled: isRowDisabled === null || isRowDisabled === void 0 ? void 0 : isRowDisabled(props.row.original) }, React.createElement(SvgChevronRight, null)));
46
- }
47
- },
26
+ hooks.allColumns.push(function (columns) {
27
+ var hasExpanderColumn = columns.find(function (c) { return c.id === EXPANDER_CELL_ID; });
28
+ if (hasExpanderColumn) {
29
+ return columns;
48
30
  }
49
- ], columns, true); });
31
+ var expanderColumn = ExpanderColumn({
32
+ subComponent: subComponent,
33
+ isDisabled: isRowDisabled,
34
+ });
35
+ return __spreadArray([
36
+ __assign(__assign({}, expanderColumn), { Cell: expanderCell !== null && expanderCell !== void 0 ? expanderCell : expanderColumn.Cell })
37
+ ], columns, true);
38
+ });
50
39
  }; };
@@ -225,7 +225,10 @@ var useInstanceBeforeDimensions = function (instance) {
225
225
  };
226
226
  var getPreviousResizableHeader = function (headerColumn, instance) {
227
227
  var _a;
228
- var headersList = ((_a = headerColumn.parent) === null || _a === void 0 ? void 0 : _a.columns) || instance.flatHeaders;
228
+ var headersList = (((_a = headerColumn.parent) === null || _a === void 0 ? void 0 : _a.columns) || instance.flatHeaders).filter(function (_a) {
229
+ var isVisible = _a.isVisible;
230
+ return isVisible;
231
+ });
229
232
  var headerIndex = headersList.findIndex(function (h) { return h.id === headerColumn.id; });
230
233
  return __spreadArray([], headersList, true).slice(0, headerIndex)
231
234
  .reverse()
@@ -233,7 +236,10 @@ var getPreviousResizableHeader = function (headerColumn, instance) {
233
236
  };
234
237
  var getNextResizableHeader = function (headerColumn, instance) {
235
238
  var _a;
236
- var headersList = ((_a = headerColumn.parent) === null || _a === void 0 ? void 0 : _a.columns) || instance.flatHeaders;
239
+ var headersList = (((_a = headerColumn.parent) === null || _a === void 0 ? void 0 : _a.columns) || instance.flatHeaders).filter(function (_a) {
240
+ var isVisible = _a.isVisible;
241
+ return isVisible;
242
+ });
237
243
  var headerIndex = headersList.findIndex(function (h) { return h.id === headerColumn.id; });
238
244
  return __spreadArray([], headersList, true).slice(headerIndex + 1)
239
245
  .find(function (h) { return !h.disableResizing; });
@@ -1,3 +1,2 @@
1
1
  import { Hooks } from 'react-table';
2
- export declare const SELECTION_CELL_ID = "iui-table-checkbox-selector";
3
2
  export declare const useSelectionCell: <T extends Record<string, unknown>>(isSelectable: boolean, isRowDisabled?: ((rowData: T) => boolean) | undefined) => (hooks: Hooks<T>) => void;
@@ -1,14 +1,3 @@
1
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
11
- };
12
1
  var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
13
2
  if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
14
3
  if (ar || !(i in from)) {
@@ -18,46 +7,14 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
18
7
  }
19
8
  return to.concat(ar || Array.prototype.slice.call(from));
20
9
  };
21
- /*---------------------------------------------------------------------------------------------
22
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
23
- * See LICENSE.md in the project root for license terms and full copyright notice.
24
- *--------------------------------------------------------------------------------------------*/
25
- import React from 'react';
26
- import { Checkbox } from '../../Checkbox';
27
- export var SELECTION_CELL_ID = 'iui-table-checkbox-selector';
10
+ import { SelectionColumn, SELECTION_CELL_ID } from '../columns';
28
11
  export var useSelectionCell = function (isSelectable, isRowDisabled) { return function (hooks) {
29
12
  if (!isSelectable) {
30
13
  return;
31
14
  }
32
- hooks.allColumns.push(function (columns) { return __spreadArray([
33
- {
34
- id: SELECTION_CELL_ID,
35
- disableResizing: true,
36
- disableGroupBy: true,
37
- minWidth: 48,
38
- width: 48,
39
- maxWidth: 48,
40
- columnClassName: 'iui-slot',
41
- cellClassName: 'iui-slot',
42
- disableReordering: true,
43
- Header: function (_a) {
44
- var getToggleAllRowsSelectedProps = _a.getToggleAllRowsSelectedProps, rows = _a.rows, initialRows = _a.initialRows, state = _a.state;
45
- var disabled = rows.every(function (row) { return isRowDisabled === null || isRowDisabled === void 0 ? void 0 : isRowDisabled(row.original); });
46
- var checked = initialRows.every(function (row) {
47
- return state.selectedRowIds[row.id] || (isRowDisabled === null || isRowDisabled === void 0 ? void 0 : isRowDisabled(row.original));
48
- });
49
- return (React.createElement(Checkbox, __assign({}, getToggleAllRowsSelectedProps(), { checked: checked && !disabled, indeterminate: !checked && Object.keys(state.selectedRowIds).length > 0, disabled: disabled })));
50
- },
51
- Cell: function (_a) {
52
- var row = _a.row;
53
- return (React.createElement(Checkbox, __assign({}, row.getToggleRowSelectedProps(), { disabled: isRowDisabled === null || isRowDisabled === void 0 ? void 0 : isRowDisabled(row.original), onClick: function (e) { return e.stopPropagation(); } })));
54
- },
55
- }
56
- ], columns, true); });
57
- hooks.useInstanceBeforeDimensions.push(function (_a) {
58
- var headerGroups = _a.headerGroups;
59
- // Fix the parent group of the selection button to not be resizable
60
- var selectionGroupHeader = headerGroups[0].headers[0];
61
- selectionGroupHeader.canResize = false;
15
+ hooks.allColumns.push(function (columns) {
16
+ return columns.find(function (c) { return c.id === SELECTION_CELL_ID; })
17
+ ? columns
18
+ : __spreadArray([SelectionColumn({ isDisabled: isRowDisabled })], columns, true);
62
19
  });
63
20
  }; };
@@ -6,5 +6,6 @@ export { DefaultCell, EditableCell } from './cells';
6
6
  export type { DefaultCellProps, EditableCellProps } from './cells';
7
7
  export { TablePaginator } from './TablePaginator';
8
8
  export type { TablePaginatorProps } from './TablePaginator';
9
+ export { ActionColumn, ExpanderColumn, SelectionColumn } from './columns';
9
10
  declare const _default: "./Table";
10
11
  export default _default;
@@ -6,4 +6,5 @@ export { Table } from './Table';
6
6
  export { BaseFilter, FilterButtonBar, tableFilters } from './filters';
7
7
  export { DefaultCell, EditableCell } from './cells';
8
8
  export { TablePaginator } from './TablePaginator';
9
+ export { ActionColumn, ExpanderColumn, SelectionColumn } from './columns';
9
10
  export default './Table';
@@ -6,7 +6,7 @@ export var getCellStyle = function (column, isTableResizing) {
6
6
  style.width = width;
7
7
  // This allows flexbox to handle the width of the column on table resize
8
8
  if (isTableResizing && column.canResize) {
9
- style.flex = Number(column.width) + " 1 " + width;
9
+ style.flex = Number(column.width) + " " + Number(column.width) + " " + width;
10
10
  }
11
11
  else {
12
12
  style.flex = "0 0 " + width;
@@ -136,7 +136,7 @@ export var ToastPresentation = function (props) {
136
136
  return (React.createElement("div", __assign({ className: cx("iui-toast iui-" + category, className) }, rest),
137
137
  React.createElement("div", { className: 'iui-status-area' }, React.createElement(StatusIcon, { className: 'iui-icon' })),
138
138
  React.createElement("div", { className: 'iui-message' }, content),
139
- link && (React.createElement("a", { className: 'iui-anchor', onClick: link.onClick }, link.title)),
139
+ link && (React.createElement("a", { className: 'iui-toast-anchor', onClick: link.onClick }, link.title)),
140
140
  (type === 'persisting' || hasCloseButton) && (React.createElement(IconButton, { size: 'small', styleType: 'borderless', onClick: onClose, "aria-label": 'Close' },
141
141
  React.createElement(SvgCloseSmall, null)))));
142
142
  };
@@ -1,3 +1,4 @@
1
1
  import React from 'react';
2
+ import '@itwin/itwinui-css/css/anchor.css';
2
3
  export declare const Anchor: React.ForwardRefExoticComponent<Pick<React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>, "key" | keyof React.AnchorHTMLAttributes<HTMLAnchorElement>> & React.RefAttributes<HTMLAnchorElement>>;
3
4
  export default Anchor;
@@ -27,6 +27,7 @@ var __rest = (this && this.__rest) || function (s, e) {
27
27
  import React from 'react';
28
28
  import cx from 'classnames';
29
29
  import { useTheme } from '../../utils';
30
+ import '@itwin/itwinui-css/css/anchor.css';
30
31
  export var Anchor = React.forwardRef(function (_a, ref) {
31
32
  var className = _a.className, rest = __rest(_a, ["className"]);
32
33
  useTheme();
@@ -8,6 +8,8 @@ export { Button, DropdownButton, IconButton, IdeasButton, SplitButton, } from '.
8
8
  export type { ButtonProps, DropdownButtonProps, IconButtonProps, IdeasButtonProps, SplitButtonProps, } from './Buttons';
9
9
  export { ButtonGroup } from './ButtonGroup';
10
10
  export type { ButtonGroupProps } from './ButtonGroup';
11
+ export { Carousel } from './Carousel';
12
+ export type { CarouselProps } from './Carousel';
11
13
  export { Checkbox } from './Checkbox';
12
14
  export type { CheckboxProps } from './Checkbox';
13
15
  export { ColorPicker, ColorSwatch, ColorBuilder, ColorInputPanel, ColorPalette, } from './ColorPicker';
@@ -48,8 +50,8 @@ export { LabeledTextarea } from './LabeledTextarea';
48
50
  export type { LabeledTextareaProps } from './LabeledTextarea';
49
51
  export { Menu, MenuItem, MenuDivider, MenuExtraContent } from './Menu';
50
52
  export type { MenuProps, MenuItemProps, MenuDividerProps, MenuExtraContentProps, } from './Menu';
51
- export { Modal, ModalButtonBar } from './Modal';
52
- export type { ModalProps, ModalButtonBarProps } from './Modal';
53
+ export { Modal, ModalButtonBar, ModalContent } from './Modal';
54
+ export type { ModalProps, ModalButtonBarProps, ModalContentProps, } from './Modal';
53
55
  export { ProgressLinear, ProgressRadial } from './ProgressIndicators';
54
56
  export type { ProgressLinearProps, ProgressRadialProps, } from './ProgressIndicators';
55
57
  export { Radio } from './Radio';
@@ -64,7 +66,7 @@ export { Slider } from './Slider';
64
66
  export type { SliderProps } from './Slider';
65
67
  export { StatusMessage } from './StatusMessage';
66
68
  export type { StatusMessageProps } from './StatusMessage';
67
- export { Table, tableFilters, FilterButtonBar, DefaultCell, EditableCell, TablePaginator, } from './Table';
69
+ export { Table, tableFilters, FilterButtonBar, DefaultCell, EditableCell, TablePaginator, ActionColumn, ExpanderColumn, SelectionColumn, } from './Table';
68
70
  export type { TableProps, TableFilterProps, TableFilterValue, DateRangeFilterOptions, FilterButtonBarProps, DefaultCellProps, EditableCellProps, TablePaginatorProps, TablePaginatorRendererProps, } from './Table';
69
71
  export { Tag, TagContainer } from './Tag';
70
72
  export type { TagProps, TagContainerProps } from './Tag';
package/esm/core/index.js CHANGED
@@ -7,6 +7,7 @@ export { Badge } from './Badge';
7
7
  export { Breadcrumbs } from './Breadcrumbs';
8
8
  export { Button, DropdownButton, IconButton, IdeasButton, SplitButton, } from './Buttons';
9
9
  export { ButtonGroup } from './ButtonGroup';
10
+ export { Carousel } from './Carousel';
10
11
  export { Checkbox } from './Checkbox';
11
12
  export { ColorPicker, ColorSwatch, ColorBuilder, ColorInputPanel, ColorPalette, } from './ColorPicker';
12
13
  export { ComboBox } from './ComboBox';
@@ -27,7 +28,7 @@ export { InputGroup } from './InputGroup';
27
28
  export { LabeledSelect } from './LabeledSelect';
28
29
  export { LabeledTextarea } from './LabeledTextarea';
29
30
  export { Menu, MenuItem, MenuDivider, MenuExtraContent } from './Menu';
30
- export { Modal, ModalButtonBar } from './Modal';
31
+ export { Modal, ModalButtonBar, ModalContent } from './Modal';
31
32
  export { ProgressLinear, ProgressRadial } from './ProgressIndicators';
32
33
  export { Radio } from './Radio';
33
34
  export { RadioTile, RadioTileGroup } from './RadioTiles';
@@ -35,7 +36,7 @@ export { Select } from './Select';
35
36
  export { SideNavigation, SidenavButton, SidenavSubmenu, SidenavSubmenuHeader, } from './SideNavigation';
36
37
  export { Slider } from './Slider';
37
38
  export { StatusMessage } from './StatusMessage';
38
- export { Table, tableFilters, FilterButtonBar, DefaultCell, EditableCell, TablePaginator, } from './Table';
39
+ export { Table, tableFilters, FilterButtonBar, DefaultCell, EditableCell, TablePaginator, ActionColumn, ExpanderColumn, SelectionColumn, } from './Table';
39
40
  export { Tag, TagContainer } from './Tag';
40
41
  export { Textarea } from './Textarea';
41
42
  export { Tile } from './Tile';
@@ -72,7 +72,19 @@ export var Popover = React.forwardRef(function (props, ref) {
72
72
  };
73
73
  }
74
74
  else {
75
- computedProps.content = mounted ? props.content : '';
75
+ // Fixing issue where elements below Popover gets click events.
76
+ // Tippy uses react Portal, which propagates events by react tree, not dom tree.
77
+ // Read more: https://reactjs.org/docs/portals.html#event-bubbling-through-portals
78
+ var clonedContent = React.isValidElement(props.content)
79
+ ? React.cloneElement(props.content, {
80
+ onClick: function (e) {
81
+ var _a, _b;
82
+ e.stopPropagation();
83
+ (_b = (_a = props.content.props).onClick) === null || _b === void 0 ? void 0 : _b.call(_a, e);
84
+ },
85
+ })
86
+ : props.content;
87
+ computedProps.content = mounted ? clonedContent : '';
76
88
  }
77
89
  return React.createElement(Tippy, __assign({}, computedProps, { ref: refs }));
78
90
  });
@@ -5,3 +5,4 @@ export * from './useResizeObserver';
5
5
  export * from './useContainerWidth';
6
6
  export * from './useTheme';
7
7
  export * from './useIntersection';
8
+ export * from './useMediaQuery';
@@ -9,3 +9,4 @@ export * from './useResizeObserver';
9
9
  export * from './useContainerWidth';
10
10
  export * from './useTheme';
11
11
  export * from './useIntersection';
12
+ export * from './useMediaQuery';
@@ -0,0 +1,2 @@
1
+ export declare const useMediaQuery: (queryString: string) => boolean;
2
+ export default useMediaQuery;
@@ -0,0 +1,39 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ import React from 'react';
6
+ import { getWindow } from '../functions';
7
+ export var useMediaQuery = function (queryString) {
8
+ var _a = React.useState(), matches = _a[0], setMatches = _a[1];
9
+ React.useLayoutEffect(function () {
10
+ var _a, _b, _c;
11
+ var mediaQueryList = (_b = (_a = getWindow()) === null || _a === void 0 ? void 0 : _a.matchMedia) === null || _b === void 0 ? void 0 : _b.call(_a, queryString);
12
+ var handleChange = function (_a) {
13
+ var matches = _a.matches;
14
+ return setMatches(matches);
15
+ };
16
+ if (mediaQueryList != undefined) {
17
+ setMatches(mediaQueryList.matches);
18
+ try {
19
+ mediaQueryList.addEventListener('change', handleChange);
20
+ }
21
+ catch (_d) {
22
+ // Safari 13 fallback
23
+ (_c = mediaQueryList.addListener) === null || _c === void 0 ? void 0 : _c.call(mediaQueryList, handleChange);
24
+ }
25
+ }
26
+ return function () {
27
+ var _a;
28
+ try {
29
+ mediaQueryList === null || mediaQueryList === void 0 ? void 0 : mediaQueryList.removeEventListener('change', handleChange);
30
+ }
31
+ catch (_b) {
32
+ // Safari 13 fallback
33
+ (_a = mediaQueryList === null || mediaQueryList === void 0 ? void 0 : mediaQueryList.removeListener) === null || _a === void 0 ? void 0 : _a.call(mediaQueryList, handleChange);
34
+ }
35
+ };
36
+ }, [queryString]);
37
+ return !!matches;
38
+ };
39
+ export default useMediaQuery;
@@ -6,6 +6,11 @@ export declare type ThemeOptions = {
6
6
  * @default document
7
7
  */
8
8
  ownerDocument?: Document;
9
+ /**
10
+ * Whether to apply high-contrast versions of light and dark themes.
11
+ * Will default to user preference if browser supports it.
12
+ */
13
+ highContrast?: boolean;
9
14
  };
10
15
  export declare type ThemeType = 'light' | 'dark' | 'os';
11
16
  /**
@@ -5,6 +5,7 @@
5
5
  import React from 'react';
6
6
  import '@itwin/itwinui-css/css/global.css';
7
7
  import { getDocument, getWindow } from '../functions/dom';
8
+ import { useMediaQuery } from './useMediaQuery';
8
9
  /**
9
10
  * Hook that applies styling and theme to all components.
10
11
  * Defaults to light theme if none provided or set elsewhere.
@@ -14,6 +15,8 @@ import { getDocument, getWindow } from '../functions/dom';
14
15
  export var useTheme = function (theme, themeOptions) {
15
16
  var _a;
16
17
  var ownerDocument = (_a = themeOptions === null || themeOptions === void 0 ? void 0 : themeOptions.ownerDocument) !== null && _a !== void 0 ? _a : getDocument();
18
+ var prefersHighContrast = useMediaQuery('(prefers-contrast: more)');
19
+ var highContrast = React.useMemo(function () { var _a; return !!((_a = themeOptions === null || themeOptions === void 0 ? void 0 : themeOptions.highContrast) !== null && _a !== void 0 ? _a : prefersHighContrast); }, [prefersHighContrast, themeOptions === null || themeOptions === void 0 ? void 0 : themeOptions.highContrast]);
17
20
  React.useLayoutEffect(function () {
18
21
  if (!(ownerDocument === null || ownerDocument === void 0 ? void 0 : ownerDocument.body.classList.contains('iui-body'))) {
19
22
  ownerDocument === null || ownerDocument === void 0 ? void 0 : ownerDocument.body.classList.add('iui-body');
@@ -28,20 +31,20 @@ export var useTheme = function (theme, themeOptions) {
28
31
  var addOSTheme = function (_a) {
29
32
  var isDark = _a.matches;
30
33
  if (isDark) {
31
- addDarkTheme(ownerDocument);
34
+ applyTheme('dark', { ownerDocument: ownerDocument, highContrast: highContrast });
32
35
  }
33
36
  else {
34
- addLightTheme(ownerDocument);
37
+ applyTheme('light', { ownerDocument: ownerDocument, highContrast: highContrast });
35
38
  }
36
39
  };
37
40
  switch (theme) {
38
41
  case 'light':
39
42
  (_c = prefersDarkMediaQuery === null || prefersDarkMediaQuery === void 0 ? void 0 : prefersDarkMediaQuery.removeEventListener) === null || _c === void 0 ? void 0 : _c.call(prefersDarkMediaQuery, 'change', addOSTheme);
40
- addLightTheme(ownerDocument);
43
+ applyTheme('light', { ownerDocument: ownerDocument, highContrast: highContrast });
41
44
  break;
42
45
  case 'dark':
43
46
  (_d = prefersDarkMediaQuery === null || prefersDarkMediaQuery === void 0 ? void 0 : prefersDarkMediaQuery.removeEventListener) === null || _d === void 0 ? void 0 : _d.call(prefersDarkMediaQuery, 'change', addOSTheme);
44
- addDarkTheme(ownerDocument);
47
+ applyTheme('dark', { ownerDocument: ownerDocument, highContrast: highContrast });
45
48
  break;
46
49
  case 'os':
47
50
  if (prefersDarkMediaQuery != undefined) {
@@ -49,25 +52,28 @@ export var useTheme = function (theme, themeOptions) {
49
52
  (_e = prefersDarkMediaQuery.addEventListener) === null || _e === void 0 ? void 0 : _e.call(prefersDarkMediaQuery, 'change', addOSTheme);
50
53
  }
51
54
  else {
52
- addLightTheme(ownerDocument);
55
+ applyTheme('light', { ownerDocument: ownerDocument, highContrast: highContrast });
53
56
  }
54
57
  break;
55
58
  default:
56
59
  if (ownerDocument.documentElement.className.indexOf('iui-theme') === -1) {
57
- addLightTheme(ownerDocument);
60
+ applyTheme('light', { ownerDocument: ownerDocument, highContrast: highContrast });
58
61
  }
59
62
  }
60
63
  return function () {
61
64
  var _a;
62
65
  (_a = prefersDarkMediaQuery === null || prefersDarkMediaQuery === void 0 ? void 0 : prefersDarkMediaQuery.removeEventListener) === null || _a === void 0 ? void 0 : _a.call(prefersDarkMediaQuery, 'change', addOSTheme);
63
66
  };
64
- }, [ownerDocument, theme]);
67
+ }, [highContrast, ownerDocument, theme]);
65
68
  };
66
- var addLightTheme = function (ownerDocument) {
67
- ownerDocument.documentElement.classList.add('iui-theme-light');
68
- ownerDocument.documentElement.classList.remove('iui-theme-dark');
69
- };
70
- var addDarkTheme = function (ownerDocument) {
71
- ownerDocument.documentElement.classList.add('iui-theme-dark');
72
- ownerDocument.documentElement.classList.remove('iui-theme-light');
69
+ var applyTheme = function (theme, _a) {
70
+ var ownerDocument = _a.ownerDocument, highContrast = _a.highContrast;
71
+ var classList = ownerDocument.documentElement.classList;
72
+ var currentTheme = Array.from(classList).find(function (cls) {
73
+ return cls.startsWith('iui-theme');
74
+ });
75
+ if (currentTheme) {
76
+ classList.remove(currentTheme);
77
+ }
78
+ classList.add("iui-theme-" + theme + (highContrast ? '-hc' : ''));
73
79
  };
@@ -2,9 +2,22 @@
2
2
  declare module 'react-table' {
3
3
  type FieldType = 'text' | 'number' | 'date' | string;
4
4
  type CellRendererProps<D extends object = {}> = {
5
+ /**
6
+ * Cell HTML props passed from the Table.
7
+ */
5
8
  cellElementProps: TableCellProps;
9
+ /**
10
+ * Table specific cell props like `column`, `row`.
11
+ */
6
12
  cellProps: CellProps<D>;
13
+ /**
14
+ * Cell's content.
15
+ */
7
16
  children: React.ReactNode;
17
+ /**
18
+ * Function that returns whether the cell is disabled.
19
+ */
20
+ isDisabled?: (rowData: D) => boolean;
8
21
  };
9
22
  interface TableOptions<D extends object = {}> extends Omit<UseTableOptions<D>, 'data'>, UseRowSelectOptions<D>, UseExpandedOptions<D>, UseFiltersOptions<D>, UsePaginationOptions<D>, Omit<UseResizeColumnsOptions<D>, 'disableResizing'>, UseSortByOptions<D> {
10
23
  /**
@@ -73,6 +86,11 @@ declare module 'react-table' {
73
86
  * @default false
74
87
  */
75
88
  disableReordering?: boolean;
89
+ /**
90
+ * If true, column's visibility cannot be toggled.
91
+ * @default false
92
+ */
93
+ disableToggleVisibility?: boolean;
76
94
  }
77
95
  interface ColumnInstance<D extends object = {}> extends UseFiltersColumnProps<D>, UseGroupByColumnProps<D>, UseResizeColumnsColumnProps<D>, UseSortByColumnProps<D> {
78
96
  originalWidth: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itwin/itwinui-react",
3
- "version": "1.34.1",
3
+ "version": "1.36.0",
4
4
  "author": "Bentley Systems",
5
5
  "license": "MIT",
6
6
  "main": "cjs/index.js",
@@ -40,7 +40,7 @@
40
40
  "build-storybook": "build-storybook"
41
41
  },
42
42
  "dependencies": {
43
- "@itwin/itwinui-css": "^0.52.0",
43
+ "@itwin/itwinui-css": "^0.54.1",
44
44
  "@itwin/itwinui-icons-react": "^1.5.0",
45
45
  "@itwin/itwinui-illustrations-react": "^1.0.1",
46
46
  "@tippyjs/react": "^4.2.5",
@@ -51,6 +51,7 @@
51
51
  },
52
52
  "devDependencies": {
53
53
  "@babel/core": "^7.12.10",
54
+ "@storybook/addon-a11y": "^6.4.19",
54
55
  "@storybook/addon-essentials": "~6.4.19",
55
56
  "@storybook/addon-storysource": "~6.4.19",
56
57
  "@storybook/addons": "~6.4.19",