@radix-ui/react-form 0.1.13-rc.1784507240898 → 0.1.14

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 CHANGED
@@ -1,8 +1,7 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
1
  import * as _radix_ui_react_context from '@radix-ui/react-context';
3
2
  import { Scope } from '@radix-ui/react-context';
4
3
  import * as React from 'react';
5
- import { Label as Label$1 } from '@radix-ui/react-label';
4
+ import { Label } from '@radix-ui/react-label';
6
5
  import { Primitive } from '@radix-ui/react-primitive';
7
6
 
8
7
  type ScopedProps<P> = P & {
@@ -20,7 +19,7 @@ interface FormFieldProps extends PrimitiveDivProps {
20
19
  serverInvalid?: boolean;
21
20
  }
22
21
  declare const FormField: React.ForwardRefExoticComponent<FormFieldProps & React.RefAttributes<HTMLDivElement>>;
23
- type LabelProps = React.ComponentPropsWithoutRef<typeof Label$1>;
22
+ type LabelProps = React.ComponentPropsWithoutRef<typeof Label>;
24
23
  interface FormLabelProps extends LabelProps {
25
24
  name?: string;
26
25
  }
@@ -45,7 +44,7 @@ interface FormValidityStateProps {
45
44
  children(validity: ValidityState | undefined): React.ReactNode;
46
45
  name?: string;
47
46
  }
48
- declare const FormValidityState: (props: ScopedProps<FormValidityStateProps>) => react_jsx_runtime.JSX.Element;
47
+ declare const FormValidityState: (props: ScopedProps<FormValidityStateProps>) => React.JSX.Element;
49
48
  type PrimitiveButtonProps = React.ComponentPropsWithoutRef<typeof Primitive.button>;
50
49
  interface FormSubmitProps extends PrimitiveButtonProps {
51
50
  }
@@ -53,12 +52,5 @@ declare const FormSubmit: React.ForwardRefExoticComponent<FormSubmitProps & Reac
53
52
  type SyncCustomMatcher = (value: string, formData: FormData) => boolean;
54
53
  type AsyncCustomMatcher = (value: string, formData: FormData) => Promise<boolean>;
55
54
  type CustomMatcher = SyncCustomMatcher | AsyncCustomMatcher;
56
- declare const Root: React.ForwardRefExoticComponent<FormProps & React.RefAttributes<HTMLFormElement>>;
57
- declare const Field: React.ForwardRefExoticComponent<FormFieldProps & React.RefAttributes<HTMLDivElement>>;
58
- declare const Label: React.ForwardRefExoticComponent<FormLabelProps & React.RefAttributes<HTMLLabelElement>>;
59
- declare const Control: React.ForwardRefExoticComponent<FormControlProps & React.RefAttributes<HTMLInputElement>>;
60
- declare const Message: React.ForwardRefExoticComponent<FormMessageProps & React.RefAttributes<HTMLSpanElement>>;
61
- declare const ValidityState: (props: ScopedProps<FormValidityStateProps>) => react_jsx_runtime.JSX.Element;
62
- declare const Submit: React.ForwardRefExoticComponent<FormSubmitProps & React.RefAttributes<HTMLButtonElement>>;
63
55
 
64
- export { Control, Field, Form, FormControl, type FormControlProps, FormField, type FormFieldProps, FormLabel, type FormLabelProps, FormMessage, type FormMessageProps, type FormProps, FormSubmit, type FormSubmitProps, FormValidityState, type FormValidityStateProps, Label, Message, Root, Submit, ValidityState, createFormScope };
56
+ export { FormControl as Control, FormField as Field, Form, FormControl, type FormControlProps, FormField, type FormFieldProps, FormLabel, type FormLabelProps, FormMessage, type FormMessageProps, type FormProps, FormSubmit, type FormSubmitProps, FormValidityState, type FormValidityStateProps, FormLabel as Label, FormMessage as Message, Form as Root, FormSubmit as Submit, FormValidityState as ValidityState, createFormScope };
package/dist/index.d.ts CHANGED
@@ -1,8 +1,7 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
1
  import * as _radix_ui_react_context from '@radix-ui/react-context';
3
2
  import { Scope } from '@radix-ui/react-context';
4
3
  import * as React from 'react';
5
- import { Label as Label$1 } from '@radix-ui/react-label';
4
+ import { Label } from '@radix-ui/react-label';
6
5
  import { Primitive } from '@radix-ui/react-primitive';
7
6
 
8
7
  type ScopedProps<P> = P & {
@@ -20,7 +19,7 @@ interface FormFieldProps extends PrimitiveDivProps {
20
19
  serverInvalid?: boolean;
21
20
  }
22
21
  declare const FormField: React.ForwardRefExoticComponent<FormFieldProps & React.RefAttributes<HTMLDivElement>>;
23
- type LabelProps = React.ComponentPropsWithoutRef<typeof Label$1>;
22
+ type LabelProps = React.ComponentPropsWithoutRef<typeof Label>;
24
23
  interface FormLabelProps extends LabelProps {
25
24
  name?: string;
26
25
  }
@@ -45,7 +44,7 @@ interface FormValidityStateProps {
45
44
  children(validity: ValidityState | undefined): React.ReactNode;
46
45
  name?: string;
47
46
  }
48
- declare const FormValidityState: (props: ScopedProps<FormValidityStateProps>) => react_jsx_runtime.JSX.Element;
47
+ declare const FormValidityState: (props: ScopedProps<FormValidityStateProps>) => React.JSX.Element;
49
48
  type PrimitiveButtonProps = React.ComponentPropsWithoutRef<typeof Primitive.button>;
50
49
  interface FormSubmitProps extends PrimitiveButtonProps {
51
50
  }
@@ -53,12 +52,5 @@ declare const FormSubmit: React.ForwardRefExoticComponent<FormSubmitProps & Reac
53
52
  type SyncCustomMatcher = (value: string, formData: FormData) => boolean;
54
53
  type AsyncCustomMatcher = (value: string, formData: FormData) => Promise<boolean>;
55
54
  type CustomMatcher = SyncCustomMatcher | AsyncCustomMatcher;
56
- declare const Root: React.ForwardRefExoticComponent<FormProps & React.RefAttributes<HTMLFormElement>>;
57
- declare const Field: React.ForwardRefExoticComponent<FormFieldProps & React.RefAttributes<HTMLDivElement>>;
58
- declare const Label: React.ForwardRefExoticComponent<FormLabelProps & React.RefAttributes<HTMLLabelElement>>;
59
- declare const Control: React.ForwardRefExoticComponent<FormControlProps & React.RefAttributes<HTMLInputElement>>;
60
- declare const Message: React.ForwardRefExoticComponent<FormMessageProps & React.RefAttributes<HTMLSpanElement>>;
61
- declare const ValidityState: (props: ScopedProps<FormValidityStateProps>) => react_jsx_runtime.JSX.Element;
62
- declare const Submit: React.ForwardRefExoticComponent<FormSubmitProps & React.RefAttributes<HTMLButtonElement>>;
63
55
 
64
- export { Control, Field, Form, FormControl, type FormControlProps, FormField, type FormFieldProps, FormLabel, type FormLabelProps, FormMessage, type FormMessageProps, type FormProps, FormSubmit, type FormSubmitProps, FormValidityState, type FormValidityStateProps, Label, Message, Root, Submit, ValidityState, createFormScope };
56
+ export { FormControl as Control, FormField as Field, Form, FormControl, type FormControlProps, FormField, type FormFieldProps, FormLabel, type FormLabelProps, FormMessage, type FormMessageProps, type FormProps, FormSubmit, type FormSubmitProps, FormValidityState, type FormValidityStateProps, FormLabel as Label, FormMessage as Message, Form as Root, FormSubmit as Submit, FormValidityState as ValidityState, createFormScope };
package/dist/index.js CHANGED
@@ -32,8 +32,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
32
32
  // src/index.ts
33
33
  var index_exports = {};
34
34
  __export(index_exports, {
35
- Control: () => Control,
36
- Field: () => Field,
35
+ Control: () => FormControl,
36
+ Field: () => FormField,
37
37
  Form: () => Form,
38
38
  FormControl: () => FormControl,
39
39
  FormField: () => FormField,
@@ -41,11 +41,11 @@ __export(index_exports, {
41
41
  FormMessage: () => FormMessage,
42
42
  FormSubmit: () => FormSubmit,
43
43
  FormValidityState: () => FormValidityState,
44
- Label: () => Label,
45
- Message: () => Message,
46
- Root: () => Root,
47
- Submit: () => Submit,
48
- ValidityState: () => ValidityState,
44
+ Label: () => FormLabel,
45
+ Message: () => FormMessage,
46
+ Root: () => Form,
47
+ Submit: () => FormSubmit,
48
+ ValidityState: () => FormValidityState,
49
49
  createFormScope: () => createFormScope
50
50
  });
51
51
  module.exports = __toCommonJS(index_exports);
@@ -229,7 +229,13 @@ var FormLabel = /* @__PURE__ */ React.forwardRef(
229
229
  var CONTROL_NAME = "FormControl";
230
230
  var FormControl = /* @__PURE__ */ React.forwardRef(
231
231
  /* @__PURE__ */ __name(function FormControl2(props, forwardedRef) {
232
- const { __scopeForm, name: nameProp, id: idProp, ...controlProps } = props;
232
+ const {
233
+ __scopeForm,
234
+ name: nameProp,
235
+ id: idProp,
236
+ "aria-describedby": ariaDescribedby,
237
+ ...controlProps
238
+ } = props;
233
239
  const validationContext = useValidationContext(CONTROL_NAME, __scopeForm);
234
240
  const fieldContext = useFormFieldContext(CONTROL_NAME, __scopeForm, { optional: true });
235
241
  const ariaDescriptionContext = useAriaDescriptionContext(CONTROL_NAME, __scopeForm);
@@ -334,7 +340,10 @@ var FormControl = /* @__PURE__ */ React.forwardRef(
334
340
  "data-valid": getValidAttribute(validity, serverInvalid),
335
341
  "data-invalid": getInvalidAttribute(validity, serverInvalid),
336
342
  "aria-invalid": serverInvalid || void 0,
337
- "aria-describedby": ariaDescriptionContext.getFieldDescription(name),
343
+ "aria-describedby": concatAriaDescribedby(
344
+ ariaDescribedby,
345
+ ariaDescriptionContext.getFieldDescription(name)
346
+ ),
338
347
  title: "",
339
348
  ...controlProps,
340
349
  ref: composedRef,
@@ -517,11 +526,15 @@ function getInvalidAttribute(validity, serverInvalid) {
517
526
  return void 0;
518
527
  }
519
528
  __name(getInvalidAttribute, "getInvalidAttribute");
520
- var Root = Form;
521
- var Field = FormField;
522
- var Label = FormLabel;
523
- var Control = FormControl;
524
- var Message = FormMessage;
525
- var ValidityState = FormValidityState;
526
- var Submit = FormSubmit;
529
+ function concatAriaDescribedby(...values) {
530
+ const ids = /* @__PURE__ */ new Set();
531
+ for (const value of values) {
532
+ if (typeof value !== "string") continue;
533
+ for (const id of String(value).trim().split(/\s+/)) {
534
+ if (id) ids.add(id);
535
+ }
536
+ }
537
+ return ids.size > 0 ? Array.from(ids).join(" ") : void 0;
538
+ }
539
+ __name(concatAriaDescribedby, "concatAriaDescribedby");
527
540
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/index.ts", "../src/form.tsx"],
4
- "sourcesContent": ["'use client';\nexport {\n createFormScope,\n //\n Form,\n FormField,\n FormLabel,\n FormControl,\n FormMessage,\n FormValidityState,\n FormSubmit,\n //\n Root,\n Field,\n Label,\n Control,\n Message,\n ValidityState,\n Submit,\n} from './form';\n\nexport type {\n FormProps,\n FormFieldProps,\n FormLabelProps,\n FormControlProps,\n FormMessageProps,\n FormValidityStateProps,\n FormSubmitProps,\n} from './form';\n", "import * as React from 'react';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { createContextScope } from '@radix-ui/react-context';\nimport { useId } from '@radix-ui/react-id';\nimport { Label as LabelPrimitive } from '@radix-ui/react-label';\nimport { Primitive } from '@radix-ui/react-primitive';\n\nimport type { Scope } from '@radix-ui/react-context';\n\ntype ScopedProps<P> = P & { __scopeForm?: Scope };\nconst [createFormContext, createFormScope] = createContextScope('Form');\n\n/* -------------------------------------------------------------------------------------------------\n * Form\n * -----------------------------------------------------------------------------------------------*/\n\nconst FORM_NAME = 'Form';\n\ntype ValidityMap = { [fieldName: string]: ValidityState | undefined };\ntype CustomMatcherEntriesMap = { [fieldName: string]: CustomMatcherEntry[] };\ntype CustomErrorsMap = { [fieldName: string]: Record<string, boolean> };\n\ntype ValidationContextValue = {\n getFieldValidity(fieldName: string): ValidityState | undefined;\n onFieldValidityChange(fieldName: string, validity: ValidityState): void;\n\n getFieldCustomMatcherEntries(fieldName: string): CustomMatcherEntry[];\n onFieldCustomMatcherEntryAdd(fieldName: string, matcherEntry: CustomMatcherEntry): void;\n onFieldCustomMatcherEntryRemove(fieldName: string, matcherEntryId: string): void;\n\n getFieldCustomErrors(fieldName: string): Record<string, boolean>;\n onFieldCustomErrorsChange(fieldName: string, errors: Record<string, boolean>): void;\n\n onFieldValiditionClear(fieldName: string): void;\n};\nconst [ValidationProvider, useValidationContext] =\n createFormContext<ValidationContextValue>(FORM_NAME);\n\ntype MessageIdsMap = { [fieldName: string]: Set<string> };\n\ntype AriaDescriptionContextValue = {\n onFieldMessageIdAdd(fieldName: string, id: string): void;\n onFieldMessageIdRemove(fieldName: string, id: string): void;\n getFieldDescription(fieldName: string): string | undefined;\n};\nconst [AriaDescriptionProvider, useAriaDescriptionContext] =\n createFormContext<AriaDescriptionContextValue>(FORM_NAME);\n\ntype FormElement = React.ComponentRef<typeof Primitive.form>;\ntype PrimitiveFormProps = React.ComponentPropsWithoutRef<typeof Primitive.form>;\ninterface FormProps extends PrimitiveFormProps {\n onClearServerErrors?(): void;\n}\n\nconst Form = /* @__PURE__ */ React.forwardRef<FormElement, FormProps>(\n // blank line to reduce diff noise\n function Form(props: ScopedProps<FormProps>, forwardedRef) {\n const { __scopeForm, onClearServerErrors = () => {}, ...rootProps } = props;\n const formRef = React.useRef<HTMLFormElement>(null);\n const composedFormRef = useComposedRefs(forwardedRef, formRef);\n\n // native validity per field\n const [validityMap, setValidityMap] = React.useState<ValidityMap>({});\n const getFieldValidity: ValidationContextValue['getFieldValidity'] = React.useCallback(\n (fieldName) => validityMap[fieldName],\n [validityMap],\n );\n const handleFieldValidityChange: ValidationContextValue['onFieldValidityChange'] =\n React.useCallback(\n (fieldName, validity) =>\n setValidityMap((prevValidityMap) => ({\n ...prevValidityMap,\n [fieldName]: { ...(prevValidityMap[fieldName] ?? {}), ...validity },\n })),\n [],\n );\n const handleFieldValiditionClear: ValidationContextValue['onFieldValiditionClear'] =\n React.useCallback((fieldName) => {\n setValidityMap((prevValidityMap) => ({ ...prevValidityMap, [fieldName]: undefined }));\n setCustomErrorsMap((prevCustomErrorsMap) => ({ ...prevCustomErrorsMap, [fieldName]: {} }));\n }, []);\n\n // custom matcher entries per field\n const [customMatcherEntriesMap, setCustomMatcherEntriesMap] =\n React.useState<CustomMatcherEntriesMap>({});\n const getFieldCustomMatcherEntries: ValidationContextValue['getFieldCustomMatcherEntries'] =\n React.useCallback(\n (fieldName) => customMatcherEntriesMap[fieldName] ?? [],\n [customMatcherEntriesMap],\n );\n const handleFieldCustomMatcherAdd: ValidationContextValue['onFieldCustomMatcherEntryAdd'] =\n React.useCallback((fieldName, matcherEntry) => {\n setCustomMatcherEntriesMap((prevCustomMatcherEntriesMap) => ({\n ...prevCustomMatcherEntriesMap,\n [fieldName]: [...(prevCustomMatcherEntriesMap[fieldName] ?? []), matcherEntry],\n }));\n }, []);\n const handleFieldCustomMatcherRemove: ValidationContextValue['onFieldCustomMatcherEntryRemove'] =\n React.useCallback((fieldName, matcherEntryId) => {\n setCustomMatcherEntriesMap((prevCustomMatcherEntriesMap) => ({\n ...prevCustomMatcherEntriesMap,\n [fieldName]: (prevCustomMatcherEntriesMap[fieldName] ?? []).filter(\n (matcherEntry) => matcherEntry.id !== matcherEntryId,\n ),\n }));\n }, []);\n\n // custom errors per field\n const [customErrorsMap, setCustomErrorsMap] = React.useState<CustomErrorsMap>({});\n const getFieldCustomErrors: ValidationContextValue['getFieldCustomErrors'] = React.useCallback(\n (fieldName) => customErrorsMap[fieldName] ?? {},\n [customErrorsMap],\n );\n const handleFieldCustomErrorsChange: ValidationContextValue['onFieldCustomErrorsChange'] =\n React.useCallback((fieldName, customErrors) => {\n setCustomErrorsMap((prevCustomErrorsMap) => ({\n ...prevCustomErrorsMap,\n [fieldName]: { ...(prevCustomErrorsMap[fieldName] ?? {}), ...customErrors },\n }));\n }, []);\n\n // messageIds per field\n const [messageIdsMap, setMessageIdsMap] = React.useState<MessageIdsMap>({});\n const handleFieldMessageIdAdd: AriaDescriptionContextValue['onFieldMessageIdAdd'] =\n React.useCallback((fieldName, id) => {\n setMessageIdsMap((prevMessageIdsMap) => {\n const fieldDescriptionIds = new Set(prevMessageIdsMap[fieldName]).add(id);\n return { ...prevMessageIdsMap, [fieldName]: fieldDescriptionIds };\n });\n }, []);\n const handleFieldMessageIdRemove: AriaDescriptionContextValue['onFieldMessageIdRemove'] =\n React.useCallback((fieldName, id) => {\n setMessageIdsMap((prevMessageIdsMap) => {\n const fieldDescriptionIds = new Set(prevMessageIdsMap[fieldName]);\n fieldDescriptionIds.delete(id);\n return { ...prevMessageIdsMap, [fieldName]: fieldDescriptionIds };\n });\n }, []);\n const getFieldDescription: AriaDescriptionContextValue['getFieldDescription'] =\n React.useCallback(\n (fieldName) => Array.from(messageIdsMap[fieldName] ?? []).join(' ') || undefined,\n [messageIdsMap],\n );\n\n return (\n <ValidationProvider\n scope={__scopeForm}\n getFieldValidity={getFieldValidity}\n onFieldValidityChange={handleFieldValidityChange}\n getFieldCustomMatcherEntries={getFieldCustomMatcherEntries}\n onFieldCustomMatcherEntryAdd={handleFieldCustomMatcherAdd}\n onFieldCustomMatcherEntryRemove={handleFieldCustomMatcherRemove}\n getFieldCustomErrors={getFieldCustomErrors}\n onFieldCustomErrorsChange={handleFieldCustomErrorsChange}\n onFieldValiditionClear={handleFieldValiditionClear}\n >\n <AriaDescriptionProvider\n scope={__scopeForm}\n onFieldMessageIdAdd={handleFieldMessageIdAdd}\n onFieldMessageIdRemove={handleFieldMessageIdRemove}\n getFieldDescription={getFieldDescription}\n >\n <Primitive.form\n {...rootProps}\n ref={composedFormRef}\n // focus first invalid control when the form is submitted\n onInvalid={composeEventHandlers(props.onInvalid, (event) => {\n const firstInvalidControl = getFirstInvalidControl(event.currentTarget);\n if (firstInvalidControl === event.target) firstInvalidControl.focus();\n\n // prevent default browser UI for form validation\n event.preventDefault();\n })}\n // clear server errors when the form is re-submitted\n onSubmit={composeEventHandlers(props.onSubmit, onClearServerErrors, {\n checkForDefaultPrevented: false,\n })}\n // clear server errors when the form is reset\n onReset={composeEventHandlers(props.onReset, onClearServerErrors)}\n />\n </AriaDescriptionProvider>\n </ValidationProvider>\n );\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * FormField\n * -----------------------------------------------------------------------------------------------*/\n\nconst FIELD_NAME = 'FormField';\n\ntype FormFieldContextValue = {\n id: string;\n name: string;\n serverInvalid: boolean;\n};\nconst [FormFieldProvider, useFormFieldContext] =\n createFormContext<FormFieldContextValue>(FIELD_NAME);\n\ntype FormFieldElement = React.ComponentRef<typeof Primitive.div>;\ntype PrimitiveDivProps = React.ComponentPropsWithoutRef<typeof Primitive.div>;\ninterface FormFieldProps extends PrimitiveDivProps {\n name: string;\n serverInvalid?: boolean;\n}\n\nconst FormField = /* @__PURE__ */ React.forwardRef<FormFieldElement, FormFieldProps>(\n function FormField(props: ScopedProps<FormFieldProps>, forwardedRef) {\n const { __scopeForm, name, serverInvalid = false, ...fieldProps } = props;\n const validationContext = useValidationContext(FIELD_NAME, __scopeForm);\n const validity = validationContext.getFieldValidity(name);\n const id = useId();\n\n return (\n <FormFieldProvider scope={__scopeForm} id={id} name={name} serverInvalid={serverInvalid}>\n <Primitive.div\n data-valid={getValidAttribute(validity, serverInvalid)}\n data-invalid={getInvalidAttribute(validity, serverInvalid)}\n {...fieldProps}\n ref={forwardedRef}\n />\n </FormFieldProvider>\n );\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * FormLabel\n * -----------------------------------------------------------------------------------------------*/\n\nconst LABEL_NAME = 'FormLabel';\n\ntype FormLabelElement = React.ComponentRef<typeof LabelPrimitive>;\ntype LabelProps = React.ComponentPropsWithoutRef<typeof LabelPrimitive>;\ninterface FormLabelProps extends LabelProps {\n name?: string;\n}\n\nconst FormLabel = /* @__PURE__ */ React.forwardRef<FormLabelElement, FormLabelProps>(\n function FormLabel(props: ScopedProps<FormLabelProps>, forwardedRef) {\n const { __scopeForm, name: nameProp, ...labelProps } = props;\n const validationContext = useValidationContext(LABEL_NAME, __scopeForm);\n const fieldContext = useFormFieldContext(LABEL_NAME, __scopeForm, { optional: true });\n const name = nameProp ?? fieldContext?.name;\n if (!name) {\n throw new Error(\n `\\`${LABEL_NAME}\\` must be used within \\`${FIELD_NAME}\\` or specify the \\`name\\` prop`,\n );\n }\n\n const htmlFor = labelProps.htmlFor || fieldContext?.id;\n if (!htmlFor) {\n throw new Error(\n `\\`${LABEL_NAME}\\` must be used within \\`${FIELD_NAME}\\` or specify the \\`htmlFor\\` prop`,\n );\n }\n\n const validity = validationContext.getFieldValidity(name);\n const serverInvalid = fieldContext?.serverInvalid ?? false;\n\n return (\n <LabelPrimitive\n data-valid={getValidAttribute(validity, serverInvalid)}\n data-invalid={getInvalidAttribute(validity, serverInvalid)}\n {...labelProps}\n ref={forwardedRef}\n htmlFor={htmlFor}\n />\n );\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * FormControl\n * -----------------------------------------------------------------------------------------------*/\n\nconst CONTROL_NAME = 'FormControl';\n\ntype FormControlElement = React.ComponentRef<typeof Primitive.input>;\ntype PrimitiveInputProps = React.ComponentPropsWithoutRef<typeof Primitive.input>;\ninterface FormControlProps extends PrimitiveInputProps {}\n\nconst FormControl = /* @__PURE__ */ React.forwardRef<FormControlElement, FormControlProps>(\n function FormControl(props: ScopedProps<FormControlProps>, forwardedRef) {\n const { __scopeForm, name: nameProp, id: idProp, ...controlProps } = props;\n\n const validationContext = useValidationContext(CONTROL_NAME, __scopeForm);\n const fieldContext = useFormFieldContext(CONTROL_NAME, __scopeForm, { optional: true });\n const ariaDescriptionContext = useAriaDescriptionContext(CONTROL_NAME, __scopeForm);\n\n const ref = React.useRef<FormControlElement>(null);\n const composedRef = useComposedRefs(forwardedRef, ref);\n const name = nameProp || fieldContext?.name;\n if (!name) {\n throw new Error(\n `\\`${CONTROL_NAME}\\` must be used within \\`${FIELD_NAME}\\` or specify the \\`name\\` prop`,\n );\n }\n\n const id = idProp || fieldContext?.id;\n if (!id) {\n throw new Error(\n `\\`${CONTROL_NAME}\\` must be used within \\`${FIELD_NAME}\\` or specify the \\`id\\` prop`,\n );\n }\n\n const customMatcherEntries = validationContext.getFieldCustomMatcherEntries(name);\n\n const { onFieldValidityChange, onFieldCustomErrorsChange, onFieldValiditionClear } =\n validationContext;\n const updateControlValidity = React.useCallback(\n async (control: FormControlElement) => {\n //------------------------------------------------------------------------------------------\n // 1. first, if we have built-in errors we stop here\n\n if (hasBuiltInError(control.validity)) {\n const controlValidity = validityStateToObject(control.validity);\n onFieldValidityChange(name, controlValidity);\n return;\n }\n\n //------------------------------------------------------------------------------------------\n // 2. then gather the form data to give to custom matchers for cross-comparisons\n\n const formData = control.form ? new FormData(control.form) : new FormData();\n const matcherArgs: CustomMatcherArgs = [control.value, formData];\n\n //------------------------------------------------------------------------------------------\n // 3. split sync and async custom matcher entries\n\n const syncCustomMatcherEntries: Array<SyncCustomMatcherEntry> = [];\n const ayncCustomMatcherEntries: Array<AsyncCustomMatcherEntry> = [];\n customMatcherEntries.forEach((customMatcherEntry) => {\n if (isAsyncCustomMatcherEntry(customMatcherEntry, matcherArgs)) {\n ayncCustomMatcherEntries.push(customMatcherEntry);\n } else if (isSyncCustomMatcherEntry(customMatcherEntry)) {\n syncCustomMatcherEntries.push(customMatcherEntry);\n }\n });\n\n //------------------------------------------------------------------------------------------\n // 4. run sync custom matchers and update control validity / internal validity + errors\n\n const syncCustomErrors = syncCustomMatcherEntries.map(({ id, match }) => {\n return [id, match(...matcherArgs)] as const;\n });\n const syncCustomErrorsById = Object.fromEntries(syncCustomErrors);\n const hasSyncCustomErrors = Object.values(syncCustomErrorsById).some(Boolean);\n const hasCustomError = hasSyncCustomErrors;\n control.setCustomValidity(hasCustomError ? DEFAULT_INVALID_MESSAGE : '');\n const controlValidity = validityStateToObject(control.validity);\n onFieldValidityChange(name, controlValidity);\n onFieldCustomErrorsChange(name, syncCustomErrorsById);\n\n //------------------------------------------------------------------------------------------\n // 5. run async custom matchers and update control validity / internal validity + errors\n\n if (!hasSyncCustomErrors && ayncCustomMatcherEntries.length > 0) {\n const promisedCustomErrors = ayncCustomMatcherEntries.map(({ id, match }) =>\n match(...matcherArgs).then((matches) => [id, matches] as const),\n );\n const asyncCustomErrors = await Promise.all(promisedCustomErrors);\n const asyncCustomErrorsById = Object.fromEntries(asyncCustomErrors);\n const hasAsyncCustomErrors = Object.values(asyncCustomErrorsById).some(Boolean);\n const hasCustomError = hasAsyncCustomErrors;\n control.setCustomValidity(hasCustomError ? DEFAULT_INVALID_MESSAGE : '');\n const controlValidity = validityStateToObject(control.validity);\n onFieldValidityChange(name, controlValidity);\n onFieldCustomErrorsChange(name, asyncCustomErrorsById);\n }\n },\n [customMatcherEntries, name, onFieldCustomErrorsChange, onFieldValidityChange],\n );\n\n React.useEffect(() => {\n const control = ref.current;\n if (control) {\n // We only want validate on change (native `change` event, not React's `onChange`). This is primarily\n // a UX decision, we don't want to validate on every keystroke and React's `onChange` is the `input` event.\n const handleChange = () => updateControlValidity(control);\n control.addEventListener('change', handleChange);\n return () => control.removeEventListener('change', handleChange);\n }\n }, [updateControlValidity]);\n\n const resetControlValidity = React.useCallback(() => {\n const control = ref.current;\n if (control) {\n control.setCustomValidity('');\n onFieldValiditionClear(name);\n }\n }, [name, onFieldValiditionClear]);\n\n // reset validity and errors when the form is reset\n React.useEffect(() => {\n const form = ref.current?.form;\n if (form) {\n form.addEventListener('reset', resetControlValidity);\n return () => form.removeEventListener('reset', resetControlValidity);\n }\n }, [resetControlValidity]);\n\n const serverInvalid = fieldContext?.serverInvalid ?? false;\n\n // focus first invalid control when fields are set as invalid by server\n React.useEffect(() => {\n if (!serverInvalid) {\n return;\n }\n\n const control = ref.current;\n const form = control?.closest('form');\n const firstInvalidControl = form ? getFirstInvalidControl(form) : null;\n if (firstInvalidControl === control) {\n firstInvalidControl?.focus();\n }\n }, [serverInvalid]);\n\n const validity = validationContext.getFieldValidity(name);\n\n return (\n <Primitive.input\n data-valid={getValidAttribute(validity, serverInvalid)}\n data-invalid={getInvalidAttribute(validity, serverInvalid)}\n aria-invalid={serverInvalid || undefined}\n aria-describedby={ariaDescriptionContext.getFieldDescription(name)}\n // disable default browser behaviour of showing built-in error message on hover\n title=\"\"\n {...controlProps}\n ref={composedRef}\n id={id}\n name={name}\n onInvalid={composeEventHandlers(props.onInvalid, (event) => {\n const control = event.currentTarget;\n updateControlValidity(control);\n })}\n onChange={composeEventHandlers(props.onChange, (_event) => {\n // reset validity when user changes value\n resetControlValidity();\n })}\n />\n );\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * FormMessage\n * -----------------------------------------------------------------------------------------------*/\n\nconst _validityMatchers = [\n 'badInput',\n 'patternMismatch',\n 'rangeOverflow',\n 'rangeUnderflow',\n 'stepMismatch',\n 'tooLong',\n 'tooShort',\n 'typeMismatch',\n 'valid',\n 'valueMissing',\n] as const;\ntype ValidityMatcher = (typeof _validityMatchers)[number];\n\nconst DEFAULT_INVALID_MESSAGE = 'This value is not valid';\nconst DEFAULT_BUILT_IN_MESSAGES: Record<ValidityMatcher, string | undefined> = {\n badInput: DEFAULT_INVALID_MESSAGE,\n patternMismatch: 'This value does not match the required pattern',\n rangeOverflow: 'This value is too large',\n rangeUnderflow: 'This value is too small',\n stepMismatch: 'This value does not match the required step',\n tooLong: 'This value is too long',\n tooShort: 'This value is too short',\n typeMismatch: 'This value does not match the required type',\n valid: undefined,\n valueMissing: 'This value is missing',\n};\n\nconst MESSAGE_NAME = 'FormMessage';\n\ntype FormMessageElement = FormMessageImplElement;\ninterface FormMessageProps extends Omit<FormMessageImplProps, 'name'> {\n match?: ValidityMatcher | CustomMatcher;\n forceMatch?: boolean;\n name?: string;\n}\n\nconst FormMessage = /* @__PURE__ */ React.forwardRef<FormMessageElement, FormMessageProps>(\n function FormMessage(props: ScopedProps<FormMessageProps>, forwardedRef) {\n const { match, name: nameProp, ...messageProps } = props;\n const fieldContext = useFormFieldContext(MESSAGE_NAME, props.__scopeForm, { optional: true });\n const name = nameProp ?? fieldContext?.name;\n if (!name) {\n throw new Error(\n `\\`${MESSAGE_NAME}\\` must be used within \\`${FIELD_NAME}\\` or specify the \\`name\\` prop`,\n );\n }\n\n if (match === undefined) {\n return (\n <FormMessageImpl {...messageProps} ref={forwardedRef} name={name}>\n {props.children || DEFAULT_INVALID_MESSAGE}\n </FormMessageImpl>\n );\n } else if (typeof match === 'function') {\n return <FormCustomMessage match={match} {...messageProps} ref={forwardedRef} name={name} />;\n } else {\n return <FormBuiltInMessage match={match} {...messageProps} ref={forwardedRef} name={name} />;\n }\n },\n);\n\ntype FormBuiltInMessageElement = FormMessageImplElement;\ninterface FormBuiltInMessageProps extends FormMessageImplProps {\n match: ValidityMatcher;\n forceMatch?: boolean;\n name: string;\n}\n\nconst FormBuiltInMessage = /* @__PURE__ */ React.forwardRef<\n FormBuiltInMessageElement,\n FormBuiltInMessageProps\n>(\n // blank line to reduce diff noise\n function FormBuiltInMessage(props: ScopedProps<FormBuiltInMessageProps>, forwardedRef) {\n const { match, forceMatch = false, name, children, ...messageProps } = props;\n const validationContext = useValidationContext(MESSAGE_NAME, messageProps.__scopeForm);\n const validity = validationContext.getFieldValidity(name);\n const matches = forceMatch || validity?.[match];\n\n if (matches) {\n return (\n <FormMessageImpl ref={forwardedRef} {...messageProps} name={name}>\n {children ?? DEFAULT_BUILT_IN_MESSAGES[match]}\n </FormMessageImpl>\n );\n }\n\n return null;\n },\n);\n\ntype FormCustomMessageElement = React.ComponentRef<typeof FormMessageImpl>;\ninterface FormCustomMessageProps extends React.ComponentPropsWithoutRef<typeof FormMessageImpl> {\n match: CustomMatcher;\n forceMatch?: boolean;\n name: string;\n}\n\nconst FormCustomMessage = /* @__PURE__ */ React.forwardRef<\n FormCustomMessageElement,\n FormCustomMessageProps\n>(\n // blank line to reduce diff noise\n function FormCustomMessage(props: ScopedProps<FormCustomMessageProps>, forwardedRef) {\n const { match, forceMatch = false, name, id: idProp, children, ...messageProps } = props;\n const validationContext = useValidationContext(MESSAGE_NAME, messageProps.__scopeForm);\n const ref = React.useRef<FormCustomMessageElement>(null);\n const composedRef = useComposedRefs(forwardedRef, ref);\n const _id = useId();\n const id = idProp ?? _id;\n\n const customMatcherEntry = React.useMemo(() => ({ id, match }), [id, match]);\n const { onFieldCustomMatcherEntryAdd, onFieldCustomMatcherEntryRemove } = validationContext;\n React.useEffect(() => {\n onFieldCustomMatcherEntryAdd(name, customMatcherEntry);\n return () => onFieldCustomMatcherEntryRemove(name, customMatcherEntry.id);\n }, [customMatcherEntry, name, onFieldCustomMatcherEntryAdd, onFieldCustomMatcherEntryRemove]);\n\n const validity = validationContext.getFieldValidity(name);\n const customErrors = validationContext.getFieldCustomErrors(name);\n const hasMatchingCustomError = customErrors[id];\n const matches =\n forceMatch || (validity && !hasBuiltInError(validity) && hasMatchingCustomError);\n\n if (matches) {\n return (\n <FormMessageImpl id={id} ref={composedRef} {...messageProps} name={name}>\n {children ?? DEFAULT_INVALID_MESSAGE}\n </FormMessageImpl>\n );\n }\n\n return null;\n },\n);\n\ntype FormMessageImplElement = React.ComponentRef<typeof Primitive.span>;\ntype PrimitiveSpanProps = React.ComponentPropsWithoutRef<typeof Primitive.span>;\ninterface FormMessageImplProps extends PrimitiveSpanProps {\n name: string;\n}\n\nconst FormMessageImpl = /* @__PURE__ */ React.forwardRef<\n FormMessageImplElement,\n FormMessageImplProps\n>(\n // blank line to reduce diff noise\n function FormMessageImpl(props: ScopedProps<FormMessageImplProps>, forwardedRef) {\n const { __scopeForm, id: idProp, name, ...messageProps } = props;\n const ariaDescriptionContext = useAriaDescriptionContext(MESSAGE_NAME, __scopeForm);\n const _id = useId();\n const id = idProp ?? _id;\n\n const { onFieldMessageIdAdd, onFieldMessageIdRemove } = ariaDescriptionContext;\n React.useEffect(() => {\n onFieldMessageIdAdd(name, id);\n return () => onFieldMessageIdRemove(name, id);\n }, [name, id, onFieldMessageIdAdd, onFieldMessageIdRemove]);\n\n return <Primitive.span id={id} {...messageProps} ref={forwardedRef} />;\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * FormValidityState\n * -----------------------------------------------------------------------------------------------*/\n\nconst VALIDITY_STATE_NAME = 'FormValidityState';\n\ninterface FormValidityStateProps {\n children(validity: ValidityState | undefined): React.ReactNode;\n name?: string;\n}\n\nconst FormValidityState = (props: ScopedProps<FormValidityStateProps>) => {\n const { __scopeForm, name: nameProp, children } = props;\n const validationContext = useValidationContext(VALIDITY_STATE_NAME, __scopeForm);\n const fieldContext = useFormFieldContext(VALIDITY_STATE_NAME, __scopeForm, { optional: true });\n const name = nameProp ?? fieldContext?.name;\n if (!name) {\n throw new Error(\n `\\`${VALIDITY_STATE_NAME}\\` must be used within \\`${FIELD_NAME}\\` or specify the \\`name\\` prop`,\n );\n }\n const validity = validationContext.getFieldValidity(name);\n return <>{children(validity)}</>;\n};\n\n/* -------------------------------------------------------------------------------------------------\n * FormSubmit\n * -----------------------------------------------------------------------------------------------*/\n\ntype FormSubmitElement = React.ComponentRef<typeof Primitive.button>;\ntype PrimitiveButtonProps = React.ComponentPropsWithoutRef<typeof Primitive.button>;\ninterface FormSubmitProps extends PrimitiveButtonProps {}\n\nconst FormSubmit = /* @__PURE__ */ React.forwardRef<FormSubmitElement, FormSubmitProps>(\n function FormSubmit(props: ScopedProps<FormSubmitProps>, forwardedRef) {\n const { __scopeForm, ...submitProps } = props;\n return <Primitive.button type=\"submit\" {...submitProps} ref={forwardedRef} />;\n },\n);\n\n/* -----------------------------------------------------------------------------------------------*/\n\ntype ValidityStateKey = keyof ValidityState;\ntype SyncCustomMatcher = (value: string, formData: FormData) => boolean;\ntype AsyncCustomMatcher = (value: string, formData: FormData) => Promise<boolean>;\ntype CustomMatcher = SyncCustomMatcher | AsyncCustomMatcher;\ntype CustomMatcherEntry = { id: string; match: CustomMatcher };\ntype SyncCustomMatcherEntry = { id: string; match: SyncCustomMatcher };\ntype AsyncCustomMatcherEntry = { id: string; match: AsyncCustomMatcher };\ntype CustomMatcherArgs = [string, FormData];\n\nfunction validityStateToObject(validity: ValidityState) {\n const object: any = {};\n for (const key in validity) {\n object[key] = validity[key as ValidityStateKey];\n }\n return object as Record<ValidityStateKey, boolean>;\n}\n\nfunction isHTMLElement(element: any): element is HTMLElement {\n return element instanceof HTMLElement;\n}\n\nfunction isFormControl(element: any): element is { validity: ValidityState } {\n return 'validity' in element;\n}\n\nfunction isInvalid(control: HTMLElement) {\n return (\n isFormControl(control) &&\n (control.validity.valid === false || control.getAttribute('aria-invalid') === 'true')\n );\n}\n\nfunction getFirstInvalidControl(form: HTMLFormElement): HTMLElement | null {\n const elements = form.elements;\n const [firstInvalidControl] = Array.from(elements).filter(isHTMLElement).filter(isInvalid);\n return firstInvalidControl ?? null;\n}\n\nfunction isAsyncCustomMatcherEntry(\n entry: CustomMatcherEntry,\n args: CustomMatcherArgs,\n): entry is AsyncCustomMatcherEntry {\n return entry.match.constructor.name === 'AsyncFunction' || returnsPromise(entry.match, args);\n}\n\nfunction isSyncCustomMatcherEntry(entry: CustomMatcherEntry): entry is SyncCustomMatcherEntry {\n return entry.match.constructor.name === 'Function';\n}\n\nfunction returnsPromise(func: Function, args: Array<unknown>) {\n return func(...args) instanceof Promise;\n}\n\nfunction hasBuiltInError(validity: ValidityState) {\n let error = false;\n for (const validityKey in validity) {\n const key = validityKey as ValidityStateKey;\n if (key !== 'valid' && key !== 'customError' && validity[key]) {\n error = true;\n break;\n }\n }\n return error;\n}\n\nfunction getValidAttribute(validity: ValidityState | undefined, serverInvalid: boolean) {\n if (validity?.valid === true && !serverInvalid) return true;\n return undefined;\n}\nfunction getInvalidAttribute(validity: ValidityState | undefined, serverInvalid: boolean) {\n if (validity?.valid === false || serverInvalid) return true;\n return undefined;\n}\n\n/* -----------------------------------------------------------------------------------------------*/\n\nconst Root = Form;\nconst Field = FormField;\nconst Label = FormLabel;\nconst Control = FormControl;\nconst Message = FormMessage;\nconst ValidityState = FormValidityState;\nconst Submit = FormSubmit;\n\nexport {\n createFormScope,\n //\n Form,\n FormField,\n FormLabel,\n FormControl,\n FormMessage,\n FormValidityState,\n FormSubmit,\n //\n Root,\n Field,\n Label,\n Control,\n Message,\n ValidityState,\n Submit,\n};\n\nexport type {\n FormProps,\n FormFieldProps,\n FormLabelProps,\n FormControlProps,\n FormMessageProps,\n FormValidityStateProps,\n FormSubmitProps,\n};\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,YAAuB;AACvB,uBAAqC;AACrC,gCAAgC;AAChC,2BAAmC;AACnC,sBAAsB;AACtB,yBAAwC;AACxC,6BAA0B;AA6JhB;AAxJV,IAAM,CAAC,mBAAmB,eAAe,QAAI,yCAAmB,MAAM;AAMtE,IAAM,YAAY;AAmBlB,IAAM,CAAC,oBAAoB,oBAA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,UAAU,SAAS,QAAQ,aAAa,cAAc,MAAM;AAElF;AALS;AAOT,SAAS,uBAAuB,MAA2C;AACzE,QAAM,WAAW,KAAK;AACtB,QAAM,CAAC,mBAAmB,IAAI,MAAM,KAAK,QAAQ,EAAE,OAAO,aAAa,EAAE,OAAO,SAAS;AACzF,SAAO,uBAAuB;AAChC;AAJS;AAMT,SAAS,0BACP,OACA,MACkC;AAClC,SAAO,MAAM,MAAM,YAAY,SAAS,mBAAmB,eAAe,MAAM,OAAO,IAAI;AAC7F;AALS;AAOT,SAAS,yBAAyB,OAA4D;AAC5F,SAAO,MAAM,MAAM,YAAY,SAAS;AAC1C;AAFS;AAIT,SAAS,eAAe,MAAgB,MAAsB;AAC5D,SAAO,KAAK,GAAG,IAAI,aAAa;AAClC;AAFS;AAIT,SAAS,gBAAgB,UAAyB;AAChD,MAAI,QAAQ;AACZ,aAAW,eAAe,UAAU;AAClC,UAAM,MAAM;AACZ,QAAI,QAAQ,WAAW,QAAQ,iBAAiB,SAAS,GAAG,GAAG;AAC7D,cAAQ;AACR;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;AAVS;AAYT,SAAS,kBAAkB,UAAqC,eAAwB;AACtF,MAAI,UAAU,UAAU,QAAQ,CAAC,cAAe,QAAO;AACvD,SAAO;AACT;AAHS;AAIT,SAAS,oBAAoB,UAAqC,eAAwB;AACxF,MAAI,UAAU,UAAU,SAAS,cAAe,QAAO;AACvD,SAAO;AACT;AAHS;AAOT,IAAM,OAAO;AACb,IAAM,QAAQ;AACd,IAAM,QAAQ;AACd,IAAM,UAAU;AAChB,IAAM,UAAU;AAChB,IAAM,gBAAgB;AACtB,IAAM,SAAS;",
4
+ "sourcesContent": ["'use client';\nexport {\n createFormScope,\n //\n Form,\n FormField,\n FormLabel,\n FormControl,\n FormMessage,\n FormValidityState,\n FormSubmit,\n //\n Root,\n Field,\n Label,\n Control,\n Message,\n ValidityState,\n Submit,\n} from './form';\n\nexport type {\n FormProps,\n FormFieldProps,\n FormLabelProps,\n FormControlProps,\n FormMessageProps,\n FormValidityStateProps,\n FormSubmitProps,\n} from './form';\n", "import * as React from 'react';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { createContextScope } from '@radix-ui/react-context';\nimport { useId } from '@radix-ui/react-id';\nimport { Label as LabelPrimitive } from '@radix-ui/react-label';\nimport { Primitive } from '@radix-ui/react-primitive';\n\nimport type { Scope } from '@radix-ui/react-context';\n\ntype ScopedProps<P> = P & { __scopeForm?: Scope };\nconst [createFormContext, createFormScope] = createContextScope('Form');\n\n/* -------------------------------------------------------------------------------------------------\n * Form\n * -----------------------------------------------------------------------------------------------*/\n\nconst FORM_NAME = 'Form';\n\ntype ValidityMap = { [fieldName: string]: ValidityState | undefined };\ntype CustomMatcherEntriesMap = { [fieldName: string]: CustomMatcherEntry[] };\ntype CustomErrorsMap = { [fieldName: string]: Record<string, boolean> };\n\ntype ValidationContextValue = {\n getFieldValidity(fieldName: string): ValidityState | undefined;\n onFieldValidityChange(fieldName: string, validity: ValidityState): void;\n\n getFieldCustomMatcherEntries(fieldName: string): CustomMatcherEntry[];\n onFieldCustomMatcherEntryAdd(fieldName: string, matcherEntry: CustomMatcherEntry): void;\n onFieldCustomMatcherEntryRemove(fieldName: string, matcherEntryId: string): void;\n\n getFieldCustomErrors(fieldName: string): Record<string, boolean>;\n onFieldCustomErrorsChange(fieldName: string, errors: Record<string, boolean>): void;\n\n onFieldValiditionClear(fieldName: string): void;\n};\nconst [ValidationProvider, useValidationContext] =\n createFormContext<ValidationContextValue>(FORM_NAME);\n\ntype MessageIdsMap = { [fieldName: string]: Set<string> };\n\ntype AriaDescriptionContextValue = {\n onFieldMessageIdAdd(fieldName: string, id: string): void;\n onFieldMessageIdRemove(fieldName: string, id: string): void;\n getFieldDescription(fieldName: string): string | undefined;\n};\nconst [AriaDescriptionProvider, useAriaDescriptionContext] =\n createFormContext<AriaDescriptionContextValue>(FORM_NAME);\n\ntype FormElement = React.ComponentRef<typeof Primitive.form>;\ntype PrimitiveFormProps = React.ComponentPropsWithoutRef<typeof Primitive.form>;\ninterface FormProps extends PrimitiveFormProps {\n onClearServerErrors?(): void;\n}\n\nconst Form = /* @__PURE__ */ React.forwardRef<FormElement, FormProps>(\n // blank line to reduce diff noise\n function Form(props: ScopedProps<FormProps>, forwardedRef) {\n const { __scopeForm, onClearServerErrors = () => {}, ...rootProps } = props;\n const formRef = React.useRef<HTMLFormElement>(null);\n const composedFormRef = useComposedRefs(forwardedRef, formRef);\n\n // native validity per field\n const [validityMap, setValidityMap] = React.useState<ValidityMap>({});\n const getFieldValidity: ValidationContextValue['getFieldValidity'] = React.useCallback(\n (fieldName) => validityMap[fieldName],\n [validityMap],\n );\n const handleFieldValidityChange: ValidationContextValue['onFieldValidityChange'] =\n React.useCallback(\n (fieldName, validity) =>\n setValidityMap((prevValidityMap) => ({\n ...prevValidityMap,\n [fieldName]: { ...(prevValidityMap[fieldName] ?? {}), ...validity },\n })),\n [],\n );\n const handleFieldValiditionClear: ValidationContextValue['onFieldValiditionClear'] =\n React.useCallback((fieldName) => {\n setValidityMap((prevValidityMap) => ({ ...prevValidityMap, [fieldName]: undefined }));\n setCustomErrorsMap((prevCustomErrorsMap) => ({ ...prevCustomErrorsMap, [fieldName]: {} }));\n }, []);\n\n // custom matcher entries per field\n const [customMatcherEntriesMap, setCustomMatcherEntriesMap] =\n React.useState<CustomMatcherEntriesMap>({});\n const getFieldCustomMatcherEntries: ValidationContextValue['getFieldCustomMatcherEntries'] =\n React.useCallback(\n (fieldName) => customMatcherEntriesMap[fieldName] ?? [],\n [customMatcherEntriesMap],\n );\n const handleFieldCustomMatcherAdd: ValidationContextValue['onFieldCustomMatcherEntryAdd'] =\n React.useCallback((fieldName, matcherEntry) => {\n setCustomMatcherEntriesMap((prevCustomMatcherEntriesMap) => ({\n ...prevCustomMatcherEntriesMap,\n [fieldName]: [...(prevCustomMatcherEntriesMap[fieldName] ?? []), matcherEntry],\n }));\n }, []);\n const handleFieldCustomMatcherRemove: ValidationContextValue['onFieldCustomMatcherEntryRemove'] =\n React.useCallback((fieldName, matcherEntryId) => {\n setCustomMatcherEntriesMap((prevCustomMatcherEntriesMap) => ({\n ...prevCustomMatcherEntriesMap,\n [fieldName]: (prevCustomMatcherEntriesMap[fieldName] ?? []).filter(\n (matcherEntry) => matcherEntry.id !== matcherEntryId,\n ),\n }));\n }, []);\n\n // custom errors per field\n const [customErrorsMap, setCustomErrorsMap] = React.useState<CustomErrorsMap>({});\n const getFieldCustomErrors: ValidationContextValue['getFieldCustomErrors'] = React.useCallback(\n (fieldName) => customErrorsMap[fieldName] ?? {},\n [customErrorsMap],\n );\n const handleFieldCustomErrorsChange: ValidationContextValue['onFieldCustomErrorsChange'] =\n React.useCallback((fieldName, customErrors) => {\n setCustomErrorsMap((prevCustomErrorsMap) => ({\n ...prevCustomErrorsMap,\n [fieldName]: { ...(prevCustomErrorsMap[fieldName] ?? {}), ...customErrors },\n }));\n }, []);\n\n // messageIds per field\n const [messageIdsMap, setMessageIdsMap] = React.useState<MessageIdsMap>({});\n const handleFieldMessageIdAdd: AriaDescriptionContextValue['onFieldMessageIdAdd'] =\n React.useCallback((fieldName, id) => {\n setMessageIdsMap((prevMessageIdsMap) => {\n const fieldDescriptionIds = new Set(prevMessageIdsMap[fieldName]).add(id);\n return { ...prevMessageIdsMap, [fieldName]: fieldDescriptionIds };\n });\n }, []);\n const handleFieldMessageIdRemove: AriaDescriptionContextValue['onFieldMessageIdRemove'] =\n React.useCallback((fieldName, id) => {\n setMessageIdsMap((prevMessageIdsMap) => {\n const fieldDescriptionIds = new Set(prevMessageIdsMap[fieldName]);\n fieldDescriptionIds.delete(id);\n return { ...prevMessageIdsMap, [fieldName]: fieldDescriptionIds };\n });\n }, []);\n const getFieldDescription: AriaDescriptionContextValue['getFieldDescription'] =\n React.useCallback(\n (fieldName) => Array.from(messageIdsMap[fieldName] ?? []).join(' ') || undefined,\n [messageIdsMap],\n );\n\n return (\n <ValidationProvider\n scope={__scopeForm}\n getFieldValidity={getFieldValidity}\n onFieldValidityChange={handleFieldValidityChange}\n getFieldCustomMatcherEntries={getFieldCustomMatcherEntries}\n onFieldCustomMatcherEntryAdd={handleFieldCustomMatcherAdd}\n onFieldCustomMatcherEntryRemove={handleFieldCustomMatcherRemove}\n getFieldCustomErrors={getFieldCustomErrors}\n onFieldCustomErrorsChange={handleFieldCustomErrorsChange}\n onFieldValiditionClear={handleFieldValiditionClear}\n >\n <AriaDescriptionProvider\n scope={__scopeForm}\n onFieldMessageIdAdd={handleFieldMessageIdAdd}\n onFieldMessageIdRemove={handleFieldMessageIdRemove}\n getFieldDescription={getFieldDescription}\n >\n <Primitive.form\n {...rootProps}\n ref={composedFormRef}\n // focus first invalid control when the form is submitted\n onInvalid={composeEventHandlers(props.onInvalid, (event) => {\n const firstInvalidControl = getFirstInvalidControl(event.currentTarget);\n if (firstInvalidControl === event.target) firstInvalidControl.focus();\n\n // prevent default browser UI for form validation\n event.preventDefault();\n })}\n // clear server errors when the form is re-submitted\n onSubmit={composeEventHandlers(props.onSubmit, onClearServerErrors, {\n checkForDefaultPrevented: false,\n })}\n // clear server errors when the form is reset\n onReset={composeEventHandlers(props.onReset, onClearServerErrors)}\n />\n </AriaDescriptionProvider>\n </ValidationProvider>\n );\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * FormField\n * -----------------------------------------------------------------------------------------------*/\n\nconst FIELD_NAME = 'FormField';\n\ntype FormFieldContextValue = {\n id: string;\n name: string;\n serverInvalid: boolean;\n};\nconst [FormFieldProvider, useFormFieldContext] =\n createFormContext<FormFieldContextValue>(FIELD_NAME);\n\ntype FormFieldElement = React.ComponentRef<typeof Primitive.div>;\ntype PrimitiveDivProps = React.ComponentPropsWithoutRef<typeof Primitive.div>;\ninterface FormFieldProps extends PrimitiveDivProps {\n name: string;\n serverInvalid?: boolean;\n}\n\nconst FormField = /* @__PURE__ */ React.forwardRef<FormFieldElement, FormFieldProps>(\n function FormField(props: ScopedProps<FormFieldProps>, forwardedRef) {\n const { __scopeForm, name, serverInvalid = false, ...fieldProps } = props;\n const validationContext = useValidationContext(FIELD_NAME, __scopeForm);\n const validity = validationContext.getFieldValidity(name);\n const id = useId();\n\n return (\n <FormFieldProvider scope={__scopeForm} id={id} name={name} serverInvalid={serverInvalid}>\n <Primitive.div\n data-valid={getValidAttribute(validity, serverInvalid)}\n data-invalid={getInvalidAttribute(validity, serverInvalid)}\n {...fieldProps}\n ref={forwardedRef}\n />\n </FormFieldProvider>\n );\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * FormLabel\n * -----------------------------------------------------------------------------------------------*/\n\nconst LABEL_NAME = 'FormLabel';\n\ntype FormLabelElement = React.ComponentRef<typeof LabelPrimitive>;\ntype LabelProps = React.ComponentPropsWithoutRef<typeof LabelPrimitive>;\ninterface FormLabelProps extends LabelProps {\n name?: string;\n}\n\nconst FormLabel = /* @__PURE__ */ React.forwardRef<FormLabelElement, FormLabelProps>(\n function FormLabel(props: ScopedProps<FormLabelProps>, forwardedRef) {\n const { __scopeForm, name: nameProp, ...labelProps } = props;\n const validationContext = useValidationContext(LABEL_NAME, __scopeForm);\n const fieldContext = useFormFieldContext(LABEL_NAME, __scopeForm, { optional: true });\n const name = nameProp ?? fieldContext?.name;\n if (!name) {\n throw new Error(\n `\\`${LABEL_NAME}\\` must be used within \\`${FIELD_NAME}\\` or specify the \\`name\\` prop`,\n );\n }\n\n const htmlFor = labelProps.htmlFor || fieldContext?.id;\n if (!htmlFor) {\n throw new Error(\n `\\`${LABEL_NAME}\\` must be used within \\`${FIELD_NAME}\\` or specify the \\`htmlFor\\` prop`,\n );\n }\n\n const validity = validationContext.getFieldValidity(name);\n const serverInvalid = fieldContext?.serverInvalid ?? false;\n\n return (\n <LabelPrimitive\n data-valid={getValidAttribute(validity, serverInvalid)}\n data-invalid={getInvalidAttribute(validity, serverInvalid)}\n {...labelProps}\n ref={forwardedRef}\n htmlFor={htmlFor}\n />\n );\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * FormControl\n * -----------------------------------------------------------------------------------------------*/\n\nconst CONTROL_NAME = 'FormControl';\n\ntype FormControlElement = React.ComponentRef<typeof Primitive.input>;\ntype PrimitiveInputProps = React.ComponentPropsWithoutRef<typeof Primitive.input>;\ninterface FormControlProps extends PrimitiveInputProps {}\n\nconst FormControl = /* @__PURE__ */ React.forwardRef<FormControlElement, FormControlProps>(\n function FormControl(props: ScopedProps<FormControlProps>, forwardedRef) {\n const {\n __scopeForm,\n name: nameProp,\n id: idProp,\n 'aria-describedby': ariaDescribedby,\n ...controlProps\n } = props;\n\n const validationContext = useValidationContext(CONTROL_NAME, __scopeForm);\n const fieldContext = useFormFieldContext(CONTROL_NAME, __scopeForm, { optional: true });\n const ariaDescriptionContext = useAriaDescriptionContext(CONTROL_NAME, __scopeForm);\n\n const ref = React.useRef<FormControlElement>(null);\n const composedRef = useComposedRefs(forwardedRef, ref);\n const name = nameProp || fieldContext?.name;\n if (!name) {\n throw new Error(\n `\\`${CONTROL_NAME}\\` must be used within \\`${FIELD_NAME}\\` or specify the \\`name\\` prop`,\n );\n }\n\n const id = idProp || fieldContext?.id;\n if (!id) {\n throw new Error(\n `\\`${CONTROL_NAME}\\` must be used within \\`${FIELD_NAME}\\` or specify the \\`id\\` prop`,\n );\n }\n\n const customMatcherEntries = validationContext.getFieldCustomMatcherEntries(name);\n\n const { onFieldValidityChange, onFieldCustomErrorsChange, onFieldValiditionClear } =\n validationContext;\n const updateControlValidity = React.useCallback(\n async (control: FormControlElement) => {\n //------------------------------------------------------------------------------------------\n // 1. first, if we have built-in errors we stop here\n\n if (hasBuiltInError(control.validity)) {\n const controlValidity = validityStateToObject(control.validity);\n onFieldValidityChange(name, controlValidity);\n return;\n }\n\n //------------------------------------------------------------------------------------------\n // 2. then gather the form data to give to custom matchers for cross-comparisons\n\n const formData = control.form ? new FormData(control.form) : new FormData();\n const matcherArgs: CustomMatcherArgs = [control.value, formData];\n\n //------------------------------------------------------------------------------------------\n // 3. split sync and async custom matcher entries\n\n const syncCustomMatcherEntries: Array<SyncCustomMatcherEntry> = [];\n const ayncCustomMatcherEntries: Array<AsyncCustomMatcherEntry> = [];\n customMatcherEntries.forEach((customMatcherEntry) => {\n if (isAsyncCustomMatcherEntry(customMatcherEntry, matcherArgs)) {\n ayncCustomMatcherEntries.push(customMatcherEntry);\n } else if (isSyncCustomMatcherEntry(customMatcherEntry)) {\n syncCustomMatcherEntries.push(customMatcherEntry);\n }\n });\n\n //------------------------------------------------------------------------------------------\n // 4. run sync custom matchers and update control validity / internal validity + errors\n\n const syncCustomErrors = syncCustomMatcherEntries.map(({ id, match }) => {\n return [id, match(...matcherArgs)] as const;\n });\n const syncCustomErrorsById = Object.fromEntries(syncCustomErrors);\n const hasSyncCustomErrors = Object.values(syncCustomErrorsById).some(Boolean);\n const hasCustomError = hasSyncCustomErrors;\n control.setCustomValidity(hasCustomError ? DEFAULT_INVALID_MESSAGE : '');\n const controlValidity = validityStateToObject(control.validity);\n onFieldValidityChange(name, controlValidity);\n onFieldCustomErrorsChange(name, syncCustomErrorsById);\n\n //------------------------------------------------------------------------------------------\n // 5. run async custom matchers and update control validity / internal validity + errors\n\n if (!hasSyncCustomErrors && ayncCustomMatcherEntries.length > 0) {\n const promisedCustomErrors = ayncCustomMatcherEntries.map(({ id, match }) =>\n match(...matcherArgs).then((matches) => [id, matches] as const),\n );\n const asyncCustomErrors = await Promise.all(promisedCustomErrors);\n const asyncCustomErrorsById = Object.fromEntries(asyncCustomErrors);\n const hasAsyncCustomErrors = Object.values(asyncCustomErrorsById).some(Boolean);\n const hasCustomError = hasAsyncCustomErrors;\n control.setCustomValidity(hasCustomError ? DEFAULT_INVALID_MESSAGE : '');\n const controlValidity = validityStateToObject(control.validity);\n onFieldValidityChange(name, controlValidity);\n onFieldCustomErrorsChange(name, asyncCustomErrorsById);\n }\n },\n [customMatcherEntries, name, onFieldCustomErrorsChange, onFieldValidityChange],\n );\n\n React.useEffect(() => {\n const control = ref.current;\n if (control) {\n // We only want validate on change (native `change` event, not React's `onChange`). This is primarily\n // a UX decision, we don't want to validate on every keystroke and React's `onChange` is the `input` event.\n const handleChange = () => updateControlValidity(control);\n control.addEventListener('change', handleChange);\n return () => control.removeEventListener('change', handleChange);\n }\n }, [updateControlValidity]);\n\n const resetControlValidity = React.useCallback(() => {\n const control = ref.current;\n if (control) {\n control.setCustomValidity('');\n onFieldValiditionClear(name);\n }\n }, [name, onFieldValiditionClear]);\n\n // reset validity and errors when the form is reset\n React.useEffect(() => {\n const form = ref.current?.form;\n if (form) {\n form.addEventListener('reset', resetControlValidity);\n return () => form.removeEventListener('reset', resetControlValidity);\n }\n }, [resetControlValidity]);\n\n const serverInvalid = fieldContext?.serverInvalid ?? false;\n\n // focus first invalid control when fields are set as invalid by server\n React.useEffect(() => {\n if (!serverInvalid) {\n return;\n }\n\n const control = ref.current;\n const form = control?.closest('form');\n const firstInvalidControl = form ? getFirstInvalidControl(form) : null;\n if (firstInvalidControl === control) {\n firstInvalidControl?.focus();\n }\n }, [serverInvalid]);\n\n const validity = validationContext.getFieldValidity(name);\n\n return (\n <Primitive.input\n data-valid={getValidAttribute(validity, serverInvalid)}\n data-invalid={getInvalidAttribute(validity, serverInvalid)}\n aria-invalid={serverInvalid || undefined}\n aria-describedby={concatAriaDescribedby(\n ariaDescribedby,\n ariaDescriptionContext.getFieldDescription(name),\n )}\n // disable default browser behaviour of showing built-in error message on hover\n title=\"\"\n {...controlProps}\n ref={composedRef}\n id={id}\n name={name}\n onInvalid={composeEventHandlers(props.onInvalid, (event) => {\n const control = event.currentTarget;\n updateControlValidity(control);\n })}\n onChange={composeEventHandlers(props.onChange, (_event) => {\n // reset validity when user changes value\n resetControlValidity();\n })}\n />\n );\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * FormMessage\n * -----------------------------------------------------------------------------------------------*/\n\nconst _validityMatchers = [\n 'badInput',\n 'patternMismatch',\n 'rangeOverflow',\n 'rangeUnderflow',\n 'stepMismatch',\n 'tooLong',\n 'tooShort',\n 'typeMismatch',\n 'valid',\n 'valueMissing',\n] as const;\ntype ValidityMatcher = (typeof _validityMatchers)[number];\n\nconst DEFAULT_INVALID_MESSAGE = 'This value is not valid';\nconst DEFAULT_BUILT_IN_MESSAGES: Record<ValidityMatcher, string | undefined> = {\n badInput: DEFAULT_INVALID_MESSAGE,\n patternMismatch: 'This value does not match the required pattern',\n rangeOverflow: 'This value is too large',\n rangeUnderflow: 'This value is too small',\n stepMismatch: 'This value does not match the required step',\n tooLong: 'This value is too long',\n tooShort: 'This value is too short',\n typeMismatch: 'This value does not match the required type',\n valid: undefined,\n valueMissing: 'This value is missing',\n};\n\nconst MESSAGE_NAME = 'FormMessage';\n\ntype FormMessageElement = FormMessageImplElement;\ninterface FormMessageProps extends Omit<FormMessageImplProps, 'name'> {\n match?: ValidityMatcher | CustomMatcher;\n forceMatch?: boolean;\n name?: string;\n}\n\nconst FormMessage = /* @__PURE__ */ React.forwardRef<FormMessageElement, FormMessageProps>(\n function FormMessage(props: ScopedProps<FormMessageProps>, forwardedRef) {\n const { match, name: nameProp, ...messageProps } = props;\n const fieldContext = useFormFieldContext(MESSAGE_NAME, props.__scopeForm, { optional: true });\n const name = nameProp ?? fieldContext?.name;\n if (!name) {\n throw new Error(\n `\\`${MESSAGE_NAME}\\` must be used within \\`${FIELD_NAME}\\` or specify the \\`name\\` prop`,\n );\n }\n\n if (match === undefined) {\n return (\n <FormMessageImpl {...messageProps} ref={forwardedRef} name={name}>\n {props.children || DEFAULT_INVALID_MESSAGE}\n </FormMessageImpl>\n );\n } else if (typeof match === 'function') {\n return <FormCustomMessage match={match} {...messageProps} ref={forwardedRef} name={name} />;\n } else {\n return <FormBuiltInMessage match={match} {...messageProps} ref={forwardedRef} name={name} />;\n }\n },\n);\n\ntype FormBuiltInMessageElement = FormMessageImplElement;\ninterface FormBuiltInMessageProps extends FormMessageImplProps {\n match: ValidityMatcher;\n forceMatch?: boolean;\n name: string;\n}\n\nconst FormBuiltInMessage = /* @__PURE__ */ React.forwardRef<\n FormBuiltInMessageElement,\n FormBuiltInMessageProps\n>(\n // blank line to reduce diff noise\n function FormBuiltInMessage(props: ScopedProps<FormBuiltInMessageProps>, forwardedRef) {\n const { match, forceMatch = false, name, children, ...messageProps } = props;\n const validationContext = useValidationContext(MESSAGE_NAME, messageProps.__scopeForm);\n const validity = validationContext.getFieldValidity(name);\n const matches = forceMatch || validity?.[match];\n\n if (matches) {\n return (\n <FormMessageImpl ref={forwardedRef} {...messageProps} name={name}>\n {children ?? DEFAULT_BUILT_IN_MESSAGES[match]}\n </FormMessageImpl>\n );\n }\n\n return null;\n },\n);\n\ntype FormCustomMessageElement = React.ComponentRef<typeof FormMessageImpl>;\ninterface FormCustomMessageProps extends React.ComponentPropsWithoutRef<typeof FormMessageImpl> {\n match: CustomMatcher;\n forceMatch?: boolean;\n name: string;\n}\n\nconst FormCustomMessage = /* @__PURE__ */ React.forwardRef<\n FormCustomMessageElement,\n FormCustomMessageProps\n>(\n // blank line to reduce diff noise\n function FormCustomMessage(props: ScopedProps<FormCustomMessageProps>, forwardedRef) {\n const { match, forceMatch = false, name, id: idProp, children, ...messageProps } = props;\n const validationContext = useValidationContext(MESSAGE_NAME, messageProps.__scopeForm);\n const ref = React.useRef<FormCustomMessageElement>(null);\n const composedRef = useComposedRefs(forwardedRef, ref);\n const _id = useId();\n const id = idProp ?? _id;\n\n const customMatcherEntry = React.useMemo(() => ({ id, match }), [id, match]);\n const { onFieldCustomMatcherEntryAdd, onFieldCustomMatcherEntryRemove } = validationContext;\n React.useEffect(() => {\n onFieldCustomMatcherEntryAdd(name, customMatcherEntry);\n return () => onFieldCustomMatcherEntryRemove(name, customMatcherEntry.id);\n }, [customMatcherEntry, name, onFieldCustomMatcherEntryAdd, onFieldCustomMatcherEntryRemove]);\n\n const validity = validationContext.getFieldValidity(name);\n const customErrors = validationContext.getFieldCustomErrors(name);\n const hasMatchingCustomError = customErrors[id];\n const matches =\n forceMatch || (validity && !hasBuiltInError(validity) && hasMatchingCustomError);\n\n if (matches) {\n return (\n <FormMessageImpl id={id} ref={composedRef} {...messageProps} name={name}>\n {children ?? DEFAULT_INVALID_MESSAGE}\n </FormMessageImpl>\n );\n }\n\n return null;\n },\n);\n\ntype FormMessageImplElement = React.ComponentRef<typeof Primitive.span>;\ntype PrimitiveSpanProps = React.ComponentPropsWithoutRef<typeof Primitive.span>;\ninterface FormMessageImplProps extends PrimitiveSpanProps {\n name: string;\n}\n\nconst FormMessageImpl = /* @__PURE__ */ React.forwardRef<\n FormMessageImplElement,\n FormMessageImplProps\n>(\n // blank line to reduce diff noise\n function FormMessageImpl(props: ScopedProps<FormMessageImplProps>, forwardedRef) {\n const { __scopeForm, id: idProp, name, ...messageProps } = props;\n const ariaDescriptionContext = useAriaDescriptionContext(MESSAGE_NAME, __scopeForm);\n const _id = useId();\n const id = idProp ?? _id;\n\n const { onFieldMessageIdAdd, onFieldMessageIdRemove } = ariaDescriptionContext;\n React.useEffect(() => {\n onFieldMessageIdAdd(name, id);\n return () => onFieldMessageIdRemove(name, id);\n }, [name, id, onFieldMessageIdAdd, onFieldMessageIdRemove]);\n\n return <Primitive.span id={id} {...messageProps} ref={forwardedRef} />;\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * FormValidityState\n * -----------------------------------------------------------------------------------------------*/\n\nconst VALIDITY_STATE_NAME = 'FormValidityState';\n\ninterface FormValidityStateProps {\n children(validity: ValidityState | undefined): React.ReactNode;\n name?: string;\n}\n\nconst FormValidityState = (props: ScopedProps<FormValidityStateProps>) => {\n const { __scopeForm, name: nameProp, children } = props;\n const validationContext = useValidationContext(VALIDITY_STATE_NAME, __scopeForm);\n const fieldContext = useFormFieldContext(VALIDITY_STATE_NAME, __scopeForm, { optional: true });\n const name = nameProp ?? fieldContext?.name;\n if (!name) {\n throw new Error(\n `\\`${VALIDITY_STATE_NAME}\\` must be used within \\`${FIELD_NAME}\\` or specify the \\`name\\` prop`,\n );\n }\n const validity = validationContext.getFieldValidity(name);\n return <>{children(validity)}</>;\n};\n\n/* -------------------------------------------------------------------------------------------------\n * FormSubmit\n * -----------------------------------------------------------------------------------------------*/\n\ntype FormSubmitElement = React.ComponentRef<typeof Primitive.button>;\ntype PrimitiveButtonProps = React.ComponentPropsWithoutRef<typeof Primitive.button>;\ninterface FormSubmitProps extends PrimitiveButtonProps {}\n\nconst FormSubmit = /* @__PURE__ */ React.forwardRef<FormSubmitElement, FormSubmitProps>(\n function FormSubmit(props: ScopedProps<FormSubmitProps>, forwardedRef) {\n const { __scopeForm, ...submitProps } = props;\n return <Primitive.button type=\"submit\" {...submitProps} ref={forwardedRef} />;\n },\n);\n\n/* -----------------------------------------------------------------------------------------------*/\n\ntype ValidityStateKey = keyof ValidityState;\ntype SyncCustomMatcher = (value: string, formData: FormData) => boolean;\ntype AsyncCustomMatcher = (value: string, formData: FormData) => Promise<boolean>;\ntype CustomMatcher = SyncCustomMatcher | AsyncCustomMatcher;\ntype CustomMatcherEntry = { id: string; match: CustomMatcher };\ntype SyncCustomMatcherEntry = { id: string; match: SyncCustomMatcher };\ntype AsyncCustomMatcherEntry = { id: string; match: AsyncCustomMatcher };\ntype CustomMatcherArgs = [string, FormData];\n\nfunction validityStateToObject(validity: ValidityState) {\n const object: any = {};\n for (const key in validity) {\n object[key] = validity[key as ValidityStateKey];\n }\n return object as Record<ValidityStateKey, boolean>;\n}\n\nfunction isHTMLElement(element: any): element is HTMLElement {\n return element instanceof HTMLElement;\n}\n\nfunction isFormControl(element: any): element is { validity: ValidityState } {\n return 'validity' in element;\n}\n\nfunction isInvalid(control: HTMLElement) {\n return (\n isFormControl(control) &&\n (control.validity.valid === false || control.getAttribute('aria-invalid') === 'true')\n );\n}\n\nfunction getFirstInvalidControl(form: HTMLFormElement): HTMLElement | null {\n const elements = form.elements;\n const [firstInvalidControl] = Array.from(elements).filter(isHTMLElement).filter(isInvalid);\n return firstInvalidControl ?? null;\n}\n\nfunction isAsyncCustomMatcherEntry(\n entry: CustomMatcherEntry,\n args: CustomMatcherArgs,\n): entry is AsyncCustomMatcherEntry {\n return entry.match.constructor.name === 'AsyncFunction' || returnsPromise(entry.match, args);\n}\n\nfunction isSyncCustomMatcherEntry(entry: CustomMatcherEntry): entry is SyncCustomMatcherEntry {\n return entry.match.constructor.name === 'Function';\n}\n\nfunction returnsPromise(func: Function, args: Array<unknown>) {\n return func(...args) instanceof Promise;\n}\n\nfunction hasBuiltInError(validity: ValidityState) {\n let error = false;\n for (const validityKey in validity) {\n const key = validityKey as ValidityStateKey;\n if (key !== 'valid' && key !== 'customError' && validity[key]) {\n error = true;\n break;\n }\n }\n return error;\n}\n\nfunction getValidAttribute(validity: ValidityState | undefined, serverInvalid: boolean) {\n if (validity?.valid === true && !serverInvalid) return true;\n return undefined;\n}\n\nfunction getInvalidAttribute(validity: ValidityState | undefined, serverInvalid: boolean) {\n if (validity?.valid === false || serverInvalid) return true;\n return undefined;\n}\n\n// TODO: Move to primitive once that package exposed individual sub-modules\nfunction concatAriaDescribedby(...values: unknown[]): string | undefined {\n const ids = new Set<string>();\n for (const value of values) {\n if (typeof value !== 'string') continue;\n for (const id of String(value).trim().split(/\\s+/)) {\n if (id) ids.add(id);\n }\n }\n\n return ids.size > 0 ? Array.from(ids).join(' ') : undefined;\n}\n\n/* -----------------------------------------------------------------------------------------------*/\n\nexport {\n createFormScope,\n //\n Form,\n FormField,\n FormLabel,\n FormControl,\n FormMessage,\n FormValidityState,\n FormSubmit,\n //\n Form as Root,\n FormField as Field,\n FormLabel as Label,\n FormControl as Control,\n FormMessage as Message,\n FormValidityState as ValidityState,\n FormSubmit as Submit,\n};\n\nexport type {\n FormProps,\n FormFieldProps,\n FormLabelProps,\n FormControlProps,\n FormMessageProps,\n FormValidityStateProps,\n FormSubmitProps,\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA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vD,SAAO;AACT;AAHS;AAMT,SAAS,yBAAyB,QAAuC;AACvE,QAAM,MAAM,oBAAI,IAAY;AAC5B,aAAW,SAAS,QAAQ;AAC1B,QAAI,OAAO,UAAU,SAAU;AAC/B,eAAW,MAAM,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,KAAK,GAAG;AAClD,UAAI,GAAI,KAAI,IAAI,EAAE;AAAA,IACpB;AAAA,EACF;AAEA,SAAO,IAAI,OAAO,IAAI,MAAM,KAAK,GAAG,EAAE,KAAK,GAAG,IAAI;AACpD;AAVS;",
6
6
  "names": ["Form", "FormField", "FormLabel", "LabelPrimitive", "FormControl", "controlValidity", "id", "hasCustomError", "FormMessage", "FormBuiltInMessage", "FormCustomMessage", "FormMessageImpl", "FormSubmit"]
7
7
  }
package/dist/index.mjs CHANGED
@@ -181,7 +181,13 @@ var FormLabel = /* @__PURE__ */ React.forwardRef(
181
181
  var CONTROL_NAME = "FormControl";
182
182
  var FormControl = /* @__PURE__ */ React.forwardRef(
183
183
  /* @__PURE__ */ __name(function FormControl2(props, forwardedRef) {
184
- const { __scopeForm, name: nameProp, id: idProp, ...controlProps } = props;
184
+ const {
185
+ __scopeForm,
186
+ name: nameProp,
187
+ id: idProp,
188
+ "aria-describedby": ariaDescribedby,
189
+ ...controlProps
190
+ } = props;
185
191
  const validationContext = useValidationContext(CONTROL_NAME, __scopeForm);
186
192
  const fieldContext = useFormFieldContext(CONTROL_NAME, __scopeForm, { optional: true });
187
193
  const ariaDescriptionContext = useAriaDescriptionContext(CONTROL_NAME, __scopeForm);
@@ -286,7 +292,10 @@ var FormControl = /* @__PURE__ */ React.forwardRef(
286
292
  "data-valid": getValidAttribute(validity, serverInvalid),
287
293
  "data-invalid": getInvalidAttribute(validity, serverInvalid),
288
294
  "aria-invalid": serverInvalid || void 0,
289
- "aria-describedby": ariaDescriptionContext.getFieldDescription(name),
295
+ "aria-describedby": concatAriaDescribedby(
296
+ ariaDescribedby,
297
+ ariaDescriptionContext.getFieldDescription(name)
298
+ ),
290
299
  title: "",
291
300
  ...controlProps,
292
301
  ref: composedRef,
@@ -469,16 +478,20 @@ function getInvalidAttribute(validity, serverInvalid) {
469
478
  return void 0;
470
479
  }
471
480
  __name(getInvalidAttribute, "getInvalidAttribute");
472
- var Root = Form;
473
- var Field = FormField;
474
- var Label = FormLabel;
475
- var Control = FormControl;
476
- var Message = FormMessage;
477
- var ValidityState = FormValidityState;
478
- var Submit = FormSubmit;
481
+ function concatAriaDescribedby(...values) {
482
+ const ids = /* @__PURE__ */ new Set();
483
+ for (const value of values) {
484
+ if (typeof value !== "string") continue;
485
+ for (const id of String(value).trim().split(/\s+/)) {
486
+ if (id) ids.add(id);
487
+ }
488
+ }
489
+ return ids.size > 0 ? Array.from(ids).join(" ") : void 0;
490
+ }
491
+ __name(concatAriaDescribedby, "concatAriaDescribedby");
479
492
  export {
480
- Control,
481
- Field,
493
+ FormControl as Control,
494
+ FormField as Field,
482
495
  Form,
483
496
  FormControl,
484
497
  FormField,
@@ -486,11 +499,11 @@ export {
486
499
  FormMessage,
487
500
  FormSubmit,
488
501
  FormValidityState,
489
- Label,
490
- Message,
491
- Root,
492
- Submit,
493
- ValidityState,
502
+ FormLabel as Label,
503
+ FormMessage as Message,
504
+ Form as Root,
505
+ FormSubmit as Submit,
506
+ FormValidityState as ValidityState,
494
507
  createFormScope
495
508
  };
496
509
  //# sourceMappingURL=index.mjs.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/form.tsx"],
4
- "sourcesContent": ["import * as React from 'react';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { createContextScope } from '@radix-ui/react-context';\nimport { useId } from '@radix-ui/react-id';\nimport { Label as LabelPrimitive } from '@radix-ui/react-label';\nimport { Primitive } from '@radix-ui/react-primitive';\n\nimport type { Scope } from '@radix-ui/react-context';\n\ntype ScopedProps<P> = P & { __scopeForm?: Scope };\nconst [createFormContext, createFormScope] = createContextScope('Form');\n\n/* -------------------------------------------------------------------------------------------------\n * Form\n * -----------------------------------------------------------------------------------------------*/\n\nconst FORM_NAME = 'Form';\n\ntype ValidityMap = { [fieldName: string]: ValidityState | undefined };\ntype CustomMatcherEntriesMap = { [fieldName: string]: CustomMatcherEntry[] };\ntype CustomErrorsMap = { [fieldName: string]: Record<string, boolean> };\n\ntype ValidationContextValue = {\n getFieldValidity(fieldName: string): ValidityState | undefined;\n onFieldValidityChange(fieldName: string, validity: ValidityState): void;\n\n getFieldCustomMatcherEntries(fieldName: string): CustomMatcherEntry[];\n onFieldCustomMatcherEntryAdd(fieldName: string, matcherEntry: CustomMatcherEntry): void;\n onFieldCustomMatcherEntryRemove(fieldName: string, matcherEntryId: string): void;\n\n getFieldCustomErrors(fieldName: string): Record<string, boolean>;\n onFieldCustomErrorsChange(fieldName: string, errors: Record<string, boolean>): void;\n\n onFieldValiditionClear(fieldName: string): void;\n};\nconst [ValidationProvider, useValidationContext] =\n createFormContext<ValidationContextValue>(FORM_NAME);\n\ntype MessageIdsMap = { [fieldName: string]: Set<string> };\n\ntype AriaDescriptionContextValue = {\n onFieldMessageIdAdd(fieldName: string, id: string): void;\n onFieldMessageIdRemove(fieldName: string, id: string): void;\n getFieldDescription(fieldName: string): string | undefined;\n};\nconst [AriaDescriptionProvider, useAriaDescriptionContext] =\n createFormContext<AriaDescriptionContextValue>(FORM_NAME);\n\ntype FormElement = React.ComponentRef<typeof Primitive.form>;\ntype PrimitiveFormProps = React.ComponentPropsWithoutRef<typeof Primitive.form>;\ninterface FormProps extends PrimitiveFormProps {\n onClearServerErrors?(): void;\n}\n\nconst Form = /* @__PURE__ */ React.forwardRef<FormElement, FormProps>(\n // blank line to reduce diff noise\n function Form(props: ScopedProps<FormProps>, forwardedRef) {\n const { __scopeForm, onClearServerErrors = () => {}, ...rootProps } = props;\n const formRef = React.useRef<HTMLFormElement>(null);\n const composedFormRef = useComposedRefs(forwardedRef, formRef);\n\n // native validity per field\n const [validityMap, setValidityMap] = React.useState<ValidityMap>({});\n const getFieldValidity: ValidationContextValue['getFieldValidity'] = React.useCallback(\n (fieldName) => validityMap[fieldName],\n [validityMap],\n );\n const handleFieldValidityChange: ValidationContextValue['onFieldValidityChange'] =\n React.useCallback(\n (fieldName, validity) =>\n setValidityMap((prevValidityMap) => ({\n ...prevValidityMap,\n [fieldName]: { ...(prevValidityMap[fieldName] ?? {}), ...validity },\n })),\n [],\n );\n const handleFieldValiditionClear: ValidationContextValue['onFieldValiditionClear'] =\n React.useCallback((fieldName) => {\n setValidityMap((prevValidityMap) => ({ ...prevValidityMap, [fieldName]: undefined }));\n setCustomErrorsMap((prevCustomErrorsMap) => ({ ...prevCustomErrorsMap, [fieldName]: {} }));\n }, []);\n\n // custom matcher entries per field\n const [customMatcherEntriesMap, setCustomMatcherEntriesMap] =\n React.useState<CustomMatcherEntriesMap>({});\n const getFieldCustomMatcherEntries: ValidationContextValue['getFieldCustomMatcherEntries'] =\n React.useCallback(\n (fieldName) => customMatcherEntriesMap[fieldName] ?? [],\n [customMatcherEntriesMap],\n );\n const handleFieldCustomMatcherAdd: ValidationContextValue['onFieldCustomMatcherEntryAdd'] =\n React.useCallback((fieldName, matcherEntry) => {\n setCustomMatcherEntriesMap((prevCustomMatcherEntriesMap) => ({\n ...prevCustomMatcherEntriesMap,\n [fieldName]: [...(prevCustomMatcherEntriesMap[fieldName] ?? []), matcherEntry],\n }));\n }, []);\n const handleFieldCustomMatcherRemove: ValidationContextValue['onFieldCustomMatcherEntryRemove'] =\n React.useCallback((fieldName, matcherEntryId) => {\n setCustomMatcherEntriesMap((prevCustomMatcherEntriesMap) => ({\n ...prevCustomMatcherEntriesMap,\n [fieldName]: (prevCustomMatcherEntriesMap[fieldName] ?? []).filter(\n (matcherEntry) => matcherEntry.id !== matcherEntryId,\n ),\n }));\n }, []);\n\n // custom errors per field\n const [customErrorsMap, setCustomErrorsMap] = React.useState<CustomErrorsMap>({});\n const getFieldCustomErrors: ValidationContextValue['getFieldCustomErrors'] = React.useCallback(\n (fieldName) => customErrorsMap[fieldName] ?? {},\n [customErrorsMap],\n );\n const handleFieldCustomErrorsChange: ValidationContextValue['onFieldCustomErrorsChange'] =\n React.useCallback((fieldName, customErrors) => {\n setCustomErrorsMap((prevCustomErrorsMap) => ({\n ...prevCustomErrorsMap,\n [fieldName]: { ...(prevCustomErrorsMap[fieldName] ?? {}), ...customErrors },\n }));\n }, []);\n\n // messageIds per field\n const [messageIdsMap, setMessageIdsMap] = React.useState<MessageIdsMap>({});\n const handleFieldMessageIdAdd: AriaDescriptionContextValue['onFieldMessageIdAdd'] =\n React.useCallback((fieldName, id) => {\n setMessageIdsMap((prevMessageIdsMap) => {\n const fieldDescriptionIds = new Set(prevMessageIdsMap[fieldName]).add(id);\n return { ...prevMessageIdsMap, [fieldName]: fieldDescriptionIds };\n });\n }, []);\n const handleFieldMessageIdRemove: AriaDescriptionContextValue['onFieldMessageIdRemove'] =\n React.useCallback((fieldName, id) => {\n setMessageIdsMap((prevMessageIdsMap) => {\n const fieldDescriptionIds = new Set(prevMessageIdsMap[fieldName]);\n fieldDescriptionIds.delete(id);\n return { ...prevMessageIdsMap, [fieldName]: fieldDescriptionIds };\n });\n }, []);\n const getFieldDescription: AriaDescriptionContextValue['getFieldDescription'] =\n React.useCallback(\n (fieldName) => Array.from(messageIdsMap[fieldName] ?? []).join(' ') || undefined,\n [messageIdsMap],\n );\n\n return (\n <ValidationProvider\n scope={__scopeForm}\n getFieldValidity={getFieldValidity}\n onFieldValidityChange={handleFieldValidityChange}\n getFieldCustomMatcherEntries={getFieldCustomMatcherEntries}\n onFieldCustomMatcherEntryAdd={handleFieldCustomMatcherAdd}\n onFieldCustomMatcherEntryRemove={handleFieldCustomMatcherRemove}\n getFieldCustomErrors={getFieldCustomErrors}\n onFieldCustomErrorsChange={handleFieldCustomErrorsChange}\n onFieldValiditionClear={handleFieldValiditionClear}\n >\n <AriaDescriptionProvider\n scope={__scopeForm}\n onFieldMessageIdAdd={handleFieldMessageIdAdd}\n onFieldMessageIdRemove={handleFieldMessageIdRemove}\n getFieldDescription={getFieldDescription}\n >\n <Primitive.form\n {...rootProps}\n ref={composedFormRef}\n // focus first invalid control when the form is submitted\n onInvalid={composeEventHandlers(props.onInvalid, (event) => {\n const firstInvalidControl = getFirstInvalidControl(event.currentTarget);\n if (firstInvalidControl === event.target) firstInvalidControl.focus();\n\n // prevent default browser UI for form validation\n event.preventDefault();\n })}\n // clear server errors when the form is re-submitted\n onSubmit={composeEventHandlers(props.onSubmit, onClearServerErrors, {\n checkForDefaultPrevented: false,\n })}\n // clear server errors when the form is reset\n onReset={composeEventHandlers(props.onReset, onClearServerErrors)}\n />\n </AriaDescriptionProvider>\n </ValidationProvider>\n );\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * FormField\n * -----------------------------------------------------------------------------------------------*/\n\nconst FIELD_NAME = 'FormField';\n\ntype FormFieldContextValue = {\n id: string;\n name: string;\n serverInvalid: boolean;\n};\nconst [FormFieldProvider, useFormFieldContext] =\n createFormContext<FormFieldContextValue>(FIELD_NAME);\n\ntype FormFieldElement = React.ComponentRef<typeof Primitive.div>;\ntype PrimitiveDivProps = React.ComponentPropsWithoutRef<typeof Primitive.div>;\ninterface FormFieldProps extends PrimitiveDivProps {\n name: string;\n serverInvalid?: boolean;\n}\n\nconst FormField = /* @__PURE__ */ React.forwardRef<FormFieldElement, FormFieldProps>(\n function FormField(props: ScopedProps<FormFieldProps>, forwardedRef) {\n const { __scopeForm, name, serverInvalid = false, ...fieldProps } = props;\n const validationContext = useValidationContext(FIELD_NAME, __scopeForm);\n const validity = validationContext.getFieldValidity(name);\n const id = useId();\n\n return (\n <FormFieldProvider scope={__scopeForm} id={id} name={name} serverInvalid={serverInvalid}>\n <Primitive.div\n data-valid={getValidAttribute(validity, serverInvalid)}\n data-invalid={getInvalidAttribute(validity, serverInvalid)}\n {...fieldProps}\n ref={forwardedRef}\n />\n </FormFieldProvider>\n );\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * FormLabel\n * -----------------------------------------------------------------------------------------------*/\n\nconst LABEL_NAME = 'FormLabel';\n\ntype FormLabelElement = React.ComponentRef<typeof LabelPrimitive>;\ntype LabelProps = React.ComponentPropsWithoutRef<typeof LabelPrimitive>;\ninterface FormLabelProps extends LabelProps {\n name?: string;\n}\n\nconst FormLabel = /* @__PURE__ */ React.forwardRef<FormLabelElement, FormLabelProps>(\n function FormLabel(props: ScopedProps<FormLabelProps>, forwardedRef) {\n const { __scopeForm, name: nameProp, ...labelProps } = props;\n const validationContext = useValidationContext(LABEL_NAME, __scopeForm);\n const fieldContext = useFormFieldContext(LABEL_NAME, __scopeForm, { optional: true });\n const name = nameProp ?? fieldContext?.name;\n if (!name) {\n throw new Error(\n `\\`${LABEL_NAME}\\` must be used within \\`${FIELD_NAME}\\` or specify the \\`name\\` prop`,\n );\n }\n\n const htmlFor = labelProps.htmlFor || fieldContext?.id;\n if (!htmlFor) {\n throw new Error(\n `\\`${LABEL_NAME}\\` must be used within \\`${FIELD_NAME}\\` or specify the \\`htmlFor\\` prop`,\n );\n }\n\n const validity = validationContext.getFieldValidity(name);\n const serverInvalid = fieldContext?.serverInvalid ?? false;\n\n return (\n <LabelPrimitive\n data-valid={getValidAttribute(validity, serverInvalid)}\n data-invalid={getInvalidAttribute(validity, serverInvalid)}\n {...labelProps}\n ref={forwardedRef}\n htmlFor={htmlFor}\n />\n );\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * FormControl\n * -----------------------------------------------------------------------------------------------*/\n\nconst CONTROL_NAME = 'FormControl';\n\ntype FormControlElement = React.ComponentRef<typeof Primitive.input>;\ntype PrimitiveInputProps = React.ComponentPropsWithoutRef<typeof Primitive.input>;\ninterface FormControlProps extends PrimitiveInputProps {}\n\nconst FormControl = /* @__PURE__ */ React.forwardRef<FormControlElement, FormControlProps>(\n function FormControl(props: ScopedProps<FormControlProps>, forwardedRef) {\n const { __scopeForm, name: nameProp, id: idProp, ...controlProps } = props;\n\n const validationContext = useValidationContext(CONTROL_NAME, __scopeForm);\n const fieldContext = useFormFieldContext(CONTROL_NAME, __scopeForm, { optional: true });\n const ariaDescriptionContext = useAriaDescriptionContext(CONTROL_NAME, __scopeForm);\n\n const ref = React.useRef<FormControlElement>(null);\n const composedRef = useComposedRefs(forwardedRef, ref);\n const name = nameProp || fieldContext?.name;\n if (!name) {\n throw new Error(\n `\\`${CONTROL_NAME}\\` must be used within \\`${FIELD_NAME}\\` or specify the \\`name\\` prop`,\n );\n }\n\n const id = idProp || fieldContext?.id;\n if (!id) {\n throw new Error(\n `\\`${CONTROL_NAME}\\` must be used within \\`${FIELD_NAME}\\` or specify the \\`id\\` prop`,\n );\n }\n\n const customMatcherEntries = validationContext.getFieldCustomMatcherEntries(name);\n\n const { onFieldValidityChange, onFieldCustomErrorsChange, onFieldValiditionClear } =\n validationContext;\n const updateControlValidity = React.useCallback(\n async (control: FormControlElement) => {\n //------------------------------------------------------------------------------------------\n // 1. first, if we have built-in errors we stop here\n\n if (hasBuiltInError(control.validity)) {\n const controlValidity = validityStateToObject(control.validity);\n onFieldValidityChange(name, controlValidity);\n return;\n }\n\n //------------------------------------------------------------------------------------------\n // 2. then gather the form data to give to custom matchers for cross-comparisons\n\n const formData = control.form ? new FormData(control.form) : new FormData();\n const matcherArgs: CustomMatcherArgs = [control.value, formData];\n\n //------------------------------------------------------------------------------------------\n // 3. split sync and async custom matcher entries\n\n const syncCustomMatcherEntries: Array<SyncCustomMatcherEntry> = [];\n const ayncCustomMatcherEntries: Array<AsyncCustomMatcherEntry> = [];\n customMatcherEntries.forEach((customMatcherEntry) => {\n if (isAsyncCustomMatcherEntry(customMatcherEntry, matcherArgs)) {\n ayncCustomMatcherEntries.push(customMatcherEntry);\n } else if (isSyncCustomMatcherEntry(customMatcherEntry)) {\n syncCustomMatcherEntries.push(customMatcherEntry);\n }\n });\n\n //------------------------------------------------------------------------------------------\n // 4. run sync custom matchers and update control validity / internal validity + errors\n\n const syncCustomErrors = syncCustomMatcherEntries.map(({ id, match }) => {\n return [id, match(...matcherArgs)] as const;\n });\n const syncCustomErrorsById = Object.fromEntries(syncCustomErrors);\n const hasSyncCustomErrors = Object.values(syncCustomErrorsById).some(Boolean);\n const hasCustomError = hasSyncCustomErrors;\n control.setCustomValidity(hasCustomError ? DEFAULT_INVALID_MESSAGE : '');\n const controlValidity = validityStateToObject(control.validity);\n onFieldValidityChange(name, controlValidity);\n onFieldCustomErrorsChange(name, syncCustomErrorsById);\n\n //------------------------------------------------------------------------------------------\n // 5. run async custom matchers and update control validity / internal validity + errors\n\n if (!hasSyncCustomErrors && ayncCustomMatcherEntries.length > 0) {\n const promisedCustomErrors = ayncCustomMatcherEntries.map(({ id, match }) =>\n match(...matcherArgs).then((matches) => [id, matches] as const),\n );\n const asyncCustomErrors = await Promise.all(promisedCustomErrors);\n const asyncCustomErrorsById = Object.fromEntries(asyncCustomErrors);\n const hasAsyncCustomErrors = Object.values(asyncCustomErrorsById).some(Boolean);\n const hasCustomError = hasAsyncCustomErrors;\n control.setCustomValidity(hasCustomError ? DEFAULT_INVALID_MESSAGE : '');\n const controlValidity = validityStateToObject(control.validity);\n onFieldValidityChange(name, controlValidity);\n onFieldCustomErrorsChange(name, asyncCustomErrorsById);\n }\n },\n [customMatcherEntries, name, onFieldCustomErrorsChange, onFieldValidityChange],\n );\n\n React.useEffect(() => {\n const control = ref.current;\n if (control) {\n // We only want validate on change (native `change` event, not React's `onChange`). This is primarily\n // a UX decision, we don't want to validate on every keystroke and React's `onChange` is the `input` event.\n const handleChange = () => updateControlValidity(control);\n control.addEventListener('change', handleChange);\n return () => control.removeEventListener('change', handleChange);\n }\n }, [updateControlValidity]);\n\n const resetControlValidity = React.useCallback(() => {\n const control = ref.current;\n if (control) {\n control.setCustomValidity('');\n onFieldValiditionClear(name);\n }\n }, [name, onFieldValiditionClear]);\n\n // reset validity and errors when the form is reset\n React.useEffect(() => {\n const form = ref.current?.form;\n if (form) {\n form.addEventListener('reset', resetControlValidity);\n return () => form.removeEventListener('reset', resetControlValidity);\n }\n }, [resetControlValidity]);\n\n const serverInvalid = fieldContext?.serverInvalid ?? false;\n\n // focus first invalid control when fields are set as invalid by server\n React.useEffect(() => {\n if (!serverInvalid) {\n return;\n }\n\n const control = ref.current;\n const form = control?.closest('form');\n const firstInvalidControl = form ? getFirstInvalidControl(form) : null;\n if (firstInvalidControl === control) {\n firstInvalidControl?.focus();\n }\n }, [serverInvalid]);\n\n const validity = validationContext.getFieldValidity(name);\n\n return (\n <Primitive.input\n data-valid={getValidAttribute(validity, serverInvalid)}\n data-invalid={getInvalidAttribute(validity, serverInvalid)}\n aria-invalid={serverInvalid || undefined}\n aria-describedby={ariaDescriptionContext.getFieldDescription(name)}\n // disable default browser behaviour of showing built-in error message on hover\n title=\"\"\n {...controlProps}\n ref={composedRef}\n id={id}\n name={name}\n onInvalid={composeEventHandlers(props.onInvalid, (event) => {\n const control = event.currentTarget;\n updateControlValidity(control);\n })}\n onChange={composeEventHandlers(props.onChange, (_event) => {\n // reset validity when user changes value\n resetControlValidity();\n })}\n />\n );\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * FormMessage\n * -----------------------------------------------------------------------------------------------*/\n\nconst _validityMatchers = [\n 'badInput',\n 'patternMismatch',\n 'rangeOverflow',\n 'rangeUnderflow',\n 'stepMismatch',\n 'tooLong',\n 'tooShort',\n 'typeMismatch',\n 'valid',\n 'valueMissing',\n] as const;\ntype ValidityMatcher = (typeof _validityMatchers)[number];\n\nconst DEFAULT_INVALID_MESSAGE = 'This value is not valid';\nconst DEFAULT_BUILT_IN_MESSAGES: Record<ValidityMatcher, string | undefined> = {\n badInput: DEFAULT_INVALID_MESSAGE,\n patternMismatch: 'This value does not match the required pattern',\n rangeOverflow: 'This value is too large',\n rangeUnderflow: 'This value is too small',\n stepMismatch: 'This value does not match the required step',\n tooLong: 'This value is too long',\n tooShort: 'This value is too short',\n typeMismatch: 'This value does not match the required type',\n valid: undefined,\n valueMissing: 'This value is missing',\n};\n\nconst MESSAGE_NAME = 'FormMessage';\n\ntype FormMessageElement = FormMessageImplElement;\ninterface FormMessageProps extends Omit<FormMessageImplProps, 'name'> {\n match?: ValidityMatcher | CustomMatcher;\n forceMatch?: boolean;\n name?: string;\n}\n\nconst FormMessage = /* @__PURE__ */ React.forwardRef<FormMessageElement, FormMessageProps>(\n function FormMessage(props: ScopedProps<FormMessageProps>, forwardedRef) {\n const { match, name: nameProp, ...messageProps } = props;\n const fieldContext = useFormFieldContext(MESSAGE_NAME, props.__scopeForm, { optional: true });\n const name = nameProp ?? fieldContext?.name;\n if (!name) {\n throw new Error(\n `\\`${MESSAGE_NAME}\\` must be used within \\`${FIELD_NAME}\\` or specify the \\`name\\` prop`,\n );\n }\n\n if (match === undefined) {\n return (\n <FormMessageImpl {...messageProps} ref={forwardedRef} name={name}>\n {props.children || DEFAULT_INVALID_MESSAGE}\n </FormMessageImpl>\n );\n } else if (typeof match === 'function') {\n return <FormCustomMessage match={match} {...messageProps} ref={forwardedRef} name={name} />;\n } else {\n return <FormBuiltInMessage match={match} {...messageProps} ref={forwardedRef} name={name} />;\n }\n },\n);\n\ntype FormBuiltInMessageElement = FormMessageImplElement;\ninterface FormBuiltInMessageProps extends FormMessageImplProps {\n match: ValidityMatcher;\n forceMatch?: boolean;\n name: string;\n}\n\nconst FormBuiltInMessage = /* @__PURE__ */ React.forwardRef<\n FormBuiltInMessageElement,\n FormBuiltInMessageProps\n>(\n // blank line to reduce diff noise\n function FormBuiltInMessage(props: ScopedProps<FormBuiltInMessageProps>, forwardedRef) {\n const { match, forceMatch = false, name, children, ...messageProps } = props;\n const validationContext = useValidationContext(MESSAGE_NAME, messageProps.__scopeForm);\n const validity = validationContext.getFieldValidity(name);\n const matches = forceMatch || validity?.[match];\n\n if (matches) {\n return (\n <FormMessageImpl ref={forwardedRef} {...messageProps} name={name}>\n {children ?? DEFAULT_BUILT_IN_MESSAGES[match]}\n </FormMessageImpl>\n );\n }\n\n return null;\n },\n);\n\ntype FormCustomMessageElement = React.ComponentRef<typeof FormMessageImpl>;\ninterface FormCustomMessageProps extends React.ComponentPropsWithoutRef<typeof FormMessageImpl> {\n match: CustomMatcher;\n forceMatch?: boolean;\n name: string;\n}\n\nconst FormCustomMessage = /* @__PURE__ */ React.forwardRef<\n FormCustomMessageElement,\n FormCustomMessageProps\n>(\n // blank line to reduce diff noise\n function FormCustomMessage(props: ScopedProps<FormCustomMessageProps>, forwardedRef) {\n const { match, forceMatch = false, name, id: idProp, children, ...messageProps } = props;\n const validationContext = useValidationContext(MESSAGE_NAME, messageProps.__scopeForm);\n const ref = React.useRef<FormCustomMessageElement>(null);\n const composedRef = useComposedRefs(forwardedRef, ref);\n const _id = useId();\n const id = idProp ?? _id;\n\n const customMatcherEntry = React.useMemo(() => ({ id, match }), [id, match]);\n const { onFieldCustomMatcherEntryAdd, onFieldCustomMatcherEntryRemove } = validationContext;\n React.useEffect(() => {\n onFieldCustomMatcherEntryAdd(name, customMatcherEntry);\n return () => onFieldCustomMatcherEntryRemove(name, customMatcherEntry.id);\n }, [customMatcherEntry, name, onFieldCustomMatcherEntryAdd, onFieldCustomMatcherEntryRemove]);\n\n const validity = validationContext.getFieldValidity(name);\n const customErrors = validationContext.getFieldCustomErrors(name);\n const hasMatchingCustomError = customErrors[id];\n const matches =\n forceMatch || (validity && !hasBuiltInError(validity) && hasMatchingCustomError);\n\n if (matches) {\n return (\n <FormMessageImpl id={id} ref={composedRef} {...messageProps} name={name}>\n {children ?? DEFAULT_INVALID_MESSAGE}\n </FormMessageImpl>\n );\n }\n\n return null;\n },\n);\n\ntype FormMessageImplElement = React.ComponentRef<typeof Primitive.span>;\ntype PrimitiveSpanProps = React.ComponentPropsWithoutRef<typeof Primitive.span>;\ninterface FormMessageImplProps extends PrimitiveSpanProps {\n name: string;\n}\n\nconst FormMessageImpl = /* @__PURE__ */ React.forwardRef<\n FormMessageImplElement,\n FormMessageImplProps\n>(\n // blank line to reduce diff noise\n function FormMessageImpl(props: ScopedProps<FormMessageImplProps>, forwardedRef) {\n const { __scopeForm, id: idProp, name, ...messageProps } = props;\n const ariaDescriptionContext = useAriaDescriptionContext(MESSAGE_NAME, __scopeForm);\n const _id = useId();\n const id = idProp ?? _id;\n\n const { onFieldMessageIdAdd, onFieldMessageIdRemove } = ariaDescriptionContext;\n React.useEffect(() => {\n onFieldMessageIdAdd(name, id);\n return () => onFieldMessageIdRemove(name, id);\n }, [name, id, onFieldMessageIdAdd, onFieldMessageIdRemove]);\n\n return <Primitive.span id={id} {...messageProps} ref={forwardedRef} />;\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * FormValidityState\n * -----------------------------------------------------------------------------------------------*/\n\nconst VALIDITY_STATE_NAME = 'FormValidityState';\n\ninterface FormValidityStateProps {\n children(validity: ValidityState | undefined): React.ReactNode;\n name?: string;\n}\n\nconst FormValidityState = (props: ScopedProps<FormValidityStateProps>) => {\n const { __scopeForm, name: nameProp, children } = props;\n const validationContext = useValidationContext(VALIDITY_STATE_NAME, __scopeForm);\n const fieldContext = useFormFieldContext(VALIDITY_STATE_NAME, __scopeForm, { optional: true });\n const name = nameProp ?? fieldContext?.name;\n if (!name) {\n throw new Error(\n `\\`${VALIDITY_STATE_NAME}\\` must be used within \\`${FIELD_NAME}\\` or specify the \\`name\\` prop`,\n );\n }\n const validity = validationContext.getFieldValidity(name);\n return <>{children(validity)}</>;\n};\n\n/* -------------------------------------------------------------------------------------------------\n * FormSubmit\n * -----------------------------------------------------------------------------------------------*/\n\ntype FormSubmitElement = React.ComponentRef<typeof Primitive.button>;\ntype PrimitiveButtonProps = React.ComponentPropsWithoutRef<typeof Primitive.button>;\ninterface FormSubmitProps extends PrimitiveButtonProps {}\n\nconst FormSubmit = /* @__PURE__ */ React.forwardRef<FormSubmitElement, FormSubmitProps>(\n function FormSubmit(props: ScopedProps<FormSubmitProps>, forwardedRef) {\n const { __scopeForm, ...submitProps } = props;\n return <Primitive.button type=\"submit\" {...submitProps} ref={forwardedRef} />;\n },\n);\n\n/* -----------------------------------------------------------------------------------------------*/\n\ntype ValidityStateKey = keyof ValidityState;\ntype SyncCustomMatcher = (value: string, formData: FormData) => boolean;\ntype AsyncCustomMatcher = (value: string, formData: FormData) => Promise<boolean>;\ntype CustomMatcher = SyncCustomMatcher | AsyncCustomMatcher;\ntype CustomMatcherEntry = { id: string; match: CustomMatcher };\ntype SyncCustomMatcherEntry = { id: string; match: SyncCustomMatcher };\ntype AsyncCustomMatcherEntry = { id: string; match: AsyncCustomMatcher };\ntype CustomMatcherArgs = [string, FormData];\n\nfunction validityStateToObject(validity: ValidityState) {\n const object: any = {};\n for (const key in validity) {\n object[key] = validity[key as ValidityStateKey];\n }\n return object as Record<ValidityStateKey, boolean>;\n}\n\nfunction isHTMLElement(element: any): element is HTMLElement {\n return element instanceof HTMLElement;\n}\n\nfunction isFormControl(element: any): element is { validity: ValidityState } {\n return 'validity' in element;\n}\n\nfunction isInvalid(control: HTMLElement) {\n return (\n isFormControl(control) &&\n (control.validity.valid === false || control.getAttribute('aria-invalid') === 'true')\n );\n}\n\nfunction getFirstInvalidControl(form: HTMLFormElement): HTMLElement | null {\n const elements = form.elements;\n const [firstInvalidControl] = Array.from(elements).filter(isHTMLElement).filter(isInvalid);\n return firstInvalidControl ?? null;\n}\n\nfunction isAsyncCustomMatcherEntry(\n entry: CustomMatcherEntry,\n args: CustomMatcherArgs,\n): entry is AsyncCustomMatcherEntry {\n return entry.match.constructor.name === 'AsyncFunction' || returnsPromise(entry.match, args);\n}\n\nfunction isSyncCustomMatcherEntry(entry: CustomMatcherEntry): entry is SyncCustomMatcherEntry {\n return entry.match.constructor.name === 'Function';\n}\n\nfunction returnsPromise(func: Function, args: Array<unknown>) {\n return func(...args) instanceof Promise;\n}\n\nfunction hasBuiltInError(validity: ValidityState) {\n let error = false;\n for (const validityKey in validity) {\n const key = validityKey as ValidityStateKey;\n if (key !== 'valid' && key !== 'customError' && validity[key]) {\n error = true;\n break;\n }\n }\n return error;\n}\n\nfunction getValidAttribute(validity: ValidityState | undefined, serverInvalid: boolean) {\n if (validity?.valid === true && !serverInvalid) return true;\n return undefined;\n}\nfunction getInvalidAttribute(validity: ValidityState | undefined, serverInvalid: boolean) {\n if (validity?.valid === false || serverInvalid) return true;\n return undefined;\n}\n\n/* -----------------------------------------------------------------------------------------------*/\n\nconst Root = Form;\nconst Field = FormField;\nconst Label = FormLabel;\nconst Control = FormControl;\nconst Message = FormMessage;\nconst ValidityState = FormValidityState;\nconst Submit = FormSubmit;\n\nexport {\n createFormScope,\n //\n Form,\n FormField,\n FormLabel,\n FormControl,\n FormMessage,\n FormValidityState,\n FormSubmit,\n //\n Root,\n Field,\n Label,\n Control,\n Message,\n ValidityState,\n Submit,\n};\n\nexport type {\n FormProps,\n FormFieldProps,\n FormLabelProps,\n FormControlProps,\n FormMessageProps,\n FormValidityStateProps,\n FormSubmitProps,\n};\n"],
5
- "mappings": ";;;;;AAAA,YAAY,WAAW;AACvB,SAAS,4BAA4B;AACrC,SAAS,uBAAuB;AAChC,SAAS,0BAA0B;AACnC,SAAS,aAAa;AACtB,SAAS,SAAS,sBAAsB;AACxC,SAAS,iBAAiB;AA6JhB,SA0dD,UA1dC;AAxJV,IAAM,CAAC,mBAAmB,eAAe,IAAI,mBAAmB,MAAM;AAMtE,IAAM,YAAY;AAmBlB,IAAM,CAAC,oBAAoB,oBAAoB,IAC7C,kBAA0C,SAAS;AASrD,IAAM,CAAC,yBAAyB,yBAAyB,IACvD,kBAA+C,SAAS;AAQ1D,IAAM,OAAuB,gBAAM;AAAA;AAAA,EAEjC,gCAASA,MAAK,OAA+B,cAAc;AACzD,UAAM,EAAE,aAAa,sBAAsB,6BAAM;AAAA,IAAC,GAAP,wBAAU,GAAG,UAAU,IAAI;AACtE,UAAM,UAAgB,aAAwB,IAAI;AAClD,UAAM,kBAAkB,gBAAgB,cAAc,OAAO;AAG7D,UAAM,CAAC,aAAa,cAAc,IAAU,eAAsB,CAAC,CAAC;AACpE,UAAM,mBAAqE;AAAA,M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AAe,MAAgB,MAAsB;AAC5D,SAAO,KAAK,GAAG,IAAI,aAAa;AAClC;AAFS;AAIT,SAAS,gBAAgB,UAAyB;AAChD,MAAI,QAAQ;AACZ,aAAW,eAAe,UAAU;AAClC,UAAM,MAAM;AACZ,QAAI,QAAQ,WAAW,QAAQ,iBAAiB,SAAS,GAAG,GAAG;AAC7D,cAAQ;AACR;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;AAVS;AAYT,SAAS,kBAAkB,UAAqC,eAAwB;AACtF,MAAI,UAAU,UAAU,QAAQ,CAAC,cAAe,QAAO;AACvD,SAAO;AACT;AAHS;AAIT,SAAS,oBAAoB,UAAqC,eAAwB;AACxF,MAAI,UAAU,UAAU,SAAS,cAAe,QAAO;AACvD,SAAO;AACT;AAHS;AAOT,IAAM,OAAO;AACb,IAAM,QAAQ;AACd,IAAM,QAAQ;AACd,IAAM,UAAU;AAChB,IAAM,UAAU;AAChB,IAAM,gBAAgB;AACtB,IAAM,SAAS;",
4
+ "sourcesContent": ["import * as React from 'react';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { createContextScope } from '@radix-ui/react-context';\nimport { useId } from '@radix-ui/react-id';\nimport { Label as LabelPrimitive } from '@radix-ui/react-label';\nimport { Primitive } from '@radix-ui/react-primitive';\n\nimport type { Scope } from '@radix-ui/react-context';\n\ntype ScopedProps<P> = P & { __scopeForm?: Scope };\nconst [createFormContext, createFormScope] = createContextScope('Form');\n\n/* -------------------------------------------------------------------------------------------------\n * Form\n * -----------------------------------------------------------------------------------------------*/\n\nconst FORM_NAME = 'Form';\n\ntype ValidityMap = { [fieldName: string]: ValidityState | undefined };\ntype CustomMatcherEntriesMap = { [fieldName: string]: CustomMatcherEntry[] };\ntype CustomErrorsMap = { [fieldName: string]: Record<string, boolean> };\n\ntype ValidationContextValue = {\n getFieldValidity(fieldName: string): ValidityState | undefined;\n onFieldValidityChange(fieldName: string, validity: ValidityState): void;\n\n getFieldCustomMatcherEntries(fieldName: string): CustomMatcherEntry[];\n onFieldCustomMatcherEntryAdd(fieldName: string, matcherEntry: CustomMatcherEntry): void;\n onFieldCustomMatcherEntryRemove(fieldName: string, matcherEntryId: string): void;\n\n getFieldCustomErrors(fieldName: string): Record<string, boolean>;\n onFieldCustomErrorsChange(fieldName: string, errors: Record<string, boolean>): void;\n\n onFieldValiditionClear(fieldName: string): void;\n};\nconst [ValidationProvider, useValidationContext] =\n createFormContext<ValidationContextValue>(FORM_NAME);\n\ntype MessageIdsMap = { [fieldName: string]: Set<string> };\n\ntype AriaDescriptionContextValue = {\n onFieldMessageIdAdd(fieldName: string, id: string): void;\n onFieldMessageIdRemove(fieldName: string, id: string): void;\n getFieldDescription(fieldName: string): string | undefined;\n};\nconst [AriaDescriptionProvider, useAriaDescriptionContext] =\n createFormContext<AriaDescriptionContextValue>(FORM_NAME);\n\ntype FormElement = React.ComponentRef<typeof Primitive.form>;\ntype PrimitiveFormProps = React.ComponentPropsWithoutRef<typeof Primitive.form>;\ninterface FormProps extends PrimitiveFormProps {\n onClearServerErrors?(): void;\n}\n\nconst Form = /* @__PURE__ */ React.forwardRef<FormElement, FormProps>(\n // blank line to reduce diff noise\n function Form(props: ScopedProps<FormProps>, forwardedRef) {\n const { __scopeForm, onClearServerErrors = () => {}, ...rootProps } = props;\n const formRef = React.useRef<HTMLFormElement>(null);\n const composedFormRef = useComposedRefs(forwardedRef, formRef);\n\n // native validity per field\n const [validityMap, setValidityMap] = React.useState<ValidityMap>({});\n const getFieldValidity: ValidationContextValue['getFieldValidity'] = React.useCallback(\n (fieldName) => validityMap[fieldName],\n [validityMap],\n );\n const handleFieldValidityChange: ValidationContextValue['onFieldValidityChange'] =\n React.useCallback(\n (fieldName, validity) =>\n setValidityMap((prevValidityMap) => ({\n ...prevValidityMap,\n [fieldName]: { ...(prevValidityMap[fieldName] ?? {}), ...validity },\n })),\n [],\n );\n const handleFieldValiditionClear: ValidationContextValue['onFieldValiditionClear'] =\n React.useCallback((fieldName) => {\n setValidityMap((prevValidityMap) => ({ ...prevValidityMap, [fieldName]: undefined }));\n setCustomErrorsMap((prevCustomErrorsMap) => ({ ...prevCustomErrorsMap, [fieldName]: {} }));\n }, []);\n\n // custom matcher entries per field\n const [customMatcherEntriesMap, setCustomMatcherEntriesMap] =\n React.useState<CustomMatcherEntriesMap>({});\n const getFieldCustomMatcherEntries: ValidationContextValue['getFieldCustomMatcherEntries'] =\n React.useCallback(\n (fieldName) => customMatcherEntriesMap[fieldName] ?? [],\n [customMatcherEntriesMap],\n );\n const handleFieldCustomMatcherAdd: ValidationContextValue['onFieldCustomMatcherEntryAdd'] =\n React.useCallback((fieldName, matcherEntry) => {\n setCustomMatcherEntriesMap((prevCustomMatcherEntriesMap) => ({\n ...prevCustomMatcherEntriesMap,\n [fieldName]: [...(prevCustomMatcherEntriesMap[fieldName] ?? []), matcherEntry],\n }));\n }, []);\n const handleFieldCustomMatcherRemove: ValidationContextValue['onFieldCustomMatcherEntryRemove'] =\n React.useCallback((fieldName, matcherEntryId) => {\n setCustomMatcherEntriesMap((prevCustomMatcherEntriesMap) => ({\n ...prevCustomMatcherEntriesMap,\n [fieldName]: (prevCustomMatcherEntriesMap[fieldName] ?? []).filter(\n (matcherEntry) => matcherEntry.id !== matcherEntryId,\n ),\n }));\n }, []);\n\n // custom errors per field\n const [customErrorsMap, setCustomErrorsMap] = React.useState<CustomErrorsMap>({});\n const getFieldCustomErrors: ValidationContextValue['getFieldCustomErrors'] = React.useCallback(\n (fieldName) => customErrorsMap[fieldName] ?? {},\n [customErrorsMap],\n );\n const handleFieldCustomErrorsChange: ValidationContextValue['onFieldCustomErrorsChange'] =\n React.useCallback((fieldName, customErrors) => {\n setCustomErrorsMap((prevCustomErrorsMap) => ({\n ...prevCustomErrorsMap,\n [fieldName]: { ...(prevCustomErrorsMap[fieldName] ?? {}), ...customErrors },\n }));\n }, []);\n\n // messageIds per field\n const [messageIdsMap, setMessageIdsMap] = React.useState<MessageIdsMap>({});\n const handleFieldMessageIdAdd: AriaDescriptionContextValue['onFieldMessageIdAdd'] =\n React.useCallback((fieldName, id) => {\n setMessageIdsMap((prevMessageIdsMap) => {\n const fieldDescriptionIds = new Set(prevMessageIdsMap[fieldName]).add(id);\n return { ...prevMessageIdsMap, [fieldName]: fieldDescriptionIds };\n });\n }, []);\n const handleFieldMessageIdRemove: AriaDescriptionContextValue['onFieldMessageIdRemove'] =\n React.useCallback((fieldName, id) => {\n setMessageIdsMap((prevMessageIdsMap) => {\n const fieldDescriptionIds = new Set(prevMessageIdsMap[fieldName]);\n fieldDescriptionIds.delete(id);\n return { ...prevMessageIdsMap, [fieldName]: fieldDescriptionIds };\n });\n }, []);\n const getFieldDescription: AriaDescriptionContextValue['getFieldDescription'] =\n React.useCallback(\n (fieldName) => Array.from(messageIdsMap[fieldName] ?? []).join(' ') || undefined,\n [messageIdsMap],\n );\n\n return (\n <ValidationProvider\n scope={__scopeForm}\n getFieldValidity={getFieldValidity}\n onFieldValidityChange={handleFieldValidityChange}\n getFieldCustomMatcherEntries={getFieldCustomMatcherEntries}\n onFieldCustomMatcherEntryAdd={handleFieldCustomMatcherAdd}\n onFieldCustomMatcherEntryRemove={handleFieldCustomMatcherRemove}\n getFieldCustomErrors={getFieldCustomErrors}\n onFieldCustomErrorsChange={handleFieldCustomErrorsChange}\n onFieldValiditionClear={handleFieldValiditionClear}\n >\n <AriaDescriptionProvider\n scope={__scopeForm}\n onFieldMessageIdAdd={handleFieldMessageIdAdd}\n onFieldMessageIdRemove={handleFieldMessageIdRemove}\n getFieldDescription={getFieldDescription}\n >\n <Primitive.form\n {...rootProps}\n ref={composedFormRef}\n // focus first invalid control when the form is submitted\n onInvalid={composeEventHandlers(props.onInvalid, (event) => {\n const firstInvalidControl = getFirstInvalidControl(event.currentTarget);\n if (firstInvalidControl === event.target) firstInvalidControl.focus();\n\n // prevent default browser UI for form validation\n event.preventDefault();\n })}\n // clear server errors when the form is re-submitted\n onSubmit={composeEventHandlers(props.onSubmit, onClearServerErrors, {\n checkForDefaultPrevented: false,\n })}\n // clear server errors when the form is reset\n onReset={composeEventHandlers(props.onReset, onClearServerErrors)}\n />\n </AriaDescriptionProvider>\n </ValidationProvider>\n );\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * FormField\n * -----------------------------------------------------------------------------------------------*/\n\nconst FIELD_NAME = 'FormField';\n\ntype FormFieldContextValue = {\n id: string;\n name: string;\n serverInvalid: boolean;\n};\nconst [FormFieldProvider, useFormFieldContext] =\n createFormContext<FormFieldContextValue>(FIELD_NAME);\n\ntype FormFieldElement = React.ComponentRef<typeof Primitive.div>;\ntype PrimitiveDivProps = React.ComponentPropsWithoutRef<typeof Primitive.div>;\ninterface FormFieldProps extends PrimitiveDivProps {\n name: string;\n serverInvalid?: boolean;\n}\n\nconst FormField = /* @__PURE__ */ React.forwardRef<FormFieldElement, FormFieldProps>(\n function FormField(props: ScopedProps<FormFieldProps>, forwardedRef) {\n const { __scopeForm, name, serverInvalid = false, ...fieldProps } = props;\n const validationContext = useValidationContext(FIELD_NAME, __scopeForm);\n const validity = validationContext.getFieldValidity(name);\n const id = useId();\n\n return (\n <FormFieldProvider scope={__scopeForm} id={id} name={name} serverInvalid={serverInvalid}>\n <Primitive.div\n data-valid={getValidAttribute(validity, serverInvalid)}\n data-invalid={getInvalidAttribute(validity, serverInvalid)}\n {...fieldProps}\n ref={forwardedRef}\n />\n </FormFieldProvider>\n );\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * FormLabel\n * -----------------------------------------------------------------------------------------------*/\n\nconst LABEL_NAME = 'FormLabel';\n\ntype FormLabelElement = React.ComponentRef<typeof LabelPrimitive>;\ntype LabelProps = React.ComponentPropsWithoutRef<typeof LabelPrimitive>;\ninterface FormLabelProps extends LabelProps {\n name?: string;\n}\n\nconst FormLabel = /* @__PURE__ */ React.forwardRef<FormLabelElement, FormLabelProps>(\n function FormLabel(props: ScopedProps<FormLabelProps>, forwardedRef) {\n const { __scopeForm, name: nameProp, ...labelProps } = props;\n const validationContext = useValidationContext(LABEL_NAME, __scopeForm);\n const fieldContext = useFormFieldContext(LABEL_NAME, __scopeForm, { optional: true });\n const name = nameProp ?? fieldContext?.name;\n if (!name) {\n throw new Error(\n `\\`${LABEL_NAME}\\` must be used within \\`${FIELD_NAME}\\` or specify the \\`name\\` prop`,\n );\n }\n\n const htmlFor = labelProps.htmlFor || fieldContext?.id;\n if (!htmlFor) {\n throw new Error(\n `\\`${LABEL_NAME}\\` must be used within \\`${FIELD_NAME}\\` or specify the \\`htmlFor\\` prop`,\n );\n }\n\n const validity = validationContext.getFieldValidity(name);\n const serverInvalid = fieldContext?.serverInvalid ?? false;\n\n return (\n <LabelPrimitive\n data-valid={getValidAttribute(validity, serverInvalid)}\n data-invalid={getInvalidAttribute(validity, serverInvalid)}\n {...labelProps}\n ref={forwardedRef}\n htmlFor={htmlFor}\n />\n );\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * FormControl\n * -----------------------------------------------------------------------------------------------*/\n\nconst CONTROL_NAME = 'FormControl';\n\ntype FormControlElement = React.ComponentRef<typeof Primitive.input>;\ntype PrimitiveInputProps = React.ComponentPropsWithoutRef<typeof Primitive.input>;\ninterface FormControlProps extends PrimitiveInputProps {}\n\nconst FormControl = /* @__PURE__ */ React.forwardRef<FormControlElement, FormControlProps>(\n function FormControl(props: ScopedProps<FormControlProps>, forwardedRef) {\n const {\n __scopeForm,\n name: nameProp,\n id: idProp,\n 'aria-describedby': ariaDescribedby,\n ...controlProps\n } = props;\n\n const validationContext = useValidationContext(CONTROL_NAME, __scopeForm);\n const fieldContext = useFormFieldContext(CONTROL_NAME, __scopeForm, { optional: true });\n const ariaDescriptionContext = useAriaDescriptionContext(CONTROL_NAME, __scopeForm);\n\n const ref = React.useRef<FormControlElement>(null);\n const composedRef = useComposedRefs(forwardedRef, ref);\n const name = nameProp || fieldContext?.name;\n if (!name) {\n throw new Error(\n `\\`${CONTROL_NAME}\\` must be used within \\`${FIELD_NAME}\\` or specify the \\`name\\` prop`,\n );\n }\n\n const id = idProp || fieldContext?.id;\n if (!id) {\n throw new Error(\n `\\`${CONTROL_NAME}\\` must be used within \\`${FIELD_NAME}\\` or specify the \\`id\\` prop`,\n );\n }\n\n const customMatcherEntries = validationContext.getFieldCustomMatcherEntries(name);\n\n const { onFieldValidityChange, onFieldCustomErrorsChange, onFieldValiditionClear } =\n validationContext;\n const updateControlValidity = React.useCallback(\n async (control: FormControlElement) => {\n //------------------------------------------------------------------------------------------\n // 1. first, if we have built-in errors we stop here\n\n if (hasBuiltInError(control.validity)) {\n const controlValidity = validityStateToObject(control.validity);\n onFieldValidityChange(name, controlValidity);\n return;\n }\n\n //------------------------------------------------------------------------------------------\n // 2. then gather the form data to give to custom matchers for cross-comparisons\n\n const formData = control.form ? new FormData(control.form) : new FormData();\n const matcherArgs: CustomMatcherArgs = [control.value, formData];\n\n //------------------------------------------------------------------------------------------\n // 3. split sync and async custom matcher entries\n\n const syncCustomMatcherEntries: Array<SyncCustomMatcherEntry> = [];\n const ayncCustomMatcherEntries: Array<AsyncCustomMatcherEntry> = [];\n customMatcherEntries.forEach((customMatcherEntry) => {\n if (isAsyncCustomMatcherEntry(customMatcherEntry, matcherArgs)) {\n ayncCustomMatcherEntries.push(customMatcherEntry);\n } else if (isSyncCustomMatcherEntry(customMatcherEntry)) {\n syncCustomMatcherEntries.push(customMatcherEntry);\n }\n });\n\n //------------------------------------------------------------------------------------------\n // 4. run sync custom matchers and update control validity / internal validity + errors\n\n const syncCustomErrors = syncCustomMatcherEntries.map(({ id, match }) => {\n return [id, match(...matcherArgs)] as const;\n });\n const syncCustomErrorsById = Object.fromEntries(syncCustomErrors);\n const hasSyncCustomErrors = Object.values(syncCustomErrorsById).some(Boolean);\n const hasCustomError = hasSyncCustomErrors;\n control.setCustomValidity(hasCustomError ? DEFAULT_INVALID_MESSAGE : '');\n const controlValidity = validityStateToObject(control.validity);\n onFieldValidityChange(name, controlValidity);\n onFieldCustomErrorsChange(name, syncCustomErrorsById);\n\n //------------------------------------------------------------------------------------------\n // 5. run async custom matchers and update control validity / internal validity + errors\n\n if (!hasSyncCustomErrors && ayncCustomMatcherEntries.length > 0) {\n const promisedCustomErrors = ayncCustomMatcherEntries.map(({ id, match }) =>\n match(...matcherArgs).then((matches) => [id, matches] as const),\n );\n const asyncCustomErrors = await Promise.all(promisedCustomErrors);\n const asyncCustomErrorsById = Object.fromEntries(asyncCustomErrors);\n const hasAsyncCustomErrors = Object.values(asyncCustomErrorsById).some(Boolean);\n const hasCustomError = hasAsyncCustomErrors;\n control.setCustomValidity(hasCustomError ? DEFAULT_INVALID_MESSAGE : '');\n const controlValidity = validityStateToObject(control.validity);\n onFieldValidityChange(name, controlValidity);\n onFieldCustomErrorsChange(name, asyncCustomErrorsById);\n }\n },\n [customMatcherEntries, name, onFieldCustomErrorsChange, onFieldValidityChange],\n );\n\n React.useEffect(() => {\n const control = ref.current;\n if (control) {\n // We only want validate on change (native `change` event, not React's `onChange`). This is primarily\n // a UX decision, we don't want to validate on every keystroke and React's `onChange` is the `input` event.\n const handleChange = () => updateControlValidity(control);\n control.addEventListener('change', handleChange);\n return () => control.removeEventListener('change', handleChange);\n }\n }, [updateControlValidity]);\n\n const resetControlValidity = React.useCallback(() => {\n const control = ref.current;\n if (control) {\n control.setCustomValidity('');\n onFieldValiditionClear(name);\n }\n }, [name, onFieldValiditionClear]);\n\n // reset validity and errors when the form is reset\n React.useEffect(() => {\n const form = ref.current?.form;\n if (form) {\n form.addEventListener('reset', resetControlValidity);\n return () => form.removeEventListener('reset', resetControlValidity);\n }\n }, [resetControlValidity]);\n\n const serverInvalid = fieldContext?.serverInvalid ?? false;\n\n // focus first invalid control when fields are set as invalid by server\n React.useEffect(() => {\n if (!serverInvalid) {\n return;\n }\n\n const control = ref.current;\n const form = control?.closest('form');\n const firstInvalidControl = form ? getFirstInvalidControl(form) : null;\n if (firstInvalidControl === control) {\n firstInvalidControl?.focus();\n }\n }, [serverInvalid]);\n\n const validity = validationContext.getFieldValidity(name);\n\n return (\n <Primitive.input\n data-valid={getValidAttribute(validity, serverInvalid)}\n data-invalid={getInvalidAttribute(validity, serverInvalid)}\n aria-invalid={serverInvalid || undefined}\n aria-describedby={concatAriaDescribedby(\n ariaDescribedby,\n ariaDescriptionContext.getFieldDescription(name),\n )}\n // disable default browser behaviour of showing built-in error message on hover\n title=\"\"\n {...controlProps}\n ref={composedRef}\n id={id}\n name={name}\n onInvalid={composeEventHandlers(props.onInvalid, (event) => {\n const control = event.currentTarget;\n updateControlValidity(control);\n })}\n onChange={composeEventHandlers(props.onChange, (_event) => {\n // reset validity when user changes value\n resetControlValidity();\n })}\n />\n );\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * FormMessage\n * -----------------------------------------------------------------------------------------------*/\n\nconst _validityMatchers = [\n 'badInput',\n 'patternMismatch',\n 'rangeOverflow',\n 'rangeUnderflow',\n 'stepMismatch',\n 'tooLong',\n 'tooShort',\n 'typeMismatch',\n 'valid',\n 'valueMissing',\n] as const;\ntype ValidityMatcher = (typeof _validityMatchers)[number];\n\nconst DEFAULT_INVALID_MESSAGE = 'This value is not valid';\nconst DEFAULT_BUILT_IN_MESSAGES: Record<ValidityMatcher, string | undefined> = {\n badInput: DEFAULT_INVALID_MESSAGE,\n patternMismatch: 'This value does not match the required pattern',\n rangeOverflow: 'This value is too large',\n rangeUnderflow: 'This value is too small',\n stepMismatch: 'This value does not match the required step',\n tooLong: 'This value is too long',\n tooShort: 'This value is too short',\n typeMismatch: 'This value does not match the required type',\n valid: undefined,\n valueMissing: 'This value is missing',\n};\n\nconst MESSAGE_NAME = 'FormMessage';\n\ntype FormMessageElement = FormMessageImplElement;\ninterface FormMessageProps extends Omit<FormMessageImplProps, 'name'> {\n match?: ValidityMatcher | CustomMatcher;\n forceMatch?: boolean;\n name?: string;\n}\n\nconst FormMessage = /* @__PURE__ */ React.forwardRef<FormMessageElement, FormMessageProps>(\n function FormMessage(props: ScopedProps<FormMessageProps>, forwardedRef) {\n const { match, name: nameProp, ...messageProps } = props;\n const fieldContext = useFormFieldContext(MESSAGE_NAME, props.__scopeForm, { optional: true });\n const name = nameProp ?? fieldContext?.name;\n if (!name) {\n throw new Error(\n `\\`${MESSAGE_NAME}\\` must be used within \\`${FIELD_NAME}\\` or specify the \\`name\\` prop`,\n );\n }\n\n if (match === undefined) {\n return (\n <FormMessageImpl {...messageProps} ref={forwardedRef} name={name}>\n {props.children || DEFAULT_INVALID_MESSAGE}\n </FormMessageImpl>\n );\n } else if (typeof match === 'function') {\n return <FormCustomMessage match={match} {...messageProps} ref={forwardedRef} name={name} />;\n } else {\n return <FormBuiltInMessage match={match} {...messageProps} ref={forwardedRef} name={name} />;\n }\n },\n);\n\ntype FormBuiltInMessageElement = FormMessageImplElement;\ninterface FormBuiltInMessageProps extends FormMessageImplProps {\n match: ValidityMatcher;\n forceMatch?: boolean;\n name: string;\n}\n\nconst FormBuiltInMessage = /* @__PURE__ */ React.forwardRef<\n FormBuiltInMessageElement,\n FormBuiltInMessageProps\n>(\n // blank line to reduce diff noise\n function FormBuiltInMessage(props: ScopedProps<FormBuiltInMessageProps>, forwardedRef) {\n const { match, forceMatch = false, name, children, ...messageProps } = props;\n const validationContext = useValidationContext(MESSAGE_NAME, messageProps.__scopeForm);\n const validity = validationContext.getFieldValidity(name);\n const matches = forceMatch || validity?.[match];\n\n if (matches) {\n return (\n <FormMessageImpl ref={forwardedRef} {...messageProps} name={name}>\n {children ?? DEFAULT_BUILT_IN_MESSAGES[match]}\n </FormMessageImpl>\n );\n }\n\n return null;\n },\n);\n\ntype FormCustomMessageElement = React.ComponentRef<typeof FormMessageImpl>;\ninterface FormCustomMessageProps extends React.ComponentPropsWithoutRef<typeof FormMessageImpl> {\n match: CustomMatcher;\n forceMatch?: boolean;\n name: string;\n}\n\nconst FormCustomMessage = /* @__PURE__ */ React.forwardRef<\n FormCustomMessageElement,\n FormCustomMessageProps\n>(\n // blank line to reduce diff noise\n function FormCustomMessage(props: ScopedProps<FormCustomMessageProps>, forwardedRef) {\n const { match, forceMatch = false, name, id: idProp, children, ...messageProps } = props;\n const validationContext = useValidationContext(MESSAGE_NAME, messageProps.__scopeForm);\n const ref = React.useRef<FormCustomMessageElement>(null);\n const composedRef = useComposedRefs(forwardedRef, ref);\n const _id = useId();\n const id = idProp ?? _id;\n\n const customMatcherEntry = React.useMemo(() => ({ id, match }), [id, match]);\n const { onFieldCustomMatcherEntryAdd, onFieldCustomMatcherEntryRemove } = validationContext;\n React.useEffect(() => {\n onFieldCustomMatcherEntryAdd(name, customMatcherEntry);\n return () => onFieldCustomMatcherEntryRemove(name, customMatcherEntry.id);\n }, [customMatcherEntry, name, onFieldCustomMatcherEntryAdd, onFieldCustomMatcherEntryRemove]);\n\n const validity = validationContext.getFieldValidity(name);\n const customErrors = validationContext.getFieldCustomErrors(name);\n const hasMatchingCustomError = customErrors[id];\n const matches =\n forceMatch || (validity && !hasBuiltInError(validity) && hasMatchingCustomError);\n\n if (matches) {\n return (\n <FormMessageImpl id={id} ref={composedRef} {...messageProps} name={name}>\n {children ?? DEFAULT_INVALID_MESSAGE}\n </FormMessageImpl>\n );\n }\n\n return null;\n },\n);\n\ntype FormMessageImplElement = React.ComponentRef<typeof Primitive.span>;\ntype PrimitiveSpanProps = React.ComponentPropsWithoutRef<typeof Primitive.span>;\ninterface FormMessageImplProps extends PrimitiveSpanProps {\n name: string;\n}\n\nconst FormMessageImpl = /* @__PURE__ */ React.forwardRef<\n FormMessageImplElement,\n FormMessageImplProps\n>(\n // blank line to reduce diff noise\n function FormMessageImpl(props: ScopedProps<FormMessageImplProps>, forwardedRef) {\n const { __scopeForm, id: idProp, name, ...messageProps } = props;\n const ariaDescriptionContext = useAriaDescriptionContext(MESSAGE_NAME, __scopeForm);\n const _id = useId();\n const id = idProp ?? _id;\n\n const { onFieldMessageIdAdd, onFieldMessageIdRemove } = ariaDescriptionContext;\n React.useEffect(() => {\n onFieldMessageIdAdd(name, id);\n return () => onFieldMessageIdRemove(name, id);\n }, [name, id, onFieldMessageIdAdd, onFieldMessageIdRemove]);\n\n return <Primitive.span id={id} {...messageProps} ref={forwardedRef} />;\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * FormValidityState\n * -----------------------------------------------------------------------------------------------*/\n\nconst VALIDITY_STATE_NAME = 'FormValidityState';\n\ninterface FormValidityStateProps {\n children(validity: ValidityState | undefined): React.ReactNode;\n name?: string;\n}\n\nconst FormValidityState = (props: ScopedProps<FormValidityStateProps>) => {\n const { __scopeForm, name: nameProp, children } = props;\n const validationContext = useValidationContext(VALIDITY_STATE_NAME, __scopeForm);\n const fieldContext = useFormFieldContext(VALIDITY_STATE_NAME, __scopeForm, { optional: true });\n const name = nameProp ?? fieldContext?.name;\n if (!name) {\n throw new Error(\n `\\`${VALIDITY_STATE_NAME}\\` must be used within \\`${FIELD_NAME}\\` or specify the \\`name\\` prop`,\n );\n }\n const validity = validationContext.getFieldValidity(name);\n return <>{children(validity)}</>;\n};\n\n/* -------------------------------------------------------------------------------------------------\n * FormSubmit\n * -----------------------------------------------------------------------------------------------*/\n\ntype FormSubmitElement = React.ComponentRef<typeof Primitive.button>;\ntype PrimitiveButtonProps = React.ComponentPropsWithoutRef<typeof Primitive.button>;\ninterface FormSubmitProps extends PrimitiveButtonProps {}\n\nconst FormSubmit = /* @__PURE__ */ React.forwardRef<FormSubmitElement, FormSubmitProps>(\n function FormSubmit(props: ScopedProps<FormSubmitProps>, forwardedRef) {\n const { __scopeForm, ...submitProps } = props;\n return <Primitive.button type=\"submit\" {...submitProps} ref={forwardedRef} />;\n },\n);\n\n/* -----------------------------------------------------------------------------------------------*/\n\ntype ValidityStateKey = keyof ValidityState;\ntype SyncCustomMatcher = (value: string, formData: FormData) => boolean;\ntype AsyncCustomMatcher = (value: string, formData: FormData) => Promise<boolean>;\ntype CustomMatcher = SyncCustomMatcher | AsyncCustomMatcher;\ntype CustomMatcherEntry = { id: string; match: CustomMatcher };\ntype SyncCustomMatcherEntry = { id: string; match: SyncCustomMatcher };\ntype AsyncCustomMatcherEntry = { id: string; match: AsyncCustomMatcher };\ntype CustomMatcherArgs = [string, FormData];\n\nfunction validityStateToObject(validity: ValidityState) {\n const object: any = {};\n for (const key in validity) {\n object[key] = validity[key as ValidityStateKey];\n }\n return object as Record<ValidityStateKey, boolean>;\n}\n\nfunction isHTMLElement(element: any): element is HTMLElement {\n return element instanceof HTMLElement;\n}\n\nfunction isFormControl(element: any): element is { validity: ValidityState } {\n return 'validity' in element;\n}\n\nfunction isInvalid(control: HTMLElement) {\n return (\n isFormControl(control) &&\n (control.validity.valid === false || control.getAttribute('aria-invalid') === 'true')\n );\n}\n\nfunction getFirstInvalidControl(form: HTMLFormElement): HTMLElement | null {\n const elements = form.elements;\n const [firstInvalidControl] = Array.from(elements).filter(isHTMLElement).filter(isInvalid);\n return firstInvalidControl ?? null;\n}\n\nfunction isAsyncCustomMatcherEntry(\n entry: CustomMatcherEntry,\n args: CustomMatcherArgs,\n): entry is AsyncCustomMatcherEntry {\n return entry.match.constructor.name === 'AsyncFunction' || returnsPromise(entry.match, args);\n}\n\nfunction isSyncCustomMatcherEntry(entry: CustomMatcherEntry): entry is SyncCustomMatcherEntry {\n return entry.match.constructor.name === 'Function';\n}\n\nfunction returnsPromise(func: Function, args: Array<unknown>) {\n return func(...args) instanceof Promise;\n}\n\nfunction hasBuiltInError(validity: ValidityState) {\n let error = false;\n for (const validityKey in validity) {\n const key = validityKey as ValidityStateKey;\n if (key !== 'valid' && key !== 'customError' && validity[key]) {\n error = true;\n break;\n }\n }\n return error;\n}\n\nfunction getValidAttribute(validity: ValidityState | undefined, serverInvalid: boolean) {\n if (validity?.valid === true && !serverInvalid) return true;\n return undefined;\n}\n\nfunction getInvalidAttribute(validity: ValidityState | undefined, serverInvalid: boolean) {\n if (validity?.valid === false || serverInvalid) return true;\n return undefined;\n}\n\n// TODO: Move to primitive once that package exposed individual sub-modules\nfunction concatAriaDescribedby(...values: unknown[]): string | undefined {\n const ids = new Set<string>();\n for (const value of values) {\n if (typeof value !== 'string') continue;\n for (const id of String(value).trim().split(/\\s+/)) {\n if (id) ids.add(id);\n }\n }\n\n return ids.size > 0 ? Array.from(ids).join(' ') : undefined;\n}\n\n/* -----------------------------------------------------------------------------------------------*/\n\nexport {\n createFormScope,\n //\n Form,\n FormField,\n FormLabel,\n FormControl,\n FormMessage,\n FormValidityState,\n FormSubmit,\n //\n Form as Root,\n FormField as Field,\n FormLabel as Label,\n FormControl as Control,\n FormMessage as Message,\n FormValidityState as ValidityState,\n FormSubmit as Submit,\n};\n\nexport type {\n FormProps,\n FormFieldProps,\n FormLabelProps,\n FormControlProps,\n FormMessageProps,\n FormValidityStateProps,\n FormSubmitProps,\n};\n"],
5
+ "mappings": ";;;;;AAAA,YAAY,WAAW;AACvB,SAAS,4BAA4B;AACrC,SAAS,uBAAuB;AAChC,SAAS,0BAA0B;AACnC,SAAS,aAAa;AACtB,SAAS,SAAS,sBAAsB;AACxC,SAAS,iBAAiB;AA6JhB,SAmeD,UAneC;AAxJV,IAAM,CAAC,mBAAmB,eAAe,IAAI,mBAAmB,MAAM;AAMtE,IAAM,YAAY;AAmBlB,IAAM,CAAC,oBAAoB,oBAAoB,IAC7C,kBAA0C,SAAS;AASrD,IAAM,CAAC,yBAAyB,yBAAyB,IACvD,kBAA+C,SAAS;AAQ1D,IAAM,OAAuB,gBAAM;AAAA;AAAA,EAEjC,gCAASA,MAAK,OAA+B,cAAc;AACzD,UAAM,EAAE,aAAa,sBAAsB,6BAAM;AAAA,IAAC,GAAP,wBAAU,GAAG,UAAU,IAAI;AACtE,UAAM,UAAgB,aAAwB,IAAI;AAClD,UAAM,kBAAkB,gBAAgB,cAAc,OAAO;AAG7D,UAAM,CAAC,aAAa,cAAc,IAAU,eAAsB,CAAC,CAAC;AACpE,UAAM,mBAAqE;AAAA,MACzE,CAAC,cAAc,YAAY,SAAS;AAAA,MACpC,CAAC,WAAW;AAAA,IACd;AACA,UAAM,4BACE;AAAA,MACJ,CAAC,WAAW,a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,SAAO,KAAK,GAAG,IAAI,aAAa;AAClC;AAFS;AAIT,SAAS,gBAAgB,UAAyB;AAChD,MAAI,QAAQ;AACZ,aAAW,eAAe,UAAU;AAClC,UAAM,MAAM;AACZ,QAAI,QAAQ,WAAW,QAAQ,iBAAiB,SAAS,GAAG,GAAG;AAC7D,cAAQ;AACR;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;AAVS;AAYT,SAAS,kBAAkB,UAAqC,eAAwB;AACtF,MAAI,UAAU,UAAU,QAAQ,CAAC,cAAe,QAAO;AACvD,SAAO;AACT;AAHS;AAKT,SAAS,oBAAoB,UAAqC,eAAwB;AACxF,MAAI,UAAU,UAAU,SAAS,cAAe,QAAO;AACvD,SAAO;AACT;AAHS;AAMT,SAAS,yBAAyB,QAAuC;AACvE,QAAM,MAAM,oBAAI,IAAY;AAC5B,aAAW,SAAS,QAAQ;AAC1B,QAAI,OAAO,UAAU,SAAU;AAC/B,eAAW,MAAM,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,KAAK,GAAG;AAClD,UAAI,GAAI,KAAI,IAAI,EAAE;AAAA,IACpB;AAAA,EACF;AAEA,SAAO,IAAI,OAAO,IAAI,MAAM,KAAK,GAAG,EAAE,KAAK,GAAG,IAAI;AACpD;AAVS;",
6
6
  "names": ["Form", "FormField", "FormLabel", "FormControl", "controlValidity", "id", "hasCustomError", "FormMessage", "FormBuiltInMessage", "FormCustomMessage", "FormMessageImpl", "FormSubmit"]
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@radix-ui/react-form",
3
- "version": "0.1.13-rc.1784507240898",
3
+ "version": "0.1.14",
4
4
  "license": "MIT",
5
5
  "source": "./src/index.ts",
6
6
  "main": "./dist/index.js",
@@ -11,20 +11,20 @@
11
11
  ],
12
12
  "sideEffects": false,
13
13
  "dependencies": {
14
- "@radix-ui/react-id": "1.1.2",
15
- "@radix-ui/react-label": "2.1.12-rc.1784507240898",
16
- "@radix-ui/react-context": "1.2.0",
17
- "@radix-ui/primitive": "1.1.6-rc.1784507240898",
18
- "@radix-ui/react-compose-refs": "1.1.3",
19
- "@radix-ui/react-primitive": "2.1.7"
14
+ "@radix-ui/react-compose-refs": "1.1.4",
15
+ "@radix-ui/primitive": "1.1.7",
16
+ "@radix-ui/react-id": "1.1.3",
17
+ "@radix-ui/react-context": "1.2.1",
18
+ "@radix-ui/react-label": "2.1.13",
19
+ "@radix-ui/react-primitive": "2.1.8"
20
20
  },
21
21
  "devDependencies": {
22
- "@types/react": "^19.2.2",
23
- "@types/react-dom": "^19.2.2",
24
- "react": "^19.2.0",
25
- "react-dom": "^19.2.0",
22
+ "@types/react": "^19.2.17",
23
+ "@types/react-dom": "^19.2.3",
24
+ "react": "^19.2.7",
25
+ "react-dom": "^19.2.7",
26
26
  "typescript": "^5.9.3",
27
- "@repo/builder": "0.0.1-rc.1784507240898",
27
+ "@repo/builder": "0.0.0",
28
28
  "@repo/typescript-config": "0.0.0"
29
29
  },
30
30
  "peerDependencies": {