@payloadcms/ui 3.0.0-beta.37 → 3.0.0-beta.39

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 (176) hide show
  1. package/dist/elements/DocumentFields/index.d.ts.map +1 -1
  2. package/dist/elements/DocumentFields/index.js +2 -0
  3. package/dist/elements/DocumentFields/index.js.map +1 -1
  4. package/dist/elements/DocumentHeader/Tabs/Tab/index.scss +3 -1
  5. package/dist/elements/DocumentHeader/Tabs/tabs/VersionsPill/index.d.ts.map +1 -1
  6. package/dist/elements/DocumentHeader/Tabs/tabs/VersionsPill/index.js +14 -8
  7. package/dist/elements/DocumentHeader/Tabs/tabs/VersionsPill/index.js.map +1 -1
  8. package/dist/elements/ReactSelect/Input/index.d.ts +5 -0
  9. package/dist/elements/ReactSelect/Input/index.d.ts.map +1 -0
  10. package/dist/elements/ReactSelect/Input/index.js +17 -0
  11. package/dist/elements/ReactSelect/Input/index.js.map +1 -0
  12. package/dist/elements/ReactSelect/MultiValue/index.d.ts.map +1 -1
  13. package/dist/elements/ReactSelect/MultiValue/index.js +7 -5
  14. package/dist/elements/ReactSelect/MultiValue/index.js.map +1 -1
  15. package/dist/elements/ReactSelect/index.d.ts.map +1 -1
  16. package/dist/elements/ReactSelect/index.js +17 -1
  17. package/dist/elements/ReactSelect/index.js.map +1 -1
  18. package/dist/elements/RenderTitle/index.d.ts.map +1 -1
  19. package/dist/elements/RenderTitle/index.js +12 -7
  20. package/dist/elements/RenderTitle/index.js.map +1 -1
  21. package/dist/elements/Table/DefaultCell/fields/Relationship/index.js +1 -1
  22. package/dist/elements/Table/DefaultCell/fields/Relationship/index.js.map +1 -1
  23. package/dist/elements/WhereBuilder/Condition/Relationship/index.d.ts.map +1 -1
  24. package/dist/elements/WhereBuilder/Condition/Relationship/index.js +104 -72
  25. package/dist/elements/WhereBuilder/Condition/Relationship/index.js.map +1 -1
  26. package/dist/elements/WhereBuilder/Condition/index.js +3 -3
  27. package/dist/elements/WhereBuilder/Condition/index.js.map +1 -1
  28. package/dist/elements/WhereBuilder/index.d.ts.map +1 -1
  29. package/dist/elements/WhereBuilder/index.js +49 -49
  30. package/dist/elements/WhereBuilder/index.js.map +1 -1
  31. package/dist/fields/Array/index.d.ts.map +1 -1
  32. package/dist/fields/Array/index.js +6 -6
  33. package/dist/fields/Array/index.js.map +1 -1
  34. package/dist/fields/Blocks/index.d.ts.map +1 -1
  35. package/dist/fields/Blocks/index.js +6 -6
  36. package/dist/fields/Blocks/index.js.map +1 -1
  37. package/dist/fields/Checkbox/index.d.ts.map +1 -1
  38. package/dist/fields/Checkbox/index.js +6 -6
  39. package/dist/fields/Checkbox/index.js.map +1 -1
  40. package/dist/fields/Code/index.d.ts.map +1 -1
  41. package/dist/fields/Code/index.js +5 -5
  42. package/dist/fields/Code/index.js.map +1 -1
  43. package/dist/fields/Collapsible/index.d.ts.map +1 -1
  44. package/dist/fields/Collapsible/index.js +5 -2
  45. package/dist/fields/Collapsible/index.js.map +1 -1
  46. package/dist/fields/DateTime/index.js +5 -5
  47. package/dist/fields/DateTime/index.js.map +1 -1
  48. package/dist/fields/Email/index.d.ts.map +1 -1
  49. package/dist/fields/Email/index.js +4 -4
  50. package/dist/fields/Email/index.js.map +1 -1
  51. package/dist/fields/Group/index.d.ts.map +1 -1
  52. package/dist/fields/Group/index.js +5 -3
  53. package/dist/fields/Group/index.js.map +1 -1
  54. package/dist/fields/JSON/index.d.ts.map +1 -1
  55. package/dist/fields/JSON/index.js +7 -7
  56. package/dist/fields/JSON/index.js.map +1 -1
  57. package/dist/fields/Number/index.d.ts.map +1 -1
  58. package/dist/fields/Number/index.js +7 -7
  59. package/dist/fields/Number/index.js.map +1 -1
  60. package/dist/fields/Password/index.d.ts.map +1 -1
  61. package/dist/fields/Password/index.js +6 -4
  62. package/dist/fields/Password/index.js.map +1 -1
  63. package/dist/fields/RadioGroup/index.d.ts.map +1 -1
  64. package/dist/fields/RadioGroup/index.js +5 -5
  65. package/dist/fields/RadioGroup/index.js.map +1 -1
  66. package/dist/fields/Relationship/findOptionsByValue.js +1 -1
  67. package/dist/fields/Relationship/findOptionsByValue.js.map +1 -1
  68. package/dist/fields/Relationship/index.d.ts.map +1 -1
  69. package/dist/fields/Relationship/index.js +2 -4
  70. package/dist/fields/Relationship/index.js.map +1 -1
  71. package/dist/fields/Select/index.d.ts.map +1 -1
  72. package/dist/fields/Select/index.js +5 -5
  73. package/dist/fields/Select/index.js.map +1 -1
  74. package/dist/fields/Tabs/index.d.ts.map +1 -1
  75. package/dist/fields/Tabs/index.js.map +1 -1
  76. package/dist/fields/Text/index.d.ts.map +1 -1
  77. package/dist/fields/Text/index.js +5 -5
  78. package/dist/fields/Text/index.js.map +1 -1
  79. package/dist/fields/Textarea/index.d.ts.map +1 -1
  80. package/dist/fields/Textarea/index.js +3 -3
  81. package/dist/fields/Textarea/index.js.map +1 -1
  82. package/dist/fields/Upload/index.d.ts.map +1 -1
  83. package/dist/fields/Upload/index.js +3 -3
  84. package/dist/fields/Upload/index.js.map +1 -1
  85. package/dist/forms/FieldPropsProvider/index.d.ts +1 -0
  86. package/dist/forms/FieldPropsProvider/index.d.ts.map +1 -1
  87. package/dist/forms/FieldPropsProvider/index.js.map +1 -1
  88. package/dist/forms/Form/context.d.ts +3 -1
  89. package/dist/forms/Form/context.d.ts.map +1 -1
  90. package/dist/forms/Form/context.js +3 -1
  91. package/dist/forms/Form/context.js.map +1 -1
  92. package/dist/forms/Form/getSiblingData.d.ts.map +1 -1
  93. package/dist/forms/Form/getSiblingData.js +1 -0
  94. package/dist/forms/Form/getSiblingData.js.map +1 -1
  95. package/dist/forms/Form/index.d.ts.map +1 -1
  96. package/dist/forms/Form/index.js +28 -11
  97. package/dist/forms/Form/index.js.map +1 -1
  98. package/dist/forms/Form/initContextState.d.ts.map +1 -1
  99. package/dist/forms/Form/initContextState.js +1 -0
  100. package/dist/forms/Form/initContextState.js.map +1 -1
  101. package/dist/forms/Form/types.d.ts +2 -0
  102. package/dist/forms/Form/types.d.ts.map +1 -1
  103. package/dist/forms/Form/types.js.map +1 -1
  104. package/dist/forms/RenderFields/index.d.ts.map +1 -1
  105. package/dist/forms/RenderFields/index.js +6 -2
  106. package/dist/forms/RenderFields/index.js.map +1 -1
  107. package/dist/forms/RenderFields/types.d.ts +8 -1
  108. package/dist/forms/RenderFields/types.d.ts.map +1 -1
  109. package/dist/forms/RenderFields/types.js.map +1 -1
  110. package/dist/forms/Submit/index.d.ts.map +1 -1
  111. package/dist/forms/Submit/index.js +3 -2
  112. package/dist/forms/Submit/index.js.map +1 -1
  113. package/dist/forms/buildStateFromSchema/calculateDefaultValues/index.d.ts +5 -3
  114. package/dist/forms/buildStateFromSchema/calculateDefaultValues/index.d.ts.map +1 -1
  115. package/dist/forms/buildStateFromSchema/calculateDefaultValues/index.js +4 -3
  116. package/dist/forms/buildStateFromSchema/calculateDefaultValues/index.js.map +1 -1
  117. package/dist/forms/buildStateFromSchema/calculateDefaultValues/iterateFields.d.ts +5 -3
  118. package/dist/forms/buildStateFromSchema/calculateDefaultValues/iterateFields.d.ts.map +1 -1
  119. package/dist/forms/buildStateFromSchema/calculateDefaultValues/iterateFields.js +4 -3
  120. package/dist/forms/buildStateFromSchema/calculateDefaultValues/iterateFields.js.map +1 -1
  121. package/dist/forms/buildStateFromSchema/calculateDefaultValues/promise.d.ts +5 -3
  122. package/dist/forms/buildStateFromSchema/calculateDefaultValues/promise.d.ts.map +1 -1
  123. package/dist/forms/buildStateFromSchema/calculateDefaultValues/promise.js +21 -15
  124. package/dist/forms/buildStateFromSchema/calculateDefaultValues/promise.js.map +1 -1
  125. package/dist/forms/buildStateFromSchema/index.d.ts.map +1 -1
  126. package/dist/forms/buildStateFromSchema/index.js +3 -2
  127. package/dist/forms/buildStateFromSchema/index.js.map +1 -1
  128. package/dist/forms/useField/index.d.ts.map +1 -1
  129. package/dist/forms/useField/index.js +5 -2
  130. package/dist/forms/useField/index.js.map +1 -1
  131. package/dist/forms/useField/types.d.ts +1 -0
  132. package/dist/forms/useField/types.d.ts.map +1 -1
  133. package/dist/forms/useField/types.js.map +1 -1
  134. package/dist/icons/Plus/index.d.ts.map +1 -1
  135. package/dist/icons/Plus/index.js +1 -0
  136. package/dist/icons/Plus/index.js.map +1 -1
  137. package/dist/icons/Plus/index.scss +0 -3
  138. package/dist/providers/ComponentMap/buildComponentMap/fields.d.ts.map +1 -1
  139. package/dist/providers/ComponentMap/buildComponentMap/fields.js +1 -0
  140. package/dist/providers/ComponentMap/buildComponentMap/fields.js.map +1 -1
  141. package/dist/providers/DocumentInfo/index.d.ts.map +1 -1
  142. package/dist/providers/DocumentInfo/index.js +67 -53
  143. package/dist/providers/DocumentInfo/index.js.map +1 -1
  144. package/dist/providers/DocumentInfo/types.d.ts +4 -0
  145. package/dist/providers/DocumentInfo/types.d.ts.map +1 -1
  146. package/dist/providers/DocumentInfo/types.js.map +1 -1
  147. package/dist/providers/Root/index.d.ts +1 -2
  148. package/dist/providers/Root/index.d.ts.map +1 -1
  149. package/dist/providers/Root/index.js.map +1 -1
  150. package/dist/providers/Translation/index.d.ts +1 -5
  151. package/dist/providers/Translation/index.d.ts.map +1 -1
  152. package/dist/providers/Translation/index.js.map +1 -1
  153. package/dist/utilities/buildFieldSchemaMap/index.d.ts +8 -0
  154. package/dist/utilities/buildFieldSchemaMap/index.d.ts.map +1 -0
  155. package/dist/utilities/buildFieldSchemaMap/index.js +29 -0
  156. package/dist/utilities/buildFieldSchemaMap/index.js.map +1 -0
  157. package/dist/utilities/buildFieldSchemaMap/traverseFields.d.ts +14 -0
  158. package/dist/utilities/buildFieldSchemaMap/traverseFields.d.ts.map +1 -0
  159. package/dist/utilities/buildFieldSchemaMap/traverseFields.js +75 -0
  160. package/dist/utilities/buildFieldSchemaMap/traverseFields.js.map +1 -0
  161. package/dist/utilities/buildFieldSchemaMap/types.d.ts +3 -0
  162. package/dist/utilities/buildFieldSchemaMap/types.d.ts.map +1 -0
  163. package/dist/utilities/buildFieldSchemaMap/types.js +3 -0
  164. package/dist/utilities/buildFieldSchemaMap/types.js.map +1 -0
  165. package/dist/utilities/buildFormState.d.ts +7 -0
  166. package/dist/utilities/buildFormState.d.ts.map +1 -0
  167. package/dist/utilities/buildFormState.js +162 -0
  168. package/dist/utilities/buildFormState.js.map +1 -0
  169. package/dist/utilities/getFormState.d.ts +1 -0
  170. package/dist/utilities/getFormState.d.ts.map +1 -1
  171. package/dist/utilities/getFormState.js +5 -2
  172. package/dist/utilities/getFormState.js.map +1 -1
  173. package/dist/utilities/reduceFieldsToValues.d.ts.map +1 -1
  174. package/dist/utilities/reduceFieldsToValues.js +1 -0
  175. package/dist/utilities/reduceFieldsToValues.js.map +1 -1
  176. package/package.json +5 -5
@@ -23,11 +23,11 @@ const _Upload = (props)=>{
23
23
  required
24
24
  ]);
25
25
  const { path: pathFromContext, readOnly: readOnlyFromContext } = useFieldProps();
