@bison-lab/ui 1.7.0 → 1.8.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/dist/index.d.mts +235 -21
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +470 -145
- package/dist/index.mjs.map +1 -1
- package/dist/validators.d.mts +74 -0
- package/dist/validators.d.mts.map +1 -0
- package/dist/validators.mjs +62 -0
- package/dist/validators.mjs.map +1 -0
- package/package.json +6 -2
package/dist/index.mjs
CHANGED
|
@@ -297,11 +297,45 @@ const FormContext = React.createContext(void 0);
|
|
|
297
297
|
function useFormContext() {
|
|
298
298
|
return React.useContext(FormContext);
|
|
299
299
|
}
|
|
300
|
-
|
|
300
|
+
/**
|
|
301
|
+
* Anything that can take focus. Hidden and disabled controls are excluded —
|
|
302
|
+
* focusing either is a no-op that would strand the user mid-form.
|
|
303
|
+
*/
|
|
304
|
+
const FOCUSABLE_SELECTOR = [
|
|
305
|
+
"input:not([type=\"hidden\"]):not([disabled])",
|
|
306
|
+
"select:not([disabled])",
|
|
307
|
+
"textarea:not([disabled])",
|
|
308
|
+
"button:not([disabled])",
|
|
309
|
+
"[tabindex]:not([tabindex=\"-1\"])"
|
|
310
|
+
].join(", ");
|
|
311
|
+
/**
|
|
312
|
+
* Move focus to the first control the schema rejected (WCAG technique G139).
|
|
313
|
+
*
|
|
314
|
+
* Dives inside the invalid element when the element itself cannot hold focus:
|
|
315
|
+
* a checkbox group marks the `<fieldset>` invalid, and a fieldset is not
|
|
316
|
+
* focusable, so the first checkbox inside it is the right landing point.
|
|
317
|
+
*/
|
|
318
|
+
function focusFirstInvalid(form) {
|
|
319
|
+
const invalids = form.querySelectorAll("[aria-invalid=\"true\"]");
|
|
320
|
+
for (const el of Array.from(invalids)) {
|
|
321
|
+
const target = el.matches(FOCUSABLE_SELECTOR) ? el : el.querySelector(FOCUSABLE_SELECTOR);
|
|
322
|
+
if (target) {
|
|
323
|
+
target.focus();
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
function defaultErrorSummary(count) {
|
|
329
|
+
return count === 1 ? "1 field needs attention." : `${count} fields need attention.`;
|
|
330
|
+
}
|
|
331
|
+
const Form = React.forwardRef(({ onSubmit, schema, formMode = "native", errors: externalErrors, focusOnError = true, errorSummary = defaultErrorSummary, children, className, noValidate, ...props }, ref) => {
|
|
301
332
|
const [errors, setErrors] = React.useState({});
|
|
302
333
|
const [touched, setTouched] = React.useState({});
|
|
303
334
|
const [isSubmitting, setIsSubmitting] = React.useState(false);
|
|
304
335
|
const [errorVersion, setErrorVersion] = React.useState(0);
|
|
336
|
+
const [announcement, setAnnouncement] = React.useState("");
|
|
337
|
+
const innerRef = React.useRef(null);
|
|
338
|
+
React.useImperativeHandle(ref, () => innerRef.current);
|
|
305
339
|
const setFieldError = React.useCallback((name, error) => {
|
|
306
340
|
setErrors((prev) => ({
|
|
307
341
|
...prev,
|
|
@@ -326,7 +360,11 @@ const Form = React.forwardRef(({ onSubmit, schema, formMode = "native", children
|
|
|
326
360
|
setIsSubmitting(true);
|
|
327
361
|
setErrors({});
|
|
328
362
|
const formData = new FormData(e.currentTarget);
|
|
329
|
-
const data =
|
|
363
|
+
const data = {};
|
|
364
|
+
for (const key of Array.from(new Set(formData.keys()))) {
|
|
365
|
+
const values = formData.getAll(key);
|
|
366
|
+
data[key] = values.length > 1 ? values : values[0];
|
|
367
|
+
}
|
|
330
368
|
if (schema) try {
|
|
331
369
|
schema.parse(data);
|
|
332
370
|
} catch (err) {
|
|
@@ -338,17 +376,32 @@ const Form = React.forwardRef(({ onSubmit, schema, formMode = "native", children
|
|
|
338
376
|
}
|
|
339
377
|
setErrors(fieldErrors);
|
|
340
378
|
setErrorVersion((v) => v + 1);
|
|
379
|
+
setAnnouncement(errorSummary(Object.keys(fieldErrors).length));
|
|
341
380
|
setIsSubmitting(false);
|
|
342
381
|
return;
|
|
343
382
|
}
|
|
383
|
+
setAnnouncement("");
|
|
344
384
|
try {
|
|
345
385
|
await onSubmit?.(data);
|
|
346
386
|
} finally {
|
|
347
387
|
setIsSubmitting(false);
|
|
348
388
|
}
|
|
349
|
-
}, [
|
|
389
|
+
}, [
|
|
390
|
+
onSubmit,
|
|
391
|
+
schema,
|
|
392
|
+
errorSummary
|
|
393
|
+
]);
|
|
394
|
+
React.useEffect(() => {
|
|
395
|
+
if (!focusOnError || errorVersion === 0) return;
|
|
396
|
+
const form = innerRef.current;
|
|
397
|
+
if (form) focusFirstInvalid(form);
|
|
398
|
+
}, [errorVersion, focusOnError]);
|
|
399
|
+
const mergedErrors = React.useMemo(() => ({
|
|
400
|
+
...externalErrors,
|
|
401
|
+
...errors
|
|
402
|
+
}), [externalErrors, errors]);
|
|
350
403
|
const contextValue = React.useMemo(() => ({
|
|
351
|
-
errors,
|
|
404
|
+
errors: mergedErrors,
|
|
352
405
|
touched,
|
|
353
406
|
setFieldError,
|
|
354
407
|
clearFieldError,
|
|
@@ -357,7 +410,7 @@ const Form = React.forwardRef(({ onSubmit, schema, formMode = "native", children
|
|
|
357
410
|
formMode,
|
|
358
411
|
errorVersion
|
|
359
412
|
}), [
|
|
360
|
-
|
|
413
|
+
mergedErrors,
|
|
361
414
|
touched,
|
|
362
415
|
setFieldError,
|
|
363
416
|
clearFieldError,
|
|
@@ -368,17 +421,127 @@ const Form = React.forwardRef(({ onSubmit, schema, formMode = "native", children
|
|
|
368
421
|
]);
|
|
369
422
|
return /* @__PURE__ */ jsx(FormContext.Provider, {
|
|
370
423
|
value: contextValue,
|
|
371
|
-
children: /* @__PURE__ */
|
|
372
|
-
ref,
|
|
424
|
+
children: /* @__PURE__ */ jsxs("form", {
|
|
425
|
+
ref: innerRef,
|
|
373
426
|
onSubmit: handleSubmit,
|
|
374
427
|
className,
|
|
428
|
+
noValidate: noValidate ?? Boolean(schema),
|
|
375
429
|
...props,
|
|
376
|
-
children
|
|
430
|
+
children: [children, /* @__PURE__ */ jsx("div", {
|
|
431
|
+
"aria-live": "polite",
|
|
432
|
+
"aria-atomic": "true",
|
|
433
|
+
className: "sr-only",
|
|
434
|
+
"data-slot": "form-status",
|
|
435
|
+
children: announcement ? /* @__PURE__ */ jsx("span", { children: announcement }, errorVersion) : null
|
|
436
|
+
})]
|
|
377
437
|
})
|
|
378
438
|
});
|
|
379
439
|
});
|
|
380
440
|
Form.displayName = "Form";
|
|
381
441
|
//#endregion
|
|
442
|
+
//#region src/form/field-context.tsx
|
|
443
|
+
const FieldContext = React.createContext(void 0);
|
|
444
|
+
const FieldProvider = FieldContext.Provider;
|
|
445
|
+
/** Read the surrounding field, if there is one. */
|
|
446
|
+
function useField() {
|
|
447
|
+
return React.useContext(FieldContext);
|
|
448
|
+
}
|
|
449
|
+
/**
|
|
450
|
+
* Merge the surrounding field's ARIA wiring into a control's own props.
|
|
451
|
+
*
|
|
452
|
+
* Call it in every control that accepts user input and spread the result onto
|
|
453
|
+
* the DOM node.
|
|
454
|
+
*
|
|
455
|
+
* Inside a field the wrapper OWNS the control's `id`, and a consumer-supplied
|
|
456
|
+
* one is deliberately overridden. The wrapper has already rendered its
|
|
457
|
+
* `<label for>` pointing at the id it published, and it cannot see the child's
|
|
458
|
+
* props to follow it anywhere else — so honouring an override here would leave
|
|
459
|
+
* the label resolving to nothing, which is precisely the defect this context
|
|
460
|
+
* exists to remove. Set the id through the wrapper's `name` / `htmlFor`
|
|
461
|
+
* instead. `aria-invalid` and `aria-required` do defer to an explicit prop,
|
|
462
|
+
* and the field's description ids are APPENDED to any `aria-describedby` the
|
|
463
|
+
* consumer set rather than replacing it.
|
|
464
|
+
*
|
|
465
|
+
* Returns `props` unchanged when there is no field, or when the field is a
|
|
466
|
+
* group.
|
|
467
|
+
*/
|
|
468
|
+
function useFieldControl(props) {
|
|
469
|
+
const field = useField();
|
|
470
|
+
if (!field || field.group) return props;
|
|
471
|
+
const describedBy = [
|
|
472
|
+
field.descriptionId,
|
|
473
|
+
field.errorId,
|
|
474
|
+
props["aria-describedby"]
|
|
475
|
+
].filter(Boolean).join(" ");
|
|
476
|
+
return {
|
|
477
|
+
...props,
|
|
478
|
+
id: field.controlId,
|
|
479
|
+
"aria-invalid": props["aria-invalid"] ?? (field.invalid || void 0),
|
|
480
|
+
"aria-required": props["aria-required"] ?? (field.required || void 0),
|
|
481
|
+
"aria-describedby": describedBy || void 0
|
|
482
|
+
};
|
|
483
|
+
}
|
|
484
|
+
/**
|
|
485
|
+
* The composite-control counterpart to {@link useFieldControl}.
|
|
486
|
+
*
|
|
487
|
+
* `TimePicker` is three selects and `CodeInput` is six inputs; neither has a
|
|
488
|
+
* single element for the field's label to point at, and a `<label for>` naming
|
|
489
|
+
* a `<div>` names nothing at all. These wrap their children in a labelled
|
|
490
|
+
* `role="group"` instead, so the whole composite is announced once with its
|
|
491
|
+
* error and hint attached.
|
|
492
|
+
*
|
|
493
|
+
* Returns `{}` outside a field wrapper, leaving standalone usage untouched.
|
|
494
|
+
*/
|
|
495
|
+
function useFieldGroup() {
|
|
496
|
+
const field = useField();
|
|
497
|
+
if (!field) return {};
|
|
498
|
+
const describedBy = [field.descriptionId, field.errorId].filter(Boolean).join(" ");
|
|
499
|
+
return {
|
|
500
|
+
role: "group",
|
|
501
|
+
"aria-labelledby": field.labelId,
|
|
502
|
+
"aria-describedby": describedBy || void 0,
|
|
503
|
+
"aria-invalid": field.invalid || void 0,
|
|
504
|
+
"aria-required": field.required || void 0
|
|
505
|
+
};
|
|
506
|
+
}
|
|
507
|
+
/**
|
|
508
|
+
* Seals a composite control against the field it sits in.
|
|
509
|
+
*
|
|
510
|
+
* `CodeInput` renders six `<Input>`s and `TimePicker` renders three
|
|
511
|
+
* `<SelectTrigger>`s. Each of those calls {@link useFieldControl}, so without
|
|
512
|
+
* this they would every one of them adopt the SAME field id — six elements
|
|
513
|
+
* sharing `id="code"`, which is worse than the missing wiring this whole
|
|
514
|
+
* mechanism set out to fix. Re-providing the field in group mode turns the
|
|
515
|
+
* hook into a no-op for everything below, leaving the composite's own wrapper
|
|
516
|
+
* ({@link useFieldGroup}) as the single labelled thing.
|
|
517
|
+
*/
|
|
518
|
+
function FieldGroupScope({ children }) {
|
|
519
|
+
const field = useField();
|
|
520
|
+
return /* @__PURE__ */ jsx(FieldProvider, {
|
|
521
|
+
value: React.useMemo(() => field ? {
|
|
522
|
+
...field,
|
|
523
|
+
group: true
|
|
524
|
+
} : void 0, [field]),
|
|
525
|
+
children
|
|
526
|
+
});
|
|
527
|
+
}
|
|
528
|
+
/**
|
|
529
|
+
* Build the ids a wrapper publishes.
|
|
530
|
+
*
|
|
531
|
+
* `useId()` supplies the hint/error ids because nothing outside the wrapper
|
|
532
|
+
* references them, so uniqueness costs nothing. The control id stays
|
|
533
|
+
* caller-derived — see {@link FieldContextValue.controlId}.
|
|
534
|
+
*/
|
|
535
|
+
function useFieldIds({ controlId, hasDescription, hasError }) {
|
|
536
|
+
const reactId = React.useId();
|
|
537
|
+
return {
|
|
538
|
+
controlId,
|
|
539
|
+
descriptionId: hasDescription ? `${reactId}-description` : void 0,
|
|
540
|
+
errorId: hasError ? `${reactId}-error` : void 0,
|
|
541
|
+
labelId: `${reactId}-label`
|
|
542
|
+
};
|
|
543
|
+
}
|
|
544
|
+
//#endregion
|
|
382
545
|
//#region src/components/outlined-field.tsx
|
|
383
546
|
/**
|
|
384
547
|
* Strips border / ring from nested form controls so the outer outlined shell
|
|
@@ -397,6 +560,29 @@ function detectControlKind(shell) {
|
|
|
397
560
|
return "other";
|
|
398
561
|
}
|
|
399
562
|
const OutlinedField = React.forwardRef(({ label, htmlFor, error, errorVersion = 0, hint, required, className, children }, ref) => {
|
|
563
|
+
const fallbackId = React.useId();
|
|
564
|
+
const controlId = htmlFor ?? `${fallbackId}-control`;
|
|
565
|
+
const { descriptionId, errorId, labelId } = useFieldIds({
|
|
566
|
+
controlId,
|
|
567
|
+
hasDescription: Boolean(hint) && !error,
|
|
568
|
+
hasError: Boolean(error)
|
|
569
|
+
});
|
|
570
|
+
const field = React.useMemo(() => ({
|
|
571
|
+
controlId,
|
|
572
|
+
descriptionId,
|
|
573
|
+
errorId,
|
|
574
|
+
labelId,
|
|
575
|
+
invalid: Boolean(error),
|
|
576
|
+
required: Boolean(required),
|
|
577
|
+
group: false
|
|
578
|
+
}), [
|
|
579
|
+
controlId,
|
|
580
|
+
descriptionId,
|
|
581
|
+
errorId,
|
|
582
|
+
labelId,
|
|
583
|
+
error,
|
|
584
|
+
required
|
|
585
|
+
]);
|
|
400
586
|
const shellRef = React.useRef(null);
|
|
401
587
|
const [focused, setFocused] = React.useState(false);
|
|
402
588
|
const [hasValue, setHasValue] = React.useState(false);
|
|
@@ -456,53 +642,84 @@ const OutlinedField = React.forwardRef(({ label, htmlFor, error, errorVersion =
|
|
|
456
642
|
x: 0,
|
|
457
643
|
y: "-50%"
|
|
458
644
|
};
|
|
459
|
-
return /* @__PURE__ */
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
645
|
+
return /* @__PURE__ */ jsx(FieldProvider, {
|
|
646
|
+
value: field,
|
|
647
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
648
|
+
ref,
|
|
649
|
+
className: cn("flex flex-col gap-1.5", className),
|
|
650
|
+
children: [
|
|
651
|
+
/* @__PURE__ */ jsxs("div", {
|
|
652
|
+
ref: shellRef,
|
|
653
|
+
className: cn("group/outlined relative w-full min-w-0 rounded-md border border-input bg-background", "ring-offset-background", "focus-within:border-primary focus-within:ring-2 focus-within:ring-primary/30 focus-within:ring-offset-0", error && "border-destructive bison-shake", outlinedFieldNestResetClasses, isTextarea ? "flex min-h-[80px] flex-col py-2" : "flex h-[var(--density-height-md)] items-stretch pointer-coarse:min-h-11", !isFloated && !focused && "[&_input]:placeholder:text-transparent [&_textarea]:placeholder:text-transparent"),
|
|
654
|
+
onInputCapture: handleInputCapture,
|
|
655
|
+
children: [/* @__PURE__ */ jsxs(motion.label, {
|
|
656
|
+
id: labelId,
|
|
657
|
+
htmlFor: controlId,
|
|
658
|
+
className: cn("pointer-events-none absolute z-10 bg-background px-1 font-medium leading-none text-muted-foreground", isFloated ? "text-xs" : "text-base", focused && "text-primary"),
|
|
659
|
+
style: { transformOrigin: "left center" },
|
|
660
|
+
initial: false,
|
|
661
|
+
animate: labelAnimate,
|
|
662
|
+
transition: {
|
|
663
|
+
type: "spring",
|
|
664
|
+
stiffness: 520,
|
|
665
|
+
damping: 34
|
|
666
|
+
},
|
|
667
|
+
children: [label, required ? /* @__PURE__ */ jsx("span", {
|
|
668
|
+
"aria-hidden": "true",
|
|
669
|
+
className: "ml-0.5 text-destructive",
|
|
670
|
+
children: "*"
|
|
671
|
+
}) : null]
|
|
672
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
673
|
+
className: cn("box-border flex min-h-0 min-w-0 flex-1", isTextarea ? "items-stretch pt-4 [&>*]:flex [&>*]:min-h-0 [&>*]:min-w-0 [&>*]:flex-1" : "items-stretch [&>*]:min-h-0 [&>*]:min-w-0 [&>*]:flex-1"),
|
|
674
|
+
children
|
|
675
|
+
})]
|
|
676
|
+
}),
|
|
677
|
+
error ? /* @__PURE__ */ jsx("p", {
|
|
678
|
+
id: errorId,
|
|
679
|
+
className: "text-sm leading-none text-destructive",
|
|
680
|
+
children: error
|
|
681
|
+
}) : null,
|
|
682
|
+
!error && hint ? /* @__PURE__ */ jsx("p", {
|
|
683
|
+
id: descriptionId,
|
|
684
|
+
className: "text-sm leading-none text-muted-foreground",
|
|
685
|
+
children: hint
|
|
686
|
+
}) : null
|
|
687
|
+
]
|
|
688
|
+
})
|
|
496
689
|
});
|
|
497
690
|
});
|
|
498
691
|
OutlinedField.displayName = "OutlinedField";
|
|
499
692
|
//#endregion
|
|
500
693
|
//#region src/form/form-field.tsx
|
|
501
|
-
function FormField({ name, label, description, required, labelLayout = "stack", className, children }) {
|
|
694
|
+
function FormField({ name, label, description, required, labelLayout = "stack", as = "field", className, children }) {
|
|
502
695
|
const formCtx = useFormContext();
|
|
503
696
|
const errorMessage = formCtx?.errors[name];
|
|
504
697
|
const errorVersion = formCtx?.errorVersion ?? 0;
|
|
505
698
|
const wrapRef = React.useRef(null);
|
|
699
|
+
const { controlId, descriptionId, errorId, labelId } = useFieldIds({
|
|
700
|
+
controlId: name,
|
|
701
|
+
hasDescription: Boolean(description) && !errorMessage,
|
|
702
|
+
hasError: Boolean(errorMessage)
|
|
703
|
+
});
|
|
704
|
+
const isGroup = as === "group";
|
|
705
|
+
const field = React.useMemo(() => ({
|
|
706
|
+
controlId,
|
|
707
|
+
descriptionId,
|
|
708
|
+
errorId,
|
|
709
|
+
labelId: label ? labelId : void 0,
|
|
710
|
+
invalid: Boolean(errorMessage),
|
|
711
|
+
required: Boolean(required),
|
|
712
|
+
group: isGroup
|
|
713
|
+
}), [
|
|
714
|
+
controlId,
|
|
715
|
+
descriptionId,
|
|
716
|
+
errorId,
|
|
717
|
+
labelId,
|
|
718
|
+
label,
|
|
719
|
+
errorMessage,
|
|
720
|
+
required,
|
|
721
|
+
isGroup
|
|
722
|
+
]);
|
|
506
723
|
React.useEffect(() => {
|
|
507
724
|
const el = wrapRef.current;
|
|
508
725
|
if (!el || !errorMessage) return;
|
|
@@ -510,7 +727,7 @@ function FormField({ name, label, description, required, labelLayout = "stack",
|
|
|
510
727
|
el.offsetWidth;
|
|
511
728
|
el.style.animation = "";
|
|
512
729
|
}, [errorVersion, errorMessage]);
|
|
513
|
-
if (label && labelLayout === "outlined") return /* @__PURE__ */ jsx(OutlinedField, {
|
|
730
|
+
if (!isGroup && label && labelLayout === "outlined") return /* @__PURE__ */ jsx(OutlinedField, {
|
|
514
731
|
label,
|
|
515
732
|
htmlFor: name,
|
|
516
733
|
required,
|
|
@@ -520,28 +737,56 @@ function FormField({ name, label, description, required, labelLayout = "stack",
|
|
|
520
737
|
className,
|
|
521
738
|
children
|
|
522
739
|
});
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
740
|
+
const describedBy = [descriptionId, errorId].filter(Boolean).join(" ") || void 0;
|
|
741
|
+
const messages = /* @__PURE__ */ jsxs(Fragment, { children: [description && !errorMessage && /* @__PURE__ */ jsx("p", {
|
|
742
|
+
id: descriptionId,
|
|
743
|
+
className: "mt-1.5 text-sm leading-none text-muted-foreground",
|
|
744
|
+
children: description
|
|
745
|
+
}), errorMessage && /* @__PURE__ */ jsx("p", {
|
|
746
|
+
id: errorId,
|
|
747
|
+
className: "mt-1.5 text-sm leading-none text-destructive",
|
|
748
|
+
children: errorMessage
|
|
749
|
+
})] });
|
|
750
|
+
const requiredMark = required ? /* @__PURE__ */ jsx("span", {
|
|
751
|
+
"aria-hidden": "true",
|
|
752
|
+
className: "text-destructive ml-1",
|
|
753
|
+
children: "*"
|
|
754
|
+
}) : null;
|
|
755
|
+
if (isGroup) return /* @__PURE__ */ jsx(FieldProvider, {
|
|
756
|
+
value: field,
|
|
757
|
+
children: /* @__PURE__ */ jsxs("fieldset", {
|
|
758
|
+
ref: wrapRef,
|
|
759
|
+
className: cn("flex flex-col", errorMessage && "bison-shake", className),
|
|
760
|
+
"aria-describedby": describedBy,
|
|
761
|
+
"aria-invalid": errorMessage ? true : void 0,
|
|
762
|
+
"aria-required": required || void 0,
|
|
763
|
+
children: [
|
|
764
|
+
label && /* @__PURE__ */ jsxs("legend", {
|
|
765
|
+
id: labelId,
|
|
766
|
+
className: "mb-1.5 text-sm font-medium leading-none",
|
|
767
|
+
children: [label, requiredMark]
|
|
768
|
+
}),
|
|
769
|
+
children,
|
|
770
|
+
messages
|
|
771
|
+
]
|
|
772
|
+
})
|
|
773
|
+
});
|
|
774
|
+
return /* @__PURE__ */ jsx(FieldProvider, {
|
|
775
|
+
value: field,
|
|
776
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
777
|
+
ref: wrapRef,
|
|
778
|
+
className: cn("flex flex-col", errorMessage && "bison-shake", className),
|
|
779
|
+
children: [
|
|
780
|
+
label && /* @__PURE__ */ jsxs("label", {
|
|
781
|
+
id: labelId,
|
|
782
|
+
htmlFor: controlId,
|
|
783
|
+
className: "mb-1.5 text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
|
|
784
|
+
children: [label, requiredMark]
|
|
785
|
+
}),
|
|
786
|
+
children,
|
|
787
|
+
messages
|
|
788
|
+
]
|
|
789
|
+
})
|
|
545
790
|
});
|
|
546
791
|
}
|
|
547
792
|
//#endregion
|
|
@@ -747,26 +992,29 @@ const centeredModalContentClasses = "fixed left-[50%] top-[50%] z-[var(--z-modal
|
|
|
747
992
|
//#endregion
|
|
748
993
|
//#region src/components/input.tsx
|
|
749
994
|
const Input = React.forwardRef(({ className, type, ...props }, ref) => {
|
|
995
|
+
const fieldProps = useFieldControl(props);
|
|
750
996
|
return /* @__PURE__ */ jsx("input", {
|
|
751
997
|
type,
|
|
752
998
|
className: cn(inputSurfaceClasses, inputSizingClasses("md"), inputFocusClasses, "file:border-0 file:bg-transparent file:text-base file:font-medium sm:file:text-sm", className),
|
|
753
999
|
ref,
|
|
754
|
-
...
|
|
1000
|
+
...fieldProps
|
|
755
1001
|
});
|
|
756
1002
|
});
|
|
757
1003
|
Input.displayName = "Input";
|
|
758
1004
|
//#endregion
|
|
759
1005
|
//#region src/components/password-input.tsx
|
|
760
|
-
const PasswordInput = React.forwardRef(({ className, ...props }, ref) => {
|
|
1006
|
+
const PasswordInput = React.forwardRef(({ className, toggleLabel = "Show or hide password", ...props }, ref) => {
|
|
1007
|
+
const fieldProps = useFieldControl(props);
|
|
761
1008
|
return /* @__PURE__ */ jsx(unstable_PasswordToggleField.Root, { children: /* @__PURE__ */ jsxs("div", {
|
|
762
1009
|
className: "relative",
|
|
763
1010
|
children: [/* @__PURE__ */ jsx(unstable_PasswordToggleField.Input, {
|
|
764
1011
|
className: cn(inputSurfaceClasses, inputSizingClasses("md"), inputFocusClasses, "pr-10 file:border-0 file:bg-transparent file:text-base file:font-medium sm:file:text-sm", className),
|
|
765
1012
|
ref,
|
|
766
|
-
...
|
|
1013
|
+
...fieldProps
|
|
767
1014
|
}), /* @__PURE__ */ jsx(unstable_PasswordToggleField.Toggle, {
|
|
768
1015
|
className: "absolute right-0 top-0 flex h-full w-10 items-center justify-center text-muted-foreground hover:text-foreground transition-colors disabled:pointer-events-none disabled:opacity-50",
|
|
769
1016
|
disabled: props.disabled,
|
|
1017
|
+
"aria-label": toggleLabel,
|
|
770
1018
|
children: /* @__PURE__ */ jsx(unstable_PasswordToggleField.Icon, {
|
|
771
1019
|
visible: /* @__PURE__ */ jsx(EyeOff, { className: "h-4 w-4" }),
|
|
772
1020
|
hidden: /* @__PURE__ */ jsx(Eye, { className: "h-4 w-4" })
|
|
@@ -777,7 +1025,8 @@ const PasswordInput = React.forwardRef(({ className, ...props }, ref) => {
|
|
|
777
1025
|
PasswordInput.displayName = "PasswordInput";
|
|
778
1026
|
//#endregion
|
|
779
1027
|
//#region src/components/code-input.tsx
|
|
780
|
-
const CodeInput = React.forwardRef(({ length = 6, onComplete, onChange, loading = false, disabled = false, className }, ref) => {
|
|
1028
|
+
const CodeInput = React.forwardRef(({ length = 6, onComplete, onChange, loading = false, disabled = false, className, digitLabel = (position, total) => `Digit ${position} of ${total}` }, ref) => {
|
|
1029
|
+
const groupProps = useFieldGroup();
|
|
781
1030
|
const [code, setCode] = React.useState(Array(length).fill(""));
|
|
782
1031
|
const inputRefs = React.useRef([]);
|
|
783
1032
|
const updateCode = React.useCallback((newCode) => {
|
|
@@ -816,7 +1065,8 @@ const CodeInput = React.forwardRef(({ length = 6, onComplete, onChange, loading
|
|
|
816
1065
|
ref,
|
|
817
1066
|
className: cn("flex justify-center gap-2", className),
|
|
818
1067
|
onPaste: handlePaste,
|
|
819
|
-
|
|
1068
|
+
...groupProps,
|
|
1069
|
+
children: /* @__PURE__ */ jsx(FieldGroupScope, { children: code.map((digit, index) => /* @__PURE__ */ jsx(Input, {
|
|
820
1070
|
ref: (el) => {
|
|
821
1071
|
inputRefs.current[index] = el;
|
|
822
1072
|
},
|
|
@@ -828,8 +1078,9 @@ const CodeInput = React.forwardRef(({ length = 6, onComplete, onChange, loading
|
|
|
828
1078
|
onKeyDown: (e) => handleKeyDown(index, e),
|
|
829
1079
|
disabled: loading || disabled,
|
|
830
1080
|
className: "h-12 w-12 text-center text-lg font-semibold",
|
|
831
|
-
autoFocus: index === 0
|
|
832
|
-
|
|
1081
|
+
autoFocus: index === 0,
|
|
1082
|
+
"aria-label": digitLabel(index + 1, length)
|
|
1083
|
+
}, index)) })
|
|
833
1084
|
});
|
|
834
1085
|
});
|
|
835
1086
|
CodeInput.displayName = "CodeInput";
|
|
@@ -856,6 +1107,7 @@ function fromCents(cents) {
|
|
|
856
1107
|
return (cents / 100).toFixed(2);
|
|
857
1108
|
}
|
|
858
1109
|
const CurrencyInput = React.forwardRef(({ className, value, onChange, symbol = "$", ...props }, ref) => {
|
|
1110
|
+
const fieldProps = useFieldControl(props);
|
|
859
1111
|
const [display, setDisplay] = React.useState(() => fromCents(value));
|
|
860
1112
|
const prevValue = React.useRef(value);
|
|
861
1113
|
if (value !== prevValue.current) {
|
|
@@ -886,15 +1138,14 @@ const CurrencyInput = React.forwardRef(({ className, value, onChange, symbol = "
|
|
|
886
1138
|
onChange: handleChange,
|
|
887
1139
|
onBlur: handleBlur,
|
|
888
1140
|
className: cn(inputSurfaceClasses, inputSizingClasses("md"), inputFocusClasses, "pl-7 pr-3 text-sm", className),
|
|
889
|
-
...
|
|
1141
|
+
...fieldProps
|
|
890
1142
|
})]
|
|
891
1143
|
});
|
|
892
1144
|
});
|
|
893
1145
|
CurrencyInput.displayName = "CurrencyInput";
|
|
894
1146
|
//#endregion
|
|
895
|
-
//#region src/
|
|
1147
|
+
//#region src/lib/us-phone.ts
|
|
896
1148
|
const PHONE_MAX_DIGITS = 10;
|
|
897
|
-
const PHONE_MAX_LENGTH = 14;
|
|
898
1149
|
/** Strips non-digits and caps at 10 (US NANP). */
|
|
899
1150
|
function parseUsPhoneDigits(value) {
|
|
900
1151
|
return value.replace(/\D/g, "").slice(0, PHONE_MAX_DIGITS);
|
|
@@ -906,6 +1157,22 @@ function formatUsPhone(value) {
|
|
|
906
1157
|
if (d.length <= 6) return `(${d.slice(0, 3)}) ${d.slice(3)}`;
|
|
907
1158
|
return `(${d.slice(0, 3)}) ${d.slice(3, 6)}-${d.slice(6)}`;
|
|
908
1159
|
}
|
|
1160
|
+
/**
|
|
1161
|
+
* Deliberately NOT a `'use client'` module, and deliberately not living in
|
|
1162
|
+
* `phone-input.tsx` any more.
|
|
1163
|
+
*
|
|
1164
|
+
* `validators.ts` needs `parseUsPhoneDigits`, and it is consumed from Server
|
|
1165
|
+
* Actions. Importing it from the component file dragged the whole client
|
|
1166
|
+
* component in behind it, and every output of the main entry carries a
|
|
1167
|
+
* `"use client"` banner — so calling the validator on the server failed with
|
|
1168
|
+
* "Attempted to call … from the server but … is on the client".
|
|
1169
|
+
*
|
|
1170
|
+
* Keep this file free of React, and free of imports from anything holding a
|
|
1171
|
+
* `'use client'` directive.
|
|
1172
|
+
*/
|
|
1173
|
+
//#endregion
|
|
1174
|
+
//#region src/components/phone-input.tsx
|
|
1175
|
+
const PHONE_MAX_LENGTH = 14;
|
|
909
1176
|
const PhoneInput = React.forwardRef(function PhoneInput({ value: valueProp, defaultValue = "", onChange, autoComplete = "tel", ...props }, ref) {
|
|
910
1177
|
const isControlled = valueProp !== void 0;
|
|
911
1178
|
const [uncontrolledDigits, setUncontrolledDigits] = React.useState(() => parseUsPhoneDigits(defaultValue));
|
|
@@ -945,47 +1212,78 @@ Label.displayName = Label$1.Root.displayName;
|
|
|
945
1212
|
//#endregion
|
|
946
1213
|
//#region src/components/input-group.tsx
|
|
947
1214
|
const InputGroup = React.forwardRef(({ label, htmlFor, error, hint, required, labelLayout = "stack", className, children }, ref) => {
|
|
1215
|
+
const fallbackId = React.useId();
|
|
1216
|
+
const controlId = htmlFor ?? `${fallbackId}-control`;
|
|
1217
|
+
const { descriptionId, errorId, labelId } = useFieldIds({
|
|
1218
|
+
controlId,
|
|
1219
|
+
hasDescription: Boolean(hint) && !error,
|
|
1220
|
+
hasError: Boolean(error)
|
|
1221
|
+
});
|
|
1222
|
+
const field = React.useMemo(() => ({
|
|
1223
|
+
controlId,
|
|
1224
|
+
descriptionId,
|
|
1225
|
+
errorId,
|
|
1226
|
+
labelId,
|
|
1227
|
+
invalid: Boolean(error),
|
|
1228
|
+
required: Boolean(required),
|
|
1229
|
+
group: false
|
|
1230
|
+
}), [
|
|
1231
|
+
controlId,
|
|
1232
|
+
descriptionId,
|
|
1233
|
+
errorId,
|
|
1234
|
+
labelId,
|
|
1235
|
+
error,
|
|
1236
|
+
required
|
|
1237
|
+
]);
|
|
948
1238
|
if (labelLayout === "outlined") return /* @__PURE__ */ jsx(OutlinedField, {
|
|
949
1239
|
ref,
|
|
950
1240
|
label,
|
|
951
|
-
htmlFor,
|
|
1241
|
+
htmlFor: controlId,
|
|
952
1242
|
error,
|
|
953
1243
|
hint,
|
|
954
1244
|
required,
|
|
955
1245
|
className,
|
|
956
1246
|
children
|
|
957
1247
|
});
|
|
958
|
-
return /* @__PURE__ */
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
1248
|
+
return /* @__PURE__ */ jsx(FieldProvider, {
|
|
1249
|
+
value: field,
|
|
1250
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
1251
|
+
ref,
|
|
1252
|
+
className: cn("flex flex-col gap-2", className),
|
|
1253
|
+
children: [
|
|
1254
|
+
/* @__PURE__ */ jsxs(Label, {
|
|
1255
|
+
id: labelId,
|
|
1256
|
+
htmlFor: controlId,
|
|
1257
|
+
children: [label, required && /* @__PURE__ */ jsx("span", {
|
|
1258
|
+
"aria-hidden": "true",
|
|
1259
|
+
className: "ml-0.5 text-destructive",
|
|
1260
|
+
children: "*"
|
|
1261
|
+
})]
|
|
1262
|
+
}),
|
|
1263
|
+
children,
|
|
1264
|
+
error && /* @__PURE__ */ jsx("p", {
|
|
1265
|
+
id: errorId,
|
|
1266
|
+
className: "text-sm text-destructive",
|
|
1267
|
+
children: error
|
|
1268
|
+
}),
|
|
1269
|
+
!error && hint && /* @__PURE__ */ jsx("p", {
|
|
1270
|
+
id: descriptionId,
|
|
1271
|
+
className: "text-sm text-muted-foreground",
|
|
1272
|
+
children: hint
|
|
1273
|
+
})
|
|
1274
|
+
]
|
|
1275
|
+
})
|
|
979
1276
|
});
|
|
980
1277
|
});
|
|
981
1278
|
InputGroup.displayName = "InputGroup";
|
|
982
1279
|
//#endregion
|
|
983
1280
|
//#region src/components/textarea.tsx
|
|
984
1281
|
const Textarea = React.forwardRef(({ className, ...props }, ref) => {
|
|
1282
|
+
const fieldProps = useFieldControl(props);
|
|
985
1283
|
return /* @__PURE__ */ jsx("textarea", {
|
|
986
1284
|
className: cn(inputSurfaceClasses, "min-h-[80px] px-3 py-2", inputFocusClasses, className),
|
|
987
1285
|
ref,
|
|
988
|
-
...
|
|
1286
|
+
...fieldProps
|
|
989
1287
|
});
|
|
990
1288
|
});
|
|
991
1289
|
Textarea.displayName = "Textarea";
|
|
@@ -994,15 +1292,18 @@ Textarea.displayName = "Textarea";
|
|
|
994
1292
|
const Select = Select$1.Root;
|
|
995
1293
|
const SelectGroup = Select$1.Group;
|
|
996
1294
|
const SelectValue = Select$1.Value;
|
|
997
|
-
const SelectTrigger = React.forwardRef(({ className, children, ...props }, ref) =>
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
children: /* @__PURE__ */ jsx(
|
|
1004
|
-
|
|
1005
|
-
})
|
|
1295
|
+
const SelectTrigger = React.forwardRef(({ className, children, ...props }, ref) => {
|
|
1296
|
+
const fieldProps = useFieldControl(props);
|
|
1297
|
+
return /* @__PURE__ */ jsxs(Select$1.Trigger, {
|
|
1298
|
+
ref,
|
|
1299
|
+
className: cn(inputSurfaceClasses, inputSizingClasses("md"), inputFocusClasses, "items-center justify-between [&>span]:line-clamp-1", className),
|
|
1300
|
+
...fieldProps,
|
|
1301
|
+
children: [children, /* @__PURE__ */ jsx(Select$1.Icon, {
|
|
1302
|
+
asChild: true,
|
|
1303
|
+
children: /* @__PURE__ */ jsx(ChevronDown, { className: "h-4 w-4 opacity-50" })
|
|
1304
|
+
})]
|
|
1305
|
+
});
|
|
1306
|
+
});
|
|
1006
1307
|
SelectTrigger.displayName = Select$1.Trigger.displayName;
|
|
1007
1308
|
const SelectScrollUpButton = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(Select$1.ScrollUpButton, {
|
|
1008
1309
|
ref,
|
|
@@ -1105,6 +1406,7 @@ PopoverContent.displayName = Popover$1.Content.displayName;
|
|
|
1105
1406
|
//#endregion
|
|
1106
1407
|
//#region src/components/date-picker.tsx
|
|
1107
1408
|
const DatePicker = React.forwardRef(({ value, onChange, placeholder = "Pick a date", dateFormat = "PPP", disabled = false, className, fromDate, toDate, disabledDates }, ref) => {
|
|
1409
|
+
const fieldProps = useFieldControl({});
|
|
1108
1410
|
const [open, setOpen] = React.useState(false);
|
|
1109
1411
|
const handleSelect = (date) => {
|
|
1110
1412
|
onChange?.(date);
|
|
@@ -1120,6 +1422,7 @@ const DatePicker = React.forwardRef(({ value, onChange, placeholder = "Pick a da
|
|
|
1120
1422
|
variant: "outline",
|
|
1121
1423
|
disabled,
|
|
1122
1424
|
className: cn("w-full justify-start text-left font-normal", !value && "text-muted-foreground", className),
|
|
1425
|
+
...fieldProps,
|
|
1123
1426
|
children: [/* @__PURE__ */ jsx(Calendar$1, { className: "mr-2 h-4 w-4" }), value ? format(value, dateFormat) : /* @__PURE__ */ jsx("span", { children: placeholder })]
|
|
1124
1427
|
})
|
|
1125
1428
|
}), /* @__PURE__ */ jsx(PopoverContent, {
|
|
@@ -1189,6 +1492,7 @@ function formatTimeValue(parts) {
|
|
|
1189
1492
|
return `${pad2(hour24)}:${pad2(parts.minute)}`;
|
|
1190
1493
|
}
|
|
1191
1494
|
const TimePicker = React.forwardRef(({ value, onChange, minuteStep = 5, size = "md", disabled = false, placeholder, className }, ref) => {
|
|
1495
|
+
const groupProps = useFieldGroup();
|
|
1192
1496
|
const [partial, setPartial] = React.useState({});
|
|
1193
1497
|
const parsedValue = parseTimeValue(value);
|
|
1194
1498
|
const isControlled = parsedValue.hour12 !== void 0;
|
|
@@ -1215,10 +1519,11 @@ const TimePicker = React.forwardRef(({ value, onChange, minuteStep = 5, size = "
|
|
|
1215
1519
|
}));
|
|
1216
1520
|
}
|
|
1217
1521
|
const triggerClassName = cn(inputSizingClasses(size), "w-auto min-w-0");
|
|
1218
|
-
return /* @__PURE__ */
|
|
1522
|
+
return /* @__PURE__ */ jsx("div", {
|
|
1219
1523
|
ref,
|
|
1220
1524
|
className: cn("flex gap-2", className),
|
|
1221
|
-
|
|
1525
|
+
...groupProps,
|
|
1526
|
+
children: /* @__PURE__ */ jsxs(FieldGroupScope, { children: [
|
|
1222
1527
|
/* @__PURE__ */ jsxs(Select, {
|
|
1223
1528
|
disabled,
|
|
1224
1529
|
value: toSegmentValue(parts.hour12),
|
|
@@ -1270,7 +1575,7 @@ const TimePicker = React.forwardRef(({ value, onChange, minuteStep = 5, size = "
|
|
|
1270
1575
|
children: "PM"
|
|
1271
1576
|
})] })]
|
|
1272
1577
|
})
|
|
1273
|
-
]
|
|
1578
|
+
] })
|
|
1274
1579
|
});
|
|
1275
1580
|
});
|
|
1276
1581
|
TimePicker.displayName = "TimePicker";
|
|
@@ -1378,6 +1683,7 @@ const dateRangePresets = {
|
|
|
1378
1683
|
})
|
|
1379
1684
|
};
|
|
1380
1685
|
const DateRangePicker = React.forwardRef(({ value, onChange, placeholder = "Pick a date range", dateFormat = "LLL dd, y", disabled = false, className, presets, numberOfMonths = 2, fromDate, toDate, clearable = true, clearLabel = "Clear date range" }, ref) => {
|
|
1686
|
+
const fieldProps = useFieldControl({});
|
|
1381
1687
|
const [open, setOpen] = React.useState(false);
|
|
1382
1688
|
const handlePresetClick = (preset) => {
|
|
1383
1689
|
const range = preset.range();
|
|
@@ -1401,6 +1707,7 @@ const DateRangePicker = React.forwardRef(({ value, onChange, placeholder = "Pick
|
|
|
1401
1707
|
variant: "outline",
|
|
1402
1708
|
disabled,
|
|
1403
1709
|
className: cn("w-full justify-start text-left font-normal", !value && "text-muted-foreground", showClear && "pr-9", className),
|
|
1710
|
+
...fieldProps,
|
|
1404
1711
|
children: [/* @__PURE__ */ jsx(Calendar$1, { className: "mr-2 h-4 w-4" }), value?.from ? value.to ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1405
1712
|
format(value.from, dateFormat),
|
|
1406
1713
|
" –",
|
|
@@ -1742,24 +2049,30 @@ function IndeterminateIcon({ className }) {
|
|
|
1742
2049
|
})
|
|
1743
2050
|
});
|
|
1744
2051
|
}
|
|
1745
|
-
const Checkbox = React.forwardRef(({ className, checked, ...props }, ref) =>
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
children:
|
|
1753
|
-
|
|
1754
|
-
}))
|
|
2052
|
+
const Checkbox = React.forwardRef(({ className, checked, ...props }, ref) => {
|
|
2053
|
+
const fieldProps = useFieldControl(props);
|
|
2054
|
+
return /* @__PURE__ */ jsx(Checkbox$1.Root, {
|
|
2055
|
+
ref,
|
|
2056
|
+
checked,
|
|
2057
|
+
className: cn("peer h-4 w-4 shrink-0 cursor-pointer rounded-[2px] border border-primary bg-background ring-offset-background transition-[color,background-color,border-color] duration-fast ease-default focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary/35 focus-visible:ring-offset-1 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:border-primary data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground data-[state=indeterminate]:border-primary data-[state=indeterminate]:bg-primary data-[state=indeterminate]:text-primary-foreground", coarseHitAreaClasses, className),
|
|
2058
|
+
...fieldProps,
|
|
2059
|
+
children: /* @__PURE__ */ jsx(Checkbox$1.Indicator, {
|
|
2060
|
+
className: cn("flex h-full w-full items-center justify-center text-current"),
|
|
2061
|
+
children: checked === "indeterminate" ? /* @__PURE__ */ jsx(IndeterminateIcon, { className: "h-[10px] w-[10px]" }) : /* @__PURE__ */ jsx(CheckIcon, { className: "h-[10px] w-[10px]" })
|
|
2062
|
+
})
|
|
2063
|
+
});
|
|
2064
|
+
});
|
|
1755
2065
|
Checkbox.displayName = Checkbox$1.Root.displayName;
|
|
1756
2066
|
//#endregion
|
|
1757
2067
|
//#region src/components/radio-group.tsx
|
|
1758
|
-
const RadioGroup = React.forwardRef(({ className, ...props }, ref) =>
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
2068
|
+
const RadioGroup = React.forwardRef(({ className, ...props }, ref) => {
|
|
2069
|
+
const fieldProps = useFieldControl(props);
|
|
2070
|
+
return /* @__PURE__ */ jsx(RadioGroup$1.Root, {
|
|
2071
|
+
className: cn("grid gap-2", className),
|
|
2072
|
+
...fieldProps,
|
|
2073
|
+
ref
|
|
2074
|
+
});
|
|
2075
|
+
});
|
|
1763
2076
|
RadioGroup.displayName = RadioGroup$1.Root.displayName;
|
|
1764
2077
|
const RadioGroupItem = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(RadioGroup$1.Item, {
|
|
1765
2078
|
ref,
|
|
@@ -1792,24 +2105,36 @@ const switchThumbVariants = cva("pointer-events-none block rounded-full bg-backg
|
|
|
1792
2105
|
} },
|
|
1793
2106
|
defaultVariants: { size: "md" }
|
|
1794
2107
|
});
|
|
1795
|
-
const Switch = React.forwardRef(({ className, size, ...props }, ref) =>
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
2108
|
+
const Switch = React.forwardRef(({ className, size, ...props }, ref) => {
|
|
2109
|
+
const fieldProps = useFieldControl(props);
|
|
2110
|
+
return /* @__PURE__ */ jsx(Switch$1.Root, {
|
|
2111
|
+
className: cn(switchVariants({ size }), coarseHitAreaClasses, className),
|
|
2112
|
+
...fieldProps,
|
|
2113
|
+
ref,
|
|
2114
|
+
children: /* @__PURE__ */ jsx(Switch$1.Thumb, { className: cn(switchThumbVariants({ size })) })
|
|
2115
|
+
});
|
|
2116
|
+
});
|
|
1801
2117
|
Switch.displayName = Switch$1.Root.displayName;
|
|
1802
2118
|
//#endregion
|
|
1803
2119
|
//#region src/components/slider.tsx
|
|
1804
|
-
const Slider = React.forwardRef(({ className, ...props }, ref) =>
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
children: /* @__PURE__ */ jsx(Slider$1.
|
|
1811
|
-
|
|
1812
|
-
})
|
|
2120
|
+
const Slider = React.forwardRef(({ className, ...props }, ref) => {
|
|
2121
|
+
const { id, "aria-describedby": describedBy, "aria-invalid": invalid, "aria-required": ariaRequired, ...rootProps } = useFieldControl(props);
|
|
2122
|
+
return /* @__PURE__ */ jsxs(Slider$1.Root, {
|
|
2123
|
+
ref,
|
|
2124
|
+
className: cn("relative flex w-full touch-none select-none items-center", className),
|
|
2125
|
+
...rootProps,
|
|
2126
|
+
children: [/* @__PURE__ */ jsx(Slider$1.Track, {
|
|
2127
|
+
className: "relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",
|
|
2128
|
+
children: /* @__PURE__ */ jsx(Slider$1.Range, { className: "absolute h-full bg-primary" })
|
|
2129
|
+
}), /* @__PURE__ */ jsx(Slider$1.Thumb, {
|
|
2130
|
+
id,
|
|
2131
|
+
"aria-describedby": describedBy,
|
|
2132
|
+
"aria-invalid": invalid,
|
|
2133
|
+
"aria-required": ariaRequired,
|
|
2134
|
+
className: cn("block h-5 w-5 rounded-full border-2 border-primary bg-background ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50", coarseHitAreaClasses)
|
|
2135
|
+
})]
|
|
2136
|
+
});
|
|
2137
|
+
});
|
|
1813
2138
|
Slider.displayName = Slider$1.Root.displayName;
|
|
1814
2139
|
//#endregion
|
|
1815
2140
|
//#region src/components/card.tsx
|
|
@@ -5857,6 +6182,6 @@ function NotificationSettingsBlock({ groups, onSave, loading = false, error, dis
|
|
|
5857
6182
|
});
|
|
5858
6183
|
}
|
|
5859
6184
|
//#endregion
|
|
5860
|
-
export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, AccountSettingsBlock, Alert, AlertDescription, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, AlertTitle, AppSidebarBlock, AspectRatio, Avatar, AvatarFallback, AvatarImage, Badge, BisonProvider, Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, Button, Calendar, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, CodeInput, Collapsible, CollapsibleContent, CollapsibleTrigger, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, ContextMenu, ContextMenuCheckboxItem, ContextMenuContent, ContextMenuGroup, ContextMenuItem, ContextMenuLabel, ContextMenuPortal, ContextMenuRadioGroup, ContextMenuRadioItem, ContextMenuSeparator, ContextMenuShortcut, ContextMenuSub, ContextMenuSubContent, ContextMenuSubTrigger, ContextMenuTrigger, CurrencyInput, DataTable, DataTableColumnHeader, DatePicker, DateRangePicker, DensityProvider, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EditableTitle, EmptyStateBlock, FooterBlock, ForgotPasswordBlock, Form, FormError, FormField, HeaderBlock, Input, InputGroup, Label, MaintenanceBlock, MediaCard, NavigationMenu, NavigationMenuContent, NavigationMenuIndicator, NavigationMenuItem, NavigationMenuLink, NavigationMenuList, NavigationMenuTrigger, NavigationMenuViewport, NotFoundBlock, NotificationSettingsBlock, OutlinedField, PageShell, Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious, PasswordInput, PhoneInput, Popover, PopoverContent, PopoverTrigger, ProfileSettingsBlock, Progress, ProgressBar, RadioGroup, RadioGroupItem, Rating, ResetPasswordBlock, ReviewsBlock, SavedPing, ScrollArea, ScrollBar, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectSeparator, SelectTrigger, SelectValue, Separator, ServerErrorBlock, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetOverlay, SheetPortal, SheetTitle, SheetTrigger, Sidebar, SidebarBlock, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, SignInBlock, SignUpBlock, Skeleton, Slider, SocialProviders, Spinner, Stepper, StepperDescription, StepperIndicator, StepperItem, StepperLabel, StepperSeparator, Switch, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, TextContent, TextEditor, Textarea, ThemeProvider, ThemeScope, TimePicker, Toaster, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, VerifyBlock, actionNegativeToneClasses, actionNeutralIconChromeClasses, actionNeutralToneClasses, actionPositiveToneClasses, alertVariants, avatarVariants, badgeVariants, buttonVariants, cn, dateRangePresets, editableTitleVariants, formatUsPhone, navigationMenuTriggerStyle, outlinedFieldNestResetClasses, parseUsPhoneDigits, progressBarVariants, ratingVariants, spinnerVariants, stepperIndicatorVariants, stepperItemVariants, stepperLabelVariants, switchVariants, toast, useDensity, useFormContext, useIsMobile, useScrollReveal, useSidebar, useTheme };
|
|
6185
|
+
export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, AccountSettingsBlock, Alert, AlertDescription, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, AlertTitle, AppSidebarBlock, AspectRatio, Avatar, AvatarFallback, AvatarImage, Badge, BisonProvider, Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, Button, Calendar, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, CodeInput, Collapsible, CollapsibleContent, CollapsibleTrigger, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, ContextMenu, ContextMenuCheckboxItem, ContextMenuContent, ContextMenuGroup, ContextMenuItem, ContextMenuLabel, ContextMenuPortal, ContextMenuRadioGroup, ContextMenuRadioItem, ContextMenuSeparator, ContextMenuShortcut, ContextMenuSub, ContextMenuSubContent, ContextMenuSubTrigger, ContextMenuTrigger, CurrencyInput, DataTable, DataTableColumnHeader, DatePicker, DateRangePicker, DensityProvider, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EditableTitle, EmptyStateBlock, FieldGroupScope, FieldProvider, FooterBlock, ForgotPasswordBlock, Form, FormError, FormField, HeaderBlock, Input, InputGroup, Label, MaintenanceBlock, MediaCard, NavigationMenu, NavigationMenuContent, NavigationMenuIndicator, NavigationMenuItem, NavigationMenuLink, NavigationMenuList, NavigationMenuTrigger, NavigationMenuViewport, NotFoundBlock, NotificationSettingsBlock, OutlinedField, PageShell, Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious, PasswordInput, PhoneInput, Popover, PopoverContent, PopoverTrigger, ProfileSettingsBlock, Progress, ProgressBar, RadioGroup, RadioGroupItem, Rating, ResetPasswordBlock, ReviewsBlock, SavedPing, ScrollArea, ScrollBar, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectSeparator, SelectTrigger, SelectValue, Separator, ServerErrorBlock, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetOverlay, SheetPortal, SheetTitle, SheetTrigger, Sidebar, SidebarBlock, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, SignInBlock, SignUpBlock, Skeleton, Slider, SocialProviders, Spinner, Stepper, StepperDescription, StepperIndicator, StepperItem, StepperLabel, StepperSeparator, Switch, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, TextContent, TextEditor, Textarea, ThemeProvider, ThemeScope, TimePicker, Toaster, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, VerifyBlock, actionNegativeToneClasses, actionNeutralIconChromeClasses, actionNeutralToneClasses, actionPositiveToneClasses, alertVariants, avatarVariants, badgeVariants, buttonVariants, cn, dateRangePresets, editableTitleVariants, formatUsPhone, navigationMenuTriggerStyle, outlinedFieldNestResetClasses, parseUsPhoneDigits, progressBarVariants, ratingVariants, spinnerVariants, stepperIndicatorVariants, stepperItemVariants, stepperLabelVariants, switchVariants, toast, useDensity, useField, useFieldControl, useFieldGroup, useFieldIds, useFormContext, useIsMobile, useScrollReveal, useSidebar, useTheme };
|
|
5861
6186
|
|
|
5862
6187
|
//# sourceMappingURL=index.mjs.map
|