@wordpress/components 32.2.1-next.v.202602111440.0 → 32.2.1

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 (588) hide show
  1. package/CHANGELOG.md +46 -1
  2. package/CLAUDE.md +1 -0
  3. package/build/alignment-matrix-control/cell.cjs +2 -2
  4. package/build/alignment-matrix-control/cell.cjs.map +1 -1
  5. package/build/alignment-matrix-control/index.cjs +2 -2
  6. package/build/alignment-matrix-control/index.cjs.map +1 -1
  7. package/build/angle-picker-control/angle-circle.cjs +4 -4
  8. package/build/angle-picker-control/angle-circle.cjs.map +2 -2
  9. package/build/autocomplete/index.cjs +16 -8
  10. package/build/autocomplete/index.cjs.map +2 -2
  11. package/build/clipboard-button/index.cjs +1 -1
  12. package/build/clipboard-button/index.cjs.map +2 -2
  13. package/build/color-picker/color-copy-button.cjs +1 -1
  14. package/build/color-picker/color-copy-button.cjs.map +2 -2
  15. package/build/confirm-dialog/component.cjs +2 -2
  16. package/build/confirm-dialog/component.cjs.map +2 -2
  17. package/build/context/context-system-provider.cjs.map +1 -1
  18. package/build/custom-gradient-picker/gradient-bar/control-points.cjs +2 -2
  19. package/build/custom-gradient-picker/gradient-bar/control-points.cjs.map +2 -2
  20. package/build/date-time/date/index.cjs +1 -1
  21. package/build/date-time/date/index.cjs.map +2 -2
  22. package/build/date-time/time/index.cjs +1 -1
  23. package/build/date-time/time/index.cjs.map +2 -2
  24. package/build/date-time/utils.cjs +9 -0
  25. package/build/date-time/utils.cjs.map +2 -2
  26. package/build/dropdown/index.cjs +1 -1
  27. package/build/dropdown/index.cjs.map +2 -2
  28. package/build/external-link/index.cjs +5 -1
  29. package/build/external-link/index.cjs.map +2 -2
  30. package/build/higher-order/with-spoken-messages/index.cjs.map +2 -2
  31. package/build/modal/index.cjs +2 -2
  32. package/build/modal/index.cjs.map +2 -2
  33. package/build/modal/use-modal-exit-animation.cjs +2 -2
  34. package/build/modal/use-modal-exit-animation.cjs.map +2 -2
  35. package/build/number-control/index.cjs +1 -1
  36. package/build/number-control/index.cjs.map +2 -2
  37. package/build/palette-edit/index.cjs +1 -1
  38. package/build/palette-edit/index.cjs.map +2 -2
  39. package/build/panel/body.cjs +1 -1
  40. package/build/panel/body.cjs.map +2 -2
  41. package/build/private-apis.cjs +0 -2
  42. package/build/private-apis.cjs.map +2 -2
  43. package/build/range-control/index.cjs +1 -1
  44. package/build/range-control/index.cjs.map +2 -2
  45. package/build/resizable-box/resize-tooltip/utils.cjs +1 -1
  46. package/build/resizable-box/resize-tooltip/utils.cjs.map +2 -2
  47. package/build/sandbox/index.cjs +126 -2
  48. package/build/sandbox/index.cjs.map +2 -2
  49. package/build/select-control/styles/select-control-styles.cjs +8 -8
  50. package/build/select-control/styles/select-control-styles.cjs.map +2 -2
  51. package/build/snackbar/list.cjs +4 -1
  52. package/build/snackbar/list.cjs.map +2 -2
  53. package/build/tabs/styles.cjs +5 -5
  54. package/build/tabs/styles.cjs.map +2 -2
  55. package/build/text/utils.cjs.map +1 -1
  56. package/build/toggle-group-control/toggle-group-control-option-base/styles.cjs +8 -8
  57. package/build/toggle-group-control/toggle-group-control-option-base/styles.cjs.map +2 -2
  58. package/build/tree-grid/roving-tab-index-item.cjs +1 -1
  59. package/build/tree-grid/roving-tab-index-item.cjs.map +2 -2
  60. package/build/utils/element-rect.cjs +1 -1
  61. package/build/utils/element-rect.cjs.map +2 -2
  62. package/build/utils/hooks/use-update-effect.cjs.map +1 -1
  63. package/build/utils/rtl.cjs +2 -2
  64. package/build/utils/rtl.cjs.map +2 -2
  65. package/build/utils/use-responsive-value.cjs +1 -7
  66. package/build/utils/use-responsive-value.cjs.map +2 -2
  67. package/build/validated-form-controls/control-with-error.cjs +26 -3
  68. package/build/validated-form-controls/control-with-error.cjs.map +2 -2
  69. package/build/validated-form-controls/validity-indicator.cjs +2 -0
  70. package/build/validated-form-controls/validity-indicator.cjs.map +2 -2
  71. package/build-module/alignment-matrix-control/cell.mjs +2 -2
  72. package/build-module/alignment-matrix-control/cell.mjs.map +1 -1
  73. package/build-module/alignment-matrix-control/index.mjs +2 -2
  74. package/build-module/alignment-matrix-control/index.mjs.map +1 -1
  75. package/build-module/angle-picker-control/angle-circle.mjs +4 -4
  76. package/build-module/angle-picker-control/angle-circle.mjs.map +2 -2
  77. package/build-module/autocomplete/index.mjs +14 -7
  78. package/build-module/autocomplete/index.mjs.map +2 -2
  79. package/build-module/clipboard-button/index.mjs +1 -1
  80. package/build-module/clipboard-button/index.mjs.map +2 -2
  81. package/build-module/color-picker/color-copy-button.mjs +1 -1
  82. package/build-module/color-picker/color-copy-button.mjs.map +2 -2
  83. package/build-module/confirm-dialog/component.mjs +2 -2
  84. package/build-module/confirm-dialog/component.mjs.map +2 -2
  85. package/build-module/context/context-system-provider.mjs.map +1 -1
  86. package/build-module/custom-gradient-picker/gradient-bar/control-points.mjs +2 -2
  87. package/build-module/custom-gradient-picker/gradient-bar/control-points.mjs.map +2 -2
  88. package/build-module/date-time/date/index.mjs +1 -1
  89. package/build-module/date-time/date/index.mjs.map +2 -2
  90. package/build-module/date-time/time/index.mjs +2 -2
  91. package/build-module/date-time/time/index.mjs.map +2 -2
  92. package/build-module/date-time/utils.mjs +8 -0
  93. package/build-module/date-time/utils.mjs.map +2 -2
  94. package/build-module/dropdown/index.mjs +1 -1
  95. package/build-module/dropdown/index.mjs.map +2 -2
  96. package/build-module/external-link/index.mjs +5 -1
  97. package/build-module/external-link/index.mjs.map +2 -2
  98. package/build-module/higher-order/with-spoken-messages/index.mjs.map +2 -2
  99. package/build-module/modal/index.mjs +2 -2
  100. package/build-module/modal/index.mjs.map +2 -2
  101. package/build-module/modal/use-modal-exit-animation.mjs +2 -2
  102. package/build-module/modal/use-modal-exit-animation.mjs.map +2 -2
  103. package/build-module/number-control/index.mjs +1 -1
  104. package/build-module/number-control/index.mjs.map +2 -2
  105. package/build-module/palette-edit/index.mjs +1 -1
  106. package/build-module/palette-edit/index.mjs.map +2 -2
  107. package/build-module/panel/body.mjs +1 -1
  108. package/build-module/panel/body.mjs.map +2 -2
  109. package/build-module/private-apis.mjs +0 -2
  110. package/build-module/private-apis.mjs.map +2 -2
  111. package/build-module/range-control/index.mjs +1 -1
  112. package/build-module/range-control/index.mjs.map +2 -2
  113. package/build-module/resizable-box/resize-tooltip/utils.mjs +1 -1
  114. package/build-module/resizable-box/resize-tooltip/utils.mjs.map +2 -2
  115. package/build-module/sandbox/index.mjs +127 -3
  116. package/build-module/sandbox/index.mjs.map +2 -2
  117. package/build-module/select-control/styles/select-control-styles.mjs +8 -8
  118. package/build-module/select-control/styles/select-control-styles.mjs.map +2 -2
  119. package/build-module/snackbar/list.mjs +4 -1
  120. package/build-module/snackbar/list.mjs.map +2 -2
  121. package/build-module/tabs/styles.mjs +5 -5
  122. package/build-module/tabs/styles.mjs.map +2 -2
  123. package/build-module/text/utils.mjs.map +1 -1
  124. package/build-module/toggle-group-control/toggle-group-control-option-base/styles.mjs +8 -8
  125. package/build-module/toggle-group-control/toggle-group-control-option-base/styles.mjs.map +2 -2
  126. package/build-module/tree-grid/roving-tab-index-item.mjs +1 -1
  127. package/build-module/tree-grid/roving-tab-index-item.mjs.map +2 -2
  128. package/build-module/utils/element-rect.mjs +1 -1
  129. package/build-module/utils/element-rect.mjs.map +2 -2
  130. package/build-module/utils/hooks/use-update-effect.mjs.map +1 -1
  131. package/build-module/utils/rtl.mjs +2 -2
  132. package/build-module/utils/rtl.mjs.map +2 -2
  133. package/build-module/utils/use-responsive-value.mjs +1 -7
  134. package/build-module/utils/use-responsive-value.mjs.map +2 -2
  135. package/build-module/validated-form-controls/control-with-error.mjs +27 -4
  136. package/build-module/validated-form-controls/control-with-error.mjs.map +2 -2
  137. package/build-module/validated-form-controls/validity-indicator.mjs +2 -0
  138. package/build-module/validated-form-controls/validity-indicator.mjs.map +2 -2
  139. package/build-style/style-rtl.css +8 -4
  140. package/build-style/style.css +8 -4
  141. package/build-types/alignment-matrix-control/styles/alignment-matrix-control-icon-styles.d.ts +19 -0
  142. package/build-types/alignment-matrix-control/styles/alignment-matrix-control-icon-styles.d.ts.map +1 -0
  143. package/build-types/alignment-matrix-control/styles/alignment-matrix-control-styles.d.ts +23 -0
  144. package/build-types/alignment-matrix-control/styles/alignment-matrix-control-styles.d.ts.map +1 -0
  145. package/build-types/angle-picker-control/angle-circle.d.ts.map +1 -1
  146. package/build-types/angle-picker-control/index.d.ts +1 -1
  147. package/build-types/angle-picker-control/stories/index.story.d.ts +1 -1
  148. package/build-types/angle-picker-control/styles/angle-picker-control-styles.d.ts +25 -0
  149. package/build-types/angle-picker-control/styles/angle-picker-control-styles.d.ts.map +1 -0
  150. package/build-types/animate/index.d.ts +1 -1
  151. package/build-types/animate/index.d.ts.map +1 -1
  152. package/build-types/animate/types.d.ts +1 -1
  153. package/build-types/animate/types.d.ts.map +1 -1
  154. package/build-types/autocomplete/get-autocomplete-match.d.ts +20 -0
  155. package/build-types/autocomplete/get-autocomplete-match.d.ts.map +1 -0
  156. package/build-types/autocomplete/index.d.ts +10 -2
  157. package/build-types/autocomplete/index.d.ts.map +1 -1
  158. package/build-types/autocomplete/test/get-autocomplete-match.d.ts +2 -0
  159. package/build-types/autocomplete/test/get-autocomplete-match.d.ts.map +1 -0
  160. package/build-types/autocomplete/types.d.ts +1 -1
  161. package/build-types/autocomplete/types.d.ts.map +1 -1
  162. package/build-types/badge/stories/e2e/index.story.d.ts +7 -0
  163. package/build-types/badge/stories/e2e/index.story.d.ts.map +1 -0
  164. package/build-types/base-control/index.d.ts +2 -2
  165. package/build-types/base-control/stories/index.story.d.ts +1 -1
  166. package/build-types/border-box-control/border-box-control/hook.d.ts +1 -1
  167. package/build-types/border-box-control/border-box-control-linked-button/hook.d.ts +1 -1
  168. package/build-types/border-box-control/border-box-control-split-controls/hook.d.ts +1 -1
  169. package/build-types/border-box-control/border-box-control-visualizer/hook.d.ts +1 -1
  170. package/build-types/border-control/border-control/hook.d.ts +1 -1
  171. package/build-types/border-control/border-control-dropdown/hook.d.ts +1 -1
  172. package/build-types/border-control/border-control-style-picker/hook.d.ts +267 -0
  173. package/build-types/border-control/border-control-style-picker/hook.d.ts.map +1 -0
  174. package/build-types/box-control/all-input-control.d.ts +4 -0
  175. package/build-types/box-control/all-input-control.d.ts.map +1 -0
  176. package/build-types/box-control/axial-input-controls.d.ts +4 -0
  177. package/build-types/box-control/axial-input-controls.d.ts.map +1 -0
  178. package/build-types/box-control/input-controls.d.ts +4 -0
  179. package/build-types/box-control/input-controls.d.ts.map +1 -0
  180. package/build-types/box-control/styles/box-control-styles.d.ts +2 -2
  181. package/build-types/box-control/styles/box-control-styles.d.ts.map +1 -1
  182. package/build-types/box-control/styles/box-control-visualizer-styles.d.ts +46 -0
  183. package/build-types/box-control/styles/box-control-visualizer-styles.d.ts.map +1 -0
  184. package/build-types/box-control/unit-control.d.ts +4 -0
  185. package/build-types/box-control/unit-control.d.ts.map +1 -0
  186. package/build-types/card/card/hook.d.ts +1 -1
  187. package/build-types/card/card-body/hook.d.ts +1 -1
  188. package/build-types/card/card-footer/hook.d.ts +1 -1
  189. package/build-types/card/card-header/hook.d.ts +1 -1
  190. package/build-types/card/card-media/hook.d.ts +1 -1
  191. package/build-types/color-palette/stories/index.story.d.ts +6 -5
  192. package/build-types/color-palette/stories/index.story.d.ts.map +1 -1
  193. package/build-types/color-palette/styles.d.ts +1 -1
  194. package/build-types/color-picker/color-copy-button.d.ts.map +1 -1
  195. package/build-types/color-picker/styles.d.ts +2 -2
  196. package/build-types/color-picker/styles.d.ts.map +1 -1
  197. package/build-types/combobox-control/styles.d.ts +1 -1
  198. package/build-types/context/context-connect.d.ts +2 -2
  199. package/build-types/context/context-connect.d.ts.map +1 -1
  200. package/build-types/context/context-system-provider.d.ts +2 -2
  201. package/build-types/context/context-system-provider.d.ts.map +1 -1
  202. package/build-types/context/wordpress-component.d.ts +3 -3
  203. package/build-types/context/wordpress-component.d.ts.map +1 -1
  204. package/build-types/custom-gradient-picker/gradient-bar/control-points.d.ts.map +1 -1
  205. package/build-types/custom-gradient-picker/styles/custom-gradient-picker-styles.d.ts +2 -2
  206. package/build-types/custom-gradient-picker/test/index.d.ts +2 -0
  207. package/build-types/custom-gradient-picker/test/index.d.ts.map +1 -0
  208. package/build-types/custom-gradient-picker/types.d.ts +1 -1
  209. package/build-types/custom-gradient-picker/types.d.ts.map +1 -1
  210. package/build-types/custom-select-control/styles.d.ts +11 -0
  211. package/build-types/custom-select-control/styles.d.ts.map +1 -0
  212. package/build-types/custom-select-control-v2/types.d.ts +4 -4
  213. package/build-types/custom-select-control-v2/types.d.ts.map +1 -1
  214. package/build-types/date-time/date/styles.d.ts +2 -2
  215. package/build-types/date-time/date-picker/index.d.ts +23 -0
  216. package/build-types/date-time/date-picker/index.d.ts.map +1 -0
  217. package/build-types/date-time/date-picker/styles.d.ts +45 -0
  218. package/build-types/date-time/date-picker/styles.d.ts.map +1 -0
  219. package/build-types/date-time/date-picker/test/index.d.ts +2 -0
  220. package/build-types/date-time/date-picker/test/index.d.ts.map +1 -0
  221. package/build-types/date-time/date-picker/test/use-lilius.d.ts +2 -0
  222. package/build-types/date-time/date-picker/test/use-lilius.d.ts.map +1 -0
  223. package/build-types/date-time/date-picker/use-lilius/index.d.ts +169 -0
  224. package/build-types/date-time/date-picker/use-lilius/index.d.ts.map +1 -0
  225. package/build-types/date-time/date-time/styles.d.ts +1 -1
  226. package/build-types/date-time/time/index.d.ts.map +1 -1
  227. package/build-types/date-time/time-picker/index.d.ts +27 -0
  228. package/build-types/date-time/time-picker/index.d.ts.map +1 -0
  229. package/build-types/date-time/time-picker/styles.d.ts +93 -0
  230. package/build-types/date-time/time-picker/styles.d.ts.map +1 -0
  231. package/build-types/date-time/time-picker/test/index.d.ts +2 -0
  232. package/build-types/date-time/time-picker/test/index.d.ts.map +1 -0
  233. package/build-types/date-time/time-picker/time-input/index.d.ts +4 -0
  234. package/build-types/date-time/time-picker/time-input/index.d.ts.map +1 -0
  235. package/build-types/date-time/time-picker/time-input/test/index.d.ts +2 -0
  236. package/build-types/date-time/time-picker/time-input/test/index.d.ts.map +1 -0
  237. package/build-types/date-time/time-picker/timezone.d.ts +7 -0
  238. package/build-types/date-time/time-picker/timezone.d.ts.map +1 -0
  239. package/build-types/date-time/utils.d.ts +9 -0
  240. package/build-types/date-time/utils.d.ts.map +1 -1
  241. package/build-types/dimension-control/index.d.ts +28 -0
  242. package/build-types/dimension-control/index.d.ts.map +1 -0
  243. package/build-types/dimension-control/sizes.d.ts +26 -0
  244. package/build-types/dimension-control/sizes.d.ts.map +1 -0
  245. package/build-types/dimension-control/stories/index.story.d.ts +4 -0
  246. package/build-types/dimension-control/stories/index.story.d.ts.map +1 -0
  247. package/build-types/dimension-control/types.d.ts +47 -0
  248. package/build-types/dimension-control/types.d.ts.map +1 -0
  249. package/build-types/draggable/types.d.ts +1 -1
  250. package/build-types/draggable/types.d.ts.map +1 -1
  251. package/build-types/drop-zone/types.d.ts +1 -1
  252. package/build-types/drop-zone/types.d.ts.map +1 -1
  253. package/build-types/dropdown-menu/types.d.ts +1 -1
  254. package/build-types/dropdown-menu/types.d.ts.map +1 -1
  255. package/build-types/dropdown-menu-v2/index.d.ts +17 -0
  256. package/build-types/dropdown-menu-v2/index.d.ts.map +1 -0
  257. package/build-types/dropdown-menu-v2/stories/index.story.d.ts +11 -0
  258. package/build-types/dropdown-menu-v2/stories/index.story.d.ts.map +1 -0
  259. package/build-types/dropdown-menu-v2/styles.d.ts +42 -0
  260. package/build-types/dropdown-menu-v2/styles.d.ts.map +1 -0
  261. package/build-types/dropdown-menu-v2/test/index.d.ts +2 -0
  262. package/build-types/dropdown-menu-v2/test/index.d.ts.map +1 -0
  263. package/build-types/dropdown-menu-v2/types.d.ts +252 -0
  264. package/build-types/dropdown-menu-v2/types.d.ts.map +1 -0
  265. package/build-types/elevation/hook.d.ts +1 -1
  266. package/build-types/external-link/index.d.ts.map +1 -1
  267. package/build-types/external-link/styles/external-link-styles.d.ts +10 -0
  268. package/build-types/external-link/styles/external-link-styles.d.ts.map +1 -0
  269. package/build-types/flex/flex/hook.d.ts +1 -1
  270. package/build-types/flex/flex-block/hook.d.ts +1 -1
  271. package/build-types/flex/flex-item/hook.d.ts +1 -1
  272. package/build-types/focal-point-picker/styles/focal-point-picker-style.d.ts +1 -1
  273. package/build-types/font-size-picker/stories/index.story.d.ts +8 -7
  274. package/build-types/font-size-picker/stories/index.story.d.ts.map +1 -1
  275. package/build-types/font-size-picker/styles.d.ts +2 -2
  276. package/build-types/form-token-field/styles.d.ts +1 -1
  277. package/build-types/gradient-picker/stories/index.story.d.ts +6 -5
  278. package/build-types/gradient-picker/stories/index.story.d.ts.map +1 -1
  279. package/build-types/grid/hook.d.ts +1 -1
  280. package/build-types/h-stack/hook.d.ts +1 -1
  281. package/build-types/heading/hook.d.ts +1 -1
  282. package/build-types/higher-order/navigate-regions/index.d.ts +1 -1
  283. package/build-types/higher-order/with-notices/types.d.ts +1 -1
  284. package/build-types/higher-order/with-notices/types.d.ts.map +1 -1
  285. package/build-types/higher-order/with-spoken-messages/index.d.ts +2 -3
  286. package/build-types/higher-order/with-spoken-messages/index.d.ts.map +1 -1
  287. package/build-types/icon/index.d.ts +2 -2
  288. package/build-types/icon/index.d.ts.map +1 -1
  289. package/build-types/input-control/styles/input-control-styles.d.ts +2 -2
  290. package/build-types/item-group/item/hook.d.ts +1 -1
  291. package/build-types/item-group/item-group/hook.d.ts +1 -1
  292. package/build-types/menu/index.d.ts +2 -2
  293. package/build-types/menu/item-help-text.d.ts +1 -1
  294. package/build-types/menu/item-label.d.ts +1 -1
  295. package/build-types/menu/styles.d.ts +2 -2
  296. package/build-types/menu-item/index.d.ts +1 -1
  297. package/build-types/menu-item/stories/index.story.d.ts +4 -4
  298. package/build-types/menu-item/types.d.ts +1 -1
  299. package/build-types/menu-item/types.d.ts.map +1 -1
  300. package/build-types/mobile/inserter-button/sparkles.d.ts +3 -0
  301. package/build-types/mobile/inserter-button/sparkles.d.ts.map +1 -0
  302. package/build-types/modal/index.d.ts.map +1 -1
  303. package/build-types/modal/types.d.ts +1 -1
  304. package/build-types/modal/types.d.ts.map +1 -1
  305. package/build-types/modal/use-modal-exit-animation.d.ts +1 -1
  306. package/build-types/navigation/styles/navigation-styles.d.ts +2 -2
  307. package/build-types/navigation/types.d.ts +1 -1
  308. package/build-types/navigation/types.d.ts.map +1 -1
  309. package/build-types/navigator/navigator-back-button/hook.d.ts +1 -1
  310. package/build-types/navigator/navigator-back-button/index.d.ts +2 -0
  311. package/build-types/navigator/navigator-back-button/index.d.ts.map +1 -0
  312. package/build-types/navigator/navigator-button/hook.d.ts +1 -1
  313. package/build-types/navigator/navigator-button/index.d.ts +2 -0
  314. package/build-types/navigator/navigator-button/index.d.ts.map +1 -0
  315. package/build-types/navigator/navigator-provider/component.d.ts +38 -0
  316. package/build-types/navigator/navigator-provider/component.d.ts.map +1 -0
  317. package/build-types/navigator/navigator-provider/index.d.ts +2 -0
  318. package/build-types/navigator/navigator-provider/index.d.ts.map +1 -0
  319. package/build-types/navigator/navigator-screen/index.d.ts +2 -0
  320. package/build-types/navigator/navigator-screen/index.d.ts.map +1 -0
  321. package/build-types/navigator/navigator-to-parent-button/index.d.ts +2 -0
  322. package/build-types/navigator/navigator-to-parent-button/index.d.ts.map +1 -0
  323. package/build-types/palette-edit/styles.d.ts +1 -1
  324. package/build-types/palette-edit/types.d.ts +1 -1
  325. package/build-types/palette-edit/types.d.ts.map +1 -1
  326. package/build-types/panel/types.d.ts +2 -2
  327. package/build-types/panel/types.d.ts.map +1 -1
  328. package/build-types/private-apis.d.ts.map +1 -1
  329. package/build-types/radio-group/radio/index.d.ts +7 -0
  330. package/build-types/radio-group/radio/index.d.ts.map +1 -0
  331. package/build-types/radio-group/radio-context/index.d.ts +6 -0
  332. package/build-types/radio-group/radio-context/index.d.ts.map +1 -0
  333. package/build-types/range-control/index.d.ts.map +1 -1
  334. package/build-types/range-control/input-range.d.ts +1 -1
  335. package/build-types/range-control/styles/range-control-styles.d.ts.map +1 -1
  336. package/build-types/range-control/types.d.ts +2 -2
  337. package/build-types/range-control/types.d.ts.map +1 -1
  338. package/build-types/resizable-box/resize-tooltip/styles/resize-tooltip.styles.d.ts +1 -1
  339. package/build-types/resizable-box/resize-tooltip/utils.d.ts +1 -1
  340. package/build-types/resizable-box/resize-tooltip/utils.d.ts.map +1 -1
  341. package/build-types/sandbox/index.d.ts +1 -1
  342. package/build-types/sandbox/index.d.ts.map +1 -1
  343. package/build-types/sandbox/types.d.ts +11 -0
  344. package/build-types/sandbox/types.d.ts.map +1 -1
  345. package/build-types/scrollable/hook.d.ts +1 -1
  346. package/build-types/search-control/types.d.ts +1 -1
  347. package/build-types/search-control/types.d.ts.map +1 -1
  348. package/build-types/select-control/styles/select-control-styles.d.ts +2 -2
  349. package/build-types/select-control/styles/select-control-styles.d.ts.map +1 -1
  350. package/build-types/slot-fill/bubbles-virtually/fill.d.ts +5 -0
  351. package/build-types/slot-fill/bubbles-virtually/fill.d.ts.map +1 -0
  352. package/build-types/slot-fill/bubbles-virtually/slot-fill-context.d.ts +12 -0
  353. package/build-types/slot-fill/bubbles-virtually/slot-fill-context.d.ts.map +1 -0
  354. package/build-types/slot-fill/bubbles-virtually/slot-fill-provider.d.ts +4 -0
  355. package/build-types/slot-fill/bubbles-virtually/slot-fill-provider.d.ts.map +1 -0
  356. package/build-types/slot-fill/bubbles-virtually/slot.d.ts +1 -1
  357. package/build-types/slot-fill/types.d.ts +1 -1
  358. package/build-types/slot-fill/types.d.ts.map +1 -1
  359. package/build-types/slot-fill/use-slot.d.ts +9 -0
  360. package/build-types/slot-fill/use-slot.d.ts.map +1 -0
  361. package/build-types/snackbar/index.d.ts +1 -1
  362. package/build-types/snackbar/list.d.ts.map +1 -1
  363. package/build-types/spacer/hook.d.ts +1 -1
  364. package/build-types/style-provider/test/index.d.ts +2 -0
  365. package/build-types/style-provider/test/index.d.ts.map +1 -0
  366. package/build-types/surface/hook.d.ts +1 -1
  367. package/build-types/tabs/styles.d.ts.map +1 -1
  368. package/build-types/text/hook.d.ts +1 -1
  369. package/build-types/text/stories/index.story.d.ts +3 -3
  370. package/build-types/text/utils.d.ts +18 -18
  371. package/build-types/text/utils.d.ts.map +1 -1
  372. package/build-types/theme/stories/index.story.d.ts +1 -1
  373. package/build-types/toggle-group-control/toggle-group-control-option-base/styles.d.ts.map +1 -1
  374. package/build-types/toggle-group-control/toggle-group-control-option-icon/component.d.ts +1 -1
  375. package/build-types/toggle-group-control/types.d.ts +1 -1
  376. package/build-types/toggle-group-control/types.d.ts.map +1 -1
  377. package/build-types/tools-panel/tools-panel/hook.d.ts +1 -1
  378. package/build-types/tools-panel/tools-panel-header/hook.d.ts +1 -1
  379. package/build-types/tools-panel/tools-panel-item/hook.d.ts +1 -1
  380. package/build-types/tree-grid/types.d.ts +1 -1
  381. package/build-types/tree-grid/types.d.ts.map +1 -1
  382. package/build-types/truncate/hook.d.ts +1 -1
  383. package/build-types/ui/context/constants.d.ts +8 -0
  384. package/build-types/ui/context/constants.d.ts.map +1 -0
  385. package/build-types/ui/context/context-connect.d.ts +40 -0
  386. package/build-types/ui/context/context-connect.d.ts.map +1 -0
  387. package/build-types/ui/context/context-system-provider.d.ts +7 -0
  388. package/build-types/ui/context/context-system-provider.d.ts.map +1 -0
  389. package/build-types/ui/context/get-styled-class-name-from-key.d.ts +2 -0
  390. package/build-types/ui/context/get-styled-class-name-from-key.d.ts.map +1 -0
  391. package/build-types/ui/context/index.d.ts +5 -0
  392. package/build-types/ui/context/index.d.ts.map +1 -0
  393. package/build-types/ui/context/test/context-connect.d.ts +2 -0
  394. package/build-types/ui/context/test/context-connect.d.ts.map +1 -0
  395. package/build-types/ui/context/test/wordpress-component.d.ts +2 -0
  396. package/build-types/ui/context/test/wordpress-component.d.ts.map +1 -0
  397. package/build-types/ui/context/use-context-system.d.ts +20 -0
  398. package/build-types/ui/context/use-context-system.d.ts.map +1 -0
  399. package/build-types/ui/context/utils.d.ts +26 -0
  400. package/build-types/ui/context/utils.d.ts.map +1 -0
  401. package/build-types/ui/context/wordpress-component.d.ts +32 -0
  402. package/build-types/ui/context/wordpress-component.d.ts.map +1 -0
  403. package/build-types/ui/shortcut/component.d.ts +12 -0
  404. package/build-types/ui/shortcut/component.d.ts.map +1 -0
  405. package/build-types/ui/shortcut/index.d.ts +3 -0
  406. package/build-types/ui/shortcut/index.d.ts.map +1 -0
  407. package/build-types/ui/tooltip/component.d.ts +29 -0
  408. package/build-types/ui/tooltip/component.d.ts.map +1 -0
  409. package/build-types/ui/tooltip/content.d.ts +9 -0
  410. package/build-types/ui/tooltip/content.d.ts.map +1 -0
  411. package/build-types/ui/tooltip/context.d.ts +10 -0
  412. package/build-types/ui/tooltip/context.d.ts.map +1 -0
  413. package/build-types/ui/tooltip/index.d.ts +3 -0
  414. package/build-types/ui/tooltip/index.d.ts.map +1 -0
  415. package/build-types/ui/tooltip/styles.d.ts +12 -0
  416. package/build-types/ui/tooltip/styles.d.ts.map +1 -0
  417. package/build-types/ui/tooltip/types.d.ts +62 -0
  418. package/build-types/ui/tooltip/types.d.ts.map +1 -0
  419. package/build-types/ui/utils/colors.d.ts +17 -0
  420. package/build-types/ui/utils/colors.d.ts.map +1 -0
  421. package/build-types/ui/utils/font-size.d.ts +18 -0
  422. package/build-types/ui/utils/font-size.d.ts.map +1 -0
  423. package/build-types/ui/utils/get-valid-children.d.ts +13 -0
  424. package/build-types/ui/utils/get-valid-children.d.ts.map +1 -0
  425. package/build-types/ui/utils/index.d.ts +2 -0
  426. package/build-types/ui/utils/index.d.ts.map +1 -0
  427. package/build-types/ui/utils/space.d.ts +23 -0
  428. package/build-types/ui/utils/space.d.ts.map +1 -0
  429. package/build-types/ui/utils/types.d.ts +14 -0
  430. package/build-types/ui/utils/types.d.ts.map +1 -0
  431. package/build-types/ui/utils/use-responsive-value.d.ts +5 -0
  432. package/build-types/ui/utils/use-responsive-value.d.ts.map +1 -0
  433. package/build-types/utils/hooks/use-latest-ref.d.ts +15 -0
  434. package/build-types/utils/hooks/use-latest-ref.d.ts.map +1 -0
  435. package/build-types/utils/hooks/use-update-effect.d.ts +3 -3
  436. package/build-types/utils/hooks/use-update-effect.d.ts.map +1 -1
  437. package/build-types/utils/input/base.d.ts +3 -0
  438. package/build-types/utils/input/base.d.ts.map +1 -0
  439. package/build-types/utils/input/index.d.ts +2 -0
  440. package/build-types/utils/input/index.d.ts.map +1 -0
  441. package/build-types/utils/input/input-control.d.ts +2 -0
  442. package/build-types/utils/input/input-control.d.ts.map +1 -0
  443. package/build-types/utils/reduce-motion.d.ts +8 -0
  444. package/build-types/utils/reduce-motion.d.ts.map +1 -0
  445. package/build-types/utils/rtl.d.ts +4 -4
  446. package/build-types/utils/rtl.d.ts.map +1 -1
  447. package/build-types/utils/use-responsive-value.d.ts.map +1 -1
  448. package/build-types/utils/z-index.d.ts +3 -0
  449. package/build-types/utils/z-index.d.ts.map +1 -0
  450. package/build-types/v-stack/hook.d.ts +1 -1
  451. package/build-types/v-stack/stories/index.story.d.ts +1 -1
  452. package/build-types/validated-form-controls/components/range-control.d.ts.map +1 -1
  453. package/build-types/validated-form-controls/components/stories/overview.story.d.ts.map +1 -1
  454. package/build-types/validated-form-controls/control-with-error.d.ts.map +1 -1
  455. package/build-types/validated-form-controls/test/checkbox-control.d.ts +2 -0
  456. package/build-types/validated-form-controls/test/checkbox-control.d.ts.map +1 -0
  457. package/build-types/validated-form-controls/test/combobox-control.d.ts +2 -0
  458. package/build-types/validated-form-controls/test/combobox-control.d.ts.map +1 -0
  459. package/build-types/validated-form-controls/test/custom-select-control.d.ts +2 -0
  460. package/build-types/validated-form-controls/test/custom-select-control.d.ts.map +1 -0
  461. package/build-types/validated-form-controls/test/form-token-field.d.ts +2 -0
  462. package/build-types/validated-form-controls/test/form-token-field.d.ts.map +1 -0
  463. package/build-types/validated-form-controls/test/input-control.d.ts +2 -0
  464. package/build-types/validated-form-controls/test/input-control.d.ts.map +1 -0
  465. package/build-types/validated-form-controls/test/number-control.d.ts +2 -0
  466. package/build-types/validated-form-controls/test/number-control.d.ts.map +1 -0
  467. package/build-types/validated-form-controls/test/radio-control.d.ts +2 -0
  468. package/build-types/validated-form-controls/test/radio-control.d.ts.map +1 -0
  469. package/build-types/validated-form-controls/test/range-control.d.ts +2 -0
  470. package/build-types/validated-form-controls/test/range-control.d.ts.map +1 -0
  471. package/build-types/validated-form-controls/test/select-control.d.ts +2 -0
  472. package/build-types/validated-form-controls/test/select-control.d.ts.map +1 -0
  473. package/build-types/validated-form-controls/test/text-control.d.ts +2 -0
  474. package/build-types/validated-form-controls/test/text-control.d.ts.map +1 -0
  475. package/build-types/validated-form-controls/test/textarea-control.d.ts +2 -0
  476. package/build-types/validated-form-controls/test/textarea-control.d.ts.map +1 -0
  477. package/build-types/validated-form-controls/test/toggle-control.d.ts +2 -0
  478. package/build-types/validated-form-controls/test/toggle-control.d.ts.map +1 -0
  479. package/build-types/validated-form-controls/test/toggle-group-control.d.ts +2 -0
  480. package/build-types/validated-form-controls/test/toggle-group-control.d.ts.map +1 -0
  481. package/build-types/validated-form-controls/validity-indicator.d.ts +2 -1
  482. package/build-types/validated-form-controls/validity-indicator.d.ts.map +1 -1
  483. package/build-types/view/types.d.ts +8 -0
  484. package/build-types/view/types.d.ts.map +1 -0
  485. package/package.json +24 -24
  486. package/src/alignment-matrix-control/test/index.tsx +1 -1
  487. package/src/angle-picker-control/angle-circle.tsx +6 -5
  488. package/src/animate/types.ts +1 -1
  489. package/src/autocomplete/autocompleter-ui.tsx +1 -1
  490. package/src/autocomplete/index.tsx +33 -8
  491. package/src/autocomplete/test/index.tsx +110 -1
  492. package/src/autocomplete/types.ts +1 -1
  493. package/src/button/style.scss +8 -5
  494. package/src/calendar/style.scss +4 -2
  495. package/src/clipboard-button/index.tsx +1 -1
  496. package/src/color-palette/stories/index.story.tsx +56 -48
  497. package/src/color-picker/color-copy-button.tsx +1 -3
  498. package/src/composite/stories/index.story.tsx +1 -1
  499. package/src/confirm-dialog/component.tsx +2 -2
  500. package/src/context/context-connect.ts +3 -3
  501. package/src/context/context-system-provider.js +4 -4
  502. package/src/context/wordpress-component.ts +3 -5
  503. package/src/custom-gradient-picker/gradient-bar/control-points.tsx +3 -2
  504. package/src/custom-gradient-picker/types.ts +1 -1
  505. package/src/custom-select-control-v2/custom-select.tsx +1 -1
  506. package/src/custom-select-control-v2/stories/index.story.tsx +3 -3
  507. package/src/custom-select-control-v2/test/index.tsx +3 -3
  508. package/src/custom-select-control-v2/types.ts +4 -4
  509. package/src/date-time/date/index.tsx +1 -1
  510. package/src/date-time/test/utils.test.ts +8 -11
  511. package/src/date-time/time/index.tsx +2 -12
  512. package/src/date-time/time/test/index.tsx +69 -0
  513. package/src/date-time/utils.ts +18 -0
  514. package/src/draggable/index.native.js +17 -17
  515. package/src/draggable/types.ts +1 -1
  516. package/src/drop-zone/types.ts +1 -1
  517. package/src/dropdown/index.tsx +1 -1
  518. package/src/dropdown-menu/types.ts +1 -1
  519. package/src/external-link/index.tsx +5 -1
  520. package/src/font-size-picker/stories/index.story.tsx +133 -125
  521. package/src/form-token-field/style.scss +1 -0
  522. package/src/gradient-picker/stories/index.story.tsx +48 -42
  523. package/src/h-stack/test/index.tsx +1 -1
  524. package/src/heading/hook.ts +2 -2
  525. package/src/higher-order/with-notices/test/index.tsx +2 -2
  526. package/src/higher-order/with-notices/types.ts +1 -1
  527. package/src/higher-order/with-spoken-messages/index.tsx +2 -4
  528. package/src/icon/index.tsx +2 -2
  529. package/src/keyboard-shortcuts/index.tsx +1 -1
  530. package/src/menu/stories/index.story.tsx +1 -1
  531. package/src/menu-item/types.ts +1 -1
  532. package/src/modal/index.tsx +4 -3
  533. package/src/modal/types.ts +1 -1
  534. package/src/modal/use-modal-exit-animation.ts +2 -2
  535. package/src/navigation/README.md +1 -1
  536. package/src/navigation/types.ts +1 -1
  537. package/src/number-control/index.tsx +1 -1
  538. package/src/palette-edit/index.tsx +2 -2
  539. package/src/palette-edit/types.ts +1 -1
  540. package/src/panel/README.md +1 -1
  541. package/src/panel/body.tsx +1 -1
  542. package/src/panel/types.ts +2 -2
  543. package/src/popover/stories/index.story.tsx +1 -1
  544. package/src/private-apis.ts +0 -2
  545. package/src/radio-control/test/index.tsx +5 -4
  546. package/src/range-control/index.tsx +1 -1
  547. package/src/range-control/types.ts +2 -2
  548. package/src/resizable-box/index.tsx +1 -1
  549. package/src/resizable-box/resize-tooltip/index.tsx +1 -1
  550. package/src/resizable-box/resize-tooltip/label.tsx +1 -1
  551. package/src/resizable-box/resize-tooltip/utils.ts +2 -2
  552. package/src/sandbox/index.tsx +190 -10
  553. package/src/sandbox/test/index.tsx +65 -24
  554. package/src/sandbox/types.ts +11 -0
  555. package/src/search-control/types.ts +1 -1
  556. package/src/select-control/styles/select-control-styles.ts +1 -0
  557. package/src/slot-fill/types.ts +1 -1
  558. package/src/snackbar/list.tsx +7 -2
  559. package/src/tabs/styles.ts +1 -0
  560. package/src/text/utils.ts +18 -18
  561. package/src/toggle-group-control/test/__snapshots__/index.tsx.snap +18 -16
  562. package/src/toggle-group-control/toggle-group-control-option-base/component.tsx +1 -1
  563. package/src/toggle-group-control/toggle-group-control-option-base/styles.ts +4 -6
  564. package/src/toggle-group-control/types.ts +1 -1
  565. package/src/tree-grid/roving-tab-index-item.tsx +1 -1
  566. package/src/tree-grid/types.ts +1 -1
  567. package/src/utils/element-rect.ts +1 -1
  568. package/src/utils/hooks/use-update-effect.js +2 -2
  569. package/src/utils/rtl.js +4 -4
  570. package/src/utils/use-responsive-value.ts +1 -5
  571. package/src/v-stack/test/index.tsx +1 -1
  572. package/src/validated-form-controls/components/stories/overview.story.tsx +2 -1
  573. package/src/validated-form-controls/control-with-error.tsx +44 -4
  574. package/src/validated-form-controls/test/checkbox-control.tsx +49 -0
  575. package/src/validated-form-controls/test/combobox-control.tsx +61 -0
  576. package/src/validated-form-controls/test/control-with-error.tsx +182 -1
  577. package/src/validated-form-controls/test/custom-select-control.tsx +60 -0
  578. package/src/validated-form-controls/test/form-token-field.tsx +52 -0
  579. package/src/validated-form-controls/test/input-control.tsx +42 -0
  580. package/src/validated-form-controls/test/number-control.tsx +44 -0
  581. package/src/validated-form-controls/test/radio-control.tsx +61 -0
  582. package/src/validated-form-controls/test/range-control.tsx +73 -0
  583. package/src/validated-form-controls/test/select-control.tsx +57 -0
  584. package/src/validated-form-controls/test/text-control.tsx +49 -0
  585. package/src/validated-form-controls/test/textarea-control.tsx +51 -0
  586. package/src/validated-form-controls/test/toggle-control.tsx +49 -0
  587. package/src/validated-form-controls/test/toggle-group-control.tsx +28 -0
  588. package/src/validated-form-controls/validity-indicator.tsx +3 -0
