@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
|
@@ -1,105 +1,124 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import cx from 'classnames';
|
|
3
3
|
import {
|
|
4
|
-
useMergedRefs,
|
|
5
|
-
useOverflow,
|
|
6
4
|
SvgChevronRight,
|
|
7
5
|
Box,
|
|
6
|
+
OverflowContainer,
|
|
8
7
|
useWarningLogger,
|
|
9
8
|
} from '../../utils/index.js';
|
|
10
9
|
import { Button } from '../Buttons/Button.js';
|
|
11
10
|
import { Anchor } from '../Typography/Anchor.js';
|
|
12
11
|
let BreadcrumbsComponent = React.forwardRef((props, ref) => {
|
|
13
12
|
let {
|
|
14
|
-
children:
|
|
15
|
-
currentIndex =
|
|
13
|
+
children: childrenProp,
|
|
14
|
+
currentIndex = React.Children.count(childrenProp) - 1,
|
|
16
15
|
separator,
|
|
17
16
|
overflowButton,
|
|
18
17
|
className,
|
|
19
18
|
...rest
|
|
20
19
|
} = props;
|
|
21
|
-
let
|
|
22
|
-
|
|
20
|
+
let items = React.useMemo(
|
|
21
|
+
() => React.Children.toArray(childrenProp),
|
|
22
|
+
[childrenProp],
|
|
23
|
+
);
|
|
23
24
|
return React.createElement(
|
|
24
25
|
Box,
|
|
25
26
|
{
|
|
26
27
|
as: 'nav',
|
|
27
28
|
className: cx('iui-breadcrumbs', className),
|
|
28
|
-
ref:
|
|
29
|
+
ref: ref,
|
|
29
30
|
'aria-label': 'Breadcrumb',
|
|
30
31
|
...rest,
|
|
31
32
|
},
|
|
32
33
|
React.createElement(
|
|
33
|
-
|
|
34
|
+
OverflowContainer,
|
|
34
35
|
{
|
|
35
36
|
as: 'ol',
|
|
37
|
+
itemsCount: items.length,
|
|
36
38
|
className: 'iui-breadcrumbs-list',
|
|
37
39
|
},
|
|
38
|
-
|
|
40
|
+
React.createElement(
|
|
41
|
+
BreadcrumbContent,
|
|
42
|
+
{
|
|
43
|
+
currentIndex: currentIndex,
|
|
44
|
+
overflowButton: overflowButton,
|
|
45
|
+
separator: separator,
|
|
46
|
+
},
|
|
47
|
+
items,
|
|
48
|
+
),
|
|
49
|
+
),
|
|
50
|
+
);
|
|
51
|
+
});
|
|
52
|
+
BreadcrumbsComponent.displayName = 'Breadcrumbs';
|
|
53
|
+
let BreadcrumbContent = (props) => {
|
|
54
|
+
let { children: items, currentIndex, overflowButton, separator } = props;
|
|
55
|
+
let { visibleCount } = OverflowContainer.useContext();
|
|
56
|
+
return React.createElement(
|
|
57
|
+
React.Fragment,
|
|
58
|
+
null,
|
|
59
|
+
visibleCount > 1 &&
|
|
60
|
+
React.createElement(
|
|
61
|
+
React.Fragment,
|
|
62
|
+
null,
|
|
63
|
+
React.createElement(ListItem, {
|
|
64
|
+
item: items[0],
|
|
65
|
+
isActive: 0 === currentIndex,
|
|
66
|
+
}),
|
|
67
|
+
React.createElement(Separator, {
|
|
68
|
+
separator: separator,
|
|
69
|
+
}),
|
|
70
|
+
),
|
|
71
|
+
items.length - visibleCount > 0 &&
|
|
72
|
+
React.createElement(
|
|
73
|
+
React.Fragment,
|
|
74
|
+
null,
|
|
39
75
|
React.createElement(
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
76
|
+
Box,
|
|
77
|
+
{
|
|
78
|
+
as: 'li',
|
|
79
|
+
className: 'iui-breadcrumbs-item',
|
|
80
|
+
},
|
|
81
|
+
overflowButton
|
|
82
|
+
? overflowButton(visibleCount)
|
|
83
|
+
: React.createElement(
|
|
84
|
+
Box,
|
|
85
|
+
{
|
|
86
|
+
as: 'span',
|
|
87
|
+
className: 'iui-breadcrumbs-content',
|
|
88
|
+
},
|
|
89
|
+
'…',
|
|
90
|
+
),
|
|
49
91
|
),
|
|
50
|
-
|
|
51
|
-
|
|
92
|
+
React.createElement(Separator, {
|
|
93
|
+
separator: separator,
|
|
94
|
+
}),
|
|
95
|
+
),
|
|
96
|
+
items
|
|
97
|
+
.slice(
|
|
98
|
+
visibleCount > 1 ? items.length - visibleCount + 1 : items.length - 1,
|
|
99
|
+
)
|
|
100
|
+
.map((_, _index) => {
|
|
101
|
+
let index =
|
|
102
|
+
visibleCount > 1
|
|
103
|
+
? 1 + (items.length - visibleCount) + _index
|
|
104
|
+
: items.length - 1;
|
|
105
|
+
return React.createElement(
|
|
52
106
|
React.Fragment,
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
},
|
|
60
|
-
overflowButton
|
|
61
|
-
? overflowButton(visibleCount)
|
|
62
|
-
: React.createElement(
|
|
63
|
-
Box,
|
|
64
|
-
{
|
|
65
|
-
as: 'span',
|
|
66
|
-
className: 'iui-breadcrumbs-content',
|
|
67
|
-
},
|
|
68
|
-
'…',
|
|
69
|
-
),
|
|
70
|
-
),
|
|
71
|
-
React.createElement(Separator, {
|
|
72
|
-
separator: separator,
|
|
107
|
+
{
|
|
108
|
+
key: index,
|
|
109
|
+
},
|
|
110
|
+
React.createElement(ListItem, {
|
|
111
|
+
item: items[index],
|
|
112
|
+
isActive: currentIndex === index,
|
|
73
113
|
}),
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
visibleCount > 1 ? items.length - visibleCount + 1 : items.length - 1,
|
|
78
|
-
)
|
|
79
|
-
.map((_, _index) => {
|
|
80
|
-
let index =
|
|
81
|
-
visibleCount > 1
|
|
82
|
-
? 1 + (items.length - visibleCount) + _index
|
|
83
|
-
: items.length - 1;
|
|
84
|
-
return React.createElement(
|
|
85
|
-
React.Fragment,
|
|
86
|
-
{
|
|
87
|
-
key: index,
|
|
88
|
-
},
|
|
89
|
-
React.createElement(ListItem, {
|
|
90
|
-
item: items[index],
|
|
91
|
-
isActive: currentIndex === index,
|
|
114
|
+
index < items.length - 1 &&
|
|
115
|
+
React.createElement(Separator, {
|
|
116
|
+
separator: separator,
|
|
92
117
|
}),
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
separator: separator,
|
|
96
|
-
}),
|
|
97
|
-
);
|
|
98
|
-
}),
|
|
99
|
-
),
|
|
118
|
+
);
|
|
119
|
+
}),
|
|
100
120
|
);
|
|
101
|
-
}
|
|
102
|
-
BreadcrumbsComponent.displayName = 'Breadcrumbs';
|
|
121
|
+
};
|
|
103
122
|
let ListItem = ({ item, isActive }) => {
|
|
104
123
|
let children = item;
|
|
105
124
|
let logWarning = useWarningLogger();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import cx from 'classnames';
|
|
3
|
-
import {
|
|
3
|
+
import { Box, OverflowContainer } from '../../utils/index.js';
|
|
4
4
|
import {
|
|
5
5
|
Composite,
|
|
6
6
|
CompositeItem,
|
|
@@ -93,14 +93,12 @@ let OverflowGroup = React.forwardRef((props, forwardedRef) => {
|
|
|
93
93
|
() => React.Children.toArray(childrenProp).filter(Boolean),
|
|
94
94
|
[childrenProp],
|
|
95
95
|
);
|
|
96
|
-
let [overflowRef, visibleCount] = useOverflow(
|
|
97
|
-
items,
|
|
98
|
-
!overflowButton,
|
|
99
|
-
orientation,
|
|
100
|
-
);
|
|
101
96
|
return React.createElement(
|
|
102
|
-
|
|
97
|
+
OverflowContainer,
|
|
103
98
|
{
|
|
99
|
+
as: BaseGroup,
|
|
100
|
+
itemsCount: items.length,
|
|
101
|
+
overflowOrientation: orientation,
|
|
104
102
|
orientation: orientation,
|
|
105
103
|
...rest,
|
|
106
104
|
className: cx(
|
|
@@ -110,27 +108,34 @@ let OverflowGroup = React.forwardRef((props, forwardedRef) => {
|
|
|
110
108
|
},
|
|
111
109
|
props.className,
|
|
112
110
|
),
|
|
113
|
-
ref:
|
|
111
|
+
ref: forwardedRef,
|
|
114
112
|
},
|
|
115
|
-
(
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
: visibleCount - 1;
|
|
121
|
-
return React.createElement(
|
|
122
|
-
React.Fragment,
|
|
123
|
-
null,
|
|
124
|
-
overflowButton &&
|
|
125
|
-
'start' === overflowPlacement &&
|
|
126
|
-
overflowButton(overflowStart),
|
|
127
|
-
'start' === overflowPlacement
|
|
128
|
-
? items.slice(overflowStart + 1)
|
|
129
|
-
: items.slice(0, Math.max(0, overflowStart)),
|
|
130
|
-
overflowButton &&
|
|
131
|
-
'end' === overflowPlacement &&
|
|
132
|
-
overflowButton(overflowStart),
|
|
133
|
-
);
|
|
134
|
-
})(),
|
|
113
|
+
React.createElement(OverflowGroupContent, {
|
|
114
|
+
overflowButton: overflowButton,
|
|
115
|
+
overflowPlacement: overflowPlacement,
|
|
116
|
+
items: items,
|
|
117
|
+
}),
|
|
135
118
|
);
|
|
136
119
|
});
|
|
120
|
+
let OverflowGroupContent = (props) => {
|
|
121
|
+
let { overflowButton, overflowPlacement, items } = props;
|
|
122
|
+
let { visibleCount } = OverflowContainer.useContext();
|
|
123
|
+
let overflowStart =
|
|
124
|
+
'start' === overflowPlacement
|
|
125
|
+
? items.length - visibleCount
|
|
126
|
+
: visibleCount - 1;
|
|
127
|
+
if (!(visibleCount < items.length)) return items;
|
|
128
|
+
return React.createElement(
|
|
129
|
+
React.Fragment,
|
|
130
|
+
null,
|
|
131
|
+
overflowButton &&
|
|
132
|
+
'start' === overflowPlacement &&
|
|
133
|
+
overflowButton(overflowStart),
|
|
134
|
+
'start' === overflowPlacement
|
|
135
|
+
? items.slice(overflowStart + 1)
|
|
136
|
+
: items.slice(0, Math.max(0, overflowStart)),
|
|
137
|
+
overflowButton &&
|
|
138
|
+
'end' === overflowPlacement &&
|
|
139
|
+
overflowButton(overflowStart),
|
|
140
|
+
);
|
|
141
|
+
};
|
|
@@ -113,12 +113,14 @@ export const ComboBox = React.forwardRef((props, forwardedRef) => {
|
|
|
113
113
|
setFocusedIndex(selectedIndexes ?? -1);
|
|
114
114
|
} else {
|
|
115
115
|
setFocusedIndex(-1);
|
|
116
|
-
|
|
117
|
-
setInputValue(
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
116
|
+
isMultipleEnabled(selectedIndexes, multiple)
|
|
117
|
+
? setInputValue('')
|
|
118
|
+
: setInputValue(
|
|
119
|
+
selectedIndexes >= 0
|
|
120
|
+
? optionsRef.current[selectedIndexes]?.label ?? ''
|
|
121
|
+
: '',
|
|
122
|
+
);
|
|
123
|
+
setIsInputDirty(false);
|
|
122
124
|
}
|
|
123
125
|
}, [isOpen, multiple, optionsRef, selectedIndexes]);
|
|
124
126
|
let previousOptions = React.useRef(options);
|
|
@@ -216,6 +218,7 @@ export const ComboBox = React.forwardRef((props, forwardedRef) => {
|
|
|
216
218
|
.filter(Boolean)
|
|
217
219
|
.join(', '),
|
|
218
220
|
);
|
|
221
|
+
setInputValue('');
|
|
219
222
|
} else {
|
|
220
223
|
setSelectedIndexes(__originalIndex);
|
|
221
224
|
hide();
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
} from '../../utils/index.js';
|
|
12
12
|
import { IconButton } from '../Buttons/IconButton.js';
|
|
13
13
|
import { TimePicker } from '../TimePicker/TimePicker.js';
|
|
14
|
+
import { PopoverInitialFocusContext } from '../Popover/Popover.js';
|
|
14
15
|
let isSameDay = (a, b) =>
|
|
15
16
|
a &&
|
|
16
17
|
b &&
|
|
@@ -175,6 +176,11 @@ export const DatePicker = React.forwardRef((props, forwardedRef) => {
|
|
|
175
176
|
currentDate.getFullYear(),
|
|
176
177
|
);
|
|
177
178
|
}, [date, setMonthAndYear, startDate, endDate, enableRangeSelect]);
|
|
179
|
+
let popoverInitialFocusContext = React.useContext(PopoverInitialFocusContext);
|
|
180
|
+
React.useLayoutEffect(() => {
|
|
181
|
+
if (setFocus && popoverInitialFocusContext)
|
|
182
|
+
popoverInitialFocusContext.setInitialFocus(-1);
|
|
183
|
+
}, [popoverInitialFocusContext, setFocus]);
|
|
178
184
|
let days = React.useMemo(() => {
|
|
179
185
|
let offsetToFirst = new Date(
|
|
180
186
|
displayedYear,
|
|
@@ -499,10 +505,12 @@ export const DatePicker = React.forwardRef((props, forwardedRef) => {
|
|
|
499
505
|
role: 'option',
|
|
500
506
|
tabIndex: isSameDay(weekDay, focusedDay) ? 0 : -1,
|
|
501
507
|
'aria-disabled': isDisabled ? 'true' : void 0,
|
|
502
|
-
ref: (element) =>
|
|
503
|
-
isSameDay(weekDay, focusedDay) &&
|
|
504
|
-
|
|
505
|
-
|
|
508
|
+
ref: (element) => {
|
|
509
|
+
if (isSameDay(weekDay, focusedDay) && needFocus.current)
|
|
510
|
+
setTimeout(() => {
|
|
511
|
+
element?.focus();
|
|
512
|
+
});
|
|
513
|
+
},
|
|
506
514
|
...dayProps,
|
|
507
515
|
className: cx(getDayClass(weekDay), dayProps?.className),
|
|
508
516
|
},
|
|
@@ -33,7 +33,9 @@ import {
|
|
|
33
33
|
useMergedRefs,
|
|
34
34
|
} from '../../utils/index.js';
|
|
35
35
|
import { usePortalTo } from '../../utils/components/Portal.js';
|
|
36
|
+
import { ThemeProvider } from '../ThemeProvider/ThemeProvider.js';
|
|
36
37
|
export const PopoverOpenContext = React.createContext(void 0);
|
|
38
|
+
export const PopoverInitialFocusContext = React.createContext(void 0);
|
|
37
39
|
export const usePopover = (options) => {
|
|
38
40
|
let {
|
|
39
41
|
placement = 'bottom-start',
|
|
@@ -231,7 +233,12 @@ export const Popover = React.forwardRef((props, forwardedRef) => {
|
|
|
231
233
|
role: 'dialog',
|
|
232
234
|
middleware,
|
|
233
235
|
});
|
|
234
|
-
let
|
|
236
|
+
let [popoverElement, setPopoverElement] = React.useState();
|
|
237
|
+
let popoverRef = useMergedRefs(
|
|
238
|
+
popover.refs.setFloating,
|
|
239
|
+
forwardedRef,
|
|
240
|
+
setPopoverElement,
|
|
241
|
+
);
|
|
235
242
|
let triggerId = `${useId()}-trigger`;
|
|
236
243
|
let hasAriaLabel = !!props['aria-labelledby'] || !!props['aria-label'];
|
|
237
244
|
useLayoutEffect(() => {
|
|
@@ -239,6 +246,13 @@ export const Popover = React.forwardRef((props, forwardedRef) => {
|
|
|
239
246
|
popover.refs.setPositionReference(positionReference);
|
|
240
247
|
return () => void popover.refs.setPositionReference(null);
|
|
241
248
|
}, [popover.refs, positionReference]);
|
|
249
|
+
let [initialFocus, setInitialFocus] = React.useState();
|
|
250
|
+
let initialFocusContextValue = React.useMemo(
|
|
251
|
+
() => ({
|
|
252
|
+
setInitialFocus,
|
|
253
|
+
}),
|
|
254
|
+
[],
|
|
255
|
+
);
|
|
242
256
|
return React.createElement(
|
|
243
257
|
React.Fragment,
|
|
244
258
|
null,
|
|
@@ -255,32 +269,46 @@ export const Popover = React.forwardRef((props, forwardedRef) => {
|
|
|
255
269
|
),
|
|
256
270
|
popover.open
|
|
257
271
|
? React.createElement(
|
|
258
|
-
|
|
272
|
+
PopoverInitialFocusContext.Provider,
|
|
259
273
|
{
|
|
260
|
-
|
|
274
|
+
value: initialFocusContextValue,
|
|
261
275
|
},
|
|
262
276
|
React.createElement(
|
|
263
|
-
|
|
277
|
+
PopoverPortal,
|
|
264
278
|
{
|
|
265
|
-
|
|
266
|
-
modal: false,
|
|
279
|
+
portal: portal,
|
|
267
280
|
},
|
|
268
281
|
React.createElement(
|
|
269
|
-
|
|
282
|
+
ThemeProvider,
|
|
270
283
|
{
|
|
271
|
-
|
|
284
|
+
portalContainer: popoverElement,
|
|
285
|
+
},
|
|
286
|
+
React.createElement(DisplayContents, null),
|
|
287
|
+
React.createElement(
|
|
288
|
+
FloatingFocusManager,
|
|
289
|
+
{
|
|
290
|
+
context: popover.context,
|
|
291
|
+
modal: false,
|
|
292
|
+
initialFocus: initialFocus,
|
|
293
|
+
},
|
|
294
|
+
React.createElement(
|
|
295
|
+
Box,
|
|
272
296
|
{
|
|
273
|
-
|
|
297
|
+
className: cx(
|
|
298
|
+
{
|
|
299
|
+
'iui-popover-surface': applyBackground,
|
|
300
|
+
},
|
|
301
|
+
className,
|
|
302
|
+
),
|
|
303
|
+
'aria-labelledby': hasAriaLabel
|
|
304
|
+
? void 0
|
|
305
|
+
: popover.refs.domReference.current?.id,
|
|
306
|
+
...popover.getFloatingProps(rest),
|
|
307
|
+
ref: popoverRef,
|
|
274
308
|
},
|
|
275
|
-
|
|
309
|
+
content,
|
|
276
310
|
),
|
|
277
|
-
|
|
278
|
-
? void 0
|
|
279
|
-
: popover.refs.domReference.current?.id,
|
|
280
|
-
...popover.getFloatingProps(rest),
|
|
281
|
-
ref: popoverRef,
|
|
282
|
-
},
|
|
283
|
-
content,
|
|
311
|
+
),
|
|
284
312
|
),
|
|
285
313
|
),
|
|
286
314
|
)
|
|
@@ -22,10 +22,11 @@ export const ProgressLinear = React.forwardRef((props, forwardedRef) => {
|
|
|
22
22
|
'data-iui-status': status,
|
|
23
23
|
'data-iui-indeterminate': indeterminate ? 'true' : void 0,
|
|
24
24
|
'data-iui-animated': isAnimated ? 'true' : void 0,
|
|
25
|
+
...rest,
|
|
25
26
|
style: {
|
|
26
27
|
'--iui-progress-percentage': `${boundedValue}%`,
|
|
28
|
+
...props.style,
|
|
27
29
|
},
|
|
28
|
-
...rest,
|
|
29
30
|
},
|
|
30
31
|
React.createElement(
|
|
31
32
|
ShadowRoot,
|
|
@@ -1,26 +1,37 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import cx from 'classnames';
|
|
3
|
-
import { useOverflow, useMergedRefs, Box } from '../../utils/index.js';
|
|
4
3
|
import { SelectTag } from './SelectTag.js';
|
|
4
|
+
import { OverflowContainer } from '../../utils/index.js';
|
|
5
5
|
export const SelectTagContainer = React.forwardRef((props, ref) => {
|
|
6
|
-
let { tags, className, ...rest } = props;
|
|
7
|
-
let
|
|
8
|
-
let refs = useMergedRefs(ref, containerRef);
|
|
6
|
+
let { tags: tagsProp, className, ...rest } = props;
|
|
7
|
+
let tags = React.useMemo(() => React.Children.toArray(tagsProp), [tagsProp]);
|
|
9
8
|
return React.createElement(
|
|
10
|
-
|
|
9
|
+
OverflowContainer,
|
|
11
10
|
{
|
|
11
|
+
itemsCount: tags.length,
|
|
12
12
|
className: cx('iui-select-tag-container', className),
|
|
13
|
-
ref:
|
|
13
|
+
ref: ref,
|
|
14
14
|
...rest,
|
|
15
15
|
},
|
|
16
|
+
React.createElement(SelectTagContainerContent, {
|
|
17
|
+
...props,
|
|
18
|
+
tags: tags,
|
|
19
|
+
}),
|
|
20
|
+
);
|
|
21
|
+
});
|
|
22
|
+
let SelectTagContainerContent = (props) => {
|
|
23
|
+
let { tags } = props;
|
|
24
|
+
let { visibleCount } = OverflowContainer.useContext();
|
|
25
|
+
return React.createElement(
|
|
26
|
+
React.Fragment,
|
|
27
|
+
null,
|
|
28
|
+
visibleCount < tags.length ? tags.slice(0, visibleCount - 1) : tags,
|
|
16
29
|
React.createElement(
|
|
17
|
-
|
|
30
|
+
OverflowContainer.OverflowNode,
|
|
18
31
|
null,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
label: `+${tags.length - visibleCount + 1} item(s)`,
|
|
23
|
-
}),
|
|
32
|
+
React.createElement(SelectTag, {
|
|
33
|
+
label: `+${tags.length - visibleCount + 1} item(s)`,
|
|
34
|
+
}),
|
|
24
35
|
),
|
|
25
36
|
);
|
|
26
|
-
}
|
|
37
|
+
};
|
|
@@ -5,40 +5,39 @@ import {
|
|
|
5
5
|
LineClamp,
|
|
6
6
|
SvgSortDown,
|
|
7
7
|
SvgSortUp,
|
|
8
|
+
useMergedRefs,
|
|
8
9
|
} from '../../utils/index.js';
|
|
9
|
-
import { SELECTION_CELL_ID } from './columns/index.js';
|
|
10
10
|
import { FilterToggle } from './filters/FilterToggle.js';
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
getCellStyle,
|
|
13
|
+
getSubRowStyle,
|
|
14
|
+
getStickyStyle,
|
|
15
|
+
TableInstanceContext,
|
|
16
|
+
} from './utils.js';
|
|
12
17
|
import cx from 'classnames';
|
|
13
|
-
export const ColumnHeader = (props) => {
|
|
18
|
+
export const ColumnHeader = React.forwardRef((props, forwardedRef) => {
|
|
14
19
|
let {
|
|
15
|
-
columnRefs,
|
|
16
20
|
column,
|
|
17
|
-
index,
|
|
18
21
|
areFiltersSet,
|
|
19
|
-
hasAnySubRows,
|
|
20
|
-
headers,
|
|
21
|
-
state,
|
|
22
|
-
data,
|
|
23
22
|
isResizable,
|
|
24
23
|
columnResizeMode,
|
|
25
24
|
enableColumnReordering,
|
|
26
25
|
density,
|
|
27
|
-
|
|
26
|
+
columnHasExpanders,
|
|
27
|
+
isLast,
|
|
28
|
+
isTableEmpty,
|
|
28
29
|
...rest
|
|
29
30
|
} = props;
|
|
30
31
|
let isHeaderDirectClick = React.useRef(false);
|
|
32
|
+
let instance = React.useContext(TableInstanceContext);
|
|
31
33
|
let COLUMN_MIN_WIDTHS = {
|
|
32
34
|
default: 72,
|
|
33
35
|
withExpander: 108,
|
|
34
36
|
};
|
|
35
37
|
let showFilterButton = (column) =>
|
|
36
|
-
(
|
|
37
|
-
let showSortButton = (column) =>
|
|
38
|
+
(!isTableEmpty || areFiltersSet) && column.canFilter && !!column.Filter;
|
|
39
|
+
let showSortButton = (column) => !isTableEmpty && column.canSort;
|
|
38
40
|
let { onClick, ...restSortProps } = column.getSortByToggleProps();
|
|
39
|
-
let columnHasExpanders =
|
|
40
|
-
hasAnySubRows &&
|
|
41
|
-
index === headers.findIndex((c) => c.id !== SELECTION_CELL_ID);
|
|
42
41
|
if ([void 0, 0].includes(column.minWidth)) {
|
|
43
42
|
column.minWidth = columnHasExpanders
|
|
44
43
|
? COLUMN_MIN_WIDTHS.withExpander
|
|
@@ -58,12 +57,12 @@ export const ColumnHeader = (props) => {
|
|
|
58
57
|
column.columnClassName,
|
|
59
58
|
),
|
|
60
59
|
style: {
|
|
61
|
-
...getCellStyle(column, !!state.isTableResizing),
|
|
60
|
+
...getCellStyle(column, !!instance?.state.isTableResizing),
|
|
62
61
|
...(columnHasExpanders &&
|
|
63
62
|
getSubRowStyle({
|
|
64
63
|
density,
|
|
65
64
|
})),
|
|
66
|
-
...getStickyStyle(column, visibleColumns),
|
|
65
|
+
...getStickyStyle(column, instance?.visibleColumns ?? []),
|
|
67
66
|
flexWrap: 'wrap',
|
|
68
67
|
columnGap: 'var(--iui-size-xs)',
|
|
69
68
|
},
|
|
@@ -75,14 +74,14 @@ export const ColumnHeader = (props) => {
|
|
|
75
74
|
...rest,
|
|
76
75
|
key: columnProps.key,
|
|
77
76
|
title: void 0,
|
|
78
|
-
ref:
|
|
79
|
-
(
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
77
|
+
ref: useMergedRefs(
|
|
78
|
+
React.useCallback(
|
|
79
|
+
(el) => {
|
|
80
|
+
if (el) column.resizeWidth = el.getBoundingClientRect().width;
|
|
81
|
+
},
|
|
82
|
+
[column],
|
|
83
|
+
),
|
|
84
|
+
forwardedRef,
|
|
86
85
|
),
|
|
87
86
|
onMouseDown: () => {
|
|
88
87
|
isHeaderDirectClick.current = true;
|
|
@@ -153,7 +152,7 @@ export const ColumnHeader = (props) => {
|
|
|
153
152
|
),
|
|
154
153
|
isResizable &&
|
|
155
154
|
column.isResizerVisible &&
|
|
156
|
-
(
|
|
155
|
+
(!isLast || 'expand' === columnResizeMode) &&
|
|
157
156
|
React.createElement(
|
|
158
157
|
Box,
|
|
159
158
|
{
|
|
@@ -172,17 +171,17 @@ export const ColumnHeader = (props) => {
|
|
|
172
171
|
slot: 'resizers',
|
|
173
172
|
}),
|
|
174
173
|
'left' === column.sticky &&
|
|
175
|
-
state.sticky.isScrolledToRight &&
|
|
174
|
+
instance?.state.sticky.isScrolledToRight &&
|
|
176
175
|
React.createElement(Box, {
|
|
177
176
|
className: 'iui-table-cell-shadow-right',
|
|
178
177
|
slot: 'shadows',
|
|
179
178
|
}),
|
|
180
179
|
'right' === column.sticky &&
|
|
181
|
-
state.sticky.isScrolledToLeft &&
|
|
180
|
+
instance?.state.sticky.isScrolledToLeft &&
|
|
182
181
|
React.createElement(Box, {
|
|
183
182
|
className: 'iui-table-cell-shadow-left',
|
|
184
183
|
slot: 'shadows',
|
|
185
184
|
}),
|
|
186
185
|
),
|
|
187
186
|
);
|
|
188
|
-
};
|
|
187
|
+
});
|