@wordpress/dataviews 3.0.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 (274) hide show
  1. package/CHANGELOG.md +8 -1
  2. package/README.md +19 -4
  3. package/build/{dataform.js → components/dataform/index.js} +5 -5
  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 -19
  10. package/build/components/dataviews-bulk-actions-toolbar/index.js.map +1 -0
  11. package/build/components/dataviews-context/index.js +36 -0
  12. package/build/components/dataviews-context/index.js.map +1 -0
  13. package/build/{add-filter.js → components/dataviews-filters/add-filter.js} +2 -2
  14. package/build/components/dataviews-filters/add-filter.js.map +1 -0
  15. package/build/{filter-summary.js → components/dataviews-filters/filter-summary.js} +9 -9
  16. package/build/components/dataviews-filters/filter-summary.js.map +1 -0
  17. package/build/{filters.js → components/dataviews-filters/index.js} +14 -15
  18. package/build/components/dataviews-filters/index.js.map +1 -0
  19. package/build/components/dataviews-filters/reset-filters.js.map +1 -0
  20. package/build/{search-widget.js → components/dataviews-filters/search-widget.js} +13 -13
  21. package/build/components/dataviews-filters/search-widget.js.map +1 -0
  22. package/build/{item-actions.js → components/dataviews-item-actions/index.js} +2 -2
  23. package/build/components/dataviews-item-actions/index.js.map +1 -0
  24. package/build/components/dataviews-layout/index.js +53 -0
  25. package/build/components/dataviews-layout/index.js.map +1 -0
  26. package/build/{pagination.js → components/dataviews-pagination/index.js} +16 -13
  27. package/build/components/dataviews-pagination/index.js.map +1 -0
  28. package/build/{search.js → components/dataviews-search/index.js} +10 -6
  29. package/build/components/dataviews-search/index.js.map +1 -0
  30. package/build/{single-selection-checkbox.js → components/dataviews-selection-checkbox/index.js} +6 -6
  31. package/build/components/dataviews-selection-checkbox/index.js.map +1 -0
  32. package/build/{view-actions.js → components/dataviews-view-config/index.js} +19 -16
  33. package/build/components/dataviews-view-config/index.js.map +1 -0
  34. package/build/index.js +2 -2
  35. package/build/index.js.map +1 -1
  36. package/build/layouts/grid/density-picker.js +143 -0
  37. package/build/layouts/grid/density-picker.js.map +1 -0
  38. package/build/{view-grid.js → layouts/grid/index.js} +34 -35
  39. package/build/layouts/grid/index.js.map +1 -0
  40. package/build/layouts/index.js +52 -0
  41. package/build/layouts/index.js.map +1 -0
  42. package/build/{view-list.js → layouts/list/index.js} +26 -23
  43. package/build/layouts/list/index.js.map +1 -0
  44. package/build/layouts/table/column-header-menu.js +196 -0
  45. package/build/layouts/table/column-header-menu.js.map +1 -0
  46. package/build/layouts/table/index.js +350 -0
  47. package/build/layouts/table/index.js.map +1 -0
  48. package/build/normalize-fields.js +1 -1
  49. package/build/normalize-fields.js.map +1 -1
  50. package/build/types.js.map +1 -1
  51. package/build-module/{dataform.js → components/dataform/index.js} +5 -5
  52. package/build-module/components/dataform/index.js.map +1 -0
  53. package/build-module/components/dataviews/index.js +108 -0
  54. package/build-module/components/dataviews/index.js.map +1 -0
  55. package/build-module/{bulk-actions.js → components/dataviews-bulk-actions/index.js} +39 -17
  56. package/build-module/components/dataviews-bulk-actions/index.js.map +1 -0
  57. package/build-module/{bulk-actions-toolbar.js → components/dataviews-bulk-actions-toolbar/index.js} +35 -19
  58. package/build-module/components/dataviews-bulk-actions-toolbar/index.js.map +1 -0
  59. package/build-module/components/dataviews-context/index.js +30 -0
  60. package/build-module/components/dataviews-context/index.js.map +1 -0
  61. package/build-module/{add-filter.js → components/dataviews-filters/add-filter.js} +2 -2
  62. package/build-module/components/dataviews-filters/add-filter.js.map +1 -0
  63. package/build-module/{filter-summary.js → components/dataviews-filters/filter-summary.js} +9 -9
  64. package/build-module/components/dataviews-filters/filter-summary.js.map +1 -0
  65. package/build-module/{filters.js → components/dataviews-filters/index.js} +15 -16
  66. package/build-module/components/dataviews-filters/index.js.map +1 -0
  67. package/build-module/components/dataviews-filters/reset-filters.js.map +1 -0
  68. package/build-module/{search-widget.js → components/dataviews-filters/search-widget.js} +13 -13
  69. package/build-module/components/dataviews-filters/search-widget.js.map +1 -0
  70. package/build-module/{item-actions.js → components/dataviews-item-actions/index.js} +2 -2
  71. package/build-module/components/dataviews-item-actions/index.js.map +1 -0
  72. package/build-module/components/dataviews-layout/index.js +45 -0
  73. package/build-module/components/dataviews-layout/index.js.map +1 -0
  74. package/build-module/{pagination.js → components/dataviews-pagination/index.js} +17 -15
  75. package/build-module/components/dataviews-pagination/index.js.map +1 -0
  76. package/build-module/{search.js → components/dataviews-search/index.js} +10 -7
  77. package/build-module/components/dataviews-search/index.js.map +1 -0
  78. package/build-module/{single-selection-checkbox.js → components/dataviews-selection-checkbox/index.js} +5 -5
  79. package/build-module/components/dataviews-selection-checkbox/index.js.map +1 -0
  80. package/build-module/{view-actions.js → components/dataviews-view-config/index.js} +19 -17
  81. package/build-module/components/dataviews-view-config/index.js.map +1 -0
  82. package/build-module/index.js +2 -2
  83. package/build-module/index.js.map +1 -1
  84. package/build-module/layouts/grid/density-picker.js +138 -0
  85. package/build-module/layouts/grid/density-picker.js.map +1 -0
  86. package/build-module/{view-grid.js → layouts/grid/index.js} +31 -32
  87. package/build-module/layouts/grid/index.js.map +1 -0
  88. package/build-module/layouts/index.js +43 -0
  89. package/build-module/layouts/index.js.map +1 -0
  90. package/build-module/{view-list.js → layouts/list/index.js} +24 -21
  91. package/build-module/layouts/list/index.js.map +1 -0
  92. package/build-module/layouts/table/column-header-menu.js +190 -0
  93. package/build-module/layouts/table/column-header-menu.js.map +1 -0
  94. package/build-module/layouts/table/index.js +344 -0
  95. package/build-module/layouts/table/index.js.map +1 -0
  96. package/build-module/normalize-fields.js +1 -1
  97. package/build-module/normalize-fields.js.map +1 -1
  98. package/build-module/types.js.map +1 -1
  99. package/build-style/style-rtl.css +607 -545
  100. package/build-style/style.css +607 -545
  101. package/build-types/{dataform.d.ts → components/dataform/index.d.ts} +2 -2
  102. package/build-types/components/dataform/index.d.ts.map +1 -0
  103. package/build-types/components/dataform/stories/index.story.d.ts +11 -0
  104. package/build-types/components/dataform/stories/index.story.d.ts.map +1 -0
  105. package/build-types/{dataviews.d.ts → components/dataviews/index.d.ts} +9 -7
  106. package/build-types/components/dataviews/index.d.ts.map +1 -0
  107. package/build-types/{stories → components/dataviews/stories}/fixtures.d.ts +7 -19
  108. package/build-types/components/dataviews/stories/fixtures.d.ts.map +1 -0
  109. package/build-types/components/dataviews/stories/index.story.d.ts +46 -0
  110. package/build-types/components/dataviews/stories/index.story.d.ts.map +1 -0
  111. package/build-types/components/dataviews-bulk-actions/index.d.ts +5 -0
  112. package/build-types/components/dataviews-bulk-actions/index.d.ts.map +1 -0
  113. package/build-types/components/dataviews-bulk-actions-toolbar/index.d.ts +2 -0
  114. package/build-types/components/dataviews-bulk-actions-toolbar/index.d.ts.map +1 -0
  115. package/build-types/components/dataviews-context/index.d.ts +26 -0
  116. package/build-types/components/dataviews-context/index.d.ts.map +1 -0
  117. package/build-types/{add-filter.d.ts → components/dataviews-filters/add-filter.d.ts} +1 -2
  118. package/build-types/components/dataviews-filters/add-filter.d.ts.map +1 -0
  119. package/build-types/{filter-summary.d.ts → components/dataviews-filters/filter-summary.d.ts} +1 -1
  120. package/build-types/components/dataviews-filters/filter-summary.d.ts.map +1 -0
  121. package/build-types/components/dataviews-filters/index.d.ts +4 -0
  122. package/build-types/components/dataviews-filters/index.d.ts.map +1 -0
  123. package/build-types/{reset-filters.d.ts → components/dataviews-filters/reset-filters.d.ts} +1 -2
  124. package/build-types/components/dataviews-filters/reset-filters.d.ts.map +1 -0
  125. package/build-types/{search-widget.d.ts → components/dataviews-filters/search-widget.d.ts} +1 -2
  126. package/build-types/components/dataviews-filters/search-widget.d.ts.map +1 -0
  127. package/build-types/{item-actions.d.ts → components/dataviews-item-actions/index.d.ts} +2 -2
  128. package/build-types/components/dataviews-item-actions/index.d.ts.map +1 -0
  129. package/build-types/components/dataviews-layout/index.d.ts +2 -0
  130. package/build-types/components/dataviews-layout/index.d.ts.map +1 -0
  131. package/build-types/components/dataviews-pagination/index.d.ts +4 -0
  132. package/build-types/components/dataviews-pagination/index.d.ts.map +1 -0
  133. package/build-types/components/dataviews-search/index.d.ts +6 -0
  134. package/build-types/components/dataviews-search/index.d.ts.map +1 -0
  135. package/build-types/components/dataviews-selection-checkbox/index.d.ts +16 -0
  136. package/build-types/components/dataviews-selection-checkbox/index.d.ts.map +1 -0
  137. package/build-types/components/dataviews-view-config/index.d.ts +8 -0
  138. package/build-types/components/dataviews-view-config/index.d.ts.map +1 -0
  139. package/build-types/index.d.ts +2 -2
  140. package/build-types/index.d.ts.map +1 -1
  141. package/build-types/layouts/grid/density-picker.d.ts +5 -0
  142. package/build-types/layouts/grid/density-picker.d.ts.map +1 -0
  143. package/build-types/layouts/grid/index.d.ts +3 -0
  144. package/build-types/layouts/grid/index.d.ts.map +1 -0
  145. package/build-types/{layouts.d.ts → layouts/index.d.ts} +6 -5
  146. package/build-types/layouts/index.d.ts.map +1 -0
  147. package/build-types/layouts/list/index.d.ts +3 -0
  148. package/build-types/layouts/list/index.d.ts.map +1 -0
  149. package/build-types/layouts/table/column-header-menu.d.ts +17 -0
  150. package/build-types/layouts/table/column-header-menu.d.ts.map +1 -0
  151. package/build-types/layouts/table/index.d.ts +4 -0
  152. package/build-types/layouts/table/index.d.ts.map +1 -0
  153. package/build-types/types.d.ts +42 -23
  154. package/build-types/types.d.ts.map +1 -1
  155. package/package.json +10 -10
  156. package/src/{dataform.tsx → components/dataform/index.tsx} +5 -5
  157. package/src/components/dataform/stories/index.story.tsx +42 -0
  158. package/src/components/dataviews/index.tsx +149 -0
  159. package/src/{stories → components/dataviews/stories}/fixtures.js +7 -11
  160. package/src/{stories → components/dataviews/stories}/index.story.js +17 -3
  161. package/src/components/dataviews/style.scss +97 -0
  162. package/src/{bulk-actions.tsx → components/dataviews-bulk-actions/index.tsx} +46 -29
  163. package/src/components/dataviews-bulk-actions/style.scss +7 -0
  164. package/src/{bulk-actions-toolbar.tsx → components/dataviews-bulk-actions-toolbar/index.tsx} +42 -30
  165. package/src/components/dataviews-bulk-actions-toolbar/style.scss +45 -0
  166. package/src/components/dataviews-context/index.ts +49 -0
  167. package/src/{add-filter.tsx → components/dataviews-filters/add-filter.tsx} +3 -3
  168. package/src/{filter-summary.tsx → components/dataviews-filters/filter-summary.tsx} +18 -10
  169. package/src/{filters.tsx → components/dataviews-filters/index.tsx} +10 -24
  170. package/src/{reset-filters.tsx → components/dataviews-filters/reset-filters.tsx} +1 -1
  171. package/src/{search-widget.tsx → components/dataviews-filters/search-widget.tsx} +14 -14
  172. package/src/components/dataviews-filters/style.scss +252 -0
  173. package/src/{item-actions.tsx → components/dataviews-item-actions/index.tsx} +2 -2
  174. package/src/components/dataviews-item-actions/style.scss +3 -0
  175. package/src/components/dataviews-layout/index.tsx +51 -0
  176. package/src/{pagination.tsx → components/dataviews-pagination/index.tsx} +13 -21
  177. package/src/components/dataviews-pagination/style.scss +26 -0
  178. package/src/{search.tsx → components/dataviews-search/index.tsx} +5 -10
  179. package/src/{single-selection-checkbox.tsx → components/dataviews-selection-checkbox/index.tsx} +9 -9
  180. package/src/components/dataviews-selection-checkbox/style.scss +14 -0
  181. package/src/{view-actions.tsx → components/dataviews-view-config/index.tsx} +16 -22
  182. package/src/index.ts +2 -2
  183. package/src/layouts/grid/density-picker.tsx +136 -0
  184. package/src/{view-grid.tsx → layouts/grid/index.tsx} +28 -29
  185. package/src/layouts/grid/style.scss +140 -0
  186. package/src/layouts/index.ts +66 -0
  187. package/src/{view-list.tsx → layouts/list/index.tsx} +30 -17
  188. package/src/layouts/list/style.scss +189 -0
  189. package/src/layouts/table/column-header-menu.tsx +268 -0
  190. package/src/layouts/table/index.tsx +471 -0
  191. package/src/layouts/table/style.scss +201 -0
  192. package/src/normalize-fields.ts +1 -1
  193. package/src/style.scss +11 -907
  194. package/src/test/filter-and-sort-data-view.js +1 -1
  195. package/src/types.ts +48 -24
  196. package/tsconfig.tsbuildinfo +1 -1
  197. package/build/add-filter.js.map +0 -1
  198. package/build/bulk-actions-toolbar.js.map +0 -1
  199. package/build/bulk-actions.js.map +0 -1
  200. package/build/dataform.js.map +0 -1
  201. package/build/dataviews.js +0 -125
  202. package/build/dataviews.js.map +0 -1
  203. package/build/filter-summary.js.map +0 -1
  204. package/build/filters.js.map +0 -1
  205. package/build/item-actions.js.map +0 -1
  206. package/build/layouts.js +0 -38
  207. package/build/layouts.js.map +0 -1
  208. package/build/pagination.js.map +0 -1
  209. package/build/reset-filters.js.map +0 -1
  210. package/build/search-widget.js.map +0 -1
  211. package/build/search.js.map +0 -1
  212. package/build/single-selection-checkbox.js.map +0 -1
  213. package/build/view-actions.js.map +0 -1
  214. package/build/view-grid.js.map +0 -1
  215. package/build/view-list.js.map +0 -1
  216. package/build/view-table.js +0 -400
  217. package/build/view-table.js.map +0 -1
  218. package/build-module/add-filter.js.map +0 -1
  219. package/build-module/bulk-actions-toolbar.js.map +0 -1
  220. package/build-module/bulk-actions.js.map +0 -1
  221. package/build-module/dataform.js.map +0 -1
  222. package/build-module/dataviews.js +0 -116
  223. package/build-module/dataviews.js.map +0 -1
  224. package/build-module/filter-summary.js.map +0 -1
  225. package/build-module/filters.js.map +0 -1
  226. package/build-module/item-actions.js.map +0 -1
  227. package/build-module/layouts.js +0 -30
  228. package/build-module/layouts.js.map +0 -1
  229. package/build-module/pagination.js.map +0 -1
  230. package/build-module/reset-filters.js.map +0 -1
  231. package/build-module/search-widget.js.map +0 -1
  232. package/build-module/search.js.map +0 -1
  233. package/build-module/single-selection-checkbox.js.map +0 -1
  234. package/build-module/view-actions.js.map +0 -1
  235. package/build-module/view-grid.js.map +0 -1
  236. package/build-module/view-list.js.map +0 -1
  237. package/build-module/view-table.js +0 -393
  238. package/build-module/view-table.js.map +0 -1
  239. package/build-types/add-filter.d.ts.map +0 -1
  240. package/build-types/bulk-actions-toolbar.d.ts +0 -13
  241. package/build-types/bulk-actions-toolbar.d.ts.map +0 -1
  242. package/build-types/bulk-actions.d.ts +0 -15
  243. package/build-types/bulk-actions.d.ts.map +0 -1
  244. package/build-types/dataform.d.ts.map +0 -1
  245. package/build-types/dataviews.d.ts.map +0 -1
  246. package/build-types/filter-summary.d.ts.map +0 -1
  247. package/build-types/filters.d.ts +0 -13
  248. package/build-types/filters.d.ts.map +0 -1
  249. package/build-types/item-actions.d.ts.map +0 -1
  250. package/build-types/layouts.d.ts.map +0 -1
  251. package/build-types/pagination.d.ts +0 -16
  252. package/build-types/pagination.d.ts.map +0 -1
  253. package/build-types/reset-filters.d.ts.map +0 -1
  254. package/build-types/search-widget.d.ts.map +0 -1
  255. package/build-types/search.d.ts +0 -13
  256. package/build-types/search.d.ts.map +0 -1
  257. package/build-types/single-selection-checkbox.d.ts +0 -17
  258. package/build-types/single-selection-checkbox.d.ts.map +0 -1
  259. package/build-types/stories/fixtures.d.ts.map +0 -1
  260. package/build-types/stories/index.story.d.ts +0 -29
  261. package/build-types/stories/index.story.d.ts.map +0 -1
  262. package/build-types/view-actions.d.ts +0 -12
  263. package/build-types/view-actions.d.ts.map +0 -1
  264. package/build-types/view-grid.d.ts +0 -4
  265. package/build-types/view-grid.d.ts.map +0 -1
  266. package/build-types/view-list.d.ts +0 -4
  267. package/build-types/view-list.d.ts.map +0 -1
  268. package/build-types/view-table.d.ts +0 -5
  269. package/build-types/view-table.d.ts.map +0 -1
  270. package/src/dataviews.tsx +0 -183
  271. package/src/layouts.ts +0 -39
  272. package/src/view-table.tsx +0 -592
  273. /package/build/{reset-filters.js → components/dataviews-filters/reset-filters.js} +0 -0
  274. /package/build-module/{reset-filters.js → components/dataviews-filters/reset-filters.js} +0 -0
