@payloadcms/ui 3.0.0-beta.36 → 3.0.0-beta.38

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 (321) hide show
  1. package/dist/elements/ArrayAction/index.d.ts.map +1 -1
  2. package/dist/elements/ArrayAction/index.js +1 -0
  3. package/dist/elements/ArrayAction/index.js.map +1 -1
  4. package/dist/elements/Banner/index.d.ts.map +1 -1
  5. package/dist/elements/Banner/index.js +1 -0
  6. package/dist/elements/Banner/index.js.map +1 -1
  7. package/dist/elements/Card/index.d.ts.map +1 -1
  8. package/dist/elements/Card/index.js +1 -0
  9. package/dist/elements/Card/index.js.map +1 -1
  10. package/dist/elements/CodeEditor/CodeEditor.d.ts.map +1 -1
  11. package/dist/elements/CodeEditor/CodeEditor.js +1 -0
  12. package/dist/elements/CodeEditor/CodeEditor.js.map +1 -1
  13. package/dist/elements/CodeEditor/index.d.ts.map +1 -1
  14. package/dist/elements/CodeEditor/index.js +1 -0
  15. package/dist/elements/CodeEditor/index.js.map +1 -1
  16. package/dist/elements/DatePicker/DatePicker.d.ts.map +1 -1
  17. package/dist/elements/DatePicker/DatePicker.js +1 -0
  18. package/dist/elements/DatePicker/DatePicker.js.map +1 -1
  19. package/dist/elements/DatePicker/index.d.ts.map +1 -1
  20. package/dist/elements/DatePicker/index.js +1 -0
  21. package/dist/elements/DatePicker/index.js.map +1 -1
  22. package/dist/elements/DocumentFields/index.d.ts.map +1 -1
  23. package/dist/elements/DocumentFields/index.js +2 -0
  24. package/dist/elements/DocumentFields/index.js.map +1 -1
  25. package/dist/elements/DocumentHeader/Tabs/Tab/index.scss +3 -1
  26. package/dist/elements/DocumentHeader/Tabs/tabs/VersionsPill/index.d.ts.map +1 -1
  27. package/dist/elements/DocumentHeader/Tabs/tabs/VersionsPill/index.js +14 -8
  28. package/dist/elements/DocumentHeader/Tabs/tabs/VersionsPill/index.js.map +1 -1
  29. package/dist/elements/DraggableSortable/DraggableSortableItem/index.d.ts.map +1 -1
  30. package/dist/elements/DraggableSortable/DraggableSortableItem/index.js +1 -0
  31. package/dist/elements/DraggableSortable/DraggableSortableItem/index.js.map +1 -1
  32. package/dist/elements/DraggableSortable/index.d.ts.map +1 -1
  33. package/dist/elements/DraggableSortable/index.js +1 -0
  34. package/dist/elements/DraggableSortable/index.js.map +1 -1
  35. package/dist/elements/DraggableSortable/useDraggableSortable/index.d.ts.map +1 -1
  36. package/dist/elements/DraggableSortable/useDraggableSortable/index.js +1 -0
  37. package/dist/elements/DraggableSortable/useDraggableSortable/index.js.map +1 -1
  38. package/dist/elements/Drawer/useDrawerSlug.d.ts.map +1 -1
  39. package/dist/elements/Drawer/useDrawerSlug.js +1 -0
  40. package/dist/elements/Drawer/useDrawerSlug.js.map +1 -1
  41. package/dist/elements/Dropzone/index.d.ts.map +1 -1
  42. package/dist/elements/Dropzone/index.js +1 -0
  43. package/dist/elements/Dropzone/index.js.map +1 -1
  44. package/dist/elements/ErrorPill/index.d.ts.map +1 -1
  45. package/dist/elements/ErrorPill/index.js +1 -0
  46. package/dist/elements/ErrorPill/index.js.map +1 -1
  47. package/dist/elements/FieldSelect/index.d.ts.map +1 -1
  48. package/dist/elements/FieldSelect/index.js +1 -0
  49. package/dist/elements/FieldSelect/index.js.map +1 -1
  50. package/dist/elements/FileDetails/FileMeta/index.d.ts.map +1 -1
  51. package/dist/elements/FileDetails/FileMeta/index.js +1 -0
  52. package/dist/elements/FileDetails/FileMeta/index.js.map +1 -1
  53. package/dist/elements/FileDetails/index.d.ts.map +1 -1
  54. package/dist/elements/FileDetails/index.js +1 -0
  55. package/dist/elements/FileDetails/index.js.map +1 -1
  56. package/dist/elements/IDLabel/index.d.ts.map +1 -1
  57. package/dist/elements/IDLabel/index.js +1 -0
  58. package/dist/elements/IDLabel/index.js.map +1 -1
  59. package/dist/elements/Localizer/LocalizerLabel/index.d.ts.map +1 -1
  60. package/dist/elements/Localizer/LocalizerLabel/index.js +1 -0
  61. package/dist/elements/Localizer/LocalizerLabel/index.js.map +1 -1
  62. package/dist/elements/Localizer/index.d.ts.map +1 -1
  63. package/dist/elements/Localizer/index.js +1 -0
  64. package/dist/elements/Localizer/index.js.map +1 -1
  65. package/dist/elements/Pagination/ClickableArrow/index.d.ts.map +1 -1
  66. package/dist/elements/Pagination/ClickableArrow/index.js +1 -0
  67. package/dist/elements/Pagination/ClickableArrow/index.js.map +1 -1
  68. package/dist/elements/Pagination/Page/index.d.ts.map +1 -1
  69. package/dist/elements/Pagination/Page/index.js +1 -0
  70. package/dist/elements/Pagination/Page/index.js.map +1 -1
  71. package/dist/elements/Pagination/Separator/index.d.ts.map +1 -1
  72. package/dist/elements/Pagination/Separator/index.js +1 -0
  73. package/dist/elements/Pagination/Separator/index.js.map +1 -1
  74. package/dist/elements/Popup/PopupTrigger/index.d.ts.map +1 -1
  75. package/dist/elements/Popup/PopupTrigger/index.js +1 -0
  76. package/dist/elements/Popup/PopupTrigger/index.js.map +1 -1
  77. package/dist/elements/PreviewSizes/index.d.ts.map +1 -1
  78. package/dist/elements/PreviewSizes/index.js +1 -0
  79. package/dist/elements/PreviewSizes/index.js.map +1 -1
  80. package/dist/elements/ReactSelect/ClearIndicator/index.d.ts.map +1 -1
  81. package/dist/elements/ReactSelect/ClearIndicator/index.js +1 -0
  82. package/dist/elements/ReactSelect/ClearIndicator/index.js.map +1 -1
  83. package/dist/elements/ReactSelect/Control/index.d.ts.map +1 -1
  84. package/dist/elements/ReactSelect/Control/index.js +1 -0
  85. package/dist/elements/ReactSelect/Control/index.js.map +1 -1
  86. package/dist/elements/ReactSelect/DropdownIndicator/index.d.ts.map +1 -1
  87. package/dist/elements/ReactSelect/DropdownIndicator/index.js +1 -0
  88. package/dist/elements/ReactSelect/DropdownIndicator/index.js.map +1 -1
  89. package/dist/elements/ReactSelect/Input/index.d.ts +5 -0
  90. package/dist/elements/ReactSelect/Input/index.d.ts.map +1 -0
  91. package/dist/elements/ReactSelect/Input/index.js +17 -0
  92. package/dist/elements/ReactSelect/Input/index.js.map +1 -0
  93. package/dist/elements/ReactSelect/MultiValue/index.d.ts +1 -0
  94. package/dist/elements/ReactSelect/MultiValue/index.d.ts.map +1 -1
  95. package/dist/elements/ReactSelect/MultiValue/index.js +14 -8
  96. package/dist/elements/ReactSelect/MultiValue/index.js.map +1 -1
  97. package/dist/elements/ReactSelect/MultiValueLabel/index.d.ts.map +1 -1
  98. package/dist/elements/ReactSelect/MultiValueLabel/index.js +1 -0
  99. package/dist/elements/ReactSelect/MultiValueLabel/index.js.map +1 -1
  100. package/dist/elements/ReactSelect/MultiValueRemove/index.d.ts.map +1 -1
  101. package/dist/elements/ReactSelect/MultiValueRemove/index.js +1 -0
  102. package/dist/elements/ReactSelect/MultiValueRemove/index.js.map +1 -1
  103. package/dist/elements/ReactSelect/SingleValue/index.d.ts.map +1 -1
  104. package/dist/elements/ReactSelect/SingleValue/index.js +1 -0
  105. package/dist/elements/ReactSelect/SingleValue/index.js.map +1 -1
  106. package/dist/elements/ReactSelect/ValueContainer/index.d.ts.map +1 -1
  107. package/dist/elements/ReactSelect/ValueContainer/index.js +1 -0
  108. package/dist/elements/ReactSelect/ValueContainer/index.js.map +1 -1
  109. package/dist/elements/ReactSelect/index.d.ts.map +1 -1
  110. package/dist/elements/ReactSelect/index.js +28 -8
  111. package/dist/elements/ReactSelect/index.js.map +1 -1
  112. package/dist/elements/RenderCustomClientComponent/index.d.ts +8 -0
  113. package/dist/elements/RenderCustomClientComponent/index.d.ts.map +1 -0
  114. package/dist/elements/RenderCustomClientComponent/index.js +19 -0
  115. package/dist/elements/RenderCustomClientComponent/index.js.map +1 -0
  116. package/dist/elements/RenderCustomComponent/index.d.ts +4 -0
  117. package/dist/elements/RenderCustomComponent/index.d.ts.map +1 -1
  118. package/dist/elements/RenderCustomComponent/index.js +4 -1
  119. package/dist/elements/RenderCustomComponent/index.js.map +1 -1
  120. package/dist/elements/RenderTitle/index.d.ts.map +1 -1
  121. package/dist/elements/RenderTitle/index.js +12 -7
  122. package/dist/elements/RenderTitle/index.js.map +1 -1
  123. package/dist/elements/SearchFilter/index.d.ts.map +1 -1
  124. package/dist/elements/SearchFilter/index.js +1 -0
  125. package/dist/elements/SearchFilter/index.js.map +1 -1
  126. package/dist/elements/SortComplex/index.d.ts.map +1 -1
  127. package/dist/elements/SortComplex/index.js +1 -0
  128. package/dist/elements/SortComplex/index.js.map +1 -1
  129. package/dist/elements/Table/DefaultCell/fields/Code/index.d.ts.map +1 -1
  130. package/dist/elements/Table/DefaultCell/fields/Code/index.js +1 -0
  131. package/dist/elements/Table/DefaultCell/fields/Code/index.js.map +1 -1
  132. package/dist/elements/Table/DefaultCell/fields/Relationship/index.js +1 -1
  133. package/dist/elements/Table/DefaultCell/fields/Relationship/index.js.map +1 -1
  134. package/dist/elements/TableColumns/buildColumnState.d.ts.map +1 -1
  135. package/dist/elements/TableColumns/buildColumnState.js +1 -0
  136. package/dist/elements/TableColumns/buildColumnState.js.map +1 -1
  137. package/dist/elements/TableColumns/filterFields.d.ts.map +1 -1
  138. package/dist/elements/TableColumns/filterFields.js +1 -0
  139. package/dist/elements/TableColumns/filterFields.js.map +1 -1
  140. package/dist/elements/ThumbnailCard/index.d.ts.map +1 -1
  141. package/dist/elements/ThumbnailCard/index.js +1 -0
  142. package/dist/elements/ThumbnailCard/index.js.map +1 -1
  143. package/dist/elements/WhereBuilder/Condition/Date/index.d.ts.map +1 -1
  144. package/dist/elements/WhereBuilder/Condition/Date/index.js +1 -0
  145. package/dist/elements/WhereBuilder/Condition/Date/index.js.map +1 -1
  146. package/dist/elements/WhereBuilder/Condition/Number/index.d.ts.map +1 -1
  147. package/dist/elements/WhereBuilder/Condition/Number/index.js +1 -0
  148. package/dist/elements/WhereBuilder/Condition/Number/index.js.map +1 -1
  149. package/dist/elements/WhereBuilder/Condition/Relationship/index.d.ts.map +1 -1
  150. package/dist/elements/WhereBuilder/Condition/Relationship/index.js +106 -73
  151. package/dist/elements/WhereBuilder/Condition/Relationship/index.js.map +1 -1
  152. package/dist/elements/WhereBuilder/Condition/Select/index.d.ts.map +1 -1
  153. package/dist/elements/WhereBuilder/Condition/Select/index.js +1 -0
  154. package/dist/elements/WhereBuilder/Condition/Select/index.js.map +1 -1
  155. package/dist/elements/WhereBuilder/Condition/Text/index.d.ts.map +1 -1
  156. package/dist/elements/WhereBuilder/Condition/Text/index.js +1 -0
  157. package/dist/elements/WhereBuilder/Condition/Text/index.js.map +1 -1
  158. package/dist/elements/WhereBuilder/Condition/index.d.ts.map +1 -1
  159. package/dist/elements/WhereBuilder/Condition/index.js +8 -7
  160. package/dist/elements/WhereBuilder/Condition/index.js.map +1 -1
  161. package/dist/elements/WhereBuilder/index.d.ts.map +1 -1
  162. package/dist/elements/WhereBuilder/index.js +56 -52
  163. package/dist/elements/WhereBuilder/index.js.map +1 -1
  164. package/dist/elements/WhereBuilder/reduceFieldMap.d.ts.map +1 -1
  165. package/dist/elements/WhereBuilder/reduceFieldMap.js +1 -0
  166. package/dist/elements/WhereBuilder/reduceFieldMap.js.map +1 -1
  167. package/dist/fields/Array/ArrayRow.d.ts.map +1 -1
  168. package/dist/fields/Array/ArrayRow.js +1 -0
  169. package/dist/fields/Array/ArrayRow.js.map +1 -1
  170. package/dist/fields/Array/index.d.ts.map +1 -1
  171. package/dist/fields/Array/index.js +6 -6
  172. package/dist/fields/Array/index.js.map +1 -1
  173. package/dist/fields/Blocks/BlocksDrawer/BlockSearch/index.d.ts.map +1 -1
  174. package/dist/fields/Blocks/BlocksDrawer/BlockSearch/index.js +1 -0
  175. package/dist/fields/Blocks/BlocksDrawer/BlockSearch/index.js.map +1 -1
  176. package/dist/fields/Blocks/SectionTitle/index.d.ts.map +1 -1
  177. package/dist/fields/Blocks/SectionTitle/index.js +1 -0
  178. package/dist/fields/Blocks/SectionTitle/index.js.map +1 -1
  179. package/dist/fields/Blocks/index.d.ts.map +1 -1
  180. package/dist/fields/Blocks/index.js +6 -6
  181. package/dist/fields/Blocks/index.js.map +1 -1
  182. package/dist/fields/Checkbox/index.d.ts.map +1 -1
  183. package/dist/fields/Checkbox/index.js +6 -6
  184. package/dist/fields/Checkbox/index.js.map +1 -1
  185. package/dist/fields/Code/index.d.ts.map +1 -1
  186. package/dist/fields/Code/index.js +5 -5
  187. package/dist/fields/Code/index.js.map +1 -1
  188. package/dist/fields/Collapsible/index.d.ts.map +1 -1
  189. package/dist/fields/Collapsible/index.js +5 -2
  190. package/dist/fields/Collapsible/index.js.map +1 -1
  191. package/dist/fields/DateTime/index.js +5 -5
  192. package/dist/fields/DateTime/index.js.map +1 -1
  193. package/dist/fields/Email/index.d.ts.map +1 -1
  194. package/dist/fields/Email/index.js +4 -4
  195. package/dist/fields/Email/index.js.map +1 -1
  196. package/dist/fields/Group/index.d.ts.map +1 -1
  197. package/dist/fields/Group/index.js +5 -3
  198. package/dist/fields/Group/index.js.map +1 -1
  199. package/dist/fields/JSON/index.d.ts.map +1 -1
  200. package/dist/fields/JSON/index.js +7 -7
  201. package/dist/fields/JSON/index.js.map +1 -1
  202. package/dist/fields/Number/index.d.ts.map +1 -1
  203. package/dist/fields/Number/index.js +7 -7
  204. package/dist/fields/Number/index.js.map +1 -1
  205. package/dist/fields/Password/index.d.ts.map +1 -1
  206. package/dist/fields/Password/index.js +6 -4
  207. package/dist/fields/Password/index.js.map +1 -1
  208. package/dist/fields/RadioGroup/index.d.ts.map +1 -1
  209. package/dist/fields/RadioGroup/index.js +5 -5
  210. package/dist/fields/RadioGroup/index.js.map +1 -1
  211. package/dist/fields/Relationship/findOptionsByValue.js +1 -1
  212. package/dist/fields/Relationship/findOptionsByValue.js.map +1 -1
  213. package/dist/fields/Relationship/index.d.ts.map +1 -1
  214. package/dist/fields/Relationship/index.js +6 -4
  215. package/dist/fields/Relationship/index.js.map +1 -1
  216. package/dist/fields/Select/index.d.ts.map +1 -1
  217. package/dist/fields/Select/index.js +5 -5
  218. package/dist/fields/Select/index.js.map +1 -1
  219. package/dist/fields/Tabs/index.d.ts.map +1 -1
  220. package/dist/fields/Tabs/index.js.map +1 -1
  221. package/dist/fields/Text/index.d.ts.map +1 -1
  222. package/dist/fields/Text/index.js +5 -5
  223. package/dist/fields/Text/index.js.map +1 -1
  224. package/dist/fields/Textarea/index.d.ts.map +1 -1
  225. package/dist/fields/Textarea/index.js +3 -3
  226. package/dist/fields/Textarea/index.js.map +1 -1
  227. package/dist/fields/Upload/index.d.ts.map +1 -1
  228. package/dist/fields/Upload/index.js +3 -3
  229. package/dist/fields/Upload/index.js.map +1 -1
  230. package/dist/forms/FieldPropsProvider/index.d.ts +1 -0
  231. package/dist/forms/FieldPropsProvider/index.d.ts.map +1 -1
  232. package/dist/forms/FieldPropsProvider/index.js.map +1 -1
  233. package/dist/forms/Form/context.d.ts +3 -1
  234. package/dist/forms/Form/context.d.ts.map +1 -1
  235. package/dist/forms/Form/context.js +3 -1
  236. package/dist/forms/Form/context.js.map +1 -1
  237. package/dist/forms/Form/getSiblingData.d.ts.map +1 -1
  238. package/dist/forms/Form/getSiblingData.js +1 -0
  239. package/dist/forms/Form/getSiblingData.js.map +1 -1
  240. package/dist/forms/Form/index.d.ts.map +1 -1
  241. package/dist/forms/Form/index.js +28 -11
  242. package/dist/forms/Form/index.js.map +1 -1
  243. package/dist/forms/Form/initContextState.d.ts.map +1 -1
  244. package/dist/forms/Form/initContextState.js +1 -0
  245. package/dist/forms/Form/initContextState.js.map +1 -1
  246. package/dist/forms/Form/types.d.ts +2 -0
  247. package/dist/forms/Form/types.d.ts.map +1 -1
  248. package/dist/forms/Form/types.js.map +1 -1
  249. package/dist/forms/RenderFields/index.d.ts.map +1 -1
  250. package/dist/forms/RenderFields/index.js +6 -2
  251. package/dist/forms/RenderFields/index.js.map +1 -1
  252. package/dist/forms/RenderFields/types.d.ts +8 -1
  253. package/dist/forms/RenderFields/types.d.ts.map +1 -1
  254. package/dist/forms/RenderFields/types.js.map +1 -1
  255. package/dist/forms/Submit/index.d.ts.map +1 -1
  256. package/dist/forms/Submit/index.js +3 -2
  257. package/dist/forms/Submit/index.js.map +1 -1
  258. package/dist/forms/buildStateFromSchema/calculateDefaultValues/index.d.ts +5 -3
  259. package/dist/forms/buildStateFromSchema/calculateDefaultValues/index.d.ts.map +1 -1
  260. package/dist/forms/buildStateFromSchema/calculateDefaultValues/index.js +4 -3
  261. package/dist/forms/buildStateFromSchema/calculateDefaultValues/index.js.map +1 -1
  262. package/dist/forms/buildStateFromSchema/calculateDefaultValues/iterateFields.d.ts +5 -3
  263. package/dist/forms/buildStateFromSchema/calculateDefaultValues/iterateFields.d.ts.map +1 -1
  264. package/dist/forms/buildStateFromSchema/calculateDefaultValues/iterateFields.js +4 -3
  265. package/dist/forms/buildStateFromSchema/calculateDefaultValues/iterateFields.js.map +1 -1
  266. package/dist/forms/buildStateFromSchema/calculateDefaultValues/promise.d.ts +5 -3
  267. package/dist/forms/buildStateFromSchema/calculateDefaultValues/promise.d.ts.map +1 -1
  268. package/dist/forms/buildStateFromSchema/calculateDefaultValues/promise.js +21 -15
  269. package/dist/forms/buildStateFromSchema/calculateDefaultValues/promise.js.map +1 -1
  270. package/dist/forms/buildStateFromSchema/index.d.ts.map +1 -1
  271. package/dist/forms/buildStateFromSchema/index.js +3 -2
  272. package/dist/forms/buildStateFromSchema/index.js.map +1 -1
  273. package/dist/forms/useField/index.d.ts.map +1 -1
  274. package/dist/forms/useField/index.js +5 -2
  275. package/dist/forms/useField/index.js.map +1 -1
  276. package/dist/forms/useField/types.d.ts +1 -0
  277. package/dist/forms/useField/types.d.ts.map +1 -1
  278. package/dist/forms/useField/types.js.map +1 -1
  279. package/dist/icons/Plus/index.d.ts.map +1 -1
  280. package/dist/icons/Plus/index.js +1 -0
  281. package/dist/icons/Plus/index.js.map +1 -1
  282. package/dist/icons/Plus/index.scss +0 -3
  283. package/dist/providers/ComponentMap/buildComponentMap/fields.d.ts.map +1 -1
  284. package/dist/providers/ComponentMap/buildComponentMap/fields.js +1 -0
  285. package/dist/providers/ComponentMap/buildComponentMap/fields.js.map +1 -1
  286. package/dist/providers/DocumentInfo/index.d.ts.map +1 -1
  287. package/dist/providers/DocumentInfo/index.js +67 -53
  288. package/dist/providers/DocumentInfo/index.js.map +1 -1
  289. package/dist/providers/DocumentInfo/types.d.ts +4 -0
  290. package/dist/providers/DocumentInfo/types.d.ts.map +1 -1
  291. package/dist/providers/DocumentInfo/types.js.map +1 -1
  292. package/dist/providers/Root/index.d.ts +1 -2
  293. package/dist/providers/Root/index.d.ts.map +1 -1
  294. package/dist/providers/Root/index.js.map +1 -1
  295. package/dist/providers/Translation/index.d.ts +1 -5
  296. package/dist/providers/Translation/index.d.ts.map +1 -1
  297. package/dist/providers/Translation/index.js.map +1 -1
  298. package/dist/utilities/buildFieldSchemaMap/index.d.ts +8 -0
  299. package/dist/utilities/buildFieldSchemaMap/index.d.ts.map +1 -0
  300. package/dist/utilities/buildFieldSchemaMap/index.js +29 -0
  301. package/dist/utilities/buildFieldSchemaMap/index.js.map +1 -0
  302. package/dist/utilities/buildFieldSchemaMap/traverseFields.d.ts +14 -0
  303. package/dist/utilities/buildFieldSchemaMap/traverseFields.d.ts.map +1 -0
  304. package/dist/utilities/buildFieldSchemaMap/traverseFields.js +75 -0
  305. package/dist/utilities/buildFieldSchemaMap/traverseFields.js.map +1 -0
  306. package/dist/utilities/buildFieldSchemaMap/types.d.ts +3 -0
  307. package/dist/utilities/buildFieldSchemaMap/types.d.ts.map +1 -0
  308. package/dist/utilities/buildFieldSchemaMap/types.js +3 -0
  309. package/dist/utilities/buildFieldSchemaMap/types.js.map +1 -0
  310. package/dist/utilities/buildFormState.d.ts +7 -0
  311. package/dist/utilities/buildFormState.d.ts.map +1 -0
  312. package/dist/utilities/buildFormState.js +162 -0
  313. package/dist/utilities/buildFormState.js.map +1 -0
  314. package/dist/utilities/getFormState.d.ts +1 -0
  315. package/dist/utilities/getFormState.d.ts.map +1 -1
  316. package/dist/utilities/getFormState.js +5 -2
  317. package/dist/utilities/getFormState.js.map +1 -1
  318. package/dist/utilities/reduceFieldsToValues.d.ts.map +1 -1
  319. package/dist/utilities/reduceFieldsToValues.js +1 -0
  320. package/dist/utilities/reduceFieldsToValues.js.map +1 -1
  321. package/package.json +16 -6
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/fields/Text/index.tsx"],"sourcesContent":["'use client'\nimport type { ClientValidate } from 'payload/types'\n\nimport React, { useCallback, useEffect, useState } from 'react'\n\nimport type { Option } from '../../elements/ReactSelect/types.js'\nimport type { TextFieldProps, TextInputProps } 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 { useLocale } from '../../providers/Locale/index.js'\nimport { isFieldRTL } from '../shared/index.js'\nimport { TextInput } from './Input.js'\nimport './index.scss'\n\nexport { TextFieldProps, TextInput, TextInputProps }\n\nconst TextField: React.FC<TextFieldProps> = (props) => {\n const {\n name,\n AfterInput,\n BeforeInput,\n CustomDescription,\n CustomError,\n CustomLabel,\n className,\n descriptionProps,\n errorProps,\n hasMany,\n inputRef,\n label,\n labelProps,\n localized,\n maxLength,\n maxRows,\n minLength,\n minRows,\n path: pathFromProps,\n placeholder,\n readOnly: readOnlyFromProps,\n required,\n rtl,\n style,\n validate,\n width,\n } = props\n\n const locale = useLocale()\n\n const { localization: localizationConfig } = useConfig()\n\n const memoizedValidate: ClientValidate = useCallback(\n (value, options) => {\n if (typeof validate === 'function')\n return validate(value, { ...options, maxLength, minLength, required })\n },\n [validate, minLength, maxLength, required],\n )\n\n const { path: pathFromContext, readOnly: readOnlyFromContext } = useFieldProps()\n const readOnly = readOnlyFromProps || readOnlyFromContext\n\n const { formProcessing, path, setValue, showError, value } = useField({\n path: pathFromContext || pathFromProps || name,\n validate: memoizedValidate,\n })\n\n const renderRTL = isFieldRTL({\n fieldLocalized: localized,\n fieldRTL: rtl,\n locale,\n localizationConfig: localizationConfig || undefined,\n })\n\n const [valueToRender, setValueToRender] = useState<\n { id: string; label: string; value: { value: number } }[]\n >([]) // Only for hasMany\n\n const handleHasManyChange = useCallback(\n (selectedOption) => {\n if (!readOnly) {\n let newValue\n if (!selectedOption) {\n newValue = []\n } else if (Array.isArray(selectedOption)) {\n newValue = selectedOption.map((option) => option.value?.value || option.value)\n } else {\n newValue = [selectedOption.value?.value || selectedOption.value]\n }\n\n setValue(newValue)\n }\n },\n [readOnly, setValue],\n )\n\n // useEffect update valueToRender:\n useEffect(() => {\n if (hasMany && Array.isArray(value)) {\n setValueToRender(\n value.map((val, index) => {\n return {\n id: `${val}${index}`, // append index to avoid duplicate keys but allow duplicate numbers\n label: `${val}`,\n value: {\n // React-select automatically uses \"label-value\" as a key, so we will get that react duplicate key warning if we just pass in the value as multiple values can be the same. So we need to append the index to the toString() of the value to avoid that warning, as it uses that as the key.\n toString: () => `${val}${index}`,\n value: val?.value || val,\n },\n }\n }),\n )\n }\n }, [value, hasMany])\n\n return (\n <TextInput\n AfterInput={AfterInput}\n BeforeInput={BeforeInput}\n CustomDescription={CustomDescription}\n CustomError={CustomError}\n CustomLabel={CustomLabel}\n className={className}\n descriptionProps={descriptionProps}\n errorProps={errorProps}\n hasMany={hasMany}\n inputRef={inputRef}\n label={label}\n labelProps={labelProps}\n maxRows={maxRows}\n minRows={minRows}\n onChange={\n hasMany\n ? handleHasManyChange\n : (e) => {\n setValue(e.target.value)\n }\n }\n path={path}\n placeholder={placeholder}\n readOnly={formProcessing || readOnly}\n required={required}\n rtl={renderRTL}\n showError={showError}\n style={style}\n value={(value as string) || ''}\n valueToRender={valueToRender as Option[]}\n width={width}\n />\n )\n}\n\nexport const Text = withCondition(TextField)\n"],"names":["React","useCallback","useEffect","useState","useFieldProps","useField","withCondition","useConfig","useLocale","isFieldRTL","TextInput","TextField","props","name","AfterInput","BeforeInput","CustomDescription","CustomError","CustomLabel","className","descriptionProps","errorProps","hasMany","inputRef","label","labelProps","localized","maxLength","maxRows","minLength","minRows","path","pathFromProps","placeholder","readOnly","readOnlyFromProps","required","rtl","style","validate","width","locale","localization","localizationConfig","memoizedValidate","value","options","pathFromContext","readOnlyFromContext","formProcessing","setValue","showError","renderRTL","fieldLocalized","fieldRTL","undefined","valueToRender","setValueToRender","handleHasManyChange","selectedOption","newValue","Array","isArray","map","option","val","index","id","toString","onChange","e","target","Text"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;;AAGA,OAAOA,SAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAK/D,SAASC,aAAa,QAAQ,0CAAyC;AACvE,SAASC,QAAQ,QAAQ,gCAA+B;AACxD,SAASC,aAAa,QAAQ,qCAAoC;AAClE,SAASC,SAAS,QAAQ,kCAAiC;AAC3D,SAASC,SAAS,QAAQ,kCAAiC;AAC3D,SAASC,UAAU,QAAQ,qBAAoB;AAC/C,SAASC,SAAS,QAAQ,aAAY;AAGtC,SAAyBA,SAAS,GAAkB;AAEpD,MAAMC,YAAsC,CAACC;IAC3C,MAAM,EACJC,IAAI,EACJC,UAAU,EACVC,WAAW,EACXC,iBAAiB,EACjBC,WAAW,EACXC,WAAW,EACXC,SAAS,EACTC,gBAAgB,EAChBC,UAAU,EACVC,OAAO,EACPC,QAAQ,EACRC,KAAK,EACLC,UAAU,EACVC,SAAS,EACTC,SAAS,EACTC,OAAO,EACPC,SAAS,EACTC,OAAO,EACPC,MAAMC,aAAa,EACnBC,WAAW,EACXC,UAAUC,iBAAiB,EAC3BC,QAAQ,EACRC,GAAG,EACHC,KAAK,EACLC,QAAQ,EACRC,KAAK,EACN,GAAG5B;IAEJ,MAAM6B,SAASjC;IAEf,MAAM,EAAEkC,cAAcC,kBAAkB,EAAE,GAAGpC;IAE7C,MAAMqC,mBAAmC3C,YACvC,CAAC4C,OAAOC;QACN,IAAI,OAAOP,aAAa,YACtB,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AM,CAAC,EAAEH,IAAI,EAAEC,MAAM,CAAC;wBAChCrB,OAAOoB,KAAKpB,SAASoB;oBACvB;gBACF;YACF;QAEJ;IACF,GAAG;QAACpB;QAAOvB;KAAQ;IAEnB,qBACE,KAACZ;QACCI,YAAYA;QACZC,aAAaA;QACbC,mBAAmBA;QACnBC,aAAaA;QACbC,aAAaA;QACbC,WAAWA;QACXC,kBAAkBA;QAClBC,YAAYA;QACZC,SAASA;QACTC,UAAUA;QACVC,OAAOA;QACPC,YAAYA;QACZG,SAASA;QACTE,SAASA;QACTuC,UACE/C,UACIoC,sBACA,CAACY;YACCpB,SAASoB,EAAEC,MAAM,CAAC1B,KAAK;QACzB;QAENd,MAAMA;QACNE,aAAaA;QACbC,UAAUe,kBAAkBf;QAC5BE,UAAUA;QACVC,KAAKe;QACLD,WAAWA;QACXb,OAAOA;QACPO,OAAO,AAACA,SAAoB;QAC5BW,eAAeA;QACfhB,OAAOA;;AAGb;AAEA,OAAO,MAAMgC,OAAOlE,cAAcK,WAAU"}
1
+ {"version":3,"sources":["../../../src/fields/Text/index.tsx"],"sourcesContent":["'use client'\nimport type { ClientValidate } from 'payload/types'\n\nimport React, { useCallback, useEffect, useState } from 'react'\n\nimport type { Option } from '../../elements/ReactSelect/types.js'\nimport type { TextFieldProps, TextInputProps } 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 { useLocale } from '../../providers/Locale/index.js'\nimport { isFieldRTL } from '../shared/index.js'\nimport { TextInput } from './Input.js'\nimport './index.scss'\n\nexport { TextFieldProps, TextInput, TextInputProps }\n\nconst TextField: React.FC<TextFieldProps> = (props) => {\n const {\n name,\n AfterInput,\n BeforeInput,\n CustomDescription,\n CustomError,\n CustomLabel,\n className,\n descriptionProps,\n errorProps,\n hasMany,\n inputRef,\n label,\n labelProps,\n localized,\n maxLength,\n maxRows,\n minLength,\n minRows,\n path: pathFromProps,\n placeholder,\n readOnly: readOnlyFromProps,\n required,\n rtl,\n style,\n validate,\n width,\n } = props\n\n const locale = useLocale()\n\n const { localization: localizationConfig } = useConfig()\n\n const memoizedValidate: ClientValidate = useCallback(\n (value, options) => {\n if (typeof validate === 'function')\n return validate(value, { ...options, maxLength, minLength, required })\n },\n [validate, minLength, maxLength, required],\n )\n\n const { path: pathFromContext, readOnly: readOnlyFromContext } = useFieldProps()\n\n const { formInitializing, formProcessing, path, setValue, showError, value } = useField({\n path: pathFromContext || pathFromProps || name,\n validate: memoizedValidate,\n })\n\n const disabled = readOnlyFromProps || readOnlyFromContext || formProcessing || formInitializing\n\n const renderRTL = isFieldRTL({\n fieldLocalized: localized,\n fieldRTL: rtl,\n locale,\n localizationConfig: localizationConfig || undefined,\n })\n\n const [valueToRender, setValueToRender] = useState<\n { id: string; label: string; value: { value: number } }[]\n >([]) // Only for hasMany\n\n const handleHasManyChange = useCallback(\n (selectedOption) => {\n if (!disabled) {\n let newValue\n if (!selectedOption) {\n newValue = []\n } else if (Array.isArray(selectedOption)) {\n newValue = selectedOption.map((option) => option.value?.value || option.value)\n } else {\n newValue = [selectedOption.value?.value || selectedOption.value]\n }\n\n setValue(newValue)\n }\n },\n [disabled, setValue],\n )\n\n // useEffect update valueToRender:\n useEffect(() => {\n if (hasMany && Array.isArray(value)) {\n setValueToRender(\n value.map((val, index) => {\n return {\n id: `${val}${index}`, // append index to avoid duplicate keys but allow duplicate numbers\n label: `${val}`,\n value: {\n // React-select automatically uses \"label-value\" as a key, so we will get that react duplicate key warning if we just pass in the value as multiple values can be the same. So we need to append the index to the toString() of the value to avoid that warning, as it uses that as the key.\n toString: () => `${val}${index}`,\n value: val?.value || val,\n },\n }\n }),\n )\n }\n }, [value, hasMany])\n\n return (\n <TextInput\n AfterInput={AfterInput}\n BeforeInput={BeforeInput}\n CustomDescription={CustomDescription}\n CustomError={CustomError}\n CustomLabel={CustomLabel}\n className={className}\n descriptionProps={descriptionProps}\n errorProps={errorProps}\n hasMany={hasMany}\n inputRef={inputRef}\n label={label}\n labelProps={labelProps}\n maxRows={maxRows}\n minRows={minRows}\n onChange={\n hasMany\n ? handleHasManyChange\n : (e) => {\n setValue(e.target.value)\n }\n }\n path={path}\n placeholder={placeholder}\n readOnly={disabled}\n required={required}\n rtl={renderRTL}\n showError={showError}\n style={style}\n value={(value as string) || ''}\n valueToRender={valueToRender as Option[]}\n width={width}\n />\n )\n}\n\nexport const Text = withCondition(TextField)\n"],"names":["React","useCallback","useEffect","useState","useFieldProps","useField","withCondition","useConfig","useLocale","isFieldRTL","TextInput","TextField","props","name","AfterInput","BeforeInput","CustomDescription","CustomError","CustomLabel","className","descriptionProps","errorProps","hasMany","inputRef","label","labelProps","localized","maxLength","maxRows","minLength","minRows","path","pathFromProps","placeholder","readOnly","readOnlyFromProps","required","rtl","style","validate","width","locale","localization","localizationConfig","memoizedValidate","value","options","pathFromContext","readOnlyFromContext","formInitializing","formProcessing","setValue","showError","disabled","renderRTL","fieldLocalized","fieldRTL","undefined","valueToRender","setValueToRender","handleHasManyChange","selectedOption","newValue","Array","isArray","map","option","val","index","id","toString","onChange","e","target","Text"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;;AAGA,OAAOA,SAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAK/D,SAASC,aAAa,QAAQ,0CAAyC;AACvE,SAASC,QAAQ,QAAQ,gCAA+B;AACxD,SAASC,aAAa,QAAQ,qCAAoC;AAClE,SAASC,SAAS,QAAQ,kCAAiC;AAC3D,SAASC,SAAS,QAAQ,kCAAiC;AAC3D,SAASC,UAAU,QAAQ,qBAAoB;AAC/C,SAASC,SAAS,QAAQ,aAAY;AAGtC,SAAyBA,SAAS,GAA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1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/Textarea/index.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAsB,MAAM,OAAO,CAAA;AAE1C,OAAO,KAAK,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAQxE,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAC1C,OAAO,cAAc,CAAA;AAErB,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,aAAa,EAAE,CAAA;AAsFhE,eAAO,MAAM,QAAQ,8BAA+B,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/Textarea/index.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAsB,MAAM,OAAO,CAAA;AAE1C,OAAO,KAAK,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAQxE,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAC1C,OAAO,cAAc,CAAA;AAErB,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,aAAa,EAAE,CAAA;AAuFhE,eAAO,MAAM,QAAQ,8BAA+B,CAAA"}
@@ -34,11 +34,11 @@ const TextareaField = (props)=>{
34
34
  minLength
35
35
  ]);
36
36
  const { path: pathFromContext, readOnly: readOnlyFromContext } = useFieldProps();
37
- const readOnly = readOnlyFromProps || readOnlyFromContext;
38
- const { path, setValue, showError, value } = useField({
37
+ const { formInitializing, formProcessing, path, setValue, showError, value } = useField({
39
38
  path: pathFromContext || pathFromProps || name,
40
39
  validate: memoizedValidate
41
40
  });
41
+ const disabled = readOnlyFromProps || readOnlyFromContext || formProcessing || formInitializing;
42
42
  return /*#__PURE__*/ _jsx(TextareaInput, {
43
43
  AfterInput: AfterInput,
44
44
  BeforeInput: BeforeInput,
@@ -55,7 +55,7 @@ const TextareaField = (props)=>{
55
55
  },
56
56
  path: path,
57
57
  placeholder: getTranslation(placeholder, i18n),
58
- readOnly: readOnly,
58
+ readOnly: disabled,
59
59
  required: required,
60
60
  rows: rows,
61
61
  rtl: isRTL,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/fields/Textarea/index.tsx"],"sourcesContent":["/* eslint-disable react/destructuring-assignment */\n'use client'\nimport type { ClientValidate } from 'payload/types'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport React, { useCallback } from 'react'\n\nimport type { TextAreaInputProps, TextareaFieldProps } 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 { useTranslation } from '../../providers/Translation/index.js'\nimport { isFieldRTL } from '../shared/index.js'\nimport { TextareaInput } from './Input.js'\nimport './index.scss'\n\nexport { TextAreaInputProps, TextareaFieldProps, TextareaInput }\n\nconst TextareaField: React.FC<TextareaFieldProps> = (props) => {\n const {\n name,\n AfterInput,\n BeforeInput,\n CustomDescription,\n CustomError,\n CustomLabel,\n className,\n descriptionProps,\n errorProps,\n label,\n labelProps,\n locale,\n localized,\n maxLength,\n minLength,\n path: pathFromProps,\n placeholder,\n readOnly: readOnlyFromProps,\n required,\n rows,\n rtl,\n style,\n validate,\n width,\n } = props\n\n const { i18n } = useTranslation()\n\n const { localization } = useConfig()\n\n const isRTL = isFieldRTL({\n fieldLocalized: localized,\n fieldRTL: rtl,\n locale,\n localizationConfig: localization || undefined,\n })\n\n const memoizedValidate: ClientValidate = useCallback(\n (value, options) => {\n if (typeof validate === 'function')\n return validate(value, { ...options, maxLength, minLength, required })\n },\n [validate, required, maxLength, minLength],\n )\n\n const { path: pathFromContext, readOnly: readOnlyFromContext } = useFieldProps()\n const readOnly = readOnlyFromProps || readOnlyFromContext\n\n const { path, setValue, showError, value } = useField<string>({\n path: pathFromContext || pathFromProps || name,\n validate: memoizedValidate,\n })\n\n return (\n <TextareaInput\n AfterInput={AfterInput}\n BeforeInput={BeforeInput}\n CustomDescription={CustomDescription}\n CustomError={CustomError}\n CustomLabel={CustomLabel}\n className={className}\n descriptionProps={descriptionProps}\n errorProps={errorProps}\n label={label}\n labelProps={labelProps}\n onChange={(e) => {\n setValue(e.target.value)\n }}\n path={path}\n placeholder={getTranslation(placeholder, i18n)}\n readOnly={readOnly}\n required={required}\n rows={rows}\n rtl={isRTL}\n showError={showError}\n style={style}\n value={value}\n width={width}\n />\n )\n}\n\nexport const Textarea = withCondition(TextareaField)\n"],"names":["getTranslation","React","useCallback","useFieldProps","useField","withCondition","useConfig","useTranslation","isFieldRTL","TextareaInput","TextareaField","props","name","AfterInput","BeforeInput","CustomDescription","CustomError","CustomLabel","className","descriptionProps","errorProps","label","labelProps","locale","localized","maxLength","minLength","path","pathFromProps","placeholder","readOnly","readOnlyFromProps","required","rows","rtl","style","validate","width","i18n","localization","isRTL","fieldLocalized","fieldRTL","localizationConfig","undefined","memoizedValidate","value","options","pathFromContext","readOnlyFromContext","setValue","showError","onChange","e","target","Textarea"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,iDAAiD,GACjD;;AAGA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,OAAOC,SAASC,WAAW,QAAQ,QAAO;AAI1C,SAASC,aAAa,QAAQ,0CAAyC;AACvE,SAASC,QAAQ,QAAQ,gCAA+B;AACxD,SAASC,aAAa,QAAQ,qCAAoC;AAClE,SAASC,SAAS,QAAQ,kCAAiC;AAC3D,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,UAAU,QAAQ,qBAAoB;AAC/C,SAASC,aAAa,QAAQ,aAAY;AAG1C,SAAiDA,aAAa,GAAE;AAEhE,MAAMC,gBAA8C,CAACC;IACnD,MAAM,EACJC,IAAI,EACJC,UAAU,EACVC,WAAW,EACXC,iBAAiB,EACjBC,WAAW,EACXC,WAAW,EACXC,SAAS,EACTC,gBAAgB,E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T,OAAOA;;AAGb;AAEA,OAAO,MAAMkB,WAAWlD,cAAcK,eAAc"}
1
+ {"version":3,"sources":["../../../src/fields/Textarea/index.tsx"],"sourcesContent":["/* eslint-disable react/destructuring-assignment */\n'use client'\nimport type { ClientValidate } from 'payload/types'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport React, { useCallback } from 'react'\n\nimport type { TextAreaInputProps, TextareaFieldProps } 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 { useTranslation } from '../../providers/Translation/index.js'\nimport { isFieldRTL } from '../shared/index.js'\nimport { TextareaInput } from './Input.js'\nimport './index.scss'\n\nexport { TextAreaInputProps, TextareaFieldProps, TextareaInput }\n\nconst TextareaField: React.FC<TextareaFieldProps> = (props) => {\n const {\n name,\n AfterInput,\n BeforeInput,\n CustomDescription,\n CustomError,\n CustomLabel,\n className,\n descriptionProps,\n errorProps,\n label,\n labelProps,\n locale,\n localized,\n maxLength,\n minLength,\n path: pathFromProps,\n placeholder,\n readOnly: readOnlyFromProps,\n required,\n rows,\n rtl,\n style,\n validate,\n width,\n } = props\n\n const { i18n } = useTranslation()\n\n const { localization } = useConfig()\n\n const isRTL = isFieldRTL({\n fieldLocalized: localized,\n fieldRTL: rtl,\n locale,\n localizationConfig: localization || undefined,\n })\n\n const memoizedValidate: ClientValidate = useCallback(\n (value, options) => {\n if (typeof validate === 'function')\n return validate(value, { ...options, maxLength, minLength, required })\n },\n [validate, required, maxLength, minLength],\n )\n\n const { path: pathFromContext, readOnly: readOnlyFromContext } = useFieldProps()\n\n const { formInitializing, formProcessing, path, setValue, showError, value } = useField<string>({\n path: pathFromContext || pathFromProps || name,\n validate: memoizedValidate,\n })\n\n const disabled = readOnlyFromProps || readOnlyFromContext || formProcessing || formInitializing\n\n return (\n <TextareaInput\n AfterInput={AfterInput}\n BeforeInput={BeforeInput}\n CustomDescription={CustomDescription}\n CustomError={CustomError}\n CustomLabel={CustomLabel}\n className={className}\n descriptionProps={descriptionProps}\n errorProps={errorProps}\n label={label}\n labelProps={labelProps}\n onChange={(e) => {\n setValue(e.target.value)\n }}\n path={path}\n placeholder={getTranslation(placeholder, i18n)}\n readOnly={disabled}\n required={required}\n rows={rows}\n rtl={isRTL}\n showError={showError}\n style={style}\n value={value}\n width={width}\n />\n )\n}\n\nexport const Textarea = withCondition(TextareaField)\n"],"names":["getTranslation","React","useCallback","useFieldProps","useField","withCondition","useConfig","useTranslation","isFieldRTL","TextareaInput","TextareaField","props","name","AfterInput","BeforeInput","CustomDescription","CustomError","CustomLabel","className","descriptionProps","errorProps","label","labelProps","locale","localized","maxLength","minLength","path","pathFromProps","placeholder","readOnly","readOnlyFromProps","required","rows","rtl","style","validate","width","i18n","localization","isRTL","fieldLocalized","fieldRTL","localizationConfig","undefined","memoizedValidate","value","options","pathFromContext","readOnlyFromContext","formInitializing","formProcessing","setValue","showError","disabled","onChange","e","target","Textarea"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,iDAAiD,GACjD;;AAGA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,OAAOC,SAASC,WAAW,QAAQ,QAAO;AAI1C,SAASC,aAAa,QAAQ,0CAAyC;AACvE,SAASC,QAAQ,QAAQ,gCAA+B;AACxD,SAASC,aAAa,QAAQ,qCAAoC;AAClE,SAASC,SAAS,QAAQ,kCAAiC;AAC3D,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,UAAU,QAAQ,qBAAoB;AAC/C,SAASC,aAAa,QAAQ,aAAY;AAG1C,SAAiDA,aAAa,GAAE;AAEhE,MAAMC,gBAA8C,CAACC;IACnD,MAAM,EACJC,IAAI,EACJC,UAAU,EACVC,WAAW,EACXC,iBAAiB,EACjBC,WAAW,EACXC,WAAW,EACXC,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A;QACVC,MAAMA;QACNC,KAAKM;QACLa,WAAWA;QACXlB,OAAOA;QACPW,OAAOA;QACPT,OAAOA;;AAGb;AAEA,OAAO,MAAMqB,WAAWrD,cAAcK,eAAc"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/Upload/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAsB,MAAM,OAAO,CAAA;AAE1C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAClD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAMlD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AACxC,OAAO,cAAc,CAAA;AAErB,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,CAAA;AACxC,YAAY,EAAE,gBAAgB,EAAE,CAAA;AAqFhC,eAAO,MAAM,MAAM,4BAAyB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/Upload/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAsB,MAAM,OAAO,CAAA;AAE1C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAClD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAMlD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AACxC,OAAO,cAAc,CAAA;AAErB,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,CAAA;AACxC,YAAY,EAAE,gBAAgB,EAAE,CAAA;AAuFhC,eAAO,MAAM,MAAM,4BAAyB,CAAA"}
@@ -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;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;IAEjE,MAAM,EAAEqC,aAAa,EAAEC,gBAAgB,EAAEC,cAAc,EAAExB,IAAI,EAAEyB,QAAQ,EAAEC,SAAS,EAAER,KAAK,EAAE,GACzFhC,SAAiB;QACfc,MAAMoB,mBAAmBnB;QACzBM,UAAUU;IACZ;IAEF,MAAMU,WAAWxB,qBAAqBkB,uBAAuBG,kBAAkBD;IAE/E,MAAMK,WAAW5C,YACf,CAAC6C;QACC,MAAMC,aAAaD,eAAeE,MAAMF;QACxCJ,SAASK;IACX,GACA;QAACL;KAAS;IAGZ,IAAIZ,WAAWmB,MAAM,EAAE;QACrB,qBACE,KAAC3C;YACCG,mBAAmBA;YACnBC,aAAaA;YACbC,aAAaA;YACbiB,KAAKA;YACLhB,WAAWA;YACXkB,YAAYA;YACZjB,kBAAkBA;YAClBC,YAAYA;YACZyB,eAAeA;YACfxB,OAAOA;YACPC,YAAYA;YACZ6B,UAAUA;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,M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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,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,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;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,OAAkC,CAAA;AACtD,QAAA,MAAM,YAAY,QAAO,OAAuC,CAAA;AAChE,QAAA,MAAM,gBAAgB,QAAO,OAAuC,CAAA;AACpE,QAAA,MAAM,iBAAiB,QAAO,OAAwC,CAAA;AACtE,QAAA,MAAM,eAAe,QAAO,OAAsC,CAAA;AAElE;;;;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,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EAChB,OAAO,EACP,aAAa,EACb,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,YAAY,GACb,CAAA"}
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,mBAAmB,kCAAuB,CAAA;AAChD,QAAA,MAAM,iBAAiB,+DAAiE,CAAA;AAExF;;;;GAIG;AACH,QAAA,MAAM,OAAO,QAAO,OAAkC,CAAA;AACtD,QAAA,MAAM,YAAY,QAAO,OAAuC,CAAA;AAChE,QAAA,MAAM,gBAAgB,QAAO,OAAuC,CAAA;AACpE,QAAA,MAAM,iBAAiB,QAAO,OAAwC,CAAA;AACtE,QAAA,MAAM,eAAe,QAAO,OAAsC,CAAA;AAClE,QAAA,MAAM,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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AW6I;QACX9H,QAAQA;QACRwI,UAAU;QACV/I,UAAU,CAACiE,IAAMnC,WAAWI,OAAO,CAAC6B,MAAM,CAAC,CAAC,GAAGE;QAC/C+E,KAAKnH;kBAEL,cAAA,KAAC5D,YAAYgL,QAAQ;YAAC5F,OAAOvB,WAAWI,OAAO;sBAC7C,cAAA,KAAC/D,iBAAiB8K,QAAQ;gBACxB5F,OAAO;oBACLrB;oBACA,GAAGF,WAAWI,OAAO;gBACvB;0BAEA,cAAA,KAAC5D,iBAAiB2K,QAAQ;oBAAC5F,OAAOlD;8BAChC,cAAA,KAAC9B,kBAAkB4K,QAAQ;wBAAC5F,OAAO3B;kCACjC,cAAA,KAACtD,gBAAgB6K,QAAQ;4BAAC5F,OAAO7B;sCAC/B,cAAA,KAACtD,kBAAkB+K,QAAQ;gCAAC5F,OAAOtB;0CAChCxC;;;;;;;;AASnB,EAAC;AAED,SACEtB,WAAW,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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;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"}