@itwin/itwinui-react 3.18.2 → 3.19.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 +50 -0
- package/DEV-cjs/core/ComboBox/ComboBoxMenuItem.js +1 -1
- package/DEV-cjs/core/Menu/MenuItem.js +8 -7
- package/DEV-cjs/core/Select/Select.js +18 -10
- package/DEV-cjs/core/SideNavigation/SideNavigation.js +2 -2
- package/DEV-cjs/core/Table/ColumnHeader.js +7 -3
- package/DEV-cjs/core/Table/Table.js +65 -5
- package/DEV-cjs/core/Table/cells/DefaultCell.js +14 -9
- package/DEV-cjs/core/Table/columns/actionColumn.js +1 -0
- package/DEV-cjs/core/Table/columns/expanderColumn.js +25 -20
- package/DEV-cjs/core/Table/columns/selectionColumn.js +14 -8
- package/DEV-cjs/core/Table/hooks/useExpanderCell.js +10 -6
- package/DEV-cjs/core/Tag/Tag.js +8 -2
- package/DEV-cjs/core/ThemeProvider/ThemeProvider.js +46 -46
- package/DEV-cjs/core/ToggleSwitch/ToggleSwitch.js +15 -4
- package/DEV-cjs/styles.js +1 -1
- package/DEV-cjs/utils/components/index.js +1 -1
- package/DEV-cjs/utils/components/lineClamp.js +23 -0
- package/DEV-cjs/utils/functions/react.js +18 -4
- package/DEV-cjs/utils/hooks/useControlledState.js +5 -1
- package/DEV-cjs/utils/providers/FutureFlagsProvider.js +48 -0
- package/DEV-cjs/utils/providers/index.js +1 -0
- package/DEV-esm/core/ComboBox/ComboBoxMenuItem.js +1 -1
- package/DEV-esm/core/Menu/MenuItem.js +8 -7
- package/DEV-esm/core/Select/Select.js +19 -10
- package/DEV-esm/core/SideNavigation/SideNavigation.js +2 -2
- package/DEV-esm/core/Table/ColumnHeader.js +8 -4
- package/DEV-esm/core/Table/Table.js +65 -5
- package/DEV-esm/core/Table/cells/DefaultCell.js +15 -10
- package/DEV-esm/core/Table/columns/actionColumn.js +1 -0
- package/DEV-esm/core/Table/columns/expanderColumn.js +25 -20
- package/DEV-esm/core/Table/columns/selectionColumn.js +14 -8
- package/DEV-esm/core/Table/hooks/useExpanderCell.js +10 -6
- package/DEV-esm/core/Tag/Tag.js +11 -3
- package/DEV-esm/core/ThemeProvider/ThemeProvider.js +48 -42
- package/DEV-esm/core/ToggleSwitch/ToggleSwitch.js +15 -5
- package/DEV-esm/styles.js +1 -1
- package/DEV-esm/utils/components/index.js +1 -1
- package/DEV-esm/utils/components/lineClamp.js +13 -0
- package/DEV-esm/utils/functions/react.js +6 -1
- package/DEV-esm/utils/hooks/useControlledState.js +5 -1
- package/DEV-esm/utils/providers/FutureFlagsProvider.js +28 -0
- package/DEV-esm/utils/providers/index.js +1 -0
- package/cjs/core/Buttons/DropdownButton.d.ts +1 -1
- package/cjs/core/ComboBox/ComboBoxMenuItem.d.ts +5 -16
- package/cjs/core/ComboBox/ComboBoxMenuItem.js +1 -1
- package/cjs/core/DropdownMenu/DropdownMenu.d.ts +1 -1
- package/cjs/core/Menu/MenuItem.d.ts +7 -1
- package/cjs/core/Menu/MenuItem.js +8 -7
- package/cjs/core/Popover/Popover.d.ts +5 -3
- package/cjs/core/Select/Select.js +18 -10
- package/cjs/core/SideNavigation/SideNavigation.js +2 -2
- package/cjs/core/Table/ColumnHeader.js +7 -3
- package/cjs/core/Table/Table.d.ts +2 -2
- package/cjs/core/Table/Table.js +65 -5
- package/cjs/core/Table/cells/DefaultCell.js +14 -9
- package/cjs/core/Table/columns/actionColumn.d.ts +1 -0
- package/cjs/core/Table/columns/actionColumn.js +1 -0
- package/cjs/core/Table/columns/expanderColumn.d.ts +2 -2
- package/cjs/core/Table/columns/expanderColumn.js +25 -20
- package/cjs/core/Table/columns/selectionColumn.d.ts +2 -2
- package/cjs/core/Table/columns/selectionColumn.js +14 -8
- package/cjs/core/Table/hooks/useExpanderCell.js +10 -6
- package/cjs/core/Tabs/Tabs.d.ts +4 -1
- package/cjs/core/Tag/Tag.js +8 -2
- package/cjs/core/ThemeProvider/ThemeContext.d.ts +1 -2
- package/cjs/core/ThemeProvider/ThemeProvider.d.ts +8 -18
- package/cjs/core/ThemeProvider/ThemeProvider.js +46 -46
- package/cjs/core/ToggleSwitch/ToggleSwitch.d.ts +21 -0
- package/cjs/core/ToggleSwitch/ToggleSwitch.js +15 -4
- package/cjs/styles.js +1 -1
- package/cjs/utils/components/index.d.ts +1 -1
- package/cjs/utils/components/index.js +1 -1
- package/cjs/utils/components/lineClamp.d.ts +5 -0
- package/cjs/utils/components/lineClamp.js +23 -0
- package/cjs/utils/functions/react.d.ts +5 -0
- package/cjs/utils/functions/react.js +18 -4
- package/cjs/utils/hooks/useControlledState.d.ts +5 -2
- package/cjs/utils/hooks/useControlledState.js +5 -1
- package/cjs/utils/hooks/useGlobals.d.ts +0 -1
- package/cjs/utils/providers/FutureFlagsProvider.d.ts +37 -0
- package/cjs/utils/providers/FutureFlagsProvider.js +48 -0
- package/cjs/utils/providers/index.d.ts +1 -0
- package/cjs/utils/providers/index.js +1 -0
- package/esm/core/Buttons/DropdownButton.d.ts +1 -1
- package/esm/core/ComboBox/ComboBoxMenuItem.d.ts +5 -16
- package/esm/core/ComboBox/ComboBoxMenuItem.js +1 -1
- package/esm/core/DropdownMenu/DropdownMenu.d.ts +1 -1
- package/esm/core/Menu/MenuItem.d.ts +7 -1
- package/esm/core/Menu/MenuItem.js +8 -7
- package/esm/core/Popover/Popover.d.ts +5 -3
- package/esm/core/Select/Select.js +19 -10
- package/esm/core/SideNavigation/SideNavigation.js +2 -2
- package/esm/core/Table/ColumnHeader.js +8 -4
- package/esm/core/Table/Table.d.ts +2 -2
- package/esm/core/Table/Table.js +65 -5
- package/esm/core/Table/cells/DefaultCell.js +15 -10
- package/esm/core/Table/columns/actionColumn.d.ts +1 -0
- package/esm/core/Table/columns/actionColumn.js +1 -0
- package/esm/core/Table/columns/expanderColumn.d.ts +2 -2
- package/esm/core/Table/columns/expanderColumn.js +25 -20
- package/esm/core/Table/columns/selectionColumn.d.ts +2 -2
- package/esm/core/Table/columns/selectionColumn.js +14 -8
- package/esm/core/Table/hooks/useExpanderCell.js +10 -6
- package/esm/core/Tabs/Tabs.d.ts +4 -1
- package/esm/core/Tag/Tag.js +11 -3
- package/esm/core/ThemeProvider/ThemeContext.d.ts +1 -2
- package/esm/core/ThemeProvider/ThemeProvider.d.ts +8 -18
- package/esm/core/ThemeProvider/ThemeProvider.js +48 -42
- package/esm/core/ToggleSwitch/ToggleSwitch.d.ts +21 -0
- package/esm/core/ToggleSwitch/ToggleSwitch.js +15 -5
- package/esm/styles.js +1 -1
- package/esm/utils/components/index.d.ts +1 -1
- package/esm/utils/components/index.js +1 -1
- package/esm/utils/components/lineClamp.d.ts +5 -0
- package/esm/utils/components/lineClamp.js +13 -0
- package/esm/utils/functions/react.d.ts +5 -0
- package/esm/utils/functions/react.js +6 -1
- package/esm/utils/hooks/useControlledState.d.ts +5 -2
- package/esm/utils/hooks/useControlledState.js +5 -1
- package/esm/utils/hooks/useGlobals.d.ts +0 -1
- package/esm/utils/providers/FutureFlagsProvider.d.ts +37 -0
- package/esm/utils/providers/FutureFlagsProvider.js +28 -0
- package/esm/utils/providers/index.d.ts +1 -0
- package/esm/utils/providers/index.js +1 -0
- package/package.json +11 -5
- package/styles.css +10 -10
- package/DEV-cjs/utils/components/LineClamp.js +0 -50
- package/DEV-esm/utils/components/LineClamp.js +0 -36
- package/cjs/utils/components/LineClamp.d.ts +0 -5
- package/cjs/utils/components/LineClamp.js +0 -50
- package/esm/utils/components/LineClamp.d.ts +0 -5
- package/esm/utils/components/LineClamp.js +0 -36
package/DEV-esm/core/Tag/Tag.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import cx from 'classnames';
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
SvgCloseSmall,
|
|
5
|
+
Box,
|
|
6
|
+
ButtonBase,
|
|
7
|
+
mergeEventHandlers,
|
|
8
|
+
} from '../../utils/index.js';
|
|
4
9
|
import { IconButton } from '../Buttons/IconButton.js';
|
|
5
10
|
import { LinkAction, LinkBox } from '../LinkAction/LinkAction.js';
|
|
6
11
|
export const Tag = React.forwardRef((props, forwardedRef) => {
|
|
@@ -35,8 +40,11 @@ export const Tag = React.forwardRef((props, forwardedRef) => {
|
|
|
35
40
|
Box,
|
|
36
41
|
{
|
|
37
42
|
as: shouldUseLinkAction ? LinkAction : 'span',
|
|
38
|
-
onClick: shouldUseLinkAction ? onClick : void 0,
|
|
39
43
|
...labelProps,
|
|
44
|
+
onClick: mergeEventHandlers(
|
|
45
|
+
labelProps?.onClick,
|
|
46
|
+
shouldUseLinkAction ? onClick : void 0,
|
|
47
|
+
),
|
|
40
48
|
className: cx('iui-tag-label', labelProps?.className),
|
|
41
49
|
},
|
|
42
50
|
children,
|
|
@@ -48,9 +56,9 @@ export const Tag = React.forwardRef((props, forwardedRef) => {
|
|
|
48
56
|
{
|
|
49
57
|
styleType: 'borderless',
|
|
50
58
|
size: 'small',
|
|
51
|
-
onClick: onRemove,
|
|
52
59
|
'aria-label': 'Delete tag',
|
|
53
60
|
...removeButtonProps,
|
|
61
|
+
onClick: mergeEventHandlers(removeButtonProps?.onClick, onRemove),
|
|
54
62
|
className: cx('iui-tag-button', removeButtonProps?.className),
|
|
55
63
|
},
|
|
56
64
|
React.createElement(SvgCloseSmall, {
|
|
@@ -13,6 +13,8 @@ import {
|
|
|
13
13
|
useHydration,
|
|
14
14
|
PortalContainerContext,
|
|
15
15
|
useId,
|
|
16
|
+
FutureFlagsProvider,
|
|
17
|
+
useFutureFlag,
|
|
16
18
|
} from '../../utils/index.js';
|
|
17
19
|
import { ThemeContext } from './ThemeContext.js';
|
|
18
20
|
import { ToastProvider, Toaster } from '../Toast/Toaster.js';
|
|
@@ -20,14 +22,14 @@ import { meta } from '../../utils/meta.js';
|
|
|
20
22
|
let versionWithoutDots = meta.version.replace(/\./g, '');
|
|
21
23
|
let OwnerDocumentContext = React.createContext(void 0);
|
|
22
24
|
export const ThemeProvider = React.forwardRef((props, forwardedRef) => {
|
|
23
|
-
var _themeOptions, _themeOptions1
|
|
25
|
+
var _themeOptions, _themeOptions1;
|
|
24
26
|
let {
|
|
25
27
|
theme: themeProp = 'inherit',
|
|
26
28
|
children,
|
|
27
29
|
themeOptions = {},
|
|
28
30
|
portalContainer: portalContainerProp,
|
|
29
31
|
includeCss = 'inherit' === themeProp,
|
|
30
|
-
future = {},
|
|
32
|
+
future: futureProp = {},
|
|
31
33
|
...rest
|
|
32
34
|
} = props;
|
|
33
35
|
useInertPolyfill();
|
|
@@ -39,62 +41,67 @@ export const ThemeProvider = React.forwardRef((props, forwardedRef) => {
|
|
|
39
41
|
(_themeOptions1 = themeOptions).highContrast ??
|
|
40
42
|
(_themeOptions1.highContrast =
|
|
41
43
|
'inherit' === themeProp ? parent.highContrast : void 0);
|
|
42
|
-
(_future = future).themeBridge ??
|
|
43
|
-
(_future.themeBridge = parent.context?.future?.themeBridge);
|
|
44
44
|
let portalContainerFromParent = React.useContext(PortalContainerContext);
|
|
45
|
-
let
|
|
45
|
+
let themeContextValue = React.useMemo(
|
|
46
46
|
() => ({
|
|
47
47
|
theme,
|
|
48
48
|
themeOptions,
|
|
49
|
-
future,
|
|
50
49
|
}),
|
|
51
|
-
[theme, JSON.stringify(themeOptions)
|
|
50
|
+
[theme, JSON.stringify(themeOptions)],
|
|
52
51
|
);
|
|
53
52
|
let [portalContainer, setPortalContainer] = React.useState(
|
|
54
53
|
portalContainerProp || null,
|
|
55
54
|
);
|
|
56
55
|
return React.createElement(
|
|
57
|
-
|
|
56
|
+
FutureFlagsProvider,
|
|
58
57
|
{
|
|
59
|
-
value:
|
|
58
|
+
value: futureProp,
|
|
60
59
|
},
|
|
61
60
|
React.createElement(
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
PortalContainerContext.Provider,
|
|
62
|
+
{
|
|
63
|
+
value: portalContainer,
|
|
64
|
+
},
|
|
64
65
|
React.createElement(
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
value: contextValue,
|
|
68
|
-
},
|
|
66
|
+
HydrationProvider,
|
|
67
|
+
null,
|
|
69
68
|
React.createElement(
|
|
70
|
-
|
|
69
|
+
ThemeContext.Provider,
|
|
71
70
|
{
|
|
72
|
-
|
|
71
|
+
value: themeContextValue,
|
|
73
72
|
},
|
|
74
|
-
includeCss && rootElement
|
|
75
|
-
? React.createElement(FallbackStyles, {
|
|
76
|
-
root: rootElement,
|
|
77
|
-
})
|
|
78
|
-
: null,
|
|
79
73
|
React.createElement(
|
|
80
|
-
|
|
74
|
+
ToastProvider,
|
|
81
75
|
{
|
|
82
|
-
|
|
83
|
-
themeOptions: themeOptions,
|
|
84
|
-
future: future,
|
|
85
|
-
ref: useMergedRefs(forwardedRef, setRootElement, useIuiDebugRef),
|
|
86
|
-
...rest,
|
|
76
|
+
inherit: 'inherit' === themeProp && !portalContainerProp,
|
|
87
77
|
},
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
78
|
+
includeCss && rootElement
|
|
79
|
+
? React.createElement(FallbackStyles, {
|
|
80
|
+
root: rootElement,
|
|
81
|
+
})
|
|
82
|
+
: null,
|
|
83
|
+
React.createElement(
|
|
84
|
+
MainRoot,
|
|
85
|
+
{
|
|
86
|
+
theme: theme,
|
|
87
|
+
themeOptions: themeOptions,
|
|
88
|
+
ref: useMergedRefs(
|
|
89
|
+
forwardedRef,
|
|
90
|
+
setRootElement,
|
|
91
|
+
useIuiDebugRef,
|
|
92
|
+
),
|
|
93
|
+
...rest,
|
|
94
|
+
},
|
|
95
|
+
children,
|
|
96
|
+
React.createElement(PortalContainer, {
|
|
97
|
+
theme: theme,
|
|
98
|
+
themeOptions: themeOptions,
|
|
99
|
+
portalContainerProp: portalContainerProp,
|
|
100
|
+
portalContainerFromParent: portalContainerFromParent,
|
|
101
|
+
setPortalContainer: setPortalContainer,
|
|
102
|
+
isInheritingTheme: 'inherit' === themeProp,
|
|
103
|
+
}),
|
|
104
|
+
),
|
|
98
105
|
),
|
|
99
106
|
),
|
|
100
107
|
),
|
|
@@ -124,12 +131,13 @@ let MainRoot = React.forwardRef((props, forwardedRef) => {
|
|
|
124
131
|
);
|
|
125
132
|
});
|
|
126
133
|
let Root = React.forwardRef((props, forwardedRef) => {
|
|
127
|
-
let { theme, children, themeOptions, className,
|
|
134
|
+
let { theme, children, themeOptions, className, ...rest } = props;
|
|
128
135
|
let prefersDark = useMediaQuery('(prefers-color-scheme: dark)');
|
|
129
136
|
let prefersHighContrast = useMediaQuery('(prefers-contrast: more)');
|
|
130
137
|
let shouldApplyDark = 'dark' === theme || ('os' === theme && prefersDark);
|
|
131
138
|
let shouldApplyHC = themeOptions?.highContrast ?? prefersHighContrast;
|
|
132
139
|
let shouldApplyBackground = themeOptions?.applyBackground;
|
|
140
|
+
let themeBridge = useFutureFlag('themeBridge');
|
|
133
141
|
return React.createElement(
|
|
134
142
|
Box,
|
|
135
143
|
{
|
|
@@ -142,7 +150,7 @@ let Root = React.forwardRef((props, forwardedRef) => {
|
|
|
142
150
|
),
|
|
143
151
|
'data-iui-theme': shouldApplyDark ? 'dark' : 'light',
|
|
144
152
|
'data-iui-contrast': shouldApplyHC ? 'high' : 'default',
|
|
145
|
-
'data-iui-bridge':
|
|
153
|
+
'data-iui-bridge': themeBridge ? 'true' : void 0,
|
|
146
154
|
ref: forwardedRef,
|
|
147
155
|
...rest,
|
|
148
156
|
},
|
|
@@ -191,7 +199,6 @@ let PortalContainer = React.memo(
|
|
|
191
199
|
isInheritingTheme,
|
|
192
200
|
theme,
|
|
193
201
|
themeOptions,
|
|
194
|
-
future,
|
|
195
202
|
}) => {
|
|
196
203
|
let ownerDocument = React.useContext(OwnerDocumentContext);
|
|
197
204
|
let shouldSetupPortalContainer =
|
|
@@ -223,7 +230,6 @@ let PortalContainer = React.memo(
|
|
|
223
230
|
...themeOptions,
|
|
224
231
|
applyBackground: false,
|
|
225
232
|
},
|
|
226
|
-
future: future,
|
|
227
233
|
'data-iui-portal': true,
|
|
228
234
|
style: {
|
|
229
235
|
display: 'contents',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import cx from 'classnames';
|
|
3
|
-
import { Box, SvgCheckmark } from '../../utils/index.js';
|
|
3
|
+
import { Box, SvgCheckmark, useFutureFlag } from '../../utils/index.js';
|
|
4
4
|
export const ToggleSwitch = React.forwardRef((props, ref) => {
|
|
5
5
|
let {
|
|
6
6
|
disabled = false,
|
|
@@ -10,15 +10,21 @@ export const ToggleSwitch = React.forwardRef((props, ref) => {
|
|
|
10
10
|
style,
|
|
11
11
|
size = 'default',
|
|
12
12
|
labelProps = {},
|
|
13
|
+
wrapperProps,
|
|
13
14
|
icon: iconProp,
|
|
14
15
|
...rest
|
|
15
16
|
} = props;
|
|
17
|
+
let { consistentPropsSpread } = useFutureFlag('ToggleSwitch') || {};
|
|
18
|
+
let shouldApplyClassNameAndStyleOnInput =
|
|
19
|
+
null != wrapperProps || consistentPropsSpread;
|
|
16
20
|
let shouldShowIcon =
|
|
17
21
|
void 0 === iconProp || (null !== iconProp && 'small' !== size);
|
|
18
22
|
return React.createElement(
|
|
19
23
|
Box,
|
|
20
24
|
{
|
|
21
25
|
as: label ? 'label' : 'div',
|
|
26
|
+
style: shouldApplyClassNameAndStyleOnInput ? void 0 : style,
|
|
27
|
+
...wrapperProps,
|
|
22
28
|
className: cx(
|
|
23
29
|
'iui-toggle-switch-wrapper',
|
|
24
30
|
{
|
|
@@ -26,19 +32,23 @@ export const ToggleSwitch = React.forwardRef((props, ref) => {
|
|
|
26
32
|
'iui-label-on-right': label && 'right' === labelPosition,
|
|
27
33
|
'iui-label-on-left': label && 'left' === labelPosition,
|
|
28
34
|
},
|
|
29
|
-
className,
|
|
35
|
+
shouldApplyClassNameAndStyleOnInput ? void 0 : className,
|
|
36
|
+
wrapperProps?.className,
|
|
30
37
|
),
|
|
31
38
|
'data-iui-size': size,
|
|
32
|
-
style: style,
|
|
33
39
|
},
|
|
34
40
|
React.createElement(Box, {
|
|
35
41
|
as: 'input',
|
|
36
|
-
className: 'iui-toggle-switch',
|
|
37
42
|
type: 'checkbox',
|
|
38
43
|
role: 'switch',
|
|
44
|
+
style: shouldApplyClassNameAndStyleOnInput ? style : void 0,
|
|
45
|
+
...rest,
|
|
46
|
+
className: cx(
|
|
47
|
+
'iui-toggle-switch',
|
|
48
|
+
shouldApplyClassNameAndStyleOnInput ? className : void 0,
|
|
49
|
+
),
|
|
39
50
|
disabled: disabled,
|
|
40
51
|
ref: ref,
|
|
41
|
-
...rest,
|
|
42
52
|
}),
|
|
43
53
|
shouldShowIcon &&
|
|
44
54
|
React.createElement(
|
package/DEV-esm/styles.js
CHANGED
|
@@ -9,6 +9,6 @@ export * from './Box.js';
|
|
|
9
9
|
export * from './ButtonBase.js';
|
|
10
10
|
export * from './Portal.js';
|
|
11
11
|
export * from './ShadowRoot.js';
|
|
12
|
-
export * from './
|
|
12
|
+
export * from './lineClamp.js';
|
|
13
13
|
export * from './FieldsetBase.js';
|
|
14
14
|
export * from './OverflowContainer.js';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
let className = '_iui-line-clamp';
|
|
2
|
+
let css = `
|
|
3
|
+
.${className} {
|
|
4
|
+
overflow: hidden;
|
|
5
|
+
display: -webkit-box;
|
|
6
|
+
-webkit-line-clamp: var(--_iui-line-clamp, 3);
|
|
7
|
+
-webkit-box-orient: vertical;
|
|
8
|
+
}
|
|
9
|
+
`;
|
|
10
|
+
export const lineClamp = {
|
|
11
|
+
css,
|
|
12
|
+
className,
|
|
13
|
+
};
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { mergeRefs } from '../hooks/useMergedRefs.js';
|
|
3
|
+
let _React = React;
|
|
4
|
+
export const isReact17or18 = (() => {
|
|
5
|
+
let version = _React.version?.split('.')?.[0];
|
|
6
|
+
return ['17', '18'].includes(version);
|
|
7
|
+
})();
|
|
3
8
|
export const cloneElementWithRef = (children, getProps) => {
|
|
4
9
|
if (!children) return null;
|
|
5
10
|
if (!React.isValidElement(children)) return children;
|
|
6
|
-
let childrenRef = children
|
|
11
|
+
let childrenRef = isReact17or18 ? children?.ref : children.props?.ref;
|
|
7
12
|
let props = getProps(children);
|
|
8
13
|
let ref = mergeRefs(
|
|
9
14
|
...[childrenRef, 'ref' in props ? props.ref : null].filter(Boolean),
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { useLatestRef } from './useLatestRef.js';
|
|
2
3
|
export const useControlledState = (
|
|
3
4
|
initialValue,
|
|
4
5
|
controlledState,
|
|
@@ -9,12 +10,15 @@ export const useControlledState = (
|
|
|
9
10
|
() => (void 0 !== controlledState ? controlledState : uncontrolledState),
|
|
10
11
|
[controlledState, uncontrolledState],
|
|
11
12
|
);
|
|
13
|
+
let oldState = useLatestRef(state);
|
|
12
14
|
let setState = React.useCallback(
|
|
13
15
|
(value) => {
|
|
16
|
+
if (value === oldState.current) return;
|
|
17
|
+
oldState.current = value;
|
|
14
18
|
setUncontrolledState(value);
|
|
15
19
|
setControlledState?.(value);
|
|
16
20
|
},
|
|
17
|
-
[
|
|
21
|
+
[oldState, setControlledState],
|
|
18
22
|
);
|
|
19
23
|
return [state, setState];
|
|
20
24
|
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useSafeContext } from '../hooks/useSafeContext.js';
|
|
3
|
+
let FutureFlagsContext = React.createContext({});
|
|
4
|
+
export function useFutureFlag(key) {
|
|
5
|
+
let context = useSafeContext(FutureFlagsContext);
|
|
6
|
+
return context[key];
|
|
7
|
+
}
|
|
8
|
+
export const FutureFlagsProvider = ({ children, value }) => {
|
|
9
|
+
if (true === value)
|
|
10
|
+
value = {
|
|
11
|
+
themeBridge: true,
|
|
12
|
+
};
|
|
13
|
+
let context = React.useContext(FutureFlagsContext);
|
|
14
|
+
let combinedValue = {
|
|
15
|
+
...context,
|
|
16
|
+
...value,
|
|
17
|
+
};
|
|
18
|
+
return React.createElement(
|
|
19
|
+
FutureFlagsContext.Provider,
|
|
20
|
+
{
|
|
21
|
+
value: React.useMemo(
|
|
22
|
+
() => combinedValue,
|
|
23
|
+
[JSON.stringify(combinedValue)],
|
|
24
|
+
),
|
|
25
|
+
},
|
|
26
|
+
children,
|
|
27
|
+
);
|
|
28
|
+
};
|
|
@@ -8,7 +8,7 @@ export type DropdownButtonProps = {
|
|
|
8
8
|
* Pass a function that takes the `close` argument (to close the menu),
|
|
9
9
|
* and returns a list of `MenuItem` components.
|
|
10
10
|
*/
|
|
11
|
-
menuItems: (close: () => void) => React.JSX.Element[];
|
|
11
|
+
menuItems: ((close: () => void) => React.JSX.Element[]) | React.JSX.Element[] | React.JSX.Element;
|
|
12
12
|
/**
|
|
13
13
|
* Style of the dropdown button.
|
|
14
14
|
* Use 'borderless' to hide outline.
|
|
@@ -1,20 +1,9 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
disabled?: boolean;
|
|
5
|
-
value?: unknown;
|
|
6
|
-
onClick?: (value?: unknown) => void;
|
|
7
|
-
size?: "default" | "large";
|
|
8
|
-
sublabel?: React.ReactNode;
|
|
9
|
-
startIcon?: React.JSX.Element;
|
|
10
|
-
icon?: React.JSX.Element;
|
|
11
|
-
endIcon?: React.JSX.Element;
|
|
12
|
-
badge?: React.JSX.Element;
|
|
13
|
-
role?: string;
|
|
14
|
-
subMenuItems?: React.JSX.Element[];
|
|
15
|
-
children?: React.ReactNode;
|
|
16
|
-
} & Pick<import("../List/ListItem.js").ListItemOwnProps, "focused"> & {
|
|
2
|
+
import type { MenuItemProps } from '../Menu/MenuItem.js';
|
|
3
|
+
type ComboBoxMenuItemProps = MenuItemProps & {
|
|
17
4
|
index: number;
|
|
18
|
-
}
|
|
5
|
+
};
|
|
6
|
+
export declare const ComboBoxMenuItem: React.NamedExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "children" | "as" | "role" | "onClick" | "size" | "icon" | "disabled" | "value" | "startIcon" | "endIcon" | "index" | "focused" | "isSelected" | "sublabel" | "badge" | "subMenuItems"> & ComboBoxMenuItemProps & {
|
|
19
7
|
as?: "div" | undefined;
|
|
20
8
|
}>;
|
|
9
|
+
export {};
|
|
@@ -49,7 +49,7 @@ const ComboBoxMenuItem = _react.memo(
|
|
|
49
49
|
disabled: disabled,
|
|
50
50
|
focused: focusedIndex === index,
|
|
51
51
|
ref: refs,
|
|
52
|
-
onClick: () => onClick?.(
|
|
52
|
+
onClick: () => onClick?.(),
|
|
53
53
|
role: role,
|
|
54
54
|
tabIndex: 'presentation' === role ? void 0 : -1,
|
|
55
55
|
'aria-selected': isSelected,
|
|
@@ -10,14 +10,20 @@ export type MenuItemProps = {
|
|
|
10
10
|
* Item is disabled.
|
|
11
11
|
*/
|
|
12
12
|
disabled?: boolean;
|
|
13
|
+
} & ({
|
|
13
14
|
/**
|
|
14
15
|
* Value of the item.
|
|
16
|
+
* @deprecated
|
|
15
17
|
*/
|
|
16
|
-
value
|
|
18
|
+
value: unknown;
|
|
17
19
|
/**
|
|
18
20
|
* Callback function that handles click and keyboard submit actions.
|
|
19
21
|
*/
|
|
20
22
|
onClick?: (value?: unknown) => void;
|
|
23
|
+
} | {
|
|
24
|
+
/** @deprecated */ value?: never;
|
|
25
|
+
onClick?: (event?: React.MouseEvent) => void;
|
|
26
|
+
}) & {
|
|
21
27
|
/**
|
|
22
28
|
* Modify height of the item.
|
|
23
29
|
* Use 'large' when any of the sibling items have `sublabel`.
|
|
@@ -70,13 +70,10 @@ const MenuItem = _react.forwardRef((props, forwardedRef) => {
|
|
|
70
70
|
}),
|
|
71
71
|
[hasSubMenu],
|
|
72
72
|
);
|
|
73
|
-
let onClick = () => {
|
|
73
|
+
let onClick = (event) => {
|
|
74
74
|
if (disabled) return;
|
|
75
75
|
if (shouldCloseMenuOnClick) dropdownMenu?.close();
|
|
76
|
-
onClickProp?.(value);
|
|
77
|
-
};
|
|
78
|
-
let handlers = {
|
|
79
|
-
onClick,
|
|
76
|
+
onClickProp?.(value ?? event);
|
|
80
77
|
};
|
|
81
78
|
let focusableItemIndex = parentMenu?.focusableElements.findIndex(
|
|
82
79
|
(el) => el === menuItemRef.current,
|
|
@@ -101,9 +98,13 @@ const MenuItem = _react.forwardRef((props, forwardedRef) => {
|
|
|
101
98
|
...(parentMenu?.popoverGetItemProps != null
|
|
102
99
|
? parentMenu.popoverGetItemProps({
|
|
103
100
|
focusableItemIndex,
|
|
104
|
-
userProps:
|
|
101
|
+
userProps: {
|
|
102
|
+
onClick,
|
|
103
|
+
},
|
|
105
104
|
})
|
|
106
|
-
:
|
|
105
|
+
: {
|
|
106
|
+
onClick,
|
|
107
|
+
}),
|
|
107
108
|
...rest,
|
|
108
109
|
},
|
|
109
110
|
startIcon &&
|
|
@@ -14,8 +14,10 @@ type PopoverOptions = {
|
|
|
14
14
|
*/
|
|
15
15
|
visible?: boolean;
|
|
16
16
|
/**
|
|
17
|
-
* Callback invoked every time the popover visibility changes
|
|
18
|
-
*
|
|
17
|
+
* Callback invoked every time the popover visibility *changes* (uncontrolled mode) or should *change*
|
|
18
|
+
* (controlled mode) as a result of internal logic.
|
|
19
|
+
*
|
|
20
|
+
* Should be used alongside `visible` prop.
|
|
19
21
|
*/
|
|
20
22
|
onVisibleChange?: (visible: boolean) => void;
|
|
21
23
|
/**
|
|
@@ -147,7 +149,7 @@ export declare const usePopover: (options: PopoverOptions & PopoverInternalProps
|
|
|
147
149
|
elements: import("@floating-ui/react").ExtendedElements<import("@floating-ui/react").ReferenceType>;
|
|
148
150
|
};
|
|
149
151
|
open: boolean;
|
|
150
|
-
onOpenChange:
|
|
152
|
+
onOpenChange: (value: boolean) => void;
|
|
151
153
|
getReferenceProps: (userProps?: React.HTMLProps<HTMLElement>) => Record<string, unknown>;
|
|
152
154
|
getFloatingProps: (userProps?: React.HTMLProps<HTMLElement>) => Record<string, unknown>;
|
|
153
155
|
};
|
|
@@ -183,7 +183,13 @@ const CustomSelect = _react.forwardRef((props, forwardedRef) => {
|
|
|
183
183
|
isSelected,
|
|
184
184
|
})
|
|
185
185
|
: _react.createElement(_MenuItem.MenuItem, null, option.label);
|
|
186
|
-
let {
|
|
186
|
+
let {
|
|
187
|
+
label,
|
|
188
|
+
icon,
|
|
189
|
+
startIcon: startIconProp,
|
|
190
|
+
value: _,
|
|
191
|
+
...restOption
|
|
192
|
+
} = option;
|
|
187
193
|
let startIcon = startIconProp ?? icon;
|
|
188
194
|
return _react.cloneElement(menuItem, {
|
|
189
195
|
key: `${label}-${index}`,
|
|
@@ -467,15 +473,17 @@ const SelectListbox = _react.forwardRef((props, forwardedRef) => {
|
|
|
467
473
|
}, []);
|
|
468
474
|
let children = _react.useMemo(
|
|
469
475
|
() =>
|
|
470
|
-
_react.Children.map(childrenProp, (child, index) =>
|
|
471
|
-
_react.isValidElement(child)
|
|
472
|
-
?
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
476
|
+
_react.Children.map(childrenProp, (child, index) => {
|
|
477
|
+
if (_react.isValidElement(child)) {
|
|
478
|
+
let ref = _index.isReact17or18 ? child.ref : child.props.ref;
|
|
479
|
+
return _react.createElement(_react1.CompositeItem, {
|
|
480
|
+
key: index,
|
|
481
|
+
ref: ref,
|
|
482
|
+
render: child,
|
|
483
|
+
});
|
|
484
|
+
}
|
|
485
|
+
return child;
|
|
486
|
+
}),
|
|
479
487
|
[childrenProp],
|
|
480
488
|
);
|
|
481
489
|
return _react.createElement(
|
|
@@ -56,9 +56,9 @@ const SideNavigation = _react.forwardRef((props, forwardedRef) => {
|
|
|
56
56
|
className: 'iui-sidenav-button iui-expand',
|
|
57
57
|
size: 'small',
|
|
58
58
|
onClick: _react.useCallback(() => {
|
|
59
|
-
setIsExpanded(
|
|
59
|
+
setIsExpanded(!isExpanded);
|
|
60
60
|
onExpanderClick?.();
|
|
61
|
-
}, [onExpanderClick, setIsExpanded]),
|
|
61
|
+
}, [isExpanded, onExpanderClick, setIsExpanded]),
|
|
62
62
|
},
|
|
63
63
|
_react.createElement(_index.SvgChevronRight, null),
|
|
64
64
|
);
|
|
@@ -105,10 +105,14 @@ const ColumnHeader = _react.forwardRef((props, forwardedRef) => {
|
|
|
105
105
|
'string' == typeof column.Header
|
|
106
106
|
? _react.createElement(
|
|
107
107
|
_index.ShadowRoot,
|
|
108
|
-
|
|
108
|
+
{
|
|
109
|
+
css: _index.lineClamp.css,
|
|
110
|
+
},
|
|
109
111
|
_react.createElement(
|
|
110
|
-
|
|
111
|
-
|
|
112
|
+
'div',
|
|
113
|
+
{
|
|
114
|
+
className: _index.lineClamp.className,
|
|
115
|
+
},
|
|
112
116
|
_react.createElement('slot', null),
|
|
113
117
|
),
|
|
114
118
|
_react.createElement('slot', {
|
|
@@ -206,8 +206,8 @@ export type TableProps<T extends Record<string, unknown> = Record<string, unknow
|
|
|
206
206
|
/**
|
|
207
207
|
* Passes props to the `role="table"` element within the wrapper.
|
|
208
208
|
*
|
|
209
|
-
* If `tableProps` or `role` is passed to `Table`, all ARIA attributes passed to `Table` will be passed to the wrapper.
|
|
210
|
-
* Else, all ARIA attributes will be passed to the inner element with `role="table"`.
|
|
209
|
+
* - If `tableProps` or `role` is passed to `Table`, all ARIA attributes passed to `Table` will be passed to the wrapper.
|
|
210
|
+
* - Else, all ARIA attributes will be passed to the inner element with `role="table"`.
|
|
211
211
|
*/
|
|
212
212
|
tableProps?: React.ComponentProps<'div'>;
|
|
213
213
|
/**
|