@wordpress/dataviews 11.0.0 → 11.1.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 (303) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +140 -93
  3. package/build/components/dataviews-filters/filter.js +25 -267
  4. package/build/components/dataviews-filters/filter.js.map +2 -2
  5. package/build/components/dataviews-filters/input-widget.js +1 -4
  6. package/build/components/dataviews-filters/input-widget.js.map +2 -2
  7. package/build/components/dataviews-filters/use-filters.js +3 -3
  8. package/build/components/dataviews-filters/use-filters.js.map +2 -2
  9. package/build/constants.js +5 -142
  10. package/build/constants.js.map +2 -2
  11. package/build/dataform-controls/number.js +2 -1
  12. package/build/dataform-controls/number.js.map +2 -2
  13. package/build/dataform-controls/textarea.js +3 -1
  14. package/build/dataform-controls/textarea.js.map +2 -2
  15. package/build/dataform-controls/utils/get-custom-validity.js +8 -0
  16. package/build/dataform-controls/utils/get-custom-validity.js.map +2 -2
  17. package/build/dataform-controls/utils/validated-input.js +4 -2
  18. package/build/dataform-controls/utils/validated-input.js.map +2 -2
  19. package/build/dataform-controls/utils/validated-number.js +4 -2
  20. package/build/dataform-controls/utils/validated-number.js.map +2 -2
  21. package/build/dataform-layouts/panel/modal.js +14 -5
  22. package/build/dataform-layouts/panel/modal.js.map +2 -2
  23. package/build/dataviews-layouts/grid/composite-grid.js +39 -37
  24. package/build/dataviews-layouts/grid/composite-grid.js.map +3 -3
  25. package/build/dataviews-layouts/table/index.js +8 -3
  26. package/build/dataviews-layouts/table/index.js.map +2 -2
  27. package/build/field-types/array.js +27 -14
  28. package/build/field-types/array.js.map +3 -3
  29. package/build/field-types/boolean.js +13 -10
  30. package/build/field-types/boolean.js.map +3 -3
  31. package/build/field-types/color.js +14 -11
  32. package/build/field-types/color.js.map +3 -3
  33. package/build/field-types/date.js +11 -8
  34. package/build/field-types/date.js.map +3 -3
  35. package/build/field-types/datetime.js +7 -5
  36. package/build/field-types/datetime.js.map +3 -3
  37. package/build/field-types/email.js +20 -11
  38. package/build/field-types/email.js.map +3 -3
  39. package/build/field-types/index.js +12 -14
  40. package/build/field-types/index.js.map +3 -3
  41. package/build/field-types/integer.js +63 -14
  42. package/build/field-types/integer.js.map +3 -3
  43. package/build/field-types/media.js +5 -5
  44. package/build/field-types/media.js.map +2 -2
  45. package/build/field-types/no-type.js +9 -6
  46. package/build/field-types/no-type.js.map +3 -3
  47. package/build/field-types/number.js +51 -15
  48. package/build/field-types/number.js.map +3 -3
  49. package/build/field-types/password.js +13 -5
  50. package/build/field-types/password.js.map +3 -3
  51. package/build/field-types/telephone.js +13 -5
  52. package/build/field-types/telephone.js.map +3 -3
  53. package/build/field-types/text.js +13 -5
  54. package/build/field-types/text.js.map +3 -3
  55. package/build/field-types/url.js +13 -5
  56. package/build/field-types/url.js.map +3 -3
  57. package/build/field-types/utils/get-is-valid.js +89 -0
  58. package/build/field-types/utils/get-is-valid.js.map +7 -0
  59. package/build/field-types/utils/is-valid-elements.js +35 -0
  60. package/build/field-types/utils/is-valid-elements.js.map +7 -0
  61. package/build/field-types/utils/is-valid-max-length.js +36 -0
  62. package/build/field-types/utils/is-valid-max-length.js.map +7 -0
  63. package/build/field-types/utils/is-valid-max.js +36 -0
  64. package/build/field-types/utils/is-valid-max.js.map +7 -0
  65. package/build/field-types/utils/is-valid-min-length.js +36 -0
  66. package/build/field-types/utils/is-valid-min-length.js.map +7 -0
  67. package/build/field-types/utils/is-valid-min.js +36 -0
  68. package/build/field-types/utils/is-valid-min.js.map +7 -0
  69. package/build/field-types/utils/is-valid-pattern.js +41 -0
  70. package/build/field-types/utils/is-valid-pattern.js.map +7 -0
  71. package/build/field-types/utils/is-valid-required-for-array.js +32 -0
  72. package/build/field-types/utils/is-valid-required-for-array.js.map +7 -0
  73. package/build/field-types/utils/is-valid-required-for-bool.js +30 -0
  74. package/build/field-types/utils/is-valid-required-for-bool.js.map +7 -0
  75. package/build/field-types/utils/is-valid-required.js +30 -0
  76. package/build/field-types/utils/is-valid-required.js.map +7 -0
  77. package/build/hooks/use-form-validity.js +52 -102
  78. package/build/hooks/use-form-validity.js.map +2 -2
  79. package/build/types/field-api.js.map +1 -1
  80. package/build/types/private.js.map +1 -1
  81. package/build/utils/filter-sort-and-paginate.js +5 -0
  82. package/build/utils/filter-sort-and-paginate.js.map +3 -3
  83. package/build/utils/operators.js +399 -0
  84. package/build/utils/operators.js.map +7 -0
  85. package/build-module/components/dataviews-filters/filter.js +26 -292
  86. package/build-module/components/dataviews-filters/filter.js.map +2 -2
  87. package/build-module/components/dataviews-filters/input-widget.js +1 -4
  88. package/build-module/components/dataviews-filters/input-widget.js.map +2 -2
  89. package/build-module/components/dataviews-filters/use-filters.js +6 -3
  90. package/build-module/components/dataviews-filters/use-filters.js.map +2 -2
  91. package/build-module/constants.js +5 -139
  92. package/build-module/constants.js.map +2 -2
  93. package/build-module/dataform-controls/number.js +2 -1
  94. package/build-module/dataform-controls/number.js.map +2 -2
  95. package/build-module/dataform-controls/textarea.js +3 -1
  96. package/build-module/dataform-controls/textarea.js.map +2 -2
  97. package/build-module/dataform-controls/utils/get-custom-validity.js +8 -0
  98. package/build-module/dataform-controls/utils/get-custom-validity.js.map +2 -2
  99. package/build-module/dataform-controls/utils/validated-input.js +4 -2
  100. package/build-module/dataform-controls/utils/validated-input.js.map +2 -2
  101. package/build-module/dataform-controls/utils/validated-number.js +4 -2
  102. package/build-module/dataform-controls/utils/validated-number.js.map +2 -2
  103. package/build-module/dataform-layouts/panel/modal.js +14 -5
  104. package/build-module/dataform-layouts/panel/modal.js.map +2 -2
  105. package/build-module/dataviews-layouts/grid/composite-grid.js +40 -38
  106. package/build-module/dataviews-layouts/grid/composite-grid.js.map +3 -3
  107. package/build-module/dataviews-layouts/table/index.js +8 -3
  108. package/build-module/dataviews-layouts/table/index.js.map +2 -2
  109. package/build-module/field-types/array.js +17 -14
  110. package/build-module/field-types/array.js.map +2 -2
  111. package/build-module/field-types/boolean.js +13 -10
  112. package/build-module/field-types/boolean.js.map +2 -2
  113. package/build-module/field-types/color.js +14 -11
  114. package/build-module/field-types/color.js.map +2 -2
  115. package/build-module/field-types/date.js +11 -8
  116. package/build-module/field-types/date.js.map +2 -2
  117. package/build-module/field-types/datetime.js +7 -5
  118. package/build-module/field-types/datetime.js.map +2 -2
  119. package/build-module/field-types/email.js +20 -11
  120. package/build-module/field-types/email.js.map +2 -2
  121. package/build-module/field-types/index.js +12 -14
  122. package/build-module/field-types/index.js.map +2 -2
  123. package/build-module/field-types/integer.js +58 -13
  124. package/build-module/field-types/integer.js.map +2 -2
  125. package/build-module/field-types/media.js +5 -5
  126. package/build-module/field-types/media.js.map +2 -2
  127. package/build-module/field-types/no-type.js +10 -7
  128. package/build-module/field-types/no-type.js.map +2 -2
  129. package/build-module/field-types/number.js +47 -15
  130. package/build-module/field-types/number.js.map +2 -2
  131. package/build-module/field-types/password.js +13 -5
  132. package/build-module/field-types/password.js.map +2 -2
  133. package/build-module/field-types/telephone.js +13 -5
  134. package/build-module/field-types/telephone.js.map +2 -2
  135. package/build-module/field-types/text.js +13 -5
  136. package/build-module/field-types/text.js.map +2 -2
  137. package/build-module/field-types/url.js +13 -5
  138. package/build-module/field-types/url.js.map +2 -2
  139. package/build-module/field-types/utils/get-is-valid.js +68 -0
  140. package/build-module/field-types/utils/get-is-valid.js.map +7 -0
  141. package/build-module/field-types/utils/is-valid-elements.js +14 -0
  142. package/build-module/field-types/utils/is-valid-elements.js.map +7 -0
  143. package/build-module/field-types/utils/is-valid-max-length.js +15 -0
  144. package/build-module/field-types/utils/is-valid-max-length.js.map +7 -0
  145. package/build-module/field-types/utils/is-valid-max.js +15 -0
  146. package/build-module/field-types/utils/is-valid-max.js.map +7 -0
  147. package/build-module/field-types/utils/is-valid-min-length.js +15 -0
  148. package/build-module/field-types/utils/is-valid-min-length.js.map +7 -0
  149. package/build-module/field-types/utils/is-valid-min.js +15 -0
  150. package/build-module/field-types/utils/is-valid-min.js.map +7 -0
  151. package/build-module/field-types/utils/is-valid-pattern.js +20 -0
  152. package/build-module/field-types/utils/is-valid-pattern.js.map +7 -0
  153. package/build-module/field-types/utils/is-valid-required-for-array.js +11 -0
  154. package/build-module/field-types/utils/is-valid-required-for-array.js.map +7 -0
  155. package/build-module/field-types/utils/is-valid-required-for-bool.js +9 -0
  156. package/build-module/field-types/utils/is-valid-required-for-bool.js.map +7 -0
  157. package/build-module/field-types/utils/is-valid-required.js +9 -0
  158. package/build-module/field-types/utils/is-valid-required.js.map +7 -0
  159. package/build-module/hooks/use-form-validity.js +52 -102
  160. package/build-module/hooks/use-form-validity.js.map +2 -2
  161. package/build-module/utils/filter-sort-and-paginate.js +5 -0
  162. package/build-module/utils/filter-sort-and-paginate.js.map +2 -2
  163. package/build-module/utils/operators.js +394 -0
  164. package/build-module/utils/operators.js.map +7 -0
  165. package/build-style/style-rtl.css +13 -80
  166. package/build-style/style.css +13 -80
  167. package/build-types/components/dataviews-filters/filter.d.ts.map +1 -1
  168. package/build-types/components/dataviews-filters/input-widget.d.ts.map +1 -1
  169. package/build-types/components/dataviews-filters/use-filters.d.ts.map +1 -1
  170. package/build-types/constants.d.ts +6 -12
  171. package/build-types/constants.d.ts.map +1 -1
  172. package/build-types/dataform-controls/number.d.ts.map +1 -1
  173. package/build-types/dataform-controls/textarea.d.ts.map +1 -1
  174. package/build-types/dataform-controls/utils/get-custom-validity.d.ts +2 -2
  175. package/build-types/dataform-controls/utils/get-custom-validity.d.ts.map +1 -1
  176. package/build-types/dataform-controls/utils/validated-input.d.ts.map +1 -1
  177. package/build-types/dataform-controls/utils/validated-number.d.ts.map +1 -1
  178. package/build-types/dataform-layouts/panel/modal.d.ts.map +1 -1
  179. package/build-types/dataviews-layouts/grid/composite-grid.d.ts.map +1 -1
  180. package/build-types/dataviews-layouts/table/index.d.ts.map +1 -1
  181. package/build-types/field-types/array.d.ts +9 -2
  182. package/build-types/field-types/array.d.ts.map +1 -1
  183. package/build-types/field-types/boolean.d.ts +9 -2
  184. package/build-types/field-types/boolean.d.ts.map +1 -1
  185. package/build-types/field-types/color.d.ts +9 -2
  186. package/build-types/field-types/color.d.ts.map +1 -1
  187. package/build-types/field-types/date.d.ts +6 -4
  188. package/build-types/field-types/date.d.ts.map +1 -1
  189. package/build-types/field-types/datetime.d.ts +6 -4
  190. package/build-types/field-types/datetime.d.ts.map +1 -1
  191. package/build-types/field-types/email.d.ts +15 -2
  192. package/build-types/field-types/email.d.ts.map +1 -1
  193. package/build-types/field-types/index.d.ts.map +1 -1
  194. package/build-types/field-types/integer.d.ts +17 -4
  195. package/build-types/field-types/integer.d.ts.map +1 -1
  196. package/build-types/field-types/media.d.ts +1 -4
  197. package/build-types/field-types/media.d.ts.map +1 -1
  198. package/build-types/field-types/no-type.d.ts +6 -4
  199. package/build-types/field-types/no-type.d.ts.map +1 -1
  200. package/build-types/field-types/number.d.ts +17 -4
  201. package/build-types/field-types/number.d.ts.map +1 -1
  202. package/build-types/field-types/password.d.ts +12 -4
  203. package/build-types/field-types/password.d.ts.map +1 -1
  204. package/build-types/field-types/telephone.d.ts +12 -4
  205. package/build-types/field-types/telephone.d.ts.map +1 -1
  206. package/build-types/field-types/text.d.ts +12 -4
  207. package/build-types/field-types/text.d.ts.map +1 -1
  208. package/build-types/field-types/url.d.ts +12 -4
  209. package/build-types/field-types/url.d.ts.map +1 -1
  210. package/build-types/field-types/utils/get-is-valid.d.ts +7 -0
  211. package/build-types/field-types/utils/get-is-valid.d.ts.map +1 -0
  212. package/build-types/field-types/utils/is-valid-elements.d.ts +6 -0
  213. package/build-types/field-types/utils/is-valid-elements.d.ts.map +1 -0
  214. package/build-types/field-types/utils/is-valid-max-length.d.ts +6 -0
  215. package/build-types/field-types/utils/is-valid-max-length.d.ts.map +1 -0
  216. package/build-types/field-types/utils/is-valid-max.d.ts +6 -0
  217. package/build-types/field-types/utils/is-valid-max.d.ts.map +1 -0
  218. package/build-types/field-types/utils/is-valid-min-length.d.ts +6 -0
  219. package/build-types/field-types/utils/is-valid-min-length.d.ts.map +1 -0
  220. package/build-types/field-types/utils/is-valid-min.d.ts +6 -0
  221. package/build-types/field-types/utils/is-valid-min.d.ts.map +1 -0
  222. package/build-types/field-types/utils/is-valid-pattern.d.ts +6 -0
  223. package/build-types/field-types/utils/is-valid-pattern.d.ts.map +1 -0
  224. package/build-types/field-types/utils/is-valid-required-for-array.d.ts +6 -0
  225. package/build-types/field-types/utils/is-valid-required-for-array.d.ts.map +1 -0
  226. package/build-types/field-types/utils/is-valid-required-for-bool.d.ts +6 -0
  227. package/build-types/field-types/utils/is-valid-required-for-bool.d.ts.map +1 -0
  228. package/build-types/field-types/utils/is-valid-required.d.ts +6 -0
  229. package/build-types/field-types/utils/is-valid-required.d.ts.map +1 -0
  230. package/build-types/hooks/use-form-validity.d.ts.map +1 -1
  231. package/build-types/stories/dataform.story.d.ts +9 -1
  232. package/build-types/stories/dataform.story.d.ts.map +1 -1
  233. package/build-types/stories/dataviews-picker.story.d.ts.map +1 -1
  234. package/build-types/stories/dataviews.story.d.ts +27 -2
  235. package/build-types/stories/dataviews.story.d.ts.map +1 -1
  236. package/build-types/stories/field-types.story.d.ts +39 -2
  237. package/build-types/stories/field-types.story.d.ts.map +1 -1
  238. package/build-types/types/field-api.d.ts +72 -4
  239. package/build-types/types/field-api.d.ts.map +1 -1
  240. package/build-types/types/private.d.ts +13 -3
  241. package/build-types/types/private.d.ts.map +1 -1
  242. package/build-types/utils/filter-sort-and-paginate.d.ts.map +1 -1
  243. package/build-types/utils/operators.d.ts +16 -0
  244. package/build-types/utils/operators.d.ts.map +1 -0
  245. package/build-wp/index.js +1548 -1452
  246. package/package.json +17 -16
  247. package/src/components/dataviews/style.scss +3 -28
  248. package/src/components/dataviews-filters/filter.tsx +34 -321
  249. package/src/components/dataviews-filters/input-widget.tsx +7 -5
  250. package/src/components/dataviews-filters/use-filters.ts +6 -3
  251. package/src/components/dataviews-footer/style.scss +1 -7
  252. package/src/constants.ts +6 -140
  253. package/src/dataform-controls/number.tsx +3 -3
  254. package/src/dataform-controls/textarea.tsx +7 -1
  255. package/src/dataform-controls/utils/get-custom-validity.ts +10 -2
  256. package/src/dataform-controls/utils/validated-input.tsx +8 -2
  257. package/src/dataform-controls/utils/validated-number.tsx +3 -1
  258. package/src/dataform-layouts/panel/modal.tsx +14 -5
  259. package/src/dataviews-layouts/activity/style.scss +1 -1
  260. package/src/dataviews-layouts/grid/composite-grid.tsx +64 -57
  261. package/src/dataviews-layouts/grid/style.scss +3 -12
  262. package/src/dataviews-layouts/table/index.tsx +9 -3
  263. package/src/dataviews-layouts/table/style.scss +4 -15
  264. package/src/dataviews-layouts/utils/grid-items.scss +1 -9
  265. package/src/field-types/array.tsx +26 -19
  266. package/src/field-types/boolean.tsx +22 -15
  267. package/src/field-types/color.tsx +22 -15
  268. package/src/field-types/date.tsx +14 -11
  269. package/src/field-types/datetime.tsx +6 -4
  270. package/src/field-types/email.tsx +24 -15
  271. package/src/field-types/index.tsx +12 -14
  272. package/src/field-types/integer.tsx +83 -17
  273. package/src/field-types/media.tsx +4 -4
  274. package/src/field-types/no-type.tsx +9 -6
  275. package/src/field-types/number.tsx +82 -16
  276. package/src/field-types/password.tsx +12 -4
  277. package/src/field-types/telephone.tsx +12 -4
  278. package/src/field-types/text.tsx +12 -4
  279. package/src/field-types/url.tsx +12 -4
  280. package/src/field-types/utils/get-is-valid.ts +103 -0
  281. package/src/field-types/utils/is-valid-elements.ts +20 -0
  282. package/src/field-types/utils/is-valid-max-length.ts +23 -0
  283. package/src/field-types/utils/is-valid-max.ts +23 -0
  284. package/src/field-types/utils/is-valid-min-length.ts +23 -0
  285. package/src/field-types/utils/is-valid-min.ts +23 -0
  286. package/src/field-types/utils/is-valid-pattern.ts +29 -0
  287. package/src/field-types/utils/is-valid-required-for-array.ts +18 -0
  288. package/src/field-types/utils/is-valid-required-for-bool.ts +13 -0
  289. package/src/field-types/utils/is-valid-required.ts +13 -0
  290. package/src/hooks/use-form-validity.ts +78 -156
  291. package/src/stories/dataform.story.tsx +126 -30
  292. package/src/stories/dataviews-picker.story.tsx +27 -17
  293. package/src/stories/dataviews.story.tsx +79 -30
  294. package/src/stories/field-types.story.tsx +86 -4
  295. package/src/test/filter-sort-and-paginate.js +2 -1
  296. package/src/test/normalize-fields.ts +87 -11
  297. package/src/test/use-form-validity.ts +796 -31
  298. package/src/types/field-api.ts +90 -4
  299. package/src/types/private.ts +26 -8
  300. package/src/utils/filter-sort-and-paginate.ts +5 -0
  301. package/src/utils/operators.tsx +448 -0
  302. package/tsconfig.json +1 -0
  303. package/tsconfig.tsbuildinfo +1 -1
