@wordpress/dataviews 4.1.0 → 4.3.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 (223) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/README.md +77 -29
  3. package/build/components/dataviews/index.js +10 -14
  4. package/build/components/dataviews/index.js.map +1 -1
  5. package/build/components/dataviews-bulk-actions/index.js +145 -141
  6. package/build/components/dataviews-bulk-actions/index.js.map +1 -1
  7. package/build/components/dataviews-filters/add-filter.js +4 -6
  8. package/build/components/dataviews-filters/add-filter.js.map +1 -1
  9. package/build/components/dataviews-filters/index.js +3 -0
  10. package/build/components/dataviews-filters/index.js.map +1 -1
  11. package/build/components/dataviews-filters/search-widget.js +30 -23
  12. package/build/components/dataviews-filters/search-widget.js.map +1 -1
  13. package/build/components/dataviews-footer/index.js +45 -0
  14. package/build/components/dataviews-footer/index.js.map +1 -0
  15. package/build/components/dataviews-item-actions/index.js +5 -8
  16. package/build/components/dataviews-item-actions/index.js.map +1 -1
  17. package/build/components/dataviews-pagination/index.js +27 -19
  18. package/build/components/dataviews-pagination/index.js.map +1 -1
  19. package/build/components/dataviews-view-config/index.js +197 -41
  20. package/build/components/dataviews-view-config/index.js.map +1 -1
  21. package/build/dataform-controls/datetime.js +49 -0
  22. package/build/dataform-controls/datetime.js.map +1 -0
  23. package/build/dataform-controls/index.js +50 -0
  24. package/build/dataform-controls/index.js.map +1 -0
  25. package/build/dataform-controls/integer.js +45 -0
  26. package/build/dataform-controls/integer.js.map +1 -0
  27. package/build/dataform-controls/radio.js +45 -0
  28. package/build/dataform-controls/radio.js.map +1 -0
  29. package/build/dataform-controls/select.js +58 -0
  30. package/build/dataform-controls/select.js.map +1 -0
  31. package/build/dataform-controls/text.js +45 -0
  32. package/build/dataform-controls/text.js.map +1 -0
  33. package/build/dataforms-layouts/panel/index.js +10 -4
  34. package/build/dataforms-layouts/panel/index.js.map +1 -1
  35. package/build/dataforms-layouts/regular/index.js +6 -3
  36. package/build/dataforms-layouts/regular/index.js.map +1 -1
  37. package/build/dataviews-layouts/grid/density-picker.js +23 -52
  38. package/build/dataviews-layouts/grid/density-picker.js.map +1 -1
  39. package/build/dataviews-layouts/grid/index.js +1 -1
  40. package/build/dataviews-layouts/grid/index.js.map +1 -1
  41. package/build/dataviews-layouts/index.js +48 -2
  42. package/build/dataviews-layouts/index.js.map +1 -1
  43. package/build/dataviews-layouts/list/index.js +124 -80
  44. package/build/dataviews-layouts/list/index.js.map +1 -1
  45. package/build/dataviews-layouts/table/column-header-menu.js +52 -57
  46. package/build/dataviews-layouts/table/column-header-menu.js.map +1 -1
  47. package/build/dataviews-layouts/table/index.js +7 -35
  48. package/build/dataviews-layouts/table/index.js.map +1 -1
  49. package/build/field-types/datetime.js +30 -0
  50. package/build/field-types/datetime.js.map +1 -0
  51. package/build/field-types/index.js +4 -0
  52. package/build/field-types/index.js.map +1 -1
  53. package/build/field-types/integer.js +1 -60
  54. package/build/field-types/integer.js.map +1 -1
  55. package/build/field-types/text.js +1 -60
  56. package/build/field-types/text.js.map +1 -1
  57. package/build/normalize-fields.js +10 -9
  58. package/build/normalize-fields.js.map +1 -1
  59. package/build/types.js.map +1 -1
  60. package/build-module/components/dataviews/index.js +10 -14
  61. package/build-module/components/dataviews/index.js.map +1 -1
  62. package/build-module/components/dataviews-bulk-actions/index.js +145 -143
  63. package/build-module/components/dataviews-bulk-actions/index.js.map +1 -1
  64. package/build-module/components/dataviews-filters/add-filter.js +4 -6
  65. package/build-module/components/dataviews-filters/add-filter.js.map +1 -1
  66. package/build-module/components/dataviews-filters/index.js +3 -0
  67. package/build-module/components/dataviews-filters/index.js.map +1 -1
  68. package/build-module/components/dataviews-filters/search-widget.js +30 -23
  69. package/build-module/components/dataviews-filters/search-widget.js.map +1 -1
  70. package/build-module/components/dataviews-footer/index.js +38 -0
  71. package/build-module/components/dataviews-footer/index.js.map +1 -0
  72. package/build-module/components/dataviews-item-actions/index.js +5 -8
  73. package/build-module/components/dataviews-item-actions/index.js.map +1 -1
  74. package/build-module/components/dataviews-pagination/index.js +28 -20
  75. package/build-module/components/dataviews-pagination/index.js.map +1 -1
  76. package/build-module/components/dataviews-view-config/index.js +203 -47
  77. package/build-module/components/dataviews-view-config/index.js.map +1 -1
  78. package/build-module/dataform-controls/datetime.js +43 -0
  79. package/build-module/dataform-controls/datetime.js.map +1 -0
  80. package/build-module/dataform-controls/index.js +42 -0
  81. package/build-module/dataform-controls/index.js.map +1 -0
  82. package/build-module/dataform-controls/integer.js +38 -0
  83. package/build-module/dataform-controls/integer.js.map +1 -0
  84. package/build-module/dataform-controls/radio.js +38 -0
  85. package/build-module/dataform-controls/radio.js.map +1 -0
  86. package/build-module/dataform-controls/select.js +51 -0
  87. package/build-module/dataform-controls/select.js.map +1 -0
  88. package/build-module/dataform-controls/text.js +38 -0
  89. package/build-module/dataform-controls/text.js.map +1 -0
  90. package/build-module/dataforms-layouts/panel/index.js +10 -4
  91. package/build-module/dataforms-layouts/panel/index.js.map +1 -1
  92. package/build-module/dataforms-layouts/regular/index.js +6 -3
  93. package/build-module/dataforms-layouts/regular/index.js.map +1 -1
  94. package/build-module/dataviews-layouts/grid/density-picker.js +25 -56
  95. package/build-module/dataviews-layouts/grid/density-picker.js.map +1 -1
  96. package/build-module/dataviews-layouts/grid/index.js +1 -1
  97. package/build-module/dataviews-layouts/grid/index.js.map +1 -1
  98. package/build-module/dataviews-layouts/index.js +45 -1
  99. package/build-module/dataviews-layouts/index.js.map +1 -1
  100. package/build-module/dataviews-layouts/list/index.js +125 -80
  101. package/build-module/dataviews-layouts/list/index.js.map +1 -1
  102. package/build-module/dataviews-layouts/table/column-header-menu.js +52 -57
  103. package/build-module/dataviews-layouts/table/column-header-menu.js.map +1 -1
  104. package/build-module/dataviews-layouts/table/index.js +9 -37
  105. package/build-module/dataviews-layouts/table/index.js.map +1 -1
  106. package/build-module/field-types/datetime.js +24 -0
  107. package/build-module/field-types/datetime.js.map +1 -0
  108. package/build-module/field-types/index.js +4 -0
  109. package/build-module/field-types/index.js.map +1 -1
  110. package/build-module/field-types/integer.js +2 -60
  111. package/build-module/field-types/integer.js.map +1 -1
  112. package/build-module/field-types/text.js +2 -60
  113. package/build-module/field-types/text.js.map +1 -1
  114. package/build-module/normalize-fields.js +11 -9
  115. package/build-module/normalize-fields.js.map +1 -1
  116. package/build-module/types.js.map +1 -1
  117. package/build-style/style-rtl.css +93 -80
  118. package/build-style/style.css +93 -80
  119. package/build-types/components/dataform/stories/index.story.d.ts.map +1 -1
  120. package/build-types/components/dataviews/index.d.ts.map +1 -1
  121. package/build-types/components/dataviews/stories/fixtures.d.ts +28 -113
  122. package/build-types/components/dataviews/stories/fixtures.d.ts.map +1 -1
  123. package/build-types/components/dataviews/stories/index.story.d.ts +12 -44
  124. package/build-types/components/dataviews/stories/index.story.d.ts.map +1 -1
  125. package/build-types/components/dataviews-bulk-actions/index.d.ts +11 -1
  126. package/build-types/components/dataviews-bulk-actions/index.d.ts.map +1 -1
  127. package/build-types/components/dataviews-filters/add-filter.d.ts.map +1 -1
  128. package/build-types/components/dataviews-filters/index.d.ts +1 -1
  129. package/build-types/components/dataviews-filters/index.d.ts.map +1 -1
  130. package/build-types/components/dataviews-filters/search-widget.d.ts.map +1 -1
  131. package/build-types/components/dataviews-footer/index.d.ts +2 -0
  132. package/build-types/components/dataviews-footer/index.d.ts.map +1 -0
  133. package/build-types/components/dataviews-item-actions/index.d.ts.map +1 -1
  134. package/build-types/components/dataviews-pagination/index.d.ts.map +1 -1
  135. package/build-types/components/dataviews-view-config/index.d.ts +4 -3
  136. package/build-types/components/dataviews-view-config/index.d.ts.map +1 -1
  137. package/build-types/dataform-controls/datetime.d.ts +6 -0
  138. package/build-types/dataform-controls/datetime.d.ts.map +1 -0
  139. package/build-types/dataform-controls/index.d.ts +11 -0
  140. package/build-types/dataform-controls/index.d.ts.map +1 -0
  141. package/build-types/dataform-controls/integer.d.ts +6 -0
  142. package/build-types/dataform-controls/integer.d.ts.map +1 -0
  143. package/build-types/dataform-controls/radio.d.ts +6 -0
  144. package/build-types/dataform-controls/radio.d.ts.map +1 -0
  145. package/build-types/dataform-controls/select.d.ts +6 -0
  146. package/build-types/dataform-controls/select.d.ts.map +1 -0
  147. package/build-types/dataform-controls/text.d.ts +6 -0
  148. package/build-types/dataform-controls/text.d.ts.map +1 -0
  149. package/build-types/dataforms-layouts/panel/index.d.ts.map +1 -1
  150. package/build-types/dataforms-layouts/regular/index.d.ts.map +1 -1
  151. package/build-types/dataviews-layouts/grid/density-picker.d.ts.map +1 -1
  152. package/build-types/dataviews-layouts/index.d.ts +4 -2
  153. package/build-types/dataviews-layouts/index.d.ts.map +1 -1
  154. package/build-types/dataviews-layouts/list/index.d.ts.map +1 -1
  155. package/build-types/dataviews-layouts/table/column-header-menu.d.ts.map +1 -1
  156. package/build-types/dataviews-layouts/table/index.d.ts.map +1 -1
  157. package/build-types/field-types/datetime.d.ts +13 -0
  158. package/build-types/field-types/datetime.d.ts.map +1 -0
  159. package/build-types/field-types/index.d.ts +1 -1
  160. package/build-types/field-types/index.d.ts.map +1 -1
  161. package/build-types/field-types/integer.d.ts +2 -3
  162. package/build-types/field-types/integer.d.ts.map +1 -1
  163. package/build-types/field-types/text.d.ts +2 -3
  164. package/build-types/field-types/text.d.ts.map +1 -1
  165. package/build-types/normalize-fields.d.ts.map +1 -1
  166. package/build-types/types.d.ts +43 -21
  167. package/build-types/types.d.ts.map +1 -1
  168. package/package.json +12 -12
  169. package/src/components/dataform/stories/index.story.tsx +43 -2
  170. package/src/components/dataviews/index.tsx +14 -18
  171. package/src/components/dataviews/stories/fixtures.tsx +690 -0
  172. package/src/components/dataviews/stories/index.story.tsx +164 -0
  173. package/src/components/dataviews/style.scss +2 -12
  174. package/src/components/dataviews-bulk-actions/index.tsx +264 -213
  175. package/src/components/dataviews-bulk-actions/style.scss +9 -4
  176. package/src/components/dataviews-filters/add-filter.tsx +7 -11
  177. package/src/components/dataviews-filters/index.tsx +3 -0
  178. package/src/components/dataviews-filters/search-widget.tsx +46 -25
  179. package/src/components/dataviews-filters/style.scss +13 -3
  180. package/src/components/dataviews-footer/index.tsx +50 -0
  181. package/src/components/dataviews-footer/style.scss +40 -0
  182. package/src/components/dataviews-item-actions/index.tsx +8 -14
  183. package/src/components/dataviews-pagination/index.tsx +40 -21
  184. package/src/components/dataviews-pagination/style.scss +7 -21
  185. package/src/components/dataviews-view-config/index.tsx +297 -69
  186. package/src/components/dataviews-view-config/style.scss +25 -0
  187. package/src/dataform-controls/datetime.tsx +43 -0
  188. package/src/dataform-controls/index.tsx +61 -0
  189. package/src/dataform-controls/integer.tsx +38 -0
  190. package/src/dataform-controls/radio.tsx +42 -0
  191. package/src/dataform-controls/select.tsx +52 -0
  192. package/src/dataform-controls/style.scss +4 -0
  193. package/src/dataform-controls/text.tsx +40 -0
  194. package/src/dataforms-layouts/panel/index.tsx +8 -2
  195. package/src/dataforms-layouts/regular/index.tsx +6 -2
  196. package/src/dataviews-layouts/grid/density-picker.tsx +33 -67
  197. package/src/dataviews-layouts/grid/index.tsx +1 -1
  198. package/src/dataviews-layouts/grid/style.scss +1 -5
  199. package/src/dataviews-layouts/index.ts +63 -2
  200. package/src/dataviews-layouts/list/index.tsx +199 -123
  201. package/src/dataviews-layouts/list/style.scss +10 -4
  202. package/src/dataviews-layouts/table/column-header-menu.tsx +86 -90
  203. package/src/dataviews-layouts/table/index.tsx +8 -65
  204. package/src/dataviews-layouts/table/style.scss +0 -5
  205. package/src/field-types/datetime.tsx +28 -0
  206. package/src/field-types/index.tsx +5 -0
  207. package/src/field-types/integer.tsx +2 -71
  208. package/src/field-types/text.tsx +2 -70
  209. package/src/normalize-fields.ts +10 -10
  210. package/src/style.scss +2 -1
  211. package/src/test/filter-and-sort-data-view.js +28 -0
  212. package/src/types.ts +56 -32
  213. package/tsconfig.tsbuildinfo +1 -1
  214. package/build/components/dataviews-bulk-actions-toolbar/index.js +0 -207
  215. package/build/components/dataviews-bulk-actions-toolbar/index.js.map +0 -1
  216. package/build-module/components/dataviews-bulk-actions-toolbar/index.js +0 -201
  217. package/build-module/components/dataviews-bulk-actions-toolbar/index.js.map +0 -1
  218. package/build-types/components/dataviews-bulk-actions-toolbar/index.d.ts +0 -2
  219. package/build-types/components/dataviews-bulk-actions-toolbar/index.d.ts.map +0 -1
  220. package/src/components/dataviews/stories/fixtures.js +0 -222
  221. package/src/components/dataviews/stories/index.story.js +0 -65
  222. package/src/components/dataviews-bulk-actions-toolbar/index.tsx +0 -288
  223. package/src/components/dataviews-bulk-actions-toolbar/style.scss +0 -45
