@itwin/itwinui-react 5.0.0-alpha.5 → 5.0.0-alpha.7
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 +17 -0
- package/dist/DEV/bricks/Avatar.js +24 -0
- package/dist/DEV/bricks/Badge.js +22 -0
- package/dist/DEV/bricks/Checkbox.js +1 -3
- package/dist/DEV/bricks/Description.js +13 -11
- package/dist/DEV/bricks/DropdownMenu.js +7 -2
- package/dist/DEV/bricks/Field.js +33 -56
- package/dist/DEV/bricks/Icon.js +5 -2
- package/dist/DEV/bricks/ListItem.js +14 -0
- package/dist/DEV/bricks/Radio.js +1 -3
- package/dist/DEV/bricks/Select.js +1 -3
- package/dist/DEV/bricks/Switch.js +1 -3
- package/dist/DEV/bricks/Table.js +114 -0
- package/dist/DEV/bricks/TextBox.js +1 -5
- package/dist/DEV/bricks/Tree.js +16 -10
- package/dist/DEV/bricks/index.js +4 -0
- package/dist/DEV/bricks/styles.css.js +1 -1
- package/dist/DEV/bricks/~hooks.js +9 -1
- package/dist/DEV/foundations/styles.css.js +1 -1
- 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/Checkbox.js +1 -3
- package/dist/bricks/Description.d.ts +1 -2
- package/dist/bricks/Description.js +13 -11
- package/dist/bricks/DropdownMenu.js +7 -2
- package/dist/bricks/Field.d.ts +4 -8
- package/dist/bricks/Field.js +33 -56
- package/dist/bricks/Icon.d.ts +28 -3
- package/dist/bricks/Icon.js +5 -2
- package/dist/bricks/ListItem.d.ts +5 -1
- package/dist/bricks/ListItem.js +13 -0
- package/dist/bricks/Radio.js +1 -3
- package/dist/bricks/Select.js +1 -3
- package/dist/bricks/Switch.js +1 -3
- package/dist/bricks/Table.d.ts +115 -0
- package/dist/bricks/Table.js +108 -0
- package/dist/bricks/TextBox.js +1 -5
- package/dist/bricks/Tree.js +16 -10
- package/dist/bricks/index.d.ts +2 -0
- package/dist/bricks/index.js +4 -0
- package/dist/bricks/styles.css.js +1 -1
- package/dist/bricks/~hooks.d.ts +9 -0
- package/dist/bricks/~hooks.js +9 -1
- package/dist/foundations/styles.css.js +1 -1
- package/package.json +4 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 5.0.0-alpha.7
|
|
4
|
+
|
|
5
|
+
- Added new `<Avatar>` component.
|
|
6
|
+
- Added new `<Badge>` component.
|
|
7
|
+
- Added `alt` prop to `<Icon>` component.
|
|
8
|
+
- Fixed all color tokens to use the correct `oklch` values.
|
|
9
|
+
- Fixed an issue where `<Tree.Item>` was not respecting its `style` prop.
|
|
10
|
+
|
|
11
|
+
## 5.0.0-alpha.6
|
|
12
|
+
|
|
13
|
+
- **breaking**: All CSS variables have been renamed to use the `--ids` prefix. See [#369](https://github.com/iTwin/kiwi/pull/369).
|
|
14
|
+
- **breaking**: Some CSS variables were renamed further. See [#368](https://github.com/iTwin/kiwi/pull/368).
|
|
15
|
+
- Notably, the "surface" backgrounds have been split into two different "page" and "elevation" scales.
|
|
16
|
+
- Background colors have been updated to match the latest design.
|
|
17
|
+
- All styles are now loaded into `@layer itwinui`. The one exception is the CSS reset which remains in `@layer reset`.
|
|
18
|
+
- `<Field>` now respects the order of `<Description>`s when creating associations.
|
|
19
|
+
|
|
3
20
|
## 5.0.0-alpha.5
|
|
4
21
|
|
|
5
22
|
- **breaking**: `Tree` API has changed to require flat structure, with explicit ARIA props (see [#300](https://github.com/iTwin/kiwi/pull/300)). `<Tree.Item>` no longer allows passing `children`.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import cx from "classnames";
|
|
3
|
+
import * as Ariakit from "@ariakit/react";
|
|
4
|
+
import { forwardRef } from "./~utils.js";
|
|
5
|
+
const Avatar = forwardRef((props, forwardedRef) => {
|
|
6
|
+
const { size = "medium", initials, alt, image, children, ...rest } = props;
|
|
7
|
+
const isDecorative = !alt;
|
|
8
|
+
return /* @__PURE__ */ jsx(
|
|
9
|
+
Ariakit.Role.span,
|
|
10
|
+
{
|
|
11
|
+
role: isDecorative ? void 0 : "img",
|
|
12
|
+
"aria-label": isDecorative ? void 0 : alt,
|
|
13
|
+
...rest,
|
|
14
|
+
"data-kiwi-size": size,
|
|
15
|
+
className: cx("\u{1F95D}-avatar", props.className),
|
|
16
|
+
ref: forwardedRef,
|
|
17
|
+
children: image ?? /* @__PURE__ */ jsx("abbr", { className: "\u{1F95D}-avatar-initials", "aria-hidden": "true", children: initials?.substring(0, 1) })
|
|
18
|
+
}
|
|
19
|
+
);
|
|
20
|
+
});
|
|
21
|
+
DEV: Avatar.displayName = "Avatar";
|
|
22
|
+
export {
|
|
23
|
+
Avatar
|
|
24
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import cx from "classnames";
|
|
3
|
+
import * as Ariakit from "@ariakit/react";
|
|
4
|
+
import { forwardRef } from "./~utils.js";
|
|
5
|
+
const Badge = forwardRef((props, forwardedRef) => {
|
|
6
|
+
const { tone = "neutral", variant = "solid", label, ...rest } = props;
|
|
7
|
+
return /* @__PURE__ */ jsx(
|
|
8
|
+
Ariakit.Role.span,
|
|
9
|
+
{
|
|
10
|
+
...rest,
|
|
11
|
+
"data-kiwi-tone": tone,
|
|
12
|
+
"data-kiwi-variant": variant,
|
|
13
|
+
className: cx("\u{1F95D}-badge", props.className),
|
|
14
|
+
ref: forwardedRef,
|
|
15
|
+
children: label
|
|
16
|
+
}
|
|
17
|
+
);
|
|
18
|
+
});
|
|
19
|
+
DEV: Badge.displayName = "Badge";
|
|
20
|
+
export {
|
|
21
|
+
Badge
|
|
22
|
+
};
|
|
@@ -1,12 +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 { FieldControl
|
|
4
|
+
import { FieldControl } from "./Field.js";
|
|
5
5
|
import { forwardRef } from "./~utils.js";
|
|
6
6
|
const Checkbox = forwardRef(
|
|
7
7
|
(props, forwardedRef) => {
|
|
8
8
|
const { id, ...rest } = props;
|
|
9
|
-
const describedBy = useFieldDescribedBy(props["aria-describedby"]);
|
|
10
9
|
return /* @__PURE__ */ jsx(
|
|
11
10
|
FieldControl,
|
|
12
11
|
{
|
|
@@ -18,7 +17,6 @@ const Checkbox = forwardRef(
|
|
|
18
17
|
accessibleWhenDisabled: true,
|
|
19
18
|
...rest,
|
|
20
19
|
className: cx("\u{1F95D}-checkbox", props.className),
|
|
21
|
-
"aria-describedby": describedBy,
|
|
22
20
|
ref: forwardedRef
|
|
23
21
|
}
|
|
24
22
|
)
|
|
@@ -1,23 +1,25 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import * as React from "react";
|
|
3
2
|
import { forwardRef } from "./~utils.js";
|
|
4
3
|
import cx from "classnames";
|
|
5
4
|
import { Text } from "./Text.js";
|
|
6
|
-
import {
|
|
5
|
+
import { FieldDescription } from "./Field.js";
|
|
7
6
|
const Description = forwardRef(
|
|
8
7
|
(props, forwardedRef) => {
|
|
9
|
-
const
|
|
10
|
-
const { id = generatedId, tone, ...rest } = props;
|
|
11
|
-
useFieldRegisterDescribedBy(id);
|
|
8
|
+
const { id, tone, ...rest } = props;
|
|
12
9
|
return /* @__PURE__ */ jsx(
|
|
13
|
-
|
|
10
|
+
FieldDescription,
|
|
14
11
|
{
|
|
15
|
-
...rest,
|
|
16
12
|
id,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
13
|
+
render: /* @__PURE__ */ jsx(
|
|
14
|
+
Text,
|
|
15
|
+
{
|
|
16
|
+
...rest,
|
|
17
|
+
variant: "caption-md",
|
|
18
|
+
"data-kiwi-tone": tone ?? "neutral",
|
|
19
|
+
className: cx("\u{1F95D}-description", props.className),
|
|
20
|
+
ref: forwardedRef
|
|
21
|
+
}
|
|
22
|
+
)
|
|
21
23
|
}
|
|
22
24
|
);
|
|
23
25
|
}
|
|
@@ -93,7 +93,7 @@ const DropdownMenuItem = forwardRef(
|
|
|
93
93
|
ref: forwardedRef,
|
|
94
94
|
children: [
|
|
95
95
|
/* @__PURE__ */ jsx(ListItem.Content, { children: props.children }),
|
|
96
|
-
hasShortcuts && /* @__PURE__ */ jsx(
|
|
96
|
+
hasShortcuts && /* @__PURE__ */ jsx(ListItem.Decoration, { className: "\u{1F95D}-dropdown-menu-item-shortcuts", children: shortcutKeys.map((key, index) => /* @__PURE__ */ jsx(Kbd, { variant: "ghost", children: key }, `${key + index}`)) })
|
|
97
97
|
]
|
|
98
98
|
}
|
|
99
99
|
);
|
|
@@ -112,7 +112,12 @@ const DropdownMenuCheckboxItem = forwardRef((props, forwardedRef) => {
|
|
|
112
112
|
ref: forwardedRef,
|
|
113
113
|
children: [
|
|
114
114
|
/* @__PURE__ */ jsx(ListItem.Content, { children: props.children }),
|
|
115
|
-
/* @__PURE__ */ jsx(
|
|
115
|
+
/* @__PURE__ */ jsx(
|
|
116
|
+
ListItem.Decoration,
|
|
117
|
+
{
|
|
118
|
+
render: /* @__PURE__ */ jsx(Checkmark, { className: "\u{1F95D}-dropdown-menu-checkmark" })
|
|
119
|
+
}
|
|
120
|
+
)
|
|
116
121
|
]
|
|
117
122
|
}
|
|
118
123
|
);
|
package/dist/DEV/bricks/Field.js
CHANGED
|
@@ -5,7 +5,7 @@ import cx from "classnames";
|
|
|
5
5
|
import { forwardRef } from "./~utils.js";
|
|
6
6
|
const Field = forwardRef((props, forwardedRef) => {
|
|
7
7
|
const { layout, ...rest } = props;
|
|
8
|
-
return /* @__PURE__ */ jsx(
|
|
8
|
+
return /* @__PURE__ */ jsx(
|
|
9
9
|
FieldCollection,
|
|
10
10
|
{
|
|
11
11
|
render: /* @__PURE__ */ jsx(
|
|
@@ -18,58 +18,9 @@ const Field = forwardRef((props, forwardedRef) => {
|
|
|
18
18
|
}
|
|
19
19
|
)
|
|
20
20
|
}
|
|
21
|
-
)
|
|
21
|
+
);
|
|
22
22
|
});
|
|
23
23
|
DEV: Field.displayName = "Field";
|
|
24
|
-
const FieldDescribedByContext = React.createContext(void 0);
|
|
25
|
-
function FieldDescribedByProvider(props) {
|
|
26
|
-
const [describedBy, setDescribedBy] = React.useState(/* @__PURE__ */ new Set());
|
|
27
|
-
const register = React.useCallback((id) => {
|
|
28
|
-
setDescribedBy((describedBy2) => {
|
|
29
|
-
const updated = new Set(describedBy2);
|
|
30
|
-
updated.add(id);
|
|
31
|
-
return updated;
|
|
32
|
-
});
|
|
33
|
-
}, []);
|
|
34
|
-
const unregister = React.useCallback((id) => {
|
|
35
|
-
setDescribedBy((describedBy2) => {
|
|
36
|
-
const updated = new Set(describedBy2);
|
|
37
|
-
updated.delete(id);
|
|
38
|
-
return updated;
|
|
39
|
-
});
|
|
40
|
-
}, []);
|
|
41
|
-
return /* @__PURE__ */ jsx(
|
|
42
|
-
FieldDescribedByContext.Provider,
|
|
43
|
-
{
|
|
44
|
-
value: React.useMemo(
|
|
45
|
-
() => ({
|
|
46
|
-
describedBy,
|
|
47
|
-
register,
|
|
48
|
-
unregister
|
|
49
|
-
}),
|
|
50
|
-
[describedBy, register, unregister]
|
|
51
|
-
),
|
|
52
|
-
children: props.children
|
|
53
|
-
}
|
|
54
|
-
);
|
|
55
|
-
}
|
|
56
|
-
function useFieldDescribedBy(ariaDescribedByProp) {
|
|
57
|
-
const describedBySet = React.useContext(FieldDescribedByContext)?.describedBy;
|
|
58
|
-
return React.useMemo(
|
|
59
|
-
() => !describedBySet || describedBySet.size === 0 ? ariaDescribedByProp : [...describedBySet, ariaDescribedByProp].filter(Boolean).join(" "),
|
|
60
|
-
[describedBySet, ariaDescribedByProp]
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
function useFieldRegisterDescribedBy(id) {
|
|
64
|
-
const context = React.useContext(FieldDescribedByContext);
|
|
65
|
-
const register = context?.register;
|
|
66
|
-
const unregister = context?.unregister;
|
|
67
|
-
React.useEffect(() => {
|
|
68
|
-
if (!register || !unregister) return;
|
|
69
|
-
register(id);
|
|
70
|
-
return () => unregister(id);
|
|
71
|
-
}, [id, register, unregister]);
|
|
72
|
-
}
|
|
73
24
|
function FieldCollection(props) {
|
|
74
25
|
const fieldElementCollection = Ariakit.useCollectionStore({
|
|
75
26
|
defaultItems: []
|
|
@@ -102,8 +53,16 @@ function FieldCollection(props) {
|
|
|
102
53
|
);
|
|
103
54
|
}
|
|
104
55
|
function FieldControl(props) {
|
|
56
|
+
const store = Ariakit.useCollectionContext();
|
|
105
57
|
const generatedId = React.useId();
|
|
106
|
-
const { id = generatedId, type, ...rest } = props;
|
|
58
|
+
const { id = store ? generatedId : void 0, type, ...rest } = props;
|
|
59
|
+
const renderedItems = Ariakit.useStoreState(store, "renderedItems");
|
|
60
|
+
const describedBy = React.useMemo(() => {
|
|
61
|
+
const idRefList = renderedItems?.filter(
|
|
62
|
+
(item) => item.elementType === "description"
|
|
63
|
+
)?.map((item) => item.id).join(" ");
|
|
64
|
+
return idRefList || void 0;
|
|
65
|
+
}, [renderedItems]);
|
|
107
66
|
const getData = React.useCallback(
|
|
108
67
|
(data) => ({
|
|
109
68
|
...data,
|
|
@@ -112,7 +71,14 @@ function FieldControl(props) {
|
|
|
112
71
|
}),
|
|
113
72
|
[type]
|
|
114
73
|
);
|
|
115
|
-
return /* @__PURE__ */ jsx(
|
|
74
|
+
return /* @__PURE__ */ jsx(
|
|
75
|
+
Ariakit.CollectionItem,
|
|
76
|
+
{
|
|
77
|
+
id,
|
|
78
|
+
getItem: getData,
|
|
79
|
+
render: /* @__PURE__ */ jsx(Ariakit.Role, { ...rest, "aria-describedby": describedBy })
|
|
80
|
+
}
|
|
81
|
+
);
|
|
116
82
|
}
|
|
117
83
|
function FieldLabel(props) {
|
|
118
84
|
const store = Ariakit.useCollectionContext();
|
|
@@ -138,10 +104,21 @@ function FieldLabel(props) {
|
|
|
138
104
|
}
|
|
139
105
|
);
|
|
140
106
|
}
|
|
107
|
+
function FieldDescription(props) {
|
|
108
|
+
const generatedId = React.useId();
|
|
109
|
+
const { id = generatedId, ...rest } = props;
|
|
110
|
+
const getData = React.useCallback(
|
|
111
|
+
(data) => ({
|
|
112
|
+
...data,
|
|
113
|
+
elementType: "description"
|
|
114
|
+
}),
|
|
115
|
+
[]
|
|
116
|
+
);
|
|
117
|
+
return /* @__PURE__ */ jsx(Ariakit.CollectionItem, { ...rest, id, getItem: getData });
|
|
118
|
+
}
|
|
141
119
|
export {
|
|
142
120
|
Field,
|
|
143
121
|
FieldControl,
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
useFieldRegisterDescribedBy
|
|
122
|
+
FieldDescription,
|
|
123
|
+
FieldLabel
|
|
147
124
|
};
|
package/dist/DEV/bricks/Icon.js
CHANGED
|
@@ -4,12 +4,15 @@ import cx from "classnames";
|
|
|
4
4
|
import * as Ariakit from "@ariakit/react";
|
|
5
5
|
import { forwardRef } from "./~utils.js";
|
|
6
6
|
const Icon = forwardRef((props, forwardedRef) => {
|
|
7
|
-
const { href, size
|
|
7
|
+
const { href, size, alt, ...rest } = props;
|
|
8
8
|
const iconId = toIconId(size);
|
|
9
|
+
const isDecorative = !alt;
|
|
9
10
|
return /* @__PURE__ */ jsx(
|
|
10
11
|
Ariakit.Role.svg,
|
|
11
12
|
{
|
|
12
|
-
"aria-hidden": true,
|
|
13
|
+
"aria-hidden": isDecorative ? "true" : void 0,
|
|
14
|
+
role: isDecorative ? void 0 : "img",
|
|
15
|
+
"aria-label": isDecorative ? void 0 : alt,
|
|
13
16
|
...rest,
|
|
14
17
|
"data-kiwi-size": size,
|
|
15
18
|
className: cx("\u{1F95D}-icon", props.className),
|
|
@@ -27,7 +27,21 @@ const ListItemContent = forwardRef(
|
|
|
27
27
|
}
|
|
28
28
|
);
|
|
29
29
|
DEV: ListItemContent.displayName = "ListItem.Content";
|
|
30
|
+
const ListItemDecoration = forwardRef(
|
|
31
|
+
(props, forwardedRef) => {
|
|
32
|
+
return /* @__PURE__ */ jsx(
|
|
33
|
+
Ariakit.Role.span,
|
|
34
|
+
{
|
|
35
|
+
...props,
|
|
36
|
+
className: cx("\u{1F95D}-list-item-decoration", props.className),
|
|
37
|
+
ref: forwardedRef
|
|
38
|
+
}
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
);
|
|
42
|
+
DEV: ListItemDecoration.displayName = "ListItem.Decoration";
|
|
30
43
|
export {
|
|
31
44
|
ListItemContent as Content,
|
|
45
|
+
ListItemDecoration as Decoration,
|
|
32
46
|
ListItem as Root
|
|
33
47
|
};
|
package/dist/DEV/bricks/Radio.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import cx from "classnames";
|
|
3
3
|
import * as Ariakit from "@ariakit/react";
|
|
4
|
-
import { FieldControl
|
|
4
|
+
import { FieldControl } from "./Field.js";
|
|
5
5
|
import { forwardRef } from "./~utils.js";
|
|
6
6
|
const Radio = forwardRef((props, forwardedRef) => {
|
|
7
7
|
const { id, ...rest } = props;
|
|
8
|
-
const describedBy = useFieldDescribedBy(props["aria-describedby"]);
|
|
9
8
|
return /* @__PURE__ */ jsx(
|
|
10
9
|
FieldControl,
|
|
11
10
|
{
|
|
@@ -17,7 +16,6 @@ const Radio = forwardRef((props, forwardedRef) => {
|
|
|
17
16
|
accessibleWhenDisabled: true,
|
|
18
17
|
...rest,
|
|
19
18
|
className: cx("\u{1F95D}-checkbox", "\u{1F95D}-radio", props.className),
|
|
20
|
-
"aria-describedby": describedBy,
|
|
21
19
|
ref: forwardedRef
|
|
22
20
|
}
|
|
23
21
|
)
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
isBrowser
|
|
8
8
|
} from "./~utils.js";
|
|
9
9
|
import { DisclosureArrow } from "./Icon.js";
|
|
10
|
-
import { FieldControl
|
|
10
|
+
import { FieldControl } from "./Field.js";
|
|
11
11
|
const supportsHas = isBrowser && CSS?.supports?.("selector(:has(+ *))");
|
|
12
12
|
const HtmlSelectContext = React.createContext(() => {
|
|
13
13
|
});
|
|
@@ -27,7 +27,6 @@ const HtmlSelect = forwardRef(
|
|
|
27
27
|
(props, forwardedRef) => {
|
|
28
28
|
const { id, variant = "solid", ...rest } = props;
|
|
29
29
|
const setIsHtmlSelect = React.useContext(HtmlSelectContext);
|
|
30
|
-
const describedBy = useFieldDescribedBy(props["aria-describedby"]);
|
|
31
30
|
React.useEffect(
|
|
32
31
|
function updateContext() {
|
|
33
32
|
setIsHtmlSelect(true);
|
|
@@ -45,7 +44,6 @@ const HtmlSelect = forwardRef(
|
|
|
45
44
|
{
|
|
46
45
|
...rest,
|
|
47
46
|
className: cx("\u{1F95D}-button", "\u{1F95D}-select", props.className),
|
|
48
|
-
"aria-describedby": describedBy,
|
|
49
47
|
"data-kiwi-tone": "neutral",
|
|
50
48
|
"data-kiwi-variant": variant,
|
|
51
49
|
ref: forwardedRef
|
|
@@ -1,12 +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 { FieldControl
|
|
4
|
+
import { FieldControl } from "./Field.js";
|
|
5
5
|
import { forwardRef } from "./~utils.js";
|
|
6
6
|
const Switch = forwardRef(
|
|
7
7
|
(props, forwardedRef) => {
|
|
8
8
|
const { id, ...rest } = props;
|
|
9
|
-
const describedBy = useFieldDescribedBy(props["aria-describedby"]);
|
|
10
9
|
return /* @__PURE__ */ jsx(
|
|
11
10
|
FieldControl,
|
|
12
11
|
{
|
|
@@ -18,7 +17,6 @@ const Switch = forwardRef(
|
|
|
18
17
|
accessibleWhenDisabled: true,
|
|
19
18
|
...rest,
|
|
20
19
|
className: cx("\u{1F95D}-switch", props.className),
|
|
21
|
-
"aria-describedby": describedBy,
|
|
22
20
|
role: "switch",
|
|
23
21
|
ref: forwardedRef
|
|
24
22
|
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import * as Ariakit from "@ariakit/react";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import cx from "classnames";
|
|
5
|
+
import { forwardRef } from "./~utils.js";
|
|
6
|
+
import { useMergedRefs } from "./~hooks.js";
|
|
7
|
+
const TableContext = React.createContext({
|
|
8
|
+
setCaptionId: () => {
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const Table = forwardRef((props, forwardedRef) => {
|
|
12
|
+
const [captionId, setCaptionId] = React.useState();
|
|
13
|
+
const tableContext = React.useMemo(() => ({ setCaptionId }), []);
|
|
14
|
+
return /* @__PURE__ */ jsx(TableContext.Provider, { value: tableContext, children: /* @__PURE__ */ jsx(
|
|
15
|
+
Ariakit.Role,
|
|
16
|
+
{
|
|
17
|
+
...props,
|
|
18
|
+
className: cx("\u{1F95D}-table", props.className),
|
|
19
|
+
ref: forwardedRef,
|
|
20
|
+
role: "table",
|
|
21
|
+
"aria-labelledby": captionId,
|
|
22
|
+
children: props.children
|
|
23
|
+
}
|
|
24
|
+
) });
|
|
25
|
+
});
|
|
26
|
+
DEV: Table.displayName = "Table.Root";
|
|
27
|
+
const TableHeaderContext = React.createContext(false);
|
|
28
|
+
const TableHeader = forwardRef(
|
|
29
|
+
(props, forwardedRef) => {
|
|
30
|
+
return /* @__PURE__ */ jsx(TableHeaderContext.Provider, { value: true, children: /* @__PURE__ */ jsx(
|
|
31
|
+
Ariakit.Role.div,
|
|
32
|
+
{
|
|
33
|
+
...props,
|
|
34
|
+
className: cx("\u{1F95D}-table-header", props.className),
|
|
35
|
+
ref: forwardedRef,
|
|
36
|
+
role: "rowgroup",
|
|
37
|
+
children: props.children
|
|
38
|
+
}
|
|
39
|
+
) });
|
|
40
|
+
}
|
|
41
|
+
);
|
|
42
|
+
DEV: TableHeader.displayName = "Table.Header";
|
|
43
|
+
const TableBody = forwardRef((props, forwardedRef) => {
|
|
44
|
+
return /* @__PURE__ */ jsx(
|
|
45
|
+
Ariakit.Role.div,
|
|
46
|
+
{
|
|
47
|
+
...props,
|
|
48
|
+
className: cx("\u{1F95D}-table-body", props.className),
|
|
49
|
+
ref: forwardedRef,
|
|
50
|
+
children: props.children
|
|
51
|
+
}
|
|
52
|
+
);
|
|
53
|
+
});
|
|
54
|
+
DEV: TableBody.displayName = "Table.Body";
|
|
55
|
+
const TableRow = forwardRef((props, forwardedRef) => {
|
|
56
|
+
const { children, ...rest } = props;
|
|
57
|
+
return /* @__PURE__ */ jsx(
|
|
58
|
+
Ariakit.Role.div,
|
|
59
|
+
{
|
|
60
|
+
...rest,
|
|
61
|
+
className: cx("\u{1F95D}-table-row", props.className),
|
|
62
|
+
ref: forwardedRef,
|
|
63
|
+
role: "row",
|
|
64
|
+
children
|
|
65
|
+
}
|
|
66
|
+
);
|
|
67
|
+
});
|
|
68
|
+
DEV: TableRow.displayName = "Table.Row";
|
|
69
|
+
const TableCaption = forwardRef(
|
|
70
|
+
(props, forwardedRef) => {
|
|
71
|
+
const fallbackId = React.useId();
|
|
72
|
+
const { id = fallbackId, children, ...rest } = props;
|
|
73
|
+
const { setCaptionId } = React.useContext(TableContext);
|
|
74
|
+
const captionIdRef = React.useCallback(
|
|
75
|
+
(element) => {
|
|
76
|
+
setCaptionId(element ? id : void 0);
|
|
77
|
+
},
|
|
78
|
+
[id, setCaptionId]
|
|
79
|
+
);
|
|
80
|
+
return /* @__PURE__ */ jsx(
|
|
81
|
+
Ariakit.Role,
|
|
82
|
+
{
|
|
83
|
+
...rest,
|
|
84
|
+
id,
|
|
85
|
+
className: cx("\u{1F95D}-table-caption", props.className),
|
|
86
|
+
ref: useMergedRefs(forwardedRef, captionIdRef),
|
|
87
|
+
children
|
|
88
|
+
}
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
);
|
|
92
|
+
DEV: TableCaption.displayName = "Table.Caption";
|
|
93
|
+
const TableCell = forwardRef((props, forwardedRef) => {
|
|
94
|
+
const isWithinTableHeader = React.useContext(TableHeaderContext);
|
|
95
|
+
return /* @__PURE__ */ jsx(
|
|
96
|
+
Ariakit.Role.span,
|
|
97
|
+
{
|
|
98
|
+
...props,
|
|
99
|
+
className: cx("\u{1F95D}-table-cell", props.className),
|
|
100
|
+
ref: forwardedRef,
|
|
101
|
+
role: isWithinTableHeader ? "columnheader" : "cell",
|
|
102
|
+
children: props.children
|
|
103
|
+
}
|
|
104
|
+
);
|
|
105
|
+
});
|
|
106
|
+
DEV: TableCell.displayName = "Table.Cell";
|
|
107
|
+
export {
|
|
108
|
+
TableBody as Body,
|
|
109
|
+
TableCaption as Caption,
|
|
110
|
+
TableCell as Cell,
|
|
111
|
+
TableHeader as Header,
|
|
112
|
+
Table as Root,
|
|
113
|
+
TableRow as Row
|
|
114
|
+
};
|
|
@@ -2,14 +2,13 @@ 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 { FieldControl
|
|
5
|
+
import { FieldControl } from "./Field.js";
|
|
6
6
|
import { Icon } from "./Icon.js";
|
|
7
7
|
import { useMergedRefs } from "./~hooks.js";
|
|
8
8
|
import { forwardRef } from "./~utils.js";
|
|
9
9
|
const TextBoxInput = forwardRef(
|
|
10
10
|
(props, forwardedRef) => {
|
|
11
11
|
const { id, ...rest } = props;
|
|
12
|
-
const describedBy = useFieldDescribedBy(props["aria-describedby"]);
|
|
13
12
|
const rootContext = React.useContext(TextBoxRootContext);
|
|
14
13
|
const setDisabled = rootContext?.setDisabled;
|
|
15
14
|
React.useEffect(() => {
|
|
@@ -25,7 +24,6 @@ const TextBoxInput = forwardRef(
|
|
|
25
24
|
{
|
|
26
25
|
readOnly: props.disabled,
|
|
27
26
|
...rest,
|
|
28
|
-
"aria-describedby": describedBy,
|
|
29
27
|
className: cx({ "\u{1F95D}-text-box": !rootContext }, props.className),
|
|
30
28
|
placeholder: props.placeholder ?? " ",
|
|
31
29
|
render: /* @__PURE__ */ jsx(
|
|
@@ -46,7 +44,6 @@ DEV: TextBoxInput.displayName = "TextBox.Input";
|
|
|
46
44
|
const TextBoxTextarea = forwardRef(
|
|
47
45
|
(props, forwardedRef) => {
|
|
48
46
|
const { id, ...rest } = props;
|
|
49
|
-
const describedBy = useFieldDescribedBy(props["aria-describedby"]);
|
|
50
47
|
return /* @__PURE__ */ jsx(
|
|
51
48
|
FieldControl,
|
|
52
49
|
{
|
|
@@ -58,7 +55,6 @@ const TextBoxTextarea = forwardRef(
|
|
|
58
55
|
readOnly: props.disabled,
|
|
59
56
|
...rest,
|
|
60
57
|
className: cx("\u{1F95D}-text-box", props.className),
|
|
61
|
-
"aria-describedby": describedBy,
|
|
62
58
|
placeholder: props.placeholder ?? " ",
|
|
63
59
|
render: /* @__PURE__ */ jsx(
|
|
64
60
|
Ariakit.Focusable,
|
package/dist/DEV/bricks/Tree.js
CHANGED
|
@@ -31,7 +31,6 @@ const TreeItem = forwardRef((props, forwardedRef) => {
|
|
|
31
31
|
icon,
|
|
32
32
|
label,
|
|
33
33
|
actions,
|
|
34
|
-
style,
|
|
35
34
|
onSelectedChange,
|
|
36
35
|
onExpandedChange,
|
|
37
36
|
onClick: onClickProp,
|
|
@@ -94,18 +93,25 @@ const TreeItem = forwardRef((props, forwardedRef) => {
|
|
|
94
93
|
style: { "--\u{1F95D}tree-item-level": level },
|
|
95
94
|
role: void 0,
|
|
96
95
|
children: [
|
|
96
|
+
/* @__PURE__ */ jsxs(ListItem.Decoration, { children: [
|
|
97
|
+
/* @__PURE__ */ jsx(
|
|
98
|
+
TreeItemExpander,
|
|
99
|
+
{
|
|
100
|
+
onClick: () => {
|
|
101
|
+
if (expanded === void 0) return;
|
|
102
|
+
onExpandedChange?.(!expanded);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
),
|
|
106
|
+
typeof icon === "string" ? /* @__PURE__ */ jsx(Icon, { href: icon }) : icon
|
|
107
|
+
] }),
|
|
108
|
+
/* @__PURE__ */ jsx(TreeItemContent, { label }),
|
|
97
109
|
/* @__PURE__ */ jsx(
|
|
98
|
-
|
|
110
|
+
ListItem.Decoration,
|
|
99
111
|
{
|
|
100
|
-
|
|
101
|
-
if (expanded === void 0) return;
|
|
102
|
-
onExpandedChange?.(!expanded);
|
|
103
|
-
}
|
|
112
|
+
render: /* @__PURE__ */ jsx(TreeItemActions, { children: actions })
|
|
104
113
|
}
|
|
105
|
-
)
|
|
106
|
-
typeof icon === "string" ? /* @__PURE__ */ jsx(Icon, { href: icon }) : icon,
|
|
107
|
-
/* @__PURE__ */ jsx(TreeItemContent, { label }),
|
|
108
|
-
/* @__PURE__ */ jsx(TreeItemActions, { children: actions })
|
|
114
|
+
)
|
|
109
115
|
]
|
|
110
116
|
}
|
|
111
117
|
)
|
package/dist/DEV/bricks/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
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";
|
|
6
8
|
import { Chip } from "./Chip.js";
|
|
@@ -24,6 +26,8 @@ import { Tooltip } from "./Tooltip.js";
|
|
|
24
26
|
import { VisuallyHidden } from "./VisuallyHidden.js";
|
|
25
27
|
export {
|
|
26
28
|
Anchor,
|
|
29
|
+
Avatar,
|
|
30
|
+
Badge,
|
|
27
31
|
Button,
|
|
28
32
|
Checkbox,
|
|
29
33
|
Chip,
|