@wordpress/components 19.8.4 → 19.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (630) hide show
  1. package/CHANGELOG.md +60 -0
  2. package/CONTRIBUTING.md +80 -7
  3. package/build/alignment-matrix-control/styles/alignment-matrix-control-styles.js +11 -11
  4. package/build/alignment-matrix-control/styles/alignment-matrix-control-styles.js.map +1 -1
  5. package/build/border-box-control/border-box-control/component.js +22 -7
  6. package/build/border-box-control/border-box-control/component.js.map +1 -1
  7. package/build/border-box-control/border-box-control-linked-button/hook.js +3 -2
  8. package/build/border-box-control/border-box-control-linked-button/hook.js.map +1 -1
  9. package/build/border-box-control/border-box-control-split-controls/component.js +21 -8
  10. package/build/border-box-control/border-box-control-split-controls/component.js.map +1 -1
  11. package/build/border-box-control/border-box-control-visualizer/hook.js +3 -2
  12. package/build/border-box-control/border-box-control-visualizer/hook.js.map +1 -1
  13. package/build/border-box-control/styles.js +11 -15
  14. package/build/border-box-control/styles.js.map +1 -1
  15. package/build/border-control/border-control/component.js +5 -3
  16. package/build/border-control/border-control/component.js.map +1 -1
  17. package/build/border-control/border-control/hook.js +6 -3
  18. package/build/border-control/border-control/hook.js.map +1 -1
  19. package/build/border-control/border-control-dropdown/component.js +6 -2
  20. package/build/border-control/border-control-dropdown/component.js.map +1 -1
  21. package/build/border-control/border-control-dropdown/hook.js +5 -5
  22. package/build/border-control/border-control-dropdown/hook.js.map +1 -1
  23. package/build/border-control/styles.js +58 -29
  24. package/build/border-control/styles.js.map +1 -1
  25. package/build/box-control/index.js +0 -21
  26. package/build/box-control/index.js.map +1 -1
  27. package/build/box-control/utils.js +1 -8
  28. package/build/box-control/utils.js.map +1 -1
  29. package/build/button/index.js +3 -5
  30. package/build/button/index.js.map +1 -1
  31. package/build/button/index.native.js +16 -2
  32. package/build/button/index.native.js.map +1 -1
  33. package/build/button-group/index.js +24 -7
  34. package/build/button-group/index.js.map +1 -1
  35. package/build/{flyout → button-group}/types.js +0 -0
  36. package/build/button-group/types.js.map +1 -0
  37. package/build/checkbox-control/index.js +34 -7
  38. package/build/checkbox-control/index.js.map +1 -1
  39. package/build/checkbox-control/types.js +6 -0
  40. package/build/checkbox-control/types.js.map +1 -0
  41. package/build/circular-option-picker/index.js +1 -2
  42. package/build/circular-option-picker/index.js.map +1 -1
  43. package/build/color-palette/index.js +5 -12
  44. package/build/color-palette/index.js.map +1 -1
  45. package/build/date-time/date.js +43 -19
  46. package/build/date-time/date.js.map +1 -1
  47. package/build/date-time/index.js +28 -3
  48. package/build/date-time/index.js.map +1 -1
  49. package/build/date-time/time.js +42 -40
  50. package/build/date-time/time.js.map +1 -1
  51. package/build/date-time/timezone.js +4 -3
  52. package/build/date-time/timezone.js.map +1 -1
  53. package/build/date-time/types.js +6 -0
  54. package/build/date-time/types.js.map +1 -0
  55. package/build/date-time/utils.js +6 -4
  56. package/build/date-time/utils.js.map +1 -1
  57. package/build/disabled/index.js +4 -76
  58. package/build/disabled/index.js.map +1 -1
  59. package/build/draggable/index.native.js +223 -0
  60. package/build/draggable/index.native.js.map +1 -0
  61. package/build/dropdown/index.js +7 -5
  62. package/build/dropdown/index.js.map +1 -1
  63. package/build/focal-point-picker/index.native.js +3 -3
  64. package/build/focal-point-picker/index.native.js.map +1 -1
  65. package/build/heading/hook.js +1 -1
  66. package/build/heading/hook.js.map +1 -1
  67. package/build/index.js +0 -8
  68. package/build/index.js.map +1 -1
  69. package/build/index.native.js +16 -0
  70. package/build/index.native.js.map +1 -1
  71. package/build/input-control/index.js +27 -4
  72. package/build/input-control/index.js.map +1 -1
  73. package/build/input-control/styles/input-control-styles.js +42 -30
  74. package/build/input-control/styles/input-control-styles.js.map +1 -1
  75. package/build/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js +1 -1
  76. package/build/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js.map +1 -1
  77. package/build/mobile/bottom-sheet/index.native.js +1 -1
  78. package/build/mobile/bottom-sheet/index.native.js.map +1 -1
  79. package/build/mobile/bottom-sheet-select-control/index.native.js +4 -2
  80. package/build/mobile/bottom-sheet-select-control/index.native.js.map +1 -1
  81. package/build/mobile/html-text-input/index.native.js +19 -8
  82. package/build/mobile/html-text-input/index.native.js.map +1 -1
  83. package/build/mobile/keyboard-aware-flat-list/index.android.js +28 -5
  84. package/build/mobile/keyboard-aware-flat-list/index.android.js.map +1 -1
  85. package/build/mobile/keyboard-aware-flat-list/index.ios.js +47 -24
  86. package/build/mobile/keyboard-aware-flat-list/index.ios.js.map +1 -1
  87. package/build/navigation/styles/navigation-styles.js +12 -12
  88. package/build/navigation/styles/navigation-styles.js.map +1 -1
  89. package/build/notice/index.native.js +44 -40
  90. package/build/notice/index.native.js.map +1 -1
  91. package/build/notice/list.native.js +27 -45
  92. package/build/notice/list.native.js.map +1 -1
  93. package/build/palette-edit/index.js +38 -7
  94. package/build/palette-edit/index.js.map +1 -1
  95. package/build/popover/index.js +223 -323
  96. package/build/popover/index.js.map +1 -1
  97. package/build/resizable-box/resize-tooltip/utils.js +5 -8
  98. package/build/resizable-box/resize-tooltip/utils.js.map +1 -1
  99. package/build/sandbox/index.js +2 -2
  100. package/build/sandbox/index.js.map +1 -1
  101. package/build/sandbox/index.native.js +1 -1
  102. package/build/sandbox/index.native.js.map +1 -1
  103. package/build/select-control/index.js +31 -4
  104. package/build/select-control/index.js.map +1 -1
  105. package/build/select-control/styles/select-control-styles.js +17 -14
  106. package/build/select-control/styles/select-control-styles.js.map +1 -1
  107. package/build/surface/styles.js +8 -8
  108. package/build/surface/styles.js.map +1 -1
  109. package/build/text/hook.js +5 -5
  110. package/build/text/hook.js.map +1 -1
  111. package/build/text/styles/text-mixins.native.js +1 -1
  112. package/build/text/styles/text-mixins.native.js.map +1 -1
  113. package/build/text/styles.js +7 -7
  114. package/build/text/styles.js.map +1 -1
  115. package/build/text-control/index.js +35 -28
  116. package/build/text-control/index.js.map +1 -1
  117. package/build/text-control/types.js +6 -0
  118. package/build/text-control/types.js.map +1 -0
  119. package/build/toggle-group-control/toggle-group-control/component.js +1 -3
  120. package/build/toggle-group-control/toggle-group-control/component.js.map +1 -1
  121. package/build/toggle-group-control/toggle-group-control-option-icon/component.js +6 -4
  122. package/build/toggle-group-control/toggle-group-control-option-icon/component.js.map +1 -1
  123. package/build/tools-panel/tools-panel-header/component.js +52 -36
  124. package/build/tools-panel/tools-panel-header/component.js.map +1 -1
  125. package/build/tooltip/index.js +2 -2
  126. package/build/tooltip/index.js.map +1 -1
  127. package/build/ui/spinner/component.js +1 -1
  128. package/build/ui/spinner/component.js.map +1 -1
  129. package/build/unit-control/index.js +3 -3
  130. package/build/unit-control/index.js.map +1 -1
  131. package/build/unit-control/styles/unit-control-styles.js +11 -20
  132. package/build/unit-control/styles/unit-control-styles.js.map +1 -1
  133. package/build/unit-control/utils.js.map +1 -1
  134. package/build/utils/colors-values.js +9 -24
  135. package/build/utils/colors-values.js.map +1 -1
  136. package/build-module/alignment-matrix-control/styles/alignment-matrix-control-styles.js +11 -11
  137. package/build-module/alignment-matrix-control/styles/alignment-matrix-control-styles.js.map +1 -1
  138. package/build-module/border-box-control/border-box-control/component.js +22 -7
  139. package/build-module/border-box-control/border-box-control/component.js.map +1 -1
  140. package/build-module/border-box-control/border-box-control-linked-button/hook.js +3 -2
  141. package/build-module/border-box-control/border-box-control-linked-button/hook.js.map +1 -1
  142. package/build-module/border-box-control/border-box-control-split-controls/component.js +21 -8
  143. package/build-module/border-box-control/border-box-control-split-controls/component.js.map +1 -1
  144. package/build-module/border-box-control/border-box-control-visualizer/hook.js +3 -2
  145. package/build-module/border-box-control/border-box-control-visualizer/hook.js.map +1 -1
  146. package/build-module/border-box-control/styles.js +9 -15
  147. package/build-module/border-box-control/styles.js.map +1 -1
  148. package/build-module/border-control/border-control/component.js +5 -3
  149. package/build-module/border-control/border-control/component.js.map +1 -1
  150. package/build-module/border-control/border-control/hook.js +6 -3
  151. package/build-module/border-control/border-control/hook.js.map +1 -1
  152. package/build-module/border-control/border-control-dropdown/component.js +6 -2
  153. package/build-module/border-control/border-control-dropdown/component.js.map +1 -1
  154. package/build-module/border-control/border-control-dropdown/hook.js +5 -5
  155. package/build-module/border-control/border-control-dropdown/hook.js.map +1 -1
  156. package/build-module/border-control/styles.js +56 -29
  157. package/build-module/border-control/styles.js.map +1 -1
  158. package/build-module/box-control/index.js +1 -20
  159. package/build-module/box-control/index.js.map +1 -1
  160. package/build-module/box-control/utils.js +0 -6
  161. package/build-module/box-control/utils.js.map +1 -1
  162. package/build-module/button/index.js +3 -4
  163. package/build-module/button/index.js.map +1 -1
  164. package/build-module/button/index.native.js +16 -3
  165. package/build-module/button/index.native.js.map +1 -1
  166. package/build-module/button-group/index.js +27 -7
  167. package/build-module/button-group/index.js.map +1 -1
  168. package/build-module/{flyout → button-group}/types.js +0 -0
  169. package/build-module/{flyout → button-group}/types.js.map +0 -0
  170. package/build-module/checkbox-control/index.js +31 -7
  171. package/build-module/checkbox-control/index.js.map +1 -1
  172. package/build-module/checkbox-control/types.js +2 -0
  173. package/{build/flyout → build-module/checkbox-control}/types.js.map +0 -0
  174. package/build-module/circular-option-picker/index.js +1 -2
  175. package/build-module/circular-option-picker/index.js.map +1 -1
  176. package/build-module/color-palette/index.js +5 -11
  177. package/build-module/color-palette/index.js.map +1 -1
  178. package/build-module/date-time/date.js +44 -19
  179. package/build-module/date-time/date.js.map +1 -1
  180. package/build-module/date-time/index.js +28 -4
  181. package/build-module/date-time/index.js.map +1 -1
  182. package/build-module/date-time/time.js +43 -41
  183. package/build-module/date-time/time.js.map +1 -1
  184. package/build-module/date-time/timezone.js +4 -3
  185. package/build-module/date-time/timezone.js.map +1 -1
  186. package/build-module/date-time/types.js +2 -0
  187. package/build-module/date-time/types.js.map +1 -0
  188. package/build-module/date-time/utils.js +6 -4
  189. package/build-module/date-time/utils.js.map +1 -1
  190. package/build-module/disabled/index.js +5 -76
  191. package/build-module/disabled/index.js.map +1 -1
  192. package/build-module/draggable/index.native.js +206 -0
  193. package/build-module/draggable/index.native.js.map +1 -0
  194. package/build-module/dropdown/index.js +7 -5
  195. package/build-module/dropdown/index.js.map +1 -1
  196. package/build-module/focal-point-picker/index.native.js +3 -3
  197. package/build-module/focal-point-picker/index.native.js.map +1 -1
  198. package/build-module/heading/hook.js +1 -1
  199. package/build-module/heading/hook.js.map +1 -1
  200. package/build-module/index.js +0 -1
  201. package/build-module/index.js.map +1 -1
  202. package/build-module/index.native.js +2 -1
  203. package/build-module/index.native.js.map +1 -1
  204. package/build-module/input-control/index.js +24 -3
  205. package/build-module/input-control/index.js.map +1 -1
  206. package/build-module/input-control/styles/input-control-styles.js +42 -30
  207. package/build-module/input-control/styles/input-control-styles.js.map +1 -1
  208. package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js +1 -1
  209. package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js.map +1 -1
  210. package/build-module/mobile/bottom-sheet/index.native.js +1 -1
  211. package/build-module/mobile/bottom-sheet/index.native.js.map +1 -1
  212. package/build-module/mobile/bottom-sheet-select-control/index.native.js +4 -2
  213. package/build-module/mobile/bottom-sheet-select-control/index.native.js.map +1 -1
  214. package/build-module/mobile/html-text-input/index.native.js +20 -9
  215. package/build-module/mobile/html-text-input/index.native.js.map +1 -1
  216. package/build-module/mobile/keyboard-aware-flat-list/index.android.js +21 -5
  217. package/build-module/mobile/keyboard-aware-flat-list/index.android.js.map +1 -1
  218. package/build-module/mobile/keyboard-aware-flat-list/index.ios.js +42 -25
  219. package/build-module/mobile/keyboard-aware-flat-list/index.ios.js.map +1 -1
  220. package/build-module/navigation/styles/navigation-styles.js +13 -13
  221. package/build-module/navigation/styles/navigation-styles.js.map +1 -1
  222. package/build-module/notice/index.native.js +45 -41
  223. package/build-module/notice/index.native.js.map +1 -1
  224. package/build-module/notice/list.native.js +28 -46
  225. package/build-module/notice/list.native.js.map +1 -1
  226. package/build-module/palette-edit/index.js +37 -7
  227. package/build-module/palette-edit/index.js.map +1 -1
  228. package/build-module/popover/index.js +225 -325
  229. package/build-module/popover/index.js.map +1 -1
  230. package/build-module/resizable-box/resize-tooltip/utils.js +4 -5
  231. package/build-module/resizable-box/resize-tooltip/utils.js.map +1 -1
  232. package/build-module/sandbox/index.js +2 -2
  233. package/build-module/sandbox/index.js.map +1 -1
  234. package/build-module/sandbox/index.native.js +1 -1
  235. package/build-module/sandbox/index.native.js.map +1 -1
  236. package/build-module/select-control/index.js +29 -3
  237. package/build-module/select-control/index.js.map +1 -1
  238. package/build-module/select-control/styles/select-control-styles.js +17 -14
  239. package/build-module/select-control/styles/select-control-styles.js.map +1 -1
  240. package/build-module/surface/styles.js +8 -8
  241. package/build-module/surface/styles.js.map +1 -1
  242. package/build-module/text/hook.js +5 -5
  243. package/build-module/text/hook.js.map +1 -1
  244. package/build-module/text/styles/text-mixins.native.js +2 -2
  245. package/build-module/text/styles/text-mixins.native.js.map +1 -1
  246. package/build-module/text/styles.js +7 -7
  247. package/build-module/text/styles.js.map +1 -1
  248. package/build-module/text-control/index.js +35 -27
  249. package/build-module/text-control/index.js.map +1 -1
  250. package/build-module/text-control/types.js +2 -0
  251. package/build-module/text-control/types.js.map +1 -0
  252. package/build-module/toggle-group-control/toggle-group-control/component.js +2 -3
  253. package/build-module/toggle-group-control/toggle-group-control/component.js.map +1 -1
  254. package/build-module/toggle-group-control/toggle-group-control-option-icon/component.js +1 -5
  255. package/build-module/toggle-group-control/toggle-group-control-option-icon/component.js.map +1 -1
  256. package/build-module/tools-panel/tools-panel-header/component.js +51 -36
  257. package/build-module/tools-panel/tools-panel-header/component.js.map +1 -1
  258. package/build-module/tooltip/index.js +2 -2
  259. package/build-module/tooltip/index.js.map +1 -1
  260. package/build-module/ui/spinner/component.js +1 -1
  261. package/build-module/ui/spinner/component.js.map +1 -1
  262. package/build-module/unit-control/index.js +3 -3
  263. package/build-module/unit-control/index.js.map +1 -1
  264. package/build-module/unit-control/styles/unit-control-styles.js +11 -20
  265. package/build-module/unit-control/styles/unit-control-styles.js.map +1 -1
  266. package/build-module/unit-control/utils.js.map +1 -1
  267. package/build-module/utils/colors-values.js +19 -23
  268. package/build-module/utils/colors-values.js.map +1 -1
  269. package/build-style/style-rtl.css +55 -170
  270. package/build-style/style.css +51 -170
  271. package/build-types/border-box-control/border-box-control/component.d.ts.map +1 -1
  272. package/build-types/border-box-control/border-box-control/hook.d.ts +3 -1
  273. package/build-types/border-box-control/border-box-control/hook.d.ts.map +1 -1
  274. package/build-types/border-box-control/border-box-control-linked-button/hook.d.ts.map +1 -1
  275. package/build-types/border-box-control/border-box-control-split-controls/component.d.ts.map +1 -1
  276. package/build-types/border-box-control/border-box-control-split-controls/hook.d.ts +3 -1
  277. package/build-types/border-box-control/border-box-control-split-controls/hook.d.ts.map +1 -1
  278. package/build-types/border-box-control/border-box-control-visualizer/hook.d.ts.map +1 -1
  279. package/build-types/border-box-control/styles.d.ts +2 -2
  280. package/build-types/border-box-control/styles.d.ts.map +1 -1
  281. package/build-types/border-box-control/types.d.ts +40 -13
  282. package/build-types/border-box-control/types.d.ts.map +1 -1
  283. package/build-types/border-control/border-control/component.d.ts.map +1 -1
  284. package/build-types/border-control/border-control/hook.d.ts +2 -1
  285. package/build-types/border-control/border-control/hook.d.ts.map +1 -1
  286. package/build-types/border-control/border-control-dropdown/component.d.ts.map +1 -1
  287. package/build-types/border-control/border-control-dropdown/hook.d.ts +1 -0
  288. package/build-types/border-control/border-control-dropdown/hook.d.ts.map +1 -1
  289. package/build-types/border-control/styles.d.ts +2 -1
  290. package/build-types/border-control/styles.d.ts.map +1 -1
  291. package/build-types/border-control/types.d.ts +18 -6
  292. package/build-types/border-control/types.d.ts.map +1 -1
  293. package/build-types/button/index.d.ts.map +1 -1
  294. package/build-types/button-group/index.d.ts +25 -0
  295. package/build-types/button-group/index.d.ts.map +1 -0
  296. package/build-types/button-group/stories/index.d.ts +12 -0
  297. package/build-types/button-group/stories/index.d.ts.map +1 -0
  298. package/build-types/button-group/types.d.ts +11 -0
  299. package/build-types/button-group/types.d.ts.map +1 -0
  300. package/build-types/checkbox-control/index.d.ts +26 -0
  301. package/build-types/checkbox-control/index.d.ts.map +1 -0
  302. package/build-types/checkbox-control/stories/index.d.ts +13 -0
  303. package/build-types/checkbox-control/stories/index.d.ts.map +1 -0
  304. package/build-types/checkbox-control/types.d.ts +35 -0
  305. package/build-types/checkbox-control/types.d.ts.map +1 -0
  306. package/build-types/circular-option-picker/index.d.ts.map +1 -1
  307. package/build-types/color-palette/index.d.ts.map +1 -1
  308. package/build-types/color-picker/styles.d.ts +3 -3
  309. package/build-types/date-time/date.d.ts +24 -0
  310. package/build-types/date-time/date.d.ts.map +1 -0
  311. package/build-types/date-time/index.d.ts +35 -0
  312. package/build-types/date-time/index.d.ts.map +1 -0
  313. package/build-types/date-time/stories/date.d.ts +14 -0
  314. package/build-types/date-time/stories/date.d.ts.map +1 -0
  315. package/build-types/date-time/stories/index.d.ts +14 -0
  316. package/build-types/date-time/stories/index.d.ts.map +1 -0
  317. package/build-types/date-time/stories/time.d.ts +12 -0
  318. package/build-types/date-time/stories/time.d.ts.map +1 -0
  319. package/build-types/date-time/stories/utils.d.ts +3 -0
  320. package/build-types/date-time/stories/utils.d.ts.map +1 -0
  321. package/build-types/date-time/test/date.d.ts +2 -0
  322. package/build-types/date-time/test/date.d.ts.map +1 -0
  323. package/build-types/date-time/test/time.d.ts +2 -0
  324. package/build-types/date-time/test/time.d.ts.map +1 -0
  325. package/build-types/date-time/test/utils.d.ts +2 -0
  326. package/build-types/date-time/test/utils.d.ts.map +1 -0
  327. package/build-types/date-time/time.d.ts +25 -0
  328. package/build-types/date-time/time.d.ts.map +1 -0
  329. package/build-types/date-time/timezone.d.ts +8 -0
  330. package/build-types/date-time/timezone.d.ts.map +1 -0
  331. package/build-types/date-time/types.d.ts +91 -0
  332. package/build-types/date-time/types.d.ts.map +1 -0
  333. package/build-types/date-time/utils.d.ts +15 -0
  334. package/build-types/date-time/utils.d.ts.map +1 -0
  335. package/build-types/disabled/index.d.ts.map +1 -1
  336. package/build-types/dropdown/index.d.ts.map +1 -1
  337. package/build-types/input-control/index.d.ts +23 -3
  338. package/build-types/input-control/index.d.ts.map +1 -1
  339. package/build-types/input-control/input-field.d.ts +1 -1
  340. package/build-types/input-control/input-field.d.ts.map +1 -1
  341. package/build-types/input-control/stories/index.d.ts +5 -5
  342. package/build-types/input-control/stories/index.d.ts.map +1 -1
  343. package/build-types/input-control/styles/input-control-styles.d.ts +1 -0
  344. package/build-types/input-control/styles/input-control-styles.d.ts.map +1 -1
  345. package/build-types/input-control/types.d.ts +79 -3
  346. package/build-types/input-control/types.d.ts.map +1 -1
  347. package/build-types/number-control/styles/number-control-styles.d.ts +1 -1
  348. package/build-types/popover/index.d.ts +5 -8
  349. package/build-types/popover/index.d.ts.map +1 -1
  350. package/build-types/resizable-box/index.d.ts +1 -1
  351. package/build-types/resizable-box/resize-tooltip/index.d.ts +1 -1
  352. package/build-types/resizable-box/resize-tooltip/utils.d.ts.map +1 -1
  353. package/build-types/select-control/index.d.ts +30 -26
  354. package/build-types/select-control/index.d.ts.map +1 -1
  355. package/build-types/select-control/stories/index.d.ts +23 -0
  356. package/build-types/select-control/stories/index.d.ts.map +1 -0
  357. package/build-types/select-control/styles/select-control-styles.d.ts +3 -4
  358. package/build-types/select-control/styles/select-control-styles.d.ts.map +1 -1
  359. package/build-types/select-control/test/select-control.d.ts +2 -0
  360. package/build-types/select-control/test/select-control.d.ts.map +1 -0
  361. package/build-types/select-control/types.d.ts +52 -1
  362. package/build-types/select-control/types.d.ts.map +1 -1
  363. package/build-types/text-control/index.d.ts +2 -2
  364. package/build-types/toggle-group-control/toggle-group-control/component.d.ts.map +1 -1
  365. package/build-types/toggle-group-control/toggle-group-control-option-icon/component.d.ts.map +1 -1
  366. package/build-types/tools-panel/tools-panel-header/component.d.ts.map +1 -1
  367. package/build-types/tools-panel/types.d.ts +0 -1
  368. package/build-types/tools-panel/types.d.ts.map +1 -1
  369. package/build-types/tooltip/index.d.ts.map +1 -1
  370. package/build-types/unit-control/index.d.ts +2 -2
  371. package/build-types/unit-control/index.d.ts.map +1 -1
  372. package/build-types/unit-control/styles/unit-control-styles.d.ts.map +1 -1
  373. package/build-types/unit-control/test/index.d.ts +2 -0
  374. package/build-types/unit-control/test/index.d.ts.map +1 -0
  375. package/build-types/unit-control/test/utils.d.ts +2 -0
  376. package/build-types/unit-control/test/utils.d.ts.map +1 -0
  377. package/build-types/unit-control/types.d.ts +1 -1
  378. package/build-types/unit-control/types.d.ts.map +1 -1
  379. package/build-types/unit-control/utils.d.ts +3 -3
  380. package/build-types/unit-control/utils.d.ts.map +1 -1
  381. package/build-types/utils/colors-values.d.ts +6 -146
  382. package/build-types/utils/colors-values.d.ts.map +1 -1
  383. package/package.json +19 -19
  384. package/src/alignment-matrix-control/styles/alignment-matrix-control-styles.js +5 -3
  385. package/src/autocomplete/style.scss +1 -1
  386. package/src/border-box-control/border-box-control/README.md +10 -14
  387. package/src/border-box-control/border-box-control/component.tsx +21 -4
  388. package/src/border-box-control/border-box-control-linked-button/hook.ts +10 -6
  389. package/src/border-box-control/border-box-control-split-controls/component.tsx +24 -7
  390. package/src/border-box-control/border-box-control-visualizer/hook.ts +11 -6
  391. package/src/border-box-control/stories/index.js +1 -0
  392. package/src/border-box-control/styles.ts +15 -8
  393. package/src/border-box-control/types.ts +40 -14
  394. package/src/border-control/border-control/README.md +0 -7
  395. package/src/border-control/border-control/component.tsx +4 -2
  396. package/src/border-control/border-control/hook.ts +5 -2
  397. package/src/border-control/border-control-dropdown/component.tsx +18 -11
  398. package/src/border-control/border-control-dropdown/hook.ts +7 -5
  399. package/src/border-control/stories/index.js +1 -0
  400. package/src/border-control/styles.ts +82 -22
  401. package/src/border-control/types.ts +18 -6
  402. package/src/box-control/README.md +0 -74
  403. package/src/box-control/index.js +0 -15
  404. package/src/box-control/stories/index.js +0 -29
  405. package/src/box-control/utils.js +0 -7
  406. package/src/button/index.js +2 -4
  407. package/src/button/index.native.js +33 -18
  408. package/src/button/test/index.js +16 -1
  409. package/src/button-group/index.tsx +47 -0
  410. package/src/button-group/stories/index.tsx +41 -0
  411. package/src/button-group/types.ts +11 -0
  412. package/src/checkbox-control/README.md +10 -8
  413. package/src/checkbox-control/{index.js → index.tsx} +49 -14
  414. package/src/checkbox-control/stories/{index.js → index.tsx} +49 -27
  415. package/src/checkbox-control/types.ts +36 -0
  416. package/src/circular-option-picker/index.js +1 -2
  417. package/src/circular-option-picker/style.scss +1 -0
  418. package/src/color-palette/README.md +0 -1
  419. package/src/color-palette/index.js +6 -13
  420. package/src/color-palette/style.scss +3 -18
  421. package/src/color-palette/test/__snapshots__/index.js.snap +2 -3
  422. package/src/confirm-dialog/stories/index.js +87 -99
  423. package/src/date-time/README.md +13 -10
  424. package/src/date-time/{date.js → date.tsx} +49 -20
  425. package/src/date-time/{index.js → index.tsx} +31 -5
  426. package/src/date-time/stories/date.tsx +73 -0
  427. package/src/date-time/stories/index.tsx +75 -0
  428. package/src/date-time/stories/time.tsx +51 -0
  429. package/src/date-time/stories/utils.ts +9 -0
  430. package/src/date-time/test/date.tsx +127 -0
  431. package/src/date-time/test/{time.js → time.tsx} +34 -19
  432. package/src/date-time/test/{utils.js → utils.ts} +1 -1
  433. package/src/date-time/{time.js → time.tsx} +57 -46
  434. package/src/date-time/{timezone.js → timezone.tsx} +4 -3
  435. package/src/date-time/types.ts +106 -0
  436. package/src/date-time/utils.ts +20 -0
  437. package/src/dimension-control/test/__snapshots__/index.test.js.snap +4 -4
  438. package/src/disabled/index.js +5 -90
  439. package/src/draggable/index.native.js +215 -0
  440. package/src/draggable/style.native.scss +3 -0
  441. package/src/dropdown/index.js +9 -4
  442. package/src/dropdown/style.scss +1 -1
  443. package/src/focal-point-picker/index.native.js +3 -3
  444. package/src/form-file-upload/test/index.js +20 -13
  445. package/src/heading/hook.ts +1 -1
  446. package/src/heading/test/__snapshots__/index.js.snap +3 -3
  447. package/src/index.js +0 -1
  448. package/src/index.native.js +1 -0
  449. package/src/input-control/README.md +3 -3
  450. package/src/input-control/index.tsx +23 -3
  451. package/src/input-control/stories/index.tsx +63 -0
  452. package/src/input-control/styles/input-control-styles.tsx +20 -7
  453. package/src/input-control/types.ts +79 -2
  454. package/src/item-group/stories/index.js +22 -18
  455. package/src/menu-item/style.scss +10 -0
  456. package/src/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js +1 -1
  457. package/src/mobile/bottom-sheet/bottom-sheet-navigation/test/navigation-container.native.js +9 -2
  458. package/src/mobile/bottom-sheet/index.native.js +1 -1
  459. package/src/mobile/bottom-sheet-select-control/index.native.js +8 -2
  460. package/src/mobile/html-text-input/index.native.js +45 -29
  461. package/src/mobile/html-text-input/style.android.scss +2 -15
  462. package/src/mobile/html-text-input/style.ios.scss +2 -15
  463. package/src/mobile/html-text-input/{style-common.native.scss → style.scss} +16 -0
  464. package/src/mobile/keyboard-aware-flat-list/index.android.js +15 -5
  465. package/src/mobile/keyboard-aware-flat-list/index.ios.js +75 -46
  466. package/src/mobile/link-settings/test/link-settings-navigation.native.js +9 -1
  467. package/src/navigation/styles/navigation-styles.js +5 -5
  468. package/src/navigator/stories/index.js +16 -10
  469. package/src/notice/index.native.js +44 -54
  470. package/src/notice/list.native.js +27 -51
  471. package/src/notice/style.native.scss +1 -0
  472. package/src/palette-edit/index.js +37 -9
  473. package/src/palette-edit/style.scss +0 -7
  474. package/src/palette-edit/test/index.js +63 -0
  475. package/src/panel/README.md +1 -1
  476. package/src/placeholder/test/index.js +7 -0
  477. package/src/popover/README.md +7 -9
  478. package/src/popover/index.js +242 -417
  479. package/src/popover/style.scss +20 -190
  480. package/src/popover/test/__snapshots__/index.js.snap +6 -18
  481. package/src/query-controls/README.md +2 -2
  482. package/src/resizable-box/resize-tooltip/utils.ts +4 -5
  483. package/src/sandbox/index.js +2 -2
  484. package/src/sandbox/index.native.js +1 -1
  485. package/src/select-control/README.md +2 -2
  486. package/src/select-control/index.tsx +30 -29
  487. package/src/select-control/stories/index.tsx +90 -0
  488. package/src/select-control/styles/select-control-styles.ts +16 -12
  489. package/src/select-control/test/{select-control.js → select-control.tsx} +2 -2
  490. package/src/select-control/types.ts +66 -1
  491. package/src/surface/styles.js +1 -1
  492. package/src/tab-panel/style.scss +1 -1
  493. package/src/text/hook.js +1 -1
  494. package/src/text/styles/text-mixins.native.js +2 -2
  495. package/src/text/styles.js +1 -1
  496. package/src/text/test/__snapshots__/{index.js.snap → index.tsx.snap} +16 -0
  497. package/src/text/test/{index.js → index.tsx} +12 -6
  498. package/src/text-control/index.tsx +84 -0
  499. package/src/text-control/stories/index.tsx +66 -0
  500. package/src/text-control/types.ts +29 -0
  501. package/src/toggle-group-control/test/__snapshots__/index.js.snap +4 -10
  502. package/src/toggle-group-control/toggle-group-control/component.tsx +7 -3
  503. package/src/toggle-group-control/toggle-group-control-option-icon/component.tsx +1 -5
  504. package/src/toolbar-group/style.scss +20 -0
  505. package/src/tools-panel/test/__snapshots__/index.js.snap +2 -2
  506. package/src/tools-panel/test/index.js +71 -18
  507. package/src/tools-panel/tools-panel-header/component.tsx +75 -33
  508. package/src/tools-panel/types.ts +0 -1
  509. package/src/tooltip/index.js +8 -2
  510. package/src/tooltip/style.scss +2 -4
  511. package/src/tooltip/test/index.js +6 -0
  512. package/src/tooltip/test/index.native.js +1 -1
  513. package/src/ui/spinner/component.js +1 -1
  514. package/src/ui/spinner/test/__snapshots__/index.js.snap +3 -3
  515. package/src/unit-control/index.tsx +2 -5
  516. package/src/unit-control/styles/unit-control-styles.ts +3 -13
  517. package/src/unit-control/test/__snapshots__/index.tsx.snap +33 -0
  518. package/src/unit-control/test/{index.js → index.tsx} +295 -166
  519. package/src/unit-control/test/{utils.js → utils.ts} +38 -19
  520. package/src/unit-control/types.ts +4 -1
  521. package/src/unit-control/utils.ts +5 -3
  522. package/src/utils/colors-values.js +18 -22
  523. package/tsconfig.json +14 -3
  524. package/tsconfig.tsbuildinfo +1 -1
  525. package/build/box-control/visualizer.js +0 -165
  526. package/build/box-control/visualizer.js.map +0 -1
  527. package/build/flyout/context.js +0 -23
  528. package/build/flyout/context.js.map +0 -1
  529. package/build/flyout/flyout/component.js +0 -106
  530. package/build/flyout/flyout/component.js.map +0 -1
  531. package/build/flyout/flyout/hook.js +0 -53
  532. package/build/flyout/flyout/hook.js.map +0 -1
  533. package/build/flyout/flyout/index.js +0 -24
  534. package/build/flyout/flyout/index.js.map +0 -1
  535. package/build/flyout/flyout-content/component.js +0 -65
  536. package/build/flyout/flyout-content/component.js.map +0 -1
  537. package/build/flyout/flyout-content/index.js +0 -16
  538. package/build/flyout/flyout-content/index.js.map +0 -1
  539. package/build/flyout/index.js +0 -16
  540. package/build/flyout/index.js.map +0 -1
  541. package/build/flyout/styles.js +0 -46
  542. package/build/flyout/styles.js.map +0 -1
  543. package/build/flyout/utils.js +0 -36
  544. package/build/flyout/utils.js.map +0 -1
  545. package/build/mobile/html-text-input/container.android.js +0 -41
  546. package/build/mobile/html-text-input/container.android.js.map +0 -1
  547. package/build/mobile/html-text-input/container.ios.js +0 -60
  548. package/build/mobile/html-text-input/container.ios.js.map +0 -1
  549. package/build/popover/utils.js +0 -322
  550. package/build/popover/utils.js.map +0 -1
  551. package/build-module/box-control/visualizer.js +0 -154
  552. package/build-module/box-control/visualizer.js.map +0 -1
  553. package/build-module/flyout/context.js +0 -11
  554. package/build-module/flyout/context.js.map +0 -1
  555. package/build-module/flyout/flyout/component.js +0 -89
  556. package/build-module/flyout/flyout/component.js.map +0 -1
  557. package/build-module/flyout/flyout/hook.js +0 -44
  558. package/build-module/flyout/flyout/hook.js.map +0 -1
  559. package/build-module/flyout/flyout/index.js +0 -3
  560. package/build-module/flyout/flyout/index.js.map +0 -1
  561. package/build-module/flyout/flyout-content/component.js +0 -51
  562. package/build-module/flyout/flyout-content/component.js.map +0 -1
  563. package/build-module/flyout/flyout-content/index.js +0 -2
  564. package/build-module/flyout/flyout-content/index.js.map +0 -1
  565. package/build-module/flyout/index.js +0 -2
  566. package/build-module/flyout/index.js.map +0 -1
  567. package/build-module/flyout/styles.js +0 -27
  568. package/build-module/flyout/styles.js.map +0 -1
  569. package/build-module/flyout/utils.js +0 -25
  570. package/build-module/flyout/utils.js.map +0 -1
  571. package/build-module/mobile/html-text-input/container.android.js +0 -29
  572. package/build-module/mobile/html-text-input/container.android.js.map +0 -1
  573. package/build-module/mobile/html-text-input/container.ios.js +0 -48
  574. package/build-module/mobile/html-text-input/container.ios.js.map +0 -1
  575. package/build-module/popover/utils.js +0 -308
  576. package/build-module/popover/utils.js.map +0 -1
  577. package/build-types/flyout/context.d.ts +0 -6
  578. package/build-types/flyout/context.d.ts.map +0 -1
  579. package/build-types/flyout/flyout/component.d.ts +0 -21
  580. package/build-types/flyout/flyout/component.d.ts.map +0 -1
  581. package/build-types/flyout/flyout/hook.d.ts +0 -270
  582. package/build-types/flyout/flyout/hook.d.ts.map +0 -1
  583. package/build-types/flyout/flyout/index.d.ts +0 -3
  584. package/build-types/flyout/flyout/index.d.ts.map +0 -1
  585. package/build-types/flyout/flyout-content/component.d.ts +0 -3
  586. package/build-types/flyout/flyout-content/component.d.ts.map +0 -1
  587. package/build-types/flyout/flyout-content/index.d.ts +0 -2
  588. package/build-types/flyout/flyout-content/index.d.ts.map +0 -1
  589. package/build-types/flyout/index.d.ts +0 -2
  590. package/build-types/flyout/index.d.ts.map +0 -1
  591. package/build-types/flyout/styles.d.ts +0 -22
  592. package/build-types/flyout/styles.d.ts.map +0 -1
  593. package/build-types/flyout/types.d.ts +0 -80
  594. package/build-types/flyout/types.d.ts.map +0 -1
  595. package/build-types/flyout/utils.d.ts +0 -8
  596. package/build-types/flyout/utils.d.ts.map +0 -1
  597. package/build-types/popover/utils.d.ts +0 -70
  598. package/build-types/popover/utils.d.ts.map +0 -1
  599. package/build-types/toggle-group-control/toggle-group-control-option/styles.d.ts +0 -19
  600. package/build-types/toggle-group-control/toggle-group-control-option/styles.d.ts.map +0 -1
  601. package/src/box-control/visualizer.js +0 -116
  602. package/src/button-group/index.js +0 -17
  603. package/src/button-group/stories/index.js +0 -21
  604. package/src/date-time/stories/date.js +0 -17
  605. package/src/date-time/stories/index.js +0 -72
  606. package/src/date-time/stories/time.js +0 -32
  607. package/src/date-time/test/date.js +0 -97
  608. package/src/date-time/utils.js +0 -18
  609. package/src/flyout/context.js +0 -10
  610. package/src/flyout/flyout/README.md +0 -98
  611. package/src/flyout/flyout/component.js +0 -111
  612. package/src/flyout/flyout/hook.js +0 -45
  613. package/src/flyout/flyout/index.js +0 -2
  614. package/src/flyout/flyout-content/component.js +0 -53
  615. package/src/flyout/flyout-content/index.js +0 -1
  616. package/src/flyout/index.js +0 -1
  617. package/src/flyout/stories/index.js +0 -24
  618. package/src/flyout/styles.ts +0 -41
  619. package/src/flyout/test/__snapshots__/index.js.snap +0 -186
  620. package/src/flyout/test/index.js +0 -103
  621. package/src/flyout/types.ts +0 -84
  622. package/src/flyout/utils.js +0 -23
  623. package/src/input-control/stories/index.js +0 -71
  624. package/src/mobile/html-text-input/container.android.js +0 -23
  625. package/src/mobile/html-text-input/container.ios.js +0 -50
  626. package/src/popover/test/utils.js +0 -304
  627. package/src/popover/utils.js +0 -396
  628. package/src/select-control/stories/index.js +0 -104
  629. package/src/text-control/index.js +0 -72
  630. package/src/text-control/stories/index.js +0 -46
