@wordpress/components 23.6.0 → 23.8.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 (484) hide show
  1. package/CHANGELOG.md +43 -4
  2. package/build/angle-picker-control/angle-circle.js +1 -4
  3. package/build/angle-picker-control/angle-circle.js.map +1 -1
  4. package/build/angle-picker-control/index.js +10 -22
  5. package/build/angle-picker-control/index.js.map +1 -1
  6. package/build/angle-picker-control/styles/angle-picker-control-styles.js +24 -15
  7. package/build/angle-picker-control/styles/angle-picker-control-styles.js.map +1 -1
  8. package/build/animate/index.js +27 -19
  9. package/build/animate/index.js.map +1 -1
  10. package/build/animate/types.js.map +1 -0
  11. package/build/box-control/axial-input-controls.js.map +1 -1
  12. package/build/color-picker/color-input.js +0 -4
  13. package/build/color-picker/color-input.js.map +1 -1
  14. package/build/color-picker/component.js +5 -4
  15. package/build/color-picker/component.js.map +1 -1
  16. package/build/color-picker/hex-input.js.map +1 -1
  17. package/build/color-picker/hsl-input.js.map +1 -1
  18. package/build/color-picker/input-with-slider.js.map +1 -1
  19. package/build/color-picker/legacy-adapter.js.map +1 -1
  20. package/build/color-picker/picker.js.map +1 -1
  21. package/build/color-picker/rgb-input.js.map +1 -1
  22. package/build/color-picker/use-deprecated-props.js.map +1 -1
  23. package/build/custom-gradient-picker/constants.js +1 -1
  24. package/build/custom-gradient-picker/constants.js.map +1 -1
  25. package/build/custom-gradient-picker/gradient-bar/constants.js.map +1 -1
  26. package/build/custom-gradient-picker/gradient-bar/control-points.js +9 -5
  27. package/build/custom-gradient-picker/gradient-bar/control-points.js.map +1 -1
  28. package/build/custom-gradient-picker/gradient-bar/index.js +14 -9
  29. package/build/custom-gradient-picker/gradient-bar/index.js.map +1 -1
  30. package/build/custom-gradient-picker/gradient-bar/utils.js +34 -54
  31. package/build/custom-gradient-picker/gradient-bar/utils.js.map +1 -1
  32. package/build/custom-gradient-picker/index.js +45 -16
  33. package/build/custom-gradient-picker/index.js.map +1 -1
  34. package/build/custom-gradient-picker/serializer.js +10 -4
  35. package/build/custom-gradient-picker/serializer.js.map +1 -1
  36. package/build/custom-gradient-picker/styles/custom-gradient-picker-styles.js +6 -6
  37. package/build/custom-gradient-picker/styles/custom-gradient-picker-styles.js.map +1 -1
  38. package/build/custom-gradient-picker/types.js +6 -0
  39. package/build/custom-gradient-picker/types.js.map +1 -0
  40. package/build/custom-gradient-picker/utils.js +17 -12
  41. package/build/custom-gradient-picker/utils.js.map +1 -1
  42. package/build/drop-zone/index.js +8 -8
  43. package/build/drop-zone/index.js.map +1 -1
  44. package/build/{color-list-picker → duotone-picker/color-list-picker}/index.js +5 -5
  45. package/build/duotone-picker/color-list-picker/index.js.map +1 -0
  46. package/build/duotone-picker/color-list-picker/types.js +6 -0
  47. package/build/duotone-picker/color-list-picker/types.js.map +1 -0
  48. package/build/duotone-picker/custom-duotone-bar.js.map +1 -1
  49. package/build/duotone-picker/duotone-picker.js +39 -2
  50. package/build/duotone-picker/duotone-picker.js.map +1 -1
  51. package/build/duotone-picker/duotone-swatch.js.map +1 -1
  52. package/build/duotone-picker/index.js.map +1 -1
  53. package/build/duotone-picker/types.js +6 -0
  54. package/build/duotone-picker/types.js.map +1 -0
  55. package/build/duotone-picker/utils.js +13 -11
  56. package/build/duotone-picker/utils.js.map +1 -1
  57. package/build/form-token-field/index.js +9 -3
  58. package/build/form-token-field/index.js.map +1 -1
  59. package/build/gradient-picker/index.js +61 -9
  60. package/build/gradient-picker/index.js.map +1 -1
  61. package/build/gradient-picker/types.js +6 -0
  62. package/build/gradient-picker/types.js.map +1 -0
  63. package/build/index.js.map +1 -1
  64. package/build/mobile/keyboard-aware-flat-list/index.android.js +0 -4
  65. package/build/mobile/keyboard-aware-flat-list/index.android.js.map +1 -1
  66. package/build/mobile/keyboard-aware-flat-list/index.ios.js +100 -55
  67. package/build/mobile/keyboard-aware-flat-list/index.ios.js.map +1 -1
  68. package/build/mobile/keyboard-aware-flat-list/use-keyboard-offset.native.js +82 -0
  69. package/build/mobile/keyboard-aware-flat-list/use-keyboard-offset.native.js.map +1 -0
  70. package/build/mobile/keyboard-aware-flat-list/use-scroll-to-text-input.native.js +85 -0
  71. package/build/mobile/keyboard-aware-flat-list/use-scroll-to-text-input.native.js.map +1 -0
  72. package/build/mobile/keyboard-aware-flat-list/use-text-input-caret-position.native.js +44 -0
  73. package/build/mobile/keyboard-aware-flat-list/use-text-input-caret-position.native.js.map +1 -0
  74. package/build/mobile/keyboard-aware-flat-list/use-text-input-offset.native.js +53 -0
  75. package/build/mobile/keyboard-aware-flat-list/use-text-input-offset.native.js.map +1 -0
  76. package/build/navigator/navigator-provider/component.js +4 -2
  77. package/build/navigator/navigator-provider/component.js.map +1 -1
  78. package/build/navigator/navigator-screen/component.js +4 -3
  79. package/build/navigator/navigator-screen/component.js.map +1 -1
  80. package/build/palette-edit/index.js +1 -2
  81. package/build/palette-edit/index.js.map +1 -1
  82. package/build/private-apis.js.map +1 -1
  83. package/build/query-controls/author-select.js +2 -1
  84. package/build/query-controls/author-select.js.map +1 -1
  85. package/build/query-controls/category-select.js +3 -1
  86. package/build/query-controls/category-select.js.map +1 -1
  87. package/build/query-controls/index.js +7 -1
  88. package/build/query-controls/index.js.map +1 -1
  89. package/build/resizable-box/resize-tooltip/utils.js.map +1 -1
  90. package/build/sandbox/index.native.js +129 -93
  91. package/build/sandbox/index.native.js.map +1 -1
  92. package/build/tab-panel/index.js +1 -1
  93. package/build/tab-panel/index.js.map +1 -1
  94. package/build/tools-panel/tools-panel/hook.js +45 -6
  95. package/build/tools-panel/tools-panel/hook.js.map +1 -1
  96. package/build/utils/input/input-control.js +1 -1
  97. package/build/utils/input/input-control.js.map +1 -1
  98. package/build-module/angle-picker-control/angle-circle.js +1 -4
  99. package/build-module/angle-picker-control/angle-circle.js.map +1 -1
  100. package/build-module/angle-picker-control/index.js +12 -21
  101. package/build-module/angle-picker-control/index.js.map +1 -1
  102. package/build-module/angle-picker-control/styles/angle-picker-control-styles.js +20 -13
  103. package/build-module/angle-picker-control/styles/angle-picker-control-styles.js.map +1 -1
  104. package/build-module/animate/index.js +25 -17
  105. package/build-module/animate/index.js.map +1 -1
  106. package/build-module/box-control/axial-input-controls.js.map +1 -1
  107. package/build-module/color-picker/color-input.js +0 -4
  108. package/build-module/color-picker/color-input.js.map +1 -1
  109. package/build-module/color-picker/component.js +3 -3
  110. package/build-module/color-picker/component.js.map +1 -1
  111. package/build-module/color-picker/hex-input.js.map +1 -1
  112. package/build-module/color-picker/hsl-input.js.map +1 -1
  113. package/build-module/color-picker/input-with-slider.js.map +1 -1
  114. package/build-module/color-picker/legacy-adapter.js.map +1 -1
  115. package/build-module/color-picker/picker.js +4 -0
  116. package/build-module/color-picker/picker.js.map +1 -1
  117. package/build-module/color-picker/rgb-input.js.map +1 -1
  118. package/build-module/color-picker/use-deprecated-props.js.map +1 -1
  119. package/build-module/custom-gradient-picker/constants.js +1 -1
  120. package/build-module/custom-gradient-picker/constants.js.map +1 -1
  121. package/build-module/custom-gradient-picker/gradient-bar/constants.js.map +1 -1
  122. package/build-module/custom-gradient-picker/gradient-bar/control-points.js +9 -4
  123. package/build-module/custom-gradient-picker/gradient-bar/control-points.js.map +1 -1
  124. package/build-module/custom-gradient-picker/gradient-bar/index.js +14 -8
  125. package/build-module/custom-gradient-picker/gradient-bar/index.js.map +1 -1
  126. package/build-module/custom-gradient-picker/gradient-bar/utils.js +34 -54
  127. package/build-module/custom-gradient-picker/gradient-bar/utils.js.map +1 -1
  128. package/build-module/custom-gradient-picker/index.js +44 -17
  129. package/build-module/custom-gradient-picker/index.js.map +1 -1
  130. package/build-module/custom-gradient-picker/serializer.js +10 -4
  131. package/build-module/custom-gradient-picker/serializer.js.map +1 -1
  132. package/build-module/custom-gradient-picker/styles/custom-gradient-picker-styles.js +6 -6
  133. package/build-module/custom-gradient-picker/styles/custom-gradient-picker-styles.js.map +1 -1
  134. package/build-module/custom-gradient-picker/types.js +2 -0
  135. package/build-module/custom-gradient-picker/utils.js +17 -12
  136. package/build-module/custom-gradient-picker/utils.js.map +1 -1
  137. package/build-module/drop-zone/index.js +8 -8
  138. package/build-module/drop-zone/index.js.map +1 -1
  139. package/build-module/{color-list-picker → duotone-picker/color-list-picker}/index.js +5 -5
  140. package/build-module/duotone-picker/color-list-picker/index.js.map +1 -0
  141. package/build-module/duotone-picker/color-list-picker/types.js +2 -0
  142. package/build-module/duotone-picker/color-list-picker/types.js.map +1 -0
  143. package/build-module/duotone-picker/custom-duotone-bar.js.map +1 -1
  144. package/build-module/duotone-picker/duotone-picker.js +38 -2
  145. package/build-module/duotone-picker/duotone-picker.js.map +1 -1
  146. package/build-module/duotone-picker/duotone-swatch.js.map +1 -1
  147. package/build-module/duotone-picker/index.js.map +1 -1
  148. package/build-module/duotone-picker/types.js +2 -0
  149. package/build-module/duotone-picker/types.js.map +1 -0
  150. package/build-module/duotone-picker/utils.js +17 -11
  151. package/build-module/duotone-picker/utils.js.map +1 -1
  152. package/build-module/form-token-field/index.js +9 -4
  153. package/build-module/form-token-field/index.js.map +1 -1
  154. package/build-module/gradient-picker/index.js +61 -10
  155. package/build-module/gradient-picker/index.js.map +1 -1
  156. package/build-module/gradient-picker/types.js +2 -0
  157. package/build-module/gradient-picker/types.js.map +1 -0
  158. package/build-module/index.js.map +1 -1
  159. package/build-module/mobile/keyboard-aware-flat-list/index.android.js +0 -4
  160. package/build-module/mobile/keyboard-aware-flat-list/index.android.js.map +1 -1
  161. package/build-module/mobile/keyboard-aware-flat-list/index.ios.js +97 -54
  162. package/build-module/mobile/keyboard-aware-flat-list/index.ios.js.map +1 -1
  163. package/build-module/mobile/keyboard-aware-flat-list/use-keyboard-offset.native.js +73 -0
  164. package/build-module/mobile/keyboard-aware-flat-list/use-keyboard-offset.native.js.map +1 -0
  165. package/build-module/mobile/keyboard-aware-flat-list/use-scroll-to-text-input.native.js +76 -0
  166. package/build-module/mobile/keyboard-aware-flat-list/use-scroll-to-text-input.native.js.map +1 -0
  167. package/build-module/mobile/keyboard-aware-flat-list/use-text-input-caret-position.native.js +33 -0
  168. package/build-module/mobile/keyboard-aware-flat-list/use-text-input-caret-position.native.js.map +1 -0
  169. package/build-module/mobile/keyboard-aware-flat-list/use-text-input-offset.native.js +40 -0
  170. package/build-module/mobile/keyboard-aware-flat-list/use-text-input-offset.native.js.map +1 -0
  171. package/build-module/navigator/navigator-provider/component.js +4 -2
  172. package/build-module/navigator/navigator-provider/component.js.map +1 -1
  173. package/build-module/navigator/navigator-screen/component.js +4 -3
  174. package/build-module/navigator/navigator-screen/component.js.map +1 -1
  175. package/build-module/palette-edit/index.js +1 -2
  176. package/build-module/palette-edit/index.js.map +1 -1
  177. package/build-module/private-apis.js.map +1 -1
  178. package/build-module/query-controls/author-select.js +2 -1
  179. package/build-module/query-controls/author-select.js.map +1 -1
  180. package/build-module/query-controls/category-select.js +3 -1
  181. package/build-module/query-controls/category-select.js.map +1 -1
  182. package/build-module/query-controls/index.js +7 -2
  183. package/build-module/query-controls/index.js.map +1 -1
  184. package/build-module/resizable-box/resize-tooltip/utils.js.map +1 -1
  185. package/build-module/sandbox/index.native.js +121 -87
  186. package/build-module/sandbox/index.native.js.map +1 -1
  187. package/build-module/tab-panel/index.js +2 -2
  188. package/build-module/tab-panel/index.js.map +1 -1
  189. package/build-module/tools-panel/tools-panel/hook.js +45 -6
  190. package/build-module/tools-panel/tools-panel/hook.js.map +1 -1
  191. package/build-module/utils/input/input-control.js +1 -1
  192. package/build-module/utils/input/input-control.js.map +1 -1
  193. package/build-style/style-rtl.css +41 -29
  194. package/build-style/style.css +43 -29
  195. package/build-types/angle-picker-control/angle-circle.d.ts.map +1 -1
  196. package/build-types/angle-picker-control/index.d.ts.map +1 -1
  197. package/build-types/angle-picker-control/styles/angle-picker-control-styles.d.ts +6 -1
  198. package/build-types/angle-picker-control/styles/angle-picker-control-styles.d.ts.map +1 -1
  199. package/build-types/animate/index.d.ts +27 -22
  200. package/build-types/animate/index.d.ts.map +1 -1
  201. package/build-types/animate/stories/index.d.ts +18 -0
  202. package/build-types/animate/stories/index.d.ts.map +1 -0
  203. package/build-types/animate/types.d.ts +30 -0
  204. package/build-types/animate/types.d.ts.map +1 -0
  205. package/build-types/border-box-control/border-box-control/hook.d.ts +2 -2
  206. package/build-types/border-box-control/border-box-control-linked-button/hook.d.ts +2 -2
  207. package/build-types/border-box-control/border-box-control-split-controls/hook.d.ts +2 -2
  208. package/build-types/border-box-control/border-box-control-visualizer/hook.d.ts +2 -2
  209. package/build-types/border-control/border-control/hook.d.ts +2 -2
  210. package/build-types/border-control/border-control-dropdown/hook.d.ts +2 -2
  211. package/build-types/border-control/border-control-style-picker/hook.d.ts +2 -2
  212. package/build-types/box-control/styles/box-control-styles.d.ts +5 -5
  213. package/build-types/button/deprecated.d.ts +2 -2
  214. package/build-types/card/card/hook.d.ts +2 -2
  215. package/build-types/card/card-body/hook.d.ts +2 -2
  216. package/build-types/card/card-divider/hook.d.ts +2 -2
  217. package/build-types/card/card-footer/hook.d.ts +2 -2
  218. package/build-types/card/card-header/hook.d.ts +2 -2
  219. package/build-types/card/card-media/hook.d.ts +2 -2
  220. package/build-types/color-palette/styles.d.ts +1 -1
  221. package/build-types/color-picker/color-input.d.ts +1 -11
  222. package/build-types/color-picker/color-input.d.ts.map +1 -1
  223. package/build-types/color-picker/component.d.ts +8 -9
  224. package/build-types/color-picker/component.d.ts.map +1 -1
  225. package/build-types/color-picker/hex-input.d.ts +1 -10
  226. package/build-types/color-picker/hex-input.d.ts.map +1 -1
  227. package/build-types/color-picker/hsl-input.d.ts +1 -10
  228. package/build-types/color-picker/hsl-input.d.ts.map +1 -1
  229. package/build-types/color-picker/input-with-slider.d.ts +1 -9
  230. package/build-types/color-picker/input-with-slider.d.ts.map +1 -1
  231. package/build-types/color-picker/legacy-adapter.d.ts +1 -3
  232. package/build-types/color-picker/legacy-adapter.d.ts.map +1 -1
  233. package/build-types/color-picker/picker.d.ts +4 -7
  234. package/build-types/color-picker/picker.d.ts.map +1 -1
  235. package/build-types/color-picker/rgb-input.d.ts +1 -10
  236. package/build-types/color-picker/rgb-input.d.ts.map +1 -1
  237. package/build-types/color-picker/stories/index.d.ts +19 -0
  238. package/build-types/color-picker/stories/index.d.ts.map +1 -0
  239. package/build-types/color-picker/styles.d.ts +5 -5
  240. package/build-types/color-picker/test/index.d.ts +2 -0
  241. package/build-types/color-picker/test/index.d.ts.map +1 -0
  242. package/build-types/color-picker/types.d.ts +105 -1
  243. package/build-types/color-picker/types.d.ts.map +1 -1
  244. package/build-types/color-picker/use-deprecated-props.d.ts +1 -44
  245. package/build-types/color-picker/use-deprecated-props.d.ts.map +1 -1
  246. package/build-types/combobox-control/styles.d.ts +1 -1
  247. package/build-types/custom-gradient-picker/constants.d.ts +8 -8
  248. package/build-types/custom-gradient-picker/constants.d.ts.map +1 -1
  249. package/build-types/custom-gradient-picker/gradient-bar/constants.d.ts +7 -7
  250. package/build-types/custom-gradient-picker/gradient-bar/constants.d.ts.map +1 -1
  251. package/build-types/custom-gradient-picker/gradient-bar/control-points.d.ts +5 -22
  252. package/build-types/custom-gradient-picker/gradient-bar/control-points.d.ts.map +1 -1
  253. package/build-types/custom-gradient-picker/gradient-bar/index.d.ts +3 -9
  254. package/build-types/custom-gradient-picker/gradient-bar/index.d.ts.map +1 -1
  255. package/build-types/custom-gradient-picker/gradient-bar/test/utils.d.ts +2 -0
  256. package/build-types/custom-gradient-picker/gradient-bar/test/utils.d.ts.map +1 -0
  257. package/build-types/custom-gradient-picker/gradient-bar/utils.d.ts +44 -92
  258. package/build-types/custom-gradient-picker/gradient-bar/utils.d.ts.map +1 -1
  259. package/build-types/custom-gradient-picker/index.d.ts +27 -6
  260. package/build-types/custom-gradient-picker/index.d.ts.map +1 -1
  261. package/build-types/custom-gradient-picker/serializer.d.ts +9 -16
  262. package/build-types/custom-gradient-picker/serializer.d.ts.map +1 -1
  263. package/build-types/custom-gradient-picker/stories/index.d.ts +12 -0
  264. package/build-types/custom-gradient-picker/stories/index.d.ts.map +1 -0
  265. package/build-types/custom-gradient-picker/styles/custom-gradient-picker-styles.d.ts +3 -2
  266. package/build-types/custom-gradient-picker/styles/custom-gradient-picker-styles.d.ts.map +1 -1
  267. package/build-types/custom-gradient-picker/test/serializer.d.ts +2 -0
  268. package/build-types/custom-gradient-picker/test/serializer.d.ts.map +1 -0
  269. package/build-types/custom-gradient-picker/types.d.ts +118 -0
  270. package/build-types/custom-gradient-picker/types.d.ts.map +1 -0
  271. package/build-types/custom-gradient-picker/utils.d.ts +12 -4
  272. package/build-types/custom-gradient-picker/utils.d.ts.map +1 -1
  273. package/build-types/date-time/date/styles.d.ts +2 -2
  274. package/build-types/date-time/date-time/styles.d.ts +1 -1
  275. package/build-types/date-time/time/styles.d.ts +8 -8
  276. package/build-types/drop-zone/index.d.ts.map +1 -1
  277. package/build-types/duotone-picker/color-list-picker/index.d.ts.map +1 -0
  278. package/build-types/{color-list-picker → duotone-picker/color-list-picker}/types.d.ts +2 -2
  279. package/build-types/duotone-picker/color-list-picker/types.d.ts.map +1 -0
  280. package/build-types/duotone-picker/custom-duotone-bar.d.ts +6 -0
  281. package/build-types/duotone-picker/custom-duotone-bar.d.ts.map +1 -0
  282. package/build-types/duotone-picker/duotone-picker.d.ts +38 -0
  283. package/build-types/duotone-picker/duotone-picker.d.ts.map +1 -0
  284. package/build-types/duotone-picker/duotone-swatch.d.ts +5 -0
  285. package/build-types/duotone-picker/duotone-swatch.d.ts.map +1 -0
  286. package/build-types/duotone-picker/index.d.ts +3 -0
  287. package/build-types/duotone-picker/index.d.ts.map +1 -0
  288. package/build-types/duotone-picker/stories/duotone-picker.d.ts +12 -0
  289. package/build-types/duotone-picker/stories/duotone-picker.d.ts.map +1 -0
  290. package/build-types/duotone-picker/stories/duotone-swatch.d.ts +14 -0
  291. package/build-types/duotone-picker/stories/duotone-swatch.d.ts.map +1 -0
  292. package/build-types/duotone-picker/types.d.ts +60 -0
  293. package/build-types/duotone-picker/types.d.ts.map +1 -0
  294. package/build-types/duotone-picker/utils.d.ts +52 -0
  295. package/build-types/duotone-picker/utils.d.ts.map +1 -0
  296. package/build-types/elevation/hook.d.ts +2 -2
  297. package/build-types/external-link/styles/external-link-styles.d.ts +1 -1
  298. package/build-types/flex/flex/hook.d.ts +2 -2
  299. package/build-types/flex/flex-block/hook.d.ts +2 -2
  300. package/build-types/flex/flex-item/hook.d.ts +2 -2
  301. package/build-types/focal-point-picker/styles/focal-point-picker-style.d.ts +2 -2
  302. package/build-types/form-token-field/index.d.ts.map +1 -1
  303. package/build-types/form-token-field/styles.d.ts +1 -1
  304. package/build-types/form-token-field/types.d.ts +6 -0
  305. package/build-types/form-token-field/types.d.ts.map +1 -1
  306. package/build-types/gradient-picker/index.d.ts +49 -11
  307. package/build-types/gradient-picker/index.d.ts.map +1 -1
  308. package/build-types/gradient-picker/stories/index.d.ts +14 -0
  309. package/build-types/gradient-picker/stories/index.d.ts.map +1 -0
  310. package/build-types/gradient-picker/types.d.ts +87 -0
  311. package/build-types/gradient-picker/types.d.ts.map +1 -0
  312. package/build-types/grid/hook.d.ts +2 -2
  313. package/build-types/h-stack/hook.d.ts +2 -2
  314. package/build-types/heading/hook.d.ts +2 -2
  315. package/build-types/index.d.ts +128 -0
  316. package/build-types/index.d.ts.map +1 -0
  317. package/build-types/input-control/styles/input-control-styles.d.ts +2 -2
  318. package/build-types/item-group/item/hook.d.ts +2 -2
  319. package/build-types/item-group/item-group/hook.d.ts +2 -2
  320. package/build-types/navigation/styles/navigation-styles.d.ts +2 -2
  321. package/build-types/navigator/navigator-back-button/hook.d.ts +2 -2
  322. package/build-types/navigator/navigator-button/hook.d.ts +2 -2
  323. package/build-types/navigator/navigator-provider/component.d.ts.map +1 -1
  324. package/build-types/navigator/navigator-screen/component.d.ts +1 -1
  325. package/build-types/navigator/navigator-screen/component.d.ts.map +1 -1
  326. package/build-types/navigator/stories/index.d.ts +1 -0
  327. package/build-types/navigator/stories/index.d.ts.map +1 -1
  328. package/build-types/navigator/types.d.ts +2 -2
  329. package/build-types/navigator/types.d.ts.map +1 -1
  330. package/build-types/number-control/index.d.ts +2 -2
  331. package/build-types/number-control/stories/index.d.ts +2 -2
  332. package/build-types/palette-edit/index.d.ts.map +1 -1
  333. package/build-types/palette-edit/styles.d.ts +3 -3
  334. package/build-types/popover/index.d.ts +1 -1
  335. package/build-types/popover/stories/e2e/index.d.ts +1 -1
  336. package/build-types/private-apis.d.ts +2 -3
  337. package/build-types/private-apis.d.ts.map +1 -1
  338. package/build-types/query-controls/author-select.d.ts.map +1 -1
  339. package/build-types/query-controls/category-select.d.ts.map +1 -1
  340. package/build-types/query-controls/index.d.ts.map +1 -1
  341. package/build-types/range-control/index.d.ts +1 -1
  342. package/build-types/range-control/styles/range-control-styles.d.ts +2 -2
  343. package/build-types/resizable-box/index.d.ts +1 -1
  344. package/build-types/resizable-box/resize-tooltip/index.d.ts +1 -1
  345. package/build-types/resizable-box/resize-tooltip/utils.d.ts +1 -1
  346. package/build-types/resizable-box/resize-tooltip/utils.d.ts.map +1 -1
  347. package/build-types/resizable-box/stories/index.d.ts +2 -2
  348. package/build-types/scrollable/hook.d.ts +2 -2
  349. package/build-types/search-control/index.d.ts +1 -1
  350. package/build-types/search-control/stories/index.d.ts +2 -2
  351. package/build-types/spacer/hook.d.ts +2 -2
  352. package/build-types/spinner/index.d.ts +1 -1
  353. package/build-types/surface/hook.d.ts +2 -2
  354. package/build-types/tab-panel/index.d.ts.map +1 -1
  355. package/build-types/text/hook.d.ts +2 -2
  356. package/build-types/text-control/index.d.ts +1 -1
  357. package/build-types/toolbar/toolbar-button/index.d.ts +2 -2
  358. package/build-types/tools-panel/tools-panel/hook.d.ts +2 -2
  359. package/build-types/tools-panel/tools-panel/hook.d.ts.map +1 -1
  360. package/build-types/tools-panel/tools-panel-header/hook.d.ts +2 -2
  361. package/build-types/tools-panel/tools-panel-item/hook.d.ts +2 -2
  362. package/build-types/tools-panel/types.d.ts +1 -0
  363. package/build-types/tools-panel/types.d.ts.map +1 -1
  364. package/build-types/truncate/hook.d.ts +2 -2
  365. package/build-types/ui/control-group/hook.d.ts +2 -2
  366. package/build-types/ui/control-label/hook.d.ts +2 -2
  367. package/build-types/ui/form-group/form-group.d.ts +2 -2
  368. package/build-types/ui/form-group/use-form-group.d.ts +2 -2
  369. package/build-types/unit-control/index.d.ts +1 -1
  370. package/build-types/unit-control/styles/unit-control-styles.d.ts +2 -2
  371. package/build-types/utils/input/input-control.d.ts.map +1 -1
  372. package/build-types/v-stack/hook.d.ts +2 -2
  373. package/package.json +20 -19
  374. package/src/angle-picker-control/angle-circle.tsx +0 -1
  375. package/src/angle-picker-control/index.tsx +14 -27
  376. package/src/angle-picker-control/styles/angle-picker-control-styles.tsx +16 -9
  377. package/src/animate/index.tsx +75 -0
  378. package/src/animate/stories/index.tsx +102 -0
  379. package/src/animate/types.ts +32 -0
  380. package/src/border-box-control/stories/index.tsx +1 -1
  381. package/src/box-control/axial-input-controls.tsx +1 -1
  382. package/src/circular-option-picker/style.scss +10 -0
  383. package/src/color-indicator/style.scss +1 -0
  384. package/src/color-picker/README.md +2 -2
  385. package/src/color-picker/color-input.tsx +1 -12
  386. package/src/color-picker/component.tsx +9 -18
  387. package/src/color-picker/hex-input.tsx +2 -7
  388. package/src/color-picker/hsl-input.tsx +2 -7
  389. package/src/color-picker/input-with-slider.tsx +1 -9
  390. package/src/color-picker/legacy-adapter.tsx +1 -2
  391. package/src/color-picker/picker.tsx +5 -6
  392. package/src/color-picker/rgb-input.tsx +2 -7
  393. package/src/color-picker/stories/index.tsx +51 -0
  394. package/src/color-picker/test/{index.js → index.tsx} +36 -18
  395. package/src/color-picker/types.ts +128 -1
  396. package/src/color-picker/use-deprecated-props.ts +2 -53
  397. package/src/combobox-control/stories/index.tsx +1 -1
  398. package/src/custom-gradient-picker/{constants.js → constants.ts} +2 -2
  399. package/src/custom-gradient-picker/gradient-bar/{control-points.js → control-points.tsx} +171 -134
  400. package/src/custom-gradient-picker/gradient-bar/{index.js → index.tsx} +32 -10
  401. package/src/custom-gradient-picker/gradient-bar/test/{utils.js → utils.ts} +58 -31
  402. package/src/custom-gradient-picker/gradient-bar/utils.ts +193 -0
  403. package/src/custom-gradient-picker/{index.js → index.tsx} +63 -22
  404. package/src/custom-gradient-picker/serializer.ts +78 -0
  405. package/src/custom-gradient-picker/stories/index.tsx +45 -0
  406. package/src/custom-gradient-picker/style.scss +25 -4
  407. package/src/custom-gradient-picker/test/{serializer.js → serializer.ts} +39 -33
  408. package/src/custom-gradient-picker/types.ts +119 -0
  409. package/src/custom-gradient-picker/{utils.js → utils.ts} +37 -22
  410. package/src/custom-select-control/test/index.js +6 -4
  411. package/src/drop-zone/index.tsx +12 -8
  412. package/src/drop-zone/style.scss +1 -1
  413. package/src/{color-list-picker → duotone-picker/color-list-picker}/index.tsx +7 -6
  414. package/src/{color-list-picker → duotone-picker/color-list-picker}/types.ts +2 -2
  415. package/src/duotone-picker/{custom-duotone-bar.js → custom-duotone-bar.tsx} +7 -1
  416. package/src/duotone-picker/{duotone-picker.js → duotone-picker.tsx} +39 -2
  417. package/src/duotone-picker/{duotone-swatch.js → duotone-swatch.tsx} +2 -1
  418. package/src/duotone-picker/stories/{duotone-picker.js → duotone-picker.tsx} +15 -8
  419. package/src/duotone-picker/stories/{duotone-swatch.js → duotone-swatch.tsx} +9 -3
  420. package/src/duotone-picker/types.ts +61 -0
  421. package/src/duotone-picker/{utils.js → utils.ts} +29 -14
  422. package/src/flex/flex-item/README.md +1 -1
  423. package/src/form-token-field/README.md +1 -0
  424. package/src/form-token-field/index.tsx +10 -3
  425. package/src/form-token-field/style.scss +0 -7
  426. package/src/form-token-field/test/index.tsx +1 -0
  427. package/src/form-token-field/types.ts +6 -0
  428. package/src/gradient-picker/README.md +16 -23
  429. package/src/gradient-picker/{index.js → index.tsx} +70 -16
  430. package/src/gradient-picker/stories/{index.js → index.tsx} +19 -8
  431. package/src/gradient-picker/types.ts +89 -0
  432. package/src/item-group/test/index.js +5 -3
  433. package/src/mobile/keyboard-aware-flat-list/index.android.js +0 -4
  434. package/src/mobile/keyboard-aware-flat-list/index.ios.js +118 -67
  435. package/src/mobile/keyboard-aware-flat-list/test/use-keyboard-offset.native.js +203 -0
  436. package/src/mobile/keyboard-aware-flat-list/test/use-scroll-to-text-input.native.js +140 -0
  437. package/src/mobile/keyboard-aware-flat-list/test/use-text-input-caret-position.native.js +82 -0
  438. package/src/mobile/keyboard-aware-flat-list/test/use-text-input-offset.native.js +147 -0
  439. package/src/mobile/keyboard-aware-flat-list/use-keyboard-offset.native.js +87 -0
  440. package/src/mobile/keyboard-aware-flat-list/use-scroll-to-text-input.native.js +105 -0
  441. package/src/mobile/keyboard-aware-flat-list/use-text-input-caret-position.native.js +36 -0
  442. package/src/mobile/keyboard-aware-flat-list/use-text-input-offset.native.js +54 -0
  443. package/src/navigator/navigator-provider/component.tsx +2 -0
  444. package/src/navigator/navigator-screen/component.tsx +5 -2
  445. package/src/navigator/stories/index.tsx +68 -0
  446. package/src/navigator/test/index.tsx +52 -0
  447. package/src/navigator/types.ts +2 -1
  448. package/src/palette-edit/index.tsx +4 -5
  449. package/src/query-controls/author-select.tsx +1 -0
  450. package/src/query-controls/category-select.tsx +1 -0
  451. package/src/query-controls/index.tsx +4 -2
  452. package/src/resizable-box/resize-tooltip/utils.ts +1 -1
  453. package/src/sandbox/index.native.js +139 -112
  454. package/src/slot-fill/test/slot.js +8 -6
  455. package/src/style.scss +1 -1
  456. package/src/tab-panel/index.tsx +7 -2
  457. package/src/tools-panel/test/index.tsx +86 -0
  458. package/src/tools-panel/tools-panel/hook.ts +44 -4
  459. package/src/tools-panel/types.ts +1 -0
  460. package/src/tooltip/test/index.js +251 -301
  461. package/src/utils/input/input-control.js +1 -0
  462. package/tsconfig.json +1 -3
  463. package/tsconfig.tsbuildinfo +1 -1
  464. package/build/color-list-picker/index.js.map +0 -1
  465. package/build-module/color-list-picker/index.js.map +0 -1
  466. package/build-types/color-list-picker/index.d.ts.map +0 -1
  467. package/build-types/color-list-picker/types.d.ts.map +0 -1
  468. package/src/animate/index.js +0 -60
  469. package/src/animate/stories/index.js +0 -53
  470. package/src/color-picker/stories/index.js +0 -41
  471. package/src/custom-gradient-picker/gradient-bar/utils.js +0 -189
  472. package/src/custom-gradient-picker/serializer.js +0 -48
  473. package/src/custom-gradient-picker/stories/index.js +0 -33
  474. /package/build/{color-list-picker → animate}/types.js +0 -0
  475. /package/build-module/{color-list-picker → animate}/types.js +0 -0
  476. /package/build-module/{color-list-picker → animate}/types.js.map +0 -0
  477. /package/{build/color-list-picker → build-module/custom-gradient-picker}/types.js.map +0 -0
  478. /package/build-types/{color-list-picker → duotone-picker/color-list-picker}/index.d.ts +0 -0
  479. /package/src/custom-gradient-picker/gradient-bar/{constants.js → constants.ts} +0 -0
  480. /package/src/custom-gradient-picker/styles/{custom-gradient-picker-styles.js → custom-gradient-picker-styles.tsx} +0 -0
  481. /package/src/{color-list-picker → duotone-picker/color-list-picker}/style.scss +0 -0
  482. /package/src/duotone-picker/{index.js → index.ts} +0 -0
  483. /package/src/{index.js → index.ts} +0 -0
  484. /package/src/{private-apis.js → private-apis.ts} +0 -0