@@ -1,14 +1,7 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { __experimentalNumberControl as NumberControl, SelectControl } from '@wordpress/components';
5
- import { useCallback } from '@wordpress/element';
6
- import { __ } from '@wordpress/i18n';
7
-
8
1
  /**
9
2
  * Internal dependencies
10
3
  */
11
- import { jsx as _jsx } from "react/jsx-runtime";
4
+
12
5
  function sort(a, b, direction) {
13
6
  return direction === 'asc' ? a - b : b - a;
14
7
  }
@@ -28,60 +21,9 @@ function isValid(value, context) {
28
21
  }
29
22
  return true;
30
23
  }
31
- function Edit({
32
- data,
33
- field,
34
- onChange,
35
- hideLabelFromVision
36
- }) {
37
- var _field$getValue;
38
- const {
39
- id,
40
- label,
41
- description
42
- } = field;
43
- const value = (_field$getValue = field.getValue({
44
- item: data
45
- })) !== null && _field$getValue !== void 0 ? _field$getValue : '';
46
- const onChangeControl = useCallback(newValue => onChange(prevItem => ({
47
- ...prevItem,
48
- [id]: newValue
49
- })), [id, onChange]);
50
- if (field.elements) {
51
- const elements = [
52
- /*
53
- * Value can be undefined when:
54
- *
55
- * - the field is not required
56
- * - in bulk editing
57
- *
58
- */
59
- {
60
- label: __('Select item'),
61
- value: ''
62
- }, ...field.elements];
63
- return /*#__PURE__*/_jsx(SelectControl, {
64
- label: label,
65
- value: value,
66
- options: elements,
67
- onChange: onChangeControl,
68
- __next40pxDefaultSize: true,
69
- __nextHasNoMarginBottom: true,
70
- hideLabelFromVision: hideLabelFromVision
71
- });
72
- }
73
- return /*#__PURE__*/_jsx(NumberControl, {
74
- label: label,
75
- help: description,
76
- value: value,
77
- onChange: onChangeControl,
78
- __next40pxDefaultSize: true,
79
- hideLabelFromVision: hideLabelFromVision
80
- });
81
- }
82
24
  export default {
83
25
  sort,
84
26
  isValid,
85
- Edit
27
+ Edit: 'integer'
86
28
  };
87
29
  //# sourceMappingURL=integer.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["__experimentalNumberControl","NumberControl","SelectControl","useCallback","__","jsx","_jsx","sort","a","b","direction","isValid","value","context","Number","isInteger","elements","validValues","map","f","includes","Edit","data","field","onChange","hideLabelFromVision","_field$getValue","id","label","description","getValue","item","onChangeControl","newValue","prevItem","options","__next40pxDefaultSize","__nextHasNoMarginBottom","help"],"sources":["@wordpress/dataviews/src/field-types/integer.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalNumberControl as NumberControl,\n\tSelectControl,\n} from '@wordpress/components';\nimport { useCallback } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport type {\n\tSortDirection,\n\tValidationContext,\n\tDataFormControlProps,\n} from '../types';\n\nfunction sort( a: any, b: any, direction: SortDirection ) {\n\treturn direction === 'asc' ? a - b : b - a;\n}\n\nfunction isValid( value: any, context?: ValidationContext ) {\n\t// TODO: this implicitely means the value is required.\n\tif ( value === '' ) {\n\t\treturn false;\n\t}\n\n\tif ( ! Number.isInteger( Number( value ) ) ) {\n\t\treturn false;\n\t}\n\n\tif ( context?.elements ) {\n\t\tconst validValues = context?.elements.map( ( f ) => f.value );\n\t\tif ( ! validValues.includes( Number( value ) ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\treturn true;\n}\n\nfunction Edit< Item >( {\n\tdata,\n\tfield,\n\tonChange,\n\thideLabelFromVision,\n}: DataFormControlProps< Item > ) {\n\tconst { id, label, description } = field;\n\tconst value = field.getValue( { item: data } ) ?? '';\n\tconst onChangeControl = useCallback(\n\t\t( newValue: string | undefined ) =>\n\t\t\tonChange( ( prevItem: Item ) => ( {\n\t\t\t\t...prevItem,\n\t\t\t\t[ id ]: newValue,\n\t\t\t} ) ),\n\t\t[ id, onChange ]\n\t);\n\n\tif ( field.elements ) {\n\t\tconst elements = [\n\t\t\t/*\n\t\t\t * Value can be undefined when:\n\t\t\t *\n\t\t\t * - the field is not required\n\t\t\t * - in bulk editing\n\t\t\t *\n\t\t\t */\n\t\t\t{ label: __( 'Select item' ), value: '' },\n\t\t\t...field.elements,\n\t\t];\n\n\t\treturn (\n\t\t\t<SelectControl\n\t\t\t\tlabel={ label }\n\t\t\t\tvalue={ value }\n\t\t\t\toptions={ elements }\n\t\t\t\tonChange={ onChangeControl }\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\thideLabelFromVision={ hideLabelFromVision }\n\t\t\t/>\n\t\t);\n\t}\n\n\treturn (\n\t\t<NumberControl\n\t\t\tlabel={ label }\n\t\t\thelp={ description }\n\t\t\tvalue={ value }\n\t\t\tonChange={ onChangeControl }\n\t\t\t__next40pxDefaultSize\n\t\t\thideLabelFromVision={ hideLabelFromVision }\n\t\t/>\n\t);\n}\n\nexport default {\n\tsort,\n\tisValid,\n\tEdit,\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,2BAA2B,IAAIC,aAAa,EAC5CC,aAAa,QACP,uBAAuB;AAC9B,SAASC,WAAW,QAAQ,oBAAoB;AAChD,SAASC,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;AAFA,SAAAC,GAAA,IAAAC,IAAA;AASA,SAASC,IAAIA,CAAEC,CAAM,EAAEC,CAAM,EAAEC,SAAwB,EAAG;EACzD,OAAOA,SAAS,KAAK,KAAK,GAAGF,CAAC,GAAGC,CAAC,GAAGA,CAAC,GAAGD,CAAC;AAC3C;AAEA,SAASG,OAAOA,CAAEC,KAAU,EAAEC,OAA2B,EAAG;EAC3D;EACA,IAAKD,KAAK,KAAK,EAAE,EAAG;IACnB,OAAO,KAAK;EACb;EAEA,IAAK,CAAEE,MAAM,CAACC,SAAS,CAAED,MAAM,CAAEF,KAAM,CAAE,CAAC,EAAG;IAC5C,OAAO,KAAK;EACb;EAEA,IAAKC,OAAO,EAAEG,QAAQ,EAAG;IACxB,MAAMC,WAAW,GAAGJ,OAAO,EAAEG,QAAQ,CAACE,GAAG,CAAIC,CAAC,IAAMA,CAAC,CAACP,KAAM,CAAC;IAC7D,IAAK,CAAEK,WAAW,CAACG,QAAQ,CAAEN,MAAM,CAAEF,KAAM,CAAE,CAAC,EAAG;MAChD,OAAO,KAAK;IACb;EACD;EAEA,OAAO,IAAI;AACZ;AAEA,SAASS,IAAIA,CAAU;EACtBC,IAAI;EACJC,KAAK;EACLC,QAAQ;EACRC;AAC6B,CAAC,EAAG;EAAA,IAAAC,eAAA;EACjC,MAAM;IAAEC,EAAE;IAAEC,KAAK;IAAEC;EAAY,CAAC,GAAGN,KAAK;EACxC,MAAMX,KAAK,IAAAc,eAAA,GAAGH,KAAK,CAACO,QAAQ,CAAE;IAAEC,IAAI,EAAET;EAAK,CAAE,CAAC,cAAAI,eAAA,cAAAA,eAAA,GAAI,EAAE;EACpD,MAAMM,eAAe,GAAG7B,WAAW,CAChC8B,QAA4B,IAC7BT,QAAQ,CAAIU,QAAc,KAAQ;IACjC,GAAGA,QAAQ;IACX,CAAEP,EAAE,GAAIM;EACT,CAAC,CAAG,CAAC,EACN,CAAEN,EAAE,EAAEH,QAAQ,CACf,CAAC;EAED,IAAKD,KAAK,CAACP,QAAQ,EAAG;IACrB,MAAMA,QAAQ,GAAG;IAChB;AACH;AACA;AACA;AACA;AACA;AACA;IACG;MAAEY,KAAK,EAAExB,EAAE,CAAE,aAAc,CAAC;MAAEQ,KAAK,EAAE;IAAG,CAAC,EACzC,GAAGW,KAAK,CAACP,QAAQ,CACjB;IAED,oBACCV,IAAA,CAACJ,aAAa;MACb0B,KAAK,EAAGA,KAAO;MACfhB,KAAK,EAAGA,KAAO;MACfuB,OAAO,EAAGnB,QAAU;MACpBQ,QAAQ,EAAGQ,eAAiB;MAC5BI,qBAAqB;MACrBC,uBAAuB;MACvBZ,mBAAmB,EAAGA;IAAqB,CAC3C,CAAC;EAEJ;EAEA,oBACCnB,IAAA,CAACL,aAAa;IACb2B,KAAK,EAAGA,KAAO;IACfU,IAAI,EAAGT,WAAa;IACpBjB,KAAK,EAAGA,KAAO;IACfY,QAAQ,EAAGQ,eAAiB;IAC5BI,qBAAqB;IACrBX,mBAAmB,EAAGA;EAAqB,CAC3C,CAAC;AAEJ;AAEA,eAAe;EACdlB,IAAI;EACJI,OAAO;EACPU;AACD,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["sort","a","b","direction","isValid","value","context","Number","isInteger","elements","validValues","map","f","includes","Edit"],"sources":["@wordpress/dataviews/src/field-types/integer.tsx"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport type { SortDirection, ValidationContext } from '../types';\n\nfunction sort( a: any, b: any, direction: SortDirection ) {\n\treturn direction === 'asc' ? a - b : b - a;\n}\n\nfunction isValid( value: any, context?: ValidationContext ) {\n\t// TODO: this implicitely means the value is required.\n\tif ( value === '' ) {\n\t\treturn false;\n\t}\n\n\tif ( ! Number.isInteger( Number( value ) ) ) {\n\t\treturn false;\n\t}\n\n\tif ( context?.elements ) {\n\t\tconst validValues = context?.elements.map( ( f ) => f.value );\n\t\tif ( ! validValues.includes( Number( value ) ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\treturn true;\n}\n\nexport default {\n\tsort,\n\tisValid,\n\tEdit: 'integer',\n};\n"],"mappings":"AAAA;AACA;AACA;;AAGA,SAASA,IAAIA,CAAEC,CAAM,EAAEC,CAAM,EAAEC,SAAwB,EAAG;EACzD,OAAOA,SAAS,KAAK,KAAK,GAAGF,CAAC,GAAGC,CAAC,GAAGA,CAAC,GAAGD,CAAC;AAC3C;AAEA,SAASG,OAAOA,CAAEC,KAAU,EAAEC,OAA2B,EAAG;EAC3D;EACA,IAAKD,KAAK,KAAK,EAAE,EAAG;IACnB,OAAO,KAAK;EACb;EAEA,IAAK,CAAEE,MAAM,CAACC,SAAS,CAAED,MAAM,CAAEF,KAAM,CAAE,CAAC,EAAG;IAC5C,OAAO,KAAK;EACb;EAEA,IAAKC,OAAO,EAAEG,QAAQ,EAAG;IACxB,MAAMC,WAAW,GAAGJ,OAAO,EAAEG,QAAQ,CAACE,GAAG,CAAIC,CAAC,IAAMA,CAAC,CAACP,KAAM,CAAC;IAC7D,IAAK,CAAEK,WAAW,CAACG,QAAQ,CAAEN,MAAM,CAAEF,KAAM,CAAE,CAAC,EAAG;MAChD,OAAO,KAAK;IACb;EACD;EAEA,OAAO,IAAI;AACZ;AAEA,eAAe;EACdL,IAAI;EACJI,OAAO;EACPU,IAAI,EAAE;AACP,CAAC","ignoreList":[]}
