@wordpress/dataviews 12.0.1-next.v.202602091733.0 → 12.0.1

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 (260) hide show
  1. package/CHANGELOG.md +39 -1
  2. package/README.md +3 -1
  3. package/build/components/dataform-controls/color.cjs +19 -30
  4. package/build/components/dataform-controls/color.cjs.map +3 -3
  5. package/build/components/dataform-controls/date.cjs.map +1 -1
  6. package/build/components/dataform-controls/datetime.cjs +12 -21
  7. package/build/components/dataform-controls/datetime.cjs.map +2 -2
  8. package/build/components/dataform-layouts/card/index.cjs +112 -164
  9. package/build/components/dataform-layouts/card/index.cjs.map +3 -3
  10. package/build/components/dataform-layouts/index.cjs +1 -1
  11. package/build/components/dataform-layouts/index.cjs.map +1 -1
  12. package/build/components/dataform-layouts/normalize-form.cjs +2 -1
  13. package/build/components/dataform-layouts/normalize-form.cjs.map +2 -2
  14. package/build/components/dataform-layouts/panel/dropdown.cjs +79 -65
  15. package/build/components/dataform-layouts/panel/dropdown.cjs.map +3 -3
  16. package/build/components/dataform-layouts/panel/index.cjs +13 -177
  17. package/build/components/dataform-layouts/panel/index.cjs.map +3 -3
  18. package/build/components/dataform-layouts/panel/modal.cjs +12 -9
  19. package/build/components/dataform-layouts/panel/modal.cjs.map +3 -3
  20. package/build/components/dataform-layouts/panel/summary-button.cjs +125 -56
  21. package/build/components/dataform-layouts/panel/summary-button.cjs.map +3 -3
  22. package/build/components/dataform-layouts/panel/utils/get-first-validation-error.cjs +59 -0
  23. package/build/components/dataform-layouts/panel/utils/get-first-validation-error.cjs.map +7 -0
  24. package/build/components/dataform-layouts/panel/utils/get-label-classname.cjs +45 -0
  25. package/build/components/dataform-layouts/panel/utils/get-label-classname.cjs.map +7 -0
  26. package/build/components/dataform-layouts/panel/utils/get-label-content.cjs +36 -0
  27. package/build/components/dataform-layouts/panel/utils/get-label-content.cjs.map +7 -0
  28. package/build/components/dataform-layouts/panel/utils/use-field-from-form-field.cjs +77 -0
  29. package/build/components/dataform-layouts/panel/utils/use-field-from-form-field.cjs.map +7 -0
  30. package/build/components/dataviews-bulk-actions/index.cjs +2 -2
  31. package/build/components/dataviews-bulk-actions/index.cjs.map +2 -2
  32. package/build/components/dataviews-context/index.cjs +1 -0
  33. package/build/components/dataviews-context/index.cjs.map +2 -2
  34. package/build/components/dataviews-filters/filter.cjs.map +1 -1
  35. package/build/components/dataviews-filters/search-widget.cjs +25 -11
  36. package/build/components/dataviews-filters/search-widget.cjs.map +2 -2
  37. package/build/components/dataviews-filters/toggle.cjs +6 -2
  38. package/build/components/dataviews-filters/toggle.cjs.map +2 -2
  39. package/build/components/dataviews-footer/index.cjs +28 -12
  40. package/build/components/dataviews-footer/index.cjs.map +3 -3
  41. package/build/components/dataviews-item-actions/index.cjs +0 -1
  42. package/build/components/dataviews-item-actions/index.cjs.map +2 -2
  43. package/build/components/dataviews-layout/index.cjs +12 -0
  44. package/build/components/dataviews-layout/index.cjs.map +2 -2
  45. package/build/components/dataviews-layouts/activity/index.cjs +41 -26
  46. package/build/components/dataviews-layouts/activity/index.cjs.map +3 -3
  47. package/build/components/dataviews-layouts/grid/composite-grid.cjs +2 -0
  48. package/build/components/dataviews-layouts/grid/composite-grid.cjs.map +2 -2
  49. package/build/components/dataviews-layouts/grid/index.cjs +19 -14
  50. package/build/components/dataviews-layouts/grid/index.cjs.map +3 -3
  51. package/build/components/dataviews-layouts/list/index.cjs +13 -9
  52. package/build/components/dataviews-layouts/list/index.cjs.map +2 -2
  53. package/build/components/dataviews-layouts/picker-table/index.cjs +1 -1
  54. package/build/components/dataviews-layouts/picker-table/index.cjs.map +2 -2
  55. package/build/components/dataviews-layouts/table/index.cjs +40 -19
  56. package/build/components/dataviews-layouts/table/index.cjs.map +2 -2
  57. package/build/dataviews/index.cjs +9 -2
  58. package/build/dataviews/index.cjs.map +3 -3
  59. package/build/dataviews-picker/index.cjs +1 -0
  60. package/build/dataviews-picker/index.cjs.map +2 -2
  61. package/build/hooks/use-data.cjs +46 -0
  62. package/build/hooks/use-data.cjs.map +7 -0
  63. package/build/hooks/use-delayed-loading.cjs +47 -0
  64. package/build/hooks/use-delayed-loading.cjs.map +7 -0
  65. package/build/types/dataform.cjs.map +1 -1
  66. package/build-module/components/dataform-controls/color.mjs +24 -31
  67. package/build-module/components/dataform-controls/color.mjs.map +2 -2
  68. package/build-module/components/dataform-controls/date.mjs.map +1 -1
  69. package/build-module/components/dataform-controls/datetime.mjs +13 -22
  70. package/build-module/components/dataform-controls/datetime.mjs.map +2 -2
  71. package/build-module/components/dataform-layouts/card/index.mjs +113 -161
  72. package/build-module/components/dataform-layouts/card/index.mjs.map +3 -3
  73. package/build-module/components/dataform-layouts/index.mjs +1 -1
  74. package/build-module/components/dataform-layouts/index.mjs.map +1 -1
  75. package/build-module/components/dataform-layouts/normalize-form.mjs +2 -1
  76. package/build-module/components/dataform-layouts/normalize-form.mjs.map +2 -2
  77. package/build-module/components/dataform-layouts/panel/dropdown.mjs +81 -67
  78. package/build-module/components/dataform-layouts/panel/dropdown.mjs.map +2 -2
  79. package/build-module/components/dataform-layouts/panel/index.mjs +14 -178
  80. package/build-module/components/dataform-layouts/panel/index.mjs.map +2 -2
  81. package/build-module/components/dataform-layouts/panel/modal.mjs +12 -9
  82. package/build-module/components/dataform-layouts/panel/modal.mjs.map +2 -2
  83. package/build-module/components/dataform-layouts/panel/summary-button.mjs +117 -58
  84. package/build-module/components/dataform-layouts/panel/summary-button.mjs.map +2 -2
  85. package/build-module/components/dataform-layouts/panel/utils/get-first-validation-error.mjs +38 -0
  86. package/build-module/components/dataform-layouts/panel/utils/get-first-validation-error.mjs.map +7 -0
  87. package/build-module/components/dataform-layouts/panel/utils/get-label-classname.mjs +14 -0
  88. package/build-module/components/dataform-layouts/panel/utils/get-label-classname.mjs.map +7 -0
  89. package/build-module/components/dataform-layouts/panel/utils/get-label-content.mjs +15 -0
  90. package/build-module/components/dataform-layouts/panel/utils/get-label-content.mjs.map +7 -0
  91. package/build-module/components/dataform-layouts/panel/utils/use-field-from-form-field.mjs +46 -0
  92. package/build-module/components/dataform-layouts/panel/utils/use-field-from-form-field.mjs.map +7 -0
  93. package/build-module/components/dataviews-bulk-actions/index.mjs +2 -2
  94. package/build-module/components/dataviews-bulk-actions/index.mjs.map +2 -2
  95. package/build-module/components/dataviews-context/index.mjs +1 -0
  96. package/build-module/components/dataviews-context/index.mjs.map +2 -2
  97. package/build-module/components/dataviews-filters/filter.mjs.map +1 -1
  98. package/build-module/components/dataviews-filters/search-widget.mjs +25 -11
  99. package/build-module/components/dataviews-filters/search-widget.mjs.map +2 -2
  100. package/build-module/components/dataviews-filters/toggle.mjs +6 -2
  101. package/build-module/components/dataviews-filters/toggle.mjs.map +2 -2
  102. package/build-module/components/dataviews-footer/index.mjs +28 -12
  103. package/build-module/components/dataviews-footer/index.mjs.map +2 -2
  104. package/build-module/components/dataviews-item-actions/index.mjs +0 -1
  105. package/build-module/components/dataviews-item-actions/index.mjs.map +2 -2
  106. package/build-module/components/dataviews-layout/index.mjs +12 -0
  107. package/build-module/components/dataviews-layout/index.mjs.map +2 -2
  108. package/build-module/components/dataviews-layouts/activity/index.mjs +41 -26
  109. package/build-module/components/dataviews-layouts/activity/index.mjs.map +2 -2
  110. package/build-module/components/dataviews-layouts/grid/composite-grid.mjs +2 -0
  111. package/build-module/components/dataviews-layouts/grid/composite-grid.mjs.map +2 -2
  112. package/build-module/components/dataviews-layouts/grid/index.mjs +19 -14
  113. package/build-module/components/dataviews-layouts/grid/index.mjs.map +2 -2
  114. package/build-module/components/dataviews-layouts/list/index.mjs +13 -9
  115. package/build-module/components/dataviews-layouts/list/index.mjs.map +2 -2
  116. package/build-module/components/dataviews-layouts/picker-table/index.mjs +1 -1
  117. package/build-module/components/dataviews-layouts/picker-table/index.mjs.map +2 -2
  118. package/build-module/components/dataviews-layouts/table/index.mjs +40 -19
  119. package/build-module/components/dataviews-layouts/table/index.mjs.map +2 -2
  120. package/build-module/dataviews/index.mjs +9 -2
  121. package/build-module/dataviews/index.mjs.map +2 -2
  122. package/build-module/dataviews-picker/index.mjs +1 -0
  123. package/build-module/dataviews-picker/index.mjs.map +2 -2
  124. package/build-module/hooks/use-data.mjs +25 -0
  125. package/build-module/hooks/use-data.mjs.map +7 -0
  126. package/build-module/hooks/use-delayed-loading.mjs +22 -0
  127. package/build-module/hooks/use-delayed-loading.mjs.map +7 -0
  128. package/build-style/style-rtl.css +190 -31
  129. package/build-style/style.css +190 -31
  130. package/build-types/components/dataform-controls/color.d.ts.map +1 -1
  131. package/build-types/components/dataform-controls/datetime.d.ts.map +1 -1
  132. package/build-types/components/dataform-controls/utils/use-disabled-date-matchers.d.ts +16 -0
  133. package/build-types/components/dataform-controls/utils/use-disabled-date-matchers.d.ts.map +1 -0
  134. package/build-types/components/dataform-layouts/card/index.d.ts +1 -10
  135. package/build-types/components/dataform-layouts/card/index.d.ts.map +1 -1
  136. package/build-types/components/dataform-layouts/normalize-form.d.ts.map +1 -1
  137. package/build-types/components/dataform-layouts/panel/dropdown.d.ts +2 -13
  138. package/build-types/components/dataform-layouts/panel/dropdown.d.ts.map +1 -1
  139. package/build-types/components/dataform-layouts/panel/index.d.ts +1 -1
  140. package/build-types/components/dataform-layouts/panel/index.d.ts.map +1 -1
  141. package/build-types/components/dataform-layouts/panel/modal.d.ts +2 -11
  142. package/build-types/components/dataform-layouts/panel/modal.d.ts.map +1 -1
  143. package/build-types/components/dataform-layouts/panel/summary-button.d.ts +6 -5
  144. package/build-types/components/dataform-layouts/panel/summary-button.d.ts.map +1 -1
  145. package/build-types/components/dataform-layouts/panel/utils/get-first-validation-error.d.ts +4 -0
  146. package/build-types/components/dataform-layouts/panel/utils/get-first-validation-error.d.ts.map +1 -0
  147. package/build-types/components/dataform-layouts/panel/utils/get-label-classname.d.ts +4 -0
  148. package/build-types/components/dataform-layouts/panel/utils/get-label-classname.d.ts.map +1 -0
  149. package/build-types/components/dataform-layouts/panel/utils/get-label-content.d.ts +3 -0
  150. package/build-types/components/dataform-layouts/panel/utils/get-label-content.d.ts.map +1 -0
  151. package/build-types/components/dataform-layouts/panel/utils/use-field-from-form-field.d.ts +23 -0
  152. package/build-types/components/dataform-layouts/panel/utils/use-field-from-form-field.d.ts.map +1 -0
  153. package/build-types/components/dataviews-context/index.d.ts +1 -0
  154. package/build-types/components/dataviews-context/index.d.ts.map +1 -1
  155. package/build-types/components/dataviews-filters/filter.d.ts +1 -1
  156. package/build-types/components/dataviews-filters/filter.d.ts.map +1 -1
  157. package/build-types/components/dataviews-filters/search-widget.d.ts.map +1 -1
  158. package/build-types/components/dataviews-filters/toggle.d.ts.map +1 -1
  159. package/build-types/components/dataviews-footer/index.d.ts +1 -1
  160. package/build-types/components/dataviews-footer/index.d.ts.map +1 -1
  161. package/build-types/components/dataviews-item-actions/index.d.ts.map +1 -1
  162. package/build-types/components/dataviews-layout/index.d.ts +1 -1
  163. package/build-types/components/dataviews-layout/index.d.ts.map +1 -1
  164. package/build-types/components/dataviews-layouts/activity/index.d.ts.map +1 -1
  165. package/build-types/components/dataviews-layouts/grid/composite-grid.d.ts +2 -1
  166. package/build-types/components/dataviews-layouts/grid/composite-grid.d.ts.map +1 -1
  167. package/build-types/components/dataviews-layouts/grid/index.d.ts.map +1 -1
  168. package/build-types/components/dataviews-layouts/list/index.d.ts.map +1 -1
  169. package/build-types/components/dataviews-layouts/picker-activity/index.d.ts +3 -0
  170. package/build-types/components/dataviews-layouts/picker-activity/index.d.ts.map +1 -0
  171. package/build-types/components/dataviews-layouts/table/index.d.ts.map +1 -1
  172. package/build-types/components/dataviews-layouts/table/use-scroll-state.d.ts +25 -0
  173. package/build-types/components/dataviews-layouts/table/use-scroll-state.d.ts.map +1 -0
  174. package/build-types/components/dataviews-layouts/utils/grid-config-options.d.ts +2 -0
  175. package/build-types/components/dataviews-layouts/utils/grid-config-options.d.ts.map +1 -0
  176. package/build-types/components/dataviews-layouts/utils/use-infinite-scroll.d.ts +22 -0
  177. package/build-types/components/dataviews-layouts/utils/use-infinite-scroll.d.ts.map +1 -0
  178. package/build-types/dataform/stories/index.story.d.ts +9 -1
  179. package/build-types/dataform/stories/index.story.d.ts.map +1 -1
  180. package/build-types/dataform/stories/layout-panel.d.ts +3 -1
  181. package/build-types/dataform/stories/layout-panel.d.ts.map +1 -1
  182. package/build-types/dataviews/index.d.ts.map +1 -1
  183. package/build-types/dataviews/stories/empty.d.ts.map +1 -1
  184. package/build-types/dataviews/stories/fixtures.d.ts +1 -0
  185. package/build-types/dataviews/stories/fixtures.d.ts.map +1 -1
  186. package/build-types/dataviews/stories/free-composition.d.ts.map +1 -1
  187. package/build-types/dataviews/stories/layout-table.d.ts.map +1 -1
  188. package/build-types/dataviews/stories/minimal-ui.d.ts.map +1 -1
  189. package/build-types/dataviews/stories/with-card.d.ts.map +1 -1
  190. package/build-types/dataviews-picker/index.d.ts.map +1 -1
  191. package/build-types/field-types/utils/is-valid-date-boundary.d.ts +7 -0
  192. package/build-types/field-types/utils/is-valid-date-boundary.d.ts.map +1 -0
  193. package/build-types/hooks/test/use-data.d.ts +2 -0
  194. package/build-types/hooks/test/use-data.d.ts.map +1 -0
  195. package/build-types/hooks/use-data.d.ts +12 -0
  196. package/build-types/hooks/use-data.d.ts.map +1 -0
  197. package/build-types/hooks/use-delayed-loading.d.ts +4 -0
  198. package/build-types/hooks/use-delayed-loading.d.ts.map +1 -0
  199. package/build-types/hooks/use-infinite-scroll.d.ts +21 -0
  200. package/build-types/hooks/use-infinite-scroll.d.ts.map +1 -0
  201. package/build-types/hooks/use-selected-items.d.ts +19 -0
  202. package/build-types/hooks/use-selected-items.d.ts.map +1 -0
  203. package/build-types/types/dataform.d.ts +3 -0
  204. package/build-types/types/dataform.d.ts.map +1 -1
  205. package/build-wp/index.js +2898 -2198
  206. package/package.json +21 -21
  207. package/src/components/dataform-controls/color.tsx +29 -36
  208. package/src/components/dataform-controls/date.tsx +2 -2
  209. package/src/components/dataform-controls/datetime.tsx +19 -34
  210. package/src/components/dataform-controls/style.scss +4 -0
  211. package/src/components/dataform-layouts/card/index.tsx +118 -185
  212. package/src/components/dataform-layouts/index.tsx +1 -1
  213. package/src/components/dataform-layouts/normalize-form.ts +1 -0
  214. package/src/components/dataform-layouts/panel/dropdown.tsx +95 -96
  215. package/src/components/dataform-layouts/panel/index.tsx +10 -245
  216. package/src/components/dataform-layouts/panel/modal.tsx +16 -20
  217. package/src/components/dataform-layouts/panel/style.scss +110 -27
  218. package/src/components/dataform-layouts/panel/summary-button.tsx +140 -62
  219. package/src/components/dataform-layouts/panel/utils/get-first-validation-error.ts +47 -0
  220. package/src/components/dataform-layouts/panel/utils/get-label-classname.ts +18 -0
  221. package/src/components/dataform-layouts/panel/utils/get-label-content.tsx +24 -0
  222. package/src/components/dataform-layouts/panel/utils/use-field-from-form-field.ts +78 -0
  223. package/src/components/dataform-layouts/regular/style.scss +7 -0
  224. package/src/components/dataform-layouts/test/normalize-form.ts +5 -0
  225. package/src/components/dataviews-bulk-actions/index.tsx +2 -2
  226. package/src/components/dataviews-context/index.ts +2 -0
  227. package/src/components/dataviews-filters/filter.tsx +1 -1
  228. package/src/components/dataviews-filters/search-widget.tsx +10 -2
  229. package/src/components/dataviews-filters/style.scss +8 -0
  230. package/src/components/dataviews-filters/toggle.tsx +10 -3
  231. package/src/components/dataviews-footer/index.tsx +39 -12
  232. package/src/components/dataviews-footer/style.scss +6 -1
  233. package/src/components/dataviews-item-actions/index.tsx +0 -3
  234. package/src/components/dataviews-item-actions/style.scss +7 -0
  235. package/src/components/dataviews-layout/index.tsx +24 -0
  236. package/src/components/dataviews-layouts/activity/index.tsx +29 -22
  237. package/src/components/dataviews-layouts/activity/style.scss +5 -0
  238. package/src/components/dataviews-layouts/grid/composite-grid.tsx +5 -1
  239. package/src/components/dataviews-layouts/grid/index.tsx +19 -22
  240. package/src/components/dataviews-layouts/grid/style.scss +5 -0
  241. package/src/components/dataviews-layouts/list/index.tsx +18 -18
  242. package/src/components/dataviews-layouts/list/style.scss +5 -0
  243. package/src/components/dataviews-layouts/picker-table/index.tsx +1 -1
  244. package/src/components/dataviews-layouts/table/index.tsx +48 -22
  245. package/src/components/dataviews-layouts/table/style.scss +8 -2
  246. package/src/dataform/stories/index.story.tsx +5 -0
  247. package/src/dataform/stories/layout-panel.tsx +19 -2
  248. package/src/dataform/test/dataform.tsx +2 -2
  249. package/src/dataviews/index.tsx +11 -3
  250. package/src/dataviews/stories/empty.tsx +1 -7
  251. package/src/dataviews/stories/fixtures.tsx +89 -0
  252. package/src/dataviews/stories/free-composition.tsx +0 -5
  253. package/src/dataviews/stories/layout-table.tsx +1 -7
  254. package/src/dataviews/stories/minimal-ui.tsx +0 -5
  255. package/src/dataviews/stories/with-card.tsx +1 -7
  256. package/src/dataviews/style.scss +25 -0
  257. package/src/dataviews-picker/index.tsx +2 -1
  258. package/src/hooks/use-data.ts +45 -0
  259. package/src/hooks/use-delayed-loading.ts +21 -0
  260. package/src/types/dataform.ts +4 -0
