@itwin/itwinui-react 5.0.0-alpha.11 → 5.0.0-alpha.12
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 +18 -0
- package/README.md +13 -2
- package/dist/DEV/bricks/Checkbox.js +7 -14
- package/dist/DEV/bricks/Description.js +7 -14
- package/dist/DEV/bricks/DropdownMenu.js +57 -19
- package/dist/DEV/bricks/Field.internal.js +47 -0
- package/dist/DEV/bricks/Field.js +116 -85
- package/dist/DEV/bricks/Icon.js +32 -0
- package/dist/DEV/bricks/Label.js +4 -10
- package/dist/DEV/bricks/Radio.js +7 -14
- package/dist/DEV/bricks/Select.js +9 -15
- package/dist/DEV/bricks/Switch.js +8 -15
- package/dist/DEV/bricks/Table.js +71 -37
- package/dist/DEV/bricks/Tabs.js +4 -29
- package/dist/DEV/bricks/TextBox.js +23 -37
- package/dist/DEV/bricks/TreeItem.js +87 -8
- package/dist/DEV/bricks/index.js +3 -1
- package/dist/DEV/bricks/styles.css.js +1 -1
- package/dist/DEV/foundations/styles.css.js +1 -1
- package/dist/bricks/Checkbox.d.ts +13 -5
- package/dist/bricks/Checkbox.js +7 -14
- package/dist/bricks/Description.d.ts +2 -6
- package/dist/bricks/Description.js +7 -14
- package/dist/bricks/DropdownMenu.d.ts +9 -9
- package/dist/bricks/DropdownMenu.js +56 -18
- package/dist/bricks/Field.d.ts +63 -27
- package/dist/bricks/Field.internal.d.ts +33 -0
- package/dist/bricks/Field.internal.js +47 -0
- package/dist/bricks/Field.js +111 -84
- package/dist/bricks/Icon.d.ts +3 -0
- package/dist/bricks/Icon.js +31 -0
- package/dist/bricks/Label.d.ts +5 -12
- package/dist/bricks/Label.js +4 -10
- package/dist/bricks/Radio.d.ts +14 -5
- package/dist/bricks/Radio.js +7 -14
- package/dist/bricks/Select.d.ts +29 -12
- package/dist/bricks/Select.js +9 -15
- package/dist/bricks/Switch.d.ts +12 -5
- package/dist/bricks/Switch.js +8 -15
- package/dist/bricks/Table.d.ts +94 -37
- package/dist/bricks/Table.js +69 -36
- package/dist/bricks/Tabs.d.ts +3 -4
- package/dist/bricks/Tabs.js +4 -29
- package/dist/bricks/TextBox.d.ts +42 -19
- package/dist/bricks/TextBox.js +23 -37
- package/dist/bricks/TreeItem.d.ts +46 -8
- package/dist/bricks/TreeItem.js +76 -8
- package/dist/bricks/index.d.ts +2 -1
- package/dist/bricks/index.js +3 -1
- package/dist/bricks/styles.css.js +1 -1
- package/dist/bricks/~hooks.d.ts +1 -1
- package/dist/foundations/styles.css.js +1 -1
- package/package.json +1 -1
package/dist/bricks/Tabs.js
CHANGED
|
@@ -1,41 +1,21 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import * as React from "react";
|
|
3
|
-
import * as ReactDOM from "react-dom";
|
|
4
2
|
import cx from "classnames";
|
|
5
3
|
import * as AkTab from "@ariakit/react/tab";
|
|
6
|
-
import { useControlledState } from "./~hooks.js";
|
|
7
4
|
import { forwardRef } from "./~utils.js";
|
|
8
5
|
function Tabs(props) {
|
|
9
6
|
const {
|
|
10
7
|
defaultSelectedId,
|
|
11
|
-
selectedId
|
|
12
|
-
setSelectedId
|
|
8
|
+
selectedId,
|
|
9
|
+
setSelectedId,
|
|
13
10
|
selectOnMove,
|
|
14
11
|
children
|
|
15
12
|
} = props;
|
|
16
|
-
const [selectedId, setSelectedId] = useControlledState(
|
|
17
|
-
defaultSelectedId,
|
|
18
|
-
selectedIdProp,
|
|
19
|
-
setSelectedIdProp
|
|
20
|
-
);
|
|
21
13
|
return /* @__PURE__ */ jsx(
|
|
22
14
|
AkTab.TabProvider,
|
|
23
15
|
{
|
|
16
|
+
defaultSelectedId,
|
|
24
17
|
selectedId,
|
|
25
|
-
setSelectedId
|
|
26
|
-
(id) => {
|
|
27
|
-
if (document.startViewTransition) {
|
|
28
|
-
document.startViewTransition(() => {
|
|
29
|
-
ReactDOM.flushSync(() => {
|
|
30
|
-
setSelectedId(id);
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
} else {
|
|
34
|
-
setSelectedId(id);
|
|
35
|
-
}
|
|
36
|
-
},
|
|
37
|
-
[setSelectedId]
|
|
38
|
-
),
|
|
18
|
+
setSelectedId,
|
|
39
19
|
selectOnMove,
|
|
40
20
|
children
|
|
41
21
|
}
|
|
@@ -43,17 +23,12 @@ function Tabs(props) {
|
|
|
43
23
|
}
|
|
44
24
|
const TabList = forwardRef((props, forwardedRef) => {
|
|
45
25
|
const { tone = "neutral", ...rest } = props;
|
|
46
|
-
const viewTransitionName = `\u{1F95D}active-stripe-${React.useId().replaceAll(":", "_")}`;
|
|
47
26
|
return /* @__PURE__ */ jsx(
|
|
48
27
|
AkTab.TabList,
|
|
49
28
|
{
|
|
50
29
|
...rest,
|
|
51
30
|
"data-kiwi-tone": tone,
|
|
52
31
|
className: cx("\u{1F95D}-tab-list", props.className),
|
|
53
|
-
style: {
|
|
54
|
-
"--\u{1F95D}tab-active-stripe-view-transition-name": viewTransitionName,
|
|
55
|
-
...props.style
|
|
56
|
-
},
|
|
57
32
|
ref: forwardedRef
|
|
58
33
|
}
|
|
59
34
|
);
|
package/dist/bricks/TextBox.d.ts
CHANGED
|
@@ -19,17 +19,26 @@ interface TextBoxInputProps extends Omit<BaseInputProps, "children" | "type"> {
|
|
|
19
19
|
*
|
|
20
20
|
* Example usage:
|
|
21
21
|
* ```tsx
|
|
22
|
-
* <TextBox.Input defaultValue="Hello" />
|
|
22
|
+
* <TextBox.Input name="greeting" defaultValue="Hello" />
|
|
23
23
|
* ```
|
|
24
24
|
*
|
|
25
25
|
* To add additional decorations, see `TextBox.Root` component.
|
|
26
26
|
*
|
|
27
|
-
*
|
|
27
|
+
* Use with the `Field` components to automatically handle ID associations for
|
|
28
|
+
* labels and descriptions:
|
|
28
29
|
* ```tsx
|
|
29
|
-
* <Field>
|
|
30
|
-
* <Label>
|
|
31
|
-
* <TextBox.Input />
|
|
32
|
-
* </Field>
|
|
30
|
+
* <Field.Root>
|
|
31
|
+
* <Field.Label>First name</Field.Label>
|
|
32
|
+
* <Field.Control render={<TextBox.Input name="firstName" />} />
|
|
33
|
+
* </Field.Root>
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* Without the `Field` components you will need to manually associate labels,
|
|
37
|
+
* descriptions, etc.:
|
|
38
|
+
* ```tsx
|
|
39
|
+
* <Label htmlFor="fruit">Fruit</Label>
|
|
40
|
+
* <TextBox.Input id="fruit" aria-describedby="fruit-description" />
|
|
41
|
+
* <Description id="fruit-description">Something to include in a fruit salad.</Description>
|
|
33
42
|
* ```
|
|
34
43
|
*
|
|
35
44
|
* Underneath, it's an HTML input, i.e. `<input>`, so it supports the same props, including
|
|
@@ -48,12 +57,21 @@ interface TextareaProps extends FocusableProps<"textarea"> {
|
|
|
48
57
|
* <TextBox.Textarea defaultValue="Hello" />
|
|
49
58
|
* ```
|
|
50
59
|
*
|
|
51
|
-
*
|
|
60
|
+
* Use with the `Field` components to automatically handle ID associations for
|
|
61
|
+
* labels and descriptions:
|
|
62
|
+
* ```tsx
|
|
63
|
+
* <Field.Root>
|
|
64
|
+
* <Field.Label>Leave a comment, be kind</Field.Label>
|
|
65
|
+
* <Field.Control render={<TextBox.Textarea name="comment" />} />
|
|
66
|
+
* </Field.Root>
|
|
67
|
+
* ```
|
|
68
|
+
*
|
|
69
|
+
* Without the `Field` components you will need to manually associate labels,
|
|
70
|
+
* descriptions, etc.:
|
|
52
71
|
* ```tsx
|
|
53
|
-
* <
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
* </Field>
|
|
72
|
+
* <Label htmlFor="fruit">Fruit</Label>
|
|
73
|
+
* <TextBox.Input id="fruit" aria-describedby="fruit-description" />
|
|
74
|
+
* <Description id="fruit-description">Something to include in a fruit salad.</Description>
|
|
57
75
|
* ```
|
|
58
76
|
*
|
|
59
77
|
* Underneath, it's an HTML textarea, i.e. `<textarea>`, so it supports the same props, including
|
|
@@ -73,15 +91,20 @@ interface TextBoxRootProps extends BaseProps {
|
|
|
73
91
|
* </TextBox.Root>
|
|
74
92
|
* ```
|
|
75
93
|
*
|
|
76
|
-
*
|
|
94
|
+
* Use with the `Field` components to automatically handle ID associations for
|
|
95
|
+
* labels and descriptions:
|
|
77
96
|
* ```tsx
|
|
78
|
-
* <Field>
|
|
79
|
-
* <Label>
|
|
80
|
-
* <
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
97
|
+
* <Field.Root>
|
|
98
|
+
* <Field.Label>First name</Field.Label>
|
|
99
|
+
* <Field.Control
|
|
100
|
+
* render={(controlProps) => (
|
|
101
|
+
* <TextBox.Root>
|
|
102
|
+
* <TextBox.Input name="firstName" {...controlProps} />
|
|
103
|
+
* <TextBox.Icon href={…} />
|
|
104
|
+
* </TextBox.Root>
|
|
105
|
+
* )}
|
|
106
|
+
* />
|
|
107
|
+
* </Field.Root>
|
|
85
108
|
* ```
|
|
86
109
|
*/
|
|
87
110
|
declare const TextBoxRoot: React.ForwardRefExoticComponent<TextBoxRootProps & React.RefAttributes<HTMLElement | HTMLDivElement>>;
|
package/dist/bricks/TextBox.js
CHANGED
|
@@ -3,69 +3,55 @@ import * as React from "react";
|
|
|
3
3
|
import { Role } from "@ariakit/react/role";
|
|
4
4
|
import { Focusable } from "@ariakit/react/focusable";
|
|
5
5
|
import cx from "classnames";
|
|
6
|
-
import { FieldControl } from "./Field.js";
|
|
7
6
|
import { Icon } from "./Icon.js";
|
|
8
7
|
import { useMergedRefs } from "./~hooks.js";
|
|
9
8
|
import { forwardRef } from "./~utils.js";
|
|
9
|
+
import { useFieldControlType } from "./Field.internal.js";
|
|
10
10
|
const TextBoxInput = forwardRef(
|
|
11
11
|
(props, forwardedRef) => {
|
|
12
|
-
|
|
12
|
+
useFieldControlType("textlike");
|
|
13
13
|
const rootContext = React.useContext(TextBoxRootContext);
|
|
14
14
|
const setDisabled = rootContext?.setDisabled;
|
|
15
15
|
React.useEffect(() => {
|
|
16
16
|
setDisabled?.(props.disabled);
|
|
17
17
|
}, [setDisabled, props.disabled]);
|
|
18
18
|
return /* @__PURE__ */ jsx(
|
|
19
|
-
|
|
19
|
+
Role.input,
|
|
20
20
|
{
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
readOnly: props.disabled,
|
|
22
|
+
...props,
|
|
23
|
+
className: cx({ "\u{1F95D}-text-box": !rootContext }, props.className),
|
|
24
|
+
placeholder: props.placeholder ?? " ",
|
|
23
25
|
render: /* @__PURE__ */ jsx(
|
|
24
|
-
|
|
26
|
+
Focusable,
|
|
25
27
|
{
|
|
26
|
-
|
|
27
|
-
|
|
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)
|
|
28
|
+
accessibleWhenDisabled: true,
|
|
29
|
+
render: props.render || /* @__PURE__ */ jsx("input", {})
|
|
38
30
|
}
|
|
39
|
-
)
|
|
31
|
+
),
|
|
32
|
+
ref: useMergedRefs(rootContext?.inputRef, forwardedRef)
|
|
40
33
|
}
|
|
41
34
|
);
|
|
42
35
|
}
|
|
43
36
|
);
|
|
44
37
|
const TextBoxTextarea = forwardRef(
|
|
45
38
|
(props, forwardedRef) => {
|
|
46
|
-
|
|
39
|
+
useFieldControlType("textlike");
|
|
47
40
|
return /* @__PURE__ */ jsx(
|
|
48
|
-
|
|
41
|
+
Role.textarea,
|
|
49
42
|
{
|
|
50
|
-
|
|
51
|
-
|
|
43
|
+
readOnly: props.disabled,
|
|
44
|
+
...props,
|
|
45
|
+
className: cx("\u{1F95D}-text-box", props.className),
|
|
46
|
+
placeholder: props.placeholder ?? " ",
|
|
52
47
|
render: /* @__PURE__ */ jsx(
|
|
53
|
-
|
|
48
|
+
Focusable,
|
|
54
49
|
{
|
|
55
|
-
|
|
56
|
-
|
|
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
|
|
50
|
+
accessibleWhenDisabled: true,
|
|
51
|
+
render: props.render || /* @__PURE__ */ jsx("textarea", {})
|
|
67
52
|
}
|
|
68
|
-
)
|
|
53
|
+
),
|
|
54
|
+
ref: forwardedRef
|
|
69
55
|
}
|
|
70
56
|
);
|
|
71
57
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import { IconButton } from "./IconButton.js";
|
|
3
2
|
import { type BaseProps } from "./~utils.js";
|
|
4
3
|
interface TreeItemRootProps extends Omit<BaseProps, "content" | "children"> {
|
|
5
4
|
/** Specifies the nesting level of the tree item. Nesting levels start at 1. */
|
|
@@ -62,20 +61,42 @@ interface TreeItemRootProps extends Omit<BaseProps, "content" | "children"> {
|
|
|
62
61
|
/** Secondary line of text to display additional information about the tree item. */
|
|
63
62
|
description?: React.ReactNode;
|
|
64
63
|
/**
|
|
65
|
-
* The actions available for the tree item. Must be a list of `Tree.ItemAction` components.
|
|
64
|
+
* The secondary actions available for the tree item. Must be a list of `Tree.ItemAction` components.
|
|
66
65
|
*
|
|
67
66
|
* Example:
|
|
68
67
|
* ```tsx
|
|
69
68
|
* actions={[
|
|
69
|
+
* error && <Tree.ItemAction key={…} icon={…} label={…} />,
|
|
70
70
|
* <Tree.ItemAction key={…} icon={…} label={…} />,
|
|
71
71
|
* <Tree.ItemAction key={…} icon={…} label={…} />,
|
|
72
72
|
* ]}
|
|
73
73
|
* ```
|
|
74
|
+
*
|
|
75
|
+
* Excess actions will automatically get collapsed into an overflow menu.
|
|
76
|
+
* - Normally, the third action and onwards will overflow.
|
|
77
|
+
* - When the `error` prop is set, the _second_ action and onwards will overflow.
|
|
78
|
+
*
|
|
79
|
+
* The actions are normally hidden until the treeitem is hovered or focused.
|
|
80
|
+
* When the `error` prop is set, the actions will be made visible by default. The first
|
|
81
|
+
* action slot can be used to display an error-related action.
|
|
82
|
+
*
|
|
83
|
+
* ```tsx
|
|
84
|
+
* actions={[
|
|
85
|
+
* error && <Tree.ItemAction key={…} icon={…} label={…} />,
|
|
86
|
+
* <Tree.ItemAction key={…} icon={…} label={…} />,
|
|
87
|
+
* <Tree.ItemAction key={…} icon={…} label={…} />,
|
|
88
|
+
* ]}
|
|
89
|
+
* ```
|
|
90
|
+
*
|
|
91
|
+
* @experimental
|
|
74
92
|
*/
|
|
75
93
|
actions?: React.ReactNode[];
|
|
76
94
|
/**
|
|
77
95
|
* Specifies if the tree item is in an error state.
|
|
78
96
|
*
|
|
97
|
+
* Can be combined with the `actions` prop to display an error-related action. The first
|
|
98
|
+
* action will be made visible by default.
|
|
99
|
+
*
|
|
79
100
|
* @default false
|
|
80
101
|
*/
|
|
81
102
|
error?: boolean;
|
|
@@ -107,23 +128,40 @@ interface TreeItemRootProps extends Omit<BaseProps, "content" | "children"> {
|
|
|
107
128
|
* Secondary actions can be passed into the `actions` prop.
|
|
108
129
|
*/
|
|
109
130
|
declare const TreeItemRoot: React.ForwardRefExoticComponent<TreeItemRootProps & React.RefAttributes<HTMLElement | HTMLDivElement>>;
|
|
110
|
-
|
|
111
|
-
|
|
131
|
+
interface TreeItemActionProps extends Omit<BaseProps<"button">, "children"> {
|
|
132
|
+
/**
|
|
133
|
+
* Label for the action.
|
|
134
|
+
*
|
|
135
|
+
* Will be displayed as a tooltip when the action is an icon-button,
|
|
136
|
+
* otherwise will be displayed as a label inside the menu-item.
|
|
137
|
+
*/
|
|
138
|
+
label: string;
|
|
139
|
+
/**
|
|
140
|
+
* Icon for the action.
|
|
141
|
+
*
|
|
142
|
+
* Can be a URL of an SVG from the `@itwin/itwinui-icons` package, or a JSX element.
|
|
143
|
+
*
|
|
144
|
+
* Required when the action is displayed as an icon-button (i.e. not overflowing).
|
|
145
|
+
*/
|
|
146
|
+
icon?: string | React.JSX.Element;
|
|
112
147
|
/**
|
|
113
|
-
* Controls the visibility of the action.
|
|
148
|
+
* Controls the visibility of the action (only when the action is displayed as icon-button).
|
|
114
149
|
*
|
|
115
150
|
* If `true`, the action is always visible.
|
|
116
151
|
* If `false`, the action is hidden and becomes inaccessible, but still occupies space.
|
|
117
152
|
*
|
|
118
|
-
* By default, the action is shown only when the treeitem receives hover/focus.
|
|
153
|
+
* By default, the action is shown only when the treeitem receives hover/focus. When the
|
|
154
|
+
* treeitem has an `error`, the action will become always visible (i.e. it will default
|
|
155
|
+
* to `true` when `error` is set).
|
|
119
156
|
*/
|
|
120
157
|
visible?: boolean;
|
|
121
158
|
}
|
|
122
159
|
/**
|
|
123
160
|
* A secondary action for `<Tree.Item>`, to be passed into the `actions` prop. The action is typically
|
|
124
|
-
* displayed as an icon-button
|
|
161
|
+
* displayed as an icon-button or a menu-item (e.g. when overflowing).
|
|
125
162
|
*
|
|
126
|
-
* By default, the action appears only
|
|
163
|
+
* By default, the action appears only when the treeitem has hover/focus or an error. This behavior can
|
|
164
|
+
* be overridden using the `visible` prop.
|
|
127
165
|
*/
|
|
128
166
|
declare const TreeItemAction: React.ForwardRefExoticComponent<TreeItemActionProps & React.RefAttributes<HTMLElement | HTMLButtonElement>>;
|
|
129
167
|
export { TreeItemRoot as Root, TreeItemAction as Action };
|
package/dist/bricks/TreeItem.js
CHANGED
|
@@ -2,15 +2,17 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import cx from "classnames";
|
|
4
4
|
import { Role } from "@ariakit/react/role";
|
|
5
|
+
import { PopoverProvider } from "@ariakit/react/popover";
|
|
5
6
|
import {
|
|
6
7
|
CompositeItem
|
|
7
8
|
} from "@ariakit/react/composite";
|
|
8
9
|
import { Toolbar } from "@ariakit/react/toolbar";
|
|
9
10
|
import * as ListItem from "./~utils.ListItem.js";
|
|
10
11
|
import { IconButton } from "./IconButton.js";
|
|
11
|
-
import
|
|
12
|
+
import * as DropdownMenu from "./DropdownMenu.js";
|
|
13
|
+
import { Icon, StatusWarning, MoreHorizontal } from "./Icon.js";
|
|
12
14
|
import { forwardRef } from "./~utils.js";
|
|
13
|
-
import { useEventHandlers } from "./~hooks.js";
|
|
15
|
+
import { useEventHandlers, useSafeContext } from "./~hooks.js";
|
|
14
16
|
import { GhostAligner, useGhostAlignment } from "./~utils.GhostAligner.js";
|
|
15
17
|
const TreeItemContext = React.createContext(void 0);
|
|
16
18
|
const TreeItemRoot = forwardRef(
|
|
@@ -63,9 +65,10 @@ const TreeItemRoot = forwardRef(
|
|
|
63
65
|
() => ({
|
|
64
66
|
level,
|
|
65
67
|
expanded,
|
|
66
|
-
selected
|
|
68
|
+
selected,
|
|
69
|
+
error
|
|
67
70
|
}),
|
|
68
|
-
[level, expanded, selected]
|
|
71
|
+
[level, expanded, selected, error]
|
|
69
72
|
),
|
|
70
73
|
children: /* @__PURE__ */ jsx(
|
|
71
74
|
CompositeItem,
|
|
@@ -142,24 +145,89 @@ const TreeItemRoot = forwardRef(
|
|
|
142
145
|
}
|
|
143
146
|
);
|
|
144
147
|
const TreeItemActions = forwardRef((props, forwardedRef) => {
|
|
145
|
-
|
|
148
|
+
const { children, ...rest } = props;
|
|
149
|
+
const actions = React.Children.toArray(children).filter(Boolean);
|
|
150
|
+
const { error } = useSafeContext(TreeItemContext);
|
|
151
|
+
const limit = error ? 2 : 3;
|
|
152
|
+
return /* @__PURE__ */ jsxs(
|
|
146
153
|
Toolbar,
|
|
147
154
|
{
|
|
148
|
-
...
|
|
155
|
+
...rest,
|
|
149
156
|
onClick: useEventHandlers(props.onClick, (e) => e.stopPropagation()),
|
|
150
157
|
onKeyDown: useEventHandlers(props.onKeyDown, (e) => e.stopPropagation()),
|
|
151
158
|
className: cx("\u{1F95D}-tree-item-actions-container", props.className),
|
|
159
|
+
focusLoop: false,
|
|
152
160
|
ref: forwardedRef,
|
|
153
|
-
children:
|
|
161
|
+
children: [
|
|
162
|
+
actions.slice(0, limit - 1),
|
|
163
|
+
actions.length === limit ? actions[limit - 1] : null,
|
|
164
|
+
actions.length > limit ? /* @__PURE__ */ jsx(TreeItemActionsOverflowMenu, { children: actions.slice(limit - 1) }) : null
|
|
165
|
+
]
|
|
154
166
|
}
|
|
155
167
|
);
|
|
156
168
|
});
|
|
169
|
+
const arrowKeys = ["ArrowDown", "ArrowUp", "ArrowLeft", "ArrowRight"];
|
|
170
|
+
const TreeItemActionsOverflowMenuContext = React.createContext(false);
|
|
171
|
+
function TreeItemActionsOverflowMenu({ children }) {
|
|
172
|
+
const [open, setOpen] = React.useState(false);
|
|
173
|
+
const isArrowKeyPressed = React.useRef(false);
|
|
174
|
+
return /* @__PURE__ */ jsx(PopoverProvider, { placement: "right-start", children: /* @__PURE__ */ jsxs(
|
|
175
|
+
DropdownMenu.Root,
|
|
176
|
+
{
|
|
177
|
+
open,
|
|
178
|
+
setOpen: React.useCallback((value) => {
|
|
179
|
+
if (value && !isArrowKeyPressed.current) {
|
|
180
|
+
setOpen(true);
|
|
181
|
+
} else {
|
|
182
|
+
setOpen(false);
|
|
183
|
+
}
|
|
184
|
+
}, []),
|
|
185
|
+
children: [
|
|
186
|
+
/* @__PURE__ */ jsx(
|
|
187
|
+
DropdownMenu.Button,
|
|
188
|
+
{
|
|
189
|
+
onKeyDown: (e) => {
|
|
190
|
+
if (arrowKeys.includes(e.key)) {
|
|
191
|
+
isArrowKeyPressed.current = true;
|
|
192
|
+
}
|
|
193
|
+
queueMicrotask(() => {
|
|
194
|
+
isArrowKeyPressed.current = false;
|
|
195
|
+
});
|
|
196
|
+
},
|
|
197
|
+
render: /* @__PURE__ */ jsx(TreeItemAction, { label: "More", icon: /* @__PURE__ */ jsx(MoreHorizontal, {}) })
|
|
198
|
+
}
|
|
199
|
+
),
|
|
200
|
+
/* @__PURE__ */ jsx(TreeItemActionsOverflowMenuContext.Provider, { value: true, children: /* @__PURE__ */ jsx(DropdownMenu.Content, { children }) })
|
|
201
|
+
]
|
|
202
|
+
}
|
|
203
|
+
) });
|
|
204
|
+
}
|
|
157
205
|
const TreeItemAction = forwardRef(
|
|
158
206
|
(props, forwardedRef) => {
|
|
159
|
-
const {
|
|
207
|
+
const { error } = useSafeContext(TreeItemContext);
|
|
208
|
+
const {
|
|
209
|
+
visible = error ? true : void 0,
|
|
210
|
+
// visible by default during error state
|
|
211
|
+
label,
|
|
212
|
+
icon,
|
|
213
|
+
...rest
|
|
214
|
+
} = props;
|
|
215
|
+
if (React.useContext(TreeItemActionsOverflowMenuContext)) {
|
|
216
|
+
return /* @__PURE__ */ jsx(
|
|
217
|
+
DropdownMenu.Item,
|
|
218
|
+
{
|
|
219
|
+
...rest,
|
|
220
|
+
label,
|
|
221
|
+
icon,
|
|
222
|
+
ref: forwardedRef
|
|
223
|
+
}
|
|
224
|
+
);
|
|
225
|
+
}
|
|
160
226
|
return /* @__PURE__ */ jsx(
|
|
161
227
|
IconButton,
|
|
162
228
|
{
|
|
229
|
+
label,
|
|
230
|
+
icon,
|
|
163
231
|
inert: visible === false ? true : void 0,
|
|
164
232
|
...rest,
|
|
165
233
|
variant: "ghost",
|
package/dist/bricks/index.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export * as DropdownMenu from "./DropdownMenu.js";
|
|
|
10
10
|
export { Divider } from "./Divider.js";
|
|
11
11
|
export { Icon } from "./Icon.js";
|
|
12
12
|
export { IconButton } from "./IconButton.js";
|
|
13
|
-
export
|
|
13
|
+
export * as Field from "./Field.js";
|
|
14
14
|
export { Kbd } from "./Kbd.js";
|
|
15
15
|
export { Label } from "./Label.js";
|
|
16
16
|
export { ProgressBar } from "./ProgressBar.js";
|
|
@@ -19,6 +19,7 @@ export * as Select from "./Select.js";
|
|
|
19
19
|
export { Spinner } from "./Spinner.js";
|
|
20
20
|
export { Skeleton } from "./Skeleton.js";
|
|
21
21
|
export { Switch } from "./Switch.js";
|
|
22
|
+
export * as Table from "./Table.js";
|
|
22
23
|
export * as Tabs from "./Tabs.js";
|
|
23
24
|
export { Text } from "./Text.js";
|
|
24
25
|
export * as TextBox from "./TextBox.js";
|
package/dist/bricks/index.js
CHANGED
|
@@ -11,7 +11,7 @@ import * as DropdownMenu from "./DropdownMenu.js";
|
|
|
11
11
|
import { Divider } from "./Divider.js";
|
|
12
12
|
import { Icon } from "./Icon.js";
|
|
13
13
|
import { IconButton } from "./IconButton.js";
|
|
14
|
-
import
|
|
14
|
+
import * as Field from "./Field.js";
|
|
15
15
|
import { Kbd } from "./Kbd.js";
|
|
16
16
|
import { Label } from "./Label.js";
|
|
17
17
|
import { ProgressBar } from "./ProgressBar.js";
|
|
@@ -20,6 +20,7 @@ import * as Select from "./Select.js";
|
|
|
20
20
|
import { Spinner } from "./Spinner.js";
|
|
21
21
|
import { Skeleton } from "./Skeleton.js";
|
|
22
22
|
import { Switch } from "./Switch.js";
|
|
23
|
+
import * as Table from "./Table.js";
|
|
23
24
|
import * as Tabs from "./Tabs.js";
|
|
24
25
|
import { Text } from "./Text.js";
|
|
25
26
|
import * as TextBox from "./TextBox.js";
|
|
@@ -48,6 +49,7 @@ export {
|
|
|
48
49
|
Skeleton,
|
|
49
50
|
Spinner,
|
|
50
51
|
Switch,
|
|
52
|
+
Table,
|
|
51
53
|
Tabs,
|
|
52
54
|
Text,
|
|
53
55
|
TextBox,
|