@@ -87,8 +87,7 @@ function ButtonAction(_ref4) {
87
87
  } = _ref4;
88
88
  return (0, _element.createElement)(_button.default, (0, _extends2.default)({
89
89
  className: (0, _classnames.default)('components-circular-option-picker__clear', className),
90
- isSmall: true,
91
- variant: "secondary"
90
+ variant: "tertiary"
92
91
  }, additionalProps), children);
93
92
  }
94
93
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/circular-option-picker/index.js"],"names":["Option","className","isSelected","selectedIconProps","tooltipText","additionalProps","optionButton","check","DropdownLinkAction","buttonProps","dropdownProps","linkText","isOpen","onToggle","ButtonAction","children","CircularOptionPicker","actions","options"],"mappings":";;;;;;;;;;;;;AAIA;;AAKA;;AAKA;;AAC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4BAAC,eAAD;AACC,IAAA,SAAS,EAAG,yBACX,0CADW,EAEXJ,SAFW,CADb;AAKC,IAAA,OAAO,MALR;AAMC,IAAA,OAAO,EAAC;AANT,KAOMI,eAPN,GASGU,QATH,CADD;AAaA;;AAEc,SAASC,oBAAT,QAKX;AAAA,MAL0C;AAC7CC,IAAAA,OAD6C;AAE7ChB,IAAAA,SAF6C;AAG7CiB,IAAAA,OAH6C;AAI7CH,IAAAA;AAJ6C,GAK1C;AACH,SACC;AACC,IAAA,SAAS,EAAG,yBACX,mCADW,EAEXd,SAFW;AADb,KAMC;AAAK,IAAA,SAAS,EAAC;AAAf,KACGiB,OADH,CAND,EASGH,QATH,EAUGE,OAAO,IACR;AAAK,IAAA,SAAS,EAAC;AAAf,KACGA,OADH,CAXF,CADD;AAkBA;;AAEDD,oBAAoB,CAAChB,MAArB,GAA8BA,MAA9B;AACAgB,oBAAoB,CAACF,YAArB,GAAoCA,YAApC;AACAE,oBAAoB,CAACR,kBAArB,GAA0CA,kBAA1C","sourcesContent":["// @ts-nocheck\n/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { Icon, check } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport Button from '../button';\nimport Dropdown from '../dropdown';\nimport Tooltip from '../tooltip';\n\nfunction Option( {\n\tclassName,\n\tisSelected,\n\tselectedIconProps,\n\ttooltipText,\n\t...additionalProps\n} ) {\n\tconst optionButton = (\n\t\t<Button\n\t\t\tisPressed={ isSelected }\n\t\t\tclassName=\"components-circular-option-picker__option\"\n\t\t\t{ ...additionalProps }\n\t\t/>\n\t);\n\treturn (\n\t\t<div\n\t\t\tclassName={ classnames(\n\t\t\t\tclassName,\n\t\t\t\t'components-circular-option-picker__option-wrapper'\n\t\t\t) }\n\t\t>\n\t\t\t{ tooltipText ? (\n\t\t\t\t<Tooltip text={ tooltipText }>{ optionButton }</Tooltip>\n\t\t\t) : (\n\t\t\t\toptionButton\n\t\t\t) }\n\t\t\t{ isSelected && (\n\t\t\t\t<Icon\n\t\t\t\t\ticon={ check }\n\t\t\t\t\t{ ...( selectedIconProps ? selectedIconProps : {} ) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n\nfunction DropdownLinkAction( {\n\tbuttonProps,\n\tclassName,\n\tdropdownProps,\n\tlinkText,\n} ) {\n\treturn (\n\t\t<Dropdown\n\t\t\tclassName={ classnames(\n\t\t\t\t'components-circular-option-picker__dropdown-link-action',\n\t\t\t\tclassName\n\t\t\t) }\n\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t<Button\n\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\taria-haspopup=\"true\"\n\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\t{ ...buttonProps }\n\t\t\t\t>\n\t\t\t\t\t{ linkText }\n\t\t\t\t</Button>\n\t\t\t) }\n\t\t\t{ ...dropdownProps }\n\t\t/>\n\t);\n}\n\nfunction ButtonAction( { className, children, ...additionalProps } ) {\n\treturn (\n\t\t<Button\n\t\t\tclassName={ classnames(\n\t\t\t\t'components-circular-option-picker__clear',\n\t\t\t\tclassName\n\t\t\t) }\n\t\t\tisSmall\n\t\t\tvariant=\"secondary\"\n\t\t\t{ ...additionalProps }\n\t\t>\n\t\t\t{ children }\n\t\t</Button>\n\t);\n}\n\nexport default function CircularOptionPicker( {\n\tactions,\n\tclassName,\n\toptions,\n\tchildren,\n} ) {\n\treturn (\n\t\t<div\n\t\t\tclassName={ classnames(\n\t\t\t\t'components-circular-option-picker',\n\t\t\t\tclassName\n\t\t\t) }\n\t\t>\n\t\t\t<div className=\"components-circular-option-picker__swatches\">\n\t\t\t\t{ options }\n\t\t\t</div>\n\t\t\t{ children }\n\t\t\t{ actions && (\n\t\t\t\t<div className=\"components-circular-option-picker__custom-clear-wrapper\">\n\t\t\t\t\t{ actions }\n\t\t\t\t</div>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n\nCircularOptionPicker.Option = Option;\nCircularOptionPicker.ButtonAction = ButtonAction;\nCircularOptionPicker.DropdownLinkAction = DropdownLinkAction;\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/circular-option-picker/index.js"],"names":["Option","className","isSelected","selectedIconProps","tooltipText","additionalProps","optionButton","check","DropdownLinkAction","buttonProps","dropdownProps","linkText","isOpen","onToggle","ButtonAction","children","CircularOptionPicker","actions","options"],"mappings":";;;;;;;;;;;;;AAIA;;AAKA;;AAKA;;AACA;;AACA;;AAhBA;;AACA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AAKA,SAASA,MAAT,OAMI;AAAA,MANa;AAChBC,IAAAA,SADgB;AAEhBC,IAAAA,UAFgB;AAGhBC,IAAAA,iBAHgB;AAIhBC,IAAAA,WAJgB;AAKhB,OAAGC;AALa,GAMb;AACH,QAAMC,YAAY,GACjB,4BAAC,eAAD;AACC,IAAA,SAAS,EAAGJ,UADb;AAEC,IAAA,SAAS,EAAC;AAFX,KAGMG,eAHN,EADD;AAOA,SACC;AACC,IAAA,SAAS,EAAG,yBACXJ,SADW,EAEX,mDAFW;AADb,KAMGG,WAAW,GACZ,4BAAC,gBAAD;AAAS,IAAA,IAAI,EAAGA;AAAhB,KAAgCE,YAAhC,CADY,GAGZA,YATF,EAWGJ,UAAU,IACX,4BAAC,WAAD;AACC,IAAA,IAAI,EAAGK;AADR,KAEQJ,iBAAiB,GAAGA,iBAAH,GAAuB,EAFhD,EAZF,CADD;AAoBA;;AAED,SAASK,kBAAT,QAKI;AAAA,MALyB;AAC5BC,IAAAA,WAD4B;AAE5BR,IAAAA,SAF4B;AAG5BS,IAAAA,aAH4B;AAI5BC,IAAAA;AAJ4B,GAKzB;AACH,SACC,4BAAC,iBAAD;AACC,IAAA,SAAS,EAAG,yBACX,yDADW,EAEXV,SAFW,CADb;AAKC,IAAA,YAAY,EAAG;AAAA,UAAE;AAAEW,QAAAA,MAAF;AAAUC,QAAAA;AAAV,OAAF;AAAA,aACd,4BAAC,eAAD;AACC,yBAAgBD,MADjB;AAEC,yBAAc,MAFf;AAGC,QAAA,OAAO,EAAGC,QAHX;AAIC,QAAA,OAAO,EAAC;AAJT,SAKMJ,WALN,GAOGE,QAPH,CADc;AAAA;AALhB,KAgBMD,aAhBN,EADD;AAoBA;;AAED,SAASI,YAAT,QAAqE;AAAA,MAA9C;AAAEb,IAAAA,SAAF;AAAac,IAAAA,QAAb;AAAuB,OAAGV;AAA1B,GAA8C;AACpE,SACC,4BAAC,eAAD;AACC,IAAA,SAAS,EAAG,yBACX,0CADW,EAEXJ,SAFW,CADb;AAKC,IAAA,OAAO,EAAC;AALT,KAMMI,eANN,GAQGU,QARH,CADD;AAYA;;AAEc,SAASC,oBAAT,QAKX;AAAA,MAL0C;AAC7CC,IAAAA,OAD6C;AAE7ChB,IAAAA,SAF6C;AAG7CiB,IAAAA,OAH6C;AAI7CH,IAAAA;AAJ6C,GAK1C;AACH,SACC;AACC,IAAA,SAAS,EAAG,yBACX,mCADW,EAEXd,SAFW;AADb,KAMC;AAAK,IAAA,SAAS,EAAC;AAAf,KACGiB,OADH,CAND,EASGH,QATH,EAUGE,OAAO,IACR;AAAK,IAAA,SAAS,EAAC;AAAf,KACGA,OADH,CAXF,CADD;AAkBA;;AAEDD,oBAAoB,CAAChB,MAArB,GAA8BA,MAA9B;AACAgB,oBAAoB,CAACF,YAArB,GAAoCA,YAApC;AACAE,oBAAoB,CAACR,kBAArB,GAA0CA,kBAA1C","sourcesContent":["// @ts-nocheck\n/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { Icon, check } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport Button from '../button';\nimport Dropdown from '../dropdown';\nimport Tooltip from '../tooltip';\n\nfunction Option( {\n\tclassName,\n\tisSelected,\n\tselectedIconProps,\n\ttooltipText,\n\t...additionalProps\n} ) {\n\tconst optionButton = (\n\t\t<Button\n\t\t\tisPressed={ isSelected }\n\t\t\tclassName=\"components-circular-option-picker__option\"\n\t\t\t{ ...additionalProps }\n\t\t/>\n\t);\n\treturn (\n\t\t<div\n\t\t\tclassName={ classnames(\n\t\t\t\tclassName,\n\t\t\t\t'components-circular-option-picker__option-wrapper'\n\t\t\t) }\n\t\t>\n\t\t\t{ tooltipText ? (\n\t\t\t\t<Tooltip text={ tooltipText }>{ optionButton }</Tooltip>\n\t\t\t) : (\n\t\t\t\toptionButton\n\t\t\t) }\n\t\t\t{ isSelected && (\n\t\t\t\t<Icon\n\t\t\t\t\ticon={ check }\n\t\t\t\t\t{ ...( selectedIconProps ? selectedIconProps : {} ) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n\nfunction DropdownLinkAction( {\n\tbuttonProps,\n\tclassName,\n\tdropdownProps,\n\tlinkText,\n} ) {\n\treturn (\n\t\t<Dropdown\n\t\t\tclassName={ classnames(\n\t\t\t\t'components-circular-option-picker__dropdown-link-action',\n\t\t\t\tclassName\n\t\t\t) }\n\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t<Button\n\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\taria-haspopup=\"true\"\n\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\t{ ...buttonProps }\n\t\t\t\t>\n\t\t\t\t\t{ linkText }\n\t\t\t\t</Button>\n\t\t\t) }\n\t\t\t{ ...dropdownProps }\n\t\t/>\n\t);\n}\n\nfunction ButtonAction( { className, children, ...additionalProps } ) {\n\treturn (\n\t\t<Button\n\t\t\tclassName={ classnames(\n\t\t\t\t'components-circular-option-picker__clear',\n\t\t\t\tclassName\n\t\t\t) }\n\t\t\tvariant=\"tertiary\"\n\t\t\t{ ...additionalProps }\n\t\t>\n\t\t\t{ children }\n\t\t</Button>\n\t);\n}\n\nexport default function CircularOptionPicker( {\n\tactions,\n\tclassName,\n\toptions,\n\tchildren,\n} ) {\n\treturn (\n\t\t<div\n\t\t\tclassName={ classnames(\n\t\t\t\t'components-circular-option-picker',\n\t\t\t\tclassName\n\t\t\t) }\n\t\t>\n\t\t\t<div className=\"components-circular-option-picker__swatches\">\n\t\t\t\t{ options }\n\t\t\t</div>\n\t\t\t{ children }\n\t\t\t{ actions && (\n\t\t\t\t<div className=\"components-circular-option-picker__custom-clear-wrapper\">\n\t\t\t\t\t{ actions }\n\t\t\t\t</div>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n\nCircularOptionPicker.Option = Option;\nCircularOptionPicker.ButtonAction = ButtonAction;\nCircularOptionPicker.DropdownLinkAction = DropdownLinkAction;\n"]}
@@ -20,8 +20,6 @@ var _names = _interopRequireDefault(require("colord/plugins/names"));
20
20
 
