@itwin/itwinui-react 2.12.10 → 2.12.12
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 +12 -0
- package/cjs/core/Table/SubRowExpander.js +1 -1
- package/cjs/core/Table/columns/expanderColumn.js +1 -1
- package/cjs/core/ThemeProvider/ThemeProvider.d.ts +1 -0
- package/cjs/core/ThemeProvider/ThemeProvider.js +18 -2
- package/cjs/core/utils/hooks/useStyles.js +15 -10
- package/esm/core/Table/SubRowExpander.js +1 -1
- package/esm/core/Table/columns/expanderColumn.js +1 -1
- package/esm/core/ThemeProvider/ThemeProvider.d.ts +1 -0
- package/esm/core/ThemeProvider/ThemeProvider.js +18 -2
- package/esm/core/utils/hooks/useStyles.js +15 -10
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 2.12.12
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#1625](https://github.com/iTwin/iTwinUI/pull/1625): Fixed an issue where components rendered in a popout window were throwing a stylesheet-related error.
|
|
8
|
+
|
|
9
|
+
## 2.12.11
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#1607](https://github.com/iTwin/iTwinUI/pull/1607): Add `aria-expanded` on table row expander button
|
|
14
|
+
|
|
3
15
|
## 2.12.10
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -38,7 +38,7 @@ const SubRowExpander = (props) => {
|
|
|
38
38
|
}, className: 'iui-table-row-expander', styleType: 'borderless', size: 'small', onClick: (e) => {
|
|
39
39
|
e.stopPropagation();
|
|
40
40
|
cell.row.toggleRowExpanded();
|
|
41
|
-
}, disabled: isDisabled }, React.createElement(index_js_1.SvgChevronRight, { style: {
|
|
41
|
+
}, disabled: isDisabled, "aria-expanded": cell.row.isExpanded }, React.createElement(index_js_1.SvgChevronRight, { style: {
|
|
42
42
|
transform: cell.row.isExpanded ? 'rotate(90deg)' : undefined,
|
|
43
43
|
} })))));
|
|
44
44
|
};
|
|
@@ -77,7 +77,7 @@ const ExpanderColumn = (props = {}) => {
|
|
|
77
77
|
return (React.createElement(index_js_2.IconButton, { className: 'iui-table-row-expander', styleType: 'borderless', size: 'small', onClick: (e) => {
|
|
78
78
|
e.stopPropagation();
|
|
79
79
|
row.toggleRowExpanded();
|
|
80
|
-
}, disabled: isDisabled === null || isDisabled === void 0 ? void 0 : isDisabled(props.row.original) }, React.createElement(index_js_1.SvgChevronRight, null)));
|
|
80
|
+
}, disabled: isDisabled === null || isDisabled === void 0 ? void 0 : isDisabled(props.row.original), "aria-expanded": row.isExpanded }, React.createElement(index_js_1.SvgChevronRight, null)));
|
|
81
81
|
}
|
|
82
82
|
},
|
|
83
83
|
cellRenderer: (props) => (React.createElement(index_js_3.DefaultCell, { ...props, isDisabled: (rowData) => !!(isDisabled === null || isDisabled === void 0 ? void 0 : isDisabled(rowData)) })),
|
|
@@ -62,14 +62,30 @@ const useStyles_js_1 = require("../utils/hooks/useStyles.js");
|
|
|
62
62
|
* </ThemeProvider>
|
|
63
63
|
*/
|
|
64
64
|
exports.ThemeProvider = React.forwardRef((props, ref) => {
|
|
65
|
-
var _a;
|
|
65
|
+
var _a, _b;
|
|
66
66
|
const { theme: themeProp, children, themeOptions, includeCss = { withLayer: true }, ...rest } = props;
|
|
67
67
|
const rootRef = React.useRef(null);
|
|
68
68
|
const mergedRefs = (0, index_js_1.useMergedRefs)(rootRef, ref);
|
|
69
69
|
const hasChildren = React.Children.count(children) > 0;
|
|
70
70
|
const parentContext = React.useContext(exports.ThemeContext);
|
|
71
71
|
const theme = themeProp === 'inherit' ? (_a = parentContext === null || parentContext === void 0 ? void 0 : parentContext.theme) !== null && _a !== void 0 ? _a : 'light' : themeProp;
|
|
72
|
-
const
|
|
72
|
+
const newStylesLoaded = React.useRef(false);
|
|
73
|
+
const stylesLoaded = (_b = parentContext === null || parentContext === void 0 ? void 0 : parentContext.stylesLoaded) !== null && _b !== void 0 ? _b : newStylesLoaded;
|
|
74
|
+
const contextValue = React.useMemo(() => ({
|
|
75
|
+
theme,
|
|
76
|
+
themeOptions,
|
|
77
|
+
rootRef,
|
|
78
|
+
includeCss,
|
|
79
|
+
stylesLoaded,
|
|
80
|
+
}),
|
|
81
|
+
// we do include all dependencies below, but we want to stringify the objects as they could be different on each render
|
|
82
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
83
|
+
[
|
|
84
|
+
theme,
|
|
85
|
+
JSON.stringify(themeOptions),
|
|
86
|
+
JSON.stringify(includeCss),
|
|
87
|
+
stylesLoaded,
|
|
88
|
+
]);
|
|
73
89
|
// if no children, then fallback to this wrapper component which calls useTheme
|
|
74
90
|
if (!hasChildren) {
|
|
75
91
|
return (React.createElement(ThemeLogicWrapper, { theme: theme, themeOptions: themeOptions !== null && themeOptions !== void 0 ? themeOptions : parentContext === null || parentContext === void 0 ? void 0 : parentContext.themeOptions }));
|
|
@@ -39,25 +39,30 @@ const styles_js_1 = __importStar(require("../../../styles.js"));
|
|
|
39
39
|
// react <18 fallback for useInsertionEffect, with workaround for webpack getting rid of React namespace
|
|
40
40
|
const _React = React;
|
|
41
41
|
const useIsomorphicInsertionEffect = (_a = _React.useInsertionEffect) !== null && _a !== void 0 ? _a : useIsomorphicLayoutEffect_js_1.useIsomorphicLayoutEffect;
|
|
42
|
+
/** This lives outside the hook because we only want to load styles once even when context is not provided. */
|
|
43
|
+
let globalLoaded = false;
|
|
42
44
|
/**
|
|
43
45
|
* Dynamically loads the iTwinUI styles as a constructed stylesheet,
|
|
44
46
|
* falling back to a regular `<style>` tag in `<head>`.
|
|
45
47
|
*/
|
|
46
48
|
const useStyles = (options) => {
|
|
47
|
-
var _a, _b;
|
|
48
49
|
const context = _React.useContext(ThemeProvider_js_1.ThemeContext);
|
|
49
|
-
const loaded = _React.useRef(false);
|
|
50
|
-
const includeCss = (_b = (_a = options === null || options === void 0 ? void 0 : options.includeCss) !== null && _a !== void 0 ? _a : context === null || context === void 0 ? void 0 : context.includeCss) !== null && _b !== void 0 ? _b : { withLayer: true };
|
|
51
50
|
useIsomorphicInsertionEffect(() => {
|
|
52
|
-
var _a;
|
|
53
|
-
|
|
51
|
+
var _a, _b, _c;
|
|
52
|
+
const includeCss = (_b = (_a = options === null || options === void 0 ? void 0 : options.includeCss) !== null && _a !== void 0 ? _a : context === null || context === void 0 ? void 0 : context.includeCss) !== null && _b !== void 0 ? _b : { withLayer: true };
|
|
53
|
+
if ((context === null || context === void 0 ? void 0 : context.stylesLoaded.current) || globalLoaded || !includeCss) {
|
|
54
54
|
return;
|
|
55
55
|
}
|
|
56
56
|
const withLayer = typeof includeCss === 'object' ? includeCss === null || includeCss === void 0 ? void 0 : includeCss.withLayer : false;
|
|
57
|
-
const document = (
|
|
57
|
+
const document = (_c = options === null || options === void 0 ? void 0 : options.document) !== null && _c !== void 0 ? _c : (() => { var _a, _b; return (_b = (_a = context === null || context === void 0 ? void 0 : context.rootRef.current) === null || _a === void 0 ? void 0 : _a.ownerDocument) !== null && _b !== void 0 ? _b : (0, dom_js_1.getDocument)(); });
|
|
58
58
|
loadStyles({ withLayer, document });
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
if (context) {
|
|
60
|
+
context.stylesLoaded.current = true;
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
globalLoaded = true;
|
|
64
|
+
}
|
|
65
|
+
}, [context, options]);
|
|
61
66
|
};
|
|
62
67
|
exports.useStyles = useStyles;
|
|
63
68
|
// ----------------------------------------------------------------------------
|
|
@@ -77,8 +82,8 @@ const loadStyles = ({ withLayer = true, document = () => (0, dom_js_1.getDocumen
|
|
|
77
82
|
: `@charset "utf-8";\n${styles_js_1.revertV1Css}\n${styles_js_1.default}`;
|
|
78
83
|
const supportsAdopting = 'adoptedStyleSheets' in Document.prototype &&
|
|
79
84
|
'replaceSync' in CSSStyleSheet.prototype;
|
|
80
|
-
if (supportsAdopting) {
|
|
81
|
-
const sheet = new CSSStyleSheet();
|
|
85
|
+
if (supportsAdopting && _document.defaultView) {
|
|
86
|
+
const sheet = new _document.defaultView.CSSStyleSheet();
|
|
82
87
|
sheet.replaceSync(cssText);
|
|
83
88
|
_document.adoptedStyleSheets = [..._document.adoptedStyleSheets, sheet];
|
|
84
89
|
}
|
|
@@ -12,7 +12,7 @@ export const SubRowExpander = (props) => {
|
|
|
12
12
|
}, className: 'iui-table-row-expander', styleType: 'borderless', size: 'small', onClick: (e) => {
|
|
13
13
|
e.stopPropagation();
|
|
14
14
|
cell.row.toggleRowExpanded();
|
|
15
|
-
}, disabled: isDisabled }, React.createElement(SvgChevronRight, { style: {
|
|
15
|
+
}, disabled: isDisabled, "aria-expanded": cell.row.isExpanded }, React.createElement(SvgChevronRight, { style: {
|
|
16
16
|
transform: cell.row.isExpanded ? 'rotate(90deg)' : undefined,
|
|
17
17
|
} })))));
|
|
18
18
|
};
|
|
@@ -51,7 +51,7 @@ export const ExpanderColumn = (props = {}) => {
|
|
|
51
51
|
return (React.createElement(IconButton, { className: 'iui-table-row-expander', styleType: 'borderless', size: 'small', onClick: (e) => {
|
|
52
52
|
e.stopPropagation();
|
|
53
53
|
row.toggleRowExpanded();
|
|
54
|
-
}, disabled: isDisabled === null || isDisabled === void 0 ? void 0 : isDisabled(props.row.original) }, React.createElement(SvgChevronRight, null)));
|
|
54
|
+
}, disabled: isDisabled === null || isDisabled === void 0 ? void 0 : isDisabled(props.row.original), "aria-expanded": row.isExpanded }, React.createElement(SvgChevronRight, null)));
|
|
55
55
|
}
|
|
56
56
|
},
|
|
57
57
|
cellRenderer: (props) => (React.createElement(DefaultCell, { ...props, isDisabled: (rowData) => !!(isDisabled === null || isDisabled === void 0 ? void 0 : isDisabled(rowData)) })),
|
|
@@ -33,14 +33,30 @@ import { useStyles } from '../utils/hooks/useStyles.js';
|
|
|
33
33
|
* </ThemeProvider>
|
|
34
34
|
*/
|
|
35
35
|
export const ThemeProvider = React.forwardRef((props, ref) => {
|
|
36
|
-
var _a;
|
|
36
|
+
var _a, _b;
|
|
37
37
|
const { theme: themeProp, children, themeOptions, includeCss = { withLayer: true }, ...rest } = props;
|
|
38
38
|
const rootRef = React.useRef(null);
|
|
39
39
|
const mergedRefs = useMergedRefs(rootRef, ref);
|
|
40
40
|
const hasChildren = React.Children.count(children) > 0;
|
|
41
41
|
const parentContext = React.useContext(ThemeContext);
|
|
42
42
|
const theme = themeProp === 'inherit' ? (_a = parentContext === null || parentContext === void 0 ? void 0 : parentContext.theme) !== null && _a !== void 0 ? _a : 'light' : themeProp;
|
|
43
|
-
const
|
|
43
|
+
const newStylesLoaded = React.useRef(false);
|
|
44
|
+
const stylesLoaded = (_b = parentContext === null || parentContext === void 0 ? void 0 : parentContext.stylesLoaded) !== null && _b !== void 0 ? _b : newStylesLoaded;
|
|
45
|
+
const contextValue = React.useMemo(() => ({
|
|
46
|
+
theme,
|
|
47
|
+
themeOptions,
|
|
48
|
+
rootRef,
|
|
49
|
+
includeCss,
|
|
50
|
+
stylesLoaded,
|
|
51
|
+
}),
|
|
52
|
+
// we do include all dependencies below, but we want to stringify the objects as they could be different on each render
|
|
53
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
54
|
+
[
|
|
55
|
+
theme,
|
|
56
|
+
JSON.stringify(themeOptions),
|
|
57
|
+
JSON.stringify(includeCss),
|
|
58
|
+
stylesLoaded,
|
|
59
|
+
]);
|
|
44
60
|
// if no children, then fallback to this wrapper component which calls useTheme
|
|
45
61
|
if (!hasChildren) {
|
|
46
62
|
return (React.createElement(ThemeLogicWrapper, { theme: theme, themeOptions: themeOptions !== null && themeOptions !== void 0 ? themeOptions : parentContext === null || parentContext === void 0 ? void 0 : parentContext.themeOptions }));
|
|
@@ -13,25 +13,30 @@ import allCss, { revertV1Css } from '../../../styles.js';
|
|
|
13
13
|
// react <18 fallback for useInsertionEffect, with workaround for webpack getting rid of React namespace
|
|
14
14
|
const _React = React;
|
|
15
15
|
const useIsomorphicInsertionEffect = (_a = _React.useInsertionEffect) !== null && _a !== void 0 ? _a : useIsomorphicLayoutEffect;
|
|
16
|
+
/** This lives outside the hook because we only want to load styles once even when context is not provided. */
|
|
17
|
+
let globalLoaded = false;
|
|
16
18
|
/**
|
|
17
19
|
* Dynamically loads the iTwinUI styles as a constructed stylesheet,
|
|
18
20
|
* falling back to a regular `<style>` tag in `<head>`.
|
|
19
21
|
*/
|
|
20
22
|
export const useStyles = (options) => {
|
|
21
|
-
var _a, _b;
|
|
22
23
|
const context = _React.useContext(ThemeContext);
|
|
23
|
-
const loaded = _React.useRef(false);
|
|
24
|
-
const includeCss = (_b = (_a = options === null || options === void 0 ? void 0 : options.includeCss) !== null && _a !== void 0 ? _a : context === null || context === void 0 ? void 0 : context.includeCss) !== null && _b !== void 0 ? _b : { withLayer: true };
|
|
25
24
|
useIsomorphicInsertionEffect(() => {
|
|
26
|
-
var _a;
|
|
27
|
-
|
|
25
|
+
var _a, _b, _c;
|
|
26
|
+
const includeCss = (_b = (_a = options === null || options === void 0 ? void 0 : options.includeCss) !== null && _a !== void 0 ? _a : context === null || context === void 0 ? void 0 : context.includeCss) !== null && _b !== void 0 ? _b : { withLayer: true };
|
|
27
|
+
if ((context === null || context === void 0 ? void 0 : context.stylesLoaded.current) || globalLoaded || !includeCss) {
|
|
28
28
|
return;
|
|
29
29
|
}
|
|
30
30
|
const withLayer = typeof includeCss === 'object' ? includeCss === null || includeCss === void 0 ? void 0 : includeCss.withLayer : false;
|
|
31
|
-
const document = (
|
|
31
|
+
const document = (_c = options === null || options === void 0 ? void 0 : options.document) !== null && _c !== void 0 ? _c : (() => { var _a, _b; return (_b = (_a = context === null || context === void 0 ? void 0 : context.rootRef.current) === null || _a === void 0 ? void 0 : _a.ownerDocument) !== null && _b !== void 0 ? _b : getDocument(); });
|
|
32
32
|
loadStyles({ withLayer, document });
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
if (context) {
|
|
34
|
+
context.stylesLoaded.current = true;
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
globalLoaded = true;
|
|
38
|
+
}
|
|
39
|
+
}, [context, options]);
|
|
35
40
|
};
|
|
36
41
|
// ----------------------------------------------------------------------------
|
|
37
42
|
const layers = `@layer itwinui-v1, itwinui.v1, itwinui.v2, itwinui.v3;`;
|
|
@@ -50,8 +55,8 @@ const loadStyles = ({ withLayer = true, document = () => getDocument() }) => {
|
|
|
50
55
|
: `@charset "utf-8";\n${revertV1Css}\n${allCss}`;
|
|
51
56
|
const supportsAdopting = 'adoptedStyleSheets' in Document.prototype &&
|
|
52
57
|
'replaceSync' in CSSStyleSheet.prototype;
|
|
53
|
-
if (supportsAdopting) {
|
|
54
|
-
const sheet = new CSSStyleSheet();
|
|
58
|
+
if (supportsAdopting && _document.defaultView) {
|
|
59
|
+
const sheet = new _document.defaultView.CSSStyleSheet();
|
|
55
60
|
sheet.replaceSync(cssText);
|
|
56
61
|
_document.adoptedStyleSheets = [..._document.adoptedStyleSheets, sheet];
|
|
57
62
|
}
|