@wordpress/dataviews 3.0.0 → 4.1.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 (352) hide show
  1. package/CHANGELOG.md +21 -3
  2. package/README.md +19 -4
  3. package/build/components/dataform/index.js +27 -0
  4. package/build/components/dataform/index.js.map +1 -0
  5. package/build/components/dataviews/index.js +126 -0
  6. package/build/components/dataviews/index.js.map +1 -0
  7. package/build/{bulk-actions.js → components/dataviews-bulk-actions/index.js} +42 -16
  8. package/build/components/dataviews-bulk-actions/index.js.map +1 -0
  9. package/build/{bulk-actions-toolbar.js → components/dataviews-bulk-actions-toolbar/index.js} +36 -19
  10. package/build/components/dataviews-bulk-actions-toolbar/index.js.map +1 -0
  11. package/build/components/dataviews-context/index.js +36 -0
  12. package/build/components/dataviews-context/index.js.map +1 -0
  13. package/build/{add-filter.js → components/dataviews-filters/add-filter.js} +35 -18
  14. package/build/components/dataviews-filters/add-filter.js.map +1 -0
  15. package/build/{filter-summary.js → components/dataviews-filters/filter-summary.js} +9 -9
  16. package/build/components/dataviews-filters/filter-summary.js.map +1 -0
  17. package/build/components/dataviews-filters/index.js +164 -0
  18. package/build/components/dataviews-filters/index.js.map +1 -0
  19. package/build/components/dataviews-filters/reset-filters.js.map +1 -0
  20. package/build/{search-widget.js → components/dataviews-filters/search-widget.js} +13 -13
  21. package/build/components/dataviews-filters/search-widget.js.map +1 -0
  22. package/build/{item-actions.js → components/dataviews-item-actions/index.js} +2 -2
  23. package/build/components/dataviews-item-actions/index.js.map +1 -0
  24. package/build/components/dataviews-layout/index.js +53 -0
  25. package/build/components/dataviews-layout/index.js.map +1 -0
  26. package/build/{pagination.js → components/dataviews-pagination/index.js} +16 -13
  27. package/build/components/dataviews-pagination/index.js.map +1 -0
  28. package/build/{search.js → components/dataviews-search/index.js} +18 -11
  29. package/build/components/dataviews-search/index.js.map +1 -0
  30. package/build/{single-selection-checkbox.js → components/dataviews-selection-checkbox/index.js} +6 -6
  31. package/build/components/dataviews-selection-checkbox/index.js.map +1 -0
  32. package/build/components/dataviews-view-config/index.js +298 -0
  33. package/build/components/dataviews-view-config/index.js.map +1 -0
  34. package/build/constants.js +6 -1
  35. package/build/constants.js.map +1 -1
  36. package/build/dataforms-layouts/index.js +24 -0
  37. package/build/dataforms-layouts/index.js.map +1 -0
  38. package/build/dataforms-layouts/panel/index.js +129 -0
  39. package/build/dataforms-layouts/panel/index.js.map +1 -0
  40. package/build/dataforms-layouts/regular/index.js +39 -0
  41. package/build/dataforms-layouts/regular/index.js.map +1 -0
  42. package/build/dataviews-layouts/grid/density-picker.js +143 -0
  43. package/build/dataviews-layouts/grid/density-picker.js.map +1 -0
  44. package/build/{view-grid.js → dataviews-layouts/grid/index.js} +40 -41
  45. package/build/dataviews-layouts/grid/index.js.map +1 -0
  46. package/build/dataviews-layouts/index.js +52 -0
  47. package/build/dataviews-layouts/index.js.map +1 -0
  48. package/build/{view-list.js → dataviews-layouts/list/index.js} +26 -23
  49. package/build/dataviews-layouts/list/index.js.map +1 -0
  50. package/build/dataviews-layouts/table/column-header-menu.js +196 -0
  51. package/build/dataviews-layouts/table/column-header-menu.js.map +1 -0
  52. package/build/dataviews-layouts/table/index.js +350 -0
  53. package/build/dataviews-layouts/table/index.js.map +1 -0
  54. package/build/field-types/index.js +46 -0
  55. package/build/field-types/index.js.map +1 -0
  56. package/build/field-types/integer.js +94 -0
  57. package/build/field-types/integer.js.map +1 -0
  58. package/build/field-types/text.js +87 -0
  59. package/build/field-types/text.js.map +1 -0
  60. package/build/filter-and-sort-data-view.js +2 -11
  61. package/build/filter-and-sort-data-view.js.map +1 -1
  62. package/build/index.js +11 -4
  63. package/build/index.js.map +1 -1
  64. package/build/normalize-fields.js +36 -2
  65. package/build/normalize-fields.js.map +1 -1
  66. package/build/types.js.map +1 -1
  67. package/build/validation.js +22 -0
  68. package/build/validation.js.map +1 -0
  69. package/build-module/components/dataform/index.js +21 -0
  70. package/build-module/components/dataform/index.js.map +1 -0
  71. package/build-module/components/dataviews/index.js +117 -0
  72. package/build-module/components/dataviews/index.js.map +1 -0
  73. package/build-module/{bulk-actions.js → components/dataviews-bulk-actions/index.js} +42 -17
  74. package/build-module/components/dataviews-bulk-actions/index.js.map +1 -0
  75. package/build-module/{bulk-actions-toolbar.js → components/dataviews-bulk-actions-toolbar/index.js} +35 -19
  76. package/build-module/components/dataviews-bulk-actions-toolbar/index.js.map +1 -0
  77. package/build-module/components/dataviews-context/index.js +30 -0
  78. package/build-module/components/dataviews-context/index.js.map +1 -0
  79. package/build-module/{add-filter.js → components/dataviews-filters/add-filter.js} +34 -18
  80. package/build-module/components/dataviews-filters/add-filter.js.map +1 -0
  81. package/build-module/{filter-summary.js → components/dataviews-filters/filter-summary.js} +9 -9
  82. package/build-module/components/dataviews-filters/filter-summary.js.map +1 -0
  83. package/build-module/components/dataviews-filters/index.js +153 -0
  84. package/build-module/components/dataviews-filters/index.js.map +1 -0
  85. package/build-module/components/dataviews-filters/reset-filters.js.map +1 -0
  86. package/build-module/{search-widget.js → components/dataviews-filters/search-widget.js} +13 -13
  87. package/build-module/components/dataviews-filters/search-widget.js.map +1 -0
  88. package/build-module/{item-actions.js → components/dataviews-item-actions/index.js} +2 -2
  89. package/build-module/components/dataviews-item-actions/index.js.map +1 -0
  90. package/build-module/components/dataviews-layout/index.js +45 -0
  91. package/build-module/components/dataviews-layout/index.js.map +1 -0
  92. package/build-module/{pagination.js → components/dataviews-pagination/index.js} +17 -15
  93. package/build-module/components/dataviews-pagination/index.js.map +1 -0
  94. package/build-module/{search.js → components/dataviews-search/index.js} +18 -12
  95. package/build-module/components/dataviews-search/index.js.map +1 -0
  96. package/build-module/{single-selection-checkbox.js → components/dataviews-selection-checkbox/index.js} +5 -5
  97. package/build-module/components/dataviews-selection-checkbox/index.js.map +1 -0
  98. package/build-module/components/dataviews-view-config/index.js +292 -0
  99. package/build-module/components/dataviews-view-config/index.js.map +1 -0
  100. package/build-module/constants.js +5 -0
  101. package/build-module/constants.js.map +1 -1
  102. package/build-module/dataforms-layouts/index.js +16 -0
  103. package/build-module/dataforms-layouts/index.js.map +1 -0
  104. package/build-module/dataforms-layouts/panel/index.js +124 -0
  105. package/build-module/dataforms-layouts/panel/index.js.map +1 -0
  106. package/build-module/dataforms-layouts/regular/index.js +32 -0
  107. package/build-module/dataforms-layouts/regular/index.js.map +1 -0
  108. package/build-module/dataviews-layouts/grid/density-picker.js +138 -0
  109. package/build-module/dataviews-layouts/grid/density-picker.js.map +1 -0
  110. package/build-module/{view-grid.js → dataviews-layouts/grid/index.js} +38 -39
  111. package/build-module/dataviews-layouts/grid/index.js.map +1 -0
  112. package/build-module/dataviews-layouts/index.js +43 -0
  113. package/build-module/dataviews-layouts/index.js.map +1 -0
  114. package/build-module/{view-list.js → dataviews-layouts/list/index.js} +24 -21
  115. package/build-module/dataviews-layouts/list/index.js.map +1 -0
  116. package/build-module/dataviews-layouts/table/column-header-menu.js +190 -0
  117. package/build-module/dataviews-layouts/table/column-header-menu.js.map +1 -0
  118. package/build-module/dataviews-layouts/table/index.js +344 -0
  119. package/build-module/dataviews-layouts/table/index.js.map +1 -0
  120. package/build-module/field-types/index.js +40 -0
  121. package/build-module/field-types/index.js.map +1 -0
  122. package/build-module/field-types/integer.js +87 -0
  123. package/build-module/field-types/integer.js.map +1 -0
  124. package/build-module/field-types/text.js +80 -0
  125. package/build-module/field-types/text.js.map +1 -0
  126. package/build-module/filter-and-sort-data-view.js +2 -11
  127. package/build-module/filter-and-sort-data-view.js.map +1 -1
  128. package/build-module/index.js +4 -3
  129. package/build-module/index.js.map +1 -1
  130. package/build-module/normalize-fields.js +35 -3
  131. package/build-module/normalize-fields.js.map +1 -1
  132. package/build-module/types.js.map +1 -1
  133. package/build-module/validation.js +15 -0
  134. package/build-module/validation.js.map +1 -0
  135. package/build-style/style-rtl.css +763 -532
  136. package/build-style/style.css +763 -532
  137. package/build-types/components/dataform/index.d.ts +6 -0
  138. package/build-types/components/dataform/index.d.ts.map +1 -0
  139. package/build-types/components/dataform/stories/index.story.d.ts +22 -0
  140. package/build-types/components/dataform/stories/index.story.d.ts.map +1 -0
  141. package/build-types/{dataviews.d.ts → components/dataviews/index.d.ts} +9 -7
  142. package/build-types/components/dataviews/index.d.ts.map +1 -0
  143. package/build-types/{stories → components/dataviews/stories}/fixtures.d.ts +13 -19
  144. package/build-types/components/dataviews/stories/fixtures.d.ts.map +1 -0
  145. package/build-types/components/dataviews/stories/index.story.d.ts +46 -0
  146. package/build-types/components/dataviews/stories/index.story.d.ts.map +1 -0
  147. package/build-types/components/dataviews-bulk-actions/index.d.ts +5 -0
  148. package/build-types/components/dataviews-bulk-actions/index.d.ts.map +1 -0
  149. package/build-types/components/dataviews-bulk-actions-toolbar/index.d.ts +2 -0
  150. package/build-types/components/dataviews-bulk-actions-toolbar/index.d.ts.map +1 -0
  151. package/build-types/components/dataviews-context/index.d.ts +26 -0
  152. package/build-types/components/dataviews-context/index.d.ts.map +1 -0
  153. package/build-types/{add-filter.d.ts → components/dataviews-filters/add-filter.d.ts} +4 -2
  154. package/build-types/components/dataviews-filters/add-filter.d.ts.map +1 -0
  155. package/build-types/{filter-summary.d.ts → components/dataviews-filters/filter-summary.d.ts} +1 -1
  156. package/build-types/components/dataviews-filters/filter-summary.d.ts.map +1 -0
  157. package/build-types/components/dataviews-filters/index.d.ts +14 -0
  158. package/build-types/components/dataviews-filters/index.d.ts.map +1 -0
  159. package/build-types/{reset-filters.d.ts → components/dataviews-filters/reset-filters.d.ts} +1 -2
  160. package/build-types/components/dataviews-filters/reset-filters.d.ts.map +1 -0
  161. package/build-types/{search-widget.d.ts → components/dataviews-filters/search-widget.d.ts} +1 -2
  162. package/build-types/components/dataviews-filters/search-widget.d.ts.map +1 -0
  163. package/build-types/{item-actions.d.ts → components/dataviews-item-actions/index.d.ts} +2 -2
  164. package/build-types/components/dataviews-item-actions/index.d.ts.map +1 -0
  165. package/build-types/components/dataviews-layout/index.d.ts +2 -0
  166. package/build-types/components/dataviews-layout/index.d.ts.map +1 -0
  167. package/build-types/components/dataviews-pagination/index.d.ts +4 -0
  168. package/build-types/components/dataviews-pagination/index.d.ts.map +1 -0
  169. package/build-types/components/dataviews-search/index.d.ts +6 -0
  170. package/build-types/components/dataviews-search/index.d.ts.map +1 -0
  171. package/build-types/components/dataviews-selection-checkbox/index.d.ts +16 -0
  172. package/build-types/components/dataviews-selection-checkbox/index.d.ts.map +1 -0
  173. package/build-types/components/dataviews-view-config/index.d.ts +8 -0
  174. package/build-types/components/dataviews-view-config/index.d.ts.map +1 -0
  175. package/build-types/constants.d.ts +4 -0
  176. package/build-types/constants.d.ts.map +1 -1
  177. package/build-types/dataforms-layouts/index.d.ts +9 -0
  178. package/build-types/dataforms-layouts/index.d.ts.map +1 -0
  179. package/build-types/dataforms-layouts/panel/index.d.ts +3 -0
  180. package/build-types/dataforms-layouts/panel/index.d.ts.map +1 -0
  181. package/build-types/dataforms-layouts/regular/index.d.ts +3 -0
  182. package/build-types/dataforms-layouts/regular/index.d.ts.map +1 -0
  183. package/build-types/dataviews-layouts/grid/density-picker.d.ts +5 -0
  184. package/build-types/dataviews-layouts/grid/density-picker.d.ts.map +1 -0
  185. package/build-types/dataviews-layouts/grid/index.d.ts +3 -0
  186. package/build-types/dataviews-layouts/grid/index.d.ts.map +1 -0
  187. package/build-types/{layouts.d.ts → dataviews-layouts/index.d.ts} +6 -5
  188. package/build-types/dataviews-layouts/index.d.ts.map +1 -0
  189. package/build-types/dataviews-layouts/list/index.d.ts +3 -0
  190. package/build-types/dataviews-layouts/list/index.d.ts.map +1 -0
  191. package/build-types/dataviews-layouts/table/column-header-menu.d.ts +17 -0
  192. package/build-types/dataviews-layouts/table/column-header-menu.d.ts.map +1 -0
  193. package/build-types/dataviews-layouts/table/index.d.ts +4 -0
  194. package/build-types/dataviews-layouts/table/index.d.ts.map +1 -0
  195. package/build-types/field-types/index.d.ts +20 -0
  196. package/build-types/field-types/index.d.ts.map +1 -0
  197. package/build-types/field-types/integer.d.ts +14 -0
  198. package/build-types/field-types/integer.d.ts.map +1 -0
  199. package/build-types/field-types/text.d.ts +14 -0
  200. package/build-types/field-types/text.d.ts.map +1 -0
  201. package/build-types/filter-and-sort-data-view.d.ts.map +1 -1
  202. package/build-types/index.d.ts +4 -3
  203. package/build-types/index.d.ts.map +1 -1
  204. package/build-types/normalize-fields.d.ts +0 -3
  205. package/build-types/normalize-fields.d.ts.map +1 -1
  206. package/build-types/types.d.ts +73 -19
  207. package/build-types/types.d.ts.map +1 -1
  208. package/build-types/validation.d.ts +3 -0
  209. package/build-types/validation.d.ts.map +1 -0
  210. package/package.json +12 -11
  211. package/src/components/dataform/index.tsx +17 -0
  212. package/src/components/dataform/stories/index.story.tsx +79 -0
  213. package/src/components/dataviews/index.tsx +161 -0
  214. package/src/{stories → components/dataviews/stories}/fixtures.js +8 -11
  215. package/src/{stories → components/dataviews/stories}/index.story.js +17 -3
  216. package/src/components/dataviews/style.scss +100 -0
  217. package/src/{bulk-actions.tsx → components/dataviews-bulk-actions/index.tsx} +51 -29
  218. package/src/components/dataviews-bulk-actions/style.scss +7 -0
  219. package/src/{bulk-actions-toolbar.tsx → components/dataviews-bulk-actions-toolbar/index.tsx} +42 -30
  220. package/src/components/dataviews-bulk-actions-toolbar/style.scss +45 -0
  221. package/src/components/dataviews-context/index.ts +49 -0
  222. package/src/{add-filter.tsx → components/dataviews-filters/add-filter.tsx} +39 -23
  223. package/src/{filter-summary.tsx → components/dataviews-filters/filter-summary.tsx} +18 -10
  224. package/src/components/dataviews-filters/index.tsx +199 -0
  225. package/src/{reset-filters.tsx → components/dataviews-filters/reset-filters.tsx} +1 -1
  226. package/src/{search-widget.tsx → components/dataviews-filters/search-widget.tsx} +14 -14
  227. package/src/components/dataviews-filters/style.scss +282 -0
  228. package/src/{item-actions.tsx → components/dataviews-item-actions/index.tsx} +2 -2
  229. package/src/components/dataviews-item-actions/style.scss +3 -0
  230. package/src/components/dataviews-layout/index.tsx +51 -0
  231. package/src/{pagination.tsx → components/dataviews-pagination/index.tsx} +13 -21
  232. package/src/components/dataviews-pagination/style.scss +26 -0
  233. package/src/{search.tsx → components/dataviews-search/index.tsx} +13 -15
  234. package/src/{single-selection-checkbox.tsx → components/dataviews-selection-checkbox/index.tsx} +9 -9
  235. package/src/components/dataviews-selection-checkbox/style.scss +14 -0
  236. package/src/components/dataviews-view-config/index.tsx +358 -0
  237. package/src/components/dataviews-view-config/style.scss +44 -0
  238. package/src/constants.ts +5 -0
  239. package/src/dataforms-layouts/index.tsx +20 -0
  240. package/src/dataforms-layouts/panel/index.tsx +164 -0
  241. package/src/dataforms-layouts/panel/style.scss +59 -0
  242. package/src/dataforms-layouts/regular/index.tsx +41 -0
  243. package/src/dataviews-layouts/grid/density-picker.tsx +136 -0
  244. package/src/{view-grid.tsx → dataviews-layouts/grid/index.tsx} +35 -36
  245. package/src/dataviews-layouts/grid/style.scss +169 -0
  246. package/src/dataviews-layouts/index.ts +66 -0
  247. package/src/{view-list.tsx → dataviews-layouts/list/index.tsx} +30 -17
  248. package/src/dataviews-layouts/list/style.scss +192 -0
  249. package/src/dataviews-layouts/table/column-header-menu.tsx +268 -0
  250. package/src/dataviews-layouts/table/index.tsx +471 -0
  251. package/src/dataviews-layouts/table/style.scss +201 -0
  252. package/src/field-types/index.tsx +45 -0
  253. package/src/field-types/integer.tsx +103 -0
  254. package/src/field-types/text.tsx +95 -0
  255. package/src/filter-and-sort-data-view.ts +1 -15
  256. package/src/index.ts +4 -3
  257. package/src/normalize-fields.ts +45 -4
  258. package/src/style.scss +14 -907
  259. package/src/test/filter-and-sort-data-view.js +47 -4
  260. package/src/test/validation.ts +131 -0
  261. package/src/types.ts +88 -17
  262. package/src/validation.ts +18 -0
  263. package/tsconfig.json +2 -1
  264. package/tsconfig.tsbuildinfo +1 -1
  265. package/build/add-filter.js.map +0 -1
  266. package/build/bulk-actions-toolbar.js.map +0 -1
  267. package/build/bulk-actions.js.map +0 -1
  268. package/build/dataform.js +0 -78
  269. package/build/dataform.js.map +0 -1
  270. package/build/dataviews.js +0 -125
  271. package/build/dataviews.js.map +0 -1
  272. package/build/filter-summary.js.map +0 -1
  273. package/build/filters.js +0 -102
  274. package/build/filters.js.map +0 -1
  275. package/build/item-actions.js.map +0 -1
  276. package/build/layouts.js +0 -38
  277. package/build/layouts.js.map +0 -1
  278. package/build/pagination.js.map +0 -1
  279. package/build/reset-filters.js.map +0 -1
  280. package/build/search-widget.js.map +0 -1
  281. package/build/search.js.map +0 -1
  282. package/build/single-selection-checkbox.js.map +0 -1
  283. package/build/view-actions.js +0 -260
  284. package/build/view-actions.js.map +0 -1
  285. package/build/view-grid.js.map +0 -1
  286. package/build/view-list.js.map +0 -1
  287. package/build/view-table.js +0 -400
  288. package/build/view-table.js.map +0 -1
  289. package/build-module/add-filter.js.map +0 -1
  290. package/build-module/bulk-actions-toolbar.js.map +0 -1
  291. package/build-module/bulk-actions.js.map +0 -1
  292. package/build-module/dataform.js +0 -72
  293. package/build-module/dataform.js.map +0 -1
  294. package/build-module/dataviews.js +0 -116
  295. package/build-module/dataviews.js.map +0 -1
  296. package/build-module/filter-summary.js.map +0 -1
  297. package/build-module/filters.js +0 -94
  298. package/build-module/filters.js.map +0 -1
  299. package/build-module/item-actions.js.map +0 -1
  300. package/build-module/layouts.js +0 -30
  301. package/build-module/layouts.js.map +0 -1
  302. package/build-module/pagination.js.map +0 -1
  303. package/build-module/reset-filters.js.map +0 -1
  304. package/build-module/search-widget.js.map +0 -1
  305. package/build-module/search.js.map +0 -1
  306. package/build-module/single-selection-checkbox.js.map +0 -1
  307. package/build-module/view-actions.js +0 -255
  308. package/build-module/view-actions.js.map +0 -1
  309. package/build-module/view-grid.js.map +0 -1
  310. package/build-module/view-list.js.map +0 -1
  311. package/build-module/view-table.js +0 -393
  312. package/build-module/view-table.js.map +0 -1
  313. package/build-types/add-filter.d.ts.map +0 -1
  314. package/build-types/bulk-actions-toolbar.d.ts +0 -13
  315. package/build-types/bulk-actions-toolbar.d.ts.map +0 -1
  316. package/build-types/bulk-actions.d.ts +0 -15
  317. package/build-types/bulk-actions.d.ts.map +0 -1
  318. package/build-types/dataform.d.ts +0 -17
  319. package/build-types/dataform.d.ts.map +0 -1
  320. package/build-types/dataviews.d.ts.map +0 -1
  321. package/build-types/filter-summary.d.ts.map +0 -1
  322. package/build-types/filters.d.ts +0 -13
  323. package/build-types/filters.d.ts.map +0 -1
  324. package/build-types/item-actions.d.ts.map +0 -1
  325. package/build-types/layouts.d.ts.map +0 -1
  326. package/build-types/pagination.d.ts +0 -16
  327. package/build-types/pagination.d.ts.map +0 -1
  328. package/build-types/reset-filters.d.ts.map +0 -1
  329. package/build-types/search-widget.d.ts.map +0 -1
  330. package/build-types/search.d.ts +0 -13
  331. package/build-types/search.d.ts.map +0 -1
  332. package/build-types/single-selection-checkbox.d.ts +0 -17
  333. package/build-types/single-selection-checkbox.d.ts.map +0 -1
  334. package/build-types/stories/fixtures.d.ts.map +0 -1
  335. package/build-types/stories/index.story.d.ts +0 -29
  336. package/build-types/stories/index.story.d.ts.map +0 -1
  337. package/build-types/view-actions.d.ts +0 -12
  338. package/build-types/view-actions.d.ts.map +0 -1
  339. package/build-types/view-grid.d.ts +0 -4
  340. package/build-types/view-grid.d.ts.map +0 -1
  341. package/build-types/view-list.d.ts +0 -4
  342. package/build-types/view-list.d.ts.map +0 -1
  343. package/build-types/view-table.d.ts +0 -5
  344. package/build-types/view-table.d.ts.map +0 -1
  345. package/src/dataform.tsx +0 -106
  346. package/src/dataviews.tsx +0 -183
  347. package/src/filters.tsx +0 -125
  348. package/src/layouts.ts +0 -39
  349. package/src/view-actions.tsx +0 -350
  350. package/src/view-table.tsx +0 -592
  351. /package/build/{reset-filters.js → components/dataviews-filters/reset-filters.js} +0 -0
  352. /package/build-module/{reset-filters.js → components/dataviews-filters/reset-filters.js} +0 -0
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+ import FormRegular from './regular';
5
+ import FormPanel from './panel';
6
+
7
+ const FORM_LAYOUTS = [
8
+ {
9
+ type: 'regular',
10
+ component: FormRegular,
11
+ },
12
+ {
13
+ type: 'panel',
14
+ component: FormPanel,
15
+ },
16
+ ];
17
+
18
+ export function getFormLayout( type: string ) {
19
+ return FORM_LAYOUTS.find( ( layout ) => layout.type === type );
20
+ }
@@ -0,0 +1,164 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import {
5
+ __experimentalVStack as VStack,
6
+ __experimentalHStack as HStack,
7
+ __experimentalHeading as Heading,
8
+ __experimentalSpacer as Spacer,
9
+ Dropdown,
10
+ Button,
11
+ } from '@wordpress/components';
12
+ import { useState, useMemo } from '@wordpress/element';
13
+ import { sprintf, __ } from '@wordpress/i18n';
14
+ import { closeSmall } from '@wordpress/icons';
15
+
16
+ /**
17
+ * Internal dependencies
18
+ */
19
+ import { normalizeFields } from '../../normalize-fields';
20
+ import type { DataFormProps, NormalizedField } from '../../types';
21
+
22
+ interface FormFieldProps< Item > {
23
+ data: Item;
24
+ field: NormalizedField< Item >;
25
+ onChange: ( value: any ) => void;
26
+ }
27
+
28
+ function DropdownHeader( {
29
+ title,
30
+ onClose,
31
+ }: {
32
+ title: string;
33
+ onClose: () => void;
34
+ } ) {
35
+ return (
36
+ <VStack
37
+ className="dataforms-layouts-panel__dropdown-header"
38
+ spacing={ 4 }
39
+ >
40
+ <HStack alignment="center">
41
+ <Heading level={ 2 } size={ 13 }>
42
+ { title }
43
+ </Heading>
44
+ <Spacer />
45
+ { onClose && (
46
+ <Button
47
+ className="dataforms-layouts-panel__dropdown-header-action"
48
+ label={ __( 'Close' ) }
49
+ icon={ closeSmall }
50
+ onClick={ onClose }
51
+ />
52
+ ) }
53
+ </HStack>
54
+ </VStack>
55
+ );
56
+ }
57
+
58
+ function FormField< Item >( {
59
+ data,
60
+ field,
61
+ onChange,
62
+ }: FormFieldProps< Item > ) {
63
+ // Use internal state instead of a ref to make sure that the component
64
+ // re-renders when the popover's anchor updates.
65
+ const [ popoverAnchor, setPopoverAnchor ] = useState< HTMLElement | null >(
66
+ null
67
+ );
68
+ // Memoize popoverProps to avoid returning a new object every time.
69
+ const popoverProps = useMemo(
70
+ () => ( {
71
+ // Anchor the popover to the middle of the entire row so that it doesn't
72
+ // move around when the label changes.
73
+ anchor: popoverAnchor,
74
+ placement: 'left-start',
75
+ offset: 36,
76
+ shift: true,
77
+ } ),
78
+ [ popoverAnchor ]
79
+ );
80
+
81
+ return (
82
+ <HStack
83
+ ref={ setPopoverAnchor }
84
+ className="dataforms-layouts-panel__field"
85
+ >
86
+ <div className="dataforms-layouts-panel__field-label">
87
+ { field.label }
88
+ </div>
89
+ <div>
90
+ <Dropdown
91
+ contentClassName="dataforms-layouts-panel__field-dropdown"
92
+ popoverProps={ popoverProps }
93
+ focusOnMount
94
+ toggleProps={ {
95
+ size: 'compact',
96
+ variant: 'tertiary',
97
+ tooltipPosition: 'middle left',
98
+ } }
99
+ renderToggle={ ( { isOpen, onToggle } ) => (
100
+ <Button
101
+ className="dataforms-layouts-panel__field-control"
102
+ size="compact"
103
+ variant="tertiary"
104
+ aria-expanded={ isOpen }
105
+ aria-label={ sprintf(
106
+ // translators: %s: Field name.
107
+ __( 'Edit %s' ),
108
+ field.label
109
+ ) }
110
+ onClick={ onToggle }
111
+ >
112
+ <field.render item={ data } />
113
+ </Button>
114
+ ) }
115
+ renderContent={ ( { onClose } ) => (
116
+ <>
117
+ <DropdownHeader
118
+ title={ field.label }
119
+ onClose={ onClose }
120
+ />
121
+ <field.Edit
122
+ key={ field.id }
123
+ data={ data }
124
+ field={ field }
125
+ onChange={ onChange }
126
+ hideLabelFromVision
127
+ />
128
+ </>
129
+ ) }
130
+ />
131
+ </div>
132
+ </HStack>
133
+ );
134
+ }
135
+
136
+ export default function FormPanel< Item >( {
137
+ data,
138
+ fields,
139
+ form,
140
+ onChange,
141
+ }: DataFormProps< Item > ) {
142
+ const visibleFields = useMemo(
143
+ () =>
144
+ normalizeFields(
145
+ fields.filter( ( { id } ) => !! form.fields?.includes( id ) )
146
+ ),
147
+ [ fields, form.fields ]
148
+ );
149
+
150
+ return (
151
+ <VStack spacing={ 2 }>
152
+ { visibleFields.map( ( field ) => {
153
+ return (
154
+ <FormField
155
+ key={ field.id }
156
+ data={ data }
157
+ field={ field }
158
+ onChange={ onChange }
159
+ />
160
+ );
161
+ } ) }
162
+ </VStack>
163
+ );
164
+ }
@@ -0,0 +1,59 @@
1
+ .dataforms-layouts-panel__field {
2
+ width: 100%;
3
+ min-height: $grid-unit-40;
4
+ justify-content: flex-start !important;
5
+ align-items: flex-start !important;
6
+ }
7
+
8
+ .dataforms-layouts-panel__field-label {
9
+ width: 38%;
10
+ flex-shrink: 0;
11
+ min-height: $grid-unit-40;
12
+ display: flex;
13
+ align-items: center;
14
+ padding: 6px 0; // Matches button to ensure alignment
15
+ line-height: $grid-unit-05 * 5;
16
+ hyphens: auto;
17
+ }
18
+
19
+ .dataforms-layouts-panel__field-control {
20
+ flex-grow: 1;
21
+ min-height: $grid-unit-40;
22
+ display: flex;
23
+ align-items: center;
24
+
25
+ .components-button {
26
+ max-width: 100%;
27
+ text-align: left;
28
+ white-space: normal;
29
+ text-wrap: balance; // Fallback for Safari.
30
+ text-wrap: pretty;
31
+ min-height: $button-size-compact;
32
+ }
33
+
34
+ .components-dropdown {
35
+ max-width: 100%;
36
+ }
37
+ }
38
+
39
+ .dataforms-layouts-panel__field-dropdown .components-popover__content {
40
+ min-width: 320px;
41
+ padding: $grid-unit-20;
42
+ }
43
+
44
+ .dataforms-layouts-panel__dropdown-header {
45
+ margin-bottom: $grid-unit-20;
46
+ }
47
+
48
+ [class].dataforms-layouts-panel__dropdown-header-action {
49
+ height: $icon-size;
50
+
51
+ &.has-icon {
52
+ min-width: $icon-size;
53
+ padding: 0;
54
+ }
55
+
56
+ &:not(.has-icon) {
57
+ text-decoration: underline;
58
+ }
59
+ }
@@ -0,0 +1,41 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { __experimentalVStack as VStack } from '@wordpress/components';
5
+ import { useMemo } from '@wordpress/element';
6
+
7
+ /**
8
+ * Internal dependencies
9
+ */
10
+ import { normalizeFields } from '../../normalize-fields';
11
+ import type { DataFormProps } from '../../types';
12
+
13
+ export default function FormRegular< Item >( {
14
+ data,
15
+ fields,
16
+ form,
17
+ onChange,
18
+ }: DataFormProps< Item > ) {
19
+ const visibleFields = useMemo(
20
+ () =>
21
+ normalizeFields(
22
+ fields.filter( ( { id } ) => !! form.fields?.includes( id ) )
23
+ ),
24
+ [ fields, form.fields ]
25
+ );
26
+
27
+ return (
28
+ <VStack spacing={ 4 }>
29
+ { visibleFields.map( ( field ) => {
30
+ return (
31
+ <field.Edit
32
+ key={ field.id }
33
+ data={ data }
34
+ field={ field }
35
+ onChange={ onChange }
36
+ />
37
+ );
38
+ } ) }
39
+ </VStack>
40
+ );
41
+ }
@@ -0,0 +1,136 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { RangeControl, Button } from '@wordpress/components';
5
+ import { __ } from '@wordpress/i18n';
6
+ import { useViewportMatch } from '@wordpress/compose';
7
+ import { plus, reset } from '@wordpress/icons';
8
+ import { useEffect } from '@wordpress/element';
9
+
10
+ const viewportBreaks = {
11
+ xhuge: { min: 3, max: 6, default: 5 },
12
+ huge: { min: 2, max: 4, default: 4 },
13
+ xlarge: { min: 2, max: 3, default: 3 },
14
+ large: { min: 1, max: 2, default: 2 },
15
+ mobile: { min: 1, max: 2, default: 2 },
16
+ };
17
+
18
+ function useViewPortBreakpoint() {
19
+ const isXHuge = useViewportMatch( 'xhuge', '>=' );
20
+ const isHuge = useViewportMatch( 'huge', '>=' );
21
+ const isXlarge = useViewportMatch( 'xlarge', '>=' );
22
+ const isLarge = useViewportMatch( 'large', '>=' );
23
+ const isMobile = useViewportMatch( 'mobile', '>=' );
24
+
25
+ if ( isXHuge ) {
26
+ return 'xhuge';
27
+ }
28
+ if ( isHuge ) {
29
+ return 'huge';
30
+ }
31
+ if ( isXlarge ) {
32
+ return 'xlarge';
33
+ }
34
+ if ( isLarge ) {
35
+ return 'large';
36
+ }
37
+ if ( isMobile ) {
38
+ return 'mobile';
39
+ }
40
+ return null;
41
+ }
42
+
43
+ // Value is number from 0 to 100 representing how big an item is in the grid
44
+ // 100 being the biggest and 0 being the smallest.
45
+ // The size is relative to the viewport size, if one a given viewport the
46
+ // number of allowed items in a grid is 3 to 6 a 0 ( the smallest ) will mean that the grid will
47
+ // have 6 items in a row, a 100 ( the biggest ) will mean that the grid will have 3 items in a row.
48
+ // A value of 75 will mean that the grid will have 4 items in a row.
49
+ function getRangeValue(
50
+ density: number,
51
+ breakValues: { min: number; max: number; default: number }
52
+ ) {
53
+ const inverseDensity = breakValues.max - density;
54
+ const max = breakValues.max - breakValues.min;
55
+ return Math.round( ( inverseDensity * 100 ) / max );
56
+ }
57
+
58
+ export default function DensityPicker( {
59
+ density,
60
+ setDensity,
61
+ }: {
62
+ density: number;
63
+ setDensity: React.Dispatch< React.SetStateAction< number > >;
64
+ } ) {
65
+ const viewport = useViewPortBreakpoint();
66
+ useEffect( () => {
67
+ setDensity( ( _density ) => {
68
+ if ( ! viewport || ! _density ) {
69
+ return 0;
70
+ }
71
+ const breakValues = viewportBreaks[ viewport ];
72
+ if ( _density < breakValues.min ) {
73
+ return breakValues.min;
74
+ }
75
+ if ( _density > breakValues.max ) {
76
+ return breakValues.max;
77
+ }
78
+ return _density;
79
+ } );
80
+ }, [ setDensity, viewport ] );
81
+ if ( ! viewport ) {
82
+ return null;
83
+ }
84
+ const breakValues = viewportBreaks[ viewport ];
85
+ const densityToUse = density || breakValues.default;
86
+ const rangeValue = getRangeValue( densityToUse, breakValues );
87
+
88
+ const step = 100 / ( breakValues.max - breakValues.min + 1 );
89
+ return (
90
+ <>
91
+ <Button
92
+ size="compact"
93
+ icon={ reset }
94
+ disabled={ rangeValue <= 0 }
95
+ accessibleWhenDisabled
96
+ label={ __( 'Decrease size' ) }
97
+ onClick={ () => {
98
+ setDensity( densityToUse + 1 );
99
+ } }
100
+ />
101
+ <RangeControl
102
+ __nextHasNoMarginBottom
103
+ showTooltip={ false }
104
+ className="dataviews-density-picker__range-control"
105
+ label={ __( 'Item size' ) }
106
+ hideLabelFromVision
107
+ value={ rangeValue }
108
+ min={ 0 }
109
+ max={ 100 }
110
+ withInputField={ false }
111
+ onChange={ ( value = 0 ) => {
112
+ const inverseValue = 100 - value;
113
+ setDensity(
114
+ Math.round(
115
+ ( inverseValue *
116
+ ( breakValues.max - breakValues.min ) ) /
117
+ 100 +
118
+ breakValues.min
119
+ )
120
+ );
121
+ } }
122
+ step={ step }
123
+ />
124
+ <Button
125
+ size="compact"
126
+ icon={ plus }
127
+ disabled={ rangeValue >= 100 }
128
+ accessibleWhenDisabled
129
+ label={ __( 'Increase size' ) }
130
+ onClick={ () => {
131
+ setDensity( densityToUse - 1 );
132
+ } }
133
+ />
134
+ </>
135
+ );
136
+ }
@@ -19,15 +19,15 @@ import { __ } from '@wordpress/i18n';
19
19
  /**
20
20
  * Internal dependencies
21
21
  */