21
21
  var _a11y = _interopRequireDefault(require("colord/plugins/a11y"));
22
22
 
23
- var _classnames = _interopRequireDefault(require("classnames"));
24
-
25
23
  var _i18n = require("@wordpress/i18n");
26
24
 
27
25
  var _dropdown = _interopRequireDefault(require("../dropdown"));
@@ -131,9 +129,11 @@ function CustomColorPickerDropdown(_ref5) {
131
129
  ...props
132
130
  } = _ref5;
133
131
  return (0, _element.createElement)(_dropdown.default, (0, _extends2.default)({
134
- contentClassName: (0, _classnames.default)('components-color-palette__custom-color-dropdown-content', {
135
- 'is-rendered-in-sidebar': isRenderedInSidebar
136
- })
132
+ contentClassName: "components-color-palette__custom-color-dropdown-content",
133
+ popoverProps: isRenderedInSidebar ? {
134
+ placement: 'left-start',
135
+ offset: 20
136
+ } : undefined
137
137
  }, props));
138
138
  }
139
139
 
@@ -189,12 +189,6 @@ function ColorPalette(_ref6) {
189
189
  enableAlpha: enableAlpha
190
190
  });
191
191
 
192
- let dropdownPosition;
193
-
194
- if (__experimentalIsRenderedInSidebar) {
195
- dropdownPosition = 'bottom left';
196
- }
197
-
198
192
  const colordColor = (0, _colord.colord)(value);