@@ -42,6 +42,20 @@ import ColumnPrimary from './column-primary';
42
42
  import { useIsHorizontalScrollEnd } from './use-is-horizontal-scroll-end';
43
43
  import getDataByGroup from '../utils/get-data-by-group';
44
44
  import { PropertiesSection } from '../../dataviews-view-config/properties-section';
45
+ import { useDelayedLoading } from '../../../hooks/use-delayed-loading';
46
+
47
+ function getEffectiveAlign(
48
+ explicitAlign: 'start' | 'center' | 'end' | undefined,
49
+ fieldType: string | undefined
50
+ ): 'start' | 'center' | 'end' | undefined {
51
+ if ( explicitAlign ) {
52
+ return explicitAlign;
53
+ }
54
+ if ( fieldType === 'integer' || fieldType === 'number' ) {
55
+ return 'end';
56
+ }
57
+ return undefined;
58
+ }
45
59
 
46
60
  interface TableColumnFieldProps< Item > {
47
61
  fields: NormalizedField< Item >[];
@@ -225,6 +239,8 @@ function TableRow< Item >( {
225
239
  // Explicit picks the supported styles.
226
240
  const { width, maxWidth, minWidth, align } =
227
241
  view.layout?.styles?.[ column ] ?? {};
242
+ const field = fields.find( ( f ) => f.id === column );
243
+ const effectiveAlign = getEffectiveAlign( align, field?.type );
228
244
 
229
245
  return (
230
246
  <td
@@ -239,7 +255,7 @@ function TableRow< Item >( {
239
255
  fields={ fields }
240
256
  item={ item }
241
257
  column={ column }
242
- align={ align }
258
+ align={ effectiveAlign }
243
259
  />
244
260
  </td>
245
261
  );
@@ -287,13 +303,13 @@ function ViewTable< Item >( {
287
303
  empty,
288
304
  }: ViewTableProps< Item > ) {
289
305
  const { containerRef } = useContext( DataViewsContext );
306
+ const isDelayedLoading = useDelayedLoading( isLoading );
290
307
  const headerMenuRefs = useRef<
291
308
  Map< string, { node: HTMLButtonElement; fallback: string } >
292
309
  >( new Map() );
293
- const headerMenuToFocusRef = useRef< HTMLButtonElement >();
310
+ const headerMenuToFocusRef = useRef< HTMLButtonElement >( undefined );
294
311
  const [ nextHeaderMenuToFocus, setNextHeaderMenuToFocus ] =
295
312
  useState< HTMLButtonElement >();
296
- const hasBulkActions = useSomeItemHasAPossibleBulkAction( actions, data );
297
313
  const [ contextMenuAnchor, setContextMenuAnchor ] = useState< {
298
314
  getBoundingClientRect: () => DOMRect;
299
315
  } | null >( null );
@@ -312,6 +328,8 @@ function ViewTable< Item >( {
312
328
  enabled: !! actions?.length,
313
329
  } );
314
330
 
331
+ const hasBulkActions = useSomeItemHasAPossibleBulkAction( actions, data );
332
+
315
333
  if ( nextHeaderMenuToFocus ) {
316
334
  // If we need to force focus, we short-circuit rendering here
317
335
  // to prevent any additional work while we handle that.
@@ -382,6 +400,18 @@ function ViewTable< Item >( {
382
400
  };
383
401
  const isInfiniteScroll = view.infiniteScrollEnabled && ! dataByGroup;
384
402
  const isRtl = isRTL();
403
+ if ( ! hasData ) {
404
+ return (
405
+ <div
406
+ className={ clsx( 'dataviews-no-results', {
407
+ 'is-refreshing': isDelayedLoading,
408
+ } ) }
409
+ id={ tableNoticeId }
410
+ >
411
+ { empty }
412
+ </div>
413
+ );
414
+ }
385
415
 
386
416
  return (
387
417
  <>
@@ -393,10 +423,13 @@ function ViewTable< Item >( {
393
423
  view.layout.density
394
424
  ),
395
425
  'has-bulk-actions': hasBulkActions,
426
+ 'is-refreshing': ! isInfiniteScroll && isDelayedLoading,
396
427
  } ) }
397
428
  aria-busy={ isLoading }
398
429
  aria-describedby={ tableNoticeId }
399
430
  role={ isInfiniteScroll ? 'feed' : undefined }
431
+ // @ts-ignore Reason: inert is a recent HTML attribute
432
+ inert={ ! isInfiniteScroll && isLoading ? 'true' : undefined }
400
433
  >
401
434
  <colgroup>
402
435
  { hasBulkActions && (
@@ -482,6 +515,13 @@ function ViewTable< Item >( {
482
515
  // Explicit picks the supported styles.
483
516
  const { width, maxWidth, minWidth, align } =
484
517
  view.layout?.styles?.[ column ] ?? {};
518
+ const field = fields.find(
519
+ ( f ) => f.id === column
520
+ );
521
+ const effectiveAlign = getEffectiveAlign(
522
+ align,
523
+ field?.type
524
+ );
485
525
  const canInsertOrMove =
486
526
  view.layout?.enableMoving ?? true;
487
527
  return (
@@ -491,7 +531,7 @@ function ViewTable< Item >( {
491
531
  width,
492
532
  maxWidth,
493
533
  minWidth,
494
- textAlign: align,
534
+ textAlign: effectiveAlign,
495
535
  } }
496
536
  aria-sort={
497
537
  view.sort?.direction &&
@@ -633,27 +673,13 @@ function ViewTable< Item >( {
633
673
  </tbody>
634
674
  ) }
635
675
  </table>
636
- <div
637
- className={ clsx( {
638
- 'dataviews-loading': isLoading,
639
- 'dataviews-no-results': ! hasData && ! isLoading,
640
- } ) }
641
- id={ tableNoticeId }
642
- >
643
- { ! hasData &&
644
- ( isLoading ? (
645
- <p>
646
- <Spinner />
647
- </p>
648
- ) : (
649
- empty
650
- ) ) }
651
- { hasData && isLoading && (
676
+ { isInfiniteScroll && isLoading && (
677
+ <div className="dataviews-loading" id={ tableNoticeId }>
652
678
  <p className="dataviews-loading-more">
653
679
  <Spinner />
654
680
  </p>
655
- ) }
656
- </div>
681
+ </div>
682
+ ) }
657
683
  </>
658
684
  );
659
685
  }
@@ -2,6 +2,7 @@
2
2
  @use "@wordpress/base-styles/mixins" as *;
3
3
  @use "@wordpress/base-styles/variables" as *;
4
4
  @use "@wordpress/base-styles/z-index" as *;
5
+ @use "../../../dataviews/style" as *;
5
6
 
6
7
  .dataviews-view-table {
7
8
  width: 100%;
@@ -155,12 +156,12 @@
155
156
 
156
157
  &:has(.dataviews-view-table-header-button):first-child {
157
158
  // Table cell padding minus the header button padding.
158
- padding-left: $grid-unit-50;
159
+ padding-left: $grid-unit-20;
159
160
  }
160
161
 
161
162
  &:has(.dataviews-view-table-header-button):last-child {
162
163
  // Table cell padding minus the header button padding.
163
- padding-right: $grid-unit-50;
164
+ padding-right: $grid-unit-20;
164
165
  }
165
166
  }
166
167
  }
@@ -176,6 +177,7 @@
176
177
 
177
178
  &.dataviews-view-table__cell-align-end {
178
179
  justify-content: flex-end;
180
+ font-variant-numeric: tabular-nums;
179
181
  }
180
182
 
181
183
  &.dataviews-view-table__cell-align-center {
@@ -309,3 +311,7 @@
309
311
  .dataviews-view-table col[class^="dataviews-view-table__col-"]:not(.dataviews-view-table__col-first-data) {
310
312
  width: 1%;
311
313
  }
314
+
315
+ .dataviews-view-table.is-refreshing {
316
+ @include dataviews-refreshing();
317
+ }
@@ -62,6 +62,11 @@ export const LayoutPanel = {
62
62
  description: 'Chooses how to open the panel.',
63
63
  options: [ 'default', 'dropdown', 'modal' ],
64
64
  },
65
+ editVisibility: {
66
+ control: { type: 'select' },
67
+ description: 'Chooses when the edit icon is visible.',
68
+ options: [ 'default', 'always', 'on-hover' ],
69
+ },
65
70
  },
66
71
  };
67
72
 
@@ -7,7 +7,13 @@ import { useMemo, useState } from '@wordpress/element';
7
7
  * Internal dependencies
8
8
  */
9
9
  import DataForm from '../index';
10
- import type { Field, Form, Layout, PanelLayout } from '../../types';
10
+ import type {
11
+ Field,
12
+ Form,
13
+ Layout,
14
+ PanelLayout,
15
+ EditVisibility,
16
+ } from '../../types';
11
17
 
12
18
  type SamplePost = {
13
19
  title: string;
@@ -261,10 +267,12 @@ const getPanelLayoutFromStoryArgs = ( {
261
267
  summary,
262
268
  labelPosition,
263
269
  openAs,
270
+ editVisibility,
264
271
  }: {
265
272
  summary?: string[];
266
273
  labelPosition?: 'default' | 'top' | 'side' | 'none';
267
274
  openAs?: 'default' | 'dropdown' | 'modal';
275
+ editVisibility?: 'default' | EditVisibility;
268
276
  } ): Layout | undefined => {
269
277
  const panelLayout: PanelLayout = {
270
278
  type: 'panel',
@@ -282,16 +290,22 @@ const getPanelLayoutFromStoryArgs = ( {
282
290
  panelLayout.summary = summary;
283
291
  }
284
292
 
293
+ if ( editVisibility !== 'default' ) {
294
+ panelLayout.editVisibility = editVisibility;
295
+ }
296
+
285
297
  return panelLayout;
286
298
  };
287
299
 
288
300
  const LayoutPanelComponent = ( {
289
301
  labelPosition,
290
302
  openAs,
303
+ editVisibility,
291
304
  }: {
292
305
  type: 'default' | 'regular' | 'panel' | 'card';
293
306
  labelPosition: 'default' | 'top' | 'side' | 'none';
294
307
  openAs: 'default' | 'dropdown' | 'modal';
308
+ editVisibility: 'default' | EditVisibility;
295
309
  } ) => {
296
310
  const [ post, setPost ] = useState< SamplePost >( {
297
311
  title: 'Hello, World!',
@@ -321,6 +335,7 @@ const LayoutPanelComponent = ( {
321
335
  layout: getPanelLayoutFromStoryArgs( {
322
336
  labelPosition,
323
337
  openAs,
338
+ editVisibility,
324
339
  } ),
325
340
  fields: [
326
341
  'title',
@@ -357,6 +372,7 @@ const LayoutPanelComponent = ( {
357
372
  summary: [ 'origin', 'destination', 'flight_status' ],
358
373
  labelPosition,
359
374
  openAs,
375
+ editVisibility,
360
376
  } ),
361
377
  },
362
378
  {
@@ -367,11 +383,12 @@ const LayoutPanelComponent = ( {
367
383
  summary: [ 'author', 'seat' ],
368
384
  labelPosition,
369
385
  openAs,
386
+ editVisibility,
370
387
  } ),
371
388
  },
372
389
  ],
373
390
  };
374
- }, [ labelPosition, openAs ] );
391
+ }, [ labelPosition, openAs, editVisibility ] );
375
392
 
376
393
  return (
377
394
  <DataForm< SamplePost >
@@ -511,9 +511,9 @@ describe( 'DataForm component', () => {
511
511
  />
512
512
  );
513
513
 
514
- const titleField = screen.getByText( data.title );
514
+ const titleButton = fieldsSelector.title.view();
515
515
  const user = await userEvent.setup();
516
- await user.click( titleField );
516
+ await user.click( titleButton );
517
517
  const titleEditField = screen.getByText(
518
518
  'This is the Title Field'
519
519
  );
@@ -31,6 +31,7 @@ import DataViewsViewConfig, {
31
31
  ViewTypeMenu,
32
32
  } from '../components/dataviews-view-config';
33
33
  import normalizeFields from '../field-types';
34
+ import useData from '../hooks/use-data';
34
35
  import type { Action, Field, View, SupportedLayouts } from '../types';
35
36
  import type { SelectionOrUpdater } from '../types/private';
36
37
  type ItemWithId = { id: string };
@@ -144,7 +145,7 @@ function DataViews< Item >( {
144
145
  onReset,
145
146
  }: DataViewsProps< Item > ) {
146
147
  const { infiniteScrollHandler } = paginationInfo;
147
- const containerRef = useRef< HTMLDivElement | null >( null );
148
+ const containerRef = useRef< HTMLDivElement >( null );
148
149
  const [ containerWidth, setContainerWidth ] = useState( 0 );
149
150
  const resizeObserverRef = useResizeObserver(
150
151
  ( resizeObserverEntries: any ) => {
@@ -236,6 +237,12 @@ function DataViews< Item >( {
236
237
  [ defaultLayoutsProperty ]
237
238
  );
238
239
 
240
+ const {
241
+ data: displayData,
242
+ paginationInfo: displayPaginationInfo,
243
+ hasInitiallyLoaded,
244
+ } = useData( data, isLoading, paginationInfo );
245
+
239
246
  if ( ! defaultLayouts[ view.type ] ) {
240
247
  return null;
241
248
  }
@@ -247,9 +254,9 @@ function DataViews< Item >( {
247
254
  onChangeView,
248
255
  fields: _fields,
249
256
  actions,
250
- data,
257
+ data: displayData,
251
258
  isLoading,
252
- paginationInfo,
259
+ paginationInfo: displayPaginationInfo,
253
260
  selection: _selection,
254
261
  onChangeSelection: setSelectionWithChange,
255
262
  openedFilter,
@@ -268,6 +275,7 @@ function DataViews< Item >( {
268
275
  setIsShowingFilter,
269
276
  config,
270
277
  empty,
278
+ hasInitiallyLoaded,
271
279
  hasInfiniteScrollHandler: !! infiniteScrollHandler,
272
280
  onReset,
273
281
  } }
@@ -59,13 +59,7 @@ const EmptyComponent = ( {
59
59
  search: '',
60
60
  page: 1,
61
61
  perPage: 10,
62
- layout: {
63
- styles: {
64
- satellites: {
65
- align: 'end' as const,
66
- },
67
- },
68
- },
62
+ layout: {},
69
63
  filters: [],
70
64
  fields: [ 'title', 'description', 'categories' ],
71
65
  } );
@@ -24,6 +24,7 @@ export type SpaceObject = {
24
24
  date: string;
25
25
  datetime: string;
26
26
  email: string;
27
+ author: string;
27
28
  };
28
29
 
29
30
  export const data: SpaceObject[] = [
@@ -42,6 +43,7 @@ export const data: SpaceObject[] = [
42
43
  date: '2021-01-01',
43
44
  datetime: '2021-01-01T14:30:00Z',
44
45
  email: 'moon@example.com',
46
+ author: 'lunarian_observer',
45
47
  },
46
48
  {
47
49
  id: 2,
@@ -57,6 +59,7 @@ export const data: SpaceObject[] = [
57
59
  date: '2019-01-02',
58
60
  datetime: '2019-01-02T09:15:00Z',
59
61
  email: 'io@example.com',
62
+ author: 'galilean_moon_enthusiast_supreme',
60
63
  },
61
64
  {
62
65
  id: 3,
@@ -72,6 +75,7 @@ export const data: SpaceObject[] = [
72
75
  date: '2025-01-03',
73
76
  datetime: '2025-01-03T16:45:30Z',
74
77
  email: 'europa@example.com',
78
+ author: 'icy_ocean_explorer',
75
79
  },
76
80
  {
77
81
  id: 4,
@@ -87,6 +91,7 @@ export const data: SpaceObject[] = [
87
91
  date: '2022-01-04',
88
92
  datetime: '2022-01-04T12:30:00Z',
89
93
  email: 'ganymede@example.com',
94
+ author: 'jovian_satellite_researcher',
90
95
  },
91
96
  {
92
97
  id: 5,
@@ -102,6 +107,7 @@ export const data: SpaceObject[] = [
102
107
  date: '2021-01-05',
103
108
  datetime: '2021-01-05T14:15:30Z',
104
109
  email: 'callisto@example.com',
110
+ author: 'crater_cartography_specialist',
105
111
  },
106
112
  {
107
113
  id: 6,
@@ -117,6 +123,7 @@ export const data: SpaceObject[] = [
117
123
  date: '2020-01-06',
118
124
  datetime: '2020-01-06T10:45:15Z',
119
125
  email: 'amalthea@example.com',
126
+ author: 'astro_photographer',
120
127
  },
121
128
  {
122
129
  id: 7,
@@ -132,6 +139,7 @@ export const data: SpaceObject[] = [
132
139
  date: '2019-01-07',
133
140
  datetime: '2019-01-07T16:20:45Z',
134
141
  email: 'himalia@example.com',
142
+ author: 'irregular_orbit_analyst',
135
143
  },
136
144
  {
137
145
  id: 8,
@@ -147,6 +155,7 @@ export const data: SpaceObject[] = [
147
155
  date: '2020-01-01',
148
156
  datetime: '2020-01-01T11:22:15Z',
149
157
  email: 'neptune@example.com',
158
+ author: 'neptunian_dynamics_professor',
150
159
  },
151
160
  {
152
161
  id: 9,
@@ -162,6 +171,7 @@ export const data: SpaceObject[] = [
162
171
  date: '2021-02-01',
163
172
  datetime: '2021-02-01T11:30:00Z',
164
173
  email: 'triton@example.com',
174
+ author: 'retrograde_orbit_specialist',
165
175
  },
166
176
  {
167
177
  id: 10,
@@ -177,6 +187,7 @@ export const data: SpaceObject[] = [
177
187
  date: '2020-02-02',
178
188
  datetime: '2020-02-02T15:45:30Z',
179
189
  email: 'nereid@example.com',
190
+ author: 'outer_solar_system_voyager_mission_director',
180
191
  },
181
192
  {
182
193
  id: 11,
@@ -192,6 +203,7 @@ export const data: SpaceObject[] = [
192
203
  date: '2019-02-03',
193
204
  datetime: '2019-02-03T09:20:15Z',
194
205
  email: 'proteus@example.com',
206
+ author: 'space_observer',
195
207
  },
196
208
  {
197
209
  id: 12,
@@ -207,6 +219,7 @@ export const data: SpaceObject[] = [
207
219
  date: '2020-01-02',
208
220
  datetime: '2020-01-02T13:05:45Z',
209
221
  email: 'mercury@example.com',
222
+ author: 'solar_wind_scientist',
210
223
  },
211
224
  {
212
225
  id: 13,
@@ -222,6 +235,7 @@ export const data: SpaceObject[] = [
222
235
  date: '2020-01-02',
223
236
  datetime: '2020-01-02T08:30:12Z',
224
237
  email: 'venus@example.com',
238
+ author: 'atmospheric_chemistry_expert',
225
239
  },
226
240
  {
227
241
  id: 14,
@@ -237,6 +251,7 @@ export const data: SpaceObject[] = [
237
251
  date: '2023-01-03',
238
252
  datetime: '2023-01-03T18:15:30Z',
239
253
  email: 'earth@example.com',
254
+ author: 'planetary_geologist',
240
255
  },
241
256
  {
242
257
  id: 15,
@@ -252,6 +267,7 @@ export const data: SpaceObject[] = [
252
267
  date: '2020-01-01',
253
268
  datetime: '2020-01-01T20:45:00Z',
254
269
  email: 'mars@example.com',
270
+ author: 'red_planet_explorer',
255
271
  },
256
272
  {
257
273
  id: 16,
@@ -267,6 +283,7 @@ export const data: SpaceObject[] = [
267
283
  date: '2017-01-01',
268
284
  datetime: '2017-01-01T00:01:00Z',
269
285
  email: 'jupiter@example.com',
286
+ author: 'gas_giant_meteorologist',
270
287
  },
271
288
  {
272
289
  id: 17,
@@ -282,6 +299,7 @@ export const data: SpaceObject[] = [
282
299
  date: '2020-02-01',
283
300
  datetime: '2020-02-01T00:02:00Z',
284
301
  email: 'saturn@example.com',
302
+ author: 'ring_system_analyst',
285
303
  },
286
304
  {
287
305
  id: 18,
@@ -297,6 +315,7 @@ export const data: SpaceObject[] = [
297
315
  date: '2020-03-01',
298
316
  datetime: '2020-03-01T10:15:20Z',
299
317
  email: 'uranus@example.com',
318
+ author: 'axial_tilt_researcher',
300
319
  },
301
320
  {
302
321
  id: 19,
@@ -312,6 +331,7 @@ export const data: SpaceObject[] = [
312
331
  date: '2020-03-01',
313
332
  datetime: '2020-03-01T10:15:20Z',
314
333
  email: 'thessalonikopolymnianebuchodonossarinacharybdis@example.com',
334
+ author: 'interstellar_nomadic_planetary_body_tracking_specialist',
315
335
  },
316
336
  ];
317
337
 
@@ -429,6 +449,10 @@ export const fields: Field< SpaceObject >[] = [
429
449
  value: 'Trans-Neptunian object',
430
450
  label: 'Trans-Neptunian object',
431
451
  },
452
+ {
453
+ value: 'Extreme Trans-Neptunian Scattered Disc Object',
454
+ label: 'Extreme Trans-Neptunian Scattered Disc Object',
455
+ },
432
456
  ],
433
457
  filterBy: {
434
458
  operators: [ 'is', 'isNot' ],
@@ -492,8 +516,73 @@ export const fields: Field< SpaceObject >[] = [
492
516
  { value: 'Ice giant', label: 'Ice giant' },
493
517
  { value: 'Terrestrial', label: 'Terrestrial' },
494
518
  { value: 'Gas giant', label: 'Gas giant' },
519
+ {
520
+ value: 'Extreme Outer Solar System Trans-Neptunian Region',
521
+ label: 'Extreme Outer Solar System Trans-Neptunian Region',
522
+ },
495
523
  ],
496
524
  type: 'array',
497
525
  enableGlobalSearch: true,
498
526
  },
527
+ {
528
+ label: 'Author',
529
+ id: 'author',
530
+ type: 'text',
531
+ enableHiding: false,
532
+ enableGlobalSearch: true,
533
+ elements: [
534
+ { value: 'lunarian_observer', label: 'lunarian_observer' },
535
+ {
536
+ value: 'galilean_moon_enthusiast_supreme',
537
+ label: 'galilean_moon_enthusiast_supreme',
538
+ },
539
+ { value: 'icy_ocean_explorer', label: 'icy_ocean_explorer' },
540
+ {
541
+ value: 'jovian_satellite_researcher',
542
+ label: 'jovian_satellite_researcher',
543
+ },
544
+ {
545
+ value: 'crater_cartography_specialist',
546
+ label: 'crater_cartography_specialist',
547
+ },
548
+ { value: 'astro_photographer', label: 'astro_photographer' },
549
+ {
550
+ value: 'irregular_orbit_analyst',
551
+ label: 'irregular_orbit_analyst',
552
+ },
553
+ {
554
+ value: 'neptunian_dynamics_professor',
555
+ label: 'neptunian_dynamics_professor',
556
+ },
557
+ {
558
+ value: 'retrograde_orbit_specialist',
559
+ label: 'retrograde_orbit_specialist',
560
+ },
561
+ {
562
+ value: 'outer_solar_system_voyager_mission_director',
563
+ label: 'outer_solar_system_voyager_mission_director',
564
+ },
565
+ { value: 'space_observer', label: 'space_observer' },
566
+ { value: 'solar_wind_scientist', label: 'solar_wind_scientist' },
567
+ {
568
+ value: 'atmospheric_chemistry_expert',
569
+ label: 'atmospheric_chemistry_expert',
570
+ },
571
+ { value: 'planetary_geologist', label: 'planetary_geologist' },
572
+ { value: 'red_planet_explorer', label: 'red_planet_explorer' },
573
+ {
574
+ value: 'gas_giant_meteorologist',
575
+ label: 'gas_giant_meteorologist',
576
+ },
577
+ { value: 'ring_system_analyst', label: 'ring_system_analyst' },
578
+ { value: 'axial_tilt_researcher', label: 'axial_tilt_researcher' },
579
+ {
580
+ value: 'interstellar_nomadic_planetary_body_tracking_specialist',
581
+ label: 'interstellar_nomadic_planetary_body_tracking_specialist',
582
+ },
583
+ ],
584
+ filterBy: {
585
+ operators: [ 'isAny', 'isNone' ],
586
+ },
587
+ },
499
588
  ];
@@ -134,11 +134,6 @@ export const FreeCompositionComponent = () => {
134
134
  page: 1,
135
135
  perPage: 10,
136
136
  layout: {
137
- styles: {
138
- satellites: {
139
- align: 'end' as const,
140
- },
141
- },
142
137
  enableMoving: false,
143
138
  },
144
139
  filters: [],
@@ -32,13 +32,7 @@ export const LayoutTableComponent = ( {
32
32
  search: '',
33
33
  page: 1,
34
34
  perPage: 10,
35
- layout: {
36
- styles: {
37
- satellites: {
38
- align: 'end' as const,
39
- },
40
- },
41
- },
35
+ layout: {},
42
36
  filters: [],
43
37
  fields: [ 'categories' ],
44
38
  titleField: 'title',
@@ -23,11 +23,6 @@ const MinimalUIComponent = ( {
23
23
  page: 1,
24
24
  perPage: 10,
25
25
  layout: {
26
- styles: {
27
- satellites: {
28
- align: 'end' as const,
29
- },
30
- },
31
26
  enableMoving: false,
32
27
  },
33
28
  filters: [],
@@ -24,13 +24,7 @@ const WithCardComponent = () => {
24
24
  search: '',
25
25
  page: 1,
26
26
  perPage: 10,
27
- layout: {
28
- styles: {
29
- satellites: {
30
- align: 'end' as const,
31
- },
32
- },
33
- },
27
+ layout: {},
34
28
  filters: [],
35
29
  fields: [ 'categories' ],
36
30
  titleField: 'title',
@@ -2,6 +2,16 @@
2
2
  @use "@wordpress/base-styles/variables" as *;
3
3
  @use "@wordpress/base-styles/mixins" as *;
4
4
 
5
+ @mixin dataviews-refreshing {
6
+ opacity: 0.5;
7
+ pointer-events: none;
8
+
9
+ @media not (prefers-reduced-motion) {
10
+ opacity: 1;
11
+ animation: dataviews-pulse 1s ease-in-out infinite;
12
+ }
13
+ }
14
+
5
15
  .dataviews-wrapper,
6
16
  .dataviews-picker-wrapper {
7
17
  height: 100%;
@@ -44,6 +54,21 @@
44
54
  }
45
55
  }
46
56
 
57
+ .dataviews-no-results.is-refreshing {
58
+ @include dataviews-refreshing();
59
+ }
60
+
61
+ @keyframes dataviews-pulse {
62
+ 0%,
63
+ 100% {
64
+ opacity: 1;
65
+ }
66
+
67
+ 50% {
68
+ opacity: 0.5;
69
+ }
70
+ }
71
+
47
72
  .dataviews-loading-more {
48
73
  text-align: center;
49
74
  }