@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
|
@@ -0,0 +1,68 @@
|
|
|
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
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.useSyncExternalStore = 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"));
|
|
32
|
+
const _React = React; // prevent bundlers from stripping the namespace import
|
|
33
|
+
/**
|
|
34
|
+
* Wrapper around `React.useSyncExternalStore` that uses a shim for React 17.
|
|
35
|
+
*/
|
|
36
|
+
exports.useSyncExternalStore = _React.useSyncExternalStore || useSyncExternalStoreShim;
|
|
37
|
+
// ----------------------------------------------------------------------------
|
|
38
|
+
/**
|
|
39
|
+
* The shim below is adapted from React's source to make it ESM-compatible.
|
|
40
|
+
*
|
|
41
|
+
* Note: This does not use `getServerSnapshot` at all, because there is
|
|
42
|
+
* apparently no way to check "hydrating" state in pre-18.
|
|
43
|
+
*
|
|
44
|
+
* @see https://github.com/facebook/react/tree/main/packages/use-sync-external-store
|
|
45
|
+
*/
|
|
46
|
+
function useSyncExternalStoreShim(subscribe, getSnapshot) {
|
|
47
|
+
const value = getSnapshot();
|
|
48
|
+
const [{ instance }, forceUpdate] = React.useState({
|
|
49
|
+
instance: { value, getSnapshot },
|
|
50
|
+
});
|
|
51
|
+
React.useLayoutEffect(() => {
|
|
52
|
+
instance.value = value;
|
|
53
|
+
instance.getSnapshot = getSnapshot;
|
|
54
|
+
if (!Object.is(value, getSnapshot())) {
|
|
55
|
+
forceUpdate({ instance });
|
|
56
|
+
}
|
|
57
|
+
}, [subscribe, value, getSnapshot]); // eslint-disable-line
|
|
58
|
+
React.useEffect(() => {
|
|
59
|
+
const synchronize = () => {
|
|
60
|
+
if (!Object.is(instance.value, instance.getSnapshot())) {
|
|
61
|
+
forceUpdate({ instance });
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
synchronize();
|
|
65
|
+
return subscribe(synchronize);
|
|
66
|
+
}, [subscribe]); // eslint-disable-line
|
|
67
|
+
return value;
|
|
68
|
+
}
|
package/cjs/core/utils/index.js
CHANGED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Hook that returns the hydration status of the app.
|
|
4
|
+
*
|
|
5
|
+
* @returns one of the following values:
|
|
6
|
+
* - `"hydrated"` after hydration is *definitely* complete (or is a pure client render)
|
|
7
|
+
* - `"hydrating"` if we know for sure that hydration is happening (in React 18)
|
|
8
|
+
* - `undefined` if the hydration status is unknown
|
|
9
|
+
*
|
|
10
|
+
* @private
|
|
11
|
+
*/
|
|
12
|
+
export declare const useHydration: () => "hydrated" | "hydrating" | undefined;
|
|
13
|
+
/** @private */
|
|
14
|
+
export declare const HydrationProvider: ({ children, }: {
|
|
15
|
+
children: React.ReactNode;
|
|
16
|
+
}) => React.JSX.Element;
|
|
@@ -0,0 +1,75 @@
|
|
|
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
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.HydrationProvider = exports.useHydration = 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"));
|
|
32
|
+
const index_js_1 = require("../hooks/index.js");
|
|
33
|
+
const HydrationContext = React.createContext(false);
|
|
34
|
+
const noopSubscribe = () => () => { };
|
|
35
|
+
const isServer = typeof window === 'undefined';
|
|
36
|
+
/**
|
|
37
|
+
* Hook that returns the hydration status of the app.
|
|
38
|
+
*
|
|
39
|
+
* @returns one of the following values:
|
|
40
|
+
* - `"hydrated"` after hydration is *definitely* complete (or is a pure client render)
|
|
41
|
+
* - `"hydrating"` if we know for sure that hydration is happening (in React 18)
|
|
42
|
+
* - `undefined` if the hydration status is unknown
|
|
43
|
+
*
|
|
44
|
+
* @private
|
|
45
|
+
*/
|
|
46
|
+
const useHydration = () => {
|
|
47
|
+
// Returns true only if getServerSnapshot is called on the client.
|
|
48
|
+
// In React 18, this is true during hydration.
|
|
49
|
+
const hydrating = (0, index_js_1.useSyncExternalStore)(noopSubscribe, () => false, () => !isServer);
|
|
50
|
+
// Returns true after hydration is complete (in all React versions).
|
|
51
|
+
const hydrated = React.useContext(HydrationContext);
|
|
52
|
+
const hydratedFallback = (0, index_js_1.useIsClient)();
|
|
53
|
+
if (hydrated || hydratedFallback) {
|
|
54
|
+
return 'hydrated';
|
|
55
|
+
}
|
|
56
|
+
else if (hydrating) {
|
|
57
|
+
return 'hydrating';
|
|
58
|
+
}
|
|
59
|
+
return undefined;
|
|
60
|
+
};
|
|
61
|
+
exports.useHydration = useHydration;
|
|
62
|
+
/** @private */
|
|
63
|
+
const HydrationProvider = ({ children, }) => {
|
|
64
|
+
const [isHydrated, setIsHydrated] = React.useState(React.useContext(HydrationContext));
|
|
65
|
+
const onHydrate = React.useCallback(() => setIsHydrated(true), []);
|
|
66
|
+
return (React.createElement(HydrationContext.Provider, { value: isHydrated },
|
|
67
|
+
!isHydrated ? React.createElement(HydrationCheck, { onHydrate: onHydrate }) : null,
|
|
68
|
+
children));
|
|
69
|
+
};
|
|
70
|
+
exports.HydrationProvider = HydrationProvider;
|
|
71
|
+
/** This is extracted into a child component to ensure it runs first. */
|
|
72
|
+
const HydrationCheck = ({ onHydrate }) => {
|
|
73
|
+
React.useEffect(() => void onHydrate(), [onHydrate]);
|
|
74
|
+
return null;
|
|
75
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './HydrationProvider.js';
|
|
@@ -0,0 +1,21 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
/*---------------------------------------------------------------------------------------------
|
|
18
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
19
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
20
|
+
*--------------------------------------------------------------------------------------------*/
|
|
21
|
+
__exportStar(require("./HydrationProvider.js"), exports);
|
|
@@ -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/esm/core/Table/Table.js
CHANGED
|
@@ -7,7 +7,7 @@ import cx from 'classnames';
|
|
|
7
7
|
import { actions as TableActions, useFlexLayout, useFilters, useRowSelect, useSortBy, useTable, useExpanded, usePagination, useColumnOrder, useGlobalFilter, } from 'react-table';
|
|
8
8
|
import { ProgressRadial } from '../ProgressIndicators/ProgressRadial.js';
|
|
9
9
|
import { useGlobals, useResizeObserver, SvgSortDown, SvgSortUp, useLayoutEffect, Box, createWarningLogger, ShadowRoot, LineClamp, useMergedRefs, } from '../utils/index.js';
|
|
10
|
-
import { getCellStyle, getStickyStyle, getSubRowStyle } from './utils.js';
|
|
10
|
+
import { TableColumnsContext, getCellStyle, getStickyStyle, getSubRowStyle, } from './utils.js';
|
|
11
11
|
import { TableRowMemoized } from './TableRowMemoized.js';
|
|
12
12
|
import { FilterToggle } from './filters/index.js';
|
|
13
13
|
import { customFilterFunctions } from './filters/customFilterFunctions.js';
|
|
@@ -384,7 +384,7 @@ export const Table = (props) => {
|
|
|
384
384
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
385
385
|
}, []);
|
|
386
386
|
const isHeaderDirectClick = React.useRef(false);
|
|
387
|
-
return (React.createElement(
|
|
387
|
+
return (React.createElement(TableColumnsContext.Provider, { value: columns },
|
|
388
388
|
React.createElement(Box, { ref: useMergedRefs(tableRef, (element) => {
|
|
389
389
|
ownerDocument.current = element?.ownerDocument;
|
|
390
390
|
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'>;
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import cx from 'classnames';
|
|
7
7
|
import { Box, LineClamp, ShadowRoot } from '../../utils/index.js';
|
|
8
|
+
import { TableColumnsContext } from '../utils.js';
|
|
8
9
|
/**
|
|
9
10
|
* Default cell.
|
|
10
11
|
* It should be passed to `cellRenderer`.
|
|
@@ -17,7 +18,11 @@ import { Box, LineClamp, ShadowRoot } from '../../utils/index.js';
|
|
|
17
18
|
* }
|
|
18
19
|
*/
|
|
19
20
|
export const DefaultCell = (props) => {
|
|
20
|
-
const
|
|
21
|
+
const columnsProp = React.useContext(TableColumnsContext);
|
|
22
|
+
const isCustomCell = React.useMemo(() => columnsProp
|
|
23
|
+
.find(({ id }) => props.cellProps.column.id === id)
|
|
24
|
+
?.hasOwnProperty('Cell'), [props.cellProps.column.id, columnsProp]);
|
|
25
|
+
const { cellElementProps: { className: cellElementClassName, style: cellElementStyle, ...cellElementProps }, children, startIcon, endIcon, cellProps, isDisabled, className, style, status, clamp = typeof cellProps.value === 'string' && !isCustomCell, ...rest } = props;
|
|
21
26
|
return (React.createElement(Box, { ...cellElementProps, ...rest, className: cx(cellElementClassName, className), "aria-disabled": isDisabled?.(cellProps.row.original) || undefined, "data-iui-status": status, style: { ...cellElementStyle, ...style } },
|
|
22
27
|
React.createElement(ShadowRoot, null,
|
|
23
28
|
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/esm/core/Table/utils.js
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
import * as React from 'react';
|
|
1
6
|
export const getCellStyle = (column, isTableResizing) => {
|
|
2
7
|
const style = {};
|
|
3
8
|
style.flex = `1 1 145px`;
|
|
@@ -59,3 +64,4 @@ export const getSubRowStyle = ({ density = 'default', depth = 1 }) => {
|
|
|
59
64
|
paddingInlineStart: cellPadding + depth * multiplier,
|
|
60
65
|
};
|
|
61
66
|
};
|
|
67
|
+
export const TableColumnsContext = React.createContext([]);
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import * as ReactDOM from 'react-dom';
|
|
7
7
|
import cx from 'classnames';
|
|
8
|
-
import { useMediaQuery, useMergedRefs, Box, useLayoutEffect, useControlledState, useLatestRef, importCss, isUnitTest, } from '../utils/index.js';
|
|
8
|
+
import { useMediaQuery, useMergedRefs, Box, useLayoutEffect, useControlledState, useLatestRef, importCss, isUnitTest, HydrationProvider, } from '../utils/index.js';
|
|
9
9
|
import { ThemeContext } from './ThemeContext.js';
|
|
10
10
|
import { ToastProvider, Toaster } from '../Toast/Toaster.js';
|
|
11
11
|
/**
|
|
@@ -56,13 +56,14 @@ export const ThemeProvider = React.forwardRef((props, forwardedRef) => {
|
|
|
56
56
|
// we do include all dependencies below, but we want to stringify the objects as they could be different on each render
|
|
57
57
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
58
58
|
[theme, JSON.stringify(themeOptions), portalContainer]);
|
|
59
|
-
return (React.createElement(
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
React.createElement(
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
React.createElement(Toaster, null)))
|
|
59
|
+
return (React.createElement(HydrationProvider, null,
|
|
60
|
+
React.createElement(ThemeContext.Provider, { value: contextValue },
|
|
61
|
+
includeCss && rootElement ? (React.createElement(FallbackStyles, { root: rootElement })) : null,
|
|
62
|
+
React.createElement(Root, { theme: theme, themeOptions: themeOptions, ref: useMergedRefs(forwardedRef, setRootElement), ...rest },
|
|
63
|
+
React.createElement(ToastProvider, null,
|
|
64
|
+
children,
|
|
65
|
+
portaledPortalContainer ? (ReactDOM.createPortal(React.createElement(Toaster, null), portaledPortalContainer)) : (React.createElement("div", { ref: setPortalContainer, style: { display: 'contents' } },
|
|
66
|
+
React.createElement(Toaster, null))))))));
|
|
66
67
|
});
|
|
67
68
|
// ----------------------------------------------------------------------------
|
|
68
69
|
const Root = React.forwardRef((props, forwardedRef) => {
|
package/esm/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;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import cx from 'classnames';
|
|
7
|
-
import { useFloating, autoUpdate, offset, flip, shift,
|
|
7
|
+
import { useFloating, autoUpdate, offset, flip, shift, useHover, useFocus, useDismiss, useInteractions, safePolygon, size, autoPlacement, hide, inline, useDelayGroupContext, useDelayGroup, } from '@floating-ui/react';
|
|
8
8
|
import { Box, Portal, cloneElementWithRef, useControlledState, useId, useMergedRefs, } from '../utils/index.js';
|
|
9
9
|
const useTooltip = (options = {}) => {
|
|
10
10
|
const uniqueId = useId();
|
|
@@ -37,10 +37,13 @@ const useTooltip = (options = {}) => {
|
|
|
37
37
|
useHover(floating.context, {
|
|
38
38
|
delay: delay ?? { open: 50, close: 250 },
|
|
39
39
|
handleClose: safePolygon({ buffer: -Infinity }),
|
|
40
|
+
move: false,
|
|
40
41
|
}),
|
|
41
42
|
useFocus(floating.context),
|
|
42
|
-
|
|
43
|
-
|
|
43
|
+
useDismiss(floating.context, {
|
|
44
|
+
referencePress: true,
|
|
45
|
+
referencePressEvent: 'click',
|
|
46
|
+
}),
|
|
44
47
|
]);
|
|
45
48
|
// Manually add attributes and event handlers to external reference element,
|
|
46
49
|
// because we cannot spread getReferenceProps onto it.
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import cx from 'classnames';
|
|
7
|
-
import { Box, ShadowRoot,
|
|
7
|
+
import { Box, ShadowRoot, useHydration } from '../utils/index.js';
|
|
8
8
|
/**
|
|
9
9
|
* Hides content visually but keeps it still accessible to screen readers
|
|
10
10
|
* and other assistive technologies.
|
|
@@ -17,12 +17,12 @@ import { Box, ShadowRoot, useIsClient } from '../utils/index.js';
|
|
|
17
17
|
*/
|
|
18
18
|
export const VisuallyHidden = React.forwardRef((props, ref) => {
|
|
19
19
|
const { as: asProp = 'span', className, unhideOnFocus = true, children: childrenProp, ...rest } = props;
|
|
20
|
-
const
|
|
20
|
+
const isHydrated = useHydration() === 'hydrated';
|
|
21
21
|
// ShadowRoot is not supported on all elements, so we only use it for few common ones.
|
|
22
22
|
const children = !['div', 'span', 'p'].includes(asProp) ? (childrenProp) : (React.createElement(React.Fragment, null,
|
|
23
23
|
React.createElement(ShadowRoot, { css: css },
|
|
24
24
|
React.createElement("slot", null)),
|
|
25
|
-
|
|
25
|
+
isHydrated && childrenProp));
|
|
26
26
|
return (React.createElement(Box, { as: asProp, className: cx('iui-visually-hidden', className), "data-iui-unhide-on-focus": unhideOnFocus ? true : undefined, ref: ref, ...rest }, children));
|
|
27
27
|
});
|
|
28
28
|
// ----------------------------------------------------------------------------
|
|
@@ -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 {};
|