@@ -1,14 +1,7 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { SelectControl, TextControl } from '@wordpress/components';
5
- import { useCallback } from '@wordpress/element';
6
- import { __ } from '@wordpress/i18n';
7
-
8
1
  /**
9
2
  * Internal dependencies
10
3
  */
11
- import { jsx as _jsx } from "react/jsx-runtime";
4
+
12
5
  function sort(valueA, valueB, direction) {
13
6
  return direction === 'asc' ? valueA.localeCompare(valueB) : valueB.localeCompare(valueA);
14
7
  }
@@ -21,60 +14,9 @@ function isValid(value, context) {
21
14
  }
22
15
  return true;
23
16
  }
24
- function Edit({
25
- data,
26
- field,
27
- onChange,
28
- hideLabelFromVision
29
- }) {
30
- const {
31
- id,
32
- label,
33
- placeholder
34
- } = field;
35
- const value = field.getValue({
36
- item: data
37
- });
38
- const onChangeControl = useCallback(newValue => onChange(prevItem => ({
39
- ...prevItem,
40
- [id]: newValue
41
- })), [id, onChange]);
42
- if (field.elements) {
43
- const elements = [
44
- /*
45
- * Value can be undefined when:
46
- *
47
- * - the field is not required
48
- * - in bulk editing
49
- *
50
- */
51
- {
52
- label: __('Select item'),
53
- value: ''
54
- }, ...field.elements];
55
- return /*#__PURE__*/_jsx(SelectControl, {
56
- label: label,
57
- value: value,
58
- options: elements,
59
- onChange: onChangeControl,
60
- __next40pxDefaultSize: true,
61
- __nextHasNoMarginBottom: true,
62
- hideLabelFromVision: hideLabelFromVision
63
- });
64
- }
65
- return /*#__PURE__*/_jsx(TextControl, {
66
- label: label,
67
- placeholder: placeholder,
68
- value: value !== null && value !== void 0 ? value : '',
69
- onChange: onChangeControl,
70
- __next40pxDefaultSize: true,
71
- __nextHasNoMarginBottom: true,
72
- hideLabelFromVision: hideLabelFromVision
73
- });
74
- }
75
17
  export default {
76
18
  sort,
77
19
  isValid,
78
- Edit
20
+ Edit: 'text'
79
21
  };
80
22
  //# sourceMappingURL=text.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["SelectControl","TextControl","useCallback","__","jsx","_jsx","sort","valueA","valueB","direction","localeCompare","isValid","value","context","elements","validValues","map","f","includes","Edit","data","field","onChange","hideLabelFromVision","id","label","placeholder","getValue","item","onChangeControl","newValue","prevItem","options","__next40pxDefaultSize","__nextHasNoMarginBottom"],"sources":["@wordpress/dataviews/src/field-types/text.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { SelectControl, TextControl } from '@wordpress/components';\nimport { useCallback } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport type {\n\tSortDirection,\n\tValidationContext,\n\tDataFormControlProps,\n} from '../types';\n\nfunction sort( valueA: any, valueB: any, direction: SortDirection ) {\n\treturn direction === 'asc'\n\t\t? valueA.localeCompare( valueB )\n\t\t: valueB.localeCompare( valueA );\n}\n\nfunction isValid( value: any, context?: ValidationContext ) {\n\tif ( context?.elements ) {\n\t\tconst validValues = context?.elements?.map( ( f ) => f.value );\n\t\tif ( ! validValues.includes( value ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\treturn true;\n}\n\nfunction Edit< Item >( {\n\tdata,\n\tfield,\n\tonChange,\n\thideLabelFromVision,\n}: DataFormControlProps< Item > ) {\n\tconst { id, label, placeholder } = field;\n\tconst value = field.getValue( { item: data } );\n\n\tconst onChangeControl = useCallback(\n\t\t( newValue: string ) =>\n\t\t\tonChange( ( prevItem: Item ) => ( {\n\t\t\t\t...prevItem,\n\t\t\t\t[ id ]: newValue,\n\t\t\t} ) ),\n\t\t[ id, onChange ]\n\t);\n\n\tif ( field.elements ) {\n\t\tconst elements = [\n\t\t\t/*\n\t\t\t * Value can be undefined when:\n\t\t\t *\n\t\t\t * - the field is not required\n\t\t\t * - in bulk editing\n\t\t\t *\n\t\t\t */\n\t\t\t{ label: __( 'Select item' ), value: '' },\n\t\t\t...field.elements,\n\t\t];\n\n\t\treturn (\n\t\t\t<SelectControl\n\t\t\t\tlabel={ label }\n\t\t\t\tvalue={ value }\n\t\t\t\toptions={ elements }\n\t\t\t\tonChange={ onChangeControl }\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\thideLabelFromVision={ hideLabelFromVision }\n\t\t\t/>\n\t\t);\n\t}\n\n\treturn (\n\t\t<TextControl\n\t\t\tlabel={ label }\n\t\t\tplaceholder={ placeholder }\n\t\t\tvalue={ value ?? '' }\n\t\t\tonChange={ onChangeControl }\n\t\t\t__next40pxDefaultSize\n\t\t\t__nextHasNoMarginBottom\n\t\t\thideLabelFromVision={ hideLabelFromVision }\n\t\t/>\n\t);\n}\n\nexport default {\n\tsort,\n\tisValid,\n\tEdit,\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,aAAa,EAAEC,WAAW,QAAQ,uBAAuB;AAClE,SAASC,WAAW,QAAQ,oBAAoB;AAChD,SAASC,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;AAFA,SAAAC,GAAA,IAAAC,IAAA;AASA,SAASC,IAAIA,CAAEC,MAAW,EAAEC,MAAW,EAAEC,SAAwB,EAAG;EACnE,OAAOA,SAAS,KAAK,KAAK,GACvBF,MAAM,CAACG,aAAa,CAAEF,MAAO,CAAC,GAC9BA,MAAM,CAACE,aAAa,CAAEH,MAAO,CAAC;AAClC;AAEA,SAASI,OAAOA,CAAEC,KAAU,EAAEC,OAA2B,EAAG;EAC3D,IAAKA,OAAO,EAAEC,QAAQ,EAAG;IACxB,MAAMC,WAAW,GAAGF,OAAO,EAAEC,QAAQ,EAAEE,GAAG,CAAIC,CAAC,IAAMA,CAAC,CAACL,KAAM,CAAC;IAC9D,IAAK,CAAEG,WAAW,CAACG,QAAQ,CAAEN,KAAM,CAAC,EAAG;MACtC,OAAO,KAAK;IACb;EACD;EAEA,OAAO,IAAI;AACZ;AAEA,SAASO,IAAIA,CAAU;EACtBC,IAAI;EACJC,KAAK;EACLC,QAAQ;EACRC;AAC6B,CAAC,EAAG;EACjC,MAAM;IAAEC,EAAE;IAAEC,KAAK;IAAEC;EAAY,CAAC,GAAGL,KAAK;EACxC,MAAMT,KAAK,GAAGS,KAAK,CAACM,QAAQ,CAAE;IAAEC,IAAI,EAAER;EAAK,CAAE,CAAC;EAE9C,MAAMS,eAAe,GAAG3B,WAAW,CAChC4B,QAAgB,IACjBR,QAAQ,CAAIS,QAAc,KAAQ;IACjC,GAAGA,QAAQ;IACX,CAAEP,EAAE,GAAIM;EACT,CAAC,CAAG,CAAC,EACN,CAAEN,EAAE,EAAEF,QAAQ,CACf,CAAC;EAED,IAAKD,KAAK,CAACP,QAAQ,EAAG;IACrB,MAAMA,QAAQ,GAAG;IAChB;AACH;AACA;AACA;AACA;AACA;AACA;IACG;MAAEW,KAAK,EAAEtB,EAAE,CAAE,aAAc,CAAC;MAAES,KAAK,EAAE;IAAG,CAAC,EACzC,GAAGS,KAAK,CAACP,QAAQ,CACjB;IAED,oBACCT,IAAA,CAACL,aAAa;MACbyB,KAAK,EAAGA,KAAO;MACfb,KAAK,EAAGA,KAAO;MACfoB,OAAO,EAAGlB,QAAU;MACpBQ,QAAQ,EAAGO,eAAiB;MAC5BI,qBAAqB;MACrBC,uBAAuB;MACvBX,mBAAmB,EAAGA;IAAqB,CAC3C,CAAC;EAEJ;EAEA,oBACClB,IAAA,CAACJ,WAAW;IACXwB,KAAK,EAAGA,KAAO;IACfC,WAAW,EAAGA,WAAa;IAC3Bd,KAAK,EAAGA,KAAK,aAALA,KAAK,cAALA,KAAK,GAAI,EAAI;IACrBU,QAAQ,EAAGO,eAAiB;IAC5BI,qBAAqB;IACrBC,uBAAuB;IACvBX,mBAAmB,EAAGA;EAAqB,CAC3C,CAAC;AAEJ;AAEA,eAAe;EACdjB,IAAI;EACJK,OAAO;EACPQ;AACD,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["sort","valueA","valueB","direction","localeCompare","isValid","value","context","elements","validValues","map","f","includes","Edit"],"sources":["@wordpress/dataviews/src/field-types/text.tsx"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport type { SortDirection, ValidationContext } from '../types';\n\nfunction sort( valueA: any, valueB: any, direction: SortDirection ) {\n\treturn direction === 'asc'\n\t\t? valueA.localeCompare( valueB )\n\t\t: valueB.localeCompare( valueA );\n}\n\nfunction isValid( value: any, context?: ValidationContext ) {\n\tif ( context?.elements ) {\n\t\tconst validValues = context?.elements?.map( ( f ) => f.value );\n\t\tif ( ! validValues.includes( value ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\treturn true;\n}\n\nexport default {\n\tsort,\n\tisValid,\n\tEdit: 'text',\n};\n"],"mappings":"AAAA;AACA;AACA;;AAGA,SAASA,IAAIA,CAAEC,MAAW,EAAEC,MAAW,EAAEC,SAAwB,EAAG;EACnE,OAAOA,SAAS,KAAK,KAAK,GACvBF,MAAM,CAACG,aAAa,CAAEF,MAAO,CAAC,GAC9BA,MAAM,CAACE,aAAa,CAAEH,MAAO,CAAC;AAClC;AAEA,SAASI,OAAOA,CAAEC,KAAU,EAAEC,OAA2B,EAAG;EAC3D,IAAKA,OAAO,EAAEC,QAAQ,EAAG;IACxB,MAAMC,WAAW,GAAGF,OAAO,EAAEC,QAAQ,EAAEE,GAAG,CAAIC,CAAC,IAAMA,CAAC,CAACL,KAAM,CAAC;IAC9D,IAAK,CAAEG,WAAW,CAACG,QAAQ,CAAEN,KAAM,CAAC,EAAG;MACtC,OAAO,KAAK;IACb;EACD;EAEA,OAAO,IAAI;AACZ;AAEA,eAAe;EACdN,IAAI;EACJK,OAAO;EACPQ,IAAI,EAAE;AACP,CAAC","ignoreList":[]}
