react-f0rm 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/dist/devtools/index.cjs.js +20 -13
  2. package/dist/devtools/index.cjs.js.map +1 -1
  3. package/dist/devtools/index.d.ts +1 -1
  4. package/dist/devtools/index.mjs +20 -13
  5. package/dist/devtools/index.mjs.map +1 -1
  6. package/dist/{form-b9441d8c.cjs.js → form-B4r7INJ0.cjs.js} +10 -39
  7. package/dist/form-B4r7INJ0.cjs.js.map +1 -0
  8. package/dist/{form-61297bc0.d.ts → form-DeRFdFKE.d.ts} +2 -2
  9. package/dist/{form-94c70b4b.mjs → form-R1hDKjBm.mjs} +11 -40
  10. package/dist/form-R1hDKjBm.mjs.map +1 -0
  11. package/dist/index.cjs.js +20 -13
  12. package/dist/index.cjs.js.map +1 -1
  13. package/dist/index.d.ts +11 -8
  14. package/dist/index.mjs +21 -14
  15. package/dist/index.mjs.map +1 -1
  16. package/dist/index.umd.js +20 -13
  17. package/dist/index.umd.js.map +1 -1
  18. package/dist/index.umd.min.js +2 -2
  19. package/dist/index.umd.min.js.map +1 -1
  20. package/dist/resolvers/standard-schema.cjs.js +1 -1
  21. package/dist/resolvers/standard-schema.cjs.js.map +1 -1
  22. package/dist/resolvers/standard-schema.d.ts +2 -2
  23. package/dist/resolvers/standard-schema.mjs +1 -1
  24. package/dist/resolvers/standard-schema.mjs.map +1 -1
  25. package/dist/resolvers/yup.cjs.js +5 -7
  26. package/dist/resolvers/yup.cjs.js.map +1 -1
  27. package/dist/resolvers/yup.d.ts +2 -2
  28. package/dist/resolvers/yup.mjs +5 -7
  29. package/dist/resolvers/yup.mjs.map +1 -1
  30. package/dist/resolvers/zod.cjs.js +5 -7
  31. package/dist/resolvers/zod.cjs.js.map +1 -1
  32. package/dist/resolvers/zod.d.ts +2 -2
  33. package/dist/resolvers/zod.mjs +5 -7
  34. package/dist/resolvers/zod.mjs.map +1 -1
  35. package/dist/{validate-148fe167.d.ts → validate-B7S9EiRT.d.ts} +1 -1
  36. package/package.json +52 -51
  37. package/dist/form-94c70b4b.mjs.map +0 -1
  38. package/dist/form-b9441d8c.cjs.js.map +0 -1
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var form = require('../form-b9441d8c.cjs.js');
3
+ var form = require('../form-B4r7INJ0.cjs.js');
4
4
 
