@wordpress/dataviews 9.1.1-next.233ccab9b.0 → 10.0.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 (787) hide show
  1. package/CHANGELOG.md +42 -1
  2. package/README.md +137 -36
  3. package/build/components/dataform/index.js +52 -28
  4. package/build/components/dataform/index.js.map +7 -1
  5. package/build/components/dataform-context/index.js +33 -25
  6. package/build/components/dataform-context/index.js.map +7 -1
  7. package/build/components/dataviews/index.js +193 -154
  8. package/build/components/dataviews/index.js.map +7 -1
  9. package/build/components/dataviews-bulk-actions/index.js +264 -155
  10. package/build/components/dataviews-bulk-actions/index.js.map +7 -1
  11. package/build/components/dataviews-context/index.js +40 -36
  12. package/build/components/dataviews-context/index.js.map +7 -1
  13. package/build/components/dataviews-filters/add-filter.js +78 -73
  14. package/build/components/dataviews-filters/add-filter.js.map +7 -1
  15. package/build/components/dataviews-filters/filter.js +473 -263
  16. package/build/components/dataviews-filters/filter.js.map +7 -1
  17. package/build/components/dataviews-filters/filters-toggled.js +39 -25
  18. package/build/components/dataviews-filters/filters-toggled.js.map +7 -1
  19. package/build/components/dataviews-filters/filters.js +95 -67
  20. package/build/components/dataviews-filters/filters.js.map +7 -1
  21. package/build/components/dataviews-filters/index.js +44 -31
  22. package/build/components/dataviews-filters/index.js.map +7 -1
  23. package/build/components/dataviews-filters/input-widget.js +88 -89
  24. package/build/components/dataviews-filters/input-widget.js.map +7 -1
  25. package/build/components/dataviews-filters/reset-filters.js +50 -34
  26. package/build/components/dataviews-filters/reset-filters.js.map +7 -1
  27. package/build/components/dataviews-filters/search-widget.js +301 -205
  28. package/build/components/dataviews-filters/search-widget.js.map +7 -1
  29. package/build/components/dataviews-filters/toggle.js +88 -63
  30. package/build/components/dataviews-filters/toggle.js.map +7 -1
  31. package/build/components/dataviews-filters/use-filters.js +40 -29
  32. package/build/components/dataviews-filters/use-filters.js.map +7 -1
  33. package/build/components/dataviews-filters/utils.js +26 -10
  34. package/build/components/dataviews-filters/utils.js.map +7 -1
  35. package/build/components/dataviews-footer/index.js +54 -33
  36. package/build/components/dataviews-footer/index.js.map +7 -1
  37. package/build/components/dataviews-item-actions/index.js +188 -150
  38. package/build/components/dataviews-item-actions/index.js.map +7 -1
  39. package/build/components/dataviews-layout/index.js +64 -49
  40. package/build/components/dataviews-layout/index.js.map +7 -1
  41. package/build/components/dataviews-pagination/index.js +143 -99
  42. package/build/components/dataviews-pagination/index.js.map +7 -1
  43. package/build/components/dataviews-picker/footer.js +152 -101
  44. package/build/components/dataviews-picker/footer.js.map +7 -1
  45. package/build/components/dataviews-picker/index.js +173 -145
  46. package/build/components/dataviews-picker/index.js.map +7 -1
  47. package/build/components/dataviews-search/index.js +63 -46
  48. package/build/components/dataviews-search/index.js.map +7 -1
  49. package/build/components/dataviews-selection-checkbox/index.js +45 -35
  50. package/build/components/dataviews-selection-checkbox/index.js.map +7 -1
  51. package/build/components/dataviews-view-config/index.js +587 -512
  52. package/build/components/dataviews-view-config/index.js.map +7 -1
  53. package/build/components/dataviews-view-config/infinite-scroll-toggle.js +56 -39
  54. package/build/components/dataviews-view-config/infinite-scroll-toggle.js.map +7 -1
  55. package/build/constants.js +215 -108
  56. package/build/constants.js.map +7 -1
  57. package/build/dataform-controls/array.js +109 -145
  58. package/build/dataform-controls/array.js.map +7 -1
  59. package/build/dataform-controls/checkbox.js +56 -66
  60. package/build/dataform-controls/checkbox.js.map +7 -1
  61. package/build/dataform-controls/color.js +112 -119
  62. package/build/dataform-controls/color.js.map +7 -1
  63. package/build/dataform-controls/date.js +531 -349
  64. package/build/dataform-controls/date.js.map +7 -1
  65. package/build/dataform-controls/datetime.js +189 -148
  66. package/build/dataform-controls/datetime.js.map +7 -1
  67. package/build/dataform-controls/email.js +52 -32
  68. package/build/dataform-controls/email.js.map +7 -1
  69. package/build/dataform-controls/index.js +83 -63
  70. package/build/dataform-controls/index.js.map +7 -1
  71. package/build/dataform-controls/integer.js +36 -129
  72. package/build/dataform-controls/integer.js.map +7 -1
  73. package/build/dataform-controls/number.js +39 -0
  74. package/build/dataform-controls/number.js.map +7 -0
  75. package/build/dataform-controls/password.js +66 -38
  76. package/build/dataform-controls/password.js.map +7 -1
  77. package/build/dataform-controls/radio.js +61 -64
  78. package/build/dataform-controls/radio.js.map +7 -1
  79. package/build/dataform-controls/select.js +70 -88
  80. package/build/dataform-controls/select.js.map +7 -1
  81. package/build/dataform-controls/telephone.js +52 -32
  82. package/build/dataform-controls/telephone.js.map +7 -1
  83. package/build/dataform-controls/text.js +52 -30
  84. package/build/dataform-controls/text.js.map +7 -1
  85. package/build/dataform-controls/textarea.js +62 -71
  86. package/build/dataform-controls/textarea.js.map +7 -1
  87. package/build/dataform-controls/toggle-group.js +73 -66
  88. package/build/dataform-controls/toggle-group.js.map +7 -1
  89. package/build/dataform-controls/toggle.js +57 -67
  90. package/build/dataform-controls/toggle.js.map +7 -1
  91. package/build/dataform-controls/url.js +52 -32
  92. package/build/dataform-controls/url.js.map +7 -1
  93. package/build/dataform-controls/utils/get-custom-validity.js +35 -0
  94. package/build/dataform-controls/utils/get-custom-validity.js.map +7 -0
  95. package/build/dataform-controls/utils/relative-date-control.js +122 -0
  96. package/build/dataform-controls/utils/relative-date-control.js.map +7 -0
  97. package/build/dataform-controls/utils/validated-input.js +67 -71
  98. package/build/dataform-controls/utils/validated-input.js.map +7 -1
  99. package/build/dataform-controls/utils/validated-number.js +167 -0
  100. package/build/dataform-controls/utils/validated-number.js.map +7 -0
  101. package/build/dataform-layouts/card/index.js +217 -0
  102. package/build/dataform-layouts/card/index.js.map +7 -0
  103. package/build/dataform-layouts/data-form-layout.js +95 -0
  104. package/build/dataform-layouts/data-form-layout.js.map +7 -0
  105. package/build/dataform-layouts/get-summary-fields.js +45 -0
  106. package/build/dataform-layouts/get-summary-fields.js.map +7 -0
  107. package/build/dataform-layouts/index.js +99 -0
  108. package/build/dataform-layouts/index.js.map +7 -0
  109. package/build/dataform-layouts/is-combined-field.js +31 -0
  110. package/build/dataform-layouts/is-combined-field.js.map +7 -0
  111. package/build/dataform-layouts/normalize-form-fields.js +104 -0
  112. package/build/dataform-layouts/normalize-form-fields.js.map +7 -0
  113. package/build/dataform-layouts/panel/dropdown.js +159 -0
  114. package/build/dataform-layouts/panel/dropdown.js.map +7 -0
  115. package/build/dataform-layouts/panel/index.js +152 -0
  116. package/build/dataform-layouts/panel/index.js.map +7 -0
  117. package/build/dataform-layouts/panel/modal.js +176 -0
  118. package/build/dataform-layouts/panel/modal.js.map +7 -0
  119. package/build/dataform-layouts/panel/summary-button.js +93 -0
  120. package/build/dataform-layouts/panel/summary-button.js.map +7 -0
  121. package/build/dataform-layouts/regular/index.js +139 -0
  122. package/build/dataform-layouts/regular/index.js.map +7 -0
  123. package/build/dataform-layouts/row/index.js +120 -0
  124. package/build/dataform-layouts/row/index.js.map +7 -0
  125. package/build/dataviews-layouts/grid/index.js +337 -278
  126. package/build/dataviews-layouts/grid/index.js.map +7 -1
  127. package/build/dataviews-layouts/grid/preview-size-picker.js +94 -69
  128. package/build/dataviews-layouts/grid/preview-size-picker.js.map +7 -1
  129. package/build/dataviews-layouts/index.js +75 -48
  130. package/build/dataviews-layouts/index.js.map +7 -1
  131. package/build/dataviews-layouts/list/index.js +441 -354
  132. package/build/dataviews-layouts/list/index.js.map +7 -1
  133. package/build/dataviews-layouts/picker-grid/index.js +366 -300
  134. package/build/dataviews-layouts/picker-grid/index.js.map +7 -1
  135. package/build/dataviews-layouts/table/column-header-menu.js +144 -133
  136. package/build/dataviews-layouts/table/column-header-menu.js.map +7 -1
  137. package/build/dataviews-layouts/table/column-primary.js +86 -66
  138. package/build/dataviews-layouts/table/column-primary.js.map +7 -1
  139. package/build/dataviews-layouts/table/density-picker.js +86 -46
  140. package/build/dataviews-layouts/table/density-picker.js.map +7 -1
  141. package/build/dataviews-layouts/table/index.js +354 -319
  142. package/build/dataviews-layouts/table/index.js.map +7 -1
  143. package/build/dataviews-layouts/table/use-is-horizontal-scroll-end.js +55 -47
  144. package/build/dataviews-layouts/table/use-is-horizontal-scroll-end.js.map +7 -1
  145. package/build/dataviews-layouts/utils/get-data-by-group.js +24 -13
  146. package/build/dataviews-layouts/utils/get-data-by-group.js.map +7 -1
  147. package/build/dataviews-layouts/utils/grid-items.js +51 -34
  148. package/build/dataviews-layouts/utils/grid-items.js.map +7 -1
  149. package/build/dataviews-layouts/utils/item-click-wrapper.js +53 -31
  150. package/build/dataviews-layouts/utils/item-click-wrapper.js.map +7 -1
  151. package/build/dataviews-layouts/utils/preview-size-picker.js +94 -69
  152. package/build/dataviews-layouts/utils/preview-size-picker.js.map +7 -1
  153. package/build/field-types/array.js +46 -41
  154. package/build/field-types/array.js.map +7 -1
  155. package/build/field-types/boolean.js +52 -47
  156. package/build/field-types/boolean.js.map +7 -1
  157. package/build/field-types/color.js +79 -81
  158. package/build/field-types/color.js.map +7 -1
  159. package/build/field-types/date.js +69 -48
  160. package/build/field-types/date.js.map +7 -1
  161. package/build/field-types/datetime.js +62 -43
  162. package/build/field-types/datetime.js.map +7 -1
  163. package/build/field-types/email.js +58 -47
  164. package/build/field-types/email.js.map +7 -1
  165. package/build/field-types/index.js +84 -89
  166. package/build/field-types/index.js.map +7 -1
  167. package/build/field-types/integer.js +68 -45
  168. package/build/field-types/integer.js.map +7 -1
  169. package/build/field-types/media.js +25 -27
  170. package/build/field-types/media.js.map +7 -1
  171. package/build/field-types/number.js +95 -0
  172. package/build/field-types/number.js.map +7 -0
  173. package/build/field-types/password.js +40 -39
  174. package/build/field-types/password.js.map +7 -1
  175. package/build/field-types/telephone.js +55 -45
  176. package/build/field-types/telephone.js.map +7 -1
  177. package/build/field-types/text.js +55 -46
  178. package/build/field-types/text.js.map +7 -1
  179. package/build/field-types/url.js +55 -45
  180. package/build/field-types/url.js.map +7 -1
  181. package/build/field-types/utils/render-from-elements.js +52 -0
  182. package/build/field-types/utils/render-from-elements.js.map +7 -0
  183. package/build/hooks/index.js +39 -0
  184. package/build/hooks/index.js.map +7 -0
  185. package/build/hooks/use-elements.js +63 -0
  186. package/build/hooks/use-elements.js.map +7 -0
  187. package/build/hooks/use-form-validity.js +426 -0
  188. package/build/hooks/use-form-validity.js.map +7 -0
  189. package/build/index.js +50 -45
  190. package/build/index.js.map +7 -1
  191. package/build/lock-unlock.js +31 -14
  192. package/build/lock-unlock.js.map +7 -1
  193. package/build/types/dataform.js +17 -0
  194. package/build/types/dataform.js.map +7 -0
  195. package/build/types/dataviews.js +17 -0
  196. package/build/types/dataviews.js.map +7 -0
  197. package/build/types/field-api.js +17 -0
  198. package/build/types/field-api.js.map +7 -0
  199. package/build/types/index.js +17 -0
  200. package/build/types/index.js.map +7 -0
  201. package/build/types/private.js +17 -0
  202. package/build/types/private.js.map +7 -0
  203. package/build/utils/filter-sort-and-paginate.js +285 -0
  204. package/build/utils/filter-sort-and-paginate.js.map +7 -0
  205. package/build/utils/has-elements.js +27 -0
  206. package/build/utils/has-elements.js.map +7 -0
  207. package/build/utils/normalize-fields.js +160 -0
  208. package/build/utils/normalize-fields.js.map +7 -0
  209. package/build-module/components/dataform/index.js +25 -25
  210. package/build-module/components/dataform/index.js.map +7 -1
  211. package/build-module/components/dataform-context/index.js +11 -19
  212. package/build-module/components/dataform-context/index.js.map +7 -1
  213. package/build-module/components/dataviews/index.js +154 -127
  214. package/build-module/components/dataviews/index.js.map +7 -1
  215. package/build-module/components/dataviews-bulk-actions/index.js +227 -140
  216. package/build-module/components/dataviews-bulk-actions/index.js.map +7 -1
  217. package/build-module/components/dataviews-context/index.js +20 -30
  218. package/build-module/components/dataviews-context/index.js.map +7 -1
  219. package/build-module/components/dataviews-filters/add-filter.js +60 -68
  220. package/build-module/components/dataviews-filters/add-filter.js.map +7 -1
  221. package/build-module/components/dataviews-filters/filter.js +454 -232
  222. package/build-module/components/dataviews-filters/filter.js.map +7 -1
  223. package/build-module/components/dataviews-filters/filters-toggled.js +11 -19
  224. package/build-module/components/dataviews-filters/filters-toggled.js.map +7 -1
  225. package/build-module/components/dataviews-filters/filters.js +65 -59
  226. package/build-module/components/dataviews-filters/filters.js.map +7 -1
  227. package/build-module/components/dataviews-filters/index.js +11 -5
  228. package/build-module/components/dataviews-filters/index.js.map +7 -1
  229. package/build-module/components/dataviews-filters/input-widget.js +57 -81
  230. package/build-module/components/dataviews-filters/input-widget.js.map +7 -1
  231. package/build-module/components/dataviews-filters/reset-filters.js +33 -30
  232. package/build-module/components/dataviews-filters/reset-filters.js.map +7 -1
  233. package/build-module/components/dataviews-filters/search-widget.js +276 -195
  234. package/build-module/components/dataviews-filters/search-widget.js.map +7 -1
  235. package/build-module/components/dataviews-filters/toggle.js +58 -55
  236. package/build-module/components/dataviews-filters/toggle.js.map +7 -1
  237. package/build-module/components/dataviews-filters/use-filters.js +21 -23
  238. package/build-module/components/dataviews-filters/use-filters.js.map +7 -1
  239. package/build-module/components/dataviews-filters/utils.js +5 -6
  240. package/build-module/components/dataviews-filters/utils.js.map +7 -1
  241. package/build-module/components/dataviews-footer/index.js +28 -26
  242. package/build-module/components/dataviews-footer/index.js.map +7 -1
  243. package/build-module/components/dataviews-item-actions/index.js +171 -144
  244. package/build-module/components/dataviews-item-actions/index.js.map +7 -1
  245. package/build-module/components/dataviews-layout/index.js +35 -42
  246. package/build-module/components/dataviews-layout/index.js.map +7 -1
  247. package/build-module/components/dataviews-pagination/index.js +115 -92
  248. package/build-module/components/dataviews-pagination/index.js.map +7 -1
  249. package/build-module/components/dataviews-picker/footer.js +122 -93
  250. package/build-module/components/dataviews-picker/footer.js.map +7 -1
  251. package/build-module/components/dataviews-picker/index.js +137 -121
  252. package/build-module/components/dataviews-picker/index.js.map +7 -1
  253. package/build-module/components/dataviews-search/index.js +30 -35
  254. package/build-module/components/dataviews-search/index.js.map +7 -1
  255. package/build-module/components/dataviews-selection-checkbox/index.js +28 -31
  256. package/build-module/components/dataviews-selection-checkbox/index.js.map +7 -1
  257. package/build-module/components/dataviews-view-config/index.js +579 -504
  258. package/build-module/components/dataviews-view-config/index.js.map +7 -1
  259. package/build-module/components/dataviews-view-config/infinite-scroll-toggle.js +28 -33
  260. package/build-module/components/dataviews-view-config/infinite-scroll-toggle.js.map +7 -1
  261. package/build-module/constants.js +157 -101
  262. package/build-module/constants.js.map +7 -1
  263. package/build-module/dataform-controls/array.js +82 -141
  264. package/build-module/dataform-controls/array.js.map +7 -1
  265. package/build-module/dataform-controls/checkbox.js +28 -61
  266. package/build-module/dataform-controls/checkbox.js.map +7 -1
  267. package/build-module/dataform-controls/color.js +89 -115
  268. package/build-module/dataform-controls/color.js.map +7 -1
  269. package/build-module/dataform-controls/date.js +524 -337
  270. package/build-module/dataform-controls/date.js.map +7 -1
  271. package/build-module/dataform-controls/datetime.js +162 -139
  272. package/build-module/dataform-controls/datetime.js.map +7 -1
  273. package/build-module/dataform-controls/email.js +28 -28
  274. package/build-module/dataform-controls/email.js.map +7 -1
  275. package/build-module/dataform-controls/index.js +36 -43
  276. package/build-module/dataform-controls/index.js.map +7 -1
  277. package/build-module/dataform-controls/integer.js +8 -123
  278. package/build-module/dataform-controls/integer.js.map +7 -1
  279. package/build-module/dataform-controls/number.js +9 -0
  280. package/build-module/dataform-controls/number.js.map +7 -0
  281. package/build-module/dataform-controls/password.js +37 -30
  282. package/build-module/dataform-controls/password.js.map +7 -1
  283. package/build-module/dataform-controls/radio.js +34 -60
  284. package/build-module/dataform-controls/radio.js.map +7 -1
  285. package/build-module/dataform-controls/select.js +43 -84
  286. package/build-module/dataform-controls/select.js.map +7 -1
  287. package/build-module/dataform-controls/telephone.js +28 -28
  288. package/build-module/dataform-controls/telephone.js.map +7 -1
  289. package/build-module/dataform-controls/text.js +25 -26
  290. package/build-module/dataform-controls/text.js.map +7 -1
  291. package/build-module/dataform-controls/textarea.js +35 -67
  292. package/build-module/dataform-controls/textarea.js.map +7 -1
  293. package/build-module/dataform-controls/toggle-group.js +50 -62
  294. package/build-module/dataform-controls/toggle-group.js.map +7 -1
  295. package/build-module/dataform-controls/toggle.js +29 -62
  296. package/build-module/dataform-controls/toggle.js.map +7 -1
  297. package/build-module/dataform-controls/url.js +28 -28
  298. package/build-module/dataform-controls/url.js.map +7 -1
  299. package/build-module/dataform-controls/utils/get-custom-validity.js +15 -0
  300. package/build-module/dataform-controls/utils/get-custom-validity.js.map +7 -0
  301. package/build-module/dataform-controls/utils/relative-date-control.js +97 -0
  302. package/build-module/dataform-controls/utils/relative-date-control.js.map +7 -0
  303. package/build-module/dataform-controls/utils/validated-input.js +40 -67
  304. package/build-module/dataform-controls/utils/validated-input.js.map +7 -1
  305. package/build-module/dataform-controls/utils/validated-number.js +142 -0
  306. package/build-module/dataform-controls/utils/validated-number.js.map +7 -0
  307. package/build-module/dataform-layouts/card/index.js +183 -0
  308. package/build-module/dataform-layouts/card/index.js.map +7 -0
  309. package/build-module/dataform-layouts/data-form-layout.js +61 -0
  310. package/build-module/dataform-layouts/data-form-layout.js.map +7 -0
  311. package/build-module/dataform-layouts/get-summary-fields.js +21 -0
  312. package/build-module/dataform-layouts/get-summary-fields.js.map +7 -0
  313. package/build-module/dataform-layouts/index.js +68 -0
  314. package/build-module/dataform-layouts/index.js.map +7 -0
  315. package/build-module/dataform-layouts/is-combined-field.js +7 -0
  316. package/build-module/dataform-layouts/is-combined-field.js.map +7 -0
  317. package/build-module/dataform-layouts/normalize-form-fields.js +79 -0
  318. package/build-module/dataform-layouts/normalize-form-fields.js.map +7 -0
  319. package/build-module/dataform-layouts/panel/dropdown.js +136 -0
  320. package/build-module/dataform-layouts/panel/dropdown.js.map +7 -0
  321. package/build-module/dataform-layouts/panel/index.js +125 -0
  322. package/build-module/dataform-layouts/panel/index.js.map +7 -0
  323. package/build-module/dataform-layouts/panel/modal.js +151 -0
  324. package/build-module/dataform-layouts/panel/modal.js.map +7 -0
  325. package/build-module/dataform-layouts/panel/summary-button.js +73 -0
  326. package/build-module/dataform-layouts/panel/summary-button.js.map +7 -0
  327. package/build-module/dataform-layouts/regular/index.js +115 -0
  328. package/build-module/dataform-layouts/regular/index.js.map +7 -0
  329. package/build-module/dataform-layouts/row/index.js +95 -0
  330. package/build-module/dataform-layouts/row/index.js.map +7 -0
  331. package/build-module/dataviews-layouts/grid/index.js +316 -267
  332. package/build-module/dataviews-layouts/grid/index.js.map +7 -1
  333. package/build-module/dataviews-layouts/grid/preview-size-picker.js +66 -63
  334. package/build-module/dataviews-layouts/grid/preview-size-picker.js.map +7 -1
  335. package/build-module/dataviews-layouts/index.js +53 -42
  336. package/build-module/dataviews-layouts/index.js.map +7 -1
  337. package/build-module/dataviews-layouts/list/index.js +422 -339
  338. package/build-module/dataviews-layouts/list/index.js.map +7 -1
  339. package/build-module/dataviews-layouts/picker-grid/index.js +344 -291
  340. package/build-module/dataviews-layouts/picker-grid/index.js.map +7 -1
  341. package/build-module/dataviews-layouts/table/column-header-menu.js +129 -127
  342. package/build-module/dataviews-layouts/table/column-header-menu.js.map +7 -1
  343. package/build-module/dataviews-layouts/table/column-primary.js +71 -62
  344. package/build-module/dataviews-layouts/table/column-primary.js.map +7 -1
  345. package/build-module/dataviews-layouts/table/density-picker.js +61 -40
  346. package/build-module/dataviews-layouts/table/density-picker.js.map +7 -1
  347. package/build-module/dataviews-layouts/table/index.js +326 -302
  348. package/build-module/dataviews-layouts/table/index.js.map +7 -1
  349. package/build-module/dataviews-layouts/table/use-is-horizontal-scroll-end.js +31 -40
  350. package/build-module/dataviews-layouts/table/use-is-horizontal-scroll-end.js.map +7 -1
  351. package/build-module/dataviews-layouts/utils/get-data-by-group.js +7 -10
  352. package/build-module/dataviews-layouts/utils/get-data-by-group.js.map +7 -1
  353. package/build-module/dataviews-layouts/utils/grid-items.js +19 -28
  354. package/build-module/dataviews-layouts/utils/grid-items.js.map +7 -1
  355. package/build-module/dataviews-layouts/utils/item-click-wrapper.js +32 -28
  356. package/build-module/dataviews-layouts/utils/item-click-wrapper.js.map +7 -1
  357. package/build-module/dataviews-layouts/utils/preview-size-picker.js +66 -63
  358. package/build-module/dataviews-layouts/utils/preview-size-picker.js.map +7 -1
  359. package/build-module/field-types/array.js +32 -37
  360. package/build-module/field-types/array.js.map +7 -1
  361. package/build-module/field-types/boolean.js +22 -41
  362. package/build-module/field-types/boolean.js.map +7 -1
  363. package/build-module/field-types/color.js +51 -72
  364. package/build-module/field-types/color.js.map +7 -1
  365. package/build-module/field-types/date.js +51 -44
  366. package/build-module/field-types/date.js.map +7 -1
  367. package/build-module/field-types/datetime.js +43 -39
  368. package/build-module/field-types/datetime.js.map +7 -1
  369. package/build-module/field-types/email.js +39 -42
  370. package/build-module/field-types/email.js.map +7 -1
  371. package/build-module/field-types/index.js +43 -72
  372. package/build-module/field-types/index.js.map +7 -1
  373. package/build-module/field-types/integer.js +52 -41
  374. package/build-module/field-types/integer.js.map +7 -1
  375. package/build-module/field-types/media.js +7 -23
  376. package/build-module/field-types/media.js.map +7 -1
  377. package/build-module/field-types/number.js +77 -0
  378. package/build-module/field-types/number.js.map +7 -0
  379. package/build-module/field-types/password.js +12 -36
  380. package/build-module/field-types/password.js.map +7 -1
  381. package/build-module/field-types/telephone.js +36 -40
  382. package/build-module/field-types/telephone.js.map +7 -1
  383. package/build-module/field-types/text.js +36 -41
  384. package/build-module/field-types/text.js.map +7 -1
  385. package/build-module/field-types/url.js +36 -40
  386. package/build-module/field-types/url.js.map +7 -1
  387. package/build-module/field-types/utils/render-from-elements.js +22 -0
  388. package/build-module/field-types/utils/render-from-elements.js.map +7 -0
  389. package/build-module/hooks/index.js +5 -0
  390. package/build-module/hooks/index.js.map +7 -0
  391. package/build-module/hooks/use-elements.js +43 -0
  392. package/build-module/hooks/use-elements.js.map +7 -0
  393. package/build-module/hooks/use-form-validity.js +392 -0
  394. package/build-module/hooks/use-form-validity.js.map +7 -0
  395. package/build-module/index.js +15 -7
  396. package/build-module/index.js.map +7 -1
  397. package/build-module/lock-unlock.js +8 -7
  398. package/build-module/lock-unlock.js.map +7 -1
  399. package/build-module/types/dataform.js +1 -0
  400. package/build-module/types/dataform.js.map +7 -0
  401. package/build-module/types/dataviews.js +1 -0
  402. package/build-module/types/dataviews.js.map +7 -0
  403. package/build-module/types/field-api.js +1 -0
  404. package/build-module/types/field-api.js.map +7 -0
  405. package/build-module/types/index.js +1 -0
  406. package/build-module/types/index.js.map +7 -0
  407. package/build-module/types/private.js +1 -0
  408. package/build-module/types/private.js.map +7 -0
  409. package/build-module/utils/filter-sort-and-paginate.js +278 -0
  410. package/build-module/utils/filter-sort-and-paginate.js.map +7 -0
  411. package/build-module/utils/has-elements.js +7 -0
  412. package/build-module/utils/has-elements.js.map +7 -0
  413. package/build-module/utils/normalize-fields.js +134 -0
  414. package/build-module/utils/normalize-fields.js.map +7 -0
  415. package/build-style/style-rtl.css +81 -217
  416. package/build-style/style.css +81 -217
  417. package/build-types/components/dataform/index.d.ts +1 -1
  418. package/build-types/components/dataform/index.d.ts.map +1 -1
  419. package/build-types/components/dataform-context/index.d.ts.map +1 -1
  420. package/build-types/components/dataviews-bulk-actions/index.d.ts +1 -1
  421. package/build-types/components/dataviews-bulk-actions/index.d.ts.map +1 -1
  422. package/build-types/components/dataviews-context/index.d.ts +1 -1
  423. package/build-types/components/dataviews-filters/filter.d.ts +1 -1
  424. package/build-types/components/dataviews-filters/filter.d.ts.map +1 -1
  425. package/build-types/components/dataviews-filters/search-widget.d.ts.map +1 -1
  426. package/build-types/components/dataviews-filters/use-filters.d.ts.map +1 -1
  427. package/build-types/components/dataviews-item-actions/index.d.ts.map +1 -1
  428. package/build-types/components/dataviews-picker/footer.d.ts.map +1 -1
  429. package/build-types/components/dataviews-selection-checkbox/index.d.ts +1 -1
  430. package/build-types/dataform-controls/array.d.ts +1 -1
  431. package/build-types/dataform-controls/array.d.ts.map +1 -1
  432. package/build-types/dataform-controls/checkbox.d.ts +1 -1
  433. package/build-types/dataform-controls/checkbox.d.ts.map +1 -1
  434. package/build-types/dataform-controls/color.d.ts +1 -1
  435. package/build-types/dataform-controls/color.d.ts.map +1 -1
  436. package/build-types/dataform-controls/date.d.ts +1 -1
  437. package/build-types/dataform-controls/date.d.ts.map +1 -1
  438. package/build-types/dataform-controls/datetime.d.ts +1 -1
  439. package/build-types/dataform-controls/datetime.d.ts.map +1 -1
  440. package/build-types/dataform-controls/email.d.ts +1 -1
  441. package/build-types/dataform-controls/email.d.ts.map +1 -1
  442. package/build-types/dataform-controls/index.d.ts.map +1 -1
  443. package/build-types/dataform-controls/integer.d.ts +4 -1
  444. package/build-types/dataform-controls/integer.d.ts.map +1 -1
  445. package/build-types/dataform-controls/number.d.ts +6 -0
  446. package/build-types/dataform-controls/number.d.ts.map +1 -0
  447. package/build-types/dataform-controls/password.d.ts +1 -1
  448. package/build-types/dataform-controls/password.d.ts.map +1 -1
  449. package/build-types/dataform-controls/radio.d.ts +1 -1
  450. package/build-types/dataform-controls/radio.d.ts.map +1 -1
  451. package/build-types/dataform-controls/select.d.ts +1 -1
  452. package/build-types/dataform-controls/select.d.ts.map +1 -1
  453. package/build-types/dataform-controls/telephone.d.ts +1 -1
  454. package/build-types/dataform-controls/telephone.d.ts.map +1 -1
  455. package/build-types/dataform-controls/text.d.ts +1 -1
  456. package/build-types/dataform-controls/text.d.ts.map +1 -1
  457. package/build-types/dataform-controls/textarea.d.ts +1 -1
  458. package/build-types/dataform-controls/textarea.d.ts.map +1 -1
  459. package/build-types/dataform-controls/toggle-group.d.ts +1 -1
  460. package/build-types/dataform-controls/toggle-group.d.ts.map +1 -1
  461. package/build-types/dataform-controls/toggle.d.ts +1 -1
  462. package/build-types/dataform-controls/toggle.d.ts.map +1 -1
  463. package/build-types/dataform-controls/url.d.ts +1 -1
  464. package/build-types/dataform-controls/url.d.ts.map +1 -1
  465. package/build-types/dataform-controls/utils/get-custom-validity.d.ts +9 -0
  466. package/build-types/dataform-controls/utils/get-custom-validity.d.ts.map +1 -0
  467. package/build-types/dataform-controls/utils/relative-date-control.d.ts +5 -0
  468. package/build-types/dataform-controls/utils/relative-date-control.d.ts.map +1 -0
  469. package/build-types/dataform-controls/utils/validated-input.d.ts +1 -1
  470. package/build-types/dataform-controls/utils/validated-input.d.ts.map +1 -1
  471. package/build-types/dataform-controls/utils/validated-number.d.ts +9 -0
  472. package/build-types/dataform-controls/utils/validated-number.d.ts.map +1 -0
  473. package/build-types/{dataforms-layouts → dataform-layouts}/card/index.d.ts +1 -1
  474. package/build-types/dataform-layouts/card/index.d.ts.map +1 -0
  475. package/build-types/{dataforms-layouts → dataform-layouts}/data-form-layout.d.ts +5 -3
  476. package/build-types/dataform-layouts/data-form-layout.d.ts.map +1 -0
  477. package/build-types/dataform-layouts/get-summary-fields.d.ts +12 -0
  478. package/build-types/dataform-layouts/get-summary-fields.d.ts.map +1 -0
  479. package/build-types/{dataforms-layouts → dataform-layouts}/index.d.ts +0 -5
  480. package/build-types/dataform-layouts/index.d.ts.map +1 -0
  481. package/build-types/dataform-layouts/is-combined-field.d.ts.map +1 -0
  482. package/build-types/{normalize-form-fields.d.ts → dataform-layouts/normalize-form-fields.d.ts} +1 -1
  483. package/build-types/dataform-layouts/normalize-form-fields.d.ts.map +1 -0
  484. package/build-types/{dataforms-layouts → dataform-layouts}/panel/dropdown.d.ts +8 -7
  485. package/build-types/dataform-layouts/panel/dropdown.d.ts.map +1 -0
  486. package/build-types/{dataforms-layouts → dataform-layouts}/panel/index.d.ts +1 -1
  487. package/build-types/dataform-layouts/panel/index.d.ts.map +1 -0
  488. package/build-types/{dataforms-layouts → dataform-layouts}/panel/modal.d.ts +5 -5
  489. package/build-types/dataform-layouts/panel/modal.d.ts.map +1 -0
  490. package/build-types/dataform-layouts/panel/summary-button.d.ts.map +1 -0
  491. package/build-types/{dataforms-layouts → dataform-layouts}/regular/index.d.ts +1 -1
  492. package/build-types/dataform-layouts/regular/index.d.ts.map +1 -0
  493. package/build-types/{dataforms-layouts → dataform-layouts}/row/index.d.ts +1 -1
  494. package/build-types/dataform-layouts/row/index.d.ts.map +1 -0
  495. package/build-types/dataviews-layouts/list/index.d.ts.map +1 -1
  496. package/build-types/dataviews-layouts/utils/item-click-wrapper.d.ts +1 -1
  497. package/build-types/dataviews-layouts/utils/item-click-wrapper.d.ts.map +1 -1
  498. package/build-types/field-types/array.d.ts.map +1 -1
  499. package/build-types/field-types/boolean.d.ts +2 -1
  500. package/build-types/field-types/boolean.d.ts.map +1 -1
  501. package/build-types/field-types/color.d.ts +2 -1
  502. package/build-types/field-types/color.d.ts.map +1 -1
  503. package/build-types/field-types/date.d.ts +4 -3
  504. package/build-types/field-types/date.d.ts.map +1 -1
  505. package/build-types/field-types/datetime.d.ts +3 -2
  506. package/build-types/field-types/datetime.d.ts.map +1 -1
  507. package/build-types/field-types/email.d.ts +3 -2
  508. package/build-types/field-types/email.d.ts.map +1 -1
  509. package/build-types/field-types/index.d.ts.map +1 -1
  510. package/build-types/field-types/integer.d.ts +2 -1
  511. package/build-types/field-types/integer.d.ts.map +1 -1
  512. package/build-types/field-types/media.d.ts +2 -5
  513. package/build-types/field-types/media.d.ts.map +1 -1
  514. package/build-types/field-types/number.d.ts +21 -0
  515. package/build-types/field-types/number.d.ts.map +1 -0
  516. package/build-types/field-types/password.d.ts +4 -3
  517. package/build-types/field-types/password.d.ts.map +1 -1
  518. package/build-types/field-types/telephone.d.ts +4 -3
  519. package/build-types/field-types/telephone.d.ts.map +1 -1
  520. package/build-types/field-types/text.d.ts +4 -3
  521. package/build-types/field-types/text.d.ts.map +1 -1
  522. package/build-types/field-types/url.d.ts +4 -3
  523. package/build-types/field-types/url.d.ts.map +1 -1
  524. package/build-types/field-types/utils/render-from-elements.d.ts +6 -0
  525. package/build-types/field-types/utils/render-from-elements.d.ts.map +1 -0
  526. package/build-types/hooks/index.d.ts +5 -0
  527. package/build-types/hooks/index.d.ts.map +1 -0
  528. package/build-types/hooks/use-elements.d.ts +12 -0
  529. package/build-types/hooks/use-elements.d.ts.map +1 -0
  530. package/build-types/hooks/use-form-validity.d.ts +16 -0
  531. package/build-types/hooks/use-form-validity.d.ts.map +1 -0
  532. package/build-types/index.d.ts +2 -2
  533. package/build-types/index.d.ts.map +1 -1
  534. package/build-types/{components/dataform/stories/index.story.d.ts → stories/dataform.story.d.ts} +16 -6
  535. package/build-types/stories/dataform.story.d.ts.map +1 -0
  536. package/build-types/{components/dataviews-picker/stories/index.story.d.ts → stories/dataviews-picker.story.d.ts} +2 -2
  537. package/build-types/stories/dataviews-picker.story.d.ts.map +1 -0
  538. package/build-types/{components/dataviews/stories/fixtures.d.ts → stories/dataviews.fixtures.d.ts} +2 -2
  539. package/build-types/stories/dataviews.fixtures.d.ts.map +1 -0
  540. package/build-types/{components/dataviews/stories/index.story.d.ts → stories/dataviews.story.d.ts} +3 -3
  541. package/build-types/stories/dataviews.story.d.ts.map +1 -0
  542. package/build-types/stories/field-types.story.d.ts +157 -0
  543. package/build-types/stories/field-types.story.d.ts.map +1 -0
  544. package/build-types/test/use-form-validity.d.ts +2 -0
  545. package/build-types/test/use-form-validity.d.ts.map +1 -0
  546. package/build-types/types/dataform.d.ts +112 -0
  547. package/build-types/types/dataform.d.ts.map +1 -0
  548. package/build-types/types/dataviews.d.ts +341 -0
  549. package/build-types/types/dataviews.d.ts.map +1 -0
  550. package/build-types/types/field-api.d.ts +298 -0
  551. package/build-types/types/field-api.d.ts.map +1 -0
  552. package/build-types/types/index.d.ts +4 -0
  553. package/build-types/types/index.d.ts.map +1 -0
  554. package/build-types/{private-types.d.ts → types/private.d.ts} +1 -1
  555. package/build-types/types/private.d.ts.map +1 -0
  556. package/build-types/{filter-and-sort-data-view.d.ts → utils/filter-sort-and-paginate.d.ts} +3 -3
  557. package/build-types/utils/filter-sort-and-paginate.d.ts.map +1 -0
  558. package/build-types/utils/has-elements.d.ts +6 -0
  559. package/build-types/utils/has-elements.d.ts.map +1 -0
  560. package/build-types/utils/normalize-fields.d.ts +9 -0
  561. package/build-types/utils/normalize-fields.d.ts.map +1 -0
  562. package/build-wp/index.js +3151 -2714
  563. package/package.json +16 -18
  564. package/src/components/dataform/index.tsx +9 -3
  565. package/src/components/dataform-context/index.tsx +3 -1
  566. package/src/components/dataviews/index.tsx +2 -2
  567. package/src/components/dataviews/style.scss +4 -0
  568. package/src/components/dataviews-bulk-actions/index.tsx +1 -2
  569. package/src/components/dataviews-bulk-actions/style.scss +3 -0
  570. package/src/components/dataviews-context/index.ts +1 -1
  571. package/src/components/dataviews-filters/filter.tsx +11 -5
  572. package/src/components/dataviews-filters/search-widget.tsx +30 -3
  573. package/src/components/dataviews-filters/style.scss +21 -6
  574. package/src/components/dataviews-filters/use-filters.ts +4 -2
  575. package/src/components/dataviews-footer/style.scss +4 -0
  576. package/src/components/dataviews-item-actions/index.tsx +6 -2
  577. package/src/components/dataviews-item-actions/style.scss +3 -0
  578. package/src/components/dataviews-pagination/style.scss +3 -0
  579. package/src/components/dataviews-picker/footer.tsx +2 -4
  580. package/src/components/dataviews-picker/index.tsx +2 -2
  581. package/src/components/dataviews-picker/style.scss +2 -0
  582. package/src/components/dataviews-selection-checkbox/index.tsx +1 -1
  583. package/src/components/dataviews-selection-checkbox/style.scss +3 -0
  584. package/src/components/dataviews-view-config/style.scss +3 -0
  585. package/src/dataform-controls/array.tsx +16 -82
  586. package/src/dataform-controls/checkbox.tsx +5 -41
  587. package/src/dataform-controls/color.tsx +5 -37
  588. package/src/dataform-controls/date.tsx +375 -238
  589. package/src/dataform-controls/datetime.tsx +92 -60
  590. package/src/dataform-controls/email.tsx +2 -0
  591. package/src/dataform-controls/index.tsx +4 -1
  592. package/src/dataform-controls/integer.tsx +3 -179
  593. package/src/dataform-controls/number.tsx +10 -0
  594. package/src/dataform-controls/password.tsx +2 -0
  595. package/src/dataform-controls/radio.tsx +24 -55
  596. package/src/dataform-controls/select.tsx +14 -61
  597. package/src/dataform-controls/style.scss +2 -0
  598. package/src/dataform-controls/telephone.tsx +2 -0
  599. package/src/dataform-controls/text.tsx +2 -0
  600. package/src/dataform-controls/textarea.tsx +6 -42
  601. package/src/dataform-controls/toggle-group.tsx +38 -64
  602. package/src/dataform-controls/toggle.tsx +6 -42
  603. package/src/dataform-controls/url.tsx +2 -0
  604. package/src/dataform-controls/utils/get-custom-validity.ts +24 -0
  605. package/src/dataform-controls/{relative-date-control.tsx → utils/relative-date-control.tsx} +37 -25
  606. package/src/dataform-controls/utils/validated-input.tsx +4 -40
  607. package/src/dataform-controls/utils/validated-number.tsx +171 -0
  608. package/src/{dataforms-layouts → dataform-layouts}/card/index.tsx +106 -8
  609. package/src/dataform-layouts/card/style.scss +24 -0
  610. package/src/{dataforms-layouts → dataform-layouts}/data-form-layout.tsx +22 -5
  611. package/src/dataform-layouts/get-summary-fields.ts +42 -0
  612. package/src/{dataforms-layouts → dataform-layouts}/index.tsx +32 -2
  613. package/src/{normalize-form-fields.ts → dataform-layouts/normalize-form-fields.ts} +28 -1
  614. package/src/{dataforms-layouts → dataform-layouts}/panel/dropdown.tsx +36 -15
  615. package/src/{dataforms-layouts → dataform-layouts}/panel/index.tsx +88 -55
  616. package/src/{dataforms-layouts → dataform-layouts}/panel/modal.tsx +42 -31
  617. package/src/{dataforms-layouts → dataform-layouts}/panel/style.scss +3 -0
  618. package/src/{dataforms-layouts → dataform-layouts}/regular/index.tsx +5 -1
  619. package/src/{dataforms-layouts → dataform-layouts}/regular/style.scss +2 -0
  620. package/src/{dataforms-layouts → dataform-layouts}/row/index.tsx +9 -4
  621. package/src/dataform-layouts/style.scss +5 -0
  622. package/src/dataviews-layouts/grid/index.tsx +1 -1
  623. package/src/dataviews-layouts/grid/style.scss +8 -3
  624. package/src/dataviews-layouts/list/index.tsx +0 -2
  625. package/src/dataviews-layouts/list/style.scss +3 -0
  626. package/src/dataviews-layouts/picker-grid/index.tsx +1 -1
  627. package/src/dataviews-layouts/picker-grid/style.scss +8 -4
  628. package/src/dataviews-layouts/table/column-header-menu.tsx +1 -1
  629. package/src/dataviews-layouts/table/index.tsx +1 -1
  630. package/src/dataviews-layouts/table/style.scss +9 -0
  631. package/src/dataviews-layouts/utils/grid-items.scss +2 -0
  632. package/src/dataviews-layouts/utils/item-click-wrapper.tsx +40 -2
  633. package/src/field-types/array.tsx +1 -0
  634. package/src/field-types/boolean.tsx +4 -3
  635. package/src/field-types/color.tsx +4 -10
  636. package/src/field-types/{date.ts → date.tsx} +5 -16
  637. package/src/field-types/datetime.tsx +8 -21
  638. package/src/field-types/email.tsx +7 -11
  639. package/src/field-types/index.tsx +13 -23
  640. package/src/field-types/integer.tsx +7 -11
  641. package/src/field-types/media.tsx +3 -17
  642. package/src/field-types/number.tsx +92 -0
  643. package/src/field-types/password.tsx +8 -21
  644. package/src/field-types/telephone.tsx +8 -21
  645. package/src/field-types/text.tsx +8 -21
  646. package/src/field-types/url.tsx +8 -21
  647. package/src/field-types/utils/render-from-elements.tsx +29 -0
  648. package/src/hooks/index.ts +4 -0
  649. package/src/hooks/use-elements.ts +66 -0
  650. package/src/hooks/use-form-validity.ts +571 -0
  651. package/src/index.ts +2 -2
  652. package/src/{components/dataform/stories/index.story.tsx → stories/dataform.story.tsx} +455 -63
  653. package/src/{components/dataviews-picker/stories/index.story.tsx → stories/dataviews-picker.story.tsx} +5 -9
  654. package/src/{components/dataviews/stories/fixtures.tsx → stories/dataviews.fixtures.tsx} +36 -5
  655. package/src/{components/dataviews/stories/index.story.tsx → stories/dataviews.story.tsx} +7 -8
  656. package/src/{field-types/stories/index.story.tsx → stories/field-types.story.tsx} +244 -48
  657. package/src/style.scss +19 -18
  658. package/src/test/dataform.tsx +36 -0
  659. package/src/test/dataviews-picker.tsx +1 -1
  660. package/src/test/dataviews.tsx +1 -2
  661. package/src/test/{filter-and-sort-data-view.js → filter-sort-and-paginate.js} +63 -16
  662. package/src/test/normalize-fields.ts +23 -1
  663. package/src/test/normalize-form-fields.ts +54 -5
  664. package/src/test/use-form-validity.ts +546 -0
  665. package/src/types/dataform.ts +144 -0
  666. package/src/types/dataviews.ts +443 -0
  667. package/src/types/field-api.ts +381 -0
  668. package/src/types/index.ts +3 -0
  669. package/src/{filter-and-sort-data-view.ts → utils/filter-sort-and-paginate.ts} +4 -4
  670. package/src/utils/has-elements.ts +11 -0
  671. package/src/{normalize-fields.ts → utils/normalize-fields.ts} +13 -8
  672. package/tsconfig.tsbuildinfo +1 -1
  673. package/build/dataform-controls/relative-date-control.js +0 -105
  674. package/build/dataform-controls/relative-date-control.js.map +0 -1
  675. package/build/dataforms-layouts/card/index.js +0 -136
  676. package/build/dataforms-layouts/card/index.js.map +0 -1
  677. package/build/dataforms-layouts/data-form-layout.js +0 -71
  678. package/build/dataforms-layouts/data-form-layout.js.map +0 -1
  679. package/build/dataforms-layouts/index.js +0 -58
  680. package/build/dataforms-layouts/index.js.map +0 -1
  681. package/build/dataforms-layouts/is-combined-field.js +0 -14
  682. package/build/dataforms-layouts/is-combined-field.js.map +0 -1
  683. package/build/dataforms-layouts/panel/dropdown.js +0 -120
  684. package/build/dataforms-layouts/panel/dropdown.js.map +0 -1
  685. package/build/dataforms-layouts/panel/index.js +0 -126
  686. package/build/dataforms-layouts/panel/index.js.map +0 -1
  687. package/build/dataforms-layouts/panel/modal.js +0 -120
  688. package/build/dataforms-layouts/panel/modal.js.map +0 -1
  689. package/build/dataforms-layouts/panel/summary-button.js +0 -67
  690. package/build/dataforms-layouts/panel/summary-button.js.map +0 -1
  691. package/build/dataforms-layouts/regular/index.js +0 -116
  692. package/build/dataforms-layouts/regular/index.js.map +0 -1
  693. package/build/dataforms-layouts/row/index.js +0 -113
  694. package/build/dataforms-layouts/row/index.js.map +0 -1
  695. package/build/filter-and-sort-data-view.js +0 -313
  696. package/build/filter-and-sort-data-view.js.map +0 -1
  697. package/build/normalize-fields.js +0 -155
  698. package/build/normalize-fields.js.map +0 -1
  699. package/build/normalize-form-fields.js +0 -81
  700. package/build/normalize-form-fields.js.map +0 -1
  701. package/build/private-types.js +0 -6
  702. package/build/private-types.js.map +0 -1
  703. package/build/types.js +0 -6
  704. package/build/types.js.map +0 -1
  705. package/build/utils.js +0 -22
  706. package/build/utils.js.map +0 -1
  707. package/build/validation.js +0 -61
  708. package/build/validation.js.map +0 -1
  709. package/build-module/dataform-controls/relative-date-control.js +0 -96
  710. package/build-module/dataform-controls/relative-date-control.js.map +0 -1
  711. package/build-module/dataforms-layouts/card/index.js +0 -127
  712. package/build-module/dataforms-layouts/card/index.js.map +0 -1
  713. package/build-module/dataforms-layouts/data-form-layout.js +0 -62
  714. package/build-module/dataforms-layouts/data-form-layout.js.map +0 -1
  715. package/build-module/dataforms-layouts/index.js +0 -51
  716. package/build-module/dataforms-layouts/index.js.map +0 -1
  717. package/build-module/dataforms-layouts/is-combined-field.js +0 -8
  718. package/build-module/dataforms-layouts/is-combined-field.js.map +0 -1
  719. package/build-module/dataforms-layouts/panel/dropdown.js +0 -113
  720. package/build-module/dataforms-layouts/panel/dropdown.js.map +0 -1
  721. package/build-module/dataforms-layouts/panel/index.js +0 -119
  722. package/build-module/dataforms-layouts/panel/index.js.map +0 -1
  723. package/build-module/dataforms-layouts/panel/modal.js +0 -113
  724. package/build-module/dataforms-layouts/panel/modal.js.map +0 -1
  725. package/build-module/dataforms-layouts/panel/summary-button.js +0 -60
  726. package/build-module/dataforms-layouts/panel/summary-button.js.map +0 -1
  727. package/build-module/dataforms-layouts/regular/index.js +0 -109
  728. package/build-module/dataforms-layouts/regular/index.js.map +0 -1
  729. package/build-module/dataforms-layouts/row/index.js +0 -106
  730. package/build-module/dataforms-layouts/row/index.js.map +0 -1
  731. package/build-module/filter-and-sort-data-view.js +0 -305
  732. package/build-module/filter-and-sort-data-view.js.map +0 -1
  733. package/build-module/normalize-fields.js +0 -145
  734. package/build-module/normalize-fields.js.map +0 -1
  735. package/build-module/normalize-form-fields.js +0 -73
  736. package/build-module/normalize-form-fields.js.map +0 -1
  737. package/build-module/private-types.js +0 -2
  738. package/build-module/private-types.js.map +0 -1
  739. package/build-module/types.js +0 -2
  740. package/build-module/types.js.map +0 -1
  741. package/build-module/utils.js +0 -16
  742. package/build-module/utils.js.map +0 -1
  743. package/build-module/validation.js +0 -54
  744. package/build-module/validation.js.map +0 -1
  745. package/build-types/components/dataform/stories/index.story.d.ts.map +0 -1
  746. package/build-types/components/dataviews/stories/fixtures.d.ts.map +0 -1
  747. package/build-types/components/dataviews/stories/index.story.d.ts.map +0 -1
  748. package/build-types/components/dataviews-picker/stories/index.story.d.ts.map +0 -1
  749. package/build-types/dataform-controls/relative-date-control.d.ts +0 -47
  750. package/build-types/dataform-controls/relative-date-control.d.ts.map +0 -1
  751. package/build-types/dataforms-layouts/card/index.d.ts.map +0 -1
  752. package/build-types/dataforms-layouts/data-form-layout.d.ts.map +0 -1
  753. package/build-types/dataforms-layouts/index.d.ts.map +0 -1
  754. package/build-types/dataforms-layouts/is-combined-field.d.ts.map +0 -1
  755. package/build-types/dataforms-layouts/panel/dropdown.d.ts.map +0 -1
  756. package/build-types/dataforms-layouts/panel/index.d.ts.map +0 -1
  757. package/build-types/dataforms-layouts/panel/modal.d.ts.map +0 -1
  758. package/build-types/dataforms-layouts/panel/summary-button.d.ts.map +0 -1
  759. package/build-types/dataforms-layouts/regular/index.d.ts.map +0 -1
  760. package/build-types/dataforms-layouts/row/index.d.ts.map +0 -1
  761. package/build-types/field-types/stories/index.story.d.ts +0 -85
  762. package/build-types/field-types/stories/index.story.d.ts.map +0 -1
  763. package/build-types/filter-and-sort-data-view.d.ts.map +0 -1
  764. package/build-types/normalize-fields.d.ts +0 -12
  765. package/build-types/normalize-fields.d.ts.map +0 -1
  766. package/build-types/normalize-form-fields.d.ts.map +0 -1
  767. package/build-types/private-types.d.ts.map +0 -1
  768. package/build-types/test/validation.d.ts +0 -2
  769. package/build-types/test/validation.d.ts.map +0 -1
  770. package/build-types/types.d.ts +0 -688
  771. package/build-types/types.d.ts.map +0 -1
  772. package/build-types/utils.d.ts +0 -6
  773. package/build-types/utils.d.ts.map +0 -1
  774. package/build-types/validation.d.ts +0 -12
  775. package/build-types/validation.d.ts.map +0 -1
  776. package/src/dataforms-layouts/card/style.scss +0 -10
  777. package/src/test/validation.ts +0 -312
  778. package/src/types.ts +0 -891
  779. package/src/utils.ts +0 -15
  780. package/src/validation.ts +0 -91
  781. /package/build-types/{dataforms-layouts → dataform-layouts}/is-combined-field.d.ts +0 -0
  782. /package/build-types/{dataforms-layouts → dataform-layouts}/panel/summary-button.d.ts +0 -0
  783. /package/src/{dataforms-layouts → dataform-layouts}/is-combined-field.ts +0 -0
  784. /package/src/{dataforms-layouts → dataform-layouts}/panel/summary-button.tsx +0 -0
  785. /package/src/{dataforms-layouts → dataform-layouts}/row/style.scss +0 -0
  786. /package/src/{components/dataviews/stories/style.css → stories/dataviews.style.css} +0 -0
  787. /package/src/{private-types.tsx → types/private.ts} +0 -0
