@itwin/itwinui-react 3.17.0-dev.0 → 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/CHANGELOG.md +7 -0
- package/DEV-cjs/core/ThemeProvider/ThemeProvider.js +13 -9
- package/DEV-cjs/styles.js +1 -1
- package/DEV-esm/core/ThemeProvider/ThemeProvider.js +13 -9
- package/DEV-esm/styles.js +1 -1
- package/cjs/core/ThemeProvider/ThemeContext.d.ts +2 -1
- package/cjs/core/ThemeProvider/ThemeProvider.d.ts +11 -5
- package/cjs/core/ThemeProvider/ThemeProvider.js +13 -9
- 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 +11 -5
- package/esm/core/ThemeProvider/ThemeProvider.js +13 -9
- package/esm/styles.js +1 -1
- package/esm/utils/hooks/useGlobals.d.ts +1 -0
- package/package.json +3 -3
- package/styles.css +9 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 3.16.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#2384](https://github.com/iTwin/iTwinUI/pull/2384): Fixed the syntax for `react` and `react-dom` version ranges declared in `peerDependencies`.
|
|
8
|
+
- [#2386](https://github.com/iTwin/iTwinUI/pull/2386): Fixed a visual issue in `Tile.Name` where a long string without spaces wasn't wrapping properly.
|
|
9
|
+
|
|
3
10
|
## 3.16.2
|
|
4
11
|
|
|
5
12
|
### Patch Changes
|
|
@@ -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,11 +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);
|
|
42
|
-
(
|
|
43
|
-
(
|
|
44
|
-
'inherit' === themeProp
|
|
45
|
-
? parent.context?.themeOptions?.bridgeToFutureVersions
|
|
46
|
-
: void 0);
|
|
43
|
+
(_future = future).themeBridge ??
|
|
44
|
+
(_future.themeBridge =
|
|
45
|
+
'inherit' === themeProp ? parent.context?.future?.themeBridge : void 0);
|
|
47
46
|
let [portalContainerFromParent] = (0, _index.useScopedAtom)(
|
|
48
47
|
_index.portalContainerAtom,
|
|
49
48
|
);
|
|
@@ -51,8 +50,9 @@ const ThemeProvider = _react.forwardRef((props, forwardedRef) => {
|
|
|
51
50
|
() => ({
|
|
52
51
|
theme,
|
|
53
52
|
themeOptions,
|
|
53
|
+
future,
|
|
54
54
|
}),
|
|
55
|
-
[theme, JSON.stringify(themeOptions)],
|
|
55
|
+
[theme, JSON.stringify(themeOptions), JSON.stringify(future)],
|
|
56
56
|
);
|
|
57
57
|
return _react.createElement(
|
|
58
58
|
_index.ScopeProvider,
|
|
@@ -80,6 +80,7 @@ const ThemeProvider = _react.forwardRef((props, forwardedRef) => {
|
|
|
80
80
|
{
|
|
81
81
|
theme: theme,
|
|
82
82
|
themeOptions: themeOptions,
|
|
83
|
+
future: future,
|
|
83
84
|
ref: (0, _index.useMergedRefs)(
|
|
84
85
|
forwardedRef,
|
|
85
86
|
setRootElement,
|
|
@@ -91,6 +92,7 @@ const ThemeProvider = _react.forwardRef((props, forwardedRef) => {
|
|
|
91
92
|
_react.createElement(PortalContainer, {
|
|
92
93
|
theme: theme,
|
|
93
94
|
themeOptions: themeOptions,
|
|
95
|
+
future: future,
|
|
94
96
|
portalContainerProp: portalContainerProp,
|
|
95
97
|
portalContainerFromParent: portalContainerFromParent,
|
|
96
98
|
isInheritingTheme: 'inherit' === themeProp,
|
|
@@ -119,7 +121,7 @@ const MainRoot = _react.forwardRef((props, forwardedRef) => {
|
|
|
119
121
|
});
|
|
120
122
|
});
|
|
121
123
|
const Root = _react.forwardRef((props, forwardedRef) => {
|
|
122
|
-
let { theme, children, themeOptions, className, ...rest } = props;
|
|
124
|
+
let { theme, children, themeOptions, className, future, ...rest } = props;
|
|
123
125
|
let prefersDark = (0, _index.useMediaQuery)('(prefers-color-scheme: dark)');
|
|
124
126
|
let prefersHighContrast = (0, _index.useMediaQuery)(
|
|
125
127
|
'(prefers-contrast: more)',
|
|
@@ -139,7 +141,7 @@ const Root = _react.forwardRef((props, forwardedRef) => {
|
|
|
139
141
|
),
|
|
140
142
|
'data-iui-theme': shouldApplyDark ? 'dark' : 'light',
|
|
141
143
|
'data-iui-contrast': shouldApplyHC ? 'high' : 'default',
|
|
142
|
-
'data-iui-bridge': !!
|
|
144
|
+
'data-iui-bridge': !!future?.themeBridge || void 0,
|
|
143
145
|
ref: forwardedRef,
|
|
144
146
|
...rest,
|
|
145
147
|
},
|
|
@@ -189,6 +191,7 @@ const PortalContainer = _react.memo(
|
|
|
189
191
|
isInheritingTheme,
|
|
190
192
|
theme,
|
|
191
193
|
themeOptions,
|
|
194
|
+
future,
|
|
192
195
|
}) => {
|
|
193
196
|
let [ownerDocument] = (0, _index.useScopedAtom)(ownerDocumentAtom);
|
|
194
197
|
let [portalContainer, setPortalContainer] = (0, _index.useScopedAtom)(
|
|
@@ -219,6 +222,7 @@ const PortalContainer = _react.memo(
|
|
|
219
222
|
...themeOptions,
|
|
220
223
|
applyBackground: false,
|
|
221
224
|
},
|
|
225
|
+
future: future,
|
|
222
226
|
'data-iui-portal': true,
|
|
223
227
|
style: {
|
|
224
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,18 +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);
|
|
44
|
-
(
|
|
45
|
-
(
|
|
46
|
-
'inherit' === themeProp
|
|
47
|
-
? parent.context?.themeOptions?.bridgeToFutureVersions
|
|
48
|
-
: void 0);
|
|
45
|
+
(_future = future).themeBridge ??
|
|
46
|
+
(_future.themeBridge =
|
|
47
|
+
'inherit' === themeProp ? parent.context?.future?.themeBridge : void 0);
|
|
49
48
|
let [portalContainerFromParent] = useScopedAtom(portalContainerAtom);
|
|
50
49
|
let contextValue = React.useMemo(
|
|
51
50
|
() => ({
|
|
52
51
|
theme,
|
|
53
52
|
themeOptions,
|
|
53
|
+
future,
|
|
54
54
|
}),
|
|
55
|
-
[theme, JSON.stringify(themeOptions)],
|
|
55
|
+
[theme, JSON.stringify(themeOptions), JSON.stringify(future)],
|
|
56
56
|
);
|
|
57
57
|
return React.createElement(
|
|
58
58
|
ScopeProvider,
|
|
@@ -80,6 +80,7 @@ export const ThemeProvider = React.forwardRef((props, forwardedRef) => {
|
|
|
80
80
|
{
|
|
81
81
|
theme: theme,
|
|
82
82
|
themeOptions: themeOptions,
|
|
83
|
+
future: future,
|
|
83
84
|
ref: useMergedRefs(forwardedRef, setRootElement, useIuiDebugRef),
|
|
84
85
|
...rest,
|
|
85
86
|
},
|
|
@@ -87,6 +88,7 @@ export const ThemeProvider = React.forwardRef((props, forwardedRef) => {
|
|
|
87
88
|
React.createElement(PortalContainer, {
|
|
88
89
|
theme: theme,
|
|
89
90
|
themeOptions: themeOptions,
|
|
91
|
+
future: future,
|
|
90
92
|
portalContainerProp: portalContainerProp,
|
|
91
93
|
portalContainerFromParent: portalContainerFromParent,
|
|
92
94
|
isInheritingTheme: 'inherit' === themeProp,
|
|
@@ -113,7 +115,7 @@ let MainRoot = React.forwardRef((props, forwardedRef) => {
|
|
|
113
115
|
});
|
|
114
116
|
});
|
|
115
117
|
let Root = React.forwardRef((props, forwardedRef) => {
|
|
116
|
-
let { theme, children, themeOptions, className, ...rest } = props;
|
|
118
|
+
let { theme, children, themeOptions, className, future, ...rest } = props;
|
|
117
119
|
let prefersDark = useMediaQuery('(prefers-color-scheme: dark)');
|
|
118
120
|
let prefersHighContrast = useMediaQuery('(prefers-contrast: more)');
|
|
119
121
|
let shouldApplyDark = 'dark' === theme || ('os' === theme && prefersDark);
|
|
@@ -131,7 +133,7 @@ let Root = React.forwardRef((props, forwardedRef) => {
|
|
|
131
133
|
),
|
|
132
134
|
'data-iui-theme': shouldApplyDark ? 'dark' : 'light',
|
|
133
135
|
'data-iui-contrast': shouldApplyHC ? 'high' : 'default',
|
|
134
|
-
'data-iui-bridge': !!
|
|
136
|
+
'data-iui-bridge': !!future?.themeBridge || void 0,
|
|
135
137
|
ref: forwardedRef,
|
|
136
138
|
...rest,
|
|
137
139
|
},
|
|
@@ -179,6 +181,7 @@ let PortalContainer = React.memo(
|
|
|
179
181
|
isInheritingTheme,
|
|
180
182
|
theme,
|
|
181
183
|
themeOptions,
|
|
184
|
+
future,
|
|
182
185
|
}) => {
|
|
183
186
|
let [ownerDocument] = useScopedAtom(ownerDocumentAtom);
|
|
184
187
|
let [portalContainer, setPortalContainer] =
|
|
@@ -208,6 +211,7 @@ let PortalContainer = React.memo(
|
|
|
208
211
|
...themeOptions,
|
|
209
212
|
applyBackground: false,
|
|
210
213
|
},
|
|
214
|
+
future: future,
|
|
211
215
|
'data-iui-portal': true,
|
|
212
216
|
style: {
|
|
213
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>;
|
|
@@ -6,6 +6,8 @@ export type ThemeOptions = {
|
|
|
6
6
|
* Will default to user preference if browser supports it.
|
|
7
7
|
*/
|
|
8
8
|
highContrast?: boolean;
|
|
9
|
+
};
|
|
10
|
+
export type FutureOptions = {
|
|
9
11
|
/**
|
|
10
12
|
* If enabled, the theme resembles the future iTwinUI version's theme (including alphas) *whenever possible*.
|
|
11
13
|
*
|
|
@@ -13,7 +15,7 @@ export type ThemeOptions = {
|
|
|
13
15
|
*
|
|
14
16
|
* **NOTE**: Since this is a theme bridge to *future* versions, the theme could have breaking changes.
|
|
15
17
|
*/
|
|
16
|
-
|
|
18
|
+
themeBridge?: boolean;
|
|
17
19
|
};
|
|
18
20
|
export type ThemeType = 'light' | 'dark' | 'os';
|
|
19
21
|
type RootProps = {
|
|
@@ -26,13 +28,13 @@ type RootProps = {
|
|
|
26
28
|
*
|
|
27
29
|
* The 'inherit' option is intended to be used by packages, to enable incremental adoption
|
|
28
30
|
* of iTwinUI while respecting the theme set by the consuming app. It will fall back to 'light'
|
|
29
|
-
* if no parent theme is found. Additionally, it will attempt to inherit `themeOptions.highContrast
|
|
30
|
-
* and `
|
|
31
|
+
* if no parent theme is found. Additionally, it will attempt to inherit `themeOptions.highContrast`,
|
|
32
|
+
* `portalContainer`, and `future.themeBridge` (if possible).
|
|
31
33
|
*
|
|
32
34
|
* @default 'inherit'
|
|
33
35
|
*/
|
|
34
36
|
theme?: ThemeType | 'inherit';
|
|
35
|
-
themeOptions?: Pick<ThemeOptions, 'highContrast'
|
|
37
|
+
themeOptions?: Pick<ThemeOptions, 'highContrast'> & {
|
|
36
38
|
/**
|
|
37
39
|
* Whether or not the element should apply the recommended `background-color` on itself.
|
|
38
40
|
*
|
|
@@ -46,8 +48,12 @@ type RootProps = {
|
|
|
46
48
|
*/
|
|
47
49
|
applyBackground?: boolean;
|
|
48
50
|
};
|
|
51
|
+
/**
|
|
52
|
+
* Options to help with early adoption of features from future versions.
|
|
53
|
+
*/
|
|
54
|
+
future?: FutureOptions;
|
|
49
55
|
};
|
|
50
|
-
type ThemeProviderOwnProps = Pick<RootProps, 'theme'> & {
|
|
56
|
+
type ThemeProviderOwnProps = Pick<RootProps, 'theme' | 'future'> & {
|
|
51
57
|
themeOptions?: RootProps['themeOptions'];
|
|
52
58
|
children: Required<React.ReactNode>;
|
|
53
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,11 +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);
|
|
42
|
-
(
|
|
43
|
-
(
|
|
44
|
-
'inherit' === themeProp
|
|
45
|
-
? parent.context?.themeOptions?.bridgeToFutureVersions
|
|
46
|
-
: void 0);
|
|
43
|
+
(_future = future).themeBridge ??
|
|
44
|
+
(_future.themeBridge =
|
|
45
|
+
'inherit' === themeProp ? parent.context?.future?.themeBridge : void 0);
|
|
47
46
|
let [portalContainerFromParent] = (0, _index.useScopedAtom)(
|
|
48
47
|
_index.portalContainerAtom,
|
|
49
48
|
);
|
|
@@ -51,8 +50,9 @@ const ThemeProvider = _react.forwardRef((props, forwardedRef) => {
|
|
|
51
50
|
() => ({
|
|
52
51
|
theme,
|
|
53
52
|
themeOptions,
|
|
53
|
+
future,
|
|
54
54
|
}),
|
|
55
|
-
[theme, JSON.stringify(themeOptions)],
|
|
55
|
+
[theme, JSON.stringify(themeOptions), JSON.stringify(future)],
|
|
56
56
|
);
|
|
57
57
|
return _react.createElement(
|
|
58
58
|
_index.ScopeProvider,
|
|
@@ -80,6 +80,7 @@ const ThemeProvider = _react.forwardRef((props, forwardedRef) => {
|
|
|
80
80
|
{
|
|
81
81
|
theme: theme,
|
|
82
82
|
themeOptions: themeOptions,
|
|
83
|
+
future: future,
|
|
83
84
|
ref: (0, _index.useMergedRefs)(
|
|
84
85
|
forwardedRef,
|
|
85
86
|
setRootElement,
|
|
@@ -91,6 +92,7 @@ const ThemeProvider = _react.forwardRef((props, forwardedRef) => {
|
|
|
91
92
|
_react.createElement(PortalContainer, {
|
|
92
93
|
theme: theme,
|
|
93
94
|
themeOptions: themeOptions,
|
|
95
|
+
future: future,
|
|
94
96
|
portalContainerProp: portalContainerProp,
|
|
95
97
|
portalContainerFromParent: portalContainerFromParent,
|
|
96
98
|
isInheritingTheme: 'inherit' === themeProp,
|
|
@@ -118,7 +120,7 @@ const MainRoot = _react.forwardRef((props, forwardedRef) => {
|
|
|
118
120
|
});
|
|
119
121
|
});
|
|
120
122
|
const Root = _react.forwardRef((props, forwardedRef) => {
|
|
121
|
-
let { theme, children, themeOptions, className, ...rest } = props;
|
|
123
|
+
let { theme, children, themeOptions, className, future, ...rest } = props;
|
|
122
124
|
let prefersDark = (0, _index.useMediaQuery)('(prefers-color-scheme: dark)');
|
|
123
125
|
let prefersHighContrast = (0, _index.useMediaQuery)(
|
|
124
126
|
'(prefers-contrast: more)',
|
|
@@ -138,7 +140,7 @@ const Root = _react.forwardRef((props, forwardedRef) => {
|
|
|
138
140
|
),
|
|
139
141
|
'data-iui-theme': shouldApplyDark ? 'dark' : 'light',
|
|
140
142
|
'data-iui-contrast': shouldApplyHC ? 'high' : 'default',
|
|
141
|
-
'data-iui-bridge': !!
|
|
143
|
+
'data-iui-bridge': !!future?.themeBridge || void 0,
|
|
142
144
|
ref: forwardedRef,
|
|
143
145
|
...rest,
|
|
144
146
|
},
|
|
@@ -188,6 +190,7 @@ const PortalContainer = _react.memo(
|
|
|
188
190
|
isInheritingTheme,
|
|
189
191
|
theme,
|
|
190
192
|
themeOptions,
|
|
193
|
+
future,
|
|
191
194
|
}) => {
|
|
192
195
|
let [ownerDocument] = (0, _index.useScopedAtom)(ownerDocumentAtom);
|
|
193
196
|
let [portalContainer, setPortalContainer] = (0, _index.useScopedAtom)(
|
|
@@ -218,6 +221,7 @@ const PortalContainer = _react.memo(
|
|
|
218
221
|
...themeOptions,
|
|
219
222
|
applyBackground: false,
|
|
220
223
|
},
|
|
224
|
+
future: future,
|
|
221
225
|
'data-iui-portal': true,
|
|
222
226
|
style: {
|
|
223
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>;
|
|
@@ -6,6 +6,8 @@ export type ThemeOptions = {
|
|
|
6
6
|
* Will default to user preference if browser supports it.
|
|
7
7
|
*/
|
|
8
8
|
highContrast?: boolean;
|
|
9
|
+
};
|
|
10
|
+
export type FutureOptions = {
|
|
9
11
|
/**
|
|
10
12
|
* If enabled, the theme resembles the future iTwinUI version's theme (including alphas) *whenever possible*.
|
|
11
13
|
*
|
|
@@ -13,7 +15,7 @@ export type ThemeOptions = {
|
|
|
13
15
|
*
|
|
14
16
|
* **NOTE**: Since this is a theme bridge to *future* versions, the theme could have breaking changes.
|
|
15
17
|
*/
|
|
16
|
-
|
|
18
|
+
themeBridge?: boolean;
|
|
17
19
|
};
|
|
18
20
|
export type ThemeType = 'light' | 'dark' | 'os';
|
|
19
21
|
type RootProps = {
|
|
@@ -26,13 +28,13 @@ type RootProps = {
|
|
|
26
28
|
*
|
|
27
29
|
* The 'inherit' option is intended to be used by packages, to enable incremental adoption
|
|
28
30
|
* of iTwinUI while respecting the theme set by the consuming app. It will fall back to 'light'
|
|
29
|
-
* if no parent theme is found. Additionally, it will attempt to inherit `themeOptions.highContrast
|
|
30
|
-
* and `
|
|
31
|
+
* if no parent theme is found. Additionally, it will attempt to inherit `themeOptions.highContrast`,
|
|
32
|
+
* `portalContainer`, and `future.themeBridge` (if possible).
|
|
31
33
|
*
|
|
32
34
|
* @default 'inherit'
|
|
33
35
|
*/
|
|
34
36
|
theme?: ThemeType | 'inherit';
|
|
35
|
-
themeOptions?: Pick<ThemeOptions, 'highContrast'
|
|
37
|
+
themeOptions?: Pick<ThemeOptions, 'highContrast'> & {
|
|
36
38
|
/**
|
|
37
39
|
* Whether or not the element should apply the recommended `background-color` on itself.
|
|
38
40
|
*
|
|
@@ -46,8 +48,12 @@ type RootProps = {
|
|
|
46
48
|
*/
|
|
47
49
|
applyBackground?: boolean;
|
|
48
50
|
};
|
|
51
|
+
/**
|
|
52
|
+
* Options to help with early adoption of features from future versions.
|
|
53
|
+
*/
|
|
54
|
+
future?: FutureOptions;
|
|
49
55
|
};
|
|
50
|
-
type ThemeProviderOwnProps = Pick<RootProps, 'theme'> & {
|
|
56
|
+
type ThemeProviderOwnProps = Pick<RootProps, 'theme' | 'future'> & {
|
|
51
57
|
themeOptions?: RootProps['themeOptions'];
|
|
52
58
|
children: Required<React.ReactNode>;
|
|
53
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,18 +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);
|
|
44
|
-
(
|
|
45
|
-
(
|
|
46
|
-
'inherit' === themeProp
|
|
47
|
-
? parent.context?.themeOptions?.bridgeToFutureVersions
|
|
48
|
-
: void 0);
|
|
45
|
+
(_future = future).themeBridge ??
|
|
46
|
+
(_future.themeBridge =
|
|
47
|
+
'inherit' === themeProp ? parent.context?.future?.themeBridge : void 0);
|
|
49
48
|
let [portalContainerFromParent] = useScopedAtom(portalContainerAtom);
|
|
50
49
|
let contextValue = React.useMemo(
|
|
51
50
|
() => ({
|
|
52
51
|
theme,
|
|
53
52
|
themeOptions,
|
|
53
|
+
future,
|
|
54
54
|
}),
|
|
55
|
-
[theme, JSON.stringify(themeOptions)],
|
|
55
|
+
[theme, JSON.stringify(themeOptions), JSON.stringify(future)],
|
|
56
56
|
);
|
|
57
57
|
return React.createElement(
|
|
58
58
|
ScopeProvider,
|
|
@@ -80,6 +80,7 @@ export const ThemeProvider = React.forwardRef((props, forwardedRef) => {
|
|
|
80
80
|
{
|
|
81
81
|
theme: theme,
|
|
82
82
|
themeOptions: themeOptions,
|
|
83
|
+
future: future,
|
|
83
84
|
ref: useMergedRefs(forwardedRef, setRootElement, useIuiDebugRef),
|
|
84
85
|
...rest,
|
|
85
86
|
},
|
|
@@ -87,6 +88,7 @@ export const ThemeProvider = React.forwardRef((props, forwardedRef) => {
|
|
|
87
88
|
React.createElement(PortalContainer, {
|
|
88
89
|
theme: theme,
|
|
89
90
|
themeOptions: themeOptions,
|
|
91
|
+
future: future,
|
|
90
92
|
portalContainerProp: portalContainerProp,
|
|
91
93
|
portalContainerFromParent: portalContainerFromParent,
|
|
92
94
|
isInheritingTheme: 'inherit' === themeProp,
|
|
@@ -112,7 +114,7 @@ let MainRoot = React.forwardRef((props, forwardedRef) => {
|
|
|
112
114
|
});
|
|
113
115
|
});
|
|
114
116
|
let Root = React.forwardRef((props, forwardedRef) => {
|
|
115
|
-
let { theme, children, themeOptions, className, ...rest } = props;
|
|
117
|
+
let { theme, children, themeOptions, className, future, ...rest } = props;
|
|
116
118
|
let prefersDark = useMediaQuery('(prefers-color-scheme: dark)');
|
|
117
119
|
let prefersHighContrast = useMediaQuery('(prefers-contrast: more)');
|
|
118
120
|
let shouldApplyDark = 'dark' === theme || ('os' === theme && prefersDark);
|
|
@@ -130,7 +132,7 @@ let Root = React.forwardRef((props, forwardedRef) => {
|
|
|
130
132
|
),
|
|
131
133
|
'data-iui-theme': shouldApplyDark ? 'dark' : 'light',
|
|
132
134
|
'data-iui-contrast': shouldApplyHC ? 'high' : 'default',
|
|
133
|
-
'data-iui-bridge': !!
|
|
135
|
+
'data-iui-bridge': !!future?.themeBridge || void 0,
|
|
134
136
|
ref: forwardedRef,
|
|
135
137
|
...rest,
|
|
136
138
|
},
|
|
@@ -178,6 +180,7 @@ let PortalContainer = React.memo(
|
|
|
178
180
|
isInheritingTheme,
|
|
179
181
|
theme,
|
|
180
182
|
themeOptions,
|
|
183
|
+
future,
|
|
181
184
|
}) => {
|
|
182
185
|
let [ownerDocument] = useScopedAtom(ownerDocumentAtom);
|
|
183
186
|
let [portalContainer, setPortalContainer] =
|
|
@@ -207,6 +210,7 @@ let PortalContainer = React.memo(
|
|
|
207
210
|
...themeOptions,
|
|
208
211
|
applyBackground: false,
|
|
209
212
|
},
|
|
213
|
+
future: future,
|
|
210
214
|
'data-iui-portal': true,
|
|
211
215
|
style: {
|
|
212
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.17.0-dev.
|
|
3
|
+
"version": "3.17.0-dev.1",
|
|
4
4
|
"author": "Bentley Systems",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -134,8 +134,8 @@
|
|
|
134
134
|
"vitest": "^1.2.1"
|
|
135
135
|
},
|
|
136
136
|
"peerDependencies": {
|
|
137
|
-
"react": ">=
|
|
138
|
-
"react-dom": ">=17.0.0 <
|
|
137
|
+
"react": ">=17.0.0 <19.0.0",
|
|
138
|
+
"react-dom": ">=17.0.0 <19.0.0"
|
|
139
139
|
},
|
|
140
140
|
"lint-staged": {
|
|
141
141
|
"*.{tsx,ts,jsx,js}": [
|