@wordpress/components 23.2.0 → 23.3.1

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 (377) hide show
  1. package/CHANGELOG.md +35 -1
  2. package/CONTRIBUTING.md +1 -1
  3. package/build/alignment-matrix-control/utils.js +2 -2
  4. package/build/alignment-matrix-control/utils.js.map +1 -1
  5. package/build/autocomplete/autocompleter-ui.js +1 -3
  6. package/build/autocomplete/autocompleter-ui.js.map +1 -1
  7. package/build/border-box-control/border-box-control-linked-button/component.js.map +1 -1
  8. package/build/border-box-control/border-box-control-linked-button/hook.js.map +1 -1
  9. package/build/border-control/border-control-dropdown/component.js +8 -4
  10. package/build/border-control/border-control-dropdown/component.js.map +1 -1
  11. package/build/button/deprecated.js +8 -6
  12. package/build/button/deprecated.js.map +1 -1
  13. package/build/button/index.js +52 -23
  14. package/build/button/index.js.map +1 -1
  15. package/build/button/types.js +6 -0
  16. package/build/button/types.js.map +1 -0
  17. package/build/color-list-picker/index.js.map +1 -1
  18. package/build/color-list-picker/types.js +6 -0
  19. package/build/color-list-picker/types.js.map +1 -0
  20. package/build/color-palette/index.js +9 -61
  21. package/build/color-palette/index.js.map +1 -1
  22. package/build/color-palette/index.native.js +24 -9
  23. package/build/color-palette/index.native.js.map +1 -1
  24. package/build/color-palette/utils.js +103 -0
  25. package/build/color-palette/utils.js.map +1 -0
  26. package/build/custom-gradient-picker/gradient-bar/utils.js +1 -1
  27. package/build/custom-gradient-picker/gradient-bar/utils.js.map +1 -1
  28. package/build/date-time/date/index.js.map +1 -1
  29. package/build/dropdown/index.js +20 -8
  30. package/build/dropdown/index.js.map +1 -1
  31. package/build/form-token-field/token.js +1 -1
  32. package/build/form-token-field/token.js.map +1 -1
  33. package/build/gradient-picker/index.js +9 -1
  34. package/build/gradient-picker/index.js.map +1 -1
  35. package/build/h-stack/component.js +0 -1
  36. package/build/h-stack/component.js.map +1 -1
  37. package/build/input-control/input-field.js +4 -2
  38. package/build/input-control/input-field.js.map +1 -1
  39. package/build/keyboard-shortcuts/index.js +44 -16
  40. package/build/keyboard-shortcuts/index.js.map +1 -1
  41. package/build/keyboard-shortcuts/types.js +6 -0
  42. package/build/keyboard-shortcuts/types.js.map +1 -0
  43. package/build/modal/index.js +1 -1
  44. package/build/modal/index.js.map +1 -1
  45. package/build/notice/index.js +16 -18
  46. package/build/notice/index.js.map +1 -1
  47. package/build/notice/list.js +23 -8
  48. package/build/notice/list.js.map +1 -1
  49. package/build/notice/types.js +6 -0
  50. package/build/notice/types.js.map +1 -0
  51. package/build/number-control/index.js +1 -1
  52. package/build/number-control/index.js.map +1 -1
  53. package/build/query-controls/author-select.js +7 -3
  54. package/build/query-controls/author-select.js.map +1 -1
  55. package/build/query-controls/category-select.js +7 -3
  56. package/build/query-controls/category-select.js.map +1 -1
  57. package/build/query-controls/index.js +68 -20
  58. package/build/query-controls/index.js.map +1 -1
  59. package/build/query-controls/terms.js +4 -3
  60. package/build/query-controls/terms.js.map +1 -1
  61. package/build/query-controls/types.js +6 -0
  62. package/build/query-controls/types.js.map +1 -0
  63. package/build/slot-fill/bubbles-virtually/fill.js +1 -0
  64. package/build/slot-fill/bubbles-virtually/fill.js.map +1 -1
  65. package/build/slot-fill/slot.js +1 -0
  66. package/build/slot-fill/slot.js.map +1 -1
  67. package/build/slot-fill/use-slot.js +1 -11
  68. package/build/slot-fill/use-slot.js.map +1 -1
  69. package/build/snackbar/index.js.map +1 -1
  70. package/build/snackbar/list.js.map +1 -1
  71. package/build/tab-panel/index.js +36 -8
  72. package/build/tab-panel/index.js.map +1 -1
  73. package/build/tree-grid/index.js +1 -1
  74. package/build/tree-grid/index.js.map +1 -1
  75. package/build/tree-select/index.js +2 -6
  76. package/build/tree-select/index.js.map +1 -1
  77. package/build-module/alignment-matrix-control/utils.js +2 -2
  78. package/build-module/alignment-matrix-control/utils.js.map +1 -1
  79. package/build-module/autocomplete/autocompleter-ui.js +1 -2
  80. package/build-module/autocomplete/autocompleter-ui.js.map +1 -1
  81. package/build-module/border-box-control/border-box-control-linked-button/component.js.map +1 -1
  82. package/build-module/border-box-control/border-box-control-linked-button/hook.js.map +1 -1
  83. package/build-module/border-control/border-control-dropdown/component.js +7 -4
  84. package/build-module/border-control/border-control-dropdown/component.js.map +1 -1
  85. package/build-module/button/deprecated.js +8 -5
  86. package/build-module/button/deprecated.js.map +1 -1
  87. package/build-module/button/index.js +51 -22
  88. package/build-module/button/index.js.map +1 -1
  89. package/build-module/button/types.js +2 -0
  90. package/build-module/button/types.js.map +1 -0
  91. package/build-module/color-list-picker/index.js.map +1 -1
  92. package/build-module/color-list-picker/types.js +2 -0
  93. package/build-module/color-list-picker/types.js.map +1 -0
  94. package/build-module/color-palette/index.js +7 -54
  95. package/build-module/color-palette/index.js.map +1 -1
  96. package/build-module/color-palette/index.native.js +24 -8
  97. package/build-module/color-palette/index.native.js.map +1 -1
  98. package/build-module/color-palette/utils.js +79 -0
  99. package/build-module/color-palette/utils.js.map +1 -0
  100. package/build-module/custom-gradient-picker/gradient-bar/utils.js +1 -1
  101. package/build-module/custom-gradient-picker/gradient-bar/utils.js.map +1 -1
  102. package/build-module/date-time/date/index.js +1 -1
  103. package/build-module/date-time/date/index.js.map +1 -1
  104. package/build-module/dropdown/index.js +19 -8
  105. package/build-module/dropdown/index.js.map +1 -1
  106. package/build-module/form-token-field/token.js +1 -1
  107. package/build-module/form-token-field/token.js.map +1 -1
  108. package/build-module/gradient-picker/index.js +9 -2
  109. package/build-module/gradient-picker/index.js.map +1 -1
  110. package/build-module/h-stack/component.js +0 -1
  111. package/build-module/h-stack/component.js.map +1 -1
  112. package/build-module/input-control/input-field.js +4 -2
  113. package/build-module/input-control/input-field.js.map +1 -1
  114. package/build-module/keyboard-shortcuts/index.js +48 -16
  115. package/build-module/keyboard-shortcuts/index.js.map +1 -1
  116. package/build-module/keyboard-shortcuts/types.js +2 -0
  117. package/build-module/keyboard-shortcuts/types.js.map +1 -0
  118. package/build-module/modal/index.js +1 -1
  119. package/build-module/modal/index.js.map +1 -1
  120. package/build-module/notice/index.js +14 -15
  121. package/build-module/notice/index.js.map +1 -1
  122. package/build-module/notice/list.js +23 -8
  123. package/build-module/notice/list.js.map +1 -1
  124. package/build-module/notice/types.js +2 -0
  125. package/build-module/notice/types.js.map +1 -0
  126. package/build-module/number-control/index.js +1 -1
  127. package/build-module/number-control/index.js.map +1 -1
  128. package/build-module/query-controls/author-select.js +7 -3
  129. package/build-module/query-controls/author-select.js.map +1 -1
  130. package/build-module/query-controls/category-select.js +8 -4
  131. package/build-module/query-controls/category-select.js.map +1 -1
  132. package/build-module/query-controls/index.js +64 -20
  133. package/build-module/query-controls/index.js.map +1 -1
  134. package/build-module/query-controls/terms.js +8 -4
  135. package/build-module/query-controls/terms.js.map +1 -1
  136. package/build-module/query-controls/types.js +2 -0
  137. package/build-module/query-controls/types.js.map +1 -0
  138. package/build-module/slot-fill/bubbles-virtually/fill.js +1 -0
  139. package/build-module/slot-fill/bubbles-virtually/fill.js.map +1 -1
  140. package/build-module/slot-fill/slot.js +1 -0
  141. package/build-module/slot-fill/slot.js.map +1 -1
  142. package/build-module/slot-fill/use-slot.js +2 -12
  143. package/build-module/slot-fill/use-slot.js.map +1 -1
  144. package/build-module/snackbar/index.js.map +1 -1
  145. package/build-module/snackbar/list.js.map +1 -1
  146. package/build-module/tab-panel/index.js +36 -8
  147. package/build-module/tab-panel/index.js.map +1 -1
  148. package/build-module/tree-grid/index.js +1 -1
  149. package/build-module/tree-grid/index.js.map +1 -1
  150. package/build-module/tree-select/index.js +2 -6
  151. package/build-module/tree-select/index.js.map +1 -1
  152. package/build-style/style-rtl.css +5 -0
  153. package/build-style/style.css +5 -0
  154. package/build-types/border-box-control/border-box-control/hook.d.ts +1 -1
  155. package/build-types/border-box-control/border-box-control-linked-button/component.d.ts +1 -1
  156. package/build-types/border-box-control/border-box-control-linked-button/hook.d.ts +171 -160
  157. package/build-types/border-box-control/border-box-control-linked-button/hook.d.ts.map +1 -1
  158. package/build-types/border-box-control/border-box-control-split-controls/hook.d.ts +1 -1
  159. package/build-types/border-control/border-control/hook.d.ts +1 -1
  160. package/build-types/border-control/border-control-dropdown/component.d.ts.map +1 -1
  161. package/build-types/border-control/border-control-dropdown/hook.d.ts +1 -1
  162. package/build-types/button/deprecated.d.ts +143 -7
  163. package/build-types/button/deprecated.d.ts.map +1 -1
  164. package/build-types/button/index.d.ts +20 -3
  165. package/build-types/button/index.d.ts.map +1 -1
  166. package/build-types/button/stories/index.d.ts +20 -0
  167. package/build-types/button/stories/index.d.ts.map +1 -0
  168. package/build-types/button/test/index.d.ts +2 -0
  169. package/build-types/button/test/index.d.ts.map +1 -0
  170. package/build-types/button/types.d.ts +134 -0
  171. package/build-types/button/types.d.ts.map +1 -0
  172. package/build-types/color-list-picker/index.d.ts +5 -0
  173. package/build-types/color-list-picker/index.d.ts.map +1 -0
  174. package/build-types/color-list-picker/types.d.ts +42 -0
  175. package/build-types/color-list-picker/types.d.ts.map +1 -0
  176. package/build-types/color-palette/index.d.ts +2 -4
  177. package/build-types/color-palette/index.d.ts.map +1 -1
  178. package/build-types/color-palette/stories/index.d.ts +2 -2
  179. package/build-types/color-palette/styles.d.ts +1 -1
  180. package/build-types/color-palette/types.d.ts +1 -1
  181. package/build-types/color-palette/types.d.ts.map +1 -1
  182. package/build-types/color-palette/utils.d.ts +14 -0
  183. package/build-types/color-palette/utils.d.ts.map +1 -0
  184. package/build-types/color-picker/styles.d.ts +2 -2
  185. package/build-types/date-time/date/index.d.ts.map +1 -1
  186. package/build-types/date-time/date/styles.d.ts +3 -3
  187. package/build-types/dropdown/index.d.ts +4 -4
  188. package/build-types/dropdown/index.d.ts.map +1 -1
  189. package/build-types/dropdown/stories/index.d.ts.map +1 -1
  190. package/build-types/dropdown/types.d.ts +9 -10
  191. package/build-types/dropdown/types.d.ts.map +1 -1
  192. package/build-types/font-size-picker/styles.d.ts +2 -2
  193. package/build-types/h-stack/component.d.ts +0 -1
  194. package/build-types/h-stack/component.d.ts.map +1 -1
  195. package/build-types/input-control/input-field.d.ts.map +1 -1
  196. package/build-types/keyboard-shortcuts/index.d.ts +38 -0
  197. package/build-types/keyboard-shortcuts/index.d.ts.map +1 -0
  198. package/build-types/keyboard-shortcuts/stories/index.d.ts +12 -0
  199. package/build-types/keyboard-shortcuts/stories/index.d.ts.map +1 -0
  200. package/build-types/keyboard-shortcuts/test/index.d.ts +2 -0
  201. package/build-types/keyboard-shortcuts/test/index.d.ts.map +1 -0
  202. package/build-types/keyboard-shortcuts/types.d.ts +48 -0
  203. package/build-types/keyboard-shortcuts/types.d.ts.map +1 -0
  204. package/build-types/modal/index.d.ts.map +1 -1
  205. package/build-types/navigator/navigator-back-button/component.d.ts +1 -1
  206. package/build-types/navigator/navigator-back-button/hook.d.ts +2 -2
  207. package/build-types/navigator/navigator-button/component.d.ts +1 -1
  208. package/build-types/navigator/navigator-button/hook.d.ts +2 -2
  209. package/build-types/notice/index.d.ts +16 -0
  210. package/build-types/notice/index.d.ts.map +1 -0
  211. package/build-types/notice/list.d.ts +32 -0
  212. package/build-types/notice/list.d.ts.map +1 -0
  213. package/build-types/notice/stories/index.d.ts +17 -0
  214. package/build-types/notice/stories/index.d.ts.map +1 -0
  215. package/build-types/notice/test/index.d.ts +2 -0
  216. package/build-types/notice/test/index.d.ts.map +1 -0
  217. package/build-types/notice/test/list.d.ts +2 -0
  218. package/build-types/notice/test/list.d.ts.map +1 -0
  219. package/build-types/notice/types.d.ts +128 -0
  220. package/build-types/notice/types.d.ts.map +1 -0
  221. package/build-types/number-control/styles/number-control-styles.d.ts +2 -2
  222. package/build-types/number-control/styles/number-control-styles.d.ts.map +1 -1
  223. package/build-types/placeholder/stories/index.d.ts.map +1 -1
  224. package/build-types/query-controls/author-select.d.ts +4 -0
  225. package/build-types/query-controls/author-select.d.ts.map +1 -0
  226. package/build-types/query-controls/category-select.d.ts +4 -0
  227. package/build-types/query-controls/category-select.d.ts.map +1 -0
  228. package/build-types/query-controls/index.d.ts +30 -0
  229. package/build-types/query-controls/index.d.ts.map +1 -0
  230. package/build-types/query-controls/stories/index.d.ts +13 -0
  231. package/build-types/query-controls/stories/index.d.ts.map +1 -0
  232. package/build-types/query-controls/terms.d.ts +13 -0
  233. package/build-types/query-controls/terms.d.ts.map +1 -0
  234. package/build-types/query-controls/test/terms.d.ts +2 -0
  235. package/build-types/query-controls/test/terms.d.ts.map +1 -0
  236. package/build-types/query-controls/types.d.ts +131 -0
  237. package/build-types/query-controls/types.d.ts.map +1 -0
  238. package/build-types/range-control/index.d.ts +1 -1
  239. package/build-types/slot-fill/bubbles-virtually/fill.d.ts.map +1 -1
  240. package/build-types/slot-fill/use-slot.d.ts.map +1 -1
  241. package/build-types/snackbar/index.d.ts +9 -2
  242. package/build-types/snackbar/index.d.ts.map +1 -1
  243. package/build-types/snackbar/list.d.ts.map +1 -1
  244. package/build-types/snackbar/types.d.ts +15 -88
  245. package/build-types/snackbar/types.d.ts.map +1 -1
  246. package/build-types/tab-panel/index.d.ts.map +1 -1
  247. package/build-types/tab-panel/types.d.ts +1 -1
  248. package/build-types/tab-panel/types.d.ts.map +1 -1
  249. package/build-types/toggle-group-control/stories/index.d.ts.map +1 -1
  250. package/build-types/tree-select/index.d.ts.map +1 -1
  251. package/build-types/ui/form-group/form-group.d.ts +2 -2
  252. package/package.json +18 -17
  253. package/src/alignment-matrix-control/utils.tsx +2 -2
  254. package/src/autocomplete/autocompleter-ui.js +1 -2
  255. package/src/autocomplete/test/index.js +1 -5
  256. package/src/border-box-control/border-box-control-linked-button/component.tsx +1 -1
  257. package/src/border-box-control/border-box-control-linked-button/hook.ts +1 -1
  258. package/src/border-control/border-control-dropdown/component.tsx +9 -8
  259. package/src/box-control/test/index.js +11 -35
  260. package/src/button/README.md +49 -55
  261. package/src/button/{deprecated.js → deprecated.tsx} +19 -4
  262. package/src/button/{index.js → index.tsx} +95 -34
  263. package/src/button/stories/index.tsx +106 -0
  264. package/src/button/style.scss +3 -2
  265. package/src/button/test/{index.js → index.tsx} +30 -7
  266. package/src/button/types.ts +138 -0
  267. package/src/checkbox-control/test/index.tsx +1 -5
  268. package/src/color-list-picker/{index.js → index.tsx} +3 -2
  269. package/src/color-list-picker/types.ts +46 -0
  270. package/src/color-palette/README.md +1 -1
  271. package/src/color-palette/index.native.js +11 -4
  272. package/src/color-palette/index.tsx +11 -67
  273. package/src/color-palette/test/index.tsx +4 -14
  274. package/src/color-palette/test/utils.ts +1 -1
  275. package/src/color-palette/types.ts +1 -1
  276. package/src/color-palette/utils.ts +98 -0
  277. package/src/color-picker/test/index.js +6 -15
  278. package/src/combobox-control/test/index.js +1 -6
  279. package/src/confirm-dialog/test/index.js +9 -29
  280. package/src/custom-gradient-picker/gradient-bar/utils.js +1 -1
  281. package/src/date-time/date/index.tsx +2 -1
  282. package/src/date-time/date/test/index.tsx +2 -8
  283. package/src/date-time/time/test/index.tsx +9 -29
  284. package/src/dimension-control/test/index.test.js +2 -8
  285. package/src/disabled/test/index.tsx +1 -5
  286. package/src/draggable/test/index.native.js +4 -4
  287. package/src/dropdown/README.md +1 -8
  288. package/src/dropdown/index.tsx +17 -6
  289. package/src/dropdown/stories/index.tsx +3 -3
  290. package/src/dropdown/test/index.tsx +2 -8
  291. package/src/dropdown/types.ts +9 -10
  292. package/src/dropdown-menu/README.md +1 -1
  293. package/src/dropdown-menu/stories/index.js +96 -27
  294. package/src/dropdown-menu/test/index.js +2 -8
  295. package/src/external-link/test/index.tsx +1 -6
  296. package/src/focal-point-picker/test/index.js +3 -11
  297. package/src/font-size-picker/test/index.tsx +14 -44
  298. package/src/form-file-upload/test/index.tsx +2 -17
  299. package/src/form-toggle/test/index.tsx +1 -5
  300. package/src/form-token-field/test/index.tsx +80 -163
  301. package/src/form-token-field/token.tsx +1 -1
  302. package/src/gradient-picker/index.js +15 -4
  303. package/src/guide/test/index.js +5 -17
  304. package/src/h-stack/component.tsx +0 -1
  305. package/src/higher-order/with-filters/test/index.js +24 -24
  306. package/src/higher-order/with-focus-outside/test/index.js +11 -25
  307. package/src/higher-order/with-focus-return/test/index.js +1 -5
  308. package/src/input-control/input-field.tsx +3 -1
  309. package/src/input-control/test/index.js +1 -6
  310. package/src/isolated-event-container/test/index.js +2 -8
  311. package/src/keyboard-shortcuts/README.md +1 -1
  312. package/src/keyboard-shortcuts/index.tsx +93 -0
  313. package/src/keyboard-shortcuts/stories/index.tsx +60 -0
  314. package/src/keyboard-shortcuts/test/{index.js → index.tsx} +16 -6
  315. package/src/keyboard-shortcuts/types.ts +51 -0
  316. package/src/modal/index.tsx +1 -2
  317. package/src/navigable-container/test/navigable-menu.js +5 -17
  318. package/src/navigable-container/test/tababble-container.js +3 -11
  319. package/src/navigation/test/index.js +3 -11
  320. package/src/navigator/test/index.tsx +6 -20
  321. package/src/notice/README.md +89 -42
  322. package/src/notice/{index.js → index.tsx} +28 -20
  323. package/src/notice/list.tsx +72 -0
  324. package/src/notice/stories/index.tsx +119 -0
  325. package/src/notice/test/__snapshots__/{index.js.snap → index.tsx.snap} +0 -0
  326. package/src/notice/test/{index.js → index.tsx} +7 -4
  327. package/src/notice/test/{list.js → list.tsx} +0 -0
  328. package/src/notice/types.ts +136 -0
  329. package/src/number-control/index.tsx +1 -1
  330. package/src/number-control/test/index.tsx +28 -86
  331. package/src/panel/test/body.js +2 -8
  332. package/src/placeholder/stories/index.tsx +1 -0
  333. package/src/query-controls/README.md +56 -56
  334. package/src/query-controls/author-select.tsx +37 -0
  335. package/src/query-controls/category-select.tsx +46 -0
  336. package/src/query-controls/index.tsx +192 -0
  337. package/src/query-controls/stories/index.tsx +205 -0
  338. package/src/query-controls/terms.ts +57 -0
  339. package/src/query-controls/test/{terms.js → terms.ts} +36 -20
  340. package/src/query-controls/types.ts +150 -0
  341. package/src/select-control/test/select-control.tsx +1 -6
  342. package/src/slot-fill/bubbles-virtually/fill.js +1 -0
  343. package/src/slot-fill/slot.js +1 -1
  344. package/src/slot-fill/use-slot.js +6 -16
  345. package/src/snackbar/index.tsx +6 -5
  346. package/src/snackbar/list.tsx +4 -2
  347. package/src/snackbar/types.ts +18 -92
  348. package/src/tab-panel/index.tsx +38 -16
  349. package/src/tab-panel/style.scss +8 -0
  350. package/src/tab-panel/test/index.tsx +35 -7
  351. package/src/tab-panel/types.ts +1 -1
  352. package/src/theme/test/index.tsx +4 -4
  353. package/src/toggle-group-control/stories/index.tsx +1 -0
  354. package/src/toggle-group-control/test/index.tsx +7 -23
  355. package/src/toolbar/stories/index.js +75 -72
  356. package/src/tools-panel/stories/index.js +3 -0
  357. package/src/tools-panel/test/index.js +1 -1
  358. package/src/tree-grid/index.js +1 -1
  359. package/src/tree-select/index.tsx +3 -6
  360. package/src/ui/context/test/context-connect.tsx +2 -0
  361. package/src/ui/context/test/wordpress-component.tsx +2 -0
  362. package/src/unit-control/test/index.tsx +21 -74
  363. package/src/utils/hooks/test/use-latest-ref.js +15 -18
  364. package/tsconfig.json +1 -4
  365. package/tsconfig.tsbuildinfo +1 -1
  366. package/build-types/radio-context/index.d.ts +0 -6
  367. package/build-types/radio-context/index.d.ts.map +0 -1
  368. package/src/button/stories/index.js +0 -179
  369. package/src/keyboard-shortcuts/index.js +0 -56
  370. package/src/notice/list.js +0 -48
  371. package/src/notice/stories/index.js +0 -46
  372. package/src/query-controls/author-select.js +0 -23
  373. package/src/query-controls/category-select.js +0 -31
  374. package/src/query-controls/index.js +0 -122
  375. package/src/query-controls/terms.js +0 -40
  376. package/src/toolbar/stories/toolbar-button.js +0 -32
  377. package/src/toolbar/stories/toolbar-group.js +0 -33
