@paragrav/rhf-utils 0.0.131 → 0.0.132

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 (139) hide show
  1. package/dist/esm/client/config/useRhfUtilsClientConfigContext.mjs +1 -0
  2. package/dist/esm/client/config/useRhfUtilsClientConfigContext.mjs.map +1 -0
  3. package/dist/esm/client/index.mjs +1 -0
  4. package/dist/esm/client/index.mjs.map +1 -0
  5. package/dist/esm/client/utils.mjs +1 -0
  6. package/dist/esm/client/utils.mjs.map +1 -0
  7. package/dist/esm/client/zod/context/RhfUtilsClientForZodContextProvider.mjs +1 -0
  8. package/dist/esm/client/zod/context/RhfUtilsClientForZodContextProvider.mjs.map +1 -0
  9. package/dist/esm/client/zod/context/RhfUtilsZodForm.mjs +1 -0
  10. package/dist/esm/client/zod/context/RhfUtilsZodForm.mjs.map +1 -0
  11. package/dist/esm/client/zod/context/useRhfUtilsClientForZodContext.mjs +1 -0
  12. package/dist/esm/client/zod/context/useRhfUtilsClientForZodContext.mjs.map +1 -0
  13. package/dist/esm/client/zod/context/useRhfUtilsZodForm.mjs +1 -0
  14. package/dist/esm/client/zod/context/useRhfUtilsZodForm.mjs.map +1 -0
  15. package/dist/esm/client/zod/createRhfUtilsClientForZod.mjs +1 -0
  16. package/dist/esm/client/zod/createRhfUtilsClientForZod.mjs.map +1 -0
  17. package/dist/esm/devtool/LazyDevTool.mjs +1 -0
  18. package/dist/esm/devtool/LazyDevTool.mjs.map +1 -0
  19. package/dist/esm/errors/flat/FlatFieldErrorsList.mjs +1 -0
  20. package/dist/esm/errors/flat/FlatFieldErrorsList.mjs.map +1 -0
  21. package/dist/esm/errors/flat/context/FlatFieldErrorsContextProvider.mjs +1 -0
  22. package/dist/esm/errors/flat/context/FlatFieldErrorsContextProvider.mjs.map +1 -0
  23. package/dist/esm/errors/flat/context/useFlatFieldErrorsContext.mjs +1 -0
  24. package/dist/esm/errors/flat/context/useFlatFieldErrorsContext.mjs.map +1 -0
  25. package/dist/esm/errors/flat/context/useFlatFieldErrorsContextHasOnlyOrphans.mjs +1 -0
  26. package/dist/esm/errors/flat/context/useFlatFieldErrorsContextHasOnlyOrphans.mjs.map +1 -0
  27. package/dist/esm/errors/flat/context/useFlatFieldErrorsContextOutput.mjs +1 -0
  28. package/dist/esm/errors/flat/context/useFlatFieldErrorsContextOutput.mjs.map +1 -0
  29. package/dist/esm/errors/flat/filterFlatFieldErrors.mjs +1 -0
  30. package/dist/esm/errors/flat/filterFlatFieldErrors.mjs.map +1 -0
  31. package/dist/esm/errors/flat/flattenFieldErrors.mjs +1 -0
  32. package/dist/esm/errors/flat/flattenFieldErrors.mjs.map +1 -0
  33. package/dist/esm/errors/flat/getFlatFieldErrors.mjs +1 -0
  34. package/dist/esm/errors/flat/getFlatFieldErrors.mjs.map +1 -0
  35. package/dist/esm/errors/getRefdFromFlatFieldErrors.mjs +1 -0
  36. package/dist/esm/errors/getRefdFromFlatFieldErrors.mjs.map +1 -0
  37. package/dist/esm/errors/isFieldErrorRefd.mjs +1 -0
  38. package/dist/esm/errors/isFieldErrorRefd.mjs.map +1 -0
  39. package/dist/esm/errors/isFlatFieldErrorEntryRefd.mjs +1 -0
  40. package/dist/esm/errors/isFlatFieldErrorEntryRefd.mjs.map +1 -0
  41. package/dist/esm/errors/message/FormErrorMessage.mjs +1 -0
  42. package/dist/esm/errors/message/FormErrorMessage.mjs.map +1 -0
  43. package/dist/esm/errors/message/FormErrorMessageByPath.mjs +1 -0
  44. package/dist/esm/errors/message/FormErrorMessageByPath.mjs.map +1 -0
  45. package/dist/esm/errors/nonfield/FormNonFieldErrorMarker.mjs +1 -0
  46. package/dist/esm/errors/nonfield/FormNonFieldErrorMarker.mjs.map +1 -0
  47. package/dist/esm/errors/nonfield/FormNonFieldErrorMarker.utils.mjs +1 -0
  48. package/dist/esm/errors/nonfield/FormNonFieldErrorMarker.utils.mjs.map +1 -0
  49. package/dist/esm/errors/nonfield/FormNonFieldErrorMarkerHtmlAttribute.mjs +1 -0
  50. package/dist/esm/errors/nonfield/FormNonFieldErrorMarkerHtmlAttribute.mjs.map +1 -0
  51. package/dist/esm/errors/nonfield/isNonFieldErrorMarkerInDOM.mjs +1 -0
  52. package/dist/esm/errors/nonfield/isNonFieldErrorMarkerInDOM.mjs.map +1 -0
  53. package/dist/esm/errors/orphan/getIsOrphanFormErrorWithParentElement.mjs +1 -0
  54. package/dist/esm/errors/orphan/getIsOrphanFormErrorWithParentElement.mjs.map +1 -0
  55. package/dist/esm/errors/orphan/getOrphansFromFlatFieldErrors.mjs +1 -0
  56. package/dist/esm/errors/orphan/getOrphansFromFlatFieldErrors.mjs.map +1 -0
  57. package/dist/esm/errors/orphan/isOrphanFormError.mjs +1 -0
  58. package/dist/esm/errors/orphan/isOrphanFormError.mjs.map +1 -0
  59. package/dist/esm/errors/output/consoleErrors.mjs +1 -0
  60. package/dist/esm/errors/output/consoleErrors.mjs.map +1 -0
  61. package/dist/esm/errors/root/RootErrorsListFromFlatFieldErrorsContext.mjs +1 -0
  62. package/dist/esm/errors/root/RootErrorsListFromFlatFieldErrorsContext.mjs.map +1 -0
  63. package/dist/esm/errors/root/consts.mjs +1 -0
  64. package/dist/esm/errors/root/consts.mjs.map +1 -0
  65. package/dist/esm/errors/root/getRootsFromFlatFieldErrors.mjs +1 -0
  66. package/dist/esm/errors/root/getRootsFromFlatFieldErrors.mjs.map +1 -0
  67. package/dist/esm/errors/root/isFlatFieldErrorEntryPathRoot.mjs +1 -0
  68. package/dist/esm/errors/root/isFlatFieldErrorEntryPathRoot.mjs.map +1 -0
  69. package/dist/esm/errors/root/isFormErrorPathRoot.mjs +1 -0
  70. package/dist/esm/errors/root/isFormErrorPathRoot.mjs.map +1 -0
  71. package/dist/esm/errors/trpc/getOnSubmitTrpcClientErrorHandler.mjs +1 -0
  72. package/dist/esm/errors/trpc/getOnSubmitTrpcClientErrorHandler.mjs.map +1 -0
  73. package/dist/esm/errors/trpc/trpcClientErrorMessageSchema.mjs +1 -0
  74. package/dist/esm/errors/trpc/trpcClientErrorMessageSchema.mjs.map +1 -0
  75. package/dist/esm/errors/trpc/trpcClientErrorToFormSubmitErrorsSchemaTransformer.mjs +1 -0
  76. package/dist/esm/errors/trpc/trpcClientErrorToFormSubmitErrorsSchemaTransformer.mjs.map +1 -0
  77. package/dist/esm/exports.mjs +1 -0
  78. package/dist/esm/exports.mjs.map +1 -0
  79. package/dist/esm/form/Form.mjs +1 -0
  80. package/dist/esm/form/Form.mjs.map +1 -0
  81. package/dist/esm/form/FormWithProviders.mjs +1 -0
  82. package/dist/esm/form/FormWithProviders.mjs.map +1 -0
  83. package/dist/esm/form/RhfUtilsFormProviders.mjs +1 -0
  84. package/dist/esm/form/RhfUtilsFormProviders.mjs.map +1 -0
  85. package/dist/esm/form/_Controller.mjs +1 -0
  86. package/dist/esm/form/_Controller.mjs.map +1 -0
  87. package/dist/esm/form/context/group/FormGroupContextProvider.mjs +1 -0
  88. package/dist/esm/form/context/group/FormGroupContextProvider.mjs.map +1 -0
  89. package/dist/esm/form/context/group/index.mjs +1 -0
  90. package/dist/esm/form/context/group/index.mjs.map +1 -0
  91. package/dist/esm/form/context/group/useFormGroupChildIsMountedTracker.mjs +1 -0
  92. package/dist/esm/form/context/group/useFormGroupChildIsMountedTracker.mjs.map +1 -0
  93. package/dist/esm/form/context/group/useFormGroupChildIsSubmittingTracker.mjs +1 -0
  94. package/dist/esm/form/context/group/useFormGroupChildIsSubmittingTracker.mjs.map +1 -0
  95. package/dist/esm/form/context/group/useFormGroupChildTracker.mjs +1 -0
  96. package/dist/esm/form/context/group/useFormGroupChildTracker.mjs.map +1 -0
  97. package/dist/esm/form/context/group/useFormGroupIsAnyBusy.mjs +1 -0
  98. package/dist/esm/form/context/group/useFormGroupIsAnyBusy.mjs.map +1 -0
  99. package/dist/esm/form/context/group/useFormGroupIsChildBusy.mjs +1 -0
  100. package/dist/esm/form/context/group/useFormGroupIsChildBusy.mjs.map +1 -0
  101. package/dist/esm/form/context/group/useFormGroupIsParentBusy.mjs +1 -0
  102. package/dist/esm/form/context/group/useFormGroupIsParentBusy.mjs.map +1 -0
  103. package/dist/esm/form/context/group/useFormGroupParentTracker.mjs +1 -0
  104. package/dist/esm/form/context/group/useFormGroupParentTracker.mjs.map +1 -0
  105. package/dist/esm/form/context/group/useFormOrParentIsBusy.mjs +1 -0
  106. package/dist/esm/form/context/group/useFormOrParentIsBusy.mjs.map +1 -0
  107. package/dist/esm/form/context/utils/RhfUtilsContextProvider.mjs +1 -0
  108. package/dist/esm/form/context/utils/RhfUtilsContextProvider.mjs.map +1 -0
  109. package/dist/esm/form/context/utils/useRhfUtilsContext.mjs +1 -0
  110. package/dist/esm/form/context/utils/useRhfUtilsContext.mjs.map +1 -0
  111. package/dist/esm/form/context/utils/useRhfUtilsContextRequestSubmit.mjs +1 -0
  112. package/dist/esm/form/context/utils/useRhfUtilsContextRequestSubmit.mjs.map +1 -0
  113. package/dist/esm/form/useFormIsBusy.mjs +1 -0
  114. package/dist/esm/form/useFormIsBusy.mjs.map +1 -0
  115. package/dist/esm/form/useRhfUtilsForm.mjs +1 -0
  116. package/dist/esm/form/useRhfUtilsForm.mjs.map +1 -0
  117. package/dist/esm/form/utils/getSubmitterButtonData.mjs +1 -0
  118. package/dist/esm/form/utils/getSubmitterButtonData.mjs.map +1 -0
  119. package/dist/esm/form/utils/useFormRequestSubmit.mjs +1 -0
  120. package/dist/esm/form/utils/useFormRequestSubmit.mjs.map +1 -0
  121. package/dist/esm/submit/error/FormSubmitError.mjs +1 -0
  122. package/dist/esm/submit/error/FormSubmitError.mjs.map +1 -0
  123. package/dist/esm/submit/error/setCtxErrorsByFormSubmitErrors.mjs +1 -0
  124. package/dist/esm/submit/error/setCtxErrorsByFormSubmitErrors.mjs.map +1 -0
  125. package/dist/esm/submit/useFormOnSubmitted.mjs +1 -0
  126. package/dist/esm/submit/useFormOnSubmitted.mjs.map +1 -0
  127. package/dist/esm/submit/useResetFormOnSubmitted.mjs +1 -0
  128. package/dist/esm/submit/useResetFormOnSubmitted.mjs.map +1 -0
  129. package/dist/esm/submit/useSubmitFormOnChange.mjs +1 -0
  130. package/dist/esm/submit/useSubmitFormOnChange.mjs.map +1 -0
  131. package/dist/esm/utils/PassthroughChildren.mjs +1 -0
  132. package/dist/esm/utils/PassthroughChildren.mjs.map +1 -0
  133. package/dist/esm/utils/createContext.mjs +1 -0
  134. package/dist/esm/utils/createContext.mjs.map +1 -0
  135. package/dist/esm/utils/isEmptyObject.mjs +1 -0
  136. package/dist/esm/utils/isEmptyObject.mjs.map +1 -0
  137. package/dist/esm/utils/useRefIfValueWasTrue.mjs +1 -0
  138. package/dist/esm/utils/useRefIfValueWasTrue.mjs.map +1 -0
  139. package/package.json +1 -1
@@ -7,3 +7,4 @@ export {
7
7
  o as _RhfUtilsClientConfigContextProvider,
8
8
  i as default
9
9
  };
