@wordpress/dataviews 14.0.0 → 14.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 (249) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +16 -5
  3. package/build/components/dataform-controls/array.cjs +2 -0
  4. package/build/components/dataform-controls/array.cjs.map +2 -2
  5. package/build/components/dataform-controls/checkbox.cjs +3 -1
  6. package/build/components/dataform-controls/checkbox.cjs.map +2 -2
  7. package/build/components/dataform-controls/color.cjs +8 -2
  8. package/build/components/dataform-controls/color.cjs.map +2 -2
  9. package/build/components/dataform-controls/date.cjs +31 -9
  10. package/build/components/dataform-controls/date.cjs.map +3 -3
  11. package/build/components/dataform-controls/datetime.cjs +9 -2
  12. package/build/components/dataform-controls/datetime.cjs.map +3 -3
  13. package/build/components/dataform-controls/password.cjs +4 -1
  14. package/build/components/dataform-controls/password.cjs.map +2 -2
  15. package/build/components/dataform-controls/radio.cjs +3 -1
  16. package/build/components/dataform-controls/radio.cjs.map +2 -2
  17. package/build/components/dataform-controls/select.cjs +3 -1
  18. package/build/components/dataform-controls/select.cjs.map +2 -2
  19. package/build/components/dataform-controls/textarea.cjs +2 -0
  20. package/build/components/dataform-controls/textarea.cjs.map +2 -2
  21. package/build/components/dataform-controls/toggle-group.cjs +3 -1
  22. package/build/components/dataform-controls/toggle-group.cjs.map +2 -2
  23. package/build/components/dataform-controls/toggle.cjs +3 -1
  24. package/build/components/dataform-controls/toggle.cjs.map +2 -2
  25. package/build/components/dataform-controls/utils/relative-date-control.cjs +5 -2
  26. package/build/components/dataform-controls/utils/relative-date-control.cjs.map +2 -2
  27. package/build/components/dataform-controls/utils/use-disabled-date-matchers.cjs +48 -0
  28. package/build/components/dataform-controls/utils/use-disabled-date-matchers.cjs.map +7 -0
  29. package/build/components/dataform-controls/utils/validated-input.cjs +2 -0
  30. package/build/components/dataform-controls/utils/validated-input.cjs.map +2 -2
  31. package/build/components/dataform-controls/utils/validated-number.cjs +3 -1
  32. package/build/components/dataform-controls/utils/validated-number.cjs.map +2 -2
  33. package/build/components/dataform-layouts/panel/summary-button.cjs +0 -1
  34. package/build/components/dataform-layouts/panel/summary-button.cjs.map +2 -2
  35. package/build/components/dataviews-context/index.cjs.map +1 -1
  36. package/build/components/dataviews-filters/input-widget.cjs +4 -0
  37. package/build/components/dataviews-filters/input-widget.cjs.map +2 -2
  38. package/build/components/dataviews-layouts/picker-grid/index.cjs +1 -4
  39. package/build/components/dataviews-layouts/picker-grid/index.cjs.map +2 -2
  40. package/build/components/dataviews-layouts/picker-table/index.cjs +15 -12
  41. package/build/components/dataviews-layouts/picker-table/index.cjs.map +2 -2
  42. package/build/components/dataviews-layouts/table/index.cjs +0 -1
  43. package/build/components/dataviews-layouts/table/index.cjs.map +2 -2
  44. package/build/components/dataviews-pagination/index.cjs +1 -0
  45. package/build/components/dataviews-pagination/index.cjs.map +2 -2
  46. package/build/dataviews/index.cjs +10 -8
  47. package/build/dataviews/index.cjs.map +2 -2
  48. package/build/dataviews-picker/index.cjs +16 -9
  49. package/build/dataviews-picker/index.cjs.map +2 -2
  50. package/build/field-types/date.cjs +4 -1
  51. package/build/field-types/date.cjs.map +2 -2
  52. package/build/field-types/datetime.cjs +4 -1
  53. package/build/field-types/datetime.cjs.map +2 -2
  54. package/build/field-types/index.cjs +1 -0
  55. package/build/field-types/index.cjs.map +2 -2
  56. package/build/field-types/utils/get-is-valid.cjs +29 -24
  57. package/build/field-types/utils/get-is-valid.cjs.map +2 -2
  58. package/build/field-types/utils/is-valid-date-boundary.cjs +64 -0
  59. package/build/field-types/utils/is-valid-date-boundary.cjs.map +7 -0
  60. package/build/types/dataviews.cjs.map +1 -1
  61. package/build/types/field-api.cjs.map +1 -1
  62. package/build-module/components/dataform-controls/array.mjs +2 -0
  63. package/build-module/components/dataform-controls/array.mjs.map +2 -2
  64. package/build-module/components/dataform-controls/checkbox.mjs +3 -1
  65. package/build-module/components/dataform-controls/checkbox.mjs.map +2 -2
  66. package/build-module/components/dataform-controls/color.mjs +8 -2
  67. package/build-module/components/dataform-controls/color.mjs.map +2 -2
  68. package/build-module/components/dataform-controls/date.mjs +31 -9
  69. package/build-module/components/dataform-controls/date.mjs.map +2 -2
  70. package/build-module/components/dataform-controls/datetime.mjs +9 -2
  71. package/build-module/components/dataform-controls/datetime.mjs.map +2 -2
  72. package/build-module/components/dataform-controls/password.mjs +4 -1
  73. package/build-module/components/dataform-controls/password.mjs.map +2 -2
  74. package/build-module/components/dataform-controls/radio.mjs +3 -1
  75. package/build-module/components/dataform-controls/radio.mjs.map +2 -2
  76. package/build-module/components/dataform-controls/select.mjs +3 -1
  77. package/build-module/components/dataform-controls/select.mjs.map +2 -2
  78. package/build-module/components/dataform-controls/textarea.mjs +2 -0
  79. package/build-module/components/dataform-controls/textarea.mjs.map +2 -2
  80. package/build-module/components/dataform-controls/toggle-group.mjs +3 -1
  81. package/build-module/components/dataform-controls/toggle-group.mjs.map +2 -2
  82. package/build-module/components/dataform-controls/toggle.mjs +3 -1
  83. package/build-module/components/dataform-controls/toggle.mjs.map +2 -2
  84. package/build-module/components/dataform-controls/utils/relative-date-control.mjs +5 -2
  85. package/build-module/components/dataform-controls/utils/relative-date-control.mjs.map +2 -2
  86. package/build-module/components/dataform-controls/utils/use-disabled-date-matchers.mjs +27 -0
  87. package/build-module/components/dataform-controls/utils/use-disabled-date-matchers.mjs.map +7 -0
  88. package/build-module/components/dataform-controls/utils/validated-input.mjs +2 -0
  89. package/build-module/components/dataform-controls/utils/validated-input.mjs.map +2 -2
  90. package/build-module/components/dataform-controls/utils/validated-number.mjs +3 -1
  91. package/build-module/components/dataform-controls/utils/validated-number.mjs.map +2 -2
  92. package/build-module/components/dataform-layouts/panel/summary-button.mjs +0 -1
  93. package/build-module/components/dataform-layouts/panel/summary-button.mjs.map +2 -2
  94. package/build-module/components/dataviews-context/index.mjs.map +1 -1
  95. package/build-module/components/dataviews-filters/input-widget.mjs +4 -0
  96. package/build-module/components/dataviews-filters/input-widget.mjs.map +2 -2
  97. package/build-module/components/dataviews-layouts/picker-grid/index.mjs +1 -4
  98. package/build-module/components/dataviews-layouts/picker-grid/index.mjs.map +2 -2
  99. package/build-module/components/dataviews-layouts/picker-table/index.mjs +15 -12
  100. package/build-module/components/dataviews-layouts/picker-table/index.mjs.map +2 -2
  101. package/build-module/components/dataviews-layouts/table/index.mjs +0 -1
  102. package/build-module/components/dataviews-layouts/table/index.mjs.map +2 -2
  103. package/build-module/components/dataviews-pagination/index.mjs +1 -0
  104. package/build-module/components/dataviews-pagination/index.mjs.map +2 -2
  105. package/build-module/dataviews/index.mjs +10 -8
  106. package/build-module/dataviews/index.mjs.map +2 -2
  107. package/build-module/dataviews-picker/index.mjs +16 -9
  108. package/build-module/dataviews-picker/index.mjs.map +2 -2
  109. package/build-module/field-types/date.mjs +4 -1
  110. package/build-module/field-types/date.mjs.map +2 -2
  111. package/build-module/field-types/datetime.mjs +4 -1
  112. package/build-module/field-types/datetime.mjs.map +2 -2
  113. package/build-module/field-types/index.mjs +1 -0
  114. package/build-module/field-types/index.mjs.map +2 -2
  115. package/build-module/field-types/utils/get-is-valid.mjs +29 -24
  116. package/build-module/field-types/utils/get-is-valid.mjs.map +2 -2
  117. package/build-module/field-types/utils/is-valid-date-boundary.mjs +38 -0
  118. package/build-module/field-types/utils/is-valid-date-boundary.mjs.map +7 -0
  119. package/build-style/style-rtl.css +14 -15
  120. package/build-style/style.css +14 -15
  121. package/build-types/components/dataform-controls/array.d.ts.map +1 -1
  122. package/build-types/components/dataform-controls/checkbox.d.ts.map +1 -1
  123. package/build-types/components/dataform-controls/color.d.ts.map +1 -1
  124. package/build-types/components/dataform-controls/date.d.ts.map +1 -1
  125. package/build-types/components/dataform-controls/datetime.d.ts.map +1 -1
  126. package/build-types/components/dataform-controls/password.d.ts.map +1 -1
  127. package/build-types/components/dataform-controls/radio.d.ts.map +1 -1
  128. package/build-types/components/dataform-controls/select.d.ts.map +1 -1
  129. package/build-types/components/dataform-controls/textarea.d.ts.map +1 -1
  130. package/build-types/components/dataform-controls/toggle-group.d.ts.map +1 -1
  131. package/build-types/components/dataform-controls/toggle.d.ts.map +1 -1
  132. package/build-types/components/dataform-controls/utils/relative-date-control.d.ts.map +1 -1
  133. package/build-types/components/dataform-controls/utils/use-disabled-date-matchers.d.ts +16 -0
  134. package/build-types/components/dataform-controls/utils/use-disabled-date-matchers.d.ts.map +1 -0
  135. package/build-types/components/dataform-controls/utils/validated-input.d.ts.map +1 -1
  136. package/build-types/components/dataform-controls/utils/validated-number.d.ts.map +1 -1
  137. package/build-types/components/dataform-layouts/panel/summary-button.d.ts.map +1 -1
  138. package/build-types/components/dataviews-context/index.d.ts +2 -2
  139. package/build-types/components/dataviews-context/index.d.ts.map +1 -1
  140. package/build-types/components/dataviews-filters/input-widget.d.ts.map +1 -1
  141. package/build-types/components/dataviews-layouts/index.d.ts +6 -6
  142. package/build-types/components/dataviews-layouts/picker-grid/index.d.ts.map +1 -1
  143. package/build-types/components/dataviews-layouts/picker-table/index.d.ts.map +1 -1
  144. package/build-types/components/dataviews-layouts/table/index.d.ts.map +1 -1
  145. package/build-types/components/dataviews-pagination/index.d.ts.map +1 -1
  146. package/build-types/components/dataviews-search/index.d.ts +1 -1
  147. package/build-types/components/dataviews-search/index.d.ts.map +1 -1
  148. package/build-types/constants.d.ts +2 -2
  149. package/build-types/dataform/stories/index.story.d.ts +11 -1
  150. package/build-types/dataform/stories/index.story.d.ts.map +1 -1
  151. package/build-types/dataform/stories/layout-regular.d.ts +2 -1
  152. package/build-types/dataform/stories/layout-regular.d.ts.map +1 -1
  153. package/build-types/dataform/stories/validation.d.ts.map +1 -1
  154. package/build-types/dataviews/index.d.ts +1 -1
  155. package/build-types/dataviews/index.d.ts.map +1 -1
  156. package/build-types/dataviews-picker/index.d.ts +3 -2
  157. package/build-types/dataviews-picker/index.d.ts.map +1 -1
  158. package/build-types/dataviews-picker/stories/index.story.d.ts.map +1 -1
  159. package/build-types/field-types/array.d.ts +1 -1
  160. package/build-types/field-types/array.d.ts.map +1 -1
  161. package/build-types/field-types/boolean.d.ts +1 -1
  162. package/build-types/field-types/boolean.d.ts.map +1 -1
  163. package/build-types/field-types/color.d.ts +1 -1
  164. package/build-types/field-types/color.d.ts.map +1 -1
  165. package/build-types/field-types/date.d.ts +3 -0
  166. package/build-types/field-types/date.d.ts.map +1 -1
  167. package/build-types/field-types/datetime.d.ts +3 -0
  168. package/build-types/field-types/datetime.d.ts.map +1 -1
  169. package/build-types/field-types/email.d.ts +1 -1
  170. package/build-types/field-types/email.d.ts.map +1 -1
  171. package/build-types/field-types/index.d.ts.map +1 -1
  172. package/build-types/field-types/integer.d.ts +1 -1
  173. package/build-types/field-types/integer.d.ts.map +1 -1
  174. package/build-types/field-types/number.d.ts +1 -1
  175. package/build-types/field-types/number.d.ts.map +1 -1
  176. package/build-types/field-types/stories/index.story.d.ts +37 -15
  177. package/build-types/field-types/stories/index.story.d.ts.map +1 -1
  178. package/build-types/field-types/utils/get-is-valid.d.ts.map +1 -1
  179. package/build-types/field-types/utils/is-valid-date-boundary.d.ts +7 -0
  180. package/build-types/field-types/utils/is-valid-date-boundary.d.ts.map +1 -0
  181. package/build-types/types/dataviews.d.ts +8 -0
  182. package/build-types/types/dataviews.d.ts.map +1 -1
  183. package/build-types/types/field-api.d.ts +24 -9
  184. package/build-types/types/field-api.d.ts.map +1 -1
  185. package/build-wp/index.js +1141 -990
  186. package/package.json +16 -16
  187. package/src/components/dataform-controls/array.tsx +2 -0
  188. package/src/components/dataform-controls/checkbox.tsx +2 -0
  189. package/src/components/dataform-controls/color.tsx +7 -0
  190. package/src/components/dataform-controls/date.tsx +30 -4
  191. package/src/components/dataform-controls/datetime.tsx +17 -0
  192. package/src/components/dataform-controls/password.tsx +3 -0
  193. package/src/components/dataform-controls/radio.tsx +2 -0
  194. package/src/components/dataform-controls/select.tsx +2 -0
  195. package/src/components/dataform-controls/textarea.tsx +2 -0
  196. package/src/components/dataform-controls/toggle-group.tsx +2 -0
  197. package/src/components/dataform-controls/toggle.tsx +2 -0
  198. package/src/components/dataform-controls/utils/relative-date-control.tsx +3 -0
  199. package/src/components/dataform-controls/utils/use-disabled-date-matchers.ts +48 -0
  200. package/src/components/dataform-controls/utils/validated-input.tsx +2 -0
  201. package/src/components/dataform-controls/utils/validated-number.tsx +2 -0
  202. package/src/components/dataform-layouts/panel/style.scss +4 -5
  203. package/src/components/dataform-layouts/panel/summary-button.tsx +0 -1
  204. package/src/components/dataviews-context/index.ts +2 -2
  205. package/src/components/dataviews-filters/input-widget.tsx +4 -0
  206. package/src/components/dataviews-filters/style.scss +2 -2
  207. package/src/components/dataviews-layouts/activity/style.scss +3 -3
  208. package/src/components/dataviews-layouts/grid/style.scss +1 -1
  209. package/src/components/dataviews-layouts/list/style.scss +1 -1
  210. package/src/components/dataviews-layouts/picker-grid/index.tsx +2 -6
  211. package/src/components/dataviews-layouts/picker-grid/style.scss +1 -1
  212. package/src/components/dataviews-layouts/picker-table/index.tsx +9 -7
  213. package/src/components/dataviews-layouts/picker-table/style.scss +1 -1
  214. package/src/components/dataviews-layouts/table/index.tsx +0 -2
  215. package/src/components/dataviews-pagination/index.tsx +1 -0
  216. package/src/dataform/stories/content.story.tsx +1 -1
  217. package/src/dataform/stories/data-adapter.tsx +6 -6
  218. package/src/dataform/stories/index.story.tsx +7 -0
  219. package/src/dataform/stories/layout-card.tsx +5 -5
  220. package/src/dataform/stories/layout-details.tsx +5 -5
  221. package/src/dataform/stories/layout-panel.tsx +9 -9
  222. package/src/dataform/stories/layout-regular.tsx +31 -10
  223. package/src/dataform/stories/layout-row.tsx +9 -9
  224. package/src/dataform/stories/validation.tsx +25 -10
  225. package/src/dataviews/index.tsx +11 -7
  226. package/src/dataviews/stories/empty.tsx +4 -4
  227. package/src/dataviews/stories/free-composition.tsx +2 -2
  228. package/src/dataviews/stories/infinite-scroll.tsx +4 -4
  229. package/src/dataviews/stories/layout-custom.tsx +1 -1
  230. package/src/dataviews/stories/layout-grid.tsx +1 -1
  231. package/src/dataviews/stories/layout-list.tsx +1 -1
  232. package/src/dataviews/stories/layout-table.tsx +1 -1
  233. package/src/dataviews/stories/minimal-ui.tsx +1 -1
  234. package/src/dataviews/stories/with-card.tsx +4 -4
  235. package/src/dataviews/style.scss +1 -1
  236. package/src/dataviews/test/dataviews.tsx +73 -6
  237. package/src/dataviews-picker/index.tsx +17 -7
  238. package/src/dataviews-picker/stories/index.story.tsx +1 -5
  239. package/src/dataviews-picker/test/dataviews-picker.tsx +79 -2
  240. package/src/field-types/date.tsx +3 -0
  241. package/src/field-types/datetime.tsx +3 -0
  242. package/src/field-types/index.tsx +4 -0
  243. package/src/field-types/stories/index.story.tsx +67 -6
  244. package/src/field-types/test/normalize-fields.ts +44 -0
  245. package/src/field-types/utils/get-is-valid.ts +44 -31
  246. package/src/field-types/utils/is-valid-date-boundary.ts +80 -0
  247. package/src/hooks/test/use-form-validity.ts +479 -0
  248. package/src/types/dataviews.ts +9 -0
  249. package/src/types/field-api.ts +27 -9
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/field-types/utils/is-valid-date-boundary.ts"],
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport { isValid as isValidDate } from 'date-fns';\n\n/**\n * WordPress dependencies\n */\nimport { getDate } from '@wordpress/date';\n\n/**\n * Internal dependencies\n */\nimport type { NormalizedField } from '../../types';\n\ntype Boundary = 'min' | 'max';\n\nfunction parseDateLike( value?: string ) {\n\tif ( ! value ) {\n\t\treturn null;\n\t}\n\n\t// Pre-check to avoid passing unparseable strings to getDate,\n\t// which uses moment.js and emits deprecation warnings.\n\tif ( ! isValidDate( new Date( value ) ) ) {\n\t\treturn null;\n\t}\n\n\tconst parsed = getDate( value );\n\treturn parsed && isValidDate( parsed ) ? parsed : null;\n}\n\nfunction validateDateLikeBoundary< Item >(\n\titem: Item,\n\tfield: NormalizedField< Item >,\n\tboundary: Boundary\n): boolean {\n\tconst constraint = field.isValid[ boundary ]?.constraint;\n\tif ( typeof constraint !== 'string' ) {\n\t\treturn false;\n\t}\n\n\tconst value = field.getValue( { item } );\n\tconst boundaryValue = Array.isArray( value )\n\t\t? value[ boundary === 'min' ? 0 : value.length - 1 ]\n\t\t: value;\n\n\tif (\n\t\tboundaryValue === undefined ||\n\t\tboundaryValue === null ||\n\t\tboundaryValue === ''\n\t) {\n\t\treturn true;\n\t}\n\n\tconst parsedConstraint = parseDateLike( constraint );\n\tconst parsedValue = parseDateLike( String( boundaryValue ) );\n\n\treturn (\n\t\t!! parsedConstraint &&\n\t\t!! parsedValue &&\n\t\t( boundary === 'min'\n\t\t\t? parsedValue.getTime() >= parsedConstraint.getTime()\n\t\t\t: parsedValue.getTime() <= parsedConstraint.getTime() )\n\t);\n}\n\nexport function isValidMinDate< Item >(\n\titem: Item,\n\tfield: NormalizedField< Item >\n): boolean {\n\treturn validateDateLikeBoundary( item, field, 'min' );\n}\n\nexport function isValidMaxDate< Item >(\n\titem: Item,\n\tfield: NormalizedField< Item >\n): boolean {\n\treturn validateDateLikeBoundary( item, field, 'max' );\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,sBAAuC;AAKvC,kBAAwB;AASxB,SAAS,cAAe,OAAiB;AACxC,MAAK,CAAE,OAAQ;AACd,WAAO;AAAA,EACR;AAIA,MAAK,KAAE,gBAAAA,SAAa,IAAI,KAAM,KAAM,CAAE,GAAI;AACzC,WAAO;AAAA,EACR;AAEA,QAAM,aAAS,qBAAS,KAAM;AAC9B,SAAO,cAAU,gBAAAA,SAAa,MAAO,IAAI,SAAS;AACnD;AAEA,SAAS,yBACR,MACA,OACA,UACU;AACV,QAAM,aAAa,MAAM,QAAS,QAAS,GAAG;AAC9C,MAAK,OAAO,eAAe,UAAW;AACrC,WAAO;AAAA,EACR;AAEA,QAAM,QAAQ,MAAM,SAAU,EAAE,KAAK,CAAE;AACvC,QAAM,gBAAgB,MAAM,QAAS,KAAM,IACxC,MAAO,aAAa,QAAQ,IAAI,MAAM,SAAS,CAAE,IACjD;AAEH,MACC,kBAAkB,UAClB,kBAAkB,QAClB,kBAAkB,IACjB;AACD,WAAO;AAAA,EACR;AAEA,QAAM,mBAAmB,cAAe,UAAW;AACnD,QAAM,cAAc,cAAe,OAAQ,aAAc,CAAE;AAE3D,SACC,CAAC,CAAE,oBACH,CAAC,CAAE,gBACD,aAAa,QACZ,YAAY,QAAQ,KAAK,iBAAiB,QAAQ,IAClD,YAAY,QAAQ,KAAK,iBAAiB,QAAQ;AAEvD;AAEO,SAAS,eACf,MACA,OACU;AACV,SAAO,yBAA0B,MAAM,OAAO,KAAM;AACrD;AAEO,SAAS,eACf,MACA,OACU;AACV,SAAO,yBAA0B,MAAM,OAAO,KAAM;AACrD;",
6
+ "names": ["isValidDate"]
7
+ }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/types/dataviews.ts"],
4
- "sourcesContent": ["/**\n * External dependencies\n */\nimport type { ReactElement, ReactNode, ComponentProps } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport type { useFocusOnMount } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport type {\n\tNormalizedField,\n\tOperator,\n\tOption,\n\tSortDirection,\n} from './field-api';\nimport type { SetSelection } from './private';\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\t/**\n\t * Whether the filter can be edited by the user.\n\t */\n\tisLocked?: boolean;\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 * Retrieval function to get the elements.\n\t */\n\tgetElements?: () => Promise< Option[] >;\n\n\t/**\n\t * Whether the filter has elements.\n\t */\n\thasElements: boolean;\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\t/**\n\t * Whether the filter can be edited by the user.\n\t */\n\tisLocked: 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 * Also used as the batch size when infinite scroll is enabled.\n\t */\n\tperPage?: number;\n\n\t/**\n\t * The fields to render\n\t */\n\tfields?: string[];\n\n\t/**\n\t * Title field\n\t */\n\ttitleField?: string;\n\n\t/**\n\t * Media field\n\t */\n\tmediaField?: string;\n\n\t/**\n\t * Description field\n\t */\n\tdescriptionField?: string;\n\n\t/**\n\t * Whether to show the title\n\t */\n\tshowTitle?: boolean;\n\n\t/**\n\t * Whether to show the media\n\t */\n\tshowMedia?: boolean;\n\n\t/**\n\t * Whether to show the description\n\t */\n\tshowDescription?: boolean;\n\n\t/**\n\t * Whether to show the hierarchical levels.\n\t */\n\tshowLevels?: boolean;\n\n\t/**\n\t * The grouping configuration.\n\t */\n\tgroupBy?: {\n\t\t/**\n\t\t * The field to group 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\n\t\t/**\n\t\t * Whether to show the field label in the group header.\n\t\t *\n\t\t * @default true\n\t\t */\n\t\tshowLabel?: boolean;\n\t};\n\n\t/**\n\t * Whether infinite scroll is enabled.\n\t */\n\tinfiniteScrollEnabled?: boolean;\n\n\t/**\n\t * The start position for infinite scroll (1-indexed).\n\t * Used when infiniteScrollEnabled is true.\n\t */\n\tstartPosition?: number;\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\t/**\n\t * The alignment of the field column, defaults to left.\n\t */\n\talign?: 'start' | 'center' | 'end';\n}\n\nexport type Density = 'compact' | 'balanced' | 'comfortable';\n\nexport interface ViewTable extends ViewBase {\n\ttype: 'table';\n\n\tlayout?: {\n\t\t/**\n\t\t * The styles for the columns.\n\t\t */\n\t\tstyles?: Record< string, ColumnStyle >;\n\n\t\t/**\n\t\t * The density of the view.\n\t\t */\n\t\tdensity?: Density;\n\n\t\t/**\n\t\t * Whether the view allows column moving.\n\t\t */\n\t\tenableMoving?: boolean;\n\t};\n}\n\nexport interface ViewList extends ViewBase {\n\ttype: 'list';\n\n\tlayout?: {\n\t\t/**\n\t\t * The density of the view.\n\t\t */\n\t\tdensity?: Density;\n\t};\n}\n\nexport interface ViewActivity extends ViewBase {\n\ttype: 'activity';\n\n\tlayout?: {\n\t\t/**\n\t\t * The density of the view.\n\t\t */\n\t\tdensity?: Density;\n\t};\n}\n\nexport interface ViewGrid extends ViewBase {\n\ttype: 'grid';\n\n\tlayout?: {\n\t\t/**\n\t\t * The fields to use as badge fields.\n\t\t */\n\t\tbadgeFields?: string[];\n\n\t\t/**\n\t\t * The preview size of the grid.\n\t\t */\n\t\tpreviewSize?: number;\n\n\t\t/**\n\t\t * The density of the grid layout.\n\t\t */\n\t\tdensity?: Density;\n\t};\n}\n\nexport interface ViewPickerGrid extends ViewBase {\n\ttype: 'pickerGrid';\n\n\tlayout?: {\n\t\t/**\n\t\t * The fields to use as badge fields.\n\t\t */\n\t\tbadgeFields?: string[];\n\n\t\t/**\n\t\t * The preview size of the grid.\n\t\t */\n\t\tpreviewSize?: number;\n\n\t\t/**\n\t\t * The density of the grid layout.\n\t\t */\n\t\tdensity?: Density;\n\t};\n}\n\nexport interface ViewPickerTable extends ViewBase {\n\ttype: 'pickerTable';\n\n\tlayout?: {\n\t\t/**\n\t\t * The styles for the columns.\n\t\t */\n\t\tstyles?: Record< string, ColumnStyle >;\n\n\t\t/**\n\t\t * The density of the view.\n\t\t */\n\t\tdensity?: Density;\n\n\t\t/**\n\t\t * Whether the view allows column moving.\n\t\t */\n\t\tenableMoving?: boolean;\n\t};\n}\n\nexport type View =\n\t| ViewList\n\t| ViewGrid\n\t| ViewTable\n\t| ViewPickerGrid\n\t| ViewPickerTable\n\t| ViewActivity;\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 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 | ( ( items: Item[] ) => string );\n\n\t/**\n\t * The size of the modal.\n\t *\n\t * @default 'medium'\n\t */\n\tmodalSize?: 'small' | 'medium' | 'large' | 'fill';\n\n\t/**\n\t * The focus on mount property of the modal.\n\t */\n\tmodalFocusOnMount?:\n\t\t| Parameters< typeof useFocusOnMount >[ 0 ]\n\t\t| 'firstContentElement';\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\tclassName?: string;\n\tactions: Action< Item >[];\n\tdata: Item[];\n\tfields: NormalizedField< Item >[];\n\tgetItemId: ( item: Item ) => string;\n\tgetItemLevel?: ( item: Item ) => number;\n\tisLoading?: boolean;\n\tonChangeView: ( view: View ) => void;\n\tonChangeSelection: SetSelection;\n\tselection: string[];\n\tsetOpenedFilter: ( fieldId: string ) => void;\n\tonClickItem?: ( item: Item ) => void;\n\trenderItemLink?: (\n\t\tprops: {\n\t\t\titem: Item;\n\t\t} & ComponentProps< 'a' >\n\t) => ReactElement;\n\tisItemClickable: ( item: Item ) => boolean;\n\tview: View;\n\tempty: ReactNode;\n}\n\nexport type ViewPickerBaseProps< Item > = Omit<\n\tViewBaseProps< Item >,\n\t| 'view'\n\t| 'onChangeView'\n\t// The following props are not supported for pickers.\n\t| 'isItemClickable'\n\t| 'onClickItem'\n\t| 'renderItemLink'\n\t| 'getItemLevel'\n> & {\n\tview: View;\n\tonChangeView: ( view: View ) => void;\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 ViewActivityProps< Item > extends ViewBaseProps< Item > {\n\tview: ViewActivity;\n}\n\nexport interface ViewGridProps< Item > extends ViewBaseProps< Item > {\n\tview: ViewGrid;\n}\n\nexport interface ViewPickerGridProps< Item >\n\textends Omit< ViewPickerBaseProps< Item >, 'view' > {\n\tview: ViewPickerGrid;\n}\n\nexport interface ViewPickerTableProps< Item >\n\textends Omit< ViewPickerBaseProps< Item >, 'view' > {\n\tview: ViewPickerTable;\n}\n\nexport type ViewProps< Item > =\n\t| ViewTableProps< Item >\n\t| ViewGridProps< Item >\n\t| ViewListProps< Item >\n\t| ViewActivityProps< Item >;\n\nexport type ViewPickerProps< Item > =\n\t| ViewPickerGridProps< Item >\n\t| ViewPickerTableProps< Item >;\n\nexport interface SupportedLayouts {\n\tlist?: Omit< ViewList, 'type' >;\n\tgrid?: Omit< ViewGrid, 'type' >;\n\ttable?: Omit< ViewTable, 'type' >;\n\tactivity?: Omit< ViewActivity, 'type' >;\n\tpickerGrid?: Omit< ViewPickerGrid, 'type' >;\n\tpickerTable?: Omit< ViewPickerTable, 'type' >;\n}\n"],
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport type { ReactElement, ReactNode, ComponentProps } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport type { useFocusOnMount } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport type {\n\tNormalizedField,\n\tOperator,\n\tOption,\n\tSortDirection,\n} from './field-api';\nimport type { SetSelection } from './private';\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\t/**\n\t * Whether the filter can be edited by the user.\n\t */\n\tisLocked?: boolean;\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 * Retrieval function to get the elements.\n\t */\n\tgetElements?: () => Promise< Option[] >;\n\n\t/**\n\t * Whether the filter has elements.\n\t */\n\thasElements: boolean;\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\t/**\n\t * Whether the filter can be edited by the user.\n\t */\n\tisLocked: 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 * Also used as the batch size when infinite scroll is enabled.\n\t */\n\tperPage?: number;\n\n\t/**\n\t * The fields to render\n\t */\n\tfields?: string[];\n\n\t/**\n\t * Title field\n\t */\n\ttitleField?: string;\n\n\t/**\n\t * Media field\n\t */\n\tmediaField?: string;\n\n\t/**\n\t * Description field\n\t */\n\tdescriptionField?: string;\n\n\t/**\n\t * Whether to show the title\n\t */\n\tshowTitle?: boolean;\n\n\t/**\n\t * Whether to show the media\n\t */\n\tshowMedia?: boolean;\n\n\t/**\n\t * Whether to show the description\n\t */\n\tshowDescription?: boolean;\n\n\t/**\n\t * Whether to show the hierarchical levels.\n\t */\n\tshowLevels?: boolean;\n\n\t/**\n\t * The grouping configuration.\n\t */\n\tgroupBy?: {\n\t\t/**\n\t\t * The field to group 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\n\t\t/**\n\t\t * Whether to show the field label in the group header.\n\t\t *\n\t\t * @default true\n\t\t */\n\t\tshowLabel?: boolean;\n\t};\n\n\t/**\n\t * Whether infinite scroll is enabled.\n\t */\n\tinfiniteScrollEnabled?: boolean;\n\n\t/**\n\t * The start position for infinite scroll (1-indexed).\n\t * Used when infiniteScrollEnabled is true.\n\t */\n\tstartPosition?: number;\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\t/**\n\t * The alignment of the field column, defaults to left.\n\t */\n\talign?: 'start' | 'center' | 'end';\n}\n\nexport type Density = 'compact' | 'balanced' | 'comfortable';\n\nexport interface ViewTable extends ViewBase {\n\ttype: 'table';\n\n\tlayout?: {\n\t\t/**\n\t\t * The styles for the columns.\n\t\t */\n\t\tstyles?: Record< string, ColumnStyle >;\n\n\t\t/**\n\t\t * The density of the view.\n\t\t */\n\t\tdensity?: Density;\n\n\t\t/**\n\t\t * Whether the view allows column moving.\n\t\t */\n\t\tenableMoving?: boolean;\n\t};\n}\n\nexport interface ViewList extends ViewBase {\n\ttype: 'list';\n\n\tlayout?: {\n\t\t/**\n\t\t * The density of the view.\n\t\t */\n\t\tdensity?: Density;\n\t};\n}\n\nexport interface ViewActivity extends ViewBase {\n\ttype: 'activity';\n\n\tlayout?: {\n\t\t/**\n\t\t * The density of the view.\n\t\t */\n\t\tdensity?: Density;\n\t};\n}\n\nexport interface ViewGrid extends ViewBase {\n\ttype: 'grid';\n\n\tlayout?: {\n\t\t/**\n\t\t * The fields to use as badge fields.\n\t\t */\n\t\tbadgeFields?: string[];\n\n\t\t/**\n\t\t * The preview size of the grid.\n\t\t */\n\t\tpreviewSize?: number;\n\n\t\t/**\n\t\t * The density of the grid layout.\n\t\t */\n\t\tdensity?: Density;\n\t};\n}\n\nexport interface ViewPickerGrid extends ViewBase {\n\ttype: 'pickerGrid';\n\n\tlayout?: {\n\t\t/**\n\t\t * The fields to use as badge fields.\n\t\t */\n\t\tbadgeFields?: string[];\n\n\t\t/**\n\t\t * The preview size of the grid.\n\t\t */\n\t\tpreviewSize?: number;\n\n\t\t/**\n\t\t * The density of the grid layout.\n\t\t */\n\t\tdensity?: Density;\n\t};\n}\n\nexport interface ViewPickerTable extends ViewBase {\n\ttype: 'pickerTable';\n\n\tlayout?: {\n\t\t/**\n\t\t * The styles for the columns.\n\t\t */\n\t\tstyles?: Record< string, ColumnStyle >;\n\n\t\t/**\n\t\t * The density of the view.\n\t\t */\n\t\tdensity?: Density;\n\n\t\t/**\n\t\t * Whether the view allows column moving.\n\t\t */\n\t\tenableMoving?: boolean;\n\t};\n}\n\nexport type View =\n\t| ViewList\n\t| ViewGrid\n\t| ViewTable\n\t| ViewPickerGrid\n\t| ViewPickerTable\n\t| ViewActivity;\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 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 | ( ( items: Item[] ) => string );\n\n\t/**\n\t * The size of the modal.\n\t *\n\t * @default 'medium'\n\t */\n\tmodalSize?: 'small' | 'medium' | 'large' | 'fill';\n\n\t/**\n\t * The focus on mount property of the modal.\n\t */\n\tmodalFocusOnMount?:\n\t\t| Parameters< typeof useFocusOnMount >[ 0 ]\n\t\t| 'firstContentElement';\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\tclassName?: string;\n\tactions: Action< Item >[];\n\tdata: Item[];\n\tfields: NormalizedField< Item >[];\n\tgetItemId: ( item: Item ) => string;\n\tgetItemLevel?: ( item: Item ) => number;\n\tisLoading?: boolean;\n\tonChangeView: ( view: View ) => void;\n\tonChangeSelection: SetSelection;\n\tselection: string[];\n\tsetOpenedFilter: ( fieldId: string ) => void;\n\tonClickItem?: ( item: Item ) => void;\n\trenderItemLink?: (\n\t\tprops: {\n\t\t\titem: Item;\n\t\t} & ComponentProps< 'a' >\n\t) => ReactElement;\n\tisItemClickable: ( item: Item ) => boolean;\n\tview: View;\n\tempty: ReactNode;\n}\n\nexport type ViewPickerBaseProps< Item > = Omit<\n\tViewBaseProps< Item >,\n\t| 'view'\n\t| 'onChangeView'\n\t// The following props are not supported for pickers.\n\t| 'isItemClickable'\n\t| 'onClickItem'\n\t| 'renderItemLink'\n\t| 'getItemLevel'\n> & {\n\tview: View;\n\tonChangeView: ( view: View ) => void;\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 ViewActivityProps< Item > extends ViewBaseProps< Item > {\n\tview: ViewActivity;\n}\n\nexport interface ViewGridProps< Item > extends ViewBaseProps< Item > {\n\tview: ViewGrid;\n}\n\nexport interface ViewPickerGridProps< Item >\n\textends Omit< ViewPickerBaseProps< Item >, 'view' > {\n\tview: ViewPickerGrid;\n}\n\nexport interface ViewPickerTableProps< Item >\n\textends Omit< ViewPickerBaseProps< Item >, 'view' > {\n\tview: ViewPickerTable;\n}\n\nexport type ViewProps< Item > =\n\t| ViewTableProps< Item >\n\t| ViewGridProps< Item >\n\t| ViewListProps< Item >\n\t| ViewActivityProps< Item >;\n\nexport type ViewPickerProps< Item > =\n\t| ViewPickerGridProps< Item >\n\t| ViewPickerTableProps< Item >;\n\nexport interface SupportedLayouts {\n\tlist?: Omit< ViewList, 'type' > | true;\n\tgrid?: Omit< ViewGrid, 'type' > | true;\n\ttable?: Omit< ViewTable, 'type' > | true;\n\tactivity?: Omit< ViewActivity, 'type' > | true;\n\tpickerGrid?: Omit< ViewPickerGrid, 'type' > | true;\n\tpickerTable?: Omit< ViewPickerTable, 'type' > | true;\n}\n\nexport interface NormalizedSupportedLayouts {\n\tlist?: Omit< ViewList, 'type' >;\n\tgrid?: Omit< ViewGrid, 'type' >;\n\ttable?: Omit< ViewTable, 'type' >;\n\tactivity?: Omit< ViewActivity, 'type' >;\n\tpickerGrid?: Omit< ViewPickerGrid, 'type' >;\n\tpickerTable?: Omit< ViewPickerTable, 'type' >;\n}\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;AAAA;AAAA;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/types/field-api.ts"],
4
- "sourcesContent": ["/**\n * External dependencies\n */\nimport type { ReactElement, ComponentType } from 'react';\n\n/**\n * Utility type that makes all properties of T optional recursively.\n * Used by field setValue functions to allow partial item updates.\n */\nexport type DeepPartial< T > = {\n\t[ P in keyof T ]?: T[ P ] extends object ? DeepPartial< T[ P ] > : T[ P ];\n};\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\nexport interface 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\t| 'lessThan'\n\t| 'greaterThan'\n\t| 'lessThanOrEqual'\n\t| 'greaterThanOrEqual'\n\t| 'before'\n\t| 'after'\n\t| 'beforeInc'\n\t| 'afterInc'\n\t| 'contains'\n\t| 'notContains'\n\t| 'startsWith'\n\t| 'between'\n\t| 'on'\n\t| 'notOn'\n\t| 'inThePast'\n\t| 'over';\n\nexport type FieldTypeName =\n\t| 'text'\n\t| 'integer'\n\t| 'number'\n\t| 'datetime'\n\t| 'date'\n\t| 'media'\n\t| 'boolean'\n\t| 'email'\n\t| 'password'\n\t| 'telephone'\n\t| 'color'\n\t| 'url'\n\t| 'array';\n\nexport type Rules< Item > = {\n\trequired?: boolean;\n\telements?: boolean;\n\tpattern?: string;\n\tminLength?: number;\n\tmaxLength?: number;\n\tmin?: number;\n\tmax?: number;\n\tcustom?:\n\t\t| ( ( item: Item, field: NormalizedField< Item > ) => null | string )\n\t\t| ( (\n\t\t\t\titem: Item,\n\t\t\t\tfield: NormalizedField< Item >\n\t\t ) => Promise< null | string > );\n};\n\nexport type Validator< Item > = (\n\titem: Item,\n\tfield: NormalizedField< Item >\n) => boolean;\n\nexport type CustomValidator< Item > =\n\t| ( ( item: Item, field: NormalizedField< Item > ) => null | string )\n\t| ( (\n\t\t\titem: Item,\n\t\t\tfield: NormalizedField< Item >\n\t ) => Promise< null | string > );\n\nexport type FilterOperator< Item > = (\n\titem: Item,\n\tfield: NormalizedField< Item >,\n\tfilterValue: any\n) => boolean;\n\nexport type FilterOperatorMap< Item > = Partial<\n\tRecord< Operator, FilterOperator< Item > >\n>;\n\ntype NormalizedRule< Item, ConstraintType > = {\n\tconstraint: ConstraintType;\n\tvalidate: Validator< Item >;\n};\n\nexport type NormalizedRules< Item > = {\n\trequired?: NormalizedRule< Item, boolean >;\n\telements?: NormalizedRule< Item, boolean >;\n\tpattern?: NormalizedRule< Item, string >;\n\tminLength?: NormalizedRule< Item, number >;\n\tmaxLength?: NormalizedRule< Item, number >;\n\tmin?: NormalizedRule< Item, number >;\n\tmax?: NormalizedRule< Item, number >;\n\tcustom?: CustomValidator< Item >;\n};\n\n/**\n * Edit configuration for textarea controls.\n */\nexport type EditConfigTextarea = {\n\tcontrol: 'textarea';\n\t/**\n\t * Number of rows for the textarea.\n\t */\n\trows?: number;\n};\n\n/**\n * Edit configuration for text controls.\n */\nexport type EditConfigText = {\n\tcontrol: 'text';\n\t/**\n\t * Prefix component to display before the input.\n\t */\n\tprefix?: React.ComponentType;\n\t/**\n\t * Suffix component to display after the input.\n\t */\n\tsuffix?: React.ComponentType;\n};\n\n/**\n * Edit configuration for datetime controls.\n */\nexport type EditConfigDatetime = {\n\tcontrol: 'datetime';\n\t/**\n\t * Whether to render a compact version without the calendar widget.\n\t */\n\tcompact?: boolean;\n};\n\n/**\n * Edit configuration for other control types (excluding 'text', 'textarea', and 'datetime').\n */\nexport type EditConfigGeneric = {\n\tcontrol: Exclude< FieldTypeName, 'text' | 'textarea' | 'datetime' >;\n};\n\n/**\n * Edit configuration object with type-safe control options.\n * Each control type has its own specific configuration properties.\n */\nexport type EditConfig =\n\t| EditConfigTextarea\n\t| EditConfigText\n\t| EditConfigDatetime\n\t| EditConfigGeneric;\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?: FieldTypeName;\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 | ReactElement;\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< DataViewRenderFieldProps< Item > >;\n\n\t/**\n\t * Callback used to render an edit control for the field.\n\t */\n\tEdit?: ComponentType< DataFormControlProps< Item > > | string | EditConfig;\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?: Rules< Item >;\n\n\t/**\n\t * Callback used to decide if a field should be displayed.\n\t */\n\tisVisible?: ( item: Item ) => 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 can be hidden in the UI.\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 * Retrieval function for elements.\n\t */\n\tgetElements?: () => Promise< Option[] >;\n\n\t/**\n\t * Filter config for the field.\n\t */\n\tfilterBy?: FilterByConfig | false;\n\n\t/**\n\t * Whether the field is readOnly.\n\t * If `true`, the value will be rendered using the `render` callback.\n\t */\n\treadOnly?: boolean;\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\t/**\n\t * Callback used to set the value of the field on the item.\n\t * Used for editing operations to update field values.\n\t */\n\tsetValue?: ( args: { item: Item; value: any } ) => DeepPartial< Item >;\n\n\t/**\n\t * Display format configuration for fields.\n\t */\n\tformat?: FormatDatetime | FormatDate | FormatNumber | FormatInteger;\n\n\t/**\n\t * Callback used to format the value of the field for display.\n\t */\n\tgetValueFormatted?: ( {\n\t\titem,\n\t\tfield,\n\t}: {\n\t\titem: Item;\n\t\tfield: NormalizedField< Item >;\n\t} ) => string;\n};\n\n/**\n * Format for datetime fields:\n *\n * - datetime: the format string (e.g., \"M j, Y g:i a\" for \"Jan 1, 2021 2:30 pm\").\n * - weekStartsOn: to specify the first day of the week (0 for 'sunday', 1 for 'monday', etc.).\n *\n * If not provided, defaults to WordPress date format settings.\n */\nexport type FormatDatetime = {\n\tdatetime?: string;\n\tweekStartsOn?: DayNumber;\n};\n\n/**\n * Format for date fields:\n *\n * - date: the format string (e.g., 'F j, Y' for 'March 10, 2023')\n * - weekStartsOn: to specify the first day of the week (0 for 'sunday', 1 for 'monday', etc.).\n *\n * If not provided, defaults to WordPress date format settings.\n */\nexport type FormatDate = {\n\tdate?: string;\n\tweekStartsOn?: DayNumber;\n};\nexport type DayNumber = 0 | 1 | 2 | 3 | 4 | 5 | 6;\n\n/**\n * Format for number fields:\n *\n * - separatorThousand: character to use for thousand separators (e.g., ',')\n * - separatorDecimal: character to use for decimal point (e.g., '.')\n * - decimals: number of decimal places to display (e.g., 2)\n *\n * If not provided, defaults to ',' for thousands, '.' for decimal, 2 decimals.\n */\nexport type FormatNumber = {\n\tseparatorThousand?: string;\n\tseparatorDecimal?: string;\n\tdecimals?: number;\n};\n\n/**\n * Format for integer fields:\n *\n * - separatorThousand: character to use for thousand separators (e.g., ',')\n *\n * If not provided, defaults to ',' for thousands.\n */\nexport type FormatInteger = {\n\tseparatorThousand?: string;\n};\n\nexport type NormalizedField< Item > = Omit<\n\tField< Item >,\n\t'Edit' | 'isValid'\n> & {\n\tlabel: string;\n\theader: string | ReactElement;\n\tgetValue: ( args: { item: Item } ) => any;\n\tsetValue: ( args: { item: Item; value: any } ) => DeepPartial< Item >;\n\trender: ComponentType< DataViewRenderFieldProps< Item > >;\n\tEdit: ComponentType< DataFormControlProps< Item > > | null;\n\thasElements: boolean;\n\tsort: ( a: Item, b: Item, direction: SortDirection ) => number;\n\tisValid: NormalizedRules< Item >;\n\tenableHiding: boolean;\n\tenableSorting: boolean;\n\tfilterBy: Required< FilterByConfig > | false;\n\tfilter: FilterOperatorMap< Item >;\n\treadOnly: boolean;\n\tformat:\n\t\t| {}\n\t\t| Required< FormatDate >\n\t\t| Required< FormatInteger >\n\t\t| Required< FormatNumber >;\n\tgetValueFormatted: ( {\n\t\titem,\n\t\tfield,\n\t}: {\n\t\titem: Item;\n\t\tfield: NormalizedField< Item >;\n\t} ) => string;\n};\n\n/**\n * A collection of dataview fields for a data type.\n */\nexport type Fields< Item > = Field< Item >[];\n\nexport type FieldValidity = {\n\trequired?: {\n\t\ttype: 'valid' | 'invalid' | 'validating';\n\t\tmessage?: string;\n\t};\n\tpattern?: {\n\t\ttype: 'valid' | 'invalid' | 'validating';\n\t\tmessage: string;\n\t};\n\tmin?: {\n\t\ttype: 'valid' | 'invalid' | 'validating';\n\t\tmessage: string;\n\t};\n\tmax?: {\n\t\ttype: 'valid' | 'invalid' | 'validating';\n\t\tmessage: string;\n\t};\n\tminLength?: {\n\t\ttype: 'valid' | 'invalid' | 'validating';\n\t\tmessage: string;\n\t};\n\tmaxLength?: {\n\t\ttype: 'valid' | 'invalid' | 'validating';\n\t\tmessage: string;\n\t};\n\telements?: {\n\t\ttype: 'valid' | 'invalid' | 'validating';\n\t\tmessage: string;\n\t};\n\tcustom?: {\n\t\ttype: 'valid' | 'invalid' | 'validating';\n\t\tmessage: string;\n\t};\n\tchildren?: Record< string, FieldValidity >;\n};\n\nexport type DataFormControlProps< Item > = {\n\tdata: Item;\n\tfield: NormalizedField< Item >;\n\tonChange: ( value: DeepPartial< Item > ) => void;\n\thideLabelFromVision?: boolean;\n\t/**\n\t * Label the control as \"optional\" when _not_ required, instead of showing \"required\".\n\t */\n\tmarkWhenOptional?: boolean;\n\t/**\n\t * The currently selected filter operator for this field.\n\t *\n\t * Used by DataViews filters to determine which control to render based on the operator type.\n\t */\n\toperator?: Operator;\n\t/**\n\t * Validity information for the field, if any.\n\t */\n\tvalidity?: FieldValidity;\n\t/**\n\t * Configuration object for the control.\n\t */\n\tconfig?: {\n\t\tprefix?: React.ComponentType;\n\t\tsuffix?: React.ComponentType;\n\t\trows?: number;\n\t\tcompact?: boolean;\n\t};\n};\n\nexport type DataViewRenderFieldProps< Item > = {\n\titem: Item;\n\tfield: NormalizedField< Item >;\n\tconfig?: {\n\t\tsizes: string;\n\t};\n};\n"],
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport type { ReactElement, ComponentType } from 'react';\n\n/**\n * Utility type that makes all properties of T optional recursively.\n * Used by field setValue functions to allow partial item updates.\n */\nexport type DeepPartial< T > = {\n\t[ P in keyof T ]?: T[ P ] extends object ? DeepPartial< T[ P ] > : T[ P ];\n};\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\nexport interface 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\t| 'lessThan'\n\t| 'greaterThan'\n\t| 'lessThanOrEqual'\n\t| 'greaterThanOrEqual'\n\t| 'before'\n\t| 'after'\n\t| 'beforeInc'\n\t| 'afterInc'\n\t| 'contains'\n\t| 'notContains'\n\t| 'startsWith'\n\t| 'between'\n\t| 'on'\n\t| 'notOn'\n\t| 'inThePast'\n\t| 'over';\n\nexport type FieldTypeName =\n\t| 'text'\n\t| 'integer'\n\t| 'number'\n\t| 'datetime'\n\t| 'date'\n\t| 'media'\n\t| 'boolean'\n\t| 'email'\n\t| 'password'\n\t| 'telephone'\n\t| 'color'\n\t| 'url'\n\t| 'array';\n\nexport type Rules< Item > = {\n\trequired?: boolean;\n\telements?: boolean;\n\tpattern?: string;\n\tminLength?: number;\n\tmaxLength?: number;\n\tmin?: number | string;\n\tmax?: number | string;\n\tcustom?:\n\t\t| ( ( item: Item, field: NormalizedField< Item > ) => null | string )\n\t\t| ( (\n\t\t\t\titem: Item,\n\t\t\t\tfield: NormalizedField< Item >\n\t\t ) => Promise< null | string > );\n};\n\nexport type Validator< Item > = (\n\titem: Item,\n\tfield: NormalizedField< Item >\n) => boolean;\n\nexport type CustomValidator< Item > =\n\t| ( ( item: Item, field: NormalizedField< Item > ) => null | string )\n\t| ( (\n\t\t\titem: Item,\n\t\t\tfield: NormalizedField< Item >\n\t ) => Promise< null | string > );\n\nexport type FilterOperator< Item > = (\n\titem: Item,\n\tfield: NormalizedField< Item >,\n\tfilterValue: any\n) => boolean;\n\nexport type FilterOperatorMap< Item > = Partial<\n\tRecord< Operator, FilterOperator< Item > >\n>;\n\ntype NormalizedRule< Item, ConstraintType > = {\n\tconstraint: ConstraintType;\n\tvalidate: Validator< Item >;\n};\n\nexport type NormalizedRules< Item > = {\n\trequired?: NormalizedRule< Item, boolean >;\n\telements?: NormalizedRule< Item, boolean >;\n\tpattern?: NormalizedRule< Item, string >;\n\tminLength?: NormalizedRule< Item, number >;\n\tmaxLength?: NormalizedRule< Item, number >;\n\tmin?: NormalizedRule< Item, number > | NormalizedRule< Item, string >;\n\tmax?: NormalizedRule< Item, number > | NormalizedRule< Item, string >;\n\tcustom?: CustomValidator< Item >;\n};\n\n/**\n * Edit configuration for textarea controls.\n */\nexport type EditConfigTextarea = {\n\tcontrol: 'textarea';\n\t/**\n\t * Number of rows for the textarea.\n\t */\n\trows?: number;\n};\n\n/**\n * Edit configuration for text controls.\n */\nexport type EditConfigText = {\n\tcontrol: 'text';\n\t/**\n\t * Prefix component to display before the input.\n\t */\n\tprefix?: React.ComponentType;\n\t/**\n\t * Suffix component to display after the input.\n\t */\n\tsuffix?: React.ComponentType;\n};\n\n/**\n * Edit configuration for datetime controls.\n */\nexport type EditConfigDatetime = {\n\tcontrol: 'datetime';\n\t/**\n\t * Whether to render a compact version without the calendar widget.\n\t */\n\tcompact?: boolean;\n};\n\n/**\n * Edit configuration for other control types (excluding 'text', 'textarea', and 'datetime').\n */\nexport type EditConfigGeneric = {\n\tcontrol: Exclude< FieldTypeName, 'text' | 'textarea' | 'datetime' >;\n};\n\n/**\n * Edit configuration object with type-safe control options.\n * Each control type has its own specific configuration properties.\n */\nexport type EditConfig =\n\t| EditConfigTextarea\n\t| EditConfigText\n\t| EditConfigDatetime\n\t| EditConfigGeneric;\n\nexport type Field< Item > = {\n\t/**\n\t * Type of the field.\n\t */\n\ttype?: FieldTypeName;\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 | ReactElement;\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< DataViewRenderFieldProps< Item > >;\n\n\t/**\n\t * Callback used to render an edit control for the field.\n\t */\n\tEdit?: ComponentType< DataFormControlProps< Item > > | string | EditConfig;\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 * Validation config for the field.\n\t *\n\t * Range rules are normalized according to `type`:\n\t * - `'integer' | 'number'`: `min`/`max` accept `number`\n\t * - `'date' | 'datetime'`: `min`/`max` accept `string`\n\t * - all other field types ignore `min`/`max`\n\t */\n\tisValid?: Rules< Item >;\n\n\t/**\n\t * Callback used to decide if a field should be displayed.\n\t */\n\tisVisible?: ( item: Item ) => boolean;\n\n\t/**\n\t * Whether a field should be disabled.\n\t * Can be a boolean or a callback receiving the current item and field.\n\t * Defaults to false.\n\t */\n\tisDisabled?:\n\t\t| boolean\n\t\t| ( ( args: {\n\t\t\t\titem: Item;\n\t\t\t\tfield: NormalizedField< Item >;\n\t\t } ) => 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 can be hidden in the UI.\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 * Retrieval function for elements.\n\t */\n\tgetElements?: () => Promise< Option[] >;\n\n\t/**\n\t * Filter config for the field.\n\t */\n\tfilterBy?: FilterByConfig | false;\n\n\t/**\n\t * Whether the field is readOnly.\n\t * If `true`, the value will be rendered using the `render` callback.\n\t */\n\treadOnly?: boolean;\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\t/**\n\t * Callback used to set the value of the field on the item.\n\t * Used for editing operations to update field values.\n\t */\n\tsetValue?: ( args: { item: Item; value: any } ) => DeepPartial< Item >;\n\n\t/**\n\t * Display format configuration for fields.\n\t */\n\tformat?: FormatDatetime | FormatDate | FormatNumber | FormatInteger;\n\n\t/**\n\t * Callback used to format the value of the field for display.\n\t */\n\tgetValueFormatted?: ( {\n\t\titem,\n\t\tfield,\n\t}: {\n\t\titem: Item;\n\t\tfield: NormalizedField< Item >;\n\t} ) => string;\n};\n\n/**\n * Format for datetime fields:\n *\n * - datetime: the format string (e.g., \"M j, Y g:i a\" for \"Jan 1, 2021 2:30 pm\").\n * - weekStartsOn: to specify the first day of the week (0 for 'sunday', 1 for 'monday', etc.).\n *\n * If not provided, defaults to WordPress date format settings.\n */\nexport type FormatDatetime = {\n\tdatetime?: string;\n\tweekStartsOn?: DayNumber;\n};\n\n/**\n * Format for date fields:\n *\n * - date: the format string (e.g., 'F j, Y' for 'March 10, 2023')\n * - weekStartsOn: to specify the first day of the week (0 for 'sunday', 1 for 'monday', etc.).\n *\n * If not provided, defaults to WordPress date format settings.\n */\nexport type FormatDate = {\n\tdate?: string;\n\tweekStartsOn?: DayNumber;\n};\nexport type DayNumber = 0 | 1 | 2 | 3 | 4 | 5 | 6;\n\n/**\n * Format for number fields:\n *\n * - separatorThousand: character to use for thousand separators (e.g., ',')\n * - separatorDecimal: character to use for decimal point (e.g., '.')\n * - decimals: number of decimal places to display (e.g., 2)\n *\n * If not provided, defaults to ',' for thousands, '.' for decimal, 2 decimals.\n */\nexport type FormatNumber = {\n\tseparatorThousand?: string;\n\tseparatorDecimal?: string;\n\tdecimals?: number;\n};\n\n/**\n * Format for integer fields:\n *\n * - separatorThousand: character to use for thousand separators (e.g., ',')\n *\n * If not provided, defaults to ',' for thousands.\n */\nexport type FormatInteger = {\n\tseparatorThousand?: string;\n};\n\nexport type NormalizedField< Item > = Omit<\n\tField< Item >,\n\t'Edit' | 'isValid'\n> & {\n\tlabel: string;\n\theader: string | ReactElement;\n\tgetValue: ( args: { item: Item } ) => any;\n\tsetValue: ( args: { item: Item; value: any } ) => DeepPartial< Item >;\n\trender: ComponentType< DataViewRenderFieldProps< Item > >;\n\tEdit: ComponentType< DataFormControlProps< Item > > | null;\n\thasElements: boolean;\n\tsort: ( a: Item, b: Item, direction: SortDirection ) => number;\n\tisValid: NormalizedRules< Item >;\n\tenableHiding: boolean;\n\tenableSorting: boolean;\n\tfilterBy: Required< FilterByConfig > | false;\n\tfilter: FilterOperatorMap< Item >;\n\treadOnly: boolean;\n\tisDisabled: ( args: {\n\t\titem: Item;\n\t\tfield: NormalizedField< Item >;\n\t} ) => boolean;\n\tformat:\n\t\t| {}\n\t\t| Required< FormatDate >\n\t\t| Required< FormatInteger >\n\t\t| Required< FormatNumber >;\n\tgetValueFormatted: ( {\n\t\titem,\n\t\tfield,\n\t}: {\n\t\titem: Item;\n\t\tfield: NormalizedField< Item >;\n\t} ) => string;\n};\n\n/**\n * A collection of dataview fields for a data type.\n */\nexport type Fields< Item > = Field< Item >[];\n\nexport type FieldValidity = {\n\trequired?: {\n\t\ttype: 'valid' | 'invalid' | 'validating';\n\t\tmessage?: string;\n\t};\n\tpattern?: {\n\t\ttype: 'valid' | 'invalid' | 'validating';\n\t\tmessage: string;\n\t};\n\tmin?: {\n\t\ttype: 'valid' | 'invalid' | 'validating';\n\t\tmessage: string;\n\t};\n\tmax?: {\n\t\ttype: 'valid' | 'invalid' | 'validating';\n\t\tmessage: string;\n\t};\n\tminLength?: {\n\t\ttype: 'valid' | 'invalid' | 'validating';\n\t\tmessage: string;\n\t};\n\tmaxLength?: {\n\t\ttype: 'valid' | 'invalid' | 'validating';\n\t\tmessage: string;\n\t};\n\telements?: {\n\t\ttype: 'valid' | 'invalid' | 'validating';\n\t\tmessage: string;\n\t};\n\tcustom?: {\n\t\ttype: 'valid' | 'invalid' | 'validating';\n\t\tmessage: string;\n\t};\n\tchildren?: Record< string, FieldValidity >;\n};\n\nexport type DataFormControlProps< Item > = {\n\tdata: Item;\n\tfield: NormalizedField< Item >;\n\tonChange: ( value: DeepPartial< Item > ) => void;\n\thideLabelFromVision?: boolean;\n\t/**\n\t * Label the control as \"optional\" when _not_ required, instead of showing \"required\".\n\t */\n\tmarkWhenOptional?: boolean;\n\t/**\n\t * The currently selected filter operator for this field.\n\t *\n\t * Used by DataViews filters to determine which control to render based on the operator type.\n\t */\n\toperator?: Operator;\n\t/**\n\t * Validity information for the field, if any.\n\t */\n\tvalidity?: FieldValidity;\n\t/**\n\t * Configuration object for the control.\n\t */\n\tconfig?: {\n\t\tprefix?: React.ComponentType;\n\t\tsuffix?: React.ComponentType;\n\t\trows?: number;\n\t\tcompact?: boolean;\n\t};\n};\n\nexport type DataViewRenderFieldProps< Item > = {\n\titem: Item;\n\tfield: NormalizedField< Item >;\n\tconfig?: {\n\t\tsizes: string;\n\t};\n};\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;AAAA;AAAA;",
6
6
  "names": []
7
7
  }
