@wordpress/components 29.13.1-next.719a03cbe.0 → 30.1.1-next.46f643fa0.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 (280) hide show
  1. package/CHANGELOG.md +34 -3
  2. package/build/autocomplete/index.js +4 -0
  3. package/build/autocomplete/index.js.map +1 -1
  4. package/build/calendar/date-calendar/index.js +13 -4
  5. package/build/calendar/date-calendar/index.js.map +1 -1
  6. package/build/calendar/date-range-calendar/index.js +8 -4
  7. package/build/calendar/date-range-calendar/index.js.map +1 -1
  8. package/build/calendar/types.js.map +1 -1
  9. package/build/color-picker/styles.js +7 -7
  10. package/build/color-picker/styles.js.map +1 -1
  11. package/build/icon/index.js +2 -0
  12. package/build/icon/index.js.map +1 -1
  13. package/build/index.js +0 -19
  14. package/build/index.js.map +1 -1
  15. package/build/palette-edit/index.js +1 -1
  16. package/build/palette-edit/index.js.map +1 -1
  17. package/build/private-apis.js +9 -1
  18. package/build/private-apis.js.map +1 -1
  19. package/build/range-control/index.js +1 -1
  20. package/build/range-control/index.js.map +1 -1
  21. package/build/range-control/styles/range-control-styles.js +35 -35
  22. package/build/range-control/styles/range-control-styles.js.map +1 -1
  23. package/build/range-control/tooltip.js +15 -15
  24. package/build/range-control/tooltip.js.map +1 -1
  25. package/build/range-control/types.js.map +1 -1
  26. package/build/select-control/index.js +1 -1
  27. package/build/select-control/index.js.map +1 -1
  28. package/build/textarea-control/index.js +7 -1
  29. package/build/textarea-control/index.js.map +1 -1
  30. package/build/toggle-group-control/toggle-group-control/as-button-group.js.map +1 -1
  31. package/build/utils/hooks/use-controlled-value.js +8 -4
  32. package/build/utils/hooks/use-controlled-value.js.map +1 -1
  33. package/build/validated-form-controls/components/checkbox-control.js +52 -0
  34. package/build/validated-form-controls/components/checkbox-control.js.map +1 -0
  35. package/build/validated-form-controls/components/combobox-control.js +64 -0
  36. package/build/validated-form-controls/components/combobox-control.js.map +1 -0
  37. package/build/validated-form-controls/components/custom-select-control.js +71 -0
  38. package/build/validated-form-controls/components/custom-select-control.js.map +1 -0
  39. package/build/validated-form-controls/components/index.js +138 -0
  40. package/build/validated-form-controls/components/index.js.map +1 -0
  41. package/build/validated-form-controls/components/input-control.js +50 -0
  42. package/build/validated-form-controls/components/input-control.js.map +1 -0
  43. package/build/validated-form-controls/components/number-control.js +53 -0
  44. package/build/validated-form-controls/components/number-control.js.map +1 -0
  45. package/build/validated-form-controls/components/radio-control.js +51 -0
  46. package/build/validated-form-controls/components/radio-control.js.map +1 -0
  47. package/build/validated-form-controls/components/range-control.js +51 -0
  48. package/build/validated-form-controls/components/range-control.js.map +1 -0
  49. package/build/validated-form-controls/components/select-control.js +53 -0
  50. package/build/validated-form-controls/components/select-control.js.map +1 -0
  51. package/build/validated-form-controls/components/text-control.js +51 -0
  52. package/build/validated-form-controls/components/text-control.js.map +1 -0
  53. package/build/validated-form-controls/components/textarea-control.js +50 -0
  54. package/build/validated-form-controls/components/textarea-control.js.map +1 -0
  55. package/build/validated-form-controls/components/toggle-control.js +60 -0
  56. package/build/validated-form-controls/components/toggle-control.js.map +1 -0
  57. package/build/validated-form-controls/components/toggle-group-control.js +69 -0
  58. package/build/validated-form-controls/components/toggle-group-control.js.map +1 -0
  59. package/build/validated-form-controls/components/types.js +6 -0
  60. package/build/validated-form-controls/components/types.js.map +1 -0
  61. package/build/validated-form-controls/control-with-error.js +137 -0
  62. package/build/validated-form-controls/control-with-error.js.map +1 -0
  63. package/build/validated-form-controls/index.js +28 -0
  64. package/build/validated-form-controls/index.js.map +1 -0
  65. package/build-module/autocomplete/index.js +4 -0
  66. package/build-module/autocomplete/index.js.map +1 -1
  67. package/build-module/calendar/date-calendar/index.js +11 -3
  68. package/build-module/calendar/date-calendar/index.js.map +1 -1
  69. package/build-module/calendar/date-range-calendar/index.js +8 -4
  70. package/build-module/calendar/date-range-calendar/index.js.map +1 -1
  71. package/build-module/calendar/types.js.map +1 -1
  72. package/build-module/color-picker/styles.js +7 -7
  73. package/build-module/color-picker/styles.js.map +1 -1
  74. package/build-module/icon/index.js +2 -0
  75. package/build-module/icon/index.js.map +1 -1
  76. package/build-module/index.js +0 -1
  77. package/build-module/index.js.map +1 -1
  78. package/build-module/palette-edit/index.js +2 -2
  79. package/build-module/palette-edit/index.js.map +1 -1
  80. package/build-module/private-apis.js +9 -1
  81. package/build-module/private-apis.js.map +1 -1
  82. package/build-module/range-control/index.js +1 -1
  83. package/build-module/range-control/index.js.map +1 -1
  84. package/build-module/range-control/styles/range-control-styles.js +35 -35
  85. package/build-module/range-control/styles/range-control-styles.js.map +1 -1
  86. package/build-module/range-control/tooltip.js +15 -15
  87. package/build-module/range-control/tooltip.js.map +1 -1
  88. package/build-module/range-control/types.js.map +1 -1
  89. package/build-module/select-control/index.js +1 -1
  90. package/build-module/select-control/index.js.map +1 -1
  91. package/build-module/textarea-control/index.js +7 -1
  92. package/build-module/textarea-control/index.js.map +1 -1
  93. package/build-module/toggle-group-control/toggle-group-control/as-button-group.js.map +1 -1
  94. package/build-module/utils/hooks/use-controlled-value.js +9 -5
  95. package/build-module/utils/hooks/use-controlled-value.js.map +1 -1
  96. package/build-module/validated-form-controls/components/checkbox-control.js +44 -0
  97. package/build-module/validated-form-controls/components/checkbox-control.js.map +1 -0
  98. package/build-module/validated-form-controls/components/combobox-control.js +56 -0
  99. package/build-module/validated-form-controls/components/combobox-control.js.map +1 -0
  100. package/build-module/validated-form-controls/components/custom-select-control.js +63 -0
  101. package/build-module/validated-form-controls/components/custom-select-control.js.map +1 -0
  102. package/build-module/validated-form-controls/components/index.js +13 -0
  103. package/build-module/validated-form-controls/components/index.js.map +1 -0
  104. package/build-module/validated-form-controls/components/input-control.js +42 -0
  105. package/build-module/validated-form-controls/components/input-control.js.map +1 -0
  106. package/build-module/validated-form-controls/components/number-control.js +45 -0
  107. package/build-module/validated-form-controls/components/number-control.js.map +1 -0
  108. package/build-module/validated-form-controls/components/radio-control.js +43 -0
  109. package/build-module/validated-form-controls/components/radio-control.js.map +1 -0
  110. package/build-module/validated-form-controls/components/range-control.js +43 -0
  111. package/build-module/validated-form-controls/components/range-control.js.map +1 -0
  112. package/build-module/validated-form-controls/components/select-control.js +45 -0
  113. package/build-module/validated-form-controls/components/select-control.js.map +1 -0
  114. package/build-module/validated-form-controls/components/text-control.js +43 -0
  115. package/build-module/validated-form-controls/components/text-control.js.map +1 -0
  116. package/build-module/validated-form-controls/components/textarea-control.js +42 -0
  117. package/build-module/validated-form-controls/components/textarea-control.js.map +1 -0
  118. package/build-module/validated-form-controls/components/toggle-control.js +52 -0
  119. package/build-module/validated-form-controls/components/toggle-control.js.map +1 -0
  120. package/build-module/validated-form-controls/components/toggle-group-control.js +62 -0
  121. package/build-module/validated-form-controls/components/toggle-group-control.js.map +1 -0
  122. package/build-module/validated-form-controls/components/types.js +2 -0
  123. package/build-module/validated-form-controls/components/types.js.map +1 -0
  124. package/build-module/validated-form-controls/control-with-error.js +129 -0
  125. package/build-module/validated-form-controls/control-with-error.js.map +1 -0
  126. package/build-module/validated-form-controls/index.js +3 -0
  127. package/build-module/validated-form-controls/index.js.map +1 -0
  128. package/build-style/style-rtl.css +79 -67
  129. package/build-style/style.css +79 -67
  130. package/build-types/autocomplete/index.d.ts.map +1 -1
  131. package/build-types/box-control/utils.d.ts +7 -7
  132. package/build-types/calendar/date-calendar/index.d.ts.map +1 -1
  133. package/build-types/calendar/date-range-calendar/index.d.ts.map +1 -1
  134. package/build-types/calendar/types.d.ts +2 -2
  135. package/build-types/calendar/types.d.ts.map +1 -1
  136. package/build-types/calendar/utils/use-localization-props.d.ts +3 -3
  137. package/build-types/color-picker/styles.d.ts.map +1 -1
  138. package/build-types/custom-gradient-picker/constants.d.ts +2 -2
  139. package/build-types/dimension-control/sizes.d.ts +5 -5
  140. package/build-types/font-size-picker/constants.d.ts +2 -2
  141. package/build-types/font-size-picker/constants.d.ts.map +1 -1
  142. package/build-types/icon/index.d.ts.map +1 -1
  143. package/build-types/index.d.ts +0 -1
  144. package/build-types/index.d.ts.map +1 -1
  145. package/build-types/private-apis.d.ts.map +1 -1
  146. package/build-types/range-control/types.d.ts +2 -2
  147. package/build-types/range-control/types.d.ts.map +1 -1
  148. package/build-types/select-control/stories/index.story.d.ts.map +1 -1
  149. package/build-types/text-control/stories/index.story.d.ts.map +1 -1
  150. package/build-types/textarea-control/index.d.ts.map +1 -1
  151. package/build-types/toggle-group-control/toggle-group-control/as-button-group.d.ts.map +1 -1
  152. package/build-types/utils/hooks/use-controlled-value.d.ts +2 -2
  153. package/build-types/utils/hooks/use-controlled-value.d.ts.map +1 -1
  154. package/build-types/validated-form-controls/components/checkbox-control.d.ts +9 -0
  155. package/build-types/validated-form-controls/components/checkbox-control.d.ts.map +1 -0
  156. package/build-types/validated-form-controls/components/combobox-control.d.ts +21 -0
  157. package/build-types/validated-form-controls/components/combobox-control.d.ts.map +1 -0
  158. package/build-types/validated-form-controls/components/custom-select-control.d.ts +4 -0
  159. package/build-types/validated-form-controls/components/custom-select-control.d.ts.map +1 -0
  160. package/build-types/validated-form-controls/components/index.d.ts +13 -0
  161. package/build-types/validated-form-controls/components/index.d.ts.map +1 -0
  162. package/build-types/validated-form-controls/components/input-control.d.ts +4 -0
  163. package/build-types/validated-form-controls/components/input-control.d.ts.map +1 -0
  164. package/build-types/validated-form-controls/components/number-control.d.ts +17 -0
  165. package/build-types/validated-form-controls/components/number-control.d.ts.map +1 -0
  166. package/build-types/validated-form-controls/components/radio-control.d.ts +11 -0
  167. package/build-types/validated-form-controls/components/radio-control.d.ts.map +1 -0
  168. package/build-types/validated-form-controls/components/range-control.d.ts +36 -0
  169. package/build-types/validated-form-controls/components/range-control.d.ts.map +1 -0
  170. package/build-types/validated-form-controls/components/select-control.d.ts +9 -0
  171. package/build-types/validated-form-controls/components/select-control.d.ts.map +1 -0
  172. package/build-types/validated-form-controls/components/stories/checkbox-control.story.d.ts +12 -0
  173. package/build-types/validated-form-controls/components/stories/checkbox-control.story.d.ts.map +1 -0
  174. package/build-types/validated-form-controls/components/stories/combobox-control.story.d.ts +12 -0
  175. package/build-types/validated-form-controls/components/stories/combobox-control.story.d.ts.map +1 -0
  176. package/build-types/validated-form-controls/components/stories/custom-select-control.story.d.ts +12 -0
  177. package/build-types/validated-form-controls/components/stories/custom-select-control.story.d.ts.map +1 -0
  178. package/build-types/validated-form-controls/components/stories/input-control.story.d.ts +18 -0
  179. package/build-types/validated-form-controls/components/stories/input-control.story.d.ts.map +1 -0
  180. package/build-types/validated-form-controls/components/stories/number-control.story.d.ts +12 -0
  181. package/build-types/validated-form-controls/components/stories/number-control.story.d.ts.map +1 -0
  182. package/build-types/validated-form-controls/components/stories/overview.story.d.ts +19 -0
  183. package/build-types/validated-form-controls/components/stories/overview.story.d.ts.map +1 -0
  184. package/build-types/validated-form-controls/components/stories/radio-control.story.d.ts +12 -0
  185. package/build-types/validated-form-controls/components/stories/radio-control.story.d.ts.map +1 -0
  186. package/build-types/validated-form-controls/components/stories/range-control.story.d.ts +9 -0
  187. package/build-types/validated-form-controls/components/stories/range-control.story.d.ts.map +1 -0
  188. package/build-types/validated-form-controls/components/stories/select-control.story.d.ts +12 -0
  189. package/build-types/validated-form-controls/components/stories/select-control.story.d.ts.map +1 -0
  190. package/build-types/validated-form-controls/components/stories/story-utils.d.ts +9 -0
  191. package/build-types/validated-form-controls/components/stories/story-utils.d.ts.map +1 -0
  192. package/build-types/validated-form-controls/components/stories/text-control.story.d.ts +9 -0
  193. package/build-types/validated-form-controls/components/stories/text-control.story.d.ts.map +1 -0
  194. package/build-types/validated-form-controls/components/stories/textarea-control.story.d.ts +9 -0
  195. package/build-types/validated-form-controls/components/stories/textarea-control.story.d.ts.map +1 -0
  196. package/build-types/validated-form-controls/components/stories/toggle-control.story.d.ts +9 -0
  197. package/build-types/validated-form-controls/components/stories/toggle-control.story.d.ts.map +1 -0
  198. package/build-types/validated-form-controls/components/stories/toggle-group-control.story.d.ts +9 -0
  199. package/build-types/validated-form-controls/components/stories/toggle-group-control.story.d.ts.map +1 -0
  200. package/build-types/validated-form-controls/components/text-control.d.ts +8 -0
  201. package/build-types/validated-form-controls/components/text-control.d.ts.map +1 -0
  202. package/build-types/validated-form-controls/components/textarea-control.d.ts +7 -0
  203. package/build-types/validated-form-controls/components/textarea-control.d.ts.map +1 -0
  204. package/build-types/validated-form-controls/components/toggle-control.d.ts +7 -0
  205. package/build-types/validated-form-controls/components/toggle-control.d.ts.map +1 -0
  206. package/build-types/validated-form-controls/components/toggle-group-control.d.ts +15 -0
  207. package/build-types/validated-form-controls/components/toggle-group-control.d.ts.map +1 -0
  208. package/build-types/validated-form-controls/components/types.d.ts +27 -0
  209. package/build-types/validated-form-controls/components/types.d.ts.map +1 -0
  210. package/build-types/validated-form-controls/control-with-error.d.ts +36 -0
  211. package/build-types/validated-form-controls/control-with-error.d.ts.map +1 -0
  212. package/build-types/validated-form-controls/index.d.ts +3 -0
  213. package/build-types/validated-form-controls/index.d.ts.map +1 -0
  214. package/package.json +19 -19
  215. package/src/autocomplete/index.tsx +4 -0
  216. package/src/calendar/date-calendar/README.md +57 -46
  217. package/src/calendar/date-calendar/index.tsx +22 -8
  218. package/src/calendar/date-range-calendar/README.md +63 -52
  219. package/src/calendar/date-range-calendar/index.tsx +23 -11
  220. package/src/calendar/types.ts +2 -2
  221. package/src/color-picker/styles.ts +10 -0
  222. package/src/dimension-control/test/__snapshots__/index.test.js.snap +8 -8
  223. package/src/icon/index.tsx +2 -0
  224. package/src/index.ts +0 -1
  225. package/src/modal/style.scss +2 -2
  226. package/src/palette-edit/index.tsx +3 -3
  227. package/src/private-apis.ts +13 -0
  228. package/src/range-control/index.tsx +1 -1
  229. package/src/range-control/styles/range-control-styles.ts +3 -3
  230. package/src/range-control/tooltip.tsx +13 -13
  231. package/src/range-control/types.ts +2 -2
  232. package/src/select-control/index.tsx +1 -1
  233. package/src/style.scss +2 -2
  234. package/src/text-control/stories/index.story.tsx +1 -0
  235. package/src/text-control/style.scss +6 -1
  236. package/src/textarea-control/index.tsx +8 -1
  237. package/src/toggle-group-control/toggle-group-control/as-button-group.tsx +3 -1
  238. package/src/utils/hooks/use-controlled-value.ts +16 -8
  239. package/src/utils/theme-variables.scss +3 -0
  240. package/src/validated-form-controls/components/checkbox-control.tsx +64 -0
  241. package/src/validated-form-controls/components/combobox-control.tsx +77 -0
  242. package/src/validated-form-controls/components/custom-select-control.tsx +86 -0
  243. package/src/validated-form-controls/components/index.ts +12 -0
  244. package/src/validated-form-controls/components/input-control.tsx +59 -0
  245. package/src/validated-form-controls/components/number-control.tsx +61 -0
  246. package/src/validated-form-controls/components/radio-control.tsx +60 -0
  247. package/src/validated-form-controls/components/range-control.tsx +60 -0
  248. package/src/validated-form-controls/components/select-control.tsx +75 -0
  249. package/src/validated-form-controls/components/stories/checkbox-control.story.tsx +57 -0
  250. package/src/validated-form-controls/components/stories/combobox-control.story.tsx +64 -0
  251. package/src/validated-form-controls/components/stories/custom-select-control.story.tsx +64 -0
  252. package/src/validated-form-controls/components/stories/input-control.story.tsx +132 -0
  253. package/src/validated-form-controls/components/stories/number-control.story.tsx +62 -0
  254. package/src/validated-form-controls/components/stories/overview.mdx +52 -0
  255. package/src/validated-form-controls/components/stories/overview.story.tsx +100 -0
  256. package/src/validated-form-controls/components/stories/radio-control.story.tsx +64 -0
  257. package/src/validated-form-controls/components/stories/range-control.story.tsx +60 -0
  258. package/src/validated-form-controls/components/stories/select-control.story.tsx +60 -0
  259. package/src/validated-form-controls/components/stories/story-utils.tsx +46 -0
  260. package/src/validated-form-controls/components/stories/text-control.story.tsx +55 -0
  261. package/src/validated-form-controls/components/stories/textarea-control.story.tsx +52 -0
  262. package/src/validated-form-controls/components/stories/toggle-control.story.tsx +55 -0
  263. package/src/validated-form-controls/components/stories/toggle-group-control.story.tsx +66 -0
  264. package/src/validated-form-controls/components/text-control.tsx +60 -0
  265. package/src/validated-form-controls/components/textarea-control.tsx +59 -0
  266. package/src/validated-form-controls/components/toggle-control.tsx +69 -0
  267. package/src/validated-form-controls/components/toggle-group-control.tsx +82 -0
  268. package/src/validated-form-controls/components/types.ts +28 -0
  269. package/src/validated-form-controls/control-with-error.tsx +198 -0
  270. package/src/validated-form-controls/index.ts +2 -0
  271. package/src/validated-form-controls/style.scss +75 -0
  272. package/tsconfig.tsbuildinfo +1 -1
  273. package/build/calendar/utils/use-controlled-value.js +0 -58
  274. package/build/calendar/utils/use-controlled-value.js.map +0 -1
  275. package/build-module/calendar/utils/use-controlled-value.js +0 -51
  276. package/build-module/calendar/utils/use-controlled-value.js.map +0 -1
  277. package/build-types/calendar/utils/use-controlled-value.d.ts +0 -27
  278. package/build-types/calendar/utils/use-controlled-value.d.ts.map +0 -1
  279. package/src/calendar/utils/use-controlled-value.ts +0 -61
  280. package/src/dimension-control/style.scss +0 -22
