@itwin/itwinui-react 1.33.0 → 1.34.1
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 +25 -0
- package/cjs/core/ButtonGroup/ButtonGroup.d.ts +0 -2
- package/cjs/core/ButtonGroup/ButtonGroup.js +3 -4
- package/cjs/core/ComboBox/ComboBox.js +2 -2
- package/cjs/core/Slider/Slider.js +10 -1
- package/cjs/core/Table/Table.d.ts +5 -0
- package/cjs/core/Table/Table.js +8 -8
- package/cjs/core/Table/TableRowMemoized.js +1 -0
- package/cjs/core/Table/actionHandlers/resizeHandler.d.ts +2 -0
- package/cjs/core/Table/actionHandlers/selectHandler.d.ts +1 -0
- package/cjs/core/Table/filters/BaseFilter.js +1 -1
- package/cjs/core/Table/filters/FilterToggle.js +4 -4
- package/cjs/core/Table/hooks/index.d.ts +1 -0
- package/cjs/core/Table/hooks/index.js +3 -1
- package/cjs/core/Table/hooks/useColumnDragAndDrop.d.ts +2 -0
- package/cjs/core/Table/hooks/useColumnDragAndDrop.js +120 -0
- package/cjs/core/Table/hooks/useExpanderCell.js +1 -0
- package/cjs/core/Table/hooks/useResizeColumns.js +8 -4
- package/cjs/core/Table/hooks/useSelectionCell.js +2 -2
- package/cjs/core/ToggleSwitch/ToggleSwitch.js +13 -10
- package/cjs/core/UserIcon/UserIcon.js +1 -10
- package/cjs/core/utils/hooks/useIntersection.d.ts +4 -3
- package/cjs/core/utils/hooks/useIntersection.js +10 -5
- package/cjs/core/utils/hooks/useOverflow.d.ts +3 -2
- package/cjs/core/utils/hooks/useOverflow.js +24 -21
- package/cjs/types/react-table-config.d.ts +7 -0
- package/esm/core/ButtonGroup/ButtonGroup.d.ts +0 -2
- package/esm/core/ButtonGroup/ButtonGroup.js +3 -4
- package/esm/core/ComboBox/ComboBox.js +2 -2
- package/esm/core/Slider/Slider.js +10 -1
- package/esm/core/Table/Table.d.ts +5 -0
- package/esm/core/Table/Table.js +10 -10
- package/esm/core/Table/TableRowMemoized.js +1 -0
- package/esm/core/Table/actionHandlers/resizeHandler.d.ts +2 -0
- package/esm/core/Table/actionHandlers/selectHandler.d.ts +1 -0
- package/esm/core/Table/filters/BaseFilter.js +1 -1
- package/esm/core/Table/filters/FilterToggle.js +4 -4
- package/esm/core/Table/hooks/index.d.ts +1 -0
- package/esm/core/Table/hooks/index.js +1 -0
- package/esm/core/Table/hooks/useColumnDragAndDrop.d.ts +2 -0
- package/esm/core/Table/hooks/useColumnDragAndDrop.js +116 -0
- package/esm/core/Table/hooks/useExpanderCell.js +1 -0
- package/esm/core/Table/hooks/useResizeColumns.js +8 -4
- package/esm/core/Table/hooks/useSelectionCell.js +2 -2
- package/esm/core/ToggleSwitch/ToggleSwitch.js +13 -10
- package/esm/core/UserIcon/UserIcon.js +1 -10
- package/esm/core/utils/hooks/useIntersection.d.ts +4 -3
- package/esm/core/utils/hooks/useIntersection.js +10 -5
- package/esm/core/utils/hooks/useOverflow.d.ts +3 -2
- package/esm/core/utils/hooks/useOverflow.js +24 -21
- package/esm/types/react-table-config.d.ts +7 -0
- package/package.json +15 -14
|
@@ -14,13 +14,14 @@ var useResizeObserver_1 = require("./useResizeObserver");
|
|
|
14
14
|
var STARTING_MAX_ITEMS_COUNT = 20;
|
|
15
15
|
/**
|
|
16
16
|
* Hook that observes the size of an element and returns the number of items
|
|
17
|
-
* that should be visible based on the
|
|
17
|
+
* that should be visible based on the size of the container element.
|
|
18
18
|
*
|
|
19
19
|
* The returned number should be used to render the element with fewer items.
|
|
20
20
|
*
|
|
21
21
|
* @private
|
|
22
22
|
* @param items Items that this element contains.
|
|
23
23
|
* @param disabled Set to true to disconnect the observer.
|
|
24
|
+
* @param dimension 'horizontal' (default) or 'vertical'
|
|
24
25
|
* @returns [callback ref to set on container, stateful count of visible items]
|
|
25
26
|
*
|
|
26
27
|
* @example
|
|
@@ -33,20 +34,21 @@ var STARTING_MAX_ITEMS_COUNT = 20;
|
|
|
33
34
|
* </div>
|
|
34
35
|
* );
|
|
35
36
|
*/
|
|
36
|
-
var useOverflow = function (items, disabled) {
|
|
37
|
+
var useOverflow = function (items, disabled, orientation) {
|
|
37
38
|
if (disabled === void 0) { disabled = false; }
|
|
39
|
+
if (orientation === void 0) { orientation = 'horizontal'; }
|
|
38
40
|
var containerRef = react_1.default.useRef(null);
|
|
39
41
|
var _a = react_1.default.useState(function () {
|
|
40
42
|
return disabled ? items.length : Math.min(items.length, STARTING_MAX_ITEMS_COUNT);
|
|
41
43
|
}), visibleCount = _a[0], setVisibleCount = _a[1];
|
|
42
44
|
var needsFullRerender = react_1.default.useRef(true);
|
|
43
|
-
var _b = react_1.default.useState(0),
|
|
44
|
-
var
|
|
45
|
-
var
|
|
46
|
-
var width = _a.width;
|
|
47
|
-
return
|
|
48
|
-
}, []);
|
|
49
|
-
var _c = (0, useResizeObserver_1.useResizeObserver)(
|
|
45
|
+
var _b = react_1.default.useState(0), containerSize = _b[0], setContainerSize = _b[1];
|
|
46
|
+
var previousContainerSize = react_1.default.useRef(0);
|
|
47
|
+
var updateContainerSize = react_1.default.useCallback(function (_a) {
|
|
48
|
+
var width = _a.width, height = _a.height;
|
|
49
|
+
return setContainerSize(orientation === 'horizontal' ? width : height);
|
|
50
|
+
}, [orientation]);
|
|
51
|
+
var _c = (0, useResizeObserver_1.useResizeObserver)(updateContainerSize), resizeRef = _c[0], observer = _c[1];
|
|
50
52
|
var resizeObserverRef = react_1.default.useRef(observer);
|
|
51
53
|
react_1.default.useLayoutEffect(function () {
|
|
52
54
|
if (disabled) {
|
|
@@ -56,7 +58,7 @@ var useOverflow = function (items, disabled) {
|
|
|
56
58
|
setVisibleCount(Math.min(items.length, STARTING_MAX_ITEMS_COUNT));
|
|
57
59
|
needsFullRerender.current = true;
|
|
58
60
|
}
|
|
59
|
-
}, [
|
|
61
|
+
}, [containerSize, disabled, items]);
|
|
60
62
|
var mergedRefs = (0, useMergedRefs_1.useMergedRefs)(containerRef, resizeRef);
|
|
61
63
|
react_1.default.useLayoutEffect(function () {
|
|
62
64
|
var _a;
|
|
@@ -64,25 +66,26 @@ var useOverflow = function (items, disabled) {
|
|
|
64
66
|
(_a = resizeObserverRef.current) === null || _a === void 0 ? void 0 : _a.disconnect();
|
|
65
67
|
return;
|
|
66
68
|
}
|
|
67
|
-
var
|
|
68
|
-
var
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
var
|
|
69
|
+
var dimension = orientation === 'horizontal' ? 'Width' : 'Height';
|
|
70
|
+
var availableSize = containerRef.current["offset" + dimension];
|
|
71
|
+
var requiredSize = containerRef.current["scroll" + dimension];
|
|
72
|
+
if (availableSize < requiredSize) {
|
|
73
|
+
var avgItemSize = requiredSize / visibleCount;
|
|
74
|
+
var visibleItems = Math.floor(availableSize / avgItemSize);
|
|
72
75
|
setVisibleCount(visibleItems);
|
|
73
76
|
}
|
|
74
77
|
else if (needsFullRerender.current) {
|
|
75
|
-
var
|
|
76
|
-
var
|
|
77
|
-
var visibleItems = Math.floor(
|
|
78
|
+
var childrenSize = Array.from(containerRef.current.children).reduce(function (sum, child) { return sum + child["offset" + dimension]; }, 0);
|
|
79
|
+
var avgItemSize = childrenSize / visibleCount;
|
|
80
|
+
var visibleItems = Math.floor(availableSize / avgItemSize);
|
|
78
81
|
// Doubling the visible items to overflow the container. Just to be safe.
|
|
79
82
|
setVisibleCount(Math.min(items.length, visibleItems * 2));
|
|
80
83
|
}
|
|
81
84
|
needsFullRerender.current = false;
|
|
82
|
-
}, [
|
|
85
|
+
}, [containerSize, visibleCount, disabled, items.length, orientation]);
|
|
83
86
|
react_1.default.useLayoutEffect(function () {
|
|
84
|
-
|
|
85
|
-
}, [
|
|
87
|
+
previousContainerSize.current = containerSize;
|
|
88
|
+
}, [containerSize]);
|
|
86
89
|
return [mergedRefs, visibleCount];
|
|
87
90
|
};
|
|
88
91
|
exports.useOverflow = useOverflow;
|
|
@@ -32,6 +32,7 @@ declare module 'react-table' {
|
|
|
32
32
|
isResizingColumn?: string;
|
|
33
33
|
};
|
|
34
34
|
isTableResizing?: boolean;
|
|
35
|
+
columnReorderStartIndex: number;
|
|
35
36
|
}
|
|
36
37
|
interface ColumnInterface<D extends object = {}> extends UseSortByColumnOptions<D>, UseFiltersColumnOptions<D>, UseResizeColumnsColumnOptions<D> {
|
|
37
38
|
/**
|
|
@@ -67,11 +68,17 @@ declare module 'react-table' {
|
|
|
67
68
|
* }
|
|
68
69
|
*/
|
|
69
70
|
cellRenderer?: (props: CellRendererProps<D>) => React.ReactNode;
|
|
71
|
+
/**
|
|
72
|
+
* If true, column can't be reordered.
|
|
73
|
+
* @default false
|
|
74
|
+
*/
|
|
75
|
+
disableReordering?: boolean;
|
|
70
76
|
}
|
|
71
77
|
interface ColumnInstance<D extends object = {}> extends UseFiltersColumnProps<D>, UseGroupByColumnProps<D>, UseResizeColumnsColumnProps<D>, UseSortByColumnProps<D> {
|
|
72
78
|
originalWidth: number;
|
|
73
79
|
resizeWidth?: number;
|
|
74
80
|
isResizerVisible?: boolean;
|
|
81
|
+
getDragAndDropProps: () => TableKeyedProps;
|
|
75
82
|
}
|
|
76
83
|
interface Cell<D extends object = {}> extends UseGroupByCellProps<D>, UseRowStateCellProps<D> {
|
|
77
84
|
}
|
|
@@ -13,8 +13,6 @@ export declare type ButtonGroupProps = {
|
|
|
13
13
|
* and returns the `ReactNode` to render.
|
|
14
14
|
*
|
|
15
15
|
* The placement of this button can be controlled using the `overflowPlacement` prop.
|
|
16
|
-
*
|
|
17
|
-
* *Note: this will not work with `orientation='vertical'`.*
|
|
18
16
|
*/
|
|
19
17
|
overflowButton?: (firstOverflowingIndex: number) => React.ReactNode;
|
|
20
18
|
/**
|
|
@@ -57,16 +57,15 @@ import '@itwin/itwinui-css/css/button.css';
|
|
|
57
57
|
* </ButtonGroup>
|
|
58
58
|
*/
|
|
59
59
|
export var ButtonGroup = React.forwardRef(function (props, ref) {
|
|
60
|
-
var children = props.children, className = props.className,
|
|
60
|
+
var children = props.children, className = props.className, overflowButton = props.overflowButton, _a = props.overflowPlacement, overflowPlacement = _a === void 0 ? 'end' : _a, _b = props.orientation, orientation = _b === void 0 ? 'horizontal' : _b, rest = __rest(props, ["children", "className", "overflowButton", "overflowPlacement", "orientation"]);
|
|
61
61
|
var items = React.useMemo(function () { var _a; return (_a = React.Children.map(children, function (child) { return React.createElement("div", null, child); })) !== null && _a !== void 0 ? _a : []; }, [children]);
|
|
62
62
|
useTheme();
|
|
63
|
-
var _c = useOverflow(items, !overflowButton), overflowRef = _c[0], visibleCount = _c[1];
|
|
63
|
+
var _c = useOverflow(items, !overflowButton, orientation), overflowRef = _c[0], visibleCount = _c[1];
|
|
64
64
|
var refs = useMergedRefs(overflowRef, ref);
|
|
65
65
|
return (React.createElement("div", __assign({ className: cx({
|
|
66
66
|
'iui-button-group': orientation === 'horizontal',
|
|
67
67
|
'iui-button-group-vertical': orientation === 'vertical',
|
|
68
|
-
}, className),
|
|
69
|
-
orientation === 'horizontal' && { width: '100%' })), style), "aria-orientation": orientation, ref: refs }, rest), !!overflowButton && visibleCount < items.length ? (React.createElement(React.Fragment, null,
|
|
68
|
+
}, className), "aria-orientation": orientation, ref: refs }, rest), !!overflowButton && visibleCount < items.length ? (React.createElement(React.Fragment, null,
|
|
70
69
|
overflowButton && overflowPlacement === 'start' && (React.createElement("div", null, overflowButton(visibleCount))),
|
|
71
70
|
items.slice(0, visibleCount - 1),
|
|
72
71
|
overflowButton && overflowPlacement === 'end' && (React.createElement("div", null, overflowButton(visibleCount))))) : (items)));
|
|
@@ -294,9 +294,9 @@ export var ComboBox = function (props) {
|
|
|
294
294
|
}
|
|
295
295
|
(_a = dropdownMenuProps === null || dropdownMenuProps === void 0 ? void 0 : dropdownMenuProps.onHide) === null || _a === void 0 ? void 0 : _a.call(dropdownMenuProps, instance);
|
|
296
296
|
} }),
|
|
297
|
-
React.createElement(Input, __assign({ ref: inputRef, onKeyDown: onKeyDown, onFocus: function () { return setIsOpen(true); },
|
|
297
|
+
React.createElement(Input, __assign({ ref: inputRef, onKeyDown: onKeyDown, onFocus: function () { return setIsOpen(true); }, value: inputValue, "aria-activedescendant": isOpen && focusedIndex > -1
|
|
298
298
|
? getOptionId(focusedIndex)
|
|
299
|
-
: undefined, role: 'combobox', "aria-controls": isOpen ? id + "-list" : undefined, "aria-autocomplete": 'list', spellCheck: false, autoCapitalize: 'none', autoCorrect: 'off' }, inputProps))),
|
|
299
|
+
: undefined, role: 'combobox', "aria-controls": isOpen ? id + "-list" : undefined, "aria-autocomplete": 'list', spellCheck: false, autoCapitalize: 'none', autoCorrect: 'off' }, inputProps, { onChange: onInput }))),
|
|
300
300
|
React.createElement("span", { ref: toggleButtonRef, className: cx('iui-end-icon', {
|
|
301
301
|
'iui-actionable': !(inputProps === null || inputProps === void 0 ? void 0 : inputProps.disabled),
|
|
302
302
|
'iui-disabled': inputProps === null || inputProps === void 0 ? void 0 : inputProps.disabled,
|
|
@@ -202,11 +202,20 @@ export var Slider = React.forwardRef(function (props, ref) {
|
|
|
202
202
|
newValues[closestValueIndex] = pointerValue;
|
|
203
203
|
setCurrentValues(newValues);
|
|
204
204
|
onChange === null || onChange === void 0 ? void 0 : onChange(newValues);
|
|
205
|
+
onUpdate === null || onUpdate === void 0 ? void 0 : onUpdate(newValues);
|
|
205
206
|
focusThumb(containerRef.current, closestValueIndex);
|
|
206
207
|
event.preventDefault();
|
|
207
208
|
event.stopPropagation();
|
|
208
209
|
}
|
|
209
|
-
}, [
|
|
210
|
+
}, [
|
|
211
|
+
min,
|
|
212
|
+
max,
|
|
213
|
+
step,
|
|
214
|
+
currentValues,
|
|
215
|
+
getAllowableThumbRange,
|
|
216
|
+
onChange,
|
|
217
|
+
onUpdate,
|
|
218
|
+
]);
|
|
210
219
|
useEventListener('pointermove', handlePointerMove, (_a = containerRef.current) === null || _a === void 0 ? void 0 : _a.ownerDocument);
|
|
211
220
|
useEventListener('pointerup', handlePointerUp, (_b = containerRef.current) === null || _b === void 0 ? void 0 : _b.ownerDocument);
|
|
212
221
|
var tickMarkArea = React.useMemo(function () {
|
|
@@ -170,6 +170,11 @@ export declare type TableProps<T extends Record<string, unknown> = Record<string
|
|
|
170
170
|
* @beta
|
|
171
171
|
*/
|
|
172
172
|
enableVirtualization?: boolean;
|
|
173
|
+
/**
|
|
174
|
+
* Flag whether columns can be reordered.
|
|
175
|
+
* @default false
|
|
176
|
+
*/
|
|
177
|
+
enableColumnReordering?: boolean;
|
|
173
178
|
} & Omit<CommonProps, 'title'>;
|
|
174
179
|
/**
|
|
175
180
|
* Table based on [react-table](https://react-table.tanstack.com/docs/api/overview).
|
package/esm/core/Table/Table.js
CHANGED
|
@@ -26,7 +26,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
26
26
|
*--------------------------------------------------------------------------------------------*/
|
|
27
27
|
import React from 'react';
|
|
28
28
|
import cx from 'classnames';
|
|
29
|
-
import { actions as TableActions, useFlexLayout, useFilters, useRowSelect, useSortBy, useTable, useExpanded, usePagination, } from 'react-table';
|
|
29
|
+
import { actions as TableActions, useFlexLayout, useFilters, useRowSelect, useSortBy, useTable, useExpanded, usePagination, useColumnOrder, } from 'react-table';
|
|
30
30
|
import { ProgressRadial } from '../ProgressIndicators';
|
|
31
31
|
import { useTheme, useResizeObserver } from '../utils';
|
|
32
32
|
import '@itwin/itwinui-css/css/table.css';
|
|
@@ -36,7 +36,7 @@ import { getCellStyle } 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, } from './hooks';
|
|
39
|
+
import { useExpanderCell, useSelectionCell, useSubRowFiltering, useSubRowSelection, useResizeColumns, useColumnDragAndDrop, } from './hooks';
|
|
40
40
|
import { onExpandHandler, onFilterHandler, onSelectHandler, } from './actionHandlers';
|
|
41
41
|
import { onSingleSelectHandler } from './actionHandlers/selectHandler';
|
|
42
42
|
import { onTableResizeEnd, onTableResizeStart, } from './actionHandlers/resizeHandler';
|
|
@@ -88,9 +88,9 @@ var tableResizeEndAction = 'tableResizeEnd';
|
|
|
88
88
|
*/
|
|
89
89
|
export var Table = function (props) {
|
|
90
90
|
var _a;
|
|
91
|
-
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, _l = props.styleType, styleType = _l === void 0 ? 'default' : _l, _m = props.enableVirtualization, enableVirtualization = _m === void 0 ? false : _m, 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", "styleType", "enableVirtualization"]);
|
|
91
|
+
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, _l = props.styleType, styleType = _l === void 0 ? 'default' : _l, _m = props.enableVirtualization, enableVirtualization = _m === void 0 ? false : _m, _o = props.enableColumnReordering, enableColumnReordering = _o === void 0 ? false : _o, 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", "styleType", "enableVirtualization", "enableColumnReordering"]);
|
|
92
92
|
useTheme();
|
|
93
|
-
var
|
|
93
|
+
var _p = React.useState(), ownerDocument = _p[0], setOwnerDocument = _p[1];
|
|
94
94
|
var defaultColumn = React.useMemo(function () { return ({
|
|
95
95
|
maxWidth: 0,
|
|
96
96
|
minWidth: 0,
|
|
@@ -146,7 +146,7 @@ export var Table = function (props) {
|
|
|
146
146
|
return getSubRows ? getSubRows(item, index) : item.subRows;
|
|
147
147
|
});
|
|
148
148
|
}, [data, getSubRows]);
|
|
149
|
-
var instance = useTable(__assign(__assign({ manualPagination: !paginatorRenderer, paginateExpandedRows: false }, props), { columns: columns, defaultColumn: defaultColumn, disableSortBy: !isSortable, stateReducer: tableStateReducer, filterTypes: filterTypes, selectSubRows: selectSubRows, data: data, getSubRows: getSubRows, initialState: __assign({ pageSize: pageSize }, props.initialState) }), useFlexLayout, useResizeColumns(ownerDocument), useFilters, useSubRowFiltering(hasAnySubRows), useSortBy, useExpanded, usePagination, useRowSelect, useSubRowSelection, useExpanderCell(subComponent, expanderCell, isRowDisabled), useSelectionCell(isSelectable, isRowDisabled));
|
|
149
|
+
var instance = useTable(__assign(__assign({ manualPagination: !paginatorRenderer, paginateExpandedRows: false }, props), { columns: columns, defaultColumn: defaultColumn, disableSortBy: !isSortable, stateReducer: tableStateReducer, filterTypes: filterTypes, selectSubRows: selectSubRows, data: data, getSubRows: getSubRows, initialState: __assign({ pageSize: pageSize }, props.initialState) }), useFlexLayout, useResizeColumns(ownerDocument), useFilters, useSubRowFiltering(hasAnySubRows), useSortBy, useExpanded, usePagination, useRowSelect, useSubRowSelection, useExpanderCell(subComponent, expanderCell, isRowDisabled), useSelectionCell(isSelectable, isRowDisabled), useColumnOrder, useColumnDragAndDrop(enableColumnReordering));
|
|
150
150
|
var getTableProps = instance.getTableProps, rows = instance.rows, headerGroups = instance.headerGroups, getTableBodyProps = instance.getTableBodyProps, prepareRow = instance.prepareRow, state = instance.state, allColumns = instance.allColumns, filteredFlatRows = instance.filteredFlatRows, dispatch = instance.dispatch, page = instance.page, gotoPage = instance.gotoPage, setPageSize = instance.setPageSize, flatHeaders = instance.flatHeaders;
|
|
151
151
|
var ariaDataAttributes = Object.entries(rest).reduce(function (result, _a) {
|
|
152
152
|
var key = _a[0], value = _a[1];
|
|
@@ -260,21 +260,21 @@ export var Table = function (props) {
|
|
|
260
260
|
className: 'iui-row',
|
|
261
261
|
});
|
|
262
262
|
return (React.createElement("div", __assign({}, headerGroupProps, { key: headerGroupProps.key }), headerGroup.headers.map(function (column, index) {
|
|
263
|
-
var
|
|
264
|
-
|
|
265
|
-
return (React.createElement("div", __assign({}, columnProps, { key: columnProps.key, title: undefined, ref: function (el) {
|
|
263
|
+
var columnProps = column.getHeaderProps(__assign(__assign({}, column.getSortByToggleProps()), { className: cx('iui-cell', { 'iui-actionable': column.canSort }, { 'iui-sorted': column.isSorted }, column.columnClassName), style: __assign({}, getCellStyle(column, !!state.isTableResizing)) }));
|
|
264
|
+
return (React.createElement("div", __assign({}, columnProps, column.getDragAndDropProps(), { key: columnProps.key, title: undefined, ref: function (el) {
|
|
266
265
|
if (el && isResizable) {
|
|
267
266
|
columnRefs.current[column.id] = el;
|
|
268
267
|
column.resizeWidth = el.getBoundingClientRect().width;
|
|
269
268
|
}
|
|
270
|
-
}
|
|
269
|
+
} }),
|
|
271
270
|
column.render('Header'),
|
|
272
271
|
!isLoading && (data.length != 0 || areFiltersSet) && (React.createElement(FilterToggle, { column: column, ownerDocument: ownerDocument })),
|
|
273
272
|
!isLoading && data.length != 0 && column.canSort && (React.createElement("div", { className: 'iui-cell-end-icon' }, column.isSorted && column.isSortedDesc ? (React.createElement(SvgSortUp, { className: 'iui-icon iui-sort', "aria-hidden": true })) : (React.createElement(SvgSortDown, { className: 'iui-icon iui-sort', "aria-hidden": true })))),
|
|
274
273
|
isResizable &&
|
|
275
274
|
column.isResizerVisible &&
|
|
276
275
|
index !== headerGroup.headers.length - 1 && (React.createElement("div", __assign({}, column.getResizerProps(), { className: 'iui-resizer' }),
|
|
277
|
-
React.createElement("div", { className: 'iui-resizer-bar' })))
|
|
276
|
+
React.createElement("div", { className: 'iui-resizer-bar' }))),
|
|
277
|
+
enableColumnReordering && !column.disableReordering && (React.createElement("div", { className: 'iui-reorder-bar' }))));
|
|
278
278
|
})));
|
|
279
279
|
})),
|
|
280
280
|
React.createElement("div", __assign({}, getTableBodyProps({
|
|
@@ -85,6 +85,7 @@ export var TableRowMemoized = React.memo(TableRow, function (prevProp, nextProp)
|
|
|
85
85
|
prevProp.rowProps === nextProp.rowProps &&
|
|
86
86
|
prevProp.expanderCell === nextProp.expanderCell &&
|
|
87
87
|
prevProp.tableHasSubRows === nextProp.tableHasSubRows &&
|
|
88
|
+
prevProp.state.columnOrder === nextProp.state.columnOrder &&
|
|
88
89
|
!nextProp.state.columnResizing.isResizingColumn &&
|
|
89
90
|
!nextProp.state.isTableResizing;
|
|
90
91
|
});
|
|
@@ -11,6 +11,7 @@ export declare const onTableResizeStart: <T extends Record<string, unknown>>(sta
|
|
|
11
11
|
columnWidths: Record<string, number>;
|
|
12
12
|
isResizingColumn?: string | undefined;
|
|
13
13
|
};
|
|
14
|
+
columnReorderStartIndex: number;
|
|
14
15
|
columnOrder: import("react-table").IdType<T>[];
|
|
15
16
|
expanded: Record<import("react-table").IdType<T>, boolean>;
|
|
16
17
|
filters: import("react-table").Filters<T>;
|
|
@@ -36,6 +37,7 @@ export declare const onTableResizeEnd: <T extends Record<string, unknown>>(state
|
|
|
36
37
|
isResizingColumn?: string | undefined;
|
|
37
38
|
};
|
|
38
39
|
hiddenColumns?: import("react-table").IdType<T>[] | undefined;
|
|
40
|
+
columnReorderStartIndex: number;
|
|
39
41
|
columnOrder: import("react-table").IdType<T>[];
|
|
40
42
|
expanded: Record<import("react-table").IdType<T>, boolean>;
|
|
41
43
|
filters: import("react-table").Filters<T>;
|
|
@@ -19,6 +19,7 @@ export declare const onSingleSelectHandler: <T extends Record<string, unknown>>(
|
|
|
19
19
|
isResizingColumn?: string | undefined;
|
|
20
20
|
};
|
|
21
21
|
isTableResizing?: boolean | undefined;
|
|
22
|
+
columnReorderStartIndex: number;
|
|
22
23
|
columnOrder: import("react-table").IdType<T>[];
|
|
23
24
|
expanded: Record<import("react-table").IdType<T>, boolean>;
|
|
24
25
|
filters: import("react-table").Filters<T>;
|
|
@@ -25,7 +25,7 @@ export var BaseFilter = function (props) {
|
|
|
25
25
|
useTheme();
|
|
26
26
|
return (React.createElement("div", { className: cx('iui-column-filter', className), style: style,
|
|
27
27
|
// Prevents from triggering sort
|
|
28
|
-
|
|
28
|
+
onClick: function (e) {
|
|
29
29
|
e.stopPropagation();
|
|
30
30
|
}, id: id }, children));
|
|
31
31
|
};
|
|
@@ -48,9 +48,9 @@ export var FilterToggle = function (props) {
|
|
|
48
48
|
close();
|
|
49
49
|
}, [close, column]);
|
|
50
50
|
return (React.createElement(React.Fragment, null, column.canFilter && column.Filter && (React.createElement(Popover, { content: column.render('Filter', { close: close, setFilter: setFilter, clearFilter: clearFilter }), placement: 'bottom-start', visible: isVisible, onClickOutside: close, appendTo: ownerDocument === null || ownerDocument === void 0 ? void 0 : ownerDocument.body },
|
|
51
|
-
React.createElement(IconButton, __assign({ styleType: 'borderless', isActive: isVisible || column.filterValue, className: cx('iui-filter-button', className), onClick: function () {
|
|
51
|
+
React.createElement(IconButton, __assign({ styleType: 'borderless', isActive: isVisible || column.filterValue, className: cx('iui-filter-button', className), onClick: function (e) {
|
|
52
52
|
setIsVisible(function (v) { return !v; });
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
// Prevents from triggering sort
|
|
54
|
+
e.stopPropagation();
|
|
55
|
+
} }, rest), column.filterValue ? React.createElement(SvgFilter, null) : React.createElement(SvgFilterHollow, null))))));
|
|
56
56
|
};
|
|
@@ -3,3 +3,4 @@ export { SELECTION_CELL_ID, useSelectionCell } from './useSelectionCell';
|
|
|
3
3
|
export { useSubRowFiltering } from './useSubRowFiltering';
|
|
4
4
|
export { useSubRowSelection } from './useSubRowSelection';
|
|
5
5
|
export { useResizeColumns } from './useResizeColumns';
|
|
6
|
+
export { useColumnDragAndDrop } from './useColumnDragAndDrop';
|
|
@@ -7,3 +7,4 @@ export { SELECTION_CELL_ID, useSelectionCell } from './useSelectionCell';
|
|
|
7
7
|
export { useSubRowFiltering } from './useSubRowFiltering';
|
|
8
8
|
export { useSubRowSelection } from './useSubRowSelection';
|
|
9
9
|
export { useResizeColumns } from './useResizeColumns';
|
|
10
|
+
export { useColumnDragAndDrop } from './useColumnDragAndDrop';
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
13
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
14
|
+
if (ar || !(i in from)) {
|
|
15
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
16
|
+
ar[i] = from[i];
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
20
|
+
};
|
|
21
|
+
import { actions, makePropGetter, useGetLatest, } from 'react-table';
|
|
22
|
+
var REORDER_ACTIONS = {
|
|
23
|
+
columnDragStart: 'columnDragStart',
|
|
24
|
+
columnDragEnd: 'columnDragEnd',
|
|
25
|
+
};
|
|
26
|
+
export var useColumnDragAndDrop = function (isEnabled) { return function (hooks) {
|
|
27
|
+
hooks.getDragAndDropProps = [defaultGetDragAndDropProps(isEnabled)];
|
|
28
|
+
hooks.stateReducers.push(reducer);
|
|
29
|
+
hooks.useInstance.push(useInstance);
|
|
30
|
+
}; };
|
|
31
|
+
var defaultGetDragAndDropProps = function (isEnabled) { return function (props, _a) {
|
|
32
|
+
var instance = _a.instance, header = _a.header;
|
|
33
|
+
if (!isEnabled || header.disableReordering) {
|
|
34
|
+
return props;
|
|
35
|
+
}
|
|
36
|
+
var onDragStart = function () {
|
|
37
|
+
instance.dispatch({
|
|
38
|
+
type: REORDER_ACTIONS.columnDragStart,
|
|
39
|
+
columnIndex: instance.flatHeaders.indexOf(header),
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
var setOnDragColumnStyle = function (event, position) {
|
|
43
|
+
var columnElement = event.currentTarget;
|
|
44
|
+
columnElement.classList.remove('iui-reorder-column-right');
|
|
45
|
+
columnElement.classList.remove('iui-reorder-column-left');
|
|
46
|
+
if (position === 'left') {
|
|
47
|
+
columnElement.classList.add('iui-reorder-column-left');
|
|
48
|
+
}
|
|
49
|
+
else if (position === 'right') {
|
|
50
|
+
columnElement.classList.add('iui-reorder-column-right');
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
var reorderColumns = function (tableColumns, srcIndex, dstIndex) {
|
|
54
|
+
var newTableColumns = __spreadArray([], tableColumns, true);
|
|
55
|
+
var removed = newTableColumns.splice(srcIndex, 1)[0];
|
|
56
|
+
newTableColumns.splice(dstIndex, 0, removed);
|
|
57
|
+
return newTableColumns;
|
|
58
|
+
};
|
|
59
|
+
var onDragOver = function (event) {
|
|
60
|
+
event.preventDefault();
|
|
61
|
+
var headerIndex = instance.flatHeaders.indexOf(header);
|
|
62
|
+
if (instance.state.columnReorderStartIndex !== headerIndex) {
|
|
63
|
+
setOnDragColumnStyle(event, instance.state.columnReorderStartIndex > headerIndex ? 'left' : 'right');
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
var onDragLeave = function (event) {
|
|
67
|
+
setOnDragColumnStyle(event);
|
|
68
|
+
};
|
|
69
|
+
var onDrop = function (event) {
|
|
70
|
+
event.preventDefault();
|
|
71
|
+
setOnDragColumnStyle(event);
|
|
72
|
+
var columnIds = instance.flatHeaders.map(function (x) { return x.id; });
|
|
73
|
+
var srcIndex = instance.state.columnReorderStartIndex;
|
|
74
|
+
var dstIndex = columnIds.findIndex(function (x) { return x === header.id; });
|
|
75
|
+
if (srcIndex === dstIndex || srcIndex === -1 || dstIndex === -1) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
instance.setColumnOrder(reorderColumns(columnIds, srcIndex, dstIndex));
|
|
79
|
+
instance.dispatch({
|
|
80
|
+
type: REORDER_ACTIONS.columnDragEnd,
|
|
81
|
+
columnIndex: -1,
|
|
82
|
+
});
|
|
83
|
+
};
|
|
84
|
+
return [
|
|
85
|
+
props,
|
|
86
|
+
{
|
|
87
|
+
draggable: true,
|
|
88
|
+
onDragStart: onDragStart,
|
|
89
|
+
onDragOver: onDragOver,
|
|
90
|
+
onDragLeave: onDragLeave,
|
|
91
|
+
onDrop: onDrop,
|
|
92
|
+
},
|
|
93
|
+
];
|
|
94
|
+
}; };
|
|
95
|
+
var reducer = function (newState, action) {
|
|
96
|
+
switch (action.type) {
|
|
97
|
+
case actions.init:
|
|
98
|
+
return __assign(__assign({}, newState), { columnReorderStartIndex: -1 });
|
|
99
|
+
case REORDER_ACTIONS.columnDragStart:
|
|
100
|
+
return __assign(__assign({}, newState), { columnReorderStartIndex: action.columnIndex });
|
|
101
|
+
case REORDER_ACTIONS.columnDragEnd:
|
|
102
|
+
return __assign(__assign({}, newState), { columnReorderStartIndex: -1 });
|
|
103
|
+
default:
|
|
104
|
+
return newState;
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
var useInstance = function (instance) {
|
|
108
|
+
var flatHeaders = instance.flatHeaders, getHooks = instance.getHooks;
|
|
109
|
+
var getInstance = useGetLatest(instance);
|
|
110
|
+
flatHeaders.forEach(function (header) {
|
|
111
|
+
header.getDragAndDropProps = makePropGetter(getHooks().getDragAndDropProps, {
|
|
112
|
+
instance: getInstance(),
|
|
113
|
+
header: header,
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
};
|
|
@@ -29,6 +29,7 @@ export var useExpanderCell = function (subComponent, expanderCell, isRowDisabled
|
|
|
29
29
|
maxWidth: 48,
|
|
30
30
|
columnClassName: 'iui-slot',
|
|
31
31
|
cellClassName: 'iui-slot',
|
|
32
|
+
disableReordering: true,
|
|
32
33
|
Cell: function (props) {
|
|
33
34
|
var row = props.row;
|
|
34
35
|
if (!subComponent(row)) {
|
|
@@ -108,16 +108,20 @@ var defaultGetResizerProps = function (ownerDocument) { return function (props,
|
|
|
108
108
|
return [
|
|
109
109
|
props,
|
|
110
110
|
{
|
|
111
|
-
|
|
112
|
-
e.persist();
|
|
111
|
+
onClick: function (e) {
|
|
113
112
|
// Prevents from triggering sort
|
|
114
113
|
e.stopPropagation();
|
|
114
|
+
},
|
|
115
|
+
onMouseDown: function (e) {
|
|
116
|
+
e.persist();
|
|
117
|
+
// Prevents from triggering drag'n'drop
|
|
118
|
+
e.preventDefault();
|
|
115
119
|
onResizeStart(e, header);
|
|
116
120
|
},
|
|
117
121
|
onTouchStart: function (e) {
|
|
118
122
|
e.persist();
|
|
119
|
-
// Prevents from triggering
|
|
120
|
-
e.
|
|
123
|
+
// Prevents from triggering drag'n'drop
|
|
124
|
+
e.preventDefault();
|
|
121
125
|
onResizeStart(e, header);
|
|
122
126
|
},
|
|
123
127
|
style: {
|
|
@@ -39,6 +39,7 @@ export var useSelectionCell = function (isSelectable, isRowDisabled) { return fu
|
|
|
39
39
|
maxWidth: 48,
|
|
40
40
|
columnClassName: 'iui-slot',
|
|
41
41
|
cellClassName: 'iui-slot',
|
|
42
|
+
disableReordering: true,
|
|
42
43
|
Header: function (_a) {
|
|
43
44
|
var getToggleAllRowsSelectedProps = _a.getToggleAllRowsSelectedProps, rows = _a.rows, initialRows = _a.initialRows, state = _a.state;
|
|
44
45
|
var disabled = rows.every(function (row) { return isRowDisabled === null || isRowDisabled === void 0 ? void 0 : isRowDisabled(row.original); });
|
|
@@ -49,8 +50,7 @@ export var useSelectionCell = function (isSelectable, isRowDisabled) { return fu
|
|
|
49
50
|
},
|
|
50
51
|
Cell: function (_a) {
|
|
51
52
|
var row = _a.row;
|
|
52
|
-
return (React.createElement(
|
|
53
|
-
React.createElement(Checkbox, __assign({}, row.getToggleRowSelectedProps(), { disabled: isRowDisabled === null || isRowDisabled === void 0 ? void 0 : isRowDisabled(row.original) }))));
|
|
53
|
+
return (React.createElement(Checkbox, __assign({}, row.getToggleRowSelectedProps(), { disabled: isRowDisabled === null || isRowDisabled === void 0 ? void 0 : isRowDisabled(row.original), onClick: function (e) { return e.stopPropagation(); } })));
|
|
54
54
|
},
|
|
55
55
|
}
|
|
56
56
|
], columns, true); });
|
|
@@ -51,20 +51,23 @@ export var ToggleSwitch = React.forwardRef(function (props, ref) {
|
|
|
51
51
|
useTheme();
|
|
52
52
|
var inputElementRef = React.useRef(null);
|
|
53
53
|
var refs = useMergedRefs(inputElementRef, ref);
|
|
54
|
+
var WrapperComponent = label ? 'label' : 'div';
|
|
54
55
|
React.useEffect(function () {
|
|
55
56
|
if (inputElementRef.current && setFocus) {
|
|
56
57
|
inputElementRef.current.focus();
|
|
57
58
|
}
|
|
58
59
|
}, [setFocus]);
|
|
59
|
-
return (React.createElement(
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
60
|
+
return (React.createElement(WrapperComponent, { className: cx('iui-toggle-switch-wrapper', {
|
|
61
|
+
'iui-disabled': disabled,
|
|
62
|
+
'iui-label-on-right': label && labelPosition === 'right',
|
|
63
|
+
'iui-label-on-left': label && labelPosition === 'left',
|
|
64
|
+
}, className), style: style },
|
|
65
|
+
React.createElement("input", __assign({ className: 'iui-toggle-switch', type: 'checkbox', role: 'switch', disabled: disabled, ref: refs }, rest)),
|
|
66
|
+
icon &&
|
|
67
|
+
React.cloneElement(icon, {
|
|
68
|
+
className: cx('iui-toggle-switch-icon', icon.props.className),
|
|
69
|
+
'aria-hidden': true,
|
|
70
|
+
}),
|
|
71
|
+
label && React.createElement("span", { className: 'iui-toggle-switch-label' }, label)));
|
|
69
72
|
});
|
|
70
73
|
export default ToggleSwitch;
|
|
@@ -24,9 +24,6 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
24
24
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
25
25
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
26
26
|
*--------------------------------------------------------------------------------------------*/
|
|
27
|
-
import SvgAway from '@itwin/itwinui-icons-react/cjs/icons/Away';
|
|
28
|
-
import SvgCheckmark from '@itwin/itwinui-icons-react/cjs/icons/Checkmark';
|
|
29
|
-
import SvgCloseSmall from '@itwin/itwinui-icons-react/cjs/icons/CloseSmall';
|
|
30
27
|
import cx from 'classnames';
|
|
31
28
|
import React from 'react';
|
|
32
29
|
import { useTheme } from '../utils';
|
|
@@ -57,16 +54,10 @@ export var UserIcon = function (props) {
|
|
|
57
54
|
var _c = props.size, size = _c === void 0 ? 'small' : _c, status = props.status, abbreviation = props.abbreviation, image = props.image, _d = props.backgroundColor, backgroundColor = _d === void 0 ? 'white' : _d, title = props.title, translatedStatusTitles = props.translatedStatusTitles, className = props.className, style = props.style, rest = __rest(props, ["size", "status", "abbreviation", "image", "backgroundColor", "title", "translatedStatusTitles", "className", "style"]);
|
|
58
55
|
useTheme();
|
|
59
56
|
var statusTitles = __assign(__assign({}, defaultStatusTitles), translatedStatusTitles);
|
|
60
|
-
var iconMap = {
|
|
61
|
-
away: React.createElement(SvgAway, { className: 'iui-status-symbol', "aria-hidden": true }),
|
|
62
|
-
offline: React.createElement(SvgCloseSmall, { className: 'iui-status-symbol', "aria-hidden": true }),
|
|
63
|
-
online: React.createElement(SvgCheckmark, { className: 'iui-status-symbol', "aria-hidden": true }),
|
|
64
|
-
busy: React.createElement(React.Fragment, null),
|
|
65
|
-
};
|
|
66
57
|
return (React.createElement("span", __assign({ className: cx('iui-user-icon', (_a = {}, _a["iui-" + size] = size !== 'medium', _a), className), title: title, style: style }, rest), image !== null && image !== void 0 ? image : (React.createElement("abbr", { className: 'iui-initials', style: { backgroundColor: backgroundColor } }, abbreviation === null || abbreviation === void 0 ? void 0 : abbreviation.substring(0, 2))),
|
|
67
58
|
React.createElement("span", { className: 'iui-stroke' }),
|
|
68
59
|
status && (React.createElement("span", { title: statusTitles[status], className: cx('iui-status', (_b = {},
|
|
69
60
|
_b["iui-" + status] = !!status,
|
|
70
|
-
_b)), "aria-label": statusTitles[status] }
|
|
61
|
+
_b)), "aria-label": statusTitles[status] }))));
|
|
71
62
|
};
|
|
72
63
|
export default UserIcon;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Hook that uses `IntersectionObserver` to trigger `onIntersect` callback when element is in viewport.
|
|
3
|
-
* Callback is called only once.
|
|
4
|
-
*
|
|
3
|
+
* Callback is called only once by default (can be changed using the `once` parameter).
|
|
4
|
+
* @returns a callback ref that needs to be set on the element you want to observe.
|
|
5
|
+
* @private
|
|
5
6
|
* @example
|
|
6
7
|
* const onIntersection = React.useCallback(() => {
|
|
7
8
|
* console.log('Element is in viewport!');
|
|
@@ -9,4 +10,4 @@
|
|
|
9
10
|
* const ref = useIntersection(onIntersection);
|
|
10
11
|
* return (<div ref={ref}>One of many elements</div>);
|
|
11
12
|
*/
|
|
12
|
-
export declare const useIntersection: (onIntersect: () => void, options?: IntersectionObserverInit) => (node: HTMLElement | null) => void;
|
|
13
|
+
export declare const useIntersection: (onIntersect: () => void, options?: IntersectionObserverInit, once?: boolean) => (node: HTMLElement | null) => void;
|