@itwin/itwinui-react 1.34.2 → 1.37.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.
- package/CHANGELOG.md +43 -0
- package/cjs/core/ButtonGroup/ButtonGroup.js +1 -0
- package/cjs/core/Carousel/Carousel.d.ts +68 -0
- package/cjs/core/Carousel/Carousel.js +130 -0
- package/cjs/core/Carousel/CarouselContext.d.ts +37 -0
- package/cjs/core/Carousel/CarouselContext.js +12 -0
- package/cjs/core/Carousel/CarouselDot.d.ts +13 -0
- package/cjs/core/Carousel/CarouselDot.js +46 -0
- package/cjs/core/Carousel/CarouselDotsList.d.ts +32 -0
- package/cjs/core/Carousel/CarouselDotsList.js +132 -0
- package/cjs/core/Carousel/CarouselNavigation.d.ts +15 -0
- package/cjs/core/Carousel/CarouselNavigation.js +88 -0
- package/cjs/core/Carousel/CarouselSlide.d.ts +14 -0
- package/cjs/core/Carousel/CarouselSlide.js +63 -0
- package/cjs/core/Carousel/CarouselSlider.d.ts +5 -0
- package/cjs/core/Carousel/CarouselSlider.js +94 -0
- package/cjs/core/Carousel/index.d.ts +4 -0
- package/cjs/core/Carousel/index.js +10 -0
- package/cjs/core/ColorPicker/ColorSwatch.d.ts +1 -1
- package/cjs/core/DatePicker/DatePicker.d.ts +5 -0
- package/cjs/core/DatePicker/DatePicker.js +38 -13
- package/cjs/core/Header/HeaderButton.js +1 -0
- package/cjs/core/Menu/Menu.js +8 -3
- package/cjs/core/Modal/Modal.d.ts +5 -0
- package/cjs/core/Modal/Modal.js +11 -9
- package/cjs/core/Modal/ModalContent.d.ts +14 -0
- package/cjs/core/Modal/ModalContent.js +46 -0
- package/cjs/core/Modal/index.d.ts +2 -0
- package/cjs/core/Modal/index.js +3 -1
- package/cjs/core/SkipToContentLink/SkipToContentLink.d.ts +33 -0
- package/cjs/core/SkipToContentLink/SkipToContentLink.js +50 -0
- package/cjs/core/SkipToContentLink/index.d.ts +4 -0
- package/cjs/core/SkipToContentLink/index.js +10 -0
- package/cjs/core/Surface/Surface.d.ts +32 -0
- package/cjs/core/Surface/Surface.js +70 -0
- package/cjs/core/Surface/index.d.ts +4 -0
- package/cjs/core/Surface/index.js +10 -0
- package/cjs/core/Table/Table.d.ts +7 -0
- package/cjs/core/Table/Table.js +51 -27
- package/cjs/core/Table/TableCell.js +3 -3
- package/cjs/core/Table/TableRowMemoized.js +12 -7
- package/cjs/core/Table/actionHandlers/index.d.ts +2 -1
- package/cjs/core/Table/actionHandlers/index.js +5 -1
- package/cjs/core/Table/cells/DefaultCell.d.ts +1 -1
- package/cjs/core/Table/cells/DefaultCell.js +5 -2
- package/cjs/core/Table/columns/actionColumn.d.ts +35 -0
- package/cjs/core/Table/columns/actionColumn.js +91 -0
- package/cjs/core/Table/columns/expanderColumn.d.ts +47 -0
- package/cjs/core/Table/columns/expanderColumn.js +81 -0
- package/cjs/core/Table/columns/index.d.ts +3 -0
- package/cjs/core/Table/columns/index.js +15 -0
- package/cjs/core/Table/columns/selectionColumn.d.ts +35 -0
- package/cjs/core/Table/columns/selectionColumn.js +67 -0
- package/cjs/core/Table/hooks/index.d.ts +2 -2
- package/cjs/core/Table/hooks/index.js +1 -3
- package/cjs/core/Table/hooks/useExpanderCell.d.ts +0 -1
- package/cjs/core/Table/hooks/useExpanderCell.js +25 -39
- package/cjs/core/Table/hooks/useResizeColumns.js +8 -2
- package/cjs/core/Table/hooks/useSelectionCell.d.ts +1 -2
- package/cjs/core/Table/hooks/useSelectionCell.js +8 -53
- package/cjs/core/Table/index.d.ts +1 -0
- package/cjs/core/Table/index.js +5 -1
- package/cjs/core/Table/utils.js +1 -1
- package/cjs/core/Tag/Tag.js +6 -3
- package/cjs/core/Tile/Tile.d.ts +6 -2
- package/cjs/core/Tile/Tile.js +7 -2
- package/cjs/core/Toast/Toast.js +1 -1
- package/cjs/core/Typography/Anchor/Anchor.d.ts +1 -0
- package/cjs/core/Typography/Anchor/Anchor.js +1 -0
- package/cjs/core/index.d.ts +9 -3
- package/cjs/core/index.js +13 -2
- package/cjs/core/utils/components/Popover.js +13 -1
- package/cjs/core/utils/hooks/index.d.ts +1 -0
- package/cjs/core/utils/hooks/index.js +1 -0
- package/cjs/core/utils/hooks/useMediaQuery.d.ts +2 -0
- package/cjs/core/utils/hooks/useMediaQuery.js +46 -0
- package/cjs/core/utils/hooks/useTheme.d.ts +5 -0
- package/cjs/core/utils/hooks/useTheme.js +20 -14
- package/cjs/types/react-table-config.d.ts +18 -0
- package/esm/core/ButtonGroup/ButtonGroup.js +1 -0
- package/esm/core/Carousel/Carousel.d.ts +68 -0
- package/esm/core/Carousel/Carousel.js +124 -0
- package/esm/core/Carousel/CarouselContext.d.ts +37 -0
- package/esm/core/Carousel/CarouselContext.js +6 -0
- package/esm/core/Carousel/CarouselDot.d.ts +13 -0
- package/esm/core/Carousel/CarouselDot.js +40 -0
- package/esm/core/Carousel/CarouselDotsList.d.ts +32 -0
- package/esm/core/Carousel/CarouselDotsList.js +126 -0
- package/esm/core/Carousel/CarouselNavigation.d.ts +15 -0
- package/esm/core/Carousel/CarouselNavigation.js +82 -0
- package/esm/core/Carousel/CarouselSlide.d.ts +14 -0
- package/esm/core/Carousel/CarouselSlide.js +57 -0
- package/esm/core/Carousel/CarouselSlider.d.ts +5 -0
- package/esm/core/Carousel/CarouselSlider.js +88 -0
- package/esm/core/Carousel/index.d.ts +4 -0
- package/esm/core/Carousel/index.js +6 -0
- package/esm/core/ColorPicker/ColorSwatch.d.ts +1 -1
- package/esm/core/DatePicker/DatePicker.d.ts +5 -0
- package/esm/core/DatePicker/DatePicker.js +38 -13
- package/esm/core/Header/HeaderButton.js +1 -0
- package/esm/core/Menu/Menu.js +8 -3
- package/esm/core/Modal/Modal.d.ts +5 -0
- package/esm/core/Modal/Modal.js +11 -9
- package/esm/core/Modal/ModalContent.d.ts +14 -0
- package/esm/core/Modal/ModalContent.js +39 -0
- package/esm/core/Modal/index.d.ts +2 -0
- package/esm/core/Modal/index.js +1 -0
- package/esm/core/SkipToContentLink/SkipToContentLink.d.ts +33 -0
- package/esm/core/SkipToContentLink/SkipToContentLink.js +44 -0
- package/esm/core/SkipToContentLink/index.d.ts +4 -0
- package/esm/core/SkipToContentLink/index.js +6 -0
- package/esm/core/Surface/Surface.d.ts +32 -0
- package/esm/core/Surface/Surface.js +64 -0
- package/esm/core/Surface/index.d.ts +4 -0
- package/esm/core/Surface/index.js +6 -0
- package/esm/core/Table/Table.d.ts +7 -0
- package/esm/core/Table/Table.js +47 -23
- package/esm/core/Table/TableCell.js +2 -2
- package/esm/core/Table/TableRowMemoized.js +12 -7
- package/esm/core/Table/actionHandlers/index.d.ts +2 -1
- package/esm/core/Table/actionHandlers/index.js +2 -1
- package/esm/core/Table/cells/DefaultCell.d.ts +1 -1
- package/esm/core/Table/cells/DefaultCell.js +5 -2
- package/esm/core/Table/columns/actionColumn.d.ts +35 -0
- package/esm/core/Table/columns/actionColumn.js +84 -0
- package/esm/core/Table/columns/expanderColumn.d.ts +47 -0
- package/esm/core/Table/columns/expanderColumn.js +74 -0
- package/esm/core/Table/columns/index.d.ts +3 -0
- package/esm/core/Table/columns/index.js +7 -0
- package/esm/core/Table/columns/selectionColumn.d.ts +35 -0
- package/esm/core/Table/columns/selectionColumn.js +60 -0
- package/esm/core/Table/hooks/index.d.ts +2 -2
- package/esm/core/Table/hooks/index.js +2 -2
- package/esm/core/Table/hooks/useExpanderCell.d.ts +0 -1
- package/esm/core/Table/hooks/useExpanderCell.js +24 -35
- package/esm/core/Table/hooks/useResizeColumns.js +8 -2
- package/esm/core/Table/hooks/useSelectionCell.d.ts +1 -2
- package/esm/core/Table/hooks/useSelectionCell.js +7 -49
- package/esm/core/Table/index.d.ts +1 -0
- package/esm/core/Table/index.js +1 -0
- package/esm/core/Table/utils.js +1 -1
- package/esm/core/Tag/Tag.js +6 -3
- package/esm/core/Tile/Tile.d.ts +6 -2
- package/esm/core/Tile/Tile.js +7 -2
- package/esm/core/Toast/Toast.js +1 -1
- package/esm/core/Typography/Anchor/Anchor.d.ts +1 -0
- package/esm/core/Typography/Anchor/Anchor.js +1 -0
- package/esm/core/index.d.ts +9 -3
- package/esm/core/index.js +5 -2
- package/esm/core/utils/components/Popover.js +13 -1
- package/esm/core/utils/hooks/index.d.ts +1 -0
- package/esm/core/utils/hooks/index.js +1 -0
- package/esm/core/utils/hooks/useMediaQuery.d.ts +2 -0
- package/esm/core/utils/hooks/useMediaQuery.js +39 -0
- package/esm/core/utils/hooks/useTheme.d.ts +5 -0
- package/esm/core/utils/hooks/useTheme.js +20 -14
- package/esm/types/react-table-config.d.ts +18 -0
- package/package.json +3 -2
package/esm/core/Modal/Modal.js
CHANGED
|
@@ -31,6 +31,7 @@ import SvgClose from '@itwin/itwinui-icons-react/cjs/icons/Close';
|
|
|
31
31
|
import { useTheme, getContainer, getDocument, FocusTrap, } from '../utils';
|
|
32
32
|
import '@itwin/itwinui-css/css/modal.css';
|
|
33
33
|
import { IconButton } from '../Buttons/IconButton';
|
|
34
|
+
import { CSSTransition } from 'react-transition-group';
|
|
34
35
|
/**
|
|
35
36
|
* Modal component which can wrap any content.
|
|
36
37
|
* @example
|
|
@@ -53,7 +54,7 @@ import { IconButton } from '../Buttons/IconButton';
|
|
|
53
54
|
* </Modal>
|
|
54
55
|
*/
|
|
55
56
|
export var Modal = function (props) {
|
|
56
|
-
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, onKeyDown = props.onKeyDown, id = props.id, className = props.className, style = props.style, children = props.children, _e = props.modalRootId, modalRootId =
|
|
57
|
+
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, onKeyDown = props.onKeyDown, id = props.id, className = props.className, style = props.style, children = props.children, _e = props.styleType, styleType = _e === void 0 ? 'default' : _e, _f = props.modalRootId, modalRootId = _f === void 0 ? 'iui-react-portal-container' : _f, _g = props.ownerDocument, ownerDocument = _g === void 0 ? getDocument() : _g, rest = __rest(props, ["isOpen", "isDismissible", "closeOnEsc", "closeOnExternalClick", "onClose", "title", "onKeyDown", "id", "className", "style", "children", "styleType", "modalRootId", "ownerDocument"]);
|
|
57
58
|
useTheme();
|
|
58
59
|
var container = getContainer(modalRootId, ownerDocument);
|
|
59
60
|
var overlayRef = React.useRef(null);
|
|
@@ -111,13 +112,14 @@ export var Modal = function (props) {
|
|
|
111
112
|
onClose(event);
|
|
112
113
|
}
|
|
113
114
|
};
|
|
114
|
-
return !!container ? (ReactDOM.createPortal(
|
|
115
|
-
React.createElement(
|
|
116
|
-
React.createElement("div", { className: 'iui-modal-
|
|
117
|
-
React.createElement("div", { className: 'iui-
|
|
118
|
-
React.createElement("div", { className: 'iui-title' },
|
|
119
|
-
|
|
120
|
-
React.createElement(
|
|
121
|
-
|
|
115
|
+
return !!container ? (ReactDOM.createPortal(React.createElement(CSSTransition, { in: isOpen, classNames: 'iui-modal-animation', timeout: { exit: 600 }, unmountOnExit: true },
|
|
116
|
+
React.createElement(FocusTrap, null,
|
|
117
|
+
React.createElement("div", __assign({ className: cx('iui-modal', { 'iui-modal-full-page': styleType === 'fullPage' }, { 'iui-modal-visible': isOpen }, className), tabIndex: -1, onKeyDown: handleKeyDown, ref: overlayRef, onMouseDown: handleMouseDown }, rest),
|
|
118
|
+
React.createElement("div", { className: 'iui-modal-dialog', id: id, style: style, role: 'dialog', "aria-modal": 'true' },
|
|
119
|
+
React.createElement("div", { className: 'iui-title-bar' },
|
|
120
|
+
React.createElement("div", { className: 'iui-title' }, title),
|
|
121
|
+
isDismissible && (React.createElement(IconButton, { size: 'small', styleType: 'borderless', onClick: onClose, "aria-label": 'Close' },
|
|
122
|
+
React.createElement(SvgClose, null)))),
|
|
123
|
+
children)))), container)) : (React.createElement(React.Fragment, null));
|
|
122
124
|
};
|
|
123
125
|
export default Modal;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { CommonProps } from '../utils';
|
|
3
|
+
import '@itwin/itwinui-css/css/modal.css';
|
|
4
|
+
export declare type ModalContentProps = {
|
|
5
|
+
/**
|
|
6
|
+
* Main content in the `Modal`.
|
|
7
|
+
*/
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
} & Omit<CommonProps, 'title'>;
|
|
10
|
+
/**
|
|
11
|
+
* Container for content in `Modal`.
|
|
12
|
+
*/
|
|
13
|
+
export declare const ModalContent: (props: ModalContentProps) => JSX.Element;
|
|
14
|
+
export default ModalContent;
|
|
@@ -0,0 +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
|
+
};
|
|
23
|
+
/*---------------------------------------------------------------------------------------------
|
|
24
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
25
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
26
|
+
*--------------------------------------------------------------------------------------------*/
|
|
27
|
+
import React from 'react';
|
|
28
|
+
import cx from 'classnames';
|
|
29
|
+
import { useTheme } from '../utils';
|
|
30
|
+
import '@itwin/itwinui-css/css/modal.css';
|
|
31
|
+
/**
|
|
32
|
+
* Container for content in `Modal`.
|
|
33
|
+
*/
|
|
34
|
+
export var ModalContent = function (props) {
|
|
35
|
+
var children = props.children, className = props.className, rest = __rest(props, ["children", "className"]);
|
|
36
|
+
useTheme();
|
|
37
|
+
return (React.createElement("div", __assign({ className: cx('iui-modal-content', className) }, rest), children));
|
|
38
|
+
};
|
|
39
|
+
export default ModalContent;
|
|
@@ -2,5 +2,7 @@ export { Modal } from './Modal';
|
|
|
2
2
|
export type { ModalProps } from './Modal';
|
|
3
3
|
export { ModalButtonBar } from './ModalButtonBar';
|
|
4
4
|
export type { ModalButtonBarProps } from './ModalButtonBar';
|
|
5
|
+
export { ModalContent } from './ModalContent';
|
|
6
|
+
export type { ModalContentProps } from './ModalContent';
|
|
5
7
|
declare const _default: "./Modal";
|
|
6
8
|
export default _default;
|
package/esm/core/Modal/index.js
CHANGED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import '@itwin/itwinui-css/css/skip-to-content.css';
|
|
3
|
+
export declare type SkipToContentLinkProps = {
|
|
4
|
+
/**
|
|
5
|
+
* The id of the main content that the link directs to. Don't forget the #!
|
|
6
|
+
*/
|
|
7
|
+
href: string;
|
|
8
|
+
/**
|
|
9
|
+
* Localize 'Skip to main content' label.
|
|
10
|
+
* @default 'Skip to main content'
|
|
11
|
+
*/
|
|
12
|
+
children?: React.ReactNode;
|
|
13
|
+
} & Omit<React.ComponentPropsWithoutRef<'a'>, 'href'>;
|
|
14
|
+
/**
|
|
15
|
+
* `SkipToContentLink` is for screen reader and keyboard users and will not be visible unless tabbed to.
|
|
16
|
+
* Provides a shortcut to the main content of the page without navigating through the header, etc.
|
|
17
|
+
* Should be placed just inside the body. Set `href` to the id of your main content component. Don't forget the `#`!
|
|
18
|
+
* @example
|
|
19
|
+
* <body><SkipToContentLink href='#main-content-id' /> ... </body>
|
|
20
|
+
* <body><SkipToContentLink href='#main-content-id'>{localizedLabel}</SkipToContentLink> ... </body>
|
|
21
|
+
*/
|
|
22
|
+
export declare const SkipToContentLink: React.ForwardRefExoticComponent<{
|
|
23
|
+
/**
|
|
24
|
+
* The id of the main content that the link directs to. Don't forget the #!
|
|
25
|
+
*/
|
|
26
|
+
href: string;
|
|
27
|
+
/**
|
|
28
|
+
* Localize 'Skip to main content' label.
|
|
29
|
+
* @default 'Skip to main content'
|
|
30
|
+
*/
|
|
31
|
+
children?: React.ReactNode;
|
|
32
|
+
} & Omit<Pick<React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>, "key" | keyof React.AnchorHTMLAttributes<HTMLAnchorElement>>, "href"> & React.RefAttributes<HTMLAnchorElement>>;
|
|
33
|
+
export default SkipToContentLink;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
+
var t = {};
|
|
14
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
+
t[p] = s[p];
|
|
16
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
+
t[p[i]] = s[p[i]];
|
|
20
|
+
}
|
|
21
|
+
return t;
|
|
22
|
+
};
|
|
23
|
+
/*---------------------------------------------------------------------------------------------
|
|
24
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
25
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
26
|
+
*--------------------------------------------------------------------------------------------*/
|
|
27
|
+
import React from 'react';
|
|
28
|
+
import cx from 'classnames';
|
|
29
|
+
import { useTheme } from '../utils';
|
|
30
|
+
import '@itwin/itwinui-css/css/skip-to-content.css';
|
|
31
|
+
/**
|
|
32
|
+
* `SkipToContentLink` is for screen reader and keyboard users and will not be visible unless tabbed to.
|
|
33
|
+
* Provides a shortcut to the main content of the page without navigating through the header, etc.
|
|
34
|
+
* Should be placed just inside the body. Set `href` to the id of your main content component. Don't forget the `#`!
|
|
35
|
+
* @example
|
|
36
|
+
* <body><SkipToContentLink href='#main-content-id' /> ... </body>
|
|
37
|
+
* <body><SkipToContentLink href='#main-content-id'>{localizedLabel}</SkipToContentLink> ... </body>
|
|
38
|
+
*/
|
|
39
|
+
export var SkipToContentLink = React.forwardRef(function (props, ref) {
|
|
40
|
+
var _a = props.children, children = _a === void 0 ? 'Skip to main content' : _a, className = props.className, rest = __rest(props, ["children", "className"]);
|
|
41
|
+
useTheme();
|
|
42
|
+
return (React.createElement("a", __assign({ ref: ref, className: cx('iui-skip-to-content-link', className) }, rest), children));
|
|
43
|
+
});
|
|
44
|
+
export default SkipToContentLink;
|
|
@@ -0,0 +1,6 @@
|
|
|
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
|
+
export { SkipToContentLink } from './SkipToContentLink';
|
|
6
|
+
export default './SkipToContentLink';
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { CommonProps } from '../utils';
|
|
3
|
+
import '@itwin/itwinui-css/css/surface.css';
|
|
4
|
+
export declare type SurfaceProps = {
|
|
5
|
+
/**
|
|
6
|
+
* Sets the elevation of the surface
|
|
7
|
+
* @default 0
|
|
8
|
+
*/
|
|
9
|
+
elevation?: 0 | 1 | 2 | 3 | 4 | 5;
|
|
10
|
+
/**
|
|
11
|
+
* Content in the surface.
|
|
12
|
+
*/
|
|
13
|
+
children: React.ReactNode;
|
|
14
|
+
} & Omit<CommonProps, 'title'>;
|
|
15
|
+
/**
|
|
16
|
+
* The Surface container allows content to appear elevated through the use of a drop shadow
|
|
17
|
+
* @example
|
|
18
|
+
* <Surface>Surface Content</Surface>
|
|
19
|
+
* <Surface elevation={2}>Surface Content</Surface>
|
|
20
|
+
*/
|
|
21
|
+
export declare const Surface: React.ForwardRefExoticComponent<{
|
|
22
|
+
/**
|
|
23
|
+
* Sets the elevation of the surface
|
|
24
|
+
* @default 0
|
|
25
|
+
*/
|
|
26
|
+
elevation?: 0 | 1 | 2 | 3 | 4 | 5 | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* Content in the surface.
|
|
29
|
+
*/
|
|
30
|
+
children: React.ReactNode;
|
|
31
|
+
} & Omit<CommonProps, "title"> & React.RefAttributes<HTMLDivElement>>;
|
|
32
|
+
export default Surface;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
+
var t = {};
|
|
14
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
+
t[p] = s[p];
|
|
16
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
+
t[p[i]] = s[p[i]];
|
|
20
|
+
}
|
|
21
|
+
return t;
|
|
22
|
+
};
|
|
23
|
+
/*---------------------------------------------------------------------------------------------
|
|
24
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
25
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
26
|
+
*--------------------------------------------------------------------------------------------*/
|
|
27
|
+
import React from 'react';
|
|
28
|
+
import cx from 'classnames';
|
|
29
|
+
import { useTheme, getWindow } from '../utils';
|
|
30
|
+
import '@itwin/itwinui-css/css/surface.css';
|
|
31
|
+
/**
|
|
32
|
+
* Helper function that returns one of the preset surface elevation values.
|
|
33
|
+
*/
|
|
34
|
+
var getSurfaceElevationValue = function (elevation) {
|
|
35
|
+
switch (elevation) {
|
|
36
|
+
case 1:
|
|
37
|
+
return '0 1px 5px rgba(0, 0, 0, 0.25)';
|
|
38
|
+
case 2:
|
|
39
|
+
return '0 1px 10px rgba(0, 0, 0, 0.25)';
|
|
40
|
+
case 3:
|
|
41
|
+
return '0 3px 14px rgba(0, 0, 0, 0.25)';
|
|
42
|
+
case 4:
|
|
43
|
+
return '0 6px 30px rgba(0, 0, 0, 0.25)';
|
|
44
|
+
case 5:
|
|
45
|
+
return '0 9px 46px rgba(0, 0, 0, 0.25)';
|
|
46
|
+
default:
|
|
47
|
+
return 'none';
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* The Surface container allows content to appear elevated through the use of a drop shadow
|
|
52
|
+
* @example
|
|
53
|
+
* <Surface>Surface Content</Surface>
|
|
54
|
+
* <Surface elevation={2}>Surface Content</Surface>
|
|
55
|
+
*/
|
|
56
|
+
export var Surface = React.forwardRef(function (props, ref) {
|
|
57
|
+
var _a, _b, _c;
|
|
58
|
+
var _d = props.elevation, elevation = _d === void 0 ? 0 : _d, className = props.className, style = props.style, children = props.children, rest = __rest(props, ["elevation", "className", "style", "children"]);
|
|
59
|
+
useTheme();
|
|
60
|
+
var _style = ((_c = (_b = (_a = getWindow()) === null || _a === void 0 ? void 0 : _a.CSS) === null || _b === void 0 ? void 0 : _b.supports) === null || _c === void 0 ? void 0 : _c.call(_b, "--iui-surface-elevation: " + getSurfaceElevationValue(elevation)))
|
|
61
|
+
? __assign({ '--iui-surface-elevation': getSurfaceElevationValue(elevation) }, style) : __assign({ boxShadow: getSurfaceElevationValue(elevation) }, style);
|
|
62
|
+
return (React.createElement("div", __assign({ className: cx('iui-surface', className), style: _style, ref: ref }, rest), children));
|
|
63
|
+
});
|
|
64
|
+
export default Surface;
|
|
@@ -0,0 +1,6 @@
|
|
|
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
|
+
export { Surface } from './Surface';
|
|
6
|
+
export default './Surface';
|
|
@@ -3,6 +3,7 @@ import { CellProps, TableOptions, Row, TableState } from 'react-table';
|
|
|
3
3
|
import { CommonProps } from '../utils';
|
|
4
4
|
import '@itwin/itwinui-css/css/table.css';
|
|
5
5
|
import { TableFilterValue } from './filters';
|
|
6
|
+
export declare const tableResizeStartAction = "tableResizeStart";
|
|
6
7
|
export declare type TablePaginatorRendererProps = {
|
|
7
8
|
/**
|
|
8
9
|
* The zero-based index of the current page.
|
|
@@ -63,6 +64,12 @@ export declare type TableProps<T extends Record<string, unknown> = Record<string
|
|
|
63
64
|
* Handler for when a row is clicked. Must be memoized.
|
|
64
65
|
*/
|
|
65
66
|
onRowClick?: (event: React.MouseEvent, row: Row<T>) => void;
|
|
67
|
+
/**
|
|
68
|
+
* Modify the selection mode of the table.
|
|
69
|
+
* The column with checkboxes will not be present with 'single' selection mode.
|
|
70
|
+
* @default 'multi'
|
|
71
|
+
*/
|
|
72
|
+
selectionMode?: 'multi' | 'single';
|
|
66
73
|
/**
|
|
67
74
|
* Flag whether table columns can be sortable.
|
|
68
75
|
* @default false
|
package/esm/core/Table/Table.js
CHANGED
|
@@ -37,12 +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, } from './hooks';
|
|
40
|
-
import { onExpandHandler, onFilterHandler, onSelectHandler, } from './actionHandlers';
|
|
41
|
-
import { onSingleSelectHandler } from './actionHandlers/selectHandler';
|
|
42
|
-
import { onTableResizeEnd, onTableResizeStart, } from './actionHandlers/resizeHandler';
|
|
40
|
+
import { onExpandHandler, onFilterHandler, onSelectHandler, onSingleSelectHandler, onTableResizeEnd, onTableResizeStart, } from './actionHandlers';
|
|
43
41
|
import VirtualScroll from '../utils/components/VirtualScroll';
|
|
42
|
+
import { SELECTION_CELL_ID } from './columns';
|
|
44
43
|
var singleRowSelectedAction = 'singleRowSelected';
|
|
45
|
-
var tableResizeStartAction = 'tableResizeStart';
|
|
44
|
+
export var tableResizeStartAction = 'tableResizeStart';
|
|
46
45
|
var tableResizeEndAction = 'tableResizeEnd';
|
|
47
46
|
/**
|
|
48
47
|
* Table based on [react-table](https://react-table.tanstack.com/docs/api/overview).
|
|
@@ -88,9 +87,10 @@ var tableResizeEndAction = 'tableResizeEnd';
|
|
|
88
87
|
*/
|
|
89
88
|
export var Table = function (props) {
|
|
90
89
|
var _a;
|
|
91
|
-
var
|
|
90
|
+
var _b;
|
|
91
|
+
var data = props.data, columns = props.columns, _c = props.isLoading, isLoading = _c === void 0 ? false : _c, emptyTableContent = props.emptyTableContent, className = props.className, style = props.style, id = props.id, _d = props.isSelectable, isSelectable = _d === void 0 ? false : _d, onSelect = props.onSelect, onRowClick = props.onRowClick, _e = props.selectionMode, selectionMode = _e === void 0 ? 'multi' : _e, _f = props.isSortable, isSortable = _f === void 0 ? false : _f, onSort = props.onSort, stateReducer = props.stateReducer, onBottomReached = props.onBottomReached, onRowInViewport = props.onRowInViewport, _g = props.intersectionMargin, intersectionMargin = _g === void 0 ? 300 : _g, subComponent = props.subComponent, onExpand = props.onExpand, onFilter = props.onFilter, emptyFilteredTableContent = props.emptyFilteredTableContent, filterFunctions = props.filterTypes, expanderCell = props.expanderCell, isRowDisabled = props.isRowDisabled, rowProps = props.rowProps, _h = props.density, density = _h === void 0 ? 'default' : _h, _j = props.selectSubRows, selectSubRows = _j === void 0 ? true : _j, getSubRows = props.getSubRows, _k = props.selectRowOnClick, selectRowOnClick = _k === void 0 ? true : _k, paginatorRenderer = props.paginatorRenderer, _l = props.pageSize, pageSize = _l === void 0 ? 25 : _l, _m = props.isResizable, isResizable = _m === void 0 ? false : _m, _o = props.styleType, styleType = _o === void 0 ? 'default' : _o, _p = props.enableVirtualization, enableVirtualization = _p === void 0 ? false : _p, _q = props.enableColumnReordering, enableColumnReordering = _q === void 0 ? false : _q, 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"]);
|
|
92
92
|
useTheme();
|
|
93
|
-
var
|
|
93
|
+
var _r = React.useState(), ownerDocument = _r[0], setOwnerDocument = _r[1];
|
|
94
94
|
var defaultColumn = React.useMemo(function () { return ({
|
|
95
95
|
maxWidth: 0,
|
|
96
96
|
minWidth: 0,
|
|
@@ -103,6 +103,7 @@ export var Table = function (props) {
|
|
|
103
103
|
onBottomReachedRef.current = onBottomReached;
|
|
104
104
|
onRowInViewportRef.current = onRowInViewport;
|
|
105
105
|
}, [onBottomReached, onRowInViewport]);
|
|
106
|
+
var hasManualSelectionColumn = (_b = columns[0]) === null || _b === void 0 ? void 0 : _b.columns.some(function (column) { return column.id === SELECTION_CELL_ID; });
|
|
106
107
|
var tableStateReducer = React.useCallback(function (newState, action, previousState, instance) {
|
|
107
108
|
switch (action.type) {
|
|
108
109
|
case TableActions.toggleSortBy:
|
|
@@ -116,13 +117,17 @@ export var Table = function (props) {
|
|
|
116
117
|
onExpandHandler(newState, instance, onExpand);
|
|
117
118
|
break;
|
|
118
119
|
case singleRowSelectedAction: {
|
|
119
|
-
newState = onSingleSelectHandler(newState, action, instance, onSelect,
|
|
120
|
+
newState = onSingleSelectHandler(newState, action, instance, onSelect,
|
|
121
|
+
// If it has manual selection column, then we can't check whether row is disabled
|
|
122
|
+
hasManualSelectionColumn ? undefined : isRowDisabled);
|
|
120
123
|
break;
|
|
121
124
|
}
|
|
122
125
|
case TableActions.toggleRowSelected:
|
|
123
126
|
case TableActions.toggleAllRowsSelected:
|
|
124
127
|
case TableActions.toggleAllPageRowsSelected: {
|
|
125
|
-
onSelectHandler(newState, instance, onSelect,
|
|
128
|
+
onSelectHandler(newState, instance, onSelect,
|
|
129
|
+
// If it has manual selection column, then we can't check whether row is disabled
|
|
130
|
+
hasManualSelectionColumn ? undefined : isRowDisabled);
|
|
126
131
|
break;
|
|
127
132
|
}
|
|
128
133
|
case tableResizeStartAction: {
|
|
@@ -139,14 +144,22 @@ export var Table = function (props) {
|
|
|
139
144
|
return stateReducer
|
|
140
145
|
? stateReducer(newState, action, previousState, instance)
|
|
141
146
|
: newState;
|
|
142
|
-
}, [
|
|
147
|
+
}, [
|
|
148
|
+
hasManualSelectionColumn,
|
|
149
|
+
isRowDisabled,
|
|
150
|
+
onExpand,
|
|
151
|
+
onFilter,
|
|
152
|
+
onSelect,
|
|
153
|
+
onSort,
|
|
154
|
+
stateReducer,
|
|
155
|
+
]);
|
|
143
156
|
var filterTypes = React.useMemo(function () { return (__assign(__assign({}, customFilterFunctions), filterFunctions)); }, [filterFunctions]);
|
|
144
157
|
var hasAnySubRows = React.useMemo(function () {
|
|
145
158
|
return data.some(function (item, index) {
|
|
146
159
|
return getSubRows ? getSubRows(item, index) : item.subRows;
|
|
147
160
|
});
|
|
148
161
|
}, [data, getSubRows]);
|
|
149
|
-
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, isRowDisabled), useColumnOrder, useColumnDragAndDrop(enableColumnReordering));
|
|
162
|
+
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));
|
|
150
163
|
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;
|
|
151
164
|
var ariaDataAttributes = Object.entries(rest).reduce(function (result, _a) {
|
|
152
165
|
var key = _a[0], value = _a[1];
|
|
@@ -158,8 +171,14 @@ export var Table = function (props) {
|
|
|
158
171
|
var areFiltersSet = allColumns.some(function (column) { return !!column.filterValue; });
|
|
159
172
|
var onRowClickHandler = React.useCallback(function (event, row) {
|
|
160
173
|
var isDisabled = isRowDisabled === null || isRowDisabled === void 0 ? void 0 : isRowDisabled(row.original);
|
|
161
|
-
if (
|
|
162
|
-
|
|
174
|
+
if (!isDisabled) {
|
|
175
|
+
onRowClick === null || onRowClick === void 0 ? void 0 : onRowClick(event, row);
|
|
176
|
+
}
|
|
177
|
+
if (isSelectable &&
|
|
178
|
+
!isDisabled &&
|
|
179
|
+
selectRowOnClick &&
|
|
180
|
+
!event.isDefaultPrevented()) {
|
|
181
|
+
if (!row.isSelected && (selectionMode === 'single' || !event.ctrlKey)) {
|
|
163
182
|
dispatch({
|
|
164
183
|
type: singleRowSelectedAction,
|
|
165
184
|
id: row.id,
|
|
@@ -169,10 +188,14 @@ export var Table = function (props) {
|
|
|
169
188
|
row.toggleRowSelected(!row.isSelected);
|
|
170
189
|
}
|
|
171
190
|
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
191
|
+
}, [
|
|
192
|
+
isRowDisabled,
|
|
193
|
+
isSelectable,
|
|
194
|
+
selectRowOnClick,
|
|
195
|
+
selectionMode,
|
|
196
|
+
dispatch,
|
|
197
|
+
onRowClick,
|
|
198
|
+
]);
|
|
176
199
|
React.useEffect(function () {
|
|
177
200
|
setPageSize(pageSize);
|
|
178
201
|
}, [pageSize, setPageSize]);
|
|
@@ -228,11 +251,12 @@ export var Table = function (props) {
|
|
|
228
251
|
});
|
|
229
252
|
var headerRef = React.useRef(null);
|
|
230
253
|
var bodyRef = React.useRef(null);
|
|
231
|
-
var getPreparedRow = React.useCallback(function (
|
|
254
|
+
var getPreparedRow = React.useCallback(function (index) {
|
|
255
|
+
var row = page[index];
|
|
232
256
|
prepareRow(row);
|
|
233
|
-
return (React.createElement(TableRowMemoized, { row: row, rowProps: rowProps, isLast:
|
|
257
|
+
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 === null || isRowDisabled === void 0 ? void 0 : isRowDisabled(row.original)), tableHasSubRows: hasAnySubRows, tableInstance: instance, expanderCell: expanderCell }));
|
|
234
258
|
}, [
|
|
235
|
-
|
|
259
|
+
page,
|
|
236
260
|
expanderCell,
|
|
237
261
|
hasAnySubRows,
|
|
238
262
|
instance,
|
|
@@ -244,7 +268,7 @@ export var Table = function (props) {
|
|
|
244
268
|
state,
|
|
245
269
|
subComponent,
|
|
246
270
|
]);
|
|
247
|
-
var virtualizedItemRenderer = React.useCallback(function (index) { return getPreparedRow(
|
|
271
|
+
var virtualizedItemRenderer = React.useCallback(function (index) { return getPreparedRow(index); }, [getPreparedRow]);
|
|
248
272
|
return (React.createElement(React.Fragment, null,
|
|
249
273
|
React.createElement("div", __assign({ ref: function (element) {
|
|
250
274
|
setOwnerDocument(element === null || element === void 0 ? void 0 : element.ownerDocument);
|
|
@@ -268,8 +292,8 @@ export var Table = function (props) {
|
|
|
268
292
|
}
|
|
269
293
|
} }),
|
|
270
294
|
column.render('Header'),
|
|
271
|
-
|
|
272
|
-
|
|
295
|
+
(data.length !== 0 || areFiltersSet) && (React.createElement(FilterToggle, { column: column, ownerDocument: ownerDocument })),
|
|
296
|
+
data.length !== 0 && column.canSort && (React.createElement("div", { className: 'iui-cell-end-icon' }, column.isSorted && column.isSortedDesc ? (React.createElement(SvgSortUp, { className: 'iui-icon iui-sort', "aria-hidden": true })) : (React.createElement(SvgSortDown, { className: 'iui-icon iui-sort', "aria-hidden": true })))),
|
|
273
297
|
isResizable &&
|
|
274
298
|
column.isResizerVisible &&
|
|
275
299
|
index !== headerGroup.headers.length - 1 && (React.createElement("div", __assign({}, column.getResizerProps(), { className: 'iui-resizer' }),
|
|
@@ -287,7 +311,7 @@ export var Table = function (props) {
|
|
|
287
311
|
headerRef.current.scrollLeft = bodyRef.current.scrollLeft;
|
|
288
312
|
}
|
|
289
313
|
}, tabIndex: -1 }),
|
|
290
|
-
data.length !== 0 && (React.createElement(React.Fragment, null, enableVirtualization ? (React.createElement(VirtualScroll, { itemsLength: page.length, itemRenderer: virtualizedItemRenderer })) : (page.map(function (
|
|
314
|
+
data.length !== 0 && (React.createElement(React.Fragment, null, enableVirtualization ? (React.createElement(VirtualScroll, { itemsLength: page.length, itemRenderer: virtualizedItemRenderer })) : (page.map(function (_, index) { return getPreparedRow(index); })))),
|
|
291
315
|
isLoading && data.length === 0 && (React.createElement("div", { className: 'iui-table-empty' },
|
|
292
316
|
React.createElement(ProgressRadial, { indeterminate: true }))),
|
|
293
317
|
isLoading && data.length !== 0 && (React.createElement("div", { className: 'iui-row' },
|
|
@@ -17,7 +17,7 @@ import React from 'react';
|
|
|
17
17
|
import cx from 'classnames';
|
|
18
18
|
import { getCellStyle } from './utils';
|
|
19
19
|
import { SubRowExpander } from './SubRowExpander';
|
|
20
|
-
import { SELECTION_CELL_ID } from './
|
|
20
|
+
import { SELECTION_CELL_ID } from './columns';
|
|
21
21
|
import { DefaultCell } from './cells';
|
|
22
22
|
export var TableCell = function (props) {
|
|
23
23
|
var cell = props.cell, cellIndex = props.cellIndex, isDisabled = props.isDisabled, tableHasSubRows = props.tableHasSubRows, tableInstance = props.tableInstance, expanderCell = props.expanderCell;
|
|
@@ -46,6 +46,6 @@ export var TableCell = function (props) {
|
|
|
46
46
|
cellProps: cellProps,
|
|
47
47
|
children: cellContent,
|
|
48
48
|
};
|
|
49
|
-
return (React.createElement(React.Fragment, null, cell.column.cellRenderer ? (cell.column.cellRenderer(cellRendererProps)) : (React.createElement(DefaultCell, __assign({}, cellRendererProps)))));
|
|
49
|
+
return (React.createElement(React.Fragment, null, cell.column.cellRenderer ? (cell.column.cellRenderer(__assign(__assign({}, cellRendererProps), { isDisabled: function () { return isDisabled; } }))) : (React.createElement(DefaultCell, __assign({}, cellRendererProps, { isDisabled: function () { return isDisabled; } })))));
|
|
50
50
|
};
|
|
51
51
|
export default TableCell;
|
|
@@ -51,7 +51,9 @@ export var TableRow = function (props) {
|
|
|
51
51
|
return (React.createElement(TableCell, { key: cell.getCellProps().key, cell: cell, cellIndex: index, isDisabled: isDisabled, tableHasSubRows: tableHasSubRows, tableInstance: tableInstance, expanderCell: expanderCell }));
|
|
52
52
|
})),
|
|
53
53
|
subComponent && (React.createElement(WithCSSTransition, { in: row.isExpanded },
|
|
54
|
-
React.createElement("div", { className: 'iui-row iui-expanded-content'
|
|
54
|
+
React.createElement("div", { className: cx('iui-row', 'iui-expanded-content', {
|
|
55
|
+
'iui-disabled': isDisabled,
|
|
56
|
+
}) }, subComponent(row))))));
|
|
55
57
|
};
|
|
56
58
|
var hasAnySelectedSubRow = function (row, selectedRowIds) {
|
|
57
59
|
if (selectedRowIds === null || selectedRowIds === void 0 ? void 0 : selectedRowIds[row.id]) {
|
|
@@ -62,14 +64,17 @@ var hasAnySelectedSubRow = function (row, selectedRowIds) {
|
|
|
62
64
|
});
|
|
63
65
|
};
|
|
64
66
|
export var TableRowMemoized = React.memo(TableRow, function (prevProp, nextProp) {
|
|
65
|
-
var _a, _b, _c, _d;
|
|
67
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
66
68
|
return prevProp.isLast === nextProp.isLast &&
|
|
69
|
+
((_a = prevProp.state.hiddenColumns) === null || _a === void 0 ? void 0 : _a.length) ===
|
|
70
|
+
((_b = nextProp.state.hiddenColumns) === null || _b === void 0 ? void 0 : _b.length) &&
|
|
71
|
+
!!((_c = prevProp.state.hiddenColumns) === null || _c === void 0 ? void 0 : _c.every(function (column, index) { var _a; return ((_a = nextProp.state.hiddenColumns) === null || _a === void 0 ? void 0 : _a[index]) === column; })) &&
|
|
67
72
|
prevProp.onRowInViewport === nextProp.onRowInViewport &&
|
|
68
73
|
prevProp.onBottomReached === nextProp.onBottomReached &&
|
|
69
74
|
prevProp.onClick === nextProp.onClick &&
|
|
70
75
|
prevProp.row.original === nextProp.row.original &&
|
|
71
|
-
((
|
|
72
|
-
((
|
|
76
|
+
((_d = prevProp.state.selectedRowIds) === null || _d === void 0 ? void 0 : _d[prevProp.row.id]) ===
|
|
77
|
+
((_e = nextProp.state.selectedRowIds) === null || _e === void 0 ? void 0 : _e[nextProp.row.id]) &&
|
|
73
78
|
// Check if sub-rows selection has changed and whether to show indeterminate state or not
|
|
74
79
|
prevProp.row.subRows.some(function (subRow) {
|
|
75
80
|
return hasAnySelectedSubRow(subRow, prevProp.state.selectedRowIds);
|
|
@@ -77,8 +82,8 @@ export var TableRowMemoized = React.memo(TableRow, function (prevProp, nextProp)
|
|
|
77
82
|
nextProp.row.subRows.some(function (subRow) {
|
|
78
83
|
return hasAnySelectedSubRow(subRow, nextProp.state.selectedRowIds);
|
|
79
84
|
}) &&
|
|
80
|
-
((
|
|
81
|
-
((
|
|
85
|
+
((_f = prevProp.state.expanded) === null || _f === void 0 ? void 0 : _f[prevProp.row.id]) ===
|
|
86
|
+
((_g = nextProp.state.expanded) === null || _g === void 0 ? void 0 : _g[nextProp.row.id]) &&
|
|
82
87
|
prevProp.subComponent === nextProp.subComponent &&
|
|
83
88
|
prevProp.row.cells.every(function (cell, index) { return nextProp.row.cells[index].column === cell.column; }) &&
|
|
84
89
|
prevProp.isDisabled === nextProp.isDisabled &&
|
|
@@ -87,5 +92,5 @@ export var TableRowMemoized = React.memo(TableRow, function (prevProp, nextProp)
|
|
|
87
92
|
prevProp.tableHasSubRows === nextProp.tableHasSubRows &&
|
|
88
93
|
prevProp.state.columnOrder === nextProp.state.columnOrder &&
|
|
89
94
|
!nextProp.state.columnResizing.isResizingColumn &&
|
|
90
|
-
|
|
95
|
+
prevProp.state.isTableResizing === nextProp.state.isTableResizing;
|
|
91
96
|
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { onExpandHandler } from './expandHandler';
|
|
2
2
|
export { onFilterHandler } from './filterHandler';
|
|
3
|
-
export { onSelectHandler } from './selectHandler';
|
|
3
|
+
export { onSelectHandler, onSingleSelectHandler } from './selectHandler';
|
|
4
|
+
export { onTableResizeStart, onTableResizeEnd } from './resizeHandler';
|
|
@@ -4,4 +4,5 @@
|
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
5
|
export { onExpandHandler } from './expandHandler';
|
|
6
6
|
export { onFilterHandler } from './filterHandler';
|
|
7
|
-
export { onSelectHandler } from './selectHandler';
|
|
7
|
+
export { onSelectHandler, onSingleSelectHandler } from './selectHandler';
|
|
8
|
+
export { onTableResizeStart, onTableResizeEnd } from './resizeHandler';
|
|
@@ -12,5 +12,5 @@ export declare type DefaultCellProps<T extends Record<string, unknown>> = CellRe
|
|
|
12
12
|
* cellRenderer: (props) => <DefaultCell {...props} />,
|
|
13
13
|
* }
|
|
14
14
|
*/
|
|
15
|
-
export declare const DefaultCell: <T extends Record<string, unknown>>(props:
|
|
15
|
+
export declare const DefaultCell: <T extends Record<string, unknown>>(props: DefaultCellProps<T>) => JSX.Element;
|
|
16
16
|
export default DefaultCell;
|