@@ -0,0 +1,252 @@
1
+ .dataviews-filters__button {
2
+ position: relative;
3
+ }
4
+
5
+ .dataviews-filters__reset-button.dataviews-filters__reset-button[aria-disabled="true"] {
6
+ &,
7
+ &:hover {
8
+ opacity: 0;
9
+ }
10
+
11
+ &:focus {
12
+ opacity: 1;
13
+ }
14
+ }
15
+
16
+ .dataviews-filters__summary-popover {
17
+ .components-popover__content {
18
+ width: 230px;
19
+ padding: 0;
20
+ border-radius: $grid-unit-05;
21
+ }
22
+ }
23
+
24
+ .dataviews-filters__summary-operators-container {
25
+ padding: $grid-unit-10 $grid-unit-10 0;
26
+
27
+ &:has(+ .dataviews-filters__search-widget-listbox) {
28
+ border-bottom: 1px solid $gray-200;
29
+ padding-bottom: $grid-unit-10;
30
+ }
31
+
32
+ &:empty {
33
+ display: none;
34
+ }
35
+
36
+ .dataviews-filters__summary-operators-filter-name {
37
+ color: $gray-700;
38
+ }
39
+ }
40
+
41
+ .dataviews-filters__summary-chip-container {
42
+ position: relative;
43
+ white-space: pre-wrap;
44
+
45
+ .dataviews-filters__summary-chip {
46
+ border-radius: $grid-unit-20;
47
+ border: 1px solid transparent;
48
+ cursor: pointer;
49
+ padding: $grid-unit-05 $grid-unit-15;
50
+ min-height: $grid-unit-40;
51
+ background: $gray-100;
52
+ color: $gray-800;
53
+ position: relative;
54
+ display: flex;
55
+ align-items: center;
56
+
57
+ &.has-reset {
58
+ padding-inline-end: $button-size-small + $grid-unit-05;
59
+ }
60
+
61
+ &:hover,
62
+ &:focus-visible,
63
+ &[aria-expanded="true"] {
64
+ background: $gray-200;
65
+ color: $gray-900;
66
+ }
67
+
68
+ &.has-values {
69
+ color: var(--wp-admin-theme-color);
70
+ background: rgba(var(--wp-admin-theme-color--rgb), 0.04);
71
+
72
+ &:hover,
73
+ &[aria-expanded="true"] {
74
+ background: rgba(var(--wp-admin-theme-color--rgb), 0.12);
75
+ }
76
+ }
77
+
78
+ &:focus-visible {
79
+ outline: none;
80
+ box-shadow:
81
+ 0 0 0 var(--wp-admin-border-width-focus)
82
+ var(--wp-admin-theme-color);
83
+ }
84
+
85
+ .dataviews-filters-__summary-filter-text-name {
86
+ font-weight: 500;
87
+ }
88
+ }
89
+
90
+ .dataviews-filters__summary-chip-remove {
91
+ width: $icon-size;
92
+ height: $icon-size;
93
+ border-radius: 50%;
94
+ border: 0;
95
+ padding: 0;
96
+ position: absolute;
97
+ right: $grid-unit-05;
98
+ top: 50%;
99
+ transform: translateY(-50%);
100
+ display: flex;
101
+ align-items: center;
102
+ justify-content: center;
103
+ background: transparent;
104
+ cursor: pointer;
105
+
106
+ svg {
107
+ fill: $gray-700;
108
+ }
109
+
110
+ &:hover,
111
+ &:focus {
112
+ background: $gray-200;
113
+ svg {
114
+ fill: $gray-900;
115
+ }
116
+ }
117
+
118
+ &.has-values {
119
+ svg {
120
+ fill: var(--wp-admin-theme-color);
121
+ }
122
+ &:hover {
123
+ background: rgba(var(--wp-admin-theme-color--rgb), 0.08);
124
+ }
125
+ }
126
+
127
+ &:focus-visible {
128
+ outline: none;
129
+ box-shadow:
130
+ 0 0 0 var(--wp-admin-border-width-focus)
131
+ var(--wp-admin-theme-color);
132
+ }
133
+ }
134
+ }
135
+
136
+ .dataviews-filters__search-widget-filter-combobox-list {
137
+ max-height: $grid-unit * 23;
138
+ padding: $grid-unit-05;
139
+ overflow: auto;
140
+ border-top: 1px solid $gray-200;
141
+
142
+ .dataviews-filters__search-widget-filter-combobox-item-value {
143
+ [data-user-value] {
144
+ font-weight: 600;
145
+ }
146
+ }
147
+ }
148
+
149
+ .dataviews-filters__search-widget-listbox {
150
+ max-height: $grid-unit * 23;
151
+ padding: $grid-unit-05;
152
+ overflow: auto;
153
+ }
154
+
155
+ .dataviews-filters__search-widget-listitem {
156
+ display: flex;
157
+ align-items: center;
158
+ gap: $grid-unit-10;
159
+ border-radius: $radius-block-ui;
160
+ box-sizing: border-box;
161
+ padding: $grid-unit-10 $grid-unit-15;
162
+ cursor: default;
163
+ margin-block-end: 2px;
164
+
165
+ &:last-child {
166
+ margin-block-end: 0;
167
+ }
168
+
169
+ &:hover,
170
+ &[data-active-item],
171
+ &:focus {
172
+ background-color: var(--wp-admin-theme-color);
173
+ color: $white;
174
+
175
+ .dataviews-filters__search-widget-listitem-check {
176
+ fill: $white;
177
+ }
178
+
179
+ .dataviews-filters__search-widget-listitem-description {
180
+ color: $white;
181
+ }
182
+ }
183
+
184
+ .dataviews-filters__search-widget-listitem-check {
185
+ width: 24px;
186
+ height: 24px;
187
+ flex-shrink: 0;
188
+ }
189
+
190
+ .dataviews-filters__search-widget-listitem-description {
191
+ display: block;
192
+ overflow: hidden;
193
+ text-overflow: ellipsis;
194
+ font-size: $helptext-font-size;
195
+ line-height: 16px;
196
+ color: $gray-700;
197
+ }
198
+ }
199
+
200
+ .dataviews-filters__search-widget-filter-combobox__wrapper {
201
+ position: relative;
202
+ padding: $grid-unit-10;
203
+
204
+ .dataviews-filters__search-widget-filter-combobox__input {
205
+ @include input-control;
206
+ display: block;
207
+ padding: 0 $grid-unit-40 0 $grid-unit-10;
208
+ background: $gray-100;
209
+ border: none;
210
+ width: 100%;
211
+ height: $grid-unit-40;
212
+
213
+ // Unset inherited values.
214
+ margin-left: 0;
215
+ margin-right: 0;
216
+
217
+ /* Fonts smaller than 16px causes mobile safari to zoom. */
218
+ font-size: $mobile-text-min-font-size;
219
+ @include break-small {
220
+ font-size: $default-font-size;
221
+ }
222
+
223
+ &:focus {
224
+ background: $white;
225
+ box-shadow:
226
+ inset 0 0 0 var(--wp-admin-border-width-focus)
227
+ var(--wp-admin-theme-color);
228
+ }
229
+
230
+ &::placeholder {
231
+ color: $gray-700;
232
+ }
233
+
234
+ &::-webkit-search-decoration,
235
+ &::-webkit-search-cancel-button,
236
+ &::-webkit-search-results-button,
237
+ &::-webkit-search-results-decoration {
238
+ -webkit-appearance: none;
239
+ }
240
+ }
241
+
242
+ .dataviews-filters__search-widget-filter-combobox__icon {
243
+ position: absolute;
244
+ right: $grid-unit-15;
245
+ top: 50%;
246
+ transform: translateY(-50%);
247
+ display: flex;
248
+ align-items: center;
249
+ justify-content: center;
250
+ width: $icon-size;
251
+ }
252
+ }
@@ -20,8 +20,8 @@ import { useRegistry } from '@wordpress/data';
20
20
  /**
21
21
  * Internal dependencies
22
22
  */
