@wix/auto-patterns 1.8.0 → 1.10.0

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 (348) hide show
  1. package/README.md +50 -0
  2. package/dist/cjs/components/AutoPatternsApp/AutoPatternsApp.js.map +1 -1
  3. package/dist/cjs/components/AutoPatternsCollectionPage/AutoPatternsCollectionPage.js +11 -25
  4. package/dist/cjs/components/AutoPatternsCollectionPage/AutoPatternsCollectionPage.js.map +1 -1
  5. package/dist/cjs/components/AutoPatternsCollectionPageContent/AutoPatternsCollectionPageContent.js +35 -6
  6. package/dist/cjs/components/AutoPatternsCollectionPageContent/AutoPatternsCollectionPageContent.js.map +1 -1
  7. package/dist/cjs/components/AutoPatternsEntityPage/AutoPatternsEntityPage.js +20 -13
  8. package/dist/cjs/components/AutoPatternsEntityPage/AutoPatternsEntityPage.js.map +1 -1
  9. package/dist/cjs/components/AutoPatternsEntityPage/Fields/DateInput.js +47 -25
  10. package/dist/cjs/components/AutoPatternsEntityPage/Fields/DateInput.js.map +1 -1
  11. package/dist/cjs/components/AutoPatternsEntityPage/Fields/DateTime.js +66 -30
  12. package/dist/cjs/components/AutoPatternsEntityPage/Fields/DateTime.js.map +1 -1
  13. package/dist/cjs/components/AutoPatternsEntityPage/Fields/FormFieldInput.js +7 -4
  14. package/dist/cjs/components/AutoPatternsEntityPage/Fields/FormFieldInput.js.map +1 -1
  15. package/dist/cjs/components/AutoPatternsEntityPage/Fields/ImageInput.js +85 -0
  16. package/dist/cjs/components/AutoPatternsEntityPage/Fields/ImageInput.js.map +1 -0
  17. package/dist/cjs/components/AutoPatternsEntityPage/Fields/LongText.js +35 -18
  18. package/dist/cjs/components/AutoPatternsEntityPage/Fields/LongText.js.map +1 -1
  19. package/dist/cjs/components/AutoPatternsEntityPage/Fields/Number.js +42 -37
  20. package/dist/cjs/components/AutoPatternsEntityPage/Fields/Number.js.map +1 -1
  21. package/dist/cjs/components/AutoPatternsEntityPage/Fields/ShortText.js +46 -29
  22. package/dist/cjs/components/AutoPatternsEntityPage/Fields/ShortText.js.map +1 -1
  23. package/dist/cjs/components/AutoPatternsEntityPage/Fields/Url.js +35 -40
  24. package/dist/cjs/components/AutoPatternsEntityPage/Fields/Url.js.map +1 -1
  25. package/dist/cjs/components/AutoPatternsGrid/AutoPatternsGrid.js +26 -15
  26. package/dist/cjs/components/AutoPatternsGrid/AutoPatternsGrid.js.map +1 -1
  27. package/dist/cjs/components/AutoPatternsTable/AutoPatternsTable.js +29 -15
  28. package/dist/cjs/components/AutoPatternsTable/AutoPatternsTable.js.map +1 -1
  29. package/dist/cjs/components/AutoPatternsTableGridSwitch/AutoPatternsTableGridSwitch.js +27 -0
  30. package/dist/cjs/components/AutoPatternsTableGridSwitch/AutoPatternsTableGridSwitch.js.map +1 -0
  31. package/dist/cjs/components/DynamicIcon.js +45 -9
  32. package/dist/cjs/components/DynamicIcon.js.map +1 -1
  33. package/dist/cjs/components/modals/actions/BulkDeleteModal.js +12 -10
  34. package/dist/cjs/components/modals/actions/BulkDeleteModal.js.map +1 -1
  35. package/dist/cjs/components/modals/actions/CreateModal.js +138 -0
  36. package/dist/cjs/components/modals/actions/CreateModal.js.map +1 -0
  37. package/dist/cjs/components/modals/actions/EditModal.js +17 -13
  38. package/dist/cjs/components/modals/actions/EditModal.js.map +1 -1
  39. package/dist/cjs/components/modals/actions/index.js +6 -0
  40. package/dist/cjs/components/modals/actions/index.js.map +1 -1
  41. package/dist/cjs/components/modals/actions/types.js.map +1 -1
  42. package/dist/cjs/dataSourceAdapters/cms/cmsAdapter.js +2 -1
  43. package/dist/cjs/dataSourceAdapters/cms/cmsAdapter.js.map +1 -1
  44. package/dist/cjs/hooks/index.js +6 -0
  45. package/dist/cjs/hooks/index.js.map +1 -1
  46. package/dist/cjs/hooks/useActionCell.js +5 -7
  47. package/dist/cjs/hooks/useActionCell.js.map +1 -1
  48. package/dist/cjs/hooks/useActionsSDK.js +34 -0
  49. package/dist/cjs/hooks/useActionsSDK.js.map +1 -0
  50. package/dist/cjs/hooks/useAutoPatternsOptimisticActions.js +11 -1
  51. package/dist/cjs/hooks/useAutoPatternsOptimisticActions.js.map +1 -1
  52. package/dist/cjs/hooks/useBaseGridFeatures.js +39 -0
  53. package/dist/cjs/hooks/useBaseGridFeatures.js.map +1 -0
  54. package/dist/cjs/hooks/{useSharedDataForActions.js → useBaseSDK.js} +7 -16
  55. package/dist/cjs/hooks/useBaseSDK.js.map +1 -0
  56. package/dist/cjs/hooks/useBaseTableFeatures.js +39 -0
  57. package/dist/cjs/hooks/useBaseTableFeatures.js.map +1 -0
  58. package/dist/cjs/hooks/useBulkActionToolbar.js +7 -9
  59. package/dist/cjs/hooks/useBulkActionToolbar.js.map +1 -1
  60. package/dist/cjs/hooks/useCollectionPageActions.js +126 -0
  61. package/dist/cjs/hooks/useCollectionPageActions.js.map +1 -0
  62. package/dist/cjs/hooks/useColumns.js +14 -3
  63. package/dist/cjs/hooks/useColumns.js.map +1 -1
  64. package/dist/cjs/hooks/useCommonCollectionFeatures.js +5 -8
  65. package/dist/cjs/hooks/useCommonCollectionFeatures.js.map +1 -1
  66. package/dist/cjs/hooks/useEntityPageHeaderTexts.js +27 -0
  67. package/dist/cjs/hooks/useEntityPageHeaderTexts.js.map +1 -0
  68. package/dist/cjs/hooks/useGridFeatures.js +7 -20
  69. package/dist/cjs/hooks/useGridFeatures.js.map +1 -1
  70. package/dist/cjs/hooks/useNavigationUtils.js +9 -5
  71. package/dist/cjs/hooks/useNavigationUtils.js.map +1 -1
  72. package/dist/cjs/hooks/usePagePath.js +1 -1
  73. package/dist/cjs/hooks/usePagePath.js.map +1 -1
  74. package/dist/cjs/hooks/useTableFeatures.js +10 -17
  75. package/dist/cjs/hooks/useTableFeatures.js.map +1 -1
  76. package/dist/cjs/hooks/useTableGridSwitchFeatures.js +81 -0
  77. package/dist/cjs/hooks/useTableGridSwitchFeatures.js.map +1 -0
  78. package/dist/cjs/providers/OptimisticActionsContext.js +43 -0
  79. package/dist/cjs/providers/OptimisticActionsContext.js.map +1 -0
  80. package/dist/cjs/providers/PatternsWizardOverridesContext.js +1 -1
  81. package/dist/cjs/providers/PatternsWizardOverridesContext.js.map +1 -1
  82. package/dist/cjs/providers/RootAppProvider.js +13 -5
  83. package/dist/cjs/providers/RootAppProvider.js.map +1 -1
  84. package/dist/cjs/types/BaseSDK.js +4 -0
  85. package/dist/cjs/types/BaseSDK.js.map +1 -0
  86. package/dist/cjs/types/CollectionPageConfig.js.map +1 -1
  87. package/dist/cjs/types/actions/base.js.map +1 -1
  88. package/dist/cjs/types/actions/bulkActions.js.map +1 -1
  89. package/dist/cjs/types/actions/collectionPageActions.js +4 -0
  90. package/dist/cjs/types/actions/collectionPageActions.js.map +1 -0
  91. package/dist/cjs/types/actions/index.js +6 -0
  92. package/dist/cjs/types/actions/index.js.map +1 -1
  93. package/dist/cjs/types/index.js +6 -0
  94. package/dist/cjs/types/index.js.map +1 -1
  95. package/dist/cjs/types/types.js.map +1 -1
  96. package/dist/cjs/types/wix-icons.d.js +2 -0
  97. package/dist/cjs/types/wix-icons.d.js.map +1 -0
  98. package/dist/cjs/utils/actions/bulkDeleteAction.js +3 -3
  99. package/dist/cjs/utils/actions/bulkDeleteAction.js.map +1 -1
  100. package/dist/cjs/utils/actions/createAction.js +38 -0
  101. package/dist/cjs/utils/actions/createAction.js.map +1 -0
  102. package/dist/cjs/utils/actions/customAction.js +4 -4
  103. package/dist/cjs/utils/actions/customAction.js.map +1 -1
  104. package/dist/cjs/utils/actions/customModalAction.js +3 -3
  105. package/dist/cjs/utils/actions/customModalAction.js.map +1 -1
  106. package/dist/cjs/utils/actions/deleteAction.js +7 -5
  107. package/dist/cjs/utils/actions/deleteAction.js.map +1 -1
  108. package/dist/cjs/utils/actions/index.js +6 -0
  109. package/dist/cjs/utils/actions/index.js.map +1 -1
  110. package/dist/cjs/utils/actions/types.js.map +1 -1
  111. package/dist/cjs/utils/actions/updateAction.js +4 -10
  112. package/dist/cjs/utils/actions/updateAction.js.map +1 -1
  113. package/dist/cjs/utils/generated-icon-imports.js +1438 -0
  114. package/dist/cjs/utils/generated-icon-imports.js.map +1 -0
  115. package/dist/cjs/utils/media/getImageUrl.js +3 -0
  116. package/dist/cjs/utils/media/getImageUrl.js.map +1 -1
  117. package/dist/esm/components/AutoPatternsApp/AutoPatternsApp.js.map +1 -1
  118. package/dist/esm/components/AutoPatternsCollectionPage/AutoPatternsCollectionPage.js +6 -5
  119. package/dist/esm/components/AutoPatternsCollectionPage/AutoPatternsCollectionPage.js.map +1 -1
  120. package/dist/esm/components/AutoPatternsCollectionPageContent/AutoPatternsCollectionPageContent.js +19 -2
  121. package/dist/esm/components/AutoPatternsCollectionPageContent/AutoPatternsCollectionPageContent.js.map +1 -1
  122. package/dist/esm/components/AutoPatternsEntityPage/AutoPatternsEntityPage.js +14 -7
  123. package/dist/esm/components/AutoPatternsEntityPage/AutoPatternsEntityPage.js.map +1 -1
  124. package/dist/esm/components/AutoPatternsEntityPage/Fields/DateInput.js +47 -25
  125. package/dist/esm/components/AutoPatternsEntityPage/Fields/DateInput.js.map +1 -1
  126. package/dist/esm/components/AutoPatternsEntityPage/Fields/DateTime.js +61 -25
  127. package/dist/esm/components/AutoPatternsEntityPage/Fields/DateTime.js.map +1 -1
  128. package/dist/esm/components/AutoPatternsEntityPage/Fields/FormFieldInput.js +6 -3
  129. package/dist/esm/components/AutoPatternsEntityPage/Fields/FormFieldInput.js.map +1 -1
  130. package/dist/esm/components/AutoPatternsEntityPage/Fields/ImageInput.js +66 -0
  131. package/dist/esm/components/AutoPatternsEntityPage/Fields/ImageInput.js.map +1 -0
  132. package/dist/esm/components/AutoPatternsEntityPage/Fields/LongText.js +33 -15
  133. package/dist/esm/components/AutoPatternsEntityPage/Fields/LongText.js.map +1 -1
  134. package/dist/esm/components/AutoPatternsEntityPage/Fields/Number.js +41 -35
  135. package/dist/esm/components/AutoPatternsEntityPage/Fields/Number.js.map +1 -1
  136. package/dist/esm/components/AutoPatternsEntityPage/Fields/ShortText.js +43 -25
  137. package/dist/esm/components/AutoPatternsEntityPage/Fields/ShortText.js.map +1 -1
  138. package/dist/esm/components/AutoPatternsEntityPage/Fields/Url.js +32 -34
  139. package/dist/esm/components/AutoPatternsEntityPage/Fields/Url.js.map +1 -1
  140. package/dist/esm/components/AutoPatternsGrid/AutoPatternsGrid.js +25 -8
  141. package/dist/esm/components/AutoPatternsGrid/AutoPatternsGrid.js.map +1 -1
  142. package/dist/esm/components/AutoPatternsTable/AutoPatternsTable.js +28 -8
  143. package/dist/esm/components/AutoPatternsTable/AutoPatternsTable.js.map +1 -1
  144. package/dist/esm/components/AutoPatternsTableGridSwitch/AutoPatternsTableGridSwitch.js +14 -0
  145. package/dist/esm/components/AutoPatternsTableGridSwitch/AutoPatternsTableGridSwitch.js.map +1 -0
  146. package/dist/esm/components/DynamicIcon.js +13 -4
  147. package/dist/esm/components/DynamicIcon.js.map +1 -1
  148. package/dist/esm/components/modals/actions/BulkDeleteModal.js +7 -5
  149. package/dist/esm/components/modals/actions/BulkDeleteModal.js.map +1 -1
  150. package/dist/esm/components/modals/actions/CreateModal.js +80 -0
  151. package/dist/esm/components/modals/actions/CreateModal.js.map +1 -0
  152. package/dist/esm/components/modals/actions/EditModal.js +9 -5
  153. package/dist/esm/components/modals/actions/EditModal.js.map +1 -1
  154. package/dist/esm/components/modals/actions/index.js +1 -0
  155. package/dist/esm/components/modals/actions/index.js.map +1 -1
  156. package/dist/esm/components/modals/actions/types.js.map +1 -1
  157. package/dist/esm/dataSourceAdapters/cms/cmsAdapter.js +2 -1
  158. package/dist/esm/dataSourceAdapters/cms/cmsAdapter.js.map +1 -1
  159. package/dist/esm/hooks/index.js +1 -0
  160. package/dist/esm/hooks/index.js.map +1 -1
  161. package/dist/esm/hooks/useActionCell.js +5 -7
  162. package/dist/esm/hooks/useActionCell.js.map +1 -1
  163. package/dist/esm/hooks/useActionsSDK.js +30 -0
  164. package/dist/esm/hooks/useActionsSDK.js.map +1 -0
  165. package/dist/esm/hooks/useAutoPatternsOptimisticActions.js +11 -1
  166. package/dist/esm/hooks/useAutoPatternsOptimisticActions.js.map +1 -1
  167. package/dist/esm/hooks/useBaseGridFeatures.js +34 -0
  168. package/dist/esm/hooks/useBaseGridFeatures.js.map +1 -0
  169. package/dist/esm/hooks/{useSharedDataForActions.js → useBaseSDK.js} +6 -16
  170. package/dist/esm/hooks/useBaseSDK.js.map +1 -0
  171. package/dist/esm/hooks/useBaseTableFeatures.js +24 -0
  172. package/dist/esm/hooks/useBaseTableFeatures.js.map +1 -0
  173. package/dist/esm/hooks/useBulkActionToolbar.js +6 -8
  174. package/dist/esm/hooks/useBulkActionToolbar.js.map +1 -1
  175. package/dist/esm/hooks/useCollectionPageActions.js +103 -0
  176. package/dist/esm/hooks/useCollectionPageActions.js.map +1 -0
  177. package/dist/esm/hooks/useColumns.js +9 -4
  178. package/dist/esm/hooks/useColumns.js.map +1 -1
  179. package/dist/esm/hooks/useCommonCollectionFeatures.js +1 -4
  180. package/dist/esm/hooks/useCommonCollectionFeatures.js.map +1 -1
  181. package/dist/esm/hooks/useEntityPageHeaderTexts.js +23 -0
  182. package/dist/esm/hooks/useEntityPageHeaderTexts.js.map +1 -0
  183. package/dist/esm/hooks/useGridFeatures.js +7 -20
  184. package/dist/esm/hooks/useGridFeatures.js.map +1 -1
  185. package/dist/esm/hooks/useNavigationUtils.js +10 -6
  186. package/dist/esm/hooks/useNavigationUtils.js.map +1 -1
  187. package/dist/esm/hooks/usePagePath.js +1 -1
  188. package/dist/esm/hooks/usePagePath.js.map +1 -1
  189. package/dist/esm/hooks/useTableFeatures.js +11 -8
  190. package/dist/esm/hooks/useTableFeatures.js.map +1 -1
  191. package/dist/esm/hooks/useTableGridSwitchFeatures.js +79 -0
  192. package/dist/esm/hooks/useTableGridSwitchFeatures.js.map +1 -0
  193. package/dist/esm/providers/OptimisticActionsContext.js +29 -0
  194. package/dist/esm/providers/OptimisticActionsContext.js.map +1 -0
  195. package/dist/esm/providers/PatternsWizardOverridesContext.js.map +1 -1
  196. package/dist/esm/providers/RootAppProvider.js +2 -1
  197. package/dist/esm/providers/RootAppProvider.js.map +1 -1
  198. package/dist/esm/types/BaseSDK.js +2 -0
  199. package/dist/esm/types/BaseSDK.js.map +1 -0
  200. package/dist/esm/types/CollectionPageConfig.js.map +1 -1
  201. package/dist/esm/types/actions/base.js.map +1 -1
  202. package/dist/esm/types/actions/bulkActions.js.map +1 -1
  203. package/dist/esm/types/actions/collectionPageActions.js +2 -0
  204. package/dist/esm/types/actions/collectionPageActions.js.map +1 -0
  205. package/dist/esm/types/actions/index.js +1 -0
  206. package/dist/esm/types/actions/index.js.map +1 -1
  207. package/dist/esm/types/index.js +1 -0
  208. package/dist/esm/types/index.js.map +1 -1
  209. package/dist/esm/types/types.js.map +1 -1
  210. package/dist/esm/types/wix-icons.d.js +2 -0
  211. package/dist/esm/types/wix-icons.d.js.map +1 -0
  212. package/dist/esm/utils/actions/bulkDeleteAction.js +3 -3
  213. package/dist/esm/utils/actions/bulkDeleteAction.js.map +1 -1
  214. package/dist/esm/utils/actions/createAction.js +33 -0
  215. package/dist/esm/utils/actions/createAction.js.map +1 -0
  216. package/dist/esm/utils/actions/customAction.js +4 -4
  217. package/dist/esm/utils/actions/customAction.js.map +1 -1
  218. package/dist/esm/utils/actions/customModalAction.js +3 -3
  219. package/dist/esm/utils/actions/customModalAction.js.map +1 -1
  220. package/dist/esm/utils/actions/deleteAction.js +7 -5
  221. package/dist/esm/utils/actions/deleteAction.js.map +1 -1
  222. package/dist/esm/utils/actions/index.js +1 -0
  223. package/dist/esm/utils/actions/index.js.map +1 -1
  224. package/dist/esm/utils/actions/types.js.map +1 -1
  225. package/dist/esm/utils/actions/updateAction.js +4 -10
  226. package/dist/esm/utils/actions/updateAction.js.map +1 -1
  227. package/dist/esm/utils/generated-icon-imports.js +1432 -0
  228. package/dist/esm/utils/generated-icon-imports.js.map +1 -0
  229. package/dist/esm/utils/media/getImageUrl.js +3 -0
  230. package/dist/esm/utils/media/getImageUrl.js.map +1 -1
  231. package/dist/types/components/AutoPatternsApp/AutoPatternsApp.d.ts +2 -2
  232. package/dist/types/components/AutoPatternsApp/AutoPatternsApp.d.ts.map +1 -1
  233. package/dist/types/components/AutoPatternsCollectionPage/AutoPatternsCollectionPage.d.ts.map +1 -1
  234. package/dist/types/components/AutoPatternsCollectionPageContent/AutoPatternsCollectionPageContent.d.ts.map +1 -1
  235. package/dist/types/components/AutoPatternsEntityPage/AutoPatternsEntityPage.d.ts.map +1 -1
  236. package/dist/types/components/AutoPatternsEntityPage/Fields/DateInput.d.ts.map +1 -1
  237. package/dist/types/components/AutoPatternsEntityPage/Fields/DateTime.d.ts.map +1 -1
  238. package/dist/types/components/AutoPatternsEntityPage/Fields/FormFieldInput.d.ts.map +1 -1
  239. package/dist/types/components/AutoPatternsEntityPage/Fields/ImageInput.d.ts +6 -0
  240. package/dist/types/components/AutoPatternsEntityPage/Fields/ImageInput.d.ts.map +1 -0
  241. package/dist/types/components/AutoPatternsEntityPage/Fields/LongText.d.ts.map +1 -1
  242. package/dist/types/components/AutoPatternsEntityPage/Fields/Number.d.ts.map +1 -1
  243. package/dist/types/components/AutoPatternsEntityPage/Fields/ShortText.d.ts.map +1 -1
  244. package/dist/types/components/AutoPatternsEntityPage/Fields/Url.d.ts.map +1 -1
  245. package/dist/types/components/AutoPatternsGrid/AutoPatternsGrid.d.ts +2 -2
  246. package/dist/types/components/AutoPatternsGrid/AutoPatternsGrid.d.ts.map +1 -1
  247. package/dist/types/components/AutoPatternsTable/AutoPatternsTable.d.ts +2 -2
  248. package/dist/types/components/AutoPatternsTable/AutoPatternsTable.d.ts.map +1 -1
  249. package/dist/types/components/AutoPatternsTableGridSwitch/AutoPatternsTableGridSwitch.d.ts +7 -0
  250. package/dist/types/components/AutoPatternsTableGridSwitch/AutoPatternsTableGridSwitch.d.ts.map +1 -0
  251. package/dist/types/components/DynamicIcon.d.ts.map +1 -1
  252. package/dist/types/components/modals/actions/BulkDeleteModal.d.ts +1 -1
  253. package/dist/types/components/modals/actions/BulkDeleteModal.d.ts.map +1 -1
  254. package/dist/types/components/modals/actions/CreateModal.d.ts +8 -0
  255. package/dist/types/components/modals/actions/CreateModal.d.ts.map +1 -0
  256. package/dist/types/components/modals/actions/EditModal.d.ts +1 -1
  257. package/dist/types/components/modals/actions/EditModal.d.ts.map +1 -1
  258. package/dist/types/components/modals/actions/index.d.ts +1 -0
  259. package/dist/types/components/modals/actions/index.d.ts.map +1 -1
  260. package/dist/types/components/modals/actions/types.d.ts +2 -2
  261. package/dist/types/components/modals/actions/types.d.ts.map +1 -1
  262. package/dist/types/dataSourceAdapters/cms/cmsAdapter.d.ts.map +1 -1
  263. package/dist/types/hooks/index.d.ts +1 -0
  264. package/dist/types/hooks/index.d.ts.map +1 -1
  265. package/dist/types/hooks/useActionCell.d.ts +1 -3
  266. package/dist/types/hooks/useActionCell.d.ts.map +1 -1
  267. package/dist/types/hooks/useActionsSDK.d.ts +6 -0
  268. package/dist/types/hooks/useActionsSDK.d.ts.map +1 -0
  269. package/dist/types/hooks/useAutoPatternsOptimisticActions.d.ts +1 -1
  270. package/dist/types/hooks/useAutoPatternsOptimisticActions.d.ts.map +1 -1
  271. package/dist/types/hooks/useBaseGridFeatures.d.ts +13 -0
  272. package/dist/types/hooks/useBaseGridFeatures.d.ts.map +1 -0
  273. package/dist/types/hooks/useBaseSDK.d.ts +3 -0
  274. package/dist/types/hooks/useBaseSDK.d.ts.map +1 -0
  275. package/dist/types/hooks/useBaseTableFeatures.d.ts +9 -0
  276. package/dist/types/hooks/useBaseTableFeatures.d.ts.map +1 -0
  277. package/dist/types/hooks/useBulkActionToolbar.d.ts +2 -3
  278. package/dist/types/hooks/useBulkActionToolbar.d.ts.map +1 -1
  279. package/dist/types/hooks/useCollectionPageActions.d.ts +10 -0
  280. package/dist/types/hooks/useCollectionPageActions.d.ts.map +1 -0
  281. package/dist/types/hooks/useColumns.d.ts.map +1 -1
  282. package/dist/types/hooks/useCommonCollectionFeatures.d.ts +1 -1
  283. package/dist/types/hooks/useCommonCollectionFeatures.d.ts.map +1 -1
  284. package/dist/types/hooks/useEntityPageHeaderTexts.d.ts +18 -0
  285. package/dist/types/hooks/useEntityPageHeaderTexts.d.ts.map +1 -0
  286. package/dist/types/hooks/useGridFeatures.d.ts +1 -0
  287. package/dist/types/hooks/useGridFeatures.d.ts.map +1 -1
  288. package/dist/types/hooks/useNavigationUtils.d.ts.map +1 -1
  289. package/dist/types/hooks/useTableFeatures.d.ts +6 -6
  290. package/dist/types/hooks/useTableFeatures.d.ts.map +1 -1
  291. package/dist/types/hooks/useTableGridSwitchFeatures.d.ts +23 -0
  292. package/dist/types/hooks/useTableGridSwitchFeatures.d.ts.map +1 -0
  293. package/dist/types/providers/OptimisticActionsContext.d.ts +12 -0
  294. package/dist/types/providers/OptimisticActionsContext.d.ts.map +1 -0
  295. package/dist/types/providers/PatternsWizardOverridesContext.d.ts +1 -3
  296. package/dist/types/providers/PatternsWizardOverridesContext.d.ts.map +1 -1
  297. package/dist/types/providers/RootAppProvider.d.ts.map +1 -1
  298. package/dist/types/types/BaseSDK.d.ts +12 -0
  299. package/dist/types/types/BaseSDK.d.ts.map +1 -0
  300. package/dist/types/types/CollectionPageConfig.d.ts +9 -2
  301. package/dist/types/types/CollectionPageConfig.d.ts.map +1 -1
  302. package/dist/types/types/actions/base.d.ts +15 -6
  303. package/dist/types/types/actions/base.d.ts.map +1 -1
  304. package/dist/types/types/actions/bulkActions.d.ts +1 -1
  305. package/dist/types/types/actions/bulkActions.d.ts.map +1 -1
  306. package/dist/types/types/actions/collectionPageActions.d.ts +38 -0
  307. package/dist/types/types/actions/collectionPageActions.d.ts.map +1 -0
  308. package/dist/types/types/actions/index.d.ts +1 -0
  309. package/dist/types/types/actions/index.d.ts.map +1 -1
  310. package/dist/types/types/index.d.ts +1 -0
  311. package/dist/types/types/index.d.ts.map +1 -1
  312. package/dist/types/types/types.d.ts +1 -4
  313. package/dist/types/types/types.d.ts.map +1 -1
  314. package/dist/types/utils/actions/createAction.d.ts +7 -0
  315. package/dist/types/utils/actions/createAction.d.ts.map +1 -0
  316. package/dist/types/utils/actions/deleteAction.d.ts.map +1 -1
  317. package/dist/types/utils/actions/index.d.ts +1 -0
  318. package/dist/types/utils/actions/index.d.ts.map +1 -1
  319. package/dist/types/utils/actions/types.d.ts +9 -13
  320. package/dist/types/utils/actions/types.d.ts.map +1 -1
  321. package/dist/types/utils/actions/updateAction.d.ts.map +1 -1
  322. package/dist/types/utils/generated-icon-imports.d.ts +4 -0
  323. package/dist/types/utils/generated-icon-imports.d.ts.map +1 -0
  324. package/dist/types/utils/media/getImageUrl.d.ts +1 -1
  325. package/dist/types/utils/media/getImageUrl.d.ts.map +1 -1
  326. package/package.json +9 -5
  327. package/dist/cjs/components/AutoPatternsEntityPage/Fields/utils/validateTextLength.js +0 -39
  328. package/dist/cjs/components/AutoPatternsEntityPage/Fields/utils/validateTextLength.js.map +0 -1
  329. package/dist/cjs/components/AutoPatternsGrid/AutoPatternsGridContent.js +0 -44
  330. package/dist/cjs/components/AutoPatternsGrid/AutoPatternsGridContent.js.map +0 -1
  331. package/dist/cjs/components/AutoPatternsTable/AutoPatternsTableContent.js +0 -54
  332. package/dist/cjs/components/AutoPatternsTable/AutoPatternsTableContent.js.map +0 -1
  333. package/dist/cjs/hooks/useSharedDataForActions.js.map +0 -1
  334. package/dist/esm/components/AutoPatternsEntityPage/Fields/utils/validateTextLength.js +0 -35
  335. package/dist/esm/components/AutoPatternsEntityPage/Fields/utils/validateTextLength.js.map +0 -1
  336. package/dist/esm/components/AutoPatternsGrid/AutoPatternsGridContent.js +0 -32
  337. package/dist/esm/components/AutoPatternsGrid/AutoPatternsGridContent.js.map +0 -1
  338. package/dist/esm/components/AutoPatternsTable/AutoPatternsTableContent.js +0 -42
  339. package/dist/esm/components/AutoPatternsTable/AutoPatternsTableContent.js.map +0 -1
  340. package/dist/esm/hooks/useSharedDataForActions.js.map +0 -1
  341. package/dist/types/components/AutoPatternsEntityPage/Fields/utils/validateTextLength.d.ts +0 -12
  342. package/dist/types/components/AutoPatternsEntityPage/Fields/utils/validateTextLength.d.ts.map +0 -1
  343. package/dist/types/components/AutoPatternsGrid/AutoPatternsGridContent.d.ts +0 -7
  344. package/dist/types/components/AutoPatternsGrid/AutoPatternsGridContent.d.ts.map +0 -1
  345. package/dist/types/components/AutoPatternsTable/AutoPatternsTableContent.d.ts +0 -7
  346. package/dist/types/components/AutoPatternsTable/AutoPatternsTableContent.d.ts.map +0 -1
  347. package/dist/types/hooks/useSharedDataForActions.d.ts +0 -8
  348. package/dist/types/hooks/useSharedDataForActions.d.ts.map +0 -1