5
5
  function hasStandardProps(schema) {
6
6
  return !!schema && typeof schema === "object" && typeof schema["~standard"]?.validate === "function";
@@ -1 +1 @@
1
- {"version":3,"file":"standard-schema.cjs.js","sources":["../../src/resolvers/standard-schema.ts"],"sourcesContent":["import {VALIDATION_OUTCOME} from '../form';\nimport type {FieldError, ValidationOutcome} from '../form';\nimport type {Validator} from '../hooks/validate';\n\n/**\n * Minimal copy of the Standard Schema v1 interfaces\n * (https://standardschema.dev) so this module has zero runtime and type\n * dependencies on any schema library. Implemented by zod v3.24+/v4,\n * valibot v1, arktype and others.\n */\nexport interface StandardSchemaIssue {\n readonly message: string;\n readonly path?:\n | ReadonlyArray<PropertyKey | {readonly key: PropertyKey}>\n | undefined;\n}\n\nexport interface StandardSchemaV1<Input = unknown, Output = Input> {\n readonly '~standard': {\n readonly version: 1;\n readonly vendor: string;\n readonly validate: (\n value: Input\n ) =>\n | {readonly value: Output; readonly issues?: undefined}\n | {readonly issues: ReadonlyArray<StandardSchemaIssue>}\n | Promise<\n | {readonly value: Output; readonly issues?: undefined}\n | {readonly issues: ReadonlyArray<StandardSchemaIssue>}\n >;\n };\n}\n\n/**\n * Does the schema implement the Standard Schema v1 props?\n */\nexport function hasStandardProps(schema: any): schema is StandardSchemaV1 {\n return (\n !!schema &&\n typeof schema === 'object' &&\n typeof schema['~standard']?.validate === 'function'\n );\n}\n\nfunction toFieldError(issue: StandardSchemaIssue | undefined): FieldError {\n return {type: 'standard', message: issue?.message || 'Validation failed'};\n}\n\n/**\n * Field-level Standard Schema adapter: validate a single value with any\n * schema implementing '~standard' and map every issue to a FieldError,\n * so a value breaking several rules surfaces all of them (setErrorByPath\n * stores the array; error/errorObject readers still see the first).\n *\n * @param schema a Standard Schema v1 (zod v3.24+/v4, valibot v1, arktype...)\n * @return field validator compatible with useField's validate option\n */\nexport function standardSchemaResolver(schema: StandardSchemaV1): Validator {\n return async (value: any) => {\n const result = await schema['~standard'].validate(value);\n if (!result.issues?.length) return undefined;\n return result.issues.map(toFieldError);\n };\n}\n\n/**\n * Form-level Standard Schema adapter: validate the whole values object with\n * any schema implementing '~standard' and return a ValidationOutcome. On\n * failure `errors` carries the nested shape Options.validate expects\n * ({a: {b: FieldError[]}}; ensureValidate flattens it back to per-field\n * errors, keeping every issue of a path). Issues without a path are\n * form-level errors and land on the '_form' key. On success `values`\n * carries the schema's parsed output (coerce/transform results included),\n * which the form stores as its parsedValues baseline — the layer getValues\n * reads above initialValues, mirroring how react-hook-form's zodResolver\n * and TanStack's standardSchemaValidators use the parsed value.\n *\n * @param schema a Standard Schema v1 (zod v3.24+/v4, valibot v1, arktype...)\n * @return form-level validator for createForm({validate: ...})\n */\nexport function standardSchemaFormValidator<T extends Record<string, any>>(\n schema: StandardSchemaV1<T, any>\n): (values: T) => Promise<ValidationOutcome<T>> {\n return async (values: T) => {\n const result = await schema['~standard'].validate(values);\n const {issues} = result;\n if (!issues?.length) {\n // Success: expose the schema's parsed output. `in` keeps the union\n // narrowed (the success variant is the one carrying `value`).\n return {\n [VALIDATION_OUTCOME]: true,\n values: 'value' in result ? result.value : undefined\n };\n }\n const errors: Record<string, any> = {};\n for (const issue of issues) {\n const segments = toPathSegments(issue);\n if (segments.length) {\n assignAtPath(errors, segments, toFieldError(issue));\n } else {\n // Pathless issues are all form-level: they accumulate on '_form'\n // instead of the first shadowing the rest. (A nested path literally\n // named '_form' would have made the slot a branch — skip then.)\n const slot = (errors._form ??= []);\n if (Array.isArray(slot)) slot.push(toFieldError(issue));\n }\n }\n return {[VALIDATION_OUTCOME]: true, errors: pruneEmpty(errors) || {}};\n };\n}\n\n/**\n * Stringify an issue path: PropertyKey or {key} path segments → strings.\n */\nfunction toPathSegments(issue: StandardSchemaIssue): string[] {\n const path = issue.path || [];\n const segments: string[] = [];\n for (const segment of path) {\n const key =\n typeof segment === 'object' && segment !== null\n ? (segment as {key: PropertyKey}).key\n : segment;\n segments.push(String(key));\n }\n return segments;\n}\n\n/**\n * Append the error at a nested path. Leaves are FieldError[] arrays, so\n * several issues on one field accumulate in issue order; an issue whose\n * path conflicts with an existing leaf or crosses it is skipped.\n */\nfunction assignAtPath(\n root: Record<string, any>,\n segments: string[],\n error: FieldError\n): void {\n let node = root;\n for (let i = 0; i < segments.length - 1; i++) {\n const segment = segments[i];\n let next = node[segment];\n if (next === undefined) {\n next = node[segment] = {};\n }\n if (!isBranch(next)) return;\n node = next;\n }\n const leaf = segments[segments.length - 1];\n const slot = node[leaf];\n if (slot === undefined) node[leaf] = [error];\n else if (Array.isArray(slot)) slot.push(error);\n}\n\n/**\n * A branch is a plain container built while nesting; the leaves it carries\n * are the FieldError[] arrays assignAtPath appends.\n */\nfunction isBranch(value: any): value is Record<string, any> {\n return !!value && typeof value === 'object' && !Array.isArray(value);\n}\n\n/**\n * Drop empty branch objects left behind by conflicting issue paths.\n */\nfunction pruneEmpty(\n node: Record<string, any>\n): Record<string, any> | undefined {\n let hasLeaf = false;\n const result: Record<string, any> = {};\n Object.entries(node).forEach(([key, value]) => {\n if (isBranch(value)) {\n const pruned = pruneEmpty(value);\n if (pruned) {\n result[key] = pruned;\n hasLeaf = true;\n }\n } else {\n result[key] = value;\n hasLeaf = true;\n }\n });\n return hasLeaf ? result : undefined;\n}\n"],"names":["VALIDATION_OUTCOME"],"mappings":";;;;AAoCO,SAAS,iBAAiB,MAAyC,EAAA;AACxE,EACE,OAAA,CAAC,CAAC,MAAA,IACF,OAAO,MAAA,KAAW,YAClB,OAAO,MAAA,CAAO,WAAW,CAAA,EAAG,QAAa,KAAA,UAAA,CAAA;AAE7C,CAAA;AAEA,SAAS,aA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OME} from '../form';\nimport type {FieldError, ValidationOutcome} from '../form';\nimport type {Validator} from '../hooks/validate';\n\n/**\n * Minimal copy of the Standard Schema v1 interfaces\n * (https://standardschema.dev) so this module has zero runtime and type\n * dependencies on any schema library. Implemented by zod v3.24+/v4,\n * valibot v1, arktype and others.\n */\nexport interface StandardSchemaIssue {\n readonly message: string;\n readonly path?:\n ReadonlyArray<PropertyKey | {readonly key: PropertyKey}> | undefined;\n}\n\nexport interface StandardSchemaV1<Input = unknown, Output = Input> {\n readonly '~standard': {\n readonly version: 1;\n readonly vendor: string;\n readonly validate: (\n value: Input\n ) =>\n | {readonly value: Output; readonly issues?: undefined}\n | {readonly issues: ReadonlyArray<StandardSchemaIssue>}\n | Promise<\n | {readonly value: Output; readonly issues?: undefined}\n | {readonly issues: ReadonlyArray<StandardSchemaIssue>}\n >;\n };\n}\n\n/**\n * Does the schema implement the Standard Schema v1 props?\n */\nexport function hasStandardProps(schema: any): schema is StandardSchemaV1 {\n return (\n !!schema &&\n typeof schema === 'object' &&\n typeof schema['~standard']?.validate === 'function'\n );\n}\n\nfunction toFieldError(issue: StandardSchemaIssue | undefined): FieldError {\n return {type: 'standard', message: issue?.message || 'Validation failed'};\n}\n\n/**\n * Field-level Standard Schema adapter: validate a single value with any\n * schema implementing '~standard' and map every issue to a FieldError,\n * so a value breaking several rules surfaces all of them (setErrorByPath\n * stores the array; error/errorObject readers still see the first).\n *\n * @param schema a Standard Schema v1 (zod v3.24+/v4, valibot v1, arktype...)\n * @return field validator compatible with useField's validate option\n */\nexport function standardSchemaResolver(schema: StandardSchemaV1): Validator {\n return async (value: any) => {\n const result = await schema['~standard'].validate(value);\n if (!result.issues?.length) return undefined;\n return result.issues.map(toFieldError);\n };\n}\n\n/**\n * Form-level Standard Schema adapter: validate the whole values object with\n * any schema implementing '~standard' and return a ValidationOutcome. On\n * failure `errors` carries the nested shape Options.validate expects\n * ({a: {b: FieldError[]}}; ensureValidate flattens it back to per-field\n * errors, keeping every issue of a path). Issues without a path are\n * form-level errors and land on the '_form' key. On success `values`\n * carries the schema's parsed output (coerce/transform results included),\n * which the form stores as its parsedValues baseline — the layer getValues\n * reads above initialValues, mirroring how react-hook-form's zodResolver\n * and TanStack's standardSchemaValidators use the parsed value.\n *\n * @param schema a Standard Schema v1 (zod v3.24+/v4, valibot v1, arktype...)\n * @return form-level validator for createForm({validate: ...})\n */\nexport function standardSchemaFormValidator<T extends Record<string, any>>(\n schema: StandardSchemaV1<T, any>\n): (values: T) => Promise<ValidationOutcome<T>> {\n return async (values: T) => {\n const result = await schema['~standard'].validate(values);\n const {issues} = result;\n if (!issues?.length) {\n // Success: expose the schema's parsed output. `in` keeps the union\n // narrowed (the success variant is the one carrying `value`).\n return {\n [VALIDATION_OUTCOME]: true,\n values: 'value' in result ? result.value : undefined\n };\n }\n const errors: Record<string, any> = {};\n for (const issue of issues) {\n const segments = toPathSegments(issue);\n if (segments.length) {\n assignAtPath(errors, segments, toFieldError(issue));\n } else {\n // Pathless issues are all form-level: they accumulate on '_form'\n // instead of the first shadowing the rest. (A nested path literally\n // named '_form' would have made the slot a branch — skip then.)\n const slot = (errors._form ??= []);\n if (Array.isArray(slot)) slot.push(toFieldError(issue));\n }\n }\n return {[VALIDATION_OUTCOME]: true, errors: pruneEmpty(errors) || {}};\n };\n}\n\n/**\n * Stringify an issue path: PropertyKey or {key} path segments → strings.\n */\nfunction toPathSegments(issue: StandardSchemaIssue): string[] {\n const path = issue.path || [];\n const segments: string[] = [];\n for (const segment of path) {\n const key =\n typeof segment === 'object' && segment !== null\n ? (segment as {key: PropertyKey}).key\n : segment;\n segments.push(String(key));\n }\n return segments;\n}\n\n/**\n * Append the error at a nested path. Leaves are FieldError[] arrays, so\n * several issues on one field accumulate in issue order; an issue whose\n * path conflicts with an existing leaf or crosses it is skipped.\n */\nfunction assignAtPath(\n root: Record<string, any>,\n segments: string[],\n error: FieldError\n): void {\n let node = root;\n for (let i = 0; i < segments.length - 1; i++) {\n const segment = segments[i];\n let next = node[segment];\n if (next === undefined) {\n next = node[segment] = {};\n }\n if (!isBranch(next)) return;\n node = next;\n }\n const leaf = segments[segments.length - 1];\n const slot = node[leaf];\n if (slot === undefined) node[leaf] = [error];\n else if (Array.isArray(slot)) slot.push(error);\n}\n\n/**\n * A branch is a plain container built while nesting; the leaves it carries\n * are the FieldError[] arrays assignAtPath appends.\n */\nfunction isBranch(value: any): value is Record<string, any> {\n return !!value && typeof value === 'object' && !Array.isArray(value);\n}\n\n/**\n * Drop empty branch objects left behind by conflicting issue paths.\n */\nfunction pruneEmpty(\n node: Record<string, any>\n): Record<string, any> | undefined {\n let hasLeaf = false;\n const result: Record<string, any> = {};\n Object.entries(node).forEach(([key, value]) => {\n if (isBranch(value)) {\n const pruned = pruneEmpty(value);\n if (pruned) {\n result[key] = pruned;\n hasLeaf = true;\n }\n } else {\n result[key] = value;\n hasLeaf = true;\n }\n });\n return hasLeaf ? result : undefined;\n}\n"],"names":["VALIDATION_OUTCOME"],"mappings":";;;;AAmCO,SAAS,iBAAiB,MAAA,EAAyC;AACxE,EAAA,OACE,CAAC,CAAC,MAAA,IACF,OAAO,MAAA,KAAW,YAClB,OAAO,MAAA,CAAO,WAAW,CAAA,EAAG,QAAA,KAAa,UAAA;AAE7C;AAEA,SAAS,aAAa,KAAA,EAAoD;AACxE,EAAA,OAAO,EAAC,IAAA,EAAM,UAAA,EAAY,OAAA,EAAS,KAAA,EAAO,WAAW,mBAAA,EAAmB;AAC1E;AAWO,SAAS,uBAAuB,MAAA,EAAqC;AAC1E,EAAA,OAAO,OAAO,KAAA,KAAe;AAC3B,IAAA,MAAM,SAAS,MAAM,MAAA,CAAO,WAAW,CAAA,CAAE,SAAS,KAAK,CAAA;AACvD,IAAA,IAAI,CAAC,MAAA,CAAO,MAAA,EAAQ,MAAA,EAAQ,OAAO,MAAA;AACnC,IAAA,OAAO,MAAA,CAAO,MAAA,CAAO,GAAA,CAAI,YAAY,CAAA;AAAA,EACvC,CAAA;AACF;AAiBO,SAAS,4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AA,KAAM;AAC7C,IAAA,IAAI,QAAA,CAAS,KAAK,CAAA,EAAG;AACnB,MAAA,MAAM,MAAA,GAAS,WAAW,KAAK,CAAA;AAC/B,MAAA,IAAI,MAAA,EAAQ;AACV,QAAA,MAAA,CAAO,GAAG,CAAA,GAAI,MAAA;AACd,QAAA,OAAA,GAAU,IAAA;AAAA,MACZ;AAAA,IACF,CAAA,MAAO;AACL,MAAA,MAAA,CAAO,GAAG,CAAA,GAAI,KAAA;AACd,MAAA,OAAA,GAAU,IAAA;AAAA,IACZ;AAAA,EACF,CAAC,CAAA;AACD,EAAA,OAAO,UAAU,MAAA,GAAS,MAAA;AAC5B;;;;;;"}
@@ -1,5 +1,5 @@
1
- import { h as ValidationOutcome } from '../form-61297bc0.js';
2
- import { V as Validator } from '../validate-148fe167.js';
1
+ import { ValidationOutcome } from '../index.js';
2
+ import { Validator } from '../index.js';
3
3
  import '@for-fun/event-emitter';
