@itwin/itwinui-react 5.0.0-alpha.0 → 5.0.0-alpha.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 (76) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/DEV/bricks/Anchor.js +20 -22
  3. package/dist/DEV/bricks/Button.js +17 -15
  4. package/dist/DEV/bricks/Checkbox.js +16 -14
  5. package/dist/DEV/bricks/Divider.js +14 -16
  6. package/dist/DEV/bricks/DropdownMenu.js +60 -44
  7. package/dist/DEV/bricks/Field.js +14 -15
  8. package/dist/DEV/bricks/Icon.js +45 -44
  9. package/dist/DEV/bricks/IconButton.js +21 -19
  10. package/dist/DEV/bricks/Kbd.js +14 -16
  11. package/dist/DEV/bricks/Label.js +2 -2
  12. package/dist/DEV/bricks/ListItem.js +16 -16
  13. package/dist/DEV/bricks/Radio.js +2 -2
  14. package/dist/DEV/bricks/Root.js +45 -43
  15. package/dist/DEV/bricks/Select.js +55 -0
  16. package/dist/DEV/bricks/Switch.js +17 -15
  17. package/dist/DEV/bricks/Tabs.js +14 -15
  18. package/dist/DEV/bricks/Text.js +20 -0
  19. package/dist/DEV/bricks/TextBox.js +52 -45
  20. package/dist/DEV/bricks/Textarea.js +22 -20
  21. package/dist/DEV/bricks/Tooltip.js +65 -57
  22. package/dist/DEV/bricks/Tree.js +70 -64
  23. package/dist/DEV/bricks/VisuallyHidden.js +6 -4
  24. package/dist/DEV/bricks/index.js +4 -0
  25. package/dist/DEV/bricks/styles.css.js +1 -1
  26. package/dist/DEV/bricks/~utils.js +3 -0
  27. package/dist/bricks/Anchor.d.ts +12 -3
  28. package/dist/bricks/Anchor.js +20 -22
  29. package/dist/bricks/Button.d.ts +27 -4
  30. package/dist/bricks/Button.js +17 -15
  31. package/dist/bricks/Checkbox.d.ts +17 -3
  32. package/dist/bricks/Checkbox.js +16 -14
  33. package/dist/bricks/Divider.d.ts +3 -4
  34. package/dist/bricks/Divider.js +14 -16
  35. package/dist/bricks/DropdownMenu.d.ts +60 -10
  36. package/dist/bricks/DropdownMenu.js +60 -44
  37. package/dist/bricks/Field.d.ts +22 -2
  38. package/dist/bricks/Field.js +14 -15
  39. package/dist/bricks/Icon.d.ts +4 -4
  40. package/dist/bricks/Icon.js +44 -43
  41. package/dist/bricks/IconButton.d.ts +4 -4
  42. package/dist/bricks/IconButton.js +21 -19
  43. package/dist/bricks/Kbd.d.ts +2 -3
  44. package/dist/bricks/Kbd.js +14 -16
  45. package/dist/bricks/Label.d.ts +22 -3
  46. package/dist/bricks/Label.js +2 -2
  47. package/dist/bricks/ListItem.d.ts +2 -3
  48. package/dist/bricks/ListItem.js +15 -15
  49. package/dist/bricks/Radio.d.ts +17 -3
  50. package/dist/bricks/Radio.js +2 -2
  51. package/dist/bricks/Root.d.ts +11 -2
  52. package/dist/bricks/Root.js +45 -43
  53. package/dist/bricks/Select.d.ts +45 -0
  54. package/dist/bricks/Select.js +55 -0
  55. package/dist/bricks/Switch.d.ts +17 -3
  56. package/dist/bricks/Switch.js +17 -15
  57. package/dist/bricks/Tabs.d.ts +65 -4
  58. package/dist/bricks/Tabs.js +14 -15
  59. package/dist/bricks/Text.d.ts +22 -0
  60. package/dist/bricks/Text.js +19 -0
  61. package/dist/bricks/TextBox.d.ts +39 -9
  62. package/dist/bricks/TextBox.js +52 -45
  63. package/dist/bricks/Textarea.d.ts +14 -4
  64. package/dist/bricks/Textarea.js +22 -20
  65. package/dist/bricks/Tooltip.d.ts +11 -4
  66. package/dist/bricks/Tooltip.js +65 -57
  67. package/dist/bricks/Tree.d.ts +5 -5
  68. package/dist/bricks/Tree.js +67 -61
  69. package/dist/bricks/VisuallyHidden.d.ts +15 -3
  70. package/dist/bricks/VisuallyHidden.js +6 -4
  71. package/dist/bricks/index.d.ts +2 -0
  72. package/dist/bricks/index.js +4 -0
  73. package/dist/bricks/styles.css.js +1 -1
  74. package/dist/bricks/~utils.d.ts +20 -0
  75. package/dist/bricks/~utils.js +3 -0
  76. package/package.json +1 -1
