@itwin/itwinui-react 3.16.3 → 3.17.0-dev.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DEV-cjs/core/ThemeProvider/ThemeProvider.js +13 -3
- package/DEV-cjs/styles.js +1 -1
- package/DEV-esm/core/ThemeProvider/ThemeProvider.js +13 -3
- package/DEV-esm/styles.js +1 -1
- package/cjs/core/ThemeProvider/ThemeContext.d.ts +2 -1
- package/cjs/core/ThemeProvider/ThemeProvider.d.ts +17 -3
- package/cjs/core/ThemeProvider/ThemeProvider.js +13 -3
- package/cjs/styles.js +1 -1
- package/cjs/utils/hooks/useGlobals.d.ts +1 -0
- package/esm/core/ThemeProvider/ThemeContext.d.ts +2 -1
- package/esm/core/ThemeProvider/ThemeProvider.d.ts +17 -3
- package/esm/core/ThemeProvider/ThemeProvider.js +13 -3
- package/esm/styles.js +1 -1
- package/esm/utils/hooks/useGlobals.d.ts +1 -0
- package/package.json +27 -27
- package/styles.css +11 -9
|
@@ -21,13 +21,14 @@ const _meta = require('../../utils/meta.js');
|
|
|
21
21
|
const versionWithoutDots = _meta.meta.version.replace(/\./g, '');
|
|
22
22
|
const ownerDocumentAtom = (0, _jotai.atom)(void 0);
|
|
23
23
|
const ThemeProvider = _react.forwardRef((props, forwardedRef) => {
|
|
24
|
-
var _themeOptions, _themeOptions1;
|
|
24
|
+
var _themeOptions, _themeOptions1, _future;
|
|
25
25
|
let {
|
|
26
26
|
theme: themeProp = 'inherit',
|
|
27
27
|
children,
|
|
28
28
|
themeOptions = {},
|
|
29
29
|
portalContainer: portalContainerProp,
|
|
30
30
|
includeCss = 'inherit' === themeProp,
|
|
31
|
+
future = {},
|
|
31
32
|
...rest
|
|
32
33
|
} = props;
|
|
33
34
|
useInertPolyfill();
|
|
@@ -39,6 +40,9 @@ const ThemeProvider = _react.forwardRef((props, forwardedRef) => {
|
|
|
39
40
|
(_themeOptions1 = themeOptions).highContrast ??
|
|
40
41
|
(_themeOptions1.highContrast =
|
|
41
42
|
'inherit' === themeProp ? parent.highContrast : void 0);
|
|
43
|
+
(_future = future).themeBridge ??
|
|
44
|
+
(_future.themeBridge =
|
|
45
|
+
'inherit' === themeProp ? parent.context?.future?.themeBridge : void 0);
|
|
42
46
|
let [portalContainerFromParent] = (0, _index.useScopedAtom)(
|
|
43
47
|
_index.portalContainerAtom,
|
|
44
48
|
);
|
|
@@ -46,8 +50,9 @@ const ThemeProvider = _react.forwardRef((props, forwardedRef) => {
|
|
|
46
50
|
() => ({
|
|
47
51
|
theme,
|
|
48
52
|
themeOptions,
|
|
53
|
+
future,
|
|
49
54
|
}),
|
|
50
|
-
[theme, JSON.stringify(themeOptions)],
|
|
55
|
+
[theme, JSON.stringify(themeOptions), JSON.stringify(future)],
|
|
51
56
|
);
|
|
52
57
|
return _react.createElement(
|
|
53
58
|
_index.ScopeProvider,
|
|
@@ -75,6 +80,7 @@ const ThemeProvider = _react.forwardRef((props, forwardedRef) => {
|
|
|
75
80
|
{
|
|
76
81
|
theme: theme,
|
|
77
82
|
themeOptions: themeOptions,
|
|
83
|
+
future: future,
|
|
78
84
|
ref: (0, _index.useMergedRefs)(
|
|
79
85
|
forwardedRef,
|
|
80
86
|
setRootElement,
|
|
@@ -86,6 +92,7 @@ const ThemeProvider = _react.forwardRef((props, forwardedRef) => {
|
|
|
86
92
|
_react.createElement(PortalContainer, {
|
|
87
93
|
theme: theme,
|
|
88
94
|
themeOptions: themeOptions,
|
|
95
|
+
future: future,
|
|
89
96
|
portalContainerProp: portalContainerProp,
|
|
90
97
|
portalContainerFromParent: portalContainerFromParent,
|
|
91
98
|
isInheritingTheme: 'inherit' === themeProp,
|
|
@@ -114,7 +121,7 @@ const MainRoot = _react.forwardRef((props, forwardedRef) => {
|
|
|
114
121
|
});
|
|
115
122
|
});
|
|
116
123
|
const Root = _react.forwardRef((props, forwardedRef) => {
|
|
117
|
-
let { theme, children, themeOptions, className, ...rest } = props;
|
|
124
|
+
let { theme, children, themeOptions, className, future, ...rest } = props;
|
|
118
125
|
let prefersDark = (0, _index.useMediaQuery)('(prefers-color-scheme: dark)');
|
|
119
126
|
let prefersHighContrast = (0, _index.useMediaQuery)(
|
|
120
127
|
'(prefers-contrast: more)',
|
|
@@ -134,6 +141,7 @@ const Root = _react.forwardRef((props, forwardedRef) => {
|
|
|
134
141
|
),
|
|
135
142
|
'data-iui-theme': shouldApplyDark ? 'dark' : 'light',
|
|
136
143
|
'data-iui-contrast': shouldApplyHC ? 'high' : 'default',
|
|
144
|
+
'data-iui-bridge': !!future?.themeBridge || void 0,
|
|
137
145
|
ref: forwardedRef,
|
|
138
146
|
...rest,
|
|
139
147
|
},
|
|
@@ -183,6 +191,7 @@ const PortalContainer = _react.memo(
|
|
|
183
191
|
isInheritingTheme,
|
|
184
192
|
theme,
|
|
185
193
|
themeOptions,
|
|
194
|
+
future,
|
|
186
195
|
}) => {
|
|
187
196
|
let [ownerDocument] = (0, _index.useScopedAtom)(ownerDocumentAtom);
|
|
188
197
|
let [portalContainer, setPortalContainer] = (0, _index.useScopedAtom)(
|
|
@@ -213,6 +222,7 @@ const PortalContainer = _react.memo(
|
|
|
213
222
|
...themeOptions,
|
|
214
223
|
applyBackground: false,
|
|
215
224
|
},
|
|
225
|
+
future: future,
|
|
216
226
|
'data-iui-portal': true,
|
|
217
227
|
style: {
|
|
218
228
|
display: 'contents',
|
package/DEV-cjs/styles.js
CHANGED
|
@@ -23,13 +23,14 @@ import { meta } from '../../utils/meta.js';
|
|
|
23
23
|
let versionWithoutDots = meta.version.replace(/\./g, '');
|
|
24
24
|
let ownerDocumentAtom = atom(void 0);
|
|
25
25
|
export const ThemeProvider = React.forwardRef((props, forwardedRef) => {
|
|
26
|
-
var _themeOptions, _themeOptions1;
|
|
26
|
+
var _themeOptions, _themeOptions1, _future;
|
|
27
27
|
let {
|
|
28
28
|
theme: themeProp = 'inherit',
|
|
29
29
|
children,
|
|
30
30
|
themeOptions = {},
|
|
31
31
|
portalContainer: portalContainerProp,
|
|
32
32
|
includeCss = 'inherit' === themeProp,
|
|
33
|
+
future = {},
|
|
33
34
|
...rest
|
|
34
35
|
} = props;
|
|
35
36
|
useInertPolyfill();
|
|
@@ -41,13 +42,17 @@ export const ThemeProvider = React.forwardRef((props, forwardedRef) => {
|
|
|
41
42
|
(_themeOptions1 = themeOptions).highContrast ??
|
|
42
43
|
(_themeOptions1.highContrast =
|
|
43
44
|
'inherit' === themeProp ? parent.highContrast : void 0);
|
|
45
|
+
(_future = future).themeBridge ??
|
|
46
|
+
(_future.themeBridge =
|
|
47
|
+
'inherit' === themeProp ? parent.context?.future?.themeBridge : void 0);
|
|
44
48
|
let [portalContainerFromParent] = useScopedAtom(portalContainerAtom);
|
|
45
49
|
let contextValue = React.useMemo(
|
|
46
50
|
() => ({
|
|
47
51
|
theme,
|
|
48
52
|
themeOptions,
|
|
53
|
+
future,
|
|
49
54
|
}),
|
|
50
|
-
[theme, JSON.stringify(themeOptions)],
|
|
55
|
+
[theme, JSON.stringify(themeOptions), JSON.stringify(future)],
|
|
51
56
|
);
|
|
52
57
|
return React.createElement(
|
|
53
58
|
ScopeProvider,
|
|
@@ -75,6 +80,7 @@ export const ThemeProvider = React.forwardRef((props, forwardedRef) => {
|
|
|
75
80
|
{
|
|
76
81
|
theme: theme,
|
|
77
82
|
themeOptions: themeOptions,
|
|
83
|
+
future: future,
|
|
78
84
|
ref: useMergedRefs(forwardedRef, setRootElement, useIuiDebugRef),
|
|
79
85
|
...rest,
|
|
80
86
|
},
|
|
@@ -82,6 +88,7 @@ export const ThemeProvider = React.forwardRef((props, forwardedRef) => {
|
|
|
82
88
|
React.createElement(PortalContainer, {
|
|
83
89
|
theme: theme,
|
|
84
90
|
themeOptions: themeOptions,
|
|
91
|
+
future: future,
|
|
85
92
|
portalContainerProp: portalContainerProp,
|
|
86
93
|
portalContainerFromParent: portalContainerFromParent,
|
|
87
94
|
isInheritingTheme: 'inherit' === themeProp,
|
|
@@ -108,7 +115,7 @@ let MainRoot = React.forwardRef((props, forwardedRef) => {
|
|
|
108
115
|
});
|
|
109
116
|
});
|
|
110
117
|
let Root = React.forwardRef((props, forwardedRef) => {
|
|
111
|
-
let { theme, children, themeOptions, className, ...rest } = props;
|
|
118
|
+
let { theme, children, themeOptions, className, future, ...rest } = props;
|
|
112
119
|
let prefersDark = useMediaQuery('(prefers-color-scheme: dark)');
|
|
113
120
|
let prefersHighContrast = useMediaQuery('(prefers-contrast: more)');
|
|
114
121
|
let shouldApplyDark = 'dark' === theme || ('os' === theme && prefersDark);
|
|
@@ -126,6 +133,7 @@ let Root = React.forwardRef((props, forwardedRef) => {
|
|
|
126
133
|
),
|
|
127
134
|
'data-iui-theme': shouldApplyDark ? 'dark' : 'light',
|
|
128
135
|
'data-iui-contrast': shouldApplyHC ? 'high' : 'default',
|
|
136
|
+
'data-iui-bridge': !!future?.themeBridge || void 0,
|
|
129
137
|
ref: forwardedRef,
|
|
130
138
|
...rest,
|
|
131
139
|
},
|
|
@@ -173,6 +181,7 @@ let PortalContainer = React.memo(
|
|
|
173
181
|
isInheritingTheme,
|
|
174
182
|
theme,
|
|
175
183
|
themeOptions,
|
|
184
|
+
future,
|
|
176
185
|
}) => {
|
|
177
186
|
let [ownerDocument] = useScopedAtom(ownerDocumentAtom);
|
|
178
187
|
let [portalContainer, setPortalContainer] =
|
|
@@ -202,6 +211,7 @@ let PortalContainer = React.memo(
|
|
|
202
211
|
...themeOptions,
|
|
203
212
|
applyBackground: false,
|
|
204
213
|
},
|
|
214
|
+
future: future,
|
|
205
215
|
'data-iui-portal': true,
|
|
206
216
|
style: {
|
|
207
217
|
display: 'contents',
|
package/DEV-esm/styles.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import type { ThemeOptions, ThemeType } from './ThemeProvider.js';
|
|
2
|
+
import type { FutureOptions, ThemeOptions, ThemeType } from './ThemeProvider.js';
|
|
3
3
|
export declare const ThemeContext: React.Context<{
|
|
4
4
|
theme?: ThemeType;
|
|
5
5
|
themeOptions?: ThemeOptions;
|
|
6
6
|
portalContainer?: HTMLElement | null;
|
|
7
|
+
future?: FutureOptions;
|
|
7
8
|
} | undefined>;
|
|
@@ -7,6 +7,16 @@ export type ThemeOptions = {
|
|
|
7
7
|
*/
|
|
8
8
|
highContrast?: boolean;
|
|
9
9
|
};
|
|
10
|
+
export type FutureOptions = {
|
|
11
|
+
/**
|
|
12
|
+
* If enabled, the theme resembles the future iTwinUI version's theme (including alphas) *whenever possible*.
|
|
13
|
+
*
|
|
14
|
+
* This is useful in making apps looks like future versions of iTwinUI to help with incremental adoption.
|
|
15
|
+
*
|
|
16
|
+
* **NOTE**: Since this is a theme bridge to *future* versions, the theme could have breaking changes.
|
|
17
|
+
*/
|
|
18
|
+
themeBridge?: boolean;
|
|
19
|
+
};
|
|
10
20
|
export type ThemeType = 'light' | 'dark' | 'os';
|
|
11
21
|
type RootProps = {
|
|
12
22
|
/**
|
|
@@ -18,8 +28,8 @@ type RootProps = {
|
|
|
18
28
|
*
|
|
19
29
|
* The 'inherit' option is intended to be used by packages, to enable incremental adoption
|
|
20
30
|
* of iTwinUI while respecting the theme set by the consuming app. It will fall back to 'light'
|
|
21
|
-
* if no parent theme is found. Additionally, it will attempt to inherit `themeOptions.highContrast
|
|
22
|
-
* and `
|
|
31
|
+
* if no parent theme is found. Additionally, it will attempt to inherit `themeOptions.highContrast`,
|
|
32
|
+
* `portalContainer`, and `future.themeBridge` (if possible).
|
|
23
33
|
*
|
|
24
34
|
* @default 'inherit'
|
|
25
35
|
*/
|
|
@@ -38,8 +48,12 @@ type RootProps = {
|
|
|
38
48
|
*/
|
|
39
49
|
applyBackground?: boolean;
|
|
40
50
|
};
|
|
51
|
+
/**
|
|
52
|
+
* Options to help with early adoption of features from future versions.
|
|
53
|
+
*/
|
|
54
|
+
future?: FutureOptions;
|
|
41
55
|
};
|
|
42
|
-
type ThemeProviderOwnProps = Pick<RootProps, 'theme'> & {
|
|
56
|
+
type ThemeProviderOwnProps = Pick<RootProps, 'theme' | 'future'> & {
|
|
43
57
|
themeOptions?: RootProps['themeOptions'];
|
|
44
58
|
children: Required<React.ReactNode>;
|
|
45
59
|
/**
|
|
@@ -21,13 +21,14 @@ const _meta = require('../../utils/meta.js');
|
|
|
21
21
|
const versionWithoutDots = _meta.meta.version.replace(/\./g, '');
|
|
22
22
|
const ownerDocumentAtom = (0, _jotai.atom)(void 0);
|
|
23
23
|
const ThemeProvider = _react.forwardRef((props, forwardedRef) => {
|
|
24
|
-
var _themeOptions, _themeOptions1;
|
|
24
|
+
var _themeOptions, _themeOptions1, _future;
|
|
25
25
|
let {
|
|
26
26
|
theme: themeProp = 'inherit',
|
|
27
27
|
children,
|
|
28
28
|
themeOptions = {},
|
|
29
29
|
portalContainer: portalContainerProp,
|
|
30
30
|
includeCss = 'inherit' === themeProp,
|
|
31
|
+
future = {},
|
|
31
32
|
...rest
|
|
32
33
|
} = props;
|
|
33
34
|
useInertPolyfill();
|
|
@@ -39,6 +40,9 @@ const ThemeProvider = _react.forwardRef((props, forwardedRef) => {
|
|
|
39
40
|
(_themeOptions1 = themeOptions).highContrast ??
|
|
40
41
|
(_themeOptions1.highContrast =
|
|
41
42
|
'inherit' === themeProp ? parent.highContrast : void 0);
|
|
43
|
+
(_future = future).themeBridge ??
|
|
44
|
+
(_future.themeBridge =
|
|
45
|
+
'inherit' === themeProp ? parent.context?.future?.themeBridge : void 0);
|
|
42
46
|
let [portalContainerFromParent] = (0, _index.useScopedAtom)(
|
|
43
47
|
_index.portalContainerAtom,
|
|
44
48
|
);
|
|
@@ -46,8 +50,9 @@ const ThemeProvider = _react.forwardRef((props, forwardedRef) => {
|
|
|
46
50
|
() => ({
|
|
47
51
|
theme,
|
|
48
52
|
themeOptions,
|
|
53
|
+
future,
|
|
49
54
|
}),
|
|
50
|
-
[theme, JSON.stringify(themeOptions)],
|
|
55
|
+
[theme, JSON.stringify(themeOptions), JSON.stringify(future)],
|
|
51
56
|
);
|
|
52
57
|
return _react.createElement(
|
|
53
58
|
_index.ScopeProvider,
|
|
@@ -75,6 +80,7 @@ const ThemeProvider = _react.forwardRef((props, forwardedRef) => {
|
|
|
75
80
|
{
|
|
76
81
|
theme: theme,
|
|
77
82
|
themeOptions: themeOptions,
|
|
83
|
+
future: future,
|
|
78
84
|
ref: (0, _index.useMergedRefs)(
|
|
79
85
|
forwardedRef,
|
|
80
86
|
setRootElement,
|
|
@@ -86,6 +92,7 @@ const ThemeProvider = _react.forwardRef((props, forwardedRef) => {
|
|
|
86
92
|
_react.createElement(PortalContainer, {
|
|
87
93
|
theme: theme,
|
|
88
94
|
themeOptions: themeOptions,
|
|
95
|
+
future: future,
|
|
89
96
|
portalContainerProp: portalContainerProp,
|
|
90
97
|
portalContainerFromParent: portalContainerFromParent,
|
|
91
98
|
isInheritingTheme: 'inherit' === themeProp,
|
|
@@ -113,7 +120,7 @@ const MainRoot = _react.forwardRef((props, forwardedRef) => {
|
|
|
113
120
|
});
|
|
114
121
|
});
|
|
115
122
|
const Root = _react.forwardRef((props, forwardedRef) => {
|
|
116
|
-
let { theme, children, themeOptions, className, ...rest } = props;
|
|
123
|
+
let { theme, children, themeOptions, className, future, ...rest } = props;
|
|
117
124
|
let prefersDark = (0, _index.useMediaQuery)('(prefers-color-scheme: dark)');
|
|
118
125
|
let prefersHighContrast = (0, _index.useMediaQuery)(
|
|
119
126
|
'(prefers-contrast: more)',
|
|
@@ -133,6 +140,7 @@ const Root = _react.forwardRef((props, forwardedRef) => {
|
|
|
133
140
|
),
|
|
134
141
|
'data-iui-theme': shouldApplyDark ? 'dark' : 'light',
|
|
135
142
|
'data-iui-contrast': shouldApplyHC ? 'high' : 'default',
|
|
143
|
+
'data-iui-bridge': !!future?.themeBridge || void 0,
|
|
136
144
|
ref: forwardedRef,
|
|
137
145
|
...rest,
|
|
138
146
|
},
|
|
@@ -182,6 +190,7 @@ const PortalContainer = _react.memo(
|
|
|
182
190
|
isInheritingTheme,
|
|
183
191
|
theme,
|
|
184
192
|
themeOptions,
|
|
193
|
+
future,
|
|
185
194
|
}) => {
|
|
186
195
|
let [ownerDocument] = (0, _index.useScopedAtom)(ownerDocumentAtom);
|
|
187
196
|
let [portalContainer, setPortalContainer] = (0, _index.useScopedAtom)(
|
|
@@ -212,6 +221,7 @@ const PortalContainer = _react.memo(
|
|
|
212
221
|
...themeOptions,
|
|
213
222
|
applyBackground: false,
|
|
214
223
|
},
|
|
224
|
+
future: future,
|
|
215
225
|
'data-iui-portal': true,
|
|
216
226
|
style: {
|
|
217
227
|
display: 'contents',
|
package/cjs/styles.js
CHANGED
|
@@ -10,6 +10,7 @@ export declare const useGlobals: () => {
|
|
|
10
10
|
theme?: import("../../index.js").ThemeType;
|
|
11
11
|
themeOptions?: import("../../core/ThemeProvider/ThemeProvider.js").ThemeOptions;
|
|
12
12
|
portalContainer?: HTMLElement | null;
|
|
13
|
+
future?: import("../../core/ThemeProvider/ThemeProvider.js").FutureOptions;
|
|
13
14
|
} | undefined;
|
|
14
15
|
/** Shows console error if ThemeProvider is not used */
|
|
15
16
|
export declare const useThemeProviderWarning: (themeContext: React.ContextType<typeof ThemeContext>) => void;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import type { ThemeOptions, ThemeType } from './ThemeProvider.js';
|
|
2
|
+
import type { FutureOptions, ThemeOptions, ThemeType } from './ThemeProvider.js';
|
|
3
3
|
export declare const ThemeContext: React.Context<{
|
|
4
4
|
theme?: ThemeType;
|
|
5
5
|
themeOptions?: ThemeOptions;
|
|
6
6
|
portalContainer?: HTMLElement | null;
|
|
7
|
+
future?: FutureOptions;
|
|
7
8
|
} | undefined>;
|
|
@@ -7,6 +7,16 @@ export type ThemeOptions = {
|
|
|
7
7
|
*/
|
|
8
8
|
highContrast?: boolean;
|
|
9
9
|
};
|
|
10
|
+
export type FutureOptions = {
|
|
11
|
+
/**
|
|
12
|
+
* If enabled, the theme resembles the future iTwinUI version's theme (including alphas) *whenever possible*.
|
|
13
|
+
*
|
|
14
|
+
* This is useful in making apps looks like future versions of iTwinUI to help with incremental adoption.
|
|
15
|
+
*
|
|
16
|
+
* **NOTE**: Since this is a theme bridge to *future* versions, the theme could have breaking changes.
|
|
17
|
+
*/
|
|
18
|
+
themeBridge?: boolean;
|
|
19
|
+
};
|
|
10
20
|
export type ThemeType = 'light' | 'dark' | 'os';
|
|
11
21
|
type RootProps = {
|
|
12
22
|
/**
|
|
@@ -18,8 +28,8 @@ type RootProps = {
|
|
|
18
28
|
*
|
|
19
29
|
* The 'inherit' option is intended to be used by packages, to enable incremental adoption
|
|
20
30
|
* of iTwinUI while respecting the theme set by the consuming app. It will fall back to 'light'
|
|
21
|
-
* if no parent theme is found. Additionally, it will attempt to inherit `themeOptions.highContrast
|
|
22
|
-
* and `
|
|
31
|
+
* if no parent theme is found. Additionally, it will attempt to inherit `themeOptions.highContrast`,
|
|
32
|
+
* `portalContainer`, and `future.themeBridge` (if possible).
|
|
23
33
|
*
|
|
24
34
|
* @default 'inherit'
|
|
25
35
|
*/
|
|
@@ -38,8 +48,12 @@ type RootProps = {
|
|
|
38
48
|
*/
|
|
39
49
|
applyBackground?: boolean;
|
|
40
50
|
};
|
|
51
|
+
/**
|
|
52
|
+
* Options to help with early adoption of features from future versions.
|
|
53
|
+
*/
|
|
54
|
+
future?: FutureOptions;
|
|
41
55
|
};
|
|
42
|
-
type ThemeProviderOwnProps = Pick<RootProps, 'theme'> & {
|
|
56
|
+
type ThemeProviderOwnProps = Pick<RootProps, 'theme' | 'future'> & {
|
|
43
57
|
themeOptions?: RootProps['themeOptions'];
|
|
44
58
|
children: Required<React.ReactNode>;
|
|
45
59
|
/**
|
|
@@ -23,13 +23,14 @@ import { meta } from '../../utils/meta.js';
|
|
|
23
23
|
let versionWithoutDots = meta.version.replace(/\./g, '');
|
|
24
24
|
let ownerDocumentAtom = atom(void 0);
|
|
25
25
|
export const ThemeProvider = React.forwardRef((props, forwardedRef) => {
|
|
26
|
-
var _themeOptions, _themeOptions1;
|
|
26
|
+
var _themeOptions, _themeOptions1, _future;
|
|
27
27
|
let {
|
|
28
28
|
theme: themeProp = 'inherit',
|
|
29
29
|
children,
|
|
30
30
|
themeOptions = {},
|
|
31
31
|
portalContainer: portalContainerProp,
|
|
32
32
|
includeCss = 'inherit' === themeProp,
|
|
33
|
+
future = {},
|
|
33
34
|
...rest
|
|
34
35
|
} = props;
|
|
35
36
|
useInertPolyfill();
|
|
@@ -41,13 +42,17 @@ export const ThemeProvider = React.forwardRef((props, forwardedRef) => {
|
|
|
41
42
|
(_themeOptions1 = themeOptions).highContrast ??
|
|
42
43
|
(_themeOptions1.highContrast =
|
|
43
44
|
'inherit' === themeProp ? parent.highContrast : void 0);
|
|
45
|
+
(_future = future).themeBridge ??
|
|
46
|
+
(_future.themeBridge =
|
|
47
|
+
'inherit' === themeProp ? parent.context?.future?.themeBridge : void 0);
|
|
44
48
|
let [portalContainerFromParent] = useScopedAtom(portalContainerAtom);
|
|
45
49
|
let contextValue = React.useMemo(
|
|
46
50
|
() => ({
|
|
47
51
|
theme,
|
|
48
52
|
themeOptions,
|
|
53
|
+
future,
|
|
49
54
|
}),
|
|
50
|
-
[theme, JSON.stringify(themeOptions)],
|
|
55
|
+
[theme, JSON.stringify(themeOptions), JSON.stringify(future)],
|
|
51
56
|
);
|
|
52
57
|
return React.createElement(
|
|
53
58
|
ScopeProvider,
|
|
@@ -75,6 +80,7 @@ export const ThemeProvider = React.forwardRef((props, forwardedRef) => {
|
|
|
75
80
|
{
|
|
76
81
|
theme: theme,
|
|
77
82
|
themeOptions: themeOptions,
|
|
83
|
+
future: future,
|
|
78
84
|
ref: useMergedRefs(forwardedRef, setRootElement, useIuiDebugRef),
|
|
79
85
|
...rest,
|
|
80
86
|
},
|
|
@@ -82,6 +88,7 @@ export const ThemeProvider = React.forwardRef((props, forwardedRef) => {
|
|
|
82
88
|
React.createElement(PortalContainer, {
|
|
83
89
|
theme: theme,
|
|
84
90
|
themeOptions: themeOptions,
|
|
91
|
+
future: future,
|
|
85
92
|
portalContainerProp: portalContainerProp,
|
|
86
93
|
portalContainerFromParent: portalContainerFromParent,
|
|
87
94
|
isInheritingTheme: 'inherit' === themeProp,
|
|
@@ -107,7 +114,7 @@ let MainRoot = React.forwardRef((props, forwardedRef) => {
|
|
|
107
114
|
});
|
|
108
115
|
});
|
|
109
116
|
let Root = React.forwardRef((props, forwardedRef) => {
|
|
110
|
-
let { theme, children, themeOptions, className, ...rest } = props;
|
|
117
|
+
let { theme, children, themeOptions, className, future, ...rest } = props;
|
|
111
118
|
let prefersDark = useMediaQuery('(prefers-color-scheme: dark)');
|
|
112
119
|
let prefersHighContrast = useMediaQuery('(prefers-contrast: more)');
|
|
113
120
|
let shouldApplyDark = 'dark' === theme || ('os' === theme && prefersDark);
|
|
@@ -125,6 +132,7 @@ let Root = React.forwardRef((props, forwardedRef) => {
|
|
|
125
132
|
),
|
|
126
133
|
'data-iui-theme': shouldApplyDark ? 'dark' : 'light',
|
|
127
134
|
'data-iui-contrast': shouldApplyHC ? 'high' : 'default',
|
|
135
|
+
'data-iui-bridge': !!future?.themeBridge || void 0,
|
|
128
136
|
ref: forwardedRef,
|
|
129
137
|
...rest,
|
|
130
138
|
},
|
|
@@ -172,6 +180,7 @@ let PortalContainer = React.memo(
|
|
|
172
180
|
isInheritingTheme,
|
|
173
181
|
theme,
|
|
174
182
|
themeOptions,
|
|
183
|
+
future,
|
|
175
184
|
}) => {
|
|
176
185
|
let [ownerDocument] = useScopedAtom(ownerDocumentAtom);
|
|
177
186
|
let [portalContainer, setPortalContainer] =
|
|
@@ -201,6 +210,7 @@ let PortalContainer = React.memo(
|
|
|
201
210
|
...themeOptions,
|
|
202
211
|
applyBackground: false,
|
|
203
212
|
},
|
|
213
|
+
future: future,
|
|
204
214
|
'data-iui-portal': true,
|
|
205
215
|
style: {
|
|
206
216
|
display: 'contents',
|
package/esm/styles.js
CHANGED
|
@@ -10,6 +10,7 @@ export declare const useGlobals: () => {
|
|
|
10
10
|
theme?: import("../../index.js").ThemeType;
|
|
11
11
|
themeOptions?: import("../../core/ThemeProvider/ThemeProvider.js").ThemeOptions;
|
|
12
12
|
portalContainer?: HTMLElement | null;
|
|
13
|
+
future?: import("../../core/ThemeProvider/ThemeProvider.js").FutureOptions;
|
|
13
14
|
} | undefined;
|
|
14
15
|
/** Shows console error if ThemeProvider is not used */
|
|
15
16
|
export declare const useThemeProviderWarning: (themeContext: React.ContextType<typeof ThemeContext>) => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/itwinui-react",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.17.0-dev.1",
|
|
4
4
|
"author": "Bentley Systems",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -78,6 +78,30 @@
|
|
|
78
78
|
"ui",
|
|
79
79
|
"ux"
|
|
80
80
|
],
|
|
81
|
+
"scripts": {
|
|
82
|
+
"build": "pnpm clean:build && pnpm build:js && pnpm build:styles && pnpm build:types && pnpm build:post",
|
|
83
|
+
"build:js": "node ./scripts/build.mjs",
|
|
84
|
+
"build:types": "tsc -p tsconfig.build.json --outDir esm && tsc -p tsconfig.build.json --outDir cjs",
|
|
85
|
+
"build:styles": "vite build src/styles.js",
|
|
86
|
+
"build:post": "node ./scripts/postBuild.mjs",
|
|
87
|
+
"clean:build": "rimraf esm && rimraf cjs && rimraf DEV-esm && rimraf DEV-cjs && rimraf styles.css",
|
|
88
|
+
"clean:coverage": "rimraf coverage",
|
|
89
|
+
"clean": "rimraf .turbo && pnpm clean:coverage && pnpm clean:build && rimraf node_modules",
|
|
90
|
+
"test": "pnpm test:types && pnpm test:unit",
|
|
91
|
+
"test:unit": "vitest run",
|
|
92
|
+
"test:unit:watch": "pnpm test:unit --watch",
|
|
93
|
+
"test:types": "tsc -p tsconfig.test.json --noEmit",
|
|
94
|
+
"format": "prettier --config .prettierrc **/*.{tsx,ts,js} --ignore-path .gitignore --write",
|
|
95
|
+
"lint": "eslint \"**/*.{js,ts,tsx}\" --max-warnings=0",
|
|
96
|
+
"lint:fix": "pnpm lint --fix && node ../../scripts/copyrightLinter.js --fix \"*/**/*.{js,ts,tsx}\"",
|
|
97
|
+
"dev": "pnpm clean:build && concurrently \"pnpm dev:esm\" \"pnpm dev:dev-esm\" \"pnpm dev:cjs\" \"pnpm dev:dev-cjs\" \"pnpm dev:styles\" \"pnpm dev:types\"",
|
|
98
|
+
"dev:esm": "swc src -d esm --env-name='production' --watch --strip-leading-paths",
|
|
99
|
+
"dev:dev-esm": "swc src -d DEV-esm --env-name='development' --watch --strip-leading-paths",
|
|
100
|
+
"dev:cjs": "swc src -d cjs --env-name='production' --watch --strip-leading-paths -C module.type=commonjs",
|
|
101
|
+
"dev:dev-cjs": "swc src -d DEV-cjs --env-name='development' --watch --strip-leading-paths -C module.type=commonjs",
|
|
102
|
+
"dev:types": "concurrently \"tsc -p tsconfig.build.json --outDir esm --watch --preserveWatchOutput\" \"tsc -p tsconfig.build.json --outDir cjs --watch --preserveWatchOutput\"",
|
|
103
|
+
"dev:styles": "pnpm build:styles --watch"
|
|
104
|
+
},
|
|
81
105
|
"dependencies": {
|
|
82
106
|
"@floating-ui/react": "^0.26.23",
|
|
83
107
|
"@itwin/itwinui-illustrations-react": "^2.1.0",
|
|
@@ -123,29 +147,5 @@
|
|
|
123
147
|
"prettier": "configs/prettier-config",
|
|
124
148
|
"sideEffects": [
|
|
125
149
|
"styles.css"
|
|
126
|
-
]
|
|
127
|
-
|
|
128
|
-
"build": "pnpm clean:build && pnpm build:js && pnpm build:styles && pnpm build:types && pnpm build:post",
|
|
129
|
-
"build:js": "node ./scripts/build.mjs",
|
|
130
|
-
"build:types": "tsc -p tsconfig.build.json --outDir esm && tsc -p tsconfig.build.json --outDir cjs",
|
|
131
|
-
"build:styles": "vite build src/styles.js",
|
|
132
|
-
"build:post": "node ./scripts/postBuild.mjs",
|
|
133
|
-
"clean:build": "rimraf esm && rimraf cjs && rimraf DEV-esm && rimraf DEV-cjs && rimraf styles.css",
|
|
134
|
-
"clean:coverage": "rimraf coverage",
|
|
135
|
-
"clean": "rimraf .turbo && pnpm clean:coverage && pnpm clean:build && rimraf node_modules",
|
|
136
|
-
"test": "pnpm test:types && pnpm test:unit",
|
|
137
|
-
"test:unit": "vitest run",
|
|
138
|
-
"test:unit:watch": "pnpm test:unit --watch",
|
|
139
|
-
"test:types": "tsc -p tsconfig.test.json --noEmit",
|
|
140
|
-
"format": "prettier --config .prettierrc **/*.{tsx,ts,js} --ignore-path .gitignore --write",
|
|
141
|
-
"lint": "eslint \"**/*.{js,ts,tsx}\" --max-warnings=0",
|
|
142
|
-
"lint:fix": "pnpm lint --fix && node ../../scripts/copyrightLinter.js --fix \"*/**/*.{js,ts,tsx}\"",
|
|
143
|
-
"dev": "pnpm clean:build && concurrently \"pnpm dev:esm\" \"pnpm dev:dev-esm\" \"pnpm dev:cjs\" \"pnpm dev:dev-cjs\" \"pnpm dev:styles\" \"pnpm dev:types\"",
|
|
144
|
-
"dev:esm": "swc src -d esm --env-name='production' --watch --strip-leading-paths",
|
|
145
|
-
"dev:dev-esm": "swc src -d DEV-esm --env-name='development' --watch --strip-leading-paths",
|
|
146
|
-
"dev:cjs": "swc src -d cjs --env-name='production' --watch --strip-leading-paths -C module.type=commonjs",
|
|
147
|
-
"dev:dev-cjs": "swc src -d DEV-cjs --env-name='development' --watch --strip-leading-paths -C module.type=commonjs",
|
|
148
|
-
"dev:types": "concurrently \"tsc -p tsconfig.build.json --outDir esm --watch --preserveWatchOutput\" \"tsc -p tsconfig.build.json --outDir cjs --watch --preserveWatchOutput\"",
|
|
149
|
-
"dev:styles": "pnpm build:styles --watch"
|
|
150
|
-
}
|
|
151
|
-
}
|
|
150
|
+
]
|
|
151
|
+
}
|