@itwin/itwinui-react 5.0.0-alpha.0 → 5.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -0
- package/dist/DEV/bricks/Anchor.js +20 -22
- package/dist/DEV/bricks/Button.js +17 -15
- package/dist/DEV/bricks/Checkbox.js +19 -15
- package/dist/DEV/bricks/Chip.js +21 -0
- package/dist/DEV/bricks/Description.js +27 -0
- package/dist/DEV/bricks/Divider.js +14 -16
- package/dist/DEV/bricks/DropdownMenu.js +60 -44
- package/dist/DEV/bricks/Field.js +66 -16
- package/dist/DEV/bricks/Icon.js +45 -44
- package/dist/DEV/bricks/IconButton.js +24 -19
- package/dist/DEV/bricks/Kbd.js +46 -16
- package/dist/DEV/bricks/Label.js +2 -2
- package/dist/DEV/bricks/ListItem.js +16 -16
- package/dist/DEV/bricks/Radio.js +5 -3
- package/dist/DEV/bricks/Root.js +45 -43
- package/dist/DEV/bricks/Select.js +57 -0
- package/dist/DEV/bricks/Spinner.js +40 -0
- package/dist/DEV/bricks/Switch.js +20 -16
- package/dist/DEV/bricks/Tabs.js +15 -16
- package/dist/DEV/bricks/Text.js +20 -0
- package/dist/DEV/bricks/TextBox.js +55 -46
- package/dist/DEV/bricks/Textarea.js +25 -21
- package/dist/DEV/bricks/Tooltip.js +65 -57
- package/dist/DEV/bricks/Tree.js +133 -66
- package/dist/DEV/bricks/VisuallyHidden.js +6 -4
- package/dist/DEV/bricks/index.js +12 -0
- package/dist/DEV/bricks/styles.css.js +1 -1
- package/dist/DEV/bricks/~hooks.js +13 -0
- package/dist/DEV/bricks/~utils.js +3 -0
- package/dist/DEV/foundations/styles.css.js +1 -1
- package/dist/bricks/Anchor.d.ts +12 -3
- package/dist/bricks/Anchor.js +20 -22
- package/dist/bricks/Button.d.ts +27 -4
- package/dist/bricks/Button.js +17 -15
- package/dist/bricks/Checkbox.d.ts +17 -3
- package/dist/bricks/Checkbox.js +19 -15
- package/dist/bricks/Chip.d.ts +22 -0
- package/dist/bricks/Chip.js +20 -0
- package/dist/bricks/Description.d.ts +20 -0
- package/dist/bricks/Description.js +27 -0
- package/dist/bricks/Divider.d.ts +3 -4
- package/dist/bricks/Divider.js +14 -16
- package/dist/bricks/DropdownMenu.d.ts +60 -10
- package/dist/bricks/DropdownMenu.js +60 -44
- package/dist/bricks/Field.d.ts +30 -2
- package/dist/bricks/Field.js +66 -16
- package/dist/bricks/Icon.d.ts +4 -4
- package/dist/bricks/Icon.js +44 -43
- package/dist/bricks/IconButton.d.ts +4 -4
- package/dist/bricks/IconButton.js +24 -19
- package/dist/bricks/Kbd.d.ts +32 -3
- package/dist/bricks/Kbd.js +39 -16
- package/dist/bricks/Label.d.ts +22 -3
- package/dist/bricks/Label.js +2 -2
- package/dist/bricks/ListItem.d.ts +2 -3
- package/dist/bricks/ListItem.js +15 -15
- package/dist/bricks/Radio.d.ts +17 -3
- package/dist/bricks/Radio.js +5 -3
- package/dist/bricks/Root.d.ts +11 -2
- package/dist/bricks/Root.js +45 -43
- package/dist/bricks/Select.d.ts +45 -0
- package/dist/bricks/Select.js +57 -0
- package/dist/bricks/Spinner.d.ts +31 -0
- package/dist/bricks/Spinner.js +39 -0
- package/dist/bricks/Switch.d.ts +17 -3
- package/dist/bricks/Switch.js +20 -16
- package/dist/bricks/Tabs.d.ts +66 -5
- package/dist/bricks/Tabs.js +15 -16
- package/dist/bricks/Text.d.ts +22 -0
- package/dist/bricks/Text.js +19 -0
- package/dist/bricks/TextBox.d.ts +39 -9
- package/dist/bricks/TextBox.js +55 -46
- package/dist/bricks/Textarea.d.ts +14 -4
- package/dist/bricks/Textarea.js +25 -21
- package/dist/bricks/Tooltip.d.ts +11 -4
- package/dist/bricks/Tooltip.js +65 -57
- package/dist/bricks/Tree.d.ts +79 -16
- package/dist/bricks/Tree.js +128 -62
- package/dist/bricks/VisuallyHidden.d.ts +15 -3
- package/dist/bricks/VisuallyHidden.js +6 -4
- package/dist/bricks/index.d.ts +6 -0
- package/dist/bricks/index.js +12 -0
- package/dist/bricks/styles.css.js +1 -1
- package/dist/bricks/~hooks.d.ts +15 -0
- package/dist/bricks/~hooks.js +13 -0
- package/dist/bricks/~utils.d.ts +20 -0
- package/dist/bricks/~utils.js +3 -0
- package/dist/foundations/styles.css.js +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,19 @@
|
|
|
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
|
+
export {
|
|
18
|
+
Text
|
|
19
|
+
};
|
package/dist/bricks/TextBox.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { Icon } from "./Icon.js";
|
|
3
3
|
import { Textarea } from "./Textarea.js";
|
|
4
|
-
import type
|
|
4
|
+
import { type FocusableProps, type BaseProps } from "./~utils.js";
|
|
5
5
|
interface BaseInputProps extends FocusableProps<"input"> {
|
|
6
6
|
}
|
|
7
7
|
interface TextBoxInputProps extends Omit<BaseInputProps, "children" | "type"> {
|
|
@@ -16,7 +16,7 @@ interface TextBoxInputProps extends Omit<BaseInputProps, "children" | "type"> {
|
|
|
16
16
|
type?: Extract<BaseInputProps["type"], "text" | "email" | "password" | "search" | "tel" | "url" | "number" | "date">;
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
19
|
+
* An input component that allows users to enter text based values.
|
|
20
20
|
*
|
|
21
21
|
* Example usage:
|
|
22
22
|
* ```tsx
|
|
@@ -24,26 +24,56 @@ interface TextBoxInputProps extends Omit<BaseInputProps, "children" | "type"> {
|
|
|
24
24
|
* ```
|
|
25
25
|
*
|
|
26
26
|
* To add additional decorations, see `TextBox.Root` component.
|
|
27
|
+
*
|
|
28
|
+
* Works well with the `Field` and `Label` components.
|
|
29
|
+
* ```tsx
|
|
30
|
+
* <Field>
|
|
31
|
+
* <Label>Enter your name</Label>
|
|
32
|
+
* <TextBox.Input />
|
|
33
|
+
* </Field>
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* Underneath, it's an HTML input, i.e. `<input>`, so it supports the same props, including
|
|
37
|
+
* `value`, `defaultValue`, `onChange`, and `disabled`.
|
|
38
|
+
*
|
|
39
|
+
* For a multiline text input, use the `TextBox.Textarea` component.
|
|
27
40
|
*/
|
|
28
|
-
declare const TextBoxInput: React.ForwardRefExoticComponent<TextBoxInputProps & React.RefAttributes<HTMLInputElement>>;
|
|
41
|
+
declare const TextBoxInput: React.ForwardRefExoticComponent<TextBoxInputProps & React.RefAttributes<HTMLElement | HTMLInputElement>>;
|
|
29
42
|
interface TextBoxRootProps extends BaseProps {
|
|
30
43
|
}
|
|
31
44
|
/**
|
|
32
|
-
*
|
|
45
|
+
* Compound component for a text input. Allows adding additional decorations.
|
|
33
46
|
*
|
|
34
47
|
* Example usage to add an end icon:
|
|
35
48
|
* ```tsx
|
|
36
49
|
* <TextBox.Root>
|
|
37
|
-
*
|
|
38
|
-
*
|
|
50
|
+
* <TextBox.Input defaultValue="Hello" />
|
|
51
|
+
* <TextBox.Icon href={...} />
|
|
39
52
|
* </TextBox.Root>
|
|
40
53
|
* ```
|
|
54
|
+
*
|
|
55
|
+
* Works well with the `Field` and `Label` components.
|
|
56
|
+
* ```tsx
|
|
57
|
+
* <Field>
|
|
58
|
+
* <Label>Enter your name</Label>
|
|
59
|
+
* <TextBox.Root>
|
|
60
|
+
* <TextBox.Input />
|
|
61
|
+
* <TextBox.Icon href={…} />
|
|
62
|
+
* </TextBox.Root>
|
|
63
|
+
* </Field>
|
|
64
|
+
* ```
|
|
41
65
|
*/
|
|
42
|
-
declare const TextBoxRoot: React.ForwardRefExoticComponent<TextBoxRootProps & React.RefAttributes<HTMLDivElement>>;
|
|
66
|
+
declare const TextBoxRoot: React.ForwardRefExoticComponent<TextBoxRootProps & React.RefAttributes<HTMLElement | HTMLDivElement>>;
|
|
43
67
|
interface TextBoxIconProps extends React.ComponentProps<typeof Icon> {
|
|
44
68
|
}
|
|
45
|
-
|
|
69
|
+
/**
|
|
70
|
+
* A static icon decoration for the `TextBox.Root` component. Can be added before or after the `TextBox.Input`.
|
|
71
|
+
*/
|
|
72
|
+
declare const TextBoxIcon: React.ForwardRefExoticComponent<Omit<TextBoxIconProps, "ref"> & React.RefAttributes<HTMLElement | SVGSVGElement>>;
|
|
46
73
|
interface TextBoxTextProps extends BaseProps<"span"> {
|
|
47
74
|
}
|
|
48
|
-
|
|
75
|
+
/**
|
|
76
|
+
* A static text decoration for the `TextBox.Root` component. Can be added before or after the `TextBox.Input`.
|
|
77
|
+
*/
|
|
78
|
+
declare const TextBoxText: React.ForwardRefExoticComponent<TextBoxTextProps & React.RefAttributes<HTMLElement | HTMLSpanElement>>;
|
|
49
79
|
export { TextBoxRoot as Root, TextBoxInput as Input, Textarea, TextBoxIcon as Icon, TextBoxText as Text, };
|
package/dist/bricks/TextBox.js
CHANGED
|
@@ -2,35 +2,40 @@ import { jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import * as Ariakit from "@ariakit/react";
|
|
4
4
|
import cx from "classnames";
|
|
5
|
-
import { useFieldId } from "./Field.js";
|
|
5
|
+
import { useFieldDescribedBy, 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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
9
|
+
import { forwardRef } from "./~utils.js";
|
|
10
|
+
const TextBoxInput = forwardRef(
|
|
11
|
+
(props, forwardedRef) => {
|
|
12
|
+
const describedBy = useFieldDescribedBy(props["aria-describedby"]);
|
|
13
|
+
const fieldId = useFieldId();
|
|
14
|
+
const rootContext = React.useContext(TextBoxRootContext);
|
|
15
|
+
const setDisabled = rootContext?.setDisabled;
|
|
16
|
+
React.useEffect(() => {
|
|
17
|
+
setDisabled?.(props.disabled);
|
|
18
|
+
}, [setDisabled, props.disabled]);
|
|
19
|
+
return /* @__PURE__ */ jsx(
|
|
20
|
+
Ariakit.Role.input,
|
|
21
|
+
{
|
|
22
|
+
id: fieldId,
|
|
23
|
+
...props,
|
|
24
|
+
"aria-describedby": describedBy,
|
|
25
|
+
className: cx({ "\u{1F95D}-text-box": !rootContext }, props.className),
|
|
26
|
+
render: /* @__PURE__ */ jsx(
|
|
27
|
+
Ariakit.Focusable,
|
|
28
|
+
{
|
|
29
|
+
accessibleWhenDisabled: true,
|
|
30
|
+
render: props.render || /* @__PURE__ */ jsx("input", {})
|
|
31
|
+
}
|
|
32
|
+
),
|
|
33
|
+
ref: useMergedRefs(rootContext?.inputRef, forwardedRef)
|
|
34
|
+
}
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
const TextBoxRoot = forwardRef(
|
|
34
39
|
(props, forwardedRef) => {
|
|
35
40
|
const inputRef = React.useRef(null);
|
|
36
41
|
const [disabled, setDisabled] = React.useState();
|
|
@@ -59,26 +64,30 @@ const TextBoxRoot = React.forwardRef(
|
|
|
59
64
|
);
|
|
60
65
|
}
|
|
61
66
|
);
|
|
62
|
-
const TextBoxIcon =
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
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
|
+
);
|
|
79
|
+
const TextBoxText = forwardRef(
|
|
80
|
+
(props, forwardedRef) => {
|
|
81
|
+
return /* @__PURE__ */ jsx(
|
|
82
|
+
Ariakit.Role.span,
|
|
83
|
+
{
|
|
84
|
+
...props,
|
|
85
|
+
className: cx("\u{1F95D}-text-box-decoration", props.className),
|
|
86
|
+
ref: forwardedRef
|
|
87
|
+
}
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
);
|
|
82
91
|
const TextBoxRootContext = React.createContext(void 0);
|
|
83
92
|
export {
|
|
84
93
|
TextBoxIcon as Icon,
|
|
@@ -1,14 +1,24 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type { FocusableProps } from "./~utils.js";
|
|
1
|
+
import { type FocusableProps } from "./~utils.js";
|
|
3
2
|
interface TextareaProps extends FocusableProps<"textarea"> {
|
|
4
3
|
}
|
|
5
4
|
/**
|
|
6
|
-
*
|
|
5
|
+
* A styled textarea element that allows users to enter multiline text values.
|
|
7
6
|
*
|
|
8
7
|
* Example usage:
|
|
9
8
|
* ```tsx
|
|
10
9
|
* <TextBox.Textarea defaultValue="Hello" />
|
|
11
10
|
* ```
|
|
11
|
+
*
|
|
12
|
+
* Works well with the `Field` and `Label` components.
|
|
13
|
+
* ```tsx
|
|
14
|
+
* <Field>
|
|
15
|
+
* <Label>Leave a comment, be kind</Label>
|
|
16
|
+
* <TextBox.Textarea />
|
|
17
|
+
* </Field>
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* Underneath, it's an HTML textarea, i.e. `<textarea>`, so it supports the same props, including
|
|
21
|
+
* `value`, `defaultValue`, `onChange`, and `disabled`.
|
|
12
22
|
*/
|
|
13
|
-
export declare const Textarea:
|
|
23
|
+
export declare const Textarea: import("react").ForwardRefExoticComponent<TextareaProps & import("react").RefAttributes<HTMLElement | HTMLTextAreaElement>>;
|
|
14
24
|
export {};
|
package/dist/bricks/Textarea.js
CHANGED
|
@@ -1,27 +1,31 @@
|
|
|
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
|
-
import { useFieldId } from "./Field.js";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
{
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
4
|
+
import { useFieldDescribedBy, useFieldId } from "./Field.js";
|
|
5
|
+
import { forwardRef } from "./~utils.js";
|
|
6
|
+
const Textarea = forwardRef(
|
|
7
|
+
(props, forwardedRef) => {
|
|
8
|
+
const fieldId = useFieldId();
|
|
9
|
+
const describedBy = useFieldDescribedBy(props["aria-describedby"]);
|
|
10
|
+
return /* @__PURE__ */ jsx(
|
|
11
|
+
Ariakit.Role.textarea,
|
|
12
|
+
{
|
|
13
|
+
id: fieldId,
|
|
14
|
+
...props,
|
|
15
|
+
className: cx("\u{1F95D}-text-box", props.className),
|
|
16
|
+
"aria-describedby": describedBy,
|
|
17
|
+
render: /* @__PURE__ */ jsx(
|
|
18
|
+
Ariakit.Focusable,
|
|
19
|
+
{
|
|
20
|
+
accessibleWhenDisabled: true,
|
|
21
|
+
render: props.render || /* @__PURE__ */ jsx("textarea", {})
|
|
22
|
+
}
|
|
23
|
+
),
|
|
24
|
+
ref: forwardedRef
|
|
25
|
+
}
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
);
|
|
25
29
|
export {
|
|
26
30
|
Textarea
|
|
27
31
|
};
|
package/dist/bricks/Tooltip.d.ts
CHANGED
|
@@ -3,12 +3,16 @@ import * as Ariakit from "@ariakit/react";
|
|
|
3
3
|
import { type FocusableProps } from "./~utils.js";
|
|
4
4
|
interface TooltipProps extends Omit<FocusableProps<"div">, "content">, Pick<Ariakit.TooltipProps, "open" | "unmountOnHide">, Pick<Ariakit.TooltipProviderProps, "defaultOpen" | "setOpen"> {
|
|
5
5
|
/**
|
|
6
|
-
* The content to be displayed inside the tooltip.
|
|
6
|
+
* The content to be displayed inside the tooltip when the trigger element is hovered or focused.
|
|
7
7
|
*/
|
|
8
8
|
content: React.ReactNode;
|
|
9
9
|
/**
|
|
10
10
|
* The element that will trigger the tooltip when hovered or focused.
|
|
11
11
|
* Common examples include buttons, links, or form controls.
|
|
12
|
+
*
|
|
13
|
+
* **Note**: The trigger must be a single interactive element. Do not add a
|
|
14
|
+
* tooltip to a non-interactive static element (such as a `<div>` or `<svg>`). Also,
|
|
15
|
+
* the trigger element must forward its ref and spread its props.
|
|
12
16
|
*/
|
|
13
17
|
children: React.ReactElement;
|
|
14
18
|
/**
|
|
@@ -23,7 +27,7 @@ interface TooltipProps extends Omit<FocusableProps<"div">, "content">, Pick<Aria
|
|
|
23
27
|
type?: "description" | "label" | "none";
|
|
24
28
|
}
|
|
25
29
|
/**
|
|
26
|
-
*
|
|
30
|
+
* A tooltip component that provides additional information or context for an interactive trigger element.
|
|
27
31
|
*
|
|
28
32
|
* Example usage:
|
|
29
33
|
*
|
|
@@ -33,7 +37,10 @@ interface TooltipProps extends Omit<FocusableProps<"div">, "content">, Pick<Aria
|
|
|
33
37
|
* </Tooltip>
|
|
34
38
|
* ```
|
|
35
39
|
*
|
|
36
|
-
* **Note**:
|
|
40
|
+
* **Note**: The trigger element must be a single interactive element, such as a button or link. Do not add a
|
|
41
|
+
* tooltip to a non-interactive static element (such as a `<div>` or `<svg>`).
|
|
42
|
+
*
|
|
43
|
+
* **Note**: If `type` is set to `"none"`, the tooltip will not use ARIA attributes.
|
|
37
44
|
*/
|
|
38
|
-
export declare const Tooltip: React.ForwardRefExoticComponent<TooltipProps & React.RefAttributes<HTMLDivElement>>;
|
|
45
|
+
export declare const Tooltip: React.ForwardRefExoticComponent<TooltipProps & React.RefAttributes<HTMLElement | HTMLDivElement>>;
|
|
39
46
|
export {};
|
package/dist/bricks/Tooltip.js
CHANGED
|
@@ -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 =
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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 generatedId = React.useId();
|
|
9
|
+
const {
|
|
10
|
+
content,
|
|
11
|
+
children,
|
|
12
|
+
type = "description",
|
|
13
|
+
id = generatedId,
|
|
34
14
|
defaultOpen: defaultOpenProp,
|
|
35
15
|
open: openProp,
|
|
36
16
|
setOpen: setOpenProp,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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", props.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
|
export {
|
|
66
74
|
Tooltip
|
|
67
75
|
};
|
package/dist/bricks/Tree.d.ts
CHANGED
|
@@ -1,23 +1,86 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import {
|
|
3
|
-
import type { BaseProps } from "./~utils.js";
|
|
2
|
+
import { type BaseProps } from "./~utils.js";
|
|
4
3
|
interface TreeProps extends BaseProps {
|
|
5
4
|
}
|
|
6
|
-
|
|
5
|
+
/**
|
|
6
|
+
* A tree is a hierarchical list of items that can be expanded or collapsed, or optionally selected.
|
|
7
|
+
*
|
|
8
|
+
* `Tree.Root` is the root component for a tree. `Tree.Item`s can be nested inside a `Tree.Root` to create a hierarchical tree structure.
|
|
9
|
+
*
|
|
10
|
+
* Example:
|
|
11
|
+
* ```tsx
|
|
12
|
+
* <Tree.Root>
|
|
13
|
+
* <Tree.Item label="Parent 1">
|
|
14
|
+
* <Tree.Item label="Child 1.1" />
|
|
15
|
+
* <Tree.Item label="Child 1.2" />
|
|
16
|
+
* </Tree.Item>
|
|
17
|
+
* <Tree.Item label="Parent 2">
|
|
18
|
+
* <Tree.Item label="Child 2.1" />
|
|
19
|
+
* </Tree.Item>
|
|
20
|
+
* </Tree.Root>
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
declare const Tree: React.ForwardRefExoticComponent<TreeProps & React.RefAttributes<HTMLElement | HTMLDivElement>>;
|
|
7
24
|
interface TreeItemProps extends Omit<BaseProps, "content"> {
|
|
8
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Specifies if the tree item is selected.
|
|
27
|
+
*
|
|
28
|
+
* If `undefined`, the tree item is not selectable.
|
|
29
|
+
*
|
|
30
|
+
* @default undefined
|
|
31
|
+
*/
|
|
9
32
|
selected?: boolean;
|
|
10
|
-
/**
|
|
33
|
+
/**
|
|
34
|
+
* Callback fired when the tree item is selected.
|
|
35
|
+
*
|
|
36
|
+
* Should be used with the `selected` prop.
|
|
37
|
+
*/
|
|
38
|
+
onSelectedChange?: (selected: boolean) => void;
|
|
39
|
+
/**
|
|
40
|
+
* Specifies if the tree item is expanded.
|
|
41
|
+
*
|
|
42
|
+
* Used to determine if a tree item is a parent node. If `undefined`, it is a leaf node (i.e. not expandable).
|
|
43
|
+
*
|
|
44
|
+
* @default undefined
|
|
45
|
+
* */
|
|
11
46
|
expanded?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Callback fired when the tree item is expanded.
|
|
49
|
+
*
|
|
50
|
+
* Should be used with the `expanded` prop.
|
|
51
|
+
*/
|
|
52
|
+
onExpandedChange?: (expanded: boolean) => void;
|
|
53
|
+
/**
|
|
54
|
+
* Icon to be displayed inside the tree item.
|
|
55
|
+
*
|
|
56
|
+
* Can be a URL of an SVG from the `kiwi-icons` package, or a JSX element.
|
|
57
|
+
*/
|
|
58
|
+
icon?: string | React.JSX.Element;
|
|
59
|
+
/** The label to display for the tree item. */
|
|
60
|
+
label?: React.ReactNode;
|
|
61
|
+
/** The actions available for the tree item. */
|
|
62
|
+
actions?: React.ReactNode;
|
|
12
63
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
64
|
+
/**
|
|
65
|
+
* A treeitem is a node in a tree structure that may be expanded or collapsed to reveal or hide its descendants.
|
|
66
|
+
*
|
|
67
|
+
* `Tree.Item`s can be nested as JSX elements inside a `Tree.Root` to create a hierarchical tree structure.
|
|
68
|
+
*
|
|
69
|
+
* Example:
|
|
70
|
+
* ```tsx
|
|
71
|
+
* <Tree.Root>
|
|
72
|
+
* <Tree.Item label="Parent">
|
|
73
|
+
* <Tree.Item label="Child 1" />
|
|
74
|
+
* <Tree.Item label="Child 2" />
|
|
75
|
+
* </Tree.Item>
|
|
76
|
+
* </Tree.Root>
|
|
77
|
+
* ```
|
|
78
|
+
*
|
|
79
|
+
* The `label` and `icon` props can be used to specify the treeitem's own content. `children` is only used for nested items.
|
|
80
|
+
*
|
|
81
|
+
* The `expanded` and `onExpandedChange` props can be used to control the expansion state of a treeitem.
|
|
82
|
+
*
|
|
83
|
+
* The `selected` and `onSelectedChange` props can be used to control the selection state of a treeitem.
|
|
84
|
+
*/
|
|
85
|
+
declare const TreeItem: React.ForwardRefExoticComponent<TreeItemProps & React.RefAttributes<HTMLElement | HTMLDivElement>>;
|
|
86
|
+
export { Tree as Root, TreeItem as Item };
|