package/src/constants.ts CHANGED
@@ -7,15 +7,18 @@ import { arrowDown, arrowUp } from '@wordpress/icons';
7
7
  /**
8
8
  * Internal dependencies
9
9
  */
10
- import type { Operator, DayNumber } from './types';
10
+ import type { DayNumber } from './types';
11
11
 
12
12
  // Filter operators.
13
- export const OPERATOR_IS = 'is';
14
- export const OPERATOR_IS_NOT = 'isNot';
15
13
  export const OPERATOR_IS_ANY = 'isAny';
16
14
  export const OPERATOR_IS_NONE = 'isNone';
17
15
  export const OPERATOR_IS_ALL = 'isAll';
18
16
  export const OPERATOR_IS_NOT_ALL = 'isNotAll';
17
+ export const OPERATOR_BETWEEN = 'between';
18
+ export const OPERATOR_IN_THE_PAST = 'inThePast';
19
+ export const OPERATOR_OVER = 'over';
20
+ export const OPERATOR_IS = 'is';
21
+ export const OPERATOR_IS_NOT = 'isNot';
19
22
  export const OPERATOR_LESS_THAN = 'lessThan';
20
23
  export const OPERATOR_GREATER_THAN = 'greaterThan';
21
24
  export const OPERATOR_LESS_THAN_OR_EQUAL = 'lessThanOrEqual';
