@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
@@ -122,17 +122,8 @@ function filterSortAndPaginate(data, view, fields) {
122
122
  });
123
123
  if (fieldToSort) {
124
124
  filteredData.sort((a, b) => {
125
- var _fieldToSort$getValue, _fieldToSort$getValue2;
126
- const valueA = (_fieldToSort$getValue = fieldToSort.getValue({
127
- item: a
128
- })) !== null && _fieldToSort$getValue !== void 0 ? _fieldToSort$getValue : '';
129
- const valueB = (_fieldToSort$getValue2 = fieldToSort.getValue({
130
- item: b
131
- })) !== null && _fieldToSort$getValue2 !== void 0 ? _fieldToSort$getValue2 : '';
132
- if (typeof valueA === 'number' && typeof valueB === 'number') {
133
- return view.sort?.direction === 'asc' ? valueA - valueB : valueB - valueA;
134
- }
135
- return view.sort?.direction === 'asc' ? valueA.localeCompare(valueB) : valueB.localeCompare(valueA);
125
+ var _view$sort$direction;
126
+ return fieldToSort.sort(a, b, (_view$sort$direction = view.sort?.direction) !== null && _view$sort$direction !== void 0 ? _view$sort$direction : 'desc');
136
127
  });
137
128
  }
138
129
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_removeAccents","_interopRequireDefault","require","_constants","_normalizeFields","normalizeSearchInput","input","removeAccents","trim","toLowerCase","EMPTY_ARRAY","filterSortAndPaginate","data","view","fields","paginationInfo","totalItems","totalPages","_fields","normalizeFields","filteredData","search","normalizedSearch","filter","item","field","enableGlobalSearch","map","getValue","some","includes","filters","length","forEach","find","_field","id","operator","OPERATOR_IS_ANY","value","fieldValue","Array","isArray","filterValue","OPERATOR_IS_NONE","OPERATOR_IS_ALL","every","OPERATOR_IS_NOT_ALL","OPERATOR_IS","OPERATOR_IS_NOT","sort","fieldId","fieldToSort","a","b","_fieldToSort$getValue","_fieldToSort$getValue2","valueA","valueB","direction","localeCompare","page","undefined","perPage","start","Math","ceil","slice"],"sources":["@wordpress/dataviews/src/filter-and-sort-data-view.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport removeAccents from 'remove-accents';\n\n/**\n * Internal dependencies\n */\nimport {\n\tOPERATOR_IS,\n\tOPERATOR_IS_NOT,\n\tOPERATOR_IS_NONE,\n\tOPERATOR_IS_ANY,\n\tOPERATOR_IS_ALL,\n\tOPERATOR_IS_NOT_ALL,\n} from './constants';\nimport { normalizeFields } from './normalize-fields';\nimport type { Field, View } from './types';\n\nfunction normalizeSearchInput( input = '' ) {\n\treturn removeAccents( input.trim().toLowerCase() );\n}\n\nconst EMPTY_ARRAY: [] = [];\n\n/**\n * Applies the filtering, sorting and pagination to the raw data based on the view configuration.\n *\n * @param data Raw data.\n * @param view View config.\n * @param fields Fields config.\n *\n * @return Filtered, sorted and paginated data.\n */\nexport function filterSortAndPaginate< Item >(\n\tdata: Item[],\n\tview: View,\n\tfields: Field< Item >[]\n): {\n\tdata: Item[];\n\tpaginationInfo: { totalItems: number; totalPages: number };\n} {\n\tif ( ! data ) {\n\t\treturn {\n\t\t\tdata: EMPTY_ARRAY,\n\t\t\tpaginationInfo: { totalItems: 0, totalPages: 0 },\n\t\t};\n\t}\n\tconst _fields = normalizeFields( fields );\n\tlet filteredData = [ ...data ];\n\t// Handle global search.\n\tif ( view.search ) {\n\t\tconst normalizedSearch = normalizeSearchInput( view.search );\n\t\tfilteredData = filteredData.filter( ( item ) => {\n\t\t\treturn _fields\n\t\t\t\t.filter( ( field ) => field.enableGlobalSearch )\n\t\t\t\t.map( ( field ) => {\n\t\t\t\t\treturn normalizeSearchInput( field.getValue( { item } ) );\n\t\t\t\t} )\n\t\t\t\t.some( ( field ) => field.includes( normalizedSearch ) );\n\t\t} );\n\t}\n\n\tif ( view.filters && view.filters?.length > 0 ) {\n\t\tview.filters.forEach( ( filter ) => {\n\t\t\tconst field = _fields.find(\n\t\t\t\t( _field ) => _field.id === filter.field\n\t\t\t);\n\t\t\tif ( field ) {\n\t\t\t\tif (\n\t\t\t\t\tfilter.operator === OPERATOR_IS_ANY &&\n\t\t\t\t\tfilter?.value?.length > 0\n\t\t\t\t) {\n\t\t\t\t\tfilteredData = filteredData.filter( ( item ) => {\n\t\t\t\t\t\tconst fieldValue = field.getValue( { item } );\n\t\t\t\t\t\tif ( Array.isArray( fieldValue ) ) {\n\t\t\t\t\t\t\treturn filter.value.some( ( filterValue: any ) =>\n\t\t\t\t\t\t\t\tfieldValue.includes( filterValue )\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} else if ( typeof fieldValue === 'string' ) {\n\t\t\t\t\t\t\treturn filter.value.includes( fieldValue );\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t} );\n\t\t\t\t} else if (\n\t\t\t\t\tfilter.operator === OPERATOR_IS_NONE &&\n\t\t\t\t\tfilter?.value?.length > 0\n\t\t\t\t) {\n\t\t\t\t\tfilteredData = filteredData.filter( ( item ) => {\n\t\t\t\t\t\tconst fieldValue = field.getValue( { item } );\n\t\t\t\t\t\tif ( Array.isArray( fieldValue ) ) {\n\t\t\t\t\t\t\treturn ! filter.value.some( ( filterValue: any ) =>\n\t\t\t\t\t\t\t\tfieldValue.includes( filterValue )\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} else if ( typeof fieldValue === 'string' ) {\n\t\t\t\t\t\t\treturn ! filter.value.includes( fieldValue );\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t} );\n\t\t\t\t} else if (\n\t\t\t\t\tfilter.operator === OPERATOR_IS_ALL &&\n\t\t\t\t\tfilter?.value?.length > 0\n\t\t\t\t) {\n\t\t\t\t\tfilteredData = filteredData.filter( ( item ) => {\n\t\t\t\t\t\treturn filter.value.every( ( value: any ) => {\n\t\t\t\t\t\t\treturn field\n\t\t\t\t\t\t\t\t.getValue( { item } )\n\t\t\t\t\t\t\t\t?.includes( value );\n\t\t\t\t\t\t} );\n\t\t\t\t\t} );\n\t\t\t\t} else if (\n\t\t\t\t\tfilter.operator === OPERATOR_IS_NOT_ALL &&\n\t\t\t\t\tfilter?.value?.length > 0\n\t\t\t\t) {\n\t\t\t\t\tfilteredData = filteredData.filter( ( item ) => {\n\t\t\t\t\t\treturn filter.value.every( ( value: any ) => {\n\t\t\t\t\t\t\treturn ! field\n\t\t\t\t\t\t\t\t.getValue( { item } )\n\t\t\t\t\t\t\t\t?.includes( value );\n\t\t\t\t\t\t} );\n\t\t\t\t\t} );\n\t\t\t\t} else if ( filter.operator === OPERATOR_IS ) {\n\t\t\t\t\tfilteredData = filteredData.filter( ( item ) => {\n\t\t\t\t\t\treturn filter.value === field.getValue( { item } );\n\t\t\t\t\t} );\n\t\t\t\t} else if ( filter.operator === OPERATOR_IS_NOT ) {\n\t\t\t\t\tfilteredData = filteredData.filter( ( item ) => {\n\t\t\t\t\t\treturn filter.value !== field.getValue( { item } );\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t}\n\t\t} );\n\t}\n\n\t// Handle sorting.\n\tif ( view.sort ) {\n\t\tconst fieldId = view.sort.field;\n\t\tconst fieldToSort = _fields.find( ( field ) => {\n\t\t\treturn field.id === fieldId;\n\t\t} );\n\t\tif ( fieldToSort ) {\n\t\t\tfilteredData.sort( ( a, b ) => {\n\t\t\t\tconst valueA = fieldToSort.getValue( { item: a } ) ?? '';\n\t\t\t\tconst valueB = fieldToSort.getValue( { item: b } ) ?? '';\n\n\t\t\t\tif (\n\t\t\t\t\ttypeof valueA === 'number' &&\n\t\t\t\t\ttypeof valueB === 'number'\n\t\t\t\t) {\n\t\t\t\t\treturn view.sort?.direction === 'asc'\n\t\t\t\t\t\t? valueA - valueB\n\t\t\t\t\t\t: valueB - valueA;\n\t\t\t\t}\n\n\t\t\t\treturn view.sort?.direction === 'asc'\n\t\t\t\t\t? valueA.localeCompare( valueB )\n\t\t\t\t\t: valueB.localeCompare( valueA );\n\t\t\t} );\n\t\t}\n\t}\n\n\t// Handle pagination.\n\tlet totalItems = filteredData.length;\n\tlet totalPages = 1;\n\tif ( view.page !== undefined && view.perPage !== undefined ) {\n\t\tconst start = ( view.page - 1 ) * view.perPage;\n\t\ttotalItems = filteredData?.length || 0;\n\t\ttotalPages = Math.ceil( totalItems / view.perPage );\n\t\tfilteredData = filteredData?.slice( start, start + view.perPage );\n\t}\n\n\treturn {\n\t\tdata: filteredData,\n\t\tpaginationInfo: {\n\t\t\ttotalIt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MAAM,CAACG,aAAa,CAAEF,MAAO,CAAC,GAC9BA,MAAM,CAACE,aAAa,CAAEH,MAAO,CAAC;MAClC,CAAE,CAAC;IACJ;EACD;;EAEA;EACA,IAAIzC,UAAU,GAAGI,YAAY,CAACY,MAAM;EACpC,IAAIf,UAAU,GAAG,CAAC;EAClB,IAAKJ,IAAI,CAACgD,IAAI,KAAKC,SAAS,IAAIjD,IAAI,CAACkD,OAAO,KAAKD,SAAS,EAAG;IAC5D,MAAME,KAAK,GAAG,CAAEnD,IAAI,CAACgD,IAAI,GAAG,CAAC,IAAKhD,IAAI,CAACkD,OAAO;IAC9C/C,UAAU,GAAGI,YAAY,EAAEY,MAAM,IAAI,CAAC;IACtCf,UAAU,GAAGgD,IAAI,CAACC,IAAI,CAAElD,UAAU,GAAGH,IAAI,CAACkD,OAAQ,CAAC;IACnD3C,YAAY,GAAGA,YAAY,EAAE+C,KAAK,CAAEH,KAAK,EAAEA,KAAK,GAAGnD,IAAI,CAACkD,OAAQ,CAAC;EAClE;EAEA,OAAO;IACNnD,IAAI,EAAEQ,YAAY;IAClBL,cAAc,EAAE;MACfC,UAAU;MACVC;IACD;EACD,CAAC;AACF","ignoreList":[]}
1
+ {"version":3,"names":["_removeAccents","_interopRequireDefault","require","_constants","_normalizeFields","normalizeSearchInput","input","removeAccents","trim","toLowerCase","EMPTY_ARRAY","filterSortAndPaginate","data","view","fields","paginationInfo","totalItems","totalPages","_fields","normalizeFields","filteredData","search","normalizedSearch","filter","item","field","enableGlobalSearch","map","getValue","some","includes","filters","length","forEach","find","_field","id","operator","OPERATOR_IS_ANY","value","fieldValue","Array","isArray","filterValue","OPERATOR_IS_NONE","OPERATOR_IS_ALL","every","OPERATOR_IS_NOT_ALL","OPERATOR_IS","OPERATOR_IS_NOT","sort","fieldId","fieldToSort","a","b","_view$sort$direction","direction","page","undefined","perPage","start","Math","ceil","slice"],"sources":["@wordpress/dataviews/src/filter-and-sort-data-view.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport removeAccents from 'remove-accents';\n\n/**\n * Internal dependencies\n */\nimport {\n\tOPERATOR_IS,\n\tOPERATOR_IS_NOT,\n\tOPERATOR_IS_NONE,\n\tOPERATOR_IS_ANY,\n\tOPERATOR_IS_ALL,\n\tOPERATOR_IS_NOT_ALL,\n} from './constants';\nimport { normalizeFields } from './normalize-fields';\nimport type { Field, View } from './types';\n\nfunction normalizeSearchInput( input = '' ) {\n\treturn removeAccents( input.trim().toLowerCase() );\n}\n\nconst EMPTY_ARRAY: [] = [];\n\n/**\n * Applies the filtering, sorting and pagination to the raw data based on the view configuration.\n *\n * @param data Raw data.\n * @param view View config.\n * @param fields Fields config.\n *\n * @return Filtered, sorted and paginated data.\n */\nexport function filterSortAndPaginate< Item >(\n\tdata: Item[],\n\tview: View,\n\tfields: Field< Item >[]\n): {\n\tdata: Item[];\n\tpaginationInfo: { totalItems: number; totalPages: number };\n} {\n\tif ( ! data ) {\n\t\treturn {\n\t\t\tdata: EMPTY_ARRAY,\n\t\t\tpaginationInfo: { totalItems: 0, totalPages: 0 },\n\t\t};\n\t}\n\tconst _fields = normalizeFields( fields );\n\tlet filteredData = [ ...data ];\n\t// Handle global search.\n\tif ( view.search ) {\n\t\tconst normalizedSearch = normalizeSearchInput( view.search );\n\t\tfilteredData = filteredData.filter( ( item ) => {\n\t\t\treturn _fields\n\t\t\t\t.filter( ( field ) => field.enableGlobalSearch )\n\t\t\t\t.map( ( field ) => {\n\t\t\t\t\treturn normalizeSearchInput( field.getValue( { item } ) );\n\t\t\t\t} )\n\t\t\t\t.some( ( field ) => field.includes( normalizedSearch ) );\n\t\t} );\n\t}\n\n\tif ( view.filters && view.filters?.length > 0 ) {\n\t\tview.filters.forEach( ( filter ) => {\n\t\t\tconst field = _fields.find(\n\t\t\t\t( _field ) => _field.id === filter.field\n\t\t\t);\n\t\t\tif ( field ) {\n\t\t\t\tif (\n\t\t\t\t\tfilter.operator === OPERATOR_IS_ANY &&\n\t\t\t\t\tfilter?.value?.length > 0\n\t\t\t\t) {\n\t\t\t\t\tfilteredData = filteredData.filter( ( item ) => {\n\t\t\t\t\t\tconst fieldValue = field.getValue( { item } );\n\t\t\t\t\t\tif ( Array.isArray( fieldValue ) ) {\n\t\t\t\t\t\t\treturn filter.value.some( ( filterValue: any ) =>\n\t\t\t\t\t\t\t\tfieldValue.includes( filterValue )\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} else if ( typeof fieldValue === 'string' ) {\n\t\t\t\t\t\t\treturn filter.value.includes( fieldValue );\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t} );\n\t\t\t\t} else if (\n\t\t\t\t\tfilter.operator === OPERATOR_IS_NONE &&\n\t\t\t\t\tfilter?.value?.length > 0\n\t\t\t\t) {\n\t\t\t\t\tfilteredData = filteredData.filter( ( item ) => {\n\t\t\t\t\t\tconst fieldValue = field.getValue( { item } );\n\t\t\t\t\t\tif ( Array.isArray( fieldValue ) ) {\n\t\t\t\t\t\t\treturn ! filter.value.some( ( filterValue: any ) =>\n\t\t\t\t\t\t\t\tfieldValue.includes( filterValue )\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} else if ( typeof fieldValue === 'string' ) {\n\t\t\t\t\t\t\treturn ! filter.value.includes( fieldValue );\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t} );\n\t\t\t\t} else if (\n\t\t\t\t\tfilter.operator === OPERATOR_IS_ALL &&\n\t\t\t\t\tfilter?.value?.length > 0\n\t\t\t\t) {\n\t\t\t\t\tfilteredData = filteredData.filter( ( item ) => {\n\t\t\t\t\t\treturn filter.value.every( ( value: any ) => {\n\t\t\t\t\t\t\treturn field\n\t\t\t\t\t\t\t\t.getValue( { item } )\n\t\t\t\t\t\t\t\t?.includes( value );\n\t\t\t\t\t\t} );\n\t\t\t\t\t} );\n\t\t\t\t} else if (\n\t\t\t\t\tfilter.operator === OPERATOR_IS_NOT_ALL &&\n\t\t\t\t\tfilter?.value?.length > 0\n\t\t\t\t) {\n\t\t\t\t\tfilteredData = filteredData.filter( ( item ) => {\n\t\t\t\t\t\treturn filter.value.every( ( value: any ) => {\n\t\t\t\t\t\t\treturn ! field\n\t\t\t\t\t\t\t\t.getValue( { item } )\n\t\t\t\t\t\t\t\t?.includes( value );\n\t\t\t\t\t\t} );\n\t\t\t\t\t} );\n\t\t\t\t} else if ( filter.operator === OPERATOR_IS ) {\n\t\t\t\t\tfilteredData = filteredData.filter( ( item ) => {\n\t\t\t\t\t\treturn filter.value === field.getValue( { item } );\n\t\t\t\t\t} );\n\t\t\t\t} else if ( filter.operator === OPERATOR_IS_NOT ) {\n\t\t\t\t\tfilteredData = filteredData.filter( ( item ) => {\n\t\t\t\t\t\treturn filter.value !== field.getValue( { item } );\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t}\n\t\t} );\n\t}\n\n\t// Handle sorting.\n\tif ( view.sort ) {\n\t\tconst fieldId = view.sort.field;\n\t\tconst fieldToSort = _fields.find( ( field ) => {\n\t\t\treturn field.id === fieldId;\n\t\t} );\n\t\tif ( fieldToSort ) {\n\t\t\tfilteredData.sort( ( a, b ) => {\n\t\t\t\treturn fieldToSort.sort( a, b, view.sort?.direction ?? 'desc' );\n\t\t\t} );\n\t\t}\n\t}\n\n\t// Handle pagination.\n\tlet totalItems = filteredData.length;\n\tlet totalPages = 1;\n\tif ( view.page !== undefined && view.perPage !== undefined ) {\n\t\tconst start = ( view.page - 1 ) * view.perPage;\n\t\ttotalItems = filteredData?.length || 0;\n\t\ttotalPages = Math.ceil( totalItems / view.perPage );\n\t\tfilteredData = filteredData?.slice( start, start + view.perPage );\n\t}\n\n\treturn {\n\t\tdata: filteredData,\n\t\tpaginationInfo: {\n\t\t\ttotalItems,\n\t\t\ttotalPages,\n\t\t},\n\t};\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,cAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,UAAA,GAAAD,OAAA;AAQA,IAAAE,gBAAA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AO;IACN/C,IAAI,EAAEQ,YAAY;IAClBL,cAAc,EAAE;MACfC,UAAU;MACVC;IACD;EACD,CAAC;AACF","ignoreList":[]}
package/build/index.js CHANGED
@@ -19,7 +19,7 @@ Object.defineProperty(exports, "DataViews", {
19
19
  Object.defineProperty(exports, "VIEW_LAYOUTS", {
20
20
  enumerable: true,
21
21
  get: function () {
22
- return _layouts.VIEW_LAYOUTS;
22
+ return _dataviewsLayouts.VIEW_LAYOUTS;
23
23
  }
24
24
  });
25
25
  Object.defineProperty(exports, "filterSortAndPaginate", {
@@ -28,8 +28,15 @@ Object.defineProperty(exports, "filterSortAndPaginate", {
28
28
  return _filterAndSortDataView.filterSortAndPaginate;
29
29
  }
30
30
  });
31
- var _dataviews = _interopRequireDefault(require("./dataviews"));
32
- var _layouts = require("./layouts");
31
+ Object.defineProperty(exports, "isItemValid", {
32
+ enumerable: true,
33
+ get: function () {
34
+ return _validation.isItemValid;
35
+ }
36
+ });
37
+ var _dataviews = _interopRequireDefault(require("./components/dataviews"));
38
+ var _dataform = _interopRequireDefault(require("./components/dataform"));
39
+ var _dataviewsLayouts = require("./dataviews-layouts");
33
40
  var _filterAndSortDataView = require("./filter-and-sort-data-view");
34
- var _dataform = _interopRequireDefault(require("./dataform"));
41
+ var _validation = require("./validation");
35
42
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_dataviews","_interopRequireDefault","require","_layouts","_filterAndSortDataView","_dataform"],"sources":["@wordpress/dataviews/src/index.ts"],"sourcesContent":["export { default as DataViews } from './dataviews';\nexport { VIEW_LAYOUTS } from './layouts';\nexport { filterSortAndPaginate } from './filter-and-sort-data-view';\nexport type * from './types';\nexport { default as DataForm } from './dataform';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,sBAAA,GAAAF,OAAA;AAEA,IAAAG,SAAA,GAAAJ,sBAAA,CAAAC,OAAA","ignoreList":[]}
1
+ {"version":3,"names":["_dataviews","_interopRequireDefault","require","_dataform","_dataviewsLayouts","_filterAndSortDataView","_validation"],"sources":["@wordpress/dataviews/src/index.ts"],"sourcesContent":["export { default as DataViews } from './components/dataviews';\nexport { default as DataForm } from './components/dataform';\nexport { VIEW_LAYOUTS } from './dataviews-layouts';\nexport { filterSortAndPaginate } from './filter-and-sort-data-view';\nexport type * from './types';\nexport { isItemValid } from './validation';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,SAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,iBAAA,GAAAF,OAAA;AACA,IAAAG,sBAAA,GAAAH,OAAA;AAEA,IAAAI,WAAA,GAAAJ,OAAA","ignoreList":[]}
@@ -1,9 +1,11 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
7
  exports.normalizeFields = normalizeFields;
8
+ var _fieldTypes = _interopRequireDefault(require("./field-types"));
7
9
  /**
8
10
  * Internal dependencies
9
11
  */
@@ -16,14 +18,46 @@ exports.normalizeFields = normalizeFields;
16
18
  */
17
19
  function normalizeFields(fields) {
18
20
  return fields.map(field => {
21
+ var _field$sort, _field$isValid;
22
+ const fieldTypeDefinition = (0, _fieldTypes.default)(field.type);
19
23
  const getValue = field.getValue || (({
20
24
  item
21
25
  }) => item[field.id]);
26
+ const sort = (_field$sort = field.sort) !== null && _field$sort !== void 0 ? _field$sort : function sort(a, b, direction) {
27
+ return fieldTypeDefinition.sort(getValue({
28
+ item: a
29
+ }), getValue({
30
+ item: b
31
+ }), direction);
32
+ };
33
+ const isValid = (_field$isValid = field.isValid) !== null && _field$isValid !== void 0 ? _field$isValid : function isValid(item, context) {
34
+ return fieldTypeDefinition.isValid(getValue({
35
+ item
36
+ }), context);
37
+ };
38
+ const Edit = field.Edit || fieldTypeDefinition.Edit;
39
+ const renderFromElements = ({
40
+ item
41
+ }) => {
42
+ const value = getValue({
43
+ item
44
+ });
45
+ const label = field?.elements?.find(element => {
46
+ // Intentionally using == here to allow for type coercion.
47
+ // eslint-disable-next-line eqeqeq
48
+ return element.value == value;
49
+ })?.label;
50
+ return label || value;
51
+ };
52
+ const render = field.render || (field.elements ? renderFromElements : getValue);
22
53
  return {
23
54
  ...field,
24
- header: field.header || field.id,
55
+ label: field.label || field.id,
25
56
  getValue,
26
- render: field.render || getValue
57
+ render,
58
+ sort,
59
+ isValid,
60
+ Edit
27
61
  };
28
62
  });
29
63
  }
@@ -1 +1 @@
1
- {"version":3,"names":["normalizeFields","fields","map","field","getValue","item","id","header","render"],"sources":["@wordpress/dataviews/src/normalize-fields.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport type { Field, NormalizedField, ItemRecord } from './types';\n\n/**\n * Apply default values and normalize the fields config.\n *\n * @param fields Fields config.\n * @return Normalized fields config.\n */\nexport function normalizeFields< Item >(\n\tfields: Field< Item >[]\n): NormalizedField< Item >[] {\n\treturn fields.map( ( field ) => {\n\t\tconst getValue =\n\t\t\tfield.getValue ||\n\t\t\t( ( { item }: { item: ItemRecord } ) => item[ field.id ] );\n\n\t\treturn {\n\t\t\t...field,\n\t\t\theader: field.header || field.id,\n\t\t\tgetValue,\n\t\t\trender: field.render || getValue,\n\t\t};\n\t} );\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,eAAeA,CAC9BC,MAAuB,EACK;EAC5B,OAAOA,MAAM,CAACC,GAAG,CAAIC,KAAK,IAAM;IAC/B,MAAMC,QAAQ,GACbD,KAAK,CAACC,QAAQ,KACZ,CAAE;MAAEC;IAA2B,CAAC,KAAMA,IAAI,CAAEF,KAAK,CAACG,EAAE,CAAE,CAAE;IAE3D,OAAO;MACN,GAAGH,KAAK;MACRI,MAAM,EAAEJ,KAAK,CAACI,MAAM,IAAIJ,KAAK,CAACG,EAAE;MAChCF,QAAQ;MACRI,MAAM,EAAEL,KAAK,CAACK,MAAM,IAAIJ;IACzB,CAAC;EACF,CAAE,CAAC;AACJ","ignoreList":[]}
1
+ {"version":3,"names":["_fieldTypes","_interopRequireDefault","require","normalizeFields","fields","map","field","_field$sort","_field$isValid","fieldTypeDefinition","getFieldTypeDefinition","type","getValue","item","id","sort","a","b","direction","isValid","context","Edit","renderFromElements","value","label","elements","find","element","render"],"sources":["@wordpress/dataviews/src/normalize-fields.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport getFieldTypeDefinition from './field-types';\nimport type { Field, NormalizedField } from './types';\n\n/**\n * Apply default values and normalize the fields config.\n *\n * @param fields Fields config.\n * @return Normalized fields config.\n */\nexport function normalizeFields< Item >(\n\tfields: Field< Item >[]\n): NormalizedField< Item >[] {\n\treturn fields.map( ( field ) => {\n\t\tconst fieldTypeDefinition = getFieldTypeDefinition( field.type );\n\n\t\tconst getValue =\n\t\t\tfield.getValue ||\n\t\t\t( ( { item }: { item: Item } ) => item[ field.id as keyof Item ] );\n\n\t\tconst sort =\n\t\t\tfield.sort ??\n\t\t\tfunction sort( a, b, direction ) {\n\t\t\t\treturn fieldTypeDefinition.sort(\n\t\t\t\t\tgetValue( { item: a } ),\n\t\t\t\t\tgetValue( { item: b } ),\n\t\t\t\t\tdirection\n\t\t\t\t);\n\t\t\t};\n\n\t\tconst isValid =\n\t\t\tfield.isValid ??\n\t\t\tfunction isValid( item, context ) {\n\t\t\t\treturn fieldTypeDefinition.isValid(\n\t\t\t\t\tgetValue( { item } ),\n\t\t\t\t\tcontext\n\t\t\t\t);\n\t\t\t};\n\n\t\tconst Edit = field.Edit || fieldTypeDefinition.Edit;\n\n\t\tconst renderFromElements = ( { item }: { item: Item } ) => {\n\t\t\tconst value = getValue( { item } );\n\t\t\tconst label = field?.elements?.find( ( element ) => {\n\t\t\t\t// Intentionally using == here to allow for type coercion.\n\t\t\t\t// eslint-disable-next-line eqeqeq\n\t\t\t\treturn element.value == value;\n\t\t\t} )?.label;\n\n\t\t\treturn label || value;\n\t\t};\n\n\t\tconst render =\n\t\t\tfield.render || ( field.elements ? renderFromElements : getValue );\n\n\t\treturn {\n\t\t\t...field,\n\t\t\tlabel: field.label || field.id,\n\t\t\tgetValue,\n\t\t\trender,\n\t\t\tsort,\n\t\t\tisValid,\n\t\t\tEdit,\n\t\t};\n\t} );\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AAHA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,eAAeA,CAC9BC,MAAuB,EACK;EAC5B,OAAOA,MAAM,CAACC,GAAG,CAAIC,KAAK,IAAM;IAAA,IAAAC,WAAA,EAAAC,cAAA;IAC/B,MAAMC,mBAAmB,GAAG,IAAAC,mBAAsB,EAAEJ,KAAK,CAACK,IAAK,CAAC;IAEhE,MAAMC,QAAQ,GACbN,KAAK,CAACM,QAAQ,KACZ,CAAE;MAAEC;IAAqB,CAAC,KAAMA,IAAI,CAAEP,KAAK,CAACQ,EAAE,CAAgB,CAAE;IAEnE,MAAMC,IAAI,IAAAR,WAAA,GACTD,KAAK,CAACS,IAAI,cAAAR,WAAA,cAAAA,WAAA,GACV,SAASQ,IAAIA,CAAEC,CAAC,EAAEC,CAAC,EAAEC,SAAS,EAAG;MAChC,OAAOT,mBAAmB,CAACM,IAAI,CAC9BH,QAAQ,CAAE;QAAEC,IAAI,EAAEG;MAAE,CAAE,CAAC,EACvBJ,QAAQ,CAAE;QAAEC,IAAI,EAAEI;MAAE,CAAE,CAAC,EACvBC,SACD,CAAC;IACF,CAAC;IAEF,MAAMC,OAAO,IAAAX,cAAA,GACZF,KAAK,CAACa,OAAO,cAAAX,cAAA,cAAAA,cAAA,GACb,SAASW,OAAOA,CAAEN,IAAI,EAAEO,OAAO,EAAG;MACjC,OAAOX,mBAAmB,CAACU,OAAO,CACjCP,QAAQ,CAAE;QAAEC;MAAK,CAAE,CAAC,EACpBO,OACD,CAAC;IACF,CAAC;IAEF,MAAMC,IAAI,GAAGf,KAAK,CAACe,IAAI,IAAIZ,mBAAmB,CAACY,IAAI;IAEnD,MAAMC,kBAAkB,GAAGA,CAAE;MAAET;IAAqB,CAAC,KAAM;MAC1D,MAAMU,KAAK,GAAGX,QAAQ,CAAE;QAAEC;MAAK,CAAE,CAAC;MAClC,MAAMW,KAAK,GAAGlB,KAAK,EAAEmB,QAAQ,EAAEC,IAAI,CAAIC,OAAO,IAAM;QACnD;QACA;QACA,OAAOA,OAAO,CAACJ,KAAK,IAAIA,KAAK;MAC9B,CAAE,CAAC,EAAEC,KAAK;MAEV,OAAOA,KAAK,IAAID,KAAK;IACtB,CAAC;IAED,MAAMK,MAAM,GACXtB,KAAK,CAACsB,MAAM,KAAMtB,KAAK,CAACmB,QAAQ,GAAGH,kBAAkB,GAAGV,QAAQ,CAAE;IAEnE,OAAO;MACN,GAAGN,KAAK;MACRkB,KAAK,EAAElB,KAAK,CAACkB,KAAK,IAAIlB,KAAK,CAACQ,EAAE;MAC9BF,QAAQ;MACRgB,MAAM;MACNb,IAAI;MACJI,OAAO;MACPE;IACD,CAAC;EACF,CAAE,CAAC;AACJ","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["@wordpress/dataviews/src/types.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { ReactElement, ReactNode } from 'react';\n\n/**\n * Internal dependencies\n */\nimport type { SetSelection } from './private-types';\n\nexport type SortDirection = 'asc' | 'desc';\n\n/**\n * Generic option type.\n */\nexport interface Option< Value extends any = any > {\n\tvalue: Value;\n\tlabel: string;\n\tdescription?: string;\n}\n\ninterface FilterByConfig {\n\t/**\n\t * The list of operators supported by the field.\n\t */\n\toperators?: Operator[];\n\n\t/**\n\t * Whether it is a primary filter.\n\t *\n\t * A primary filter is always visible and is not listed in the \"Add filter\" component,\n\t * except for the list layout where it behaves like a secondary filter.\n\t */\n\tisPrimary?: boolean;\n}\n\nexport type Operator =\n\t| 'is'\n\t| 'isNot'\n\t| 'isAny'\n\t| 'isNone'\n\t| 'isAll'\n\t| 'isNotAll';\n\nexport type ItemRecord = Record< string, unknown >;\n\nexport type FieldType = 'text';\n\n/**\n * A dataview field for a specific property of a data type.\n */\nexport type Field< Item > = {\n\t/**\n\t * Type of the fields.\n\t */\n\ttype?: FieldType;\n\n\t/**\n\t * The unique identifier of the field.\n\t */\n\tid: string;\n\n\t/**\n\t * The label of the field. Defaults to the id.\n\t */\n\theader?: string;\n\n\t/**\n\t * Placeholder for the field.\n\t */\n\tplaceholder?: string;\n\n\t/**\n\t * Callback used to render the field. Defaults to `field.getValue`.\n\t */\n\trender?: ( args: { item: Item } ) => ReactNode;\n\n\t/**\n\t * The width of the field column.\n\t */\n\twidth?: string | number;\n\n\t/**\n\t * The minimum width of the field column.\n\t */\n\tmaxWidth?: string | number;\n\n\t/**\n\t * The maximum width of the field column.\n\t */\n\tminWidth?: string | number;\n\n\t/**\n\t * Whether the field is sortable.\n\t */\n\tenableSorting?: boolean;\n\n\t/**\n\t * Whether the field is searchable.\n\t */\n\tenableGlobalSearch?: boolean;\n\n\t/**\n\t * Whether the field is filterable.\n\t */\n\tenableHiding?: boolean;\n\n\t/**\n\t * The list of options to pick from when using the field as a filter.\n\t */\n\telements?: Option[];\n\n\t/**\n\t * Filter config for the field.\n\t */\n\tfilterBy?: FilterByConfig | undefined;\n} & ( Item extends ItemRecord\n\t? {\n\t\t\t/**\n\t\t\t * Callback used to retrieve the value of the field from the item.\n\t\t\t * Defaults to `item[ field.id ]`.\n\t\t\t */\n\t\t\tgetValue?: ( args: { item: Item } ) => any;\n\t }\n\t: {\n\t\t\t/**\n\t\t\t * Callback used to retrieve the value of the field from the item.\n\t\t\t * Defaults to `item[ field.id ]`.\n\t\t\t */\n\t\t\tgetValue: ( args: { item: Item } ) => any;\n\t } );\n\nexport type NormalizedField< Item > = Field< Item > & {\n\theader: string;\n\tgetValue: ( args: { item: Item } ) => any;\n\trender: ( args: { item: Item } ) => ReactNode;\n};\n\n/**\n * A collection of dataview fields for a data type.\n */\nexport type Fields< Item > = Field< Item >[];\n\nexport type Data< Item > = Item[];\n\n/**\n * The form configuration.\n */\nexport type Form = {\n\tvisibleFields?: string[];\n};\n\n/**\n * The filters applied to the dataset.\n */\nexport interface Filter {\n\t/**\n\t * The field to filter by.\n\t */\n\tfield: string;\n\n\t/**\n\t * The operator to use.\n\t */\n\toperator: Operator;\n\n\t/**\n\t * The value to filter by.\n\t */\n\tvalue: any;\n}\n\nexport interface NormalizedFilter {\n\t/**\n\t * The field to filter by.\n\t */\n\tfield: string;\n\n\t/**\n\t * The field name.\n\t */\n\tname: string;\n\n\t/**\n\t * The list of options to pick from when using the field as a filter.\n\t */\n\telements: Option[];\n\n\t/**\n\t * Is a single selection filter.\n\t */\n\tsingleSelection: boolean;\n\n\t/**\n\t * The list of operators supported by the field.\n\t */\n\toperators: Operator[];\n\n\t/**\n\t * Whether the filter is visible.\n\t */\n\tisVisible: boolean;\n\n\t/**\n\t * Whether it is a primary filter.\n\t */\n\tisPrimary: boolean;\n}\n\ninterface ViewBase {\n\t/**\n\t * The layout of the view.\n\t */\n\ttype: string;\n\n\t/**\n\t * The global search term.\n\t */\n\tsearch?: string;\n\n\t/**\n\t * The filters to apply.\n\t */\n\tfilters?: Filter[];\n\n\t/**\n\t * The sorting configuration.\n\t */\n\tsort?: {\n\t\t/**\n\t\t * The field to sort by.\n\t\t */\n\t\tfield: string;\n\n\t\t/**\n\t\t * The direction to sort by.\n\t\t */\n\t\tdirection: SortDirection;\n\t};\n\n\t/**\n\t * The active page\n\t */\n\tpage?: number;\n\n\t/**\n\t * The number of items per page\n\t */\n\tperPage?: number;\n\n\t/**\n\t * The hidden fields.\n\t */\n\tfields?: string[];\n}\n\nexport interface ViewTable extends ViewBase {\n\ttype: 'table';\n\n\tlayout?: {\n\t\t/**\n\t\t * The field to use as the primary field.\n\t\t */\n\t\tprimaryField?: string;\n\n\t\t/**\n\t\t * The field to use as the media field.\n\t\t */\n\t\tmediaField?: string;\n\t};\n}\n\nexport interface ViewList extends ViewBase {\n\ttype: 'list';\n\n\tlayout?: {\n\t\t/**\n\t\t * The field to use as the primary field.\n\t\t */\n\t\tprimaryField?: string;\n\n\t\t/**\n\t\t * The field to use as the media field.\n\t\t */\n\t\tmediaField?: string;\n\t};\n}\n\nexport interface ViewGrid extends ViewBase {\n\ttype: 'grid';\n\n\tlayout?: {\n\t\t/**\n\t\t * The field to use as the primary field.\n\t\t */\n\t\tprimaryField?: string;\n\n\t\t/**\n\t\t * The field to use as the media field.\n\t\t */\n\t\tmediaField?: string;\n\n\t\t/**\n\t\t * The fields to use as columns.\n\t\t */\n\t\tcolumnFields?: string[];\n\n\t\t/**\n\t\t * The fields to use as badge fields.\n\t\t */\n\t\tbadgeFields?: string[];\n\t};\n}\n\nexport type View = ViewList | ViewGrid | ViewTable;\n\ninterface ActionBase< Item > {\n\t/**\n\t * The unique identifier of the action.\n\t */\n\tid: string;\n\n\t/**\n\t * The label of the action.\n\t * In case we want to adjust the label based on the selected items,\n\t * a function can be provided.\n\t */\n\tlabel: string | ( ( items: Item[] ) => string );\n\n\t/**\n\t * The icon of the action. (Either a string or an SVG element)\n\t * This should be IconType from the components package\n\t * but that import is breaking typescript build for the moment.\n\t */\n\ticon?: any;\n\n\t/**\n\t * Whether the action is disabled.\n\t */\n\tdisabled?: boolean;\n\n\t/**\n\t * Whether the action is destructive.\n\t */\n\tisDestructive?: boolean;\n\n\t/**\n\t * Whether the action is a primary action.\n\t */\n\tisPrimary?: boolean;\n\n\t/**\n\t * Whether the item passed as an argument supports the current action.\n\t */\n\tisEligible?: ( item: Item ) => boolean;\n\n\t/**\n\t * Whether the action can be used as a bulk action.\n\t */\n\tsupportsBulk?: boolean;\n}\n\nexport interface ActionModal< Item > extends ActionBase< Item > {\n\t/**\n\t * Modal to render when the action is triggered.\n\t */\n\tRenderModal: ( {\n\t\titems,\n\t\tcloseModal,\n\t\tonActionPerformed,\n\t}: {\n\t\titems: Item[];\n\t\tcloseModal?: () => void;\n\t\tonActionPerformed?: ( items: Item[] ) => void;\n\t} ) => ReactElement;\n\n\t/**\n\t * Whether to hide the modal header.\n\t */\n\thideModalHeader?: boolean;\n\n\t/**\n\t * The header of the modal.\n\t */\n\tmodalHeader?: string;\n}\n\nexport interface ActionButton< Item > extends ActionBase< Item > {\n\t/**\n\t * The callback to execute when the action is triggered.\n\t */\n\tcallback: (\n\t\titems: Item[],\n\t\tcontext: {\n\t\t\tregistry: any;\n\t\t\tonActionPerformed?: ( items: Item[] ) => void;\n\t\t}\n\t) => void;\n}\n\nexport type Action< Item > = ActionModal< Item > | ActionButton< Item >;\n\nexport interface ViewBaseProps< Item > {\n\tactions: Action< Item >[];\n\tdata: Item[];\n\tfields: NormalizedField< Item >[];\n\tgetItemId: ( item: Item ) => string;\n\tisLoading?: boolean;\n\tonChangeView: ( view: View ) => void;\n\tonSelectionChange: SetSelection;\n\tselection: string[];\n\tsetOpenedFilter: ( fieldId: string ) => void;\n\tview: View;\n}\n\nexport interface ViewTableProps< Item > extends ViewBaseProps< Item > {\n\tview: ViewTable;\n}\n\nexport interface ViewListProps< Item > extends ViewBaseProps< Item > {\n\tview: ViewList;\n}\n\nexport interface ViewGridProps< Item > extends ViewBaseProps< Item > {\n\tview: ViewGrid;\n}\n\nexport type ViewProps< Item > =\n\t| ViewTableProps< Item >\n\t| ViewGridProps< Item >\n\t| ViewListProps< Item >;\n\nexport interface SupportedLayouts {\n\tlist?: Omit< ViewList, 'type' >;\n\tgrid?: Omit< ViewGrid, 'type' >;\n\ttable?: Omit< ViewTable, 'type' >;\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["@wordpress/dataviews/src/types.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport type {\n\tReactElement,\n\tComponentType,\n\tDispatch,\n\tSetStateAction,\n} from 'react';\n\n/**\n * Internal dependencies\n */\nimport type { SetSelection } from './private-types';\n\nexport type SortDirection = 'asc' | 'desc';\n\n/**\n * Generic option type.\n */\nexport interface Option< Value extends any = any > {\n\tvalue: Value;\n\tlabel: string;\n\tdescription?: string;\n}\n\ninterface FilterByConfig {\n\t/**\n\t * The list of operators supported by the field.\n\t */\n\toperators?: Operator[];\n\n\t/**\n\t * Whether it is a primary filter.\n\t *\n\t * A primary filter is always visible and is not listed in the \"Add filter\" component,\n\t * except for the list layout where it behaves like a secondary filter.\n\t */\n\tisPrimary?: boolean;\n}\n\nexport type Operator =\n\t| 'is'\n\t| 'isNot'\n\t| 'isAny'\n\t| 'isNone'\n\t| 'isAll'\n\t| 'isNotAll';\n\nexport type ItemRecord = Record< string, unknown >;\n\nexport type FieldType = 'text' | 'integer';\n\nexport type ValidationContext = {\n\telements?: Option[];\n};\n\n/**\n * A dataview field for a specific property of a data type.\n */\nexport type Field< Item > = {\n\t/**\n\t * Type of the fields.\n\t */\n\ttype?: FieldType;\n\n\t/**\n\t * The unique identifier of the field.\n\t */\n\tid: string;\n\n\t/**\n\t * The label of the field. Defaults to the id.\n\t */\n\tlabel?: string;\n\n\t/**\n\t * A description of the field.\n\t */\n\tdescription?: string;\n\n\t/**\n\t * Placeholder for the field.\n\t */\n\tplaceholder?: string;\n\n\t/**\n\t * Callback used to render the field. Defaults to `field.getValue`.\n\t */\n\trender?: ComponentType< { item: Item } >;\n\n\t/**\n\t * Callback used to render an edit control for the field.\n\t */\n\tEdit?: ComponentType< DataFormControlProps< Item > >;\n\n\t/**\n\t * Callback used to sort the field.\n\t */\n\tsort?: ( a: Item, b: Item, direction: SortDirection ) => number;\n\n\t/**\n\t * Callback used to validate the field.\n\t */\n\tisValid?: ( item: Item, context?: ValidationContext ) => boolean;\n\n\t/**\n\t * Whether the field is sortable.\n\t */\n\tenableSorting?: boolean;\n\n\t/**\n\t * Whether the field is searchable.\n\t */\n\tenableGlobalSearch?: boolean;\n\n\t/**\n\t * Whether the field is filterable.\n\t */\n\tenableHiding?: boolean;\n\n\t/**\n\t * The list of options to pick from when using the field as a filter.\n\t */\n\telements?: Option[];\n\n\t/**\n\t * Filter config for the field.\n\t */\n\tfilterBy?: FilterByConfig | undefined;\n} & ( Item extends ItemRecord\n\t? {\n\t\t\t/**\n\t\t\t * Callback used to retrieve the value of the field from the item.\n\t\t\t * Defaults to `item[ field.id ]`.\n\t\t\t */\n\t\t\tgetValue?: ( args: { item: Item } ) => any;\n\t }\n\t: {\n\t\t\t/**\n\t\t\t * Callback used to retrieve the value of the field from the item.\n\t\t\t * Defaults to `item[ field.id ]`.\n\t\t\t */\n\t\t\tgetValue: ( args: { item: Item } ) => any;\n\t } );\n\nexport type NormalizedField< Item > = Field< Item > & {\n\tlabel: string;\n\tgetValue: ( args: { item: Item } ) => any;\n\trender: ComponentType< { item: Item } >;\n\tEdit: ComponentType< DataFormControlProps< Item > >;\n\tsort: ( a: Item, b: Item, direction: SortDirection ) => number;\n\tisValid: ( item: Item, context?: ValidationContext ) => boolean;\n};\n\n/**\n * A collection of dataview fields for a data type.\n */\nexport type Fields< Item > = Field< Item >[];\n\nexport type Data< Item > = Item[];\n\n/**\n * The form configuration.\n */\nexport type Form = {\n\ttype?: 'regular' | 'panel';\n\tfields?: string[];\n};\n\nexport type DataFormControlProps< Item > = {\n\tdata: Item;\n\tfield: NormalizedField< Item >;\n\tonChange: Dispatch< SetStateAction< Item > >;\n\thideLabelFromVision?: boolean;\n};\n\n/**\n * The filters applied to the dataset.\n */\nexport interface Filter {\n\t/**\n\t * The field to filter by.\n\t */\n\tfield: string;\n\n\t/**\n\t * The operator to use.\n\t */\n\toperator: Operator;\n\n\t/**\n\t * The value to filter by.\n\t */\n\tvalue: any;\n}\n\nexport interface NormalizedFilter {\n\t/**\n\t * The field to filter by.\n\t */\n\tfield: string;\n\n\t/**\n\t * The field name.\n\t */\n\tname: string;\n\n\t/**\n\t * The list of options to pick from when using the field as a filter.\n\t */\n\telements: Option[];\n\n\t/**\n\t * Is a single selection filter.\n\t */\n\tsingleSelection: boolean;\n\n\t/**\n\t * The list of operators supported by the field.\n\t */\n\toperators: Operator[];\n\n\t/**\n\t * Whether the filter is visible.\n\t */\n\tisVisible: boolean;\n\n\t/**\n\t * Whether it is a primary filter.\n\t */\n\tisPrimary: boolean;\n}\n\ninterface ViewBase {\n\t/**\n\t * The layout of the view.\n\t */\n\ttype: string;\n\n\t/**\n\t * The global search term.\n\t */\n\tsearch?: string;\n\n\t/**\n\t * The filters to apply.\n\t */\n\tfilters?: Filter[];\n\n\t/**\n\t * The sorting configuration.\n\t */\n\tsort?: {\n\t\t/**\n\t\t * The field to sort by.\n\t\t */\n\t\tfield: string;\n\n\t\t/**\n\t\t * The direction to sort by.\n\t\t */\n\t\tdirection: SortDirection;\n\t};\n\n\t/**\n\t * The active page\n\t */\n\tpage?: number;\n\n\t/**\n\t * The number of items per page\n\t */\n\tperPage?: number;\n\n\t/**\n\t * The fields to render\n\t */\n\tfields?: string[];\n}\n\nexport interface CombinedField {\n\tid: string;\n\n\tlabel: string;\n\n\t/**\n\t * The fields to use as columns.\n\t */\n\tchildren: string[];\n\n\t/**\n\t * The direction of the stack.\n\t */\n\tdirection: 'horizontal' | 'vertical';\n}\n\nexport interface ColumnStyle {\n\t/**\n\t * The width of the field column.\n\t */\n\twidth?: string | number;\n\n\t/**\n\t * The minimum width of the field column.\n\t */\n\tmaxWidth?: string | number;\n\n\t/**\n\t * The maximum width of the field column.\n\t */\n\tminWidth?: string | number;\n}\n\nexport interface ViewTable extends ViewBase {\n\ttype: 'table';\n\n\tlayout?: {\n\t\t/**\n\t\t * The field to use as the primary field.\n\t\t */\n\t\tprimaryField?: string;\n\n\t\t/**\n\t\t * The fields to use as columns.\n\t\t */\n\t\tcombinedFields?: CombinedField[];\n\n\t\t/**\n\t\t * The styles for the columns.\n\t\t */\n\t\tstyles?: Record< string, ColumnStyle >;\n\t};\n}\n\nexport interface ViewList extends ViewBase {\n\ttype: 'list';\n\n\tlayout?: {\n\t\t/**\n\t\t * The field to use as the primary field.\n\t\t */\n\t\tprimaryField?: string;\n\n\t\t/**\n\t\t * The field to use as the media field.\n\t\t */\n\t\tmediaField?: string;\n\t};\n}\n\nexport interface ViewGrid extends ViewBase {\n\ttype: 'grid';\n\n\tlayout?: {\n\t\t/**\n\t\t * The field to use as the primary field.\n\t\t */\n\t\tprimaryField?: string;\n\n\t\t/**\n\t\t * The field to use as the media field.\n\t\t */\n\t\tmediaField?: string;\n\n\t\t/**\n\t\t * The fields to use as columns.\n\t\t */\n\t\tcolumnFields?: string[];\n\n\t\t/**\n\t\t * The fields to use as badge fields.\n\t\t */\n\t\tbadgeFields?: string[];\n\t};\n}\n\nexport type View = ViewList | ViewGrid | ViewTable;\n\ninterface ActionBase< Item > {\n\t/**\n\t * The unique identifier of the action.\n\t */\n\tid: string;\n\n\t/**\n\t * The label of the action.\n\t * In case we want to adjust the label based on the selected items,\n\t * a function can be provided.\n\t */\n\tlabel: string | ( ( items: Item[] ) => string );\n\n\t/**\n\t * The icon of the action. (Either a string or an SVG element)\n\t * This should be IconType from the components package\n\t * but that import is breaking typescript build for the moment.\n\t */\n\ticon?: any;\n\n\t/**\n\t * Whether the action is disabled.\n\t */\n\tdisabled?: boolean;\n\n\t/**\n\t * Whether the action is destructive.\n\t */\n\tisDestructive?: boolean;\n\n\t/**\n\t * Whether the action is a primary action.\n\t */\n\tisPrimary?: boolean;\n\n\t/**\n\t * Whether the item passed as an argument supports the current action.\n\t */\n\tisEligible?: ( item: Item ) => boolean;\n\n\t/**\n\t * Whether the action can be used as a bulk action.\n\t */\n\tsupportsBulk?: boolean;\n}\n\nexport interface ActionModal< Item > extends ActionBase< Item > {\n\t/**\n\t * Modal to render when the action is triggered.\n\t */\n\tRenderModal: ( {\n\t\titems,\n\t\tcloseModal,\n\t\tonActionPerformed,\n\t}: {\n\t\titems: Item[];\n\t\tcloseModal?: () => void;\n\t\tonActionPerformed?: ( items: Item[] ) => void;\n\t} ) => ReactElement;\n\n\t/**\n\t * Whether to hide the modal header.\n\t */\n\thideModalHeader?: boolean;\n\n\t/**\n\t * The header of the modal.\n\t */\n\tmodalHeader?: string;\n}\n\nexport interface ActionButton< Item > extends ActionBase< Item > {\n\t/**\n\t * The callback to execute when the action is triggered.\n\t */\n\tcallback: (\n\t\titems: Item[],\n\t\tcontext: {\n\t\t\tregistry: any;\n\t\t\tonActionPerformed?: ( items: Item[] ) => void;\n\t\t}\n\t) => void;\n}\n\nexport type Action< Item > = ActionModal< Item > | ActionButton< Item >;\n\nexport interface ViewBaseProps< Item > {\n\tactions: Action< Item >[];\n\tdata: Item[];\n\tfields: NormalizedField< Item >[];\n\tgetItemId: ( item: Item ) => string;\n\tisLoading?: boolean;\n\tonChangeView: ( view: View ) => void;\n\tonChangeSelection: SetSelection;\n\tselection: string[];\n\tsetOpenedFilter: ( fieldId: string ) => void;\n\tview: View;\n\tdensity: number;\n}\n\nexport interface ViewTableProps< Item > extends ViewBaseProps< Item > {\n\tview: ViewTable;\n}\n\nexport interface ViewListProps< Item > extends ViewBaseProps< Item > {\n\tview: ViewList;\n}\n\nexport interface ViewGridProps< Item > extends ViewBaseProps< Item > {\n\tview: ViewGrid;\n}\n\nexport type ViewProps< Item > =\n\t| ViewTableProps< Item >\n\t| ViewGridProps< Item >\n\t| ViewListProps< Item >;\n\nexport interface SupportedLayouts {\n\tlist?: Omit< ViewList, 'type' >;\n\tgrid?: Omit< ViewGrid, 'type' >;\n\ttable?: Omit< ViewTable, 'type' >;\n}\n\nexport interface DataFormProps< Item > {\n\tdata: Item;\n\tfields: Field< Item >[];\n\tform: Form;\n\tonChange: Dispatch< SetStateAction< Item > >;\n}\n"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.isItemValid = isItemValid;
7
+ var _normalizeFields = require("./normalize-fields");
8
+ /**
9
+ * Internal dependencies
10
+ */
11
+
12
+ function isItemValid(item, fields, form) {
13
+ const _fields = (0, _normalizeFields.normalizeFields)(fields.filter(({
14
+ id
15
+ }) => !!form.fields?.includes(id)));
16
+ return _fields.every(field => {
17
+ return field.isValid(item, {
18
+ elements: field.elements
19
+ });
20
+ });
21
+ }
22
+ //# sourceMappingURL=validation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_normalizeFields","require","isItemValid","item","fields","form","_fields","normalizeFields","filter","id","includes","every","field","isValid","elements"],"sources":["@wordpress/dataviews/src/validation.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport { normalizeFields } from './normalize-fields';\nimport type { Field, Form } from './types';\n\nexport function isItemValid< Item >(\n\titem: Item,\n\tfields: Field< Item >[],\n\tform: Form\n): boolean {\n\tconst _fields = normalizeFields(\n\t\tfields.filter( ( { id } ) => !! form.fields?.includes( id ) )\n\t);\n\treturn _fields.every( ( field ) => {\n\t\treturn field.isValid( item, { elements: field.elements } );\n\t} );\n}\n"],"mappings":";;;;;;AAGA,IAAAA,gBAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAIO,SAASC,WAAWA,CAC1BC,IAAU,EACVC,MAAuB,EACvBC,IAAU,EACA;EACV,MAAMC,OAAO,GAAG,IAAAC,gCAAe,EAC9BH,MAAM,CAACI,MAAM,CAAE,CAAE;IAAEC;EAAG,CAAC,KAAM,CAAC,CAAEJ,IAAI,CAACD,MAAM,EAAEM,QAAQ,CAAED,EAAG,CAAE,CAC7D,CAAC;EACD,OAAOH,OAAO,CAACK,KAAK,CAAIC,KAAK,IAAM;IAClC,OAAOA,KAAK,CAACC,OAAO,CAAEV,IAAI,EAAE;MAAEW,QAAQ,EAAEF,KAAK,CAACE;IAAS,CAAE,CAAC;EAC3D,CAAE,CAAC;AACJ","ignoreList":[]}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+
5
+ import { getFormLayout } from '../../dataforms-layouts';
6
+ import { jsx as _jsx } from "react/jsx-runtime";
7
+ export default function DataForm({
8
+ form,
9
+ ...props
10
+ }) {
11
+ var _form$type;
12
+ const layout = getFormLayout((_form$type = form.type) !== null && _form$type !== void 0 ? _form$type : 'regular');
13
+ if (!layout) {
14
+ return null;
15
+ }
16
+ return /*#__PURE__*/_jsx(layout.component, {
17
+ form: form,
18
+ ...props
19
+ });
20
+ }
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["getFormLayout","jsx","_jsx","DataForm","form","props","_form$type","layout","type","component"],"sources":["@wordpress/dataviews/src/components/dataform/index.tsx"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport type { DataFormProps } from '../../types';\nimport { getFormLayout } from '../../dataforms-layouts';\n\nexport default function DataForm< Item >( {\n\tform,\n\t...props\n}: DataFormProps< Item > ) {\n\tconst layout = getFormLayout( form.type ?? 'regular' );\n\tif ( ! layout ) {\n\t\treturn null;\n\t}\n\n\treturn <layout.component form={ form } { ...props } />;\n}\n"],"mappings":"AAAA;AACA;AACA;;AAEA,SAASA,aAAa,QAAQ,yBAAyB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAExD,eAAe,SAASC,QAAQA,CAAU;EACzCC,IAAI;EACJ,GAAGC;AACmB,CAAC,EAAG;EAAA,IAAAC,UAAA;EAC1B,MAAMC,MAAM,GAAGP,aAAa,EAAAM,UAAA,GAAEF,IAAI,CAACI,IAAI,cAAAF,UAAA,cAAAA,UAAA,GAAI,SAAU,CAAC;EACtD,IAAK,CAAEC,MAAM,EAAG;IACf,OAAO,IAAI;EACZ;EAEA,oBAAOL,IAAA,CAACK,MAAM,CAACE,SAAS;IAACL,IAAI,EAAGA,IAAM;IAAA,GAAMC;EAAK,CAAI,CAAC;AACvD","ignoreList":[]}
@@ -0,0 +1,117 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+
5
+ /**
6
+ * WordPress dependencies
7
+ */
8
+ import { __experimentalHStack as HStack } from '@wordpress/components';
9
+ import { useMemo, useState } from '@wordpress/element';
10
+
11
+ /**
12
+ * Internal dependencies
13
+ */
14
+ import { default as DataViewsBulkActions } from '../dataviews-bulk-actions';
15
+ import DataViewsBulkActionsToolbar from '../dataviews-bulk-actions-toolbar';
16
+ import DataViewsContext from '../dataviews-context';
17
+ import { default as DataViewsFilters, useFilters, FilterVisibilityToggle } from '../dataviews-filters';
18
+ import DataViewsLayout from '../dataviews-layout';
19
+ import DataviewsPagination from '../dataviews-pagination';
20
+ import DataViewsSearch from '../dataviews-search';
21
+ import DataViewsViewConfig from '../dataviews-view-config';
22
+ import { normalizeFields } from '../../normalize-fields';
23
+ import DensityPicker from '../../dataviews-layouts/grid/density-picker';
24
+ import { LAYOUT_GRID } from '../../constants';
25
+ import { jsx as _jsx } from "react/jsx-runtime";
26
+ import { jsxs as _jsxs } from "react/jsx-runtime";
27
+ const defaultGetItemId = item => item.id;
28
+ export default function DataViews({
29
+ view,
30
+ onChangeView,
31
+ fields,
32
+ search = true,
33
+ searchLabel = undefined,
34
+ actions = [],
35
+ data,
36
+ getItemId = defaultGetItemId,
37
+ isLoading = false,
38
+ paginationInfo,
39
+ defaultLayouts,
40
+ selection: selectionProperty,
41
+ onChangeSelection,
42
+ header
43
+ }) {
44
+ const [selectionState, setSelectionState] = useState([]);
45
+ const [density, setDensity] = useState(0);
46
+ const [isShowingFilter, setIsShowingFilter] = useState(false);
47
+ const isUncontrolled = selectionProperty === undefined || onChangeSelection === undefined;
48
+ const selection = isUncontrolled ? selectionState : selectionProperty;
49
+ const [openedFilter, setOpenedFilter] = useState(null);
50
+ function setSelectionWithChange(value) {
51
+ const newValue = typeof value === 'function' ? value(selection) : value;
52
+ if (isUncontrolled) {
53
+ setSelectionState(newValue);
54
+ }
55
+ if (onChangeSelection) {
56
+ onChangeSelection(newValue);
57
+ }
58
+ }
59
+ const _fields = useMemo(() => normalizeFields(fields), [fields]);
60
+ const _selection = useMemo(() => {
61
+ return selection.filter(id => data.some(item => getItemId(item) === id));
62
+ }, [selection, data, getItemId]);
63
+ const filters = useFilters(_fields, view);
64
+ return /*#__PURE__*/_jsx(DataViewsContext.Provider, {
65
+ value: {
66
+ view,
67
+ onChangeView,
68
+ fields: _fields,
69
+ actions,
70
+ data,
71
+ isLoading,
72
+ paginationInfo,
73
+ selection: _selection,
74
+ onChangeSelection: setSelectionWithChange,
75
+ openedFilter,
76
+ setOpenedFilter,
77
+ getItemId,
78
+ density
79
+ },
80
+ children: /*#__PURE__*/_jsxs("div", {
81
+ className: "dataviews-wrapper",
82
+ children: [/*#__PURE__*/_jsxs(HStack, {
83
+ alignment: "top",
84
+ justify: "start",
85
+ className: "dataviews__view-actions",
86
+ spacing: 1,
87
+ children: [/*#__PURE__*/_jsxs(HStack, {
88
+ justify: "start",
89
+ wrap: true,
90
+ children: [search && /*#__PURE__*/_jsx(DataViewsSearch, {
91
+ label: searchLabel
92
+ }), /*#__PURE__*/_jsx(FilterVisibilityToggle, {
93
+ filters: filters,
94
+ view: view,
95
+ onChangeView: onChangeView,
96
+ setOpenedFilter: setOpenedFilter,
97
+ setIsShowingFilter: setIsShowingFilter,
98
+ isShowingFilter: isShowingFilter
99
+ })]
100
+ }), view.type === LAYOUT_GRID && /*#__PURE__*/_jsx(DensityPicker, {
101
+ density: density,
102
+ setDensity: setDensity
103
+ }), /*#__PURE__*/_jsx(DataViewsBulkActions, {}), /*#__PURE__*/_jsxs(HStack, {
104
+ spacing: 1,
105
+ expanded: false,
106
+ style: {
107
+ flexShrink: 0
108
+ },
109
+ children: [/*#__PURE__*/_jsx(DataViewsViewConfig, {
110
+ defaultLayouts: defaultLayouts
111
+ }), header]
112
+ })]
113
+ }), isShowingFilter && /*#__PURE__*/_jsx(DataViewsFilters, {}), /*#__PURE__*/_jsx(DataViewsLayout, {}), /*#__PURE__*/_jsx(DataviewsPagination, {}), /*#__PURE__*/_jsx(DataViewsBulkActionsToolbar, {})]
114
+ })
115
+ });
116
+ }
117
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["__experimentalHStack","HStack","useMemo","useState","default","DataViewsBulkActions","DataViewsBulkActionsToolbar","DataViewsContext","DataViewsFilters","useFilters","FilterVisibilityToggle","DataViewsLayout","DataviewsPagination","DataViewsSearch","DataViewsViewConfig","normalizeFields","DensityPicker","LAYOUT_GRID","jsx","_jsx","jsxs","_jsxs","defaultGetItemId","item","id","DataViews","view","onChangeView","fields","search","searchLabel","undefined","actions","data","getItemId","isLoading","paginationInfo","defaultLayouts","selection","selectionProperty","onChangeSelection","header","selectionState","setSelectionState","density","setDensity","isShowingFilter","setIsShowingFilter","isUncontrolled","openedFilter","setOpenedFilter","setSelectionWithChange","value","newValue","_fields","_selection","filter","some","filters","Provider","children","className","alignment","justify","spacing","wrap","label","type","expanded","style","flexShrink"],"sources":["@wordpress/dataviews/src/components/dataviews/index.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { ReactNode } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { __experimentalHStack as HStack } from '@wordpress/components';\nimport { useMemo, useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { default as DataViewsBulkActions } from '../dataviews-bulk-actions';\nimport DataViewsBulkActionsToolbar from '../dataviews-bulk-actions-toolbar';\nimport DataViewsContext from '../dataviews-context';\nimport {\n\tdefault as DataViewsFilters,\n\tuseFilters,\n\tFilterVisibilityToggle,\n} from '../dataviews-filters';\nimport DataViewsLayout from '../dataviews-layout';\nimport DataviewsPagination from '../dataviews-pagination';\nimport DataViewsSearch from '../dataviews-search';\nimport DataViewsViewConfig from '../dataviews-view-config';\nimport { normalizeFields } from '../../normalize-fields';\nimport type { Action, Field, View, SupportedLayouts } from '../../types';\nimport type { SelectionOrUpdater } from '../../private-types';\nimport DensityPicker from '../../dataviews-layouts/grid/density-picker';\nimport { LAYOUT_GRID } from '../../constants';\n\ntype ItemWithId = { id: string };\n\ntype DataViewsProps< Item > = {\n\tview: View;\n\tonChangeView: ( view: View ) => void;\n\tfields: Field< Item >[];\n\tsearch?: boolean;\n\tsearchLabel?: string;\n\tactions?: Action< Item >[];\n\tdata: Item[];\n\tisLoading?: boolean;\n\tpaginationInfo: {\n\t\ttotalItems: number;\n\t\ttotalPages: number;\n\t};\n\tdefaultLayouts: SupportedLayouts;\n\tselection?: string[];\n\tonChangeSelection?: ( items: string[] ) => void;\n\theader?: ReactNode;\n} & ( Item extends ItemWithId\n\t? { getItemId?: ( item: Item ) => string }\n\t: { getItemId: ( item: Item ) => string } );\n\nconst defaultGetItemId = ( item: ItemWithId ) => item.id;\n\nexport default function DataViews< Item >( {\n\tview,\n\tonChangeView,\n\tfields,\n\tsearch = true,\n\tsearchLabel = undefined,\n\tactions = [],\n\tdata,\n\tgetItemId = defaultGetItemId,\n\tisLoading = false,\n\tpaginationInfo,\n\tdefaultLayouts,\n\tselection: selectionProperty,\n\tonChangeSelection,\n\theader,\n}: DataViewsProps< Item > ) {\n\tconst [ selectionState, setSelectionState ] = useState< string[] >( [] );\n\tconst [ density, setDensity ] = useState< number >( 0 );\n\tconst [ isShowingFilter, setIsShowingFilter ] =\n\t\tuseState< boolean >( false );\n\tconst isUncontrolled =\n\t\tselectionProperty === undefined || onChangeSelection === undefined;\n\tconst selection = isUncontrolled ? selectionState : selectionProperty;\n\tconst [ openedFilter, setOpenedFilter ] = useState< string | null >( null );\n\tfunction setSelectionWithChange( value: SelectionOrUpdater ) {\n\t\tconst newValue =\n\t\t\ttypeof value === 'function' ? value( selection ) : value;\n\t\tif ( isUncontrolled ) {\n\t\t\tsetSelectionState( newValue );\n\t\t}\n\t\tif ( onChangeSelection ) {\n\t\t\tonChangeSelection( newValue );\n\t\t}\n\t}\n\tconst _fields = useMemo( () => normalizeFields( fields ), [ fields ] );\n\tconst _selection = useMemo( () => {\n\t\treturn selection.filter( ( id ) =>\n\t\t\tdata.some( ( item ) => getItemId( item ) === id )\n\t\t);\n\t}, [ selection, data, getItemId ] );\n\n\tconst filters = useFilters( _fields, view );\n\treturn (\n\t\t<DataViewsContext.Provider\n\t\t\tvalue={ {\n\t\t\t\tview,\n\t\t\t\tonChangeView,\n\t\t\t\tfields: _fields,\n\t\t\t\tactions,\n\t\t\t\tdata,\n\t\t\t\tisLoading,\n\t\t\t\tpaginationInfo,\n\t\t\t\tselection: _selection,\n\t\t\t\tonChangeSelection: setSelectionWithChange,\n\t\t\t\topenedFilter,\n\t\t\t\tsetOpenedFilter,\n\t\t\t\tgetItemId,\n\t\t\t\tdensity,\n\t\t\t} }\n\t\t>\n\t\t\t<div className=\"dataviews-wrapper\">\n\t\t\t\t<HStack\n\t\t\t\t\talignment=\"top\"\n\t\t\t\t\tjustify=\"start\"\n\t\t\t\t\tclassName=\"dataviews__view-actions\"\n\t\t\t\t\tspacing={ 1 }\n\t\t\t\t>\n\t\t\t\t\t<HStack justify=\"start\" wrap>\n\t\t\t\t\t\t{ search && <DataViewsSearch label={ searchLabel } /> }\n\t\t\t\t\t\t<FilterVisibilityToggle\n\t\t\t\t\t\t\tfilters={ filters }\n\t\t\t\t\t\t\tview={ view }\n\t\t\t\t\t\t\tonChangeView={ onChangeView }\n\t\t\t\t\t\t\tsetOpenedFilter={ setOpenedFilter }\n\t\t\t\t\t\t\tsetIsShowingFilter={ setIsShowingFilter }\n\t\t\t\t\t\t\tisShowingFilter={ isShowingFilter }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</HStack>\n\t\t\t\t\t{ view.type === LAYOUT_GRID && (\n\t\t\t\t\t\t<DensityPicker\n\t\t\t\t\t\t\tdensity={ density }\n\t\t\t\t\t\t\tsetDensity={ setDensity }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\t<DataViewsBulkActions />\n\t\t\t\t\t<HStack\n\t\t\t\t\t\tspacing={ 1 }\n\t\t\t\t\t\texpanded={ false }\n\t\t\t\t\t\tstyle={ { flexShrink: 0 } }\n\t\t\t\t\t>\n\t\t\t\t\t\t<DataViewsViewConfig\n\t\t\t\t\t\t\tdefaultLayouts={ defaultLayouts }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{ header }\n\t\t\t\t\t</HStack>\n\t\t\t\t</HStack>\n\t\t\t\t{ isShowingFilter && <DataViewsFilters /> }\n\t\t\t\t<DataViewsLayout />\n\t\t\t\t<DataviewsPagination />\n\t\t\t\t<DataViewsBulkActionsToolbar />\n\t\t\t</div>\n\t\t</DataViewsContext.Provider>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;;AAGA;AACA;AACA;AACA,SAASA,oBAAoB,IAAIC,MAAM,QAAQ,uBAAuB;AACtE,SAASC,OAAO,EAAEC,QAAQ,QAAQ,oBAAoB;;AAEtD;AACA;AACA;AACA,SAASC,OAAO,IAAIC,oBAAoB,QAAQ,2BAA2B;AAC3E,OAAOC,2BAA2B,MAAM,mCAAmC;AAC3E,OAAOC,gBAAgB,MAAM,sBAAsB;AACnD,SACCH,OAAO,IAAII,gBAAgB,EAC3BC,UAAU,EACVC,sBAAsB,QAChB,sBAAsB;AAC7B,OAAOC,eAAe,MAAM,qBAAqB;AACjD,OAAOC,mBAAmB,MAAM,yBAAyB;AACzD,OAAOC,eAAe,MAAM,qBAAqB;AACjD,OAAOC,mBAAmB,MAAM,0BAA0B;AAC1D,SAASC,eAAe,QAAQ,wBAAwB;AAGxD,OAAOC,aAAa,MAAM,6CAA6C;AACvE,SAASC,WAAW,QAAQ,iBAAiB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAyB9C,MAAMC,gBAAgB,GAAKC,IAAgB,IAAMA,IAAI,CAACC,EAAE;AAExD,eAAe,SAASC,SAASA,CAAU;EAC1CC,IAAI;EACJC,YAAY;EACZC,MAAM;EACNC,MAAM,GAAG,IAAI;EACbC,WAAW,GAAGC,SAAS;EACvBC,OAAO,GAAG,EAAE;EACZC,IAAI;EACJC,SAAS,GAAGZ,gBAAgB;EAC5Ba,SAAS,GAAG,KAAK;EACjBC,cAAc;EACdC,cAAc;EACdC,SAAS,EAAEC,iBAAiB;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B,cAAc,EAAGA;UAAgB,CACjC,CAAC,EACAI,MAAM;QAAA,CACD,CAAC;MAAA,CACF,CAAC,EACPK,eAAe,iBAAI3B,IAAA,CAACX,gBAAgB,IAAE,CAAC,eACzCW,IAAA,CAACR,eAAe,IAAE,CAAC,eACnBQ,IAAA,CAACP,mBAAmB,IAAE,CAAC,eACvBO,IAAA,CAACb,2BAA2B,IAAE,CAAC;IAAA,CAC3B;EAAC,CACoB,CAAC;AAE9B","ignoreList":[]}
@@ -3,13 +3,15 @@
3
3
  */
4
4
  import { privateApis as componentsPrivateApis, Button, Modal } from '@wordpress/components';
5
5
  import { __, sprintf, _n } from '@wordpress/i18n';
6
- import { useMemo, useState, useCallback } from '@wordpress/element';
6
+ import { useMemo, useState, useCallback, useContext } from '@wordpress/element';
7
7
  import { useRegistry } from '@wordpress/data';
8
8
 
9
9
  /**
10
10
  * Internal dependencies
11
11
  */
12
- import { unlock } from './lock-unlock';
12
+ import DataViewsContext from '../dataviews-context';
13
+ import { LAYOUT_TABLE, LAYOUT_GRID } from '../../constants';
14
+ import { unlock } from '../../lock-unlock';
13
15
  import { jsx as _jsx } from "react/jsx-runtime";
14
16
  import { Fragment as _Fragment } from "react/jsx-runtime";
15
17
  import { jsxs as _jsxs } from "react/jsx-runtime";
@@ -51,12 +53,15 @@ function ActionWithModal({
51
53
  const onCloseModal = useCallback(() => {
52
54
  setActionWithModal(undefined);
53
55
  }, [setActionWithModal]);
56
+ if (!eligibleItems.length) {
57
+ return null;
58
+ }
54
59
  const label = typeof action.label === 'string' ? action.label : action.label(selectedItems);
55
60
  return /*#__PURE__*/_jsx(Modal, {
56
61
  title: !hideModalHeader ? label : undefined,
57
62
  __experimentalHideHeader: !!hideModalHeader,
58
63
  onRequestClose: onCloseModal,
59
- overlayClassName: "dataviews-action-modal",
64
+ overlayClassName: "dataviews-bulk-actions__modal",
60
65
  children: /*#__PURE__*/_jsx(RenderModal, {
61
66
  items: eligibleItems,
62
67
  closeModal: onCloseModal,
@@ -75,7 +80,6 @@ function BulkActionItem({
75
80
  }, [action, selectedItems]);
76
81
  const shouldShowModal = ('RenderModal' in action);
77
82
  return /*#__PURE__*/_jsx(DropdownMenuItem, {
78
- disabled: eligibleItems.length === 0,
79
83
  hideOnClick: !shouldShowModal,
80
84
  onClick: async () => {
81
85
  if (shouldShowModal) {
@@ -86,7 +90,7 @@ function BulkActionItem({
86
90
  });
87
91
  }
88
92
  },
89
- suffix: eligibleItems.length > 0 ? eligibleItems.length : undefined,
93
+ suffix: eligibleItems.length,
90
94
  children: action.label
91
95
  }, action.id);
92
96
  }
@@ -95,9 +99,17 @@ function ActionsMenuGroup({
95
99
  selectedItems,
96
100
  setActionWithModal
97
101
  }) {
102
+ const elligibleActions = useMemo(() => {
103
+ return actions.filter(action => {
104
+ return selectedItems.some(item => !action.isEligible || action.isEligible(item));
105
+ });
106
+ }, [actions, selectedItems]);
107
+ if (!elligibleActions.length) {
108
+ return null;
109
+ }
98
110
  return /*#__PURE__*/_jsxs(_Fragment, {
99
111
  children: [/*#__PURE__*/_jsx(DropdownMenuGroup, {
100
- children: actions.map(action => /*#__PURE__*/_jsx(BulkActionItem, {
112
+ children: elligibleActions.map(action => /*#__PURE__*/_jsx(BulkActionItem, {
101
113
  action: action,
102
114
  selectedItems: selectedItems,
103
115
  setActionWithModal: setActionWithModal
@@ -105,13 +117,14 @@ function ActionsMenuGroup({
105
117
  }), /*#__PURE__*/_jsx(DropdownMenuSeparator, {})]
106
118
  });
107
119
  }
108
- export default function BulkActions({
109
- data,
110
- actions,
111
- selection,
112
- onSelectionChange,
113
- getItemId
114
- }) {
120
+ function _BulkActions() {
121
+ const {
122
+ data,
123
+ actions = [],
124
+ selection,
125
+ onChangeSelection,
126
+ getItemId
127
+ } = useContext(DataViewsContext);
115
128
  const bulkActions = useMemo(() => actions.filter(action => action.supportsBulk), [actions]);
116
129
  const [isMenuOpen, onMenuOpenChange] = useState(false);
117
130
  const [actionWithModal, setActionWithModal] = useState();
@@ -137,7 +150,7 @@ export default function BulkActions({
137
150
  minWidth: '240px'
138
151
  },
139
152
  trigger: /*#__PURE__*/_jsx(Button, {
140
- className: "dataviews-bulk-edit-button",
153
+ className: "dataviews-bulk-actions__edit-button",
141
154
  __next40pxDefaultSize: true,
142
155
  variant: "tertiary",
143
156
  size: "compact",
@@ -153,7 +166,7 @@ export default function BulkActions({
153
166
  disabled: areAllSelected,
154
167
  hideOnClick: false,
155
168
  onClick: () => {
156
- onSelectionChange(selectableItems.map(item => getItemId(item)));
169
+ onChangeSelection(selectableItems.map(item => getItemId(item)));
157
170
  },
158
171
  suffix: numberSelectableItems,
159
172
  children: __('Select all')
@@ -161,7 +174,7 @@ export default function BulkActions({
161
174
  disabled: selection.length === 0,
162
175
  hideOnClick: false,
163
176
  onClick: () => {
164
- onSelectionChange([]);
177
+ onChangeSelection([]);
165
178
  },
166
179
  children: __('Deselect')
167
180
  })]
@@ -174,4 +187,16 @@ export default function BulkActions({
174
187
  })]
175
188
  });
176
189
  }
177
- //# sourceMappingURL=bulk-actions.js.map
190
+ export default function BulkActions() {
191
+ const {
192
+ data,
193
+ actions = [],
194
+ view
195
+ } = useContext(DataViewsContext);
196
+ const hasPossibleBulkAction = useSomeItemHasAPossibleBulkAction(actions, data);
197
+ if (![LAYOUT_TABLE, LAYOUT_GRID].includes(view.type) || !hasPossibleBulkAction) {
198
+ return null;
199
+ }
200
+ return /*#__PURE__*/_jsx(_BulkActions, {});
201
+ }
202
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["privateApis","componentsPrivateApis","Button","Modal","__","sprintf","_n","useMemo","useState","useCallback","useContext","useRegistry","DataViewsContext","LAYOUT_TABLE","LAYOUT_GRID","unlock","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","DropdownMenuV2","DropdownMenu","DropdownMenuGroupV2","DropdownMenuGroup","DropdownMenuItemV2","DropdownMenuItem","DropdownMenuSeparatorV2","DropdownMenuSeparator","useHasAPossibleBulkAction","actions","item","some","action","supportsBulk","isEligible","useSomeItemHasAPossibleBulkAction","data","ActionWithModal","selectedItems","setActionWithModal","onMenuOpenChange","eligibleItems","filter","RenderModal","hideModalHeader","onCloseModal","undefined","length","label","title","__experimentalHideHeader","onRequestClose","overlayClassName","children","items","closeModal","onActionPerformed","BulkActionItem","registry","shouldShowModal","hideOnClick","onClick","callback","suffix","id","ActionsMenuGroup","elligibleActions","map","_BulkActions","selection","onChangeSelection","getItemId","bulkActions","isMenuOpen","actionWithModal","selectableItems","numberSelectableItems","includes","areAllSelected","open","onOpenChange","style","minWidth","trigger","className","__next40pxDefaultSize","variant","size","disabled","BulkActions","view","hasPossibleBulkAction","type"],"sources":["@wordpress/dataviews/src/components/dataviews-bulk-actions/index.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tprivateApis as componentsPrivateApis,\n\tButton,\n\tModal,\n} from '@wordpress/components';\nimport { __, sprintf, _n } from '@wordpress/i18n';\nimport { useMemo, useState, useCallback, useContext } from '@wordpress/element';\nimport { useRegistry } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport DataViewsContext from '../dataviews-context';\nimport { LAYOUT_TABLE, LAYOUT_GRID } from '../../constants';\nimport { unlock } from '../../lock-unlock';\nimport type { Action, ActionModal } from '../../types';\n\nconst {\n\tDropdownMenuV2: DropdownMenu,\n\tDropdownMenuGroupV2: DropdownMenuGroup,\n\tDropdownMenuItemV2: DropdownMenuItem,\n\tDropdownMenuSeparatorV2: DropdownMenuSeparator,\n} = unlock( componentsPrivateApis );\n\ninterface ActionWithModalProps< Item > {\n\taction: ActionModal< Item >;\n\tselectedItems: Item[];\n\tsetActionWithModal: ( action?: ActionModal< Item > ) => void;\n\tonMenuOpenChange: ( isOpen: boolean ) => void;\n}\n\ninterface BulkActionsItemProps< Item > {\n\taction: Action< Item >;\n\tselectedItems: Item[];\n\tsetActionWithModal: ( action?: ActionModal< Item > ) => void;\n}\n\ninterface ActionsMenuGroupProps< Item > {\n\tactions: Action< Item >[];\n\tselectedItems: Item[];\n\tsetActionWithModal: ( action?: ActionModal< Item > ) => void;\n}\n\nexport function useHasAPossibleBulkAction< Item >(\n\tactions: Action< Item >[],\n\titem: Item\n) {\n\treturn useMemo( () => {\n\t\treturn actions.some( ( action ) => {\n\t\t\treturn (\n\t\t\t\taction.supportsBulk &&\n\t\t\t\t( ! action.isEligible || action.isEligible( item ) )\n\t\t\t);\n\t\t} );\n\t}, [ actions, item ] );\n}\n\nexport function useSomeItemHasAPossibleBulkAction< Item >(\n\tactions: Action< Item >[],\n\tdata: Item[]\n) {\n\treturn useMemo( () => {\n\t\treturn data.some( ( item ) => {\n\t\t\treturn actions.some( ( action ) => {\n\t\t\t\treturn (\n\t\t\t\t\taction.supportsBulk &&\n\t\t\t\t\t( ! action.isEligible || action.isEligible( item ) )\n\t\t\t\t);\n\t\t\t} );\n\t\t} );\n\t}, [ actions, data ] );\n}\n\nfunction ActionWithModal< Item >( {\n\taction,\n\tselectedItems,\n\tsetActionWithModal,\n\tonMenuOpenChange,\n}: ActionWithModalProps< Item > ) {\n\tconst eligibleItems = useMemo( () => {\n\t\treturn selectedItems.filter(\n\t\t\t( item ) => ! action.isEligible || action.isEligible( item )\n\t\t);\n\t}, [ action, selectedItems ] );\n\tconst { RenderModal, hideModalHeader } = action;\n\tconst onCloseModal = useCallback( () => {\n\t\tsetActionWithModal( undefined );\n\t}, [ setActionWithModal ] );\n\n\tif ( ! eligibleItems.length ) {\n\t\treturn null;\n\t}\n\n\tconst label =\n\t\ttypeof action.label === 'string'\n\t\t\t? action.label\n\t\t\t: action.label( selectedItems );\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ ! hideModalHeader ? label : undefined }\n\t\t\t__experimentalHideHeader={ !! hideModalHeader }\n\t\t\tonRequestClose={ onCloseModal }\n\t\t\toverlayClassName=\"dataviews-bulk-actions__modal\"\n\t\t>\n\t\t\t<RenderModal\n\t\t\t\titems={ eligibleItems }\n\t\t\t\tcloseModal={ onCloseModal }\n\t\t\t\tonActionPerformed={ () => onMenuOpenChange( false ) }\n\t\t\t/>\n\t\t</Modal>\n\t);\n}\n\nfunction BulkActionItem< Item >( {\n\taction,\n\tselectedItems,\n\tsetActionWithModal,\n}: BulkActionsItemProps< Item > ) {\n\tconst registry = useRegistry();\n\tconst eligibleItems = useMemo( () => {\n\t\treturn selectedItems.filter(\n\t\t\t( item ) => ! action.isEligible || action.isEligible( item )\n\t\t);\n\t}, [ action, selectedItems ] );\n\n\tconst shouldShowModal = 'RenderModal' in action;\n\n\treturn (\n\t\t<DropdownMenuItem\n\t\t\tkey={ action.id }\n\t\t\thideOnClick={ ! shouldShowModal }\n\t\t\tonClick={ async () => {\n\t\t\t\tif ( shouldShowModal ) {\n\t\t\t\t\tsetActionWithModal( action );\n\t\t\t\t} else {\n\t\t\t\t\taction.callback( eligibleItems, { registry } );\n\t\t\t\t}\n\t\t\t} }\n\t\t\tsuffix={ eligibleItems.length }\n\t\t>\n\t\t\t{ action.label }\n\t\t</DropdownMenuItem>\n\t);\n}\n\nfunction ActionsMenuGroup< Item >( {\n\tactions,\n\tselectedItems,\n\tsetActionWithModal,\n}: ActionsMenuGroupProps< Item > ) {\n\tconst elligibleActions = useMemo( () => {\n\t\treturn actions.filter( ( action ) => {\n\t\t\treturn selectedItems.some(\n\t\t\t\t( item ) => ! action.isEligible || action.isEligible( item )\n\t\t\t);\n\t\t} );\n\t}, [ actions, selectedItems ] );\n\tif ( ! elligibleActions.length ) {\n\t\treturn null;\n\t}\n\treturn (\n\t\t<>\n\t\t\t<DropdownMenuGroup>\n\t\t\t\t{ elligibleActions.map( ( action ) => (\n\t\t\t\t\t<BulkActionItem\n\t\t\t\t\t\tkey={ action.id }\n\t\t\t\t\t\taction={ action }\n\t\t\t\t\t\tselectedItems={ selectedItems }\n\t\t\t\t\t\tsetActionWithModal={ setActionWithModal }\n\t\t\t\t\t/>\n\t\t\t\t) ) }\n\t\t\t</DropdownMenuGroup>\n\t\t\t<DropdownMenuSeparator />\n\t\t</>\n\t);\n}\n\nfunction _BulkActions() {\n\tconst {\n\t\tdata,\n\t\tactions = [],\n\t\tselection,\n\t\tonChangeSelection,\n\t\tgetItemId,\n\t} = useContext( DataViewsContext );\n\tconst bulkActions = useMemo(\n\t\t() => actions.filter( ( action ) => action.supportsBulk ),\n\t\t[ actions ]\n\t);\n\tconst [ isMenuOpen, onMenuOpenChange ] = useState( false );\n\tconst [ actionWithModal, setActionWithModal ] = useState<\n\t\tActionModal< any > | undefined\n\t>();\n\tconst selectableItems = useMemo( () => {\n\t\treturn data.filter( ( item ) => {\n\t\t\treturn bulkActions.some(\n\t\t\t\t( action ) => ! action.isEligible || action.isEligible( item )\n\t\t\t);\n\t\t} );\n\t}, [ data, bulkActions ] );\n\n\tconst numberSelectableItems = selectableItems.length;\n\n\tconst selectedItems = useMemo( () => {\n\t\treturn data.filter(\n\t\t\t( item ) =>\n\t\t\t\tselection.includes( getItemId( item ) ) &&\n\t\t\t\tselectableItems.includes( item )\n\t\t);\n\t}, [ selection, data, getItemId, selectableItems ] );\n\n\tconst areAllSelected = selectedItems.length === numberSelectableItems;\n\n\tif ( bulkActions.length === 0 ) {\n\t\treturn null;\n\t}\n\treturn (\n\t\t<>\n\t\t\t<DropdownMenu\n\t\t\t\topen={ isMenuOpen }\n\t\t\t\tonOpenChange={ onMenuOpenChange }\n\t\t\t\tlabel={ __( 'Bulk actions' ) }\n\t\t\t\tstyle={ { minWidth: '240px' } }\n\t\t\t\ttrigger={\n\t\t\t\t\t<Button\n\t\t\t\t\t\tclassName=\"dataviews-bulk-actions__edit-button\"\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ selectedItems.length\n\t\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t\t/* translators: %d: Number of items. */\n\t\t\t\t\t\t\t\t\t_n(\n\t\t\t\t\t\t\t\t\t\t'Edit %d item',\n\t\t\t\t\t\t\t\t\t\t'Edit %d items',\n\t\t\t\t\t\t\t\t\t\tselectedItems.length\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\tselectedItems.length\n\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t: __( 'Bulk edit' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t}\n\t\t\t>\n\t\t\t\t<ActionsMenuGroup\n\t\t\t\t\tactions={ bulkActions }\n\t\t\t\t\tsetActionWithModal={ setActionWithModal }\n\t\t\t\t\tselectedItems={ selectedItems }\n\t\t\t\t/>\n\t\t\t\t<DropdownMenuGroup>\n\t\t\t\t\t<DropdownMenuItem\n\t\t\t\t\t\tdisabled={ areAllSelected }\n\t\t\t\t\t\thideOnClick={ false }\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tonChangeSelection(\n\t\t\t\t\t\t\t\tselectableItems.map( ( item ) =>\n\t\t\t\t\t\t\t\t\tgetItemId( item )\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tsuffix={ numberSelectableItems }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Select all' ) }\n\t\t\t\t\t</DropdownMenuItem>\n\t\t\t\t\t<DropdownMenuItem\n\t\t\t\t\t\tdisabled={ selection.length === 0 }\n\t\t\t\t\t\thideOnClick={ false }\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tonChangeSelection( [] );\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Deselect' ) }\n\t\t\t\t\t</DropdownMenuItem>\n\t\t\t\t</DropdownMenuGroup>\n\t\t\t</DropdownMenu>\n\t\t\t{ actionWithModal && (\n\t\t\t\t<ActionWithModal\n\t\t\t\t\taction={ actionWithModal }\n\t\t\t\t\tselectedItems={ selectedItems }\n\t\t\t\t\tsetActionWithModal={ setActionWithModal }\n\t\t\t\t\tonMenuOpenChange={ onMenuOpenChange }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default function BulkActions() {\n\tconst { data, actions = [], view } = useContext( DataViewsContext );\n\tconst hasPossibleBulkAction = useSomeItemHasAPossibleBulkAction(\n\t\tactions,\n\t\tdata\n\t);\n\tif (\n\t\t! [ LAYOUT_TABLE, LAYOUT_GRID ].includes( view.type ) ||\n\t\t! hasPossibleBulkAction\n\t) {\n\t\treturn null;\n\t}\n\n\treturn <_BulkActions />;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,WAAW,IAAIC,qBAAqB,EACpCC,MAAM,EACNC,KAAK,QACC,uBAAuB;AAC9B,SAASC,EAAE,EAAEC,OAAO,EAAEC,EAAE,QAAQ,iBAAiB;AACjD,SAASC,OAAO,EAAEC,QAAQ,EAAEC,WAAW,EAAEC,UAAU,QAAQ,oBAAoB;AAC/E,SAASC,WAAW,QAAQ,iBAAiB;;AAE7C;AACA;AACA;AACA,OAAOC,gBAAgB,MAAM,sBAAsB;AACnD,SAASC,YAAY,EAAEC,WAAW,QAAQ,iBAAiB;AAC3D,SAASC,MAAM,QAAQ,mBAAmB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,QAAA,IAAAC,SAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAG3C,MAAM;EACLC,cAAc,EAAEC,YAAY;EAC5BC,mBAAmB,EAAEC,iBAAiB;EACtCC,kBAAkB,EAAEC,gBAAgB;EACpCC,uBAAuB,EAAEC;AAC1B,CAAC,GAAGd,MAAM,CAAEd,qBAAsB,CAAC;AAqBnC,OAAO,SAAS6B,yBAAyBA,CACxCC,OAAyB,EACzBC,IAAU,EACT;EACD,OAAOzB,OAAO,CAAE,MAAM;IACrB,OAAOwB,OAAO,CAACE,IAAI,CAAIC,MAAM,IAAM;MAClC,OACCA,MAAM,CAACC,YAAY,KACjB,CAAED,MAAM,CAACE,UAAU,IAAIF,MAAM,CAACE,UAAU,CAAE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