@itwin/itwinui-react 5.0.0-alpha.0 → 5.0.0-alpha.10
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/LICENSE.md +1 -1
- package/README.md +6 -6
- package/dist/DEV/bricks/Anchor.js +16 -23
- package/dist/DEV/bricks/Avatar.js +24 -0
- package/dist/DEV/bricks/Badge.js +22 -0
- package/dist/DEV/bricks/Button.js +25 -16
- package/dist/DEV/bricks/Checkbox.js +26 -16
- package/dist/DEV/bricks/Chip.js +42 -0
- package/dist/DEV/bricks/Description.js +29 -0
- package/dist/DEV/bricks/Divider.js +16 -17
- package/dist/DEV/bricks/DropdownMenu.js +143 -48
- package/dist/DEV/bricks/Field.js +120 -20
- package/dist/DEV/bricks/Icon.js +108 -45
- package/dist/DEV/bricks/IconButton.js +31 -18
- package/dist/DEV/bricks/Kbd.internal.js +19 -0
- package/dist/DEV/bricks/Kbd.js +32 -17
- package/dist/DEV/bricks/Label.js +13 -10
- package/dist/DEV/bricks/ProgressBar.js +25 -0
- package/dist/DEV/bricks/Radio.js +19 -11
- package/dist/DEV/bricks/Root.js +78 -45
- package/dist/DEV/bricks/Select.js +61 -0
- package/dist/DEV/bricks/Skeleton.js +24 -0
- package/dist/DEV/bricks/Spinner.js +40 -0
- package/dist/DEV/bricks/Switch.js +27 -17
- package/dist/DEV/bricks/Table.js +114 -0
- package/dist/DEV/bricks/Tabs.js +19 -20
- package/dist/DEV/bricks/Text.js +20 -0
- package/dist/DEV/bricks/TextBox.js +95 -50
- package/dist/DEV/bricks/Tooltip.js +58 -58
- package/dist/DEV/bricks/Tree.js +16 -102
- package/dist/DEV/bricks/TreeItem.js +224 -0
- package/dist/DEV/bricks/VisuallyHidden.js +7 -5
- package/dist/DEV/bricks/index.js +20 -0
- package/dist/DEV/bricks/styles.css.js +2 -2
- package/dist/DEV/bricks/~hooks.js +55 -3
- package/dist/DEV/bricks/~utils.GhostAligner.js +13 -0
- package/dist/DEV/bricks/~utils.ListItem.js +49 -0
- package/dist/DEV/bricks/~utils.js +3 -0
- package/dist/DEV/foundations/styles.css.js +2 -2
- package/dist/bricks/Anchor.d.ts +12 -3
- package/dist/bricks/Anchor.js +16 -23
- package/dist/bricks/Avatar.d.ts +47 -0
- package/dist/bricks/Avatar.js +23 -0
- package/dist/bricks/Badge.d.ts +28 -0
- package/dist/bricks/Badge.js +21 -0
- package/dist/bricks/Button.d.ts +27 -4
- package/dist/bricks/Button.js +25 -16
- package/dist/bricks/Checkbox.d.ts +19 -5
- package/dist/bricks/Checkbox.js +26 -16
- package/dist/bricks/Chip.d.ts +31 -0
- package/dist/bricks/Chip.js +41 -0
- package/dist/bricks/Description.d.ts +19 -0
- package/dist/bricks/Description.js +29 -0
- package/dist/bricks/Divider.d.ts +5 -6
- package/dist/bricks/Divider.js +16 -17
- package/dist/bricks/DropdownMenu.d.ts +92 -15
- package/dist/bricks/DropdownMenu.js +138 -46
- package/dist/bricks/Field.d.ts +45 -3
- package/dist/bricks/Field.js +120 -20
- package/dist/bricks/Icon.d.ts +38 -7
- package/dist/bricks/Icon.js +105 -44
- package/dist/bricks/IconButton.d.ts +20 -4
- package/dist/bricks/IconButton.js +31 -18
- package/dist/bricks/Kbd.d.ts +17 -3
- package/dist/bricks/Kbd.internal.d.ts +17 -0
- package/dist/bricks/Kbd.internal.js +19 -0
- package/dist/bricks/Kbd.js +25 -17
- package/dist/bricks/Label.d.ts +22 -3
- package/dist/bricks/Label.js +13 -10
- package/dist/bricks/ProgressBar.d.ts +31 -0
- package/dist/bricks/ProgressBar.js +24 -0
- package/dist/bricks/Radio.d.ts +19 -5
- package/dist/bricks/Radio.js +19 -11
- package/dist/bricks/Root.d.ts +11 -2
- package/dist/bricks/Root.js +78 -45
- package/dist/bricks/Select.d.ts +51 -0
- package/dist/bricks/Select.js +61 -0
- package/dist/bricks/Skeleton.d.ts +25 -0
- package/dist/bricks/Skeleton.js +23 -0
- package/dist/bricks/Spinner.d.ts +31 -0
- package/dist/bricks/Spinner.js +39 -0
- package/dist/bricks/Switch.d.ts +19 -5
- package/dist/bricks/Switch.js +27 -17
- package/dist/bricks/Table.d.ts +115 -0
- package/dist/bricks/Table.js +108 -0
- package/dist/bricks/Tabs.d.ts +69 -8
- package/dist/bricks/Tabs.js +19 -20
- package/dist/bricks/Text.d.ts +22 -0
- package/dist/bricks/Text.js +19 -0
- package/dist/bricks/TextBox.d.ts +62 -11
- package/dist/bricks/TextBox.js +94 -50
- package/dist/bricks/Tooltip.d.ts +13 -6
- package/dist/bricks/Tooltip.js +58 -58
- package/dist/bricks/Tree.d.ts +20 -21
- package/dist/bricks/Tree.js +15 -97
- package/dist/bricks/TreeItem.d.ts +123 -0
- package/dist/bricks/TreeItem.js +219 -0
- package/dist/bricks/VisuallyHidden.d.ts +15 -3
- package/dist/bricks/VisuallyHidden.js +7 -5
- package/dist/bricks/index.d.ts +10 -0
- package/dist/bricks/index.js +20 -0
- package/dist/bricks/styles.css.js +2 -2
- package/dist/bricks/~hooks.d.ts +55 -0
- package/dist/bricks/~hooks.js +55 -3
- package/dist/bricks/~utils.GhostAligner.d.ts +22 -0
- package/dist/bricks/~utils.GhostAligner.js +13 -0
- package/dist/bricks/~utils.ListItem.d.ts +14 -0
- package/dist/bricks/~utils.ListItem.js +46 -0
- package/dist/bricks/~utils.d.ts +26 -3
- package/dist/bricks/~utils.js +3 -0
- package/dist/foundations/styles.css.js +2 -2
- package/package.json +14 -13
- package/dist/DEV/bricks/ListItem.js +0 -33
- package/dist/DEV/bricks/Textarea.js +0 -28
- package/dist/bricks/ListItem.d.ts +0 -11
- package/dist/bricks/ListItem.js +0 -31
- package/dist/bricks/Textarea.d.ts +0 -14
- package/dist/bricks/Textarea.js +0 -27
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Role } from "@ariakit/react/role";
|
|
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
|
+
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,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { Icon } from "./Icon.js";
|
|
3
|
-
import {
|
|
4
|
-
import type { FocusableProps, BaseProps } from "./~utils.js";
|
|
3
|
+
import { type FocusableProps, type BaseProps } from "./~utils.js";
|
|
5
4
|
interface BaseInputProps extends FocusableProps<"input"> {
|
|
6
5
|
}
|
|
7
6
|
interface TextBoxInputProps extends Omit<BaseInputProps, "children" | "type"> {
|
|
@@ -16,7 +15,7 @@ interface TextBoxInputProps extends Omit<BaseInputProps, "children" | "type"> {
|
|
|
16
15
|
type?: Extract<BaseInputProps["type"], "text" | "email" | "password" | "search" | "tel" | "url" | "number" | "date">;
|
|
17
16
|
}
|
|
18
17
|
/**
|
|
19
|
-
*
|
|
18
|
+
* An input component that allows users to enter text based values.
|
|
20
19
|
*
|
|
21
20
|
* Example usage:
|
|
22
21
|
* ```tsx
|
|
@@ -24,26 +23,78 @@ interface TextBoxInputProps extends Omit<BaseInputProps, "children" | "type"> {
|
|
|
24
23
|
* ```
|
|
25
24
|
*
|
|
26
25
|
* To add additional decorations, see `TextBox.Root` component.
|
|
26
|
+
*
|
|
27
|
+
* Works well with the `Field` and `Label` components.
|
|
28
|
+
* ```tsx
|
|
29
|
+
* <Field>
|
|
30
|
+
* <Label>Enter your name</Label>
|
|
31
|
+
* <TextBox.Input />
|
|
32
|
+
* </Field>
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* Underneath, it's an HTML input, i.e. `<input>`, so it supports the same props, including
|
|
36
|
+
* `value`, `defaultValue`, `onChange`, and `disabled`.
|
|
37
|
+
*
|
|
38
|
+
* For a multiline text input, use the `TextBox.Textarea` component.
|
|
27
39
|
*/
|
|
28
|
-
declare const TextBoxInput: React.ForwardRefExoticComponent<TextBoxInputProps & React.RefAttributes<HTMLInputElement>>;
|
|
40
|
+
declare const TextBoxInput: React.ForwardRefExoticComponent<TextBoxInputProps & React.RefAttributes<HTMLElement | HTMLInputElement>>;
|
|
41
|
+
interface TextareaProps extends FocusableProps<"textarea"> {
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* A styled textarea element that allows users to enter multiline text values.
|
|
45
|
+
*
|
|
46
|
+
* Example usage:
|
|
47
|
+
* ```tsx
|
|
48
|
+
* <TextBox.Textarea defaultValue="Hello" />
|
|
49
|
+
* ```
|
|
50
|
+
*
|
|
51
|
+
* Works well with the `Field` and `Label` components.
|
|
52
|
+
* ```tsx
|
|
53
|
+
* <Field>
|
|
54
|
+
* <Label>Leave a comment, be kind</Label>
|
|
55
|
+
* <TextBox.Textarea />
|
|
56
|
+
* </Field>
|
|
57
|
+
* ```
|
|
58
|
+
*
|
|
59
|
+
* Underneath, it's an HTML textarea, i.e. `<textarea>`, so it supports the same props, including
|
|
60
|
+
* `value`, `defaultValue`, `onChange`, and `disabled`.
|
|
61
|
+
*/
|
|
62
|
+
declare const TextBoxTextarea: React.ForwardRefExoticComponent<TextareaProps & React.RefAttributes<HTMLElement | HTMLTextAreaElement>>;
|
|
29
63
|
interface TextBoxRootProps extends BaseProps {
|
|
30
64
|
}
|
|
31
65
|
/**
|
|
32
|
-
*
|
|
66
|
+
* Compound component for a text input. Allows adding additional decorations.
|
|
33
67
|
*
|
|
34
68
|
* Example usage to add an end icon:
|
|
35
69
|
* ```tsx
|
|
36
70
|
* <TextBox.Root>
|
|
37
|
-
*
|
|
38
|
-
*
|
|
71
|
+
* <TextBox.Input defaultValue="Hello" />
|
|
72
|
+
* <TextBox.Icon href={...} />
|
|
39
73
|
* </TextBox.Root>
|
|
40
74
|
* ```
|
|
75
|
+
*
|
|
76
|
+
* Works well with the `Field` and `Label` components.
|
|
77
|
+
* ```tsx
|
|
78
|
+
* <Field>
|
|
79
|
+
* <Label>Enter your name</Label>
|
|
80
|
+
* <TextBox.Root>
|
|
81
|
+
* <TextBox.Input />
|
|
82
|
+
* <TextBox.Icon href={…} />
|
|
83
|
+
* </TextBox.Root>
|
|
84
|
+
* </Field>
|
|
85
|
+
* ```
|
|
41
86
|
*/
|
|
42
|
-
declare const TextBoxRoot: React.ForwardRefExoticComponent<TextBoxRootProps & React.RefAttributes<HTMLDivElement>>;
|
|
87
|
+
declare const TextBoxRoot: React.ForwardRefExoticComponent<TextBoxRootProps & React.RefAttributes<HTMLElement | HTMLDivElement>>;
|
|
43
88
|
interface TextBoxIconProps extends React.ComponentProps<typeof Icon> {
|
|
44
89
|
}
|
|
45
|
-
|
|
90
|
+
/**
|
|
91
|
+
* A static icon decoration for the `TextBox.Root` component. Can be added before or after the `TextBox.Input`.
|
|
92
|
+
*/
|
|
93
|
+
declare const TextBoxIcon: React.ForwardRefExoticComponent<Omit<TextBoxIconProps, "ref"> & React.RefAttributes<HTMLElement | SVGSVGElement>>;
|
|
46
94
|
interface TextBoxTextProps extends BaseProps<"span"> {
|
|
47
95
|
}
|
|
48
|
-
|
|
49
|
-
|
|
96
|
+
/**
|
|
97
|
+
* A static text decoration for the `TextBox.Root` component. Can be added before or after the `TextBox.Input`.
|
|
98
|
+
*/
|
|
99
|
+
declare const TextBoxText: React.ForwardRefExoticComponent<TextBoxTextProps & React.RefAttributes<HTMLElement | HTMLSpanElement>>;
|
|
100
|
+
export { TextBoxRoot as Root, TextBoxInput as Input, TextBoxTextarea as Textarea, TextBoxIcon as Icon, TextBoxText as Text, };
|
package/dist/bricks/TextBox.js
CHANGED
|
@@ -1,36 +1,76 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import * as React from "react";
|
|
3
|
-
import
|
|
3
|
+
import { Role } from "@ariakit/react/role";
|
|
4
|
+
import { Focusable } from "@ariakit/react/focusable";
|
|
4
5
|
import cx from "classnames";
|
|
5
|
-
import {
|
|
6
|
+
import { FieldControl } from "./Field.js";
|
|
6
7
|
import { Icon } from "./Icon.js";
|
|
7
|
-
import { Textarea } from "./Textarea.js";
|
|
8
8
|
import { useMergedRefs } from "./~hooks.js";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
setDisabled?.
|
|
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 { id, ...rest } = props;
|
|
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
|
+
FieldControl,
|
|
20
|
+
{
|
|
21
|
+
type: "textlike",
|
|
22
|
+
id,
|
|
23
|
+
render: /* @__PURE__ */ jsx(
|
|
24
|
+
Role.input,
|
|
25
|
+
{
|
|
26
|
+
readOnly: props.disabled,
|
|
27
|
+
...rest,
|
|
28
|
+
className: cx({ "\u{1F95D}-text-box": !rootContext }, props.className),
|
|
29
|
+
placeholder: props.placeholder ?? " ",
|
|
30
|
+
render: /* @__PURE__ */ jsx(
|
|
31
|
+
Focusable,
|
|
32
|
+
{
|
|
33
|
+
accessibleWhenDisabled: true,
|
|
34
|
+
render: props.render || /* @__PURE__ */ jsx("input", {})
|
|
35
|
+
}
|
|
36
|
+
),
|
|
37
|
+
ref: useMergedRefs(rootContext?.inputRef, forwardedRef)
|
|
38
|
+
}
|
|
39
|
+
)
|
|
40
|
+
}
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
);
|
|
44
|
+
const TextBoxTextarea = forwardRef(
|
|
45
|
+
(props, forwardedRef) => {
|
|
46
|
+
const { id, ...rest } = props;
|
|
47
|
+
return /* @__PURE__ */ jsx(
|
|
48
|
+
FieldControl,
|
|
49
|
+
{
|
|
50
|
+
type: "textlike",
|
|
51
|
+
id,
|
|
52
|
+
render: /* @__PURE__ */ jsx(
|
|
53
|
+
Role.textarea,
|
|
54
|
+
{
|
|
55
|
+
readOnly: props.disabled,
|
|
56
|
+
...rest,
|
|
57
|
+
className: cx("\u{1F95D}-text-box", props.className),
|
|
58
|
+
placeholder: props.placeholder ?? " ",
|
|
59
|
+
render: /* @__PURE__ */ jsx(
|
|
60
|
+
Focusable,
|
|
61
|
+
{
|
|
62
|
+
accessibleWhenDisabled: true,
|
|
63
|
+
render: props.render || /* @__PURE__ */ jsx("textarea", {})
|
|
64
|
+
}
|
|
65
|
+
),
|
|
66
|
+
ref: forwardedRef
|
|
67
|
+
}
|
|
68
|
+
)
|
|
69
|
+
}
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
);
|
|
73
|
+
const TextBoxRoot = forwardRef(
|
|
34
74
|
(props, forwardedRef) => {
|
|
35
75
|
const inputRef = React.useRef(null);
|
|
36
76
|
const [disabled, setDisabled] = React.useState();
|
|
@@ -39,7 +79,7 @@ const TextBoxRoot = React.forwardRef(
|
|
|
39
79
|
{
|
|
40
80
|
value: React.useMemo(() => ({ setDisabled, inputRef }), []),
|
|
41
81
|
children: /* @__PURE__ */ jsx(
|
|
42
|
-
|
|
82
|
+
Role.div,
|
|
43
83
|
{
|
|
44
84
|
...props,
|
|
45
85
|
"data-kiwi-disabled": disabled,
|
|
@@ -59,31 +99,35 @@ const TextBoxRoot = React.forwardRef(
|
|
|
59
99
|
);
|
|
60
100
|
}
|
|
61
101
|
);
|
|
62
|
-
const TextBoxIcon =
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
102
|
+
const TextBoxIcon = forwardRef(
|
|
103
|
+
(props, forwardedRef) => {
|
|
104
|
+
return /* @__PURE__ */ jsx(
|
|
105
|
+
Icon,
|
|
106
|
+
{
|
|
107
|
+
...props,
|
|
108
|
+
className: cx("\u{1F95D}-text-box-decoration", props.className),
|
|
109
|
+
ref: forwardedRef
|
|
110
|
+
}
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
);
|
|
114
|
+
const TextBoxText = forwardRef(
|
|
115
|
+
(props, forwardedRef) => {
|
|
116
|
+
return /* @__PURE__ */ jsx(
|
|
117
|
+
Role.span,
|
|
118
|
+
{
|
|
119
|
+
...props,
|
|
120
|
+
className: cx("\u{1F95D}-text-box-decoration", props.className),
|
|
121
|
+
ref: forwardedRef
|
|
122
|
+
}
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
);
|
|
82
126
|
const TextBoxRootContext = React.createContext(void 0);
|
|
83
127
|
export {
|
|
84
128
|
TextBoxIcon as Icon,
|
|
85
129
|
TextBoxInput as Input,
|
|
86
130
|
TextBoxRoot as Root,
|
|
87
131
|
TextBoxText as Text,
|
|
88
|
-
Textarea
|
|
132
|
+
TextBoxTextarea as Textarea
|
|
89
133
|
};
|
package/dist/bricks/Tooltip.d.ts
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import * as
|
|
2
|
+
import * as AkTooltip from "@ariakit/react/tooltip";
|
|
3
3
|
import { type FocusableProps } from "./~utils.js";
|
|
4
|
-
interface TooltipProps extends Omit<FocusableProps<"div">, "content">, Pick<
|
|
4
|
+
interface TooltipProps extends Omit<FocusableProps<"div">, "content">, Pick<AkTooltip.TooltipProps, "open" | "unmountOnHide">, Pick<AkTooltip.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
|
@@ -1,67 +1,67 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import cx from "classnames";
|
|
4
|
-
import * as
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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,
|
|
4
|
+
import * as AkTooltip from "@ariakit/react/tooltip";
|
|
5
|
+
import { useStoreState } from "@ariakit/react/store";
|
|
6
|
+
import { forwardRef } from "./~utils.js";
|
|
7
|
+
import { usePopoverApi } from "./~hooks.js";
|
|
8
|
+
const Tooltip = forwardRef(
|
|
9
|
+
(props, forwardedRef) => {
|
|
10
|
+
const generatedId = React.useId();
|
|
11
|
+
const {
|
|
12
|
+
content,
|
|
13
|
+
children,
|
|
14
|
+
type = "description",
|
|
15
|
+
id = generatedId,
|
|
34
16
|
defaultOpen: defaultOpenProp,
|
|
35
17
|
open: openProp,
|
|
36
18
|
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
|
-
|
|
19
|
+
unmountOnHide = type === "none",
|
|
20
|
+
...rest
|
|
21
|
+
} = props;
|
|
22
|
+
const store = AkTooltip.useTooltipStore();
|
|
23
|
+
const open = useStoreState(store, (store2) => store2.open);
|
|
24
|
+
const popover = usePopoverApi(store);
|
|
25
|
+
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(
|
|
26
|
+
AkTooltip.TooltipProvider,
|
|
27
|
+
{
|
|
28
|
+
store,
|
|
29
|
+
defaultOpen: defaultOpenProp,
|
|
30
|
+
open: openProp,
|
|
31
|
+
setOpen: setOpenProp,
|
|
32
|
+
children: [
|
|
33
|
+
/* @__PURE__ */ jsx(
|
|
34
|
+
AkTooltip.TooltipAnchor,
|
|
35
|
+
{
|
|
36
|
+
render: children,
|
|
37
|
+
"data-has-popover-open": open || void 0,
|
|
38
|
+
...type === "description" && { "aria-describedby": id },
|
|
39
|
+
...type === "label" && { "aria-labelledby": id }
|
|
40
|
+
}
|
|
41
|
+
),
|
|
42
|
+
/* @__PURE__ */ jsx(
|
|
43
|
+
AkTooltip.Tooltip,
|
|
44
|
+
{
|
|
45
|
+
"aria-hidden": "true",
|
|
46
|
+
...rest,
|
|
47
|
+
unmountOnHide,
|
|
48
|
+
className: cx("\u{1F95D}-tooltip", props.className),
|
|
49
|
+
ref: forwardedRef,
|
|
50
|
+
id,
|
|
51
|
+
style: {
|
|
52
|
+
...popover.style,
|
|
53
|
+
...props.style
|
|
54
|
+
},
|
|
55
|
+
wrapperProps: popover.wrapperProps,
|
|
56
|
+
portal: popover.portal,
|
|
57
|
+
children: content
|
|
58
|
+
}
|
|
59
|
+
)
|
|
60
|
+
]
|
|
61
|
+
}
|
|
62
|
+
) });
|
|
63
|
+
}
|
|
64
|
+
);
|
|
65
65
|
export {
|
|
66
66
|
Tooltip
|
|
67
67
|
};
|
package/dist/bricks/Tree.d.ts
CHANGED
|
@@ -1,23 +1,22 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import type { BaseProps } from "./~utils.js";
|
|
1
|
+
import { type BaseProps } from "./~utils.js";
|
|
2
|
+
import { Root as TreeItemRoot, Action as TreeItemAction } from "./TreeItem.js";
|
|
4
3
|
interface TreeProps extends BaseProps {
|
|
5
4
|
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
declare const
|
|
23
|
-
export { Tree as Root,
|
|
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 are rendered as a flat list in the `Tree.Root` component to create a hierarchical tree structure.
|
|
9
|
+
*
|
|
10
|
+
* Example:
|
|
11
|
+
* ```tsx
|
|
12
|
+
* <Tree.Root>
|
|
13
|
+
* <Tree.Item label="Parent 1" aria-level={1} aria-posinset={1} aria-setsize={2} />
|
|
14
|
+
* <Tree.Item label="Child 1.1" aria-level={2} aria-posinset={1} aria-setsize={2} />
|
|
15
|
+
* <Tree.Item label="Child 1.2" aria-level={2} aria-posinset={2} aria-setsize={2} />
|
|
16
|
+
* <Tree.Item label="Parent 2" aria-level={1} aria-posinset={2} aria-setsize={2} />
|
|
17
|
+
* <Tree.Item label="Child 2.1" aria-level={2} aria-posinset={1} aria-setsize={1} />
|
|
18
|
+
* </Tree.Root>
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
declare const Tree: import("react").ForwardRefExoticComponent<TreeProps & import("react").RefAttributes<HTMLElement | HTMLDivElement>>;
|
|
22
|
+
export { Tree as Root, TreeItemRoot as Item, TreeItemAction as ItemAction };
|
package/dist/bricks/Tree.js
CHANGED
|
@@ -1,107 +1,25 @@
|
|
|
1
|
-
import { jsx
|
|
2
|
-
import * as React from "react";
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
2
|
import cx from "classnames";
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
const Tree =
|
|
9
|
-
(
|
|
10
|
-
return /* @__PURE__ */ jsx(Ariakit.Role.div, { ...props, role: "list", ref: forwardedRef, children: props.children });
|
|
11
|
-
}
|
|
12
|
-
);
|
|
13
|
-
const TreeItem = React.forwardRef(
|
|
14
|
-
(props, forwardedRef) => {
|
|
15
|
-
const { selected, content, children, className, expanded, style, ...rest } = props;
|
|
16
|
-
const parentContext = React.useContext(TreeItemContext);
|
|
17
|
-
const level = parentContext ? parentContext.level + 1 : 1;
|
|
18
|
-
return /* @__PURE__ */ jsx(
|
|
19
|
-
TreeItemContext.Provider,
|
|
20
|
-
{
|
|
21
|
-
value: React.useMemo(
|
|
22
|
-
() => ({
|
|
23
|
-
level,
|
|
24
|
-
expanded
|
|
25
|
-
}),
|
|
26
|
-
[level, expanded]
|
|
27
|
-
),
|
|
28
|
-
children: /* @__PURE__ */ jsxs("div", { role: "listitem", children: [
|
|
29
|
-
/* @__PURE__ */ jsx(
|
|
30
|
-
ListItem.Root,
|
|
31
|
-
{
|
|
32
|
-
...rest,
|
|
33
|
-
"data-kiwi-expanded": expanded,
|
|
34
|
-
"data-kiwi-selected": selected,
|
|
35
|
-
className: cx("\u{1F95D}-tree-item", className),
|
|
36
|
-
style: {
|
|
37
|
-
...style,
|
|
38
|
-
"--\u{1F95D}tree-item-level": level
|
|
39
|
-
},
|
|
40
|
-
ref: forwardedRef,
|
|
41
|
-
role: void 0,
|
|
42
|
-
children: content
|
|
43
|
-
}
|
|
44
|
-
),
|
|
45
|
-
children && /* @__PURE__ */ jsx("div", { role: "list", children })
|
|
46
|
-
] })
|
|
47
|
-
}
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
);
|
|
51
|
-
const TreeItemContent = React.forwardRef((props, forwardedRef) => {
|
|
3
|
+
import { Role } from "@ariakit/react/role";
|
|
4
|
+
import { useCompositeStore, Composite } from "@ariakit/react/composite";
|
|
5
|
+
import { forwardRef } from "./~utils.js";
|
|
6
|
+
import { Root as TreeItemRoot, Action as TreeItemAction } from "./TreeItem.js";
|
|
7
|
+
const Tree = forwardRef((props, forwardedRef) => {
|
|
8
|
+
const composite = useCompositeStore({ orientation: "vertical" });
|
|
52
9
|
return /* @__PURE__ */ jsx(
|
|
53
|
-
|
|
10
|
+
Role.div,
|
|
54
11
|
{
|
|
12
|
+
role: "tree",
|
|
55
13
|
...props,
|
|
56
|
-
|
|
57
|
-
|
|
14
|
+
render: /* @__PURE__ */ jsx(Composite, { store: composite }),
|
|
15
|
+
className: cx("\u{1F95D}-tree", props.className),
|
|
16
|
+
ref: forwardedRef,
|
|
17
|
+
children: props.children
|
|
58
18
|
}
|
|
59
19
|
);
|
|
60
20
|
});
|
|
61
|
-
const TreeItemExpander = React.forwardRef((props, forwardedRef) => {
|
|
62
|
-
const context = React.useContext(TreeItemContext);
|
|
63
|
-
const expanded = context?.expanded;
|
|
64
|
-
return /* @__PURE__ */ jsx(
|
|
65
|
-
IconButton,
|
|
66
|
-
{
|
|
67
|
-
icon: /* @__PURE__ */ jsx(TreeChevron, {}),
|
|
68
|
-
label: "Toggle",
|
|
69
|
-
"aria-expanded": expanded === void 0 ? void 0 : expanded,
|
|
70
|
-
...props,
|
|
71
|
-
className: cx("\u{1F95D}-tree-item-expander", props.className),
|
|
72
|
-
variant: "ghost",
|
|
73
|
-
labelVariant: "visually-hidden",
|
|
74
|
-
ref: forwardedRef
|
|
75
|
-
}
|
|
76
|
-
);
|
|
77
|
-
});
|
|
78
|
-
const TreeChevron = React.forwardRef(
|
|
79
|
-
(props, forwardedRef) => {
|
|
80
|
-
return /* @__PURE__ */ jsx(
|
|
81
|
-
Icon,
|
|
82
|
-
{
|
|
83
|
-
...props,
|
|
84
|
-
render: /* @__PURE__ */ jsx(
|
|
85
|
-
Ariakit.Role.svg,
|
|
86
|
-
{
|
|
87
|
-
width: "16",
|
|
88
|
-
height: "16",
|
|
89
|
-
fill: "currentColor",
|
|
90
|
-
viewBox: "0 0 16 16",
|
|
91
|
-
render: props.render,
|
|
92
|
-
children: /* @__PURE__ */ jsx("path", { d: "M4.146 6.146a.5.5 0 0 1 .708 0L8 9.293l3.146-3.147a.5.5 0 0 1 .708.708l-3.5 3.5a.5.5 0 0 1-.708 0l-3.5-3.5a.5.5 0 0 1 0-.708Z" })
|
|
93
|
-
}
|
|
94
|
-
),
|
|
95
|
-
className: cx("\u{1F95D}-tree-chevron", props.className),
|
|
96
|
-
ref: forwardedRef
|
|
97
|
-
}
|
|
98
|
-
);
|
|
99
|
-
}
|
|
100
|
-
);
|
|
101
|
-
const TreeItemContext = React.createContext(void 0);
|
|
102
21
|
export {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
TreeItem as Item,
|
|
22
|
+
TreeItemRoot as Item,
|
|
23
|
+
TreeItemAction as ItemAction,
|
|
106
24
|
Tree as Root
|
|
107
25
|
};
|