@itwin/itwinui-react 3.11.0 → 3.11.2
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 +20 -0
- package/cjs/core/Breadcrumbs/Breadcrumbs.js +13 -3
- package/cjs/core/Buttons/IconButton.d.ts +1 -1
- package/cjs/core/Carousel/Carousel.d.ts +4 -4
- package/cjs/core/Carousel/CarouselNavigation.d.ts +4 -4
- package/cjs/core/ComboBox/ComboBox.js +2 -2
- package/cjs/core/Header/Header.d.ts +3 -3
- package/cjs/core/Header/Header.js +3 -3
- package/cjs/core/InputWithDecorations/InputWithDecorations.d.ts +1 -1
- package/cjs/core/Table/cells/EditableCell.js +6 -2
- package/cjs/core/ThemeProvider/ThemeProvider.js +26 -16
- package/cjs/core/Tile/Tile.d.ts +2 -2
- package/cjs/utils/providers/ScopeProvider.js +5 -3
- package/esm/core/Breadcrumbs/Breadcrumbs.js +13 -3
- package/esm/core/Buttons/IconButton.d.ts +1 -1
- package/esm/core/Carousel/Carousel.d.ts +4 -4
- package/esm/core/Carousel/CarouselNavigation.d.ts +4 -4
- package/esm/core/ComboBox/ComboBox.js +2 -2
- package/esm/core/Header/Header.d.ts +3 -3
- package/esm/core/Header/Header.js +3 -3
- package/esm/core/InputWithDecorations/InputWithDecorations.d.ts +1 -1
- package/esm/core/Table/cells/EditableCell.js +3 -2
- package/esm/core/ThemeProvider/ThemeProvider.js +26 -16
- package/esm/core/Tile/Tile.d.ts +2 -2
- package/esm/utils/providers/ScopeProvider.js +5 -3
- package/package.json +7 -1
- package/styles.css +1 -1
|
@@ -72,10 +72,13 @@ const Root = React.forwardRef((props, forwardedRef) => {
|
|
|
72
72
|
const shouldApplyDark = theme === 'dark' || (theme === 'os' && prefersDark);
|
|
73
73
|
const shouldApplyHC = themeOptions?.highContrast ?? prefersHighContrast;
|
|
74
74
|
const shouldApplyBackground = themeOptions?.applyBackground;
|
|
75
|
-
const setOwnerDocument =
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
75
|
+
const [ownerDocument, setOwnerDocument] = useScopedAtom(ownerDocumentAtom);
|
|
76
|
+
const findOwnerDocumentFromRef = React.useCallback((el) => {
|
|
77
|
+
if (el && el.ownerDocument !== ownerDocument) {
|
|
78
|
+
setOwnerDocument(el.ownerDocument);
|
|
79
|
+
}
|
|
80
|
+
}, [ownerDocument, setOwnerDocument]);
|
|
81
|
+
return (React.createElement(Box, { className: cx('iui-root', { 'iui-root-background': shouldApplyBackground }, className), "data-iui-theme": shouldApplyDark ? 'dark' : 'light', "data-iui-contrast": shouldApplyHC ? 'high' : 'default', ref: useMergedRefs(forwardedRef, findOwnerDocumentFromRef), ...rest }, children));
|
|
79
82
|
});
|
|
80
83
|
// ----------------------------------------------------------------------------
|
|
81
84
|
/**
|
|
@@ -130,33 +133,40 @@ const useParentThemeAndContext = (rootElement) => {
|
|
|
130
133
|
*/
|
|
131
134
|
const PortalContainer = React.memo(({ portalContainerProp, portalContainerFromParent, isInheritingTheme, }) => {
|
|
132
135
|
const [ownerDocument] = useScopedAtom(ownerDocumentAtom);
|
|
133
|
-
const
|
|
136
|
+
const setPortalContainer = useScopedSetAtom(portalContainerAtom);
|
|
134
137
|
// bail if not hydrated, because portals don't work on server
|
|
135
138
|
const isHydrated = useHydration() === 'hydrated';
|
|
136
139
|
if (!isHydrated) {
|
|
137
140
|
return null;
|
|
138
141
|
}
|
|
142
|
+
if (portalContainerProp) {
|
|
143
|
+
return React.createElement(PortaledToaster, { target: portalContainerProp });
|
|
144
|
+
}
|
|
139
145
|
// Create a new portal container only if necessary:
|
|
140
146
|
// - not inheriting theme
|
|
141
147
|
// - no parent portal container to portal into
|
|
142
148
|
// - parent portal container is in a different window (#2006)
|
|
143
|
-
if (!
|
|
144
|
-
|
|
145
|
-
|
|
149
|
+
if (!isInheritingTheme ||
|
|
150
|
+
!portalContainerFromParent ||
|
|
151
|
+
(!!ownerDocument &&
|
|
146
152
|
portalContainerFromParent.ownerDocument !== ownerDocument)) {
|
|
147
153
|
return (React.createElement("div", { style: { display: 'contents' }, ref: setPortalContainer },
|
|
148
154
|
React.createElement(Toaster, null)));
|
|
149
155
|
}
|
|
150
|
-
|
|
151
|
-
// Synchronize atom with the correct portal container if necessary.
|
|
152
|
-
if (portalTarget && portalTarget !== portalContainer) {
|
|
153
|
-
setPortalContainer(portalTarget);
|
|
154
|
-
}
|
|
155
|
-
return portalTarget
|
|
156
|
-
? ReactDOM.createPortal(React.createElement(Toaster, null), portalTarget)
|
|
157
|
-
: null;
|
|
156
|
+
return React.createElement(PortaledToaster, { target: portalContainerFromParent });
|
|
158
157
|
});
|
|
159
158
|
// ----------------------------------------------------------------------------
|
|
159
|
+
const PortaledToaster = ({ target }) => {
|
|
160
|
+
const [portalContainer, setPortalContainer] = useScopedAtom(portalContainerAtom);
|
|
161
|
+
// Synchronize atom with the correct portal target if necessary.
|
|
162
|
+
React.useEffect(() => {
|
|
163
|
+
if (target && target !== portalContainer) {
|
|
164
|
+
setPortalContainer(target);
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
return target ? ReactDOM.createPortal(React.createElement(Toaster, null), target) : null;
|
|
168
|
+
};
|
|
169
|
+
// ----------------------------------------------------------------------------
|
|
160
170
|
/**
|
|
161
171
|
* When `@itwin/itwinui-react/styles.css` is not imported, we will attempt to
|
|
162
172
|
* dynamically import it (if possible) and fallback to loading it from a CDN.
|
package/esm/core/Tile/Tile.d.ts
CHANGED
|
@@ -249,7 +249,7 @@ export declare const Tile: PolymorphicForwardRefComponent<"div", TileLegacyProps
|
|
|
249
249
|
*/
|
|
250
250
|
IconButton: PolymorphicForwardRefComponent<"button", Omit<Omit<Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
|
|
251
251
|
ref?: ((instance: HTMLButtonElement | null) => void) | React.RefObject<HTMLButtonElement> | null | undefined;
|
|
252
|
-
}, "label" | "as" | "
|
|
252
|
+
}, "label" | "as" | "size" | "htmlDisabled" | "styleType" | "labelProps" | "stretched" | "isActive" | "iconProps"> & {
|
|
253
253
|
isActive?: boolean | undefined;
|
|
254
254
|
label?: React.ReactNode;
|
|
255
255
|
labelProps?: Omit<Omit<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
@@ -323,7 +323,7 @@ export declare const Tile: PolymorphicForwardRefComponent<"div", TileLegacyProps
|
|
|
323
323
|
as?: "div" | undefined;
|
|
324
324
|
}, "ref">, "children" | "content" | "reference" | "ariaStrategy"> | undefined;
|
|
325
325
|
iconProps?: React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement> | undefined;
|
|
326
|
-
} & Omit<import("../Buttons/Button.js").ButtonProps, "startIcon" | "endIcon" | "labelProps" | "startIconProps" | "endIconProps"> & {
|
|
326
|
+
} & Omit<import("../Buttons/Button.js").ButtonProps, "loading" | "startIcon" | "endIcon" | "labelProps" | "startIconProps" | "endIconProps"> & {
|
|
327
327
|
as?: "button" | undefined;
|
|
328
328
|
}, "ref">>;
|
|
329
329
|
/**
|
|
@@ -33,9 +33,11 @@ export const useScopedAtom = (atom) => {
|
|
|
33
33
|
const setAtom = useScopedSetAtom(atom);
|
|
34
34
|
const value = useAtomValue(atom, { store });
|
|
35
35
|
const inheritedValue = useAtomValue(atom, { store: parentStore || store });
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
React.useEffect(() => {
|
|
37
|
+
if (value == undefined && inheritedValue != undefined) {
|
|
38
|
+
setAtom(inheritedValue);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
39
41
|
return [value, setAtom];
|
|
40
42
|
};
|
|
41
43
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/itwinui-react",
|
|
3
|
-
"version": "3.11.
|
|
3
|
+
"version": "3.11.2",
|
|
4
4
|
"author": "Bentley Systems",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -19,6 +19,12 @@
|
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
21
|
"./react-table": {
|
|
22
|
+
"import": {
|
|
23
|
+
"types": "./esm/react-table/react-table.d.ts"
|
|
24
|
+
},
|
|
25
|
+
"require": {
|
|
26
|
+
"types": "./cjs/react-table/react-table.d.ts"
|
|
27
|
+
},
|
|
22
28
|
"types": "./react-table.d.ts"
|
|
23
29
|
},
|
|
24
30
|
"./styles.css": "./styles.css",
|