@wordpress/dataviews 2.2.0 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (298) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/README.md +23 -8
  3. package/build/components/dataform/index.js +78 -0
  4. package/build/components/dataform/index.js.map +1 -0
  5. package/build/components/dataviews/index.js +115 -0
  6. package/build/components/dataviews/index.js.map +1 -0
  7. package/build/{bulk-actions.js → components/dataviews-bulk-actions/index.js} +39 -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 -20
  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} +3 -3
  14. package/build/components/dataviews-filters/add-filter.js.map +1 -0
  15. package/build/{filter-summary.js → components/dataviews-filters/filter-summary.js} +15 -14
  16. package/build/components/dataviews-filters/filter-summary.js.map +1 -0
  17. package/build/{filters.js → components/dataviews-filters/index.js} +15 -16
  18. package/build/components/dataviews-filters/index.js.map +1 -0
  19. package/build/{reset-filters.js → components/dataviews-filters/reset-filters.js} +1 -1
  20. package/build/components/dataviews-filters/reset-filters.js.map +1 -0
  21. package/build/{search-widget.js → components/dataviews-filters/search-widget.js} +21 -19
  22. package/build/components/dataviews-filters/search-widget.js.map +1 -0
  23. package/build/{item-actions.js → components/dataviews-item-actions/index.js} +3 -3
  24. package/build/components/dataviews-item-actions/index.js.map +1 -0
  25. package/build/components/dataviews-layout/index.js +53 -0
  26. package/build/components/dataviews-layout/index.js.map +1 -0
  27. package/build/{pagination.js → components/dataviews-pagination/index.js} +18 -15
  28. package/build/components/dataviews-pagination/index.js.map +1 -0
  29. package/build/{search.js → components/dataviews-search/index.js} +10 -6
  30. package/build/components/dataviews-search/index.js.map +1 -0
  31. package/build/components/dataviews-selection-checkbox/index.js +52 -0
  32. package/build/components/dataviews-selection-checkbox/index.js.map +1 -0
  33. package/build/{view-actions.js → components/dataviews-view-config/index.js} +94 -80
  34. package/build/components/dataviews-view-config/index.js.map +1 -0
  35. package/build/filter-and-sort-data-view.js +4 -1
  36. package/build/filter-and-sort-data-view.js.map +1 -1
  37. package/build/index.js +8 -1
  38. package/build/index.js.map +1 -1
  39. package/build/layouts/grid/density-picker.js +143 -0
  40. package/build/layouts/grid/density-picker.js.map +1 -0
  41. package/build/{view-grid.js → layouts/grid/index.js} +40 -53
  42. package/build/layouts/grid/index.js.map +1 -0
  43. package/build/layouts/index.js +52 -0
  44. package/build/layouts/index.js.map +1 -0
  45. package/build/{view-list.js → layouts/list/index.js} +31 -27
  46. package/build/layouts/list/index.js.map +1 -0
  47. package/build/layouts/table/column-header-menu.js +196 -0
  48. package/build/layouts/table/column-header-menu.js.map +1 -0
  49. package/build/layouts/table/index.js +350 -0
  50. package/build/layouts/table/index.js.map +1 -0
  51. package/build/normalize-fields.js +1 -1
  52. package/build/normalize-fields.js.map +1 -1
  53. package/build/private-types.js +6 -0
  54. package/build/private-types.js.map +1 -0
  55. package/build/types.js.map +1 -1
  56. package/build/utils.js.map +1 -1
  57. package/build-module/components/dataform/index.js +72 -0
  58. package/build-module/components/dataform/index.js.map +1 -0
  59. package/build-module/components/dataviews/index.js +108 -0
  60. package/build-module/components/dataviews/index.js.map +1 -0
  61. package/build-module/{bulk-actions.js → components/dataviews-bulk-actions/index.js} +39 -17
  62. package/build-module/components/dataviews-bulk-actions/index.js.map +1 -0
  63. package/build-module/{bulk-actions-toolbar.js → components/dataviews-bulk-actions-toolbar/index.js} +35 -20
  64. package/build-module/components/dataviews-bulk-actions-toolbar/index.js.map +1 -0
  65. package/build-module/components/dataviews-context/index.js +30 -0
  66. package/build-module/components/dataviews-context/index.js.map +1 -0
  67. package/build-module/{add-filter.js → components/dataviews-filters/add-filter.js} +3 -3
  68. package/build-module/components/dataviews-filters/add-filter.js.map +1 -0
  69. package/build-module/{filter-summary.js → components/dataviews-filters/filter-summary.js} +15 -14
  70. package/build-module/components/dataviews-filters/filter-summary.js.map +1 -0
  71. package/build-module/{filters.js → components/dataviews-filters/index.js} +16 -17
  72. package/build-module/components/dataviews-filters/index.js.map +1 -0
  73. package/build-module/{reset-filters.js → components/dataviews-filters/reset-filters.js} +1 -1
  74. package/build-module/components/dataviews-filters/reset-filters.js.map +1 -0
  75. package/build-module/{search-widget.js → components/dataviews-filters/search-widget.js} +21 -19
  76. package/build-module/components/dataviews-filters/search-widget.js.map +1 -0
  77. package/build-module/{item-actions.js → components/dataviews-item-actions/index.js} +3 -3
  78. package/build-module/components/dataviews-item-actions/index.js.map +1 -0
  79. package/build-module/components/dataviews-layout/index.js +45 -0
  80. package/build-module/components/dataviews-layout/index.js.map +1 -0
  81. package/build-module/{pagination.js → components/dataviews-pagination/index.js} +19 -17
  82. package/build-module/components/dataviews-pagination/index.js.map +1 -0
  83. package/build-module/{search.js → components/dataviews-search/index.js} +10 -7
  84. package/build-module/components/dataviews-search/index.js.map +1 -0
  85. package/build-module/components/dataviews-selection-checkbox/index.js +45 -0
  86. package/build-module/components/dataviews-selection-checkbox/index.js.map +1 -0
  87. package/build-module/{view-actions.js → components/dataviews-view-config/index.js} +98 -84
  88. package/build-module/components/dataviews-view-config/index.js.map +1 -0
  89. package/build-module/filter-and-sort-data-view.js +4 -1
  90. package/build-module/filter-and-sort-data-view.js.map +1 -1
  91. package/build-module/index.js +2 -1
  92. package/build-module/index.js.map +1 -1
  93. package/build-module/layouts/grid/density-picker.js +138 -0
  94. package/build-module/layouts/grid/density-picker.js.map +1 -0
  95. package/build-module/{view-grid.js → layouts/grid/index.js} +37 -50
  96. package/build-module/layouts/grid/index.js.map +1 -0
  97. package/build-module/layouts/index.js +43 -0
  98. package/build-module/layouts/index.js.map +1 -0
  99. package/build-module/{view-list.js → layouts/list/index.js} +29 -25
  100. package/build-module/layouts/list/index.js.map +1 -0
  101. package/build-module/layouts/table/column-header-menu.js +190 -0
  102. package/build-module/layouts/table/column-header-menu.js.map +1 -0
  103. package/build-module/layouts/table/index.js +344 -0
  104. package/build-module/layouts/table/index.js.map +1 -0
  105. package/build-module/normalize-fields.js +1 -1
  106. package/build-module/normalize-fields.js.map +1 -1
  107. package/build-module/private-types.js +2 -0
  108. package/build-module/private-types.js.map +1 -0
  109. package/build-module/types.js.map +1 -1
  110. package/build-module/utils.js.map +1 -1
  111. package/build-style/style-rtl.css +607 -561
  112. package/build-style/style.css +607 -561
  113. package/build-types/components/dataform/index.d.ts +17 -0
  114. package/build-types/components/dataform/index.d.ts.map +1 -0
  115. package/build-types/components/dataform/stories/index.story.d.ts +11 -0
  116. package/build-types/components/dataform/stories/index.story.d.ts.map +1 -0
  117. package/build-types/components/dataviews/index.d.ts +33 -0
  118. package/build-types/components/dataviews/index.d.ts.map +1 -0
  119. package/build-types/{stories → components/dataviews/stories}/fixtures.d.ts +18 -17
  120. package/build-types/components/dataviews/stories/fixtures.d.ts.map +1 -0
  121. package/build-types/components/dataviews/stories/index.story.d.ts +46 -0
  122. package/build-types/components/dataviews/stories/index.story.d.ts.map +1 -0
  123. package/build-types/components/dataviews-bulk-actions/index.d.ts +5 -0
  124. package/build-types/components/dataviews-bulk-actions/index.d.ts.map +1 -0
  125. package/build-types/components/dataviews-bulk-actions-toolbar/index.d.ts +2 -0
  126. package/build-types/components/dataviews-bulk-actions-toolbar/index.d.ts.map +1 -0
  127. package/build-types/components/dataviews-context/index.d.ts +26 -0
  128. package/build-types/components/dataviews-context/index.d.ts.map +1 -0
  129. package/build-types/{add-filter.d.ts → components/dataviews-filters/add-filter.d.ts} +1 -2
  130. package/build-types/components/dataviews-filters/add-filter.d.ts.map +1 -0
  131. package/build-types/{filter-summary.d.ts → components/dataviews-filters/filter-summary.d.ts} +1 -1
  132. package/build-types/components/dataviews-filters/filter-summary.d.ts.map +1 -0
  133. package/build-types/components/dataviews-filters/index.d.ts +4 -0
  134. package/build-types/components/dataviews-filters/index.d.ts.map +1 -0
  135. package/build-types/{reset-filters.d.ts → components/dataviews-filters/reset-filters.d.ts} +1 -2
  136. package/build-types/components/dataviews-filters/reset-filters.d.ts.map +1 -0
  137. package/build-types/{search-widget.d.ts → components/dataviews-filters/search-widget.d.ts} +1 -2
  138. package/build-types/components/dataviews-filters/search-widget.d.ts.map +1 -0
  139. package/build-types/components/dataviews-item-actions/index.d.ts +35 -0
  140. package/build-types/components/dataviews-item-actions/index.d.ts.map +1 -0
  141. package/build-types/components/dataviews-layout/index.d.ts +2 -0
  142. package/build-types/components/dataviews-layout/index.d.ts.map +1 -0
  143. package/build-types/components/dataviews-pagination/index.d.ts +4 -0
  144. package/build-types/components/dataviews-pagination/index.d.ts.map +1 -0
  145. package/build-types/components/dataviews-search/index.d.ts +6 -0
  146. package/build-types/components/dataviews-search/index.d.ts.map +1 -0
  147. package/build-types/components/dataviews-selection-checkbox/index.d.ts +16 -0
  148. package/build-types/components/dataviews-selection-checkbox/index.d.ts.map +1 -0
  149. package/build-types/components/dataviews-view-config/index.d.ts +8 -0
  150. package/build-types/components/dataviews-view-config/index.d.ts.map +1 -0
  151. package/build-types/filter-and-sort-data-view.d.ts +2 -2
  152. package/build-types/filter-and-sort-data-view.d.ts.map +1 -1
  153. package/build-types/index.d.ts +2 -1
  154. package/build-types/index.d.ts.map +1 -1
  155. package/build-types/layouts/grid/density-picker.d.ts +5 -0
  156. package/build-types/layouts/grid/density-picker.d.ts.map +1 -0
  157. package/build-types/layouts/grid/index.d.ts +3 -0
  158. package/build-types/layouts/grid/index.d.ts.map +1 -0
  159. package/build-types/{layouts.d.ts → layouts/index.d.ts} +6 -5
  160. package/build-types/layouts/index.d.ts.map +1 -0
  161. package/build-types/layouts/list/index.d.ts +3 -0
  162. package/build-types/layouts/list/index.d.ts.map +1 -0
  163. package/build-types/layouts/table/column-header-menu.d.ts +17 -0
  164. package/build-types/layouts/table/column-header-menu.d.ts.map +1 -0
  165. package/build-types/layouts/table/index.d.ts +4 -0
  166. package/build-types/layouts/table/index.d.ts.map +1 -0
  167. package/build-types/normalize-fields.d.ts +2 -2
  168. package/build-types/normalize-fields.d.ts.map +1 -1
  169. package/build-types/private-types.d.ts +3 -0
  170. package/build-types/private-types.d.ts.map +1 -0
  171. package/build-types/types.d.ts +106 -46
  172. package/build-types/types.d.ts.map +1 -1
  173. package/build-types/utils.d.ts +2 -2
  174. package/build-types/utils.d.ts.map +1 -1
  175. package/package.json +10 -10
  176. package/src/components/dataform/index.tsx +106 -0
  177. package/src/components/dataform/stories/index.story.tsx +42 -0
  178. package/src/components/dataviews/index.tsx +149 -0
  179. package/src/{stories → components/dataviews/stories}/fixtures.js +23 -11
  180. package/src/components/dataviews/stories/index.story.js +65 -0
  181. package/src/components/dataviews/style.scss +97 -0
  182. package/src/{bulk-actions.tsx → components/dataviews-bulk-actions/index.tsx} +58 -36
  183. package/src/components/dataviews-bulk-actions/style.scss +7 -0
  184. package/src/{bulk-actions-toolbar.tsx → components/dataviews-bulk-actions-toolbar/index.tsx} +48 -36
  185. package/src/components/dataviews-bulk-actions-toolbar/style.scss +45 -0
  186. package/src/components/dataviews-context/index.ts +49 -0
  187. package/src/{add-filter.tsx → components/dataviews-filters/add-filter.tsx} +4 -4
  188. package/src/{filter-summary.tsx → components/dataviews-filters/filter-summary.tsx} +36 -22
  189. package/src/{filters.tsx → components/dataviews-filters/index.tsx} +11 -25
  190. package/src/{reset-filters.tsx → components/dataviews-filters/reset-filters.tsx} +2 -2
  191. package/src/{search-widget.tsx → components/dataviews-filters/search-widget.tsx} +20 -20
  192. package/src/components/dataviews-filters/style.scss +252 -0
  193. package/src/{item-actions.tsx → components/dataviews-item-actions/index.tsx} +16 -17
  194. package/src/components/dataviews-item-actions/style.scss +3 -0
  195. package/src/components/dataviews-layout/index.tsx +51 -0
  196. package/src/{pagination.tsx → components/dataviews-pagination/index.tsx} +15 -23
  197. package/src/components/dataviews-pagination/style.scss +26 -0
  198. package/src/{search.tsx → components/dataviews-search/index.tsx} +5 -10
  199. package/src/components/dataviews-selection-checkbox/index.tsx +65 -0
  200. package/src/components/dataviews-selection-checkbox/style.scss +14 -0
  201. package/src/{view-actions.tsx → components/dataviews-view-config/index.tsx} +116 -119
  202. package/src/filter-and-sort-data-view.ts +13 -3
  203. package/src/index.ts +2 -1
  204. package/src/layouts/grid/density-picker.tsx +136 -0
  205. package/src/{view-grid.tsx → layouts/grid/index.tsx} +45 -63
  206. package/src/layouts/grid/style.scss +140 -0
  207. package/src/layouts/index.ts +66 -0
  208. package/src/{view-list.tsx → layouts/list/index.tsx} +40 -30
  209. package/src/layouts/list/style.scss +189 -0
  210. package/src/layouts/table/column-header-menu.tsx +268 -0
  211. package/src/layouts/table/index.tsx +471 -0
  212. package/src/layouts/table/style.scss +201 -0
  213. package/src/normalize-fields.ts +6 -4
  214. package/src/private-types.tsx +2 -0
  215. package/src/style.scss +11 -919
  216. package/src/test/filter-and-sort-data-view.js +17 -2
  217. package/src/types.ts +113 -55
  218. package/src/utils.ts +2 -4
  219. package/tsconfig.tsbuildinfo +1 -1
  220. package/build/add-filter.js.map +0 -1
  221. package/build/bulk-actions-toolbar.js.map +0 -1
  222. package/build/bulk-actions.js.map +0 -1
  223. package/build/dataviews.js +0 -136
  224. package/build/dataviews.js.map +0 -1
  225. package/build/filter-summary.js.map +0 -1
  226. package/build/filters.js.map +0 -1
  227. package/build/item-actions.js.map +0 -1
  228. package/build/layouts.js +0 -38
  229. package/build/layouts.js.map +0 -1
  230. package/build/pagination.js.map +0 -1
  231. package/build/reset-filters.js.map +0 -1
  232. package/build/search-widget.js.map +0 -1
  233. package/build/search.js.map +0 -1
  234. package/build/single-selection-checkbox.js +0 -63
  235. package/build/single-selection-checkbox.js.map +0 -1
  236. package/build/view-actions.js.map +0 -1
  237. package/build/view-grid.js.map +0 -1
  238. package/build/view-list.js.map +0 -1
  239. package/build/view-table.js +0 -409
  240. package/build/view-table.js.map +0 -1
  241. package/build-module/add-filter.js.map +0 -1
  242. package/build-module/bulk-actions-toolbar.js.map +0 -1
  243. package/build-module/bulk-actions.js.map +0 -1
  244. package/build-module/dataviews.js +0 -129
  245. package/build-module/dataviews.js.map +0 -1
  246. package/build-module/filter-summary.js.map +0 -1
  247. package/build-module/filters.js.map +0 -1
  248. package/build-module/item-actions.js.map +0 -1
  249. package/build-module/layouts.js +0 -30
  250. package/build-module/layouts.js.map +0 -1
  251. package/build-module/pagination.js.map +0 -1
  252. package/build-module/reset-filters.js.map +0 -1
  253. package/build-module/search-widget.js.map +0 -1
  254. package/build-module/search.js.map +0 -1
  255. package/build-module/single-selection-checkbox.js +0 -56
  256. package/build-module/single-selection-checkbox.js.map +0 -1
  257. package/build-module/view-actions.js.map +0 -1
  258. package/build-module/view-grid.js.map +0 -1
  259. package/build-module/view-list.js.map +0 -1
  260. package/build-module/view-table.js +0 -402
  261. package/build-module/view-table.js.map +0 -1
  262. package/build-types/add-filter.d.ts.map +0 -1
  263. package/build-types/bulk-actions-toolbar.d.ts +0 -12
  264. package/build-types/bulk-actions-toolbar.d.ts.map +0 -1
  265. package/build-types/bulk-actions.d.ts +0 -14
  266. package/build-types/bulk-actions.d.ts.map +0 -1
  267. package/build-types/dataviews.d.ts +0 -24
  268. package/build-types/dataviews.d.ts.map +0 -1
  269. package/build-types/filter-summary.d.ts.map +0 -1
  270. package/build-types/filters.d.ts +0 -13
  271. package/build-types/filters.d.ts.map +0 -1
  272. package/build-types/item-actions.d.ts +0 -35
  273. package/build-types/item-actions.d.ts.map +0 -1
  274. package/build-types/layouts.d.ts.map +0 -1
  275. package/build-types/pagination.d.ts +0 -16
  276. package/build-types/pagination.d.ts.map +0 -1
  277. package/build-types/reset-filters.d.ts.map +0 -1
  278. package/build-types/search-widget.d.ts.map +0 -1
  279. package/build-types/search.d.ts +0 -13
  280. package/build-types/search.d.ts.map +0 -1
  281. package/build-types/single-selection-checkbox.d.ts +0 -17
  282. package/build-types/single-selection-checkbox.d.ts.map +0 -1
  283. package/build-types/stories/fixtures.d.ts.map +0 -1
  284. package/build-types/stories/index.story.d.ts +0 -15
  285. package/build-types/stories/index.story.d.ts.map +0 -1
  286. package/build-types/view-actions.d.ts +0 -12
  287. package/build-types/view-actions.d.ts.map +0 -1
  288. package/build-types/view-grid.d.ts +0 -4
  289. package/build-types/view-grid.d.ts.map +0 -1
  290. package/build-types/view-list.d.ts +0 -4
  291. package/build-types/view-list.d.ts.map +0 -1
  292. package/build-types/view-table.d.ts +0 -5
  293. package/build-types/view-table.d.ts.map +0 -1
  294. package/src/dataviews.tsx +0 -189
  295. package/src/layouts.ts +0 -39
  296. package/src/single-selection-checkbox.tsx +0 -80
  297. package/src/stories/index.story.js +0 -64
  298. package/src/view-table.tsx +0 -603
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["@wordpress/dataviews/src/types.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { ReactElement, ReactNode } from 'react';\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 AnyItem = Record< string, any >;\n\n/**\n * A dataview field for a specific property of a data type.\n */\nexport interface Field< Item extends AnyItem > {\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 * Callback used to retrieve the value of the field from the item.\n\t * Defaults to `item[ field.id ]`.\n\t */\n\tgetValue?: ( args: { item: Item } ) => any;\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}\n\nexport type NormalizedField< Item extends AnyItem > = Field< Item > &\n\tRequired< Pick< Field< Item >, 'header' | 'getValue' | 'render' > >;\n\n/**\n * A collection of dataview fields for a data type.\n */\nexport type Fields< Item extends AnyItem > = Field< Item >[];\n\nexport type Data< Item extends AnyItem > = Item[];\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\thiddenFields: 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 extends AnyItem > {\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 AnyItem >\n\textends 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 AnyItem >\n\textends ActionBase< AnyItem > {\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 extends AnyItem > =\n\t| ActionModal< Item >\n\t| ActionButton< Item >;\n\nexport interface ViewBaseProps< Item extends AnyItem > {\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: ( items: Item[] ) => void;\n\tselection: string[];\n\tsetOpenedFilter: ( fieldId: string ) => void;\n\tview: View;\n}\n\nexport interface ViewTableProps< Item extends AnyItem >\n\textends ViewBaseProps< Item > {\n\tview: ViewTable;\n}\n\nexport interface ViewListProps< Item extends AnyItem >\n\textends ViewBaseProps< Item > {\n\tview: ViewList;\n}\n\nexport interface ViewGridProps< Item extends AnyItem >\n\textends ViewBaseProps< Item > {\n\tview: ViewGrid;\n}\n\nexport type ViewProps< Item extends AnyItem > =\n\t| ViewTableProps< Item >\n\t| ViewGridProps< Item >\n\t| ViewListProps< Item >;\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["@wordpress/dataviews/src/types.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { ReactElement, ComponentType } 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\tlabel?: 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 * 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};\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 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"],"mappings":"","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["ALL_OPERATORS","OPERATOR_IS","OPERATOR_IS_NOT","OPERATOR_IS_ANY","OPERATOR_IS_NONE","sanitizeOperators","field","operators","filterBy","Array","isArray","filter","operator","includes"],"sources":["@wordpress/dataviews/src/utils.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport {\n\tALL_OPERATORS,\n\tOPERATOR_IS,\n\tOPERATOR_IS_NOT,\n\tOPERATOR_IS_ANY,\n\tOPERATOR_IS_NONE,\n} from './constants';\nimport type { AnyItem, NormalizedField } from './types';\n\nexport function sanitizeOperators< Item extends AnyItem >(\n\tfield: NormalizedField< Item >\n) {\n\tlet operators = field.filterBy?.operators;\n\n\t// Assign default values.\n\tif ( ! operators || ! Array.isArray( operators ) ) {\n\t\toperators = [ OPERATOR_IS_ANY, OPERATOR_IS_NONE ];\n\t}\n\n\t// Make sure only valid operators are used.\n\toperators = operators.filter( ( operator ) =>\n\t\tALL_OPERATORS.includes( operator )\n\t);\n\n\t// Do not allow mixing single & multiselection operators.\n\t// Remove multiselection operators if any of the single selection ones is present.\n\tif (\n\t\toperators.includes( OPERATOR_IS ) ||\n\t\toperators.includes( OPERATOR_IS_NOT )\n\t) {\n\t\toperators = operators.filter( ( operator ) =>\n\t\t\t[ OPERATOR_IS, OPERATOR_IS_NOT ].includes( operator )\n\t\t);\n\t}\n\n\treturn operators;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,aAAa,EACbC,WAAW,EACXC,eAAe,EACfC,eAAe,EACfC,gBAAgB,QACV,aAAa;AAGpB,OAAO,SAASC,iBAAiBA,CAChCC,KAA8B,EAC7B;EACD,IAAIC,SAAS,GAAGD,KAAK,CAACE,QAAQ,EAAED,SAAS;;EAEzC;EACA,IAAK,CAAEA,SAAS,IAAI,CAAEE,KAAK,CAACC,OAAO,CAAEH,SAAU,CAAC,EAAG;IAClDA,SAAS,GAAG,CAAEJ,eAAe,EAAEC,gBAAgB,CAAE;EAClD;;EAEA;EACAG,SAAS,GAAGA,SAAS,CAACI,MAAM,CAAIC,QAAQ,IACvCZ,aAAa,CAACa,QAAQ,CAAED,QAAS,CAClC,CAAC;;EAED;EACA;EACA,IACCL,SAAS,CAACM,QAAQ,CAAEZ,WAAY,CAAC,IACjCM,SAAS,CAACM,QAAQ,CAAEX,eAAgB,CAAC,EACpC;IACDK,SAAS,GAAGA,SAAS,CAACI,MAAM,CAAIC,QAAQ,IACvC,CAAEX,WAAW,EAAEC,eAAe,CAAE,CAACW,QAAQ,CAAED,QAAS,CACrD,CAAC;EACF;EAEA,OAAOL,SAAS;AACjB","ignoreList":[]}
1
+ {"version":3,"names":["ALL_OPERATORS","OPERATOR_IS","OPERATOR_IS_NOT","OPERATOR_IS_ANY","OPERATOR_IS_NONE","sanitizeOperators","field","operators","filterBy","Array","isArray","filter","operator","includes"],"sources":["@wordpress/dataviews/src/utils.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport {\n\tALL_OPERATORS,\n\tOPERATOR_IS,\n\tOPERATOR_IS_NOT,\n\tOPERATOR_IS_ANY,\n\tOPERATOR_IS_NONE,\n} from './constants';\nimport type { NormalizedField } from './types';\n\nexport function sanitizeOperators< Item >( field: NormalizedField< Item > ) {\n\tlet operators = field.filterBy?.operators;\n\n\t// Assign default values.\n\tif ( ! operators || ! Array.isArray( operators ) ) {\n\t\toperators = [ OPERATOR_IS_ANY, OPERATOR_IS_NONE ];\n\t}\n\n\t// Make sure only valid operators are used.\n\toperators = operators.filter( ( operator ) =>\n\t\tALL_OPERATORS.includes( operator )\n\t);\n\n\t// Do not allow mixing single & multiselection operators.\n\t// Remove multiselection operators if any of the single selection ones is present.\n\tif (\n\t\toperators.includes( OPERATOR_IS ) ||\n\t\toperators.includes( OPERATOR_IS_NOT )\n\t) {\n\t\toperators = operators.filter( ( operator ) =>\n\t\t\t[ OPERATOR_IS, OPERATOR_IS_NOT ].includes( operator )\n\t\t);\n\t}\n\n\treturn operators;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,aAAa,EACbC,WAAW,EACXC,eAAe,EACfC,eAAe,EACfC,gBAAgB,QACV,aAAa;AAGpB,OAAO,SAASC,iBAAiBA,CAAUC,KAA8B,EAAG;EAC3E,IAAIC,SAAS,GAAGD,KAAK,CAACE,QAAQ,EAAED,SAAS;;EAEzC;EACA,IAAK,CAAEA,SAAS,IAAI,CAAEE,KAAK,CAACC,OAAO,CAAEH,SAAU,CAAC,EAAG;IAClDA,SAAS,GAAG,CAAEJ,eAAe,EAAEC,gBAAgB,CAAE;EAClD;;EAEA;EACAG,SAAS,GAAGA,SAAS,CAACI,MAAM,CAAIC,QAAQ,IACvCZ,aAAa,CAACa,QAAQ,CAAED,QAAS,CAClC,CAAC;;EAED;EACA;EACA,IACCL,SAAS,CAACM,QAAQ,CAAEZ,WAAY,CAAC,IACjCM,SAAS,CAACM,QAAQ,CAAEX,eAAgB,CAAC,EACpC;IACDK,SAAS,GAAGA,SAAS,CAACI,MAAM,CAAIC,QAAQ,IACvC,CAAEX,WAAW,EAAEC,eAAe,CAAE,CAACW,QAAQ,CAAED,QAAS,CACrD,CAAC;EACF;EAEA,OAAOL,SAAS;AACjB","ignoreList":[]}