@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
@@ -1,47 +1,27 @@
1
- // @ts-nocheck
2
-
3
1
  /**
4
2
  * Internal dependencies
5
3
  */
6
4
  import { MINIMUM_DISTANCE_BETWEEN_POINTS } from './constants';
7
- /**
8
- * Control point for the gradient bar.
9
- *
10
- * @typedef {Object} ControlPoint
11
- * @property {string} color Color of the control point.
12
- * @property {number} position Integer position of the control point as a percentage.
13
- */
14
-
15
- /**
16
- * Color as parsed from the gradient by gradient-parser.
17
- *
18
- * @typedef {Object} Color
19
- * @property {string} r Red component.
20
- * @property {string} g Green component.
21
- * @property {string} b Green component.
22
- * @property {string} [a] Optional alpha component.
23
- */
24
5
 
25
6
  /**
26
7
  * Clamps a number between 0 and 100.
27
8
  *
28
- * @param {number} value Value to clamp.
9
+ * @param value Value to clamp.
29
10
  *
30
- * @return {number} Value clamped between 0 and 100.
11
+ * @return Value clamped between 0 and 100.
31
12
  */
32
-
33
13
  export function clampPercent(value) {
34
14
  return Math.max(0, Math.min(100, value));
35
15
  }
36
16
  /**
37
17
  * Check if a control point is overlapping with another.
38
18
  *
39
- * @param {ControlPoint[]} value Array of control points.
40
- * @param {number} initialIndex Index of the position to test.
41
- * @param {number} newPosition New position of the control point.
42
- * @param {number} minDistance Distance considered to be overlapping.
19
+ * @param value Array of control points.
20
+ * @param initialIndex Index of the position to test.
21
+ * @param newPosition New position of the control point.
22
+ * @param minDistance Distance considered to be overlapping.
43
23
  *
44
- * @return {boolean} True if the point is overlapping.
24
+ * @return True if the point is overlapping.
45
25
  */
46
26
 