@@ -4,48 +4,46 @@ import * as Ariakit from "@ariakit/react";
4
4
  import cx from "classnames";
5
5
  import foundationsCss from "../foundations/styles.css.js";
6
6
  import bricksCss from "./styles.css.js";
7
- import { isBrowser } from "./~utils.js";
7
+ import { forwardRef, isBrowser } from "./~utils.js";
8
8
  import { useMergedRefs } from "./~hooks.js";
9
9
  const css = foundationsCss + bricksCss;
10
- const Root = React.forwardRef(
11
- (props, forwardedRef) => {
12
- const { children, synchronizeColorScheme = false, ...rest } = props;
13
- return /* @__PURE__ */ jsxs(RootInternal, { ...rest, ref: forwardedRef, children: [
14
- /* @__PURE__ */ jsx(Styles, {}),
15
- /* @__PURE__ */ jsx(Fonts, {}),
16
- synchronizeColorScheme ? /* @__PURE__ */ jsx(SynchronizeColorScheme, { colorScheme: props.colorScheme }) : null,
17
- children
18
- ] });
19
- }
20
- );
10
+ const Root = forwardRef((props, forwardedRef) => {
11
+ const { children, synchronizeColorScheme = false, ...rest } = props;
12
+ return /* @__PURE__ */ jsxs(RootInternal, { ...rest, ref: forwardedRef, children: [
13
+ /* @__PURE__ */ jsx(Styles, {}),
14
+ /* @__PURE__ */ jsx(Fonts, {}),
15
+ synchronizeColorScheme ? /* @__PURE__ */ jsx(SynchronizeColorScheme, { colorScheme: props.colorScheme }) : null,
16
+ children
17
+ ] });
18
+ });
21
19
  DEV: Root.displayName = "Root";
22
20
  const RootNodeContext = React.createContext(null);
23
21
  function useRootNode() {
24
22
  return React.useContext(RootNodeContext);
25
23
  }
