@page-speed/forms 0.4.9 → 0.5.1

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.cjs CHANGED
@@ -1,10 +1,12 @@
1
1
  'use strict';
2
2
 
3
- var React3 = require('react');
3
+ var React4 = require('react');
4
4
  var react = require('@legendapp/state/react');
5
5
  var useMap = require('@opensite/hooks/useMap');
6
6
  var clsx = require('clsx');
7
7
  var tailwindMerge = require('tailwind-merge');
8
+ var classVarianceAuthority = require('class-variance-authority');
9
+ var radixUi = require('radix-ui');
8
10
 
9
11
  function _interopNamespace(e) {
10
12
  if (e && e.__esModule) return e;
@@ -24,7 +26,7 @@ function _interopNamespace(e) {
24
26
  return Object.freeze(n);
25
27
  }
26
28
 
27
- var React3__namespace = /*#__PURE__*/_interopNamespace(React3);
29
+ var React4__namespace = /*#__PURE__*/_interopNamespace(React4);
28
30
 
29
31
  // src/core/useForm.ts
30
32
  function useForm(options) {
@@ -47,9 +49,9 @@ function useForm(options) {
47
49
  // Create a copy to prevent reference sharing
48
50
  hasValidated: {}
49
51
  });
50
- const validationInProgress = React3.useRef(/* @__PURE__ */ new Set());
52
+ const validationInProgress = React4.useRef(/* @__PURE__ */ new Set());
51
53
  const [, fieldMetadataActions] = useMap.useMap();
52
- const validateField = React3.useCallback(
54
+ const validateField = React4.useCallback(
53
55
  async (field) => {
54
56
  const validators = validationSchema?.[field];
55
57
  if (!validators) return void 0;
@@ -86,7 +88,7 @@ function useForm(options) {
86
88
  },
87
89
  [validationSchema, state$, fieldMetadataActions]
88
90
  );
89
- const validateForm = React3.useCallback(async () => {
91
+ const validateForm = React4.useCallback(async () => {
90
92
  if (!validationSchema) return {};
91
93
  const fields = Object.keys(validationSchema);
92
94
  const errors2 = {};
@@ -101,7 +103,7 @@ function useForm(options) {
101
103
  state$.errors.set(errors2);
102
104
  return errors2;
103
105
  }, [validationSchema, validateField, state$]);
104
- const setFieldValue = React3.useCallback(
106
+ const setFieldValue = React4.useCallback(
105
107
  (field, value) => {
106
108
  state$.values[field].set(value);
107
109
  const shouldRevalidate = revalidateOn === "onChange" && state$.hasValidated[String(field)].get();
@@ -114,7 +116,7 @@ function useForm(options) {
114
116
  },
115
117
  [state$, revalidateOn, validationSchema, validateField, debug]
116
118
  );
117
- const setFieldTouched = React3.useCallback(
119
+ const setFieldTouched = React4.useCallback(
118
120
  (field, touched2) => {
119
121
  state$.touched[field].set(touched2);
120
122
  if (touched2 && validateOn === "onBlur" && validationSchema?.[field]) {
@@ -127,7 +129,7 @@ function useForm(options) {
127
129
  },
128
130
  [state$, validateOn, validationSchema, validateField, debug]
129
131
  );
130
- const resetForm = React3.useCallback(() => {
132
+ const resetForm = React4.useCallback(() => {
131
133
  state$.values.set(state$.initialValues.get());
132
134
  state$.errors.set({});
133
135
  state$.touched.set({});
@@ -139,7 +141,7 @@ function useForm(options) {
139
141
  console.log("[useForm] Form reset");
140
142
  }
141
143
  }, [state$, fieldMetadataActions, debug]);
142
- const handleSubmit = React3.useCallback(
144
+ const handleSubmit = React4.useCallback(
143
145
  async (e) => {
144
146
  e?.preventDefault();
145
147
  if (debug) {
@@ -200,7 +202,7 @@ function useForm(options) {
200
202
  debug
201
203
  ]
202
204
  );
203
- const getFieldProps = React3.useCallback(
205
+ const getFieldProps = React4.useCallback(
204
206
  (field) => {
205
207
  return {
206
208
  name: String(field),
@@ -211,7 +213,7 @@ function useForm(options) {
211
213
  },
212
214
  [state$, setFieldValue, setFieldTouched]
213
215
  );
214
- const getFieldMeta = React3.useCallback(
216
+ const getFieldMeta = React4.useCallback(
215
217
  (field) => {
216
218
  const fieldKey = String(field);
217
219
  const metadata = fieldMetadataActions.get(fieldKey);
@@ -270,13 +272,13 @@ function useForm(options) {
270
272
  getFieldMeta
271
273
  };
272
274
  }
273
- var FormContext = React3__namespace.createContext(null);
275
+ var FormContext = React4__namespace.createContext(null);
274
276
  FormContext.displayName = "FormContext";
275
277
 
276
278
  // src/core/useField.ts
277
279
  function useField(options) {
278
280
  const { name, validate, transform } = options;
279
- const form = React3.useContext(FormContext);
281
+ const form = React4.useContext(FormContext);
280
282
  if (!form) {
281
283
  throw new Error(
282
284
  "useField must be used within a FormContext. Wrap your component with <Form> or use useForm's getFieldProps instead."
@@ -305,20 +307,20 @@ function useField(options) {
305
307
  };
306
308
  const meta = form.getFieldMeta(name);
307
309
  const helpers = {
308
- setValue: React3.useCallback(
310
+ setValue: React4.useCallback(
309
311
  (value) => {
310
312
  const transformedValue = transform ? transform(value) : value;
311
313
  form.setFieldValue(name, transformedValue);
312
314
  },
313
315
  [name, transform, form]
314
316
  ),
315
- setTouched: React3.useCallback(
317
+ setTouched: React4.useCallback(
316
318
  (touched) => {
317
319
  form.setFieldTouched(name, touched);
318
320
  },
319
321
  [name, form]
320
322
  ),
321
- setError: React3.useCallback(
323
+ setError: React4.useCallback(
322
324
  (error) => {
323
325
  form.setFieldError(name, error);
324
326
  },
@@ -338,7 +340,7 @@ function cn(...inputs) {
338
340
  // src/core/form-feedback.tsx
339
341
  function renderMessage(message, fallbackClassName, className) {
340
342
  if (typeof message === "string") {
341
- return /* @__PURE__ */ React3__namespace.createElement(
343
+ return /* @__PURE__ */ React4__namespace.createElement(
342
344
  "p",
343
345
  {
344
346
  className: cn(
@@ -349,7 +351,7 @@ function renderMessage(message, fallbackClassName, className) {
349
351
  message
350
352
  );
351
353
  }
352
- return /* @__PURE__ */ React3__namespace.createElement("div", { className: cn(fallbackClassName, className) }, message);
354
+ return /* @__PURE__ */ React4__namespace.createElement("div", { className: cn(fallbackClassName, className) }, message);
353
355
  }
354
356
  function FormFeedback({
355
357
  successMessage,
@@ -360,7 +362,7 @@ function FormFeedback({
360
362
  if (!successMessage && !submissionError) {
361
363
  return null;
362
364
  }
363
- return /* @__PURE__ */ React3__namespace.createElement(React3__namespace.Fragment, null, successMessage ? /* @__PURE__ */ React3__namespace.createElement(
365
+ return /* @__PURE__ */ React4__namespace.createElement(React4__namespace.Fragment, null, successMessage ? /* @__PURE__ */ React4__namespace.createElement(
364
366
  "div",
365
367
  {
366
368
  className: cn(
@@ -375,7 +377,7 @@ function FormFeedback({
375
377
  "text-primary-foreground",
376
378
  "text-primary-foreground"
377
379
  )
378
- ) : null, submissionError ? /* @__PURE__ */ React3__namespace.createElement(
380
+ ) : null, submissionError ? /* @__PURE__ */ React4__namespace.createElement(
379
381
  "div",
380
382
  {
381
383
  className: cn(
@@ -393,6 +395,54 @@ function FormFeedback({
393
395
  ) : null);
394
396
  }
395
397
  FormFeedback.displayName = "FormFeedback";
398
+ var buttonVariants = classVarianceAuthority.cva(
399
+ "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 aria-invalid:border-destructive",
400
+ {
401
+ variants: {
402
+ variant: {
403
+ default: "bg-primary text-primary-foreground hover:bg-primary/90",
404
+ destructive: "bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20",
405
+ outline: "border border-input bg-transparent shadow-xs hover:bg-accent hover:text-accent-foreground",
406
+ secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
407
+ ghost: "hover:bg-accent hover:text-accent-foreground",
408
+ link: "text-primary underline-offset-4 hover:underline"
409
+ },
410
+ size: {
411
+ default: "h-9 px-4 py-2 has-[>svg]:px-3",
412
+ xs: "h-6 gap-1 rounded-md px-2 text-xs has-[>svg]:px-1.5 [&_svg:not([class*='size-'])]:size-3",
413
+ sm: "h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",
414
+ lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
415
+ icon: "size-9",
416
+ "icon-xs": "size-6 rounded-md [&_svg:not([class*='size-'])]:size-3",
417
+ "icon-sm": "size-8",
418
+ "icon-lg": "size-10"
419
+ }
420
+ },
421
+ defaultVariants: {
422
+ variant: "default",
423
+ size: "default"
424
+ }
425
+ }
426
+ );
427
+ function Button({
428
+ className,
429
+ variant = "default",
430
+ size = "default",
431
+ asChild = false,
432
+ ...props
433
+ }) {
434
+ const Comp = asChild ? radixUi.Slot.Root : "button";
435
+ return /* @__PURE__ */ React4__namespace.createElement(
436
+ Comp,
437
+ {
438
+ "data-slot": "button",
439
+ "data-variant": variant,
440
+ "data-size": size,
441
+ className: cn(buttonVariants({ variant, size, className })),
442
+ ...props
443
+ }
444
+ );
445
+ }
396
446
 
397
447
  // src/core/Form.tsx
398
448
  function Form({
@@ -410,7 +460,7 @@ function Form({
410
460
  onNewSubmission,
411
461
  ...props
412
462
  }) {
413
- const handleFormSubmit = React3__namespace.useCallback(
463
+ const handleFormSubmit = React4__namespace.useCallback(
414
464
  async (e) => {
415
465
  try {
416
466
  await form.handleSubmit(e);
@@ -429,11 +479,11 @@ function Form({
429
479
  const newSubmissionAction = submissionConfig?.newFormSubmissionAction;
430
480
  const showNewSubmissionAction = isSubmissionSuccessful && (typeof newSubmissionAction?.enable === "boolean" ? newSubmissionAction.enable : Boolean(newSubmissionAction?.label));
431
481
  const newSubmissionLabel = newSubmissionAction?.label ?? "Submit another response";
432
- const handleNewSubmission = React3__namespace.useCallback(() => {
482
+ const handleNewSubmission = React4__namespace.useCallback(() => {
433
483
  form.resetForm();
434
484
  onNewSubmission?.();
435
485
  }, [form, onNewSubmission]);
436
- return /* @__PURE__ */ React3__namespace.createElement(FormContext.Provider, { value: form }, /* @__PURE__ */ React3__namespace.createElement(
486
+ return /* @__PURE__ */ React4__namespace.createElement(FormContext.Provider, { value: form }, /* @__PURE__ */ React4__namespace.createElement(
437
487
  "form",
438
488
  {
439
489
  onSubmit: handleFormSubmit,
@@ -443,24 +493,21 @@ function Form({
443
493
  className,
444
494
  ...props
445
495
  },
446
- isSubmissionSuccessful ? /* @__PURE__ */ React3__namespace.createElement("div", { className: "space-y-4" }, shouldRenderCustomComponent ? submissionConfig?.customComponent : /* @__PURE__ */ React3__namespace.createElement(
496
+ isSubmissionSuccessful ? /* @__PURE__ */ React4__namespace.createElement("div", { className: "space-y-4" }, shouldRenderCustomComponent ? submissionConfig?.customComponent : /* @__PURE__ */ React4__namespace.createElement(
447
497
  FormFeedback,
448
498
  {
449
499
  successMessage: resolvedSuccessMessage,
450
500
  successMessageClassName
451
501
  }
452
- ), showNewSubmissionAction ? /* @__PURE__ */ React3__namespace.createElement(
453
- "button",
502
+ ), showNewSubmissionAction ? /* @__PURE__ */ React4__namespace.createElement(
503
+ Button,
454
504
  {
455
505
  type: "button",
456
- onClick: handleNewSubmission,
457
- className: cn(
458
- "inline-flex items-center justify-center whitespace-nowrap rounded-md border border-input bg-transparent px-4 py-2 text-sm font-medium shadow-sm transition-colors",
459
- "hover:bg-muted focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"
460
- )
506
+ variant: "outline",
507
+ onClick: handleNewSubmission
461
508
  },
462
509
  newSubmissionLabel
463
- ) : null) : /* @__PURE__ */ React3__namespace.createElement(React3__namespace.Fragment, null, children, submissionError ? /* @__PURE__ */ React3__namespace.createElement("div", { className: "mt-4" }, /* @__PURE__ */ React3__namespace.createElement(
510
+ ) : null) : /* @__PURE__ */ React4__namespace.createElement(React4__namespace.Fragment, null, children, submissionError ? /* @__PURE__ */ React4__namespace.createElement("div", { className: "mt-4" }, /* @__PURE__ */ React4__namespace.createElement(
464
511
  FormFeedback,
465
512
  {
466
513
  submissionError,
@@ -470,6 +517,102 @@ function Form({
470
517
  ));
471
518
  }
472
519
  Form.displayName = "Form";
520
+ function Label({
521
+ className,
522
+ ...props
523
+ }) {
524
+ return /* @__PURE__ */ React4__namespace.createElement(
525
+ radixUi.Label.Root,
526
+ {
527
+ "data-slot": "label",
528
+ className: cn(
529
+ "flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",
530
+ className
531
+ ),
532
+ ...props
533
+ }
534
+ );
535
+ }
536
+
537
+ // src/components/ui/field.tsx
538
+ var Field = React4__namespace.forwardRef(
539
+ ({ className, orientation = "vertical", invalid = false, ...props }, ref) => {
540
+ return /* @__PURE__ */ React4__namespace.createElement(
541
+ "div",
542
+ {
543
+ ref,
544
+ "data-slot": "field",
545
+ "data-orientation": orientation,
546
+ "data-invalid": invalid || void 0,
547
+ className: cn(
548
+ "flex",
549
+ orientation === "horizontal" ? "items-center gap-2" : "flex-col gap-1.5",
550
+ className
551
+ ),
552
+ ...props
553
+ }
554
+ );
555
+ }
556
+ );
557
+ Field.displayName = "Field";
558
+ var FieldGroup = React4__namespace.forwardRef(({ className, ...props }, ref) => {
559
+ return /* @__PURE__ */ React4__namespace.createElement(
560
+ "div",
561
+ {
562
+ ref,
563
+ "data-slot": "field-group",
564
+ className: cn("flex flex-col gap-4", className),
565
+ ...props
566
+ }
567
+ );
568
+ });
569
+ FieldGroup.displayName = "FieldGroup";
570
+ var FieldLabel = React4__namespace.forwardRef(({ className, required, children, ...props }, ref) => {
571
+ return /* @__PURE__ */ React4__namespace.createElement(
572
+ Label,
573
+ {
574
+ ref,
575
+ "data-slot": "field-label",
576
+ className: cn(
577
+ "text-sm font-medium leading-none select-none",
578
+ "peer-disabled:cursor-not-allowed peer-disabled:opacity-50",
579
+ className
580
+ ),
581
+ ...props
582
+ },
583
+ children,
584
+ required && /* @__PURE__ */ React4__namespace.createElement("span", { className: "text-destructive ml-1" }, "*")
585
+ );
586
+ });
587
+ FieldLabel.displayName = "FieldLabel";
588
+ var FieldDescription = React4__namespace.forwardRef(({ className, ...props }, ref) => {
589
+ return /* @__PURE__ */ React4__namespace.createElement(
590
+ "p",
591
+ {
592
+ ref,
593
+ "data-slot": "field-description",
594
+ className: cn("text-sm opacity-70", className),
595
+ ...props
596
+ }
597
+ );
598
+ });
599
+ FieldDescription.displayName = "FieldDescription";
600
+ var FieldError = React4__namespace.forwardRef(({ className, ...props }, ref) => {
601
+ return /* @__PURE__ */ React4__namespace.createElement(
602
+ "p",
603
+ {
604
+ ref,
605
+ "data-slot": "field-error",
606
+ role: "alert",
607
+ "aria-live": "polite",
608
+ className: cn("text-sm text-destructive", className),
609
+ ...props
610
+ }
611
+ );
612
+ });
613
+ FieldError.displayName = "FieldError";
614
+
615
+ // src/core/field-feedback.tsx
473
616
  var FieldFeedback = ({
474
617
  errorId,
475
618
  errorClassName,
@@ -478,22 +621,7 @@ var FieldFeedback = ({
478
621
  }) => {
479
622
  const errorText = Array.isArray(error) ? error.join(", ") : error;
480
623
  if (!errorText || !shouldRenderError) return null;
481
- return /* @__PURE__ */ React3__namespace.createElement(
482
- "div",
483
- {
484
- id: errorId,
485
- className: cn(
486
- "text-xs px-3 py-2 font-medium",
487
- "rounded-md shadow-md mt-2",
488
- "text-destructive-foreground bg-destructive",
489
- "border border-destructive",
490
- errorClassName
491
- ),
492
- role: "alert",
493
- "aria-live": "polite"
494
- },
495
- errorText
496
- );
624
+ return /* @__PURE__ */ React4__namespace.createElement(FieldError, { id: errorId, className: errorClassName }, errorText);
497
625
  };
498
626
  var LabelGroup = ({
499
627
  labelHtmlFor,
@@ -510,44 +638,42 @@ var LabelGroup = ({
510
638
  variant === "legend" ? "mb-1.5" : "mb-1 block",
511
639
  primaryClassName
512
640
  );
513
- const requiredIndicator = required ? /* @__PURE__ */ React3__namespace.createElement("span", { className: "text-destructive pl-0.5", "aria-label": "required" }, "*") : null;
641
+ const requiredIndicator = required && variant !== "label" ? /* @__PURE__ */ React4__namespace.createElement("span", { className: "text-destructive pl-0.5", "aria-label": "required" }, "*") : null;
514
642
  let primaryElement = null;
515
643
  if (primary) {
516
644
  if (variant === "label") {
517
- primaryElement = /* @__PURE__ */ React3__namespace.createElement(
518
- "label",
645
+ primaryElement = /* @__PURE__ */ React4__namespace.createElement(
646
+ FieldLabel,
519
647
  {
520
648
  htmlFor: labelHtmlFor,
521
- "data-slot": "field-label",
649
+ required,
522
650
  className: primaryClasses
523
651
  },
524
- primary,
525
- requiredIndicator
652
+ primary
526
653
  );
527
654
  } else if (variant === "legend") {
528
- primaryElement = /* @__PURE__ */ React3__namespace.createElement("legend", { "data-slot": "field-legend", className: primaryClasses }, primary, requiredIndicator);
655
+ primaryElement = /* @__PURE__ */ React4__namespace.createElement("legend", { "data-slot": "field-legend", className: primaryClasses }, primary, requiredIndicator);
529
656
  } else {
530
- primaryElement = /* @__PURE__ */ React3__namespace.createElement("div", { "data-slot": "field-label", className: primaryClasses }, primary, requiredIndicator);
657
+ primaryElement = /* @__PURE__ */ React4__namespace.createElement("div", { "data-slot": "field-label", className: primaryClasses }, primary, requiredIndicator);
531
658
  }
532
659
  }
533
- const secondaryElement = secondary ? /* @__PURE__ */ React3__namespace.createElement(
534
- "p",
660
+ const secondaryElement = secondary ? /* @__PURE__ */ React4__namespace.createElement(
661
+ FieldDescription,
535
662
  {
536
- "data-slot": "field-description",
537
663
  id: secondaryId,
538
- className: cn("text-sm leading-normal font-normal", secondaryClassName)
664
+ className: cn("leading-normal font-normal", secondaryClassName)
539
665
  },
540
666
  secondary
541
667
  ) : null;
542
668
  if (!primaryElement && !secondaryElement) return null;
543
669
  if (variant === "legend") {
544
- return /* @__PURE__ */ React3__namespace.createElement(React3__namespace.Fragment, null, primaryElement, secondaryElement);
670
+ return /* @__PURE__ */ React4__namespace.createElement(React4__namespace.Fragment, null, primaryElement, secondaryElement);
545
671
  }
546
- return /* @__PURE__ */ React3__namespace.createElement("div", { className: "flex flex-1 flex-col gap-0.5" }, primaryElement, secondaryElement);
672
+ return /* @__PURE__ */ React4__namespace.createElement("div", { className: "flex flex-1 flex-col gap-0.5" }, primaryElement, secondaryElement);
547
673
  };
548
674
 
549
675
  // src/core/Field.tsx
550
- function Field({
676
+ function Field2({
551
677
  name,
552
678
  label,
553
679
  description,
@@ -560,104 +686,48 @@ function Field({
560
686
  }) {
561
687
  const fieldState = useField({ name, validate });
562
688
  const { meta } = fieldState;
563
- const hasError = React3__namespace.useMemo(() => {
689
+ const hasError = React4__namespace.useMemo(() => {
564
690
  return showError && meta.touched && meta.error ? true : false;
565
691
  }, [meta?.touched, meta?.error, showError]);
566
692
  const errorId = `${name}-error`;
567
693
  const descriptionId = `${name}-description`;
568
- return /* @__PURE__ */ React3__namespace.createElement("div", { className, "data-field": name }, /* @__PURE__ */ React3__namespace.createElement(
569
- LabelGroup,
570
- {
571
- labelHtmlFor: name,
572
- required,
573
- variant: "label",
574
- secondaryId: descriptionId,
575
- secondary: description,
576
- primary: label
577
- }
578
- ), /* @__PURE__ */ React3__namespace.createElement("div", null, typeof children === "function" ? children(fieldState) : children), /* @__PURE__ */ React3__namespace.createElement(
579
- FieldFeedback,
580
- {
581
- errorId,
582
- errorClassName,
583
- shouldRenderError: hasError,
584
- error: meta.error
585
- }
586
- ));
587
- }
588
- Field.displayName = "Field";
589
- var Field2 = React3__namespace.forwardRef(({ className, ...props }, ref) => {
590
- return /* @__PURE__ */ React3__namespace.createElement(
591
- "div",
694
+ return /* @__PURE__ */ React4__namespace.createElement(
695
+ Field,
592
696
  {
593
- ref,
594
- "data-slot": "field",
595
- className: cn("flex flex-col gap-1.5", className),
596
- ...props
597
- }
598
- );
599
- });
600
- Field2.displayName = "Field";
601
- var FieldGroup = React3__namespace.forwardRef(({ className, ...props }, ref) => {
602
- return /* @__PURE__ */ React3__namespace.createElement(
603
- "div",
604
- {
605
- ref,
606
- "data-slot": "field-group",
607
- className: cn("flex flex-col gap-4", className),
608
- ...props
609
- }
610
- );
611
- });
612
- FieldGroup.displayName = "FieldGroup";
613
- var FieldLabel = React3__namespace.forwardRef(({ className, required, children, ...props }, ref) => {
614
- return /* @__PURE__ */ React3__namespace.createElement(
615
- "label",
616
- {
617
- ref,
618
- "data-slot": "field-label",
619
- className: cn(
620
- "text-sm font-medium leading-none select-none",
621
- "peer-disabled:cursor-not-allowed peer-disabled:opacity-50",
622
- className
623
- ),
624
- ...props
697
+ className,
698
+ "data-field": name,
699
+ invalid: hasError
625
700
  },
626
- children,
627
- required && /* @__PURE__ */ React3__namespace.createElement("span", { className: "text-destructive ml-1" }, "*")
628
- );
629
- });
630
- FieldLabel.displayName = "FieldLabel";
631
- var FieldDescription = React3__namespace.forwardRef(({ className, ...props }, ref) => {
632
- return /* @__PURE__ */ React3__namespace.createElement(
633
- "p",
634
- {
635
- ref,
636
- "data-slot": "field-description",
637
- className: cn("text-sm opacity-70", className),
638
- ...props
639
- }
640
- );
641
- });
642
- FieldDescription.displayName = "FieldDescription";
643
- var FieldError = React3__namespace.forwardRef(({ className, ...props }, ref) => {
644
- return /* @__PURE__ */ React3__namespace.createElement(
645
- "p",
646
- {
647
- ref,
648
- "data-slot": "field-error",
649
- className: cn("text-sm text-destructive", className),
650
- ...props
651
- }
701
+ /* @__PURE__ */ React4__namespace.createElement(
702
+ LabelGroup,
703
+ {
704
+ labelHtmlFor: name,
705
+ required,
706
+ variant: "label",
707
+ secondaryId: descriptionId,
708
+ secondary: description,
709
+ primary: label
710
+ }
711
+ ),
712
+ /* @__PURE__ */ React4__namespace.createElement("div", { "data-slot": "field-control" }, typeof children === "function" ? children(fieldState) : children),
713
+ /* @__PURE__ */ React4__namespace.createElement(
714
+ FieldFeedback,
715
+ {
716
+ errorId,
717
+ errorClassName,
718
+ shouldRenderError: hasError,
719
+ error: meta.error
720
+ }
721
+ )
652
722
  );
653
- });
654
- FieldError.displayName = "FieldError";
723
+ }
724
+ Field2.displayName = "Field";
655
725
 
656
- exports.Field = Field;
726
+ exports.Field = Field2;
657
727
  exports.FieldDescription = FieldDescription;
658
728
  exports.FieldError = FieldError;
659
729
  exports.FieldGroup = FieldGroup;
660
- exports.FieldWrapper = Field2;
730
+ exports.FieldWrapper = Field;
661
731
  exports.Form = Form;
662
732
  exports.FormContext = FormContext;
663
733
  exports.FormFeedback = FormFeedback;