@itwin/itwinui-react 3.15.5 → 3.16.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 +23 -0
- package/DEV-cjs/core/Breadcrumbs/Breadcrumbs.js +2 -2
- package/DEV-cjs/core/Checkbox/Checkbox.js +4 -6
- package/DEV-cjs/core/ComboBox/ComboBox.js +10 -6
- package/DEV-cjs/core/DatePicker/DatePicker.js +9 -1
- package/DEV-cjs/core/Dialog/Dialog.js +1 -1
- package/DEV-cjs/core/Panels/Panels.js +319 -0
- package/DEV-cjs/core/Panels/helpers.js +62 -0
- package/DEV-cjs/core/Radio/Radio.js +4 -6
- package/DEV-cjs/core/RadioTiles/RadioTileGroup.js +9 -2
- package/DEV-cjs/core/Select/SelectTag.js +9 -11
- package/DEV-cjs/core/Select/SelectTagContainer.js +2 -2
- package/DEV-cjs/core/Stepper/Stepper.js +1 -0
- package/DEV-cjs/core/Stepper/StepperStep.js +2 -1
- package/DEV-cjs/core/Table/Table.js +3 -4
- package/DEV-cjs/core/Table/TablePaginator.js +15 -3
- package/DEV-cjs/core/Table/actionHandlers/selectHandler.js +10 -7
- package/DEV-cjs/core/Table/columns/selectionColumn.js +6 -1
- package/DEV-cjs/core/Tree/Tree.js +1 -0
- package/DEV-cjs/index.js +4 -0
- package/DEV-cjs/styles.js +1 -1
- package/DEV-cjs/utils/components/MiddleTextTruncation.js +22 -4
- package/DEV-cjs/utils/components/OverflowContainer.js +170 -27
- package/DEV-cjs/utils/hooks/index.js +1 -1
- package/DEV-cjs/utils/hooks/useInstance.js +38 -0
- package/DEV-esm/core/Breadcrumbs/Breadcrumbs.js +2 -2
- package/DEV-esm/core/Checkbox/Checkbox.js +5 -10
- package/DEV-esm/core/ComboBox/ComboBox.js +10 -6
- package/DEV-esm/core/DatePicker/DatePicker.js +11 -1
- package/DEV-esm/core/Dialog/Dialog.js +1 -1
- package/DEV-esm/core/Panels/Panels.js +301 -0
- package/DEV-esm/core/Panels/helpers.js +42 -0
- package/DEV-esm/core/Radio/Radio.js +4 -9
- package/DEV-esm/core/RadioTiles/RadioTileGroup.js +8 -2
- package/DEV-esm/core/Select/SelectTag.js +9 -11
- package/DEV-esm/core/Select/SelectTagContainer.js +2 -2
- package/DEV-esm/core/Stepper/Stepper.js +1 -0
- package/DEV-esm/core/Stepper/StepperStep.js +2 -1
- package/DEV-esm/core/Table/Table.js +1 -5
- package/DEV-esm/core/Table/TablePaginator.js +16 -3
- package/DEV-esm/core/Table/actionHandlers/selectHandler.js +10 -7
- package/DEV-esm/core/Table/columns/selectionColumn.js +6 -1
- package/DEV-esm/core/Tree/Tree.js +1 -0
- package/DEV-esm/index.js +1 -0
- package/DEV-esm/styles.js +1 -1
- package/DEV-esm/utils/components/MiddleTextTruncation.js +22 -4
- package/DEV-esm/utils/components/OverflowContainer.js +143 -4
- package/DEV-esm/utils/hooks/index.js +1 -1
- package/DEV-esm/utils/hooks/useInstance.js +18 -0
- package/cjs/core/Breadcrumbs/Breadcrumbs.js +2 -2
- package/cjs/core/Checkbox/Checkbox.js +4 -6
- package/cjs/core/ComboBox/ComboBox.d.ts +13 -0
- package/cjs/core/ComboBox/ComboBox.js +10 -6
- package/cjs/core/DatePicker/DatePicker.d.ts +2 -2
- package/cjs/core/DatePicker/DatePicker.js +2 -1
- package/cjs/core/Dialog/Dialog.js +1 -1
- package/cjs/core/Dialog/DialogContext.d.ts +6 -2
- package/cjs/core/Panels/Panels.d.ts +174 -0
- package/cjs/core/Panels/Panels.js +312 -0
- package/cjs/core/Panels/helpers.d.ts +23 -0
- package/cjs/core/Panels/helpers.js +61 -0
- package/cjs/core/Radio/Radio.js +4 -6
- package/cjs/core/RadioTiles/RadioTileGroup.d.ts +3 -1
- package/cjs/core/RadioTiles/RadioTileGroup.js +9 -2
- package/cjs/core/Select/SelectTag.d.ts +3 -1
- package/cjs/core/Select/SelectTag.js +9 -11
- package/cjs/core/Select/SelectTagContainer.js +2 -2
- package/cjs/core/Stepper/Stepper.d.ts +4 -0
- package/cjs/core/Stepper/Stepper.js +1 -0
- package/cjs/core/Stepper/StepperStep.d.ts +4 -0
- package/cjs/core/Stepper/StepperStep.js +2 -1
- package/cjs/core/Table/Table.d.ts +1 -0
- package/cjs/core/Table/Table.js +3 -4
- package/cjs/core/Table/TablePaginator.js +15 -3
- package/cjs/core/Table/actionHandlers/selectHandler.js +10 -7
- package/cjs/core/Table/columns/selectionColumn.js +6 -1
- package/cjs/core/Tree/Tree.js +1 -0
- package/cjs/index.d.ts +1 -0
- package/cjs/index.js +4 -0
- package/cjs/styles.js +1 -1
- package/cjs/utils/components/MiddleTextTruncation.d.ts +5 -7
- package/cjs/utils/components/MiddleTextTruncation.js +22 -4
- package/cjs/utils/components/OverflowContainer.d.ts +1 -0
- package/cjs/utils/components/OverflowContainer.js +170 -27
- package/cjs/utils/hooks/index.d.ts +1 -1
- package/cjs/utils/hooks/index.js +1 -1
- package/cjs/utils/hooks/useInstance.d.ts +22 -0
- package/cjs/utils/hooks/useInstance.js +38 -0
- package/esm/core/Breadcrumbs/Breadcrumbs.js +2 -2
- package/esm/core/Checkbox/Checkbox.js +5 -10
- package/esm/core/ComboBox/ComboBox.d.ts +13 -0
- package/esm/core/ComboBox/ComboBox.js +10 -6
- package/esm/core/DatePicker/DatePicker.d.ts +2 -2
- package/esm/core/DatePicker/DatePicker.js +4 -1
- package/esm/core/Dialog/Dialog.js +1 -1
- package/esm/core/Dialog/DialogContext.d.ts +6 -2
- package/esm/core/Panels/Panels.d.ts +174 -0
- package/esm/core/Panels/Panels.js +294 -0
- package/esm/core/Panels/helpers.d.ts +23 -0
- package/esm/core/Panels/helpers.js +41 -0
- package/esm/core/Radio/Radio.js +4 -9
- package/esm/core/RadioTiles/RadioTileGroup.d.ts +3 -1
- package/esm/core/RadioTiles/RadioTileGroup.js +8 -2
- package/esm/core/Select/SelectTag.d.ts +3 -1
- package/esm/core/Select/SelectTag.js +9 -11
- package/esm/core/Select/SelectTagContainer.js +2 -2
- package/esm/core/Stepper/Stepper.d.ts +4 -0
- package/esm/core/Stepper/Stepper.js +1 -0
- package/esm/core/Stepper/StepperStep.d.ts +4 -0
- package/esm/core/Stepper/StepperStep.js +2 -1
- package/esm/core/Table/Table.d.ts +1 -0
- package/esm/core/Table/Table.js +1 -5
- package/esm/core/Table/TablePaginator.js +16 -3
- package/esm/core/Table/actionHandlers/selectHandler.js +10 -7
- package/esm/core/Table/columns/selectionColumn.js +6 -1
- package/esm/core/Tree/Tree.js +1 -0
- package/esm/index.d.ts +1 -0
- package/esm/index.js +1 -0
- package/esm/styles.js +1 -1
- package/esm/utils/components/MiddleTextTruncation.d.ts +5 -7
- package/esm/utils/components/MiddleTextTruncation.js +22 -4
- package/esm/utils/components/OverflowContainer.d.ts +1 -0
- package/esm/utils/components/OverflowContainer.js +143 -4
- package/esm/utils/hooks/index.d.ts +1 -1
- package/esm/utils/hooks/index.js +1 -1
- package/esm/utils/hooks/useInstance.d.ts +22 -0
- package/esm/utils/hooks/useInstance.js +18 -0
- package/package.json +2 -2
- package/styles.css +8 -8
- package/DEV-cjs/utils/hooks/useOverflow.js +0 -76
- package/DEV-esm/utils/hooks/useOverflow.js +0 -63
- package/cjs/utils/hooks/useOverflow.d.ts +0 -23
- package/cjs/utils/hooks/useOverflow.js +0 -76
- package/esm/utils/hooks/useOverflow.d.ts +0 -23
- package/esm/utils/hooks/useOverflow.js +0 -63
|
@@ -13,6 +13,9 @@ _export(exports, {
|
|
|
13
13
|
Table: function () {
|
|
14
14
|
return Table;
|
|
15
15
|
},
|
|
16
|
+
iuiId: function () {
|
|
17
|
+
return iuiId;
|
|
18
|
+
},
|
|
16
19
|
tableResizeStartAction: function () {
|
|
17
20
|
return tableResizeStartAction;
|
|
18
21
|
},
|
|
@@ -658,11 +661,7 @@ const Table = (props) => {
|
|
|
658
661
|
},
|
|
659
662
|
bodyProps?.className,
|
|
660
663
|
),
|
|
661
|
-
style: {
|
|
662
|
-
outline: 0,
|
|
663
|
-
},
|
|
664
664
|
}),
|
|
665
|
-
tabIndex: -1,
|
|
666
665
|
'aria-multiselectable':
|
|
667
666
|
(isSelectable && 'multi' === selectionMode) || void 0,
|
|
668
667
|
},
|
|
@@ -60,7 +60,7 @@ const TablePaginator = (props) => {
|
|
|
60
60
|
);
|
|
61
61
|
let pageListRef = _react.useRef(null);
|
|
62
62
|
let [focusedIndex, setFocusedIndex] = _react.useState(currentPage);
|
|
63
|
-
|
|
63
|
+
(0, _index.useLayoutEffect)(() => {
|
|
64
64
|
setFocusedIndex(currentPage);
|
|
65
65
|
}, [currentPage]);
|
|
66
66
|
let needFocus = _react.useRef(false);
|
|
@@ -182,6 +182,7 @@ const TablePaginator = (props) => {
|
|
|
182
182
|
: _react.createElement(TablePaginatorPageButtons, {
|
|
183
183
|
size: size,
|
|
184
184
|
focusedIndex: focusedIndex,
|
|
185
|
+
setFocusedIndex: setFocusedIndex,
|
|
185
186
|
totalPagesCount: totalPagesCount,
|
|
186
187
|
onPageChange: onPageChange,
|
|
187
188
|
currentPage: currentPage,
|
|
@@ -255,6 +256,7 @@ const TablePaginator = (props) => {
|
|
|
255
256
|
const TablePaginatorPageButtons = (props) => {
|
|
256
257
|
let {
|
|
257
258
|
focusedIndex,
|
|
259
|
+
setFocusedIndex,
|
|
258
260
|
totalPagesCount,
|
|
259
261
|
onPageChange,
|
|
260
262
|
currentPage,
|
|
@@ -274,14 +276,24 @@ const TablePaginatorPageButtons = (props) => {
|
|
|
274
276
|
styleType: 'borderless',
|
|
275
277
|
size: buttonSize,
|
|
276
278
|
'data-iui-active': index === currentPage,
|
|
277
|
-
onClick: () =>
|
|
279
|
+
onClick: () => {
|
|
280
|
+
setFocusedIndex(index);
|
|
281
|
+
onPageChange(index);
|
|
282
|
+
},
|
|
278
283
|
'aria-current': index === currentPage,
|
|
279
284
|
'aria-label': localization.goToPageLabel?.(index + 1),
|
|
280
285
|
tabIndex: tabIndex,
|
|
281
286
|
},
|
|
282
287
|
index + 1,
|
|
283
288
|
),
|
|
284
|
-
[
|
|
289
|
+
[
|
|
290
|
+
focusedIndex,
|
|
291
|
+
buttonSize,
|
|
292
|
+
currentPage,
|
|
293
|
+
localization,
|
|
294
|
+
setFocusedIndex,
|
|
295
|
+
onPageChange,
|
|
296
|
+
],
|
|
285
297
|
);
|
|
286
298
|
let pageList = _react.useMemo(
|
|
287
299
|
() =>
|
|
@@ -20,6 +20,7 @@ _export(exports, {
|
|
|
20
20
|
return onToggleHandler;
|
|
21
21
|
},
|
|
22
22
|
});
|
|
23
|
+
const _Table = require('../Table.js');
|
|
23
24
|
const onSelectHandler = (newState, instance, onSelect, isRowDisabled) => {
|
|
24
25
|
if (!instance?.rows.length) {
|
|
25
26
|
onSelect?.([], newState);
|
|
@@ -29,14 +30,16 @@ const onSelectHandler = (newState, instance, onSelect, isRowDisabled) => {
|
|
|
29
30
|
let handleRow = (row) => {
|
|
30
31
|
if (isRowDisabled?.(row.original)) return false;
|
|
31
32
|
let isAllSubSelected = true;
|
|
32
|
-
row.initialSubRows.
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
if (row.initialSubRows[0]?.original[_Table.iuiId] === void 0)
|
|
34
|
+
row.initialSubRows.forEach((subRow) => {
|
|
35
|
+
let result = handleRow(subRow);
|
|
36
|
+
if (!result) isAllSubSelected = false;
|
|
37
|
+
});
|
|
36
38
|
if (
|
|
37
|
-
|
|
38
|
-
(!
|
|
39
|
-
|
|
39
|
+
newState.selectedRowIds[row.id] &&
|
|
40
|
+
(!instance.selectSubRows ||
|
|
41
|
+
!row.initialSubRows.length ||
|
|
42
|
+
isAllSubSelected)
|
|
40
43
|
)
|
|
41
44
|
newSelectedRowIds[row.id] = true;
|
|
42
45
|
return !!newSelectedRowIds[row.id];
|
|
@@ -21,6 +21,7 @@ const _interop_require_wildcard = require('@swc/helpers/_/_interop_require_wildc
|
|
|
21
21
|
const _react = _interop_require_wildcard._(require('react'));
|
|
22
22
|
const _Checkbox = require('../../Checkbox/Checkbox.js');
|
|
23
23
|
const _index = require('../cells/index.js');
|
|
24
|
+
const _Table = require('../Table.js');
|
|
24
25
|
const SELECTION_CELL_ID = 'iui-table-checkbox-selector';
|
|
25
26
|
const SelectionColumn = (props = {}) => {
|
|
26
27
|
let { isDisabled, density } = props;
|
|
@@ -70,7 +71,11 @@ const SelectionColumn = (props = {}) => {
|
|
|
70
71
|
disabled: isDisabled?.(row.original),
|
|
71
72
|
onClick: (e) => e.stopPropagation(),
|
|
72
73
|
onChange: () => {
|
|
73
|
-
if (
|
|
74
|
+
if (
|
|
75
|
+
row.subRows.length > 0 &&
|
|
76
|
+
selectSubRows &&
|
|
77
|
+
void 0 === row.initialSubRows[0].original[_Table.iuiId]
|
|
78
|
+
)
|
|
74
79
|
row.toggleRowSelected(
|
|
75
80
|
!row.subRows.every(
|
|
76
81
|
(subRow) => subRow.isSelected || isDisabled?.(subRow.original),
|
package/DEV-cjs/index.js
CHANGED
|
@@ -371,6 +371,9 @@ _export(exports, {
|
|
|
371
371
|
tableFilters: function () {
|
|
372
372
|
return _index.tableFilters;
|
|
373
373
|
},
|
|
374
|
+
unstable_Panels: function () {
|
|
375
|
+
return _Panels.Panels;
|
|
376
|
+
},
|
|
374
377
|
useToaster: function () {
|
|
375
378
|
return _Toaster.useToaster;
|
|
376
379
|
},
|
|
@@ -437,6 +440,7 @@ const _ModalContent = require('./core/Modal/ModalContent.js');
|
|
|
437
440
|
const _ModalButtonBar = require('./core/Modal/ModalButtonBar.js');
|
|
438
441
|
const _NotificationMarker = require('./core/NotificationMarker/NotificationMarker.js');
|
|
439
442
|
const _Overlay = require('./core/Overlay/Overlay.js');
|
|
443
|
+
const _Panels = require('./core/Panels/Panels.js');
|
|
440
444
|
const _ProgressLinear = require('./core/ProgressIndicators/ProgressLinear.js');
|
|
441
445
|
const _ProgressRadial = require('./core/ProgressIndicators/ProgressRadial.js');
|
|
442
446
|
const _Radio = require('./core/Radio/Radio.js');
|
package/DEV-cjs/styles.js
CHANGED
|
@@ -11,9 +11,11 @@ Object.defineProperty(exports, 'MiddleTextTruncation', {
|
|
|
11
11
|
const _interop_require_wildcard = require('@swc/helpers/_/_interop_require_wildcard');
|
|
12
12
|
const _react = _interop_require_wildcard._(require('react'));
|
|
13
13
|
const _OverflowContainer = require('./OverflowContainer.js');
|
|
14
|
+
const _VisuallyHidden = require('../../core/VisuallyHidden/VisuallyHidden.js');
|
|
15
|
+
const _ShadowRoot = require('./ShadowRoot.js');
|
|
14
16
|
const ELLIPSIS_CHAR = '…';
|
|
15
|
-
const MiddleTextTruncation = (props) => {
|
|
16
|
-
let { text, style, ...rest } = props;
|
|
17
|
+
const MiddleTextTruncation = _react.forwardRef((props, forwardedRef) => {
|
|
18
|
+
let { text, endCharsCount, textRenderer, style, ...rest } = props;
|
|
17
19
|
return _react.createElement(
|
|
18
20
|
_OverflowContainer.OverflowContainer,
|
|
19
21
|
{
|
|
@@ -27,10 +29,26 @@ const MiddleTextTruncation = (props) => {
|
|
|
27
29
|
},
|
|
28
30
|
itemsCount: text.length,
|
|
29
31
|
...rest,
|
|
32
|
+
ref: forwardedRef,
|
|
30
33
|
},
|
|
31
|
-
_react.createElement(
|
|
34
|
+
_react.createElement(
|
|
35
|
+
_ShadowRoot.ShadowRoot,
|
|
36
|
+
null,
|
|
37
|
+
_react.createElement(_VisuallyHidden.VisuallyHidden, null, text),
|
|
38
|
+
_react.createElement('slot', {
|
|
39
|
+
'aria-hidden': true,
|
|
40
|
+
style: {
|
|
41
|
+
pointerEvents: 'none',
|
|
42
|
+
},
|
|
43
|
+
}),
|
|
44
|
+
),
|
|
45
|
+
_react.createElement(MiddleTextTruncationContent, {
|
|
46
|
+
text: text,
|
|
47
|
+
endCharsCount: endCharsCount,
|
|
48
|
+
textRenderer: textRenderer,
|
|
49
|
+
}),
|
|
32
50
|
);
|
|
33
|
-
};
|
|
51
|
+
});
|
|
34
52
|
MiddleTextTruncation.displayName = 'MiddleTextTruncation';
|
|
35
53
|
const MiddleTextTruncationContent = (props) => {
|
|
36
54
|
let { text, endCharsCount = 6, textRenderer } = props;
|
|
@@ -12,49 +12,192 @@ const _interop_require_default = require('@swc/helpers/_/_interop_require_defaul
|
|
|
12
12
|
const _react = _interop_require_default._(require('react'));
|
|
13
13
|
const _useMergedRefs = require('../hooks/useMergedRefs.js');
|
|
14
14
|
const _Box = require('./Box.js');
|
|
15
|
-
const
|
|
15
|
+
const _useIsomorphicLayoutEffect = require('../hooks/useIsomorphicLayoutEffect.js');
|
|
16
16
|
const _useSafeContext = require('../hooks/useSafeContext.js');
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
);
|
|
24
|
-
let overflowContainerContextValue = _react.default.useMemo(
|
|
25
|
-
() => ({
|
|
26
|
-
visibleCount,
|
|
17
|
+
const _dev = require('../functions/dev.js');
|
|
18
|
+
const _useResizeObserver = require('../hooks/useResizeObserver.js');
|
|
19
|
+
const OverflowContainerMain = _react.default.forwardRef(
|
|
20
|
+
(props, forwardedRef) => {
|
|
21
|
+
let { itemsCount, children, overflowOrientation, ...rest } = props;
|
|
22
|
+
let [containerRef, visibleCount] = useOverflow(
|
|
27
23
|
itemsCount,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
24
|
+
overflowOrientation,
|
|
25
|
+
);
|
|
26
|
+
let overflowContainerContextValue = _react.default.useMemo(
|
|
27
|
+
() => ({
|
|
28
|
+
visibleCount,
|
|
29
|
+
itemsCount,
|
|
30
|
+
}),
|
|
31
|
+
[itemsCount, visibleCount],
|
|
32
|
+
);
|
|
33
|
+
return _react.default.createElement(
|
|
34
|
+
OverflowContainerContext.Provider,
|
|
38
35
|
{
|
|
39
|
-
|
|
40
|
-
...rest,
|
|
36
|
+
value: overflowContainerContextValue,
|
|
41
37
|
},
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
38
|
+
_react.default.createElement(
|
|
39
|
+
_Box.Box,
|
|
40
|
+
{
|
|
41
|
+
ref: (0, _useMergedRefs.useMergedRefs)(forwardedRef, containerRef),
|
|
42
|
+
...rest,
|
|
43
|
+
},
|
|
44
|
+
children,
|
|
45
|
+
),
|
|
46
|
+
);
|
|
47
|
+
},
|
|
48
|
+
);
|
|
46
49
|
const OverflowContainerOverflowNode = (props) => {
|
|
47
50
|
let { children } = props;
|
|
48
51
|
let { visibleCount, itemsCount } = useOverflowContainerContext();
|
|
49
52
|
let isOverflowing = visibleCount < itemsCount;
|
|
50
53
|
return isOverflowing ? children : null;
|
|
51
54
|
};
|
|
55
|
+
const OverflowContainerComponent = _react.default.forwardRef(
|
|
56
|
+
(props, forwardedRef) => {
|
|
57
|
+
let { itemsCount, overflowOrientation = 'horizontal', ...rest } = props;
|
|
58
|
+
let [size, setSize] = _react.default.useState(null);
|
|
59
|
+
let [resizeRef] = (0, _useResizeObserver.useResizeObserver)(setSize);
|
|
60
|
+
let ref = (0, _useMergedRefs.useMergedRefs)(resizeRef, forwardedRef);
|
|
61
|
+
let key = `${itemsCount}${
|
|
62
|
+
'vertical' === overflowOrientation ? size?.height : size?.width
|
|
63
|
+
}`;
|
|
64
|
+
return _react.default.createElement(OverflowContainerMain, {
|
|
65
|
+
...rest,
|
|
66
|
+
key: key,
|
|
67
|
+
ref: ref,
|
|
68
|
+
itemsCount: itemsCount,
|
|
69
|
+
overflowOrientation: overflowOrientation,
|
|
70
|
+
});
|
|
71
|
+
},
|
|
72
|
+
);
|
|
52
73
|
const OverflowContainer = Object.assign(OverflowContainerComponent, {
|
|
53
74
|
OverflowNode: OverflowContainerOverflowNode,
|
|
54
75
|
useContext: useOverflowContainerContext,
|
|
55
76
|
});
|
|
56
77
|
const OverflowContainerContext = _react.default.createContext(void 0);
|
|
57
78
|
OverflowContainerContext.displayName = 'OverflowContainerContext';
|
|
79
|
+
const useOverflow = (itemsCount, orientation = 'horizontal') => {
|
|
80
|
+
let [guessState, dispatch] = _react.default.useReducer(
|
|
81
|
+
overflowGuessReducer,
|
|
82
|
+
{
|
|
83
|
+
itemsCount,
|
|
84
|
+
},
|
|
85
|
+
overflowGuessReducerInitialState,
|
|
86
|
+
);
|
|
87
|
+
let containerRef = _react.default.useRef(null);
|
|
88
|
+
let isGuessing = _react.default.useRef(false);
|
|
89
|
+
(0, _useIsomorphicLayoutEffect.useLayoutEffect)(() => {
|
|
90
|
+
let { minGuess, maxGuess, isStabilized, visibleCount } = guessState;
|
|
91
|
+
if (isStabilized) return;
|
|
92
|
+
guessVisibleCount();
|
|
93
|
+
function guessVisibleCount() {
|
|
94
|
+
if (isStabilized || isGuessing.current || _dev.isUnitTest) return;
|
|
95
|
+
try {
|
|
96
|
+
isGuessing.current = true;
|
|
97
|
+
if (null == containerRef.current) return;
|
|
98
|
+
let dimension = 'horizontal' === orientation ? 'Width' : 'Height';
|
|
99
|
+
let availableSize = containerRef.current[`offset${dimension}`];
|
|
100
|
+
let requiredSize = containerRef.current[`scroll${dimension}`];
|
|
101
|
+
let isOverflowing = availableSize < requiredSize;
|
|
102
|
+
if (
|
|
103
|
+
0 === itemsCount ||
|
|
104
|
+
(1 === visibleCount && isOverflowing) ||
|
|
105
|
+
(visibleCount === itemsCount && !isOverflowing) ||
|
|
106
|
+
(maxGuess - minGuess === 1 && visibleCount === minGuess)
|
|
107
|
+
) {
|
|
108
|
+
dispatch({
|
|
109
|
+
type: 'stabilize',
|
|
110
|
+
});
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
if (maxGuess === visibleCount && !isOverflowing) {
|
|
114
|
+
dispatch({
|
|
115
|
+
type: 'shiftGuessRangeForward',
|
|
116
|
+
});
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
isOverflowing
|
|
120
|
+
? dispatch({
|
|
121
|
+
type: 'decreaseMaxGuess',
|
|
122
|
+
currentState: guessState,
|
|
123
|
+
})
|
|
124
|
+
: dispatch({
|
|
125
|
+
type: 'increaseMinGuess',
|
|
126
|
+
currentState: guessState,
|
|
127
|
+
});
|
|
128
|
+
} finally {
|
|
129
|
+
isGuessing.current = false;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}, [guessState, itemsCount, orientation]);
|
|
133
|
+
return [containerRef, guessState.visibleCount];
|
|
134
|
+
};
|
|
135
|
+
const STARTING_MAX_ITEMS_COUNT = 32;
|
|
136
|
+
const overflowGuessReducerInitialState = ({ itemsCount }) => {
|
|
137
|
+
let initialVisibleCount = Math.min(itemsCount, STARTING_MAX_ITEMS_COUNT);
|
|
138
|
+
return _dev.isUnitTest
|
|
139
|
+
? {
|
|
140
|
+
isStabilized: true,
|
|
141
|
+
minGuess: null,
|
|
142
|
+
maxGuess: null,
|
|
143
|
+
itemsCount,
|
|
144
|
+
visibleCount: itemsCount,
|
|
145
|
+
}
|
|
146
|
+
: {
|
|
147
|
+
isStabilized: false,
|
|
148
|
+
minGuess: 0,
|
|
149
|
+
maxGuess: initialVisibleCount,
|
|
150
|
+
itemsCount,
|
|
151
|
+
visibleCount: initialVisibleCount,
|
|
152
|
+
};
|
|
153
|
+
};
|
|
154
|
+
const overflowGuessReducer = (state, action) => {
|
|
155
|
+
let getSafeVisibleCount = ({ visibleCount, itemsCount }) =>
|
|
156
|
+
Math.min(itemsCount, visibleCount);
|
|
157
|
+
switch (action.type) {
|
|
158
|
+
case 'decreaseMaxGuess':
|
|
159
|
+
case 'increaseMinGuess':
|
|
160
|
+
if (state.isStabilized) return state;
|
|
161
|
+
let newMinGuess = state.minGuess;
|
|
162
|
+
let newMaxGuess = state.maxGuess;
|
|
163
|
+
if ('decreaseMaxGuess' === action.type)
|
|
164
|
+
newMaxGuess = action.currentState.visibleCount;
|
|
165
|
+
else newMinGuess = action.currentState.visibleCount;
|
|
166
|
+
let newVisibleCount = Math.floor((newMinGuess + newMaxGuess) / 2);
|
|
167
|
+
return {
|
|
168
|
+
...state,
|
|
169
|
+
isStabilized: false,
|
|
170
|
+
minGuess: newMinGuess,
|
|
171
|
+
maxGuess: newMaxGuess,
|
|
172
|
+
visibleCount: getSafeVisibleCount({
|
|
173
|
+
visibleCount: newVisibleCount,
|
|
174
|
+
itemsCount: state.itemsCount,
|
|
175
|
+
}),
|
|
176
|
+
};
|
|
177
|
+
case 'shiftGuessRangeForward':
|
|
178
|
+
if (state.isStabilized) return state;
|
|
179
|
+
let doubleOfMaxGuess = 2 * state.maxGuess;
|
|
180
|
+
return {
|
|
181
|
+
...state,
|
|
182
|
+
isStabilized: false,
|
|
183
|
+
minGuess: state.maxGuess,
|
|
184
|
+
maxGuess: doubleOfMaxGuess,
|
|
185
|
+
visibleCount: getSafeVisibleCount({
|
|
186
|
+
visibleCount: doubleOfMaxGuess,
|
|
187
|
+
itemsCount: state.itemsCount,
|
|
188
|
+
}),
|
|
189
|
+
};
|
|
190
|
+
case 'stabilize':
|
|
191
|
+
return {
|
|
192
|
+
...state,
|
|
193
|
+
isStabilized: true,
|
|
194
|
+
minGuess: null,
|
|
195
|
+
maxGuess: null,
|
|
196
|
+
};
|
|
197
|
+
default:
|
|
198
|
+
return state;
|
|
199
|
+
}
|
|
200
|
+
};
|
|
58
201
|
function useOverflowContainerContext() {
|
|
59
202
|
let overflowContainerContext = (0, _useSafeContext.useSafeContext)(
|
|
60
203
|
OverflowContainerContext,
|
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, '__esModule', {
|
|
|
5
5
|
const _export_star = require('@swc/helpers/_/_export_star');
|
|
6
6
|
_export_star._(require('./useEventListener.js'), exports);
|
|
7
7
|
_export_star._(require('./useMergedRefs.js'), exports);
|
|
8
|
-
_export_star._(require('./useOverflow.js'), exports);
|
|
9
8
|
_export_star._(require('./useResizeObserver.js'), exports);
|
|
10
9
|
_export_star._(require('./useContainerWidth.js'), exports);
|
|
11
10
|
_export_star._(require('./useGlobals.js'), exports);
|
|
@@ -19,4 +18,5 @@ _export_star._(require('./useId.js'), exports);
|
|
|
19
18
|
_export_star._(require('./useControlledState.js'), exports);
|
|
20
19
|
_export_star._(require('./useSyncExternalStore.js'), exports);
|
|
21
20
|
_export_star._(require('./useVirtualScroll.js'), exports);
|
|
21
|
+
_export_star._(require('./useInstance.js'), exports);
|
|
22
22
|
_export_star._(require('./useWarningLogger.js'), exports);
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
Object.defineProperty(exports, '__esModule', {
|
|
3
|
+
value: true,
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
Object.defineProperty(target, name, {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: all[name],
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
_export(exports, {
|
|
13
|
+
useInstance: function () {
|
|
14
|
+
return useInstance;
|
|
15
|
+
},
|
|
16
|
+
useSynchronizeInstance: function () {
|
|
17
|
+
return useSynchronizeInstance;
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
const _interop_require_wildcard = require('@swc/helpers/_/_interop_require_wildcard');
|
|
21
|
+
const _react = _interop_require_wildcard._(require('react'));
|
|
22
|
+
const _useSyncExternalStore = require('./useSyncExternalStore.js');
|
|
23
|
+
class Instance {}
|
|
24
|
+
const useInstance = () => _react.useMemo(() => new Instance(), []);
|
|
25
|
+
const useSynchronizeInstance = (instance, properties) => {
|
|
26
|
+
let synchronize = _react.useCallback(() => {
|
|
27
|
+
if (!(instance instanceof Instance)) return () => {};
|
|
28
|
+
Object.assign(instance, properties);
|
|
29
|
+
return () => {
|
|
30
|
+
for (let key in properties) delete instance[key];
|
|
31
|
+
};
|
|
32
|
+
}, [instance, properties]);
|
|
33
|
+
return (0, _useSyncExternalStore.useSyncExternalStore)(
|
|
34
|
+
synchronize,
|
|
35
|
+
() => instance,
|
|
36
|
+
() => instance,
|
|
37
|
+
);
|
|
38
|
+
};
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
} from '../../utils/index.js';
|
|
9
9
|
import { Button } from '../Buttons/Button.js';
|
|
10
10
|
import { Anchor } from '../Typography/Anchor.js';
|
|
11
|
-
let BreadcrumbsComponent = React.forwardRef((props,
|
|
11
|
+
let BreadcrumbsComponent = React.forwardRef((props, forwardedRef) => {
|
|
12
12
|
let {
|
|
13
13
|
children: childrenProp,
|
|
14
14
|
currentIndex = React.Children.count(childrenProp) - 1,
|
|
@@ -26,7 +26,7 @@ let BreadcrumbsComponent = React.forwardRef((props, ref) => {
|
|
|
26
26
|
{
|
|
27
27
|
as: 'nav',
|
|
28
28
|
className: cx('iui-breadcrumbs', className),
|
|
29
|
-
ref:
|
|
29
|
+
ref: forwardedRef,
|
|
30
30
|
'aria-label': 'Breadcrumb',
|
|
31
31
|
...rest,
|
|
32
32
|
},
|
|
@@ -34,11 +34,11 @@ export const Checkbox = React.forwardRef((props, ref) => {
|
|
|
34
34
|
'iui-checkbox',
|
|
35
35
|
{
|
|
36
36
|
'iui-checkbox-visibility': 'eyeball' === variant,
|
|
37
|
-
'iui-loading': isLoading,
|
|
38
37
|
},
|
|
39
38
|
className,
|
|
40
39
|
),
|
|
41
40
|
style: style,
|
|
41
|
+
'data-iui-loading': isLoading ? 'true' : void 0,
|
|
42
42
|
disabled: disabled || isLoading,
|
|
43
43
|
type: 'checkbox',
|
|
44
44
|
ref: refs,
|
|
@@ -57,15 +57,10 @@ export const Checkbox = React.forwardRef((props, ref) => {
|
|
|
57
57
|
Box,
|
|
58
58
|
{
|
|
59
59
|
as: 'label',
|
|
60
|
-
className: cx(
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
[`iui-${status}`]: !!status,
|
|
65
|
-
'iui-loading': isLoading,
|
|
66
|
-
},
|
|
67
|
-
wrapperClassName,
|
|
68
|
-
),
|
|
60
|
+
className: cx('iui-checkbox-wrapper', wrapperClassName),
|
|
61
|
+
'data-iui-disabled': disabled ? 'true' : void 0,
|
|
62
|
+
'data-iui-status': status,
|
|
63
|
+
'data-iui-loading': isLoading ? 'true' : void 0,
|
|
69
64
|
...restWrapperProps,
|
|
70
65
|
},
|
|
71
66
|
checkbox,
|
|
@@ -47,6 +47,7 @@ export const ComboBox = React.forwardRef((props, forwardedRef) => {
|
|
|
47
47
|
onHide: onHideProp,
|
|
48
48
|
id = inputProps?.id ? `iui-${inputProps.id}-cb` : idPrefix,
|
|
49
49
|
defaultValue,
|
|
50
|
+
clearFilterOnOptionToggle = true,
|
|
50
51
|
...rest
|
|
51
52
|
} = props;
|
|
52
53
|
let inputRef = React.useRef(null);
|
|
@@ -200,7 +201,6 @@ export const ComboBox = React.forwardRef((props, forwardedRef) => {
|
|
|
200
201
|
preventScroll: true,
|
|
201
202
|
});
|
|
202
203
|
if (optionsRef.current[__originalIndex]?.disabled) return;
|
|
203
|
-
setIsInputDirty(false);
|
|
204
204
|
if (multiple) {
|
|
205
205
|
let actionType = isMenuItemSelected(__originalIndex)
|
|
206
206
|
? 'removed'
|
|
@@ -218,7 +218,10 @@ export const ComboBox = React.forwardRef((props, forwardedRef) => {
|
|
|
218
218
|
.filter(Boolean)
|
|
219
219
|
.join(', '),
|
|
220
220
|
);
|
|
221
|
-
|
|
221
|
+
if (clearFilterOnOptionToggle) {
|
|
222
|
+
setInputValue('');
|
|
223
|
+
setIsInputDirty(false);
|
|
224
|
+
}
|
|
222
225
|
} else {
|
|
223
226
|
setSelectedIndexes(__originalIndex);
|
|
224
227
|
hide();
|
|
@@ -226,13 +229,14 @@ export const ComboBox = React.forwardRef((props, forwardedRef) => {
|
|
|
226
229
|
}
|
|
227
230
|
},
|
|
228
231
|
[
|
|
229
|
-
|
|
230
|
-
isMenuItemSelected,
|
|
232
|
+
optionsRef,
|
|
231
233
|
multiple,
|
|
234
|
+
isMenuItemSelected,
|
|
235
|
+
selectedChangeHandler,
|
|
236
|
+
setSelectedIndexes,
|
|
232
237
|
onChangeHandler,
|
|
233
|
-
|
|
238
|
+
clearFilterOnOptionToggle,
|
|
234
239
|
hide,
|
|
235
|
-
setSelectedIndexes,
|
|
236
240
|
],
|
|
237
241
|
);
|
|
238
242
|
let getMenuItem = React.useCallback(
|
|
@@ -8,6 +8,8 @@ import {
|
|
|
8
8
|
isBefore,
|
|
9
9
|
Box,
|
|
10
10
|
useId,
|
|
11
|
+
useLayoutEffect,
|
|
12
|
+
useWarningLogger,
|
|
11
13
|
} from '../../utils/index.js';
|
|
12
14
|
import { IconButton } from '../Buttons/IconButton.js';
|
|
13
15
|
import { TimePicker } from '../TimePicker/TimePicker.js';
|
|
@@ -135,6 +137,14 @@ export const DatePicker = React.forwardRef((props, forwardedRef) => {
|
|
|
135
137
|
showDatesOutsideMonth = true,
|
|
136
138
|
...rest
|
|
137
139
|
} = props;
|
|
140
|
+
let logWarning = useWarningLogger();
|
|
141
|
+
{
|
|
142
|
+
let onlyOneRangePropPassed = (startDate ? 1 : 0) + (endDate ? 1 : 0) === 1;
|
|
143
|
+
if (enableRangeSelect && onlyOneRangePropPassed)
|
|
144
|
+
logWarning(
|
|
145
|
+
'`DatePicker` with `enableRangeSelect` needs *both* `startDate` and `endDate` to either be `Date` or `undefined`. Passing `Date` to just one of them is not allowed.',
|
|
146
|
+
);
|
|
147
|
+
}
|
|
138
148
|
let monthNames = localizedNames?.months ?? defaultMonths;
|
|
139
149
|
let shortDays = localizedNames?.shortDays ?? defaultShortDays;
|
|
140
150
|
let longDays = localizedNames?.days ?? defaultLongDays;
|
|
@@ -177,7 +187,7 @@ export const DatePicker = React.forwardRef((props, forwardedRef) => {
|
|
|
177
187
|
);
|
|
178
188
|
}, [date, setMonthAndYear, startDate, endDate, enableRangeSelect]);
|
|
179
189
|
let popoverInitialFocusContext = React.useContext(PopoverInitialFocusContext);
|
|
180
|
-
|
|
190
|
+
useLayoutEffect(() => {
|
|
181
191
|
if (setFocus && popoverInitialFocusContext)
|
|
182
192
|
popoverInitialFocusContext.setInitialFocus(-1);
|
|
183
193
|
}, [popoverInitialFocusContext, setFocus]);
|
|
@@ -11,7 +11,7 @@ import { Transition } from 'react-transition-group';
|
|
|
11
11
|
let DialogComponent = React.forwardRef((props, ref) => {
|
|
12
12
|
let {
|
|
13
13
|
trapFocus = false,
|
|
14
|
-
setFocus =
|
|
14
|
+
setFocus = trapFocus,
|
|
15
15
|
preventDocumentScroll = false,
|
|
16
16
|
isOpen = false,
|
|
17
17
|
isDismissible = true,
|