4
4
 
5
5
  /**
@@ -1,4 +1,4 @@
1
- import { V as VALIDATION_OUTCOME } from '../form-94c70b4b.mjs';
1
+ import { V as VALIDATION_OUTCOME } from '../form-R1hDKjBm.mjs';
2
2
 
3
3
  function hasStandardProps(schema) {
4
4
  return !!schema && typeof schema === "object" && typeof schema["~standard"]?.validate === "function";
@@ -1 +1 @@
1
- {"version":3,"file":"standard-schema.mjs","sources":["../../src/resolvers/standard-schema.ts"],"sourcesContent":["import {VALIDATION_OUTCOME} from '../form';\nimport type {FieldError, ValidationOutcome} from '../form';\nimport type {Validator} from '../hooks/validate';\n\n/**\n * Minimal copy of the Standard Schema v1 interfaces\n * (https://standardschema.dev) so this module has zero runtime and type\n * dependencies on any schema library. Implemented by zod v3.24+/v4,\n * valibot v1, arktype and others.\n */\nexport interface StandardSchemaIssue {\n readonly message: string;\n readonly path?:\n | ReadonlyArray<PropertyKey | {readonly key: PropertyKey}>\n | undefined;\n}\n\nexport interface StandardSchemaV1<Input = unknown, Output = Input> {\n readonly '~standard': {\n readonly version: 1;\n readonly vendor: string;\n readonly validate: (\n value: Input\n ) =>\n | {readonly value: Output; readonly issues?: undefined}\n | {readonly issues: ReadonlyArray<StandardSchemaIssue>}\n | Promise<\n | {readonly value: Output; readonly issues?: undefined}\n | {readonly issues: ReadonlyArray<StandardSchemaIssue>}\n >;\n };\n}\n\n/**\n * Does the schema implement the Standard Schema v1 props?\n */\nexport function hasStandardProps(schema: any): schema is StandardSchemaV1 {\n return (\n !!schema &&\n typeof schema === 'object' &&\n typeof schema['~standard']?.validate === 'function'\n );\n}\n\nfunction toFieldError(issue: StandardSchemaIssue | undefined): FieldError {\n return {type: 'standard', message: issue?.message || 'Validation failed'};\n}\n\n/**\n * Field-level Standard Schema adapter: validate a single value with any\n * schema implementing '~standard' and map every issue to a FieldError,\n * so a value breaking several rules surfaces all of them (setErrorByPath\n * stores the array; error/errorObject readers still see the first).\n *\n * @param schema a Standard Schema v1 (zod v3.24+/v4, valibot v1, arktype...)\n * @return field validator compatible with useField's validate option\n */\nexport function standardSchemaResolver(schema: StandardSchemaV1): Validator {\n return async (value: any) => {\n const result = await schema['~standard'].validate(value);\n if (!result.issues?.length) return undefined;\n return result.issues.map(toFieldError);\n };\n}\n\n/**\n * Form-level Standard Schema adapter: validate the whole values object with\n * any schema implementing '~standard' and return a ValidationOutcome. On\n * failure `errors` carries the nested shape Options.validate expects\n * ({a: {b: FieldError[]}}; ensureValidate flattens it back to per-field\n * errors, keeping every issue of a path). Issues without a path are\n * form-level errors and land on the '_form' key. On success `values`\n * carries the schema's parsed output (coerce/transform results included),\n * which the form stores as its parsedValues baseline — the layer getValues\n * reads above initialValues, mirroring how react-hook-form's zodResolver\n * and TanStack's standardSchemaValidators use the parsed value.\n *\n * @param schema a Standard Schema v1 (zod v3.24+/v4, valibot v1, arktype...)\n * @return form-level validator for createForm({validate: ...})\n */\nexport function standardSchemaFormValidator<T extends Record<string, any>>(\n schema: StandardSchemaV1<T, any>\n): (values: T) => Promise<ValidationOutcome<T>> {\n return async (values: T) => {\n const result = await schema['~standard'].validate(values);\n const {issues} = result;\n if (!issues?.length) {\n // Success: expose the schema's parsed output. `in` keeps the union\n // narrowed (the success variant is the one carrying `value`).\n return {\n [VALIDATION_OUTCOME]: true,\n values: 'value' in result ? result.value : undefined\n };\n }\n const errors: Record<string, any> = {};\n for (const issue of issues) {\n const segments = toPathSegments(issue);\n if (segments.length) {\n assignAtPath(errors, segments, toFieldError(issue));\n } else {\n // Pathless issues are all form-level: they accumulate on '_form'\n // instead of the first shadowing the rest. (A nested path literally\n // named '_form' would have made the slot a branch — skip then.)\n const slot = (errors._form ??= []);\n if (Array.isArray(slot)) slot.push(toFieldError(issue));\n }\n }\n return {[VALIDATION_OUTCOME]: true, errors: pruneEmpty(errors) || {}};\n };\n}\n\n/**\n * Stringify an issue path: PropertyKey or {key} path segments → strings.\n */\nfunction toPathSegments(issue: StandardSchemaIssue): string[] {\n const path = issue.path || [];\n const segments: string[] = [];\n for (const segment of path) {\n const key =\n typeof segment === 'object' && segment !== null\n ? (segment as {key: PropertyKey}).key\n : segment;\n segments.push(String(key));\n }\n return segments;\n}\n\n/**\n * Append the error at a nested path. Leaves are FieldError[] arrays, so\n * several issues on one field accumulate in issue order; an issue whose\n * path conflicts with an existing leaf or crosses it is skipped.\n */\nfunction assignAtPath(\n root: Record<string, any>,\n segments: string[],\n error: FieldError\n): void {\n let node = root;\n for (let i = 0; i < segments.length - 1; i++) {\n const segment = segments[i];\n let next = node[segment];\n if (next === undefined) {\n next = node[segment] = {};\n }\n if (!isBranch(next)) return;\n node = next;\n }\n const leaf = segments[segments.length - 1];\n const slot = node[leaf];\n if (slot === undefined) node[leaf] = [error];\n else if (Array.isArray(slot)) slot.push(error);\n}\n\n/**\n * A branch is a plain container built while nesting; the leaves it carries\n * are the FieldError[] arrays assignAtPath appends.\n */\nfunction isBranch(value: any): value is Record<string, any> {\n return !!value && typeof value === 'object' && !Array.isArray(value);\n}\n\n/**\n * Drop empty branch objects left behind by conflicting issue paths.\n */\nfunction pruneEmpty(\n node: Record<string, any>\n): Record<string, any> | undefined {\n let hasLeaf = false;\n const result: Record<string, any> = {};\n Object.entries(node).forEach(([key, value]) => {\n if (isBranch(value)) {\n const pruned = pruneEmpty(value);\n if (pruned) {\n result[key] = pruned;\n hasLeaf = true;\n }\n } else {\n result[key] = value;\n hasLeaf = true;\n }\n });\n return hasLeaf ? result : undefined;\n}\n"],"names":[],"mappings":";;AAoCO,SAAS,iBAAiB,MAAyC,EAAA;AACxE,EACE,OAAA,CAAC,CAAC,MAAA,IACF,OAAO,MAAA,KAAW,YAClB,OAAO,MAAA,CAAO,WAAW,CAAA,EAAG,QAAa,KAAA,UAAA,CAAA;AAE7C,CAAA;AAEA,SAAS,aAAa,KAAoD,EAAA;AACxE,EAAA,OAAO,EAAC,IAAM,EAAA,UAAA,EAAY,OAAS,EAAA,KAAA,EAAO,WAAW,mBAAmB,EAAA,CAAA;AAC1E,CAAA;AAWO,SAAS,uBAAuB,MAAqC,EAAA;AAC1E,EAAA,OAAO,OAAO,KAAe,KAAA;AAC3B,IAAA,MAAM,SAAS,MAAM,MAAA,CAAO,WAAW,CAAA,CAAE,SAAS,KAAK,CAAA,CAAA;AACvD,IAAA,IAAI,CAAC,MAAA,CAAO,MAAQ,EAAA,MAAA,EAAe,OAAA,KAAA,CAAA,CAAA;AACnC,IAAO,OAAA,MAAA,CAAO,MAAO,CAAA,GAAA,CAAI,YAAY,CAAA,CAAA;AAAA,GACvC,CAAA;AACF,CAAA;AAiBO,SAAS,4BACd,MAC8C,EAAA;AAC9C,EAAA,OAAO,OAAO,MAAc,KAAA;AAC1B,IAAA,MAAM,SAAS,MAAM,MAAA,CAAO,WAAW,CAAA,CAAE,SAAS,MAAM,CAAA,CAAA;AACxD,IAAM,MAAA,EAAC,QAAU,GAAA,MAAA,CAAA;AACjB,IAAI,IAAA,CAAC,QAAQ,MAAQ,EAAA;AAGnB,MAAO,OAAA;AAAA,QACL,CAAC,kBAAkB,GAAG,IAAA;AAAA,QACtB,MAAQ,E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A,CAAA;AAC/B,MAAA,IAAI,MAAQ,EAAA;AACV,QAAA,MAAA,CAAO,GAAG,CAAI,GAAA,MAAA,CAAA;AACd,QAAU,OAAA,GAAA,IAAA,CAAA;AAAA,OACZ;AAAA,KACK,MAAA;AACL,MAAA,MAAA,CAAO,GAAG,CAAI,GAAA,KAAA,CAAA;AACd,MAAU,OAAA,GAAA,IAAA,CAAA;AAAA,KACZ;AAAA,GACD,CAAA,CAAA;AACD,EAAA,OAAO,UAAU,MAAS,GAAA,KAAA,CAAA,CAAA;AAC5B;;;;"}
1
+ {"version":3,"file":"standard-schema.mjs","sources":["../../src/resolvers/standard-schema.ts"],"sourcesContent":["import {VALIDATION_OUTCOME} from '../form';\nimport type {FieldError, ValidationOutcome} from '../form';\nimport type {Validator} from '../hooks/validate';\n\n/**\n * Minimal copy of the Standard Schema v1 interfaces\n * (https://standardschema.dev) so this module has zero runtime and type\n * dependencies on any schema library. Implemented by zod v3.24+/v4,\n * valibot v1, arktype and others.\n */\nexport interface StandardSchemaIssue {\n readonly message: string;\n readonly path?:\n ReadonlyArray<PropertyKey | {readonly key: PropertyKey}> | undefined;\n}\n\nexport interface StandardSchemaV1<Input = unknown, Output = Input> {\n readonly '~standard': {\n readonly version: 1;\n readonly vendor: string;\n readonly validate: (\n value: Input\n ) =>\n | {readonly value: Output; readonly issues?: undefined}\n | {readonly issues: ReadonlyArray<StandardSchemaIssue>}\n | Promise<\n | {readonly value: Output; readonly issues?: undefined}\n | {readonly issues: ReadonlyArray<StandardSchemaIssue>}\n >;\n };\n}\n\n/**\n * Does the schema implement the Standard Schema v1 props?\n */\nexport function hasStandardProps(schema: any): schema is StandardSchemaV1 {\n return (\n !!schema &&\n typeof schema === 'object' &&\n typeof schema['~standard']?.validate === 'function'\n );\n}\n\nfunction toFieldError(issue: StandardSchemaIssue | undefined): FieldError {\n return {type: 'standard', message: issue?.message || 'Validation failed'};\n}\n\n/**\n * Field-level Standard Schema adapter: validate a single value with any\n * schema implementing '~standard' and map every issue to a FieldError,\n * so a value breaking several rules surfaces all of them (setErrorByPath\n * stores the array; error/errorObject readers still see the first).\n *\n * @param schema a Standard Schema v1 (zod v3.24+/v4, valibot v1, arktype...)\n * @return field validator compatible with useField's validate option\n */\nexport function standardSchemaResolver(schema: StandardSchemaV1): Validator {\n return async (value: any) => {\n const result = await schema['~standard'].validate(value);\n if (!result.issues?.length) return undefined;\n return result.issues.map(toFieldError);\n };\n}\n\n/**\n * Form-level Standard Schema adapter: validate the whole values object with\n * any schema implementing '~standard' and return a ValidationOutcome. On\n * failure `errors` carries the nested shape Options.validate expects\n * ({a: {b: FieldError[]}}; ensureValidate flattens it back to per-field\n * errors, keeping every issue of a path). Issues without a path are\n * form-level errors and land on the '_form' key. On success `values`\n * carries the schema's parsed output (coerce/transform results included),\n * which the form stores as its parsedValues baseline — the layer getValues\n * reads above initialValues, mirroring how react-hook-form's zodResolver\n * and TanStack's standardSchemaValidators use the parsed value.\n *\n * @param schema a Standard Schema v1 (zod v3.24+/v4, valibot v1, arktype...)\n * @return form-level validator for createForm({validate: ...})\n */\nexport function standardSchemaFormValidator<T extends Record<string, any>>(\n schema: StandardSchemaV1<T, any>\n): (values: T) => Promise<ValidationOutcome<T>> {\n return async (values: T) => {\n const result = await schema['~standard'].validate(values);\n const {issues} = result;\n if (!issues?.length) {\n // Success: expose the schema's parsed output. `in` keeps the union\n // narrowed (the success variant is the one carrying `value`).\n return {\n [VALIDATION_OUTCOME]: true,\n values: 'value' in result ? result.value : undefined\n };\n }\n const errors: Record<string, any> = {};\n for (const issue of issues) {\n const segments = toPathSegments(issue);\n if (segments.length) {\n assignAtPath(errors, segments, toFieldError(issue));\n } else {\n // Pathless issues are all form-level: they accumulate on '_form'\n // instead of the first shadowing the rest. (A nested path literally\n // named '_form' would have made the slot a branch — skip then.)\n const slot = (errors._form ??= []);\n if (Array.isArray(slot)) slot.push(toFieldError(issue));\n }\n }\n return {[VALIDATION_OUTCOME]: true, errors: pruneEmpty(errors) || {}};\n };\n}\n\n/**\n * Stringify an issue path: PropertyKey or {key} path segments → strings.\n */\nfunction toPathSegments(issue: StandardSchemaIssue): string[] {\n const path = issue.path || [];\n const segments: string[] = [];\n for (const segment of path) {\n const key =\n typeof segment === 'object' && segment !== null\n ? (segment as {key: PropertyKey}).key\n : segment;\n segments.push(String(key));\n }\n return segments;\n}\n\n/**\n * Append the error at a nested path. Leaves are FieldError[] arrays, so\n * several issues on one field accumulate in issue order; an issue whose\n * path conflicts with an existing leaf or crosses it is skipped.\n */\nfunction assignAtPath(\n root: Record<string, any>,\n segments: string[],\n error: FieldError\n): void {\n let node = root;\n for (let i = 0; i < segments.length - 1; i++) {\n const segment = segments[i];\n let next = node[segment];\n if (next === undefined) {\n next = node[segment] = {};\n }\n if (!isBranch(next)) return;\n node = next;\n }\n const leaf = segments[segments.length - 1];\n const slot = node[leaf];\n if (slot === undefined) node[leaf] = [error];\n else if (Array.isArray(slot)) slot.push(error);\n}\n\n/**\n * A branch is a plain container built while nesting; the leaves it carries\n * are the FieldError[] arrays assignAtPath appends.\n */\nfunction isBranch(value: any): value is Record<string, any> {\n return !!value && typeof value === 'object' && !Array.isArray(value);\n}\n\n/**\n * Drop empty branch objects left behind by conflicting issue paths.\n */\nfunction pruneEmpty(\n node: Record<string, any>\n): Record<string, any> | undefined {\n let hasLeaf = false;\n const result: Record<string, any> = {};\n Object.entries(node).forEach(([key, value]) => {\n if (isBranch(value)) {\n const pruned = pruneEmpty(value);\n if (pruned) {\n result[key] = pruned;\n hasLeaf = true;\n }\n } else {\n result[key] = value;\n hasLeaf = true;\n }\n });\n return hasLeaf ? result : undefined;\n}\n"],"names":[],"mappings":";;AAmCO,SAAS,iBAAiB,MAAA,EAAyC;AACxE,EAAA,OACE,CAAC,CAAC,MAAA,IACF,OAAO,MAAA,KAAW,YAClB,OAAO,MAAA,CAAO,WAAW,CAAA,EAAG,QAAA,KAAa,UAAA;AAE7C;AAEA,SAAS,aAAa,KAAA,EAAoD;AACxE,EAAA,OAAO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AAA,CAAQ,IAAI,CAAA,EAAG,IAAA,CAAK,KAAK,KAAK,CAAA;AAC/C;AAMA,SAAS,SAAS,KAAA,EAA0C;AAC1D,EAAA,OAAO,CAAC,CAAC,KAAA,IAAS,OAAO,UAAU,QAAA,IAAY,CAAC,KAAA,CAAM,OAAA,CAAQ,KAAK,CAAA;AACrE;AAKA,SAAS,WACP,IAAA,EACiC;AACjC,EAAA,IAAI,OAAA,GAAU,KAAA;AACd,EAAA,MAAM,SAA8B,EAAC;AACrC,EAAA,MAAA,CAAO,OAAA,CAAQ,IAAI,CAAA,CAAE,OAAA,CAAQ,CAAC,CAAC,GAAA,EAAK,KAAK,CAAA,KAAM;AAC7C,IAAA,IAAI,QAAA,CAAS,KAAK,CAAA,EAAG;AACnB,MAAA,MAAM,MAAA,GAAS,WAAW,KAAK,CAAA;AAC/B,MAAA,IAAI,MAAA,EAAQ;AACV,QAAA,MAAA,CAAO,GAAG,CAAA,GAAI,MAAA;AACd,QAAA,OAAA,GAAU,IAAA;AAAA,MACZ;AAAA,IACF,CAAA,MAAO;AACL,MAAA,MAAA,CAAO,GAAG,CAAA,GAAI,KAAA;AACd,MAAA,OAAA,GAAU,IAAA;AAAA,IACZ;AAAA,EACF,CAAC,CAAA;AACD,EAAA,OAAO,UAAU,MAAA,GAAS,MAAA;AAC5B;;;;"}
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var resolvers_standardSchema = require('./standard-schema.cjs.js');
4
- require('../form-b9441d8c.cjs.js');
4
+ require('../form-B4r7INJ0.cjs.js');
5
5
 
6
6
  function yupResolver(schema) {
7
7
  if (resolvers_standardSchema.hasStandardProps(schema)) return resolvers_standardSchema.standardSchemaResolver(schema);
@@ -11,12 +11,10 @@ function yupResolver(schema) {
11
11
  return void 0;
12
12
  } catch (err) {
13
13
  const issues = Array.isArray(err?.inner) && err.inner.length ? err.inner : [err];
14
- return issues.map(
15
- (issue) => ({
16
- type: issue?.type || "custom",
17
- message: issue?.message || "Validation failed"
18
- })
19
- );
14
+ return issues.map((issue) => ({
15
+ type: issue?.type || "custom",
16
+ message: issue?.message || "Validation failed"
17
+ }));
20
18
  }
21
19
  };
22
20
  }
@@ -1 +1 @@
1
- {"version":3,"file":"yup.cjs.js","sources":["../../src/resolvers/yup.ts"],"sourcesContent":["import type {FieldError} from '../form';\nimport type {Validator} from '../hooks/validate';\nimport {hasStandardProps, standardSchemaResolver} from './standard-schema';\n\nexport function yupResolver(schema: any): Validator {\n // Recent yup versions implement the Standard Schema props — prefer them.\n if (hasStandardProps(schema)) return standardSchemaResolver(schema);\n // Older yup: fall back to the throw-based validate API. abortEarly:false\n // makes yup aggregate every failure into err.inner instead of throwing\n // on the first, so all of a field's errors reach the form.\n return async (value: any) => {\n try {\n await schema.validate(value, {abortEarly: false});\n return undefined;\n } catch (err: any) {\n const issues =\n Array.isArray(err?.inner) && err.inner.length ? err.inner : [err];\n return issues.map(\n (issue: any): FieldError => ({\n type: issue?.type || 'custom',\n message: issue?.message || 'Validation failed'\n })\n );\n }\n };\n}\n"],"names":["hasStandardProps","standardSchemaResolver"],"mappings":";;;;;AAIO,SAAS,YAAY,MAAwB,EAAA;AAElD,EAAA,IAAIA,yCAAiB,CAAA,MAAM,CAAG,EAAA,OAAOC,gDAAuB,MAAM,CAAA,CAAA;AAIlE,EAAA,OAAO,OAAO,KAAe,KAAA;AAC3B,IAAI,IAAA;AACF,MAAA,MAAM,OAAO,QAAS,CAAA,KAAA,EAAO,EAAC,UAAA,EAAY,OAAM,CAAA,CAAA;AAChD,MAAO,OAAA,KAAA,CAAA,CAAA;AAAA,aACA,GAAU,EAAA;AACjB,MAAA,MAAM,MACJ,GAAA,KAAA,CAAM,OAAQ,CAAA,GAAA,EAAK,KAAK,CAAA,IAAK,GAAI,CAAA,KAAA,CAAM,MAAS,GAAA,GAAA,CAAI,KAAQ,GAAA,CAAC,GAAG,CAAA,CAAA;AAClE,MAAA,OAAO,MAAO,CAAA,GAAA;AAAA,QACZ,CAAC,KAA4B,MAAA;AAAA,UAC3B,IAAA,EAAM,OAAO,IAAQ,IAAA,QAAA;AAAA,UACrB,OAAA,EAAS,OAAO,OAAW,IAAA,mBAAA;AAAA,SAC7B,CAAA;AAAA,OACF,CAAA;AAAA,KACF;AAAA,GACF,CAAA;AACF;;;;"}
1
+ {"version":3,"file":"yup.cjs.js","sources":["../../src/resolvers/yup.ts"],"sourcesContent":["import type {FieldError} from '../form';\nimport type {Validator} from '../hooks/validate';\nimport {hasStandardProps, standardSchemaResolver} from './standard-schema';\n\nexport function yupResolver(schema: any): Validator {\n // Recent yup versions implement the Standard Schema props — prefer them.\n if (hasStandardProps(schema)) return standardSchemaResolver(schema);\n // Older yup: fall back to the throw-based validate API. abortEarly:false\n // makes yup aggregate every failure into err.inner instead of throwing\n // on the first, so all of a field's errors reach the form.\n return async (value: any) => {\n try {\n await schema.validate(value, {abortEarly: false});\n return undefined;\n } catch (err: any) {\n const issues =\n Array.isArray(err?.inner) && err.inner.length ? err.inner : [err];\n return issues.map((issue: any): FieldError => ({\n type: issue?.type || 'custom',\n message: issue?.message || 'Validation failed'\n }));\n }\n };\n}\n"],"names":["hasStandardProps","standardSchemaResolver"],"mappings":";;;;;AAIO,SAAS,YAAY,MAAA,EAAwB;AAElD,EAAA,IAAIA,yCAAA,CAAiB,MAAM,CAAA,EAAG,OAAOC,gDAAuB,MAAM,CAAA;AAIlE,EAAA,OAAO,OAAO,KAAA,KAAe;AAC3B,IAAA,IAAI;AACF,MAAA,MAAM,OAAO,QAAA,CAAS,KAAA,EAAO,EAAC,UAAA,EAAY,OAAM,CAAA;AAChD,MAAA,OAAO,KAAA,CAAA;AAAA,IACT,SAAS,GAAA,EAAU;AACjB,MAAA,MAAM,MAAA,GACJ,KAAA,CAAM,OAAA,CAAQ,GAAA,EAAK,KAAK,CAAA,IAAK,GAAA,CAAI,KAAA,CAAM,MAAA,GAAS,GAAA,CAAI,KAAA,GAAQ,CAAC,GAAG,CAAA;AAClE,MAAA,OAAO,MAAA,CAAO,GAAA,CAAI,CAAC,KAAA,MAA4B;AAAA,QAC7C,IAAA,EAAM,OAAO,IAAA,IAAQ,QAAA;AAAA,QACrB,OAAA,EAAS,OAAO,OAAA,IAAW;AAAA,OAC7B,CAAE,CAAA;AAAA,IACJ;AAAA,EACF,CAAA;AACF;;;;"}
@@ -1,5 +1,5 @@
1
- import { V as Validator } from '../validate-148fe167.js';
2
- import '../form-61297bc0.js';
1
+ import { Validator } from '../index.js';
2
+ import '../form-DeRFdFKE.js';
3
3
  import '@for-fun/event-emitter';
4
4
 
5
5
  declare function yupResolver(schema: any): Validator;
@@ -1,5 +1,5 @@
1
1
  import { hasStandardProps, standardSchemaResolver } from './standard-schema.mjs';
2
- import '../form-94c70b4b.mjs';
2
+ import '../form-R1hDKjBm.mjs';
3
3
 
4
4
  function yupResolver(schema) {
5
5
  if (hasStandardProps(schema)) return standardSchemaResolver(schema);
@@ -9,12 +9,10 @@ function yupResolver(schema) {
9
9
  return void 0;
10
10
  } catch (err) {
11
11
  const issues = Array.isArray(err?.inner) && err.inner.length ? err.inner : [err];
12
- return issues.map(
13
- (issue) => ({
14
- type: issue?.type || "custom",
15
- message: issue?.message || "Validation failed"
16
- })
17
- );
12
+ return issues.map((issue) => ({
13
+ type: issue?.type || "custom",
14
+ message: issue?.message || "Validation failed"
15
+ }));
18
16
  }
19
17
  };
20
18
  }
@@ -1 +1 @@
1
- {"version":3,"file":"yup.mjs","sources":["../../src/resolvers/yup.ts"],"sourcesContent":["import type {FieldError} from '../form';\nimport type {Validator} from '../hooks/validate';\nimport {hasStandardProps, standardSchemaResolver} from './standard-schema';\n\nexport function yupResolver(schema: any): Validator {\n // Recent yup versions implement the Standard Schema props — prefer them.\n if (hasStandardProps(schema)) return standardSchemaResolver(schema);\n // Older yup: fall back to the throw-based validate API. abortEarly:false\n // makes yup aggregate every failure into err.inner instead of throwing\n // on the first, so all of a field's errors reach the form.\n return async (value: any) => {\n try {\n await schema.validate(value, {abortEarly: false});\n return undefined;\n } catch (err: any) {\n const issues =\n Array.isArray(err?.inner) && err.inner.length ? err.inner : [err];\n return issues.map(\n (issue: any): FieldError => ({\n type: issue?.type || 'custom',\n message: issue?.message || 'Validation failed'\n })\n );\n }\n };\n}\n"],"names":[],"mappings":";;;AAIO,SAAS,YAAY,MAAwB,EAAA;AAElD,EAAA,IAAI,gBAAiB,CAAA,MAAM,CAAG,EAAA,OAAO,uBAAuB,MAAM,CAAA,CAAA;AAIlE,EAAA,OAAO,OAAO,KAAe,KAAA;AAC3B,IAAI,IAAA;AACF,MAAA,MAAM,OAAO,QAAS,CAAA,KAAA,EAAO,EAAC,UAAA,EAAY,OAAM,CAAA,CAAA;AAChD,MAAO,OAAA,KAAA,CAAA,CAAA;AAAA,aACA,GAAU,EAAA;AACjB,MAAA,MAAM,MACJ,GAAA,KAAA,CAAM,OAAQ,CAAA,GAAA,EAAK,KAAK,CAAA,IAAK,GAAI,CAAA,KAAA,CAAM,MAAS,GAAA,GAAA,CAAI,KAAQ,GAAA,CAAC,GAAG,CAAA,CAAA;AAClE,MAAA,OAAO,MAAO,CAAA,GAAA;AAAA,QACZ,CAAC,KAA4B,MAAA;AAAA,UAC3B,IAAA,EAAM,OAAO,IAAQ,IAAA,QAAA;AAAA,UACrB,OAAA,EAAS,OAAO,OAAW,IAAA,mBAAA;AAAA,SAC7B,CAAA;AAAA,OACF,CAAA;AAAA,KACF;AAAA,GACF,CAAA;AACF;;;;"}
1
+ {"version":3,"file":"yup.mjs","sources":["../../src/resolvers/yup.ts"],"sourcesContent":["import type {FieldError} from '../form';\nimport type {Validator} from '../hooks/validate';\nimport {hasStandardProps, standardSchemaResolver} from './standard-schema';\n\nexport function yupResolver(schema: any): Validator {\n // Recent yup versions implement the Standard Schema props — prefer them.\n if (hasStandardProps(schema)) return standardSchemaResolver(schema);\n // Older yup: fall back to the throw-based validate API. abortEarly:false\n // makes yup aggregate every failure into err.inner instead of throwing\n // on the first, so all of a field's errors reach the form.\n return async (value: any) => {\n try {\n await schema.validate(value, {abortEarly: false});\n return undefined;\n } catch (err: any) {\n const issues =\n Array.isArray(err?.inner) && err.inner.length ? err.inner : [err];\n return issues.map((issue: any): FieldError => ({\n type: issue?.type || 'custom',\n message: issue?.message || 'Validation failed'\n }));\n }\n };\n}\n"],"names":[],"mappings":";;;AAIO,SAAS,YAAY,MAAA,EAAwB;AAElD,EAAA,IAAI,gBAAA,CAAiB,MAAM,CAAA,EAAG,OAAO,uBAAuB,MAAM,CAAA;AAIlE,EAAA,OAAO,OAAO,KAAA,KAAe;AAC3B,IAAA,IAAI;AACF,MAAA,MAAM,OAAO,QAAA,CAAS,KAAA,EAAO,EAAC,UAAA,EAAY,OAAM,CAAA;AAChD,MAAA,OAAO,KAAA,CAAA;AAAA,IACT,SAAS,GAAA,EAAU;AACjB,MAAA,MAAM,MAAA,GACJ,KAAA,CAAM,OAAA,CAAQ,GAAA,EAAK,KAAK,CAAA,IAAK,GAAA,CAAI,KAAA,CAAM,MAAA,GAAS,GAAA,CAAI,KAAA,GAAQ,CAAC,GAAG,CAAA;AAClE,MAAA,OAAO,MAAA,CAAO,GAAA,CAAI,CAAC,KAAA,MAA4B;AAAA,QAC7C,IAAA,EAAM,OAAO,IAAA,IAAQ,QAAA;AAAA,QACrB,OAAA,EAAS,OAAO,OAAA,IAAW;AAAA,OAC7B,CAAE,CAAA;AAAA,IACJ;AAAA,EACF,CAAA;AACF;;;;"}
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var resolvers_standardSchema = require('./standard-schema.cjs.js');
4
- require('../form-b9441d8c.cjs.js');
4
+ require('../form-B4r7INJ0.cjs.js');
5
5
 
6
6
  function zodResolver(schema) {
7
7
  if (resolvers_standardSchema.hasStandardProps(schema)) return resolvers_standardSchema.standardSchemaResolver(schema);
@@ -12,12 +12,10 @@ function zodResolver(schema) {
12
12
  if (!issues?.length) {
13
13
  return [{ type: "custom", message: "Validation failed" }];
14
14
  }
15
- return issues.map(
16
- (issue) => ({
17
- type: issue?.code || "custom",
18
- message: issue?.message || "Validation failed"
19
- })
20
- );
15
+ return issues.map((issue) => ({
16
+ type: issue?.code || "custom",
17
+ message: issue?.message || "Validation failed"
18
+ }));
21
19
  };
22
20
  }
23
21
 
@@ -1 +1 @@
1
- {"version":3,"file":"zod.cjs.js","sources":["../../src/resolvers/zod.ts"],"sourcesContent":["import type {FieldError} from '../form';\nimport type {Validator} from '../hooks/validate';\nimport {hasStandardProps, standardSchemaResolver} from './standard-schema';\n\nexport function zodResolver(schema: any): Validator {\n // zod v3.24+/v4 schemas carry the Standard Schema props — prefer them.\n if (hasStandardProps(schema)) return standardSchemaResolver(schema);\n // Older zod: fall back to the legacy safeParseAsync API. It aggregates\n // every issue (no abortEarly), so map them all — a value breaking\n // several rules surfaces all of its errors.\n return async (value: any) => {\n const result = await schema.safeParseAsync(value);\n if (result.success) return undefined;\n const {issues} = result.error;\n if (!issues?.length) {\n return [{type: 'custom', message: 'Validation failed'}];\n }\n return issues.map(\n (issue: any): FieldError => ({\n type: issue?.code || 'custom',\n message: issue?.message || 'Validation failed'\n })\n );\n };\n}\n"],"names":["hasStandardProps","standardSchemaResolver"],"mappings":";;;;;AAIO,SAAS,YAAY,MAAwB,EAAA;AAElD,EAAA,IAAIA,yCAAiB,CAAA,MAAM,CAAG,EAAA,OAAOC,gDAAuB,MAAM,CAAA,CAAA;AAIlE,EAAA,OAAO,OAAO,KAAe,KAAA;AAC3B,IAAA,MAAM,MAAS,GAAA,MAAM,MAAO,CAAA,cAAA,CAAe,KAAK,CAAA,CAAA;AAChD,IAAI,IAAA,MAAA,CAAO,SAAgB,OAAA,KAAA,CAAA,CAAA;AAC3B,IAAM,MAAA,EAAC,MAAM,EAAA,GAAI,MAAO,CAAA,KAAA,CAAA;AACxB,IAAI,IAAA,CAAC,QAAQ,MAAQ,EAAA;AACnB,MAAA,OAAO,CAAC,EAAC,IAAA,EAAM,QAAU,EAAA,OAAA,EAAS,qBAAoB,CAAA,CAAA;AAAA,KACxD;AACA,IAAA,OAAO,MAAO,CAAA,GAAA;AAAA,MACZ,CAAC,KAA4B,MAAA;AAAA,QAC3B,IAAA,EAAM,OAAO,IAAQ,IAAA,QAAA;AAAA,QACrB,OAAA,EAAS,OAAO,OAAW,IAAA,mBAAA;AAAA,OAC7B,CAAA;AAAA,KACF,CAAA;AAAA,GACF,CAAA;AACF;;;;"}
1
+ {"version":3,"file":"zod.cjs.js","sources":["../../src/resolvers/zod.ts"],"sourcesContent":["import type {FieldError} from '../form';\nimport type {Validator} from '../hooks/validate';\nimport {hasStandardProps, standardSchemaResolver} from './standard-schema';\n\nexport function zodResolver(schema: any): Validator {\n // zod v3.24+/v4 schemas carry the Standard Schema props — prefer them.\n if (hasStandardProps(schema)) return standardSchemaResolver(schema);\n // Older zod: fall back to the legacy safeParseAsync API. It aggregates\n // every issue (no abortEarly), so map them all — a value breaking\n // several rules surfaces all of its errors.\n return async (value: any) => {\n const result = await schema.safeParseAsync(value);\n if (result.success) return undefined;\n const {issues} = result.error;\n if (!issues?.length) {\n return [{type: 'custom', message: 'Validation failed'}];\n }\n return issues.map((issue: any): FieldError => ({\n type: issue?.code || 'custom',\n message: issue?.message || 'Validation failed'\n }));\n };\n}\n"],"names":["hasStandardProps","standardSchemaResolver"],"mappings":";;;;;AAIO,SAAS,YAAY,MAAA,EAAwB;AAElD,EAAA,IAAIA,yCAAA,CAAiB,MAAM,CAAA,EAAG,OAAOC,gDAAuB,MAAM,CAAA;AAIlE,EAAA,OAAO,OAAO,KAAA,KAAe;AAC3B,IAAA,MAAM,MAAA,GAAS,MAAM,MAAA,CAAO,cAAA,CAAe,KAAK,CAAA;AAChD,IAAA,IAAI,MAAA,CAAO,SAAS,OAAO,MAAA;AAC3B,IAAA,MAAM,EAAC,MAAA,EAAM,GAAI,MAAA,CAAO,KAAA;AACxB,IAAA,IAAI,CAAC,QAAQ,MAAA,EAAQ;AACnB,MAAA,OAAO,CAAC,EAAC,IAAA,EAAM,QAAA,EAAU,OAAA,EAAS,qBAAoB,CAAA;AAAA,IACxD;AACA,IAAA,OAAO,MAAA,CAAO,GAAA,CAAI,CAAC,KAAA,MAA4B;AAAA,MAC7C,IAAA,EAAM,OAAO,IAAA,IAAQ,QAAA;AAAA,MACrB,OAAA,EAAS,OAAO,OAAA,IAAW;AAAA,KAC7B,CAAE,CAAA;AAAA,EACJ,CAAA;AACF;;;;"}
@@ -1,5 +1,5 @@
1
- import { V as Validator } from '../validate-148fe167.js';
2
- import '../form-61297bc0.js';
1
+ import { Validator } from '../index.js';
2
+ import '../form-DeRFdFKE.js';
3
3
  import '@for-fun/event-emitter';
4
4
 
5
5
  declare function zodResolver(schema: any): Validator;
@@ -1,5 +1,5 @@
1
1
  import { hasStandardProps, standardSchemaResolver } from './standard-schema.mjs';
2
- import '../form-94c70b4b.mjs';
2
+ import '../form-R1hDKjBm.mjs';
3
3
 
4
4
  function zodResolver(schema) {
5
5
  if (hasStandardProps(schema)) return standardSchemaResolver(schema);
@@ -10,12 +10,10 @@ function zodResolver(schema) {
10
10
  if (!issues?.length) {
11
11
  return [{ type: "custom", message: "Validation failed" }];
12
12
  }
13
- return issues.map(
14
- (issue) => ({
15
- type: issue?.code || "custom",
16
- message: issue?.message || "Validation failed"
17
- })
18
- );
13
+ return issues.map((issue) => ({
14
+ type: issue?.code || "custom",
15
+ message: issue?.message || "Validation failed"
16
+ }));
19
17
  };
20
18
  }
21
19
 
@@ -1 +1 @@
1
- {"version":3,"file":"zod.mjs","sources":["../../src/resolvers/zod.ts"],"sourcesContent":["import type {FieldError} from '../form';\nimport type {Validator} from '../hooks/validate';\nimport {hasStandardProps, standardSchemaResolver} from './standard-schema';\n\nexport function zodResolver(schema: any): Validator {\n // zod v3.24+/v4 schemas carry the Standard Schema props — prefer them.\n if (hasStandardProps(schema)) return standardSchemaResolver(schema);\n // Older zod: fall back to the legacy safeParseAsync API. It aggregates\n // every issue (no abortEarly), so map them all — a value breaking\n // several rules surfaces all of its errors.\n return async (value: any) => {\n const result = await schema.safeParseAsync(value);\n if (result.success) return undefined;\n const {issues} = result.error;\n if (!issues?.length) {\n return [{type: 'custom', message: 'Validation failed'}];\n }\n return issues.map(\n (issue: any): FieldError => ({\n type: issue?.code || 'custom',\n message: issue?.message || 'Validation failed'\n })\n );\n };\n}\n"],"names":[],"mappings":";;;AAIO,SAAS,YAAY,MAAwB,EAAA;AAElD,EAAA,IAAI,gBAAiB,CAAA,MAAM,CAAG,EAAA,OAAO,uBAAuB,MAAM,CAAA,CAAA;AAIlE,EAAA,OAAO,OAAO,KAAe,KAAA;AAC3B,IAAA,MAAM,MAAS,GAAA,MAAM,MAAO,CAAA,cAAA,CAAe,KAAK,CAAA,CAAA;AAChD,IAAI,IAAA,MAAA,CAAO,SAAgB,OAAA,KAAA,CAAA,CAAA;AAC3B,IAAM,MAAA,EAAC,MAAM,EAAA,GAAI,MAAO,CAAA,KAAA,CAAA;AACxB,IAAI,IAAA,CAAC,QAAQ,MAAQ,EAAA;AACnB,MAAA,OAAO,CAAC,EAAC,IAAA,EAAM,QAAU,EAAA,OAAA,EAAS,qBAAoB,CAAA,CAAA;AAAA,KACxD;AACA,IAAA,OAAO,MAAO,CAAA,GAAA;AAAA,MACZ,CAAC,KAA4B,MAAA;AAAA,QAC3B,IAAA,EAAM,OAAO,IAAQ,IAAA,QAAA;AAAA,QACrB,OAAA,EAAS,OAAO,OAAW,IAAA,mBAAA;AAAA,OAC7B,CAAA;AAAA,KACF,CAAA;AAAA,GACF,CAAA;AACF;;;;"}
1
+ {"version":3,"file":"zod.mjs","sources":["../../src/resolvers/zod.ts"],"sourcesContent":["import type {FieldError} from '../form';\nimport type {Validator} from '../hooks/validate';\nimport {hasStandardProps, standardSchemaResolver} from './standard-schema';\n\nexport function zodResolver(schema: any): Validator {\n // zod v3.24+/v4 schemas carry the Standard Schema props — prefer them.\n if (hasStandardProps(schema)) return standardSchemaResolver(schema);\n // Older zod: fall back to the legacy safeParseAsync API. It aggregates\n // every issue (no abortEarly), so map them all — a value breaking\n // several rules surfaces all of its errors.\n return async (value: any) => {\n const result = await schema.safeParseAsync(value);\n if (result.success) return undefined;\n const {issues} = result.error;\n if (!issues?.length) {\n return [{type: 'custom', message: 'Validation failed'}];\n }\n return issues.map((issue: any): FieldError => ({\n type: issue?.code || 'custom',\n message: issue?.message || 'Validation failed'\n }));\n };\n}\n"],"names":[],"mappings":";;;AAIO,SAAS,YAAY,MAAA,EAAwB;AAElD,EAAA,IAAI,gBAAA,CAAiB,MAAM,CAAA,EAAG,OAAO,uBAAuB,MAAM,CAAA;AAIlE,EAAA,OAAO,OAAO,KAAA,KAAe;AAC3B,IAAA,MAAM,MAAA,GAAS,MAAM,MAAA,CAAO,cAAA,CAAe,KAAK,CAAA;AAChD,IAAA,IAAI,MAAA,CAAO,SAAS,OAAO,MAAA;AAC3B,IAAA,MAAM,EAAC,MAAA,EAAM,GAAI,MAAA,CAAO,KAAA;AACxB,IAAA,IAAI,CAAC,QAAQ,MAAA,EAAQ;AACnB,MAAA,OAAO,CAAC,EAAC,IAAA,EAAM,QAAA,EAAU,OAAA,EAAS,qBAAoB,CAAA;AAAA,IACxD;AACA,IAAA,OAAO,MAAA,CAAO,GAAA,CAAI,CAAC,KAAA,MAA4B;AAAA,MAC7C,IAAA,EAAM,OAAO,IAAA,IAAQ,QAAA;AAAA,MACrB,OAAA,EAAS,OAAO,OAAA,IAAW;AAAA,KAC7B,CAAE,CAAA;AAAA,EACJ,CAAA;AACF;;;;"}
@@ -1,4 +1,4 @@
1
- import { a as Form, c as Path, b as FieldError } from './form-61297bc0.js';
1
+ import { F as Form, c as Path, b as FieldError } from './form-DeRFdFKE.js';
2
2
 
3
3
  /**
4
4
  * Field validator. Returns an error (a string, a FieldError, or an array
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-f0rm",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "packageManager": "pnpm@11.4.0",
5
5
  "description": "react form",
6
6
  "main": "dist/index.cjs.js",
@@ -39,6 +39,7 @@
39
39
  ],
40
40
  "sideEffects": false,
41
41
  "scripts": {
42
+ "prepare": "husky",
42
43
  "start": "vitest --watch",
43
44
  "commit": "lint-staged && git-cz -n",
44
45
  "build": "npm run clean && cross-env NODE_ENV=production rollup -c",
@@ -89,63 +90,63 @@
89
90
  }
90
91
  },
91
92
  "devDependencies": {
92
- "@babel/core": "^7.22.8",
93
- "@babel/eslint-parser": "^7.22.7",
94
- "@babel/preset-env": "^7.22.7",
95
- "@babel/preset-react": "^7.22.5",
96
- "@babel/register": "^7.22.5",
97
- "@rollup/plugin-babel": "^6.0.3",
98
- "@rollup/plugin-commonjs": "^25.0.2",
99
- "@rollup/plugin-node-resolve": "^15.1.0",
100
- "@rollup/plugin-replace": "^5.0.2",
101
- "@rollup/plugin-terser": "^0.4.3",
102
- "@size-limit/preset-small-lib": "^12.1.0",
103
- "@storybook/addon-docs": "^10.4.1",
104
- "@storybook/addon-links": "^10.4.1",
105
- "@storybook/react": "^10.4.1",
106
- "@storybook/react-vite": "^10.4.1",
93
+ "@babel/core": "^8.0.1",
94
+ "@babel/preset-env": "^8.0.2",
95
+ "@babel/preset-react": "^8.0.1",
96
+ "@babel/register": "^8.0.1",
97
+ "@eslint/eslintrc": "^3.3.6",
98
+ "@eslint/js": "^10.0.1",
99
+ "@rollup/plugin-babel": "^7.1.0",
100
+ "@rollup/plugin-commonjs": "^29.0.3",
101
+ "@rollup/plugin-node-resolve": "^16.0.3",
102
+ "@rollup/plugin-replace": "^6.0.3",
103
+ "@rollup/plugin-terser": "^1.0.0",
104
+ "@size-limit/preset-small-lib": "^13.0.3",
105
+ "@storybook/addon-docs": "^10.5.10",
106
+ "@storybook/addon-links": "^10.5.10",
107
+ "@storybook/react": "^10.5.10",
108
+ "@storybook/react-vite": "^10.5.10",
107
109
  "@testing-library/dom": "^10.4.1",
108
- "@testing-library/jest-dom": "^6.9.1",
110
+ "@testing-library/jest-dom": "^7.0.1",
109
111
  "@testing-library/react": "^16.3.2",
110
- "@testing-library/user-event": "^14.6.1",
111
- "@types/react": "^18.2.14",
112
- "@typescript-eslint/eslint-plugin": "^8.60.0",
113
- "@typescript-eslint/parser": "^8.60.0",
114
- "@vitest/coverage-v8": "^3.0.0",
115
- "@vitest/ui": "^3.0.0",
116
- "babel-loader": "^9.1.3",
117
- "commitizen": "^4.3.0",
118
- "cross-env": "^7.0.3",
119
- "eslint": "^8.44.0",
120
- "eslint-config-airbnb": "^19.0.4",
112
+ "@testing-library/user-event": "^14.6.6",
113
+ "@types/react": "^19.2.18",
114
+ "@typescript-eslint/eslint-plugin": "^8.67.0",
115
+ "@typescript-eslint/parser": "^8.67.0",
116
+ "@vitest/coverage-v8": "^4.1.11",
117
+ "@vitest/ui": "^4.1.11",
118
+ "babel-loader": "^10.1.1",
119
+ "commitizen": "^4.3.2",
120
+ "cross-env": "^10.1.0",
121
+ "eslint": "^10.9.0",
121
122
  "eslint-config-prettier": "^10.1.8",
122
- "eslint-import-resolver-typescript": "^4.4.4",
123
+ "eslint-import-resolver-typescript": "^4.4.5",
123
124
  "eslint-plugin-builtin-compat": "0.0.2",
124
- "eslint-plugin-import": "^2.27.5",
125
- "eslint-plugin-jsx-a11y": "^6.7.1",
126
- "eslint-plugin-prettier": "^5.5.5",
127
- "eslint-plugin-react": "^7.32.2",
128
- "eslint-plugin-react-hooks": "^4.6.0",
129
- "eslint-plugin-storybook": "^10.4.1",
130
- "eslint-plugin-vitest": "^0.5.4",
131
- "husky": "^8.0.3",
132
- "jsdom": "^24.0.0",
133
- "lint-staged": "^13.2.3",
134
- "prettier": "^3.0.0",
135
- "react": "^18.2.0",
136
- "react-dom": "^18.2.0",
137
- "react-hook-form": "^7.85.0",
138
- "rimraf": "^5.0.1",
139
- "rollup": "^3.26.2",
140
- "rollup-plugin-dts": "^6.4.1",
125
+ "eslint-plugin-import": "^2.32.0",
126
+ "eslint-plugin-jsx-a11y": "^6.10.2",
127
+ "eslint-plugin-prettier": "^5.5.6",
128
+ "eslint-plugin-react": "^7.37.5",
129
+ "eslint-plugin-react-hooks": "^7.1.1",
130
+ "eslint-plugin-storybook": "^10.5.10",
131
+ "globals": "^17.11.0",
132
+ "husky": "^9.1.7",
133
+ "jsdom": "^30.0.1",
134
+ "lint-staged": "^17.3.0",
135
+ "prettier": "^3.9.6",
136
+ "react": "^19.2.8",
137
+ "react-dom": "^19.2.8",
138
+ "react-hook-form": "^7.86.0",
139
+ "rimraf": "^6.1.3",
140
+ "rollup": "^4.62.5",
141
+ "rollup-plugin-dts": "^6.5.1",
141
142
  "rollup-plugin-esbuild": "^6.2.1",
142
- "size-limit": "^12.1.0",
143
- "storybook": "^10.4.1",
144
- "typescript": "^5.1.6",
145
- "vitest": "^3.0.0"
143
+ "size-limit": "^13.0.3",
144
+ "storybook": "^10.5.10",
145
+ "typescript": "^6.0.3",
146
+ "vitest": "^4.1.11"
146
147
  },
147
148
  "dependencies": {
148
- "@for-fun/event-emitter": "^1.0.0",
149
+ "@for-fun/event-emitter": "^1.0.1",
149
150
  "use-sync-external-store": "^1.6.0"
150
151
  },
151
152
  "size-limit": [