@itwin/itwinui-react 3.7.4 → 3.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/cjs/core/Carousel/Carousel.d.ts +4 -4
  3. package/cjs/core/Carousel/CarouselNavigation.d.ts +4 -4
  4. package/cjs/core/InformationPanel/InformationPanel.js +10 -5
  5. package/cjs/core/LabeledSelect/LabeledSelect.d.ts +2 -2
  6. package/cjs/core/Popover/Popover.d.ts +2 -2
  7. package/cjs/core/Table/Table.js +1 -1
  8. package/cjs/core/Table/cells/DefaultCell.d.ts +2 -1
  9. package/cjs/core/Table/cells/DefaultCell.js +6 -1
  10. package/cjs/core/Table/utils.d.ts +3 -1
  11. package/cjs/core/Table/utils.js +30 -1
  12. package/cjs/core/ThemeProvider/ThemeProvider.js +8 -7
  13. package/cjs/core/Tile/Tile.d.ts +2 -2
  14. package/cjs/core/VisuallyHidden/VisuallyHidden.js +2 -2
  15. package/cjs/core/utils/components/ShadowRoot.js +26 -24
  16. package/cjs/core/utils/hooks/index.d.ts +1 -0
  17. package/cjs/core/utils/hooks/index.js +1 -0
  18. package/cjs/core/utils/hooks/useMediaQuery.d.ts +1 -1
  19. package/cjs/core/utils/hooks/useMediaQuery.js +11 -26
  20. package/cjs/core/utils/hooks/useSyncExternalStore.d.ts +5 -0
  21. package/cjs/core/utils/hooks/useSyncExternalStore.js +68 -0
  22. package/cjs/core/utils/index.d.ts +1 -0
  23. package/cjs/core/utils/index.js +1 -0
  24. package/cjs/core/utils/providers/HydrationProvider.d.ts +16 -0
  25. package/cjs/core/utils/providers/HydrationProvider.js +75 -0
  26. package/cjs/core/utils/providers/index.d.ts +1 -0
  27. package/cjs/core/utils/providers/index.js +21 -0
  28. package/esm/core/Carousel/Carousel.d.ts +4 -4
  29. package/esm/core/Carousel/CarouselNavigation.d.ts +4 -4
  30. package/esm/core/InformationPanel/InformationPanel.js +10 -5
  31. package/esm/core/LabeledSelect/LabeledSelect.d.ts +2 -2
  32. package/esm/core/Popover/Popover.d.ts +2 -2
  33. package/esm/core/Table/Table.js +2 -2
  34. package/esm/core/Table/cells/DefaultCell.d.ts +2 -1
  35. package/esm/core/Table/cells/DefaultCell.js +6 -1
  36. package/esm/core/Table/utils.d.ts +3 -1
  37. package/esm/core/Table/utils.js +6 -0
  38. package/esm/core/ThemeProvider/ThemeProvider.js +9 -8
  39. package/esm/core/Tile/Tile.d.ts +2 -2
  40. package/esm/core/VisuallyHidden/VisuallyHidden.js +3 -3
  41. package/esm/core/utils/components/ShadowRoot.js +26 -24
  42. package/esm/core/utils/hooks/index.d.ts +1 -0
  43. package/esm/core/utils/hooks/index.js +1 -0
  44. package/esm/core/utils/hooks/useMediaQuery.d.ts +1 -1
  45. package/esm/core/utils/hooks/useMediaQuery.js +11 -26
  46. package/esm/core/utils/hooks/useSyncExternalStore.d.ts +5 -0
  47. package/esm/core/utils/hooks/useSyncExternalStore.js +42 -0
  48. package/esm/core/utils/index.d.ts +1 -0
  49. package/esm/core/utils/index.js +1 -0
  50. package/esm/core/utils/providers/HydrationProvider.d.ts +16 -0
  51. package/esm/core/utils/providers/HydrationProvider.js +47 -0
  52. package/esm/core/utils/providers/index.d.ts +1 -0
  53. package/esm/core/utils/providers/index.js +5 -0
  54. package/package.json +2 -2
  55. package/styles.css +1 -677
@@ -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,47 @@
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';
6
+ import { useSyncExternalStore, useIsClient } from '../hooks/index.js';
7
+ const HydrationContext = React.createContext(false);
8
+ const noopSubscribe = () => () => { };
9
+ const isServer = typeof window === 'undefined';
10
+ /**
11
+ * Hook that returns the hydration status of the app.
12
+ *
13
+ * @returns one of the following values:
14
+ * - `"hydrated"` after hydration is *definitely* complete (or is a pure client render)
15
+ * - `"hydrating"` if we know for sure that hydration is happening (in React 18)
16
+ * - `undefined` if the hydration status is unknown
17
+ *
18
+ * @private
19
+ */
20
+ export const useHydration = () => {
21
+ // Returns true only if getServerSnapshot is called on the client.
22
+ // In React 18, this is true during hydration.
23
+ const hydrating = useSyncExternalStore(noopSubscribe, () => false, () => !isServer);
24
+ // Returns true after hydration is complete (in all React versions).
25
+ const hydrated = React.useContext(HydrationContext);
26
+ const hydratedFallback = useIsClient();
27
+ if (hydrated || hydratedFallback) {
28
+ return 'hydrated';
29
+ }
30
+ else if (hydrating) {
31
+ return 'hydrating';
32
+ }
33
+ return undefined;
34
+ };
35
+ /** @private */
36
+ export const HydrationProvider = ({ children, }) => {
37
+ const [isHydrated, setIsHydrated] = React.useState(React.useContext(HydrationContext));
38
+ const onHydrate = React.useCallback(() => setIsHydrated(true), []);
39
+ return (React.createElement(HydrationContext.Provider, { value: isHydrated },
40
+ !isHydrated ? React.createElement(HydrationCheck, { onHydrate: onHydrate }) : null,
41
+ children));
42
+ };
43
+ /** This is extracted into a child component to ensure it runs first. */
44
+ const HydrationCheck = ({ onHydrate }) => {
45
+ React.useEffect(() => void onHydrate(), [onHydrate]);
46
+ return null;
47
+ };
@@ -0,0 +1 @@
1
+ export * from './HydrationProvider.js';
@@ -0,0 +1,5 @@
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
+ export * from './HydrationProvider.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itwin/itwinui-react",
3
- "version": "3.7.4",
3
+ "version": "3.8.1",
4
4
  "author": "Bentley Systems",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -56,7 +56,7 @@
56
56
  "ux"
57
57
  ],
58
58
  "dependencies": {
59
- "@floating-ui/react": "^0.26.3",
59
+ "@floating-ui/react": "^0.26.10",
60
60
  "@itwin/itwinui-illustrations-react": "^2.1.0",
61
61
  "classnames": "^2.3.2",
62
62
  "react-table": "^7.8.0",