@itwin/itwinui-react 1.24.0 → 1.27.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 +44 -0
- package/cjs/core/Buttons/Button/Button.d.ts +1 -1
- package/cjs/core/Buttons/Button/Button.js +4 -5
- package/cjs/core/Buttons/IconButton/IconButton.js +2 -3
- package/cjs/core/Checkbox/Checkbox.d.ts +11 -0
- package/cjs/core/Checkbox/Checkbox.js +14 -4
- package/cjs/core/ColorPicker/ColorBuilder.js +1 -1
- package/cjs/core/ColorPicker/ColorInputPanel.js +43 -21
- package/cjs/core/ColorPicker/ColorPalette.js +1 -1
- package/cjs/core/ColorPicker/ColorPicker.js +2 -2
- package/cjs/core/ColorPicker/ColorPickerContext.d.ts +2 -2
- package/cjs/core/ColorPicker/ColorSwatch.d.ts +1 -1
- package/cjs/core/ColorPicker/ColorSwatch.js +10 -6
- package/cjs/core/ComboBox/ComboBox.d.ts +2 -2
- package/cjs/core/DatePicker/DatePicker.d.ts +1 -1
- package/cjs/core/ErrorPage/ErrorPage.d.ts +2 -1
- package/cjs/core/ErrorPage/ErrorPage.js +3 -2
- package/cjs/core/InformationPanel/InformationPanel.d.ts +4 -1
- package/cjs/core/InformationPanel/InformationPanel.js +4 -1
- package/cjs/core/InformationPanel/InformationPanelContent.d.ts +42 -0
- package/cjs/core/InformationPanel/InformationPanelContent.js +66 -0
- package/cjs/core/InformationPanel/index.d.ts +2 -0
- package/cjs/core/InformationPanel/index.js +3 -1
- package/cjs/core/Label/Label.d.ts +31 -0
- package/cjs/core/Label/Label.js +53 -0
- package/cjs/core/Label/index.d.ts +4 -0
- package/cjs/core/Label/index.js +10 -0
- package/cjs/core/LabeledInput/LabeledInput.d.ts +2 -2
- package/cjs/core/LabeledTextarea/LabeledTextarea.d.ts +1 -1
- package/cjs/core/Menu/MenuItem.d.ts +1 -1
- package/cjs/core/Modal/ModalButtonBar.d.ts +2 -1
- package/cjs/core/Modal/ModalButtonBar.js +3 -2
- package/cjs/core/Table/Table.d.ts +8 -0
- package/cjs/core/Table/Table.js +71 -10
- package/cjs/core/Table/TableCell.js +1 -1
- package/cjs/core/Table/TablePaginator.d.ts +7 -7
- package/cjs/core/Table/TablePaginator.js +20 -10
- package/cjs/core/Table/TableRowMemoized.d.ts +21 -0
- package/cjs/core/Table/TableRowMemoized.js +6 -3
- package/cjs/core/Table/actionHandlers/resizeHandler.d.ts +51 -0
- package/cjs/core/Table/actionHandlers/resizeHandler.js +22 -0
- package/cjs/core/Table/actionHandlers/selectHandler.d.ts +10 -7
- package/cjs/core/Table/hooks/index.d.ts +1 -0
- package/cjs/core/Table/hooks/index.js +3 -1
- package/cjs/core/Table/hooks/useResizeColumns.d.ts +5 -0
- package/cjs/core/Table/hooks/useResizeColumns.js +271 -0
- package/cjs/core/Table/utils.d.ts +1 -1
- package/cjs/core/Table/utils.js +8 -2
- package/cjs/core/Tabs/Tabs.d.ts +4 -0
- package/cjs/core/Tabs/Tabs.js +23 -29
- package/cjs/core/index.d.ts +6 -4
- package/cjs/core/index.js +6 -2
- package/cjs/core/utils/color/ColorValue.d.ts +1 -0
- package/cjs/core/utils/color/ColorValue.js +96 -84
- package/cjs/core/utils/components/MiddleTextTruncation.d.ts +21 -0
- package/cjs/core/utils/components/MiddleTextTruncation.js +56 -0
- package/cjs/core/utils/components/index.d.ts +1 -0
- package/cjs/core/utils/components/index.js +1 -0
- package/cjs/core/utils/hooks/index.d.ts +1 -0
- package/cjs/core/utils/hooks/index.js +1 -0
- package/cjs/core/utils/hooks/useContainerWidth.d.ts +17 -0
- package/cjs/core/utils/hooks/useContainerWidth.js +50 -0
- package/cjs/core/utils/hooks/useOverflow.d.ts +1 -1
- package/cjs/core/utils/hooks/useOverflow.js +30 -17
- package/cjs/types/react-table-config.d.ts +16 -3
- package/esm/core/Buttons/Button/Button.d.ts +1 -1
- package/esm/core/Buttons/Button/Button.js +4 -5
- package/esm/core/Buttons/IconButton/IconButton.js +2 -3
- package/esm/core/Checkbox/Checkbox.d.ts +11 -0
- package/esm/core/Checkbox/Checkbox.js +14 -4
- package/esm/core/ColorPicker/ColorBuilder.js +1 -1
- package/esm/core/ColorPicker/ColorInputPanel.js +43 -21
- package/esm/core/ColorPicker/ColorPalette.js +1 -1
- package/esm/core/ColorPicker/ColorPicker.js +2 -2
- package/esm/core/ColorPicker/ColorPickerContext.d.ts +2 -2
- package/esm/core/ColorPicker/ColorSwatch.d.ts +1 -1
- package/esm/core/ColorPicker/ColorSwatch.js +10 -6
- package/esm/core/ComboBox/ComboBox.d.ts +2 -2
- package/esm/core/DatePicker/DatePicker.d.ts +1 -1
- package/esm/core/ErrorPage/ErrorPage.d.ts +2 -1
- package/esm/core/ErrorPage/ErrorPage.js +3 -2
- package/esm/core/InformationPanel/InformationPanel.d.ts +4 -1
- package/esm/core/InformationPanel/InformationPanel.js +4 -1
- package/esm/core/InformationPanel/InformationPanelContent.d.ts +42 -0
- package/esm/core/InformationPanel/InformationPanelContent.js +59 -0
- package/esm/core/InformationPanel/index.d.ts +2 -0
- package/esm/core/InformationPanel/index.js +1 -0
- package/esm/core/Label/Label.d.ts +31 -0
- package/esm/core/Label/Label.js +46 -0
- package/esm/core/Label/index.d.ts +4 -0
- package/esm/core/Label/index.js +6 -0
- package/esm/core/LabeledInput/LabeledInput.d.ts +2 -2
- package/esm/core/LabeledTextarea/LabeledTextarea.d.ts +1 -1
- package/esm/core/Menu/MenuItem.d.ts +1 -1
- package/esm/core/Modal/ModalButtonBar.d.ts +2 -1
- package/esm/core/Modal/ModalButtonBar.js +3 -2
- package/esm/core/Table/Table.d.ts +8 -0
- package/esm/core/Table/Table.js +73 -12
- package/esm/core/Table/TableCell.js +1 -1
- package/esm/core/Table/TablePaginator.d.ts +7 -7
- package/esm/core/Table/TablePaginator.js +21 -11
- package/esm/core/Table/TableRowMemoized.d.ts +21 -0
- package/esm/core/Table/TableRowMemoized.js +4 -2
- package/esm/core/Table/actionHandlers/resizeHandler.d.ts +51 -0
- package/esm/core/Table/actionHandlers/resizeHandler.js +17 -0
- package/esm/core/Table/actionHandlers/selectHandler.d.ts +10 -7
- package/esm/core/Table/hooks/index.d.ts +1 -0
- package/esm/core/Table/hooks/index.js +1 -0
- package/esm/core/Table/hooks/useResizeColumns.d.ts +5 -0
- package/esm/core/Table/hooks/useResizeColumns.js +267 -0
- package/esm/core/Table/utils.d.ts +1 -1
- package/esm/core/Table/utils.js +8 -2
- package/esm/core/Tabs/Tabs.d.ts +4 -0
- package/esm/core/Tabs/Tabs.js +24 -30
- package/esm/core/index.d.ts +6 -4
- package/esm/core/index.js +3 -2
- package/esm/core/utils/color/ColorValue.d.ts +1 -0
- package/esm/core/utils/color/ColorValue.js +96 -84
- package/esm/core/utils/components/MiddleTextTruncation.d.ts +21 -0
- package/esm/core/utils/components/MiddleTextTruncation.js +49 -0
- package/esm/core/utils/components/index.d.ts +1 -0
- package/esm/core/utils/components/index.js +1 -0
- package/esm/core/utils/hooks/index.d.ts +1 -0
- package/esm/core/utils/hooks/index.js +1 -0
- package/esm/core/utils/hooks/useContainerWidth.d.ts +17 -0
- package/esm/core/utils/hooks/useContainerWidth.js +43 -0
- package/esm/core/utils/hooks/useOverflow.d.ts +1 -1
- package/esm/core/utils/hooks/useOverflow.js +30 -17
- package/esm/types/react-table-config.d.ts +16 -3
- package/package.json +13 -5
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { CommonProps } from '../utils';
|
|
3
|
+
import '@itwin/itwinui-css/css/information-panel.css';
|
|
4
|
+
export declare type InformationPanelContentProps = {
|
|
5
|
+
/**
|
|
6
|
+
* If set to 'inline', the label/input pairs will be shown on the same line.
|
|
7
|
+
* The component handles the spacing and alignment automatically.
|
|
8
|
+
*
|
|
9
|
+
* @default 'default'
|
|
10
|
+
*/
|
|
11
|
+
displayStyle?: 'default' | 'inline';
|
|
12
|
+
/**
|
|
13
|
+
* Content of the component.
|
|
14
|
+
* Should ideally be pairs of `Label` and input components.
|
|
15
|
+
*/
|
|
16
|
+
children: React.ReactNode;
|
|
17
|
+
} & Omit<CommonProps, 'title'>;
|
|
18
|
+
/**
|
|
19
|
+
* The `InformationPanelContent` component should be used inside `InformationPanelBody`
|
|
20
|
+
* to style rows of key/value pairs, where the key is ideally represented by a `Label` component
|
|
21
|
+
* and the value can be any input element (including readonly inputs for non-modifiable fields).
|
|
22
|
+
*
|
|
23
|
+
* By default, the pairs are displayed of label and input are displayed in separate lines,
|
|
24
|
+
* but displayStyle can be set to 'inline' to show them in the same line with correct alignment.
|
|
25
|
+
*
|
|
26
|
+
* You can use multiple `InformationPanelContent` instances inside one `InformationPanelBody`; this is
|
|
27
|
+
* useful when you want to show other content, e.g. separate headings for different sections of key/value pairs.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* <InformationPanelContent displayStyle='inline'>
|
|
31
|
+
* <Label htmlFor='name-input'>File name</Label>
|
|
32
|
+
* <Input id='name-input' value='Alpha.mp3' />
|
|
33
|
+
*
|
|
34
|
+
* <Label htmlFor='year-input'>Year</Label>
|
|
35
|
+
* <Input id='year-input' value='2021' />
|
|
36
|
+
*
|
|
37
|
+
* <Label htmlFor='path-input'>Path</Label>
|
|
38
|
+
* <Input id='path-input' value='/Shared/Music/' />
|
|
39
|
+
* </InformationPanelContent>
|
|
40
|
+
*/
|
|
41
|
+
export declare const InformationPanelContent: (props: InformationPanelContentProps) => JSX.Element;
|
|
42
|
+
export default InformationPanelContent;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
14
|
+
var t = {};
|
|
15
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
16
|
+
t[p] = s[p];
|
|
17
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
18
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
19
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
20
|
+
t[p[i]] = s[p[i]];
|
|
21
|
+
}
|
|
22
|
+
return t;
|
|
23
|
+
};
|
|
24
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
25
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
26
|
+
};
|
|
27
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
+
exports.InformationPanelContent = void 0;
|
|
29
|
+
/*---------------------------------------------------------------------------------------------
|
|
30
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
31
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
32
|
+
*--------------------------------------------------------------------------------------------*/
|
|
33
|
+
var classnames_1 = __importDefault(require("classnames"));
|
|
34
|
+
var react_1 = __importDefault(require("react"));
|
|
35
|
+
var utils_1 = require("../utils");
|
|
36
|
+
require("@itwin/itwinui-css/css/information-panel.css");
|
|
37
|
+
/**
|
|
38
|
+
* The `InformationPanelContent` component should be used inside `InformationPanelBody`
|
|
39
|
+
* to style rows of key/value pairs, where the key is ideally represented by a `Label` component
|
|
40
|
+
* and the value can be any input element (including readonly inputs for non-modifiable fields).
|
|
41
|
+
*
|
|
42
|
+
* By default, the pairs are displayed of label and input are displayed in separate lines,
|
|
43
|
+
* but displayStyle can be set to 'inline' to show them in the same line with correct alignment.
|
|
44
|
+
*
|
|
45
|
+
* You can use multiple `InformationPanelContent` instances inside one `InformationPanelBody`; this is
|
|
46
|
+
* useful when you want to show other content, e.g. separate headings for different sections of key/value pairs.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* <InformationPanelContent displayStyle='inline'>
|
|
50
|
+
* <Label htmlFor='name-input'>File name</Label>
|
|
51
|
+
* <Input id='name-input' value='Alpha.mp3' />
|
|
52
|
+
*
|
|
53
|
+
* <Label htmlFor='year-input'>Year</Label>
|
|
54
|
+
* <Input id='year-input' value='2021' />
|
|
55
|
+
*
|
|
56
|
+
* <Label htmlFor='path-input'>Path</Label>
|
|
57
|
+
* <Input id='path-input' value='/Shared/Music/' />
|
|
58
|
+
* </InformationPanelContent>
|
|
59
|
+
*/
|
|
60
|
+
var InformationPanelContent = function (props) {
|
|
61
|
+
var className = props.className, _a = props.displayStyle, displayStyle = _a === void 0 ? 'default' : _a, children = props.children, rest = __rest(props, ["className", "displayStyle", "children"]);
|
|
62
|
+
(0, utils_1.useTheme)();
|
|
63
|
+
return (react_1.default.createElement("div", __assign({ className: (0, classnames_1.default)('iui-information-body-content', { 'iui-inline': displayStyle === 'inline' }, className) }, rest), children));
|
|
64
|
+
};
|
|
65
|
+
exports.InformationPanelContent = InformationPanelContent;
|
|
66
|
+
exports.default = exports.InformationPanelContent;
|
|
@@ -8,3 +8,5 @@ export { InformationPanelHeader } from './InformationPanelHeader';
|
|
|
8
8
|
export type { InformationPanelHeaderProps } from './InformationPanelHeader';
|
|
9
9
|
export { InformationPanelBody } from './InformationPanelBody';
|
|
10
10
|
export type { InformationPanelBodyProps } from './InformationPanelBody';
|
|
11
|
+
export { InformationPanelContent } from './InformationPanelContent';
|
|
12
|
+
export type { InformationPanelContentProps } from './InformationPanelContent';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.InformationPanelBody = exports.InformationPanelHeader = exports.InformationPanelWrapper = exports.InformationPanel = void 0;
|
|
3
|
+
exports.InformationPanelContent = exports.InformationPanelBody = exports.InformationPanelHeader = exports.InformationPanelWrapper = exports.InformationPanel = void 0;
|
|
4
4
|
/*---------------------------------------------------------------------------------------------
|
|
5
5
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
6
6
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
@@ -14,3 +14,5 @@ var InformationPanelHeader_1 = require("./InformationPanelHeader");
|
|
|
14
14
|
Object.defineProperty(exports, "InformationPanelHeader", { enumerable: true, get: function () { return InformationPanelHeader_1.InformationPanelHeader; } });
|
|
15
15
|
var InformationPanelBody_1 = require("./InformationPanelBody");
|
|
16
16
|
Object.defineProperty(exports, "InformationPanelBody", { enumerable: true, get: function () { return InformationPanelBody_1.InformationPanelBody; } });
|
|
17
|
+
var InformationPanelContent_1 = require("./InformationPanelContent");
|
|
18
|
+
Object.defineProperty(exports, "InformationPanelContent", { enumerable: true, get: function () { return InformationPanelContent_1.InformationPanelContent; } });
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import '@itwin/itwinui-css/css/inputs.css';
|
|
3
|
+
declare type LabelOwnProps<T extends React.ElementType = 'label'> = {
|
|
4
|
+
/**
|
|
5
|
+
* What element should the label be rendered as?
|
|
6
|
+
* @default 'label'
|
|
7
|
+
*/
|
|
8
|
+
as?: T;
|
|
9
|
+
/**
|
|
10
|
+
* Set the display style of the label.
|
|
11
|
+
* - 'block' - default, no extra spacing (label and input will be on separate lines)
|
|
12
|
+
* - 'inline' - label gets a right margin so it can be placed inline
|
|
13
|
+
* @default 'block'
|
|
14
|
+
*/
|
|
15
|
+
displayStyle?: 'block' | 'inline';
|
|
16
|
+
/**
|
|
17
|
+
* Set to true if the label's associated input is required.
|
|
18
|
+
* This adds an asterisk next to the label text.
|
|
19
|
+
*/
|
|
20
|
+
required?: boolean;
|
|
21
|
+
};
|
|
22
|
+
export declare type LabelProps<T extends React.ElementType = 'label'> = LabelOwnProps<T> & Omit<React.ComponentPropsWithoutRef<T>, keyof LabelOwnProps<T>>;
|
|
23
|
+
/**
|
|
24
|
+
* A standalone label to be used with input components (using `htmlFor`).
|
|
25
|
+
* Can be rendered as any element, e.g. span, using the `as` prop.
|
|
26
|
+
* @example
|
|
27
|
+
* <Label htmlFor='name-input'>Name</Label>
|
|
28
|
+
* <Input id='name-input' />
|
|
29
|
+
*/
|
|
30
|
+
export declare const Label: <T extends React.ElementType<any> = "label">(props: LabelProps<T>) => JSX.Element;
|
|
31
|
+
export default Label;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
14
|
+
var t = {};
|
|
15
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
16
|
+
t[p] = s[p];
|
|
17
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
18
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
19
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
20
|
+
t[p[i]] = s[p[i]];
|
|
21
|
+
}
|
|
22
|
+
return t;
|
|
23
|
+
};
|
|
24
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
25
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
26
|
+
};
|
|
27
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
+
exports.Label = void 0;
|
|
29
|
+
/*---------------------------------------------------------------------------------------------
|
|
30
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
31
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
32
|
+
*--------------------------------------------------------------------------------------------*/
|
|
33
|
+
var react_1 = __importDefault(require("react"));
|
|
34
|
+
var classnames_1 = __importDefault(require("classnames"));
|
|
35
|
+
var utils_1 = require("../utils");
|
|
36
|
+
require("@itwin/itwinui-css/css/inputs.css");
|
|
37
|
+
/**
|
|
38
|
+
* A standalone label to be used with input components (using `htmlFor`).
|
|
39
|
+
* Can be rendered as any element, e.g. span, using the `as` prop.
|
|
40
|
+
* @example
|
|
41
|
+
* <Label htmlFor='name-input'>Name</Label>
|
|
42
|
+
* <Input id='name-input' />
|
|
43
|
+
*/
|
|
44
|
+
var Label = function (props) {
|
|
45
|
+
var _a = props.as, Element = _a === void 0 ? 'label' : _a, _b = props.displayStyle, displayStyle = _b === void 0 ? 'block' : _b, required = props.required, className = props.className, children = props.children, rest = __rest(props, ["as", "displayStyle", "required", "className", "children"]);
|
|
46
|
+
(0, utils_1.useTheme)();
|
|
47
|
+
return (react_1.default.createElement(Element, __assign({ className: (0, classnames_1.default)('iui-input-label', {
|
|
48
|
+
'iui-inline': displayStyle === 'inline',
|
|
49
|
+
'iui-required': required,
|
|
50
|
+
}, className) }, rest), children));
|
|
51
|
+
};
|
|
52
|
+
exports.Label = Label;
|
|
53
|
+
exports.default = exports.Label;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Label = void 0;
|
|
4
|
+
/*---------------------------------------------------------------------------------------------
|
|
5
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
6
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
7
|
+
*--------------------------------------------------------------------------------------------*/
|
|
8
|
+
var Label_1 = require("./Label");
|
|
9
|
+
Object.defineProperty(exports, "Label", { enumerable: true, get: function () { return Label_1.Label; } });
|
|
10
|
+
exports.default = './Label';
|
|
@@ -84,7 +84,7 @@ export declare const LabeledInput: React.ForwardRefExoticComponent<{
|
|
|
84
84
|
* - 'inline' - appears in the same line as input.
|
|
85
85
|
* @default 'default'
|
|
86
86
|
*/
|
|
87
|
-
displayStyle?: "
|
|
87
|
+
displayStyle?: "inline" | "default" | undefined;
|
|
88
88
|
/**
|
|
89
89
|
* Set display style of icon.
|
|
90
90
|
* Supported values:
|
|
@@ -93,7 +93,7 @@ export declare const LabeledInput: React.ForwardRefExoticComponent<{
|
|
|
93
93
|
*
|
|
94
94
|
* Defaults to 'block' if `displayStyle` is `default`, else 'inline'.
|
|
95
95
|
*/
|
|
96
|
-
iconDisplayStyle?: "
|
|
96
|
+
iconDisplayStyle?: "block" | "inline" | undefined;
|
|
97
97
|
} & {
|
|
98
98
|
setFocus?: boolean | undefined;
|
|
99
99
|
size?: "small" | "large" | undefined;
|
|
@@ -66,7 +66,7 @@ export declare const LabeledTextarea: React.ForwardRefExoticComponent<{
|
|
|
66
66
|
* Custom style for textarea.
|
|
67
67
|
*/
|
|
68
68
|
textareaStyle?: React.CSSProperties | undefined;
|
|
69
|
-
} & Pick<LabeledInputProps, "
|
|
69
|
+
} & Pick<LabeledInputProps, "displayStyle" | "svgIcon" | "iconDisplayStyle"> & {
|
|
70
70
|
setFocus?: boolean | undefined;
|
|
71
71
|
} & React.TextareaHTMLAttributes<HTMLTextAreaElement> & React.RefAttributes<HTMLTextAreaElement>>;
|
|
72
72
|
export default LabeledTextarea;
|
|
@@ -77,7 +77,7 @@ export declare const MenuItem: React.ForwardRefExoticComponent<{
|
|
|
77
77
|
*
|
|
78
78
|
* Defaults to 'large' if `sublabel` provided, otherwise 'default'.
|
|
79
79
|
*/
|
|
80
|
-
size?: "
|
|
80
|
+
size?: "default" | "large" | undefined;
|
|
81
81
|
/**
|
|
82
82
|
* Sub label shown below the main content of the item.
|
|
83
83
|
*/
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { CommonProps } from '../utils';
|
|
2
3
|
import '@itwin/itwinui-css/css/modal.css';
|
|
3
4
|
export declare type ModalButtonBarProps = {
|
|
4
5
|
/**
|
|
5
6
|
* Buttons in the modal bar.
|
|
6
7
|
*/
|
|
7
8
|
children: React.ReactNode;
|
|
8
|
-
}
|
|
9
|
+
} & Omit<CommonProps, 'title'>;
|
|
9
10
|
/**
|
|
10
11
|
* Container for Buttons in modal.
|
|
11
12
|
*/
|
|
@@ -31,15 +31,16 @@ exports.ModalButtonBar = void 0;
|
|
|
31
31
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
32
32
|
*--------------------------------------------------------------------------------------------*/
|
|
33
33
|
var react_1 = __importDefault(require("react"));
|
|
34
|
+
var classnames_1 = __importDefault(require("classnames"));
|
|
34
35
|
var utils_1 = require("../utils");
|
|
35
36
|
require("@itwin/itwinui-css/css/modal.css");
|
|
36
37
|
/**
|
|
37
38
|
* Container for Buttons in modal.
|
|
38
39
|
*/
|
|
39
40
|
var ModalButtonBar = function (props) {
|
|
40
|
-
var children = props.children, rest = __rest(props, ["children"]);
|
|
41
|
+
var children = props.children, className = props.className, rest = __rest(props, ["children", "className"]);
|
|
41
42
|
(0, utils_1.useTheme)();
|
|
42
|
-
return (react_1.default.createElement("div", __assign({ className: 'iui-button-bar' }, rest), children));
|
|
43
|
+
return (react_1.default.createElement("div", __assign({ className: (0, classnames_1.default)('iui-button-bar', className) }, rest), children));
|
|
43
44
|
};
|
|
44
45
|
exports.ModalButtonBar = ModalButtonBar;
|
|
45
46
|
exports.default = exports.ModalButtonBar;
|
|
@@ -147,6 +147,14 @@ export declare type TableProps<T extends Record<string, unknown> = Record<string
|
|
|
147
147
|
* @default 25
|
|
148
148
|
*/
|
|
149
149
|
pageSize?: number;
|
|
150
|
+
/**
|
|
151
|
+
* Flag whether columns are resizable.
|
|
152
|
+
* In order to disable resizing for specific column, set `disableResizing: true` for that column.
|
|
153
|
+
*
|
|
154
|
+
* If you want to use it in older browsers e.g. IE, then you need to have `ResizeObserver` polyfill.
|
|
155
|
+
* @default false
|
|
156
|
+
*/
|
|
157
|
+
isResizable?: boolean;
|
|
150
158
|
} & Omit<CommonProps, 'title'>;
|
|
151
159
|
/**
|
|
152
160
|
* Table based on [react-table](https://react-table.tanstack.com/docs/api/overview).
|
package/cjs/core/Table/Table.js
CHANGED
|
@@ -45,7 +45,10 @@ var customFilterFunctions_1 = require("./filters/customFilterFunctions");
|
|
|
45
45
|
var hooks_1 = require("./hooks");
|
|
46
46
|
var actionHandlers_1 = require("./actionHandlers");
|
|
47
47
|
var selectHandler_1 = require("./actionHandlers/selectHandler");
|
|
48
|
+
var resizeHandler_1 = require("./actionHandlers/resizeHandler");
|
|
48
49
|
var singleRowSelectedAction = 'singleRowSelected';
|
|
50
|
+
var tableResizeStartAction = 'tableResizeStart';
|
|
51
|
+
var tableResizeEndAction = 'tableResizeEnd';
|
|
49
52
|
/**
|
|
50
53
|
* Table based on [react-table](https://react-table.tanstack.com/docs/api/overview).
|
|
51
54
|
* @example
|
|
@@ -90,9 +93,9 @@ var singleRowSelectedAction = 'singleRowSelected';
|
|
|
90
93
|
*/
|
|
91
94
|
var Table = function (props) {
|
|
92
95
|
var _a;
|
|
93
|
-
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.isSortable, isSortable = _d === void 0 ? false : _d, onSort = props.onSort, stateReducer = props.stateReducer, onBottomReached = props.onBottomReached, onRowInViewport = props.onRowInViewport, _e = props.intersectionMargin, intersectionMargin = _e === void 0 ? 300 : _e, subComponent = props.subComponent, onExpand = props.onExpand, onFilter = props.onFilter, emptyFilteredTableContent = props.emptyFilteredTableContent, filterFunctions = props.filterTypes, expanderCell = props.expanderCell, isRowDisabled = props.isRowDisabled, rowProps = props.rowProps, _f = props.density, density = _f === void 0 ? 'default' : _f, _g = props.selectSubRows, selectSubRows = _g === void 0 ? true : _g, getSubRows = props.getSubRows, _h = props.selectRowOnClick, selectRowOnClick = _h === void 0 ? true : _h, paginatorRenderer = props.paginatorRenderer, _j = props.pageSize, pageSize = _j === void 0 ? 25 : _j, rest = __rest(props, ["data", "columns", "isLoading", "emptyTableContent", "className", "style", "id", "isSelectable", "onSelect", "onRowClick", "isSortable", "onSort", "stateReducer", "onBottomReached", "onRowInViewport", "intersectionMargin", "subComponent", "onExpand", "onFilter", "emptyFilteredTableContent", "filterTypes", "expanderCell", "isRowDisabled", "rowProps", "density", "selectSubRows", "getSubRows", "selectRowOnClick", "paginatorRenderer", "pageSize"]);
|
|
96
|
+
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.isSortable, isSortable = _d === void 0 ? false : _d, onSort = props.onSort, stateReducer = props.stateReducer, onBottomReached = props.onBottomReached, onRowInViewport = props.onRowInViewport, _e = props.intersectionMargin, intersectionMargin = _e === void 0 ? 300 : _e, subComponent = props.subComponent, onExpand = props.onExpand, onFilter = props.onFilter, emptyFilteredTableContent = props.emptyFilteredTableContent, filterFunctions = props.filterTypes, expanderCell = props.expanderCell, isRowDisabled = props.isRowDisabled, rowProps = props.rowProps, _f = props.density, density = _f === void 0 ? 'default' : _f, _g = props.selectSubRows, selectSubRows = _g === void 0 ? true : _g, getSubRows = props.getSubRows, _h = props.selectRowOnClick, selectRowOnClick = _h === void 0 ? true : _h, paginatorRenderer = props.paginatorRenderer, _j = props.pageSize, pageSize = _j === void 0 ? 25 : _j, _k = props.isResizable, isResizable = _k === void 0 ? false : _k, rest = __rest(props, ["data", "columns", "isLoading", "emptyTableContent", "className", "style", "id", "isSelectable", "onSelect", "onRowClick", "isSortable", "onSort", "stateReducer", "onBottomReached", "onRowInViewport", "intersectionMargin", "subComponent", "onExpand", "onFilter", "emptyFilteredTableContent", "filterTypes", "expanderCell", "isRowDisabled", "rowProps", "density", "selectSubRows", "getSubRows", "selectRowOnClick", "paginatorRenderer", "pageSize", "isResizable"]);
|
|
94
97
|
(0, utils_1.useTheme)();
|
|
95
|
-
var
|
|
98
|
+
var _l = react_1.default.useState(), ownerDocument = _l[0], setOwnerDocument = _l[1];
|
|
96
99
|
var defaultColumn = react_1.default.useMemo(function () { return ({
|
|
97
100
|
maxWidth: 0,
|
|
98
101
|
minWidth: 0,
|
|
@@ -127,6 +130,14 @@ var Table = function (props) {
|
|
|
127
130
|
(0, actionHandlers_1.onSelectHandler)(newState, instance, onSelect, isRowDisabled);
|
|
128
131
|
break;
|
|
129
132
|
}
|
|
133
|
+
case tableResizeStartAction: {
|
|
134
|
+
newState = (0, resizeHandler_1.onTableResizeStart)(newState);
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
case tableResizeEndAction: {
|
|
138
|
+
newState = (0, resizeHandler_1.onTableResizeEnd)(newState, action);
|
|
139
|
+
break;
|
|
140
|
+
}
|
|
130
141
|
default:
|
|
131
142
|
break;
|
|
132
143
|
}
|
|
@@ -140,8 +151,8 @@ var Table = function (props) {
|
|
|
140
151
|
return getSubRows ? getSubRows(item, index) : item.subRows;
|
|
141
152
|
});
|
|
142
153
|
}, [data, getSubRows]);
|
|
143
|
-
var instance = (0, react_table_1.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) }), react_table_1.useFlexLayout, react_table_1.useFilters, (0, hooks_1.useSubRowFiltering)(hasAnySubRows), react_table_1.useSortBy, react_table_1.useExpanded, react_table_1.usePagination, react_table_1.useRowSelect, hooks_1.useSubRowSelection, (0, hooks_1.useExpanderCell)(subComponent, expanderCell, isRowDisabled), (0, hooks_1.useSelectionCell)(isSelectable, isRowDisabled));
|
|
144
|
-
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;
|
|
154
|
+
var instance = (0, react_table_1.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) }), react_table_1.useFlexLayout, (0, hooks_1.useResizeColumns)(ownerDocument), react_table_1.useFilters, (0, hooks_1.useSubRowFiltering)(hasAnySubRows), react_table_1.useSortBy, react_table_1.useExpanded, react_table_1.usePagination, react_table_1.useRowSelect, hooks_1.useSubRowSelection, (0, hooks_1.useExpanderCell)(subComponent, expanderCell, isRowDisabled), (0, hooks_1.useSelectionCell)(isSelectable, isRowDisabled));
|
|
155
|
+
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;
|
|
145
156
|
var ariaDataAttributes = Object.entries(rest).reduce(function (result, _a) {
|
|
146
157
|
var key = _a[0], value = _a[1];
|
|
147
158
|
if (key.startsWith('data-') || key.startsWith('aria-')) {
|
|
@@ -187,8 +198,46 @@ var Table = function (props) {
|
|
|
187
198
|
state.pageIndex,
|
|
188
199
|
state.pageSize,
|
|
189
200
|
]);
|
|
201
|
+
var columnRefs = react_1.default.useRef({});
|
|
202
|
+
var previousTableWidth = react_1.default.useRef(0);
|
|
203
|
+
var onTableResize = react_1.default.useCallback(function (_a) {
|
|
204
|
+
var width = _a.width;
|
|
205
|
+
if (width === previousTableWidth.current) {
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
previousTableWidth.current = width;
|
|
209
|
+
// Update column widths when table was resized
|
|
210
|
+
flatHeaders.forEach(function (header) {
|
|
211
|
+
if (columnRefs.current[header.id]) {
|
|
212
|
+
header.resizeWidth = columnRefs.current[header.id].getBoundingClientRect().width;
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
// If no column was resized then leave table resize handling to the flexbox
|
|
216
|
+
if (Object.keys(state.columnResizing.columnWidths).length === 0) {
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
dispatch({ type: tableResizeStartAction });
|
|
220
|
+
}, [dispatch, state.columnResizing.columnWidths, flatHeaders]);
|
|
221
|
+
var resizeRef = (0, utils_1.useResizeObserver)(onTableResize)[0];
|
|
222
|
+
// Flexbox handles columns resize so we take new column widths before browser repaints.
|
|
223
|
+
react_1.default.useLayoutEffect(function () {
|
|
224
|
+
if (state.isTableResizing) {
|
|
225
|
+
var newColumnWidths_1 = {};
|
|
226
|
+
flatHeaders.forEach(function (column) {
|
|
227
|
+
if (columnRefs.current[column.id]) {
|
|
228
|
+
newColumnWidths_1[column.id] = columnRefs.current[column.id].getBoundingClientRect().width;
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
dispatch({ type: tableResizeEndAction, columnWidths: newColumnWidths_1 });
|
|
232
|
+
}
|
|
233
|
+
});
|
|
190
234
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
191
|
-
react_1.default.createElement("div", __assign({ ref: function (element) {
|
|
235
|
+
react_1.default.createElement("div", __assign({ ref: function (element) {
|
|
236
|
+
setOwnerDocument(element === null || element === void 0 ? void 0 : element.ownerDocument);
|
|
237
|
+
if (isResizable) {
|
|
238
|
+
resizeRef(element);
|
|
239
|
+
}
|
|
240
|
+
}, id: id }, getTableProps({
|
|
192
241
|
className: (0, classnames_1.default)('iui-table', (_a = {}, _a["iui-" + density] = density !== 'default', _a), className),
|
|
193
242
|
style: style,
|
|
194
243
|
}), ariaDataAttributes),
|
|
@@ -196,15 +245,27 @@ var Table = function (props) {
|
|
|
196
245
|
var headerGroupProps = headerGroup.getHeaderGroupProps({
|
|
197
246
|
className: 'iui-row',
|
|
198
247
|
});
|
|
199
|
-
return (react_1.default.createElement("div", __assign({}, headerGroupProps, { key: headerGroupProps.key }), headerGroup.headers.map(function (column) {
|
|
200
|
-
var
|
|
201
|
-
|
|
248
|
+
return (react_1.default.createElement("div", __assign({}, headerGroupProps, { key: headerGroupProps.key }), headerGroup.headers.map(function (column, index) {
|
|
249
|
+
var _a = column.getSortByToggleProps(), onSortClick = _a.onClick, sortByProps = __rest(_a, ["onClick"]);
|
|
250
|
+
var columnProps = column.getHeaderProps(__assign(__assign({}, sortByProps), { className: (0, classnames_1.default)('iui-cell', { 'iui-actionable': column.canSort }, { 'iui-sorted': column.isSorted }, column.columnClassName), style: __assign({}, (0, utils_2.getCellStyle)(column, !!state.isTableResizing)) }));
|
|
251
|
+
return (react_1.default.createElement("div", __assign({}, columnProps, { key: columnProps.key, title: undefined, ref: function (el) {
|
|
252
|
+
if (el && isResizable) {
|
|
253
|
+
columnRefs.current[column.id] = el;
|
|
254
|
+
column.resizeWidth = el.getBoundingClientRect().width;
|
|
255
|
+
}
|
|
256
|
+
}, onMouseDown: onSortClick }),
|
|
202
257
|
column.render('Header'),
|
|
203
258
|
!isLoading && (data.length != 0 || areFiltersSet) && (react_1.default.createElement(filters_1.FilterToggle, { column: column, ownerDocument: ownerDocument })),
|
|
204
|
-
!isLoading && data.length != 0 && column.canSort && (react_1.default.createElement("div", { className: 'iui-cell-end-icon' }, column.isSorted && column.isSortedDesc ? (react_1.default.createElement(SortUp_1.default, { className: 'iui-icon iui-sort', "aria-hidden": true })) : (react_1.default.createElement(SortDown_1.default, { className: 'iui-icon iui-sort', "aria-hidden": true }))))
|
|
259
|
+
!isLoading && data.length != 0 && column.canSort && (react_1.default.createElement("div", { className: 'iui-cell-end-icon' }, column.isSorted && column.isSortedDesc ? (react_1.default.createElement(SortUp_1.default, { className: 'iui-icon iui-sort', "aria-hidden": true })) : (react_1.default.createElement(SortDown_1.default, { className: 'iui-icon iui-sort', "aria-hidden": true })))),
|
|
260
|
+
isResizable &&
|
|
261
|
+
column.isResizerVisible &&
|
|
262
|
+
index !== headerGroup.headers.length - 1 && (react_1.default.createElement("div", __assign({}, column.getResizerProps(), { className: 'iui-resizer' }),
|
|
263
|
+
react_1.default.createElement("div", { className: 'iui-resizer-bar' })))));
|
|
205
264
|
})));
|
|
206
265
|
})),
|
|
207
|
-
react_1.default.createElement("div", __assign({}, getTableBodyProps({
|
|
266
|
+
react_1.default.createElement("div", __assign({}, getTableBodyProps({
|
|
267
|
+
className: 'iui-table-body',
|
|
268
|
+
})),
|
|
208
269
|
data.length !== 0 &&
|
|
209
270
|
page.map(function (row) {
|
|
210
271
|
prepareRow(row);
|
|
@@ -41,7 +41,7 @@ var TableCell = function (props) {
|
|
|
41
41
|
};
|
|
42
42
|
var cellElementProps = cell.getCellProps({
|
|
43
43
|
className: (0, classnames_1.default)('iui-cell', cell.column.cellClassName),
|
|
44
|
-
style: __assign(__assign({}, (0, utils_1.getCellStyle)(cell.column)), getSubRowStyle()),
|
|
44
|
+
style: __assign(__assign({}, (0, utils_1.getCellStyle)(cell.column, !!tableInstance.state.isTableResizing)), getSubRowStyle()),
|
|
45
45
|
});
|
|
46
46
|
var cellProps = __assign(__assign({}, tableInstance), { cell: cell, row: cell.row, value: cell.value, column: cell.column });
|
|
47
47
|
var cellContent = (react_1.default.createElement(react_1.default.Fragment, null,
|
|
@@ -30,12 +30,7 @@ export declare type TablePaginatorProps = {
|
|
|
30
30
|
/**
|
|
31
31
|
* Function that returns a label for the range of rows within the current page and the length of the whole data.
|
|
32
32
|
* @default
|
|
33
|
-
* (
|
|
34
|
-
* startIndex: number,
|
|
35
|
-
* endIndex: number,
|
|
36
|
-
* totalRows: number,
|
|
37
|
-
* isLoading: boolean,
|
|
38
|
-
* ) =>
|
|
33
|
+
* (startIndex, endIndex, totalRows, isLoading) =>
|
|
39
34
|
* isLoading
|
|
40
35
|
* ? `${startIndex}-${endIndex}…`
|
|
41
36
|
* : `${startIndex}-${endIndex} of ${totalRows}`;
|
|
@@ -56,6 +51,11 @@ export declare type TablePaginatorProps = {
|
|
|
56
51
|
* @default (page: number) => `Go to page ${page}`
|
|
57
52
|
*/
|
|
58
53
|
goToPageLabel?: (page: number) => string;
|
|
54
|
+
/**
|
|
55
|
+
* A label shown next to the page size selector. Use `null` to hide.
|
|
56
|
+
* @default 'Rows per page'
|
|
57
|
+
*/
|
|
58
|
+
rowsPerPageLabel?: string | null;
|
|
59
59
|
};
|
|
60
60
|
} & TablePaginatorRendererProps & Omit<CommonProps, 'title'>;
|
|
61
61
|
/**
|
|
@@ -67,5 +67,5 @@ export declare type TablePaginatorProps = {
|
|
|
67
67
|
* paginatorRenderer={(props) => <TablePaginator {...props} />}
|
|
68
68
|
* />
|
|
69
69
|
*/
|
|
70
|
-
export declare const TablePaginator: (props: TablePaginatorProps) => JSX.Element;
|
|
70
|
+
export declare const TablePaginator: (props: TablePaginatorProps) => JSX.Element | null;
|
|
71
71
|
export default TablePaginator;
|
|
@@ -50,6 +50,7 @@ var defaultLocalization = {
|
|
|
50
50
|
previousPage: 'Previous page',
|
|
51
51
|
nextPage: 'Next page',
|
|
52
52
|
goToPageLabel: function (page) { return "Go to page " + page; },
|
|
53
|
+
rowsPerPageLabel: 'Rows per page',
|
|
53
54
|
};
|
|
54
55
|
/**
|
|
55
56
|
* Table paginator component. Recommended to pass to the `Table` as `paginatorRenderer` prop.
|
|
@@ -94,6 +95,7 @@ var TablePaginator = function (props) {
|
|
|
94
95
|
.map(function (_, index) { return pageButton(index); });
|
|
95
96
|
}, [pageButton, totalPagesCount]);
|
|
96
97
|
var _e = (0, utils_1.useOverflow)(pageList), overflowRef = _e[0], visibleCount = _e[1];
|
|
98
|
+
var _f = (0, utils_1.useContainerWidth)(), paginatorResizeRef = _f[0], paginatorWidth = _f[1];
|
|
97
99
|
var onKeyDown = function (event) {
|
|
98
100
|
// alt + arrow keys are used by browser/assistive technologies
|
|
99
101
|
if (event.altKey) {
|
|
@@ -144,12 +146,17 @@ var TablePaginator = function (props) {
|
|
|
144
146
|
endPage = totalPagesCount;
|
|
145
147
|
}
|
|
146
148
|
var hasNoRows = totalPagesCount === 0;
|
|
149
|
+
var showPagesList = totalPagesCount > 1 || isLoading;
|
|
150
|
+
var showPageSizeList = pageSizeList && onPageSizeChange && !!totalRowsCount;
|
|
147
151
|
var ellipsis = (react_1.default.createElement("span", { className: (0, classnames_1.default)('iui-ellipsis', { 'iui-small': size === 'small' }) }, "\u2026"));
|
|
148
152
|
var noRowsContent = (react_1.default.createElement(react_1.default.Fragment, null, isLoading ? (react_1.default.createElement(ProgressIndicators_1.ProgressRadial, { indeterminate: true, size: 'small' })) : (react_1.default.createElement(Buttons_1.Button, { styleType: 'borderless', disabled: true, size: buttonSize }, "1"))));
|
|
149
|
-
|
|
153
|
+
if (!showPagesList && !showPageSizeList) {
|
|
154
|
+
return null;
|
|
155
|
+
}
|
|
156
|
+
return (react_1.default.createElement("div", __assign({ className: (0, classnames_1.default)('iui-paginator', className), ref: paginatorResizeRef }, rest),
|
|
150
157
|
react_1.default.createElement("div", { className: 'iui-left' }),
|
|
151
|
-
react_1.default.createElement("div", { className: 'iui-center', ref: overflowRef },
|
|
152
|
-
react_1.default.createElement(Buttons_1.IconButton, { styleType: 'borderless', disabled: currentPage === 0
|
|
158
|
+
showPagesList && (react_1.default.createElement("div", { className: 'iui-center', ref: overflowRef },
|
|
159
|
+
react_1.default.createElement(Buttons_1.IconButton, { styleType: 'borderless', disabled: currentPage === 0, onClick: function () { return onPageChange(currentPage - 1); }, size: buttonSize, "aria-label": localization.previousPage },
|
|
153
160
|
react_1.default.createElement(ChevronLeft_1.default, null)),
|
|
154
161
|
react_1.default.createElement(ButtonGroup_1.ButtonGroup, { onKeyDown: onKeyDown, ref: pageListRef }, (function () {
|
|
155
162
|
if (hasNoRows) {
|
|
@@ -171,13 +178,16 @@ var TablePaginator = function (props) {
|
|
|
171
178
|
react_1.default.createElement(ProgressIndicators_1.ProgressRadial, { indeterminate: true, size: 'small' })))));
|
|
172
179
|
})()),
|
|
173
180
|
react_1.default.createElement(Buttons_1.IconButton, { styleType: 'borderless', disabled: currentPage === totalPagesCount - 1 || hasNoRows, onClick: function () { return onPageChange(currentPage + 1); }, size: buttonSize, "aria-label": localization.nextPage },
|
|
174
|
-
react_1.default.createElement(ChevronRight_1.default, null))),
|
|
175
|
-
react_1.default.createElement("div", { className: 'iui-right' },
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
+
react_1.default.createElement(ChevronRight_1.default, null)))),
|
|
182
|
+
react_1.default.createElement("div", { className: 'iui-right' }, showPageSizeList && (react_1.default.createElement(react_1.default.Fragment, null,
|
|
183
|
+
localization.rowsPerPageLabel !== null &&
|
|
184
|
+
paginatorWidth >= 1024 && (react_1.default.createElement("span", { className: 'iui-paginator-page-size-label' }, localization.rowsPerPageLabel)),
|
|
185
|
+
react_1.default.createElement(Buttons_1.DropdownButton, { styleType: 'borderless', size: buttonSize, menuItems: function (close) {
|
|
186
|
+
return pageSizeList.map(function (size) { return (react_1.default.createElement(Menu_1.MenuItem, { key: size, isSelected: size === pageSize, onClick: function () {
|
|
187
|
+
close();
|
|
188
|
+
onPageSizeChange(size);
|
|
189
|
+
} }, localization.pageSizeLabel(size))); });
|
|
190
|
+
} }, localization.rangeLabel(currentPage * pageSize + 1, Math.min(totalRowsCount, (currentPage + 1) * pageSize), totalRowsCount, isLoading)))))));
|
|
181
191
|
};
|
|
182
192
|
exports.TablePaginator = TablePaginator;
|
|
183
193
|
exports.default = exports.TablePaginator;
|
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { CellProps, Row, TableInstance, TableState } from 'react-table';
|
|
3
|
+
/**
|
|
4
|
+
* Memoization is needed to avoid unnecessary re-renders of all rows when additional data is added when lazy-loading.
|
|
5
|
+
* Using `isLast` here instead of passing data length to avoid re-renders of all rows when more data is added. Now only the last row re-renders.
|
|
6
|
+
* Although state is not used it is needed for `React.memo` to check state that changes row state e.g. selection.
|
|
7
|
+
* When adding new features check whether it changes state that affects row. If it does then add equality check to `React.memo`.
|
|
8
|
+
*/
|
|
9
|
+
export declare const TableRow: <T extends Record<string, unknown>>(props: {
|
|
10
|
+
row: Row<T>;
|
|
11
|
+
rowProps?: ((row: Row<T>) => React.ComponentPropsWithRef<'div'>) | undefined;
|
|
12
|
+
isLast: boolean;
|
|
13
|
+
onRowInViewport: React.MutableRefObject<((rowData: T) => void) | undefined>;
|
|
14
|
+
onBottomReached: React.MutableRefObject<(() => void) | undefined>;
|
|
15
|
+
intersectionMargin: number;
|
|
16
|
+
state: TableState<T>;
|
|
17
|
+
onClick?: ((event: React.MouseEvent, row: Row<T>) => void) | undefined;
|
|
18
|
+
subComponent?: ((row: Row<T>) => React.ReactNode) | undefined;
|
|
19
|
+
isDisabled: boolean;
|
|
20
|
+
tableHasSubRows: boolean;
|
|
21
|
+
tableInstance: TableInstance<T>;
|
|
22
|
+
expanderCell?: ((cellProps: CellProps<T, any>) => React.ReactNode) | undefined;
|
|
23
|
+
}) => JSX.Element;
|
|
3
24
|
export declare const TableRowMemoized: <T extends Record<string, unknown>>(props: {
|
|
4
25
|
row: Row<T>;
|
|
5
26
|
rowProps?: ((row: Row<T>) => React.ComponentPropsWithRef<'div'>) | undefined;
|