@@ -5,6 +5,9 @@ exports.getImageUrl = void 0;
5
5
  exports.isAbsoluteUrl = isAbsoluteUrl;
6
6
  var _sdk = require("@wix/sdk");
7
7
  const getImageUrl = image => {
8
+ if (!image) {
9
+ return undefined;
10
+ }
8
11
  if (isAbsoluteUrl(image)) {
9
12
  return image;
10
13
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_sdk","require","getImageUrl","image","isAbsoluteUrl","media","url","exports","parsed","URL","protocol","host"],"sources":["../../../../src/utils/media/getImageUrl.ts"],"sourcesContent":["import { media } from '@wix/sdk';\n\nexport const getImageUrl = (image: string) => {\n if (isAbsoluteUrl(image)) {\n return image;\n }\n\n return media.getImageUrl(image).url;\n};\n\nexport function isAbsoluteUrl(url: string): boolean {\n try {\n const parsed = new URL(url);\n return !!parsed.protocol && !!parsed.host;\n } catch {\n return false;\n }\n}\n"],"mappings":";;;;;AAAA,IAAAA,IAAA,GAAAC,OAAA;AAEO,MAAMC,WAAW,GAAIC,KAAa,IAAK;EAC5C,IAAIC,aAAa,CAACD,KAAK,CAAC,EAAE;IACxB,OAAOA,KAAK;EACd;EAEA,OAAOE,UAAK,CAACH,WAAW,CAACC,KAAK,CAAC,CAACG,GAAG;AACrC,CAAC;AAACC,OAAA,CAAAL,WAAA,GAAAA,WAAA;AAEK,SAASE,aAAaA,CAACE,GAAW,EAAW;EAClD,IAAI;IACF,MAAME,MAAM,GAAG,IAAIC,GAAG,CAACH,GAAG,CAAC;IAC3B,OAAO,CAAC,CAACE,MAAM,CAACE,QAAQ,IAAI,CAAC,CAACF,MAAM,CAACG,IAAI;EAC3C,CAAC,CAAC,MAAM;IACN,OAAO,KAAK;EACd;AACF","ignoreList":[]}
1
+ {"version":3,"names":["_sdk","require","getImageUrl","image","undefined","isAbsoluteUrl","media","url","exports","parsed","URL","protocol","host"],"sources":["../../../../src/utils/media/getImageUrl.ts"],"sourcesContent":["import { media } from '@wix/sdk';\n\nexport const getImageUrl = (image: string | undefined | null) => {\n if (!image) {\n return undefined;\n }\n\n if (isAbsoluteUrl(image)) {\n return image;\n }\n\n return media.getImageUrl(image).url;\n};\n\nexport function isAbsoluteUrl(url: string): boolean {\n try {\n const parsed = new URL(url);\n return !!parsed.protocol && !!parsed.host;\n } catch {\n return false;\n }\n}\n"],"mappings":";;;;;AAAA,IAAAA,IAAA,GAAAC,OAAA;AAEO,MAAMC,WAAW,GAAIC,KAAgC,IAAK;EAC/D,IAAI,CAACA,KAAK,EAAE;IACV,OAAOC,SAAS;EAClB;EAEA,IAAIC,aAAa,CAACF,KAAK,CAAC,EAAE;IACxB,OAAOA,KAAK;EACd;EAEA,OAAOG,UAAK,CAACJ,WAAW,CAACC,KAAK,CAAC,CAACI,GAAG;AACrC,CAAC;AAACC,OAAA,CAAAN,WAAA,GAAAA,WAAA;AAEK,SAASG,aAAaA,CAACE,GAAW,EAAW;EAClD,IAAI;IACF,MAAME,MAAM,GAAG,IAAIC,GAAG,CAACH,GAAG,CAAC;IAC3B,OAAO,CAAC,CAACE,MAAM,CAACE,QAAQ,IAAI,CAAC,CAACF,MAAM,CAACG,IAAI;EAC3C,CAAC,CAAC,MAAM;IACN,OAAO,KAAK;EACd;AACF","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["React","RootAppProvider","AutoPatternsRoutes","AutoPatternsApp","_ref","configuration","createElement","appConfig","config"],"sources":["../../../../src/components/AutoPatternsApp/AutoPatternsApp.tsx"],"sourcesContent":["import React from 'react';\nimport { AppConfig } from '../../types';\nimport { RootAppProvider } from '../../providers/RootAppProvider';\nimport { AutoPatternsRoutes } from '../AutoPatternsRoute/AutoPatternsRoutes';\n\nexport interface AutoPatternsAppPageProps {\n configuration: AppConfig;\n}\n\nexport const AutoPatternsApp: React.FC<AutoPatternsAppPageProps> = ({\n configuration,\n}) => {\n return (\n <RootAppProvider appConfig={configuration}>\n <AutoPatternsRoutes config={configuration} />\n </RootAppProvider>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AAEzB,SAASC,eAAe,QAAQ,iCAAiC;AACjE,SAASC,kBAAkB,QAAQ,yCAAyC;AAM5E,OAAO,MAAMC,eAAmD,GAAGC,IAAA,IAE7D;EAAA,IAF8D;IAClEC;EACF,CAAC,GAAAD,IAAA;EACC,oBACEJ,KAAA,CAAAM,aAAA,CAACL,eAAe;IAACM,SAAS,EAAEF;EAAc,gBACxCL,KAAA,CAAAM,aAAA,CAACJ,kBAAkB;IAACM,MAAM,EAAEH;EAAc,CAAE,CAC7B,CAAC;AAEtB,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["React","RootAppProvider","AutoPatternsRoutes","AutoPatternsApp","_ref","configuration","createElement","appConfig","config"],"sources":["../../../../src/components/AutoPatternsApp/AutoPatternsApp.tsx"],"sourcesContent":["import React from 'react';\nimport { AppConfig } from '../../types';\nimport { RootAppProvider } from '../../providers/RootAppProvider';\nimport { AutoPatternsRoutes } from '../AutoPatternsRoute/AutoPatternsRoutes';\n\nexport interface AutoPatternsAppProps {\n configuration: AppConfig;\n}\n\nexport const AutoPatternsApp: React.FC<AutoPatternsAppProps> = ({\n configuration,\n}) => {\n return (\n <RootAppProvider appConfig={configuration}>\n <AutoPatternsRoutes config={configuration} />\n </RootAppProvider>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AAEzB,SAASC,eAAe,QAAQ,iCAAiC;AACjE,SAASC,kBAAkB,QAAQ,yCAAyC;AAM5E,OAAO,MAAMC,eAA+C,GAAGC,IAAA,IAEzD;EAAA,IAF0D;IAC9DC;EACF,CAAC,GAAAD,IAAA;EACC,oBACEJ,KAAA,CAAAM,aAAA,CAACL,eAAe;IAACM,SAAS,EAAEF;EAAc,gBACxCL,KAAA,CAAAM,aAAA,CAACJ,kBAAkB;IAACM,MAAM,EAAEH;EAAc,CAAE,CAC7B,CAAC;AAEtB,CAAC","ignoreList":[]}
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import { CollectionPage } from '@wix/patterns/page';
3
3
  import { AutoPatternsCollectionPageContent } from '../AutoPatternsCollectionPageContent';
4
4
  import { usePatternsWizardOverridesContext } from '../../providers';
5
- import { PrimaryActions, SecondaryActions } from '@wix/patterns';
5
+ import { useCollectionPageActions } from '../../hooks/useCollectionPageActions';
6
6
  export const AutoPatternsCollectionPage = _ref => {
7
7
  let {
8
8
  configuration
@@ -11,17 +11,18 @@ export const AutoPatternsCollectionPage = _ref => {
11
11
  title,
12
12
  subtitle
13
13
  } = configuration;
14
+ const actions = useCollectionPageActions({
15
+ collectionPageActions: configuration.actions
16
+ });
14
17
  const context = usePatternsWizardOverridesContext();
15
- const primaryActionProps = context == null || context.usePagePrimaryAction == null ? void 0 : context.usePagePrimaryAction();
16
- const secondaryActionProps = context == null || context.usePageSecondaryAction == null ? void 0 : context.usePageSecondaryAction();
17
18
  return /*#__PURE__*/React.createElement(CollectionPage, {
18
19
  height: "100vh",
19
20
  dataHook: "auto-patterns-page"
20
21
  }, /*#__PURE__*/React.createElement(CollectionPage.Header, {
21
22
  title: title,
22
23
  subtitle: subtitle,
23
- primaryAction: primaryActionProps ? /*#__PURE__*/React.createElement(PrimaryActions, primaryActionProps) : undefined,
24
- secondaryActions: secondaryActionProps ? /*#__PURE__*/React.createElement(SecondaryActions, secondaryActionProps) : undefined
24
+ primaryAction: actions.primaryActions,
25
+ secondaryActions: actions.secondaryActions
25
26
  }), /*#__PURE__*/React.createElement(CollectionPage.Content, null, context != null && context.HeaderAddon ? /*#__PURE__*/React.createElement(context.HeaderAddon, null) : null, /*#__PURE__*/React.createElement(AutoPatternsCollectionPageContent, {
26
27
  configuration: configuration
27
28
  })));
@@ -1 +1 @@
1
- {"version":3,"names":["React","CollectionPage","AutoPatternsCollectionPageContent","usePatternsWizardOverridesContext","PrimaryActions","SecondaryActions","AutoPatternsCollectionPage","_ref","configuration","title","subtitle","context","primaryActionProps","usePagePrimaryAction","secondaryActionProps","usePageSecondaryAction","createElement","height","dataHook","Header","primaryAction","undefined","secondaryActions","Content","HeaderAddon"],"sources":["../../../../src/components/AutoPatternsCollectionPage/AutoPatternsCollectionPage.tsx"],"sourcesContent":["import React from 'react';\nimport { CollectionPage } from '@wix/patterns/page';\nimport { AutoPatternsCollectionPageContent } from '../AutoPatternsCollectionPageContent';\nimport { usePatternsWizardOverridesContext } from '../../providers';\nimport { PrimaryActions, SecondaryActions } from '@wix/patterns';\nimport { CollectionPageConfig } from '../../types/CollectionPageConfig';\n\nexport interface AutoPatternsCollectionPageProps {\n configuration: CollectionPageConfig;\n}\n\nexport const AutoPatternsCollectionPage: React.FC<\n AutoPatternsCollectionPageProps\n> = ({ configuration }) => {\n const { title, subtitle } = configuration;\n const context = usePatternsWizardOverridesContext();\n const primaryActionProps = context?.usePagePrimaryAction?.();\n const secondaryActionProps = context?.usePageSecondaryAction?.();\n\n return (\n <CollectionPage height=\"100vh\" dataHook=\"auto-patterns-page\">\n <CollectionPage.Header\n title={title}\n subtitle={subtitle}\n primaryAction={\n primaryActionProps ? (\n <PrimaryActions {...primaryActionProps} />\n ) : undefined\n }\n secondaryActions={\n secondaryActionProps ? (\n <SecondaryActions {...secondaryActionProps} />\n ) : undefined\n }\n />\n <CollectionPage.Content>\n {context?.HeaderAddon ? <context.HeaderAddon /> : null}\n <AutoPatternsCollectionPageContent configuration={configuration} />\n </CollectionPage.Content>\n </CollectionPage>\n );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A,CAAAgB,aAAA,CAACd,iCAAiC;IAACM,aAAa,EAAEA;EAAc,CAAE,CAC5C,CACV,CAAC;AAErB,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["React","CollectionPage","AutoPatternsCollectionPageContent","usePatternsWizardOverridesContext","useCollectionPageActions","AutoPatternsCollectionPage","_ref","configuration","title","subtitle","actions","collectionPageActions","context","createElement","height","dataHook","Header","primaryAction","primaryActions","secondaryActions","Content","HeaderAddon"],"sources":["../../../../src/components/AutoPatternsCollectionPage/AutoPatternsCollectionPage.tsx"],"sourcesContent":["import React from 'react';\nimport { CollectionPage } from '@wix/patterns/page';\nimport { AutoPatternsCollectionPageContent } from '../AutoPatternsCollectionPageContent';\nimport { usePatternsWizardOverridesContext } from '../../providers';\nimport { CollectionPageConfig } from '../../types/CollectionPageConfig';\nimport { useCollectionPageActions } from '../../hooks/useCollectionPageActions';\n\nexport interface AutoPatternsCollectionPageProps {\n configuration: CollectionPageConfig;\n}\n\nexport const AutoPatternsCollectionPage: React.FC<\n AutoPatternsCollectionPageProps\n> = ({ configuration }) => {\n const { title, subtitle } = configuration;\n\n const actions = useCollectionPageActions({\n collectionPageActions: configuration.actions,\n });\n\n const context = usePatternsWizardOverridesContext();\n\n return (\n <CollectionPage height=\"100vh\" dataHook=\"auto-patterns-page\">\n <CollectionPage.Header\n title={title}\n subtitle={subtitle}\n primaryAction={actions.primaryActions}\n secondaryActions={actions.secondaryActions}\n />\n <CollectionPage.Content>\n {context?.HeaderAddon ? <context.HeaderAddon /> : null}\n <AutoPatternsCollectionPageContent configuration={configuration} />\n </CollectionPage.Content>\n </CollectionPage>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,cAAc,QAAQ,oBAAoB;AACnD,SAASC,iCAAiC,QAAQ,sCAAsC;AACxF,SAASC,iCAAiC,QAAQ,iBAAiB;AAEnE,SAASC,wBAAwB,QAAQ,sCAAsC;AAM/E,OAAO,MAAMC,0BAEZ,GAAGC,IAAA,IAAuB;EAAA,IAAtB;IAAEC;EAAc,CAAC,GAAAD,IAAA;EACpB,MAAM;IAAEE,KAAK;IAAEC;EAAS,CAAC,GAAGF,aAAa;EAEzC,MAAMG,OAAO,GAAGN,wBAAwB,CAAC;IACvCO,qBAAqB,EAAEJ,aAAa,CAACG;EACvC,CAAC,CAAC;EAEF,MAAME,OAAO,GAAGT,iCAAiC,CAAC,CAAC;EAEnD,oBACEH,KAAA,CAAAa,aAAA,CAACZ,cAAc;IAACa,MAAM,EAAC,OAAO;IAACC,QAAQ,EAAC;EAAoB,gBAC1Df,KAAA,CAAAa,aAAA,CAACZ,cAAc,CAACe,MAAM;IACpBR,KAAK,EAAEA,KAAM;IACbC,QAAQ,EAAEA,QAAS;IACnBQ,aAAa,EAAEP,OAAO,CAACQ,cAAe;IACtCC,gBAAgB,EAAET,OAAO,CAACS;EAAiB,CAC5C,CAAC,eACFnB,KAAA,CAAAa,aAAA,CAACZ,cAAc,CAACmB,OAAO,QACpBR,OAAO,YAAPA,OAAO,CAAES,WAAW,gBAAGrB,KAAA,CAAAa,aAAA,CAACD,OAAO,CAACS,WAAW,MAAE,CAAC,GAAG,IAAI,eACtDrB,KAAA,CAAAa,aAAA,CAACX,iCAAiC;IAACK,aAAa,EAAEA;EAAc,CAAE,CAC5C,CACV,CAAC;AAErB,CAAC","ignoreList":[]}
@@ -1,6 +1,8 @@
1
1
  import React from 'react';
2
2
  import { AutoPatternsTable } from '../AutoPatternsTable';
3
3
  import { AutoPatternsGrid } from '../AutoPatternsGrid';
4
+ import { AutoPatternsTableGridSwitch } from '../AutoPatternsTableGridSwitch/AutoPatternsTableGridSwitch';
5
+ import { SchemaProvider } from '../../providers';
4
6
  export const AutoPatternsCollectionPageContent = _ref => {
5
7
  let {
6
8
  configuration
@@ -16,7 +18,6 @@ export const AutoPatternsCollectionPageContent = _ref => {
16
18
  case 'Table':
17
19
  if (component.table) {
18
20
  return /*#__PURE__*/React.createElement(AutoPatternsTable, {
19
- key: component.table.collection.collectionId,
20
21
  configuration: component.table
21
22
  });
22
23
  }
@@ -24,14 +25,30 @@ export const AutoPatternsCollectionPageContent = _ref => {
24
25
  case 'Grid':
25
26
  if (component.grid) {
26
27
  return /*#__PURE__*/React.createElement(AutoPatternsGrid, {
27
- key: component.grid.collection.collectionId,
28
28
  configuration: component.grid
29
29
  });
30
30
  }
31
31
  return null;
32
+ case 'TableGridSwitch':
33
+ if (component.tableGridSwitch) {
34
+ return /*#__PURE__*/React.createElement(AutoPatternsTableGridSwitch, {
35
+ configuration: component.tableGridSwitch
36
+ });
37
+ }
38
+ return null;
32
39
  default:
33
40
  return null;
34
41
  }
42
+ }).map(element => {
43
+ if (element == null) {
44
+ return null;
45
+ }
46
+ const configuration = element.props.configuration;
47
+ return /*#__PURE__*/React.createElement(SchemaProvider, {
48
+ key: configuration.collection.collectionId,
49
+ collectionId: configuration.collection.collectionId,
50
+ entityTypeSource: configuration.collection.entityTypeSource
51
+ }, element);
35
52
  }));
36
53
  };
37
54
  //# sourceMappingURL=AutoPatternsCollectionPageContent.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["React","AutoPatternsTable","AutoPatternsGrid","AutoPatternsCollectionPageContent","_ref","configuration","components","createElement","Fragment","map","component","type","table","key","collection","collectionId","grid"],"sources":["../../../../src/components/AutoPatternsCollectionPageContent/AutoPatternsCollectionPageContent.tsx"],"sourcesContent":["import React from 'react';\nimport { AutoPatternsTable } from '../AutoPatternsTable';\nimport { CollectionPageConfig } from '../../types';\nimport { AutoPatternsGrid } from '../AutoPatternsGrid';\n\nexport interface AutoPatternsCollectionPageContentProps {\n configuration: CollectionPageConfig;\n}\n\nexport const AutoPatternsCollectionPageContent = ({\n configuration,\n}: AutoPatternsCollectionPageContentProps) => {\n const { components } = configuration;\n return (\n <>\n {components.map((component) => {\n const { type } = component;\n switch (type) {\n case 'Table':\n if (component.table) {\n return (\n <AutoPatternsTable\n key={component.table.collection.collectionId}\n configuration={component.table}\n />\n );\n }\n return null;\n case 'Grid':\n if (component.grid) {\n return (\n <AutoPatternsGrid\n key={component.grid.collection.collectionId}\n configuration={component.grid}\n />\n );\n }\n return null;\n default:\n return null;\n }\n })}\n </>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,iBAAiB,QAAQ,sBAAsB;AAExD,SAASC,gBAAgB,QAAQ,qBAAqB;AAMtD,OAAO,MAAMC,iCAAiC,GAAGC,IAAA,IAEH;EAAA,IAFI;IAChDC;EACsC,CAAC,GAAAD,IAAA;EACvC,MAAM;IAAEE;EAAW,CAAC,GAAGD,aAAa;EACpC,oBACEL,KAAA,CAAAO,aAAA,CAAAP,KAAA,CAAAQ,QAAA,QACGF,UAAU,CAACG,GAAG,CAAEC,SAAS,IAAK;IAC7B,MAAM;MAAEC;IAAK,CAAC,GAAGD,SAAS;IAC1B,QAAQC,IAAI;MACV,KAAK,OAAO;QACV,IAAID,SAAS,CAACE,KAAK,EAAE;UACnB,oBACEZ,KAAA,CAAAO,aAAA,CAACN,iBAAiB;YAChBY,GAAG,EAAEH,SAAS,CAACE,KAAK,CAACE,UAAU,CAACC,YAAa;YAC7CV,aAAa,EAAEK,SAAS,CAACE;UAAM,CAChC,CAAC;QAEN;QACA,OAAO,IAAI;MACb,KAAK,MAAM;QACT,IAAIF,SAAS,CAACM,IAAI,EAAE;UAClB,oBACEhB,KAAA,CAAAO,aAAA,CAACL,gBAAgB;YACfW,GAAG,EAAEH,SAAS,CAACM,IAAI,CAACF,UAAU,CAACC,YAAa;YAC5CV,aAAa,EAAEK,SAAS,CAACM;UAAK,CAC/B,CAAC;QAEN;QACA,OAAO,IAAI;MACb;QACE,OAAO,IAAI;IACf;EACF,CAAC,CACD,CAAC;AAEP,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["React","AutoPatternsTable","AutoPatternsGrid","AutoPatternsTableGridSwitch","SchemaProvider","AutoPatternsCollectionPageContent","_ref","configuration","components","createElement","Fragment","map","component","type","table","grid","tableGridSwitch","element","props","key","collection","collectionId","entityTypeSource"],"sources":["../../../../src/components/AutoPatternsCollectionPageContent/AutoPatternsCollectionPageContent.tsx"],"sourcesContent":["import React, { ReactElement } from 'react';\nimport { AutoPatternsTable } from '../AutoPatternsTable';\nimport {\n BaseCollectionComponentConfig,\n CollectionPageConfig,\n} from '../../types';\nimport { AutoPatternsGrid } from '../AutoPatternsGrid';\nimport { AutoPatternsTableGridSwitch } from '../AutoPatternsTableGridSwitch/AutoPatternsTableGridSwitch';\nimport { SchemaProvider } from '../../providers';\n\nexport interface AutoPatternsCollectionPageContentProps {\n configuration: CollectionPageConfig;\n}\n\nexport const AutoPatternsCollectionPageContent = ({\n configuration,\n}: AutoPatternsCollectionPageContentProps) => {\n const { components } = configuration;\n return (\n <>\n {components\n .map(\n (\n component,\n ): ReactElement<{\n configuration: BaseCollectionComponentConfig;\n }> | null => {\n const { type } = component;\n switch (type) {\n case 'Table':\n if (component.table) {\n return <AutoPatternsTable configuration={component.table} />;\n }\n return null;\n case 'Grid':\n if (component.grid) {\n return <AutoPatternsGrid configuration={component.grid} />;\n }\n return null;\n case 'TableGridSwitch':\n if (component.tableGridSwitch) {\n return (\n <AutoPatternsTableGridSwitch\n configuration={component.tableGridSwitch}\n />\n );\n }\n return null;\n default:\n return null;\n }\n },\n )\n .map((element) => {\n if (element == null) {\n return null;\n }\n\n const configuration = element.props.configuration;\n\n return (\n <SchemaProvider\n key={configuration.collection.collectionId}\n collectionId={configuration.collection.collectionId}\n entityTypeSource={configuration.collection.entityTypeSource}\n >\n {element}\n </SchemaProvider>\n );\n })}\n </>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,MAAwB,OAAO;AAC3C,SAASC,iBAAiB,QAAQ,sBAAsB;AAKxD,SAASC,gBAAgB,QAAQ,qBAAqB;AACtD,SAASC,2BAA2B,QAAQ,4DAA4D;AACxG,SAASC,cAAc,QAAQ,iBAAiB;AAMhD,OAAO,MAAMC,iCAAiC,GAAGC,IAAA,IAEH;EAAA,IAF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}
@@ -5,7 +5,7 @@ import { Card, Cell, Layout } from '@wix/design-system';
5
5
  import { useParams } from 'react-router-dom';
6
6
  import { useSchema } from '../../providers/SchemaContext';
7
7
  import { FormFieldInput } from './Fields/FormFieldInput';
8
- import { useNavigation } from '../../hooks';
8
+ import { useEntityPageHeaderTexts, useNavigation } from '../../hooks';
9
9
  import { usePatternsWizardOverridesContext } from '../../providers';
10
10
  const RenderLayoutContent = _ref => {
11
11
  var _content$container$ch, _overrides$components;
@@ -103,16 +103,17 @@ export const AutoPatternsEntityPage = _ref3 => {
103
103
  configuration
104
104
  } = _ref3;
105
105
  const {
106
- title,
107
- subtitle,
108
106
  layout: pageLayout,
109
107
  parentPageId,
110
108
  route
111
109
  } = configuration;
112
- const form = useForm();
110
+ const form = useForm({
111
+ mode: 'onChange'
112
+ });
113
113
  const params = useParams();
114
114
  const entityId = params[route.params.id];
115
115
  const schema = useSchema();
116
+ const isCreateMode = !entityId;
116
117
  const inputRefs = useRef({});
117
118
  const setInputRef = (id, input) => {
118
119
  inputRefs.current[id] = input;
@@ -161,13 +162,19 @@ export const AutoPatternsEntityPage = _ref3 => {
161
162
  }
162
163
  });
163
164
  const entity = useEntity(state);
165
+ const {
166
+ title,
167
+ subtitle
168
+ } = useEntityPageHeaderTexts({
169
+ config: configuration,
170
+ isCreateMode,
171
+ entityDisplayName: entity == null ? void 0 : entity[schema.displayField]
172
+ });
164
173
  return /*#__PURE__*/React.createElement(EntityPage, {
165
174
  state: state,
166
175
  dataHook: "auto-patterns-entity-page"
167
176
  }, /*#__PURE__*/React.createElement(EntityPage.Header, {
168
- title: title ?? {
169
- text: (entity == null ? void 0 : entity[schema.displayField]) ?? 'Edit Entity'
170
- },
177
+ title: title,
171
178
  subtitle: subtitle
172
179
  }), /*#__PURE__*/React.createElement(EntityPage.Content, null, /*#__PURE__*/React.createElement(EntityPage.MainContent, null, pageLayout == null || (_pageLayout$main = pageLayout.main) == null ? void 0 : _pageLayout$main.map((layout, layoutIndex) => /*#__PURE__*/React.createElement(RenderLayoutCard, {
173
180
  key: `main-section-card-${layoutIndex}`,
@@ -1 +1 @@
1
- {"version":3,"names":["React","useMemo","useRef","EntityPage","useEntity","useEntityPage","useEntityPageContext","useForm","Card","Cell","Layout","useParams","useSchema","FormFieldInput","useNavigation","usePatternsWizardOverridesContext","RenderLayoutContent","_ref","_content$container$ch","_overrides$components","content","level","sectionId","cardIndex","contentIndex","setInputRef","schema","overrides","pageState","type","field","fieldId","fields","createElement","span","key","inputRef","ref","container","children","length","map","child","index","component","componentId","Component","components","form","entity","RenderLayoutCard","_ref2","_layout$card$subtitle","layout","minHeight","Header","title","card","text","subtitle","Divider","Content","AutoPatternsEntityPage","_ref3","_pageLayout$main","_pageLayout$sidebar","configuration","pageLayout","parentPageId","route","params","entityId","id","inputRefs","input","current","validate","invalidFieldId","Object","keys","find","_inputRefs$current$fi","invalid","_inputRefs$current$in","focus","Error","getParentPagePath","parentPath","state","onSave","formValues","getValues","baseEntity","updatedEntity","newEntity","actions","update","create","fetch","undefined","get","dataHook","displayField","MainContent","main","layoutIndex","sidebar","AdditionalContent"],"sources":["../../../../src/components/AutoPatternsEntityPage/AutoPatternsEntityPage.tsx"],"sourcesContent":["import React, { useMemo, useRef } from 'react';\nimport { CardLayout, EntityPageConfig, LayoutContent } from '../../types';\nimport {\n EntityPage,\n EntityPageState,\n useEntity,\n useEntityPage,\n useEntityPageContext,\n} from '@wix/patterns';\nimport { useForm } from '@wix/patterns/form';\nimport { Card, Cell, Layout } from '@wix/design-system';\nimport { useParams } from 'react-router-dom';\nimport { useSchema } from '../../providers/SchemaContext';\nimport { BaseInputRef } from './Fields/types';\nimport { FormFieldInput } from './Fields/FormFieldInput';\nimport { useNavigation } from '../../hooks';\nimport { usePatternsWizardOverridesContext } from '../../providers';\n\nconst RenderLayoutContent: React.FC<{\n content: LayoutContent;\n level: number;\n sectionId: string;\n cardIndex: number;\n contentIndex: number;\n setInputRef: (id: string, input: BaseInputRef) => void;\n}> = ({ content, level, sectionId, cardIndex, contentIndex, setInputRef }) => {\n const schema = useSchema();\n const overrides = usePatternsWizardOverridesContext();\n const pageState = useEntityPageContext();\n\n switch (content.type) {\n case 'field':\n if (!content.field.fieldId) {\n return null;\n }\n\n const field = schema.fields[content.field.fieldId];\n\n if (!field) {\n return null;\n }\n\n return (\n <Cell span={content.field.span}>\n <FormFieldInput\n key={content.field.fieldId}\n field={field}\n inputRef={(ref) => setInputRef(content.field.fieldId, ref)}\n />\n </Cell>\n );\n\n case 'container':\n if (!content.container.children?.length) {\n return null;\n }\n\n return (\n <Cell span={content.container.span}>\n <Layout>\n {content.container.children.map((child, index) => (\n <RenderLayoutContent\n key={`${sectionId}-card-${cardIndex}-content-${contentIndex}-level-${level}-child-${index}`}\n content={child}\n level={level + 1}\n sectionId={sectionId}\n cardIndex={cardIndex}\n contentIndex={index}\n setInputRef={setInputRef}\n />\n ))}\n </Layout>\n </Cell>\n );\n\n case 'component':\n if (!content.component.componentId) {\n return null;\n }\n\n const Component = overrides?.components?.[content.component.componentId];\n\n if (!Component) {\n return null;\n }\n\n return (\n <Cell span={content.component.span}>\n <Component\n form={pageState.form as any}\n entity={pageState.entity as any as Record<string, any>}\n />\n </Cell>\n );\n\n default:\n return null;\n }\n};\n\nconst RenderLayoutCard: React.FC<{\n layout: CardLayout;\n sectionId: string;\n cardIndex: number;\n setInputRef: (id: string, input: BaseInputRef) => void;\n}> = ({ layout, sectionId, cardIndex, setInputRef }) => {\n switch (layout.type) {\n case 'card':\n return (\n <EntityPage.Card minHeight=\"50px\">\n <Card.Header\n title={layout.card.title.text}\n subtitle={layout.card.subtitle?.text}\n />\n <Card.Divider />\n <Card.Content>\n <Layout>\n {layout.card.children.map((child, index: number) => (\n <RenderLayoutContent\n key={`${sectionId}-card-${cardIndex}-content-${index}`}\n content={child}\n level={0}\n sectionId={sectionId}\n cardIndex={cardIndex}\n contentIndex={index}\n setInputRef={setInputRef}\n />\n ))}\n </Layout>\n </Card.Content>\n </EntityPage.Card>\n );\n default:\n return null;\n }\n};\n\nexport interface AutoPatternsEntityPageProps {\n configuration: EntityPageConfig;\n}\n\nexport const AutoPatternsEntityPage: React.FC<AutoPatternsEntityPageProps> = ({\n configuration,\n}) => {\n const {\n title,\n subtitle,\n layout: pageLayout,\n parentPageId,\n route,\n } = configuration;\n\n const form = useForm<any>();\n const params = useParams();\n const entityId = params[route.params.id];\n const schema = useSchema();\n\n const inputRefs = useRef<{ [fieldId: string]: BaseInputRef }>({});\n\n const setInputRef = (id: string, input: BaseInputRef) => {\n inputRefs.current[id] = input;\n };\n\n const validate = () => {\n const invalidFieldId = Object.keys(inputRefs.current).find((fieldId) => {\n return inputRefs.current[fieldId]?.invalid;\n });\n\n if (invalidFieldId) {\n inputRefs.current[invalidFieldId]?.focus?.();\n throw new Error('Invalid form');\n }\n };\n const { getParentPagePath } = useNavigation();\n\n const parentPath = useMemo(\n () => getParentPagePath(parentPageId),\n [parentPageId, getParentPagePath],\n );\n\n const state: EntityPageState<any> = useEntityPage<any, any>({\n parentPath,\n form,\n onSave: async () => {\n validate();\n\n const formValues = form.getValues();\n const baseEntity = state.entity || {};\n const updatedEntity = {\n ...baseEntity,\n ...formValues,\n };\n\n const newEntity = entityId\n ? await schema.actions.update(updatedEntity)\n : await schema.actions.create(updatedEntity);\n\n return { updatedEntity: newEntity };\n },\n fetch: async () => {\n if (!entityId) {\n return { entity: undefined };\n }\n const entity = await schema.actions.get(entityId);\n return { entity };\n },\n });\n\n const entity = useEntity(state);\n\n return (\n <EntityPage state={state} dataHook=\"auto-patterns-entity-page\">\n <EntityPage.Header\n title={\n title ?? { text: entity?.[schema.displayField] ?? 'Edit Entity' }\n }\n subtitle={subtitle}\n />\n <EntityPage.Content>\n <EntityPage.MainContent>\n {pageLayout?.main?.map((layout, layoutIndex) => (\n <RenderLayoutCard\n key={`main-section-card-${layoutIndex}`}\n layout={layout}\n sectionId=\"main\"\n cardIndex={layoutIndex}\n setInputRef={setInputRef}\n />\n ))}\n </EntityPage.MainContent>\n {pageLayout?.sidebar ? (\n <EntityPage.AdditionalContent>\n {pageLayout.sidebar?.map((layout, layoutIndex) => (\n <RenderLayoutCard\n key={`sidebar-section-card-${layoutIndex}`}\n layout={layout}\n sectionId=\"sidebar\"\n cardIndex={layoutIndex}\n setInputRef={setInputRef}\n />\n ))}\n </EntityPage.AdditionalContent>\n ) : null}\n </EntityPage.Content>\n </EntityPage>\n );\n};\n\n/*\n Key structure explanation:\n\n Main cards: main-section-card-{layoutIndex}\n Sidebar cards: sidebar-section-card-{layoutIndex}\n\n Layout content:\n {sectionId}-card-{cardIndex}-content-{contentIndex}\n\n Nested children:\n {sectionId}-card-{cardIndex}-content-{parentContentIndex}-level-{level}-child-{childIndex}\n\n This ensures uniqueness across all levels and sections.\n*/\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,OAAO,EAAEC,MAAM,QAAQ,OAAO;AAE9C,SACEC,UAAU,EAEVC,SAAS,EACTC,aAAa,EACbC,oBAAoB,QACf,eAAe;AACtB,SAASC,OAAO,QAAQ,oBAAoB;AAC5C,SAASC,IAAI,EAAEC,IAAI,EAAEC,MAAM,QAAQ,oBAAoB;AACvD,SAASC,SAAS,QAAQ,kBAAkB;AAC5C,SAASC,SAAS,QAAQ,+BAA+B;AAEzD,SAASC,cAAc,QAAQ,yBAAyB;AACxD,SAASC,aAAa,QAAQ,aAAa;AAC3C,SAASC,iCAAiC,QAAQ,iBAAiB;AAEnE,MAAMC,mBAOJ,GAAGC,IAAA,IAAyE;EAAA,IAAAC,qBAAA,EAAAC,qBAAA;EAAA,IAAxE;IAAEC,OAAO;IAAEC,KAAK;IAAEC,SAAS;IAAEC,SAAS;IAAEC,YAAY;IAAEC;EAAY,CAAC,GAAAR,IAAA;EACvE,MAAMS,MAAM,GAAGd,SAAS,CAAC,CAAC;EAC1B,MAAMe,SAAS,GAAGZ,iCAAiC,CAAC,CAAC;EACrD,MAAMa,SAAS,GAAGtB,oBAAoB,CAAC,CAAC;EAExC,QAAQc,OA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,GAAG,CAAC,CAACY,MAAM,EAAEoD,WAAW,kBAC3CzG,KAAA,CAAAiC,aAAA,CAACiB,gBAAgB;IACff,GAAG,EAAE,wBAAwBsE,WAAW,EAAG;IAC3CpD,MAAM,EAAEA,MAAO;IACf/B,SAAS,EAAC,SAAS;IACnBC,SAAS,EAAEkF,WAAY;IACvBhF,WAAW,EAAEA;EAAY,CAC1B,CACF,CAC2B,CAAC,GAC7B,IACc,CACV,CAAC;AAEjB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
1
+ {"version":3,"names":["React","useMemo","useRef","EntityPage","useEntity","useEntityPage","useEntityPageContext","useForm","Card","Cell","Layout","useParams","useSchema","FormFieldInput","useEntityPageHeaderTexts","useNavigation","usePatternsWizardOverridesContext","RenderLayoutContent","_ref","_content$container$ch","_overrides$components","content","level","sectionId","cardIndex","contentIndex","setInputRef","schema","overrides","pageState","type","field","fieldId","fields","createElement","span","key","inputRef","ref","container","children","length","map","child","index","component","componentId","Component","components","form","entity","RenderLayoutCard","_ref2","_layout$card$subtitle","layout","minHeight","Header","title","card","text","subtitle","Divider","Content","AutoPatternsEntityPage","_ref3","_pageLayout$main","_pageLayout$sidebar","configuration","pageLayout","parentPageId","route","mode","params","entityId","id","isCreateMode","inputRefs","input","current","validate","invalidFieldId","Object","keys","find","_inputRefs$current$fi","invalid","_inputRefs$current$in","focus","Error","getParentPagePath","parentPath","state","onSave","formValues","getValues","baseEntity","updatedEntity","newEntity","actions","update","create","fetch","undefined","get","config","entityDisplayName","displayField","dataHook","MainContent","main","layoutIndex","sidebar","AdditionalContent"],"sources":["../../../../src/components/AutoPatternsEntityPage/AutoPatternsEntityPage.tsx"],"sourcesContent":["import React, { useMemo, useRef } from 'react';\nimport { CardLayout, EntityPageConfig, LayoutContent } from '../../types';\nimport {\n EntityPage,\n EntityPageState,\n useEntity,\n useEntityPage,\n useEntityPageContext,\n} from '@wix/patterns';\nimport { useForm } from '@wix/patterns/form';\nimport { Card, Cell, Layout } from '@wix/design-system';\nimport { useParams } from 'react-router-dom';\nimport { useSchema } from '../../providers/SchemaContext';\nimport { BaseInputRef } from './Fields/types';\nimport { FormFieldInput } from './Fields/FormFieldInput';\nimport { useEntityPageHeaderTexts, useNavigation } from '../../hooks';\nimport { usePatternsWizardOverridesContext } from '../../providers';\n\nconst RenderLayoutContent: React.FC<{\n content: LayoutContent;\n level: number;\n sectionId: string;\n cardIndex: number;\n contentIndex: number;\n setInputRef: (id: string, input: BaseInputRef) => void;\n}> = ({ content, level, sectionId, cardIndex, contentIndex, setInputRef }) => {\n const schema = useSchema();\n const overrides = usePatternsWizardOverridesContext();\n const pageState = useEntityPageContext();\n\n switch (content.type) {\n case 'field':\n if (!content.field.fieldId) {\n return null;\n }\n\n const field = schema.fields[content.field.fieldId];\n\n if (!field) {\n return null;\n }\n\n return (\n <Cell span={content.field.span}>\n <FormFieldInput\n key={content.field.fieldId}\n field={field}\n inputRef={(ref) => setInputRef(content.field.fieldId, ref)}\n />\n </Cell>\n );\n\n case 'container':\n if (!content.container.children?.length) {\n return null;\n }\n\n return (\n <Cell span={content.container.span}>\n <Layout>\n {content.container.children.map((child, index) => (\n <RenderLayoutContent\n key={`${sectionId}-card-${cardIndex}-content-${contentIndex}-level-${level}-child-${index}`}\n content={child}\n level={level + 1}\n sectionId={sectionId}\n cardIndex={cardIndex}\n contentIndex={index}\n setInputRef={setInputRef}\n />\n ))}\n </Layout>\n </Cell>\n );\n\n case 'component':\n if (!content.component.componentId) {\n return null;\n }\n\n const Component = overrides?.components?.[content.component.componentId];\n\n if (!Component) {\n return null;\n }\n\n return (\n <Cell span={content.component.span}>\n <Component\n form={pageState.form as any}\n entity={pageState.entity as any as Record<string, any>}\n />\n </Cell>\n );\n\n default:\n return null;\n }\n};\n\nconst RenderLayoutCard: React.FC<{\n layout: CardLayout;\n sectionId: string;\n cardIndex: number;\n setInputRef: (id: string, input: BaseInputRef) => void;\n}> = ({ layout, sectionId, cardIndex, setInputRef }) => {\n switch (layout.type) {\n case 'card':\n return (\n <EntityPage.Card minHeight=\"50px\">\n <Card.Header\n title={layout.card.title.text}\n subtitle={layout.card.subtitle?.text}\n />\n <Card.Divider />\n <Card.Content>\n <Layout>\n {layout.card.children.map((child, index: number) => (\n <RenderLayoutContent\n key={`${sectionId}-card-${cardIndex}-content-${index}`}\n content={child}\n level={0}\n sectionId={sectionId}\n cardIndex={cardIndex}\n contentIndex={index}\n setInputRef={setInputRef}\n />\n ))}\n </Layout>\n </Card.Content>\n </EntityPage.Card>\n );\n default:\n return null;\n }\n};\n\nexport interface AutoPatternsEntityPageProps {\n configuration: EntityPageConfig;\n}\n\nexport const AutoPatternsEntityPage: React.FC<AutoPatternsEntityPageProps> = ({\n configuration,\n}) => {\n const { layout: pageLayout, parentPageId, route } = configuration;\n\n const form = useForm<any>({\n mode: 'onChange',\n });\n const params = useParams();\n const entityId = params[route.params.id];\n const schema = useSchema();\n const isCreateMode = !entityId;\n\n const inputRefs = useRef<{ [fieldId: string]: BaseInputRef }>({});\n\n const setInputRef = (id: string, input: BaseInputRef) => {\n inputRefs.current[id] = input;\n };\n\n const validate = () => {\n const invalidFieldId = Object.keys(inputRefs.current).find((fieldId) => {\n return inputRefs.current[fieldId]?.invalid;\n });\n\n if (invalidFieldId) {\n inputRefs.current[invalidFieldId]?.focus?.();\n throw new Error('Invalid form');\n }\n };\n const { getParentPagePath } = useNavigation();\n\n const parentPath = useMemo(\n () => getParentPagePath(parentPageId),\n [parentPageId, getParentPagePath],\n );\n\n const state: EntityPageState<any> = useEntityPage<any, any>({\n parentPath,\n form,\n onSave: async () => {\n validate();\n\n const formValues = form.getValues();\n const baseEntity = state.entity || {};\n const updatedEntity = {\n ...baseEntity,\n ...formValues,\n };\n\n const newEntity = entityId\n ? await schema.actions.update(updatedEntity)\n : await schema.actions.create(updatedEntity);\n\n return { updatedEntity: newEntity };\n },\n fetch: async () => {\n if (!entityId) {\n return { entity: undefined };\n }\n const entity = await schema.actions.get(entityId);\n return { entity };\n },\n });\n\n const entity = useEntity(state);\n\n const { title, subtitle } = useEntityPageHeaderTexts({\n config: configuration,\n isCreateMode,\n entityDisplayName: entity?.[schema.displayField],\n });\n\n return (\n <EntityPage state={state} dataHook=\"auto-patterns-entity-page\">\n <EntityPage.Header title={title} subtitle={subtitle} />\n <EntityPage.Content>\n <EntityPage.MainContent>\n {pageLayout?.main?.map((layout, layoutIndex) => (\n <RenderLayoutCard\n key={`main-section-card-${layoutIndex}`}\n layout={layout}\n sectionId=\"main\"\n cardIndex={layoutIndex}\n setInputRef={setInputRef}\n />\n ))}\n </EntityPage.MainContent>\n {pageLayout?.sidebar ? (\n <EntityPage.AdditionalContent>\n {pageLayout.sidebar?.map((layout, layoutIndex) => (\n <RenderLayoutCard\n key={`sidebar-section-card-${layoutIndex}`}\n layout={layout}\n sectionId=\"sidebar\"\n cardIndex={layoutIndex}\n setInputRef={setInputRef}\n />\n ))}\n </EntityPage.AdditionalContent>\n ) : null}\n </EntityPage.Content>\n </EntityPage>\n );\n};\n\n/*\n Key structure explanation:\n\n Main cards: main-section-card-{layoutIndex}\n Sidebar cards: sidebar-section-card-{layoutIndex}\n\n Layout content:\n {sectionId}-card-{cardIndex}-content-{contentIndex}\n\n Nested children:\n {sectionId}-card-{cardIndex}-content-{parentContentIndex}-level-{level}-child-{childIndex}\n\n This ensures uniqueness across all levels and sections.\n*/\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,OAAO,EAAEC,MAAM,QAAQ,OAAO;AAE9C,SACEC,UAAU,EAEVC,SAAS,EACTC,aAAa,EACbC,oBAAoB,QACf,eAAe;AACtB,SAASC,OAAO,QAAQ,oBAAoB;AAC5C,SAASC,IAAI,EAAEC,IAAI,EAAEC,MAAM,QAAQ,oBAAoB;AACvD,SAASC,SAAS,QAAQ,kBAAkB;AAC5C,SAASC,SAAS,QAAQ,+BAA+B;AAEzD,SAASC,cAAc,QAAQ,yBAAyB;AACxD,SA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D,OAAO,qBACjB9D,KAAA,CAAAkC,aAAA,CAAC/B,UAAU,CAACyG,WAAW,QACpBxC,UAAU,aAAAH,gBAAA,GAAVG,UAAU,CAAEyC,IAAI,qBAAhB5C,gBAAA,CAAkBvB,GAAG,CAAC,CAACY,MAAM,EAAEwD,WAAW,kBACzC9G,KAAA,CAAAkC,aAAA,CAACiB,gBAAgB;IACff,GAAG,EAAE,qBAAqB0E,WAAW,EAAG;IACxCxD,MAAM,EAAEA,MAAO;IACf/B,SAAS,EAAC,MAAM;IAChBC,SAAS,EAAEsF,WAAY;IACvBpF,WAAW,EAAEA;EAAY,CAC1B,CACF,CACqB,CAAC,EACxB0C,UAAU,YAAVA,UAAU,CAAE2C,OAAO,gBAClB/G,KAAA,CAAAkC,aAAA,CAAC/B,UAAU,CAAC6G,iBAAiB,SAAA9C,mBAAA,GAC1BE,UAAU,CAAC2C,OAAO,qBAAlB7C,mBAAA,CAAoBxB,GAAG,CAAC,CAACY,MAAM,EAAEwD,WAAW,kBAC3C9G,KAAA,CAAAkC,aAAA,CAACiB,gBAAgB;IACff,GAAG,EAAE,wBAAwB0E,WAAW,EAAG;IAC3CxD,MAAM,EAAEA,MAAO;IACf/B,SAAS,EAAC,SAAS;IACnBC,SAAS,EAAEsF,WAAY;IACvBpF,WAAW,EAAEA;EAAY,CAC1B,CACF,CAC2B,CAAC,GAC7B,IACc,CACV,CAAC;AAEjB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
@@ -1,13 +1,22 @@
1
- import React, { useRef, useState } from 'react';
1
+ import React, { useState, useRef } from 'react';
2
2
  import { FormField, DatePicker } from '@wix/design-system';
3
3
  import { getDateWithoutTimezone, getISODateStringWithFixedTimezone } from './utils/dates';
4
- import { useSelector, useWixPatternsContainer } from '@wix/patterns';
4
+ import { useSelector, useWixPatternsContainer, useEntityPageContext } from '@wix/patterns';
5
+ import { useController } from '@wix/patterns/form';
6
+ function validateDateField(value, validation, t, format, validationType) {
7
+ if (validation != null && validation.required && (value === null || value === undefined || value === '')) {
8
+ return t('cairo.fieldValidation.requiredField');
9
+ } else if (validationType === 'formatError' && format) {
10
+ return t('cairo.customFields.fieldType.date.invalid.value', {
11
+ dateFormat: format
12
+ });
13
+ }
14
+ return '';
15
+ }
5
16
  export const DateInput = props => {
6
- var _field$validation;
17
+ var _pageState$entity, _field$validation;
7
18
  const {
8
19
  field,
9
- value,
10
- onChange,
11
20
  dataHook,
12
21
  inputRef
13
22
  } = props;
@@ -16,9 +25,26 @@ export const DateInput = props => {
16
25
  ...container
17
26
  } = useWixPatternsContainer();
18
27
  useSelector(() => container.initTask.status);
19
- const [date, setDate] = useState(() => value ? getDateWithoutTimezone(getISODateStringWithFixedTimezone(value)) : undefined);
28
+ const pageState = useEntityPageContext();
29
+ const controller = useController({
30
+ name: (field == null ? void 0 : field.id) ?? '',
31
+ control: pageState.form.control,
32
+ defaultValue: (_pageState$entity = pageState.entity) == null ? void 0 : _pageState$entity[(field == null ? void 0 : field.id) ?? ''],
33
+ rules: {
34
+ validate: value => {
35
+ const error = validateDateField(value, field.validation, t);
36
+ return error || true;
37
+ }
38
+ }
39
+ });
40
+ const [date, setDate] = useState(() => {
41
+ if (controller.field.value) {
42
+ return getDateWithoutTimezone(getISODateStringWithFixedTimezone(controller.field.value));
43
+ }
44
+ return undefined;
45
+ });
20
46
  const ref = useRef({});
21
- const [statusMessage, setStatusMessage] = useState('');
47
+ const [errorMessage, setErrorMessage] = useState('');
22
48
  return /*#__PURE__*/React.createElement(FormField, {
23
49
  label: field.displayName,
24
50
  required: (_field$validation = field.validation) == null ? void 0 : _field$validation.required,
@@ -26,8 +52,7 @@ export const DateInput = props => {
26
52
  }, /*#__PURE__*/React.createElement(DatePicker, {
27
53
  ref: internalRef => {
28
54
  inputRef == null || inputRef(ref.current);
29
- // TODO: PR to WSR needed to expose as public API
30
- // @ts-expect-error
55
+ // @ts-expect-error: WSR internal API hack for focusing
31
56
  ref.current.focus = () => {
32
57
  var _internalRef$state;
33
58
  return internalRef == null || (_internalRef$state = internalRef.state) == null || (_internalRef$state = _internalRef$state.inputRef) == null || _internalRef$state.focus == null ? void 0 : _internalRef$state.focus();
@@ -37,9 +62,13 @@ export const DateInput = props => {
37
62
  width: "100%",
38
63
  value: date,
39
64
  onChange: newValue => {
40
- const formattedDate = getISODateStringWithFixedTimezone(newValue);
41
65
  setDate(newValue);
42
- onChange(formattedDate.split('T')[0]);
66
+ if (newValue) {
67
+ const formattedDate = getISODateStringWithFixedTimezone(newValue);
68
+ controller.field.onChange(formattedDate.split('T')[0]);
69
+ } else {
70
+ controller.field.onChange(null);
71
+ }
43
72
  },
44
73
  onValidate: _ref => {
45
74
  let {
@@ -47,23 +76,16 @@ export const DateInput = props => {
47
76
  value: newValue,
48
77
  format
49
78
  } = _ref;
50
- if (validationType === 'valid') {
51
- setStatusMessage('');
52
- ref.current.invalid = false;
53
- } else if (validationType === 'formatError' && newValue === '') {
79
+ const error = validateDateField(newValue, field.validation, t, format, validationType);
80
+ setErrorMessage(error);
81
+ ref.current.invalid = !!error;
82
+ if (validationType === 'formatError' && newValue === '') {
54
83
  setDate(undefined);
55
- onChange(null);
56
- setStatusMessage('');
57
- ref.current.invalid = false;
58
- } else {
59
- setStatusMessage(t('cairo.customFields.fieldType.date.invalid.value', {
60
- dateFormat: format ?? ''
61
- }));
62
- ref.current.invalid = true;
84
+ controller.field.onChange(null);
63
85
  }
64
86
  },
65
- status: ref.current.invalid ? 'error' : undefined,
66
- statusMessage: statusMessage
87
+ status: errorMessage ? 'error' : undefined,
88
+ statusMessage: errorMessage
67
89
  }));
68
90
  };
69
91
  //# sourceMappingURL=DateInput.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["React","useRef","useState","FormField","DatePicker","getDateWithoutTimezone","getISODateStringWithFixedTimezone","useSelector","useWixPatternsContainer","DateInput","props","_field$validation","field","value","onChange","dataHook","inputRef","translate","t","container","initTask","status","date","setDate","undefined","ref","statusMessage","setStatusMessage","createElement","label","displayName","required","validation","internalRef","current","focus","_internalRef$state","state","id","width","newValue","formattedDate","split","onValidate","_ref","validationType","format","invalid","dateFormat"],"sources":["../../../../../src/components/AutoPatternsEntityPage/Fields/DateInput.tsx"],"sourcesContent":["import React, { useRef, useState } from 'react';\nimport { FormField, DatePicker } from '@wix/design-system';\nimport {\n getDateWithoutTimezone,\n getISODateStringWithFixedTimezone,\n} from './utils/dates';\nimport { BaseInputProps, BaseInputRef } from './types';\nimport { useSelector, useWixPatternsContainer } from '@wix/patterns';\n\nexport interface DateProps extends BaseInputProps<string | null> {}\n\nexport const DateInput = (props: DateProps) => {\n const { field, value, onChange, dataHook, inputRef } = props;\n const { translate: t, ...container } = useWixPatternsContainer();\n useSelector(() => container.initTask.status);\n\n const [date, setDate] = useState<Date | undefined>(() =>\n value\n ? getDateWithoutTimezone(getISODateStringWithFixedTimezone(value))\n : undefined,\n );\n\n const ref = useRef<BaseInputRef>({});\n const [statusMessage, setStatusMessage] = useState('');\n\n return (\n <FormField\n label={field.displayName}\n required={field.validation?.required}\n dataHook={dataHook}\n >\n <DatePicker\n ref={(internalRef) => {\n inputRef?.(ref.current);\n // TODO: PR to WSR needed to expose as public API\n // @ts-expect-error\n ref.current.focus = () => internalRef?.state?.inputRef?.focus?.();\n }}\n dataHook={`date-${field.id}`}\n width=\"100%\"\n value={date}\n onChange={(newValue: Date) => {\n const formattedDate = getISODateStringWithFixedTimezone(newValue);\n setDate(newValue);\n onChange(formattedDate.split('T')[0]);\n }}\n onValidate={({ validationType, value: newValue, format }) => {\n if (validationType === 'valid') {\n setStatusMessage('');\n ref.current.invalid = false;\n } else if (validationType === 'formatError' && newValue === '') {\n setDate(undefined);\n onChange(null);\n setStatusMessage('');\n ref.current.invalid = false;\n } else {\n setStatusMessage(\n t('cairo.customFields.fieldType.date.invalid.value', {\n dateFormat: format ?? '',\n }),\n );\n ref.current.invalid = true;\n }\n }}\n status={ref.current.invalid ? 'error' : undefined}\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,CAAE;IACF1B,MAAM,EAAEI,GAAG,CAACS,OAAO,CAACa,OAAO,GAAG,OAAO,GAAGvB,SAAU;IAClDE,aAAa,EAAEA;EAAc,CAC9B,CACQ,CAAC;AAEhB,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["React","useState","useRef","FormField","DatePicker","getDateWithoutTimezone","getISODateStringWithFixedTimezone","useSelector","useWixPatternsContainer","useEntityPageContext","useController","validateDateField","value","validation","t","format","validationType","required","undefined","dateFormat","DateInput","props","_pageState$entity","_field$validation","field","dataHook","inputRef","translate","container","initTask","status","pageState","controller","name","id","control","form","defaultValue","entity","rules","validate","error","date","setDate","ref","errorMessage","setErrorMessage","createElement","label","displayName","internalRef","current","focus","_internalRef$state","state","width","onChange","newValue","formattedDate","split","onValidate","_ref","invalid","statusMessage"],"sources":["../../../../../src/components/AutoPatternsEntityPage/Fields/DateInput.tsx"],"sourcesContent":["import React, { useState, useRef } from 'react';\nimport { FormField, DatePicker } from '@wix/design-system';\nimport {\n getDateWithoutTimezone,\n getISODateStringWithFixedTimezone,\n} from './utils/dates';\nimport { BaseInputProps, BaseInputRef } from './types';\nimport {\n useSelector,\n useWixPatternsContainer,\n useEntityPageContext,\n} from '@wix/patterns';\nimport { useController } from '@wix/patterns/form';\nimport { Translate } from '@wix/patterns/core';\n\nexport interface DateProps extends BaseInputProps<string | null> {}\n\nfunction validateDateField(\n value: string | null | undefined,\n validation: DateProps['field']['validation'],\n t: Translate,\n format?: string,\n validationType?: 'outOfBoundsError' | 'formatError' | 'valid',\n) {\n if (\n validation?.required &&\n (value === null || value === undefined || value === '')\n ) {\n return t('cairo.fieldValidation.requiredField');\n } else if (validationType === 'formatError' && format) {\n return t('cairo.customFields.fieldType.date.invalid.value', {\n dateFormat: format,\n });\n }\n\n return '';\n}\n\nexport const DateInput = (props: DateProps) => {\n const { field, dataHook, inputRef } = props;\n const { translate: t, ...container } = useWixPatternsContainer();\n useSelector(() => container.initTask.status);\n const pageState = useEntityPageContext();\n\n const controller = useController({\n name: field?.id ?? '',\n control: pageState.form.control,\n defaultValue: (pageState.entity as any)?.[field?.id ?? ''],\n rules: {\n validate: (value) => {\n const error = validateDateField(value, field.validation, t);\n return error || true;\n },\n },\n });\n\n const [date, setDate] = useState<Date | undefined>(() => {\n if (controller.field.value) {\n return getDateWithoutTimezone(\n getISODateStringWithFixedTimezone(controller.field.value),\n );\n }\n return undefined;\n });\n\n const ref = useRef<BaseInputRef>({});\n const [errorMessage, setErrorMessage] = useState<string>('');\n\n return (\n <FormField\n label={field.displayName}\n required={field.validation?.required}\n dataHook={dataHook}\n >\n <DatePicker\n ref={(internalRef) => {\n inputRef?.(ref.current);\n // @ts-expect-error: WSR internal API hack for focusing\n ref.current.focus = () => internalRef?.state?.inputRef?.focus?.();\n }}\n dataHook={`date-${field.id}`}\n width=\"100%\"\n value={date}\n onChange={(newValue: Date) => {\n setDate(newValue);\n if (newValue) {\n const formattedDate = getISODateStringWithFixedTimezone(newValue);\n controller.field.onChange(formattedDate.split('T')[0]);\n } else {\n controller.field.onChange(null);\n }\n }}\n onValidate={({ validationType, value: newValue, format }) => {\n const error = validateDateField(\n newValue,\n field.validation,\n t,\n format,\n validationType,\n );\n setErrorMessage(error);\n ref.current.invalid = !!error;\n\n if (validationType === 'formatError' && newValue === '') {\n setDate(undefined);\n controller.field.onChange(null);\n }\n }}\n status={errorMessage ? 'error' : undefined}\n statusMessage={errorMessage}\n />\n </FormField>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,QAAQ,EAAEC,MAAM,QAAQ,OAAO;AAC/C,SAASC,SAAS,EAAEC,UAAU,QAAQ,oBAAoB;AAC1D,SACEC,sBAAsB,EACtBC,iCAAiC,QAC5B,eAAe;AAEtB,SACEC,WAAW,EACXC,uBAAuB,EACvBC,oBAAoB,QACf,eAAe;AACtB,SAASC,aAAa,QAAQ,oBAAoB;AAKlD,SAASC,iBAAiBA,CACxBC,KAAgC,EAChCC,UAA4C,EAC5CC,CAAY,EACZC,M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AAa,GAAGpD,iCAAiC,CAACmD,QAAQ,CAAC;QACjEzB,UAAU,CAACR,KAAK,CAACgC,QAAQ,CAACE,aAAa,CAACC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;MACxD,CAAC,MAAM;QACL3B,UAAU,CAACR,KAAK,CAACgC,QAAQ,CAAC,IAAI,CAAC;MACjC;IACF,CAAE;IACFI,UAAU,EAAEC,IAAA,IAAiD;MAAA,IAAhD;QAAE7C,cAAc;QAAEJ,KAAK,EAAE6C,QAAQ;QAAE1C;MAAO,CAAC,GAAA8C,IAAA;MACtD,MAAMpB,KAAK,GAAG9B,iBAAiB,CAC7B8C,QAAQ,EACRjC,KAAK,CAACX,UAAU,EAChBC,CAAC,EACDC,MAAM,EACNC,cACF,CAAC;MACD8B,eAAe,CAACL,KAAK,CAAC;MACtBG,GAAG,CAACO,OAAO,CAACW,OAAO,GAAG,CAAC,CAACrB,KAAK;MAE7B,IAAIzB,cAAc,KAAK,aAAa,IAAIyC,QAAQ,KAAK,EAAE,EAAE;QACvDd,OAAO,CAACzB,SAAS,CAAC;QAClBc,UAAU,CAACR,KAAK,CAACgC,QAAQ,CAAC,IAAI,CAAC;MACjC;IACF,CAAE;IACF1B,MAAM,EAAEe,YAAY,GAAG,OAAO,GAAG3B,SAAU;IAC3C6C,aAAa,EAAElB;EAAa,CAC7B,CACQ,CAAC;AAEhB,CAAC","ignoreList":[]}
@@ -1,12 +1,11 @@
1
1
  import React, { useRef, useMemo, useState, useEffect } from 'react';
2
2
  import { Cell, DatePicker, FormField, Layout, TimeInput } from '@wix/design-system';
3
- import { useWixPatternsContainer, useSelector } from '@wix/patterns';
3
+ import { useWixPatternsContainer, useSelector, useEntityPageContext } from '@wix/patterns';
4
+ import { useController } from '@wix/patterns/form';
4
5
  export const DateTime = props => {
5
- var _field$validation;
6
+ var _pageState$entity, _field$validation2;
6
7
  const {
7
8
  field,
8
- value,
9
- onChange,
10
9
  dataHook,
11
10
  inputRef
12
11
  } = props;
@@ -15,14 +14,30 @@ export const DateTime = props => {
15
14
  ...container
16
15
  } = useWixPatternsContainer();
17
16
  useSelector(() => container.initTask.status);
17
+ const pageState = useEntityPageContext();
18
+ const controller = useController({
19
+ name: (field == null ? void 0 : field.id) ?? '',
20
+ control: pageState.form.control,
21
+ defaultValue: (_pageState$entity = pageState.entity) == null ? void 0 : _pageState$entity[(field == null ? void 0 : field.id) ?? ''],
22
+ rules: {
23
+ validate: v => {
24
+ var _field$validation;
25
+ if (field != null && (_field$validation = field.validation) != null && _field$validation.required && (v === null || v === undefined || v === '')) {
26
+ return t('cairo.fieldValidation.requiredField');
27
+ }
28
+ return true;
29
+ }
30
+ }
31
+ });
18
32
  const date = useMemo(() => {
19
- if (!value) {
33
+ if (!controller.field.value) {
20
34
  return undefined;
21
35
  }
22
- const d = new Date(value);
36
+ const d = new Date(controller.field.value);
23
37
  return isNaN(d.getTime()) ? undefined : d;
24
- }, [value]);
25
- const [statusMessage, setStatusMessage] = useState('');
38
+ }, [controller.field.value]);
39
+ const [dateStatusMessage, setDateStatusMessage] = useState('');
40
+ const [timeStatusMessage, setTimeStatusMessage] = useState('');
26
41
  const ref = useRef({});
27
42
  const dateRef = useRef({});
28
43
  const timeRef = useRef({});
@@ -39,7 +54,7 @@ export const DateTime = props => {
39
54
  }, [inputRef]);
40
55
  return /*#__PURE__*/React.createElement(FormField, {
41
56
  label: field.displayName,
42
- required: (_field$validation = field.validation) == null ? void 0 : _field$validation.required,
57
+ required: (_field$validation2 = field.validation) == null ? void 0 : _field$validation2.required,
43
58
  dataHook: dataHook
44
59
  }, /*#__PURE__*/React.createElement(Layout, null, /*#__PURE__*/React.createElement(Cell, {
45
60
  span: 6
@@ -55,7 +70,7 @@ export const DateTime = props => {
55
70
  },
56
71
  width: "100%",
57
72
  value: date
58
- // onChange is triggered only when you have valid, non-empty value. and onValidate is triggered on every change to we use onValidate
73
+ // onChange is triggered only when you have valid, non-empty value. and onValidate is triggered on every change so we use onValidate
59
74
  ,
60
75
  onChange: () => {},
61
76
  onValidate: _ref => {
@@ -70,27 +85,33 @@ export const DateTime = props => {
70
85
  dateWithNewDate.setFullYear(_value.getFullYear());
71
86
  dateWithNewDate.setMonth(_value.getMonth());
72
87
  dateWithNewDate.setDate(_value.getDate());
73
- onChange(dateWithNewDate.toISOString());
88
+ controller.field.onChange(dateWithNewDate.toISOString());
74
89
  setDateValue(new Date(newValue).getDate());
75
- setStatusMessage('');
76
- dateRef.current.invalid = false;
77
- } else if (validationType === 'formatError' && value === '') {
78
- setStatusMessage('');
90
+ setDateStatusMessage('');
79
91
  dateRef.current.invalid = false;
80
- setDateValue(value);
92
+ } else if (validationType === 'formatError' && newValue === '') {
93
+ var _field$validation3;
94
+ if ((_field$validation3 = field.validation) != null && _field$validation3.required) {
95
+ setDateStatusMessage(t('cairo.fieldValidation.requiredField'));
96
+ dateRef.current.invalid = true;
97
+ } else {
98
+ setDateStatusMessage('');
99
+ dateRef.current.invalid = false;
100
+ }
101
+ setDateValue(newValue);
81
102
  if (!timeValue) {
82
- onChange(null);
103
+ controller.field.onChange(null);
83
104
  }
84
105
  } else {
85
- setStatusMessage(t('cairo.customFields.fieldType.date.invalid.value', {
106
+ setDateStatusMessage(t('cairo.customFields.fieldType.date.invalid.value', {
86
107
  dateFormat: format ?? ''
87
108
  }));
88
109
  dateRef.current.invalid = true;
89
110
  }
90
111
  ref.current.invalid = dateRef.current.invalid || timeRef.current.invalid;
91
112
  },
92
- status: ref.current.invalid ? 'error' : undefined,
93
- statusMessage: statusMessage,
113
+ status: controller.fieldState.error || dateStatusMessage ? 'error' : undefined,
114
+ statusMessage: controller.fieldState.error || dateStatusMessage,
94
115
  dataHook: `datetime-date-${field.id}`
95
116
  })), /*#__PURE__*/React.createElement(Cell, {
96
117
  span: 6
@@ -100,15 +121,18 @@ export const DateTime = props => {
100
121
  },
101
122
  dataHook: `datetime-time-${field.id}`,
102
123
  value: date ?? null,
103
- invalidMessage: t('cairo.customFields.fieldType.dateAndTime.invalid.value'),
124
+ status: controller.fieldState.error || timeStatusMessage ? 'error' : undefined,
125
+ statusMessage: controller.fieldState.error || timeStatusMessage,
104
126
  onInvalid: () => {
105
127
  timeRef.current.invalid = true;
128
+ setTimeStatusMessage(t('cairo.customFields.fieldType.dateAndTime.invalid.value'));
106
129
  ref.current.invalid = dateRef.current.invalid || timeRef.current.invalid;
107
130
  },
108
131
  onChange: _ref2 => {
109
132
  let {
110
133
  date: newValue
111
134
  } = _ref2;
135
+ debugger;
112
136
  timeRef.current.invalid = false;
113
137
  ref.current.invalid = dateRef.current.invalid || timeRef.current.invalid;
114
138
  if (newValue) {
@@ -117,12 +141,24 @@ export const DateTime = props => {
117
141
  dateWithNewTime.setMinutes(newValue.getMinutes());
118
142
  dateWithNewTime.setSeconds(newValue.getSeconds());
119
143
  dateWithNewTime.setMilliseconds(newValue.getMilliseconds());
120
- onChange(dateWithNewTime.toISOString());
121
- } else if (!ref.current.invalid) {
144
+ controller.field.onChange(dateWithNewTime.toISOString());
145
+ setTimeStatusMessage('');
146
+ setDateStatusMessage('');
147
+ } else {
122
148
  if (!newValue) {
149
+ var _field$validation4;
123
150
  setTimeValue('');
124
- if (!dateValue) {
125
- onChange(null);
151
+ if ((_field$validation4 = field.validation) != null && _field$validation4.required) {
152
+ setTimeStatusMessage(t('cairo.fieldValidation.requiredField'));
153
+ timeRef.current.invalid = true;
154
+ } else {
155
+ setTimeStatusMessage('');
156
+ timeRef.current.invalid = false;
157
+ }
158
+ if (!ref.current.invalid) {
159
+ if (!dateValue) {
160
+ controller.field.onChange(null);
161
+ }
126
162
  }
127
163
  }
128
164
  }