199
193
  const valueWithoutLeadingHash = value !== null && value !== void 0 && value.startsWith('#') ? value.substring(1) : value !== null && value !== void 0 ? value : '';
200
194
  const buttonLabelName = (0, _element.useMemo)(() => extractColorNameFromCurrentValue(value, colors, showMultiplePalettes), [value, colors, showMultiplePalettes]);
@@ -204,7 +198,6 @@ function ColorPalette(_ref6) {
204
198
  spacing: 3,
205
199
  className: className
206
200
  }, !disableCustomColors && (0, _element.createElement)(CustomColorPickerDropdown, {
207
- position: dropdownPosition,
208
201
  isRenderedInSidebar: __experimentalIsRenderedInSidebar,
209
202
  renderContent: renderCustomColorPicker,
210
203
  renderToggle: _ref7 => {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/color-palette/index.js"],"names":["namesPlugin","a11yPlugin","SinglePalette","className","clearColor","colors","onChange","value","actions","colorOptions","color","name","colordColor","fill","contrast","backgroundColor","MultiplePalettes","map","index","colorPalette","length","CustomColorPickerDropdown","isRenderedInSidebar","props","extractColorNameFromCurrentValue","currentValue","showMultiplePalettes","colorPalettes","paletteColors","colorName","colorValue","toHex","ColorPalette","clearable","disableCustomColors","enableAlpha","__experimentalHasMultipleOrigins","__experimentalIsRenderedInSidebar","undefined","Component","renderCustomColorPicker","dropdownPosition","valueWithoutLeadingHash","startsWith","substring","buttonLabelName","customColorAccessibleLabel","isOpen","onToggle","background","Truncate"],"mappings":";;;;;;;;;;AAcA;;;;AAVA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AAMA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAzBA;;AACA;AACA;AACA;;AAOA;AACA;AACA;;AAIA;AACA;AACA;AASA,oBAAQ,CAAEA,cAAF,EAAeC,aAAf,CAAR;;AAEA,SAASC,aAAT,OAOI;AAAA,MAPoB;AACvBC,IAAAA,SADuB;AAEvBC,IAAAA,UAFuB;AAGvBC,IAAAA,MAHuB;AAIvBC,IAAAA,QAJuB;AAKvBC,IAAAA,KALuB;AAMvBC,IAAAA;AANuB,GAOpB;AACH,QAAMC,YAAY,GAAG,sBAAS,MAAM;AACnC,WAAO,iBAAKJ,MAAL,EAAa,SAAuB;A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ATT,SAkBC,4BAAC,cAAD;AACC,QAAA,OAAO,MADR;AAEC,QAAA,EAAE,EAAGoC,kBAFN;AAGC,QAAA,SAAS,EAAC;AAHX,SAKGL,eALH,CAlBD,EAyBC,4BAAC,cAAD;AACC,QAAA,EAAE,EAAC,MADJ;AAEC,QAAA,SAAS,EAAC;AAFX,SAIGH,uBAJH,CAzBD,CADc;AAAA;AAJhB,IAFF,EA0CC,4BAAC,SAAD;AACC,IAAA,SAAS,EAAGT,SADb;AAEC,IAAA,UAAU,EAAG7B,UAFd;AAGC,IAAA,MAAM,EAAGC,MAHV;AAIC,IAAA,QAAQ,EAAGC,QAJZ;AAKC,IAAA,KAAK,EAAGC,KALT;AAMC,IAAA,OAAO,EACN,CAAC,CAAE0B,SAAH,IACC,4BAAC,6BAAD,CAAsB,YAAtB;AACC,MAAA,OAAO,EAAG7B;AADX,OAGG,cAAI,OAAJ,CAHH;AARH,IA1CD,CADD;AA6DA","sourcesContent":["// @ts-nocheck\n/**\n * External dependencies\n */\nimport { map } from 'lodash';\nimport { colord, extend } from 'colord';\nimport namesPlugin from 'colord/plugins/names';\nimport a11yPlugin from 'colord/plugins/a11y';\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useCallback, useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport Dropdown from '../dropdown';\nimport { ColorPicker } from '../color-picker';\nimport CircularOptionPicker from '../circular-option-picker';\nimport { VStack } from '../v-stack';\nimport { Flex, FlexItem } from '../flex';\nimport { Truncate } from '../truncate';\nimport { ColorHeading } from './styles';\n\nextend( [ namesPlugin, a11yPlugin ] );\n\nfunction SinglePalette( {\n\tclassName,\n\tclearColor,\n\tcolors,\n\tonChange,\n\tvalue,\n\tactions,\n} ) {\n\tconst colorOptions = useMemo( () => {\n\t\treturn map( colors, ( { color, name } ) => {\n\t\t\tconst colordColor = colord( color );\n\n\t\t\treturn (\n\t\t\t\t<CircularOptionPicker.Option\n\t\t\t\t\tkey={ color }\n\t\t\t\t\tisSelected={ value === color }\n\t\t\t\t\tselectedIconProps={\n\t\t\t\t\t\tvalue === color\n\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\tfill:\n\t\t\t\t\t\t\t\t\t\tcolordColor.contrast() >\n\t\t\t\t\t\t\t\t\t\tcolordColor.contrast( '#000' )\n\t\t\t\t\t\t\t\t\t\t\t? '#fff'\n\t\t\t\t\t\t\t\t\t\t\t: '#000',\n\t\t\t\t\t\t\t }\n\t\t\t\t\t\t\t: {}\n\t\t\t\t\t}\n\t\t\t\t\ttooltipText={\n\t\t\t\t\t\tname ||\n\t\t\t\t\t\t// translators: %s: color hex code e.g: \"#f00\".\n\t\t\t\t\t\tsprintf( __( 'Color code: %s' ), color )\n\t\t\t\t\t}\n\t\t\t\t\tstyle={ { backgroundColor: color, color } }\n\t\t\t\t\tonClick={\n\t\t\t\t\t\tvalue === color ? clearColor : () => onChange( color )\n\t\t\t\t\t}\n\t\t\t\t\taria-label={\n\t\t\t\t\t\tname\n\t\t\t\t\t\t\t? // translators: %s: The name of the color e.g: \"vivid red\".\n\t\t\t\t\t\t\t sprintf( __( 'Color: %s' ), name )\n\t\t\t\t\t\t\t: // translators: %s: color hex code e.g: \"#f00\".\n\t\t\t\t\t\t\t sprintf( __( 'Color code: %s' ), color )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t);\n\t\t} );\n\t}, [ colors, value, onChange, clearColor ] );\n\treturn (\n\t\t<CircularOptionPicker\n\t\t\tclassName={ className }\n\t\t\toptions={ colorOptions }\n\t\t\tactions={ actions }\n\t\t/>\n\t);\n}\n\nfunction MultiplePalettes( {\n\tclassName,\n\tclearColor,\n\tcolors,\n\tonChange,\n\tvalue,\n\tactions,\n} ) {\n\treturn (\n\t\t<VStack spacing={ 3 } className={ className }>\n\t\t\t{ colors.map( ( { name, colors: colorPalette }, index ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<VStack spacing={ 2 } key={ index }>\n\t\t\t\t\t\t<ColorHeading>{ name }</ColorHeading>\n\t\t\t\t\t\t<SinglePalette\n\t\t\t\t\t\t\tclearColor={ clearColor }\n\t\t\t\t\t\t\tcolors={ colorPalette }\n\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\t\tactions={\n\t\t\t\t\t\t\t\tcolors.length === index + 1 ? actions : null\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</VStack>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</VStack>\n\t);\n}\n\nexport function CustomColorPickerDropdown( { isRenderedInSidebar, ...props } ) {\n\treturn (\n\t\t<Dropdown\n\t\t\tcontentClassName={ classnames(\n\t\t\t\t'components-color-palette__custom-color-dropdown-content',\n\t\t\t\t{\n\t\t\t\t\t'is-rendered-in-sidebar': isRenderedInSidebar,\n\t\t\t\t}\n\t\t\t) }\n\t\t\t{ ...props }\n\t\t/>\n\t);\n}\n\nconst extractColorNameFromCurrentValue = (\n\tcurrentValue,\n\tcolors = [],\n\tshowMultiplePalettes = false\n) => {\n\tif ( ! currentValue ) {\n\t\treturn '';\n\t}\n\n\t// Normalize format of `colors` to simplify the following loop\n\tconst colorPalettes = showMultiplePalettes ? colors : [ { colors } ];\n\tfor ( const { colors: paletteColors } of colorPalettes ) {\n\t\tfor ( const { name: colorName, color: colorValue } of paletteColors ) {\n\t\t\tif (\n\t\t\t\tcolord( currentValue ).toHex() === colord( colorValue ).toHex()\n\t\t\t) {\n\t\t\t\treturn colorName;\n\t\t\t}\n\t\t}\n\t}\n\n\t// translators: shown when the user has picked a custom color (i.e not in the palette of colors).\n\treturn __( 'Custom' );\n};\n\nexport default function ColorPalette( {\n\tclearable = true,\n\tclassName,\n\tcolors,\n\tdisableCustomColors = false,\n\tenableAlpha,\n\tonChange,\n\tvalue,\n\t__experimentalHasMultipleOrigins = false,\n\t__experimentalIsRenderedInSidebar = false,\n} ) {\n\tconst clearColor = useCallback( () => onChange( undefined ), [ onChange ] );\n\tconst showMultiplePalettes =\n\t\t__experimentalHasMultipleOrigins && colors?.length;\n\tconst Component = showMultiplePalettes ? MultiplePalettes : SinglePalette;\n\n\tconst renderCustomColorPicker = () => (\n\t\t<ColorPicker\n\t\t\tcolor={ value }\n\t\t\tonChange={ ( color ) => onChange( color ) }\n\t\t\tenableAlpha={ enableAlpha }\n\t\t/>\n\t);\n\n\tlet dropdownPosition;\n\tif ( __experimentalIsRenderedInSidebar ) {\n\t\tdropdownPosition = 'bottom left';\n\t}\n\n\tconst colordColor = colord( value );\n\n\tconst valueWithoutLeadingHash = value?.startsWith( '#' )\n\t\t? value.substring( 1 )\n\t\t: value ?? '';\n\tconst buttonLabelName = useMemo(\n\t\t() =>\n\t\t\textractColorNameFromCurrentValue(\n\t\t\t\tvalue,\n\t\t\t\tcolors,\n\t\t\t\tshowMultiplePalettes\n\t\t\t),\n\t\t[ value, colors, showMultiplePalettes ]\n\t);\n\n\tconst customColorAccessibleLabel = !! valueWithoutLeadingHash\n\t\t? sprintf(\n\t\t\t\t// translators: %1$s: The name of the color e.g: \"vivid red\". %2$s: The color's hex code e.g: \"#f00\".\n\t\t\t\t__(\n\t\t\t\t\t'Custom color picker. The currently selected color is called \"%1$s\" and has a value of \"%2$s\".'\n\t\t\t\t),\n\t\t\t\tbuttonLabelName,\n\t\t\t\tvalueWithoutLeadingHash\n\t\t )\n\t\t: __( 'Custom color picker.' );\n\n\treturn (\n\t\t<VStack spacing={ 3 } className={ className }>\n\t\t\t{ ! disableCustomColors && (\n\t\t\t\t<CustomColorPickerDropdown\n\t\t\t\t\tposition={ dropdownPosition }\n\t\t\t\t\tisRenderedInSidebar={ __experimentalIsRenderedInSidebar }\n\t\t\t\t\trenderContent={ renderCustomColorPicker }\n\t\t\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t\t\t<Flex\n\t\t\t\t\t\t\tas={ 'button' }\n\t\t\t\t\t\t\tjustify=\"space-between\"\n\t\t\t\t\t\t\talign=\"flex-start\"\n\t\t\t\t\t\t\tclassName=\"components-color-palette__custom-color\"\n\t\t\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\t\t\taria-haspopup=\"true\"\n\t\t\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\t\t\taria-label={ customColorAccessibleLabel }\n\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\tbackground: value,\n\t\t\t\t\t\t\t\tcolor:\n\t\t\t\t\t\t\t\t\tcolordColor.contrast() >\n\t\t\t\t\t\t\t\t\tcolordColor.contrast( '#000' )\n\t\t\t\t\t\t\t\t\t\t? '#fff'\n\t\t\t\t\t\t\t\t\t\t: '#000',\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<FlexItem\n\t\t\t\t\t\t\t\tisBlock\n\t\t\t\t\t\t\t\tas={ Truncate }\n\t\t\t\t\t\t\t\tclassName=\"components-color-palette__custom-color-name\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ buttonLabelName }\n\t\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t\t\t<FlexItem\n\t\t\t\t\t\t\t\tas=\"span\"\n\t\t\t\t\t\t\t\tclassName=\"components-color-palette__custom-color-value\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ valueWithoutLeadingHash }\n\t\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t\t</Flex>\n\t\t\t\t\t) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t<Component\n\t\t\t\tclearable={ clearable }\n\t\t\t\tclearColor={ clearColor }\n\t\t\t\tcolors={ colors }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tvalue={ value }\n\t\t\t\tactions={\n\t\t\t\t\t!! clearable && (\n\t\t\t\t\t\t<CircularOptionPicker.ButtonAction\n\t\t\t\t\t\t\tonClick={ clearColor }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Clear' ) }\n\t\t\t\t\t\t</CircularOptionPicker.ButtonAction>\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t/>\n\t\t</VStack>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/color-palette/index.js"],"names":["namesPlugin","a11yPlugin","SinglePalette","className","clearColor","colors","onChange","value","actions","colorOptions","color","name","colordColor","fill","contrast","backgroundColor","MultiplePalettes","map","index","colorPalette","length","CustomColorPickerDropdown","isRenderedInSidebar","props","placement","offset","undefined","extractColorNameFromCurrentValue","currentValue","showMultiplePalettes","colorPalettes","paletteColors","colorName","colorValue","toHex","ColorPalette","clearable","disableCustomColors","enableAlpha","__experimentalHasMultipleOrigins","__experimentalIsRenderedInSidebar","Component","renderCustomColorPicker","valueWithoutLeadingHash","startsWith","substring","buttonLabelName","customColorAccessibleLabel","isOpen","onToggle","background","Truncate"],"mappings":";;;;;;;;;;AAaA;;;;AATA;;AACA;;AACA;;AACA;;AAKA;;AAMA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAxBA;;AACA;AACA;AACA;;AAMA;AACA;AACA;;AAIA;AACA;AACA;AASA,oBAAQ,CAAEA,cAAF,EAAeC,aAAf,CAAR;;AAEA,SAASC,aAAT,OAOI;AAAA,MAPoB;AACvBC,IAAAA,SADuB;AAEvBC,IAAAA,UAFuB;AAGvBC,IAAAA,MAHuB;AAIvBC,IAAAA,QAJuB;AAKvBC,IAAAA,KALuB;AAMvBC,IAAAA;AANuB,GAOpB;AACH,QAAMC,YAAY,GAAG,sBAAS,MAAM;AACnC,WAAO,iBAAKJ,MAAL,EAAa,SAAuB;AAAA,UAArB;AAAEK,QAAAA,KAAF;AAASC,QAAAA;AAAT,OAAqB;AAC1C,YAAMC,WAAW,GAAG,oBAAQF,KAAR,CAApB;AAEA,aACC,4BAAC,6BAAD,CAAsB,MAAtB;AACC,QAAA,GAAG,EAAGA,KADP;AAEC,QAAA,UAAU,EAAGH,KAAK,KAAKG,KAFxB;AAGC,Q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C,IAAA,SAAS,EAAGP,SADb;AAEC,IAAA,UAAU,EAAGhC,UAFd;AAGC,IAAA,MAAM,EAAGC,MAHV;AAIC,IAAA,QAAQ,EAAGC,QAJZ;AAKC,IAAA,KAAK,EAAGC,KALT;AAMC,IAAA,OAAO,EACN,CAAC,CAAE6B,SAAH,IACC,4BAAC,6BAAD,CAAsB,YAAtB;AACC,MAAA,OAAO,EAAGhC;AADX,OAGG,cAAI,OAAJ,CAHH;AARH,IAzCD,CADD;AA4DA","sourcesContent":["// @ts-nocheck\n/**\n * External dependencies\n */\nimport { map } from 'lodash';\nimport { colord, extend } from 'colord';\nimport namesPlugin from 'colord/plugins/names';\nimport a11yPlugin from 'colord/plugins/a11y';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useCallback, useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport Dropdown from '../dropdown';\nimport { ColorPicker } from '../color-picker';\nimport CircularOptionPicker from '../circular-option-picker';\nimport { VStack } from '../v-stack';\nimport { Flex, FlexItem } from '../flex';\nimport { Truncate } from '../truncate';\nimport { ColorHeading } from './styles';\n\nextend( [ namesPlugin, a11yPlugin ] );\n\nfunction SinglePalette( {\n\tclassName,\n\tclearColor,\n\tcolors,\n\tonChange,\n\tvalue,\n\tactions,\n} ) {\n\tconst colorOptions = useMemo( () => {\n\t\treturn map( colors, ( { color, name } ) => {\n\t\t\tconst colordColor = colord( color );\n\n\t\t\treturn (\n\t\t\t\t<CircularOptionPicker.Option\n\t\t\t\t\tkey={ color }\n\t\t\t\t\tisSelected={ value === color }\n\t\t\t\t\tselectedIconProps={\n\t\t\t\t\t\tvalue === color\n\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\tfill:\n\t\t\t\t\t\t\t\t\t\tcolordColor.contrast() >\n\t\t\t\t\t\t\t\t\t\tcolordColor.contrast( '#000' )\n\t\t\t\t\t\t\t\t\t\t\t? '#fff'\n\t\t\t\t\t\t\t\t\t\t\t: '#000',\n\t\t\t\t\t\t\t }\n\t\t\t\t\t\t\t: {}\n\t\t\t\t\t}\n\t\t\t\t\ttooltipText={\n\t\t\t\t\t\tname ||\n\t\t\t\t\t\t// translators: %s: color hex code e.g: \"#f00\".\n\t\t\t\t\t\tsprintf( __( 'Color code: %s' ), color )\n\t\t\t\t\t}\n\t\t\t\t\tstyle={ { backgroundColor: color, color } }\n\t\t\t\t\tonClick={\n\t\t\t\t\t\tvalue === color ? clearColor : () => onChange( color )\n\t\t\t\t\t}\n\t\t\t\t\taria-label={\n\t\t\t\t\t\tname\n\t\t\t\t\t\t\t? // translators: %s: The name of the color e.g: \"vivid red\".\n\t\t\t\t\t\t\t sprintf( __( 'Color: %s' ), name )\n\t\t\t\t\t\t\t: // translators: %s: color hex code e.g: \"#f00\".\n\t\t\t\t\t\t\t sprintf( __( 'Color code: %s' ), color )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t);\n\t\t} );\n\t}, [ colors, value, onChange, clearColor ] );\n\treturn (\n\t\t<CircularOptionPicker\n\t\t\tclassName={ className }\n\t\t\toptions={ colorOptions }\n\t\t\tactions={ actions }\n\t\t/>\n\t);\n}\n\nfunction MultiplePalettes( {\n\tclassName,\n\tclearColor,\n\tcolors,\n\tonChange,\n\tvalue,\n\tactions,\n} ) {\n\treturn (\n\t\t<VStack spacing={ 3 } className={ className }>\n\t\t\t{ colors.map( ( { name, colors: colorPalette }, index ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<VStack spacing={ 2 } key={ index }>\n\t\t\t\t\t\t<ColorHeading>{ name }</ColorHeading>\n\t\t\t\t\t\t<SinglePalette\n\t\t\t\t\t\t\tclearColor={ clearColor }\n\t\t\t\t\t\t\tcolors={ colorPalette }\n\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\t\tactions={\n\t\t\t\t\t\t\t\tcolors.length === index + 1 ? actions : null\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</VStack>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</VStack>\n\t);\n}\n\nexport function CustomColorPickerDropdown( { isRenderedInSidebar, ...props } ) {\n\treturn (\n\t\t<Dropdown\n\t\t\tcontentClassName=\"components-color-palette__custom-color-dropdown-content\"\n\t\t\tpopoverProps={\n\t\t\t\tisRenderedInSidebar\n\t\t\t\t\t? { placement: 'left-start', offset: 20 }\n\t\t\t\t\t: undefined\n\t\t\t}\n\t\t\t{ ...props }\n\t\t/>\n\t);\n}\n\nconst extractColorNameFromCurrentValue = (\n\tcurrentValue,\n\tcolors = [],\n\tshowMultiplePalettes = false\n) => {\n\tif ( ! currentValue ) {\n\t\treturn '';\n\t}\n\n\t// Normalize format of `colors` to simplify the following loop\n\tconst colorPalettes = showMultiplePalettes ? colors : [ { colors } ];\n\tfor ( const { colors: paletteColors } of colorPalettes ) {\n\t\tfor ( const { name: colorName, color: colorValue } of paletteColors ) {\n\t\t\tif (\n\t\t\t\tcolord( currentValue ).toHex() === colord( colorValue ).toHex()\n\t\t\t) {\n\t\t\t\treturn colorName;\n\t\t\t}\n\t\t}\n\t}\n\n\t// translators: shown when the user has picked a custom color (i.e not in the palette of colors).\n\treturn __( 'Custom' );\n};\n\nexport default function ColorPalette( {\n\tclearable = true,\n\tclassName,\n\tcolors,\n\tdisableCustomColors = false,\n\tenableAlpha,\n\tonChange,\n\tvalue,\n\t__experimentalHasMultipleOrigins = false,\n\t__experimentalIsRenderedInSidebar = false,\n} ) {\n\tconst clearColor = useCallback( () => onChange( undefined ), [ onChange ] );\n\tconst showMultiplePalettes =\n\t\t__experimentalHasMultipleOrigins && colors?.length;\n\tconst Component = showMultiplePalettes ? MultiplePalettes : SinglePalette;\n\n\tconst renderCustomColorPicker = () => (\n\t\t<ColorPicker\n\t\t\tcolor={ value }\n\t\t\tonChange={ ( color ) => onChange( color ) }\n\t\t\tenableAlpha={ enableAlpha }\n\t\t/>\n\t);\n\n\tconst colordColor = colord( value );\n\n\tconst valueWithoutLeadingHash = value?.startsWith( '#' )\n\t\t? value.substring( 1 )\n\t\t: value ?? '';\n\tconst buttonLabelName = useMemo(\n\t\t() =>\n\t\t\textractColorNameFromCurrentValue(\n\t\t\t\tvalue,\n\t\t\t\tcolors,\n\t\t\t\tshowMultiplePalettes\n\t\t\t),\n\t\t[ value, colors, showMultiplePalettes ]\n\t);\n\n\tconst customColorAccessibleLabel = !! valueWithoutLeadingHash\n\t\t? sprintf(\n\t\t\t\t// translators: %1$s: The name of the color e.g: \"vivid red\". %2$s: The color's hex code e.g: \"#f00\".\n\t\t\t\t__(\n\t\t\t\t\t'Custom color picker. The currently selected color is called \"%1$s\" and has a value of \"%2$s\".'\n\t\t\t\t),\n\t\t\t\tbuttonLabelName,\n\t\t\t\tvalueWithoutLeadingHash\n\t\t )\n\t\t: __( 'Custom color picker.' );\n\n\treturn (\n\t\t<VStack spacing={ 3 } className={ className }>\n\t\t\t{ ! disableCustomColors && (\n\t\t\t\t<CustomColorPickerDropdown\n\t\t\t\t\tisRenderedInSidebar={ __experimentalIsRenderedInSidebar }\n\t\t\t\t\trenderContent={ renderCustomColorPicker }\n\t\t\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t\t\t<Flex\n\t\t\t\t\t\t\tas={ 'button' }\n\t\t\t\t\t\t\tjustify=\"space-between\"\n\t\t\t\t\t\t\talign=\"flex-start\"\n\t\t\t\t\t\t\tclassName=\"components-color-palette__custom-color\"\n\t\t\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\t\t\taria-haspopup=\"true\"\n\t\t\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\t\t\taria-label={ customColorAccessibleLabel }\n\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\tbackground: value,\n\t\t\t\t\t\t\t\tcolor:\n\t\t\t\t\t\t\t\t\tcolordColor.contrast() >\n\t\t\t\t\t\t\t\t\tcolordColor.contrast( '#000' )\n\t\t\t\t\t\t\t\t\t\t? '#fff'\n\t\t\t\t\t\t\t\t\t\t: '#000',\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<FlexItem\n\t\t\t\t\t\t\t\tisBlock\n\t\t\t\t\t\t\t\tas={ Truncate }\n\t\t\t\t\t\t\t\tclassName=\"components-color-palette__custom-color-name\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ buttonLabelName }\n\t\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t\t\t<FlexItem\n\t\t\t\t\t\t\t\tas=\"span\"\n\t\t\t\t\t\t\t\tclassName=\"components-color-palette__custom-color-value\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ valueWithoutLeadingHash }\n\t\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t\t</Flex>\n\t\t\t\t\t) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t<Component\n\t\t\t\tclearable={ clearable }\n\t\t\t\tclearColor={ clearColor }\n\t\t\t\tcolors={ colors }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tvalue={ value }\n\t\t\t\tactions={\n\t\t\t\t\t!! clearable && (\n\t\t\t\t\t\t<CircularOptionPicker.ButtonAction\n\t\t\t\t\t\t\tonClick={ clearColor }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Clear' ) }\n\t\t\t\t\t\t</CircularOptionPicker.ButtonAction>\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t/>\n\t\t</VStack>\n\t);\n}\n"]}
@@ -5,6 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
+ exports.DatePicker = DatePicker;
8
9
  exports.default = void 0;
9
10
 
10
11
  var _element = require("@wordpress/element");
@@ -13,6 +14,8 @@ var _moment = _interopRequireDefault(require("moment"));
13
14
 
14
15
  var _classnames = _interopRequireDefault(require("classnames"));
15
16
 
17
+ var _lodash = require("lodash");
18
+
16
19
  var _DayPickerSingleDateController = _interopRequireDefault(require("react-dates/lib/components/DayPickerSingleDateController"));
17
20
 
18
21
  var _i18n = require("@wordpress/i18n");
@@ -22,20 +25,16 @@ var _utils = require("./utils");
22
25
  /**
23
26
  * External dependencies
24
27
  */
25
- // react-dates doesn't tree-shake correctly, so we import from the individual
26
- // component here, to avoid including too much of the library
27
-
28
+ // `react-dates` doesn't tree-shake correctly, so we import from the individual
29
+ // component here.
30
+ // @ts-expect-error TypeScript won't find any type declarations at
31
+ // `react-dates/lib/components/DayPickerSingleDateController` as they're located
32
+ // at `react-dates`.
33
+ const TypedDayPickerSingleDateController = _DayPickerSingleDateController.default;
28
34
  /**
29
35
  * WordPress dependencies
30
36
  */
31
37
 
32
- /**
33
- * Internal dependencies
34
- */
35
-
36
- /**
37
- * Module Constants
38
- */
39
38
  const TIMEZONELESS_FORMAT = 'YYYY-MM-DDTHH:mm:ss';
40
39
  const ARIAL_LABEL_TIME_FORMAT = 'dddd, LL';
41
40
 
@@ -44,7 +43,7 @@ function DatePickerDay(_ref) {
44
43
  day,
45
44
  events = []
46
45
  } = _ref;
47
- const ref = (0, _element.useRef)();
46
+ const ref = (0, _element.useRef)(null);
48
47
  /*
49
48
  * a11y hack to make the `There is/are n events` string
50
49
  * available speaking for readers,
@@ -56,7 +55,7 @@ function DatePickerDay(_ref) {
56
55
  var _ref$current;
57
56
 
58
57
  // Bail when no parent node.
59
- if (!(ref !== null && ref !== void 0 && (_ref$current = ref.current) !== null && _ref$current !== void 0 && _ref$current.parentNode)) {
58
+ if (!((ref === null || ref === void 0 ? void 0 : (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.parentNode) instanceof Element)) {
60
59
  return;
61
60
  }
62
61
 
@@ -82,6 +81,26 @@ function DatePickerDay(_ref) {
82
81
  })
83
82
  }, day.format('D'));
84
83
  }
84
+ /**
85
+ * DatePicker is a React component that renders a calendar for date selection.
86
+ *
87
+ * ```jsx
88
+ * import { DatePicker } from '@wordpress/components';
89
+ * import { useState } from '@wordpress/element';
90
+ *
91
+ * const MyDatePicker = () => {
92
+ * const [ date, setDate ] = useState( new Date() );
93
+ *
94
+ * return (
95
+ * <DatePicker
96
+ * currentDate={ date }
97
+ * onChange={ ( newDate ) => setDate( newDate ) }
98
+ * />
99
+ * );
100
+ * };
101
+ * ```
102
+ */
103
+
85
104
 
86
105
  function DatePicker(_ref2) {
87
106
  let {
@@ -91,7 +110,7 @@ function DatePicker(_ref2) {
91
110
  isInvalidDate,
92
111
  onMonthPreviewed
93
112
  } = _ref2;
94
- const nodeRef = (0, _element.useRef)();
113
+ const nodeRef = (0, _element.useRef)(null);
95
114
 
96
115
  const onMonthPreviewedHandler = newMonthDate => {
97
116
  onMonthPreviewed === null || onMonthPreviewed === void 0 ? void 0 : onMonthPreviewed(newMonthDate.toISOString());
@@ -121,7 +140,7 @@ function DatePicker(_ref2) {
121
140
  // Retrieve the focus region div.
122
141
  const focusRegion = nodeRef.current.querySelector('.DayPicker_focusRegion');
123
142
 
124
- if (!focusRegion) {
143
+ if (!(focusRegion instanceof HTMLElement)) {
125
144
  return;
126
145
  } // Keep the focus on focus region.
127
146
 
@@ -131,14 +150,18 @@ function DatePicker(_ref2) {
131
150
  };
132
151
 
133
152
  const onChangeMoment = newDate => {
134
- // If currentDate is null, use now as momentTime to designate hours, minutes, seconds.
153
+ if (!newDate) {
154
+ return;
155
+ } // If currentDate is null, use now as momentTime to designate hours, minutes, seconds.
156
+
157
+
135
158
  const momentDate = currentDate ? (0, _moment.default)(currentDate) : (0, _moment.default)();
136
159
  const momentTime = {
137
160
  hours: momentDate.hours(),
138
161
  minutes: momentDate.minutes(),
139
162
  seconds: 0
140
163
  };
141
- onChange(newDate.set(momentTime).format(TIMEZONELESS_FORMAT)); // Keep focus on the date picker.
164
+ onChange === null || onChange === void 0 ? void 0 : onChange(newDate.set(momentTime).format(TIMEZONELESS_FORMAT)); // Keep focus on the date picker.
142
165
 
143
166
  keepFocusInside();
144
167
  };
@@ -155,7 +178,7 @@ function DatePicker(_ref2) {
155
178
  return (0, _element.createElement)("div", {
156
179
  className: "components-datetime__date",
157
180
  ref: nodeRef
158
- }, (0, _element.createElement)(_DayPickerSingleDateController.default, {
181
+ }, (0, _element.createElement)(TypedDayPickerSingleDateController, {
159
182
  date: momentDate,
160
183
  daySize: 30,
161
184
  focused: true,
@@ -171,14 +194,15 @@ function DatePicker(_ref2) {
171
194
  dayAriaLabelFormat: ARIAL_LABEL_TIME_FORMAT,
172
195
  isRTL: (0, _i18n.isRTL)(),
173
196
  isOutsideRange: date => {
174
- return isInvalidDate && isInvalidDate(date.toDate());
197
+ return !!isInvalidDate && isInvalidDate(date.toDate());
175
198
  },
176
199
  onPrevMonthClick: onMonthPreviewedHandler,
177
200
  onNextMonthClick: onMonthPreviewedHandler,
178
201
  renderDayContents: day => (0, _element.createElement)(DatePickerDay, {
179
202
  day: day,
180
203
  events: getEventsPerDay(day)
181
- })
204
+ }),
205
+ onFocusChange: _lodash.noop
182
206
  }));
183
207
  }
184
208
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/date-time/date.js"],"names":["TIMEZONELESS_FORMAT","ARIAL_LABEL_TIME_FORMAT","DatePickerDay","day","events","ref","current","parentNode","dayAriaLabel","format","length","setAttribute","dayWithEventsDescription","DatePicker","currentDate","onChange","isInvalidDate","onMonthPreviewed","nodeRef","onMonthPreviewedHandler","newMonthDate","toISOString","keepFocusInside","ownerDocument","activeElement","contains","focusRegion","querySelector","focus","onChangeMoment","newDate","momentDate","momentTime","hours","minutes","seconds","set","getEventsPerDay","filter","eventDay","isSame","date","toDate"],"mappings":";;;;;;;;;AAaA;;AAVA;;AACA;;AAIA;;AAMA;;AAKA;;AAnBA;AACA;AACA;AAIA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;;AAGA;AACA;AACA;AACA,MAAMA,mBAAmB,GAAG,qBAA5B;AACA,MAAMC,uBAAuB,GAAG,UAA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moment';\nimport classnames from 'classnames';\n\n// react-dates doesn't tree-shake correctly, so we import from the individual\n// component here, to avoid including too much of the library\nimport DayPickerSingleDateController from 'react-dates/lib/components/DayPickerSingleDateController';\n\n/**\n * WordPress dependencies\n */\nimport { useEffect, useRef } from '@wordpress/element';\nimport { isRTL, _n, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { getMomentDate } from './utils';\n\n/**\n * Module Constants\n */\nconst TIMEZONELESS_FORMAT = 'YYYY-MM-DDTHH:mm:ss';\nconst ARIAL_LABEL_TIME_FORMAT = 'dddd, LL';\n\nfunction DatePickerDay( { day, events = [] } ) {\n\tconst ref = useRef();\n\n\t/*\n\t * a11y hack to make the `There is/are n events` string\n\t * available speaking for readers,\n\t * re-defining the aria-label attribute.\n\t * This attribute is handled by the react-dates component.\n\t */\n\tuseEffect( () => {\n\t\t// Bail when no parent node.\n\t\tif ( ! ref?.current?.parentNode ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { parentNode } = ref.current;\n\t\tconst dayAriaLabel = moment( day ).format( ARIAL_LABEL_TIME_FORMAT );\n\n\t\tif ( ! events.length ) {\n\t\t\t// Set aria-label without event description.\n\t\t\tparentNode.setAttribute( 'aria-label', dayAriaLabel );\n\t\t\treturn;\n\t\t}\n\n\t\tconst dayWithEventsDescription = sprintf(\n\t\t\t// translators: 1: Calendar day format, 2: Calendar event number.\n\t\t\t_n(\n\t\t\t\t'%1$s. There is %2$d event.',\n\t\t\t\t'%1$s. There are %2$d events.',\n\t\t\t\tevents.length\n\t\t\t),\n\t\t\tdayAriaLabel,\n\t\t\tevents.length\n\t\t);\n\n\t\tparentNode.setAttribute( 'aria-label', dayWithEventsDescription );\n\t}, [ events.length ] );\n\n\treturn (\n\t\t<div\n\t\t\tref={ ref }\n\t\t\tclassName={ classnames( 'components-datetime__date__day', {\n\t\t\t\t'has-events': events?.length,\n\t\t\t} ) }\n\t\t>\n\t\t\t{ day.format( 'D' ) }\n\t\t</div>\n\t);\n}\n\nfunction DatePicker( {\n\tcurrentDate,\n\tonChange,\n\tevents,\n\tisInvalidDate,\n\tonMonthPreviewed,\n} ) {\n\tconst nodeRef = useRef();\n\tconst onMonthPreviewedHandler = ( newMonthDate ) => {\n\t\tonMonthPreviewed?.( newMonthDate.toISOString() );\n\t\tkeepFocusInside();\n\t};\n\n\t/*\n\t * Todo: We should remove this function ASAP.\n\t * It is kept because focus is lost when we click on the previous and next month buttons.\n\t * This focus loss closes the date picker popover.\n\t * Ideally we should add an upstream commit on react-dates to fix this issue.\n\t */\n\tconst keepFocusInside = () => {\n\t\tif ( ! nodeRef.current ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { ownerDocument } = nodeRef.current;\n\t\tconst { activeElement } = ownerDocument;\n\n\t\t// If focus was lost.\n\t\tif (\n\t\t\t! activeElement ||\n\t\t\t! nodeRef.current.contains( ownerDocument.activeElement )\n\t\t) {\n\t\t\t// Retrieve the focus region div.\n\t\t\tconst focusRegion = nodeRef.current.querySelector(\n\t\t\t\t'.DayPicker_focusRegion'\n\t\t\t);\n\t\t\tif ( ! focusRegion ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Keep the focus on focus region.\n\t\t\tfocusRegion.focus();\n\t\t}\n\t};\n\n\tconst onChangeMoment = ( newDate ) => {\n\t\t// If currentDate is null, use now as momentTime to designate hours, minutes, seconds.\n\t\tconst momentDate = currentDate ? moment( currentDate ) : moment();\n\t\tconst momentTime = {\n\t\t\thours: momentDate.hours(),\n\t\t\tminutes: momentDate.minutes(),\n\t\t\tseconds: 0,\n\t\t};\n\n\t\tonChange( newDate.set( momentTime ).format( TIMEZONELESS_FORMAT ) );\n\n\t\t// Keep focus on the date picker.\n\t\tkeepFocusInside();\n\t};\n\n\tconst getEventsPerDay = ( day ) => {\n\t\tif ( ! events?.length ) {\n\t\t\treturn [];\n\t\t}\n\n\t\treturn events.filter( ( eventDay ) =>\n\t\t\tday.isSame( eventDay.date, 'day' )\n\t\t);\n\t};\n\n\tconst momentDate = getMomentDate( currentDate );\n\n\treturn (\n\t\t<div className=\"components-datetime__date\" ref={ nodeRef }>\n\t\t\t<DayPickerSingleDateController\n\t\t\t\tdate={ momentDate }\n\t\t\t\tdaySize={ 30 }\n\t\t\t\tfocused\n\t\t\t\thideKeyboardShortcutsPanel\n\t\t\t\t// This is a hack to force the calendar to update on month or year change\n\t\t\t\t// https://github.com/airbnb/react-dates/issues/240#issuecomment-361776665\n\t\t\t\tkey={ `datepicker-controller-${\n\t\t\t\t\tmomentDate ? momentDate.format( 'MM-YYYY' ) : 'null'\n\t\t\t\t}` }\n\t\t\t\tnoBorder\n\t\t\t\tnumberOfMonths={ 1 }\n\t\t\t\tonDateChange={ onChangeMoment }\n\t\t\t\ttransitionDuration={ 0 }\n\t\t\t\tweekDayFormat=\"ddd\"\n\t\t\t\tdayAriaLabelFormat={ ARIAL_LABEL_TIME_FORMAT }\n\t\t\t\tisRTL={ isRTL() }\n\t\t\t\tisOutsideRange={ ( date ) => {\n\t\t\t\t\treturn isInvalidDate && isInvalidDate( date.toDate() );\n\t\t\t\t} }\n\t\t\t\tonPrevMonthClick={ onMonthPreviewedHandler }\n\t\t\t\tonNextMonthClick={ onMonthPreviewedHandler }\n\t\t\t\trenderDayContents={ ( day ) => (\n\t\t\t\t\t<DatePickerDay\n\t\t\t\t\t\tday={ day }\n\t\t\t\t\t\tevents={ getEventsPerDay( day ) }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n\nexport default DatePicker;\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/date-time/date.tsx"],"names":["TypedDayPickerSingleDateController","UntypedDayPickerSingleDateController","TIMEZONELESS_FORMAT","ARIAL_LABEL_TIME_FORMAT","DatePickerDay","day","events","ref","current","parentNode","Element","dayAriaLabel","format","length","setAttribute","dayWithEventsDescription","DatePicker","currentDate","onChange","isInvalidDate","onMonthPreviewed","nodeRef","onMonthPreviewedHandler","newMonthDate","toISOString","keepFocusInside","ownerDocument","activeElement","contains","focusRegion","querySelector","HTMLElement","focus","onChangeMoment","newDate","momentDate","momentTime","hours","minutes","seconds","set","getEventsPerDay","filter","eventDay","isSame","date","toDate","noop"],"mappings":";;;;;;;;;;AAoBA;;AAjBA;;AACA;;AAEA;;AAOA;;AAQA;;AAKA;;AA1BA;AACA;AACA;AAMA;AACA;AACA;AACA;AACA;AAGA,MAAMA,kCAAkC,GAAGC,sCAA3C;AAEA;AACA;AACA;;AAUA,MAAMC,mBAAmB,GAAG,qBAA5B;AACA,MAAMC,uBAAuB,GAAG,UAAhC;;AAEA,SAASC,aAAT,OAAmE;AAAA,MAA3C;AAAEC,IAAAA,GAAF;AAAOC,IAAAA,MAAM,GAAG;AAAhB,GAA2C;AAClE,QAAMC,GAAG,GAAG,qBAA0B,IAA1B,CAAZ;AAEA;AACD;AACA;AACA;AACA;AACA;;AACC,0BAAW,MAAM;AAAA;;AAChB;AACA,QAAK,EAAI,CAAAA,GAAG,SAAH,IAAAA,GAAG,WAAH,4BAAAA,GAAG,CAAEC,OAAL,8DAAcC,UAAd,aAAoCC,OAAxC,CAAL,EAAyD;AACxD;AACA;;AAED,UAAM;AAAED,MAAAA;AAAF,QAAiBF,GAAG,CAACC,OAA3B;AACA,UAAMG,YAAY,GAAG,qBAAQN,GAAR,EAAcO,MAAd,CAAsBT,uBAAtB,CAArB;;AAEA,QAAK,CAAEG,MAAM,CAACO,MAAd,EAAuB;AACtB;AACAJ,MAAAA,UAAU,CAACK,YAAX,CAAyB,YAAzB,EAAuCH,YAAvC;AACA;AACA;;AAED,UAAMI,wBAAwB,GAAG,oBAChC;AACA,kBACC,4BADD,EAEC,8BAFD,EAGCT,MAAM,CAACO,MAHR,CAFgC,EAOhCF,YAPgC,EAQhCL,MAAM,CAACO,MARyB,CAAjC;AAWAJ,IAAAA,UAAU,CAACK,YAAX,CAAyB,YAAzB,EAAuCC,wBAAvC;AACA,GA3BD,EA2BG,CAAET,MAAM,CAACO,MAAT,CA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9C,EATF;AAUC,IAAA,QAAQ,MAVT;AAWC,IAAA,cAAc,EAAG,CAXlB;AAYC,IAAA,YAAY,EAAGqB,cAZhB;AAaC,IAAA,kBAAkB,EAAG,CAbtB;AAcC,IAAA,aAAa,EAAC,KAdf;AAeC,IAAA,kBAAkB,EAAG9B,uBAftB;AAgBC,IAAA,KAAK,EAAG,kBAhBT;AAiBC,IAAA,cAAc,EAAK0C,IAAF,IAAY;AAC5B,aAAO,CAAC,CAAE1B,aAAH,IAAoBA,aAAa,CAAE0B,IAAI,CAACC,MAAL,EAAF,CAAxC;AACA,KAnBF;AAoBC,IAAA,gBAAgB,EAAGxB,uBApBpB;AAqBC,IAAA,gBAAgB,EAAGA,uBArBpB;AAsBC,IAAA,iBAAiB,EAAKjB,GAAF,IACnB,4BAAC,aAAD;AACC,MAAA,GAAG,EAAGA,GADP;AAEC,MAAA,MAAM,EAAGoC,eAAe,CAAEpC,GAAF;AAFzB,MAvBF;AA4BC,IAAA,aAAa,EAAG0C;AA5BjB,IADD,CADD;AAkCA;;eAEc/B,U","sourcesContent":["/**\n * External dependencies\n */\nimport moment from 'moment';\nimport classnames from 'classnames';\nimport type { Moment } from 'moment';\nimport { noop } from 'lodash';\n\n// `react-dates` doesn't tree-shake correctly, so we import from the individual\n// component here.\n// @ts-expect-error TypeScript won't find any type declarations at\n// `react-dates/lib/components/DayPickerSingleDateController` as they're located\n// at `react-dates`.\nimport UntypedDayPickerSingleDateController from 'react-dates/lib/components/DayPickerSingleDateController';\nimport type { DayPickerSingleDateController } from 'react-dates';\nconst TypedDayPickerSingleDateController = UntypedDayPickerSingleDateController as DayPickerSingleDateController;\n\n/**\n * WordPress dependencies\n */\nimport { useEffect, useRef } from '@wordpress/element';\nimport { isRTL, _n, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { getMomentDate } from './utils';\nimport type { DatePickerDayProps, DatePickerProps } from './types';\n\nconst TIMEZONELESS_FORMAT = 'YYYY-MM-DDTHH:mm:ss';\nconst ARIAL_LABEL_TIME_FORMAT = 'dddd, LL';\n\nfunction DatePickerDay( { day, events = [] }: DatePickerDayProps ) {\n\tconst ref = useRef< HTMLDivElement >( null );\n\n\t/*\n\t * a11y hack to make the `There is/are n events` string\n\t * available speaking for readers,\n\t * re-defining the aria-label attribute.\n\t * This attribute is handled by the react-dates component.\n\t */\n\tuseEffect( () => {\n\t\t// Bail when no parent node.\n\t\tif ( ! ( ref?.current?.parentNode instanceof Element ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { parentNode } = ref.current;\n\t\tconst dayAriaLabel = moment( day ).format( ARIAL_LABEL_TIME_FORMAT );\n\n\t\tif ( ! events.length ) {\n\t\t\t// Set aria-label without event description.\n\t\t\tparentNode.setAttribute( 'aria-label', dayAriaLabel );\n\t\t\treturn;\n\t\t}\n\n\t\tconst dayWithEventsDescription = sprintf(\n\t\t\t// translators: 1: Calendar day format, 2: Calendar event number.\n\t\t\t_n(\n\t\t\t\t'%1$s. There is %2$d event.',\n\t\t\t\t'%1$s. There are %2$d events.',\n\t\t\t\tevents.length\n\t\t\t),\n\t\t\tdayAriaLabel,\n\t\t\tevents.length\n\t\t);\n\n\t\tparentNode.setAttribute( 'aria-label', dayWithEventsDescription );\n\t}, [ events.length ] );\n\n\treturn (\n\t\t<div\n\t\t\tref={ ref }\n\t\t\tclassName={ classnames( 'components-datetime__date__day', {\n\t\t\t\t'has-events': events?.length,\n\t\t\t} ) }\n\t\t>\n\t\t\t{ day.format( 'D' ) }\n\t\t</div>\n\t);\n}\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 */\nexport function DatePicker( {\n\tcurrentDate,\n\tonChange,\n\tevents,\n\tisInvalidDate,\n\tonMonthPreviewed,\n}: DatePickerProps ) {\n\tconst nodeRef = useRef< HTMLDivElement >( null );\n\tconst onMonthPreviewedHandler = ( newMonthDate: Moment ) => {\n\t\tonMonthPreviewed?.( newMonthDate.toISOString() );\n\t\tkeepFocusInside();\n\t};\n\n\t/*\n\t * Todo: We should remove this function ASAP.\n\t * It is kept because focus is lost when we click on the previous and next month buttons.\n\t * This focus loss closes the date picker popover.\n\t * Ideally we should add an upstream commit on react-dates to fix this issue.\n\t */\n\tconst keepFocusInside = () => {\n\t\tif ( ! nodeRef.current ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { ownerDocument } = nodeRef.current;\n\t\tconst { activeElement } = ownerDocument;\n\n\t\t// If focus was lost.\n\t\tif (\n\t\t\t! activeElement ||\n\t\t\t! nodeRef.current.contains( ownerDocument.activeElement )\n\t\t) {\n\t\t\t// Retrieve the focus region div.\n\t\t\tconst focusRegion = nodeRef.current.querySelector(\n\t\t\t\t'.DayPicker_focusRegion'\n\t\t\t);\n\t\t\tif ( ! ( focusRegion instanceof HTMLElement ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Keep the focus on focus region.\n\t\t\tfocusRegion.focus();\n\t\t}\n\t};\n\n\tconst onChangeMoment = ( newDate: Moment | null ) => {\n\t\tif ( ! newDate ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// If currentDate is null, use now as momentTime to designate hours, minutes, seconds.\n\t\tconst momentDate = currentDate ? moment( currentDate ) : moment();\n\t\tconst momentTime = {\n\t\t\thours: momentDate.hours(),\n\t\t\tminutes: momentDate.minutes(),\n\t\t\tseconds: 0,\n\t\t};\n\n\t\tonChange?.( newDate.set( momentTime ).format( TIMEZONELESS_FORMAT ) );\n\n\t\t// Keep focus on the date picker.\n\t\tkeepFocusInside();\n\t};\n\n\tconst getEventsPerDay = ( day: Moment ) => {\n\t\tif ( ! events?.length ) {\n\t\t\treturn [];\n\t\t}\n\n\t\treturn events.filter( ( eventDay ) =>\n\t\t\tday.isSame( eventDay.date, 'day' )\n\t\t);\n\t};\n\n\tconst momentDate = getMomentDate( currentDate );\n\n\treturn (\n\t\t<div className=\"components-datetime__date\" ref={ nodeRef }>\n\t\t\t<TypedDayPickerSingleDateController\n\t\t\t\tdate={ momentDate }\n\t\t\t\tdaySize={ 30 }\n\t\t\t\tfocused\n\t\t\t\thideKeyboardShortcutsPanel\n\t\t\t\t// This is a hack to force the calendar to update on month or year change\n\t\t\t\t// https://github.com/airbnb/react-dates/issues/240#issuecomment-361776665\n\t\t\t\tkey={ `datepicker-controller-${\n\t\t\t\t\tmomentDate ? momentDate.format( 'MM-YYYY' ) : 'null'\n\t\t\t\t}` }\n\t\t\t\tnoBorder\n\t\t\t\tnumberOfMonths={ 1 }\n\t\t\t\tonDateChange={ onChangeMoment }\n\t\t\t\ttransitionDuration={ 0 }\n\t\t\t\tweekDayFormat=\"ddd\"\n\t\t\t\tdayAriaLabelFormat={ ARIAL_LABEL_TIME_FORMAT }\n\t\t\t\tisRTL={ isRTL() }\n\t\t\t\tisOutsideRange={ ( date ) => {\n\t\t\t\t\treturn !! isInvalidDate && isInvalidDate( date.toDate() );\n\t\t\t\t} }\n\t\t\t\tonPrevMonthClick={ onMonthPreviewedHandler }\n\t\t\t\tonNextMonthClick={ onMonthPreviewedHandler }\n\t\t\t\trenderDayContents={ ( day ) => (\n\t\t\t\t\t<DatePickerDay\n\t\t\t\t\t\tday={ day }\n\t\t\t\t\t\tevents={ getEventsPerDay( day ) }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\tonFocusChange={ noop }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n\nexport default DatePicker;\n"]}
@@ -11,6 +11,7 @@ Object.defineProperty(exports, "DatePicker", {
11
11
  return _date.default;
12
12
  }
13
13
  });
14
+ exports.DateTimePicker = void 0;
14
15
  Object.defineProperty(exports, "TimePicker", {
15
16
  enumerable: true,
16
17
  get: function () {
@@ -46,7 +47,7 @@ var _time = _interopRequireDefault(require("./time"));
46
47
  /**
47
48
  * Internal dependencies
48
49
  */
49
- function DateTimePicker(_ref, ref) {
50
+ function UnforwardedDateTimePicker(_ref, ref) {
50
51
  let {
51
52
  currentDate,
52
53
  is12Hour,
@@ -101,15 +102,39 @@ function DateTimePicker(_ref, ref) {
101
102
  }, !calendarHelpIsVisible && currentDate && (0, _element.createElement)(_button.default, {
102
103
  className: "components-datetime__date-reset-button",
103
104
  variant: "link",
104
- onClick: () => onChange(null)
105
+ onClick: () => onChange === null || onChange === void 0 ? void 0 : onChange(null)
105
106
  }, (0, _i18n.__)('Reset')), (0, _element.createElement)(_button.default, {
106
107
  className: "components-datetime__date-help-toggle",
107
108
  variant: "link",
108
109
  onClick: onClickDescriptionToggle
109
110
  }, calendarHelpIsVisible ? (0, _i18n.__)('Close') : (0, _i18n.__)('Calendar Help'))));
110
111
  }
112
+ /**
113
+ * DateTimePicker is a React component that renders a calendar and clock for
114
+ * date and time selection. The calendar and clock components can be accessed
115
+ * individually using the `DatePicker` and `TimePicker` components respectively.
116
+ *
117
+ * ```jsx
118
+ * import { DateTimePicker } from '@wordpress/components';
119
+ * import { useState } from '@wordpress/element';
120
+ *
121
+ * const MyDateTimePicker = () => {
122
+ * const [ date, setDate ] = useState( new Date() );
123
+ *
124
+ * return (
125
+ * <DateTimePicker
126
+ * currentDate={ date }
127
+ * onChange={ ( newDate ) => setDate( newDate ) }
128
+ * is12Hour
129
+ * />
130
+ * );
131
+ * };
132
+ * ```
133
+ */
111
134
 
112
- var _default = (0, _element.forwardRef)(DateTimePicker);
113
135
 
136
+ const DateTimePicker = (0, _element.forwardRef)(UnforwardedDateTimePicker);
137
+ exports.DateTimePicker = DateTimePicker;
138
+ var _default = DateTimePicker;
114
139
  exports.default = _default;
115
140
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/date-time/index.js"],"names":["DateTimePicker","ref","currentDate","is12Hour","isInvalidDate","onMonthPreviewed","noop","onChange","events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N,IAYC,0CACG,cAAI,2BAAJ,CADH,CAZD,CADD,EAiBC,wCACC;AACC,kBAAa,cAAI,uBAAJ;AADd,qBADD,EAOE;AAAI;AAPN,IASG,cACD,qDADC,CATH,CAjBD,EA8BC,wCACC;AAAM,kBAAa,cAAI,oBAAJ;AAAnB,qBADD,EAKE;AAAI;AALN,IAOG,cACD,mDADC,CAPH,CA9BD,EAyCC,wCACC;AACC,kBAAa,cAAI,uBAAJ;AADd,KAGG,cAAI,WAAJ,CAHH,CADD,EAOE;AAAI;AAPN,IASG,cACD,sDADC,CATH,CAzCD,EAsDC,wCACC;AAAM,kBAAa,cAAI,cAAJ;AAAnB,KAEG,cAAI,UAAJ,CAFH,CADD,EAME;AAAI;AANN,IAQG,cACD,qDADC,CARH,CAtDD,CAbD,CADD,CAlBF,EAsGC;AAAK,IAAA,SAAS,EAAC;AAAf,KACG,CAAEA,qBAAF,IAA2BP,WAA3B,IACD,4BAAC,eAAD;AACC,IAAA,SAAS,EAAC,wCADX;AAEC,IAAA,OAAO,EAAC,MAFT;AAGC,IAAA,OAAO,EAAG,MAAMK,QAAQ,CAAE,IAAF;AAHzB,KAKG,cAAI,OAAJ,CALH,CAFF,EAUC,4BAAC,eAAD;AACC,IAAA,SAAS,EAAC,uCADX;AAEC,IAAA,OAAO,EAAC,MAFT;AAGC,IAAA,OAAO,EAAGI;AAHX,KAKGF,qBAAqB,GACpB,cAAI,OAAJ,CADoB,GAEpB,cAAI,eAAJ,CAPJ,CAVD,CAtGD,CADD;AA6HA;;eAEc,yBAAYT,cAAZ,C","sourcesContent":["/**\n * External dependencies\n */\n// Needed to initialise the default datepicker styles.\n// See: https://github.com/airbnb/react-dates#initialize\nimport 'react-dates/initialize';\nimport { noop } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useState, forwardRef } from '@wordpress/element';\nimport { __, _x } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport Button from '../button';\nimport { default as DatePicker } from './date';\nimport { default as TimePicker } from './time';\n\nexport { DatePicker, TimePicker };\n\nfunction DateTimePicker(\n\t{\n\t\tcurrentDate,\n\t\tis12Hour,\n\t\tisInvalidDate,\n\t\tonMonthPreviewed = noop,\n\t\tonChange,\n\t\tevents,\n\t},\n\tref\n) {\n\tconst [ calendarHelpIsVisible, setCalendarHelpIsVisible ] = useState(\n\t\tfalse\n\t);\n\n\tfunction onClickDescriptionToggle() {\n\t\tsetCalendarHelpIsVisible( ! calendarHelpIsVisible );\n\t}\n\n\treturn (\n\t\t<div ref={ ref } className=\"components-datetime\">\n\t\t\t{ ! calendarHelpIsVisible && (\n\t\t\t\t<>\n\t\t\t\t\t<TimePicker\n\t\t\t\t\t\tcurrentTime={ currentDate }\n\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\tis12Hour={ is12Hour }\n\t\t\t\t\t/>\n\t\t\t\t\t<DatePicker\n\t\t\t\t\t\tcurrentDate={ currentDate }\n\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\tisInvalidDate={ isInvalidDate }\n\t\t\t\t\t\tevents={ events }\n\t\t\t\t\t\tonMonthPreviewed={ onMonthPreviewed }\n\t\t\t\t\t/>\n\t\t\t\t</>\n\t\t\t) }\n\t\t\t{ calendarHelpIsVisible && (\n\t\t\t\t<>\n\t\t\t\t\t<div className=\"components-datetime__calendar-help\">\n\t\t\t\t\t\t<h4>{ __( 'Click to Select' ) }</h4>\n\t\t\t\t\t\t<ul>\n\t\t\t\t\t\t\t<li>\n\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t'Click the right or left arrows to select other months in the past or the future.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t\t<li>\n\t\t\t\t\t\t\t\t{ __( 'Click the desired day to select it.' ) }\n\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t</ul>\n\t\t\t\t\t\t<h4>{ __( 'Navigating with a keyboard' ) }</h4>\n\t\t\t\t\t\t<ul>\n\t\t\t\t\t\t\t<li>\n\t\t\t\t\t\t\t\t<abbr\n\t\t\t\t\t\t\t\t\taria-label={ _x(\n\t\t\t\t\t\t\t\t\t\t'Enter',\n\t\t\t\t\t\t\t\t\t\t'keyboard button'\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t↵\n\t\t\t\t\t\t\t\t</abbr>\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t' ' /* JSX removes whitespace, but a space is required for screen readers. */\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t<span>\n\t\t\t\t\t\t\t\t\t{ __( 'Select the date in focus.' ) }\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t\t<li>\n\t\t\t\t\t\t\t\t<abbr\n\t\t\t\t\t\t\t\t\taria-label={ __( 'Left and Right Arrows' ) }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t←/→\n\t\t\t\t\t\t\t\t</abbr>\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t' ' /* JSX removes whitespace, but a space is required for screen readers. */\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t'Move backward (left) or forward (right) by one day.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t\t<li>\n\t\t\t\t\t\t\t\t<abbr aria-label={ __( 'Up and Down Arrows' ) }>\n\t\t\t\t\t\t\t\t\t↑/↓\n\t\t\t\t\t\t\t\t</abbr>\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t' ' /* JSX removes whitespace, but a space is required for screen readers. */\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t'Move backward (up) or forward (down) by one week.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t\t<li>\n\t\t\t\t\t\t\t\t<abbr\n\t\t\t\t\t\t\t\t\taria-label={ __( 'Page Up and Page Down' ) }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ __( 'PgUp/PgDn' ) }\n\t\t\t\t\t\t\t\t</abbr>\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t' ' /* JSX removes whitespace, but a space is required for screen readers. */\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t'Move backward (PgUp) or forward (PgDn) by one month.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t\t<li>\n\t\t\t\t\t\t\t\t<abbr aria-label={ __( 'Home and End' ) }>\n\t\t\t\t\t\t\t\t\t{ /* Translators: Home/End reffer to the 'Home' and 'End' buttons on the keyboard.*/ }\n\t\t\t\t\t\t\t\t\t{ __( 'Home/End' ) }\n\t\t\t\t\t\t\t\t</abbr>\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t' ' /* JSX removes whitespace, but a space is required for screen readers. */\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t'Go to the first (Home) or last (End) day of a week.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t</ul>\n\t\t\t\t\t</div>\n\t\t\t\t</>\n\t\t\t) }\n\t\t\t<div className=\"components-datetime__buttons\">\n\t\t\t\t{ ! calendarHelpIsVisible && currentDate && (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tclassName=\"components-datetime__date-reset-button\"\n\t\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\t\tonClick={ () => onChange( null ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Reset' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t) }\n\t\t\t\t<Button\n\t\t\t\t\tclassName=\"components-datetime__date-help-toggle\"\n\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\tonClick={ onClickDescriptionToggle }\n\t\t\t\t>\n\t\t\t\t\t{ calendarHelpIsVisible\n\t\t\t\t\t\t? __( 'Close' )\n\t\t\t\t\t\t: __( 'Calendar Help' ) }\n\t\t\t\t</Button>\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n\nexport default forwardRef( DateTimePicker );\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/date-time/index.tsx"],"names":["UnforwardedDateTimePicker","ref","currentDate","is12Hour","isInvalidDate","onMonthPreviewed","noop","onChange","events","calendarHelpIsVisible","setCalendarHelpIsVisible","onClickDescriptionToggle","DateTimePicker"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAYA;;AAPA;;AACA;;AAOA;;AAKA;;AACA;;AACA;;AApBA;AACA;AACA;AACA;AACA;;AAKA;AACA;AACA;;AAIA;AACA;AACA;AAQA,SAASA,yBAAT,OASCC,GATD,EAUE;AAAA,MATD;AACCC,IAAAA,WADD;AAECC,IAAAA,QAFD;AAGCC,IAAAA,aAHD;AAICC,IAAAA,gBAAgB,GAAGC,YAJpB;AAKCC,IAAAA,QALD;AAMCC,IAAAA;AAND,GASC;AACD,QAAM,CAAEC,qBAAF,EAAyBC,wBAAzB,IAAsD,uBAC3D,KAD2D,CAA5D;;AAIA,WAASC,wBAAT,GAAoC;AACnCD,IAAAA,wBAAwB,CAAE,CAAED,qBAAJ,CAAxB;AACA;;AAED,SACC;AAAK,IAAA,GAAG,EAAGR,GAAX;AAAiB,IAAA,SAAS,EAAC;AAA3B,KACG,CAAEQ,qBAAF,IACD,qDACC,4BAAC,aAAD;AACC,IAAA,WAAW,EAAGP,WADf;AAEC,IAAA,QAAQ,EAAGK,QAFZ;AAGC,IAAA,QAAQ,EAAGJ;AAHZ,IADD,EAMC,4BAAC,aAAD;AACC,IAAA,WAAW,EAAGD,WADf;AAEC,IAAA,QAAQ,EAAGK,QAFZ;AAGC,IAA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AC,MAFT;AAGC,IAAA,OAAO,EAAGI;AAHX,KAKGF,qBAAqB,GACpB,cAAI,OAAJ,CADoB,GAEpB,cAAI,eAAJ,CAPJ,CAVD,CAtGD,CADD;AA6HA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAMG,cAAc,GAAG,yBAAYZ,yBAAZ,CAAvB;;eAEQY,c","sourcesContent":["/**\n * External dependencies\n */\n// Needed to initialise the default datepicker styles.\n// See: https://github.com/airbnb/react-dates#initialize\nimport 'react-dates/initialize';\nimport { noop } from 'lodash';\nimport type { ForwardedRef } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { useState, forwardRef } from '@wordpress/element';\nimport { __, _x } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport Button from '../button';\nimport { default as DatePicker } from './date';\nimport { default as TimePicker } from './time';\nimport type { DateTimePickerProps } from './types';\n\nexport { DatePicker, TimePicker };\n\nfunction UnforwardedDateTimePicker(\n\t{\n\t\tcurrentDate,\n\t\tis12Hour,\n\t\tisInvalidDate,\n\t\tonMonthPreviewed = noop,\n\t\tonChange,\n\t\tevents,\n\t}: DateTimePickerProps,\n\tref: ForwardedRef< any >\n) {\n\tconst [ calendarHelpIsVisible, setCalendarHelpIsVisible ] = useState(\n\t\tfalse\n\t);\n\n\tfunction onClickDescriptionToggle() {\n\t\tsetCalendarHelpIsVisible( ! calendarHelpIsVisible );\n\t}\n\n\treturn (\n\t\t<div ref={ ref } className=\"components-datetime\">\n\t\t\t{ ! calendarHelpIsVisible && (\n\t\t\t\t<>\n\t\t\t\t\t<TimePicker\n\t\t\t\t\t\tcurrentTime={ currentDate }\n\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\tis12Hour={ is12Hour }\n\t\t\t\t\t/>\n\t\t\t\t\t<DatePicker\n\t\t\t\t\t\tcurrentDate={ currentDate }\n\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\tisInvalidDate={ isInvalidDate }\n\t\t\t\t\t\tevents={ events }\n\t\t\t\t\t\tonMonthPreviewed={ onMonthPreviewed }\n\t\t\t\t\t/>\n\t\t\t\t</>\n\t\t\t) }\n\t\t\t{ calendarHelpIsVisible && (\n\t\t\t\t<>\n\t\t\t\t\t<div className=\"components-datetime__calendar-help\">\n\t\t\t\t\t\t<h4>{ __( 'Click to Select' ) }</h4>\n\t\t\t\t\t\t<ul>\n\t\t\t\t\t\t\t<li>\n\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t'Click the right or left arrows to select other months in the past or the future.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t\t<li>\n\t\t\t\t\t\t\t\t{ __( 'Click the desired day to select it.' ) }\n\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t</ul>\n\t\t\t\t\t\t<h4>{ __( 'Navigating with a keyboard' ) }</h4>\n\t\t\t\t\t\t<ul>\n\t\t\t\t\t\t\t<li>\n\t\t\t\t\t\t\t\t<abbr\n\t\t\t\t\t\t\t\t\taria-label={ _x(\n\t\t\t\t\t\t\t\t\t\t'Enter',\n\t\t\t\t\t\t\t\t\t\t'keyboard button'\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t↵\n\t\t\t\t\t\t\t\t</abbr>\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t' ' /* JSX removes whitespace, but a space is required for screen readers. */\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t<span>\n\t\t\t\t\t\t\t\t\t{ __( 'Select the date in focus.' ) }\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t\t<li>\n\t\t\t\t\t\t\t\t<abbr\n\t\t\t\t\t\t\t\t\taria-label={ __( 'Left and Right Arrows' ) }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t←/→\n\t\t\t\t\t\t\t\t</abbr>\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t' ' /* JSX removes whitespace, but a space is required for screen readers. */\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t'Move backward (left) or forward (right) by one day.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t\t<li>\n\t\t\t\t\t\t\t\t<abbr aria-label={ __( 'Up and Down Arrows' ) }>\n\t\t\t\t\t\t\t\t\t↑/↓\n\t\t\t\t\t\t\t\t</abbr>\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t' ' /* JSX removes whitespace, but a space is required for screen readers. */\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t'Move backward (up) or forward (down) by one week.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t\t<li>\n\t\t\t\t\t\t\t\t<abbr\n\t\t\t\t\t\t\t\t\taria-label={ __( 'Page Up and Page Down' ) }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ __( 'PgUp/PgDn' ) }\n\t\t\t\t\t\t\t\t</abbr>\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t' ' /* JSX removes whitespace, but a space is required for screen readers. */\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t'Move backward (PgUp) or forward (PgDn) by one month.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t\t<li>\n\t\t\t\t\t\t\t\t<abbr aria-label={ __( 'Home and End' ) }>\n\t\t\t\t\t\t\t\t\t{ /* Translators: Home/End reffer to the 'Home' and 'End' buttons on the keyboard.*/ }\n\t\t\t\t\t\t\t\t\t{ __( 'Home/End' ) }\n\t\t\t\t\t\t\t\t</abbr>\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t' ' /* JSX removes whitespace, but a space is required for screen readers. */\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t'Go to the first (Home) or last (End) day of a week.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t</ul>\n\t\t\t\t\t</div>\n\t\t\t\t</>\n\t\t\t) }\n\t\t\t<div className=\"components-datetime__buttons\">\n\t\t\t\t{ ! calendarHelpIsVisible && currentDate && (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tclassName=\"components-datetime__date-reset-button\"\n\t\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\t\tonClick={ () => onChange?.( null ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Reset' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t) }\n\t\t\t\t<Button\n\t\t\t\t\tclassName=\"components-datetime__date-help-toggle\"\n\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\tonClick={ onClickDescriptionToggle }\n\t\t\t\t>\n\t\t\t\t\t{ calendarHelpIsVisible\n\t\t\t\t\t\t? __( 'Close' )\n\t\t\t\t\t\t: __( 'Calendar Help' ) }\n\t\t\t\t</Button>\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n\n/**\n * DateTimePicker is a React component that renders a calendar and clock for\n * date and time selection. The calendar and clock components can be accessed\n * individually using the `DatePicker` and `TimePicker` components respectively.\n *\n * ```jsx\n * import { DateTimePicker } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * const MyDateTimePicker = () => {\n * const [ date, setDate ] = useState( new Date() );\n *\n * return (\n * <DateTimePicker\n * currentDate={ date }\n * onChange={ ( newDate ) => setDate( newDate ) }\n * is12Hour\n * />\n * );\n * };\n * ```\n */\nexport const DateTimePicker = forwardRef( UnforwardedDateTimePicker );\n\nexport default DateTimePicker;\n"]}
@@ -35,24 +35,14 @@ var _timezone = _interopRequireDefault(require("./timezone"));
35
35
  /**
36
36
  * Internal dependencies
37
37
  */
38
-
39
- /**
40
- * Module Constants
41
- */
42
38
  const TIMEZONELESS_FORMAT = 'YYYY-MM-DDTHH:mm:ss';
43
39
 
44
40
  function from12hTo24h(hours, isPm) {
45
41
  return isPm ? (hours % 12 + 12) % 24 : hours % 12;
46
42
  }
47
43
  /**
48
- * <UpdateOnBlurAsIntegerField>
49
- * A shared component to parse, validate, and handle remounting of the underlying form field element like <input> and <select>.
50
- *
51
- * @param {Object} props Component props.
52
- * @param {string} props.as Render the component as specific element tag, defaults to "input".
53
- * @param {number|string} props.value The default value of the component which will be parsed to integer.
54
- * @param {Function} props.onUpdate Call back when blurred and validated.
55
- * @param {string} [props.className]
44
+ * A shared component to parse, validate, and handle remounting of the
45
+ * underlying form field element like <input> and <select>.
56
46
  */
57
47
 
58
48
 
@@ -70,7 +60,7 @@ function UpdateOnBlurAsIntegerField(_ref) {
70
60
  target
71
61
  } = event;
72
62
 
73
- if (value === target.value) {
63
+ if (String(value) === target.value) {
74
64
  return;
75
65
  }
76
66
 
@@ -78,10 +68,10 @@ function UpdateOnBlurAsIntegerField(_ref) {
78
68
 
79
69
  if (!(0, _lodash.isInteger)(parsedValue) || typeof props.max !== 'undefined' && parsedValue > props.max || typeof props.min !== 'undefined' && parsedValue < props.min) {
80
70
  // If validation failed, reset the value to the previous valid value.
81
- target.value = value;
71
+ target.value = String(value);
82
72
  } else {
83
73
  // Otherwise, it's valid, call onUpdate.
84
- onUpdate(target.name, parsedValue);
74
+ onUpdate(parsedValue);
85
75
  }
86
76
  }
87
77
 
@@ -95,14 +85,24 @@ function UpdateOnBlurAsIntegerField(_ref) {
95
85
  });
96
86
  }
97
87
  /**
98
- * <TimePicker>
88
+ * TimePicker is a React component that renders a clock for time selection.
99
89
  *
100
- * @typedef {Date|string|number} WPValidDateTimeFormat
90
+ * ```jsx
91
+ * import { TimePicker } from '@wordpress/components';
92
+ * import { useState } from '@wordpress/element';
101
93
  *
102
- * @param {Object} props Component props.
103
- * @param {boolean} props.is12Hour Should the time picker showed in 12 hour format or 24 hour format.
104
- * @param {WPValidDateTimeFormat} props.currentTime The initial current time the time picker should render.
105
- * @param {Function} props.onChange Callback function when the date changed.
94
+ * const MyTimePicker = () => {
95
+ * const [ time, setTime ] = useState( new Date() );
96
+ *
97
+ * return (
98
+ * <TimePicker
99
+ * currentTime={ date }
100
+ * onChange={ ( newTime ) => setTime( newTime ) }
101
+ * is12Hour
102
+ * />
103
+ * );
104
+ * };
105
+ * ```
106
106
  */
107
107
 
108
108
 
@@ -113,7 +113,7 @@ function TimePicker(_ref2) {
113
113
  onChange
114
114
  } = _ref2;
115
115
  const [date, setDate] = (0, _element.useState)(() => // Truncate the date at the minutes, see: #15495.
116
- (0, _moment.default)(currentTime).startOf('minutes')); // Reset the state when currentTime changed.
116
+ currentTime ? (0, _moment.default)(currentTime).startOf('minutes') : (0, _moment.default)()); // Reset the state when currentTime changed.
117
117
 
118
118
  (0, _element.useEffect)(() => {
119
119
  setDate(currentTime ? (0, _moment.default)(currentTime).startOf('minutes') : (0, _moment.default)());
@@ -131,33 +131,35 @@ function TimePicker(_ref2) {
131
131
  year: date.format('YYYY'),
132
132
  minutes: date.format('mm'),
133
133
  hours: date.format(is12Hour ? 'hh' : 'HH'),
134
- am: date.format('H') <= 11 ? 'AM' : 'PM'
134
+ am: Number(date.format('H')) <= 11 ? 'AM' : 'PM'
135
135
  }), [date, is12Hour]);
136
136
  /**
137
137
  * Function that sets the date state and calls the onChange with a new date.
138
138
  * The date is truncated at the minutes.
139
139
  *
140
- * @param {Object} newDate The date object.
140
+ * @param {Moment} newDate The date object.
141
141
  */
142
142
 
143
143
  function changeDate(newDate) {
144
144
  setDate(newDate);
145
- onChange(newDate.format(TIMEZONELESS_FORMAT));
145
+ onChange === null || onChange === void 0 ? void 0 : onChange(newDate.format(TIMEZONELESS_FORMAT));
146
146
  }
147
147
 
148
- function update(name, value) {
149
- // If the 12-hour format is being used and the 'PM' period is selected, then
150
- // the incoming value (which ranges 1-12) should be increased by 12 to match
151
- // the expected 24-hour format.
152
- let adjustedValue = value;
148
+ function update(name) {
149
+ return value => {
150
+ // If the 12-hour format is being used and the 'PM' period is selected, then
151
+ // the incoming value (which ranges 1-12) should be increased by 12 to match
152
+ // the expected 24-hour format.
153
+ let adjustedValue = value;
153
154
 
154
- if (name === 'hours' && is12Hour) {
155
- adjustedValue = from12hTo24h(value, am === 'PM');
156
- } // Clone the date and call the specific setter function according to `name`.
155
+ if (name === 'hours' && is12Hour) {
156
+ adjustedValue = from12hTo24h(value, am === 'PM');
157
+ } // Clone the date and call the specific setter function according to `name`.
157
158
 
158
159
 
159
- const newDate = date.clone()[name](adjustedValue);
160
- changeDate(newDate);
160
+ const newDate = date.clone()[name](adjustedValue);
161
+ changeDate(newDate);
162
+ };
161
163
  }
162
164
 
163
165
  function updateAmPm(value) {
@@ -184,7 +186,7 @@ function TimePicker(_ref2) {
184
186
  step: 1,
185
187
  min: 1,
186
188
  max: 31,
187
- onUpdate: update
189
+ onUpdate: update('date')
188
190
  }));
189
191
  const monthFormat = (0, _element.createElement)("div", {
190
192
  className: "components-datetime__time-field components-datetime__time-field-month"
@@ -195,7 +197,7 @@ function TimePicker(_ref2) {
195
197
  name: "month",
196
198
  value: month // The value starts from 0, so we have to -1 when setting month.
197
199
  ,
198
- onUpdate: (key, value) => update(key, value - 1)
200
+ onUpdate: value => update('month')(value - 1)
199
201
  }, (0, _element.createElement)("option", {
200
202
  value: "01"
201
203
  }, (0, _i18n.__)('January')), (0, _element.createElement)("option", {
@@ -239,7 +241,7 @@ function TimePicker(_ref2) {
239
241
  min: 0,
240
242
  max: 9999,
241
243
  value: year,
242
- onUpdate: update
244
+ onUpdate: update('year')
243
245
  })))), (0, _element.createElement)("fieldset", null, (0, _element.createElement)("legend", {
244
246
  className: "components-datetime__time-legend invisible"
245
247
  }, (0, _i18n.__)('Time')), (0, _element.createElement)("div", {
@@ -255,7 +257,7 @@ function TimePicker(_ref2) {
255
257
  min: is12Hour ? 1 : 0,
256
258
  max: is12Hour ? 12 : 23,
257
259
  value: hours,
258
- onUpdate: update
260
+ onUpdate: update('hours')
259
261
  }), (0, _element.createElement)("span", {
260
262
  className: "components-datetime__time-separator",
261
263
  "aria-hidden": "true"
@@ -268,7 +270,7 @@ function TimePicker(_ref2) {
268
270
  min: 0,
269
271
  max: 59,
270
272
  value: minutes,
271
- onUpdate: update
273
+ onUpdate: update('minutes')
272
274
  })), is12Hour && (0, _element.createElement)(_buttonGroup.default, {
273
275
  className: "components-datetime__time-field components-datetime__time-field-am-pm"
274
276
  }, (0, _element.createElement)(_button.default, {