@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
|
@@ -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,6 +36,7 @@ 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
|
);
|
|
@@ -83,13 +86,23 @@ const DropdownMenuItem = forwardRef(
|
|
|
83
86
|
MenuItem,
|
|
84
87
|
{
|
|
85
88
|
accessibleWhenDisabled: true,
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
89
|
+
render: /* @__PURE__ */ jsx(
|
|
90
|
+
ListItem.Root,
|
|
91
|
+
{
|
|
92
|
+
render: /* @__PURE__ */ jsx(
|
|
93
|
+
ButtonAk,
|
|
94
|
+
{
|
|
95
|
+
accessibleWhenDisabled: true,
|
|
96
|
+
...rest,
|
|
97
|
+
className: cx("\u{1F95D}-dropdown-menu-item", props.className),
|
|
98
|
+
ref: forwardedRef
|
|
99
|
+
}
|
|
100
|
+
)
|
|
101
|
+
}
|
|
102
|
+
),
|
|
90
103
|
children: [
|
|
91
104
|
icon ? /* @__PURE__ */ jsx(DropdownMenuIcon, { icon }) : null,
|
|
92
|
-
/* @__PURE__ */ jsx(ListItem.Content, { children: label }),
|
|
105
|
+
/* @__PURE__ */ jsx(ListItem.Content, { render: /* @__PURE__ */ jsx("span", {}), children: label }),
|
|
93
106
|
shortcuts ? /* @__PURE__ */ jsx(DropdownMenuItemShortcuts, { shortcuts }) : null
|
|
94
107
|
]
|
|
95
108
|
}
|
|
@@ -107,6 +120,7 @@ const DropdownMenuItemShortcuts = forwardRef((props, forwardedRef) => {
|
|
|
107
120
|
return /* @__PURE__ */ jsx(
|
|
108
121
|
ListItem.Decoration,
|
|
109
122
|
{
|
|
123
|
+
render: /* @__PURE__ */ jsx("span", {}),
|
|
110
124
|
...rest,
|
|
111
125
|
className: cx("\u{1F95D}-dropdown-menu-item-shortcuts", props.className),
|
|
112
126
|
ref: forwardedRef,
|
|
@@ -136,29 +150,53 @@ const DropdownMenuIcon = forwardRef(
|
|
|
136
150
|
Icon,
|
|
137
151
|
{
|
|
138
152
|
href: typeof icon === "string" ? icon : void 0,
|
|
139
|
-
render: React.isValidElement(icon) ? icon : void 0
|
|
153
|
+
render: React.isValidElement(icon) ? icon : void 0,
|
|
154
|
+
...rest,
|
|
155
|
+
ref: forwardedRef
|
|
140
156
|
}
|
|
141
|
-
)
|
|
142
|
-
...rest,
|
|
143
|
-
ref: forwardedRef
|
|
157
|
+
)
|
|
144
158
|
}
|
|
145
159
|
);
|
|
146
160
|
}
|
|
147
161
|
);
|
|
148
162
|
const DropdownMenuCheckboxItem = forwardRef((props, forwardedRef) => {
|
|
149
|
-
const {
|
|
163
|
+
const {
|
|
164
|
+
label,
|
|
165
|
+
icon,
|
|
166
|
+
defaultChecked,
|
|
167
|
+
checked,
|
|
168
|
+
onChange,
|
|
169
|
+
name,
|
|
170
|
+
value = defaultChecked ? "on" : void 0,
|
|
171
|
+
// For defaultChecked to work
|
|
172
|
+
...rest
|
|
173
|
+
} = props;
|
|
150
174
|
return /* @__PURE__ */ jsxs(
|
|
151
175
|
MenuItemCheckbox,
|
|
152
176
|
{
|
|
153
177
|
accessibleWhenDisabled: true,
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
178
|
+
defaultChecked,
|
|
179
|
+
checked,
|
|
180
|
+
name,
|
|
181
|
+
value,
|
|
182
|
+
onChange,
|
|
183
|
+
render: /* @__PURE__ */ jsx(
|
|
184
|
+
ListItem.Root,
|
|
185
|
+
{
|
|
186
|
+
render: /* @__PURE__ */ jsx(
|
|
187
|
+
ButtonAk,
|
|
188
|
+
{
|
|
189
|
+
accessibleWhenDisabled: true,
|
|
190
|
+
...rest,
|
|
191
|
+
className: cx("\u{1F95D}-dropdown-menu-item", props.className),
|
|
192
|
+
ref: forwardedRef
|
|
193
|
+
}
|
|
194
|
+
)
|
|
195
|
+
}
|
|
196
|
+
),
|
|
159
197
|
children: [
|
|
160
198
|
icon ? /* @__PURE__ */ jsx(DropdownMenuIcon, { icon }) : null,
|
|
161
|
-
/* @__PURE__ */ jsx(ListItem.Content, { children: label }),
|
|
199
|
+
/* @__PURE__ */ jsx(ListItem.Content, { render: /* @__PURE__ */ jsx("span", {}), children: label }),
|
|
162
200
|
/* @__PURE__ */ jsx(
|
|
163
201
|
ListItem.Decoration,
|
|
164
202
|
{
|
|
@@ -174,5 +212,5 @@ export {
|
|
|
174
212
|
DropdownMenuCheckboxItem as CheckboxItem,
|
|
175
213
|
DropdownMenuContent as Content,
|
|
176
214
|
DropdownMenuItem as Item,
|
|
177
|
-
|
|
215
|
+
DropdownMenuRoot as Root
|
|
178
216
|
};
|
package/dist/bricks/Field.d.ts
CHANGED
|
@@ -1,53 +1,89 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { type CollectionItemProps } from "@ariakit/react/collection";
|
|
3
3
|
import { type BaseProps } from "./~utils.js";
|
|
4
|
-
interface
|
|
4
|
+
interface FieldRootProps extends BaseProps {
|
|
5
5
|
/**
|
|
6
6
|
* Allows overriding the default block layout for text controls.
|
|
7
7
|
*/
|
|
8
8
|
layout?: "inline";
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
|
-
* A container for form controls. It manages ID associations provides a
|
|
11
|
+
* A container for form controls. It manages ID associations, and provides a
|
|
12
|
+
* consistent layout and spacing.
|
|
12
13
|
*
|
|
13
14
|
* Example:
|
|
14
15
|
* ```tsx
|
|
15
|
-
* <Field>
|
|
16
|
-
* <Label>Label</Label>
|
|
17
|
-
* <TextBox.Input />
|
|
18
|
-
* </Field>
|
|
16
|
+
* <Field.Root>
|
|
17
|
+
* <Field.Label>Label</Field.Label>
|
|
18
|
+
* <Field.Control render={<TextBox.Input />} />
|
|
19
|
+
* </Field.Root>
|
|
19
20
|
* ```
|
|
20
21
|
*
|
|
21
|
-
* Supports a `layout` prop, which can be set to `inline` to align the label and
|
|
22
|
+
* Supports a `layout` prop, which can be set to `inline` to align the label and
|
|
23
|
+
* control horizontally.
|
|
22
24
|
*
|
|
23
|
-
* Should contain a `Label` component paired with a form control.
|
|
25
|
+
* Should contain a `Field.Label` component paired with a form control.
|
|
26
|
+
*
|
|
27
|
+
* Supported form controls include:
|
|
24
28
|
* - `TextBox.Input`
|
|
25
29
|
* - `TextBox.Textarea`
|
|
26
30
|
* - `Checkbox`
|
|
27
31
|
* - `Radio`
|
|
28
32
|
* - `Switch`
|
|
29
33
|
*/
|
|
30
|
-
|
|
31
|
-
type CollectionStoreItem = NonNullable<ReturnType<ReturnType<typeof useCollectionStore>["item"]>>;
|
|
32
|
-
interface FieldCollectionStoreItem extends CollectionStoreItem {
|
|
33
|
-
/** The type of field element being tracked */
|
|
34
|
-
elementType: "label" | "control" | "description";
|
|
35
|
-
/** If a control, the type of control. */
|
|
36
|
-
controlType?: "textlike" | "checkable";
|
|
37
|
-
}
|
|
38
|
-
interface FieldCollectionItemControlProps extends Pick<CollectionItemProps, "render" | "id"> {
|
|
39
|
-
type: FieldCollectionStoreItem["controlType"];
|
|
40
|
-
}
|
|
34
|
+
declare const FieldRoot: React.ForwardRefExoticComponent<FieldRootProps & React.RefAttributes<HTMLElement | HTMLDivElement>>;
|
|
41
35
|
/**
|
|
42
|
-
*
|
|
36
|
+
* A label for the field’s control element. This is automatically associated
|
|
37
|
+
* with the control’s `id`.
|
|
43
38
|
*/
|
|
44
|
-
|
|
39
|
+
declare const FieldLabel: React.ForwardRefExoticComponent<Pick<import("@ariakit/react/role").RoleProps, "render"> & Omit<Omit<React.DetailedHTMLProps<React.LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>, "ref">, "render"> & React.RefAttributes<HTMLElement | HTMLDivElement>>;
|
|
45
40
|
/**
|
|
46
|
-
*
|
|
41
|
+
* A description for the field’s control element. This is automatically
|
|
42
|
+
* associated with the control.
|
|
43
|
+
*
|
|
44
|
+
* Should not include content without an adequate text alternative (e.g.
|
|
45
|
+
* interactive elements).
|
|
47
46
|
*/
|
|
48
|
-
|
|
47
|
+
declare const FieldDescription: React.ForwardRefExoticComponent<Pick<import("@ariakit/react/role").RoleProps, "render"> & Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "render"> & React.RefAttributes<HTMLElement | HTMLDivElement>>;
|
|
48
|
+
interface FieldCollectionItemControlProps extends Pick<CollectionItemProps, "render" | "id"> {
|
|
49
|
+
}
|
|
49
50
|
/**
|
|
50
|
-
*
|
|
51
|
+
* The control component for the field.
|
|
52
|
+
*
|
|
53
|
+
* If the rendered component uses a compositional API, then use a function
|
|
54
|
+
* within `render` to apply the `controlProps` to the correct sub-component:
|
|
55
|
+
*
|
|
56
|
+
* ```tsx
|
|
57
|
+
* <Field.Control
|
|
58
|
+
* render={(controlProps) => (
|
|
59
|
+
* <TextBox.Root>
|
|
60
|
+
* <TextBox.Icon href={placeholder} />
|
|
61
|
+
* <TextBox.Input {...controlProps} />
|
|
62
|
+
* </TextBox.Root>
|
|
63
|
+
* )}
|
|
64
|
+
* />
|
|
65
|
+
* ```
|
|
66
|
+
*
|
|
67
|
+
* If you need a custom `id` set for the control, set it on this component
|
|
68
|
+
* instead of the control component within `render`.
|
|
69
|
+
*
|
|
70
|
+
* ```tsx
|
|
71
|
+
* <Field.Control id="custom" render={<TextBox.Input />} />
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
declare const FieldControl: React.ForwardRefExoticComponent<FieldCollectionItemControlProps & React.RefAttributes<HTMLElement | HTMLDivElement>>;
|
|
75
|
+
/**
|
|
76
|
+
* An associated error message for a field. When used within `<Field.Root>`, the
|
|
77
|
+
* associated form control will be rendered with `aria-invalid="true"`.
|
|
78
|
+
*
|
|
79
|
+
* Example:
|
|
80
|
+
* ```tsx
|
|
81
|
+
* <Field.Root>
|
|
82
|
+
* <Field.Label>Label</Field.Label>
|
|
83
|
+
* <Field.Control render={<TextBox.Input />} />
|
|
84
|
+
* <Field.ErrorMessage>Something is wrong!</Field.ErrorMessage>
|
|
85
|
+
* </Field.Root>
|
|
86
|
+
* ```
|
|
51
87
|
*/
|
|
52
|
-
|
|
53
|
-
export {};
|
|
88
|
+
declare const FieldErrorMessage: React.ForwardRefExoticComponent<Pick<import("@ariakit/react/role").RoleProps, "render"> & Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "render"> & React.RefAttributes<HTMLElement | HTMLDivElement>>;
|
|
89
|
+
export { FieldRoot as Root, FieldControl as Control, FieldLabel as Label, FieldDescription as Description, FieldErrorMessage as ErrorMessage, };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { useCollectionStore, type CollectionProps } from "@ariakit/react/collection";
|
|
3
|
+
/**
|
|
4
|
+
* Ariakit’s unexported `CollectionStoreItem` type inferred.
|
|
5
|
+
* @private
|
|
6
|
+
*/
|
|
7
|
+
export type CollectionStoreItem = NonNullable<ReturnType<ReturnType<typeof useCollectionStore>["item"]>>;
|
|
8
|
+
/**
|
|
9
|
+
* An extension of `CollectionStoreItem` to track element and control types.
|
|
10
|
+
* @private
|
|
11
|
+
*/
|
|
12
|
+
export interface FieldCollectionStoreItem extends CollectionStoreItem {
|
|
13
|
+
/** The type of field element being tracked */
|
|
14
|
+
elementType: "label" | "control" | "description" | "error";
|
|
15
|
+
/** If a control, the type of control. */
|
|
16
|
+
controlType?: "textlike" | "checkable";
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* A collection that tracks labels, controls, and descriptions which provides
|
|
20
|
+
* information about IDs, placement of labels, and control types.
|
|
21
|
+
* @private
|
|
22
|
+
*/
|
|
23
|
+
export declare function FieldCollection(props: Pick<CollectionProps, "render">): import("react/jsx-runtime").JSX.Element;
|
|
24
|
+
/**
|
|
25
|
+
* Control type context for the field.
|
|
26
|
+
* @private
|
|
27
|
+
*/
|
|
28
|
+
export declare const FieldControlTypeContext: React.Context<React.Dispatch<React.SetStateAction<"textlike" | "checkable" | undefined>> | undefined>;
|
|
29
|
+
/**
|
|
30
|
+
* Sets the control type for the field. Necessary for layout.
|
|
31
|
+
* @private
|
|
32
|
+
*/
|
|
33
|
+
export declare function useFieldControlType(controlType: NonNullable<FieldCollectionStoreItem["controlType"]>): void;
|
|
@@ -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/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,75 +31,40 @@ const Field = forwardRef((props, forwardedRef) => {
|
|
|
27
31
|
}
|
|
28
32
|
);
|
|
29
33
|
});
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
const FieldLabel = forwardRef(
|
|
35
|
+
(props, forwardedRef) => {
|
|
36
|
+
const store = useCollectionContext();
|
|
37
|
+
const renderedItems = useStoreState(store, "renderedItems");
|
|
38
|
+
const fieldId = React.useMemo(
|
|
39
|
+
() => renderedItems?.find(
|
|
40
|
+
(item) => item.elementType === "control"
|
|
41
|
+
)?.id,
|
|
42
|
+
[renderedItems]
|
|
38
43
|
);
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
+
const getData = React.useCallback(
|
|
45
|
+
(data) => ({
|
|
46
|
+
...data,
|
|
47
|
+
elementType: "label"
|
|
48
|
+
}),
|
|
49
|
+
[]
|
|
44
50
|
);
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
function FieldControl(props) {
|
|
59
|
-
const store = useCollectionContext();
|
|
51
|
+
return /* @__PURE__ */ jsx(
|
|
52
|
+
CollectionItem,
|
|
53
|
+
{
|
|
54
|
+
getItem: getData,
|
|
55
|
+
render: /* @__PURE__ */ jsx(Label, { ...props, htmlFor: fieldId }),
|
|
56
|
+
ref: forwardedRef
|
|
57
|
+
}
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
);
|
|
61
|
+
const FieldDescription = forwardRef((props, forwardedRef) => {
|
|
60
62
|
const generatedId = React.useId();
|
|
61
|
-
const { id =
|
|
62
|
-
const renderedItems = useStoreState(store, "renderedItems");
|
|
63
|
-
const describedBy = React.useMemo(() => {
|
|
64
|
-
const idRefList = renderedItems?.filter(
|
|
65
|
-
(item) => item.elementType === "description"
|
|
66
|
-
)?.map((item) => item.id).join(" ");
|
|
67
|
-
return idRefList || void 0;
|
|
68
|
-
}, [renderedItems]);
|
|
69
|
-
const getData = React.useCallback(
|
|
70
|
-
(data) => ({
|
|
71
|
-
...data,
|
|
72
|
-
elementType: "control",
|
|
73
|
-
controlType: type
|
|
74
|
-
}),
|
|
75
|
-
[type]
|
|
76
|
-
);
|
|
77
|
-
return /* @__PURE__ */ jsx(
|
|
78
|
-
CollectionItem,
|
|
79
|
-
{
|
|
80
|
-
id,
|
|
81
|
-
getItem: getData,
|
|
82
|
-
render: /* @__PURE__ */ jsx(Role, { ...rest, "aria-describedby": describedBy })
|
|
83
|
-
}
|
|
84
|
-
);
|
|
85
|
-
}
|
|
86
|
-
function FieldLabel(props) {
|
|
87
|
-
const store = useCollectionContext();
|
|
88
|
-
const renderedItems = useStoreState(store, "renderedItems");
|
|
89
|
-
const fieldId = React.useMemo(
|
|
90
|
-
() => renderedItems?.find(
|
|
91
|
-
(item) => item.elementType === "control"
|
|
92
|
-
)?.id,
|
|
93
|
-
[renderedItems]
|
|
94
|
-
);
|
|
63
|
+
const { id = generatedId, ...rest } = props;
|
|
95
64
|
const getData = React.useCallback(
|
|
96
65
|
(data) => ({
|
|
97
66
|
...data,
|
|
98
|
-
elementType: "
|
|
67
|
+
elementType: "description"
|
|
99
68
|
}),
|
|
100
69
|
[]
|
|
101
70
|
);
|
|
@@ -103,25 +72,83 @@ function FieldLabel(props) {
|
|
|
103
72
|
CollectionItem,
|
|
104
73
|
{
|
|
105
74
|
getItem: getData,
|
|
106
|
-
|
|
75
|
+
id,
|
|
76
|
+
render: /* @__PURE__ */ jsx(Description, { ...rest }),
|
|
77
|
+
ref: forwardedRef
|
|
107
78
|
}
|
|
108
79
|
);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
80
|
+
});
|
|
81
|
+
const FieldControl = forwardRef(
|
|
82
|
+
(props, forwardedRef) => {
|
|
83
|
+
const [controlType, setControlType] = React.useState();
|
|
84
|
+
const store = useCollectionContext();
|
|
85
|
+
const generatedId = React.useId();
|
|
86
|
+
const { id = store ? generatedId : void 0, ...rest } = props;
|
|
87
|
+
const renderedItems = useStoreState(store, "renderedItems");
|
|
88
|
+
const describedBy = React.useMemo(() => {
|
|
89
|
+
const idRefList = renderedItems?.filter(
|
|
90
|
+
(item) => item.elementType === "description" || item.elementType === "error"
|
|
91
|
+
)?.map((item) => item.id).join(" ");
|
|
92
|
+
return idRefList || void 0;
|
|
93
|
+
}, [renderedItems]);
|
|
94
|
+
const getData = React.useCallback(
|
|
95
|
+
(data) => ({
|
|
96
|
+
...data,
|
|
97
|
+
elementType: "control",
|
|
98
|
+
controlType
|
|
99
|
+
}),
|
|
100
|
+
[controlType]
|
|
101
|
+
);
|
|
102
|
+
const invalid = React.useMemo(
|
|
103
|
+
() => renderedItems?.some(
|
|
104
|
+
(item) => item.elementType === "error"
|
|
105
|
+
),
|
|
106
|
+
[renderedItems]
|
|
107
|
+
);
|
|
108
|
+
return /* @__PURE__ */ jsx(FieldControlTypeContext.Provider, { value: setControlType, children: /* @__PURE__ */ jsx(
|
|
109
|
+
CollectionItem,
|
|
110
|
+
{
|
|
111
|
+
id,
|
|
112
|
+
getItem: getData,
|
|
113
|
+
render: /* @__PURE__ */ jsx(
|
|
114
|
+
Role,
|
|
115
|
+
{
|
|
116
|
+
...rest,
|
|
117
|
+
"aria-invalid": invalid ? "true" : void 0,
|
|
118
|
+
"aria-describedby": describedBy
|
|
119
|
+
}
|
|
120
|
+
),
|
|
121
|
+
ref: forwardedRef
|
|
122
|
+
}
|
|
123
|
+
) });
|
|
124
|
+
}
|
|
125
|
+
);
|
|
126
|
+
const FieldErrorMessage = forwardRef(
|
|
127
|
+
(props, forwardedRef) => {
|
|
128
|
+
const generatedId = React.useId();
|
|
129
|
+
const { id = generatedId, ...rest } = props;
|
|
130
|
+
const getData = React.useCallback(
|
|
131
|
+
(data) => ({
|
|
132
|
+
...data,
|
|
133
|
+
elementType: "error"
|
|
134
|
+
}),
|
|
135
|
+
[]
|
|
136
|
+
);
|
|
137
|
+
return /* @__PURE__ */ jsx(
|
|
138
|
+
CollectionItem,
|
|
139
|
+
{
|
|
140
|
+
id,
|
|
141
|
+
getItem: getData,
|
|
142
|
+
render: /* @__PURE__ */ jsx(Description, { ...rest, tone: "critical" }),
|
|
143
|
+
ref: forwardedRef
|
|
144
|
+
}
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
);
|
|
122
148
|
export {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
FieldLabel
|
|
149
|
+
FieldControl as Control,
|
|
150
|
+
FieldDescription as Description,
|
|
151
|
+
FieldErrorMessage as ErrorMessage,
|
|
152
|
+
FieldLabel as Label,
|
|
153
|
+
FieldRoot as Root
|
|
127
154
|
};
|
package/dist/bricks/Icon.d.ts
CHANGED
|
@@ -71,4 +71,7 @@ export declare const Dismiss: React.ForwardRefExoticComponent<DismissProps & Rea
|
|
|
71
71
|
interface StatusWarningProps extends Omit<BaseProps<"svg">, "children"> {
|
|
72
72
|
}
|
|
73
73
|
export declare const StatusWarning: React.ForwardRefExoticComponent<StatusWarningProps & React.RefAttributes<HTMLElement | SVGSVGElement>>;
|
|
74
|
+
interface MoreHorizontalProps extends Omit<BaseProps<"svg">, "children"> {
|
|
75
|
+
}
|
|
76
|
+
export declare const MoreHorizontal: React.ForwardRefExoticComponent<MoreHorizontalProps & React.RefAttributes<HTMLElement | SVGSVGElement>>;
|
|
74
77
|
export {};
|
package/dist/bricks/Icon.js
CHANGED
|
@@ -215,10 +215,41 @@ const StatusWarning = forwardRef(
|
|
|
215
215
|
);
|
|
216
216
|
}
|
|
217
217
|
);
|
|
218
|
+
const MoreHorizontal = forwardRef(
|
|
219
|
+
(props, forwardedRef) => {
|
|
220
|
+
return /* @__PURE__ */ jsx(
|
|
221
|
+
Icon,
|
|
222
|
+
{
|
|
223
|
+
...props,
|
|
224
|
+
render: /* @__PURE__ */ jsx(
|
|
225
|
+
Role.svg,
|
|
226
|
+
{
|
|
227
|
+
width: "16",
|
|
228
|
+
height: "16",
|
|
229
|
+
viewBox: "0 0 16 16",
|
|
230
|
+
fill: "none",
|
|
231
|
+
render: props.render,
|
|
232
|
+
children: /* @__PURE__ */ jsx(
|
|
233
|
+
"path",
|
|
234
|
+
{
|
|
235
|
+
fill: "currentColor",
|
|
236
|
+
fillRule: "evenodd",
|
|
237
|
+
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",
|
|
238
|
+
clipRule: "evenodd"
|
|
239
|
+
}
|
|
240
|
+
)
|
|
241
|
+
}
|
|
242
|
+
),
|
|
243
|
+
ref: forwardedRef
|
|
244
|
+
}
|
|
245
|
+
);
|
|
246
|
+
}
|
|
247
|
+
);
|
|
218
248
|
export {
|
|
219
249
|
Checkmark,
|
|
220
250
|
DisclosureArrow,
|
|
221
251
|
Dismiss,
|
|
222
252
|
Icon,
|
|
253
|
+
MoreHorizontal,
|
|
223
254
|
StatusWarning
|
|
224
255
|
};
|
package/dist/bricks/Label.d.ts
CHANGED
|
@@ -2,24 +2,17 @@ import { type BaseProps } from "./~utils.js";
|
|
|
2
2
|
interface LabelProps extends BaseProps<"label"> {
|
|
3
3
|
}
|
|
4
4
|
/**
|
|
5
|
-
* A styled wrapper over the HTML `<label>` element, used for labelling form
|
|
5
|
+
* A styled wrapper over the HTML `<label>` element, used for labelling form
|
|
6
|
+
* controls.
|
|
6
7
|
*
|
|
7
|
-
*
|
|
8
|
-
|
|
8
|
+
* Example usage:
|
|
9
9
|
* ```tsx
|
|
10
10
|
* <Label htmlFor="my-input">Label</Label>
|
|
11
11
|
* <TextBox.Input id="my-input" />
|
|
12
12
|
* ```
|
|
13
13
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* ```tsx
|
|
17
|
-
* <Field>
|
|
18
|
-
* <Label>Label</Label>
|
|
19
|
-
* <TextBox.Input />
|
|
20
|
-
* </Field>
|
|
21
|
-
* ```
|
|
22
|
-
*
|
|
14
|
+
* See `Field.Label` for convenient usage with form controls (e.g. automatic
|
|
15
|
+
* association with adjacent form control).
|
|
23
16
|
*/
|
|
24
17
|
export declare const Label: import("react").ForwardRefExoticComponent<LabelProps & import("react").RefAttributes<HTMLElement | HTMLLabelElement>>;
|
|
25
18
|
export {};
|
package/dist/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
|
});
|