@@ -0,0 +1 @@
1
+ {"version":3,"file":"story-utils.d.ts","sourceRoot":"","sources":["../../../../src/validated-form-controls/components/stories/story-utils.tsx"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAO7C,eAAO,MAAM,aAAa,EAAE,IAAI,CAAE,YAAY,CA+B7C,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import type { StoryObj, Meta } from '@storybook/react';
5
+ import { ValidatedTextControl } from '../text-control';
6
+ declare const meta: Meta<typeof ValidatedTextControl>;
7
+ export default meta;
8
+ export declare const Default: StoryObj<typeof ValidatedTextControl>;
9
+ //# sourceMappingURL=text-control.story.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text-control.story.d.ts","sourceRoot":"","sources":["../../../../src/validated-form-controls/components/stories/text-control.story.tsx"],"names":[],"mappings":"AAKA;;GAEG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAMvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAEvD,QAAA,MAAM,IAAI,EAAE,IAAI,CAAE,OAAO,oBAAoB,CAS5C,CAAC;AACF,eAAe,IAAI,CAAC;AAEpB,eAAO,MAAM,OAAO,EAAE,QAAQ,CAAE,OAAO,oBAAoB,CAe1D,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import type { StoryObj, Meta } from '@storybook/react';
5
+ import { ValidatedTextareaControl } from '../textarea-control';
6
+ declare const meta: Meta<typeof ValidatedTextareaControl>;
7
+ export default meta;
8
+ export declare const Default: StoryObj<typeof ValidatedTextareaControl>;
9
+ //# sourceMappingURL=textarea-control.story.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"textarea-control.story.d.ts","sourceRoot":"","sources":["../../../../src/validated-form-controls/components/stories/textarea-control.story.tsx"],"names":[],"mappings":"AAKA;;GAEG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAKvD,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAE/D,QAAA,MAAM,IAAI,EAAE,IAAI,CAAE,OAAO,wBAAwB,CAOhD,CAAC;AACF,eAAe,IAAI,CAAC;AAEpB,eAAO,MAAM,OAAO,EAAE,QAAQ,CAAE,OAAO,wBAAwB,CAe9D,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import type { StoryObj, Meta } from '@storybook/react';
5
+ import { ValidatedToggleControl } from '../toggle-control';
6
+ declare const meta: Meta<typeof ValidatedToggleControl>;
7
+ export default meta;
8
+ export declare const Default: StoryObj<typeof ValidatedToggleControl>;
9
+ //# sourceMappingURL=toggle-control.story.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toggle-control.story.d.ts","sourceRoot":"","sources":["../../../../src/validated-form-controls/components/stories/toggle-control.story.tsx"],"names":[],"mappings":"AAKA;;GAEG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAMvD,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAE3D,QAAA,MAAM,IAAI,EAAE,IAAI,CAAE,OAAO,sBAAsB,CAS9C,CAAC;AACF,eAAe,IAAI,CAAC;AAEpB,eAAO,MAAM,OAAO,EAAE,QAAQ,CAAE,OAAO,sBAAsB,CAe5D,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import type { StoryObj, Meta } from '@storybook/react';
5
+ import { ValidatedToggleGroupControl } from '../toggle-group-control';
6
+ declare const meta: Meta<typeof ValidatedToggleGroupControl>;
7
+ export default meta;
8
+ export declare const Default: StoryObj<typeof ValidatedToggleGroupControl>;
9
+ //# sourceMappingURL=toggle-group-control.story.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toggle-group-control.story.d.ts","sourceRoot":"","sources":["../../../../src/validated-form-controls/components/stories/toggle-group-control.story.tsx"],"names":[],"mappings":"AAKA;;GAEG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAMvD,OAAO,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAC;AAGtE,QAAA,MAAM,IAAI,EAAE,IAAI,CAAE,OAAO,2BAA2B,CASnD,CAAC;AACF,eAAe,IAAI,CAAC;AAEpB,eAAO,MAAM,OAAO,EAAE,QAAQ,CAAE,OAAO,2BAA2B,CAoBjE,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { ValidatedControlProps } from './types';
2
+ export declare const ValidatedTextControl: import("react").ForwardRefExoticComponent<Omit<Omit<Pick<import("../../base-control/types").BaseControlProps, "help" | "label" | "className" | "hideLabelFromVision" | "__nextHasNoMarginBottom"> & {
3
+ onChange: (value: string) => void;
4
+ value: string | number;
5
+ type?: "date" | "datetime-local" | "email" | "number" | "password" | "tel" | "text" | "time" | "search" | "url";
6
+ __next40pxDefaultSize?: boolean;
7
+ } & Omit<Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "ref">, "help" | "label" | "className" | "type" | "children" | "onChange" | "value" | "as" | "__next40pxDefaultSize" | "hideLabelFromVision" | "__nextHasNoMarginBottom"> & import("react").RefAttributes<HTMLInputElement>, "__next40pxDefaultSize" | "__nextHasNoMarginBottom"> & ValidatedControlProps<string | number>, "ref"> & import("react").RefAttributes<HTMLInputElement>>;
8
+ //# sourceMappingURL=text-control.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text-control.d.ts","sourceRoot":"","sources":["../../../src/validated-form-controls/components/text-control.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AA+CrD,eAAO,MAAM,oBAAoB;;;;;+eAEhC,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { ValidatedControlProps } from './types';
2
+ export declare const ValidatedTextareaControl: import("react").ForwardRefExoticComponent<Omit<Omit<Pick<import("../../base-control/types").BaseControlProps, "help" | "label" | "hideLabelFromVision" | "__nextHasNoMarginBottom"> & {
3
+ onChange: (value: string) => void;
4
+ value: string;
5
+ rows?: import("react").TextareaHTMLAttributes<HTMLTextAreaElement>["rows"];
6
+ } & Omit<Omit<import("react").DetailedHTMLProps<import("react").TextareaHTMLAttributes<HTMLTextAreaElement>, HTMLTextAreaElement>, "ref">, "help" | "label" | "children" | "onChange" | "value" | "rows" | "as" | "hideLabelFromVision" | "__nextHasNoMarginBottom"> & import("react").RefAttributes<HTMLTextAreaElement>, "__nextHasNoMarginBottom"> & ValidatedControlProps<string>, "ref"> & import("react").RefAttributes<HTMLTextAreaElement>>;
7
+ //# sourceMappingURL=textarea-control.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"textarea-control.d.ts","sourceRoot":"","sources":["../../../src/validated-form-controls/components/textarea-control.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AA8CrD,eAAO,MAAM,wBAAwB;;;;mbAEpC,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { ValidatedControlProps } from './types';
2
+ export declare const ValidatedToggleControl: import("react").ForwardRefExoticComponent<Omit<Omit<Pick<import("../../form-toggle/types").FormToggleProps, "disabled" | "checked"> & Pick<import("../../base-control/types").BaseControlProps, "className" | "__nextHasNoMarginBottom"> & {
3
+ help?: import("react").ReactNode | ((checked: boolean) => import("react").ReactNode);
4
+ label: import("react").ReactNode;
5
+ onChange: (value: boolean) => void;
6
+ } & Omit<Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "ref">, "help" | "disabled" | "label" | "className" | "children" | "onChange" | "checked" | "as" | "__nextHasNoMarginBottom"> & import("react").RefAttributes<HTMLInputElement>, "__nextHasNoMarginBottom"> & ValidatedControlProps<boolean | undefined>, "ref"> & import("react").RefAttributes<HTMLInputElement>>;
7
+ //# sourceMappingURL=toggle-control.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toggle-control.d.ts","sourceRoot":"","sources":["../../../src/validated-form-controls/components/toggle-control.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAwDrD,eAAO,MAAM,sBAAsB;;;;6aAElC,CAAC"}
@@ -0,0 +1,15 @@
1
+ import type { ValidatedControlProps } from './types';
2
+ export declare const ValidatedToggleGroupControl: import("react").ForwardRefExoticComponent<Omit<Omit<Pick<import("../../base-control/types").BaseControlProps, "help" | "__nextHasNoMarginBottom"> & {
3
+ label: string;
4
+ hideLabelFromVision?: boolean;
5
+ isAdaptiveWidth?: boolean;
6
+ isBlock?: boolean;
7
+ isDeselectable?: boolean;
8
+ onChange?: (value: string | number | undefined) => void;
9
+ value?: string | number;
10
+ children: import("react").ReactNode;
11
+ size?: "default" | "__unstable-large";
12
+ __next40pxDefaultSize?: boolean;
13
+ __shouldNotWarnDeprecated36pxSize?: boolean;
14
+ } & import("react").RefAttributes<any> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "size" | "help" | "label" | "children" | "onChange" | "value" | "as" | keyof import("react").RefAttributes<any> | "isBlock" | "__next40pxDefaultSize" | "__shouldNotWarnDeprecated36pxSize" | "hideLabelFromVision" | "__nextHasNoMarginBottom" | "isAdaptiveWidth" | "isDeselectable">, "__next40pxDefaultSize" | "__nextHasNoMarginBottom"> & ValidatedControlProps<string | number | undefined>, "ref"> & import("react").RefAttributes<HTMLInputElement>>;
15
+ //# sourceMappingURL=toggle-group-control.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toggle-group-control.d.ts","sourceRoot":"","sources":["../../../src/validated-form-controls/components/toggle-group-control.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAsErD,eAAO,MAAM,2BAA2B;;;;;;;;;;;;2lBAEvC,CAAC"}
@@ -0,0 +1,27 @@
1
+ export type ValidatedControlProps<V> = {
2
+ /**
3
+ * Whether the control is required.
4
+ * @default false
5
+ */
6
+ required?: boolean;
7
+ /**
8
+ * Label the control as "optional" when _not_ `required`, instead of the inverse.
9
+ * @default false
10
+ */
11
+ markWhenOptional?: boolean;
12
+ /**
13
+ * A function that returns a custom validity message when applicable. This error message will be applied to the
14
+ * underlying element using the native [`setCustomValidity()` method](https://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement/setCustomValidity).
15
+ * This means the custom validator will be run _in addition_ to any other HTML attribute-based validation, and
16
+ * will be prioritized over any existing validity messages dictated by the HTML attributes.
17
+ * An empty string or `undefined` return value will clear any existing custom validity message.
18
+ *
19
+ * Make sure you don't programatically pass a value (such as an initial value) to the control component
20
+ * that fails this validator, because the validator will only run for user-initiated changes.
21
+ *
22
+ * Always prefer using standard HTML attributes like `required` and `min`/`max` over custom validators
23
+ * when possible, as they are simpler and have localized error messages built in.
24
+ */
25
+ customValidator?: (currentValue: V) => string | void;
26
+ };
27
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/validated-form-controls/components/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,qBAAqB,CAAE,CAAC,IAAK;IACxC;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;;;;;;;;;;;OAYG;IAGH,eAAe,CAAC,EAAE,CAAE,YAAY,EAAE,CAAC,KAAM,MAAM,GAAG,IAAI,CAAC;CACvD,CAAC"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * HTML elements that support the Constraint Validation API.
3
+ *
4
+ * Here, we exclude HTMLButtonElement because although it does technically support the API,
5
+ * normal buttons are actually exempted from any validation.
6
+ * @see https://developer.mozilla.org/en-US/docs/Learn_web_development/Extensions/Forms/Form_validation
7
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLButtonElement/willValidate
8
+ */
9
+ type ValidityTarget = HTMLFieldSetElement | HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement;
10
+ export declare const ControlWithError: import("react").ForwardRefExoticComponent<{
11
+ /**
12
+ * Whether the control is required.
13
+ */
14
+ required?: boolean;
15
+ /**
16
+ * Label the control as "optional" when _not_ `required`, instead of the inverse.
17
+ */
18
+ markWhenOptional?: boolean;
19
+ /**
20
+ * A function that returns a custom validity message when applicable.
21
+ *
22
+ * This message will be applied to the element returned by `getValidityTarget`.
23
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement/setCustomValidity
24
+ */
25
+ customValidator?: () => string | void;
26
+ /**
27
+ * A function that returns the actual element on which the validity data should be applied.
28
+ */
29
+ getValidityTarget: () => ValidityTarget | null | undefined;
30
+ /**
31
+ * The control component to apply validation to.
32
+ */
33
+ children: import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
34
+ } & import("react").RefAttributes<HTMLDivElement>>;
35
+ export {};
36
+ //# sourceMappingURL=control-with-error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"control-with-error.d.ts","sourceRoot":"","sources":["../../src/validated-form-controls/control-with-error.tsx"],"names":[],"mappings":"AA6CA;;;;;;;GAOG;AACH,KAAK,cAAc,GAChB,mBAAmB,GACnB,gBAAgB,GAChB,iBAAiB,GACjB,mBAAmB,CAAC;AA4IvB,eAAO,MAAM,gBAAgB;IAlI3B;;OAEG;eACQ,OAAO;IAClB;;OAEG;uBACgB,OAAO;IAC1B;;;;;OAKG;sBACe,MAAM,MAAM,GAAG,IAAI;IACrC;;OAEG;uBACgB,MAAM,cAAc,GAAG,IAAI,GAAG,SAAS;IAC1D;;OAEG;;kDA6GoE,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from './components';
2
+ export * from './control-with-error';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/validated-form-controls/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/components",
3
- "version": "29.13.1-next.719a03cbe.0",
3
+ "version": "30.1.1-next.46f643fa0.0",
4
4
  "description": "UI components for WordPress.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -44,23 +44,23 @@
44
44
  "@types/gradient-parser": "0.1.3",
45
45
  "@types/highlight-words-core": "1.2.1",
46
46
  "@use-gesture/react": "^10.3.1",
47
- "@wordpress/a11y": "^4.26.1-next.719a03cbe.0",
48
- "@wordpress/compose": "^7.26.1-next.719a03cbe.0",
49
- "@wordpress/date": "^5.26.1-next.719a03cbe.0",
50
- "@wordpress/deprecated": "^4.26.1-next.719a03cbe.0",
51
- "@wordpress/dom": "^4.26.1-next.719a03cbe.0",
52
- "@wordpress/element": "^6.26.1-next.719a03cbe.0",
53
- "@wordpress/escape-html": "^3.26.1-next.719a03cbe.0",
54
- "@wordpress/hooks": "^4.26.1-next.719a03cbe.0",
55
- "@wordpress/html-entities": "^4.26.1-next.719a03cbe.0",
56
- "@wordpress/i18n": "^6.0.1-next.719a03cbe.0",
57
- "@wordpress/icons": "^10.26.2-next.719a03cbe.0",
58
- "@wordpress/is-shallow-equal": "^5.26.1-next.719a03cbe.0",
59
- "@wordpress/keycodes": "^4.26.1-next.719a03cbe.0",
60
- "@wordpress/primitives": "^4.26.1-next.719a03cbe.0",
61
- "@wordpress/private-apis": "^1.26.1-next.719a03cbe.0",
62
- "@wordpress/rich-text": "^7.26.1-next.719a03cbe.0",
63
- "@wordpress/warning": "^3.26.1-next.719a03cbe.0",
47
+ "@wordpress/a11y": "^4.27.1-next.46f643fa0.0",
48
+ "@wordpress/compose": "^7.27.1-next.46f643fa0.0",
49
+ "@wordpress/date": "^5.27.1-next.46f643fa0.0",
50
+ "@wordpress/deprecated": "^4.27.1-next.46f643fa0.0",
51
+ "@wordpress/dom": "^4.27.1-next.46f643fa0.0",
52
+ "@wordpress/element": "^6.27.1-next.46f643fa0.0",
53
+ "@wordpress/escape-html": "^3.27.1-next.46f643fa0.0",
54
+ "@wordpress/hooks": "^4.27.1-next.46f643fa0.0",
55
+ "@wordpress/html-entities": "^4.27.1-next.46f643fa0.0",
56
+ "@wordpress/i18n": "^6.0.1-next.46f643fa0.0",
57
+ "@wordpress/icons": "^10.27.2-next.46f643fa0.0",
58
+ "@wordpress/is-shallow-equal": "^5.27.1-next.46f643fa0.0",
59
+ "@wordpress/keycodes": "^4.27.1-next.46f643fa0.0",
60
+ "@wordpress/primitives": "^4.27.1-next.46f643fa0.0",
61
+ "@wordpress/private-apis": "^1.27.1-next.46f643fa0.0",
62
+ "@wordpress/rich-text": "^7.27.1-next.46f643fa0.0",
63
+ "@wordpress/warning": "^3.27.1-next.46f643fa0.0",
64
64
  "change-case": "^4.1.2",
65
65
  "clsx": "^2.1.1",
66
66
  "colord": "^2.7.0",
@@ -86,5 +86,5 @@
86
86
  "publishConfig": {
87
87
  "access": "public"
88
88
  },
89
- "gitHead": "5e146e949c2765411a8310bcc2641a88d036a6d9"
89
+ "gitHead": "17e600e091675c5e3d809adfea23ac456bbeae19"
90
90
  }
@@ -126,6 +126,10 @@ export function useAutocomplete( {
126
126
  // Reset autocomplete state after insertion rather than before
127
127
  // so insertion events don't cause the completion menu to redisplay.
128
128
  reset();
129
+
130
+ // Make sure that the content remains focused after making a selection
131
+ // and that the text cursor position is not lost.
132
+ contentRef.current?.focus();
129
133
  }
130
134
 
131
135
  function reset() {
@@ -1,5 +1,7 @@
1
1
  # `DateCalendar`
2
2
 
3
+ 🔒 This component is locked as a [private API](https://developer.wordpress.org/block-editor/reference-guides/packages/packages-private-apis/). We do not yet recommend using this outside of the Gutenberg project.
4
+
3
5
  `DateCalendar` is a React component that provides a customizable calendar interface for **single date** selection.
4
6
 
5
7
  The component is built with accessibility in mind and follows ARIA best practices for calendar widgets. It provides keyboard navigation, screen reader support, and customizable labels for internationalization.
@@ -7,7 +9,7 @@ The component is built with accessibility in mind and follows ARIA best practice
7
9
  ## Usage example
8
10
 
9
11
  ```tsx
10
- import { DateCalendar } from '@automattic/components';
12
+ import { DateCalendar } from '@wordpress/components';
11
13
 
12
14
  function MyComponent() {
13
15
  const [ selected, setSelected ] = useState< Date >( new Date() );
@@ -22,95 +24,95 @@ These props are shared between both single date and date range calendar modes.
22
24
 
23
25
  ### `required`
24
26
 
25
- - Type: `boolean`
26
- - Required: No
27
- - Default: `false`
27
+ - Type: `boolean`
28
+ - Required: No
29
+ - Default: `false`
28
30
 
29
31
  Whether the selection is required. When `true`, there always needs to be a date selected.
30
32
 
31
33
  ### `selected`
32
34
 
33
- - Type: `Date | undefined | null`
34
- - Required: No
35
+ - Type: `Date | undefined | null`
36
+ - Required: No
35
37
 
36
38
  The selected date.
37
39
 
38
40
  ### `onSelect`
39
41
 
40
- - Type: `(selected: Date | undefined, triggerDate: Date, modifiers: Modifiers, e: React.MouseEvent | React.KeyboardEvent) => void`
41
- - Required: No
42
+ - Type: `(selected: Date | undefined, triggerDate: Date, modifiers: Modifiers, e: React.MouseEvent | React.KeyboardEvent) => void`
43
+ - Required: No
42
44
 
43
45
  Event handler when a day is selected.
44
46
 
45
47
  ### `defaultSelected`
46
48
 
47
- - Type: `Date`
48
- - Required: No
49
+ - Type: `Date`
50
+ - Required: No
49
51
 
50
52
  The default selected date (for uncontrolled usage).
51
53
 
52
54
  ### `defaultMonth`
53
55
 
54
- - Type: `Date`
55
- - Required: No
56
- - Default: Current month
56
+ - Type: `Date`
57
+ - Required: No
58
+ - Default: Current month
57
59
 
58
60
  The initial month to show in the calendar view (uncontrolled).
59
61
 
60
62
  ### `month`
61
63
 
62
- - Type: `Date`
63
- - Required: No
64
+ - Type: `Date`
65
+ - Required: No
64
66
 
65
67
  The month displayed in the calendar view (controlled). Use together with `onMonthChange` to change the month programmatically.
66
68
 
67
69
  ### `numberOfMonths`
68
70
 
69
- - Type: `number`
70
- - Required: No
71
- - Default: `1`
71
+ - Type: `number`
72
+ - Required: No
73
+ - Default: `1`
72
74
 
73
75
  The number of months displayed at once.
74
76
 
75
77
  ### `startMonth`
76
78
 
77
- - Type: `Date`
78
- - Required: No
79
+ - Type: `Date`
80
+ - Required: No
79
81
 
80
82
  The earliest month to start the month navigation.
81
83
 
82
84
  ### `endMonth`
83
85
 
84
- - Type: `Date`
85
- - Required: No
86
+ - Type: `Date`
87
+ - Required: No
86
88
 
87
89
  The latest month to end the month navigation.
88
90
 
89
91
  ### `autoFocus`
90
92
 
91
- - Type: `boolean`
92
- - Required: No
93
+ - Type: `boolean`
94
+ - Required: No
93
95
 
94
96
  Focus the first selected day (if set) or today's date (if not disabled). Use this prop when you need to focus the calendar after a user action (e.g. opening the dialog with the calendar).
95
97
 
96
98
  ### `disabled`
97
99
 
98
- - Type: `Matcher | Matcher[] | undefined`
99
- - Required: No
100
+ - Type: `Matcher | Matcher[] | undefined`
101
+ - Required: No
100
102
 
101
103
  Specify which days are disabled. Using `true` will disable all dates. See the [Matcher Types](#matcher-types) section for more details.
102
104
 
103
105
  ### `disableNavigation`
104
106
 
105
- - Type: `boolean`
106
- - Required: No
107
+ - Type: `boolean`
108
+ - Required: No
107
109
 
108
110
  Disable the navigation buttons.
109
111
 
110
112
  ### `labels`
111
113
 
112
- - Type: `object`
113
- - Required: No
114
+ - Type: `object`
115
+ - Required: No
114
116
 
115
117
  Use custom labels for internationalization. All labels are optional and have sensible defaults:
116
118
 
@@ -130,9 +132,9 @@ Use custom labels for internationalization. All labels are optional and have sen
130
132
 
131
133
  ### `locale`
132
134
 
133
- - Type: `Locale`
134
- - Required: No
135
- - Default: `enUS` from `@date-fns/locale`
135
+ - Type: `Locale`
136
+ - Required: No
137
+ - Default: `enUS` from `@date-fns/locale`
136
138
 
137
139
  The locale object used to localize dates. Pass a locale from `@date-fns/locale` to localize the calendar.
138
140
 
@@ -140,45 +142,51 @@ The locale object used to localize dates. Pass a locale from `@date-fns/locale`
140
142
 
141
143
  ### `weekStartsOn`
142
144
 
143
- - Type: `0 | 1 | 2 | 3 | 4 | 5 | 6 | undefined`
144
- - Required: No
145
- - Default: Based on the `locale` prop
145
+ - Type: `0 | 1 | 2 | 3 | 4 | 5 | 6 | undefined`
146
+ - Required: No
147
+ - Default: Based on the `locale` prop
146
148
 
147
149
  The index of the first day of the week (0 - Sunday). Overrides the locale's setting.
148
150
 
149
151
  ### `onMonthChange`
150
152
 
151
- - Type: `(month: Date) => void`
152
- - Required: No
153
+ - Type: `(month: Date) => void`
154
+ - Required: No
153
155
 
154
156
  Event fired when the user navigates between months.
155
157
 
156
158
  ### `timeZone`
157
159
 
158
- - Type: `string`
159
- - Required: No
160
+ - Type: `string`
161
+ - Required: No
160
162
 
161
163
  The time zone (IANA or UTC offset) to use in the calendar. See [Wikipedia](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) for possible values.
162
164
 
163
165
  When working with time zones, use the `TZDate` object exported by this package instead of the native `Date` object.
164
166
 
165
167
  ```tsx
166
- import { DateCalendar, TZDate } from '@automattic/components';
168
+ import { DateCalendar, TZDate } from '@wordpress/components';
167
169
 
168
170
  export function WithTimeZone() {
169
171
  const timeZone = 'America/New_York';
170
172
  const [ selected, setSelected ] = useState< Date | undefined >(
171
173
  new TZDate( 2024, 12, 10, timeZone ) // Use `TZDate` instead of `Date`
172
174
  );
173
- return <DateCalendar timeZone={ timeZone } selected={ selected } onSelect={ setSelected } />;
175
+ return (
176
+ <DateCalendar
177
+ timeZone={ timeZone }
178
+ selected={ selected }
179
+ onSelect={ setSelected }
180
+ />
181
+ );
174
182
  }
175
183
  ```
176
184
 
177
185
  ### `role`
178
186
 
179
- - Type: `'application' | 'dialog' | undefined`
180
- - Required: No
181
- - Default: `'application'`
187
+ - Type: `'application' | 'dialog' | undefined`
188
+ - Required: No
189
+ - Default: `'application'`
182
190
 
183
191
  The role attribute to add to the container element.
184
192
 
@@ -201,7 +209,10 @@ const dateMatcher: Matcher = new Date(); // Will match today's date
201
209
  ### Array Matcher
202
210
 
203
211
  ```typescript
204
- const arrayMatcher: Matcher = [ new Date( 2019, 1, 2 ), new Date( 2019, 1, 4 ) ]; // Will match the days in the array
212
+ const arrayMatcher: Matcher = [
213
+ new Date( 2019, 1, 2 ),
214
+ new Date( 2019, 1, 4 ),
215
+ ]; // Will match the days in the array
205
216
  ```
206
217
 
207
218
  ### Date After Matcher
@@ -3,14 +3,18 @@
3
3
  */
4
4
  import { DayPicker } from 'react-day-picker';
5
5
  import { enUS } from 'react-day-picker/locale';
6
+ /**
7
+ * WordPress dependencies
8
+ */
9
+ import { useCallback } from '@wordpress/element';
6
10
  /**
7
11
  * Internal dependencies
8
12
  */
9
13
  import { COMMON_PROPS } from '../utils/constants';
10
14
  import { clampNumberOfMonths } from '../utils/misc';
11
- import { useControlledValue } from '../utils/use-controlled-value';
15
+ import { useControlledValue } from '../../utils/hooks';
12
16
  import { useLocalizationProps } from '../utils/use-localization-props';
13
- import type { DateCalendarProps } from '../types';
17
+ import type { DateCalendarProps, OnSelectHandler } from '../types';
14
18
 
15
19
  /**
16
20
  * `DateCalendar` is a React component that provides a customizable calendar
@@ -35,11 +39,21 @@ export const DateCalendar = ( {
35
39
  mode: 'single',
36
40
  } );
37
41
 
38
- const [ selected, setSelected ] = useControlledValue< Date | undefined >( {
39
- defaultValue: defaultSelected,
40
- value: selectedProp,
41
- onChange: onSelect,
42
- } );
42
+ const onChange: OnSelectHandler< typeof selectedProp > = useCallback(
43
+ ( selected, triggerDate, modifiers, e ) => {
44
+ // Convert internal `null` to `undefined` for the public event handler.
45
+ onSelect?.( selected ?? undefined, triggerDate, modifiers, e );
46
+ },
47
+ [ onSelect ]
48
+ );
49
+
50
+ const [ selected, setSelected ] = useControlledValue< typeof selectedProp >(
51
+ {
52
+ defaultValue: defaultSelected,
53
+ value: selectedProp,
54
+ onChange,
55
+ }
56
+ );
43
57
 
44
58
  return (
45
59
  <DayPicker
@@ -48,7 +62,7 @@ export const DateCalendar = ( {
48
62
  { ...props }
49
63
  mode="single"
50
64
  numberOfMonths={ clampNumberOfMonths( numberOfMonths ) }
51
- selected={ selected }
65
+ selected={ selected ?? undefined }
52
66
  onSelect={ setSelected }
53
67
  />
54
68
  );