22
- import ItemActions from './item-actions';
23
- import SingleSelectionCheckbox from './single-selection-checkbox';
24
- import { useHasAPossibleBulkAction } from './bulk-actions';
25
- import type { Action, NormalizedField, ViewGridProps } from './types';
26
- import type { SetSelection } from './private-types';
22
+ import ItemActions from '../../components/dataviews-item-actions';
23
+ import SingleSelectionCheckbox from '../../components/dataviews-selection-checkbox';
24
+ import { useHasAPossibleBulkAction } from '../../components/dataviews-bulk-actions';
25
+ import type { Action, NormalizedField, ViewGridProps } from '../../types';
26
+ import type { SetSelection } from '../../private-types';
27
27
 
28
28
  interface GridItemProps< Item > {
29
29
  selection: string[];
30
- onSelectionChange: SetSelection;
30
+ onChangeSelection: SetSelection;
31
31
  getItemId: ( item: Item ) => string;
32
32
  item: Item;
33
33
  actions: Action< Item >[];
@@ -40,7 +40,7 @@ interface GridItemProps< Item > {
40
40
 
41
41
  function GridItem< Item >( {
42
42
  selection,
43
- onSelectionChange,
43
+ onChangeSelection,
44
44
  getItemId,
45
45
  item,
46
46
  actions,
@@ -53,6 +53,12 @@ function GridItem< Item >( {
53
53
  const hasBulkAction = useHasAPossibleBulkAction( actions, item );
54
54
  const id = getItemId( item );
55
55
  const isSelected = selection.includes( id );
56
+ const renderedMediaField = mediaField?.render ? (
57
+ <mediaField.render item={ item } />
58
+ ) : null;
59
+ const renderedPrimaryField = primaryField?.render ? (
60
+ <primaryField.render item={ item } />
61
+ ) : null;
56
62
  return (
57
63
  <VStack
58
64
  spacing={ 0 }
@@ -67,7 +73,7 @@ function GridItem< Item >( {
67
73
  if ( ! hasBulkAction ) {
68
74
  return;
69
75
  }
70
- onSelectionChange(
76
+ onChangeSelection(
71
77
  selection.includes( id )
72
78
  ? selection.filter( ( itemId ) => id !== itemId )
73
79
  : [ ...selection, id ]
@@ -76,22 +82,22 @@ function GridItem< Item >( {
76
82
  } }
77
83
  >
78
84
  <div className="dataviews-view-grid__media">
79
- { mediaField?.render( { item } ) }
85
+ { renderedMediaField }
80
86
  </div>
87
+ <SingleSelectionCheckbox
88
+ item={ item }
89
+ selection={ selection }
90
+ onChangeSelection={ onChangeSelection }
91
+ getItemId={ getItemId }
92
+ primaryField={ primaryField }
93
+ disabled={ ! hasBulkAction }
94
+ />
81
95
  <HStack
82
96
  justify="space-between"
83
97
  className="dataviews-view-grid__title-actions"
84
98
  >
85
- <SingleSelectionCheckbox
86
- item={ item }
87
- selection={ selection }
88
- onSelectionChange={ onSelectionChange }
89
- getItemId={ getItemId }
90
- primaryField={ primaryField }
91
- disabled={ ! hasBulkAction }
92
- />
93
99
  <HStack className="dataviews-view-grid__primary-field">
94
- { primaryField?.render( { item } ) }
100
+ { renderedPrimaryField }
95
101
  </HStack>
96
102
  <ItemActions item={ item } actions={ actions } isCompact />
97
103
  </HStack>
@@ -104,32 +110,20 @@ function GridItem< Item >( {
104
110
  justify="flex-start"
105
111
  >
106
112
  { badgeFields.map( ( field ) => {
107
- const renderedValue = field.render( {
108
- item,
109
- } );
110
- if ( ! renderedValue ) {
111
- return null;
112
- }
113
113
  return (
114
114
  <FlexItem
115
115
  key={ field.id }
116
116
  className="dataviews-view-grid__field-value"
117
117
  >
118
- { renderedValue }
118
+ <field.render item={ item } />
119
119
  </FlexItem>
120
120
  );
121
121
  } ) }
122
122
  </HStack>
123
123
  ) }
124
124
  { !! visibleFields?.length && (
125
- <VStack className="dataviews-view-grid__fields" spacing={ 3 }>
125
+ <VStack className="dataviews-view-grid__fields" spacing={ 1 }>
126
126
  { visibleFields.map( ( field ) => {
127
- const renderedValue = field.render( {
128
- item,
129
- } );
130
- if ( ! renderedValue ) {
131
- return null;
132
- }
133
127
  return (
134
128
  <Flex
135
129
  className={ clsx(
@@ -151,13 +145,13 @@ function GridItem< Item >( {
151
145
  >
152
146
  <>
153
147
  <FlexItem className="dataviews-view-grid__field-name">
154
- { field.header }
148
+ { field.label }
155
149
  </FlexItem>
156
150
  <FlexItem
157
151
  className="dataviews-view-grid__field-value"
158
152
  style={ { maxHeight: 'none' } }
159
153
  >
160
- { renderedValue }
154
+ <field.render item={ item } />
161
155
  </FlexItem>
162
156
  </>
163
157
  </Flex>
@@ -175,9 +169,10 @@ export default function ViewGrid< Item >( {
175
169
  fields,
176
170
  getItemId,
177
171
  isLoading,
178
- onSelectionChange,
172
+ onChangeSelection,
179
173
  selection,
180
174
  view,
175
+ density,
181
176
  }: ViewGridProps< Item > ) {
182
177
  const mediaField = fields.find(
183
178
  ( field ) => field.id === view.layout?.mediaField
@@ -208,6 +203,9 @@ export default function ViewGrid< Item >( {
208
203
  { visibleFields: [], badgeFields: [] }
209
204
  );
210
205
  const hasData = !! data?.length;
206
+ const gridStyle = density
207
+ ? { gridTemplateColumns: `repeat(${ density }, minmax(0, 1fr))` }
208
+ : {};
211
209
  return (
212
210
  <>
213
211
  { hasData && (
@@ -216,6 +214,7 @@ export default function ViewGrid< Item >( {
216
214
  columns={ 2 }
217
215
  alignment="top"
218
216
  className="dataviews-view-grid"
217
+ style={ gridStyle }
219
218
  aria-busy={ isLoading }
220
219
  >
221
220
  { data.map( ( item ) => {
@@ -223,7 +222,7 @@ export default function ViewGrid< Item >( {
223
222
  <GridItem
224
223
  key={ getItemId( item ) }
225
224
  selection={ selection }
226
- onSelectionChange={ onSelectionChange }
225
+ onChangeSelection={ onChangeSelection }
227
226
  getItemId={ getItemId }
228
227
  item={ item }
229
228
  actions={ actions }