@webiny/app-headless-cms 0.0.0-unstable.6e5425ee89 → 0.0.0-unstable.7f63ea0744

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 (516) hide show
  1. package/HeadlessCMS.js +2 -0
  2. package/HeadlessCMS.js.map +1 -1
  3. package/admin/components/ContentEntryForm/ContentEntryForm.js +24 -12
  4. package/admin/components/ContentEntryForm/ContentEntryForm.js.map +1 -1
  5. package/admin/components/ContentEntryForm/Fields.d.ts +2 -2
  6. package/admin/components/ContentEntryForm/Fields.js.map +1 -1
  7. package/admin/components/ContentEntryForm/RenderFieldElement.d.ts +2 -2
  8. package/admin/components/ContentEntryForm/RenderFieldElement.js +5 -2
  9. package/admin/components/ContentEntryForm/RenderFieldElement.js.map +1 -1
  10. package/admin/components/ContentEntryForm/functions/getValue.d.ts +2 -2
  11. package/admin/components/ContentEntryForm/functions/getValue.js.map +1 -1
  12. package/admin/components/ContentEntryForm/functions/setValue.d.ts +2 -2
  13. package/admin/components/ContentEntryForm/functions/setValue.js.map +1 -1
  14. package/admin/components/ContentEntryForm/useBind.d.ts +2 -2
  15. package/admin/components/ContentEntryForm/useBind.js +11 -10
  16. package/admin/components/ContentEntryForm/useBind.js.map +1 -1
  17. package/admin/components/ContentEntryForm/useContentEntryForm.d.ts +1 -2
  18. package/admin/components/ContentEntryForm/useContentEntryForm.js +250 -228
  19. package/admin/components/ContentEntryForm/useContentEntryForm.js.map +1 -1
  20. package/admin/components/ContentModelEditor/{Context.d.ts → ContentModelEditorProvider.d.ts} +10 -4
  21. package/admin/components/ContentModelEditor/{Context.js → ContentModelEditorProvider.js} +114 -170
  22. package/admin/components/ContentModelEditor/ContentModelEditorProvider.js.map +1 -0
  23. package/admin/components/ContentModelEditor/Editor.js +5 -5
  24. package/admin/components/ContentModelEditor/Editor.js.map +1 -1
  25. package/admin/components/ContentModelEditor/FieldsSidebar.js.map +1 -1
  26. package/admin/components/ContentModelEditor/PreviewTab.js +3 -3
  27. package/admin/components/ContentModelEditor/PreviewTab.js.map +1 -1
  28. package/admin/components/ContentModelEditor/index.d.ts +2 -0
  29. package/admin/components/ContentModelEditor/index.js +27 -0
  30. package/admin/components/ContentModelEditor/index.js.map +1 -0
  31. package/admin/components/ContentModelEditor/useModelEditor.d.ts +1 -0
  32. package/admin/components/ContentModelEditor/{useContentModelEditor.js → useModelEditor.js} +4 -4
  33. package/admin/components/ContentModelEditor/useModelEditor.js.map +1 -0
  34. package/admin/{views/contentModelGroups → components}/DelayedOnChange.d.ts +0 -0
  35. package/admin/{views/contentModelGroups → components}/DelayedOnChange.js +0 -0
  36. package/admin/{views/contentModelGroups → components}/DelayedOnChange.js.map +0 -0
  37. package/admin/components/Dialog.d.ts +4 -0
  38. package/admin/components/Dialog.js +28 -0
  39. package/admin/components/Dialog.js.map +1 -0
  40. package/admin/components/DropZone/Center.d.ts +2 -1
  41. package/admin/components/DropZone/Center.js +34 -46
  42. package/admin/components/DropZone/Center.js.map +1 -1
  43. package/admin/components/Droppable.d.ts +1 -0
  44. package/admin/components/Droppable.js +9 -1
  45. package/admin/components/Droppable.js.map +1 -1
  46. package/admin/components/FieldEditor/EditFieldDialog/AppearanceTab.d.ts +2 -8
  47. package/admin/components/FieldEditor/EditFieldDialog/AppearanceTab.js +15 -9
  48. package/admin/components/FieldEditor/EditFieldDialog/AppearanceTab.js.map +1 -1
  49. package/admin/components/FieldEditor/EditFieldDialog/GeneralTab.d.ts +2 -9
  50. package/admin/components/FieldEditor/EditFieldDialog/GeneralTab.js +29 -21
  51. package/admin/components/FieldEditor/EditFieldDialog/GeneralTab.js.map +1 -1
  52. package/admin/components/FieldEditor/EditFieldDialog/PredefinedValues.d.ts +2 -9
  53. package/admin/components/FieldEditor/EditFieldDialog/PredefinedValues.js +23 -26
  54. package/admin/components/FieldEditor/EditFieldDialog/PredefinedValues.js.map +1 -1
  55. package/admin/components/FieldEditor/EditFieldDialog/ValidationsSection.d.ts +10 -0
  56. package/admin/components/FieldEditor/EditFieldDialog/ValidationsSection.js +34 -0
  57. package/admin/components/FieldEditor/EditFieldDialog/ValidationsSection.js.map +1 -0
  58. package/admin/components/FieldEditor/EditFieldDialog/ValidatorsList.d.ts +8 -0
  59. package/admin/components/FieldEditor/EditFieldDialog/ValidatorsList.js +189 -0
  60. package/admin/components/FieldEditor/EditFieldDialog/ValidatorsList.js.map +1 -0
  61. package/admin/components/FieldEditor/EditFieldDialog/getValidators.d.ts +13 -0
  62. package/admin/components/FieldEditor/EditFieldDialog/getValidators.js +91 -0
  63. package/admin/components/FieldEditor/EditFieldDialog/getValidators.js.map +1 -0
  64. package/admin/components/FieldEditor/EditFieldDialog.d.ts +3 -3
  65. package/admin/components/FieldEditor/EditFieldDialog.js +109 -234
  66. package/admin/components/FieldEditor/EditFieldDialog.js.map +1 -1
  67. package/admin/components/FieldEditor/Field.d.ts +5 -5
  68. package/admin/components/FieldEditor/Field.js +46 -38
  69. package/admin/components/FieldEditor/Field.js.map +1 -1
  70. package/admin/components/FieldEditor/FieldEditor.d.ts +4 -4
  71. package/admin/components/FieldEditor/FieldEditor.js +72 -31
  72. package/admin/components/FieldEditor/FieldEditor.js.map +1 -1
  73. package/admin/components/FieldEditor/FieldEditorContext.d.ts +20 -16
  74. package/admin/components/FieldEditor/FieldEditorContext.js +23 -18
  75. package/admin/components/FieldEditor/FieldEditorContext.js.map +1 -1
  76. package/admin/components/FieldEditor/Styled.js +4 -13
  77. package/admin/components/FieldEditor/Styled.js.map +1 -1
  78. package/admin/components/FieldEditor/index.d.ts +1 -1
  79. package/admin/components/FieldEditor/index.js +3 -3
  80. package/admin/components/FieldEditor/index.js.map +1 -1
  81. package/admin/components/FieldEditor/useModelFieldEditor.d.ts +2 -0
  82. package/admin/components/FieldEditor/useModelFieldEditor.js +15 -0
  83. package/admin/components/FieldEditor/useModelFieldEditor.js.map +1 -0
  84. package/admin/components/FieldEditor/utils/deleteField.d.ts +2 -2
  85. package/admin/components/FieldEditor/utils/deleteField.js.map +1 -1
  86. package/admin/components/FieldEditor/utils/getFieldPosition.d.ts +2 -2
  87. package/admin/components/FieldEditor/utils/getFieldPosition.js.map +1 -1
  88. package/admin/components/FieldEditor/utils/moveField.d.ts +3 -3
  89. package/admin/components/FieldEditor/utils/moveField.js.map +1 -1
  90. package/admin/components/IconPicker.d.ts +7 -0
  91. package/admin/{views/contentModelGroups → components}/IconPicker.js +34 -31
  92. package/admin/components/IconPicker.js.map +1 -0
  93. package/admin/components/ModelFieldProvider/ModelFieldContext.d.ts +36 -0
  94. package/admin/components/ModelFieldProvider/ModelFieldContext.js +18 -0
  95. package/admin/components/ModelFieldProvider/ModelFieldContext.js.map +1 -0
  96. package/admin/components/ModelFieldProvider/index.d.ts +2 -0
  97. package/admin/components/ModelFieldProvider/index.js +27 -0
  98. package/admin/components/ModelFieldProvider/index.js.map +1 -0
  99. package/admin/components/ModelFieldProvider/useModelField.d.ts +35 -0
  100. package/admin/components/ModelFieldProvider/useModelField.js +33 -0
  101. package/admin/components/ModelFieldProvider/useModelField.js.map +1 -0
  102. package/admin/components/ModelProvider/ModelContext.d.ts +9 -0
  103. package/admin/components/ModelProvider/ModelContext.js +18 -0
  104. package/admin/components/ModelProvider/ModelContext.js.map +1 -0
  105. package/admin/components/ModelProvider/index.d.ts +2 -0
  106. package/admin/components/ModelProvider/index.js +27 -0
  107. package/admin/components/ModelProvider/index.js.map +1 -0
  108. package/admin/components/ModelProvider/useModel.d.ts +9 -0
  109. package/admin/components/ModelProvider/useModel.js +20 -0
  110. package/admin/components/ModelProvider/useModel.js.map +1 -0
  111. package/admin/contexts/Cms/index.js +28 -32
  112. package/admin/contexts/Cms/index.js.map +1 -1
  113. package/admin/graphql/contentEntries.js +19 -13
  114. package/admin/graphql/contentEntries.js.map +1 -1
  115. package/admin/graphql/contentModels.d.ts +1 -1
  116. package/admin/graphql/contentModels.js +2 -2
  117. package/admin/graphql/contentModels.js.map +1 -1
  118. package/admin/graphql/createFieldsList.d.ts +7 -2
  119. package/admin/graphql/createFieldsList.js +4 -1
  120. package/admin/graphql/createFieldsList.js.map +1 -1
  121. package/admin/hooks/index.d.ts +5 -0
  122. package/admin/hooks/index.js +42 -2
  123. package/admin/hooks/index.js.map +1 -1
  124. package/admin/hooks/usePermission.js +4 -1
  125. package/admin/hooks/usePermission.js.map +1 -1
  126. package/admin/menus/NothingToShowElement.js.map +1 -1
  127. package/admin/plugins/arrayUtils.d.ts +12 -0
  128. package/admin/plugins/arrayUtils.js +45 -0
  129. package/admin/plugins/arrayUtils.js.map +1 -0
  130. package/admin/plugins/editor/defaultBar/CreateContentButton.js +4 -4
  131. package/admin/plugins/editor/defaultBar/CreateContentButton.js.map +1 -1
  132. package/admin/plugins/editor/defaultBar/FormSettings/FormSettings.js +4 -4
  133. package/admin/plugins/editor/defaultBar/FormSettings/FormSettings.js.map +1 -1
  134. package/admin/plugins/editor/defaultBar/FormSettings/FormSettingsStyled.js.map +1 -1
  135. package/admin/plugins/editor/defaultBar/Name/Name.js +4 -4
  136. package/admin/plugins/editor/defaultBar/Name/Name.js.map +1 -1
  137. package/admin/plugins/editor/defaultBar/SaveContentModelButton.js +22 -24
  138. package/admin/plugins/editor/defaultBar/SaveContentModelButton.js.map +1 -1
  139. package/admin/plugins/editor/formSettings/components/GeneralSettings.js +8 -1
  140. package/admin/plugins/editor/formSettings/components/GeneralSettings.js.map +1 -1
  141. package/admin/plugins/entry/DefaultOnEntryDelete.js +91 -95
  142. package/admin/plugins/entry/DefaultOnEntryDelete.js.map +1 -1
  143. package/admin/plugins/entry/DefaultOnEntryPublish.js +68 -72
  144. package/admin/plugins/entry/DefaultOnEntryPublish.js.map +1 -1
  145. package/admin/plugins/fieldRenderers/DynamicSection.d.ts +3 -3
  146. package/admin/plugins/fieldRenderers/DynamicSection.js.map +1 -1
  147. package/admin/plugins/fieldRenderers/dateTime/DateOnly.d.ts +2 -2
  148. package/admin/plugins/fieldRenderers/dateTime/DateOnly.js +18 -20
  149. package/admin/plugins/fieldRenderers/dateTime/DateOnly.js.map +1 -1
  150. package/admin/plugins/fieldRenderers/dateTime/DateTimeWithTimezone.d.ts +2 -2
  151. package/admin/plugins/fieldRenderers/dateTime/DateTimeWithTimezone.js +36 -40
  152. package/admin/plugins/fieldRenderers/dateTime/DateTimeWithTimezone.js.map +1 -1
  153. package/admin/plugins/fieldRenderers/dateTime/DateTimeWithoutTimezone.d.ts +2 -2
  154. package/admin/plugins/fieldRenderers/dateTime/DateTimeWithoutTimezone.js +36 -40
  155. package/admin/plugins/fieldRenderers/dateTime/DateTimeWithoutTimezone.js.map +1 -1
  156. package/admin/plugins/fieldRenderers/dateTime/Input.d.ts +2 -2
  157. package/admin/plugins/fieldRenderers/dateTime/Input.js.map +1 -1
  158. package/admin/plugins/fieldRenderers/dateTime/Time.js +18 -20
  159. package/admin/plugins/fieldRenderers/dateTime/Time.js.map +1 -1
  160. package/admin/plugins/fieldRenderers/dateTime/utils.d.ts +2 -2
  161. package/admin/plugins/fieldRenderers/dateTime/utils.js.map +1 -1
  162. package/admin/plugins/fieldRenderers/dynamicZone/AddTemplate.d.ts +12 -0
  163. package/admin/plugins/fieldRenderers/dynamicZone/AddTemplate.js +85 -0
  164. package/admin/plugins/fieldRenderers/dynamicZone/AddTemplate.js.map +1 -0
  165. package/admin/plugins/fieldRenderers/dynamicZone/MultiValueDynamicZone.d.ts +11 -0
  166. package/admin/plugins/fieldRenderers/dynamicZone/MultiValueDynamicZone.js +114 -0
  167. package/admin/plugins/fieldRenderers/dynamicZone/MultiValueDynamicZone.js.map +1 -0
  168. package/admin/plugins/fieldRenderers/dynamicZone/SingleValueDynamicZone.d.ts +11 -0
  169. package/admin/plugins/fieldRenderers/dynamicZone/SingleValueDynamicZone.js +54 -0
  170. package/admin/plugins/fieldRenderers/dynamicZone/SingleValueDynamicZone.js.map +1 -0
  171. package/admin/plugins/fieldRenderers/dynamicZone/TemplateCard.d.ts +8 -0
  172. package/admin/plugins/fieldRenderers/dynamicZone/TemplateCard.js +54 -0
  173. package/admin/plugins/fieldRenderers/dynamicZone/TemplateCard.js.map +1 -0
  174. package/admin/plugins/fieldRenderers/dynamicZone/TemplateGallery.d.ts +8 -0
  175. package/admin/plugins/fieldRenderers/dynamicZone/TemplateGallery.js +40 -0
  176. package/admin/plugins/fieldRenderers/dynamicZone/TemplateGallery.js.map +1 -0
  177. package/admin/plugins/fieldRenderers/dynamicZone/TemplateIcon.d.ts +6 -0
  178. package/admin/plugins/fieldRenderers/dynamicZone/TemplateIcon.js +17 -0
  179. package/admin/plugins/fieldRenderers/dynamicZone/TemplateIcon.js.map +1 -0
  180. package/admin/plugins/fieldRenderers/dynamicZone/dynamicZoneRenderer.d.ts +2 -0
  181. package/admin/plugins/fieldRenderers/dynamicZone/dynamicZoneRenderer.js +56 -0
  182. package/admin/plugins/fieldRenderers/dynamicZone/dynamicZoneRenderer.js.map +1 -0
  183. package/admin/plugins/fieldRenderers/file/fileFields.js.map +1 -1
  184. package/admin/plugins/fieldRenderers/number/numberInputs.js +0 -1
  185. package/admin/plugins/fieldRenderers/number/numberInputs.js.map +1 -1
  186. package/admin/plugins/fieldRenderers/object/index.js +4 -2
  187. package/admin/plugins/fieldRenderers/object/index.js.map +1 -1
  188. package/admin/plugins/fieldRenderers/object/multipleObjects.js +21 -16
  189. package/admin/plugins/fieldRenderers/object/multipleObjects.js.map +1 -1
  190. package/admin/plugins/fieldRenderers/object/multipleObjectsAccordion.js +12 -36
  191. package/admin/plugins/fieldRenderers/object/multipleObjectsAccordion.js.map +1 -1
  192. package/admin/plugins/fieldRenderers/object/singleObjectAccordion.js +2 -11
  193. package/admin/plugins/fieldRenderers/object/singleObjectAccordion.js.map +1 -1
  194. package/admin/plugins/fieldRenderers/object/singleObjectInline.js +2 -14
  195. package/admin/plugins/fieldRenderers/object/singleObjectInline.js.map +1 -1
  196. package/admin/plugins/fieldRenderers/ref/components/ContentEntriesAutocomplete.d.ts +2 -2
  197. package/admin/plugins/fieldRenderers/ref/components/ContentEntriesAutocomplete.js.map +1 -1
  198. package/admin/plugins/fieldRenderers/ref/components/ContentEntriesMultiAutoComplete.d.ts +2 -2
  199. package/admin/plugins/fieldRenderers/ref/components/ContentEntriesMultiAutoComplete.js.map +1 -1
  200. package/admin/plugins/fieldRenderers/ref/components/NewRefEntryFormDialog.js +8 -8
  201. package/admin/plugins/fieldRenderers/ref/components/NewRefEntryFormDialog.js.map +1 -1
  202. package/admin/plugins/fieldRenderers/ref/components/renderItem.js.map +1 -1
  203. package/admin/plugins/fieldRenderers/ref/components/useReference.d.ts +2 -2
  204. package/admin/plugins/fieldRenderers/ref/components/useReference.js +32 -34
  205. package/admin/plugins/fieldRenderers/ref/components/useReference.js.map +1 -1
  206. package/admin/plugins/fieldRenderers/ref/components/useReferences.d.ts +2 -2
  207. package/admin/plugins/fieldRenderers/ref/components/useReferences.js +28 -30
  208. package/admin/plugins/fieldRenderers/ref/components/useReferences.js.map +1 -1
  209. package/admin/plugins/fieldRenderers/ref/hooks/useNewRefEntry.d.ts +2 -2
  210. package/admin/plugins/fieldRenderers/ref/hooks/useNewRefEntry.js +14 -14
  211. package/admin/plugins/fieldRenderers/ref/hooks/useNewRefEntry.js.map +1 -1
  212. package/admin/plugins/fieldRenderers/ref/refInputs.js.map +1 -1
  213. package/admin/plugins/fieldRenderers/richText/richTextInput.js.map +1 -1
  214. package/admin/plugins/fieldRenderers/richText/richTextInputs.js.map +1 -1
  215. package/admin/plugins/fieldRenderers/text/textInputs.js +0 -1
  216. package/admin/plugins/fieldRenderers/text/textInputs.js.map +1 -1
  217. package/admin/plugins/fieldValidators/date/createDateInputField.d.ts +2 -2
  218. package/admin/plugins/fieldValidators/date/createDateInputField.js.map +1 -1
  219. package/admin/plugins/fieldValidators/dateGte.d.ts +2 -2
  220. package/admin/plugins/fieldValidators/dateGte.js +61 -22
  221. package/admin/plugins/fieldValidators/dateGte.js.map +1 -1
  222. package/admin/plugins/fieldValidators/dateLte.d.ts +2 -2
  223. package/admin/plugins/fieldValidators/dateLte.js +61 -22
  224. package/admin/plugins/fieldValidators/dateLte.js.map +1 -1
  225. package/admin/plugins/fieldValidators/dynamicZone.d.ts +2 -0
  226. package/admin/plugins/fieldValidators/dynamicZone.js +163 -0
  227. package/admin/plugins/fieldValidators/dynamicZone.js.map +1 -0
  228. package/admin/plugins/fieldValidators/gte.d.ts +2 -2
  229. package/admin/plugins/fieldValidators/gte.js +33 -5
  230. package/admin/plugins/fieldValidators/gte.js.map +1 -1
  231. package/admin/plugins/fieldValidators/in.d.ts +2 -2
  232. package/admin/plugins/fieldValidators/in.js +33 -5
  233. package/admin/plugins/fieldValidators/in.js.map +1 -1
  234. package/admin/plugins/fieldValidators/lte.d.ts +2 -2
  235. package/admin/plugins/fieldValidators/lte.js +33 -5
  236. package/admin/plugins/fieldValidators/lte.js.map +1 -1
  237. package/admin/plugins/fieldValidators/maxLength.d.ts +2 -2
  238. package/admin/plugins/fieldValidators/maxLength.js +44 -6
  239. package/admin/plugins/fieldValidators/maxLength.js.map +1 -1
  240. package/admin/plugins/fieldValidators/minLength.d.ts +2 -2
  241. package/admin/plugins/fieldValidators/minLength.js +44 -6
  242. package/admin/plugins/fieldValidators/minLength.js.map +1 -1
  243. package/admin/plugins/fieldValidators/pattern.d.ts +2 -2
  244. package/admin/plugins/fieldValidators/pattern.js +108 -58
  245. package/admin/plugins/fieldValidators/pattern.js.map +1 -1
  246. package/admin/plugins/fieldValidators/patternPlugins/email.d.ts +2 -2
  247. package/admin/plugins/fieldValidators/patternPlugins/email.js +6 -4
  248. package/admin/plugins/fieldValidators/patternPlugins/email.js.map +1 -1
  249. package/admin/plugins/fieldValidators/patternPlugins/lowerCase.d.ts +2 -2
  250. package/admin/plugins/fieldValidators/patternPlugins/lowerCase.js +5 -3
  251. package/admin/plugins/fieldValidators/patternPlugins/lowerCase.js.map +1 -1
  252. package/admin/plugins/fieldValidators/patternPlugins/lowerCaseSpace.d.ts +2 -2
  253. package/admin/plugins/fieldValidators/patternPlugins/lowerCaseSpace.js +5 -3
  254. package/admin/plugins/fieldValidators/patternPlugins/lowerCaseSpace.js.map +1 -1
  255. package/admin/plugins/fieldValidators/patternPlugins/upperCase.d.ts +2 -2
  256. package/admin/plugins/fieldValidators/patternPlugins/upperCase.js +5 -3
  257. package/admin/plugins/fieldValidators/patternPlugins/upperCase.js.map +1 -1
  258. package/admin/plugins/fieldValidators/patternPlugins/upperCaseSpace.d.ts +2 -2
  259. package/admin/plugins/fieldValidators/patternPlugins/upperCaseSpace.js +5 -3
  260. package/admin/plugins/fieldValidators/patternPlugins/upperCaseSpace.js.map +1 -1
  261. package/admin/plugins/fieldValidators/patternPlugins/url.d.ts +2 -2
  262. package/admin/plugins/fieldValidators/patternPlugins/url.js +5 -3
  263. package/admin/plugins/fieldValidators/patternPlugins/url.js.map +1 -1
  264. package/admin/plugins/fieldValidators/required.d.ts +2 -2
  265. package/admin/plugins/fieldValidators/required.js +6 -2
  266. package/admin/plugins/fieldValidators/required.js.map +1 -1
  267. package/admin/plugins/fieldValidators/unique.d.ts +2 -2
  268. package/admin/plugins/fieldValidators/unique.js +22 -2
  269. package/admin/plugins/fieldValidators/unique.js.map +1 -1
  270. package/admin/plugins/fields/PredefinedValuesDynamicFieldset.d.ts +1 -2
  271. package/admin/plugins/fields/PredefinedValuesDynamicFieldset.js +22 -26
  272. package/admin/plugins/fields/PredefinedValuesDynamicFieldset.js.map +1 -1
  273. package/admin/plugins/fields/boolean.d.ts +2 -2
  274. package/admin/plugins/fields/boolean.js +5 -5
  275. package/admin/plugins/fields/boolean.js.map +1 -1
  276. package/admin/plugins/fields/dateTime.d.ts +2 -2
  277. package/admin/plugins/fields/dateTime.js +53 -48
  278. package/admin/plugins/fields/dateTime.js.map +1 -1
  279. package/admin/plugins/fields/dynamicZone/AddTemplate.d.ts +11 -0
  280. package/admin/plugins/fields/dynamicZone/AddTemplate.js +91 -0
  281. package/admin/plugins/fields/dynamicZone/AddTemplate.js.map +1 -0
  282. package/admin/plugins/fields/dynamicZone/DynamicZone.d.ts +2 -0
  283. package/admin/plugins/fields/dynamicZone/DynamicZone.js +62 -0
  284. package/admin/plugins/fields/dynamicZone/DynamicZone.js.map +1 -0
  285. package/admin/plugins/fields/dynamicZone/DynamicZoneTemplate.d.ts +11 -0
  286. package/admin/plugins/fields/dynamicZone/DynamicZoneTemplate.js +104 -0
  287. package/admin/plugins/fields/dynamicZone/DynamicZoneTemplate.js.map +1 -0
  288. package/admin/plugins/fields/dynamicZone/TemplateDialog.d.ts +9 -0
  289. package/admin/plugins/fields/dynamicZone/TemplateDialog.js +141 -0
  290. package/admin/plugins/fields/dynamicZone/TemplateDialog.js.map +1 -0
  291. package/admin/plugins/fields/dynamicZone/commonValidators.d.ts +2 -0
  292. package/admin/plugins/fields/dynamicZone/commonValidators.js +26 -0
  293. package/admin/plugins/fields/dynamicZone/commonValidators.js.map +1 -0
  294. package/admin/plugins/fields/dynamicZone.d.ts +2 -0
  295. package/admin/plugins/fields/dynamicZone.js +83 -0
  296. package/admin/plugins/fields/dynamicZone.js.map +1 -0
  297. package/admin/plugins/fields/file.d.ts +2 -2
  298. package/admin/plugins/fields/file.js +5 -5
  299. package/admin/plugins/fields/file.js.map +1 -1
  300. package/admin/plugins/fields/longText.d.ts +2 -2
  301. package/admin/plugins/fields/longText.js +3 -3
  302. package/admin/plugins/fields/longText.js.map +1 -1
  303. package/admin/plugins/fields/number.d.ts +2 -2
  304. package/admin/plugins/fields/number.js +5 -5
  305. package/admin/plugins/fields/number.js.map +1 -1
  306. package/admin/plugins/fields/object/ObjectFields.d.ts +2 -2
  307. package/admin/plugins/fields/object/ObjectFields.js +3 -3
  308. package/admin/plugins/fields/object/ObjectFields.js.map +1 -1
  309. package/admin/plugins/fields/object.d.ts +2 -2
  310. package/admin/plugins/fields/object.js +9 -4
  311. package/admin/plugins/fields/object.js.map +1 -1
  312. package/admin/plugins/fields/ref.d.ts +2 -2
  313. package/admin/plugins/fields/ref.js +93 -91
  314. package/admin/plugins/fields/ref.js.map +1 -1
  315. package/admin/plugins/fields/richText.d.ts +2 -2
  316. package/admin/plugins/fields/richText.js +5 -5
  317. package/admin/plugins/fields/richText.js.map +1 -1
  318. package/admin/plugins/fields/text.d.ts +2 -2
  319. package/admin/plugins/fields/text.js +3 -3
  320. package/admin/plugins/fields/text.js.map +1 -1
  321. package/admin/plugins/index.d.ts +28 -1
  322. package/admin/plugins/install.js +14 -16
  323. package/admin/plugins/install.js.map +1 -1
  324. package/admin/plugins/permissionRenderer/CmsPermissions.js +2 -7
  325. package/admin/plugins/permissionRenderer/CmsPermissions.js.map +1 -1
  326. package/admin/plugins/permissionRenderer/components/ContentEntryPermission.js.map +1 -1
  327. package/admin/plugins/permissionRenderer/components/ContentModelPermission.js.map +1 -1
  328. package/admin/plugins/permissionRenderer/components/useCmsData.js +53 -33
  329. package/admin/plugins/permissionRenderer/components/useCmsData.js.map +1 -1
  330. package/admin/plugins/transformers/dateTransformer.d.ts +1 -2
  331. package/admin/plugins/transformers/dateTransformer.js +3 -3
  332. package/admin/plugins/transformers/dateTransformer.js.map +1 -1
  333. package/admin/plugins/transformers/dynamicZoneTransformer.d.ts +2 -0
  334. package/admin/plugins/transformers/dynamicZoneTransformer.js +36 -0
  335. package/admin/plugins/transformers/dynamicZoneTransformer.js.map +1 -0
  336. package/admin/plugins/transformers/index.js +4 -4
  337. package/admin/plugins/transformers/index.js.map +1 -1
  338. package/admin/plugins/transformers/numberTransformer.d.ts +1 -2
  339. package/admin/plugins/transformers/numberTransformer.js +3 -3
  340. package/admin/plugins/transformers/numberTransformer.js.map +1 -1
  341. package/admin/plugins/upgrades/5.19.0/UpgradeItemsInfo.js.map +1 -1
  342. package/admin/plugins/upgrades/5.19.0/fetchModelEntries.js +71 -75
  343. package/admin/plugins/upgrades/5.19.0/fetchModelEntries.js.map +1 -1
  344. package/admin/plugins/upgrades/5.33.0/locales.js +25 -27
  345. package/admin/plugins/upgrades/5.33.0/locales.js.map +1 -1
  346. package/admin/plugins/upgrades/5.33.0/upgrade.js +34 -36
  347. package/admin/plugins/upgrades/5.33.0/upgrade.js.map +1 -1
  348. package/admin/plugins/upgrades/v5.0.0.js +22 -24
  349. package/admin/plugins/upgrades/v5.0.0.js.map +1 -1
  350. package/admin/plugins/upgrades/v5.19.0.js +317 -329
  351. package/admin/plugins/upgrades/v5.19.0.js.map +1 -1
  352. package/admin/plugins/upgrades/v5.33.0.js.map +1 -1
  353. package/admin/plugins/upgrades/v5.5.0.js +22 -24
  354. package/admin/plugins/upgrades/v5.5.0.js.map +1 -1
  355. package/admin/plugins/upgrades/v5.8.0.js +22 -24
  356. package/admin/plugins/upgrades/v5.8.0.js.map +1 -1
  357. package/admin/plugins/welcomeScreenWidget.js.map +1 -1
  358. package/admin/views/contentEntries/ContentEntries.js +5 -2
  359. package/admin/views/contentEntries/ContentEntries.js.map +1 -1
  360. package/admin/views/contentEntries/ContentEntriesContext.d.ts +4 -4
  361. package/admin/views/contentEntries/ContentEntriesContext.js +1 -9
  362. package/admin/views/contentEntries/ContentEntriesContext.js.map +1 -1
  363. package/admin/views/contentEntries/ContentEntriesList.js +21 -7
  364. package/admin/views/contentEntries/ContentEntriesList.js.map +1 -1
  365. package/admin/views/contentEntries/ContentEntry/ContentEntryContext.js +9 -9
  366. package/admin/views/contentEntries/ContentEntry/ContentEntryContext.js.map +1 -1
  367. package/admin/views/contentEntries/ContentEntry/RevisionListItem.js +56 -57
  368. package/admin/views/contentEntries/ContentEntry/RevisionListItem.js.map +1 -1
  369. package/admin/views/contentEntries/ContentEntry/cache.js +3 -1
  370. package/admin/views/contentEntries/ContentEntry/cache.js.map +1 -1
  371. package/admin/views/contentEntries/ContentEntry/header/contentFormOptionsMenu/ContentFormOptionsMenu.js +31 -33
  372. package/admin/views/contentEntries/ContentEntry/header/contentFormOptionsMenu/ContentFormOptionsMenu.js.map +1 -1
  373. package/admin/views/contentEntries/ContentEntry/header/index.js +0 -14
  374. package/admin/views/contentEntries/ContentEntry/header/index.js.map +1 -1
  375. package/admin/views/contentEntries/ContentEntry/header/revisionSelector/RevisionSelector.js.map +1 -1
  376. package/admin/views/contentEntries/ContentEntry/header/saveAndPublishContent/SaveAndPublishContent.js +17 -19
  377. package/admin/views/contentEntries/ContentEntry/header/saveAndPublishContent/SaveAndPublishContent.js.map +1 -1
  378. package/admin/views/contentEntries/ContentEntry/prepareFormData.d.ts +2 -2
  379. package/admin/views/contentEntries/ContentEntry/prepareFormData.js.map +1 -1
  380. package/admin/views/contentEntries/ContentEntry/useRevision.js +126 -143
  381. package/admin/views/contentEntries/ContentEntry/useRevision.js.map +1 -1
  382. package/admin/views/contentEntries/ContentEntry.js +0 -2
  383. package/admin/views/contentEntries/ContentEntry.js.map +1 -1
  384. package/admin/views/contentEntries/experiment/ContentEntriesModule.js +18 -11
  385. package/admin/views/contentEntries/experiment/ContentEntriesModule.js.map +1 -1
  386. package/admin/views/contentEntries/hooks/useContentEntries.js +5 -1
  387. package/admin/views/contentEntries/hooks/useContentEntries.js.map +1 -1
  388. package/admin/views/contentEntries/hooks/useContentEntriesList.d.ts +1 -1
  389. package/admin/views/contentModelGroups/ContentModelGroupsDataList.js +50 -52
  390. package/admin/views/contentModelGroups/ContentModelGroupsDataList.js.map +1 -1
  391. package/admin/views/contentModelGroups/ContentModelGroupsForm.js +33 -35
  392. package/admin/views/contentModelGroups/ContentModelGroupsForm.js.map +1 -1
  393. package/admin/views/contentModels/CloneContentModelDialog.js +10 -31
  394. package/admin/views/contentModels/CloneContentModelDialog.js.map +1 -1
  395. package/admin/views/contentModels/ContentModelEditor.js +2 -2
  396. package/admin/views/contentModels/ContentModelEditor.js.map +1 -1
  397. package/admin/views/contentModels/ContentModelsDataList.js +44 -48
  398. package/admin/views/contentModels/ContentModelsDataList.js.map +1 -1
  399. package/admin/views/contentModels/NewContentModelDialog.js +67 -96
  400. package/admin/views/contentModels/NewContentModelDialog.js.map +1 -1
  401. package/admin/viewsGraphql.js +1 -1
  402. package/admin/viewsGraphql.js.map +1 -1
  403. package/allPlugins.d.ts +34 -0
  404. package/allPlugins.js +51 -0
  405. package/allPlugins.js.map +1 -0
  406. package/index.d.ts +1 -0
  407. package/index.js +13 -1
  408. package/index.js.map +1 -1
  409. package/package.json +20 -20
  410. package/{types.d.ts → types/index.d.ts} +50 -175
  411. package/types/index.js +38 -0
  412. package/types/index.js.map +1 -0
  413. package/types/model.d.ts +83 -0
  414. package/{types.js → types/model.js} +0 -0
  415. package/types/model.js.map +1 -0
  416. package/types/shared.d.ts +5 -0
  417. package/types/shared.js +5 -0
  418. package/types/shared.js.map +1 -0
  419. package/types/validation.d.ts +70 -0
  420. package/types/validation.js +5 -0
  421. package/types/validation.js.map +1 -0
  422. package/utils/CmsModelFieldValidatorConfigAdapter.d.ts +15 -0
  423. package/utils/CmsModelFieldValidatorConfigAdapter.js +79 -0
  424. package/utils/CmsModelFieldValidatorConfigAdapter.js.map +1 -0
  425. package/utils/createTypeName.d.ts +1 -0
  426. package/utils/createTypeName.js +13 -0
  427. package/utils/createTypeName.js.map +1 -0
  428. package/utils/createValidators.d.ts +3 -0
  429. package/utils/createValidators.js +76 -0
  430. package/utils/createValidators.js.map +1 -0
  431. package/utils/getFetchPolicy.d.ts +6 -0
  432. package/utils/getFetchPolicy.js +17 -0
  433. package/utils/getFetchPolicy.js.map +1 -0
  434. package/utils/getModelTitleFieldId.d.ts +2 -0
  435. package/utils/getModelTitleFieldId.js +13 -0
  436. package/utils/getModelTitleFieldId.js.map +1 -0
  437. package/admin/components/ContentEntryForm/functions/createValidators.d.ts +0 -3
  438. package/admin/components/ContentEntryForm/functions/createValidators.js +0 -60
  439. package/admin/components/ContentEntryForm/functions/createValidators.js.map +0 -1
  440. package/admin/components/ContentModelEditor/Context.js.map +0 -1
  441. package/admin/components/ContentModelEditor/useContentModelEditor.d.ts +0 -1
  442. package/admin/components/ContentModelEditor/useContentModelEditor.js.map +0 -1
  443. package/admin/components/FieldEditor/EditFieldDialog/ValidatorsTab.d.ts +0 -15
  444. package/admin/components/FieldEditor/EditFieldDialog/ValidatorsTab.js +0 -128
  445. package/admin/components/FieldEditor/EditFieldDialog/ValidatorsTab.js.map +0 -1
  446. package/admin/components/FieldEditor/useFieldEditor.d.ts +0 -1
  447. package/admin/components/FieldEditor/useFieldEditor.js +0 -11
  448. package/admin/components/FieldEditor/useFieldEditor.js.map +0 -1
  449. package/admin/plugins/fieldRenderers/object/singleObject.d.ts +0 -3
  450. package/admin/plugins/fieldRenderers/object/singleObject.js +0 -52
  451. package/admin/plugins/fieldRenderers/object/singleObject.js.map +0 -1
  452. package/admin/plugins/validators/dateGte.d.ts +0 -3
  453. package/admin/plugins/validators/dateGte.js +0 -53
  454. package/admin/plugins/validators/dateGte.js.map +0 -1
  455. package/admin/plugins/validators/dateLte.d.ts +0 -3
  456. package/admin/plugins/validators/dateLte.js +0 -53
  457. package/admin/plugins/validators/dateLte.js.map +0 -1
  458. package/admin/plugins/validators/gte.d.ts +0 -3
  459. package/admin/plugins/validators/gte.js +0 -46
  460. package/admin/plugins/validators/gte.js.map +0 -1
  461. package/admin/plugins/validators/in.d.ts +0 -3
  462. package/admin/plugins/validators/in.js +0 -46
  463. package/admin/plugins/validators/in.js.map +0 -1
  464. package/admin/plugins/validators/lte.d.ts +0 -3
  465. package/admin/plugins/validators/lte.js +0 -46
  466. package/admin/plugins/validators/lte.js.map +0 -1
  467. package/admin/plugins/validators/maxLength.d.ts +0 -3
  468. package/admin/plugins/validators/maxLength.js +0 -46
  469. package/admin/plugins/validators/maxLength.js.map +0 -1
  470. package/admin/plugins/validators/minLength.d.ts +0 -3
  471. package/admin/plugins/validators/minLength.js +0 -46
  472. package/admin/plugins/validators/minLength.js.map +0 -1
  473. package/admin/plugins/validators/pattern.d.ts +0 -3
  474. package/admin/plugins/validators/pattern.js +0 -62
  475. package/admin/plugins/validators/pattern.js.map +0 -1
  476. package/admin/plugins/validators/patternPlugins/email.d.ts +0 -3
  477. package/admin/plugins/validators/patternPlugins/email.js +0 -17
  478. package/admin/plugins/validators/patternPlugins/email.js.map +0 -1
  479. package/admin/plugins/validators/patternPlugins/lowerCase.d.ts +0 -3
  480. package/admin/plugins/validators/patternPlugins/lowerCase.js +0 -17
  481. package/admin/plugins/validators/patternPlugins/lowerCase.js.map +0 -1
  482. package/admin/plugins/validators/patternPlugins/lowerCaseSpace.d.ts +0 -3
  483. package/admin/plugins/validators/patternPlugins/lowerCaseSpace.js +0 -17
  484. package/admin/plugins/validators/patternPlugins/lowerCaseSpace.js.map +0 -1
  485. package/admin/plugins/validators/patternPlugins/upperCase.d.ts +0 -3
  486. package/admin/plugins/validators/patternPlugins/upperCase.js +0 -17
  487. package/admin/plugins/validators/patternPlugins/upperCase.js.map +0 -1
  488. package/admin/plugins/validators/patternPlugins/upperCaseSpace.d.ts +0 -3
  489. package/admin/plugins/validators/patternPlugins/upperCaseSpace.js +0 -17
  490. package/admin/plugins/validators/patternPlugins/upperCaseSpace.js.map +0 -1
  491. package/admin/plugins/validators/patternPlugins/url.d.ts +0 -3
  492. package/admin/plugins/validators/patternPlugins/url.js +0 -17
  493. package/admin/plugins/validators/patternPlugins/url.js.map +0 -1
  494. package/admin/plugins/validators/required.d.ts +0 -3
  495. package/admin/plugins/validators/required.js +0 -19
  496. package/admin/plugins/validators/required.js.map +0 -1
  497. package/admin/plugins/validators/timeGte.d.ts +0 -3
  498. package/admin/plugins/validators/timeGte.js +0 -47
  499. package/admin/plugins/validators/timeGte.js.map +0 -1
  500. package/admin/plugins/validators/timeLte.d.ts +0 -3
  501. package/admin/plugins/validators/timeLte.js +0 -47
  502. package/admin/plugins/validators/timeLte.js.map +0 -1
  503. package/admin/plugins/validators/unique.d.ts +0 -7
  504. package/admin/plugins/validators/unique.js +0 -42
  505. package/admin/plugins/validators/unique.js.map +0 -1
  506. package/admin/views/contentEntries/ContentEntry/header/requestChanges/RequestChanges.d.ts +0 -1
  507. package/admin/views/contentEntries/ContentEntry/header/requestChanges/RequestChanges.js +0 -11
  508. package/admin/views/contentEntries/ContentEntry/header/requestChanges/RequestChanges.js.map +0 -1
  509. package/admin/views/contentEntries/ContentEntry/header/requestChanges/rule-24px.svg +0 -1
  510. package/admin/views/contentEntries/ContentEntry/header/requestReview/RequestReview.d.ts +0 -1
  511. package/admin/views/contentEntries/ContentEntry/header/requestReview/RequestReview.js +0 -11
  512. package/admin/views/contentEntries/ContentEntry/header/requestReview/RequestReview.js.map +0 -1
  513. package/admin/views/contentEntries/ContentEntry/header/requestReview/emoji_people-24px.svg +0 -1
  514. package/admin/views/contentModelGroups/IconPicker.d.ts +0 -8
  515. package/admin/views/contentModelGroups/IconPicker.js.map +0 -1
  516. package/types.js.map +0 -1