@@ -16,6 +16,7 @@ function ArrayControl({
16
16
  }) {
17
17
  const { label, placeholder, getValue, setValue, isValid } = field;
18
18
  const value = getValue({ item: data });
19
+ const disabled = field.isDisabled({ item: data, field });
19
20
  const { elements, isLoading } = useElements({
20
21
  elements: field.elements,
21
22
  getElements: field.getElements
@@ -55,6 +56,7 @@ function ArrayControl({
55
56
  onChange: onChangeControl,
56
57
  placeholder,
57
58
  suggestions: elements?.map((element) => element.value),
59
+ disabled,
58
60
  __experimentalValidateInput: (token) => {
59
61
  if (field.isValid?.elements && elements) {
60
62
  return elements.some(
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/dataform-controls/array.tsx"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { privateApis, Spinner } from '@wordpress/components';\nimport { useCallback, useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport type { DataFormControlProps } from '../../types';\nimport { unlock } from '../../lock-unlock';\nimport getCustomValidity from './utils/get-custom-validity';\nimport useElements from '../../hooks/use-elements';\n\nconst { ValidatedFormTokenField } = unlock( privateApis );\n\nexport default function ArrayControl< Item >( {\n\tdata,\n\tfield,\n\tonChange,\n\thideLabelFromVision,\n\tmarkWhenOptional,\n\tvalidity,\n}: DataFormControlProps< Item > ) {\n\tconst { label, placeholder, getValue, setValue, isValid } = field;\n\tconst value = getValue( { item: data } );\n\n\tconst { elements, isLoading } = useElements( {\n\t\telements: field.elements,\n\t\tgetElements: field.getElements,\n\t} );\n\n\t// Convert stored values to element objects for the token field\n\tconst arrayValueAsElements = useMemo(\n\t\t() =>\n\t\t\tArray.isArray( value )\n\t\t\t\t? value.map( ( token ) => {\n\t\t\t\t\t\tconst element = elements?.find(\n\t\t\t\t\t\t\t( suggestion ) => suggestion.value === token\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn element || { value: token, label: token };\n\t\t\t\t } )\n\t\t\t\t: [],\n\t\t[ value, elements ]\n\t);\n\n\tconst onChangeControl = useCallback(\n\t\t( tokens: ( string | { value: string; label?: string } )[] ) => {\n\t\t\tconst valueTokens = tokens.map( ( token ) => {\n\t\t\t\tif ( typeof token === 'object' && 'value' in token ) {\n\t\t\t\t\treturn token.value;\n\t\t\t\t}\n\t\t\t\t// If it's a string, it's either a new suggestion value or user input\n\t\t\t\treturn token;\n\t\t\t} );\n\n\t\t\tonChange( setValue( { item: data, value: valueTokens } ) );\n\t\t},\n\t\t[ onChange, setValue, data ]\n\t);\n\n\tif ( isLoading ) {\n\t\treturn <Spinner />;\n\t}\n\n\treturn (\n\t\t<ValidatedFormTokenField\n\t\t\trequired={ !! isValid?.required }\n\t\t\tmarkWhenOptional={ markWhenOptional }\n\t\t\tcustomValidity={ getCustomValidity( isValid, validity ) }\n\t\t\tlabel={ hideLabelFromVision ? undefined : label }\n\t\t\tvalue={ arrayValueAsElements }\n\t\t\tonChange={ onChangeControl }\n\t\t\tplaceholder={ placeholder }\n\t\t\tsuggestions={ elements?.map( ( element ) => element.value ) }\n\t\t\t__experimentalValidateInput={ ( token: string ) => {\n\t\t\t\t// If elements validation is required, check if token is valid\n\t\t\t\tif ( field.isValid?.elements && elements ) {\n\t\t\t\t\treturn elements.some(\n\t\t\t\t\t\t( element ) =>\n\t\t\t\t\t\t\telement.value === token || element.label === token\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\t// For non-elements validation, allow all tokens\n\t\t\t\treturn true;\n\t\t\t} }\n\t\t\t__experimentalExpandOnFocus={ elements && elements.length > 0 }\n\t\t\t__experimentalShowHowTo={ ! field.isValid?.elements }\n\t\t\tdisplayTransform={ ( token: any ) => {\n\t\t\t\t// For existing tokens (element objects), display their label\n\t\t\t\tif ( typeof token === 'object' && 'label' in token ) {\n\t\t\t\t\treturn token.label;\n\t\t\t\t}\n\t\t\t\t// For suggestions (value strings), find the corresponding element and show its label\n\t\t\t\tif ( typeof token === 'string' && elements ) {\n\t\t\t\t\tconst element = elements.find(\n\t\t\t\t\t\t( el ) => el.value === token\n\t\t\t\t\t);\n\t\t\t\t\treturn element?.label || token;\n\t\t\t\t}\n\t\t\t\treturn token;\n\t\t\t} }\n\t\t\t__experimentalRenderItem={ ( { item }: { item: any } ) => {\n\t\t\t\t// Custom rendering for suggestion items (item is a value string)\n\t\t\t\tif ( typeof item === 'string' && elements ) {\n\t\t\t\t\tconst element = elements.find(\n\t\t\t\t\t\t( el ) => el.value === item\n\t\t\t\t\t);\n\t\t\t\t\treturn <span>{ element?.label || item }</span>;\n\t\t\t\t}\n\t\t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,MACA,UAAW,CAAC,CAAE,SAAS;AAAA,MACvB;AAAA,MACA,gBAAiB,kBAAmB,SAAS,QAAS;AAAA,MACtD,OAAQ,sBAAsB,SAAY;AAAA,MAC1C,OAAQ;AAAA,MACR,UAAW;AAAA,MACX;AAAA,MACA,aAAc,UAAU,IAAK,CAAE,YAAa,QAAQ,KAAM;AAAA,MAC1D,6BAA8B,CAAE,UAAmB;AAElD,YAAK,MAAM,SAAS,YAAY,UAAW;AAC1C,iBAAO,SAAS;AAAA,YACf,CAAE,YACD,QAAQ,UAAU,SAAS,QAAQ,UAAU;AAAA,UAC/C;AAAA,QACD;AAGA,eAAO;AAAA,MACR;AAAA,MACA,6BAA8B,YAAY,SAAS,SAAS;AAAA,MAC5D,yBAA0B,CAAE,MAAM,SAAS;AAAA,MAC3C,kBAAmB,CAAE,UAAgB;AAEpC,YAAK,OAAO,UAAU,YAAY,WAAW,OAAQ;AACpD,iBAAO,MAAM;AAAA,QACd;AAEA,YAAK,OAAO,UAAU,YAAY,UAAW;AAC5C,gBAAM,UAAU,SAAS;AAAA,YACxB,CAAE,OAAQ,GAAG,UAAU;AAAA,UACxB;AACA,iBAAO,SAAS,SAAS;AAAA,QAC1B;AACA,eAAO;AAAA,MACR;AAAA,MACA,0BAA2B,CAAE,EAAE,KAAK,MAAsB;AAEzD,YAAK,OAAO,SAAS,YAAY,UAAW;AAC3C,gBAAM,UAAU,SAAS;AAAA,YACxB,CAAE,OAAQ,GAAG,UAAU;AAAA,UACxB;AACA,iBAAO,oBAAC,UAAO,mBAAS,SAAS,MAAM;AAAA,QACxC;AACA,eAAO,oBAAC,UAAO,gBAAM;AAAA,MACtB;AAAA;AAAA,EACD;AAEF;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { privateApis, Spinner } from '@wordpress/components';\nimport { useCallback, useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport type { DataFormControlProps } from '../../types';\nimport { unlock } from '../../lock-unlock';\nimport getCustomValidity from './utils/get-custom-validity';\nimport useElements from '../../hooks/use-elements';\n\nconst { ValidatedFormTokenField } = unlock( privateApis );\n\nexport default function ArrayControl< Item >( {\n\tdata,\n\tfield,\n\tonChange,\n\thideLabelFromVision,\n\tmarkWhenOptional,\n\tvalidity,\n}: DataFormControlProps< Item > ) {\n\tconst { label, placeholder, getValue, setValue, isValid } = field;\n\tconst value = getValue( { item: data } );\n\tconst disabled = field.isDisabled( { item: data, field } );\n\n\tconst { elements, isLoading } = useElements( {\n\t\telements: field.elements,\n\t\tgetElements: field.getElements,\n\t} );\n\n\t// Convert stored values to element objects for the token field\n\tconst arrayValueAsElements = useMemo(\n\t\t() =>\n\t\t\tArray.isArray( value )\n\t\t\t\t? value.map( ( token ) => {\n\t\t\t\t\t\tconst element = elements?.find(\n\t\t\t\t\t\t\t( suggestion ) => suggestion.value === token\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn element || { value: token, label: token };\n\t\t\t\t } )\n\t\t\t\t: [],\n\t\t[ value, elements ]\n\t);\n\n\tconst onChangeControl = useCallback(\n\t\t( tokens: ( string | { value: string; label?: string } )[] ) => {\n\t\t\tconst valueTokens = tokens.map( ( token ) => {\n\t\t\t\tif ( typeof token === 'object' && 'value' in token ) {\n\t\t\t\t\treturn token.value;\n\t\t\t\t}\n\t\t\t\t// If it's a string, it's either a new suggestion value or user input\n\t\t\t\treturn token;\n\t\t\t} );\n\n\t\t\tonChange( setValue( { item: data, value: valueTokens } ) );\n\t\t},\n\t\t[ onChange, setValue, data ]\n\t);\n\n\tif ( isLoading ) {\n\t\treturn <Spinner />;\n\t}\n\n\treturn (\n\t\t<ValidatedFormTokenField\n\t\t\trequired={ !! isValid?.required }\n\t\t\tmarkWhenOptional={ markWhenOptional }\n\t\t\tcustomValidity={ getCustomValidity( isValid, validity ) }\n\t\t\tlabel={ hideLabelFromVision ? undefined : label }\n\t\t\tvalue={ arrayValueAsElements }\n\t\t\tonChange={ onChangeControl }\n\t\t\tplaceholder={ placeholder }\n\t\t\tsuggestions={ elements?.map( ( element ) => element.value ) }\n\t\t\tdisabled={ disabled }\n\t\t\t__experimentalValidateInput={ ( token: string ) => {\n\t\t\t\t// If elements validation is required, check if token is valid\n\t\t\t\tif ( field.isValid?.elements && elements ) {\n\t\t\t\t\treturn elements.some(\n\t\t\t\t\t\t( element ) =>\n\t\t\t\t\t\t\telement.value === token || element.label === token\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\t// For non-elements validation, allow all tokens\n\t\t\t\treturn true;\n\t\t\t} }\n\t\t\t__experimentalExpandOnFocus={ elements && elements.length > 0 }\n\t\t\t__experimentalShowHowTo={ ! field.isValid?.elements }\n\t\t\tdisplayTransform={ ( token: any ) => {\n\t\t\t\t// For existing tokens (element objects), display their label\n\t\t\t\tif ( typeof token === 'object' && 'label' in token ) {\n\t\t\t\t\treturn token.label;\n\t\t\t\t}\n\t\t\t\t// For suggestions (value strings), find the corresponding element and show its label\n\t\t\t\tif ( typeof token === 'string' && elements ) {\n\t\t\t\t\tconst element = elements.find(\n\t\t\t\t\t\t( el ) => el.value === token\n\t\t\t\t\t);\n\t\t\t\t\treturn element?.label || token;\n\t\t\t\t}\n\t\t\t\treturn token;\n\t\t\t} }\n\t\t\t__experimentalRenderItem={ ( { item }: { item: any } ) => {\n\t\t\t\t// Custom rendering for suggestion items (item is a value string)\n\t\t\t\tif ( typeof item === 'string' && elements ) {\n\t\t\t\t\tconst element = elements.find(\n\t\t\t\t\t\t( el ) => el.value === item\n\t\t\t\t\t);\n\t\t\t\t\treturn <span>{ element?.label || item }</span>;\n\t\t\t\t}\n\t\t\t\treturn <span>{ item }</span>;\n\t\t\t} }\n\t\t/>\n\t);\n}\n"],
5
+ "mappings": ";AAGA,SAAS,aAAa,eAAe;AACrC,SAAS,aAAa,eAAe;AAMrC,SAAS,cAAc;AACvB,OAAO,uBAAuB;AAC9B,OAAO,iBAAiB;AAmDf;AAjDT,IAAM,EAAE,wBAAwB,IAAI,OAAQ,WAAY;AAEzC,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UAAU,IAAK,CAAE,YAAa,QAAQ,KAAM;AAAA,MAC1D;AAAA,MACA,6BAA8B,CAAE,UAAmB;AAElD,YAAK,MAAM,SAAS,YAAY,UAAW;AAC1C,iBAAO,SAAS;AAAA,YACf,CAAE,YACD,QAAQ,UAAU,SAAS,QAAQ,UAAU;AAAA,UAC/C;AAAA,QACD;AAGA,eAAO;AAAA,MACR;AAAA,MACA,6BAA8B,YAAY,SAAS,SAAS;AAAA,MAC5D,yBAA0B,CAAE,MAAM,SAAS;AAAA,MAC3C,kBAAmB,CAAE,UAAgB;AAEpC,YAAK,OAAO,UAAU,YAAY,WAAW,OAAQ;AACpD,iBAAO,MAAM;AAAA,QACd;AAEA,YAAK,OAAO,UAAU,YAAY,UAAW;AAC5C,gBAAM,UAAU,SAAS;AAAA,YACxB,CAAE,OAAQ,GAAG,UAAU;AAAA,UACxB;AACA,iBAAO,SAAS,SAAS;AAAA,QAC1B;AACA,eAAO;AAAA,MACR;AAAA,MACA,0BAA2B,CAAE,EAAE,KAAK,MAAsB;AAEzD,YAAK,OAAO,SAAS,YAAY,UAAW;AAC3C,gBAAM,UAAU,SAAS;AAAA,YACxB,CAAE,OAAQ,GAAG,UAAU;AAAA,UACxB;AACA,iBAAO,oBAAC,UAAO,mBAAS,SAAS,MAAM;AAAA,QACxC;AACA,eAAO,oBAAC,UAAO,gBAAM;AAAA,MACtB;AAAA;AAAA,EACD;AAEF;",
6
6
  "names": []
7
7
  }
@@ -14,6 +14,7 @@ function Checkbox({
14
14
  validity
15
15
  }) {
16
16
  const { getValue, setValue, label, description, isValid } = field;
17
+ const disabled = field.isDisabled({ item: data, field });
17
18
  const onChangeControl = useCallback(() => {
18
19
  onChange(
19
20
  setValue({ item: data, value: !getValue({ item: data }) })
@@ -29,7 +30,8 @@ function Checkbox({
29
30
  label,
30
31
  help: description,
31
32
  checked: getValue({ item: data }),
32
- onChange: onChangeControl
33
+ onChange: onChangeControl,
34
+ disabled
33
35
  }
34
36
  );
35
37
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/dataform-controls/checkbox.tsx"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { privateApis } from '@wordpress/components';\nimport { useCallback } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport type { DataFormControlProps } from '../../types';\nimport { unlock } from '../../lock-unlock';\nimport getCustomValidity from './utils/get-custom-validity';\n\nconst { ValidatedCheckboxControl } = unlock( privateApis );\n\nexport default function Checkbox< Item >( {\n\tfield,\n\tonChange,\n\tdata,\n\thideLabelFromVision,\n\tmarkWhenOptional,\n\tvalidity,\n}: DataFormControlProps< Item > ) {\n\tconst { getValue, setValue, label, description, isValid } = field;\n\n\tconst onChangeControl = useCallback( () => {\n\t\tonChange(\n\t\t\tsetValue( { item: data, value: ! getValue( { item: data } ) } )\n\t\t);\n\t}, [ data, getValue, onChange, setValue ] );\n\n\treturn (\n\t\t<ValidatedCheckboxControl\n\t\t\trequired={ !! field.isValid?.required }\n\t\t\tmarkWhenOptional={ markWhenOptional }\n\t\t\tcustomValidity={ getCustomValidity( isValid, validity ) }\n\t\t\thidden={ hideLabelFromVision }\n\t\t\tlabel={ label }\n\t\t\thelp={ description }\n\t\t\tchecked={ getValue( { item: data } ) }\n\t\t\tonChange={ onChangeControl }\n\t\t/>\n\t);\n}\n"],
5
- "mappings": ";AAGA,SAAS,mBAAmB;AAC5B,SAAS,mBAAmB;AAM5B,SAAS,cAAc;AACvB,OAAO,uBAAuB;AAqB5B;AAnBF,IAAM,EAAE,yBAAyB,IAAI,OAAQ,WAAY;AAE1C,SAAR,SAAmC;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAkC;AACjC,QAAM,EAAE,UAAU,UAAU,OAAO,aAAa,QAAQ,IAAI;AAE5D,QAAM,kBAAkB,YAAa,MAAM;AAC1C;AAAA,MACC,SAAU,EAAE,MAAM,MAAM,OAAO,CAAE,SAAU,EAAE,MAAM,KAAK,CAAE,EAAE,CAAE;AAAA,IAC/D;AAAA,EACD,GAAG,CAAE,MAAM,UAAU,UAAU,QAAS,CAAE;AAE1C,SACC;AAAA,IAAC;AAAA;AAAA,MACA,UAAW,CAAC,CAAE,MAAM,SAAS;AAAA,MAC7B;AAAA,MACA,gBAAiB,kBAAmB,SAAS,QAAS;AAAA,MACtD,QAAS;AAAA,MACT;AAAA,MACA,MAAO;AAAA,MACP,SAAU,SAAU,EAAE,MAAM,KAAK,CAAE;AAAA,MACnC,UAAW;AAAA;AAAA,EACZ;AAEF;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { privateApis } from '@wordpress/components';\nimport { useCallback } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport type { DataFormControlProps } from '../../types';\nimport { unlock } from '../../lock-unlock';\nimport getCustomValidity from './utils/get-custom-validity';\n\nconst { ValidatedCheckboxControl } = unlock( privateApis );\n\nexport default function Checkbox< Item >( {\n\tfield,\n\tonChange,\n\tdata,\n\thideLabelFromVision,\n\tmarkWhenOptional,\n\tvalidity,\n}: DataFormControlProps< Item > ) {\n\tconst { getValue, setValue, label, description, isValid } = field;\n\tconst disabled = field.isDisabled( { item: data, field } );\n\n\tconst onChangeControl = useCallback( () => {\n\t\tonChange(\n\t\t\tsetValue( { item: data, value: ! getValue( { item: data } ) } )\n\t\t);\n\t}, [ data, getValue, onChange, setValue ] );\n\n\treturn (\n\t\t<ValidatedCheckboxControl\n\t\t\trequired={ !! field.isValid?.required }\n\t\t\tmarkWhenOptional={ markWhenOptional }\n\t\t\tcustomValidity={ getCustomValidity( isValid, validity ) }\n\t\t\thidden={ hideLabelFromVision }\n\t\t\tlabel={ label }\n\t\t\thelp={ description }\n\t\t\tchecked={ getValue( { item: data } ) }\n\t\t\tonChange={ onChangeControl }\n\t\t\tdisabled={ disabled }\n\t\t/>\n\t);\n}\n"],
5
+ "mappings": ";AAGA,SAAS,mBAAmB;AAC5B,SAAS,mBAAmB;AAM5B,SAAS,cAAc;AACvB,OAAO,uBAAuB;AAsB5B;AApBF,IAAM,EAAE,yBAAyB,IAAI,OAAQ,WAAY;AAE1C,SAAR,SAAmC;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAkC;AACjC,QAAM,EAAE,UAAU,UAAU,OAAO,aAAa,QAAQ,IAAI;AAC5D,QAAM,WAAW,MAAM,WAAY,EAAE,MAAM,MAAM,MAAM,CAAE;AAEzD,QAAM,kBAAkB,YAAa,MAAM;AAC1C;AAAA,MACC,SAAU,EAAE,MAAM,MAAM,OAAO,CAAE,SAAU,EAAE,MAAM,KAAK,CAAE,EAAE,CAAE;AAAA,IAC/D;AAAA,EACD,GAAG,CAAE,MAAM,UAAU,UAAU,QAAS,CAAE;AAE1C,SACC;AAAA,IAAC;AAAA;AAAA,MACA,UAAW,CAAC,CAAE,MAAM,SAAS;AAAA,MAC7B;AAAA,MACA,gBAAiB,kBAAmB,SAAS,QAAS;AAAA,MACtD,QAAS;AAAA,MACT;AAAA,MACA,MAAO;AAAA,MACP,SAAU,SAAU,EAAE,MAAM,KAAK,CAAE;AAAA,MACnC,UAAW;AAAA,MACX;AAAA;AAAA,EACD;AAEF;",
6
6
  "names": []
7
7
  }
@@ -17,7 +17,8 @@ import { jsx } from "react/jsx-runtime";
17
17
  var { ValidatedInputControl } = unlock(privateApis);
18
18
  var ColorPickerDropdown = ({
19
19
  color,
20
- onColorChange
20
+ onColorChange,
21
+ disabled
21
22
  }) => {
22
23
  const validColor = color && colord(color).isValid() ? color : "#ffffff";
23
24
  return /* @__PURE__ */ jsx(
@@ -31,6 +32,8 @@ var ColorPickerDropdown = ({
31
32
  onClick: onToggle,
32
33
  "aria-label": __("Open color picker"),
33
34
  size: "small",
35
+ disabled,
36
+ accessibleWhenDisabled: true,
34
37
  icon: () => /* @__PURE__ */ jsx(ColorIndicator, { colorValue: validColor })
35
38
  }
36
39
  ),
@@ -54,6 +57,7 @@ function Color({
54
57
  validity
55
58
  }) {
56
59
  const { label, placeholder, description, setValue, isValid } = field;
60
+ const disabled = field.isDisabled({ item: data, field });
57
61
  const value = field.getValue({ item: data }) || "";
58
62
  const handleColorChange = useCallback(
59
63
  (newColor) => {
@@ -80,11 +84,13 @@ function Color({
80
84
  onChange: handleInputChange,
81
85
  hideLabelFromVision,
82
86
  type: "text",
87
+ disabled,
83
88
  prefix: /* @__PURE__ */ jsx(InputControlPrefixWrapper, { variant: "control", children: /* @__PURE__ */ jsx(
84
89
  ColorPickerDropdown,
85
90
  {
86
91
  color: value,
87
- onColorChange: handleColorChange
92
+ onColorChange: handleColorChange,
93
+ disabled
88
94
  }
89
95
  ) })
90
96
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/dataform-controls/color.tsx"],
4
- "sourcesContent": ["/**\n * External dependencies\n */\nimport { colord } from 'colord';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tColorIndicator,\n\tColorPicker,\n\tDropdown,\n\tprivateApis,\n\t__experimentalInputControlPrefixWrapper as InputControlPrefixWrapper,\n\t__experimentalDropdownContentWrapper as DropdownContentWrapper,\n} from '@wordpress/components';\nimport { useCallback } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport type { DataFormControlProps } from '../../types';\nimport { unlock } from '../../lock-unlock';\nimport getCustomValidity from './utils/get-custom-validity';\n\nconst { ValidatedInputControl } = unlock( privateApis );\n\nconst ColorPickerDropdown = ( {\n\tcolor,\n\tonColorChange,\n}: {\n\tcolor: string;\n\tonColorChange: ( newColor: string ) => void;\n} ) => {\n\tconst validColor = color && colord( color ).isValid() ? color : '#ffffff';\n\n\treturn (\n\t\t<Dropdown\n\t\t\tclassName=\"dataviews-controls__color-picker-dropdown\"\n\t\t\tpopoverProps={ { resize: false } }\n\t\t\trenderToggle={ ( { onToggle } ) => (\n\t\t\t\t<Button\n\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\taria-label={ __( 'Open color picker' ) }\n\t\t\t\t\tsize=\"small\"\n\t\t\t\t\ticon={ () => <ColorIndicator colorValue={ validColor } /> }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\trenderContent={ () => (\n\t\t\t\t<DropdownContentWrapper paddingSize=\"none\">\n\t\t\t\t\t<ColorPicker\n\t\t\t\t\t\tcolor={ validColor }\n\t\t\t\t\t\tonChange={ onColorChange }\n\t\t\t\t\t\tenableAlpha\n\t\t\t\t\t/>\n\t\t\t\t</DropdownContentWrapper>\n\t\t\t) }\n\t\t/>\n\t);\n};\n\nexport default function Color< Item >( {\n\tdata,\n\tfield,\n\tonChange,\n\thideLabelFromVision,\n\tmarkWhenOptional,\n\tvalidity,\n}: DataFormControlProps< Item > ) {\n\tconst { label, placeholder, description, setValue, isValid } = field;\n\tconst value = field.getValue( { item: data } ) || '';\n\n\tconst handleColorChange = useCallback(\n\t\t( newColor: string ) => {\n\t\t\tonChange( setValue( { item: data, value: newColor } ) );\n\t\t},\n\t\t[ data, onChange, setValue ]\n\t);\n\n\tconst handleInputChange = useCallback(\n\t\t( newValue: string | undefined ) => {\n\t\t\tonChange( setValue( { item: data, value: newValue || '' } ) );\n\t\t},\n\t\t[ data, onChange, setValue ]\n\t);\n\n\treturn (\n\t\t<ValidatedInputControl\n\t\t\trequired={ !! field.isValid?.required }\n\t\t\tmarkWhenOptional={ markWhenOptional }\n\t\t\tcustomValidity={ getCustomValidity( isValid, validity ) }\n\t\t\tlabel={ label }\n\t\t\tplaceholder={ placeholder }\n\t\t\tvalue={ value }\n\t\t\thelp={ description }\n\t\t\tonChange={ handleInputChange }\n\t\t\thideLabelFromVision={ hideLabelFromVision }\n\t\t\ttype=\"text\"\n\t\t\tprefix={\n\t\t\t\t<InputControlPrefixWrapper variant=\"control\">\n\t\t\t\t\t<ColorPickerDropdown\n\t\t\t\t\t\tcolor={ value }\n\t\t\t\t\t\tonColorChange={ handleColorChange }\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,SAAS,CAAE,CAAE;AAAA,IACvD;AAAA,IACA,CAAE,MAAM,UAAU,QAAS;AAAA,EAC5B;AAEA,QAAM,oBAAoB;AAAA,IACzB,CAAE,aAAkC;AACnC,eAAU,SAAU,EAAE,MAAM,MAAM,OAAO,YAAY,GAAG,CAAE,CAAE;AAAA,IAC7D;AAAA,IACA,CAAE,MAAM,UAAU,QAAS;AAAA,EAC5B;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACA,UAAW,CAAC,CAAE,MAAM,SAAS;AAAA,MAC7B;AAAA,MACA,gBAAiB,kBAAmB,SAAS,QAAS;AAAA,MACtD;AAAA,MACA;AAAA,MACA;AAAA,MACA,MAAO;AAAA,MACP,UAAW;AAAA,MACX;AAAA,MACA,MAAK;AAAA,MACL,QACC,oBAAC,6BAA0B,SAAQ,WAClC;AAAA,QAAC;AAAA;AAAA,UACA,OAAQ;AAAA,UACR,eAAgB;AAAA;AAAA,MACjB,GACD;AAAA;AAAA,EAEF;AAEF;",
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport { colord } from 'colord';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tColorIndicator,\n\tColorPicker,\n\tDropdown,\n\tprivateApis,\n\t__experimentalInputControlPrefixWrapper as InputControlPrefixWrapper,\n\t__experimentalDropdownContentWrapper as DropdownContentWrapper,\n} from '@wordpress/components';\nimport { useCallback } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport type { DataFormControlProps } from '../../types';\nimport { unlock } from '../../lock-unlock';\nimport getCustomValidity from './utils/get-custom-validity';\n\nconst { ValidatedInputControl } = unlock( privateApis );\n\nconst ColorPickerDropdown = ( {\n\tcolor,\n\tonColorChange,\n\tdisabled,\n}: {\n\tcolor: string;\n\tonColorChange: ( newColor: string ) => void;\n\tdisabled?: boolean;\n} ) => {\n\tconst validColor = color && colord( color ).isValid() ? color : '#ffffff';\n\n\treturn (\n\t\t<Dropdown\n\t\t\tclassName=\"dataviews-controls__color-picker-dropdown\"\n\t\t\tpopoverProps={ { resize: false } }\n\t\t\trenderToggle={ ( { onToggle } ) => (\n\t\t\t\t<Button\n\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\taria-label={ __( 'Open color picker' ) }\n\t\t\t\t\tsize=\"small\"\n\t\t\t\t\tdisabled={ disabled }\n\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\ticon={ () => <ColorIndicator colorValue={ validColor } /> }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\trenderContent={ () => (\n\t\t\t\t<DropdownContentWrapper paddingSize=\"none\">\n\t\t\t\t\t<ColorPicker\n\t\t\t\t\t\tcolor={ validColor }\n\t\t\t\t\t\tonChange={ onColorChange }\n\t\t\t\t\t\tenableAlpha\n\t\t\t\t\t/>\n\t\t\t\t</DropdownContentWrapper>\n\t\t\t) }\n\t\t/>\n\t);\n};\n\nexport default function Color< Item >( {\n\tdata,\n\tfield,\n\tonChange,\n\thideLabelFromVision,\n\tmarkWhenOptional,\n\tvalidity,\n}: DataFormControlProps< Item > ) {\n\tconst { label, placeholder, description, setValue, isValid } = field;\n\tconst disabled = field.isDisabled( { item: data, field } );\n\tconst value = field.getValue( { item: data } ) || '';\n\n\tconst handleColorChange = useCallback(\n\t\t( newColor: string ) => {\n\t\t\tonChange( setValue( { item: data, value: newColor } ) );\n\t\t},\n\t\t[ data, onChange, setValue ]\n\t);\n\n\tconst handleInputChange = useCallback(\n\t\t( newValue: string | undefined ) => {\n\t\t\tonChange( setValue( { item: data, value: newValue || '' } ) );\n\t\t},\n\t\t[ data, onChange, setValue ]\n\t);\n\n\treturn (\n\t\t<ValidatedInputControl\n\t\t\trequired={ !! field.isValid?.required }\n\t\t\tmarkWhenOptional={ markWhenOptional }\n\t\t\tcustomValidity={ getCustomValidity( isValid, validity ) }\n\t\t\tlabel={ label }\n\t\t\tplaceholder={ placeholder }\n\t\t\tvalue={ value }\n\t\t\thelp={ description }\n\t\t\tonChange={ handleInputChange }\n\t\t\thideLabelFromVision={ hideLabelFromVision }\n\t\t\ttype=\"text\"\n\t\t\tdisabled={ disabled }\n\t\t\tprefix={\n\t\t\t\t<InputControlPrefixWrapper variant=\"control\">\n\t\t\t\t\t<ColorPickerDropdown\n\t\t\t\t\t\tcolor={ value }\n\t\t\t\t\t\tonColorChange={ handleColorChange }\n\t\t\t\t\t\tdisabled={ disabled }\n\t\t\t\t\t/>\n\t\t\t\t</InputControlPrefixWrapper>\n\t\t\t}\n\t\t/>\n\t);\n}\n"],
5
+ "mappings": ";AAGA,SAAS,cAAc;AAKvB;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,2CAA2C;AAAA,EAC3C,wCAAwC;AAAA,OAClC;AACP,SAAS,mBAAmB;AAC5B,SAAS,UAAU;AAMnB,SAAS,cAAc;AACvB,OAAO,uBAAuB;AA0BZ;AAxBlB,IAAM,EAAE,sBAAsB,IAAI,OAAQ,WAAY;AAEtD,IAAM,sBAAsB,CAAE;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AACD,MAIO;AACN,QAAM,aAAa,SAAS,OAAQ,KAAM,EAAE,QAAQ,IAAI,QAAQ;AAEhE,SACC;AAAA,IAAC;AAAA;AAAA,MACA,WAAU;AAAA,MACV,cAAe,EAAE,QAAQ,MAAM;AAAA,MAC/B,cAAe,CAAE,EAAE,SAAS,MAC3B;AAAA,QAAC;AAAA;AAAA,UACA,SAAU;AAAA,UACV,cAAa,GAAI,mBAAoB;AAAA,UACrC,MAAK;AAAA,UACL;AAAA,UACA,wBAAsB;AAAA,UACtB,MAAO,MAAM,oBAAC,kBAAe,YAAa,YAAa;AAAA;AAAA,MACxD;AAAA,MAED,eAAgB,MACf,oBAAC,0BAAuB,aAAY,QACnC;AAAA,QAAC;AAAA;AAAA,UACA,OAAQ;AAAA,UACR,UAAW;AAAA,UACX,aAAW;AAAA;AAAA,MACZ,GACD;AAAA;AAAA,EAEF;AAEF;AAEe,SAAR,MAAgC;AAAA,EACtC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAkC;AACjC,QAAM,EAAE,OAAO,aAAa,aAAa,UAAU,QAAQ,IAAI;AAC/D,QAAM,WAAW,MAAM,WAAY,EAAE,MAAM,MAAM,MAAM,CAAE;AACzD,QAAM,QAAQ,MAAM,SAAU,EAAE,MAAM,KAAK,CAAE,KAAK;AAElD,QAAM,oBAAoB;AAAA,IACzB,CAAE,aAAsB;AACvB,eAAU,SAAU,EAAE,MAAM,MAAM,OAAO,SAAS,CAAE,CAAE;AAAA,IACvD;AAAA,IACA,CAAE,MAAM,UAAU,QAAS;AAAA,EAC5B;AAEA,QAAM,oBAAoB;AAAA,IACzB,CAAE,aAAkC;AACnC,eAAU,SAAU,EAAE,MAAM,MAAM,OAAO,YAAY,GAAG,CAAE,CAAE;AAAA,IAC7D;AAAA,IACA,CAAE,MAAM,UAAU,QAAS;AAAA,EAC5B;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACA,UAAW,CAAC,CAAE,MAAM,SAAS;AAAA,MAC7B;AAAA,MACA,gBAAiB,kBAAmB,SAAS,QAAS;AAAA,MACtD;AAAA,MACA;AAAA,MACA;AAAA,MACA,MAAO;AAAA,MACP,UAAW;AAAA,MACX;AAAA,MACA,MAAK;AAAA,MACL;AAAA,MACA,QACC,oBAAC,6BAA0B,SAAQ,WAClC;AAAA,QAAC;AAAA;AAAA,UACA,OAAQ;AAAA,UACR,eAAgB;AAAA,UAChB;AAAA;AAAA,MACD,GACD;AAAA;AAAA,EAEF;AAEF;",
6
6
  "names": []
7
7
  }
@@ -28,6 +28,7 @@ import { getDate, getSettings } from "@wordpress/date";
28
28
  import { error as errorIcon } from "@wordpress/icons";
29
29
  import { Stack } from "@wordpress/ui";
30
30
  import RelativeDateControl from "./utils/relative-date-control.mjs";
31
+ import useDisabledDateMatchers from "./utils/use-disabled-date-matchers.mjs";
31
32
  import {
32
33
  OPERATOR_IN_THE_PAST,
33
34
  OPERATOR_OVER,
@@ -235,6 +236,7 @@ function CalendarDateControl({
235
236
  isValid,
236
237
  format: fieldFormat
237
238
  } = field;
239
+ const disabled = field.isDisabled({ item: data, field });
238
240
  const [selectedPresetId, setSelectedPresetId] = useState(
239
241
  null
240
242
  );
@@ -247,6 +249,7 @@ function CalendarDateControl({
247
249
  });
248
250
  const [isTouched, setIsTouched] = useState(false);
249
251
  const validityTargetRef = useRef(null);
252
+ const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid, parseDate);
250
253
  const onChangeCallback = useCallback(
251
254
  (newValue) => onChange(setValue({ item: data, value: newValue })),
252
255
  [data, onChange, setValue]
@@ -328,6 +331,8 @@ function CalendarDateControl({
328
331
  variant: "tertiary",
329
332
  isPressed: isSelected,
330
333
  size: "small",
334
+ disabled,
335
+ accessibleWhenDisabled: true,
331
336
  onClick: () => handlePresetClick(preset),
332
337
  children: preset.label
333
338
  },
@@ -341,8 +346,8 @@ function CalendarDateControl({
341
346
  variant: "tertiary",
342
347
  isPressed: !selectedPresetId,
343
348
  size: "small",
344
- disabled: !!selectedPresetId,
345
- accessibleWhenDisabled: false,
349
+ disabled: !!selectedPresetId || disabled,
350
+ accessibleWhenDisabled: true,
346
351
  children: __("Custom")
347
352
  }
348
353
  )
@@ -359,7 +364,10 @@ function CalendarDateControl({
359
364
  hideLabelFromVision: true,
360
365
  value,
361
366
  onChange: handleManualDateChange,
362
- required: !!field.isValid?.required
367
+ required: !!field.isValid?.required,
368
+ disabled,
369
+ min: minConstraint,
370
+ max: maxConstraint
363
371
  }
364
372
  ),
365
373
  /* @__PURE__ */ jsx(
@@ -371,7 +379,9 @@ function CalendarDateControl({
371
379
  month: calendarMonth,
372
380
  onMonthChange: setCalendarMonth,
373
381
  timeZone: timezoneString || void 0,
374
- weekStartsOn
382
+ weekStartsOn,
383
+ disabled: disabled || disabledMatchers,
384
+ disableNavigation: disabled
375
385
  }
376
386
  )
377
387
  ] })
@@ -394,14 +404,17 @@ function CalendarDateRangeControl({
394
404
  description,
395
405
  getValue,
396
406
  setValue,
407
+ isValid,
397
408
  format: fieldFormat
398
409
  } = field;
410
+ const disabled = field.isDisabled({ item: data, field });
399
411
  let value;
400
412
  const fieldValue = getValue({ item: data });
401
413
  if (Array.isArray(fieldValue) && fieldValue.length === 2 && fieldValue.every((date) => typeof date === "string")) {
402
414
  value = fieldValue;
403
415
  }
404
416
  const weekStartsOn = fieldFormat.weekStartsOn ?? getSettings().l10n.startOfWeek;
417
+ const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid, parseDate);
405
418
  const onChangeCallback = useCallback(
406
419
  (newValue) => {
407
420
  onChange(
@@ -524,6 +537,8 @@ function CalendarDateRangeControl({
524
537
  variant: "tertiary",
525
538
  isPressed: isSelected,
526
539
  size: "small",
540
+ disabled,
541
+ accessibleWhenDisabled: true,
527
542
  onClick: () => handlePresetClick(preset),
528
543
  children: preset.label
529
544
  },
@@ -537,8 +552,8 @@ function CalendarDateRangeControl({
537
552
  variant: "tertiary",
538
553
  isPressed: !selectedPresetId,
539
554
  size: "small",
540
- accessibleWhenDisabled: false,
541
- disabled: !!selectedPresetId,
555
+ accessibleWhenDisabled: true,
556
+ disabled: !!selectedPresetId || disabled,
542
557
  children: __("Custom")
543
558
  }
544
559
  )
@@ -563,7 +578,10 @@ function CalendarDateRangeControl({
563
578
  hideLabelFromVision: true,
564
579
  value: value?.[0],
565
580
  onChange: (newValue) => handleManualDateChange("from", newValue),
566
- required: !!field.isValid?.required
581
+ required: !!field.isValid?.required,
582
+ disabled,
583
+ min: minConstraint,
584
+ max: maxConstraint
567
585
  }
568
586
  ),
569
587
  /* @__PURE__ */ jsx(
@@ -576,7 +594,10 @@ function CalendarDateRangeControl({
576
594
  hideLabelFromVision: true,
577
595
  value: value?.[1],
578
596
  onChange: (newValue) => handleManualDateChange("to", newValue),
579
- required: !!field.isValid?.required
597
+ required: !!field.isValid?.required,
598
+ disabled,
599
+ min: minConstraint,
600
+ max: maxConstraint
580
601
  }
581
602
  )
582
603
  ]
@@ -591,7 +612,8 @@ function CalendarDateRangeControl({
591
612
  month: calendarMonth,
592
613
  onMonthChange: setCalendarMonth,
593
614
  timeZone: timezone.string || void 0,
594
- weekStartsOn
615
+ weekStartsOn,
616
+ disabled: disabled || disabledMatchers
595
617
  }
596
618
  )
597
619
  ] })
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/dataform-controls/date.tsx"],
4
- "sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\nimport {\n\tformat,\n\tisValid as isValidDate,\n\tsubMonths,\n\tsubDays,\n\tsubYears,\n\tstartOfMonth,\n\tstartOfYear,\n} from 'date-fns';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tBaseControl,\n\tButton,\n\tIcon,\n\tprivateApis as componentsPrivateApis,\n\t__experimentalInputControl as InputControl,\n} from '@wordpress/components';\nimport {\n\tuseCallback,\n\tuseEffect,\n\tuseMemo,\n\tuseRef,\n\tuseState,\n} from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { getDate, getSettings } from '@wordpress/date';\nimport { error as errorIcon } from '@wordpress/icons';\nimport { Stack } from '@wordpress/ui';\n\n/**\n * Internal dependencies\n */\nimport RelativeDateControl from './utils/relative-date-control';\nimport {\n\tOPERATOR_IN_THE_PAST,\n\tOPERATOR_OVER,\n\tOPERATOR_BETWEEN,\n} from '../../constants';\nimport { unlock } from '../../lock-unlock';\nimport type {\n\tDataFormControlProps,\n\tFieldValidity,\n\tFormatDate,\n\tNormalizedField,\n} from '../../types';\nimport getCustomValidity from './utils/get-custom-validity';\n\nconst { DateCalendar, DateRangeCalendar } = unlock( componentsPrivateApis );\n\ntype DateRange = [ string, string ] | undefined;\n\nconst DATE_PRESETS: {\n\tid: string;\n\tlabel: string;\n\tgetValue: () => Date;\n}[] = [\n\t{\n\t\tid: 'today',\n\t\tlabel: __( 'Today' ),\n\t\tgetValue: () => getDate( null ),\n\t},\n\t{\n\t\tid: 'yesterday',\n\t\tlabel: __( 'Yesterday' ),\n\t\tgetValue: () => {\n\t\t\tconst today = getDate( null );\n\t\t\treturn subDays( today, 1 );\n\t\t},\n\t},\n\t{\n\t\tid: 'past-week',\n\t\tlabel: __( 'Past week' ),\n\t\tgetValue: () => {\n\t\t\tconst today = getDate( null );\n\t\t\treturn subDays( today, 7 );\n\t\t},\n\t},\n\t{\n\t\tid: 'past-month',\n\t\tlabel: __( 'Past month' ),\n\t\tgetValue: () => {\n\t\t\tconst today = getDate( null );\n\t\t\treturn subMonths( today, 1 );\n\t\t},\n\t},\n];\n\nconst DATE_RANGE_PRESETS = [\n\t{\n\t\tid: 'last-7-days',\n\t\tlabel: __( 'Last 7 days' ),\n\t\tgetValue: () => {\n\t\t\tconst today = getDate( null );\n\t\t\treturn [ subDays( today, 7 ), today ];\n\t\t},\n\t},\n\t{\n\t\tid: 'last-30-days',\n\t\tlabel: __( 'Last 30 days' ),\n\t\tgetValue: () => {\n\t\t\tconst today = getDate( null );\n\t\t\treturn [ subDays( today, 30 ), today ];\n\t\t},\n\t},\n\t{\n\t\tid: 'month-to-date',\n\t\tlabel: __( 'Month to date' ),\n\t\tgetValue: () => {\n\t\t\tconst today = getDate( null );\n\t\t\treturn [ startOfMonth( today ), today ];\n\t\t},\n\t},\n\t{\n\t\tid: 'last-year',\n\t\tlabel: __( 'Last year' ),\n\t\tgetValue: () => {\n\t\t\tconst today = getDate( null );\n\t\t\treturn [ subYears( today, 1 ), today ];\n\t\t},\n\t},\n\t{\n\t\tid: 'year-to-date',\n\t\tlabel: __( 'Year to date' ),\n\t\tgetValue: () => {\n\t\t\tconst today = getDate( null );\n\t\t\treturn [ startOfYear( today ), today ];\n\t\t},\n\t},\n];\n\nconst parseDate = ( dateString?: string ): Date | null => {\n\tif ( ! dateString ) {\n\t\treturn null;\n\t}\n\tconst parsed = getDate( dateString );\n\treturn parsed && isValidDate( parsed ) ? parsed : null;\n};\n\nconst formatDate = ( date?: Date | string ): string => {\n\tif ( ! date ) {\n\t\treturn '';\n\t}\n\treturn typeof date === 'string' ? date : format( date, 'yyyy-MM-dd' );\n};\n\nfunction ValidatedDateControl< Item >( {\n\tfield,\n\tvalidity,\n\tinputRefs,\n\tisTouched,\n\tsetIsTouched,\n\tchildren,\n}: {\n\tfield: NormalizedField< Item >;\n\tvalidity?: FieldValidity;\n\tinputRefs:\n\t\t| React.RefObject< HTMLInputElement | null >\n\t\t| React.RefObject< HTMLInputElement | null >[];\n\tisTouched: boolean;\n\tsetIsTouched: ( touched: boolean ) => void;\n\tchildren: React.ReactNode;\n} ) {\n\tconst { isValid } = field;\n\tconst [ customValidity, setCustomValidity ] = useState<\n\t\t| { type: 'valid' | 'validating' | 'invalid'; message?: string }\n\t\t| undefined\n\t>( undefined );\n\n\tconst validateRefs = useCallback( () => {\n\t\t// Check HTML5 validity on all refs\n\t\tconst refs = Array.isArray( inputRefs ) ? inputRefs : [ inputRefs ];\n\t\tfor ( const ref of refs ) {\n\t\t\tconst input = ref.current;\n\t\t\tif ( input && ! input.validity.valid ) {\n\t\t\t\tsetCustomValidity( {\n\t\t\t\t\ttype: 'invalid',\n\t\t\t\t\tmessage: input.validationMessage,\n\t\t\t\t} );\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\t// No errors\n\t\tsetCustomValidity( undefined );\n\t}, [ inputRefs ] );\n\n\t// Sync React-level validation to native inputs.\n\tuseEffect( () => {\n\t\tconst refs = Array.isArray( inputRefs ) ? inputRefs : [ inputRefs ];\n\t\tconst result = validity\n\t\t\t? getCustomValidity( isValid, validity )\n\t\t\t: undefined;\n\t\tfor ( const ref of refs ) {\n\t\t\tconst input = ref.current;\n\t\t\tif ( input ) {\n\t\t\t\tinput.setCustomValidity(\n\t\t\t\t\tresult?.type === 'invalid' && result.message\n\t\t\t\t\t\t? result.message\n\t\t\t\t\t\t: ''\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}, [ inputRefs, isValid, validity ] );\n\n\t// Listen for 'invalid' events (e.g., from reportValidity() on card re-expand).\n\tuseEffect( () => {\n\t\tconst refs = Array.isArray( inputRefs ) ? inputRefs : [ inputRefs ];\n\t\tconst handleInvalid = ( event: Event ) => {\n\t\t\tevent.preventDefault();\n\t\t\tsetIsTouched( true );\n\t\t};\n\t\tfor ( const ref of refs ) {\n\t\t\tref.current?.addEventListener( 'invalid', handleInvalid );\n\t\t}\n\t\treturn () => {\n\t\t\tfor ( const ref of refs ) {\n\t\t\t\tref.current?.removeEventListener( 'invalid', handleInvalid );\n\t\t\t}\n\t\t};\n\t}, [ inputRefs, setIsTouched ] );\n\n\tuseEffect( () => {\n\t\tif ( ! isTouched ) {\n\t\t\treturn;\n\t\t}\n\t\tconst result = validity\n\t\t\t? getCustomValidity( isValid, validity )\n\t\t\t: undefined;\n\t\tif ( result ) {\n\t\t\tsetCustomValidity( result );\n\t\t} else {\n\t\t\tvalidateRefs();\n\t\t}\n\t}, [ isTouched, isValid, validity, validateRefs ] );\n\n\tconst onBlur = ( event: React.FocusEvent< HTMLDivElement > ) => {\n\t\tif ( isTouched ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Only consider \"blurred from the component\" if focus has fully left the wrapping div.\n\t\t// This prevents unnecessary blurs from components with multiple focusable elements.\n\t\tif (\n\t\t\t! event.relatedTarget ||\n\t\t\t! event.currentTarget.contains( event.relatedTarget )\n\t\t) {\n\t\t\tsetIsTouched( true );\n\t\t}\n\t};\n\n\treturn (\n\t\t<div onBlur={ onBlur }>\n\t\t\t{ children }\n\t\t\t<div aria-live=\"polite\">\n\t\t\t\t{ customValidity && (\n\t\t\t\t\t<p\n\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t'components-validated-control__indicator',\n\t\t\t\t\t\t\tcustomValidity.type === 'invalid'\n\t\t\t\t\t\t\t\t? 'is-invalid'\n\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t) }\n\t\t\t\t\t>\n\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\tclassName=\"components-validated-control__indicator-icon\"\n\t\t\t\t\t\t\ticon={ errorIcon }\n\t\t\t\t\t\t\tsize={ 16 }\n\t\t\t\t\t\t\tfill=\"currentColor\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{ customValidity.message }\n\t\t\t\t\t</p>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n\nfunction CalendarDateControl< Item >( {\n\tdata,\n\tfield,\n\tonChange,\n\thideLabelFromVision,\n\tmarkWhenOptional,\n\tvalidity,\n}: DataFormControlProps< Item > ) {\n\tconst {\n\t\tid,\n\t\tlabel,\n\t\tdescription,\n\t\tsetValue,\n\t\tgetValue,\n\t\tisValid,\n\t\tformat: fieldFormat,\n\t} = field;\n\tconst [ selectedPresetId, setSelectedPresetId ] = useState< string | null >(\n\t\tnull\n\t);\n\n\tconst weekStartsOn =\n\t\t( fieldFormat as FormatDate ).weekStartsOn ??\n\t\tgetSettings().l10n.startOfWeek;\n\n\tconst fieldValue = getValue( { item: data } );\n\tconst value = typeof fieldValue === 'string' ? fieldValue : undefined;\n\tconst [ calendarMonth, setCalendarMonth ] = useState< Date >( () => {\n\t\tconst parsedDate = parseDate( value );\n\t\treturn parsedDate || new Date(); // Default to current month\n\t} );\n\n\tconst [ isTouched, setIsTouched ] = useState( false );\n\tconst validityTargetRef = useRef< HTMLInputElement >( null );\n\n\tconst onChangeCallback = useCallback(\n\t\t( newValue: string | undefined ) =>\n\t\t\tonChange( setValue( { item: data, value: newValue } ) ),\n\t\t[ data, onChange, setValue ]\n\t);\n\n\tconst onSelectDate = useCallback(\n\t\t( newDate: Date | undefined | null ) => {\n\t\t\tconst dateValue = newDate\n\t\t\t\t? format( newDate, 'yyyy-MM-dd' )\n\t\t\t\t: undefined;\n\t\t\tonChangeCallback( dateValue );\n\t\t\tsetSelectedPresetId( null );\n\t\t\tsetIsTouched( true );\n\t\t},\n\t\t[ onChangeCallback ]\n\t);\n\n\tconst handlePresetClick = useCallback(\n\t\t( preset: ( typeof DATE_PRESETS )[ 0 ] ) => {\n\t\t\tconst presetDate = preset.getValue();\n\t\t\tconst dateValue = formatDate( presetDate );\n\n\t\t\tsetCalendarMonth( presetDate );\n\t\t\tonChangeCallback( dateValue );\n\t\t\tsetSelectedPresetId( preset.id );\n\t\t\tsetIsTouched( true );\n\t\t},\n\t\t[ onChangeCallback ]\n\t);\n\n\tconst handleManualDateChange = useCallback(\n\t\t( newValue?: string ) => {\n\t\t\tonChangeCallback( newValue );\n\t\t\tif ( newValue ) {\n\t\t\t\tconst parsedDate = parseDate( newValue );\n\t\t\t\tif ( parsedDate ) {\n\t\t\t\t\tsetCalendarMonth( parsedDate );\n\t\t\t\t}\n\t\t\t}\n\t\t\tsetSelectedPresetId( null );\n\t\t\tsetIsTouched( true );\n\t\t},\n\t\t[ onChangeCallback ]\n\t);\n\n\tconst {\n\t\ttimezone: { string: timezoneString },\n\t} = getSettings();\n\n\tlet displayLabel = label;\n\tif ( isValid?.required && ! markWhenOptional ) {\n\t\tdisplayLabel = `${ label } (${ __( 'Required' ) })`;\n\t} else if ( ! isValid?.required && markWhenOptional ) {\n\t\tdisplayLabel = `${ label } (${ __( 'Optional' ) })`;\n\t}\n\n\treturn (\n\t\t<ValidatedDateControl\n\t\t\tfield={ field }\n\t\t\tvalidity={ validity }\n\t\t\tinputRefs={ validityTargetRef }\n\t\t\tisTouched={ isTouched }\n\t\t\tsetIsTouched={ setIsTouched }\n\t\t>\n\t\t\t<BaseControl\n\t\t\t\tid={ id }\n\t\t\t\tclassName=\"dataviews-controls__date\"\n\t\t\t\tlabel={ displayLabel }\n\t\t\t\thelp={ description }\n\t\t\t\thideLabelFromVision={ hideLabelFromVision }\n\t\t\t>\n\t\t\t\t<Stack direction=\"column\" gap=\"lg\">\n\t\t\t\t\t{ /* Preset buttons */ }\n\t\t\t\t\t<Stack\n\t\t\t\t\t\tdirection=\"row\"\n\t\t\t\t\t\tgap=\"sm\"\n\t\t\t\t\t\twrap=\"wrap\"\n\t\t\t\t\t\tjustify=\"flex-start\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ DATE_PRESETS.map( ( preset ) => {\n\t\t\t\t\t\t\tconst isSelected = selectedPresetId === preset.id;\n\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tclassName=\"dataviews-controls__date-preset\"\n\t\t\t\t\t\t\t\t\tkey={ preset.id }\n\t\t\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\t\t\tisPressed={ isSelected }\n\t\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\t\t\thandlePresetClick( preset )\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ preset.label }\n\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} ) }\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tclassName=\"dataviews-controls__date-preset\"\n\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\tisPressed={ ! selectedPresetId }\n\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\tdisabled={ !! selectedPresetId }\n\t\t\t\t\t\t\taccessibleWhenDisabled={ false }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Custom' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</Stack>\n\n\t\t\t\t\t{ /* Manual date input */ }\n\t\t\t\t\t<InputControl\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tref={ validityTargetRef }\n\t\t\t\t\t\ttype=\"date\"\n\t\t\t\t\t\tlabel={ __( 'Date' ) }\n\t\t\t\t\t\thideLabelFromVision\n\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\tonChange={ handleManualDateChange }\n\t\t\t\t\t\trequired={ !! field.isValid?.required }\n\t\t\t\t\t/>\n\n\t\t\t\t\t{ /* Calendar widget */ }\n\t\t\t\t\t<DateCalendar\n\t\t\t\t\t\tstyle={ { width: '100%' } }\n\t\t\t\t\t\tselected={\n\t\t\t\t\t\t\tvalue ? parseDate( value ) || undefined : undefined\n\t\t\t\t\t\t}\n\t\t\t\t\t\tonSelect={ onSelectDate }\n\t\t\t\t\t\tmonth={ calendarMonth }\n\t\t\t\t\t\tonMonthChange={ setCalendarMonth }\n\t\t\t\t\t\ttimeZone={ timezoneString || undefined }\n\t\t\t\t\t\tweekStartsOn={ weekStartsOn }\n\t\t\t\t\t/>\n\t\t\t\t</Stack>\n\t\t\t</BaseControl>\n\t\t</ValidatedDateControl>\n\t);\n}\n\nfunction CalendarDateRangeControl< Item >( {\n\tdata,\n\tfield,\n\tonChange,\n\thideLabelFromVision,\n\tmarkWhenOptional,\n\tvalidity,\n}: DataFormControlProps< Item > ) {\n\tconst {\n\t\tid,\n\t\tlabel,\n\t\tdescription,\n\t\tgetValue,\n\t\tsetValue,\n\t\tformat: fieldFormat,\n\t} = field;\n\tlet value: DateRange;\n\tconst fieldValue = getValue( { item: data } );\n\tif (\n\t\tArray.isArray( fieldValue ) &&\n\t\tfieldValue.length === 2 &&\n\t\tfieldValue.every( ( date ) => typeof date === 'string' )\n\t) {\n\t\tvalue = fieldValue as DateRange;\n\t}\n\n\tconst weekStartsOn =\n\t\t( fieldFormat as FormatDate ).weekStartsOn ??\n\t\tgetSettings().l10n.startOfWeek;\n\n\tconst onChangeCallback = useCallback(\n\t\t( newValue: DateRange ) => {\n\t\t\tonChange(\n\t\t\t\tsetValue( {\n\t\t\t\t\titem: data,\n\t\t\t\t\tvalue: newValue,\n\t\t\t\t} )\n\t\t\t);\n\t\t},\n\t\t[ data, onChange, setValue ]\n\t);\n\n\tconst [ selectedPresetId, setSelectedPresetId ] = useState< string | null >(\n\t\tnull\n\t);\n\n\tconst selectedRange = useMemo( () => {\n\t\tif ( ! value ) {\n\t\t\treturn { from: undefined, to: undefined };\n\t\t}\n\n\t\tconst [ from, to ] = value;\n\t\treturn {\n\t\t\tfrom: parseDate( from ) || undefined,\n\t\t\tto: parseDate( to ) || undefined,\n\t\t};\n\t}, [ value ] );\n\n\tconst [ calendarMonth, setCalendarMonth ] = useState< Date >( () => {\n\t\treturn selectedRange.from || new Date();\n\t} );\n\n\tconst [ isTouched, setIsTouched ] = useState( false );\n\tconst fromInputRef = useRef< HTMLInputElement >( null );\n\tconst toInputRef = useRef< HTMLInputElement >( null );\n\n\tconst updateDateRange = useCallback(\n\t\t( fromDate?: Date | string, toDate?: Date | string ) => {\n\t\t\tif ( fromDate && toDate ) {\n\t\t\t\tonChangeCallback( [\n\t\t\t\t\tformatDate( fromDate ),\n\t\t\t\t\tformatDate( toDate ),\n\t\t\t\t] );\n\t\t\t} else if ( ! fromDate && ! toDate ) {\n\t\t\t\tonChangeCallback( undefined );\n\t\t\t}\n\t\t\t// Do nothing if only one date is set - wait for both\n\t\t},\n\t\t[ onChangeCallback ]\n\t);\n\n\tconst onSelectCalendarRange = useCallback(\n\t\t(\n\t\t\tnewRange:\n\t\t\t\t| { from: Date | undefined; to?: Date | undefined }\n\t\t\t\t| undefined\n\t\t) => {\n\t\t\tupdateDateRange( newRange?.from, newRange?.to );\n\t\t\tsetSelectedPresetId( null );\n\t\t\tsetIsTouched( true );\n\t\t},\n\t\t[ updateDateRange ]\n\t);\n\n\tconst handlePresetClick = useCallback(\n\t\t( preset: ( typeof DATE_RANGE_PRESETS )[ 0 ] ) => {\n\t\t\tconst [ startDate, endDate ] = preset.getValue();\n\t\t\tsetCalendarMonth( startDate );\n\t\t\tupdateDateRange( startDate, endDate );\n\t\t\tsetSelectedPresetId( preset.id );\n\t\t\tsetIsTouched( true );\n\t\t},\n\t\t[ updateDateRange ]\n\t);\n\n\tconst handleManualDateChange = useCallback(\n\t\t( fromOrTo: 'from' | 'to', newValue?: string ) => {\n\t\t\tconst [ currentFrom, currentTo ] = value || [\n\t\t\t\tundefined,\n\t\t\t\tundefined,\n\t\t\t];\n\t\t\tconst updatedFrom = fromOrTo === 'from' ? newValue : currentFrom;\n\t\t\tconst updatedTo = fromOrTo === 'to' ? newValue : currentTo;\n\n\t\t\tupdateDateRange( updatedFrom, updatedTo );\n\n\t\t\tif ( newValue ) {\n\t\t\t\tconst parsedDate = parseDate( newValue );\n\t\t\t\tif ( parsedDate ) {\n\t\t\t\t\tsetCalendarMonth( parsedDate );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tsetSelectedPresetId( null );\n\t\t\tsetIsTouched( true );\n\t\t},\n\t\t[ value, updateDateRange ]\n\t);\n\n\tconst { timezone } = getSettings();\n\n\tlet displayLabel = label;\n\tif ( field.isValid?.required && ! markWhenOptional ) {\n\t\tdisplayLabel = `${ label } (${ __( 'Required' ) })`;\n\t} else if ( ! field.isValid?.required && markWhenOptional ) {\n\t\tdisplayLabel = `${ label } (${ __( 'Optional' ) })`;\n\t}\n\n\treturn (\n\t\t<ValidatedDateControl\n\t\t\tfield={ field }\n\t\t\tvalidity={ validity }\n\t\t\tinputRefs={ [ fromInputRef, toInputRef ] }\n\t\t\tisTouched={ isTouched }\n\t\t\tsetIsTouched={ setIsTouched }\n\t\t>\n\t\t\t<BaseControl\n\t\t\t\tid={ id }\n\t\t\t\tclassName=\"dataviews-controls__date\"\n\t\t\t\tlabel={ displayLabel }\n\t\t\t\thelp={ description }\n\t\t\t\thideLabelFromVision={ hideLabelFromVision }\n\t\t\t>\n\t\t\t\t<Stack direction=\"column\" gap=\"lg\">\n\t\t\t\t\t{ /* Preset buttons */ }\n\t\t\t\t\t<Stack\n\t\t\t\t\t\tdirection=\"row\"\n\t\t\t\t\t\tgap=\"sm\"\n\t\t\t\t\t\twrap=\"wrap\"\n\t\t\t\t\t\tjustify=\"flex-start\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ DATE_RANGE_PRESETS.map( ( preset ) => {\n\t\t\t\t\t\t\tconst isSelected = selectedPresetId === preset.id;\n\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tclassName=\"dataviews-controls__date-preset\"\n\t\t\t\t\t\t\t\t\tkey={ preset.id }\n\t\t\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\t\t\tisPressed={ isSelected }\n\t\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\t\t\thandlePresetClick( preset )\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ preset.label }\n\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} ) }\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tclassName=\"dataviews-controls__date-preset\"\n\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\tisPressed={ ! selectedPresetId }\n\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\taccessibleWhenDisabled={ false }\n\t\t\t\t\t\t\tdisabled={ !! selectedPresetId }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Custom' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</Stack>\n\n\t\t\t\t\t{ /* Manual date range inputs */ }\n\t\t\t\t\t<Stack\n\t\t\t\t\t\tdirection=\"row\"\n\t\t\t\t\t\tgap=\"sm\"\n\t\t\t\t\t\tjustify=\"space-between\"\n\t\t\t\t\t\tclassName=\"dataviews-controls__date-range-inputs\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<InputControl\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tref={ fromInputRef }\n\t\t\t\t\t\t\ttype=\"date\"\n\t\t\t\t\t\t\tlabel={ __( 'From' ) }\n\t\t\t\t\t\t\thideLabelFromVision\n\t\t\t\t\t\t\tvalue={ value?.[ 0 ] }\n\t\t\t\t\t\t\tonChange={ ( newValue ) =>\n\t\t\t\t\t\t\t\thandleManualDateChange( 'from', newValue )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\trequired={ !! field.isValid?.required }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<InputControl\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tref={ toInputRef }\n\t\t\t\t\t\t\ttype=\"date\"\n\t\t\t\t\t\t\tlabel={ __( 'To' ) }\n\t\t\t\t\t\t\thideLabelFromVision\n\t\t\t\t\t\t\tvalue={ value?.[ 1 ] }\n\t\t\t\t\t\t\tonChange={ ( newValue ) =>\n\t\t\t\t\t\t\t\thandleManualDateChange( 'to', newValue )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\trequired={ !! field.isValid?.required }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</Stack>\n\n\t\t\t\t\t<DateRangeCalendar\n\t\t\t\t\t\tstyle={ { width: '100%' } }\n\t\t\t\t\t\tselected={ selectedRange }\n\t\t\t\t\t\tonSelect={ onSelectCalendarRange }\n\t\t\t\t\t\tmonth={ calendarMonth }\n\t\t\t\t\t\tonMonthChange={ setCalendarMonth }\n\t\t\t\t\t\ttimeZone={ timezone.string || undefined }\n\t\t\t\t\t\tweekStartsOn={ weekStartsOn }\n\t\t\t\t\t/>\n\t\t\t\t</Stack>\n\t\t\t</BaseControl>\n\t\t</ValidatedDateControl>\n\t);\n}\n\nexport default function DateControl< Item >( {\n\tdata,\n\tfield,\n\tonChange,\n\thideLabelFromVision,\n\tmarkWhenOptional,\n\toperator,\n\tvalidity,\n}: DataFormControlProps< Item > ) {\n\tif ( operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER ) {\n\t\treturn (\n\t\t\t<RelativeDateControl\n\t\t\t\tclassName=\"dataviews-controls__date\"\n\t\t\t\tdata={ data }\n\t\t\t\tfield={ field }\n\t\t\t\tonChange={ onChange }\n\t\t\t\thideLabelFromVision={ hideLabelFromVision }\n\t\t\t\toperator={ operator }\n\t\t\t/>\n\t\t);\n\t}\n\n\tif ( operator === OPERATOR_BETWEEN ) {\n\t\treturn (\n\t\t\t<CalendarDateRangeControl\n\t\t\t\tdata={ data }\n\t\t\t\tfield={ field }\n\t\t\t\tonChange={ onChange }\n\t\t\t\thideLabelFromVision={ hideLabelFromVision }\n\t\t\t\tmarkWhenOptional={ markWhenOptional }\n\t\t\t\tvalidity={ validity }\n\t\t\t/>\n\t\t);\n\t}\n\n\treturn (\n\t\t<CalendarDateControl\n\t\t\tdata={ data }\n\t\t\tfield={ field }\n\t\t\tonChange={ onChange }\n\t\t\thideLabelFromVision={ hideLabelFromVision }\n\t\t\tmarkWhenOptional={ markWhenOptional }\n\t\t\tvalidity={ validity }\n\t\t/>\n\t);\n}\n"],
5
- "mappings": ";AAGA,OAAO,UAAU;AACjB;AAAA,EACC;AAAA,EACA,WAAW;AAAA,EACX;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAKP;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA,eAAe;AAAA,EACf,8BAA8B;AAAA,OACxB;AACP;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,UAAU;AACnB,SAAS,SAAS,mBAAmB;AACrC,SAAS,SAAS,iBAAiB;AACnC,SAAS,aAAa;AAKtB,OAAO,yBAAyB;AAChC;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,cAAc;AAOvB,OAAO,uBAAuB;AAkNzB,SAQC,KARD;AAhNL,IAAM,EAAE,cAAc,kBAAkB,IAAI,OAAQ,qBAAsB;AAI1E,IAAM,eAIA;AAAA,EACL;AAAA,IACC,IAAI;AAAA,IACJ,OAAO,GAAI,OAAQ;AAAA,IACnB,UAAU,MAAM,QAAS,IAAK;AAAA,EAC/B;AAAA,EACA;AAAA,IACC,IAAI;AAAA,IACJ,OAAO,GAAI,WAAY;AAA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cAAC;AAAA;AAAA,gBACA,OAAQ,EAAE,OAAO,OAAO;AAAA,gBACxB,UAAW;AAAA,gBACX,UAAW;AAAA,gBACX,OAAQ;AAAA,gBACR,eAAgB;AAAA,gBAChB,UAAW,SAAS,UAAU;AAAA,gBAC9B;AAAA;AAAA,YACD;AAAA,aACD;AAAA;AAAA,MACD;AAAA;AAAA,EACD;AAEF;AAEe,SAAR,YAAsC;AAAA,EAC5C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAkC;AACjC,MAAK,aAAa,wBAAwB,aAAa,eAAgB;AACtE,WACC;AAAA,MAAC;AAAA;AAAA,QACA,WAAU;AAAA,QACV;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA;AAAA,IACD;AAAA,EAEF;AAEA,MAAK,aAAa,kBAAmB;AACpC,WACC;AAAA,MAAC;AAAA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA;AAAA,IACD;AAAA,EAEF;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAAA,EACD;AAEF;",
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\nimport {\n\tformat,\n\tisValid as isValidDate,\n\tsubMonths,\n\tsubDays,\n\tsubYears,\n\tstartOfMonth,\n\tstartOfYear,\n} from 'date-fns';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tBaseControl,\n\tButton,\n\tIcon,\n\tprivateApis as componentsPrivateApis,\n\t__experimentalInputControl as InputControl,\n} from '@wordpress/components';\nimport {\n\tuseCallback,\n\tuseEffect,\n\tuseMemo,\n\tuseRef,\n\tuseState,\n} from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { getDate, getSettings } from '@wordpress/date';\nimport { error as errorIcon } from '@wordpress/icons';\nimport { Stack } from '@wordpress/ui';\n\n/**\n * Internal dependencies\n */\nimport RelativeDateControl from './utils/relative-date-control';\nimport useDisabledDateMatchers from './utils/use-disabled-date-matchers';\nimport {\n\tOPERATOR_IN_THE_PAST,\n\tOPERATOR_OVER,\n\tOPERATOR_BETWEEN,\n} from '../../constants';\nimport { unlock } from '../../lock-unlock';\nimport type {\n\tDataFormControlProps,\n\tFieldValidity,\n\tFormatDate,\n\tNormalizedField,\n} from '../../types';\nimport getCustomValidity from './utils/get-custom-validity';\n\nconst { DateCalendar, DateRangeCalendar } = unlock( componentsPrivateApis );\n\ntype DateRange = [ string, string ] | undefined;\n\nconst DATE_PRESETS: {\n\tid: string;\n\tlabel: string;\n\tgetValue: () => Date;\n}[] = [\n\t{\n\t\tid: 'today',\n\t\tlabel: __( 'Today' ),\n\t\tgetValue: () => getDate( null ),\n\t},\n\t{\n\t\tid: 'yesterday',\n\t\tlabel: __( 'Yesterday' ),\n\t\tgetValue: () => {\n\t\t\tconst today = getDate( null );\n\t\t\treturn subDays( today, 1 );\n\t\t},\n\t},\n\t{\n\t\tid: 'past-week',\n\t\tlabel: __( 'Past week' ),\n\t\tgetValue: () => {\n\t\t\tconst today = getDate( null );\n\t\t\treturn subDays( today, 7 );\n\t\t},\n\t},\n\t{\n\t\tid: 'past-month',\n\t\tlabel: __( 'Past month' ),\n\t\tgetValue: () => {\n\t\t\tconst today = getDate( null );\n\t\t\treturn subMonths( today, 1 );\n\t\t},\n\t},\n];\n\nconst DATE_RANGE_PRESETS = [\n\t{\n\t\tid: 'last-7-days',\n\t\tlabel: __( 'Last 7 days' ),\n\t\tgetValue: () => {\n\t\t\tconst today = getDate( null );\n\t\t\treturn [ subDays( today, 7 ), today ];\n\t\t},\n\t},\n\t{\n\t\tid: 'last-30-days',\n\t\tlabel: __( 'Last 30 days' ),\n\t\tgetValue: () => {\n\t\t\tconst today = getDate( null );\n\t\t\treturn [ subDays( today, 30 ), today ];\n\t\t},\n\t},\n\t{\n\t\tid: 'month-to-date',\n\t\tlabel: __( 'Month to date' ),\n\t\tgetValue: () => {\n\t\t\tconst today = getDate( null );\n\t\t\treturn [ startOfMonth( today ), today ];\n\t\t},\n\t},\n\t{\n\t\tid: 'last-year',\n\t\tlabel: __( 'Last year' ),\n\t\tgetValue: () => {\n\t\t\tconst today = getDate( null );\n\t\t\treturn [ subYears( today, 1 ), today ];\n\t\t},\n\t},\n\t{\n\t\tid: 'year-to-date',\n\t\tlabel: __( 'Year to date' ),\n\t\tgetValue: () => {\n\t\t\tconst today = getDate( null );\n\t\t\treturn [ startOfYear( today ), today ];\n\t\t},\n\t},\n];\n\nconst parseDate = ( dateString?: string ): Date | null => {\n\tif ( ! dateString ) {\n\t\treturn null;\n\t}\n\tconst parsed = getDate( dateString );\n\treturn parsed && isValidDate( parsed ) ? parsed : null;\n};\n\nconst formatDate = ( date?: Date | string ): string => {\n\tif ( ! date ) {\n\t\treturn '';\n\t}\n\treturn typeof date === 'string' ? date : format( date, 'yyyy-MM-dd' );\n};\n\nfunction ValidatedDateControl< Item >( {\n\tfield,\n\tvalidity,\n\tinputRefs,\n\tisTouched,\n\tsetIsTouched,\n\tchildren,\n}: {\n\tfield: NormalizedField< Item >;\n\tvalidity?: FieldValidity;\n\tinputRefs:\n\t\t| React.RefObject< HTMLInputElement | null >\n\t\t| React.RefObject< HTMLInputElement | null >[];\n\tisTouched: boolean;\n\tsetIsTouched: ( touched: boolean ) => void;\n\tchildren: React.ReactNode;\n} ) {\n\tconst { isValid } = field;\n\tconst [ customValidity, setCustomValidity ] = useState<\n\t\t| { type: 'valid' | 'validating' | 'invalid'; message?: string }\n\t\t| undefined\n\t>( undefined );\n\n\tconst validateRefs = useCallback( () => {\n\t\t// Check HTML5 validity on all refs\n\t\tconst refs = Array.isArray( inputRefs ) ? inputRefs : [ inputRefs ];\n\t\tfor ( const ref of refs ) {\n\t\t\tconst input = ref.current;\n\t\t\tif ( input && ! input.validity.valid ) {\n\t\t\t\tsetCustomValidity( {\n\t\t\t\t\ttype: 'invalid',\n\t\t\t\t\tmessage: input.validationMessage,\n\t\t\t\t} );\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\t// No errors\n\t\tsetCustomValidity( undefined );\n\t}, [ inputRefs ] );\n\n\t// Sync React-level validation to native inputs.\n\tuseEffect( () => {\n\t\tconst refs = Array.isArray( inputRefs ) ? inputRefs : [ inputRefs ];\n\t\tconst result = validity\n\t\t\t? getCustomValidity( isValid, validity )\n\t\t\t: undefined;\n\t\tfor ( const ref of refs ) {\n\t\t\tconst input = ref.current;\n\t\t\tif ( input ) {\n\t\t\t\tinput.setCustomValidity(\n\t\t\t\t\tresult?.type === 'invalid' && result.message\n\t\t\t\t\t\t? result.message\n\t\t\t\t\t\t: ''\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}, [ inputRefs, isValid, validity ] );\n\n\t// Listen for 'invalid' events (e.g., from reportValidity() on card re-expand).\n\tuseEffect( () => {\n\t\tconst refs = Array.isArray( inputRefs ) ? inputRefs : [ inputRefs ];\n\t\tconst handleInvalid = ( event: Event ) => {\n\t\t\tevent.preventDefault();\n\t\t\tsetIsTouched( true );\n\t\t};\n\t\tfor ( const ref of refs ) {\n\t\t\tref.current?.addEventListener( 'invalid', handleInvalid );\n\t\t}\n\t\treturn () => {\n\t\t\tfor ( const ref of refs ) {\n\t\t\t\tref.current?.removeEventListener( 'invalid', handleInvalid );\n\t\t\t}\n\t\t};\n\t}, [ inputRefs, setIsTouched ] );\n\n\tuseEffect( () => {\n\t\tif ( ! isTouched ) {\n\t\t\treturn;\n\t\t}\n\t\tconst result = validity\n\t\t\t? getCustomValidity( isValid, validity )\n\t\t\t: undefined;\n\t\tif ( result ) {\n\t\t\tsetCustomValidity( result );\n\t\t} else {\n\t\t\tvalidateRefs();\n\t\t}\n\t}, [ isTouched, isValid, validity, validateRefs ] );\n\n\tconst onBlur = ( event: React.FocusEvent< HTMLDivElement > ) => {\n\t\tif ( isTouched ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Only consider \"blurred from the component\" if focus has fully left the wrapping div.\n\t\t// This prevents unnecessary blurs from components with multiple focusable elements.\n\t\tif (\n\t\t\t! event.relatedTarget ||\n\t\t\t! event.currentTarget.contains( event.relatedTarget )\n\t\t) {\n\t\t\tsetIsTouched( true );\n\t\t}\n\t};\n\n\treturn (\n\t\t<div onBlur={ onBlur }>\n\t\t\t{ children }\n\t\t\t<div aria-live=\"polite\">\n\t\t\t\t{ customValidity && (\n\t\t\t\t\t<p\n\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t'components-validated-control__indicator',\n\t\t\t\t\t\t\tcustomValidity.type === 'invalid'\n\t\t\t\t\t\t\t\t? 'is-invalid'\n\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t) }\n\t\t\t\t\t>\n\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\tclassName=\"components-validated-control__indicator-icon\"\n\t\t\t\t\t\t\ticon={ errorIcon }\n\t\t\t\t\t\t\tsize={ 16 }\n\t\t\t\t\t\t\tfill=\"currentColor\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{ customValidity.message }\n\t\t\t\t\t</p>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n\nfunction CalendarDateControl< Item >( {\n\tdata,\n\tfield,\n\tonChange,\n\thideLabelFromVision,\n\tmarkWhenOptional,\n\tvalidity,\n}: DataFormControlProps< Item > ) {\n\tconst {\n\t\tid,\n\t\tlabel,\n\t\tdescription,\n\t\tsetValue,\n\t\tgetValue,\n\t\tisValid,\n\t\tformat: fieldFormat,\n\t} = field;\n\tconst disabled = field.isDisabled( { item: data, field } );\n\tconst [ selectedPresetId, setSelectedPresetId ] = useState< string | null >(\n\t\tnull\n\t);\n\n\tconst weekStartsOn =\n\t\t( fieldFormat as FormatDate ).weekStartsOn ??\n\t\tgetSettings().l10n.startOfWeek;\n\n\tconst fieldValue = getValue( { item: data } );\n\tconst value = typeof fieldValue === 'string' ? fieldValue : undefined;\n\tconst [ calendarMonth, setCalendarMonth ] = useState< Date >( () => {\n\t\tconst parsedDate = parseDate( value );\n\t\treturn parsedDate || new Date(); // Default to current month\n\t} );\n\n\tconst [ isTouched, setIsTouched ] = useState( false );\n\tconst validityTargetRef = useRef< HTMLInputElement >( null );\n\n\tconst { minConstraint, maxConstraint, disabledMatchers } =\n\t\tuseDisabledDateMatchers( isValid, parseDate );\n\n\tconst onChangeCallback = useCallback(\n\t\t( newValue: string | undefined ) =>\n\t\t\tonChange( setValue( { item: data, value: newValue } ) ),\n\t\t[ data, onChange, setValue ]\n\t);\n\n\tconst onSelectDate = useCallback(\n\t\t( newDate: Date | undefined | null ) => {\n\t\t\tconst dateValue = newDate\n\t\t\t\t? format( newDate, 'yyyy-MM-dd' )\n\t\t\t\t: undefined;\n\t\t\tonChangeCallback( dateValue );\n\t\t\tsetSelectedPresetId( null );\n\t\t\tsetIsTouched( true );\n\t\t},\n\t\t[ onChangeCallback ]\n\t);\n\n\tconst handlePresetClick = useCallback(\n\t\t( preset: ( typeof DATE_PRESETS )[ 0 ] ) => {\n\t\t\tconst presetDate = preset.getValue();\n\t\t\tconst dateValue = formatDate( presetDate );\n\n\t\t\tsetCalendarMonth( presetDate );\n\t\t\tonChangeCallback( dateValue );\n\t\t\tsetSelectedPresetId( preset.id );\n\t\t\tsetIsTouched( true );\n\t\t},\n\t\t[ onChangeCallback ]\n\t);\n\n\tconst handleManualDateChange = useCallback(\n\t\t( newValue?: string ) => {\n\t\t\tonChangeCallback( newValue );\n\t\t\tif ( newValue ) {\n\t\t\t\tconst parsedDate = parseDate( newValue );\n\t\t\t\tif ( parsedDate ) {\n\t\t\t\t\tsetCalendarMonth( parsedDate );\n\t\t\t\t}\n\t\t\t}\n\t\t\tsetSelectedPresetId( null );\n\t\t\tsetIsTouched( true );\n\t\t},\n\t\t[ onChangeCallback ]\n\t);\n\n\tconst {\n\t\ttimezone: { string: timezoneString },\n\t} = getSettings();\n\n\tlet displayLabel = label;\n\tif ( isValid?.required && ! markWhenOptional ) {\n\t\tdisplayLabel = `${ label } (${ __( 'Required' ) })`;\n\t} else if ( ! isValid?.required && markWhenOptional ) {\n\t\tdisplayLabel = `${ label } (${ __( 'Optional' ) })`;\n\t}\n\n\treturn (\n\t\t<ValidatedDateControl\n\t\t\tfield={ field }\n\t\t\tvalidity={ validity }\n\t\t\tinputRefs={ validityTargetRef }\n\t\t\tisTouched={ isTouched }\n\t\t\tsetIsTouched={ setIsTouched }\n\t\t>\n\t\t\t<BaseControl\n\t\t\t\tid={ id }\n\t\t\t\tclassName=\"dataviews-controls__date\"\n\t\t\t\tlabel={ displayLabel }\n\t\t\t\thelp={ description }\n\t\t\t\thideLabelFromVision={ hideLabelFromVision }\n\t\t\t>\n\t\t\t\t<Stack direction=\"column\" gap=\"lg\">\n\t\t\t\t\t{ /* Preset buttons */ }\n\t\t\t\t\t<Stack\n\t\t\t\t\t\tdirection=\"row\"\n\t\t\t\t\t\tgap=\"sm\"\n\t\t\t\t\t\twrap=\"wrap\"\n\t\t\t\t\t\tjustify=\"flex-start\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ DATE_PRESETS.map( ( preset ) => {\n\t\t\t\t\t\t\tconst isSelected = selectedPresetId === preset.id;\n\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tclassName=\"dataviews-controls__date-preset\"\n\t\t\t\t\t\t\t\t\tkey={ preset.id }\n\t\t\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\t\t\tisPressed={ isSelected }\n\t\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t\t\tdisabled={ disabled }\n\t\t\t\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\t\t\thandlePresetClick( preset )\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ preset.label }\n\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} ) }\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tclassName=\"dataviews-controls__date-preset\"\n\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\tisPressed={ ! selectedPresetId }\n\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\tdisabled={ !! selectedPresetId || disabled }\n\t\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Custom' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</Stack>\n\n\t\t\t\t\t{ /* Manual date input */ }\n\t\t\t\t\t<InputControl\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tref={ validityTargetRef }\n\t\t\t\t\t\ttype=\"date\"\n\t\t\t\t\t\tlabel={ __( 'Date' ) }\n\t\t\t\t\t\thideLabelFromVision\n\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\tonChange={ handleManualDateChange }\n\t\t\t\t\t\trequired={ !! field.isValid?.required }\n\t\t\t\t\t\tdisabled={ disabled }\n\t\t\t\t\t\tmin={ minConstraint }\n\t\t\t\t\t\tmax={ maxConstraint }\n\t\t\t\t\t/>\n\n\t\t\t\t\t{ /* Calendar widget */ }\n\t\t\t\t\t<DateCalendar\n\t\t\t\t\t\tstyle={ { width: '100%' } }\n\t\t\t\t\t\tselected={\n\t\t\t\t\t\t\tvalue ? parseDate( value ) || undefined : undefined\n\t\t\t\t\t\t}\n\t\t\t\t\t\tonSelect={ onSelectDate }\n\t\t\t\t\t\tmonth={ calendarMonth }\n\t\t\t\t\t\tonMonthChange={ setCalendarMonth }\n\t\t\t\t\t\ttimeZone={ timezoneString || undefined }\n\t\t\t\t\t\tweekStartsOn={ weekStartsOn }\n\t\t\t\t\t\tdisabled={ disabled || disabledMatchers }\n\t\t\t\t\t\tdisableNavigation={ disabled }\n\t\t\t\t\t/>\n\t\t\t\t</Stack>\n\t\t\t</BaseControl>\n\t\t</ValidatedDateControl>\n\t);\n}\n\nfunction CalendarDateRangeControl< Item >( {\n\tdata,\n\tfield,\n\tonChange,\n\thideLabelFromVision,\n\tmarkWhenOptional,\n\tvalidity,\n}: DataFormControlProps< Item > ) {\n\tconst {\n\t\tid,\n\t\tlabel,\n\t\tdescription,\n\t\tgetValue,\n\t\tsetValue,\n\t\tisValid,\n\t\tformat: fieldFormat,\n\t} = field;\n\tconst disabled = field.isDisabled( { item: data, field } );\n\tlet value: DateRange;\n\tconst fieldValue = getValue( { item: data } );\n\tif (\n\t\tArray.isArray( fieldValue ) &&\n\t\tfieldValue.length === 2 &&\n\t\tfieldValue.every( ( date ) => typeof date === 'string' )\n\t) {\n\t\tvalue = fieldValue as DateRange;\n\t}\n\n\tconst weekStartsOn =\n\t\t( fieldFormat as FormatDate ).weekStartsOn ??\n\t\tgetSettings().l10n.startOfWeek;\n\n\tconst { minConstraint, maxConstraint, disabledMatchers } =\n\t\tuseDisabledDateMatchers( isValid, parseDate );\n\n\tconst onChangeCallback = useCallback(\n\t\t( newValue: DateRange ) => {\n\t\t\tonChange(\n\t\t\t\tsetValue( {\n\t\t\t\t\titem: data,\n\t\t\t\t\tvalue: newValue,\n\t\t\t\t} )\n\t\t\t);\n\t\t},\n\t\t[ data, onChange, setValue ]\n\t);\n\n\tconst [ selectedPresetId, setSelectedPresetId ] = useState< string | null >(\n\t\tnull\n\t);\n\n\tconst selectedRange = useMemo( () => {\n\t\tif ( ! value ) {\n\t\t\treturn { from: undefined, to: undefined };\n\t\t}\n\n\t\tconst [ from, to ] = value;\n\t\treturn {\n\t\t\tfrom: parseDate( from ) || undefined,\n\t\t\tto: parseDate( to ) || undefined,\n\t\t};\n\t}, [ value ] );\n\n\tconst [ calendarMonth, setCalendarMonth ] = useState< Date >( () => {\n\t\treturn selectedRange.from || new Date();\n\t} );\n\n\tconst [ isTouched, setIsTouched ] = useState( false );\n\tconst fromInputRef = useRef< HTMLInputElement >( null );\n\tconst toInputRef = useRef< HTMLInputElement >( null );\n\n\tconst updateDateRange = useCallback(\n\t\t( fromDate?: Date | string, toDate?: Date | string ) => {\n\t\t\tif ( fromDate && toDate ) {\n\t\t\t\tonChangeCallback( [\n\t\t\t\t\tformatDate( fromDate ),\n\t\t\t\t\tformatDate( toDate ),\n\t\t\t\t] );\n\t\t\t} else if ( ! fromDate && ! toDate ) {\n\t\t\t\tonChangeCallback( undefined );\n\t\t\t}\n\t\t\t// Do nothing if only one date is set - wait for both\n\t\t},\n\t\t[ onChangeCallback ]\n\t);\n\n\tconst onSelectCalendarRange = useCallback(\n\t\t(\n\t\t\tnewRange:\n\t\t\t\t| { from: Date | undefined; to?: Date | undefined }\n\t\t\t\t| undefined\n\t\t) => {\n\t\t\tupdateDateRange( newRange?.from, newRange?.to );\n\t\t\tsetSelectedPresetId( null );\n\t\t\tsetIsTouched( true );\n\t\t},\n\t\t[ updateDateRange ]\n\t);\n\n\tconst handlePresetClick = useCallback(\n\t\t( preset: ( typeof DATE_RANGE_PRESETS )[ 0 ] ) => {\n\t\t\tconst [ startDate, endDate ] = preset.getValue();\n\t\t\tsetCalendarMonth( startDate );\n\t\t\tupdateDateRange( startDate, endDate );\n\t\t\tsetSelectedPresetId( preset.id );\n\t\t\tsetIsTouched( true );\n\t\t},\n\t\t[ updateDateRange ]\n\t);\n\n\tconst handleManualDateChange = useCallback(\n\t\t( fromOrTo: 'from' | 'to', newValue?: string ) => {\n\t\t\tconst [ currentFrom, currentTo ] = value || [\n\t\t\t\tundefined,\n\t\t\t\tundefined,\n\t\t\t];\n\t\t\tconst updatedFrom = fromOrTo === 'from' ? newValue : currentFrom;\n\t\t\tconst updatedTo = fromOrTo === 'to' ? newValue : currentTo;\n\n\t\t\tupdateDateRange( updatedFrom, updatedTo );\n\n\t\t\tif ( newValue ) {\n\t\t\t\tconst parsedDate = parseDate( newValue );\n\t\t\t\tif ( parsedDate ) {\n\t\t\t\t\tsetCalendarMonth( parsedDate );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tsetSelectedPresetId( null );\n\t\t\tsetIsTouched( true );\n\t\t},\n\t\t[ value, updateDateRange ]\n\t);\n\n\tconst { timezone } = getSettings();\n\n\tlet displayLabel = label;\n\tif ( field.isValid?.required && ! markWhenOptional ) {\n\t\tdisplayLabel = `${ label } (${ __( 'Required' ) })`;\n\t} else if ( ! field.isValid?.required && markWhenOptional ) {\n\t\tdisplayLabel = `${ label } (${ __( 'Optional' ) })`;\n\t}\n\n\treturn (\n\t\t<ValidatedDateControl\n\t\t\tfield={ field }\n\t\t\tvalidity={ validity }\n\t\t\tinputRefs={ [ fromInputRef, toInputRef ] }\n\t\t\tisTouched={ isTouched }\n\t\t\tsetIsTouched={ setIsTouched }\n\t\t>\n\t\t\t<BaseControl\n\t\t\t\tid={ id }\n\t\t\t\tclassName=\"dataviews-controls__date\"\n\t\t\t\tlabel={ displayLabel }\n\t\t\t\thelp={ description }\n\t\t\t\thideLabelFromVision={ hideLabelFromVision }\n\t\t\t>\n\t\t\t\t<Stack direction=\"column\" gap=\"lg\">\n\t\t\t\t\t{ /* Preset buttons */ }\n\t\t\t\t\t<Stack\n\t\t\t\t\t\tdirection=\"row\"\n\t\t\t\t\t\tgap=\"sm\"\n\t\t\t\t\t\twrap=\"wrap\"\n\t\t\t\t\t\tjustify=\"flex-start\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ DATE_RANGE_PRESETS.map( ( preset ) => {\n\t\t\t\t\t\t\tconst isSelected = selectedPresetId === preset.id;\n\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tclassName=\"dataviews-controls__date-preset\"\n\t\t\t\t\t\t\t\t\tkey={ preset.id }\n\t\t\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\t\t\tisPressed={ isSelected }\n\t\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t\t\tdisabled={ disabled }\n\t\t\t\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\t\t\thandlePresetClick( preset )\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ preset.label }\n\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} ) }\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tclassName=\"dataviews-controls__date-preset\"\n\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\tisPressed={ ! selectedPresetId }\n\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t\t\tdisabled={ !! selectedPresetId || disabled }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Custom' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</Stack>\n\n\t\t\t\t\t{ /* Manual date range inputs */ }\n\t\t\t\t\t<Stack\n\t\t\t\t\t\tdirection=\"row\"\n\t\t\t\t\t\tgap=\"sm\"\n\t\t\t\t\t\tjustify=\"space-between\"\n\t\t\t\t\t\tclassName=\"dataviews-controls__date-range-inputs\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<InputControl\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tref={ fromInputRef }\n\t\t\t\t\t\t\ttype=\"date\"\n\t\t\t\t\t\t\tlabel={ __( 'From' ) }\n\t\t\t\t\t\t\thideLabelFromVision\n\t\t\t\t\t\t\tvalue={ value?.[ 0 ] }\n\t\t\t\t\t\t\tonChange={ ( newValue ) =>\n\t\t\t\t\t\t\t\thandleManualDateChange( 'from', newValue )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\trequired={ !! field.isValid?.required }\n\t\t\t\t\t\t\tdisabled={ disabled }\n\t\t\t\t\t\t\tmin={ minConstraint }\n\t\t\t\t\t\t\tmax={ maxConstraint }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<InputControl\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tref={ toInputRef }\n\t\t\t\t\t\t\ttype=\"date\"\n\t\t\t\t\t\t\tlabel={ __( 'To' ) }\n\t\t\t\t\t\t\thideLabelFromVision\n\t\t\t\t\t\t\tvalue={ value?.[ 1 ] }\n\t\t\t\t\t\t\tonChange={ ( newValue ) =>\n\t\t\t\t\t\t\t\thandleManualDateChange( 'to', newValue )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\trequired={ !! field.isValid?.required }\n\t\t\t\t\t\t\tdisabled={ disabled }\n\t\t\t\t\t\t\tmin={ minConstraint }\n\t\t\t\t\t\t\tmax={ maxConstraint }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</Stack>\n\n\t\t\t\t\t<DateRangeCalendar\n\t\t\t\t\t\tstyle={ { width: '100%' } }\n\t\t\t\t\t\tselected={ selectedRange }\n\t\t\t\t\t\tonSelect={ onSelectCalendarRange }\n\t\t\t\t\t\tmonth={ calendarMonth }\n\t\t\t\t\t\tonMonthChange={ setCalendarMonth }\n\t\t\t\t\t\ttimeZone={ timezone.string || undefined }\n\t\t\t\t\t\tweekStartsOn={ weekStartsOn }\n\t\t\t\t\t\tdisabled={ disabled || disabledMatchers }\n\t\t\t\t\t/>\n\t\t\t\t</Stack>\n\t\t\t</BaseControl>\n\t\t</ValidatedDateControl>\n\t);\n}\n\nexport default function DateControl< Item >( {\n\tdata,\n\tfield,\n\tonChange,\n\thideLabelFromVision,\n\tmarkWhenOptional,\n\toperator,\n\tvalidity,\n}: DataFormControlProps< Item > ) {\n\tif ( operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER ) {\n\t\treturn (\n\t\t\t<RelativeDateControl\n\t\t\t\tclassName=\"dataviews-controls__date\"\n\t\t\t\tdata={ data }\n\t\t\t\tfield={ field }\n\t\t\t\tonChange={ onChange }\n\t\t\t\thideLabelFromVision={ hideLabelFromVision }\n\t\t\t\toperator={ operator }\n\t\t\t/>\n\t\t);\n\t}\n\n\tif ( operator === OPERATOR_BETWEEN ) {\n\t\treturn (\n\t\t\t<CalendarDateRangeControl\n\t\t\t\tdata={ data }\n\t\t\t\tfield={ field }\n\t\t\t\tonChange={ onChange }\n\t\t\t\thideLabelFromVision={ hideLabelFromVision }\n\t\t\t\tmarkWhenOptional={ markWhenOptional }\n\t\t\t\tvalidity={ validity }\n\t\t\t/>\n\t\t);\n\t}\n\n\treturn (\n\t\t<CalendarDateControl\n\t\t\tdata={ data }\n\t\t\tfield={ field }\n\t\t\tonChange={ onChange }\n\t\t\thideLabelFromVision={ hideLabelFromVision }\n\t\t\tmarkWhenOptional={ markWhenOptional }\n\t\t\tvalidity={ validity }\n\t\t/>\n\t);\n}\n"],
5
+ "mappings": ";AAGA,OAAO,UAAU;AACjB;AAAA,EACC;AAAA,EACA,WAAW;AAAA,EACX;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAKP;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA,eAAe;AAAA,EACf,8BAA8B;AAAA,OACxB;AACP;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,UAAU;AACnB,SAAS,SAAS,mBAAmB;AACrC,SAAS,SAAS,iBAAiB;AACnC,SAAS,aAAa;AAKtB,OAAO,yBAAyB;AAChC,OAAO,6BAA6B;AACpC;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,cAAc;AAOvB,OAAO,uBAAuB;AAkNzB,SAQC,KARD;AAhNL,IAAM,EAAE,cAAc,kBAAkB,IAAI,OAAQ,qBAAsB;AAI1E,IAAM,eAIA;AAAA,EACL;AAAA,IACC,IAAI;AAAA,IACJ,OAAO,GAAI,OAAQ;AAAA,IACnB,UAAU,MAAM,QAAS,IAAK;AAAA,EAC/B;AAAA,EACA;A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