@itwin/itwinui-react 3.7.3 → 3.8.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 +22 -0
- package/cjs/core/Carousel/Carousel.d.ts +6 -42
- package/cjs/core/Carousel/CarouselNavigation.d.ts +4 -4
- package/cjs/core/LabeledSelect/LabeledSelect.d.ts +2 -2
- package/cjs/core/Popover/Popover.d.ts +2 -2
- package/cjs/core/Table/Table.js +1 -1
- package/cjs/core/Table/cells/DefaultCell.d.ts +2 -1
- package/cjs/core/Table/cells/DefaultCell.js +6 -1
- package/cjs/core/Table/utils.d.ts +3 -1
- package/cjs/core/Table/utils.js +30 -1
- package/cjs/core/ThemeProvider/ThemeProvider.js +8 -7
- package/cjs/core/Tile/Tile.d.ts +4 -10
- package/cjs/core/Tooltip/Tooltip.js +5 -2
- package/cjs/core/VisuallyHidden/VisuallyHidden.js +2 -2
- package/cjs/core/utils/components/ShadowRoot.d.ts +6 -4
- package/cjs/core/utils/components/ShadowRoot.js +64 -28
- package/cjs/core/utils/hooks/index.d.ts +1 -0
- package/cjs/core/utils/hooks/index.js +1 -0
- package/cjs/core/utils/hooks/useMediaQuery.d.ts +1 -1
- package/cjs/core/utils/hooks/useMediaQuery.js +11 -26
- package/cjs/core/utils/hooks/useSyncExternalStore.d.ts +5 -0
- package/cjs/core/utils/hooks/useSyncExternalStore.js +68 -0
- package/cjs/core/utils/index.d.ts +1 -0
- package/cjs/core/utils/index.js +1 -0
- package/cjs/core/utils/providers/HydrationProvider.d.ts +16 -0
- package/cjs/core/utils/providers/HydrationProvider.js +75 -0
- package/cjs/core/utils/providers/index.d.ts +1 -0
- package/cjs/core/utils/providers/index.js +21 -0
- package/esm/core/Carousel/Carousel.d.ts +6 -42
- package/esm/core/Carousel/CarouselNavigation.d.ts +4 -4
- package/esm/core/LabeledSelect/LabeledSelect.d.ts +2 -2
- package/esm/core/Popover/Popover.d.ts +2 -2
- package/esm/core/Table/Table.js +2 -2
- package/esm/core/Table/cells/DefaultCell.d.ts +2 -1
- package/esm/core/Table/cells/DefaultCell.js +6 -1
- package/esm/core/Table/utils.d.ts +3 -1
- package/esm/core/Table/utils.js +6 -0
- package/esm/core/ThemeProvider/ThemeProvider.js +9 -8
- package/esm/core/Tile/Tile.d.ts +4 -10
- package/esm/core/Tooltip/Tooltip.js +6 -3
- package/esm/core/VisuallyHidden/VisuallyHidden.js +3 -3
- package/esm/core/utils/components/ShadowRoot.d.ts +6 -4
- package/esm/core/utils/components/ShadowRoot.js +64 -28
- package/esm/core/utils/hooks/index.d.ts +1 -0
- package/esm/core/utils/hooks/index.js +1 -0
- package/esm/core/utils/hooks/useMediaQuery.d.ts +1 -1
- package/esm/core/utils/hooks/useMediaQuery.js +11 -26
- package/esm/core/utils/hooks/useSyncExternalStore.d.ts +5 -0
- package/esm/core/utils/hooks/useSyncExternalStore.js +42 -0
- package/esm/core/utils/index.d.ts +1 -0
- package/esm/core/utils/index.js +1 -0
- package/esm/core/utils/providers/HydrationProvider.d.ts +16 -0
- package/esm/core/utils/providers/HydrationProvider.js +47 -0
- package/esm/core/utils/providers/index.d.ts +1 -0
- package/esm/core/utils/providers/index.js +5 -0
- package/package.json +2 -2
- package/styles.css +1 -677
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 3.8.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#1957](https://github.com/iTwin/iTwinUI/pull/1957): Bumped the minimum required version of `@floating-ui/react` from `^0.26.3` to `^0.26.10`. (Make sure to also update transitive deps!)
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- [#1962](https://github.com/iTwin/iTwinUI/pull/1962): Hydration checks have been added in some components to facilitate showing pure client-rendered content more eagerly.
|
|
12
|
+
- [#1968](https://github.com/iTwin/iTwinUI/pull/1968): Fixed a regression in `Table` where the layout of a custom `Cell` unexpectedly changed from horizontal to vertical.
|
|
13
|
+
|
|
14
|
+
## 3.7.4
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- [#1944](https://github.com/iTwin/iTwinUI/pull/1944): Fixed an issue where `Tooltip` would stay open after clicking on the trigger element. The tooltip will now be correctly dismissed upon click.
|
|
19
|
+
|
|
20
|
+
Also affects other components that use tooltips internally: `IconButton`, `SideNavigation`, etc.
|
|
21
|
+
|
|
22
|
+
- [#1955](https://github.com/iTwin/iTwinUI/pull/1955): Fixed a regression in `Tabs` where the panel content was not occupying the full width of the container.
|
|
23
|
+
- [#1954](https://github.com/iTwin/iTwinUI/pull/1954): Fixed an issue in older Safari versions where visually-hidden styles inside `ProgressRadial` were not being applied.
|
|
24
|
+
|
|
3
25
|
## 3.7.3
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
|
@@ -48,7 +48,7 @@ export declare const Carousel: PolymorphicForwardRefComponent<"section", Carouse
|
|
|
48
48
|
labelProps?: Omit<Omit<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
49
49
|
ref?: ((instance: HTMLDivElement | null) => void) | React.RefObject<HTMLDivElement> | null | undefined;
|
|
50
50
|
}, "as" | "children" | "content" | "portal" | keyof {
|
|
51
|
-
placement?: import("@floating-ui/
|
|
51
|
+
placement?: import("@floating-ui/utils").Placement | undefined;
|
|
52
52
|
visible?: boolean | undefined;
|
|
53
53
|
onVisibleChange?: ((visible: boolean) => void) | undefined;
|
|
54
54
|
autoUpdateOptions?: {
|
|
@@ -71,28 +71,10 @@ export declare const Carousel: PolymorphicForwardRefComponent<"section", Carouse
|
|
|
71
71
|
ariaStrategy?: "label" | "description" | "none" | undefined;
|
|
72
72
|
id?: string | undefined;
|
|
73
73
|
}> & {
|
|
74
|
-
content: React.ReactNode;
|
|
75
|
-
* The Carousel component consists of a set of slides, normally displayed one at a time. A navigation section is
|
|
76
|
-
* shown below the slides, consisting of "dots" and "previous"/"next" buttons, used for changing slides; this navigation
|
|
77
|
-
* section must be present _before_ the slides in DOM order, even though it is visually shown below the slides.
|
|
78
|
-
*
|
|
79
|
-
* The currently shown slide can also be changed using the left/right arrow keys or by dragging on a touch device.
|
|
80
|
-
*
|
|
81
|
-
* This component uses a composition approach so it should be used with the provided subcomponents.
|
|
82
|
-
*
|
|
83
|
-
* @example
|
|
84
|
-
* <Carousel>
|
|
85
|
-
* <Carousel.Navigation />
|
|
86
|
-
* <Carousel.Slider>
|
|
87
|
-
* <Carousel.Slide>...</Carousel.Slide>
|
|
88
|
-
* <Carousel.Slide>...</Carousel.Slide>
|
|
89
|
-
* <Carousel.Slide>...</Carousel.Slide>
|
|
90
|
-
* </Carousel.Slider>
|
|
91
|
-
* </Carousel>
|
|
92
|
-
*/
|
|
74
|
+
content: React.ReactNode;
|
|
93
75
|
children?: React.ReactNode;
|
|
94
76
|
} & import("../utils/index.js").PortalProps & {
|
|
95
|
-
placement?: import("@floating-ui/
|
|
77
|
+
placement?: import("@floating-ui/utils").Placement | undefined;
|
|
96
78
|
visible?: boolean | undefined;
|
|
97
79
|
onVisibleChange?: ((visible: boolean) => void) | undefined;
|
|
98
80
|
autoUpdateOptions?: {
|
|
@@ -129,7 +111,7 @@ export declare const Carousel: PolymorphicForwardRefComponent<"section", Carouse
|
|
|
129
111
|
labelProps?: Omit<Omit<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
130
112
|
ref?: ((instance: HTMLDivElement | null) => void) | React.RefObject<HTMLDivElement> | null | undefined;
|
|
131
113
|
}, "as" | "children" | "content" | "portal" | keyof {
|
|
132
|
-
placement?: import("@floating-ui/
|
|
114
|
+
placement?: import("@floating-ui/utils").Placement | undefined;
|
|
133
115
|
visible?: boolean | undefined;
|
|
134
116
|
onVisibleChange?: ((visible: boolean) => void) | undefined;
|
|
135
117
|
autoUpdateOptions?: {
|
|
@@ -152,28 +134,10 @@ export declare const Carousel: PolymorphicForwardRefComponent<"section", Carouse
|
|
|
152
134
|
ariaStrategy?: "label" | "description" | "none" | undefined;
|
|
153
135
|
id?: string | undefined;
|
|
154
136
|
}> & {
|
|
155
|
-
content: React.ReactNode;
|
|
156
|
-
* The Carousel component consists of a set of slides, normally displayed one at a time. A navigation section is
|
|
157
|
-
* shown below the slides, consisting of "dots" and "previous"/"next" buttons, used for changing slides; this navigation
|
|
158
|
-
* section must be present _before_ the slides in DOM order, even though it is visually shown below the slides.
|
|
159
|
-
*
|
|
160
|
-
* The currently shown slide can also be changed using the left/right arrow keys or by dragging on a touch device.
|
|
161
|
-
*
|
|
162
|
-
* This component uses a composition approach so it should be used with the provided subcomponents.
|
|
163
|
-
*
|
|
164
|
-
* @example
|
|
165
|
-
* <Carousel>
|
|
166
|
-
* <Carousel.Navigation />
|
|
167
|
-
* <Carousel.Slider>
|
|
168
|
-
* <Carousel.Slide>...</Carousel.Slide>
|
|
169
|
-
* <Carousel.Slide>...</Carousel.Slide>
|
|
170
|
-
* <Carousel.Slide>...</Carousel.Slide>
|
|
171
|
-
* </Carousel.Slider>
|
|
172
|
-
* </Carousel>
|
|
173
|
-
*/
|
|
137
|
+
content: React.ReactNode;
|
|
174
138
|
children?: React.ReactNode;
|
|
175
139
|
} & import("../utils/index.js").PortalProps & {
|
|
176
|
-
placement?: import("@floating-ui/
|
|
140
|
+
placement?: import("@floating-ui/utils").Placement | undefined;
|
|
177
141
|
visible?: boolean | undefined;
|
|
178
142
|
onVisibleChange?: ((visible: boolean) => void) | undefined;
|
|
179
143
|
autoUpdateOptions?: {
|
|
@@ -15,7 +15,7 @@ export declare const CarouselNavigation: PolymorphicForwardRefComponent<"div", {
|
|
|
15
15
|
labelProps?: Omit<Omit<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
16
16
|
ref?: ((instance: HTMLDivElement | null) => void) | React.RefObject<HTMLDivElement> | null | undefined;
|
|
17
17
|
}, "as" | "children" | "content" | "portal" | keyof {
|
|
18
|
-
placement?: import("@floating-ui/
|
|
18
|
+
placement?: import("@floating-ui/utils").Placement | undefined;
|
|
19
19
|
visible?: boolean | undefined;
|
|
20
20
|
onVisibleChange?: ((visible: boolean) => void) | undefined;
|
|
21
21
|
autoUpdateOptions?: {
|
|
@@ -41,7 +41,7 @@ export declare const CarouselNavigation: PolymorphicForwardRefComponent<"div", {
|
|
|
41
41
|
content: React.ReactNode;
|
|
42
42
|
children?: React.ReactNode;
|
|
43
43
|
} & import("../utils/index.js").PortalProps & {
|
|
44
|
-
placement?: import("@floating-ui/
|
|
44
|
+
placement?: import("@floating-ui/utils").Placement | undefined;
|
|
45
45
|
visible?: boolean | undefined;
|
|
46
46
|
onVisibleChange?: ((visible: boolean) => void) | undefined;
|
|
47
47
|
autoUpdateOptions?: {
|
|
@@ -78,7 +78,7 @@ export declare const CarouselNavigation: PolymorphicForwardRefComponent<"div", {
|
|
|
78
78
|
labelProps?: Omit<Omit<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
79
79
|
ref?: ((instance: HTMLDivElement | null) => void) | React.RefObject<HTMLDivElement> | null | undefined;
|
|
80
80
|
}, "as" | "children" | "content" | "portal" | keyof {
|
|
81
|
-
placement?: import("@floating-ui/
|
|
81
|
+
placement?: import("@floating-ui/utils").Placement | undefined;
|
|
82
82
|
visible?: boolean | undefined;
|
|
83
83
|
onVisibleChange?: ((visible: boolean) => void) | undefined;
|
|
84
84
|
autoUpdateOptions?: {
|
|
@@ -104,7 +104,7 @@ export declare const CarouselNavigation: PolymorphicForwardRefComponent<"div", {
|
|
|
104
104
|
content: React.ReactNode;
|
|
105
105
|
children?: React.ReactNode;
|
|
106
106
|
} & import("../utils/index.js").PortalProps & {
|
|
107
|
-
placement?: import("@floating-ui/
|
|
107
|
+
placement?: import("@floating-ui/utils").Placement | undefined;
|
|
108
108
|
visible?: boolean | undefined;
|
|
109
109
|
onVisibleChange?: ((visible: boolean) => void) | undefined;
|
|
110
110
|
autoUpdateOptions?: {
|
|
@@ -297,7 +297,7 @@ export declare const LabeledSelect: <T>(props: ({
|
|
|
297
297
|
menuClassName?: string | undefined;
|
|
298
298
|
menuStyle?: React.CSSProperties | undefined;
|
|
299
299
|
popoverProps?: Pick<{
|
|
300
|
-
placement?: import("@floating-ui/
|
|
300
|
+
placement?: import("@floating-ui/utils").Placement | undefined;
|
|
301
301
|
visible?: boolean | undefined;
|
|
302
302
|
onVisibleChange?: ((visible: boolean) => void) | undefined;
|
|
303
303
|
closeOnOutsideClick?: boolean | undefined;
|
|
@@ -427,7 +427,7 @@ export declare const LabeledSelect: <T>(props: ({
|
|
|
427
427
|
menuClassName?: string | undefined;
|
|
428
428
|
menuStyle?: React.CSSProperties | undefined;
|
|
429
429
|
popoverProps?: Pick<{
|
|
430
|
-
placement?: import("@floating-ui/
|
|
430
|
+
placement?: import("@floating-ui/utils").Placement | undefined;
|
|
431
431
|
visible?: boolean | undefined;
|
|
432
432
|
onVisibleChange?: ((visible: boolean) => void) | undefined;
|
|
433
433
|
closeOnOutsideClick?: boolean | undefined;
|
|
@@ -71,7 +71,7 @@ type PopoverInternalProps = {
|
|
|
71
71
|
};
|
|
72
72
|
export declare const usePopover: (options: PopoverOptions & PopoverInternalProps) => {
|
|
73
73
|
placement: Placement;
|
|
74
|
-
strategy: import("@floating-ui/
|
|
74
|
+
strategy: import("@floating-ui/utils").Strategy;
|
|
75
75
|
middlewareData: import("@floating-ui/core").MiddlewareData;
|
|
76
76
|
x: number;
|
|
77
77
|
y: number;
|
|
@@ -92,7 +92,7 @@ export declare const usePopover: (options: PopoverOptions & PopoverInternalProps
|
|
|
92
92
|
x: number;
|
|
93
93
|
y: number;
|
|
94
94
|
placement: Placement;
|
|
95
|
-
strategy: import("@floating-ui/
|
|
95
|
+
strategy: import("@floating-ui/utils").Strategy;
|
|
96
96
|
middlewareData: import("@floating-ui/core").MiddlewareData;
|
|
97
97
|
isPositioned: boolean;
|
|
98
98
|
update: () => void;
|
package/cjs/core/Table/Table.js
CHANGED
|
@@ -413,7 +413,7 @@ const Table = (props) => {
|
|
|
413
413
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
414
414
|
}, []);
|
|
415
415
|
const isHeaderDirectClick = React.useRef(false);
|
|
416
|
-
return (React.createElement(
|
|
416
|
+
return (React.createElement(utils_js_1.TableColumnsContext.Provider, { value: columns },
|
|
417
417
|
React.createElement(index_js_1.Box, { ref: (0, index_js_1.useMergedRefs)(tableRef, (element) => {
|
|
418
418
|
ownerDocument.current = element?.ownerDocument;
|
|
419
419
|
resizeRef(element);
|
|
@@ -16,7 +16,8 @@ export type DefaultCellProps<T extends Record<string, unknown>> = {
|
|
|
16
16
|
/**
|
|
17
17
|
* Should the contents of the cell be clamped after a certain number of lines?
|
|
18
18
|
*
|
|
19
|
-
* Will be enabled by default if the cell content is a string
|
|
19
|
+
* Will be enabled by default if the cell content is a string and a custom `Cell`
|
|
20
|
+
* is not specified in the column object.
|
|
20
21
|
*/
|
|
21
22
|
clamp?: boolean;
|
|
22
23
|
} & CellRendererProps<T> & React.ComponentPropsWithoutRef<'div'>;
|
|
@@ -34,6 +34,7 @@ exports.DefaultCell = void 0;
|
|
|
34
34
|
const React = __importStar(require("react"));
|
|
35
35
|
const classnames_1 = __importDefault(require("classnames"));
|
|
36
36
|
const index_js_1 = require("../../utils/index.js");
|
|
37
|
+
const utils_js_1 = require("../utils.js");
|
|
37
38
|
/**
|
|
38
39
|
* Default cell.
|
|
39
40
|
* It should be passed to `cellRenderer`.
|
|
@@ -46,7 +47,11 @@ const index_js_1 = require("../../utils/index.js");
|
|
|
46
47
|
* }
|
|
47
48
|
*/
|
|
48
49
|
const DefaultCell = (props) => {
|
|
49
|
-
const
|
|
50
|
+
const columnsProp = React.useContext(utils_js_1.TableColumnsContext);
|
|
51
|
+
const isCustomCell = React.useMemo(() => columnsProp
|
|
52
|
+
.find(({ id }) => props.cellProps.column.id === id)
|
|
53
|
+
?.hasOwnProperty('Cell'), [props.cellProps.column.id, columnsProp]);
|
|
54
|
+
const { cellElementProps: { className: cellElementClassName, style: cellElementStyle, ...cellElementProps }, children, startIcon, endIcon, cellProps, isDisabled, className, style, status, clamp = typeof cellProps.value === 'string' && !isCustomCell, ...rest } = props;
|
|
50
55
|
return (React.createElement(index_js_1.Box, { ...cellElementProps, ...rest, className: (0, classnames_1.default)(cellElementClassName, className), "aria-disabled": isDisabled?.(cellProps.row.original) || undefined, "data-iui-status": status, style: { ...cellElementStyle, ...style } },
|
|
51
56
|
React.createElement(index_js_1.ShadowRoot, null,
|
|
52
57
|
React.createElement("slot", { name: 'start' }),
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { ColumnInstance, Column } from '../../react-table/react-table.js';
|
|
2
3
|
export declare const getCellStyle: <T extends Record<string, unknown>>(column: ColumnInstance<T>, isTableResizing: boolean) => React.CSSProperties | undefined;
|
|
3
4
|
export declare const getStickyStyle: <T extends Record<string, unknown>>(column: ColumnInstance<T>, columnList: ColumnInstance<T>[]) => React.CSSProperties;
|
|
4
5
|
export declare const getSubRowStyle: ({ density, depth }: {
|
|
@@ -7,3 +8,4 @@ export declare const getSubRowStyle: ({ density, depth }: {
|
|
|
7
8
|
}) => {
|
|
8
9
|
paddingInlineStart: number;
|
|
9
10
|
};
|
|
11
|
+
export declare const TableColumnsContext: React.Context<Column[]>;
|
package/cjs/core/Table/utils.js
CHANGED
|
@@ -1,6 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getSubRowStyle = exports.getStickyStyle = exports.getCellStyle = void 0;
|
|
26
|
+
exports.TableColumnsContext = exports.getSubRowStyle = exports.getStickyStyle = exports.getCellStyle = void 0;
|
|
27
|
+
/*---------------------------------------------------------------------------------------------
|
|
28
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
29
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
30
|
+
*--------------------------------------------------------------------------------------------*/
|
|
31
|
+
const React = __importStar(require("react"));
|
|
4
32
|
const getCellStyle = (column, isTableResizing) => {
|
|
5
33
|
const style = {};
|
|
6
34
|
style.flex = `1 1 145px`;
|
|
@@ -65,3 +93,4 @@ const getSubRowStyle = ({ density = 'default', depth = 1 }) => {
|
|
|
65
93
|
};
|
|
66
94
|
};
|
|
67
95
|
exports.getSubRowStyle = getSubRowStyle;
|
|
96
|
+
exports.TableColumnsContext = React.createContext([]);
|
|
@@ -85,13 +85,14 @@ exports.ThemeProvider = React.forwardRef((props, forwardedRef) => {
|
|
|
85
85
|
// we do include all dependencies below, but we want to stringify the objects as they could be different on each render
|
|
86
86
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
87
87
|
[theme, JSON.stringify(themeOptions), portalContainer]);
|
|
88
|
-
return (React.createElement(
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
React.createElement(
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
React.createElement(Toaster_js_1.Toaster, null)))
|
|
88
|
+
return (React.createElement(index_js_1.HydrationProvider, null,
|
|
89
|
+
React.createElement(ThemeContext_js_1.ThemeContext.Provider, { value: contextValue },
|
|
90
|
+
includeCss && rootElement ? (React.createElement(FallbackStyles, { root: rootElement })) : null,
|
|
91
|
+
React.createElement(Root, { theme: theme, themeOptions: themeOptions, ref: (0, index_js_1.useMergedRefs)(forwardedRef, setRootElement), ...rest },
|
|
92
|
+
React.createElement(Toaster_js_1.ToastProvider, null,
|
|
93
|
+
children,
|
|
94
|
+
portaledPortalContainer ? (ReactDOM.createPortal(React.createElement(Toaster_js_1.Toaster, null), portaledPortalContainer)) : (React.createElement("div", { ref: setPortalContainer, style: { display: 'contents' } },
|
|
95
|
+
React.createElement(Toaster_js_1.Toaster, null))))))));
|
|
95
96
|
});
|
|
96
97
|
// ----------------------------------------------------------------------------
|
|
97
98
|
const Root = React.forwardRef((props, forwardedRef) => {
|
package/cjs/core/Tile/Tile.d.ts
CHANGED
|
@@ -255,15 +255,12 @@ export declare const Tile: PolymorphicForwardRefComponent<"div", TileLegacyProps
|
|
|
255
255
|
labelProps?: Omit<Omit<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
256
256
|
ref?: ((instance: HTMLDivElement | null) => void) | React.RefObject<HTMLDivElement> | null | undefined;
|
|
257
257
|
}, "as" | "children" | "content" | "portal" | keyof {
|
|
258
|
-
placement?: import("@floating-ui/
|
|
258
|
+
placement?: import("@floating-ui/utils").Placement | undefined;
|
|
259
259
|
visible?: boolean | undefined;
|
|
260
260
|
onVisibleChange?: ((visible: boolean) => void) | undefined;
|
|
261
261
|
autoUpdateOptions?: {
|
|
262
262
|
ancestorScroll?: boolean | undefined;
|
|
263
|
-
ancestorResize?: boolean | undefined;
|
|
264
|
-
* Display a loading state.
|
|
265
|
-
* @default false
|
|
266
|
-
*/
|
|
263
|
+
ancestorResize?: boolean | undefined;
|
|
267
264
|
elementResize?: boolean | undefined;
|
|
268
265
|
animationFrame?: boolean | undefined;
|
|
269
266
|
layoutShift?: boolean | undefined;
|
|
@@ -284,15 +281,12 @@ export declare const Tile: PolymorphicForwardRefComponent<"div", TileLegacyProps
|
|
|
284
281
|
content: React.ReactNode;
|
|
285
282
|
children?: React.ReactNode;
|
|
286
283
|
} & import("../utils/index.js").PortalProps & {
|
|
287
|
-
placement?: import("@floating-ui/
|
|
284
|
+
placement?: import("@floating-ui/utils").Placement | undefined;
|
|
288
285
|
visible?: boolean | undefined;
|
|
289
286
|
onVisibleChange?: ((visible: boolean) => void) | undefined;
|
|
290
287
|
autoUpdateOptions?: {
|
|
291
288
|
ancestorScroll?: boolean | undefined;
|
|
292
|
-
ancestorResize?: boolean | undefined;
|
|
293
|
-
* Display a loading state.
|
|
294
|
-
* @default false
|
|
295
|
-
*/
|
|
289
|
+
ancestorResize?: boolean | undefined;
|
|
296
290
|
elementResize?: boolean | undefined;
|
|
297
291
|
animationFrame?: boolean | undefined;
|
|
298
292
|
layoutShift?: boolean | undefined;
|
|
@@ -66,10 +66,13 @@ const useTooltip = (options = {}) => {
|
|
|
66
66
|
(0, react_1.useHover)(floating.context, {
|
|
67
67
|
delay: delay ?? { open: 50, close: 250 },
|
|
68
68
|
handleClose: (0, react_1.safePolygon)({ buffer: -Infinity }),
|
|
69
|
+
move: false,
|
|
69
70
|
}),
|
|
70
71
|
(0, react_1.useFocus)(floating.context),
|
|
71
|
-
(0, react_1.
|
|
72
|
-
|
|
72
|
+
(0, react_1.useDismiss)(floating.context, {
|
|
73
|
+
referencePress: true,
|
|
74
|
+
referencePressEvent: 'click',
|
|
75
|
+
}),
|
|
73
76
|
]);
|
|
74
77
|
// Manually add attributes and event handlers to external reference element,
|
|
75
78
|
// because we cannot spread getReferenceProps onto it.
|
|
@@ -46,12 +46,12 @@ const index_js_1 = require("../utils/index.js");
|
|
|
46
46
|
*/
|
|
47
47
|
exports.VisuallyHidden = React.forwardRef((props, ref) => {
|
|
48
48
|
const { as: asProp = 'span', className, unhideOnFocus = true, children: childrenProp, ...rest } = props;
|
|
49
|
-
const
|
|
49
|
+
const isHydrated = (0, index_js_1.useHydration)() === 'hydrated';
|
|
50
50
|
// ShadowRoot is not supported on all elements, so we only use it for few common ones.
|
|
51
51
|
const children = !['div', 'span', 'p'].includes(asProp) ? (childrenProp) : (React.createElement(React.Fragment, null,
|
|
52
52
|
React.createElement(index_js_1.ShadowRoot, { css: css },
|
|
53
53
|
React.createElement("slot", null)),
|
|
54
|
-
|
|
54
|
+
isHydrated && childrenProp));
|
|
55
55
|
return (React.createElement(index_js_1.Box, { as: asProp, className: (0, classnames_1.default)('iui-visually-hidden', className), "data-iui-unhide-on-focus": unhideOnFocus ? true : undefined, ref: ref, ...rest }, children));
|
|
56
56
|
});
|
|
57
57
|
// ----------------------------------------------------------------------------
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
type ShadowRootProps = {
|
|
3
|
+
children: React.ReactNode;
|
|
4
|
+
css?: string;
|
|
5
|
+
};
|
|
2
6
|
/**
|
|
3
7
|
* Wrapper around `<template>` element that attaches shadow root to its parent
|
|
4
8
|
* and moves its children into the shadow root.
|
|
5
9
|
*
|
|
6
10
|
* @private
|
|
7
11
|
*/
|
|
8
|
-
export declare const ShadowRoot: ({ children, css
|
|
9
|
-
|
|
10
|
-
css?: string | undefined;
|
|
11
|
-
}) => React.JSX.Element | null;
|
|
12
|
+
export declare const ShadowRoot: ({ children, css }: ShadowRootProps) => React.JSX.Element | null;
|
|
13
|
+
export {};
|
|
@@ -30,6 +30,8 @@ exports.ShadowRoot = void 0;
|
|
|
30
30
|
*--------------------------------------------------------------------------------------------*/
|
|
31
31
|
const React = __importStar(require("react"));
|
|
32
32
|
const ReactDOM = __importStar(require("react-dom"));
|
|
33
|
+
const index_js_1 = require("../hooks/index.js");
|
|
34
|
+
const index_js_2 = require("../providers/index.js");
|
|
33
35
|
const isBrowser = typeof document !== 'undefined';
|
|
34
36
|
const supportsDSD = isBrowser && 'shadowRootMode' in HTMLTemplateElement.prototype;
|
|
35
37
|
const supportsAdoptedStylesheets = isBrowser && 'adoptedStyleSheets' in Document.prototype;
|
|
@@ -39,28 +41,8 @@ const supportsAdoptedStylesheets = isBrowser && 'adoptedStyleSheets' in Document
|
|
|
39
41
|
*
|
|
40
42
|
* @private
|
|
41
43
|
*/
|
|
42
|
-
const ShadowRoot = ({ children, css
|
|
43
|
-
const
|
|
44
|
-
const isFirstRender = useIsFirstRender();
|
|
45
|
-
const styleSheet = React.useRef();
|
|
46
|
-
const attachShadowRef = React.useCallback((template) => {
|
|
47
|
-
const parent = template?.parentElement;
|
|
48
|
-
if (!template || !parent) {
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
if (parent.shadowRoot) {
|
|
52
|
-
parent.shadowRoot.replaceChildren(); // Remove previous shadowroot content
|
|
53
|
-
}
|
|
54
|
-
queueMicrotask(() => {
|
|
55
|
-
const shadow = parent.shadowRoot || parent.attachShadow({ mode: 'open' });
|
|
56
|
-
if (css && supportsAdoptedStylesheets) {
|
|
57
|
-
styleSheet.current || (styleSheet.current = new CSSStyleSheet());
|
|
58
|
-
styleSheet.current.replaceSync(css);
|
|
59
|
-
shadow.adoptedStyleSheets = [styleSheet.current];
|
|
60
|
-
}
|
|
61
|
-
ReactDOM.flushSync(() => setShadowRoot(shadow));
|
|
62
|
-
});
|
|
63
|
-
}, [css]);
|
|
44
|
+
const ShadowRoot = ({ children, css }) => {
|
|
45
|
+
const isHydrating = (0, index_js_2.useHydration)() === 'hydrating';
|
|
64
46
|
if (!isBrowser) {
|
|
65
47
|
return (React.createElement("template", { shadowrootmode: 'open' },
|
|
66
48
|
css && React.createElement("style", null, css),
|
|
@@ -68,15 +50,69 @@ const ShadowRoot = ({ children, css, }) => {
|
|
|
68
50
|
}
|
|
69
51
|
// In browsers that support DSD, the template will be automatically removed as soon as it's parsed.
|
|
70
52
|
// To pass hydration, the first client render needs to emulate this browser behavior and return null.
|
|
71
|
-
if (supportsDSD &&
|
|
53
|
+
if (supportsDSD && isHydrating) {
|
|
72
54
|
return null;
|
|
73
55
|
}
|
|
74
|
-
return
|
|
56
|
+
return React.createElement(ClientShadowRoot, { css: css }, children);
|
|
75
57
|
};
|
|
76
58
|
exports.ShadowRoot = ShadowRoot;
|
|
77
59
|
// ----------------------------------------------------------------------------
|
|
78
|
-
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
|
|
60
|
+
const ClientShadowRoot = ({ children, css }) => {
|
|
61
|
+
const templateRef = React.useRef(null);
|
|
62
|
+
const shadowRoot = useShadowRoot(templateRef, { css });
|
|
63
|
+
// fallback to <style> tag if adoptedStyleSheets is not supported
|
|
64
|
+
const fallbackCss = !supportsAdoptedStylesheets && css ? React.createElement("style", null, css) : null;
|
|
65
|
+
return shadowRoot ? (ReactDOM.createPortal(React.createElement(React.Fragment, null,
|
|
66
|
+
fallbackCss,
|
|
67
|
+
children), shadowRoot)) : (React.createElement("template", { ref: templateRef }));
|
|
68
|
+
};
|
|
69
|
+
// ----------------------------------------------------------------------------
|
|
70
|
+
/**
|
|
71
|
+
* Given a ref, this hook will return a shadowRoot attached to its parent element.
|
|
72
|
+
*
|
|
73
|
+
* The css will be added to the shadowRoot using `adoptedStyleSheets` (if supported).
|
|
74
|
+
*/
|
|
75
|
+
function useShadowRoot(templateRef, { css = '' }) {
|
|
76
|
+
const [shadowRoot, setShadowRoot] = React.useState(null);
|
|
77
|
+
const styleSheet = React.useRef();
|
|
78
|
+
const latestCss = (0, index_js_1.useLatestRef)(css);
|
|
79
|
+
const latestShadowRoot = (0, index_js_1.useLatestRef)(shadowRoot);
|
|
80
|
+
(0, index_js_1.useLayoutEffect)(() => {
|
|
81
|
+
const parent = templateRef.current?.parentElement;
|
|
82
|
+
if (!parent) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
const setupOrReuseShadowRoot = () => {
|
|
86
|
+
if (parent.shadowRoot && latestShadowRoot.current === null) {
|
|
87
|
+
parent.shadowRoot.replaceChildren(); // Remove previous shadowroot content
|
|
88
|
+
}
|
|
89
|
+
const shadow = parent.shadowRoot || parent.attachShadow({ mode: 'open' });
|
|
90
|
+
if (supportsAdoptedStylesheets) {
|
|
91
|
+
// create an empty stylesheet and add it to the shadowRoot
|
|
92
|
+
const currentWindow = shadow.ownerDocument.defaultView || globalThis;
|
|
93
|
+
styleSheet.current = new currentWindow.CSSStyleSheet();
|
|
94
|
+
shadow.adoptedStyleSheets = [styleSheet.current];
|
|
95
|
+
// add the CSS immediately to avoid FOUC (one-time)
|
|
96
|
+
if (latestCss.current) {
|
|
97
|
+
styleSheet.current.replaceSync(latestCss.current);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
// Flush the state immediately after shadow-root is attached, to ensure that layout
|
|
101
|
+
// measurements in parent component are correct.
|
|
102
|
+
// Without this, the parent component may end up measuring the layout when the shadow-root
|
|
103
|
+
// is attached in the DOM but React hasn't rendered any slots or content into it yet.
|
|
104
|
+
ReactDOM.flushSync(() => setShadowRoot(shadow));
|
|
105
|
+
};
|
|
106
|
+
queueMicrotask(() => {
|
|
107
|
+
setupOrReuseShadowRoot();
|
|
108
|
+
});
|
|
109
|
+
return () => void setShadowRoot(null);
|
|
110
|
+
}, [templateRef, latestCss, latestShadowRoot]);
|
|
111
|
+
// Synchronize `css` with contents of the existing stylesheet
|
|
112
|
+
(0, index_js_1.useLayoutEffect)(() => {
|
|
113
|
+
if (css && supportsAdoptedStylesheets) {
|
|
114
|
+
styleSheet.current?.replaceSync(css);
|
|
115
|
+
}
|
|
116
|
+
}, [css]);
|
|
117
|
+
return shadowRoot;
|
|
82
118
|
}
|
|
@@ -32,3 +32,4 @@ __exportStar(require("./useIsomorphicLayoutEffect.js"), exports);
|
|
|
32
32
|
__exportStar(require("./useIsClient.js"), exports);
|
|
33
33
|
__exportStar(require("./useId.js"), exports);
|
|
34
34
|
__exportStar(require("./useControlledState.js"), exports);
|
|
35
|
+
__exportStar(require("./useSyncExternalStore.js"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const useMediaQuery: (queryString: string) => boolean;
|
|
1
|
+
export declare const useMediaQuery: (queryString: string) => boolean | undefined;
|
|
@@ -29,33 +29,18 @@ exports.useMediaQuery = void 0;
|
|
|
29
29
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
30
30
|
*--------------------------------------------------------------------------------------------*/
|
|
31
31
|
const React = __importStar(require("react"));
|
|
32
|
-
const
|
|
33
|
-
const useIsomorphicLayoutEffect_js_1 = require("./useIsomorphicLayoutEffect.js");
|
|
32
|
+
const useSyncExternalStore_js_1 = require("./useSyncExternalStore.js");
|
|
34
33
|
const useMediaQuery = (queryString) => {
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
if (mediaQueryList != undefined) {
|
|
40
|
-
setMatches(mediaQueryList.matches);
|
|
41
|
-
try {
|
|
42
|
-
mediaQueryList.addEventListener('change', handleChange);
|
|
43
|
-
}
|
|
44
|
-
catch {
|
|
45
|
-
// Safari 13 fallback
|
|
46
|
-
mediaQueryList.addListener?.(handleChange);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
return () => {
|
|
50
|
-
try {
|
|
51
|
-
mediaQueryList?.removeEventListener('change', handleChange);
|
|
52
|
-
}
|
|
53
|
-
catch {
|
|
54
|
-
// Safari 13 fallback
|
|
55
|
-
mediaQueryList?.removeListener?.(handleChange);
|
|
56
|
-
}
|
|
57
|
-
};
|
|
34
|
+
const getSnapshot = React.useCallback(() => {
|
|
35
|
+
return typeof window !== 'undefined'
|
|
36
|
+
? window.matchMedia?.(queryString).matches
|
|
37
|
+
: undefined;
|
|
58
38
|
}, [queryString]);
|
|
59
|
-
|
|
39
|
+
const subscribe = React.useCallback((onChange) => {
|
|
40
|
+
const mediaQueryList = window.matchMedia?.(queryString);
|
|
41
|
+
mediaQueryList?.addEventListener?.('change', onChange);
|
|
42
|
+
return () => mediaQueryList?.removeEventListener?.('change', onChange);
|
|
43
|
+
}, [queryString]);
|
|
44
|
+
return (0, useSyncExternalStore_js_1.useSyncExternalStore)(subscribe, getSnapshot, () => undefined);
|
|
60
45
|
};
|
|
61
46
|
exports.useMediaQuery = useMediaQuery;
|