@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
@@ -12,7 +12,7 @@ import {
12
12
  /**
13
13
  * Internal dependencies
14
14
  */
15
- import { LAYOUT_TABLE } from '../constants';
15
+ import { LAYOUT_TABLE } from '../../../constants';
16
16
 
17
17
  export const data = [
18
18
  {
@@ -22,6 +22,7 @@ export const data = [
22
22
  image: 'https://live.staticflickr.com/5725/21726228300_51333bd62c_b.jpg',
23
23
  type: 'Not a planet',
24
24
  categories: [ 'Space', 'NASA' ],
25
+ satellites: 0,
25
26
  },
26
27
  {
27
28
  id: 2,
@@ -30,6 +31,7 @@ export const data = [
30
31
  image: 'https://live.staticflickr.com/5678/21911065441_92e2d44708_b.jpg',
31
32
  type: 'Not a planet',
32
33
  categories: [ 'Space' ],
34
+ satellites: 0,
33
35
  },
34
36
  {
35
37
  id: 3,
@@ -38,6 +40,7 @@ export const data = [
38
40
  image: 'https://live.staticflickr.com/742/21712365770_8f70a2c91e_b.jpg',
39
41
  type: 'Not a planet',
40
42
  categories: [ 'NASA' ],
43
+ satellites: 0,
41
44
  },
42
45
  {
43
46
  id: 4,
@@ -46,6 +49,7 @@ export const data = [
46
49
  image: 'https://live.staticflickr.com/5725/21726228300_51333bd62c_b.jpg',
47
50
  type: 'Ice giant',
48
51
  categories: [ 'Space', 'Planet', 'Solar system' ],
52
+ satellites: 14,
49
53
  },
50
54
  {
51
55
  id: 5,
@@ -54,6 +58,7 @@ export const data = [
54
58
  image: 'https://live.staticflickr.com/5725/21726228300_51333bd62c_b.jpg',
55
59
  type: 'Terrestrial',
56
60
  categories: [ 'Space', 'Planet', 'Solar system' ],
61
+ satellites: 0,
57
62
  },
58
63
  {
59
64
  id: 6,
@@ -62,6 +67,7 @@ export const data = [
62
67
  image: 'https://live.staticflickr.com/5725/21726228300_51333bd62c_b.jpg',
63
68
  type: 'Terrestrial',
64
69
  categories: [ 'Space', 'Planet', 'Solar system' ],
70
+ satellites: 0,
65
71
  },
66
72
  {
67
73
  id: 7,
@@ -70,6 +76,7 @@ export const data = [
70
76
  image: 'https://live.staticflickr.com/5725/21726228300_51333bd62c_b.jpg',
71
77
  type: 'Terrestrial',
72
78
  categories: [ 'Space', 'Planet', 'Solar system' ],
79
+ satellites: 1,
73
80
  },
74
81
  {
75
82
  id: 8,
@@ -78,6 +85,7 @@ export const data = [
78
85
  image: 'https://live.staticflickr.com/5725/21726228300_51333bd62c_b.jpg',
79
86
  type: 'Terrestrial',
80
87
  categories: [ 'Space', 'Planet', 'Solar system' ],
88
+ satellites: 2,
81
89
  },
82
90
  {
83
91
  id: 9,
@@ -86,6 +94,7 @@ export const data = [
86
94
  image: 'https://live.staticflickr.com/5725/21726228300_51333bd62c_b.jpg',
87
95
  type: 'Gas giant',
88
96
  categories: [ 'Space', 'Planet', 'Solar system' ],
97
+ satellites: 95,
89
98
  },
90
99
  {
91
100
  id: 10,
@@ -94,6 +103,7 @@ export const data = [
94
103
  image: 'https://live.staticflickr.com/5725/21726228300_51333bd62c_b.jpg',
95
104
  type: 'Gas giant',
96
105
  categories: [ 'Space', 'Planet', 'Solar system' ],
106
+ satellites: 146,
97
107
  },
98
108
  {
99
109
  id: 11,
@@ -102,6 +112,7 @@ export const data = [
102
112
  image: 'https://live.staticflickr.com/5725/21726228300_51333bd62c_b.jpg',
103
113
  type: 'Ice giant',
104
114
  categories: [ 'Space', 'Ice giant', 'Solar system' ],
115
+ satellites: 28,
105
116
  },
106
117
  ];
107
118
 
@@ -110,7 +121,7 @@ export const DEFAULT_VIEW = {
110
121
  search: '',
111
122
  page: 1,
112
123
  perPage: 10,
113
- hiddenFields: [ 'image', 'type' ],
124
+ fields: [ 'title', 'description', 'categories' ],
114
125
  layout: {},
115
126
  filters: [],
116
127
  };
@@ -149,27 +160,24 @@ export const actions = [
149
160
 
150
161
  export const fields = [
151
162
  {
152
- header: 'Image',
163
+ label: 'Image',
153
164
  id: 'image',
154
165
  render: ( { item } ) => {
155
166
  return (
156
167
  <img src={ item.image } alt="" style={ { width: '100%' } } />
157
168
  );
158
169
  },
159
- width: 50,
160
170
  enableSorting: false,
161
171
  },
162
172
  {
163
- header: 'Title',
173
+ label: 'Title',
164
174
  id: 'title',
165
- maxWidth: 400,
166
175
  enableHiding: false,
167
176
  enableGlobalSearch: true,
168
177
  },
169
178
  {
170
- header: 'Type',
179
+ label: 'Type',
171
180
  id: 'type',
172
- maxWidth: 400,
173
181
  enableHiding: false,
174
182
  elements: [
175
183
  { value: 'Not a planet', label: 'Not a planet' },
@@ -179,14 +187,18 @@ export const fields = [
179
187
  ],
180
188
  },
181
189
  {
182
- header: 'Description',
190
+ label: 'Satellites',
191
+ id: 'satellites',
192
+ enableSorting: true,
193
+ },
194
+ {
195
+ label: 'Description',
183
196
  id: 'description',
184
- maxWidth: 200,
185
197
  enableSorting: false,
186
198
  enableGlobalSearch: true,
187
199
  },
188
200
  {
189
- header: 'Categories',
201
+ label: 'Categories',
190
202
  id: 'categories',
191
203
  elements: [
192
204
  { value: 'Space', label: 'Space' },
@@ -0,0 +1,65 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { useState, useMemo } from '@wordpress/element';
5
+
6
+ /**
7
+ * Internal dependencies
8
+ */
9
+ import DataViews from '../index';
10
+ import { DEFAULT_VIEW, actions, data, fields } from './fixtures';
11
+ import { LAYOUT_GRID, LAYOUT_TABLE } from '../../../constants';
12
+ import { filterSortAndPaginate } from '../../../filter-and-sort-data-view';
13
+
14
+ const meta = {
15
+ title: 'DataViews/DataViews',
16
+ component: DataViews,
17
+ };
18
+ export default meta;
19
+
20
+ export const Default = ( props ) => {
21
+ const [ view, setView ] = useState( DEFAULT_VIEW );
22
+ const { data: shownData, paginationInfo } = useMemo( () => {
23
+ return filterSortAndPaginate( data, view, fields );
24
+ }, [ view ] );
25
+ return (
26
+ <DataViews
27
+ { ...props }
28
+ paginationInfo={ paginationInfo }
29
+ data={ shownData }
30
+ view={ view }
31
+ fields={ fields }
32
+ onChangeView={ setView }
33
+ />
34
+ );
35
+ };
36
+ Default.args = {
37
+ actions,
38
+ defaultLayouts: {
39
+ [ LAYOUT_TABLE ]: {
40
+ layout: {
41
+ primaryField: 'title',
42
+ styles: {
43
+ image: {
44
+ width: 50,
45
+ },
46
+ title: {
47
+ maxWidth: 400,
48
+ },
49
+ type: {
50
+ maxWidth: 400,
51
+ },
52
+ description: {
53
+ maxWidth: 200,
54
+ },
55
+ },
56
+ },
57
+ },
58
+ [ LAYOUT_GRID ]: {
59
+ layout: {
60
+ mediaField: 'image',
61
+ primaryField: 'title',
62
+ },
63
+ },
64
+ },
65
+ };
@@ -0,0 +1,97 @@
1
+ .dataviews-wrapper {
2
+ height: 100%;
3
+ overflow: auto;
4
+ box-sizing: border-box;
5
+ scroll-padding-bottom: $grid-unit-80;
6
+ /* stylelint-disable-next-line property-no-unknown -- '@container' not globally permitted */
7
+ container: dataviews-wrapper / inline-size;
8
+ display: flex;
9
+ flex-direction: column;
10
+ }
11
+
12
+ .dataviews__view-actions {
13
+ box-sizing: border-box;
14
+ padding: $grid-unit-20 $grid-unit-60;
15
+ flex-shrink: 0;
16
+ position: sticky;
17
+ left: 0;
18
+ transition: padding ease-out 0.1s;
19
+ @include reduce-motion("transition");
20
+
21
+ .components-search-control {
22
+ .components-base-control__field {
23
+ max-width: 240px;
24
+ }
25
+ }
26
+ }
27
+
28
+ .dataviews-view-list__primary-field,
29
+ .dataviews-view-grid__primary-field,
30
+ .dataviews-view-table__primary-field {
31
+ font-size: $default-font-size;
32
+ font-weight: 500;
33
+ color: $gray-700;
34
+ text-overflow: ellipsis;
35
+ white-space: nowrap;
36
+ width: 100%;
37
+
38
+ a {
39
+ text-decoration: none;
40
+ text-overflow: ellipsis;
41
+ white-space: nowrap;
42
+ overflow: hidden;
43
+ display: block;
44
+ flex-grow: 0;
45
+ color: $gray-900;
46
+
47
+ &:hover {
48
+ color: var(--wp-admin-theme-color);
49
+ }
50
+ @include link-reset();
51
+ }
52
+
53
+ button.components-button.is-link {
54
+ text-decoration: none;
55
+ font-weight: inherit;
56
+ text-overflow: ellipsis;
57
+ white-space: nowrap;
58
+ overflow: hidden;
59
+ display: block;
60
+ width: 100%;
61
+ color: $gray-900;
62
+ &:hover {
63
+ color: var(--wp-admin-theme-color);
64
+ }
65
+ }
66
+ }
67
+
68
+ .dataviews-no-results,
69
+ .dataviews-loading {
70
+ padding: 0 $grid-unit-60;
71
+ flex-grow: 1;
72
+ display: flex;
73
+ align-items: center;
74
+ justify-content: center;
75
+ transition: padding ease-out 0.1s;
76
+ @include reduce-motion("transition");
77
+ }
78
+
79
+ /* stylelint-disable-next-line scss/at-rule-no-unknown -- '@container' not globally permitted */
80
+ @container (max-width: 430px) {
81
+ .dataviews__view-actions {
82
+ padding: $grid-unit-15 $grid-unit-30;
83
+
84
+ .components-search-control {
85
+ .components-base-control__field {
86
+ max-width: 112px;
87
+ }
88
+ }
89
+ }
90
+
91
+ .dataviews-view-grid,
92
+ .dataviews-no-results,
93
+ .dataviews-loading {
94
+ padding-left: $grid-unit-30;
95
+ padding-right: $grid-unit-30;
96
+ }
97
+ }
@@ -7,14 +7,16 @@ import {
7
7
  Modal,
8
8
  } from '@wordpress/components';
9
9
  import { __, sprintf, _n } from '@wordpress/i18n';
10
- import { useMemo, useState, useCallback } from '@wordpress/element';
10
+ import { useMemo, useState, useCallback, useContext } from '@wordpress/element';
11
11
  import { useRegistry } from '@wordpress/data';
12
12
 
13
13
  /**
14
14
  * Internal dependencies
15
15
  */
16
- import { unlock } from './lock-unlock';
17
- import type { Action, ActionModal, AnyItem } from './types';
16
+ import DataViewsContext from '../dataviews-context';
17
+ import { LAYOUT_TABLE, LAYOUT_GRID } from '../../constants';
18
+ import { unlock } from '../../lock-unlock';
19
+ import type { Action, ActionModal } from '../../types';
18
20
 
19
21
  const {
20
22
  DropdownMenuV2: DropdownMenu,
@@ -23,34 +25,26 @@ const {
23
25
  DropdownMenuSeparatorV2: DropdownMenuSeparator,
24
26
  } = unlock( componentsPrivateApis );
25
27
 
26
- interface ActionWithModalProps< Item extends AnyItem > {
28
+ interface ActionWithModalProps< Item > {
27
29
  action: ActionModal< Item >;
28
30
  selectedItems: Item[];
29
31
  setActionWithModal: ( action?: ActionModal< Item > ) => void;
30
32
  onMenuOpenChange: ( isOpen: boolean ) => void;
31
33
  }
32
34
 
33
- interface BulkActionsItemProps< Item extends AnyItem > {
35
+ interface BulkActionsItemProps< Item > {
34
36
  action: Action< Item >;
35
37
  selectedItems: Item[];
36
38
  setActionWithModal: ( action?: ActionModal< Item > ) => void;
37
39
  }
38
40
 
39
- interface ActionsMenuGroupProps< Item extends AnyItem > {
41
+ interface ActionsMenuGroupProps< Item > {
40
42
  actions: Action< Item >[];
41
43
  selectedItems: Item[];
42
44
  setActionWithModal: ( action?: ActionModal< Item > ) => void;
43
45
  }
44
46
 
45
- interface BulkActionsProps< Item extends AnyItem > {
46
- data: Item[];
47
- actions: Action< Item >[];
48
- selection: string[];
49
- onSelectionChange: ( selection: Item[] ) => void;
50
- getItemId: ( item: Item ) => string;
51
- }
52
-
53
- export function useHasAPossibleBulkAction< Item extends AnyItem >(
47
+ export function useHasAPossibleBulkAction< Item >(
54
48
  actions: Action< Item >[],
55
49
  item: Item
56
50
  ) {
@@ -64,7 +58,7 @@ export function useHasAPossibleBulkAction< Item extends AnyItem >(
64
58
  }, [ actions, item ] );
65
59
  }
66
60
 
67
- export function useSomeItemHasAPossibleBulkAction< Item extends AnyItem >(
61
+ export function useSomeItemHasAPossibleBulkAction< Item >(
68
62
  actions: Action< Item >[],
69
63
  data: Item[]
70
64
  ) {
@@ -80,7 +74,7 @@ export function useSomeItemHasAPossibleBulkAction< Item extends AnyItem >(
80
74
  }, [ actions, data ] );
81
75
  }
82
76
 
83
- function ActionWithModal< Item extends AnyItem >( {
77
+ function ActionWithModal< Item >( {
84
78
  action,
85
79
  selectedItems,
86
80
  setActionWithModal,
@@ -104,7 +98,7 @@ function ActionWithModal< Item extends AnyItem >( {
104
98
  title={ ! hideModalHeader ? label : undefined }
105
99
  __experimentalHideHeader={ !! hideModalHeader }
106
100
  onRequestClose={ onCloseModal }
107
- overlayClassName="dataviews-action-modal"
101
+ overlayClassName="dataviews-bulk-actions__modal"
108
102
  >
109
103
  <RenderModal
110
104
  items={ eligibleItems }
@@ -115,7 +109,7 @@ function ActionWithModal< Item extends AnyItem >( {
115
109
  );
116
110
  }
117
111
 
118
- function BulkActionItem< Item extends AnyItem >( {
112
+ function BulkActionItem< Item >( {
119
113
  action,
120
114
  selectedItems,
121
115
  setActionWithModal,
@@ -132,7 +126,6 @@ function BulkActionItem< Item extends AnyItem >( {
132
126
  return (
133
127
  <DropdownMenuItem
134
128
  key={ action.id }
135
- disabled={ eligibleItems.length === 0 }
136
129
  hideOnClick={ ! shouldShowModal }
137
130
  onClick={ async () => {
138
131
  if ( shouldShowModal ) {
@@ -141,24 +134,32 @@ function BulkActionItem< Item extends AnyItem >( {
141
134
  action.callback( eligibleItems, { registry } );
142
135
  }
143
136
  } }
144
- suffix={
145
- eligibleItems.length > 0 ? eligibleItems.length : undefined
146
- }
137
+ suffix={ eligibleItems.length }
147
138
  >
148
139
  { action.label }
149
140
  </DropdownMenuItem>
150
141
  );
151
142
  }
152
143
 
153
- function ActionsMenuGroup< Item extends AnyItem >( {
144
+ function ActionsMenuGroup< Item >( {
154
145
  actions,
155
146
  selectedItems,
156
147
  setActionWithModal,
157
148
  }: ActionsMenuGroupProps< Item > ) {
149
+ const elligibleActions = useMemo( () => {
150
+ return actions.filter( ( action ) => {
151
+ return selectedItems.some(
152
+ ( item ) => ! action.isEligible || action.isEligible( item )
153
+ );
154
+ } );
155
+ }, [ actions, selectedItems ] );
156
+ if ( ! elligibleActions.length ) {
157
+ return null;
158
+ }
158
159
  return (
159
160
  <>
160
161
  <DropdownMenuGroup>
161
- { actions.map( ( action ) => (
162
+ { elligibleActions.map( ( action ) => (
162
163
  <BulkActionItem
163
164
  key={ action.id }
164
165
  action={ action }
@@ -172,20 +173,21 @@ function ActionsMenuGroup< Item extends AnyItem >( {
172
173
  );
173
174
  }
174
175
 
175
- export default function BulkActions< Item extends AnyItem >( {
176
- data,
177
- actions,
178
- selection,
179
- onSelectionChange,
180
- getItemId,
181
- }: BulkActionsProps< Item > ) {
176
+ function _BulkActions() {
177
+ const {
178
+ data,
179
+ actions = [],
180
+ selection,
181
+ onChangeSelection,
182
+ getItemId,
183
+ } = useContext( DataViewsContext );
182
184
  const bulkActions = useMemo(
183
185
  () => actions.filter( ( action ) => action.supportsBulk ),
184
186
  [ actions ]
185
187
  );
186
188
  const [ isMenuOpen, onMenuOpenChange ] = useState( false );
187
189
  const [ actionWithModal, setActionWithModal ] = useState<
188
- ActionModal< Item > | undefined
190
+ ActionModal< any > | undefined
189
191
  >();
190
192
  const selectableItems = useMemo( () => {
191
193
  return data.filter( ( item ) => {
@@ -219,7 +221,7 @@ export default function BulkActions< Item extends AnyItem >( {
219
221
  style={ { minWidth: '240px' } }
220
222
  trigger={
221
223
  <Button
222
- className="dataviews-bulk-edit-button"
224
+ className="dataviews-bulk-actions__edit-button"
223
225
  __next40pxDefaultSize
224
226
  variant="tertiary"
225
227
  size="compact"
@@ -248,7 +250,11 @@ export default function BulkActions< Item extends AnyItem >( {
248
250
  disabled={ areAllSelected }
249
251
  hideOnClick={ false }
250
252
  onClick={ () => {
251
- onSelectionChange( selectableItems );
253
+ onChangeSelection(
254
+ selectableItems.map( ( item ) =>
255
+ getItemId( item )
256
+ )
257
+ );
252
258
  } }
253
259
  suffix={ numberSelectableItems }
254
260
  >
@@ -258,7 +264,7 @@ export default function BulkActions< Item extends AnyItem >( {
258
264
  disabled={ selection.length === 0 }
259
265
  hideOnClick={ false }
260
266
  onClick={ () => {
261
- onSelectionChange( [] );
267
+ onChangeSelection( [] );
262
268
  } }
263
269
  >
264
270
  { __( 'Deselect' ) }
@@ -276,3 +282,19 @@ export default function BulkActions< Item extends AnyItem >( {
276
282
  </>
277
283
  );
278
284
  }
285
+
286
+ export default function BulkActions() {
287
+ const { data, actions = [], view } = useContext( DataViewsContext );
288
+ const hasPossibleBulkAction = useSomeItemHasAPossibleBulkAction(
289
+ actions,
290
+ data
291
+ );
292
+ if (
293
+ ! [ LAYOUT_TABLE, LAYOUT_GRID ].includes( view.type ) ||
294
+ ! hasPossibleBulkAction
295
+ ) {
296
+ return null;
297
+ }
298
+
299
+ return <_BulkActions />;
300
+ }
@@ -0,0 +1,7 @@
1
+ .dataviews-bulk-actions__modal {
2
+ z-index: z-index(".dataviews-bulk-actions__modal");
3
+ }
4
+
5
+ .dataviews-bulk-actions__edit-button.components-button {
6
+ flex-shrink: 0;
7
+ }