@wordpress/components 23.1.0 → 23.3.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 (623) hide show
  1. package/CHANGELOG.md +53 -0
  2. package/CONTRIBUTING.md +1 -1
  3. package/LICENSE.md +1 -1
  4. package/build/alignment-matrix-control/utils.js +2 -2
  5. package/build/alignment-matrix-control/utils.js.map +1 -1
  6. package/build/autocomplete/autocompleter-ui.js +1 -3
  7. package/build/autocomplete/autocompleter-ui.js.map +1 -1
  8. package/build/border-box-control/border-box-control-linked-button/component.js.map +1 -1
  9. package/build/border-box-control/border-box-control-linked-button/hook.js.map +1 -1
  10. package/build/border-control/border-control-dropdown/component.js +8 -4
  11. package/build/border-control/border-control-dropdown/component.js.map +1 -1
  12. package/build/button/deprecated.js +8 -6
  13. package/build/button/deprecated.js.map +1 -1
  14. package/build/button/index.js +52 -23
  15. package/build/button/index.js.map +1 -1
  16. package/build/button/types.js +6 -0
  17. package/build/button/types.js.map +1 -0
  18. package/build/color-list-picker/index.js.map +1 -1
  19. package/build/color-list-picker/types.js +6 -0
  20. package/build/color-list-picker/types.js.map +1 -0
  21. package/build/color-palette/index.js +9 -61
  22. package/build/color-palette/index.js.map +1 -1
  23. package/build/color-palette/index.native.js +24 -9
  24. package/build/color-palette/index.native.js.map +1 -1
  25. package/build/color-palette/utils.js +103 -0
  26. package/build/color-palette/utils.js.map +1 -0
  27. package/build/color-picker/component.js +1 -0
  28. package/build/color-picker/component.js.map +1 -1
  29. package/build/color-picker/styles.js +8 -10
  30. package/build/color-picker/styles.js.map +1 -1
  31. package/build/combobox-control/index.js +5 -1
  32. package/build/combobox-control/index.js.map +1 -1
  33. package/build/custom-gradient-picker/gradient-bar/utils.js +1 -1
  34. package/build/custom-gradient-picker/gradient-bar/utils.js.map +1 -1
  35. package/build/date-time/date/index.js.map +1 -1
  36. package/build/dropdown/index.js +20 -8
  37. package/build/dropdown/index.js.map +1 -1
  38. package/build/focal-point-picker/utils.js +1 -1
  39. package/build/focal-point-picker/utils.js.map +1 -1
  40. package/build/form-token-field/token.js +1 -1
  41. package/build/form-token-field/token.js.map +1 -1
  42. package/build/gradient-picker/index.js +9 -1
  43. package/build/gradient-picker/index.js.map +1 -1
  44. package/build/h-stack/component.js +0 -1
  45. package/build/h-stack/component.js.map +1 -1
  46. package/build/index.js +7 -17
  47. package/build/index.js.map +1 -1
  48. package/build/index.native.js +8 -18
  49. package/build/index.native.js.map +1 -1
  50. package/build/input-control/input-field.js +4 -2
  51. package/build/input-control/input-field.js.map +1 -1
  52. package/build/item-group/item/component.js +27 -3
  53. package/build/item-group/item/component.js.map +1 -1
  54. package/build/item-group/item-group/component.js +26 -3
  55. package/build/item-group/item-group/component.js.map +1 -1
  56. package/build/item-group/styles.js +14 -14
  57. package/build/item-group/styles.js.map +1 -1
  58. package/build/keyboard-shortcuts/index.js +44 -16
  59. package/build/keyboard-shortcuts/index.js.map +1 -1
  60. package/build/keyboard-shortcuts/types.js +6 -0
  61. package/build/keyboard-shortcuts/types.js.map +1 -0
  62. package/build/modal/index.js +1 -1
  63. package/build/modal/index.js.map +1 -1
  64. package/build/notice/index.js +16 -18
  65. package/build/notice/index.js.map +1 -1
  66. package/build/notice/list.js +23 -8
  67. package/build/notice/list.js.map +1 -1
  68. package/build/notice/types.js +6 -0
  69. package/build/notice/types.js.map +1 -0
  70. package/build/number-control/index.js +1 -1
  71. package/build/number-control/index.js.map +1 -1
  72. package/build/panel/row.js +5 -3
  73. package/build/panel/row.js.map +1 -1
  74. package/build/query-controls/author-select.js +7 -3
  75. package/build/query-controls/author-select.js.map +1 -1
  76. package/build/query-controls/category-select.js +7 -3
  77. package/build/query-controls/category-select.js.map +1 -1
  78. package/build/query-controls/index.js +69 -20
  79. package/build/query-controls/index.js.map +1 -1
  80. package/build/query-controls/terms.js +4 -3
  81. package/build/query-controls/terms.js.map +1 -1
  82. package/build/query-controls/types.js +6 -0
  83. package/build/query-controls/types.js.map +1 -0
  84. package/build/resizable-box/index.js +5 -4
  85. package/build/resizable-box/index.js.map +1 -1
  86. package/build/responsive-wrapper/index.js +18 -1
  87. package/build/responsive-wrapper/index.js.map +1 -1
  88. package/build/responsive-wrapper/types.js +6 -0
  89. package/build/responsive-wrapper/types.js.map +1 -0
  90. package/build/sandbox/index.js +35 -24
  91. package/build/sandbox/index.js.map +1 -1
  92. package/build/sandbox/types.js +6 -0
  93. package/build/sandbox/types.js.map +1 -0
  94. package/build/slot-fill/bubbles-virtually/fill.js +1 -0
  95. package/build/slot-fill/bubbles-virtually/fill.js.map +1 -1
  96. package/build/slot-fill/slot.js +1 -0
  97. package/build/slot-fill/slot.js.map +1 -1
  98. package/build/slot-fill/use-slot.js +1 -11
  99. package/build/slot-fill/use-slot.js.map +1 -1
  100. package/build/snackbar/index.js.map +1 -1
  101. package/build/snackbar/list.js.map +1 -1
  102. package/build/tab-panel/index.js +40 -7
  103. package/build/tab-panel/index.js.map +1 -1
  104. package/build/toolbar/index.js +42 -60
  105. package/build/toolbar/index.js.map +1 -1
  106. package/build/toolbar/toolbar/index.js +74 -0
  107. package/build/toolbar/toolbar/index.js.map +1 -0
  108. package/build/toolbar/{toolbar-container.js → toolbar/toolbar-container.js} +0 -0
  109. package/build/toolbar/toolbar/toolbar-container.js.map +1 -0
  110. package/build/toolbar/{toolbar-container.native.js → toolbar/toolbar-container.native.js} +0 -0
  111. package/build/toolbar/toolbar/toolbar-container.native.js.map +1 -0
  112. package/build/{toolbar-button → toolbar/toolbar-button}/index.js +1 -1
  113. package/build/toolbar/toolbar-button/index.js.map +1 -0
  114. package/build/{toolbar-button → toolbar/toolbar-button}/toolbar-button-container.js +0 -0
  115. package/build/toolbar/toolbar-button/toolbar-button-container.js.map +1 -0
  116. package/build/{toolbar-button → toolbar/toolbar-button}/toolbar-button-container.native.js +0 -0
  117. package/build/toolbar/toolbar-button/toolbar-button-container.native.js.map +1 -0
  118. package/build/{toolbar-context → toolbar/toolbar-context}/index.js +0 -0
  119. package/build/toolbar/toolbar-context/index.js.map +1 -0
  120. package/build/{toolbar-dropdown-menu → toolbar/toolbar-dropdown-menu}/index.js +1 -1
  121. package/build/toolbar/toolbar-dropdown-menu/index.js.map +1 -0
  122. package/build/{toolbar-group → toolbar/toolbar-group}/index.js +0 -0
  123. package/build/toolbar/toolbar-group/index.js.map +1 -0
  124. package/build/{toolbar-group → toolbar/toolbar-group}/toolbar-group-collapsed.js +1 -1
  125. package/build/toolbar/toolbar-group/toolbar-group-collapsed.js.map +1 -0
  126. package/build/{toolbar-group → toolbar/toolbar-group}/toolbar-group-collapsed.native.js +1 -1
  127. package/build/toolbar/toolbar-group/toolbar-group-collapsed.native.js.map +1 -0
  128. package/build/{toolbar-group → toolbar/toolbar-group}/toolbar-group-container.js +0 -0
  129. package/build/toolbar/toolbar-group/toolbar-group-container.js.map +1 -0
  130. package/build/{toolbar-group → toolbar/toolbar-group}/toolbar-group-container.native.js +0 -0
  131. package/build/toolbar/toolbar-group/toolbar-group-container.native.js.map +1 -0
  132. package/build/{toolbar-item → toolbar/toolbar-item}/index.js +0 -0
  133. package/build/toolbar/toolbar-item/index.js.map +1 -0
  134. package/build/{toolbar-item → toolbar/toolbar-item}/index.native.js +0 -0
  135. package/build/toolbar/toolbar-item/index.native.js.map +1 -0
  136. package/build/tree-grid/index.js +4 -4
  137. package/build/tree-grid/index.js.map +1 -1
  138. package/build/tree-select/index.js +2 -6
  139. package/build/tree-select/index.js.map +1 -1
  140. package/build-module/alignment-matrix-control/utils.js +2 -2
  141. package/build-module/alignment-matrix-control/utils.js.map +1 -1
  142. package/build-module/autocomplete/autocompleter-ui.js +1 -2
  143. package/build-module/autocomplete/autocompleter-ui.js.map +1 -1
  144. package/build-module/border-box-control/border-box-control-linked-button/component.js.map +1 -1
  145. package/build-module/border-box-control/border-box-control-linked-button/hook.js.map +1 -1
  146. package/build-module/border-control/border-control-dropdown/component.js +7 -4
  147. package/build-module/border-control/border-control-dropdown/component.js.map +1 -1
  148. package/build-module/button/deprecated.js +8 -5
  149. package/build-module/button/deprecated.js.map +1 -1
  150. package/build-module/button/index.js +51 -22
  151. package/build-module/button/index.js.map +1 -1
  152. package/build-module/button/types.js +2 -0
  153. package/build-module/button/types.js.map +1 -0
  154. package/build-module/color-list-picker/index.js.map +1 -1
  155. package/build-module/color-list-picker/types.js +2 -0
  156. package/build-module/color-list-picker/types.js.map +1 -0
  157. package/build-module/color-palette/index.js +7 -54
  158. package/build-module/color-palette/index.js.map +1 -1
  159. package/build-module/color-palette/index.native.js +24 -8
  160. package/build-module/color-palette/index.native.js.map +1 -1
  161. package/build-module/color-palette/utils.js +79 -0
  162. package/build-module/color-palette/utils.js.map +1 -0
  163. package/build-module/color-picker/component.js +1 -0
  164. package/build-module/color-picker/component.js.map +1 -1
  165. package/build-module/color-picker/styles.js +8 -9
  166. package/build-module/color-picker/styles.js.map +1 -1
  167. package/build-module/combobox-control/index.js +5 -1
  168. package/build-module/combobox-control/index.js.map +1 -1
  169. package/build-module/custom-gradient-picker/gradient-bar/utils.js +1 -1
  170. package/build-module/custom-gradient-picker/gradient-bar/utils.js.map +1 -1
  171. package/build-module/date-time/date/index.js +1 -1
  172. package/build-module/date-time/date/index.js.map +1 -1
  173. package/build-module/dropdown/index.js +19 -8
  174. package/build-module/dropdown/index.js.map +1 -1
  175. package/build-module/focal-point-picker/utils.js +1 -1
  176. package/build-module/focal-point-picker/utils.js.map +1 -1
  177. package/build-module/form-token-field/token.js +1 -1
  178. package/build-module/form-token-field/token.js.map +1 -1
  179. package/build-module/gradient-picker/index.js +9 -2
  180. package/build-module/gradient-picker/index.js.map +1 -1
  181. package/build-module/h-stack/component.js +0 -1
  182. package/build-module/h-stack/component.js.map +1 -1
  183. package/build-module/index.js +1 -6
  184. package/build-module/index.js.map +1 -1
  185. package/build-module/index.native.js +1 -6
  186. package/build-module/index.native.js.map +1 -1
  187. package/build-module/input-control/input-field.js +4 -2
  188. package/build-module/input-control/input-field.js.map +1 -1
  189. package/build-module/item-group/item/component.js +26 -2
  190. package/build-module/item-group/item/component.js.map +1 -1
  191. package/build-module/item-group/item-group/component.js +25 -2
  192. package/build-module/item-group/item-group/component.js.map +1 -1
  193. package/build-module/item-group/styles.js +14 -14
  194. package/build-module/item-group/styles.js.map +1 -1
  195. package/build-module/keyboard-shortcuts/index.js +48 -16
  196. package/build-module/keyboard-shortcuts/index.js.map +1 -1
  197. package/build-module/keyboard-shortcuts/types.js +2 -0
  198. package/build-module/keyboard-shortcuts/types.js.map +1 -0
  199. package/build-module/modal/index.js +1 -1
  200. package/build-module/modal/index.js.map +1 -1
  201. package/build-module/notice/index.js +14 -15
  202. package/build-module/notice/index.js.map +1 -1
  203. package/build-module/notice/list.js +23 -8
  204. package/build-module/notice/list.js.map +1 -1
  205. package/build-module/notice/types.js +2 -0
  206. package/build-module/notice/types.js.map +1 -0
  207. package/build-module/number-control/index.js +1 -1
  208. package/build-module/number-control/index.js.map +1 -1
  209. package/build-module/panel/row.js +5 -3
  210. package/build-module/panel/row.js.map +1 -1
  211. package/build-module/query-controls/author-select.js +7 -3
  212. package/build-module/query-controls/author-select.js.map +1 -1
  213. package/build-module/query-controls/category-select.js +8 -4
  214. package/build-module/query-controls/category-select.js.map +1 -1
  215. package/build-module/query-controls/index.js +65 -20
  216. package/build-module/query-controls/index.js.map +1 -1
  217. package/build-module/query-controls/terms.js +8 -4
  218. package/build-module/query-controls/terms.js.map +1 -1
  219. package/build-module/query-controls/types.js +2 -0
  220. package/build-module/query-controls/types.js.map +1 -0
  221. package/build-module/resizable-box/index.js +3 -2
  222. package/build-module/resizable-box/index.js.map +1 -1
  223. package/build-module/responsive-wrapper/index.js +20 -1
  224. package/build-module/responsive-wrapper/index.js.map +1 -1
  225. package/build-module/responsive-wrapper/types.js +2 -0
  226. package/build-module/responsive-wrapper/types.js.map +1 -0
  227. package/build-module/sandbox/index.js +37 -23
  228. package/build-module/sandbox/index.js.map +1 -1
  229. package/build-module/sandbox/types.js +2 -0
  230. package/build-module/sandbox/types.js.map +1 -0
  231. package/build-module/slot-fill/bubbles-virtually/fill.js +1 -0
  232. package/build-module/slot-fill/bubbles-virtually/fill.js.map +1 -1
  233. package/build-module/slot-fill/slot.js +1 -0
  234. package/build-module/slot-fill/slot.js.map +1 -1
  235. package/build-module/slot-fill/use-slot.js +2 -12
  236. package/build-module/slot-fill/use-slot.js.map +1 -1
  237. package/build-module/snackbar/index.js.map +1 -1
  238. package/build-module/snackbar/list.js.map +1 -1
  239. package/build-module/tab-panel/index.js +40 -7
  240. package/build-module/tab-panel/index.js.map +1 -1
  241. package/build-module/toolbar/index.js +6 -58
  242. package/build-module/toolbar/index.js.map +1 -1
  243. package/build-module/toolbar/toolbar/index.js +59 -0
  244. package/build-module/toolbar/toolbar/index.js.map +1 -0
  245. package/build-module/toolbar/{toolbar-container.js → toolbar/toolbar-container.js} +0 -0
  246. package/{build → build-module/toolbar}/toolbar/toolbar-container.js.map +1 -1
  247. package/build-module/toolbar/{toolbar-container.native.js → toolbar/toolbar-container.native.js} +0 -0
  248. package/build-module/toolbar/toolbar/toolbar-container.native.js.map +1 -0
  249. package/build-module/{toolbar-button → toolbar/toolbar-button}/index.js +1 -1
  250. package/build-module/toolbar/toolbar-button/index.js.map +1 -0
  251. package/build-module/{toolbar-button → toolbar/toolbar-button}/toolbar-button-container.js +0 -0
  252. package/build-module/toolbar/toolbar-button/toolbar-button-container.js.map +1 -0
  253. package/build-module/{toolbar-button → toolbar/toolbar-button}/toolbar-button-container.native.js +0 -0
  254. package/build-module/toolbar/toolbar-button/toolbar-button-container.native.js.map +1 -0
  255. package/build-module/{toolbar-context → toolbar/toolbar-context}/index.js +0 -0
  256. package/build-module/toolbar/toolbar-context/index.js.map +1 -0
  257. package/build-module/{toolbar-dropdown-menu → toolbar/toolbar-dropdown-menu}/index.js +1 -1
  258. package/build-module/toolbar/toolbar-dropdown-menu/index.js.map +1 -0
  259. package/build-module/{toolbar-group → toolbar/toolbar-group}/index.js +0 -0
  260. package/build-module/toolbar/toolbar-group/index.js.map +1 -0
  261. package/build-module/{toolbar-group → toolbar/toolbar-group}/toolbar-group-collapsed.js +1 -1
  262. package/build-module/toolbar/toolbar-group/toolbar-group-collapsed.js.map +1 -0
  263. package/build-module/{toolbar-group → toolbar/toolbar-group}/toolbar-group-collapsed.native.js +1 -1
  264. package/build-module/toolbar/toolbar-group/toolbar-group-collapsed.native.js.map +1 -0
  265. package/build-module/{toolbar-group → toolbar/toolbar-group}/toolbar-group-container.js +0 -0
  266. package/build-module/toolbar/toolbar-group/toolbar-group-container.js.map +1 -0
  267. package/build-module/{toolbar-group → toolbar/toolbar-group}/toolbar-group-container.native.js +0 -0
  268. package/build-module/toolbar/toolbar-group/toolbar-group-container.native.js.map +1 -0
  269. package/build-module/{toolbar-item → toolbar/toolbar-item}/index.js +0 -0
  270. package/build-module/toolbar/toolbar-item/index.js.map +1 -0
  271. package/build-module/{toolbar-item → toolbar/toolbar-item}/index.native.js +0 -0
  272. package/build-module/toolbar/toolbar-item/index.native.js.map +1 -0
  273. package/build-module/tree-grid/index.js +4 -4
  274. package/build-module/tree-grid/index.js.map +1 -1
  275. package/build-module/tree-select/index.js +2 -6
  276. package/build-module/tree-select/index.js.map +1 -1
  277. package/build-style/style-rtl.css +6 -1
  278. package/build-style/style.css +6 -1
  279. package/build-types/border-box-control/border-box-control/hook.d.ts +1 -1
  280. package/build-types/border-box-control/border-box-control-linked-button/component.d.ts +1 -1
  281. package/build-types/border-box-control/border-box-control-linked-button/hook.d.ts +171 -160
  282. package/build-types/border-box-control/border-box-control-linked-button/hook.d.ts.map +1 -1
  283. package/build-types/border-box-control/border-box-control-split-controls/hook.d.ts +1 -1
  284. package/build-types/border-control/border-control/hook.d.ts +1 -1
  285. package/build-types/border-control/border-control-dropdown/component.d.ts.map +1 -1
  286. package/build-types/border-control/border-control-dropdown/hook.d.ts +1 -1
  287. package/build-types/button/deprecated.d.ts +143 -7
  288. package/build-types/button/deprecated.d.ts.map +1 -1
  289. package/build-types/button/index.d.ts +20 -3
  290. package/build-types/button/index.d.ts.map +1 -1
  291. package/build-types/button/stories/index.d.ts +20 -0
  292. package/build-types/button/stories/index.d.ts.map +1 -0
  293. package/build-types/button/test/index.d.ts +2 -0
  294. package/build-types/button/test/index.d.ts.map +1 -0
  295. package/build-types/button/types.d.ts +134 -0
  296. package/build-types/button/types.d.ts.map +1 -0
  297. package/build-types/color-list-picker/index.d.ts +5 -0
  298. package/build-types/color-list-picker/index.d.ts.map +1 -0
  299. package/build-types/color-list-picker/types.d.ts +42 -0
  300. package/build-types/color-list-picker/types.d.ts.map +1 -0
  301. package/build-types/color-palette/index.d.ts +2 -4
  302. package/build-types/color-palette/index.d.ts.map +1 -1
  303. package/build-types/color-palette/stories/index.d.ts +2 -2
  304. package/build-types/color-palette/styles.d.ts +1 -1
  305. package/build-types/color-palette/types.d.ts +1 -1
  306. package/build-types/color-palette/types.d.ts.map +1 -1
  307. package/build-types/color-palette/utils.d.ts +14 -0
  308. package/build-types/color-palette/utils.d.ts.map +1 -0
  309. package/build-types/color-picker/component.d.ts.map +1 -1
  310. package/build-types/color-picker/styles.d.ts +2 -2
  311. package/build-types/color-picker/styles.d.ts.map +1 -1
  312. package/build-types/dashicon/types.d.ts +0 -4
  313. package/build-types/dashicon/types.d.ts.map +1 -1
  314. package/build-types/date-time/date/index.d.ts.map +1 -1
  315. package/build-types/date-time/date/styles.d.ts +3 -3
  316. package/build-types/dropdown/index.d.ts +4 -4
  317. package/build-types/dropdown/index.d.ts.map +1 -1
  318. package/build-types/dropdown/stories/index.d.ts.map +1 -1
  319. package/build-types/dropdown/types.d.ts +9 -10
  320. package/build-types/dropdown/types.d.ts.map +1 -1
  321. package/build-types/focal-point-picker/utils.d.ts.map +1 -1
  322. package/build-types/font-size-picker/styles.d.ts +2 -2
  323. package/build-types/h-stack/component.d.ts +0 -1
  324. package/build-types/h-stack/component.d.ts.map +1 -1
  325. package/build-types/input-control/input-field.d.ts.map +1 -1
  326. package/build-types/item-group/item/component.d.ts +24 -2
  327. package/build-types/item-group/item/component.d.ts.map +1 -1
  328. package/build-types/item-group/item-group/component.d.ts +23 -2
  329. package/build-types/item-group/item-group/component.d.ts.map +1 -1
  330. package/build-types/item-group/stories/index.d.ts +15 -0
  331. package/build-types/item-group/stories/index.d.ts.map +1 -0
  332. package/build-types/item-group/styles.d.ts.map +1 -1
  333. package/build-types/keyboard-shortcuts/index.d.ts +38 -0
  334. package/build-types/keyboard-shortcuts/index.d.ts.map +1 -0
  335. package/build-types/keyboard-shortcuts/stories/index.d.ts +12 -0
  336. package/build-types/keyboard-shortcuts/stories/index.d.ts.map +1 -0
  337. package/build-types/keyboard-shortcuts/test/index.d.ts +2 -0
  338. package/build-types/keyboard-shortcuts/test/index.d.ts.map +1 -0
  339. package/build-types/keyboard-shortcuts/types.d.ts +48 -0
  340. package/build-types/keyboard-shortcuts/types.d.ts.map +1 -0
  341. package/build-types/modal/index.d.ts.map +1 -1
  342. package/build-types/navigator/navigator-back-button/component.d.ts +1 -1
  343. package/build-types/navigator/navigator-back-button/hook.d.ts +2 -2
  344. package/build-types/navigator/navigator-button/component.d.ts +1 -1
  345. package/build-types/navigator/navigator-button/hook.d.ts +2 -2
  346. package/build-types/notice/index.d.ts +16 -0
  347. package/build-types/notice/index.d.ts.map +1 -0
  348. package/build-types/notice/list.d.ts +32 -0
  349. package/build-types/notice/list.d.ts.map +1 -0
  350. package/build-types/notice/stories/index.d.ts +17 -0
  351. package/build-types/notice/stories/index.d.ts.map +1 -0
  352. package/build-types/notice/test/index.d.ts +2 -0
  353. package/build-types/notice/test/index.d.ts.map +1 -0
  354. package/build-types/notice/test/list.d.ts +2 -0
  355. package/build-types/notice/test/list.d.ts.map +1 -0
  356. package/build-types/notice/types.d.ts +128 -0
  357. package/build-types/notice/types.d.ts.map +1 -0
  358. package/build-types/number-control/styles/number-control-styles.d.ts +2 -2
  359. package/build-types/number-control/styles/number-control-styles.d.ts.map +1 -1
  360. package/build-types/placeholder/stories/index.d.ts.map +1 -1
  361. package/build-types/query-controls/author-select.d.ts +4 -0
  362. package/build-types/query-controls/author-select.d.ts.map +1 -0
  363. package/build-types/query-controls/category-select.d.ts +4 -0
  364. package/build-types/query-controls/category-select.d.ts.map +1 -0
  365. package/build-types/query-controls/index.d.ts +30 -0
  366. package/build-types/query-controls/index.d.ts.map +1 -0
  367. package/build-types/query-controls/stories/index.d.ts +13 -0
  368. package/build-types/query-controls/stories/index.d.ts.map +1 -0
  369. package/build-types/query-controls/terms.d.ts +13 -0
  370. package/build-types/query-controls/terms.d.ts.map +1 -0
  371. package/build-types/query-controls/test/terms.d.ts +2 -0
  372. package/build-types/query-controls/test/terms.d.ts.map +1 -0
  373. package/build-types/query-controls/types.d.ts +131 -0
  374. package/build-types/query-controls/types.d.ts.map +1 -0
  375. package/build-types/range-control/index.d.ts +1 -1
  376. package/build-types/resizable-box/index.d.ts +6 -7
  377. package/build-types/resizable-box/index.d.ts.map +1 -1
  378. package/build-types/resizable-box/stories/index.d.ts +61 -0
  379. package/build-types/resizable-box/stories/index.d.ts.map +1 -0
  380. package/build-types/responsive-wrapper/index.d.ts +24 -0
  381. package/build-types/responsive-wrapper/index.d.ts.map +1 -0
  382. package/build-types/responsive-wrapper/stories/index.d.ts +12 -0
  383. package/build-types/responsive-wrapper/stories/index.d.ts.map +1 -0
  384. package/build-types/responsive-wrapper/types.d.ts +22 -0
  385. package/build-types/responsive-wrapper/types.d.ts.map +1 -0
  386. package/build-types/sandbox/index.d.ts +19 -0
  387. package/build-types/sandbox/index.d.ts.map +1 -0
  388. package/build-types/sandbox/stories/index.d.ts +12 -0
  389. package/build-types/sandbox/stories/index.d.ts.map +1 -0
  390. package/build-types/sandbox/test/index.d.ts +2 -0
  391. package/build-types/sandbox/test/index.d.ts.map +1 -0
  392. package/build-types/sandbox/types.d.ts +36 -0
  393. package/build-types/sandbox/types.d.ts.map +1 -0
  394. package/build-types/slot-fill/bubbles-virtually/fill.d.ts.map +1 -1
  395. package/build-types/slot-fill/use-slot.d.ts.map +1 -1
  396. package/build-types/snackbar/index.d.ts +9 -2
  397. package/build-types/snackbar/index.d.ts.map +1 -1
  398. package/build-types/snackbar/list.d.ts.map +1 -1
  399. package/build-types/snackbar/types.d.ts +15 -88
  400. package/build-types/snackbar/types.d.ts.map +1 -1
  401. package/build-types/tab-panel/index.d.ts.map +1 -1
  402. package/build-types/tab-panel/stories/index.d.ts +1 -0
  403. package/build-types/tab-panel/stories/index.d.ts.map +1 -1
  404. package/build-types/tab-panel/types.d.ts +11 -5
  405. package/build-types/tab-panel/types.d.ts.map +1 -1
  406. package/build-types/toggle-group-control/stories/index.d.ts.map +1 -1
  407. package/build-types/tree-select/index.d.ts.map +1 -1
  408. package/build-types/ui/form-group/form-group.d.ts +2 -2
  409. package/package.json +18 -17
  410. package/src/alignment-matrix-control/utils.tsx +2 -2
  411. package/src/autocomplete/autocompleter-ui.js +1 -2
  412. package/src/autocomplete/test/index.js +1 -5
  413. package/src/border-box-control/border-box-control-linked-button/component.tsx +1 -1
  414. package/src/border-box-control/border-box-control-linked-button/hook.ts +1 -1
  415. package/src/border-control/border-control-dropdown/component.tsx +9 -8
  416. package/src/box-control/test/index.js +11 -35
  417. package/src/button/README.md +49 -55
  418. package/src/button/{deprecated.js → deprecated.tsx} +19 -4
  419. package/src/button/{index.js → index.tsx} +95 -34
  420. package/src/button/stories/index.tsx +106 -0
  421. package/src/button/style.scss +3 -2
  422. package/src/button/test/{index.js → index.tsx} +30 -7
  423. package/src/button/types.ts +138 -0
  424. package/src/checkbox-control/test/index.tsx +1 -5
  425. package/src/color-list-picker/{index.js → index.tsx} +3 -2
  426. package/src/color-list-picker/types.ts +46 -0
  427. package/src/color-palette/README.md +1 -1
  428. package/src/color-palette/index.native.js +11 -4
  429. package/src/color-palette/index.tsx +11 -67
  430. package/src/color-palette/test/index.tsx +4 -14
  431. package/src/color-palette/test/utils.ts +1 -1
  432. package/src/color-palette/types.ts +1 -1
  433. package/src/color-palette/utils.ts +98 -0
  434. package/src/color-picker/component.tsx +1 -0
  435. package/src/color-picker/stories/index.js +20 -60
  436. package/src/color-picker/styles.ts +0 -5
  437. package/src/color-picker/test/index.js +6 -15
  438. package/src/combobox-control/index.js +9 -1
  439. package/src/combobox-control/test/index.js +1 -6
  440. package/src/confirm-dialog/test/index.js +9 -29
  441. package/src/custom-gradient-picker/gradient-bar/utils.js +1 -1
  442. package/src/dashicon/types.ts +0 -6
  443. package/src/date-time/date/index.tsx +2 -1
  444. package/src/date-time/date/test/index.tsx +2 -8
  445. package/src/date-time/time/test/index.tsx +9 -29
  446. package/src/dimension-control/test/index.test.js +2 -8
  447. package/src/disabled/test/index.tsx +1 -5
  448. package/src/draggable/test/index.native.js +4 -4
  449. package/src/dropdown/README.md +1 -8
  450. package/src/dropdown/index.tsx +17 -6
  451. package/src/dropdown/stories/index.tsx +3 -3
  452. package/src/dropdown/test/index.tsx +2 -8
  453. package/src/dropdown/types.ts +9 -10
  454. package/src/dropdown-menu/README.md +1 -1
  455. package/src/dropdown-menu/stories/index.js +96 -27
  456. package/src/dropdown-menu/test/index.js +2 -8
  457. package/src/external-link/test/index.tsx +1 -6
  458. package/src/focal-point-picker/stories/index.tsx +1 -1
  459. package/src/focal-point-picker/test/index.js +3 -11
  460. package/src/focal-point-picker/utils.ts +4 -1
  461. package/src/font-size-picker/test/index.tsx +14 -44
  462. package/src/form-file-upload/test/index.tsx +2 -17
  463. package/src/form-toggle/test/index.tsx +1 -5
  464. package/src/form-token-field/test/index.tsx +80 -163
  465. package/src/form-token-field/token.tsx +1 -1
  466. package/src/gradient-picker/index.js +15 -4
  467. package/src/guide/stories/index.js +14 -41
  468. package/src/guide/test/index.js +5 -17
  469. package/src/h-stack/component.tsx +0 -1
  470. package/src/higher-order/with-filters/test/index.js +24 -24
  471. package/src/higher-order/with-focus-outside/test/index.js +11 -25
  472. package/src/higher-order/with-focus-return/test/index.js +1 -5
  473. package/src/index.js +8 -6
  474. package/src/index.native.js +8 -6
  475. package/src/input-control/input-field.tsx +3 -1
  476. package/src/input-control/test/index.js +1 -6
  477. package/src/isolated-event-container/test/index.js +2 -8
  478. package/src/item-group/item/component.tsx +26 -2
  479. package/src/item-group/item-group/component.tsx +25 -2
  480. package/src/item-group/stories/index.tsx +103 -0
  481. package/src/item-group/styles.ts +1 -0
  482. package/src/item-group/test/__snapshots__/index.js.snap +11 -10
  483. package/src/keyboard-shortcuts/README.md +1 -1
  484. package/src/keyboard-shortcuts/index.tsx +93 -0
  485. package/src/keyboard-shortcuts/stories/index.tsx +60 -0
  486. package/src/keyboard-shortcuts/test/{index.js → index.tsx} +16 -6
  487. package/src/keyboard-shortcuts/types.ts +51 -0
  488. package/src/modal/index.tsx +1 -2
  489. package/src/navigable-container/test/navigable-menu.js +5 -17
  490. package/src/navigable-container/test/tababble-container.js +3 -11
  491. package/src/navigation/test/index.js +3 -11
  492. package/src/navigator/test/index.tsx +6 -20
  493. package/src/notice/README.md +89 -42
  494. package/src/notice/{index.js → index.tsx} +28 -20
  495. package/src/notice/list.tsx +72 -0
  496. package/src/notice/stories/index.tsx +119 -0
  497. package/src/notice/test/__snapshots__/{index.js.snap → index.tsx.snap} +0 -0
  498. package/src/notice/test/{index.js → index.tsx} +7 -4
  499. package/src/notice/test/{list.js → list.tsx} +0 -0
  500. package/src/notice/types.ts +136 -0
  501. package/src/number-control/index.tsx +1 -1
  502. package/src/number-control/test/index.tsx +28 -86
  503. package/src/panel/row.js +3 -3
  504. package/src/panel/stories/index.js +62 -80
  505. package/src/panel/test/body.js +2 -8
  506. package/src/placeholder/stories/index.tsx +1 -0
  507. package/src/placeholder/style.scss +1 -1
  508. package/src/query-controls/README.md +56 -56
  509. package/src/query-controls/author-select.tsx +37 -0
  510. package/src/query-controls/category-select.tsx +46 -0
  511. package/src/query-controls/index.tsx +192 -0
  512. package/src/query-controls/stories/index.tsx +205 -0
  513. package/src/query-controls/terms.ts +57 -0
  514. package/src/query-controls/test/{terms.js → terms.ts} +36 -20
  515. package/src/query-controls/types.ts +150 -0
  516. package/src/resizable-box/README.md +2 -2
  517. package/src/resizable-box/index.tsx +7 -6
  518. package/src/resizable-box/stories/index.tsx +92 -0
  519. package/src/responsive-wrapper/README.md +29 -0
  520. package/src/responsive-wrapper/{index.js → index.tsx} +23 -2
  521. package/src/responsive-wrapper/stories/index.tsx +38 -0
  522. package/src/responsive-wrapper/types.ts +20 -0
  523. package/src/sandbox/README.md +45 -2
  524. package/src/sandbox/{index.js → index.tsx} +47 -24
  525. package/src/sandbox/stories/index.tsx +32 -0
  526. package/src/sandbox/test/{index.js → index.tsx} +9 -4
  527. package/src/sandbox/types.ts +34 -0
  528. package/src/select-control/test/select-control.tsx +1 -6
  529. package/src/slot-fill/bubbles-virtually/fill.js +1 -0
  530. package/src/slot-fill/slot.js +1 -1
  531. package/src/slot-fill/stories/index.js +12 -17
  532. package/src/slot-fill/use-slot.js +6 -16
  533. package/src/snackbar/index.tsx +6 -5
  534. package/src/snackbar/list.tsx +4 -2
  535. package/src/snackbar/types.ts +18 -92
  536. package/src/style.scss +3 -3
  537. package/src/tab-panel/README.md +1 -0
  538. package/src/tab-panel/index.tsx +42 -6
  539. package/src/tab-panel/stories/index.tsx +20 -0
  540. package/src/tab-panel/style.scss +8 -0
  541. package/src/tab-panel/test/index.tsx +124 -7
  542. package/src/tab-panel/types.ts +11 -5
  543. package/src/theme/test/index.tsx +4 -4
  544. package/src/toggle-group-control/stories/index.tsx +1 -0
  545. package/src/toggle-group-control/test/index.tsx +7 -23
  546. package/src/toolbar/index.js +6 -52
  547. package/src/toolbar/stories/index.js +71 -75
  548. package/src/toolbar/test/index.js +1 -2
  549. package/src/{toolbar-group/test/index.js → toolbar/test/toolbar-group.js} +1 -1
  550. package/src/toolbar/{README.md → toolbar/README.md} +0 -0
  551. package/src/toolbar/toolbar/index.js +52 -0
  552. package/src/toolbar/{style.native.scss → toolbar/style.native.scss} +0 -0
  553. package/src/toolbar/{style.scss → toolbar/style.scss} +0 -0
  554. package/src/toolbar/{toolbar-container.js → toolbar/toolbar-container.js} +0 -0
  555. package/src/toolbar/{toolbar-container.native.js → toolbar/toolbar-container.native.js} +0 -0
  556. package/src/{toolbar-button → toolbar/toolbar-button}/README.md +0 -0
  557. package/src/{toolbar-button → toolbar/toolbar-button}/index.js +1 -1
  558. package/src/{toolbar-button → toolbar/toolbar-button}/style.scss +0 -0
  559. package/src/{toolbar-button → toolbar/toolbar-button}/toolbar-button-container.js +0 -0
  560. package/src/{toolbar-button → toolbar/toolbar-button}/toolbar-button-container.native.js +0 -0
  561. package/src/{toolbar-context → toolbar/toolbar-context}/index.js +0 -0
  562. package/src/{toolbar-dropdown-menu → toolbar/toolbar-dropdown-menu}/README.md +0 -0
  563. package/src/{toolbar-dropdown-menu → toolbar/toolbar-dropdown-menu}/index.js +1 -1
  564. package/src/{toolbar-group → toolbar/toolbar-group}/README.md +0 -0
  565. package/src/{toolbar-group → toolbar/toolbar-group}/index.js +0 -0
  566. package/src/{toolbar-group → toolbar/toolbar-group}/style.native.scss +0 -0
  567. package/src/{toolbar-group → toolbar/toolbar-group}/style.scss +0 -0
  568. package/src/{toolbar-group → toolbar/toolbar-group}/toolbar-group-collapsed.js +1 -1
  569. package/src/{toolbar-group → toolbar/toolbar-group}/toolbar-group-collapsed.native.js +1 -1
  570. package/src/{toolbar-group → toolbar/toolbar-group}/toolbar-group-container.js +0 -0
  571. package/src/{toolbar-group → toolbar/toolbar-group}/toolbar-group-container.native.js +0 -0
  572. package/src/{toolbar-item → toolbar/toolbar-item}/README.md +0 -0
  573. package/src/{toolbar-item → toolbar/toolbar-item}/index.js +0 -0
  574. package/src/{toolbar-item → toolbar/toolbar-item}/index.native.js +0 -0
  575. package/src/tools-panel/stories/index.js +3 -0
  576. package/src/tools-panel/test/index.js +1 -1
  577. package/src/tree-grid/index.js +3 -5
  578. package/src/tree-select/index.tsx +3 -6
  579. package/src/ui/context/test/context-connect.tsx +2 -0
  580. package/src/ui/context/test/wordpress-component.tsx +2 -0
  581. package/src/unit-control/test/index.tsx +21 -74
  582. package/src/utils/hooks/test/use-latest-ref.js +15 -18
  583. package/tsconfig.json +1 -11
  584. package/tsconfig.tsbuildinfo +1 -1
  585. package/build/toolbar/toolbar-container.native.js.map +0 -1
  586. package/build/toolbar-button/index.js.map +0 -1
  587. package/build/toolbar-button/toolbar-button-container.js.map +0 -1
  588. package/build/toolbar-button/toolbar-button-container.native.js.map +0 -1
  589. package/build/toolbar-context/index.js.map +0 -1
  590. package/build/toolbar-dropdown-menu/index.js.map +0 -1
  591. package/build/toolbar-group/index.js.map +0 -1
  592. package/build/toolbar-group/toolbar-group-collapsed.js.map +0 -1
  593. package/build/toolbar-group/toolbar-group-collapsed.native.js.map +0 -1
  594. package/build/toolbar-group/toolbar-group-container.js.map +0 -1
  595. package/build/toolbar-group/toolbar-group-container.native.js.map +0 -1
  596. package/build/toolbar-item/index.js.map +0 -1
  597. package/build/toolbar-item/index.native.js.map +0 -1
  598. package/build-module/toolbar/toolbar-container.js.map +0 -1
  599. package/build-module/toolbar/toolbar-container.native.js.map +0 -1
  600. package/build-module/toolbar-button/index.js.map +0 -1
  601. package/build-module/toolbar-button/toolbar-button-container.js.map +0 -1
  602. package/build-module/toolbar-button/toolbar-button-container.native.js.map +0 -1
  603. package/build-module/toolbar-context/index.js.map +0 -1
  604. package/build-module/toolbar-dropdown-menu/index.js.map +0 -1
  605. package/build-module/toolbar-group/index.js.map +0 -1
  606. package/build-module/toolbar-group/toolbar-group-collapsed.js.map +0 -1
  607. package/build-module/toolbar-group/toolbar-group-collapsed.native.js.map +0 -1
  608. package/build-module/toolbar-group/toolbar-group-container.js.map +0 -1
  609. package/build-module/toolbar-group/toolbar-group-container.native.js.map +0 -1
  610. package/build-module/toolbar-item/index.js.map +0 -1
  611. package/build-module/toolbar-item/index.native.js.map +0 -1
  612. package/src/button/stories/index.js +0 -179
  613. package/src/item-group/stories/index.js +0 -270
  614. package/src/keyboard-shortcuts/index.js +0 -56
  615. package/src/notice/list.js +0 -48
  616. package/src/notice/stories/index.js +0 -74
  617. package/src/query-controls/author-select.js +0 -23
  618. package/src/query-controls/category-select.js +0 -31
  619. package/src/query-controls/index.js +0 -121
  620. package/src/query-controls/terms.js +0 -40
  621. package/src/resizable-box/stories/index.js +0 -97
  622. package/src/toolbar-button/stories/index.js +0 -33
  623. package/src/toolbar-group/stories/index.js +0 -33
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/color-list-picker/index.js"],"names":["ColorOption","label","value","colors","disableCustomColors","enableAlpha","onChange","isOpen","setIsOpen","prev","swatch","ColorListPicker","labels","map","index","newColor","newColors","slice"],"mappings":";;;;;;;;;AAGA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AAbA;AACA;AACA;;AAIA;AACA;AACA;AAOA,SAASA,WAAT,OAOI;AAAA,MAPkB;AACrBC,IAAAA,KADqB;AAErBC,IAAAA,KAFqB;AAGrBC,IAAAA,MAHqB;AAIrBC,IAAAA,mBAJqB;AAKrBC,IAAAA,WALqB;AAMrBC,IAAAA;AANqB,GAOlB;AACH,QAAM,CAAEC,MAAF,EAAUC,SAAV,IAAwB,uBAAU,KAAV,CAA9B;AACA,SACC,qDACC,4BAAC,eAAD;AACC,IAAA,SAAS,EAAC,6CADX;AAEC,IAAA,OAAO,EAAG,MAAMA,SAAS,CAAIC,IAAF,IAAY,CAAEA,IAAhB;AAF1B,KAIC,4BAAC,cAAD;AAAQ,IAAA,OAAO,EAAC,YAAhB;AAA6B,IAAA,OAAO,EAAG;AAAvC,KACGP,KAAK,GACN,4BAAC,uBAAD;AACC,IAAA,UAAU,EAAGA,KADd;AAEC,IAAA,SAAS,EAAC;AAFX,IADM,GAMN,4BAAC,aAAD;AAAM,IAAA,IAAI,EAAGQ;AAAb,IAPF,EASC,0CAAQT,KAAR,CATD,CAJD,CADD,EAiBGM,MAAM,IACP,4BAAC,qBAAD;AACC,IAAA,SAAS,EAAC,4CADX;AAEC,IAAA,MAAM,EAAGJ,MAFV;AAGC,IAAA,KAAK,EAAGD,KAHT;AAIC,IAAA,SAAS,EAAG,KAJb;AAKC,IAAA,QAAQ,EAAGI,QALZ;AAMC,IAAA,mBAAmB,EAAGF,mBANvB;AAOC,IAAA,WAAW,EAAGC;AAPf,IAlBF,CADD;AA+BA;;AAED,SAASM,eAAT,QAOI;AAAA,MAPsB;AACzBR,IAAAA,MADyB;AAEzBS,IAAAA,MAFyB;AAGzBV,IAAAA,KAAK,GAAG,EAHiB;AAIzBE,IAAAA,mBAJyB;AAKzBC,IAAAA,WALyB;AAMzBC,IAAAA;AANyB,GAOtB;AACH,SACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACGM,MAAM,CAACC,GAAP,CAAY,CAAEZ,KAAF,EAASa,KAAT,KACb,4BAAC,WAAD;AACC,IAAA,GAAG,EAAGA,KADP;AAEC,IAAA,KAAK,EAAGb,KAFT;AAGC,IAAA,KAAK,EAAGC,KAAK,CAAEY,KAAF,CAHd;AAIC,IAAA,MAAM,EAAGX,MAJV;AAKC,IAAA,mBAAmB,EAAGC,mBALvB;AAMC,IAAA,WAAW,EAAGC,WANf;AAOC,IAAA,QAAQ,EAAKU,QAAF,IAAgB;AAC1B,YAAMC,SAAS,GAAGd,KAAK,CAACe,KAAN,EAAlB;AACAD,MAAAA,SAAS,CAAEF,KAAF,CAAT,GAAqBC,QAArB;AACAT,MAAAA,QAAQ,CAAEU,SAAF,CAAR;AACA;AAXF,IADC,CADH,CADD;AAmBA;;eAEcL,e","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState } from '@wordpress/element';\nimport { swatch } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport Button from '../button';\nimport ColorPalette from '../color-palette';\nimport ColorIndicator from '../color-indicator';\nimport Icon from '../icon';\nimport { HStack } from '../h-stack';\n\nfunction ColorOption( {\n\tlabel,\n\tvalue,\n\tcolors,\n\tdisableCustomColors,\n\tenableAlpha,\n\tonChange,\n} ) {\n\tconst [ isOpen, setIsOpen ] = useState( false );\n\treturn (\n\t\t<>\n\t\t\t<Button\n\t\t\t\tclassName=\"components-color-list-picker__swatch-button\"\n\t\t\t\tonClick={ () => setIsOpen( ( prev ) => ! prev ) }\n\t\t\t>\n\t\t\t\t<HStack justify=\"flex-start\" spacing={ 2 }>\n\t\t\t\t\t{ value ? (\n\t\t\t\t\t\t<ColorIndicator\n\t\t\t\t\t\t\tcolorValue={ value }\n\t\t\t\t\t\t\tclassName=\"components-color-list-picker__swatch-color\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<Icon icon={ swatch } />\n\t\t\t\t\t) }\n\t\t\t\t\t<span>{ label }</span>\n\t\t\t\t</HStack>\n\t\t\t</Button>\n\t\t\t{ isOpen && (\n\t\t\t\t<ColorPalette\n\t\t\t\t\tclassName=\"components-color-list-picker__color-picker\"\n\t\t\t\t\tcolors={ colors }\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\tclearable={ false }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\tdisableCustomColors={ disableCustomColors }\n\t\t\t\t\tenableAlpha={ enableAlpha }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nfunction ColorListPicker( {\n\tcolors,\n\tlabels,\n\tvalue = [],\n\tdisableCustomColors,\n\tenableAlpha,\n\tonChange,\n} ) {\n\treturn (\n\t\t<div className=\"components-color-list-picker\">\n\t\t\t{ labels.map( ( label, index ) => (\n\t\t\t\t<ColorOption\n\t\t\t\t\tkey={ index }\n\t\t\t\t\tlabel={ label }\n\t\t\t\t\tvalue={ value[ index ] }\n\t\t\t\t\tcolors={ colors }\n\t\t\t\t\tdisableCustomColors={ disableCustomColors }\n\t\t\t\t\tenableAlpha={ enableAlpha }\n\t\t\t\t\tonChange={ ( newColor ) => {\n\t\t\t\t\t\tconst newColors = value.slice();\n\t\t\t\t\t\tnewColors[ index ] = newColor;\n\t\t\t\t\t\tonChange( newColors );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t</div>\n\t);\n}\n\nexport default ColorListPicker;\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/color-list-picker/index.tsx"],"names":["ColorOption","label","value","colors","disableCustomColors","enableAlpha","onChange","isOpen","setIsOpen","prev","swatch","ColorListPicker","labels","map","index","newColor","newColors","slice"],"mappings":";;;;;;;;;AAGA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AAbA;AACA;AACA;;AAIA;AACA;AACA;AAQA,SAASA,WAAT,OAOsB;AAAA,MAPA;AACrBC,IAAAA,KADqB;AAErBC,IAAAA,KAFqB;AAGrBC,IAAAA,MAHqB;AAIrBC,IAAAA,mBAJqB;AAKrBC,IAAAA,WALqB;AAMrBC,IAAAA;AANqB,GAOA;AACrB,QAAM,CAAEC,MAAF,EAAUC,SAAV,IAAwB,uBAAU,KAAV,CAA9B;AACA,SACC,qDACC,4BAAC,eAAD;AACC,IAAA,SAAS,EAAC,6CADX;AAEC,IAAA,OAAO,EAAG,MAAMA,SAAS,CAAIC,IAAF,IAAY,CAAEA,IAAhB;AAF1B,KAIC,4BAAC,cAAD;AAAQ,IAAA,OAAO,EAAC,YAAhB;AAA6B,IAAA,OAAO,EAAG;AAAvC,KACGP,KAAK,GACN,4BAAC,uBAAD;AACC,IAAA,UAAU,EAAGA,KADd;AAEC,IAAA,SAAS,EAAC;AAFX,IADM,GAMN,4BAAC,aAAD;AAAM,IAAA,IAAI,EAAGQ;AAAb,IAPF,EASC,0CAAQT,KAAR,CATD,CAJD,CADD,EAiBGM,MAAM,IACP,4BAAC,qBAAD;AACC,IAAA,SAAS,EAAC,4CADX;AAEC,IAAA,MAAM,EAAGJ,MAFV;AAGC,IAAA,KAAK,EAAGD,KAHT;AAIC,IAAA,SAAS,EAAG,KAJb;AAKC,IAAA,QAAQ,EAAGI,QALZ;AAMC,IAAA,mBAAmB,EAAGF,mBANvB;AAOC,IAAA,WAAW,EAAGC;AAPf,IAlBF,CADD;AA+BA;;AAED,SAASM,eAAT,QAO0B;AAAA,MAPA;AACzBR,IAAAA,MADyB;AAEzBS,IAAAA,MAFyB;AAGzBV,IAAAA,KAAK,GAAG,EAHiB;AAIzBE,IAAAA,mBAJyB;AAKzBC,IAAAA,WALyB;AAMzBC,IAAAA;AANyB,GAOA;AACzB,SACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACGM,MAAM,CAACC,GAAP,CAAY,CAAEZ,KAAF,EAASa,KAAT,KACb,4BAAC,WAAD;AACC,IAAA,GAAG,EAAGA,KADP;AAEC,IAAA,KAAK,EAAGb,KAFT;AAGC,IAAA,KAAK,EAAGC,KAAK,CAAEY,KAAF,CAHd;AAIC,IAAA,MAAM,EAAGX,MAJV;AAKC,IAAA,mBAAmB,EAAGC,mBALvB;AAMC,IAAA,WAAW,EAAGC,WANf;AAOC,IAAA,QAAQ,EAAKU,QAAF,IAAgB;AAC1B,YAAMC,SAAS,GAAGd,KAAK,CAACe,KAAN,EAAlB;AACAD,MAAAA,SAAS,CAAEF,KAAF,CAAT,GAAqBC,QAArB;AACAT,MAAAA,QAAQ,CAAEU,SAAF,CAAR;AACA;AAXF,IADC,CADH,CADD;AAmBA;;eAEcL,e","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState } from '@wordpress/element';\nimport { swatch } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport Button from '../button';\nimport ColorPalette from '../color-palette';\nimport ColorIndicator from '../color-indicator';\nimport Icon from '../icon';\nimport { HStack } from '../h-stack';\nimport type { ColorListPickerProps, ColorOptionProps } from './types';\n\nfunction ColorOption( {\n\tlabel,\n\tvalue,\n\tcolors,\n\tdisableCustomColors,\n\tenableAlpha,\n\tonChange,\n}: ColorOptionProps ) {\n\tconst [ isOpen, setIsOpen ] = useState( false );\n\treturn (\n\t\t<>\n\t\t\t<Button\n\t\t\t\tclassName=\"components-color-list-picker__swatch-button\"\n\t\t\t\tonClick={ () => setIsOpen( ( prev ) => ! prev ) }\n\t\t\t>\n\t\t\t\t<HStack justify=\"flex-start\" spacing={ 2 }>\n\t\t\t\t\t{ value ? (\n\t\t\t\t\t\t<ColorIndicator\n\t\t\t\t\t\t\tcolorValue={ value }\n\t\t\t\t\t\t\tclassName=\"components-color-list-picker__swatch-color\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<Icon icon={ swatch } />\n\t\t\t\t\t) }\n\t\t\t\t\t<span>{ label }</span>\n\t\t\t\t</HStack>\n\t\t\t</Button>\n\t\t\t{ isOpen && (\n\t\t\t\t<ColorPalette\n\t\t\t\t\tclassName=\"components-color-list-picker__color-picker\"\n\t\t\t\t\tcolors={ colors }\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\tclearable={ false }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\tdisableCustomColors={ disableCustomColors }\n\t\t\t\t\tenableAlpha={ enableAlpha }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nfunction ColorListPicker( {\n\tcolors,\n\tlabels,\n\tvalue = [],\n\tdisableCustomColors,\n\tenableAlpha,\n\tonChange,\n}: ColorListPickerProps ) {\n\treturn (\n\t\t<div className=\"components-color-list-picker\">\n\t\t\t{ labels.map( ( label, index ) => (\n\t\t\t\t<ColorOption\n\t\t\t\t\tkey={ index }\n\t\t\t\t\tlabel={ label }\n\t\t\t\t\tvalue={ value[ index ] }\n\t\t\t\t\tcolors={ colors }\n\t\t\t\t\tdisableCustomColors={ disableCustomColors }\n\t\t\t\t\tenableAlpha={ enableAlpha }\n\t\t\t\t\tonChange={ ( newColor ) => {\n\t\t\t\t\t\tconst newColors = value.slice();\n\t\t\t\t\t\tnewColors[ index ] = newColor;\n\t\t\t\t\t\tonChange( newColors );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t</div>\n\t);\n}\n\nexport default ColorListPicker;\n"]}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.ColorPalette = void 0;
9
9
  exports.CustomColorPickerDropdown = CustomColorPickerDropdown;
