@wordpress/components 19.11.0 → 19.14.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 (1322) hide show
  1. package/CHANGELOG.md +110 -0
  2. package/CONTRIBUTING.md +94 -12
  3. package/README.md +1 -1
  4. package/build/alignment-matrix-control/index.js +8 -5
  5. package/build/alignment-matrix-control/index.js.map +1 -1
  6. package/build/alignment-matrix-control/utils.js +1 -7
  7. package/build/alignment-matrix-control/utils.js.map +1 -1
  8. package/build/angle-picker-control/index.js +2 -2
  9. package/build/angle-picker-control/index.js.map +1 -1
  10. package/build/autocomplete/autocompleter-ui.js +3 -1
  11. package/build/autocomplete/autocompleter-ui.js.map +1 -1
  12. package/build/autocomplete/autocompleter-ui.native.js +8 -2
  13. package/build/autocomplete/autocompleter-ui.native.js.map +1 -1
  14. package/build/autocomplete/index.js +14 -10
  15. package/build/autocomplete/index.js.map +1 -1
  16. package/build/border-box-control/border-box-control/component.js +2 -1
  17. package/build/border-box-control/border-box-control/component.js.map +1 -1
  18. package/build/border-box-control/border-box-control/hook.js +2 -2
  19. package/build/border-box-control/border-box-control/hook.js.map +1 -1
  20. package/build/border-box-control/border-box-control-linked-button/component.js.map +1 -1
  21. package/build/border-box-control/border-box-control-split-controls/component.js +4 -1
  22. package/build/border-box-control/border-box-control-split-controls/component.js.map +1 -1
  23. package/build/border-box-control/border-box-control-split-controls/hook.js +13 -4
  24. package/build/border-box-control/border-box-control-split-controls/hook.js.map +1 -1
  25. package/build/border-box-control/border-box-control-visualizer/hook.js +6 -2
  26. package/build/border-box-control/border-box-control-visualizer/hook.js.map +1 -1
  27. package/build/border-box-control/styles.js +21 -11
  28. package/build/border-box-control/styles.js.map +1 -1
  29. package/build/border-box-control/utils.js.map +1 -1
  30. package/build/border-control/border-control/component.js +40 -4
  31. package/build/border-control/border-control/component.js.map +1 -1
  32. package/build/border-control/border-control/hook.js +2 -2
  33. package/build/border-control/border-control/hook.js.map +1 -1
  34. package/build/box-control/all-input-control.js +6 -10
  35. package/build/box-control/all-input-control.js.map +1 -1
  36. package/build/box-control/axial-input-controls.js.map +1 -1
  37. package/build/box-control/index.js +3 -7
  38. package/build/box-control/index.js.map +1 -1
  39. package/build/box-control/input-controls.js +6 -10
  40. package/build/box-control/input-controls.js.map +1 -1
  41. package/build/box-control/unit-control.js +4 -4
  42. package/build/box-control/unit-control.js.map +1 -1
  43. package/build/box-control/utils.js +3 -3
  44. package/build/box-control/utils.js.map +1 -1
  45. package/build/button/index.native.js +1 -3
  46. package/build/button/index.native.js.map +1 -1
  47. package/build/checkbox-control/index.js.map +1 -1
  48. package/build/color-indicator/index.js +27 -10
  49. package/build/color-indicator/index.js.map +1 -1
  50. package/build/color-indicator/types.js +6 -0
  51. package/build/color-indicator/types.js.map +1 -0
  52. package/build/color-palette/index.js +11 -3
  53. package/build/color-palette/index.js.map +1 -1
  54. package/build/color-palette/index.native.js +4 -1
  55. package/build/color-palette/index.native.js.map +1 -1
  56. package/build/color-picker/color-copy-button.js +87 -0
  57. package/build/color-picker/color-copy-button.js.map +1 -0
  58. package/build/color-picker/component.js +10 -23
  59. package/build/color-picker/component.js.map +1 -1
  60. package/build/color-picker/hex-input.js +18 -1
  61. package/build/color-picker/hex-input.js.map +1 -1
  62. package/build/color-picker/index.native.js.map +1 -1
  63. package/build/color-picker/input-with-slider.js +1 -2
  64. package/build/color-picker/input-with-slider.js.map +1 -1
  65. package/build/color-picker/styles.js +37 -19
  66. package/build/color-picker/styles.js.map +1 -1
  67. package/build/combobox-control/index.js +4 -2
  68. package/build/combobox-control/index.js.map +1 -1
  69. package/build/confirm-dialog/component.js.map +1 -1
  70. package/build/custom-gradient-bar/constants.js +1 -3
  71. package/build/custom-gradient-bar/constants.js.map +1 -1
  72. package/build/custom-gradient-bar/control-points.js +15 -8
  73. package/build/custom-gradient-bar/control-points.js.map +1 -1
  74. package/build/custom-gradient-bar/index.js +5 -5
  75. package/build/custom-gradient-bar/index.js.map +1 -1
  76. package/build/custom-gradient-bar/utils.js +5 -7
  77. package/build/custom-gradient-bar/utils.js.map +1 -1
  78. package/build/custom-gradient-picker/index.js +8 -8
  79. package/build/custom-gradient-picker/index.js.map +1 -1
  80. package/build/custom-gradient-picker/index.native.js +8 -9
  81. package/build/custom-gradient-picker/index.native.js.map +1 -1
  82. package/build/custom-gradient-picker/serializer.js +4 -7
  83. package/build/custom-gradient-picker/serializer.js.map +1 -1
  84. package/build/custom-gradient-picker/utils.js +1 -1
  85. package/build/custom-gradient-picker/utils.js.map +1 -1
  86. package/build/custom-select-control/index.js.map +1 -1
  87. package/build/date-time/{date.js → date/index.js} +57 -16
  88. package/build/date-time/date/index.js.map +1 -0
  89. package/build/date-time/date/styles.js +70 -0
  90. package/build/date-time/date/styles.js.map +1 -0
  91. package/build/date-time/{utils.js → date/utils.js} +0 -0
  92. package/build/date-time/date/utils.js.map +1 -0
  93. package/build/date-time/date-time/index.js +177 -0
  94. package/build/date-time/date-time/index.js.map +1 -0
  95. package/build/date-time/date-time/styles.js +32 -0
  96. package/build/date-time/date-time/styles.js.map +1 -0
  97. package/build/date-time/index.js +2 -109
  98. package/build/date-time/index.js.map +1 -1
  99. package/build/date-time/time/index.js +322 -0
  100. package/build/date-time/time/index.js.map +1 -0
  101. package/build/date-time/time/styles.js +139 -0
  102. package/build/date-time/time/styles.js.map +1 -0
  103. package/build/date-time/{timezone.js → time/timezone.js} +4 -2
  104. package/build/date-time/time/timezone.js.map +1 -0
  105. package/build/dimension-control/index.js +1 -3
  106. package/build/dimension-control/index.js.map +1 -1
  107. package/build/divider/styles.js +5 -5
  108. package/build/divider/styles.js.map +1 -1
  109. package/build/draggable/index.js.map +1 -1
  110. package/build/draggable/index.native.js +16 -6
  111. package/build/draggable/index.native.js.map +1 -1
  112. package/build/drop-zone/provider.js.map +1 -1
  113. package/build/dropdown/index.js +6 -3
  114. package/build/dropdown/index.js.map +1 -1
  115. package/build/dropdown-menu/index.js +13 -2
  116. package/build/dropdown-menu/index.js.map +1 -1
  117. package/build/dropdown-menu/index.native.js +13 -2
  118. package/build/dropdown-menu/index.native.js.map +1 -1
  119. package/build/duotone-picker/duotone-picker.js +42 -29
  120. package/build/duotone-picker/duotone-picker.js.map +1 -1
  121. package/build/elevation/hook.js +13 -13
  122. package/build/elevation/hook.js.map +1 -1
  123. package/build/external-link/index.js +20 -8
  124. package/build/external-link/index.js.map +1 -1
  125. package/build/external-link/styles/external-link-styles.js +3 -3
  126. package/build/external-link/styles/external-link-styles.js.map +1 -1
  127. package/build/external-link/types.js +6 -0
  128. package/build/external-link/types.js.map +1 -0
  129. package/build/flex/flex/hook.js +9 -5
  130. package/build/flex/flex/hook.js.map +1 -1
  131. package/build/focal-point-picker/controls.js +3 -7
  132. package/build/focal-point-picker/controls.js.map +1 -1
  133. package/build/focal-point-picker/index.js.map +1 -1
  134. package/build/focal-point-picker/index.native.js +4 -4
  135. package/build/focal-point-picker/index.native.js.map +1 -1
  136. package/build/focal-point-picker/media.js +4 -8
  137. package/build/focal-point-picker/media.js.map +1 -1
  138. package/build/font-size-picker/index.js +1 -1
  139. package/build/font-size-picker/index.js.map +1 -1
  140. package/build/form-toggle/index.js +34 -9
  141. package/build/form-toggle/index.js.map +1 -1
  142. package/build/form-toggle/types.js +6 -0
  143. package/build/form-toggle/types.js.map +1 -0
  144. package/build/form-token-field/index.js +328 -359
  145. package/build/form-token-field/index.js.map +1 -1
  146. package/build/form-token-field/suggestions-list.js +26 -20
  147. package/build/form-token-field/suggestions-list.js.map +1 -1
  148. package/build/form-token-field/token-input.js +39 -53
  149. package/build/form-token-field/token-input.js.map +1 -1
  150. package/build/form-token-field/token.js +3 -3
  151. package/build/form-token-field/token.js.map +1 -1
  152. package/build/form-token-field/types.js +6 -0
  153. package/build/form-token-field/types.js.map +1 -0
  154. package/build/gradient-picker/index.js.map +1 -1
  155. package/build/h-stack/utils.js +3 -3
  156. package/build/h-stack/utils.js.map +1 -1
  157. package/build/heading/component.js +0 -1
  158. package/build/heading/component.js.map +1 -1
  159. package/build/heading/hook.js.map +1 -1
  160. package/build/heading/types.js +6 -0
  161. package/build/heading/types.js.map +1 -0
  162. package/build/higher-order/navigate-regions/index.js.map +1 -1
  163. package/build/higher-order/with-focus-return/index.js.map +1 -1
  164. package/build/higher-order/with-spoken-messages/index.js.map +1 -1
  165. package/build/icon/index.js.map +1 -1
  166. package/build/input-control/index.js +14 -9
  167. package/build/input-control/index.js.map +1 -1
  168. package/build/input-control/input-field.js +11 -36
  169. package/build/input-control/input-field.js.map +1 -1
  170. package/build/input-control/reducer/reducer.js +36 -24
  171. package/build/input-control/reducer/reducer.js.map +1 -1
  172. package/build/input-control/reducer/state.js +0 -1
  173. package/build/input-control/reducer/state.js.map +1 -1
  174. package/build/input-control/utils.js +46 -1
  175. package/build/input-control/utils.js.map +1 -1
  176. package/build/menu-items-choice/index.js +3 -7
  177. package/build/menu-items-choice/index.js.map +1 -1
  178. package/build/mobile/bottom-sheet/bottom-sheet-context.native.js.map +1 -1
  179. package/build/mobile/bottom-sheet/cell.native.js.map +1 -1
  180. package/build/mobile/bottom-sheet/cycle-picker-cell.native.js +1 -7
  181. package/build/mobile/bottom-sheet/cycle-picker-cell.native.js.map +1 -1
  182. package/build/mobile/bottom-sheet/index.native.js.map +1 -1
  183. package/build/mobile/bottom-sheet/keyboard-avoiding-view.native.js +0 -1
  184. package/build/mobile/bottom-sheet/keyboard-avoiding-view.native.js.map +1 -1
  185. package/build/mobile/bottom-sheet/picker-cell.native.js.map +1 -1
  186. package/build/mobile/bottom-sheet/stepper-cell/index.native.js.map +1 -1
  187. package/build/mobile/color-settings/index.native.js.map +1 -1
  188. package/build/mobile/global-styles-context/index.native.js.map +1 -1
  189. package/build/mobile/gradient/index.native.js.map +1 -1
  190. package/build/mobile/html-text-input/index.native.js.map +1 -1
  191. package/build/mobile/inserter-button/index.native.js.map +1 -1
  192. package/build/mobile/link-picker/index.native.js +4 -4
  193. package/build/mobile/link-picker/index.native.js.map +1 -1
  194. package/build/mobile/link-settings/image-link-destinations-screen.native.js.map +1 -1
  195. package/build/mobile/media-edit/index.native.js.map +1 -1
  196. package/build/mobile/segmented-control/index.native.js +3 -5
  197. package/build/mobile/segmented-control/index.native.js.map +1 -1
  198. package/build/modal/index.js +1 -1
  199. package/build/modal/index.js.map +1 -1
  200. package/build/navigable-container/container.js +4 -2
  201. package/build/navigable-container/container.js.map +1 -1
  202. package/build/navigation/context.js +12 -16
  203. package/build/navigation/context.js.map +1 -1
  204. package/build/navigation/group/index.js +4 -7
  205. package/build/navigation/group/index.js.map +1 -1
  206. package/build/navigation/index.js +3 -3
  207. package/build/navigation/index.js.map +1 -1
  208. package/build/navigation/item/base.js +3 -3
  209. package/build/navigation/item/base.js.map +1 -1
  210. package/build/navigation/item/index.js +3 -3
  211. package/build/navigation/item/index.js.map +1 -1
  212. package/build/navigation/item/use-navigation-tree-item.js +2 -1
  213. package/build/navigation/item/use-navigation-tree-item.js.map +1 -1
  214. package/build/navigation/menu/menu-title-search.js +1 -7
  215. package/build/navigation/menu/menu-title-search.js.map +1 -1
  216. package/build/navigation/menu/search-no-results-found.js +1 -7
  217. package/build/navigation/menu/search-no-results-found.js.map +1 -1
  218. package/build/navigation/use-navigation-tree-nodes.js +18 -10
  219. package/build/navigation/use-navigation-tree-nodes.js.map +1 -1
  220. package/build/navigation/utils.js +4 -2
  221. package/build/navigation/utils.js.map +1 -1
  222. package/build/navigator/navigator-back-button/hook.js.map +1 -1
  223. package/build/navigator/navigator-button/hook.js.map +1 -1
  224. package/build/navigator/navigator-provider/component.js +1 -1
  225. package/build/navigator/navigator-provider/component.js.map +1 -1
  226. package/build/navigator/navigator-screen/component.js +1 -1
  227. package/build/navigator/navigator-screen/component.js.map +1 -1
  228. package/build/notice/index.js +5 -5
  229. package/build/notice/index.js.map +1 -1
  230. package/build/notice/list.js +4 -2
  231. package/build/notice/list.js.map +1 -1
  232. package/build/panel/body.js +3 -3
  233. package/build/panel/body.js.map +1 -1
  234. package/build/placeholder/index.js +26 -12
  235. package/build/placeholder/index.js.map +1 -1
  236. package/build/popover/index.js +40 -33
  237. package/build/popover/index.js.map +1 -1
  238. package/build/radio-control/index.js +43 -7
  239. package/build/radio-control/index.js.map +1 -1
  240. package/build/radio-control/types.js +6 -0
  241. package/build/radio-control/types.js.map +1 -0
  242. package/build/range-control/index.js +11 -9
  243. package/build/range-control/index.js.map +1 -1
  244. package/build/range-control/input-range.js +6 -10
  245. package/build/range-control/input-range.js.map +1 -1
  246. package/build/range-control/utils.js +10 -12
  247. package/build/range-control/utils.js.map +1 -1
  248. package/build/resizable-box/resize-tooltip/index.js +3 -3
  249. package/build/resizable-box/resize-tooltip/index.js.map +1 -1
  250. package/build/resizable-box/resize-tooltip/utils.js +4 -7
  251. package/build/resizable-box/resize-tooltip/utils.js.map +1 -1
  252. package/build/responsive-wrapper/index.js.map +1 -1
  253. package/build/search-control/index.js +4 -6
  254. package/build/search-control/index.js.map +1 -1
  255. package/build/select-control/index.js +8 -4
  256. package/build/select-control/index.js.map +1 -1
  257. package/build/slot-fill/fill.js +1 -7
  258. package/build/slot-fill/fill.js.map +1 -1
  259. package/build/slot-fill/slot.js +14 -3
  260. package/build/slot-fill/slot.js.map +1 -1
  261. package/build/snackbar/index.js +7 -7
  262. package/build/snackbar/index.js.map +1 -1
  263. package/build/snackbar/list.js +3 -1
  264. package/build/snackbar/list.js.map +1 -1
  265. package/build/spacer/component.js +5 -5
  266. package/build/spacer/component.js.map +1 -1
  267. package/build/spacer/hook.js +11 -3
  268. package/build/spacer/hook.js.map +1 -1
  269. package/build/spinner/index.js +26 -13
  270. package/build/spinner/index.js.map +1 -1
  271. package/build/spinner/styles.js +10 -10
  272. package/build/spinner/styles.js.map +1 -1
  273. package/build/surface/component.js +7 -7
  274. package/build/surface/component.js.map +1 -1
  275. package/build/surface/hook.js +8 -11
  276. package/build/surface/hook.js.map +1 -1
  277. package/build/surface/index.js.map +1 -1
  278. package/build/surface/styles.js +8 -48
  279. package/build/surface/styles.js.map +1 -1
  280. package/build/tab-panel/index.js +3 -1
  281. package/build/tab-panel/index.js.map +1 -1
  282. package/build/text/hook.js +4 -4
  283. package/build/text/hook.js.map +1 -1
  284. package/build/text/utils.js.map +1 -1
  285. package/build/textarea-control/index.js +40 -6
  286. package/build/textarea-control/index.js.map +1 -1
  287. package/build/textarea-control/styles/textarea-control-styles.js +3 -3
  288. package/build/textarea-control/styles/textarea-control-styles.js.map +1 -1
  289. package/build/textarea-control/types.js +6 -0
  290. package/build/textarea-control/types.js.map +1 -0
  291. package/build/toggle-control/index.js +1 -3
  292. package/build/toggle-control/index.js.map +1 -1
  293. package/build/toggle-control/index.native.js +1 -7
  294. package/build/toggle-control/index.native.js.map +1 -1
  295. package/build/toggle-group-control/toggle-group-control/toggle-group-control-backdrop.js.map +1 -1
  296. package/build/toolbar/index.js.map +1 -1
  297. package/build/tools-panel/tools-panel/hook.js.map +1 -1
  298. package/build/tools-panel/tools-panel-header/hook.js.map +1 -1
  299. package/build/tooltip/index.js +2 -1
  300. package/build/tooltip/index.js.map +1 -1
  301. package/build/tree-grid/roving-tab-index-item.js.map +1 -1
  302. package/build/tree-select/index.js +57 -4
  303. package/build/tree-select/index.js.map +1 -1
  304. package/build/tree-select/types.js +6 -0
  305. package/build/tree-select/types.js.map +1 -0
  306. package/build/truncate/component.js +7 -8
  307. package/build/truncate/component.js.map +1 -1
  308. package/build/truncate/hook.js +3 -10
  309. package/build/truncate/hook.js.map +1 -1
  310. package/build/truncate/index.js.map +1 -1
  311. package/build/truncate/styles.js +1 -1
  312. package/build/truncate/styles.js.map +1 -1
  313. package/build/truncate/utils.js +3 -16
  314. package/build/truncate/utils.js.map +1 -1
  315. package/build/ui/form-group/form-group-content.js.map +1 -1
  316. package/build/unit-control/index.js.map +1 -1
  317. package/build/utils/hooks/index.js +0 -8
  318. package/build/utils/hooks/index.js.map +1 -1
  319. package/build/utils/math.js +17 -7
  320. package/build/utils/math.js.map +1 -1
  321. package/build/utils/unit-values.js.map +1 -1
  322. package/build/utils/values.js.map +1 -1
  323. package/build/v-stack/component.js +9 -9
  324. package/build/v-stack/component.js.map +1 -1
  325. package/build/v-stack/hook.js +0 -5
  326. package/build/v-stack/hook.js.map +1 -1
  327. package/build/v-stack/index.js.map +1 -1
  328. package/build/z-stack/component.js +22 -3
  329. package/build/z-stack/component.js.map +1 -1
  330. package/build/z-stack/types.js +6 -0
  331. package/build/z-stack/types.js.map +1 -0
  332. package/build-module/alignment-matrix-control/index.js +7 -3
  333. package/build-module/alignment-matrix-control/index.js.map +1 -1
  334. package/build-module/alignment-matrix-control/utils.js +1 -6
  335. package/build-module/alignment-matrix-control/utils.js.map +1 -1
  336. package/build-module/angle-picker-control/index.js +1 -1
  337. package/build-module/angle-picker-control/index.js.map +1 -1
  338. package/build-module/autocomplete/autocompleter-ui.js +3 -1
  339. package/build-module/autocomplete/autocompleter-ui.js.map +1 -1
  340. package/build-module/autocomplete/autocompleter-ui.native.js +8 -2
  341. package/build-module/autocomplete/autocompleter-ui.native.js.map +1 -1
  342. package/build-module/autocomplete/index.js +15 -11
  343. package/build-module/autocomplete/index.js.map +1 -1
  344. package/build-module/border-box-control/border-box-control/component.js +2 -1
  345. package/build-module/border-box-control/border-box-control/component.js.map +1 -1
  346. package/build-module/border-box-control/border-box-control/hook.js +2 -2
  347. package/build-module/border-box-control/border-box-control/hook.js.map +1 -1
  348. package/build-module/border-box-control/border-box-control-linked-button/component.js.map +1 -1
  349. package/build-module/border-box-control/border-box-control-split-controls/component.js +4 -1
  350. package/build-module/border-box-control/border-box-control-split-controls/component.js.map +1 -1
  351. package/build-module/border-box-control/border-box-control-split-controls/hook.js +11 -4
  352. package/build-module/border-box-control/border-box-control-split-controls/hook.js.map +1 -1
  353. package/build-module/border-box-control/border-box-control-visualizer/hook.js +4 -2
  354. package/build-module/border-box-control/border-box-control-visualizer/hook.js.map +1 -1
  355. package/build-module/border-box-control/styles.js +13 -8
  356. package/build-module/border-box-control/styles.js.map +1 -1
  357. package/build-module/border-box-control/utils.js.map +1 -1
  358. package/build-module/border-control/border-control/component.js +38 -3
  359. package/build-module/border-control/border-control/component.js.map +1 -1
  360. package/build-module/border-control/border-control/hook.js +2 -2
  361. package/build-module/border-control/border-control/hook.js.map +1 -1
  362. package/build-module/box-control/all-input-control.js +3 -5
  363. package/build-module/box-control/all-input-control.js.map +1 -1
  364. package/build-module/box-control/axial-input-controls.js.map +1 -1
  365. package/build-module/box-control/index.js +2 -5
  366. package/build-module/box-control/index.js.map +1 -1
  367. package/build-module/box-control/input-controls.js +3 -5
  368. package/build-module/box-control/input-controls.js.map +1 -1
  369. package/build-module/box-control/unit-control.js +3 -1
  370. package/build-module/box-control/unit-control.js.map +1 -1
  371. package/build-module/box-control/utils.js +4 -4
  372. package/build-module/box-control/utils.js.map +1 -1
  373. package/build-module/button/index.native.js +1 -2
  374. package/build-module/button/index.native.js.map +1 -1
  375. package/build-module/checkbox-control/index.js.map +1 -1
  376. package/build-module/color-indicator/index.js +29 -8
  377. package/build-module/color-indicator/index.js.map +1 -1
  378. package/build-module/color-indicator/types.js +2 -0
  379. package/build-module/color-indicator/types.js.map +1 -0
  380. package/build-module/color-palette/index.js +9 -6
  381. package/build-module/color-palette/index.js.map +1 -1
  382. package/build-module/color-palette/index.native.js +4 -1
  383. package/build-module/color-palette/index.native.js.map +1 -1
  384. package/build-module/color-picker/color-copy-button.js +73 -0
  385. package/build-module/color-picker/color-copy-button.js.map +1 -0
  386. package/build-module/color-picker/component.js +11 -21
  387. package/build-module/color-picker/component.js.map +1 -1
  388. package/build-module/color-picker/hex-input.js +18 -1
  389. package/build-module/color-picker/hex-input.js.map +1 -1
  390. package/build-module/color-picker/index.native.js.map +1 -1
  391. package/build-module/color-picker/input-with-slider.js +1 -2
  392. package/build-module/color-picker/input-with-slider.js.map +1 -1
  393. package/build-module/color-picker/styles.js +30 -16
  394. package/build-module/color-picker/styles.js.map +1 -1
  395. package/build-module/combobox-control/index.js +5 -2
  396. package/build-module/combobox-control/index.js.map +1 -1
  397. package/build-module/confirm-dialog/component.js.map +1 -1
  398. package/build-module/custom-gradient-bar/constants.js +0 -1
  399. package/build-module/custom-gradient-bar/constants.js.map +1 -1
  400. package/build-module/custom-gradient-bar/control-points.js +16 -9
  401. package/build-module/custom-gradient-bar/control-points.js.map +1 -1
  402. package/build-module/custom-gradient-bar/index.js +6 -6
  403. package/build-module/custom-gradient-bar/index.js.map +1 -1
  404. package/build-module/custom-gradient-bar/utils.js +6 -8
  405. package/build-module/custom-gradient-bar/utils.js.map +1 -1
  406. package/build-module/custom-gradient-picker/index.js +8 -7
  407. package/build-module/custom-gradient-picker/index.js.map +1 -1
  408. package/build-module/custom-gradient-picker/index.native.js +8 -8
  409. package/build-module/custom-gradient-picker/index.native.js.map +1 -1
  410. package/build-module/custom-gradient-picker/serializer.js +4 -6
  411. package/build-module/custom-gradient-picker/serializer.js.map +1 -1
  412. package/build-module/custom-gradient-picker/utils.js +1 -1
  413. package/build-module/custom-gradient-picker/utils.js.map +1 -1
  414. package/build-module/custom-select-control/index.js.map +1 -1
  415. package/build-module/date-time/{date.js → date/index.js} +51 -16
  416. package/build-module/date-time/date/index.js.map +1 -0
  417. package/build-module/date-time/date/styles.js +61 -0
  418. package/build-module/date-time/date/styles.js.map +1 -0
  419. package/build-module/date-time/{utils.js → date/utils.js} +0 -0
  420. package/build-module/date-time/date/utils.js.map +1 -0
  421. package/build-module/date-time/date-time/index.js +147 -0
  422. package/build-module/date-time/date-time/index.js.map +1 -0
  423. package/build-module/date-time/date-time/styles.js +22 -0
  424. package/build-module/date-time/date-time/styles.js.map +1 -0
  425. package/build-module/date-time/index.js +1 -105
  426. package/build-module/date-time/index.js.map +1 -1
  427. package/build-module/date-time/time/index.js +302 -0
  428. package/build-module/date-time/time/index.js.map +1 -0
  429. package/build-module/date-time/time/styles.js +118 -0
  430. package/build-module/date-time/time/styles.js.map +1 -0
  431. package/build-module/date-time/{timezone.js → time/timezone.js} +3 -2
  432. package/build-module/date-time/time/timezone.js.map +1 -0
  433. package/build-module/dimension-control/index.js +1 -2
  434. package/build-module/dimension-control/index.js.map +1 -1
  435. package/build-module/divider/styles.js +5 -5
  436. package/build-module/divider/styles.js.map +1 -1
  437. package/build-module/draggable/index.js.map +1 -1
  438. package/build-module/draggable/index.native.js +16 -6
  439. package/build-module/draggable/index.native.js.map +1 -1
  440. package/build-module/drop-zone/provider.js.map +1 -1
  441. package/build-module/dropdown/index.js +6 -3
  442. package/build-module/dropdown/index.js.map +1 -1
  443. package/build-module/dropdown-menu/index.js +12 -1
  444. package/build-module/dropdown-menu/index.js.map +1 -1
  445. package/build-module/dropdown-menu/index.native.js +12 -1
  446. package/build-module/dropdown-menu/index.native.js.map +1 -1
  447. package/build-module/duotone-picker/duotone-picker.js +42 -29
  448. package/build-module/duotone-picker/duotone-picker.js.map +1 -1
  449. package/build-module/elevation/hook.js +12 -12
  450. package/build-module/elevation/hook.js.map +1 -1
  451. package/build-module/external-link/index.js +22 -7
  452. package/build-module/external-link/index.js.map +1 -1
  453. package/build-module/external-link/styles/external-link-styles.js +3 -3
  454. package/build-module/external-link/styles/external-link-styles.js.map +1 -1
  455. package/build-module/external-link/types.js +2 -0
  456. package/build-module/external-link/types.js.map +1 -0
  457. package/build-module/flex/flex/hook.js +7 -5
  458. package/build-module/flex/flex/hook.js.map +1 -1
  459. package/build-module/focal-point-picker/controls.js +3 -5
  460. package/build-module/focal-point-picker/controls.js.map +1 -1
  461. package/build-module/focal-point-picker/index.js.map +1 -1
  462. package/build-module/focal-point-picker/index.native.js +1 -1
  463. package/build-module/focal-point-picker/index.native.js.map +1 -1
  464. package/build-module/focal-point-picker/media.js +3 -5
  465. package/build-module/focal-point-picker/media.js.map +1 -1
  466. package/build-module/font-size-picker/index.js +1 -1
  467. package/build-module/font-size-picker/index.js.map +1 -1
  468. package/build-module/form-toggle/index.js +31 -7
  469. package/build-module/form-toggle/index.js.map +1 -1
  470. package/build-module/form-toggle/types.js +2 -0
  471. package/build-module/form-toggle/types.js.map +1 -0
  472. package/build-module/form-token-field/index.js +329 -361
  473. package/build-module/form-token-field/index.js.map +1 -1
  474. package/build-module/form-token-field/suggestions-list.js +32 -23
  475. package/build-module/form-token-field/suggestions-list.js.map +1 -1
  476. package/build-module/form-token-field/token-input.js +43 -58
  477. package/build-module/form-token-field/token-input.js.map +1 -1
  478. package/build-module/form-token-field/token.js +3 -1
  479. package/build-module/form-token-field/token.js.map +1 -1
  480. package/build-module/form-token-field/types.js +2 -0
  481. package/build-module/form-token-field/types.js.map +1 -0
  482. package/build-module/gradient-picker/index.js.map +1 -1
  483. package/build-module/h-stack/utils.js +3 -3
  484. package/build-module/h-stack/utils.js.map +1 -1
  485. package/build-module/heading/component.js +0 -1
  486. package/build-module/heading/component.js.map +1 -1
  487. package/build-module/heading/hook.js.map +1 -1
  488. package/build-module/heading/types.js +2 -0
  489. package/build-module/heading/types.js.map +1 -0
  490. package/build-module/higher-order/navigate-regions/index.js.map +1 -1
  491. package/build-module/higher-order/with-focus-return/index.js.map +1 -1
  492. package/build-module/higher-order/with-spoken-messages/index.js.map +1 -1
  493. package/build-module/icon/index.js.map +1 -1
  494. package/build-module/input-control/index.js +10 -5
  495. package/build-module/input-control/index.js.map +1 -1
  496. package/build-module/input-control/input-field.js +3 -26
  497. package/build-module/input-control/input-field.js.map +1 -1
  498. package/build-module/input-control/reducer/reducer.js +38 -26
  499. package/build-module/input-control/reducer/reducer.js.map +1 -1
  500. package/build-module/input-control/reducer/state.js +0 -1
  501. package/build-module/input-control/reducer/state.js.map +1 -1
  502. package/build-module/input-control/utils.js +49 -3
  503. package/build-module/input-control/utils.js.map +1 -1
  504. package/build-module/menu-items-choice/index.js +3 -5
  505. package/build-module/menu-items-choice/index.js.map +1 -1
  506. package/build-module/mobile/bottom-sheet/bottom-sheet-context.native.js.map +1 -1
  507. package/build-module/mobile/bottom-sheet/cell.native.js.map +1 -1
  508. package/build-module/mobile/bottom-sheet/cycle-picker-cell.native.js +1 -6
  509. package/build-module/mobile/bottom-sheet/cycle-picker-cell.native.js.map +1 -1
  510. package/build-module/mobile/bottom-sheet/index.native.js.map +1 -1
  511. package/build-module/mobile/bottom-sheet/keyboard-avoiding-view.native.js +0 -1
  512. package/build-module/mobile/bottom-sheet/keyboard-avoiding-view.native.js.map +1 -1
  513. package/build-module/mobile/bottom-sheet/picker-cell.native.js.map +1 -1
  514. package/build-module/mobile/bottom-sheet/stepper-cell/index.native.js.map +1 -1
  515. package/build-module/mobile/color-settings/index.native.js.map +1 -1
  516. package/build-module/mobile/global-styles-context/index.native.js.map +1 -1
  517. package/build-module/mobile/gradient/index.native.js.map +1 -1
  518. package/build-module/mobile/html-text-input/index.native.js.map +1 -1
  519. package/build-module/mobile/inserter-button/index.native.js.map +1 -1
  520. package/build-module/mobile/link-picker/index.native.js +4 -3
  521. package/build-module/mobile/link-picker/index.native.js.map +1 -1
  522. package/build-module/mobile/link-settings/image-link-destinations-screen.native.js.map +1 -1
  523. package/build-module/mobile/media-edit/index.native.js.map +1 -1
  524. package/build-module/mobile/segmented-control/index.native.js +3 -4
  525. package/build-module/mobile/segmented-control/index.native.js.map +1 -1
  526. package/build-module/modal/index.js +1 -1
  527. package/build-module/modal/index.js.map +1 -1
  528. package/build-module/navigable-container/container.js +5 -2
  529. package/build-module/navigable-container/container.js.map +1 -1
  530. package/build-module/navigation/context.js +3 -5
  531. package/build-module/navigation/context.js.map +1 -1
  532. package/build-module/navigation/group/index.js +3 -6
  533. package/build-module/navigation/group/index.js.map +1 -1
  534. package/build-module/navigation/index.js +3 -1
  535. package/build-module/navigation/index.js.map +1 -1
  536. package/build-module/navigation/item/base.js +2 -2
  537. package/build-module/navigation/item/base.js.map +1 -1
  538. package/build-module/navigation/item/index.js +3 -1
  539. package/build-module/navigation/item/index.js.map +1 -1
  540. package/build-module/navigation/item/use-navigation-tree-item.js +2 -1
  541. package/build-module/navigation/item/use-navigation-tree-item.js.map +1 -1
  542. package/build-module/navigation/menu/menu-title-search.js +1 -6
  543. package/build-module/navigation/menu/menu-title-search.js.map +1 -1
  544. package/build-module/navigation/menu/search-no-results-found.js +1 -6
  545. package/build-module/navigation/menu/search-no-results-found.js.map +1 -1
  546. package/build-module/navigation/use-navigation-tree-nodes.js +18 -9
  547. package/build-module/navigation/use-navigation-tree-nodes.js.map +1 -1
  548. package/build-module/navigation/utils.js +2 -2
  549. package/build-module/navigation/utils.js.map +1 -1
  550. package/build-module/navigator/navigator-back-button/hook.js.map +1 -1
  551. package/build-module/navigator/navigator-button/hook.js.map +1 -1
  552. package/build-module/navigator/navigator-provider/component.js +1 -1
  553. package/build-module/navigator/navigator-provider/component.js.map +1 -1
  554. package/build-module/navigator/navigator-screen/component.js +1 -1
  555. package/build-module/navigator/navigator-screen/component.js.map +1 -1
  556. package/build-module/notice/index.js +2 -1
  557. package/build-module/notice/index.js.map +1 -1
  558. package/build-module/notice/list.js +4 -1
  559. package/build-module/notice/list.js.map +1 -1
  560. package/build-module/panel/body.js +3 -1
  561. package/build-module/panel/body.js.map +1 -1
  562. package/build-module/placeholder/index.js +24 -11
  563. package/build-module/placeholder/index.js.map +1 -1
  564. package/build-module/popover/index.js +40 -33
  565. package/build-module/popover/index.js.map +1 -1
  566. package/build-module/radio-control/index.js +40 -7
  567. package/build-module/radio-control/index.js.map +1 -1
  568. package/build-module/radio-control/types.js +2 -0
  569. package/build-module/radio-control/types.js.map +1 -0
  570. package/build-module/range-control/index.js +4 -2
  571. package/build-module/range-control/index.js.map +1 -1
  572. package/build-module/range-control/input-range.js +2 -5
  573. package/build-module/range-control/input-range.js.map +1 -1
  574. package/build-module/range-control/utils.js +4 -5
  575. package/build-module/range-control/utils.js.map +1 -1
  576. package/build-module/resizable-box/resize-tooltip/index.js +2 -1
  577. package/build-module/resizable-box/resize-tooltip/index.js.map +1 -1
  578. package/build-module/resizable-box/resize-tooltip/utils.js +3 -5
  579. package/build-module/resizable-box/resize-tooltip/utils.js.map +1 -1
  580. package/build-module/responsive-wrapper/index.js.map +1 -1
  581. package/build-module/search-control/index.js +6 -7
  582. package/build-module/search-control/index.js.map +1 -1
  583. package/build-module/select-control/index.js +6 -2
  584. package/build-module/select-control/index.js.map +1 -1
  585. package/build-module/slot-fill/fill.js +1 -6
  586. package/build-module/slot-fill/fill.js.map +1 -1
  587. package/build-module/slot-fill/slot.js +12 -2
  588. package/build-module/slot-fill/slot.js.map +1 -1
  589. package/build-module/snackbar/index.js +3 -1
  590. package/build-module/snackbar/index.js.map +1 -1
  591. package/build-module/snackbar/list.js +4 -1
  592. package/build-module/snackbar/list.js.map +1 -1
  593. package/build-module/spacer/component.js +3 -4
  594. package/build-module/spacer/component.js.map +1 -1
  595. package/build-module/spacer/hook.js +10 -2
  596. package/build-module/spacer/hook.js.map +1 -1
  597. package/build-module/spinner/index.js +22 -13
  598. package/build-module/spinner/index.js.map +1 -1
  599. package/build-module/spinner/styles.js +10 -10
  600. package/build-module/spinner/styles.js.map +1 -1
  601. package/build-module/surface/component.js +7 -7
  602. package/build-module/surface/component.js.map +1 -1
  603. package/build-module/surface/hook.js +8 -11
  604. package/build-module/surface/hook.js.map +1 -1
  605. package/build-module/surface/index.js.map +1 -1
  606. package/build-module/surface/styles.js +8 -48
  607. package/build-module/surface/styles.js.map +1 -1
  608. package/build-module/tab-panel/index.js +3 -1
  609. package/build-module/tab-panel/index.js.map +1 -1
  610. package/build-module/text/hook.js +4 -4
  611. package/build-module/text/hook.js.map +1 -1
  612. package/build-module/text/utils.js.map +1 -1
  613. package/build-module/textarea-control/index.js +36 -5
  614. package/build-module/textarea-control/index.js.map +1 -1
  615. package/build-module/textarea-control/styles/textarea-control-styles.js +3 -3
  616. package/build-module/textarea-control/styles/textarea-control-styles.js.map +1 -1
  617. package/build-module/textarea-control/types.js +2 -0
  618. package/build-module/textarea-control/types.js.map +1 -0
  619. package/build-module/toggle-control/index.js +1 -2
  620. package/build-module/toggle-control/index.js.map +1 -1
  621. package/build-module/toggle-control/index.native.js +1 -6
  622. package/build-module/toggle-control/index.native.js.map +1 -1
  623. package/build-module/toggle-group-control/toggle-group-control/toggle-group-control-backdrop.js.map +1 -1
  624. package/build-module/toolbar/index.js.map +1 -1
  625. package/build-module/tools-panel/tools-panel/hook.js.map +1 -1
  626. package/build-module/tools-panel/tools-panel-header/hook.js.map +1 -1
  627. package/build-module/tooltip/index.js +2 -1
  628. package/build-module/tooltip/index.js.map +1 -1
  629. package/build-module/tree-grid/roving-tab-index-item.js.map +1 -1
  630. package/build-module/tree-select/index.js +53 -3
  631. package/build-module/tree-select/index.js.map +1 -1
  632. package/build-module/tree-select/types.js +2 -0
  633. package/build-module/tree-select/types.js.map +1 -0
  634. package/build-module/truncate/component.js +7 -8
  635. package/build-module/truncate/component.js.map +1 -1
  636. package/build-module/truncate/hook.js +3 -10
  637. package/build-module/truncate/hook.js.map +1 -1
  638. package/build-module/truncate/index.js.map +1 -1
  639. package/build-module/truncate/styles.js +1 -1
  640. package/build-module/truncate/styles.js.map +1 -1
  641. package/build-module/truncate/utils.js +3 -16
  642. package/build-module/truncate/utils.js.map +1 -1
  643. package/build-module/ui/form-group/form-group-content.js.map +1 -1
  644. package/build-module/unit-control/index.js.map +1 -1
  645. package/build-module/utils/hooks/index.js +0 -1
  646. package/build-module/utils/hooks/index.js.map +1 -1
  647. package/build-module/utils/math.js +15 -6
  648. package/build-module/utils/math.js.map +1 -1
  649. package/build-module/utils/unit-values.js.map +1 -1
  650. package/build-module/utils/values.js.map +1 -1
  651. package/build-module/v-stack/component.js +9 -9
  652. package/build-module/v-stack/component.js.map +1 -1
  653. package/build-module/v-stack/hook.js +0 -5
  654. package/build-module/v-stack/hook.js.map +1 -1
  655. package/build-module/v-stack/index.js.map +1 -1
  656. package/build-module/z-stack/component.js +21 -2
  657. package/build-module/z-stack/component.js.map +1 -1
  658. package/build-module/z-stack/types.js +2 -0
  659. package/build-module/z-stack/types.js.map +1 -0
  660. package/build-style/style-rtl.css +61 -191
  661. package/build-style/style.css +61 -195
  662. package/build-types/base-control/stories/index.d.ts.map +1 -1
  663. package/build-types/base-field/hook.d.ts +0 -1
  664. package/build-types/base-field/hook.d.ts.map +1 -1
  665. package/build-types/border-box-control/border-box-control/component.d.ts.map +1 -1
  666. package/build-types/border-box-control/border-box-control/hook.d.ts +0 -1
  667. package/build-types/border-box-control/border-box-control/hook.d.ts.map +1 -1
  668. package/build-types/border-box-control/border-box-control-linked-button/component.d.ts.map +1 -1
  669. package/build-types/border-box-control/border-box-control-linked-button/hook.d.ts +0 -1
  670. package/build-types/border-box-control/border-box-control-linked-button/hook.d.ts.map +1 -1
  671. package/build-types/border-box-control/border-box-control-split-controls/component.d.ts.map +1 -1
  672. package/build-types/border-box-control/border-box-control-split-controls/hook.d.ts +1 -1
  673. package/build-types/border-box-control/border-box-control-split-controls/hook.d.ts.map +1 -1
  674. package/build-types/border-box-control/border-box-control-visualizer/hook.d.ts +0 -1
  675. package/build-types/border-box-control/border-box-control-visualizer/hook.d.ts.map +1 -1
  676. package/build-types/border-box-control/styles.d.ts +3 -2
  677. package/build-types/border-box-control/styles.d.ts.map +1 -1
  678. package/build-types/border-box-control/utils.d.ts.map +1 -1
  679. package/build-types/border-control/border-control/component.d.ts +36 -2
  680. package/build-types/border-control/border-control/component.d.ts.map +1 -1
  681. package/build-types/border-control/border-control/hook.d.ts +0 -1
  682. package/build-types/border-control/border-control/hook.d.ts.map +1 -1
  683. package/build-types/border-control/border-control-dropdown/hook.d.ts +0 -1
  684. package/build-types/border-control/border-control-dropdown/hook.d.ts.map +1 -1
  685. package/build-types/border-control/border-control-style-picker/hook.d.ts +0 -1
  686. package/build-types/border-control/border-control-style-picker/hook.d.ts.map +1 -1
  687. package/build-types/border-control/stories/index.d.ts +33 -0
  688. package/build-types/border-control/stories/index.d.ts.map +1 -0
  689. package/build-types/button-group/index.d.ts +1 -1
  690. package/build-types/button-group/index.d.ts.map +1 -1
  691. package/build-types/card/card/hook.d.ts +0 -1
  692. package/build-types/card/card/hook.d.ts.map +1 -1
  693. package/build-types/card/card-body/hook.d.ts +0 -1
  694. package/build-types/card/card-body/hook.d.ts.map +1 -1
  695. package/build-types/card/card-divider/hook.d.ts +0 -1
  696. package/build-types/card/card-divider/hook.d.ts.map +1 -1
  697. package/build-types/card/card-footer/hook.d.ts +0 -1
  698. package/build-types/card/card-footer/hook.d.ts.map +1 -1
  699. package/build-types/card/card-header/hook.d.ts +0 -1
  700. package/build-types/card/card-header/hook.d.ts.map +1 -1
  701. package/build-types/card/card-media/hook.d.ts +0 -1
  702. package/build-types/card/card-media/hook.d.ts.map +1 -1
  703. package/build-types/card/types.d.ts +1 -1
  704. package/build-types/card/types.d.ts.map +1 -1
  705. package/build-types/checkbox-control/index.d.ts.map +1 -1
  706. package/build-types/checkbox-control/stories/index.d.ts.map +1 -1
  707. package/build-types/checkbox-control/test/index.d.ts +2 -0
  708. package/build-types/checkbox-control/test/index.d.ts.map +1 -0
  709. package/build-types/color-indicator/index.d.ts +16 -5
  710. package/build-types/color-indicator/index.d.ts.map +1 -1
  711. package/build-types/color-indicator/stories/index.d.ts +12 -0
  712. package/build-types/color-indicator/stories/index.d.ts.map +1 -0
  713. package/build-types/color-indicator/test/index.d.ts +2 -0
  714. package/build-types/color-indicator/test/index.d.ts.map +1 -0
  715. package/build-types/color-indicator/types.d.ts +12 -0
  716. package/build-types/color-indicator/types.d.ts.map +1 -0
  717. package/build-types/color-palette/index.d.ts +1 -0
  718. package/build-types/color-palette/index.d.ts.map +1 -1
  719. package/build-types/color-palette/styles.d.ts +4 -2
  720. package/build-types/color-palette/styles.d.ts.map +1 -1
  721. package/build-types/{date-time → color-palette}/test/utils.d.ts +0 -0
  722. package/build-types/color-palette/test/utils.d.ts.map +1 -0
  723. package/build-types/color-picker/color-copy-button.d.ts +4 -0
  724. package/build-types/color-picker/color-copy-button.d.ts.map +1 -0
  725. package/build-types/color-picker/component.d.ts.map +1 -1
  726. package/build-types/color-picker/hex-input.d.ts.map +1 -1
  727. package/build-types/color-picker/styles.d.ts +25 -8
  728. package/build-types/color-picker/styles.d.ts.map +1 -1
  729. package/build-types/color-picker/types.d.ts +8 -0
  730. package/build-types/color-picker/types.d.ts.map +1 -1
  731. package/build-types/confirm-dialog/component.d.ts.map +1 -1
  732. package/build-types/date-time/{date.d.ts → date/index.d.ts} +4 -3
  733. package/build-types/date-time/date/index.d.ts.map +1 -0
  734. package/build-types/date-time/date/styles.d.ts +23 -0
  735. package/build-types/date-time/date/styles.d.ts.map +1 -0
  736. package/build-types/date-time/date/test/index.d.ts +2 -0
  737. package/build-types/date-time/date/test/index.d.ts.map +1 -0
  738. package/build-types/date-time/date/test/utils.d.ts +2 -0
  739. package/build-types/date-time/date/test/utils.d.ts.map +1 -0
  740. package/build-types/date-time/{utils.d.ts → date/utils.d.ts} +0 -0
  741. package/build-types/date-time/date/utils.d.ts.map +1 -0
  742. package/build-types/date-time/date-time/index.d.ts +33 -0
  743. package/build-types/date-time/date-time/index.d.ts.map +1 -0
  744. package/build-types/date-time/date-time/styles.d.ts +6 -0
  745. package/build-types/date-time/date-time/styles.d.ts.map +1 -0
  746. package/build-types/date-time/index.d.ts +2 -28
  747. package/build-types/date-time/index.d.ts.map +1 -1
  748. package/build-types/date-time/stories/{index.d.ts → date-time.d.ts} +2 -2
  749. package/build-types/date-time/stories/date-time.d.ts.map +1 -0
  750. package/build-types/date-time/stories/date.d.ts.map +1 -1
  751. package/build-types/date-time/{time.d.ts → time/index.d.ts} +2 -2
  752. package/build-types/date-time/time/index.d.ts.map +1 -0
  753. package/build-types/date-time/time/styles.d.ts +111 -0
  754. package/build-types/date-time/time/styles.d.ts.map +1 -0
  755. package/build-types/date-time/time/test/index.d.ts +2 -0
  756. package/build-types/date-time/time/test/index.d.ts.map +1 -0
  757. package/build-types/date-time/{timezone.d.ts → time/timezone.d.ts} +0 -0
  758. package/build-types/date-time/time/timezone.d.ts.map +1 -0
  759. package/build-types/date-time/types.d.ts +20 -15
  760. package/build-types/date-time/types.d.ts.map +1 -1
  761. package/build-types/divider/styles.d.ts.map +1 -1
  762. package/build-types/dropdown/index.d.ts.map +1 -1
  763. package/build-types/dropdown-menu/index.d.ts.map +1 -1
  764. package/build-types/elevation/hook.d.ts +0 -1
  765. package/build-types/elevation/hook.d.ts.map +1 -1
  766. package/build-types/external-link/index.d.ts +17 -0
  767. package/build-types/external-link/index.d.ts.map +1 -0
  768. package/build-types/external-link/stories/index.d.ts +12 -0
  769. package/build-types/external-link/stories/index.d.ts.map +1 -0
  770. package/build-types/external-link/styles/external-link-styles.d.ts +10 -0
  771. package/build-types/external-link/styles/external-link-styles.d.ts.map +1 -0
  772. package/build-types/external-link/types.d.ts +15 -0
  773. package/build-types/external-link/types.d.ts.map +1 -0
  774. package/build-types/flex/flex/hook.d.ts +0 -1
  775. package/build-types/flex/flex/hook.d.ts.map +1 -1
  776. package/build-types/flex/flex-block/hook.d.ts +0 -1
  777. package/build-types/flex/flex-block/hook.d.ts.map +1 -1
  778. package/build-types/flex/flex-item/hook.d.ts +0 -1
  779. package/build-types/flex/flex-item/hook.d.ts.map +1 -1
  780. package/build-types/form-toggle/index.d.ts +29 -0
  781. package/build-types/form-toggle/index.d.ts.map +1 -0
  782. package/build-types/form-toggle/stories/index.d.ts +12 -0
  783. package/build-types/form-toggle/stories/index.d.ts.map +1 -0
  784. package/build-types/form-toggle/test/index.d.ts +2 -0
  785. package/build-types/form-toggle/test/index.d.ts.map +1 -0
  786. package/build-types/form-toggle/types.d.ts +22 -0
  787. package/build-types/form-toggle/types.d.ts.map +1 -0
  788. package/build-types/form-token-field/index.d.ts +15 -0
  789. package/build-types/form-token-field/index.d.ts.map +1 -0
  790. package/build-types/form-token-field/stories/index.d.ts +13 -0
  791. package/build-types/form-token-field/stories/index.d.ts.map +1 -0
  792. package/build-types/form-token-field/suggestions-list.d.ts +10 -0
  793. package/build-types/form-token-field/suggestions-list.d.ts.map +1 -0
  794. package/build-types/form-token-field/test/lib/fixtures.d.ts +26 -0
  795. package/build-types/form-token-field/test/lib/fixtures.d.ts.map +1 -0
  796. package/build-types/form-token-field/test/lib/token-field-wrapper.d.ts +21 -0
  797. package/build-types/form-token-field/test/lib/token-field-wrapper.d.ts.map +1 -0
  798. package/build-types/form-token-field/token-input.d.ts +12 -0
  799. package/build-types/form-token-field/token-input.d.ts.map +1 -0
  800. package/build-types/form-token-field/token.d.ts +4 -0
  801. package/build-types/form-token-field/token.d.ts.map +1 -0
  802. package/build-types/form-token-field/types.d.ts +176 -0
  803. package/build-types/form-token-field/types.d.ts.map +1 -0
  804. package/build-types/grid/hook.d.ts +0 -1
  805. package/build-types/grid/hook.d.ts.map +1 -1
  806. package/build-types/h-stack/hook.d.ts +0 -1
  807. package/build-types/h-stack/hook.d.ts.map +1 -1
  808. package/build-types/heading/component.d.ts +1 -2
  809. package/build-types/heading/component.d.ts.map +1 -1
  810. package/build-types/heading/hook.d.ts +1 -29
  811. package/build-types/heading/hook.d.ts.map +1 -1
  812. package/build-types/heading/stories/index.d.ts.map +1 -1
  813. package/build-types/heading/test/index.d.ts +2 -0
  814. package/build-types/heading/test/index.d.ts.map +1 -0
  815. package/build-types/heading/types.d.ts +16 -0
  816. package/build-types/heading/types.d.ts.map +1 -0
  817. package/build-types/higher-order/with-focus-outside/index.d.ts +1 -1
  818. package/build-types/input-control/index.d.ts +1 -1
  819. package/build-types/input-control/index.d.ts.map +1 -1
  820. package/build-types/input-control/input-field.d.ts +1 -1
  821. package/build-types/input-control/input-field.d.ts.map +1 -1
  822. package/build-types/input-control/reducer/reducer.d.ts +5 -3
  823. package/build-types/input-control/reducer/reducer.d.ts.map +1 -1
  824. package/build-types/input-control/reducer/state.d.ts +2 -2
  825. package/build-types/input-control/reducer/state.d.ts.map +1 -1
  826. package/build-types/input-control/stories/index.d.ts +5 -5
  827. package/build-types/input-control/stories/index.d.ts.map +1 -1
  828. package/build-types/input-control/utils.d.ts +17 -0
  829. package/build-types/input-control/utils.d.ts.map +1 -1
  830. package/build-types/item-group/item/hook.d.ts +0 -1
  831. package/build-types/item-group/item/hook.d.ts.map +1 -1
  832. package/build-types/item-group/item-group/hook.d.ts +0 -1
  833. package/build-types/item-group/item-group/hook.d.ts.map +1 -1
  834. package/build-types/navigator/navigator-back-button/hook.d.ts +0 -1
  835. package/build-types/navigator/navigator-back-button/hook.d.ts.map +1 -1
  836. package/build-types/navigator/navigator-button/hook.d.ts +0 -1
  837. package/build-types/navigator/navigator-button/hook.d.ts.map +1 -1
  838. package/build-types/navigator/navigator-provider/component.d.ts.map +1 -1
  839. package/build-types/number-control/styles/number-control-styles.d.ts +1 -1
  840. package/build-types/popover/index.d.ts +1 -0
  841. package/build-types/popover/index.d.ts.map +1 -1
  842. package/build-types/radio-control/index.d.ts +31 -0
  843. package/build-types/radio-control/index.d.ts.map +1 -0
  844. package/build-types/radio-control/stories/index.d.ts +12 -0
  845. package/build-types/radio-control/stories/index.d.ts.map +1 -0
  846. package/build-types/radio-control/types.d.ts +29 -0
  847. package/build-types/radio-control/types.d.ts.map +1 -0
  848. package/build-types/range-control/index.d.ts +5 -5
  849. package/build-types/range-control/index.d.ts.map +1 -1
  850. package/build-types/range-control/input-range.d.ts +4 -4
  851. package/build-types/range-control/input-range.d.ts.map +1 -1
  852. package/build-types/range-control/utils.d.ts.map +1 -1
  853. package/build-types/resizable-box/resize-tooltip/index.d.ts.map +1 -1
  854. package/build-types/resizable-box/resize-tooltip/utils.d.ts.map +1 -1
  855. package/build-types/scrollable/hook.d.ts +0 -1
  856. package/build-types/scrollable/hook.d.ts.map +1 -1
  857. package/build-types/select-control/index.d.ts +1 -1
  858. package/build-types/select-control/index.d.ts.map +1 -1
  859. package/build-types/select-control/stories/index.d.ts +3 -3
  860. package/build-types/select-control/stories/index.d.ts.map +1 -1
  861. package/build-types/select-control/types.d.ts +1 -1
  862. package/build-types/select-control/types.d.ts.map +1 -1
  863. package/build-types/slot-fill/fill.d.ts.map +1 -1
  864. package/build-types/slot-fill/slot.d.ts.map +1 -1
  865. package/build-types/spacer/component.d.ts +2 -3
  866. package/build-types/spacer/component.d.ts.map +1 -1
  867. package/build-types/spacer/hook.d.ts +0 -1
  868. package/build-types/spacer/hook.d.ts.map +1 -1
  869. package/build-types/spacer/stories/index.d.ts +12 -0
  870. package/build-types/spacer/stories/index.d.ts.map +1 -0
  871. package/build-types/spinner/index.d.ts +16 -15
  872. package/build-types/spinner/index.d.ts.map +1 -1
  873. package/build-types/spinner/stories/index.d.ts +13 -0
  874. package/build-types/spinner/stories/index.d.ts.map +1 -0
  875. package/build-types/spinner/styles.d.ts +4 -3
  876. package/build-types/spinner/styles.d.ts.map +1 -1
  877. package/build-types/surface/component.d.ts +3 -2
  878. package/build-types/surface/component.d.ts.map +1 -1
  879. package/build-types/surface/hook.d.ts +4 -5
  880. package/build-types/surface/hook.d.ts.map +1 -1
  881. package/build-types/surface/index.d.ts +2 -2
  882. package/build-types/surface/index.d.ts.map +1 -1
  883. package/build-types/surface/stories/index.d.ts +12 -0
  884. package/build-types/surface/stories/index.d.ts.map +1 -0
  885. package/build-types/surface/styles.d.ts +10 -21
  886. package/build-types/surface/styles.d.ts.map +1 -1
  887. package/build-types/surface/test/index.d.ts +2 -0
  888. package/build-types/surface/test/index.d.ts.map +1 -0
  889. package/build-types/surface/types.d.ts +1 -1
  890. package/build-types/surface/types.d.ts.map +1 -1
  891. package/build-types/text/hook.d.ts +0 -1
  892. package/build-types/text/hook.d.ts.map +1 -1
  893. package/build-types/text/types.d.ts +1 -1
  894. package/build-types/text/types.d.ts.map +1 -1
  895. package/build-types/text/utils.d.ts.map +1 -1
  896. package/build-types/text-control/index.d.ts +1 -1
  897. package/build-types/text-control/index.d.ts.map +1 -1
  898. package/build-types/text-control/stories/index.d.ts.map +1 -1
  899. package/build-types/textarea-control/index.d.ts +29 -0
  900. package/build-types/textarea-control/index.d.ts.map +1 -0
  901. package/build-types/textarea-control/stories/index.d.ts +12 -0
  902. package/build-types/textarea-control/stories/index.d.ts.map +1 -0
  903. package/build-types/textarea-control/styles/textarea-control-styles.d.ts +6 -0
  904. package/build-types/textarea-control/styles/textarea-control-styles.d.ts.map +1 -0
  905. package/build-types/textarea-control/types.d.ts +26 -0
  906. package/build-types/textarea-control/types.d.ts.map +1 -0
  907. package/build-types/toggle-group-control/toggle-group-control/toggle-group-control-backdrop.d.ts.map +1 -1
  908. package/build-types/tools-panel/tools-panel/hook.d.ts +0 -1
  909. package/build-types/tools-panel/tools-panel/hook.d.ts.map +1 -1
  910. package/build-types/tools-panel/tools-panel-header/hook.d.ts +0 -1
  911. package/build-types/tools-panel/tools-panel-header/hook.d.ts.map +1 -1
  912. package/build-types/tools-panel/tools-panel-item/hook.d.ts +0 -1
  913. package/build-types/tools-panel/tools-panel-item/hook.d.ts.map +1 -1
  914. package/build-types/tooltip/index.d.ts.map +1 -1
  915. package/build-types/tree-select/index.d.ts +53 -0
  916. package/build-types/tree-select/index.d.ts.map +1 -0
  917. package/build-types/tree-select/stories/index.d.ts +12 -0
  918. package/build-types/tree-select/stories/index.d.ts.map +1 -0
  919. package/build-types/tree-select/types.d.ts +30 -0
  920. package/build-types/tree-select/types.d.ts.map +1 -0
  921. package/build-types/truncate/component.d.ts +3 -3
  922. package/build-types/truncate/component.d.ts.map +1 -1
  923. package/build-types/truncate/hook.d.ts +5 -3
  924. package/build-types/truncate/hook.d.ts.map +1 -1
  925. package/build-types/truncate/index.d.ts +2 -2
  926. package/build-types/truncate/index.d.ts.map +1 -1
  927. package/build-types/truncate/stories/index.d.ts +13 -0
  928. package/build-types/truncate/stories/index.d.ts.map +1 -0
  929. package/build-types/truncate/styles.d.ts +1 -1
  930. package/build-types/truncate/styles.d.ts.map +1 -1
  931. package/build-types/truncate/test/index.d.ts +2 -0
  932. package/build-types/truncate/test/index.d.ts.map +1 -0
  933. package/build-types/truncate/types.d.ts +22 -11
  934. package/build-types/truncate/types.d.ts.map +1 -1
  935. package/build-types/truncate/utils.d.ts +17 -28
  936. package/build-types/truncate/utils.d.ts.map +1 -1
  937. package/build-types/ui/context/wordpress-component.d.ts.map +1 -1
  938. package/build-types/ui/control-group/hook.d.ts +0 -1
  939. package/build-types/ui/control-group/hook.d.ts.map +1 -1
  940. package/build-types/ui/control-label/hook.d.ts +0 -1
  941. package/build-types/ui/control-label/hook.d.ts.map +1 -1
  942. package/build-types/ui/form-group/use-form-group.d.ts +2 -4
  943. package/build-types/ui/form-group/use-form-group.d.ts.map +1 -1
  944. package/build-types/unit-control/index.d.ts +1 -1
  945. package/build-types/unit-control/index.d.ts.map +1 -1
  946. package/build-types/unit-control/stories/index.d.ts.map +1 -1
  947. package/build-types/utils/hooks/index.d.ts +0 -1
  948. package/build-types/utils/math.d.ts +10 -0
  949. package/build-types/utils/math.d.ts.map +1 -1
  950. package/build-types/utils/unit-values.d.ts.map +1 -1
  951. package/build-types/utils/values.d.ts.map +1 -1
  952. package/build-types/v-stack/component.d.ts +5 -4
  953. package/build-types/v-stack/component.d.ts.map +1 -1
  954. package/build-types/v-stack/hook.d.ts +5 -4
  955. package/build-types/v-stack/hook.d.ts.map +1 -1
  956. package/build-types/v-stack/index.d.ts +2 -2
  957. package/build-types/v-stack/index.d.ts.map +1 -1
  958. package/build-types/v-stack/stories/index.d.ts +9 -0
  959. package/build-types/v-stack/stories/index.d.ts.map +1 -0
  960. package/build-types/v-stack/test/index.d.ts +2 -0
  961. package/build-types/v-stack/test/index.d.ts.map +1 -0
  962. package/build-types/v-stack/types.d.ts +21 -1
  963. package/build-types/v-stack/types.d.ts.map +1 -1
  964. package/build-types/z-stack/component.d.ts +18 -28
  965. package/build-types/z-stack/component.d.ts.map +1 -1
  966. package/build-types/z-stack/stories/index.d.ts +6 -0
  967. package/build-types/z-stack/stories/index.d.ts.map +1 -0
  968. package/build-types/z-stack/types.d.ts +33 -0
  969. package/build-types/z-stack/types.d.ts.map +1 -0
  970. package/package.json +19 -18
  971. package/src/alignment-matrix-control/index.js +6 -3
  972. package/src/alignment-matrix-control/utils.js +1 -6
  973. package/src/angle-picker-control/index.js +1 -1
  974. package/src/autocomplete/autocompleter-ui.js +3 -0
  975. package/src/autocomplete/autocompleter-ui.native.js +6 -0
  976. package/src/autocomplete/index.js +16 -8
  977. package/src/base-control/stories/index.tsx +2 -3
  978. package/src/border-box-control/border-box-control/component.tsx +1 -0
  979. package/src/border-box-control/border-box-control/hook.ts +2 -2
  980. package/src/border-box-control/border-box-control-linked-button/component.tsx +2 -5
  981. package/src/border-box-control/border-box-control-split-controls/component.tsx +3 -0
  982. package/src/border-box-control/border-box-control-split-controls/hook.ts +18 -4
  983. package/src/border-box-control/border-box-control-visualizer/hook.ts +5 -2
  984. package/src/border-box-control/styles.ts +6 -2
  985. package/src/border-box-control/utils.ts +5 -2
  986. package/src/border-control/border-control/component.tsx +41 -4
  987. package/src/border-control/border-control/hook.ts +10 -5
  988. package/src/border-control/stories/index.tsx +150 -0
  989. package/src/box-control/all-input-control.js +2 -4
  990. package/src/box-control/axial-input-controls.js +4 -6
  991. package/src/box-control/index.js +2 -5
  992. package/src/box-control/input-controls.js +33 -36
  993. package/src/box-control/test/index.js +120 -109
  994. package/src/box-control/unit-control.js +2 -1
  995. package/src/box-control/utils.js +4 -4
  996. package/src/button/index.native.js +1 -2
  997. package/src/card/stories/index.js +10 -5
  998. package/src/card/types.ts +1 -1
  999. package/src/checkbox-control/index.tsx +2 -3
  1000. package/src/checkbox-control/stories/index.tsx +2 -3
  1001. package/src/checkbox-control/test/__snapshots__/index.tsx.snap +42 -0
  1002. package/src/checkbox-control/test/index.tsx +110 -0
  1003. package/src/color-indicator/README.md +7 -9
  1004. package/src/color-indicator/index.tsx +47 -0
  1005. package/src/color-indicator/stories/index.tsx +37 -0
  1006. package/src/color-indicator/test/__snapshots__/index.tsx.snap +11 -0
  1007. package/src/color-indicator/test/{index.js → index.tsx} +4 -4
  1008. package/src/color-indicator/types.ts +12 -0
  1009. package/src/color-palette/index.js +16 -5
  1010. package/src/color-palette/index.native.js +3 -0
  1011. package/src/color-palette/stories/index.js +25 -1
  1012. package/src/color-palette/test/utils.ts +24 -0
  1013. package/src/color-picker/color-copy-button.tsx +76 -0
  1014. package/src/color-picker/component.tsx +18 -37
  1015. package/src/color-picker/hex-input.tsx +16 -0
  1016. package/src/color-picker/index.native.js +7 -4
  1017. package/src/color-picker/input-with-slider.tsx +2 -2
  1018. package/src/color-picker/styles.ts +25 -2
  1019. package/src/color-picker/types.ts +9 -0
  1020. package/src/combobox-control/index.js +4 -2
  1021. package/src/confirm-dialog/component.tsx +7 -8
  1022. package/src/custom-gradient-bar/constants.js +2 -2
  1023. package/src/custom-gradient-bar/control-points.js +20 -16
  1024. package/src/custom-gradient-bar/index.js +11 -11
  1025. package/src/custom-gradient-bar/test/utils.js +79 -0
  1026. package/src/custom-gradient-bar/utils.js +6 -18
  1027. package/src/custom-gradient-picker/index.js +4 -11
  1028. package/src/custom-gradient-picker/index.native.js +3 -11
  1029. package/src/custom-gradient-picker/serializer.js +5 -11
  1030. package/src/custom-gradient-picker/style.scss +1 -3
  1031. package/src/custom-gradient-picker/utils.js +5 -4
  1032. package/src/custom-select-control/index.js +2 -1
  1033. package/src/custom-select-control/stories/index.js +1 -2
  1034. package/src/date-time/README.md +23 -0
  1035. package/src/date-time/{datepicker.scss → date/datepicker.scss} +0 -0
  1036. package/src/date-time/{date.tsx → date/index.tsx} +42 -17
  1037. package/src/date-time/date/style.scss +85 -0
  1038. package/src/date-time/date/styles.ts +55 -0
  1039. package/src/date-time/{test/date.tsx → date/test/index.tsx} +2 -2
  1040. package/src/date-time/{test → date/test}/utils.ts +0 -0
  1041. package/src/date-time/{utils.ts → date/utils.ts} +0 -0
  1042. package/src/date-time/date-time/index.tsx +217 -0
  1043. package/src/date-time/date-time/styles.ts +8 -0
  1044. package/src/date-time/index.ts +9 -0
  1045. package/src/date-time/stories/{index.tsx → date-time.tsx} +5 -7
  1046. package/src/date-time/stories/date.tsx +2 -3
  1047. package/src/date-time/style.scss +1 -262
  1048. package/src/date-time/time/index.tsx +356 -0
  1049. package/src/date-time/time/styles.ts +119 -0
  1050. package/src/date-time/{test/time.tsx → time/test/index.tsx} +97 -50
  1051. package/src/date-time/{timezone.tsx → time/timezone.tsx} +5 -2
  1052. package/src/date-time/types.ts +23 -18
  1053. package/src/dimension-control/README.md +5 -2
  1054. package/src/dimension-control/index.js +1 -2
  1055. package/src/dimension-control/test/index.test.js +7 -7
  1056. package/src/divider/styles.ts +2 -3
  1057. package/src/draggable/index.js +3 -3
  1058. package/src/draggable/index.native.js +26 -7
  1059. package/src/draggable/test/index.native.js +130 -0
  1060. package/src/drop-zone/provider.js +1 -2
  1061. package/src/dropdown/index.js +7 -3
  1062. package/src/dropdown-menu/index.js +11 -1
  1063. package/src/dropdown-menu/index.native.js +11 -1
  1064. package/src/duotone-picker/duotone-picker.js +58 -37
  1065. package/src/duotone-picker/style.scss +19 -0
  1066. package/src/elevation/hook.js +8 -8
  1067. package/src/external-link/README.md +18 -0
  1068. package/src/external-link/{index.js → index.tsx} +26 -6
  1069. package/src/external-link/stories/index.tsx +36 -0
  1070. package/src/external-link/styles/{external-link-styles.js → external-link-styles.ts} +0 -0
  1071. package/src/external-link/types.ts +15 -0
  1072. package/src/flex/flex/README.md +5 -10
  1073. package/src/flex/flex/hook.js +4 -1
  1074. package/src/flex/flex-item/README.md +1 -1
  1075. package/src/focal-point-picker/controls.js +1 -5
  1076. package/src/focal-point-picker/index.js +2 -8
  1077. package/src/focal-point-picker/index.native.js +1 -1
  1078. package/src/focal-point-picker/media.js +2 -5
  1079. package/src/font-size-picker/index.js +3 -1
  1080. package/src/form-toggle/README.md +10 -11
  1081. package/src/form-toggle/index.tsx +71 -0
  1082. package/src/form-toggle/stories/index.tsx +52 -0
  1083. package/src/form-toggle/test/__snapshots__/index.tsx.snap +54 -0
  1084. package/src/form-toggle/test/index.tsx +102 -0
  1085. package/src/form-toggle/types.ts +22 -0
  1086. package/src/form-token-field/index.tsx +694 -0
  1087. package/src/form-token-field/stories/index.tsx +103 -0
  1088. package/src/form-token-field/style.scss +2 -1
  1089. package/src/form-token-field/{suggestions-list.js → suggestions-list.tsx} +45 -29
  1090. package/src/form-token-field/test/index.js +70 -40
  1091. package/src/form-token-field/test/lib/token-field-wrapper.tsx +71 -0
  1092. package/src/form-token-field/token-input.tsx +76 -0
  1093. package/src/form-token-field/{token.js → token.tsx} +4 -2
  1094. package/src/form-token-field/types.ts +178 -0
  1095. package/src/gradient-picker/index.js +4 -3
  1096. package/src/h-stack/utils.js +3 -3
  1097. package/src/heading/README.md +4 -3
  1098. package/src/heading/component.tsx +2 -2
  1099. package/src/heading/hook.ts +6 -46
  1100. package/src/heading/stories/index.tsx +5 -1
  1101. package/src/heading/test/__snapshots__/{index.js.snap → index.tsx.snap} +0 -0
  1102. package/src/heading/test/index.tsx +68 -0
  1103. package/src/heading/types.ts +29 -0
  1104. package/src/higher-order/navigate-regions/index.js +7 -5
  1105. package/src/higher-order/with-filters/test/index.js +43 -36
  1106. package/src/higher-order/with-focus-return/index.js +14 -13
  1107. package/src/higher-order/with-spoken-messages/index.js +8 -7
  1108. package/src/higher-order/with-spoken-messages/test/index.js +1 -1
  1109. package/src/icon/index.tsx +2 -2
  1110. package/src/input-control/index.tsx +10 -3
  1111. package/src/input-control/input-field.tsx +12 -31
  1112. package/src/input-control/reducer/reducer.ts +63 -47
  1113. package/src/input-control/reducer/state.ts +2 -3
  1114. package/src/input-control/test/index.js +106 -31
  1115. package/src/input-control/utils.ts +56 -2
  1116. package/src/item-group/stories/index.js +2 -1
  1117. package/src/menu-item/test/index.js +2 -1
  1118. package/src/menu-items-choice/index.js +2 -5
  1119. package/src/mobile/bottom-sheet/bottom-sheet-context.native.js +2 -4
  1120. package/src/mobile/bottom-sheet/cell.native.js +2 -3
  1121. package/src/mobile/bottom-sheet/cycle-picker-cell.native.js +3 -5
  1122. package/src/mobile/bottom-sheet/index.native.js +14 -17
  1123. package/src/mobile/bottom-sheet/keyboard-avoiding-view.native.js +2 -7
  1124. package/src/mobile/bottom-sheet/picker-cell.native.js +2 -7
  1125. package/src/mobile/bottom-sheet/stepper-cell/index.native.js +4 -6
  1126. package/src/mobile/color-settings/index.native.js +2 -4
  1127. package/src/mobile/global-styles-context/index.native.js +8 -7
  1128. package/src/mobile/gradient/index.native.js +12 -9
  1129. package/src/mobile/gradient/test/index.native.js +1 -3
  1130. package/src/mobile/html-text-input/index.native.js +2 -3
  1131. package/src/mobile/inserter-button/index.native.js +2 -6
  1132. package/src/mobile/link-picker/index.native.js +2 -3
  1133. package/src/mobile/link-settings/image-link-destinations-screen.native.js +6 -2
  1134. package/src/mobile/media-edit/index.native.js +2 -3
  1135. package/src/mobile/segmented-control/index.native.js +9 -9
  1136. package/src/mobile/utils/test/index.native.js +3 -12
  1137. package/src/modal/index.js +1 -1
  1138. package/src/navigable-container/container.js +3 -2
  1139. package/src/navigable-container/test/menu.js +1 -2
  1140. package/src/navigable-container/test/tabbable.js +1 -2
  1141. package/src/navigation/context.js +2 -5
  1142. package/src/navigation/group/index.js +8 -3
  1143. package/src/navigation/index.js +2 -1
  1144. package/src/navigation/item/base.js +3 -2
  1145. package/src/navigation/item/index.js +2 -1
  1146. package/src/navigation/item/use-navigation-tree-item.js +2 -0
  1147. package/src/navigation/menu/menu-title-search.js +3 -6
  1148. package/src/navigation/menu/search-no-results-found.js +3 -6
  1149. package/src/navigation/stories/controlled-state.js +1 -1
  1150. package/src/navigation/stories/more-examples.js +2 -3
  1151. package/src/navigation/test/index.js +252 -52
  1152. package/src/navigation/use-navigation-tree-nodes.js +11 -10
  1153. package/src/navigation/utils.js +2 -2
  1154. package/src/navigator/navigator-back-button/hook.ts +14 -12
  1155. package/src/navigator/navigator-button/hook.ts +14 -13
  1156. package/src/navigator/navigator-provider/component.tsx +2 -6
  1157. package/src/navigator/navigator-screen/component.tsx +3 -3
  1158. package/src/notice/index.js +2 -1
  1159. package/src/notice/list.js +3 -1
  1160. package/src/number-control/stories/index.js +24 -24
  1161. package/src/panel/body.js +2 -1
  1162. package/src/placeholder/README.md +7 -6
  1163. package/src/placeholder/index.js +27 -10
  1164. package/src/placeholder/style.scss +23 -0
  1165. package/src/popover/index.js +42 -27
  1166. package/src/query-controls/README.md +1 -1
  1167. package/src/radio-control/README.md +17 -23
  1168. package/src/radio-control/index.tsx +107 -0
  1169. package/src/radio-control/stories/index.tsx +72 -0
  1170. package/src/radio-control/types.ts +32 -0
  1171. package/src/range-control/index.js +4 -2
  1172. package/src/range-control/input-range.js +2 -5
  1173. package/src/range-control/utils.js +3 -4
  1174. package/src/resizable-box/resize-tooltip/index.tsx +2 -1
  1175. package/src/resizable-box/resize-tooltip/utils.ts +1 -5
  1176. package/src/responsive-wrapper/index.js +2 -4
  1177. package/src/sandbox/test/index.js +4 -6
  1178. package/src/search-control/index.js +6 -7
  1179. package/src/select-control/README.md +11 -0
  1180. package/src/select-control/index.tsx +9 -2
  1181. package/src/select-control/stories/index.tsx +3 -4
  1182. package/src/select-control/types.ts +1 -1
  1183. package/src/slot-fill/README.md +1 -1
  1184. package/src/slot-fill/fill.js +1 -5
  1185. package/src/slot-fill/slot.js +12 -2
  1186. package/src/slot-fill/test/slot.js +2 -3
  1187. package/src/snackbar/index.js +1 -1
  1188. package/src/snackbar/list.js +2 -1
  1189. package/src/spacer/component.tsx +3 -4
  1190. package/src/spacer/hook.ts +13 -13
  1191. package/src/spacer/stories/index.tsx +70 -0
  1192. package/src/spinner/{index.js → index.tsx} +23 -9
  1193. package/src/spinner/stories/index.tsx +32 -0
  1194. package/src/spinner/{styles.js → styles.ts} +0 -0
  1195. package/src/style.scss +1 -0
  1196. package/src/surface/README.md +15 -15
  1197. package/src/surface/{component.js → component.tsx} +13 -7
  1198. package/src/surface/{hook.js → hook.ts} +13 -12
  1199. package/src/surface/{index.js → index.ts} +0 -0
  1200. package/src/surface/stories/index.tsx +40 -0
  1201. package/src/surface/{styles.js → styles.ts} +15 -44
  1202. package/src/surface/test/__snapshots__/{index.js.snap → index.tsx.snap} +0 -0
  1203. package/src/surface/test/{index.js → index.tsx} +2 -1
  1204. package/src/surface/types.ts +1 -1
  1205. package/src/tab-panel/index.js +3 -1
  1206. package/src/text/hook.js +4 -1
  1207. package/src/text/types.ts +1 -1
  1208. package/src/text/utils.js +2 -3
  1209. package/src/text-control/stories/index.tsx +4 -6
  1210. package/src/textarea-control/README.md +14 -20
  1211. package/src/textarea-control/index.tsx +86 -0
  1212. package/src/textarea-control/stories/index.tsx +58 -0
  1213. package/src/textarea-control/styles/{textarea-control-styles.js → textarea-control-styles.ts} +0 -0
  1214. package/src/textarea-control/types.ts +30 -0
  1215. package/src/toggle-control/index.js +1 -2
  1216. package/src/toggle-control/index.native.js +2 -6
  1217. package/src/toggle-group-control/toggle-group-control/toggle-group-control-backdrop.tsx +2 -4
  1218. package/src/toolbar/index.js +1 -2
  1219. package/src/tools-panel/tools-panel/hook.ts +2 -4
  1220. package/src/tools-panel/tools-panel-header/hook.ts +2 -5
  1221. package/src/tooltip/index.js +1 -0
  1222. package/src/tree-grid/roving-tab-index-item.js +2 -4
  1223. package/src/tree-grid/test/index.js +2 -3
  1224. package/src/tree-select/README.md +2 -2
  1225. package/src/tree-select/index.tsx +99 -0
  1226. package/src/tree-select/stories/index.tsx +80 -0
  1227. package/src/tree-select/types.ts +35 -0
  1228. package/src/truncate/README.md +16 -12
  1229. package/src/truncate/{component.js → component.tsx} +13 -9
  1230. package/src/truncate/{hook.js → hook.ts} +8 -10
  1231. package/src/truncate/{index.js → index.ts} +0 -0
  1232. package/src/truncate/stories/index.tsx +49 -0
  1233. package/src/truncate/{styles.js → styles.ts} +0 -0
  1234. package/src/truncate/test/{index.js → index.tsx} +4 -4
  1235. package/src/truncate/types.ts +28 -10
  1236. package/src/truncate/{utils.js → utils.ts} +19 -19
  1237. package/src/ui/context/wordpress-component.ts +4 -5
  1238. package/src/ui/form-group/form-group-content.js +4 -4
  1239. package/src/unit-control/index.tsx +7 -9
  1240. package/src/unit-control/stories/index.tsx +8 -12
  1241. package/src/unit-control/test/index.tsx +4 -7
  1242. package/src/utils/hooks/index.js +0 -1
  1243. package/src/utils/hooks/stories/use-cx.js +8 -7
  1244. package/src/utils/hooks/test/use-controlled-state.js +2 -1
  1245. package/src/utils/math.js +14 -5
  1246. package/src/utils/test/math.js +22 -1
  1247. package/src/utils/unit-values.ts +2 -1
  1248. package/src/utils/values.js +2 -3
  1249. package/src/v-stack/README.md +6 -18
  1250. package/src/v-stack/{component.js → component.tsx} +15 -10
  1251. package/src/v-stack/{hook.js → hook.ts} +5 -6
  1252. package/src/v-stack/{index.js → index.ts} +0 -0
  1253. package/src/v-stack/stories/index.tsx +41 -0
  1254. package/src/v-stack/test/__snapshots__/{index.js.snap → index.tsx.snap} +0 -0
  1255. package/src/v-stack/test/{index.js → index.tsx} +0 -0
  1256. package/src/v-stack/types.ts +21 -1
  1257. package/src/z-stack/README.md +14 -3
  1258. package/src/z-stack/component.tsx +24 -29
  1259. package/src/z-stack/stories/index.tsx +76 -0
  1260. package/src/z-stack/types.ts +33 -0
  1261. package/tsconfig.json +7 -0
  1262. package/tsconfig.tsbuildinfo +1 -1
  1263. package/build/color-picker/color-display.js +0 -184
  1264. package/build/color-picker/color-display.js.map +0 -1
  1265. package/build/date-time/date.js.map +0 -1
  1266. package/build/date-time/time.js +0 -289
  1267. package/build/date-time/time.js.map +0 -1
  1268. package/build/date-time/timezone.js.map +0 -1
  1269. package/build/date-time/utils.js.map +0 -1
  1270. package/build/utils/hooks/use-combined-ref.js +0 -32
  1271. package/build/utils/hooks/use-combined-ref.js.map +0 -1
  1272. package/build-module/color-picker/color-display.js +0 -170
  1273. package/build-module/color-picker/color-display.js.map +0 -1
  1274. package/build-module/date-time/date.js.map +0 -1
  1275. package/build-module/date-time/time.js +0 -271
  1276. package/build-module/date-time/time.js.map +0 -1
  1277. package/build-module/date-time/timezone.js.map +0 -1
  1278. package/build-module/date-time/utils.js.map +0 -1
  1279. package/build-module/utils/hooks/use-combined-ref.js +0 -28
  1280. package/build-module/utils/hooks/use-combined-ref.js.map +0 -1
  1281. package/build-types/color-picker/color-display.d.ts +0 -14
  1282. package/build-types/color-picker/color-display.d.ts.map +0 -1
  1283. package/build-types/date-time/date.d.ts.map +0 -1
  1284. package/build-types/date-time/stories/index.d.ts.map +0 -1
  1285. package/build-types/date-time/test/date.d.ts +0 -2
  1286. package/build-types/date-time/test/date.d.ts.map +0 -1
  1287. package/build-types/date-time/test/time.d.ts +0 -2
  1288. package/build-types/date-time/test/time.d.ts.map +0 -1
  1289. package/build-types/date-time/test/utils.d.ts.map +0 -1
  1290. package/build-types/date-time/time.d.ts.map +0 -1
  1291. package/build-types/date-time/timezone.d.ts.map +0 -1
  1292. package/build-types/date-time/utils.d.ts.map +0 -1
  1293. package/build-types/utils/hooks/use-combined-ref.d.ts +0 -8
  1294. package/build-types/utils/hooks/use-combined-ref.d.ts.map +0 -1
  1295. package/src/border-control/stories/index.js +0 -119
  1296. package/src/color-indicator/index.js +0 -16
  1297. package/src/color-indicator/stories/index.js +0 -22
  1298. package/src/color-indicator/test/__snapshots__/index.js.snap +0 -13
  1299. package/src/color-picker/color-display.tsx +0 -169
  1300. package/src/date-time/index.tsx +0 -196
  1301. package/src/date-time/time.tsx +0 -321
  1302. package/src/external-link/stories/index.js +0 -23
  1303. package/src/form-toggle/index.js +0 -37
  1304. package/src/form-toggle/stories/index.js +0 -28
  1305. package/src/form-toggle/test/index.js +0 -75
  1306. package/src/form-token-field/index.js +0 -725
  1307. package/src/form-token-field/stories/index.js +0 -102
  1308. package/src/form-token-field/test/lib/token-field-wrapper.js +0 -56
  1309. package/src/form-token-field/token-input.js +0 -81
  1310. package/src/heading/test/index.js +0 -67
  1311. package/src/radio-control/index.js +0 -69
  1312. package/src/radio-control/stories/index.js +0 -41
  1313. package/src/spacer/stories/index.js +0 -59
  1314. package/src/spinner/stories/index.js +0 -43
  1315. package/src/surface/stories/index.js +0 -46
  1316. package/src/textarea-control/index.js +0 -45
  1317. package/src/textarea-control/stories/index.js +0 -48
  1318. package/src/tree-select/index.js +0 -48
  1319. package/src/tree-select/stories/index.js +0 -80
  1320. package/src/truncate/stories/index.js +0 -38
  1321. package/src/utils/hooks/use-combined-ref.ts +0 -28
  1322. package/src/z-stack/stories/index.js +0 -70
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/custom-gradient-bar/control-points.js"],"names":["classnames","colord","useInstanceId","useEffect","useRef","useState","useMemo","__","sprintf","plus","LEFT","RIGHT","Button","ColorPicker","VisuallyHidden","CustomColorPickerDropdown","addControlPoint","clampPercent","removeControlPoint","updateControlPointColor","updateControlPointColorByPosition","updateControlPointPosition","getHorizontalRelativeGradientPosition","GRADIENT_MARKERS_WIDTH","MINIMUM_SIGNIFICANT_MOVE","KEYBOARD_CONTROL_POINT_VARIATION","ControlPointButton","isOpen","position","color","additionalProps","instanceId","descriptionId","left","GradientColorPickerDropdown","isRenderedInSidebar","gradientPickerDomRef","props","popoverProps","result","className","anchorRef","current","ControlPoints","disableRemove","disableAlpha","ignoreMarkerPosition","value","controlPoints","onChange","onStartControlPointChange","onStopControlPointChange","__experimentalIsRenderedInSidebar","controlPointMoveState","onMouseMove","event","relativePosition","clientX","initialPosition","index","significantMoveHappened","Math","abs","cleanEventListeners","window","removeEventListener","listenersActivated","map","point","onToggle","addEventListener","keyCode","stopPropagation","onClose","toRgbString","length","InsertPoint","onOpenInserter","onCloseInserter","insertPosition","alreadyInsertedPoint","setAlreadyInsertedPoint","undefined"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AACA,SAASC,MAAT,QAAuB,QAAvB;AAEA;AACA;AACA;;AACA,SAASC,aAAT,QAA8B,oBAA9B;AACA,SAASC,SAAT,EAAoBC,MAApB,EAA4BC,QAA5B,EAAsCC,OAAtC,QAAqD,oBAArD;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,IAAT,QAAqB,kBAArB;AACA,SAASC,IAAT,EAAeC,KAAf,QAA4B,qBAA5B;AAEA;AACA;AACA;;AACA,OAAOC,MAAP,MAAmB,WAAnB;AACA,SAASC,WAAT,QAA4B,iBAA5B;AACA,SAASC,cAAT,QAA+B,oBAA/B;AACA,SAASC,yBAAT,QAA0C,kBAA1C;AAEA,SACCC,eAD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AEO;AACNG,YAAAA,uBAAuB,CAAE,KAAF,CAAvB;AACAJ,YAAAA,cAAc;AACd;;AACDR,UAAAA,QAAQ;AACR,SAXF;AAYC,QAAA,SAAS,EAAC,iDAZX;AAaC,QAAA,IAAI,EAAG5D,IAbR;AAcC,QAAA,KAAK,EAAG;AACPwB,UAAAA,IAAI,EACH8C,cAAc,KAAK,IAAnB,GACI,GAAGA,cAAgB,GADvB,GAEGG;AAJG;AAdT,QADc;AAAA,KAPhB;AA8BC,IAAA,aAAa,EAAG,MACf,cAAC,WAAD;AACC,MAAA,WAAW,EAAG,CAAErC,YADjB;AAEC,MAAA,QAAQ,EAAKhB,KAAF,IAAa;AACvB,YAAK,CAAEmD,oBAAP,EAA8B;AAC7B/B,UAAAA,QAAQ,CACPjC,eAAe,CACdgC,aADc,EAEd+B,cAFc,EAGd9E,MAAM,CAAE4B,KAAF,CAAN,CAAgB6C,WAAhB,EAHc,CADR,CAAR;AAOAO,UAAAA,uBAAuB,CAAE,IAAF,CAAvB;AACA,SATD,MASO;AACNhC,UAAAA,QAAQ,CACP7B,iCAAiC,CAChC4B,aADgC,EAEhC+B,cAFgC,EAGhC9E,MAAM,CAAE4B,KAAF,CAAN,CAAgB6C,WAAhB,EAHgC,CAD1B,CAAR;AAOA;AACD;AArBF;AA/BF,IADD;AA0DA;;AACD/B,aAAa,CAACiC,WAAd,GAA4BA,WAA5B;AAEA,eAAejC,aAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport { colord } from 'colord';\n\n/**\n * WordPress dependencies\n */\nimport { useInstanceId } from '@wordpress/compose';\nimport { useEffect, useRef, useState, useMemo } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { plus } from '@wordpress/icons';\nimport { LEFT, RIGHT } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport Button from '../button';\nimport { ColorPicker } from '../color-picker';\nimport { VisuallyHidden } from '../visually-hidden';\nimport { CustomColorPickerDropdown } from '../color-palette';\n\nimport {\n\taddControlPoint,\n\tclampPercent,\n\tremoveControlPoint,\n\tupdateControlPointColor,\n\tupdateControlPointColorByPosition,\n\tupdateControlPointPosition,\n\tgetHorizontalRelativeGradientPosition,\n} from './utils';\nimport {\n\tGRADIENT_MARKERS_WIDTH,\n\tMINIMUM_SIGNIFICANT_MOVE,\n\tKEYBOARD_CONTROL_POINT_VARIATION,\n} from './constants';\n\nfunction ControlPointButton( { isOpen, position, color, ...additionalProps } ) {\n\tconst instanceId = useInstanceId( ControlPointButton );\n\tconst descriptionId = `components-custom-gradient-picker__control-point-button-description-${ instanceId }`;\n\treturn (\n\t\t<>\n\t\t\t<Button\n\t\t\t\taria-label={ sprintf(\n\t\t\t\t\t// translators: %1$s: gradient position e.g: 70, %2$s: gradient color code e.g: rgb(52,121,151).\n\t\t\t\t\t__(\n\t\t\t\t\t\t'Gradient control point at position %1$s%% with color code %2$s.'\n\t\t\t\t\t),\n\t\t\t\t\tposition,\n\t\t\t\t\tcolor\n\t\t\t\t) }\n\t\t\t\taria-describedby={ descriptionId }\n\t\t\t\taria-haspopup=\"true\"\n\t\t\t\taria-expanded={ isOpen }\n\t\t\t\tclassName={ classnames(\n\t\t\t\t\t'components-custom-gradient-picker__control-point-button',\n\t\t\t\t\t{\n\t\t\t\t\t\t'is-active': isOpen,\n\t\t\t\t\t}\n\t\t\t\t) }\n\t\t\t\tstyle={ {\n\t\t\t\t\tleft: `${ position }%`,\n\t\t\t\t} }\n\t\t\t\t{ ...additionalProps }\n\t\t\t/>\n\t\t\t<VisuallyHidden id={ descriptionId }>\n\t\t\t\t{ __(\n\t\t\t\t\t'Use your left or right arrow keys or drag and drop with the mouse to change the gradient position. Press the button to change the color or remove the control point.'\n\t\t\t\t) }\n\t\t\t</VisuallyHidden>\n\t\t</>\n\t);\n}\n\nfunction GradientColorPickerDropdown( {\n\tisRenderedInSidebar,\n\tgradientPickerDomRef,\n\t...props\n} ) {\n\tconst popoverProps = useMemo( () => {\n\t\tconst result = {\n\t\t\tclassName:\n\t\t\t\t'components-custom-gradient-picker__color-picker-popover',\n\t\t\tposition: 'top',\n\t\t};\n\t\tif ( isRenderedInSidebar ) {\n\t\t\tresult.anchorRef = gradientPickerDomRef.current;\n\t\t\tresult.position = 'bottom left';\n\t\t}\n\t\treturn result;\n\t}, [ gradientPickerDomRef.current, isRenderedInSidebar ] );\n\treturn (\n\t\t<CustomColorPickerDropdown\n\t\t\tisRenderedInSidebar={ isRenderedInSidebar }\n\t\t\tpopoverProps={ popoverProps }\n\t\t\t{ ...props }\n\t\t/>\n\t);\n}\n\nfunction ControlPoints( {\n\tdisableRemove,\n\tdisableAlpha,\n\tgradientPickerDomRef,\n\tignoreMarkerPosition,\n\tvalue: controlPoints,\n\tonChange,\n\tonStartControlPointChange,\n\tonStopControlPointChange,\n\t__experimentalIsRenderedInSidebar,\n} ) {\n\tconst controlPointMoveState = useRef();\n\n\tconst onMouseMove = ( event ) => {\n\t\tconst relativePosition = getHorizontalRelativeGradientPosition(\n\t\t\tevent.clientX,\n\t\t\tgradientPickerDomRef.current,\n\t\t\tGRADIENT_MARKERS_WIDTH\n\t\t);\n\t\tconst {\n\t\t\tinitialPosition,\n\t\t\tindex,\n\t\t\tsignificantMoveHappened,\n\t\t} = controlPointMoveState.current;\n\t\tif (\n\t\t\t! significantMoveHappened &&\n\t\t\tMath.abs( initialPosition - relativePosition ) >=\n\t\t\t\tMINIMUM_SIGNIFICANT_MOVE\n\t\t) {\n\t\t\tcontrolPointMoveState.current.significantMoveHappened = true;\n\t\t}\n\n\t\tonChange(\n\t\t\tupdateControlPointPosition( controlPoints, index, relativePosition )\n\t\t);\n\t};\n\n\tconst cleanEventListeners = () => {\n\t\tif (\n\t\t\twindow &&\n\t\t\twindow.removeEventListener &&\n\t\t\tcontrolPointMoveState.current &&\n\t\t\tcontrolPointMoveState.current.listenersActivated\n\t\t) {\n\t\t\twindow.removeEventListener( 'mousemove', onMouseMove );\n\t\t\twindow.removeEventListener( 'mouseup', cleanEventListeners );\n\t\t\tonStopControlPointChange();\n\t\t\tcontrolPointMoveState.current.listenersActivated = false;\n\t\t}\n\t};\n\n\tuseEffect( () => {\n\t\treturn () => {\n\t\t\tcleanEventListeners();\n\t\t};\n\t}, [] );\n\n\treturn controlPoints.map( ( point, index ) => {\n\t\tconst initialPosition = point?.position;\n\t\treturn (\n\t\t\tignoreMarkerPosition !== initialPosition && (\n\t\t\t\t<GradientColorPickerDropdown\n\t\t\t\t\tgradientPickerDomRef={ gradientPickerDomRef }\n\t\t\t\t\tisRenderedInSidebar={ __experimentalIsRenderedInSidebar }\n\t\t\t\t\tkey={ index }\n\t\t\t\t\tonClose={ onStopControlPointChange }\n\t\t\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t\t\t<ControlPointButton\n\t\t\t\t\t\t\tkey={ index }\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\tcontrolPointMoveState.current &&\n\t\t\t\t\t\t\t\t\tcontrolPointMoveState.current\n\t\t\t\t\t\t\t\t\t\t.significantMoveHappened\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif ( isOpen ) {\n\t\t\t\t\t\t\t\t\tonStopControlPointChange();\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tonStartControlPointChange();\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tonToggle();\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tonMouseDown={ () => {\n\t\t\t\t\t\t\t\tif ( window && window.addEventListener ) {\n\t\t\t\t\t\t\t\t\tcontrolPointMoveState.current = {\n\t\t\t\t\t\t\t\t\t\tinitialPosition,\n\t\t\t\t\t\t\t\t\t\tindex,\n\t\t\t\t\t\t\t\t\t\tsignificantMoveHappened: false,\n\t\t\t\t\t\t\t\t\t\tlistenersActivated: true,\n\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\tonStartControlPointChange();\n\t\t\t\t\t\t\t\t\twindow.addEventListener(\n\t\t\t\t\t\t\t\t\t\t'mousemove',\n\t\t\t\t\t\t\t\t\t\tonMouseMove\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\twindow.addEventListener(\n\t\t\t\t\t\t\t\t\t\t'mouseup',\n\t\t\t\t\t\t\t\t\t\tcleanEventListeners\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tonKeyDown={ ( event ) => {\n\t\t\t\t\t\t\t\tif ( event.keyCode === LEFT ) {\n\t\t\t\t\t\t\t\t\t// Stop propagation of the key press event to avoid focus moving\n\t\t\t\t\t\t\t\t\t// to another editor area.\n\t\t\t\t\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\t\t\t\t\tonChange(\n\t\t\t\t\t\t\t\t\t\tupdateControlPointPosition(\n\t\t\t\t\t\t\t\t\t\t\tcontrolPoints,\n\t\t\t\t\t\t\t\t\t\t\tindex,\n\t\t\t\t\t\t\t\t\t\t\tclampPercent(\n\t\t\t\t\t\t\t\t\t\t\t\tpoint.position -\n\t\t\t\t\t\t\t\t\t\t\t\t\tKEYBOARD_CONTROL_POINT_VARIATION\n\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t} else if ( event.keyCode === RIGHT ) {\n\t\t\t\t\t\t\t\t\t// Stop propagation of the key press event to avoid focus moving\n\t\t\t\t\t\t\t\t\t// to another editor area.\n\t\t\t\t\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\t\t\t\t\tonChange(\n\t\t\t\t\t\t\t\t\t\tupdateControlPointPosition(\n\t\t\t\t\t\t\t\t\t\t\tcontrolPoints,\n\t\t\t\t\t\t\t\t\t\t\tindex,\n\t\t\t\t\t\t\t\t\t\t\tclampPercent(\n\t\t\t\t\t\t\t\t\t\t\t\tpoint.position +\n\t\t\t\t\t\t\t\t\t\t\t\t\tKEYBOARD_CONTROL_POINT_VARIATION\n\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tisOpen={ isOpen }\n\t\t\t\t\t\t\tposition={ point.position }\n\t\t\t\t\t\t\tcolor={ point.color }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\trenderContent={ ( { onClose } ) => (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<ColorPicker\n\t\t\t\t\t\t\t\tenableAlpha={ ! disableAlpha }\n\t\t\t\t\t\t\t\tcolor={ point.color }\n\t\t\t\t\t\t\t\tonChange={ ( color ) => {\n\t\t\t\t\t\t\t\t\tonChange(\n\t\t\t\t\t\t\t\t\t\tupdateControlPointColor(\n\t\t\t\t\t\t\t\t\t\t\tcontrolPoints,\n\t\t\t\t\t\t\t\t\t\t\tindex,\n\t\t\t\t\t\t\t\t\t\t\tcolord( color ).toRgbString()\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t{ ! disableRemove && controlPoints.length > 2 && (\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tclassName=\"components-custom-gradient-picker__remove-control-point\"\n\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\tonChange(\n\t\t\t\t\t\t\t\t\t\t\tremoveControlPoint(\n\t\t\t\t\t\t\t\t\t\t\t\tcontrolPoints,\n\t\t\t\t\t\t\t\t\t\t\t\tindex\n\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ __( 'Remove Control Point' ) }\n\t\t\t\t\t\t\t\t</Button>\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);\n\t} );\n}\n\nfunction InsertPoint( {\n\tvalue: controlPoints,\n\tonChange,\n\tonOpenInserter,\n\tonCloseInserter,\n\tinsertPosition,\n\tdisableAlpha,\n\t__experimentalIsRenderedInSidebar,\n\tgradientPickerDomRef,\n} ) {\n\tconst [ alreadyInsertedPoint, setAlreadyInsertedPoint ] = useState( false );\n\treturn (\n\t\t<GradientColorPickerDropdown\n\t\t\tgradientPickerDomRef={ gradientPickerDomRef }\n\t\t\tisRenderedInSidebar={ __experimentalIsRenderedInSidebar }\n\t\t\tclassName=\"components-custom-gradient-picker__inserter\"\n\t\t\tonClose={ () => {\n\t\t\t\tonCloseInserter();\n\t\t\t} }\n\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t<Button\n\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\taria-haspopup=\"true\"\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tif ( isOpen ) {\n\t\t\t\t\t\t\tonCloseInserter();\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tsetAlreadyInsertedPoint( false );\n\t\t\t\t\t\t\tonOpenInserter();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tonToggle();\n\t\t\t\t\t} }\n\t\t\t\t\tclassName=\"components-custom-gradient-picker__insert-point\"\n\t\t\t\t\ticon={ plus }\n\t\t\t\t\tstyle={ {\n\t\t\t\t\t\tleft:\n\t\t\t\t\t\t\tinsertPosition !== null\n\t\t\t\t\t\t\t\t? `${ insertPosition }%`\n\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\trenderContent={ () => (\n\t\t\t\t<ColorPicker\n\t\t\t\t\tenableAlpha={ ! disableAlpha }\n\t\t\t\t\tonChange={ ( color ) => {\n\t\t\t\t\t\tif ( ! alreadyInsertedPoint ) {\n\t\t\t\t\t\t\tonChange(\n\t\t\t\t\t\t\t\taddControlPoint(\n\t\t\t\t\t\t\t\t\tcontrolPoints,\n\t\t\t\t\t\t\t\t\tinsertPosition,\n\t\t\t\t\t\t\t\t\tcolord( color ).toRgbString()\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tsetAlreadyInsertedPoint( true );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tonChange(\n\t\t\t\t\t\t\t\tupdateControlPointColorByPosition(\n\t\t\t\t\t\t\t\t\tcontrolPoints,\n\t\t\t\t\t\t\t\t\tinsertPosition,\n\t\t\t\t\t\t\t\t\tcolord( color ).toRgbString()\n\t\t\t\t\t\t\t\t)\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/>\n\t);\n}\nControlPoints.InsertPoint = InsertPoint;\n\nexport default ControlPoints;\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/custom-gradient-bar/control-points.js"],"names":["classnames","colord","useInstanceId","useEffect","useRef","useState","useMemo","__","sprintf","plus","LEFT","RIGHT","Button","ColorPicker","VisuallyHidden","CustomColorPickerDropdown","addControlPoint","clampPercent","removeControlPoint","updateControlPointColor","updateControlPointColorByPosition","updateControlPointPosition","getHorizontalRelativeGradientPosition","MINIMUM_SIGNIFICANT_MOVE","KEYBOARD_CONTROL_POINT_VARIATION","ControlPointButton","isOpen","position","color","additionalProps","instanceId","descriptionId","left","transform","GradientColorPickerDropdown","isRenderedInSidebar","gradientPickerDomRef","props","popoverProps","result","className","anchorRef","current","ControlPoints","disableRemove","disableAlpha","ignoreMarkerPosition","value","controlPoints","onChange","onStartControlPointChange","onStopControlPointChange","__experimentalIsRenderedInSidebar","controlPointMoveState","onMouseMove","event","relativePosition","clientX","initialPosition","index","significantMoveHappened","Math","abs","cleanEventListeners","window","removeEventListener","listenersActivated","cleanEventListenersRef","map","point","onToggle","addEventListener","keyCode","stopPropagation","onClose","toRgbString","length","InsertPoint","onOpenInserter","onCloseInserter","insertPosition","alreadyInsertedPoint","setAlreadyInsertedPoint","undefined"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AACA,SAASC,MAAT,QAAuB,QAAvB;AAEA;AACA;AACA;;AACA,SAASC,aAAT,QAA8B,oBAA9B;AACA,SAASC,SAAT,EAAoBC,MAApB,EAA4BC,QAA5B,EAAsCC,OAAtC,QAAqD,oBAArD;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,IAAT,QAAqB,kBAArB;AACA,SAASC,IAAT,EAAeC,KAAf,QAA4B,qBAA5B;AAEA;AACA;AACA;;AACA,OAAOC,MAAP,MAAmB,WAAnB;AACA,SAASC,WAAT,QAA4B,iBAA5B;AACA,SAASC,cAAT,QAA+B,oBAA/B;AACA,SAASC,yBAAT,QAA0C,kBAA1C;AAEA,SACCC,eADD,EAECC,YAFD,EAGCC,kBAHD,EAICC,uBAJD,EAKCC,iCALD,EAMCC,0BAND,EAOCC,qCAPD,QAQO,SARP;AASA,SACCC,wBADD,EAECC,gCAFD,QAGO,aAHP;;AAKA,SAASC,kBAAT,OAA+E;AAAA,MAAlD;AAAEC,IAAAA,MAAF;AAAUC,IAAAA,QAAV;AAAoBC,IAAAA,KAApB;AAA2B,OAAGC;AAA9B,GAAkD;AAC9E,QAAMC,UAAU,GAAG5B,aAAa,CAAEuB,kBAAF,CAAhC;AACA,QAAMM,aAAa,GAAI,uEAAuED,UAAY,EAA1G;AACA,SACC,8BACC,cAAC,MAAD;AACC,kBAAatB,OAAO,EACnB;AACAD,IAAAA,EAAE,CACD,iEADC,CA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;AAAA,KAPhB;AAgCC,IAAA,aAAa,EAAG,MACf,cAAC,WAAD;AACC,MAAA,WAAW,EAAG,CAAEtC,YADjB;AAEC,MAAA,QAAQ,EAAKjB,KAAF,IAAa;AACvB,YAAK,CAAEqD,oBAAP,EAA8B;AAC7BhC,UAAAA,QAAQ,CACPjC,eAAe,CACdgC,aADc,EAEdgC,cAFc,EAGd/E,MAAM,CAAE2B,KAAF,CAAN,CAAgB+C,WAAhB,EAHc,CADR,CAAR;AAOAO,UAAAA,uBAAuB,CAAE,IAAF,CAAvB;AACA,SATD,MASO;AACNjC,UAAAA,QAAQ,CACP7B,iCAAiC,CAChC4B,aADgC,EAEhCgC,cAFgC,EAGhC/E,MAAM,CAAE2B,KAAF,CAAN,CAAgB+C,WAAhB,EAHgC,CAD1B,CAAR;AAOA;AACD;AArBF;AAjCF,IADD;AA4DA;;AACDhC,aAAa,CAACkC,WAAd,GAA4BA,WAA5B;AAEA,eAAelC,aAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport { colord } from 'colord';\n\n/**\n * WordPress dependencies\n */\nimport { useInstanceId } from '@wordpress/compose';\nimport { useEffect, useRef, useState, useMemo } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { plus } from '@wordpress/icons';\nimport { LEFT, RIGHT } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport Button from '../button';\nimport { ColorPicker } from '../color-picker';\nimport { VisuallyHidden } from '../visually-hidden';\nimport { CustomColorPickerDropdown } from '../color-palette';\n\nimport {\n\taddControlPoint,\n\tclampPercent,\n\tremoveControlPoint,\n\tupdateControlPointColor,\n\tupdateControlPointColorByPosition,\n\tupdateControlPointPosition,\n\tgetHorizontalRelativeGradientPosition,\n} from './utils';\nimport {\n\tMINIMUM_SIGNIFICANT_MOVE,\n\tKEYBOARD_CONTROL_POINT_VARIATION,\n} from './constants';\n\nfunction ControlPointButton( { isOpen, position, color, ...additionalProps } ) {\n\tconst instanceId = useInstanceId( ControlPointButton );\n\tconst descriptionId = `components-custom-gradient-picker__control-point-button-description-${ instanceId }`;\n\treturn (\n\t\t<>\n\t\t\t<Button\n\t\t\t\taria-label={ sprintf(\n\t\t\t\t\t// translators: %1$s: gradient position e.g: 70, %2$s: gradient color code e.g: rgb(52,121,151).\n\t\t\t\t\t__(\n\t\t\t\t\t\t'Gradient control point at position %1$s%% with color code %2$s.'\n\t\t\t\t\t),\n\t\t\t\t\tposition,\n\t\t\t\t\tcolor\n\t\t\t\t) }\n\t\t\t\taria-describedby={ descriptionId }\n\t\t\t\taria-haspopup=\"true\"\n\t\t\t\taria-expanded={ isOpen }\n\t\t\t\tclassName={ classnames(\n\t\t\t\t\t'components-custom-gradient-picker__control-point-button',\n\t\t\t\t\t{\n\t\t\t\t\t\t'is-active': isOpen,\n\t\t\t\t\t}\n\t\t\t\t) }\n\t\t\t\tstyle={ {\n\t\t\t\t\tleft: `${ position }%`,\n\t\t\t\t\ttransform: 'translateX( -50% )',\n\t\t\t\t} }\n\t\t\t\t{ ...additionalProps }\n\t\t\t/>\n\t\t\t<VisuallyHidden id={ descriptionId }>\n\t\t\t\t{ __(\n\t\t\t\t\t'Use your left or right arrow keys or drag and drop with the mouse to change the gradient position. Press the button to change the color or remove the control point.'\n\t\t\t\t) }\n\t\t\t</VisuallyHidden>\n\t\t</>\n\t);\n}\n\nfunction GradientColorPickerDropdown( {\n\tisRenderedInSidebar,\n\tgradientPickerDomRef,\n\t...props\n} ) {\n\tconst popoverProps = useMemo( () => {\n\t\tconst result = {\n\t\t\tclassName:\n\t\t\t\t'components-custom-gradient-picker__color-picker-popover',\n\t\t\tposition: 'top',\n\t\t};\n\t\tif ( isRenderedInSidebar ) {\n\t\t\tresult.anchorRef = gradientPickerDomRef.current;\n\t\t\tresult.position = 'bottom left';\n\t\t}\n\t\treturn result;\n\t}, [ gradientPickerDomRef, isRenderedInSidebar ] );\n\treturn (\n\t\t<CustomColorPickerDropdown\n\t\t\tisRenderedInSidebar={ isRenderedInSidebar }\n\t\t\tpopoverProps={ popoverProps }\n\t\t\t{ ...props }\n\t\t/>\n\t);\n}\n\nfunction ControlPoints( {\n\tdisableRemove,\n\tdisableAlpha,\n\tgradientPickerDomRef,\n\tignoreMarkerPosition,\n\tvalue: controlPoints,\n\tonChange,\n\tonStartControlPointChange,\n\tonStopControlPointChange,\n\t__experimentalIsRenderedInSidebar,\n} ) {\n\tconst controlPointMoveState = useRef();\n\n\tconst onMouseMove = ( event ) => {\n\t\tconst relativePosition = getHorizontalRelativeGradientPosition(\n\t\t\tevent.clientX,\n\t\t\tgradientPickerDomRef.current\n\t\t);\n\t\tconst { initialPosition, index, significantMoveHappened } =\n\t\t\tcontrolPointMoveState.current;\n\t\tif (\n\t\t\t! significantMoveHappened &&\n\t\t\tMath.abs( initialPosition - relativePosition ) >=\n\t\t\t\tMINIMUM_SIGNIFICANT_MOVE\n\t\t) {\n\t\t\tcontrolPointMoveState.current.significantMoveHappened = true;\n\t\t}\n\n\t\tonChange(\n\t\t\tupdateControlPointPosition( controlPoints, index, relativePosition )\n\t\t);\n\t};\n\n\tconst cleanEventListeners = () => {\n\t\tif (\n\t\t\twindow &&\n\t\t\twindow.removeEventListener &&\n\t\t\tcontrolPointMoveState.current &&\n\t\t\tcontrolPointMoveState.current.listenersActivated\n\t\t) {\n\t\t\twindow.removeEventListener( 'mousemove', onMouseMove );\n\t\t\twindow.removeEventListener( 'mouseup', cleanEventListeners );\n\t\t\tonStopControlPointChange();\n\t\t\tcontrolPointMoveState.current.listenersActivated = false;\n\t\t}\n\t};\n\n\t// Adding `cleanEventListeners` to the dependency array below requires the function itself to be wrapped in a `useCallback`\n\t// This memoization would prevent the event listeners from being properly cleaned.\n\t// Instead, we'll pass a ref to the function in our `useEffect` so `cleanEventListeners` itself is no longer a dependency.\n\tconst cleanEventListenersRef = useRef();\n\tcleanEventListenersRef.current = cleanEventListeners;\n\n\tuseEffect( () => {\n\t\treturn () => {\n\t\t\tcleanEventListenersRef.current();\n\t\t};\n\t}, [] );\n\n\treturn controlPoints.map( ( point, index ) => {\n\t\tconst initialPosition = point?.position;\n\t\treturn (\n\t\t\tignoreMarkerPosition !== initialPosition && (\n\t\t\t\t<GradientColorPickerDropdown\n\t\t\t\t\tgradientPickerDomRef={ gradientPickerDomRef }\n\t\t\t\t\tisRenderedInSidebar={ __experimentalIsRenderedInSidebar }\n\t\t\t\t\tkey={ index }\n\t\t\t\t\tonClose={ onStopControlPointChange }\n\t\t\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t\t\t<ControlPointButton\n\t\t\t\t\t\t\tkey={ index }\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\tcontrolPointMoveState.current &&\n\t\t\t\t\t\t\t\t\tcontrolPointMoveState.current\n\t\t\t\t\t\t\t\t\t\t.significantMoveHappened\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif ( isOpen ) {\n\t\t\t\t\t\t\t\t\tonStopControlPointChange();\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tonStartControlPointChange();\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tonToggle();\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tonMouseDown={ () => {\n\t\t\t\t\t\t\t\tif ( window && window.addEventListener ) {\n\t\t\t\t\t\t\t\t\tcontrolPointMoveState.current = {\n\t\t\t\t\t\t\t\t\t\tinitialPosition,\n\t\t\t\t\t\t\t\t\t\tindex,\n\t\t\t\t\t\t\t\t\t\tsignificantMoveHappened: false,\n\t\t\t\t\t\t\t\t\t\tlistenersActivated: true,\n\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\tonStartControlPointChange();\n\t\t\t\t\t\t\t\t\twindow.addEventListener(\n\t\t\t\t\t\t\t\t\t\t'mousemove',\n\t\t\t\t\t\t\t\t\t\tonMouseMove\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\twindow.addEventListener(\n\t\t\t\t\t\t\t\t\t\t'mouseup',\n\t\t\t\t\t\t\t\t\t\tcleanEventListeners\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tonKeyDown={ ( event ) => {\n\t\t\t\t\t\t\t\tif ( event.keyCode === LEFT ) {\n\t\t\t\t\t\t\t\t\t// Stop propagation of the key press event to avoid focus moving\n\t\t\t\t\t\t\t\t\t// to another editor area.\n\t\t\t\t\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\t\t\t\t\tonChange(\n\t\t\t\t\t\t\t\t\t\tupdateControlPointPosition(\n\t\t\t\t\t\t\t\t\t\t\tcontrolPoints,\n\t\t\t\t\t\t\t\t\t\t\tindex,\n\t\t\t\t\t\t\t\t\t\t\tclampPercent(\n\t\t\t\t\t\t\t\t\t\t\t\tpoint.position -\n\t\t\t\t\t\t\t\t\t\t\t\t\tKEYBOARD_CONTROL_POINT_VARIATION\n\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t} else if ( event.keyCode === RIGHT ) {\n\t\t\t\t\t\t\t\t\t// Stop propagation of the key press event to avoid focus moving\n\t\t\t\t\t\t\t\t\t// to another editor area.\n\t\t\t\t\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\t\t\t\t\tonChange(\n\t\t\t\t\t\t\t\t\t\tupdateControlPointPosition(\n\t\t\t\t\t\t\t\t\t\t\tcontrolPoints,\n\t\t\t\t\t\t\t\t\t\t\tindex,\n\t\t\t\t\t\t\t\t\t\t\tclampPercent(\n\t\t\t\t\t\t\t\t\t\t\t\tpoint.position +\n\t\t\t\t\t\t\t\t\t\t\t\t\tKEYBOARD_CONTROL_POINT_VARIATION\n\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tisOpen={ isOpen }\n\t\t\t\t\t\t\tposition={ point.position }\n\t\t\t\t\t\t\tcolor={ point.color }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\trenderContent={ ( { onClose } ) => (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<ColorPicker\n\t\t\t\t\t\t\t\tenableAlpha={ ! disableAlpha }\n\t\t\t\t\t\t\t\tcolor={ point.color }\n\t\t\t\t\t\t\t\tonChange={ ( color ) => {\n\t\t\t\t\t\t\t\t\tonChange(\n\t\t\t\t\t\t\t\t\t\tupdateControlPointColor(\n\t\t\t\t\t\t\t\t\t\t\tcontrolPoints,\n\t\t\t\t\t\t\t\t\t\t\tindex,\n\t\t\t\t\t\t\t\t\t\t\tcolord( color ).toRgbString()\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t{ ! disableRemove && controlPoints.length > 2 && (\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tclassName=\"components-custom-gradient-picker__remove-control-point\"\n\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\tonChange(\n\t\t\t\t\t\t\t\t\t\t\tremoveControlPoint(\n\t\t\t\t\t\t\t\t\t\t\t\tcontrolPoints,\n\t\t\t\t\t\t\t\t\t\t\t\tindex\n\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ __( 'Remove Control Point' ) }\n\t\t\t\t\t\t\t\t</Button>\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);\n\t} );\n}\n\nfunction InsertPoint( {\n\tvalue: controlPoints,\n\tonChange,\n\tonOpenInserter,\n\tonCloseInserter,\n\tinsertPosition,\n\tdisableAlpha,\n\t__experimentalIsRenderedInSidebar,\n\tgradientPickerDomRef,\n} ) {\n\tconst [ alreadyInsertedPoint, setAlreadyInsertedPoint ] = useState( false );\n\treturn (\n\t\t<GradientColorPickerDropdown\n\t\t\tgradientPickerDomRef={ gradientPickerDomRef }\n\t\t\tisRenderedInSidebar={ __experimentalIsRenderedInSidebar }\n\t\t\tclassName=\"components-custom-gradient-picker__inserter\"\n\t\t\tonClose={ () => {\n\t\t\t\tonCloseInserter();\n\t\t\t} }\n\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t<Button\n\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\taria-haspopup=\"true\"\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tif ( isOpen ) {\n\t\t\t\t\t\t\tonCloseInserter();\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tsetAlreadyInsertedPoint( false );\n\t\t\t\t\t\t\tonOpenInserter();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tonToggle();\n\t\t\t\t\t} }\n\t\t\t\t\tclassName=\"components-custom-gradient-picker__insert-point\"\n\t\t\t\t\ticon={ plus }\n\t\t\t\t\tstyle={\n\t\t\t\t\t\tinsertPosition !== null\n\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\tleft: `${ insertPosition }%`,\n\t\t\t\t\t\t\t\t\ttransform: 'translateX( -50% )',\n\t\t\t\t\t\t\t }\n\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t) }\n\t\t\trenderContent={ () => (\n\t\t\t\t<ColorPicker\n\t\t\t\t\tenableAlpha={ ! disableAlpha }\n\t\t\t\t\tonChange={ ( color ) => {\n\t\t\t\t\t\tif ( ! alreadyInsertedPoint ) {\n\t\t\t\t\t\t\tonChange(\n\t\t\t\t\t\t\t\taddControlPoint(\n\t\t\t\t\t\t\t\t\tcontrolPoints,\n\t\t\t\t\t\t\t\t\tinsertPosition,\n\t\t\t\t\t\t\t\t\tcolord( color ).toRgbString()\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tsetAlreadyInsertedPoint( true );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tonChange(\n\t\t\t\t\t\t\t\tupdateControlPointColorByPosition(\n\t\t\t\t\t\t\t\t\tcontrolPoints,\n\t\t\t\t\t\t\t\t\tinsertPosition,\n\t\t\t\t\t\t\t\t\tcolord( color ).toRgbString()\n\t\t\t\t\t\t\t\t)\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/>\n\t);\n}\nControlPoints.InsertPoint = InsertPoint;\n\nexport default ControlPoints;\n"]}
@@ -16,7 +16,7 @@ import { useRef, useReducer } from '@wordpress/element';
16
16
 
17
17
  import ControlPoints from './control-points';
18
18
  import { getHorizontalRelativeGradientPosition } from './utils';
19
- import { INSERT_POINT_WIDTH, MINIMUM_DISTANCE_BETWEEN_INSERTER_AND_POINT } from './constants';
19
+ import { MINIMUM_DISTANCE_BETWEEN_INSERTER_AND_POINT } from './constants';
20
20
 
21
21
  function customGradientBarReducer(state, action) {
22
22
  switch (action.type) {
@@ -93,11 +93,11 @@ export default function CustomGradientBar(_ref) {
93
93
  disableAlpha = false,
94
94
  __experimentalIsRenderedInSidebar
95
95
  } = _ref;
96
- const gradientPickerDomRef = useRef();
96
+ const gradientMarkersContainerDomRef = useRef();
97
97
  const [gradientBarState, gradientBarStateDispatch] = useReducer(customGradientBarReducer, customGradientBarReducerInitialState);
98
98
 
99
99
  const onMouseEnterAndMove = event => {
100
- const insertPosition = getHorizontalRelativeGradientPosition(event.clientX, gradientPickerDomRef.current, INSERT_POINT_WIDTH); // If the insert point is close to an existing control point don't show it.
100
+ const insertPosition = getHorizontalRelativeGradientPosition(event.clientX, gradientMarkersContainerDomRef.current); // If the insert point is close to an existing control point don't show it.
101
101
 
102
102
  if (some(controlPoints, _ref2 => {
103
103
  let {
@@ -129,7 +129,6 @@ export default function CustomGradientBar(_ref) {
129
129
  const isMovingInserter = gradientBarState.id === 'MOVING_INSERTER';
130
130
  const isInsertingControlPoint = gradientBarState.id === 'INSERTING_CONTROL_POINT';
131
131
  return createElement("div", {
132
- ref: gradientPickerDomRef,
133
132
  className: classnames('components-custom-gradient-picker__gradient-bar', {
134
133
  'has-gradient': hasGradient
135
134
  }),
@@ -140,10 +139,11 @@ export default function CustomGradientBar(_ref) {
140
139
  },
141
140
  onMouseLeave: onMouseLeave
142
141
  }, createElement("div", {
142
+ ref: gradientMarkersContainerDomRef,
143
143
  className: "components-custom-gradient-picker__markers-container"
144
144
  }, !disableInserter && (isMovingInserter || isInsertingControlPoint) && createElement(ControlPoints.InsertPoint, {
145
145
  __experimentalIsRenderedInSidebar: __experimentalIsRenderedInSidebar,
146
- gradientPickerDomRef: gradientPickerDomRef,
146
+ gradientPickerDomRef: gradientMarkersContainerDomRef,
147
147
  disableAlpha: disableAlpha,
148
148
  insertPosition: gradientBarState.insertPosition,
149
149
  value: controlPoints,
@@ -162,7 +162,7 @@ export default function CustomGradientBar(_ref) {
162
162
  __experimentalIsRenderedInSidebar: __experimentalIsRenderedInSidebar,
163
163
  disableAlpha: disableAlpha,
164
164
  disableRemove: disableInserter,
165
- gradientPickerDomRef: gradientPickerDomRef,
165
+ gradientPickerDomRef: gradientMarkersContainerDomRef,
166
166
  ignoreMarkerPosition: isInsertingControlPoint ? gradientBarState.insertPosition : undefined,
167
167
  value: controlPoints,
168
168
  onChange: onChange,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/custom-gradient-bar/index.js"],"names":["some","classnames","useRef","useReducer","ControlPoints","getHorizontalRelativeGradientPosition","INSERT_POINT_WIDTH","MINIMUM_DISTANCE_BETWEEN_INSERTER_AND_POINT","customGradientBarReducer","state","action","type","id","insertPosition","customGradientBarReducerInitialState","CustomGradientBar","background","hasGradient","value","controlPoints","onChange","disableInserter","disableAlpha","__experimentalIsRenderedInSidebar","gradientPickerDomRef","gradientBarState","gradientBarStateDispatch","onMouseEnterAndMove","event","clientX","current","position","Math","abs","onMouseLeave","isMovingInserter","isInsertingControlPoint","undefined"],"mappings":";;AAAA;AACA;AACA;AAEA,SAASA,IAAT,QAAqB,QAArB;AACA,OAAOC,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,MAAT,EAAiBC,UAAjB,QAAmC,oBAAnC;AAEA;AACA;AACA;;AACA,OAAOC,aAAP,MAA0B,kBAA1B;AACA,SAASC,qCAAT,QAAsD,SAAtD;AACA,SACCC,kBADD,EAECC,2CAFD,QAGO,aAHP;;AAKA,SAASC,wBAAT,CAAmCC,KAAnC,EAA0CC,MAA1C,EAAmD;AAClD,UAASA,MAAM,CAACC,IAAhB;AACC,SAAK,eAAL;AACC,UAAKF,KAAK,CAACG,EAAN,KAAa,MAAb,IAAuBH,KAAK,CAACG,EAAN,KAAa,iBAAzC,EAA6D;AAC5D,eAAO;AACNA,UAAAA,EAAE,EAAE,iBADE;AAENC,UAAAA,cAAc,EAAEH,MAAM,CAACG;AAFjB,SAAP;AAIA;;AACD;;AACD,SAAK,oBAAL;AACC,UAAKJ,KAAK,CAACG,EAAN,KAAa,iBAAlB,EAAsC;AACrC,eAAO;AACNA,UAAAA,EAAE,EAAE;AADE,SAAP;AAGA;;AACD;;AACD,SAAK,eAAL;AACC,UAAKH,KAAK,CAACG,EAAN,KAAa,iBAAlB,EAAsC;AACrC,eAAO;AACNA,UAAAA,EAAE,EAAE,yBADE;AAENC,UAAAA,cAAc,EAAEJ,KAAK,CAACI;AAFhB,S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,OAAF,CAAxB;AAGA,KAbF;AAcC,IAAA,eAAe,EAAG,MAAM;AACvBe,MAAAA,wBAAwB,CAAE;AACzBf,QAAAA,IAAI,EAAE;AADmB,OAAF,CAAxB;AAGA;AAlBF,IAHH,EAwBC,cAAC,aAAD;AACC,IAAA,iCAAiC,EAChCY,iCAFF;AAIC,IAAA,YAAY,EAAGD,YAJhB;AAKC,IAAA,aAAa,EAAGD,eALjB;AAMC,IAAA,oBAAoB,EAAGG,oBANxB;AAOC,IAAA,oBAAoB,EACnBY,uBAAuB,GACpBX,gBAAgB,CAACZ,cADG,GAEpBwB,SAVL;AAYC,IAAA,KAAK,EAAGlB,aAZT;AAaC,IAAA,QAAQ,EAAGC,QAbZ;AAcC,IAAA,yBAAyB,EAAG,MAAM;AACjCM,MAAAA,wBAAwB,CAAE;AACzBf,QAAAA,IAAI,EAAE;AADmB,OAAF,CAAxB;AAGA,KAlBF;AAmBC,IAAA,wBAAwB,EAAG,MAAM;AAChCe,MAAAA,wBAAwB,CAAE;AACzBf,QAAAA,IAAI,EAAE;AADmB,OAAF,CAAxB;AAGA;AAvBF,IAxBD,CAXD,CADD;AAgEA","sourcesContent":["/**\n * External dependencies\n */\n\nimport { some } from 'lodash';\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useRef, useReducer } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport ControlPoints from './control-points';\nimport { getHorizontalRelativeGradientPosition } from './utils';\nimport {\n\tINSERT_POINT_WIDTH,\n\tMINIMUM_DISTANCE_BETWEEN_INSERTER_AND_POINT,\n} from './constants';\n\nfunction customGradientBarReducer( state, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'MOVE_INSERTER':\n\t\t\tif ( state.id === 'IDLE' || state.id === 'MOVING_INSERTER' ) {\n\t\t\t\treturn {\n\t\t\t\t\tid: 'MOVING_INSERTER',\n\t\t\t\t\tinsertPosition: action.insertPosition,\n\t\t\t\t};\n\t\t\t}\n\t\t\tbreak;\n\t\tcase 'STOP_INSERTER_MOVE':\n\t\t\tif ( state.id === 'MOVING_INSERTER' ) {\n\t\t\t\treturn {\n\t\t\t\t\tid: 'IDLE',\n\t\t\t\t};\n\t\t\t}\n\t\t\tbreak;\n\t\tcase 'OPEN_INSERTER':\n\t\t\tif ( state.id === 'MOVING_INSERTER' ) {\n\t\t\t\treturn {\n\t\t\t\t\tid: 'INSERTING_CONTROL_POINT',\n\t\t\t\t\tinsertPosition: state.insertPosition,\n\t\t\t\t};\n\t\t\t}\n\t\t\tbreak;\n\t\tcase 'CLOSE_INSERTER':\n\t\t\tif ( state.id === 'INSERTING_CONTROL_POINT' ) {\n\t\t\t\treturn {\n\t\t\t\t\tid: 'IDLE',\n\t\t\t\t};\n\t\t\t}\n\t\t\tbreak;\n\t\tcase 'START_CONTROL_CHANGE':\n\t\t\tif ( state.id === 'IDLE' ) {\n\t\t\t\treturn {\n\t\t\t\t\tid: 'MOVING_CONTROL_POINT',\n\t\t\t\t};\n\t\t\t}\n\t\t\tbreak;\n\t\tcase 'STOP_CONTROL_CHANGE':\n\t\t\tif ( state.id === 'MOVING_CONTROL_POINT' ) {\n\t\t\t\treturn {\n\t\t\t\t\tid: 'IDLE',\n\t\t\t\t};\n\t\t\t}\n\t\t\tbreak;\n\t}\n\treturn state;\n}\nconst customGradientBarReducerInitialState = { id: 'IDLE' };\n\nexport default function CustomGradientBar( {\n\tbackground,\n\thasGradient,\n\tvalue: controlPoints,\n\tonChange,\n\tdisableInserter = false,\n\tdisableAlpha = false,\n\t__experimentalIsRenderedInSidebar,\n} ) {\n\tconst gradientPickerDomRef = useRef();\n\n\tconst [ gradientBarState, gradientBarStateDispatch ] = useReducer(\n\t\tcustomGradientBarReducer,\n\t\tcustomGradientBarReducerInitialState\n\t);\n\tconst onMouseEnterAndMove = ( event ) => {\n\t\tconst insertPosition = getHorizontalRelativeGradientPosition(\n\t\t\tevent.clientX,\n\t\t\tgradientPickerDomRef.current,\n\t\t\tINSERT_POINT_WIDTH\n\t\t);\n\n\t\t// If the insert point is close to an existing control point don't show it.\n\t\tif (\n\t\t\tsome( controlPoints, ( { position } ) => {\n\t\t\t\treturn (\n\t\t\t\t\tMath.abs( insertPosition - position ) <\n\t\t\t\t\tMINIMUM_DISTANCE_BETWEEN_INSERTER_AND_POINT\n\t\t\t\t);\n\t\t\t} )\n\t\t) {\n\t\t\tif ( gradientBarState.id === 'MOVING_INSERTER' ) {\n\t\t\t\tgradientBarStateDispatch( { type: 'STOP_INSERTER_MOVE' } );\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tgradientBarStateDispatch( { type: 'MOVE_INSERTER', insertPosition } );\n\t};\n\n\tconst onMouseLeave = () => {\n\t\tgradientBarStateDispatch( { type: 'STOP_INSERTER_MOVE' } );\n\t};\n\n\tconst isMovingInserter = gradientBarState.id === 'MOVING_INSERTER';\n\tconst isInsertingControlPoint =\n\t\tgradientBarState.id === 'INSERTING_CONTROL_POINT';\n\n\treturn (\n\t\t<div\n\t\t\tref={ gradientPickerDomRef }\n\t\t\tclassName={ classnames(\n\t\t\t\t'components-custom-gradient-picker__gradient-bar',\n\t\t\t\t{ 'has-gradient': hasGradient }\n\t\t\t) }\n\t\t\tonMouseEnter={ onMouseEnterAndMove }\n\t\t\tonMouseMove={ onMouseEnterAndMove }\n\t\t\tstyle={ { background } }\n\t\t\tonMouseLeave={ onMouseLeave }\n\t\t>\n\t\t\t<div className=\"components-custom-gradient-picker__markers-container\">\n\t\t\t\t{ ! disableInserter &&\n\t\t\t\t\t( isMovingInserter || isInsertingControlPoint ) && (\n\t\t\t\t\t\t<ControlPoints.InsertPoint\n\t\t\t\t\t\t\t__experimentalIsRenderedInSidebar={\n\t\t\t\t\t\t\t\t__experimentalIsRenderedInSidebar\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tgradientPickerDomRef={ gradientPickerDomRef }\n\t\t\t\t\t\t\tdisableAlpha={ disableAlpha }\n\t\t\t\t\t\t\tinsertPosition={ gradientBarState.insertPosition }\n\t\t\t\t\t\t\tvalue={ controlPoints }\n\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\tonOpenInserter={ () => {\n\t\t\t\t\t\t\t\tgradientBarStateDispatch( {\n\t\t\t\t\t\t\t\t\ttype: 'OPEN_INSERTER',\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tonCloseInserter={ () => {\n\t\t\t\t\t\t\t\tgradientBarStateDispatch( {\n\t\t\t\t\t\t\t\t\ttype: 'CLOSE_INSERTER',\n\t\t\t\t\t\t\t\t} );\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<ControlPoints\n\t\t\t\t\t__experimentalIsRenderedInSidebar={\n\t\t\t\t\t\t__experimentalIsRenderedInSidebar\n\t\t\t\t\t}\n\t\t\t\t\tdisableAlpha={ disableAlpha }\n\t\t\t\t\tdisableRemove={ disableInserter }\n\t\t\t\t\tgradientPickerDomRef={ gradientPickerDomRef }\n\t\t\t\t\tignoreMarkerPosition={\n\t\t\t\t\t\tisInsertingControlPoint\n\t\t\t\t\t\t\t? gradientBarState.insertPosition\n\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t}\n\t\t\t\t\tvalue={ controlPoints }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\tonStartControlPointChange={ () => {\n\t\t\t\t\t\tgradientBarStateDispatch( {\n\t\t\t\t\t\t\ttype: 'START_CONTROL_CHANGE',\n\t\t\t\t\t\t} );\n\t\t\t\t\t} }\n\t\t\t\t\tonStopControlPointChange={ () => {\n\t\t\t\t\t\tgradientBarStateDispatch( {\n\t\t\t\t\t\t\ttype: 'STOP_CONTROL_CHANGE',\n\t\t\t\t\t\t} );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/custom-gradient-bar/index.js"],"names":["some","classnames","useRef","useReducer","ControlPoints","getHorizontalRelativeGradientPosition","MINIMUM_DISTANCE_BETWEEN_INSERTER_AND_POINT","customGradientBarReducer","state","action","type","id","insertPosition","customGradientBarReducerInitialState","CustomGradientBar","background","hasGradient","value","controlPoints","onChange","disableInserter","disableAlpha","__experimentalIsRenderedInSidebar","gradientMarkersContainerDomRef","gradientBarState","gradientBarStateDispatch","onMouseEnterAndMove","event","clientX","current","position","Math","abs","onMouseLeave","isMovingInserter","isInsertingControlPoint","undefined"],"mappings":";;AAAA;AACA;AACA;AAEA,SAASA,IAAT,QAAqB,QAArB;AACA,OAAOC,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,MAAT,EAAiBC,UAAjB,QAAmC,oBAAnC;AAEA;AACA;AACA;;AACA,OAAOC,aAAP,MAA0B,kBAA1B;AACA,SAASC,qCAAT,QAAsD,SAAtD;AACA,SAASC,2CAAT,QAA4D,aAA5D;;AAEA,SAASC,wBAAT,CAAmCC,KAAnC,EAA0CC,MAA1C,EAAmD;AAClD,UAASA,MAAM,CAACC,IAAhB;AACC,SAAK,eAAL;AACC,UAAKF,KAAK,CAACG,EAAN,KAAa,MAAb,IAAuBH,KAAK,CAACG,EAAN,KAAa,iBAAzC,EAA6D;AAC5D,eAAO;AACNA,UAAAA,EAAE,EAAE,iBADE;AAENC,UAAAA,cAAc,EAAEH,MAAM,CAACG;AAFjB,SAAP;AAIA;;AACD;;AACD,SAAK,oBAAL;AACC,UAAKJ,KAAK,CAACG,EAAN,KAAa,iBAAlB,EAAsC;AACrC,eAAO;AACNA,UAAAA,EAAE,EAAE;AADE,SAAP;AAGA;;AACD;;AACD,SAAK,eAAL;AACC,UAAKH,KAAK,CAACG,EAAN,KAAa,iBAAlB,EAAsC;AACrC,eAAO;AACNA,UAAAA,EAAE,EAAE,yBADE;AAENC,UAAAA,cAAc,EAAEJ,KAAK,CAACI;AAFhB,SAAP;AAIA;;AACD;;AACD,SAAK,gBAAL;AACC,UAAKJ,KAAK,CAACG,EAA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E;AACzBf,QAAAA,IAAI,EAAE;AADmB,OAAF,CAAxB;AAGA;AApBF,IANH,EA6BC,cAAC,aAAD;AACC,IAAA,iCAAiC,EAChCY,iCAFF;AAIC,IAAA,YAAY,EAAGD,YAJhB;AAKC,IAAA,aAAa,EAAGD,eALjB;AAMC,IAAA,oBAAoB,EAAGG,8BANxB;AAOC,IAAA,oBAAoB,EACnBY,uBAAuB,GACpBX,gBAAgB,CAACZ,cADG,GAEpBwB,SAVL;AAYC,IAAA,KAAK,EAAGlB,aAZT;AAaC,IAAA,QAAQ,EAAGC,QAbZ;AAcC,IAAA,yBAAyB,EAAG,MAAM;AACjCM,MAAAA,wBAAwB,CAAE;AACzBf,QAAAA,IAAI,EAAE;AADmB,OAAF,CAAxB;AAGA,KAlBF;AAmBC,IAAA,wBAAwB,EAAG,MAAM;AAChCe,MAAAA,wBAAwB,CAAE;AACzBf,QAAAA,IAAI,EAAE;AADmB,OAAF,CAAxB;AAGA;AAvBF,IA7BD,CAVD,CADD;AAoEA","sourcesContent":["/**\n * External dependencies\n */\n\nimport { some } from 'lodash';\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useRef, useReducer } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport ControlPoints from './control-points';\nimport { getHorizontalRelativeGradientPosition } from './utils';\nimport { MINIMUM_DISTANCE_BETWEEN_INSERTER_AND_POINT } from './constants';\n\nfunction customGradientBarReducer( state, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'MOVE_INSERTER':\n\t\t\tif ( state.id === 'IDLE' || state.id === 'MOVING_INSERTER' ) {\n\t\t\t\treturn {\n\t\t\t\t\tid: 'MOVING_INSERTER',\n\t\t\t\t\tinsertPosition: action.insertPosition,\n\t\t\t\t};\n\t\t\t}\n\t\t\tbreak;\n\t\tcase 'STOP_INSERTER_MOVE':\n\t\t\tif ( state.id === 'MOVING_INSERTER' ) {\n\t\t\t\treturn {\n\t\t\t\t\tid: 'IDLE',\n\t\t\t\t};\n\t\t\t}\n\t\t\tbreak;\n\t\tcase 'OPEN_INSERTER':\n\t\t\tif ( state.id === 'MOVING_INSERTER' ) {\n\t\t\t\treturn {\n\t\t\t\t\tid: 'INSERTING_CONTROL_POINT',\n\t\t\t\t\tinsertPosition: state.insertPosition,\n\t\t\t\t};\n\t\t\t}\n\t\t\tbreak;\n\t\tcase 'CLOSE_INSERTER':\n\t\t\tif ( state.id === 'INSERTING_CONTROL_POINT' ) {\n\t\t\t\treturn {\n\t\t\t\t\tid: 'IDLE',\n\t\t\t\t};\n\t\t\t}\n\t\t\tbreak;\n\t\tcase 'START_CONTROL_CHANGE':\n\t\t\tif ( state.id === 'IDLE' ) {\n\t\t\t\treturn {\n\t\t\t\t\tid: 'MOVING_CONTROL_POINT',\n\t\t\t\t};\n\t\t\t}\n\t\t\tbreak;\n\t\tcase 'STOP_CONTROL_CHANGE':\n\t\t\tif ( state.id === 'MOVING_CONTROL_POINT' ) {\n\t\t\t\treturn {\n\t\t\t\t\tid: 'IDLE',\n\t\t\t\t};\n\t\t\t}\n\t\t\tbreak;\n\t}\n\treturn state;\n}\nconst customGradientBarReducerInitialState = { id: 'IDLE' };\n\nexport default function CustomGradientBar( {\n\tbackground,\n\thasGradient,\n\tvalue: controlPoints,\n\tonChange,\n\tdisableInserter = false,\n\tdisableAlpha = false,\n\t__experimentalIsRenderedInSidebar,\n} ) {\n\tconst gradientMarkersContainerDomRef = useRef();\n\n\tconst [ gradientBarState, gradientBarStateDispatch ] = useReducer(\n\t\tcustomGradientBarReducer,\n\t\tcustomGradientBarReducerInitialState\n\t);\n\tconst onMouseEnterAndMove = ( event ) => {\n\t\tconst insertPosition = getHorizontalRelativeGradientPosition(\n\t\t\tevent.clientX,\n\t\t\tgradientMarkersContainerDomRef.current\n\t\t);\n\n\t\t// If the insert point is close to an existing control point don't show it.\n\t\tif (\n\t\t\tsome( controlPoints, ( { position } ) => {\n\t\t\t\treturn (\n\t\t\t\t\tMath.abs( insertPosition - position ) <\n\t\t\t\t\tMINIMUM_DISTANCE_BETWEEN_INSERTER_AND_POINT\n\t\t\t\t);\n\t\t\t} )\n\t\t) {\n\t\t\tif ( gradientBarState.id === 'MOVING_INSERTER' ) {\n\t\t\t\tgradientBarStateDispatch( { type: 'STOP_INSERTER_MOVE' } );\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tgradientBarStateDispatch( { type: 'MOVE_INSERTER', insertPosition } );\n\t};\n\n\tconst onMouseLeave = () => {\n\t\tgradientBarStateDispatch( { type: 'STOP_INSERTER_MOVE' } );\n\t};\n\n\tconst isMovingInserter = gradientBarState.id === 'MOVING_INSERTER';\n\tconst isInsertingControlPoint =\n\t\tgradientBarState.id === 'INSERTING_CONTROL_POINT';\n\n\treturn (\n\t\t<div\n\t\t\tclassName={ classnames(\n\t\t\t\t'components-custom-gradient-picker__gradient-bar',\n\t\t\t\t{ 'has-gradient': hasGradient }\n\t\t\t) }\n\t\t\tonMouseEnter={ onMouseEnterAndMove }\n\t\t\tonMouseMove={ onMouseEnterAndMove }\n\t\t\tstyle={ { background } }\n\t\t\tonMouseLeave={ onMouseLeave }\n\t\t>\n\t\t\t<div\n\t\t\t\tref={ gradientMarkersContainerDomRef }\n\t\t\t\tclassName=\"components-custom-gradient-picker__markers-container\"\n\t\t\t>\n\t\t\t\t{ ! disableInserter &&\n\t\t\t\t\t( isMovingInserter || isInsertingControlPoint ) && (\n\t\t\t\t\t\t<ControlPoints.InsertPoint\n\t\t\t\t\t\t\t__experimentalIsRenderedInSidebar={\n\t\t\t\t\t\t\t\t__experimentalIsRenderedInSidebar\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tgradientPickerDomRef={\n\t\t\t\t\t\t\t\tgradientMarkersContainerDomRef\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tdisableAlpha={ disableAlpha }\n\t\t\t\t\t\t\tinsertPosition={ gradientBarState.insertPosition }\n\t\t\t\t\t\t\tvalue={ controlPoints }\n\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\tonOpenInserter={ () => {\n\t\t\t\t\t\t\t\tgradientBarStateDispatch( {\n\t\t\t\t\t\t\t\t\ttype: 'OPEN_INSERTER',\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tonCloseInserter={ () => {\n\t\t\t\t\t\t\t\tgradientBarStateDispatch( {\n\t\t\t\t\t\t\t\t\ttype: 'CLOSE_INSERTER',\n\t\t\t\t\t\t\t\t} );\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<ControlPoints\n\t\t\t\t\t__experimentalIsRenderedInSidebar={\n\t\t\t\t\t\t__experimentalIsRenderedInSidebar\n\t\t\t\t\t}\n\t\t\t\t\tdisableAlpha={ disableAlpha }\n\t\t\t\t\tdisableRemove={ disableInserter }\n\t\t\t\t\tgradientPickerDomRef={ gradientMarkersContainerDomRef }\n\t\t\t\t\tignoreMarkerPosition={\n\t\t\t\t\t\tisInsertingControlPoint\n\t\t\t\t\t\t\t? gradientBarState.insertPosition\n\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t}\n\t\t\t\t\tvalue={ controlPoints }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\tonStartControlPointChange={ () => {\n\t\t\t\t\t\tgradientBarStateDispatch( {\n\t\t\t\t\t\t\ttype: 'START_CONTROL_CHANGE',\n\t\t\t\t\t\t} );\n\t\t\t\t\t} }\n\t\t\t\t\tonStopControlPointChange={ () => {\n\t\t\t\t\t\tgradientBarStateDispatch( {\n\t\t\t\t\t\t\ttype: 'STOP_CONTROL_CHANGE',\n\t\t\t\t\t\t} );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Internal dependencies
3
3
  */
4
- import { MINIMUM_DISTANCE_BETWEEN_POINTS, MINIMUM_ABSOLUTE_LEFT_POSITION, INSERT_POINT_WIDTH } from './constants';
4
+ import { MINIMUM_DISTANCE_BETWEEN_POINTS } from './constants';
5
5
  /**
6
6
  * Control point for the gradient bar.
7
7
  *
@@ -156,14 +156,13 @@ export function updateControlPointColorByPosition(points, position, newColor) {
156
156
  /**
157
157
  * Gets the horizontal coordinate when dragging a control point with the mouse.
158
158
  *
159
- * @param {number} mouseXCoordinate Horizontal coordinate of the mouse position.
160
- * @param {Element} containerElement Container for the gradient picker.
161
- * @param {number} positionedElementWidth Width of the positioned element.
159
+ * @param {number} mouseXCoordinate Horizontal coordinate of the mouse position.
160
+ * @param {Element} containerElement Container for the gradient picker.
162
161
  *
163
162
  * @return {number} Whole number percentage from the left.
164
163
  */
165
164
 
166
- export function getHorizontalRelativeGradientPosition(mouseXCoordinate, containerElement, positionedElementWidth) {
165
+ export function getHorizontalRelativeGradientPosition(mouseXCoordinate, containerElement) {
167
166
  if (!containerElement) {
168
167
  return;
169
168
  }
@@ -172,8 +171,7 @@ export function getHorizontalRelativeGradientPosition(mouseXCoordinate, containe
172
171
  x,
173
172
  width
174
173
  } = containerElement.getBoundingClientRect();
175
- const absolutePositionValue = mouseXCoordinate - x - MINIMUM_ABSOLUTE_LEFT_POSITION - positionedElementWidth / 2;
176
- const availableWidth = width - MINIMUM_ABSOLUTE_LEFT_POSITION - INSERT_POINT_WIDTH;
177
- return Math.round(clampPercent(absolutePositionValue * 100 / availableWidth));
174
+ const absolutePositionValue = mouseXCoordinate - x;
175
+ return Math.round(clampPercent(absolutePositionValue * 100 / width));
178
176
  }
179
177
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/custom-gradient-bar/utils.js"],"names":["MINIMUM_DISTANCE_BETWEEN_POINTS","MINIMUM_ABSOLUTE_LEFT_POSITION","INSERT_POINT_WIDTH","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","positionedElementWidth","x","width","getBoundingClientRect","absolutePositionValue","availableWidth","round"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,+BADD,EAECC,8BAFD,EAGCC,kBAHD,QAIO,aAJP;AAMA;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,uEADaX,+BACb;AACD,QAAMY,eAAe,GAAGR,KAAK,CAAEK,YAAF,CAAL,CAAsBI,QAA9C;AACA,QAAMC,WAAW,GAAGT,IAAI,CAACE,GAAL,CAAUK,eAAV,EAA2BF,WAA3B,CAApB;AACA,QAAMK,WAAW,GAAGV,IAAI,CAACC,GAAL,CAAUM,eAAV,EAA2BF,WAA3B,CAApB;AAEA,SAAON,KAAK,CAACY,IAAN,CAAY,OAAgBC,KAAhB,KAA2B;AAAA,QAAzB;AAAEJ,MAAAA;AAAF,KAAyB;AAC7C,WACCI,KAAK,KAAKR,YAAV,KACEJ,IAAI,CAACa,GAAL,CAAUL,QAAQ,GAAGH,WAArB,IAAqCC,WAArC,IACCG,WAAW,GAAGD,QAAd,IAA0BA,QAAQ,GAAGE,WAFxC,CADD;AAKA,GANM,CAAP;AAOA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AAC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encies\n */\nimport {\n\tMINIMUM_DISTANCE_BETWEEN_POINTS,\n\tMINIMUM_ABSOLUTE_LEFT_POSITION,\n\tINSERT_POINT_WIDTH,\n} 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 * @param {number} positionedElementWidth Width of the positioned element.\n *\n * @return {number} Whole number percentage from the left.\n */\nexport function getHorizontalRelativeGradientPosition(\n\tmouseXCoordinate,\n\tcontainerElement,\n\tpositionedElementWidth\n) {\n\tif ( ! containerElement ) {\n\t\treturn;\n\t}\n\tconst { x, width } = containerElement.getBoundingClientRect();\n\tconst absolutePositionValue =\n\t\tmouseXCoordinate -\n\t\tx -\n\t\tMINIMUM_ABSOLUTE_LEFT_POSITION -\n\t\tpositionedElementWidth / 2;\n\tconst availableWidth =\n\t\twidth - MINIMUM_ABSOLUTE_LEFT_POSITION - INSERT_POINT_WIDTH;\n\treturn Math.round(\n\t\tclampPercent( ( absolutePositionValue * 100 ) / availableWidth )\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/custom-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;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,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O,SAASY,iCAAT,CACNjB,MADM,EAENP,QAFM,EAGNuB,QAHM,EAIL;AACD,QAAMnB,KAAK,GAAGG,MAAM,CAACG,SAAP,CAAoBC,KAAF,IAAaA,KAAK,CAACX,QAAN,KAAmBA,QAAlD,CAAd;AACA,SAAOsB,uBAAuB,CAAEf,MAAF,EAAUH,KAAV,EAAiBmB,QAAjB,CAA9B;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,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,SAAOpC,IAAI,CAACwC,KAAL,CACN1C,YAAY,CAAIyC,qBAAqB,GAAG,GAA1B,GAAkCF,KAApC,CADN,CAAP;AAGA","sourcesContent":["/**\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} 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,13 +1,8 @@
1
1
  import { createElement } from "@wordpress/element";
2
2
 
3
- /**
4
- * External dependencies
5
- */
6
- import { get, omit } from 'lodash';
7
3
  /**
8
4
  * WordPress dependencies
9
5
  */
10
-
11
6
  import { __ } from '@wordpress/i18n';
12
7
  /**
13
8
  * Internal dependencies
@@ -23,12 +18,14 @@ import { DEFAULT_LINEAR_GRADIENT_ANGLE, HORIZONTAL_GRADIENT_ORIENTATION, GRADIEN
23
18
  import { AccessoryWrapper, SelectWrapper } from './styles/custom-gradient-picker-styles';
24
19
 
25
20
  const GradientAnglePicker = _ref => {
21
+ var _gradientAST$orientat, _gradientAST$orientat2;
22
+
26
23
  let {
27
24
  gradientAST,
28
25
  hasGradient,
29
26
  onChange
30
27
  } = _ref;
31
- const angle = get(gradientAST, ['orientation', 'value'], DEFAULT_LINEAR_GRADIENT_ANGLE);
28
+ const angle = (_gradientAST$orientat = gradientAST === null || gradientAST === void 0 ? void 0 : (_gradientAST$orientat2 = gradientAST.orientation) === null || _gradientAST$orientat2 === void 0 ? void 0 : _gradientAST$orientat2.value) !== null && _gradientAST$orientat !== void 0 ? _gradientAST$orientat : DEFAULT_LINEAR_GRADIENT_ANGLE;
32
29
 
33
30
  const onAngleChange = newAngle => {
34
31
  onChange(serializeGradient({ ...gradientAST,
@@ -66,7 +63,11 @@ const GradientTypePicker = _ref2 => {
66
63
  };
67
64
 
68
65
  const onSetRadialGradient = () => {
69
- onChange(serializeGradient({ ...omit(gradientAST, ['orientation']),
66
+ const {
67
+ orientation,
68
+ ...restGradientAST
69
+ } = gradientAST;
70
+ onChange(serializeGradient({ ...restGradientAST,
70
71
  type: 'radial-gradient'
71
72
  }));
72
73
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/custom-gradient-picker/index.js"],"names":["get","omit","__","AnglePickerControl","CustomGradientBar","Flex","SelectControl","getGradientAstWithDefault","getLinearGradientRepresentation","getGradientAstWithControlPoints","getStopCssColor","serializeGradient","DEFAULT_LINEAR_GRADIENT_ANGLE","HORIZONTAL_GRADIENT_ORIENTATION","GRADIENT_OPTIONS","DEFAULT_GRADIENT","AccessoryWrapper","SelectWrapper","GradientAnglePicker","gradientAST","hasGradient","onChange","angle","onAngleChange","newAngle","orientation","type","value","GradientTypePicker","onSetLinearGradient","onSetRadialGradient","handleOnChange","next","CustomGradientPicker","__experimentalIsRenderedInSidebar","background","controlPoints","colorStops","map","colorStop","color","position","parseInt","length","newControlPoints"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,GAAT,EAAcC,IAAd,QAA0B,QAA1B;AAEA;AACA;AACA;;AACA,SAASC,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AACA,OAAOC,kBAAP,MAA+B,yBAA/B;AACA,OAAOC,iBAAP,MAA8B,wBAA9B;AACA,SAASC,IAAT,QAAqB,SAArB;AACA,OAAOC,aAAP,MAA0B,mBAA1B;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,MAA5C;AAAEC,IAAAA,WAAF;AAAeC,IAAAA,WAAf;AAA4BC,IAAAA;AAA5B,GAA4C;AACzE,QAAMC,KAAK,GAAGtB,GAAG,CAChBmB,WADgB,EAEhB,CAAE,aAAF,EAAiB,OAAjB,CAFgB,EAGhBP,6BAHgB,CAAjB;;AAKA,QAAMW,aAAa,GAAKC,QAAF,IAAgB;AACrCH,IAAAA,QAAQ,CACPV,iBAAiB,CAAE,EAClB,GAAGQ,WADe;AAElBM,MAAAA,WAAW,EAAE;AACZC,QAAAA,IAAI,EAAE,SADM;AAEZC,QAAAA,KAAK,EAAEH;AAFK;AAFK,KAAF,CADV,CAAR;AASA,GAVD;;AAWA,SACC,cAAC,kBAAD;AACC,IAAA,QAAQ,EAAGD,aADZ;AAEC,IAAA,aAAa,EAAC,KAFf;AAGC,IAAA,KAAK,EAAGH,WAAW,GAAGE,KAAH,GAAW;AAH/B,IADD;AAOA,CAxBD;;AA0BA,MAAMM,kBAAkB,GAAG,SAA8C;AAAA,MAA5C;AAAET,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dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport AnglePickerControl from '../angle-picker-control';\nimport CustomGradientBar from '../custom-gradient-bar';\nimport { Flex } from '../flex';\nimport SelectControl from '../select-control';\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 = get(\n\t\tgradientAST,\n\t\t[ 'orientation', 'value' ],\n\t\tDEFAULT_LINEAR_GRADIENT_ANGLE\n\t);\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\tonChange={ onAngleChange }\n\t\t\tlabelPosition=\"top\"\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\tonChange(\n\t\t\tserializeGradient( {\n\t\t\t\t...omit( gradientAST, [ 'orientation' ] ),\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\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\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\treturn (\n\t\t<div className=\"components-custom-gradient-picker\">\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</div>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/custom-gradient-picker/index.js"],"names":["__","AnglePickerControl","CustomGradientBar","Flex","SelectControl","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","__experimentalIsRenderedInSidebar","background","controlPoints","colorStops","map","colorStop","color","position","parseInt","length","newControlPoints"],"mappings":";;AAAA;AACA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BAA1C,CANG,CAOH;AACA;;AACA,QAAMsB,aAAa,GAAGlB,WAAW,CAACmB,UAAZ,CAAuBC,GAAvB,CAA8BC,SAAF,KAAmB;AACpEC,IAAAA,KAAK,EAAE/B,eAAe,CAAE8B,SAAF,CAD8C;AAEpEE,IAAAA,QAAQ,EAAEC,QAAQ,CAAEH,SAAS,CAACI,MAAV,CAAiBpB,KAAnB;AAFkD,GAAnB,CAA5B,CAAtB;AAKA,SACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,cAAC,iBAAD;AACC,IAAA,iCAAiC,EAChCW,iCAFF;AAIC,IAAA,UAAU,EAAGC,UAJd;AAKC,IAAA,WAAW,EAAGhB,WALf;AAMC,IAAA,KAAK,EAAGiB,aANT;AAOC,IAAA,QAAQ,EAAKQ,gBAAF,IAAwB;AAClCxB,MAAAA,QAAQ,CACPV,iBAAiB,CAChBF,+BAA+B,CAC9BU,WAD8B,EAE9B0B,gBAF8B,CADf,CADV,CAAR;AAQA;AAhBF,IADD,EAmBC,cAAC,IAAD;AACC,IAAA,GAAG,EAAG,CADP;AAEC,IAAA,SAAS,EAAC;AAFX,KAIC,cAAC,aAAD,QACC,cAAC,kBAAD;AACC,IAAA,WAAW,EAAG1B,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,CAnBD,CADD;AA2CA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport AnglePickerControl from '../angle-picker-control';\nimport CustomGradientBar from '../custom-gradient-bar';\nimport { Flex } from '../flex';\nimport SelectControl from '../select-control';\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\tonChange={ onAngleChange }\n\t\t\tlabelPosition=\"top\"\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\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\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\treturn (\n\t\t<div className=\"components-custom-gradient-picker\">\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</div>\n\t);\n}\n"]}
@@ -1,13 +1,8 @@
1
1
  import { createElement, Fragment } from "@wordpress/element";
2
2
 
3
- /**
4
- * External dependencies
5
- */
6
- import { get, omit } from 'lodash';
7
3
  /**
8
4
  * WordPress dependencies
9
5
  */
10
-
11
6
  import { PanelBody, RadioControl, RangeControl } from '@wordpress/components';
12
7
  import { __ } from '@wordpress/i18n';
13
8
  import { useState } from '@wordpress/element';
@@ -42,7 +37,10 @@ function CustomGradientPicker(_ref) {
42
37
  }
43
38
 
44
39
  function getGradientColor(type) {
45
- const orientation = get(gradientAST, ['orientation']);
40
+ const {
41
+ orientation,
42
+ ...restGradientAST
43
+ } = gradientAST;
46
44
 
47
45
  if (orientation) {
48
46
  setGradientOrientation(orientation);
@@ -53,7 +51,7 @@ function CustomGradientPicker(_ref) {
53
51
  orientation: gradientOrientation
54
52
  }),
55
53
  type
56
- } : { ...omit(gradientAST, ['orientation']),
54
+ } : { ...restGradientAST,
57
55
  type
58
56
  });
59
57
  }
@@ -79,7 +77,9 @@ function CustomGradientPicker(_ref) {
79
77
  }
80
78
 
81
79
  function getGradientAngle() {
82
- return get(gradientAST, ['orientation', 'value'], DEFAULT_LINEAR_GRADIENT_ANGLE);
80
+ var _gradientAST$orientat, _gradientAST$orientat2;
81
+
82
+ return (_gradientAST$orientat = gradientAST === null || gradientAST === void 0 ? void 0 : (_gradientAST$orientat2 = gradientAST.orientation) === null || _gradientAST$orientat2 === void 0 ? void 0 : _gradientAST$orientat2.value) !== null && _gradientAST$orientat !== void 0 ? _gradientAST$orientat : DEFAULT_LINEAR_GRADIENT_ANGLE;
83
83
  }
84
84
 
85
85
  return createElement(Fragment, null, createElement(PanelBody, {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/custom-gradient-picker/index.native.js"],"names":["get","omit","PanelBody","RadioControl","RangeControl","__","useState","colorsUtils","getGradientAstWithDefault","serializeGradient","DEFAULT_LINEAR_GRADIENT_ANGLE","HORIZONTAL_GRADIENT_ORIENTATION","styles","CustomGradientPicker","setColor","currentValue","isGradientColor","gradientOrientation","setGradientOrientation","currentColor","setCurrentColor","getGradientType","gradients","gradientOptions","gradientAST","gradientType","isLinearGradient","type","linear","getGradientColor","orientation","onGradientTypeChange","gradientColor","setGradientAngle","value","getGradientAngle","angleControl"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,GAAT,EAAcC,IAAd,QAA0B,QAA1B;AACA;AACA;AACA;;AACA,SAASC,SAAT,EAAoBC,YAApB,EAAkCC,YAAlC,QAAsD,uBAAtD;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,QAAT,QAAyB,oBAAzB;AAEA;AACA;AACA;;AACA,SAASC,WAAT,QAA4B,gCAA5B;AACA,SAASC,yBAAT,QAA0C,SAA1C;AACA,SAASC,iBAAT,QAAkC,cAAlC;AACA,SACCC,6BADD,EAECC,+BAFD,QAGO,aAHP;AAIA,OAAOC,MAAP,MAAmB,cAAnB;;AAEA,SAASC,oBAAT,OAA6E;AAAA,MAA9C;AAAEC,IAAAA,QAAF;AAAYC,IAAAA,YAAZ;AA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F,aAAa,GAAGvB,iBAAiB,CAAE,EACxC,GAAGe,WADqC;AAExCM,MAAAA,WAAW,EAAE;AACZH,QAAAA,IAAI,EAAE,SADM;AAEZO,QAAAA;AAFY;AAF2B,KAAF,CAAvC;;AAQA,QAAKlB,eAAe,IAAIgB,aAAa,KAAKb,YAA1C,EAAyD;AACxDC,MAAAA,eAAe,CAAEY,aAAF,CAAf;AACAlB,MAAAA,QAAQ,CAAEkB,aAAF,CAAR;AACA;AACD;;AAED,WAASG,gBAAT,GAA4B;AAC3B,WAAOnC,GAAG,CACTwB,WADS,EAET,CAAE,aAAF,EAAiB,OAAjB,CAFS,EAGTd,6BAHS,CAAV;AAKA;;AACD,SACC,8BACC,cAAC,SAAD;AAAW,IAAA,KAAK,EAAGL,EAAE,CAAE,eAAF;AAArB,KACC,cAAC,YAAD;AACC,IAAA,QAAQ,EAAGoB,YADZ;AAEC,IAAA,OAAO,EAAGF,eAFX;AAGC,IAAA,QAAQ,EAAGQ;AAHZ,IADD,CADD,EAQGL,gBAAgB,CAAED,YAAF,CAAhB,IACD,cAAC,SAAD;AAAW,IAAA,KAAK,EAAGb,MAAM,CAACwB;AAA1B,KACC,cAAC,YAAD;AACC,IAAA,KAAK,EAAG/B,EAAE,CAAE,OAAF,CADX;AAEC,IAAA,YAAY,EAAG,CAFhB;AAGC,IAAA,YAAY,EAAG,GAHhB;AAIC,IAAA,KAAK,EAAG8B,gBAAgB,EAJzB;AAKC,IAAA,QAAQ,EAAGF;AALZ,IADD,CATF,CADD;AAsBA;;AAED,eAAepB,oBAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { get, omit } from 'lodash';\n/**\n * WordPress dependencies\n */\nimport { PanelBody, RadioControl, RangeControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { colorsUtils } from '../mobile/color-settings/utils';\nimport { getGradientAstWithDefault } from './utils';\nimport { serializeGradient } from './serializer';\nimport {\n\tDEFAULT_LINEAR_GRADIENT_ANGLE,\n\tHORIZONTAL_GRADIENT_ORIENTATION,\n} from './constants';\nimport styles from './style.scss';\n\nfunction CustomGradientPicker( { setColor, currentValue, isGradientColor } ) {\n\tconst [ gradientOrientation, setGradientOrientation ] = useState(\n\t\tHORIZONTAL_GRADIENT_ORIENTATION\n\t);\n\n\tconst [ currentColor, setCurrentColor ] = useState( currentValue );\n\n\tconst { getGradientType, gradients, gradientOptions } = colorsUtils;\n\tconst gradientAST = getGradientAstWithDefault( currentColor );\n\tconst gradientType = getGradientType( currentColor );\n\n\tfunction isLinearGradient( type ) {\n\t\treturn type === gradients.linear;\n\t}\n\n\tfunction getGradientColor( type ) {\n\t\tconst orientation = get( gradientAST, [ 'orientation' ] );\n\n\t\tif ( orientation ) {\n\t\t\tsetGradientOrientation( orientation );\n\t\t}\n\n\t\treturn serializeGradient(\n\t\t\tisLinearGradient( type )\n\t\t\t\t? {\n\t\t\t\t\t\t...gradientAST,\n\t\t\t\t\t\t...( gradientAST.orientation\n\t\t\t\t\t\t\t? {}\n\t\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\t\torientation: gradientOrientation,\n\t\t\t\t\t\t\t } ),\n\t\t\t\t\t\ttype,\n\t\t\t\t }\n\t\t\t\t: {\n\t\t\t\t\t\t...omit( gradientAST, [ 'orientation' ] ),\n\t\t\t\t\t\ttype,\n\t\t\t\t }\n\t\t);\n\t}\n\n\tfunction onGradientTypeChange( type ) {\n\t\tconst gradientColor = getGradientColor( type );\n\t\tsetCurrentColor( gradientColor );\n\t\tsetColor( gradientColor );\n\t}\n\n\tfunction setGradientAngle( value ) {\n\t\tconst gradientColor = serializeGradient( {\n\t\t\t...gradientAST,\n\t\t\torientation: {\n\t\t\t\ttype: 'angular',\n\t\t\t\tvalue,\n\t\t\t},\n\t\t} );\n\n\t\tif ( isGradientColor && gradientColor !== currentColor ) {\n\t\t\tsetCurrentColor( gradientColor );\n\t\t\tsetColor( gradientColor );\n\t\t}\n\t}\n\n\tfunction getGradientAngle() {\n\t\treturn get(\n\t\t\tgradientAST,\n\t\t\t[ 'orientation', 'value' ],\n\t\t\tDEFAULT_LINEAR_GRADIENT_ANGLE\n\t\t);\n\t}\n\treturn (\n\t\t<>\n\t\t\t<PanelBody title={ __( 'Gradient Type' ) }>\n\t\t\t\t<RadioControl\n\t\t\t\t\tselected={ gradientType }\n\t\t\t\t\toptions={ gradientOptions }\n\t\t\t\t\tonChange={ onGradientTypeChange }\n\t\t\t\t/>\n\t\t\t</PanelBody>\n\t\t\t{ isLinearGradient( gradientType ) && (\n\t\t\t\t<PanelBody style={ styles.angleControl }>\n\t\t\t\t\t<RangeControl\n\t\t\t\t\t\tlabel={ __( 'Angle' ) }\n\t\t\t\t\t\tminimumValue={ 0 }\n\t\t\t\t\t\tmaximumValue={ 360 }\n\t\t\t\t\t\tvalue={ getGradientAngle() }\n\t\t\t\t\t\tonChange={ setGradientAngle }\n\t\t\t\t\t/>\n\t\t\t\t</PanelBody>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default CustomGradientPicker;\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/custom-gradient-picker/index.native.js"],"names":["PanelBody","RadioControl","RangeControl","__","useState","colorsUtils","getGradientAstWithDefault","serializeGradient","DEFAULT_LINEAR_GRADIENT_ANGLE","HORIZONTAL_GRADIENT_ORIENTATION","styles","CustomGradientPicker","setColor","currentValue","isGradientColor","gradientOrientation","setGradientOrientation","currentColor","setCurrentColor","getGradientType","gradients","gradientOptions","gradientAST","gradientType","isLinearGradient","type","linear","getGradientColor","orientation","restGradientAST","onGradientTypeChange","gradientColor","setGradientAngle","value","getGradientAngle","angleControl"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,EAAoBC,YAApB,EAAkCC,YAAlC,QAAsD,uBAAtD;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,QAAT,QAAyB,oBAAzB;AAEA;AACA;AACA;;AACA,SAASC,WAAT,QAA4B,gC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,GAAGJ,gBAAgB,CAAEF,IAAF,CAAtC;AACAP,IAAAA,eAAe,CAAEa,aAAF,CAAf;AACAnB,IAAAA,QAAQ,CAAEmB,aAAF,CAAR;AACA;;AAED,WAASC,gBAAT,CAA2BC,KAA3B,EAAmC;AAClC,UAAMF,aAAa,GAAGxB,iBAAiB,CAAE,EACxC,GAAGe,WADqC;AAExCM,MAAAA,WAAW,EAAE;AACZH,QAAAA,IAAI,EAAE,SADM;AAEZQ,QAAAA;AAFY;AAF2B,KAAF,CAAvC;;AAQA,QAAKnB,eAAe,IAAIiB,aAAa,KAAKd,YAA1C,EAAyD;AACxDC,MAAAA,eAAe,CAAEa,aAAF,CAAf;AACAnB,MAAAA,QAAQ,CAAEmB,aAAF,CAAR;AACA;AACD;;AAED,WAASG,gBAAT,GAA4B;AAAA;;AAC3B,oCAAOZ,WAAP,aAAOA,WAAP,iDAAOA,WAAW,CAAEM,WAApB,2DAAO,uBAA0BK,KAAjC,yEAA0CzB,6BAA1C;AACA;;AACD,SACC,8BACC,cAAC,SAAD;AAAW,IAAA,KAAK,EAAGL,EAAE,CAAE,eAAF;AAArB,KACC,cAAC,YAAD;AACC,IAAA,QAAQ,EAAGoB,YADZ;AAEC,IAAA,OAAO,EAAGF,eAFX;AAGC,IAAA,QAAQ,EAAGS;AAHZ,IADD,CADD,EAQGN,gBAAgB,CAAED,YAAF,CAAhB,IACD,cAAC,SAAD;AAAW,IAAA,KAAK,EAAGb,MAAM,CAACyB;AAA1B,KACC,cAAC,YAAD;AACC,IAAA,KAAK,EAAGhC,EAAE,CAAE,OAAF,CADX;AAEC,IAAA,YAAY,EAAG,CAFhB;AAGC,IAAA,YAAY,EAAG,GAHhB;AAIC,IAAA,KAAK,EAAG+B,gBAAgB,EAJzB;AAKC,IAAA,QAAQ,EAAGF;AALZ,IADD,CATF,CADD;AAsBA;;AAED,eAAerB,oBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { PanelBody, RadioControl, RangeControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { colorsUtils } from '../mobile/color-settings/utils';\nimport { getGradientAstWithDefault } from './utils';\nimport { serializeGradient } from './serializer';\nimport {\n\tDEFAULT_LINEAR_GRADIENT_ANGLE,\n\tHORIZONTAL_GRADIENT_ORIENTATION,\n} from './constants';\nimport styles from './style.scss';\n\nfunction CustomGradientPicker( { setColor, currentValue, isGradientColor } ) {\n\tconst [ gradientOrientation, setGradientOrientation ] = useState(\n\t\tHORIZONTAL_GRADIENT_ORIENTATION\n\t);\n\n\tconst [ currentColor, setCurrentColor ] = useState( currentValue );\n\n\tconst { getGradientType, gradients, gradientOptions } = colorsUtils;\n\tconst gradientAST = getGradientAstWithDefault( currentColor );\n\tconst gradientType = getGradientType( currentColor );\n\n\tfunction isLinearGradient( type ) {\n\t\treturn type === gradients.linear;\n\t}\n\n\tfunction getGradientColor( type ) {\n\t\tconst { orientation, ...restGradientAST } = gradientAST;\n\n\t\tif ( orientation ) {\n\t\t\tsetGradientOrientation( orientation );\n\t\t}\n\n\t\treturn serializeGradient(\n\t\t\tisLinearGradient( type )\n\t\t\t\t? {\n\t\t\t\t\t\t...gradientAST,\n\t\t\t\t\t\t...( gradientAST.orientation\n\t\t\t\t\t\t\t? {}\n\t\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\t\torientation: gradientOrientation,\n\t\t\t\t\t\t\t } ),\n\t\t\t\t\t\ttype,\n\t\t\t\t }\n\t\t\t\t: {\n\t\t\t\t\t\t...restGradientAST,\n\t\t\t\t\t\ttype,\n\t\t\t\t }\n\t\t);\n\t}\n\n\tfunction onGradientTypeChange( type ) {\n\t\tconst gradientColor = getGradientColor( type );\n\t\tsetCurrentColor( gradientColor );\n\t\tsetColor( gradientColor );\n\t}\n\n\tfunction setGradientAngle( value ) {\n\t\tconst gradientColor = serializeGradient( {\n\t\t\t...gradientAST,\n\t\t\torientation: {\n\t\t\t\ttype: 'angular',\n\t\t\t\tvalue,\n\t\t\t},\n\t\t} );\n\n\t\tif ( isGradientColor && gradientColor !== currentColor ) {\n\t\t\tsetCurrentColor( gradientColor );\n\t\t\tsetColor( gradientColor );\n\t\t}\n\t}\n\n\tfunction getGradientAngle() {\n\t\treturn gradientAST?.orientation?.value ?? DEFAULT_LINEAR_GRADIENT_ANGLE;\n\t}\n\treturn (\n\t\t<>\n\t\t\t<PanelBody title={ __( 'Gradient Type' ) }>\n\t\t\t\t<RadioControl\n\t\t\t\t\tselected={ gradientType }\n\t\t\t\t\toptions={ gradientOptions }\n\t\t\t\t\tonChange={ onGradientTypeChange }\n\t\t\t\t/>\n\t\t\t</PanelBody>\n\t\t\t{ isLinearGradient( gradientType ) && (\n\t\t\t\t<PanelBody style={ styles.angleControl }>\n\t\t\t\t\t<RangeControl\n\t\t\t\t\t\tlabel={ __( 'Angle' ) }\n\t\t\t\t\t\tminimumValue={ 0 }\n\t\t\t\t\t\tmaximumValue={ 360 }\n\t\t\t\t\t\tvalue={ getGradientAngle() }\n\t\t\t\t\t\tonChange={ setGradientAngle }\n\t\t\t\t\t/>\n\t\t\t\t</PanelBody>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default CustomGradientPicker;\n"]}
@@ -1,7 +1,3 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { compact, get } from 'lodash';
5
1
  export function serializeGradientColor(_ref) {
6
2
  let {
7
3
  type,
@@ -55,8 +51,10 @@ export function serializeGradient(_ref3) {
55
51
  } = _ref3;
56
52
  const serializedOrientation = serializeGradientOrientation(orientation);
57
53
  const serializedColorStops = colorStops.sort((colorStop1, colorStop2) => {
58
- return get(colorStop1, ['length', 'value'], 0) - get(colorStop2, ['length', 'value'], 0);
54
+ var _colorStop1$length$va, _colorStop1$length, _colorStop2$length$va, _colorStop2$length;
55
+
56
+ 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);
59
57
  }).map(serializeGradientColorStop);
60
- return `${type}(${compact([serializedOrientation, ...serializedColorStops]).join(',')})`;
58
+ return `${type}(${[serializedOrientation, ...serializedColorStops].filter(Boolean).join(',')})`;
61
59
  }
62
60
  //# sourceMappingURL=serializer.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/custom-gradient-picker/serializer.js"],"names":["compact","get","serializeGradientColor","type","value","join","serializeGradientPosition","position","serializeGradientColorStop","length","serializeGradientOrientation","orientation","serializeGradient","colorStops","serializedOrientation","serializedColorStops","sort","colorStop1","colorStop2","map"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAT,EAAkBC,GAAlB,QAA6B,QAA7B;AAEA,OAAO,SAASC,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;AACpC,WACCjB,GAAG,CAAEgB,UAAF,EAAc,CAAE,QAAF,EAAY,OAAZ,CAAd,EAAqC,CAArC,CAAH,GACAhB,GAAG,CAAEiB,UAAF,EAAc,CAAE,QAAF,EAAY,OAAZ,CAAd,EAAqC,CAArC,CAFJ;AAIA,GAN2B,EAO3BC,GAP2B,CAOtBX,0BAPsB,CAA7B;AAQA,SAAQ,GAAGL,IAAM,IAAIH,OAAO,CAAE,CAC7Bc,qBAD6B,EAE7B,GAAGC,oBAF0B,CAAF,CAAP,CAGjBV,IAHiB,CAGX,GAHW,CAGJ,GAHjB;AAIA","sourcesContent":["/**\n * External dependencies\n */\nimport { compact, get } from 'lodash';\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\tget( colorStop1, [ 'length', 'value' ], 0 ) -\n\t\t\t\tget( colorStop2, [ 'length', 'value' ], 0 )\n\t\t\t);\n\t\t} )\n\t\t.map( serializeGradientColorStop );\n\treturn `${ type }(${ compact( [\n\t\tserializedOrientation,\n\t\t...serializedColorStops,\n\t] ).join( ',' ) })`;\n}\n"]}
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,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,MA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GAFa,CAEN,GAFf;AAGA","sourcesContent":["export 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"]}
@@ -75,7 +75,7 @@ export function getGradientAstWithControlPoints(gradientAST, newControlPoints) {
75
75
  return {
76
76
  length: {
77
77
  type: '%',
78
- value: position.toString()
78
+ value: position === null || position === void 0 ? void 0 : position.toString()
79
79
  },
80
80
  type: a < 1 ? 'rgba' : 'rgb',
81
81
  value: a < 1 ? [r, g, b, a] : [r, g, b]
@@ -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;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,CAAsBf,gBAAtB,EAA0C,CAA1C,CAAd;AACAK,IAAAA,WAAW,CAACS,KAAZ,GAAoBd,gBAApB;AACA;;AA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,KAAK,EAAEY,QAAQ,CAACT,QAAT;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":["/**\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 = DIRECTIONAL_ORIENTATION_ANGLE_MAP[\n\t\t\tgradientAST.orientation.value\n\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.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;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;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CAAsB,QAA2B;AAAA,UAAzB;AAAEC,QAAAA,QAAF;AAAYC,QAAAA;AAAZ,OAAyB;AAC5D,YAAM;AAAEC,QAAAA,CAAF;AAAKC,QAAAA,CAAL;AAAQC,QAAAA,CAAR;AAAWC,QAAAA;AAAX,UAAiBlC,MAAM,CAAE8B,KAAF,CAAN,CAAgBK,KAAhB,EAAvB;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":["/**\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"]}