@itwin/itwinui-react 5.0.0-alpha.1 → 5.0.0-alpha.11
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 +102 -0
- package/LICENSE.md +1 -1
- package/README.md +6 -6
- package/dist/DEV/bricks/Anchor.js +5 -10
- package/dist/DEV/bricks/Avatar.js +24 -0
- package/dist/DEV/bricks/Badge.js +22 -0
- package/dist/DEV/bricks/Button.js +11 -4
- package/dist/DEV/bricks/Checkbox.js +17 -9
- package/dist/DEV/bricks/Chip.js +42 -0
- package/dist/DEV/bricks/Description.js +29 -0
- package/dist/DEV/bricks/Divider.js +3 -2
- package/dist/DEV/bricks/DropdownMenu.js +109 -30
- package/dist/DEV/bricks/Field.js +115 -14
- package/dist/DEV/bricks/Icon.js +177 -10
- package/dist/DEV/bricks/IconButton.js +14 -3
- package/dist/DEV/bricks/Kbd.internal.js +19 -0
- package/dist/DEV/bricks/Kbd.js +23 -6
- package/dist/DEV/bricks/Label.js +11 -8
- package/dist/DEV/bricks/ProgressBar.js +25 -0
- package/dist/DEV/bricks/Radio.js +17 -9
- package/dist/DEV/bricks/Root.internal.js +17 -0
- package/dist/DEV/bricks/Root.js +103 -26
- package/dist/DEV/bricks/Select.js +17 -11
- package/dist/DEV/bricks/Skeleton.js +24 -0
- package/dist/DEV/bricks/Spinner.js +55 -0
- package/dist/DEV/bricks/Switch.js +18 -10
- package/dist/DEV/bricks/Table.js +114 -0
- package/dist/DEV/bricks/Tabs.js +6 -6
- package/dist/DEV/bricks/Text.js +2 -2
- package/dist/DEV/bricks/TextBox.js +54 -16
- package/dist/DEV/bricks/Tooltip.js +17 -25
- package/dist/DEV/bricks/Tree.js +15 -107
- package/dist/DEV/bricks/TreeItem.js +227 -0
- package/dist/DEV/bricks/VisuallyHidden.js +2 -2
- package/dist/DEV/bricks/index.js +16 -0
- package/dist/DEV/bricks/styles.css.js +2 -2
- package/dist/DEV/bricks/~hooks.js +57 -3
- package/dist/DEV/bricks/~utils.GhostAligner.js +13 -0
- package/dist/DEV/bricks/{ListItem.js → ~utils.ListItem.js} +19 -3
- package/dist/DEV/bricks/~utils.js +17 -0
- package/dist/DEV/foundations/styles.css.js +2 -2
- package/dist/bricks/Anchor.js +5 -10
- 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.js +11 -4
- package/dist/bricks/Checkbox.d.ts +2 -2
- package/dist/bricks/Checkbox.js +17 -9
- 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 +2 -2
- package/dist/bricks/Divider.js +3 -2
- package/dist/bricks/DropdownMenu.d.ts +41 -14
- package/dist/bricks/DropdownMenu.js +106 -30
- package/dist/bricks/Field.d.ts +23 -1
- package/dist/bricks/Field.js +115 -14
- package/dist/bricks/Icon.d.ts +43 -4
- package/dist/bricks/Icon.js +174 -10
- package/dist/bricks/IconButton.d.ts +20 -4
- package/dist/bricks/IconButton.js +14 -3
- package/dist/bricks/Kbd.d.ts +15 -0
- package/dist/bricks/Kbd.internal.d.ts +17 -0
- package/dist/bricks/Kbd.internal.js +19 -0
- package/dist/bricks/Kbd.js +16 -6
- package/dist/bricks/Label.js +11 -8
- package/dist/bricks/ProgressBar.d.ts +31 -0
- package/dist/bricks/ProgressBar.js +24 -0
- package/dist/bricks/Radio.d.ts +2 -2
- package/dist/bricks/Radio.js +17 -9
- package/dist/bricks/Root.d.ts +12 -0
- package/dist/bricks/Root.internal.d.ts +6 -0
- package/dist/bricks/Root.internal.js +17 -0
- package/dist/bricks/Root.js +103 -26
- package/dist/bricks/Select.d.ts +9 -3
- package/dist/bricks/Select.js +17 -11
- 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 +54 -0
- package/dist/bricks/Switch.d.ts +2 -2
- package/dist/bricks/Switch.js +18 -10
- package/dist/bricks/Table.d.ts +115 -0
- package/dist/bricks/Table.js +108 -0
- package/dist/bricks/Tabs.d.ts +4 -4
- package/dist/bricks/Tabs.js +6 -6
- package/dist/bricks/Text.d.ts +1 -1
- package/dist/bricks/Text.js +2 -2
- package/dist/bricks/TextBox.d.ts +23 -2
- package/dist/bricks/TextBox.js +53 -16
- package/dist/bricks/Tooltip.d.ts +2 -2
- package/dist/bricks/Tooltip.js +17 -25
- package/dist/bricks/Tree.d.ts +19 -20
- package/dist/bricks/Tree.js +14 -102
- package/dist/bricks/TreeItem.d.ts +129 -0
- package/dist/bricks/TreeItem.js +222 -0
- package/dist/bricks/VisuallyHidden.js +2 -2
- package/dist/bricks/index.d.ts +8 -0
- package/dist/bricks/index.js +16 -0
- package/dist/bricks/styles.css.js +2 -2
- package/dist/bricks/~hooks.d.ts +63 -0
- package/dist/bricks/~hooks.js +57 -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/{ListItem.js → ~utils.ListItem.js} +18 -3
- package/dist/bricks/~utils.d.ts +14 -3
- package/dist/bricks/~utils.js +17 -0
- package/dist/foundations/styles.css.js +2 -2
- package/package.json +14 -13
- package/dist/DEV/bricks/Textarea.js +0 -30
- package/dist/bricks/ListItem.d.ts +0 -10
- package/dist/bricks/Textarea.d.ts +0 -24
- package/dist/bricks/Textarea.js +0 -29
package/dist/bricks/Tree.js
CHANGED
|
@@ -1,113 +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 { IconButton } from "./IconButton.js";
|
|
7
|
-
import { Icon } from "./Icon.js";
|
|
3
|
+
import { Role } from "@ariakit/react/role";
|
|
4
|
+
import { useCompositeStore, Composite } from "@ariakit/react/composite";
|
|
8
5
|
import { forwardRef } from "./~utils.js";
|
|
6
|
+
import { Root as TreeItemRoot, Action as TreeItemAction } from "./TreeItem.js";
|
|
9
7
|
const Tree = forwardRef((props, forwardedRef) => {
|
|
10
|
-
|
|
11
|
-
});
|
|
12
|
-
const TreeItem = forwardRef((props, forwardedRef) => {
|
|
13
|
-
const { selected, content, children, className, expanded, style, ...rest } = props;
|
|
14
|
-
const parentContext = React.useContext(TreeItemContext);
|
|
15
|
-
const level = parentContext ? parentContext.level + 1 : 1;
|
|
16
|
-
const firstSelected = !!selected && !parentContext?.selected;
|
|
8
|
+
const composite = useCompositeStore({ orientation: "vertical" });
|
|
17
9
|
return /* @__PURE__ */ jsx(
|
|
18
|
-
|
|
10
|
+
Role.div,
|
|
19
11
|
{
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
[level, expanded, selected]
|
|
27
|
-
),
|
|
28
|
-
children: /* @__PURE__ */ jsxs("div", { role: "listitem", "aria-current": firstSelected ? true : void 0, children: [
|
|
29
|
-
/* @__PURE__ */ jsx(
|
|
30
|
-
ListItem.Root,
|
|
31
|
-
{
|
|
32
|
-
...rest,
|
|
33
|
-
"data-kiwi-expanded": expanded,
|
|
34
|
-
"data-kiwi-selected": selected,
|
|
35
|
-
"data-kiwi-parent-selected": parentContext?.selected,
|
|
36
|
-
className: cx("\u{1F95D}-tree-item", className),
|
|
37
|
-
style: {
|
|
38
|
-
...style,
|
|
39
|
-
"--\u{1F95D}tree-item-level": level
|
|
40
|
-
},
|
|
41
|
-
ref: forwardedRef,
|
|
42
|
-
role: void 0,
|
|
43
|
-
children: content
|
|
44
|
-
}
|
|
45
|
-
),
|
|
46
|
-
children && /* @__PURE__ */ jsx("div", { role: "list", children })
|
|
47
|
-
] })
|
|
12
|
+
role: "tree",
|
|
13
|
+
...props,
|
|
14
|
+
render: /* @__PURE__ */ jsx(Composite, { store: composite }),
|
|
15
|
+
className: cx("\u{1F95D}-tree", props.className),
|
|
16
|
+
ref: forwardedRef,
|
|
17
|
+
children: props.children
|
|
48
18
|
}
|
|
49
19
|
);
|
|
50
20
|
});
|
|
51
|
-
const TreeItemContent = forwardRef(
|
|
52
|
-
(props, forwardedRef) => {
|
|
53
|
-
const { children, ...rest } = props;
|
|
54
|
-
return /* @__PURE__ */ jsx(
|
|
55
|
-
ListItem.Content,
|
|
56
|
-
{
|
|
57
|
-
...rest,
|
|
58
|
-
className: cx("\u{1F95D}-tree-item-content", props.className),
|
|
59
|
-
ref: forwardedRef,
|
|
60
|
-
children: /* @__PURE__ */ jsx("button", { type: "button", children })
|
|
61
|
-
}
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
);
|
|
65
|
-
const TreeItemExpander = forwardRef(
|
|
66
|
-
(props, forwardedRef) => {
|
|
67
|
-
const context = React.useContext(TreeItemContext);
|
|
68
|
-
const expanded = context?.expanded;
|
|
69
|
-
return /* @__PURE__ */ jsx(
|
|
70
|
-
IconButton,
|
|
71
|
-
{
|
|
72
|
-
icon: /* @__PURE__ */ jsx(TreeChevron, {}),
|
|
73
|
-
label: "Toggle",
|
|
74
|
-
"aria-expanded": expanded === void 0 ? void 0 : expanded,
|
|
75
|
-
...props,
|
|
76
|
-
className: cx("\u{1F95D}-tree-item-expander", props.className),
|
|
77
|
-
variant: "ghost",
|
|
78
|
-
labelVariant: "visually-hidden",
|
|
79
|
-
ref: forwardedRef
|
|
80
|
-
}
|
|
81
|
-
);
|
|
82
|
-
}
|
|
83
|
-
);
|
|
84
|
-
const TreeChevron = forwardRef(
|
|
85
|
-
(props, forwardedRef) => {
|
|
86
|
-
return /* @__PURE__ */ jsx(
|
|
87
|
-
Icon,
|
|
88
|
-
{
|
|
89
|
-
...props,
|
|
90
|
-
render: /* @__PURE__ */ jsx(
|
|
91
|
-
Ariakit.Role.svg,
|
|
92
|
-
{
|
|
93
|
-
width: "16",
|
|
94
|
-
height: "16",
|
|
95
|
-
fill: "currentColor",
|
|
96
|
-
viewBox: "0 0 16 16",
|
|
97
|
-
render: props.render,
|
|
98
|
-
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" })
|
|
99
|
-
}
|
|
100
|
-
),
|
|
101
|
-
className: cx("\u{1F95D}-tree-chevron", props.className),
|
|
102
|
-
ref: forwardedRef
|
|
103
|
-
}
|
|
104
|
-
);
|
|
105
|
-
}
|
|
106
|
-
);
|
|
107
|
-
const TreeItemContext = React.createContext(void 0);
|
|
108
21
|
export {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
TreeItem as Item,
|
|
22
|
+
TreeItemRoot as Item,
|
|
23
|
+
TreeItemAction as ItemAction,
|
|
112
24
|
Tree as Root
|
|
113
25
|
};
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { IconButton } from "./IconButton.js";
|
|
3
|
+
import { type BaseProps } from "./~utils.js";
|
|
4
|
+
interface TreeItemRootProps extends Omit<BaseProps, "content" | "children"> {
|
|
5
|
+
/** Specifies the nesting level of the tree item. Nesting levels start at 1. */
|
|
6
|
+
"aria-level": number;
|
|
7
|
+
/** Defines tree item position in the current level of tree items. Integer greater than or equal to 1. */
|
|
8
|
+
"aria-posinset": number;
|
|
9
|
+
/** Defines tree item set size of the current level. */
|
|
10
|
+
"aria-setsize": number;
|
|
11
|
+
/**
|
|
12
|
+
* Specifies if the tree item is selected.
|
|
13
|
+
*
|
|
14
|
+
* If `undefined`, the tree item is not selectable.
|
|
15
|
+
*
|
|
16
|
+
* @default undefined
|
|
17
|
+
*/
|
|
18
|
+
selected?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Callback fired when the tree item is selected.
|
|
21
|
+
*
|
|
22
|
+
* Should be used with the `selected` prop.
|
|
23
|
+
*/
|
|
24
|
+
onSelectedChange?: (selected: boolean) => void;
|
|
25
|
+
/**
|
|
26
|
+
* Specifies if the tree item is expanded.
|
|
27
|
+
*
|
|
28
|
+
* Used to determine if a tree item is a parent node. If `undefined`, it is a leaf node (i.e. not expandable).
|
|
29
|
+
*
|
|
30
|
+
* @default undefined
|
|
31
|
+
*/
|
|
32
|
+
expanded?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Callback fired when the tree item is expanded.
|
|
35
|
+
*
|
|
36
|
+
* Should be used with the `expanded` prop.
|
|
37
|
+
*/
|
|
38
|
+
onExpandedChange?: (expanded: boolean) => void;
|
|
39
|
+
/**
|
|
40
|
+
* Icon to be displayed inside the tree item.
|
|
41
|
+
*
|
|
42
|
+
* Can be a URL of an SVG from the `@itwin/itwinui-icons` package, or a JSX element.
|
|
43
|
+
*
|
|
44
|
+
* For multiple icons/decorations, use the `unstable_decorations` prop.
|
|
45
|
+
*/
|
|
46
|
+
icon?: string | React.JSX.Element;
|
|
47
|
+
/**
|
|
48
|
+
* Decoration(s) to be displayed inside the tree item.
|
|
49
|
+
*
|
|
50
|
+
* This is an alternative to the `icon` prop, and can be used to
|
|
51
|
+
* display multiple icons or other decorations before the label.
|
|
52
|
+
*
|
|
53
|
+
* Note: This should _not_ be used together with the `icon` prop.
|
|
54
|
+
*
|
|
55
|
+
* @experimental
|
|
56
|
+
*/
|
|
57
|
+
unstable_decorations?: React.ReactNode;
|
|
58
|
+
/**
|
|
59
|
+
* The primary label that identifies the tree item and is displayed inside it.
|
|
60
|
+
*/
|
|
61
|
+
label?: React.ReactNode;
|
|
62
|
+
/** Secondary line of text to display additional information about the tree item. */
|
|
63
|
+
description?: React.ReactNode;
|
|
64
|
+
/**
|
|
65
|
+
* The actions available for the tree item. Must be a list of `Tree.ItemAction` components.
|
|
66
|
+
*
|
|
67
|
+
* Example:
|
|
68
|
+
* ```tsx
|
|
69
|
+
* actions={[
|
|
70
|
+
* <Tree.ItemAction key={…} icon={…} label={…} />,
|
|
71
|
+
* <Tree.ItemAction key={…} icon={…} label={…} />,
|
|
72
|
+
* ]}
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
actions?: React.ReactNode[];
|
|
76
|
+
/**
|
|
77
|
+
* Specifies if the tree item is in an error state.
|
|
78
|
+
*
|
|
79
|
+
* @default false
|
|
80
|
+
*/
|
|
81
|
+
error?: boolean;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* A treeitem is a node in a tree structure that may be expanded or collapsed to reveal or hide its descendants.
|
|
85
|
+
*
|
|
86
|
+
* `Tree.Item`s can be rendered inside a `Tree.Root`. Additional properties are specified to the `Tree.Item`s to create a hierarchical tree structure.
|
|
87
|
+
*
|
|
88
|
+
* Example:
|
|
89
|
+
* ```tsx
|
|
90
|
+
* <Tree.Root>
|
|
91
|
+
* <Tree.Item label="Parent" aria-level={1} aria-posinset={1} aria-setsize={1} />
|
|
92
|
+
* <Tree.Item label="Child 1" aria-level={2} aria-posinset={1} aria-setsize={2} />
|
|
93
|
+
* <Tree.Item label="Child 2" aria-level={2} aria-posinset={2} aria-setsize={2} />
|
|
94
|
+
* </Tree.Root>
|
|
95
|
+
* ```
|
|
96
|
+
*
|
|
97
|
+
* The `label` and `icon` props can be used to specify the treeitem's own content.
|
|
98
|
+
*
|
|
99
|
+
* The `aria-level` prop is used to specify the nesting level of the treeitem. Nesting levels start at 1.
|
|
100
|
+
*
|
|
101
|
+
* The `aria-posinset` and `aria-setsize` props are used to define the treeitem's position in the current level of tree items.
|
|
102
|
+
*
|
|
103
|
+
* The `expanded` and `onExpandedChange` props can be used to control the expansion state of a treeitem.
|
|
104
|
+
*
|
|
105
|
+
* The `selected` and `onSelectedChange` props can be used to control the selection state of a treeitem.
|
|
106
|
+
*
|
|
107
|
+
* Secondary actions can be passed into the `actions` prop.
|
|
108
|
+
*/
|
|
109
|
+
declare const TreeItemRoot: React.ForwardRefExoticComponent<TreeItemRootProps & React.RefAttributes<HTMLElement | HTMLDivElement>>;
|
|
110
|
+
type IconButtonProps = React.ComponentProps<typeof IconButton>;
|
|
111
|
+
interface TreeItemActionProps extends BaseProps<"button">, Pick<IconButtonProps, "label" | "icon"> {
|
|
112
|
+
/**
|
|
113
|
+
* Controls the visibility of the action.
|
|
114
|
+
*
|
|
115
|
+
* If `true`, the action is always visible.
|
|
116
|
+
* If `false`, the action is hidden and becomes inaccessible, but still occupies space.
|
|
117
|
+
*
|
|
118
|
+
* By default, the action is shown only when the treeitem receives hover/focus.
|
|
119
|
+
*/
|
|
120
|
+
visible?: boolean;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* A secondary action for `<Tree.Item>`, to be passed into the `actions` prop. The action is typically
|
|
124
|
+
* displayed as an icon-button on the right end of the treeitem.
|
|
125
|
+
*
|
|
126
|
+
* By default, the action appears only on hover/focus. This can be controlled by the `visible` prop.
|
|
127
|
+
*/
|
|
128
|
+
declare const TreeItemAction: React.ForwardRefExoticComponent<TreeItemActionProps & React.RefAttributes<HTMLElement | HTMLButtonElement>>;
|
|
129
|
+
export { TreeItemRoot as Root, TreeItemAction as Action };
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import cx from "classnames";
|
|
4
|
+
import { Role } from "@ariakit/react/role";
|
|
5
|
+
import {
|
|
6
|
+
CompositeItem
|
|
7
|
+
} from "@ariakit/react/composite";
|
|
8
|
+
import { Toolbar } from "@ariakit/react/toolbar";
|
|
9
|
+
import * as ListItem from "./~utils.ListItem.js";
|
|
10
|
+
import { IconButton } from "./IconButton.js";
|
|
11
|
+
import { Icon, StatusWarning } from "./Icon.js";
|
|
12
|
+
import { forwardRef } from "./~utils.js";
|
|
13
|
+
import { useEventHandlers } from "./~hooks.js";
|
|
14
|
+
import { GhostAligner, useGhostAlignment } from "./~utils.GhostAligner.js";
|
|
15
|
+
const TreeItemContext = React.createContext(void 0);
|
|
16
|
+
const TreeItemRoot = forwardRef(
|
|
17
|
+
(props, forwardedRef) => {
|
|
18
|
+
const {
|
|
19
|
+
"aria-level": level,
|
|
20
|
+
selected,
|
|
21
|
+
expanded,
|
|
22
|
+
icon: iconProp,
|
|
23
|
+
unstable_decorations,
|
|
24
|
+
label,
|
|
25
|
+
description,
|
|
26
|
+
actions,
|
|
27
|
+
error,
|
|
28
|
+
onSelectedChange,
|
|
29
|
+
onExpandedChange,
|
|
30
|
+
onClick: onClickProp,
|
|
31
|
+
onKeyDown: onKeyDownProp,
|
|
32
|
+
...rest
|
|
33
|
+
} = props;
|
|
34
|
+
const handleClick = (event) => {
|
|
35
|
+
if (selected === void 0) return;
|
|
36
|
+
event.stopPropagation();
|
|
37
|
+
onSelectedChange?.(!selected);
|
|
38
|
+
};
|
|
39
|
+
const handleKeyDown = (event) => {
|
|
40
|
+
if (event.altKey || event.ctrlKey || event.metaKey || event.shiftKey) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
if (expanded === void 0) return;
|
|
44
|
+
if (event.key === "ArrowRight" || event.key === "ArrowLeft") {
|
|
45
|
+
event.preventDefault();
|
|
46
|
+
onExpandedChange?.(event.key === "ArrowRight");
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
const labelId = React.useId();
|
|
50
|
+
const descriptionId = React.useId();
|
|
51
|
+
const decorationId = React.useId();
|
|
52
|
+
const icon = error ? /* @__PURE__ */ jsx(StatusWarning, {}) : iconProp;
|
|
53
|
+
const describedBy = React.useMemo(() => {
|
|
54
|
+
const idRefs = [];
|
|
55
|
+
if (description) idRefs.push(descriptionId);
|
|
56
|
+
if (unstable_decorations || icon) idRefs.push(decorationId);
|
|
57
|
+
return idRefs.length > 0 ? idRefs.join(" ") : void 0;
|
|
58
|
+
}, [unstable_decorations, icon, decorationId, description, descriptionId]);
|
|
59
|
+
return /* @__PURE__ */ jsx(
|
|
60
|
+
TreeItemContext.Provider,
|
|
61
|
+
{
|
|
62
|
+
value: React.useMemo(
|
|
63
|
+
() => ({
|
|
64
|
+
level,
|
|
65
|
+
expanded,
|
|
66
|
+
selected
|
|
67
|
+
}),
|
|
68
|
+
[level, expanded, selected]
|
|
69
|
+
),
|
|
70
|
+
children: /* @__PURE__ */ jsx(
|
|
71
|
+
CompositeItem,
|
|
72
|
+
{
|
|
73
|
+
render: /* @__PURE__ */ jsx(Role, { ...rest }),
|
|
74
|
+
onClick: useEventHandlers(
|
|
75
|
+
onClickProp,
|
|
76
|
+
handleClick
|
|
77
|
+
),
|
|
78
|
+
onKeyDown: useEventHandlers(
|
|
79
|
+
onKeyDownProp,
|
|
80
|
+
handleKeyDown
|
|
81
|
+
),
|
|
82
|
+
role: "treeitem",
|
|
83
|
+
"aria-expanded": expanded,
|
|
84
|
+
"aria-selected": selected,
|
|
85
|
+
"aria-labelledby": labelId,
|
|
86
|
+
"aria-describedby": describedBy,
|
|
87
|
+
"aria-level": level,
|
|
88
|
+
className: cx("\u{1F95D}-tree-item", props.className),
|
|
89
|
+
ref: forwardedRef,
|
|
90
|
+
children: /* @__PURE__ */ jsxs(
|
|
91
|
+
ListItem.Root,
|
|
92
|
+
{
|
|
93
|
+
"data-kiwi-expanded": expanded,
|
|
94
|
+
"data-kiwi-selected": selected,
|
|
95
|
+
"data-kiwi-error": error ? true : void 0,
|
|
96
|
+
className: "\u{1F95D}-tree-item-node",
|
|
97
|
+
style: { "--\u{1F95D}tree-item-level": level },
|
|
98
|
+
role: void 0,
|
|
99
|
+
children: [
|
|
100
|
+
/* @__PURE__ */ jsxs(ListItem.Decoration, { children: [
|
|
101
|
+
/* @__PURE__ */ jsx(GhostAligner, { align: description ? "block" : void 0, children: /* @__PURE__ */ jsx(
|
|
102
|
+
TreeItemExpander,
|
|
103
|
+
{
|
|
104
|
+
onClick: () => {
|
|
105
|
+
if (expanded === void 0) return;
|
|
106
|
+
onExpandedChange?.(!expanded);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
) }),
|
|
110
|
+
icon || unstable_decorations ? /* @__PURE__ */ jsx(
|
|
111
|
+
Role,
|
|
112
|
+
{
|
|
113
|
+
className: "\u{1F95D}-tree-item-decoration",
|
|
114
|
+
id: decorationId,
|
|
115
|
+
render: React.isValidElement(icon) ? icon : typeof icon === "string" ? /* @__PURE__ */ jsx(Icon, { href: icon }) : void 0,
|
|
116
|
+
children: !icon ? unstable_decorations : null
|
|
117
|
+
}
|
|
118
|
+
) : null
|
|
119
|
+
] }),
|
|
120
|
+
/* @__PURE__ */ jsx(ListItem.Content, { id: labelId, className: "\u{1F95D}-tree-item-content", children: label }),
|
|
121
|
+
description ? /* @__PURE__ */ jsx(
|
|
122
|
+
ListItem.Content,
|
|
123
|
+
{
|
|
124
|
+
id: descriptionId,
|
|
125
|
+
className: "\u{1F95D}-tree-item-description",
|
|
126
|
+
children: description
|
|
127
|
+
}
|
|
128
|
+
) : void 0,
|
|
129
|
+
/* @__PURE__ */ jsx(
|
|
130
|
+
ListItem.Decoration,
|
|
131
|
+
{
|
|
132
|
+
render: /* @__PURE__ */ jsx(TreeItemActions, { children: actions })
|
|
133
|
+
}
|
|
134
|
+
)
|
|
135
|
+
]
|
|
136
|
+
}
|
|
137
|
+
)
|
|
138
|
+
}
|
|
139
|
+
)
|
|
140
|
+
}
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
);
|
|
144
|
+
const TreeItemActions = forwardRef((props, forwardedRef) => {
|
|
145
|
+
return /* @__PURE__ */ jsx(
|
|
146
|
+
Toolbar,
|
|
147
|
+
{
|
|
148
|
+
...props,
|
|
149
|
+
onClick: useEventHandlers(props.onClick, (e) => e.stopPropagation()),
|
|
150
|
+
onKeyDown: useEventHandlers(props.onKeyDown, (e) => e.stopPropagation()),
|
|
151
|
+
className: cx("\u{1F95D}-tree-item-actions-container", props.className),
|
|
152
|
+
ref: forwardedRef,
|
|
153
|
+
children: props.children
|
|
154
|
+
}
|
|
155
|
+
);
|
|
156
|
+
});
|
|
157
|
+
const TreeItemAction = forwardRef(
|
|
158
|
+
(props, forwardedRef) => {
|
|
159
|
+
const { visible, ...rest } = props;
|
|
160
|
+
return /* @__PURE__ */ jsx(
|
|
161
|
+
IconButton,
|
|
162
|
+
{
|
|
163
|
+
inert: visible === false ? true : void 0,
|
|
164
|
+
...rest,
|
|
165
|
+
variant: "ghost",
|
|
166
|
+
className: cx("\u{1F95D}-tree-item-action", props.className),
|
|
167
|
+
"data-kiwi-visible": visible,
|
|
168
|
+
ref: forwardedRef
|
|
169
|
+
}
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
);
|
|
173
|
+
const TreeItemExpander = forwardRef(
|
|
174
|
+
(props, forwardedRef) => {
|
|
175
|
+
return /* @__PURE__ */ jsx(
|
|
176
|
+
Role.span,
|
|
177
|
+
{
|
|
178
|
+
"aria-hidden": "true",
|
|
179
|
+
...props,
|
|
180
|
+
onClick: useEventHandlers(props.onClick, (e) => e.stopPropagation()),
|
|
181
|
+
className: cx(
|
|
182
|
+
"\u{1F95D}-button",
|
|
183
|
+
"\u{1F95D}-icon-button",
|
|
184
|
+
"\u{1F95D}-ghost-aligner",
|
|
185
|
+
"\u{1F95D}-tree-item-expander",
|
|
186
|
+
props.className
|
|
187
|
+
),
|
|
188
|
+
"data-kiwi-variant": "ghost",
|
|
189
|
+
"data-kiwi-ghost-align": useGhostAlignment(),
|
|
190
|
+
ref: forwardedRef,
|
|
191
|
+
children: /* @__PURE__ */ jsx(TreeChevron, {})
|
|
192
|
+
}
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
);
|
|
196
|
+
const TreeChevron = forwardRef(
|
|
197
|
+
(props, forwardedRef) => {
|
|
198
|
+
return /* @__PURE__ */ jsx(
|
|
199
|
+
Icon,
|
|
200
|
+
{
|
|
201
|
+
...props,
|
|
202
|
+
render: /* @__PURE__ */ jsx(
|
|
203
|
+
Role.svg,
|
|
204
|
+
{
|
|
205
|
+
width: "16",
|
|
206
|
+
height: "16",
|
|
207
|
+
fill: "currentColor",
|
|
208
|
+
viewBox: "0 0 16 16",
|
|
209
|
+
render: props.render,
|
|
210
|
+
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" })
|
|
211
|
+
}
|
|
212
|
+
),
|
|
213
|
+
className: cx("\u{1F95D}-tree-chevron", props.className),
|
|
214
|
+
ref: forwardedRef
|
|
215
|
+
}
|
|
216
|
+
);
|
|
217
|
+
}
|
|
218
|
+
);
|
|
219
|
+
export {
|
|
220
|
+
TreeItemAction as Action,
|
|
221
|
+
TreeItemRoot as Root
|
|
222
|
+
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
2
|
+
import { VisuallyHidden as AkVisuallyHidden } from "@ariakit/react/visually-hidden";
|
|
3
3
|
import { forwardRef } from "./~utils.js";
|
|
4
4
|
const VisuallyHidden = forwardRef(
|
|
5
5
|
(props, forwardedRef) => {
|
|
6
|
-
return /* @__PURE__ */ jsx(
|
|
6
|
+
return /* @__PURE__ */ jsx(AkVisuallyHidden, { ...props, ref: forwardedRef });
|
|
7
7
|
}
|
|
8
8
|
);
|
|
9
9
|
export {
|
package/dist/bricks/index.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
export { Root } from "./Root.js";
|
|
2
2
|
export { Anchor } from "./Anchor.js";
|
|
3
|
+
export { Avatar } from "./Avatar.js";
|
|
4
|
+
export { Badge } from "./Badge.js";
|
|
3
5
|
export { Button } from "./Button.js";
|
|
4
6
|
export { Checkbox } from "./Checkbox.js";
|
|
7
|
+
export { Chip } from "./Chip.js";
|
|
8
|
+
export { Description } from "./Description.js";
|
|
5
9
|
export * as DropdownMenu from "./DropdownMenu.js";
|
|
6
10
|
export { Divider } from "./Divider.js";
|
|
7
11
|
export { Icon } from "./Icon.js";
|
|
@@ -9,11 +13,15 @@ export { IconButton } from "./IconButton.js";
|
|
|
9
13
|
export { Field } from "./Field.js";
|
|
10
14
|
export { Kbd } from "./Kbd.js";
|
|
11
15
|
export { Label } from "./Label.js";
|
|
16
|
+
export { ProgressBar } from "./ProgressBar.js";
|
|
12
17
|
export { Radio } from "./Radio.js";
|
|
13
18
|
export * as Select from "./Select.js";
|
|
19
|
+
export { Spinner } from "./Spinner.js";
|
|
20
|
+
export { Skeleton } from "./Skeleton.js";
|
|
14
21
|
export { Switch } from "./Switch.js";
|
|
15
22
|
export * as Tabs from "./Tabs.js";
|
|
16
23
|
export { Text } from "./Text.js";
|
|
17
24
|
export * as TextBox from "./TextBox.js";
|
|
25
|
+
export * as Tree from "./Tree.js";
|
|
18
26
|
export { Tooltip } from "./Tooltip.js";
|
|
19
27
|
export { VisuallyHidden } from "./VisuallyHidden.js";
|
package/dist/bricks/index.js
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { Root } from "./Root.js";
|
|
3
3
|
import { Anchor } from "./Anchor.js";
|
|
4
|
+
import { Avatar } from "./Avatar.js";
|
|
5
|
+
import { Badge } from "./Badge.js";
|
|
4
6
|
import { Button } from "./Button.js";
|
|
5
7
|
import { Checkbox } from "./Checkbox.js";
|
|
8
|
+
import { Chip } from "./Chip.js";
|
|
9
|
+
import { Description } from "./Description.js";
|
|
6
10
|
import * as DropdownMenu from "./DropdownMenu.js";
|
|
7
11
|
import { Divider } from "./Divider.js";
|
|
8
12
|
import { Icon } from "./Icon.js";
|
|
@@ -10,18 +14,26 @@ import { IconButton } from "./IconButton.js";
|
|
|
10
14
|
import { Field } from "./Field.js";
|
|
11
15
|
import { Kbd } from "./Kbd.js";
|
|
12
16
|
import { Label } from "./Label.js";
|
|
17
|
+
import { ProgressBar } from "./ProgressBar.js";
|
|
13
18
|
import { Radio } from "./Radio.js";
|
|
14
19
|
import * as Select from "./Select.js";
|
|
20
|
+
import { Spinner } from "./Spinner.js";
|
|
21
|
+
import { Skeleton } from "./Skeleton.js";
|
|
15
22
|
import { Switch } from "./Switch.js";
|
|
16
23
|
import * as Tabs from "./Tabs.js";
|
|
17
24
|
import { Text } from "./Text.js";
|
|
18
25
|
import * as TextBox from "./TextBox.js";
|
|
26
|
+
import * as Tree from "./Tree.js";
|
|
19
27
|
import { Tooltip } from "./Tooltip.js";
|
|
20
28
|
import { VisuallyHidden } from "./VisuallyHidden.js";
|
|
21
29
|
export {
|
|
22
30
|
Anchor,
|
|
31
|
+
Avatar,
|
|
32
|
+
Badge,
|
|
23
33
|
Button,
|
|
24
34
|
Checkbox,
|
|
35
|
+
Chip,
|
|
36
|
+
Description,
|
|
25
37
|
Divider,
|
|
26
38
|
DropdownMenu,
|
|
27
39
|
Field,
|
|
@@ -29,13 +41,17 @@ export {
|
|
|
29
41
|
IconButton,
|
|
30
42
|
Kbd,
|
|
31
43
|
Label,
|
|
44
|
+
ProgressBar,
|
|
32
45
|
Radio,
|
|
33
46
|
Root,
|
|
34
47
|
Select,
|
|
48
|
+
Skeleton,
|
|
49
|
+
Spinner,
|
|
35
50
|
Switch,
|
|
36
51
|
Tabs,
|
|
37
52
|
Text,
|
|
38
53
|
TextBox,
|
|
39
54
|
Tooltip,
|
|
55
|
+
Tree,
|
|
40
56
|
VisuallyHidden
|
|
41
57
|
};
|