@@ -12,8 +12,8 @@ import { plusCircle } from '@wordpress/icons';
12
12
  /**
13
13
  * Internal dependencies
14
14
  */
15
- import Button from '../';
16
- import { Tooltip } from '../../';
15
+ import Button from '..';
16
+ import Tooltip from '../../tooltip';
17
17
 
18
18
  jest.mock( '../../icon', () => () => <div data-testid="test-icon" /> );
19
19
 
@@ -126,6 +126,7 @@ describe( 'Button', () => {
126
126
  } );
127
127
 
128
128
  it( 'should not pass the prop target into the element', () => {
129
+ // @ts-expect-error - `target` requires `href`
129
130
  render( <Button target="_blank" /> );
130
131
 
131
132
  expect( screen.getByRole( 'button' ) ).not.toHaveAttribute(
@@ -139,13 +140,12 @@ describe( 'Button', () => {
139
140
  expect( screen.getByRole( 'button' ) ).toHaveClass( 'gutenberg' );
140
141
  } );
141
142
 
142
- it( 'should render an additional WordPress prop of value awesome', () => {
143
- render( <Button WordPress="awesome" /> );
143
+ it( 'should pass additional props to the element', () => {
144
+ render( <Button type="submit" /> );
144
145
 
145
- expect( console ).toHaveErrored();
146
146
  expect( screen.getByRole( 'button' ) ).toHaveAttribute(
147
- 'wordpress',
148
- 'awesome'
147
+ 'type',
148
+ 'submit'
149
149
  );
150
150
  } );
151
151
 
@@ -342,6 +342,7 @@ describe( 'Button', () => {
342
342
  } );
343
343
 
344
344
  it( 'should become a button again when disabled is supplied', () => {
345
+ // @ts-expect-error - a button should not have `href`
345
346
  render( <Button href="https://wordpress.org/" disabled /> );
346
347
 
347
348
  expect( screen.getByRole( 'button' ) ).toBeVisible();
@@ -360,11 +361,13 @@ describe( 'Button', () => {
360
361
 
361
362
  describe( 'deprecated props', () => {
362
363
  it( 'should not break when the legacy isPrimary prop is passed', () => {
364
+ // @ts-expect-error
363
365
  render( <Button isPrimary /> );
364
366
  expect( screen.getByRole( 'button' ) ).toHaveClass( 'is-primary' );
365
367
  } );
366
368
 
367
369
  it( 'should not break when the legacy isSecondary prop is passed', () => {
370
+ // @ts-expect-error
368
371
  render( <Button isSecondary /> );
369
372
  expect( screen.getByRole( 'button' ) ).toHaveClass(
370
373
  'is-secondary'
@@ -372,16 +375,19 @@ describe( 'Button', () => {
372
375
  } );
373
376
 
374
377
  it( 'should not break when the legacy isTertiary prop is passed', () => {
378
+ // @ts-expect-error
375
379
  render( <Button isTertiary /> );
376
380
  expect( screen.getByRole( 'button' ) ).toHaveClass( 'is-tertiary' );
377
381
  } );
378
382
 
379
383
  it( 'should not break when the legacy isLink prop is passed', () => {
384
+ // @ts-expect-error
380
385
  render( <Button isLink /> );
381
386
  expect( screen.getByRole( 'button' ) ).toHaveClass( 'is-link' );
382
387
  } );
383
388
 
384
389
  it( 'should warn when the isDefault prop is passed', () => {
390
+ // @ts-expect-error
385
391
  render( <Button isDefault /> );
386
392
  expect( screen.getByRole( 'button' ) ).toHaveClass(
387
393
  'is-secondary'
@@ -389,4 +395,21 @@ describe( 'Button', () => {
389
395
  expect( console ).toHaveWarned();
390
396
  } );
391
397
  } );
398
+
399
+ describe( 'static typing', () => {
400
+ <>
401
+ <Button href="foo" />
402
+ { /* @ts-expect-error - `target` requires `href` */ }
403
+ <Button target="foo" />
404
+ { /* @ts-expect-error - `disabled` is only for buttons */ }
405
+ <Button href="foo" disabled />
406
+ <Button href="foo" type="image/png" />
407
+ { /* @ts-expect-error - if button, type must be submit/reset/button */ }
408
+ <Button type="image/png" />
409
+ { /* @ts-expect-error */ }
410
+ <Button type="invalidtype" />
411
+ { /* @ts-expect-error - although the runtime behavior will allow this to be an anchor, this is probably a mistake. */ }
412
+ <Button disabled __experimentalIsFocusable href="foo" />
413
+ </>;
414
+ } );
392
415
  } );
@@ -0,0 +1,138 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import type { ReactNode } from 'react';
5
+
6
+ /**
7
+ * Internal dependencies
8
+ */
9
+ import type { Props as IconProps } from '../icon';
10
+ import type { PopoverProps } from '../popover/types';
11
+ import type { WordPressComponentProps } from '../ui/context/wordpress-component';
12
+
13
+ export type ButtonProps =
14
+ | WordPressComponentProps< BaseButtonProps & _ButtonProps, 'button', false >
15
+ | WordPressComponentProps< BaseButtonProps & AnchorProps, 'a', false >;
16
+
17
+ type BaseButtonProps = {
18
+ /**
19
+ * The button's children.
20
+ */
21
+ children?: ReactNode;
22
+ /**
23
+ * An accessible description for the button.
24
+ */
25
+ describedBy?: string;
26
+ /**
27
+ * Whether the button is focused.
28
+ */
29
+ focus?: boolean;
30
+ /**
31
+ * If provided, renders an Icon component inside the button.
32
+ */
33
+ icon?: IconProps< unknown >[ 'icon' ];
34
+ /**
35
+ * If provided with `icon`, sets the position of icon relative to the `text`.
36
+ *
37
+ * @default 'left'
38
+ */
39
+ iconPosition?: 'left' | 'right';
40
+ /**
41
+ * If provided with `icon`, sets the icon size.
42
+ * Please refer to the Icon component for more details regarding
43
+ * the default value of its `size` prop.
44
+ */
45
+ iconSize?: IconProps< unknown >[ 'size' ];
46
+ /**
47
+ * Indicates activity while a action is being performed.
48
+ */
49
+ isBusy?: boolean;
50
+ /**
51
+ * Renders a red text-based button style to indicate destructive behavior.
52
+ */
53
+ isDestructive?: boolean;
54
+ /**
55
+ * Renders a pressed button style.
56
+ */
57
+ isPressed?: boolean;
58
+ /**
59
+ * Decreases the size of the button.
60
+ */
61
+ isSmall?: boolean;
62
+ /**
63
+ * Sets the `aria-label` of the component, if none is provided.
64
+ * Sets the Tooltip content if `showTooltip` is provided.
65
+ */
66
+ label?: string;
67
+ /**
68
+ * If provided with `showTooltip`, appends the Shortcut label to the tooltip content.
69
+ * If an object is provided, it should contain `display` and `ariaLabel` keys.
70
+ */
71
+ shortcut?: string | { display: string; ariaLabel: string };
72
+ /**
73
+ * If provided, renders a Tooltip component for the button.
74
+ */
75
+ showTooltip?: boolean;
76
+ /**
77
+ * If provided, displays the given text inside the button. If the button contains children elements, the text is displayed before them.
78
+ */
79
+ text?: string;
80
+ /**
81
+ * If provided with `showTooltip`, sets the position of the tooltip.
82
+ * Please refer to the Tooltip component for more details regarding the defaults.
83
+ */
84
+ tooltipPosition?: PopoverProps[ 'position' ];
85
+ /**
86
+ * Specifies the button's style.
87
+ * The accepted values are:
88
+ * 'primary' (the primary button styles)
89
+ * 'secondary' (the default button styles)
90
+ * 'tertiary' (the text-based button styles)
91
+ * 'link' (the link button styles)
92
+ */
93
+ variant?: 'primary' | 'secondary' | 'tertiary' | 'link';
94
+ /**
95
+ * Whether this is focusable.
96
+ */
97
+ __experimentalIsFocusable?: boolean;
98
+ };
99
+
100
+ type _ButtonProps = {
101
+ /**
102
+ * Whether the button is disabled.
103
+ * If `true`, this will force a `button` element to be rendered.
104
+ */
105
+ disabled?: boolean;
106
+ };
107
+
108
+ type AnchorProps = {
109
+ /**
110
+ * Whether the button is disabled.
111
+ * If `true`, this will force a `button` element to be rendered.
112
+ */
113
+ disabled?: false;
114
+ /**
115
+ * If provided, renders `a` instead of `button`.
116
+ */
117
+ href: string;
118
+ /**
119
+ * If provided with `href`, sets the `target` attribute to the `a`.
120
+ */
121
+ target?: string;
122
+ };
123
+
124
+ export type DeprecatedButtonProps = {
125
+ isDefault?: boolean;
126
+ isLink?: boolean;
127
+ isPrimary?: boolean;
128
+ isSecondary?: boolean;
129
+ isTertiary?: boolean;
130
+ };
131
+
132
+ export type DeprecatedIconButtonProps = {
133
+ labelPosition: ButtonProps[ 'tooltipPosition' ];
134
+ showTooltip?: boolean;
135
+ size: ButtonProps[ 'iconSize' ];
136
+ label: ButtonProps[ 'label' ];
137
+ tooltip: ButtonProps[ 'label' ];
138
+ };
@@ -15,8 +15,6 @@ import { useState } from '@wordpress/element';
15
15
  import BaseCheckboxControl from '..';
16
16
  import type { CheckboxControlProps } from '../types';
17
17
 
18
- jest.useFakeTimers();
19
-
20
18
  const noop = () => {};
21
19
 
22
20
  const getInput = () => screen.getByRole( 'checkbox' ) as HTMLInputElement;
@@ -85,9 +83,7 @@ describe( 'CheckboxControl', () => {
85
83
 
86
84
  describe( 'Value', () => {
87
85
  it( 'should flip the checked property when clicked', async () => {
88
- const user = userEvent.setup( {
89
- advanceTimers: jest.advanceTimersByTime,
90
- } );
86
+ const user = userEvent.setup();
91
87
 
92
88
  let state = false;
93
89
  const setState = jest.fn(
@@ -12,6 +12,7 @@ import ColorPalette from '../color-palette';
12
12
  import ColorIndicator from '../color-indicator';
13
13
  import Icon from '../icon';
14
14
  import { HStack } from '../h-stack';
15
+ import type { ColorListPickerProps, ColorOptionProps } from './types';
15
16
 
16
17
  function ColorOption( {
17
18
  label,
@@ -20,7 +21,7 @@ function ColorOption( {
20
21
  disableCustomColors,
21
22
  enableAlpha,
22
23
  onChange,
23
- } ) {
24
+ }: ColorOptionProps ) {
24
25
  const [ isOpen, setIsOpen ] = useState( false );
25
26
  return (
26
27
  <>
@@ -62,7 +63,7 @@ function ColorListPicker( {
62
63
  disableCustomColors,
63
64
  enableAlpha,
64
65
  onChange,
65
- } ) {
66
+ }: ColorListPickerProps ) {
66
67
  return (
67
68
  <div className="components-color-list-picker">
68
69
  { labels.map( ( label, index ) => (
@@ -0,0 +1,46 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import type { CSSProperties } from 'react';
5
+
6
+ export type ColorListPickerProps = {
7
+ /**
8
+ * A list of predifened colors. Each color is an object with a `name` and a
9
+ * `color` value.
10
+ * The `name` is a string used to identify the color in the UI.
11
+ * The `color` is a valid CSS color string.
12
+ */
13
+ colors: Array< {
14
+ name: string;
15
+ color: NonNullable< CSSProperties[ 'color' ] >;
16
+ } >;
17
+ /**
18
+ * A list of labels for each of the options displayed in the UI.
19
+ */
20
+ labels: Array< string >;
21
+ /**
22
+ * An array containing the currently selected colors.
23
+ */
24
+ value?: Array< string | undefined >;
25
+ /**
26
+ * Controls whether the custom color picker is displayed.
27
+ */
28
+ disableCustomColors?: boolean;
29
+ /**
30
+ * Controls whether the ColorPalette should show an alpha channel control.
31
+ */
32
+ enableAlpha?: boolean;
33
+ /**
34
+ * A function that receives the updated color value.
35
+ */
36
+ onChange: ( newValue: Array< string | undefined > ) => void;
37
+ };
38
+
39
+ export type ColorOptionProps = Pick<
40
+ ColorListPickerProps,
41
+ 'colors' | 'disableCustomColors' | 'enableAlpha'
42
+ > & {
43
+ label: ColorListPickerProps[ 'labels' ][ number ];
44
+ value: string | undefined;
45
+ onChange: ( newValue: string | undefined ) => void;
46
+ };
@@ -43,7 +43,7 @@ Whether the palette should have a clearing button.
43
43
  - Required: No
44
44
  - Default: `true`
45
45
 
46
- ### `colors`: `( PaletteObject | ColorObject )[]`
46
+ ### `colors`: `PaletteObject[] | ColorObject[]`
47
47
 
48
48
  Array with the colors to be shown. When displaying multiple color palettes to choose from, the format of the array changes from an array of colors objects, to an array of color palettes.
49
49
 
@@ -11,7 +11,6 @@ import {
11
11
  Platform,
12
12
  Text,
13
13
  } from 'react-native';
14
- import { map } from 'lodash';
15
14
 
16
15
  /**
17
16
  * WordPress dependencies
@@ -64,13 +63,21 @@ function ColorPalette( {
64
63
  const opacity = useRef( new Animated.Value( 1 ) ).current;
65
64
 
66
65
  const defaultColors = [
67
- ...new Set( map( defaultSettings.colors, 'color' ) ),
66
+ ...new Set(
67
+ ( defaultSettings.colors ?? [] ).map( ( { color } ) => color )
68
+ ),
68
69
  ];
69
70
  const mergedColors = [
70
- ...new Set( map( defaultSettings.allColors, 'color' ) ),
71
+ ...new Set(
72
+ ( defaultSettings.allColors ?? [] ).map( ( { color } ) => color )
73
+ ),
71
74
  ];
72
75
  const defaultGradientColors = [
73
- ...new Set( map( defaultSettings.gradients, 'gradient' ) ),
76
+ ...new Set(
77
+ ( defaultSettings.gradients ?? [] ).map(
78
+ ( { gradient } ) => gradient
79
+ )
80
+ ),
74
81
  ];
75
82
  const colors = isGradientSegment ? defaultGradientColors : defaultColors;
76
83
 
@@ -10,7 +10,7 @@ import a11yPlugin from 'colord/plugins/a11y';
10
10
  * WordPress dependencies
11
11
  */
12
12
  import { __, sprintf } from '@wordpress/i18n';
13
- import { useCallback, useMemo, forwardRef } from '@wordpress/element';
13
+ import { useCallback, useRef, useMemo, forwardRef } from '@wordpress/element';
14
14
 
15
15
  /**
16
16
  * Internal dependencies
@@ -33,6 +33,12 @@ import type {
33
33
  } from './types';
34
34
  import type { WordPressComponentProps } from '../ui/context';
35
35
  import type { DropdownProps } from '../dropdown/types';
36
+ import {
37
+ extractColorNameFromCurrentValue,
38
+ isMultiplePaletteArray,
39
+ normalizeColorValue,
40
+ showTransparentBackground,
41
+ } from './utils';
36
42
 
37
43
  extend( [ namesPlugin, a11yPlugin ] );
38
44
 
@@ -164,60 +170,11 @@ export function CustomColorPickerDropdown( {
164
170
  );
165
171
  }
166
172
 
167
- export const extractColorNameFromCurrentValue = (
168
- currentValue?: ColorPaletteProps[ 'value' ],
169
- colors: ColorPaletteProps[ 'colors' ] = [],
170
- showMultiplePalettes: boolean = false
171
- ) => {
172
- if ( ! currentValue ) {
173
- return '';
174
- }
175
-
176
- const currentValueIsCssVariable = /^var\(/.test( currentValue );
177
- const normalizedCurrentValue = currentValueIsCssVariable
178
- ? currentValue
179
- : colord( currentValue ).toHex();
180
-
181
- // Normalize format of `colors` to simplify the following loop
182
- type normalizedPaletteObject = { colors: ColorObject[] };
183
- const colorPalettes: normalizedPaletteObject[] = showMultiplePalettes
184
- ? ( colors as PaletteObject[] )
185
- : [ { colors: colors as ColorObject[] } ];
186
- for ( const { colors: paletteColors } of colorPalettes ) {
187
- for ( const { name: colorName, color: colorValue } of paletteColors ) {
188
- const normalizedColorValue = currentValueIsCssVariable
189
- ? colorValue
190
- : colord( colorValue ).toHex();
191
-
192
- if ( normalizedCurrentValue === normalizedColorValue ) {
193
- return colorName;
194
- }
195
- }
196
- }
197
-
198
- // translators: shown when the user has picked a custom color (i.e not in the palette of colors).
199
- return __( 'Custom' );
200
- };
201
-
202
- export const showTransparentBackground = ( currentValue?: string ) => {
203
- if ( typeof currentValue === 'undefined' ) {
204
- return true;
205
- }
206
- return colord( currentValue ).alpha() === 0;
207
- };
208
-
209
- const areColorsMultiplePalette = (
210
- colors: NonNullable< ColorPaletteProps[ 'colors' ] >
211
- ): colors is PaletteObject[] => {
212
- return colors.every( ( colorObj ) =>
213
- Array.isArray( ( colorObj as PaletteObject ).colors )
214
- );
215
- };
216
-
217
173
  function UnforwardedColorPalette(
218
174
  props: WordPressComponentProps< ColorPaletteProps, 'div' >,
219
175
  forwardedRef: ForwardedRef< any >
220
176
  ) {
177
+ const customColorPaletteRef = useRef< HTMLElement | null >( null );
221
178
  const {
222
179
  clearable = true,
223
180
  colors = [],
@@ -230,9 +187,7 @@ function UnforwardedColorPalette(
230
187
  } = props;
231
188
  const clearColor = useCallback( () => onChange( undefined ), [ onChange ] );
232
189
 
233
- const hasMultipleColorOrigins =
234
- colors.length > 0 &&
235
- ( colors as PaletteObject[] )[ 0 ].colors !== undefined;
190
+ const hasMultipleColorOrigins = isMultiplePaletteArray( colors );
236
191
  const buttonLabelName = useMemo(
237
192
  () =>
238
193
  extractColorNameFromCurrentValue(
@@ -243,22 +198,10 @@ function UnforwardedColorPalette(
243
198
  [ value, colors, hasMultipleColorOrigins ]
244
199
  );
245
200
 
246
- // Make sure that the `colors` array has a valid format.
247
- if (
248
- colors.length > 0 &&
249
- hasMultipleColorOrigins !== areColorsMultiplePalette( colors )
250
- ) {
251
- // eslint-disable-next-line no-console
252
- console.warn(
253
- 'wp.components.ColorPalette: please specify a valid format for the `colors` prop. '
254
- );
255
- return null;
256
- }
257
-
258
201
  const renderCustomColorPicker = () => (
259
202
  <DropdownContentWrapper paddingSize="none">
260
203
  <ColorPicker
261
- color={ value }
204
+ color={ normalizeColorValue( value, customColorPaletteRef ) }
262
205
  onChange={ ( color ) => onChange( color ) }
263
206
  enableAlpha={ enableAlpha }
264
207
  />
@@ -303,6 +246,7 @@ function UnforwardedColorPalette(
303
246
  renderToggle={ ( { isOpen, onToggle } ) => (
304
247
  <Flex
305
248
  as={ 'button' }
249
+ ref={ customColorPaletteRef }
306
250
  justify="space-between"
307
251
  align="flex-start"
308
252
  className="components-color-palette__custom-color"
@@ -9,8 +9,6 @@ import userEvent from '@testing-library/user-event';
9
9
  */
10
10
  import ColorPalette from '..';
11
11
 
12
- jest.useFakeTimers();
13
-
14
12
  const EXAMPLE_COLORS = [
15
13
  { name: 'red', color: '#f00' },
16
14
  { name: 'green', color: '#0f0' },
@@ -54,9 +52,7 @@ describe( 'ColorPalette', () => {
54
52
  } );
55
53
 
56
54
  it( 'should call onClick on an active button with undefined', async () => {
57
- const user = userEvent.setup( {
58
- advanceTimers: jest.advanceTimersByTime,
59
- } );
55
+ const user = userEvent.setup();
60
56
  const onChange = jest.fn();
61
57
 
62
58
  render(
@@ -76,9 +72,7 @@ describe( 'ColorPalette', () => {
76
72
  } );
77
73
 
78
74
  it( 'should call onClick on an inactive button', async () => {
79
- const user = userEvent.setup( {
80
- advanceTimers: jest.advanceTimersByTime,
81
- } );
75
+ const user = userEvent.setup();
82
76
  const onChange = jest.fn();
83
77
 
84
78
  render(
@@ -104,9 +98,7 @@ describe( 'ColorPalette', () => {
104
98
  } );
105
99
 
106
100
  it( 'should call onClick with undefined, when the clearButton onClick is triggered', async () => {
107
- const user = userEvent.setup( {
108
- advanceTimers: jest.advanceTimersByTime,
109
- } );
101
+ const user = userEvent.setup();
110
102
  const onChange = jest.fn();
111
103
 
112
104
  render(
@@ -139,9 +131,7 @@ describe( 'ColorPalette', () => {
139
131
  } );
140
132
 
141
133
  it( 'should render dropdown and its content', async () => {
142
- const user = userEvent.setup( {
143
- advanceTimers: jest.advanceTimersByTime,
144
- } );
134
+ const user = userEvent.setup();
145
135
  const onChange = jest.fn();
146
136
 
147
137
  render(
@@ -4,7 +4,7 @@
4
4
  import {
5
5
  extractColorNameFromCurrentValue,
6
6
  showTransparentBackground,
7
- } from '../';
7
+ } from '../utils';
8
8
 
9
9
  describe( 'ColorPalette: Utils', () => {
10
10
  describe( 'extractColorNameFromCurrentValue', () => {
@@ -55,7 +55,7 @@ export type ColorPaletteProps = Pick< PaletteProps, 'onChange' > & {
55
55
  *
56
56
  * @default []
57
57
  */
58
- colors?: ( PaletteObject | ColorObject )[];
58
+ colors?: PaletteObject[] | ColorObject[];
59
59
  /**
60
60
  * Whether to allow the user to pick a custom color on top of the predefined
61
61
  * choices (defined via the `colors` prop).
@@ -0,0 +1,98 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import type { RefObject } from 'react';
5
+ import { colord, extend } from 'colord';
6
+ import namesPlugin from 'colord/plugins/names';
7
+ import a11yPlugin from 'colord/plugins/a11y';
8
+
9
+ /**
10
+ * WordPress dependencies
11
+ */
12
+ import { __ } from '@wordpress/i18n';
13
+
14
+ /**
15
+ * Internal dependencies
16
+ */
17
+ import type { ColorObject, ColorPaletteProps, PaletteObject } from './types';
18
+
19
+ extend( [ namesPlugin, a11yPlugin ] );
20
+
21
+ export const extractColorNameFromCurrentValue = (
22
+ currentValue?: ColorPaletteProps[ 'value' ],
23
+ colors: ColorPaletteProps[ 'colors' ] = [],
24
+ showMultiplePalettes: boolean = false
25
+ ) => {
26
+ if ( ! currentValue ) {
27
+ return '';
28
+ }
29
+
30
+ const currentValueIsCssVariable = /^var\(/.test( currentValue );
31
+ const normalizedCurrentValue = currentValueIsCssVariable
32
+ ? currentValue
33
+ : colord( currentValue ).toHex();
34
+
35
+ // Normalize format of `colors` to simplify the following loop
36
+ type normalizedPaletteObject = { colors: ColorObject[] };
37
+ const colorPalettes: normalizedPaletteObject[] = showMultiplePalettes
38
+ ? ( colors as PaletteObject[] )
39
+ : [ { colors: colors as ColorObject[] } ];
40
+ for ( const { colors: paletteColors } of colorPalettes ) {
41
+ for ( const { name: colorName, color: colorValue } of paletteColors ) {
42
+ const normalizedColorValue = currentValueIsCssVariable
43
+ ? colorValue
44
+ : colord( colorValue ).toHex();
45
+
46
+ if ( normalizedCurrentValue === normalizedColorValue ) {
47
+ return colorName;
48
+ }
49
+ }
50
+ }
51
+
52
+ // translators: shown when the user has picked a custom color (i.e not in the palette of colors).
53
+ return __( 'Custom' );
54
+ };
55
+
56
+ export const showTransparentBackground = ( currentValue?: string ) => {
57
+ if ( typeof currentValue === 'undefined' ) {
58
+ return true;
59
+ }
60
+ return colord( currentValue ).alpha() === 0;
61
+ };
62
+
63
+ // The PaletteObject type has a `colors` property (an array of ColorObject),
64
+ // while the ColorObject type has a `color` property (the CSS color value).
65
+ export const isMultiplePaletteObject = (
66
+ obj: PaletteObject | ColorObject
67
+ ): obj is PaletteObject =>
68
+ Array.isArray( ( obj as PaletteObject ).colors ) && ! ( 'color' in obj );
69
+
70
+ export const isMultiplePaletteArray = (
71
+ arr: ( PaletteObject | ColorObject )[]
72
+ ): arr is PaletteObject[] => {
73
+ return (
74
+ arr.length > 0 &&
75
+ arr.every( ( colorObj ) => isMultiplePaletteObject( colorObj ) )
76
+ );
77
+ };
78
+
79
+ export const normalizeColorValue = (
80
+ value: string | undefined,
81
+ ref: RefObject< HTMLElement > | null
82
+ ) => {
83
+ const currentValueIsCssVariable = /^var\(/.test( value ?? '' );
84
+
85
+ if ( ! currentValueIsCssVariable || ! ref?.current ) {
86
+ return value;
87
+ }
88
+
89
+ const { ownerDocument } = ref.current;
90
+ const { defaultView } = ownerDocument;
91
+ const computedBackgroundColor = defaultView?.getComputedStyle(
92
+ ref.current
93
+ ).backgroundColor;
94
+
95
+ return computedBackgroundColor
96
+ ? colord( computedBackgroundColor ).toHex()
97
+ : value;
98
+ };