package/HeadlessCMS.js CHANGED
@@ -16,6 +16,7 @@ var _apiInformation = _interopRequireDefault(require("./admin/plugins/apiInforma
16
16
  var _ContentEntriesModule = require("./admin/views/contentEntries/experiment/ContentEntriesModule");
17
17
  var _DefaultOnEntryDelete = require("./admin/plugins/entry/DefaultOnEntryDelete");
18
18
  var _DefaultOnEntryPublish = require("./admin/plugins/entry/DefaultOnEntryPublish");
19
+ var _allPlugins = _interopRequireDefault(require("./allPlugins"));
19
20
  var createHeadlessCMSProvider = function createHeadlessCMSProvider(createApolloClient) {
20
21
  return function (Component) {
21
22
  return function HeadlessCMSProvider(_ref) {
@@ -29,6 +30,7 @@ var createHeadlessCMSProvider = function createHeadlessCMSProvider(createApolloC
29
30
  var HeadlessCMSExtension = function HeadlessCMSExtension(_ref2) {
30
31
  var createApolloClient = _ref2.createApolloClient;
31
32
  _plugins.plugins.register(_apiInformation.default);
33
+ _plugins.plugins.register(_allPlugins.default);
32
34
  _plugins.plugins.register(new _app.ApolloCacheObjectIdPlugin(function (obj) {
33
35
  if (obj.__typename === "CmsContentModelField") {
34
36
  return null;
@@ -1 +1 @@
1
- {"version":3,"names":["createHeadlessCMSProvider","createApolloClient","Component","HeadlessCMSProvider","children","HeadlessCMSExtension","plugins","register","apiInformation","ApolloCacheObjectIdPlugin","obj","__typename","undefined","HeadlessCMS","memo"],"sources":["HeadlessCMS.tsx"],"sourcesContent":["import React, { Fragment, memo } from \"react\";\nimport { plugins } from \"@webiny/plugins\";\nimport { Plugins, Provider } from \"@webiny/app-admin\";\nimport { ApolloCacheObjectIdPlugin } from \"@webiny/app\";\nimport { ApolloClient } from \"apollo-client\";\nimport { CmsProvider } from \"./admin/contexts/Cms\";\nimport { CmsMenuLoader } from \"~/admin/menus/CmsMenuLoader\";\nimport apiInformation from \"./admin/plugins/apiInformation\";\nimport { ContentEntriesModule } from \"./admin/views/contentEntries/experiment/ContentEntriesModule\";\nimport { DefaultOnEntryDelete } from \"./admin/plugins/entry/DefaultOnEntryDelete\";\nimport { DefaultOnEntryPublish } from \"~/admin/plugins/entry/DefaultOnEntryPublish\";\n\nconst createHeadlessCMSProvider =\n (createApolloClient: CreateApolloClient) =>\n (Component: React.FC): React.FC => {\n return function HeadlessCMSProvider({ children }) {\n return (\n <CmsProvider createApolloClient={createApolloClient}>\n <Component>{children}</Component>\n </CmsProvider>\n );\n };\n };\n\ninterface CreateApolloClientParams {\n uri: string;\n}\ninterface CreateApolloClient {\n (params: CreateApolloClientParams): ApolloClient<any>;\n}\n\nexport interface HeadlessCMSProps {\n createApolloClient: CreateApolloClient;\n}\n\nconst HeadlessCMSExtension = ({ createApolloClient }: HeadlessCMSProps) => {\n plugins.register(apiInformation);\n\n plugins.register(\n new ApolloCacheObjectIdPlugin(obj => {\n if (obj.__typename === \"CmsContentModelField\") {\n return null;\n }\n\n return undefined;\n })\n );\n\n return (\n <Fragment>\n <ContentEntriesModule />\n <Provider hoc={createHeadlessCMSProvider(createApolloClient)} />\n <Plugins>\n <CmsMenuLoader />\n <DefaultOnEntryDelete />\n <DefaultOnEntryPublish />\n </Plugins>\n </Fragment>\n );\n};\n\nexport const HeadlessCMS = memo(HeadlessCMSExtension);\n"],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA,IAAMA,yBAAyB,GAC3B,SADEA,yBAAyB,CAC1BC,kBAAsC;EAAA,OACvC,UAACC,SAAmB,EAAe;IAC/B,OAAO,SAASC,mBAAmB,OAAe;MAAA,IAAZC,QAAQ,QAARA,QAAQ;MAC1C,oBACI,6BAAC,gBAAW;QAAC,kBAAkB,EAAEH;MAAmB,gBAChD,6BAAC,SAAS,QAAEG,QAAQ,CAAa,CACvB;IAEtB,CAAC;EACL,CAAC;AAAA;AAaL,IAAMC,oBAAoB,GAAG,SAAvBA,oBAAoB,QAAiD;EAAA,IAA3CJ,kBAAkB,SAAlBA,kBAAkB;EAC9CK,gBAAO,CAACC,QAAQ,CAACC,uBAAc,CAAC;EAEhCF,gBAAO,CAACC,QAAQ,CACZ,IAAIE,8BAAyB,CAAC,UAAAC,GAAG,EAAI;IACjC,IAAIA,GAAG,CAACC,UAAU,KAAK,sBAAsB,EAAE;MAC3C,OAAO,IAAI;IACf;IAEA,OAAOC,SAAS;EACpB,CAAC,CAAC,CACL;EAED,oBACI,6BAAC,eAAQ,qBACL,6BAAC,0CAAoB,OAAG,eACxB,6BAAC,kBAAQ;IAAC,GAAG,EAAEZ,yBAAyB,CAACC,kBAAkB;EAAE,EAAG,eAChE,6BAAC,iBAAO,qBACJ,6BAAC,4BAAa,OAAG,eACjB,6BAAC,0CAAoB,OAAG,eACxB,6BAAC,4CAAqB,OAAG,CACnB,CACH;AAEnB,CAAC;AAEM,IAAMY,WAAW,gBAAG,IAAAC,WAAI,EAACT,oBAAoB,CAAC;AAAC"}
1
+ {"version":3,"names":["createHeadlessCMSProvider","createApolloClient","Component","HeadlessCMSProvider","children","HeadlessCMSExtension","plugins","register","apiInformation","allPlugins","ApolloCacheObjectIdPlugin","obj","__typename","undefined","HeadlessCMS","memo"],"sources":["HeadlessCMS.tsx"],"sourcesContent":["import React, { Fragment, memo } from \"react\";\nimport { plugins } from \"@webiny/plugins\";\nimport { Plugins, Provider } from \"@webiny/app-admin\";\nimport { ApolloCacheObjectIdPlugin } from \"@webiny/app\";\nimport { ApolloClient } from \"apollo-client\";\nimport { CmsProvider } from \"./admin/contexts/Cms\";\nimport { CmsMenuLoader } from \"~/admin/menus/CmsMenuLoader\";\nimport apiInformation from \"./admin/plugins/apiInformation\";\nimport { ContentEntriesModule } from \"./admin/views/contentEntries/experiment/ContentEntriesModule\";\nimport { DefaultOnEntryDelete } from \"./admin/plugins/entry/DefaultOnEntryDelete\";\nimport { DefaultOnEntryPublish } from \"~/admin/plugins/entry/DefaultOnEntryPublish\";\nimport allPlugins from \"./allPlugins\";\n\nconst createHeadlessCMSProvider =\n (createApolloClient: CreateApolloClient) =>\n (Component: React.FC): React.FC => {\n return function HeadlessCMSProvider({ children }) {\n return (\n <CmsProvider createApolloClient={createApolloClient}>\n <Component>{children}</Component>\n </CmsProvider>\n );\n };\n };\n\ninterface CreateApolloClientParams {\n uri: string;\n}\ninterface CreateApolloClient {\n (params: CreateApolloClientParams): ApolloClient<any>;\n}\n\nexport interface HeadlessCMSProps {\n createApolloClient: CreateApolloClient;\n}\n\nconst HeadlessCMSExtension = ({ createApolloClient }: HeadlessCMSProps) => {\n plugins.register(apiInformation);\n plugins.register(allPlugins);\n\n plugins.register(\n new ApolloCacheObjectIdPlugin(obj => {\n if (obj.__typename === \"CmsContentModelField\") {\n return null;\n }\n\n return undefined;\n })\n );\n\n return (\n <Fragment>\n <ContentEntriesModule />\n <Provider hoc={createHeadlessCMSProvider(createApolloClient)} />\n <Plugins>\n <CmsMenuLoader />\n <DefaultOnEntryDelete />\n <DefaultOnEntryPublish />\n </Plugins>\n </Fragment>\n );\n};\n\nexport const HeadlessCMS = memo(HeadlessCMSExtension);\n"],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,IAAMA,yBAAyB,GAC3B,SADEA,yBAAyB,CAC1BC,kBAAsC;EAAA,OACvC,UAACC,SAAmB,EAAe;IAC/B,OAAO,SAASC,mBAAmB,OAAe;MAAA,IAAZC,QAAQ,QAARA,QAAQ;MAC1C,oBACI,6BAAC,gBAAW;QAAC,kBAAkB,EAAEH;MAAmB,gBAChD,6BAAC,SAAS,QAAEG,QAAQ,CAAa,CACvB;IAEtB,CAAC;EACL,CAAC;AAAA;AAaL,IAAMC,oBAAoB,GAAG,SAAvBA,oBAAoB,QAAiD;EAAA,IAA3CJ,kBAAkB,SAAlBA,kBAAkB;EAC9CK,gBAAO,CAACC,QAAQ,CAACC,uBAAc,CAAC;EAChCF,gBAAO,CAACC,QAAQ,CAACE,mBAAU,CAAC;EAE5BH,gBAAO,CAACC,QAAQ,CACZ,IAAIG,8BAAyB,CAAC,UAAAC,GAAG,EAAI;IACjC,IAAIA,GAAG,CAACC,UAAU,KAAK,sBAAsB,EAAE;MAC3C,OAAO,IAAI;IACf;IAEA,OAAOC,SAAS;EACpB,CAAC,CAAC,CACL;EAED,oBACI,6BAAC,eAAQ,qBACL,6BAAC,0CAAoB,OAAG,eACxB,6BAAC,kBAAQ;IAAC,GAAG,EAAEb,yBAAyB,CAACC,kBAAkB;EAAE,EAAG,eAChE,6BAAC,iBAAO,qBACJ,6BAAC,4BAAa,OAAG,eACjB,6BAAC,0CAAoB,OAAG,eACxB,6BAAC,4CAAqB,OAAG,CACnB,CACH;AAEnB,CAAC;AAEM,IAAMa,WAAW,gBAAG,IAAAC,WAAI,EAACV,oBAAoB,CAAC;AAAC"}
@@ -19,6 +19,7 @@ var _useContentEntryForm2 = require("./useContentEntryForm");
19
19
  var _Fields = require("./Fields");
20
20
  var _reactRouter = require("@webiny/react-router");
21
21
  var _appAdmin = require("@webiny/app-admin");
22
+ var _ModelProvider = require("../ModelProvider");
22
23
  var _excluded = ["onForm"];
23
24
  var FormWrapper = /*#__PURE__*/(0, _styled.default)("div", {
24
25
  target: "ejw5gwy0",
@@ -42,7 +43,9 @@ var isDifferent = function isDifferent(value, compare) {
42
43
  var ContentEntryForm = function ContentEntryForm(_ref) {
43
44
  var onForm = _ref.onForm,
44
45
  props = (0, _objectWithoutProperties2.default)(_ref, _excluded);
45
- var contentModel = props.contentModel;
46
+ var formElementRef = (0, _react.useRef)(null);
47
+ var _useModel = (0, _ModelProvider.useModel)(),
48
+ model = _useModel.model;
46
49
  var _useContentEntryForm = (0, _useContentEntryForm2.useContentEntryForm)(props),
47
50
  loading = _useContentEntryForm.loading,
48
51
  initialData = _useContentEntryForm.data,
@@ -71,11 +74,17 @@ var ContentEntryForm = function ContentEntryForm(_ref) {
71
74
  }
72
75
  onForm(ref.current);
73
76
  }, []);
77
+ (0, _react.useEffect)(function () {
78
+ if (!formElementRef.current) {
79
+ return;
80
+ }
81
+ formElementRef.current.scrollTo(0, 0);
82
+ }, [initialData.id, formElementRef.current]);
74
83
  var formRenderer = _plugins.plugins.byType("cms-content-form-renderer").find(function (pl) {
75
- return pl.modelId === contentModel.modelId;
84
+ return pl.modelId === model.modelId;
76
85
  });
77
86
  var renderCustomLayout = (0, _react.useCallback)(function (formRenderProps) {
78
- var fields = contentModel.fields.reduce(function (acc, field) {
87
+ var fields = model.fields.reduce(function (acc, field) {
79
88
  /**
80
89
  * TODO @ts-refactor
81
90
  * Figure out type for Bind.
@@ -83,15 +92,15 @@ var ContentEntryForm = function ContentEntryForm(_ref) {
83
92
  acc[field.fieldId] = /*#__PURE__*/_react.default.createElement(_RenderFieldElement.default, {
84
93
  field: field,
85
94
  Bind: formRenderProps.Bind,
86
- contentModel: contentModel
95
+ contentModel: model
87
96
  });
88
97
  return acc;
89
98
  }, {});
90
99
  if (!formRenderer) {
91
- return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, "Missing form renderer for modelId \"".concat(contentModel.modelId, "\"."));
100
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, "Missing form renderer for modelId \"".concat(model.modelId, "\"."));
92
101
  }
93
102
  return formRenderer.render((0, _objectSpread2.default)((0, _objectSpread2.default)({}, formRenderProps), {}, {
94
- contentModel: contentModel,
103
+ contentModel: model,
95
104
  fields: fields,
96
105
  /**
97
106
  * TODO @ts-refactor
@@ -117,18 +126,21 @@ var ContentEntryForm = function ContentEntryForm(_ref) {
117
126
  invalidFields: invalidFields,
118
127
  onInvalid: function onInvalid() {
119
128
  setIsDirty(true);
120
- showSnackbar("You have fields that did not pass the validation. Please check the form.");
129
+ showSnackbar("Some fields did not pass the validation. Please check the form.");
121
130
  }
122
131
  }, function (formProps) {
123
- return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_reactRouter.Prompt, {
132
+ return /*#__PURE__*/_react.default.createElement(_ModelProvider.ModelProvider, {
133
+ model: model
134
+ }, /*#__PURE__*/_react.default.createElement(_reactRouter.Prompt, {
124
135
  when: isDirty,
125
136
  message: "There are some unsaved changes! Are you sure you want to navigate away and discard all changes?"
126
137
  }), /*#__PURE__*/_react.default.createElement(FormWrapper, {
127
- "data-testid": "cms-content-form"
138
+ "data-testid": "cms-content-form",
139
+ ref: formElementRef
128
140
  }, loading && /*#__PURE__*/_react.default.createElement(_Progress.CircularProgress, null), formRenderer ? renderCustomLayout(formProps) : /*#__PURE__*/_react.default.createElement(_Fields.Fields, Object.assign({
129
- contentModel: contentModel,
130
- fields: contentModel.fields || [],
131
- layout: contentModel.layout || []
141
+ contentModel: model,
142
+ fields: model.fields || [],
143
+ layout: model.layout || []
132
144
  }, formProps, {
133
145
  Bind: formProps.Bind
134
146
  }))));
@@ -1 +1 @@
1
- {"version":3,"names":["FormWrapper","styled","height","overflow","omitTypename","key","value","undefined","stringify","JSON","isDifferent","compare","ContentEntryForm","onForm","props","contentModel","useContentEntryForm","loading","initialData","data","onChange","onSubmit","invalidFields","React","useState","isDirty","setIsDirty","useEffect","useSnackbar","showSnackbar","ref","useRef","current","formRenderer","plugins","byType","find","pl","modelId","renderCustomLayout","useCallback","formRenderProps","fields","reduce","acc","field","fieldId","Bind","render","form","different","formProps","layout"],"sources":["ContentEntryForm.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useRef } from \"react\";\nimport RenderFieldElement from \"./RenderFieldElement\";\nimport styled from \"@emotion/styled\";\nimport { Form } from \"@webiny/form\";\nimport { FormAPI, FormRenderPropParams } from \"@webiny/form/types\";\nimport { plugins } from \"@webiny/plugins\";\nimport { CircularProgress } from \"@webiny/ui/Progress\";\nimport { CmsContentFormRendererPlugin } from \"~/types\";\nimport { useContentEntryForm, UseContentEntryFormParams } from \"./useContentEntryForm\";\nimport { Fields } from \"./Fields\";\nimport { Prompt } from \"@webiny/react-router\";\nimport { useSnackbar } from \"@webiny/app-admin\";\n\nconst FormWrapper = styled(\"div\")({\n height: \"calc(100vh - 260px)\",\n overflow: \"auto\"\n});\n\ninterface ContentEntryFormProps extends UseContentEntryFormParams {\n onForm?: (form: FormAPI) => void;\n}\n\nfunction omitTypename(key: string, value: string): string | undefined {\n return key === \"__typename\" ? undefined : value;\n}\n\nconst stringify = (value: any): string => {\n return JSON.stringify(value || {}, omitTypename);\n};\n\nconst isDifferent = (value: any, compare: any): boolean => {\n if (!value && !compare) {\n return false;\n }\n return stringify(value) !== stringify(compare);\n};\n\nexport const ContentEntryForm: React.FC<ContentEntryFormProps> = ({ onForm, ...props }) => {\n const { contentModel } = props;\n const {\n loading,\n data: initialData,\n onChange,\n onSubmit,\n invalidFields\n } = useContentEntryForm(props);\n\n const [isDirty, setIsDirty] = React.useState<boolean>(false);\n /**\n * Reset isDirty when the loaded data changes.\n */\n useEffect(() => {\n if (!isDirty) {\n return;\n }\n setIsDirty(false);\n }, [initialData]);\n\n const { showSnackbar } = useSnackbar();\n\n const ref = useRef<FormAPI | null>(null);\n\n useEffect(() => {\n if (typeof onForm !== \"function\" || !ref.current) {\n return;\n }\n onForm(ref.current);\n }, []);\n\n const formRenderer = plugins\n .byType<CmsContentFormRendererPlugin>(\"cms-content-form-renderer\")\n .find(pl => pl.modelId === contentModel.modelId);\n\n const renderCustomLayout = useCallback(\n (formRenderProps: FormRenderPropParams) => {\n const fields = contentModel.fields.reduce((acc, field) => {\n /**\n * TODO @ts-refactor\n * Figure out type for Bind.\n */\n acc[field.fieldId] = (\n <RenderFieldElement\n field={field}\n Bind={formRenderProps.Bind as any}\n contentModel={contentModel}\n />\n );\n\n return acc;\n }, {} as Record<string, React.ReactElement>);\n if (!formRenderer) {\n return <>{`Missing form renderer for modelId \"${contentModel.modelId}\".`}</>;\n }\n return formRenderer.render({\n ...formRenderProps,\n contentModel,\n fields,\n /**\n * TODO @ts-refactor\n * Figure out type for Bind.\n */\n Bind: formRenderProps.Bind as any\n });\n },\n [formRenderer]\n );\n\n return (\n <Form\n onChange={(data, form) => {\n const different = isDifferent(data, initialData);\n if (isDirty !== different) {\n setIsDirty(different);\n }\n return onChange(data, form);\n }}\n onSubmit={(data, form) => {\n setIsDirty(false);\n return onSubmit(data, form);\n }}\n data={initialData}\n ref={ref}\n invalidFields={invalidFields}\n onInvalid={() => {\n setIsDirty(true);\n showSnackbar(\n \"You have fields that did not pass the validation. Please check the form.\"\n );\n }}\n >\n {formProps => {\n return (\n <>\n <Prompt\n when={isDirty}\n message={\n \"There are some unsaved changes! Are you sure you want to navigate away and discard all changes?\"\n }\n />\n <FormWrapper data-testid={\"cms-content-form\"}>\n {loading && <CircularProgress />}\n {formRenderer ? (\n renderCustomLayout(formProps)\n ) : (\n <Fields\n contentModel={contentModel}\n fields={contentModel.fields || []}\n layout={contentModel.layout || []}\n {...formProps}\n Bind={formProps.Bind as any}\n />\n )}\n </FormWrapper>\n </>\n );\n }}\n </Form>\n );\n};\n"],"mappings":";;;;;;;;;;;AAAA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AAAgD;AAEhD,IAAMA,WAAW,oBAAGC,eAAM,EAAC,KAAK;EAAA;EAAA;AAAA,GAAE;EAC9BC,MAAM,EAAE,qBAAqB;EAC7BC,QAAQ,EAAE;AACd,CAAC,CAAC;AAMF,SAASC,YAAY,CAACC,GAAW,EAAEC,KAAa,EAAsB;EAClE,OAAOD,GAAG,KAAK,YAAY,GAAGE,SAAS,GAAGD,KAAK;AACnD;AAEA,IAAME,SAAS,GAAG,SAAZA,SAAS,CAAIF,KAAU,EAAa;EACtC,OAAOG,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,EAAE8B,IAAI,CAAC;IAC/B,CAAE;IACF,IAAI,EAAE/B,WAAY;IAClB,GAAG,EAAEY,GAAI;IACT,aAAa,EAAER,aAAc;IAC7B,SAAS,EAAE,qBAAM;MACbI,UAAU,CAAC,IAAI,CAAC;MAChBG,YAAY,CACR,0EAA0E,CAC7E;IACL;EAAE,GAED,UAAAsB,SAAS,EAAI;IACV,oBACI,yEACI,6BAAC,mBAAM;MACH,IAAI,EAAE1B,OAAQ;MACd,OAAO,EACH;IACH,EACH,eACF,6BAAC,WAAW;MAAC,eAAa;IAAmB,GACxCR,OAAO,iBAAI,6BAAC,0BAAgB,OAAG,EAC/BgB,YAAY,GACTM,kBAAkB,CAACY,SAAS,CAAC,gBAE7B,6BAAC,cAAM;MACH,YAAY,EAAEpC,YAAa;MAC3B,MAAM,EAAEA,YAAY,CAAC2B,MAAM,IAAI,EAAG;MAClC,MAAM,EAAE3B,YAAY,CAACqC,MAAM,IAAI;IAAG,GAC9BD,SAAS;MACb,IAAI,EAAEA,SAAS,CAACJ;IAAY,GAEnC,CACS,CACf;EAEX,CAAC,CACE;AAEf,CAAC;AAAC"}
1
+ {"version":3,"names":["FormWrapper","styled","height","overflow","omitTypename","key","value","undefined","stringify","JSON","isDifferent","compare","ContentEntryForm","onForm","props","formElementRef","useRef","useModel","model","useContentEntryForm","loading","initialData","data","onChange","onSubmit","invalidFields","React","useState","isDirty","setIsDirty","useEffect","useSnackbar","showSnackbar","ref","current","scrollTo","id","formRenderer","plugins","byType","find","pl","modelId","renderCustomLayout","useCallback","formRenderProps","fields","reduce","acc","field","fieldId","Bind","render","contentModel","form","different","formProps","layout"],"sources":["ContentEntryForm.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useRef } from \"react\";\nimport RenderFieldElement from \"./RenderFieldElement\";\nimport styled from \"@emotion/styled\";\nimport { Form } from \"@webiny/form\";\nimport { FormAPI, FormRenderPropParams } from \"@webiny/form/types\";\nimport { plugins } from \"@webiny/plugins\";\nimport { CircularProgress } from \"@webiny/ui/Progress\";\nimport { CmsContentFormRendererPlugin } from \"~/types\";\nimport { useContentEntryForm, UseContentEntryFormParams } from \"./useContentEntryForm\";\nimport { Fields } from \"./Fields\";\nimport { Prompt } from \"@webiny/react-router\";\nimport { useSnackbar } from \"@webiny/app-admin\";\nimport { ModelProvider, useModel } from \"~/admin/components/ModelProvider\";\n\nconst FormWrapper = styled(\"div\")({\n height: \"calc(100vh - 260px)\",\n overflow: \"auto\"\n});\n\ninterface ContentEntryFormProps extends UseContentEntryFormParams {\n onForm?: (form: FormAPI) => void;\n}\n\nfunction omitTypename(key: string, value: string): string | undefined {\n return key === \"__typename\" ? undefined : value;\n}\n\nconst stringify = (value: any): string => {\n return JSON.stringify(value || {}, omitTypename);\n};\n\nconst isDifferent = (value: any, compare: any): boolean => {\n if (!value && !compare) {\n return false;\n }\n return stringify(value) !== stringify(compare);\n};\n\nexport const ContentEntryForm: React.FC<ContentEntryFormProps> = ({ onForm, ...props }) => {\n const formElementRef = useRef<HTMLDivElement>(null);\n const { model } = useModel();\n const {\n loading,\n data: initialData,\n onChange,\n onSubmit,\n invalidFields\n } = useContentEntryForm(props);\n\n const [isDirty, setIsDirty] = React.useState<boolean>(false);\n /**\n * Reset isDirty when the loaded data changes.\n */\n useEffect(() => {\n if (!isDirty) {\n return;\n }\n setIsDirty(false);\n }, [initialData]);\n\n const { showSnackbar } = useSnackbar();\n\n const ref = useRef<FormAPI | null>(null);\n\n useEffect(() => {\n if (typeof onForm !== \"function\" || !ref.current) {\n return;\n }\n onForm(ref.current);\n }, []);\n\n useEffect(() => {\n if (!formElementRef.current) {\n return;\n }\n\n formElementRef.current.scrollTo(0, 0);\n }, [initialData.id, formElementRef.current]);\n\n const formRenderer = plugins\n .byType<CmsContentFormRendererPlugin>(\"cms-content-form-renderer\")\n .find(pl => pl.modelId === model.modelId);\n\n const renderCustomLayout = useCallback(\n (formRenderProps: FormRenderPropParams) => {\n const fields = model.fields.reduce((acc, field) => {\n /**\n * TODO @ts-refactor\n * Figure out type for Bind.\n */\n acc[field.fieldId] = (\n <RenderFieldElement\n field={field}\n Bind={formRenderProps.Bind as any}\n contentModel={model}\n />\n );\n\n return acc;\n }, {} as Record<string, React.ReactElement>);\n if (!formRenderer) {\n return <>{`Missing form renderer for modelId \"${model.modelId}\".`}</>;\n }\n return formRenderer.render({\n ...formRenderProps,\n contentModel: model,\n fields,\n /**\n * TODO @ts-refactor\n * Figure out type for Bind.\n */\n Bind: formRenderProps.Bind as any\n });\n },\n [formRenderer]\n );\n\n return (\n <Form\n onChange={(data, form) => {\n const different = isDifferent(data, initialData);\n if (isDirty !== different) {\n setIsDirty(different);\n }\n return onChange(data, form);\n }}\n onSubmit={(data, form) => {\n setIsDirty(false);\n return onSubmit(data, form);\n }}\n data={initialData}\n ref={ref}\n invalidFields={invalidFields}\n onInvalid={() => {\n setIsDirty(true);\n showSnackbar(\"Some fields did not pass the validation. Please check the form.\");\n }}\n >\n {formProps => {\n return (\n <ModelProvider model={model}>\n <Prompt\n when={isDirty}\n message={\n \"There are some unsaved changes! Are you sure you want to navigate away and discard all changes?\"\n }\n />\n <FormWrapper data-testid={\"cms-content-form\"} ref={formElementRef}>\n {loading && <CircularProgress />}\n {formRenderer ? (\n renderCustomLayout(formProps)\n ) : (\n <Fields\n contentModel={model}\n fields={model.fields || []}\n layout={model.layout || []}\n {...formProps}\n Bind={formProps.Bind as any}\n />\n )}\n </FormWrapper>\n </ModelProvider>\n );\n }}\n </Form>\n );\n};\n"],"mappings":";;;;;;;;;;;AAAA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AAA2E;AAE3E,IAAMA,WAAW,oBAAGC,eAAM,EAAC,KAAK;EAAA;EAAA;AAAA,GAAE;EAC9BC,MAAM,EAAE,qBAAqB;EAC7BC,QAAQ,EAAE;AACd,CAAC,CAAC;AAMF,SAASC,YAAY,CAACC,GAAW,EAAEC,KAAa,EAAsB;EAClE,OAAOD,GAAG,KAAK,YAAY,GAAG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ContentModel, CmsEditorField, CmsEditorFieldsLayout, BindComponent } from "../../../types";
2
+ import { CmsEditorContentModel, CmsModelField, CmsEditorFieldsLayout, BindComponent } from "../../../types";
3
3
  interface FieldsProps {
4
4
  Bind: BindComponent;
5
5
  contentModel: CmsEditorContentModel;
6
- fields: CmsEditorField[];
6
+ fields: CmsModelField[];
7
7
  layout: CmsEditorFieldsLayout;
8
8
  gridClassName?: string;
9
9
  }
@@ -1 +1 @@
1
- {"version":3,"names":["getFieldById","fields","id","find","field","Fields","Bind","layout","contentModel","gridClassName","map","row","rowIndex","fieldId","Math","floor","length"],"sources":["Fields.tsx"],"sourcesContent":["import React from \"react\";\nimport { Cell, Grid } from \"@webiny/ui/Grid\";\nimport RenderFieldElement from \"./RenderFieldElement\";\nimport {\n CmsEditorContentModel,\n CmsEditorField,\n CmsEditorFieldsLayout,\n BindComponent\n} from \"~/types\";\n\ninterface FieldsProps {\n Bind: BindComponent;\n contentModel: CmsEditorContentModel;\n fields: CmsEditorField[];\n layout: CmsEditorFieldsLayout;\n gridClassName?: string;\n}\n\nconst getFieldById = (fields: CmsEditorField[], id: string): CmsEditorField | null => {\n return fields.find(field => field.id === id) || null;\n};\n\nexport const Fields: React.FC<FieldsProps> = ({\n Bind,\n fields,\n layout,\n contentModel,\n gridClassName\n}) => {\n return (\n <Grid className={gridClassName}>\n {layout.map((row, rowIndex) => (\n <React.Fragment key={rowIndex}>\n {row.map(fieldId => (\n <Cell span={Math.floor(12 / row.length)} key={fieldId}>\n <RenderFieldElement\n field={getFieldById(fields, fieldId) as CmsEditorField}\n Bind={Bind}\n contentModel={contentModel}\n />\n </Cell>\n ))}\n </React.Fragment>\n ))}\n </Grid>\n );\n};\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AAgBA,IAAMA,YAAY,GAAG,SAAfA,YAAY,CAAIC,MAAwB,EAAEC,EAAU,EAA4B;EAClF,OAAOD,MAAM,CAACE,IAAI,CAAC,UAAAC,KAAK;IAAA,OAAIA,KAAK,CAACF,EAAE,KAAKA,EAAE;EAAA,EAAC,IAAI,IAAI;AACxD,CAAC;AAEM,IAAMG,MAA6B,GAAG,SAAhCA,MAA6B,OAMpC;EAAA,IALFC,IAAI,QAAJA,IAAI;IACJL,MAAM,QAANA,MAAM;IACNM,MAAM,QAANA,MAAM;IACNC,YAAY,QAAZA,YAAY;IACZC,aAAa,QAAbA,aAAa;EAEb,oBACI,6BAAC,UAAI;IAAC,SAAS,EAAEA;EAAc,GAC1BF,MAAM,CAACG,GAAG,CAAC,UAACC,GAAG,EAAEC,QAAQ;IAAA,oBACtB,6BAAC,cAAK,CAAC,QAAQ;MAAC,GAAG,EAAEA;IAAS,GACzBD,GAAG,CAACD,GAAG,CAAC,UAAAG,OAAO;MAAA,oBACZ,6BAAC,UAAI;QAAC,IAAI,EAAEC,IAAI,CAACC,KAAK,CAAC,EAAE,GAAGJ,GAAG,CAACK,MAAM,CAAE;QAAC,GAAG,EAAEH;MAAQ,gBAClD,6BAAC,2BAAkB;QACf,KAAK,EAAEb,YAAY,CAACC,MAAM,EAAEY,OAAO,CAAoB;QACvD,IAAI,EAAEP,IAAK;QACX,YAAY,EAAEE;MAAa,EAC7B,CACC;IAAA,CACV,CAAC,CACW;EAAA,CACpB,CAAC,CACC;AAEf,CAAC;AAAC"}
1
+ {"version":3,"names":["getFieldById","fields","id","find","field","Fields","Bind","layout","contentModel","gridClassName","map","row","rowIndex","fieldId","Math","floor","length"],"sources":["Fields.tsx"],"sourcesContent":["import React from \"react\";\nimport { Cell, Grid } from \"@webiny/ui/Grid\";\nimport RenderFieldElement from \"./RenderFieldElement\";\nimport {\n CmsEditorContentModel,\n CmsModelField,\n CmsEditorFieldsLayout,\n BindComponent\n} from \"~/types\";\n\ninterface FieldsProps {\n Bind: BindComponent;\n contentModel: CmsEditorContentModel;\n fields: CmsModelField[];\n layout: CmsEditorFieldsLayout;\n gridClassName?: string;\n}\n\nconst getFieldById = (fields: CmsModelField[], id: string): CmsModelField | null => {\n return fields.find(field => field.id === id) || null;\n};\n\nexport const Fields: React.FC<FieldsProps> = ({\n Bind,\n fields,\n layout,\n contentModel,\n gridClassName\n}) => {\n return (\n <Grid className={gridClassName}>\n {layout.map((row, rowIndex) => (\n <React.Fragment key={rowIndex}>\n {row.map(fieldId => (\n <Cell span={Math.floor(12 / row.length)} key={fieldId}>\n <RenderFieldElement\n field={getFieldById(fields, fieldId) as CmsModelField}\n Bind={Bind}\n contentModel={contentModel}\n />\n </Cell>\n ))}\n </React.Fragment>\n ))}\n </Grid>\n );\n};\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AAgBA,IAAMA,YAAY,GAAG,SAAfA,YAAY,CAAIC,MAAuB,EAAEC,EAAU,EAA2B;EAChF,OAAOD,MAAM,CAACE,IAAI,CAAC,UAAAC,KAAK;IAAA,OAAIA,KAAK,CAACF,EAAE,KAAKA,EAAE;EAAA,EAAC,IAAI,IAAI;AACxD,CAAC;AAEM,IAAMG,MAA6B,GAAG,SAAhCA,MAA6B,OAMpC;EAAA,IALFC,IAAI,QAAJA,IAAI;IACJL,MAAM,QAANA,MAAM;IACNM,MAAM,QAANA,MAAM;IACNC,YAAY,QAAZA,YAAY;IACZC,aAAa,QAAbA,aAAa;EAEb,oBACI,6BAAC,UAAI;IAAC,SAAS,EAAEA;EAAc,GAC1BF,MAAM,CAACG,GAAG,CAAC,UAACC,GAAG,EAAEC,QAAQ;IAAA,oBACtB,6BAAC,cAAK,CAAC,QAAQ;MAAC,GAAG,EAAEA;IAAS,GACzBD,GAAG,CAACD,GAAG,CAAC,UAAAG,OAAO;MAAA,oBACZ,6BAAC,UAAI;QAAC,IAAI,EAAEC,IAAI,CAACC,KAAK,CAAC,EAAE,GAAGJ,GAAG,CAACK,MAAM,CAAE;QAAC,GAAG,EAAEH;MAAQ,gBAClD,6BAAC,2BAAkB;QACf,KAAK,EAAEb,YAAY,CAACC,MAAM,EAAEY,OAAO,CAAmB;QACtD,IAAI,EAAEP,IAAK;QACX,YAAY,EAAEE;MAAa,EAC7B,CACC;IAAA,CACV,CAAC,CACW;EAAA,CACpB,CAAC,CACC;AAEf,CAAC;AAAC"}
@@ -1,7 +1,7 @@
1
1
  import React from "react";
2
- import { CmsEditorField, CmsEditorContentModel, BindComponent } from "../../../types";
2
+ import { CmsModelField, CmsEditorContentModel, BindComponent } from "../../../types";
3
3
  interface RenderFieldElementProps {
4
- field: CmsEditorField;
4
+ field: CmsModelField;
5
5
  Bind: BindComponent;
6
6
  contentModel: CmsEditorContentModel;
7
7
  }
@@ -12,6 +12,7 @@ var _i18n = require("@webiny/app/i18n");
12
12
  var _Label = _interopRequireDefault(require("./Label"));
13
13
  var _useBind = require("./useBind");
14
14
  var _useRenderPlugins = require("./useRenderPlugins");
15
+ var _ModelFieldProvider = require("../ModelFieldProvider");
15
16
  var _templateObject;
16
17
  var t = _i18n.i18n.ns("app-headless-cms/admin/components/content-form");
17
18
  var RenderFieldElement = function RenderFieldElement(props) {
@@ -31,12 +32,14 @@ var RenderFieldElement = function RenderFieldElement(props) {
31
32
  fieldName: /*#__PURE__*/_react.default.createElement("strong", null, field.fieldId)
32
33
  });
33
34
  }
34
- return renderPlugin.renderer.render({
35
+ return /*#__PURE__*/_react.default.createElement(_ModelFieldProvider.ModelFieldProvider, {
36
+ field: field
37
+ }, renderPlugin.renderer.render({
35
38
  field: field,
36
39
  getBind: getBind,
37
40
  Label: _Label.default,
38
41
  contentModel: contentModel
39
- });
42
+ }));
40
43
  };
41
44
  var _default = RenderFieldElement;
42
45
  exports.default = _default;
@@ -1 +1 @@
1
- {"version":3,"names":["t","i18n","ns","RenderFieldElement","props","renderPlugins","useRenderPlugins","field","Bind","contentModel","getBind","useBind","renderPlugin","find","plugin","renderer","rendererName","get","fieldName","fieldId","render","Label"],"sources":["RenderFieldElement.tsx"],"sourcesContent":["import React from \"react\";\nimport { CmsEditorField, CmsEditorContentModel, BindComponent } from \"~/types\";\nimport get from \"lodash/get\";\nimport { i18n } from \"@webiny/app/i18n\";\nimport Label from \"./Label\";\nimport { useBind } from \"./useBind\";\nimport { useRenderPlugins } from \"./useRenderPlugins\";\n\nconst t = i18n.ns(\"app-headless-cms/admin/components/content-form\");\n\ninterface RenderFieldElementProps {\n field: CmsEditorField;\n Bind: BindComponent;\n contentModel: CmsEditorContentModel;\n}\nconst RenderFieldElement: React.FC<RenderFieldElementProps> = props => {\n const renderPlugins = useRenderPlugins();\n const { field, Bind, contentModel } = props;\n const getBind = useBind({ Bind, field });\n\n const renderPlugin = renderPlugins.find(\n plugin => plugin.renderer.rendererName === get(field, \"renderer.name\")\n );\n\n if (!renderPlugin) {\n return t`Cannot render \"{fieldName}\" field - field renderer missing.`({\n fieldName: <strong>{field.fieldId}</strong>\n });\n }\n\n return renderPlugin.renderer.render({ field, getBind, Label, contentModel });\n};\n\nexport default RenderFieldElement;\n"],"mappings":";;;;;;;;AAAA;AAEA;AACA;AACA;AACA;AACA;AAAsD;AAEtD,IAAMA,CAAC,GAAGC,UAAI,CAACC,EAAE,CAAC,gDAAgD,CAAC;AAOnE,IAAMC,kBAAqD,GAAG,SAAxDA,kBAAqD,CAAGC,KAAK,EAAI;EACnE,IAAMC,aAAa,GAAG,IAAAC,kCAAgB,GAAE;EACxC,IAAQC,KAAK,GAAyBH,KAAK,CAAnCG,KAAK;IAAEC,IAAI,GAAmBJ,KAAK,CAA5BI,IAAI;IAAEC,YAAY,GAAKL,KAAK,CAAtBK,YAAY;EACjC,IAAMC,OAAO,GAAG,IAAAC,gBAAO,EAAC;IAAEH,IAAI,EAAJA,IAAI;IAAED,KAAK,EAALA;EAAM,CAAC,CAAC;EAExC,IAAMK,YAAY,GAAGP,aAAa,CAACQ,IAAI,CACnC,UAAAC,MAAM;IAAA,OAAIA,MAAM,CAACC,QAAQ,CAACC,YAAY,KAAK,IAAAC,YAAG,EAACV,KAAK,EAAE,eAAe,CAAC;EAAA,EACzE;EAED,IAAI,CAACK,YAAY,EAAE;IACf,OAAOZ,CAAC,iJAA8D;MAClEkB,SAAS,eAAE,6CAASX,KAAK,CAACY,OAAO;IACrC,CAAC,CAAC;EACN;EAEA,OAAOP,YAAY,CAACG,QAAQ,CAACK,MAAM,CAAC;IAAEb,KAAK,EAALA,KAAK;IAAEG,OAAO,EAAPA,OAAO;IAAEW,KAAK,EAALA,cAAK;IAAEZ,YAAY,EAAZA;EAAa,CAAC,CAAC;AAChF,CAAC;AAAC,eAEaN,kBAAkB;AAAA"}
1
+ {"version":3,"names":["t","i18n","ns","RenderFieldElement","props","renderPlugins","useRenderPlugins","field","Bind","contentModel","getBind","useBind","renderPlugin","find","plugin","renderer","rendererName","get","fieldName","fieldId","render","Label"],"sources":["RenderFieldElement.tsx"],"sourcesContent":["import React from \"react\";\nimport { CmsModelField, CmsEditorContentModel, BindComponent } from \"~/types\";\nimport get from \"lodash/get\";\nimport { i18n } from \"@webiny/app/i18n\";\nimport Label from \"./Label\";\nimport { useBind } from \"./useBind\";\nimport { useRenderPlugins } from \"./useRenderPlugins\";\nimport { ModelFieldProvider } from \"../ModelFieldProvider\";\n\nconst t = i18n.ns(\"app-headless-cms/admin/components/content-form\");\n\ninterface RenderFieldElementProps {\n field: CmsModelField;\n Bind: BindComponent;\n contentModel: CmsEditorContentModel;\n}\n\nconst RenderFieldElement: React.FC<RenderFieldElementProps> = props => {\n const renderPlugins = useRenderPlugins();\n const { field, Bind, contentModel } = props;\n const getBind = useBind({ Bind, field });\n\n const renderPlugin = renderPlugins.find(\n plugin => plugin.renderer.rendererName === get(field, \"renderer.name\")\n );\n\n if (!renderPlugin) {\n return t`Cannot render \"{fieldName}\" field - field renderer missing.`({\n fieldName: <strong>{field.fieldId}</strong>\n });\n }\n\n return (\n <ModelFieldProvider field={field}>\n {renderPlugin.renderer.render({ field, getBind, Label, contentModel })}\n </ModelFieldProvider>\n );\n};\n\nexport default RenderFieldElement;\n"],"mappings":";;;;;;;;AAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AAA2D;AAE3D,IAAMA,CAAC,GAAGC,UAAI,CAACC,EAAE,CAAC,gDAAgD,CAAC;AAQnE,IAAMC,kBAAqD,GAAG,SAAxDA,kBAAqD,CAAGC,KAAK,EAAI;EACnE,IAAMC,aAAa,GAAG,IAAAC,kCAAgB,GAAE;EACxC,IAAQC,KAAK,GAAyBH,KAAK,CAAnCG,KAAK;IAAEC,IAAI,GAAmBJ,KAAK,CAA5BI,IAAI;IAAEC,YAAY,GAAKL,KAAK,CAAtBK,YAAY;EACjC,IAAMC,OAAO,GAAG,IAAAC,gBAAO,EAAC;IAAEH,IAAI,EAAJA,IAAI;IAAED,KAAK,EAALA;EAAM,CAAC,CAAC;EAExC,IAAMK,YAAY,GAAGP,aAAa,CAACQ,IAAI,CACnC,UAAAC,MAAM;IAAA,OAAIA,MAAM,CAACC,QAAQ,CAACC,YAAY,KAAK,IAAAC,YAAG,EAACV,KAAK,EAAE,eAAe,CAAC;EAAA,EACzE;EAED,IAAI,CAACK,YAAY,EAAE;IACf,OAAOZ,CAAC,iJAA8D;MAClEkB,SAAS,eAAE,6CAASX,KAAK,CAACY,OAAO;IACrC,CAAC,CAAC;EACN;EAEA,oBACI,6BAAC,sCAAkB;IAAC,KAAK,EAAEZ;EAAM,GAC5BK,YAAY,CAACG,QAAQ,CAACK,MAAM,CAAC;IAAEb,KAAK,EAALA,KAAK;IAAEG,OAAO,EAAPA,OAAO;IAAEW,KAAK,EAALA,cAAK;IAAEZ,YAAY,EAAZA;EAAa,CAAC,CAAC,CACrD;AAE7B,CAAC;AAAC,eAEaN,kBAAkB;AAAA"}
@@ -1,8 +1,8 @@
1
- import { CmsEditorField } from "../../../../types";
1
+ import { CmsModelField } from "../../../../types";
2
2
  import { BindComponentRenderProp } from "@webiny/form";
3
3
  interface GetValueParams {
4
4
  bind: BindComponentRenderProp;
5
- field: Pick<CmsEditorField, "multipleValues">;
5
+ field: Pick<CmsModelField, "multipleValues">;
6
6
  index: number;
7
7
  }
8
8
  export declare const getValue: (params: GetValueParams) => string;
@@ -1 +1 @@
1
- {"version":3,"names":["getValue","params","bind","field","index","value","multipleValues","Array","isArray"],"sources":["getValue.ts"],"sourcesContent":["import { CmsEditorField } from \"~/types\";\nimport { BindComponentRenderProp } from \"@webiny/form\";\n\ninterface GetValueParams {\n bind: BindComponentRenderProp;\n field: Pick<CmsEditorField, \"multipleValues\">;\n index: number;\n}\nexport const getValue = (params: GetValueParams): string => {\n const { bind, field, index } = params;\n let value = bind.value || null;\n\n if (field.multipleValues) {\n if (!Array.isArray(value)) {\n value = [];\n }\n\n if (index >= 0) {\n return value[index] || null;\n }\n\n return value;\n }\n\n return value;\n};\n"],"mappings":";;;;;;AAQO,IAAMA,QAAQ,GAAG,SAAXA,QAAQ,CAAIC,MAAsB,EAAa;EACxD,IAAQC,IAAI,GAAmBD,MAAM,CAA7BC,IAAI;IAAEC,KAAK,GAAYF,MAAM,CAAvBE,KAAK;IAAEC,KAAK,GAAKH,MAAM,CAAhBG,KAAK;EAC1B,IAAIC,KAAK,GAAGH,IAAI,CAACG,KAAK,IAAI,IAAI;EAE9B,IAAIF,KAAK,CAACG,cAAc,EAAE;IACtB,IAAI,CAACC,KAAK,CAACC,OAAO,CAACH,KAAK,CAAC,EAAE;MACvBA,KAAK,GAAG,EAAE;IACd;IAEA,IAAID,KAAK,IAAI,CAAC,EAAE;MACZ,OAAOC,KAAK,CAACD,KAAK,CAAC,IAAI,IAAI;IAC/B;IAEA,OAAOC,KAAK;EAChB;EAEA,OAAOA,KAAK;AAChB,CAAC;AAAC"}
1
+ {"version":3,"names":["getValue","params","bind","field","index","value","multipleValues","Array","isArray"],"sources":["getValue.ts"],"sourcesContent":["import { CmsModelField } from \"~/types\";\nimport { BindComponentRenderProp } from \"@webiny/form\";\n\ninterface GetValueParams {\n bind: BindComponentRenderProp;\n field: Pick<CmsModelField, \"multipleValues\">;\n index: number;\n}\nexport const getValue = (params: GetValueParams): string => {\n const { bind, field, index } = params;\n let value = bind.value || null;\n\n if (field.multipleValues) {\n if (!Array.isArray(value)) {\n value = [];\n }\n\n if (index >= 0) {\n return value[index] || null;\n }\n\n return value;\n }\n\n return value;\n};\n"],"mappings":";;;;;;AAQO,IAAMA,QAAQ,GAAG,SAAXA,QAAQ,CAAIC,MAAsB,EAAa;EACxD,IAAQC,IAAI,GAAmBD,MAAM,CAA7BC,IAAI;IAAEC,KAAK,GAAYF,MAAM,CAAvBE,KAAK;IAAEC,KAAK,GAAKH,MAAM,CAAhBG,KAAK;EAC1B,IAAIC,KAAK,GAAGH,IAAI,CAACG,KAAK,IAAI,IAAI;EAE9B,IAAIF,KAAK,CAACG,cAAc,EAAE;IACtB,IAAI,CAACC,KAAK,CAACC,OAAO,CAACH,KAAK,CAAC,EAAE;MACvBA,KAAK,GAAG,EAAE;IACd;IAEA,IAAID,KAAK,IAAI,CAAC,EAAE;MACZ,OAAOC,KAAK,CAACD,KAAK,CAAC,IAAI,IAAI;IAC/B;IAEA,OAAOC,KAAK;EAChB;EAEA,OAAOA,KAAK;AAChB,CAAC;AAAC"}
@@ -1,9 +1,9 @@
1
- import { CmsEditorField } from "../../../../types";
1
+ import { CmsModelField } from "../../../../types";
2
2
  import { BindComponentRenderProp } from "@webiny/form";
3
3
  interface setValueParams {
4
4
  value: string[];
5
5
  bind: BindComponentRenderProp;
6
- field: Pick<CmsEditorField, "multipleValues">;
6
+ field: Pick<CmsModelField, "multipleValues">;
7
7
  index: number;
8
8
  }
9
9
  export declare const setValue: (params: setValueParams) => void;
@@ -1 +1 @@
1
- {"version":3,"names":["setValue","params","value","bind","field","index","newValue","multipleValues","onChange"],"sources":["setValue.ts"],"sourcesContent":["import { CmsEditorField } from \"~/types\";\nimport { BindComponentRenderProp } from \"@webiny/form\";\n\ninterface setValueParams {\n value: string[];\n bind: BindComponentRenderProp;\n field: Pick<CmsEditorField, \"multipleValues\">;\n index: number;\n}\nexport const setValue = (params: setValueParams): void => {\n const { value, bind, field, index } = params;\n let newValue = field.multipleValues ? [...(bind.value || [])] : bind.value;\n\n if (field.multipleValues) {\n if (index >= 0) {\n newValue[index] = value;\n } else {\n newValue = value;\n }\n } else {\n newValue = value;\n }\n\n bind.onChange(newValue);\n};\n"],"mappings":";;;;;;;;AASO,IAAMA,QAAQ,GAAG,SAAXA,QAAQ,CAAIC,MAAsB,EAAW;EACtD,IAAQC,KAAK,GAAyBD,MAAM,CAApCC,KAAK;IAAEC,IAAI,GAAmBF,MAAM,CAA7BE,IAAI;IAAEC,KAAK,GAAYH,MAAM,CAAvBG,KAAK;IAAEC,KAAK,GAAKJ,MAAM,CAAhBI,KAAK;EACjC,IAAIC,QAAQ,GAAGF,KAAK,CAACG,cAAc,oCAAQJ,IAAI,CAACD,KAAK,IAAI,EAAE,IAAKC,IAAI,CAACD,KAAK;EAE1E,IAAIE,KAAK,CAACG,cAAc,EAAE;IACtB,IAAIF,KAAK,IAAI,CAAC,EAAE;MACZC,QAAQ,CAACD,KAAK,CAAC,GAAGH,KAAK;IAC3B,CAAC,MAAM;MACHI,QAAQ,GAAGJ,KAAK;IACpB;EACJ,CAAC,MAAM;IACHI,QAAQ,GAAGJ,KAAK;EACpB;EAEAC,IAAI,CAACK,QAAQ,CAACF,QAAQ,CAAC;AAC3B,CAAC;AAAC"}
1
+ {"version":3,"names":["setValue","params","value","bind","field","index","newValue","multipleValues","onChange"],"sources":["setValue.ts"],"sourcesContent":["import { CmsModelField } from \"~/types\";\nimport { BindComponentRenderProp } from \"@webiny/form\";\n\ninterface setValueParams {\n value: string[];\n bind: BindComponentRenderProp;\n field: Pick<CmsModelField, \"multipleValues\">;\n index: number;\n}\nexport const setValue = (params: setValueParams): void => {\n const { value, bind, field, index } = params;\n let newValue = field.multipleValues ? [...(bind.value || [])] : bind.value;\n\n if (field.multipleValues) {\n if (index >= 0) {\n newValue[index] = value;\n } else {\n newValue = value;\n }\n } else {\n newValue = value;\n }\n\n bind.onChange(newValue);\n};\n"],"mappings":";;;;;;;;AASO,IAAMA,QAAQ,GAAG,SAAXA,QAAQ,CAAIC,MAAsB,EAAW;EACtD,IAAQC,KAAK,GAAyBD,MAAM,CAApCC,KAAK;IAAEC,IAAI,GAAmBF,MAAM,CAA7BE,IAAI;IAAEC,KAAK,GAAYH,MAAM,CAAvBG,KAAK;IAAEC,KAAK,GAAKJ,MAAM,CAAhBI,KAAK;EACjC,IAAIC,QAAQ,GAAGF,KAAK,CAACG,cAAc,oCAAQJ,IAAI,CAACD,KAAK,IAAI,EAAE,IAAKC,IAAI,CAACD,KAAK;EAE1E,IAAIE,KAAK,CAACG,cAAc,EAAE;IACtB,IAAIF,KAAK,IAAI,CAAC,EAAE;MACZC,QAAQ,CAACD,KAAK,CAAC,GAAGH,KAAK;IAC3B,CAAC,MAAM;MACHI,QAAQ,GAAGJ,KAAK;IACpB;EACJ,CAAC,MAAM;IACHI,QAAQ,GAAGJ,KAAK;EACpB;EAEAC,IAAI,CAACK,QAAQ,CAACF,QAAQ,CAAC;AAC3B,CAAC;AAAC"}
@@ -1,6 +1,6 @@
1
- import { BindComponent, CmsEditorField } from "../../../types";
1
+ import { BindComponent, CmsModelField } from "../../../types";
2
2
  interface UseBindProps {
3
- field: CmsEditorField;
3
+ field: CmsModelField;
4
4
  Bind: BindComponent;
5
5
  }
6
6
  export interface GetBindCallable {
@@ -9,7 +9,7 @@ exports.useBind = useBind;
9
9
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
10
10
  var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
11
  var _react = _interopRequireWildcard(require("react"));
12
- var _createValidators = require("./functions/createValidators");
12
+ var _createValidators = require("../../../utils/createValidators");
13
13
  function useBind(_ref) {
14
14
  var ParentBind = _ref.Bind,
15
15
  field = _ref.field;
@@ -25,8 +25,8 @@ function useBind(_ref) {
25
25
  if (memoizedBindComponents.current[name]) {
26
26
  return memoizedBindComponents.current[name];
27
27
  }
28
- var validators = (0, _createValidators.createValidators)(field.validation || []);
29
- var listValidators = (0, _createValidators.createValidators)(field.listValidation || []);
28
+ var validators = (0, _createValidators.createValidators)(field, field.validation || []);
29
+ var listValidators = (0, _createValidators.createValidators)(field, field.listValidation || []);
30
30
  var defaultValue = field.multipleValues ? [] : undefined;
31
31
  var isMultipleValues = index === -1 && field.multipleValues;
32
32
  var inputValidators = isMultipleValues ? listValidators : validators;
@@ -42,14 +42,16 @@ function useBind(_ref) {
42
42
  // Multiple-values functions below.
43
43
  var props = (0, _objectSpread2.default)({}, bind);
44
44
  if (field.multipleValues && index === -1) {
45
- props.appendValue = function (newValue) {
46
- bind.onChange([].concat((0, _toConsumableArray2.default)(bind.value), [newValue]));
45
+ props.appendValue = function (newValue, index) {
46
+ var currentValue = bind.value || [];
47
+ var newIndex = index !== null && index !== void 0 ? index : currentValue.length;
48
+ bind.onChange([].concat((0, _toConsumableArray2.default)(currentValue.slice(0, newIndex)), [newValue], (0, _toConsumableArray2.default)(currentValue.slice(newIndex))));
47
49
  };
48
50
  props.prependValue = function (newValue) {
49
- bind.onChange([newValue].concat((0, _toConsumableArray2.default)(bind.value)));
51
+ bind.onChange([newValue].concat((0, _toConsumableArray2.default)(bind.value || [])));
50
52
  };
51
53
  props.appendValues = function (newValues) {
52
- bind.onChange([].concat((0, _toConsumableArray2.default)(bind.value), (0, _toConsumableArray2.default)(newValues)));
54
+ bind.onChange([].concat((0, _toConsumableArray2.default)(bind.value || []), (0, _toConsumableArray2.default)(newValues)));
53
55
  };
54
56
  props.removeValue = function (index) {
55
57
  if (index < 0) {
@@ -90,8 +92,7 @@ function useBind(_ref) {
90
92
 
91
93
  // We need to keep track of current field name, to support nested fields.
92
94
  memoizedBindComponents.current[name].parentName = name;
95
+ memoizedBindComponents.current[name].displayName = "ParentBind<".concat(name, ">");
93
96
  return memoizedBindComponents.current[name];
94
97
  }, [field.fieldId]);
95
- }
96
-
97
- // [0,1,2,3,4,5]
98
+ }
@@ -1 +1 @@
1
- {"version":3,"names":["useBind","ParentBind","Bind","field","memoizedBindComponents","useRef","useCallback","index","parentName","name","fieldId","undefined","filter","v","join","current","validators","createValidators","validation","listValidators","listValidation","defaultValue","multipleValues","isMultipleValues","inputValidators","UseBind","params","childName","childValidators","children","bind","props","appendValue","newValue","onChange","value","prependValue","appendValues","newValues","removeValue","slice","form","validateInput","moveValueUp","splice","moveValueDown","length","cloneElement"],"sources":["useBind.tsx"],"sourcesContent":["import React, { useRef, useCallback, cloneElement } from \"react\";\nimport { createValidators } from \"./functions/createValidators\";\nimport { BindComponent, CmsEditorField } from \"~/types\";\nimport { Validator } from \"@webiny/validation/types\";\n\ninterface UseBindProps {\n field: CmsEditorField;\n Bind: BindComponent;\n}\n\ninterface UseBindParams {\n name?: string;\n validators?: Validator | Validator[];\n children?: any;\n}\n\nexport interface GetBindCallable {\n (index?: number): BindComponent;\n}\n\nexport function useBind({ Bind: ParentBind, field }: UseBindProps) {\n const memoizedBindComponents = useRef<Record<string, BindComponent>>({});\n\n return useCallback(\n (index = -1) => {\n const { parentName } = ParentBind;\n // If there's a parent name assigned to the given Bind component, we need to include it in the new field \"name\".\n // This allows us to have nested fields (like \"object\" field with nested properties)\n const name = [parentName, field.fieldId, index >= 0 ? index : undefined]\n .filter(v => v !== undefined)\n .join(\".\");\n\n if (memoizedBindComponents.current[name]) {\n return memoizedBindComponents.current[name];\n }\n\n const validators = createValidators(field.validation || []);\n const listValidators = createValidators(field.listValidation || []);\n const defaultValue: string[] | undefined = field.multipleValues ? [] : undefined;\n const isMultipleValues = index === -1 && field.multipleValues;\n const inputValidators = isMultipleValues ? listValidators : validators;\n\n memoizedBindComponents.current[name] = function UseBind(params: UseBindParams) {\n const { name: childName, validators: childValidators, children } = params;\n return (\n <ParentBind\n name={childName || name}\n validators={childValidators || inputValidators}\n defaultValue={index === -1 ? defaultValue : null}\n >\n {bind => {\n // Multiple-values functions below.\n const props = { ...bind };\n if (field.multipleValues && index === -1) {\n props.appendValue = (newValue: string) => {\n bind.onChange([...bind.value, newValue]);\n };\n props.prependValue = (newValue: string) => {\n bind.onChange([newValue, ...bind.value]);\n };\n props.appendValues = (newValues: string[]) => {\n bind.onChange([...bind.value, ...newValues]);\n };\n\n props.removeValue = (index: number) => {\n if (index < 0) {\n return;\n }\n let value = bind.value;\n value = [...value.slice(0, index), ...value.slice(index + 1)];\n\n bind.onChange(value);\n\n // To make sure the field is still valid, we must trigger validation.\n bind.form.validateInput(field.fieldId);\n };\n\n props.moveValueUp = (index: number) => {\n if (index <= 0) {\n return;\n }\n\n const value = [...bind.value];\n value.splice(index, 1);\n value.splice(index - 1, 0, bind.value[index]);\n\n bind.onChange(value);\n };\n\n props.moveValueDown = (index: number) => {\n if (index >= bind.value.length) {\n return;\n }\n\n const value = [...bind.value];\n value.splice(index, 1);\n value.splice(index + 1, 0, bind.value[index]);\n\n bind.onChange(value);\n };\n }\n\n if (typeof children === \"function\") {\n return children(props);\n }\n\n return cloneElement(children, props);\n }}\n </ParentBind>\n );\n };\n\n // We need to keep track of current field name, to support nested fields.\n memoizedBindComponents.current[name].parentName = name;\n\n return memoizedBindComponents.current[name];\n },\n [field.fieldId]\n );\n}\n\n// [0,1,2,3,4,5]\n"],"mappings":";;;;;;;;;;AAAA;AACA;AAmBO,SAASA,OAAO,OAA4C;EAAA,IAAnCC,UAAU,QAAhBC,IAAI;IAAcC,KAAK,QAALA,KAAK;EAC7C,IAAMC,sBAAsB,GAAG,IAAAC,aAAM,EAAgC,CAAC,CAAC,CAAC;EAExE,OAAO,IAAAC,kBAAW,EACd,YAAgB;IAAA,IAAfC,KAAK,uEAAG,CAAC,CAAC;IACP,IAAQC,UAAU,GAAKP,UAAU,CAAzBO,UAAU;IAClB;IACA;IACA,IAAMC,IAAI,GAAG,CAACD,UAAU,EAAEL,KAAK,CAACO,OAAO,EAAEH,KAAK,IAAI,CAAC,GAAGA,KAAK,GAAGI,SAAS,CAAC,CACnEC,MAAM,CAAC,UAAAC,CAAC;MAAA,OAAIA,CAAC,KAAKF,SAAS;IAAA,EAAC,CAC5BG,IAAI,CAAC,GAAG,CAAC;IAEd,IAAIV,sBAAsB,CAACW,OAAO,CAACN,IAAI,CAAC,E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CAACS,MAAM,CAACrC,KAAK,GAAG,CAAC,EAAE,CAAC,EAAEuB,IAAI,CAACK,KAAK,CAAC5B,KAAK,CAAC,CAAC;YAE7CuB,IAAI,CAACI,QAAQ,CAACC,KAAK,CAAC;UACxB,CAAC;QACL;QAEA,IAAI,OAAON,QAAQ,KAAK,UAAU,EAAE;UAChC,OAAOA,QAAQ,CAACE,KAAK,CAAC;QAC1B;QAEA,oBAAO,IAAAgB,mBAAY,EAAClB,QAAQ,EAAEE,KAAK,CAAC;MACxC,CAAC,CACQ;IAErB,CAAC;;IAED;IACA3B,sBAAsB,CAACW,OAAO,CAACN,IAAI,CAAC,CAACD,UAAU,GAAGC,IAAI;IAEtD,OAAOL,sBAAsB,CAACW,OAAO,CAACN,IAAI,CAAC;EAC/C,CAAC,EACD,CAACN,KAAK,CAACO,OAAO,CAAC,CAClB;AACL;;AAEA"}
1
+ {"version":3,"names":["useBind","ParentBind","Bind","field","memoizedBindComponents","useRef","useCallback","index","parentName","name","fieldId","undefined","filter","v","join","current","validators","createValidators","validation","listValidators","listValidation","defaultValue","multipleValues","isMultipleValues","inputValidators","UseBind","params","childName","childValidators","children","bind","props","appendValue","newValue","currentValue","value","newIndex","length","onChange","slice","prependValue","appendValues","newValues","removeValue","form","validateInput","moveValueUp","splice","moveValueDown","cloneElement","displayName"],"sources":["useBind.tsx"],"sourcesContent":["import React, { useRef, useCallback, cloneElement } from \"react\";\nimport { createValidators } from \"~/utils/createValidators\";\nimport { BindComponent, CmsModelField } from \"~/types\";\nimport { Validator } from \"@webiny/validation/types\";\n\ninterface UseBindProps {\n field: CmsModelField;\n Bind: BindComponent;\n}\n\ninterface UseBindParams {\n name?: string;\n validators?: Validator | Validator[];\n children?: any;\n}\n\nexport interface GetBindCallable {\n (index?: number): BindComponent;\n}\n\nexport function useBind({ Bind: ParentBind, field }: UseBindProps) {\n const memoizedBindComponents = useRef<Record<string, BindComponent>>({});\n\n return useCallback(\n (index = -1) => {\n const { parentName } = ParentBind;\n // If there's a parent name assigned to the given Bind component, we need to include it in the new field \"name\".\n // This allows us to have nested fields (like \"object\" field with nested properties)\n const name = [parentName, field.fieldId, index >= 0 ? index : undefined]\n .filter(v => v !== undefined)\n .join(\".\");\n\n if (memoizedBindComponents.current[name]) {\n return memoizedBindComponents.current[name];\n }\n\n const validators = createValidators(field, field.validation || []);\n const listValidators = createValidators(field, field.listValidation || []);\n const defaultValue: string[] | undefined = field.multipleValues ? [] : undefined;\n const isMultipleValues = index === -1 && field.multipleValues;\n const inputValidators = isMultipleValues ? listValidators : validators;\n\n memoizedBindComponents.current[name] = function UseBind(params: UseBindParams) {\n const { name: childName, validators: childValidators, children } = params;\n\n return (\n <ParentBind\n name={childName || name}\n validators={childValidators || inputValidators}\n defaultValue={index === -1 ? defaultValue : null}\n >\n {bind => {\n // Multiple-values functions below.\n const props = { ...bind };\n if (field.multipleValues && index === -1) {\n props.appendValue = (newValue: any, index?: number) => {\n const currentValue = bind.value || [];\n const newIndex = index ?? currentValue.length;\n\n bind.onChange([\n ...currentValue.slice(0, newIndex),\n newValue,\n ...currentValue.slice(newIndex)\n ]);\n };\n props.prependValue = (newValue: any) => {\n bind.onChange([newValue, ...(bind.value || [])]);\n };\n props.appendValues = (newValues: any[]) => {\n bind.onChange([...(bind.value || []), ...newValues]);\n };\n\n props.removeValue = (index: number) => {\n if (index < 0) {\n return;\n }\n let value = bind.value;\n value = [...value.slice(0, index), ...value.slice(index + 1)];\n\n bind.onChange(value);\n\n // To make sure the field is still valid, we must trigger validation.\n bind.form.validateInput(field.fieldId);\n };\n\n props.moveValueUp = (index: number) => {\n if (index <= 0) {\n return;\n }\n\n const value = [...bind.value];\n value.splice(index, 1);\n value.splice(index - 1, 0, bind.value[index]);\n\n bind.onChange(value);\n };\n\n props.moveValueDown = (index: number) => {\n if (index >= bind.value.length) {\n return;\n }\n\n const value = [...bind.value];\n value.splice(index, 1);\n value.splice(index + 1, 0, bind.value[index]);\n\n bind.onChange(value);\n };\n }\n\n if (typeof children === \"function\") {\n return children(props);\n }\n\n return cloneElement(children, props);\n }}\n </ParentBind>\n );\n };\n\n // We need to keep track of current field name, to support nested fields.\n memoizedBindComponents.current[name].parentName = name;\n memoizedBindComponents.current[name].displayName = `ParentBind<${name}>`;\n\n return memoizedBindComponents.current[name];\n },\n [field.fieldId]\n );\n}\n"],"mappings":";;;;;;;;;;AAAA;AACA;AAmBO,SAASA,OAAO,OAA4C;EAAA,IAAnCC,UAAU,QAAhBC,IAAI;IAAcC,KAAK,QAALA,KAAK;EAC7C,IAAMC,sBAAsB,GAAG,IAAAC,aAAM,EAAgC,CAAC,CAAC,CAAC;EAExE,OAAO,IAAAC,kBAAW,EACd,YAAgB;IAAA,IAAfC,KAAK,uEAAG,CAAC,CAAC;IACP,IAAQC,UAAU,GAAKP,UAAU,CAAzBO,UAAU;IAClB;IACA;IACA,IAAMC,IAAI,GAAG,CAACD,UAAU,EAAEL,KAAK,CAACO,OAAO,EAAEH,KAAK,IAAI,CAAC,GAAGA,KAAK,GAAGI,SAAS,CAAC,CACnEC,MAAM,CAAC,UAAAC,CAAC;MAAA,OAAIA,CAAC,KAAKF,SAAS;IAAA,EAAC,CAC5BG,IAAI,CAAC,GAAG,CAAC;IAEd,IAAIV,sBAAsB,CAACW,OAAO,CAACN,IAAI,CAAC,EAAE;MACtC,OAAOL,sBAAsB,CAACW,OAAO,CAACN,IAAI,CAAC;IAC/C;IAEA,IAAMO,UAAU,GAAG,IAAAC,kCAAgB,EAACd,KAAK,EAAEA,KAAK,CAACe,UAAU,IAAI,EAAE,CAAC;IAClE,IAAMC,cAAc,GAAG,IAAAF,kCAAgB,EAACd,KAAK,EAAEA,KAAK,CAACiB,cAAc,IAAI,EAAE,CAAC;IAC1E,IAAMC,YAAkC,GAAGlB,KAAK,CAACmB,cAAc,GAAG,EAAE,GAAGX,SAAS;IAChF,IAAMY,gBAAgB,GAAGhB,KAAK,KAAK,CAAC,CAAC,IAAIJ,KAAK,CAACmB,cAAc;IAC7D,IAAME,e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AK,CAAC;UACxB,CAAC;QACL;QAEA,IAAI,OAAON,QAAQ,KAAK,UAAU,EAAE;UAChC,OAAOA,QAAQ,CAACE,KAAK,CAAC;QAC1B;QAEA,oBAAO,IAAAkB,mBAAY,EAACpB,QAAQ,EAAEE,KAAK,CAAC;MACxC,CAAC,CACQ;IAErB,CAAC;;IAED;IACA3B,sBAAsB,CAACW,OAAO,CAACN,IAAI,CAAC,CAACD,UAAU,GAAGC,IAAI;IACtDL,sBAAsB,CAACW,OAAO,CAACN,IAAI,CAAC,CAACyC,WAAW,wBAAiBzC,IAAI,MAAG;IAExE,OAAOL,sBAAsB,CAACW,OAAO,CAACN,IAAI,CAAC;EAC/C,CAAC,EACD,CAACN,KAAK,CAACO,OAAO,CAAC,CAClB;AACL"}
@@ -1,6 +1,6 @@
1
1
  import { Dispatch, SetStateAction } from "react";
2
2
  import { FormOnSubmit } from "@webiny/form";
3
- import { CmsEditorContentEntry, CmsEditorContentModel, CmsEditorFieldRendererPlugin } from "../../../types";
3
+ import { CmsEditorContentEntry, CmsEditorFieldRendererPlugin } from "../../../types";
4
4
  interface UseContentEntryForm {
5
5
  data: Record<string, any>;
6
6
  loading: boolean;
@@ -11,7 +11,6 @@ interface UseContentEntryForm {
11
11
  renderPlugins: CmsEditorFieldRendererPlugin[];
12
12
  }
13
13
  export interface UseContentEntryFormParams {
14
- contentModel: CmsEditorContentModel;
15
14
  entry: Partial<CmsEditorContentEntry>;
16
15
  onChange?: FormOnSubmit;
17
16
  onSubmit?: FormOnSubmit;