@@ -18,7 +18,7 @@ function ClipboardButton({
18
18
  since: "5.8",
19
19
  alternative: "wp.compose.useCopyToClipboard"
20
20
  });
21
- const timeoutIdRef = useRef();
21
+ const timeoutIdRef = useRef(void 0);
22
22
  const ref = useCopyToClipboard(text, () => {
23
23
  onCopy();
24
24
  if (timeoutIdRef.current) {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/clipboard-button/index.tsx"],
4
- "sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useRef, useEffect } from '@wordpress/element';\nimport { useCopyToClipboard } from '@wordpress/compose';\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport Button from '../button';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nconst TIMEOUT = 4000;\nexport default function ClipboardButton({\n className,\n children,\n onCopy,\n onFinishCopy,\n text,\n ...buttonProps\n}) {\n deprecated('wp.components.ClipboardButton', {\n since: '5.8',\n alternative: 'wp.compose.useCopyToClipboard'\n });\n const timeoutIdRef = useRef();\n const ref = useCopyToClipboard(text, () => {\n onCopy();\n if (timeoutIdRef.current) {\n clearTimeout(timeoutIdRef.current);\n }\n if (onFinishCopy) {\n timeoutIdRef.current = setTimeout(() => onFinishCopy(), TIMEOUT);\n }\n });\n useEffect(() => {\n return () => {\n if (timeoutIdRef.current) {\n clearTimeout(timeoutIdRef.current);\n }\n };\n }, []);\n const classes = clsx('components-clipboard-button', className);\n\n // Workaround for inconsistent behavior in Safari, where <textarea> is not\n // the document.activeElement at the moment when the copy event fires.\n // This causes documentHasSelection() in the copy-handler component to\n // mistakenly override the ClipboardButton, and copy a serialized string\n // of the current block instead.\n const focusOnCopyEventTarget = event => {\n // @ts-expect-error: Should be currentTarget, but not changing because this component is deprecated.\n event.target.focus();\n };\n return (\n /*#__PURE__*/\n // Disable reasons: the parent component takes care of the __next40pxDefaultSize prop.\n // eslint-disable-next-line @wordpress/components-no-missing-40px-size-prop\n _jsx(Button, {\n ...buttonProps,\n className: classes,\n ref: ref,\n onCopy: focusOnCopyEventTarget,\n children: children\n })\n );\n}"],
5
- "mappings": ";AAGA,OAAO,UAAU;AAKjB,SAAS,QAAQ,iBAAiB;AAClC,SAAS,0BAA0B;AACnC,OAAO,gBAAgB;AAKvB,OAAO,YAAY;AACnB,SAAS,OAAO,YAAY;AAC5B,IAAM,UAAU;AACD,SAAR,gBAAiC;AAAA,EACtC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAG;AACD,aAAW,iCAAiC;AAAA,IAC1C,OAAO;AAAA,IACP,aAAa;AAAA,EACf,CAAC;AACD,QAAM,eAAe,OAAO;AAC5B,QAAM,MAAM,mBAAmB,MAAM,MAAM;AACzC,WAAO;AACP,QAAI,aAAa,SAAS;AACxB,mBAAa,aAAa,OAAO;AAAA,IACnC;AACA,QAAI,cAAc;AAChB,mBAAa,UAAU,WAAW,MAAM,aAAa,GAAG,OAAO;AAAA,IACjE;AAAA,EACF,CAAC;AACD,YAAU,MAAM;AACd,WAAO,MAAM;AACX,UAAI,aAAa,SAAS;AACxB,qBAAa,aAAa,OAAO;AAAA,MACnC;AAAA,IACF;AAAA,EACF,GAAG,CAAC,CAAC;AACL,QAAM,UAAU,KAAK,+BAA+B,SAAS;AAO7D,QAAM,yBAAyB,WAAS;AAEtC,UAAM,OAAO,MAAM;AAAA,EACrB;AACA;AAAA;AAAA;AAAA,IAIE,qBAAK,QAAQ;AAAA,MACX,GAAG;AAAA,MACH,WAAW;AAAA,MACX;AAAA,MACA,QAAQ;AAAA,MACR;AAAA,IACF,CAAC;AAAA;AAEL;",
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useRef, useEffect } from '@wordpress/element';\nimport { useCopyToClipboard } from '@wordpress/compose';\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport Button from '../button';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nconst TIMEOUT = 4000;\nexport default function ClipboardButton({\n className,\n children,\n onCopy,\n onFinishCopy,\n text,\n ...buttonProps\n}) {\n deprecated('wp.components.ClipboardButton', {\n since: '5.8',\n alternative: 'wp.compose.useCopyToClipboard'\n });\n const timeoutIdRef = useRef(undefined);\n const ref = useCopyToClipboard(text, () => {\n onCopy();\n if (timeoutIdRef.current) {\n clearTimeout(timeoutIdRef.current);\n }\n if (onFinishCopy) {\n timeoutIdRef.current = setTimeout(() => onFinishCopy(), TIMEOUT);\n }\n });\n useEffect(() => {\n return () => {\n if (timeoutIdRef.current) {\n clearTimeout(timeoutIdRef.current);\n }\n };\n }, []);\n const classes = clsx('components-clipboard-button', className);\n\n // Workaround for inconsistent behavior in Safari, where <textarea> is not\n // the document.activeElement at the moment when the copy event fires.\n // This causes documentHasSelection() in the copy-handler component to\n // mistakenly override the ClipboardButton, and copy a serialized string\n // of the current block instead.\n const focusOnCopyEventTarget = event => {\n // @ts-expect-error: Should be currentTarget, but not changing because this component is deprecated.\n event.target.focus();\n };\n return (\n /*#__PURE__*/\n // Disable reasons: the parent component takes care of the __next40pxDefaultSize prop.\n // eslint-disable-next-line @wordpress/components-no-missing-40px-size-prop\n _jsx(Button, {\n ...buttonProps,\n className: classes,\n ref: ref,\n onCopy: focusOnCopyEventTarget,\n children: children\n })\n );\n}"],
5
+ "mappings": ";AAGA,OAAO,UAAU;AAKjB,SAAS,QAAQ,iBAAiB;AAClC,SAAS,0BAA0B;AACnC,OAAO,gBAAgB;AAKvB,OAAO,YAAY;AACnB,SAAS,OAAO,YAAY;AAC5B,IAAM,UAAU;AACD,SAAR,gBAAiC;AAAA,EACtC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAG;AACD,aAAW,iCAAiC;AAAA,IAC1C,OAAO;AAAA,IACP,aAAa;AAAA,EACf,CAAC;AACD,QAAM,eAAe,OAAO,MAAS;AACrC,QAAM,MAAM,mBAAmB,MAAM,MAAM;AACzC,WAAO;AACP,QAAI,aAAa,SAAS;AACxB,mBAAa,aAAa,OAAO;AAAA,IACnC;AACA,QAAI,cAAc;AAChB,mBAAa,UAAU,WAAW,MAAM,aAAa,GAAG,OAAO;AAAA,IACjE;AAAA,EACF,CAAC;AACD,YAAU,MAAM;AACd,WAAO,MAAM;AACX,UAAI,aAAa,SAAS;AACxB,qBAAa,aAAa,OAAO;AAAA,MACnC;AAAA,IACF;AAAA,EACF,GAAG,CAAC,CAAC;AACL,QAAM,UAAU,KAAK,+BAA+B,SAAS;AAO7D,QAAM,yBAAyB,WAAS;AAEtC,UAAM,OAAO,MAAM;AAAA,EACrB;AACA;AAAA;AAAA;AAAA,IAIE,qBAAK,QAAQ;AAAA,MACX,GAAG;AAAA,MACH,WAAW;AAAA,MACX;AAAA,MACA,QAAQ;AAAA,MACR;AAAA,IACF,CAAC;AAAA;AAEL;",
6
6
  "names": []
7
7
  }
@@ -12,7 +12,7 @@ var ColorCopyButton = (props) => {
12
12
  colorType
13
13
  } = props;
14
14
  const [copiedColor, setCopiedColor] = useState(null);
15
- const copyTimerRef = useRef();
15
+ const copyTimerRef = useRef(void 0);
16
16
  const copyRef = useCopyToClipboard(() => {
17
17
  switch (colorType) {
18
18
  case "hsl": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/color-picker/color-copy-button.tsx"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useCopyToClipboard } from '@wordpress/compose';\nimport { useState, useEffect, useRef } from '@wordpress/element';\nimport { copy, check } from '@wordpress/icons';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { Button } from '../button';\nimport Tooltip from '../tooltip';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nexport const ColorCopyButton = props => {\n const {\n color,\n colorType\n } = props;\n const [copiedColor, setCopiedColor] = useState(null);\n const copyTimerRef = useRef();\n const copyRef = useCopyToClipboard(() => {\n switch (colorType) {\n case 'hsl':\n {\n return color.toHslString();\n }\n case 'rgb':\n {\n return color.toRgbString();\n }\n default:\n case 'hex':\n {\n return color.toHex();\n }\n }\n }, () => {\n if (copyTimerRef.current) {\n clearTimeout(copyTimerRef.current);\n }\n setCopiedColor(color.toHex());\n copyTimerRef.current = setTimeout(() => {\n setCopiedColor(null);\n copyTimerRef.current = undefined;\n }, 3000);\n });\n useEffect(() => {\n // Clear copyTimerRef on component unmount.\n return () => {\n if (copyTimerRef.current) {\n clearTimeout(copyTimerRef.current);\n }\n };\n }, []);\n const isCopied = copiedColor === color.toHex();\n const label = isCopied ? __('Copied!') : __('Copy');\n return /*#__PURE__*/_jsx(Tooltip, {\n delay: 0,\n hideOnClick: false,\n text: label,\n children: /*#__PURE__*/_jsx(Button, {\n size: \"compact\",\n \"aria-label\": label,\n ref: copyRef,\n icon: isCopied ? check : copy,\n showTooltip: false\n })\n });\n};"],
5
- "mappings": ";AAGA,SAAS,0BAA0B;AACnC,SAAS,UAAU,WAAW,cAAc;AAC5C,SAAS,MAAM,aAAa;AAC5B,SAAS,UAAU;AAKnB,SAAS,cAAc;AACvB,OAAO,aAAa;AACpB,SAAS,OAAO,YAAY;AACrB,IAAM,kBAAkB,WAAS;AACtC,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,EACF,IAAI;AACJ,QAAM,CAAC,aAAa,cAAc,IAAI,SAAS,IAAI;AACnD,QAAM,eAAe,OAAO;AAC5B,QAAM,UAAU,mBAAmB,MAAM;AACvC,YAAQ,WAAW;AAAA,MACjB,KAAK,OACH;AACE,eAAO,MAAM,YAAY;AAAA,MAC3B;AAAA,MACF,KAAK,OACH;AACE,eAAO,MAAM,YAAY;AAAA,MAC3B;AAAA,MACF;AAAA,MACA,KAAK,OACH;AACE,eAAO,MAAM,MAAM;AAAA,MACrB;AAAA,IACJ;AAAA,EACF,GAAG,MAAM;AACP,QAAI,aAAa,SAAS;AACxB,mBAAa,aAAa,OAAO;AAAA,IACnC;AACA,mBAAe,MAAM,MAAM,CAAC;AAC5B,iBAAa,UAAU,WAAW,MAAM;AACtC,qBAAe,IAAI;AACnB,mBAAa,UAAU;AAAA,IACzB,GAAG,GAAI;AAAA,EACT,CAAC;AACD,YAAU,MAAM;AAEd,WAAO,MAAM;AACX,UAAI,aAAa,SAAS;AACxB,qBAAa,aAAa,OAAO;AAAA,MACnC;AAAA,IACF;AAAA,EACF,GAAG,CAAC,CAAC;AACL,QAAM,WAAW,gBAAgB,MAAM,MAAM;AAC7C,QAAM,QAAQ,WAAW,GAAG,SAAS,IAAI,GAAG,MAAM;AAClD,SAAoB,qBAAK,SAAS;AAAA,IAChC,OAAO;AAAA,IACP,aAAa;AAAA,IACb,MAAM;AAAA,IACN,UAAuB,qBAAK,QAAQ;AAAA,MAClC,MAAM;AAAA,MACN,cAAc;AAAA,MACd,KAAK;AAAA,MACL,MAAM,WAAW,QAAQ;AAAA,MACzB,aAAa;AAAA,IACf,CAAC;AAAA,EACH,CAAC;AACH;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useCopyToClipboard } from '@wordpress/compose';\nimport { useState, useEffect, useRef } from '@wordpress/element';\nimport { copy, check } from '@wordpress/icons';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { Button } from '../button';\nimport Tooltip from '../tooltip';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nexport const ColorCopyButton = props => {\n const {\n color,\n colorType\n } = props;\n const [copiedColor, setCopiedColor] = useState(null);\n const copyTimerRef = useRef(undefined);\n const copyRef = useCopyToClipboard(() => {\n switch (colorType) {\n case 'hsl':\n {\n return color.toHslString();\n }\n case 'rgb':\n {\n return color.toRgbString();\n }\n default:\n case 'hex':\n {\n return color.toHex();\n }\n }\n }, () => {\n if (copyTimerRef.current) {\n clearTimeout(copyTimerRef.current);\n }\n setCopiedColor(color.toHex());\n copyTimerRef.current = setTimeout(() => {\n setCopiedColor(null);\n copyTimerRef.current = undefined;\n }, 3000);\n });\n useEffect(() => {\n // Clear copyTimerRef on component unmount.\n return () => {\n if (copyTimerRef.current) {\n clearTimeout(copyTimerRef.current);\n }\n };\n }, []);\n const isCopied = copiedColor === color.toHex();\n const label = isCopied ? __('Copied!') : __('Copy');\n return /*#__PURE__*/_jsx(Tooltip, {\n delay: 0,\n hideOnClick: false,\n text: label,\n children: /*#__PURE__*/_jsx(Button, {\n size: \"compact\",\n \"aria-label\": label,\n ref: copyRef,\n icon: isCopied ? check : copy,\n showTooltip: false\n })\n });\n};"],
5
+ "mappings": ";AAGA,SAAS,0BAA0B;AACnC,SAAS,UAAU,WAAW,cAAc;AAC5C,SAAS,MAAM,aAAa;AAC5B,SAAS,UAAU;AAKnB,SAAS,cAAc;AACvB,OAAO,aAAa;AACpB,SAAS,OAAO,YAAY;AACrB,IAAM,kBAAkB,WAAS;AACtC,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,EACF,IAAI;AACJ,QAAM,CAAC,aAAa,cAAc,IAAI,SAAS,IAAI;AACnD,QAAM,eAAe,OAAO,MAAS;AACrC,QAAM,UAAU,mBAAmB,MAAM;AACvC,YAAQ,WAAW;AAAA,MACjB,KAAK,OACH;AACE,eAAO,MAAM,YAAY;AAAA,MAC3B;AAAA,MACF,KAAK,OACH;AACE,eAAO,MAAM,YAAY;AAAA,MAC3B;AAAA,MACF;AAAA,MACA,KAAK,OACH;AACE,eAAO,MAAM,MAAM;AAAA,MACrB;AAAA,IACJ;AAAA,EACF,GAAG,MAAM;AACP,QAAI,aAAa,SAAS;AACxB,mBAAa,aAAa,OAAO;AAAA,IACnC;AACA,mBAAe,MAAM,MAAM,CAAC;AAC5B,iBAAa,UAAU,WAAW,MAAM;AACtC,qBAAe,IAAI;AACnB,mBAAa,UAAU;AAAA,IACzB,GAAG,GAAI;AAAA,EACT,CAAC;AACD,YAAU,MAAM;AAEd,WAAO,MAAM;AACX,UAAI,aAAa,SAAS;AACxB,qBAAa,aAAa,OAAO;AAAA,MACnC;AAAA,IACF;AAAA,EACF,GAAG,CAAC,CAAC;AACL,QAAM,WAAW,gBAAgB,MAAM,MAAM;AAC7C,QAAM,QAAQ,WAAW,GAAG,SAAS,IAAI,GAAG,MAAM;AAClD,SAAoB,qBAAK,SAAS;AAAA,IAChC,OAAO;AAAA,IACP,aAAa;AAAA,IACb,MAAM;AAAA,IACN,UAAuB,qBAAK,QAAQ;AAAA,MAClC,MAAM;AAAA,MACN,cAAc;AAAA,MACd,KAAK;AAAA,MACL,MAAM,WAAW,QAAQ;AAAA,MACzB,aAAa;AAAA,IACf,CAAC;AAAA,EACH,CAAC;AACH;",
6
6
  "names": []
7
7
  }
@@ -23,8 +23,8 @@ var UnconnectedConfirmDialog = (props, forwardedRef) => {
23
23
  } = useContextSystem(props, "ConfirmDialog");
24
24
  const cx = useCx();
25
25
  const wrapperClassName = cx(styles.wrapper);
26
- const cancelButtonRef = useRef();
27
- const confirmButtonRef = useRef();
26
+ const cancelButtonRef = useRef(null);
27
+ const confirmButtonRef = useRef(null);
28
28
  const [isOpen, setIsOpen] = useState();
29
29
  const [shouldSelfClose, setShouldSelfClose] = useState();
30
30
  useEffect(() => {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/confirm-dialog/component.tsx"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useCallback, useEffect, useRef, useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport Modal from '../modal';\nimport { useContextSystem, contextConnect } from '../context';\nimport { Flex } from '../flex';\nimport Button from '../button';\nimport { Text } from '../text';\nimport { VStack } from '../v-stack';\nimport * as styles from './styles';\nimport { useCx } from '../utils/hooks/use-cx';\nimport { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from \"react/jsx-runtime\";\nconst UnconnectedConfirmDialog = (props, forwardedRef) => {\n const {\n isOpen: isOpenProp,\n onConfirm,\n onCancel,\n children,\n confirmButtonText,\n cancelButtonText,\n isBusy,\n ...otherProps\n } = useContextSystem(props, 'ConfirmDialog');\n const cx = useCx();\n const wrapperClassName = cx(styles.wrapper);\n const cancelButtonRef = useRef();\n const confirmButtonRef = useRef();\n const [isOpen, setIsOpen] = useState();\n const [shouldSelfClose, setShouldSelfClose] = useState();\n useEffect(() => {\n // We only allow the dialog to close itself if `isOpenProp` is *not* set.\n // If `isOpenProp` is set, then it (probably) means it's controlled by a\n // parent component. In that case, `shouldSelfClose` might do more harm than\n // good, so we disable it.\n const isIsOpenSet = typeof isOpenProp !== 'undefined';\n setIsOpen(isIsOpenSet ? isOpenProp : true);\n setShouldSelfClose(!isIsOpenSet);\n }, [isOpenProp]);\n const handleEvent = useCallback(callback => event => {\n callback?.(event);\n if (shouldSelfClose) {\n setIsOpen(false);\n }\n }, [shouldSelfClose, setIsOpen]);\n const handleEnter = useCallback(event => {\n // Avoid triggering the 'confirm' action when a button is focused,\n // as this can cause a double submission.\n const isConfirmOrCancelButton = event.target === cancelButtonRef.current || event.target === confirmButtonRef.current;\n if (!isConfirmOrCancelButton && event.key === 'Enter') {\n handleEvent(onConfirm)(event);\n }\n }, [handleEvent, onConfirm]);\n const cancelLabel = cancelButtonText ?? __('Cancel');\n const confirmLabel = confirmButtonText ?? __('OK');\n return /*#__PURE__*/_jsx(_Fragment, {\n children: isOpen && /*#__PURE__*/_jsx(Modal, {\n onRequestClose: handleEvent(onCancel),\n onKeyDown: handleEnter,\n closeButtonLabel: cancelLabel,\n isDismissible: true,\n ref: forwardedRef,\n overlayClassName: wrapperClassName,\n __experimentalHideHeader: true,\n ...otherProps,\n children: /*#__PURE__*/_jsxs(VStack, {\n spacing: 8,\n children: [/*#__PURE__*/_jsx(Text, {\n children: children\n }), /*#__PURE__*/_jsxs(Flex, {\n direction: \"row\",\n justify: \"flex-end\",\n children: [/*#__PURE__*/_jsx(Button, {\n __next40pxDefaultSize: true,\n ref: cancelButtonRef,\n variant: \"tertiary\",\n onClick: handleEvent(onCancel),\n accessibleWhenDisabled: true,\n disabled: isBusy,\n children: cancelLabel\n }), /*#__PURE__*/_jsx(Button, {\n __next40pxDefaultSize: true,\n ref: confirmButtonRef,\n variant: \"primary\",\n onClick: handleEvent(onConfirm),\n accessibleWhenDisabled: true,\n disabled: isBusy,\n isBusy: isBusy,\n children: confirmLabel\n })]\n })]\n })\n })\n });\n};\n\n/**\n * `ConfirmDialog` is built of top of [`Modal`](/packages/components/src/modal/README.md)\n * and displays a confirmation dialog, with _confirm_ and _cancel_ buttons.\n * The dialog is confirmed by clicking the _confirm_ button or by pressing the `Enter` key.\n * It is cancelled (closed) by clicking the _cancel_ button, by pressing the `ESC` key, or by\n * clicking outside the dialog focus (i.e, the overlay).\n *\n * `ConfirmDialog` has two main implicit modes: controlled and uncontrolled.\n *\n * UnControlled:\n *\n * Allows the component to be used standalone, just by declaring it as part of another React's component render method:\n * - It will be automatically open (displayed) upon mounting;\n * - It will be automatically closed when clicking the _cancel_ button, by pressing the `ESC` key, or by clicking outside the dialog focus (i.e, the overlay);\n * - `onCancel` is not mandatory but can be passed. Even if passed, the dialog will still be able to close itself.\n *\n * Activating this mode is as simple as omitting the `isOpen` prop. The only mandatory prop, in this case, is the `onConfirm` callback. The message is passed as the `children`. You can pass any JSX you'd like, which allows to further format the message or include sub-component if you'd like:\n *\n * ```jsx\n * import { __experimentalConfirmDialog as ConfirmDialog } from '@wordpress/components';\n *\n * function Example() {\n * \treturn (\n * \t\t<ConfirmDialog onConfirm={ () => console.debug( ' Confirmed! ' ) }>\n * \t\t\tAre you sure? <strong>This action cannot be undone!</strong>\n * \t\t</ConfirmDialog>\n * \t);\n * }\n * ```\n *\n *\n * Controlled mode:\n * Let the parent component control when the dialog is open/closed. It's activated when a\n * boolean value is passed to `isOpen`:\n * - It will not be automatically closed. You need to let it know when to open/close by updating the value of the `isOpen` prop;\n * - Both `onConfirm` and the `onCancel` callbacks are mandatory props in this mode;\n * - You'll want to update the state that controls `isOpen` by updating it from the `onCancel` and `onConfirm` callbacks.\n *\n *```jsx\n * import { __experimentalConfirmDialog as ConfirmDialog } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * function Example() {\n * \tconst [ isOpen, setIsOpen ] = useState( true );\n *\n * \tconst handleConfirm = () => {\n * \t\tconsole.debug( 'Confirmed!' );\n * \t\tsetIsOpen( false );\n * \t};\n *\n * \tconst handleCancel = () => {\n * \t\tconsole.debug( 'Cancelled!' );\n * \t\tsetIsOpen( false );\n * \t};\n *\n * \treturn (\n * \t\t<ConfirmDialog\n * \t\t\tisOpen={ isOpen }\n * \t\t\tonConfirm={ handleConfirm }\n * \t\t\tonCancel={ handleCancel }\n * \t\t>\n * \t\t\tAre you sure? <strong>This action cannot be undone!</strong>\n * \t\t</ConfirmDialog>\n * \t);\n * }\n * ```\n */\nexport const ConfirmDialog = contextConnect(UnconnectedConfirmDialog, 'ConfirmDialog');\nexport default ConfirmDialog;"],
5
- "mappings": ";AAGA,SAAS,UAAU;AACnB,SAAS,aAAa,WAAW,QAAQ,gBAAgB;AAKzD,OAAO,WAAW;AAClB,SAAS,kBAAkB,sBAAsB;AACjD,SAAS,YAAY;AACrB,OAAO,YAAY;AACnB,SAAS,YAAY;AACrB,SAAS,cAAc;AACvB,YAAY,YAAY;AACxB,SAAS,aAAa;AACtB,SAAS,OAAO,MAAM,QAAQ,OAAO,YAAY,iBAAiB;AAClE,IAAM,2BAA2B,CAAC,OAAO,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,QACnC,SAAS;AAAA,QACT,UAAU,CAAc,qBAAK,MAAM;AAAA,UACjC;AAAA,QACF,CAAC,GAAgB,sBAAM,MAAM;AAAA,UAC3B,WAAW;AAAA,UACX,SAAS;AAAA,UACT,UAAU,CAAc,qBAAK,QAAQ;AAAA,YACnC,uBAAuB;AAAA,YACvB,KAAK;AAAA,YACL,SAAS;AAAA,YACT,SAAS,YAAY,QAAQ;AAAA,YAC7B,wBAAwB;AAAA,YACxB,UAAU;AAAA,YACV,UAAU;AAAA,UACZ,CAAC,GAAgB,qBAAK,QAAQ;AAAA,YAC5B,uBAAuB;AAAA,YACvB,KAAK;AAAA,YACL,SAAS;AAAA,YACT,SAAS,YAAY,SAAS;AAAA,YAC9B,wBAAwB;AAAA,YACxB,UAAU;AAAA,YACV;AAAA,YACA,UAAU;AAAA,UACZ,CAAC,CAAC;AAAA,QACJ,CAAC,CAAC;AAAA,MACJ,CAAC;AAAA,IACH,CAAC;AAAA,EACH,CAAC;AACH;AAqEO,IAAM,gBAAgB,eAAe,0BAA0B,eAAe;AACrF,IAAO,oBAAQ;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useCallback, useEffect, useRef, useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport Modal from '../modal';\nimport { useContextSystem, contextConnect } from '../context';\nimport { Flex } from '../flex';\nimport Button from '../button';\nimport { Text } from '../text';\nimport { VStack } from '../v-stack';\nimport * as styles from './styles';\nimport { useCx } from '../utils/hooks/use-cx';\nimport { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from \"react/jsx-runtime\";\nconst UnconnectedConfirmDialog = (props, forwardedRef) => {\n const {\n isOpen: isOpenProp,\n onConfirm,\n onCancel,\n children,\n confirmButtonText,\n cancelButtonText,\n isBusy,\n ...otherProps\n } = useContextSystem(props, 'ConfirmDialog');\n const cx = useCx();\n const wrapperClassName = cx(styles.wrapper);\n const cancelButtonRef = useRef(null);\n const confirmButtonRef = useRef(null);\n const [isOpen, setIsOpen] = useState();\n const [shouldSelfClose, setShouldSelfClose] = useState();\n useEffect(() => {\n // We only allow the dialog to close itself if `isOpenProp` is *not* set.\n // If `isOpenProp` is set, then it (probably) means it's controlled by a\n // parent component. In that case, `shouldSelfClose` might do more harm than\n // good, so we disable it.\n const isIsOpenSet = typeof isOpenProp !== 'undefined';\n setIsOpen(isIsOpenSet ? isOpenProp : true);\n setShouldSelfClose(!isIsOpenSet);\n }, [isOpenProp]);\n const handleEvent = useCallback(callback => event => {\n callback?.(event);\n if (shouldSelfClose) {\n setIsOpen(false);\n }\n }, [shouldSelfClose, setIsOpen]);\n const handleEnter = useCallback(event => {\n // Avoid triggering the 'confirm' action when a button is focused,\n // as this can cause a double submission.\n const isConfirmOrCancelButton = event.target === cancelButtonRef.current || event.target === confirmButtonRef.current;\n if (!isConfirmOrCancelButton && event.key === 'Enter') {\n handleEvent(onConfirm)(event);\n }\n }, [handleEvent, onConfirm]);\n const cancelLabel = cancelButtonText ?? __('Cancel');\n const confirmLabel = confirmButtonText ?? __('OK');\n return /*#__PURE__*/_jsx(_Fragment, {\n children: isOpen && /*#__PURE__*/_jsx(Modal, {\n onRequestClose: handleEvent(onCancel),\n onKeyDown: handleEnter,\n closeButtonLabel: cancelLabel,\n isDismissible: true,\n ref: forwardedRef,\n overlayClassName: wrapperClassName,\n __experimentalHideHeader: true,\n ...otherProps,\n children: /*#__PURE__*/_jsxs(VStack, {\n spacing: 8,\n children: [/*#__PURE__*/_jsx(Text, {\n children: children\n }), /*#__PURE__*/_jsxs(Flex, {\n direction: \"row\",\n justify: \"flex-end\",\n children: [/*#__PURE__*/_jsx(Button, {\n __next40pxDefaultSize: true,\n ref: cancelButtonRef,\n variant: \"tertiary\",\n onClick: handleEvent(onCancel),\n accessibleWhenDisabled: true,\n disabled: isBusy,\n children: cancelLabel\n }), /*#__PURE__*/_jsx(Button, {\n __next40pxDefaultSize: true,\n ref: confirmButtonRef,\n variant: \"primary\",\n onClick: handleEvent(onConfirm),\n accessibleWhenDisabled: true,\n disabled: isBusy,\n isBusy: isBusy,\n children: confirmLabel\n })]\n })]\n })\n })\n });\n};\n\n/**\n * `ConfirmDialog` is built of top of [`Modal`](/packages/components/src/modal/README.md)\n * and displays a confirmation dialog, with _confirm_ and _cancel_ buttons.\n * The dialog is confirmed by clicking the _confirm_ button or by pressing the `Enter` key.\n * It is cancelled (closed) by clicking the _cancel_ button, by pressing the `ESC` key, or by\n * clicking outside the dialog focus (i.e, the overlay).\n *\n * `ConfirmDialog` has two main implicit modes: controlled and uncontrolled.\n *\n * UnControlled:\n *\n * Allows the component to be used standalone, just by declaring it as part of another React's component render method:\n * - It will be automatically open (displayed) upon mounting;\n * - It will be automatically closed when clicking the _cancel_ button, by pressing the `ESC` key, or by clicking outside the dialog focus (i.e, the overlay);\n * - `onCancel` is not mandatory but can be passed. Even if passed, the dialog will still be able to close itself.\n *\n * Activating this mode is as simple as omitting the `isOpen` prop. The only mandatory prop, in this case, is the `onConfirm` callback. The message is passed as the `children`. You can pass any JSX you'd like, which allows to further format the message or include sub-component if you'd like:\n *\n * ```jsx\n * import { __experimentalConfirmDialog as ConfirmDialog } from '@wordpress/components';\n *\n * function Example() {\n * \treturn (\n * \t\t<ConfirmDialog onConfirm={ () => console.debug( ' Confirmed! ' ) }>\n * \t\t\tAre you sure? <strong>This action cannot be undone!</strong>\n * \t\t</ConfirmDialog>\n * \t);\n * }\n * ```\n *\n *\n * Controlled mode:\n * Let the parent component control when the dialog is open/closed. It's activated when a\n * boolean value is passed to `isOpen`:\n * - It will not be automatically closed. You need to let it know when to open/close by updating the value of the `isOpen` prop;\n * - Both `onConfirm` and the `onCancel` callbacks are mandatory props in this mode;\n * - You'll want to update the state that controls `isOpen` by updating it from the `onCancel` and `onConfirm` callbacks.\n *\n *```jsx\n * import { __experimentalConfirmDialog as ConfirmDialog } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * function Example() {\n * \tconst [ isOpen, setIsOpen ] = useState( true );\n *\n * \tconst handleConfirm = () => {\n * \t\tconsole.debug( 'Confirmed!' );\n * \t\tsetIsOpen( false );\n * \t};\n *\n * \tconst handleCancel = () => {\n * \t\tconsole.debug( 'Cancelled!' );\n * \t\tsetIsOpen( false );\n * \t};\n *\n * \treturn (\n * \t\t<ConfirmDialog\n * \t\t\tisOpen={ isOpen }\n * \t\t\tonConfirm={ handleConfirm }\n * \t\t\tonCancel={ handleCancel }\n * \t\t>\n * \t\t\tAre you sure? <strong>This action cannot be undone!</strong>\n * \t\t</ConfirmDialog>\n * \t);\n * }\n * ```\n */\nexport const ConfirmDialog = contextConnect(UnconnectedConfirmDialog, 'ConfirmDialog');\nexport default ConfirmDialog;"],
5
+ "mappings": ";AAGA,SAAS,UAAU;AACnB,SAAS,aAAa,WAAW,QAAQ,gBAAgB;AAKzD,OAAO,WAAW;AAClB,SAAS,kBAAkB,sBAAsB;AACjD,SAAS,YAAY;AACrB,OAAO,YAAY;AACnB,SAAS,YAAY;AACrB,SAAS,cAAc;AACvB,YAAY,YAAY;AACxB,SAAS,aAAa;AACtB,SAAS,OAAO,MAAM,QAAQ,OAAO,YAAY,iBAAiB;AAClE,IAAM,2BAA2B,CAAC,OAAO,iBAAiB;AACxD,QAAM;AAAA,IACJ,QAAQ;AAAA,IACR;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL,IAAI,iBAAiB,OAAO,eAAe;AAC3C,QAAM,KAAK,MAAM;AACjB,QAAM,mBAAmB,GAAU,cAAO;AAC1C,QAAM,kBAAkB,OAAO,IAAI;AACnC,QAAM,mBAAmB,OAAO,IAAI;AACpC,QAAM,CAAC,QAAQ,SAAS,IAAI,SAAS;AACrC,QAAM,CAAC,iBAAiB,kBAAkB,IAAI,SAAS;AACvD,YAAU,MAAM;AAKd,UAAM,cAAc,OAAO,eAAe;AAC1C,cAAU,cAAc,aAAa,IAAI;AACzC,uBAAmB,CAAC,WA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A,YACxB,UAAU;AAAA,YACV;AAAA,YACA,UAAU;AAAA,UACZ,CAAC,CAAC;AAAA,QACJ,CAAC,CAAC;AAAA,MACJ,CAAC;AAAA,IACH,CAAC;AAAA,EACH,CAAC;AACH;AAqEO,IAAM,gBAAgB,eAAe,0BAA0B,eAAe;AACrF,IAAO,oBAAQ;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/context/context-system-provider.js"],
4
- "sourcesContent": ["/**\n * External dependencies\n */\nimport deepmerge from 'deepmerge';\nimport fastDeepEqual from 'fast-deep-equal/es6/index.js';\n// @ts-expect-error https://github.com/jonschlinkert/is-plain-object/pull/47\nimport { isPlainObject } from 'is-plain-object';\n\n/**\n * WordPress dependencies\n */\nimport { createContext, useContext, useRef, useMemo, memo } from '@wordpress/element';\nimport warn from '@wordpress/warning';\n\n/**\n * Internal dependencies\n */\nimport { useUpdateEffect } from '../utils';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nexport const ComponentsContext = createContext(/** @type {Record<string, any>} */{});\nComponentsContext.displayName = 'ComponentsContext';\nexport const useComponentsContext = () => useContext(ComponentsContext);\n\n/**\n * Consolidates incoming ContextSystem values with a (potential) parent ContextSystem value.\n *\n * Note: This function will warn if it detects an un-memoized `value`\n *\n * @param {Object} props\n * @param {Record<string, any>} props.value\n * @return {Record<string, any>} The consolidated value.\n */\nfunction useContextSystemBridge({\n value\n}) {\n const parentContext = useComponentsContext();\n const valueRef = useRef(value);\n useUpdateEffect(() => {\n if (\n // Objects are equivalent.\n fastDeepEqual(valueRef.current, value) &&\n // But not the same reference.\n valueRef.current !== value) {\n globalThis.SCRIPT_DEBUG === true ? warn(`Please memoize your context: ${JSON.stringify(value)}`) : void 0;\n }\n }, [value]);\n\n // `parentContext` will always be memoized (i.e., the result of this hook itself)\n // or the default value from when the `ComponentsContext` was originally\n // initialized (which will never change, it's a static variable)\n // so this memoization will prevent `deepmerge()` from rerunning unless\n // the references to `value` change OR the `parentContext` has an actual material change\n // (because again, it's guaranteed to be memoized or a static reference to the empty object\n // so we know that the only changes for `parentContext` are material ones... i.e., why we\n // don't have to warn in the `useUpdateEffect` hook above for `parentContext` and we only\n // need to bother with the `value`). The `useUpdateEffect` above will ensure that we are\n // correctly warning when the `value` isn't being properly memoized. All of that to say\n // that this should be super safe to assume that `useMemo` will only run on actual\n // changes to the two dependencies, therefore saving us calls to `deepmerge()`!\n const config = useMemo(() => {\n // Deep clone `parentContext` to avoid mutating it later.\n return deepmerge(parentContext ?? {}, value ?? {}, {\n isMergeableObject: isPlainObject\n });\n }, [parentContext, value]);\n return config;\n}\n\n/**\n * A Provider component that can modify props for connected components within\n * the Context system.\n *\n * @example\n * ```jsx\n * <ContextSystemProvider value={{ Button: { size: 'small' }}}>\n * <Button>...</Button>\n * </ContextSystemProvider>\n * ```\n *\n * @template {Record<string, any>} T\n * @param {Object} options\n * @param {import('react').ReactNode} options.children Children to render.\n * @param {T} options.value Props to render into connected components.\n * @return {JSX.Element} A Provider wrapped component.\n */\nconst BaseContextSystemProvider = ({\n children,\n value\n}) => {\n const contextValue = useContextSystemBridge({\n value\n });\n return /*#__PURE__*/_jsx(ComponentsContext.Provider, {\n value: contextValue,\n children: children\n });\n};\nexport const ContextSystemProvider = memo(BaseContextSystemProvider);"],
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport deepmerge from 'deepmerge';\nimport fastDeepEqual from 'fast-deep-equal/es6/index.js';\n// @ts-expect-error https://github.com/jonschlinkert/is-plain-object/pull/47\nimport { isPlainObject } from 'is-plain-object';\n\n/**\n * WordPress dependencies\n */\nimport { createContext, useContext, useRef, useMemo, memo } from '@wordpress/element';\nimport warn from '@wordpress/warning';\n\n/**\n * Internal dependencies\n */\nimport { useUpdateEffect } from '../utils';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nexport const ComponentsContext = createContext(/** @type {Record<string, any>} */{});\nComponentsContext.displayName = 'ComponentsContext';\nexport const useComponentsContext = () => useContext(ComponentsContext);\n\n/**\n * Consolidates incoming ContextSystem values with a (potential) parent ContextSystem value.\n *\n * Note: This function will warn if it detects an un-memoized `value`\n *\n * @param {Object} props\n * @param {Record<string, any>} props.value\n * @return {Record<string, any>} The consolidated value.\n */\nfunction useContextSystemBridge({\n value\n}) {\n const parentContext = useComponentsContext();\n const valueRef = useRef(value);\n useUpdateEffect(() => {\n if (\n // Objects are equivalent.\n fastDeepEqual(valueRef.current, value) &&\n // But not the same reference.\n valueRef.current !== value) {\n globalThis.SCRIPT_DEBUG === true ? warn(`Please memoize your context: ${JSON.stringify(value)}`) : void 0;\n }\n }, [value]);\n\n // `parentContext` will always be memoized (i.e., the result of this hook itself)\n // or the default value from when the `ComponentsContext` was originally\n // initialized (which will never change, it's a static variable)\n // so this memoization will prevent `deepmerge()` from rerunning unless\n // the references to `value` change OR the `parentContext` has an actual material change\n // (because again, it's guaranteed to be memoized or a static reference to the empty object\n // so we know that the only changes for `parentContext` are material ones... i.e., why we\n // don't have to warn in the `useUpdateEffect` hook above for `parentContext` and we only\n // need to bother with the `value`). The `useUpdateEffect` above will ensure that we are\n // correctly warning when the `value` isn't being properly memoized. All of that to say\n // that this should be super safe to assume that `useMemo` will only run on actual\n // changes to the two dependencies, therefore saving us calls to `deepmerge()`!\n const config = useMemo(() => {\n // Deep clone `parentContext` to avoid mutating it later.\n return deepmerge(parentContext ?? {}, value ?? {}, {\n isMergeableObject: isPlainObject\n });\n }, [parentContext, value]);\n return config;\n}\n\n/**\n * A Provider component that can modify props for connected components within\n * the Context system.\n *\n * @example\n * ```jsx\n * <ContextSystemProvider value={{ Button: { size: 'small' }}}>\n * <Button>...</Button>\n * </ContextSystemProvider>\n * ```\n *\n * @template {Record<string, any>} T\n * @param {Object} options\n * @param {React.ReactNode} options.children Children to render.\n * @param {T} options.value Props to render into connected components.\n * @return {React.JSX.Element} A Provider wrapped component.\n */\nconst BaseContextSystemProvider = ({\n children,\n value\n}) => {\n const contextValue = useContextSystemBridge({\n value\n });\n return /*#__PURE__*/_jsx(ComponentsContext.Provider, {\n value: contextValue,\n children: children\n });\n};\nexport const ContextSystemProvider = memo(BaseContextSystemProvider);"],
5
5
  "mappings": ";AAGA,OAAO,eAAe;AACtB,OAAO,mBAAmB;AAE1B,SAAS,qBAAqB;AAK9B,SAAS,eAAe,YAAY,QAAQ,SAAS,YAAY;AACjE,OAAO,UAAU;AAKjB,SAAS,uBAAuB;AAChC,SAAS,OAAO,YAAY;AACrB,IAAM,oBAAoB;AAAA;AAAA,EAAgD,CAAC;AAAC;AACnF,kBAAkB,cAAc;AACzB,IAAM,uBAAuB,MAAM,WAAW,iBAAiB;AAWtE,SAAS,uBAAuB;AAAA,EAC9B;AACF,GAAG;AACD,QAAM,gBAAgB,qBAAqB;AAC3C,QAAM,WAAW,OAAO,KAAK;AAC7B,kBAAgB,MAAM;AACpB;AAAA;AAAA,MAEA,cAAc,SAAS,SAAS,KAAK;AAAA,MAErC,SAAS,YAAY;AAAA,MAAO;AAC1B,iBAAW,iBAAiB,OAAO,KAAK,gCAAgC,KAAK,UAAU,KAAK,CAAC,EAAE,IAAI;AAAA,IACrG;AAAA,EACF,GAAG,CAAC,KAAK,CAAC;AAcV,QAAM,SAAS,QAAQ,MAAM;AAE3B,WAAO,UAAU,iBAAiB,CAAC,GAAG,SAAS,CAAC,GAAG;AAAA,MACjD,mBAAmB;AAAA,IACrB,CAAC;AAAA,EACH,GAAG,CAAC,eAAe,KAAK,CAAC;AACzB,SAAO;AACT;AAmBA,IAAM,4BAA4B,CAAC;AAAA,EACjC;AAAA,EACA;AACF,MAAM;AACJ,QAAM,eAAe,uBAAuB;AAAA,IAC1C;AAAA,EACF,CAAC;AACD,SAAoB,qBAAK,kBAAkB,UAAU;AAAA,IACnD,OAAO;AAAA,IACP;AAAA,EACF,CAAC;AACH;AACO,IAAM,wBAAwB,KAAK,yBAAyB;",
