@itwin/itwinui-react 3.15.2 → 3.15.4
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 +19 -0
- package/DEV-cjs/core/Breadcrumbs/Breadcrumbs.js +85 -65
- package/DEV-cjs/core/ButtonGroup/ButtonGroup.js +32 -27
- package/DEV-cjs/core/ComboBox/ComboBox.js +9 -6
- package/DEV-cjs/core/DatePicker/DatePicker.js +14 -4
- package/DEV-cjs/core/Popover/Popover.js +44 -16
- package/DEV-cjs/core/ProgressIndicators/ProgressLinear.js +2 -1
- package/DEV-cjs/core/Select/SelectTagContainer.js +27 -13
- package/DEV-cjs/core/Table/ColumnHeader.js +21 -28
- package/DEV-cjs/core/Table/Table.js +17 -10
- package/DEV-cjs/core/Table/TablePaginator.js +111 -88
- package/DEV-cjs/core/Table/cells/DefaultCell.js +3 -3
- package/DEV-cjs/core/Table/utils.js +3 -3
- package/DEV-cjs/core/TransferList/TransferList.js +18 -6
- package/DEV-cjs/styles.js +1 -1
- package/DEV-cjs/utils/components/MiddleTextTruncation.js +19 -14
- package/DEV-cjs/utils/components/OverflowContainer.js +63 -0
- package/DEV-cjs/utils/components/index.js +1 -0
- package/DEV-cjs/utils/hooks/useOverflow.js +12 -8
- package/DEV-esm/core/Breadcrumbs/Breadcrumbs.js +86 -67
- package/DEV-esm/core/ButtonGroup/ButtonGroup.js +33 -28
- package/DEV-esm/core/ComboBox/ComboBox.js +9 -6
- package/DEV-esm/core/DatePicker/DatePicker.js +12 -4
- package/DEV-esm/core/Popover/Popover.js +45 -17
- package/DEV-esm/core/ProgressIndicators/ProgressLinear.js +2 -1
- package/DEV-esm/core/Select/SelectTagContainer.js +24 -13
- package/DEV-esm/core/Table/ColumnHeader.js +28 -29
- package/DEV-esm/core/Table/Table.js +18 -11
- package/DEV-esm/core/Table/TablePaginator.js +112 -89
- package/DEV-esm/core/Table/cells/DefaultCell.js +4 -4
- package/DEV-esm/core/Table/utils.js +1 -1
- package/DEV-esm/core/TransferList/TransferList.js +14 -2
- package/DEV-esm/styles.js +1 -1
- package/DEV-esm/utils/components/MiddleTextTruncation.js +19 -14
- package/DEV-esm/utils/components/OverflowContainer.js +50 -0
- package/DEV-esm/utils/components/index.js +1 -0
- package/DEV-esm/utils/hooks/useOverflow.js +8 -8
- package/cjs/core/Breadcrumbs/Breadcrumbs.js +84 -64
- package/cjs/core/ButtonGroup/ButtonGroup.js +32 -27
- package/cjs/core/ComboBox/ComboBox.js +9 -6
- package/cjs/core/DatePicker/DatePicker.js +14 -4
- package/cjs/core/Popover/Popover.d.ts +10 -0
- package/cjs/core/Popover/Popover.js +44 -16
- package/cjs/core/ProgressIndicators/ProgressLinear.js +2 -1
- package/cjs/core/Select/SelectTagContainer.js +27 -13
- package/cjs/core/Table/ColumnHeader.d.ts +8 -12
- package/cjs/core/Table/ColumnHeader.js +21 -28
- package/cjs/core/Table/Table.js +13 -10
- package/cjs/core/Table/TablePaginator.js +111 -88
- package/cjs/core/Table/cells/DefaultCell.js +3 -3
- package/cjs/core/Table/utils.d.ts +2 -2
- package/cjs/core/Table/utils.js +3 -3
- package/cjs/core/TransferList/TransferList.d.ts +1 -1
- package/cjs/core/TransferList/TransferList.js +18 -6
- package/cjs/styles.js +1 -1
- package/cjs/utils/components/MiddleTextTruncation.js +19 -14
- package/cjs/utils/components/OverflowContainer.d.ts +37 -0
- package/cjs/utils/components/OverflowContainer.js +62 -0
- package/cjs/utils/components/index.d.ts +1 -0
- package/cjs/utils/components/index.js +1 -0
- package/cjs/utils/hooks/useOverflow.d.ts +2 -3
- package/cjs/utils/hooks/useOverflow.js +12 -8
- package/esm/core/Breadcrumbs/Breadcrumbs.js +85 -66
- package/esm/core/ButtonGroup/ButtonGroup.js +33 -28
- package/esm/core/ComboBox/ComboBox.js +9 -6
- package/esm/core/DatePicker/DatePicker.js +12 -4
- package/esm/core/Popover/Popover.d.ts +10 -0
- package/esm/core/Popover/Popover.js +45 -17
- package/esm/core/ProgressIndicators/ProgressLinear.js +2 -1
- package/esm/core/Select/SelectTagContainer.js +24 -13
- package/esm/core/Table/ColumnHeader.d.ts +8 -12
- package/esm/core/Table/ColumnHeader.js +28 -29
- package/esm/core/Table/Table.js +14 -11
- package/esm/core/Table/TablePaginator.js +112 -89
- package/esm/core/Table/cells/DefaultCell.js +4 -4
- package/esm/core/Table/utils.d.ts +2 -2
- package/esm/core/Table/utils.js +1 -1
- package/esm/core/TransferList/TransferList.d.ts +1 -1
- package/esm/core/TransferList/TransferList.js +14 -2
- package/esm/styles.js +1 -1
- package/esm/utils/components/MiddleTextTruncation.js +19 -14
- package/esm/utils/components/OverflowContainer.d.ts +37 -0
- package/esm/utils/components/OverflowContainer.js +49 -0
- package/esm/utils/components/index.d.ts +1 -0
- package/esm/utils/components/index.js +1 -0
- package/esm/utils/hooks/useOverflow.d.ts +2 -3
- package/esm/utils/hooks/useOverflow.js +8 -8
- package/package.json +1 -1
- package/styles.css +8 -8
|
@@ -289,7 +289,6 @@ const Table = (props) => {
|
|
|
289
289
|
gotoPage,
|
|
290
290
|
setPageSize,
|
|
291
291
|
flatHeaders,
|
|
292
|
-
visibleColumns,
|
|
293
292
|
setGlobalFilter,
|
|
294
293
|
} = instance;
|
|
295
294
|
let headerGroups = _headerGroups;
|
|
@@ -300,6 +299,10 @@ const Table = (props) => {
|
|
|
300
299
|
"Table's `columns` prop should not have a top-level `Header` or sub-columns. They are only allowed to be passed for backwards compatibility.\n See https://github.com/iTwin/iTwinUI/wiki/iTwinUI-react-v2-migration-guide#breaking-changes",
|
|
301
300
|
);
|
|
302
301
|
}
|
|
302
|
+
if (subComponent && data.some((item) => !!item.subRows?.length))
|
|
303
|
+
logWarning(
|
|
304
|
+
'Passing both `subComponent` and `data` with `subRows` is not supported. There are features designed for `subRows` that are not compatible with `subComponent` and vice versa.',
|
|
305
|
+
);
|
|
303
306
|
let ariaDataAttributes = Object.entries(rest).reduce(
|
|
304
307
|
(result, [key, value]) => {
|
|
305
308
|
if (key.startsWith('data-') || key.startsWith('aria-'))
|
|
@@ -537,9 +540,9 @@ const Table = (props) => {
|
|
|
537
540
|
updateStickyState();
|
|
538
541
|
}, []);
|
|
539
542
|
return _react.createElement(
|
|
540
|
-
_utils.
|
|
543
|
+
_utils.TableInstanceContext.Provider,
|
|
541
544
|
{
|
|
542
|
-
value: instance
|
|
545
|
+
value: instance,
|
|
543
546
|
},
|
|
544
547
|
_react.createElement(
|
|
545
548
|
_index.Box,
|
|
@@ -601,19 +604,23 @@ const Table = (props) => {
|
|
|
601
604
|
return _react.createElement(_ColumnHeader.ColumnHeader, {
|
|
602
605
|
...dragAndDropProps,
|
|
603
606
|
key: dragAndDropProps.key || column.id || index,
|
|
604
|
-
columnRefs: columnRefs,
|
|
605
607
|
column: column,
|
|
606
|
-
index: index,
|
|
607
608
|
areFiltersSet: areFiltersSet,
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
609
|
+
columnHasExpanders:
|
|
610
|
+
hasAnySubRows &&
|
|
611
|
+
index ===
|
|
612
|
+
headerGroup.headers.findIndex(
|
|
613
|
+
(c) => c.id !== _index3.SELECTION_CELL_ID,
|
|
614
|
+
),
|
|
615
|
+
isLast: index === headerGroup.headers.length - 1,
|
|
616
|
+
isTableEmpty: 0 === data.length,
|
|
612
617
|
isResizable: isResizable,
|
|
613
618
|
columnResizeMode: columnResizeMode,
|
|
614
619
|
enableColumnReordering: enableColumnReordering,
|
|
615
620
|
density: density,
|
|
616
|
-
|
|
621
|
+
ref: (el) => {
|
|
622
|
+
if (el) columnRefs.current[column.id] = el;
|
|
623
|
+
},
|
|
617
624
|
});
|
|
618
625
|
}),
|
|
619
626
|
),
|
|
@@ -18,6 +18,7 @@ const _DropdownButton = require('../Buttons/DropdownButton.js');
|
|
|
18
18
|
const _ProgressRadial = require('../ProgressIndicators/ProgressRadial.js');
|
|
19
19
|
const _MenuItem = require('../Menu/MenuItem.js');
|
|
20
20
|
const _index = require('../../utils/index.js');
|
|
21
|
+
const _styles = require('../../styles.js');
|
|
21
22
|
const defaultLocalization = {
|
|
22
23
|
pageSizeLabel: (size) => `${size} per page`,
|
|
23
24
|
rangeLabel: (startIndex, endIndex, totalRows, isLoading) =>
|
|
@@ -59,7 +60,7 @@ const TablePaginator = (props) => {
|
|
|
59
60
|
);
|
|
60
61
|
let pageListRef = _react.useRef(null);
|
|
61
62
|
let [focusedIndex, setFocusedIndex] = _react.useState(currentPage);
|
|
62
|
-
_react.
|
|
63
|
+
_react.useLayoutEffect(() => {
|
|
63
64
|
setFocusedIndex(currentPage);
|
|
64
65
|
}, [currentPage]);
|
|
65
66
|
let needFocus = _react.useRef(false);
|
|
@@ -68,7 +69,7 @@ const TablePaginator = (props) => {
|
|
|
68
69
|
if (isMounted.current && needFocus.current) {
|
|
69
70
|
let buttonToFocus = Array.from(
|
|
70
71
|
pageListRef.current?.querySelectorAll(
|
|
71
|
-
'
|
|
72
|
+
`.${_styles.styles['iui-table-paginator-page-button']}`,
|
|
72
73
|
) ?? [],
|
|
73
74
|
).find((el) => el.textContent?.trim() === (focusedIndex + 1).toString());
|
|
74
75
|
buttonToFocus?.focus();
|
|
@@ -77,35 +78,7 @@ const TablePaginator = (props) => {
|
|
|
77
78
|
isMounted.current = true;
|
|
78
79
|
}, [focusedIndex]);
|
|
79
80
|
let buttonSize = 'default' != size ? 'small' : void 0;
|
|
80
|
-
let pageButton = _react.useCallback(
|
|
81
|
-
(index, tabIndex = index === focusedIndex ? 0 : -1) =>
|
|
82
|
-
_react.createElement(
|
|
83
|
-
_Button.Button,
|
|
84
|
-
{
|
|
85
|
-
key: index,
|
|
86
|
-
className: 'iui-table-paginator-page-button',
|
|
87
|
-
styleType: 'borderless',
|
|
88
|
-
size: buttonSize,
|
|
89
|
-
'data-iui-active': index === currentPage,
|
|
90
|
-
onClick: () => onPageChange(index),
|
|
91
|
-
'aria-current': index === currentPage,
|
|
92
|
-
'aria-label': localization.goToPageLabel(index + 1),
|
|
93
|
-
tabIndex: tabIndex,
|
|
94
|
-
},
|
|
95
|
-
index + 1,
|
|
96
|
-
),
|
|
97
|
-
[focusedIndex, currentPage, localization, buttonSize, onPageChange],
|
|
98
|
-
);
|
|
99
81
|
let totalPagesCount = Math.ceil(totalRowsCount / pageSize);
|
|
100
|
-
let pageList = _react.useMemo(
|
|
101
|
-
() =>
|
|
102
|
-
new Array(totalPagesCount)
|
|
103
|
-
.fill(null)
|
|
104
|
-
.map((_, index) => pageButton(index)),
|
|
105
|
-
[pageButton, totalPagesCount],
|
|
106
|
-
);
|
|
107
|
-
let [overflowRef, visibleCount] = (0, _index.useOverflow)(pageList);
|
|
108
|
-
let [paginatorResizeRef, paginatorWidth] = (0, _index.useContainerWidth)();
|
|
109
82
|
let onKeyDown = (event) => {
|
|
110
83
|
if (event.altKey) return;
|
|
111
84
|
let focusPage = (delta) => {
|
|
@@ -136,30 +109,10 @@ const TablePaginator = (props) => {
|
|
|
136
109
|
break;
|
|
137
110
|
}
|
|
138
111
|
};
|
|
139
|
-
let
|
|
140
|
-
let startPage = focusedIndex - halfVisibleCount;
|
|
141
|
-
let endPage = focusedIndex + halfVisibleCount + 1;
|
|
142
|
-
if (startPage < 0) {
|
|
143
|
-
endPage = Math.min(totalPagesCount, endPage + Math.abs(startPage));
|
|
144
|
-
startPage = 0;
|
|
145
|
-
}
|
|
146
|
-
if (endPage > totalPagesCount) {
|
|
147
|
-
startPage = Math.max(0, startPage - (endPage - totalPagesCount));
|
|
148
|
-
endPage = totalPagesCount;
|
|
149
|
-
}
|
|
150
|
-
let hasNoRows = 0 === totalPagesCount;
|
|
112
|
+
let [paginatorResizeRef, paginatorWidth] = (0, _index.useContainerWidth)();
|
|
151
113
|
let showPagesList = totalPagesCount > 1 || isLoading;
|
|
152
114
|
let showPageSizeList = pageSizeList && !!onPageSizeChange && !!totalRowsCount;
|
|
153
|
-
let
|
|
154
|
-
_index.Box,
|
|
155
|
-
{
|
|
156
|
-
as: 'span',
|
|
157
|
-
className: (0, _classnames.default)('iui-table-paginator-ellipsis', {
|
|
158
|
-
'iui-table-paginator-ellipsis-small': 'small' === size,
|
|
159
|
-
}),
|
|
160
|
-
},
|
|
161
|
-
'…',
|
|
162
|
-
);
|
|
115
|
+
let hasNoRows = 0 === totalPagesCount;
|
|
163
116
|
let noRowsContent = _react.createElement(
|
|
164
117
|
_react.Fragment,
|
|
165
118
|
null,
|
|
@@ -200,10 +153,10 @@ const TablePaginator = (props) => {
|
|
|
200
153
|
),
|
|
201
154
|
showPagesList &&
|
|
202
155
|
_react.createElement(
|
|
203
|
-
_index.
|
|
156
|
+
_index.OverflowContainer,
|
|
204
157
|
{
|
|
205
158
|
className: 'iui-center',
|
|
206
|
-
|
|
159
|
+
itemsCount: totalPagesCount,
|
|
207
160
|
},
|
|
208
161
|
_react.createElement(
|
|
209
162
|
_IconButton.IconButton,
|
|
@@ -224,40 +177,17 @@ const TablePaginator = (props) => {
|
|
|
224
177
|
onKeyDown: onKeyDown,
|
|
225
178
|
ref: pageListRef,
|
|
226
179
|
},
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
ellipsis,
|
|
239
|
-
),
|
|
240
|
-
pageList.slice(startPage, endPage),
|
|
241
|
-
endPage !== totalPagesCount &&
|
|
242
|
-
!isLoading &&
|
|
243
|
-
_react.createElement(
|
|
244
|
-
_react.Fragment,
|
|
245
|
-
null,
|
|
246
|
-
ellipsis,
|
|
247
|
-
pageButton(totalPagesCount - 1, 0),
|
|
248
|
-
),
|
|
249
|
-
isLoading &&
|
|
250
|
-
_react.createElement(
|
|
251
|
-
_react.Fragment,
|
|
252
|
-
null,
|
|
253
|
-
ellipsis,
|
|
254
|
-
_react.createElement(_ProgressRadial.ProgressRadial, {
|
|
255
|
-
indeterminate: true,
|
|
256
|
-
size: 'small',
|
|
257
|
-
}),
|
|
258
|
-
),
|
|
259
|
-
);
|
|
260
|
-
})(),
|
|
180
|
+
hasNoRows
|
|
181
|
+
? noRowsContent
|
|
182
|
+
: _react.createElement(TablePaginatorPageButtons, {
|
|
183
|
+
size: size,
|
|
184
|
+
focusedIndex: focusedIndex,
|
|
185
|
+
totalPagesCount: totalPagesCount,
|
|
186
|
+
onPageChange: onPageChange,
|
|
187
|
+
currentPage: currentPage,
|
|
188
|
+
localization: localization,
|
|
189
|
+
isLoading: isLoading,
|
|
190
|
+
}),
|
|
261
191
|
),
|
|
262
192
|
_react.createElement(
|
|
263
193
|
_IconButton.IconButton,
|
|
@@ -322,3 +252,96 @@ const TablePaginator = (props) => {
|
|
|
322
252
|
),
|
|
323
253
|
);
|
|
324
254
|
};
|
|
255
|
+
const TablePaginatorPageButtons = (props) => {
|
|
256
|
+
let {
|
|
257
|
+
focusedIndex,
|
|
258
|
+
totalPagesCount,
|
|
259
|
+
onPageChange,
|
|
260
|
+
currentPage,
|
|
261
|
+
localization,
|
|
262
|
+
isLoading,
|
|
263
|
+
size,
|
|
264
|
+
} = props;
|
|
265
|
+
let { visibleCount } = _index.OverflowContainer.useContext();
|
|
266
|
+
let buttonSize = 'default' != size ? 'small' : void 0;
|
|
267
|
+
let pageButton = _react.useCallback(
|
|
268
|
+
(index, tabIndex = index === focusedIndex ? 0 : -1) =>
|
|
269
|
+
_react.createElement(
|
|
270
|
+
_Button.Button,
|
|
271
|
+
{
|
|
272
|
+
key: index,
|
|
273
|
+
className: 'iui-table-paginator-page-button',
|
|
274
|
+
styleType: 'borderless',
|
|
275
|
+
size: buttonSize,
|
|
276
|
+
'data-iui-active': index === currentPage,
|
|
277
|
+
onClick: () => onPageChange(index),
|
|
278
|
+
'aria-current': index === currentPage,
|
|
279
|
+
'aria-label': localization.goToPageLabel?.(index + 1),
|
|
280
|
+
tabIndex: tabIndex,
|
|
281
|
+
},
|
|
282
|
+
index + 1,
|
|
283
|
+
),
|
|
284
|
+
[focusedIndex, currentPage, localization, buttonSize, onPageChange],
|
|
285
|
+
);
|
|
286
|
+
let pageList = _react.useMemo(
|
|
287
|
+
() =>
|
|
288
|
+
new Array(totalPagesCount)
|
|
289
|
+
.fill(null)
|
|
290
|
+
.map((_, index) => pageButton(index)),
|
|
291
|
+
[pageButton, totalPagesCount],
|
|
292
|
+
);
|
|
293
|
+
let halfVisibleCount = Math.floor(visibleCount / 2);
|
|
294
|
+
let startPage = focusedIndex - halfVisibleCount;
|
|
295
|
+
let endPage = focusedIndex + halfVisibleCount + 1;
|
|
296
|
+
if (startPage < 0) {
|
|
297
|
+
endPage = Math.min(totalPagesCount, endPage + Math.abs(startPage));
|
|
298
|
+
startPage = 0;
|
|
299
|
+
}
|
|
300
|
+
if (endPage > totalPagesCount) {
|
|
301
|
+
startPage = Math.max(0, startPage - (endPage - totalPagesCount));
|
|
302
|
+
endPage = totalPagesCount;
|
|
303
|
+
}
|
|
304
|
+
let ellipsis = _react.createElement(
|
|
305
|
+
_index.Box,
|
|
306
|
+
{
|
|
307
|
+
as: 'span',
|
|
308
|
+
className: (0, _classnames.default)('iui-table-paginator-ellipsis', {
|
|
309
|
+
'iui-table-paginator-ellipsis-small': 'small' === size,
|
|
310
|
+
}),
|
|
311
|
+
},
|
|
312
|
+
'…',
|
|
313
|
+
);
|
|
314
|
+
if (1 === visibleCount) return pageButton(focusedIndex);
|
|
315
|
+
let showStartEllipsis = startPage > 1;
|
|
316
|
+
let showEndEllipsis = endPage < totalPagesCount - 1;
|
|
317
|
+
return _react.createElement(
|
|
318
|
+
_react.Fragment,
|
|
319
|
+
null,
|
|
320
|
+
0 !== startPage &&
|
|
321
|
+
_react.createElement(
|
|
322
|
+
_react.Fragment,
|
|
323
|
+
null,
|
|
324
|
+
pageButton(0, 0),
|
|
325
|
+
showStartEllipsis ? ellipsis : null,
|
|
326
|
+
),
|
|
327
|
+
pageList.slice(startPage, endPage),
|
|
328
|
+
endPage !== totalPagesCount &&
|
|
329
|
+
!isLoading &&
|
|
330
|
+
_react.createElement(
|
|
331
|
+
_react.Fragment,
|
|
332
|
+
null,
|
|
333
|
+
showEndEllipsis ? ellipsis : null,
|
|
334
|
+
pageButton(totalPagesCount - 1, 0),
|
|
335
|
+
),
|
|
336
|
+
isLoading &&
|
|
337
|
+
_react.createElement(
|
|
338
|
+
_react.Fragment,
|
|
339
|
+
null,
|
|
340
|
+
ellipsis,
|
|
341
|
+
_react.createElement(_ProgressRadial.ProgressRadial, {
|
|
342
|
+
indeterminate: true,
|
|
343
|
+
size: 'small',
|
|
344
|
+
}),
|
|
345
|
+
),
|
|
346
|
+
);
|
|
347
|
+
};
|
|
@@ -16,12 +16,12 @@ const _classnames = _interop_require_default._(require('classnames'));
|
|
|
16
16
|
const _index = require('../../../utils/index.js');
|
|
17
17
|
const _utils = require('../utils.js');
|
|
18
18
|
const DefaultCell = (props) => {
|
|
19
|
-
let
|
|
19
|
+
let instance = _react.useContext(_utils.TableInstanceContext);
|
|
20
20
|
let isCustomCell = _react.useMemo(
|
|
21
21
|
() =>
|
|
22
|
-
|
|
22
|
+
instance?.columns.find(({ id }) => props.cellProps.column.id === id)
|
|
23
23
|
?.Cell !== _reacttable.defaultColumn.Cell,
|
|
24
|
-
[
|
|
24
|
+
[instance, props.cellProps.column.id],
|
|
25
25
|
);
|
|
26
26
|
let {
|
|
27
27
|
cellElementProps: {
|
|
@@ -10,8 +10,8 @@ function _export(target, all) {
|
|
|
10
10
|
});
|
|
11
11
|
}
|
|
12
12
|
_export(exports, {
|
|
13
|
-
|
|
14
|
-
return
|
|
13
|
+
TableInstanceContext: function () {
|
|
14
|
+
return TableInstanceContext;
|
|
15
15
|
},
|
|
16
16
|
getCellStyle: function () {
|
|
17
17
|
return getCellStyle;
|
|
@@ -73,4 +73,4 @@ const getSubRowStyle = ({ density = 'default', depth = 1 }) => {
|
|
|
73
73
|
paddingInlineStart: cellPadding + depth * multiplier,
|
|
74
74
|
};
|
|
75
75
|
};
|
|
76
|
-
const
|
|
76
|
+
const TableInstanceContext = _react.createContext(void 0);
|
|
@@ -25,6 +25,7 @@ const _index = require('../../utils/index.js');
|
|
|
25
25
|
const _List = require('../List/List.js');
|
|
26
26
|
const _ListItem = require('../List/ListItem.js');
|
|
27
27
|
const _Label = require('../Label/Label.js');
|
|
28
|
+
const _ButtonGroup = require('../ButtonGroup/ButtonGroup.js');
|
|
28
29
|
const TransferListComponent = _index.polymorphic.div(
|
|
29
30
|
'iui-transfer-list-wrapper',
|
|
30
31
|
);
|
|
@@ -174,12 +175,23 @@ const TransferListListboxLabel = _react.forwardRef((props, ref) => {
|
|
|
174
175
|
);
|
|
175
176
|
});
|
|
176
177
|
TransferListListboxLabel.displayName = 'TransferList.ListboxLabel';
|
|
177
|
-
const TransferListToolbar =
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
178
|
+
const TransferListToolbar = _react.forwardRef((props, ref) => {
|
|
179
|
+
let { className, children, ...rest } = props;
|
|
180
|
+
return _react.createElement(
|
|
181
|
+
_ButtonGroup.ButtonGroup,
|
|
182
|
+
{
|
|
183
|
+
role: 'toolbar',
|
|
184
|
+
ref: ref,
|
|
185
|
+
...rest,
|
|
186
|
+
orientation: 'vertical',
|
|
187
|
+
className: (0, _classnames.default)(
|
|
188
|
+
'iui-transfer-list-toolbar',
|
|
189
|
+
className,
|
|
190
|
+
),
|
|
191
|
+
},
|
|
192
|
+
children,
|
|
193
|
+
);
|
|
194
|
+
});
|
|
183
195
|
TransferListToolbar.displayName = 'TransferList.Toolbar';
|
|
184
196
|
const TransferList = Object.assign(TransferListComponent, {
|
|
185
197
|
ListboxWrapper: TransferListListboxWrapper,
|
package/DEV-cjs/styles.js
CHANGED
|
@@ -10,22 +10,14 @@ Object.defineProperty(exports, 'MiddleTextTruncation', {
|
|
|
10
10
|
});
|
|
11
11
|
const _interop_require_wildcard = require('@swc/helpers/_/_interop_require_wildcard');
|
|
12
12
|
const _react = _interop_require_wildcard._(require('react'));
|
|
13
|
-
const
|
|
13
|
+
const _OverflowContainer = require('./OverflowContainer.js');
|
|
14
14
|
const ELLIPSIS_CHAR = '…';
|
|
15
15
|
const MiddleTextTruncation = (props) => {
|
|
16
|
-
let { text,
|
|
17
|
-
let [ref, visibleCount] = (0, _useOverflow.useOverflow)(text);
|
|
18
|
-
let truncatedText = _react.useMemo(() => {
|
|
19
|
-
if (visibleCount < text.length)
|
|
20
|
-
return `${text.substring(
|
|
21
|
-
0,
|
|
22
|
-
visibleCount - endCharsCount - ELLIPSIS_CHAR.length,
|
|
23
|
-
)}${ELLIPSIS_CHAR}${text.substring(text.length - endCharsCount)}`;
|
|
24
|
-
return text;
|
|
25
|
-
}, [endCharsCount, text, visibleCount]);
|
|
16
|
+
let { text, style, ...rest } = props;
|
|
26
17
|
return _react.createElement(
|
|
27
|
-
|
|
18
|
+
_OverflowContainer.OverflowContainer,
|
|
28
19
|
{
|
|
20
|
+
as: 'span',
|
|
29
21
|
style: {
|
|
30
22
|
display: 'flex',
|
|
31
23
|
minWidth: 0,
|
|
@@ -33,10 +25,23 @@ const MiddleTextTruncation = (props) => {
|
|
|
33
25
|
whiteSpace: 'nowrap',
|
|
34
26
|
...style,
|
|
35
27
|
},
|
|
36
|
-
|
|
28
|
+
itemsCount: text.length,
|
|
37
29
|
...rest,
|
|
38
30
|
},
|
|
39
|
-
|
|
31
|
+
_react.createElement(MiddleTextTruncationContent, props),
|
|
40
32
|
);
|
|
41
33
|
};
|
|
42
34
|
MiddleTextTruncation.displayName = 'MiddleTextTruncation';
|
|
35
|
+
const MiddleTextTruncationContent = (props) => {
|
|
36
|
+
let { text, endCharsCount = 6, textRenderer } = props;
|
|
37
|
+
let { visibleCount } = _OverflowContainer.OverflowContainer.useContext();
|
|
38
|
+
let truncatedText = _react.useMemo(() => {
|
|
39
|
+
if (visibleCount < text.length)
|
|
40
|
+
return `${text.substring(
|
|
41
|
+
0,
|
|
42
|
+
visibleCount - endCharsCount - ELLIPSIS_CHAR.length,
|
|
43
|
+
)}${ELLIPSIS_CHAR}${text.substring(text.length - endCharsCount)}`;
|
|
44
|
+
return text;
|
|
45
|
+
}, [endCharsCount, text, visibleCount]);
|
|
46
|
+
return textRenderer?.(truncatedText, text) ?? truncatedText;
|
|
47
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
Object.defineProperty(exports, '__esModule', {
|
|
3
|
+
value: true,
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, 'OverflowContainer', {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function () {
|
|
8
|
+
return OverflowContainer;
|
|
9
|
+
},
|
|
10
|
+
});
|
|
11
|
+
const _interop_require_default = require('@swc/helpers/_/_interop_require_default');
|
|
12
|
+
const _react = _interop_require_default._(require('react'));
|
|
13
|
+
const _useMergedRefs = require('../hooks/useMergedRefs.js');
|
|
14
|
+
const _Box = require('./Box.js');
|
|
15
|
+
const _useOverflow = require('../hooks/useOverflow.js');
|
|
16
|
+
const _useSafeContext = require('../hooks/useSafeContext.js');
|
|
17
|
+
const OverflowContainerComponent = _react.default.forwardRef((props, ref) => {
|
|
18
|
+
let { itemsCount, children, overflowOrientation, ...rest } = props;
|
|
19
|
+
let [containerRef, visibleCount] = (0, _useOverflow.useOverflow)(
|
|
20
|
+
itemsCount,
|
|
21
|
+
false,
|
|
22
|
+
overflowOrientation,
|
|
23
|
+
);
|
|
24
|
+
let overflowContainerContextValue = _react.default.useMemo(
|
|
25
|
+
() => ({
|
|
26
|
+
visibleCount,
|
|
27
|
+
itemsCount,
|
|
28
|
+
}),
|
|
29
|
+
[itemsCount, visibleCount],
|
|
30
|
+
);
|
|
31
|
+
return _react.default.createElement(
|
|
32
|
+
OverflowContainerContext.Provider,
|
|
33
|
+
{
|
|
34
|
+
value: overflowContainerContextValue,
|
|
35
|
+
},
|
|
36
|
+
_react.default.createElement(
|
|
37
|
+
_Box.Box,
|
|
38
|
+
{
|
|
39
|
+
ref: (0, _useMergedRefs.useMergedRefs)(ref, containerRef),
|
|
40
|
+
...rest,
|
|
41
|
+
},
|
|
42
|
+
children,
|
|
43
|
+
),
|
|
44
|
+
);
|
|
45
|
+
});
|
|
46
|
+
const OverflowContainerOverflowNode = (props) => {
|
|
47
|
+
let { children } = props;
|
|
48
|
+
let { visibleCount, itemsCount } = useOverflowContainerContext();
|
|
49
|
+
let isOverflowing = visibleCount < itemsCount;
|
|
50
|
+
return isOverflowing ? children : null;
|
|
51
|
+
};
|
|
52
|
+
const OverflowContainer = Object.assign(OverflowContainerComponent, {
|
|
53
|
+
OverflowNode: OverflowContainerOverflowNode,
|
|
54
|
+
useContext: useOverflowContainerContext,
|
|
55
|
+
});
|
|
56
|
+
const OverflowContainerContext = _react.default.createContext(void 0);
|
|
57
|
+
OverflowContainerContext.displayName = 'OverflowContainerContext';
|
|
58
|
+
function useOverflowContainerContext() {
|
|
59
|
+
let overflowContainerContext = (0, _useSafeContext.useSafeContext)(
|
|
60
|
+
OverflowContainerContext,
|
|
61
|
+
);
|
|
62
|
+
return overflowContainerContext;
|
|
63
|
+
}
|
|
@@ -17,3 +17,4 @@ _export_star._(require('./Portal.js'), exports);
|
|
|
17
17
|
_export_star._(require('./ShadowRoot.js'), exports);
|
|
18
18
|
_export_star._(require('./LineClamp.js'), exports);
|
|
19
19
|
_export_star._(require('./FieldsetBase.js'), exports);
|
|
20
|
+
_export_star._(require('./OverflowContainer.js'), exports);
|
|
@@ -14,10 +14,14 @@ const _useMergedRefs = require('./useMergedRefs.js');
|
|
|
14
14
|
const _useResizeObserver = require('./useResizeObserver.js');
|
|
15
15
|
const _useIsomorphicLayoutEffect = require('./useIsomorphicLayoutEffect.js');
|
|
16
16
|
const STARTING_MAX_ITEMS_COUNT = 20;
|
|
17
|
-
const useOverflow = (
|
|
17
|
+
const useOverflow = (
|
|
18
|
+
itemsCount,
|
|
19
|
+
disabled = false,
|
|
20
|
+
orientation = 'horizontal',
|
|
21
|
+
) => {
|
|
18
22
|
let containerRef = _react.useRef(null);
|
|
19
23
|
let [visibleCount, setVisibleCount] = _react.useState(() =>
|
|
20
|
-
disabled ?
|
|
24
|
+
disabled ? itemsCount : Math.min(itemsCount, STARTING_MAX_ITEMS_COUNT),
|
|
21
25
|
);
|
|
22
26
|
let needsFullRerender = _react.useRef(true);
|
|
23
27
|
let [containerSize, setContainerSize] = _react.useState(0);
|
|
@@ -32,12 +36,12 @@ const useOverflow = (items, disabled = false, orientation = 'horizontal') => {
|
|
|
32
36
|
);
|
|
33
37
|
let resizeObserverRef = _react.useRef(observer);
|
|
34
38
|
(0, _useIsomorphicLayoutEffect.useLayoutEffect)(() => {
|
|
35
|
-
if (disabled) setVisibleCount(
|
|
39
|
+
if (disabled) setVisibleCount(itemsCount);
|
|
36
40
|
else {
|
|
37
|
-
setVisibleCount(Math.min(
|
|
41
|
+
setVisibleCount(Math.min(itemsCount, STARTING_MAX_ITEMS_COUNT));
|
|
38
42
|
needsFullRerender.current = true;
|
|
39
43
|
}
|
|
40
|
-
}, [containerSize, disabled,
|
|
44
|
+
}, [containerSize, disabled, itemsCount]);
|
|
41
45
|
let mergedRefs = (0, _useMergedRefs.useMergedRefs)(containerRef, resizeRef);
|
|
42
46
|
(0, _useIsomorphicLayoutEffect.useLayoutEffect)(() => {
|
|
43
47
|
if (!containerRef.current || disabled) {
|
|
@@ -57,14 +61,14 @@ const useOverflow = (items, disabled = false, orientation = 'horizontal') => {
|
|
|
57
61
|
0,
|
|
58
62
|
);
|
|
59
63
|
let currentVisibleCount =
|
|
60
|
-
visibleCount || Math.min(
|
|
64
|
+
visibleCount || Math.min(itemsCount, STARTING_MAX_ITEMS_COUNT);
|
|
61
65
|
let avgItemSize = childrenSize / currentVisibleCount;
|
|
62
66
|
let visibleItems = Math.floor(availableSize / avgItemSize);
|
|
63
67
|
if (!isNaN(visibleItems))
|
|
64
|
-
setVisibleCount(Math.min(
|
|
68
|
+
setVisibleCount(Math.min(itemsCount, 2 * visibleItems));
|
|
65
69
|
}
|
|
66
70
|
needsFullRerender.current = false;
|
|
67
|
-
}, [containerSize, visibleCount, disabled,
|
|
71
|
+
}, [containerSize, visibleCount, disabled, itemsCount, orientation]);
|
|
68
72
|
(0, _useIsomorphicLayoutEffect.useLayoutEffect)(() => {
|
|
69
73
|
previousContainerSize.current = containerSize;
|
|
70
74
|
}, [containerSize]);
|