@@ -2,6 +2,8 @@
2
2
  * Internal dependencies
3
3
  */
4
4
  import getFieldTypeDefinition from './field-types';
5
+ import { getControl } from './dataform-controls';
6
+
5
7
  /**
6
8
  * Apply default values and normalize the fields config.
7
9
  *
@@ -10,7 +12,7 @@ import getFieldTypeDefinition from './field-types';
10
12
  */
11
13
  export function normalizeFields(fields) {
12
14
  return fields.map(field => {
13
- var _field$sort, _field$isValid;
15
+ var _field$sort, _field$isValid, _field$enableHiding, _field$enableSorting;
14
16
  const fieldTypeDefinition = getFieldTypeDefinition(field.type);
15
17
  const getValue = field.getValue || (({
16
18
  item
@@ -27,29 +29,29 @@ export function normalizeFields(fields) {
27
29
  item
28
30
  }), context);
29
31
  };
30
- const Edit = field.Edit || fieldTypeDefinition.Edit;
32
+ const Edit = getControl(field, fieldTypeDefinition);
31
33
  const renderFromElements = ({
32
34
  item
33
35
  }) => {
34
36
  const value = getValue({
35
37
  item
36
38
  });
37
- const label = field?.elements?.find(element => {
38
- // Intentionally using == here to allow for type coercion.
39
- // eslint-disable-next-line eqeqeq
40
- return element.value == value;
41
- })?.label;
42
- return label || value;
39
+ return field?.elements?.find(element => element.value === value)?.label || getValue({
40
+ item
41
+ });
43
42
  };
44
43
  const render = field.render || (field.elements ? renderFromElements : getValue);
45
44
  return {
46
45
  ...field,
47
46
  label: field.label || field.id,
47
+ header: field.header || field.label || field.id,
48
48
  getValue,
49
49
  render,
50
50
  sort,
51
51
  isValid,
52
- Edit
52
+ Edit,
53
+ enableHiding: (_field$enableHiding = field.enableHiding) !== null && _field$enableHiding !== void 0 ? _field$enableHiding : true,
54
+ enableSorting: (_field$enableSorting = field.enableSorting) !== null && _field$enableSorting !== void 0 ? _field$enableSorting : true
53
55
  };
54
56
  });
55
57
  }