47
27
  export function isOverlapping(value, initialIndex, newPosition) {
@@ -59,11 +39,11 @@ export function isOverlapping(value, initialIndex, newPosition) {
59
39
  /**
60
40
  * Adds a control point from an array and returns the new array.
61
41
  *
62
- * @param {ControlPoint[]} points Array of control points.
63
- * @param {number} position Position to insert the new point.
64
- * @param {Color} color Color to update the control point at index.
42
+ * @param points Array of control points.
43
+ * @param position Position to insert the new point.
44
+ * @param color Color to update the control point at index.
65
45
  *
66
- * @return {ControlPoint[]} New array of control points.
46
+ * @return New array of control points.
67
47
  */
68
48
 
69
49
  export function addControlPoint(points, position, color) {
@@ -79,25 +59,25 @@ export function addControlPoint(points, position, color) {
79
59
  /**
80
60
  * Removes a control point from an array and returns the new array.
81
61
  *
82
- * @param {ControlPoint[]} points Array of control points.
83
- * @param {number} index Index to remove.
62
+ * @param points Array of control points.
63
+ * @param index Index to remove.
84
64
  *
85
- * @return {ControlPoint[]} New array of control points.
65
+ * @return New array of control points.
86
66
  */
87
67
 
88
68
  export function removeControlPoint(points, index) {
89
- return points.filter((point, pointIndex) => {
69
+ return points.filter((_point, pointIndex) => {
90
70
  return pointIndex !== index;
91
71
  });
92
72
  }
93
73
  /**
94
74
  * Updates a control point from an array and returns the new array.
95
75
  *
96
- * @param {ControlPoint[]} points Array of control points.
97
- * @param {number} index Index to update.
98
- * @param {ControlPoint[]} newPoint New control point to replace the index.
76
+ * @param points Array of control points.
77
+ * @param index Index to update.
78
+ * @param newPoint New control point to replace the index.
99
79
  *
100
- * @return {ControlPoint[]} New array of control points.
80
+ * @return New array of control points.
101
81
  */
102
82
 
103
83
  export function updateControlPoint(points, index, newPoint) {
@@ -108,11 +88,11 @@ export function updateControlPoint(points, index, newPoint) {
108
88
  /**
109
89
  * Updates the position of a control point from an array and returns the new array.
110
90
  *
111
- * @param {ControlPoint[]} points Array of control points.
112
- * @param {number} index Index to update.
113
- * @param {number} newPosition Position to move the control point at index.
91
+ * @param points Array of control points.
92
+ * @param index Index to update.
93
+ * @param newPosition Position to move the control point at index.
114
94
  *
115
- * @return {ControlPoint[]} New array of control points.
95
+ * @return New array of control points.
116
96
  */
117
97
 
118
98
  export function updateControlPointPosition(points, index, newPosition) {
@@ -128,11 +108,11 @@ export function updateControlPointPosition(points, index, newPosition) {
128
108
  /**
129
109
  * Updates the position of a control point from an array and returns the new array.
130
110
  *
131
- * @param {ControlPoint[]} points Array of control points.
132
- * @param {number} index Index to update.
133
- * @param {Color} newColor Color to update the control point at index.
111
+ * @param points Array of control points.
112
+ * @param index Index to update.
113
+ * @param newColor Color to update the control point at index.
134
114
  *
135
- * @return {ControlPoint[]} New array of control points.
115
+ * @return New array of control points.
136
116
  */
137
117
 
138
118
  export function updateControlPointColor(points, index, newColor) {
@@ -144,11 +124,11 @@ export function updateControlPointColor(points, index, newColor) {
144
124
  /**
145
125
  * Updates the position of a control point from an array and returns the new array.
146
126
  *
147
- * @param {ControlPoint[]} points Array of control points.
148
- * @param {number} position Position of the color stop.
149
- * @param {string} newColor Color to update the control point at index.
127
+ * @param points Array of control points.
128
+ * @param position Position of the color stop.
129
+ * @param newColor Color to update the control point at index.
150
130
  *
151
- * @return {ControlPoint[]} New array of control points.
131
+ * @return New array of control points.
152
132
  */
153
133
 
154
134
  export function updateControlPointColorByPosition(points, position, newColor) {
@@ -158,10 +138,10 @@ export function updateControlPointColorByPosition(points, position, newColor) {
158
138
  /**
159
139
  * Gets the horizontal coordinate when dragging a control point with the mouse.
160
140
  *
161
- * @param {number} mouseXCoordinate Horizontal coordinate of the mouse position.
162
- * @param {Element} containerElement Container for the gradient picker.
141
+ * @param mouseXcoordinate Horizontal coordinate of the mouse position.
142
+ * @param containerElement Container for the gradient picker.
163
143
  *
164
- * @return {number | undefined} Whole number percentage from the left.
144
+ * @return Whole number percentage from the left.
165
145
  */
166
146
 
167
147
  export function getHorizontalRelativeGradientPosition(mouseXCoordinate, containerElement) {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/custom-gradient-picker/gradient-bar/utils.js"],"names":["MINIMUM_DISTANCE_BETWEEN_POINTS","clampPercent","value","Math","max","min","isOverlapping","initialIndex","newPosition","minDistance","initialPosition","position","minPosition","maxPosition","some","index","abs","addControlPoint","points","color","nextIndex","findIndex","point","newPoint","newPoints","slice","splice","removeControlPoint","filter","pointIndex","updateControlPoint","newValue","updateControlPointPosition","updateControlPointColor","newColor","updateControlPointColorByPosition","getHorizontalRelativeGradientPosition","mouseXCoordinate","containerElement","x","width","getBoundingClientRect","absolutePositionValue","round"],"mappings":"AAAA;;AAEA;AACA;AACA;AACA,SAASA,+BAAT,QAAgD,aAAhD;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,YAAT,CAAuBC,KAAvB,EAA+B;AACrC,SAAOC,IAAI,CAACC,GAAL,CAAU,CAAV,EAAaD,IAAI,CAACE,GAAL,CAAU,GAAV,EAAeH,KAAf,CAAb,CAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASI,aAAT,CACNJ,KADM,EAENK,YAFM,EAGNC,WAHM,EAKL;AAAA,MADDC,WACC,uEADaT,+BACb;AACD,QAAMU,eAAe,GAAGR,KAAK,CAAEK,YAAF,CAAL,CAAsBI,QAA9C;AACA,QAAM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gBADM,EAENC,gBAFM,EAGL;AACD,MAAK,CAAEA,gBAAP,EAA0B;AACzB;AACA;;AACD,QAAM;AAAEC,IAAAA,CAAF;AAAKC,IAAAA;AAAL,MAAeF,gBAAgB,CAACG,qBAAjB,EAArB;AACA,QAAMC,qBAAqB,GAAGL,gBAAgB,GAAGE,CAAjD;AACA,SAAOpC,IAAI,CAACwC,KAAL,CACN1C,YAAY,CAAIyC,qBAAqB,GAAG,GAA1B,GAAkCF,KAApC,CADN,CAAP;AAGA","sourcesContent":["// @ts-nocheck\n\n/**\n * Internal dependencies\n */\nimport { MINIMUM_DISTANCE_BETWEEN_POINTS } from './constants';\n\n/**\n * Control point for the gradient bar.\n *\n * @typedef {Object} ControlPoint\n * @property {string} color Color of the control point.\n * @property {number} position Integer position of the control point as a percentage.\n */\n\n/**\n * Color as parsed from the gradient by gradient-parser.\n *\n * @typedef {Object} Color\n * @property {string} r Red component.\n * @property {string} g Green component.\n * @property {string} b Green component.\n * @property {string} [a] Optional alpha component.\n */\n\n/**\n * Clamps a number between 0 and 100.\n *\n * @param {number} value Value to clamp.\n *\n * @return {number} Value clamped between 0 and 100.\n */\nexport function clampPercent( value ) {\n\treturn Math.max( 0, Math.min( 100, value ) );\n}\n\n/**\n * Check if a control point is overlapping with another.\n *\n * @param {ControlPoint[]} value Array of control points.\n * @param {number} initialIndex Index of the position to test.\n * @param {number} newPosition New position of the control point.\n * @param {number} minDistance Distance considered to be overlapping.\n *\n * @return {boolean} True if the point is overlapping.\n */\nexport function isOverlapping(\n\tvalue,\n\tinitialIndex,\n\tnewPosition,\n\tminDistance = MINIMUM_DISTANCE_BETWEEN_POINTS\n) {\n\tconst initialPosition = value[ initialIndex ].position;\n\tconst minPosition = Math.min( initialPosition, newPosition );\n\tconst maxPosition = Math.max( initialPosition, newPosition );\n\n\treturn value.some( ( { position }, index ) => {\n\t\treturn (\n\t\t\tindex !== initialIndex &&\n\t\t\t( Math.abs( position - newPosition ) < minDistance ||\n\t\t\t\t( minPosition < position && position < maxPosition ) )\n\t\t);\n\t} );\n}\n\n/**\n * Adds a control point from an array and returns the new array.\n *\n * @param {ControlPoint[]} points Array of control points.\n * @param {number} position Position to insert the new point.\n * @param {Color} color Color to update the control point at index.\n *\n * @return {ControlPoint[]} New array of control points.\n */\nexport function addControlPoint( points, position, color ) {\n\tconst nextIndex = points.findIndex(\n\t\t( point ) => point.position > position\n\t);\n\tconst newPoint = { color, position };\n\tconst newPoints = points.slice();\n\tnewPoints.splice( nextIndex - 1, 0, newPoint );\n\treturn newPoints;\n}\n\n/**\n * Removes a control point from an array and returns the new array.\n *\n * @param {ControlPoint[]} points Array of control points.\n * @param {number} index Index to remove.\n *\n * @return {ControlPoint[]} New array of control points.\n */\nexport function removeControlPoint( points, index ) {\n\treturn points.filter( ( point, pointIndex ) => {\n\t\treturn pointIndex !== index;\n\t} );\n}\n\n/**\n * Updates a control point from an array and returns the new array.\n *\n * @param {ControlPoint[]} points Array of control points.\n * @param {number} index Index to update.\n * @param {ControlPoint[]} newPoint New control point to replace the index.\n *\n * @return {ControlPoint[]} New array of control points.\n */\nexport function updateControlPoint( points, index, newPoint ) {\n\tconst newValue = points.slice();\n\tnewValue[ index ] = newPoint;\n\treturn newValue;\n}\n\n/**\n * Updates the position of a control point from an array and returns the new array.\n *\n * @param {ControlPoint[]} points Array of control points.\n * @param {number} index Index to update.\n * @param {number} newPosition Position to move the control point at index.\n *\n * @return {ControlPoint[]} New array of control points.\n */\nexport function updateControlPointPosition( points, index, newPosition ) {\n\tif ( isOverlapping( points, index, newPosition ) ) {\n\t\treturn points;\n\t}\n\tconst newPoint = {\n\t\t...points[ index ],\n\t\tposition: newPosition,\n\t};\n\treturn updateControlPoint( points, index, newPoint );\n}\n\n/**\n * Updates the position of a control point from an array and returns the new array.\n *\n * @param {ControlPoint[]} points Array of control points.\n * @param {number} index Index to update.\n * @param {Color} newColor Color to update the control point at index.\n *\n * @return {ControlPoint[]} New array of control points.\n */\nexport function updateControlPointColor( points, index, newColor ) {\n\tconst newPoint = {\n\t\t...points[ index ],\n\t\tcolor: newColor,\n\t};\n\treturn updateControlPoint( points, index, newPoint );\n}\n\n/**\n * Updates the position of a control point from an array and returns the new array.\n *\n * @param {ControlPoint[]} points Array of control points.\n * @param {number} position Position of the color stop.\n * @param {string} newColor Color to update the control point at index.\n *\n * @return {ControlPoint[]} New array of control points.\n */\nexport function updateControlPointColorByPosition(\n\tpoints,\n\tposition,\n\tnewColor\n) {\n\tconst index = points.findIndex( ( point ) => point.position === position );\n\treturn updateControlPointColor( points, index, newColor );\n}\n\n/**\n * Gets the horizontal coordinate when dragging a control point with the mouse.\n *\n * @param {number} mouseXCoordinate Horizontal coordinate of the mouse position.\n * @param {Element} containerElement Container for the gradient picker.\n *\n * @return {number | undefined} Whole number percentage from the left.\n */\nexport function getHorizontalRelativeGradientPosition(\n\tmouseXCoordinate,\n\tcontainerElement\n) {\n\tif ( ! containerElement ) {\n\t\treturn;\n\t}\n\tconst { x, width } = containerElement.getBoundingClientRect();\n\tconst absolutePositionValue = mouseXCoordinate - x;\n\treturn Math.round(\n\t\tclampPercent( ( absolutePositionValue * 100 ) / width )\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/custom-gradient-picker/gradient-bar/utils.ts"],"names":["MINIMUM_DISTANCE_BETWEEN_POINTS","clampPercent","value","Math","max","min","isOverlapping","initialIndex","newPosition","minDistance","initialPosition","position","minPosition","maxPosition","some","index","abs","addControlPoint","points","color","nextIndex","findIndex","point","newPoint","newPoints","slice","splice","removeControlPoint","filter","_point","pointIndex","updateControlPoint","newValue","updateControlPointPosition","updateControlPointColor","newColor","updateControlPointColorByPosition","getHorizontalRelativeGradientPosition","mouseXCoordinate","containerElement","x","width","getBoundingClientRect","absolutePositionValue","round"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,+BAAT,QAAgD,aAAhD;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,YAAT,CAAuBC,KAAvB,EAAuC;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EAENP,QAFM,EAGNwB,QAHM,EAIL;AACD,QAAMpB,KAAK,GAAGG,MAAM,CAACG,SAAP,CAAoBC,KAAF,IAAaA,KAAK,CAACX,QAAN,KAAmBA,QAAlD,CAAd;AACA,SAAOuB,uBAAuB,CAAEhB,MAAF,EAAUH,KAAV,EAAiBoB,QAAjB,CAA9B;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AASA,OAAO,SAASE,qCAAT,CACNC,gBADM,EAENC,gBAFM,EAGL;AACD,MAAK,CAAEA,gBAAP,EAA0B;AACzB;AACA;;AACD,QAAM;AAAEC,IAAAA,CAAF;AAAKC,IAAAA;AAAL,MAAeF,gBAAgB,CAACG,qBAAjB,EAArB;AACA,QAAMC,qBAAqB,GAAGL,gBAAgB,GAAGE,CAAjD;AACA,SAAOrC,IAAI,CAACyC,KAAL,CACN3C,YAAY,CAAI0C,qBAAqB,GAAG,GAA1B,GAAkCF,KAApC,CADN,CAAP;AAGA","sourcesContent":["/**\n * Internal dependencies\n */\nimport { MINIMUM_DISTANCE_BETWEEN_POINTS } from './constants';\nimport type { ControlPoint } from '../types';\n\n/**\n * Clamps a number between 0 and 100.\n *\n * @param value Value to clamp.\n *\n * @return Value clamped between 0 and 100.\n */\nexport function clampPercent( value: number ) {\n\treturn Math.max( 0, Math.min( 100, value ) );\n}\n\n/**\n * Check if a control point is overlapping with another.\n *\n * @param value Array of control points.\n * @param initialIndex Index of the position to test.\n * @param newPosition New position of the control point.\n * @param minDistance Distance considered to be overlapping.\n *\n * @return True if the point is overlapping.\n */\nexport function isOverlapping(\n\tvalue: ControlPoint[],\n\tinitialIndex: number,\n\tnewPosition: number,\n\tminDistance: number = MINIMUM_DISTANCE_BETWEEN_POINTS\n) {\n\tconst initialPosition = value[ initialIndex ].position;\n\tconst minPosition = Math.min( initialPosition, newPosition );\n\tconst maxPosition = Math.max( initialPosition, newPosition );\n\n\treturn value.some( ( { position }, index ) => {\n\t\treturn (\n\t\t\tindex !== initialIndex &&\n\t\t\t( Math.abs( position - newPosition ) < minDistance ||\n\t\t\t\t( minPosition < position && position < maxPosition ) )\n\t\t);\n\t} );\n}\n\n/**\n * Adds a control point from an array and returns the new array.\n *\n * @param points Array of control points.\n * @param position Position to insert the new point.\n * @param color Color to update the control point at index.\n *\n * @return New array of control points.\n */\nexport function addControlPoint(\n\tpoints: ControlPoint[],\n\tposition: number,\n\tcolor: ControlPoint[ 'color' ]\n) {\n\tconst nextIndex = points.findIndex(\n\t\t( point ) => point.position > position\n\t);\n\tconst newPoint = { color, position };\n\tconst newPoints = points.slice();\n\tnewPoints.splice( nextIndex - 1, 0, newPoint );\n\treturn newPoints;\n}\n\n/**\n * Removes a control point from an array and returns the new array.\n *\n * @param points Array of control points.\n * @param index Index to remove.\n *\n * @return New array of control points.\n */\nexport function removeControlPoint( points: ControlPoint[], index: number ) {\n\treturn points.filter( ( _point, pointIndex ) => {\n\t\treturn pointIndex !== index;\n\t} );\n}\n/**\n * Updates a control point from an array and returns the new array.\n *\n * @param points Array of control points.\n * @param index Index to update.\n * @param newPoint New control point to replace the index.\n *\n * @return New array of control points.\n */\nexport function updateControlPoint(\n\tpoints: ControlPoint[],\n\tindex: number,\n\tnewPoint: ControlPoint\n) {\n\tconst newValue = points.slice();\n\tnewValue[ index ] = newPoint;\n\treturn newValue;\n}\n\n/**\n * Updates the position of a control point from an array and returns the new array.\n *\n * @param points Array of control points.\n * @param index Index to update.\n * @param newPosition Position to move the control point at index.\n *\n * @return New array of control points.\n */\nexport function updateControlPointPosition(\n\tpoints: ControlPoint[],\n\tindex: number,\n\tnewPosition: ControlPoint[ 'position' ]\n) {\n\tif ( isOverlapping( points, index, newPosition ) ) {\n\t\treturn points;\n\t}\n\tconst newPoint = {\n\t\t...points[ index ],\n\t\tposition: newPosition,\n\t};\n\treturn updateControlPoint( points, index, newPoint );\n}\n\n/**\n * Updates the position of a control point from an array and returns the new array.\n *\n * @param points Array of control points.\n * @param index Index to update.\n * @param newColor Color to update the control point at index.\n *\n * @return New array of control points.\n */\nexport function updateControlPointColor(\n\tpoints: ControlPoint[],\n\tindex: number,\n\tnewColor: ControlPoint[ 'color' ]\n) {\n\tconst newPoint = {\n\t\t...points[ index ],\n\t\tcolor: newColor,\n\t};\n\treturn updateControlPoint( points, index, newPoint );\n}\n\n/**\n * Updates the position of a control point from an array and returns the new array.\n *\n * @param points Array of control points.\n * @param position Position of the color stop.\n * @param newColor Color to update the control point at index.\n *\n * @return New array of control points.\n */\nexport function updateControlPointColorByPosition(\n\tpoints: ControlPoint[],\n\tposition: ControlPoint[ 'position' ],\n\tnewColor: ControlPoint[ 'color' ]\n) {\n\tconst index = points.findIndex( ( point ) => point.position === position );\n\treturn updateControlPointColor( points, index, newColor );\n}\n\n/**\n * Gets the horizontal coordinate when dragging a control point with the mouse.\n *\n * @param mouseXcoordinate Horizontal coordinate of the mouse position.\n * @param containerElement Container for the gradient picker.\n *\n * @return Whole number percentage from the left.\n */\nexport function getHorizontalRelativeGradientPosition(\n\tmouseXcoordinate: number,\n\tcontainerElement: HTMLDivElement\n): number;\nexport function getHorizontalRelativeGradientPosition(\n\tmouseXcoordinate: number,\n\tcontainerElement: null\n): undefined;\nexport function getHorizontalRelativeGradientPosition(\n\tmouseXCoordinate: number,\n\tcontainerElement: HTMLDivElement | null\n) {\n\tif ( ! containerElement ) {\n\t\treturn;\n\t}\n\tconst { x, width } = containerElement.getBoundingClientRect();\n\tconst absolutePositionValue = mouseXCoordinate - x;\n\treturn Math.round(\n\t\tclampPercent( ( absolutePositionValue * 100 ) / width )\n\t);\n}\n"]}
@@ -1,14 +1,13 @@
1
1
  import { createElement } from "@wordpress/element";
2
- // @ts-nocheck
3
2
 
4
3
  /**
5
4
  * External dependencies
6
5
  */
7
6
  import classnames from 'classnames';
7
+
8
8
  /**
9
9
  * WordPress dependencies
10
10
  */
11
-
12
11
  import deprecated from '@wordpress/deprecated';
13
12
  import { __ } from '@wordpress/i18n';
14
13
  /**
@@ -22,7 +21,7 @@ import SelectControl from '../select-control';
22
21
  import { VStack } from '../v-stack';
23
22
  import { getGradientAstWithDefault, getLinearGradientRepresentation, getGradientAstWithControlPoints, getStopCssColor } from './utils';
24
23
  import { serializeGradient } from './serializer';
25
- import { DEFAULT_LINEAR_GRADIENT_ANGLE, HORIZONTAL_GRADIENT_ORIENTATION, GRADIENT_OPTIONS, DEFAULT_GRADIENT } from './constants';
24
+ import { DEFAULT_LINEAR_GRADIENT_ANGLE, HORIZONTAL_GRADIENT_ORIENTATION, GRADIENT_OPTIONS } from './constants';
26
25
  import { AccessoryWrapper, SelectWrapper } from './styles/custom-gradient-picker-styles';
27
26
 
28
27
  const GradientAnglePicker = _ref => {
@@ -39,7 +38,7 @@ const GradientAnglePicker = _ref => {
39
38
  onChange(serializeGradient({ ...gradientAST,
40
39
  orientation: {
41
40
  type: 'angular',
42
- value: newAngle
41
+ value: `${newAngle}`
43
42
  }
44
43
  }));
45
44
  };
@@ -63,9 +62,7 @@ const GradientTypePicker = _ref2 => {
63
62
 
64
63
  const onSetLinearGradient = () => {
65
64
  onChange(serializeGradient({ ...gradientAST,
66
- ...(gradientAST.orientation ? {} : {
67
- orientation: HORIZONTAL_GRADIENT_ORIENTATION
68
- }),
65
+ orientation: gradientAST.orientation ? undefined : HORIZONTAL_GRADIENT_ORIENTATION,
69
66
  type: 'linear-gradient'
70
67
  }));
71
68
  };
@@ -98,30 +95,59 @@ const GradientTypePicker = _ref2 => {
98
95
  onChange: handleOnChange,
99
96
  options: GRADIENT_OPTIONS,
100
97
  size: "__unstable-large",
101
- value: hasGradient && type
98
+ value: hasGradient ? type : undefined
102
99
  });
103
100
  };
101
+ /**
102
+ * CustomGradientPicker is a React component that renders a UI for specifying
103
+ * linear or radial gradients. Radial gradients are displayed in the picker as
104
+ * a slice of the gradient from the center to the outside.
105
+ *
106
+ * ```jsx
107
+ * import { CustomGradientPicker } from '@wordpress/components';
108
+ * import { useState } from '@wordpress/element';
109
+ *
110
+ * const MyCustomGradientPicker = () => {
111
+ * const [ gradient, setGradient ] = useState();
112
+ *
113
+ * return (
114
+ * <CustomGradientPicker
115
+ * value={ gradient }
116
+ * onChange={ setGradient }
117
+ * />
118
+ * );
119
+ * };
120
+ * ```
121
+ */
104
122
 
105
- export default function CustomGradientPicker(_ref3) {
123
+
124
+ export function CustomGradientPicker(_ref3) {
106
125
  let {
107
126
  /** Start opting into the new margin-free styles that will become the default in a future version. */
108
127
  __nextHasNoMargin = false,
109
128
  value,
110
129
  onChange,
111
- __experimentalIsRenderedInSidebar
130
+ __experimentalIsRenderedInSidebar = false
112
131
  } = _ref3;
113
- const gradientAST = getGradientAstWithDefault(value); // On radial gradients the bar should display a linear gradient.
132
+ const {
133
+ gradientAST,
134
+ hasGradient
135
+ } = getGradientAstWithDefault(value); // On radial gradients the bar should display a linear gradient.
114
136
  // On radial gradients the bar represents a slice of the gradient from the center until the outside.
115
137
  // On liner gradients the bar represents the color stops from left to right independently of the angle.
116
138
 
117
- const background = getLinearGradientRepresentation(gradientAST);
118
- const hasGradient = gradientAST.value !== DEFAULT_GRADIENT; // Control points color option may be hex from presets, custom colors will be rgb.
139
+ const background = getLinearGradientRepresentation(gradientAST); // Control points color option may be hex from presets, custom colors will be rgb.
119
140
  // The position should always be a percentage.
120
141
 
121
- const controlPoints = gradientAST.colorStops.map(colorStop => ({
122
- color: getStopCssColor(colorStop),
123
- position: parseInt(colorStop.length.value)
124
- }));
142
+ const controlPoints = gradientAST.colorStops.map(colorStop => {
143
+ return {
144
+ color: getStopCssColor(colorStop),
145
+ // Although it's already been checked by `hasUnsupportedLength` in `getGradientAstWithDefault`,
146
+ // TypeScript doesn't know that `colorStop.length` is not undefined here.
147
+ // @ts-expect-error
148
+ position: parseInt(colorStop.length.value)
149
+ };
150
+ });
125
151
 
126
152
  if (!__nextHasNoMargin) {
127
153
  deprecated('Outer margin styles for wp.components.CustomGradientPicker', {
@@ -157,4 +183,5 @@ export default function CustomGradientPicker(_ref3) {
157
183
  onChange: onChange
158
184
  }))));
159
185
  }
186
+ export default CustomGradientPicker;
160
187
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/custom-gradient-picker/index.js"],"names":["classnames","deprecated","__","AnglePickerControl","CustomGradientBar","Flex","SelectControl","VStack","getGradientAstWithDefault","getLinearGradientRepresentation","getGradientAstWithControlPoints","getStopCssColor","serializeGradient","DEFAULT_LINEAR_GRADIENT_ANGLE","HORIZONTAL_GRADIENT_ORIENTATION","GRADIENT_OPTIONS","DEFAULT_GRADIENT","AccessoryWrapper","SelectWrapper","GradientAnglePicker","gradientAST","hasGradient","onChange","angle","orientation","value","onAngleChange","newAngle","type","GradientTypePicker","onSetLinearGradient","onSetRadialGradient","restGradientAST","handleOnChange","next","CustomGradientPicker","__nextHasNoMargin","__experimentalIsRenderedInSidebar","background","controlPoints","colorStops","map","colorStop","color","position","parseInt","length","since","version","hint","newControlPoints"],"mappings":";AAAA;;AAEA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,OAAOC,UAAP,MAAuB,uBAAvB;AACA,SAASC,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AACA,OAAOC,kBAAP,MAA+B,yBAA/B;AACA,OAAOC,iBAAP,MAA8B,gBAA9B;AACA,SAASC,IAAT,QAAqB,SAArB;AACA,OAAOC,aAAP,MAA0B,mBAA1B;AACA,SAASC,MAAT,QAAuB,YAAvB;AACA,SACCC,yBADD,EAECC,+BAFD,EAGCC,+BAHD,EAICC,eAJD,QAKO,SALP;AAMA,SAASC,iBAAT,QAAkC,cAAlC;AACA,SACCC,6BADD,EAECC,+BAFD,EAGCC,gBAHD,EAICC,gBAJD,QAKO,aALP;AAMA,SACCC,gBADD,EAECC,aAFD,QAGO,wCAHP;;AAKA,MAAMC,mBAAmB,GAAG,QAA8C;AAAA;;AAAA,MAA5C;AAAEC,IAAAA,WAAF;AAAeC,IAAAA,WAAf;AAA4BC,IAAAA;AAA5B,GAA4C;AACzE,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C,cAAC,MAAD;AACC,IAAA,OAAO,EAAG,CADX;AAEC,IAAA,SAAS,EAAGjD,UAAU,CAAE,mCAAF,EAAuC;AAC5D,+BAAyBoC;AADmC,KAAvC;AAFvB,KAMC,cAAC,iBAAD;AACC,IAAA,iCAAiC,EAChCC,iCAFF;AAIC,IAAA,UAAU,EAAGC,UAJd;AAKC,IAAA,WAAW,EAAGjB,WALf;AAMC,IAAA,KAAK,EAAGkB,aANT;AAOC,IAAA,QAAQ,EAAKW,gBAAF,IAAwB;AAClC5B,MAAAA,QAAQ,CACPV,iBAAiB,CAChBF,+BAA+B,CAC9BU,WAD8B,EAE9B8B,gBAF8B,CADf,CADV,CAAR;AAQA;AAhBF,IAND,EAwBC,cAAC,IAAD;AACC,IAAA,GAAG,EAAG,CADP;AAEC,IAAA,SAAS,EAAC;AAFX,KAIC,cAAC,aAAD,QACC,cAAC,kBAAD;AACC,IAAA,WAAW,EAAG9B,WADf;AAEC,IAAA,WAAW,EAAGC,WAFf;AAGC,IAAA,QAAQ,EAAGC;AAHZ,IADD,CAJD,EAWC,cAAC,gBAAD,QACGF,WAAW,CAACQ,IAAZ,KAAqB,iBAArB,IACD,cAAC,mBAAD;AACC,IAAA,WAAW,EAAGR,WADf;AAEC,IAAA,WAAW,EAAGC,WAFf;AAGC,IAAA,QAAQ,EAAGC;AAHZ,IAFF,CAXD,CAxBD,CADD;AAgDA","sourcesContent":["// @ts-nocheck\n\n/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport deprecated from '@wordpress/deprecated';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport AnglePickerControl from '../angle-picker-control';\nimport CustomGradientBar from './gradient-bar';\nimport { Flex } from '../flex';\nimport SelectControl from '../select-control';\nimport { VStack } from '../v-stack';\nimport {\n\tgetGradientAstWithDefault,\n\tgetLinearGradientRepresentation,\n\tgetGradientAstWithControlPoints,\n\tgetStopCssColor,\n} from './utils';\nimport { serializeGradient } from './serializer';\nimport {\n\tDEFAULT_LINEAR_GRADIENT_ANGLE,\n\tHORIZONTAL_GRADIENT_ORIENTATION,\n\tGRADIENT_OPTIONS,\n\tDEFAULT_GRADIENT,\n} from './constants';\nimport {\n\tAccessoryWrapper,\n\tSelectWrapper,\n} from './styles/custom-gradient-picker-styles';\n\nconst GradientAnglePicker = ( { gradientAST, hasGradient, onChange } ) => {\n\tconst angle =\n\t\tgradientAST?.orientation?.value ?? DEFAULT_LINEAR_GRADIENT_ANGLE;\n\tconst onAngleChange = ( newAngle ) => {\n\t\tonChange(\n\t\t\tserializeGradient( {\n\t\t\t\t...gradientAST,\n\t\t\t\torientation: {\n\t\t\t\t\ttype: 'angular',\n\t\t\t\t\tvalue: newAngle,\n\t\t\t\t},\n\t\t\t} )\n\t\t);\n\t};\n\treturn (\n\t\t<AnglePickerControl\n\t\t\t__nextHasNoMarginBottom\n\t\t\tonChange={ onAngleChange }\n\t\t\tvalue={ hasGradient ? angle : '' }\n\t\t/>\n\t);\n};\n\nconst GradientTypePicker = ( { gradientAST, hasGradient, onChange } ) => {\n\tconst { type } = gradientAST;\n\tconst onSetLinearGradient = () => {\n\t\tonChange(\n\t\t\tserializeGradient( {\n\t\t\t\t...gradientAST,\n\t\t\t\t...( gradientAST.orientation\n\t\t\t\t\t? {}\n\t\t\t\t\t: { orientation: HORIZONTAL_GRADIENT_ORIENTATION } ),\n\t\t\t\ttype: 'linear-gradient',\n\t\t\t} )\n\t\t);\n\t};\n\n\tconst onSetRadialGradient = () => {\n\t\tconst { orientation, ...restGradientAST } = gradientAST;\n\t\tonChange(\n\t\t\tserializeGradient( {\n\t\t\t\t...restGradientAST,\n\t\t\t\ttype: 'radial-gradient',\n\t\t\t} )\n\t\t);\n\t};\n\n\tconst handleOnChange = ( next ) => {\n\t\tif ( next === 'linear-gradient' ) {\n\t\t\tonSetLinearGradient();\n\t\t}\n\t\tif ( next === 'radial-gradient' ) {\n\t\t\tonSetRadialGradient();\n\t\t}\n\t};\n\n\treturn (\n\t\t<SelectControl\n\t\t\t__nextHasNoMarginBottom\n\t\t\tclassName=\"components-custom-gradient-picker__type-picker\"\n\t\t\tlabel={ __( 'Type' ) }\n\t\t\tlabelPosition=\"top\"\n\t\t\tonChange={ handleOnChange }\n\t\t\toptions={ GRADIENT_OPTIONS }\n\t\t\tsize=\"__unstable-large\"\n\t\t\tvalue={ hasGradient && type }\n\t\t/>\n\t);\n};\n\nexport default function CustomGradientPicker( {\n\t/** Start opting into the new margin-free styles that will become the default in a future version. */\n\t__nextHasNoMargin = false,\n\tvalue,\n\tonChange,\n\t__experimentalIsRenderedInSidebar,\n} ) {\n\tconst gradientAST = getGradientAstWithDefault( value );\n\t// On radial gradients the bar should display a linear gradient.\n\t// On radial gradients the bar represents a slice of the gradient from the center until the outside.\n\t// On liner gradients the bar represents the color stops from left to right independently of the angle.\n\tconst background = getLinearGradientRepresentation( gradientAST );\n\tconst hasGradient = gradientAST.value !== DEFAULT_GRADIENT;\n\t// Control points color option may be hex from presets, custom colors will be rgb.\n\t// The position should always be a percentage.\n\tconst controlPoints = gradientAST.colorStops.map( ( colorStop ) => ( {\n\t\tcolor: getStopCssColor( colorStop ),\n\t\tposition: parseInt( colorStop.length.value ),\n\t} ) );\n\n\tif ( ! __nextHasNoMargin ) {\n\t\tdeprecated(\n\t\t\t'Outer margin styles for wp.components.CustomGradientPicker',\n\t\t\t{\n\t\t\t\tsince: '6.1',\n\t\t\t\tversion: '6.4',\n\t\t\t\thint: 'Set the `__nextHasNoMargin` prop to true to start opting into the new styles, which will become the default in a future version',\n\t\t\t}\n\t\t);\n\t}\n\n\treturn (\n\t\t<VStack\n\t\t\tspacing={ 4 }\n\t\t\tclassName={ classnames( 'components-custom-gradient-picker', {\n\t\t\t\t'is-next-has-no-margin': __nextHasNoMargin,\n\t\t\t} ) }\n\t\t>\n\t\t\t<CustomGradientBar\n\t\t\t\t__experimentalIsRenderedInSidebar={\n\t\t\t\t\t__experimentalIsRenderedInSidebar\n\t\t\t\t}\n\t\t\t\tbackground={ background }\n\t\t\t\thasGradient={ hasGradient }\n\t\t\t\tvalue={ controlPoints }\n\t\t\t\tonChange={ ( newControlPoints ) => {\n\t\t\t\t\tonChange(\n\t\t\t\t\t\tserializeGradient(\n\t\t\t\t\t\t\tgetGradientAstWithControlPoints(\n\t\t\t\t\t\t\t\tgradientAST,\n\t\t\t\t\t\t\t\tnewControlPoints\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t<Flex\n\t\t\t\tgap={ 3 }\n\t\t\t\tclassName=\"components-custom-gradient-picker__ui-line\"\n\t\t\t>\n\t\t\t\t<SelectWrapper>\n\t\t\t\t\t<GradientTypePicker\n\t\t\t\t\t\tgradientAST={ gradientAST }\n\t\t\t\t\t\thasGradient={ hasGradient }\n\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t/>\n\t\t\t\t</SelectWrapper>\n\t\t\t\t<AccessoryWrapper>\n\t\t\t\t\t{ gradientAST.type === 'linear-gradient' && (\n\t\t\t\t\t\t<GradientAnglePicker\n\t\t\t\t\t\t\tgradientAST={ gradientAST }\n\t\t\t\t\t\t\thasGradient={ hasGradient }\n\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</AccessoryWrapper>\n\t\t\t</Flex>\n\t\t</VStack>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/custom-gradient-picker/index.tsx"],"names":["classnames","deprecated","__","AnglePickerControl","CustomGradientBar","Flex","SelectControl","VStack","getGradientAstWithDefault","getLinearGradientRepresentation","getGradientAstWithControlPoints","getStopCssColor","serializeGradient","DEFAULT_LINEAR_GRADIENT_ANGLE","HORIZONTAL_GRADIENT_ORIENTATION","GRADIENT_OPTIONS","AccessoryWrapper","SelectWrapper","GradientAnglePicker","gradientAST","hasGradient","onChange","angle","orientation","value","onAngleChange","newAngle","type","GradientTypePicker","onSetLinearGradient","undefined","onSetRadialGradient","restGradientAST","handleOnChange","next","CustomGradientPicker","__nextHasNoMargin","__experimentalIsRenderedInSidebar","background","controlPoints","colorStops","map","colorStop","color","position","parseInt","length","since","version","hint","newControlPoints"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;;AAGA;AACA;AACA;AACA,OAAOC,UAAP,MAAuB,uBAAvB;AACA,SAASC,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AACA,OAAOC,kBAAP,MAA+B,yBAA/B;AACA,OAAOC,iBAAP,MAA8B,gBAA9B;AACA,SAASC,IAAT,QAAqB,SAArB;AACA,OAAOC,aAAP,MAA0B,mBAA1B;AACA,SAASC,MAAT,QAAuB,YAAvB;AACA,SACCC,yBADD,EAECC,+BAFD,EAGCC,+BAHD,EAICC,eAJD,QAKO,SALP;AAMA,SAASC,iBAAT,QAAkC,cAAlC;AACA,SACCC,6BADD,EAECC,+BAFD,EAGCC,gBAHD,QAIO,aAJP;AAKA,SACCC,gBADD,EAECC,aAFD,QAGO,wCAHP;;AAUA,MAAMC,mBAAmB,GAAG,QAIK;AAAA;;AAAA,MAJH;AAC7BC,IAAAA,WAD6B;AAE7BC,IAAAA,WAF6B;AAG7BC,IAAAA;AAH6B,GAIG;AAChC,QAAMC,KAAK,4BACVH,WADU,aACVA,WADU,iDACVA,WAAW,CAAEI,WADH,2DACV,uBAA0BC,KADhB,yEACyBX,6BADpC;;AAEA,QAAMY,aAAa,GAAKC,QAAF,IAAwB;AAC7CL,IAAAA,QAAQ,CACPT,iBAAiB,CAAE,EAClB,GAAGO,WADe;AAElBI,MAAAA,WAAW,EAAE;AACZI,QAAAA,IAAI,EAAE,SADM;AAEZH,QAAAA,KAAK,EAAG,GAAGE,QAAU;AAFT;AAFK,KAAF,CADV,CAAR;AASA,GAVD;;AAWA,SACC,cAAC,kBAAD;AACC,IAAA,uBAAuB,MADxB;AAEC,IAAA,QAAQ,EAAGD,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AA,QAAQ,EAAKW,gBAAF,IAAwB;AAClC7B,MAAAA,QAAQ,CACPT,iBAAiB,CAChBF,+BAA+B,CAC9BS,WAD8B,EAE9B+B,gBAF8B,CADf,CADV,CAAR;AAQA;AAhBF,IAND,EAwBC,cAAC,IAAD;AACC,IAAA,GAAG,EAAG,CADP;AAEC,IAAA,SAAS,EAAC;AAFX,KAIC,cAAC,aAAD,QACC,cAAC,kBAAD;AACC,IAAA,WAAW,EAAG/B,WADf;AAEC,IAAA,WAAW,EAAGC,WAFf;AAGC,IAAA,QAAQ,EAAGC;AAHZ,IADD,CAJD,EAWC,cAAC,gBAAD,QACGF,WAAW,CAACQ,IAAZ,KAAqB,iBAArB,IACD,cAAC,mBAAD;AACC,IAAA,WAAW,EAAGR,WADf;AAEC,IAAA,WAAW,EAAGC,WAFf;AAGC,IAAA,QAAQ,EAAGC;AAHZ,IAFF,CAXD,CAxBD,CADD;AAgDA;AAED,eAAec,oBAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport type gradientParser from 'gradient-parser';\n\n/**\n * WordPress dependencies\n */\nimport deprecated from '@wordpress/deprecated';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport AnglePickerControl from '../angle-picker-control';\nimport CustomGradientBar from './gradient-bar';\nimport { Flex } from '../flex';\nimport SelectControl from '../select-control';\nimport { VStack } from '../v-stack';\nimport {\n\tgetGradientAstWithDefault,\n\tgetLinearGradientRepresentation,\n\tgetGradientAstWithControlPoints,\n\tgetStopCssColor,\n} from './utils';\nimport { serializeGradient } from './serializer';\nimport {\n\tDEFAULT_LINEAR_GRADIENT_ANGLE,\n\tHORIZONTAL_GRADIENT_ORIENTATION,\n\tGRADIENT_OPTIONS,\n} from './constants';\nimport {\n\tAccessoryWrapper,\n\tSelectWrapper,\n} from './styles/custom-gradient-picker-styles';\nimport type {\n\tCustomGradientPickerProps,\n\tGradientAnglePickerProps,\n\tGradientTypePickerProps,\n} from './types';\n\nconst GradientAnglePicker = ( {\n\tgradientAST,\n\thasGradient,\n\tonChange,\n}: GradientAnglePickerProps ) => {\n\tconst angle =\n\t\tgradientAST?.orientation?.value ?? DEFAULT_LINEAR_GRADIENT_ANGLE;\n\tconst onAngleChange = ( newAngle: number ) => {\n\t\tonChange(\n\t\t\tserializeGradient( {\n\t\t\t\t...gradientAST,\n\t\t\t\torientation: {\n\t\t\t\t\ttype: 'angular',\n\t\t\t\t\tvalue: `${ newAngle }`,\n\t\t\t\t},\n\t\t\t} )\n\t\t);\n\t};\n\treturn (\n\t\t<AnglePickerControl\n\t\t\t__nextHasNoMarginBottom\n\t\t\tonChange={ onAngleChange }\n\t\t\tvalue={ hasGradient ? angle : '' }\n\t\t/>\n\t);\n};\n\nconst GradientTypePicker = ( {\n\tgradientAST,\n\thasGradient,\n\tonChange,\n}: GradientTypePickerProps ) => {\n\tconst { type } = gradientAST;\n\n\tconst onSetLinearGradient = () => {\n\t\tonChange(\n\t\t\tserializeGradient( {\n\t\t\t\t...gradientAST,\n\t\t\t\torientation: gradientAST.orientation\n\t\t\t\t\t? undefined\n\t\t\t\t\t: HORIZONTAL_GRADIENT_ORIENTATION,\n\t\t\t\ttype: 'linear-gradient',\n\t\t\t} as gradientParser.LinearGradientNode )\n\t\t);\n\t};\n\n\tconst onSetRadialGradient = () => {\n\t\tconst { orientation, ...restGradientAST } = gradientAST;\n\t\tonChange(\n\t\t\tserializeGradient( {\n\t\t\t\t...restGradientAST,\n\t\t\t\ttype: 'radial-gradient',\n\t\t\t} )\n\t\t);\n\t};\n\n\tconst handleOnChange = ( next: string ) => {\n\t\tif ( next === 'linear-gradient' ) {\n\t\t\tonSetLinearGradient();\n\t\t}\n\t\tif ( next === 'radial-gradient' ) {\n\t\t\tonSetRadialGradient();\n\t\t}\n\t};\n\n\treturn (\n\t\t<SelectControl\n\t\t\t__nextHasNoMarginBottom\n\t\t\tclassName=\"components-custom-gradient-picker__type-picker\"\n\t\t\tlabel={ __( 'Type' ) }\n\t\t\tlabelPosition=\"top\"\n\t\t\tonChange={ handleOnChange }\n\t\t\toptions={ GRADIENT_OPTIONS }\n\t\t\tsize=\"__unstable-large\"\n\t\t\tvalue={ hasGradient ? type : undefined }\n\t\t/>\n\t);\n};\n\n/**\n * CustomGradientPicker is a React component that renders a UI for specifying\n * linear or radial gradients. Radial gradients are displayed in the picker as\n * a slice of the gradient from the center to the outside.\n *\n * ```jsx\n * import { CustomGradientPicker } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * const MyCustomGradientPicker = () => {\n * const [ gradient, setGradient ] = useState();\n *\n * return (\n * <CustomGradientPicker\n *\t\t\tvalue={ gradient }\n *\t\t\tonChange={ setGradient }\n * />\n * );\n * };\n * ```\n */\nexport function CustomGradientPicker( {\n\t/** Start opting into the new margin-free styles that will become the default in a future version. */\n\t__nextHasNoMargin = false,\n\tvalue,\n\tonChange,\n\t__experimentalIsRenderedInSidebar = false,\n}: CustomGradientPickerProps ) {\n\tconst { gradientAST, hasGradient } = getGradientAstWithDefault( value );\n\n\t// On radial gradients the bar should display a linear gradient.\n\t// On radial gradients the bar represents a slice of the gradient from the center until the outside.\n\t// On liner gradients the bar represents the color stops from left to right independently of the angle.\n\tconst background = getLinearGradientRepresentation( gradientAST );\n\n\t// Control points color option may be hex from presets, custom colors will be rgb.\n\t// The position should always be a percentage.\n\tconst controlPoints = gradientAST.colorStops.map( ( colorStop ) => {\n\t\treturn {\n\t\t\tcolor: getStopCssColor( colorStop ),\n\t\t\t// Although it's already been checked by `hasUnsupportedLength` in `getGradientAstWithDefault`,\n\t\t\t// TypeScript doesn't know that `colorStop.length` is not undefined here.\n\t\t\t// @ts-expect-error\n\t\t\tposition: parseInt( colorStop.length.value ),\n\t\t};\n\t} );\n\n\tif ( ! __nextHasNoMargin ) {\n\t\tdeprecated(\n\t\t\t'Outer margin styles for wp.components.CustomGradientPicker',\n\t\t\t{\n\t\t\t\tsince: '6.1',\n\t\t\t\tversion: '6.4',\n\t\t\t\thint: 'Set the `__nextHasNoMargin` prop to true to start opting into the new styles, which will become the default in a future version',\n\t\t\t}\n\t\t);\n\t}\n\n\treturn (\n\t\t<VStack\n\t\t\tspacing={ 4 }\n\t\t\tclassName={ classnames( 'components-custom-gradient-picker', {\n\t\t\t\t'is-next-has-no-margin': __nextHasNoMargin,\n\t\t\t} ) }\n\t\t>\n\t\t\t<CustomGradientBar\n\t\t\t\t__experimentalIsRenderedInSidebar={\n\t\t\t\t\t__experimentalIsRenderedInSidebar\n\t\t\t\t}\n\t\t\t\tbackground={ background }\n\t\t\t\thasGradient={ hasGradient }\n\t\t\t\tvalue={ controlPoints }\n\t\t\t\tonChange={ ( newControlPoints ) => {\n\t\t\t\t\tonChange(\n\t\t\t\t\t\tserializeGradient(\n\t\t\t\t\t\t\tgetGradientAstWithControlPoints(\n\t\t\t\t\t\t\t\tgradientAST,\n\t\t\t\t\t\t\t\tnewControlPoints\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t<Flex\n\t\t\t\tgap={ 3 }\n\t\t\t\tclassName=\"components-custom-gradient-picker__ui-line\"\n\t\t\t>\n\t\t\t\t<SelectWrapper>\n\t\t\t\t\t<GradientTypePicker\n\t\t\t\t\t\tgradientAST={ gradientAST }\n\t\t\t\t\t\thasGradient={ hasGradient }\n\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t/>\n\t\t\t\t</SelectWrapper>\n\t\t\t\t<AccessoryWrapper>\n\t\t\t\t\t{ gradientAST.type === 'linear-gradient' && (\n\t\t\t\t\t\t<GradientAnglePicker\n\t\t\t\t\t\t\tgradientAST={ gradientAST }\n\t\t\t\t\t\t\thasGradient={ hasGradient }\n\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</AccessoryWrapper>\n\t\t\t</Flex>\n\t\t</VStack>\n\t);\n}\n\nexport default CustomGradientPicker;\n"]}
@@ -1,4 +1,6 @@
1
- // @ts-nocheck
1
+ /**
2
+ * External dependencies
3
+ */
2
4
  export function serializeGradientColor(_ref) {
3
5
  let {
4
6
  type,
@@ -38,7 +40,7 @@ export function serializeGradientColorStop(_ref2) {
38
40
  })} ${serializeGradientPosition(length)}`;
39
41
  }
40
42
  export function serializeGradientOrientation(orientation) {
41
- if (!orientation || orientation.type !== 'angular') {
43
+ if (Array.isArray(orientation) || !orientation || orientation.type !== 'angular') {
42
44
  return;
43
45
  }
44
46
 
@@ -52,9 +54,13 @@ export function serializeGradient(_ref3) {
52
54
  } = _ref3;
53
55
  const serializedOrientation = serializeGradientOrientation(orientation);
54
56
  const serializedColorStops = colorStops.sort((colorStop1, colorStop2) => {
55
- var _colorStop1$length$va, _colorStop1$length, _colorStop2$length$va, _colorStop2$length;
57
+ const getNumericStopValue = colorStop => {
58
+ var _colorStop$length;
56
59
 
57
- return ((_colorStop1$length$va = colorStop1 === null || colorStop1 === void 0 ? void 0 : (_colorStop1$length = colorStop1.length) === null || _colorStop1$length === void 0 ? void 0 : _colorStop1$length.value) !== null && _colorStop1$length$va !== void 0 ? _colorStop1$length$va : 0) - ((_colorStop2$length$va = colorStop2 === null || colorStop2 === void 0 ? void 0 : (_colorStop2$length = colorStop2.length) === null || _colorStop2$length === void 0 ? void 0 : _colorStop2$length.value) !== null && _colorStop2$length$va !== void 0 ? _colorStop2$length$va : 0);
60
+ return (colorStop === null || colorStop === void 0 ? void 0 : (_colorStop$length = colorStop.length) === null || _colorStop$length === void 0 ? void 0 : _colorStop$length.value) === undefined ? 0 : parseInt(colorStop.length.value);
61
+ };
62
+
63
+ return getNumericStopValue(colorStop1) - getNumericStopValue(colorStop2);
58
64
  }).map(serializeGradientColorStop);
59
65
  return `${type}(${[serializedOrientation, ...serializedColorStops].filter(Boolean).join(',')})`;
60
66
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/custom-gradient-picker/serializer.js"],"names":["serializeGradientColor","type","value","join","serializeGradientPosition","position","serializeGradientColorStop","length","serializeGradientOrientation","orientation","serializeGradient","colorStops","serializedOrientation","serializedColorStops","sort","colorStop1","colorStop2","map","filter","Boolean"],"mappings":"AAAA;AAEA,OAAO,SAASA,sBAAT,OAAmD;AAAA,MAAlB;AAAEC,IAAAA,IAAF;AAAQC,IAAAA;AAAR,GAAkB;;AACzD,MAAKD,IAAI,KAAK,SAAd,EAA0B;AACzB,WAAOC,KAAP;AACA;;AACD,MAAKD,IAAI,KAAK,KAAd,EAAsB;AACrB,WAAQ,IAAIC,KAAO,EAAnB;AACA;;AACD,SAAQ,GAAGD,IAAM,IAAIC,KAAK,CAACC,IAAN,CAAY,GAAZ,CAAmB,GAAxC;AACA;AAED,OAAO,SAASC,yBAAT,CAAoCC,QAApC,EAA+C;AACrD,MAAK,CAAEA,QAAP,EAAkB;AACjB,WAAO,EAAP;AACA;;AACD,QAAM;AAAEH,IAAAA,KAAF;AAASD,IAAAA;AAAT,MAAkBI,QAAxB;AACA,SAAQ,GAAGH,KAAO,GAAGD,IAAM,EAA3B;AACA;AAED,OAAO,SAASK,0BAAT,QAA+D;AAAA,MAA1B;AAAEL,IAAAA,IAAF;AAAQC,IAAAA,KAAR;AAAeK,IAAAA;AAAf,GAA0B;AACrE,SAAQ,GAAGP,sBAAsB,CAAE;AAClCC,IAAAA,IADkC;AAElCC,IAAAA;AAFkC,GAAF,CAG5B,IAAIE,yBAAyB,CAAEG,MAAF,CAAY,EAH9C;AAIA;AAED,OAAO,SAASC,4BAAT,CAAuCC,WAAvC,EAAqD;AAC3D,MAAK,CAAEA,WAAF,IAAiBA,WAAW,CAACR,IAAZ,KAAqB,SAA3C,EAAuD;AACtD;AACA;;AACD,SAAQ,GAAGQ,WAAW,CAACP,KAAO,KAA9B;AACA;AAED,OAAO,SAASQ,iBAAT,QAAgE;AAAA,MAApC;AAAET,IAAAA,IAAF;AAAQQ,IAAAA,WAAR;AAAqBE,IAAAA;AAArB,GAAoC;AACtE,QAAMC,qBAAqB,GAAGJ,4BAA4B,CAAEC,WAAF,CAA1D;AACA,QAAMI,oBAAoB,GAAGF,UAAU,CACrCG,IAD2B,CACrB,CAAEC,UAAF,EAAcC,UAAd,KAA8B;AAAA;;AACpC,WACC,0BAAED,UAAF,aAAEA,UAAF,6CAAEA,UAAU,CAAER,MAAd,uDAAE,mBAAoBL,KAAtB,yEAA+B,CAA/B,8BACEc,UADF,aACEA,UADF,6CACEA,UAAU,CAAET,MADd,uDACE,mBAAoBL,KADtB,yEAC+B,CAD/B,CADD;AAIA,GAN2B,EAO3Be,GAP2B,CAOtBX,0BAPsB,CAA7B;AAQA,SAAQ,GAAGL,IAAM,IAAI,CAAEW,qBAAF,EAAyB,GAAGC,oBAA5B,EACnBK,MADmB,CACXC,OADW,EAEnBhB,IAFmB,CAEb,GAFa,CAEN,GAFf;AAGA","sourcesContent":["// @ts-nocheck\n\nexport function serializeGradientColor( { type, value } ) {\n\tif ( type === 'literal' ) {\n\t\treturn value;\n\t}\n\tif ( type === 'hex' ) {\n\t\treturn `#${ value }`;\n\t}\n\treturn `${ type }(${ value.join( ',' ) })`;\n}\n\nexport function serializeGradientPosition( position ) {\n\tif ( ! position ) {\n\t\treturn '';\n\t}\n\tconst { value, type } = position;\n\treturn `${ value }${ type }`;\n}\n\nexport function serializeGradientColorStop( { type, value, length } ) {\n\treturn `${ serializeGradientColor( {\n\t\ttype,\n\t\tvalue,\n\t} ) } ${ serializeGradientPosition( length ) }`;\n}\n\nexport function serializeGradientOrientation( orientation ) {\n\tif ( ! orientation || orientation.type !== 'angular' ) {\n\t\treturn;\n\t}\n\treturn `${ orientation.value }deg`;\n}\n\nexport function serializeGradient( { type, orientation, colorStops } ) {\n\tconst serializedOrientation = serializeGradientOrientation( orientation );\n\tconst serializedColorStops = colorStops\n\t\t.sort( ( colorStop1, colorStop2 ) => {\n\t\t\treturn (\n\t\t\t\t( colorStop1?.length?.value ?? 0 ) -\n\t\t\t\t( colorStop2?.length?.value ?? 0 )\n\t\t\t);\n\t\t} )\n\t\t.map( serializeGradientColorStop );\n\treturn `${ type }(${ [ serializedOrientation, ...serializedColorStops ]\n\t\t.filter( Boolean )\n\t\t.join( ',' ) })`;\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/custom-gradient-picker/serializer.ts"],"names":["serializeGradientColor","type","value","join","serializeGradientPosition","position","serializeGradientColorStop","length","serializeGradientOrientation","orientation","Array","isArray","serializeGradient","colorStops","serializedOrientation","serializedColorStops","sort","colorStop1","colorStop2","getNumericStopValue","colorStop","undefined","parseInt","map","filter","Boolean"],"mappings":"AAAA;AACA;AACA;AAGA,OAAO,SAASA,sBAAT,OAGuB;AAAA,MAHU;AACvCC,IAAAA,IADuC;AAEvCC,IAAAA;AAFuC,GAGV;;AAC7B,MAAKD,IAAI,KAAK,SAAd,EAA0B;AACzB,WAAOC,KAAP;AACA;;AACD,MAAKD,IAAI,KAAK,KAAd,EAAsB;AACrB,WAAQ,IAAIC,KAAO,EAAnB;AACA;;AACD,SAAQ,GAAGD,IAAM,IAAIC,KAAK,CAACC,IAAN,CAAY,GAAZ,CAAmB,GAAxC;AACA;AAED,OAAO,SAASC,yBAAT,CACNC,QADM,EAEL;AACD,MAAK,CAAEA,QAAP,EAAkB;AACjB,WAAO,EAAP;AACA;;AACD,QAAM;AAAEH,IAAAA,KAAF;AAASD,IAAAA;AAAT,MAAkBI,QAAxB;AACA,SAAQ,GAAGH,KAAO,GAAGD,IAAM,EAA3B;AACA;AAED,OAAO,SAASK,0BAAT,QAIuB;AAAA,MAJc;AAC3CL,IAAAA,IAD2C;AAE3CC,IAAAA,KAF2C;AAG3CK,IAAAA;AAH2C,GAId;AAC7B,SAAQ,GAAGP,sBAAsB,CAAE;AAClCC,IAAAA,IADkC;AAElCC,IAAAA;AAFkC,GAAF,CAGA,IAAIE,yBAAyB,CAAEG,MAAF,CAAY,EAH1E;AAIA;AAED,OAAO,SAASC,4BAAT,CACNC,WADM,EAEL;AACD,MACCC,KAAK,CAACC,OAAN,CAAeF,WAAf,KACA,CAAEA,WADF,IAEAA,WAAW,CAACR,IAAZ,KAAqB,SAHtB,EAIE;AACD;AACA;;AACD,SAAQ,GAAGQ,WAAW,CAACP,KAAO,KAA9B;AACA;AAED,OAAO,SAASU,iBAAT,QAI0B;AAAA,MAJE;AAClCX,IAAAA,IADkC;AAElCQ,IAAAA,WAFkC;AAGlCI,IAAAA;AAHkC,GAIF;AAChC,QAAMC,qBAAqB,GAAGN,4BAA4B,CAAEC,WAAF,CAA1D;AACA,QAAMM,oBAAoB,GAAGF,UAAU,CACrCG,IAD2B,CACrB,CAAEC,UAAF,EAAcC,UAAd,KAA8B;AACpC,UAAMC,mBAAmB,GACxBC,SAD2B,IAEvB;AAAA;;AACJ,aAAO,CAAAA,SAAS,SAAT,IAAAA,SAAS,WAAT,iCAAAA,SAAS,CAAEb,MAAX,wEAAmBL,KAAnB,MAA6BmB,SAA7B,GACJ,CADI,GAEJC,QAAQ,CAAEF,SAAS,CAACb,MAAV,CAAiBL,KAAnB,CAFX;AAGA,KAND;;AAQA,WACCiB,mBAAmB,CAAEF,UAAF,CAAnB,GACAE,mBAAmB,CAAED,UAAF,CAFpB;AAIA,GAd2B,EAe3BK,GAf2B,CAetBjB,0BAfsB,CAA7B;AAgBA,SAAQ,GAAGL,IAAM,IAAI,CAAEa,qBAAF,EAAyB,GAAGC,oBAA5B,EACnBS,MADmB,CACXC,OADW,EAEnBtB,IAFmB,CAEb,GAFa,CAEN,GAFf;AAGA","sourcesContent":["/**\n * External dependencies\n */\nimport type gradientParser from 'gradient-parser';\n\nexport function serializeGradientColor( {\n\ttype,\n\tvalue,\n}: gradientParser.ColorStop ) {\n\tif ( type === 'literal' ) {\n\t\treturn value;\n\t}\n\tif ( type === 'hex' ) {\n\t\treturn `#${ value }`;\n\t}\n\treturn `${ type }(${ value.join( ',' ) })`;\n}\n\nexport function serializeGradientPosition(\n\tposition: gradientParser.ColorStop[ 'length' ]\n) {\n\tif ( ! position ) {\n\t\treturn '';\n\t}\n\tconst { value, type } = position;\n\treturn `${ value }${ type }`;\n}\n\nexport function serializeGradientColorStop( {\n\ttype,\n\tvalue,\n\tlength,\n}: gradientParser.ColorStop ) {\n\treturn `${ serializeGradientColor( {\n\t\ttype,\n\t\tvalue,\n\t} as gradientParser.ColorStop ) } ${ serializeGradientPosition( length ) }`;\n}\n\nexport function serializeGradientOrientation(\n\torientation: gradientParser.GradientNode[ 'orientation' ]\n) {\n\tif (\n\t\tArray.isArray( orientation ) ||\n\t\t! orientation ||\n\t\torientation.type !== 'angular'\n\t) {\n\t\treturn;\n\t}\n\treturn `${ orientation.value }deg`;\n}\n\nexport function serializeGradient( {\n\ttype,\n\torientation,\n\tcolorStops,\n}: gradientParser.GradientNode ) {\n\tconst serializedOrientation = serializeGradientOrientation( orientation );\n\tconst serializedColorStops = colorStops\n\t\t.sort( ( colorStop1, colorStop2 ) => {\n\t\t\tconst getNumericStopValue = (\n\t\t\t\tcolorStop: gradientParser.ColorStop\n\t\t\t) => {\n\t\t\t\treturn colorStop?.length?.value === undefined\n\t\t\t\t\t? 0\n\t\t\t\t\t: parseInt( colorStop.length.value );\n\t\t\t};\n\n\t\t\treturn (\n\t\t\t\tgetNumericStopValue( colorStop1 ) -\n\t\t\t\tgetNumericStopValue( colorStop2 )\n\t\t\t);\n\t\t} )\n\t\t.map( serializeGradientColorStop );\n\treturn `${ type }(${ [ serializedOrientation, ...serializedColorStops ]\n\t\t.filter( Boolean )\n\t\t.join( ',' ) })`;\n}\n"]}
@@ -11,9 +11,9 @@ function _EMOTION_STRINGIFIED_CSS_ERROR__() { return "You have tried to stringif
11
11
  */
12
12
  import { FlexBlock } from '../../flex';
13
13
  export const SelectWrapper = /*#__PURE__*/_styled(FlexBlock, process.env.NODE_ENV === "production" ? {
14
- target: "e99xvul1"
14
+ target: "e10bzpgi1"
15
15
  } : {
16
- target: "e99xvul1",
16
+ target: "e10bzpgi1",
17
17
  label: "SelectWrapper"
18
18
  })(process.env.NODE_ENV === "production" ? {
19
19
  name: "1gvx10y",
@@ -21,13 +21,13 @@ export const SelectWrapper = /*#__PURE__*/_styled(FlexBlock, process.env.NODE_EN
21
21
  } : {
22
22
  name: "1gvx10y",
23
23
  styles: "flex-grow:5",
24
- map: "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIkB3b3JkcHJlc3MvY29tcG9uZW50cy9zcmMvY3VzdG9tLWdyYWRpZW50LXBpY2tlci9zdHlsZXMvY3VzdG9tLWdyYWRpZW50LXBpY2tlci1zdHlsZXMuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBU2dEIiwiZmlsZSI6IkB3b3JkcHJlc3MvY29tcG9uZW50cy9zcmMvY3VzdG9tLWdyYWRpZW50LXBpY2tlci9zdHlsZXMvY3VzdG9tLWdyYWRpZW50LXBpY2tlci1zdHlsZXMuanMiLCJzb3VyY2VzQ29udGVudCI6WyIvKipcbiAqIEV4dGVybmFsIGRlcGVuZGVuY2llc1xuICovXG5pbXBvcnQgc3R5bGVkIGZyb20gJ0BlbW90aW9uL3N0eWxlZCc7XG4vKipcbiAqIEludGVybmFsIGRlcGVuZGVuY2llc1xuICovXG5pbXBvcnQgeyBGbGV4QmxvY2sgfSBmcm9tICcuLi8uLi9mbGV4JztcblxuZXhwb3J0IGNvbnN0IFNlbGVjdFdyYXBwZXIgPSBzdHlsZWQoIEZsZXhCbG9jayApYFxuXHRmbGV4LWdyb3c6IDU7XG5gO1xuXG5leHBvcnQgY29uc3QgQWNjZXNzb3J5V3JhcHBlciA9IHN0eWxlZCggRmxleEJsb2NrIClgXG5cdGZsZXgtZ3JvdzogNTtcbmA7XG4iXX0= */",
24
+ map: "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIkB3b3JkcHJlc3MvY29tcG9uZW50cy9zcmMvY3VzdG9tLWdyYWRpZW50LXBpY2tlci9zdHlsZXMvY3VzdG9tLWdyYWRpZW50LXBpY2tlci1zdHlsZXMudHN4Il0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQVNnRCIsImZpbGUiOiJAd29yZHByZXNzL2NvbXBvbmVudHMvc3JjL2N1c3RvbS1ncmFkaWVudC1waWNrZXIvc3R5bGVzL2N1c3RvbS1ncmFkaWVudC1waWNrZXItc3R5bGVzLnRzeCIsInNvdXJjZXNDb250ZW50IjpbIi8qKlxuICogRXh0ZXJuYWwgZGVwZW5kZW5jaWVzXG4gKi9cbmltcG9ydCBzdHlsZWQgZnJvbSAnQGVtb3Rpb24vc3R5bGVkJztcbi8qKlxuICogSW50ZXJuYWwgZGVwZW5kZW5jaWVzXG4gKi9cbmltcG9ydCB7IEZsZXhCbG9jayB9IGZyb20gJy4uLy4uL2ZsZXgnO1xuXG5leHBvcnQgY29uc3QgU2VsZWN0V3JhcHBlciA9IHN0eWxlZCggRmxleEJsb2NrIClgXG5cdGZsZXgtZ3JvdzogNTtcbmA7XG5cbmV4cG9ydCBjb25zdCBBY2Nlc3NvcnlXcmFwcGVyID0gc3R5bGVkKCBGbGV4QmxvY2sgKWBcblx0ZmxleC1ncm93OiA1O1xuYDtcbiJdfQ== */",
25
25
  toString: _EMOTION_STRINGIFIED_CSS_ERROR__
26
26
  });
27
27
  export const AccessoryWrapper = /*#__PURE__*/_styled(FlexBlock, process.env.NODE_ENV === "production" ? {
28
- target: "e99xvul0"
28
+ target: "e10bzpgi0"
29
29
  } : {
30
- target: "e99xvul0",
30
+ target: "e10bzpgi0",
31
31
  label: "AccessoryWrapper"
32
32
  })(process.env.NODE_ENV === "production" ? {
33
33
  name: "1gvx10y",
@@ -35,7 +35,7 @@ export const AccessoryWrapper = /*#__PURE__*/_styled(FlexBlock, process.env.NODE
35
35
  } : {
36
36
  name: "1gvx10y",
37
37
  styles: "flex-grow:5",
38
- map: "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIkB3b3JkcHJl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sInNvdXJjZXNDb250ZW50IjpbIi8qKlxuICogRXh0ZXJuYWwgZGVwZW5kZW5jaWVzXG4gKi9cbmltcG9ydCBzdHlsZWQgZnJvbSAnQGVtb3Rpb24vc3R5bGVkJztcbi8qKlxuICogSW50ZXJuYWwgZGVwZW5kZW5jaWVzXG4gKi9cbmltcG9ydCB7IEZsZXhCbG9jayB9IGZyb20gJy4uLy4uL2ZsZXgnO1xuXG5leHBvcnQgY29uc3QgU2VsZWN0V3JhcHBlciA9IHN0eWxlZCggRmxleEJsb2NrIClgXG5cdGZsZXgtZ3JvdzogNTtcbmA7XG5cbmV4cG9ydCBjb25zdCBBY2Nlc3NvcnlXcmFwcGVyID0gc3R5bGVkKCBGbGV4QmxvY2sgKWBcblx0ZmxleC1ncm93OiA1O1xuYDtcbiJdfQ== */",
39
39
  toString: _EMOTION_STRINGIFIED_CSS_ERROR__
40
40
  });
41
41
  //# sourceMappingURL=custom-gradient-picker-styles.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/custom-gradient-picker/styles/custom-gradient-picker-styles.js"],"names":["FlexBlock","SelectWrapper","AccessoryWrapper"],"mappings":";;;;AAAA;AACA;AACA;;AAEA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,YAA1B;AAEA,OAAO,MAAMC,aAAa,GAAG,qBAAQD,SAAR;AAAA;AAAA;AAAA;AAAA;AAAA,EAAH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAAnB;AAIP,OAAO,MAAME,gBAAgB,GAAG,qBAAQF,SAAR;AAAA;AAAA;AAAA;AAAA;AAAA,EAAH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAAtB","sourcesContent":["/**\n * External dependencies\n */\nimport styled from '@emotion/styled';\n/**\n * Internal dependencies\n */\nimport { FlexBlock } from '../../flex';\n\nexport const SelectWrapper = styled( FlexBlock )`\n\tflex-grow: 5;\n`;\n\nexport const AccessoryWrapper = styled( FlexBlock )`\n\tflex-grow: 5;\n`;\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/custom-gradient-picker/styles/custom-gradient-picker-styles.tsx"],"names":["FlexBlock","SelectWrapper","AccessoryWrapper"],"mappings":";;;;AAAA;AACA;AACA;;AAEA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,YAA1B;AAEA,OAAO,MAAMC,aAAa,GAAG,qBAAQD,SAAR;AAAA;AAAA;AAAA;AAAA;AAAA,EAAH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAAnB;AAIP,OAAO,MAAME,gBAAgB,GAAG,qBAAQF,SAAR;AAAA;AAAA;AAAA;AAAA;AAAA,EAAH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAAtB","sourcesContent":["/**\n * External dependencies\n */\nimport styled from '@emotion/styled';\n/**\n * Internal dependencies\n */\nimport { FlexBlock } from '../../flex';\n\nexport const SelectWrapper = styled( FlexBlock )`\n\tflex-grow: 5;\n`;\n\nexport const AccessoryWrapper = styled( FlexBlock )`\n\tflex-grow: 5;\n`;\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -1,5 +1,3 @@
1
- // @ts-nocheck
2
-
3
1
  /**
4
2
  * External dependencies
5
3
  */
@@ -31,18 +29,23 @@ export function getGradientAstWithDefault(value) {
31
29
  // gradientAST will contain the gradient AST as parsed by gradient-parser npm module.
32
30
  // More information of its structure available at https://www.npmjs.com/package/gradient-parser#ast.
33
31
  let gradientAST;
32
+ let hasGradient = !!value;
33
+ const valueToParse = value !== null && value !== void 0 ? value : DEFAULT_GRADIENT;
34
34
 
35
35
  try {
36
- gradientAST = gradientParser.parse(value)[0];
37
- gradientAST.value = value;
36
+ gradientAST = gradientParser.parse(valueToParse)[0];
38
37
  } catch (error) {
38
+ // eslint-disable-next-line no-console
39
+ console.warn('wp.components.CustomGradientPicker failed to parse the gradient with error', error);
39
40
  gradientAST = gradientParser.parse(DEFAULT_GRADIENT)[0];
40
- gradientAST.value = DEFAULT_GRADIENT;
41
+ hasGradient = false;
41
42
  }
42
43
 
43
- if (((_gradientAST$orientat = gradientAST.orientation) === null || _gradientAST$orientat === void 0 ? void 0 : _gradientAST$orientat.type) === 'directional') {
44
- gradientAST.orientation.type = 'angular';
45
- gradientAST.orientation.value = DIRECTIONAL_ORIENTATION_ANGLE_MAP[gradientAST.orientation.value].toString();
44
+ if (!Array.isArray(gradientAST.orientation) && ((_gradientAST$orientat = gradientAST.orientation) === null || _gradientAST$orientat === void 0 ? void 0 : _gradientAST$orientat.type) === 'directional') {
45
+ gradientAST.orientation = {
46
+ type: 'angular',
47
+ value: DIRECTIONAL_ORIENTATION_ANGLE_MAP[gradientAST.orientation.value].toString()
48
+ };
46
49
  }
47
50
 
48
51
  if (gradientAST.colorStops.some(hasUnsupportedLength)) {
@@ -52,14 +55,16 @@ export function getGradientAstWithDefault(value) {
52
55
  const step = 100 / (colorStops.length - 1);
53
56
  colorStops.forEach((stop, index) => {
54
57
  stop.length = {
55
- value: step * index,
58
+ value: `${step * index}`,
56
59
  type: '%'
57
60
  };
58
61
  });
59
- gradientAST.value = serializeGradient(gradientAST);
60
62
  }
61
63
 
62
- return gradientAST;
64
+ return {
65
+ gradientAST,
66
+ hasGradient
67
+ };
63
68
  }
64
69
  export function getGradientAstWithControlPoints(gradientAST, newControlPoints) {
65
70
  return { ...gradientAST,
@@ -80,7 +85,7 @@ export function getGradientAstWithControlPoints(gradientAST, newControlPoints) {
80
85
  value: position === null || position === void 0 ? void 0 : position.toString()
81
86
  },
82
87
  type: a < 1 ? 'rgba' : 'rgb',
83
- value: a < 1 ? [r, g, b, a] : [r, g, b]
88
+ value: a < 1 ? [`${r}`, `${g}`, `${b}`, `${a}`] : [`${r}`, `${g}`, `${b}`]
84
89
  };
85
90
  })
86
91
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/custom-gradient-picker/utils.js"],"names":["gradientParser","colord","extend","namesPlugin","DEFAULT_GRADIENT","HORIZONTAL_GRADIENT_ORIENTATION","DIRECTIONAL_ORIENTATION_ANGLE_MAP","serializeGradient","getLinearGradientRepresentation","gradientAST","type","orientation","colorStops","hasUnsupportedLength","item","length","undefined","getGradientAstWithDefault","value","parse","error","toString","some","step","forEach","stop","index","getGradientAstWithControlPoints","newControlPoints","map","position","color","r","g","b","a","toRgb","getStopCssColor","colorStop","join"],"mappings":"AAAA;;AAEA;AACA;AACA;AACA,OAAOA,cAAP,MAA2B,iBAA3B;AACA,SAASC,MAAT,EAAiBC,MAAjB,QAA+B,QAA/B;AACA,OAAOC,WAAP,MAAwB,sBAAxB;AAEA;AACA;AACA;;AACA,SACCC,gBADD,EAECC,+BAFD,EAGCC,iCAHD,QAIO,aAJP;AAKA,SAASC,iBAAT,QAAkC,cAAlC;AAEAL,MAAM,CAAE,CAAEC,WAAF,CAAF,CAAN;AAEA,OAAO,SAASK,+BAAT,CAA0CC,WAA1C,EAAwD;AAC9D,SAAOF,iBAAiB,CAAE;AACzBG,IAAAA,IAAI,EAAE,iBADmB;AAEzBC,IAAAA,WAAW,EAAEN,+BAFY;AAGzBO,IAAAA,UAAU,EAAEH,WAAW,CAACG;AAHC,GAAF,CAAxB;AAKA;;AAED,SAASC,oBAAT,CAA+BC,IAA/B,EAAsC;AACrC,SAAOA,IAAI,CAACC,MAAL,KAAgBC,SAAhB,IAA6BF,IAAI,CAACC,MAAL,CAAYL,IAAZ,KAAqB,GAAzD;AACA;;AAED,OAAO,SAASO,yBAAT,CAAoCC,KAApC,EAA4C;AAAA;;AAClD;AACA;AACA,MAAIT,WAAJ;;AAEA,MAAI;AACHA,IAAAA,WAAW,GAAGT,cAAc,CAACmB,KAAf,CAAsBD,KAAtB,EAA+B,CAA/B,CAAd;AACAT,IAAAA,WAAW,CAACS,KAAZ,GAAoBA,KAApB;AACA,GAHD,CAGE,OAAQE,KAAR,EAAgB;AACjBX,IAAAA,WAAW,GAAGT,cAAc,CAACmB,KAAf,CA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B;AACA,aAAO;AACNrB,QAAAA,MAAM,EAAE;AACPL,UAAAA,IAAI,EAAE,GADC;AAEPQ,UAAAA,KAAK,EAAEY,QAAF,aAAEA,QAAF,uBAAEA,QAAQ,CAAET,QAAV;AAFA,SADF;AAKNX,QAAAA,IAAI,EAAEyB,CAAC,GAAG,CAAJ,GAAQ,MAAR,GAAiB,KALjB;AAMNjB,QAAAA,KAAK,EAAEiB,CAAC,GAAG,CAAJ,GAAQ,CAAEH,CAAF,EAAKC,CAAL,EAAQC,CAAR,EAAWC,CAAX,CAAR,GAAyB,CAAEH,CAAF,EAAKC,CAAL,EAAQC,CAAR;AAN1B,OAAP;AAQA,KAVW;AAFN,GAAP;AAcA;AAED,OAAO,SAASG,eAAT,CAA0BC,SAA1B,EAAsC;AAC5C,UAASA,SAAS,CAAC5B,IAAnB;AACC,SAAK,KAAL;AACC,aAAQ,IAAI4B,SAAS,CAACpB,KAAO,EAA7B;;AACD,SAAK,SAAL;AACC,aAAOoB,SAAS,CAACpB,KAAjB;;AACD,SAAK,KAAL;AACA,SAAK,MAAL;AACC,aAAQ,GAAGoB,SAAS,CAAC5B,IAAM,IAAI4B,SAAS,CAACpB,KAAV,CAAgBqB,IAAhB,CAAsB,GAAtB,CAA6B,GAA5D;;AACD;AACC;AACA;AACA,aAAO,aAAP;AAXF;AAaA","sourcesContent":["// @ts-nocheck\n\n/**\n * External dependencies\n */\nimport gradientParser from 'gradient-parser';\nimport { colord, extend } from 'colord';\nimport namesPlugin from 'colord/plugins/names';\n\n/**\n * Internal dependencies\n */\nimport {\n\tDEFAULT_GRADIENT,\n\tHORIZONTAL_GRADIENT_ORIENTATION,\n\tDIRECTIONAL_ORIENTATION_ANGLE_MAP,\n} from './constants';\nimport { serializeGradient } from './serializer';\n\nextend( [ namesPlugin ] );\n\nexport function getLinearGradientRepresentation( gradientAST ) {\n\treturn serializeGradient( {\n\t\ttype: 'linear-gradient',\n\t\torientation: HORIZONTAL_GRADIENT_ORIENTATION,\n\t\tcolorStops: gradientAST.colorStops,\n\t} );\n}\n\nfunction hasUnsupportedLength( item ) {\n\treturn item.length === undefined || item.length.type !== '%';\n}\n\nexport function getGradientAstWithDefault( value ) {\n\t// gradientAST will contain the gradient AST as parsed by gradient-parser npm module.\n\t// More information of its structure available at https://www.npmjs.com/package/gradient-parser#ast.\n\tlet gradientAST;\n\n\ttry {\n\t\tgradientAST = gradientParser.parse( value )[ 0 ];\n\t\tgradientAST.value = value;\n\t} catch ( error ) {\n\t\tgradientAST = gradientParser.parse( DEFAULT_GRADIENT )[ 0 ];\n\t\tgradientAST.value = DEFAULT_GRADIENT;\n\t}\n\n\tif ( gradientAST.orientation?.type === 'directional' ) {\n\t\tgradientAST.orientation.type = 'angular';\n\t\tgradientAST.orientation.value =\n\t\t\tDIRECTIONAL_ORIENTATION_ANGLE_MAP[\n\t\t\t\tgradientAST.orientation.value\n\t\t\t].toString();\n\t}\n\n\tif ( gradientAST.colorStops.some( hasUnsupportedLength ) ) {\n\t\tconst { colorStops } = gradientAST;\n\t\tconst step = 100 / ( colorStops.length - 1 );\n\t\tcolorStops.forEach( ( stop, index ) => {\n\t\t\tstop.length = {\n\t\t\t\tvalue: step * index,\n\t\t\t\ttype: '%',\n\t\t\t};\n\t\t} );\n\t\tgradientAST.value = serializeGradient( gradientAST );\n\t}\n\n\treturn gradientAST;\n}\n\nexport function getGradientAstWithControlPoints(\n\tgradientAST,\n\tnewControlPoints\n) {\n\treturn {\n\t\t...gradientAST,\n\t\tcolorStops: newControlPoints.map( ( { position, color } ) => {\n\t\t\tconst { r, g, b, a } = colord( color ).toRgb();\n\t\t\treturn {\n\t\t\t\tlength: {\n\t\t\t\t\ttype: '%',\n\t\t\t\t\tvalue: position?.toString(),\n\t\t\t\t},\n\t\t\t\ttype: a < 1 ? 'rgba' : 'rgb',\n\t\t\t\tvalue: a < 1 ? [ r, g, b, a ] : [ r, g, b ],\n\t\t\t};\n\t\t} ),\n\t};\n}\n\nexport function getStopCssColor( colorStop ) {\n\tswitch ( colorStop.type ) {\n\t\tcase 'hex':\n\t\t\treturn `#${ colorStop.value }`;\n\t\tcase 'literal':\n\t\t\treturn colorStop.value;\n\t\tcase 'rgb':\n\t\tcase 'rgba':\n\t\t\treturn `${ colorStop.type }(${ colorStop.value.join( ',' ) })`;\n\t\tdefault:\n\t\t\t// Should be unreachable if passing an AST from gradient-parser.\n\t\t\t// See https://github.com/rafaelcaricio/gradient-parser#ast.\n\t\t\treturn 'transparent';\n\t}\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/custom-gradient-picker/utils.ts"],"names":["gradientParser","colord","extend","namesPlugin","DEFAULT_GRADIENT","HORIZONTAL_GRADIENT_ORIENTATION","DIRECTIONAL_ORIENTATION_ANGLE_MAP","serializeGradient","getLinearGradientRepresentation","gradientAST","type","orientation","colorStops","hasUnsupportedLength","item","length","undefined","getGradientAstWithDefault","value","hasGradient","valueToParse","parse","error","console","warn","Array","isArray","toString","some","step","forEach","stop","index","getGradientAstWithControlPoints","newControlPoints","map","position","color","r","g","b","a","toRgb","getStopCssColor","colorStop","join"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,cAAP,MAA2B,iBAA3B;AACA,SAASC,MAAT,EAAiBC,MAAjB,QAA+B,QAA/B;AACA,OAAOC,WAAP,MAAwB,sBAAxB;AAEA;AACA;AACA;;AACA,SACCC,gBADD,EAECC,+BAFD,EAGCC,iCAHD,QAIO,aAJP;AAKA,SAASC,iBAAT,QAAkC,cAAlC;AAGAL,MAAM,CAAE,CAAEC,WAAF,CAAF,CAAN;AAEA,OAAO,SAASK,+BAAT,CACNC,WADM,EAEL;AACD,SAAOF,iBAAiB,CAAE;AACzBG,IAAAA,IAAI,EAAE,iBADmB;AAEzBC,IAAAA,WAAW,EAAEN,+BAFY;AAGzBO,IAAAA,UAAU,EAAEH,WAAW,CAACG;AAHC,GAAF,CAAxB;AAKA;;AAED,SAASC,oBAAT,CAA+BC,IAA/B,EAAgE;AAC/D,SAAOA,IAAI,CAACC,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AL;AACC,aAAO0B,SAAS,CAAC1B,KAAjB;;AACD,SAAK,KAAL;AACA,SAAK,MAAL;AACC,aAAQ,GAAG0B,SAAS,CAAClC,IAAM,IAAIkC,SAAS,CAAC1B,KAAV,CAAgB2B,IAAhB,CAAsB,GAAtB,CAA6B,GAA5D;;AACD;AACC;AACA;AACA,aAAO,aAAP;AAXF;AAaA","sourcesContent":["/**\n * External dependencies\n */\nimport gradientParser from 'gradient-parser';\nimport { colord, extend } from 'colord';\nimport namesPlugin from 'colord/plugins/names';\n\n/**\n * Internal dependencies\n */\nimport {\n\tDEFAULT_GRADIENT,\n\tHORIZONTAL_GRADIENT_ORIENTATION,\n\tDIRECTIONAL_ORIENTATION_ANGLE_MAP,\n} from './constants';\nimport { serializeGradient } from './serializer';\nimport type { ControlPoint } from './types';\n\nextend( [ namesPlugin ] );\n\nexport function getLinearGradientRepresentation(\n\tgradientAST: gradientParser.GradientNode\n) {\n\treturn serializeGradient( {\n\t\ttype: 'linear-gradient',\n\t\torientation: HORIZONTAL_GRADIENT_ORIENTATION,\n\t\tcolorStops: gradientAST.colorStops,\n\t} );\n}\n\nfunction hasUnsupportedLength( item: gradientParser.ColorStop ) {\n\treturn item.length === undefined || item.length.type !== '%';\n}\n\nexport function getGradientAstWithDefault( value?: string | null ) {\n\t// gradientAST will contain the gradient AST as parsed by gradient-parser npm module.\n\t// More information of its structure available at https://www.npmjs.com/package/gradient-parser#ast.\n\tlet gradientAST: gradientParser.GradientNode | undefined;\n\tlet hasGradient = !! value;\n\n\tconst valueToParse = value ?? DEFAULT_GRADIENT;\n\n\ttry {\n\t\tgradientAST = gradientParser.parse( valueToParse )[ 0 ];\n\t} catch ( error ) {\n\t\t// eslint-disable-next-line no-console\n\t\tconsole.warn(\n\t\t\t'wp.components.CustomGradientPicker failed to parse the gradient with error',\n\t\t\terror\n\t\t);\n\n\t\tgradientAST = gradientParser.parse( DEFAULT_GRADIENT )[ 0 ];\n\t\thasGradient = false;\n\t}\n\n\tif (\n\t\t! Array.isArray( gradientAST.orientation ) &&\n\t\tgradientAST.orientation?.type === 'directional'\n\t) {\n\t\tgradientAST.orientation = {\n\t\t\ttype: 'angular',\n\t\t\tvalue: DIRECTIONAL_ORIENTATION_ANGLE_MAP[\n\t\t\t\tgradientAST.orientation.value\n\t\t\t].toString(),\n\t\t};\n\t}\n\n\tif ( gradientAST.colorStops.some( hasUnsupportedLength ) ) {\n\t\tconst { colorStops } = gradientAST;\n\t\tconst step = 100 / ( colorStops.length - 1 );\n\t\tcolorStops.forEach( ( stop, index ) => {\n\t\t\tstop.length = {\n\t\t\t\tvalue: `${ step * index }`,\n\t\t\t\ttype: '%',\n\t\t\t};\n\t\t} );\n\t}\n\n\treturn { gradientAST, hasGradient };\n}\n\nexport function getGradientAstWithControlPoints(\n\tgradientAST: gradientParser.GradientNode,\n\tnewControlPoints: ControlPoint[]\n) {\n\treturn {\n\t\t...gradientAST,\n\t\tcolorStops: newControlPoints.map( ( { position, color } ) => {\n\t\t\tconst { r, g, b, a } = colord( color ).toRgb();\n\t\t\treturn {\n\t\t\t\tlength: {\n\t\t\t\t\ttype: '%',\n\t\t\t\t\tvalue: position?.toString(),\n\t\t\t\t},\n\t\t\t\ttype: a < 1 ? 'rgba' : 'rgb',\n\t\t\t\tvalue:\n\t\t\t\t\ta < 1\n\t\t\t\t\t\t? [ `${ r }`, `${ g }`, `${ b }`, `${ a }` ]\n\t\t\t\t\t\t: [ `${ r }`, `${ g }`, `${ b }` ],\n\t\t\t};\n\t\t} ),\n\t} as gradientParser.GradientNode;\n}\n\nexport function getStopCssColor( colorStop: gradientParser.ColorStop ) {\n\tswitch ( colorStop.type ) {\n\t\tcase 'hex':\n\t\t\treturn `#${ colorStop.value }`;\n\t\tcase 'literal':\n\t\t\treturn colorStop.value;\n\t\tcase 'rgb':\n\t\tcase 'rgba':\n\t\t\treturn `${ colorStop.type }(${ colorStop.value.join( ',' ) })`;\n\t\tdefault:\n\t\t\t// Should be unreachable if passing an AST from gradient-parser.\n\t\t\t// See https://github.com/rafaelcaricio/gradient-parser#ast.\n\t\t\treturn 'transparent';\n\t}\n}\n"]}