26
- const RootInternal = React.forwardRef((props, forwardedRef) => {
27
- const { children, colorScheme, density, ...rest } = props;
28
- const [rootNode, setRootNode] = React.useState(
29
- null
30
- );
31
- const findRootNodeFromRef = React.useCallback((element) => {
32
- if (!element) return;
33
- const rootNode2 = element.getRootNode();
34
- if (!isDocument(rootNode2) && !isShadow(rootNode2)) return;
35
- setRootNode(rootNode2);
36
- }, []);
37
- return /* @__PURE__ */ jsx(
38
- Ariakit.Role,
39
- {
40
- ...rest,
41
- className: cx("\u{1F95D}-root", props.className),
42
- "data-kiwi-theme": colorScheme,
43
- "data-kiwi-density": density,
44
- ref: useMergedRefs(forwardedRef, findRootNodeFromRef),
45
- children: /* @__PURE__ */ jsx(RootNodeContext.Provider, { value: rootNode, children })
46
- }
47
- );
48
- });
24
+ const RootInternal = forwardRef(
25
+ (props, forwardedRef) => {
26
+ const { children, colorScheme, density, ...rest } = props;
27
+ const [rootNode, setRootNode] = React.useState(null);
28
+ const findRootNodeFromRef = React.useCallback((element) => {
29
+ if (!element) return;
30
+ const rootNode2 = element.getRootNode();
31
+ if (!isDocument(rootNode2) && !isShadow(rootNode2)) return;
32
+ setRootNode(rootNode2);
33
+ }, []);
34
+ return /* @__PURE__ */ jsx(
35
+ Ariakit.Role,
36
+ {
37
+ ...rest,
38
+ className: cx("\u{1F95D}-root", props.className),
39
+ "data-kiwi-theme": colorScheme,
40
+ "data-kiwi-density": density,
41
+ ref: useMergedRefs(forwardedRef, findRootNodeFromRef),
42
+ children: /* @__PURE__ */ jsx(RootNodeContext.Provider, { value: rootNode, children })
43
+ }
44
+ );
45
+ }
46
+ );
49
47
  function SynchronizeColorScheme({
50
48
  colorScheme
51
49
  }) {
@@ -105,8 +103,8 @@ function Fonts() {
105
103
  return null;
106
104
  }
107
105
  function loadFonts(rootNode) {
108
- const ownerDocument = getOwnerDocument(rootNode);
109
- if (!ownerDocument || Array.from(ownerDocument.fonts).some(
106
+ const ownerWindow = getWindow(rootNode);
107
+ if (!ownerWindow || Array.from(ownerWindow.document.fonts).some(
110
108
  (font) => font.family === "InterVariable"
111
109
  )) {
112
110
  return;
@@ -116,12 +114,16 @@ function loadFonts(rootNode) {
116
114
  italic: "https://rsms.me/inter/font-files/InterVariable-Italic.woff2?v=4.1"
117
115
  };
118
116
  for (const [style, url] of Object.entries(interStyles)) {
119
- const font = new FontFace("InterVariable", `url(${url}) format("woff2")`, {
120
- display: "swap",
121
- weight: "100 900",
122
- style
123
- });
124
- ownerDocument.fonts.add(font);
117
+ const font = new ownerWindow.FontFace(
118
+ "InterVariable",
119
+ `url(${url}) format("woff2")`,
120
+ {
121
+ display: "swap",
122
+ weight: "100 900",
123
+ style
124
+ }
125
+ );
126
+ ownerWindow.document.fonts.add(font);
125
127
  }
126
128
  }
127
129
  const supportsAdoptedStylesheets = isBrowser && "adoptedStyleSheets" in Document.prototype;
@@ -0,0 +1,55 @@
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import * as React from "react";
3
+ import cx from "classnames";
4
+ import * as Ariakit from "@ariakit/react";
5
+ import {
6
+ forwardRef,
7
+ isBrowser
8
+ } from "./~utils.js";
9
+ import { DisclosureArrow } from "./Icon.js";
10
+ import { useFieldId } from "./Field.js";
11
+ const supportsHas = isBrowser && CSS?.supports?.("selector(:has(+ *))");
12
+ const HtmlSelectContext = React.createContext(() => {
13
+ });
14
+ const SelectRoot = forwardRef((props, forwardedRef) => {
15
+ const [isHtmlSelect, setIsHtmlSelect] = React.useState(false);
16
+ return /* @__PURE__ */ jsx(HtmlSelectContext.Provider, { value: setIsHtmlSelect, children: /* @__PURE__ */ jsx(
17
+ Ariakit.Role.div,
18
+ {
19
+ ...props,
20
+ className: cx("\u{1F95D}-select-root", props.className),
21
+ "data-kiwi-has-select": !supportsHas && isHtmlSelect ? "true" : void 0,
22
+ ref: forwardedRef
23
+ }
24
+ ) });
25
+ });
26
+ const HtmlSelect = forwardRef(
27
+ (props, forwardedRef) => {
28
+ const setIsHtmlSelect = React.useContext(HtmlSelectContext);
29
+ const fieldId = useFieldId();
30
+ React.useEffect(
31
+ function updateContext() {
32
+ setIsHtmlSelect(true);
33
+ },
34
+ [setIsHtmlSelect]
35
+ );
36
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
37
+ /* @__PURE__ */ jsx(
38
+ Ariakit.Role.select,
39
+ {
40
+ id: fieldId,
41
+ ...props,
42
+ className: cx("\u{1F95D}-button", "\u{1F95D}-select", props.className),
43
+ "data-kiwi-tone": "neutral",
44
+ "data-kiwi-variant": "solid",
45
+ ref: forwardedRef
46
+ }
47
+ ),
48
+ /* @__PURE__ */ jsx(DisclosureArrow, { className: "\u{1F95D}-select-arrow" })
49
+ ] });
50
+ }
51
+ );
52
+ export {
53
+ HtmlSelect,
54
+ SelectRoot as Root
55
+ };
@@ -1,22 +1,24 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
- import * as React from "react";
3
2
  import cx from "classnames";
4
3
  import * as Ariakit from "@ariakit/react";
5
4
  import { useFieldId } from "./Field.js";
6
- const Switch = React.forwardRef((props, forwardedRef) => {
7
- const fieldId = useFieldId();
8
- return /* @__PURE__ */ jsx(
9
- Ariakit.Checkbox,
10
- {
11
- accessibleWhenDisabled: true,
12
- id: fieldId,
13
- ...props,
14
- className: cx("\u{1F95D}-switch", props.className),
15
- role: "switch",
16
- ref: forwardedRef
17
- }
18
- );
19
- });
5
+ import { forwardRef } from "./~utils.js";
6
+ const Switch = forwardRef(
7
+ (props, forwardedRef) => {
8
+ const fieldId = useFieldId();
9
+ return /* @__PURE__ */ jsx(
10
+ Ariakit.Checkbox,
11
+ {
12
+ accessibleWhenDisabled: true,
13
+ id: fieldId,
14
+ ...props,
15
+ className: cx("\u{1F95D}-switch", props.className),
16
+ role: "switch",
17
+ ref: forwardedRef
18
+ }
19
+ );
20
+ }
21
+ );
20
22
  DEV: Switch.displayName = "Switch";
21
23
  export {
22
24
  Switch
@@ -4,6 +4,7 @@ import * as ReactDOM from "react-dom";
4
4
  import cx from "classnames";
5
5
  import * as Ariakit from "@ariakit/react";
6
6
  import { useControlledState } from "./~hooks.js";
7
+ import { forwardRef } from "./~utils.js";
7
8
  function Tabs(props) {
8
9
  const {
9
10
  defaultSelectedId,
@@ -41,7 +42,7 @@ function Tabs(props) {
41
42
  );
42
43
  }
43
44
  DEV: Tabs.displayName = "Tabs.Root";
44
- const TabList = React.forwardRef((props, forwardedRef) => {
45
+ const TabList = forwardRef((props, forwardedRef) => {
45
46
  const { tone = "neutral", ...rest } = props;
46
47
  const viewTransitionName = `\u{1F95D}active-stripe-${React.useId().replaceAll(":", "_")}`;
47
48
  return /* @__PURE__ */ jsx(
@@ -59,21 +60,19 @@ const TabList = React.forwardRef((props, forwardedRef) => {
59
60
  );
60
61
  });
61
62
  DEV: TabList.displayName = "Tabs.TabList";
62
- const Tab = React.forwardRef(
63
- (props, forwardedRef) => {
64
- return /* @__PURE__ */ jsx(
65
- Ariakit.Tab,
66
- {
67
- accessibleWhenDisabled: true,
68
- ...props,
69
- className: cx("\u{1F95D}-tab", props.className),
70
- ref: forwardedRef
71
- }
72
- );
73
- }
74
- );
63
+ const Tab = forwardRef((props, forwardedRef) => {
64
+ return /* @__PURE__ */ jsx(
65
+ Ariakit.Tab,
66
+ {
67
+ accessibleWhenDisabled: true,
68
+ ...props,
69
+ className: cx("\u{1F95D}-tab", props.className),
70
+ ref: forwardedRef
71
+ }
72
+ );
73
+ });
75
74
  DEV: Tab.displayName = "Tabs.Tab";
76
- const TabPanel = React.forwardRef((props, forwardedRef) => {
75
+ const TabPanel = forwardRef((props, forwardedRef) => {
77
76
  return /* @__PURE__ */ jsx(
78
77
  Ariakit.TabPanel,
79
78
  {
@@ -0,0 +1,20 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import * as Ariakit from "@ariakit/react";
3
+ import cx from "classnames";
4
+ import { forwardRef } from "./~utils.js";
5
+ const Text = forwardRef((props, forwardedRef) => {
6
+ const { variant, ...rest } = props;
7
+ return /* @__PURE__ */ jsx(
8
+ Ariakit.Role,
9
+ {
10
+ ...rest,
11
+ className: cx("\u{1F95D}-text", props.className),
12
+ "data-kiwi-text-variant": variant,
13
+ ref: forwardedRef
14
+ }
15
+ );
16
+ });
17
+ DEV: Text.displayName = "Text";
18
+ export {
19
+ Text
20
+ };
@@ -6,32 +6,35 @@ import { useFieldId } from "./Field.js";
6
6
  import { Icon } from "./Icon.js";
7
7
  import { Textarea } from "./Textarea.js";
8
8
  import { useMergedRefs } from "./~hooks.js";
9
- const TextBoxInput = React.forwardRef((props, forwardedRef) => {
10
- const fieldId = useFieldId();
11
- const rootContext = React.useContext(TextBoxRootContext);
12
- const setDisabled = rootContext?.setDisabled;
13
- React.useEffect(() => {
14
- setDisabled?.(props.disabled);
15
- }, [setDisabled, props.disabled]);
16
- return /* @__PURE__ */ jsx(
17
- Ariakit.Role.input,
18
- {
19
- id: fieldId,
20
- ...props,
21
- className: cx({ "\u{1F95D}-text-box": !rootContext }, props.className),
22
- render: /* @__PURE__ */ jsx(
23
- Ariakit.Focusable,
24
- {
25
- accessibleWhenDisabled: true,
26
- render: props.render || /* @__PURE__ */ jsx("input", {})
27
- }
28
- ),
29
- ref: useMergedRefs(rootContext?.inputRef, forwardedRef)
30
- }
31
- );
32
- });
9
+ import { forwardRef } from "./~utils.js";
10
+ const TextBoxInput = forwardRef(
11
+ (props, forwardedRef) => {
12
+ const fieldId = useFieldId();
13
+ const rootContext = React.useContext(TextBoxRootContext);
14
+ const setDisabled = rootContext?.setDisabled;
15
+ React.useEffect(() => {
16
+ setDisabled?.(props.disabled);
17
+ }, [setDisabled, props.disabled]);
18
+ return /* @__PURE__ */ jsx(
19
+ Ariakit.Role.input,
20
+ {
21
+ id: fieldId,
22
+ ...props,
23
+ className: cx({ "\u{1F95D}-text-box": !rootContext }, props.className),
24
+ render: /* @__PURE__ */ jsx(
25
+ Ariakit.Focusable,
26
+ {
27
+ accessibleWhenDisabled: true,
28
+ render: props.render || /* @__PURE__ */ jsx("input", {})
29
+ }
30
+ ),
31
+ ref: useMergedRefs(rootContext?.inputRef, forwardedRef)
32
+ }
33
+ );
34
+ }
35
+ );
33
36
  DEV: TextBoxInput.displayName = "TextBox.Input";
34
- const TextBoxRoot = React.forwardRef(
37
+ const TextBoxRoot = forwardRef(
35
38
  (props, forwardedRef) => {
36
39
  const inputRef = React.useRef(null);
37
40
  const [disabled, setDisabled] = React.useState();
@@ -61,27 +64,31 @@ const TextBoxRoot = React.forwardRef(
61
64
  }
62
65
  );
63
66
  DEV: TextBoxRoot.displayName = "TextBox.Root";
64
- const TextBoxIcon = React.forwardRef((props, forwardedRef) => {
65
- return /* @__PURE__ */ jsx(
66
- Icon,
67
- {
68
- ...props,
69
- className: cx("\u{1F95D}-text-box-decoration", props.className),
70
- ref: forwardedRef
71
- }
72
- );
73
- });
67
+ const TextBoxIcon = forwardRef(
68
+ (props, forwardedRef) => {
69
+ return /* @__PURE__ */ jsx(
70
+ Icon,
71
+ {
72
+ ...props,
73
+ className: cx("\u{1F95D}-text-box-decoration", props.className),
74
+ ref: forwardedRef
75
+ }
76
+ );
77
+ }
78
+ );
74
79
  DEV: TextBoxIcon.displayName = "TextBox.Icon";
75
- const TextBoxText = React.forwardRef((props, forwardedRef) => {
76
- return /* @__PURE__ */ jsx(
77
- Ariakit.Role.span,
78
- {
79
- ...props,
80
- className: cx("\u{1F95D}-text-box-decoration", props.className),
81
- ref: forwardedRef
82
- }
83
- );
84
- });
80
+ const TextBoxText = forwardRef(
81
+ (props, forwardedRef) => {
82
+ return /* @__PURE__ */ jsx(
83
+ Ariakit.Role.span,
84
+ {
85
+ ...props,
86
+ className: cx("\u{1F95D}-text-box-decoration", props.className),
87
+ ref: forwardedRef
88
+ }
89
+ );
90
+ }
91
+ );
85
92
  DEV: TextBoxText.displayName = "TextBox.Text";
86
93
  const TextBoxRootContext = React.createContext(void 0);
87
94
  export {
@@ -1,27 +1,29 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
- import * as React from "react";
3
2
  import * as Ariakit from "@ariakit/react";
4
3
  import cx from "classnames";
5
4
  import { useFieldId } from "./Field.js";
6
- const Textarea = React.forwardRef((props, forwardedRef) => {
7
- const fieldId = useFieldId();
8
- return /* @__PURE__ */ jsx(
9
- Ariakit.Role.textarea,
10
- {
11
- id: fieldId,
12
- ...props,
13
- className: cx("\u{1F95D}-text-box", props.className),
14
- render: /* @__PURE__ */ jsx(
15
- Ariakit.Focusable,
16
- {
17
- accessibleWhenDisabled: true,
18
- render: props.render || /* @__PURE__ */ jsx("textarea", {})
19
- }
20
- ),
21
- ref: forwardedRef
22
- }
23
- );
24
- });
5
+ import { forwardRef } from "./~utils.js";
6
+ const Textarea = forwardRef(
7
+ (props, forwardedRef) => {
8
+ const fieldId = useFieldId();
9
+ return /* @__PURE__ */ jsx(
10
+ Ariakit.Role.textarea,
11
+ {
12
+ id: fieldId,
13
+ ...props,
14
+ className: cx("\u{1F95D}-text-box", props.className),
15
+ render: /* @__PURE__ */ jsx(
16
+ Ariakit.Focusable,
17
+ {
18
+ accessibleWhenDisabled: true,
19
+ render: props.render || /* @__PURE__ */ jsx("textarea", {})
20
+ }
21
+ ),
22
+ ref: forwardedRef
23
+ }
24
+ );
25
+ }
26
+ );
25
27
  DEV: Textarea.displayName = "Textarea";
26
28
  export {
27
29
  Textarea
@@ -2,66 +2,74 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
2
  import * as React from "react";
3
3
  import cx from "classnames";
4
4
  import * as Ariakit from "@ariakit/react";
5
- import { supportsPopover } from "./~utils.js";
6
- const Tooltip = React.forwardRef((props, forwardedRef) => {
7
- const {
8
- content,
9
- children,
10
- className,
11
- type = "description",
12
- id = React.useId(),
13
- defaultOpen: defaultOpenProp,
14
- open: openProp,
15
- setOpen: setOpenProp,
16
- unmountOnHide = type === "none",
17
- ...rest
18
- } = props;
19
- const store = Ariakit.useTooltipStore();
20
- const open = Ariakit.useStoreState(store, (state) => state.open);
21
- const popover = Ariakit.useStoreState(store, (state) => state.popoverElement);
22
- React.useEffect(
23
- function syncPopoverWithOpenState() {
24
- if (popover?.isConnected) {
25
- popover?.togglePopover?.(open);
26
- }
27
- },
28
- [open, popover]
29
- );
30
- return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(
31
- Ariakit.TooltipProvider,
32
- {
33
- store,
5
+ import { forwardRef, supportsPopover } from "./~utils.js";
6
+ const Tooltip = forwardRef(
7
+ (props, forwardedRef) => {
8
+ const {
9
+ content,
10
+ children,
11
+ className,
12
+ type = "description",
13
+ id = React.useId(),
34
14
  defaultOpen: defaultOpenProp,
35
15
  open: openProp,
36
16
  setOpen: setOpenProp,
37
- children: [
38
- /* @__PURE__ */ jsx(
39
- Ariakit.TooltipAnchor,
40
- {
41
- render: children,
42
- ...type === "description" && { "aria-describedby": id },
43
- ...type === "label" && { "aria-labelledby": id }
44
- }
45
- ),
46
- /* @__PURE__ */ jsx(
47
- Ariakit.Tooltip,
48
- {
49
- "aria-hidden": "true",
50
- ...rest,
51
- unmountOnHide,
52
- className: cx("\u{1F95D}-tooltip", className),
53
- ref: forwardedRef,
54
- id,
55
- style: { zIndex: supportsPopover ? void 0 : 9999, ...props.style },
56
- wrapperProps: { popover: "manual" },
57
- portal: !supportsPopover,
58
- children: content
59
- }
60
- )
61
- ]
62
- }
63
- ) });
64
- });
17
+ unmountOnHide = type === "none",
18
+ ...rest
19
+ } = props;
20
+ const store = Ariakit.useTooltipStore();
21
+ const open = Ariakit.useStoreState(store, (state) => state.open);
22
+ const popover = Ariakit.useStoreState(
23
+ store,
24
+ (state) => state.popoverElement
25
+ );
26
+ React.useEffect(
27
+ function syncPopoverWithOpenState() {
28
+ if (popover?.isConnected) {
29
+ popover?.togglePopover?.(open);
30
+ }
31
+ },
32
+ [open, popover]
33
+ );
34
+ return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(
35
+ Ariakit.TooltipProvider,
36
+ {
37
+ store,
38
+ defaultOpen: defaultOpenProp,
39
+ open: openProp,
40
+ setOpen: setOpenProp,
41
+ children: [
42
+ /* @__PURE__ */ jsx(
43
+ Ariakit.TooltipAnchor,
44
+ {
45
+ render: children,
46
+ ...type === "description" && { "aria-describedby": id },
47
+ ...type === "label" && { "aria-labelledby": id }
48
+ }
49
+ ),
50
+ /* @__PURE__ */ jsx(
51
+ Ariakit.Tooltip,
52
+ {
53
+ "aria-hidden": "true",
54
+ ...rest,
55
+ unmountOnHide,
56
+ className: cx("\u{1F95D}-tooltip", className),
57
+ ref: forwardedRef,
58
+ id,
59
+ style: {
60
+ zIndex: supportsPopover ? void 0 : 9999,
61
+ ...props.style
62
+ },
63
+ wrapperProps: { popover: "manual" },
64
+ portal: !supportsPopover,
65
+ children: content
66
+ }
67
+ )
68
+ ]
69
+ }
70
+ ) });
71
+ }
72
+ );
65
73
  DEV: Tooltip.displayName = "Tooltip";
66
74
  export {
67
75
  Tooltip