6
6
  "names": []
7
7
  }
@@ -76,7 +76,7 @@ function ControlPoints({
76
76
  onStopControlPointChange,
77
77
  __experimentalIsRenderedInSidebar
78
78
  }) {
79
- const controlPointMoveStateRef = useRef();
79
+ const controlPointMoveStateRef = useRef(void 0);
80
80
  const onMouseMove = (event) => {
81
81
  if (controlPointMoveStateRef.current === void 0 || gradientPickerDomRef.current === null) {
82
82
  return;
@@ -100,7 +100,7 @@ function ControlPoints({
100
100
  controlPointMoveStateRef.current.listenersActivated = false;
101
101
  }
102
102
  };
103
- const cleanEventListenersRef = useRef();
103
+ const cleanEventListenersRef = useRef(void 0);
104
104
  cleanEventListenersRef.current = cleanEventListeners;
105
105
  useEffect(() => {
106
106
  return () => {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/custom-gradient-picker/gradient-bar/control-points.tsx"],
4
- "sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\nimport { colord } from 'colord';\n\n/**\n * WordPress dependencies\n */\nimport { useInstanceId } from '@wordpress/compose';\nimport { useEffect, useRef, useState, useMemo } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { plus } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport Button from '../../button';\nimport { HStack } from '../../h-stack';\nimport { ColorPicker } from '../../color-picker';\nimport { VisuallyHidden } from '../../visually-hidden';\nimport { CustomColorPickerDropdown } from '../../color-palette';\nimport { addControlPoint, clampPercent, removeControlPoint, updateControlPointColor, updateControlPointColorByPosition, updateControlPointPosition, getHorizontalRelativeGradientPosition } from './utils';\nimport { MINIMUM_SIGNIFICANT_MOVE, KEYBOARD_CONTROL_POINT_VARIATION } from './constants';\nimport DropdownContentWrapper from '../../dropdown/dropdown-content-wrapper';\nimport { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from \"react/jsx-runtime\";\nfunction ControlPointButton({\n isOpen,\n position,\n color,\n ...additionalProps\n}) {\n const instanceId = useInstanceId(ControlPointButton);\n const descriptionId = `components-custom-gradient-picker__control-point-button-description-${instanceId}`;\n return /*#__PURE__*/_jsxs(_Fragment, {\n children: [/*#__PURE__*/_jsx(Button, {\n \"aria-label\": sprintf(\n // translators: 1: gradient position e.g: 70. 2: gradient color code e.g: rgb(52,121,151).\n __('Gradient control point at position %1$d%% with color code %2$s.'), position, color),\n \"aria-describedby\": descriptionId,\n \"aria-haspopup\": \"true\",\n \"aria-expanded\": isOpen,\n __next40pxDefaultSize: true,\n className: clsx('components-custom-gradient-picker__control-point-button', {\n 'is-active': isOpen\n }),\n ...additionalProps\n }), /*#__PURE__*/_jsx(VisuallyHidden, {\n id: descriptionId,\n children: __('Use your left or right arrow keys or drag and drop with the mouse to change the gradient position. Press the button to change the color or remove the control point.')\n })]\n });\n}\nfunction GradientColorPickerDropdown({\n isRenderedInSidebar,\n className,\n ...props\n}) {\n // Open the popover below the gradient control/insertion point\n const popoverProps = useMemo(() => ({\n placement: 'bottom',\n offset: 8,\n // Disabling resize as it would otherwise cause the popover to show\n // scrollbars while dragging the color picker's handle close to the\n // popover edge.\n resize: false\n }), []);\n const mergedClassName = clsx('components-custom-gradient-picker__control-point-dropdown', className);\n return /*#__PURE__*/_jsx(CustomColorPickerDropdown, {\n isRenderedInSidebar: isRenderedInSidebar,\n popoverProps: popoverProps,\n className: mergedClassName,\n ...props\n });\n}\nfunction ControlPoints({\n disableRemove,\n disableAlpha,\n gradientPickerDomRef,\n ignoreMarkerPosition,\n value: controlPoints,\n onChange,\n onStartControlPointChange,\n onStopControlPointChange,\n __experimentalIsRenderedInSidebar\n}) {\n const controlPointMoveStateRef = useRef();\n const onMouseMove = event => {\n if (controlPointMoveStateRef.current === undefined || gradientPickerDomRef.current === null) {\n return;\n }\n const relativePosition = getHorizontalRelativeGradientPosition(event.clientX, gradientPickerDomRef.current);\n const {\n initialPosition,\n index,\n significantMoveHappened\n } = controlPointMoveStateRef.current;\n if (!significantMoveHappened && Math.abs(initialPosition - relativePosition) >= MINIMUM_SIGNIFICANT_MOVE) {\n controlPointMoveStateRef.current.significantMoveHappened = true;\n }\n onChange(updateControlPointPosition(controlPoints, index, relativePosition));\n };\n const cleanEventListeners = () => {\n if (window && window.removeEventListener && controlPointMoveStateRef.current && controlPointMoveStateRef.current.listenersActivated) {\n window.removeEventListener('mousemove', onMouseMove);\n window.removeEventListener('mouseup', cleanEventListeners);\n onStopControlPointChange();\n controlPointMoveStateRef.current.listenersActivated = false;\n }\n };\n\n // Adding `cleanEventListeners` to the dependency array below requires the function itself to be wrapped in a `useCallback`\n // This memoization would prevent the event listeners from being properly cleaned.\n // Instead, we'll pass a ref to the function in our `useEffect` so `cleanEventListeners` itself is no longer a dependency.\n const cleanEventListenersRef = useRef();\n cleanEventListenersRef.current = cleanEventListeners;\n useEffect(() => {\n return () => {\n cleanEventListenersRef.current?.();\n };\n }, []);\n return /*#__PURE__*/_jsx(_Fragment, {\n children: controlPoints.map((point, index) => {\n const initialPosition = point?.position;\n return ignoreMarkerPosition !== initialPosition && /*#__PURE__*/_jsx(GradientColorPickerDropdown, {\n isRenderedInSidebar: __experimentalIsRenderedInSidebar,\n onClose: onStopControlPointChange,\n renderToggle: ({\n isOpen,\n onToggle\n }) => /*#__PURE__*/_jsx(ControlPointButton, {\n onClick: () => {\n if (controlPointMoveStateRef.current && controlPointMoveStateRef.current.significantMoveHappened) {\n return;\n }\n if (isOpen) {\n onStopControlPointChange();\n } else {\n onStartControlPointChange();\n }\n onToggle();\n },\n onMouseDown: () => {\n if (window && window.addEventListener) {\n controlPointMoveStateRef.current = {\n initialPosition,\n index,\n significantMoveHappened: false,\n listenersActivated: true\n };\n onStartControlPointChange();\n window.addEventListener('mousemove', onMouseMove);\n window.addEventListener('mouseup', cleanEventListeners);\n }\n },\n onKeyDown: event => {\n if (event.code === 'ArrowLeft') {\n // Stop propagation of the key press event to avoid focus moving\n // to another editor area.\n event.stopPropagation();\n onChange(updateControlPointPosition(controlPoints, index, clampPercent(point.position - KEYBOARD_CONTROL_POINT_VARIATION)));\n } else if (event.code === 'ArrowRight') {\n // Stop propagation of the key press event to avoid focus moving\n // to another editor area.\n event.stopPropagation();\n onChange(updateControlPointPosition(controlPoints, index, clampPercent(point.position + KEYBOARD_CONTROL_POINT_VARIATION)));\n }\n },\n isOpen: isOpen,\n position: point.position,\n color: point.color\n }, index),\n renderContent: ({\n onClose\n }) => /*#__PURE__*/_jsxs(DropdownContentWrapper, {\n paddingSize: \"none\",\n children: [/*#__PURE__*/_jsx(ColorPicker, {\n enableAlpha: !disableAlpha,\n color: point.color,\n onChange: color => {\n onChange(updateControlPointColor(controlPoints, index, colord(color).toRgbString()));\n }\n }), !disableRemove && controlPoints.length > 2 && /*#__PURE__*/_jsx(HStack, {\n className: \"components-custom-gradient-picker__remove-control-point-wrapper\",\n alignment: \"center\",\n children: /*#__PURE__*/_jsx(Button, {\n onClick: () => {\n onChange(removeControlPoint(controlPoints, index));\n onClose();\n },\n variant: \"link\",\n children: __('Remove Control Point')\n })\n })]\n }),\n style: {\n left: `${point.position}%`,\n transform: 'translateX( -50% )'\n }\n }, index);\n })\n });\n}\nfunction InsertPoint({\n value: controlPoints,\n onChange,\n onOpenInserter,\n onCloseInserter,\n insertPosition,\n disableAlpha,\n __experimentalIsRenderedInSidebar\n}) {\n const [alreadyInsertedPoint, setAlreadyInsertedPoint] = useState(false);\n return /*#__PURE__*/_jsx(GradientColorPickerDropdown, {\n isRenderedInSidebar: __experimentalIsRenderedInSidebar,\n className: \"components-custom-gradient-picker__inserter\",\n onClose: () => {\n onCloseInserter();\n },\n renderToggle: ({\n isOpen,\n onToggle\n }) => /*#__PURE__*/_jsx(Button, {\n __next40pxDefaultSize: true,\n \"aria-expanded\": isOpen,\n \"aria-haspopup\": \"true\",\n onClick: () => {\n if (isOpen) {\n onCloseInserter();\n } else {\n setAlreadyInsertedPoint(false);\n onOpenInserter();\n }\n onToggle();\n },\n className: \"components-custom-gradient-picker__insert-point-dropdown\",\n icon: plus\n }),\n renderContent: () => /*#__PURE__*/_jsx(DropdownContentWrapper, {\n paddingSize: \"none\",\n children: /*#__PURE__*/_jsx(ColorPicker, {\n enableAlpha: !disableAlpha,\n onChange: color => {\n if (!alreadyInsertedPoint) {\n onChange(addControlPoint(controlPoints, insertPosition, colord(color).toRgbString()));\n setAlreadyInsertedPoint(true);\n } else {\n onChange(updateControlPointColorByPosition(controlPoints, insertPosition, colord(color).toRgbString()));\n }\n }\n })\n }),\n style: insertPosition !== null ? {\n left: `${insertPosition}%`,\n transform: 'translateX( -50% )'\n } : undefined\n });\n}\nControlPoints.InsertPoint = InsertPoint;\nexport default ControlPoints;"],
5
- "mappings": ";AAGA,OAAO,UAAU;AACjB,SAAS,cAAc;AAKvB,SAAS,qBAAqB;AAC9B,SAAS,WAAW,QAAQ,UAAU,eAAe;AACrD,SAAS,IAAI,eAAe;AAC5B,SAAS,YAAY;AAKrB,OAAO,YAAY;AACnB,SAAS,cAAc;AACvB,SAAS,mBAAmB;AAC5B,SAAS,sBAAsB;AAC/B,SAAS,iCAAiC;AAC1C,SAAS,iBAAiB,cAAc,oBAAoB,yBAAyB,mCAAmC,4BAA4B,6CAA6C;AACjM,SAAS,0BAA0B,wCAAwC;AAC3E,OAAO,4BAA4B;AACnC,SAAS,OAAO,MAAM,YAAY,WAAW,QAAQ,aAAa;AAClE,SAAS,mBAAmB;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAG;AACD,QAAM,aAAa,cAAc,kBAAkB;AACnD,QAAM,gBAAgB,uEAAuE,UAAU;AACvG,SAAoB,sBAAM,WAAW;AAAA,IACnC,UAAU,CAAc,qBAAK,QAAQ;AAAA,MACnC,cAAc;AAAA;AAAA,QAEd,GAAG,iEAAiE;AAAA,QAAG;AAAA,QAAU;AAAA,MAAK;AAAA,MACtF,oBAAoB;AAAA,MACpB,iBAAiB;AAAA,MACjB,iBAAiB;AAAA,MACjB,uBAAuB;AAAA,MACvB,WAAW,KAAK,2DAA2D;AAAA,QACzE,aAAa;AAAA,MACf,CAAC;AAAA,MACD,GAAG;AAAA,IACL,CAAC,GAAgB,qB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,QAAQ;AACV,0BAAgB;AAAA,QAClB,OAAO;AACL,kCAAwB,KAAK;AAC7B,yBAAe;AAAA,QACjB;AACA,iBAAS;AAAA,MACX;AAAA,MACA,WAAW;AAAA,MACX,MAAM;AAAA,IACR,CAAC;AAAA,IACD,eAAe,MAAmB,qBAAK,wBAAwB;AAAA,MAC7D,aAAa;AAAA,MACb,UAAuB,qBAAK,aAAa;AAAA,QACvC,aAAa,CAAC;AAAA,QACd,UAAU,WAAS;AACjB,cAAI,CAAC,sBAAsB;AACzB,qBAAS,gBAAgB,eAAe,gBAAgB,OAAO,KAAK,EAAE,YAAY,CAAC,CAAC;AACpF,oCAAwB,IAAI;AAAA,UAC9B,OAAO;AACL,qBAAS,kCAAkC,eAAe,gBAAgB,OAAO,KAAK,EAAE,YAAY,CAAC,CAAC;AAAA,UACxG;AAAA,QACF;AAAA,MACF,CAAC;AAAA,IACH,CAAC;AAAA,IACD,OAAO,mBAAmB,OAAO;AAAA,MAC/B,MAAM,GAAG,cAAc;AAAA,MACvB,WAAW;AAAA,IACb,IAAI;AAAA,EACN,CAAC;AACH;AACA,cAAc,cAAc;AAC5B,IAAO,yBAAQ;",
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\nimport { colord } from 'colord';\n\n/**\n * WordPress dependencies\n */\nimport { useInstanceId } from '@wordpress/compose';\nimport { useEffect, useRef, useState, useMemo } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { plus } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport Button from '../../button';\nimport { HStack } from '../../h-stack';\nimport { ColorPicker } from '../../color-picker';\nimport { VisuallyHidden } from '../../visually-hidden';\nimport { CustomColorPickerDropdown } from '../../color-palette';\nimport { addControlPoint, clampPercent, removeControlPoint, updateControlPointColor, updateControlPointColorByPosition, updateControlPointPosition, getHorizontalRelativeGradientPosition } from './utils';\nimport { MINIMUM_SIGNIFICANT_MOVE, KEYBOARD_CONTROL_POINT_VARIATION } from './constants';\nimport DropdownContentWrapper from '../../dropdown/dropdown-content-wrapper';\nimport { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from \"react/jsx-runtime\";\nfunction ControlPointButton({\n isOpen,\n position,\n color,\n ...additionalProps\n}) {\n const instanceId = useInstanceId(ControlPointButton);\n const descriptionId = `components-custom-gradient-picker__control-point-button-description-${instanceId}`;\n return /*#__PURE__*/_jsxs(_Fragment, {\n children: [/*#__PURE__*/_jsx(Button, {\n \"aria-label\": sprintf(\n // translators: 1: gradient position e.g: 70. 2: gradient color code e.g: rgb(52,121,151).\n __('Gradient control point at position %1$d%% with color code %2$s.'), position, color),\n \"aria-describedby\": descriptionId,\n \"aria-haspopup\": \"true\",\n \"aria-expanded\": isOpen,\n __next40pxDefaultSize: true,\n className: clsx('components-custom-gradient-picker__control-point-button', {\n 'is-active': isOpen\n }),\n ...additionalProps\n }), /*#__PURE__*/_jsx(VisuallyHidden, {\n id: descriptionId,\n children: __('Use your left or right arrow keys or drag and drop with the mouse to change the gradient position. Press the button to change the color or remove the control point.')\n })]\n });\n}\nfunction GradientColorPickerDropdown({\n isRenderedInSidebar,\n className,\n ...props\n}) {\n // Open the popover below the gradient control/insertion point\n const popoverProps = useMemo(() => ({\n placement: 'bottom',\n offset: 8,\n // Disabling resize as it would otherwise cause the popover to show\n // scrollbars while dragging the color picker's handle close to the\n // popover edge.\n resize: false\n }), []);\n const mergedClassName = clsx('components-custom-gradient-picker__control-point-dropdown', className);\n return /*#__PURE__*/_jsx(CustomColorPickerDropdown, {\n isRenderedInSidebar: isRenderedInSidebar,\n popoverProps: popoverProps,\n className: mergedClassName,\n ...props\n });\n}\nfunction ControlPoints({\n disableRemove,\n disableAlpha,\n gradientPickerDomRef,\n ignoreMarkerPosition,\n value: controlPoints,\n onChange,\n onStartControlPointChange,\n onStopControlPointChange,\n __experimentalIsRenderedInSidebar\n}) {\n const controlPointMoveStateRef = useRef(undefined);\n const onMouseMove = event => {\n if (controlPointMoveStateRef.current === undefined || gradientPickerDomRef.current === null) {\n return;\n }\n const relativePosition = getHorizontalRelativeGradientPosition(event.clientX, gradientPickerDomRef.current);\n const {\n initialPosition,\n index,\n significantMoveHappened\n } = controlPointMoveStateRef.current;\n if (!significantMoveHappened && Math.abs(initialPosition - relativePosition) >= MINIMUM_SIGNIFICANT_MOVE) {\n controlPointMoveStateRef.current.significantMoveHappened = true;\n }\n onChange(updateControlPointPosition(controlPoints, index, relativePosition));\n };\n const cleanEventListeners = () => {\n if (window && window.removeEventListener && controlPointMoveStateRef.current && controlPointMoveStateRef.current.listenersActivated) {\n window.removeEventListener('mousemove', onMouseMove);\n window.removeEventListener('mouseup', cleanEventListeners);\n onStopControlPointChange();\n controlPointMoveStateRef.current.listenersActivated = false;\n }\n };\n\n // Adding `cleanEventListeners` to the dependency array below requires the function itself to be wrapped in a `useCallback`\n // This memoization would prevent the event listeners from being properly cleaned.\n // Instead, we'll pass a ref to the function in our `useEffect` so `cleanEventListeners` itself is no longer a dependency.\n const cleanEventListenersRef = useRef(undefined);\n cleanEventListenersRef.current = cleanEventListeners;\n useEffect(() => {\n return () => {\n cleanEventListenersRef.current?.();\n };\n }, []);\n return /*#__PURE__*/_jsx(_Fragment, {\n children: controlPoints.map((point, index) => {\n const initialPosition = point?.position;\n return ignoreMarkerPosition !== initialPosition && /*#__PURE__*/_jsx(GradientColorPickerDropdown, {\n isRenderedInSidebar: __experimentalIsRenderedInSidebar,\n onClose: onStopControlPointChange,\n renderToggle: ({\n isOpen,\n onToggle\n }) => /*#__PURE__*/_jsx(ControlPointButton, {\n onClick: () => {\n if (controlPointMoveStateRef.current && controlPointMoveStateRef.current.significantMoveHappened) {\n return;\n }\n if (isOpen) {\n onStopControlPointChange();\n } else {\n onStartControlPointChange();\n }\n onToggle();\n },\n onMouseDown: () => {\n if (window && window.addEventListener) {\n controlPointMoveStateRef.current = {\n initialPosition,\n index,\n significantMoveHappened: false,\n listenersActivated: true\n };\n onStartControlPointChange();\n window.addEventListener('mousemove', onMouseMove);\n window.addEventListener('mouseup', cleanEventListeners);\n }\n },\n onKeyDown: event => {\n if (event.code === 'ArrowLeft') {\n // Stop propagation of the key press event to avoid focus moving\n // to another editor area.\n event.stopPropagation();\n onChange(updateControlPointPosition(controlPoints, index, clampPercent(point.position - KEYBOARD_CONTROL_POINT_VARIATION)));\n } else if (event.code === 'ArrowRight') {\n // Stop propagation of the key press event to avoid focus moving\n // to another editor area.\n event.stopPropagation();\n onChange(updateControlPointPosition(controlPoints, index, clampPercent(point.position + KEYBOARD_CONTROL_POINT_VARIATION)));\n }\n },\n isOpen: isOpen,\n position: point.position,\n color: point.color\n }, index),\n renderContent: ({\n onClose\n }) => /*#__PURE__*/_jsxs(DropdownContentWrapper, {\n paddingSize: \"none\",\n children: [/*#__PURE__*/_jsx(ColorPicker, {\n enableAlpha: !disableAlpha,\n color: point.color,\n onChange: color => {\n onChange(updateControlPointColor(controlPoints, index, colord(color).toRgbString()));\n }\n }), !disableRemove && controlPoints.length > 2 && /*#__PURE__*/_jsx(HStack, {\n className: \"components-custom-gradient-picker__remove-control-point-wrapper\",\n alignment: \"center\",\n children: /*#__PURE__*/_jsx(Button, {\n onClick: () => {\n onChange(removeControlPoint(controlPoints, index));\n onClose();\n },\n variant: \"link\",\n children: __('Remove Control Point')\n })\n })]\n }),\n style: {\n left: `${point.position}%`,\n transform: 'translateX( -50% )'\n }\n }, index);\n })\n });\n}\nfunction InsertPoint({\n value: controlPoints,\n onChange,\n onOpenInserter,\n onCloseInserter,\n insertPosition,\n disableAlpha,\n __experimentalIsRenderedInSidebar\n}) {\n const [alreadyInsertedPoint, setAlreadyInsertedPoint] = useState(false);\n return /*#__PURE__*/_jsx(GradientColorPickerDropdown, {\n isRenderedInSidebar: __experimentalIsRenderedInSidebar,\n className: \"components-custom-gradient-picker__inserter\",\n onClose: () => {\n onCloseInserter();\n },\n renderToggle: ({\n isOpen,\n onToggle\n }) => /*#__PURE__*/_jsx(Button, {\n __next40pxDefaultSize: true,\n \"aria-expanded\": isOpen,\n \"aria-haspopup\": \"true\",\n onClick: () => {\n if (isOpen) {\n onCloseInserter();\n } else {\n setAlreadyInsertedPoint(false);\n onOpenInserter();\n }\n onToggle();\n },\n className: \"components-custom-gradient-picker__insert-point-dropdown\",\n icon: plus\n }),\n renderContent: () => /*#__PURE__*/_jsx(DropdownContentWrapper, {\n paddingSize: \"none\",\n children: /*#__PURE__*/_jsx(ColorPicker, {\n enableAlpha: !disableAlpha,\n onChange: color => {\n if (!alreadyInsertedPoint) {\n onChange(addControlPoint(controlPoints, insertPosition, colord(color).toRgbString()));\n setAlreadyInsertedPoint(true);\n } else {\n onChange(updateControlPointColorByPosition(controlPoints, insertPosition, colord(color).toRgbString()));\n }\n }\n })\n }),\n style: insertPosition !== null ? {\n left: `${insertPosition}%`,\n transform: 'translateX( -50% )'\n } : undefined\n });\n}\nControlPoints.InsertPoint = InsertPoint;\nexport default ControlPoints;"],
5
+ "mappings": ";AAGA,OAAO,UAAU;AACjB,SAAS,cAAc;AAKvB,SAAS,qBAAqB;AAC9B,SAAS,WAAW,QAAQ,UAAU,eAAe;AACrD,SAAS,IAAI,eAAe;AAC5B,SAAS,YAAY;AAKrB,OAAO,YAAY;AACnB,SAAS,cAAc;AACvB,SAAS,mBAAmB;AAC5B,SAAS,sBAAsB;AAC/B,SAAS,iCAAiC;AAC1C,SAAS,iBAAiB,cAAc,oBAAoB,yBAAyB,mCAAmC,4BAA4B,6CAA6C;AACjM,SAAS,0BAA0B,wCAAwC;AAC3E,OAAO,4BAA4B;AACnC,SAAS,OAAO,MAAM,YAAY,WAAW,QAAQ,aAAa;AAClE,SAAS,mBAAmB;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAG;AACD,QAAM,aAAa,cAAc,kBAAkB;AACnD,QAAM,gBAAgB,uEAAuE,UAAU;AACvG,SAAoB,sBAAM,WAAW;AAAA,IACnC,UAAU,CAAc,qBAAK,QAAQ;AAAA,MACnC,cAAc;AAA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K,6BAA6B;AAAA,IACpD,qBAAqB;AAAA,IACrB,WAAW;AAAA,IACX,SAAS,MAAM;AACb,sBAAgB;AAAA,IAClB;AAAA,IACA,cAAc,CAAC;AAAA,MACb;AAAA,MACA;AAAA,IACF,MAAmB,qBAAK,QAAQ;AAAA,MAC9B,uBAAuB;AAAA,MACvB,iBAAiB;AAAA,MACjB,iBAAiB;AAAA,MACjB,SAAS,MAAM;AACb,YAAI,QAAQ;AACV,0BAAgB;AAAA,QAClB,OAAO;AACL,kCAAwB,KAAK;AAC7B,yBAAe;AAAA,QACjB;AACA,iBAAS;AAAA,MACX;AAAA,MACA,WAAW;AAAA,MACX,MAAM;AAAA,IACR,CAAC;AAAA,IACD,eAAe,MAAmB,qBAAK,wBAAwB;AAAA,MAC7D,aAAa;AAAA,MACb,UAAuB,qBAAK,aAAa;AAAA,QACvC,aAAa,CAAC;AAAA,QACd,UAAU,WAAS;AACjB,cAAI,CAAC,sBAAsB;AACzB,qBAAS,gBAAgB,eAAe,gBAAgB,OAAO,KAAK,EAAE,YAAY,CAAC,CAAC;AACpF,oCAAwB,IAAI;AAAA,UAC9B,OAAO;AACL,qBAAS,kCAAkC,eAAe,gBAAgB,OAAO,KAAK,EAAE,YAAY,CAAC,CAAC;AAAA,UACxG;AAAA,QACF;AAAA,MACF,CAAC;AAAA,IACH,CAAC;AAAA,IACD,OAAO,mBAAmB,OAAO;AAAA,MAC/B,MAAM,GAAG,cAAc;AAAA,MACvB,WAAW;AAAA,IACb,IAAI;AAAA,EACN,CAAC;AACH;AACA,cAAc,cAAc;AAC5B,IAAO,yBAAQ;",
6
6
  "names": []
7
7
  }
@@ -157,7 +157,7 @@ function Day({
157
157
  onClick,
158
158
  onKeyDown
159
159
  }) {
160
- const ref = useRef();
160
+ const ref = useRef(null);
161
161
  useEffect(() => {
162
162
  if (ref.current && isFocusable && isFocusAllowed) {
163
163
  ref.current.focus();
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/date-time/date/index.tsx"],
4
- "sourcesContent": ["/**\n * External dependencies\n */\nimport { isSameDay, subMonths, addMonths, isEqual, addDays, subDays, subWeeks, addWeeks, isSameMonth } from 'date-fns';\n/**\n * WordPress dependencies\n */\nimport { __, _n, sprintf, isRTL } from '@wordpress/i18n';\nimport { arrowLeft, arrowRight } from '@wordpress/icons';\nimport { dateI18n, date as formatDate, getSettings } from '@wordpress/date';\nimport { useState, useRef, useEffect } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { useLilius } from './use-lilius';\nimport { Wrapper, Navigator, ViewPreviousMonthButton, ViewNextMonthButton, NavigatorHeading, Calendar, DayOfWeek, DayButton } from './styles';\nimport { inputToDate, setInConfiguredTimezone, startOfDayInConfiguredTimezone } from '../utils';\nimport { TIMEZONELESS_FORMAT } from '../constants';\n\n/**\n * DatePicker is a React component that renders a calendar for date selection.\n *\n * ```jsx\n * import { DatePicker } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * const MyDatePicker = () => {\n * const [ date, setDate ] = useState( new Date() );\n *\n * return (\n * <DatePicker\n * currentDate={ date }\n * onChange={ ( newDate ) => setDate( newDate ) }\n * />\n * );\n * };\n * ```\n */\nimport { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nexport function DatePicker({\n currentDate,\n onChange,\n events = [],\n isInvalidDate,\n onMonthPreviewed,\n startOfWeek: weekStartsOn = 0\n}) {\n const date = inputToDate(currentDate ?? new Date());\n const {\n calendar,\n viewing,\n setSelected,\n setViewing,\n isSelected,\n viewPreviousMonth,\n viewNextMonth\n } = useLilius({\n selected: [startOfDayInConfiguredTimezone(date)],\n viewing: startOfDayInConfiguredTimezone(date),\n weekStartsOn\n });\n\n // Used to implement a roving tab index. Tracks the day that receives focus\n // when the user tabs into the calendar.\n const [focusable, setFocusable] = useState(startOfDayInConfiguredTimezone(date));\n\n // Allows us to only programmatically focus() a day when focus was already\n // within the calendar. This stops us stealing focus from e.g. a TimePicker\n // input.\n const [isFocusWithinCalendar, setIsFocusWithinCalendar] = useState(false);\n\n // Update internal state when currentDate prop changes.\n const [prevCurrentDate, setPrevCurrentDate] = useState(currentDate);\n if (currentDate !== prevCurrentDate) {\n setPrevCurrentDate(currentDate);\n setSelected([startOfDayInConfiguredTimezone(date)]);\n setViewing(startOfDayInConfiguredTimezone(date));\n setFocusable(startOfDayInConfiguredTimezone(date));\n }\n return /*#__PURE__*/_jsxs(Wrapper, {\n className: \"components-datetime__date\",\n role: \"application\",\n \"aria-label\": __('Calendar'),\n children: [/*#__PURE__*/_jsxs(Navigator, {\n children: [/*#__PURE__*/_jsx(ViewPreviousMonthButton, {\n icon: isRTL() ? arrowRight : arrowLeft,\n variant: \"tertiary\",\n \"aria-label\": __('View previous month'),\n onClick: () => {\n viewPreviousMonth();\n setFocusable(subMonths(focusable, 1));\n const prevMonth = subMonths(viewing, 1);\n onMonthPreviewed?.(dateI18n(TIMEZONELESS_FORMAT, prevMonth, -prevMonth.getTimezoneOffset()));\n },\n size: \"compact\"\n }), /*#__PURE__*/_jsxs(NavigatorHeading, {\n level: 3,\n children: [/*#__PURE__*/_jsx(\"strong\", {\n children: dateI18n('F', viewing, -viewing.getTimezoneOffset())\n }), ' ', dateI18n('Y', viewing, -viewing.getTimezoneOffset())]\n }), /*#__PURE__*/_jsx(ViewNextMonthButton, {\n icon: isRTL() ? arrowLeft : arrowRight,\n variant: \"tertiary\",\n \"aria-label\": __('View next month'),\n onClick: () => {\n viewNextMonth();\n setFocusable(addMonths(focusable, 1));\n const nextMonth = addMonths(viewing, 1);\n onMonthPreviewed?.(dateI18n(TIMEZONELESS_FORMAT, nextMonth, -nextMonth.getTimezoneOffset()));\n },\n size: \"compact\"\n })]\n }), /*#__PURE__*/_jsxs(Calendar, {\n onFocus: () => setIsFocusWithinCalendar(true),\n onBlur: () => setIsFocusWithinCalendar(false),\n children: [calendar[0][0].map(day => /*#__PURE__*/_jsx(DayOfWeek, {\n children: dateI18n('D', day, -day.getTimezoneOffset())\n }, day.toString())), calendar[0].map(week => week.map((day, index) => {\n if (!isSameMonth(day, viewing)) {\n return null;\n }\n return /*#__PURE__*/_jsx(Day, {\n day: day,\n column: index + 1,\n isSelected: isSelected(day),\n isFocusable: isEqual(day, focusable),\n isFocusAllowed: isFocusWithinCalendar,\n isToday: isSameDay(day, startOfDayInConfiguredTimezone(new Date())),\n isInvalid: isInvalidDate ? isInvalidDate(day) : false,\n numEvents: events.filter(event => isSameDay(event.date, day)).length,\n onClick: () => {\n setSelected([day]);\n setFocusable(day);\n const newDate = setInConfiguredTimezone(date, {\n year: day.getFullYear(),\n month: day.getMonth(),\n date: day.getDate()\n });\n onChange?.(formatDate(TIMEZONELESS_FORMAT, newDate));\n },\n onKeyDown: event => {\n let nextFocusable;\n if (event.key === 'ArrowLeft') {\n nextFocusable = addDays(day, isRTL() ? 1 : -1);\n }\n if (event.key === 'ArrowRight') {\n nextFocusable = addDays(day, isRTL() ? -1 : 1);\n }\n if (event.key === 'ArrowUp') {\n nextFocusable = subWeeks(day, 1);\n }\n if (event.key === 'ArrowDown') {\n nextFocusable = addWeeks(day, 1);\n }\n if (event.key === 'PageUp') {\n nextFocusable = subMonths(day, 1);\n }\n if (event.key === 'PageDown') {\n nextFocusable = addMonths(day, 1);\n }\n if (event.key === 'Home') {\n const dayOfWeek = day.getDay();\n const daysToSubtract = (dayOfWeek - weekStartsOn + 7) % 7;\n nextFocusable = subDays(day, daysToSubtract);\n }\n if (event.key === 'End') {\n const dayOfWeek = day.getDay();\n const daysToAdd = (weekStartsOn + 6 - dayOfWeek) % 7;\n nextFocusable = addDays(day, daysToAdd);\n }\n if (nextFocusable) {\n event.preventDefault();\n setFocusable(nextFocusable);\n if (!isSameMonth(nextFocusable, viewing)) {\n setViewing(nextFocusable);\n onMonthPreviewed?.(dateI18n(TIMEZONELESS_FORMAT, nextFocusable, -nextFocusable.getTimezoneOffset()));\n }\n }\n }\n }, day.toString());\n }))]\n })]\n });\n}\nfunction Day({\n day,\n column,\n isSelected,\n isFocusable,\n isFocusAllowed,\n isToday,\n isInvalid,\n numEvents,\n onClick,\n onKeyDown\n}) {\n const ref = useRef();\n\n // Focus the day when it becomes focusable, e.g. because an arrow key is\n // pressed. Only do this if focus is allowed - this stops us stealing focus\n // from e.g. a TimePicker input.\n useEffect(() => {\n if (ref.current && isFocusable && isFocusAllowed) {\n ref.current.focus();\n }\n // isFocusAllowed is not a dep as there is no point calling focus() on\n // an already focused element.\n }, [isFocusable]);\n return /*#__PURE__*/_jsx(DayButton, {\n __next40pxDefaultSize: true,\n ref: ref,\n className: \"components-datetime__date__day\" // Unused, for backwards compatibility.\n ,\n disabled: isInvalid,\n tabIndex: isFocusable ? 0 : -1,\n \"aria-label\": getDayLabel(day, isSelected, isToday, numEvents),\n column: column,\n isSelected: isSelected,\n isToday: isToday,\n hasEvents: numEvents > 0,\n onClick: onClick,\n onKeyDown: onKeyDown,\n children: dateI18n('j', day, -day.getTimezoneOffset())\n });\n}\nfunction getDayLabel(date, isSelected, isToday, numEvents) {\n const {\n formats\n } = getSettings();\n const localizedDate = dateI18n(formats.date, date, -date.getTimezoneOffset());\n const parts = [localizedDate];\n if (isSelected) {\n parts.push(__('Selected'));\n }\n if (isToday) {\n parts.push(__('Today'));\n }\n if (numEvents > 0) {\n parts.push(sprintf(\n // translators: %d: Number of events on the calendar date.\n _n('There is %d event', 'There are %d events', numEvents), numEvents));\n }\n return parts.join('. ');\n}\nexport default DatePicker;"],
5
- "mappings": ";AAGA,SAAS,WAAW,WAAW,WAAW,SAAS,SAAS,SAAS,UAAU,UAAU,mBAAmB;AAI5G,SAAS,IAAI,IAAI,SAAS,aAAa;AACvC,SAAS,WAAW,kBAAkB;AACtC,SAAS,UAAU,QAAQ,YAAY,mBAAmB;AAC1D,SAAS,UAAU,QAAQ,iBAAiB;AAK5C,SAAS,iBAAiB;AAC1B,SAAS,SAAS,WAAW,yBAAyB,qBAAqB,kBAAkB,UAAU,WAAW,iBAAiB;AACnI,SAAS,aAAa,yB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UAAM,KAAK,GAAG,UAAU,CAAC;AAAA,EAC3B;AACA,MAAI,SAAS;AACX,UAAM,KAAK,GAAG,OAAO,CAAC;AAAA,EACxB;AACA,MAAI,YAAY,GAAG;AACjB,UAAM,KAAK;AAAA;AAAA,MAEX,GAAG,qBAAqB,uBAAuB,SAAS;AAAA,MAAG;AAAA,IAAS,CAAC;AAAA,EACvE;AACA,SAAO,MAAM,KAAK,IAAI;AACxB;AACA,IAAO,eAAQ;",
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport { isSameDay, subMonths, addMonths, isEqual, addDays, subDays, subWeeks, addWeeks, isSameMonth } from 'date-fns';\n/**\n * WordPress dependencies\n */\nimport { __, _n, sprintf, isRTL } from '@wordpress/i18n';\nimport { arrowLeft, arrowRight } from '@wordpress/icons';\nimport { dateI18n, date as formatDate, getSettings } from '@wordpress/date';\nimport { useState, useRef, useEffect } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { useLilius } from './use-lilius';\nimport { Wrapper, Navigator, ViewPreviousMonthButton, ViewNextMonthButton, NavigatorHeading, Calendar, DayOfWeek, DayButton } from './styles';\nimport { inputToDate, setInConfiguredTimezone, startOfDayInConfiguredTimezone } from '../utils';\nimport { TIMEZONELESS_FORMAT } from '../constants';\n\n/**\n * DatePicker is a React component that renders a calendar for date selection.\n *\n * ```jsx\n * import { DatePicker } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * const MyDatePicker = () => {\n * const [ date, setDate ] = useState( new Date() );\n *\n * return (\n * <DatePicker\n * currentDate={ date }\n * onChange={ ( newDate ) => setDate( newDate ) }\n * />\n * );\n * };\n * ```\n */\nimport { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nexport function DatePicker({\n currentDate,\n onChange,\n events = [],\n isInvalidDate,\n onMonthPreviewed,\n startOfWeek: weekStartsOn = 0\n}) {\n const date = inputToDate(currentDate ?? new Date());\n const {\n calendar,\n viewing,\n setSelected,\n setViewing,\n isSelected,\n viewPreviousMonth,\n viewNextMonth\n } = useLilius({\n selected: [startOfDayInConfiguredTimezone(date)],\n viewing: startOfDayInConfiguredTimezone(date),\n weekStartsOn\n });\n\n // Used to implement a roving tab index. Tracks the day that receives focus\n // when the user tabs into the calendar.\n const [focusable, setFocusable] = useState(startOfDayInConfiguredTimezone(date));\n\n // Allows us to only programmatically focus() a day when focus was already\n // within the calendar. This stops us stealing focus from e.g. a TimePicker\n // input.\n const [isFocusWithinCalendar, setIsFocusWithinCalendar] = useState(false);\n\n // Update internal state when currentDate prop changes.\n const [prevCurrentDate, setPrevCurrentDate] = useState(currentDate);\n if (currentDate !== prevCurrentDate) {\n setPrevCurrentDate(currentDate);\n setSelected([startOfDayInConfiguredTimezone(date)]);\n setViewing(startOfDayInConfiguredTimezone(date));\n setFocusable(startOfDayInConfiguredTimezone(date));\n }\n return /*#__PURE__*/_jsxs(Wrapper, {\n className: \"components-datetime__date\",\n role: \"application\",\n \"aria-label\": __('Calendar'),\n children: [/*#__PURE__*/_jsxs(Navigator, {\n children: [/*#__PURE__*/_jsx(ViewPreviousMonthButton, {\n icon: isRTL() ? arrowRight : arrowLeft,\n variant: \"tertiary\",\n \"aria-label\": __('View previous month'),\n onClick: () => {\n viewPreviousMonth();\n setFocusable(subMonths(focusable, 1));\n const prevMonth = subMonths(viewing, 1);\n onMonthPreviewed?.(dateI18n(TIMEZONELESS_FORMAT, prevMonth, -prevMonth.getTimezoneOffset()));\n },\n size: \"compact\"\n }), /*#__PURE__*/_jsxs(NavigatorHeading, {\n level: 3,\n children: [/*#__PURE__*/_jsx(\"strong\", {\n children: dateI18n('F', viewing, -viewing.getTimezoneOffset())\n }), ' ', dateI18n('Y', viewing, -viewing.getTimezoneOffset())]\n }), /*#__PURE__*/_jsx(ViewNextMonthButton, {\n icon: isRTL() ? arrowLeft : arrowRight,\n variant: \"tertiary\",\n \"aria-label\": __('View next month'),\n onClick: () => {\n viewNextMonth();\n setFocusable(addMonths(focusable, 1));\n const nextMonth = addMonths(viewing, 1);\n onMonthPreviewed?.(dateI18n(TIMEZONELESS_FORMAT, nextMonth, -nextMonth.getTimezoneOffset()));\n },\n size: \"compact\"\n })]\n }), /*#__PURE__*/_jsxs(Calendar, {\n onFocus: () => setIsFocusWithinCalendar(true),\n onBlur: () => setIsFocusWithinCalendar(false),\n children: [calendar[0][0].map(day => /*#__PURE__*/_jsx(DayOfWeek, {\n children: dateI18n('D', day, -day.getTimezoneOffset())\n }, day.toString())), calendar[0].map(week => week.map((day, index) => {\n if (!isSameMonth(day, viewing)) {\n return null;\n }\n return /*#__PURE__*/_jsx(Day, {\n day: day,\n column: index + 1,\n isSelected: isSelected(day),\n isFocusable: isEqual(day, focusable),\n isFocusAllowed: isFocusWithinCalendar,\n isToday: isSameDay(day, startOfDayInConfiguredTimezone(new Date())),\n isInvalid: isInvalidDate ? isInvalidDate(day) : false,\n numEvents: events.filter(event => isSameDay(event.date, day)).length,\n onClick: () => {\n setSelected([day]);\n setFocusable(day);\n const newDate = setInConfiguredTimezone(date, {\n year: day.getFullYear(),\n month: day.getMonth(),\n date: day.getDate()\n });\n onChange?.(formatDate(TIMEZONELESS_FORMAT, newDate));\n },\n onKeyDown: event => {\n let nextFocusable;\n if (event.key === 'ArrowLeft') {\n nextFocusable = addDays(day, isRTL() ? 1 : -1);\n }\n if (event.key === 'ArrowRight') {\n nextFocusable = addDays(day, isRTL() ? -1 : 1);\n }\n if (event.key === 'ArrowUp') {\n nextFocusable = subWeeks(day, 1);\n }\n if (event.key === 'ArrowDown') {\n nextFocusable = addWeeks(day, 1);\n }\n if (event.key === 'PageUp') {\n nextFocusable = subMonths(day, 1);\n }\n if (event.key === 'PageDown') {\n nextFocusable = addMonths(day, 1);\n }\n if (event.key === 'Home') {\n const dayOfWeek = day.getDay();\n const daysToSubtract = (dayOfWeek - weekStartsOn + 7) % 7;\n nextFocusable = subDays(day, daysToSubtract);\n }\n if (event.key === 'End') {\n const dayOfWeek = day.getDay();\n const daysToAdd = (weekStartsOn + 6 - dayOfWeek) % 7;\n nextFocusable = addDays(day, daysToAdd);\n }\n if (nextFocusable) {\n event.preventDefault();\n setFocusable(nextFocusable);\n if (!isSameMonth(nextFocusable, viewing)) {\n setViewing(nextFocusable);\n onMonthPreviewed?.(dateI18n(TIMEZONELESS_FORMAT, nextFocusable, -nextFocusable.getTimezoneOffset()));\n }\n }\n }\n }, day.toString());\n }))]\n })]\n });\n}\nfunction Day({\n day,\n column,\n isSelected,\n isFocusable,\n isFocusAllowed,\n isToday,\n isInvalid,\n numEvents,\n onClick,\n onKeyDown\n}) {\n const ref = useRef(null);\n\n // Focus the day when it becomes focusable, e.g. because an arrow key is\n // pressed. Only do this if focus is allowed - this stops us stealing focus\n // from e.g. a TimePicker input.\n useEffect(() => {\n if (ref.current && isFocusable && isFocusAllowed) {\n ref.current.focus();\n }\n // isFocusAllowed is not a dep as there is no point calling focus() on\n // an already focused element.\n }, [isFocusable]);\n return /*#__PURE__*/_jsx(DayButton, {\n __next40pxDefaultSize: true,\n ref: ref,\n className: \"components-datetime__date__day\" // Unused, for backwards compatibility.\n ,\n disabled: isInvalid,\n tabIndex: isFocusable ? 0 : -1,\n \"aria-label\": getDayLabel(day, isSelected, isToday, numEvents),\n column: column,\n isSelected: isSelected,\n isToday: isToday,\n hasEvents: numEvents > 0,\n onClick: onClick,\n onKeyDown: onKeyDown,\n children: dateI18n('j', day, -day.getTimezoneOffset())\n });\n}\nfunction getDayLabel(date, isSelected, isToday, numEvents) {\n const {\n formats\n } = getSettings();\n const localizedDate = dateI18n(formats.date, date, -date.getTimezoneOffset());\n const parts = [localizedDate];\n if (isSelected) {\n parts.push(__('Selected'));\n }\n if (isToday) {\n parts.push(__('Today'));\n }\n if (numEvents > 0) {\n parts.push(sprintf(\n // translators: %d: Number of events on the calendar date.\n _n('There is %d event', 'There are %d events', numEvents), numEvents));\n }\n return parts.join('. ');\n}\nexport default DatePicker;"],
5
+ "mappings": ";AAGA,SAAS,WAAW,WAAW,WAAW,SAAS,SAAS,SAA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S,KAAK,KAAK,CAAC,IAAI,kBAAkB,CAAC;AAAA,EACvD,CAAC;AACH;AACA,SAAS,YAAY,MAAM,YAAY,SAAS,WAAW;AACzD,QAAM;AAAA,IACJ;AAAA,EACF,IAAI,YAAY;AAChB,QAAM,gBAAgB,SAAS,QAAQ,MAAM,MAAM,CAAC,KAAK,kBAAkB,CAAC;AAC5E,QAAM,QAAQ,CAAC,aAAa;AAC5B,MAAI,YAAY;AACd,UAAM,KAAK,GAAG,UAAU,CAAC;AAAA,EAC3B;AACA,MAAI,SAAS;AACX,UAAM,KAAK,GAAG,OAAO,CAAC;AAAA,EACxB;AACA,MAAI,YAAY,GAAG;AACjB,UAAM,KAAK;AAAA;AAAA,MAEX,GAAG,qBAAqB,uBAAuB,SAAS;AAAA,MAAG;AAAA,IAAS,CAAC;AAAA,EACvE;AACA,SAAO,MAAM,KAAK,IAAI;AACxB;AACA,IAAO,eAAQ;",
6
6
  "names": []
7
7
  }
@@ -10,7 +10,7 @@ import TimeZone from "./timezone.mjs";
10
10
  import { Wrapper, Fieldset, MonthSelectWrapper, DayInput, YearInput } from "./styles.mjs";
11
11
  import { HStack } from "../../h-stack/index.mjs";
12
12
  import { Spacer } from "../../spacer/index.mjs";
13
- import { inputToDate, buildPadInputStateReducer, validateInputElementTarget, setInConfiguredTimezone } from "../utils.mjs";
13
+ import { inputToDate, buildPadInputStateReducer, validateInputElementTarget, setInConfiguredTimezone, getDaysInMonth } from "../utils.mjs";
14
14
  import { TIMEZONELESS_FORMAT } from "../constants.mjs";
15
15
  import { TimeInput } from "./time-input/index.mjs";
16
16
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
@@ -114,7 +114,7 @@ function TimePicker({
114
114
  value: day,
115
115
  step: 1,
116
116
  min: 1,
117
- max: 31,
117
+ max: getDaysInMonth(Number(year), Number(month) - 1),
118
118
  required: true,
119
119
  spinControls: "none",
120
120
  isPressEnterToChange: true,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/date-time/time/index.tsx"],
4
- "sourcesContent": ["/**\n * External dependencies\n */\nimport { startOfMinute } from 'date-fns';\n\n/**\n * WordPress dependencies\n */\nimport { useState, useMemo, useEffect } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { date as formatDate } from '@wordpress/date';\n\n/**\n * Internal dependencies\n */\nimport BaseControl from '../../base-control';\nimport { VisuallyHidden } from '../../visually-hidden';\nimport SelectControl from '../../select-control';\nimport TimeZone from './timezone';\nimport { Wrapper, Fieldset, MonthSelectWrapper, DayInput, YearInput } from './styles';\nimport { HStack } from '../../h-stack';\nimport { Spacer } from '../../spacer';\nimport { inputToDate, buildPadInputStateReducer, validateInputElementTarget, setInConfiguredTimezone } from '../utils';\nimport { TIMEZONELESS_FORMAT } from '../constants';\nimport { TimeInput } from './time-input';\nimport { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nconst VALID_DATE_ORDERS = ['dmy', 'mdy', 'ymd'];\n\n/**\n * TimePicker is a React component that renders a clock for time selection.\n *\n * ```jsx\n * import { TimePicker } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * const MyTimePicker = () => {\n * const [ time, setTime ] = useState( new Date() );\n *\n * return (\n * <TimePicker\n * currentTime={ date }\n * onChange={ ( newTime ) => setTime( newTime ) }\n * is12Hour\n * />\n * );\n * };\n * ```\n */\nexport function TimePicker({\n is12Hour,\n currentTime,\n onChange,\n dateOrder: dateOrderProp,\n hideLabelFromVision = false\n}) {\n const [date, setDate] = useState(() =>\n // Truncate the date at the minutes, see: #15495.\n startOfMinute(inputToDate(currentTime ?? new Date())));\n\n // Reset the state when currentTime changed.\n // TODO: useEffect() shouldn't be used like this, causes an unnecessary render\n useEffect(() => {\n setDate(startOfMinute(inputToDate(currentTime ?? new Date())));\n }, [currentTime]);\n const monthOptions = [{\n value: '01',\n label: __('January')\n }, {\n value: '02',\n label: __('February')\n }, {\n value: '03',\n label: __('March')\n }, {\n value: '04',\n label: __('April')\n }, {\n value: '05',\n label: __('May')\n }, {\n value: '06',\n label: __('June')\n }, {\n value: '07',\n label: __('July')\n }, {\n value: '08',\n label: __('August')\n }, {\n value: '09',\n label: __('September')\n }, {\n value: '10',\n label: __('October')\n }, {\n value: '11',\n label: __('November')\n }, {\n value: '12',\n label: __('December')\n }];\n const {\n day,\n month,\n year,\n minutes,\n hours\n } = useMemo(() => ({\n day: formatDate('d', date),\n month: formatDate('m', date),\n year: formatDate('Y', date),\n minutes: formatDate('i', date),\n hours: formatDate('H', date)\n }), [date]);\n const buildNumberControlChangeCallback = method => {\n const callback = (value, {\n event\n }) => {\n if (!validateInputElementTarget(event)) {\n return;\n }\n\n // We can safely assume value is a number if target is valid.\n const numberValue = Number(value);\n\n // Internal date is UTC-normalized, but the field should be updated\n // as if in the configured timezone.\n const newDate = setInConfiguredTimezone(date, {\n [method]: numberValue\n });\n setDate(newDate);\n onChange?.(formatDate(TIMEZONELESS_FORMAT, newDate));\n };\n return callback;\n };\n const onTimeInputChangeCallback = ({\n hours: newHours,\n minutes: newMinutes\n }) => {\n // Internal date is UTC-normalized, but the field should be updated\n // as if in the configured timezone.\n const newDate = setInConfiguredTimezone(date, {\n hours: newHours,\n minutes: newMinutes\n });\n setDate(newDate);\n onChange?.(formatDate(TIMEZONELESS_FORMAT, newDate));\n };\n const dayField = /*#__PURE__*/_jsx(DayInput, {\n className: \"components-datetime__time-field components-datetime__time-field-day\" // Unused, for backwards compatibility.\n ,\n label: __('Day'),\n hideLabelFromVision: true,\n __next40pxDefaultSize: true,\n value: day,\n step: 1,\n min: 1,\n max: 31,\n required: true,\n spinControls: \"none\",\n isPressEnterToChange: true,\n isDragEnabled: false,\n isShiftStepEnabled: false,\n onChange: buildNumberControlChangeCallback('date')\n }, \"day\");\n const monthField = /*#__PURE__*/_jsx(MonthSelectWrapper, {\n children: /*#__PURE__*/_jsx(SelectControl, {\n className: \"components-datetime__time-field components-datetime__time-field-month\" // Unused, for backwards compatibility.\n ,\n label: __('Month'),\n hideLabelFromVision: true,\n __next40pxDefaultSize: true,\n value: month,\n options: monthOptions,\n onChange: value => {\n // Internal date is UTC-normalized, but the field should be updated\n // as if in the configured timezone.\n const newDate = setInConfiguredTimezone(date, {\n month: Number(value) - 1\n });\n setDate(newDate);\n onChange?.(formatDate(TIMEZONELESS_FORMAT, newDate));\n }\n })\n }, \"month\");\n const yearField = /*#__PURE__*/_jsx(YearInput, {\n className: \"components-datetime__time-field components-datetime__time-field-year\" // Unused, for backwards compatibility.\n ,\n label: __('Year'),\n hideLabelFromVision: true,\n __next40pxDefaultSize: true,\n value: year,\n step: 1,\n min: 1,\n max: 9999,\n required: true,\n spinControls: \"none\",\n isPressEnterToChange: true,\n isDragEnabled: false,\n isShiftStepEnabled: false,\n onChange: buildNumberControlChangeCallback('year'),\n __unstableStateReducer: buildPadInputStateReducer(4)\n }, \"year\");\n const defaultDateOrder = is12Hour ? 'mdy' : 'dmy';\n const dateOrder = dateOrderProp && VALID_DATE_ORDERS.includes(dateOrderProp) ? dateOrderProp : defaultDateOrder;\n const fields = dateOrder.split('').map(field => {\n switch (field) {\n case 'd':\n return dayField;\n case 'm':\n return monthField;\n case 'y':\n return yearField;\n default:\n return null;\n }\n });\n return /*#__PURE__*/_jsxs(Wrapper, {\n className: \"components-datetime__time\" // Unused, for backwards compatibility.\n ,\n children: [/*#__PURE__*/_jsxs(Fieldset, {\n children: [hideLabelFromVision ? /*#__PURE__*/_jsx(VisuallyHidden, {\n as: \"legend\",\n children: __('Time')\n }) : /*#__PURE__*/_jsx(BaseControl.VisualLabel, {\n as: \"legend\",\n className: \"components-datetime__time-legend\" // Unused, for backwards compatibility.\n ,\n children: __('Time')\n }), /*#__PURE__*/_jsxs(HStack, {\n className: \"components-datetime__time-wrapper\" // Unused, for backwards compatibility.\n ,\n children: [/*#__PURE__*/_jsx(TimeInput, {\n value: {\n hours: Number(hours),\n minutes: Number(minutes)\n },\n is12Hour: is12Hour,\n onChange: onTimeInputChangeCallback\n }), /*#__PURE__*/_jsx(Spacer, {}), /*#__PURE__*/_jsx(TimeZone, {})]\n })]\n }), /*#__PURE__*/_jsxs(Fieldset, {\n children: [hideLabelFromVision ? /*#__PURE__*/_jsx(VisuallyHidden, {\n as: \"legend\",\n children: __('Date')\n }) : /*#__PURE__*/_jsx(BaseControl.VisualLabel, {\n as: \"legend\",\n className: \"components-datetime__time-legend\" // Unused, for backwards compatibility.\n ,\n children: __('Date')\n }), /*#__PURE__*/_jsx(HStack, {\n className: \"components-datetime__time-wrapper\" // Unused, for backwards compatibility.\n ,\n children: fields\n })]\n })]\n });\n}\n\n/**\n * A component to input a time.\n *\n * Values are passed as an object in 24-hour format (`{ hours: number, minutes: number }`).\n *\n * ```jsx\n * import { TimePicker } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * const MyTimeInput = () => {\n * \tconst [ time, setTime ] = useState( { hours: 13, minutes: 30 } );\n *\n * \treturn (\n * \t\t<TimePicker.TimeInput\n * \t\t\tvalue={ time }\n * \t\t\tonChange={ setTime }\n * \t\t\tlabel=\"Time\"\n * \t\t/>\n * \t);\n * };\n * ```\n */\nTimePicker.TimeInput = TimeInput;\nObject.assign(TimePicker.TimeInput, {\n displayName: 'TimePicker.TimeInput'\n});\nexport default TimePicker;"],
5
- "mappings": ";AAGA,SAAS,qBAAqB;AAK9B,SAAS,UAAU,SAAS,iBAAiB;AAC7C,SAAS,UAAU;AACnB,SAAS,QAAQ,kBAAkB;AAKnC,OAAO,iBAAiB;AACxB,SAAS,sBAAsB;AAC/B,OAAO,mBAAmB;AAC1B,OAAO,cAAc;AACrB,SAAS,SAAS,UAAU,oBAAoB,UAAU,iBAAiB;AAC3E,SAAS,cAAc;AACvB,SAAS,cAAc;AACvB,SAAS,aAAa,2BAA2B,4BAA4B,+BAA+B;AAC5G,SAAS,2BAA2B;AACpC,SAAS,iBAAiB;AAC1B,SAAS,OAAO,MAAM,QAAQ,aAAa;AAC3C,IAAM,oBAAoB,CAAC,OAAO,OAAO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ACJ,WAAW;AAAA,QAEX,UAAU,GAAG,MAAM;AAAA,MACrB,CAAC,GAAgB,sBAAM,QAAQ;AAAA,QAC7B,WAAW;AAAA,QAEX,UAAU,CAAc,qBAAK,WAAW;AAAA,UACtC,OAAO;AAAA,YACL,OAAO,OAAO,KAAK;AAAA,YACnB,SAAS,OAAO,OAAO;AAAA,UACzB;AAAA,UACA;AAAA,UACA,UAAU;AAAA,QACZ,CAAC,GAAgB,qBAAK,QAAQ,CAAC,CAAC,GAAgB,qBAAK,UAAU,CAAC,CAAC,CAAC;AAAA,MACpE,CAAC,CAAC;AAAA,IACJ,CAAC,GAAgB,sBAAM,UAAU;AAAA,MAC/B,UAAU,CAAC,sBAAmC,qBAAK,gBAAgB;AAAA,QACjE,IAAI;AAAA,QACJ,UAAU,GAAG,MAAM;AAAA,MACrB,CAAC,IAAiB,qBAAK,YAAY,aAAa;AAAA,QAC9C,IAAI;AAAA,QACJ,WAAW;AAAA,QAEX,UAAU,GAAG,MAAM;AAAA,MACrB,CAAC,GAAgB,qBAAK,QAAQ;AAAA,QAC5B,WAAW;AAAA,QAEX,UAAU;AAAA,MACZ,CAAC,CAAC;AAAA,IACJ,CAAC,CAAC;AAAA,EACJ,CAAC;AACH;AAwBA,WAAW,YAAY;AACvB,OAAO,OAAO,WAAW,WAAW;AAAA,EAClC,aAAa;AACf,CAAC;AACD,IAAO,eAAQ;",
4
+ "sourcesContent": ["import { startOfMinute } from 'date-fns';\nimport { useState, useMemo, useEffect } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { date as formatDate } from '@wordpress/date';\nimport BaseControl from '../../base-control';\nimport { VisuallyHidden } from '../../visually-hidden';\nimport SelectControl from '../../select-control';\nimport TimeZone from './timezone';\nimport { Wrapper, Fieldset, MonthSelectWrapper, DayInput, YearInput } from './styles';\nimport { HStack } from '../../h-stack';\nimport { Spacer } from '../../spacer';\nimport { inputToDate, buildPadInputStateReducer, validateInputElementTarget, setInConfiguredTimezone, getDaysInMonth } from '../utils';\nimport { TIMEZONELESS_FORMAT } from '../constants';\nimport { TimeInput } from './time-input';\nimport { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nconst VALID_DATE_ORDERS = ['dmy', 'mdy', 'ymd'];\n\n/**\n * TimePicker is a React component that renders a clock for time selection.\n *\n * ```jsx\n * import { TimePicker } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * const MyTimePicker = () => {\n * const [ time, setTime ] = useState( new Date() );\n *\n * return (\n * <TimePicker\n * currentTime={ date }\n * onChange={ ( newTime ) => setTime( newTime ) }\n * is12Hour\n * />\n * );\n * };\n * ```\n */\nexport function TimePicker({\n is12Hour,\n currentTime,\n onChange,\n dateOrder: dateOrderProp,\n hideLabelFromVision = false\n}) {\n const [date, setDate] = useState(() =>\n // Truncate the date at the minutes, see: #15495.\n startOfMinute(inputToDate(currentTime ?? new Date())));\n\n // Reset the state when currentTime changed.\n // TODO: useEffect() shouldn't be used like this, causes an unnecessary render\n useEffect(() => {\n setDate(startOfMinute(inputToDate(currentTime ?? new Date())));\n }, [currentTime]);\n const monthOptions = [{\n value: '01',\n label: __('January')\n }, {\n value: '02',\n label: __('February')\n }, {\n value: '03',\n label: __('March')\n }, {\n value: '04',\n label: __('April')\n }, {\n value: '05',\n label: __('May')\n }, {\n value: '06',\n label: __('June')\n }, {\n value: '07',\n label: __('July')\n }, {\n value: '08',\n label: __('August')\n }, {\n value: '09',\n label: __('September')\n }, {\n value: '10',\n label: __('October')\n }, {\n value: '11',\n label: __('November')\n }, {\n value: '12',\n label: __('December')\n }];\n const {\n day,\n month,\n year,\n minutes,\n hours\n } = useMemo(() => ({\n day: formatDate('d', date),\n month: formatDate('m', date),\n year: formatDate('Y', date),\n minutes: formatDate('i', date),\n hours: formatDate('H', date)\n }), [date]);\n const buildNumberControlChangeCallback = method => {\n const callback = (value, {\n event\n }) => {\n if (!validateInputElementTarget(event)) {\n return;\n }\n\n // We can safely assume value is a number if target is valid.\n const numberValue = Number(value);\n\n // Internal date is UTC-normalized, but the field should be updated\n // as if in the configured timezone.\n const newDate = setInConfiguredTimezone(date, {\n [method]: numberValue\n });\n setDate(newDate);\n onChange?.(formatDate(TIMEZONELESS_FORMAT, newDate));\n };\n return callback;\n };\n const onTimeInputChangeCallback = ({\n hours: newHours,\n minutes: newMinutes\n }) => {\n // Internal date is UTC-normalized, but the field should be updated\n // as if in the configured timezone.\n const newDate = setInConfiguredTimezone(date, {\n hours: newHours,\n minutes: newMinutes\n });\n setDate(newDate);\n onChange?.(formatDate(TIMEZONELESS_FORMAT, newDate));\n };\n const dayField = /*#__PURE__*/_jsx(DayInput, {\n className: \"components-datetime__time-field components-datetime__time-field-day\" // Unused, for backwards compatibility.\n ,\n label: __('Day'),\n hideLabelFromVision: true,\n __next40pxDefaultSize: true,\n value: day,\n step: 1,\n min: 1,\n max: getDaysInMonth(Number(year), Number(month) - 1),\n required: true,\n spinControls: \"none\",\n isPressEnterToChange: true,\n isDragEnabled: false,\n isShiftStepEnabled: false,\n onChange: buildNumberControlChangeCallback('date')\n }, \"day\");\n const monthField = /*#__PURE__*/_jsx(MonthSelectWrapper, {\n children: /*#__PURE__*/_jsx(SelectControl, {\n className: \"components-datetime__time-field components-datetime__time-field-month\" // Unused, for backwards compatibility.\n ,\n label: __('Month'),\n hideLabelFromVision: true,\n __next40pxDefaultSize: true,\n value: month,\n options: monthOptions,\n onChange: value => {\n // Internal date is UTC-normalized, but the field should be updated\n // as if in the configured timezone.\n const newDate = setInConfiguredTimezone(date, {\n month: Number(value) - 1\n });\n setDate(newDate);\n onChange?.(formatDate(TIMEZONELESS_FORMAT, newDate));\n }\n })\n }, \"month\");\n const yearField = /*#__PURE__*/_jsx(YearInput, {\n className: \"components-datetime__time-field components-datetime__time-field-year\" // Unused, for backwards compatibility.\n ,\n label: __('Year'),\n hideLabelFromVision: true,\n __next40pxDefaultSize: true,\n value: year,\n step: 1,\n min: 1,\n max: 9999,\n required: true,\n spinControls: \"none\",\n isPressEnterToChange: true,\n isDragEnabled: false,\n isShiftStepEnabled: false,\n onChange: buildNumberControlChangeCallback('year'),\n __unstableStateReducer: buildPadInputStateReducer(4)\n }, \"year\");\n const defaultDateOrder = is12Hour ? 'mdy' : 'dmy';\n const dateOrder = dateOrderProp && VALID_DATE_ORDERS.includes(dateOrderProp) ? dateOrderProp : defaultDateOrder;\n const fields = dateOrder.split('').map(field => {\n switch (field) {\n case 'd':\n return dayField;\n case 'm':\n return monthField;\n case 'y':\n return yearField;\n default:\n return null;\n }\n });\n return /*#__PURE__*/_jsxs(Wrapper, {\n className: \"components-datetime__time\" // Unused, for backwards compatibility.\n ,\n children: [/*#__PURE__*/_jsxs(Fieldset, {\n children: [hideLabelFromVision ? /*#__PURE__*/_jsx(VisuallyHidden, {\n as: \"legend\",\n children: __('Time')\n }) : /*#__PURE__*/_jsx(BaseControl.VisualLabel, {\n as: \"legend\",\n className: \"components-datetime__time-legend\" // Unused, for backwards compatibility.\n ,\n children: __('Time')\n }), /*#__PURE__*/_jsxs(HStack, {\n className: \"components-datetime__time-wrapper\" // Unused, for backwards compatibility.\n ,\n children: [/*#__PURE__*/_jsx(TimeInput, {\n value: {\n hours: Number(hours),\n minutes: Number(minutes)\n },\n is12Hour: is12Hour,\n onChange: onTimeInputChangeCallback\n }), /*#__PURE__*/_jsx(Spacer, {}), /*#__PURE__*/_jsx(TimeZone, {})]\n })]\n }), /*#__PURE__*/_jsxs(Fieldset, {\n children: [hideLabelFromVision ? /*#__PURE__*/_jsx(VisuallyHidden, {\n as: \"legend\",\n children: __('Date')\n }) : /*#__PURE__*/_jsx(BaseControl.VisualLabel, {\n as: \"legend\",\n className: \"components-datetime__time-legend\" // Unused, for backwards compatibility.\n ,\n children: __('Date')\n }), /*#__PURE__*/_jsx(HStack, {\n className: \"components-datetime__time-wrapper\" // Unused, for backwards compatibility.\n ,\n children: fields\n })]\n })]\n });\n}\n\n/**\n * A component to input a time.\n *\n * Values are passed as an object in 24-hour format (`{ hours: number, minutes: number }`).\n *\n * ```jsx\n * import { TimePicker } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * const MyTimeInput = () => {\n * \tconst [ time, setTime ] = useState( { hours: 13, minutes: 30 } );\n *\n * \treturn (\n * \t\t<TimePicker.TimeInput\n * \t\t\tvalue={ time }\n * \t\t\tonChange={ setTime }\n * \t\t\tlabel=\"Time\"\n * \t\t/>\n * \t);\n * };\n * ```\n */\nTimePicker.TimeInput = TimeInput;\nObject.assign(TimePicker.TimeInput, {\n displayName: 'TimePicker.TimeInput'\n});\nexport default TimePicker;"],
5
+ "mappings": ";AAAA,SAAS,qBAAqB;AAC9B,SAAS,UAAU,SAAS,iBAAiB;AAC7C,SAAS,UAAU;AACnB,SAAS,QAAQ,kBAAkB;AACnC,OAAO,iBAAiB;AACxB,SAAS,sBAAsB;AAC/B,OAAO,mBAAmB;AAC1B,OAAO,cAAc;AACrB,SAAS,SAAS,UAAU,oBAAoB,UAAU,iBAAiB;AAC3E,SAAS,cAAc;AACvB,SAAS,cAAc;AACvB,SAAS,aAAa,2BAA2B,4BAA4B,yBAAyB,sBAAsB;AAC5H,SAAS,2BAA2B;AACpC,SAAS,iBAAiB;AAC1B,SAAS,OAAO,MAAM,QAAQ,aAAa;AAC3C,IAAM,oBAAoB,CAAC,OAAO,OAAO,KAAK;AAsBvC,SAAS,WAAW;AAAA,EACzB;AAAA,EACA;AAAA,EACA;AAAA,EACA,WAAW;AAAA,EACX,sBAAsB;AACxB,GAAG;AACD,QAAM,CAAC,MAAM,OAAO,IAAI,SAAS;AAAA;AAAA,IAEjC,cAAc,YAAY,eAAe,oBAAI,KAAK,CAAC,CAAC;AAAA,GAAC;AAIrD,YAAU,MAAM;AACd,YAAQ,cAAc,YAAY,eAAe,oBAAI,KAAK,CAAC,CAAC,CAAC;AAAA,EAC/D,GAAG,CAAC,WAAW,CAAC;AAChB,QAAM,eAAe,CAAC;AAAA,IACpB,OAAO;AAAA,IACP,OAAO,GAAG,SAAS;AAAA,EACrB,GAAG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AAC,GAAgB,sBAAM,UAAU;AAAA,MAC/B,UAAU,CAAC,sBAAmC,qBAAK,gBAAgB;AAAA,QACjE,IAAI;AAAA,QACJ,UAAU,GAAG,MAAM;AAAA,MACrB,CAAC,IAAiB,qBAAK,YAAY,aAAa;AAAA,QAC9C,IAAI;AAAA,QACJ,WAAW;AAAA,QAEX,UAAU,GAAG,MAAM;AAAA,MACrB,CAAC,GAAgB,qBAAK,QAAQ;AAAA,QAC5B,WAAW;AAAA,QAEX,UAAU;AAAA,MACZ,CAAC,CAAC;AAAA,IACJ,CAAC,CAAC;AAAA,EACJ,CAAC;AACH;AAwBA,WAAW,YAAY;AACvB,OAAO,OAAO,WAAW,WAAW;AAAA,EAClC,aAAa;AACf,CAAC;AACD,IAAO,eAAQ;",
6
6
  "names": []
7
7
  }
@@ -38,6 +38,11 @@ function buildPadInputStateReducer(pad) {
38
38
  return nextState;
39
39
  };
40
40
  }
41
+ var getDaysInMonth = (year, month) => (
42
+ // Take advantage of JavaScript's built-in date wrapping logic, where day 0
43
+ // of the next month is interpreted as the last day of the preceding month.
44
+ new Date(year, month + 1, 0).getDate()
45
+ );
41
46
  function setInConfiguredTimezone(date, updates) {
42
47
  const values = {
43
48
  year: Number(formatDate("Y", date)),
@@ -48,6 +53,8 @@ function setInConfiguredTimezone(date, updates) {
48
53
  seconds: Number(formatDate("s", date)),
49
54
  ...updates
50
55
  };
56
+ const daysInMonth = getDaysInMonth(values.year, values.month);
57
+ values.date = Math.min(values.date, daysInMonth);
51
58
  const year = String(values.year).padStart(4, "0");
52
59
  const month = String(values.month + 1).padStart(2, "0");
53
60
  const day = String(values.date).padStart(2, "0");
@@ -68,6 +75,7 @@ export {
68
75
  buildPadInputStateReducer,
69
76
  from12hTo24h,
70
77
  from24hTo12h,
78
+ getDaysInMonth,
71
79
  inputToDate,
72
80
  setInConfiguredTimezone,
73
81
  startOfDayInConfiguredTimezone,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/date-time/utils.ts"],
4
- "sourcesContent": ["/**\n * External dependencies\n */\nimport { UTCDateMini } from '@date-fns/utc';\n\n/**\n * WordPress dependencies\n */\nimport { date as formatDate, getDate } from '@wordpress/date';\n\n/**\n * Internal dependencies\n */\n\nimport { COMMIT, PRESS_DOWN, PRESS_UP } from '../input-control/reducer/actions';\n\n/**\n * Converts a date input to a UTC-normalized date for consistent date\n * manipulation. Timezoneless strings are interpreted using the timezone\n * offset from @wordpress/date settings. Date objects and timestamps\n * represent specific UTC instants.\n *\n * @param input Value to turn into a date.\n */\nexport function inputToDate(input) {\n if (typeof input === 'string') {\n // Note that JavaScript doesn't fully support ISO-8601 time strings, so\n // the behavior of passing these through to the Date constructor is\n // non-deterministic.\n //\n // See: https://tc39.es/ecma262/#sec-date-time-string-format\n const hasTimezone = /Z|[+-]\\d{2}(:?\\d{2})?$/.test(input);\n if (hasTimezone) {\n return new UTCDateMini(new Date(input));\n }\n\n // Strings without timezone indicators are interpreted using configured\n // timezone offset, then converted to UTC for internal storage.\n return new UTCDateMini(getDate(input).getTime());\n }\n\n // Date objects and number timestamps represent specific UTC moments.\n // Convert to milliseconds since epoch for consistent UTC handling.\n const time = input instanceof Date ? input.getTime() : input;\n return new UTCDateMini(time);\n}\n\n/**\n * Returns the start of day (midnight) as a browser-local Date for the calendar\n * day in the configured timezone in @wordpress/date settings. This is necessary\n * because date-fns's startOfDay operates in browser local time, which can cause\n * off-by-one-day bugs when browser and configured timezones differ.\n *\n * For example, if the UTC time is Nov 16, 01:00 UTC and configured timezone\n * is UTC-5, the date is Nov 15. This function returns a browser-local Date\n * at Nov 15, 00:00 (browser local midnight) so it matches calendar days.\n *\n * @param date A Date object normalized to UTC\n * @return A browser-local Date at midnight for the configured timezone date\n */\nexport function startOfDayInConfiguredTimezone(date) {\n // Determine the calendar day in the configured WordPress timezone and\n // return a browser-local Date at midnight for that calendar day.\n const year = Number(formatDate('Y', date));\n const month = Number(formatDate('n', date)) - 1;\n const day = Number(formatDate('j', date));\n return new Date(year, month, day, 0, 0, 0, 0);\n}\n\n/**\n * Converts a 12-hour time to a 24-hour time.\n * @param hours\n * @param isPm\n */\nexport function from12hTo24h(hours, isPm) {\n return isPm ? (hours % 12 + 12) % 24 : hours % 12;\n}\n\n/**\n * Converts a 24-hour time to a 12-hour time.\n * @param hours\n */\nexport function from24hTo12h(hours) {\n return hours % 12 || 12;\n}\n\n/**\n * Creates an InputControl reducer used to pad an input so that it is always a\n * given width. For example, the hours and minutes inputs are padded to 2 so\n * that '4' appears as '04'.\n *\n * @param pad How many digits the value should be.\n */\nexport function buildPadInputStateReducer(pad) {\n return (state, action) => {\n const nextState = {\n ...state\n };\n if (action.type === COMMIT || action.type === PRESS_UP || action.type === PRESS_DOWN) {\n if (nextState.value !== undefined) {\n nextState.value = nextState.value.toString().padStart(pad, '0');\n }\n }\n return nextState;\n };\n}\n\n/**\n * Updates specific date fields in the configured timezone and returns a new\n * UTC date.\n *\n * @param date A Date object\n * @param updates Object with fields to update\n * @return A Date object normalized to UTC with the updated values\n */\nexport function setInConfiguredTimezone(date, updates) {\n const values = {\n year: Number(formatDate('Y', date)),\n month: Number(formatDate('n', date)) - 1,\n date: Number(formatDate('j', date)),\n hours: Number(formatDate('H', date)),\n minutes: Number(formatDate('i', date)),\n seconds: Number(formatDate('s', date)),\n ...updates\n };\n const year = String(values.year).padStart(4, '0');\n const month = String(values.month + 1).padStart(2, '0');\n const day = String(values.date).padStart(2, '0');\n const hours = String(values.hours).padStart(2, '0');\n const minutes = String(values.minutes).padStart(2, '0');\n const seconds = String(values.seconds).padStart(2, '0');\n const timezoneless = `${year}-${month}-${day}T${hours}:${minutes}:${seconds}`;\n\n // Parse as WordPress-configured timezone time and convert to a UTC instant.\n return new UTCDateMini(getDate(timezoneless).getTime());\n}\n\n/**\n * Validates the target of a React event to ensure it is an input element and\n * that the input is valid.\n * @param event\n */\nexport function validateInputElementTarget(event) {\n // `instanceof` checks need to get the instance definition from the\n // corresponding window object \u2014 therefore, the following logic makes\n // the component work correctly even when rendered inside an iframe.\n const HTMLInputElementInstance = event.target?.ownerDocument.defaultView?.HTMLInputElement ?? HTMLInputElement;\n if (!(event.target instanceof HTMLInputElementInstance)) {\n return false;\n }\n return event.target.validity.valid;\n}"],
5
- "mappings": ";AAGA,SAAS,mBAAmB;AAK5B,SAAS,QAAQ,YAAY,eAAe;AAM5C,SAAS,QAAQ,YAAY,gBAAgB;AAUtC,SAAS,YAAY,OAAO;AACjC,MAAI,OAAO,UAAU,UAAU;AAM7B,UAAM,cAAc,yBAAyB,KAAK,KAAK;AACvD,QAAI,aAAa;AACf,aAAO,IAAI,YAAY,IAAI,KAAK,KAAK,CAAC;AAAA,IACxC;AAIA,WAAO,IAAI,YAAY,QAAQ,KAAK,EAAE,QAAQ,CAAC;AAAA,EACjD;AAIA,QAAM,OAAO,iBAAiB,OAAO,MAAM,QAAQ,IAAI;AACvD,SAAO,IAAI,YAAY,IAAI;AAC7B;AAeO,SAAS,+BAA+B,MAAM;AAGnD,QAAM,OAAO,OAAO,WAAW,KAAK,IAAI,CAAC;AACzC,QAAM,QAAQ,OAAO,WAAW,KAAK,IAAI,CAAC,IAAI;AAC9C,QAAM,MAAM,OAAO,WAAW,KAAK,IAAI,CAAC;AACxC,SAAO,IAAI,KAAK,MAAM,OAAO,KAAK,GAAG,GAAG,GAAG,CAAC;AAC9C;AAOO,SAAS,aAAa,OAAO,MAAM;AACxC,SAAO,QAAQ,QAAQ,KAAK,MAAM,KAAK,QAAQ;AACjD;AAMO,SAAS,aAAa,OAAO;AAClC,SAAO,QAAQ,MAAM;AACvB;AASO,SAAS,0BAA0B,KAAK;AAC7C,SAAO,CAAC,OAAO,WAAW;AACxB,UAAM,YAAY;AAAA,MAChB,GAAG;AAAA,IACL;AACA,QAAI,OAAO,SAAS,UAAU,OAAO,SAAS,YAAY,OAAO,SAAS,YAAY;AACpF,UAAI,UAAU,UAAU,QAAW;AACjC,kBAAU,QAAQ,UAAU,MAAM,SAAS,EAAE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ies\n */\nimport { date as formatDate, getDate } from '@wordpress/date';\n\n/**\n * Internal dependencies\n */\n\nimport { COMMIT, PRESS_DOWN, PRESS_UP } from '../input-control/reducer/actions';\n\n/**\n * Converts a date input to a UTC-normalized date for consistent date\n * manipulation. Timezoneless strings are interpreted using the timezone\n * offset from @wordpress/date settings. Date objects and timestamps\n * represent specific UTC instants.\n *\n * @param input Value to turn into a date.\n */\nexport function inputToDate(input) {\n if (typeof input === 'string') {\n // Note that JavaScript doesn't fully support ISO-8601 time strings, so\n // the behavior of passing these through to the Date constructor is\n // non-deterministic.\n //\n // See: https://tc39.es/ecma262/#sec-date-time-string-format\n const hasTimezone = /Z|[+-]\\d{2}(:?\\d{2})?$/.test(input);\n if (hasTimezone) {\n return new UTCDateMini(new Date(input));\n }\n\n // Strings without timezone indicators are interpreted using configured\n // timezone offset, then converted to UTC for internal storage.\n return new UTCDateMini(getDate(input).getTime());\n }\n\n // Date objects and number timestamps represent specific UTC moments.\n // Convert to milliseconds since epoch for consistent UTC handling.\n const time = input instanceof Date ? input.getTime() : input;\n return new UTCDateMini(time);\n}\n\n/**\n * Returns the start of day (midnight) as a browser-local Date for the calendar\n * day in the configured timezone in @wordpress/date settings. This is necessary\n * because date-fns's startOfDay operates in browser local time, which can cause\n * off-by-one-day bugs when browser and configured timezones differ.\n *\n * For example, if the UTC time is Nov 16, 01:00 UTC and configured timezone\n * is UTC-5, the date is Nov 15. This function returns a browser-local Date\n * at Nov 15, 00:00 (browser local midnight) so it matches calendar days.\n *\n * @param date A Date object normalized to UTC\n * @return A browser-local Date at midnight for the configured timezone date\n */\nexport function startOfDayInConfiguredTimezone(date) {\n // Determine the calendar day in the configured WordPress timezone and\n // return a browser-local Date at midnight for that calendar day.\n const year = Number(formatDate('Y', date));\n const month = Number(formatDate('n', date)) - 1;\n const day = Number(formatDate('j', date));\n return new Date(year, month, day, 0, 0, 0, 0);\n}\n\n/**\n * Converts a 12-hour time to a 24-hour time.\n * @param hours\n * @param isPm\n */\nexport function from12hTo24h(hours, isPm) {\n return isPm ? (hours % 12 + 12) % 24 : hours % 12;\n}\n\n/**\n * Converts a 24-hour time to a 12-hour time.\n * @param hours\n */\nexport function from24hTo12h(hours) {\n return hours % 12 || 12;\n}\n\n/**\n * Creates an InputControl reducer used to pad an input so that it is always a\n * given width. For example, the hours and minutes inputs are padded to 2 so\n * that '4' appears as '04'.\n *\n * @param pad How many digits the value should be.\n */\nexport function buildPadInputStateReducer(pad) {\n return (state, action) => {\n const nextState = {\n ...state\n };\n if (action.type === COMMIT || action.type === PRESS_UP || action.type === PRESS_DOWN) {\n if (nextState.value !== undefined) {\n nextState.value = nextState.value.toString().padStart(pad, '0');\n }\n }\n return nextState;\n };\n}\n\n/**\n * Returns the number of days in a month.\n *\n * @param year The year\n * @param month The month, zero-indexed (0-11)\n *\n * @return The number of days in the month\n */\nexport const getDaysInMonth = (year, month) =>\n// Take advantage of JavaScript's built-in date wrapping logic, where day 0\n// of the next month is interpreted as the last day of the preceding month.\nnew Date(year, month + 1, 0).getDate();\n\n/**\n * Updates specific date fields in the configured timezone and returns a new\n * UTC date.\n *\n * @param date A Date object\n * @param updates Object with fields to update\n * @return A Date object normalized to UTC with the updated values\n */\nexport function setInConfiguredTimezone(date, updates) {\n const values = {\n year: Number(formatDate('Y', date)),\n month: Number(formatDate('n', date)) - 1,\n date: Number(formatDate('j', date)),\n hours: Number(formatDate('H', date)),\n minutes: Number(formatDate('i', date)),\n seconds: Number(formatDate('s', date)),\n ...updates\n };\n\n // Clamp the day to the last valid day of the month, to avoid producing\n // invalid date strings (e.g. \"2026-02-31\").\n const daysInMonth = getDaysInMonth(values.year, values.month);\n values.date = Math.min(values.date, daysInMonth);\n const year = String(values.year).padStart(4, '0');\n const month = String(values.month + 1).padStart(2, '0');\n const day = String(values.date).padStart(2, '0');\n const hours = String(values.hours).padStart(2, '0');\n const minutes = String(values.minutes).padStart(2, '0');\n const seconds = String(values.seconds).padStart(2, '0');\n const timezoneless = `${year}-${month}-${day}T${hours}:${minutes}:${seconds}`;\n\n // Parse as WordPress-configured timezone time and convert to a UTC instant.\n return new UTCDateMini(getDate(timezoneless).getTime());\n}\n\n/**\n * Validates the target of a React event to ensure it is an input element and\n * that the input is valid.\n * @param event\n */\nexport function validateInputElementTarget(event) {\n // `instanceof` checks need to get the instance definition from the\n // corresponding window object \u2014 therefore, the following logic makes\n // the component work correctly even when rendered inside an iframe.\n const HTMLInputElementInstance = event.target?.ownerDocument.defaultView?.HTMLInputElement ?? HTMLInputElement;\n if (!(event.target instanceof HTMLInputElementInstance)) {\n return false;\n }\n return event.target.validity.valid;\n}"],
5
+ "mappings": ";AAGA,SAAS,mBAAmB;AAK5B,SAAS,QAAQ,YAAY,eAAe;AAM5C,SAAS,QAAQ,YAAY,gBAAgB;AAUtC,SAAS,YAAY,OAAO;AACjC,MAAI,OAAO,UAAU,UAAU;AAM7B,UAAM,cAAc,yBAAyB,KAAK,KAAK;AACvD,QAAI,aAAa;AACf,aAAO,IAAI,YAAY,IAAI,KAAK,KAAK,CAAC;AAAA,IACxC;AAIA,WAAO,IAAI,YAAY,QAAQ,KAAK,EAAE,QAAQ,CAAC;AAAA,EACjD;AAIA,QAAM,OAAO,iBAAiB,OAAO,MAAM,QAAQ,IAAI;AACvD,SAAO,IAAI,YAAY,IAAI;AAC7B;AAeO,SAAS,+BAA+B,MAAM;AAGnD,QAAM,OAAO,OAAO,WAAW,KAAK,IAAI,CAAC;AACzC,QAAM,QAAQ,OAAO,WAAW,KAAK,IAAI,CAAC,IAAI;AAC9C,QAAM,MAAM,OAAO,WAAW,KAAK,IAAI,CAAC;AACxC,SAAO,IAAI,KAAK,MAAM,OAAO,KAAK,GAAG,GAAG,GAAG,CAAC;AAC9C;AAOO,SAAS,aAAa,OAAO,MAAM;AACxC,SAAO,QAAQ,QAAQ,KAAK,MAAM,KAAK,QAAQ;AACjD;AAMO,SAAS,aAAa,OAAO;AAClC,SAAO,QAAQ,MAAM;AACvB;AASO,SAAS,0BAA0B,KAAK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,GAAG,GAAG;AACtD,QAAM,eAAe,GAAG,IAAI,IAAI,KAAK,IAAI,GAAG,IAAI,KAAK,IAAI,OAAO,IAAI,OAAO;AAG3E,SAAO,IAAI,YAAY,QAAQ,YAAY,EAAE,QAAQ,CAAC;AACxD;AAOO,SAAS,2BAA2B,OAAO;AAIhD,QAAM,2BAA2B,MAAM,QAAQ,cAAc,aAAa,oBAAoB;AAC9F,MAAI,EAAE,MAAM,kBAAkB,2BAA2B;AACvD,WAAO;AAAA,EACT;AACA,SAAO,MAAM,OAAO,SAAS;AAC/B;",
6
6
  "names": []
7
7
  }
@@ -35,7 +35,7 @@ var UnconnectedDropdown = (props, forwardedRef) => {
35
35
  });
36
36
  }
37
37
  const [fallbackPopoverAnchor, setFallbackPopoverAnchor] = useState(null);
38
- const containerRef = useRef();
38
+ const containerRef = useRef(null);
39
39
  const [isOpen, setIsOpen] = useControlledValue({
40
40
  defaultValue: defaultOpen,
41
41
  value: open,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/dropdown/index.tsx"],
4
- "sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n/**\n * WordPress dependencies\n */\nimport { useRef, useState } from '@wordpress/element';\nimport { useMergeRefs } from '@wordpress/compose';\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport { contextConnect, useContextSystem } from '../context';\nimport { useControlledValue } from '../utils/hooks';\nimport Popover from '../popover';\nimport { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nconst UnconnectedDropdown = (props, forwardedRef) => {\n const {\n renderContent,\n renderToggle,\n className,\n contentClassName,\n expandOnMobile,\n headerTitle,\n focusOnMount,\n popoverProps,\n onClose,\n onToggle,\n style,\n open,\n defaultOpen,\n // Deprecated props\n position,\n // From context system\n variant\n } = useContextSystem(props, 'Dropdown');\n if (position !== undefined) {\n deprecated('`position` prop in wp.components.Dropdown', {\n since: '6.2',\n alternative: '`popoverProps.placement` prop',\n hint: 'Note that the `position` prop will override any values passed through the `popoverProps.placement` prop.'\n });\n }\n\n // Use internal state instead of a ref to make sure that the component\n // re-renders when the popover's anchor updates.\n const [fallbackPopoverAnchor, setFallbackPopoverAnchor] = useState(null);\n const containerRef = useRef();\n const [isOpen, setIsOpen] = useControlledValue({\n defaultValue: defaultOpen,\n value: open,\n onChange: onToggle\n });\n\n /**\n * Closes the popover when focus leaves it unless the toggle was pressed or\n * focus has moved to a separate dialog. The former is to let the toggle\n * handle closing the popover and the latter is to preserve presence in\n * case a dialog has opened, allowing focus to return when it's dismissed.\n */\n function closeIfFocusOutside() {\n if (!containerRef.current) {\n return;\n }\n const {\n ownerDocument\n } = containerRef.current;\n const dialog = ownerDocument?.activeElement?.closest('[role=\"dialog\"]');\n if (!containerRef.current.contains(ownerDocument.activeElement) && (!dialog || dialog.contains(containerRef.current))) {\n close();\n }\n }\n function close() {\n onClose?.();\n setIsOpen(false);\n }\n const args = {\n isOpen: !!isOpen,\n onToggle: () => setIsOpen(!isOpen),\n onClose: close\n };\n const popoverPropsHaveAnchor = !!popoverProps?.anchor ||\n // Note: `anchorRef`, `getAnchorRect` and `anchorRect` are deprecated and\n // be removed from `Popover` from WordPress 6.3\n !!popoverProps?.anchorRef || !!popoverProps?.getAnchorRect || !!popoverProps?.anchorRect;\n return /*#__PURE__*/_jsxs(\"div\", {\n className: className,\n ref: useMergeRefs([containerRef, forwardedRef, setFallbackPopoverAnchor])\n // Some UAs focus the closest focusable parent when the toggle is\n // clicked. Making this div focusable ensures such UAs will focus\n // it and `closeIfFocusOutside` can tell if the toggle was clicked.\n ,\n tabIndex: -1,\n style: style,\n children: [renderToggle(args), isOpen && /*#__PURE__*/_jsx(Popover, {\n position: position,\n onClose: close,\n onFocusOutside: closeIfFocusOutside,\n expandOnMobile: expandOnMobile,\n headerTitle: headerTitle,\n focusOnMount: focusOnMount\n // This value is used to ensure that the dropdowns\n // align with the editor header by default.\n ,\n offset: 13,\n anchor: !popoverPropsHaveAnchor ? fallbackPopoverAnchor : undefined,\n variant: variant,\n ...popoverProps,\n className: clsx('components-dropdown__content', popoverProps?.className, contentClassName),\n children: renderContent(args)\n })]\n });\n};\n\n/**\n * Renders a button that opens a floating content modal when clicked.\n *\n * ```jsx\n * import { Button, Dropdown } from '@wordpress/components';\n *\n * const MyDropdown = () => (\n * <Dropdown\n * className=\"my-container-class-name\"\n * contentClassName=\"my-dropdown-content-classname\"\n * popoverProps={ { placement: 'bottom-start' } }\n * renderToggle={ ( { isOpen, onToggle } ) => (\n * <Button\n * variant=\"primary\"\n * onClick={ onToggle }\n * aria-expanded={ isOpen }\n * >\n * Toggle Dropdown!\n * </Button>\n * ) }\n * renderContent={ () => <div>This is the content of the dropdown.</div> }\n * />\n * );\n * ```\n */\nexport const Dropdown = contextConnect(UnconnectedDropdown, 'Dropdown');\nexport default Dropdown;"],
5
- "mappings": ";AAGA,OAAO,UAAU;AAIjB,SAAS,QAAQ,gBAAgB;AACjC,SAAS,oBAAoB;AAC7B,OAAO,gBAAgB;AAKvB,SAAS,gBAAgB,wBAAwB;AACjD,SAAS,0BAA0B;AACnC,OAAO,aAAa;AACpB,SAAS,OAAO,MAAM,QAAQ,aAAa;AAC3C,IAAM,sBAAsB,CAAC,OAAO,iBAAiB;AACnD,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAAA,IAEA;AAAA;AAAA,IAEA;AAAA,EACF,IAAI,iBAAiB,OAAO,UAAU;AACtC,MAAI,aAAa,QAAW;AAC1B,eAAW,6CAA6C;AAAA,MACtD,OAAO;AAAA,MACP,aAAa;AAAA,MACb,MAAM;AAAA,IACR,CAAC;AAAA,EACH;AAIA,QAAM,CAAC,uBAAuB,wBAAwB,IAAI,SAAS,IAAI;AACvE,QAAM,eAAe,OAAO;AAC5B,QAAM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IAAO,mBAAQ;",
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n/**\n * WordPress dependencies\n */\nimport { useRef, useState } from '@wordpress/element';\nimport { useMergeRefs } from '@wordpress/compose';\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport { contextConnect, useContextSystem } from '../context';\nimport { useControlledValue } from '../utils/hooks';\nimport Popover from '../popover';\nimport { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nconst UnconnectedDropdown = (props, forwardedRef) => {\n const {\n renderContent,\n renderToggle,\n className,\n contentClassName,\n expandOnMobile,\n headerTitle,\n focusOnMount,\n popoverProps,\n onClose,\n onToggle,\n style,\n open,\n defaultOpen,\n // Deprecated props\n position,\n // From context system\n variant\n } = useContextSystem(props, 'Dropdown');\n if (position !== undefined) {\n deprecated('`position` prop in wp.components.Dropdown', {\n since: '6.2',\n alternative: '`popoverProps.placement` prop',\n hint: 'Note that the `position` prop will override any values passed through the `popoverProps.placement` prop.'\n });\n }\n\n // Use internal state instead of a ref to make sure that the component\n // re-renders when the popover's anchor updates.\n const [fallbackPopoverAnchor, setFallbackPopoverAnchor] = useState(null);\n const containerRef = useRef(null);\n const [isOpen, setIsOpen] = useControlledValue({\n defaultValue: defaultOpen,\n value: open,\n onChange: onToggle\n });\n\n /**\n * Closes the popover when focus leaves it unless the toggle was pressed or\n * focus has moved to a separate dialog. The former is to let the toggle\n * handle closing the popover and the latter is to preserve presence in\n * case a dialog has opened, allowing focus to return when it's dismissed.\n */\n function closeIfFocusOutside() {\n if (!containerRef.current) {\n return;\n }\n const {\n ownerDocument\n } = containerRef.current;\n const dialog = ownerDocument?.activeElement?.closest('[role=\"dialog\"]');\n if (!containerRef.current.contains(ownerDocument.activeElement) && (!dialog || dialog.contains(containerRef.current))) {\n close();\n }\n }\n function close() {\n onClose?.();\n setIsOpen(false);\n }\n const args = {\n isOpen: !!isOpen,\n onToggle: () => setIsOpen(!isOpen),\n onClose: close\n };\n const popoverPropsHaveAnchor = !!popoverProps?.anchor ||\n // Note: `anchorRef`, `getAnchorRect` and `anchorRect` are deprecated and\n // be removed from `Popover` from WordPress 6.3\n !!popoverProps?.anchorRef || !!popoverProps?.getAnchorRect || !!popoverProps?.anchorRect;\n return /*#__PURE__*/_jsxs(\"div\", {\n className: className,\n ref: useMergeRefs([containerRef, forwardedRef, setFallbackPopoverAnchor])\n // Some UAs focus the closest focusable parent when the toggle is\n // clicked. Making this div focusable ensures such UAs will focus\n // it and `closeIfFocusOutside` can tell if the toggle was clicked.\n ,\n tabIndex: -1,\n style: style,\n children: [renderToggle(args), isOpen && /*#__PURE__*/_jsx(Popover, {\n position: position,\n onClose: close,\n onFocusOutside: closeIfFocusOutside,\n expandOnMobile: expandOnMobile,\n headerTitle: headerTitle,\n focusOnMount: focusOnMount\n // This value is used to ensure that the dropdowns\n // align with the editor header by default.\n ,\n offset: 13,\n anchor: !popoverPropsHaveAnchor ? fallbackPopoverAnchor : undefined,\n variant: variant,\n ...popoverProps,\n className: clsx('components-dropdown__content', popoverProps?.className, contentClassName),\n children: renderContent(args)\n })]\n });\n};\n\n/**\n * Renders a button that opens a floating content modal when clicked.\n *\n * ```jsx\n * import { Button, Dropdown } from '@wordpress/components';\n *\n * const MyDropdown = () => (\n * <Dropdown\n * className=\"my-container-class-name\"\n * contentClassName=\"my-dropdown-content-classname\"\n * popoverProps={ { placement: 'bottom-start' } }\n * renderToggle={ ( { isOpen, onToggle } ) => (\n * <Button\n * variant=\"primary\"\n * onClick={ onToggle }\n * aria-expanded={ isOpen }\n * >\n * Toggle Dropdown!\n * </Button>\n * ) }\n * renderContent={ () => <div>This is the content of the dropdown.</div> }\n * />\n * );\n * ```\n */\nexport const Dropdown = contextConnect(UnconnectedDropdown, 'Dropdown');\nexport default Dropdown;"],
5
+ "mappings": ";AAGA,OAAO,UAAU;AAIjB,SAAS,QAAQ,gBAAgB;AACjC,SAAS,oBAAoB;AAC7B,OAAO,gBAAgB;AAKvB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c,aAAa,CAAC,CAAC,cAAc,iBAAiB,CAAC,CAAC,cAAc;AAC9E,SAAoB,sBAAM,OAAO;AAAA,IAC/B;AAAA,IACA,KAAK,aAAa,CAAC,cAAc,cAAc,wBAAwB,CAAC;AAAA,IAKxE,UAAU;AAAA,IACV;AAAA,IACA,UAAU,CAAC,aAAa,IAAI,GAAG,UAAuB,qBAAK,SAAS;AAAA,MAClE;AAAA,MACA,SAAS;AAAA,MACT,gBAAgB;AAAA,MAChB;AAAA,MACA;AAAA,MACA;AAAA,MAIA,QAAQ;AAAA,MACR,QAAQ,CAAC,yBAAyB,wBAAwB;AAAA,MAC1D;AAAA,MACA,GAAG;AAAA,MACH,WAAW,KAAK,gCAAgC,cAAc,WAAW,gBAAgB;AAAA,MACzF,UAAU,cAAc,IAAI;AAAA,IAC9B,CAAC,CAAC;AAAA,EACJ,CAAC;AACH;AA2BO,IAAM,WAAW,eAAe,qBAAqB,UAAU;AACtE,IAAO,mBAAQ;",
6
6
  "names": []
7
7
  }
@@ -36,7 +36,11 @@ function UnforwardedExternalLink(props, ref) {
36
36
  className: "components-external-link__contents",
37
37
  children
38
38
  }), /* @__PURE__ */ _jsx("span", {
39
- className: "components-external-link__icon",
39
+ className: clsx(
40
+ "components-external-link__icon",
41
+ // This class prevents the arrow from being replaced by a Twemoji image.
42
+ "wp-exclude-emoji"
43
+ ),
40
44
  "aria-label": (
41
45
  /* translators: accessibility text */
42
46
  __("(opens in a new tab)")