@itwin/itwinui-react 1.26.1 → 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 +15 -0
- 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/ComboBox/ComboBox.d.ts +2 -2
- package/cjs/core/ErrorPage/ErrorPage.d.ts +2 -1
- package/cjs/core/ErrorPage/ErrorPage.js +3 -2
- 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 +6 -6
- package/cjs/core/Table/TablePaginator.js +12 -7
- 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 +2 -2
- package/cjs/types/react-table-config.d.ts +16 -3
- 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/ComboBox/ComboBox.d.ts +2 -2
- package/esm/core/ErrorPage/ErrorPage.d.ts +2 -1
- package/esm/core/ErrorPage/ErrorPage.js +3 -2
- 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 +6 -6
- package/esm/core/Table/TablePaginator.js +13 -8
- 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 +2 -2
- package/esm/types/react-table-config.d.ts +16 -3
- package/package.json +13 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.27.0](https://www.github.com/iTwin/iTwinUI-react/compare/v1.26.1...v1.27.0) (2021-12-14)
|
|
4
|
+
|
|
5
|
+
### What's new
|
|
6
|
+
|
|
7
|
+
* **Checkbox:** Add visibility (eyeball) checkbox using `variant` prop ([#470](https://www.github.com/iTwin/iTwinUI-react/issues/470)) ([cda4416](https://www.github.com/iTwin/iTwinUI-react/commit/cda44162a5b40686228c542ab0251b6861dd8359))
|
|
8
|
+
* **ComboBox:** Add `status` prop ([#473](https://www.github.com/iTwin/iTwinUI-react/issues/473)) ([8f5f098](https://www.github.com/iTwin/iTwinUI-react/commit/8f5f09804a541cab8c2add6417e57b9693e69714))
|
|
9
|
+
* **Table:** Add `rowsPerPageLabel` to paginator localization ([#427](https://www.github.com/iTwin/iTwinUI-react/issues/427)) ([52d5c86](https://www.github.com/iTwin/iTwinUI-react/commit/52d5c86efc569238221a7e39cad2d17636c7f9b8))
|
|
10
|
+
* **Table:** Added column resizing using `isResizable` prop ([#448](https://www.github.com/iTwin/iTwinUI-react/issues/448)) ([4c25fe1](https://www.github.com/iTwin/iTwinUI-react/commit/4c25fe1ec5de8f2f6bf771c4adf11bc6ad5e0dd2))
|
|
11
|
+
* **Tabs:** Add `wrapperClassName` prop ([#451](https://www.github.com/iTwin/iTwinUI-react/issues/451)) ([574480a](https://www.github.com/iTwin/iTwinUI-react/commit/574480a8cd7cc92b95a79d2d53ddae0b39d6c5f5))
|
|
12
|
+
|
|
13
|
+
### Fixes
|
|
14
|
+
|
|
15
|
+
* **ErrorPage:** Add `className` and `style` props ([#479](https://www.github.com/iTwin/iTwinUI-react/issues/479)) ([74f9060](https://www.github.com/iTwin/iTwinUI-react/commit/74f906058b12adb85f2653a0b4e7a1d808df1ef5))
|
|
16
|
+
* **ModalButtonBar:** Add `className` and `style` props ([#474](https://www.github.com/iTwin/iTwinUI-react/issues/474)) ([2228cc7](https://www.github.com/iTwin/iTwinUI-react/commit/2228cc7ad56c5f1a104abb93b33107af30de62c9))
|
|
17
|
+
|
|
3
18
|
### [1.26.1](https://www.github.com/iTwin/iTwinUI-react/compare/v1.26.0...v1.26.1) (2021-12-03)
|
|
4
19
|
|
|
5
20
|
### Fixes
|
|
@@ -47,18 +47,17 @@ exports.Button = react_1.default.forwardRef(function (props, ref) {
|
|
|
47
47
|
var _a;
|
|
48
48
|
var children = props.children, className = props.className, size = props.size, style = props.style, _b = props.styleType, styleType = _b === void 0 ? 'default' : _b, _c = props.type, type = _c === void 0 ? 'button' : _c, startIcon = props.startIcon, endIcon = props.endIcon, rest = __rest(props, ["children", "className", "size", "style", "styleType", "type", "startIcon", "endIcon"]);
|
|
49
49
|
(0, utils_1.useTheme)();
|
|
50
|
-
return (react_1.default.createElement("button", __assign({ ref: ref, className: (0, classnames_1.default)('iui-button', (_a = {},
|
|
50
|
+
return (react_1.default.createElement("button", __assign({ ref: ref, className: (0, classnames_1.default)('iui-button', "iui-" + styleType, (_a = {},
|
|
51
51
|
_a["iui-" + size] = !!size,
|
|
52
|
-
_a["iui-" + styleType] = styleType !== 'default',
|
|
53
52
|
_a), className), style: style, type: type }, rest),
|
|
54
53
|
startIcon &&
|
|
55
54
|
react_1.default.cloneElement(startIcon, {
|
|
56
|
-
className: (0, classnames_1.default)('iui-icon', startIcon.props.className),
|
|
55
|
+
className: (0, classnames_1.default)('iui-button-icon', startIcon.props.className),
|
|
57
56
|
}),
|
|
58
|
-
children && react_1.default.createElement("span", { className: 'iui-label' }, children),
|
|
57
|
+
children && react_1.default.createElement("span", { className: 'iui-button-label' }, children),
|
|
59
58
|
endIcon &&
|
|
60
59
|
react_1.default.cloneElement(endIcon, {
|
|
61
|
-
className: (0, classnames_1.default)('iui-icon', endIcon.props.className),
|
|
60
|
+
className: (0, classnames_1.default)('iui-button-icon', endIcon.props.className),
|
|
62
61
|
})));
|
|
63
62
|
});
|
|
64
63
|
exports.default = exports.Button;
|
|
@@ -44,12 +44,11 @@ exports.IconButton = react_1.default.forwardRef(function (props, ref) {
|
|
|
44
44
|
var _a;
|
|
45
45
|
var isActive = props.isActive, children = props.children, _b = props.styleType, styleType = _b === void 0 ? 'default' : _b, size = props.size, _c = props.type, type = _c === void 0 ? 'button' : _c, className = props.className, rest = __rest(props, ["isActive", "children", "styleType", "size", "type", "className"]);
|
|
46
46
|
(0, utils_1.useTheme)();
|
|
47
|
-
return (react_1.default.createElement("button", __assign({ ref: ref, className: (0, classnames_1.default)('iui-button', (_a = {},
|
|
47
|
+
return (react_1.default.createElement("button", __assign({ ref: ref, className: (0, classnames_1.default)('iui-button', "iui-" + styleType, (_a = {},
|
|
48
48
|
_a["iui-" + size] = !!size,
|
|
49
|
-
_a["iui-" + styleType] = styleType !== 'default',
|
|
50
49
|
_a['iui-active'] = isActive,
|
|
51
50
|
_a), className), type: type }, rest), react_1.default.cloneElement(children, {
|
|
52
|
-
className: (0, classnames_1.default)('iui-icon', children.props.className),
|
|
51
|
+
className: (0, classnames_1.default)('iui-button-icon', children.props.className),
|
|
53
52
|
'aria-hidden': true,
|
|
54
53
|
})));
|
|
55
54
|
});
|
|
@@ -14,6 +14,11 @@ export declare type CheckboxProps = {
|
|
|
14
14
|
* Status of checkbox.
|
|
15
15
|
*/
|
|
16
16
|
status?: 'positive' | 'warning' | 'negative';
|
|
17
|
+
/**
|
|
18
|
+
* Type of checkbox, regular or eyeball checkbox that is used for visibility.
|
|
19
|
+
* @default 'default'
|
|
20
|
+
*/
|
|
21
|
+
variant?: 'default' | 'eyeball';
|
|
17
22
|
/**
|
|
18
23
|
* Set focus on checkbox.
|
|
19
24
|
*/
|
|
@@ -41,6 +46,7 @@ export declare type CheckboxProps = {
|
|
|
41
46
|
* <Checkbox label='Positive Checkbox' status='positive' />
|
|
42
47
|
* <Checkbox label='Warning Checkbox' status='warning' />
|
|
43
48
|
* <Checkbox label='Negative Checkbox' status='negative' />
|
|
49
|
+
* <Checkbox label='Visibility Checkbox' variant='eyeball' />
|
|
44
50
|
*/
|
|
45
51
|
export declare const Checkbox: React.ForwardRefExoticComponent<{
|
|
46
52
|
/**
|
|
@@ -56,6 +62,11 @@ export declare const Checkbox: React.ForwardRefExoticComponent<{
|
|
|
56
62
|
* Status of checkbox.
|
|
57
63
|
*/
|
|
58
64
|
status?: "positive" | "warning" | "negative" | undefined;
|
|
65
|
+
/**
|
|
66
|
+
* Type of checkbox, regular or eyeball checkbox that is used for visibility.
|
|
67
|
+
* @default 'default'
|
|
68
|
+
*/
|
|
69
|
+
variant?: "default" | "eyeball" | undefined;
|
|
59
70
|
/**
|
|
60
71
|
* Set focus on checkbox.
|
|
61
72
|
*/
|
|
@@ -44,10 +44,11 @@ require("@itwin/itwinui-css/css/inputs.css");
|
|
|
44
44
|
* <Checkbox label='Positive Checkbox' status='positive' />
|
|
45
45
|
* <Checkbox label='Warning Checkbox' status='warning' />
|
|
46
46
|
* <Checkbox label='Negative Checkbox' status='negative' />
|
|
47
|
+
* <Checkbox label='Visibility Checkbox' variant='eyeball' />
|
|
47
48
|
*/
|
|
48
49
|
exports.Checkbox = react_1.default.forwardRef(function (props, ref) {
|
|
49
50
|
var _a;
|
|
50
|
-
var className = props.className, _b = props.disabled, disabled = _b === void 0 ? false : _b, _c = props.indeterminate, indeterminate = _c === void 0 ? false : _c, label = props.label, status = props.status, setFocus = props.setFocus,
|
|
51
|
+
var className = props.className, _b = props.disabled, disabled = _b === void 0 ? false : _b, _c = props.indeterminate, indeterminate = _c === void 0 ? false : _c, label = props.label, status = props.status, _d = props.variant, variant = _d === void 0 ? 'default' : _d, setFocus = props.setFocus, _e = props.isLoading, isLoading = _e === void 0 ? false : _e, style = props.style, checkmarkClassName = props.checkmarkClassName, checkmarkStyle = props.checkmarkStyle, rest = __rest(props, ["className", "disabled", "indeterminate", "label", "status", "variant", "setFocus", "isLoading", "style", "checkmarkClassName", "checkmarkStyle"]);
|
|
51
52
|
(0, utils_1.useTheme)();
|
|
52
53
|
var inputElementRef = react_1.default.useRef(null);
|
|
53
54
|
var refs = (0, utils_1.useMergedRefs)(inputElementRef, ref);
|
|
@@ -64,18 +65,27 @@ exports.Checkbox = react_1.default.forwardRef(function (props, ref) {
|
|
|
64
65
|
: inputElementRef.current.checked;
|
|
65
66
|
}
|
|
66
67
|
});
|
|
68
|
+
var defaultCheckbox = (react_1.default.createElement("svg", { viewBox: '0 0 16 16', "aria-hidden": 'true', focusable: 'false' },
|
|
69
|
+
react_1.default.createElement("path", { className: 'iui-check', d: 'M6,14L0,8l2-2l4,4l8-8l2,2L6,14z' }),
|
|
70
|
+
react_1.default.createElement("path", { className: 'iui-check-partial', d: 'm1 6.5h14v3h-14z' })));
|
|
71
|
+
var visibilityCheckbox = (react_1.default.createElement("svg", { viewBox: '0 0 16 16', "aria-hidden": 'true', focusable: 'false' },
|
|
72
|
+
react_1.default.createElement("path", { className: 'iui-check', d: 'm8 2.99051a8.81883 8.81883 0 0 0 -8 4.95062 8.74664 8.74664 0 0 0 8 5.06836 8.63266 8.63266 0 0 0 8-5.06836 8.83631 8.83631 0 0 0 -8-4.95062zm-1.31445 1.86981a1.47663 1.47663 0 1 1 -1.47663 1.47668 1.47665 1.47665 0 0 1 1.47663-1.47668zm1.31445 6.64917a7.17486 7.17486 0 0 1 -6.30475-3.55237 7.4952 7.4952 0 0 1 2.81475-2.6336 3.83956 3.83956 0 1 0 6.98126.00244 7.522 7.522 0 0 1 2.81774 2.63916 7.09785 7.09785 0 0 1 -6.309 3.54437z' }),
|
|
73
|
+
react_1.default.createElement("g", { className: 'iui-check-partial' },
|
|
74
|
+
react_1.default.createElement("path", { d: 'm8 3v7.9a4.01179 4.01179 0 0 0 4-4 6.7509 6.7509 0 0 0 -.2-1.4l.1.1a6.89429 6.89429 0 0 1 2.4 2.4 8.39088 8.39088 0 0 1 -2.3 2.3 6.89412 6.89412 0 0 1 -3.9 1.2c-.03345 0-.06653-.00677-.1-.0072v1.5072a8.90686 8.90686 0 0 0 8-5 8.90686 8.90686 0 0 0 -8-5z', opacity: '.33' }),
|
|
75
|
+
react_1.default.createElement("path", { d: 'm8 0a1 1 0 0 0 -1 1v2.07135a8.91637 8.91637 0 0 0 -7 4.92865 8.91637 8.91637 0 0 0 7 4.92865v2.07135a1 1 0 0 0 2 0v-14a1 1 0 0 0 -1-1zm-1.5 4.9a1.55426 1.55426 0 0 1 .5.087v2.81451a1.40746 1.40746 0 0 1 -.5.09849 1.538 1.538 0 0 1 -1.5-1.5 1.53794 1.53794 0 0 1 1.5-1.5zm-2.3 5.4a6.97279 6.97279 0 0 1 -2.5-2.3 6.89429 6.89429 0 0 1 2.4-2.4c.1 0 .1-.1.2-.1a3.194 3.194 0 0 0 -.3 1.4 4.0047 4.0047 0 0 0 3 3.857v.65289a6.37491 6.37491 0 0 1 -2.8-1.10989z' })),
|
|
76
|
+
react_1.default.createElement("path", { className: 'iui-uncheck', d: 'm1.70671 12.879 11.17218-11.17219 1.4142 1.4142-11.17218 11.17218zm.99329-1.679 1.1-1.1a5.06317 5.06317 0 0 1 -2-2.1 7.48268 7.48268 0 0 1 6.2-3.5 4.86877 4.86877 0 0 1 1.2.1l1.3-1.3a10.07431 10.07431 0 0 0 -2.5-.3 8.84129 8.84129 0 0 0 -8 5 8.42455 8.42455 0 0 0 2.7 3.2zm10.7-6.4-1.1 1.1a7.08625 7.08625 0 0 1 2 2.1 7.50323 7.50323 0 0 1 -6.2 3.5 8.31665 8.31665 0 0 1 -1.3-.2l-1.3 1.3a8.909 8.909 0 0 0 6.4-.5 9.04344 9.04344 0 0 0 4.1-4.1 9.168 9.168 0 0 0 -2.6-3.2z' })));
|
|
67
77
|
return (react_1.default.createElement("label", { className: (0, classnames_1.default)('iui-checkbox', (_a = {
|
|
68
78
|
'iui-disabled': disabled
|
|
69
79
|
},
|
|
70
80
|
_a["iui-" + status] = !!status,
|
|
71
81
|
_a['iui-loading'] = isLoading,
|
|
82
|
+
_a['iui-checkbox-visibility'] = variant === 'eyeball',
|
|
72
83
|
_a), className), style: style },
|
|
73
84
|
react_1.default.createElement("input", __assign({ disabled: disabled || isLoading, type: 'checkbox', ref: refs }, rest)),
|
|
74
85
|
react_1.default.createElement("span", { className: (0, classnames_1.default)('iui-checkbox-checkmark', checkmarkClassName), style: checkmarkStyle },
|
|
75
86
|
isLoading && react_1.default.createElement(ProgressIndicators_1.ProgressRadial, { indeterminate: true }),
|
|
76
|
-
!isLoading &&
|
|
77
|
-
|
|
78
|
-
react_1.default.createElement("path", { className: 'iui-check-partial', d: 'm1 6.5h14v3h-14z' })))),
|
|
87
|
+
!isLoading &&
|
|
88
|
+
(variant === 'default' ? defaultCheckbox : visibilityCheckbox)),
|
|
79
89
|
label && react_1.default.createElement("span", { className: 'iui-label' }, label)));
|
|
80
90
|
});
|
|
81
91
|
exports.default = exports.Checkbox;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { InputProps } from '../Input';
|
|
3
3
|
import { SelectOption } from '../Select';
|
|
4
|
-
import { PopoverProps, CommonProps } from '../utils';
|
|
4
|
+
import { PopoverProps, CommonProps, InputContainerProps } from '../utils';
|
|
5
5
|
import 'tippy.js/animations/shift-away.css';
|
|
6
6
|
export declare type ComboBoxProps<T> = {
|
|
7
7
|
/**
|
|
@@ -33,7 +33,7 @@ export declare type ComboBoxProps<T> = {
|
|
|
33
33
|
* @default 'No options found'
|
|
34
34
|
*/
|
|
35
35
|
emptyStateMessage?: string;
|
|
36
|
-
} & Omit<CommonProps, 'title'>;
|
|
36
|
+
} & Pick<InputContainerProps, 'status'> & Omit<CommonProps, 'title'>;
|
|
37
37
|
/**
|
|
38
38
|
* ComboBox component that allows typing a value to filter the options in dropdown list.
|
|
39
39
|
* Values can be selected either using mouse clicks or using the Enter key.
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { CommonProps } from '../utils';
|
|
2
3
|
import '@itwin/itwinui-css/css/non-ideal-state.css';
|
|
3
4
|
export declare type ErrorPageType = '401' | '403' | '404' | '500' | '502' | '503' | 'generic';
|
|
4
5
|
export declare type ErrorTypeTranslations = {
|
|
@@ -45,7 +46,7 @@ export declare type ErrorPageProps = {
|
|
|
45
46
|
* Used to translate default error messages, if no specific @errorName passed in
|
|
46
47
|
*/
|
|
47
48
|
translatedErrorMessages?: ErrorTypeTranslations;
|
|
48
|
-
}
|
|
49
|
+
} & Omit<CommonProps, 'title'>;
|
|
49
50
|
/**
|
|
50
51
|
* A stylized display to communicate common http errors.
|
|
51
52
|
* @example
|
|
@@ -40,6 +40,7 @@ var Error_1 = __importDefault(require("@itwin/itwinui-illustrations-react/cjs/il
|
|
|
40
40
|
var react_1 = __importDefault(require("react"));
|
|
41
41
|
var Button_1 = require("../Buttons/Button");
|
|
42
42
|
var utils_1 = require("../utils");
|
|
43
|
+
var classnames_1 = __importDefault(require("classnames"));
|
|
43
44
|
require("@itwin/itwinui-css/css/non-ideal-state.css");
|
|
44
45
|
/**
|
|
45
46
|
* A stylized display to communicate common http errors.
|
|
@@ -47,7 +48,7 @@ require("@itwin/itwinui-css/css/non-ideal-state.css");
|
|
|
47
48
|
* <ErrorPage errorType='401' />
|
|
48
49
|
*/
|
|
49
50
|
var ErrorPage = function (props) {
|
|
50
|
-
var errorType = props.errorType, errorName = props.errorName, errorMessage = props.errorMessage, primaryButtonHandle = props.primaryButtonHandle, primaryButtonLabel = props.primaryButtonLabel, secondaryButtonHandle = props.secondaryButtonHandle, secondaryButtonLabel = props.secondaryButtonLabel, translatedErrorMessages = props.translatedErrorMessages, rest = __rest(props, ["errorType", "errorName", "errorMessage", "primaryButtonHandle", "primaryButtonLabel", "secondaryButtonHandle", "secondaryButtonLabel", "translatedErrorMessages"]);
|
|
51
|
+
var errorType = props.errorType, errorName = props.errorName, errorMessage = props.errorMessage, primaryButtonHandle = props.primaryButtonHandle, primaryButtonLabel = props.primaryButtonLabel, secondaryButtonHandle = props.secondaryButtonHandle, secondaryButtonLabel = props.secondaryButtonLabel, translatedErrorMessages = props.translatedErrorMessages, className = props.className, rest = __rest(props, ["errorType", "errorName", "errorMessage", "primaryButtonHandle", "primaryButtonLabel", "secondaryButtonHandle", "secondaryButtonLabel", "translatedErrorMessages", "className"]);
|
|
51
52
|
(0, utils_1.useTheme)();
|
|
52
53
|
var defaultErrorMessages = __assign({ badGateway: 'Bad gateway', error: 'Error', forbidden: 'Forbidden', internalServerError: 'Internal server error', pageNotFound: 'Page not found', serviceUnavailable: 'Service unavailable', unauthorized: 'Unauthorized' }, translatedErrorMessages);
|
|
53
54
|
function getErrorIcon() {
|
|
@@ -127,7 +128,7 @@ var ErrorPage = function (props) {
|
|
|
127
128
|
primaryButton,
|
|
128
129
|
secondaryButton));
|
|
129
130
|
}
|
|
130
|
-
return (react_1.default.createElement("div", __assign({ className: 'iui-non-ideal-state' }, rest),
|
|
131
|
+
return (react_1.default.createElement("div", __assign({ className: (0, classnames_1.default)('iui-non-ideal-state', className) }, rest),
|
|
131
132
|
getErrorIcon(),
|
|
132
133
|
react_1.default.createElement("div", { className: 'iui-non-ideal-state-title' }, getHeadingMessage()),
|
|
133
134
|
errorMessage && (react_1.default.createElement("div", { className: 'iui-non-ideal-state-description' }, errorMessage)),
|
|
@@ -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
|
/**
|
|
@@ -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) {
|
|
@@ -151,7 +153,7 @@ var TablePaginator = function (props) {
|
|
|
151
153
|
if (!showPagesList && !showPageSizeList) {
|
|
152
154
|
return null;
|
|
153
155
|
}
|
|
154
|
-
return (react_1.default.createElement("div", __assign({ className: (0, classnames_1.default)('iui-paginator', className) }, rest),
|
|
156
|
+
return (react_1.default.createElement("div", __assign({ className: (0, classnames_1.default)('iui-paginator', className), ref: paginatorResizeRef }, rest),
|
|
155
157
|
react_1.default.createElement("div", { className: 'iui-left' }),
|
|
156
158
|
showPagesList && (react_1.default.createElement("div", { className: 'iui-center', ref: overflowRef },
|
|
157
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 },
|
|
@@ -177,12 +179,15 @@ var TablePaginator = function (props) {
|
|
|
177
179
|
})()),
|
|
178
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 },
|
|
179
181
|
react_1.default.createElement(ChevronRight_1.default, null)))),
|
|
180
|
-
react_1.default.createElement("div", { className: 'iui-right' }, showPageSizeList && (react_1.default.createElement(
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
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)))))));
|
|
186
191
|
};
|
|
187
192
|
exports.TablePaginator = TablePaginator;
|
|
188
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;
|
|
@@ -14,7 +14,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.TableRowMemoized = void 0;
|
|
17
|
+
exports.TableRowMemoized = exports.TableRow = void 0;
|
|
18
18
|
/*---------------------------------------------------------------------------------------------
|
|
19
19
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
20
20
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
@@ -59,6 +59,7 @@ var TableRow = function (props) {
|
|
|
59
59
|
subComponent && (react_1.default.createElement(utils_1.WithCSSTransition, { in: row.isExpanded },
|
|
60
60
|
react_1.default.createElement("div", { className: 'iui-row iui-expanded-content' }, subComponent(row))))));
|
|
61
61
|
};
|
|
62
|
+
exports.TableRow = TableRow;
|
|
62
63
|
var hasAnySelectedSubRow = function (row, selectedRowIds) {
|
|
63
64
|
if (selectedRowIds === null || selectedRowIds === void 0 ? void 0 : selectedRowIds[row.id]) {
|
|
64
65
|
return true;
|
|
@@ -67,7 +68,7 @@ var hasAnySelectedSubRow = function (row, selectedRowIds) {
|
|
|
67
68
|
return hasAnySelectedSubRow(subRow, selectedRowIds);
|
|
68
69
|
});
|
|
69
70
|
};
|
|
70
|
-
exports.TableRowMemoized = react_1.default.memo(TableRow, function (prevProp, nextProp) {
|
|
71
|
+
exports.TableRowMemoized = react_1.default.memo(exports.TableRow, function (prevProp, nextProp) {
|
|
71
72
|
var _a, _b, _c, _d;
|
|
72
73
|
return prevProp.isLast === nextProp.isLast &&
|
|
73
74
|
prevProp.onRowInViewport === nextProp.onRowInViewport &&
|
|
@@ -90,5 +91,7 @@ exports.TableRowMemoized = react_1.default.memo(TableRow, function (prevProp, ne
|
|
|
90
91
|
prevProp.isDisabled === nextProp.isDisabled &&
|
|
91
92
|
prevProp.rowProps === nextProp.rowProps &&
|
|
92
93
|
prevProp.expanderCell === nextProp.expanderCell &&
|
|
93
|
-
prevProp.tableHasSubRows === nextProp.tableHasSubRows
|
|
94
|
+
prevProp.tableHasSubRows === nextProp.tableHasSubRows &&
|
|
95
|
+
!nextProp.state.columnResizing.isResizingColumn &&
|
|
96
|
+
!nextProp.state.isTableResizing;
|
|
94
97
|
});
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { ActionType, TableState } from 'react-table';
|
|
2
|
+
export declare const onTableResizeStart: <T extends Record<string, unknown>>(state: TableState<T>) => {
|
|
3
|
+
isTableResizing: boolean;
|
|
4
|
+
hiddenColumns?: import("react-table").IdType<T>[] | undefined;
|
|
5
|
+
columnResizing: {
|
|
6
|
+
startX?: number | undefined;
|
|
7
|
+
columnWidth?: number | undefined;
|
|
8
|
+
nextColumnWidth?: number | undefined;
|
|
9
|
+
headerIdWidths?: [string, number][] | undefined;
|
|
10
|
+
nextHeaderIdWidths?: [string, number][] | undefined;
|
|
11
|
+
columnWidths: Record<string, number>;
|
|
12
|
+
isResizingColumn?: string | undefined;
|
|
13
|
+
};
|
|
14
|
+
columnOrder: import("react-table").IdType<T>[];
|
|
15
|
+
expanded: Record<import("react-table").IdType<T>, boolean>;
|
|
16
|
+
filters: import("react-table").Filters<T>;
|
|
17
|
+
globalFilter: any;
|
|
18
|
+
groupBy: import("react-table").IdType<T>[];
|
|
19
|
+
pageSize: number;
|
|
20
|
+
pageIndex: number;
|
|
21
|
+
selectedRowIds: Record<import("react-table").IdType<T>, boolean>;
|
|
22
|
+
rowState: Record<string, {
|
|
23
|
+
cellState: import("react-table").UseRowStateLocalState<T, unknown>;
|
|
24
|
+
}>;
|
|
25
|
+
sortBy: import("react-table").SortingRule<T>[];
|
|
26
|
+
};
|
|
27
|
+
export declare const onTableResizeEnd: <T extends Record<string, unknown>>(state: TableState<T>, action: ActionType) => {
|
|
28
|
+
isTableResizing: boolean;
|
|
29
|
+
columnResizing: {
|
|
30
|
+
columnWidths: any;
|
|
31
|
+
startX?: number | undefined;
|
|
32
|
+
columnWidth?: number | undefined;
|
|
33
|
+
nextColumnWidth?: number | undefined;
|
|
34
|
+
headerIdWidths?: [string, number][] | undefined;
|
|
35
|
+
nextHeaderIdWidths?: [string, number][] | undefined;
|
|
36
|
+
isResizingColumn?: string | undefined;
|
|
37
|
+
};
|
|
38
|
+
hiddenColumns?: import("react-table").IdType<T>[] | undefined;
|
|
39
|
+
columnOrder: import("react-table").IdType<T>[];
|
|
40
|
+
expanded: Record<import("react-table").IdType<T>, boolean>;
|
|
41
|
+
filters: import("react-table").Filters<T>;
|
|
42
|
+
globalFilter: any;
|
|
43
|
+
groupBy: import("react-table").IdType<T>[];
|
|
44
|
+
pageSize: number;
|
|
45
|
+
pageIndex: number;
|
|
46
|
+
selectedRowIds: Record<import("react-table").IdType<T>, boolean>;
|
|
47
|
+
rowState: Record<string, {
|
|
48
|
+
cellState: import("react-table").UseRowStateLocalState<T, unknown>;
|
|
49
|
+
}>;
|
|
50
|
+
sortBy: import("react-table").SortingRule<T>[];
|
|
51
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.onTableResizeEnd = exports.onTableResizeStart = void 0;
|
|
15
|
+
var onTableResizeStart = function (state) {
|
|
16
|
+
return __assign(__assign({}, state), { isTableResizing: true });
|
|
17
|
+
};
|
|
18
|
+
exports.onTableResizeStart = onTableResizeStart;
|
|
19
|
+
var onTableResizeEnd = function (state, action) {
|
|
20
|
+
return __assign(__assign({}, state), { isTableResizing: false, columnResizing: __assign(__assign({}, state.columnResizing), { columnWidths: __assign({}, action.columnWidths) }) });
|
|
21
|
+
};
|
|
22
|
+
exports.onTableResizeEnd = onTableResizeEnd;
|