23
- import { unlock } from './lock-unlock';
24
- import type { Action, ActionModal as ActionModalType } from './types';
23
+ import { unlock } from '../../lock-unlock';
24
+ import type { Action, ActionModal as ActionModalType } from '../../types';
25
25
 
26
26
  const {
27
27
  DropdownMenuV2: DropdownMenu,
@@ -0,0 +1,3 @@
1
+ .dataviews-action-modal {
2
+ z-index: z-index(".dataviews-action-modal");
3
+ }
@@ -0,0 +1,51 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import type { ComponentType } from 'react';
5
+
6
+ /**
7
+ * WordPress dependencies
8
+ */
9
+ import { useContext } from '@wordpress/element';
10
+
11
+ /**
12
+ * Internal dependencies
13
+ */
14
+ import DataViewsContext from '../dataviews-context';
15
+ import { VIEW_LAYOUTS } from '../../layouts';
16
+ import type { ViewBaseProps } from '../../types';
17
+
18
+ export default function DataViewsLayout() {
19
+ const {
20
+ actions = [],
21
+ data,
22
+ fields,
23
+ getItemId,
24
+ isLoading,
25
+ view,
26
+ onChangeView,
27
+ selection,
28
+ onChangeSelection,
29
+ setOpenedFilter,
30
+ density,
31
+ } = useContext( DataViewsContext );
32
+
33
+ const ViewComponent = VIEW_LAYOUTS.find( ( v ) => v.type === view.type )
34
+ ?.component as ComponentType< ViewBaseProps< any > >;
35
+
36
+ return (
37
+ <ViewComponent
38
+ actions={ actions }
39
+ data={ data }
40
+ fields={ fields }
41
+ getItemId={ getItemId }
42
+ isLoading={ isLoading }
43
+ onChangeView={ onChangeView }
44
+ onChangeSelection={ onChangeSelection }
45
+ selection={ selection }
46
+ setOpenedFilter={ setOpenedFilter }
47
+ view={ view }
48
+ density={ density }
49
+ />
50
+ );
51
+ }
@@ -6,29 +6,21 @@ import {
6
6
  __experimentalHStack as HStack,
7
7
  SelectControl,
8
8
  } from '@wordpress/components';
9
- import { createInterpolateElement, memo } from '@wordpress/element';
9
+ import { createInterpolateElement, memo, useContext } from '@wordpress/element';
10
10
  import { sprintf, __, _x } from '@wordpress/i18n';
11
- import { chevronRight, chevronLeft } from '@wordpress/icons';
11
+ import { next, previous } from '@wordpress/icons';
12
12
 
13
13
  /**
14
14
  * Internal dependencies
15
15
  */
16
- import type { View } from './types';
16
+ import DataViewsContext from '../dataviews-context';
17
17
 
18
- interface PaginationProps {
19
- view: View;
20
- onChangeView: ( view: View ) => void;
21
- paginationInfo: {
22
- totalItems: number;
23
- totalPages: number;
24
- };
25
- }
26
-
27
- const Pagination = memo( function Pagination( {
28
- view,
29
- onChangeView,
30
- paginationInfo: { totalItems = 0, totalPages },
31
- }: PaginationProps ) {
18
+ function DataViewsPagination() {
19
+ const {
20
+ view,
21
+ onChangeView,
22
+ paginationInfo: { totalItems = 0, totalPages },
23
+ } = useContext( DataViewsContext );
32
24
  if ( ! totalItems || ! totalPages ) {
33
25
  return null;
34
26
  }
@@ -92,7 +84,7 @@ const Pagination = memo( function Pagination( {
92
84
  disabled={ currentPage === 1 }
93
85
  accessibleWhenDisabled
94
86
  label={ __( 'Previous page' ) }
95
- icon={ chevronLeft }
87
+ icon={ previous }
96
88
  showTooltip
97
89
  size="compact"
98
90
  tooltipPosition="top"
@@ -104,7 +96,7 @@ const Pagination = memo( function Pagination( {
104
96
  disabled={ currentPage >= totalPages }
105
97
  accessibleWhenDisabled
106
98
  label={ __( 'Next page' ) }
107
- icon={ chevronRight }
99
+ icon={ next }
108
100
  showTooltip
109
101
  size="compact"
110
102
  tooltipPosition="top"
@@ -113,6 +105,6 @@ const Pagination = memo( function Pagination( {
113
105
  </HStack>
114
106
  )
115
107
  );
116
- } );
108
+ }
117
109
 
118
- export default Pagination;
110
+ export default memo( DataViewsPagination );
@@ -0,0 +1,26 @@
1
+ .dataviews-pagination {
2
+ position: sticky;
3
+ bottom: 0;
4
+ left: 0;
5
+ background-color: $white;
6
+ padding: $grid-unit-15 $grid-unit-60;
7
+ border-top: $border-width solid $gray-100;
8
+ color: $gray-700;
9
+ flex-shrink: 0;
10
+ transition: padding ease-out 0.1s;
11
+ @include reduce-motion("transition");
12
+ }
13
+
14
+ .dataviews-pagination__page-selection {
15
+ font-size: 11px;
16
+ text-transform: uppercase;
17
+ font-weight: 500;
18
+ color: $gray-900;
19
+ }
20
+
21
+ /* stylelint-disable-next-line scss/at-rule-no-unknown -- '@container' not globally permitted */
22
+ @container (max-width: 430px) {
23
+ .dataviews-pagination {
24
+ padding: $grid-unit-15 $grid-unit-30;
25
+ }
26
+ }
@@ -2,26 +2,21 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { __ } from '@wordpress/i18n';
5
- import { useEffect, useRef, memo } from '@wordpress/element';
5
+ import { useEffect, useRef, memo, useContext } from '@wordpress/element';
6
6
  import { SearchControl } from '@wordpress/components';
7
7
  import { useDebouncedInput } from '@wordpress/compose';
8
8
 
9
9
  /**
10
10
  * Internal dependencies
11
11
  */
12
- import type { View } from './types';
12
+ import DataViewsContext from '../dataviews-context';
13
13
 
14
14
  interface SearchProps {
15
15
  label?: string;
16
- view: View;
17
- onChangeView: ( view: View ) => void;
18
16
  }
19
17
 
20
- const Search = memo( function Search( {
21
- label,
22
- view,
23
- onChangeView,
24
- }: SearchProps ) {
18
+ const DataViewsSearch = memo( function Search( { label }: SearchProps ) {
19
+ const { view, onChangeView } = useContext( DataViewsContext );
25
20
  const [ search, setSearch, debouncedSearch ] = useDebouncedInput(
26
21
  view.search
27
22
  );
@@ -54,4 +49,4 @@ const Search = memo( function Search( {
54
49
  );
55
50
  } );
56
51
 
57
- export default Search;
52
+ export default DataViewsSearch;
@@ -7,26 +7,26 @@ import { CheckboxControl } from '@wordpress/components';
7
7
  /**
8
8
  * Internal dependencies
9
9
  */
10
- import type { Field } from './types';
11
- import type { SetSelection } from './private-types';
10
+ import type { Field } from '../../types';
11
+ import type { SetSelection } from '../../private-types';
12
12
 
13
- interface SingleSelectionCheckboxProps< Item > {
13
+ interface DataViewsSelectionCheckboxProps< Item > {
14
14
  selection: string[];
15
- onSelectionChange: SetSelection;
15
+ onChangeSelection: SetSelection;
16
16
  item: Item;
17
17
  getItemId: ( item: Item ) => string;
18
18
  primaryField?: Field< Item >;
19
19
  disabled: boolean;
20
20
  }
21
21
 
22
- export default function SingleSelectionCheckbox< Item >( {
22
+ export default function DataViewsSelectionCheckbox< Item >( {
23
23
  selection,
24
- onSelectionChange,
24
+ onChangeSelection,
25
25
  item,
26
26
  getItemId,
27
27
  primaryField,
28
28
  disabled,
29
- }: SingleSelectionCheckboxProps< Item > ) {
29
+ }: DataViewsSelectionCheckboxProps< Item > ) {
30
30
  const id = getItemId( item );
31
31
  const checked = ! disabled && selection.includes( id );
32
32
  let selectionLabel;
@@ -44,7 +44,7 @@ export default function SingleSelectionCheckbox< Item >( {
44
44
  }
45
45
  return (
46
46
  <CheckboxControl
47
- className="dataviews-view-table-selection-checkbox"
47
+ className="dataviews-selection-checkbox"
48
48
  __nextHasNoMarginBottom
49
49
  aria-label={ selectionLabel }
50
50
  aria-disabled={ disabled }
@@ -54,7 +54,7 @@ export default function SingleSelectionCheckbox< Item >( {
54
54
  return;
55
55
  }
56
56
 
57
- onSelectionChange(
57
+ onChangeSelection(
58
58
  selection.includes( id )
59
59
  ? selection.filter( ( itemId ) => id !== itemId )
60
60
  : [ ...selection, id ]
@@ -0,0 +1,14 @@
1
+ .dataviews-selection-checkbox {
2
+ // Experimental override for CheckboxControl size (fragile)
3
+ --checkbox-input-size: 24px;
4
+ @include break-small() {
5
+ --checkbox-input-size: 16px;
6
+ }
7
+
8
+ line-height: 0;
9
+ flex-shrink: 0;
10
+
11
+ .components-checkbox-control__input-container {
12
+ margin: 0;
13
+ }
14
+ }
@@ -12,16 +12,17 @@ import {
12
12
  __experimentalHStack as HStack,
13
13
  } from '@wordpress/components';
14
14
  import { __, _x } from '@wordpress/i18n';
15
- import { memo } from '@wordpress/element';
15
+ import { memo, useContext } from '@wordpress/element';
16
16
  import { cog } from '@wordpress/icons';
17
17
 
18
18
  /**
19
19
  * Internal dependencies
20
20
  */
21
- import { unlock } from './lock-unlock';
22
- import { SORTING_DIRECTIONS, sortLabels } from './constants';
23
- import { VIEW_LAYOUTS } from './layouts';
24
- import type { NormalizedField, View, SupportedLayouts } from './types';
21
+ import { unlock } from '../../lock-unlock';
22
+ import { SORTING_DIRECTIONS, sortLabels } from '../../constants';
23
+ import { VIEW_LAYOUTS, getMandatoryFields } from '../../layouts';
24
+ import type { NormalizedField, View, SupportedLayouts } from '../../types';
25
+ import DataViewsContext from '../dataviews-context';
25
26
 
26
27
  const {
27
28
  DropdownMenuV2: DropdownMenu,
@@ -55,10 +56,7 @@ interface SortMenuProps< Item > {
55
56
  onChangeView: ( view: View ) => void;
56
57
  }
57
58
 
58
- interface ViewActionsProps< Item > {
59
- fields: NormalizedField< Item >[];
60
- view: View;
61
- onChangeView: ( view: View ) => void;
59
+ interface ViewActionsProps {
62
60
  defaultLayouts?: SupportedLayouts;
63
61
  }
64
62
 
@@ -147,10 +145,11 @@ function FieldsVisibilityMenu< Item >( {
147
145
  onChangeView,
148
146
  fields,
149
147
  }: FieldsVisibilityMenuProps< Item > ) {
148
+ const mandatoryFields = getMandatoryFields( view );
150
149
  const hidableFields = fields.filter(
151
150
  ( field ) =>
152
151
  field.enableHiding !== false &&
153
- field.id !== view?.layout?.mediaField
152
+ ! mandatoryFields.includes( field.id )
154
153
  );
155
154
  const viewFields = view.fields || fields.map( ( field ) => field.id );
156
155
  if ( ! hidableFields?.length ) {
@@ -184,7 +183,7 @@ function FieldsVisibilityMenu< Item >( {
184
183
  } }
185
184
  >
186
185
  <DropdownMenuItemLabel>
187
- { field.header }
186
+ { field.label }
188
187
  </DropdownMenuItemLabel>
189
188
  </DropdownMenuCheckboxItem>
190
189
  );
@@ -213,7 +212,7 @@ function SortMenu< Item >( {
213
212
  <DropdownMenuItem
214
213
  suffix={
215
214
  <span aria-hidden="true">
216
- { currentSortedField?.header }
215
+ { currentSortedField?.label }
217
216
  </span>
218
217
  }
219
218
  >
@@ -231,7 +230,7 @@ function SortMenu< Item >( {
231
230
  trigger={
232
231
  <DropdownMenuItem>
233
232
  <DropdownMenuItemLabel>
234
- { field.header }
233
+ { field.label }
235
234
  </DropdownMenuItemLabel>
236
235
  </DropdownMenuItem>
237
236
  }
@@ -281,12 +280,8 @@ function SortMenu< Item >( {
281
280
  );
282
281
  }
283
282
 
284
- function _ViewActions< Item >( {
285
- fields,
286
- view,
287
- onChangeView,
288
- defaultLayouts,
289
- }: ViewActionsProps< Item > ) {
283
+ function _DataViewsViewConfig( { defaultLayouts }: ViewActionsProps ) {
284
+ const { view, fields, onChangeView } = useContext( DataViewsContext );
290
285
  const activeView = VIEW_LAYOUTS.find( ( v ) => view.type === v.type );
291
286
  return (
292
287
  <>
@@ -344,7 +339,6 @@ function _ViewActions< Item >( {
344
339
  );
345
340
  }
346
341
 
347
- // A type assertion is used here to keep the type argument.
348
- const ViewActions = memo( _ViewActions ) as typeof _ViewActions;
342
+ const DataViewsViewConfig = memo( _DataViewsViewConfig );
349
343
 
350
- export default ViewActions;
344
+ export default DataViewsViewConfig;
package/src/index.ts CHANGED
@@ -1,5 +1,5 @@
1
- export { default as DataViews } from './dataviews';
1
+ export { default as DataViews } from './components/dataviews';
2
+ export { default as DataForm } from './components/dataform';
2
3
  export { VIEW_LAYOUTS } from './layouts';
3
4
  export { filterSortAndPaginate } from './filter-and-sort-data-view';
4
5
  export type * from './types';
5
- export { default as DataForm } from './dataform';