@itwin/itwinui-react 5.0.0-alpha.11 → 5.0.0-alpha.13
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 +28 -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 +68 -21
- package/dist/DEV/bricks/ErrorRegion.js +137 -0
- package/dist/DEV/bricks/Field.internal.js +47 -0
- package/dist/DEV/bricks/Field.js +120 -85
- package/dist/DEV/bricks/Icon.js +57 -0
- package/dist/DEV/bricks/IconButton.js +2 -5
- 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/Toolbar.js +25 -0
- package/dist/DEV/bricks/TreeItem.js +114 -42
- package/dist/DEV/bricks/index.js +9 -3
- package/dist/DEV/bricks/styles.css.js +1 -1
- package/dist/DEV/bricks/~utils.Dot.js +22 -0
- 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 +11 -9
- package/dist/bricks/DropdownMenu.js +67 -20
- package/dist/bricks/ErrorRegion.d.ts +88 -0
- package/dist/bricks/ErrorRegion.js +135 -0
- package/dist/bricks/Field.d.ts +69 -27
- package/dist/bricks/Field.internal.d.ts +33 -0
- package/dist/bricks/Field.internal.js +47 -0
- package/dist/bricks/Field.js +115 -84
- package/dist/bricks/Icon.d.ts +6 -0
- package/dist/bricks/Icon.js +55 -0
- package/dist/bricks/IconButton.js +2 -5
- package/dist/bricks/Label.d.ts +5 -12
- package/dist/bricks/Label.js +4 -10
- package/dist/bricks/ProgressBar.d.ts +7 -1
- 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/Toolbar.d.ts +35 -0
- package/dist/bricks/Toolbar.js +23 -0
- package/dist/bricks/TreeItem.d.ts +63 -9
- package/dist/bricks/TreeItem.js +103 -41
- package/dist/bricks/index.d.ts +5 -2
- package/dist/bricks/index.js +9 -3
- package/dist/bricks/styles.css.js +1 -1
- package/dist/bricks/~hooks.d.ts +1 -1
- package/dist/bricks/~utils.Dot.d.ts +11 -0
- package/dist/bricks/~utils.Dot.js +21 -0
- package/dist/foundations/styles.css.js +1 -1
- package/package.json +1 -1
package/dist/DEV/bricks/Field.js
CHANGED
|
@@ -3,14 +3,18 @@ import * as React from "react";
|
|
|
3
3
|
import cx from "classnames";
|
|
4
4
|
import { Role } from "@ariakit/react/role";
|
|
5
5
|
import {
|
|
6
|
-
useCollectionStore,
|
|
7
|
-
Collection,
|
|
8
6
|
useCollectionContext,
|
|
9
7
|
CollectionItem
|
|
10
8
|
} from "@ariakit/react/collection";
|
|
11
9
|
import { useStoreState } from "@ariakit/react/store";
|
|
12
10
|
import { forwardRef } from "./~utils.js";
|
|
13
|
-
|
|
11
|
+
import {
|
|
12
|
+
FieldCollection,
|
|
13
|
+
FieldControlTypeContext
|
|
14
|
+
} from "./Field.internal.js";
|
|
15
|
+
import { Label } from "./Label.js";
|
|
16
|
+
import { Description } from "./Description.js";
|
|
17
|
+
const FieldRoot = forwardRef((props, forwardedRef) => {
|
|
14
18
|
const { layout, ...rest } = props;
|
|
15
19
|
return /* @__PURE__ */ jsx(
|
|
16
20
|
FieldCollection,
|
|
@@ -27,76 +31,43 @@ const Field = forwardRef((props, forwardedRef) => {
|
|
|
27
31
|
}
|
|
28
32
|
);
|
|
29
33
|
});
|
|
30
|
-
DEV:
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const controlIndex2 = renderedItems.findIndex(
|
|
38
|
-
(item) => item.elementType === "control"
|
|
34
|
+
DEV: FieldRoot.displayName = "Field";
|
|
35
|
+
const FieldLabel = forwardRef(
|
|
36
|
+
(props, forwardedRef) => {
|
|
37
|
+
const store = useCollectionContext();
|
|
38
|
+
const renderedItems = useStoreState(
|
|
39
|
+
store,
|
|
40
|
+
"renderedItems"
|
|
39
41
|
);
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
const labelIndex = renderedItems.findIndex(
|
|
44
|
-
(item) => item.elementType === "label"
|
|
42
|
+
const fieldId = React.useMemo(
|
|
43
|
+
() => renderedItems?.find((item) => item.elementType === "control")?.id,
|
|
44
|
+
[renderedItems]
|
|
45
45
|
);
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
46
|
+
const getData = React.useCallback(
|
|
47
|
+
(data) => ({
|
|
48
|
+
...data,
|
|
49
|
+
elementType: "label"
|
|
50
|
+
}),
|
|
51
|
+
[]
|
|
52
|
+
);
|
|
53
|
+
return /* @__PURE__ */ jsx(
|
|
54
|
+
CollectionItem,
|
|
55
|
+
{
|
|
56
|
+
getItem: getData,
|
|
57
|
+
render: /* @__PURE__ */ jsx(Label, { ...props, htmlFor: fieldId }),
|
|
58
|
+
ref: forwardedRef
|
|
59
|
+
}
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
);
|
|
63
|
+
DEV: FieldLabel.displayName = "Field.Label";
|
|
64
|
+
const FieldDescription = forwardRef((props, forwardedRef) => {
|
|
61
65
|
const generatedId = React.useId();
|
|
62
|
-
const { id =
|
|
63
|
-
const renderedItems = useStoreState(store, "renderedItems");
|
|
64
|
-
const describedBy = React.useMemo(() => {
|
|
65
|
-
const idRefList = renderedItems?.filter(
|
|
66
|
-
(item) => item.elementType === "description"
|
|
67
|
-
)?.map((item) => item.id).join(" ");
|
|
68
|
-
return idRefList || void 0;
|
|
69
|
-
}, [renderedItems]);
|
|
70
|
-
const getData = React.useCallback(
|
|
71
|
-
(data) => ({
|
|
72
|
-
...data,
|
|
73
|
-
elementType: "control",
|
|
74
|
-
controlType: type
|
|
75
|
-
}),
|
|
76
|
-
[type]
|
|
77
|
-
);
|
|
78
|
-
return /* @__PURE__ */ jsx(
|
|
79
|
-
CollectionItem,
|
|
80
|
-
{
|
|
81
|
-
id,
|
|
82
|
-
getItem: getData,
|
|
83
|
-
render: /* @__PURE__ */ jsx(Role, { ...rest, "aria-describedby": describedBy })
|
|
84
|
-
}
|
|
85
|
-
);
|
|
86
|
-
}
|
|
87
|
-
function FieldLabel(props) {
|
|
88
|
-
const store = useCollectionContext();
|
|
89
|
-
const renderedItems = useStoreState(store, "renderedItems");
|
|
90
|
-
const fieldId = React.useMemo(
|
|
91
|
-
() => renderedItems?.find(
|
|
92
|
-
(item) => item.elementType === "control"
|
|
93
|
-
)?.id,
|
|
94
|
-
[renderedItems]
|
|
95
|
-
);
|
|
66
|
+
const { id = generatedId, ...rest } = props;
|
|
96
67
|
const getData = React.useCallback(
|
|
97
68
|
(data) => ({
|
|
98
69
|
...data,
|
|
99
|
-
elementType: "
|
|
70
|
+
elementType: "description"
|
|
100
71
|
}),
|
|
101
72
|
[]
|
|
102
73
|
);
|
|
@@ -104,25 +75,89 @@ function FieldLabel(props) {
|
|
|
104
75
|
CollectionItem,
|
|
105
76
|
{
|
|
106
77
|
getItem: getData,
|
|
107
|
-
|
|
78
|
+
id,
|
|
79
|
+
render: /* @__PURE__ */ jsx(Description, { ...rest }),
|
|
80
|
+
ref: forwardedRef
|
|
108
81
|
}
|
|
109
82
|
);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
83
|
+
});
|
|
84
|
+
DEV: FieldDescription.displayName = "Field.Description";
|
|
85
|
+
const FieldControl = forwardRef(
|
|
86
|
+
(props, forwardedRef) => {
|
|
87
|
+
const [controlType, setControlType] = React.useState();
|
|
88
|
+
const store = useCollectionContext();
|
|
89
|
+
const generatedId = React.useId();
|
|
90
|
+
const { id = store ? generatedId : void 0, ...rest } = props;
|
|
91
|
+
const renderedItems = useStoreState(
|
|
92
|
+
store,
|
|
93
|
+
"renderedItems"
|
|
94
|
+
);
|
|
95
|
+
const describedBy = React.useMemo(() => {
|
|
96
|
+
const idRefList = renderedItems?.filter(
|
|
97
|
+
(item) => item.elementType === "description" || item.elementType === "error"
|
|
98
|
+
)?.map((item) => item.id).join(" ");
|
|
99
|
+
return idRefList || void 0;
|
|
100
|
+
}, [renderedItems]);
|
|
101
|
+
const getData = React.useCallback(
|
|
102
|
+
(data) => ({
|
|
103
|
+
...data,
|
|
104
|
+
elementType: "control",
|
|
105
|
+
controlType
|
|
106
|
+
}),
|
|
107
|
+
[controlType]
|
|
108
|
+
);
|
|
109
|
+
const invalid = React.useMemo(
|
|
110
|
+
() => renderedItems?.some(
|
|
111
|
+
(item) => item.elementType === "error"
|
|
112
|
+
),
|
|
113
|
+
[renderedItems]
|
|
114
|
+
);
|
|
115
|
+
return /* @__PURE__ */ jsx(FieldControlTypeContext.Provider, { value: setControlType, children: /* @__PURE__ */ jsx(
|
|
116
|
+
CollectionItem,
|
|
117
|
+
{
|
|
118
|
+
id,
|
|
119
|
+
getItem: getData,
|
|
120
|
+
render: /* @__PURE__ */ jsx(
|
|
121
|
+
Role,
|
|
122
|
+
{
|
|
123
|
+
...rest,
|
|
124
|
+
"aria-invalid": invalid ? "true" : void 0,
|
|
125
|
+
"aria-describedby": describedBy
|
|
126
|
+
}
|
|
127
|
+
),
|
|
128
|
+
ref: forwardedRef
|
|
129
|
+
}
|
|
130
|
+
) });
|
|
131
|
+
}
|
|
132
|
+
);
|
|
133
|
+
DEV: FieldControl.displayName = "Field.Control";
|
|
134
|
+
const FieldErrorMessage = forwardRef(
|
|
135
|
+
(props, forwardedRef) => {
|
|
136
|
+
const generatedId = React.useId();
|
|
137
|
+
const { id = generatedId, ...rest } = props;
|
|
138
|
+
const getData = React.useCallback(
|
|
139
|
+
(data) => ({
|
|
140
|
+
...data,
|
|
141
|
+
elementType: "error"
|
|
142
|
+
}),
|
|
143
|
+
[]
|
|
144
|
+
);
|
|
145
|
+
return /* @__PURE__ */ jsx(
|
|
146
|
+
CollectionItem,
|
|
147
|
+
{
|
|
148
|
+
id,
|
|
149
|
+
getItem: getData,
|
|
150
|
+
render: /* @__PURE__ */ jsx(Description, { ...rest, tone: "critical" }),
|
|
151
|
+
ref: forwardedRef
|
|
152
|
+
}
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
);
|
|
156
|
+
DEV: FieldErrorMessage.displayName = "Field.ErrorMessage";
|
|
123
157
|
export {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
FieldLabel
|
|
158
|
+
FieldControl as Control,
|
|
159
|
+
FieldDescription as Description,
|
|
160
|
+
FieldErrorMessage as ErrorMessage,
|
|
161
|
+
FieldLabel as Label,
|
|
162
|
+
FieldRoot as Root
|
|
128
163
|
};
|
package/dist/DEV/bricks/Icon.js
CHANGED
|
@@ -220,10 +220,67 @@ const StatusWarning = forwardRef(
|
|
|
220
220
|
}
|
|
221
221
|
);
|
|
222
222
|
DEV: StatusWarning.displayName = "StatusWarning";
|
|
223
|
+
const MoreHorizontal = forwardRef(
|
|
224
|
+
(props, forwardedRef) => {
|
|
225
|
+
return /* @__PURE__ */ jsx(
|
|
226
|
+
Icon,
|
|
227
|
+
{
|
|
228
|
+
...props,
|
|
229
|
+
render: /* @__PURE__ */ jsx(
|
|
230
|
+
Role.svg,
|
|
231
|
+
{
|
|
232
|
+
width: "16",
|
|
233
|
+
height: "16",
|
|
234
|
+
viewBox: "0 0 16 16",
|
|
235
|
+
fill: "none",
|
|
236
|
+
render: props.render,
|
|
237
|
+
children: /* @__PURE__ */ jsx(
|
|
238
|
+
"path",
|
|
239
|
+
{
|
|
240
|
+
fill: "currentColor",
|
|
241
|
+
fillRule: "evenodd",
|
|
242
|
+
d: "M3 9a1 1 0 1 0 0-2 1 1 0 0 0 0 2Zm6-1a1 1 0 1 1-2 0 1 1 0 0 1 2 0Zm5 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z",
|
|
243
|
+
clipRule: "evenodd"
|
|
244
|
+
}
|
|
245
|
+
)
|
|
246
|
+
}
|
|
247
|
+
),
|
|
248
|
+
ref: forwardedRef
|
|
249
|
+
}
|
|
250
|
+
);
|
|
251
|
+
}
|
|
252
|
+
);
|
|
253
|
+
DEV: MoreHorizontal.displayName = "MoreHorizontal";
|
|
254
|
+
const ChevronDown = forwardRef(
|
|
255
|
+
(props, forwardedRef) => {
|
|
256
|
+
return /* @__PURE__ */ jsx(
|
|
257
|
+
Icon,
|
|
258
|
+
{
|
|
259
|
+
...props,
|
|
260
|
+
render: /* @__PURE__ */ jsx(
|
|
261
|
+
Role.svg,
|
|
262
|
+
{
|
|
263
|
+
width: "16",
|
|
264
|
+
height: "16",
|
|
265
|
+
fill: "currentColor",
|
|
266
|
+
viewBox: "0 0 16 16",
|
|
267
|
+
render: props.render,
|
|
268
|
+
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" })
|
|
269
|
+
}
|
|
270
|
+
),
|
|
271
|
+
className: cx("\u{1F95D}-chevron-down", props.className),
|
|
272
|
+
ref: forwardedRef
|
|
273
|
+
}
|
|
274
|
+
);
|
|
275
|
+
}
|
|
276
|
+
);
|
|
277
|
+
DEV: ChevronDown.displayName = "ChevronDown";
|
|
223
278
|
export {
|
|
224
279
|
Checkmark,
|
|
280
|
+
ChevronDown,
|
|
225
281
|
DisclosureArrow,
|
|
226
282
|
Dismiss,
|
|
227
283
|
Icon,
|
|
284
|
+
MoreHorizontal,
|
|
228
285
|
StatusWarning
|
|
229
286
|
};
|
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import cx from "classnames";
|
|
4
|
-
import { useToolbarContext, ToolbarItem } from "@ariakit/react/toolbar";
|
|
5
4
|
import { Button } from "./Button.js";
|
|
6
5
|
import { VisuallyHidden } from "./VisuallyHidden.js";
|
|
7
6
|
import { Icon } from "./Icon.js";
|
|
8
7
|
import { Tooltip } from "./Tooltip.js";
|
|
9
8
|
import { forwardRef } from "./~utils.js";
|
|
9
|
+
import { Dot } from "./~utils.Dot.js";
|
|
10
10
|
const IconButton = forwardRef(
|
|
11
11
|
(props, forwardedRef) => {
|
|
12
12
|
const { label, icon, isActive, labelVariant, dot, ...rest } = props;
|
|
13
13
|
const baseId = React.useId();
|
|
14
14
|
const labelId = `${baseId}-label`;
|
|
15
15
|
const dotId = `${baseId}-dot`;
|
|
16
|
-
const toolbar = useToolbarContext();
|
|
17
16
|
const button = /* @__PURE__ */ jsxs(
|
|
18
17
|
Button,
|
|
19
18
|
{
|
|
@@ -21,14 +20,12 @@ const IconButton = forwardRef(
|
|
|
21
20
|
"aria-labelledby": labelId,
|
|
22
21
|
"aria-describedby": dot ? dotId : void 0,
|
|
23
22
|
...rest,
|
|
24
|
-
"data-kiwi-dot": dot ? "true" : void 0,
|
|
25
|
-
render: toolbar ? /* @__PURE__ */ jsx(ToolbarItem, { render: props.render }) : props.render,
|
|
26
23
|
className: cx("\u{1F95D}-icon-button", props.className),
|
|
27
24
|
ref: forwardedRef,
|
|
28
25
|
children: [
|
|
29
26
|
/* @__PURE__ */ jsx(VisuallyHidden, { id: labelId, children: label }),
|
|
30
27
|
typeof icon === "string" ? /* @__PURE__ */ jsx(Icon, { href: icon }) : icon,
|
|
31
|
-
dot ? /* @__PURE__ */ jsx(
|
|
28
|
+
dot ? /* @__PURE__ */ jsx(Dot, { id: dotId, className: "\u{1F95D}-icon-button-dot", children: dot }) : null
|
|
32
29
|
]
|
|
33
30
|
}
|
|
34
31
|
);
|
package/dist/DEV/bricks/Label.js
CHANGED
|
@@ -2,19 +2,13 @@ import { jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import cx from "classnames";
|
|
3
3
|
import { Role } from "@ariakit/react/role";
|
|
4
4
|
import { forwardRef } from "./~utils.js";
|
|
5
|
-
import { FieldLabel } from "./Field.js";
|
|
6
5
|
const Label = forwardRef((props, forwardedRef) => {
|
|
7
6
|
return /* @__PURE__ */ jsx(
|
|
8
|
-
|
|
7
|
+
Role.label,
|
|
9
8
|
{
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
...props,
|
|
14
|
-
className: cx("\u{1F95D}-label", props.className),
|
|
15
|
-
ref: forwardedRef
|
|
16
|
-
}
|
|
17
|
-
)
|
|
9
|
+
...props,
|
|
10
|
+
className: cx("\u{1F95D}-label", props.className),
|
|
11
|
+
ref: forwardedRef
|
|
18
12
|
}
|
|
19
13
|
);
|
|
20
14
|
});
|
package/dist/DEV/bricks/Radio.js
CHANGED
|
@@ -3,24 +3,17 @@ import cx from "classnames";
|
|
|
3
3
|
import {
|
|
4
4
|
Radio as AkRadio
|
|
5
5
|
} from "@ariakit/react/radio";
|
|
6
|
-
import { FieldControl } from "./Field.js";
|
|
7
6
|
import { forwardRef } from "./~utils.js";
|
|
7
|
+
import { useFieldControlType } from "./Field.internal.js";
|
|
8
8
|
const Radio = forwardRef((props, forwardedRef) => {
|
|
9
|
-
|
|
9
|
+
useFieldControlType("checkable");
|
|
10
10
|
return /* @__PURE__ */ jsx(
|
|
11
|
-
|
|
11
|
+
AkRadio,
|
|
12
12
|
{
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
{
|
|
18
|
-
accessibleWhenDisabled: true,
|
|
19
|
-
...rest,
|
|
20
|
-
className: cx("\u{1F95D}-checkbox", "\u{1F95D}-radio", props.className),
|
|
21
|
-
ref: forwardedRef
|
|
22
|
-
}
|
|
23
|
-
)
|
|
13
|
+
accessibleWhenDisabled: true,
|
|
14
|
+
...props,
|
|
15
|
+
className: cx("\u{1F95D}-checkbox", "\u{1F95D}-radio", props.className),
|
|
16
|
+
ref: forwardedRef
|
|
24
17
|
}
|
|
25
18
|
);
|
|
26
19
|
});
|
|
@@ -7,11 +7,12 @@ import {
|
|
|
7
7
|
isBrowser
|
|
8
8
|
} from "./~utils.js";
|
|
9
9
|
import { DisclosureArrow } from "./Icon.js";
|
|
10
|
-
import {
|
|
10
|
+
import { useFieldControlType } from "./Field.internal.js";
|
|
11
11
|
const supportsHas = isBrowser && CSS?.supports?.("selector(:has(+ *))");
|
|
12
12
|
const HtmlSelectContext = React.createContext(() => {
|
|
13
13
|
});
|
|
14
14
|
const SelectRoot = forwardRef((props, forwardedRef) => {
|
|
15
|
+
useFieldControlType("textlike");
|
|
15
16
|
const [isHtmlSelect, setIsHtmlSelect] = React.useState(false);
|
|
16
17
|
return /* @__PURE__ */ jsx(HtmlSelectContext.Provider, { value: setIsHtmlSelect, children: /* @__PURE__ */ jsx(
|
|
17
18
|
Role.div,
|
|
@@ -25,7 +26,7 @@ const SelectRoot = forwardRef((props, forwardedRef) => {
|
|
|
25
26
|
});
|
|
26
27
|
const HtmlSelect = forwardRef(
|
|
27
28
|
(props, forwardedRef) => {
|
|
28
|
-
const {
|
|
29
|
+
const { variant = "solid", ...rest } = props;
|
|
29
30
|
const setIsHtmlSelect = React.useContext(HtmlSelectContext);
|
|
30
31
|
React.useEffect(
|
|
31
32
|
function updateContext() {
|
|
@@ -35,20 +36,13 @@ const HtmlSelect = forwardRef(
|
|
|
35
36
|
);
|
|
36
37
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
37
38
|
/* @__PURE__ */ jsx(
|
|
38
|
-
|
|
39
|
+
Role.select,
|
|
39
40
|
{
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
...rest,
|
|
46
|
-
className: cx("\u{1F95D}-button", "\u{1F95D}-select", props.className),
|
|
47
|
-
"data-kiwi-tone": "neutral",
|
|
48
|
-
"data-kiwi-variant": variant,
|
|
49
|
-
ref: forwardedRef
|
|
50
|
-
}
|
|
51
|
-
)
|
|
41
|
+
...rest,
|
|
42
|
+
className: cx("\u{1F95D}-button", "\u{1F95D}-select", props.className),
|
|
43
|
+
"data-kiwi-tone": "neutral",
|
|
44
|
+
"data-kiwi-variant": variant,
|
|
45
|
+
ref: forwardedRef
|
|
52
46
|
}
|
|
53
47
|
),
|
|
54
48
|
/* @__PURE__ */ jsx(DisclosureArrow, { className: "\u{1F95D}-select-arrow" })
|
|
@@ -3,26 +3,19 @@ import cx from "classnames";
|
|
|
3
3
|
import {
|
|
4
4
|
Checkbox as AkCheckbox
|
|
5
5
|
} from "@ariakit/react/checkbox";
|
|
6
|
-
import { FieldControl } from "./Field.js";
|
|
7
6
|
import { forwardRef } from "./~utils.js";
|
|
7
|
+
import { useFieldControlType } from "./Field.internal.js";
|
|
8
8
|
const Switch = forwardRef(
|
|
9
9
|
(props, forwardedRef) => {
|
|
10
|
-
|
|
10
|
+
useFieldControlType("checkable");
|
|
11
11
|
return /* @__PURE__ */ jsx(
|
|
12
|
-
|
|
12
|
+
AkCheckbox,
|
|
13
13
|
{
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
accessibleWhenDisabled: true,
|
|
20
|
-
...rest,
|
|
21
|
-
className: cx("\u{1F95D}-switch", props.className),
|
|
22
|
-
role: "switch",
|
|
23
|
-
ref: forwardedRef
|
|
24
|
-
}
|
|
25
|
-
)
|
|
14
|
+
accessibleWhenDisabled: true,
|
|
15
|
+
...props,
|
|
16
|
+
className: cx("\u{1F95D}-switch", props.className),
|
|
17
|
+
role: "switch",
|
|
18
|
+
ref: forwardedRef
|
|
26
19
|
}
|
|
27
20
|
);
|
|
28
21
|
}
|
package/dist/DEV/bricks/Table.js
CHANGED
|
@@ -3,65 +3,90 @@ import { Role } from "@ariakit/react/role";
|
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import cx from "classnames";
|
|
5
5
|
import { forwardRef } from "./~utils.js";
|
|
6
|
-
import { useMergedRefs } from "./~hooks.js";
|
|
7
|
-
const TableContext = React.createContext(
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return /* @__PURE__ */ jsx(TableContext.Provider, { value:
|
|
6
|
+
import { useMergedRefs, useSafeContext } from "./~hooks.js";
|
|
7
|
+
const TableContext = React.createContext(void 0);
|
|
8
|
+
const TableHeaderContext = React.createContext(false);
|
|
9
|
+
const HtmlTable = forwardRef((props, forwardedRef) => {
|
|
10
|
+
const tableContextValue = React.useMemo(
|
|
11
|
+
() => ({ mode: "html" }),
|
|
12
|
+
[]
|
|
13
|
+
);
|
|
14
|
+
return /* @__PURE__ */ jsx(TableContext.Provider, { value: tableContextValue, children: /* @__PURE__ */ jsx(
|
|
15
15
|
Role,
|
|
16
16
|
{
|
|
17
|
+
render: /* @__PURE__ */ jsx("table", {}),
|
|
17
18
|
...props,
|
|
18
|
-
className: cx("\u{1F95D}-table", props.className),
|
|
19
19
|
ref: forwardedRef,
|
|
20
|
-
|
|
21
|
-
"aria-labelledby": captionId,
|
|
22
|
-
children: props.children
|
|
20
|
+
className: cx("\u{1F95D}-table", props.className)
|
|
23
21
|
}
|
|
24
22
|
) });
|
|
25
23
|
});
|
|
26
|
-
DEV:
|
|
27
|
-
const
|
|
24
|
+
DEV: HtmlTable.displayName = "Table.HtmlTable";
|
|
25
|
+
const CustomTable = forwardRef(
|
|
26
|
+
(props, forwardedRef) => {
|
|
27
|
+
const [captionId, setCaptionId] = React.useState();
|
|
28
|
+
const tableContextValue = React.useMemo(
|
|
29
|
+
() => ({ captionId, setCaptionId, mode: "aria" }),
|
|
30
|
+
[captionId]
|
|
31
|
+
);
|
|
32
|
+
return /* @__PURE__ */ jsx(TableContext.Provider, { value: tableContextValue, children: /* @__PURE__ */ jsx(
|
|
33
|
+
Role.div,
|
|
34
|
+
{
|
|
35
|
+
role: "table",
|
|
36
|
+
"aria-labelledby": captionId,
|
|
37
|
+
...props,
|
|
38
|
+
ref: forwardedRef,
|
|
39
|
+
className: cx("\u{1F95D}-table", props.className)
|
|
40
|
+
}
|
|
41
|
+
) });
|
|
42
|
+
}
|
|
43
|
+
);
|
|
44
|
+
DEV: CustomTable.displayName = "Table.CustomTable";
|
|
28
45
|
const TableHeader = forwardRef(
|
|
29
46
|
(props, forwardedRef) => {
|
|
47
|
+
const { mode } = useSafeContext(TableContext);
|
|
48
|
+
const render = mode === "html" ? /* @__PURE__ */ jsx("thead", {}) : void 0;
|
|
49
|
+
const role = mode === "aria" ? "rowgroup" : void 0;
|
|
30
50
|
return /* @__PURE__ */ jsx(TableHeaderContext.Provider, { value: true, children: /* @__PURE__ */ jsx(
|
|
31
51
|
Role.div,
|
|
32
52
|
{
|
|
53
|
+
render,
|
|
54
|
+
role,
|
|
33
55
|
...props,
|
|
34
|
-
className: cx("\u{1F95D}-table-header", props.className),
|
|
35
56
|
ref: forwardedRef,
|
|
36
|
-
|
|
37
|
-
children: props.children
|
|
57
|
+
className: cx("\u{1F95D}-table-header", props.className)
|
|
38
58
|
}
|
|
39
59
|
) });
|
|
40
60
|
}
|
|
41
61
|
);
|
|
42
62
|
DEV: TableHeader.displayName = "Table.Header";
|
|
43
63
|
const TableBody = forwardRef((props, forwardedRef) => {
|
|
64
|
+
const { mode } = useSafeContext(TableContext);
|
|
65
|
+
const render = mode === "html" ? /* @__PURE__ */ jsx("tbody", {}) : void 0;
|
|
44
66
|
return /* @__PURE__ */ jsx(
|
|
45
67
|
Role.div,
|
|
46
68
|
{
|
|
69
|
+
render,
|
|
70
|
+
role: void 0,
|
|
47
71
|
...props,
|
|
48
|
-
className: cx("\u{1F95D}-table-body", props.className),
|
|
49
72
|
ref: forwardedRef,
|
|
50
|
-
|
|
73
|
+
className: cx("\u{1F95D}-table-body", props.className)
|
|
51
74
|
}
|
|
52
75
|
);
|
|
53
76
|
});
|
|
54
77
|
DEV: TableBody.displayName = "Table.Body";
|
|
55
78
|
const TableRow = forwardRef((props, forwardedRef) => {
|
|
56
|
-
const {
|
|
79
|
+
const { mode } = useSafeContext(TableContext);
|
|
80
|
+
const render = mode === "html" ? /* @__PURE__ */ jsx("tr", {}) : void 0;
|
|
81
|
+
const role = mode === "aria" ? "row" : void 0;
|
|
57
82
|
return /* @__PURE__ */ jsx(
|
|
58
83
|
Role.div,
|
|
59
84
|
{
|
|
60
|
-
|
|
61
|
-
|
|
85
|
+
render,
|
|
86
|
+
role,
|
|
87
|
+
...props,
|
|
62
88
|
ref: forwardedRef,
|
|
63
|
-
|
|
64
|
-
children
|
|
89
|
+
className: cx("\u{1F95D}-table-row", props.className)
|
|
65
90
|
}
|
|
66
91
|
);
|
|
67
92
|
});
|
|
@@ -69,37 +94,45 @@ DEV: TableRow.displayName = "Table.Row";
|
|
|
69
94
|
const TableCaption = forwardRef(
|
|
70
95
|
(props, forwardedRef) => {
|
|
71
96
|
const fallbackId = React.useId();
|
|
72
|
-
const { id = fallbackId,
|
|
73
|
-
const { setCaptionId } =
|
|
97
|
+
const { id = fallbackId, ...rest } = props;
|
|
98
|
+
const { mode, setCaptionId } = useSafeContext(TableContext);
|
|
99
|
+
const render = mode === "html" ? /* @__PURE__ */ jsx("caption", {}) : void 0;
|
|
74
100
|
const captionIdRef = React.useCallback(
|
|
75
101
|
(element) => {
|
|
76
|
-
setCaptionId(element ? id : void 0);
|
|
102
|
+
setCaptionId?.(element ? id : void 0);
|
|
77
103
|
},
|
|
78
104
|
[id, setCaptionId]
|
|
79
105
|
);
|
|
80
106
|
return /* @__PURE__ */ jsx(
|
|
81
|
-
Role,
|
|
107
|
+
Role.div,
|
|
82
108
|
{
|
|
109
|
+
render,
|
|
83
110
|
...rest,
|
|
84
111
|
id,
|
|
85
|
-
className: cx("\u{1F95D}-table-caption", props.className),
|
|
86
112
|
ref: useMergedRefs(forwardedRef, captionIdRef),
|
|
87
|
-
|
|
113
|
+
className: cx("\u{1F95D}-table-caption", props.className)
|
|
88
114
|
}
|
|
89
115
|
);
|
|
90
116
|
}
|
|
91
117
|
);
|
|
92
118
|
DEV: TableCaption.displayName = "Table.Caption";
|
|
93
119
|
const TableCell = forwardRef((props, forwardedRef) => {
|
|
94
|
-
const isWithinTableHeader =
|
|
120
|
+
const isWithinTableHeader = useSafeContext(TableHeaderContext);
|
|
121
|
+
const { mode } = useSafeContext(TableContext);
|
|
122
|
+
const { render, role } = React.useMemo(() => {
|
|
123
|
+
if (mode === "aria") {
|
|
124
|
+
return { role: isWithinTableHeader ? "columnheader" : "cell" };
|
|
125
|
+
}
|
|
126
|
+
return { render: isWithinTableHeader ? /* @__PURE__ */ jsx("th", {}) : /* @__PURE__ */ jsx("td", {}) };
|
|
127
|
+
}, [isWithinTableHeader, mode]);
|
|
95
128
|
return /* @__PURE__ */ jsx(
|
|
96
|
-
Role.
|
|
129
|
+
Role.div,
|
|
97
130
|
{
|
|
131
|
+
render,
|
|
132
|
+
role,
|
|
98
133
|
...props,
|
|
99
|
-
className: cx("\u{1F95D}-table-cell", props.className),
|
|
100
134
|
ref: forwardedRef,
|
|
101
|
-
|
|
102
|
-
children: props.children
|
|
135
|
+
className: cx("\u{1F95D}-table-cell", props.className)
|
|
103
136
|
}
|
|
104
137
|
);
|
|
105
138
|
});
|
|
@@ -108,7 +141,8 @@ export {
|
|
|
108
141
|
TableBody as Body,
|
|
109
142
|
TableCaption as Caption,
|
|
110
143
|
TableCell as Cell,
|
|
144
|
+
CustomTable,
|
|
111
145
|
TableHeader as Header,
|
|
112
|
-
|
|
146
|
+
HtmlTable,
|
|
113
147
|
TableRow as Row
|
|
114
148
|
};
|