@uniflowed/ui 0.1.0 → 0.3.0
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/accordion.js +22 -9
- package/alert-dialog.js +41 -19
- package/alert.js +14 -8
- package/avatar.js +14 -8
- package/breadcrumb.js +24 -6
- package/calendar.js +54 -10
- package/carousel.js +24 -6
- package/collapsible.js +14 -3
- package/color-picker.js +22 -5
- package/combobox.js +30 -21
- package/context-menu.js +31 -2
- package/date-picker.js +37 -11
- package/date-range-picker.js +25 -8
- package/dialog.js +39 -11
- package/drawer.js +47 -34
- package/field.js +24 -6
- package/hover-card.js +14 -3
- package/index.js +107 -740
- package/input-otp.js +20 -4
- package/interactions.js +0 -1
- package/internal/collection.js +262 -95
- package/internal/focus.js +13 -4
- package/internal/roving-focus.js +12 -3
- package/internal/segmented-field.js +2 -1
- package/internal/selection.js +171 -0
- package/internal/visually-hidden-style.js +41 -0
- package/menu.js +36 -13
- package/menubar.js +32 -5
- package/navigation-menu.js +24 -6
- package/number-field.js +20 -12
- package/package.json +5 -5
- package/pagination.js +22 -5
- package/popover.js +14 -4
- package/radio-group.js +15 -4
- package/range-calendar.js +22 -3
- package/resizable.js +14 -3
- package/scroll-area.js +14 -3
- package/select.js +30 -13
- package/sheet.js +39 -18
- package/sidebar.js +31 -16
- package/skeleton.js +13 -3
- package/slider.js +15 -4
- package/table.js +34 -24
- package/tabs.js +15 -9
- package/toast.js +24 -6
- package/toggle-group.js +14 -3
- package/tooltip.js +21 -5
- package/visually-hidden.js +259 -0
package/drawer.js
CHANGED
|
@@ -62,15 +62,15 @@ import {
|
|
|
62
62
|
withoutComposed,
|
|
63
63
|
} from "./internal/merge-props.js";
|
|
64
64
|
import {
|
|
65
|
-
SheetBody,
|
|
66
|
-
SheetClose,
|
|
67
|
-
SheetDescription,
|
|
68
|
-
SheetFooter,
|
|
69
|
-
SheetHeader,
|
|
70
|
-
SheetOverlay,
|
|
71
|
-
SheetRoot,
|
|
72
|
-
SheetTitle,
|
|
73
|
-
SheetTrigger,
|
|
65
|
+
Body as SheetBody,
|
|
66
|
+
Close as SheetClose,
|
|
67
|
+
Description as SheetDescription,
|
|
68
|
+
Footer as SheetFooter,
|
|
69
|
+
Header as SheetHeader,
|
|
70
|
+
Overlay as SheetOverlay,
|
|
71
|
+
Root as SheetRoot,
|
|
72
|
+
Title as SheetTitle,
|
|
73
|
+
Trigger as SheetTrigger,
|
|
74
74
|
} from "./sheet.js";
|
|
75
75
|
import { useControlled } from "./internal/controlled-state.js";
|
|
76
76
|
|
|
@@ -132,7 +132,7 @@ hook useDrawer(part: string): DrawerState {
|
|
|
132
132
|
* `onOpenChange` behave exactly as they do everywhere else in this package,
|
|
133
133
|
* because `internal/controlled-state.js` is what answers here too.
|
|
134
134
|
*/
|
|
135
|
-
|
|
135
|
+
component DrawerRoot(
|
|
136
136
|
children: React.Node,
|
|
137
137
|
defaultOpen?: boolean = false,
|
|
138
138
|
defaultSnapPoint?: number = 0,
|
|
@@ -173,7 +173,7 @@ export component DrawerRoot(
|
|
|
173
173
|
}
|
|
174
174
|
|
|
175
175
|
/** What opens it, and what focus comes back to when it closes. */
|
|
176
|
-
|
|
176
|
+
component DrawerTrigger(children: React.Node, render?: RenderProp, ...rest: Rest) {
|
|
177
177
|
return (
|
|
178
178
|
<SheetTrigger {...forwarded(rest)} render={render}>
|
|
179
179
|
{children}
|
|
@@ -182,7 +182,7 @@ export component DrawerTrigger(children: React.Node, render?: RenderProp, ...res
|
|
|
182
182
|
}
|
|
183
183
|
|
|
184
184
|
/** The backdrop. It carries the edge, the same as a sheet's. */
|
|
185
|
-
|
|
185
|
+
component DrawerOverlay(render?: RenderProp, ...rest: Rest) {
|
|
186
186
|
return <SheetOverlay {...forwarded(rest)} render={render} />;
|
|
187
187
|
}
|
|
188
188
|
|
|
@@ -194,7 +194,7 @@ export component DrawerOverlay(render?: RenderProp, ...rest: Rest) {
|
|
|
194
194
|
* no drag to provide an alternative to — and a drawer with a handle and no
|
|
195
195
|
* `Drawer.Close` has a gesture that is the only way out.
|
|
196
196
|
*/
|
|
197
|
-
|
|
197
|
+
component DrawerBody(children: React.Node, render?: RenderProp, ...rest: Rest) {
|
|
198
198
|
const drawer = useDrawer("Drawer.Body");
|
|
199
199
|
const { bodyRef, snapIndex, snapPoints } = drawer;
|
|
200
200
|
const reducedMotion = usePrefersReducedMotion();
|
|
@@ -260,7 +260,7 @@ component RequireCloseForTheDrag() {
|
|
|
260
260
|
}
|
|
261
261
|
|
|
262
262
|
/** The top of the drawer, where the handle usually goes. */
|
|
263
|
-
|
|
263
|
+
component DrawerHeader(children: React.Node, render?: RenderProp, ...rest: Rest) {
|
|
264
264
|
return (
|
|
265
265
|
<SheetHeader {...forwarded(rest)} render={render}>
|
|
266
266
|
{children}
|
|
@@ -269,7 +269,7 @@ export component DrawerHeader(children: React.Node, render?: RenderProp, ...rest
|
|
|
269
269
|
}
|
|
270
270
|
|
|
271
271
|
/** The bottom of the drawer, where the actions go. */
|
|
272
|
-
|
|
272
|
+
component DrawerFooter(children: React.Node, render?: RenderProp, ...rest: Rest) {
|
|
273
273
|
return (
|
|
274
274
|
<SheetFooter {...forwarded(rest)} render={render}>
|
|
275
275
|
{children}
|
|
@@ -278,7 +278,7 @@ export component DrawerFooter(children: React.Node, render?: RenderProp, ...rest
|
|
|
278
278
|
}
|
|
279
279
|
|
|
280
280
|
/** The drawer's accessible name. */
|
|
281
|
-
|
|
281
|
+
component DrawerTitle(children: React.Node, render?: RenderProp, ...rest: Rest) {
|
|
282
282
|
return (
|
|
283
283
|
<SheetTitle {...forwarded(rest)} render={render}>
|
|
284
284
|
{children}
|
|
@@ -287,7 +287,7 @@ export component DrawerTitle(children: React.Node, render?: RenderProp, ...rest:
|
|
|
287
287
|
}
|
|
288
288
|
|
|
289
289
|
/** What the drawer is for, announced after its name. */
|
|
290
|
-
|
|
290
|
+
component DrawerDescription(children: React.Node, render?: RenderProp, ...rest: Rest) {
|
|
291
291
|
return (
|
|
292
292
|
<SheetDescription {...forwarded(rest)} render={render}>
|
|
293
293
|
{children}
|
|
@@ -301,7 +301,7 @@ export component DrawerDescription(children: React.Node, render?: RenderProp, ..
|
|
|
301
301
|
*
|
|
302
302
|
* It registers itself so `Drawer.Body` can tell whether the gesture has one.
|
|
303
303
|
*/
|
|
304
|
-
|
|
304
|
+
component DrawerClose(children: React.Node, render?: RenderProp, ...rest: Rest) {
|
|
305
305
|
const drawer = useDrawer("Drawer.Close");
|
|
306
306
|
const closeCountRef = drawer.closeCountRef;
|
|
307
307
|
|
|
@@ -336,11 +336,7 @@ export component DrawerClose(children: React.Node, render?: RenderProp, ...rest:
|
|
|
336
336
|
* `label` because a slider with no accessible name is announced as "slider",
|
|
337
337
|
* which is the same failure `Resizable.Handle` names.
|
|
338
338
|
*/
|
|
339
|
-
|
|
340
|
-
label?: string = "Resize the drawer",
|
|
341
|
-
render?: RenderProp,
|
|
342
|
-
...rest: Rest
|
|
343
|
-
) {
|
|
339
|
+
component DrawerHandle(label?: string = "Resize the drawer", render?: RenderProp, ...rest: Rest) {
|
|
344
340
|
const drawer = useDrawer("Drawer.Handle");
|
|
345
341
|
const { bodyRef, close, handleCountRef, setSnapIndex, side, snapIndex, snapPoints } = drawer;
|
|
346
342
|
const passed = withoutComposed(rest, [
|
|
@@ -359,17 +355,12 @@ export component DrawerHandle(
|
|
|
359
355
|
// So `Drawer.Body` knows there is a drag to provide an alternative to. A
|
|
360
356
|
// drawer with no handle has no gesture, and requiring a close button of one
|
|
361
357
|
// would be this component inventing a rule WCAG did not write.
|
|
362
|
-
useEffect(
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
},
|
|
369
|
-
// The context ref object is stable; the effect registers this part's mount.
|
|
370
|
-
// uf-lint-disable-next-line react-compiler/refs
|
|
371
|
-
[handleCountRef],
|
|
372
|
-
);
|
|
358
|
+
useEffect(() => {
|
|
359
|
+
handleCountRef.current += 1;
|
|
360
|
+
return () => {
|
|
361
|
+
handleCountRef.current -= 1;
|
|
362
|
+
};
|
|
363
|
+
}, [handleCountRef]);
|
|
373
364
|
|
|
374
365
|
/** Move by one snap point, or close when there is no smaller one. */
|
|
375
366
|
const step = (towardsOpen: boolean) => {
|
|
@@ -502,3 +493,25 @@ const CLOSES_WITH: { readonly [Edge]: string } = {
|
|
|
502
493
|
right: "ArrowRight",
|
|
503
494
|
top: "ArrowUp",
|
|
504
495
|
};
|
|
496
|
+
|
|
497
|
+
/**
|
|
498
|
+
* The parts, under the names the `Drawer` namespace gives them.
|
|
499
|
+
*
|
|
500
|
+
* `index.js` re-exports this module whole — `export * as Drawer from "./drawer.js"` —
|
|
501
|
+
* so a caller writes `<Drawer.Root>`, and the namespace is the prefix. Each
|
|
502
|
+
* part is still *declared* as `DrawerRoot`, so React DevTools, a component
|
|
503
|
+
* stack and an error name the part a reader can find rather than one of forty
|
|
504
|
+
* `Root`s.
|
|
505
|
+
*/
|
|
506
|
+
export {
|
|
507
|
+
DrawerRoot as Root,
|
|
508
|
+
DrawerTrigger as Trigger,
|
|
509
|
+
DrawerOverlay as Overlay,
|
|
510
|
+
DrawerBody as Body,
|
|
511
|
+
DrawerHandle as Handle,
|
|
512
|
+
DrawerHeader as Header,
|
|
513
|
+
DrawerFooter as Footer,
|
|
514
|
+
DrawerTitle as Title,
|
|
515
|
+
DrawerDescription as Description,
|
|
516
|
+
DrawerClose as Close,
|
|
517
|
+
};
|
package/field.js
CHANGED
|
@@ -187,7 +187,7 @@ hook useField(part: string): FieldState {
|
|
|
187
187
|
* caller saying "and also mark it invalid", which is what `invalid || source`
|
|
188
188
|
* means and what a server-side error arriving beside a client-side one needs.
|
|
189
189
|
*/
|
|
190
|
-
|
|
190
|
+
component FieldRoot(
|
|
191
191
|
children: React.Node,
|
|
192
192
|
invalid?: boolean = false,
|
|
193
193
|
required?: boolean = false,
|
|
@@ -279,7 +279,7 @@ export component FieldRoot(
|
|
|
279
279
|
* `<label for>` naming something that is not a form control is ignored by every
|
|
280
280
|
* browser, and ignored silently. The module header says more.
|
|
281
281
|
*/
|
|
282
|
-
|
|
282
|
+
component FieldLabel(children: React.Node, render?: RenderProp, ...rest: Rest) {
|
|
283
283
|
const field = useField("Field.Label");
|
|
284
284
|
// `rest` first: a caller `id` here would break the relationship the control
|
|
285
285
|
// points at, and it would break it silently.
|
|
@@ -300,7 +300,7 @@ export component FieldLabel(children: React.Node, render?: RenderProp, ...rest:
|
|
|
300
300
|
* `ref` and handlers *and* the field's attributes from one spread instead of
|
|
301
301
|
* two that overwrite each other.
|
|
302
302
|
*/
|
|
303
|
-
|
|
303
|
+
component FieldControl(render: RenderProp) {
|
|
304
304
|
const field = useField("Field.Control");
|
|
305
305
|
// A group already carries the name, the description and the validity, and a
|
|
306
306
|
// control repeating them makes a reader hear the error once for the set and
|
|
@@ -319,7 +319,7 @@ export component FieldControl(render: RenderProp) {
|
|
|
319
319
|
}
|
|
320
320
|
|
|
321
321
|
/** Help text, which the control points at while it is rendered. */
|
|
322
|
-
|
|
322
|
+
component FieldDescription(children: React.Node, render?: RenderProp, ...rest: Rest) {
|
|
323
323
|
const field = useField("Field.Description");
|
|
324
324
|
const register = field.registerDescription;
|
|
325
325
|
useEffect(() => {
|
|
@@ -338,7 +338,7 @@ export component FieldDescription(children: React.Node, render?: RenderProp, ...
|
|
|
338
338
|
* `Field.Error`, this part stays in the document even while it is empty; the
|
|
339
339
|
* control points at it only while the caller rendered the part.
|
|
340
340
|
*/
|
|
341
|
-
|
|
341
|
+
component FieldStatus(children?: React.Node, render?: RenderProp, ...rest: Rest) {
|
|
342
342
|
const field = useField("Field.Status");
|
|
343
343
|
const register = field.registerStatus;
|
|
344
344
|
useEffect(() => {
|
|
@@ -367,7 +367,7 @@ export component FieldStatus(children?: React.Node, render?: RenderProp, ...rest
|
|
|
367
367
|
* store does not need the caller to reach back into `formState.errors` for a
|
|
368
368
|
* string the source is already carrying.
|
|
369
369
|
*/
|
|
370
|
-
|
|
370
|
+
component FieldError(children?: React.Node, render?: RenderProp, ...rest: Rest) {
|
|
371
371
|
const field = useField("Field.Error");
|
|
372
372
|
const register = field.registerError;
|
|
373
373
|
useEffect(() => {
|
|
@@ -385,3 +385,21 @@ export component FieldError(children?: React.Node, render?: RenderProp, ...rest:
|
|
|
385
385
|
});
|
|
386
386
|
return render != null ? render(props) : <p {...props} />;
|
|
387
387
|
}
|
|
388
|
+
|
|
389
|
+
/**
|
|
390
|
+
* The parts, under the names the `Field` namespace gives them.
|
|
391
|
+
*
|
|
392
|
+
* `index.js` re-exports this module whole — `export * as Field from "./field.js"` —
|
|
393
|
+
* so a caller writes `<Field.Root>`, and the namespace is the prefix. Each
|
|
394
|
+
* part is still *declared* as `FieldRoot`, so React DevTools, a component
|
|
395
|
+
* stack and an error name the part a reader can find rather than one of forty
|
|
396
|
+
* `Root`s.
|
|
397
|
+
*/
|
|
398
|
+
export {
|
|
399
|
+
FieldRoot as Root,
|
|
400
|
+
FieldLabel as Label,
|
|
401
|
+
FieldControl as Control,
|
|
402
|
+
FieldDescription as Description,
|
|
403
|
+
FieldStatus as Status,
|
|
404
|
+
FieldError as Error,
|
|
405
|
+
};
|
package/hover-card.js
CHANGED
|
@@ -88,7 +88,7 @@ hook useHoverCard(part: string): HoverCardState {
|
|
|
88
88
|
* the time the reader has to reach the card, and a card holding links is a card
|
|
89
89
|
* they are reaching for.
|
|
90
90
|
*/
|
|
91
|
-
|
|
91
|
+
component HoverCardRoot(
|
|
92
92
|
children: React.Node,
|
|
93
93
|
closeDelay?: number = DEFAULT_CLOSE_DELAY,
|
|
94
94
|
defaultOpen?: boolean = false,
|
|
@@ -127,7 +127,7 @@ export component HoverCardRoot(
|
|
|
127
127
|
* reachable by keyboard, and `useFocusableTrigger` refuses anything else —
|
|
128
128
|
* a hover card on a `<span>` is one a keyboard reader can never see.
|
|
129
129
|
*/
|
|
130
|
-
|
|
130
|
+
component HoverCardTrigger(children?: React.Node, render?: RenderProp, ...rest: Rest) {
|
|
131
131
|
const card = useHoverCard("HoverCard.Trigger");
|
|
132
132
|
const { closeDelay, dismissedRef, intent, openDelay, triggerRef } = card;
|
|
133
133
|
useFocusableTrigger(triggerRef, "HoverCard.Trigger");
|
|
@@ -202,7 +202,7 @@ export component HoverCardTrigger(children?: React.Node, render?: RenderProp, ..
|
|
|
202
202
|
* because a card that took its own links away and left focus on `<body>` would
|
|
203
203
|
* send the reader back to the top of the page.
|
|
204
204
|
*/
|
|
205
|
-
|
|
205
|
+
component HoverCardBody(
|
|
206
206
|
children: React.Node,
|
|
207
207
|
align?: Align = "center",
|
|
208
208
|
alignOffset?: number = 0,
|
|
@@ -332,3 +332,14 @@ export component HoverCardBody(
|
|
|
332
332
|
|
|
333
333
|
return <div {...props} />;
|
|
334
334
|
}
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* The parts, under the names the `HoverCard` namespace gives them.
|
|
338
|
+
*
|
|
339
|
+
* `index.js` re-exports this module whole — `export * as HoverCard from "./hover-card.js"` —
|
|
340
|
+
* so a caller writes `<HoverCard.Root>`, and the namespace is the prefix. Each
|
|
341
|
+
* part is still *declared* as `HoverCardRoot`, so React DevTools, a component
|
|
342
|
+
* stack and an error name the part a reader can find rather than one of forty
|
|
343
|
+
* `Root`s.
|
|
344
|
+
*/
|
|
345
|
+
export { HoverCardRoot as Root, HoverCardTrigger as Trigger, HoverCardBody as Body };
|