@itwin/itwinui-react 1.40.1 → 1.43.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 +42 -0
- package/cjs/core/Backdrop/Backdrop.d.ts +10 -0
- package/cjs/core/Backdrop/Backdrop.js +41 -0
- package/cjs/core/Backdrop/index.d.ts +2 -0
- package/cjs/core/Backdrop/index.js +9 -0
- package/cjs/core/Breadcrumbs/Breadcrumbs.js +18 -18
- package/cjs/core/ButtonGroup/ButtonGroup.js +11 -4
- package/cjs/core/ComboBox/ComboBox.js +22 -18
- package/cjs/core/Dialog/Dialog.d.ts +41 -0
- package/cjs/core/Dialog/Dialog.js +59 -0
- package/cjs/core/Dialog/DialogBackdrop.d.ts +12 -0
- package/cjs/core/Dialog/DialogBackdrop.js +61 -0
- package/cjs/core/Dialog/DialogButtonBar.d.ts +18 -0
- package/cjs/core/Dialog/DialogButtonBar.js +50 -0
- package/cjs/core/Dialog/DialogContent.d.ts +17 -0
- package/cjs/core/Dialog/DialogContent.js +49 -0
- package/cjs/core/Dialog/DialogContext.d.ts +39 -0
- package/cjs/core/Dialog/DialogContext.js +16 -0
- package/cjs/core/Dialog/DialogMain.d.ts +36 -0
- package/cjs/core/Dialog/DialogMain.js +120 -0
- package/cjs/core/Dialog/DialogTitleBar.d.ts +34 -0
- package/cjs/core/Dialog/DialogTitleBar.js +69 -0
- package/cjs/core/Dialog/DialogTitleBarTitle.d.ts +15 -0
- package/cjs/core/Dialog/DialogTitleBarTitle.js +47 -0
- package/cjs/core/Dialog/index.d.ts +8 -0
- package/cjs/core/Dialog/index.js +10 -0
- package/cjs/core/ErrorPage/ErrorPage.d.ts +3 -1
- package/cjs/core/ErrorPage/ErrorPage.js +31 -1
- package/cjs/core/Footer/Footer.d.ts +16 -2
- package/cjs/core/Footer/Footer.js +57 -45
- package/cjs/core/Footer/FooterItem.d.ts +8 -0
- package/cjs/core/Footer/FooterItem.js +46 -0
- package/cjs/core/Footer/FooterList.d.ts +8 -0
- package/cjs/core/Footer/FooterList.js +46 -0
- package/cjs/core/Footer/FooterSeparator.d.ts +8 -0
- package/cjs/core/Footer/FooterSeparator.js +46 -0
- package/cjs/core/Footer/index.d.ts +1 -1
- package/cjs/core/Footer/index.js +2 -1
- package/cjs/core/Modal/Modal.d.ts +4 -13
- package/cjs/core/Modal/Modal.js +9 -71
- package/cjs/core/Modal/ModalButtonBar.d.ts +1 -2
- package/cjs/core/Modal/ModalButtonBar.js +2 -39
- package/cjs/core/Modal/ModalContent.d.ts +1 -2
- package/cjs/core/Modal/ModalContent.js +2 -39
- package/cjs/core/Slider/Slider.d.ts +10 -0
- package/cjs/core/Slider/Slider.js +20 -14
- package/cjs/core/Slider/Thumb.d.ts +2 -1
- package/cjs/core/Slider/Thumb.js +5 -3
- package/cjs/core/Slider/Track.d.ts +2 -1
- package/cjs/core/Slider/Track.js +23 -4
- package/cjs/core/Table/Table.d.ts +24 -0
- package/cjs/core/Table/Table.js +21 -10
- package/cjs/core/Table/TableRowMemoized.d.ts +4 -0
- package/cjs/core/Table/TableRowMemoized.js +15 -3
- package/cjs/core/Table/cells/EditableCell.js +7 -2
- package/cjs/core/Table/columns/actionColumn.d.ts +8 -3
- package/cjs/core/Table/columns/actionColumn.js +33 -2
- package/cjs/core/Table/hooks/index.d.ts +1 -0
- package/cjs/core/Table/hooks/index.js +3 -1
- package/cjs/core/Table/hooks/useScrollToRow.d.ts +11 -0
- package/cjs/core/Table/hooks/useScrollToRow.js +49 -0
- package/cjs/core/Tree/Tree.d.ts +9 -0
- package/cjs/core/Tree/Tree.js +67 -19
- package/cjs/core/Tree/TreeContext.d.ts +4 -0
- package/cjs/core/Tree/TreeNode.js +8 -9
- package/cjs/core/Typography/Small/Small.js +1 -1
- package/cjs/core/index.d.ts +3 -1
- package/cjs/core/index.js +6 -3
- package/cjs/core/utils/components/FocusTrap.js +1 -1
- package/cjs/core/utils/components/MiddleTextTruncation.js +1 -1
- package/cjs/core/utils/hooks/index.d.ts +1 -0
- package/cjs/core/utils/hooks/index.js +1 -0
- package/cjs/core/utils/hooks/useLatestRef.d.ts +9 -0
- package/cjs/core/utils/hooks/useLatestRef.js +26 -0
- package/esm/core/Backdrop/Backdrop.d.ts +10 -0
- package/esm/core/Backdrop/Backdrop.js +35 -0
- package/esm/core/Backdrop/index.d.ts +2 -0
- package/esm/core/Backdrop/index.js +5 -0
- package/esm/core/Breadcrumbs/Breadcrumbs.js +18 -18
- package/esm/core/ButtonGroup/ButtonGroup.js +11 -4
- package/esm/core/ComboBox/ComboBox.js +23 -19
- package/esm/core/Dialog/Dialog.d.ts +41 -0
- package/esm/core/Dialog/Dialog.js +53 -0
- package/esm/core/Dialog/DialogBackdrop.d.ts +12 -0
- package/esm/core/Dialog/DialogBackdrop.js +55 -0
- package/esm/core/Dialog/DialogButtonBar.d.ts +18 -0
- package/esm/core/Dialog/DialogButtonBar.js +44 -0
- package/esm/core/Dialog/DialogContent.d.ts +17 -0
- package/esm/core/Dialog/DialogContent.js +43 -0
- package/esm/core/Dialog/DialogContext.d.ts +39 -0
- package/esm/core/Dialog/DialogContext.js +9 -0
- package/esm/core/Dialog/DialogMain.d.ts +36 -0
- package/esm/core/Dialog/DialogMain.js +114 -0
- package/esm/core/Dialog/DialogTitleBar.d.ts +34 -0
- package/esm/core/Dialog/DialogTitleBar.js +63 -0
- package/esm/core/Dialog/DialogTitleBarTitle.d.ts +15 -0
- package/esm/core/Dialog/DialogTitleBarTitle.js +41 -0
- package/esm/core/Dialog/index.d.ts +8 -0
- package/esm/core/Dialog/index.js +6 -0
- package/esm/core/ErrorPage/ErrorPage.d.ts +3 -1
- package/esm/core/ErrorPage/ErrorPage.js +31 -1
- package/esm/core/Footer/Footer.d.ts +16 -2
- package/esm/core/Footer/Footer.js +56 -43
- package/esm/core/Footer/FooterItem.d.ts +8 -0
- package/esm/core/Footer/FooterItem.js +39 -0
- package/esm/core/Footer/FooterList.d.ts +8 -0
- package/esm/core/Footer/FooterList.js +39 -0
- package/esm/core/Footer/FooterSeparator.d.ts +8 -0
- package/esm/core/Footer/FooterSeparator.js +39 -0
- package/esm/core/Footer/index.d.ts +1 -1
- package/esm/core/Footer/index.js +1 -1
- package/esm/core/Modal/Modal.d.ts +4 -13
- package/esm/core/Modal/Modal.js +10 -72
- package/esm/core/Modal/ModalButtonBar.d.ts +1 -2
- package/esm/core/Modal/ModalButtonBar.js +2 -35
- package/esm/core/Modal/ModalContent.d.ts +1 -2
- package/esm/core/Modal/ModalContent.js +2 -35
- package/esm/core/Slider/Slider.d.ts +10 -0
- package/esm/core/Slider/Slider.js +20 -14
- package/esm/core/Slider/Thumb.d.ts +2 -1
- package/esm/core/Slider/Thumb.js +5 -3
- package/esm/core/Slider/Track.d.ts +2 -1
- package/esm/core/Slider/Track.js +23 -4
- package/esm/core/Table/Table.d.ts +24 -0
- package/esm/core/Table/Table.js +23 -12
- package/esm/core/Table/TableRowMemoized.d.ts +4 -0
- package/esm/core/Table/TableRowMemoized.js +15 -3
- package/esm/core/Table/cells/EditableCell.js +7 -2
- package/esm/core/Table/columns/actionColumn.d.ts +8 -3
- package/esm/core/Table/columns/actionColumn.js +33 -2
- package/esm/core/Table/hooks/index.d.ts +1 -0
- package/esm/core/Table/hooks/index.js +1 -0
- package/esm/core/Table/hooks/useScrollToRow.d.ts +11 -0
- package/esm/core/Table/hooks/useScrollToRow.js +42 -0
- package/esm/core/Tree/Tree.d.ts +9 -0
- package/esm/core/Tree/Tree.js +68 -20
- package/esm/core/Tree/TreeContext.d.ts +4 -0
- package/esm/core/Tree/TreeNode.js +8 -9
- package/esm/core/Typography/Small/Small.js +1 -1
- package/esm/core/index.d.ts +3 -1
- package/esm/core/index.js +2 -1
- package/esm/core/utils/components/FocusTrap.js +1 -1
- package/esm/core/utils/components/MiddleTextTruncation.js +1 -1
- package/esm/core/utils/hooks/index.d.ts +1 -0
- package/esm/core/utils/hooks/index.js +1 -0
- package/esm/core/utils/hooks/useLatestRef.d.ts +9 -0
- package/esm/core/utils/hooks/useLatestRef.js +19 -0
- package/package.json +8 -7
|
@@ -1,39 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
-
var t = {};
|
|
14
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
-
t[p] = s[p];
|
|
16
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
-
t[p[i]] = s[p[i]];
|
|
20
|
-
}
|
|
21
|
-
return t;
|
|
22
|
-
};
|
|
23
|
-
/*---------------------------------------------------------------------------------------------
|
|
24
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
25
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
26
|
-
*--------------------------------------------------------------------------------------------*/
|
|
27
|
-
import React from 'react';
|
|
28
|
-
import cx from 'classnames';
|
|
29
|
-
import { useTheme } from '../utils';
|
|
30
|
-
import '@itwin/itwinui-css/css/dialog.css';
|
|
1
|
+
import { DialogContent } from '../Dialog/DialogContent';
|
|
31
2
|
/**
|
|
32
3
|
* Container for content in `Modal`.
|
|
33
4
|
*/
|
|
34
|
-
export var ModalContent =
|
|
35
|
-
var children = props.children, className = props.className, rest = __rest(props, ["children", "className"]);
|
|
36
|
-
useTheme();
|
|
37
|
-
return (React.createElement("div", __assign({ className: cx('iui-dialog-content', className) }, rest), children));
|
|
38
|
-
};
|
|
5
|
+
export var ModalContent = DialogContent;
|
|
39
6
|
export default ModalContent;
|
|
@@ -96,6 +96,11 @@ export declare type SliderProps = {
|
|
|
96
96
|
* high-volume of updates will occur when dragging.
|
|
97
97
|
*/
|
|
98
98
|
onUpdate?: (values: ReadonlyArray<number>) => void;
|
|
99
|
+
/**
|
|
100
|
+
* The orientation of slider
|
|
101
|
+
* @default 'horizontal'
|
|
102
|
+
*/
|
|
103
|
+
orientation?: 'horizontal' | 'vertical';
|
|
99
104
|
} & Omit<CommonProps, 'title'>;
|
|
100
105
|
/**
|
|
101
106
|
* Slider component that display Thumbs for each value specified along a Rail.
|
|
@@ -195,5 +200,10 @@ export declare const Slider: React.ForwardRefExoticComponent<{
|
|
|
195
200
|
* high-volume of updates will occur when dragging.
|
|
196
201
|
*/
|
|
197
202
|
onUpdate?: ((values: ReadonlyArray<number>) => void) | undefined;
|
|
203
|
+
/**
|
|
204
|
+
* The orientation of slider
|
|
205
|
+
* @default 'horizontal'
|
|
206
|
+
*/
|
|
207
|
+
orientation?: "horizontal" | "vertical" | undefined;
|
|
198
208
|
} & Omit<CommonProps, "title"> & React.RefAttributes<HTMLDivElement>>;
|
|
199
209
|
export default Slider;
|
|
@@ -39,9 +39,13 @@ import { useTheme, getBoundedValue, useEventListener, } from '../utils';
|
|
|
39
39
|
import '@itwin/itwinui-css/css/slider.css';
|
|
40
40
|
import { Track } from './Track';
|
|
41
41
|
import { Thumb } from './Thumb';
|
|
42
|
-
var getPercentageOfRectangle = function (rect,
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
var getPercentageOfRectangle = function (rect, pointerX, pointerY, orientation) {
|
|
43
|
+
if (orientation === 'horizontal') {
|
|
44
|
+
var position_1 = getBoundedValue(pointerX, rect.left, rect.right);
|
|
45
|
+
return (position_1 - rect.left) / rect.width;
|
|
46
|
+
}
|
|
47
|
+
var position = getBoundedValue(pointerY, rect.top, rect.bottom);
|
|
48
|
+
return (rect.bottom - position) / rect.height;
|
|
45
49
|
};
|
|
46
50
|
var getClosestValueIndex = function (values, pointerValue) {
|
|
47
51
|
if (1 === values.length) {
|
|
@@ -88,20 +92,20 @@ var focusThumb = function (sliderContainer, activeIndex) {
|
|
|
88
92
|
*/
|
|
89
93
|
export var Slider = React.forwardRef(function (props, ref) {
|
|
90
94
|
var _a, _b;
|
|
91
|
-
var _c = props.min, min = _c === void 0 ? 0 : _c, _d = props.max, max = _d === void 0 ? 100 : _d, values = props.values, _e = props.step, step = _e === void 0 ? 1 : _e, _f = props.setFocus, setFocus = _f === void 0 ? false : _f, tooltipProps = props.tooltipProps, _g = props.disabled, disabled = _g === void 0 ? false : _g, tickLabels = props.tickLabels, minLabel = props.minLabel, maxLabel = props.maxLabel, _h = props.trackDisplayMode, trackDisplayMode = _h === void 0 ? 'auto' : _h, _j = props.thumbMode, thumbMode = _j === void 0 ? 'inhibit-crossing' : _j, onChange = props.onChange, onUpdate = props.onUpdate, thumbProps = props.thumbProps, className = props.className, railContainerProps = props.railContainerProps, rest = __rest(props, ["min", "max", "values", "step", "setFocus", "tooltipProps", "disabled", "tickLabels", "minLabel", "maxLabel", "trackDisplayMode", "thumbMode", "onChange", "onUpdate", "thumbProps", "className", "railContainerProps"]);
|
|
92
|
-
var
|
|
95
|
+
var _c = props.min, min = _c === void 0 ? 0 : _c, _d = props.max, max = _d === void 0 ? 100 : _d, values = props.values, _e = props.step, step = _e === void 0 ? 1 : _e, _f = props.setFocus, setFocus = _f === void 0 ? false : _f, tooltipProps = props.tooltipProps, _g = props.disabled, disabled = _g === void 0 ? false : _g, tickLabels = props.tickLabels, minLabel = props.minLabel, maxLabel = props.maxLabel, _h = props.trackDisplayMode, trackDisplayMode = _h === void 0 ? 'auto' : _h, _j = props.thumbMode, thumbMode = _j === void 0 ? 'inhibit-crossing' : _j, onChange = props.onChange, onUpdate = props.onUpdate, thumbProps = props.thumbProps, className = props.className, railContainerProps = props.railContainerProps, _k = props.orientation, orientation = _k === void 0 ? 'horizontal' : _k, rest = __rest(props, ["min", "max", "values", "step", "setFocus", "tooltipProps", "disabled", "tickLabels", "minLabel", "maxLabel", "trackDisplayMode", "thumbMode", "onChange", "onUpdate", "thumbProps", "className", "railContainerProps", "orientation"]);
|
|
96
|
+
var _l = React.useState(values), currentValues = _l[0], setCurrentValues = _l[1];
|
|
93
97
|
React.useEffect(function () {
|
|
94
98
|
setCurrentValues(values);
|
|
95
99
|
}, [values]);
|
|
96
|
-
var
|
|
100
|
+
var _m = React.useState(function () { return minLabel !== null && minLabel !== void 0 ? minLabel : min.toString(); }), minValueLabel = _m[0], setMinValueLabel = _m[1];
|
|
97
101
|
React.useEffect(function () {
|
|
98
102
|
setMinValueLabel(minLabel !== null && minLabel !== void 0 ? minLabel : min.toString());
|
|
99
103
|
}, [minLabel, min]);
|
|
100
|
-
var
|
|
104
|
+
var _o = React.useState(function () { return maxLabel !== null && maxLabel !== void 0 ? maxLabel : max.toString(); }), maxValueLabel = _o[0], setMaxValueLabel = _o[1];
|
|
101
105
|
React.useEffect(function () {
|
|
102
106
|
setMaxValueLabel(maxLabel !== null && maxLabel !== void 0 ? maxLabel : max.toString());
|
|
103
107
|
}, [maxLabel, max]);
|
|
104
|
-
var
|
|
108
|
+
var _p = React.useState(function () { return getDefaultTrackDisplay(trackDisplayMode, currentValues); }), trackDisplay = _p[0], setTrackDisplay = _p[1];
|
|
105
109
|
React.useEffect(function () {
|
|
106
110
|
setTrackDisplay(getDefaultTrackDisplay(trackDisplayMode, currentValues));
|
|
107
111
|
}, [trackDisplayMode, currentValues]);
|
|
@@ -127,10 +131,10 @@ export var Slider = React.forwardRef(function (props, ref) {
|
|
|
127
131
|
}
|
|
128
132
|
return [min, max];
|
|
129
133
|
}, [max, min, step, thumbMode, currentValues]);
|
|
130
|
-
var
|
|
134
|
+
var _q = React.useState(undefined), activeThumbIndex = _q[0], setActiveThumbIndex = _q[1];
|
|
131
135
|
var updateThumbValue = React.useCallback(function (event, callbackType) {
|
|
132
136
|
if (containerRef.current && undefined !== activeThumbIndex) {
|
|
133
|
-
var percent = getPercentageOfRectangle(containerRef.current.getBoundingClientRect(), event.clientX);
|
|
137
|
+
var percent = getPercentageOfRectangle(containerRef.current.getBoundingClientRect(), event.clientX, event.clientY, orientation);
|
|
134
138
|
var pointerValue = min + (max - min) * percent;
|
|
135
139
|
pointerValue = roundValueToClosestStep(pointerValue, step, min);
|
|
136
140
|
var _a = getAllowableThumbRange(activeThumbIndex), minVal = _a[0], maxVal = _a[1];
|
|
@@ -156,6 +160,7 @@ export var Slider = React.forwardRef(function (props, ref) {
|
|
|
156
160
|
currentValues,
|
|
157
161
|
onUpdate,
|
|
158
162
|
onChange,
|
|
163
|
+
orientation,
|
|
159
164
|
]);
|
|
160
165
|
var handlePointerMove = React.useCallback(function (event) {
|
|
161
166
|
if (activeThumbIndex === undefined) {
|
|
@@ -189,7 +194,7 @@ export var Slider = React.forwardRef(function (props, ref) {
|
|
|
189
194
|
}, [activeThumbIndex, updateThumbValue]);
|
|
190
195
|
var handlePointerDownOnSlider = React.useCallback(function (event) {
|
|
191
196
|
if (containerRef.current) {
|
|
192
|
-
var percent = getPercentageOfRectangle(containerRef.current.getBoundingClientRect(), event.clientX);
|
|
197
|
+
var percent = getPercentageOfRectangle(containerRef.current.getBoundingClientRect(), event.clientX, event.clientY, orientation);
|
|
193
198
|
var pointerValue = min + (max - min) * percent;
|
|
194
199
|
pointerValue = roundValueToClosestStep(pointerValue, step, min);
|
|
195
200
|
var closestValueIndex = getClosestValueIndex(currentValues, pointerValue);
|
|
@@ -215,6 +220,7 @@ export var Slider = React.forwardRef(function (props, ref) {
|
|
|
215
220
|
getAllowableThumbRange,
|
|
216
221
|
onChange,
|
|
217
222
|
onUpdate,
|
|
223
|
+
orientation,
|
|
218
224
|
]);
|
|
219
225
|
useEventListener('pointermove', handlePointerMove, (_a = containerRef.current) === null || _a === void 0 ? void 0 : _a.ownerDocument);
|
|
220
226
|
useEventListener('pointerup', handlePointerUp, (_b = containerRef.current) === null || _b === void 0 ? void 0 : _b.ownerDocument);
|
|
@@ -235,7 +241,7 @@ export var Slider = React.forwardRef(function (props, ref) {
|
|
|
235
241
|
? outProps.content
|
|
236
242
|
: formatNumberValue(val, step, getNumDecimalPlaces) });
|
|
237
243
|
}, [getNumDecimalPlaces, step, tooltipProps]);
|
|
238
|
-
return (React.createElement("div", __assign({ ref: ref, className: cx('iui-slider-component-container', { 'iui-disabled': disabled }, className) }, rest),
|
|
244
|
+
return (React.createElement("div", __assign({ ref: ref, className: cx('iui-slider-component-container', "iui-slider-".concat(orientation), { 'iui-disabled': disabled }, className) }, rest),
|
|
239
245
|
minValueLabel && (React.createElement("span", { className: 'iui-slider-min' }, minValueLabel)),
|
|
240
246
|
React.createElement("div", __assign({ ref: containerRef, className: cx('iui-slider-container', {
|
|
241
247
|
'iui-grabbing': undefined !== activeThumbIndex,
|
|
@@ -245,9 +251,9 @@ export var Slider = React.forwardRef(function (props, ref) {
|
|
|
245
251
|
var _a;
|
|
246
252
|
var _b = getAllowableThumbRange(index), minVal = _b[0], maxVal = _b[1];
|
|
247
253
|
var thisThumbProps = thumbProps === null || thumbProps === void 0 ? void 0 : thumbProps(index);
|
|
248
|
-
return (React.createElement(Thumb, { key: (_a = thisThumbProps === null || thisThumbProps === void 0 ? void 0 : thisThumbProps.id) !== null && _a !== void 0 ? _a : index, index: index, disabled: disabled, isActive: activeThumbIndex === index, onThumbActivated: onThumbActivated, onThumbValueChanged: onThumbValueChanged, minVal: minVal, maxVal: maxVal, value: thumbValue, tooltipProps: generateTooltipProps(index, thumbValue), thumbProps: thisThumbProps, step: step, sliderMin: min, sliderMax: max }));
|
|
254
|
+
return (React.createElement(Thumb, { key: (_a = thisThumbProps === null || thisThumbProps === void 0 ? void 0 : thisThumbProps.id) !== null && _a !== void 0 ? _a : index, index: index, disabled: disabled, isActive: activeThumbIndex === index, onThumbActivated: onThumbActivated, onThumbValueChanged: onThumbValueChanged, minVal: minVal, maxVal: maxVal, value: thumbValue, tooltipProps: generateTooltipProps(index, thumbValue), thumbProps: thisThumbProps, step: step, sliderMin: min, sliderMax: max, orientation: orientation }));
|
|
249
255
|
}),
|
|
250
|
-
React.createElement(Track, { trackDisplayMode: trackDisplay, sliderMin: min, sliderMax: max, values: currentValues }),
|
|
256
|
+
React.createElement(Track, { trackDisplayMode: trackDisplay, sliderMin: min, sliderMax: max, values: currentValues, orientation: orientation }),
|
|
251
257
|
tickMarkArea),
|
|
252
258
|
maxValueLabel && (React.createElement("span", { className: 'iui-slider-max' }, maxValueLabel))));
|
|
253
259
|
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { TooltipProps } from '../Tooltip';
|
|
3
|
+
import { SliderProps } from './Slider';
|
|
3
4
|
export declare type ThumbProps = {
|
|
4
5
|
/**
|
|
5
6
|
* Thumb value.
|
|
@@ -53,7 +54,7 @@ export declare type ThumbProps = {
|
|
|
53
54
|
* Additional props for Thumb.
|
|
54
55
|
*/
|
|
55
56
|
thumbProps?: React.HTMLAttributes<HTMLDivElement>;
|
|
56
|
-
}
|
|
57
|
+
} & Pick<SliderProps, 'orientation'>;
|
|
57
58
|
/**
|
|
58
59
|
* Thumb is a local component used to show and modify the values maintained by the Slider.
|
|
59
60
|
* Only one Thumb can be active at a time. A Thumb is made active when the user selects
|
package/esm/core/Slider/Thumb.js
CHANGED
|
@@ -33,7 +33,7 @@ import { Tooltip } from '../Tooltip';
|
|
|
33
33
|
* it with pointer. Whenever a Thumb is active, focused, or hovered its tooltip is shown.
|
|
34
34
|
*/
|
|
35
35
|
export var Thumb = function (props) {
|
|
36
|
-
var value = props.value, index = props.index, minVal = props.minVal, maxVal = props.maxVal, step = props.step, sliderMin = props.sliderMin, sliderMax = props.sliderMax, isActive = props.isActive, onThumbActivated = props.onThumbActivated, onThumbValueChanged = props.onThumbValueChanged, tooltipProps = props.tooltipProps, thumbProps = props.thumbProps, disabled = props.disabled;
|
|
36
|
+
var value = props.value, index = props.index, minVal = props.minVal, maxVal = props.maxVal, step = props.step, sliderMin = props.sliderMin, sliderMax = props.sliderMax, isActive = props.isActive, onThumbActivated = props.onThumbActivated, onThumbValueChanged = props.onThumbValueChanged, tooltipProps = props.tooltipProps, thumbProps = props.thumbProps, disabled = props.disabled, orientation = props.orientation;
|
|
37
37
|
var thumbRef = React.useRef(null);
|
|
38
38
|
var handleOnKeyDown = React.useCallback(function (event) {
|
|
39
39
|
if (disabled || event.altKey) {
|
|
@@ -73,7 +73,7 @@ export var Thumb = function (props) {
|
|
|
73
73
|
}
|
|
74
74
|
return value;
|
|
75
75
|
}, [sliderMax, sliderMin, value]);
|
|
76
|
-
var
|
|
76
|
+
var lowPercent = React.useMemo(function () {
|
|
77
77
|
if (sliderMax === sliderMin) {
|
|
78
78
|
return 0;
|
|
79
79
|
}
|
|
@@ -81,5 +81,7 @@ export var Thumb = function (props) {
|
|
|
81
81
|
}, [adjustedValue, sliderMax, sliderMin]);
|
|
82
82
|
var _c = thumbProps || {}, style = _c.style, className = _c.className, rest = __rest(_c, ["style", "className"]);
|
|
83
83
|
return (React.createElement(Tooltip, __assign({ visible: isActive || hasFocus || isHovered, placement: 'top' }, tooltipProps),
|
|
84
|
-
React.createElement("div", __assign({}, rest, { "data-index": index, ref: thumbRef, style: __assign(__assign({}, style),
|
|
84
|
+
React.createElement("div", __assign({}, rest, { "data-index": index, ref: thumbRef, style: __assign(__assign({}, style), (orientation === 'horizontal'
|
|
85
|
+
? { left: "".concat(lowPercent, "%") }
|
|
86
|
+
: { bottom: "".concat(lowPercent, "%") })), className: cx('iui-slider-thumb', { 'iui-active': isActive }, className), role: 'slider', tabIndex: disabled ? undefined : 0, "aria-valuemin": minVal, "aria-valuenow": value, "aria-valuemax": maxVal, "aria-disabled": disabled, onPointerDown: handlePointerDownOnThumb, onKeyDown: handleOnKeyDown, onFocus: function () { return setHasFocus(true); }, onBlur: function () { return setHasFocus(false); }, onMouseEnter: function () { return setIsHovered(true); }, onMouseLeave: function () { return setIsHovered(false); } }))));
|
|
85
87
|
};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { TrackDisplayMode } from './Slider';
|
|
2
|
+
import { SliderProps, TrackDisplayMode } from './Slider';
|
|
3
3
|
export declare type TrackProps = {
|
|
4
4
|
trackDisplayMode: TrackDisplayMode;
|
|
5
5
|
sliderMin: number;
|
|
6
6
|
sliderMax: number;
|
|
7
7
|
values: number[];
|
|
8
|
+
orientation: SliderProps['orientation'];
|
|
8
9
|
};
|
|
9
10
|
/**
|
|
10
11
|
* Track displays color segments above Rail. Which, if any, segments that are
|
package/esm/core/Slider/Track.js
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
1
12
|
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
2
13
|
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
3
14
|
if (ar || !(i in from)) {
|
|
@@ -44,7 +55,7 @@ function generateSegments(values, min, max) {
|
|
|
44
55
|
* colorized is based on `trackDisplayMode`.
|
|
45
56
|
*/
|
|
46
57
|
export var Track = function (props) {
|
|
47
|
-
var trackDisplayMode = props.trackDisplayMode, sliderMin = props.sliderMin, sliderMax = props.sliderMax, values = props.values;
|
|
58
|
+
var trackDisplayMode = props.trackDisplayMode, sliderMin = props.sliderMin, sliderMax = props.sliderMax, values = props.values, orientation = props.orientation;
|
|
48
59
|
var _a = React.useState(function () {
|
|
49
60
|
return generateSegments(values, sliderMin, sliderMax);
|
|
50
61
|
}), segments = _a[0], setSegments = _a[1];
|
|
@@ -53,13 +64,21 @@ export var Track = function (props) {
|
|
|
53
64
|
}, [values, sliderMin, sliderMax]);
|
|
54
65
|
return (React.createElement(React.Fragment, null, 'none' !== trackDisplayMode &&
|
|
55
66
|
segments.map(function (segment, index) {
|
|
56
|
-
var
|
|
67
|
+
var lowPercent = segment.left >= sliderMin && sliderMax !== sliderMin
|
|
57
68
|
? (100.0 * (segment.left - sliderMin)) / (sliderMax - sliderMin)
|
|
58
69
|
: 0;
|
|
59
|
-
var
|
|
70
|
+
var highPercent = segment.right >= sliderMin && sliderMax !== sliderMin
|
|
60
71
|
? 100.0 -
|
|
61
72
|
(100.0 * (segment.right - sliderMin)) / (sliderMax - sliderMin)
|
|
62
73
|
: 100;
|
|
63
|
-
return (React.createElement(React.Fragment, { key: index }, shouldDisplaySegment(index, trackDisplayMode) ? (React.createElement("div", { className: 'iui-slider-track', style: {
|
|
74
|
+
return (React.createElement(React.Fragment, { key: index }, shouldDisplaySegment(index, trackDisplayMode) ? (React.createElement("div", { className: 'iui-slider-track', style: __assign({}, (orientation === 'horizontal'
|
|
75
|
+
? {
|
|
76
|
+
left: "".concat(lowPercent, "%"),
|
|
77
|
+
right: "".concat(highPercent, "%"),
|
|
78
|
+
}
|
|
79
|
+
: {
|
|
80
|
+
top: "".concat(highPercent, "%"),
|
|
81
|
+
bottom: "".concat(lowPercent, "%"),
|
|
82
|
+
})) })) : null));
|
|
64
83
|
})));
|
|
65
84
|
};
|
|
@@ -182,6 +182,30 @@ export declare type TableProps<T extends Record<string, unknown> = Record<string
|
|
|
182
182
|
* @default false
|
|
183
183
|
*/
|
|
184
184
|
enableColumnReordering?: boolean;
|
|
185
|
+
/**
|
|
186
|
+
* Function that returns index of the row that you want to scroll to.
|
|
187
|
+
*
|
|
188
|
+
* When using with lazy-loading table, you need to take care that row is already loaded.
|
|
189
|
+
* It doesn't work with paginated tables.
|
|
190
|
+
* @beta
|
|
191
|
+
* @example
|
|
192
|
+
* <Table
|
|
193
|
+
* scrollToRow={React.useCallback(
|
|
194
|
+
* (rows, data) => rows.findIndex((row) => row.original === data[250]),
|
|
195
|
+
* []
|
|
196
|
+
* )}
|
|
197
|
+
* {...restProps}
|
|
198
|
+
* />
|
|
199
|
+
* @example
|
|
200
|
+
* <Table
|
|
201
|
+
* scrollToRow={React.useCallback(
|
|
202
|
+
* (rows, data) => rows.findIndex((row) => row.original.id === data[250].id),
|
|
203
|
+
* []
|
|
204
|
+
* )}
|
|
205
|
+
* {...restProps}
|
|
206
|
+
* />
|
|
207
|
+
*/
|
|
208
|
+
scrollToRow?: (rows: Row<T>[], data: T[]) => number;
|
|
185
209
|
} & Omit<CommonProps, 'title'>;
|
|
186
210
|
/**
|
|
187
211
|
* Table based on [react-table](https://react-table.tanstack.com/docs/api/overview).
|
package/esm/core/Table/Table.js
CHANGED
|
@@ -28,7 +28,7 @@ import React from 'react';
|
|
|
28
28
|
import cx from 'classnames';
|
|
29
29
|
import { actions as TableActions, useFlexLayout, useFilters, useRowSelect, useSortBy, useTable, useExpanded, usePagination, useColumnOrder, } from 'react-table';
|
|
30
30
|
import { ProgressRadial } from '../ProgressIndicators';
|
|
31
|
-
import { useTheme, useResizeObserver } from '../utils';
|
|
31
|
+
import { useTheme, useResizeObserver, mergeRefs } from '../utils';
|
|
32
32
|
import '@itwin/itwinui-css/css/table.css';
|
|
33
33
|
import SvgSortDown from '@itwin/itwinui-icons-react/cjs/icons/SortDown';
|
|
34
34
|
import SvgSortUp from '@itwin/itwinui-icons-react/cjs/icons/SortUp';
|
|
@@ -36,7 +36,7 @@ import { getCellStyle, getStickyStyle } from './utils';
|
|
|
36
36
|
import { TableRowMemoized } from './TableRowMemoized';
|
|
37
37
|
import { FilterToggle } from './filters';
|
|
38
38
|
import { customFilterFunctions } from './filters/customFilterFunctions';
|
|
39
|
-
import { useExpanderCell, useSelectionCell, useSubRowFiltering, useSubRowSelection, useResizeColumns, useColumnDragAndDrop, useStickyColumns, } from './hooks';
|
|
39
|
+
import { useExpanderCell, useSelectionCell, useSubRowFiltering, useSubRowSelection, useResizeColumns, useColumnDragAndDrop, useScrollToRow, useStickyColumns, } from './hooks';
|
|
40
40
|
import { onExpandHandler, onFilterHandler, onSelectHandler, onSingleSelectHandler, onTableResizeEnd, onTableResizeStart, } from './actionHandlers';
|
|
41
41
|
import VirtualScroll from '../utils/components/VirtualScroll';
|
|
42
42
|
import { SELECTION_CELL_ID } from './columns';
|
|
@@ -234,6 +234,7 @@ export var Table = function (props) {
|
|
|
234
234
|
state.pageIndex,
|
|
235
235
|
state.pageSize,
|
|
236
236
|
]);
|
|
237
|
+
var _r = useScrollToRow(__assign(__assign({}, props), { page: page })), scrollToIndex = _r.scrollToIndex, tableRowRef = _r.tableRowRef;
|
|
237
238
|
var columnRefs = React.useRef({});
|
|
238
239
|
var previousTableWidth = React.useRef(0);
|
|
239
240
|
var onTableResize = React.useCallback(function (_a) {
|
|
@@ -269,22 +270,27 @@ export var Table = function (props) {
|
|
|
269
270
|
});
|
|
270
271
|
var headerRef = React.useRef(null);
|
|
271
272
|
var bodyRef = React.useRef(null);
|
|
273
|
+
// Using `useState` to rerender rows when table body ref is available
|
|
274
|
+
var _s = React.useState(null), bodyRefState = _s[0], setBodyRefState = _s[1];
|
|
272
275
|
var getPreparedRow = React.useCallback(function (index) {
|
|
273
276
|
var row = page[index];
|
|
274
277
|
prepareRow(row);
|
|
275
|
-
return (React.createElement(TableRowMemoized, { row: row, rowProps: rowProps, isLast: index === page.length - 1, onRowInViewport: onRowInViewportRef, onBottomReached: onBottomReachedRef, intersectionMargin: intersectionMargin, state: state, key: row.getRowProps().key, onClick: onRowClickHandler, subComponent: subComponent, isDisabled: !!(isRowDisabled === null || isRowDisabled === void 0 ? void 0 : isRowDisabled(row.original)), tableHasSubRows: hasAnySubRows, tableInstance: instance, expanderCell: expanderCell }));
|
|
278
|
+
return (React.createElement(TableRowMemoized, { row: row, rowProps: rowProps, isLast: index === page.length - 1, onRowInViewport: onRowInViewportRef, onBottomReached: onBottomReachedRef, intersectionMargin: intersectionMargin, state: state, key: row.getRowProps().key, onClick: onRowClickHandler, subComponent: subComponent, isDisabled: !!(isRowDisabled === null || isRowDisabled === void 0 ? void 0 : isRowDisabled(row.original)), tableHasSubRows: hasAnySubRows, tableInstance: instance, expanderCell: expanderCell, bodyRef: bodyRefState, tableRowRef: enableVirtualization ? undefined : tableRowRef(row) }));
|
|
276
279
|
}, [
|
|
277
280
|
page,
|
|
278
|
-
expanderCell,
|
|
279
|
-
hasAnySubRows,
|
|
280
|
-
instance,
|
|
281
|
-
intersectionMargin,
|
|
282
|
-
isRowDisabled,
|
|
283
|
-
onRowClickHandler,
|
|
284
281
|
prepareRow,
|
|
285
282
|
rowProps,
|
|
283
|
+
intersectionMargin,
|
|
286
284
|
state,
|
|
285
|
+
onRowClickHandler,
|
|
287
286
|
subComponent,
|
|
287
|
+
isRowDisabled,
|
|
288
|
+
hasAnySubRows,
|
|
289
|
+
instance,
|
|
290
|
+
expanderCell,
|
|
291
|
+
bodyRefState,
|
|
292
|
+
enableVirtualization,
|
|
293
|
+
tableRowRef,
|
|
288
294
|
]);
|
|
289
295
|
var virtualizedItemRenderer = React.useCallback(function (index) { return getPreparedRow(index); }, [getPreparedRow]);
|
|
290
296
|
var updateStickyState = function () {
|
|
@@ -321,7 +327,12 @@ export var Table = function (props) {
|
|
|
321
327
|
className: cx('iui-table', (_a = {}, _a["iui-".concat(density)] = density !== 'default', _a), className),
|
|
322
328
|
style: __assign({ minWidth: 0 }, style),
|
|
323
329
|
}), ariaDataAttributes),
|
|
324
|
-
React.createElement("div", { className: 'iui-table-header-wrapper', ref: headerRef
|
|
330
|
+
React.createElement("div", { className: 'iui-table-header-wrapper', ref: headerRef, onScroll: function () {
|
|
331
|
+
if (headerRef.current && bodyRef.current) {
|
|
332
|
+
bodyRef.current.scrollLeft = headerRef.current.scrollLeft;
|
|
333
|
+
updateStickyState();
|
|
334
|
+
}
|
|
335
|
+
} },
|
|
325
336
|
React.createElement("div", { className: 'iui-table-header' }, headerGroups.slice(1).map(function (headerGroup) {
|
|
326
337
|
var headerGroupProps = headerGroup.getHeaderGroupProps({
|
|
327
338
|
className: 'iui-row',
|
|
@@ -360,13 +371,13 @@ export var Table = function (props) {
|
|
|
360
371
|
'iui-zebra-striping': styleType === 'zebra-rows',
|
|
361
372
|
}),
|
|
362
373
|
style: { outline: 0 },
|
|
363
|
-
}), { ref: bodyRef, onScroll: function () {
|
|
374
|
+
}), { ref: mergeRefs(bodyRef, setBodyRefState), onScroll: function () {
|
|
364
375
|
if (headerRef.current && bodyRef.current) {
|
|
365
376
|
headerRef.current.scrollLeft = bodyRef.current.scrollLeft;
|
|
366
377
|
updateStickyState();
|
|
367
378
|
}
|
|
368
379
|
}, tabIndex: -1 }),
|
|
369
|
-
data.length !== 0 && (React.createElement(React.Fragment, null, enableVirtualization ? (React.createElement(VirtualScroll, { itemsLength: page.length, itemRenderer: virtualizedItemRenderer })) : (page.map(function (_, index) { return getPreparedRow(index); })))),
|
|
380
|
+
data.length !== 0 && (React.createElement(React.Fragment, null, enableVirtualization ? (React.createElement(VirtualScroll, { itemsLength: page.length, itemRenderer: virtualizedItemRenderer, scrollToIndex: scrollToIndex })) : (page.map(function (_, index) { return getPreparedRow(index); })))),
|
|
370
381
|
isLoading && data.length === 0 && (React.createElement("div", { className: 'iui-table-empty' },
|
|
371
382
|
React.createElement(ProgressRadial, { indeterminate: true }))),
|
|
372
383
|
isLoading && data.length !== 0 && (React.createElement("div", { className: 'iui-row' },
|
|
@@ -20,6 +20,8 @@ export declare const TableRow: <T extends Record<string, unknown>>(props: {
|
|
|
20
20
|
tableHasSubRows: boolean;
|
|
21
21
|
tableInstance: TableInstance<T>;
|
|
22
22
|
expanderCell?: ((cellProps: CellProps<T, any>) => React.ReactNode) | undefined;
|
|
23
|
+
bodyRef: HTMLDivElement | null;
|
|
24
|
+
tableRowRef?: React.Ref<HTMLDivElement> | undefined;
|
|
23
25
|
}) => JSX.Element;
|
|
24
26
|
export declare const TableRowMemoized: <T extends Record<string, unknown>>(props: {
|
|
25
27
|
row: Row<T>;
|
|
@@ -35,4 +37,6 @@ export declare const TableRowMemoized: <T extends Record<string, unknown>>(props
|
|
|
35
37
|
tableHasSubRows: boolean;
|
|
36
38
|
tableInstance: TableInstance<T>;
|
|
37
39
|
expanderCell?: ((cellProps: CellProps<T, any>) => React.ReactNode) | undefined;
|
|
40
|
+
bodyRef: HTMLDivElement | null;
|
|
41
|
+
tableRowRef?: React.Ref<HTMLDivElement> | undefined;
|
|
38
42
|
}) => JSX.Element;
|
|
@@ -24,14 +24,25 @@ import { TableCell } from './TableCell';
|
|
|
24
24
|
* When adding new features check whether it changes state that affects row. If it does then add equality check to `React.memo`.
|
|
25
25
|
*/
|
|
26
26
|
export var TableRow = function (props) {
|
|
27
|
-
var row = props.row, rowProps = props.rowProps, isLast = props.isLast, onRowInViewport = props.onRowInViewport, onBottomReached = props.onBottomReached, intersectionMargin = props.intersectionMargin, onClick = props.onClick, subComponent = props.subComponent, isDisabled = props.isDisabled, tableHasSubRows = props.tableHasSubRows, tableInstance = props.tableInstance, expanderCell = props.expanderCell;
|
|
27
|
+
var row = props.row, rowProps = props.rowProps, isLast = props.isLast, onRowInViewport = props.onRowInViewport, onBottomReached = props.onBottomReached, intersectionMargin = props.intersectionMargin, onClick = props.onClick, subComponent = props.subComponent, isDisabled = props.isDisabled, tableHasSubRows = props.tableHasSubRows, tableInstance = props.tableInstance, expanderCell = props.expanderCell, bodyRef = props.bodyRef, tableRowRef = props.tableRowRef;
|
|
28
28
|
var onIntersect = React.useCallback(function () {
|
|
29
29
|
var _a, _b;
|
|
30
30
|
(_a = onRowInViewport.current) === null || _a === void 0 ? void 0 : _a.call(onRowInViewport, row.original);
|
|
31
31
|
isLast && ((_b = onBottomReached.current) === null || _b === void 0 ? void 0 : _b.call(onBottomReached));
|
|
32
32
|
}, [isLast, onBottomReached, onRowInViewport, row.original]);
|
|
33
|
-
var
|
|
33
|
+
var intersectionRoot = React.useMemo(function () {
|
|
34
|
+
var _a, _b;
|
|
35
|
+
var isTableBodyScrollable = ((_a = bodyRef === null || bodyRef === void 0 ? void 0 : bodyRef.scrollHeight) !== null && _a !== void 0 ? _a : 0) > ((_b = bodyRef === null || bodyRef === void 0 ? void 0 : bodyRef.offsetHeight) !== null && _b !== void 0 ? _b : 0);
|
|
36
|
+
// If table body is scrollable, make it the intersection root
|
|
37
|
+
if (isTableBodyScrollable) {
|
|
38
|
+
return bodyRef;
|
|
39
|
+
}
|
|
40
|
+
// Otherwise, make the viewport the intersection root
|
|
41
|
+
return undefined;
|
|
42
|
+
}, [bodyRef]);
|
|
43
|
+
var intersectionRef = useIntersection(onIntersect, {
|
|
34
44
|
rootMargin: "".concat(intersectionMargin, "px"),
|
|
45
|
+
root: intersectionRoot,
|
|
35
46
|
});
|
|
36
47
|
var userRowProps = rowProps === null || rowProps === void 0 ? void 0 : rowProps(row);
|
|
37
48
|
var mergedProps = __assign(__assign(__assign({}, row.getRowProps({ style: { flex: "0 0 auto", minWidth: '100%' } })), userRowProps), {
|
|
@@ -41,7 +52,7 @@ export var TableRow = function (props) {
|
|
|
41
52
|
'iui-disabled': isDisabled,
|
|
42
53
|
}, userRowProps === null || userRowProps === void 0 ? void 0 : userRowProps.className),
|
|
43
54
|
});
|
|
44
|
-
var refs = useMergedRefs(
|
|
55
|
+
var refs = useMergedRefs(intersectionRef, mergedProps.ref, tableRowRef);
|
|
45
56
|
return (React.createElement(React.Fragment, null,
|
|
46
57
|
React.createElement("div", __assign({}, mergedProps, { ref: refs, onClick: function (event) {
|
|
47
58
|
var _a;
|
|
@@ -90,6 +101,7 @@ export var TableRowMemoized = React.memo(TableRow, function (prevProp, nextProp)
|
|
|
90
101
|
prevProp.rowProps === nextProp.rowProps &&
|
|
91
102
|
prevProp.expanderCell === nextProp.expanderCell &&
|
|
92
103
|
prevProp.tableHasSubRows === nextProp.tableHasSubRows &&
|
|
104
|
+
prevProp.bodyRef === nextProp.bodyRef &&
|
|
93
105
|
prevProp.state.columnOrder === nextProp.state.columnOrder &&
|
|
94
106
|
!nextProp.state.columnResizing.isResizingColumn &&
|
|
95
107
|
prevProp.state.isTableResizing === nextProp.state.isTableResizing &&
|
|
@@ -25,6 +25,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
25
25
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
26
26
|
*--------------------------------------------------------------------------------------------*/
|
|
27
27
|
import React from 'react';
|
|
28
|
+
import { getRandomValue } from '../../utils';
|
|
28
29
|
/**
|
|
29
30
|
* Editable cell.
|
|
30
31
|
* It should be passed to `cellRenderer`.
|
|
@@ -47,8 +48,9 @@ export var EditableCell = function (props) {
|
|
|
47
48
|
React.useEffect(function () {
|
|
48
49
|
setValue(sanitizeString(cellProps.value));
|
|
49
50
|
}, [cellProps.value]);
|
|
50
|
-
var _b = React.useState(
|
|
51
|
-
|
|
51
|
+
var _b = React.useState(getRandomValue(10)), key = _b[0], setKey = _b[1];
|
|
52
|
+
var _c = React.useState(false), isDirty = _c[0], setIsDirty = _c[1];
|
|
53
|
+
return (React.createElement("div", __assign({}, cellElementProps, { contentEditable: true, suppressContentEditableWarning: true, key: key }, rest, { onInput: function (e) {
|
|
52
54
|
var _a;
|
|
53
55
|
setValue(sanitizeString(e.target.innerText));
|
|
54
56
|
setIsDirty(true);
|
|
@@ -59,6 +61,9 @@ export var EditableCell = function (props) {
|
|
|
59
61
|
onCellEdit(cellProps.column.id, value, cellProps.row.original);
|
|
60
62
|
}
|
|
61
63
|
(_a = props.onBlur) === null || _a === void 0 ? void 0 : _a.call(props, e);
|
|
64
|
+
// Prevents error when text is cleared.
|
|
65
|
+
// New key makes React to reattach with the DOM so it won't complain about deleted text node.
|
|
66
|
+
setKey(getRandomValue(10));
|
|
62
67
|
}, onKeyDown: function (e) {
|
|
63
68
|
var _a;
|
|
64
69
|
// Prevents from adding HTML elements (div, br) inside a cell on Enter press
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { HeaderProps } from 'react-table';
|
|
3
|
+
import { DropdownMenuProps } from '../../DropdownMenu';
|
|
4
|
+
declare type ActionColumnProps = {
|
|
5
|
+
columnManager?: boolean | {
|
|
6
|
+
dropdownMenuProps: Omit<DropdownMenuProps, 'menuItems' | 'children'>;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
3
9
|
/**
|
|
4
10
|
* Action column that adds column manager to the Table header.
|
|
5
11
|
* It is recommended to add this column to the end of the Table
|
|
@@ -19,9 +25,7 @@ import { HeaderProps } from 'react-table';
|
|
|
19
25
|
* ),
|
|
20
26
|
* },
|
|
21
27
|
*/
|
|
22
|
-
export declare const ActionColumn: <T extends Record<string, unknown>>({ columnManager, }?: {
|
|
23
|
-
columnManager?: boolean | undefined;
|
|
24
|
-
}) => {
|
|
28
|
+
export declare const ActionColumn: <T extends Record<string, unknown>>({ columnManager, }?: ActionColumnProps) => {
|
|
25
29
|
id: string;
|
|
26
30
|
disableResizing: boolean;
|
|
27
31
|
disableGroupBy: boolean;
|
|
@@ -33,3 +37,4 @@ export declare const ActionColumn: <T extends Record<string, unknown>>({ columnM
|
|
|
33
37
|
disableReordering: boolean;
|
|
34
38
|
Header: ({ allColumns, dispatch, state }: HeaderProps<T>) => JSX.Element | null;
|
|
35
39
|
};
|
|
40
|
+
export {};
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
1
12
|
/*---------------------------------------------------------------------------------------------
|
|
2
13
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
14
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
@@ -11,6 +22,7 @@ import { MenuItem } from '../../Menu';
|
|
|
11
22
|
import { tableResizeStartAction } from '../Table';
|
|
12
23
|
import { SELECTION_CELL_ID } from './selectionColumn';
|
|
13
24
|
import { EXPANDER_CELL_ID } from './expanderColumn';
|
|
25
|
+
import cx from 'classnames';
|
|
14
26
|
var ACTION_CELL_ID = 'iui-table-action';
|
|
15
27
|
/**
|
|
16
28
|
* Action column that adds column manager to the Table header.
|
|
@@ -46,6 +58,7 @@ export var ActionColumn = function (_a) {
|
|
|
46
58
|
Header: function (_a) {
|
|
47
59
|
var allColumns = _a.allColumns, dispatch = _a.dispatch, state = _a.state;
|
|
48
60
|
var _b = React.useState(false), isOpen = _b[0], setIsOpen = _b[1];
|
|
61
|
+
var buttonRef = React.useRef(null);
|
|
49
62
|
if (!columnManager) {
|
|
50
63
|
return null;
|
|
51
64
|
}
|
|
@@ -71,13 +84,31 @@ export var ActionColumn = function (_a) {
|
|
|
71
84
|
}
|
|
72
85
|
// Triggers an update to resize the widths of all visible columns
|
|
73
86
|
dispatch({ type: tableResizeStartAction });
|
|
87
|
+
// If some columns were resized and some columns visibility was enabled, then horizontal scrollbar appears
|
|
88
|
+
// and table is scrolled to the very left which means our visibility dropdown menu is not visible.
|
|
89
|
+
// So for better UX we need to scroll to that dropdown menu.
|
|
90
|
+
queueMicrotask(function () {
|
|
91
|
+
var _a;
|
|
92
|
+
(_a = buttonRef.current) === null || _a === void 0 ? void 0 : _a.scrollIntoView();
|
|
93
|
+
});
|
|
74
94
|
};
|
|
75
95
|
return (React.createElement(MenuItem, { key: column.id, icon: React.createElement(Checkbox, { checked: checked, disabled: column.disableToggleVisibility, onClick: function (e) { return e.stopPropagation(); }, onChange: onClick, "aria-labelledby": "iui-column-".concat(column.id) }), onClick: onClick, disabled: column.disableToggleVisibility },
|
|
76
96
|
React.createElement("div", { id: "iui-column-".concat(column.id) }, column.render('Header'))));
|
|
77
97
|
});
|
|
78
98
|
};
|
|
79
|
-
|
|
80
|
-
|
|
99
|
+
var dropdownMenuProps = typeof columnManager !== 'boolean'
|
|
100
|
+
? columnManager.dropdownMenuProps
|
|
101
|
+
: {};
|
|
102
|
+
return (React.createElement(DropdownMenu, __assign({}, dropdownMenuProps, { menuItems: headerCheckBoxes, onHide: function (i) {
|
|
103
|
+
var _a;
|
|
104
|
+
setIsOpen(false);
|
|
105
|
+
(_a = dropdownMenuProps.onHide) === null || _a === void 0 ? void 0 : _a.call(dropdownMenuProps, i);
|
|
106
|
+
}, onShow: function (i) {
|
|
107
|
+
var _a;
|
|
108
|
+
setIsOpen(true);
|
|
109
|
+
(_a = dropdownMenuProps.onShow) === null || _a === void 0 ? void 0 : _a.call(dropdownMenuProps, i);
|
|
110
|
+
}, style: __assign({ maxHeight: '315px' }, dropdownMenuProps.style), className: cx('iui-scroll', dropdownMenuProps.className) }),
|
|
111
|
+
React.createElement(IconButton, { styleType: 'borderless', isActive: isOpen, ref: buttonRef },
|
|
81
112
|
React.createElement(SvgColumnManager, null))));
|
|
82
113
|
},
|
|
83
114
|
};
|
|
@@ -4,4 +4,5 @@ export { useSubRowFiltering } from './useSubRowFiltering';
|
|
|
4
4
|
export { useSubRowSelection } from './useSubRowSelection';
|
|
5
5
|
export { useResizeColumns } from './useResizeColumns';
|
|
6
6
|
export { useColumnDragAndDrop } from './useColumnDragAndDrop';
|
|
7
|
+
export { useScrollToRow } from './useScrollToRow';
|
|
7
8
|
export { useStickyColumns } from './useStickyColumns';
|
|
@@ -8,4 +8,5 @@ export { useSubRowFiltering } from './useSubRowFiltering';
|
|
|
8
8
|
export { useSubRowSelection } from './useSubRowSelection';
|
|
9
9
|
export { useResizeColumns } from './useResizeColumns';
|
|
10
10
|
export { useColumnDragAndDrop } from './useColumnDragAndDrop';
|
|
11
|
+
export { useScrollToRow } from './useScrollToRow';
|
|
11
12
|
export { useStickyColumns } from './useStickyColumns';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Row } from 'react-table';
|
|
2
|
+
import { TableProps } from '../Table';
|
|
3
|
+
declare type ScrollToRow<T extends Record<string, unknown>> = {
|
|
4
|
+
scrollToIndex: number | undefined;
|
|
5
|
+
tableRowRef: (row: Row<T>) => (element: HTMLDivElement) => void;
|
|
6
|
+
};
|
|
7
|
+
declare type ScrollToRowProps<T extends Record<string, unknown>> = TableProps<T> & {
|
|
8
|
+
page: Row<T>[];
|
|
9
|
+
};
|
|
10
|
+
export declare function useScrollToRow<T extends Record<string, unknown>>({ data, enableVirtualization, page, paginatorRenderer, scrollToRow, }: ScrollToRowProps<T>): ScrollToRow<T>;
|
|
11
|
+
export {};
|