@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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 5.0.0-alpha.13
|
|
4
|
+
|
|
5
|
+
- Added new `unstable_ErrorRegion` component for displaying errors originating from `Tree`. See [#454](https://github.com/iTwin/design-system/pull/454).
|
|
6
|
+
- Added initial `unstable_Toolbar` component. See [#529](https://github.com/iTwin/design-system/pull/529).
|
|
7
|
+
- Added `dot` prop to `<Tree.ItemAction>`, matching the `dot` prop from `<IconButton>`.
|
|
8
|
+
- Also added `unstable_dot` prop to `<DropdownMenu.Item>`, although it's not meant to be used currently.
|
|
9
|
+
- Styling changes:
|
|
10
|
+
- Improved forced-colors mode styling for `<Icon>`, `<Button>` as anchor, and `<Tree.Item>`.
|
|
11
|
+
- Updated the color of `dot` used in `<IconButton>`.
|
|
12
|
+
|
|
13
|
+
## 5.0.0-alpha.12
|
|
14
|
+
|
|
15
|
+
- **breaking**: Introduce composition API for `Field`. See [#449](https://github.com/iTwin/design-system/pull/449).
|
|
16
|
+
- Includes `<Field.Root>`, `<Field.Label>`, `<Field.Control>`, `<Field.Description>`.
|
|
17
|
+
- Added a new `<Field.ErrorMessage>` subcomponent.
|
|
18
|
+
- `Tree.Item`: Added automatic overflow handling for `actions`.
|
|
19
|
+
- **breaking**: `DropdownMenu` is no longer allowed to be passed into `actions`. See [#404](https://github.com/iTwin/design-system/pull/404).
|
|
20
|
+
- Added a new `Table` component, usable as `<Table.HtmlTable>` or `<Table.CustomTable>`.
|
|
21
|
+
- `DropdownMenu`: menuitems will now be rendered as `<button>`.
|
|
22
|
+
- Styling changes:
|
|
23
|
+
- Reset `<button>` styles.
|
|
24
|
+
- Added popover-open state styles to `<Button>` and `<IconButton>`.
|
|
25
|
+
- Improved forced-colors mode styling for `<Checkbox>`, `<Radio>` and `<Switch>`.
|
|
26
|
+
- Bug fixes:
|
|
27
|
+
- Fixed `<Select.HtmlSelect>` overflowing beyond its container.
|
|
28
|
+
- Fixed `<Select.HtmlSelect>` options text not appearing in Windows in certain cases.
|
|
29
|
+
- Added missing `border-radius` to `<Skeleton>`.
|
|
30
|
+
|
|
3
31
|
## 5.0.0-alpha.11
|
|
4
32
|
|
|
5
33
|
- 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,9 @@ 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
|
+
import { Dot } from "./~utils.Dot.js";
|
|
25
|
+
function DropdownMenuRoot(props) {
|
|
23
26
|
const {
|
|
24
27
|
children,
|
|
25
28
|
placement,
|
|
@@ -34,11 +37,12 @@ function DropdownMenu(props) {
|
|
|
34
37
|
defaultOpen: defaultOpenProp,
|
|
35
38
|
open: openProp,
|
|
36
39
|
setOpen: setOpenProp,
|
|
40
|
+
popover: usePopoverContext(),
|
|
37
41
|
children
|
|
38
42
|
}
|
|
39
43
|
);
|
|
40
44
|
}
|
|
41
|
-
DEV:
|
|
45
|
+
DEV: DropdownMenuRoot.displayName = "DropdownMenu.Root";
|
|
42
46
|
const DropdownMenuContent = forwardRef(
|
|
43
47
|
(props, forwardedRef) => {
|
|
44
48
|
const popover = usePopoverApi(useMenuContext());
|
|
@@ -81,19 +85,37 @@ const DropdownMenuButton = forwardRef(
|
|
|
81
85
|
DEV: DropdownMenuButton.displayName = "DropdownMenu.Button";
|
|
82
86
|
const DropdownMenuItem = forwardRef(
|
|
83
87
|
(props, forwardedRef) => {
|
|
84
|
-
const { label, shortcuts, icon, ...rest } = props;
|
|
88
|
+
const { label, shortcuts, icon, unstable_dot, ...rest } = props;
|
|
89
|
+
const dotId = React.useId();
|
|
85
90
|
return /* @__PURE__ */ jsxs(
|
|
86
91
|
MenuItem,
|
|
87
92
|
{
|
|
88
93
|
accessibleWhenDisabled: true,
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
94
|
+
render: /* @__PURE__ */ jsx(
|
|
95
|
+
ListItem.Root,
|
|
96
|
+
{
|
|
97
|
+
render: /* @__PURE__ */ jsx(
|
|
98
|
+
ButtonAk,
|
|
99
|
+
{
|
|
100
|
+
accessibleWhenDisabled: true,
|
|
101
|
+
"aria-describedby": dotId,
|
|
102
|
+
...rest,
|
|
103
|
+
className: cx("\u{1F95D}-dropdown-menu-item", props.className),
|
|
104
|
+
ref: forwardedRef
|
|
105
|
+
}
|
|
106
|
+
)
|
|
107
|
+
}
|
|
108
|
+
),
|
|
93
109
|
children: [
|
|
94
110
|
icon ? /* @__PURE__ */ jsx(DropdownMenuIcon, { icon }) : null,
|
|
95
|
-
/* @__PURE__ */ jsx(ListItem.Content, { children: label }),
|
|
96
|
-
shortcuts ? /* @__PURE__ */ jsx(DropdownMenuItemShortcuts, { shortcuts }) : null
|
|
111
|
+
/* @__PURE__ */ jsx(ListItem.Content, { render: /* @__PURE__ */ jsx("span", {}), children: label }),
|
|
112
|
+
shortcuts ? /* @__PURE__ */ jsx(DropdownMenuItemShortcuts, { shortcuts }) : null,
|
|
113
|
+
unstable_dot ? /* @__PURE__ */ jsx(
|
|
114
|
+
ListItem.Decoration,
|
|
115
|
+
{
|
|
116
|
+
render: /* @__PURE__ */ jsx(Dot, { id: dotId, className: "\u{1F95D}-dropdown-menu-item-dot", children: unstable_dot })
|
|
117
|
+
}
|
|
118
|
+
) : null
|
|
97
119
|
]
|
|
98
120
|
}
|
|
99
121
|
);
|
|
@@ -111,6 +133,7 @@ const DropdownMenuItemShortcuts = forwardRef((props, forwardedRef) => {
|
|
|
111
133
|
return /* @__PURE__ */ jsx(
|
|
112
134
|
ListItem.Decoration,
|
|
113
135
|
{
|
|
136
|
+
render: /* @__PURE__ */ jsx("span", {}),
|
|
114
137
|
...rest,
|
|
115
138
|
className: cx("\u{1F95D}-dropdown-menu-item-shortcuts", props.className),
|
|
116
139
|
ref: forwardedRef,
|
|
@@ -141,30 +164,54 @@ const DropdownMenuIcon = forwardRef(
|
|
|
141
164
|
Icon,
|
|
142
165
|
{
|
|
143
166
|
href: typeof icon === "string" ? icon : void 0,
|
|
144
|
-
render: React.isValidElement(icon) ? icon : void 0
|
|
167
|
+
render: React.isValidElement(icon) ? icon : void 0,
|
|
168
|
+
...rest,
|
|
169
|
+
ref: forwardedRef
|
|
145
170
|
}
|
|
146
|
-
)
|
|
147
|
-
...rest,
|
|
148
|
-
ref: forwardedRef
|
|
171
|
+
)
|
|
149
172
|
}
|
|
150
173
|
);
|
|
151
174
|
}
|
|
152
175
|
);
|
|
153
176
|
DEV: DropdownMenuIcon.displayName = "DropdownMenuIcon";
|
|
154
177
|
const DropdownMenuCheckboxItem = forwardRef((props, forwardedRef) => {
|
|
155
|
-
const {
|
|
178
|
+
const {
|
|
179
|
+
label,
|
|
180
|
+
icon,
|
|
181
|
+
defaultChecked,
|
|
182
|
+
checked,
|
|
183
|
+
onChange,
|
|
184
|
+
name,
|
|
185
|
+
value = defaultChecked ? "on" : void 0,
|
|
186
|
+
// For defaultChecked to work
|
|
187
|
+
...rest
|
|
188
|
+
} = props;
|
|
156
189
|
return /* @__PURE__ */ jsxs(
|
|
157
190
|
MenuItemCheckbox,
|
|
158
191
|
{
|
|
159
192
|
accessibleWhenDisabled: true,
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
193
|
+
defaultChecked,
|
|
194
|
+
checked,
|
|
195
|
+
name,
|
|
196
|
+
value,
|
|
197
|
+
onChange,
|
|
198
|
+
render: /* @__PURE__ */ jsx(
|
|
199
|
+
ListItem.Root,
|
|
200
|
+
{
|
|
201
|
+
render: /* @__PURE__ */ jsx(
|
|
202
|
+
ButtonAk,
|
|
203
|
+
{
|
|
204
|
+
accessibleWhenDisabled: true,
|
|
205
|
+
...rest,
|
|
206
|
+
className: cx("\u{1F95D}-dropdown-menu-item", props.className),
|
|
207
|
+
ref: forwardedRef
|
|
208
|
+
}
|
|
209
|
+
)
|
|
210
|
+
}
|
|
211
|
+
),
|
|
165
212
|
children: [
|
|
166
213
|
icon ? /* @__PURE__ */ jsx(DropdownMenuIcon, { icon }) : null,
|
|
167
|
-
/* @__PURE__ */ jsx(ListItem.Content, { children: label }),
|
|
214
|
+
/* @__PURE__ */ jsx(ListItem.Content, { render: /* @__PURE__ */ jsx("span", {}), children: label }),
|
|
168
215
|
/* @__PURE__ */ jsx(
|
|
169
216
|
ListItem.Decoration,
|
|
170
217
|
{
|
|
@@ -181,5 +228,5 @@ export {
|
|
|
181
228
|
DropdownMenuCheckboxItem as CheckboxItem,
|
|
182
229
|
DropdownMenuContent as Content,
|
|
183
230
|
DropdownMenuItem as Item,
|
|
184
|
-
|
|
231
|
+
DropdownMenuRoot as Root
|
|
185
232
|
};
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import cx from "classnames";
|
|
4
|
+
import {
|
|
5
|
+
DialogProvider,
|
|
6
|
+
DialogDisclosure,
|
|
7
|
+
Dialog
|
|
8
|
+
} from "@ariakit/react/dialog";
|
|
9
|
+
import { Role } from "@ariakit/react/role";
|
|
10
|
+
import { forwardRef } from "./~utils.js";
|
|
11
|
+
import { ChevronDown, Dismiss, StatusWarning } from "./Icon.js";
|
|
12
|
+
import { Text } from "./Text.js";
|
|
13
|
+
import { IconButton } from "./IconButton.js";
|
|
14
|
+
import { Button } from "./Button.js";
|
|
15
|
+
import { useControlledState } from "./~hooks.js";
|
|
16
|
+
import { VisuallyHidden } from "./VisuallyHidden.js";
|
|
17
|
+
const ErrorRegionRoot = forwardRef(
|
|
18
|
+
(props, forwardedRef) => {
|
|
19
|
+
const { label, items, expanded, onExpandedChange, ...rest } = props;
|
|
20
|
+
const labelId = React.useId();
|
|
21
|
+
const sectionLabelledBy = props["aria-labelledby"] ?? (props["aria-label"] ? void 0 : labelId);
|
|
22
|
+
const [open, setOpen] = useControlledState(
|
|
23
|
+
false,
|
|
24
|
+
expanded,
|
|
25
|
+
onExpandedChange
|
|
26
|
+
);
|
|
27
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
28
|
+
/* @__PURE__ */ jsx(VisuallyHidden, { "aria-live": "polite", "aria-atomic": true, children: label }),
|
|
29
|
+
/* @__PURE__ */ jsx(DialogProvider, { open, setOpen, children: /* @__PURE__ */ jsx(
|
|
30
|
+
Role.section,
|
|
31
|
+
{
|
|
32
|
+
...rest,
|
|
33
|
+
"aria-labelledby": sectionLabelledBy,
|
|
34
|
+
className: cx("\u{1F95D}-error-region", props.className),
|
|
35
|
+
"data-kiwi-visible": !!label,
|
|
36
|
+
"data-kiwi-expanded": open,
|
|
37
|
+
ref: forwardedRef,
|
|
38
|
+
children: /* @__PURE__ */ jsxs("div", { className: "\u{1F95D}-error-region-container", children: [
|
|
39
|
+
/* @__PURE__ */ jsxs(
|
|
40
|
+
DialogDisclosure,
|
|
41
|
+
{
|
|
42
|
+
className: "\u{1F95D}-error-region-header",
|
|
43
|
+
render: /* @__PURE__ */ jsx(Button, { variant: "ghost" }),
|
|
44
|
+
children: [
|
|
45
|
+
/* @__PURE__ */ jsx(StatusWarning, { className: "\u{1F95D}-error-region-icon" }),
|
|
46
|
+
/* @__PURE__ */ jsx(
|
|
47
|
+
Text,
|
|
48
|
+
{
|
|
49
|
+
id: labelId,
|
|
50
|
+
className: "\u{1F95D}-error-region-label",
|
|
51
|
+
variant: "body-sm",
|
|
52
|
+
children: label
|
|
53
|
+
}
|
|
54
|
+
),
|
|
55
|
+
/* @__PURE__ */ jsx(
|
|
56
|
+
IconButton,
|
|
57
|
+
{
|
|
58
|
+
inert: true,
|
|
59
|
+
render: /* @__PURE__ */ jsx("span", {}),
|
|
60
|
+
role: void 0,
|
|
61
|
+
label: "",
|
|
62
|
+
icon: /* @__PURE__ */ jsx(ChevronDown, {}),
|
|
63
|
+
variant: "ghost"
|
|
64
|
+
}
|
|
65
|
+
)
|
|
66
|
+
]
|
|
67
|
+
}
|
|
68
|
+
),
|
|
69
|
+
/* @__PURE__ */ jsx(
|
|
70
|
+
Dialog,
|
|
71
|
+
{
|
|
72
|
+
className: "\u{1F95D}-error-region-dialog",
|
|
73
|
+
portal: false,
|
|
74
|
+
modal: false,
|
|
75
|
+
autoFocusOnShow: false,
|
|
76
|
+
"aria-labelledby": labelId,
|
|
77
|
+
children: /* @__PURE__ */ jsx("div", { className: "\u{1F95D}-error-region-items", role: "list", children: items })
|
|
78
|
+
}
|
|
79
|
+
)
|
|
80
|
+
] })
|
|
81
|
+
}
|
|
82
|
+
) })
|
|
83
|
+
] });
|
|
84
|
+
}
|
|
85
|
+
);
|
|
86
|
+
DEV: ErrorRegionRoot.displayName = "ErrorRegion.Root";
|
|
87
|
+
const ErrorRegionItem = forwardRef(
|
|
88
|
+
(props, forwardedRef) => {
|
|
89
|
+
const generatedId = React.useId();
|
|
90
|
+
const {
|
|
91
|
+
message,
|
|
92
|
+
messageId = `${generatedId}-message`,
|
|
93
|
+
actions,
|
|
94
|
+
onDismiss,
|
|
95
|
+
...rest
|
|
96
|
+
} = props;
|
|
97
|
+
const dismissButtonId = `${generatedId}-dismiss`;
|
|
98
|
+
return /* @__PURE__ */ jsxs(
|
|
99
|
+
Role.div,
|
|
100
|
+
{
|
|
101
|
+
...rest,
|
|
102
|
+
role: "listitem",
|
|
103
|
+
className: cx("\u{1F95D}-error-region-item", props.className),
|
|
104
|
+
ref: forwardedRef,
|
|
105
|
+
children: [
|
|
106
|
+
/* @__PURE__ */ jsx(
|
|
107
|
+
Text,
|
|
108
|
+
{
|
|
109
|
+
id: messageId,
|
|
110
|
+
variant: "body-sm",
|
|
111
|
+
className: "\u{1F95D}-error-region-item-message",
|
|
112
|
+
children: message
|
|
113
|
+
}
|
|
114
|
+
),
|
|
115
|
+
onDismiss && /* @__PURE__ */ jsx(
|
|
116
|
+
IconButton,
|
|
117
|
+
{
|
|
118
|
+
id: dismissButtonId,
|
|
119
|
+
className: "\u{1F95D}-error-region-item-dismiss",
|
|
120
|
+
variant: "ghost",
|
|
121
|
+
label: "Dismiss",
|
|
122
|
+
"aria-labelledby": `${dismissButtonId} ${messageId}`,
|
|
123
|
+
icon: /* @__PURE__ */ jsx(Dismiss, {}),
|
|
124
|
+
onClick: onDismiss
|
|
125
|
+
}
|
|
126
|
+
),
|
|
127
|
+
/* @__PURE__ */ jsx("div", { className: "\u{1F95D}-error-region-item-actions", children: actions })
|
|
128
|
+
]
|
|
129
|
+
}
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
);
|
|
133
|
+
DEV: ErrorRegionItem.displayName = "ErrorRegion.Item";
|
|
134
|
+
export {
|
|
135
|
+
ErrorRegionItem as Item,
|
|
136
|
+
ErrorRegionRoot as Root
|
|
137
|
+
};
|
|
@@ -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
|
+
};
|