10
- exports.showTransparentBackground = exports.extractColorNameFromCurrentValue = exports.default = void 0;
10
+ exports.default = void 0;
11
11
 
12
12
  var _element = require("@wordpress/element");
13
13
 
@@ -37,6 +37,8 @@ var _styles = require("./styles");
37
37
 
38
38
  var _dropdownContentWrapper = _interopRequireDefault(require("../dropdown/dropdown-content-wrapper"));
39
39
 
40
+ var _utils = require("./utils");
41
+
40
42
  /**
41
43
  * External dependencies
42
44
  */
@@ -154,57 +156,8 @@ function CustomColorPickerDropdown(_ref5) {
154
156
  }, props));
155
157
  }
156
158
 
157
- const extractColorNameFromCurrentValue = function (currentValue) {
158
- let colors = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
159
- let showMultiplePalettes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
160
-
161
- if (!currentValue) {
162
- return '';
163
- }
164
-
165
- const currentValueIsCssVariable = /^var\(/.test(currentValue);
166
- const normalizedCurrentValue = currentValueIsCssVariable ? currentValue : (0, _colord.colord)(currentValue).toHex(); // Normalize format of `colors` to simplify the following loop
167
-
168
- const colorPalettes = showMultiplePalettes ? colors : [{
169
- colors: colors
170
- }];
171
-
172
- for (const {
173
- colors: paletteColors
174
- } of colorPalettes) {
175
- for (const {
176
- name: colorName,
177
- color: colorValue
178
- } of paletteColors) {
179
- const normalizedColorValue = currentValueIsCssVariable ? colorValue : (0, _colord.colord)(colorValue).toHex();
180
-
181
- if (normalizedCurrentValue === normalizedColorValue) {
182
- return colorName;
183
- }
184
- }
185
- } // translators: shown when the user has picked a custom color (i.e not in the palette of colors).
186
-
187
-
188
- return (0, _i18n.__)('Custom');
189
- };
190
-
191
- exports.extractColorNameFromCurrentValue = extractColorNameFromCurrentValue;
192
-
193
- const showTransparentBackground = currentValue => {
194
- if (typeof currentValue === 'undefined') {
195
- return true;
196
- }
197
-
198
- return (0, _colord.colord)(currentValue).alpha() === 0;
199
- };
200
-
201
- exports.showTransparentBackground = showTransparentBackground;
202
-
203
- const areColorsMultiplePalette = colors => {
204
- return colors.every(colorObj => Array.isArray(colorObj.colors));
205
- };
206
-
207
159
  function UnforwardedColorPalette(props, forwardedRef) {
160
+ const customColorPaletteRef = (0, _element.useRef)(null);
208
161
  const {
209
162
  clearable = true,
210
163
  colors = [],
@@ -216,19 +169,13 @@ function UnforwardedColorPalette(props, forwardedRef) {
216
169
  ...otherProps
217
170
  } = props;
218
171
  const clearColor = (0, _element.useCallback)(() => onChange(undefined), [onChange]);
219
- const hasMultipleColorOrigins = colors.length > 0 && colors[0].colors !== undefined;
220
- const buttonLabelName = (0, _element.useMemo)(() => extractColorNameFromCurrentValue(value, colors, hasMultipleColorOrigins), [value, colors, hasMultipleColorOrigins]); // Make sure that the `colors` array has a valid format.
221
-
222
- if (colors.length > 0 && hasMultipleColorOrigins !== areColorsMultiplePalette(colors)) {
223
- // eslint-disable-next-line no-console
224
- console.warn('wp.components.ColorPalette: please specify a valid format for the `colors` prop. ');
225
- return null;
226
- }
172
+ const hasMultipleColorOrigins = (0, _utils.isMultiplePaletteArray)(colors);
173
+ const buttonLabelName = (0, _element.useMemo)(() => (0, _utils.extractColorNameFromCurrentValue)(value, colors, hasMultipleColorOrigins), [value, colors, hasMultipleColorOrigins]);
227
174
 
228
175
  const renderCustomColorPicker = () => (0, _element.createElement)(_dropdownContentWrapper.default, {
229
176
  paddingSize: "none"
230
177
  }, (0, _element.createElement)(_colorPicker.ColorPicker, {
231
- color: value,
178
+ color: (0, _utils.normalizeColorValue)(value, customColorPaletteRef),
232
179
  onChange: color => onChange(color),
233
180
  enableAlpha: enableAlpha
234
181
  }));
@@ -259,6 +206,7 @@ function UnforwardedColorPalette(props, forwardedRef) {
259
206
  } = _ref6;
260
207
  return (0, _element.createElement)(_flex.Flex, {
261
208
  as: 'button',
209
+ ref: customColorPaletteRef,
262
210
  justify: "space-between",
263
211
  align: "flex-start",
264
212
  className: "components-color-palette__custom-color",
@@ -266,7 +214,7 @@ function UnforwardedColorPalette(props, forwardedRef) {
266
214
  "aria-haspopup": "true",
267
215
  onClick: onToggle,
268
216
  "aria-label": customColorAccessibleLabel,
269
- style: showTransparentBackground(value) ? {
217
+ style: (0, _utils.showTransparentBackground)(value) ? {
270
218
  color: '#000'
271
219
  } : {
272
220
  background: value,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/color-palette/index.tsx"],"names":["namesPlugin","a11yPlugin","SinglePalette","className","clearColor","colors","onChange","value","actions","colorOptions","map","index","color","name","colordColor","isSelected","fill","contrast","backgroundColor","MultiplePalettes","length","colorPalette","newColor","CustomColorPickerDropdown","isRenderedInSidebar","popoverProps","receivedPopoverProps","props","shift","placement","offset","extractColorNameFromCurrentValue","currentValue","showMultiplePalettes","currentValueIsCssVariable","test","normalizedCurrentValue","toHex","colorPalettes","paletteColors","colorName","colorValue","normalizedColorValue","showTransparentBackground","alpha","areColorsMultiplePalette","every","colorObj","Array","isArray","UnforwardedColorPalette","forwardedRef","clearable","disableCustomColors","enableAlpha","__experimentalIsRenderedInSidebar","otherProps","undefined","hasMultipleColorOrigins","buttonLabelName","console","warn","renderCustomColorPicker","valueWithoutLeadingHash","startsWith","substring","customColorAccessibleLabel","paletteCommonProps","isOpen","onToggle","background","Truncate","ColorPalette"],"mappings":";;;;;;;;;;;AAYA;;;;AARA;;AACA;;AACA;;AAKA;;AAMA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAxBA;AACA;AACA;;AAMA;AACA;AACA;;AAIA;AACA;AACA;AAoBA,oBAAQ,CAAEA,cAAF,EAAeC,aAAf,CAAR;;AAEA,SAASC,aAAT,OAOwB;AAAA,MAPA;AACvBC,IAAAA,SADuB;AAEvBC,IAAAA,UAFuB;AAGvBC,IAAAA,MAHuB;AAIvBC,IAAAA,QAJuB;AA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AAE;AAAEM,QAAAA,MAAF;AAAUC,QAAAA;AAAV,OAAF;AAAA,aACd,4BAAC,UAAD;AACC,QAAA,EAAE,EAAG,QADN;AAEC,QAAA,OAAO,EAAC,eAFT;AAGC,QAAA,KAAK,EAAC,YAHP;AAIC,QAAA,SAAS,EAAC,wCAJX;AAKC,yBAAgBD,MALjB;AAMC,yBAAc,MANf;AAOC,QAAA,OAAO,EAAGC,QAPX;AAQC,sBAAaH,0BARd;AASC,QAAA,KAAK,EACJvB,yBAAyB,CAAEpC,KAAF,CAAzB,GACG;AAAEK,UAAAA,KAAK,EAAE;AAAT,SADH,GAEG;AACA0D,UAAAA,UAAU,EAAE/D,KADZ;AAEAK,UAAAA,KAAK,EACJE,WAAW,CAACG,QAAZ,KACAH,WAAW,CAACG,QAAZ,CAAsB,MAAtB,CADA,GAEG,MAFH,GAGG;AANJ;AAZL,SAsBC,4BAAC,cAAD;AACC,QAAA,OAAO,MADR;AAEC,QAAA,EAAE,EAAGsD,kBAFN;AAGC,QAAA,SAAS,EAAC;AAHX,SAKGZ,eALH,CAtBD,EA6BC,4BAAC,cAAD;AACC,QAAA,EAAE,EAAC,MADJ;AAEC,QAAA,SAAS,EAAC;AAFX,SAIGI,uBAJH,CA7BD,CADc;AAAA;AAHhB,IAFF,EA6CGL,uBAAuB,GACxB,4BAAC,gBAAD,6BACMS,kBADN;AAEC,IAAA,MAAM,EAAG9D;AAFV,KADwB,GAMxB,4BAAC,aAAD,6BACM8D,kBADN;AAEC,IAAA,MAAM,EAAG9D;AAFV,KAnDF,CADD;AA2DA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAMmE,YAAY,GAAG,yBAAYtB,uBAAZ,CAArB;;eAEQsB,Y","sourcesContent":["/**\n * External dependencies\n */\nimport type { ForwardedRef } from 'react';\nimport { colord, extend } from 'colord';\nimport namesPlugin from 'colord/plugins/names';\nimport a11yPlugin from 'colord/plugins/a11y';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useCallback, useMemo, forwardRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport Dropdown from '../dropdown';\nimport { ColorPicker } from '../color-picker';\nimport CircularOptionPicker from '../circular-option-picker';\nimport { VStack } from '../v-stack';\nimport { Flex, FlexItem } from '../flex';\nimport { Truncate } from '../truncate';\nimport { ColorHeading } from './styles';\nimport DropdownContentWrapper from '../dropdown/dropdown-content-wrapper';\nimport type {\n\tColorObject,\n\tColorPaletteProps,\n\tCustomColorPickerDropdownProps,\n\tMultiplePalettesProps,\n\tPaletteObject,\n\tSinglePaletteProps,\n} from './types';\nimport type { WordPressComponentProps } from '../ui/context';\nimport type { DropdownProps } from '../dropdown/types';\n\nextend( [ namesPlugin, a11yPlugin ] );\n\nfunction SinglePalette( {\n\tclassName,\n\tclearColor,\n\tcolors,\n\tonChange,\n\tvalue,\n\tactions,\n}: SinglePaletteProps ) {\n\tconst colorOptions = useMemo( () => {\n\t\treturn colors.map( ( { color, name }, index ) => {\n\t\t\tconst colordColor = colord( color );\n\t\t\tconst isSelected = value === color;\n\n\t\t\treturn (\n\t\t\t\t<CircularOptionPicker.Option\n\t\t\t\t\tkey={ `${ color }-${ index }` }\n\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\tselectedIconProps={\n\t\t\t\t\t\tisSelected\n\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\tfill:\n\t\t\t\t\t\t\t\t\t\tcolordColor.contrast() >\n\t\t\t\t\t\t\t\t\t\tcolordColor.contrast( '#000' )\n\t\t\t\t\t\t\t\t\t\t\t? '#fff'\n\t\t\t\t\t\t\t\t\t\t\t: '#000',\n\t\t\t\t\t\t\t }\n\t\t\t\t\t\t\t: {}\n\t\t\t\t\t}\n\t\t\t\t\ttooltipText={\n\t\t\t\t\t\tname ||\n\t\t\t\t\t\t// translators: %s: color hex code e.g: \"#f00\".\n\t\t\t\t\t\tsprintf( __( 'Color code: %s' ), color )\n\t\t\t\t\t}\n\t\t\t\t\tstyle={ { backgroundColor: color, color } }\n\t\t\t\t\tonClick={\n\t\t\t\t\t\tisSelected ? clearColor : () => onChange( color, index )\n\t\t\t\t\t}\n\t\t\t\t\taria-label={\n\t\t\t\t\t\tname\n\t\t\t\t\t\t\t? // translators: %s: The name of the color e.g: \"vivid red\".\n\t\t\t\t\t\t\t sprintf( __( 'Color: %s' ), name )\n\t\t\t\t\t\t\t: // translators: %s: color hex code e.g: \"#f00\".\n\t\t\t\t\t\t\t sprintf( __( 'Color code: %s' ), color )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t);\n\t\t} );\n\t}, [ colors, value, onChange, clearColor ] );\n\n\treturn (\n\t\t<CircularOptionPicker\n\t\t\tclassName={ className }\n\t\t\toptions={ colorOptions }\n\t\t\tactions={ actions }\n\t\t/>\n\t);\n}\n\nfunction MultiplePalettes( {\n\tclassName,\n\tclearColor,\n\tcolors,\n\tonChange,\n\tvalue,\n\tactions,\n}: MultiplePalettesProps ) {\n\tif ( colors.length === 0 ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<VStack spacing={ 3 } className={ className }>\n\t\t\t{ colors.map( ( { name, colors: colorPalette }, index ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<VStack spacing={ 2 } key={ index }>\n\t\t\t\t\t\t<ColorHeading>{ name }</ColorHeading>\n\t\t\t\t\t\t<SinglePalette\n\t\t\t\t\t\t\tclearColor={ clearColor }\n\t\t\t\t\t\t\tcolors={ colorPalette }\n\t\t\t\t\t\t\tonChange={ ( newColor ) =>\n\t\t\t\t\t\t\t\tonChange( newColor, index )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\t\tactions={\n\t\t\t\t\t\t\t\tcolors.length === index + 1 ? actions : null\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</VStack>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</VStack>\n\t);\n}\n\nexport function CustomColorPickerDropdown( {\n\tisRenderedInSidebar,\n\tpopoverProps: receivedPopoverProps,\n\t...props\n}: CustomColorPickerDropdownProps ) {\n\tconst popoverProps = useMemo< DropdownProps[ 'popoverProps' ] >(\n\t\t() => ( {\n\t\t\tshift: true,\n\t\t\t...( isRenderedInSidebar\n\t\t\t\t? {\n\t\t\t\t\t\t// When in the sidebar: open to the left (stacking),\n\t\t\t\t\t\t// leaving the same gap as the parent popover.\n\t\t\t\t\t\tplacement: 'left-start',\n\t\t\t\t\t\toffset: 34,\n\t\t\t\t }\n\t\t\t\t: {\n\t\t\t\t\t\t// Default behavior: open below the anchor\n\t\t\t\t\t\tplacement: 'bottom',\n\t\t\t\t\t\toffset: 8,\n\t\t\t\t } ),\n\t\t\t...receivedPopoverProps,\n\t\t} ),\n\t\t[ isRenderedInSidebar, receivedPopoverProps ]\n\t);\n\n\treturn (\n\t\t<Dropdown\n\t\t\tcontentClassName=\"components-color-palette__custom-color-dropdown-content\"\n\t\t\tpopoverProps={ popoverProps }\n\t\t\t{ ...props }\n\t\t/>\n\t);\n}\n\nexport const extractColorNameFromCurrentValue = (\n\tcurrentValue?: ColorPaletteProps[ 'value' ],\n\tcolors: ColorPaletteProps[ 'colors' ] = [],\n\tshowMultiplePalettes: boolean = false\n) => {\n\tif ( ! currentValue ) {\n\t\treturn '';\n\t}\n\n\tconst currentValueIsCssVariable = /^var\\(/.test( currentValue );\n\tconst normalizedCurrentValue = currentValueIsCssVariable\n\t\t? currentValue\n\t\t: colord( currentValue ).toHex();\n\n\t// Normalize format of `colors` to simplify the following loop\n\ttype normalizedPaletteObject = { colors: ColorObject[] };\n\tconst colorPalettes: normalizedPaletteObject[] = showMultiplePalettes\n\t\t? ( colors as PaletteObject[] )\n\t\t: [ { colors: colors as ColorObject[] } ];\n\tfor ( const { colors: paletteColors } of colorPalettes ) {\n\t\tfor ( const { name: colorName, color: colorValue } of paletteColors ) {\n\t\t\tconst normalizedColorValue = currentValueIsCssVariable\n\t\t\t\t? colorValue\n\t\t\t\t: colord( colorValue ).toHex();\n\n\t\t\tif ( normalizedCurrentValue === normalizedColorValue ) {\n\t\t\t\treturn colorName;\n\t\t\t}\n\t\t}\n\t}\n\n\t// translators: shown when the user has picked a custom color (i.e not in the palette of colors).\n\treturn __( 'Custom' );\n};\n\nexport const showTransparentBackground = ( currentValue?: string ) => {\n\tif ( typeof currentValue === 'undefined' ) {\n\t\treturn true;\n\t}\n\treturn colord( currentValue ).alpha() === 0;\n};\n\nconst areColorsMultiplePalette = (\n\tcolors: NonNullable< ColorPaletteProps[ 'colors' ] >\n): colors is PaletteObject[] => {\n\treturn colors.every( ( colorObj ) =>\n\t\tArray.isArray( ( colorObj as PaletteObject ).colors )\n\t);\n};\n\nfunction UnforwardedColorPalette(\n\tprops: WordPressComponentProps< ColorPaletteProps, 'div' >,\n\tforwardedRef: ForwardedRef< any >\n) {\n\tconst {\n\t\tclearable = true,\n\t\tcolors = [],\n\t\tdisableCustomColors = false,\n\t\tenableAlpha = false,\n\t\tonChange,\n\t\tvalue,\n\t\t__experimentalIsRenderedInSidebar = false,\n\t\t...otherProps\n\t} = props;\n\tconst clearColor = useCallback( () => onChange( undefined ), [ onChange ] );\n\n\tconst hasMultipleColorOrigins =\n\t\tcolors.length > 0 &&\n\t\t( colors as PaletteObject[] )[ 0 ].colors !== undefined;\n\tconst buttonLabelName = useMemo(\n\t\t() =>\n\t\t\textractColorNameFromCurrentValue(\n\t\t\t\tvalue,\n\t\t\t\tcolors,\n\t\t\t\thasMultipleColorOrigins\n\t\t\t),\n\t\t[ value, colors, hasMultipleColorOrigins ]\n\t);\n\n\t// Make sure that the `colors` array has a valid format.\n\tif (\n\t\tcolors.length > 0 &&\n\t\thasMultipleColorOrigins !== areColorsMultiplePalette( colors )\n\t) {\n\t\t// eslint-disable-next-line no-console\n\t\tconsole.warn(\n\t\t\t'wp.components.ColorPalette: please specify a valid format for the `colors` prop. '\n\t\t);\n\t\treturn null;\n\t}\n\n\tconst renderCustomColorPicker = () => (\n\t\t<DropdownContentWrapper paddingSize=\"none\">\n\t\t\t<ColorPicker\n\t\t\t\tcolor={ value }\n\t\t\t\tonChange={ ( color ) => onChange( color ) }\n\t\t\t\tenableAlpha={ enableAlpha }\n\t\t\t/>\n\t\t</DropdownContentWrapper>\n\t);\n\n\tconst colordColor = colord( value ?? '' );\n\n\tconst valueWithoutLeadingHash = value?.startsWith( '#' )\n\t\t? value.substring( 1 )\n\t\t: value ?? '';\n\n\tconst customColorAccessibleLabel = !! valueWithoutLeadingHash\n\t\t? sprintf(\n\t\t\t\t// translators: %1$s: The name of the color e.g: \"vivid red\". %2$s: The color's hex code e.g: \"#f00\".\n\t\t\t\t__(\n\t\t\t\t\t'Custom color picker. The currently selected color is called \"%1$s\" and has a value of \"%2$s\".'\n\t\t\t\t),\n\t\t\t\tbuttonLabelName,\n\t\t\t\tvalueWithoutLeadingHash\n\t\t )\n\t\t: __( 'Custom color picker.' );\n\n\tconst paletteCommonProps = {\n\t\tclearable,\n\t\tclearColor,\n\t\tonChange,\n\t\tvalue,\n\t\tactions: !! clearable && (\n\t\t\t<CircularOptionPicker.ButtonAction onClick={ clearColor }>\n\t\t\t\t{ __( 'Clear' ) }\n\t\t\t</CircularOptionPicker.ButtonAction>\n\t\t),\n\t};\n\n\treturn (\n\t\t<VStack spacing={ 3 } ref={ forwardedRef } { ...otherProps }>\n\t\t\t{ ! disableCustomColors && (\n\t\t\t\t<CustomColorPickerDropdown\n\t\t\t\t\tisRenderedInSidebar={ __experimentalIsRenderedInSidebar }\n\t\t\t\t\trenderContent={ renderCustomColorPicker }\n\t\t\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t\t\t<Flex\n\t\t\t\t\t\t\tas={ 'button' }\n\t\t\t\t\t\t\tjustify=\"space-between\"\n\t\t\t\t\t\t\talign=\"flex-start\"\n\t\t\t\t\t\t\tclassName=\"components-color-palette__custom-color\"\n\t\t\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\t\t\taria-haspopup=\"true\"\n\t\t\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\t\t\taria-label={ customColorAccessibleLabel }\n\t\t\t\t\t\t\tstyle={\n\t\t\t\t\t\t\t\tshowTransparentBackground( value )\n\t\t\t\t\t\t\t\t\t? { color: '#000' }\n\t\t\t\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\t\t\t\tbackground: value,\n\t\t\t\t\t\t\t\t\t\t\tcolor:\n\t\t\t\t\t\t\t\t\t\t\t\tcolordColor.contrast() >\n\t\t\t\t\t\t\t\t\t\t\t\tcolordColor.contrast( '#000' )\n\t\t\t\t\t\t\t\t\t\t\t\t\t? '#fff'\n\t\t\t\t\t\t\t\t\t\t\t\t\t: '#000',\n\t\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\t\t<FlexItem\n\t\t\t\t\t\t\t\tisBlock\n\t\t\t\t\t\t\t\tas={ Truncate }\n\t\t\t\t\t\t\t\tclassName=\"components-color-palette__custom-color-name\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ buttonLabelName }\n\t\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t\t\t<FlexItem\n\t\t\t\t\t\t\t\tas=\"span\"\n\t\t\t\t\t\t\t\tclassName=\"components-color-palette__custom-color-value\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ valueWithoutLeadingHash }\n\t\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t\t</Flex>\n\t\t\t\t\t) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ hasMultipleColorOrigins ? (\n\t\t\t\t<MultiplePalettes\n\t\t\t\t\t{ ...paletteCommonProps }\n\t\t\t\t\tcolors={ colors as PaletteObject[] }\n\t\t\t\t/>\n\t\t\t) : (\n\t\t\t\t<SinglePalette\n\t\t\t\t\t{ ...paletteCommonProps }\n\t\t\t\t\tcolors={ colors as ColorObject[] }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</VStack>\n\t);\n}\n\n/**\n * Allows the user to pick a color from a list of pre-defined color entries.\n *\n * ```jsx\n * import { ColorPalette } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * const MyColorPalette = () => {\n * const [ color, setColor ] = useState ( '#f00' )\n * const colors = [\n * { name: 'red', color: '#f00' },\n * { name: 'white', color: '#fff' },\n * { name: 'blue', color: '#00f' },\n * ];\n * return (\n * <ColorPalette\n * colors={ colors }\n * value={ color }\n * onChange={ ( color ) => setColor( color ) }\n * />\n * );\n * } );\n * ```\n */\nexport const ColorPalette = forwardRef( UnforwardedColorPalette );\n\nexport default ColorPalette;\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/color-palette/index.tsx"],"names":["namesPlugin","a11yPlugin","SinglePalette","className","clearColor","colors","onChange","value","actions","colorOptions","map","index","color","name","colordColor","isSelected","fill","contrast","backgroundColor","MultiplePalettes","length","colorPalette","newColor","CustomColorPickerDropdown","isRenderedInSidebar","popoverProps","receivedPopoverProps","props","shift","placement","offset","UnforwardedColorPalette","forwardedRef","customColorPaletteRef","clearable","disableCustomColors","enableAlpha","__experimentalIsRenderedInSidebar","otherProps","undefined","hasMultipleColorOrigins","buttonLabelName","renderCustomColorPicker","valueWithoutLeadingHash","startsWith","substring","customColorAccessibleLabel","paletteCommonProps","isOpen","onToggle","background","Truncate","ColorPalette"],"mappings":";;;;;;;;;;;AAYA;;;;AARA;;AACA;;AACA;;AAKA;;AAMA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAWA;;AAnCA;AACA;AACA;;AAMA;AACA;AACA;;AAIA;AACA;AACA;AA0BA,oBAAQ,CAAEA,cAAF,EAAeC,aAAf,CAAR;;AAEA,SAASC,aAAT,OAOwB;AAAA,MAPA;AACvBC,IAAAA,SADuB;AAEvBC,IAAAA,UAFuB;AAGvB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,KAAK,EAAC,YAJP;AAKC,QAAA,SAAS,EAAC,wCALX;AAMC,yBAAgBe,MANjB;AAOC,yBAAc,MAPf;AAQC,QAAA,OAAO,EAAGC,QARX;AASC,sBAAaH,0BATd;AAUC,QAAA,KAAK,EACJ,sCAA2BvC,KAA3B,IACG;AAAEK,UAAAA,KAAK,EAAE;AAAT,SADH,GAEG;AACAsC,UAAAA,UAAU,EAAE3C,KADZ;AAEAK,UAAAA,KAAK,EACJE,WAAW,CAACG,QAAZ,KACAH,WAAW,CAACG,QAAZ,CAAsB,MAAtB,CADA,GAEG,MAFH,GAGG;AANJ;AAbL,SAuBC,4BAAC,cAAD;AACC,QAAA,OAAO,MADR;AAEC,QAAA,EAAE,EAAGkC,kBAFN;AAGC,QAAA,SAAS,EAAC;AAHX,SAKGV,eALH,CAvBD,EA8BC,4BAAC,cAAD;AACC,QAAA,EAAE,EAAC,MADJ;AAEC,QAAA,SAAS,EAAC;AAFX,SAIGE,uBAJH,CA9BD,CADc;AAAA;AAHhB,IAFF,EA8CGH,uBAAuB,GACxB,4BAAC,gBAAD,6BACMO,kBADN;AAEC,IAAA,MAAM,EAAG1C;AAFV,KADwB,GAMxB,4BAAC,aAAD,6BACM0C,kBADN;AAEC,IAAA,MAAM,EAAG1C;AAFV,KApDF,CADD;AA4DA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAM+C,YAAY,GAAG,yBAAYrB,uBAAZ,CAArB;;eAEQqB,Y","sourcesContent":["/**\n * External dependencies\n */\nimport type { ForwardedRef } from 'react';\nimport { colord, extend } from 'colord';\nimport namesPlugin from 'colord/plugins/names';\nimport a11yPlugin from 'colord/plugins/a11y';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useCallback, useRef, useMemo, forwardRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport Dropdown from '../dropdown';\nimport { ColorPicker } from '../color-picker';\nimport CircularOptionPicker from '../circular-option-picker';\nimport { VStack } from '../v-stack';\nimport { Flex, FlexItem } from '../flex';\nimport { Truncate } from '../truncate';\nimport { ColorHeading } from './styles';\nimport DropdownContentWrapper from '../dropdown/dropdown-content-wrapper';\nimport type {\n\tColorObject,\n\tColorPaletteProps,\n\tCustomColorPickerDropdownProps,\n\tMultiplePalettesProps,\n\tPaletteObject,\n\tSinglePaletteProps,\n} from './types';\nimport type { WordPressComponentProps } from '../ui/context';\nimport type { DropdownProps } from '../dropdown/types';\nimport {\n\textractColorNameFromCurrentValue,\n\tisMultiplePaletteArray,\n\tnormalizeColorValue,\n\tshowTransparentBackground,\n} from './utils';\n\nextend( [ namesPlugin, a11yPlugin ] );\n\nfunction SinglePalette( {\n\tclassName,\n\tclearColor,\n\tcolors,\n\tonChange,\n\tvalue,\n\tactions,\n}: SinglePaletteProps ) {\n\tconst colorOptions = useMemo( () => {\n\t\treturn colors.map( ( { color, name }, index ) => {\n\t\t\tconst colordColor = colord( color );\n\t\t\tconst isSelected = value === color;\n\n\t\t\treturn (\n\t\t\t\t<CircularOptionPicker.Option\n\t\t\t\t\tkey={ `${ color }-${ index }` }\n\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\tselectedIconProps={\n\t\t\t\t\t\tisSelected\n\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\tfill:\n\t\t\t\t\t\t\t\t\t\tcolordColor.contrast() >\n\t\t\t\t\t\t\t\t\t\tcolordColor.contrast( '#000' )\n\t\t\t\t\t\t\t\t\t\t\t? '#fff'\n\t\t\t\t\t\t\t\t\t\t\t: '#000',\n\t\t\t\t\t\t\t }\n\t\t\t\t\t\t\t: {}\n\t\t\t\t\t}\n\t\t\t\t\ttooltipText={\n\t\t\t\t\t\tname ||\n\t\t\t\t\t\t// translators: %s: color hex code e.g: \"#f00\".\n\t\t\t\t\t\tsprintf( __( 'Color code: %s' ), color )\n\t\t\t\t\t}\n\t\t\t\t\tstyle={ { backgroundColor: color, color } }\n\t\t\t\t\tonClick={\n\t\t\t\t\t\tisSelected ? clearColor : () => onChange( color, index )\n\t\t\t\t\t}\n\t\t\t\t\taria-label={\n\t\t\t\t\t\tname\n\t\t\t\t\t\t\t? // translators: %s: The name of the color e.g: \"vivid red\".\n\t\t\t\t\t\t\t sprintf( __( 'Color: %s' ), name )\n\t\t\t\t\t\t\t: // translators: %s: color hex code e.g: \"#f00\".\n\t\t\t\t\t\t\t sprintf( __( 'Color code: %s' ), color )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t);\n\t\t} );\n\t}, [ colors, value, onChange, clearColor ] );\n\n\treturn (\n\t\t<CircularOptionPicker\n\t\t\tclassName={ className }\n\t\t\toptions={ colorOptions }\n\t\t\tactions={ actions }\n\t\t/>\n\t);\n}\n\nfunction MultiplePalettes( {\n\tclassName,\n\tclearColor,\n\tcolors,\n\tonChange,\n\tvalue,\n\tactions,\n}: MultiplePalettesProps ) {\n\tif ( colors.length === 0 ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<VStack spacing={ 3 } className={ className }>\n\t\t\t{ colors.map( ( { name, colors: colorPalette }, index ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<VStack spacing={ 2 } key={ index }>\n\t\t\t\t\t\t<ColorHeading>{ name }</ColorHeading>\n\t\t\t\t\t\t<SinglePalette\n\t\t\t\t\t\t\tclearColor={ clearColor }\n\t\t\t\t\t\t\tcolors={ colorPalette }\n\t\t\t\t\t\t\tonChange={ ( newColor ) =>\n\t\t\t\t\t\t\t\tonChange( newColor, index )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\t\tactions={\n\t\t\t\t\t\t\t\tcolors.length === index + 1 ? actions : null\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</VStack>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</VStack>\n\t);\n}\n\nexport function CustomColorPickerDropdown( {\n\tisRenderedInSidebar,\n\tpopoverProps: receivedPopoverProps,\n\t...props\n}: CustomColorPickerDropdownProps ) {\n\tconst popoverProps = useMemo< DropdownProps[ 'popoverProps' ] >(\n\t\t() => ( {\n\t\t\tshift: true,\n\t\t\t...( isRenderedInSidebar\n\t\t\t\t? {\n\t\t\t\t\t\t// When in the sidebar: open to the left (stacking),\n\t\t\t\t\t\t// leaving the same gap as the parent popover.\n\t\t\t\t\t\tplacement: 'left-start',\n\t\t\t\t\t\toffset: 34,\n\t\t\t\t }\n\t\t\t\t: {\n\t\t\t\t\t\t// Default behavior: open below the anchor\n\t\t\t\t\t\tplacement: 'bottom',\n\t\t\t\t\t\toffset: 8,\n\t\t\t\t } ),\n\t\t\t...receivedPopoverProps,\n\t\t} ),\n\t\t[ isRenderedInSidebar, receivedPopoverProps ]\n\t);\n\n\treturn (\n\t\t<Dropdown\n\t\t\tcontentClassName=\"components-color-palette__custom-color-dropdown-content\"\n\t\t\tpopoverProps={ popoverProps }\n\t\t\t{ ...props }\n\t\t/>\n\t);\n}\n\nfunction UnforwardedColorPalette(\n\tprops: WordPressComponentProps< ColorPaletteProps, 'div' >,\n\tforwardedRef: ForwardedRef< any >\n) {\n\tconst customColorPaletteRef = useRef< HTMLElement | null >( null );\n\tconst {\n\t\tclearable = true,\n\t\tcolors = [],\n\t\tdisableCustomColors = false,\n\t\tenableAlpha = false,\n\t\tonChange,\n\t\tvalue,\n\t\t__experimentalIsRenderedInSidebar = false,\n\t\t...otherProps\n\t} = props;\n\tconst clearColor = useCallback( () => onChange( undefined ), [ onChange ] );\n\n\tconst hasMultipleColorOrigins = isMultiplePaletteArray( colors );\n\tconst buttonLabelName = useMemo(\n\t\t() =>\n\t\t\textractColorNameFromCurrentValue(\n\t\t\t\tvalue,\n\t\t\t\tcolors,\n\t\t\t\thasMultipleColorOrigins\n\t\t\t),\n\t\t[ value, colors, hasMultipleColorOrigins ]\n\t);\n\n\tconst renderCustomColorPicker = () => (\n\t\t<DropdownContentWrapper paddingSize=\"none\">\n\t\t\t<ColorPicker\n\t\t\t\tcolor={ normalizeColorValue( value, customColorPaletteRef ) }\n\t\t\t\tonChange={ ( color ) => onChange( color ) }\n\t\t\t\tenableAlpha={ enableAlpha }\n\t\t\t/>\n\t\t</DropdownContentWrapper>\n\t);\n\n\tconst colordColor = colord( value ?? '' );\n\n\tconst valueWithoutLeadingHash = value?.startsWith( '#' )\n\t\t? value.substring( 1 )\n\t\t: value ?? '';\n\n\tconst customColorAccessibleLabel = !! valueWithoutLeadingHash\n\t\t? sprintf(\n\t\t\t\t// translators: %1$s: The name of the color e.g: \"vivid red\". %2$s: The color's hex code e.g: \"#f00\".\n\t\t\t\t__(\n\t\t\t\t\t'Custom color picker. The currently selected color is called \"%1$s\" and has a value of \"%2$s\".'\n\t\t\t\t),\n\t\t\t\tbuttonLabelName,\n\t\t\t\tvalueWithoutLeadingHash\n\t\t )\n\t\t: __( 'Custom color picker.' );\n\n\tconst paletteCommonProps = {\n\t\tclearable,\n\t\tclearColor,\n\t\tonChange,\n\t\tvalue,\n\t\tactions: !! clearable && (\n\t\t\t<CircularOptionPicker.ButtonAction onClick={ clearColor }>\n\t\t\t\t{ __( 'Clear' ) }\n\t\t\t</CircularOptionPicker.ButtonAction>\n\t\t),\n\t};\n\n\treturn (\n\t\t<VStack spacing={ 3 } ref={ forwardedRef } { ...otherProps }>\n\t\t\t{ ! disableCustomColors && (\n\t\t\t\t<CustomColorPickerDropdown\n\t\t\t\t\tisRenderedInSidebar={ __experimentalIsRenderedInSidebar }\n\t\t\t\t\trenderContent={ renderCustomColorPicker }\n\t\t\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t\t\t<Flex\n\t\t\t\t\t\t\tas={ 'button' }\n\t\t\t\t\t\t\tref={ customColorPaletteRef }\n\t\t\t\t\t\t\tjustify=\"space-between\"\n\t\t\t\t\t\t\talign=\"flex-start\"\n\t\t\t\t\t\t\tclassName=\"components-color-palette__custom-color\"\n\t\t\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\t\t\taria-haspopup=\"true\"\n\t\t\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\t\t\taria-label={ customColorAccessibleLabel }\n\t\t\t\t\t\t\tstyle={\n\t\t\t\t\t\t\t\tshowTransparentBackground( value )\n\t\t\t\t\t\t\t\t\t? { color: '#000' }\n\t\t\t\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\t\t\t\tbackground: value,\n\t\t\t\t\t\t\t\t\t\t\tcolor:\n\t\t\t\t\t\t\t\t\t\t\t\tcolordColor.contrast() >\n\t\t\t\t\t\t\t\t\t\t\t\tcolordColor.contrast( '#000' )\n\t\t\t\t\t\t\t\t\t\t\t\t\t? '#fff'\n\t\t\t\t\t\t\t\t\t\t\t\t\t: '#000',\n\t\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\t\t<FlexItem\n\t\t\t\t\t\t\t\tisBlock\n\t\t\t\t\t\t\t\tas={ Truncate }\n\t\t\t\t\t\t\t\tclassName=\"components-color-palette__custom-color-name\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ buttonLabelName }\n\t\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t\t\t<FlexItem\n\t\t\t\t\t\t\t\tas=\"span\"\n\t\t\t\t\t\t\t\tclassName=\"components-color-palette__custom-color-value\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ valueWithoutLeadingHash }\n\t\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t\t</Flex>\n\t\t\t\t\t) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ hasMultipleColorOrigins ? (\n\t\t\t\t<MultiplePalettes\n\t\t\t\t\t{ ...paletteCommonProps }\n\t\t\t\t\tcolors={ colors as PaletteObject[] }\n\t\t\t\t/>\n\t\t\t) : (\n\t\t\t\t<SinglePalette\n\t\t\t\t\t{ ...paletteCommonProps }\n\t\t\t\t\tcolors={ colors as ColorObject[] }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</VStack>\n\t);\n}\n\n/**\n * Allows the user to pick a color from a list of pre-defined color entries.\n *\n * ```jsx\n * import { ColorPalette } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * const MyColorPalette = () => {\n * const [ color, setColor ] = useState ( '#f00' )\n * const colors = [\n * { name: 'red', color: '#f00' },\n * { name: 'white', color: '#fff' },\n * { name: 'blue', color: '#00f' },\n * ];\n * return (\n * <ColorPalette\n * colors={ colors }\n * value={ color }\n * onChange={ ( color ) => setColor( color ) }\n * />\n * );\n * } );\n * ```\n */\nexport const ColorPalette = forwardRef( UnforwardedColorPalette );\n\nexport default ColorPalette;\n"]}
@@ -11,8 +11,6 @@ var _element = require("@wordpress/element");
11
11
 
12
12
  var _reactNative = require("react-native");
13
13
 
14
- var _lodash = require("lodash");
15
-
16
14
  var _i18n = require("@wordpress/i18n");
17
15
 
18
16
  var _compose = require("@wordpress/compose");
@@ -40,6 +38,8 @@ let scrollPosition = 0;
40
38
  let customIndicatorWidth = 0;
41
39
 
42
40
  function ColorPalette(_ref) {
41
+ var _defaultSettings$colo, _defaultSettings$allC, _defaultSettings$grad;
42
+
43
43
  let {
44
44
  enableCustomColor = true,
45
45
  setColor,
@@ -62,9 +62,24 @@ function ColorPalette(_ref) {
62
62
  const isGradientSegment = currentSegment === _utils.colorsUtils.segments[1];
63
63
  const scale = (0, _element.useRef)(new _reactNative.Animated.Value(1)).current;
64
64
  const opacity = (0, _element.useRef)(new _reactNative.Animated.Value(1)).current;
65
- const defaultColors = [...new Set((0, _lodash.map)(defaultSettings.colors, 'color'))];
66
- const mergedColors = [...new Set((0, _lodash.map)(defaultSettings.allColors, 'color'))];
67
- const defaultGradientColors = [...new Set((0, _lodash.map)(defaultSettings.gradients, 'gradient'))];
65
+ const defaultColors = [...new Set(((_defaultSettings$colo = defaultSettings.colors) !== null && _defaultSettings$colo !== void 0 ? _defaultSettings$colo : []).map(_ref2 => {
66
+ let {
67
+ color
68
+ } = _ref2;
69
+ return color;
70
+ }))];
71
+ const mergedColors = [...new Set(((_defaultSettings$allC = defaultSettings.allColors) !== null && _defaultSettings$allC !== void 0 ? _defaultSettings$allC : []).map(_ref3 => {
72
+ let {
73
+ color
74
+ } = _ref3;
75
+ return color;
76
+ }))];
77
+ const defaultGradientColors = [...new Set(((_defaultSettings$grad = defaultSettings.gradients) !== null && _defaultSettings$grad !== void 0 ? _defaultSettings$grad : []).map(_ref4 => {
78
+ let {
79
+ gradient
80
+ } = _ref4;
81
+ return gradient;
82
+ }))];
68
83
  const colors = isGradientSegment ? defaultGradientColors : defaultColors;
69
84
  const customIndicatorColor = isGradientSegment ? activeColor : customSwatchGradients;
70
85
  const isCustomGradientColor = isGradientColor && isSelectedCustom();
@@ -174,10 +189,10 @@ function ColorPalette(_ref) {
174
189
  };
175
190
  }
176
191
 
177
- function onCustomIndicatorLayout(_ref2) {
192
+ function onCustomIndicatorLayout(_ref5) {
178
193
  let {
179
194
  nativeEvent
180
- } = _ref2;
195
+ } = _ref5;
181
196
  const {
182
197
  width
183
198
  } = nativeEvent.layout;
@@ -187,10 +202,10 @@ function ColorPalette(_ref) {
187
202
  }
188
203
  }
189
204
 
190
- function onScroll(_ref3) {
205
+ function onScroll(_ref6) {
191
206
  let {
192
207
  nativeEvent
193
- } = _ref3;
208
+ } = _ref6;
194
209
  scrollPosition = nativeEvent.contentOffset.x;
195
210
  }
196
211
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/color-palette/index.native.js"],"names":["ANIMATION_DURATION","contentWidth","scrollPosition","customIndicatorWidth","ColorPalette","enableCustomColor","setColor","activeColor","isGradientColor","defaultSettings","currentSegment","onCustomPress","shouldEnableBottomSheetScroll","shouldShowCustomIndicatorOption","shouldShowCustomLabel","shouldShowCustomVerticalSeparator","customColorIndicatorStyles","customIndicatorWrapperStyles","label","customSwatchGradients","scrollViewRef","isIOS","Platform","OS","isGradientSegment","colorsUtils","segments","scale","Animated","Value","current","opacity","defaultColors","Set","colors","mergedColors","allColors","defaultGradientColors","gradients","customIndicatorColor","isCustomGradientColor","isSelectedCustom","shouldShowCustomIndicator","accessibilityHint","customText","scrollToEndWithDelay","scrollTo","x","y","isWithinColors","includes","isSelected","color","timingAnimation","property","toValue","timing","duration","easing","Easing","ease","useNativeDriver","performAnimation","setValue","parallel","start","scaleInterpolation","interpolate","inputRange","outputRange","deselectCustomGradient","width","Dimensions","get","isVisible","onColorPress","onContentSizeChange","delayedScroll","setTimeout","scrollToEnd","clearTimeout","onCustomIndicatorLayout","nativeEvent","layout","onScroll","contentOffset","verticalSeparatorStyle","styles","verticalSeparator","verticalSeparatorDark","customTextStyle","customTextAndroid","customTextDark","customIndicatorWrapperStyle","customIndicatorWrapper","headerText","contentContainer","map","scaleValue","selected","transform","colorIndicator","toUpperCase"],"mappings":";;;;;;;;;AAmBA;;AAhBA;;AAUA;;AAKA;;AAEA;;AAKA;;AACA;;AACA;;AA3BA;AACA;AACA;;AAaA;AACA;AACA;;AAKA;AACA;AACA;AAKA,MAAMA,kBAAkB,GAAG,GAA3B;AAEA,IAAIC,YAAY,GAAG,CAAnB;AACA,IAAIC,cAAc,GAAG,CAArB;AACA,IAAIC,oBAAoB,GAAG,CAA3B;;AAEA,SAASC,YAAT,OAeI;AAAA,MAfmB;AACtBC,IAAAA,iBAAiB,GAAG,IADE;AAEtBC,IAAAA,QAFsB;AAGtBC,IAAAA,WAHsB;AAItBC,IAAAA,eAJsB;AAKtBC,IAAAA,eALsB;AAMtBC,IAAAA,cANsB;AAOtBC,IAAAA,aAPsB;AAQtBC,IAAAA,6BARsB;AAStBC,IAAAA,+BAA+B,GAAG,IATZ;AAUtBC,IAAAA,qBAAqB,GAAG,IAVF;AAWtBC,IAAAA,iCAAiC,GAAG,IAXd;AAYtBC,IAAAA,0BAZsB;AAatBC,IAAAA,4BAbsB;AActBC,IAAAA;AAdsB,GAenB;AACH,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,2BADT;AAEC,IAAA,QAAQ,EAAGZ;AAFZ,KAIGlE,iCAAiC,IAClC,4BAAC,iBAAD;AAAM,IAAA,KAAK,EAAGuE;AAAd,IALF,EAOC,4BAAC,qCAAD;AACC,IAAA,OAAO,EAAG3E,aADX;AAEC,IAAA,iBAAiB,EAAG,QAFrB;AAGC,IAAA,kBAAkB,EAAG;AACpBwF,MAAAA,QAAQ,EAAE1D,gBAAgB;AADN,KAHtB;AAMC,IAAA,iBAAiB,EAAGE;AANrB,KAQC,4BAAC,iBAAD;AAAM,IAAA,KAAK,EAAGkD;AAAd,KACC,4BAAC,uBAAD;AACC,IAAA,gBAAgB,EAAG,CAAErE,iBADtB;AAEC,IAAA,KAAK,EAAGe,oBAFT;AAGC,IAAA,UAAU,EAAGE,gBAAgB,EAH9B;AAIC,IAAA,KAAK,EAAG,CACP8C,eAAOc,cADA,EAEPrF,0BAFO;AAJT,IADD,EAUGF,qBAAqB,IACtB,4BAAC,iBAAD;AAAM,IAAA,KAAK,EAAG4E;AAAd,KACGrE,KAAK,GACJuB,UADI,GAEJA,UAAU,CAAC0D,WAAX,EAHJ,CAXF,CARD,CAPD,CAvDF,CAPD,CADD;AAsGA;;eAEclG,Y","sourcesContent":["/**\n * External dependencies\n */\nimport {\n\tScrollView,\n\tTouchableWithoutFeedback,\n\tView,\n\tAnimated,\n\tEasing,\n\tDimensions,\n\tPlatform,\n\tText,\n} from 'react-native';\nimport { map } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useRef, useEffect } from '@wordpress/element';\nimport { usePreferredColorSchemeStyle } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport styles from './style.scss';\nimport ColorIndicator from '../color-indicator';\nimport { colorsUtils } from '../mobile/color-settings/utils';\n\nconst ANIMATION_DURATION = 200;\n\nlet contentWidth = 0;\nlet scrollPosition = 0;\nlet customIndicatorWidth = 0;\n\nfunction ColorPalette( {\n\tenableCustomColor = true,\n\tsetColor,\n\tactiveColor,\n\tisGradientColor,\n\tdefaultSettings,\n\tcurrentSegment,\n\tonCustomPress,\n\tshouldEnableBottomSheetScroll,\n\tshouldShowCustomIndicatorOption = true,\n\tshouldShowCustomLabel = true,\n\tshouldShowCustomVerticalSeparator = true,\n\tcustomColorIndicatorStyles,\n\tcustomIndicatorWrapperStyles,\n\tlabel,\n} ) {\n\tconst customSwatchGradients = [\n\t\t'linear-gradient(120deg, rgba(255,0,0,.8) 0%, rgba(255,255,255,1) 70.71%)',\n\t\t'linear-gradient(240deg, rgba(0,255,0,.8) 0%, rgba(0,255,0,0) 70.71%)',\n\t\t'linear-gradient(360deg, rgba(0,0,255,.8) 0%, rgba(0,0,255,0) 70.71%)',\n\t];\n\n\tconst scrollViewRef = useRef();\n\tconst isIOS = Platform.OS === 'ios';\n\n\tconst isGradientSegment = currentSegment === colorsUtils.segments[ 1 ];\n\n\tconst scale = useRef( new Animated.Value( 1 ) ).current;\n\tconst opacity = useRef( new Animated.Value( 1 ) ).current;\n\n\tconst defaultColors = [\n\t\t...new Set( map( defaultSettings.colors, 'color' ) ),\n\t];\n\tconst mergedColors = [\n\t\t...new Set( map( defaultSettings.allColors, 'color' ) ),\n\t];\n\tconst defaultGradientColors = [\n\t\t...new Set( map( defaultSettings.gradients, 'gradient' ) ),\n\t];\n\tconst colors = isGradientSegment ? defaultGradientColors : defaultColors;\n\n\tconst customIndicatorColor = isGradientSegment\n\t\t? activeColor\n\t\t: customSwatchGradients;\n\tconst isCustomGradientColor = isGradientColor && isSelectedCustom();\n\tconst shouldShowCustomIndicator =\n\t\tenableCustomColor &&\n\t\tshouldShowCustomIndicatorOption &&\n\t\t( ! isGradientSegment || isCustomGradientColor );\n\n\tconst accessibilityHint = isGradientSegment\n\t\t? __( 'Navigates to customize the gradient' )\n\t\t: __( 'Navigates to custom color picker' );\n\tconst customText = __( 'Custom' );\n\n\tuseEffect( () => {\n\t\tif ( scrollViewRef.current ) {\n\t\t\tif ( isSelectedCustom() ) {\n\t\t\t\tscrollToEndWithDelay();\n\t\t\t} else {\n\t\t\t\tscrollViewRef.current.scrollTo( { x: 0, y: 0 } );\n\t\t\t}\n\t\t}\n\t\t// Temporarily disabling exhuastive-deps until the component can be refactored and updated safely.\n\t\t// Please see https://github.com/WordPress/gutenberg/pull/41253 for discussion and details.\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [ currentSegment ] );\n\n\tfunction isSelectedCustom() {\n\t\tconst isWithinColors =\n\t\t\tactiveColor && mergedColors && mergedColors.includes( activeColor );\n\t\tif ( enableCustomColor && activeColor ) {\n\t\t\tif ( isGradientSegment ) {\n\t\t\t\treturn isGradientColor && ! isWithinColors;\n\t\t\t}\n\t\t\treturn ! isGradientColor && ! isWithinColors;\n\t\t}\n\t\treturn false;\n\t}\n\n\tfunction isSelected( color ) {\n\t\treturn ! isSelectedCustom() && activeColor === color;\n\t}\n\n\tfunction timingAnimation( property, toValue ) {\n\t\treturn Animated.timing( property, {\n\t\t\ttoValue,\n\t\t\tduration: ANIMATION_DURATION,\n\t\t\teasing: Easing.ease,\n\t\t\tuseNativeDriver: true,\n\t\t} );\n\t}\n\n\tfunction performAnimation( color ) {\n\t\tif ( ! isSelected( color ) ) {\n\t\t\topacity.setValue( 0 );\n\t\t}\n\n\t\tAnimated.parallel( [\n\t\t\ttimingAnimation( scale, 2 ),\n\t\t\ttimingAnimation( opacity, 1 ),\n\t\t] ).start( () => {\n\t\t\topacity.setValue( 1 );\n\t\t\tscale.setValue( 1 );\n\t\t} );\n\t}\n\n\tconst scaleInterpolation = scale.interpolate( {\n\t\tinputRange: [ 1, 1.5, 2 ],\n\t\toutputRange: [ 1, 0.7, 1 ],\n\t} );\n\n\tfunction deselectCustomGradient() {\n\t\tconst { width } = Dimensions.get( 'window' );\n\t\tconst isVisible =\n\t\t\tcontentWidth - scrollPosition - customIndicatorWidth < width;\n\n\t\tif ( isCustomGradientColor ) {\n\t\t\tif ( ! isIOS ) {\n\t\t\t\t// Scroll position on Android doesn't adjust automatically when removing the last item from the horizontal list.\n\t\t\t\t// https://github.com/facebook/react-native/issues/27504\n\t\t\t\t// Workaround: Force the scroll when deselecting custom gradient color and when custom indicator is visible on layout.\n\t\t\t\tif (\n\t\t\t\t\tisCustomGradientColor &&\n\t\t\t\t\tisVisible &&\n\t\t\t\t\tscrollViewRef.current\n\t\t\t\t) {\n\t\t\t\t\tscrollViewRef.current.scrollTo( {\n\t\t\t\t\t\tx: scrollPosition - customIndicatorWidth,\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction onColorPress( color ) {\n\t\tdeselectCustomGradient();\n\t\tperformAnimation( color );\n\t\tsetColor( color );\n\t}\n\n\tfunction onContentSizeChange( width ) {\n\t\tcontentWidth = width;\n\t\tif ( isSelectedCustom() && scrollViewRef.current ) {\n\t\t\tscrollToEndWithDelay();\n\t\t}\n\t}\n\n\tfunction scrollToEndWithDelay() {\n\t\tconst delayedScroll = setTimeout( () => {\n\t\t\tscrollViewRef.current.scrollToEnd();\n\t\t}, ANIMATION_DURATION );\n\t\treturn () => {\n\t\t\tclearTimeout( delayedScroll );\n\t\t};\n\t}\n\n\tfunction onCustomIndicatorLayout( { nativeEvent } ) {\n\t\tconst { width } = nativeEvent.layout;\n\t\tif ( width !== customIndicatorWidth ) {\n\t\t\tcustomIndicatorWidth = width;\n\t\t}\n\t}\n\n\tfunction onScroll( { nativeEvent } ) {\n\t\tscrollPosition = nativeEvent.contentOffset.x;\n\t}\n\n\tconst verticalSeparatorStyle = usePreferredColorSchemeStyle(\n\t\tstyles.verticalSeparator,\n\t\tstyles.verticalSeparatorDark\n\t);\n\n\tconst customTextStyle = usePreferredColorSchemeStyle(\n\t\t[ styles.customText, ! isIOS && styles.customTextAndroid ],\n\t\tstyles.customTextDark\n\t);\n\n\tconst customIndicatorWrapperStyle = [\n\t\tstyles.customIndicatorWrapper,\n\t\tcustomIndicatorWrapperStyles,\n\t];\n\n\treturn (\n\t\t<>\n\t\t\t{ label && (\n\t\t\t\t<Text accessibilityRole=\"header\" style={ styles.headerText }>\n\t\t\t\t\t{ label }\n\t\t\t\t</Text>\n\t\t\t) }\n\n\t\t\t<ScrollView\n\t\t\t\tcontentContainerStyle={ styles.contentContainer }\n\t\t\t\thorizontal\n\t\t\t\tshowsHorizontalScrollIndicator={ false }\n\t\t\t\tkeyboardShouldPersistTaps=\"always\"\n\t\t\t\tdisableScrollViewPanResponder\n\t\t\t\tscrollEventThrottle={ 16 }\n\t\t\t\tonScroll={ onScroll }\n\t\t\t\tonContentSizeChange={ onContentSizeChange }\n\t\t\t\tonScrollBeginDrag={ () =>\n\t\t\t\t\tshouldEnableBottomSheetScroll( false )\n\t\t\t\t}\n\t\t\t\tonScrollEndDrag={ () => shouldEnableBottomSheetScroll( true ) }\n\t\t\t\tref={ scrollViewRef }\n\t\t\t\ttestID={ `color-palette${ label ? '-' + label : '' }` }\n\t\t\t>\n\t\t\t\t{ colors.map( ( color ) => {\n\t\t\t\t\tconst scaleValue = isSelected( color )\n\t\t\t\t\t\t? scaleInterpolation\n\t\t\t\t\t\t: 1;\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<View key={ `${ color }-${ isSelected( color ) }` }>\n\t\t\t\t\t\t\t<TouchableWithoutFeedback\n\t\t\t\t\t\t\t\tonPress={ () => onColorPress( color ) }\n\t\t\t\t\t\t\t\taccessibilityRole={ 'button' }\n\t\t\t\t\t\t\t\taccessibilityState={ {\n\t\t\t\t\t\t\t\t\tselected: isSelected( color ),\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\taccessibilityHint={ color }\n\t\t\t\t\t\t\t\ttestID={ color }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<Animated.View\n\t\t\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\t\t\ttransform: [\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\tscale: scaleValue,\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\t\t<ColorIndicator\n\t\t\t\t\t\t\t\t\t\tcolor={ color }\n\t\t\t\t\t\t\t\t\t\tisSelected={ isSelected( color ) }\n\t\t\t\t\t\t\t\t\t\topacity={ opacity }\n\t\t\t\t\t\t\t\t\t\tstyle={ [\n\t\t\t\t\t\t\t\t\t\t\tstyles.colorIndicator,\n\t\t\t\t\t\t\t\t\t\t\tcustomColorIndicatorStyles,\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</Animated.View>\n\t\t\t\t\t\t\t</TouchableWithoutFeedback>\n\t\t\t\t\t\t</View>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t\t\t{ shouldShowCustomIndicator && (\n\t\t\t\t\t<View\n\t\t\t\t\t\tstyle={ customIndicatorWrapperStyle }\n\t\t\t\t\t\tonLayout={ onCustomIndicatorLayout }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ shouldShowCustomVerticalSeparator && (\n\t\t\t\t\t\t\t<View style={ verticalSeparatorStyle } />\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<TouchableWithoutFeedback\n\t\t\t\t\t\t\tonPress={ onCustomPress }\n\t\t\t\t\t\t\taccessibilityRole={ 'button' }\n\t\t\t\t\t\t\taccessibilityState={ {\n\t\t\t\t\t\t\t\tselected: isSelectedCustom(),\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\taccessibilityHint={ accessibilityHint }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<View style={ customIndicatorWrapperStyle }>\n\t\t\t\t\t\t\t\t<ColorIndicator\n\t\t\t\t\t\t\t\t\twithCustomPicker={ ! isGradientSegment }\n\t\t\t\t\t\t\t\t\tcolor={ customIndicatorColor }\n\t\t\t\t\t\t\t\t\tisSelected={ isSelectedCustom() }\n\t\t\t\t\t\t\t\t\tstyle={ [\n\t\t\t\t\t\t\t\t\t\tstyles.colorIndicator,\n\t\t\t\t\t\t\t\t\t\tcustomColorIndicatorStyles,\n\t\t\t\t\t\t\t\t\t] }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t{ shouldShowCustomLabel && (\n\t\t\t\t\t\t\t\t\t<Text style={ customTextStyle }>\n\t\t\t\t\t\t\t\t\t\t{ isIOS\n\t\t\t\t\t\t\t\t\t\t\t? customText\n\t\t\t\t\t\t\t\t\t\t\t: customText.toUpperCase() }\n\t\t\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</View>\n\t\t\t\t\t\t</TouchableWithoutFeedback>\n\t\t\t\t\t</View>\n\t\t\t\t) }\n\t\t\t</ScrollView>\n\t\t</>\n\t);\n}\n\nexport default ColorPalette;\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/color-palette/index.native.js"],"names":["ANIMATION_DURATION","contentWidth","scrollPosition","customIndicatorWidth","ColorPalette","enableCustomColor","setColor","activeColor","isGradientColor","defaultSettings","currentSegment","onCustomPress","shouldEnableBottomSheetScroll","shouldShowCustomIndicatorOption","shouldShowCustomLabel","shouldShowCustomVerticalSeparator","customColorIndicatorStyles","customIndicatorWrapperStyles","label","customSwatchGradients","scrollViewRef","isIOS","Platform","OS","isGradientSegment","colorsUtils","segments","scale","Animated","Value","current","opacity","defaultColors","Set","colors","map","color","mergedColors","allColors","defaultGradientColors","gradients","gradient","customIndicatorColor","isCustomGradientColor","isSelectedCustom","shouldShowCustomIndicator","accessibilityHint","customText","scrollToEndWithDelay","scrollTo","x","y","isWithinColors","includes","isSelected","timingAnimation","property","toValue","timing","duration","easing","Easing","ease","useNativeDriver","performAnimation","setValue","parallel","start","scaleInterpolation","interpolate","inputRange","outputRange","deselectCustomGradient","width","Dimensions","get","isVisible","onColorPress","onContentSizeChange","delayedScroll","setTimeout","scrollToEnd","clearTimeout","onCustomIndicatorLayout","nativeEvent","layout","onScroll","contentOffset","verticalSeparatorStyle","styles","verticalSeparator","verticalSeparatorDark","customTextStyle","customTextAndroid","customTextDark","customIndicatorWrapperStyle","customIndicatorWrapper","headerText","contentContainer","scaleValue","selected","transform","colorIndicator","toUpperCase"],"mappings":";;;;;;;;;AAkBA;;AAfA;;AAcA;;AAEA;;AAKA;;AACA;;AACA;;AA1BA;AACA;AACA;;AAYA;AACA;AACA;;AAKA;AACA;AACA;AAKA,MAAMA,kBAAkB,GAAG,GAA3B;AAEA,IAAIC,YAAY,GAAG,CAAnB;AACA,IAAIC,cAAc,GAAG,CAArB;AACA,IAAIC,oBAAoB,GAAG,CAA3B;;AAEA,SAASC,YAAT,OAeI;AAAA;;AAAA,MAfmB;AACtBC,IAAAA,iBAAiB,GAAG,IADE;AAEtBC,IAAAA,QAFsB;AAGtBC,IAAAA,WAHsB;AAItBC,IAAAA,eAJsB;AAKtBC,IAAAA,eALsB;AAMtBC,IAAAA,cANsB;AAOtBC,IAAAA,aAPsB;AAQtBC,IAAAA,6BARsB;AAStBC,IAAAA,+BAA+B,GAAG,IATZ;AAUtBC,IAAAA,qBAAqB,GAAG,IAVF;AAWtBC,IAAAA,iCAAiC,GAAG,IAXd;AAYtBC,IAAAA,0BAZsB;AAatBC,IAAAA,4BAbsB;AActBC,IAAAA;AAdsB,GAenB;AACH,QAAMC,qBAAqB,GAAG,CAC7B,0EAD6B,EAE7B,sEAF6B,EAG7B,sEAH6B,CAA9B;AAMA,QAAMC,aAAa,GAAG,sBAAtB;AACA,QAAMC,KAAK,GAAGC,sBAASC,EAAT,KAAgB,KAA9B;AAEA,QAAMC,iBAAiB,GAAGd,cAAc,KAAKe,mBAAYC,QAAZ,CAAsB,CAAtB,CAA7C;AAEA,QAAMC,KAAK,GAAG,qBAAQ,IAAIC,sBAASC,KAAb,CAAoB,CAApB,CAAR,EAAkCC,OAAhD;AACA,QAAMC,OAAO,GAAG,qBAAQ,IAAIH,sBAASC,KAAb,C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K,EAAGyE;AAAd,IALF,EAOC,4BAAC,qCAAD;AACC,IAAA,OAAO,EAAG7E,aADX;AAEC,IAAA,iBAAiB,EAAG,QAFrB;AAGC,IAAA,kBAAkB,EAAG;AACpByF,MAAAA,QAAQ,EAAExD,gBAAgB;AADN,KAHtB;AAMC,IAAA,iBAAiB,EAAGE;AANrB,KAQC,4BAAC,iBAAD;AAAM,IAAA,KAAK,EAAGiD;AAAd,KACC,4BAAC,uBAAD;AACC,IAAA,gBAAgB,EAAG,CAAEvE,iBADtB;AAEC,IAAA,KAAK,EAAGkB,oBAFT;AAGC,IAAA,UAAU,EAAGE,gBAAgB,EAH9B;AAIC,IAAA,KAAK,EAAG,CACP6C,eAAOa,cADA,EAEPtF,0BAFO;AAJT,IADD,EAUGF,qBAAqB,IACtB,4BAAC,iBAAD;AAAM,IAAA,KAAK,EAAG8E;AAAd,KACGvE,KAAK,GACJ0B,UADI,GAEJA,UAAU,CAACwD,WAAX,EAHJ,CAXF,CARD,CAPD,CAvDF,CAPD,CADD;AAsGA;;eAEcnG,Y","sourcesContent":["/**\n * External dependencies\n */\nimport {\n\tScrollView,\n\tTouchableWithoutFeedback,\n\tView,\n\tAnimated,\n\tEasing,\n\tDimensions,\n\tPlatform,\n\tText,\n} from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useRef, useEffect } from '@wordpress/element';\nimport { usePreferredColorSchemeStyle } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport styles from './style.scss';\nimport ColorIndicator from '../color-indicator';\nimport { colorsUtils } from '../mobile/color-settings/utils';\n\nconst ANIMATION_DURATION = 200;\n\nlet contentWidth = 0;\nlet scrollPosition = 0;\nlet customIndicatorWidth = 0;\n\nfunction ColorPalette( {\n\tenableCustomColor = true,\n\tsetColor,\n\tactiveColor,\n\tisGradientColor,\n\tdefaultSettings,\n\tcurrentSegment,\n\tonCustomPress,\n\tshouldEnableBottomSheetScroll,\n\tshouldShowCustomIndicatorOption = true,\n\tshouldShowCustomLabel = true,\n\tshouldShowCustomVerticalSeparator = true,\n\tcustomColorIndicatorStyles,\n\tcustomIndicatorWrapperStyles,\n\tlabel,\n} ) {\n\tconst customSwatchGradients = [\n\t\t'linear-gradient(120deg, rgba(255,0,0,.8) 0%, rgba(255,255,255,1) 70.71%)',\n\t\t'linear-gradient(240deg, rgba(0,255,0,.8) 0%, rgba(0,255,0,0) 70.71%)',\n\t\t'linear-gradient(360deg, rgba(0,0,255,.8) 0%, rgba(0,0,255,0) 70.71%)',\n\t];\n\n\tconst scrollViewRef = useRef();\n\tconst isIOS = Platform.OS === 'ios';\n\n\tconst isGradientSegment = currentSegment === colorsUtils.segments[ 1 ];\n\n\tconst scale = useRef( new Animated.Value( 1 ) ).current;\n\tconst opacity = useRef( new Animated.Value( 1 ) ).current;\n\n\tconst defaultColors = [\n\t\t...new Set(\n\t\t\t( defaultSettings.colors ?? [] ).map( ( { color } ) => color )\n\t\t),\n\t];\n\tconst mergedColors = [\n\t\t...new Set(\n\t\t\t( defaultSettings.allColors ?? [] ).map( ( { color } ) => color )\n\t\t),\n\t];\n\tconst defaultGradientColors = [\n\t\t...new Set(\n\t\t\t( defaultSettings.gradients ?? [] ).map(\n\t\t\t\t( { gradient } ) => gradient\n\t\t\t)\n\t\t),\n\t];\n\tconst colors = isGradientSegment ? defaultGradientColors : defaultColors;\n\n\tconst customIndicatorColor = isGradientSegment\n\t\t? activeColor\n\t\t: customSwatchGradients;\n\tconst isCustomGradientColor = isGradientColor && isSelectedCustom();\n\tconst shouldShowCustomIndicator =\n\t\tenableCustomColor &&\n\t\tshouldShowCustomIndicatorOption &&\n\t\t( ! isGradientSegment || isCustomGradientColor );\n\n\tconst accessibilityHint = isGradientSegment\n\t\t? __( 'Navigates to customize the gradient' )\n\t\t: __( 'Navigates to custom color picker' );\n\tconst customText = __( 'Custom' );\n\n\tuseEffect( () => {\n\t\tif ( scrollViewRef.current ) {\n\t\t\tif ( isSelectedCustom() ) {\n\t\t\t\tscrollToEndWithDelay();\n\t\t\t} else {\n\t\t\t\tscrollViewRef.current.scrollTo( { x: 0, y: 0 } );\n\t\t\t}\n\t\t}\n\t\t// Temporarily disabling exhuastive-deps until the component can be refactored and updated safely.\n\t\t// Please see https://github.com/WordPress/gutenberg/pull/41253 for discussion and details.\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [ currentSegment ] );\n\n\tfunction isSelectedCustom() {\n\t\tconst isWithinColors =\n\t\t\tactiveColor && mergedColors && mergedColors.includes( activeColor );\n\t\tif ( enableCustomColor && activeColor ) {\n\t\t\tif ( isGradientSegment ) {\n\t\t\t\treturn isGradientColor && ! isWithinColors;\n\t\t\t}\n\t\t\treturn ! isGradientColor && ! isWithinColors;\n\t\t}\n\t\treturn false;\n\t}\n\n\tfunction isSelected( color ) {\n\t\treturn ! isSelectedCustom() && activeColor === color;\n\t}\n\n\tfunction timingAnimation( property, toValue ) {\n\t\treturn Animated.timing( property, {\n\t\t\ttoValue,\n\t\t\tduration: ANIMATION_DURATION,\n\t\t\teasing: Easing.ease,\n\t\t\tuseNativeDriver: true,\n\t\t} );\n\t}\n\n\tfunction performAnimation( color ) {\n\t\tif ( ! isSelected( color ) ) {\n\t\t\topacity.setValue( 0 );\n\t\t}\n\n\t\tAnimated.parallel( [\n\t\t\ttimingAnimation( scale, 2 ),\n\t\t\ttimingAnimation( opacity, 1 ),\n\t\t] ).start( () => {\n\t\t\topacity.setValue( 1 );\n\t\t\tscale.setValue( 1 );\n\t\t} );\n\t}\n\n\tconst scaleInterpolation = scale.interpolate( {\n\t\tinputRange: [ 1, 1.5, 2 ],\n\t\toutputRange: [ 1, 0.7, 1 ],\n\t} );\n\n\tfunction deselectCustomGradient() {\n\t\tconst { width } = Dimensions.get( 'window' );\n\t\tconst isVisible =\n\t\t\tcontentWidth - scrollPosition - customIndicatorWidth < width;\n\n\t\tif ( isCustomGradientColor ) {\n\t\t\tif ( ! isIOS ) {\n\t\t\t\t// Scroll position on Android doesn't adjust automatically when removing the last item from the horizontal list.\n\t\t\t\t// https://github.com/facebook/react-native/issues/27504\n\t\t\t\t// Workaround: Force the scroll when deselecting custom gradient color and when custom indicator is visible on layout.\n\t\t\t\tif (\n\t\t\t\t\tisCustomGradientColor &&\n\t\t\t\t\tisVisible &&\n\t\t\t\t\tscrollViewRef.current\n\t\t\t\t) {\n\t\t\t\t\tscrollViewRef.current.scrollTo( {\n\t\t\t\t\t\tx: scrollPosition - customIndicatorWidth,\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction onColorPress( color ) {\n\t\tdeselectCustomGradient();\n\t\tperformAnimation( color );\n\t\tsetColor( color );\n\t}\n\n\tfunction onContentSizeChange( width ) {\n\t\tcontentWidth = width;\n\t\tif ( isSelectedCustom() && scrollViewRef.current ) {\n\t\t\tscrollToEndWithDelay();\n\t\t}\n\t}\n\n\tfunction scrollToEndWithDelay() {\n\t\tconst delayedScroll = setTimeout( () => {\n\t\t\tscrollViewRef.current.scrollToEnd();\n\t\t}, ANIMATION_DURATION );\n\t\treturn () => {\n\t\t\tclearTimeout( delayedScroll );\n\t\t};\n\t}\n\n\tfunction onCustomIndicatorLayout( { nativeEvent } ) {\n\t\tconst { width } = nativeEvent.layout;\n\t\tif ( width !== customIndicatorWidth ) {\n\t\t\tcustomIndicatorWidth = width;\n\t\t}\n\t}\n\n\tfunction onScroll( { nativeEvent } ) {\n\t\tscrollPosition = nativeEvent.contentOffset.x;\n\t}\n\n\tconst verticalSeparatorStyle = usePreferredColorSchemeStyle(\n\t\tstyles.verticalSeparator,\n\t\tstyles.verticalSeparatorDark\n\t);\n\n\tconst customTextStyle = usePreferredColorSchemeStyle(\n\t\t[ styles.customText, ! isIOS && styles.customTextAndroid ],\n\t\tstyles.customTextDark\n\t);\n\n\tconst customIndicatorWrapperStyle = [\n\t\tstyles.customIndicatorWrapper,\n\t\tcustomIndicatorWrapperStyles,\n\t];\n\n\treturn (\n\t\t<>\n\t\t\t{ label && (\n\t\t\t\t<Text accessibilityRole=\"header\" style={ styles.headerText }>\n\t\t\t\t\t{ label }\n\t\t\t\t</Text>\n\t\t\t) }\n\n\t\t\t<ScrollView\n\t\t\t\tcontentContainerStyle={ styles.contentContainer }\n\t\t\t\thorizontal\n\t\t\t\tshowsHorizontalScrollIndicator={ false }\n\t\t\t\tkeyboardShouldPersistTaps=\"always\"\n\t\t\t\tdisableScrollViewPanResponder\n\t\t\t\tscrollEventThrottle={ 16 }\n\t\t\t\tonScroll={ onScroll }\n\t\t\t\tonContentSizeChange={ onContentSizeChange }\n\t\t\t\tonScrollBeginDrag={ () =>\n\t\t\t\t\tshouldEnableBottomSheetScroll( false )\n\t\t\t\t}\n\t\t\t\tonScrollEndDrag={ () => shouldEnableBottomSheetScroll( true ) }\n\t\t\t\tref={ scrollViewRef }\n\t\t\t\ttestID={ `color-palette${ label ? '-' + label : '' }` }\n\t\t\t>\n\t\t\t\t{ colors.map( ( color ) => {\n\t\t\t\t\tconst scaleValue = isSelected( color )\n\t\t\t\t\t\t? scaleInterpolation\n\t\t\t\t\t\t: 1;\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<View key={ `${ color }-${ isSelected( color ) }` }>\n\t\t\t\t\t\t\t<TouchableWithoutFeedback\n\t\t\t\t\t\t\t\tonPress={ () => onColorPress( color ) }\n\t\t\t\t\t\t\t\taccessibilityRole={ 'button' }\n\t\t\t\t\t\t\t\taccessibilityState={ {\n\t\t\t\t\t\t\t\t\tselected: isSelected( color ),\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\taccessibilityHint={ color }\n\t\t\t\t\t\t\t\ttestID={ color }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<Animated.View\n\t\t\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\t\t\ttransform: [\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\tscale: scaleValue,\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\t\t<ColorIndicator\n\t\t\t\t\t\t\t\t\t\tcolor={ color }\n\t\t\t\t\t\t\t\t\t\tisSelected={ isSelected( color ) }\n\t\t\t\t\t\t\t\t\t\topacity={ opacity }\n\t\t\t\t\t\t\t\t\t\tstyle={ [\n\t\t\t\t\t\t\t\t\t\t\tstyles.colorIndicator,\n\t\t\t\t\t\t\t\t\t\t\tcustomColorIndicatorStyles,\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</Animated.View>\n\t\t\t\t\t\t\t</TouchableWithoutFeedback>\n\t\t\t\t\t\t</View>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t\t\t{ shouldShowCustomIndicator && (\n\t\t\t\t\t<View\n\t\t\t\t\t\tstyle={ customIndicatorWrapperStyle }\n\t\t\t\t\t\tonLayout={ onCustomIndicatorLayout }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ shouldShowCustomVerticalSeparator && (\n\t\t\t\t\t\t\t<View style={ verticalSeparatorStyle } />\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<TouchableWithoutFeedback\n\t\t\t\t\t\t\tonPress={ onCustomPress }\n\t\t\t\t\t\t\taccessibilityRole={ 'button' }\n\t\t\t\t\t\t\taccessibilityState={ {\n\t\t\t\t\t\t\t\tselected: isSelectedCustom(),\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\taccessibilityHint={ accessibilityHint }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<View style={ customIndicatorWrapperStyle }>\n\t\t\t\t\t\t\t\t<ColorIndicator\n\t\t\t\t\t\t\t\t\twithCustomPicker={ ! isGradientSegment }\n\t\t\t\t\t\t\t\t\tcolor={ customIndicatorColor }\n\t\t\t\t\t\t\t\t\tisSelected={ isSelectedCustom() }\n\t\t\t\t\t\t\t\t\tstyle={ [\n\t\t\t\t\t\t\t\t\t\tstyles.colorIndicator,\n\t\t\t\t\t\t\t\t\t\tcustomColorIndicatorStyles,\n\t\t\t\t\t\t\t\t\t] }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t{ shouldShowCustomLabel && (\n\t\t\t\t\t\t\t\t\t<Text style={ customTextStyle }>\n\t\t\t\t\t\t\t\t\t\t{ isIOS\n\t\t\t\t\t\t\t\t\t\t\t? customText\n\t\t\t\t\t\t\t\t\t\t\t: customText.toUpperCase() }\n\t\t\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</View>\n\t\t\t\t\t\t</TouchableWithoutFeedback>\n\t\t\t\t\t</View>\n\t\t\t\t) }\n\t\t\t</ScrollView>\n\t\t</>\n\t);\n}\n\nexport default ColorPalette;\n"]}
@@ -0,0 +1,103 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.showTransparentBackground = exports.normalizeColorValue = exports.isMultiplePaletteObject = exports.isMultiplePaletteArray = exports.extractColorNameFromCurrentValue = void 0;
9
+
10
+ var _colord = require("colord");
11
+
12
+ var _names = _interopRequireDefault(require("colord/plugins/names"));
13
+
14
+ var _a11y = _interopRequireDefault(require("colord/plugins/a11y"));
15
+
16
+ var _i18n = require("@wordpress/i18n");
17
+
18
+ /**
19
+ * External dependencies
20
+ */
21
+
22
+ /**
23
+ * WordPress dependencies
24
+ */
25
+ (0, _colord.extend)([_names.default, _a11y.default]);
26
+
27
+ const extractColorNameFromCurrentValue = function (currentValue) {
28
+ let colors = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
29
+ let showMultiplePalettes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
30
+
31
+ if (!currentValue) {
32
+ return '';
33
+ }
34
+
35
+ const currentValueIsCssVariable = /^var\(/.test(currentValue);
36
+ const normalizedCurrentValue = currentValueIsCssVariable ? currentValue : (0, _colord.colord)(currentValue).toHex(); // Normalize format of `colors` to simplify the following loop
37
+
38
+ const colorPalettes = showMultiplePalettes ? colors : [{
39
+ colors: colors
40
+ }];
41
+
42
+ for (const {
43
+ colors: paletteColors
44
+ } of colorPalettes) {
45
+ for (const {
46
+ name: colorName,
47
+ color: colorValue
48
+ } of paletteColors) {
49
+ const normalizedColorValue = currentValueIsCssVariable ? colorValue : (0, _colord.colord)(colorValue).toHex();
50
+
51
+ if (normalizedCurrentValue === normalizedColorValue) {
52
+ return colorName;
53
+ }
54
+ }
55
+ } // translators: shown when the user has picked a custom color (i.e not in the palette of colors).
56
+
57
+
58
+ return (0, _i18n.__)('Custom');
59
+ };
60
+
61
+ exports.extractColorNameFromCurrentValue = extractColorNameFromCurrentValue;
62
+
63
+ const showTransparentBackground = currentValue => {
64
+ if (typeof currentValue === 'undefined') {
65
+ return true;
66
+ }
67
+
68
+ return (0, _colord.colord)(currentValue).alpha() === 0;
69
+ }; // The PaletteObject type has a `colors` property (an array of ColorObject),
70
+ // while the ColorObject type has a `color` property (the CSS color value).
71
+
72
+
73
+ exports.showTransparentBackground = showTransparentBackground;
74
+
75
+ const isMultiplePaletteObject = obj => Array.isArray(obj.colors) && !('color' in obj);
76
+
77
+ exports.isMultiplePaletteObject = isMultiplePaletteObject;
78
+
79
+ const isMultiplePaletteArray = arr => {
80
+ return arr.length > 0 && arr.every(colorObj => isMultiplePaletteObject(colorObj));
81
+ };
82
+
83
+ exports.isMultiplePaletteArray = isMultiplePaletteArray;
84
+
85
+ const normalizeColorValue = (value, ref) => {
86
+ const currentValueIsCssVariable = /^var\(/.test(value !== null && value !== void 0 ? value : '');
87
+
88
+ if (!currentValueIsCssVariable || !(ref !== null && ref !== void 0 && ref.current)) {
89
+ return value;
90
+ }
91
+
92
+ const {
93
+ ownerDocument
94
+ } = ref.current;
95
+ const {
96
+ defaultView
97
+ } = ownerDocument;
98
+ const computedBackgroundColor = defaultView === null || defaultView === void 0 ? void 0 : defaultView.getComputedStyle(ref.current).backgroundColor;
99
+ return computedBackgroundColor ? (0, _colord.colord)(computedBackgroundColor).toHex() : value;
100
+ };
101
+
102
+ exports.normalizeColorValue = normalizeColorValue;
103
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/components/src/color-palette/utils.ts"],"names":["namesPlugin","a11yPlugin","extractColorNameFromCurrentValue","currentValue","colors","showMultiplePalettes","currentValueIsCssVariable","test","normalizedCurrentValue","toHex","colorPalettes","paletteColors","name","colorName","color","colorValue","normalizedColorValue","showTransparentBackground","alpha","isMultiplePaletteObject","obj","Array","isArray","isMultiplePaletteArray","arr","length","every","colorObj","normalizeColorValue","value","ref","current","ownerDocument","defaultView","computedBackgroundColor","getComputedStyle","backgroundColor"],"mappings":";;;;;;;;;AAIA;;AACA;;AACA;;AAKA;;AAXA;AACA;AACA;;AAMA;AACA;AACA;AAQA,oBAAQ,CAAEA,cAAF,EAAeC,aAAf,CAAR;;AAEO,MAAMC,gCAAgC,GAAG,UAC/CC,YAD+C,EAI3C;AAAA,MAFJC,MAEI,uEAFoC,EAEpC;AAAA,MADJC,oBACI,uEAD4B,KAC5B;;AACJ,MAAK,CAAEF,YAAP,EAAsB;AACrB,WAAO,EAAP;AACA;;AAED,QAAMG,yBAAyB,GAAG,SAASC,IAAT,CAAeJ,YAAf,CAAlC;AACA,QAAMK,sBAAsB,GAAGF,yBAAyB,GACrDH,YADqD,GAErD,oBAAQA,YAAR,EAAuBM,KAAvB,EAFH,CANI,CAUJ;;AAEA,QAAMC,aAAwC,GAAGL,oBAAoB,GAChED,MADgE,GAElE,CAAE;AAAEA,IAAAA,MAAM,EAAEA;AAAV,GAAF,CAFH;;AAGA,OAAM,MAAM;AAAEA,IAAAA,MAAM,EAAEO;AAAV,GAAZ,IAAyCD,aAAzC,EAAyD;AACxD,SAAM,MAAM;A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AAkBD,aAAxB;AACA,QAAME,uBAAuB,GAAGD,WAAH,aAAGA,WAAH,uBAAGA,WAAW,CAAEE,gBAAb,CAC/BL,GAAG,CAACC,OAD2B,EAE9BK,eAFF;AAIA,SAAOF,uBAAuB,GAC3B,oBAAQA,uBAAR,EAAkCzB,KAAlC,EAD2B,GAE3BoB,KAFH;AAGA,CAnBM","sourcesContent":["/**\n * External dependencies\n */\nimport type { RefObject } from 'react';\nimport { colord, extend } from 'colord';\nimport namesPlugin from 'colord/plugins/names';\nimport a11yPlugin from 'colord/plugins/a11y';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport type { ColorObject, ColorPaletteProps, PaletteObject } from './types';\n\nextend( [ namesPlugin, a11yPlugin ] );\n\nexport const extractColorNameFromCurrentValue = (\n\tcurrentValue?: ColorPaletteProps[ 'value' ],\n\tcolors: ColorPaletteProps[ 'colors' ] = [],\n\tshowMultiplePalettes: boolean = false\n) => {\n\tif ( ! currentValue ) {\n\t\treturn '';\n\t}\n\n\tconst currentValueIsCssVariable = /^var\\(/.test( currentValue );\n\tconst normalizedCurrentValue = currentValueIsCssVariable\n\t\t? currentValue\n\t\t: colord( currentValue ).toHex();\n\n\t// Normalize format of `colors` to simplify the following loop\n\ttype normalizedPaletteObject = { colors: ColorObject[] };\n\tconst colorPalettes: normalizedPaletteObject[] = showMultiplePalettes\n\t\t? ( colors as PaletteObject[] )\n\t\t: [ { colors: colors as ColorObject[] } ];\n\tfor ( const { colors: paletteColors } of colorPalettes ) {\n\t\tfor ( const { name: colorName, color: colorValue } of paletteColors ) {\n\t\t\tconst normalizedColorValue = currentValueIsCssVariable\n\t\t\t\t? colorValue\n\t\t\t\t: colord( colorValue ).toHex();\n\n\t\t\tif ( normalizedCurrentValue === normalizedColorValue ) {\n\t\t\t\treturn colorName;\n\t\t\t}\n\t\t}\n\t}\n\n\t// translators: shown when the user has picked a custom color (i.e not in the palette of colors).\n\treturn __( 'Custom' );\n};\n\nexport const showTransparentBackground = ( currentValue?: string ) => {\n\tif ( typeof currentValue === 'undefined' ) {\n\t\treturn true;\n\t}\n\treturn colord( currentValue ).alpha() === 0;\n};\n\n// The PaletteObject type has a `colors` property (an array of ColorObject),\n// while the ColorObject type has a `color` property (the CSS color value).\nexport const isMultiplePaletteObject = (\n\tobj: PaletteObject | ColorObject\n): obj is PaletteObject =>\n\tArray.isArray( ( obj as PaletteObject ).colors ) && ! ( 'color' in obj );\n\nexport const isMultiplePaletteArray = (\n\tarr: ( PaletteObject | ColorObject )[]\n): arr is PaletteObject[] => {\n\treturn (\n\t\tarr.length > 0 &&\n\t\tarr.every( ( colorObj ) => isMultiplePaletteObject( colorObj ) )\n\t);\n};\n\nexport const normalizeColorValue = (\n\tvalue: string | undefined,\n\tref: RefObject< HTMLElement > | null\n) => {\n\tconst currentValueIsCssVariable = /^var\\(/.test( value ?? '' );\n\n\tif ( ! currentValueIsCssVariable || ! ref?.current ) {\n\t\treturn value;\n\t}\n\n\tconst { ownerDocument } = ref.current;\n\tconst { defaultView } = ownerDocument;\n\tconst computedBackgroundColor = defaultView?.getComputedStyle(\n\t\tref.current\n\t).backgroundColor;\n\n\treturn computedBackgroundColor\n\t\t? colord( computedBackgroundColor ).toHex()\n\t\t: value;\n};\n"]}
@@ -86,6 +86,7 @@ const ColorPicker = (props, forwardedRef) => {
86
86
  }), (0, _element.createElement)(_styles.AuxiliaryColorArtefactWrapper, null, (0, _element.createElement)(_styles.AuxiliaryColorArtefactHStackHeader, {
87
87
  justify: "space-between"
88
88
  }, (0, _element.createElement)(_styles.SelectControl, {
89
+ __nextHasNoMarginBottom: true,
89
90
  options: options,
90
91
  value: colorType,
91
92
  onChange: nextColorType => setColorType(nextColorType),
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/color-picker/component.tsx"],"names":["namesPlugin","options","label","value","ColorPicker","props","forwardedRef","enableAlpha","color","colorProp","onChange","defaultValue","copyFormat","divProps","setColor","safeColordColor","debouncedSetColor","handleChange","nextValue","toHex","colorType","setColorType","nextColorType","ConnectedColorPicker"],"mappings":";;;;;;;;;AAUA;;;;AANA;;AACA;;AAMA;;AACA;;AAKA;;AAKA;;AAOA;;AACA;;AACA;;AACA;;AAhCA;AACA;AACA;;AAKA;AACA;AACA;;AAKA;AACA;AACA;AAoBA,oBAAQ,CAAEA,cAAF,CAAR;AAUA,MAAMC,OAAO,GAAG,CACf;AAAEC,EAAAA,KAAK,EAAE,KAAT;AAAgBC,EAAAA,KAAK,EAAE;AAAvB,CADe,EAEf;AAAED,EAAAA,KAAK,EAAE,KAAT;AAAgBC,EAAAA,KAAK,EAAE;AAAvB,CAFe,EAGf;AAAED,EAAAA,KAAK,EAAE,KAAT;AAAgBC,EAAAA,KAAK,EAAE;AAAvB,CAHe,CAAhB;;AAMA,MAAMC,WAAW,GAAG,CACnBC,KADmB,EAEnBC,YAFmB,KAGf;AACJ,QAAM;AACLC,IAAAA,WAAW,GAAG,KADT;AAELC,IAAAA,KAAK,EAAEC,SAFF;AAGLC,IAAAA,QAHK;AAILC,IAAAA,YAAY,GAAG,MAJV;AAKLC,IAAAA,UALK;AAML,OAAGC;AANE,MAOF,+BAAkBR,KAAlB,EAAyB,aAAzB,CAPJ,CADI,CAUJ;;AACA,QAAM,CAAEG,KAAF,EAASM,QAAT,IAAsB,+BAAoB;AAC/CJ,IAAAA,QAD+C;AAE/CP,IAAAA,KAAK,EAAEM,SAFwC;AAG/CE,IAAAA;AAH+C,GAApB,CAA5B;AAMA,QAAMI,eAAe,GAAG,sBAAS,MAAM;AACtC,WAAO,oBAAQP,KAAK,IAAI,EAAjB,CAAP;AACA,GAFuB,EAErB,CAAEA,KAAF,CAFqB,CAAxB;AAIA,QAAMQ,iBAAiB,GAAG,0BAAaF,QAAb,CAA1B;AAEA,QAAMG,YAAY,GAAG,0BAClBC,SAAF,IAAyB;AACxBF,IAAAA,iBAAiB,CAAEE,SAAS,CAACC,KAAV,EAAF,CAAjB;AACA,GAHmB,EAIpB,CAAEH,iBAAF,CAJoB,CAArB;AAOA,QAAM,CAAEI,SAAF,EAAaC,YAAb,IAA8B,uBACnCT,UAAU,IAAI,KADqB,CAApC;AAIA,SACC,4BAAC,uBAAD;AAAiB,IAAA,GAAG,EAAGN;AAAvB,KAA2CO,QAA3C,GACC,4BAAC,cAAD;AACC,IAAA,QAAQ,EAAGI,YADZ;AAEC,IAAA,KAAK,EAAGF,eAFT;AAGC,IAAA,WAAW,EAAGR;AAHf,IADD,EAMC,4BAAC,qCAAD,QACC,4BAAC,0CAAD;AAAoC,IAAA,OAAO,EAAC;AAA5C,KACC,4BAAC,qBAAD;AACC,IAAA,OAAO,EAAGN,OADX;AAEC,IAAA,KAAK,EAAGmB,SAFT;AAGC,IAAA,QAAQ,EAAKE,aAAF,IACVD,YAAY,CAAEC,aAAF,CAJd;AAMC,IAAA,KAAK,EAAG,cAAI,cAAJ,CANT;AAOC,IAAA,mBAAmB;AAPpB,IADD,EAUC,4BAAC,gCAAD;AACC,IAAA,KAAK,EAAGP,eADT;AAEC,IAAA,SAAS,EAAGH,UAAU,IAAIQ;AAF3B,IAVD,CADD,EAgBC,4BAAC,yBAAD;AAAmB,IAAA,SAAS,EAAC,QAA7B;AAAsC,IAAA,GAAG,EAAG;AAA5C,KACC,4BAAC,sBAAD;AACC,IAAA,SAAS,EAAGA,SADb;AAEC,IAAA,KAAK,EAAGL,eAFT;AAGC,IAAA,QAAQ,EAAGE,YAHZ;AAIC,IAAA,WAAW,EAAGV;AAJf,IADD,CAhBD,CAND,CADD;AAkCA,CAvED;;AAyEA,MAAMgB,oBAAoB,GAAG,6BAAgBnB,WAAhB,EAA6B,aAA7B,CAA7B;eAEemB,oB","sourcesContent":["/**\n * External dependencies\n */\nimport type { ForwardedRef } from 'react';\nimport { colord, extend, Colord } from 'colord';\nimport namesPlugin from 'colord/plugins/names';\n\n/**\n * WordPress dependencies\n */\nimport { useCallback, useState, useMemo } from '@wordpress/element';\nimport { useDebounce } from '@wordpress/compose';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport {\n\tuseContextSystem,\n\tcontextConnect,\n\tWordPressComponentProps,\n} from '../ui/context';\nimport {\n\tColorfulWrapper,\n\tSelectControl,\n\tAuxiliaryColorArtefactWrapper,\n\tAuxiliaryColorArtefactHStackHeader,\n\tColorInputWrapper,\n} from './styles';\nimport { ColorCopyButton } from './color-copy-button';\nimport { ColorInput } from './color-input';\nimport { Picker } from './picker';\nimport { useControlledValue } from '../utils/hooks';\n\nimport type { ColorType } from './types';\n\nextend( [ namesPlugin ] );\n\nexport interface ColorPickerProps {\n\tenableAlpha?: boolean;\n\tcolor?: string;\n\tonChange?: ( color: string ) => void;\n\tdefaultValue?: string;\n\tcopyFormat?: ColorType;\n}\n\nconst options = [\n\t{ label: 'RGB', value: 'rgb' as const },\n\t{ label: 'HSL', value: 'hsl' as const },\n\t{ label: 'Hex', value: 'hex' as const },\n];\n\nconst ColorPicker = (\n\tprops: WordPressComponentProps< ColorPickerProps, 'div', false >,\n\tforwardedRef: ForwardedRef< any >\n) => {\n\tconst {\n\t\tenableAlpha = false,\n\t\tcolor: colorProp,\n\t\tonChange,\n\t\tdefaultValue = '#fff',\n\t\tcopyFormat,\n\t\t...divProps\n\t} = useContextSystem( props, 'ColorPicker' );\n\n\t// Use a safe default value for the color and remove the possibility of `undefined`.\n\tconst [ color, setColor ] = useControlledValue( {\n\t\tonChange,\n\t\tvalue: colorProp,\n\t\tdefaultValue,\n\t} );\n\n\tconst safeColordColor = useMemo( () => {\n\t\treturn colord( color || '' );\n\t}, [ color ] );\n\n\tconst debouncedSetColor = useDebounce( setColor );\n\n\tconst handleChange = useCallback(\n\t\t( nextValue: Colord ) => {\n\t\t\tdebouncedSetColor( nextValue.toHex() );\n\t\t},\n\t\t[ debouncedSetColor ]\n\t);\n\n\tconst [ colorType, setColorType ] = useState< ColorType >(\n\t\tcopyFormat || 'hex'\n\t);\n\n\treturn (\n\t\t<ColorfulWrapper ref={ forwardedRef } { ...divProps }>\n\t\t\t<Picker\n\t\t\t\tonChange={ handleChange }\n\t\t\t\tcolor={ safeColordColor }\n\t\t\t\tenableAlpha={ enableAlpha }\n\t\t\t/>\n\t\t\t<AuxiliaryColorArtefactWrapper>\n\t\t\t\t<AuxiliaryColorArtefactHStackHeader justify=\"space-between\">\n\t\t\t\t\t<SelectControl\n\t\t\t\t\t\toptions={ options }\n\t\t\t\t\t\tvalue={ colorType }\n\t\t\t\t\t\tonChange={ ( nextColorType ) =>\n\t\t\t\t\t\t\tsetColorType( nextColorType as ColorType )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tlabel={ __( 'Color format' ) }\n\t\t\t\t\t\thideLabelFromVision\n\t\t\t\t\t/>\n\t\t\t\t\t<ColorCopyButton\n\t\t\t\t\t\tcolor={ safeColordColor }\n\t\t\t\t\t\tcolorType={ copyFormat || colorType }\n\t\t\t\t\t/>\n\t\t\t\t</AuxiliaryColorArtefactHStackHeader>\n\t\t\t\t<ColorInputWrapper direction=\"column\" gap={ 2 }>\n\t\t\t\t\t<ColorInput\n\t\t\t\t\t\tcolorType={ colorType }\n\t\t\t\t\t\tcolor={ safeColordColor }\n\t\t\t\t\t\tonChange={ handleChange }\n\t\t\t\t\t\tenableAlpha={ enableAlpha }\n\t\t\t\t\t/>\n\t\t\t\t</ColorInputWrapper>\n\t\t\t</AuxiliaryColorArtefactWrapper>\n\t\t</ColorfulWrapper>\n\t);\n};\n\nconst ConnectedColorPicker = contextConnect( ColorPicker, 'ColorPicker' );\n\nexport default ConnectedColorPicker;\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/color-picker/component.tsx"],"names":["namesPlugin","options","label","value","ColorPicker","props","forwardedRef","enableAlpha","color","colorProp","onChange","defaultValue","copyFormat","divProps","setColor","safeColordColor","debouncedSetColor","handleChange","nextValue","toHex","colorType","setColorType","nextColorType","ConnectedColorPicker"],"mappings":";;;;;;;;;AAUA;;;;AANA;;AACA;;AAMA;;AACA;;AAKA;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A,SACC,4BAAC,uBAAD;AAAiB,IAAA,GAAG,EAAGN;AAAvB,KAA2CO,QAA3C,GACC,4BAAC,cAAD;AACC,IAAA,QAAQ,EAAGI,YADZ;AAEC,IAAA,KAAK,EAAGF,eAFT;AAGC,IAAA,WAAW,EAAGR;AAHf,IADD,EAMC,4BAAC,qCAAD,QACC,4BAAC,0CAAD;AAAoC,IAAA,OAAO,EAAC;AAA5C,KACC,4BAAC,qBAAD;AACC,IAAA,uBAAuB,MADxB;AAEC,IAAA,OAAO,EAAGN,OAFX;AAGC,IAAA,KAAK,EAAGmB,SAHT;AAIC,IAAA,QAAQ,EAAKE,aAAF,IACVD,YAAY,CAAEC,aAAF,CALd;AAOC,IAAA,KAAK,EAAG,cAAI,cAAJ,CAPT;AAQC,IAAA,mBAAmB;AARpB,IADD,EAWC,4BAAC,gCAAD;AACC,IAAA,KAAK,EAAGP,eADT;AAEC,IAAA,SAAS,EAAGH,UAAU,IAAIQ;AAF3B,IAXD,CADD,EAiBC,4BAAC,yBAAD;AAAmB,IAAA,SAAS,EAAC,QAA7B;AAAsC,IAAA,GAAG,EAAG;AAA5C,KACC,4BAAC,sBAAD;AACC,IAAA,SAAS,EAAGA,SADb;AAEC,IAAA,KAAK,EAAGL,eAFT;AAGC,IAAA,QAAQ,EAAGE,YAHZ;AAIC,IAAA,WAAW,EAAGV;AAJf,IADD,CAjBD,CAND,CADD;AAmCA,CAxED;;AA0EA,MAAMgB,oBAAoB,GAAG,6BAAgBnB,WAAhB,EAA6B,aAA7B,CAA7B;eAEemB,oB","sourcesContent":["/**\n * External dependencies\n */\nimport type { ForwardedRef } from 'react';\nimport { colord, extend, Colord } from 'colord';\nimport namesPlugin from 'colord/plugins/names';\n\n/**\n * WordPress dependencies\n */\nimport { useCallback, useState, useMemo } from '@wordpress/element';\nimport { useDebounce } from '@wordpress/compose';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport {\n\tuseContextSystem,\n\tcontextConnect,\n\tWordPressComponentProps,\n} from '../ui/context';\nimport {\n\tColorfulWrapper,\n\tSelectControl,\n\tAuxiliaryColorArtefactWrapper,\n\tAuxiliaryColorArtefactHStackHeader,\n\tColorInputWrapper,\n} from './styles';\nimport { ColorCopyButton } from './color-copy-button';\nimport { ColorInput } from './color-input';\nimport { Picker } from './picker';\nimport { useControlledValue } from '../utils/hooks';\n\nimport type { ColorType } from './types';\n\nextend( [ namesPlugin ] );\n\nexport interface ColorPickerProps {\n\tenableAlpha?: boolean;\n\tcolor?: string;\n\tonChange?: ( color: string ) => void;\n\tdefaultValue?: string;\n\tcopyFormat?: ColorType;\n}\n\nconst options = [\n\t{ label: 'RGB', value: 'rgb' as const },\n\t{ label: 'HSL', value: 'hsl' as const },\n\t{ label: 'Hex', value: 'hex' as const },\n];\n\nconst ColorPicker = (\n\tprops: WordPressComponentProps< ColorPickerProps, 'div', false >,\n\tforwardedRef: ForwardedRef< any >\n) => {\n\tconst {\n\t\tenableAlpha = false,\n\t\tcolor: colorProp,\n\t\tonChange,\n\t\tdefaultValue = '#fff',\n\t\tcopyFormat,\n\t\t...divProps\n\t} = useContextSystem( props, 'ColorPicker' );\n\n\t// Use a safe default value for the color and remove the possibility of `undefined`.\n\tconst [ color, setColor ] = useControlledValue( {\n\t\tonChange,\n\t\tvalue: colorProp,\n\t\tdefaultValue,\n\t} );\n\n\tconst safeColordColor = useMemo( () => {\n\t\treturn colord( color || '' );\n\t}, [ color ] );\n\n\tconst debouncedSetColor = useDebounce( setColor );\n\n\tconst handleChange = useCallback(\n\t\t( nextValue: Colord ) => {\n\t\t\tdebouncedSetColor( nextValue.toHex() );\n\t\t},\n\t\t[ debouncedSetColor ]\n\t);\n\n\tconst [ colorType, setColorType ] = useState< ColorType >(\n\t\tcopyFormat || 'hex'\n\t);\n\n\treturn (\n\t\t<ColorfulWrapper ref={ forwardedRef } { ...divProps }>\n\t\t\t<Picker\n\t\t\t\tonChange={ handleChange }\n\t\t\t\tcolor={ safeColordColor }\n\t\t\t\tenableAlpha={ enableAlpha }\n\t\t\t/>\n\t\t\t<AuxiliaryColorArtefactWrapper>\n\t\t\t\t<AuxiliaryColorArtefactHStackHeader justify=\"space-between\">\n\t\t\t\t\t<SelectControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\toptions={ options }\n\t\t\t\t\t\tvalue={ colorType }\n\t\t\t\t\t\tonChange={ ( nextColorType ) =>\n\t\t\t\t\t\t\tsetColorType( nextColorType as ColorType )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tlabel={ __( 'Color format' ) }\n\t\t\t\t\t\thideLabelFromVision\n\t\t\t\t\t/>\n\t\t\t\t\t<ColorCopyButton\n\t\t\t\t\t\tcolor={ safeColordColor }\n\t\t\t\t\t\tcolorType={ copyFormat || colorType }\n\t\t\t\t\t/>\n\t\t\t\t</AuxiliaryColorArtefactHStackHeader>\n\t\t\t\t<ColorInputWrapper direction=\"column\" gap={ 2 }>\n\t\t\t\t\t<ColorInput\n\t\t\t\t\t\tcolorType={ colorType }\n\t\t\t\t\t\tcolor={ safeColordColor }\n\t\t\t\t\t\tonChange={ handleChange }\n\t\t\t\t\t\tenableAlpha={ enableAlpha }\n\t\t\t\t\t/>\n\t\t\t\t</ColorInputWrapper>\n\t\t\t</AuxiliaryColorArtefactWrapper>\n\t\t</ColorfulWrapper>\n\t);\n};\n\nconst ConnectedColorPicker = contextConnect( ColorPicker, 'ColorPicker' );\n\nexport default ConnectedColorPicker;\n"]}