@itwin/itwinui-react 5.0.0-alpha.1 → 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 +10 -0
- package/dist/DEV/bricks/Anchor.js +1 -1
- package/dist/DEV/bricks/Button.js +1 -1
- package/dist/DEV/bricks/Checkbox.js +3 -1
- package/dist/DEV/bricks/Chip.js +21 -0
- package/dist/DEV/bricks/Description.js +27 -0
- package/dist/DEV/bricks/Field.js +56 -5
- package/dist/DEV/bricks/Icon.js +1 -1
- package/dist/DEV/bricks/IconButton.js +3 -0
- package/dist/DEV/bricks/Kbd.js +36 -4
- package/dist/DEV/bricks/Radio.js +3 -1
- package/dist/DEV/bricks/Select.js +3 -1
- package/dist/DEV/bricks/Spinner.js +40 -0
- package/dist/DEV/bricks/Switch.js +3 -1
- package/dist/DEV/bricks/Tabs.js +1 -1
- package/dist/DEV/bricks/TextBox.js +3 -1
- package/dist/DEV/bricks/Textarea.js +3 -1
- package/dist/DEV/bricks/Tooltip.js +3 -3
- package/dist/DEV/bricks/Tree.js +77 -16
- package/dist/DEV/bricks/index.js +8 -0
- package/dist/DEV/bricks/styles.css.js +1 -1
- package/dist/DEV/bricks/~hooks.js +13 -0
- package/dist/DEV/foundations/styles.css.js +1 -1
- package/dist/bricks/Anchor.js +1 -1
- package/dist/bricks/Button.js +1 -1
- package/dist/bricks/Checkbox.js +3 -1
- 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/Field.d.ts +8 -0
- package/dist/bricks/Field.js +56 -5
- package/dist/bricks/Icon.js +1 -1
- package/dist/bricks/IconButton.js +3 -0
- package/dist/bricks/Kbd.d.ts +30 -0
- package/dist/bricks/Kbd.js +29 -4
- package/dist/bricks/Radio.js +3 -1
- package/dist/bricks/Select.js +3 -1
- package/dist/bricks/Spinner.d.ts +31 -0
- package/dist/bricks/Spinner.js +39 -0
- package/dist/bricks/Switch.js +3 -1
- package/dist/bricks/Tabs.d.ts +1 -1
- package/dist/bricks/Tabs.js +1 -1
- package/dist/bricks/TextBox.js +3 -1
- package/dist/bricks/Textarea.js +3 -1
- package/dist/bricks/Tooltip.js +3 -3
- package/dist/bricks/Tree.d.ts +76 -13
- package/dist/bricks/Tree.js +74 -14
- package/dist/bricks/index.d.ts +4 -0
- package/dist/bricks/index.js +8 -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/foundations/styles.css.js +1 -1
- package/package.json +2 -2
package/dist/bricks/Kbd.d.ts
CHANGED
|
@@ -1,7 +1,33 @@
|
|
|
1
1
|
import { type BaseProps } from "./~utils.js";
|
|
2
|
+
declare const predefinedSymbols: {
|
|
3
|
+
readonly Backspace: "⌫";
|
|
4
|
+
readonly Command: "⌘";
|
|
5
|
+
readonly Control: "Ctrl";
|
|
6
|
+
readonly Down: "↓";
|
|
7
|
+
readonly Eject: "⏏";
|
|
8
|
+
readonly Enter: "↵";
|
|
9
|
+
readonly Escape: "Esc";
|
|
10
|
+
readonly Left: "←";
|
|
11
|
+
readonly Option: "⌥";
|
|
12
|
+
readonly Right: "→";
|
|
13
|
+
readonly Shift: "⇧";
|
|
14
|
+
readonly Space: "␣";
|
|
15
|
+
readonly Tab: "Tab";
|
|
16
|
+
readonly Up: "↑";
|
|
17
|
+
};
|
|
2
18
|
interface KbdProps extends BaseProps<"kbd"> {
|
|
3
19
|
/** @default "solid" */
|
|
4
20
|
variant?: "solid" | "muted" | "ghost";
|
|
21
|
+
/**
|
|
22
|
+
* Display a specific key symbol from a predefined list. This is useful for
|
|
23
|
+
* displaying modifier keys or special keys, such as `Control`, `Shift`, `Enter`, etc.
|
|
24
|
+
*
|
|
25
|
+
* Example:
|
|
26
|
+
* ```tsx
|
|
27
|
+
* <Kbd symbol="Control" />
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
symbol?: keyof typeof predefinedSymbols;
|
|
5
31
|
}
|
|
6
32
|
/**
|
|
7
33
|
* A styled wrapper over the HTML `<kbd>` element. This is typically
|
|
@@ -10,6 +36,10 @@ interface KbdProps extends BaseProps<"kbd"> {
|
|
|
10
36
|
* ```tsx
|
|
11
37
|
* <Kbd>Ctrl</Kbd> <Kbd>S</Kbd>
|
|
12
38
|
* ```
|
|
39
|
+
*
|
|
40
|
+
* ```tsx
|
|
41
|
+
* <Kbd symbol="Control" />
|
|
42
|
+
* ```
|
|
13
43
|
*/
|
|
14
44
|
export declare const Kbd: import("react").ForwardRefExoticComponent<KbdProps & import("react").RefAttributes<HTMLElement>>;
|
|
15
45
|
export {};
|
package/dist/bricks/Kbd.js
CHANGED
|
@@ -1,17 +1,42 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import cx from "classnames";
|
|
3
3
|
import * as Ariakit from "@ariakit/react";
|
|
4
4
|
import { forwardRef } from "./~utils.js";
|
|
5
|
+
import { VisuallyHidden } from "./VisuallyHidden.js";
|
|
6
|
+
const predefinedSymbols = {
|
|
7
|
+
Backspace: "\u232B",
|
|
8
|
+
Command: "\u2318",
|
|
9
|
+
Control: "Ctrl",
|
|
10
|
+
Down: "\u2193",
|
|
11
|
+
Eject: "\u23CF",
|
|
12
|
+
Enter: "\u21B5",
|
|
13
|
+
Escape: "Esc",
|
|
14
|
+
Left: "\u2190",
|
|
15
|
+
Option: "\u2325",
|
|
16
|
+
Right: "\u2192",
|
|
17
|
+
Shift: "\u21E7",
|
|
18
|
+
Space: "\u2423",
|
|
19
|
+
Tab: "Tab",
|
|
20
|
+
Up: "\u2191"
|
|
21
|
+
};
|
|
5
22
|
const Kbd = forwardRef((props, forwardedRef) => {
|
|
6
|
-
const { variant = "solid", ...rest } = props;
|
|
23
|
+
const { variant = "solid", symbol, children, ...rest } = props;
|
|
24
|
+
let content = children;
|
|
25
|
+
if (symbol) {
|
|
26
|
+
content = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
27
|
+
/* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: predefinedSymbols[symbol] }),
|
|
28
|
+
children || /* @__PURE__ */ jsx(VisuallyHidden, { children: symbol })
|
|
29
|
+
] });
|
|
30
|
+
}
|
|
7
31
|
return /* @__PURE__ */ jsx(
|
|
8
32
|
Ariakit.Role,
|
|
9
33
|
{
|
|
10
|
-
"data-kiwi-variant": variant,
|
|
11
34
|
...rest,
|
|
35
|
+
"data-kiwi-variant": variant,
|
|
12
36
|
className: cx("\u{1F95D}-kbd", props.className),
|
|
13
37
|
render: props.render || /* @__PURE__ */ jsx("kbd", {}),
|
|
14
|
-
ref: forwardedRef
|
|
38
|
+
ref: forwardedRef,
|
|
39
|
+
children: content
|
|
15
40
|
}
|
|
16
41
|
);
|
|
17
42
|
});
|
package/dist/bricks/Radio.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import cx from "classnames";
|
|
3
3
|
import * as Ariakit from "@ariakit/react";
|
|
4
|
-
import { useFieldId } from "./Field.js";
|
|
4
|
+
import { useFieldDescribedBy, useFieldId } from "./Field.js";
|
|
5
5
|
import { forwardRef } from "./~utils.js";
|
|
6
6
|
const Radio = forwardRef((props, forwardedRef) => {
|
|
7
7
|
const fieldId = useFieldId();
|
|
8
|
+
const describedBy = useFieldDescribedBy(props["aria-describedby"]);
|
|
8
9
|
return /* @__PURE__ */ jsx(
|
|
9
10
|
Ariakit.Radio,
|
|
10
11
|
{
|
|
@@ -12,6 +13,7 @@ const Radio = forwardRef((props, forwardedRef) => {
|
|
|
12
13
|
id: fieldId,
|
|
13
14
|
...props,
|
|
14
15
|
className: cx("\u{1F95D}-checkbox", "\u{1F95D}-radio", props.className),
|
|
16
|
+
"aria-describedby": describedBy,
|
|
15
17
|
ref: forwardedRef
|
|
16
18
|
}
|
|
17
19
|
);
|
package/dist/bricks/Select.js
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
isBrowser
|
|
8
8
|
} from "./~utils.js";
|
|
9
9
|
import { DisclosureArrow } from "./Icon.js";
|
|
10
|
-
import { useFieldId } from "./Field.js";
|
|
10
|
+
import { useFieldDescribedBy, useFieldId } from "./Field.js";
|
|
11
11
|
const supportsHas = isBrowser && CSS?.supports?.("selector(:has(+ *))");
|
|
12
12
|
const HtmlSelectContext = React.createContext(() => {
|
|
13
13
|
});
|
|
@@ -27,6 +27,7 @@ const HtmlSelect = forwardRef(
|
|
|
27
27
|
(props, forwardedRef) => {
|
|
28
28
|
const setIsHtmlSelect = React.useContext(HtmlSelectContext);
|
|
29
29
|
const fieldId = useFieldId();
|
|
30
|
+
const describedBy = useFieldDescribedBy(props["aria-describedby"]);
|
|
30
31
|
React.useEffect(
|
|
31
32
|
function updateContext() {
|
|
32
33
|
setIsHtmlSelect(true);
|
|
@@ -40,6 +41,7 @@ const HtmlSelect = forwardRef(
|
|
|
40
41
|
id: fieldId,
|
|
41
42
|
...props,
|
|
42
43
|
className: cx("\u{1F95D}-button", "\u{1F95D}-select", props.className),
|
|
44
|
+
"aria-describedby": describedBy,
|
|
43
45
|
"data-kiwi-tone": "neutral",
|
|
44
46
|
"data-kiwi-variant": "solid",
|
|
45
47
|
ref: forwardedRef
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type BaseProps } from "./~utils.js";
|
|
2
|
+
interface SpinnerProps extends BaseProps {
|
|
3
|
+
/**
|
|
4
|
+
* A text alternative for the spinner.
|
|
5
|
+
* @default "Loading…"
|
|
6
|
+
*/
|
|
7
|
+
alt?: string;
|
|
8
|
+
/**
|
|
9
|
+
* The size of the spinner.
|
|
10
|
+
* @default "medium"
|
|
11
|
+
*/
|
|
12
|
+
size?: "small" | "medium" | "large" | "xlarge";
|
|
13
|
+
/**
|
|
14
|
+
* The tone of the spinner.
|
|
15
|
+
* @default "neutral"
|
|
16
|
+
*/
|
|
17
|
+
tone?: "neutral" | "accent";
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* A loading spinner.
|
|
21
|
+
*
|
|
22
|
+
* Example:
|
|
23
|
+
* ```tsx
|
|
24
|
+
* <Spinner />
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* Supports a `tone` prop to change the tone (color) of the spinner.
|
|
28
|
+
* Supports a `size` prop to change the size of the spinner.
|
|
29
|
+
*/
|
|
30
|
+
export declare const Spinner: import("react").ForwardRefExoticComponent<SpinnerProps & import("react").RefAttributes<HTMLElement | HTMLDivElement>>;
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as Ariakit from "@ariakit/react";
|
|
3
|
+
import cx from "classnames";
|
|
4
|
+
import { VisuallyHidden } from "./VisuallyHidden.js";
|
|
5
|
+
import { forwardRef } from "./~utils.js";
|
|
6
|
+
const Spinner = forwardRef(
|
|
7
|
+
(props, forwardedRef) => {
|
|
8
|
+
const {
|
|
9
|
+
alt = "Loading\u2026",
|
|
10
|
+
size = "medium",
|
|
11
|
+
tone = "neutral",
|
|
12
|
+
...rest
|
|
13
|
+
} = props;
|
|
14
|
+
return /* @__PURE__ */ jsxs(
|
|
15
|
+
Ariakit.Role,
|
|
16
|
+
{
|
|
17
|
+
...rest,
|
|
18
|
+
"data-kiwi-size": size,
|
|
19
|
+
"data-kiwi-tone": tone,
|
|
20
|
+
className: cx("\u{1F95D}-spinner", props.className),
|
|
21
|
+
ref: forwardedRef,
|
|
22
|
+
children: [
|
|
23
|
+
/* @__PURE__ */ jsx("svg", { "aria-hidden": "true", className: "\u{1F95D}-spinner-svg", viewBox: "0 0 16 16", children: /* @__PURE__ */ jsx(
|
|
24
|
+
"path",
|
|
25
|
+
{
|
|
26
|
+
stroke: "currentColor",
|
|
27
|
+
"stroke-linecap": "round",
|
|
28
|
+
d: "M9.5 1.674a6.503 6.503 0 0 1 0 12.652m-3-12.652a6.503 6.503 0 0 0 0 12.652"
|
|
29
|
+
}
|
|
30
|
+
) }),
|
|
31
|
+
/* @__PURE__ */ jsx(VisuallyHidden, { children: alt })
|
|
32
|
+
]
|
|
33
|
+
}
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
);
|
|
37
|
+
export {
|
|
38
|
+
Spinner
|
|
39
|
+
};
|
package/dist/bricks/Switch.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import cx from "classnames";
|
|
3
3
|
import * as Ariakit from "@ariakit/react";
|
|
4
|
-
import { useFieldId } from "./Field.js";
|
|
4
|
+
import { useFieldDescribedBy, useFieldId } from "./Field.js";
|
|
5
5
|
import { forwardRef } from "./~utils.js";
|
|
6
6
|
const Switch = forwardRef(
|
|
7
7
|
(props, forwardedRef) => {
|
|
8
8
|
const fieldId = useFieldId();
|
|
9
|
+
const describedBy = useFieldDescribedBy(props["aria-describedby"]);
|
|
9
10
|
return /* @__PURE__ */ jsx(
|
|
10
11
|
Ariakit.Checkbox,
|
|
11
12
|
{
|
|
@@ -13,6 +14,7 @@ const Switch = forwardRef(
|
|
|
13
14
|
id: fieldId,
|
|
14
15
|
...props,
|
|
15
16
|
className: cx("\u{1F95D}-switch", props.className),
|
|
17
|
+
"aria-describedby": describedBy,
|
|
16
18
|
role: "switch",
|
|
17
19
|
ref: forwardedRef
|
|
18
20
|
}
|
package/dist/bricks/Tabs.d.ts
CHANGED
|
@@ -67,7 +67,7 @@ interface TabProps extends FocusableProps<"button">, Pick<Ariakit.TabProps, "id"
|
|
|
67
67
|
* ```
|
|
68
68
|
*/
|
|
69
69
|
declare const Tab: React.ForwardRefExoticComponent<TabProps & React.RefAttributes<HTMLElement | HTMLButtonElement>>;
|
|
70
|
-
interface TabPanelProps extends
|
|
70
|
+
interface TabPanelProps extends FocusableProps<"div">, Pick<Ariakit.TabPanelProps, "tabId" | "unmountOnHide" | "focusable"> {
|
|
71
71
|
}
|
|
72
72
|
/**
|
|
73
73
|
* The actual content of a tab, shown when the tab is selected. Should be used as a child of `Tabs.Root`.
|
package/dist/bricks/Tabs.js
CHANGED
|
@@ -47,8 +47,8 @@ const TabList = forwardRef((props, forwardedRef) => {
|
|
|
47
47
|
return /* @__PURE__ */ jsx(
|
|
48
48
|
Ariakit.TabList,
|
|
49
49
|
{
|
|
50
|
-
"data-kiwi-tone": tone,
|
|
51
50
|
...rest,
|
|
51
|
+
"data-kiwi-tone": tone,
|
|
52
52
|
className: cx("\u{1F95D}-tab-list", props.className),
|
|
53
53
|
style: {
|
|
54
54
|
"--\u{1F95D}tab-active-stripe-view-transition-name": viewTransitionName,
|
package/dist/bricks/TextBox.js
CHANGED
|
@@ -2,13 +2,14 @@ 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
9
|
import { forwardRef } from "./~utils.js";
|
|
10
10
|
const TextBoxInput = forwardRef(
|
|
11
11
|
(props, forwardedRef) => {
|
|
12
|
+
const describedBy = useFieldDescribedBy(props["aria-describedby"]);
|
|
12
13
|
const fieldId = useFieldId();
|
|
13
14
|
const rootContext = React.useContext(TextBoxRootContext);
|
|
14
15
|
const setDisabled = rootContext?.setDisabled;
|
|
@@ -20,6 +21,7 @@ const TextBoxInput = forwardRef(
|
|
|
20
21
|
{
|
|
21
22
|
id: fieldId,
|
|
22
23
|
...props,
|
|
24
|
+
"aria-describedby": describedBy,
|
|
23
25
|
className: cx({ "\u{1F95D}-text-box": !rootContext }, props.className),
|
|
24
26
|
render: /* @__PURE__ */ jsx(
|
|
25
27
|
Ariakit.Focusable,
|
package/dist/bricks/Textarea.js
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import * as Ariakit from "@ariakit/react";
|
|
3
3
|
import cx from "classnames";
|
|
4
|
-
import { useFieldId } from "./Field.js";
|
|
4
|
+
import { useFieldDescribedBy, useFieldId } from "./Field.js";
|
|
5
5
|
import { forwardRef } from "./~utils.js";
|
|
6
6
|
const Textarea = forwardRef(
|
|
7
7
|
(props, forwardedRef) => {
|
|
8
8
|
const fieldId = useFieldId();
|
|
9
|
+
const describedBy = useFieldDescribedBy(props["aria-describedby"]);
|
|
9
10
|
return /* @__PURE__ */ jsx(
|
|
10
11
|
Ariakit.Role.textarea,
|
|
11
12
|
{
|
|
12
13
|
id: fieldId,
|
|
13
14
|
...props,
|
|
14
15
|
className: cx("\u{1F95D}-text-box", props.className),
|
|
16
|
+
"aria-describedby": describedBy,
|
|
15
17
|
render: /* @__PURE__ */ jsx(
|
|
16
18
|
Ariakit.Focusable,
|
|
17
19
|
{
|
package/dist/bricks/Tooltip.js
CHANGED
|
@@ -5,12 +5,12 @@ import * as Ariakit from "@ariakit/react";
|
|
|
5
5
|
import { forwardRef, supportsPopover } from "./~utils.js";
|
|
6
6
|
const Tooltip = forwardRef(
|
|
7
7
|
(props, forwardedRef) => {
|
|
8
|
+
const generatedId = React.useId();
|
|
8
9
|
const {
|
|
9
10
|
content,
|
|
10
11
|
children,
|
|
11
|
-
className,
|
|
12
12
|
type = "description",
|
|
13
|
-
id =
|
|
13
|
+
id = generatedId,
|
|
14
14
|
defaultOpen: defaultOpenProp,
|
|
15
15
|
open: openProp,
|
|
16
16
|
setOpen: setOpenProp,
|
|
@@ -53,7 +53,7 @@ const Tooltip = forwardRef(
|
|
|
53
53
|
"aria-hidden": "true",
|
|
54
54
|
...rest,
|
|
55
55
|
unmountOnHide,
|
|
56
|
-
className: cx("\u{1F95D}-tooltip", className),
|
|
56
|
+
className: cx("\u{1F95D}-tooltip", props.className),
|
|
57
57
|
ref: forwardedRef,
|
|
58
58
|
id,
|
|
59
59
|
style: {
|
package/dist/bricks/Tree.d.ts
CHANGED
|
@@ -1,23 +1,86 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import { IconButton } from "./IconButton.js";
|
|
3
2
|
import { type BaseProps } from "./~utils.js";
|
|
4
3
|
interface TreeProps extends BaseProps {
|
|
5
4
|
}
|
|
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
|
+
*/
|
|
6
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
|
}
|
|
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
|
+
*/
|
|
13
85
|
declare const TreeItem: React.ForwardRefExoticComponent<TreeItemProps & React.RefAttributes<HTMLElement | HTMLDivElement>>;
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
declare const TreeItemContent: React.ForwardRefExoticComponent<TreeItemContentProps & React.RefAttributes<HTMLElement | HTMLSpanElement>>;
|
|
17
|
-
type IconButtonProps = React.ComponentProps<typeof IconButton>;
|
|
18
|
-
interface TreeItemExpanderProps extends Omit<IconButtonProps, "variant" | "label" | "icon"> {
|
|
19
|
-
label?: IconButtonProps["label"];
|
|
20
|
-
icon?: IconButtonProps["icon"];
|
|
21
|
-
}
|
|
22
|
-
declare const TreeItemExpander: React.ForwardRefExoticComponent<Omit<TreeItemExpanderProps, "ref"> & React.RefAttributes<HTMLElement | HTMLButtonElement>>;
|
|
23
|
-
export { Tree as Root, TreeItem as Item, TreeItemExpander as Expander, TreeItemContent as Content, };
|
|
86
|
+
export { Tree as Root, TreeItem as Item };
|
package/dist/bricks/Tree.js
CHANGED
|
@@ -6,14 +6,33 @@ import * as ListItem from "./ListItem.js";
|
|
|
6
6
|
import { IconButton } from "./IconButton.js";
|
|
7
7
|
import { Icon } from "./Icon.js";
|
|
8
8
|
import { forwardRef } from "./~utils.js";
|
|
9
|
+
import { VisuallyHidden } from "./VisuallyHidden.js";
|
|
9
10
|
const Tree = forwardRef((props, forwardedRef) => {
|
|
10
|
-
return /* @__PURE__ */ jsx(
|
|
11
|
+
return /* @__PURE__ */ jsx(
|
|
12
|
+
Ariakit.Role.div,
|
|
13
|
+
{
|
|
14
|
+
...props,
|
|
15
|
+
className: cx("\u{1F95D}-tree", props.className),
|
|
16
|
+
ref: forwardedRef,
|
|
17
|
+
children: /* @__PURE__ */ jsx("div", { role: "list", children: props.children })
|
|
18
|
+
}
|
|
19
|
+
);
|
|
11
20
|
});
|
|
12
21
|
const TreeItem = forwardRef((props, forwardedRef) => {
|
|
13
|
-
const {
|
|
22
|
+
const {
|
|
23
|
+
selected,
|
|
24
|
+
children,
|
|
25
|
+
expanded,
|
|
26
|
+
icon,
|
|
27
|
+
label,
|
|
28
|
+
actions,
|
|
29
|
+
style,
|
|
30
|
+
onSelectedChange,
|
|
31
|
+
onExpandedChange,
|
|
32
|
+
...rest
|
|
33
|
+
} = props;
|
|
14
34
|
const parentContext = React.useContext(TreeItemContext);
|
|
15
35
|
const level = parentContext ? parentContext.level + 1 : 1;
|
|
16
|
-
const firstSelected = !!selected && !parentContext?.selected;
|
|
17
36
|
return /* @__PURE__ */ jsx(
|
|
18
37
|
TreeItemContext.Provider,
|
|
19
38
|
{
|
|
@@ -21,26 +40,39 @@ const TreeItem = forwardRef((props, forwardedRef) => {
|
|
|
21
40
|
() => ({
|
|
22
41
|
level,
|
|
23
42
|
expanded,
|
|
24
|
-
selected
|
|
43
|
+
selected,
|
|
44
|
+
onSelectedChange
|
|
25
45
|
}),
|
|
26
|
-
[level, expanded, selected]
|
|
46
|
+
[level, expanded, selected, onSelectedChange]
|
|
27
47
|
),
|
|
28
|
-
children: /* @__PURE__ */ jsxs("div", { role: "listitem",
|
|
29
|
-
/* @__PURE__ */
|
|
48
|
+
children: /* @__PURE__ */ jsxs("div", { role: "listitem", children: [
|
|
49
|
+
/* @__PURE__ */ jsxs(
|
|
30
50
|
ListItem.Root,
|
|
31
51
|
{
|
|
32
52
|
...rest,
|
|
33
53
|
"data-kiwi-expanded": expanded,
|
|
34
54
|
"data-kiwi-selected": selected,
|
|
35
|
-
"
|
|
36
|
-
className: cx("\u{1F95D}-tree-item", className),
|
|
55
|
+
className: cx("\u{1F95D}-tree-item", props.className),
|
|
37
56
|
style: {
|
|
38
57
|
...style,
|
|
39
58
|
"--\u{1F95D}tree-item-level": level
|
|
40
59
|
},
|
|
41
60
|
ref: forwardedRef,
|
|
42
61
|
role: void 0,
|
|
43
|
-
children:
|
|
62
|
+
children: [
|
|
63
|
+
/* @__PURE__ */ jsx(
|
|
64
|
+
TreeItemExpander,
|
|
65
|
+
{
|
|
66
|
+
onClick: () => {
|
|
67
|
+
if (expanded === void 0) return;
|
|
68
|
+
onExpandedChange?.(!expanded);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
),
|
|
72
|
+
typeof icon === "string" ? /* @__PURE__ */ jsx(Icon, { href: icon }) : icon,
|
|
73
|
+
/* @__PURE__ */ jsx(TreeItemContent, { label }),
|
|
74
|
+
/* @__PURE__ */ jsx(TreeItemActions, { children: actions })
|
|
75
|
+
]
|
|
44
76
|
}
|
|
45
77
|
),
|
|
46
78
|
children && /* @__PURE__ */ jsx("div", { role: "list", children })
|
|
@@ -50,14 +82,44 @@ const TreeItem = forwardRef((props, forwardedRef) => {
|
|
|
50
82
|
});
|
|
51
83
|
const TreeItemContent = forwardRef(
|
|
52
84
|
(props, forwardedRef) => {
|
|
53
|
-
const {
|
|
85
|
+
const { label, ...rest } = props;
|
|
86
|
+
const context = React.useContext(TreeItemContext);
|
|
54
87
|
return /* @__PURE__ */ jsx(
|
|
55
88
|
ListItem.Content,
|
|
56
89
|
{
|
|
57
90
|
...rest,
|
|
58
91
|
className: cx("\u{1F95D}-tree-item-content", props.className),
|
|
59
92
|
ref: forwardedRef,
|
|
60
|
-
children: /* @__PURE__ */
|
|
93
|
+
children: /* @__PURE__ */ jsxs(
|
|
94
|
+
"button",
|
|
95
|
+
{
|
|
96
|
+
type: "button",
|
|
97
|
+
onClick: () => {
|
|
98
|
+
if (!context?.onSelectedChange || context.selected === void 0)
|
|
99
|
+
return;
|
|
100
|
+
context.onSelectedChange(!context.selected);
|
|
101
|
+
},
|
|
102
|
+
children: [
|
|
103
|
+
label,
|
|
104
|
+
context?.selected && /* @__PURE__ */ jsx(VisuallyHidden, { children: "Selected item" })
|
|
105
|
+
]
|
|
106
|
+
}
|
|
107
|
+
)
|
|
108
|
+
}
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
);
|
|
112
|
+
const TreeItemActions = forwardRef(
|
|
113
|
+
(props, forwardedRef) => {
|
|
114
|
+
const { visible, ...rest } = props;
|
|
115
|
+
return /* @__PURE__ */ jsx(
|
|
116
|
+
Ariakit.Toolbar,
|
|
117
|
+
{
|
|
118
|
+
...rest,
|
|
119
|
+
className: cx("\u{1F95D}-tree-item-actions", props.className),
|
|
120
|
+
"data-kiwi-visible": visible,
|
|
121
|
+
ref: forwardedRef,
|
|
122
|
+
children: props.children
|
|
61
123
|
}
|
|
62
124
|
);
|
|
63
125
|
}
|
|
@@ -106,8 +168,6 @@ const TreeChevron = forwardRef(
|
|
|
106
168
|
);
|
|
107
169
|
const TreeItemContext = React.createContext(void 0);
|
|
108
170
|
export {
|
|
109
|
-
TreeItemContent as Content,
|
|
110
|
-
TreeItemExpander as Expander,
|
|
111
171
|
TreeItem as Item,
|
|
112
172
|
Tree as Root
|
|
113
173
|
};
|
package/dist/bricks/index.d.ts
CHANGED
|
@@ -2,6 +2,8 @@ export { Root } from "./Root.js";
|
|
|
2
2
|
export { Anchor } from "./Anchor.js";
|
|
3
3
|
export { Button } from "./Button.js";
|
|
4
4
|
export { Checkbox } from "./Checkbox.js";
|
|
5
|
+
export { Chip } from "./Chip.js";
|
|
6
|
+
export { Description } from "./Description.js";
|
|
5
7
|
export * as DropdownMenu from "./DropdownMenu.js";
|
|
6
8
|
export { Divider } from "./Divider.js";
|
|
7
9
|
export { Icon } from "./Icon.js";
|
|
@@ -11,9 +13,11 @@ export { Kbd } from "./Kbd.js";
|
|
|
11
13
|
export { Label } from "./Label.js";
|
|
12
14
|
export { Radio } from "./Radio.js";
|
|
13
15
|
export * as Select from "./Select.js";
|
|
16
|
+
export { Spinner } from "./Spinner.js";
|
|
14
17
|
export { Switch } from "./Switch.js";
|
|
15
18
|
export * as Tabs from "./Tabs.js";
|
|
16
19
|
export { Text } from "./Text.js";
|
|
17
20
|
export * as TextBox from "./TextBox.js";
|
|
21
|
+
export * as Tree from "./Tree.js";
|
|
18
22
|
export { Tooltip } from "./Tooltip.js";
|
|
19
23
|
export { VisuallyHidden } from "./VisuallyHidden.js";
|
package/dist/bricks/index.js
CHANGED
|
@@ -3,6 +3,8 @@ import { Root } from "./Root.js";
|
|
|
3
3
|
import { Anchor } from "./Anchor.js";
|
|
4
4
|
import { Button } from "./Button.js";
|
|
5
5
|
import { Checkbox } from "./Checkbox.js";
|
|
6
|
+
import { Chip } from "./Chip.js";
|
|
7
|
+
import { Description } from "./Description.js";
|
|
6
8
|
import * as DropdownMenu from "./DropdownMenu.js";
|
|
7
9
|
import { Divider } from "./Divider.js";
|
|
8
10
|
import { Icon } from "./Icon.js";
|
|
@@ -12,16 +14,20 @@ import { Kbd } from "./Kbd.js";
|
|
|
12
14
|
import { Label } from "./Label.js";
|
|
13
15
|
import { Radio } from "./Radio.js";
|
|
14
16
|
import * as Select from "./Select.js";
|
|
17
|
+
import { Spinner } from "./Spinner.js";
|
|
15
18
|
import { Switch } from "./Switch.js";
|
|
16
19
|
import * as Tabs from "./Tabs.js";
|
|
17
20
|
import { Text } from "./Text.js";
|
|
18
21
|
import * as TextBox from "./TextBox.js";
|
|
22
|
+
import * as Tree from "./Tree.js";
|
|
19
23
|
import { Tooltip } from "./Tooltip.js";
|
|
20
24
|
import { VisuallyHidden } from "./VisuallyHidden.js";
|
|
21
25
|
export {
|
|
22
26
|
Anchor,
|
|
23
27
|
Button,
|
|
24
28
|
Checkbox,
|
|
29
|
+
Chip,
|
|
30
|
+
Description,
|
|
25
31
|
Divider,
|
|
26
32
|
DropdownMenu,
|
|
27
33
|
Field,
|
|
@@ -32,10 +38,12 @@ export {
|
|
|
32
38
|
Radio,
|
|
33
39
|
Root,
|
|
34
40
|
Select,
|
|
41
|
+
Spinner,
|
|
35
42
|
Switch,
|
|
36
43
|
Tabs,
|
|
37
44
|
Text,
|
|
38
45
|
TextBox,
|
|
39
46
|
Tooltip,
|
|
47
|
+
Tree,
|
|
40
48
|
VisuallyHidden
|
|
41
49
|
};
|