10
+ //# sourceMappingURL=useRhfUtilsClientConfigContext.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useRhfUtilsClientConfigContext.mjs","sources":["../../../../src/client/config/useRhfUtilsClientConfigContext.tsx"],"sourcesContent":["import createContext from '@/utils/createContext';\n\nimport type { RhfUtilsClientConfig } from './RhfUtilsClientConfig';\n\nconst {\n Provider: _RhfUtilsClientConfigContextProvider,\n useMaybe: useRhfUtilsClientConfigMaybeContext,\n} = createContext<RhfUtilsClientConfig>();\n\n//\n\nexport default useRhfUtilsClientConfigMaybeContext;\n\n//\n\nexport { _RhfUtilsClientConfigContextProvider };\n"],"names":["_RhfUtilsClientConfigContextProvider","useRhfUtilsClientConfigMaybeContext","createContext"],"mappings":";AAIM,MAAA;AAAA,EACJ,UAAUA;AAAA,EACV,UAAUC;AACZ,IAAIC,EAAoC;"}
@@ -47,3 +47,4 @@ const c = (r) => (o) => {
47
47
  export {
48
48
  c as createRhfUtilsClient
49
49
  };
50
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sources":["../../../src/client/index.tsx"],"sourcesContent":["import React from 'react';\nimport type { Resolver } from 'react-hook-form';\n\nimport type { RhfUtilsClientConfig } from '@/client/config/RhfUtilsClientConfig';\n\nimport type { FormWithProvidersProps } from '@/form/FormWithProviders';\nimport FormWithProviders from '@/form/FormWithProviders';\nimport type { SafeFieldValues } from '@/form/SafeFieldValues';\nimport useRhfUtilsForm from '@/form/useRhfUtilsForm';\nimport type { UseRhfUtilsFormProps } from '@/form/UseRhfUtilsFormProps';\nimport type { UseRhfUtilsFormReturn } from '@/form/UseRhfUtilsFormReturn';\n\nimport { mergeRhfUtilsClientConfigDefaultsWithUseRhfUtilsFormProps } from './utils';\n\n/**\n * Generic object schema type.\n */\nexport type ObjectSchema<\n TInputKey extends string,\n TOutputKey extends string,\n> = {\n [key in TInputKey]: SafeFieldValues; // should have key that returns FieldValues for input\n} & {\n [key in TOutputKey]: SafeFieldValues; // should have key that returns FieldValues for output\n};\n\n//\n\nexport type CreateRhfUtilsClient<\n TObjectSchema extends ObjectSchema<\n TObjectSchemaInputKey,\n TObjectSchemaOutputKey\n >,\n TObjectSchemaInputKey extends string,\n TObjectSchemaOutputKey extends string,\n> = {\n useForm: <\n TSchema extends TObjectSchema,\n TSchemaInput extends SafeFieldValues = TSchema[TObjectSchemaInputKey],\n TSchemaOutput extends SafeFieldValues = TSchema[TObjectSchemaOutputKey],\n UseRhfUtilsFormPropsForm extends UseRhfUtilsFormProps<\n TSchemaInput,\n TSchemaOutput\n > = UseRhfUtilsFormProps<TSchemaInput, TSchemaOutput>,\n >(\n schema: TSchema,\n form: UseRhfUtilsFormPropsForm,\n ) => UseRhfUtilsFormReturn<TSchemaInput, TSchemaOutput> & {\n FormWithProviders: React.FC<React.PropsWithChildren>;\n };\n\n FormWithProviders: <\n TSchema extends TObjectSchema,\n TSchemaInput extends SafeFieldValues = TSchema[TObjectSchemaInputKey],\n TSchemaOutput extends SafeFieldValues = TSchema[TObjectSchemaOutputKey],\n >(\n props: { schema: TSchema } & FormWithProvidersProps<\n TSchemaInput,\n TSchemaOutput\n >,\n ) => JSX.Element;\n};\n\n/**\n * ...\n *\n * (We need to use generics to generate types for schema resolver.)\n */\nexport const createRhfUtilsClient =\n <\n TObjectSchema extends ObjectSchema<\n TObjectSchemaInputKey,\n TObjectSchemaOutputKey\n >,\n TObjectSchemaInputKey extends string,\n TObjectSchemaOutputKey extends string,\n >(\n resolver: (schema: TObjectSchema) => Resolver<SafeFieldValues, unknown>,\n ) =>\n (\n config: RhfUtilsClientConfig,\n ): CreateRhfUtilsClient<\n TObjectSchema,\n TObjectSchemaInputKey,\n TObjectSchemaOutputKey\n > => {\n const _getUseRhfUtilsFormPropsWithResolverAndConfig =\n _getUseRhfUtilsFormProps(resolver, config);\n\n return {\n useForm: <\n TSchema extends TObjectSchema,\n TSchemaInput extends SafeFieldValues = TSchema[TObjectSchemaInputKey],\n TSchemaOutput extends SafeFieldValues = TSchema[TObjectSchemaOutputKey],\n UseRhfUtilsFormPropsForm extends UseRhfUtilsFormProps<\n TSchemaInput,\n TSchemaOutput\n > = UseRhfUtilsFormProps<TSchemaInput, TSchemaOutput>,\n >(\n schema: TSchema,\n form: UseRhfUtilsFormPropsForm,\n ) => {\n const useFormProps = _getUseRhfUtilsFormPropsWithResolverAndConfig<\n TSchema,\n TSchemaInput,\n TSchemaOutput\n >(schema, form);\n\n return {\n ...useRhfUtilsForm(useFormProps),\n FormWithProviders: (): React.ReactNode => {\n return <FormWithProviders {...useFormProps} />;\n },\n };\n },\n FormWithProviders: _getFormWithProviders(resolver, config),\n };\n };\n\nconst _getUseRhfUtilsFormProps = <\n TObjectSchema extends ObjectSchema<\n TObjectSchemaInputKey,\n TObjectSchemaOutputKey\n >,\n TObjectSchemaInputKey extends string,\n TObjectSchemaOutputKey extends string,\n>(\n resolver: (schema: TObjectSchema) => Resolver<SafeFieldValues, unknown>,\n config: RhfUtilsClientConfig,\n) =>\n function _getUseRhfUtilsFormPropsWithResolverAndConfigBySchemaAndFormProps<\n TSchema extends TObjectSchema,\n TSchemaInput extends SafeFieldValues = TSchema[TObjectSchemaInputKey],\n TSchemaOutput extends SafeFieldValues = TSchema[TObjectSchemaOutputKey],\n >(\n schema: TSchema,\n props: UseRhfUtilsFormProps<TSchemaInput, TSchemaOutput>,\n ): UseRhfUtilsFormProps<TSchemaInput, TSchemaOutput> {\n return {\n ...props,\n\n ...mergeRhfUtilsClientConfigDefaultsWithUseRhfUtilsFormProps(\n config.defaults,\n props,\n {\n rhf: {\n resolver: resolver(schema) as Resolver<TSchemaInput, unknown>,\n },\n },\n ),\n };\n };\n\nconst _getFormWithProviders = <\n TObjectSchema extends ObjectSchema<\n TObjectSchemaInputKey,\n TObjectSchemaOutputKey\n >,\n TObjectSchemaInputKey extends string,\n TObjectSchemaOutputKey extends string,\n>(\n resolver: (schema: TObjectSchema) => Resolver<SafeFieldValues, unknown>,\n config: RhfUtilsClientConfig,\n) => {\n const _getUseRhfUtilsFormPropsWithResolverAndConfig =\n _getUseRhfUtilsFormProps<\n TObjectSchema,\n TObjectSchemaInputKey,\n TObjectSchemaOutputKey\n >(resolver, config);\n\n return function _FormWithProviders<\n TSchema extends TObjectSchema,\n TSchemaInput extends SafeFieldValues = TSchema[TObjectSchemaInputKey],\n TSchemaOutput extends SafeFieldValues = TSchema[TObjectSchemaOutputKey],\n >({\n schema,\n children,\n ...props\n }: { schema: TSchema } & FormWithProvidersProps<\n TSchemaInput,\n TSchemaOutput\n >) {\n return (\n <FormWithProviders\n {..._getUseRhfUtilsFormPropsWithResolverAndConfig(schema, props)}\n >\n {children}\n </FormWithProviders>\n );\n };\n};\n"],"names":["createRhfUtilsClient","resolver","config","_getUseRhfUtilsFormPropsWithResolverAndConfig","_getUseRhfUtilsFormProps","schema","form","useFormProps","useRhfUtilsForm","jsx","FormWithProviders","_getFormWithProviders","props","mergeRhfUtilsClientConfigDefaultsWithUseRhfUtilsFormProps","children"],"mappings":";;;;;AAoEO,MAAMA,IACX,CAQEC,MAEF,CACEC,MAKG;AACG,QAAAC,IACJC,EAAyBH,GAAUC,CAAM;AAEpC,SAAA;AAAA,IACL,SAAS,CASPG,GACAC,MACG;AACG,YAAAC,IAAeJ,EAInBE,GAAQC,CAAI;AAEP,aAAA;AAAA,QACL,GAAGE,EAAgBD,CAAY;AAAA,QAC/B,mBAAmB,MACV,gBAAAE,EAACC,GAAmB,EAAA,GAAGH,EAAc,CAAA;AAAA,MAC9C;AAAA,IAEJ;AAAA,IACA,mBAAmBI,EAAsBV,GAAUC,CAAM;AAAA,EAAA;AAE7D,GAEIE,IAA2B,CAQ/BH,GACAC,MAEA,SAKEG,GACAO,GACmD;AAC5C,SAAA;AAAA,IACL,GAAGA;AAAA,IAEH,GAAGC;AAAA,MACDX,EAAO;AAAA,MACPU;AAAA,MACA;AAAA,QACE,KAAK;AAAA,UACH,UAAUX,EAASI,CAAM;AAAA,QAC3B;AAAA,MACF;AAAA,IACF;AAAA,EAAA;AAEJ,GAEIM,IAAwB,CAQ5BV,GACAC,MACG;AACG,QAAAC,IACJC,EAIEH,GAAUC,CAAM;AAEpB,SAAO,SAIL;AAAA,IACA,QAAAG;AAAA,IACA,UAAAS;AAAA,IACA,GAAGF;AAAA,EAAA,GAIF;AAEC,WAAA,gBAAAH;AAAA,MAACC;AAAA,MAAA;AAAA,QACE,GAAGP,EAA8CE,GAAQO,CAAK;AAAA,QAE9D,UAAAE;AAAA,MAAA;AAAA,IAAA;AAAA,EACH;AAGN;"}
@@ -27,3 +27,4 @@ const i = (l, ...t) => (
27
27
  export {
28
28
  i as mergeRhfUtilsClientConfigDefaultsWithUseRhfUtilsFormProps
29
29
  };
30
+ //# sourceMappingURL=utils.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.mjs","sources":["../../../src/client/utils.ts"],"sourcesContent":["import type { RhfUtilsFormOptions } from '@/form/RhfUtilsFormOptions';\nimport type { SafeFieldValues } from '@/form/SafeFieldValues';\nimport type { UseRhfUtilsFormProps } from '@/form/UseRhfUtilsFormProps';\n\nimport type { RhfUtilsClientConfig } from './config/RhfUtilsClientConfig';\n\n/**\n * Merge {@link RhfUtilsClientConfig.defaults} with array of {@link UseRhfUtilsFormProps}'s overrides.\n */\nexport const mergeRhfUtilsClientConfigDefaultsWithUseRhfUtilsFormProps = <\n TFieldValues extends SafeFieldValues,\n TTransformedValues extends SafeFieldValues,\n>(\n defaults: RhfUtilsClientConfig['defaults'],\n ...props: Pick<\n UseRhfUtilsFormProps<TFieldValues, TTransformedValues>,\n 'rhf' | 'utils' | 'form'\n >[]\n) =>\n // sequentially merge each set of props into defaults\n props.reduce(\n (acc, curr) => ({\n rhf: {\n ...acc?.rhf,\n ...curr.rhf,\n },\n\n utils: {\n ...acc?.utils,\n ...curr.utils,\n } satisfies RhfUtilsFormOptions,\n\n form: {\n ...acc?.form,\n ...curr.form,\n className: [acc?.form?.className, curr.form?.className]\n .filter(Boolean) // filter out falsy values\n .join(' '), // stringify\n },\n }),\n\n // start with defaults\n defaults,\n );\n"],"names":["mergeRhfUtilsClientConfigDefaultsWithUseRhfUtilsFormProps","defaults","props","acc","curr","_a","_b"],"mappings":"AASa,MAAAA,IAA4D,CAIvEC,MACGC;AAAA;AAAA,EAMHA,EAAM;AAAA,IACJ,CAACC,GAAKC,MAAU;AAZP,UAAAC,GAAAC;AAYO;AAAA,QACd,KAAK;AAAA,UACH,GAAGH,KAAA,gBAAAA,EAAK;AAAA,UACR,GAAGC,EAAK;AAAA,QACV;AAAA,QAEA,OAAO;AAAA,UACL,GAAGD,KAAA,gBAAAA,EAAK;AAAA,UACR,GAAGC,EAAK;AAAA,QACV;AAAA,QAEA,MAAM;AAAA,UACJ,GAAGD,KAAA,gBAAAA,EAAK;AAAA,UACR,GAAGC,EAAK;AAAA,UACR,WAAW,EAACC,IAAAF,KAAA,gBAAAA,EAAK,SAAL,gBAAAE,EAAW,YAAWC,IAAAF,EAAK,SAAL,gBAAAE,EAAW,SAAS,EACnD,OAAO,OAAO,EACd,KAAK,GAAG;AAAA;AAAA,QACb;AAAA,MAAA;AAAA;AAAA;AAAA,IAIFL;AAAA,EACF;AAAA;"}
@@ -13,3 +13,4 @@ const d = ({
13
13
  export {
14
14
  p as default
15
15
  };
16
+ //# sourceMappingURL=RhfUtilsClientForZodContextProvider.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RhfUtilsClientForZodContextProvider.mjs","sources":["../../../../../src/client/zod/context/RhfUtilsClientForZodContextProvider.tsx"],"sourcesContent":["import React from 'react';\n\nimport type { RhfUtilsClientConfig } from '@/client/config/RhfUtilsClientConfig';\nimport { _RhfUtilsClientConfigContextProvider } from '@/client/config/useRhfUtilsClientConfigContext';\n\nimport createRhfUtilsClientForZod from '../createRhfUtilsClientForZod';\n\nimport { _RhfUtilsClientForZodContextProvider } from './useRhfUtilsClientForZodContext';\n\ntype Props = React.PropsWithChildren<{\n config: RhfUtilsClientConfig;\n}>;\n\nconst RhfUtilsClientForZodContextProvider: React.FC<Props> = ({\n config,\n children,\n}) => {\n const [_config] = React.useState(config); // memo-ize initial value\n const [_client] = React.useState(() => createRhfUtilsClientForZod(_config));\n\n return (\n <_RhfUtilsClientConfigContextProvider value={_config}>\n <_RhfUtilsClientForZodContextProvider value={_client}>\n {children}\n </_RhfUtilsClientForZodContextProvider>\n </_RhfUtilsClientConfigContextProvider>\n );\n};\n\nexport default RhfUtilsClientForZodContextProvider;\n"],"names":["RhfUtilsClientForZodContextProvider","config","children","_config","React","_client","createRhfUtilsClientForZod","jsx","_RhfUtilsClientConfigContextProvider","_RhfUtilsClientForZodContextProvider","RhfUtilsClientForZodContextProvider$1"],"mappings":";;;;;AAaA,MAAMA,IAAuD,CAAC;AAAA,EAC5D,QAAAC;AAAA,EACA,UAAAC;AACF,MAAM;AACJ,QAAM,CAACC,CAAO,IAAIC,EAAM,SAASH,CAAM,GACjC,CAACI,CAAO,IAAID,EAAM,SAAS,MAAME,EAA2BH,CAAO,CAAC;AAGxE,SAAA,gBAAAI,EAACC,KAAqC,OAAOL,GAC3C,4BAACM,GAAqC,EAAA,OAAOJ,GAC1C,UAAAH,EACH,CAAA,EACF,CAAA;AAEJ,GAEAQ,IAAeV;"}
@@ -10,3 +10,4 @@ function m({
10
10
  export {
11
11
  m as default
12
12
  };
13
+ //# sourceMappingURL=RhfUtilsZodForm.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RhfUtilsZodForm.mjs","sources":["../../../../../src/client/zod/context/RhfUtilsZodForm.tsx"],"sourcesContent":["import type { UseRhfUtilsFormProps } from '@/form/UseRhfUtilsFormProps';\n\nimport type { zodTypeInput, zodTypeOutput } from '../consts';\nimport type { ZodTypeFieldValues } from '../ZodTypeFieldValues';\n\nimport useRhfUtilsClientForZodContext from './useRhfUtilsClientForZodContext';\n\ntype Props<TSchema extends ZodTypeFieldValues> = {\n schema: TSchema;\n} & UseRhfUtilsFormProps<\n TSchema[typeof zodTypeInput],\n TSchema[typeof zodTypeOutput]\n>;\n\nfunction RhfUtilsZodForm<TSchema extends ZodTypeFieldValues>({\n schema,\n ...props\n}: Props<TSchema>) {\n const { FormWithProviders } = useRhfUtilsClientForZodContext();\n\n return <FormWithProviders schema={schema} {...props} />;\n}\n\nexport default RhfUtilsZodForm;\n"],"names":["RhfUtilsZodForm","schema","props","FormWithProviders","useRhfUtilsClientForZodContext","jsx"],"mappings":";;AAcA,SAASA,EAAoD;AAAA,EAC3D,QAAAC;AAAA,EACA,GAAGC;AACL,GAAmB;AACX,QAAA,EAAE,mBAAAC,MAAsBC;AAE9B,SAAQ,gBAAAC,EAAAF,GAAA,EAAkB,QAAAF,GAAiB,GAAGC,EAAO,CAAA;AACvD;"}
@@ -7,3 +7,4 @@ export {
7
7
  o as _RhfUtilsClientForZodContextProvider,
8
8
  r as default
9
9
  };
10
+ //# sourceMappingURL=useRhfUtilsClientForZodContext.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useRhfUtilsClientForZodContext.mjs","sources":["../../../../../src/client/zod/context/useRhfUtilsClientForZodContext.tsx"],"sourcesContent":["import createContext from '@/utils/createContext';\n\nimport type createRhfUtilsClientForZod from '../createRhfUtilsClientForZod';\n\nexport type RhfUtilsClientForZodContext = ReturnType<\n typeof createRhfUtilsClientForZod\n>;\n\nconst {\n Provider: _RhfUtilsClientForZodContextProvider,\n useRequired: useRhfUtilsClientForZodContext,\n} = createContext<RhfUtilsClientForZodContext>();\n\n//\n\nexport default useRhfUtilsClientForZodContext;\n\n//\n\nexport { _RhfUtilsClientForZodContextProvider };\n"],"names":["_RhfUtilsClientForZodContextProvider","useRhfUtilsClientForZodContext","createContext"],"mappings":";AAQM,MAAA;AAAA,EACJ,UAAUA;AAAA,EACV,aAAaC;AACf,IAAIC,EAA2C;"}
@@ -3,3 +3,4 @@ const e = (o, t) => s().useForm(o, t), f = e;
3
3
  export {
4
4
  f as default
5
5
  };
6
+ //# sourceMappingURL=useRhfUtilsZodForm.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useRhfUtilsZodForm.mjs","sources":["../../../../../src/client/zod/context/useRhfUtilsZodForm.ts"],"sourcesContent":["import type { UseRhfUtilsFormProps } from '@/form/UseRhfUtilsFormProps';\n\nimport type { zodTypeInput, zodTypeOutput } from '../consts';\nimport type { ZodTypeFieldValues } from '../ZodTypeFieldValues';\n\nimport useRhfUtilsClientForZodContext from './useRhfUtilsClientForZodContext';\n\nconst useRhfUtilsZodForm = <TSchema extends ZodTypeFieldValues>(\n schema: TSchema,\n form: UseRhfUtilsFormProps<\n TSchema[typeof zodTypeInput],\n TSchema[typeof zodTypeOutput]\n >,\n) => useRhfUtilsClientForZodContext().useForm(schema, form);\n\nexport default useRhfUtilsZodForm;\n"],"names":["useRhfUtilsZodForm","schema","form","useRhfUtilsClientForZodContext","useRhfUtilsZodForm$1"],"mappings":";AAOA,MAAMA,IAAqB,CACzBC,GACAC,MAIGC,EAAiC,EAAA,QAAQF,GAAQC,CAAI,GAE1DE,IAAeJ;"}
@@ -4,3 +4,4 @@ const i = e(t);
4
4
  export {
5
5
  i as default
6
6
  };
7
+ //# sourceMappingURL=createRhfUtilsClientForZod.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createRhfUtilsClientForZod.mjs","sources":["../../../../src/client/zod/createRhfUtilsClientForZod.tsx"],"sourcesContent":["import { zodResolver } from '@hookform/resolvers/zod';\n\nimport { createRhfUtilsClient } from '..';\n\nimport { zodTypeInput, zodTypeOutput } from './consts';\nimport type { ZodTypeFieldValues } from './ZodTypeFieldValues';\n\nconst createRhfUtilsClientForZod = createRhfUtilsClient<\n ZodTypeFieldValues,\n typeof zodTypeInput,\n typeof zodTypeOutput\n>(zodResolver);\n\nexport default createRhfUtilsClientForZod;\n"],"names":["createRhfUtilsClientForZod","createRhfUtilsClient","zodResolver"],"mappings":";;AAOM,MAAAA,IAA6BC,EAIjCC,CAAW;"}
@@ -13,3 +13,4 @@ const a = e.lazy(
13
13
  export {
14
14
  u as default
15
15
  };
16
+ //# sourceMappingURL=LazyDevTool.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LazyDevTool.mjs","sources":["../../../src/devtool/LazyDevTool.tsx"],"sourcesContent":["import type { DevtoolUIProps } from '@hookform/devtools/dist/devToolUI';\nimport React from 'react';\nimport { useFormContext } from 'react-hook-form';\n\nconst LazyRhfDevTool = React.lazy(() =>\n import('@hookform/devtools').then((res) => ({\n default: res.DevTool,\n })),\n);\n\ntype LazyDevToolProps = {\n isDevelopment?: boolean;\n props?: Omit<DevtoolUIProps, 'control'>;\n};\n\n/**\n * Lazy-loaded RHF DevTool.\n */\nconst LazyDevTool: React.FC<LazyDevToolProps> = ({ isDevelopment, props }) => {\n // early escape for non-dev builds\n if (!isDevelopment) return null;\n\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const { control } = useFormContext();\n\n return (\n <React.Suspense fallback={null}>\n <LazyRhfDevTool control={control} {...props} />\n </React.Suspense>\n );\n};\n\nexport default LazyDevTool;\n"],"names":["LazyRhfDevTool","React","res","LazyDevTool","isDevelopment","props","control","useFormContext","jsx"],"mappings":";;;AAIA,MAAMA,IAAiBC,EAAM;AAAA,EAAK,MAChC,OAAO,oBAAoB,EAAE,KAAK,CAACC,OAAS;AAAA,IAC1C,SAASA,EAAI;AAAA,EAAA,EACb;AACJ,GAUMC,IAA0C,CAAC,EAAE,eAAAC,GAAe,OAAAC,QAAY;AAExE,MAAA,CAACD,EAAsB,QAAA;AAGrB,QAAA,EAAE,SAAAE,MAAYC;AAGlB,SAAA,gBAAAC,EAACP,EAAM,UAAN,EAAe,UAAU,MACxB,UAAA,gBAAAO,EAACR,GAAe,EAAA,SAAAM,GAAmB,GAAGD,EAAO,CAAA,EAC/C,CAAA;AAEJ;"}
@@ -15,3 +15,4 @@ const o = ({ errors: e }) => {
15
15
  export {
16
16
  o as default
17
17
  };
18
+ //# sourceMappingURL=FlatFieldErrorsList.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FlatFieldErrorsList.mjs","sources":["../../../../src/errors/flat/FlatFieldErrorsList.tsx"],"sourcesContent":["import isEmptyObject from '@/utils/isEmptyObject';\n\nimport type { FlatFieldErrors } from './types';\n\nexport type Props = {\n errors: FlatFieldErrors | null | undefined;\n};\n\nconst FlatFieldErrorsList: React.FC<Props> = ({ errors }) => {\n if (!errors) return;\n if (isEmptyObject(errors)) return;\n\n return (\n <ul>\n {Object.values(errors).map((value, index) => (\n <li\n key={index}\n role=\"alert\"\n aria-live=\"polite\" // https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-live\n >\n {value.message}\n </li>\n ))}\n </ul>\n );\n};\n\nexport default FlatFieldErrorsList;\n"],"names":["FlatFieldErrorsList","errors","isEmptyObject","jsx","value","index"],"mappings":";;AAQA,MAAMA,IAAuC,CAAC,EAAE,QAAAC,QAAa;AAC3D,MAAKA,KACD,CAAAC,EAAcD,CAAM;AAGtB,WAAA,gBAAAE,EAAC,QACE,UAAO,OAAA,OAAOF,CAAM,EAAE,IAAI,CAACG,GAAOC,MACjC,gBAAAF;AAAA,MAAC;AAAA,MAAA;AAAA,QAEC,MAAK;AAAA,QACL,aAAU;AAAA,QAET,UAAMC,EAAA;AAAA,MAAA;AAAA,MAJFC;AAAA,IAMR,CAAA,EACH,CAAA;AAEJ;"}
@@ -25,3 +25,4 @@ const C = ({
25
25
  export {
26
26
  C as default
27
27
  };
28
+ //# sourceMappingURL=FlatFieldErrorsContextProvider.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FlatFieldErrorsContextProvider.mjs","sources":["../../../../../src/errors/flat/context/FlatFieldErrorsContextProvider.tsx"],"sourcesContent":["import React from 'react';\nimport { useFormState } from 'react-hook-form';\n\nimport getRefdFromFlatFieldErrors from '@/errors/getRefdFromFlatFieldErrors';\n\nimport isEmptyObject from '@/utils/isEmptyObject';\n\nimport getOrphansFromFlatFieldErrors from '../../orphan/getOrphansFromFlatFieldErrors';\nimport getRootsFromFlatFieldErrors from '../../root/getRootsFromFlatFieldErrors';\n\nimport getFlatFieldErrors from '../getFlatFieldErrors';\n\nimport { _FormErrorsFlatContextProvider } from './useFlatFieldErrorsContext';\n\ntype Props = React.PropsWithChildren<{\n formRef: React.RefObject<HTMLFormElement>;\n}>;\n\n/**\n * Provides a flattened version of the form errors.\n * Allows flattening and filtering to happen once per errors change.\n */\nconst FlatFieldErrorsContextProvider: React.FC<Props> = ({\n formRef,\n children,\n}) => {\n const { errors } = useFormState();\n\n const all = getFlatFieldErrors(errors);\n\n const orphans = formRef.current\n ? getOrphansFromFlatFieldErrors(all, formRef.current)\n : {};\n\n const value = {\n all,\n fields: getRefdFromFlatFieldErrors(all),\n roots: getRootsFromFlatFieldErrors(all),\n orphans,\n // computed\n hasErrors: !isEmptyObject(errors),\n hasOrphans: !isEmptyObject(orphans),\n };\n\n return (\n <_FormErrorsFlatContextProvider value={value}>\n {children}\n </_FormErrorsFlatContextProvider>\n );\n};\n\nexport default FlatFieldErrorsContextProvider;\n"],"names":["FlatFieldErrorsContextProvider","formRef","children","errors","useFormState","all","getFlatFieldErrors","orphans","getOrphansFromFlatFieldErrors","value","getRefdFromFlatFieldErrors","getRootsFromFlatFieldErrors","isEmptyObject","jsx","_FormErrorsFlatContextProvider"],"mappings":";;;;;;;;;AAsBA,MAAMA,IAAkD,CAAC;AAAA,EACvD,SAAAC;AAAA,EACA,UAAAC;AACF,MAAM;AACE,QAAA,EAAE,QAAAC,MAAWC,KAEbC,IAAMC,EAAmBH,CAAM,GAE/BI,IAAUN,EAAQ,UACpBO,EAA8BH,GAAKJ,EAAQ,OAAO,IAClD,IAEEQ,IAAQ;AAAA,IACZ,KAAAJ;AAAA,IACA,QAAQK,EAA2BL,CAAG;AAAA,IACtC,OAAOM,EAA4BN,CAAG;AAAA,IACtC,SAAAE;AAAA;AAAA,IAEA,WAAW,CAACK,EAAcT,CAAM;AAAA,IAChC,YAAY,CAACS,EAAcL,CAAO;AAAA,EAAA;AAIlC,SAAA,gBAAAM,EAACC,GAA+B,EAAA,OAAAL,GAC7B,UAAAP,EACH,CAAA;AAEJ;"}
@@ -7,3 +7,4 @@ export {
7
7
  o as _FormErrorsFlatContextProvider,
8
8
  s as default
9
9
  };
10
+ //# sourceMappingURL=useFlatFieldErrorsContext.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFlatFieldErrorsContext.mjs","sources":["../../../../../src/errors/flat/context/useFlatFieldErrorsContext.ts"],"sourcesContent":["import createContext from '@/utils/createContext';\n\nimport type { FlatFieldErrors } from '../types';\n\nexport type FlatFieldErrorsContext = {\n all: FlatFieldErrors;\n fields: FlatFieldErrors;\n roots: FlatFieldErrors;\n orphans: FlatFieldErrors;\n // computed\n hasErrors: boolean;\n hasOrphans: boolean;\n};\n\nconst {\n Provider: _FormErrorsFlatContextProvider,\n useRequired: useFlatFieldErrorsContext,\n} = createContext<FlatFieldErrorsContext>();\n\n//\n\nexport default useFlatFieldErrorsContext;\n\n//\n\nexport { _FormErrorsFlatContextProvider };\n"],"names":["_FormErrorsFlatContextProvider","useFlatFieldErrorsContext","createContext","useFlatFieldErrorsContext$1"],"mappings":";AAcM,MAAA;AAAA,EACJ,UAAUA;AAAA,EACV,aAAaC;AACf,IAAIC,EAAsC,GAI1CC,IAAeF;"}
@@ -7,3 +7,4 @@ const t = () => {
7
7
  export {
8
8
  l as default
9
9
  };
10
+ //# sourceMappingURL=useFlatFieldErrorsContextHasOnlyOrphans.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFlatFieldErrorsContextHasOnlyOrphans.mjs","sources":["../../../../../src/errors/flat/context/useFlatFieldErrorsContextHasOnlyOrphans.ts"],"sourcesContent":["import React from 'react';\n\nimport useFlatFieldErrorsContext from './useFlatFieldErrorsContext';\n\n/**\n * Returns `true` if all errors are orphans.\n *\n * You may want to treat this case specifically.\n */\nconst useFlatFieldErrorsContextHasOnlyOrphans = () => {\n const errors = useFlatFieldErrorsContext();\n\n const hasOnlyOrphans = React.useMemo(() => {\n // if empty or no orphans, early return\n if (!errors.hasErrors) return false;\n if (!errors.hasOrphans) return false;\n\n // if same count, then all errors are orphans\n return (\n Object.keys(errors.orphans).length === Object.keys(errors.all).length\n );\n }, [errors]);\n\n return hasOnlyOrphans;\n};\n\nexport default useFlatFieldErrorsContextHasOnlyOrphans;\n"],"names":["useFlatFieldErrorsContextHasOnlyOrphans","errors","useFlatFieldErrorsContext","React","useFlatFieldErrorsContextHasOnlyOrphans$1"],"mappings":";;AASA,MAAMA,IAA0C,MAAM;AACpD,QAAMC,IAASC;AAaR,SAXgBC,EAAM,QAAQ,MAE/B,CAACF,EAAO,aACR,CAACA,EAAO,aAAmB,KAI7B,OAAO,KAAKA,EAAO,OAAO,EAAE,WAAW,OAAO,KAAKA,EAAO,GAAG,EAAE,QAEhE,CAACA,CAAM,CAAC;AAGb,GAEAG,IAAeJ;"}
@@ -22,3 +22,4 @@ const C = (r) => {
22
22
  export {
23
23
  C as default
24
24
  };
25
+ //# sourceMappingURL=useFlatFieldErrorsContextOutput.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFlatFieldErrorsContextOutput.mjs","sources":["../../../../../src/errors/flat/context/useFlatFieldErrorsContextOutput.ts"],"sourcesContent":["import React from 'react';\nimport { useFormContext } from 'react-hook-form';\n\nimport consoleErrors from '../../output/consoleErrors';\n\nimport type { FlatFieldErrorsOutputConfig } from './FlatFieldErrorsOutputConfig';\nimport useFlatFieldErrorsContext from './useFlatFieldErrorsContext';\n\n/**\n * Outputs (e.g., console, throw) errors based on config.\n */\nconst useFlatFieldErrorsContextOutput = (\n config?: FlatFieldErrorsOutputConfig,\n) => {\n const form = useFormContext();\n\n const errors = useFlatFieldErrorsContext();\n\n // when errors change (memo-ized by provider)\n // output as configured\n React.useEffect(() => {\n // if no errors, don't do anything further\n if (!errors.hasErrors) return;\n\n // CONSOLE\n\n const console = config?.console?.(errors);\n\n if (console) {\n consoleErrors(\n console.message ?? defaultMessage,\n form.getValues(),\n errors,\n console.type,\n );\n }\n\n // THROW\n\n const _throw = config?.throw?.(errors);\n\n if (_throw)\n throw new Error(typeof _throw === 'string' ? _throw : defaultMessage);\n }, [errors]); // eslint-disable-line react-hooks/exhaustive-deps\n};\n\nexport default useFlatFieldErrorsContextOutput;\n\nconst defaultMessage = 'Form errors';\n"],"names":["useFlatFieldErrorsContextOutput","config","form","useFormContext","errors","useFlatFieldErrorsContext","React","console","_a","consoleErrors","defaultMessage","_throw","_b"],"mappings":";;;;AAWM,MAAAA,IAAkC,CACtCC,MACG;AACH,QAAMC,IAAOC,KAEPC,IAASC;AAIf,EAAAC,EAAM,UAAU,MAAM;;AAEhB,QAAA,CAACF,EAAO,UAAW;AAIjB,UAAAG,KAAUC,IAAAP,KAAA,gBAAAA,EAAQ,YAAR,gBAAAO,EAAA,KAAAP,GAAkBG;AAElC,IAAIG,KACFE;AAAA,MACEF,EAAQ,WAAWG;AAAA,MACnBR,EAAK,UAAU;AAAA,MACfE;AAAA,MACAG,EAAQ;AAAA,IAAA;AAMN,UAAAI,KAASC,IAAAX,KAAA,gBAAAA,EAAQ,UAAR,gBAAAW,EAAA,KAAAX,GAAgBG;AAE3B,QAAAO;AACF,YAAM,IAAI,MAAM,OAAOA,KAAW,WAAWA,IAASD,CAAc;AAAA,EAAA,GACrE,CAACN,CAAM,CAAC;AACb,GAIMM,IAAiB;"}
@@ -8,3 +8,4 @@ const r = (e) => (t) => (
8
8
  export {
9
9
  r as default
10
10
  };
11
+ //# sourceMappingURL=filterFlatFieldErrors.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filterFlatFieldErrors.mjs","sources":["../../../../src/errors/flat/filterFlatFieldErrors.ts"],"sourcesContent":["import type { FlatFieldErrorEntry, FlatFieldErrors } from './types';\n\n/**\n * Filter {@link FlatFieldErrors} by a predicate.\n *\n * (Encapsulates to and from Object entries.)\n */\nconst makeFlatFieldErrorsFilter =\n (predicate: (entry: FlatFieldErrorEntry, index: number) => boolean) =>\n (errors: FlatFieldErrors): FlatFieldErrors =>\n // re-create object from entries\n Object.fromEntries(\n // break down to entries\n Object.entries(errors)\n // filter by predicate\n .filter(predicate),\n );\n\nexport default makeFlatFieldErrorsFilter;\n"],"names":["makeFlatFieldErrorsFilter","predicate","errors"],"mappings":"AAOM,MAAAA,IACJ,CAACC,MACD,CAACC;AAAA;AAAA,EAEC,OAAO;AAAA;AAAA,IAEL,OAAO,QAAQA,CAAM,EAElB,OAAOD,CAAS;AAAA,EACrB;AAAA;"}
@@ -3,3 +3,4 @@ const o = (t) => r(t);
3
3
  export {
4
4
  o as default
5
5
  };
6
+ //# sourceMappingURL=flattenFieldErrors.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flattenFieldErrors.mjs","sources":["../../../../src/errors/flat/flattenFieldErrors.ts"],"sourcesContent":["import { flatten } from 'flat';\nimport type { FieldErrors } from 'react-hook-form';\n\n/**\n * Only flattens a {@link FieldErrors} object.\n * @returns e.g.,\n * ```\n * {\n * \"address.street.type\": \"too_short\",\n * \"address.street.ref.value\": \"123\",\n * \"address.street.message\": \"Required.\"\n * }\n * ```\n */\nconst flattenFieldErrors = (errors: FieldErrors) =>\n flatten<FieldErrors, Record<string, unknown>>(errors);\n\nexport default flattenFieldErrors;\n"],"names":["flattenFieldErrors","errors","flatten"],"mappings":";AAcA,MAAMA,IAAqB,CAACC,MAC1BC,EAA8CD,CAAM;"}
@@ -22,3 +22,4 @@ export {
22
22
  u as default,
23
23
  d as regexMaybeFieldErrorLeafNodeSuffix
24
24
  };
25
+ //# sourceMappingURL=getFlatFieldErrors.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getFlatFieldErrors.mjs","sources":["../../../../src/errors/flat/getFlatFieldErrors.ts"],"sourcesContent":["import type { FieldError, FieldErrors } from 'react-hook-form';\nimport { get } from 'react-hook-form';\n\nimport flattenFieldErrors from './flattenFieldErrors';\nimport type { FlatFieldErrors } from './types';\n\n/**\n * Get {@link FlatFieldErrors} from {@link FieldErrors}.\n * This makes it easy to work with potentially deeply-nested {@link FieldErrors}.\n *\n * @param errors {@link FieldErrors} object.\n *\n * @returns `FlatFieldErrors` object.\n *\n * @example\n * ```\n * {\n * \"address.street\": {\n * type: \"too_short\",\n * ref: { value: \"123\" },\n * message: \"Required.\" }\n * }\n * }\n * ```\n */\nconst getFlatFieldErrors = (errors: FieldErrors): FlatFieldErrors => {\n // flatten object for simpler processing\n const flattened = flattenFieldErrors(errors);\n\n // get flattened keys (e.g., `name.message`), which we must transform back to actual paths (e.g., `name`)\n const flattenedKeys = Object.keys(flattened);\n\n // rebuild FlatFieldErrors\n return Object.fromEntries(\n flattenedKeys.reduce<[PropertyKey, FieldError][]>(\n (entries, flattenedKey) => {\n // remove possible leaf node suffix from flattened key\n const path = flattenedKey.replace(\n regexMaybeFieldErrorLeafNodeSuffix,\n '',\n );\n\n // if nothing replaced, then it's not a leaf node; return early\n if (path === flattenedKey) return entries;\n\n // find field error in original FieldErrors object\n // has dual-purpose of confirming that each path is valid\n const fieldError = get(errors, path, undefined) as\n | FieldError\n | undefined;\n\n // if no field error found, then key was wrong; return early\n if (!fieldError) return entries;\n\n // add entry\n entries.push([path, fieldError]);\n\n // if dupe, doesn't matter -- i.e., `.type` leaf node matched before `.message`\n // Object.entries will overwrite dupe with same key/value\n\n return entries;\n },\n\n [], // entries\n ),\n );\n};\n\nexport default getFlatFieldErrors;\n\n//\n\n/**\n * Regular expression to maybe match the end of a leaf node path.\n *\n * i.e., `name.type`, `address.street.message`\n *\n * iow: dot [?: non-capturing](\"type\" | \"message\")[\\b word boundary][$ end of string]\n */\nexport const regexMaybeFieldErrorLeafNodeSuffix = /\\.(?:type|message)\\b$/;\n"],"names":["getFlatFieldErrors","errors","flattened","flattenFieldErrors","flattenedKeys","entries","flattenedKey","path","regexMaybeFieldErrorLeafNodeSuffix","fieldError","get"],"mappings":";;AAyBM,MAAAA,IAAqB,CAACC,MAAyC;AAE7D,QAAAC,IAAYC,EAAmBF,CAAM,GAGrCG,IAAgB,OAAO,KAAKF,CAAS;AAG3C,SAAO,OAAO;AAAA,IACZE,EAAc;AAAA,MACZ,CAACC,GAASC,MAAiB;AAEzB,cAAMC,IAAOD,EAAa;AAAA,UACxBE;AAAA,UACA;AAAA,QAAA;AAIE,YAAAD,MAASD,EAAqB,QAAAD;AAIlC,cAAMI,IAAaC,EAAIT,GAAQM,GAAM,MAAS;AAK1C,eAACE,KAGLJ,EAAQ,KAAK,CAACE,GAAME,CAAU,CAAC,GAKxBJ;AAAA,MACT;AAAA,MAEA,CAAC;AAAA;AAAA,IACH;AAAA,EAAA;AAEJ,GAaaG,IAAqC;"}
@@ -6,3 +6,4 @@ const l = r(
6
6
  export {
7
7
  l as default
8
8
  };
9
+ //# sourceMappingURL=getRefdFromFlatFieldErrors.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getRefdFromFlatFieldErrors.mjs","sources":["../../../src/errors/getRefdFromFlatFieldErrors.ts"],"sourcesContent":["import makeFlatFieldErrorsFilter from './flat/filterFlatFieldErrors';\nimport isFlatFieldErrorEntryRefd from './isFlatFieldErrorEntryRefd';\n\nconst getRefdFromFlatFieldErrors = makeFlatFieldErrorsFilter(\n isFlatFieldErrorEntryRefd,\n);\n\nexport default getRefdFromFlatFieldErrors;\n"],"names":["getRefdFromFlatFieldErrors","makeFlatFieldErrorsFilter","isFlatFieldErrorEntryRefd"],"mappings":";;AAGA,MAAMA,IAA6BC;AAAA,EACjCC;AACF;"}
@@ -2,3 +2,4 @@ const r = (e) => !!e.ref;
2
2
  export {
3
3
  r as default
4
4
  };
5
+ //# sourceMappingURL=isFieldErrorRefd.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isFieldErrorRefd.mjs","sources":["../../../src/errors/isFieldErrorRefd.ts"],"sourcesContent":["import type { FieldError } from 'react-hook-form';\n\n/**\n * Determine if {@link FieldError} is a `ref`'d field error.\n */\nconst isFieldErrorRefd = (error: FieldError): boolean => !!error.ref;\n\nexport default isFieldErrorRefd;\n"],"names":["isFieldErrorRefd","error"],"mappings":"AAKA,MAAMA,IAAmB,CAACC,MAA+B,CAAC,CAACA,EAAM;"}
@@ -3,3 +3,4 @@ const t = ([, r]) => e(r);
3
3
  export {
4
4
  t as default
5
5
  };
6
+ //# sourceMappingURL=isFlatFieldErrorEntryRefd.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isFlatFieldErrorEntryRefd.mjs","sources":["../../../src/errors/isFlatFieldErrorEntryRefd.ts"],"sourcesContent":["import type { FlatFieldErrorEntry } from './flat/types';\nimport isFieldErrorRefd from './isFieldErrorRefd';\n\n/**\n * Determine if {@link FieldError} is a `ref`'d field error.\n */\nconst isFlatFieldErrorEntryRefd = ([, error]: FlatFieldErrorEntry): boolean =>\n isFieldErrorRefd(error);\n\nexport default isFlatFieldErrorEntryRefd;\n"],"names":["isFlatFieldErrorEntryRefd","error","isFieldErrorRefd"],"mappings":";AAMA,MAAMA,IAA4B,CAAC,CAAA,EAAGC,CAAK,MACzCC,EAAiBD,CAAK;"}
@@ -12,3 +12,4 @@ const i = ({ message: r, className: e }) => /* @__PURE__ */ o(
12
12
  export {
13
13
  i as default
14
14
  };
15
+ //# sourceMappingURL=FormErrorMessage.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormErrorMessage.mjs","sources":["../../../../src/errors/message/FormErrorMessage.tsx"],"sourcesContent":["import React from 'react';\n\ntype Props = { message: string; className?: string };\n\nconst FormErrorMessage: React.FC<Props> = ({ message, className }) => (\n <p\n role=\"alert\"\n aria-live=\"polite\" // https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-live\n className={className}\n >\n {message}\n </p>\n);\n\nexport default FormErrorMessage;\n"],"names":["FormErrorMessage","message","className","jsx"],"mappings":";;AAIA,MAAMA,IAAoC,CAAC,EAAE,SAAAC,GAAS,WAAAC,EACpD,MAAA,gBAAAC;AAAA,EAAC;AAAA,EAAA;AAAA,IACC,MAAK;AAAA,IACL,aAAU;AAAA,IACV,WAAAD;AAAA,IAEC,UAAAD;AAAA,EAAA;AACH;"}
@@ -12,3 +12,4 @@ const f = ({ path: o, Component: s }) => {
12
12
  export {
13
13
  E as default
14
14
  };
15
+ //# sourceMappingURL=FormErrorMessageByPath.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormErrorMessageByPath.mjs","sources":["../../../../src/errors/message/FormErrorMessageByPath.tsx"],"sourcesContent":["import type { FieldError } from 'react-hook-form';\nimport { get, useFormState } from 'react-hook-form';\n\nimport FormNonFieldErrorMarker from '../nonfield/FormNonFieldErrorMarker';\n\nimport FormErrorMessage from './FormErrorMessage';\n\ntype Props = {\n /** Field name as flat path. (e.g., \"address.street\") */\n path: string;\n /** Optional component to use to display message. (Defaults to {@link FormErrorMessage}) */\n Component?: React.FC<{ message: string }>;\n};\n\nconst FormErrorMessageByPath: React.FC<Props> = ({ path, Component }) => {\n const { errors } = useFormState();\n\n const error = get(errors, path, undefined) as FieldError | undefined;\n\n const _Component = Component ?? FormErrorMessage;\n\n if (!error?.message) return null;\n\n return (\n <>\n {/* marker (only required for non-root non-field errors) */}\n <FormNonFieldErrorMarker path={path} />\n\n {/* error message */}\n <_Component message={error.message} />\n </>\n );\n};\n\nexport default FormErrorMessageByPath;\n"],"names":["FormErrorMessageByPath","path","Component","errors","useFormState","error","get","_Component","FormErrorMessage","jsxs","Fragment","jsx","FormNonFieldErrorMarker","FormErrorMessageByPath$1"],"mappings":";;;;AAcA,MAAMA,IAA0C,CAAC,EAAE,MAAAC,GAAM,WAAAC,QAAgB;AACjE,QAAA,EAAE,QAAAC,MAAWC,KAEbC,IAAQC,EAAIH,GAAQF,GAAM,MAAS,GAEnCM,IAAaL,KAAaM;AAE5B,SAACH,KAAA,QAAAA,EAAO,UAKR,gBAAAI,EAAAC,GAAA,EAAA,UAAA;AAAA,IAAA,gBAAAC,EAACC,KAAwB,MAAAX,GAAY;AAAA,IAGpC,gBAAAU,EAAAJ,GAAA,EAAW,SAASF,EAAM,QAAS,CAAA;AAAA,EACtC,EAAA,CAAA,IAT0B;AAW9B,GAEAQ,IAAeb;"}
@@ -17,3 +17,4 @@ const a = ({ path: r }) => {
17
17
  export {
18
18
  d as default
19
19
  };
20
+ //# sourceMappingURL=FormNonFieldErrorMarker.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormNonFieldErrorMarker.mjs","sources":["../../../../src/errors/nonfield/FormNonFieldErrorMarker.tsx"],"sourcesContent":["import FormNonFieldErrorMarkerHtmlAttribute from './FormNonFieldErrorMarkerHtmlAttribute';\n\ntype Props = {\n /** Flat field name. (e.g., `address.street`) */\n path: string;\n};\n\n/**\n * Empty, hidden marker to indicate a non-field/non-root error is being displayed to user.\n *\n * Example use case:\n * Field array with minimum items.\n * (When there are no items, the error is not associated with a field and is displayed separately.)\n */\nconst FormNonFieldErrorMarker: React.FC<Props> = ({ path }) => {\n const dataAttribute = {\n [FormNonFieldErrorMarkerHtmlAttribute]: path,\n };\n\n return (\n <div\n role=\"alert\"\n aria-hidden=\"true\" // hide from screen readers\n style={{ display: 'none' }} // hide from view/flow\n {...dataAttribute}\n />\n );\n};\n\nexport default FormNonFieldErrorMarker;\n"],"names":["FormNonFieldErrorMarker","path","dataAttribute","FormNonFieldErrorMarkerHtmlAttribute","jsx","FormNonFieldErrorMarker$1"],"mappings":";;AAcA,MAAMA,IAA2C,CAAC,EAAE,MAAAC,QAAW;AAC7D,QAAMC,IAAgB;AAAA,IACpB,CAACC,CAAoC,GAAGF;AAAA,EAAA;AAIxC,SAAA,gBAAAG;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,MAAK;AAAA,MACL,eAAY;AAAA,MACZ,OAAO,EAAE,SAAS,OAAO;AAAA,MACxB,GAAGF;AAAA,IAAA;AAAA,EAAA;AAGV,GAEAG,IAAeL;"}
@@ -21,3 +21,4 @@ const m = (r, e) => (
21
21
  export {
22
22
  m as getFormNonFieldErrorMarkerQuerySelector
23
23
  };
24
+ //# sourceMappingURL=FormNonFieldErrorMarker.utils.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormNonFieldErrorMarker.utils.mjs","sources":["../../../../src/errors/nonfield/FormNonFieldErrorMarker.utils.ts"],"sourcesContent":["import FormNonFieldErrorMarkerHtmlAttribute from './FormNonFieldErrorMarkerHtmlAttribute';\n\n/**\n * Returns query selector for matching non-field error marker.\n * By default includes nested field matching. (See `options.excludeNested`.)\n *\n * @returns One or more selectors in a comma-separated list.\n */\nexport const getFormNonFieldErrorMarkerQuerySelector = (\n path: string,\n options?: {\n /**\n * Do not look for match as nested field.\n *\n * By default this is enabled to facilitate looking for fields that may be nested inside objects.\n * This is only a problem when a front-end field is nested more deeply than back-end.\n * For example, field arrays require objects as items, so actual field may be `field.value`.\n * This should be safe, as fields are by definition leaf nodes, so will not have nested fields.\n * (If this check should need to be more precise in the future, it may be ideal to distinguish between client/server errors or paths.)\n */\n excludeNested?: boolean;\n },\n) => {\n return (\n // list of selector variants\n (\n [\n // equals\n // e.g., attr=\"path\"\n ['', ''],\n\n // starts with\n // e.g., attr^=\"path.\"\n ...(options?.excludeNested\n ? []\n : [\n [\n // @see https://developer.mozilla.org/en-US/docs/Web/CSS/Attribute_selectors#attrvalue_4\n '^',\n // only match nested (avoid match 'field' with 'field1`)\n '.',\n ],\n ]),\n ] as const\n )\n .map(([attrSuffix, pathSuffix]) =>\n _getQuerySelector(\n FormNonFieldErrorMarkerHtmlAttribute + attrSuffix,\n path + pathSuffix,\n ),\n )\n\n // construct list selector for O(n)\n .join(', ')\n );\n};\n\n// util\n\nconst _getQuerySelector = (attr: string, value: string) =>\n `[role=\"alert\"][${attr}=\"${value}\"]`;\n"],"names":["getFormNonFieldErrorMarkerQuerySelector","path","options","attrSuffix","pathSuffix","_getQuerySelector","FormNonFieldErrorMarkerHtmlAttribute","attr","value"],"mappings":";AAQa,MAAAA,IAA0C,CACrDC,GACAC;AAAA;AAAA,EAgBI;AAAA;AAAA;AAAA,IAGE,CAAC,IAAI,EAAE;AAAA,IAOD;AAAA;AAAA,MAEE;AAAA;AAAA,MAEA;AAAA,IACF;AAAA,EACF,EAGL;AAAA,IAAI,CAAC,CAACC,GAAYC,CAAU,MAC3BC;AAAA,MACEC,IAAuCH;AAAA,MACvCF,IAAOG;AAAA,IACT;AAAA,EAAA,EAID,KAAK,IAAI;AAAA,GAMVC,IAAoB,CAACE,GAAcC,MACvC,kBAAkBD,CAAI,KAAKC,CAAK;"}
@@ -2,3 +2,4 @@ const r = "data-paragrav-rhf-utils-nonfield-error-marker-path";
2
2
  export {
3
3
  r as default
4
4
  };
5
+ //# sourceMappingURL=FormNonFieldErrorMarkerHtmlAttribute.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormNonFieldErrorMarkerHtmlAttribute.mjs","sources":["../../../../src/errors/nonfield/FormNonFieldErrorMarkerHtmlAttribute.ts"],"sourcesContent":["/**\n * HTML data attribute for {@link FormNonFieldErrorMarker}.\n */\nconst FormNonFieldErrorMarkerHtmlAttribute =\n 'data-paragrav-rhf-utils-nonfield-error-marker-path';\n\nexport default FormNonFieldErrorMarkerHtmlAttribute;\n"],"names":["FormNonFieldErrorMarkerHtmlAttribute"],"mappings":"AAGA,MAAMA,IACJ;"}
@@ -3,3 +3,4 @@ const l = (r, e) => !!e.querySelector(o(r));
3
3
  export {
4
4
  l as default
5
5
  };
6
+ //# sourceMappingURL=isNonFieldErrorMarkerInDOM.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isNonFieldErrorMarkerInDOM.mjs","sources":["../../../../src/errors/nonfield/isNonFieldErrorMarkerInDOM.ts"],"sourcesContent":["import { getFormNonFieldErrorMarkerQuerySelector } from './FormNonFieldErrorMarker.utils';\n\n/**\n * Determine if a non-field error marker is in the DOM.\n * Note: this will also look for nested markers to accommodate field arrays\n */\nconst isNonFieldErrorMarkerInDOM = (\n path: string,\n parentElement: Pick<HTMLElement, 'querySelector'>,\n): boolean =>\n !!parentElement.querySelector(getFormNonFieldErrorMarkerQuerySelector(path));\n\nexport default isNonFieldErrorMarkerInDOM;\n"],"names":["isNonFieldErrorMarkerInDOM","path","parentElement","getFormNonFieldErrorMarkerQuerySelector"],"mappings":";AAMM,MAAAA,IAA6B,CACjCC,GACAC,MAEA,CAAC,CAACA,EAAc,cAAcC,EAAwCF,CAAI,CAAC;"}
@@ -3,3 +3,4 @@ const n = (r) => ([t, e]) => o(t, e, r);
3
3
  export {
4
4
  n as default
5
5
  };
6
+ //# sourceMappingURL=getIsOrphanFormErrorWithParentElement.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getIsOrphanFormErrorWithParentElement.mjs","sources":["../../../../src/errors/orphan/getIsOrphanFormErrorWithParentElement.ts"],"sourcesContent":["import type { FlatFieldErrorEntry } from '../flat/types';\n\nimport isOrphanFormError from './isOrphanFormError';\n\n/**\n * Util wrapper for {@link isOrphanFormError} for usage with {@link FlatFieldErrorEntry}.\n */\nconst getIsFlatFieldErrorEntryOrphanByParentElement =\n (parentElement: Pick<HTMLElement, 'querySelector'>) =>\n ([path, error]: FlatFieldErrorEntry) =>\n isOrphanFormError(path, error, parentElement);\n\nexport default getIsFlatFieldErrorEntryOrphanByParentElement;\n"],"names":["getIsFlatFieldErrorEntryOrphanByParentElement","parentElement","path","error","isOrphanFormError"],"mappings":";AAOM,MAAAA,IACJ,CAACC,MACD,CAAC,CAACC,GAAMC,CAAK,MACXC,EAAkBF,GAAMC,GAAOF,CAAa;"}
@@ -6,3 +6,4 @@ const F = (r, t) => e(
6
6
  export {
7
7
  F as default
8
8
  };
9
+ //# sourceMappingURL=getOrphansFromFlatFieldErrors.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getOrphansFromFlatFieldErrors.mjs","sources":["../../../../src/errors/orphan/getOrphansFromFlatFieldErrors.ts"],"sourcesContent":["import makeFlatFieldErrorsFilter from '../flat/filterFlatFieldErrors';\nimport type { FlatFieldErrors } from '../flat/types';\n\nimport getIsFlatFieldErrorEntryOrphanByParentElement from './getIsOrphanFormErrorWithParentElement';\n\nconst getOrphansFromFlatFieldErrors = (\n errors: FlatFieldErrors,\n parentElement: Pick<HTMLElement, 'querySelector'>,\n): FlatFieldErrors =>\n makeFlatFieldErrorsFilter(\n getIsFlatFieldErrorEntryOrphanByParentElement(parentElement),\n )(errors);\n\nexport default getOrphansFromFlatFieldErrors;\n"],"names":["getOrphansFromFlatFieldErrors","errors","parentElement","makeFlatFieldErrorsFilter","getIsFlatFieldErrorEntryOrphanByParentElement"],"mappings":";;AAKM,MAAAA,IAAgC,CACpCC,GACAC,MAEAC;AAAA,EACEC,EAA8CF,CAAa;AAC7D,EAAED,CAAM;"}
@@ -10,3 +10,4 @@ const d = (r, o, i) => (
10
10
  export {
11
11
  d as default
12
12
  };
13
+ //# sourceMappingURL=isOrphanFormError.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isOrphanFormError.mjs","sources":["../../../../src/errors/orphan/isOrphanFormError.ts"],"sourcesContent":["import type { FieldError } from 'react-hook-form';\n\nimport isFieldErrorRefd from '../isFieldErrorRefd';\nimport isNonFieldErrorMarkerInDOM from '../nonfield/isNonFieldErrorMarkerInDOM';\nimport isFormErrorPathRoot from '../root/isFormErrorPathRoot';\n\nconst isOrphanFormError = (\n path: string,\n error: FieldError,\n parentElement: Pick<HTMLElement, 'querySelector'>,\n) =>\n // not root path\n !isFormErrorPathRoot(path) &&\n // non-field\n !isFieldErrorRefd(error) &&\n // not marked in DOM\n !isNonFieldErrorMarkerInDOM(path, parentElement);\n\nexport default isOrphanFormError;\n"],"names":["isOrphanFormError","path","error","parentElement","isFormErrorPathRoot","isFieldErrorRefd","isNonFieldErrorMarkerInDOM"],"mappings":";;;AAMM,MAAAA,IAAoB,CACxBC,GACAC,GACAC;AAAA;AAAA,EAGA,CAACC,EAAoBH,CAAI;AAAA,EAEzB,CAACI,EAAiBH,CAAK;AAAA,EAEvB,CAACI,EAA2BL,GAAME,CAAa;AAAA;"}
@@ -4,3 +4,4 @@ const c = (o, e, s, r = "debug") => {
4
4
  export {
5
5
  c as default
6
6
  };
7
+ //# sourceMappingURL=consoleErrors.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"consoleErrors.mjs","sources":["../../../../src/errors/output/consoleErrors.ts"],"sourcesContent":["import type { SafeFieldValues } from '@/form/SafeFieldValues';\n\n/**\n * Output form values and errors to console.\n */\nconst consoleErrors = (\n message: string,\n values: SafeFieldValues,\n // accept any record -- e.g., FieldErrors or FlatFieldErrors\n errors: Record<string, unknown>,\n type: 'debug' | 'error' = 'debug',\n) => {\n // eslint-disable-next-line no-console -- deliberate logging\n console[type](message, { values, errors });\n};\n\nexport default consoleErrors;\n"],"names":["consoleErrors","message","values","errors","type"],"mappings":"AAKA,MAAMA,IAAgB,CACpBC,GACAC,GAEAC,GACAC,IAA0B,YACvB;AAEH,UAAQA,CAAI,EAAEH,GAAS,EAAE,QAAAC,GAAQ,QAAAC,GAAQ;AAC3C;"}
@@ -8,3 +8,4 @@ const e = () => {
8
8
  export {
9
9
  m as default
10
10
  };
11
+ //# sourceMappingURL=RootErrorsListFromFlatFieldErrorsContext.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RootErrorsListFromFlatFieldErrorsContext.mjs","sources":["../../../../src/errors/root/RootErrorsListFromFlatFieldErrorsContext.tsx"],"sourcesContent":["import useFlatFieldErrorsContext from '../flat/context/useFlatFieldErrorsContext';\nimport FlatFieldErrorsList from '../flat/FlatFieldErrorsList';\n\nconst RootErrorsListFromFlatFieldErrorsContext: React.FC = () => {\n const rootErrors = useFlatFieldErrorsContext().roots;\n\n return <FlatFieldErrorsList errors={rootErrors} />;\n};\n\nexport default RootErrorsListFromFlatFieldErrorsContext;\n"],"names":["RootErrorsListFromFlatFieldErrorsContext","rootErrors","useFlatFieldErrorsContext","jsx","FlatFieldErrorsList","RootErrorsListFromFlatFieldErrorsContext$1"],"mappings":";;;AAGA,MAAMA,IAAqD,MAAM;AACzD,QAAAC,IAAaC,EAA4B,EAAA;AAExC,SAAA,gBAAAC,EAACC,GAAoB,EAAA,QAAQH,EAAY,CAAA;AAClD,GAEAI,IAAeL;"}
@@ -2,3 +2,4 @@ const o = "root";
2
2
  export {
3
3
  o as FormErrorPathRoot
4
4
  };
5
+ //# sourceMappingURL=consts.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"consts.mjs","sources":["../../../../src/errors/root/consts.ts"],"sourcesContent":["export const FormErrorPathRoot = 'root';\n"],"names":["FormErrorPathRoot"],"mappings":"AAAO,MAAMA,IAAoB;"}
@@ -6,3 +6,4 @@ const l = r(
6
6
  export {
7
7
  l as default
8
8
  };
9
+ //# sourceMappingURL=getRootsFromFlatFieldErrors.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getRootsFromFlatFieldErrors.mjs","sources":["../../../../src/errors/root/getRootsFromFlatFieldErrors.ts"],"sourcesContent":["import makeFlatFieldErrorsFilter from '../flat/filterFlatFieldErrors';\n\nimport isFlatFieldErrorEntryPathRoot from './isFlatFieldErrorEntryPathRoot';\n\nconst getRootsFromFlatFieldErrors = makeFlatFieldErrorsFilter(\n isFlatFieldErrorEntryPathRoot,\n);\n\nexport default getRootsFromFlatFieldErrors;\n"],"names":["getRootsFromFlatFieldErrors","makeFlatFieldErrorsFilter","isFlatFieldErrorEntryPathRoot"],"mappings":";;AAIA,MAAMA,IAA8BC;AAAA,EAClCC;AACF;"}
@@ -3,3 +3,4 @@ const a = ([o]) => r(o);
3
3
  export {
4
4
  a as default
5
5
  };
6
+ //# sourceMappingURL=isFlatFieldErrorEntryPathRoot.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isFlatFieldErrorEntryPathRoot.mjs","sources":["../../../../src/errors/root/isFlatFieldErrorEntryPathRoot.ts"],"sourcesContent":["import type { FlatFieldErrorEntry } from '../flat/types';\n\nimport isFormErrorPathRoot from './isFormErrorPathRoot';\n\n/**\n * Util wrapper for {@link isFormErrorPathRoot} for usage with {@link FlatFieldErrorEntry}.\n */\nconst isFlatFieldErrorEntryPathRoot = ([path]: FlatFieldErrorEntry) =>\n isFormErrorPathRoot(path);\n\nexport default isFlatFieldErrorEntryPathRoot;\n"],"names":["isFlatFieldErrorEntryPathRoot","path","isFormErrorPathRoot"],"mappings":";AAOA,MAAMA,IAAgC,CAAC,CAACC,CAAI,MAC1CC,EAAoBD,CAAI;"}
@@ -3,3 +3,4 @@ const s = (o) => o === r || o.startsWith(r + ".");
3
3
  export {
4
4
  s as default
5
5
  };
6
+ //# sourceMappingURL=isFormErrorPathRoot.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isFormErrorPathRoot.mjs","sources":["../../../../src/errors/root/isFormErrorPathRoot.ts"],"sourcesContent":["import { FormErrorPathRoot } from './consts';\n\n/**\n * Determine if an error path is root. (e.g., `root` or `root.nested`)\n *\n * @param path Flat path. (e.g., 'root.nested')\n */\nconst isFormErrorPathRoot = (path: string): boolean =>\n path === FormErrorPathRoot || path.startsWith(FormErrorPathRoot + '.');\n\nexport default isFormErrorPathRoot;\n"],"names":["isFormErrorPathRoot","path","FormErrorPathRoot"],"mappings":";AAOM,MAAAA,IAAsB,CAACC,MAC3BA,MAASC,KAAqBD,EAAK,WAAWC,IAAoB,GAAG;"}
@@ -4,3 +4,4 @@ const o = (t) => (r) => r instanceof n ? e.parse(r) : t(r), a = o;
4
4
  export {
5
5
  a as default
6
6
  };
7
+ //# sourceMappingURL=getOnSubmitTrpcClientErrorHandler.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getOnSubmitTrpcClientErrorHandler.mjs","sources":["../../../../src/errors/trpc/getOnSubmitTrpcClientErrorHandler.ts"],"sourcesContent":["import { TRPCClientError } from '@trpc/client';\n\nimport type { RhfUtilsClientConfig } from '@/client/config/RhfUtilsClientConfig';\n\nimport type { FormSubmitErrors } from '@/submit/error/FormSubmitErrors';\n\nimport trpcClientErrorToFormSubmitErrorsSchemaTransformer from './trpcClientErrorToFormSubmitErrorsSchemaTransformer';\n\n/**\n * HOF that returns submit error handler for {@link RhfUtilsClientConfig.onSubmitErrorUnknown}.\n *\n * @param onError Fallback for handling non-TRPC errors.\n * @returns FormSubmitError\n */\nconst getOnSubmitTrpcClientErrorHandler =\n (\n onNotTrpcClientError: NonNullable<\n RhfUtilsClientConfig['onSubmitErrorUnknown']\n >,\n ) =>\n (error: unknown): FormSubmitErrors | undefined => {\n // transform\n if (error instanceof TRPCClientError)\n return trpcClientErrorToFormSubmitErrorsSchemaTransformer.parse(error);\n\n // if unknown error, use callback\n return onNotTrpcClientError(error);\n };\n\nexport default getOnSubmitTrpcClientErrorHandler;\n"],"names":["getOnSubmitTrpcClientErrorHandler","onNotTrpcClientError","error","TRPCClientError","trpcClientErrorToFormSubmitErrorsSchemaTransformer","getOnSubmitTrpcClientErrorHandler$1"],"mappings":";;AAcA,MAAMA,IACJ,CACEC,MAIF,CAACC,MAEKA,aAAiBC,IACZC,EAAmD,MAAMF,CAAK,IAGhED,EAAqBC,CAAK,GAGrCG,IAAeL;"}
@@ -8,3 +8,4 @@ const a = r.object({
8
8
  export {
9
9
  a as default
10
10
  };
11
+ //# sourceMappingURL=trpcClientErrorMessageSchema.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trpcClientErrorMessageSchema.mjs","sources":["../../../../src/errors/trpc/trpcClientErrorMessageSchema.ts"],"sourcesContent":["import { z } from 'zod';\n\n/**\n * Schema for {@link TRPCClientError} message.\n *\n * (Sent from backend as JSON string.)\n */\nconst trpcClientErrorMessageSchema = z.object({\n validation: z.string(),\n code: z.string(),\n message: z.string(),\n path: z.array(z.string()),\n});\n\nexport default trpcClientErrorMessageSchema;\n"],"names":["trpcClientErrorMessageSchema","z"],"mappings":";AAOM,MAAAA,IAA+BC,EAAE,OAAO;AAAA,EAC5C,YAAYA,EAAE,OAAO;AAAA,EACrB,MAAMA,EAAE,OAAO;AAAA,EACf,SAASA,EAAE,OAAO;AAAA,EAClB,MAAMA,EAAE,MAAMA,EAAE,QAAQ;AAC1B,CAAC;"}
@@ -32,3 +32,4 @@ const i = e.custom(
32
32
  export {
33
33
  i as default
34
34
  };
35
+ //# sourceMappingURL=trpcClientErrorToFormSubmitErrorsSchemaTransformer.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trpcClientErrorToFormSubmitErrorsSchemaTransformer.mjs","sources":["../../../../src/errors/trpc/trpcClientErrorToFormSubmitErrorsSchemaTransformer.ts"],"sourcesContent":["import type { TRPCClientErrorLike } from '@trpc/client';\nimport { TRPCClientError } from '@trpc/client';\nimport type { AnyRouter } from '@trpc/server';\nimport type { ErrorOption } from 'react-hook-form';\nimport { z } from 'zod';\n\nimport type { FormSubmitErrors } from '@/submit/error/FormSubmitErrors';\n\nimport trpcClientErrorMessageSchema from './trpcClientErrorMessageSchema';\n\n/**\n * Schema that transforms {@link TRPCClientError} to RHF {@link FormSubmitErrors}.\n */\nconst trpcClientErrorToFormSubmitErrorsSchemaTransformer = z\n .custom<TRPCClientErrorLike<AnyRouter>>(\n (error: unknown) => error instanceof TRPCClientError, // check instance type\n )\n\n // return: message (stringified json)\n .transform((error) => error.message)\n\n // return: parsed json as unknown\n .transform((json) => {\n try {\n return JSON.parse(json) as unknown;\n } catch (error) {\n // if not json, message is just string\n // build single item array for root\n // (must be in array for next step in transform)\n return [\n {\n validation: 'root',\n code: 'server',\n message: json,\n path: ['root'],\n },\n ] satisfies z.infer<typeof trpcClientErrorMessageSchema>[];\n }\n })\n\n // return: (trpc client error)[]\n .pipe(z.array(trpcClientErrorMessageSchema))\n\n // return: [path, ErrorOption][] (array of entries)\n .transform((errors) =>\n errors.map(\n (error) =>\n [\n error.path.join('.'), // flatten path (e.g., \"street.name\")\n {\n type: error.code,\n message: error.message,\n } satisfies ErrorOption,\n ] as const,\n ),\n )\n\n // return: FormSubmitErrors\n .transform((errors) => Object.fromEntries(errors) as FormSubmitErrors);\n\nexport default trpcClientErrorToFormSubmitErrorsSchemaTransformer;\n"],"names":["trpcClientErrorToFormSubmitErrorsSchemaTransformer","z","error","TRPCClientError","json","trpcClientErrorMessageSchema","errors"],"mappings":";;;AAaA,MAAMA,IAAqDC,EACxD;AAAA,EACC,CAACC,MAAmBA,aAAiBC;AAAA;AACvC,EAGC,UAAU,CAACD,MAAUA,EAAM,OAAO,EAGlC,UAAU,CAACE,MAAS;AACf,MAAA;AACK,WAAA,KAAK,MAAMA,CAAI;AAAA,UACR;AAIP,WAAA;AAAA,MACL;AAAA,QACE,YAAY;AAAA,QACZ,MAAM;AAAA,QACN,SAASA;AAAA,QACT,MAAM,CAAC,MAAM;AAAA,MACf;AAAA,IAAA;AAAA,EAEJ;AACF,CAAC,EAGA,KAAKH,EAAE,MAAMI,CAA4B,CAAC,EAG1C;AAAA,EAAU,CAACC,MACVA,EAAO;AAAA,IACL,CAACJ,MACC;AAAA,MACEA,EAAM,KAAK,KAAK,GAAG;AAAA;AAAA,MACnB;AAAA,QACE,MAAMA,EAAM;AAAA,QACZ,SAASA,EAAM;AAAA,MACjB;AAAA,IACF;AAAA,EACJ;AACF,EAGC,UAAU,CAACI,MAAW,OAAO,YAAYA,CAAM,CAAqB;"}
@@ -48,3 +48,4 @@ export {
48
48
  y as useRhfUtilsContextRequestSubmit,
49
49
  u as useRhfUtilsZodForm
50
50
  };
51
+ //# sourceMappingURL=exports.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exports.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -84,3 +84,4 @@ function A({
84
84
  export {
85
85
  A as default
86
86
  };
87
+ //# sourceMappingURL=Form.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Form.mjs","sources":["../../../src/form/Form.tsx"],"sourcesContent":["import React from 'react';\nimport type { UseFormHandleSubmit } from 'react-hook-form';\nimport { useFormContext } from 'react-hook-form';\n\nimport useRhfUtilsClientConfigMaybeContext from '@/client/config/useRhfUtilsClientConfigContext';\n\nimport LazyDevTool from '@/devtool/LazyDevTool';\n\nimport { FormSubmitError } from '@/submit/error/FormSubmitError';\nimport setCtxErrorsByFormSubmitErrors from '@/submit/error/setCtxErrorsByFormSubmitErrors';\n\nimport PassthroughChildren from '@/utils/PassthroughChildren';\n\nimport _Controller from './_Controller';\nimport type { SafeFieldValues } from './SafeFieldValues';\nimport type { UseRhfUtilsFormChildrenProps } from './UseRhfUtilsFormChildrenProps';\nimport type {\n UseRhfUtilsFormOnSubmitContext,\n UseRhfUtilsFormOnSubmitErrorContext,\n} from './UseRhfUtilsFormOnSubmitContext';\nimport type { UseRhfUtilsFormProps } from './UseRhfUtilsFormProps';\n\nexport type FormChildrenSlots = 'top' | 'bottom';\n\nexport type FormProps<\n TFieldValues extends SafeFieldValues,\n TTransformedValues extends SafeFieldValues,\n> = {\n formId: string;\n formRef: React.RefObject<HTMLFormElement>;\n} & Pick<\n UseRhfUtilsFormProps<TFieldValues, TTransformedValues>,\n | 'onSubmit'\n | 'onSubmitError'\n | 'onSubmitInvalid'\n //\n | 'Children'\n //\n | 'form'\n | 'utils'\n>;\n\nfunction _Form<\n TFieldValues extends SafeFieldValues,\n TTransformedValues extends SafeFieldValues,\n>({\n formId,\n formRef,\n //\n onSubmit,\n onSubmitError,\n onSubmitInvalid,\n Children,\n //\n form,\n utils,\n}: FormProps<TFieldValues, TTransformedValues>) {\n const rhfContext = useFormContext<\n TFieldValues,\n unknown,\n TTransformedValues\n >();\n\n const config = useRhfUtilsClientConfigMaybeContext();\n\n // handlers\n\n const handleSubmit = async (event: React.FormEvent<HTMLFormElement>) => {\n // cannot stop propagation in handleSubmitValid, b/c it receives a different event object\n if (utils?.stopSubmitPropagation) event.stopPropagation();\n\n try {\n await rhfContext.handleSubmit(handleSubmitValid, onSubmitInvalid)(event);\n } catch (error) {\n handleSubmitError(error, event);\n }\n };\n\n const handleSubmitValid = ((\n data: TTransformedValues,\n event?: React.BaseSyntheticEvent,\n ) => {\n return onSubmit?.(\n data,\n {\n formId,\n formRef,\n context: rhfContext,\n utils,\n FormSubmitError: FormSubmitError<TFieldValues>,\n } satisfies UseRhfUtilsFormOnSubmitContext<\n TFieldValues,\n TTransformedValues\n >,\n event as React.BaseSyntheticEvent<SubmitEvent>, // `as` required due to conditional generic\n );\n }) as Parameters<UseFormHandleSubmit<TFieldValues, TTransformedValues>>[0];\n\n const handleSubmitError = (\n error: unknown,\n event: React.BaseSyntheticEvent,\n ) => {\n // get `FormSubmitErrors`, if possible\n const formSubmitErrors =\n error instanceof FormSubmitError\n ? // consumer can manually throw FormSubmitError (e.g., manual validation)\n (error as FormSubmitError).errors // `as` to avoid `<any>`\n : // if error is not FormSubmitError, consumer can provide global handler\n config?.onSubmitErrorUnknown?.(error);\n\n if (formSubmitErrors)\n setCtxErrorsByFormSubmitErrors(rhfContext, formSubmitErrors);\n\n onSubmitError?.(\n error,\n {\n formId,\n formRef,\n context: rhfContext,\n utils,\n } satisfies UseRhfUtilsFormOnSubmitErrorContext<\n TFieldValues,\n TTransformedValues\n >,\n event as React.BaseSyntheticEvent<SubmitEvent>, // `as` required due to conditional generic\n );\n };\n\n const childrenProps: UseRhfUtilsFormChildrenProps<\n TFieldValues,\n TTransformedValues\n > = {\n formId,\n formRef,\n context: rhfContext,\n utils,\n Controller: _Controller<TFieldValues>,\n FormSubmitError: FormSubmitError<TFieldValues>,\n };\n\n const FormComponent = config?.FormComponent ?? 'form';\n\n const FormChildrenWrapper =\n config?.FormChildrenWrapper ?? PassthroughChildren;\n\n return (\n <FormComponent\n {...form}\n ref={formRef}\n onSubmit={(e) => void handleSubmit(e)}\n >\n <FormChildrenWrapper {...childrenProps}>\n {utils?.devTool && (\n <LazyDevTool\n props={\n typeof utils.devTool === 'object' ? utils.devTool : undefined\n }\n />\n )}\n\n <Children {...childrenProps} />\n </FormChildrenWrapper>\n </FormComponent>\n );\n}\n\nexport default _Form;\n"],"names":["_Form","formId","formRef","onSubmit","onSubmitError","onSubmitInvalid","Children","form","utils","rhfContext","useFormContext","config","useRhfUtilsClientConfigMaybeContext","handleSubmit","event","handleSubmitValid","error","handleSubmitError","data","FormSubmitError","formSubmitErrors","_a","setCtxErrorsByFormSubmitErrors","childrenProps","_Controller","FormComponent","FormChildrenWrapper","PassthroughChildren","jsx","e","jsxs","LazyDevTool"],"mappings":";;;;;;;;;AA0CA,SAASA,EAGP;AAAA,EACA,QAAAC;AAAA,EACA,SAAAC;AAAA;AAAA,EAEA,UAAAC;AAAA,EACA,eAAAC;AAAA,EACA,iBAAAC;AAAA,EACA,UAAAC;AAAA;AAAA,EAEA,MAAAC;AAAA,EACA,OAAAC;AACF,GAAgD;AAC9C,QAAMC,IAAaC,KAMbC,IAASC,KAITC,IAAe,OAAOC,MAA4C;AAElE,IAAAN,KAAA,QAAAA,EAAO,yBAAuBM,EAAM,gBAAgB;AAEpD,QAAA;AACF,YAAML,EAAW,aAAaM,GAAmBV,CAAe,EAAES,CAAK;AAAA,aAChEE,GAAO;AACd,MAAAC,EAAkBD,GAAOF,CAAK;AAAA,IAChC;AAAA,EAAA,GAGIC,IAAqB,CACzBG,GACAJ,MAEOX,KAAA,gBAAAA;AAAA,IACLe;AAAA,IACA;AAAA,MACE,QAAAjB;AAAA,MACA,SAAAC;AAAA,MACA,SAASO;AAAA,MACT,OAAAD;AAAA,MACA,iBAAAW;AAAA,IACF;AAAA,IAIAL;AAAA,KAIEG,IAAoB,CACxBD,GACAF,MACG;;AAEH,UAAMM,IACJJ,aAAiBG;AAAA;AAAA,MAEZH,EAA0B;AAAA;AAAA;AAAA,OAE3BK,IAAAV,KAAA,gBAAAA,EAAQ,yBAAR,gBAAAU,EAAA,KAAAV,GAA+BK;AAAA;AAEjC,IAAAI,KACFE,EAA+Bb,GAAYW,CAAgB,GAE7DhB,KAAA,QAAAA;AAAA,MACEY;AAAA,MACA;AAAA,QACE,QAAAf;AAAA,QACA,SAAAC;AAAA,QACA,SAASO;AAAA,QACT,OAAAD;AAAA,MACF;AAAA,MAIAM;AAAA;AAAA,EACF,GAGIS,IAGF;AAAA,IACF,QAAAtB;AAAA,IACA,SAAAC;AAAA,IACA,SAASO;AAAA,IACT,OAAAD;AAAA,IACA,YAAYgB;AAAA,IACZ,iBAAAL;AAAA,EAAA,GAGIM,KAAgBd,KAAA,gBAAAA,EAAQ,kBAAiB,QAEzCe,KACJf,KAAA,gBAAAA,EAAQ,wBAAuBgB;AAG/B,SAAA,gBAAAC;AAAA,IAACH;AAAA,IAAA;AAAA,MACE,GAAGlB;AAAA,MACJ,KAAKL;AAAA,MACL,UAAU,CAAC2B,MAAM,KAAKhB,EAAagB,CAAC;AAAA,MAEpC,UAAA,gBAAAC,EAACJ,GAAqB,EAAA,GAAGH,GACtB,UAAA;AAAA,SAAAf,KAAA,gBAAAA,EAAO,YACN,gBAAAoB;AAAA,UAACG;AAAA,UAAA;AAAA,YACC,OACE,OAAOvB,EAAM,WAAY,WAAWA,EAAM,UAAU;AAAA,UAAA;AAAA,QAExD;AAAA,QAGF,gBAAAoB,EAACtB,GAAU,EAAA,GAAGiB,GAAe;AAAA,MAAA,GAC/B;AAAA,IAAA;AAAA,EAAA;AAGN;"}
@@ -9,3 +9,4 @@ function n(m) {
9
9
  export {
10
10
  n as default
11
11
  };
12
+ //# sourceMappingURL=FormWithProviders.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormWithProviders.mjs","sources":["../../../src/form/FormWithProviders.tsx"],"sourcesContent":["import Form from './Form';\nimport RhfUtilsFormProviders from './RhfUtilsFormProviders';\nimport type { SafeFieldValues } from './SafeFieldValues';\nimport useRhfUtilsForm from './useRhfUtilsForm';\nimport type { UseRhfUtilsFormProps } from './UseRhfUtilsFormProps';\n\nexport type FormWithProvidersProps<\n TFieldValues extends SafeFieldValues,\n TTransformedValues extends SafeFieldValues,\n> = React.PropsWithChildren<\n UseRhfUtilsFormProps<TFieldValues, TTransformedValues>\n>;\n\n/**\n * Form providers (with utils) with immediate descendent {@link Form}.\n * (Syntactic sugar for {@link useRhfUtilsForm}. Use this for most applications.)\n *\n * Use {@link useRhfUtilsForm} if you need to specific nesting hierarchy.\n * (e.g., wrapping `<tr>` with provider and nesting `<form>` within `<td>` to appease HTML rules.)\n */\nfunction FormWithProviders<\n TFieldValues extends SafeFieldValues,\n TTransformedValues extends SafeFieldValues,\n>(props: FormWithProvidersProps<TFieldValues, TTransformedValues>) {\n const form = useRhfUtilsForm(props);\n\n return (\n <RhfUtilsFormProviders {...form.providerProps}>\n <Form {...form.formProps} />\n </RhfUtilsFormProviders>\n );\n}\n\nexport default FormWithProviders;\n"],"names":["FormWithProviders","props","form","useRhfUtilsForm","jsx","RhfUtilsFormProviders","Form"],"mappings":";;;;AAoBA,SAASA,EAGPC,GAAiE;AAC3D,QAAAC,IAAOC,EAAgBF,CAAK;AAGhC,SAAA,gBAAAG,EAACC,GAAuB,EAAA,GAAGH,EAAK,eAC9B,4BAACI,GAAM,EAAA,GAAGJ,EAAK,UAAW,CAAA,EAC5B,CAAA;AAEJ;"}
@@ -22,3 +22,4 @@ function v({
22
22
  export {
23
23
  v as default
24
24
  };
25
+ //# sourceMappingURL=RhfUtilsFormProviders.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RhfUtilsFormProviders.mjs","sources":["../../../src/form/RhfUtilsFormProviders.tsx"],"sourcesContent":["import type { UseFormReturn } from 'react-hook-form';\nimport { FormProvider } from 'react-hook-form';\n\nimport FlatFieldErrorsContextProvider from '@/errors/flat/context/FlatFieldErrorsContextProvider';\n\nimport RhfUtilsContextProvider from './context/utils/RhfUtilsContextProvider';\nimport type { RhfUtilsFormOptions } from './RhfUtilsFormOptions';\nimport type { SafeFieldValues } from './SafeFieldValues';\n\nexport type RhfUtilsFormProvidersProps<\n TFieldValues extends SafeFieldValues,\n TTransformedValues extends SafeFieldValues,\n> = React.PropsWithChildren<{\n formId: string;\n formRef: React.RefObject<HTMLFormElement>;\n rhfForm: UseFormReturn<TFieldValues, unknown, TTransformedValues>;\n utils?: RhfUtilsFormOptions;\n}>;\n\nfunction RhfUtilsFormProviders<\n TFieldValues extends SafeFieldValues,\n TTransformedValues extends SafeFieldValues,\n>({\n formId,\n formRef,\n rhfForm,\n utils,\n children,\n}: RhfUtilsFormProvidersProps<TFieldValues, TTransformedValues>) {\n return (\n <FormProvider {...rhfForm}>\n <FlatFieldErrorsContextProvider formRef={formRef}>\n <RhfUtilsContextProvider\n formId={formId}\n formRef={formRef}\n options={utils}\n >\n {children}\n </RhfUtilsContextProvider>\n </FlatFieldErrorsContextProvider>\n </FormProvider>\n );\n}\n\nexport default RhfUtilsFormProviders;\n"],"names":["RhfUtilsFormProviders","formId","formRef","rhfForm","utils","children","FormProvider","jsx","FlatFieldErrorsContextProvider","RhfUtilsContextProvider"],"mappings":";;;;AAmBA,SAASA,EAGP;AAAA,EACA,QAAAC;AAAA,EACA,SAAAC;AAAA,EACA,SAAAC;AAAA,EACA,OAAAC;AAAA,EACA,UAAAC;AACF,GAAiE;AAC/D,2BACGC,GAAc,EAAA,GAAGH,GAChB,UAAA,gBAAAI,EAACC,KAA+B,SAAAN,GAC9B,UAAA,gBAAAK;AAAA,IAACE;AAAA,IAAA;AAAA,MACC,QAAAR;AAAA,MACA,SAAAC;AAAA,MACA,SAASE;AAAA,MAER,UAAAC;AAAA,IAAA;AAAA,EAAA,EAEL,CAAA,EACF,CAAA;AAEJ;"}
@@ -6,3 +6,4 @@ function n(r) {
6
6
  export {
7
7
  n as default
8
8
  };
9
+ //# sourceMappingURL=_Controller.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_Controller.mjs","sources":["../../../src/form/_Controller.tsx"],"sourcesContent":["import type { ControllerProps, FieldPath } from 'react-hook-form';\nimport { Controller as RhfController } from 'react-hook-form';\n\nimport type { SafeFieldValues } from './SafeFieldValues';\n\nexport type _ControllerProps<\n TFieldValues extends SafeFieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n> = Omit<ControllerProps<TFieldValues, TName>, 'control'>;\n\nfunction _Controller<\n TFieldValues extends SafeFieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n>(props: _ControllerProps<TFieldValues, TName>) {\n return <RhfController {...props} />;\n}\n\nexport default _Controller;\n"],"names":["_Controller","props","jsx","RhfController"],"mappings":";;AAUA,SAASA,EAGPC,GAA8C;AACvC,SAAA,gBAAAC,EAACC,GAAe,EAAA,GAAGF,EAAO,CAAA;AACnC;"}
@@ -28,3 +28,4 @@ const B = ({ children: o }) => {
28
28
  export {
29
29
  h as default
30
30
  };
31
+ //# sourceMappingURL=FormGroupContextProvider.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormGroupContextProvider.mjs","sources":["../../../../../src/form/context/group/FormGroupContextProvider.tsx"],"sourcesContent":["import React from 'react';\n\nimport { _FormGroupContextProvider } from '.';\n\ntype Props = React.PropsWithChildren;\n\nconst FormGroupContextProvider: React.FC<Props> = ({ children }) => {\n // children\n\n const [childrenBusyIds, setChildrenBusyIds] = React.useState<string[]>([]);\n\n const childrenBusyCount = childrenBusyIds.length;\n\n const setChildrenBusyId = React.useCallback((id: string, isBusy: boolean) => {\n setChildrenBusyIds((prev) =>\n isBusy\n ? // add to array\n [...prev, id]\n : // remove from array\n prev.filter((formId) => formId !== id),\n );\n }, []);\n\n // parent\n\n const [isParentBusy, setIsParentBusy] = React.useState(false);\n\n // value\n\n const value = {\n children: {\n busyCount: childrenBusyCount,\n busyIds: childrenBusyIds,\n setBusyId: setChildrenBusyId,\n },\n parent: {\n isBusy: isParentBusy,\n setIsBusy: setIsParentBusy,\n },\n };\n\n return (\n <_FormGroupContextProvider value={value}>\n {children}\n </_FormGroupContextProvider>\n );\n};\n\nexport default FormGroupContextProvider;\n"],"names":["FormGroupContextProvider","children","childrenBusyIds","setChildrenBusyIds","React","childrenBusyCount","setChildrenBusyId","id","isBusy","prev","formId","isParentBusy","setIsParentBusy","jsx","_FormGroupContextProvider","FormGroupContextProvider$1"],"mappings":";;;AAMA,MAAMA,IAA4C,CAAC,EAAE,UAAAC,QAAe;AAGlE,QAAM,CAACC,GAAiBC,CAAkB,IAAIC,EAAM,SAAmB,CAAA,CAAE,GAEnEC,IAAoBH,EAAgB,QAEpCI,IAAoBF,EAAM,YAAY,CAACG,GAAYC,MAAoB;AAC3E,IAAAL;AAAA,MAAmB,CAACM,MAClBD;AAAA;AAAA,QAEI,CAAC,GAAGC,GAAMF,CAAE;AAAA;AAAA;AAAA,QAEZE,EAAK,OAAO,CAACC,MAAWA,MAAWH,CAAE;AAAA;AAAA,IAAA;AAAA,EAE7C,GAAG,CAAE,CAAA,GAIC,CAACI,GAAcC,CAAe,IAAIR,EAAM,SAAS,EAAK;AAiB1D,SAAA,gBAAAS,EAACC,GAA0B,EAAA,OAbf;AAAA,IACZ,UAAU;AAAA,MACR,WAAWT;AAAA,MACX,SAASH;AAAA,MACT,WAAWI;AAAA,IACb;AAAA,IACA,QAAQ;AAAA,MACN,QAAQK;AAAA,MACR,WAAWC;AAAA,IACb;AAAA,EAAA,GAKG,UAAAX,EACH,CAAA;AAEJ,GAEAc,IAAef;"}
@@ -9,3 +9,4 @@ export {
9
9
  t as _useFormGroupContext,
10
10
  u as _useFormGroupContextMaybe
11
11
  };
12
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sources":["../../../../../src/form/context/group/index.ts"],"sourcesContent":["import createContext from '@/utils/createContext';\n\nexport type FormGroupContext = {\n /** Dependent forms. */\n children: {\n busyIds: string[];\n busyCount: number;\n setBusyId: (id: string, isBusy: boolean) => void;\n };\n /** Main form. */\n parent: {\n isBusy: boolean;\n setIsBusy: (isBusy: boolean) => void;\n };\n};\n\nexport const {\n Provider: _FormGroupContextProvider,\n useRequired: _useFormGroupContext,\n useMaybe: _useFormGroupContextMaybe,\n} = createContext<FormGroupContext>();\n"],"names":["_FormGroupContextProvider","_useFormGroupContext","_useFormGroupContextMaybe","createContext"],"mappings":";AAgBa,MAAA;AAAA,EACX,UAAUA;AAAA,EACV,aAAaC;AAAA,EACb,UAAUC;AACZ,IAAIC,EAAgC;"}
@@ -4,3 +4,4 @@ const e = () => (r(!0), o()), t = e;
4
4
  export {
5
5
  t as default
6
6
  };
7
+ //# sourceMappingURL=useFormGroupChildIsMountedTracker.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFormGroupChildIsMountedTracker.mjs","sources":["../../../../../src/form/context/group/useFormGroupChildIsMountedTracker.ts"],"sourcesContent":["import useFormGroupChildTracker from './useFormGroupChildTracker';\nimport useFormGroupIsParentBusy from './useFormGroupIsParentBusy';\n\n/**\n * Mark \"child\" form as \"busy\" when mounted.\n */\nconst useFormGroupChildIsMountedTracker = () => {\n useFormGroupChildTracker(true);\n\n // return parent status\n return useFormGroupIsParentBusy();\n};\n\nexport default useFormGroupChildIsMountedTracker;\n"],"names":["useFormGroupChildIsMountedTracker","useFormGroupChildTracker","useFormGroupIsParentBusy","useFormGroupChildIsMountedTracker$1"],"mappings":";;AAMA,MAAMA,IAAoC,OACxCC,EAAyB,EAAI,GAGtBC,EAAyB,IAGlCC,IAAeH;"}
@@ -8,3 +8,4 @@ const m = () => {
8
8
  export {
9
9
  n as default
10
10
  };
11
+ //# sourceMappingURL=useFormGroupChildIsSubmittingTracker.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFormGroupChildIsSubmittingTracker.mjs","sources":["../../../../../src/form/context/group/useFormGroupChildIsSubmittingTracker.ts"],"sourcesContent":["import { useFormState } from 'react-hook-form';\n\nimport useFormGroupChildTracker from './useFormGroupChildTracker';\nimport useFormGroupIsParentBusy from './useFormGroupIsParentBusy';\n\n/**\n * Mark \"child\" form as \"busy\" when submitting.\n */\nconst useFormGroupChildIsSubmittingTracker = () => {\n const { isSubmitting } = useFormState();\n\n useFormGroupChildTracker(isSubmitting);\n\n // return parent status\n return useFormGroupIsParentBusy();\n};\n\nexport default useFormGroupChildIsSubmittingTracker;\n"],"names":["useFormGroupChildIsSubmittingTracker","isSubmitting","useFormState","useFormGroupChildTracker","useFormGroupIsParentBusy","useFormGroupChildIsSubmittingTracker$1"],"mappings":";;;AAQA,MAAMA,IAAuC,MAAM;AAC3C,QAAA,EAAE,cAAAC,MAAiBC;AAEzB,SAAAC,EAAyBF,CAAY,GAG9BG,EAAyB;AAClC,GAEAC,IAAeL;"}
@@ -11,3 +11,4 @@ const u = (s) => {
11
11
  export {
12
12
  d as default
13
13
  };
14
+ //# sourceMappingURL=useFormGroupChildTracker.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFormGroupChildTracker.mjs","sources":["../../../../../src/form/context/group/useFormGroupChildTracker.ts"],"sourcesContent":["import React from 'react';\n\nimport { _useFormGroupContext } from '.';\n\n/**\n * Mark \"child\" form as \"busy\" via arbitrary boolean.\n * Automatically marks as \"not busy\" on dismount.\n */\nconst useFormGroupChildTracker = (track: boolean) => {\n const { setBusyId } = _useFormGroupContext().children;\n\n // generate unique id to track this form instance\n const id = React.useId();\n\n // update context state based on isSubmitting\n React.useEffect(() => {\n setBusyId(id, track);\n }, [track, id, setBusyId]);\n\n // on dismount, set form as not busy\n // (e.g., form hides after successful submission; useEffect above will not re-run before unmount)\n React.useEffect(() => {\n return () => {\n setBusyId(id, false);\n };\n }, []); // eslint-disable-line react-hooks/exhaustive-deps\n};\n\nexport default useFormGroupChildTracker;\n"],"names":["useFormGroupChildTracker","track","setBusyId","_useFormGroupContext","id","React","useFormGroupChildTracker$1"],"mappings":";;AAQA,MAAMA,IAA2B,CAACC,MAAmB;AACnD,QAAM,EAAE,WAAAC,EAAA,IAAcC,EAAA,EAAuB,UAGvCC,IAAKC,EAAM;AAGjB,EAAAA,EAAM,UAAU,MAAM;AACpB,IAAAH,EAAUE,GAAIH,CAAK;AAAA,EAClB,GAAA,CAACA,GAAOG,GAAIF,CAAS,CAAC,GAIzBG,EAAM,UAAU,MACP,MAAM;AACX,IAAAH,EAAUE,GAAI,EAAK;AAAA,EAAA,GAEpB,CAAE,CAAA;AACP,GAEAE,IAAeN;"}
@@ -6,3 +6,4 @@ const r = () => {
6
6
  export {
7
7
  e as default
8
8
  };
9
+ //# sourceMappingURL=useFormGroupIsAnyBusy.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFormGroupIsAnyBusy.mjs","sources":["../../../../../src/form/context/group/useFormGroupIsAnyBusy.ts"],"sourcesContent":["import { _useFormGroupContextMaybe } from '.';\n\nconst useFormGroupIsAnyBusy = (): boolean => {\n const ctx = _useFormGroupContextMaybe();\n\n return !!ctx?.children.busyCount || !!ctx?.parent.isBusy;\n};\n\nexport default useFormGroupIsAnyBusy;\n"],"names":["useFormGroupIsAnyBusy","ctx","_useFormGroupContextMaybe","useFormGroupIsAnyBusy$1"],"mappings":";AAEA,MAAMA,IAAwB,MAAe;AAC3C,QAAMC,IAAMC;AAEL,SAAA,CAAC,EAACD,KAAA,QAAAA,EAAK,SAAS,cAAa,CAAC,EAACA,KAAA,QAAAA,EAAK,OAAO;AACpD,GAEAE,IAAeH;"}
@@ -6,3 +6,4 @@ const s = () => {
6
6
  export {
7
7
  e as default
8
8
  };
9
+ //# sourceMappingURL=useFormGroupIsChildBusy.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFormGroupIsChildBusy.mjs","sources":["../../../../../src/form/context/group/useFormGroupIsChildBusy.ts"],"sourcesContent":["import { _useFormGroupContextMaybe } from '.';\n\nconst useFormGroupIsChildBusy = (): boolean => {\n const ctx = _useFormGroupContextMaybe();\n\n return !!ctx?.children.busyCount;\n};\n\nexport default useFormGroupIsChildBusy;\n"],"names":["useFormGroupIsChildBusy","ctx","_useFormGroupContextMaybe","useFormGroupIsChildBusy$1"],"mappings":";AAEA,MAAMA,IAA0B,MAAe;AAC7C,QAAMC,IAAMC;AAEL,SAAA,CAAC,EAACD,KAAA,QAAAA,EAAK,SAAS;AACzB,GAEAE,IAAeH;"}
@@ -6,3 +6,4 @@ const s = () => {
6
6
  export {
7
7
  s as default
8
8
  };
9
+ //# sourceMappingURL=useFormGroupIsParentBusy.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFormGroupIsParentBusy.mjs","sources":["../../../../../src/form/context/group/useFormGroupIsParentBusy.ts"],"sourcesContent":["import { _useFormGroupContextMaybe } from '.';\n\nconst useFormGroupIsParentBusy = (): boolean => {\n const ctx = _useFormGroupContextMaybe();\n\n return !!ctx?.parent.isBusy;\n};\n\nexport default useFormGroupIsParentBusy;\n"],"names":["useFormGroupIsParentBusy","ctx","_useFormGroupContextMaybe"],"mappings":";AAEA,MAAMA,IAA2B,MAAe;AAC9C,QAAMC,IAAMC;AAEL,SAAA,CAAC,EAACD,KAAA,QAAAA,EAAK,OAAO;AACvB;"}
@@ -11,3 +11,4 @@ const m = () => {
11
11
  export {
12
12
  f as default
13
13
  };
14
+ //# sourceMappingURL=useFormGroupParentTracker.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFormGroupParentTracker.mjs","sources":["../../../../../src/form/context/group/useFormGroupParentTracker.ts"],"sourcesContent":["import React from 'react';\n\nimport useFormIsBusy from '@/form/useFormIsBusy';\n\nimport { _useFormGroupContext } from '.';\nimport useFormGroupIsChildBusy from './useFormGroupIsChildBusy';\n\n/**\n * Connect specific form state as parent context.\n *\n * Requires usage of provider.\n */\nconst useFormGroupParentTracker = () => {\n const isBusy = useFormIsBusy();\n\n const { setIsBusy } = _useFormGroupContext().parent;\n\n // when this form state changes, update context state\n React.useEffect(() => {\n setIsBusy(isBusy);\n }, [setIsBusy, isBusy]);\n\n // return children status\n return useFormGroupIsChildBusy();\n};\n\nexport default useFormGroupParentTracker;\n"],"names":["useFormGroupParentTracker","isBusy","useFormIsBusy","setIsBusy","_useFormGroupContext","React","useFormGroupIsChildBusy","useFormGroupParentTracker$1"],"mappings":";;;;AAYA,MAAMA,IAA4B,MAAM;AACtC,QAAMC,IAASC,KAET,EAAE,WAAAC,EAAA,IAAcC,EAAA,EAAuB;AAG7C,SAAAC,EAAM,UAAU,MAAM;AACpB,IAAAF,EAAUF,CAAM;AAAA,EAAA,GACf,CAACE,GAAWF,CAAM,CAAC,GAGfK,EAAwB;AACjC,GAEAC,IAAeP;"}
@@ -8,3 +8,4 @@ const u = () => {
8
8
  export {
9
9
  a as default
10
10
  };
11
+ //# sourceMappingURL=useFormOrParentIsBusy.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFormOrParentIsBusy.mjs","sources":["../../../../../src/form/context/group/useFormOrParentIsBusy.ts"],"sourcesContent":["import useFormIsBusy from '../../useFormIsBusy';\n\nimport { _useFormGroupContextMaybe } from '.';\n\nconst useFormOrParentIsBusy = (): boolean => {\n const isFormBusy = useFormIsBusy();\n const isParentBusy = _useFormGroupContextMaybe()?.parent.isBusy;\n\n return Boolean(isFormBusy || isParentBusy);\n};\n\nexport default useFormOrParentIsBusy;\n"],"names":["useFormOrParentIsBusy","isFormBusy","useFormIsBusy","isParentBusy","_a","_useFormGroupContextMaybe","useFormOrParentIsBusy$1"],"mappings":";;AAIA,MAAMA,IAAwB,MAAe;;AAC3C,QAAMC,IAAaC,KACbC,KAAeC,IAAAC,QAAA,gBAAAD,EAA6B,OAAO;AAElD,SAAA,GAAQH,KAAcE;AAC/B,GAEAG,IAAeN;"}
@@ -19,3 +19,4 @@ const n = ({
19
19
  export {
20
20
  n as default
21
21
  };
22
+ //# sourceMappingURL=RhfUtilsContextProvider.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RhfUtilsContextProvider.mjs","sources":["../../../../../src/form/context/utils/RhfUtilsContextProvider.tsx"],"sourcesContent":["import useRhfUtilsClientConfigMaybeContext from '@/client/config/useRhfUtilsClientConfigContext';\n\nimport useFlatFieldErrorsContextOutput from '@/errors/flat/context/useFlatFieldErrorsContextOutput';\n\nimport type { RhfUtilsFormOptions } from '@/form/RhfUtilsFormOptions';\n\nimport useResetFormOnSubmitted from '@/submit/useResetFormOnSubmitted';\nimport useSubmitFormOnChange from '@/submit/useSubmitFormOnChange';\n\nimport { _RhfUtilsContextProvider } from './useRhfUtilsContext';\n\ntype Props = React.PropsWithChildren<{\n formId: string;\n formRef: React.RefObject<HTMLFormElement>;\n options?: RhfUtilsFormOptions;\n}>;\n\nconst RhfUtilsContextProvider: React.FC<Props> = ({\n formId,\n formRef,\n options,\n children,\n}) => {\n const config = useRhfUtilsClientConfigMaybeContext();\n\n useFlatFieldErrorsContextOutput(config?.FieldErrors?.output);\n\n useSubmitFormOnChange(formRef, {\n disabled: !options?.submitOnChange,\n });\n\n useResetFormOnSubmitted(options?.resetOnSubmitted);\n\n return (\n <_RhfUtilsContextProvider value={{ formId, formRef, options }}>\n {children}\n </_RhfUtilsContextProvider>\n );\n};\n\nexport default RhfUtilsContextProvider;\n"],"names":["RhfUtilsContextProvider","formId","formRef","options","children","config","useRhfUtilsClientConfigMaybeContext","useFlatFieldErrorsContextOutput","_a","useSubmitFormOnChange","useResetFormOnSubmitted","jsx","_RhfUtilsContextProvider"],"mappings":";;;;;;AAiBA,MAAMA,IAA2C,CAAC;AAAA,EAChD,QAAAC;AAAA,EACA,SAAAC;AAAA,EACA,SAAAC;AAAA,EACA,UAAAC;AACF,MAAM;;AACJ,QAAMC,IAASC;AAEiB,SAAAC,GAAAC,IAAAH,KAAA,gBAAAA,EAAQ,gBAAR,gBAAAG,EAAqB,MAAM,GAE3DC,EAAsBP,GAAS;AAAA,IAC7B,UAAU,EAACC,KAAA,QAAAA,EAAS;AAAA,EAAA,CACrB,GAEDO,EAAwBP,KAAA,gBAAAA,EAAS,gBAAgB,GAG/C,gBAAAQ,EAACC,KAAyB,OAAO,EAAE,QAAAX,GAAQ,SAAAC,GAAS,SAAAC,EAAA,GACjD,UAAAC,EACH,CAAA;AAEJ;"}
@@ -4,3 +4,4 @@ export {
4
4
  r as _RhfUtilsContextProvider,
5
5
  i as default
6
6
  };
7
+ //# sourceMappingURL=useRhfUtilsContext.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useRhfUtilsContext.mjs","sources":["../../../../../src/form/context/utils/useRhfUtilsContext.tsx"],"sourcesContent":["import type { RhfUtilsFormOptions } from '@/form/RhfUtilsFormOptions';\n\nimport createContext from '@/utils/createContext';\n\nexport type RhfUtilsContext = {\n formId: string;\n formRef: React.RefObject<HTMLFormElement>;\n options: RhfUtilsFormOptions | undefined;\n};\n\nconst { Provider: _RhfUtilsContextProvider, useRequired: _useRhfUtilsContext } =\n createContext<RhfUtilsContext>();\n\n/**\n * Use utils from the current form context.\n */\nconst useRhfUtilsContext = _useRhfUtilsContext;\n\nexport default useRhfUtilsContext;\n\nexport { _RhfUtilsContextProvider };\n"],"names":["_RhfUtilsContextProvider","_useRhfUtilsContext","createContext","useRhfUtilsContext","useRhfUtilsContext$1"],"mappings":";AAUA,MAAM,EAAE,UAAUA,GAA0B,aAAaC,EAAA,IACvDC,EAA+B,GAK3BC,IAAqBF,GAE3BG,IAAeD;"}
@@ -7,3 +7,4 @@ const o = () => {
7
7
  export {
8
8
  m as default
9
9
  };
10
+ //# sourceMappingURL=useRhfUtilsContextRequestSubmit.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useRhfUtilsContextRequestSubmit.mjs","sources":["../../../../../src/form/context/utils/useRhfUtilsContextRequestSubmit.ts"],"sourcesContent":["import useFormRequestSubmit from '@/form/utils/useFormRequestSubmit';\n\nimport useRhfUtilsContext from './useRhfUtilsContext';\n\n/**\n * Get `requestSubmit` function from the form ref'd in current context.\n */\nconst useRhfUtilsContextRequestSubmit = () => {\n const utils = useRhfUtilsContext();\n\n return useFormRequestSubmit(utils.formRef);\n};\n\nexport default useRhfUtilsContextRequestSubmit;\n"],"names":["useRhfUtilsContextRequestSubmit","utils","useRhfUtilsContext","useFormRequestSubmit","useRhfUtilsContextRequestSubmit$1"],"mappings":";;AAOA,MAAMA,IAAkC,MAAM;AAC5C,QAAMC,IAAQC;AAEP,SAAAC,EAAqBF,EAAM,OAAO;AAC3C,GAEAG,IAAeJ;"}
@@ -6,3 +6,4 @@ const e = () => {
6
6
  export {
7
7
  e as default
8
8
  };
9
+ //# sourceMappingURL=useFormIsBusy.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFormIsBusy.mjs","sources":["../../../src/form/useFormIsBusy.ts"],"sourcesContent":["import { useFormState } from 'react-hook-form';\n\nconst useFormIsBusy = (): boolean => {\n const { isSubmitting, isLoading } = useFormState();\n\n return isSubmitting || isLoading;\n};\n\nexport default useFormIsBusy;\n"],"names":["useFormIsBusy","isSubmitting","isLoading","useFormState"],"mappings":";AAEA,MAAMA,IAAgB,MAAe;AACnC,QAAM,EAAE,cAAAC,GAAc,WAAAC,EAAU,IAAIC,EAAa;AAEjD,SAAOF,KAAgBC;AACzB;"}
@@ -41,3 +41,4 @@ const v = ({
41
41
  export {
42
42
  v as default
43
43
  };
44
+ //# sourceMappingURL=useRhfUtilsForm.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useRhfUtilsForm.mjs","sources":["../../../src/form/useRhfUtilsForm.tsx"],"sourcesContent":["import React from 'react';\nimport { useForm as useRhfForm } from 'react-hook-form';\n\nimport { FormSubmitError } from '@/submit/error/FormSubmitError';\n\nimport type { FormProps } from './Form';\nimport type { RhfUtilsFormProvidersProps } from './RhfUtilsFormProviders';\nimport type { SafeFieldValues } from './SafeFieldValues';\nimport type { UseRhfUtilsFormProps } from './UseRhfUtilsFormProps';\nimport type { UseRhfUtilsFormReturn } from './UseRhfUtilsFormReturn';\n\n/**\n * Core Rhf Form hook. Use `Form` in `index.ts` for most cases.\n * Use this if you need to separate form components.\n * e.g., a form for table row due to `form` being considered invalid HTML around `tr` tags.\n * With this hook, you can wrap the `tr` tag with `form.Provider` and use `form.Form` inside\n * one of the cells. Other components can be outside form while referring to form by its id via `form` attribute.\n * see https://caniuse.com/?search=form%20attribute\n * @returns Form provider and form.\n */\nconst useRhfUtilsForm = <\n TFieldValues extends SafeFieldValues,\n TTransformedValues extends SafeFieldValues,\n>({\n defaultValues,\n onSubmit,\n onSubmitError,\n onSubmitInvalid,\n Children,\n rhf,\n form,\n utils,\n}: UseRhfUtilsFormProps<\n TFieldValues,\n TTransformedValues\n>): UseRhfUtilsFormReturn<TFieldValues, TTransformedValues> => {\n const formId = React.useId();\n\n const rhfForm = useRhfForm<TFieldValues, unknown, TTransformedValues>({\n ...rhf,\n defaultValues,\n });\n\n const formRef = React.useRef<HTMLFormElement>(null);\n\n const providerProps: RhfUtilsFormProvidersProps<\n TFieldValues,\n TTransformedValues\n > = {\n formId,\n formRef,\n rhfForm,\n utils,\n };\n\n const formProps: FormProps<TFieldValues, TTransformedValues> = {\n Children,\n onSubmit,\n onSubmitError,\n onSubmitInvalid,\n formId,\n formRef,\n form,\n utils,\n };\n\n return {\n id: formId,\n ref: formRef,\n context: rhfForm,\n providerProps,\n formProps,\n FormSubmitError: FormSubmitError<TFieldValues>,\n } as const;\n};\n\nexport default useRhfUtilsForm;\n\nexport type UseRhfUtilsForm<\n TFieldValues extends SafeFieldValues,\n TTransformedValues extends SafeFieldValues,\n> = typeof useRhfUtilsForm<TFieldValues, TTransformedValues>;\n"],"names":["useRhfUtilsForm","defaultValues","onSubmit","onSubmitError","onSubmitInvalid","Children","rhf","form","utils","formId","React","rhfForm","useRhfForm","formRef","FormSubmitError"],"mappings":";;;AAoBA,MAAMA,IAAkB,CAGtB;AAAA,EACA,eAAAC;AAAA,EACA,UAAAC;AAAA,EACA,eAAAC;AAAA,EACA,iBAAAC;AAAA,EACA,UAAAC;AAAA,EACA,KAAAC;AAAA,EACA,MAAAC;AAAA,EACA,OAAAC;AACF,MAG+D;AACvD,QAAAC,IAASC,EAAM,SAEfC,IAAUC,EAAsD;AAAA,IACpE,GAAGN;AAAA,IACH,eAAAL;AAAA,EAAA,CACD,GAEKY,IAAUH,EAAM,OAAwB,IAAI;AAuB3C,SAAA;AAAA,IACL,IAAID;AAAA,IACJ,KAAKI;AAAA,IACL,SAASF;AAAA,IACT,eAtBE;AAAA,MACF,QAAAF;AAAA,MACA,SAAAI;AAAA,MACA,SAAAF;AAAA,MACA,OAAAH;AAAA,IAAA;AAAA,IAmBA,WAhB6D;AAAA,MAC7D,UAAAH;AAAA,MACA,UAAAH;AAAA,MACA,eAAAC;AAAA,MACA,iBAAAC;AAAA,MACA,QAAAK;AAAA,MACA,SAAAI;AAAA,MACA,MAAAN;AAAA,MACA,OAAAC;AAAA,IAAA;AAAA,IASA,iBAAAM;AAAA,EAAA;AAEJ;"}
@@ -10,3 +10,4 @@ const e = (t) => {
10
10
  export {
11
11
  i as default
12
12
  };
13
+ //# sourceMappingURL=getSubmitterButtonData.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getSubmitterButtonData.mjs","sources":["../../../../src/form/utils/getSubmitterButtonData.ts"],"sourcesContent":["import React from 'react';\n\n/**\n * Get [name, value] tuple of button/input that submitted form.\n * Useful when determining user intent\n */\nconst getSubmitterButtonData = (\n event: React.BaseSyntheticEvent,\n): [name: string, value: string] | undefined => {\n if (!(event.nativeEvent instanceof SubmitEvent)) return; // not submit\n if (\n !(event.nativeEvent.submitter instanceof HTMLButtonElement) && // not button\n !(event.nativeEvent.submitter instanceof HTMLInputElement) // not input\n )\n return;\n\n if (!event.nativeEvent.submitter.name) return; // no name on button\n\n return [\n event.nativeEvent.submitter.name,\n event.nativeEvent.submitter.value,\n ] as const;\n};\n\nexport default getSubmitterButtonData;\n"],"names":["getSubmitterButtonData","event","getSubmitterButtonData$1"],"mappings":";AAMA,MAAMA,IAAyB,CAC7BC,MAC8C;AAC1C,MAAEA,EAAM,uBAAuB,eAEjC,IAAEA,EAAM,YAAY,qBAAqB;AAAA,EACzC,EAAEA,EAAM,YAAY,qBAAqB,sBAItCA,EAAM,YAAY,UAAU;AAE1B,WAAA;AAAA,MACLA,EAAM,YAAY,UAAU;AAAA,MAC5BA,EAAM,YAAY,UAAU;AAAA,IAAA;AAEhC,GAEAC,IAAeF;"}
@@ -7,3 +7,4 @@ const u = (t) => (r) => {
7
7
  export {
8
8
  u as default
9
9
  };
10
+ //# sourceMappingURL=useFormRequestSubmit.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFormRequestSubmit.mjs","sources":["../../../../src/form/utils/useFormRequestSubmit.ts"],"sourcesContent":["/**\n * Get callback to trigger submit manually on form.\n * @link https://developer.mozilla.org/docs/Web/API/HTMLFormElement/requestSubmit\n */\nconst useFormRequestSubmit =\n (\n ref: React.RefObject<HTMLFormElement>, // limit scope to avoid mistakes (allows for `{[string]: any}`)\n ): HTMLFormElement['requestSubmit'] =>\n (submitter) => {\n // typeguard (should never happen at runtime when callback is called)\n if (!ref.current) throw new Error();\n\n requestSubmitByForm(ref.current, submitter);\n };\n\nexport default useFormRequestSubmit;\n\n//\n\nconst requestSubmitByForm = (\n form: Pick<HTMLFormElement, 'requestSubmit'>, // narrow to avoid `{[string]: any}` type\n submitter?: HTMLElement | null,\n) => {\n form.requestSubmit(submitter);\n};\n"],"names":["useFormRequestSubmit","ref","submitter","requestSubmitByForm","form"],"mappings":"AAIA,MAAMA,IACJ,CACEC,MAEF,CAACC,MAAc;AAEb,MAAI,CAACD,EAAI,QAAS,OAAM,IAAI,MAAM;AAEd,EAAAE,EAAAF,EAAI,SAASC,CAAS;AAC5C,GAMIC,IAAsB,CAC1BC,GACAF,MACG;AACH,EAAAE,EAAK,cAAcF,CAAS;AAC9B;"}
@@ -6,3 +6,4 @@ class t extends Error {
6
6
  export {
7
7
  t as FormSubmitError
8
8
  };
9
+ //# sourceMappingURL=FormSubmitError.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormSubmitError.mjs","sources":["../../../../src/submit/error/FormSubmitError.ts"],"sourcesContent":["import type { SafeFieldValues } from '@/form/SafeFieldValues';\n\nimport type { FormSubmitErrors } from './FormSubmitErrors';\n\nexport class FormSubmitError<\n TFieldValues extends SafeFieldValues = SafeFieldValues,\n> extends Error {\n constructor(\n public errors: FormSubmitErrors<TFieldValues>,\n message?: string, // error message\n // options?: ErrorOptions, // requires es2022\n ) {\n super(message);\n }\n}\n"],"names":["FormSubmitError","errors","message"],"mappings":"AAIO,MAAMA,UAEH,MAAM;AAAA,EACd,YACSC,GACPC,GAEA;AACA,UAAMA,CAAO,GAJN,KAAA,SAAAD;AAAA,EAKT;AACF;"}
@@ -10,3 +10,4 @@ const s = (r, t) => {
10
10
  export {
11
11
  s as default
12
12
  };
13
+ //# sourceMappingURL=setCtxErrorsByFormSubmitErrors.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setCtxErrorsByFormSubmitErrors.mjs","sources":["../../../../src/submit/error/setCtxErrorsByFormSubmitErrors.ts"],"sourcesContent":["import type { FieldPath, UseFormReturn } from 'react-hook-form';\n\nimport type { SafeFieldValues } from '@/form/SafeFieldValues';\n\nimport type { FormSubmitErrors } from './FormSubmitErrors';\n\n/**\n * Handle thrown {@link FormSubmitError}.\n * Add key/values as name/message to RHF context errors.\n */\nconst setCtxErrorsByFormSubmitErrors = <\n TFieldValues extends SafeFieldValues,\n TTransformedValues extends SafeFieldValues,\n>(\n ctx: UseFormReturn<TFieldValues, unknown, TTransformedValues>,\n errors: FormSubmitErrors,\n) => {\n // loop through error object and set errors in rhf context\n Object.entries(errors).forEach(([name, fieldError]) => {\n ctx.setError(name as FieldPath<TFieldValues>, {\n type: 'FormSubmitError', // default\n ...fieldError,\n });\n });\n};\n\nexport default setCtxErrorsByFormSubmitErrors;\n"],"names":["setCtxErrorsByFormSubmitErrors","ctx","errors","name","fieldError"],"mappings":"AAUM,MAAAA,IAAiC,CAIrCC,GACAC,MACG;AAEI,SAAA,QAAQA,CAAM,EAAE,QAAQ,CAAC,CAACC,GAAMC,CAAU,MAAM;AACrD,IAAAH,EAAI,SAASE,GAAiC;AAAA,MAC5C,MAAM;AAAA;AAAA,MACN,GAAGC;AAAA,IAAA,CACJ;AAAA,EAAA,CACF;AACH;"}
@@ -10,3 +10,4 @@ const c = (e, f) => {
10
10
  export {
11
11
  c as default
12
12
  };
13
+ //# sourceMappingURL=useFormOnSubmitted.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFormOnSubmitted.mjs","sources":["../../../src/submit/useFormOnSubmitted.ts"],"sourcesContent":["import type { MaybePromise } from '@trpc/server/unstable-core-do-not-import';\nimport React from 'react';\nimport { useFormState } from 'react-hook-form';\n\nimport useRefIfValueWasTrue from '@/utils/useRefIfValueWasTrue';\n\nconst useFormOnSubmitted = (\n callback?: (success: boolean) => MaybePromise<unknown>,\n options?: { successful?: boolean },\n) => {\n const { isSubmitSuccessful, isSubmitting } = useFormState();\n\n const [wasSubmitting, resetWasSubmitting] =\n useRefIfValueWasTrue(isSubmitting);\n\n // on successful submit, call callback\n React.useEffect(() => {\n if (!callback) return;\n\n // if currently submitting, ignore\n if (isSubmitting) return;\n\n // wait for submit to finish\n if (!wasSubmitting) return;\n\n // always reset to wait for next submit\n resetWasSubmitting();\n\n // check success against options passed\n if (\n options?.successful === undefined || // if option not specified, call on any submit\n isSubmitSuccessful === options.successful // otherwise, call only if matches\n ) {\n callback(isSubmitSuccessful);\n }\n\n // eslint-disable-next-line react-hooks/exhaustive-deps -- only track isSubmitting -- so success is checked each time\n }, [isSubmitting]);\n};\n\nexport default useFormOnSubmitted;\n"],"names":["useFormOnSubmitted","callback","options","isSubmitSuccessful","isSubmitting","useFormState","wasSubmitting","resetWasSubmitting","useRefIfValueWasTrue","React"],"mappings":";;;AAMM,MAAAA,IAAqB,CACzBC,GACAC,MACG;AACH,QAAM,EAAE,oBAAAC,GAAoB,cAAAC,EAAa,IAAIC,EAAa,GAEpD,CAACC,GAAeC,CAAkB,IACtCC,EAAqBJ,CAAY;AAGnC,EAAAK,EAAM,UAAU,MAAM;AACpB,IAAKR,MAGDG,KAGCE,MAGcC,KAOjBN,EAASE,CAAkB;AAAA,EAC7B,GAGC,CAACC,CAAY,CAAC;AACnB;"}
@@ -34,3 +34,4 @@ const p = (e) => {
34
34
  export {
35
35
  p as default
36
36
  };
37
+ //# sourceMappingURL=useResetFormOnSubmitted.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useResetFormOnSubmitted.mjs","sources":["../../../src/submit/useResetFormOnSubmitted.ts"],"sourcesContent":["import { useFormContext } from 'react-hook-form';\n\nimport useFormOnSubmitted from './useFormOnSubmitted';\n\n/**\n * Configuration options for {@link useResetFormOnSubmitted}.\n */\nexport type UseResetFormOnSubmittedOptions =\n // disabled\n | undefined\n\n // enabled\n | {\n /**\n * Reset values on successful submit.\n * - `defaults`: reset current values to defaults\n * - `current`: reset defaults to current values\n */\n success?: { values: 'defaults' | 'current' };\n\n /**\n * Reset values to defaults on submit error.\n */\n error?: { values: 'defaults' };\n };\n\n/**\n * Control resetting of values and (some) state (e.g., `isDirty`) after form submitted.\n *\n * `isDirty` and other state is reset, but submit-related state is preserved, as well as errors.\n *\n * Use cases:\n * - on success:\n * - `defaults`: reset current values to defaults (e.g., clear form)\n * - `current`: reset defaults to current values (e.g., keep values)\n * - on error:\n * - reset current values to default values (e.g., submitOnChange reset)\n *\n * See `Rules` section: https://react-hook-form.com/api/useform/reset/\n * Specifically: \"- It's recommended to reset inside useEffect after submission.\"\n */\nconst useResetFormOnSubmitted = (options: UseResetFormOnSubmittedOptions) => {\n const { getValues, reset } = useFormContext();\n\n useFormOnSubmitted((success) => {\n if (!options) return;\n\n const whichValues = options[success ? 'success' : 'error']?.values;\n\n if (!whichValues) return;\n\n const keepValues = whichValues === 'current';\n\n const values = keepValues\n ? getValues() // current values\n : undefined; // default values\n\n reset(values, {\n // keep submit stuff for tracking relevant state (e.g., `useFormOnSubmitSuccessful`)\n keepIsSubmitSuccessful: true,\n keepIsSubmitted: true,\n keepSubmitCount: true,\n\n /**\n * This is necessary when setting default values to current values (lest form stop updating).\n *\n * Technically, we are keeping values and resetting default values to same values.\n *\n * Steps to repro:\n * - RhfUtilsClientConfig with resetOnSubmitted set to success values to current\n * - remove `keepValues` prop from reset\n * - create valid form, submit\n * - form values should be unchanged\n * - unexpectedly: can no longer type into input\n */\n keepValues,\n\n // keep errors in the case of unsuccessful submit\n keepErrors: true,\n });\n });\n};\n\nexport default useResetFormOnSubmitted;\n"],"names":["useResetFormOnSubmitted","options","getValues","reset","useFormContext","useFormOnSubmitted","success","whichValues","_a","keepValues","values"],"mappings":";;AAyCM,MAAAA,IAA0B,CAACC,MAA4C;AAC3E,QAAM,EAAE,WAAAC,GAAW,OAAAC,EAAM,IAAIC,EAAe;AAE5C,EAAAC,EAAmB,CAACC,MAAY;;AAC9B,QAAI,CAACL,EAAS;AAEd,UAAMM,KAAcC,IAAAP,EAAQK,IAAU,YAAY,OAAO,MAArC,gBAAAE,EAAwC;AAE5D,QAAI,CAACD,EAAa;AAElB,UAAME,IAAaF,MAAgB,WAE7BG,IAASD,IACXP,EACA,IAAA;AAEJ,IAAAC,EAAMO,GAAQ;AAAA;AAAA,MAEZ,wBAAwB;AAAA,MACxB,iBAAiB;AAAA,MACjB,iBAAiB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAcjB,YAAAD;AAAA;AAAA,MAGA,YAAY;AAAA,IAAA,CACb;AAAA,EAAA,CACF;AACH;"}
@@ -17,3 +17,4 @@ const d = (t, e) => {
17
17
  export {
18
18
  d as default
19
19
  };
20
+ //# sourceMappingURL=useSubmitFormOnChange.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSubmitFormOnChange.mjs","sources":["../../../src/submit/useSubmitFormOnChange.ts"],"sourcesContent":["import React from 'react';\n\nimport useFormRequestSubmit from '@/form/utils/useFormRequestSubmit';\n\nconst useSubmitFormOnChange = (\n formRef: React.RefObject<HTMLFormElement>,\n options?: {\n /** Disable-able so that default behavior is enabled for sake of simplicity of usage. */\n disabled?: boolean;\n },\n) => {\n const enabled = !options?.disabled;\n\n const requestSubmit = useFormRequestSubmit(formRef);\n\n // on mount, listen for event\n React.useEffect(() => {\n if (!enabled) return;\n\n const form = formRef.current;\n\n if (!form) throw new Error();\n\n const onChange = () => {\n requestSubmit();\n };\n\n form.addEventListener('change', onChange);\n\n return () => {\n form.removeEventListener('change', onChange);\n };\n }, []); // eslint-disable-line react-hooks/exhaustive-deps -- on mount\n};\n\nexport default useSubmitFormOnChange;\n"],"names":["useSubmitFormOnChange","formRef","options","enabled","requestSubmit","useFormRequestSubmit","React","form","onChange"],"mappings":";;AAIM,MAAAA,IAAwB,CAC5BC,GACAC,MAIG;AACG,QAAAC,IAAU,EAACD,KAAA,QAAAA,EAAS,WAEpBE,IAAgBC,EAAqBJ,CAAO;AAGlD,EAAAK,EAAM,UAAU,MAAM;AACpB,QAAI,CAACH,EAAS;AAEd,UAAMI,IAAON,EAAQ;AAErB,QAAI,CAACM,EAAY,OAAA,IAAI;AAErB,UAAMC,IAAW,MAAM;AACP,MAAAJ;IAAA;AAGX,WAAAG,EAAA,iBAAiB,UAAUC,CAAQ,GAEjC,MAAM;AACN,MAAAD,EAAA,oBAAoB,UAAUC,CAAQ;AAAA,IAAA;AAAA,EAE/C,GAAG,CAAE,CAAA;AACP;"}
@@ -5,3 +5,4 @@ const a = ({
5
5
  export {
6
6
  a as default
7
7
  };
8
+ //# sourceMappingURL=PassthroughChildren.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PassthroughChildren.mjs","sources":["../../../src/utils/PassthroughChildren.tsx"],"sourcesContent":["/**\n * Component for simply passing through children.\n *\n * (Useful for conditional wrapping of children.)\n */\nconst PassthroughChildren: React.FC<React.PropsWithChildren> = ({\n children,\n}) => <>{children}</>;\n\nexport default PassthroughChildren;\n"],"names":["PassthroughChildren","children"],"mappings":";AAKA,MAAMA,IAAyD,CAAC;AAAA,EAC9D,UAAAC;AACF,6BAAS,UAAAA,EAAS,CAAA;"}
@@ -14,3 +14,4 @@ function i() {
14
14
  export {
15
15
  i as default
16
16
  };
17
+ //# sourceMappingURL=createContext.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createContext.mjs","sources":["../../../src/utils/createContext.ts"],"sourcesContent":["import React from 'react';\n\n/**\n * Create a strictly-typed context that throws error if no provider is found.\n * @returns A tuple with a function to get the context and the context provider.\n */\nfunction createContext<T = unknown>() {\n const context = React.createContext<T | undefined>(undefined);\n\n const useMaybe = () => React.useContext(context);\n\n const useRequired = () => {\n const c = useMaybe();\n\n // type guard\n if (c === undefined) throw new Error();\n\n return c;\n };\n\n return {\n Provider: context.Provider,\n useMaybe,\n useRequired,\n } as const;\n}\n\nexport default createContext;\n"],"names":["createContext","context","React","useMaybe","useRequired","c"],"mappings":";AAMA,SAASA,IAA6B;AAC9B,QAAAC,IAAUC,EAAM,cAA6B,MAAS,GAEtDC,IAAW,MAAMD,EAAM,WAAWD,CAAO,GAEzCG,IAAc,MAAM;AACxB,UAAMC,IAAIF;AAGV,QAAIE,MAAM,OAAiB,OAAA,IAAI,MAAM;AAE9B,WAAAA;AAAA,EAAA;AAGF,SAAA;AAAA,IACL,UAAUJ,EAAQ;AAAA,IAClB,UAAAE;AAAA,IACA,aAAAC;AAAA,EAAA;AAEJ;"}
@@ -2,3 +2,4 @@ const e = (t) => Object.keys(t).length === 0;
2
2
  export {
3
3
  e as default
4
4
  };
5
+ //# sourceMappingURL=isEmptyObject.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isEmptyObject.mjs","sources":["../../../src/utils/isEmptyObject.ts"],"sourcesContent":["const isEmptyObject = (obj: Record<string, unknown>) =>\n Object.keys(obj).length === 0;\n\nexport default isEmptyObject;\n"],"names":["isEmptyObject","obj"],"mappings":"AAAA,MAAMA,IAAgB,CAACC,MACrB,OAAO,KAAKA,CAAG,EAAE,WAAW;"}
@@ -12,3 +12,4 @@ const f = (r) => {
12
12
  export {
13
13
  f as default
14
14
  };
15
+ //# sourceMappingURL=useRefIfValueWasTrue.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useRefIfValueWasTrue.mjs","sources":["../../../src/utils/useRefIfValueWasTrue.ts"],"sourcesContent":["import React from 'react';\n\nconst useRefIfValueWasTrue = (value: boolean) => {\n const hasBooleanChanged = React.useRef(false);\n\n // when value is true, set ref to true\n React.useEffect(() => {\n if (!value) return;\n\n hasBooleanChanged.current = true;\n }, [value]);\n\n const reset = () => {\n hasBooleanChanged.current = false;\n };\n\n return [hasBooleanChanged.current, reset] as const;\n};\n\nexport default useRefIfValueWasTrue;\n"],"names":["useRefIfValueWasTrue","value","hasBooleanChanged","React","reset"],"mappings":";AAEM,MAAAA,IAAuB,CAACC,MAAmB;AACzC,QAAAC,IAAoBC,EAAM,OAAO,EAAK;AAG5C,EAAAA,EAAM,UAAU,MAAM;AACpB,IAAKF,MAELC,EAAkB,UAAU;AAAA,EAAA,GAC3B,CAACD,CAAK,CAAC;AAEV,QAAMG,IAAQ,MAAM;AAClB,IAAAF,EAAkB,UAAU;AAAA,EAAA;AAGvB,SAAA,CAACA,EAAkB,SAASE,CAAK;AAC1C;"}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@paragrav/rhf-utils",
3
3
  "author": "paragrav.dev",
4
4
  "license": "MIT",
5
- "version": "0.0.131",
5
+ "version": "0.0.132",
6
6
  "description": "Integration utilities for react-hook-form.",
7
7
  "type": "module",
8
8
  "sideEffects": false,