@@ -27,145 +30,8 @@ export const OPERATOR_AFTER_INC = 'afterInc';
27
30
  export const OPERATOR_CONTAINS = 'contains';
28
31
  export const OPERATOR_NOT_CONTAINS = 'notContains';
29
32
  export const OPERATOR_STARTS_WITH = 'startsWith';
30
- export const OPERATOR_BETWEEN = 'between';
31
33
  export const OPERATOR_ON = 'on';
32
34
  export const OPERATOR_NOT_ON = 'notOn';
33
- export const OPERATOR_IN_THE_PAST = 'inThePast';
34
- export const OPERATOR_OVER = 'over';
35
-
36
- export const ALL_OPERATORS: Operator[] = [
37
- OPERATOR_IS,
38
- OPERATOR_IS_NOT,
39
- OPERATOR_IS_ANY,
40
- OPERATOR_IS_NONE,
41
- OPERATOR_IS_ALL,
42
- OPERATOR_IS_NOT_ALL,
43
- OPERATOR_LESS_THAN,
44
- OPERATOR_GREATER_THAN,
45
- OPERATOR_LESS_THAN_OR_EQUAL,
46
- OPERATOR_GREATER_THAN_OR_EQUAL,
47
- OPERATOR_BEFORE,
48
- OPERATOR_AFTER,
49
- OPERATOR_BEFORE_INC,
50
- OPERATOR_AFTER_INC,
51
- OPERATOR_CONTAINS,
52
- OPERATOR_NOT_CONTAINS,
53
- OPERATOR_STARTS_WITH,
54
- OPERATOR_BETWEEN,
55
- OPERATOR_ON,
56
- OPERATOR_NOT_ON,
57
- OPERATOR_IN_THE_PAST,
58
- OPERATOR_OVER,
59
- ];
60
-
61
- export const SINGLE_SELECTION_OPERATORS: Operator[] = [
62
- OPERATOR_IS,
63
- OPERATOR_IS_NOT,
64
- OPERATOR_LESS_THAN,
65
- OPERATOR_GREATER_THAN,
66
- OPERATOR_LESS_THAN_OR_EQUAL,
67
- OPERATOR_GREATER_THAN_OR_EQUAL,
68
- OPERATOR_BEFORE,
69
- OPERATOR_AFTER,
70
- OPERATOR_BEFORE_INC,
71
- OPERATOR_AFTER_INC,
72
- OPERATOR_CONTAINS,
73
- OPERATOR_NOT_CONTAINS,
74
- OPERATOR_STARTS_WITH,
75
- OPERATOR_ON,
76
- OPERATOR_NOT_ON,
77
- ];
78
-
79
- export const OPERATORS: Record< Operator, { key: string; label: string } > = {
80
- [ OPERATOR_IS ]: {
81
- key: 'is-filter',
82
- label: __( 'Is' ),
83
- },
84
- [ OPERATOR_IS_NOT ]: {
85
- key: 'is-not-filter',
86
- label: __( 'Is not' ),
87
- },
88
- [ OPERATOR_IS_ANY ]: {
89
- key: 'is-any-filter',
90
- label: __( 'Is any' ),
91
- },
92
- [ OPERATOR_IS_NONE ]: {
93
- key: 'is-none-filter',
94
- label: __( 'Is none' ),
95
- },
96
- [ OPERATOR_IS_ALL ]: {
97
- key: 'is-all-filter',
98
- label: __( 'Is all' ),
99
- },
100
- [ OPERATOR_IS_NOT_ALL ]: {
101
- key: 'is-not-all-filter',
102
- label: __( 'Is not all' ),
103
- },
104
- [ OPERATOR_LESS_THAN ]: {
105
- key: 'less-than-filter',
106
- label: __( 'Less than' ),
107
- },
108
- [ OPERATOR_GREATER_THAN ]: {
109
- key: 'greater-than-filter',
110
- label: __( 'Greater than' ),
111
- },
112
- [ OPERATOR_LESS_THAN_OR_EQUAL ]: {
113
- key: 'less-than-or-equal-filter',
114
- label: __( 'Less than or equal' ),
115
- },
116
- [ OPERATOR_GREATER_THAN_OR_EQUAL ]: {
117
- key: 'greater-than-or-equal-filter',
118
- label: __( 'Greater than or equal' ),
119
- },
120
- [ OPERATOR_BEFORE ]: {
121
- key: 'before-filter',
122
- label: __( 'Before' ),
123
- },
124
- [ OPERATOR_AFTER ]: {
125
- key: 'after-filter',
126
- label: __( 'After' ),
127
- },
128
- [ OPERATOR_BEFORE_INC ]: {
129
- key: 'before-inc-filter',
130
- label: __( 'Before (inc)' ),
131
- },
132
- [ OPERATOR_AFTER_INC ]: {
133
- key: 'after-inc-filter',
134
- label: __( 'After (inc)' ),
135
- },
136
- [ OPERATOR_CONTAINS ]: {
137
- key: 'contains-filter',
138
- label: __( 'Contains' ),
139
- },
140
- [ OPERATOR_NOT_CONTAINS ]: {
141
- key: 'not-contains-filter',
142
- label: __( "Doesn't contain" ),
143
- },
144
- [ OPERATOR_STARTS_WITH ]: {
145
- key: 'starts-with-filter',
146
- label: __( 'Starts with' ),
147
- },
148
- [ OPERATOR_BETWEEN ]: {
149
- key: 'between-filter',
150
- label: __( 'Between (inc)' ),
151
- },
152
- [ OPERATOR_ON ]: {
153
- key: 'on-filter',
154
- label: __( 'On' ),
155
- },
156
- [ OPERATOR_NOT_ON ]: {
157
- key: 'not-on-filter',
158
- label: __( 'Not on' ),
159
- },
160
- [ OPERATOR_IN_THE_PAST ]: {
161
- key: 'in-the-past-filter',
162
- label: __( 'In the past' ),
163
- },
164
- [ OPERATOR_OVER ]: {
165
- key: 'over-filter',
166
- label: __( 'Over' ),
167
- },
168
- };
169
35
 