@@ -1 +1 @@
1
- {"version":3,"names":["getFieldTypeDefinition","normalizeFields","fields","map","field","_field$sort","_field$isValid","fieldTypeDefinition","type","getValue","item","id","sort","a","b","direction","isValid","context","Edit","renderFromElements","value","label","elements","find","element","render"],"sources":["@wordpress/dataviews/src/normalize-fields.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport getFieldTypeDefinition from './field-types';\nimport type { Field, NormalizedField } from './types';\n\n/**\n * Apply default values and normalize the fields config.\n *\n * @param fields Fields config.\n * @return Normalized fields config.\n */\nexport function normalizeFields< Item >(\n\tfields: Field< Item >[]\n): NormalizedField< Item >[] {\n\treturn fields.map( ( field ) => {\n\t\tconst fieldTypeDefinition = getFieldTypeDefinition( field.type );\n\n\t\tconst getValue =\n\t\t\tfield.getValue ||\n\t\t\t( ( { item }: { item: Item } ) => item[ field.id as keyof Item ] );\n\n\t\tconst sort =\n\t\t\tfield.sort ??\n\t\t\tfunction sort( a, b, direction ) {\n\t\t\t\treturn fieldTypeDefinition.sort(\n\t\t\t\t\tgetValue( { item: a } ),\n\t\t\t\t\tgetValue( { item: b } ),\n\t\t\t\t\tdirection\n\t\t\t\t);\n\t\t\t};\n\n\t\tconst isValid =\n\t\t\tfield.isValid ??\n\t\t\tfunction isValid( item, context ) {\n\t\t\t\treturn fieldTypeDefinition.isValid(\n\t\t\t\t\tgetValue( { item } ),\n\t\t\t\t\tcontext\n\t\t\t\t);\n\t\t\t};\n\n\t\tconst Edit = field.Edit || fieldTypeDefinition.Edit;\n\n\t\tconst renderFromElements = ( { item }: { item: Item } ) => {\n\t\t\tconst value = getValue( { item } );\n\t\t\tconst label = field?.elements?.find( ( element ) => {\n\t\t\t\t// Intentionally using == here to allow for type coercion.\n\t\t\t\t// eslint-disable-next-line eqeqeq\n\t\t\t\treturn element.value == value;\n\t\t\t} )?.label;\n\n\t\t\treturn label || value;\n\t\t};\n\n\t\tconst render =\n\t\t\tfield.render || ( field.elements ? renderFromElements : getValue );\n\n\t\treturn {\n\t\t\t...field,\n\t\t\tlabel: field.label || field.id,\n\t\t\tgetValue,\n\t\t\trender,\n\t\t\tsort,\n\t\t\tisValid,\n\t\t\tEdit,\n\t\t};\n\t} );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,sBAAsB,MAAM,eAAe;AAGlD;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,eAAeA,CAC9BC,MAAuB,EACK;EAC5B,OAAOA,MAAM,CAACC,GAAG,CAAIC,KAAK,IAAM;IAAA,IAAAC,WAAA,EAAAC,cAAA;IAC/B,MAAMC,mBAAmB,GAAGP,sBAAsB,CAAEI,KAAK,CAACI,IAAK,CAAC;IAEhE,MAAMC,QAAQ,GACbL,KAAK,CAACK,QAAQ,KACZ,CAAE;MAAEC;IAAqB,CAAC,KAAMA,IAAI,CAAEN,KAAK,CAACO,EAAE,CAAgB,CAAE;IAEnE,MAAMC,IAAI,IAAAP,WAAA,GACTD,KAAK,CAACQ,IAAI,cAAAP,WAAA,cAAAA,WAAA,GACV,SAASO,IAAIA,CAAEC,CAAC,EAAEC,CAAC,EAAEC,SAAS,EAAG;MAChC,OAAOR,mBAAmB,CAACK,IAAI,CAC9BH,QAAQ,CAAE;QAAEC,IAAI,EAAEG;MAAE,CAAE,CAAC,EACvBJ,QAAQ,CAAE;QAAEC,IAAI,EAAEI;MAAE,CAAE,CAAC,EACvBC,SACD,CAAC;IACF,CAAC;IAEF,MAAMC,OAAO,IAAAV,cAAA,GACZF,KAAK,CAACY,OAAO,cAAAV,cAAA,cAAAA,cAAA,GACb,SAASU,OAAOA,CAAEN,IAAI,EAAEO,OAAO,EAAG;MACjC,OAAOV,mBAAmB,CAACS,OAAO,CACjCP,QAAQ,CAAE;QAAEC;MAAK,CAAE,CAAC,EACpBO,OACD,CAAC;IACF,CAAC;IAEF,MAAMC,IAAI,GAAGd,KAAK,CAACc,IAAI,IAAIX,mBAAmB,CAACW,IAAI;IAEnD,MAAMC,kBAAkB,GAAGA,CAAE;MAAET;IAAqB,CAAC,KAAM;MAC1D,MAAMU,KAAK,GAAGX,QAAQ,CAAE;QAAEC;MAAK,CAAE,CAAC;MAClC,MAAMW,KAAK,GAAGjB,KAAK,EAAEkB,QAAQ,EAAEC,IAAI,CAAIC,OAAO,IAAM;QACnD;QACA;QACA,OAAOA,OAAO,CAACJ,KAAK,IAAIA,KAAK;MAC9B,CAAE,CAAC,EAAEC,KAAK;MAEV,OAAOA,KAAK,IAAID,KAAK;IACtB,CAAC;IAED,MAAMK,MAAM,GACXrB,KAAK,CAACqB,MAAM,KAAMrB,KAAK,CAACkB,QAAQ,GAAGH,kBAAkB,GAAGV,QAAQ,CAAE;IAEnE,OAAO;MACN,GAAGL,KAAK;MACRiB,KAAK,EAAEjB,KAAK,CAACiB,KAAK,IAAIjB,KAAK,CAACO,EAAE;MAC9BF,QAAQ;MACRgB,MAAM;MACNb,IAAI;MACJI,OAAO;MACPE;IACD,CAAC;EACF,CAAE,CAAC;AACJ","ignoreList":[]}
1
+ {"version":3,"names":["getFieldTypeDefinition","getControl","normalizeFields","fields","map","field","_field$sort","_field$isValid","_field$enableHiding","_field$enableSorting","fieldTypeDefinition","type","getValue","item","id","sort","a","b","direction","isValid","context","Edit","renderFromElements","value","elements","find","element","label","render","header","enableHiding","enableSorting"],"sources":["@wordpress/dataviews/src/normalize-fields.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport getFieldTypeDefinition from './field-types';\nimport type { Field, NormalizedField } from './types';\nimport { getControl } from './dataform-controls';\n\n/**\n * Apply default values and normalize the fields config.\n *\n * @param fields Fields config.\n * @return Normalized fields config.\n */\nexport function normalizeFields< Item >(\n\tfields: Field< Item >[]\n): NormalizedField< Item >[] {\n\treturn fields.map( ( field ) => {\n\t\tconst fieldTypeDefinition = getFieldTypeDefinition( field.type );\n\n\t\tconst getValue =\n\t\t\tfield.getValue || ( ( { item } ) => ( item as any )[ field.id ] );\n\n\t\tconst sort =\n\t\t\tfield.sort ??\n\t\t\tfunction sort( a, b, direction ) {\n\t\t\t\treturn fieldTypeDefinition.sort(\n\t\t\t\t\tgetValue( { item: a } ),\n\t\t\t\t\tgetValue( { item: b } ),\n\t\t\t\t\tdirection\n\t\t\t\t);\n\t\t\t};\n\n\t\tconst isValid =\n\t\t\tfield.isValid ??\n\t\t\tfunction isValid( item, context ) {\n\t\t\t\treturn fieldTypeDefinition.isValid(\n\t\t\t\t\tgetValue( { item } ),\n\t\t\t\t\tcontext\n\t\t\t\t);\n\t\t\t};\n\n\t\tconst Edit = getControl( field, fieldTypeDefinition );\n\n\t\tconst renderFromElements = ( { item }: { item: Item } ) => {\n\t\t\tconst value = getValue( { item } );\n\t\t\treturn (\n\t\t\t\tfield?.elements?.find( ( element ) => element.value === value )\n\t\t\t\t\t?.label || getValue( { item } )\n\t\t\t);\n\t\t};\n\n\t\tconst render =\n\t\t\tfield.render || ( field.elements ? renderFromElements : getValue );\n\n\t\treturn {\n\t\t\t...field,\n\t\t\tlabel: field.label || field.id,\n\t\t\theader: field.header || field.label || field.id,\n\t\t\tgetValue,\n\t\t\trender,\n\t\t\tsort,\n\t\t\tisValid,\n\t\t\tEdit,\n\t\t\tenableHiding: field.enableHiding ?? true,\n\t\t\tenableSorting: field.enableSorting ?? true,\n\t\t};\n\t} );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,sBAAsB,MAAM,eAAe;AAElD,SAASC,UAAU,QAAQ,qBAAqB;;AAEhD;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,eAAeA,CAC9BC,MAAuB,EACK;EAC5B,OAAOA,MAAM,CAACC,GAAG,CAAIC,KAAK,IAAM;IAAA,IAAAC,WAAA,EAAAC,cAAA,EAAAC,mBAAA,EAAAC,oBAAA;IAC/B,MAAMC,mBAAmB,GAAGV,sBAAsB,CAAEK,KAAK,CAACM,IAAK,CAAC;IAEhE,MAAMC,QAAQ,GACbP,KAAK,CAACO,QAAQ,KAAM,CAAE;MAAEC;IAAK,CAAC,KAAQA,IAAI,CAAWR,KAAK,CAACS,EAAE,CAAE,CAAE;IAElE,MAAMC,IAAI,IAAAT,WAAA,GACTD,KAAK,CAACU,IAAI,cAAAT,WAAA,cAAAA,WAAA,GACV,SAASS,IAAIA,CAAEC,CAAC,EAAEC,CAAC,EAAEC,SAAS,EAAG;MAChC,OAAOR,mBAAmB,CAACK,IAAI,CAC9BH,QAAQ,CAAE;QAAEC,IAAI,EAAEG;MAAE,CAAE,CAAC,EACvBJ,QAAQ,CAAE;QAAEC,IAAI,EAAEI;MAAE,CAAE,CAAC,EACvBC,SACD,CAAC;IACF,CAAC;IAEF,MAAMC,OAAO,IAAAZ,cAAA,GACZF,KAAK,CAACc,OAAO,cAAAZ,cAAA,cAAAA,cAAA,GACb,SAASY,OAAOA,CAAEN,IAAI,EAAEO,OAAO,EAAG;MACjC,OAAOV,mBAAmB,CAACS,OAAO,CACjCP,QAAQ,CAAE;QAAEC;MAAK,CAAE,CAAC,EACpBO,OACD,CAAC;IACF,CAAC;IAEF,MAAMC,IAAI,GAAGpB,UAAU,CAAEI,KAAK,EAAEK,mBAAoB,CAAC;IAErD,MAAMY,kBAAkB,GAAGA,CAAE;MAAET;IAAqB,CAAC,KAAM;MAC1D,MAAMU,KAAK,GAAGX,QAAQ,CAAE;QAAEC;MAAK,CAAE,CAAC;MAClC,OACCR,KAAK,EAAEmB,QAAQ,EAAEC,IAAI,CAAIC,OAAO,IAAMA,OAAO,CAACH,KAAK,KAAKA,KAAM,CAAC,EAC5DI,KAAK,IAAIf,QAAQ,CAAE;QAAEC;MAAK,CAAE,CAAC;IAElC,CAAC;IAED,MAAMe,MAAM,GACXvB,KAAK,CAACuB,MAAM,KAAMvB,KAAK,CAACmB,QAAQ,GAAGF,kBAAkB,GAAGV,QAAQ,CAAE;IAEnE,OAAO;MACN,GAAGP,KAAK;MACRsB,KAAK,EAAEtB,KAAK,CAACsB,KAAK,IAAItB,KAAK,CAACS,EAAE;MAC9Be,MAAM,EAAExB,KAAK,CAACwB,MAAM,IAAIxB,KAAK,CAACsB,KAAK,IAAItB,KAAK,CAACS,EAAE;MAC/CF,QAAQ;MACRgB,MAAM;MACNb,IAAI;MACJI,OAAO;MACPE,IAAI;MACJS,YAAY,GAAAtB,mBAAA,GAAEH,KAAK,CAACyB,YAAY,cAAAtB,mBAAA,cAAAA,mBAAA,GAAI,IAAI;MACxCuB,aAAa,GAAAtB,oBAAA,GAAEJ,KAAK,CAAC0B,aAAa,cAAAtB,oBAAA,cAAAA,oBAAA,GAAI;IACvC,CAAC;EACF,CAAE,CAAC;AACJ","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["@wordpress/dataviews/src/types.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport type {\n\tReactElement,\n\tComponentType,\n\tDispatch,\n\tSetStateAction,\n} from 'react';\n\n/**\n * Internal dependencies\n */\nimport type { SetSelection } from './private-types';\n\nexport type SortDirection = 'asc' | 'desc';\n\n/**\n * Generic option type.\n */\nexport interface Option< Value extends any = any > {\n\tvalue: Value;\n\tlabel: string;\n\tdescription?: string;\n}\n\ninterface FilterByConfig {\n\t/**\n\t * The list of operators supported by the field.\n\t */\n\toperators?: Operator[];\n\n\t/**\n\t * Whether it is a primary filter.\n\t *\n\t * A primary filter is always visible and is not listed in the \"Add filter\" component,\n\t * except for the list layout where it behaves like a secondary filter.\n\t */\n\tisPrimary?: boolean;\n}\n\nexport type Operator =\n\t| 'is'\n\t| 'isNot'\n\t| 'isAny'\n\t| 'isNone'\n\t| 'isAll'\n\t| 'isNotAll';\n\nexport type ItemRecord = Record< string, unknown >;\n\nexport type FieldType = 'text' | 'integer';\n\nexport type ValidationContext = {\n\telements?: Option[];\n};\n\n/**\n * A dataview field for a specific property of a data type.\n */\nexport type Field< Item > = {\n\t/**\n\t * Type of the fields.\n\t */\n\ttype?: FieldType;\n\n\t/**\n\t * The unique identifier of the field.\n\t */\n\tid: string;\n\n\t/**\n\t * The label of the field. Defaults to the id.\n\t */\n\tlabel?: string;\n\n\t/**\n\t * A description of the field.\n\t */\n\tdescription?: string;\n\n\t/**\n\t * Placeholder for the field.\n\t */\n\tplaceholder?: string;\n\n\t/**\n\t * Callback used to render the field. Defaults to `field.getValue`.\n\t */\n\trender?: ComponentType< { item: Item } >;\n\n\t/**\n\t * Callback used to render an edit control for the field.\n\t */\n\tEdit?: ComponentType< DataFormControlProps< Item > >;\n\n\t/**\n\t * Callback used to sort the field.\n\t */\n\tsort?: ( a: Item, b: Item, direction: SortDirection ) => number;\n\n\t/**\n\t * Callback used to validate the field.\n\t */\n\tisValid?: ( item: Item, context?: ValidationContext ) => boolean;\n\n\t/**\n\t * Whether the field is sortable.\n\t */\n\tenableSorting?: boolean;\n\n\t/**\n\t * Whether the field is searchable.\n\t */\n\tenableGlobalSearch?: boolean;\n\n\t/**\n\t * Whether the field is filterable.\n\t */\n\tenableHiding?: boolean;\n\n\t/**\n\t * The list of options to pick from when using the field as a filter.\n\t */\n\telements?: Option[];\n\n\t/**\n\t * Filter config for the field.\n\t */\n\tfilterBy?: FilterByConfig | undefined;\n} & ( Item extends ItemRecord\n\t? {\n\t\t\t/**\n\t\t\t * Callback used to retrieve the value of the field from the item.\n\t\t\t * Defaults to `item[ field.id ]`.\n\t\t\t */\n\t\t\tgetValue?: ( args: { item: Item } ) => any;\n\t }\n\t: {\n\t\t\t/**\n\t\t\t * Callback used to retrieve the value of the field from the item.\n\t\t\t * Defaults to `item[ field.id ]`.\n\t\t\t */\n\t\t\tgetValue: ( args: { item: Item } ) => any;\n\t } );\n\nexport type NormalizedField< Item > = Field< Item > & {\n\tlabel: string;\n\tgetValue: ( args: { item: Item } ) => any;\n\trender: ComponentType< { item: Item } >;\n\tEdit: ComponentType< DataFormControlProps< Item > >;\n\tsort: ( a: Item, b: Item, direction: SortDirection ) => number;\n\tisValid: ( item: Item, context?: ValidationContext ) => boolean;\n};\n\n/**\n * A collection of dataview fields for a data type.\n */\nexport type Fields< Item > = Field< Item >[];\n\nexport type Data< Item > = Item[];\n\n/**\n * The form configuration.\n */\nexport type Form = {\n\ttype?: 'regular' | 'panel';\n\tfields?: string[];\n};\n\nexport type DataFormControlProps< Item > = {\n\tdata: Item;\n\tfield: NormalizedField< Item >;\n\tonChange: Dispatch< SetStateAction< Item > >;\n\thideLabelFromVision?: boolean;\n};\n\n/**\n * The filters applied to the dataset.\n */\nexport interface Filter {\n\t/**\n\t * The field to filter by.\n\t */\n\tfield: string;\n\n\t/**\n\t * The operator to use.\n\t */\n\toperator: Operator;\n\n\t/**\n\t * The value to filter by.\n\t */\n\tvalue: any;\n}\n\nexport interface NormalizedFilter {\n\t/**\n\t * The field to filter by.\n\t */\n\tfield: string;\n\n\t/**\n\t * The field name.\n\t */\n\tname: string;\n\n\t/**\n\t * The list of options to pick from when using the field as a filter.\n\t */\n\telements: Option[];\n\n\t/**\n\t * Is a single selection filter.\n\t */\n\tsingleSelection: boolean;\n\n\t/**\n\t * The list of operators supported by the field.\n\t */\n\toperators: Operator[];\n\n\t/**\n\t * Whether the filter is visible.\n\t */\n\tisVisible: boolean;\n\n\t/**\n\t * Whether it is a primary filter.\n\t */\n\tisPrimary: boolean;\n}\n\ninterface ViewBase {\n\t/**\n\t * The layout of the view.\n\t */\n\ttype: string;\n\n\t/**\n\t * The global search term.\n\t */\n\tsearch?: string;\n\n\t/**\n\t * The filters to apply.\n\t */\n\tfilters?: Filter[];\n\n\t/**\n\t * The sorting configuration.\n\t */\n\tsort?: {\n\t\t/**\n\t\t * The field to sort by.\n\t\t */\n\t\tfield: string;\n\n\t\t/**\n\t\t * The direction to sort by.\n\t\t */\n\t\tdirection: SortDirection;\n\t};\n\n\t/**\n\t * The active page\n\t */\n\tpage?: number;\n\n\t/**\n\t * The number of items per page\n\t */\n\tperPage?: number;\n\n\t/**\n\t * The fields to render\n\t */\n\tfields?: string[];\n}\n\nexport interface CombinedField {\n\tid: string;\n\n\tlabel: string;\n\n\t/**\n\t * The fields to use as columns.\n\t */\n\tchildren: string[];\n\n\t/**\n\t * The direction of the stack.\n\t */\n\tdirection: 'horizontal' | 'vertical';\n}\n\nexport interface ColumnStyle {\n\t/**\n\t * The width of the field column.\n\t */\n\twidth?: string | number;\n\n\t/**\n\t * The minimum width of the field column.\n\t */\n\tmaxWidth?: string | number;\n\n\t/**\n\t * The maximum width of the field column.\n\t */\n\tminWidth?: string | number;\n}\n\nexport interface ViewTable extends ViewBase {\n\ttype: 'table';\n\n\tlayout?: {\n\t\t/**\n\t\t * The field to use as the primary field.\n\t\t */\n\t\tprimaryField?: string;\n\n\t\t/**\n\t\t * The fields to use as columns.\n\t\t */\n\t\tcombinedFields?: CombinedField[];\n\n\t\t/**\n\t\t * The styles for the columns.\n\t\t */\n\t\tstyles?: Record< string, ColumnStyle >;\n\t};\n}\n\nexport interface ViewList extends ViewBase {\n\ttype: 'list';\n\n\tlayout?: {\n\t\t/**\n\t\t * The field to use as the primary field.\n\t\t */\n\t\tprimaryField?: string;\n\n\t\t/**\n\t\t * The field to use as the media field.\n\t\t */\n\t\tmediaField?: string;\n\t};\n}\n\nexport interface ViewGrid extends ViewBase {\n\ttype: 'grid';\n\n\tlayout?: {\n\t\t/**\n\t\t * The field to use as the primary field.\n\t\t */\n\t\tprimaryField?: string;\n\n\t\t/**\n\t\t * The field to use as the media field.\n\t\t */\n\t\tmediaField?: string;\n\n\t\t/**\n\t\t * The fields to use as columns.\n\t\t */\n\t\tcolumnFields?: string[];\n\n\t\t/**\n\t\t * The fields to use as badge fields.\n\t\t */\n\t\tbadgeFields?: string[];\n\t};\n}\n\nexport type View = ViewList | ViewGrid | ViewTable;\n\ninterface ActionBase< Item > {\n\t/**\n\t * The unique identifier of the action.\n\t */\n\tid: string;\n\n\t/**\n\t * The label of the action.\n\t * In case we want to adjust the label based on the selected items,\n\t * a function can be provided.\n\t */\n\tlabel: string | ( ( items: Item[] ) => string );\n\n\t/**\n\t * The icon of the action. (Either a string or an SVG element)\n\t * This should be IconType from the components package\n\t * but that import is breaking typescript build for the moment.\n\t */\n\ticon?: any;\n\n\t/**\n\t * Whether the action is disabled.\n\t */\n\tdisabled?: boolean;\n\n\t/**\n\t * Whether the action is destructive.\n\t */\n\tisDestructive?: boolean;\n\n\t/**\n\t * Whether the action is a primary action.\n\t */\n\tisPrimary?: boolean;\n\n\t/**\n\t * Whether the item passed as an argument supports the current action.\n\t */\n\tisEligible?: ( item: Item ) => boolean;\n\n\t/**\n\t * Whether the action can be used as a bulk action.\n\t */\n\tsupportsBulk?: boolean;\n}\n\nexport interface ActionModal< Item > extends ActionBase< Item > {\n\t/**\n\t * Modal to render when the action is triggered.\n\t */\n\tRenderModal: ( {\n\t\titems,\n\t\tcloseModal,\n\t\tonActionPerformed,\n\t}: {\n\t\titems: Item[];\n\t\tcloseModal?: () => void;\n\t\tonActionPerformed?: ( items: Item[] ) => void;\n\t} ) => ReactElement;\n\n\t/**\n\t * Whether to hide the modal header.\n\t */\n\thideModalHeader?: boolean;\n\n\t/**\n\t * The header of the modal.\n\t */\n\tmodalHeader?: string;\n}\n\nexport interface ActionButton< Item > extends ActionBase< Item > {\n\t/**\n\t * The callback to execute when the action is triggered.\n\t */\n\tcallback: (\n\t\titems: Item[],\n\t\tcontext: {\n\t\t\tregistry: any;\n\t\t\tonActionPerformed?: ( items: Item[] ) => void;\n\t\t}\n\t) => void;\n}\n\nexport type Action< Item > = ActionModal< Item > | ActionButton< Item >;\n\nexport interface ViewBaseProps< Item > {\n\tactions: Action< Item >[];\n\tdata: Item[];\n\tfields: NormalizedField< Item >[];\n\tgetItemId: ( item: Item ) => string;\n\tisLoading?: boolean;\n\tonChangeView: ( view: View ) => void;\n\tonChangeSelection: SetSelection;\n\tselection: string[];\n\tsetOpenedFilter: ( fieldId: string ) => void;\n\tview: View;\n\tdensity: number;\n}\n\nexport interface ViewTableProps< Item > extends ViewBaseProps< Item > {\n\tview: ViewTable;\n}\n\nexport interface ViewListProps< Item > extends ViewBaseProps< Item > {\n\tview: ViewList;\n}\n\nexport interface ViewGridProps< Item > extends ViewBaseProps< Item > {\n\tview: ViewGrid;\n}\n\nexport type ViewProps< Item > =\n\t| ViewTableProps< Item >\n\t| ViewGridProps< Item >\n\t| ViewListProps< Item >;\n\nexport interface SupportedLayouts {\n\tlist?: Omit< ViewList, 'type' >;\n\tgrid?: Omit< ViewGrid, 'type' >;\n\ttable?: Omit< ViewTable, 'type' >;\n}\n\nexport interface DataFormProps< Item > {\n\tdata: Item;\n\tfields: Field< Item >[];\n\tform: Form;\n\tonChange: Dispatch< SetStateAction< Item > >;\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["@wordpress/dataviews/src/types.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { ReactElement, ComponentType } from 'react';\n\n/**\n * Internal dependencies\n */\nimport type { SetSelection } from './private-types';\n\nexport type SortDirection = 'asc' | 'desc';\n\n/**\n * Generic option type.\n */\nexport interface Option< Value extends any = any > {\n\tvalue: Value;\n\tlabel: string;\n\tdescription?: string;\n}\n\ninterface FilterByConfig {\n\t/**\n\t * The list of operators supported by the field.\n\t */\n\toperators?: Operator[];\n\n\t/**\n\t * Whether it is a primary filter.\n\t *\n\t * A primary filter is always visible and is not listed in the \"Add filter\" component,\n\t * except for the list layout where it behaves like a secondary filter.\n\t */\n\tisPrimary?: boolean;\n}\n\nexport type Operator =\n\t| 'is'\n\t| 'isNot'\n\t| 'isAny'\n\t| 'isNone'\n\t| 'isAll'\n\t| 'isNotAll';\n\nexport type FieldType = 'text' | 'integer' | 'datetime';\n\nexport type ValidationContext = {\n\telements?: Option[];\n};\n\n/**\n * An abstract interface for Field based on the field type.\n */\nexport type FieldTypeDefinition< Item > = {\n\t/**\n\t * Callback used to sort the field.\n\t */\n\tsort: ( a: Item, b: Item, direction: SortDirection ) => number;\n\n\t/**\n\t * Callback used to validate the field.\n\t */\n\tisValid: ( item: Item, context?: ValidationContext ) => boolean;\n\n\t/**\n\t * Callback used to render an edit control for the field or control name.\n\t */\n\tEdit: ComponentType< DataFormControlProps< Item > > | string;\n};\n\n/**\n * A dataview field for a specific property of a data type.\n */\nexport type Field< Item > = {\n\t/**\n\t * Type of the fields.\n\t */\n\ttype?: FieldType;\n\n\t/**\n\t * The unique identifier of the field.\n\t */\n\tid: string;\n\n\t/**\n\t * The label of the field. Defaults to the id.\n\t */\n\tlabel?: string;\n\n\t/**\n\t * The header of the field. Defaults to the label.\n\t * It allows the usage of a React Element to render the field labels.\n\t */\n\theader?: string | ReactElement;\n\n\t/**\n\t * A description of the field.\n\t */\n\tdescription?: string;\n\n\t/**\n\t * Placeholder for the field.\n\t */\n\tplaceholder?: string;\n\n\t/**\n\t * Callback used to render the field. Defaults to `field.getValue`.\n\t */\n\trender?: ComponentType< { item: Item } >;\n\n\t/**\n\t * Callback used to render an edit control for the field.\n\t */\n\tEdit?: ComponentType< DataFormControlProps< Item > > | string;\n\n\t/**\n\t * Callback used to sort the field.\n\t */\n\tsort?: ( a: Item, b: Item, direction: SortDirection ) => number;\n\n\t/**\n\t * Callback used to validate the field.\n\t */\n\tisValid?: ( item: Item, context?: ValidationContext ) => boolean;\n\n\t/**\n\t * Whether the field is sortable.\n\t */\n\tenableSorting?: boolean;\n\n\t/**\n\t * Whether the field is searchable.\n\t */\n\tenableGlobalSearch?: boolean;\n\n\t/**\n\t * Whether the field is filterable.\n\t */\n\tenableHiding?: boolean;\n\n\t/**\n\t * The list of options to pick from when using the field as a filter.\n\t */\n\telements?: Option[];\n\n\t/**\n\t * Filter config for the field.\n\t */\n\tfilterBy?: FilterByConfig | undefined;\n\n\t/**\n\t * Callback used to retrieve the value of the field from the item.\n\t * Defaults to `item[ field.id ]`.\n\t */\n\tgetValue?: ( args: { item: Item } ) => any;\n};\n\nexport type NormalizedField< Item > = Field< Item > & {\n\tlabel: string;\n\theader: string | ReactElement;\n\tgetValue: ( args: { item: Item } ) => any;\n\trender: ComponentType< { item: Item } >;\n\tEdit: ComponentType< DataFormControlProps< Item > >;\n\tsort: ( a: Item, b: Item, direction: SortDirection ) => number;\n\tisValid: ( item: Item, context?: ValidationContext ) => boolean;\n\tenableHiding: boolean;\n\tenableSorting: boolean;\n};\n\n/**\n * A collection of dataview fields for a data type.\n */\nexport type Fields< Item > = Field< Item >[];\n\nexport type Data< Item > = Item[];\n\n/**\n * The form configuration.\n */\nexport type Form = {\n\ttype?: 'regular' | 'panel';\n\tfields?: string[];\n};\n\nexport type DataFormControlProps< Item > = {\n\tdata: Item;\n\tfield: NormalizedField< Item >;\n\tonChange: ( value: Record< string, any > ) => void;\n\thideLabelFromVision?: boolean;\n};\n\n/**\n * The filters applied to the dataset.\n */\nexport interface Filter {\n\t/**\n\t * The field to filter by.\n\t */\n\tfield: string;\n\n\t/**\n\t * The operator to use.\n\t */\n\toperator: Operator;\n\n\t/**\n\t * The value to filter by.\n\t */\n\tvalue: any;\n}\n\nexport interface NormalizedFilter {\n\t/**\n\t * The field to filter by.\n\t */\n\tfield: string;\n\n\t/**\n\t * The field name.\n\t */\n\tname: string;\n\n\t/**\n\t * The list of options to pick from when using the field as a filter.\n\t */\n\telements: Option[];\n\n\t/**\n\t * Is a single selection filter.\n\t */\n\tsingleSelection: boolean;\n\n\t/**\n\t * The list of operators supported by the field.\n\t */\n\toperators: Operator[];\n\n\t/**\n\t * Whether the filter is visible.\n\t */\n\tisVisible: boolean;\n\n\t/**\n\t * Whether it is a primary filter.\n\t */\n\tisPrimary: boolean;\n}\n\ninterface ViewBase {\n\t/**\n\t * The layout of the view.\n\t */\n\ttype: string;\n\n\t/**\n\t * The global search term.\n\t */\n\tsearch?: string;\n\n\t/**\n\t * The filters to apply.\n\t */\n\tfilters?: Filter[];\n\n\t/**\n\t * The sorting configuration.\n\t */\n\tsort?: {\n\t\t/**\n\t\t * The field to sort by.\n\t\t */\n\t\tfield: string;\n\n\t\t/**\n\t\t * The direction to sort by.\n\t\t */\n\t\tdirection: SortDirection;\n\t};\n\n\t/**\n\t * The active page\n\t */\n\tpage?: number;\n\n\t/**\n\t * The number of items per page\n\t */\n\tperPage?: number;\n\n\t/**\n\t * The fields to render\n\t */\n\tfields?: string[];\n}\n\nexport interface CombinedField {\n\tid: string;\n\n\tlabel: string;\n\n\theader?: string | ReactElement;\n\n\t/**\n\t * The fields to use as columns.\n\t */\n\tchildren: string[];\n\n\t/**\n\t * The direction of the stack.\n\t */\n\tdirection: 'horizontal' | 'vertical';\n}\n\nexport interface ColumnStyle {\n\t/**\n\t * The width of the field column.\n\t */\n\twidth?: string | number;\n\n\t/**\n\t * The minimum width of the field column.\n\t */\n\tmaxWidth?: string | number;\n\n\t/**\n\t * The maximum width of the field column.\n\t */\n\tminWidth?: string | number;\n}\n\nexport interface ViewTable extends ViewBase {\n\ttype: 'table';\n\n\tlayout?: {\n\t\t/**\n\t\t * The field to use as the primary field.\n\t\t */\n\t\tprimaryField?: string;\n\n\t\t/**\n\t\t * The fields to use as columns.\n\t\t */\n\t\tcombinedFields?: CombinedField[];\n\n\t\t/**\n\t\t * The styles for the columns.\n\t\t */\n\t\tstyles?: Record< string, ColumnStyle >;\n\t};\n}\n\nexport interface ViewList extends ViewBase {\n\ttype: 'list';\n\n\tlayout?: {\n\t\t/**\n\t\t * The field to use as the primary field.\n\t\t */\n\t\tprimaryField?: string;\n\n\t\t/**\n\t\t * The field to use as the media field.\n\t\t */\n\t\tmediaField?: string;\n\t};\n}\n\nexport interface ViewGrid extends ViewBase {\n\ttype: 'grid';\n\n\tlayout?: {\n\t\t/**\n\t\t * The field to use as the primary field.\n\t\t */\n\t\tprimaryField?: string;\n\n\t\t/**\n\t\t * The field to use as the media field.\n\t\t */\n\t\tmediaField?: string;\n\n\t\t/**\n\t\t * The fields to use as columns.\n\t\t */\n\t\tcolumnFields?: string[];\n\n\t\t/**\n\t\t * The fields to use as badge fields.\n\t\t */\n\t\tbadgeFields?: string[];\n\t};\n}\n\nexport type View = ViewList | ViewGrid | ViewTable;\n\ninterface ActionBase< Item > {\n\t/**\n\t * The unique identifier of the action.\n\t */\n\tid: string;\n\n\t/**\n\t * The label of the action.\n\t * In case we want to adjust the label based on the selected items,\n\t * a function can be provided.\n\t */\n\tlabel: string | ( ( items: Item[] ) => string );\n\n\t/**\n\t * The icon of the action. (Either a string or an SVG element)\n\t * This should be IconType from the components package\n\t * but that import is breaking typescript build for the moment.\n\t */\n\ticon?: any;\n\n\t/**\n\t * Whether the action is disabled.\n\t */\n\tdisabled?: boolean;\n\n\t/**\n\t * Whether the action is destructive.\n\t */\n\tisDestructive?: boolean;\n\n\t/**\n\t * Whether the action is a primary action.\n\t */\n\tisPrimary?: boolean;\n\n\t/**\n\t * Whether the item passed as an argument supports the current action.\n\t */\n\tisEligible?: ( item: Item ) => boolean;\n\n\t/**\n\t * Whether the action can be used as a bulk action.\n\t */\n\tsupportsBulk?: boolean;\n\n\t/**\n\t * The context in which the action is visible.\n\t * This is only a \"meta\" information for now.\n\t */\n\tcontext?: 'list' | 'single';\n}\n\nexport interface RenderModalProps< Item > {\n\titems: Item[];\n\tcloseModal?: () => void;\n\tonActionPerformed?: ( items: Item[] ) => void;\n}\n\nexport interface ActionModal< Item > extends ActionBase< Item > {\n\t/**\n\t * Modal to render when the action is triggered.\n\t */\n\tRenderModal: ( {\n\t\titems,\n\t\tcloseModal,\n\t\tonActionPerformed,\n\t}: RenderModalProps< Item > ) => ReactElement;\n\n\t/**\n\t * Whether to hide the modal header.\n\t */\n\thideModalHeader?: boolean;\n\n\t/**\n\t * The header of the modal.\n\t */\n\tmodalHeader?: string;\n}\n\nexport interface ActionButton< Item > extends ActionBase< Item > {\n\t/**\n\t * The callback to execute when the action is triggered.\n\t */\n\tcallback: (\n\t\titems: Item[],\n\t\tcontext: {\n\t\t\tregistry: any;\n\t\t\tonActionPerformed?: ( items: Item[] ) => void;\n\t\t}\n\t) => void;\n}\n\nexport type Action< Item > = ActionModal< Item > | ActionButton< Item >;\n\nexport interface ViewBaseProps< Item > {\n\tactions: Action< Item >[];\n\tdata: Item[];\n\tfields: NormalizedField< Item >[];\n\tgetItemId: ( item: Item ) => string;\n\tisLoading?: boolean;\n\tonChangeView: ( view: View ) => void;\n\tonChangeSelection: SetSelection;\n\tselection: string[];\n\tsetOpenedFilter: ( fieldId: string ) => void;\n\tview: View;\n\tdensity: number;\n}\n\nexport interface ViewTableProps< Item > extends ViewBaseProps< Item > {\n\tview: ViewTable;\n}\n\nexport interface ViewListProps< Item > extends ViewBaseProps< Item > {\n\tview: ViewList;\n}\n\nexport interface ViewGridProps< Item > extends ViewBaseProps< Item > {\n\tview: ViewGrid;\n}\n\nexport type ViewProps< Item > =\n\t| ViewTableProps< Item >\n\t| ViewGridProps< Item >\n\t| ViewListProps< Item >;\n\nexport interface SupportedLayouts {\n\tlist?: Omit< ViewList, 'type' >;\n\tgrid?: Omit< ViewGrid, 'type' >;\n\ttable?: Omit< ViewTable, 'type' >;\n}\n\nexport interface DataFormProps< Item > {\n\tdata: Item;\n\tfields: Field< Item >[];\n\tform: Form;\n\tonChange: ( value: Record< string, any > ) => void;\n}\n"],"mappings":"","ignoreList":[]}
@@ -37,10 +37,10 @@
37
37
  * Radius scale.
38
38
  */
39
39
  /**
40
- * Dimensions.
40
+ * Elevation scale.
41
41
  */
42
42
  /**
43
- * Shadows.
43
+ * Dimensions.
44
44
  */
45
45
  /**
46
46
  * Editor widths.
@@ -116,6 +116,8 @@
116
116
  container: dataviews-wrapper/inline-size;
117
117
  display: flex;
118
118
  flex-direction: column;
119
+ font-size: 13px;
120
+ line-height: 1.4;
119
121
  }
120
122
 
121
123
  .dataviews__view-actions,
@@ -134,10 +136,6 @@
134
136
  transition-delay: 0s;
135
137
  }
136
138
  }
137
- .dataviews__view-actions .components-search-control .components-base-control__field,
138
- .dataviews-filters__container .components-search-control .components-base-control__field {
139
- max-width: 240px;
140
- }
141
139
 
142
140
  .dataviews-view-list__primary-field,
143
141
  .dataviews-view-grid__primary-field,
@@ -213,10 +211,6 @@
213
211
  .dataviews-filters__container {
214
212
  padding: 12px 24px;
215
213
  }
216
- .dataviews__view-actions .components-search-control .components-base-control__field,
217
- .dataviews-filters__container .components-search-control .components-base-control__field {
218
- max-width: 112px;
219
- }
220
214
 
221
215
  .dataviews-view-grid,
222
216
  .dataviews-no-results,
@@ -225,53 +219,16 @@
225
219
  padding-left: 24px;
226
220
  }
227
221
  }
228
- .dataviews-bulk-actions__modal {
229
- z-index: 1000001;
230
- }
231
-
232
- .dataviews-bulk-actions__edit-button.components-button {
233
- flex-shrink: 0;
222
+ .dataviews-bulk-actions-footer__item-count {
223
+ color: #1e1e1e;
224
+ font-weight: 500;
225
+ font-size: 11px;
226
+ text-transform: uppercase;
234
227
  }
235
228
 
236
- .dataviews-bulk-actions-toolbar {
237
- position: sticky;
238
- display: flex;
239
- flex-direction: column;
240
- align-content: center;
241
- flex-wrap: wrap;
242
- width: -moz-fit-content;
243
- width: fit-content;
244
- margin-right: auto;
229
+ .dataviews-bulk-actions-footer__container {
245
230
  margin-left: auto;
246
- bottom: 24px;
247
- z-index: 2;
248
- }
249
- .dataviews-bulk-actions-toolbar .components-accessible-toolbar {
250
- border-color: #ddd;
251
- box-shadow: 0 0.7px 1px rgba(0, 0, 0, 0.1), 0 1.2px 1.7px -0.2px rgba(0, 0, 0, 0.1), 0 2.3px 3.3px -0.5px rgba(0, 0, 0, 0.1);
252
- }
253
- .dataviews-bulk-actions-toolbar .components-accessible-toolbar .components-toolbar-group {
254
- border-color: #e0e0e0;
255
- }
256
- .dataviews-bulk-actions-toolbar .components-accessible-toolbar .components-toolbar-group:last-child {
257
- border: 0;
258
- }
259
- .dataviews-bulk-actions-toolbar .dataviews-bulk-actions-toolbar__selection-count {
260
- display: flex;
261
- align-items: center;
262
- margin: 0 8px 0 8px;
263
- }
264
-
265
- .dataviews-bulk-actions-toolbar__wrapper {
266
- display: flex;
267
- flex-grow: 1;
268
- width: 100%;
269
- }
270
- .dataviews-bulk-actions-toolbar__wrapper .components-toolbar-group {
271
- align-items: center;
272
- }
273
- .dataviews-bulk-actions-toolbar__wrapper .components-button.is-busy {
274
- max-height: 36px;
231
+ min-height: 32px;
275
232
  }
276
233
 
277
234
  .dataviews-filters__button {
@@ -289,11 +246,17 @@
289
246
  opacity: 1;
290
247
  }
291
248
 
249
+ .dataviews-filters__summary-popover {
250
+ font-size: 13px;
251
+ line-height: 1.4;
252
+ }
292
253
  .dataviews-filters__summary-popover .components-popover__content {
293
254
  width: 230px;
294
- padding: 0;
295
255
  border-radius: 4px;
296
256
  }
257
+ .dataviews-filters__summary-popover.components-dropdown__content .components-popover__content {
258
+ padding: 0;
259
+ }
297
260
 
298
261
  .dataviews-filters__summary-operators-container {
299
262
  padding: 8px 8px 0;
@@ -324,6 +287,7 @@
324
287
  position: relative;
325
288
  display: flex;
326
289
  align-items: center;
290
+ box-sizing: border-box;
327
291
  }
328
292
  .dataviews-filters__summary-chip-container .dataviews-filters__summary-chip.has-reset {
329
293
  padding-inline-end: 28px;
@@ -535,6 +499,7 @@
535
499
  font-size: 11px;
536
500
  outline: var(--wp-admin-border-width-focus) solid #fff;
537
501
  color: #fff;
502
+ box-sizing: border-box;
538
503
  }
539
504
 
540
505
  .dataviews-search {
@@ -542,37 +507,58 @@
542
507
  width: fit-content;
543
508
  }
544
509
 
545
- .dataviews-pagination {
510
+ .dataviews-footer {
546
511
  position: sticky;
547
512
  bottom: 0;
548
513
  right: 0;
549
514
  background-color: #fff;
550
515
  padding: 12px 48px;
551
516
  border-top: 1px solid #f0f0f0;
552
- color: #757575;
553
517
  flex-shrink: 0;
554
518
  transition: padding ease-out 0.1s;
519
+ z-index: 2;
555
520
  }
556
521
  @media (prefers-reduced-motion: reduce) {
557
- .dataviews-pagination {
522
+ .dataviews-footer {
558
523
  transition-duration: 0s;
559
524
  transition-delay: 0s;
560
525
  }
561
526
  }
562
527
 
563
- .dataviews-pagination__page-selection {
564
- font-size: 11px;
565
- text-transform: uppercase;
566
- font-weight: 500;
567
- color: #1e1e1e;
568
- }
569
-
570
528
  /* stylelint-disable-next-line scss/at-rule-no-unknown -- '@container' not globally permitted */
571
529
  @container (max-width: 430px) {
572
- .dataviews-pagination {
530
+ .dataviews-footer {
573
531
  padding: 12px 24px;
574
532
  }
575
533
  }
534
+ /* stylelint-disable-next-line scss/at-rule-no-unknown -- '@container' not globally permitted */
535
+ @container (max-width: 560px) {
536
+ .dataviews-footer {
537
+ flex-direction: column !important;
538
+ }
539
+ .dataviews-footer .dataviews-bulk-actions-footer__container {
540
+ width: 100%;
541
+ }
542
+ .dataviews-footer .dataviews-bulk-actions-footer__item-count {
543
+ flex-grow: 1;
544
+ }
545
+ .dataviews-footer .dataviews-pagination {
546
+ width: 100%;
547
+ justify-content: space-between;
548
+ }
549
+ }
550
+ .dataviews-pagination__page-select {
551
+ font-size: 11px;
552
+ font-weight: 500;
553
+ text-transform: uppercase;
554
+ }
555
+ @media (min-width: 600px) {
556
+ .dataviews-pagination__page-select .components-select-control__input {
557
+ font-size: 11px !important;
558
+ font-weight: 500;
559
+ }
560
+ }
561
+
576
562
  .dataviews-action-modal {
577
563
  z-index: 1000001;
578
564
  }
@@ -596,6 +582,8 @@
596
582
  /* stylelint-disable-next-line property-no-unknown -- the linter needs to be updated to accepted the container-type property */
597
583
  container-type: inline-size;
598
584
  padding: 16px;
585
+ font-size: 13px;
586
+ line-height: 1.4;
599
587
  }
600
588
 
601
589
  .dataviews-view-config__sort-direction .components-toggle-group-control-option-base {
@@ -623,6 +611,10 @@
623
611
  grid-column: span 4;
624
612
  }
625
613
 
614
+ .dataviews-settings-section:has(.dataviews-settings-section__content:empty) {
615
+ display: none;
616
+ }
617
+
626
618
  /* stylelint-disable-next-line scss/at-rule-no-unknown -- '@container' not globally permitted */
627
619
  @container (max-width: 500px) {
628
620
  .dataviews-settings-section.dataviews-settings-section {
@@ -635,6 +627,25 @@
635
627
  grid-column: span 2;
636
628
  }
637
629
  }
630
+ .dataviews-field-control__field {
631
+ height: 32px;
632
+ }
633
+
634
+ .dataviews-field-control__actions {
635
+ position: absolute;
636
+ top: -9999em;
637
+ }
638
+
639
+ .dataviews-field-control__actions.dataviews-field-control__actions {
640
+ gap: 4px;
641
+ }
642
+
643
+ .dataviews-field-control__field:hover .dataviews-field-control__actions,
644
+ .dataviews-field-control__field:focus-within .dataviews-field-control__actions {
645
+ position: unset;
646
+ top: unset;
647
+ }
648
+
638
649
  .dataviews-view-grid {
639
650
  margin-bottom: auto;
640
651
  grid-template-rows: max-content;
@@ -766,10 +777,6 @@
766
777
  }
767
778
  }
768
779
 
769
- .dataviews-density-picker__range-control {
770
- width: 200px;
771
- }
772
-
773
780
  .dataviews-view-grid__field-value:empty,
774
781
  .dataviews-view-grid__field:empty {
775
782
  display: none;
@@ -788,6 +795,10 @@
788
795
  top: 8px;
789
796
  }
790
797
 
798
+ ul.dataviews-view-list {
799
+ list-style-type: none;
800
+ }
801
+
791
802
  .dataviews-view-list {
792
803
  margin: 0 0 auto;
793
804
  }
@@ -841,12 +852,13 @@
841
852
  .dataviews-view-list li:not(.is-selected) .dataviews-view-list__primary-field {
842
853
  color: #1e1e1e;
843
854
  }
844
- .dataviews-view-list li:not(.is-selected):hover, .dataviews-view-list li:not(.is-selected):focus-within {
855
+ .dataviews-view-list li:not(.is-selected):hover, .dataviews-view-list li:not(.is-selected).is-hovered, .dataviews-view-list li:not(.is-selected):focus-within {
845
856
  color: var(--wp-admin-theme-color);
846
857
  background-color: #f8f8f8;
847
858
  }
848
859
  .dataviews-view-list li:not(.is-selected):hover .dataviews-view-list__primary-field,
849
- .dataviews-view-list li:not(.is-selected):hover .dataviews-view-list__fields, .dataviews-view-list li:not(.is-selected):focus-within .dataviews-view-list__primary-field,
860
+ .dataviews-view-list li:not(.is-selected):hover .dataviews-view-list__fields, .dataviews-view-list li:not(.is-selected).is-hovered .dataviews-view-list__primary-field,
861
+ .dataviews-view-list li:not(.is-selected).is-hovered .dataviews-view-list__fields, .dataviews-view-list li:not(.is-selected):focus-within .dataviews-view-list__primary-field,
850
862
  .dataviews-view-list li:not(.is-selected):focus-within .dataviews-view-list__fields {
851
863
  color: var(--wp-admin-theme-color);
852
864
  }
@@ -862,6 +874,7 @@
862
874
  color: var(--wp-admin-theme-color);
863
875
  }
864
876
  .dataviews-view-list .dataviews-view-list__item {
877
+ box-sizing: border-box;
865
878
  padding: 16px 24px;
866
879
  width: 100%;
867
880
  scroll-margin: 8px 0;
@@ -869,7 +882,7 @@
869
882
  .dataviews-view-list .dataviews-view-list__item:focus-visible::before {
870
883
  position: absolute;
871
884
  content: "";
872
- top: calc(var(--wp-admin-border-width-focus) + 1px);
885
+ top: var(--wp-admin-border-width-focus);
873
886
  left: var(--wp-admin-border-width-focus);
874
887
  bottom: var(--wp-admin-border-width-focus);
875
888
  right: var(--wp-admin-border-width-focus);
@@ -906,8 +919,8 @@
906
919
  border-radius: 4px;
907
920
  }
908
921
  .dataviews-view-list .dataviews-view-list__media-placeholder {
909
- min-width: 32px;
910
- height: 32px;
922
+ width: 52px;
923
+ height: 52px;
911
924
  background-color: #e0e0e0;
912
925
  }
913
926
  .dataviews-view-list .dataviews-view-list__field-wrapper {
@@ -946,11 +959,6 @@
946
959
  color: #757575;
947
960
  margin-bottom: auto;
948
961
  }
949
- .dataviews-view-table a {
950
- text-decoration: none;
951
- color: #1e1e1e;
952
- font-weight: 500;
953
- }
954
962
  .dataviews-view-table th {
955
963
  text-align: right;
956
964
  color: #1e1e1e;
@@ -1108,6 +1116,11 @@
1108
1116
  }
1109
1117
  }
1110
1118
 
1119
+ .dataviews-controls__datetime {
1120
+ border: none;
1121
+ padding: 0;
1122
+ }
1123
+
1111
1124
  .dataforms-layouts-panel__field {
1112
1125
  width: 100%;
1113
1126
  min-height: 32px;