@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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 5.0.0-alpha.12
|
|
4
|
+
|
|
5
|
+
- **breaking**: Introduce composition API for `Field`. See [#449](https://github.com/iTwin/design-system/pull/449).
|
|
6
|
+
- Includes `<Field.Root>`, `<Field.Label>`, `<Field.Control>`, `<Field.Description>`.
|
|
7
|
+
- Added a new `<Field.ErrorMessage>` subcomponent.
|
|
8
|
+
- `Tree.Item`: Added automatic overflow handling for `actions`.
|
|
9
|
+
- **breaking**: `DropdownMenu` is no longer allowed to be passed into `actions`. See [#404](https://github.com/iTwin/design-system/pull/404).
|
|
10
|
+
- Added a new `Table` component, usable as `<Table.HtmlTable>` or `<Table.CustomTable>`.
|
|
11
|
+
- `DropdownMenu`: menuitems will now be rendered as `<button>`.
|
|
12
|
+
- Styling changes:
|
|
13
|
+
- Reset `<button>` styles.
|
|
14
|
+
- Added popover-open state styles to `<Button>` and `<IconButton>`.
|
|
15
|
+
- Improved forced-colors mode styling for `<Checkbox>`, `<Radio>` and `<Switch>`.
|
|
16
|
+
- Bug fixes:
|
|
17
|
+
- Fixed `<Select.HtmlSelect>` overflowing beyond its container.
|
|
18
|
+
- Fixed `<Select.HtmlSelect>` options text not appearing in Windows in certain cases.
|
|
19
|
+
- Added missing `border-radius` to `<Skeleton>`.
|
|
20
|
+
|
|
3
21
|
## 5.0.0-alpha.11
|
|
4
22
|
|
|
5
23
|
- Added `error` prop to `<Tree.Item>`.
|
package/README.md
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
# @itwin/itwinui-react
|
|
2
2
|
|
|
3
|
-
A React component library for the next evolution of the iTwinUI design system.
|
|
3
|
+
A React component library for the [next evolution of the iTwinUI design system](https://github.com/iTwin/design-system/discussions/481).
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Using your package manager of choice, install the latest **alpha** version of [`@itwin/itwinui-react`](https://www.npmjs.com/package/@itwin/itwinui-react?activeTab=versions).
|
|
8
|
+
|
|
9
|
+
```console
|
|
10
|
+
npm add @itwin/itwinui-react@alpha
|
|
11
|
+
```
|
|
4
12
|
|
|
5
13
|
## Usage
|
|
6
14
|
|
|
@@ -20,7 +28,10 @@ export function App() {
|
|
|
20
28
|
|
|
21
29
|
This will ensure iTwinUI's styles are loaded to either the document or the encompassing shadow root.
|
|
22
30
|
|
|
23
|
-
Once that’s in place you can import and use components from `@itwin/itwinui-react/bricks`.
|
|
31
|
+
Once that’s in place, you can import and use components from `@itwin/itwinui-react/bricks`.
|
|
32
|
+
|
|
33
|
+
> [!NOTE]
|
|
34
|
+
> If you are trying to use this package alongside the current stable version of iTwinUI, you will need to set up the [iTwinUI theme bridge](https://github.com/iTwin/iTwinUI/wiki/iTwinUI-v5-theme-bridge).
|
|
24
35
|
|
|
25
36
|
## Contributing
|
|
26
37
|
|
|
@@ -3,25 +3,18 @@ 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 Checkbox = 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}-checkbox", props.className),
|
|
22
|
-
ref: forwardedRef
|
|
23
|
-
}
|
|
24
|
-
)
|
|
14
|
+
accessibleWhenDisabled: true,
|
|
15
|
+
...props,
|
|
16
|
+
className: cx("\u{1F95D}-checkbox", props.className),
|
|
17
|
+
ref: forwardedRef
|
|
25
18
|
}
|
|
26
19
|
);
|
|
27
20
|
}
|
|
@@ -2,24 +2,17 @@ import { jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { forwardRef } from "./~utils.js";
|
|
3
3
|
import cx from "classnames";
|
|
4
4
|
import { Text } from "./Text.js";
|
|
5
|
-
import { FieldDescription } from "./Field.js";
|
|
6
5
|
const Description = forwardRef(
|
|
7
6
|
(props, forwardedRef) => {
|
|
8
|
-
const {
|
|
7
|
+
const { tone, ...rest } = props;
|
|
9
8
|
return /* @__PURE__ */ jsx(
|
|
10
|
-
|
|
9
|
+
Text,
|
|
11
10
|
{
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
variant: "caption-md",
|
|
18
|
-
"data-kiwi-tone": tone ?? "neutral",
|
|
19
|
-
className: cx("\u{1F95D}-description", props.className),
|
|
20
|
-
ref: forwardedRef
|
|
21
|
-
}
|
|
22
|
-
)
|
|
11
|
+
...rest,
|
|
12
|
+
variant: "caption-md",
|
|
13
|
+
"data-kiwi-tone": tone ?? "neutral",
|
|
14
|
+
className: cx("\u{1F95D}-description", props.className),
|
|
15
|
+
ref: forwardedRef
|
|
23
16
|
}
|
|
24
17
|
);
|
|
25
18
|
}
|
|
@@ -3,6 +3,7 @@ import * as React from "react";
|
|
|
3
3
|
import cx from "classnames";
|
|
4
4
|
import * as ListItem from "./~utils.ListItem.js";
|
|
5
5
|
import { Button } from "./Button.js";
|
|
6
|
+
import { Button as ButtonAk } from "@ariakit/react/button";
|
|
6
7
|
import { Kbd } from "./Kbd.js";
|
|
7
8
|
import { Checkmark, DisclosureArrow, Icon } from "./Icon.js";
|
|
8
9
|
import {
|
|
@@ -19,7 +20,8 @@ import {
|
|
|
19
20
|
} from "@ariakit/react/menu";
|
|
20
21
|
import { useStoreState } from "@ariakit/react/store";
|
|
21
22
|
import { predefinedSymbols } from "./Kbd.internal.js";
|
|
22
|
-
|
|
23
|
+
import { usePopoverContext } from "@ariakit/react/popover";
|
|
24
|
+
function DropdownMenuRoot(props) {
|
|
23
25
|
const {
|
|
24
26
|
children,
|
|
25
27
|
placement,
|
|
@@ -34,11 +36,12 @@ function DropdownMenu(props) {
|
|
|
34
36
|
defaultOpen: defaultOpenProp,
|
|
35
37
|
open: openProp,
|
|
36
38
|
setOpen: setOpenProp,
|
|
39
|
+
popover: usePopoverContext(),
|
|
37
40
|
children
|
|
38
41
|
}
|
|
39
42
|
);
|
|
40
43
|
}
|
|
41
|
-
DEV:
|
|
44
|
+
DEV: DropdownMenuRoot.displayName = "DropdownMenu.Root";
|
|
42
45
|
const DropdownMenuContent = forwardRef(
|
|
43
46
|
(props, forwardedRef) => {
|
|
44
47
|
const popover = usePopoverApi(useMenuContext());
|
|
@@ -86,13 +89,23 @@ const DropdownMenuItem = forwardRef(
|
|
|
86
89
|
MenuItem,
|
|
87
90
|
{
|
|
88
91
|
accessibleWhenDisabled: true,
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
92
|
+
render: /* @__PURE__ */ jsx(
|
|
93
|
+
ListItem.Root,
|
|
94
|
+
{
|
|
95
|
+
render: /* @__PURE__ */ jsx(
|
|
96
|
+
ButtonAk,
|
|
97
|
+
{
|
|
98
|
+
accessibleWhenDisabled: true,
|
|
99
|
+
...rest,
|
|
100
|
+
className: cx("\u{1F95D}-dropdown-menu-item", props.className),
|
|
101
|
+
ref: forwardedRef
|
|
102
|
+
}
|
|
103
|
+
)
|
|
104
|
+
}
|
|
105
|
+
),
|
|
93
106
|
children: [
|
|
94
107
|
icon ? /* @__PURE__ */ jsx(DropdownMenuIcon, { icon }) : null,
|
|
95
|
-
/* @__PURE__ */ jsx(ListItem.Content, { children: label }),
|
|
108
|
+
/* @__PURE__ */ jsx(ListItem.Content, { render: /* @__PURE__ */ jsx("span", {}), children: label }),
|
|
96
109
|
shortcuts ? /* @__PURE__ */ jsx(DropdownMenuItemShortcuts, { shortcuts }) : null
|
|
97
110
|
]
|
|
98
111
|
}
|
|
@@ -111,6 +124,7 @@ const DropdownMenuItemShortcuts = forwardRef((props, forwardedRef) => {
|
|
|
111
124
|
return /* @__PURE__ */ jsx(
|
|
112
125
|
ListItem.Decoration,
|
|
113
126
|
{
|
|
127
|
+
render: /* @__PURE__ */ jsx("span", {}),
|
|
114
128
|
...rest,
|
|
115
129
|
className: cx("\u{1F95D}-dropdown-menu-item-shortcuts", props.className),
|
|
116
130
|
ref: forwardedRef,
|
|
@@ -141,30 +155,54 @@ const DropdownMenuIcon = forwardRef(
|
|
|
141
155
|
Icon,
|
|
142
156
|
{
|
|
143
157
|
href: typeof icon === "string" ? icon : void 0,
|
|
144
|
-
render: React.isValidElement(icon) ? icon : void 0
|
|
158
|
+
render: React.isValidElement(icon) ? icon : void 0,
|
|
159
|
+
...rest,
|
|
160
|
+
ref: forwardedRef
|
|
145
161
|
}
|
|
146
|
-
)
|
|
147
|
-
...rest,
|
|
148
|
-
ref: forwardedRef
|
|
162
|
+
)
|
|
149
163
|
}
|
|
150
164
|
);
|
|
151
165
|
}
|
|
152
166
|
);
|
|
153
167
|
DEV: DropdownMenuIcon.displayName = "DropdownMenuIcon";
|
|
154
168
|
const DropdownMenuCheckboxItem = forwardRef((props, forwardedRef) => {
|
|
155
|
-
const {
|
|
169
|
+
const {
|
|
170
|
+
label,
|
|
171
|
+
icon,
|
|
172
|
+
defaultChecked,
|
|
173
|
+
checked,
|
|
174
|
+
onChange,
|
|
175
|
+
name,
|
|
176
|
+
value = defaultChecked ? "on" : void 0,
|
|
177
|
+
// For defaultChecked to work
|
|
178
|
+
...rest
|
|
179
|
+
} = props;
|
|
156
180
|
return /* @__PURE__ */ jsxs(
|
|
157
181
|
MenuItemCheckbox,
|
|
158
182
|
{
|
|
159
183
|
accessibleWhenDisabled: true,
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
184
|
+
defaultChecked,
|
|
185
|
+
checked,
|
|
186
|
+
name,
|
|
187
|
+
value,
|
|
188
|
+
onChange,
|
|
189
|
+
render: /* @__PURE__ */ jsx(
|
|
190
|
+
ListItem.Root,
|
|
191
|
+
{
|
|
192
|
+
render: /* @__PURE__ */ jsx(
|
|
193
|
+
ButtonAk,
|
|
194
|
+
{
|
|
195
|
+
accessibleWhenDisabled: true,
|
|
196
|
+
...rest,
|
|
197
|
+
className: cx("\u{1F95D}-dropdown-menu-item", props.className),
|
|
198
|
+
ref: forwardedRef
|
|
199
|
+
}
|
|
200
|
+
)
|
|
201
|
+
}
|
|
202
|
+
),
|
|
165
203
|
children: [
|
|
166
204
|
icon ? /* @__PURE__ */ jsx(DropdownMenuIcon, { icon }) : null,
|
|
167
|
-
/* @__PURE__ */ jsx(ListItem.Content, { children: label }),
|
|
205
|
+
/* @__PURE__ */ jsx(ListItem.Content, { render: /* @__PURE__ */ jsx("span", {}), children: label }),
|
|
168
206
|
/* @__PURE__ */ jsx(
|
|
169
207
|
ListItem.Decoration,
|
|
170
208
|
{
|
|
@@ -181,5 +219,5 @@ export {
|
|
|
181
219
|
DropdownMenuCheckboxItem as CheckboxItem,
|
|
182
220
|
DropdownMenuContent as Content,
|
|
183
221
|
DropdownMenuItem as Item,
|
|
184
|
-
|
|
222
|
+
DropdownMenuRoot as Root
|
|
185
223
|
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import {
|
|
4
|
+
useCollectionStore,
|
|
5
|
+
Collection
|
|
6
|
+
} from "@ariakit/react/collection";
|
|
7
|
+
import { useStoreState } from "@ariakit/react/store";
|
|
8
|
+
function FieldCollection(props) {
|
|
9
|
+
const fieldElementCollection = useCollectionStore({
|
|
10
|
+
defaultItems: []
|
|
11
|
+
});
|
|
12
|
+
const renderedItems = useStoreState(fieldElementCollection, "renderedItems");
|
|
13
|
+
const [controlType, controlIndex] = React.useMemo(() => {
|
|
14
|
+
const controlIndex2 = renderedItems.findIndex(
|
|
15
|
+
(item) => item.elementType === "control"
|
|
16
|
+
);
|
|
17
|
+
return [renderedItems[controlIndex2]?.controlType, controlIndex2];
|
|
18
|
+
}, [renderedItems]);
|
|
19
|
+
const labelPlacement = React.useMemo(() => {
|
|
20
|
+
const labelIndex = renderedItems.findIndex(
|
|
21
|
+
(item) => item.elementType === "label"
|
|
22
|
+
);
|
|
23
|
+
if (controlIndex === -1 || labelIndex === -1) return;
|
|
24
|
+
return labelIndex < controlIndex ? "before" : "after";
|
|
25
|
+
}, [renderedItems, controlIndex]);
|
|
26
|
+
return /* @__PURE__ */ jsx(
|
|
27
|
+
Collection,
|
|
28
|
+
{
|
|
29
|
+
...props,
|
|
30
|
+
store: fieldElementCollection,
|
|
31
|
+
"data-kiwi-label-placement": labelPlacement,
|
|
32
|
+
"data-kiwi-control-type": controlType
|
|
33
|
+
}
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
const FieldControlTypeContext = React.createContext(void 0);
|
|
37
|
+
function useFieldControlType(controlType) {
|
|
38
|
+
const setControlType = React.useContext(FieldControlTypeContext);
|
|
39
|
+
React.useEffect(() => {
|
|
40
|
+
setControlType?.(controlType);
|
|
41
|
+
}, [controlType, setControlType]);
|
|
42
|
+
}
|
|
43
|
+
export {
|
|
44
|
+
FieldCollection,
|
|
45
|
+
FieldControlTypeContext,
|
|
46
|
+
useFieldControlType
|
|
47
|
+
};
|
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,42 @@ const Field = forwardRef((props, forwardedRef) => {
|
|
|
27
31
|
}
|
|
28
32
|
);
|
|
29
33
|
});
|
|
30
|
-
DEV:
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
DEV: FieldRoot.displayName = "Field";
|
|
35
|
+
const FieldLabel = forwardRef(
|
|
36
|
+
(props, forwardedRef) => {
|
|
37
|
+
const store = useCollectionContext();
|
|
38
|
+
const renderedItems = useStoreState(store, "renderedItems");
|
|
39
|
+
const fieldId = React.useMemo(
|
|
40
|
+
() => renderedItems?.find(
|
|
41
|
+
(item) => item.elementType === "control"
|
|
42
|
+
)?.id,
|
|
43
|
+
[renderedItems]
|
|
39
44
|
);
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
+
const getData = React.useCallback(
|
|
46
|
+
(data) => ({
|
|
47
|
+
...data,
|
|
48
|
+
elementType: "label"
|
|
49
|
+
}),
|
|
50
|
+
[]
|
|
45
51
|
);
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
function FieldControl(props) {
|
|
60
|
-
const store = useCollectionContext();
|
|
52
|
+
return /* @__PURE__ */ jsx(
|
|
53
|
+
CollectionItem,
|
|
54
|
+
{
|
|
55
|
+
getItem: getData,
|
|
56
|
+
render: /* @__PURE__ */ jsx(Label, { ...props, htmlFor: fieldId }),
|
|
57
|
+
ref: forwardedRef
|
|
58
|
+
}
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
);
|
|
62
|
+
DEV: FieldLabel.displayName = "Field.Label";
|
|
63
|
+
const FieldDescription = forwardRef((props, forwardedRef) => {
|
|
61
64
|
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
|
-
);
|
|
65
|
+
const { id = generatedId, ...rest } = props;
|
|
96
66
|
const getData = React.useCallback(
|
|
97
67
|
(data) => ({
|
|
98
68
|
...data,
|
|
99
|
-
elementType: "
|
|
69
|
+
elementType: "description"
|
|
100
70
|
}),
|
|
101
71
|
[]
|
|
102
72
|
);
|
|
@@ -104,25 +74,86 @@ function FieldLabel(props) {
|
|
|
104
74
|
CollectionItem,
|
|
105
75
|
{
|
|
106
76
|
getItem: getData,
|
|
107
|
-
|
|
77
|
+
id,
|
|
78
|
+
render: /* @__PURE__ */ jsx(Description, { ...rest }),
|
|
79
|
+
ref: forwardedRef
|
|
108
80
|
}
|
|
109
81
|
);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
82
|
+
});
|
|
83
|
+
DEV: FieldDescription.displayName = "Field.Description";
|
|
84
|
+
const FieldControl = forwardRef(
|
|
85
|
+
(props, forwardedRef) => {
|
|
86
|
+
const [controlType, setControlType] = React.useState();
|
|
87
|
+
const store = useCollectionContext();
|
|
88
|
+
const generatedId = React.useId();
|
|
89
|
+
const { id = store ? generatedId : void 0, ...rest } = props;
|
|
90
|
+
const renderedItems = useStoreState(store, "renderedItems");
|
|
91
|
+
const describedBy = React.useMemo(() => {
|
|
92
|
+
const idRefList = renderedItems?.filter(
|
|
93
|
+
(item) => item.elementType === "description" || item.elementType === "error"
|
|
94
|
+
)?.map((item) => item.id).join(" ");
|
|
95
|
+
return idRefList || void 0;
|
|
96
|
+
}, [renderedItems]);
|
|
97
|
+
const getData = React.useCallback(
|
|
98
|
+
(data) => ({
|
|
99
|
+
...data,
|
|
100
|
+
elementType: "control",
|
|
101
|
+
controlType
|
|
102
|
+
}),
|
|
103
|
+
[controlType]
|
|
104
|
+
);
|
|
105
|
+
const invalid = React.useMemo(
|
|
106
|
+
() => renderedItems?.some(
|
|
107
|
+
(item) => item.elementType === "error"
|
|
108
|
+
),
|
|
109
|
+
[renderedItems]
|
|
110
|
+
);
|
|
111
|
+
return /* @__PURE__ */ jsx(FieldControlTypeContext.Provider, { value: setControlType, children: /* @__PURE__ */ jsx(
|
|
112
|
+
CollectionItem,
|
|
113
|
+
{
|
|
114
|
+
id,
|
|
115
|
+
getItem: getData,
|
|
116
|
+
render: /* @__PURE__ */ jsx(
|
|
117
|
+
Role,
|
|
118
|
+
{
|
|
119
|
+
...rest,
|
|
120
|
+
"aria-invalid": invalid ? "true" : void 0,
|
|
121
|
+
"aria-describedby": describedBy
|
|
122
|
+
}
|
|
123
|
+
),
|
|
124
|
+
ref: forwardedRef
|
|
125
|
+
}
|
|
126
|
+
) });
|
|
127
|
+
}
|
|
128
|
+
);
|
|
129
|
+
DEV: FieldControl.displayName = "Field.Control";
|
|
130
|
+
const FieldErrorMessage = forwardRef(
|
|
131
|
+
(props, forwardedRef) => {
|
|
132
|
+
const generatedId = React.useId();
|
|
133
|
+
const { id = generatedId, ...rest } = props;
|
|
134
|
+
const getData = React.useCallback(
|
|
135
|
+
(data) => ({
|
|
136
|
+
...data,
|
|
137
|
+
elementType: "error"
|
|
138
|
+
}),
|
|
139
|
+
[]
|
|
140
|
+
);
|
|
141
|
+
return /* @__PURE__ */ jsx(
|
|
142
|
+
CollectionItem,
|
|
143
|
+
{
|
|
144
|
+
id,
|
|
145
|
+
getItem: getData,
|
|
146
|
+
render: /* @__PURE__ */ jsx(Description, { ...rest, tone: "critical" }),
|
|
147
|
+
ref: forwardedRef
|
|
148
|
+
}
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
);
|
|
152
|
+
DEV: FieldErrorMessage.displayName = "Field.ErrorMessage";
|
|
123
153
|
export {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
FieldLabel
|
|
154
|
+
FieldControl as Control,
|
|
155
|
+
FieldDescription as Description,
|
|
156
|
+
FieldErrorMessage as ErrorMessage,
|
|
157
|
+
FieldLabel as Label,
|
|
158
|
+
FieldRoot as Root
|
|
128
159
|
};
|
package/dist/DEV/bricks/Icon.js
CHANGED
|
@@ -220,10 +220,42 @@ 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";
|
|
223
254
|
export {
|
|
224
255
|
Checkmark,
|
|
225
256
|
DisclosureArrow,
|
|
226
257
|
Dismiss,
|
|
227
258
|
Icon,
|
|
259
|
+
MoreHorizontal,
|
|
228
260
|
StatusWarning
|
|
229
261
|
};
|
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
|
});
|