@primitiv-ui/react 0.1.1 → 0.1.2
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/LICENSE +21 -0
- package/package.json +2 -1
- package/src/AccessibleIcon/AccessibleIcon.tsx +1 -0
- package/src/AccessibleIcon/types.ts +4 -0
- package/src/Accordion/Accordion.tsx +23 -0
- package/src/Accordion/index.ts +2 -1
- package/src/Accordion/types.ts +55 -13
- package/src/Alert/Alert.tsx +1 -0
- package/src/Alert/types.ts +1 -0
- package/src/Avatar/Avatar.tsx +8 -4
- package/src/Avatar/AvatarContext.ts +2 -0
- package/src/Breadcrumb/Breadcrumb.tsx +15 -7
- package/src/Button/Button.tsx +1 -0
- package/src/Button/types.ts +4 -0
- package/src/Carousel/Carousel.tsx +9 -0
- package/src/Carousel/CarouselContext.ts +5 -2
- package/src/Carousel/types.ts +8 -0
- package/src/Checkbox/Checkbox.tsx +7 -3
- package/src/Checkbox/index.ts +1 -0
- package/src/Checkbox/types.ts +30 -3
- package/src/CheckboxCard/CheckboxCard.tsx +9 -8
- package/src/CheckboxCard/CheckboxCardContext.ts +9 -1
- package/src/CheckboxCard/hooks/useCheckboxCardRoot.ts +1 -1
- package/src/CheckboxCard/types.ts +21 -5
- package/src/Collapsible/Collapsible.tsx +15 -0
- package/src/Collapsible/index.ts +1 -0
- package/src/Collapsible/types.ts +45 -12
- package/src/ContextMenu/ContextMenu.tsx +40 -15
- package/src/ContextMenu/index.ts +2 -1
- package/src/ContextMenu/types.ts +159 -16
- package/src/DirectionProvider/DirectionProvider.tsx +1 -0
- package/src/DirectionProvider/types.ts +1 -0
- package/src/Divider/Divider.tsx +1 -0
- package/src/Divider/index.ts +2 -1
- package/src/Divider/types.ts +5 -0
- package/src/Dropdown/Dropdown.tsx +40 -15
- package/src/Dropdown/index.ts +2 -1
- package/src/Dropdown/types.ts +152 -24
- package/src/EmptyState/EmptyState.tsx +26 -14
- package/src/EmptyState/types.ts +2 -1
- package/src/Field/Field.tsx +14 -5
- package/src/Field/types.ts +4 -0
- package/src/Fieldset/Fieldset.tsx +17 -10
- package/src/Fieldset/types.ts +2 -0
- package/src/Input/Input.tsx +1 -0
- package/src/Input/types.ts +4 -0
- package/src/InputGroup/InputGroup.tsx +9 -4
- package/src/InputGroup/types.ts +9 -0
- package/src/MillerColumns/MillerColumns.tsx +19 -0
- package/src/MillerColumns/index.ts +1 -1
- package/src/MillerColumns/types.ts +67 -14
- package/src/Modal/Modal.tsx +1 -0
- package/src/Modal/ModalContext.ts +5 -2
- package/src/Modal/types.ts +51 -2
- package/src/Portal/Portal.tsx +1 -0
- package/src/Portal/types.ts +4 -0
- package/src/Progress/Progress.tsx +7 -3
- package/src/Progress/ProgressContext.ts +7 -0
- package/src/RadioCard/RadioCard.tsx +9 -4
- package/src/RadioCard/RadioCardContext.ts +7 -0
- package/src/RadioCard/RadioCardItemContext.ts +8 -0
- package/src/RadioCard/types.ts +24 -3
- package/src/RadioGroup/RadioGroup.tsx +9 -4
- package/src/RadioGroup/index.ts +1 -0
- package/src/RadioGroup/types.ts +34 -3
- package/src/Select/Select.tsx +16 -5
- package/src/Select/index.ts +1 -1
- package/src/Select/types.ts +18 -3
- package/src/Slider/Slider.tsx +10 -5
- package/src/Slider/SliderContext.ts +3 -0
- package/src/Slider/types.ts +12 -3
- package/src/Status/Status.tsx +1 -0
- package/src/Status/types.ts +4 -0
- package/src/Switch/Switch.tsx +8 -3
- package/src/Switch/SwitchContext.ts +4 -0
- package/src/Switch/types.ts +24 -3
- package/src/Table/Table.tsx +44 -24
- package/src/Table/index.ts +2 -1
- package/src/Tabs/Tabs.tsx +7 -2
- package/src/Tabs/TabsContext.ts +7 -2
- package/src/Tabs/types.ts +35 -1
- package/src/Textarea/Textarea.tsx +1 -0
- package/src/Textarea/types.ts +4 -0
- package/src/Toggle/Toggle.tsx +1 -0
- package/src/Toggle/types.ts +7 -3
- package/src/ToggleGroup/ToggleGroup.tsx +9 -3
- package/src/ToggleGroup/types.ts +45 -5
- package/src/Tooltip/Tooltip.tsx +25 -7
- package/src/Tooltip/index.ts +1 -0
- package/src/Tooltip/types.ts +50 -2
- package/src/Tree/Tree.tsx +46 -1
- package/src/Tree/index.ts +1 -1
- package/src/Tree/types.ts +39 -7
- package/src/VisuallyHidden/VisuallyHidden.tsx +1 -0
- package/src/VisuallyHidden/types.ts +4 -0
- package/src/index.ts +1 -0
- package/src/types.ts +1 -0
package/src/Dropdown/types.ts
CHANGED
|
@@ -3,7 +3,11 @@ import { ComponentProps, ReactNode, Ref } from "react";
|
|
|
3
3
|
import { CheckedState } from "../Checkbox/types";
|
|
4
4
|
import { Direction } from "../DirectionProvider/index.ts";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Shared base for both {@link DropdownRootProps} variants — `children` plus
|
|
8
|
+
* the reading-direction control.
|
|
9
|
+
*/
|
|
10
|
+
export type DropdownRootBaseProps = {
|
|
7
11
|
children?: ReactNode;
|
|
8
12
|
/**
|
|
9
13
|
* Reading direction for the menu. Affects which arrow key opens / closes
|
|
@@ -14,22 +18,42 @@ type DropdownRootBaseProps = {
|
|
|
14
18
|
dir?: Direction;
|
|
15
19
|
};
|
|
16
20
|
|
|
17
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Uncontrolled variant of {@link DropdownRootProps}: the component owns the
|
|
23
|
+
* open state. Pass `defaultOpen` (or omit it); `onOpenChange` is optional
|
|
24
|
+
* and `open` is forbidden.
|
|
25
|
+
*/
|
|
26
|
+
export type DropdownRootUncontrolledProps = DropdownRootBaseProps & {
|
|
18
27
|
defaultOpen?: boolean;
|
|
19
28
|
open?: never;
|
|
20
29
|
onOpenChange?: (open: boolean) => void;
|
|
21
30
|
};
|
|
22
31
|
|
|
23
|
-
|
|
32
|
+
/**
|
|
33
|
+
* Controlled variant of {@link DropdownRootProps}: the parent owns the open
|
|
34
|
+
* state. Pass `open` and `onOpenChange` together; `defaultOpen` is
|
|
35
|
+
* forbidden.
|
|
36
|
+
*/
|
|
37
|
+
export type DropdownRootControlledProps = DropdownRootBaseProps & {
|
|
24
38
|
defaultOpen?: never;
|
|
25
39
|
open: boolean;
|
|
26
40
|
onOpenChange: (open: boolean) => void;
|
|
27
41
|
};
|
|
28
42
|
|
|
43
|
+
/**
|
|
44
|
+
* Props for {@link Dropdown.Root} — the controlled/uncontrolled discriminated
|
|
45
|
+
* union pairing {@link DropdownRootUncontrolledProps} with
|
|
46
|
+
* {@link DropdownRootControlledProps}, plus the shared `children` and `dir`.
|
|
47
|
+
*/
|
|
29
48
|
export type DropdownRootProps =
|
|
30
49
|
| DropdownRootUncontrolledProps
|
|
31
50
|
| DropdownRootControlledProps;
|
|
32
51
|
|
|
52
|
+
/**
|
|
53
|
+
* Props for {@link Dropdown.Trigger} — the button that opens the menu. Extends
|
|
54
|
+
* the native `<button>` props (minus the ARIA attributes Dropdown owns) and
|
|
55
|
+
* adds `asChild` for rendering a custom element.
|
|
56
|
+
*/
|
|
33
57
|
export type DropdownTriggerProps = Omit<
|
|
34
58
|
ComponentProps<"button">,
|
|
35
59
|
"aria-haspopup" | "aria-expanded" | "aria-controls"
|
|
@@ -39,6 +63,11 @@ export type DropdownTriggerProps = Omit<
|
|
|
39
63
|
asChild?: boolean;
|
|
40
64
|
};
|
|
41
65
|
|
|
66
|
+
/**
|
|
67
|
+
* Props for {@link Dropdown.Content} — the popover menu surface. Extends the
|
|
68
|
+
* native `<menu>` props (minus the `role`/`popover`/`id` Dropdown manages) and
|
|
69
|
+
* adds `asChild` for rendering a custom element.
|
|
70
|
+
*/
|
|
42
71
|
export type DropdownContentProps = Omit<
|
|
43
72
|
ComponentProps<"menu">,
|
|
44
73
|
"role" | "popover" | "id"
|
|
@@ -48,6 +77,11 @@ export type DropdownContentProps = Omit<
|
|
|
48
77
|
asChild?: boolean;
|
|
49
78
|
};
|
|
50
79
|
|
|
80
|
+
/**
|
|
81
|
+
* Props for {@link Dropdown.Item} — a selectable menu item. Extends the native
|
|
82
|
+
* `<li>` props and adds `disabled`, `asChild`, and an `onSelect` callback that
|
|
83
|
+
* fires on activation (click, Enter, or Space).
|
|
84
|
+
*/
|
|
51
85
|
export type DropdownItemProps = Omit<
|
|
52
86
|
ComponentProps<"li">,
|
|
53
87
|
"role" | "tabIndex" | "onSelect"
|
|
@@ -64,12 +98,21 @@ export type DropdownItemProps = Omit<
|
|
|
64
98
|
onSelect?: (event: Event) => void;
|
|
65
99
|
};
|
|
66
100
|
|
|
101
|
+
/**
|
|
102
|
+
* Props for {@link Dropdown.Separator} — a non-interactive divider between
|
|
103
|
+
* groups of items. Extends the native `<li>` props and adds `asChild`.
|
|
104
|
+
*/
|
|
67
105
|
export type DropdownSeparatorProps = Omit<ComponentProps<"li">, "role"> & {
|
|
68
106
|
children?: ReactNode;
|
|
69
107
|
ref?: Ref<HTMLLIElement>;
|
|
70
108
|
asChild?: boolean;
|
|
71
109
|
};
|
|
72
110
|
|
|
111
|
+
/**
|
|
112
|
+
* Props for {@link Dropdown.ItemIndicator} — the check/dot rendered inside a
|
|
113
|
+
* checkbox or radio item. Extends the native `<span>` props and adds
|
|
114
|
+
* `forceMount` to keep it mounted while unchecked for enter/exit animation.
|
|
115
|
+
*/
|
|
73
116
|
export type DropdownItemIndicatorProps = ComponentProps<"span"> & {
|
|
74
117
|
children?: ReactNode;
|
|
75
118
|
ref?: Ref<HTMLSpanElement>;
|
|
@@ -83,19 +126,31 @@ export type DropdownItemIndicatorProps = ComponentProps<"span"> & {
|
|
|
83
126
|
forceMount?: boolean;
|
|
84
127
|
};
|
|
85
128
|
|
|
129
|
+
/**
|
|
130
|
+
* Props for {@link Dropdown.Group} — a labelled grouping of related items.
|
|
131
|
+
* Extends the native `<li>` props and adds `asChild`.
|
|
132
|
+
*/
|
|
86
133
|
export type DropdownGroupProps = Omit<ComponentProps<"li">, "role"> & {
|
|
87
134
|
children?: ReactNode;
|
|
88
135
|
ref?: Ref<HTMLLIElement>;
|
|
89
136
|
asChild?: boolean;
|
|
90
137
|
};
|
|
91
138
|
|
|
139
|
+
/**
|
|
140
|
+
* Props for {@link Dropdown.Label} — an accessible label for a
|
|
141
|
+
* {@link Dropdown.Group}. Extends the native `<li>` props and adds `asChild`.
|
|
142
|
+
*/
|
|
92
143
|
export type DropdownLabelProps = ComponentProps<"li"> & {
|
|
93
144
|
children?: ReactNode;
|
|
94
145
|
ref?: Ref<HTMLLIElement>;
|
|
95
146
|
asChild?: boolean;
|
|
96
147
|
};
|
|
97
148
|
|
|
98
|
-
|
|
149
|
+
/**
|
|
150
|
+
* Shared base for both {@link DropdownCheckboxItemProps} variants — the native
|
|
151
|
+
* `<li>` props plus `disabled`, `asChild`, and the `onSelect` callback.
|
|
152
|
+
*/
|
|
153
|
+
export type DropdownCheckboxItemBaseProps = Omit<
|
|
99
154
|
ComponentProps<"li">,
|
|
100
155
|
"role" | "tabIndex" | "aria-checked" | "defaultChecked" | "onSelect"
|
|
101
156
|
> & {
|
|
@@ -110,44 +165,88 @@ type DropdownCheckboxItemBaseProps = Omit<
|
|
|
110
165
|
onSelect?: (event: Event) => void;
|
|
111
166
|
};
|
|
112
167
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
168
|
+
/**
|
|
169
|
+
* Uncontrolled variant of {@link DropdownCheckboxItemProps}: the component owns
|
|
170
|
+
* the checked state. Pass `defaultChecked` (or omit it); `onCheckedChange` is
|
|
171
|
+
* optional and the controlled `checked` prop is forbidden.
|
|
172
|
+
*/
|
|
173
|
+
export type DropdownCheckboxItemUncontrolledProps =
|
|
174
|
+
DropdownCheckboxItemBaseProps & {
|
|
175
|
+
defaultChecked?: CheckedState;
|
|
176
|
+
checked?: never;
|
|
177
|
+
onCheckedChange?: (checked: boolean) => void;
|
|
178
|
+
};
|
|
118
179
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
180
|
+
/**
|
|
181
|
+
* Controlled variant of {@link DropdownCheckboxItemProps}: the parent owns the
|
|
182
|
+
* checked state. Pass `checked` and `onCheckedChange` together;
|
|
183
|
+
* `defaultChecked` is forbidden.
|
|
184
|
+
*/
|
|
185
|
+
export type DropdownCheckboxItemControlledProps =
|
|
186
|
+
DropdownCheckboxItemBaseProps & {
|
|
187
|
+
defaultChecked?: never;
|
|
188
|
+
checked: CheckedState;
|
|
189
|
+
onCheckedChange: (checked: boolean) => void;
|
|
190
|
+
};
|
|
124
191
|
|
|
192
|
+
/**
|
|
193
|
+
* Props for {@link Dropdown.CheckboxItem} — a togglable menu item. The
|
|
194
|
+
* controlled/uncontrolled discriminated union pairing
|
|
195
|
+
* {@link DropdownCheckboxItemUncontrolledProps} with
|
|
196
|
+
* {@link DropdownCheckboxItemControlledProps}.
|
|
197
|
+
*/
|
|
125
198
|
export type DropdownCheckboxItemProps =
|
|
126
199
|
| DropdownCheckboxItemUncontrolledProps
|
|
127
200
|
| DropdownCheckboxItemControlledProps;
|
|
128
201
|
|
|
129
|
-
|
|
202
|
+
/**
|
|
203
|
+
* Shared base for both {@link DropdownRadioGroupProps} variants — the native
|
|
204
|
+
* `<li>` props plus `asChild`.
|
|
205
|
+
*/
|
|
206
|
+
export type DropdownRadioGroupBaseProps = Omit<ComponentProps<"li">, "role"> & {
|
|
130
207
|
children?: ReactNode;
|
|
131
208
|
ref?: Ref<HTMLLIElement>;
|
|
132
209
|
asChild?: boolean;
|
|
133
210
|
};
|
|
134
211
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
212
|
+
/**
|
|
213
|
+
* Uncontrolled variant of {@link DropdownRadioGroupProps}: the component owns
|
|
214
|
+
* the selected value. Pass `defaultValue` (or omit it); `onValueChange` is
|
|
215
|
+
* optional and the controlled `value` prop is forbidden.
|
|
216
|
+
*/
|
|
217
|
+
export type DropdownRadioGroupUncontrolledProps =
|
|
218
|
+
DropdownRadioGroupBaseProps & {
|
|
219
|
+
defaultValue?: string;
|
|
220
|
+
value?: never;
|
|
221
|
+
onValueChange?: (value: string) => void;
|
|
222
|
+
};
|
|
140
223
|
|
|
141
|
-
|
|
224
|
+
/**
|
|
225
|
+
* Controlled variant of {@link DropdownRadioGroupProps}: the parent owns the
|
|
226
|
+
* selected value. Pass `value` and `onValueChange` together; `defaultValue` is
|
|
227
|
+
* forbidden.
|
|
228
|
+
*/
|
|
229
|
+
export type DropdownRadioGroupControlledProps = DropdownRadioGroupBaseProps & {
|
|
142
230
|
defaultValue?: never;
|
|
143
231
|
value: string;
|
|
144
232
|
onValueChange: (value: string) => void;
|
|
145
233
|
};
|
|
146
234
|
|
|
235
|
+
/**
|
|
236
|
+
* Props for {@link Dropdown.RadioGroup} — a single-select group of radio items.
|
|
237
|
+
* The controlled/uncontrolled discriminated union pairing
|
|
238
|
+
* {@link DropdownRadioGroupUncontrolledProps} with
|
|
239
|
+
* {@link DropdownRadioGroupControlledProps}.
|
|
240
|
+
*/
|
|
147
241
|
export type DropdownRadioGroupProps =
|
|
148
242
|
| DropdownRadioGroupUncontrolledProps
|
|
149
243
|
| DropdownRadioGroupControlledProps;
|
|
150
244
|
|
|
245
|
+
/**
|
|
246
|
+
* Props for {@link Dropdown.RadioItem} — one option within a
|
|
247
|
+
* {@link Dropdown.RadioGroup}. Extends the native `<li>` props and adds the
|
|
248
|
+
* required `value`, plus `disabled`, `asChild`, and `onSelect`.
|
|
249
|
+
*/
|
|
151
250
|
export type DropdownRadioItemProps = Omit<
|
|
152
251
|
ComponentProps<"li">,
|
|
153
252
|
"role" | "tabIndex" | "aria-checked" | "onSelect"
|
|
@@ -160,26 +259,50 @@ export type DropdownRadioItemProps = Omit<
|
|
|
160
259
|
onSelect?: (event: Event) => void;
|
|
161
260
|
};
|
|
162
261
|
|
|
163
|
-
|
|
262
|
+
/**
|
|
263
|
+
* Shared base for both {@link DropdownSubProps} variants — just the submenu
|
|
264
|
+
* `children`.
|
|
265
|
+
*/
|
|
266
|
+
export type DropdownSubBaseProps = {
|
|
164
267
|
children?: ReactNode;
|
|
165
268
|
};
|
|
166
269
|
|
|
167
|
-
|
|
270
|
+
/**
|
|
271
|
+
* Uncontrolled variant of {@link DropdownSubProps}: the component owns the
|
|
272
|
+
* submenu open state. Pass `defaultOpen` (or omit it); `onOpenChange` is
|
|
273
|
+
* optional and the controlled `open` prop is forbidden.
|
|
274
|
+
*/
|
|
275
|
+
export type DropdownSubUncontrolledProps = DropdownSubBaseProps & {
|
|
168
276
|
defaultOpen?: boolean;
|
|
169
277
|
open?: never;
|
|
170
278
|
onOpenChange?: (open: boolean) => void;
|
|
171
279
|
};
|
|
172
280
|
|
|
173
|
-
|
|
281
|
+
/**
|
|
282
|
+
* Controlled variant of {@link DropdownSubProps}: the parent owns the submenu
|
|
283
|
+
* open state. Pass `open` and `onOpenChange` together; `defaultOpen` is
|
|
284
|
+
* forbidden.
|
|
285
|
+
*/
|
|
286
|
+
export type DropdownSubControlledProps = DropdownSubBaseProps & {
|
|
174
287
|
defaultOpen?: never;
|
|
175
288
|
open: boolean;
|
|
176
289
|
onOpenChange: (open: boolean) => void;
|
|
177
290
|
};
|
|
178
291
|
|
|
292
|
+
/**
|
|
293
|
+
* Props for {@link Dropdown.Sub} — the root of a nested submenu. The
|
|
294
|
+
* controlled/uncontrolled discriminated union pairing
|
|
295
|
+
* {@link DropdownSubUncontrolledProps} with {@link DropdownSubControlledProps}.
|
|
296
|
+
*/
|
|
179
297
|
export type DropdownSubProps =
|
|
180
298
|
| DropdownSubUncontrolledProps
|
|
181
299
|
| DropdownSubControlledProps;
|
|
182
300
|
|
|
301
|
+
/**
|
|
302
|
+
* Props for {@link Dropdown.SubTrigger} — the item that opens a submenu.
|
|
303
|
+
* Extends the native `<li>` props (minus the ARIA attributes Dropdown owns) and
|
|
304
|
+
* adds `disabled` and `asChild`.
|
|
305
|
+
*/
|
|
183
306
|
export type DropdownSubTriggerProps = Omit<
|
|
184
307
|
ComponentProps<"li">,
|
|
185
308
|
"role" | "tabIndex" | "aria-haspopup" | "aria-expanded" | "aria-controls"
|
|
@@ -190,6 +313,11 @@ export type DropdownSubTriggerProps = Omit<
|
|
|
190
313
|
disabled?: boolean;
|
|
191
314
|
};
|
|
192
315
|
|
|
316
|
+
/**
|
|
317
|
+
* Props for {@link Dropdown.SubContent} — the popover surface of a submenu.
|
|
318
|
+
* Extends the native `<menu>` props (minus the `role`/`popover`/`id` Dropdown
|
|
319
|
+
* manages) and adds `asChild`.
|
|
320
|
+
*/
|
|
193
321
|
export type DropdownSubContentProps = Omit<
|
|
194
322
|
ComponentProps<"menu">,
|
|
195
323
|
"role" | "popover" | "id"
|
|
@@ -36,7 +36,7 @@ import {
|
|
|
36
36
|
* )}
|
|
37
37
|
* ```
|
|
38
38
|
*/
|
|
39
|
-
function EmptyStateRoot({
|
|
39
|
+
export function EmptyStateRoot({
|
|
40
40
|
asChild = false,
|
|
41
41
|
children,
|
|
42
42
|
...rest
|
|
@@ -50,6 +50,7 @@ function EmptyStateRoot({
|
|
|
50
50
|
return <div {...rootProps}>{children}</div>;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
+
/** @internal */
|
|
53
54
|
EmptyStateRoot.displayName = "EmptyStateRoot";
|
|
54
55
|
|
|
55
56
|
/**
|
|
@@ -74,7 +75,7 @@ EmptyStateRoot.displayName = "EmptyStateRoot";
|
|
|
74
75
|
* </EmptyState.Media>
|
|
75
76
|
* ```
|
|
76
77
|
*/
|
|
77
|
-
function EmptyStateMedia({
|
|
78
|
+
export function EmptyStateMedia({
|
|
78
79
|
asChild = false,
|
|
79
80
|
children,
|
|
80
81
|
...rest
|
|
@@ -88,6 +89,7 @@ function EmptyStateMedia({
|
|
|
88
89
|
return <div {...mediaProps}>{children}</div>;
|
|
89
90
|
}
|
|
90
91
|
|
|
92
|
+
/** @internal */
|
|
91
93
|
EmptyStateMedia.displayName = "EmptyStateMedia";
|
|
92
94
|
|
|
93
95
|
/**
|
|
@@ -109,7 +111,7 @@ EmptyStateMedia.displayName = "EmptyStateMedia";
|
|
|
109
111
|
* </EmptyState.Title>
|
|
110
112
|
* ```
|
|
111
113
|
*/
|
|
112
|
-
function EmptyStateTitle({
|
|
114
|
+
export function EmptyStateTitle({
|
|
113
115
|
asChild = false,
|
|
114
116
|
children,
|
|
115
117
|
...rest
|
|
@@ -121,6 +123,7 @@ function EmptyStateTitle({
|
|
|
121
123
|
return <p {...rest}>{children}</p>;
|
|
122
124
|
}
|
|
123
125
|
|
|
126
|
+
/** @internal */
|
|
124
127
|
EmptyStateTitle.displayName = "EmptyStateTitle";
|
|
125
128
|
|
|
126
129
|
/**
|
|
@@ -139,7 +142,7 @@ EmptyStateTitle.displayName = "EmptyStateTitle";
|
|
|
139
142
|
* <EmptyState.Description>Try adjusting your filters.</EmptyState.Description>
|
|
140
143
|
* ```
|
|
141
144
|
*/
|
|
142
|
-
function EmptyStateDescription({
|
|
145
|
+
export function EmptyStateDescription({
|
|
143
146
|
asChild = false,
|
|
144
147
|
children,
|
|
145
148
|
...rest
|
|
@@ -151,6 +154,7 @@ function EmptyStateDescription({
|
|
|
151
154
|
return <p {...rest}>{children}</p>;
|
|
152
155
|
}
|
|
153
156
|
|
|
157
|
+
/** @internal */
|
|
154
158
|
EmptyStateDescription.displayName = "EmptyStateDescription";
|
|
155
159
|
|
|
156
160
|
/**
|
|
@@ -173,7 +177,7 @@ EmptyStateDescription.displayName = "EmptyStateDescription";
|
|
|
173
177
|
* </EmptyState.Actions>
|
|
174
178
|
* ```
|
|
175
179
|
*/
|
|
176
|
-
function EmptyStateActions({
|
|
180
|
+
export function EmptyStateActions({
|
|
177
181
|
asChild = false,
|
|
178
182
|
children,
|
|
179
183
|
...rest
|
|
@@ -185,24 +189,23 @@ function EmptyStateActions({
|
|
|
185
189
|
return <div {...rest}>{children}</div>;
|
|
186
190
|
}
|
|
187
191
|
|
|
192
|
+
/** @internal */
|
|
188
193
|
EmptyStateActions.displayName = "EmptyStateActions";
|
|
189
194
|
|
|
190
|
-
|
|
195
|
+
/** Type of the {@link EmptyState} compound — the Root callable plus its sub-components. */
|
|
196
|
+
export type EmptyStateCompound = typeof EmptyStateRoot & {
|
|
197
|
+
/** The `<div role="status">` live region wrapping the placeholder. */
|
|
191
198
|
Root: typeof EmptyStateRoot;
|
|
199
|
+
/** The decorative icon/illustration slot. */
|
|
192
200
|
Media: typeof EmptyStateMedia;
|
|
201
|
+
/** The headline. */
|
|
193
202
|
Title: typeof EmptyStateTitle;
|
|
203
|
+
/** The supporting copy. */
|
|
194
204
|
Description: typeof EmptyStateDescription;
|
|
205
|
+
/** The recovery-action slot. */
|
|
195
206
|
Actions: typeof EmptyStateActions;
|
|
196
207
|
};
|
|
197
208
|
|
|
198
|
-
const EmptyState: EmptyStateCompound = Object.assign(EmptyStateRoot, {
|
|
199
|
-
Root: EmptyStateRoot,
|
|
200
|
-
Media: EmptyStateMedia,
|
|
201
|
-
Title: EmptyStateTitle,
|
|
202
|
-
Description: EmptyStateDescription,
|
|
203
|
-
Actions: EmptyStateActions,
|
|
204
|
-
});
|
|
205
|
-
|
|
206
209
|
/**
|
|
207
210
|
* Headless, accessible **Empty State** — a stateless compound component for
|
|
208
211
|
* the placeholder shown when a collection, search, or view has no content.
|
|
@@ -242,6 +245,15 @@ const EmptyState: EmptyStateCompound = Object.assign(EmptyStateRoot, {
|
|
|
242
245
|
* )}
|
|
243
246
|
* ```
|
|
244
247
|
*/
|
|
248
|
+
const EmptyState: EmptyStateCompound = Object.assign(EmptyStateRoot, {
|
|
249
|
+
Root: EmptyStateRoot,
|
|
250
|
+
Media: EmptyStateMedia,
|
|
251
|
+
Title: EmptyStateTitle,
|
|
252
|
+
Description: EmptyStateDescription,
|
|
253
|
+
Actions: EmptyStateActions,
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
/** @internal */
|
|
245
257
|
EmptyState.displayName = "EmptyState";
|
|
246
258
|
|
|
247
259
|
export { EmptyState };
|
package/src/EmptyState/types.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ComponentProps } from "react";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
/** Mixin adding the `asChild` opt-in to a sub-component's props. */
|
|
4
|
+
export type WithAsChild = {
|
|
4
5
|
/** Render the consumer's own element instead of the default, via `Slot`. */
|
|
5
6
|
asChild?: boolean;
|
|
6
7
|
};
|
package/src/Field/Field.tsx
CHANGED
|
@@ -46,7 +46,7 @@ import {
|
|
|
46
46
|
* </Field.Root>
|
|
47
47
|
* ```
|
|
48
48
|
*/
|
|
49
|
-
function FieldRoot({
|
|
49
|
+
export function FieldRoot({
|
|
50
50
|
id: idProp,
|
|
51
51
|
invalid = false,
|
|
52
52
|
disabled = false,
|
|
@@ -84,6 +84,7 @@ function FieldRoot({
|
|
|
84
84
|
);
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
+
/** @internal */
|
|
87
88
|
FieldRoot.displayName = "FieldRoot";
|
|
88
89
|
|
|
89
90
|
/**
|
|
@@ -95,7 +96,7 @@ FieldRoot.displayName = "FieldRoot";
|
|
|
95
96
|
*
|
|
96
97
|
* @throws If rendered outside a `<Field.Root>`.
|
|
97
98
|
*/
|
|
98
|
-
function FieldLabel({
|
|
99
|
+
export function FieldLabel({
|
|
99
100
|
asChild = false,
|
|
100
101
|
children,
|
|
101
102
|
...rest
|
|
@@ -109,6 +110,7 @@ function FieldLabel({
|
|
|
109
110
|
return <label {...labelProps}>{children}</label>;
|
|
110
111
|
}
|
|
111
112
|
|
|
113
|
+
/** @internal */
|
|
112
114
|
FieldLabel.displayName = "FieldLabel";
|
|
113
115
|
|
|
114
116
|
/**
|
|
@@ -122,7 +124,7 @@ FieldLabel.displayName = "FieldLabel";
|
|
|
122
124
|
*
|
|
123
125
|
* @throws If rendered outside a `<Field.Root>`.
|
|
124
126
|
*/
|
|
125
|
-
function FieldDescription({
|
|
127
|
+
export function FieldDescription({
|
|
126
128
|
asChild = false,
|
|
127
129
|
children,
|
|
128
130
|
...rest
|
|
@@ -136,6 +138,7 @@ function FieldDescription({
|
|
|
136
138
|
return <div {...descriptionProps}>{children}</div>;
|
|
137
139
|
}
|
|
138
140
|
|
|
141
|
+
/** @internal */
|
|
139
142
|
FieldDescription.displayName = "FieldDescription";
|
|
140
143
|
|
|
141
144
|
/**
|
|
@@ -156,7 +159,7 @@ FieldDescription.displayName = "FieldDescription";
|
|
|
156
159
|
*
|
|
157
160
|
* @throws If rendered outside a `<Field.Root>`.
|
|
158
161
|
*/
|
|
159
|
-
function FieldErrorText({
|
|
162
|
+
export function FieldErrorText({
|
|
160
163
|
asChild = false,
|
|
161
164
|
children,
|
|
162
165
|
...rest
|
|
@@ -171,12 +174,18 @@ function FieldErrorText({
|
|
|
171
174
|
return <div {...errorProps}>{children}</div>;
|
|
172
175
|
}
|
|
173
176
|
|
|
177
|
+
/** @internal */
|
|
174
178
|
FieldErrorText.displayName = "FieldErrorText";
|
|
175
179
|
|
|
176
|
-
|
|
180
|
+
/** Type of the {@link Field} compound — the Root callable plus its sub-components. */
|
|
181
|
+
export type TFieldCompound = typeof FieldRoot & {
|
|
182
|
+
/** The wrapper that owns shared field state and context. */
|
|
177
183
|
Root: typeof FieldRoot;
|
|
184
|
+
/** The field's label. */
|
|
178
185
|
Label: typeof FieldLabel;
|
|
186
|
+
/** The field's supporting helper text. */
|
|
179
187
|
Description: typeof FieldDescription;
|
|
188
|
+
/** The error message shown when invalid. */
|
|
180
189
|
ErrorText: typeof FieldErrorText;
|
|
181
190
|
};
|
|
182
191
|
|
package/src/Field/types.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ComponentProps, ReactNode } from "react";
|
|
2
2
|
|
|
3
|
+
/** Props for `Field.Root`, the wrapper that owns shared field state. */
|
|
3
4
|
export type FieldRootProps = ComponentProps<"div"> & {
|
|
4
5
|
/** Stable id wired to the control via {@link FieldLabel}'s `htmlFor`. Auto-generated via `useId` when omitted. */
|
|
5
6
|
id?: string;
|
|
@@ -14,18 +15,21 @@ export type FieldRootProps = ComponentProps<"div"> & {
|
|
|
14
15
|
children?: ReactNode;
|
|
15
16
|
};
|
|
16
17
|
|
|
18
|
+
/** Props for `Field.Label`, the field's `<label>`. */
|
|
17
19
|
export type FieldLabelProps = ComponentProps<"label"> & {
|
|
18
20
|
/** Renders the consumer element instead of `<label>` via Slot. */
|
|
19
21
|
asChild?: boolean;
|
|
20
22
|
children?: ReactNode;
|
|
21
23
|
};
|
|
22
24
|
|
|
25
|
+
/** Props for `Field.Description`, the field's supporting helper text. */
|
|
23
26
|
export type FieldDescriptionProps = ComponentProps<"div"> & {
|
|
24
27
|
/** Renders the consumer element instead of `<div>` via Slot. */
|
|
25
28
|
asChild?: boolean;
|
|
26
29
|
children?: ReactNode;
|
|
27
30
|
};
|
|
28
31
|
|
|
32
|
+
/** Props for `Field.ErrorText`, the error message shown when invalid. */
|
|
29
33
|
export type FieldErrorTextProps = ComponentProps<"div"> & {
|
|
30
34
|
/** Renders the consumer element instead of `<div>` via Slot. */
|
|
31
35
|
asChild?: boolean;
|
|
@@ -29,7 +29,7 @@ import { FieldsetLegendProps, FieldsetProps } from "./types";
|
|
|
29
29
|
* </Fieldset.Root>
|
|
30
30
|
* ```
|
|
31
31
|
*/
|
|
32
|
-
function
|
|
32
|
+
export function FieldsetRoot({
|
|
33
33
|
disabled,
|
|
34
34
|
children,
|
|
35
35
|
...rest
|
|
@@ -45,7 +45,8 @@ function Fieldset({
|
|
|
45
45
|
);
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
/** @internal */
|
|
49
|
+
FieldsetRoot.displayName = "Fieldset";
|
|
49
50
|
|
|
50
51
|
/**
|
|
51
52
|
* The caption for a {@link Fieldset} — renders a native `<legend>`.
|
|
@@ -59,25 +60,25 @@ Fieldset.displayName = "Fieldset";
|
|
|
59
60
|
* <Fieldset.Legend>Shipping address</Fieldset.Legend>
|
|
60
61
|
* ```
|
|
61
62
|
*/
|
|
62
|
-
function FieldsetLegend({
|
|
63
|
+
export function FieldsetLegend({
|
|
63
64
|
children,
|
|
64
65
|
...rest
|
|
65
66
|
}: FieldsetLegendProps): ReactElement {
|
|
66
67
|
return <legend {...rest}>{children}</legend>;
|
|
67
68
|
}
|
|
68
69
|
|
|
70
|
+
/** @internal */
|
|
69
71
|
FieldsetLegend.displayName = "FieldsetLegend";
|
|
70
72
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
+
/**
|
|
74
|
+
* The shape of the exported `Fieldset` value — callable as
|
|
75
|
+
* `Fieldset.Root` and carrying `Root` and `Legend` as static properties.
|
|
76
|
+
*/
|
|
77
|
+
export type FieldsetCompound = typeof FieldsetRoot & {
|
|
78
|
+
Root: typeof FieldsetRoot;
|
|
73
79
|
Legend: typeof FieldsetLegend;
|
|
74
80
|
};
|
|
75
81
|
|
|
76
|
-
const FieldsetCompound: FieldsetCompound = Object.assign(Fieldset, {
|
|
77
|
-
Root: Fieldset,
|
|
78
|
-
Legend: FieldsetLegend,
|
|
79
|
-
});
|
|
80
|
-
|
|
81
82
|
/**
|
|
82
83
|
* Headless, accessible **Fieldset** — a stateless compound component that
|
|
83
84
|
* groups related form controls, with zero styles.
|
|
@@ -108,6 +109,12 @@ const FieldsetCompound: FieldsetCompound = Object.assign(Fieldset, {
|
|
|
108
109
|
* </Fieldset.Root>
|
|
109
110
|
* ```
|
|
110
111
|
*/
|
|
112
|
+
const FieldsetCompound: FieldsetCompound = Object.assign(FieldsetRoot, {
|
|
113
|
+
Root: FieldsetRoot,
|
|
114
|
+
Legend: FieldsetLegend,
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
/** @internal */
|
|
111
118
|
FieldsetCompound.displayName = "Fieldset";
|
|
112
119
|
|
|
113
120
|
export { FieldsetCompound as Fieldset };
|
package/src/Fieldset/types.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { ComponentProps } from "react";
|
|
2
2
|
|
|
3
|
+
/** Props for `Fieldset.Root` — the native `<fieldset>` attributes. */
|
|
3
4
|
export type FieldsetProps = ComponentProps<"fieldset">;
|
|
4
5
|
|
|
6
|
+
/** Props for `Fieldset.Legend` — the native `<legend>` attributes. */
|
|
5
7
|
export type FieldsetLegendProps = ComponentProps<"legend">;
|
package/src/Input/Input.tsx
CHANGED
package/src/Input/types.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { ComponentProps, ReactNode, Ref } from "react";
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Props for {@link Input} — all native `<input>` attributes plus the
|
|
5
|
+
* `asChild` escape hatch and a typed `ref`.
|
|
6
|
+
*/
|
|
3
7
|
export type InputProps = ComponentProps<"input"> & {
|
|
4
8
|
asChild?: boolean;
|
|
5
9
|
ref?: Ref<HTMLInputElement>;
|