170
36
  export const SORTING_DIRECTIONS = [ 'asc', 'desc' ] as const;
171
37
  export const sortArrows = { asc: '↑', desc: '↓' };
@@ -1,10 +1,10 @@
1
1
  /**
2
2
  * Internal dependencies
3
3
  */
4
- import type { DataFormControlProps } from '../types';
4
+ import type { DataFormControlProps, FormatNumber } from '../types';
5
5
  import ValidatedNumber from './utils/validated-number';
6
6
 
7
7
  export default function Number< Item >( props: DataFormControlProps< Item > ) {
8
- // TODO: remove this hardcoded value when the decimal number is configurable
9
- return <ValidatedNumber { ...props } decimals={ 2 } />;
8
+ const decimals = ( props.field.format as FormatNumber )?.decimals ?? 2;
9
+ return <ValidatedNumber { ...props } decimals={ decimals } />;
10
10
  }
@@ -33,7 +33,7 @@ export default function Textarea< Item >( {
33
33
 
34
34
  return (
35
35
  <ValidatedTextareaControl
36
- required={ !! isValid?.required }
36
+ required={ !! isValid.required }
37
37
  customValidity={ getCustomValidity( isValid, validity ) }
38
38
  label={ label }
39
39
  placeholder={ placeholder }
@@ -41,6 +41,12 @@ export default function Textarea< Item >( {
41
41
  help={ description }
42
42
  onChange={ onChangeControl }
43
43
  rows={ rows }
44
+ minLength={
45
+ isValid.minLength ? isValid.minLength.constraint : undefined
46
+ }
47
+ maxLength={
48
+ isValid.maxLength ? isValid.maxLength.constraint : undefined
49
+ }
44
50
  __next40pxDefaultSize
45
51
  __nextHasNoMarginBottom
46
52
  hideLabelFromVision={ hideLabelFromVision }
@@ -1,10 +1,10 @@
1
1
  /**
2
2
  * Internal dependencies
3
3
  */
4
- import type { Rules, FieldValidity } from '../../types';
4
+ import type { NormalizedRules, FieldValidity } from '../../types';
5
5
 
6
6
  export default function getCustomValidity< Item >(
7
- isValid: Rules< Item >,
7
+ isValid: NormalizedRules< Item >,
8
8
  validity: FieldValidity | undefined
9
9
  ) {
10
10
  let customValidity;
@@ -16,6 +16,14 @@ export default function getCustomValidity< Item >(
16
16
  : undefined;
17
17
  } else if ( isValid?.pattern && validity?.pattern ) {
18
18
  customValidity = validity.pattern;
19
+ } else if ( isValid?.min && validity?.min ) {
20
+ customValidity = validity.min;
21
+ } else if ( isValid?.max && validity?.max ) {
22
+ customValidity = validity.max;
23
+ } else if ( isValid?.minLength && validity?.minLength ) {
24
+ customValidity = validity.minLength;
25
+ } else if ( isValid?.maxLength && validity?.maxLength ) {
26
+ customValidity = validity.maxLength;
19
27
  } else if ( isValid?.elements && validity?.elements ) {
20
28
  customValidity = validity.elements;
21
29
  } else if ( validity?.custom ) {
@@ -56,7 +56,7 @@ export default function ValidatedText< Item >( {
56
56
 
57
57
  return (
58
58
  <ValidatedInputControl
59
- required={ !! isValid?.required }
59
+ required={ !! isValid.required }
60
60
  customValidity={ getCustomValidity( isValid, validity ) }
61
61
  label={ label }
62
62
  placeholder={ placeholder }
@@ -67,7 +67,13 @@ export default function ValidatedText< Item >( {
67
67
  type={ type }
68
68
  prefix={ prefix }
69
69
  suffix={ suffix }
70
- pattern={ isValid?.pattern }
70
+ pattern={ isValid.pattern ? isValid.pattern.constraint : undefined }
71
+ minLength={
72
+ isValid.minLength ? isValid.minLength.constraint : undefined
73
+ }
74
+ maxLength={
75
+ isValid.maxLength ? isValid.maxLength.constraint : undefined
76
+ }
71
77
  __next40pxDefaultSize
72
78
  />
73
79
  );
@@ -157,7 +157,7 @@ export default function ValidatedNumber< Item >( {
157
157
 
158
158
  return (
159
159
  <ValidatedNumberControl
160
- required={ !! isValid?.required }
160
+ required={ !! isValid.required }
161
161
  customValidity={ getCustomValidity( isValid, validity ) }
162
162
  label={ label }
163
163
  help={ description }
@@ -166,6 +166,8 @@ export default function ValidatedNumber< Item >( {
166
166
  __next40pxDefaultSize
167
167
  hideLabelFromVision={ hideLabelFromVision }
168
168
  step={ step }
169
+ min={ isValid.min ? isValid.min.constraint : undefined }
170
+ max={ isValid.max ? isValid.max.constraint : undefined }
169
171
  />
170
172
  );
171
173
  }
@@ -63,11 +63,20 @@ function ModalContent< Item >( {
63
63
  [ field ]
64
64
  );
65
65
 
66
- const { validity } = useFormValidity(
67
- modalData,
68
- fields as Field< any >[],
69
- form
70
- );
66
+ const fieldsAsFieldType: Field< Item >[] = fields.map( ( f ) => ( {
67
+ ...f,
68
+ Edit: f.Edit === null ? undefined : f.Edit,
69
+ isValid: {
70
+ required: f.isValid.required?.constraint,
71
+ elements: f.isValid.elements?.constraint,
72
+ min: f.isValid.min?.constraint,
73
+ max: f.isValid.max?.constraint,
74
+ pattern: f.isValid.pattern?.constraint,
75
+ minLength: f.isValid.minLength?.constraint,
76
+ maxLength: f.isValid.maxLength?.constraint,
77
+ },
78
+ } ) );
79
+ const { validity } = useFormValidity( modalData, fieldsAsFieldType, form );
71
80
 
72
81
  const onApply = () => {
73
82
  onChange( changes );
@@ -3,7 +3,7 @@
3
3
 
4
4
  .dataviews-view-activity {
5
5
  margin: 0 0 auto;
6
- padding: $grid-unit-10 $grid-unit-60;
6
+ padding: $grid-unit-10 $grid-unit-30;
7
7
 
8
8
  .dataviews-view-activity__group-header {
9
9
  font-size: $font-size-large;
@@ -2,7 +2,7 @@
2
2
  * External dependencies
3
3
  */
4
4
  import clsx from 'clsx';
5
- import type { ComponentProps, ReactElement } from 'react';
5
+ import type { ComponentProps, ReactElement, HTMLAttributes } from 'react';
6
6
 
7
7
  /**
8
8
  * WordPress dependencies
@@ -19,7 +19,7 @@ import {
19
19
  import { __, sprintf } from '@wordpress/i18n';
20
20
  import { useInstanceId } from '@wordpress/compose';
21
21
  import { isAppleOS } from '@wordpress/keycodes';
22
- import { useContext } from '@wordpress/element';
22
+ import { useContext, forwardRef } from '@wordpress/element';
23
23
 
24
24
  /**
25
25
  * Internal dependencies
@@ -50,7 +50,7 @@ function chunk< T >( array: T[], size: number ): T[][] {
50
50
  return chunks;
51
51
  }
52
52
 
53
- interface GridItemProps< Item > {
53
+ interface GridItemProps< Item > extends HTMLAttributes< HTMLDivElement > {
54
54
  view: ViewGridType;
55
55
  selection: string[];
56
56
  onChangeSelection: SetSelection;
@@ -75,24 +75,28 @@ interface GridItemProps< Item > {
75
75
  };
76
76
  }
77
77
 
78
- function GridItem< Item >( {
79
- view,
80
- selection,
81
- onChangeSelection,
82
- onClickItem,
83
- isItemClickable,
84
- renderItemLink,
85
- getItemId,
86
- item,
87
- actions,
88
- mediaField,
89
- titleField,
90
- descriptionField,
91
- regularFields,
92
- badgeFields,
93
- hasBulkActions,
94
- config,
95
- }: GridItemProps< Item > ) {
78
+ const GridItem = forwardRef( function GridItem< Item >(
79
+ {
80
+ view,
81
+ selection,
82
+ onChangeSelection,
83
+ onClickItem,
84
+ isItemClickable,
85
+ renderItemLink,
86
+ getItemId,
87
+ item,
88
+ actions,
89
+ mediaField,
90
+ titleField,
91
+ descriptionField,
92
+ regularFields,
93
+ badgeFields,
94
+ hasBulkActions,
95
+ config,
96
+ ...props
97
+ }: GridItemProps< Item >,
98
+ ref: React.ForwardedRef< HTMLDivElement >
99
+ ) {
96
100
  const { showTitle = true, showMedia = true, showDescription = true } = view;
97
101
  const hasBulkAction = useHasAPossibleBulkAction( actions, item );
98
102
  const id = getItemId( item );
@@ -129,12 +133,19 @@ function GridItem< Item >( {
129
133
  }
130
134
  return (
131
135
  <VStack
136
+ { ...props }
137
+ ref={ ref }
132
138
  spacing={ 0 }
133
- key={ id }
134
- className={ clsx( 'dataviews-view-grid__card', {
135
- 'is-selected': hasBulkAction && isSelected,
136
- } ) }
139
+ className={ clsx(
140
+ props.className,
141
+ 'dataviews-view-grid__row__gridcell',
142
+ 'dataviews-view-grid__card',
143
+ {
144
+ 'is-selected': hasBulkAction && isSelected,
145
+ }
146
+ ) }
137
147
  onClickCapture={ ( event ) => {
148
+ props.onClickCapture?.( event );
138
149
  if ( isAppleOS() ? event.metaKey : event.ctrlKey ) {
139
150
  event.stopPropagation();
140
151
  event.preventDefault();
@@ -270,7 +281,11 @@ function GridItem< Item >( {
270
281
  </VStack>
271
282
  </VStack>
272
283
  );
273
- }
284
+ } ) as < Item >(
285
+ props: GridItemProps< Item > & {
286
+ ref?: React.ForwardedRef< HTMLDivElement >;
287
+ }
288
+ ) => JSX.Element;
274
289
 
275
290
  interface CompositeGridProps< Item > {
276
291
  data: Item[];
@@ -383,10 +398,9 @@ export default function CompositeGrid< Item >( {
383
398
  return (
384
399
  <Composite.Item
385
400
  key={ getItemId( item ) }
386
- render={
387
- <div
388
- id={ getItemId( item ) }
389
- className="dataviews-view-grid__row__gridcell"
401
+ render={ ( props ) => (
402
+ <GridItem
403
+ { ...props }
390
404
  role={
391
405
  isInfiniteScroll
392
406
  ? 'article'
@@ -402,33 +416,26 @@ export default function CompositeGrid< Item >( {
402
416
  ? index + 1
403
417
  : undefined
404
418
  }
405
- >
406
- <GridItem
407
- view={ view }
408
- selection={ selection }
409
- onChangeSelection={
410
- onChangeSelection
411
- }
412
- onClickItem={ onClickItem }
413
- isItemClickable={ isItemClickable }
414
- renderItemLink={ renderItemLink }
415
- getItemId={ getItemId }
416
- item={ item }
417
- actions={ actions }
418
- mediaField={ mediaField }
419
- titleField={ titleField }
420
- descriptionField={
421
- descriptionField
422
- }
423
- regularFields={ regularFields }
424
- badgeFields={ badgeFields }
425
- hasBulkActions={ hasBulkActions }
426
- config={ {
427
- sizes: size,
428
- } }
429
- />
430
- </div>
431
- }
419
+ view={ view }
420
+ selection={ selection }
421
+ onChangeSelection={ onChangeSelection }
422
+ onClickItem={ onClickItem }
423
+ isItemClickable={ isItemClickable }
424
+ renderItemLink={ renderItemLink }
425
+ getItemId={ getItemId }
426
+ item={ item }
427
+ actions={ actions }
428
+ mediaField={ mediaField }
429
+ titleField={ titleField }
430
+ descriptionField={ descriptionField }
431
+ regularFields={ regularFields }
432
+ badgeFields={ badgeFields }
433
+ hasBulkActions={ hasBulkActions }
434
+ config={ {
435
+ sizes: size,
436
+ } }
437
+ />
438
+ ) }
432
439
  />
433
440
  );
434
441
  } ) }
@@ -5,21 +5,17 @@
5
5
  @use "../utils/grid-items.scss" as *;
6
6
 
7
7
  .dataviews-view-grid {
8
- padding: 0 $grid-unit-60 $grid-unit-30;
8
+ padding: 0 $grid-unit-30 $grid-unit-30;
9
9
  display: flex;
10
10
  flex-direction: column;
11
11
  gap: $grid-unit-40;
12
12
  container-type: inline-size;
13
+ margin-bottom: auto;
13
14
 
14
15
  @media not (prefers-reduced-motion) {
15
16
  transition: padding ease-out 0.1s;
16
17
  }
17
18
 
18
- @container (max-width: 430px) {
19
- padding-left: $grid-unit-30;
20
- padding-right: $grid-unit-30;
21
- }
22
-
23
19
  .dataviews-view-grid__row {
24
20
  display: grid;
25
21
  gap: $grid-unit-40;
@@ -223,11 +219,6 @@
223
219
  font-weight: $font-weight-medium;
224
220
  color: $gray-900;
225
221
  margin: 0 0 $grid-unit-10 0;
226
- padding: 0 $grid-unit-60;
222
+ padding: 0 $grid-unit-30;
227
223
  container-type: inline-size;
228
-
229
- @container (max-width: 430px) {
230
- padding-left: $grid-unit-30;
231
- padding-right: $grid-unit-30;
232
- }
233
224
  }
@@ -405,12 +405,18 @@ function ViewTable< Item >( {
405
405
  <col className="dataviews-view-table__col-checkbox" />
406
406
  ) }
407
407
  { hasPrimaryColumn && (
408
- <col className="dataviews-view-table__col-primary" />
408
+ <col className="dataviews-view-table__col-first-data" />
409
409
  ) }
410
- { columns.map( ( column ) => (
410
+ { columns.map( ( column, index ) => (
411
411
  <col
412
412
  key={ `col-${ column }` }
413
- className={ `dataviews-view-table__col-${ column }` }
413
+ className={ clsx(
414
+ `dataviews-view-table__col-${ column }`,
415
+ {
416
+ 'dataviews-view-table__col-first-data':
417
+ ! hasPrimaryColumn && index === 0,
418
+ }
419
+ ) }
414
420
  />
415
421
  ) ) }
416
422
  { !! actions?.length && (
@@ -61,12 +61,12 @@
61
61
 
62
62
  td:first-child,
63
63
  th:first-child {
64
- padding-left: $grid-unit-60;
64
+ padding-left: $grid-unit-30;
65
65
  }
66
66
 
67
67
  td:last-child,
68
68
  th:last-child {
69
- padding-right: $grid-unit-60;
69
+ padding-right: $grid-unit-30;
70
70
  }
71
71
 
72
72
  &:last-child {
@@ -260,17 +260,6 @@
260
260
  }
261
261
  }
262
262
 
263
- @container (max-width: 430px) {
264
- .dataviews-view-table tr td:first-child,
265
- .dataviews-view-table tr th:first-child {
266
- padding-left: $grid-unit-30;
267
- }
268
-
269
- .dataviews-view-table tr td:last-child,
270
- .dataviews-view-table tr th:last-child {
271
- padding-right: $grid-unit-30;
272
- }
273
- }
274
263
 
275
264
  .dataviews-view-table-selection-checkbox {
276
265
  --checkbox-input-size: 24px;
@@ -316,12 +305,12 @@
316
305
  .dataviews-view-table__group-header-row {
317
306
  .dataviews-view-table__group-header-cell {
318
307
  font-weight: $font-weight-medium;
319
- padding: $grid-unit-15 $grid-unit-60;
308
+ padding: $grid-unit-15 $grid-unit-30;
320
309
  color: $gray-900;
321
310
  }
322
311
  }
323
312
 
324
313
  /* Column width intents via colgroup: make non-primary columns shrink-to-fit */
325
- .dataviews-view-table col[class^="dataviews-view-table__col-"]:not(.dataviews-view-table__col-primary) {
314
+ .dataviews-view-table col[class^="dataviews-view-table__col-"]:not(.dataviews-view-table__col-first-data) {
326
315
  width: 1%;
327
316
  }
@@ -6,16 +6,8 @@
6
6
  gap: $grid-unit-40;
7
7
  grid-template-rows: max-content;
8
8
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
9
- padding: 0 $grid-unit-60 $grid-unit-30;
9
+ padding: 0 $grid-unit-30 $grid-unit-30;
10
10
  container-type: inline-size;
11
- /**
12
- * Breakpoints were adjusted from media queries breakpoints to account for
13
- * the sidebar width. This was done to match the existing styles we had.
14
- */
15
- @container (max-width: 430px) {
16
- padding-left: $grid-unit-30;
17
- padding-right: $grid-unit-30;
18
- }
19
11
 
20
12
  @media not (prefers-reduced-motion) {
21
13
  transition: padding ease-out 0.1s;