@@ -10,12 +10,13 @@ import styled from '@emotion/styled';
10
10
  import { Flex } from '../../flex';
11
11
  import { COLORS } from '../../utils';
12
12
  import { space } from '../../ui/utils/space';
13
+ import { Text } from '../../text';
13
14
  import CONFIG from '../../utils/config-values';
14
15
 
15
16
  import type { AnglePickerControlProps } from '../types';
16
17
 
17
18
  const CIRCLE_SIZE = 32;
18
- const INNER_CIRCLE_SIZE = 3;
19
+ const INNER_CIRCLE_SIZE = 6;
19
20
 
20
21
  const deprecatedBottomMargin = ( {
21
22
  __nextHasNoMarginBottom,
@@ -39,6 +40,10 @@ export const CircleRoot = styled.div`
39
40
  height: ${ CIRCLE_SIZE }px;
40
41
  overflow: hidden;
41
42
  width: ${ CIRCLE_SIZE }px;
43
+
44
+ :active {
45
+ cursor: grabbing;
46
+ }
42
47
  `;
43
48
 
44
49
  export const CircleIndicatorWrapper = styled.div`
@@ -55,15 +60,17 @@ export const CircleIndicatorWrapper = styled.div`
55
60
  export const CircleIndicator = styled.div`
56
61
  background: ${ COLORS.ui.theme };
57
62
  border-radius: 50%;
58
- border: ${ INNER_CIRCLE_SIZE }px solid ${ COLORS.ui.theme };
59
- bottom: 0;
60
63
  box-sizing: border-box;
61
64
  display: block;
62
- height: 0px;
63
- left: 0;
64
- margin: auto;
65
+ left: 50%;
66
+ top: 4px;
67
+ transform: translateX( -50% );
65
68
  position: absolute;
66
- right: 0;
67
- top: -${ CIRCLE_SIZE / 2 }px;
68
- width: 0px;
69
+ width: ${ INNER_CIRCLE_SIZE }px;
70
+ height: ${ INNER_CIRCLE_SIZE }px;
71
+ `;
72
+
73
+ export const UnitText = styled( Text )`
74
+ color: ${ COLORS.ui.theme };
75
+ margin-right: ${ space( 3 ) };
69
76
  `;
@@ -0,0 +1,75 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import classnames from 'classnames';
5
+
6
+ /**
7
+ * Internal dependencies
8
+ */
9
+ import type { AnimateProps, GetAnimateOptions } from './types';
10
+
11
+ /**
12
+ * @param type The animation type
13
+ * @return Default origin
14
+ */
15
+ function getDefaultOrigin( type?: GetAnimateOptions[ 'type' ] ) {
16
+ return type === 'appear' ? 'top' : 'left';
17
+ }
18
+
19
+ /**
20
+ * @param options
21
+ *
22
+ * @return ClassName that applies the animations
23
+ */
24
+ export function getAnimateClassName( options: GetAnimateOptions ) {
25
+ if ( options.type === 'loading' ) {
26
+ return classnames( 'components-animate__loading' );
27
+ }
28
+
29
+ const { type, origin = getDefaultOrigin( type ) } = options;
30
+
31
+ if ( type === 'appear' ) {
32
+ const [ yAxis, xAxis = 'center' ] = origin.split( ' ' );
33
+ return classnames( 'components-animate__appear', {
34
+ [ 'is-from-' + xAxis ]: xAxis !== 'center',
35
+ [ 'is-from-' + yAxis ]: yAxis !== 'middle',
36
+ } );
37
+ }
38
+
39
+ if ( type === 'slide-in' ) {
40
+ return classnames(
41
+ 'components-animate__slide-in',
42
+ 'is-from-' + origin
43
+ );
44
+ }
45
+
46
+ return undefined;
47
+ }
48
+
49
+ /**
50
+ * Simple interface to introduce animations to components.
51
+ *
52
+ * ```jsx
53
+ * import { Animate, Notice } from '@wordpress/components';
54
+ *
55
+ * const MyAnimatedNotice = () => (
56
+ * <Animate type="slide-in" options={ { origin: 'top' } }>
57
+ * { ( { className } ) => (
58
+ * <Notice className={ className } status="success">
59
+ * <p>Animation finished.</p>
60
+ * </Notice>
61
+ * ) }
62
+ * </Animate>
63
+ * );
64
+ * ```
65
+ */
66
+ export function Animate( { type, options = {}, children }: AnimateProps ) {
67
+ return children( {
68
+ className: getAnimateClassName( {
69
+ type,
70
+ ...options,
71
+ } as GetAnimateOptions ),
72
+ } );
73
+ }
74
+
75
+ export default Animate;
@@ -0,0 +1,102 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import type { ComponentMeta, ComponentStory } from '@storybook/react';
5
+
6
+ /**
7
+ * Internal dependencies
8
+ */
9
+ import { Animate } from '..';
10
+ import Notice from '../../notice';
11
+
12
+ const meta: ComponentMeta< typeof Animate > = {
13
+ title: 'Components/Animate',
14
+ component: Animate,
15
+ parameters: {
16
+ controls: { expanded: true },
17
+ docs: { source: { state: 'open' } },
18
+ },
19
+ };
20
+ export default meta;
21
+
22
+ const Template: ComponentStory< typeof Animate > = ( props ) => (
23
+ <Animate { ...props } />
24
+ );
25
+
26
+ export const Default: ComponentStory< typeof Animate > = Template.bind( {} );
27
+ Default.args = {
28
+ children: ( { className } ) => (
29
+ <Notice className={ className } status="success">
30
+ <p>{ `No default animation. Use one of type = "appear", "slide-in", or "loading".` }</p>
31
+ </Notice>
32
+ ),
33
+ };
34
+
35
+ export const AppearTopLeft: ComponentStory< typeof Animate > = Template.bind(
36
+ {}
37
+ );
38
+ AppearTopLeft.args = {
39
+ type: 'appear',
40
+ options: { origin: 'top left' },
41
+ children: ( { className } ) => (
42
+ <Notice className={ className } status="success">
43
+ <p>Appear animation. Origin: top left.</p>
44
+ </Notice>
45
+ ),
46
+ };
47
+ export const AppearTopRight: ComponentStory< typeof Animate > = Template.bind(
48
+ {}
49
+ );
50
+ AppearTopRight.args = {
51
+ type: 'appear',
52
+ options: { origin: 'top right' },
53
+ children: ( { className } ) => (
54
+ <Notice className={ className } status="success">
55
+ <p>Appear animation. Origin: top right.</p>
56
+ </Notice>
57
+ ),
58
+ };
59
+ export const AppearBottomLeft: ComponentStory< typeof Animate > = Template.bind(
60
+ {}
61
+ );
62
+ AppearBottomLeft.args = {
63
+ type: 'appear',
64
+ options: { origin: 'bottom left' },
65
+ children: ( { className } ) => (
66
+ <Notice className={ className } status="success">
67
+ <p>Appear animation. Origin: bottom left.</p>
68
+ </Notice>
69
+ ),
70
+ };
71
+ export const AppearBottomRight: ComponentStory< typeof Animate > =
72
+ Template.bind( {} );
73
+ AppearBottomRight.args = {
74
+ type: 'appear',
75
+ options: { origin: 'bottom right' },
76
+ children: ( { className } ) => (
77
+ <Notice className={ className } status="success">
78
+ <p>Appear animation. Origin: bottom right.</p>
79
+ </Notice>
80
+ ),
81
+ };
82
+
83
+ export const Loading: ComponentStory< typeof Animate > = Template.bind( {} );
84
+ Loading.args = {
85
+ type: 'loading',
86
+ children: ( { className } ) => (
87
+ <Notice className={ className } status="success">
88
+ <p>Loading animation.</p>
89
+ </Notice>
90
+ ),
91
+ };
92
+
93
+ export const SlideIn: ComponentStory< typeof Animate > = Template.bind( {} );
94
+ SlideIn.args = {
95
+ type: 'slide-in',
96
+ options: { origin: 'left' },
97
+ children: ( { className } ) => (
98
+ <Notice className={ className } status="success">
99
+ <p>Slide-in animation.</p>
100
+ </Notice>
101
+ ),
102
+ };
@@ -0,0 +1,32 @@
1
+ export type AppearOptions = {
2
+ type: 'appear';
3
+ origin?:
4
+ | 'top'
5
+ | 'top left'
6
+ | 'top right'
7
+ | 'middle'
8
+ | 'middle left'
9
+ | 'middle right'
10
+ | 'bottom'
11
+ | 'bottom left'
12
+ | 'bottom right';
13
+ };
14
+ type SlideInOptions = { type: 'slide-in'; origin?: 'left' | 'right' };
15
+ type LoadingOptions = { type: 'loading'; origin?: never };
16
+ type NoAnimationOptions = { type?: never; origin?: never };
17
+
18
+ export type GetAnimateOptions =
19
+ | AppearOptions
20
+ | SlideInOptions
21
+ | LoadingOptions
22
+ | NoAnimationOptions;
23
+
24
+ // Create a new type that and distributes the `Pick` operator separately to
25
+ // every individual type of a union, thus preserving that same union.
26
+ type DistributiveTypeAndOptions< T extends { type?: any } > = T extends any
27
+ ? Pick< T, 'type' > & { options?: Omit< T, 'type' > }
28
+ : never;
29
+
30
+ export type AnimateProps = DistributiveTypeAndOptions< GetAnimateOptions > & {
31
+ children: ( props: { className?: string } ) => JSX.Element;
32
+ };
@@ -43,7 +43,7 @@ const colors = [
43
43
 
44
44
  const Template: ComponentStory< typeof BorderBoxControl > = ( props ) => {
45
45
  const { onChange, ...otherProps } = props;
46
- const [ borders, setBorders ] = useState< typeof props[ 'value' ] >();
46
+ const [ borders, setBorders ] = useState< ( typeof props )[ 'value' ] >();
47
47
 
48
48
  const onChangeMerged: ComponentProps<
49
49
  typeof BorderBoxControl
@@ -8,7 +8,7 @@ import { Layout } from './styles/box-control-styles';
8
8
  import type { BoxControlInputControlProps } from './types';
9
9
 
10
10
  const groupedSides = [ 'vertical', 'horizontal' ] as const;
11
- type GroupedSide = typeof groupedSides[ number ];
11
+ type GroupedSide = ( typeof groupedSides )[ number ];
12
12
 
13
13
  export default function AxialInputControls( {
14
14
  onChange,
@@ -16,6 +16,16 @@ $color-palette-circle-spacing: 12px;
16
16
  display: flex;
17
17
  flex-wrap: wrap;
18
18
  gap: $color-palette-circle-spacing;
19
+ position: relative;
20
+ z-index: z-index(".components-circular-option-picker__swatches");
21
+ }
22
+
23
+ // Make sure that the .components-circular-option-picker__swatches element
24
+ // renders visually on top of its siblings. This is necessary to make sure
25
+ // that the tooltip rendered when hovering an `Option` always appears on top.
26
+ > *:not(.components-circular-option-picker__swatches) {
27
+ position: relative;
28
+ z-index: z-index("> *:not(.components-circular-option-picker__swatches)");
19
29
  }
20
30
  }
21
31
 
@@ -5,4 +5,5 @@
5
5
  border-radius: 50%;
6
6
  display: inline-block;
7
7
  padding: 0;
8
+ background: $white linear-gradient(-45deg, transparent 48%, $gray-300 48%, $gray-300 52%, transparent 52%);
8
9
  }
@@ -31,13 +31,13 @@ The current color value to display in the picker. Must be a hex or hex8 string.
31
31
 
32
32
  ### `onChange`: `(hex8Color: string) => void`
33
33
 
34
- Fired when the color changes. Always passes a hex8 color string.
34
+ Fired when the color changes. Always passes a hex or hex8 color string.
35
35
 
36
36
  - Required: No
37
37
 
38
38
  ### `enableAlpha`: `boolean`
39
39
 
40
- Defaults to `false`. When `true` the color picker will display the alpha channel both in the bottom inputs as well as in the color picker itself.
40
+ When `true` the color picker will display the alpha channel both in the bottom inputs as well as in the color picker itself.
41
41
 
42
42
  - Required: No
43
43
  - Default: `false`
@@ -1,21 +1,10 @@
1
- /**
2
- * External dependencies
3
- */
4
- import type { Colord } from 'colord';
5
-
6
1
  /**
7
2
  * Internal dependencies
8
3
  */
9
4
  import { RgbInput } from './rgb-input';
10
5
  import { HslInput } from './hsl-input';
11
6
  import { HexInput } from './hex-input';
12
-
13
- interface ColorInputProps {
14
- colorType: 'hsl' | 'hex' | 'rgb';
15
- color: Colord;
16
- onChange: ( nextColor: Colord ) => void;
17
- enableAlpha: boolean;
18
- }
7
+ import type { ColorInputProps } from './types';
19
8
 
20
9
  export const ColorInput = ( {
21
10
  colorType,
@@ -15,11 +15,7 @@ import { __ } from '@wordpress/i18n';
15
15
  /**
16
16
  * Internal dependencies
17
17
  */
18
- import {
19
- useContextSystem,
20
- contextConnect,
21
- WordPressComponentProps,
22
- } from '../ui/context';
18
+ import { useContextSystem, contextConnect } from '../ui/context';
23
19
  import {
24
20
  ColorfulWrapper,
25
21
  SelectControl,
@@ -32,26 +28,18 @@ import { ColorInput } from './color-input';
32
28
  import { Picker } from './picker';
33
29
  import { useControlledValue } from '../utils/hooks';
34
30
 
35
- import type { ColorType } from './types';
31
+ import type { ColorPickerProps, ColorType } from './types';
36
32
 
37
33
  extend( [ namesPlugin ] );
38
34
 
39
- export interface ColorPickerProps {
40
- enableAlpha?: boolean;
41
- color?: string;
42
- onChange?: ( color: string ) => void;
43
- defaultValue?: string;
44
- copyFormat?: ColorType;
45
- }
46
-
47
35
  const options = [
48
36
  { label: 'RGB', value: 'rgb' as const },
49
37
  { label: 'HSL', value: 'hsl' as const },
50
38
  { label: 'Hex', value: 'hex' as const },
51
39
  ];
52
40
 
53
- const ColorPicker = (
54
- props: WordPressComponentProps< ColorPickerProps, 'div', false >,
41
+ const UnconnectedColorPicker = (
42
+ props: ColorPickerProps,
55
43
  forwardedRef: ForwardedRef< any >
56
44
  ) => {
57
45
  const {
@@ -124,6 +112,9 @@ const ColorPicker = (
124
112
  );
125
113
  };
126
114
 
127
- const ConnectedColorPicker = contextConnect( ColorPicker, 'ColorPicker' );
115
+ export const ColorPicker = contextConnect(
116
+ UnconnectedColorPicker,
117
+ 'ColorPicker'
118
+ );
128
119
 
129
- export default ConnectedColorPicker;
120
+ export default ColorPicker;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import { colord, Colord } from 'colord';
4
+ import { colord } from 'colord';
5
5
 
6
6
  /**
7
7
  * WordPress dependencies
@@ -17,12 +17,7 @@ import { Spacer } from '../spacer';
17
17
  import { space } from '../ui/utils/space';
18
18
  import { COLORS } from '../utils/colors-values';
19
19
  import type { StateReducer } from '../input-control/reducer/state';
20
-
21
- interface HexInputProps {
22
- color: Colord;
23
- onChange: ( nextColor: Colord ) => void;
24
- enableAlpha: boolean;
25
- }
20
+ import type { HexInputProps } from './types';
26
21
 
27
22
  export const HexInput = ( { color, onChange, enableAlpha }: HexInputProps ) => {
28
23
  const handleChange = ( nextValue: string | undefined ) => {
@@ -1,18 +1,13 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import { colord, Colord } from 'colord';
4
+ import { colord } from 'colord';
5
5
 
6
6
  /**
7
7
  * Internal dependencies
8
8
  */
9
9
  import { InputWithSlider } from './input-with-slider';
10
-
11
- interface HslInputProps {
12
- color: Colord;
13
- onChange: ( nextColor: Colord ) => void;
14
- enableAlpha: boolean;
15
- }
10
+ import type { HslInputProps } from './types';
16
11
 
17
12
  export const HslInput = ( { color, onChange, enableAlpha }: HslInputProps ) => {
18
13
  const { h, s, l, a } = color.toHsl();
@@ -7,15 +7,7 @@ import { Spacer } from '../spacer';
7
7
  import { space } from '../ui/utils/space';
8
8
  import { RangeControl, NumberControlWrapper } from './styles';
9
9
  import { COLORS } from '../utils/colors-values';
10
-
11
- interface InputWithSliderProps {
12
- min: number;
13
- max: number;
14
- value: number;
15
- label: string;
16
- abbreviation: string;
17
- onChange: ( value: number ) => void;
18
- }
10
+ import type { InputWithSliderProps } from './types';
19
11
 
20
12
  export const InputWithSlider = ( {
21
13
  min,
@@ -2,10 +2,9 @@
2
2
  * Internal dependencies
3
3
  */
4
4
  import ColorPicker from './component';
5
+ import type { LegacyAdapterProps } from './types';
5
6
  import { useDeprecatedProps } from './use-deprecated-props';
6
7
 
7
- type LegacyAdapterProps = Parameters< typeof useDeprecatedProps >[ 0 ];
8
-
9
8
  export const LegacyAdapter = ( props: LegacyAdapterProps ) => {
10
9
  return <ColorPicker { ...useDeprecatedProps( props ) } />;
11
10
  };
@@ -2,17 +2,16 @@
2
2
  * External dependencies
3
3
  */
4
4
  import { RgbStringColorPicker, RgbaStringColorPicker } from 'react-colorful';
5
- import { colord, Colord } from 'colord';
5
+ import { colord } from 'colord';
6
6
 
7
7
  /**
8
8
  * WordPress dependencies
9
9
  */
10
10
  import { useMemo } from '@wordpress/element';
11
- interface PickerProps {
12
- color: Colord;
13
- enableAlpha: boolean;
14
- onChange: ( nextColor: Colord ) => void;
15
- }
11
+ /**
12
+ * Internal dependencies
13
+ */
14
+ import type { PickerProps } from './types';
16
15
 
17
16
  export const Picker = ( { color, enableAlpha, onChange }: PickerProps ) => {
18
17
  const Component = enableAlpha
@@ -1,18 +1,13 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import { colord, Colord } from 'colord';
4
+ import { colord } from 'colord';
5
5
 
6
6
  /**
7
7
  * Internal dependencies
8
8
  */
9
9
  import { InputWithSlider } from './input-with-slider';
10
-
11
- interface RgbInputProps {
12
- color: Colord;
13
- onChange: ( nextColor: Colord ) => void;
14
- enableAlpha: boolean;
15
- }
10
+ import type { RgbInputProps } from './types';
16
11
 
17
12
  export const RgbInput = ( { color, onChange, enableAlpha }: RgbInputProps ) => {
18
13
  const { r, g, b, a } = color.toRgb();
@@ -0,0 +1,51 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import type { ComponentMeta, ComponentStory } from '@storybook/react';
5
+
6
+ /**
7
+ * WordPress dependencies
8
+ */
9
+ import { useState } from '@wordpress/element';
10
+
11
+ /**
12
+ * Internal dependencies
13
+ */
14
+ import { ColorPicker } from '../component';
15
+
16
+ const meta: ComponentMeta< typeof ColorPicker > = {
17
+ component: ColorPicker,
18
+ title: 'Components/ColorPicker',
19
+ argTypes: {
20
+ as: { control: { type: null } },
21
+ color: { control: { type: null } },
22
+ },
23
+ parameters: {
24
+ actions: { argTypesRegex: '^on.*' },
25
+ controls: {
26
+ expanded: true,
27
+ },
28
+ docs: { source: { state: 'open' } },
29
+ },
30
+ };
31
+ export default meta;
32
+
33
+ const Template: ComponentStory< typeof ColorPicker > = ( {
34
+ onChange,
35
+ ...props
36
+ } ) => {
37
+ const [ color, setColor ] = useState< string | undefined >();
38
+
39
+ return (
40
+ <ColorPicker
41
+ { ...props }
42
+ color={ color }
43
+ onChange={ ( ...changeArgs ) => {
44
+ onChange?.( ...changeArgs );
45
+ setColor( ...changeArgs );
46
+ } }
47
+ />
48
+ );
49
+ };
50
+
51
+ export const Default = Template.bind( {} );
@@ -9,34 +9,37 @@ import { render, fireEvent, waitFor } from '@testing-library/react';
9
9
  import { ColorPicker } from '..';
10
10
 
11
11
  /**
12
- * Ordinarily we'd try to select the compnoent by role but the silder role appears
12
+ * Ordinarily we'd try to select the component by role but the slider role appears
13
13
  * on several elements and we'd end up encoding assumptions about order when
14
- * trying to select the appropriate element. We might as well just use the classname
14
+ * trying to select the appropriate element. We might as well just use the class name
15
15
  * on the container which will be more durable if, for example, the order changes.
16
- *
17
- * @param {HTMLElement} container
18
- * @return {HTMLElement} The saturation element
19
16
  */
20
- function getSaturation( container ) {
17
+ function getSaturation( container: HTMLElement ) {
21
18
  return container.querySelector(
22
19
  '.react-colorful__saturation .react-colorful__interactive'
23
20
  );
24
21
  }
25
22
 
23
+ type PageXPageY = { pageX: number; pageY: number };
24
+
26
25
  // Fix to pass `pageX` and `pageY`
27
26
  // See https://github.com/testing-library/react-testing-library/issues/268
28
- class FakeMouseEvent extends window.MouseEvent {
29
- constructor( type, values = {} ) {
27
+ class FakeMouseEvent extends MouseEvent {
28
+ constructor( type: MouseEvent[ 'type' ], values?: PageXPageY ) {
30
29
  super( type, { buttons: 1, bubbles: true, ...values } );
31
30
 
32
31
  Object.assign( this, {
33
- pageX: values.pageX || 0,
34
- pageY: values.pageY || 0,
32
+ pageX: values?.pageX ?? 0,
33
+ pageY: values?.pageY ?? 0,
35
34
  } );
36
35
  }
37
36
  }
38
37
 
39
- function moveReactColorfulSlider( sliderElement, from, to ) {
38
+ function moveReactColorfulSlider(
39
+ sliderElement: Element,
40
+ from: PageXPageY,
41
+ to: PageXPageY
42
+ ) {
40
43
  fireEvent( sliderElement, new FakeMouseEvent( 'mousedown', from ) );
41
44
  fireEvent( sliderElement, new FakeMouseEvent( 'mousemove', to ) );
42
45
  }
@@ -81,6 +84,13 @@ describe( 'ColorPicker', () => {
81
84
  );
82
85
 
83
86
  const saturation = getSaturation( container );
87
+
88
+ if ( saturation === null ) {
89
+ throw new Error( 'The saturation slider could not be found' );
90
+ }
91
+
92
+ expect( saturation ).toBeInTheDocument();
93
+
84
94
  moveReactColorfulSlider(
85
95
  saturation,
86
96
  { pageX: 0, pageY: 0 },
@@ -106,6 +116,13 @@ describe( 'ColorPicker', () => {
106
116
  );
107
117
 
108
118
  const saturation = getSaturation( container );
119
+
120
+ if ( saturation === null ) {
121
+ throw new Error( 'The saturation slider could not be found' );
122
+ }
123
+
124
+ expect( saturation ).toBeInTheDocument();
125
+
109
126
  moveReactColorfulSlider(
110
127
  saturation,
111
128
  { pageX: 0, pageY: 0 },
@@ -121,13 +138,7 @@ describe( 'ColorPicker', () => {
121
138
 
122
139
  it( 'should fire onChange with the HSL value', async () => {
123
140
  const onChange = jest.fn();
124
- const color = {
125
- h: 125,
126
- s: 0.2,
127
- l: 0.5,
128
- // Add alpha to prove it's ignored.
129
- a: 0.5,
130
- };
141
+ const color = 'hsla(125, 20%, 50%, 0.5)';
131
142
 
132
143
  const { container } = render(
133
144
  <ColorPicker
@@ -138,6 +149,13 @@ describe( 'ColorPicker', () => {
138
149
  );
139
150
 
140
151
  const saturation = getSaturation( container );
152
+
153
+ if ( saturation === null ) {
154
+ throw new Error( 'The saturation slider could not be found' );
155
+ }
156
+
157
+ expect( saturation ).toBeInTheDocument();
158
+
141
159
  moveReactColorfulSlider(
142
160
  saturation,
143
161
  { pageX: 0, pageY: 0 },