@@ -0,0 +1,183 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { Button, Card, CardBody, CardHeader } from "@wordpress/components";
3
+ import { useCallback, useContext, useMemo, useState } from "@wordpress/element";
4
+ import { chevronDown, chevronUp } from "@wordpress/icons";
5
+ import { getFormFieldLayout } from "..";
6
+ import DataFormContext from "../../components/dataform-context";
7
+ import { DataFormLayout } from "../data-form-layout";
8
+ import { isCombinedField } from "../is-combined-field";
9
+ import { DEFAULT_LAYOUT, normalizeLayout } from "../normalize-form-fields";
10
+ import { getSummaryFields } from "../get-summary-fields";
11
+ function useCollapsibleCard(initialIsOpen = true) {
12
+ const [isOpen, setIsOpen] = useState(initialIsOpen);
13
+ const toggle = useCallback(() => {
14
+ setIsOpen((prev) => !prev);
15
+ }, []);
16
+ const CollapsibleCardHeader = useCallback(
17
+ ({
18
+ children,
19
+ ...props
20
+ }) => /* @__PURE__ */ jsxs(
21
+ CardHeader,
22
+ {
23
+ ...props,
24
+ onClick: toggle,
25
+ style: {
26
+ cursor: "pointer",
27
+ ...props.style
28
+ },
29
+ children: [
30
+ /* @__PURE__ */ jsx(
31
+ "div",
32
+ {
33
+ style: {
34
+ width: "100%",
35
+ display: "flex",
36
+ justifyContent: "space-between",
37
+ alignItems: "center"
38
+ },
39
+ children
40
+ }
41
+ ),
42
+ /* @__PURE__ */ jsx(
43
+ Button,
44
+ {
45
+ __next40pxDefaultSize: true,
46
+ variant: "tertiary",
47
+ icon: isOpen ? chevronUp : chevronDown,
48
+ "aria-expanded": isOpen,
49
+ "aria-label": isOpen ? "Collapse" : "Expand"
50
+ }
51
+ )
52
+ ]
53
+ }
54
+ ),
55
+ [toggle, isOpen]
56
+ );
57
+ return { isOpen, CollapsibleCardHeader };
58
+ }
59
+ function isSummaryFieldVisible(summaryField, summaryConfig, isOpen) {
60
+ if (!summaryConfig || Array.isArray(summaryConfig) && summaryConfig.length === 0) {
61
+ return false;
62
+ }
63
+ const summaryConfigArray = Array.isArray(summaryConfig) ? summaryConfig : [summaryConfig];
64
+ const fieldConfig = summaryConfigArray.find((config) => {
65
+ if (typeof config === "string") {
66
+ return config === summaryField.id;
67
+ }
68
+ if (typeof config === "object" && "id" in config) {
69
+ return config.id === summaryField.id;
70
+ }
71
+ return false;
72
+ });
73
+ if (!fieldConfig) {
74
+ return false;
75
+ }
76
+ if (typeof fieldConfig === "string") {
77
+ return true;
78
+ }
79
+ if (typeof fieldConfig === "object" && "visibility" in fieldConfig) {
80
+ return fieldConfig.visibility === "always" || fieldConfig.visibility === "when-collapsed" && !isOpen;
81
+ }
82
+ return true;
83
+ }
84
+ function FormCardField({
85
+ data,
86
+ field,
87
+ onChange,
88
+ hideLabelFromVision,
89
+ validity
90
+ }) {
91
+ const { fields } = useContext(DataFormContext);
92
+ const layout = normalizeLayout({
93
+ ...field.layout,
94
+ type: "card"
95
+ });
96
+ const form = useMemo(
97
+ () => ({
98
+ layout: DEFAULT_LAYOUT,
99
+ fields: isCombinedField(field) ? field.children : []
100
+ }),
101
+ [field]
102
+ );
103
+ const { isOpen, CollapsibleCardHeader } = useCollapsibleCard(
104
+ layout.isOpened
105
+ );
106
+ const summaryFields = getSummaryFields(layout.summary, fields);
107
+ const visibleSummaryFields = summaryFields.filter(
108
+ (summaryField) => isSummaryFieldVisible(summaryField, layout.summary, isOpen)
109
+ );
110
+ if (isCombinedField(field)) {
111
+ const withHeader2 = !!field.label && layout.withHeader;
112
+ return /* @__PURE__ */ jsxs(Card, { className: "dataforms-layouts-card__field", children: [
113
+ withHeader2 && /* @__PURE__ */ jsxs(CollapsibleCardHeader, { className: "dataforms-layouts-card__field-header", children: [
114
+ /* @__PURE__ */ jsx("span", { className: "dataforms-layouts-card__field-header-label", children: field.label }),
115
+ visibleSummaryFields.length > 0 && layout.withHeader && /* @__PURE__ */ jsx("div", { className: "dataforms-layouts-card__field-summary", children: visibleSummaryFields.map(
116
+ (summaryField) => /* @__PURE__ */ jsx(
117
+ summaryField.render,
118
+ {
119
+ item: data,
120
+ field: summaryField
121
+ },
122
+ summaryField.id
123
+ )
124
+ ) })
125
+ ] }),
126
+ (isOpen || !withHeader2) && // If it doesn't have a header, keep it open.
127
+ // Otherwise, the card will not be visible.
128
+ /* @__PURE__ */ jsxs(CardBody, { className: "dataforms-layouts-card__field-control", children: [
129
+ field.description && /* @__PURE__ */ jsx("div", { className: "dataforms-layouts-card__field-description", children: field.description }),
130
+ /* @__PURE__ */ jsx(
131
+ DataFormLayout,
132
+ {
133
+ data,
134
+ form,
135
+ onChange,
136
+ validity: validity?.children
137
+ }
138
+ )
139
+ ] })
140
+ ] });
141
+ }
142
+ const fieldDefinition = fields.find(
143
+ (fieldDef) => fieldDef.id === field.id
144
+ );
145
+ if (!fieldDefinition || !fieldDefinition.Edit) {
146
+ return null;
147
+ }
148
+ const RegularLayout = getFormFieldLayout("regular")?.component;
149
+ if (!RegularLayout) {
150
+ return null;
151
+ }
152
+ const withHeader = !!fieldDefinition.label && layout.withHeader;
153
+ return /* @__PURE__ */ jsxs(Card, { className: "dataforms-layouts-card__field", children: [
154
+ withHeader && /* @__PURE__ */ jsxs(CollapsibleCardHeader, { className: "dataforms-layouts-card__field-header", children: [
155
+ /* @__PURE__ */ jsx("span", { className: "dataforms-layouts-card__field-header-label", children: fieldDefinition.label }),
156
+ visibleSummaryFields.length > 0 && layout.withHeader && /* @__PURE__ */ jsx("div", { className: "dataforms-layouts-card__field-summary", children: visibleSummaryFields.map((summaryField) => /* @__PURE__ */ jsx(
157
+ summaryField.render,
158
+ {
159
+ item: data,
160
+ field: summaryField
161
+ },
162
+ summaryField.id
163
+ )) })
164
+ ] }),
165
+ (isOpen || !withHeader) && // If it doesn't have a header, keep it open.
166
+ // Otherwise, the card will not be visible.
167
+ /* @__PURE__ */ jsx(CardBody, { className: "dataforms-layouts-card__field-control", children: /* @__PURE__ */ jsx(
168
+ RegularLayout,
169
+ {
170
+ data,
171
+ field,
172
+ onChange,
173
+ hideLabelFromVision: hideLabelFromVision || withHeader,
174
+ validity
175
+ }
176
+ ) })
177
+ ] });
178
+ }
179
+ export {
180
+ FormCardField as default,
181
+ useCollapsibleCard
182
+ };
183
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/dataform-layouts/card/index.tsx"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { Button, Card, CardBody, CardHeader } from '@wordpress/components';\nimport { useCallback, useContext, useMemo, useState } from '@wordpress/element';\nimport { chevronDown, chevronUp } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { getFormFieldLayout } from '..';\nimport DataFormContext from '../../components/dataform-context';\nimport type {\n\tNormalizedCardLayout,\n\tCardLayout,\n\tFieldLayoutProps,\n\tForm,\n\tLayout,\n\tNormalizedField,\n} from '../../types';\nimport { DataFormLayout } from '../data-form-layout';\nimport { isCombinedField } from '../is-combined-field';\nimport { DEFAULT_LAYOUT, normalizeLayout } from '../normalize-form-fields';\nimport { getSummaryFields } from '../get-summary-fields';\n\nexport function useCollapsibleCard( initialIsOpen: boolean = true ) {\n\tconst [ isOpen, setIsOpen ] = useState( initialIsOpen );\n\n\tconst toggle = useCallback( () => {\n\t\tsetIsOpen( ( prev ) => ! prev );\n\t}, [] );\n\n\tconst CollapsibleCardHeader = useCallback(\n\t\t( {\n\t\t\tchildren,\n\t\t\t...props\n\t\t}: {\n\t\t\tchildren: React.ReactNode;\n\t\t\t[ key: string ]: any;\n\t\t} ) => (\n\t\t\t<CardHeader\n\t\t\t\t{ ...props }\n\t\t\t\tonClick={ toggle }\n\t\t\t\tstyle={ {\n\t\t\t\t\tcursor: 'pointer',\n\t\t\t\t\t...props.style,\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t<div\n\t\t\t\t\tstyle={ {\n\t\t\t\t\t\twidth: '100%',\n\t\t\t\t\t\tdisplay: 'flex',\n\t\t\t\t\t\tjustifyContent: 'space-between',\n\t\t\t\t\t\talignItems: 'center',\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t{ children }\n\t\t\t\t</div>\n\t\t\t\t<Button\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\ticon={ isOpen ? chevronUp : chevronDown }\n\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\taria-label={ isOpen ? 'Collapse' : 'Expand' }\n\t\t\t\t/>\n\t\t\t</CardHeader>\n\t\t),\n\t\t[ toggle, isOpen ]\n\t);\n\n\treturn { isOpen, CollapsibleCardHeader };\n}\n\nfunction isSummaryFieldVisible< Item >(\n\tsummaryField: NormalizedField< Item >,\n\tsummaryConfig: NormalizedCardLayout[ 'summary' ],\n\tisOpen: boolean\n) {\n\t// If no summary config, dont't show any fields\n\tif (\n\t\t! summaryConfig ||\n\t\t( Array.isArray( summaryConfig ) && summaryConfig.length === 0 )\n\t) {\n\t\treturn false;\n\t}\n\n\t// Convert to array for consistent handling\n\tconst summaryConfigArray = Array.isArray( summaryConfig )\n\t\t? summaryConfig\n\t\t: [ summaryConfig ];\n\n\t// Find the config for this specific field\n\tconst fieldConfig = summaryConfigArray.find( ( config ) => {\n\t\tif ( typeof config === 'string' ) {\n\t\t\treturn config === summaryField.id;\n\t\t}\n\t\tif ( typeof config === 'object' && 'id' in config ) {\n\t\t\treturn config.id === summaryField.id;\n\t\t}\n\t\treturn false;\n\t} );\n\n\t// If field is not in summary config, don't show it\n\tif ( ! fieldConfig ) {\n\t\treturn false;\n\t}\n\n\t// If it's a string, always show it\n\tif ( typeof fieldConfig === 'string' ) {\n\t\treturn true;\n\t}\n\n\t// If it has visibility rules, respect them\n\tif ( typeof fieldConfig === 'object' && 'visibility' in fieldConfig ) {\n\t\treturn (\n\t\t\tfieldConfig.visibility === 'always' ||\n\t\t\t( fieldConfig.visibility === 'when-collapsed' && ! isOpen )\n\t\t);\n\t}\n\n\t// Default to always show\n\treturn true;\n}\n\nexport default function FormCardField< Item >( {\n\tdata,\n\tfield,\n\tonChange,\n\thideLabelFromVision,\n\tvalidity,\n}: FieldLayoutProps< Item > ) {\n\tconst { fields } = useContext( DataFormContext );\n\n\tconst layout: NormalizedCardLayout = normalizeLayout( {\n\t\t...field.layout,\n\t\ttype: 'card',\n\t} as CardLayout ) as NormalizedCardLayout;\n\n\tconst form: Form = useMemo(\n\t\t(): Form => ( {\n\t\t\tlayout: DEFAULT_LAYOUT as Layout,\n\t\t\tfields: isCombinedField( field ) ? field.children : [],\n\t\t} ),\n\t\t[ field ]\n\t);\n\n\tconst { isOpen, CollapsibleCardHeader } = useCollapsibleCard(\n\t\tlayout.isOpened\n\t);\n\n\tconst summaryFields = getSummaryFields< Item >( layout.summary, fields );\n\n\tconst visibleSummaryFields = summaryFields.filter( ( summaryField ) =>\n\t\tisSummaryFieldVisible( summaryField, layout.summary, isOpen )\n\t);\n\n\tif ( isCombinedField( field ) ) {\n\t\tconst withHeader = !! field.label && layout.withHeader;\n\t\treturn (\n\t\t\t<Card className=\"dataforms-layouts-card__field\">\n\t\t\t\t{ withHeader && (\n\t\t\t\t\t<CollapsibleCardHeader className=\"dataforms-layouts-card__field-header\">\n\t\t\t\t\t\t<span className=\"dataforms-layouts-card__field-header-label\">\n\t\t\t\t\t\t\t{ field.label }\n\t\t\t\t\t\t</span>\n\t\t\t\t\t\t{ visibleSummaryFields.length > 0 &&\n\t\t\t\t\t\t\tlayout.withHeader && (\n\t\t\t\t\t\t\t\t<div className=\"dataforms-layouts-card__field-summary\">\n\t\t\t\t\t\t\t\t\t{ visibleSummaryFields.map(\n\t\t\t\t\t\t\t\t\t\t( summaryField ) => (\n\t\t\t\t\t\t\t\t\t\t\t<summaryField.render\n\t\t\t\t\t\t\t\t\t\t\t\tkey={ summaryField.id }\n\t\t\t\t\t\t\t\t\t\t\t\titem={ data }\n\t\t\t\t\t\t\t\t\t\t\t\tfield={ summaryField }\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t</CollapsibleCardHeader>\n\t\t\t\t) }\n\t\t\t\t{ ( isOpen || ! withHeader ) && (\n\t\t\t\t\t// If it doesn't have a header, keep it open.\n\t\t\t\t\t// Otherwise, the card will not be visible.\n\t\t\t\t\t<CardBody className=\"dataforms-layouts-card__field-control\">\n\t\t\t\t\t\t{ field.description && (\n\t\t\t\t\t\t\t<div className=\"dataforms-layouts-card__field-description\">\n\t\t\t\t\t\t\t\t{ field.description }\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<DataFormLayout\n\t\t\t\t\t\t\tdata={ data }\n\t\t\t\t\t\t\tform={ form }\n\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\tvalidity={ validity?.children }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</CardBody>\n\t\t\t\t) }\n\t\t\t</Card>\n\t\t);\n\t}\n\n\tconst fieldDefinition = fields.find(\n\t\t( fieldDef ) => fieldDef.id === field.id\n\t);\n\n\tif ( ! fieldDefinition || ! fieldDefinition.Edit ) {\n\t\treturn null;\n\t}\n\n\tconst RegularLayout = getFormFieldLayout( 'regular' )?.component;\n\tif ( ! RegularLayout ) {\n\t\treturn null;\n\t}\n\tconst withHeader = !! fieldDefinition.label && layout.withHeader;\n\treturn (\n\t\t<Card className=\"dataforms-layouts-card__field\">\n\t\t\t{ withHeader && (\n\t\t\t\t<CollapsibleCardHeader className=\"dataforms-layouts-card__field-header\">\n\t\t\t\t\t<span className=\"dataforms-layouts-card__field-header-label\">\n\t\t\t\t\t\t{ fieldDefinition.label }\n\t\t\t\t\t</span>\n\t\t\t\t\t{ visibleSummaryFields.length > 0 && layout.withHeader && (\n\t\t\t\t\t\t<div className=\"dataforms-layouts-card__field-summary\">\n\t\t\t\t\t\t\t{ visibleSummaryFields.map( ( summaryField ) => (\n\t\t\t\t\t\t\t\t<summaryField.render\n\t\t\t\t\t\t\t\t\tkey={ summaryField.id }\n\t\t\t\t\t\t\t\t\titem={ data }\n\t\t\t\t\t\t\t\t\tfield={ summaryField }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) ) }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) }\n\t\t\t\t</CollapsibleCardHeader>\n\t\t\t) }\n\t\t\t{ ( isOpen || ! withHeader ) && (\n\t\t\t\t// If it doesn't have a header, keep it open.\n\t\t\t\t// Otherwise, the card will not be visible.\n\t\t\t\t<CardBody className=\"dataforms-layouts-card__field-control\">\n\t\t\t\t\t<RegularLayout\n\t\t\t\t\t\tdata={ data }\n\t\t\t\t\t\tfield={ field }\n\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\thideLabelFromVision={\n\t\t\t\t\t\t\thideLabelFromVision || withHeader\n\t\t\t\t\t\t}\n\t\t\t\t\t\tvalidity={ validity }\n\t\t\t\t\t/>\n\t\t\t\t</CardBody>\n\t\t\t) }\n\t\t</Card>\n\t);\n}\n"],
5
+ "mappings": "AAwCG,SAQC,KARD;AArCH,SAAS,QAAQ,MAAM,UAAU,kBAAkB;AACnD,SAAS,aAAa,YAAY,SAAS,gBAAgB;AAC3D,SAAS,aAAa,iBAAiB;AAKvC,SAAS,0BAA0B;AACnC,OAAO,qBAAqB;AAS5B,SAAS,sBAAsB;AAC/B,SAAS,uBAAuB;AAChC,SAAS,gBAAgB,uBAAuB;AAChD,SAAS,wBAAwB;AAE1B,SAAS,mBAAoB,gBAAyB,MAAO;AACnE,QAAM,CAAE,QAAQ,SAAU,IAAI,SAAU,aAAc;AAEtD,QAAM,SAAS,YAAa,MAAM;AACjC,cAAW,CAAE,SAAU,CAAE,IAAK;AAAA,EAC/B,GAAG,CAAC,CAAE;AAEN,QAAM,wBAAwB;AAAA,IAC7B,CAAE;AAAA,MACD;AAAA,MACA,GAAG;AAAA,IACJ,MAIC;AAAA,MAAC;AAAA;AAAA,QACE,GAAG;AAAA,QACL,SAAU;AAAA,QACV,OAAQ;AAAA,UACP,QAAQ;AAAA,UACR,GAAG,MAAM;AAAA,QACV;AAAA,QAEA;AAAA;AAAA,YAAC;AAAA;AAAA,cACA,OAAQ;AAAA,gBACP,OAAO;AAAA,gBACP,SAAS;AAAA,gBACT,gBAAgB;AAAA,gBAChB,YAAY;AAAA,cACb;AAAA,cAEE;AAAA;AAAA,UACH;AAAA,UACA;AAAA,YAAC;AAAA;AAAA,cACA,uBAAqB;AAAA,cACrB,SAAQ;AAAA,cACR,MAAO,SAAS,YAAY;AAAA,cAC5B,iBAAgB;AAAA,cAChB,cAAa,SAAS,aAAa;AAAA;AAAA,UACpC;AAAA;AAAA;AAAA,IACD;AAAA,IAED,CAAE,QAAQ,MAAO;AAAA,EAClB;AAEA,SAAO,EAAE,QAAQ,sBAAsB;AACxC;AAEA,SAAS,sBACR,cACA,eACA,QACC;AAED,MACC,CAAE,iBACA,MAAM,QAAS,aAAc,KAAK,cAAc,WAAW,GAC5D;AACD,WAAO;AAAA,EACR;AAGA,QAAM,qBAAqB,MAAM,QAAS,aAAc,IACrD,gBACA,CAAE,aAAc;AAGnB,QAAM,cAAc,mBAAmB,KAAM,CAAE,WAAY;AAC1D,QAAK,OAAO,WAAW,UAAW;AACjC,aAAO,WAAW,aAAa;AAAA,IAChC;AACA,QAAK,OAAO,WAAW,YAAY,QAAQ,QAAS;AACnD,aAAO,OAAO,OAAO,aAAa;AAAA,IACnC;AACA,WAAO;AAAA,EACR,CAAE;AAGF,MAAK,CAAE,aAAc;AACpB,WAAO;AAAA,EACR;AAGA,MAAK,OAAO,gBAAgB,UAAW;AACtC,WAAO;AAAA,EACR;AAGA,MAAK,OAAO,gBAAgB,YAAY,gBAAgB,aAAc;AACrE,WACC,YAAY,eAAe,YACzB,YAAY,eAAe,oBAAoB,CAAE;AAAA,EAErD;AAGA,SAAO;AACR;AAEe,SAAR,cAAwC;AAAA,EAC9C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAA8B;AAC7B,QAAM,EAAE,OAAO,IAAI,WAAY,eAAgB;AAE/C,QAAM,SAA+B,gBAAiB;AAAA,IACrD,GAAG,MAAM;AAAA,IACT,MAAM;AAAA,EACP,CAAgB;AAEhB,QAAM,OAAa;AAAA,IAClB,OAAc;AAAA,MACb,QAAQ;AAAA,MACR,QAAQ,gBAAiB,KAAM,IAAI,MAAM,WAAW,CAAC;AAAA,IACtD;AAAA,IACA,CAAE,KAAM;AAAA,EACT;AAEA,QAAM,EAAE,QAAQ,sBAAsB,IAAI;AAAA,IACzC,OAAO;AAAA,EACR;AAEA,QAAM,gBAAgB,iBAA0B,OAAO,SAAS,MAAO;AAEvE,QAAM,uBAAuB,cAAc;AAAA,IAAQ,CAAE,iBACpD,sBAAuB,cAAc,OAAO,SAAS,MAAO;AAAA,EAC7D;AAEA,MAAK,gBAAiB,KAAM,GAAI;AAC/B,UAAMA,cAAa,CAAC,CAAE,MAAM,SAAS,OAAO;AAC5C,WACC,qBAAC,QAAK,WAAU,iCACb;AAAA,MAAAA,eACD,qBAAC,yBAAsB,WAAU,wCAChC;AAAA,4BAAC,UAAK,WAAU,8CACb,gBAAM,OACT;AAAA,QACE,qBAAqB,SAAS,KAC/B,OAAO,cACN,oBAAC,SAAI,WAAU,yCACZ,+BAAqB;AAAA,UACtB,CAAE,iBACD;AAAA,YAAC,aAAa;AAAA,YAAb;AAAA,cAEA,MAAO;AAAA,cACP,OAAQ;AAAA;AAAA,YAFF,aAAa;AAAA,UAGpB;AAAA,QAEF,GACD;AAAA,SAEH;AAAA,OAEG,UAAU,CAAEA;AAAA;AAAA,MAGf,qBAAC,YAAS,WAAU,yCACjB;AAAA,cAAM,eACP,oBAAC,SAAI,WAAU,6CACZ,gBAAM,aACT;AAAA,QAED;AAAA,UAAC;AAAA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA,UAAW,UAAU;AAAA;AAAA,QACtB;AAAA,SACD;AAAA,OAEF;AAAA,EAEF;AAEA,QAAM,kBAAkB,OAAO;AAAA,IAC9B,CAAE,aAAc,SAAS,OAAO,MAAM;AAAA,EACvC;AAEA,MAAK,CAAE,mBAAmB,CAAE,gBAAgB,MAAO;AAClD,WAAO;AAAA,EACR;AAEA,QAAM,gBAAgB,mBAAoB,SAAU,GAAG;AACvD,MAAK,CAAE,eAAgB;AACtB,WAAO;AAAA,EACR;AACA,QAAM,aAAa,CAAC,CAAE,gBAAgB,SAAS,OAAO;AACtD,SACC,qBAAC,QAAK,WAAU,iCACb;AAAA,kBACD,qBAAC,yBAAsB,WAAU,wCAChC;AAAA,0BAAC,UAAK,WAAU,8CACb,0BAAgB,OACnB;AAAA,MACE,qBAAqB,SAAS,KAAK,OAAO,cAC3C,oBAAC,SAAI,WAAU,yCACZ,+BAAqB,IAAK,CAAE,iBAC7B;AAAA,QAAC,aAAa;AAAA,QAAb;AAAA,UAEA,MAAO;AAAA,UACP,OAAQ;AAAA;AAAA,QAFF,aAAa;AAAA,MAGpB,CACC,GACH;AAAA,OAEF;AAAA,KAEG,UAAU,CAAE;AAAA;AAAA,IAGf,oBAAC,YAAS,WAAU,yCACnB;AAAA,MAAC;AAAA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA,qBACC,uBAAuB;AAAA,QAExB;AAAA;AAAA,IACD,GACD;AAAA,KAEF;AAEF;",
6
+ "names": ["withHeader"]
7
+ }
@@ -0,0 +1,61 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { __experimentalVStack as VStack } from "@wordpress/components";
3
+ import { useContext, useMemo } from "@wordpress/element";
4
+ import { getFormFieldLayout } from "./index";
5
+ import DataFormContext from "../components/dataform-context";
6
+ import { isCombinedField } from "./is-combined-field";
7
+ import normalizeFormFields, { normalizeLayout } from "./normalize-form-fields";
8
+ const DEFAULT_WRAPPER = ({ children }) => /* @__PURE__ */ jsx(VStack, { className: "dataforms-layouts__wrapper", spacing: 4, children });
9
+ function DataFormLayout({
10
+ data,
11
+ form,
12
+ onChange,
13
+ validity,
14
+ children,
15
+ as
16
+ }) {
17
+ const { fields: fieldDefinitions } = useContext(DataFormContext);
18
+ function getFieldDefinition(field) {
19
+ const fieldId = typeof field === "string" ? field : field.id;
20
+ return fieldDefinitions.find(
21
+ (fieldDefinition) => fieldDefinition.id === fieldId
22
+ );
23
+ }
24
+ const normalizedFormFields = useMemo(
25
+ () => normalizeFormFields(form),
26
+ [form]
27
+ );
28
+ const normalizedFormLayout = normalizeLayout(form.layout);
29
+ const Wrapper = as ?? getFormFieldLayout(normalizedFormLayout.type)?.wrapper ?? DEFAULT_WRAPPER;
30
+ return /* @__PURE__ */ jsx(Wrapper, { layout: normalizedFormLayout, children: normalizedFormFields.map((formField) => {
31
+ const FieldLayout = getFormFieldLayout(formField.layout.type)?.component;
32
+ if (!FieldLayout) {
33
+ return null;
34
+ }
35
+ const fieldDefinition = !isCombinedField(formField) ? getFieldDefinition(formField) : void 0;
36
+ if (fieldDefinition && fieldDefinition.isVisible && !fieldDefinition.isVisible(data)) {
37
+ return null;
38
+ }
39
+ if (children) {
40
+ return children(
41
+ FieldLayout,
42
+ formField,
43
+ validity?.[formField.id]
44
+ );
45
+ }
46
+ return /* @__PURE__ */ jsx(
47
+ FieldLayout,
48
+ {
49
+ data,
50
+ field: formField,
51
+ onChange,
52
+ validity: validity?.[formField.id]
53
+ },
54
+ formField.id
55
+ );
56
+ }) });
57
+ }
58
+ export {
59
+ DataFormLayout
60
+ };
61
+ //# sourceMappingURL=data-form-layout.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/dataform-layouts/data-form-layout.tsx"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __experimentalVStack as VStack } from '@wordpress/components';\nimport { useContext, useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport type {\n\tFieldValidity,\n\tForm,\n\tFormField,\n\tFormValidity,\n\tSimpleFormField,\n} from '../types';\nimport { getFormFieldLayout } from './index';\nimport DataFormContext from '../components/dataform-context';\nimport { isCombinedField } from './is-combined-field';\nimport normalizeFormFields, { normalizeLayout } from './normalize-form-fields';\n\nconst DEFAULT_WRAPPER = ( { children }: { children: React.ReactNode } ) => (\n\t<VStack className=\"dataforms-layouts__wrapper\" spacing={ 4 }>\n\t\t{ children }\n\t</VStack>\n);\n\nexport function DataFormLayout< Item >( {\n\tdata,\n\tform,\n\tonChange,\n\tvalidity,\n\tchildren,\n\tas,\n}: {\n\tdata: Item;\n\tform: Form;\n\tonChange: ( value: any ) => void;\n\tvalidity?: FormValidity;\n\tchildren?: (\n\t\tFieldLayout: ( props: {\n\t\t\tdata: Item;\n\t\t\tfield: FormField;\n\t\t\tonChange: ( value: any ) => void;\n\t\t\thideLabelFromVision?: boolean;\n\t\t\tvalidity?: FieldValidity;\n\t\t} ) => React.JSX.Element | null,\n\t\tchildField: FormField,\n\t\tchildFieldValidity?: FieldValidity\n\t) => React.JSX.Element;\n\tas?: React.ComponentType< { children: React.ReactNode } >;\n} ) {\n\tconst { fields: fieldDefinitions } = useContext( DataFormContext );\n\n\tfunction getFieldDefinition( field: SimpleFormField | string ) {\n\t\tconst fieldId = typeof field === 'string' ? field : field.id;\n\n\t\treturn fieldDefinitions.find(\n\t\t\t( fieldDefinition ) => fieldDefinition.id === fieldId\n\t\t);\n\t}\n\n\tconst normalizedFormFields = useMemo(\n\t\t() => normalizeFormFields( form ),\n\t\t[ form ]\n\t);\n\n\tconst normalizedFormLayout = normalizeLayout( form.layout );\n\tconst Wrapper =\n\t\tas ??\n\t\tgetFormFieldLayout( normalizedFormLayout.type )?.wrapper ??\n\t\tDEFAULT_WRAPPER;\n\n\treturn (\n\t\t<Wrapper layout={ normalizedFormLayout }>\n\t\t\t{ normalizedFormFields.map( ( formField ) => {\n\t\t\t\tconst FieldLayout = getFormFieldLayout( formField.layout.type )\n\t\t\t\t\t?.component;\n\n\t\t\t\tif ( ! FieldLayout ) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\tconst fieldDefinition = ! isCombinedField( formField )\n\t\t\t\t\t? getFieldDefinition( formField )\n\t\t\t\t\t: undefined;\n\n\t\t\t\tif (\n\t\t\t\t\tfieldDefinition &&\n\t\t\t\t\tfieldDefinition.isVisible &&\n\t\t\t\t\t! fieldDefinition.isVisible( data )\n\t\t\t\t) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\tif ( children ) {\n\t\t\t\t\treturn children(\n\t\t\t\t\t\tFieldLayout,\n\t\t\t\t\t\tformField,\n\t\t\t\t\t\tvalidity?.[ formField.id ]\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn (\n\t\t\t\t\t<FieldLayout\n\t\t\t\t\t\tkey={ formField.id }\n\t\t\t\t\t\tdata={ data }\n\t\t\t\t\t\tfield={ formField }\n\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\tvalidity={ validity?.[ formField.id ] }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</Wrapper>\n\t);\n}\n"],
5
+ "mappings": "AAsBC;AAnBD,SAAS,wBAAwB,cAAc;AAC/C,SAAS,YAAY,eAAe;AAYpC,SAAS,0BAA0B;AACnC,OAAO,qBAAqB;AAC5B,SAAS,uBAAuB;AAChC,OAAO,uBAAuB,uBAAuB;AAErD,MAAM,kBAAkB,CAAE,EAAE,SAAS,MACpC,oBAAC,UAAO,WAAU,8BAA6B,SAAU,GACtD,UACH;AAGM,SAAS,eAAwB;AAAA,EACvC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAiBI;AACH,QAAM,EAAE,QAAQ,iBAAiB,IAAI,WAAY,eAAgB;AAEjE,WAAS,mBAAoB,OAAkC;AAC9D,UAAM,UAAU,OAAO,UAAU,WAAW,QAAQ,MAAM;AAE1D,WAAO,iBAAiB;AAAA,MACvB,CAAE,oBAAqB,gBAAgB,OAAO;AAAA,IAC/C;AAAA,EACD;AAEA,QAAM,uBAAuB;AAAA,IAC5B,MAAM,oBAAqB,IAAK;AAAA,IAChC,CAAE,IAAK;AAAA,EACR;AAEA,QAAM,uBAAuB,gBAAiB,KAAK,MAAO;AAC1D,QAAM,UACL,MACA,mBAAoB,qBAAqB,IAAK,GAAG,WACjD;AAED,SACC,oBAAC,WAAQ,QAAS,sBACf,+BAAqB,IAAK,CAAE,cAAe;AAC5C,UAAM,cAAc,mBAAoB,UAAU,OAAO,IAAK,GAC3D;AAEH,QAAK,CAAE,aAAc;AACpB,aAAO;AAAA,IACR;AAEA,UAAM,kBAAkB,CAAE,gBAAiB,SAAU,IAClD,mBAAoB,SAAU,IAC9B;AAEH,QACC,mBACA,gBAAgB,aAChB,CAAE,gBAAgB,UAAW,IAAK,GACjC;AACD,aAAO;AAAA,IACR;AAEA,QAAK,UAAW;AACf,aAAO;AAAA,QACN;AAAA,QACA;AAAA,QACA,WAAY,UAAU,EAAG;AAAA,MAC1B;AAAA,IACD;AAEA,WACC;AAAA,MAAC;AAAA;AAAA,QAEA;AAAA,QACA,OAAQ;AAAA,QACR;AAAA,QACA,UAAW,WAAY,UAAU,EAAG;AAAA;AAAA,MAJ9B,UAAU;AAAA,IAKjB;AAAA,EAEF,CAAE,GACH;AAEF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,21 @@
1
+ function extractSummaryIds(summary) {
2
+ if (Array.isArray(summary)) {
3
+ return summary.map(
4
+ (item) => typeof item === "string" ? item : item.id
5
+ );
6
+ }
7
+ return [];
8
+ }
9
+ const getSummaryFields = (summaryField, fields) => {
10
+ if (Array.isArray(summaryField) && summaryField.length > 0) {
11
+ const summaryIds = extractSummaryIds(summaryField);
12
+ return summaryIds.map(
13
+ (summaryId) => fields.find((_field) => _field.id === summaryId)
14
+ ).filter((_field) => _field !== void 0);
15
+ }
16
+ return [];
17
+ };
18
+ export {
19
+ getSummaryFields
20
+ };
21
+ //# sourceMappingURL=get-summary-fields.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/dataform-layouts/get-summary-fields.ts"],
4
+ "sourcesContent": ["/**\n * Internal dependencies\n */\nimport type { NormalizedField, NormalizedSummaryField } from '../types';\n\n/**\n * Extracts field IDs from various summary field formats.\n *\n * @param summary The summary field configuration.\n * @return Array of field IDs.\n */\nfunction extractSummaryIds( summary: NormalizedSummaryField ): string[] {\n\tif ( Array.isArray( summary ) ) {\n\t\treturn summary.map( ( item ) =>\n\t\t\ttypeof item === 'string' ? item : item.id\n\t\t);\n\t}\n\n\treturn [];\n}\n\n/**\n * Returns the summary fields for a given field.\n * @param summaryField - The summary field configuration.\n * @param fields - The fields to get the summary fields from.\n * @return The summary fields.\n */\nexport const getSummaryFields = < Item >(\n\tsummaryField: NormalizedSummaryField,\n\tfields: NormalizedField< Item >[]\n): NormalizedField< Item >[] => {\n\tif ( Array.isArray( summaryField ) && summaryField.length > 0 ) {\n\t\tconst summaryIds = extractSummaryIds( summaryField );\n\t\treturn summaryIds\n\t\t\t.map( ( summaryId ) =>\n\t\t\t\tfields.find( ( _field ) => _field.id === summaryId )\n\t\t\t)\n\t\t\t.filter( ( _field ) => _field !== undefined );\n\t}\n\n\treturn [];\n};\n"],
5
+ "mappings": "AAWA,SAAS,kBAAmB,SAA4C;AACvE,MAAK,MAAM,QAAS,OAAQ,GAAI;AAC/B,WAAO,QAAQ;AAAA,MAAK,CAAE,SACrB,OAAO,SAAS,WAAW,OAAO,KAAK;AAAA,IACxC;AAAA,EACD;AAEA,SAAO,CAAC;AACT;AAQO,MAAM,mBAAmB,CAC/B,cACA,WAC+B;AAC/B,MAAK,MAAM,QAAS,YAAa,KAAK,aAAa,SAAS,GAAI;AAC/D,UAAM,aAAa,kBAAmB,YAAa;AACnD,WAAO,WACL;AAAA,MAAK,CAAE,cACP,OAAO,KAAM,CAAE,WAAY,OAAO,OAAO,SAAU;AAAA,IACpD,EACC,OAAQ,CAAE,WAAY,WAAW,MAAU;AAAA,EAC9C;AAEA,SAAO,CAAC;AACT;",
6
+ "names": []
7
+ }
@@ -0,0 +1,68 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import {
3
+ __experimentalVStack as VStack,
4
+ __experimentalHStack as HStack
5
+ } from "@wordpress/components";
6
+ import FormRegularField from "./regular";
7
+ import FormPanelField from "./panel";
8
+ import FormCardField from "./card";
9
+ import FormRowField from "./row";
10
+ const FORM_FIELD_LAYOUTS = [
11
+ {
12
+ type: "regular",
13
+ component: FormRegularField,
14
+ wrapper: ({
15
+ children,
16
+ layout
17
+ }) => /* @__PURE__ */ jsx(
18
+ VStack,
19
+ {
20
+ className: "dataforms-layouts__wrapper",
21
+ spacing: layout?.spacing ?? 4,
22
+ children
23
+ }
24
+ )
25
+ },
26
+ {
27
+ type: "panel",
28
+ component: FormPanelField,
29
+ wrapper: ({ children }) => /* @__PURE__ */ jsx(VStack, { className: "dataforms-layouts__wrapper", spacing: 2, children })
30
+ },
31
+ {
32
+ type: "card",
33
+ component: FormCardField,
34
+ wrapper: ({
35
+ children,
36
+ layout
37
+ }) => /* @__PURE__ */ jsx(
38
+ VStack,
39
+ {
40
+ className: "dataforms-layouts__wrapper",
41
+ spacing: layout?.spacing ?? 6,
42
+ children
43
+ }
44
+ )
45
+ },
46
+ {
47
+ type: "row",
48
+ component: FormRowField,
49
+ wrapper: ({
50
+ children,
51
+ layout
52
+ }) => /* @__PURE__ */ jsx(VStack, { className: "dataforms-layouts__wrapper", spacing: 4, children: /* @__PURE__ */ jsx("div", { className: "dataforms-layouts-row__field", children: /* @__PURE__ */ jsx(
53
+ HStack,
54
+ {
55
+ spacing: 4,
56
+ alignment: layout.alignment,
57
+ children
58
+ }
59
+ ) }) })
60
+ }
61
+ ];
62
+ function getFormFieldLayout(type) {
63
+ return FORM_FIELD_LAYOUTS.find((layout) => layout.type === type);
64
+ }
65
+ export {
66
+ getFormFieldLayout
67
+ };
68
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/dataform-layouts/index.tsx"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalVStack as VStack,\n\t__experimentalHStack as HStack,\n} from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport type { Layout, RowLayout } from '../types';\nimport FormRegularField from './regular';\nimport FormPanelField from './panel';\nimport FormCardField from './card';\nimport FormRowField from './row';\n\nconst FORM_FIELD_LAYOUTS = [\n\t{\n\t\ttype: 'regular',\n\t\tcomponent: FormRegularField,\n\t\twrapper: ( {\n\t\t\tchildren,\n\t\t\tlayout,\n\t\t}: {\n\t\t\tchildren: React.ReactNode;\n\t\t\tlayout: Layout;\n\t\t} ) => (\n\t\t\t<VStack\n\t\t\t\tclassName=\"dataforms-layouts__wrapper\"\n\t\t\t\tspacing={ ( layout as any )?.spacing ?? 4 }\n\t\t\t>\n\t\t\t\t{ children }\n\t\t\t</VStack>\n\t\t),\n\t},\n\t{\n\t\ttype: 'panel',\n\t\tcomponent: FormPanelField,\n\t\twrapper: ( { children }: { children: React.ReactNode } ) => (\n\t\t\t<VStack className=\"dataforms-layouts__wrapper\" spacing={ 2 }>\n\t\t\t\t{ children }\n\t\t\t</VStack>\n\t\t),\n\t},\n\t{\n\t\ttype: 'card',\n\t\tcomponent: FormCardField,\n\t\twrapper: ( {\n\t\t\tchildren,\n\t\t\tlayout,\n\t\t}: {\n\t\t\tchildren: React.ReactNode;\n\t\t\tlayout: Layout;\n\t\t} ) => (\n\t\t\t<VStack\n\t\t\t\tclassName=\"dataforms-layouts__wrapper\"\n\t\t\t\tspacing={ ( layout as any )?.spacing ?? 6 }\n\t\t\t>\n\t\t\t\t{ children }\n\t\t\t</VStack>\n\t\t),\n\t},\n\t{\n\t\ttype: 'row',\n\t\tcomponent: FormRowField,\n\t\twrapper: ( {\n\t\t\tchildren,\n\t\t\tlayout,\n\t\t}: {\n\t\t\tchildren: React.ReactNode;\n\t\t\tlayout: Layout;\n\t\t} ) => (\n\t\t\t<VStack className=\"dataforms-layouts__wrapper\" spacing={ 4 }>\n\t\t\t\t<div className=\"dataforms-layouts-row__field\">\n\t\t\t\t\t<HStack\n\t\t\t\t\t\tspacing={ 4 }\n\t\t\t\t\t\talignment={ ( layout as RowLayout ).alignment }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ children }\n\t\t\t\t\t</HStack>\n\t\t\t\t</div>\n\t\t\t</VStack>\n\t\t),\n\t},\n];\n\nexport function getFormFieldLayout( type: string ) {\n\treturn FORM_FIELD_LAYOUTS.find( ( layout ) => layout.type === type );\n}\n"],
5
+ "mappings": "AA4BG;AAzBH;AAAA,EACC,wBAAwB;AAAA,EACxB,wBAAwB;AAAA,OAClB;AAMP,OAAO,sBAAsB;AAC7B,OAAO,oBAAoB;AAC3B,OAAO,mBAAmB;AAC1B,OAAO,kBAAkB;AAEzB,MAAM,qBAAqB;AAAA,EAC1B;AAAA,IACC,MAAM;AAAA,IACN,WAAW;AAAA,IACX,SAAS,CAAE;AAAA,MACV;AAAA,MACA;AAAA,IACD,MAIC;AAAA,MAAC;AAAA;AAAA,QACA,WAAU;AAAA,QACV,SAAY,QAAiB,WAAW;AAAA,QAEtC;AAAA;AAAA,IACH;AAAA,EAEF;AAAA,EACA;AAAA,IACC,MAAM;AAAA,IACN,WAAW;AAAA,IACX,SAAS,CAAE,EAAE,SAAS,MACrB,oBAAC,UAAO,WAAU,8BAA6B,SAAU,GACtD,UACH;AAAA,EAEF;AAAA,EACA;AAAA,IACC,MAAM;AAAA,IACN,WAAW;AAAA,IACX,SAAS,CAAE;AAAA,MACV;AAAA,MACA;AAAA,IACD,MAIC;AAAA,MAAC;AAAA;AAAA,QACA,WAAU;AAAA,QACV,SAAY,QAAiB,WAAW;AAAA,QAEtC;AAAA;AAAA,IACH;AAAA,EAEF;AAAA,EACA;AAAA,IACC,MAAM;AAAA,IACN,WAAW;AAAA,IACX,SAAS,CAAE;AAAA,MACV;AAAA,MACA;AAAA,IACD,MAIC,oBAAC,UAAO,WAAU,8BAA6B,SAAU,GACxD,8BAAC,SAAI,WAAU,gCACd;AAAA,MAAC;AAAA;AAAA,QACA,SAAU;AAAA,QACV,WAAc,OAAsB;AAAA,QAElC;AAAA;AAAA,IACH,GACD,GACD;AAAA,EAEF;AACD;AAEO,SAAS,mBAAoB,MAAe;AAClD,SAAO,mBAAmB,KAAM,CAAE,WAAY,OAAO,SAAS,IAAK;AACpE;",
6
+ "names": []
7
+ }
@@ -0,0 +1,7 @@
1
+ function isCombinedField(field) {
2
+ return field.children !== void 0;
3
+ }
4
+ export {
5
+ isCombinedField
6
+ };
7
+ //# sourceMappingURL=is-combined-field.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/dataform-layouts/is-combined-field.ts"],
4
+ "sourcesContent": ["/**\n * Internal dependencies\n */\nimport type { FormField, CombinedFormField } from '../types';\n\nexport function isCombinedField(\n\tfield: FormField\n): field is CombinedFormField {\n\treturn ( field as CombinedFormField ).children !== undefined;\n}\n"],
5
+ "mappings": "AAKO,SAAS,gBACf,OAC6B;AAC7B,SAAS,MAA6B,aAAa;AACpD;",
6
+ "names": []
7
+ }
@@ -0,0 +1,79 @@
1
+ const DEFAULT_LAYOUT = {
2
+ type: "regular",
3
+ labelPosition: "top"
4
+ };
5
+ const normalizeCardSummaryField = (sum) => {
6
+ if (typeof sum === "string") {
7
+ return [{ id: sum, visibility: "when-collapsed" }];
8
+ }
9
+ return sum.map((item) => {
10
+ if (typeof item === "string") {
11
+ return { id: item, visibility: "when-collapsed" };
12
+ }
13
+ return { id: item.id, visibility: item.visibility };
14
+ });
15
+ };
16
+ function normalizeLayout(layout) {
17
+ let normalizedLayout = DEFAULT_LAYOUT;
18
+ if (layout?.type === "regular") {
19
+ normalizedLayout = {
20
+ type: "regular",
21
+ labelPosition: layout?.labelPosition ?? "top"
22
+ };
23
+ } else if (layout?.type === "panel") {
24
+ const summary = layout.summary ?? [];
25
+ const normalizedSummary = Array.isArray(summary) ? summary : [summary];
26
+ normalizedLayout = {
27
+ type: "panel",
28
+ labelPosition: layout?.labelPosition ?? "side",
29
+ openAs: layout?.openAs ?? "dropdown",
30
+ summary: normalizedSummary
31
+ };
32
+ } else if (layout?.type === "card") {
33
+ if (layout.withHeader === false) {
34
+ normalizedLayout = {
35
+ type: "card",
36
+ withHeader: false,
37
+ isOpened: true,
38
+ summary: []
39
+ };
40
+ } else {
41
+ const summary = layout.summary ?? [];
42
+ normalizedLayout = {
43
+ type: "card",
44
+ withHeader: true,
45
+ isOpened: typeof layout.isOpened === "boolean" ? layout.isOpened : true,
46
+ summary: normalizeCardSummaryField(summary)
47
+ };
48
+ }
49
+ } else if (layout?.type === "row") {
50
+ normalizedLayout = {
51
+ type: "row",
52
+ alignment: layout?.alignment ?? "center",
53
+ styles: layout?.styles ?? {}
54
+ };
55
+ }
56
+ return normalizedLayout;
57
+ }
58
+ function normalizeFormFields(form) {
59
+ const formLayout = normalizeLayout(form?.layout);
60
+ return (form.fields ?? []).map((field) => {
61
+ if (typeof field === "string") {
62
+ return {
63
+ id: field,
64
+ layout: formLayout
65
+ };
66
+ }
67
+ const fieldLayout = field.layout ? normalizeLayout(field.layout) : formLayout;
68
+ return {
69
+ ...field,
70
+ layout: fieldLayout
71
+ };
72
+ });
73
+ }
74
+ export {
75
+ DEFAULT_LAYOUT,
76
+ normalizeFormFields as default,
77
+ normalizeLayout
78
+ };
79
+ //# sourceMappingURL=normalize-form-fields.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/dataform-layouts/normalize-form-fields.ts"],
4
+ "sourcesContent": ["/**\n * Internal dependencies\n */\nimport type {\n\tForm,\n\tLayout,\n\tNormalizedLayout,\n\tNormalizedRegularLayout,\n\tNormalizedPanelLayout,\n\tNormalizedCardLayout,\n\tNormalizedRowLayout,\n\tNormalizedCardSummaryField,\n\tCardSummaryField,\n} from '../types';\n\ninterface NormalizedFormField {\n\tid: string;\n\tlayout: Layout;\n}\n\nexport const DEFAULT_LAYOUT: NormalizedLayout = {\n\ttype: 'regular',\n\tlabelPosition: 'top',\n};\n\nconst normalizeCardSummaryField = (\n\tsum: CardSummaryField\n): NormalizedCardSummaryField => {\n\tif ( typeof sum === 'string' ) {\n\t\treturn [ { id: sum, visibility: 'when-collapsed' } ];\n\t}\n\treturn sum.map( ( item ) => {\n\t\tif ( typeof item === 'string' ) {\n\t\t\treturn { id: item, visibility: 'when-collapsed' };\n\t\t}\n\t\treturn { id: item.id, visibility: item.visibility };\n\t} );\n};\n\n/**\n * Normalizes a layout configuration based on its type.\n *\n * @param layout The layout object to normalize.\n * @return The normalized layout object.\n */\nexport function normalizeLayout( layout?: Layout ): NormalizedLayout {\n\tlet normalizedLayout = DEFAULT_LAYOUT;\n\n\tif ( layout?.type === 'regular' ) {\n\t\tnormalizedLayout = {\n\t\t\ttype: 'regular',\n\t\t\tlabelPosition: layout?.labelPosition ?? 'top',\n\t\t} satisfies NormalizedRegularLayout;\n\t} else if ( layout?.type === 'panel' ) {\n\t\tconst summary = layout.summary ?? [];\n\t\tconst normalizedSummary = Array.isArray( summary )\n\t\t\t? summary\n\t\t\t: [ summary ];\n\n\t\tnormalizedLayout = {\n\t\t\ttype: 'panel',\n\t\t\tlabelPosition: layout?.labelPosition ?? 'side',\n\t\t\topenAs: layout?.openAs ?? 'dropdown',\n\t\t\tsummary: normalizedSummary,\n\t\t} satisfies NormalizedPanelLayout;\n\t} else if ( layout?.type === 'card' ) {\n\t\tif ( layout.withHeader === false ) {\n\t\t\t// Don't let isOpened be false if withHeader is false.\n\t\t\t// Otherwise, the card will not be visible.\n\t\t\tnormalizedLayout = {\n\t\t\t\ttype: 'card',\n\t\t\t\twithHeader: false,\n\t\t\t\tisOpened: true,\n\t\t\t\tsummary: [],\n\t\t\t} satisfies NormalizedCardLayout;\n\t\t} else {\n\t\t\tconst summary = layout.summary ?? [];\n\n\t\t\tnormalizedLayout = {\n\t\t\t\ttype: 'card',\n\t\t\t\twithHeader: true,\n\t\t\t\tisOpened:\n\t\t\t\t\ttypeof layout.isOpened === 'boolean'\n\t\t\t\t\t\t? layout.isOpened\n\t\t\t\t\t\t: true,\n\t\t\t\tsummary: normalizeCardSummaryField( summary ),\n\t\t\t} satisfies NormalizedCardLayout;\n\t\t}\n\t} else if ( layout?.type === 'row' ) {\n\t\tnormalizedLayout = {\n\t\t\ttype: 'row',\n\t\t\talignment: layout?.alignment ?? 'center',\n\t\t\tstyles: layout?.styles ?? {},\n\t\t} satisfies NormalizedRowLayout;\n\t}\n\n\treturn normalizedLayout;\n}\n\nexport default function normalizeFormFields(\n\tform: Form\n): NormalizedFormField[] {\n\tconst formLayout = normalizeLayout( form?.layout );\n\n\treturn ( form.fields ?? [] ).map( ( field ) => {\n\t\tif ( typeof field === 'string' ) {\n\t\t\treturn {\n\t\t\t\tid: field,\n\t\t\t\tlayout: formLayout,\n\t\t\t};\n\t\t}\n\n\t\tconst fieldLayout = field.layout\n\t\t\t? normalizeLayout( field.layout )\n\t\t\t: formLayout;\n\t\treturn {\n\t\t\t...field,\n\t\t\tlayout: fieldLayout,\n\t\t};\n\t} );\n}\n"],
5
+ "mappings": "AAoBO,MAAM,iBAAmC;AAAA,EAC/C,MAAM;AAAA,EACN,eAAe;AAChB;AAEA,MAAM,4BAA4B,CACjC,QACgC;AAChC,MAAK,OAAO,QAAQ,UAAW;AAC9B,WAAO,CAAE,EAAE,IAAI,KAAK,YAAY,iBAAiB,CAAE;AAAA,EACpD;AACA,SAAO,IAAI,IAAK,CAAE,SAAU;AAC3B,QAAK,OAAO,SAAS,UAAW;AAC/B,aAAO,EAAE,IAAI,MAAM,YAAY,iBAAiB;AAAA,IACjD;AACA,WAAO,EAAE,IAAI,KAAK,IAAI,YAAY,KAAK,WAAW;AAAA,EACnD,CAAE;AACH;AAQO,SAAS,gBAAiB,QAAoC;AACpE,MAAI,mBAAmB;AAEvB,MAAK,QAAQ,SAAS,WAAY;AACjC,uBAAmB;AAAA,MAClB,MAAM;AAAA,MACN,eAAe,QAAQ,iBAAiB;AAAA,IACzC;AAAA,EACD,WAAY,QAAQ,SAAS,SAAU;AACtC,UAAM,UAAU,OAAO,WAAW,CAAC;AACnC,UAAM,oBAAoB,MAAM,QAAS,OAAQ,IAC9C,UACA,CAAE,OAAQ;AAEb,uBAAmB;AAAA,MAClB,MAAM;AAAA,MACN,eAAe,QAAQ,iBAAiB;AAAA,MACxC,QAAQ,QAAQ,UAAU;AAAA,MAC1B,SAAS;AAAA,IACV;AAAA,EACD,WAAY,QAAQ,SAAS,QAAS;AACrC,QAAK,OAAO,eAAe,OAAQ;AAGlC,yBAAmB;AAAA,QAClB,MAAM;AAAA,QACN,YAAY;AAAA,QACZ,UAAU;AAAA,QACV,SAAS,CAAC;AAAA,MACX;AAAA,IACD,OAAO;AACN,YAAM,UAAU,OAAO,WAAW,CAAC;AAEnC,yBAAmB;AAAA,QAClB,MAAM;AAAA,QACN,YAAY;AAAA,QACZ,UACC,OAAO,OAAO,aAAa,YACxB,OAAO,WACP;AAAA,QACJ,SAAS,0BAA2B,OAAQ;AAAA,MAC7C;AAAA,IACD;AAAA,EACD,WAAY,QAAQ,SAAS,OAAQ;AACpC,uBAAmB;AAAA,MAClB,MAAM;AAAA,MACN,WAAW,QAAQ,aAAa;AAAA,MAChC,QAAQ,QAAQ,UAAU,CAAC;AAAA,IAC5B;AAAA,EACD;AAEA,SAAO;AACR;AAEe,SAAR,oBACN,MACwB;AACxB,QAAM,aAAa,gBAAiB,MAAM,MAAO;AAEjD,UAAS,KAAK,UAAU,CAAC,GAAI,IAAK,CAAE,UAAW;AAC9C,QAAK,OAAO,UAAU,UAAW;AAChC,aAAO;AAAA,QACN,IAAI;AAAA,QACJ,QAAQ;AAAA,MACT;AAAA,IACD;AAEA,UAAM,cAAc,MAAM,SACvB,gBAAiB,MAAM,MAAO,IAC9B;AACH,WAAO;AAAA,MACN,GAAG;AAAA,MACH,QAAQ;AAAA,IACT;AAAA,EACD,CAAE;AACH;",
6
+ "names": []
7
+ }
@@ -0,0 +1,136 @@
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import {
3
+ __experimentalVStack as VStack,
4
+ __experimentalHStack as HStack,
5
+ __experimentalHeading as Heading,
6
+ __experimentalSpacer as Spacer,
7
+ Dropdown,
8
+ Button
9
+ } from "@wordpress/components";
10
+ import { __ } from "@wordpress/i18n";
11
+ import { useMemo } from "@wordpress/element";
12
+ import { closeSmall } from "@wordpress/icons";
13
+ import { DataFormLayout } from "../data-form-layout";
14
+ import { isCombinedField } from "../is-combined-field";
15
+ import { DEFAULT_LAYOUT } from "../normalize-form-fields";
16
+ import SummaryButton from "./summary-button";
17
+ function DropdownHeader({
18
+ title,
19
+ onClose
20
+ }) {
21
+ return /* @__PURE__ */ jsx(
22
+ VStack,
23
+ {
24
+ className: "dataforms-layouts-panel__dropdown-header",
25
+ spacing: 4,
26
+ children: /* @__PURE__ */ jsxs(HStack, { alignment: "center", children: [
27
+ title && /* @__PURE__ */ jsx(Heading, { level: 2, size: 13, children: title }),
28
+ /* @__PURE__ */ jsx(Spacer, {}),
29
+ onClose && /* @__PURE__ */ jsx(
30
+ Button,
31
+ {
32
+ label: __("Close"),
33
+ icon: closeSmall,
34
+ onClick: onClose,
35
+ size: "small"
36
+ }
37
+ )
38
+ ] })
39
+ }
40
+ );
41
+ }
42
+ function PanelDropdown({
43
+ data,
44
+ field,
45
+ onChange,
46
+ validity,
47
+ labelPosition = "side",
48
+ summaryFields,
49
+ fieldDefinition,
50
+ popoverAnchor
51
+ }) {
52
+ const fieldLabel = isCombinedField(field) ? field.label : fieldDefinition?.label;
53
+ const form = useMemo(
54
+ () => ({
55
+ layout: DEFAULT_LAYOUT,
56
+ fields: isCombinedField(field) ? field.children : (
57
+ // If not explicit children return the field id itself.
58
+ [{ id: field.id }]
59
+ )
60
+ }),
61
+ [field]
62
+ );
63
+ const formValidity = useMemo(() => {
64
+ if (validity === void 0) {
65
+ return void 0;
66
+ }
67
+ if (isCombinedField(field)) {
68
+ return validity?.children;
69
+ }
70
+ return { [field.id]: validity };
71
+ }, [validity, field]);
72
+ const popoverProps = useMemo(
73
+ () => ({
74
+ // Anchor the popover to the middle of the entire row so that it doesn't
75
+ // move around when the label changes.
76
+ anchor: popoverAnchor,
77
+ placement: "left-start",
78
+ offset: 36,
79
+ shift: true
80
+ }),
81
+ [popoverAnchor]
82
+ );
83
+ return /* @__PURE__ */ jsx(
84
+ Dropdown,
85
+ {
86
+ contentClassName: "dataforms-layouts-panel__field-dropdown",
87
+ popoverProps,
88
+ focusOnMount: true,
89
+ toggleProps: {
90
+ size: "compact",
91
+ variant: "tertiary",
92
+ tooltipPosition: "middle left"
93
+ },
94
+ renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ jsx(
95
+ SummaryButton,
96
+ {
97
+ summaryFields,
98
+ data,
99
+ labelPosition,
100
+ fieldLabel,
101
+ disabled: fieldDefinition.readOnly === true,
102
+ onClick: onToggle,
103
+ "aria-expanded": isOpen
104
+ }
105
+ ),
106
+ renderContent: ({ onClose }) => /* @__PURE__ */ jsxs(Fragment, { children: [
107
+ /* @__PURE__ */ jsx(DropdownHeader, { title: fieldLabel, onClose }),
108
+ /* @__PURE__ */ jsx(
109
+ DataFormLayout,
110
+ {
111
+ data,
112
+ form,
113
+ onChange,
114
+ validity: formValidity,
115
+ children: (FieldLayout, childField, childFieldValidity) => /* @__PURE__ */ jsx(
116
+ FieldLayout,
117
+ {
118
+ data,
119
+ field: childField,
120
+ onChange,
121
+ hideLabelFromVision: (form?.fields ?? []).length < 2,
122
+ validity: childFieldValidity
123
+ },
124
+ childField.id
125
+ )
126
+ }
127
+ )
128
+ ] })
129
+ }
130
+ );
131
+ }
132
+ var dropdown_default = PanelDropdown;
133
+ export {
134
+ dropdown_default as default
135
+ };
136
+ //# sourceMappingURL=dropdown.js.map