26
- const readOnly = readOnlyFromProps || readOnlyFromContext;
27
- const { filterOptions, path, setValue, showError, value } = useField({
26
+ const { filterOptions, formInitializing, formProcessing, path, setValue, showError, value } = useField({
28
27
  path: pathFromContext || pathFromProps,
29
28
  validate: memoizedValidate
30
29
  });
30
+ const disabled = readOnlyFromProps || readOnlyFromContext || formProcessing || formInitializing;
31
31
  const onChange = useCallback((incomingValue)=>{
32
32
  const incomingID = incomingValue?.id || incomingValue;
33
33
  setValue(incomingID);
@@ -49,7 +49,7 @@ const _Upload = (props)=>{
49
49
  labelProps: labelProps,
50
50
  onChange: onChange,
51
51
  path: path,
52
- readOnly: readOnly,
52
+ readOnly: disabled,
53
53
  relationTo: relationTo,
54
54
  required: required,
55
55
  serverURL: serverURL,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/fields/Upload/index.tsx"],"sourcesContent":["'use client'\n\nimport React, { useCallback } from 'react'\n\nimport type { UploadInputProps } from './Input.js'\nimport type { UploadFieldProps } from './types.js'\n\nimport { useFieldProps } from '../../forms/FieldPropsProvider/index.js'\nimport { useField } from '../../forms/useField/index.js'\nimport { withCondition } from '../../forms/withCondition/index.js'\nimport { useConfig } from '../../providers/Config/index.js'\nimport { UploadInput } from './Input.js'\nimport './index.scss'\n\nexport { UploadFieldProps, UploadInput }\nexport type { UploadInputProps }\n\nconst _Upload: React.FC<UploadFieldProps> = (props) => {\n const {\n CustomDescription,\n CustomError,\n CustomLabel,\n className,\n descriptionProps,\n errorProps,\n label,\n labelProps,\n path: pathFromProps,\n readOnly: readOnlyFromProps,\n relationTo,\n required,\n style,\n validate,\n width,\n } = props\n\n const {\n collections,\n routes: { api },\n serverURL,\n } = useConfig()\n\n const collection = collections.find((coll) => coll.slug === relationTo)\n\n const memoizedValidate = useCallback(\n (value, options) => {\n if (typeof validate === 'function') {\n return validate(value, { ...options, required })\n }\n },\n [validate, required],\n )\n\n const { path: pathFromContext, readOnly: readOnlyFromContext } = useFieldProps()\n const readOnly = readOnlyFromProps || readOnlyFromContext\n\n const { filterOptions, path, setValue, showError, value } = useField<string>({\n path: pathFromContext || pathFromProps,\n validate: memoizedValidate,\n })\n\n const onChange = useCallback(\n (incomingValue) => {\n const incomingID = incomingValue?.id || incomingValue\n setValue(incomingID)\n },\n [setValue],\n )\n\n if (collection.upload) {\n return (\n <UploadInput\n CustomDescription={CustomDescription}\n CustomError={CustomError}\n CustomLabel={CustomLabel}\n api={api}\n className={className}\n collection={collection}\n descriptionProps={descriptionProps}\n errorProps={errorProps}\n filterOptions={filterOptions}\n label={label}\n labelProps={labelProps}\n onChange={onChange}\n path={path}\n readOnly={readOnly}\n relationTo={relationTo}\n required={required}\n serverURL={serverURL}\n showError={showError}\n style={style}\n value={value}\n width={width}\n />\n )\n }\n\n return null\n}\n\nexport const Upload = withCondition(_Upload)\n"],"names":["React","useCallback","useFieldProps","useField","withCondition","useConfig","UploadInput","_Upload","props","CustomDescription","CustomError","CustomLabel","className","descriptionProps","errorProps","label","labelProps","path","pathFromProps","readOnly","readOnlyFromProps","relationTo","required","style","validate","width","collections","routes","api","serverURL","collection","find","coll","slug","memoizedValidate","value","options","pathFromContext","readOnlyFromContext","filterOptions","setValue","showError","onChange","incomingValue","incomingID","id","upload","Upload"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;;AAEA,OAAOA,SAASC,WAAW,QAAQ,QAAO;AAK1C,SAASC,aAAa,QAAQ,0CAAyC;AACvE,SAASC,QAAQ,QAAQ,gCAA+B;AACxD,SAASC,aAAa,QAAQ,qCAAoC;AAClE,SAASC,SAAS,QAAQ,kCAAiC;AAC3D,SAASC,WAAW,QAAQ,aAAY;AAGxC,SAA2BA,WAAW,GAAE;AAGxC,MAAMC,UAAsC,CAACC;IAC3C,MAAM,EACJC,iBAAiB,EACjBC,WAAW,EACXC,WAAW,EACXC,SAAS,EACTC,gBAAgB,EAChBC,UAAU,EACVC,KAAK,EACLC,UAAU,EACVC,MAAMC,aAAa,EACnBC,UAAUC,iBAAiB,EAC3BC,UAAU,EACVC,QAAQ,EACRC,KAAK,EACLC,QAAQ,EACRC,KAAK,EACN,GAAGjB;IAEJ,MAAM,EACJkB,WAAW,EACXC,QAAQ,EAAEC,GAAG,EAAE,EACfC,SAAS,EACV,GAAGxB;IAEJ,MAAMyB,aAAaJ,YAAYK,IAAI,CAAC,CAACC,OAASA,KAAKC,IAAI,KAAKZ;IAE5D,MAAMa,mBAAmBjC,YACvB,CAACkC,OAAOC;QACN,IAAI,OAAOZ,aAAa,YAAY;YAClC,OAAOA,SAASW,OAAO;gBAAE,GAAGC,OAAO;gBAAEd;YAAS;QAChD;IACF,GACA;QAACE;QAAUF;KAAS;IAGtB,MAAM,EAAEL,MAAMoB,eAAe,EAAElB,UAAUmB,mBAAmB,EAAE,GAAGpC;IACjE,MAAMiB,WAAWC,qBAAqBkB;IAEtC,MAAM,EAAEC,aAAa,EAAEtB,IAAI,EAAEuB,QAAQ,EAAEC,SAAS,EAAEN,KAAK,EAAE,GAAGhC,SAAiB;QAC3Ec,MAAMoB,mBAAmBnB;QACzBM,UAAUU;IACZ;IAEA,MAAMQ,WAAWzC,YACf,CAAC0C;QACC,MAAMC,aAAaD,eAAeE,MAAMF;QACxCH,SAASI;IACX,GACA;QAACJ;KAAS;IAGZ,IAAIV,WAAWgB,MAAM,EAAE;QACrB,qBACE,KAACxC;YACCG,mBAAmBA;YACnBC,aAAaA;YACbC,aAAaA;YACbiB,KAAKA;YACLhB,WAAWA;YACXkB,YAAYA;YACZjB,kBAAkBA;YAClBC,YAAYA;YACZyB,eAAeA;YACfxB,OAAOA;YACPC,YAAYA;YACZ0B,UAAUA;YACVzB,MAAMA;YACNE,UAAUA;YACVE,YAAYA;YACZC,UAAUA;YACVO,WAAWA;YACXY,WAAWA;YACXlB,OAAOA;YACPY,OAAOA;YACPV,OAAOA;;IAGb;IAEA,OAAO;AACT;AAEA,OAAO,MAAMsB,SAAS3C,cAAcG,SAAQ"}
1
+ {"version":3,"sources":["../../../src/fields/Upload/index.tsx"],"sourcesContent":["'use client'\n\nimport React, { useCallback } from 'react'\n\nimport type { UploadInputProps } from './Input.js'\nimport type { UploadFieldProps } from './types.js'\n\nimport { useFieldProps } from '../../forms/FieldPropsProvider/index.js'\nimport { useField } from '../../forms/useField/index.js'\nimport { withCondition } from '../../forms/withCondition/index.js'\nimport { useConfig } from '../../providers/Config/index.js'\nimport { UploadInput } from './Input.js'\nimport './index.scss'\n\nexport { UploadFieldProps, UploadInput }\nexport type { UploadInputProps }\n\nconst _Upload: React.FC<UploadFieldProps> = (props) => {\n const {\n CustomDescription,\n CustomError,\n CustomLabel,\n className,\n descriptionProps,\n errorProps,\n label,\n labelProps,\n path: pathFromProps,\n readOnly: readOnlyFromProps,\n relationTo,\n required,\n style,\n validate,\n width,\n } = props\n\n const {\n collections,\n routes: { api },\n serverURL,\n } = useConfig()\n\n const collection = collections.find((coll) => coll.slug === relationTo)\n\n const memoizedValidate = useCallback(\n (value, options) => {\n if (typeof validate === 'function') {\n return validate(value, { ...options, required })\n }\n },\n [validate, required],\n )\n\n const { path: pathFromContext, readOnly: readOnlyFromContext } = useFieldProps()\n\n const { filterOptions, formInitializing, formProcessing, path, setValue, showError, value } =\n useField<string>({\n path: pathFromContext || pathFromProps,\n validate: memoizedValidate,\n })\n\n const disabled = readOnlyFromProps || readOnlyFromContext || formProcessing || formInitializing\n\n const onChange = useCallback(\n (incomingValue) => {\n const incomingID = incomingValue?.id || incomingValue\n setValue(incomingID)\n },\n [setValue],\n )\n\n if (collection.upload) {\n return (\n <UploadInput\n CustomDescription={CustomDescription}\n CustomError={CustomError}\n CustomLabel={CustomLabel}\n api={api}\n className={className}\n collection={collection}\n descriptionProps={descriptionProps}\n errorProps={errorProps}\n filterOptions={filterOptions}\n label={label}\n labelProps={labelProps}\n onChange={onChange}\n path={path}\n readOnly={disabled}\n relationTo={relationTo}\n required={required}\n serverURL={serverURL}\n showError={showError}\n style={style}\n value={value}\n width={width}\n />\n )\n }\n\n return null\n}\n\nexport const Upload = withCondition(_Upload)\n"],"names":["React","useCallback","useFieldProps","useField","withCondition","useConfig","UploadInput","_Upload","props","CustomDescription","CustomError","CustomLabel","className","descriptionProps","errorProps","label","labelProps","path","pathFromProps","readOnly","readOnlyFromProps","relationTo","required","style","validate","width","collections","routes","api","serverURL","collection","find","coll","slug","memoizedValidate","value","options","pathFromContext","readOnlyFromContext","filterOptions","formInitializing","formProcessing","setValue","showError","disabled","onChange","incomingValue","incomingID","id","upload","Upload"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;;AAEA,OAAOA,SAASC,WAAW,QAAQ,QAAO;AAK1C,SAASC,aAAa,QAAQ,0CAAyC;AACvE,SAASC,QAAQ,QAAQ,gCAA+B;AACxD,SAASC,aAAa,QAAQ,qCAAoC;AAClE,SAASC,SAAS,QAAQ,kCAAiC;AAC3D,SAASC,WAAW,QAAQ,aAAY;AAGxC,SAA2BA,WAAW,GAAE;AAG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UA;YACV5B,MAAMA;YACNE,UAAUyB;YACVvB,YAAYA;YACZC,UAAUA;YACVO,WAAWA;YACXc,WAAWA;YACXpB,OAAOA;YACPY,OAAOA;YACPV,OAAOA;;IAGb;IAEA,OAAO;AACT;AAEA,OAAO,MAAMyB,SAAS9C,cAAcG,SAAQ"}
@@ -17,6 +17,7 @@ export type Props = {
17
17
  children: React.ReactNode;
18
18
  custom?: Record<any, string>;
19
19
  indexPath?: string;
20
+ isForceRendered?: boolean;
20
21
  path: string;
21
22
  permissions?: FieldPermissions;
22
23
  readOnly: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/forms/FieldPropsProvider/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAErD,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,MAAM,MAAM,qBAAqB,GAAG;IAClC,MAAM,CAAC,EAAE,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,CAAC,EAAE,gBAAgB,CAAA;IAC9B,QAAQ,EAAE,OAAO,CAAA;IACjB,UAAU,EAAE,MAAM,CAAA;IAClB,kBAAkB,EAAE;QAClB,CAAC,SAAS,EAAE,MAAM,GAAG,gBAAgB,CAAA;KACtC,CAAA;IACD,IAAI,EAAE,MAAM,UAAU,CAAA;CACvB,CAAA;AAaD,MAAM,MAAM,KAAK,GAAG;IAClB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,CAAC,EAAE,g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;IAC9B,QAAQ,EAAE,OAAO,CAAA;IACjB,UAAU,EAAE,MAAM,CAAA;IAClB,kBAAkB,EAAE;QAClB,CAAC,SAAS,EAAE,MAAM,GAAG,gBAAgB,CAAA;KACtC,CAAA;IACD,IAAI,EAAE,MAAM,UAAU,CAAA;CACvB,CAAA;AAED,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CA2B9C,CAAA;AAED,eAAO,MAAM,aAAa,6BAGzB,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/forms/FieldPropsProvider/index.tsx"],"sourcesContent":["'use client'\nimport type { FieldTypes } from 'payload/config'\nimport type { FieldPermissions } from 'payload/types'\n\nimport React from 'react'\n\nexport type FieldPropsContextType = {\n custom?: Record<any, string>\n indexPath?: string\n path: string\n permissions?: FieldPermissions\n readOnly: boolean\n schemaPath: string\n siblingPermissions: {\n [fieldName: string]: FieldPermissions\n }\n type: keyof FieldTypes\n}\n\nconst FieldPropsContext = React.createContext<FieldPropsContextType>({\n type: '' as keyof FieldTypes,\n custom: {},\n indexPath: '',\n path: '',\n permissions: {} as FieldPermissions,\n readOnly: false,\n schemaPath: '',\n siblingPermissions: {},\n})\n\nexport type Props = {\n children: React.ReactNode\n custom?: Record<any, string>\n indexPath?: string\n path: string\n permissions?: FieldPermissions\n readOnly: boolean\n schemaPath: string\n siblingPermissions: {\n [fieldName: string]: FieldPermissions\n }\n type: keyof FieldTypes\n}\n\nexport const FieldPropsProvider: React.FC<Props> = ({\n type,\n children,\n custom,\n indexPath,\n path,\n permissions,\n readOnly,\n schemaPath,\n siblingPermissions,\n}) => {\n return (\n <FieldPropsContext.Provider\n value={{\n type,\n custom,\n indexPath,\n path,\n permissions,\n readOnly,\n schemaPath,\n siblingPermissions,\n }}\n >\n {children}\n </FieldPropsContext.Provider>\n )\n}\n\nexport const useFieldProps = () => {\n const props = React.useContext(FieldPropsContext)\n return props\n}\n"],"names":["React","FieldPropsContext","createContext","type","custom","indexPath","path","permissions","readOnly","schemaPath","siblingPermissions","FieldPropsProvider","children","Provider","value","useFieldProps","props","useContext"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;;AAIA,OAAOA,WAAW,QAAO;AAezB,MAAMC,kCAAoBD,MAAME,aAAa,CAAwB;IACnEC,MAAM;IACNC,QAAQ,CAAC;IACTC,WAAW;IACXC,MAAM;IACNC,aAAa,CAAC;IACdC,UAAU;IACVC,YAAY;IACZC,oBAAoB,CAAC;AACvB;AAgBA,OAAO,MAAMC,qBAAsC,CAAC,EAClDR,IAAI,EACJS,QAAQ,EACRR,MAAM,EACNC,SAAS,EACTC,IAAI,EACJC,WAAW,EACXC,QAAQ,EACRC,UAAU,EACVC,kBAAkB,EACnB;IACC,qBACE,KAACT,kBAAkBY,QAAQ;QACzBC,OAAO;YACLX;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;QACF;kBAECE;;AAGP,EAAC;AAED,OAAO,MAAMG,gBAAgB;IAC3B,MAAMC,QAAQhB,MAAMiB,UAAU,CAAChB;IAC/B,OAAOe;AACT,EAAC"}
1
+ {"version":3,"sources":["../../../src/forms/FieldPropsProvider/index.tsx"],"sourcesContent":["'use client'\nimport type { FieldTypes } from 'payload/config'\nimport type { FieldPermissions } from 'payload/types'\n\nimport React from 'react'\n\nexport type FieldPropsContextType = {\n custom?: Record<any, string>\n indexPath?: string\n path: string\n permissions?: FieldPermissions\n readOnly: boolean\n schemaPath: string\n siblingPermissions: {\n [fieldName: string]: FieldPermissions\n }\n type: keyof FieldTypes\n}\n\nconst FieldPropsContext = React.createContext<FieldPropsContextType>({\n type: '' as keyof FieldTypes,\n custom: {},\n indexPath: '',\n path: '',\n permissions: {} as FieldPermissions,\n readOnly: false,\n schemaPath: '',\n siblingPermissions: {},\n})\n\nexport type Props = {\n children: React.ReactNode\n custom?: Record<any, string>\n indexPath?: string\n isForceRendered?: boolean\n path: string\n permissions?: FieldPermissions\n readOnly: boolean\n schemaPath: string\n siblingPermissions: {\n [fieldName: string]: FieldPermissions\n }\n type: keyof FieldTypes\n}\n\nexport const FieldPropsProvider: React.FC<Props> = ({\n type,\n children,\n custom,\n indexPath,\n path,\n permissions,\n readOnly,\n schemaPath,\n siblingPermissions,\n}) => {\n return (\n <FieldPropsContext.Provider\n value={{\n type,\n custom,\n indexPath,\n path,\n permissions,\n readOnly,\n schemaPath,\n siblingPermissions,\n }}\n >\n {children}\n </FieldPropsContext.Provider>\n )\n}\n\nexport const useFieldProps = () => {\n const props = React.useContext(FieldPropsContext)\n return props\n}\n"],"names":["React","FieldPropsContext","createContext","type","custom","indexPath","path","permissions","readOnly","schemaPath","siblingPermissions","FieldPropsProvider","children","Provider","value","useFieldProps","props","useContext"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;;AAIA,OAAOA,WAAW,QAAO;AAezB,MAAMC,kCAAoBD,MAAME,aAAa,CAAwB;IACnEC,MAAM;IACNC,QAAQ,CAAC;IACTC,WAAW;IACXC,MAAM;IACNC,aAAa,CAAC;IACdC,UAAU;IACVC,YAAY;IACZC,oBAAoB,CAAC;AACvB;AAiBA,OAAO,MAAMC,qBAAsC,CAAC,EAClDR,IAAI,EACJS,QAAQ,EACRR,MAAM,EACNC,SAAS,EACTC,IAAI,EACJC,WAAW,EACXC,QAAQ,EACRC,UAAU,EACVC,kBAAkB,EACnB;IACC,qBACE,KAACT,kBAAkBY,QAAQ;QACzBC,OAAO;YACLX;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;QACF;kBAECE;;AAGP,EAAC;AAED,OAAO,MAAMG,gBAAgB;IAC3B,MAAMC,QAAQhB,MAAMiB,UAAU,CAAChB;IAC/B,OAAOe;AACT,EAAC"}
@@ -5,6 +5,7 @@ declare const FormWatchContext: import("react").Context<Context>;
5
5
  declare const SubmittedContext: import("react").Context<boolean>;
6
6
  declare const ProcessingContext: import("react").Context<boolean>;
7
7
  declare const ModifiedContext: import("react").Context<boolean>;
8
+ declare const InitializingContext: import("react").Context<boolean>;
8
9
  declare const FormFieldsContext: import("use-context-selector").Context<FormFieldsContextType>;
9
10
  /**
10
11
  * Get the state of the form, can be used to submit & validate the form.
@@ -16,6 +17,7 @@ declare const useWatchForm: () => Context;
16
17
  declare const useFormSubmitted: () => boolean;
17
18
  declare const useFormProcessing: () => boolean;
18
19
  declare const useFormModified: () => boolean;
20
+ declare const useFormInitializing: () => boolean;
19
21
  /**
20
22
  * Get and set the value of a form field based on a selector
21
23
  *
@@ -28,5 +30,5 @@ declare const useFormFields: <Value = unknown>(selector: (context: FormFieldsCon
28
30
  * @see https://payloadcms.com/docs/admin/hooks#useallformfields
29
31
  */
30
32
  declare const useAllFormFields: () => FormFieldsContextType;
31
- export { FormContext, FormFieldsContext, FormWatchContext, ModifiedContext, ProcessingContext, SubmittedContext, useAllFormFields, useForm, useFormFields, useFormModified, useFormProcessing, useFormSubmitted, useWatchForm, };
33
+ export { FormContext, FormFieldsContext, FormWatchContext, InitializingContext, ModifiedContext, ProcessingContext, SubmittedContext, useAllFormFields, useForm, useFormFields, useFormInitializing, useFormModified, useFormProcessing, useFormSubmitted, useWatchForm, };
32
34
  //# sourceMappingURL=context.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/forms/Form/context.ts"],"names":[],"mappings":";AAQA,OAAO,KAAK,EAAE,OAAO,EAAE,iBAAiB,IAAI,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAErF,QAAA,MAAM,WAAW,kCAA+B,CAAA;AAChD,QAAA,MAAM,gBAAgB,kCAA+B,CAAA;AACrD,QAAA,MAAM,gBAAgB,kCAAuB,CAAA;AAC7C,QAAA,MAAM,iBAAiB,kCAAuB,CAAA;AAC9C,QAAA,MAAM,eAAe,kCAAuB,CAAA;AAC5C,QAAA,MAAM,iBAAiB,+DAAiE,CAAA;AAExF;;;;GAIG;AACH,QAAA,MAAM,OAAO,QAAO,OAA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AM,mBAAmB,QAAO,OAA0C,CAAA;AAE1E;;;;GAIG;AACH,QAAA,MAAM,aAAa,8BACP,CAAC,OAAO,EAAE,qBAAqB,KAAK,KAAK,KAClD,KAAwD,CAAA;AAE3D;;;;GAIG;AACH,QAAA,MAAM,gBAAgB,6BAAiE,CAAA;AAEvF,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,gBAAgB,EAChB,mBAAmB,EACnB,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EAChB,OAAO,EACP,aAAa,EACb,mBAAmB,EACnB,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,YAAY,GACb,CAAA"}
@@ -6,6 +6,7 @@ const FormWatchContext = createContext({});
6
6
  const SubmittedContext = createContext(false);
7
7
  const ProcessingContext = createContext(false);
8
8
  const ModifiedContext = createContext(false);
9
+ const InitializingContext = createContext(false);
9
10
  const FormFieldsContext = createSelectorContext([
10
11
  {},
11
12
  ()=>null
@@ -19,6 +20,7 @@ const useWatchForm = ()=>useContext(FormWatchContext);
19
20
  const useFormSubmitted = ()=>useContext(SubmittedContext);
20
21
  const useFormProcessing = ()=>useContext(ProcessingContext);
21
22
  const useFormModified = ()=>useContext(ModifiedContext);
23
+ const useFormInitializing = ()=>useContext(InitializingContext);
22
24
  /**
23
25
  * Get and set the value of a form field based on a selector
24
26
  *
@@ -29,6 +31,6 @@ const useFormModified = ()=>useContext(ModifiedContext);
29
31
  *
30
32
  * @see https://payloadcms.com/docs/admin/hooks#useallformfields
31
33
  */ const useAllFormFields = ()=>useFullContext(FormFieldsContext);
32
- export { FormContext, FormFieldsContext, FormWatchContext, ModifiedContext, ProcessingContext, SubmittedContext, useAllFormFields, useForm, useFormFields, useFormModified, useFormProcessing, useFormSubmitted, useWatchForm, };
34
+ export { FormContext, FormFieldsContext, FormWatchContext, InitializingContext, ModifiedContext, ProcessingContext, SubmittedContext, useAllFormFields, useForm, useFormFields, useFormInitializing, useFormModified, useFormProcessing, useFormSubmitted, useWatchForm, };
33
35
 
34
36
  //# sourceMappingURL=context.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/forms/Form/context.ts"],"sourcesContent":["'use client'\nimport { createContext, useContext } from 'react'\nimport {\n createContext as createSelectorContext,\n useContextSelector,\n useContext as useFullContext,\n} from 'use-context-selector'\n\nimport type { Context, FormFieldsContext as FormFieldsContextType } from './types.js'\n\nconst FormContext = createContext({} as Context)\nconst FormWatchContext = createContext({} as Context)\nconst SubmittedContext = createContext(false)\nconst ProcessingContext = createContext(false)\nconst ModifiedContext = createContext(false)\nconst FormFieldsContext = createSelectorContext<FormFieldsContextType>([{}, () => null])\n\n/**\n * Get the state of the form, can be used to submit & validate the form.\n *\n * @see https://payloadcms.com/docs/admin/hooks#useform\n */\nconst useForm = (): Context => useContext(FormContext)\nconst useWatchForm = (): Context => useContext(FormWatchContext)\nconst useFormSubmitted = (): boolean => useContext(SubmittedContext)\nconst useFormProcessing = (): boolean => useContext(ProcessingContext)\nconst useFormModified = (): boolean => useContext(ModifiedContext)\n\n/**\n * Get and set the value of a form field based on a selector\n *\n * @see https://payloadcms.com/docs/admin/hooks#useformfields\n */\nconst useFormFields = <Value = unknown>(\n selector: (context: FormFieldsContextType) => Value,\n): Value => useContextSelector(FormFieldsContext, selector)\n\n/**\n * Get the state of all form fields.\n *\n * @see https://payloadcms.com/docs/admin/hooks#useallformfields\n */\nconst useAllFormFields = (): FormFieldsContextType => useFullContext(FormFieldsContext)\n\nexport {\n FormContext,\n FormFieldsContext,\n FormWatchContext,\n ModifiedContext,\n ProcessingContext,\n SubmittedContext,\n useAllFormFields,\n useForm,\n useFormFields,\n useFormModified,\n useFormProcessing,\n useFormSubmitted,\n useWatchForm,\n}\n"],"names":["createContext","useContext","createSelectorContext","useContextSelector","useFullContext","FormContext","FormWatchContext","SubmittedContext","ProcessingContext","ModifiedContext","FormFieldsContext","useForm","useWatchForm","useFormSubmitted","useFormProcessing","useFormModified","useFormFields","selector","useAllFormFields"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AACA,SAASA,aAAa,EAAEC,UAAU,QAAQ,QAAO;AACjD,SACED,iBAAiBE,qBAAqB,EACtCC,kBAAkB,EAClBF,cAAcG,cAAc,QACvB,uBAAsB;AAI7B,MAAMC,cAAcL,cAAc,CAAC;AACnC,MAAMM,mBAAmBN,cAAc,CAAC;AACxC,MAAMO,mBAAmBP,cAAc;AACvC,MAAMQ,oBAAoBR,cAAc;AACxC,MAAMS,kBAAkBT,cAAc;AACtC,MAAMU,oBAAoBR,sBAA6C;IAAC,CAAC;IAAG,IAAM;CAAK;AAEvF;;;;CAIC,GACD,MAAMS,UAAU,IAAeV,WAAWI;AAC1C,MAAMO,eAAe,IAAeX,WAAWK;AAC/C,MAAMO,mBAAmB,IAAeZ,WAAWM;AACnD,MAAMO,oBAAoB,IAAeb,WAAWO;AACpD,MAAMO,kBAAkB,IAAed,WAAWQ;AAElD;;;;CAIC,GACD,MAAMO,gBAAgB,CACpBC,WACUd,mBAAmBO,mBAAmBO;AAElD;;;;CAIC,GACD,MAAMC,mBAAmB,IAA6Bd,eAAeM;AAErE,SACEL,WAAW,EACXK,iBAAiB,EACjBJ,gBAAgB,EAChBG,eAAe,EACfD,iBAAiB,EACjBD,gBAAgB,EAChBW,gBAAgB,EAChBP,OAAO,EACPK,aAAa,EACbD,eAAe,EACfD,iBAAiB,EACjBD,gBAAgB,EAChBD,YAAY,KACb"}
1
+ {"version":3,"sources":["../../../src/forms/Form/context.ts"],"sourcesContent":["'use client'\nimport { createContext, useContext } from 'react'\nimport {\n createContext as createSelectorContext,\n useContextSelector,\n useContext as useFullContext,\n} from 'use-context-selector'\n\nimport type { Context, FormFieldsContext as FormFieldsContextType } from './types.js'\n\nconst FormContext = createContext({} as Context)\nconst FormWatchContext = createContext({} as Context)\nconst SubmittedContext = createContext(false)\nconst ProcessingContext = createContext(false)\nconst ModifiedContext = createContext(false)\nconst InitializingContext = createContext(false)\nconst FormFieldsContext = createSelectorContext<FormFieldsContextType>([{}, () => null])\n\n/**\n * Get the state of the form, can be used to submit & validate the form.\n *\n * @see https://payloadcms.com/docs/admin/hooks#useform\n */\nconst useForm = (): Context => useContext(FormContext)\nconst useWatchForm = (): Context => useContext(FormWatchContext)\nconst useFormSubmitted = (): boolean => useContext(SubmittedContext)\nconst useFormProcessing = (): boolean => useContext(ProcessingContext)\nconst useFormModified = (): boolean => useContext(ModifiedContext)\nconst useFormInitializing = (): boolean => useContext(InitializingContext)\n\n/**\n * Get and set the value of a form field based on a selector\n *\n * @see https://payloadcms.com/docs/admin/hooks#useformfields\n */\nconst useFormFields = <Value = unknown>(\n selector: (context: FormFieldsContextType) => Value,\n): Value => useContextSelector(FormFieldsContext, selector)\n\n/**\n * Get the state of all form fields.\n *\n * @see https://payloadcms.com/docs/admin/hooks#useallformfields\n */\nconst useAllFormFields = (): FormFieldsContextType => useFullContext(FormFieldsContext)\n\nexport {\n FormContext,\n FormFieldsContext,\n FormWatchContext,\n InitializingContext,\n ModifiedContext,\n ProcessingContext,\n SubmittedContext,\n useAllFormFields,\n useForm,\n useFormFields,\n useFormInitializing,\n useFormModified,\n useFormProcessing,\n useFormSubmitted,\n useWatchForm,\n}\n"],"names":["createContext","useContext","createSelectorContext","useContextSelector","useFullContext","FormContext","FormWatchContext","SubmittedContext","ProcessingContext","ModifiedContext","InitializingContext","FormFieldsContext","useForm","useWatchForm","useFormSubmitted","useFormProcessing","useFormModified","useFormInitializing","useFormFields","selector","useAllFormFields"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AACA,SAASA,aAAa,EAAEC,UAAU,QAAQ,QAAO;AACjD,SACED,iBAAiBE,qBAAqB,EACtCC,kBAAkB,EAClBF,cAAcG,cAAc,QACvB,uBAAsB;AAI7B,MAAMC,cAAcL,cAAc,CAAC;AACnC,MAAMM,mBAAmBN,cAAc,CAAC;AACxC,MAAMO,mBAAmBP,cAAc;AACvC,MAAMQ,oBAAoBR,cAAc;AACxC,MAAMS,kBAAkBT,cAAc;AACtC,MAAMU,sBAAsBV,cAAc;AAC1C,MAAMW,oBAAoBT,sBAA6C;IAAC,CAAC;IAAG,IAAM;CAAK;AAEvF;;;;CAIC,GACD,MAAMU,UAAU,IAAeX,WAAWI;AAC1C,MAAMQ,eAAe,IAAeZ,WAAWK;AAC/C,MAAMQ,mBAAmB,IAAeb,WAAWM;AACnD,MAAMQ,oBAAoB,IAAed,WAAWO;AACpD,MAAMQ,kBAAkB,IAAef,WAAWQ;AAClD,MAAMQ,sBAAsB,IAAehB,WAAWS;AAEtD;;;;CAIC,GACD,MAAMQ,gBAAgB,CACpBC,WACUhB,mBAAmBQ,mBAAmBQ;AAElD;;;;CAIC,GACD,MAAMC,mBAAmB,IAA6BhB,eAAeO;AAErE,SACEN,WAAW,EACXM,iBAAiB,EACjBL,gBAAgB,EAChBI,mBAAmB,EACnBD,eAAe,EACfD,iBAAiB,EACjBD,gBAAgB,EAChBa,gBAAgB,EAChBR,OAAO,EACPM,aAAa,EACbD,mBAAmB,EACnBD,eAAe,EACfD,iBAAiB,EACjBD,gBAAgB,EAChBD,YAAY,KACb"}
@@ -1 +1 @@
1
- {"version":3,"file":"getSiblingData.d.ts","sourceRoot":"","sources":["../../../src/forms/Form/getSiblingData.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAOpD,eAAO,MAAM,cAAc,WAAY,SAAS,QAAQ,MAAM,KAAG,IAgChE,CAAA"}
1
+ {"version":3,"file":"getSiblingData.d.ts","sourceRoot":"","sources":["../../../src/forms/Form/getSiblingData.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAOpD,eAAO,MAAM,cAAc,WAAY,SAAS,QAAQ,MAAM,KAAG,IAmChE,CAAA"}
@@ -2,6 +2,7 @@ import flatleyImport from 'flatley';
2
2
  const { unflatten } = flatleyImport;
3
3
  import { reduceFieldsToValues } from '../../utilities/reduceFieldsToValues.js';
4
4
  export const getSiblingData = (fields, path)=>{
5
+ if (!fields) return null;
5
6
  if (path.indexOf('.') === -1) {
6
7
  return reduceFieldsToValues(fields, true);
7
8
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/forms/Form/getSiblingData.ts"],"sourcesContent":["import type { Data, FormState } from 'payload/types'\n\nimport flatleyImport from 'flatley'\nconst { unflatten } = flatleyImport\n\nimport { reduceFieldsToValues } from '../../utilities/reduceFieldsToValues.js'\n\nexport const getSiblingData = (fields: FormState, path: string): Data => {\n if (path.indexOf('.') === -1) {\n return reduceFieldsToValues(fields, true)\n }\n const siblingFields = {}\n\n // Determine if the last segment of the path is an array-based row\n const pathSegments = path.split('.')\n const lastSegment = pathSegments[pathSegments.length - 1]\n const lastSegmentIsRowIndex = !Number.isNaN(Number(lastSegment))\n\n let parentFieldPath: string\n\n if (lastSegmentIsRowIndex) {\n // If the last segment is a row index,\n // the sibling data is that row's contents\n // so create a parent field path that will\n // retrieve all contents of that row index only\n parentFieldPath = `${path}.`\n } else {\n // Otherwise, the last path segment is a field name\n // and it should be removed\n parentFieldPath = path.substring(0, path.lastIndexOf('.') + 1)\n }\n\n Object.keys(fields).forEach((fieldKey) => {\n if (!fields[fieldKey].disableFormData && fieldKey.indexOf(parentFieldPath) === 0) {\n siblingFields[fieldKey.replace(parentFieldPath, '')] = fields[fieldKey].value\n }\n })\n\n return unflatten(siblingFields, { safe: true })\n}\n"],"names":["flatleyImport","unflatten","reduceFieldsToValues","getSiblingData","fields","path","indexOf","siblingFields","pathSegments","split","lastSegment","length","lastSegmentIsRowIndex","Number","isNaN","parentFieldPath","substring","lastIndexOf","Object","keys","forEach","fieldKey","disableFormData","replace","value","safe"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAEA,OAAOA,mBAAmB,UAAS;AACnC,MAAM,EAAEC,SAAS,EAAE,GAAGD;AAEtB,SAASE,oBAAoB,QAAQ,0CAAyC;AAE9E,OAAO,MAAMC,iBAAiB,CAACC,QAAmBC;IAChD,IAAIA,KAAKC,OAAO,CAAC,SAAS,CAAC,GAAG;QAC5B,OAAOJ,qBAAqBE,QAAQ;IACtC;IACA,MAAMG,gBAAgB,CAAC;IAEvB,kEAAkE;IAClE,MAAMC,eAAeH,KAAKI,KAAK,CAAC;IAChC,MAAMC,cAAcF,YAAY,CAACA,aAAaG,MAAM,GAAG,EAAE;IACzD,MAAMC,wBAAwB,CAACC,OAAOC,KAAK,CAACD,OAAOH;IAEnD,IAAIK;IAEJ,IAAIH,uBAAuB;QACzB,sCAAsC;QACtC,0CAA0C;QAC1C,0CAA0C;QAC1C,+CAA+C;QAC/CG,kBAAkB,CAAC,EAAEV,KAAK,CAAC,CAAC;IAC9B,OAAO;QACL,mDAAmD;QACnD,2BAA2B;QAC3BU,kBAAkBV,KAAKW,SAAS,CAAC,GAAGX,KAAKY,WAAW,CAAC,OAAO;IAC9D;IAEAC,OAAOC,IAAI,CAACf,QAAQgB,OAAO,CAAC,CAACC;QAC3B,IAAI,CAACjB,MAAM,CAACiB,SAAS,CAACC,eAAe,IAAID,SAASf,OAAO,CAACS,qBAAqB,GAAG;YAChFR,aAAa,CAACc,SAASE,OAAO,CAACR,iBAAiB,IAAI,GAAGX,MAAM,CAACiB,SAAS,CAACG,KAAK;QAC/E;IACF;IAEA,OAAOvB,UAAUM,eAAe;QAAEkB,MAAM;IAAK;AAC/C,EAAC"}
1
+ {"version":3,"sources":["../../../src/forms/Form/getSiblingData.ts"],"sourcesContent":["import type { Data, FormState } from 'payload/types'\n\nimport flatleyImport from 'flatley'\nconst { unflatten } = flatleyImport\n\nimport { reduceFieldsToValues } from '../../utilities/reduceFieldsToValues.js'\n\nexport const getSiblingData = (fields: FormState, path: string): Data => {\n if (!fields) return null\n\n if (path.indexOf('.') === -1) {\n return reduceFieldsToValues(fields, true)\n }\n\n const siblingFields = {}\n\n // Determine if the last segment of the path is an array-based row\n const pathSegments = path.split('.')\n const lastSegment = pathSegments[pathSegments.length - 1]\n const lastSegmentIsRowIndex = !Number.isNaN(Number(lastSegment))\n\n let parentFieldPath: string\n\n if (lastSegmentIsRowIndex) {\n // If the last segment is a row index,\n // the sibling data is that row's contents\n // so create a parent field path that will\n // retrieve all contents of that row index only\n parentFieldPath = `${path}.`\n } else {\n // Otherwise, the last path segment is a field name\n // and it should be removed\n parentFieldPath = path.substring(0, path.lastIndexOf('.') + 1)\n }\n\n Object.keys(fields).forEach((fieldKey) => {\n if (!fields[fieldKey].disableFormData && fieldKey.indexOf(parentFieldPath) === 0) {\n siblingFields[fieldKey.replace(parentFieldPath, '')] = fields[fieldKey].value\n }\n })\n\n return unflatten(siblingFields, { safe: true })\n}\n"],"names":["flatleyImport","unflatten","reduceFieldsToValues","getSiblingData","fields","path","indexOf","siblingFields","pathSegments","split","lastSegment","length","lastSegmentIsRowIndex","Number","isNaN","parentFieldPath","substring","lastIndexOf","Object","keys","forEach","fieldKey","disableFormData","replace","value","safe"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAEA,OAAOA,mBAAmB,UAAS;AACnC,MAAM,EAAEC,SAAS,EAAE,GAAGD;AAEtB,SAASE,oBAAoB,QAAQ,0CAAyC;AAE9E,OAAO,MAAMC,iBAAiB,CAACC,QAAmBC;IAChD,IAAI,CAACD,QAAQ,OAAO;IAEpB,IAAIC,KAAKC,OAAO,CAAC,SAAS,CAAC,GAAG;QAC5B,OAAOJ,qBAAqBE,QAAQ;IACtC;IAEA,MAAMG,gBAAgB,CAAC;IAEvB,kEAAkE;IAClE,MAAMC,eAAeH,KAAKI,KAAK,CAAC;IAChC,MAAMC,cAAcF,YAAY,CAACA,aAAaG,MAAM,GAAG,EAAE;IACzD,MAAMC,wBAAwB,CAACC,OAAOC,KAAK,CAACD,OAAOH;IAEnD,IAAIK;IAEJ,IAAIH,uBAAuB;QACzB,sCAAsC;QACtC,0CAA0C;QAC1C,0CAA0C;QAC1C,+CAA+C;QAC/CG,kBAAkB,CAAC,EAAEV,KAAK,CAAC,CAAC;IAC9B,OAAO;QACL,mDAAmD;QACnD,2BAA2B;QAC3BU,kBAAkBV,KAAKW,SAAS,CAAC,GAAGX,KAAKY,WAAW,CAAC,OAAO;IAC9D;IAEAC,OAAOC,IAAI,CAACf,QAAQgB,OAAO,CAAC,CAACC;QAC3B,IAAI,CAACjB,MAAM,CAACiB,SAAS,CAACC,eAAe,IAAID,SAASf,OAAO,CAACS,qBAAqB,GAAG;YAChFR,aAAa,CAACc,SAASE,OAAO,CAACR,iBAAiB,IAAI,GAAGX,MAAM,CAACiB,SAAS,CAACG,KAAK;QAC/E;IACF;IAEA,OAAOvB,UAAUM,eAAe;QAAEkB,MAAM;IAAK;AAC/C,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/forms/Form/index.tsx"],"names":[],"mappings":"AASA,OAAO,KAA+D,MAAM,OAAO,CAAA;AAGnF,OAAO,KAAK,EAEV,SAAS,EAGV,MAAM,YAAY,CAAA;AA+BnB,eAAO,MAAM,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC,SAAS,CAmjBpC,CAAA;AAED,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EAChB,OAAO,EACP,aAAa,EACb,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,YAAY,GACb,MAAM,cAAc,CAAA;AAErB,OAAO,EAAE,SAAS,EAAE,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/forms/Form/index.tsx"],"names":[],"mappings":"AASA,OAAO,KAA+D,MAAM,OAAO,CAAA;AAGnF,OAAO,KAAK,EAEV,SAAS,EAGV,MAAM,YAAY,CAAA;AAgCnB,eAAO,MAAM,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC,SAAS,CAokBpC,CAAA;AAED,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EAChB,OAAO,EACP,aAAa,EACb,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,YAAY,GACb,MAAM,cAAc,CAAA;AAErB,OAAO,EAAE,SAAS,EAAE,CAAA"}
@@ -19,7 +19,7 @@ import { useTranslation } from '../../providers/Translation/index.js';
19
19
  import { requests } from '../../utilities/api.js';
20
20
  import { getFormState } from '../../utilities/getFormState.js';
21
21
  import { reduceFieldsToValues } from '../../utilities/reduceFieldsToValues.js';
22
- import { FormContext, FormFieldsContext, FormWatchContext, ModifiedContext, ProcessingContext, SubmittedContext } from './context.js';
22
+ import { FormContext, FormFieldsContext, FormWatchContext, InitializingContext, ModifiedContext, ProcessingContext, SubmittedContext } from './context.js';
23
23
  import { errorMessages } from './errorMessages.js';
24
24
  import { fieldReducer } from './fieldReducer.js';
25
25
  import { getDataByPath as getDataByPathFunc } from './getDataByPath.js';
@@ -30,7 +30,7 @@ const baseClass = 'form';
30
30
  export const Form = (props)=>{
31
31
  const { id, collectionSlug, globalSlug } = useDocumentInfo();
32
32
  const { action, beforeSubmit, children, className, disableSuccessStatus, disableValidationOnSubmit, disabled: disabledFromProps, // fields: fieldsFromProps = collection?.fields || global?.fields,
33
- handleResponse, initialState, onChange, onSubmit, onSuccess, redirect, submitted: submittedFromProps, uuid, waitForAutocomplete } = props;
33
+ handleResponse, initialState, isInitializing: initializingFromProps, onChange, onSubmit, onSuccess, redirect, submitted: submittedFromProps, uuid, waitForAutocomplete } = props;
34
34
  const method = 'method' in props ? props?.method : undefined;
35
35
  const router = useRouter();
36
36
  const { code: locale } = useLocale();
@@ -41,7 +41,9 @@ export const Form = (props)=>{
41
41
  const config = useConfig();
42
42
  const { routes: { api: apiRoute }, serverURL } = config;
43
43
  const [disabled, setDisabled] = useState(disabledFromProps || false);
44
+ const [isMounted, setIsMounted] = useState(false);
44
45
  const [modified, setModified] = useState(false);
46
+ const [initializing, setInitializing] = useState(initializingFromProps);
45
47
  const [processing, setProcessing] = useState(false);
46
48
  const [submitted, setSubmitted] = useState(false);
47
49
  const formRef = useRef(null);
@@ -403,9 +405,11 @@ export const Form = (props)=>{
403
405
  dispatchFields
404
406
  ]);
405
407
  useEffect(()=>{
406
- if (typeof disabledFromProps === 'boolean') setDisabled(disabledFromProps);
408
+ if (initializingFromProps !== undefined) {
409
+ setInitializing(initializingFromProps);
410
+ }
407
411
  }, [
408
- disabledFromProps
412
+ initializingFromProps
409
413
  ]);
410
414
  contextRef.current.submit = submit;
411
415
  contextRef.current.getFields = getFields;
@@ -428,6 +432,15 @@ export const Form = (props)=>{
428
432
  contextRef.current.removeFieldRow = removeFieldRow;
429
433
  contextRef.current.replaceFieldRow = replaceFieldRow;
430
434
  contextRef.current.uuid = uuid;
435
+ contextRef.current.initializing = initializing;
436
+ useEffect(()=>{
437
+ setIsMounted(true);
438
+ }, []);
439
+ useEffect(()=>{
440
+ if (typeof disabledFromProps === 'boolean') setDisabled(disabledFromProps);
441
+ }, [
442
+ disabledFromProps
443
+ ]);
431
444
  useEffect(()=>{
432
445
  if (typeof submittedFromProps === 'boolean') setSubmitted(submittedFromProps);
433
446
  }, [
@@ -440,6 +453,7 @@ export const Form = (props)=>{
440
453
  };
441
454
  dispatchFields({
442
455
  type: 'REPLACE_STATE',
456
+ optimize: false,
443
457
  state: initialState
444
458
  });
445
459
  }
@@ -512,13 +526,16 @@ export const Form = (props)=>{
512
526
  },
513
527
  children: /*#__PURE__*/ _jsx(SubmittedContext.Provider, {
514
528
  value: submitted,
515
- children: /*#__PURE__*/ _jsx(ProcessingContext.Provider, {
516
- value: processing,
517
- children: /*#__PURE__*/ _jsx(ModifiedContext.Provider, {
518
- value: modified,
519
- children: /*#__PURE__*/ _jsx(FormFieldsContext.Provider, {
520
- value: fieldsReducer,
521
- children: children
529
+ children: /*#__PURE__*/ _jsx(InitializingContext.Provider, {
530
+ value: !isMounted || isMounted && initializing,
531
+ children: /*#__PURE__*/ _jsx(ProcessingContext.Provider, {
532
+ value: processing,
533
+ children: /*#__PURE__*/ _jsx(ModifiedContext.Provider, {
534
+ value: modified,
535
+ children: /*#__PURE__*/ _jsx(FormFieldsContext.Provider, {
536
+ value: fieldsReducer,
537
+ children: children
538
+ })
522
539
  })
523
540
  })
524
541
  })
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/forms/Form/index.tsx"],"sourcesContent":["'use client'\nimport type { FormState } from 'payload/types'\n\n/* eslint-disable jsx-a11y/no-noninteractive-element-interactions */\nimport isDeepEqual from 'deep-equal'\nimport { useRouter } from 'next/navigation.js'\nimport { serialize } from 'object-to-formdata'\nimport { wait } from 'payload/utilities'\nimport QueryString from 'qs'\nimport React, { useCallback, useEffect, useReducer, useRef, useState } from 'react'\nimport { toast } from 'react-toastify'\n\nimport type {\n Context as FormContextType,\n FormProps,\n GetDataByPath,\n SubmitOptions,\n} from './types.js'\n\nimport { useDebouncedEffect } from '../../hooks/useDebouncedEffect.js'\nimport useThrottledEffect from '../../hooks/useThrottledEffect.js'\nimport { useAuth } from '../../providers/Auth/index.js'\nimport { useConfig } from '../../providers/Config/index.js'\nimport { useDocumentInfo } from '../../providers/DocumentInfo/index.js'\nimport { useFormQueryParams } from '../../providers/FormQueryParams/index.js'\nimport { useLocale } from '../../providers/Locale/index.js'\nimport { useOperation } from '../../providers/Operation/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { requests } from '../../utilities/api.js'\nimport { getFormState } from '../../utilities/getFormState.js'\nimport { reduceFieldsToValues } from '../../utilities/reduceFieldsToValues.js'\nimport {\n FormContext,\n FormFieldsContext,\n FormWatchContext,\n ModifiedContext,\n ProcessingContext,\n SubmittedContext,\n} from './context.js'\nimport { errorMessages } from './errorMessages.js'\nimport { fieldReducer } from './fieldReducer.js'\nimport { getDataByPath as getDataByPathFunc } from './getDataByPath.js'\nimport { getSiblingData as getSiblingDataFunc } from './getSiblingData.js'\nimport { initContextState } from './initContextState.js'\nimport { mergeServerFormState } from './mergeServerFormState.js'\n\nconst baseClass = 'form'\n\nexport const Form: React.FC<FormProps> = (props) => {\n const { id, collectionSlug, globalSlug } = useDocumentInfo()\n\n const {\n action,\n beforeSubmit,\n children,\n className,\n disableSuccessStatus,\n disableValidationOnSubmit,\n disabled: disabledFromProps,\n // fields: fieldsFromProps = collection?.fields || global?.fields,\n handleResponse,\n initialState, // fully formed initial field state\n onChange,\n onSubmit,\n onSuccess,\n redirect,\n submitted: submittedFromProps,\n uuid,\n waitForAutocomplete,\n } = props\n\n const method = 'method' in props ? props?.method : undefined\n\n const router = useRouter()\n\n const { code: locale } = useLocale()\n const { i18n, t } = useTranslation()\n const { refreshCookie, user } = useAuth()\n const operation = useOperation()\n const { formQueryParams } = useFormQueryParams()\n\n const config = useConfig()\n const {\n routes: { api: apiRoute },\n serverURL,\n } = config\n\n const [disabled, setDisabled] = useState(disabledFromProps || false)\n const [modified, setModified] = useState(false)\n const [processing, setProcessing] = useState(false)\n const [submitted, setSubmitted] = useState(false)\n const formRef = useRef<HTMLFormElement>(null)\n const contextRef = useRef({} as FormContextType)\n\n const fieldsReducer = useReducer(fieldReducer, {}, () => initialState)\n /**\n * `fields` is the current, up-to-date state/data of all fields in the form. It can be modified by using dispatchFields,\n * which calls the fieldReducer, which then updates the state.\n */\n const [fields, dispatchFields] = fieldsReducer\n\n contextRef.current.fields = fields\n\n const validateForm = useCallback(async () => {\n const validatedFieldState = {}\n let isValid = true\n\n const dataFromContext = contextRef.current.getData()\n const data = dataFromContext\n\n const validationPromises = Object.entries(contextRef.current.fields).map(\n async ([path, field]) => {\n const validatedField = field\n\n if (field.passesCondition !== false) {\n let validationResult: boolean | string = validatedField.valid\n\n if (typeof field.validate === 'function') {\n let valueToValidate = field.value\n\n if (field?.rows && Array.isArray(field.rows)) {\n valueToValidate = contextRef.current.getDataByPath(path)\n }\n\n validationResult = await field.validate(valueToValidate, {\n id,\n config,\n data,\n operation,\n siblingData: contextRef.current.getSiblingData(path),\n t,\n user,\n })\n\n if (typeof validationResult === 'string') {\n validatedField.errorMessage = validationResult\n validatedField.valid = false\n } else {\n validatedField.valid = true\n validatedField.errorMessage = undefined\n }\n }\n\n if (validatedField.valid === false) {\n isValid = false\n }\n }\n\n validatedFieldState[path] = validatedField\n },\n )\n\n await Promise.all(validationPromises)\n\n if (!isDeepEqual(contextRef.current.fields, validatedFieldState)) {\n dispatchFields({ type: 'REPLACE_STATE', state: validatedFieldState })\n }\n\n return isValid\n }, [id, user, operation, t, dispatchFields, config])\n\n const submit = useCallback(\n async (options: SubmitOptions = {}, e): Promise<void> => {\n const {\n action: actionArg,\n method: methodToUse = method,\n overrides = {},\n skipValidation,\n } = options\n\n if (disabled) {\n if (e) {\n e.preventDefault()\n }\n return\n }\n\n if (e) {\n e.stopPropagation()\n e.preventDefault()\n }\n\n setProcessing(true)\n setDisabled(true)\n\n if (waitForAutocomplete) await wait(100)\n\n // Execute server side validations\n if (Array.isArray(beforeSubmit)) {\n let revalidatedFormState: FormState\n\n await beforeSubmit.reduce(async (priorOnChange, beforeSubmitFn) => {\n await priorOnChange\n\n const result = await beforeSubmitFn({\n formState: fields,\n })\n\n revalidatedFormState = result\n }, Promise.resolve())\n\n const isValid = Object.entries(revalidatedFormState).every(([, field]) => field.valid)\n\n if (!isValid) {\n setProcessing(false)\n setSubmitted(true)\n setDisabled(false)\n return dispatchFields({ type: 'REPLACE_STATE', state: revalidatedFormState })\n }\n }\n\n const isValid =\n skipValidation || disableValidationOnSubmit ? true : await contextRef.current.validateForm()\n\n // If not valid, prevent submission\n if (!isValid) {\n toast.error(t('error:correctInvalidFields'))\n setProcessing(false)\n setSubmitted(true)\n setDisabled(false)\n return\n }\n\n // If submit handler comes through via props, run that\n if (onSubmit) {\n const data = {\n ...reduceFieldsToValues(fields, true),\n ...overrides,\n }\n\n onSubmit(fields, data)\n }\n\n const formData = contextRef.current.createFormData(overrides)\n\n try {\n let res\n const actionEndpoint =\n actionArg ||\n (typeof action === 'string'\n ? `${action}${QueryString.stringify(formQueryParams, { addQueryPrefix: true })}`\n : null)\n\n if (actionEndpoint) {\n res = await requests[methodToUse.toLowerCase()](actionEndpoint, {\n body: formData,\n headers: {\n 'Accept-Language': i18n.language,\n },\n })\n } else if (typeof action === 'function') {\n res = await action(formData)\n }\n\n setModified(false)\n setDisabled(false)\n\n if (typeof handleResponse === 'function') {\n handleResponse(res)\n return\n }\n\n const contentType = res.headers.get('content-type')\n const isJSON = contentType && contentType.indexOf('application/json') !== -1\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let json: Record<string, any> = {}\n\n if (isJSON) json = await res.json()\n\n if (res.status < 400) {\n if (typeof onSuccess === 'function') await onSuccess(json)\n setSubmitted(false)\n setProcessing(false)\n\n if (redirect) {\n router.push(redirect)\n } else if (!disableSuccessStatus) {\n toast.success(json.message || t('general:submissionSuccessful'), { autoClose: 3000 })\n }\n } else {\n setProcessing(false)\n setSubmitted(true)\n\n contextRef.current = { ...contextRef.current } // triggers rerender of all components that subscribe to form\n if (json.message) {\n toast.error(json.message)\n\n return\n }\n\n if (Array.isArray(json.errors)) {\n const [fieldErrors, nonFieldErrors] = json.errors.reduce(\n ([fieldErrs, nonFieldErrs], err) => {\n const newFieldErrs = []\n const newNonFieldErrs = []\n\n if (err?.message) {\n newNonFieldErrs.push(err)\n }\n\n if (Array.isArray(err?.data)) {\n err.data.forEach((dataError) => {\n if (dataError?.field) {\n newFieldErrs.push(dataError)\n } else {\n newNonFieldErrs.push(dataError)\n }\n })\n }\n\n return [\n [...fieldErrs, ...newFieldErrs],\n [...nonFieldErrs, ...newNonFieldErrs],\n ]\n },\n [[], []],\n )\n\n dispatchFields({\n type: 'ADD_SERVER_ERRORS',\n errors: fieldErrors,\n })\n\n nonFieldErrors.forEach((err) => {\n toast.error(err.message || t('error:unknown'))\n })\n\n return\n }\n\n const message = errorMessages?.[res.status] || res?.statusText || t('error:unknown')\n\n toast.error(message)\n }\n } catch (err) {\n setProcessing(false)\n setSubmitted(true)\n setDisabled(false)\n\n toast.error(err)\n }\n },\n [\n beforeSubmit,\n action,\n disableSuccessStatus,\n disableValidationOnSubmit,\n disabled,\n dispatchFields,\n fields,\n handleResponse,\n method,\n onSubmit,\n onSuccess,\n redirect,\n router,\n t,\n i18n,\n waitForAutocomplete,\n formQueryParams,\n ],\n )\n\n const getFields = useCallback(() => contextRef.current.fields, [])\n\n const getField = useCallback((path: string) => contextRef.current.fields[path], [])\n\n const getData = useCallback(() => reduceFieldsToValues(contextRef.current.fields, true), [])\n\n const getSiblingData = useCallback(\n (path: string) => getSiblingDataFunc(contextRef.current.fields, path),\n [],\n )\n const getDataByPath = useCallback<GetDataByPath>(\n (path: string) => getDataByPathFunc(contextRef.current.fields, path),\n [],\n )\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const createFormData = useCallback((overrides: any = {}) => {\n const data = reduceFieldsToValues(contextRef.current.fields, true)\n\n const file = data?.file\n\n if (file) {\n delete data.file\n }\n\n const dataWithOverrides = {\n ...data,\n ...overrides,\n }\n\n const dataToSerialize = {\n _payload: JSON.stringify(dataWithOverrides),\n file,\n }\n\n // nullAsUndefineds is important to allow uploads and relationship fields to clear themselves\n const formData = serialize(dataToSerialize, { indices: true, nullsAsUndefineds: false })\n\n return formData\n }, [])\n\n const reset = useCallback(\n async (data: unknown) => {\n const newState = await getFormState({\n apiRoute,\n body: {\n id,\n collectionSlug,\n data,\n globalSlug,\n operation,\n schemaPath: collectionSlug || globalSlug,\n },\n serverURL,\n })\n\n contextRef.current = { ...initContextState } as FormContextType\n setModified(false)\n dispatchFields({ type: 'REPLACE_STATE', state: newState })\n },\n [apiRoute, collectionSlug, dispatchFields, globalSlug, id, operation, serverURL],\n )\n\n const replaceState = useCallback(\n (state: FormState) => {\n contextRef.current = { ...initContextState } as FormContextType\n setModified(false)\n dispatchFields({ type: 'REPLACE_STATE', state })\n },\n [dispatchFields],\n )\n\n const getFieldStateBySchemaPath = useCallback(\n async ({ data, schemaPath }) => {\n const fieldSchema = await getFormState({\n apiRoute,\n body: {\n collectionSlug,\n data,\n globalSlug,\n schemaPath,\n },\n serverURL,\n })\n return fieldSchema\n },\n [apiRoute, collectionSlug, globalSlug, serverURL],\n )\n\n const addFieldRow: FormContextType['addFieldRow'] = useCallback(\n async ({ data, path, rowIndex, schemaPath }) => {\n const subFieldState = await getFieldStateBySchemaPath({ data, schemaPath })\n\n dispatchFields({\n type: 'ADD_ROW',\n blockType: data?.blockType,\n path,\n rowIndex,\n subFieldState,\n })\n },\n [getFieldStateBySchemaPath, dispatchFields],\n )\n\n const removeFieldRow: FormContextType['removeFieldRow'] = useCallback(\n ({ path, rowIndex }) => {\n dispatchFields({ type: 'REMOVE_ROW', path, rowIndex })\n },\n [dispatchFields],\n )\n\n const replaceFieldRow: FormContextType['replaceFieldRow'] = useCallback(\n async ({ data, path, rowIndex, schemaPath }) => {\n const subFieldState = await getFieldStateBySchemaPath({ data, schemaPath })\n\n dispatchFields({\n type: 'REPLACE_ROW',\n blockType: data?.blockType,\n path,\n rowIndex,\n subFieldState,\n })\n },\n [getFieldStateBySchemaPath, dispatchFields],\n )\n\n useEffect(() => {\n if (typeof disabledFromProps === 'boolean') setDisabled(disabledFromProps)\n }, [disabledFromProps])\n\n contextRef.current.submit = submit\n contextRef.current.getFields = getFields\n contextRef.current.getField = getField\n contextRef.current.getData = getData\n contextRef.current.getSiblingData = getSiblingData\n contextRef.current.getDataByPath = getDataByPath\n contextRef.current.validateForm = validateForm\n contextRef.current.createFormData = createFormData\n contextRef.current.setModified = setModified\n contextRef.current.setProcessing = setProcessing\n contextRef.current.setSubmitted = setSubmitted\n contextRef.current.disabled = disabled\n contextRef.current.setDisabled = setDisabled\n contextRef.current.formRef = formRef\n contextRef.current.reset = reset\n contextRef.current.replaceState = replaceState\n contextRef.current.dispatchFields = dispatchFields\n contextRef.current.addFieldRow = addFieldRow\n contextRef.current.removeFieldRow = removeFieldRow\n contextRef.current.replaceFieldRow = replaceFieldRow\n contextRef.current.uuid = uuid\n\n useEffect(() => {\n if (typeof submittedFromProps === 'boolean') setSubmitted(submittedFromProps)\n }, [submittedFromProps])\n\n useEffect(() => {\n if (initialState) {\n contextRef.current = { ...initContextState } as FormContextType\n dispatchFields({ type: 'REPLACE_STATE', state: initialState })\n }\n }, [initialState, dispatchFields])\n\n useThrottledEffect(\n () => {\n refreshCookie()\n },\n 15000,\n [fields],\n )\n\n useEffect(() => {\n contextRef.current = { ...contextRef.current } // triggers rerender of all components that subscribe to form\n setModified(false)\n }, [locale])\n\n const classes = [className, baseClass].filter(Boolean).join(' ')\n\n useDebouncedEffect(\n () => {\n const executeOnChange = async () => {\n if (Array.isArray(onChange)) {\n let revalidatedFormState: FormState = contextRef.current.fields\n\n for (const onChangeFn of onChange) {\n revalidatedFormState = await onChangeFn({\n formState: revalidatedFormState,\n })\n }\n\n const { changed, newState } = mergeServerFormState(\n contextRef.current.fields || {},\n revalidatedFormState,\n )\n\n if (changed) {\n dispatchFields({\n type: 'REPLACE_STATE',\n optimize: false,\n state: newState,\n })\n }\n }\n }\n\n if (modified) void executeOnChange()\n },\n 150,\n // Make sure we trigger this whenever modified changes (not just when `fields` changes), otherwise we will miss merging server form state for the first form update/onChange. Here's why:\n // `fields` updates before `modified`, because setModified is in a setTimeout. So on the first change, modified is false, so we don't trigger the effect even though we should.\n [contextRef.current.fields, dispatchFields, onChange, modified],\n )\n\n const actionString =\n typeof action === 'string'\n ? `${action}${QueryString.stringify(formQueryParams, { addQueryPrefix: true })}`\n : ''\n\n return (\n <form\n action={method ? actionString : (action as string)}\n className={classes}\n method={method}\n noValidate\n onSubmit={(e) => contextRef.current.submit({}, e)}\n ref={formRef}\n >\n <FormContext.Provider value={contextRef.current}>\n <FormWatchContext.Provider\n value={{\n fields,\n ...contextRef.current,\n }}\n >\n <SubmittedContext.Provider value={submitted}>\n <ProcessingContext.Provider value={processing}>\n <ModifiedContext.Provider value={modified}>\n <FormFieldsContext.Provider value={fieldsReducer}>\n {children}\n </FormFieldsContext.Provider>\n </ModifiedContext.Provider>\n </ProcessingContext.Provider>\n </SubmittedContext.Provider>\n </FormWatchContext.Provider>\n </FormContext.Provider>\n </form>\n )\n}\n\nexport {\n FormContext,\n FormFieldsContext,\n FormWatchContext,\n ModifiedContext,\n ProcessingContext,\n SubmittedContext,\n useAllFormFields,\n useForm,\n useFormFields,\n useFormModified,\n useFormProcessing,\n useFormSubmitted,\n useWatchForm,\n} from './context.js'\n\nexport { FormProps }\n"],"names":["isDeepEqual","useRouter","serialize","wait","QueryString","React","useCallback","useEffect","useReducer","useRef","useState","toast","useDebouncedEffect","useThrottledEffect","useAuth","useConfig","useDocumentInfo","useFormQueryParams","useLocale","useOperation","useTranslation","requests","getFormState","reduceFieldsToValues","FormContext","FormFieldsContext","FormWatchContext","ModifiedContext","ProcessingContext","SubmittedContext","errorMessages","fieldReducer","getDataByPath","getDataByPathFunc","getSiblingData","getSiblingDataFunc","initContextState","mergeServerFormState","baseClass","Form","props","id","collectionSlug","globalSlug","action","beforeSubmit","children","className","disableSuccessStatus","disableValidationOnSubmit","disabled","disabledFromProps","handleResponse","initialState","onChange","onSubmit","onSuccess","redirect","submitted","submittedFromProps","uuid","waitForAutocomplete","method","undefined","router","code","locale","i18n","t","refreshCookie","user","operation","formQueryParams","config","routes","api","apiRoute","serverURL","setDisabled","modified","setModified","processing","setProcessing","setSubmitted","formRef","contextRef","fieldsReducer","fields","dispatchFields","current","validateForm","validatedFieldState","isValid","dataFromContext","getData","data","validationPromises","Object","entries","map","path","field","validatedField","passesCondition","validationResult","valid","validate","valueToValidate","value","rows","Array","isArray","siblingData","errorMessage","Promise","all","type","state","submit","options","e","actionArg","methodToUse","overrides","skipValidation","preventDefault","stopPropagation","revalidatedFormState","reduce","priorOnChange","beforeSubmitFn","result","formState","resolve","every","error","formData","createFormData","res","actionEndpoint","stringify","addQueryPrefix","toLowerCase","body","headers","language","contentType","get","isJSON","indexOf","json","status","push","success","message","autoClose","errors","fieldErrors","nonFieldErrors","fieldErrs","nonFieldErrs","err","newFieldErrs","newNonFieldErrs","forEach","dataError","statusText","getFields","getField","file","dataWithOverrides","dataToSerialize","_payload","JSON","indices","nullsAsUndefineds","reset","newState","schemaPath","replaceState","getFieldStateBySchemaPath","fieldSchema","addFieldRow","rowIndex","subFieldState","blockType","removeFieldRow","replaceFieldRow","classes","filter","Boolean","join","executeOnChange","onChangeFn","changed","optimize","actionString","form","noValidate","ref","Provider","useAllFormFields","useForm","useFormFields","useFormModified","useFormProcessing","useFormSubmitted","useWatchForm"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;;AAGA,kEAAkE,GAClE,OAAOA,iBAAiB,aAAY;AACpC,SAASC,SAAS,QAAQ,qBAAoB;AAC9C,SAASC,SAAS,QAAQ,qBAAoB;AAC9C,SAASC,IAAI,QAAQ,oBAAmB;AACxC,OAAOC,iBAAiB,KAAI;AAC5B,OAAOC,SA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EACXC,iBAAiB,EACjBC,gBAAgB,EAChBC,eAAe,EACfC,iBAAiB,EACjBC,gBAAgB,EAChB4K,gBAAgB,EAChBC,OAAO,EACPC,aAAa,EACbC,eAAe,EACfC,iBAAiB,EACjBC,gBAAgB,EAChBC,YAAY,QACP,eAAc"}
1
+ {"version":3,"sources":["../../../src/forms/Form/index.tsx"],"sourcesContent":["'use client'\nimport type { FormState } from 'payload/types'\n\n/* eslint-disable jsx-a11y/no-noninteractive-element-interactions */\nimport isDeepEqual from 'deep-equal'\nimport { useRouter } from 'next/navigation.js'\nimport { serialize } from 'object-to-formdata'\nimport { wait } from 'payload/utilities'\nimport QueryString from 'qs'\nimport React, { useCallback, useEffect, useReducer, useRef, useState } from 'react'\nimport { toast } from 'react-toastify'\n\nimport type {\n Context as FormContextType,\n FormProps,\n GetDataByPath,\n SubmitOptions,\n} from './types.js'\n\nimport { useDebouncedEffect } from '../../hooks/useDebouncedEffect.js'\nimport useThrottledEffect from '../../hooks/useThrottledEffect.js'\nimport { useAuth } from '../../providers/Auth/index.js'\nimport { useConfig } from '../../providers/Config/index.js'\nimport { useDocumentInfo } from '../../providers/DocumentInfo/index.js'\nimport { useFormQueryParams } from '../../providers/FormQueryParams/index.js'\nimport { useLocale } from '../../providers/Locale/index.js'\nimport { useOperation } from '../../providers/Operation/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { requests } from '../../utilities/api.js'\nimport { getFormState } from '../../utilities/getFormState.js'\nimport { reduceFieldsToValues } from '../../utilities/reduceFieldsToValues.js'\nimport {\n FormContext,\n FormFieldsContext,\n FormWatchContext,\n InitializingContext,\n ModifiedContext,\n ProcessingContext,\n SubmittedContext,\n} from './context.js'\nimport { errorMessages } from './errorMessages.js'\nimport { fieldReducer } from './fieldReducer.js'\nimport { getDataByPath as getDataByPathFunc } from './getDataByPath.js'\nimport { getSiblingData as getSiblingDataFunc } from './getSiblingData.js'\nimport { initContextState } from './initContextState.js'\nimport { mergeServerFormState } from './mergeServerFormState.js'\n\nconst baseClass = 'form'\n\nexport const Form: React.FC<FormProps> = (props) => {\n const { id, collectionSlug, globalSlug } = useDocumentInfo()\n\n const {\n action,\n beforeSubmit,\n children,\n className,\n disableSuccessStatus,\n disableValidationOnSubmit,\n disabled: disabledFromProps,\n // fields: fieldsFromProps = collection?.fields || global?.fields,\n handleResponse,\n initialState, // fully formed initial field state\n isInitializing: initializingFromProps,\n onChange,\n onSubmit,\n onSuccess,\n redirect,\n submitted: submittedFromProps,\n uuid,\n waitForAutocomplete,\n } = props\n\n const method = 'method' in props ? props?.method : undefined\n\n const router = useRouter()\n\n const { code: locale } = useLocale()\n const { i18n, t } = useTranslation()\n const { refreshCookie, user } = useAuth()\n const operation = useOperation()\n const { formQueryParams } = useFormQueryParams()\n\n const config = useConfig()\n const {\n routes: { api: apiRoute },\n serverURL,\n } = config\n\n const [disabled, setDisabled] = useState(disabledFromProps || false)\n const [isMounted, setIsMounted] = useState(false)\n const [modified, setModified] = useState(false)\n const [initializing, setInitializing] = useState(initializingFromProps)\n const [processing, setProcessing] = useState(false)\n const [submitted, setSubmitted] = useState(false)\n const formRef = useRef<HTMLFormElement>(null)\n const contextRef = useRef({} as FormContextType)\n\n const fieldsReducer = useReducer(fieldReducer, {}, () => initialState)\n\n /**\n * `fields` is the current, up-to-date state/data of all fields in the form. It can be modified by using dispatchFields,\n * which calls the fieldReducer, which then updates the state.\n */\n const [fields, dispatchFields] = fieldsReducer\n\n contextRef.current.fields = fields\n\n const validateForm = useCallback(async () => {\n const validatedFieldState = {}\n let isValid = true\n\n const dataFromContext = contextRef.current.getData()\n const data = dataFromContext\n\n const validationPromises = Object.entries(contextRef.current.fields).map(\n async ([path, field]) => {\n const validatedField = field\n\n if (field.passesCondition !== false) {\n let validationResult: boolean | string = validatedField.valid\n\n if (typeof field.validate === 'function') {\n let valueToValidate = field.value\n\n if (field?.rows && Array.isArray(field.rows)) {\n valueToValidate = contextRef.current.getDataByPath(path)\n }\n\n validationResult = await field.validate(valueToValidate, {\n id,\n config,\n data,\n operation,\n siblingData: contextRef.current.getSiblingData(path),\n t,\n user,\n })\n\n if (typeof validationResult === 'string') {\n validatedField.errorMessage = validationResult\n validatedField.valid = false\n } else {\n validatedField.valid = true\n validatedField.errorMessage = undefined\n }\n }\n\n if (validatedField.valid === false) {\n isValid = false\n }\n }\n\n validatedFieldState[path] = validatedField\n },\n )\n\n await Promise.all(validationPromises)\n\n if (!isDeepEqual(contextRef.current.fields, validatedFieldState)) {\n dispatchFields({ type: 'REPLACE_STATE', state: validatedFieldState })\n }\n\n return isValid\n }, [id, user, operation, t, dispatchFields, config])\n\n const submit = useCallback(\n async (options: SubmitOptions = {}, e): Promise<void> => {\n const {\n action: actionArg,\n method: methodToUse = method,\n overrides = {},\n skipValidation,\n } = options\n\n if (disabled) {\n if (e) {\n e.preventDefault()\n }\n return\n }\n\n if (e) {\n e.stopPropagation()\n e.preventDefault()\n }\n\n setProcessing(true)\n setDisabled(true)\n\n if (waitForAutocomplete) await wait(100)\n\n // Execute server side validations\n if (Array.isArray(beforeSubmit)) {\n let revalidatedFormState: FormState\n\n await beforeSubmit.reduce(async (priorOnChange, beforeSubmitFn) => {\n await priorOnChange\n\n const result = await beforeSubmitFn({\n formState: fields,\n })\n\n revalidatedFormState = result\n }, Promise.resolve())\n\n const isValid = Object.entries(revalidatedFormState).every(([, field]) => field.valid)\n\n if (!isValid) {\n setProcessing(false)\n setSubmitted(true)\n setDisabled(false)\n return dispatchFields({ type: 'REPLACE_STATE', state: revalidatedFormState })\n }\n }\n\n const isValid =\n skipValidation || disableValidationOnSubmit ? true : await contextRef.current.validateForm()\n\n // If not valid, prevent submission\n if (!isValid) {\n toast.error(t('error:correctInvalidFields'))\n setProcessing(false)\n setSubmitted(true)\n setDisabled(false)\n return\n }\n\n // If submit handler comes through via props, run that\n if (onSubmit) {\n const data = {\n ...reduceFieldsToValues(fields, true),\n ...overrides,\n }\n\n onSubmit(fields, data)\n }\n\n const formData = contextRef.current.createFormData(overrides)\n\n try {\n let res\n const actionEndpoint =\n actionArg ||\n (typeof action === 'string'\n ? `${action}${QueryString.stringify(formQueryParams, { addQueryPrefix: true })}`\n : null)\n\n if (actionEndpoint) {\n res = await requests[methodToUse.toLowerCase()](actionEndpoint, {\n body: formData,\n headers: {\n 'Accept-Language': i18n.language,\n },\n })\n } else if (typeof action === 'function') {\n res = await action(formData)\n }\n\n setModified(false)\n setDisabled(false)\n\n if (typeof handleResponse === 'function') {\n handleResponse(res)\n return\n }\n\n const contentType = res.headers.get('content-type')\n const isJSON = contentType && contentType.indexOf('application/json') !== -1\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let json: Record<string, any> = {}\n\n if (isJSON) json = await res.json()\n\n if (res.status < 400) {\n if (typeof onSuccess === 'function') await onSuccess(json)\n setSubmitted(false)\n setProcessing(false)\n\n if (redirect) {\n router.push(redirect)\n } else if (!disableSuccessStatus) {\n toast.success(json.message || t('general:submissionSuccessful'), { autoClose: 3000 })\n }\n } else {\n setProcessing(false)\n setSubmitted(true)\n\n contextRef.current = { ...contextRef.current } // triggers rerender of all components that subscribe to form\n if (json.message) {\n toast.error(json.message)\n\n return\n }\n\n if (Array.isArray(json.errors)) {\n const [fieldErrors, nonFieldErrors] = json.errors.reduce(\n ([fieldErrs, nonFieldErrs], err) => {\n const newFieldErrs = []\n const newNonFieldErrs = []\n\n if (err?.message) {\n newNonFieldErrs.push(err)\n }\n\n if (Array.isArray(err?.data)) {\n err.data.forEach((dataError) => {\n if (dataError?.field) {\n newFieldErrs.push(dataError)\n } else {\n newNonFieldErrs.push(dataError)\n }\n })\n }\n\n return [\n [...fieldErrs, ...newFieldErrs],\n [...nonFieldErrs, ...newNonFieldErrs],\n ]\n },\n [[], []],\n )\n\n dispatchFields({\n type: 'ADD_SERVER_ERRORS',\n errors: fieldErrors,\n })\n\n nonFieldErrors.forEach((err) => {\n toast.error(err.message || t('error:unknown'))\n })\n\n return\n }\n\n const message = errorMessages?.[res.status] || res?.statusText || t('error:unknown')\n\n toast.error(message)\n }\n } catch (err) {\n setProcessing(false)\n setSubmitted(true)\n setDisabled(false)\n\n toast.error(err)\n }\n },\n [\n beforeSubmit,\n action,\n disableSuccessStatus,\n disableValidationOnSubmit,\n disabled,\n dispatchFields,\n fields,\n handleResponse,\n method,\n onSubmit,\n onSuccess,\n redirect,\n router,\n t,\n i18n,\n waitForAutocomplete,\n formQueryParams,\n ],\n )\n\n const getFields = useCallback(() => contextRef.current.fields, [])\n\n const getField = useCallback((path: string) => contextRef.current.fields[path], [])\n\n const getData = useCallback(() => reduceFieldsToValues(contextRef.current.fields, true), [])\n\n const getSiblingData = useCallback(\n (path: string) => getSiblingDataFunc(contextRef.current.fields, path),\n [],\n )\n const getDataByPath = useCallback<GetDataByPath>(\n (path: string) => getDataByPathFunc(contextRef.current.fields, path),\n [],\n )\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const createFormData = useCallback((overrides: any = {}) => {\n const data = reduceFieldsToValues(contextRef.current.fields, true)\n\n const file = data?.file\n\n if (file) {\n delete data.file\n }\n\n const dataWithOverrides = {\n ...data,\n ...overrides,\n }\n\n const dataToSerialize = {\n _payload: JSON.stringify(dataWithOverrides),\n file,\n }\n\n // nullAsUndefineds is important to allow uploads and relationship fields to clear themselves\n const formData = serialize(dataToSerialize, { indices: true, nullsAsUndefineds: false })\n\n return formData\n }, [])\n\n const reset = useCallback(\n async (data: unknown) => {\n const newState = await getFormState({\n apiRoute,\n body: {\n id,\n collectionSlug,\n data,\n globalSlug,\n operation,\n schemaPath: collectionSlug || globalSlug,\n },\n serverURL,\n })\n\n contextRef.current = { ...initContextState } as FormContextType\n setModified(false)\n dispatchFields({ type: 'REPLACE_STATE', state: newState })\n },\n [apiRoute, collectionSlug, dispatchFields, globalSlug, id, operation, serverURL],\n )\n\n const replaceState = useCallback(\n (state: FormState) => {\n contextRef.current = { ...initContextState } as FormContextType\n setModified(false)\n dispatchFields({ type: 'REPLACE_STATE', state })\n },\n [dispatchFields],\n )\n\n const getFieldStateBySchemaPath = useCallback(\n async ({ data, schemaPath }) => {\n const fieldSchema = await getFormState({\n apiRoute,\n body: {\n collectionSlug,\n data,\n globalSlug,\n schemaPath,\n },\n serverURL,\n })\n return fieldSchema\n },\n [apiRoute, collectionSlug, globalSlug, serverURL],\n )\n\n const addFieldRow: FormContextType['addFieldRow'] = useCallback(\n async ({ data, path, rowIndex, schemaPath }) => {\n const subFieldState = await getFieldStateBySchemaPath({ data, schemaPath })\n\n dispatchFields({\n type: 'ADD_ROW',\n blockType: data?.blockType,\n path,\n rowIndex,\n subFieldState,\n })\n },\n [getFieldStateBySchemaPath, dispatchFields],\n )\n\n const removeFieldRow: FormContextType['removeFieldRow'] = useCallback(\n ({ path, rowIndex }) => {\n dispatchFields({ type: 'REMOVE_ROW', path, rowIndex })\n },\n [dispatchFields],\n )\n\n const replaceFieldRow: FormContextType['replaceFieldRow'] = useCallback(\n async ({ data, path, rowIndex, schemaPath }) => {\n const subFieldState = await getFieldStateBySchemaPath({ data, schemaPath })\n\n dispatchFields({\n type: 'REPLACE_ROW',\n blockType: data?.blockType,\n path,\n rowIndex,\n subFieldState,\n })\n },\n [getFieldStateBySchemaPath, dispatchFields],\n )\n\n useEffect(() => {\n if (initializingFromProps !== undefined) {\n setInitializing(initializingFromProps)\n }\n }, [initializingFromProps])\n\n contextRef.current.submit = submit\n contextRef.current.getFields = getFields\n contextRef.current.getField = getField\n contextRef.current.getData = getData\n contextRef.current.getSiblingData = getSiblingData\n contextRef.current.getDataByPath = getDataByPath\n contextRef.current.validateForm = validateForm\n contextRef.current.createFormData = createFormData\n contextRef.current.setModified = setModified\n contextRef.current.setProcessing = setProcessing\n contextRef.current.setSubmitted = setSubmitted\n contextRef.current.disabled = disabled\n contextRef.current.setDisabled = setDisabled\n contextRef.current.formRef = formRef\n contextRef.current.reset = reset\n contextRef.current.replaceState = replaceState\n contextRef.current.dispatchFields = dispatchFields\n contextRef.current.addFieldRow = addFieldRow\n contextRef.current.removeFieldRow = removeFieldRow\n contextRef.current.replaceFieldRow = replaceFieldRow\n contextRef.current.uuid = uuid\n contextRef.current.initializing = initializing\n\n useEffect(() => {\n setIsMounted(true)\n }, [])\n\n useEffect(() => {\n if (typeof disabledFromProps === 'boolean') setDisabled(disabledFromProps)\n }, [disabledFromProps])\n\n useEffect(() => {\n if (typeof submittedFromProps === 'boolean') setSubmitted(submittedFromProps)\n }, [submittedFromProps])\n\n useEffect(() => {\n if (initialState) {\n contextRef.current = { ...initContextState } as FormContextType\n dispatchFields({ type: 'REPLACE_STATE', optimize: false, state: initialState })\n }\n }, [initialState, dispatchFields])\n\n useThrottledEffect(\n () => {\n refreshCookie()\n },\n 15000,\n [fields],\n )\n\n useEffect(() => {\n contextRef.current = { ...contextRef.current } // triggers rerender of all components that subscribe to form\n setModified(false)\n }, [locale])\n\n const classes = [className, baseClass].filter(Boolean).join(' ')\n\n useDebouncedEffect(\n () => {\n const executeOnChange = async () => {\n if (Array.isArray(onChange)) {\n let revalidatedFormState: FormState = contextRef.current.fields\n\n for (const onChangeFn of onChange) {\n revalidatedFormState = await onChangeFn({\n formState: revalidatedFormState,\n })\n }\n\n const { changed, newState } = mergeServerFormState(\n contextRef.current.fields || {},\n revalidatedFormState,\n )\n\n if (changed) {\n dispatchFields({\n type: 'REPLACE_STATE',\n optimize: false,\n state: newState,\n })\n }\n }\n }\n\n if (modified) void executeOnChange()\n },\n 150,\n // Make sure we trigger this whenever modified changes (not just when `fields` changes), otherwise we will miss merging server form state for the first form update/onChange. Here's why:\n // `fields` updates before `modified`, because setModified is in a setTimeout. So on the first change, modified is false, so we don't trigger the effect even though we should.\n [contextRef.current.fields, dispatchFields, onChange, modified],\n )\n\n const actionString =\n typeof action === 'string'\n ? `${action}${QueryString.stringify(formQueryParams, { addQueryPrefix: true })}`\n : ''\n\n return (\n <form\n action={method ? actionString : (action as string)}\n className={classes}\n method={method}\n noValidate\n onSubmit={(e) => contextRef.current.submit({}, e)}\n ref={formRef}\n >\n <FormContext.Provider value={contextRef.current}>\n <FormWatchContext.Provider\n value={{\n fields,\n ...contextRef.current,\n }}\n >\n <SubmittedContext.Provider value={submitted}>\n <InitializingContext.Provider value={!isMounted || (isMounted && initializing)}>\n <ProcessingContext.Provider value={processing}>\n <ModifiedContext.Provider value={modified}>\n <FormFieldsContext.Provider value={fieldsReducer}>\n {children}\n </FormFieldsContext.Provider>\n </ModifiedContext.Provider>\n </ProcessingContext.Provider>\n </InitializingContext.Provider>\n </SubmittedContext.Provider>\n </FormWatchContext.Provider>\n </FormContext.Provider>\n </form>\n )\n}\n\nexport {\n FormContext,\n FormFieldsContext,\n FormWatchContext,\n ModifiedContext,\n ProcessingContext,\n SubmittedContext,\n useAllFormFields,\n useForm,\n useFormFields,\n useFormModified,\n useFormProcessing,\n useFormSubmitted,\n useWatchForm,\n} from './context.js'\n\nexport { FormProps }\n"],"names":["isDeepEqual","useRouter","serialize","wait","QueryString","React","useCallback","useEffect","useReducer","useRef","useState","toast","useDebouncedEffect","useThrottledEffect","useAuth","useConfig","useDocumentInfo","useFormQueryParams","useLocale","useOperation","useTranslation","requests","getFormState","reduceFieldsToValues","FormContext","FormFieldsContext","FormWatchContext","InitializingContext","ModifiedContext","ProcessingContext","SubmittedContext","errorMessages","fieldReducer","getDataByPath","getDataByPathFunc","getSiblingData","getSiblingDataFunc","initContextState","mergeServerFormState","baseClass","Form","props","id","collectionSlug","globalSlug","action","beforeSubmit","children","className","disableSuccessStatus","disableValidationOnSubmit","disabled","disabledFromProps","handleResponse","initialState","isInitializing","initializingFromProps","onChange","onSubmit","onSuccess","redirect","submitted","submittedFromProps","uuid","waitForAutocomplete","method","undefined","router","code","locale","i18n","t","refreshCookie","user","operation","formQueryParams","config","routes","api","apiRoute","serverURL","setDisabled","isMounted","setIsMounted","modified","setModified","initializing","setInitializing","processing","setProcessing","setSubmitted","formRef","contextRef","fieldsReducer","fields","dispatchFields","current","validateForm","validatedFieldState","isValid","dataFromContext","getData","data","validationPromises","Object","entries","map","path","field","validatedField","passesCondition","validationResult","valid","validate","valueToValidate","value","rows","Array","isArray","siblingData","errorMessage","Promise","all","type","state","submit","options","e","actionArg","methodToUse","overrides","skipValidation","preventDefault","stopPropagation","revalidatedFormState","reduce","priorOnChange","beforeSubmitFn","result","formState","resolve","every","error","formData","createFormData","res","actionEndpoint","stringify","addQueryPrefix","toLowerCase","body","headers","language","contentType","get","isJSON","indexOf","json","status","push","success","message","autoClose","errors","fieldErrors","nonFieldErrors","fieldErrs","nonFieldErrs","err","newFieldErrs","newNonFieldErrs","forEach","dataError","statusText","getFields","getField","file","dataWithOverrides","dataToSerialize","_payload","JSON","indices","nullsAsUndefineds","reset","newState","schemaPath","replaceState","getFieldStateBySchemaPath","fieldSchema","addFieldRow","rowIndex","subFieldState","blockType","removeFieldRow","replaceFieldRow","optimize","classes","filter","Boolean","join","executeOnChange","onChangeFn","changed","actionString","form","noValidate","ref","Provider","useAllFormFields","useForm","useFormFields","useFormModified","useFormProcessing","useFormSubmitted","useWatchForm"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,SAAS0I,eAAgB9J;QACjCG,WAAWoJ;QACXnI,QAAQA;QACR4I,UAAU;QACVnJ,UAAU,CAACqE,IAAMnC,WAAWI,OAAO,CAAC6B,MAAM,CAAC,CAAC,GAAGE;QAC/C+E,KAAKnH;kBAEL,cAAA,KAACnE,YAAYuL,QAAQ;YAAC5F,OAAOvB,WAAWI,OAAO;sBAC7C,cAAA,KAACtE,iBAAiBqL,QAAQ;gBACxB5F,OAAO;oBACLrB;oBACA,GAAGF,WAAWI,OAAO;gBACvB;0BAEA,cAAA,KAAClE,iBAAiBiL,QAAQ;oBAAC5F,OAAOtD;8BAChC,cAAA,KAAClC,oBAAoBoL,QAAQ;wBAAC5F,OAAO,CAACjC,aAAcA,aAAaI;kCAC/D,cAAA,KAACzD,kBAAkBkL,QAAQ;4BAAC5F,OAAO3B;sCACjC,cAAA,KAAC5D,gBAAgBmL,QAAQ;gCAAC5F,OAAO/B;0CAC/B,cAAA,KAAC3D,kBAAkBsL,QAAQ;oCAAC5F,OAAOtB;8CAChC9C;;;;;;;;;AAUrB,EAAC;AAED,SACEvB,WAAW,EACXC,iBAAiB,EACjBC,gBAAgB,EAChBE,eAAe,EACfC,iBAAiB,EACjBC,gBAAgB,EAChBkL,gBAAgB,EAChBC,OAAO,EACPC,aAAa,EACbC,eAAe,EACfC,iBAAiB,EACjBC,gBAAgB,EAChBC,YAAY,QACP,eAAc"}
@@ -1 +1 @@
1
- {"version":3,"file":"initContextState.d.ts","sourceRoot":"","sources":["../../../src/forms/Form/initContextState.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,OAAO,EAUR,MAAM,YAAY,CAAA;AAanB,eAAO,MAAM,gBAAgB,EAAE,OAuB9B,CAAA"}
1
+ {"version":3,"file":"initContextState.d.ts","sourceRoot":"","sources":["../../../src/forms/Form/initContextState.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,OAAO,EAUR,MAAM,YAAY,CAAA;AAanB,eAAO,MAAM,gBAAgB,EAAE,OAwB9B,CAAA"}
@@ -20,6 +20,7 @@ export const initContextState = {
20
20
  getField: ()=>undefined,
21
21
  getFields: ()=>({}),
22
22
  getSiblingData,
23
+ initializing: undefined,
23
24
  removeFieldRow: ()=>undefined,
24
25
  replaceFieldRow: ()=>undefined,
25
26
  replaceState: ()=>undefined,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/forms/Form/initContextState.ts"],"sourcesContent":["import type { Data, FormField, FormState } from 'payload/types'\n\nimport type {\n Context,\n CreateFormData,\n DispatchFields,\n GetSiblingData,\n Reset,\n SetModified,\n SetProcessing,\n SetSubmitted,\n Submit,\n ValidateForm,\n} from './types.js'\n\nconst submit: Submit = () => undefined\nconst getSiblingData: GetSiblingData = () => undefined\nconst dispatchFields: DispatchFields = () => undefined\nconst validateForm: ValidateForm = () => undefined\nconst createFormData: CreateFormData = () => undefined\n\nconst setModified: SetModified = () => undefined\nconst setProcessing: SetProcessing = () => undefined\nconst setSubmitted: SetSubmitted = () => undefined\nconst reset: Reset = () => undefined\n\nexport const initContextState: Context = {\n addFieldRow: () => undefined,\n buildRowErrors: () => undefined,\n createFormData,\n disabled: false,\n dispatchFields,\n fields: {},\n formRef: null,\n getData: (): Data => undefined,\n getDataByPath: () => undefined,\n getField: (): FormField => undefined,\n getFields: (): FormState => ({}),\n getSiblingData,\n removeFieldRow: () => undefined,\n replaceFieldRow: () => undefined,\n replaceState: () => undefined,\n reset,\n setDisabled: () => undefined,\n setModified,\n setProcessing,\n setSubmitted,\n submit,\n validateForm,\n}\n"],"names":["submit","undefined","getSiblingData","dispatchFields","validateForm","createFormData","setModified","setProcessing","setSubmitted","reset","initContextState","addFieldRow","buildRowErrors","disabled","fields","formRef","getData","getDataByPath","getField","getFields","removeFieldRow","replaceFieldRow","replaceState","setDisabled"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAeA,MAAMA,SAAiB,IAAMC;AAC7B,MAAMC,iBAAiC,IAAMD;AAC7C,MAAME,iBAAiC,IAAMF;AAC7C,MAAMG,eAA6B,IAAMH;AACzC,MAAMI,iBAAiC,IAAMJ;AAE7C,MAAMK,cAA2B,IAAML;AACvC,MAAMM,gBAA+B,IAAMN;AAC3C,MAAMO,eAA6B,IAAMP;AACzC,MAAMQ,QAAe,IAAMR;AAE3B,OAAO,MAAMS,mBAA4B;IACvCC,aAAa,IAAMV;IACnBW,gBAAgB,IAAMX;IACtBI;IACAQ,UAAU;IACVV;IACAW,QAAQ,CAAC;IACTC,SAAS;IACTC,SAAS,IAAYf;IACrBgB,eAAe,IAAMhB;IACrBiB,UAAU,IAAiBjB;IAC3BkB,WAAW,IAAkB,CAAA,CAAC,CAAA;IAC9BjB;IACAkB,gBAAgB,IAAMnB;IACtBoB,iBAAiB,IAAMpB;IACvBqB,cAAc,IAAMrB;IACpBQ;IACAc,aAAa,IAAMtB;IACnBK;IACAC;IACAC;IACAR;IACAI;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../src/forms/Form/initContextState.ts"],"sourcesContent":["import type { Data, FormField, FormState } from 'payload/types'\n\nimport type {\n Context,\n CreateFormData,\n DispatchFields,\n GetSiblingData,\n Reset,\n SetModified,\n SetProcessing,\n SetSubmitted,\n Submit,\n ValidateForm,\n} from './types.js'\n\nconst submit: Submit = () => undefined\nconst getSiblingData: GetSiblingData = () => undefined\nconst dispatchFields: DispatchFields = () => undefined\nconst validateForm: ValidateForm = () => undefined\nconst createFormData: CreateFormData = () => undefined\n\nconst setModified: SetModified = () => undefined\nconst setProcessing: SetProcessing = () => undefined\nconst setSubmitted: SetSubmitted = () => undefined\nconst reset: Reset = () => undefined\n\nexport const initContextState: Context = {\n addFieldRow: () => undefined,\n buildRowErrors: () => undefined,\n createFormData,\n disabled: false,\n dispatchFields,\n fields: {},\n formRef: null,\n getData: (): Data => undefined,\n getDataByPath: () => undefined,\n getField: (): FormField => undefined,\n getFields: (): FormState => ({}),\n getSiblingData,\n initializing: undefined,\n removeFieldRow: () => undefined,\n replaceFieldRow: () => undefined,\n replaceState: () => undefined,\n reset,\n setDisabled: () => undefined,\n setModified,\n setProcessing,\n setSubmitted,\n submit,\n validateForm,\n}\n"],"names":["submit","undefined","getSiblingData","dispatchFields","validateForm","createFormData","setModified","setProcessing","setSubmitted","reset","initContextState","addFieldRow","buildRowErrors","disabled","fields","formRef","getData","getDataByPath","getField","getFields","initializing","removeFieldRow","replaceFieldRow","replaceState","setDisabled"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAeA,MAAMA,SAAiB,IAAMC;AAC7B,MAAMC,iBAAiC,IAAMD;AAC7C,MAAME,iBAAiC,IAAMF;AAC7C,MAAMG,eAA6B,IAAMH;AACzC,MAAMI,iBAAiC,IAAMJ;AAE7C,MAAMK,cAA2B,IAAML;AACvC,MAAMM,gBAA+B,IAAMN;AAC3C,MAAMO,eAA6B,IAAMP;AACzC,MAAMQ,QAAe,IAAMR;AAE3B,OAAO,MAAMS,mBAA4B;IACvCC,aAAa,IAAMV;IACnBW,gBAAgB,IAAMX;IACtBI;IACAQ,UAAU;IACVV;IACAW,QAAQ,CAAC;IACTC,SAAS;IACTC,SAAS,IAAYf;IACrBgB,eAAe,IAAMhB;IACrBiB,UAAU,IAAiBjB;IAC3BkB,WAAW,IAAkB,CAAA,CAAC,CAAA;IAC9BjB;IACAkB,cAAcnB;IACdoB,gBAAgB,IAAMpB;IACtBqB,iBAAiB,IAAMrB;IACvBsB,cAAc,IAAMtB;IACpBQ;IACAe,aAAa,IAAMvB;IACnBK;IACAC;IACAC;IACAR;IACAI;AACF,EAAC"}
@@ -32,6 +32,7 @@ export type FormProps = ({
32
32
  fields?: Field[];
33
33
  handleResponse?: (res: Response) => void;
34
34
  initialState?: FormState;
35
+ isInitializing?: boolean;
35
36
  log?: boolean;
36
37
  onChange?: ((args: {
37
38
  formState: FormState;
@@ -159,6 +160,7 @@ export type Context = {
159
160
  getField: GetField;
160
161
  getFields: GetFields;
161
162
  getSiblingData: GetSiblingData;
163
+ initializing: boolean;
162
164
  removeFieldRow: ({ path, rowIndex }: {
163
165
  path: string;
164
166
  rowIndex: number;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/forms/Form/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAChE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAA;AACzC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAErC,MAAM,MAAM,WAAW,GAAG;IACxB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CACvB,CAAA;AAED,MAAM,MAAM,SAAS,GAAG,CACpB;IACE,MAAM,EAAE,CAAC,QAAQ,EAAE,QAAQ,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;CAC9C,GACD;IACE,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,QAAQ,GAAG,KAAK,GAAG,OAAO,GAAG,MAAM,CAAA;CAC7C,CACJ,GAAG;IACF,YAAY,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE;QAAE,SAAS,EAAE,SAAS,CAAA;KAAE,KAAK,OAAO,CAAC,SAAS,CAAC,CAAC,EAAE,CAAA;IACzE,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAC9B;;;OAGG;IACH,yBAAyB,CAAC,EAAE,OAAO,CAAA;IACnC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB;;;;OAIG;IACH,MAAM,CAAC,EAAE,KAAK,EAAE,CAAA;IAChB,cAAc,CAAC,EAAE,CAAC,GAAG,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C,KAAK,EAAE,SAAS,KAAK,IAAI,CAAA;IACxC,KAAK,EAAE,KAAK,CAAA;IACZ,WAAW,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAA;IACxC,WAAW,EAAE,WAAW,CAAA;IACxB,aAAa,EAAE,aAAa,CAAA;IAC5B,YAAY,EAAE,YAAY,CAAA;IAC1B,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,YAAY,EAAE,YAAY,CAAA;CAC3B,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/forms/Form/types.ts"],"sourcesContent":["import type { User } from 'payload/auth'\nimport type { Field, FormField, FormState } from 'payload/types'\nimport type { Data } from 'payload/types'\nimport type React from 'react'\nimport type { Dispatch } from 'react'\n\nexport type Preferences = {\n [key: string]: unknown\n}\n\nexport type FormProps = (\n | {\n action: (formData: FormData) => Promise<void>\n }\n | {\n action?: string\n method?: 'DELETE' | 'GET' | 'PATCH' | 'POST'\n }\n) & {\n beforeSubmit?: ((args: { formState: FormState }) => Promise<FormState>)[]\n children?: React.ReactNode\n className?: string\n disableSuccessStatus?: boolean\n /**\n * If you would like to solely leverage server-side validation on submit,\n * you can disable checks that the form makes before it submits\n */\n disableValidationOnSubmit?: boolean\n disabled?: boolean\n /**\n * By default, the form will get the field schema (not data) from the current document. If you pass this in, you can override that behavior.\n * This is very useful for sub-forms, where the form's field schema is not necessarily the field schema of the current document (e.g. for the Blocks\n * feature of the Lexical Rich Text field)\n */\n fields?: Field[]\n handleResponse?: (res: Response) => void\n initialState?: FormState\n log?: boolean\n onChange?: ((args: { formState: FormState }) => Promise<FormState>)[]\n onSubmit?: (fields: FormState, data: Data) => void\n onSuccess?: (json: unknown) => Promise<void> | void\n redirect?: string\n submitted?: boolean\n uuid?: string\n validationOperation?: 'create' | 'update'\n waitForAutocomplete?: boolean\n}\n\nexport type SubmitOptions = {\n action?: string\n method?: string\n overrides?: Record<string, unknown>\n skipValidation?: boolean\n}\n\nexport type DispatchFields = React.Dispatch<any>\nexport type Submit = (\n options?: SubmitOptions,\n e?: React.FormEvent<HTMLFormElement>,\n) => Promise<void>\nexport type ValidateForm = () => Promise<boolean>\nexport type CreateFormData = (overrides?: any) => FormData\nexport type GetFields = () => FormState\nexport type GetField = (path: string) => FormField\nexport type GetData = () => Data\nexport type GetSiblingData = (path: string) => Data\nexport type GetDataByPath = <T = unknown>(path: string) => T\nexport type SetModified = (modified: boolean) => void\nexport type SetSubmitted = (submitted: boolean) => void\nexport type SetProcessing = (processing: boolean) => void\n\nexport type Reset = (data: unknown) => Promise<void>\n\nexport type REPLACE_STATE = {\n optimize?: boolean\n state: FormState\n type: 'REPLACE_STATE'\n}\n\nexport type REMOVE = {\n path: string\n type: 'REMOVE'\n}\n\nexport type MODIFY_CONDITION = {\n path: string\n result: boolean\n type: 'MODIFY_CONDITION'\n user: User\n}\n\nexport type UPDATE = {\n path: string\n type: 'UPDATE'\n} & Partial<FormField>\n\nexport type REMOVE_ROW = {\n path: string\n rowIndex: number\n type: 'REMOVE_ROW'\n}\n\nexport type ADD_ROW = {\n blockType?: string\n path: string\n rowIndex?: number\n subFieldState?: FormState\n type: 'ADD_ROW'\n}\n\nexport type REPLACE_ROW = {\n blockType?: string\n path: string\n rowIndex: number\n subFieldState?: FormState\n type: 'REPLACE_ROW'\n}\n\nexport type DUPLICATE_ROW = {\n path: string\n rowIndex: number\n type: 'DUPLICATE_ROW'\n}\n\nexport type MOVE_ROW = {\n moveFromIndex: number\n moveToIndex: number\n path: string\n type: 'MOVE_ROW'\n}\n\nexport type ADD_SERVER_ERRORS = {\n errors: {\n field: string\n message: string\n }[]\n type: 'ADD_SERVER_ERRORS'\n}\n\nexport type SET_ROW_COLLAPSED = {\n collapsed: boolean\n path: string\n rowID: string\n setDocFieldPreferences: (field: string, fieldPreferences: { [key: string]: unknown }) => void\n type: 'SET_ROW_COLLAPSED'\n}\n\nexport type SET_ALL_ROWS_COLLAPSED = {\n collapsed: boolean\n path: string\n setDocFieldPreferences: (field: string, fieldPreferences: { [key: string]: unknown }) => void\n type: 'SET_ALL_ROWS_COLLAPSED'\n}\n\nexport type FieldAction =\n | ADD_ROW\n | ADD_SERVER_ERRORS\n | DUPLICATE_ROW\n | MODIFY_CONDITION\n | MOVE_ROW\n | REMOVE\n | REMOVE_ROW\n | REPLACE_ROW\n | REPLACE_STATE\n | SET_ALL_ROWS_COLLAPSED\n | SET_ROW_COLLAPSED\n | UPDATE\n\nexport type FormFieldsContext = [FormState, Dispatch<FieldAction>]\n\nexport type Context = {\n addFieldRow: ({\n data,\n path,\n rowIndex,\n schemaPath,\n }: {\n data?: Data\n path: string\n /*\n * by default the new row will be added to the end of the list\n */\n rowIndex?: number\n schemaPath: string\n }) => Promise<void>\n buildRowErrors: () => void\n createFormData: CreateFormData\n disabled: boolean\n dispatchFields: Dispatch<FieldAction>\n /**\n * Form context fields may be outdated and should not be relied on. Instead, prefer `useFormFields`.\n */\n fields: FormState\n formRef: React.MutableRefObject<HTMLFormElement>\n getData: GetData\n getDataByPath: GetDataByPath\n getField: GetField\n getFields: GetFields\n getSiblingData: GetSiblingData\n removeFieldRow: ({ path, rowIndex }: { path: string; rowIndex: number }) => void\n replaceFieldRow: ({\n data,\n path,\n rowIndex,\n schemaPath,\n }: {\n data?: Data\n path: string\n rowIndex: number\n schemaPath: string\n }) => Promise<void>\n replaceState: (state: FormState) => void\n reset: Reset\n setDisabled: (disabled: boolean) => void\n setModified: SetModified\n setProcessing: SetProcessing\n setSubmitted: SetSubmitted\n submit: Submit\n uuid?: string\n validateForm: ValidateForm\n}\n"],"names":[],"rangeMappings":"","mappings":"AA0KA,WAkDC"}
1
+ {"version":3,"sources":["../../../src/forms/Form/types.ts"],"sourcesContent":["import type { User } from 'payload/auth'\nimport type { Field, FormField, FormState } from 'payload/types'\nimport type { Data } from 'payload/types'\nimport type React from 'react'\nimport type { Dispatch } from 'react'\n\nexport type Preferences = {\n [key: string]: unknown\n}\n\nexport type FormProps = (\n | {\n action: (formData: FormData) => Promise<void>\n }\n | {\n action?: string\n method?: 'DELETE' | 'GET' | 'PATCH' | 'POST'\n }\n) & {\n beforeSubmit?: ((args: { formState: FormState }) => Promise<FormState>)[]\n children?: React.ReactNode\n className?: string\n disableSuccessStatus?: boolean\n /**\n * If you would like to solely leverage server-side validation on submit,\n * you can disable checks that the form makes before it submits\n */\n disableValidationOnSubmit?: boolean\n disabled?: boolean\n /**\n * By default, the form will get the field schema (not data) from the current document. If you pass this in, you can override that behavior.\n * This is very useful for sub-forms, where the form's field schema is not necessarily the field schema of the current document (e.g. for the Blocks\n * feature of the Lexical Rich Text field)\n */\n fields?: Field[]\n handleResponse?: (res: Response) => void\n initialState?: FormState\n isInitializing?: boolean\n log?: boolean\n onChange?: ((args: { formState: FormState }) => Promise<FormState>)[]\n onSubmit?: (fields: FormState, data: Data) => void\n onSuccess?: (json: unknown) => Promise<void> | void\n redirect?: string\n submitted?: boolean\n uuid?: string\n validationOperation?: 'create' | 'update'\n waitForAutocomplete?: boolean\n}\n\nexport type SubmitOptions = {\n action?: string\n method?: string\n overrides?: Record<string, unknown>\n skipValidation?: boolean\n}\n\nexport type DispatchFields = React.Dispatch<any>\nexport type Submit = (\n options?: SubmitOptions,\n e?: React.FormEvent<HTMLFormElement>,\n) => Promise<void>\nexport type ValidateForm = () => Promise<boolean>\nexport type CreateFormData = (overrides?: any) => FormData\nexport type GetFields = () => FormState\nexport type GetField = (path: string) => FormField\nexport type GetData = () => Data\nexport type GetSiblingData = (path: string) => Data\nexport type GetDataByPath = <T = unknown>(path: string) => T\nexport type SetModified = (modified: boolean) => void\nexport type SetSubmitted = (submitted: boolean) => void\nexport type SetProcessing = (processing: boolean) => void\n\nexport type Reset = (data: unknown) => Promise<void>\n\nexport type REPLACE_STATE = {\n optimize?: boolean\n state: FormState\n type: 'REPLACE_STATE'\n}\n\nexport type REMOVE = {\n path: string\n type: 'REMOVE'\n}\n\nexport type MODIFY_CONDITION = {\n path: string\n result: boolean\n type: 'MODIFY_CONDITION'\n user: User\n}\n\nexport type UPDATE = {\n path: string\n type: 'UPDATE'\n} & Partial<FormField>\n\nexport type REMOVE_ROW = {\n path: string\n rowIndex: number\n type: 'REMOVE_ROW'\n}\n\nexport type ADD_ROW = {\n blockType?: string\n path: string\n rowIndex?: number\n subFieldState?: FormState\n type: 'ADD_ROW'\n}\n\nexport type REPLACE_ROW = {\n blockType?: string\n path: string\n rowIndex: number\n subFieldState?: FormState\n type: 'REPLACE_ROW'\n}\n\nexport type DUPLICATE_ROW = {\n path: string\n rowIndex: number\n type: 'DUPLICATE_ROW'\n}\n\nexport type MOVE_ROW = {\n moveFromIndex: number\n moveToIndex: number\n path: string\n type: 'MOVE_ROW'\n}\n\nexport type ADD_SERVER_ERRORS = {\n errors: {\n field: string\n message: string\n }[]\n type: 'ADD_SERVER_ERRORS'\n}\n\nexport type SET_ROW_COLLAPSED = {\n collapsed: boolean\n path: string\n rowID: string\n setDocFieldPreferences: (field: string, fieldPreferences: { [key: string]: unknown }) => void\n type: 'SET_ROW_COLLAPSED'\n}\n\nexport type SET_ALL_ROWS_COLLAPSED = {\n collapsed: boolean\n path: string\n setDocFieldPreferences: (field: string, fieldPreferences: { [key: string]: unknown }) => void\n type: 'SET_ALL_ROWS_COLLAPSED'\n}\n\nexport type FieldAction =\n | ADD_ROW\n | ADD_SERVER_ERRORS\n | DUPLICATE_ROW\n | MODIFY_CONDITION\n | MOVE_ROW\n | REMOVE\n | REMOVE_ROW\n | REPLACE_ROW\n | REPLACE_STATE\n | SET_ALL_ROWS_COLLAPSED\n | SET_ROW_COLLAPSED\n | UPDATE\n\nexport type FormFieldsContext = [FormState, Dispatch<FieldAction>]\n\nexport type Context = {\n addFieldRow: ({\n data,\n path,\n rowIndex,\n schemaPath,\n }: {\n data?: Data\n path: string\n /*\n * by default the new row will be added to the end of the list\n */\n rowIndex?: number\n schemaPath: string\n }) => Promise<void>\n buildRowErrors: () => void\n createFormData: CreateFormData\n disabled: boolean\n dispatchFields: Dispatch<FieldAction>\n /**\n * Form context fields may be outdated and should not be relied on. Instead, prefer `useFormFields`.\n */\n fields: FormState\n formRef: React.MutableRefObject<HTMLFormElement>\n getData: GetData\n getDataByPath: GetDataByPath\n getField: GetField\n getFields: GetFields\n getSiblingData: GetSiblingData\n initializing: boolean\n removeFieldRow: ({ path, rowIndex }: { path: string; rowIndex: number }) => void\n replaceFieldRow: ({\n data,\n path,\n rowIndex,\n schemaPath,\n }: {\n data?: Data\n path: string\n rowIndex: number\n schemaPath: string\n }) => Promise<void>\n replaceState: (state: FormState) => void\n reset: Reset\n setDisabled: (disabled: boolean) => void\n setModified: SetModified\n setProcessing: SetProcessing\n setSubmitted: SetSubmitted\n submit: Submit\n uuid?: string\n validateForm: ValidateForm\n}\n"],"names":[],"rangeMappings":"","mappings":"AA2KA,WAmDC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/forms/RenderFields/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAKvC,OAAO,cAAc,CAAA;AAIrB,OAAO,EAAE,KAAK,EAAE,CAAA;AAEhB,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAiFxC,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/forms/RenderFields/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAKvC,OAAO,cAAc,CAAA;AAIrB,OAAO,EAAE,KAAK,EAAE,CAAA;AAEhB,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAqFxC,CAAA"}