@wordpress/components 25.12.0 → 25.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (342) hide show
  1. package/CHANGELOG.md +65 -0
  2. package/build/angle-picker-control/index.js +0 -1
  3. package/build/angle-picker-control/index.js.map +1 -1
  4. package/build/border-control/border-control-dropdown/component.js +4 -2
  5. package/build/border-control/border-control-dropdown/component.js.map +1 -1
  6. package/build/border-control/border-control-dropdown/hook.js +3 -2
  7. package/build/border-control/border-control-dropdown/hook.js.map +1 -1
  8. package/build/border-control/styles.js +17 -17
  9. package/build/border-control/styles.js.map +1 -1
  10. package/build/checkbox-control/index.js +1 -1
  11. package/build/checkbox-control/index.js.map +1 -1
  12. package/build/checkbox-control/types.js.map +1 -1
  13. package/build/custom-select-control-v2/index.js +87 -0
  14. package/build/custom-select-control-v2/index.js.map +1 -0
  15. package/build/custom-select-control-v2/styles.js +85 -0
  16. package/build/custom-select-control-v2/styles.js.map +1 -0
  17. package/build/custom-select-control-v2/types.js +6 -0
  18. package/build/custom-select-control-v2/types.js.map +1 -0
  19. package/build/date-time/time/timezone.js +11 -2
  20. package/build/date-time/time/timezone.js.map +1 -1
  21. package/build/dimension-control/index.js +2 -0
  22. package/build/dimension-control/index.js.map +1 -1
  23. package/build/dimension-control/types.js.map +1 -1
  24. package/build/dropdown-menu-v2-ariakit/index.js +49 -20
  25. package/build/dropdown-menu-v2-ariakit/index.js.map +1 -1
  26. package/build/dropdown-menu-v2-ariakit/styles.js +82 -59
  27. package/build/dropdown-menu-v2-ariakit/styles.js.map +1 -1
  28. package/build/dropdown-menu-v2-ariakit/types.js.map +1 -1
  29. package/build/focal-point-picker/controls.js +5 -1
  30. package/build/focal-point-picker/controls.js.map +1 -1
  31. package/build/focal-point-picker/index.js +2 -0
  32. package/build/focal-point-picker/index.js.map +1 -1
  33. package/build/focal-point-picker/styles/focal-point-picker-style.js +15 -15
  34. package/build/focal-point-picker/styles/focal-point-picker-style.js.map +1 -1
  35. package/build/focal-point-picker/types.js.map +1 -1
  36. package/build/font-size-picker/font-size-picker-select.js +2 -0
  37. package/build/font-size-picker/font-size-picker-select.js.map +1 -1
  38. package/build/font-size-picker/font-size-picker-toggle-group.js +2 -0
  39. package/build/font-size-picker/font-size-picker-toggle-group.js.map +1 -1
  40. package/build/font-size-picker/index.js +6 -1
  41. package/build/font-size-picker/index.js.map +1 -1
  42. package/build/font-size-picker/types.js.map +1 -1
  43. package/build/form-token-field/index.js +6 -2
  44. package/build/form-token-field/index.js.map +1 -1
  45. package/build/form-token-field/token-input.js.map +1 -1
  46. package/build/form-token-field/types.js.map +1 -1
  47. package/build/heading/hook.js +6 -3
  48. package/build/heading/hook.js.map +1 -1
  49. package/build/heading/types.js.map +1 -1
  50. package/build/index.native.js +0 -16
  51. package/build/index.native.js.map +1 -1
  52. package/build/mobile/global-styles-context/utils.native.js +13 -0
  53. package/build/mobile/global-styles-context/utils.native.js.map +1 -1
  54. package/build/mobile/utils/alignments.native.js +1 -1
  55. package/build/mobile/utils/alignments.native.js.map +1 -1
  56. package/build/palette-edit/index.js +21 -1
  57. package/build/palette-edit/index.js.map +1 -1
  58. package/build/private-apis.js +3 -2
  59. package/build/private-apis.js.map +1 -1
  60. package/build/query-controls/author-select.js +3 -1
  61. package/build/query-controls/author-select.js.map +1 -1
  62. package/build/query-controls/category-select.js +3 -1
  63. package/build/query-controls/category-select.js.map +1 -1
  64. package/build/query-controls/index.js +6 -1
  65. package/build/query-controls/index.js.map +1 -1
  66. package/build/query-controls/types.js.map +1 -1
  67. package/build/slot-fill/types.js.map +1 -1
  68. package/build/tabs/index.js +24 -5
  69. package/build/tabs/index.js.map +1 -1
  70. package/build/tabs/tab.js +4 -4
  71. package/build/tabs/tab.js.map +1 -1
  72. package/build/tabs/tabpanel.js +4 -3
  73. package/build/tabs/tabpanel.js.map +1 -1
  74. package/build/tabs/types.js.map +1 -1
  75. package/build/text/types.js.map +1 -1
  76. package/build/toggle-group-control/toggle-group-control/utils.js +17 -17
  77. package/build/toggle-group-control/toggle-group-control/utils.js.map +1 -1
  78. package/build/tools-panel/tools-panel-item/hook.js +16 -12
  79. package/build/tools-panel/tools-panel-item/hook.js.map +1 -1
  80. package/build-module/angle-picker-control/index.js +0 -1
  81. package/build-module/angle-picker-control/index.js.map +1 -1
  82. package/build-module/border-control/border-control-dropdown/component.js +4 -2
  83. package/build-module/border-control/border-control-dropdown/component.js.map +1 -1
  84. package/build-module/border-control/border-control-dropdown/hook.js +3 -2
  85. package/build-module/border-control/border-control-dropdown/hook.js.map +1 -1
  86. package/build-module/border-control/styles.js +17 -17
  87. package/build-module/border-control/styles.js.map +1 -1
  88. package/build-module/checkbox-control/index.js +1 -1
  89. package/build-module/checkbox-control/index.js.map +1 -1
  90. package/build-module/checkbox-control/types.js.map +1 -1
  91. package/build-module/custom-select-control-v2/index.js +74 -0
  92. package/build-module/custom-select-control-v2/index.js.map +1 -0
  93. package/build-module/custom-select-control-v2/styles.js +71 -0
  94. package/build-module/custom-select-control-v2/styles.js.map +1 -0
  95. package/build-module/custom-select-control-v2/types.js +2 -0
  96. package/build-module/custom-select-control-v2/types.js.map +1 -0
  97. package/build-module/date-time/time/timezone.js +11 -2
  98. package/build-module/date-time/time/timezone.js.map +1 -1
  99. package/build-module/dimension-control/index.js +2 -0
  100. package/build-module/dimension-control/index.js.map +1 -1
  101. package/build-module/dimension-control/types.js.map +1 -1
  102. package/build-module/dropdown-menu-v2-ariakit/index.js +46 -18
  103. package/build-module/dropdown-menu-v2-ariakit/index.js.map +1 -1
  104. package/build-module/dropdown-menu-v2-ariakit/styles.js +69 -40
  105. package/build-module/dropdown-menu-v2-ariakit/styles.js.map +1 -1
  106. package/build-module/dropdown-menu-v2-ariakit/types.js.map +1 -1
  107. package/build-module/focal-point-picker/controls.js +5 -1
  108. package/build-module/focal-point-picker/controls.js.map +1 -1
  109. package/build-module/focal-point-picker/index.js +2 -0
  110. package/build-module/focal-point-picker/index.js.map +1 -1
  111. package/build-module/focal-point-picker/styles/focal-point-picker-style.js +15 -15
  112. package/build-module/focal-point-picker/styles/focal-point-picker-style.js.map +1 -1
  113. package/build-module/focal-point-picker/types.js.map +1 -1
  114. package/build-module/font-size-picker/font-size-picker-select.js +2 -0
  115. package/build-module/font-size-picker/font-size-picker-select.js.map +1 -1
  116. package/build-module/font-size-picker/font-size-picker-toggle-group.js +2 -0
  117. package/build-module/font-size-picker/font-size-picker-toggle-group.js.map +1 -1
  118. package/build-module/font-size-picker/index.js +6 -1
  119. package/build-module/font-size-picker/index.js.map +1 -1
  120. package/build-module/font-size-picker/types.js.map +1 -1
  121. package/build-module/form-token-field/index.js +6 -2
  122. package/build-module/form-token-field/index.js.map +1 -1
  123. package/build-module/form-token-field/token-input.js.map +1 -1
  124. package/build-module/form-token-field/types.js.map +1 -1
  125. package/build-module/heading/hook.js +6 -3
  126. package/build-module/heading/hook.js.map +1 -1
  127. package/build-module/heading/types.js.map +1 -1
  128. package/build-module/index.native.js +0 -2
  129. package/build-module/index.native.js.map +1 -1
  130. package/build-module/mobile/global-styles-context/utils.native.js +13 -0
  131. package/build-module/mobile/global-styles-context/utils.native.js.map +1 -1
  132. package/build-module/mobile/utils/alignments.native.js +1 -1
  133. package/build-module/mobile/utils/alignments.native.js.map +1 -1
  134. package/build-module/palette-edit/index.js +20 -3
  135. package/build-module/palette-edit/index.js.map +1 -1
  136. package/build-module/private-apis.js +4 -3
  137. package/build-module/private-apis.js.map +1 -1
  138. package/build-module/query-controls/author-select.js +3 -1
  139. package/build-module/query-controls/author-select.js.map +1 -1
  140. package/build-module/query-controls/category-select.js +3 -1
  141. package/build-module/query-controls/category-select.js.map +1 -1
  142. package/build-module/query-controls/index.js +6 -1
  143. package/build-module/query-controls/index.js.map +1 -1
  144. package/build-module/query-controls/types.js.map +1 -1
  145. package/build-module/slot-fill/types.js.map +1 -1
  146. package/build-module/tabs/index.js +25 -6
  147. package/build-module/tabs/index.js.map +1 -1
  148. package/build-module/tabs/tab.js +6 -6
  149. package/build-module/tabs/tab.js.map +1 -1
  150. package/build-module/tabs/tabpanel.js +6 -5
  151. package/build-module/tabs/tabpanel.js.map +1 -1
  152. package/build-module/tabs/types.js.map +1 -1
  153. package/build-module/text/types.js.map +1 -1
  154. package/build-module/toggle-group-control/toggle-group-control/utils.js +17 -17
  155. package/build-module/toggle-group-control/toggle-group-control/utils.js.map +1 -1
  156. package/build-module/tools-panel/tools-panel-item/hook.js +17 -13
  157. package/build-module/tools-panel/tools-panel-item/hook.js.map +1 -1
  158. package/build-style/style-rtl.css +32 -6
  159. package/build-style/style.css +32 -6
  160. package/build-types/angle-picker-control/index.d.ts.map +1 -1
  161. package/build-types/border-control/border-control-dropdown/component.d.ts.map +1 -1
  162. package/build-types/border-control/border-control-dropdown/hook.d.ts +1 -0
  163. package/build-types/border-control/border-control-dropdown/hook.d.ts.map +1 -1
  164. package/build-types/border-control/styles.d.ts +1 -1
  165. package/build-types/border-control/styles.d.ts.map +1 -1
  166. package/build-types/box-control/stories/index.story.d.ts +1944 -0
  167. package/build-types/box-control/stories/index.story.d.ts.map +1 -0
  168. package/build-types/checkbox-control/index.d.ts.map +1 -1
  169. package/build-types/checkbox-control/types.d.ts +3 -2
  170. package/build-types/checkbox-control/types.d.ts.map +1 -1
  171. package/build-types/color-palette/styles.d.ts +4 -1
  172. package/build-types/color-palette/styles.d.ts.map +1 -1
  173. package/build-types/custom-select-control-v2/index.d.ts +6 -0
  174. package/build-types/custom-select-control-v2/index.d.ts.map +1 -0
  175. package/build-types/custom-select-control-v2/stories/index.story.d.ts +19 -0
  176. package/build-types/custom-select-control-v2/stories/index.story.d.ts.map +1 -0
  177. package/build-types/custom-select-control-v2/styles.d.ts +47 -0
  178. package/build-types/custom-select-control-v2/styles.d.ts.map +1 -0
  179. package/build-types/custom-select-control-v2/types.d.ts +57 -0
  180. package/build-types/custom-select-control-v2/types.d.ts.map +1 -0
  181. package/build-types/date-time/date/styles.d.ts +4 -1
  182. package/build-types/date-time/date/styles.d.ts.map +1 -1
  183. package/build-types/date-time/time/timezone.d.ts.map +1 -1
  184. package/build-types/dimension-control/index.d.ts.map +1 -1
  185. package/build-types/dimension-control/types.d.ts +6 -0
  186. package/build-types/dimension-control/types.d.ts.map +1 -1
  187. package/build-types/dropdown-menu-v2-ariakit/index.d.ts +11 -2
  188. package/build-types/dropdown-menu-v2-ariakit/index.d.ts.map +1 -1
  189. package/build-types/dropdown-menu-v2-ariakit/stories/index.story.d.ts.map +1 -1
  190. package/build-types/dropdown-menu-v2-ariakit/styles.d.ts +26 -18
  191. package/build-types/dropdown-menu-v2-ariakit/styles.d.ts.map +1 -1
  192. package/build-types/dropdown-menu-v2-ariakit/types.d.ts +0 -6
  193. package/build-types/dropdown-menu-v2-ariakit/types.d.ts.map +1 -1
  194. package/build-types/focal-point-picker/controls.d.ts +1 -1
  195. package/build-types/focal-point-picker/controls.d.ts.map +1 -1
  196. package/build-types/focal-point-picker/index.d.ts +1 -1
  197. package/build-types/focal-point-picker/index.d.ts.map +1 -1
  198. package/build-types/focal-point-picker/stories/index.story.d.ts +8 -4
  199. package/build-types/focal-point-picker/stories/index.story.d.ts.map +1 -1
  200. package/build-types/focal-point-picker/types.d.ts +7 -0
  201. package/build-types/focal-point-picker/types.d.ts.map +1 -1
  202. package/build-types/font-size-picker/font-size-picker-select.d.ts.map +1 -1
  203. package/build-types/font-size-picker/font-size-picker-toggle-group.d.ts.map +1 -1
  204. package/build-types/font-size-picker/index.d.ts.map +1 -1
  205. package/build-types/font-size-picker/types.d.ts +8 -1
  206. package/build-types/font-size-picker/types.d.ts.map +1 -1
  207. package/build-types/form-token-field/index.d.ts.map +1 -1
  208. package/build-types/form-token-field/token-input.d.ts.map +1 -1
  209. package/build-types/form-token-field/types.d.ts +1 -1
  210. package/build-types/form-token-field/types.d.ts.map +1 -1
  211. package/build-types/heading/component.d.ts +4 -1
  212. package/build-types/heading/component.d.ts.map +1 -1
  213. package/build-types/heading/hook.d.ts.map +1 -1
  214. package/build-types/heading/types.d.ts +20 -1
  215. package/build-types/heading/types.d.ts.map +1 -1
  216. package/build-types/navigation/styles/navigation-styles.d.ts +4 -1
  217. package/build-types/navigation/styles/navigation-styles.d.ts.map +1 -1
  218. package/build-types/palette-edit/index.d.ts +6 -1
  219. package/build-types/palette-edit/index.d.ts.map +1 -1
  220. package/build-types/palette-edit/styles.d.ts +4 -1
  221. package/build-types/palette-edit/styles.d.ts.map +1 -1
  222. package/build-types/private-apis.d.ts.map +1 -1
  223. package/build-types/query-controls/author-select.d.ts +1 -1
  224. package/build-types/query-controls/author-select.d.ts.map +1 -1
  225. package/build-types/query-controls/category-select.d.ts +1 -1
  226. package/build-types/query-controls/category-select.d.ts.map +1 -1
  227. package/build-types/query-controls/index.d.ts +1 -1
  228. package/build-types/query-controls/index.d.ts.map +1 -1
  229. package/build-types/query-controls/types.d.ts +9 -0
  230. package/build-types/query-controls/types.d.ts.map +1 -1
  231. package/build-types/slot-fill/bubbles-virtually/slot.d.ts +1 -1
  232. package/build-types/slot-fill/types.d.ts +16 -6
  233. package/build-types/slot-fill/types.d.ts.map +1 -1
  234. package/build-types/tabs/index.d.ts +3 -2
  235. package/build-types/tabs/index.d.ts.map +1 -1
  236. package/build-types/tabs/stories/index.story.d.ts.map +1 -1
  237. package/build-types/tabs/tab.d.ts +2 -1
  238. package/build-types/tabs/tab.d.ts.map +1 -1
  239. package/build-types/tabs/tabpanel.d.ts +2 -1
  240. package/build-types/tabs/tabpanel.d.ts.map +1 -1
  241. package/build-types/tabs/types.d.ts +8 -3
  242. package/build-types/tabs/types.d.ts.map +1 -1
  243. package/build-types/text/types.d.ts +15 -2
  244. package/build-types/text/types.d.ts.map +1 -1
  245. package/build-types/toggle-group-control/toggle-group-control/utils.d.ts.map +1 -1
  246. package/build-types/tools-panel/tools-panel-item/hook.d.ts.map +1 -1
  247. package/package.json +19 -19
  248. package/src/angle-picker-control/index.tsx +0 -1
  249. package/src/border-control/border-control-dropdown/component.tsx +3 -1
  250. package/src/border-control/border-control-dropdown/hook.ts +3 -2
  251. package/src/border-control/styles.ts +2 -9
  252. package/src/box-control/stories/index.story.tsx +82 -0
  253. package/src/button/style.scss +10 -2
  254. package/src/checkbox-control/README.md +2 -1
  255. package/src/checkbox-control/index.tsx +8 -6
  256. package/src/checkbox-control/test/__snapshots__/index.tsx.snap +3 -8
  257. package/src/checkbox-control/test/index.tsx +7 -0
  258. package/src/checkbox-control/types.ts +3 -2
  259. package/src/combobox-control/README.md +1 -3
  260. package/src/custom-select-control/test/index.js +367 -35
  261. package/src/custom-select-control-v2/README.md +73 -0
  262. package/src/custom-select-control-v2/index.tsx +99 -0
  263. package/src/custom-select-control-v2/stories/index.story.tsx +149 -0
  264. package/src/custom-select-control-v2/styles.ts +76 -0
  265. package/src/custom-select-control-v2/types.ts +63 -0
  266. package/src/date-time/time/timezone.tsx +15 -3
  267. package/src/dimension-control/index.tsx +2 -0
  268. package/src/dimension-control/test/__snapshots__/index.test.js.snap +2 -2
  269. package/src/dimension-control/types.ts +6 -0
  270. package/src/dropdown-menu-v2-ariakit/README.md +19 -5
  271. package/src/dropdown-menu-v2-ariakit/index.tsx +85 -36
  272. package/src/dropdown-menu-v2-ariakit/stories/index.story.tsx +204 -90
  273. package/src/dropdown-menu-v2-ariakit/styles.ts +165 -117
  274. package/src/dropdown-menu-v2-ariakit/test/index.tsx +5 -10
  275. package/src/dropdown-menu-v2-ariakit/types.ts +0 -7
  276. package/src/focal-point-picker/controls.tsx +4 -0
  277. package/src/focal-point-picker/index.tsx +2 -0
  278. package/src/focal-point-picker/styles/focal-point-picker-style.ts +1 -1
  279. package/src/focal-point-picker/types.ts +7 -0
  280. package/src/font-size-picker/font-size-picker-select.tsx +2 -0
  281. package/src/font-size-picker/font-size-picker-toggle-group.tsx +9 -1
  282. package/src/font-size-picker/index.tsx +11 -3
  283. package/src/font-size-picker/types.ts +8 -1
  284. package/src/form-toggle/style.scss +40 -8
  285. package/src/form-token-field/index.tsx +11 -3
  286. package/src/form-token-field/token-input.tsx +1 -3
  287. package/src/form-token-field/types.ts +1 -0
  288. package/src/heading/README.md +6 -1
  289. package/src/heading/hook.ts +6 -3
  290. package/src/heading/types.ts +23 -1
  291. package/src/index.native.js +0 -2
  292. package/src/mobile/global-styles-context/test/utils.native.js +22 -0
  293. package/src/mobile/global-styles-context/utils.native.js +14 -0
  294. package/src/mobile/link-settings/style.native.scss +0 -17
  295. package/src/mobile/utils/alignments.native.js +1 -0
  296. package/src/navigable-container/README.md +1 -1
  297. package/src/palette-edit/index.tsx +22 -8
  298. package/src/palette-edit/style.scss +2 -2
  299. package/src/palette-edit/test/index.tsx +75 -1
  300. package/src/private-apis.ts +4 -2
  301. package/src/query-controls/author-select.tsx +2 -0
  302. package/src/query-controls/category-select.tsx +2 -0
  303. package/src/query-controls/index.tsx +6 -1
  304. package/src/query-controls/types.ts +9 -0
  305. package/src/search-control/README.md +2 -0
  306. package/src/slot-fill/README.md +1 -1
  307. package/src/slot-fill/types.ts +18 -6
  308. package/src/spinner/README.md +2 -0
  309. package/src/tabs/README.md +4 -4
  310. package/src/tabs/index.tsx +34 -3
  311. package/src/tabs/stories/index.story.tsx +56 -48
  312. package/src/tabs/tab.tsx +7 -7
  313. package/src/tabs/tabpanel.tsx +10 -6
  314. package/src/tabs/test/index.tsx +180 -87
  315. package/src/tabs/types.ts +8 -3
  316. package/src/text/README.md +5 -1
  317. package/src/text/types.ts +15 -2
  318. package/src/toggle-control/README.md +2 -2
  319. package/src/toggle-group-control/test/index.tsx +54 -1
  320. package/src/toggle-group-control/toggle-group-control/utils.ts +15 -20
  321. package/src/tools-panel/tools-panel-item/hook.ts +21 -23
  322. package/tsconfig.tsbuildinfo +1 -1
  323. package/build/mobile/inserter-button/index.native.js +0 -98
  324. package/build/mobile/inserter-button/index.native.js.map +0 -1
  325. package/build/mobile/inserter-button/sparkles.js +0 -23
  326. package/build/mobile/inserter-button/sparkles.js.map +0 -1
  327. package/build/mobile/link-settings/image-link-destinations-screen.native.js +0 -119
  328. package/build/mobile/link-settings/image-link-destinations-screen.native.js.map +0 -1
  329. package/build-module/mobile/inserter-button/index.native.js +0 -89
  330. package/build-module/mobile/inserter-button/index.native.js.map +0 -1
  331. package/build-module/mobile/inserter-button/sparkles.js +0 -15
  332. package/build-module/mobile/inserter-button/sparkles.js.map +0 -1
  333. package/build-module/mobile/link-settings/image-link-destinations-screen.native.js +0 -110
  334. package/build-module/mobile/link-settings/image-link-destinations-screen.native.js.map +0 -1
  335. package/build-types/mobile/inserter-button/sparkles.d.ts +0 -3
  336. package/build-types/mobile/inserter-button/sparkles.d.ts.map +0 -1
  337. package/src/box-control/stories/index.story.js +0 -75
  338. package/src/mobile/inserter-button/README.md +0 -62
  339. package/src/mobile/inserter-button/index.native.js +0 -116
  340. package/src/mobile/inserter-button/sparkles.js +0 -15
  341. package/src/mobile/inserter-button/style.native.scss +0 -72
  342. package/src/mobile/link-settings/image-link-destinations-screen.native.js +0 -152
@@ -20,11 +20,11 @@ var _context = require("./context");
20
20
 
21
21
  const TabPanel = (0, _element.forwardRef)(function TabPanel({
22
22
  children,
23
- id,
23
+ tabId,
24
24
  focusable = true,
25
25
  ...otherProps
26
26
  }, ref) {
27
- const context = (0, _element.useContext)(_context.TabsContext);
27
+ const context = (0, _context.useTabsContext)();
28
28
  if (!context) {
29
29
  typeof SCRIPT_DEBUG !== "undefined" && SCRIPT_DEBUG === true ? (0, _warning.default)('`Tabs.TabPanel` must be wrapped in a `Tabs` component.') : void 0;
30
30
  return null;
@@ -33,10 +33,11 @@ const TabPanel = (0, _element.forwardRef)(function TabPanel({
33
33
  store,
34
34
  instanceId
35
35
  } = context;
36
+ const instancedTabId = `${instanceId}-${tabId}`;
36
37
  return (0, _react.createElement)(_styles.TabPanel, {
37
38
  ref: ref,
38
39
  store: store,
39
- id: `${instanceId}-${id}-view`,
40
+ id: instancedTabId,
40
41
  focusable: focusable,
41
42
  ...otherProps
42
43
  }, children);
@@ -1 +1 @@
1
- {"version":3,"names":["_element","require","_styles","_warning","_interopRequireDefault","_context","TabPanel","forwardRef","children","id","focusable","otherProps","ref","context","useContext","TabsContext","SCRIPT_DEBUG","warning","store","instanceId","_react","createElement","exports"],"sources":["@wordpress/components/src/tabs/tabpanel.tsx"],"sourcesContent":["/**\n * External dependencies\n */\n\n/**\n * WordPress dependencies\n */\n\nimport { forwardRef, useContext } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport type { TabPanelProps } from './types';\nimport { TabPanel as StyledTabPanel } from './styles';\n\nimport warning from '@wordpress/warning';\nimport { TabsContext } from './context';\nimport type { WordPressComponentProps } from '../context';\n\nexport const TabPanel = forwardRef<\n\tHTMLDivElement,\n\tWordPressComponentProps< TabPanelProps, 'div', false >\n>( function TabPanel( { children, id, focusable = true, ...otherProps }, ref ) {\n\tconst context = useContext( TabsContext );\n\tif ( ! context ) {\n\t\twarning( '`Tabs.TabPanel` must be wrapped in a `Tabs` component.' );\n\t\treturn null;\n\t}\n\tconst { store, instanceId } = context;\n\n\treturn (\n\t\t<StyledTabPanel\n\t\t\tref={ ref }\n\t\t\tstore={ store }\n\t\t\tid={ `${ instanceId }-${ id }-view` }\n\t\t\tfocusable={ focusable }\n\t\t\t{ ...otherProps }\n\t\t>\n\t\t\t{ children }\n\t\t</StyledTabPanel>\n\t);\n} );\n"],"mappings":";;;;;;;;AAQA,IAAAA,QAAA,GAAAC,OAAA;AAMA,IAAAC,OAAA,GAAAD,OAAA;AAEA,IAAAE,QAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AAjBA;AACA;AACA;;AAEA;AACA;AACA;;AAcO,MAAMK,QAAQ,GAAG,IAAAC,mBAAU,EAG/B,SAASD,QAAQA,CAAE;EAAEE,QAAQ;EAAEC,EAAE;EAAEC,SAAS,GAAG,IAAI;EAAE,GAAGC;AAAW,CAAC,EAAEC,GAAG,EAAG;EAC9E,MAAMC,OAAO,GAAG,IAAAC,mBAAU,EAAEC,oBAAY,CAAC;EACzC,IAAK,CAAEF,OAAO,EAAG;IAChB,OAAAG,YAAA,oBAAAA,YAAA,gBAAAC,gBAAO,EAAE,wDAAyD,CAAC;IACnE,OAAO,IAAI;EACZ;EACA,MAAM;IAAEC,KAAK;IAAEC;EAAW,CAAC,GAAGN,OAAO;EAErC,OACC,IAAAO,MAAA,CAAAC,aAAA,EAACnB,OAAA,CAAAI,QAAc;IACdM,GAAG,EAAGA,GAAK;IACXM,KAAK,EAAGA,KAAO;IACfT,EAAE,EAAI,GAAGU,UAAY,IAAIV,EAAI,OAAQ;IACrCC,SAAS,EAAGA,SAAW;IAAA,GAClBC;EAAU,GAEbH,QACa,CAAC;AAEnB,CAAE,CAAC;AAACc,OAAA,CAAAhB,QAAA,GAAAA,QAAA"}
1
+ {"version":3,"names":["_element","require","_styles","_warning","_interopRequireDefault","_context","TabPanel","forwardRef","children","tabId","focusable","otherProps","ref","context","useTabsContext","SCRIPT_DEBUG","warning","store","instanceId","instancedTabId","_react","createElement","id","exports"],"sources":["@wordpress/components/src/tabs/tabpanel.tsx"],"sourcesContent":["/**\n * External dependencies\n */\n\n/**\n * WordPress dependencies\n */\n\nimport { forwardRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport type { TabPanelProps } from './types';\nimport { TabPanel as StyledTabPanel } from './styles';\n\nimport warning from '@wordpress/warning';\nimport { useTabsContext } from './context';\nimport type { WordPressComponentProps } from '../context';\n\nexport const TabPanel = forwardRef<\n\tHTMLDivElement,\n\tOmit< WordPressComponentProps< TabPanelProps, 'div', false >, 'id' >\n>( function TabPanel(\n\t{ children, tabId, focusable = true, ...otherProps },\n\tref\n) {\n\tconst context = useTabsContext();\n\tif ( ! context ) {\n\t\twarning( '`Tabs.TabPanel` must be wrapped in a `Tabs` component.' );\n\t\treturn null;\n\t}\n\tconst { store, instanceId } = context;\n\tconst instancedTabId = `${ instanceId }-${ tabId }`;\n\n\treturn (\n\t\t<StyledTabPanel\n\t\t\tref={ ref }\n\t\t\tstore={ store }\n\t\t\tid={ instancedTabId }\n\t\t\tfocusable={ focusable }\n\t\t\t{ ...otherProps }\n\t\t>\n\t\t\t{ children }\n\t\t</StyledTabPanel>\n\t);\n} );\n"],"mappings":";;;;;;;;AAQA,IAAAA,QAAA,GAAAC,OAAA;AAMA,IAAAC,OAAA,GAAAD,OAAA;AAEA,IAAAE,QAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AAjBA;AACA;AACA;;AAEA;AACA;AACA;;AAcO,MAAMK,QAAQ,GAAG,IAAAC,mBAAU,EAG/B,SAASD,QAAQA,CACnB;EAAEE,QAAQ;EAAEC,KAAK;EAAEC,SAAS,GAAG,IAAI;EAAE,GAAGC;AAAW,CAAC,EACpDC,GAAG,EACF;EACD,MAAMC,OAAO,GAAG,IAAAC,uBAAc,EAAC,CAAC;EAChC,IAAK,CAAED,OAAO,EAAG;IAChB,OAAAE,YAAA,oBAAAA,YAAA,gBAAAC,gBAAO,EAAE,wDAAyD,CAAC;IACnE,OAAO,IAAI;EACZ;EACA,MAAM;IAAEC,KAAK;IAAEC;EAAW,CAAC,GAAGL,OAAO;EACrC,MAAMM,cAAc,GAAI,GAAGD,UAAY,IAAIT,KAAO,EAAC;EAEnD,OACC,IAAAW,MAAA,CAAAC,aAAA,EAACnB,OAAA,CAAAI,QAAc;IACdM,GAAG,EAAGA,GAAK;IACXK,KAAK,EAAGA,KAAO;IACfK,EAAE,EAAGH,cAAgB;IACrBT,SAAS,EAAGA,SAAW;IAAA,GAClBC;EAAU,GAEbH,QACa,CAAC;AAEnB,CAAE,CAAC;AAACe,OAAA,CAAAjB,QAAA,GAAAA,QAAA"}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["@wordpress/components/src/tabs/types.ts"],"sourcesContent":["/**\n * External dependencies\n */\n// eslint-disable-next-line no-restricted-imports\nimport type * as Ariakit from '@ariakit/react';\n\nexport type TabsContextProps =\n\t| {\n\t\t\t/**\n\t\t\t * The tabStore object returned by Ariakit's `useTabStore` hook.\n\t\t\t */\n\t\t\tstore: Ariakit.TabStore;\n\t\t\t/**\n\t\t\t * The unique id string for this instance of the Tabs component.\n\t\t\t */\n\t\t\tinstanceId: string;\n\t }\n\t| undefined;\n\nexport type TabsProps = {\n\t/**\n\t * The children elements, which should be at least a\n\t * `Tabs.Tablist` component and a series of `Tabs.TabPanel`\n\t * components.\n\t */\n\tchildren: React.ReactNode;\n\t/**\n\t * When `true`, the tab will be selected when receiving focus (automatic tab\n\t * activation). When `false`, the tab will be selected only when clicked\n\t * (manual tab activation). See the official W3C docs for more info.\n\t *\n\t * @default true\n\t *\n\t * @see https://www.w3.org/WAI/ARIA/apg/patterns/tabpanel/\n\t */\n\tselectOnMove?: boolean;\n\t/**\n\t * The id of the tab to be selected upon mounting of component.\n\t * If this prop is not set, the first tab will be selected by default.\n\t * The id provided will be internally prefixed with the\n\t * `TabsContextProps.instanceId`.\n\t *\n\t * Note: this prop will be overridden by the `selectedTabId` prop if it is\n\t * provided. (Controlled Mode)\n\t */\n\tinitialTabId?: string;\n\t/**\n\t * The function called when a tab has been selected.\n\t * It is passed the id of the newly selected tab as an argument.\n\t */\n\tonSelect?: ( selectedId: string | null | undefined ) => void;\n\n\t/**\n\t * The orientation of the tablist.\n\t *\n\t * @default `horizontal`\n\t */\n\torientation?: 'horizontal' | 'vertical';\n\t/**\n\t * The Id of the tab to display. This id is prepended with the `Tabs`\n\t * instanceId internally.\n\t *\n\t * If left `undefined`, the component assumes it is being used in\n\t * uncontrolled mode. Consequently, any value different than `undefined`\n\t * will set the component in `controlled` mode.\n\t * When in controlled mode, the `null` value will result in no tab being selected.\n\t */\n\tselectedTabId?: string | null;\n};\n\nexport type TabListProps = {\n\t/**\n\t * The children elements, which should be a series of `Tabs.TabPanel` components.\n\t */\n\tchildren?: React.ReactNode;\n};\n\nexport type TabProps = {\n\t/**\n\t * The id of the tab, which is prepended with the `Tabs` instanceId.\n\t */\n\tid: string;\n\t/**\n\t * The children elements, generally the text to display on the tab.\n\t */\n\tchildren?: React.ReactNode;\n\t/**\n\t * Determines if the tab button should be disabled.\n\t *\n\t * @default false\n\t */\n\tdisabled?: boolean;\n\t/**\n\t * The type of component to render the tab button as. If this prop is not\n\t * provided, the tab button will be rendered as a `button` element.\n\t */\n\trender?: React.ReactElement;\n};\n\nexport type TabPanelProps = {\n\t/**\n\t * The children elements, generally the content to display on the tabpanel.\n\t */\n\tchildren?: React.ReactNode;\n\t/**\n\t * A unique identifier for the tabpanel, which is used to generate a unique `id` for the underlying element.\n\t */\n\tid: string;\n\t/**\n\t * Determines whether or not the tabpanel element should be focusable.\n\t * If `false`, pressing the tab key will skip over the tabpanel, and instead\n\t * focus on the first focusable element in the panel (if there is one).\n\t *\n\t * @default true\n\t */\n\tfocusable?: boolean;\n};\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["@wordpress/components/src/tabs/types.ts"],"sourcesContent":["/**\n * External dependencies\n */\n// eslint-disable-next-line no-restricted-imports\nimport type * as Ariakit from '@ariakit/react';\n\nexport type TabsContextProps =\n\t| {\n\t\t\t/**\n\t\t\t * The tabStore object returned by Ariakit's `useTabStore` hook.\n\t\t\t */\n\t\t\tstore: Ariakit.TabStore;\n\t\t\t/**\n\t\t\t * The unique id string for this instance of the Tabs component.\n\t\t\t */\n\t\t\tinstanceId: string;\n\t }\n\t| undefined;\n\nexport type TabsProps = {\n\t/**\n\t * The children elements, which should be at least a\n\t * `Tabs.Tablist` component and a series of `Tabs.TabPanel`\n\t * components.\n\t */\n\tchildren: React.ReactNode;\n\t/**\n\t * When `true`, the tab will be selected when receiving focus (automatic tab\n\t * activation). When `false`, the tab will be selected only when clicked\n\t * (manual tab activation). See the official W3C docs for more info.\n\t *\n\t * @default true\n\t *\n\t * @see https://www.w3.org/WAI/ARIA/apg/patterns/tabpanel/\n\t */\n\tselectOnMove?: boolean;\n\t/**\n\t * The id of the tab to be selected upon mounting of component.\n\t * If this prop is not set, the first tab will be selected by default.\n\t * The id provided will be internally prefixed with the\n\t * `TabsContextProps.instanceId`.\n\t *\n\t * Note: this prop will be overridden by the `selectedTabId` prop if it is\n\t * provided. (Controlled Mode)\n\t */\n\tinitialTabId?: string;\n\t/**\n\t * The function called when a tab has been selected.\n\t * It is passed the id of the newly selected tab as an argument.\n\t */\n\tonSelect?: ( selectedId: string | null | undefined ) => void;\n\n\t/**\n\t * The orientation of the tablist.\n\t *\n\t * @default `horizontal`\n\t */\n\torientation?: 'horizontal' | 'vertical';\n\t/**\n\t * The Id of the tab to display. This id is prepended with the `Tabs`\n\t * instanceId internally.\n\t *\n\t * If left `undefined`, the component assumes it is being used in\n\t * uncontrolled mode. Consequently, any value different than `undefined`\n\t * will set the component in `controlled` mode.\n\t * When in controlled mode, the `null` value will result in no tab being selected.\n\t */\n\tselectedTabId?: string | null;\n};\n\nexport type TabListProps = {\n\t/**\n\t * The children elements, which should be a series of `Tabs.TabPanel` components.\n\t */\n\tchildren?: React.ReactNode;\n};\n\nexport type TabProps = {\n\t/**\n\t * The id of the tab, which is prepended with the `Tabs` instanceId.\n\t * The value of this prop should match with the value of the `tabId` prop on\n\t * the corresponding `Tabs.TabPanel` component.\n\t */\n\ttabId: string;\n\t/**\n\t * The children elements, generally the text to display on the tab.\n\t */\n\tchildren?: React.ReactNode;\n\t/**\n\t * Determines if the tab button should be disabled.\n\t *\n\t * @default false\n\t */\n\tdisabled?: boolean;\n\t/**\n\t * The type of component to render the tab button as. If this prop is not\n\t * provided, the tab button will be rendered as a `button` element.\n\t */\n\trender?: React.ReactElement;\n};\n\nexport type TabPanelProps = {\n\t/**\n\t * The children elements, generally the content to display on the tabpanel.\n\t */\n\tchildren?: React.ReactNode;\n\t/**\n\t * A unique identifier for the tabpanel, which is used to generate an\n\t * instanced id for the underlying element.\n\t * The value of this prop should match with the value of the `tabId` prop on\n\t * the corresponding `Tabs.Tab` component.\n\t */\n\ttabId: string;\n\t/**\n\t * Determines whether or not the tabpanel element should be focusable.\n\t * If `false`, pressing the tab key will skip over the tabpanel, and instead\n\t * focus on the first focusable element in the panel (if there is one).\n\t *\n\t * @default true\n\t */\n\tfocusable?: boolean;\n};\n"],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["@wordpress/components/src/text/types.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport type { TruncateProps } from '../truncate/types';\n\n/**\n * External dependencies\n */\nimport type { CSSProperties } from 'react';\nimport type { FindAllArgs } from 'highlight-words-core';\n\nexport type TextSize =\n\t| 'body'\n\t| 'caption'\n\t| 'footnote'\n\t| 'largeTitle'\n\t| 'subheadline'\n\t| 'title';\n\ntype TextVariant = 'muted';\n\ntype TextWeight = 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900;\n\nexport interface Props extends TruncateProps {\n\t/**\n\t * Adjusts the text alignment.\n\t */\n\talign?: CSSProperties[ 'textAlign' ];\n\t/**\n\t * Automatically calculate the appropriate line-height value for contents that render text and Control elements (e.g. `TextInput`).\n\t */\n\tadjustLineHeightForInnerControls?: 'large' | 'medium' | 'small' | 'xSmall';\n\t/**\n\t * Adjusts the text color.\n\t */\n\tcolor?: CSSProperties[ 'color' ];\n\t/**\n\t * Adjusts the CSS display.\n\t */\n\tdisplay?: CSSProperties[ 'display' ];\n\t/**\n\t * Renders a destructive color.\n\t *\n\t * @default false\n\t */\n\tisDestructive?: boolean;\n\t/**\n\t * Escape characters in `highlightWords` which are meaningful in regular expressions.\n\t */\n\thighlightEscape?: boolean;\n\t/**\n\t * Determines if `highlightWords` should be case sensitive.\n\t */\n\thighlightCaseSensitive?: boolean;\n\t/**\n\t * Array of search words. String search terms are automatically cast to RegExps unless `highlightEscape` is true.\n\t */\n\thighlightSanitize?: FindAllArgs[ 'sanitize' ];\n\t/**\n\t * Sets `Text` to have `display: block`.\n\t */\n\tisBlock?: boolean;\n\t/**\n\t * Adjusts all text line-height based on the typography system.\n\t */\n\tlineHeight?: CSSProperties[ 'lineHeight' ];\n\t/**\n\t * The `Text` color can be adapted to a background color for optimal readability. `optimizeReadabilityFor` can accept CSS variables, in addition to standard CSS color values (e.g. Hex, RGB, HSL, etc...).\n\t */\n\toptimizeReadabilityFor?: CSSProperties[ 'color' ];\n\t/**\n\t * Adjusts text size based on the typography system. `Text` can render a wide range of font sizes, which are automatically calculated and adapted to the typography system. The `size` value can be a system preset, a `number`, or a custom unit value (`string`) such as `30em`.\n\t */\n\tsize?: CSSProperties[ 'fontSize' ] | TextSize;\n\t/**\n\t * Enables text truncation. When `truncate` is set,we are able to truncate the long text in a variety of ways.\n\t */\n\ttruncate?: boolean;\n\t/**\n\t * Uppercases the text content.\n\t */\n\tupperCase?: boolean;\n\t/**\n\t * Adjusts style variation of the text.\n\t */\n\tvariant?: TextVariant;\n\t/**\n\t * Adjusts font-weight of the text.\n\t */\n\tweight?: CSSProperties[ 'fontWeight' ] | TextWeight;\n\t/**\n\t * Adjusts letter-spacing of the text.\n\t */\n\tletterSpacing?: CSSProperties[ 'letterSpacing' ];\n\t/**\n\t * Letters or words within `Text` can be highlighted using `highlightWords`.\n\t */\n\thighlightWords?: string[];\n}\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["@wordpress/components/src/text/types.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport type { TruncateProps } from '../truncate/types';\n\n/**\n * External dependencies\n */\nimport type { CSSProperties } from 'react';\nimport type { FindAllArgs } from 'highlight-words-core';\n\nexport type TextSize =\n\t| 'body'\n\t| 'caption'\n\t| 'footnote'\n\t| 'largeTitle'\n\t| 'subheadline'\n\t| 'title';\n\ntype TextVariant = 'muted';\n\ntype TextWeight = 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900;\n\nexport interface Props extends TruncateProps {\n\t/**\n\t * Adjusts the text alignment.\n\t */\n\talign?: CSSProperties[ 'textAlign' ];\n\t/**\n\t * Automatically calculate the appropriate line-height value for contents that render text and Control elements (e.g. `TextInput`).\n\t */\n\tadjustLineHeightForInnerControls?: 'large' | 'medium' | 'small' | 'xSmall';\n\t/**\n\t * Adjusts the text color.\n\t */\n\tcolor?: CSSProperties[ 'color' ];\n\t/**\n\t * Adjusts the CSS display.\n\t */\n\tdisplay?: CSSProperties[ 'display' ];\n\t/**\n\t * Renders a destructive color.\n\t *\n\t * @default false\n\t */\n\tisDestructive?: boolean;\n\t/**\n\t * Escape characters in `highlightWords` which are meaningful in regular expressions.\n\t *\n\t * @default false\n\t */\n\thighlightEscape?: boolean;\n\t/**\n\t * Determines if `highlightWords` should be case sensitive.\n\t *\n\t * @default false\n\t */\n\thighlightCaseSensitive?: boolean;\n\t/**\n\t * Array of search words. String search terms are automatically cast to RegExps unless `highlightEscape` is true.\n\t */\n\thighlightSanitize?: FindAllArgs[ 'sanitize' ];\n\t/**\n\t * Sets `Text` to have `display: block`. Note: text truncation only works\n\t * when `isBlock` is `false`.\n\t *\n\t * @default false\n\t */\n\tisBlock?: boolean;\n\t/**\n\t * Adjusts all text line-height based on the typography system.\n\t */\n\tlineHeight?: CSSProperties[ 'lineHeight' ];\n\t/**\n\t * The `Text` color can be adapted to a background color for optimal readability. `optimizeReadabilityFor` can accept CSS variables, in addition to standard CSS color values (e.g. Hex, RGB, HSL, etc...).\n\t */\n\toptimizeReadabilityFor?: CSSProperties[ 'color' ];\n\t/**\n\t * Adjusts text size based on the typography system. `Text` can render a wide range of font sizes, which are automatically calculated and adapted to the typography system. The `size` value can be a system preset, a `number`, or a custom unit value (`string`) such as `30em`.\n\t */\n\tsize?: CSSProperties[ 'fontSize' ] | TextSize;\n\t/**\n\t * Enables text truncation. When `truncate` is set, we are able to truncate the long text in a variety of ways. Note: text truncation won't work if the `isBlock` property is set to `true`\n\t *\n\t * @default false\n\t */\n\ttruncate?: boolean;\n\t/**\n\t * Uppercases the text content.\n\t *\n\t * @default false\n\t */\n\tupperCase?: boolean;\n\t/**\n\t * Adjusts style variation of the text.\n\t */\n\tvariant?: TextVariant;\n\t/**\n\t * Adjusts font-weight of the text.\n\t *\n\t * @default 'normal'\n\t */\n\tweight?: CSSProperties[ 'fontWeight' ] | TextWeight;\n\t/**\n\t * Adjusts letter-spacing of the text.\n\t */\n\tletterSpacing?: CSSProperties[ 'letterSpacing' ];\n\t/**\n\t * Letters or words within `Text` can be highlighted using `highlightWords`.\n\t */\n\thighlightWords?: string[];\n}\n"],"mappings":""}
@@ -18,27 +18,27 @@ var _element = require("@wordpress/element");
18
18
  * @param valueProp The received `value`
19
19
  */
20
20
  function useComputeControlledOrUncontrolledValue(valueProp) {
21
- const hasEverBeenUsedInControlledMode = (0, _element.useRef)(false);
22
- const previousValueProp = (0, _compose.usePrevious)(valueProp);
21
+ const prevValueProp = (0, _compose.usePrevious)(valueProp);
22
+ const prevIsControlled = (0, _element.useRef)(false);
23
+
24
+ // Assume the component is being used in controlled mode on the first re-render
25
+ // that has a different `valueProp` from the previous render.
26
+ const isControlled = prevIsControlled.current || prevValueProp !== undefined && valueProp !== undefined && prevValueProp !== valueProp;
23
27
  (0, _element.useEffect)(() => {
24
- if (!hasEverBeenUsedInControlledMode.current) {
25
- // Assume the component is being used in controlled mode if:
26
- // - the `value` prop is not `undefined`
27
- // - the `value` prop was not previously `undefined` and was given a new value
28
- hasEverBeenUsedInControlledMode.current = valueProp !== undefined && previousValueProp !== undefined && valueProp !== previousValueProp;
29
- }
30
- }, [valueProp, previousValueProp]);
31
- let value, defaultValue;
32
- if (hasEverBeenUsedInControlledMode.current) {
28
+ prevIsControlled.current = isControlled;
29
+ }, [isControlled]);
30
+ if (isControlled) {
33
31
  // When in controlled mode, use `''` instead of `undefined`
34
- value = valueProp !== null && valueProp !== void 0 ? valueProp : '';
35
- } else {
36
- // When in uncontrolled mode, the `value` should be intended as the initial value
37
- defaultValue = valueProp;
32
+ return {
33
+ value: valueProp !== null && valueProp !== void 0 ? valueProp : '',
34
+ defaultValue: undefined
35
+ };
38
36
  }
37
+
38
+ // When in uncontrolled mode, the `value` should be intended as the initial value
39
39
  return {
40
- value,
41
- defaultValue
40
+ value: undefined,
41
+ defaultValue: valueProp
42
42
  };
43
43
  }
44
44
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_compose","require","_element","useComputeControlledOrUncontrolledValue","valueProp","hasEverBeenUsedInControlledMode","useRef","previousValueProp","usePrevious","useEffect","current","undefined","value","defaultValue"],"sources":["@wordpress/components/src/toggle-group-control/toggle-group-control/utils.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { usePrevious } from '@wordpress/compose';\nimport { useEffect, useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport type { ToggleGroupControlProps } from '../types';\n\ntype ValueProp = ToggleGroupControlProps[ 'value' ];\n\n/**\n * Used to determine, via an internal heuristics, whether an `undefined` value\n * received for the `value` prop should be interpreted as the component being\n * used in uncontrolled mode, or as an \"empty\" value for controlled mode.\n *\n * @param valueProp The received `value`\n */\nexport function useComputeControlledOrUncontrolledValue(\n\tvalueProp: ValueProp\n): { value: ValueProp; defaultValue: ValueProp } {\n\tconst hasEverBeenUsedInControlledMode = useRef( false );\n\tconst previousValueProp = usePrevious( valueProp );\n\n\tuseEffect( () => {\n\t\tif ( ! hasEverBeenUsedInControlledMode.current ) {\n\t\t\t// Assume the component is being used in controlled mode if:\n\t\t\t// - the `value` prop is not `undefined`\n\t\t\t// - the `value` prop was not previously `undefined` and was given a new value\n\t\t\thasEverBeenUsedInControlledMode.current =\n\t\t\t\tvalueProp !== undefined &&\n\t\t\t\tpreviousValueProp !== undefined &&\n\t\t\t\tvalueProp !== previousValueProp;\n\t\t}\n\t}, [ valueProp, previousValueProp ] );\n\n\tlet value, defaultValue;\n\n\tif ( hasEverBeenUsedInControlledMode.current ) {\n\t\t// When in controlled mode, use `''` instead of `undefined`\n\t\tvalue = valueProp ?? '';\n\t} else {\n\t\t// When in uncontrolled mode, the `value` should be intended as the initial value\n\t\tdefaultValue = valueProp;\n\t}\n\n\treturn { value, defaultValue };\n}\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAJA;AACA;AACA;;AAWA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,uCAAuCA,CACtDC,SAAoB,EAC4B;EAChD,MAAMC,+BAA+B,GAAG,IAAAC,eAAM,EAAE,KAAM,CAAC;EACvD,MAAMC,iBAAiB,GAAG,IAAAC,oBAAW,EAAEJ,SAAU,CAAC;EAElD,IAAAK,kBAAS,EAAE,MAAM;IAChB,IAAK,CAAEJ,+BAA+B,CAACK,OAAO,EAAG;MAChD;MACA;MACA;MACAL,+BAA+B,CAACK,OAAO,GACtCN,SAAS,KAAKO,SAAS,IACvBJ,iBAAiB,KAAKI,SAAS,IAC/BP,SAAS,KAAKG,iBAAiB;IACjC;EACD,CAAC,EAAE,CAAEH,SAAS,EAAEG,iBAAiB,CAAG,CAAC;EAErC,IAAIK,KAAK,EAAEC,YAAY;EAEvB,IAAKR,+BAA+B,CAACK,OAAO,EAAG;IAC9C;IACAE,KAAK,GAAGR,SAAS,aAATA,SAAS,cAATA,SAAS,GAAI,EAAE;EACxB,CAAC,MAAM;IACN;IACAS,YAAY,GAAGT,SAAS;EACzB;EAEA,OAAO;IAAEQ,KAAK;IAAEC;EAAa,CAAC;AAC/B"}
1
+ {"version":3,"names":["_compose","require","_element","useComputeControlledOrUncontrolledValue","valueProp","prevValueProp","usePrevious","prevIsControlled","useRef","isControlled","current","undefined","useEffect","value","defaultValue"],"sources":["@wordpress/components/src/toggle-group-control/toggle-group-control/utils.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { usePrevious } from '@wordpress/compose';\nimport { useEffect, useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport type { ToggleGroupControlProps } from '../types';\n\ntype ValueProp = ToggleGroupControlProps[ 'value' ];\n\n/**\n * Used to determine, via an internal heuristics, whether an `undefined` value\n * received for the `value` prop should be interpreted as the component being\n * used in uncontrolled mode, or as an \"empty\" value for controlled mode.\n *\n * @param valueProp The received `value`\n */\nexport function useComputeControlledOrUncontrolledValue(\n\tvalueProp: ValueProp\n): { value: ValueProp; defaultValue: ValueProp } {\n\tconst prevValueProp = usePrevious( valueProp );\n\tconst prevIsControlled = useRef( false );\n\n\t// Assume the component is being used in controlled mode on the first re-render\n\t// that has a different `valueProp` from the previous render.\n\tconst isControlled =\n\t\tprevIsControlled.current ||\n\t\t( prevValueProp !== undefined &&\n\t\t\tvalueProp !== undefined &&\n\t\t\tprevValueProp !== valueProp );\n\tuseEffect( () => {\n\t\tprevIsControlled.current = isControlled;\n\t}, [ isControlled ] );\n\n\tif ( isControlled ) {\n\t\t// When in controlled mode, use `''` instead of `undefined`\n\t\treturn { value: valueProp ?? '', defaultValue: undefined };\n\t}\n\n\t// When in uncontrolled mode, the `value` should be intended as the initial value\n\treturn { value: undefined, defaultValue: valueProp };\n}\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAJA;AACA;AACA;;AAWA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,uCAAuCA,CACtDC,SAAoB,EAC4B;EAChD,MAAMC,aAAa,GAAG,IAAAC,oBAAW,EAAEF,SAAU,CAAC;EAC9C,MAAMG,gBAAgB,GAAG,IAAAC,eAAM,EAAE,KAAM,CAAC;;EAExC;EACA;EACA,MAAMC,YAAY,GACjBF,gBAAgB,CAACG,OAAO,IACtBL,aAAa,KAAKM,SAAS,IAC5BP,SAAS,KAAKO,SAAS,IACvBN,aAAa,KAAKD,SAAW;EAC/B,IAAAQ,kBAAS,EAAE,MAAM;IAChBL,gBAAgB,CAACG,OAAO,GAAGD,YAAY;EACxC,CAAC,EAAE,CAAEA,YAAY,CAAG,CAAC;EAErB,IAAKA,YAAY,EAAG;IACnB;IACA,OAAO;MAAEI,KAAK,EAAET,SAAS,aAATA,SAAS,cAATA,SAAS,GAAI,EAAE;MAAEU,YAAY,EAAEH;IAAU,CAAC;EAC3D;;EAEA;EACA,OAAO;IAAEE,KAAK,EAAEF,SAAS;IAAEG,YAAY,EAAEV;EAAU,CAAC;AACrD"}
@@ -48,14 +48,25 @@ function useToolsPanelItem(props) {
48
48
  __experimentalFirstVisibleItemClass,
49
49
  __experimentalLastVisibleItemClass
50
50
  } = (0, _context.useToolsPanelContext)();
51
- const hasValueCallback = (0, _element.useCallback)(hasValue, [panelId, hasValue]);
52
- const resetAllFilterCallback = (0, _element.useCallback)(resetAllFilter, [panelId, resetAllFilter]);
51
+
52
+ // hasValue is a new function on every render, so do not add it as a
53
+ // dependency to the useCallback hook! If needed, we should use a ref.
54
+ // eslint-disable-next-line react-hooks/exhaustive-deps
55
+ const hasValueCallback = (0, _element.useCallback)(hasValue, [panelId]);
56
+ // resetAllFilter is a new function on every render, so do not add it as a
57
+ // dependency to the useCallback hook! If needed, we should use a ref.
58
+ // eslint-disable-next-line react-hooks/exhaustive-deps
59
+ const resetAllFilterCallback = (0, _element.useCallback)(resetAllFilter, [panelId]);
53
60
  const previousPanelId = (0, _compose.usePrevious)(currentPanelId);
54
61
  const hasMatchingPanel = currentPanelId === panelId || currentPanelId === null;
55
62
 
56
63
  // Registering the panel item allows the panel to include it in its
57
64
  // automatically generated menu and determine its initial checked status.
58
- (0, _element.useEffect)(() => {
65
+ //
66
+ // This is performed in a layout effect to ensure that the panel item
67
+ // is registered before it is rendered preventing a rendering glitch.
68
+ // See: https://github.com/WordPress/gutenberg/issues/56470
69
+ (0, _element.useLayoutEffect)(() => {
59
70
  if (hasMatchingPanel && previousPanelId !== null) {
60
71
  registerPanelItem({
61
72
  hasValue: hasValueCallback,
@@ -92,19 +103,12 @@ function useToolsPanelItem(props) {
92
103
  const newValueSet = isValueSet && !wasValueSet;
93
104
 
94
105
  // Notify the panel when an item's value has been set.
95
- //
96
- // 1. For default controls, this is so "reset" appears beside its menu item.
97
- // 2. For optional controls, when the panel ID is `null`, it allows the
98
- // panel to ensure the item is toggled on for display in the menu, given the
99
- // value has been set external to the control.
100
106
  (0, _element.useEffect)(() => {
101
107
  if (!newValueSet) {
102
108
  return;
103
109
  }
104
- if (isShownByDefault || currentPanelId === null) {
105
- flagItemCustomization(label, menuGroup);
106
- }
107
- }, [currentPanelId, newValueSet, isShownByDefault, menuGroup, label, flagItemCustomization]);
110
+ flagItemCustomization(label, menuGroup);
111
+ }, [newValueSet, menuGroup, label, flagItemCustomization]);
108
112
 
109
113
  // Determine if the panel item's corresponding menu is being toggled and
110
114
  // trigger appropriate callback if it is.
@@ -1 +1 @@
1
- {"version":3,"names":["_compose","require","_element","styles","_interopRequireWildcard","_context","_context2","_useCx","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","noop","useToolsPanelItem","props","className","hasValue","isShownByDefault","label","panelId","resetAllFilter","onDeselect","onSelect","otherProps","useContextSystem","currentPanelId","menuItems","registerResetAllFilter","deregisterResetAllFilter","registerPanelItem","deregisterPanelItem","flagItemCustomization","isResetting","shouldRenderPlaceholderItems","shouldRenderPlaceholder","firstDisplayedItem","lastDisplayedItem","__experimentalFirstVisibleItemClass","__experimentalLastVisibleItemClass","useToolsPanelContext","hasValueCallback","useCallback","resetAllFilterCallback","previousPanelId","usePrevious","hasMatchingPanel","useEffect","menuGroup","isMenuItemChecked","wasMenuItemChecked","isRegistered","undefined","isValueSet","wasValueSet","newValueSet","isShown","cx","useCx","classes","useMemo","shouldApplyPlaceholderStyles","firstItemStyle","lastItemStyle","ToolsPanelItem","ToolsPanelItemPlaceholder"],"sources":["@wordpress/components/src/tools-panel/tools-panel-item/hook.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { usePrevious } from '@wordpress/compose';\nimport { useCallback, useEffect, useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport * as styles from '../styles';\nimport { useToolsPanelContext } from '../context';\nimport type { WordPressComponentProps } from '../../context';\nimport { useContextSystem } from '../../context';\nimport { useCx } from '../../utils/hooks/use-cx';\nimport type { ToolsPanelItemProps } from '../types';\n\nconst noop = () => {};\n\nexport function useToolsPanelItem(\n\tprops: WordPressComponentProps< ToolsPanelItemProps, 'div' >\n) {\n\tconst {\n\t\tclassName,\n\t\thasValue,\n\t\tisShownByDefault = false,\n\t\tlabel,\n\t\tpanelId,\n\t\tresetAllFilter = noop,\n\t\tonDeselect,\n\t\tonSelect,\n\t\t...otherProps\n\t} = useContextSystem( props, 'ToolsPanelItem' );\n\n\tconst {\n\t\tpanelId: currentPanelId,\n\t\tmenuItems,\n\t\tregisterResetAllFilter,\n\t\tderegisterResetAllFilter,\n\t\tregisterPanelItem,\n\t\tderegisterPanelItem,\n\t\tflagItemCustomization,\n\t\tisResetting,\n\t\tshouldRenderPlaceholderItems: shouldRenderPlaceholder,\n\t\tfirstDisplayedItem,\n\t\tlastDisplayedItem,\n\t\t__experimentalFirstVisibleItemClass,\n\t\t__experimentalLastVisibleItemClass,\n\t} = useToolsPanelContext();\n\n\tconst hasValueCallback = useCallback( hasValue, [ panelId, hasValue ] );\n\tconst resetAllFilterCallback = useCallback( resetAllFilter, [\n\t\tpanelId,\n\t\tresetAllFilter,\n\t] );\n\tconst previousPanelId = usePrevious( currentPanelId );\n\n\tconst hasMatchingPanel =\n\t\tcurrentPanelId === panelId || currentPanelId === null;\n\n\t// Registering the panel item allows the panel to include it in its\n\t// automatically generated menu and determine its initial checked status.\n\tuseEffect( () => {\n\t\tif ( hasMatchingPanel && previousPanelId !== null ) {\n\t\t\tregisterPanelItem( {\n\t\t\t\thasValue: hasValueCallback,\n\t\t\t\tisShownByDefault,\n\t\t\t\tlabel,\n\t\t\t\tpanelId,\n\t\t\t} );\n\t\t}\n\n\t\treturn () => {\n\t\t\tif (\n\t\t\t\t( previousPanelId === null && !! currentPanelId ) ||\n\t\t\t\tcurrentPanelId === panelId\n\t\t\t) {\n\t\t\t\tderegisterPanelItem( label );\n\t\t\t}\n\t\t};\n\t}, [\n\t\tcurrentPanelId,\n\t\thasMatchingPanel,\n\t\tisShownByDefault,\n\t\tlabel,\n\t\thasValueCallback,\n\t\tpanelId,\n\t\tpreviousPanelId,\n\t\tregisterPanelItem,\n\t\tderegisterPanelItem,\n\t] );\n\n\tuseEffect( () => {\n\t\tif ( hasMatchingPanel ) {\n\t\t\tregisterResetAllFilter( resetAllFilterCallback );\n\t\t}\n\t\treturn () => {\n\t\t\tif ( hasMatchingPanel ) {\n\t\t\t\tderegisterResetAllFilter( resetAllFilterCallback );\n\t\t\t}\n\t\t};\n\t}, [\n\t\tregisterResetAllFilter,\n\t\tderegisterResetAllFilter,\n\t\tresetAllFilterCallback,\n\t\thasMatchingPanel,\n\t] );\n\n\t// Note: `label` is used as a key when building menu item state in\n\t// `ToolsPanel`.\n\tconst menuGroup = isShownByDefault ? 'default' : 'optional';\n\tconst isMenuItemChecked = menuItems?.[ menuGroup ]?.[ label ];\n\tconst wasMenuItemChecked = usePrevious( isMenuItemChecked );\n\tconst isRegistered = menuItems?.[ menuGroup ]?.[ label ] !== undefined;\n\n\tconst isValueSet = hasValue();\n\tconst wasValueSet = usePrevious( isValueSet );\n\tconst newValueSet = isValueSet && ! wasValueSet;\n\n\t// Notify the panel when an item's value has been set.\n\t//\n\t// 1. For default controls, this is so \"reset\" appears beside its menu item.\n\t// 2. For optional controls, when the panel ID is `null`, it allows the\n\t// panel to ensure the item is toggled on for display in the menu, given the\n\t// value has been set external to the control.\n\tuseEffect( () => {\n\t\tif ( ! newValueSet ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( isShownByDefault || currentPanelId === null ) {\n\t\t\tflagItemCustomization( label, menuGroup );\n\t\t}\n\t}, [\n\t\tcurrentPanelId,\n\t\tnewValueSet,\n\t\tisShownByDefault,\n\t\tmenuGroup,\n\t\tlabel,\n\t\tflagItemCustomization,\n\t] );\n\n\t// Determine if the panel item's corresponding menu is being toggled and\n\t// trigger appropriate callback if it is.\n\tuseEffect( () => {\n\t\t// We check whether this item is currently registered as items rendered\n\t\t// via fills can persist through the parent panel being remounted.\n\t\t// See: https://github.com/WordPress/gutenberg/pull/45673\n\t\tif ( ! isRegistered || isResetting || ! hasMatchingPanel ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( isMenuItemChecked && ! isValueSet && ! wasMenuItemChecked ) {\n\t\t\tonSelect?.();\n\t\t}\n\n\t\tif ( ! isMenuItemChecked && wasMenuItemChecked ) {\n\t\t\tonDeselect?.();\n\t\t}\n\t}, [\n\t\thasMatchingPanel,\n\t\tisMenuItemChecked,\n\t\tisRegistered,\n\t\tisResetting,\n\t\tisValueSet,\n\t\twasMenuItemChecked,\n\t\tonSelect,\n\t\tonDeselect,\n\t] );\n\n\t// The item is shown if it is a default control regardless of whether it\n\t// has a value. Optional items are shown when they are checked or have\n\t// a value.\n\tconst isShown = isShownByDefault\n\t\t? menuItems?.[ menuGroup ]?.[ label ] !== undefined\n\t\t: isMenuItemChecked;\n\n\tconst cx = useCx();\n\tconst classes = useMemo( () => {\n\t\tconst shouldApplyPlaceholderStyles =\n\t\t\tshouldRenderPlaceholder && ! isShown;\n\t\tconst firstItemStyle =\n\t\t\tfirstDisplayedItem === label && __experimentalFirstVisibleItemClass;\n\t\tconst lastItemStyle =\n\t\t\tlastDisplayedItem === label && __experimentalLastVisibleItemClass;\n\t\treturn cx(\n\t\t\tstyles.ToolsPanelItem,\n\t\t\tshouldApplyPlaceholderStyles && styles.ToolsPanelItemPlaceholder,\n\t\t\t! shouldApplyPlaceholderStyles && className,\n\t\t\tfirstItemStyle,\n\t\t\tlastItemStyle\n\t\t);\n\t}, [\n\t\tisShown,\n\t\tshouldRenderPlaceholder,\n\t\tclassName,\n\t\tcx,\n\t\tfirstDisplayedItem,\n\t\tlastDisplayedItem,\n\t\t__experimentalFirstVisibleItemClass,\n\t\t__experimentalLastVisibleItemClass,\n\t\tlabel,\n\t] );\n\n\treturn {\n\t\t...otherProps,\n\t\tisShown,\n\t\tshouldRenderPlaceholder,\n\t\tclassName: classes,\n\t};\n}\n"],"mapp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C3C8C,cAAc,EACdC,aACD,CAAC;EACF,CAAC,EAAE,CACFP,OAAO,EACPrB,uBAAuB,EACvBnB,SAAS,EACTyC,EAAE,EACFrB,kBAAkB,EAClBC,iBAAiB,EACjBC,mCAAmC,EACnCC,kCAAkC,EAClCpB,KAAK,CACJ,CAAC;EAEH,OAAO;IACN,GAAGK,UAAU;IACbgC,OAAO;IACPrB,uBAAuB;IACvBnB,SAAS,EAAE2C;EACZ,CAAC;AACF"}
1
+ {"version":3,"names":["_compose","require","_element","styles","_interopRequireWildcard","_context","_context2","_useCx","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","noop","useToolsPanelItem","props","className","hasValue","isShownByDefault","label","panelId","resetAllFilter","onDeselect","onSelect","otherProps","useContextSystem","currentPanelId","menuItems","registerResetAllFilter","deregisterResetAllFilter","registerPanelItem","deregisterPanelItem","flagItemCustomization","isResetting","shouldRenderPlaceholderItems","shouldRenderPlaceholder","firstDisplayedItem","lastDisplayedItem","__experimentalFirstVisibleItemClass","__experimentalLastVisibleItemClass","useToolsPanelContext","hasValueCallback","useCallback","resetAllFilterCallback","previousPanelId","usePrevious","hasMatchingPanel","useLayoutEffect","useEffect","menuGroup","isMenuItemChecked","wasMenuItemChecked","isRegistered","undefined","isValueSet","wasValueSet","newValueSet","isShown","cx","useCx","classes","useMemo","shouldApplyPlaceholderStyles","firstItemStyle","lastItemStyle","ToolsPanelItem","ToolsPanelItemPlaceholder"],"sources":["@wordpress/components/src/tools-panel/tools-panel-item/hook.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { usePrevious } from '@wordpress/compose';\nimport {\n\tuseCallback,\n\tuseEffect,\n\tuseLayoutEffect,\n\tuseMemo,\n} from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport * as styles from '../styles';\nimport { useToolsPanelContext } from '../context';\nimport type { WordPressComponentProps } from '../../context';\nimport { useContextSystem } from '../../context';\nimport { useCx } from '../../utils/hooks/use-cx';\nimport type { ToolsPanelItemProps } from '../types';\n\nconst noop = () => {};\n\nexport function useToolsPanelItem(\n\tprops: WordPressComponentProps< ToolsPanelItemProps, 'div' >\n) {\n\tconst {\n\t\tclassName,\n\t\thasValue,\n\t\tisShownByDefault = false,\n\t\tlabel,\n\t\tpanelId,\n\t\tresetAllFilter = noop,\n\t\tonDeselect,\n\t\tonSelect,\n\t\t...otherProps\n\t} = useContextSystem( props, 'ToolsPanelItem' );\n\n\tconst {\n\t\tpanelId: currentPanelId,\n\t\tmenuItems,\n\t\tregisterResetAllFilter,\n\t\tderegisterResetAllFilter,\n\t\tregisterPanelItem,\n\t\tderegisterPanelItem,\n\t\tflagItemCustomization,\n\t\tisResetting,\n\t\tshouldRenderPlaceholderItems: shouldRenderPlaceholder,\n\t\tfirstDisplayedItem,\n\t\tlastDisplayedItem,\n\t\t__experimentalFirstVisibleItemClass,\n\t\t__experimentalLastVisibleItemClass,\n\t} = useToolsPanelContext();\n\n\t// hasValue is a new function on every render, so do not add it as a\n\t// dependency to the useCallback hook! If needed, we should use a ref.\n\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\tconst hasValueCallback = useCallback( hasValue, [ panelId ] );\n\t// resetAllFilter is a new function on every render, so do not add it as a\n\t// dependency to the useCallback hook! If needed, we should use a ref.\n\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\tconst resetAllFilterCallback = useCallback( resetAllFilter, [ panelId ] );\n\tconst previousPanelId = usePrevious( currentPanelId );\n\n\tconst hasMatchingPanel =\n\t\tcurrentPanelId === panelId || currentPanelId === null;\n\n\t// Registering the panel item allows the panel to include it in its\n\t// automatically generated menu and determine its initial checked status.\n\t//\n\t// This is performed in a layout effect to ensure that the panel item\n\t// is registered before it is rendered preventing a rendering glitch.\n\t// See: https://github.com/WordPress/gutenberg/issues/56470\n\tuseLayoutEffect( () => {\n\t\tif ( hasMatchingPanel && previousPanelId !== null ) {\n\t\t\tregisterPanelItem( {\n\t\t\t\thasValue: hasValueCallback,\n\t\t\t\tisShownByDefault,\n\t\t\t\tlabel,\n\t\t\t\tpanelId,\n\t\t\t} );\n\t\t}\n\n\t\treturn () => {\n\t\t\tif (\n\t\t\t\t( previousPanelId === null && !! currentPanelId ) ||\n\t\t\t\tcurrentPanelId === panelId\n\t\t\t) {\n\t\t\t\tderegisterPanelItem( label );\n\t\t\t}\n\t\t};\n\t}, [\n\t\tcurrentPanelId,\n\t\thasMatchingPanel,\n\t\tisShownByDefault,\n\t\tlabel,\n\t\thasValueCallback,\n\t\tpanelId,\n\t\tpreviousPanelId,\n\t\tregisterPanelItem,\n\t\tderegisterPanelItem,\n\t] );\n\n\tuseEffect( () => {\n\t\tif ( hasMatchingPanel ) {\n\t\t\tregisterResetAllFilter( resetAllFilterCallback );\n\t\t}\n\t\treturn () => {\n\t\t\tif ( hasMatchingPanel ) {\n\t\t\t\tderegisterResetAllFilter( resetAllFilterCallback );\n\t\t\t}\n\t\t};\n\t}, [\n\t\tregisterResetAllFilter,\n\t\tderegisterResetAllFilter,\n\t\tresetAllFilterCallback,\n\t\thasMatchingPanel,\n\t] );\n\n\t// Note: `label` is used as a key when building menu item state in\n\t// `ToolsPanel`.\n\tconst menuGroup = isShownByDefault ? 'default' : 'optional';\n\tconst isMenuItemChecked = menuItems?.[ menuGroup ]?.[ label ];\n\tconst wasMenuItemChecked = usePrevious( isMenuItemChecked );\n\tconst isRegistered = menuItems?.[ menuGroup ]?.[ label ] !== undefined;\n\n\tconst isValueSet = hasValue();\n\tconst wasValueSet = usePrevious( isValueSet );\n\tconst newValueSet = isValueSet && ! wasValueSet;\n\n\t// Notify the panel when an item's value has been set.\n\tuseEffect( () => {\n\t\tif ( ! newValueSet ) {\n\t\t\treturn;\n\t\t}\n\n\t\tflagItemCustomization( label, menuGroup );\n\t}, [ newValueSet, menuGroup, label, flagItemCustomization ] );\n\n\t// Determine if the panel item's corresponding menu is being toggled and\n\t// trigger appropriate callback if it is.\n\tuseEffect( () => {\n\t\t// We check whether this item is currently registered as items rendered\n\t\t// via fills can persist through the parent panel being remounted.\n\t\t// See: https://github.com/WordPress/gutenberg/pull/45673\n\t\tif ( ! isRegistered || isResetting || ! hasMatchingPanel ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( isMenuItemChecked && ! isValueSet && ! wasMenuItemChecked ) {\n\t\t\tonSelect?.();\n\t\t}\n\n\t\tif ( ! isMenuItemChecked && wasMenuItemChecked ) {\n\t\t\tonDeselect?.();\n\t\t}\n\t}, [\n\t\thasMatchingPanel,\n\t\tisMenuItemChecked,\n\t\tisRegistered,\n\t\tisResetting,\n\t\tisValueSet,\n\t\twasMenuItemChecked,\n\t\tonSelect,\n\t\tonDeselect,\n\t] );\n\n\t// The item is shown if it is a default control regardless of whether it\n\t// has a value. Optional items are shown when they are checked or have\n\t// a value.\n\tconst isShown = isShownByDefault\n\t\t? menuItems?.[ menuGroup ]?.[ label ] !== undefined\n\t\t: isMenuItemChecked;\n\n\tconst cx = useCx();\n\tconst classes = useMemo( () => {\n\t\tconst shouldApplyPlaceholderStyles =\n\t\t\tshouldRenderPlaceholder && ! isShown;\n\t\tconst firstItemStyle =\n\t\t\tfirstDisplayedItem === label && __experimentalFirstVisibleItemClass;\n\t\tconst lastItemStyle =\n\t\t\tlastDisplayedItem === label && __experimentalLastVisibleItemClass;\n\t\treturn cx(\n\t\t\tstyles.ToolsPanelItem,\n\t\t\tshouldApplyPlaceholderStyles && styles.ToolsPanelItemPlaceholder,\n\t\t\t! shouldApplyPlaceholderStyles && className,\n\t\t\tfirstItemStyle,\n\t\t\tlastItemStyle\n\t\t);\n\t}, [\n\t\tisShown,\n\t\tshouldRenderPlaceholder,\n\t\tclassName,\n\t\tcx,\n\t\tfirstDisplayedItem,\n\t\tlastDisplayedItem,\n\t\t__experimentalFirstVisibleItemClass,\n\t\t__experimentalLastVisibleItemClass,\n\t\tlabel,\n\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,SAAS,EAC3C+C,cAAc,EACdC,aACD,CAAC;EACF,CAAC,EAAE,CACFP,OAAO,EACPtB,uBAAuB,EACvBnB,SAAS,EACT0C,EAAE,EACFtB,kBAAkB,EAClBC,iBAAiB,EACjBC,mCAAmC,EACnCC,kCAAkC,EAClCpB,KAAK,CACJ,CAAC;EAEH,OAAO;IACN,GAAGK,UAAU;IACbiC,OAAO;IACPtB,uBAAuB;IACvBnB,SAAS,EAAE4C;EACZ,CAAC;AACF"}
@@ -32,7 +32,6 @@ function UnforwardedAnglePickerControl(props, ref) {
32
32
  if (!__nextHasNoMarginBottom) {
33
33
  deprecated('Bottom margin styles for wp.components.AnglePickerControl', {
34
34
  since: '6.1',
35
- version: '6.4',
36
35
  hint: 'Set the `__nextHasNoMarginBottom` prop to true to start opting into the new styles, which will become the default in a future version.'
37
36
  });
38
37
  }
@@ -1 +1 @@
1
- {"version":3,"names":["classnames","deprecated","forwardRef","isRTL","__","FlexBlock","Spacer","NumberControl","AngleCircle","Root","UnitText","UnforwardedAnglePickerControl","props","ref","__nextHasNoMarginBottom","className","label","onChange","value","restProps","since","version","hint","handleOnNumberChange","unprocessedValue","undefined","inputValue","parseInt","classes","unitText","createElement","prefixedUnitText","suffixedUnitText","gap","max","min","size","step","spinControls","prefix","suffix","marginBottom","marginTop","AnglePickerControl"],"sources":["@wordpress/components/src/angle-picker-control/index.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { ForwardedRef } from 'react';\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport deprecated from '@wordpress/deprecated';\nimport { forwardRef } from '@wordpress/element';\nimport { isRTL, __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { FlexBlock } from '../flex';\nimport { Spacer } from '../spacer';\nimport NumberControl from '../number-control';\nimport AngleCircle from './angle-circle';\nimport { Root, UnitText } from './styles/angle-picker-control-styles';\n\nimport type { WordPressComponentProps } from '../context';\nimport type { AnglePickerControlProps } from './types';\n\nfunction UnforwardedAnglePickerControl(\n\tprops: WordPressComponentProps< AnglePickerControlProps, 'div' >,\n\tref: ForwardedRef< any >\n) {\n\tconst {\n\t\t__nextHasNoMarginBottom = false,\n\t\tclassName,\n\t\tlabel = __( 'Angle' ),\n\t\tonChange,\n\t\tvalue,\n\t\t...restProps\n\t} = props;\n\n\tif ( ! __nextHasNoMarginBottom ) {\n\t\tdeprecated(\n\t\t\t'Bottom margin styles for wp.components.AnglePickerControl',\n\t\t\t{\n\t\t\t\tsince: '6.1',\n\t\t\t\tversion: '6.4',\n\t\t\t\thint: 'Set the `__nextHasNoMarginBottom` prop to true to start opting into the new styles, which will become the default in a future version.',\n\t\t\t}\n\t\t);\n\t}\n\n\tconst handleOnNumberChange = ( unprocessedValue: string | undefined ) => {\n\t\tif ( onChange === undefined ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst inputValue =\n\t\t\tunprocessedValue !== undefined && unprocessedValue !== ''\n\t\t\t\t? parseInt( unprocessedValue, 10 )\n\t\t\t\t: 0;\n\t\tonChange( inputValue );\n\t};\n\n\tconst classes = classnames( 'components-angle-picker-control', className );\n\n\tconst unitText = <UnitText>°</UnitText>;\n\tconst [ prefixedUnitText, suffixedUnitText ] = isRTL()\n\t\t? [ unitText, null ]\n\t\t: [ null, unitText ];\n\n\treturn (\n\t\t<Root\n\t\t\t{ ...restProps }\n\t\t\tref={ ref }\n\t\t\t__nextHasNoMarginBottom={ __nextHasNoMarginBottom }\n\t\t\tclassName={ classes }\n\t\t\tgap={ 2 }\n\t\t>\n\t\t\t<FlexBlock>\n\t\t\t\t<NumberControl\n\t\t\t\t\tlabel={ label }\n\t\t\t\t\tclassName=\"components-angle-picker-control__input-field\"\n\t\t\t\t\tmax={ 360 }\n\t\t\t\t\tmin={ 0 }\n\t\t\t\t\tonChange={ handleOnNumberChange }\n\t\t\t\t\tsize=\"__unstable-large\"\n\t\t\t\t\tstep=\"1\"\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\tspinControls=\"none\"\n\t\t\t\t\tprefix={ prefixedUnitText }\n\t\t\t\t\tsuffix={ suffixedUnitText }\n\t\t\t\t/>\n\t\t\t</FlexBlock>\n\t\t\t<Spacer marginBottom=\"1\" marginTop=\"auto\">\n\t\t\t\t<AngleCircle\n\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t/>\n\t\t\t</Spacer>\n\t\t</Root>\n\t);\n}\n\n/**\n * `AnglePickerControl` is a React component to render a UI that allows users to\n * pick an angle. Users can choose an angle in a visual UI with the mouse by\n * dragging an angle indicator inside a circle or by directly inserting the\n * desired angle in a text field.\n *\n * ```jsx\n * import { useState } from '@wordpress/element';\n * import { AnglePickerControl } from '@wordpress/components';\n *\n * function Example() {\n * const [ angle, setAngle ] = useState( 0 );\n * return (\n * <AnglePickerControl\n * value={ angle }\n * onChange={ setAngle }\n * __nextHasNoMarginBottom\n * </>\n * );\n * }\n * ```\n */\nexport const AnglePickerControl = forwardRef( UnforwardedAnglePickerControl );\n\nexport default AnglePickerControl;\n"],"mappings":";AAAA;AACA;AACA;;AAEA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,OAAOC,UAAU,MAAM,uBAAuB;AAC9C,SAASC,UAAU,QAAQ,oBAAoB;AAC/C,SAASC,KAAK,EAAEC,EAAE,QAAQ,iBAAiB;;AAE3C;AACA;AACA;AACA,SAASC,SAAS,QAAQ,SAAS;AACnC,SAASC,MAAM,QAAQ,WAAW;AAClC,OAAOC,aAAa,MAAM,mBAAmB;AAC7C,OAAOC,WAAW,MAAM,gBAAgB;AACxC,SAASC,IAAI,EAAEC,QAAQ,QAAQ,sCAAsC;AAKrE,SAASC,6BAA6BA,CACrCC,KAAgE,EAChEC,GAAwB,EACvB;EACD,MAAM;IACLC,uBAAuB,GAAG,KAAK;IAC/BC,SAAS;IACTC,KAAK,GAAGZ,EAAE,CAAE,OAAQ,CAAC;IACrBa,QAAQ;IACRC,KAA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3BS,MAAM,EAAGR;EAAkB,CAC3B,CACS,CAAC,EACZF,aAAA,CAACxB,MAAM;IAACmC,YAAY,EAAC,GAAG;IAACC,SAAS,EAAC;EAAM,GACxCZ,aAAA,CAACtB,WAAW;IACX,eAAY,MAAM;IAClBU,KAAK,EAAGA,KAAO;IACfD,QAAQ,EAAGA;EAAU,CACrB,CACM,CACH,CAAC;AAET;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAM0B,kBAAkB,GAAGzC,UAAU,CAAES,6BAA8B,CAAC;AAE7E,eAAegC,kBAAkB"}
1
+ {"version":3,"names":["classnames","deprecated","forwardRef","isRTL","__","FlexBlock","Spacer","NumberControl","AngleCircle","Root","UnitText","UnforwardedAnglePickerControl","props","ref","__nextHasNoMarginBottom","className","label","onChange","value","restProps","since","hint","handleOnNumberChange","unprocessedValue","undefined","inputValue","parseInt","classes","unitText","createElement","prefixedUnitText","suffixedUnitText","gap","max","min","size","step","spinControls","prefix","suffix","marginBottom","marginTop","AnglePickerControl"],"sources":["@wordpress/components/src/angle-picker-control/index.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { ForwardedRef } from 'react';\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport deprecated from '@wordpress/deprecated';\nimport { forwardRef } from '@wordpress/element';\nimport { isRTL, __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { FlexBlock } from '../flex';\nimport { Spacer } from '../spacer';\nimport NumberControl from '../number-control';\nimport AngleCircle from './angle-circle';\nimport { Root, UnitText } from './styles/angle-picker-control-styles';\n\nimport type { WordPressComponentProps } from '../context';\nimport type { AnglePickerControlProps } from './types';\n\nfunction UnforwardedAnglePickerControl(\n\tprops: WordPressComponentProps< AnglePickerControlProps, 'div' >,\n\tref: ForwardedRef< any >\n) {\n\tconst {\n\t\t__nextHasNoMarginBottom = false,\n\t\tclassName,\n\t\tlabel = __( 'Angle' ),\n\t\tonChange,\n\t\tvalue,\n\t\t...restProps\n\t} = props;\n\n\tif ( ! __nextHasNoMarginBottom ) {\n\t\tdeprecated(\n\t\t\t'Bottom margin styles for wp.components.AnglePickerControl',\n\t\t\t{\n\t\t\t\tsince: '6.1',\n\t\t\t\thint: 'Set the `__nextHasNoMarginBottom` prop to true to start opting into the new styles, which will become the default in a future version.',\n\t\t\t}\n\t\t);\n\t}\n\n\tconst handleOnNumberChange = ( unprocessedValue: string | undefined ) => {\n\t\tif ( onChange === undefined ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst inputValue =\n\t\t\tunprocessedValue !== undefined && unprocessedValue !== ''\n\t\t\t\t? parseInt( unprocessedValue, 10 )\n\t\t\t\t: 0;\n\t\tonChange( inputValue );\n\t};\n\n\tconst classes = classnames( 'components-angle-picker-control', className );\n\n\tconst unitText = <UnitText>°</UnitText>;\n\tconst [ prefixedUnitText, suffixedUnitText ] = isRTL()\n\t\t? [ unitText, null ]\n\t\t: [ null, unitText ];\n\n\treturn (\n\t\t<Root\n\t\t\t{ ...restProps }\n\t\t\tref={ ref }\n\t\t\t__nextHasNoMarginBottom={ __nextHasNoMarginBottom }\n\t\t\tclassName={ classes }\n\t\t\tgap={ 2 }\n\t\t>\n\t\t\t<FlexBlock>\n\t\t\t\t<NumberControl\n\t\t\t\t\tlabel={ label }\n\t\t\t\t\tclassName=\"components-angle-picker-control__input-field\"\n\t\t\t\t\tmax={ 360 }\n\t\t\t\t\tmin={ 0 }\n\t\t\t\t\tonChange={ handleOnNumberChange }\n\t\t\t\t\tsize=\"__unstable-large\"\n\t\t\t\t\tstep=\"1\"\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\tspinControls=\"none\"\n\t\t\t\t\tprefix={ prefixedUnitText }\n\t\t\t\t\tsuffix={ suffixedUnitText }\n\t\t\t\t/>\n\t\t\t</FlexBlock>\n\t\t\t<Spacer marginBottom=\"1\" marginTop=\"auto\">\n\t\t\t\t<AngleCircle\n\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t/>\n\t\t\t</Spacer>\n\t\t</Root>\n\t);\n}\n\n/**\n * `AnglePickerControl` is a React component to render a UI that allows users to\n * pick an angle. Users can choose an angle in a visual UI with the mouse by\n * dragging an angle indicator inside a circle or by directly inserting the\n * desired angle in a text field.\n *\n * ```jsx\n * import { useState } from '@wordpress/element';\n * import { AnglePickerControl } from '@wordpress/components';\n *\n * function Example() {\n * const [ angle, setAngle ] = useState( 0 );\n * return (\n * <AnglePickerControl\n * value={ angle }\n * onChange={ setAngle }\n * __nextHasNoMarginBottom\n * </>\n * );\n * }\n * ```\n */\nexport const AnglePickerControl = forwardRef( UnforwardedAnglePickerControl );\n\nexport default AnglePickerControl;\n"],"mappings":";AAAA;AACA;AACA;;AAEA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,OAAOC,UAAU,MAAM,uBAAuB;AAC9C,SAASC,UAAU,QAAQ,oBAAoB;AAC/C,SAASC,KAAK,EAAEC,EAAE,QAAQ,iBAAiB;;AAE3C;AACA;AACA;AACA,SAASC,SAAS,QAAQ,SAAS;AACnC,SAASC,MAAM,QAAQ,WAAW;AAClC,OAAOC,aAAa,MAAM,mBAAmB;AAC7C,OAAOC,WAAW,MAAM,gBAAgB;AACxC,SAASC,IAAI,EAAEC,QAAQ,QAAQ,sCAAsC;AAKrE,SAASC,6BAA6BA,CACrCC,KAAgE,EAChEC,GAAwB,EACvB;EACD,MAAM;IACLC,uBAAuB,GAAG,KAAK;IAC/BC,SAAS;IACTC,KAAK,GAAGZ,EAAE,CAAE,OAAQ,CAAC;IACrBa,QAAQ;IACRC,KAAK;IACL,GAAGC;EACJ,CAAC,GAAGP,KAAK;EAET,IAAK,CAAEE,uBAAuB,EAAG;IAChCb,UAAU,CACT,2DAA2D,EAC3D;MACCmB,KAAK,EAAE,KAAK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AY,MAAM;IAClBU,KAAK,EAAGA,KAAO;IACfD,QAAQ,EAAGA;EAAU,CACrB,CACM,CACH,CAAC;AAET;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMyB,kBAAkB,GAAGxC,UAAU,CAAES,6BAA8B,CAAC;AAE7E,eAAe+B,kBAAkB"}
@@ -97,6 +97,7 @@ const BorderControlDropdown = (props, forwardedRef) => {
97
97
  popoverControlsClassName,
98
98
  resetButtonClassName,
99
99
  showDropdownHeader,
100
+ size,
100
101
  __unstablePopoverProps,
101
102
  ...otherProps
102
103
  } = useBorderControlDropdown(props);
@@ -116,7 +117,8 @@ const BorderControlDropdown = (props, forwardedRef) => {
116
117
  "aria-label": toggleAriaLabel,
117
118
  tooltipPosition: dropdownPosition,
118
119
  label: __('Border color and style picker'),
119
- showTooltip: true
120
+ showTooltip: true,
121
+ __next40pxDefaultSize: size === '__unstable-large' ? true : false
120
122
  }, createElement("span", {
121
123
  className: indicatorWrapperClassName
122
124
  }, createElement(ColorIndicator, {
@@ -131,7 +133,7 @@ const BorderControlDropdown = (props, forwardedRef) => {
131
133
  className: popoverControlsClassName,
132
134
  spacing: 6
133
135
  }, showDropdownHeader ? createElement(HStack, null, createElement(StyledLabel, null, __('Border color')), createElement(Button, {
134
- isSmall: true,
136
+ size: "small",
135
137
  label: __('Close border color'),
136
138
  icon: closeSmall,
137
139
  onClick: onClose
@@ -1 +1 @@
1
- {"version":3,"names":["__","sprintf","closeSmall","BorderControlStylePicker","Button","ColorIndicator","ColorPalette","Dropdown","HStack","VStack","contextConnect","useBorderControlDropdown","StyledLabel","DropdownContentWrapper","isMultiplePaletteArray","getAriaLabelColorValue","colorValue","replace","getColorObject","colors","matchedColor","some","origin","color","find","getToggleAriaLabel","colorObject","style","isStyleEnabled","ariaLabelValue","name","BorderControlDropdown","props","forwardedRef","__experimentalIsRenderedInSidebar","border","disableCustomColors","enableAlpha","enableStyle","indicatorClassName","indicatorWrapperClassName","onReset","onColorChange","onStyleChange","popoverContentClassName","popoverControlsClassName","resetButtonClassName","showDropdownHeader","__unstablePopoverProps","otherProps","toggleAriaLabel","showResetButton","dropdownPosition","undefined","renderToggle","onToggle","createElement","onClick","variant","tooltipPosition","label","showTooltip","className","renderContent","onClose","Fragment","paddingSize","spacing","isSmall","icon","value","onChange","clearable","popoverProps","ref","ConnectedBorderControlDropdown"],"sources":["@wordpress/components/src/border-control/border-control-dropdown/component.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { CSSProperties } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { closeSmall } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport BorderControlStylePicker from '../border-control-style-picker';\nimport Button from '../../button';\nimport ColorIndicator from '../../color-indicator';\nimport ColorPalette from '../../color-palette';\nimport Dropdown from '../../dropdown';\nimport { HStack } from '../../h-stack';\nimport { VStack } from '../../v-stack';\nimport type { WordPressComponentProps } from '../../context';\nimport { contextConnect } from '../../context';\nimport { useBorderControlDropdown } from './hook';\nimport { StyledLabel } from '../../base-control/styles/base-control-styles';\nimport DropdownContentWrapper from '../../dropdown/dropdown-content-wrapper';\n\nimport type { ColorObject } from '../../color-palette/types';\nimport { isMultiplePaletteArray } from '../../color-palette/utils';\nimport type { DropdownProps as DropdownComponentProps } from '../../dropdown/types';\nimport type { ColorProps, DropdownProps } from '../types';\n\nconst getAriaLabelColorValue = ( colorValue: string ) => {\n\t// Leave hex values as-is. Remove the `var()` wrapper from CSS vars.\n\treturn colorValue.replace( /^var\\((.+)\\)$/, '$1' );\n};\n\nconst getColorObject = (\n\tcolorValue: CSSProperties[ 'borderColor' ],\n\tcolors: ColorProps[ 'colors' ] | undefined\n) => {\n\tif ( ! colorValue || ! colors ) {\n\t\treturn;\n\t}\n\n\tif ( isMultiplePaletteArray( colors ) ) {\n\t\t// Multiple origins\n\t\tlet matchedColor;\n\n\t\tcolors.some( ( origin ) =>\n\t\t\torigin.colors.some( ( color ) => {\n\t\t\t\tif ( color.color === colorValue ) {\n\t\t\t\t\tmatchedColor = color;\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\n\t\t\t\treturn false;\n\t\t\t} )\n\t\t);\n\n\t\treturn matchedColor;\n\t}\n\n\t// Single origin\n\treturn colors.find( ( color ) => color.color === colorValue );\n};\n\nconst getToggleAriaLabel = (\n\tcolorValue: CSSProperties[ 'borderColor' ],\n\tcolorObject: ColorObject | undefined,\n\tstyle: CSSProperties[ 'borderStyle' ],\n\tisStyleEnabled: boolean\n) => {\n\tif ( isStyleEnabled ) {\n\t\tif ( colorObject ) {\n\t\t\tconst ariaLabelValue = getAriaLabelColorValue( colorObject.color );\n\t\t\treturn style\n\t\t\t\t? sprintf(\n\t\t\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:\". %3$s: The current border style selection e.g. \"solid\".\n\t\t\t\t\t\t'Border color and style picker. The currently selected color is called \"%1$s\" and has a value of \"%2$s\". The currently selected style is \"%3$s\".',\n\t\t\t\t\t\tcolorObject.name,\n\t\t\t\t\t\tariaLabelValue,\n\t\t\t\t\t\tstyle\n\t\t\t\t )\n\t\t\t\t: sprintf(\n\t\t\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\t\t'Border color and style picker. The currently selected color is called \"%1$s\" and has a value of \"%2$s\".',\n\t\t\t\t\t\tcolorObject.name,\n\t\t\t\t\t\tariaLabelValue\n\t\t\t\t );\n\t\t}\n\n\t\tif ( colorValue ) {\n\t\t\tconst ariaLabelValue = getAriaLabelColorValue( colorValue );\n\t\t\treturn style\n\t\t\t\t? sprintf(\n\t\t\t\t\t\t// translators: %1$s: The color's hex code e.g.: \"#f00:\". %2$s: The current border style selection e.g. \"solid\".\n\t\t\t\t\t\t'Border color and style picker. The currently selected color has a value of \"%1$s\". The currently selected style is \"%2$s\".',\n\t\t\t\t\t\tariaLabelValue,\n\t\t\t\t\t\tstyle\n\t\t\t\t )\n\t\t\t\t: sprintf(\n\t\t\t\t\t\t// translators: %1$s: The color's hex code e.g: \"#f00\".\n\t\t\t\t\t\t'Border color and style picker. The currently selected color has a value of \"%1$s\".',\n\t\t\t\t\t\tariaLabelValue\n\t\t\t\t );\n\t\t}\n\n\t\treturn __( 'Border color and style picker.' );\n\t}\n\n\tif ( colorObject ) {\n\t\treturn sprintf(\n\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'Border color picker. The currently selected color is called \"%1$s\" and has a value of \"%2$s\".',\n\t\t\tcolorObject.name,\n\t\t\tgetAriaLabelColorValue( colorObject.color )\n\t\t);\n\t}\n\n\tif ( colorValue ) {\n\t\treturn sprintf(\n\t\t\t// translators: %1$s: The color's hex code e.g: \"#f00\".\n\t\t\t'Border color picker. The currently selected color has a value of \"%1$s\".',\n\t\t\tgetAriaLabelColorValue( colorValue )\n\t\t);\n\t}\n\n\treturn __( 'Border color picker.' );\n};\n\nconst BorderControlDropdown = (\n\tprops: WordPressComponentProps< DropdownProps, 'div' >,\n\tforwardedRef: React.ForwardedRef< any >\n) => {\n\tconst {\n\t\t__experimentalIsRenderedInSidebar,\n\t\tborder,\n\t\tcolors,\n\t\tdisableCustomColors,\n\t\tenableAlpha,\n\t\tenableStyle,\n\t\tindicatorClassName,\n\t\tindicatorWrapperClassName,\n\t\tonReset,\n\t\tonColorChange,\n\t\tonStyleChange,\n\t\tpopoverContentClassName,\n\t\tpopoverControlsClassName,\n\t\tresetButtonClassName,\n\t\tshowDropdownHeader,\n\t\t__unstablePopoverProps,\n\t\t...otherProps\n\t} = useBorderControlDropdown( props );\n\n\tconst { color, style } = border || {};\n\tconst colorObject = getColorObject( color, colors );\n\n\tconst toggleAriaLabel = getToggleAriaLabel(\n\t\tcolor,\n\t\tcolorObject,\n\t\tstyle,\n\t\tenableStyle\n\t);\n\n\tconst showResetButton = color || ( style && style !== 'none' );\n\tconst dropdownPosition = __experimentalIsRenderedInSidebar\n\t\t? 'bottom left'\n\t\t: undefined;\n\n\tconst renderToggle: DropdownComponentProps[ 'renderToggle' ] = ( {\n\t\tonToggle,\n\t} ) => (\n\t\t<Button\n\t\t\tonClick={ onToggle }\n\t\t\tvariant=\"tertiary\"\n\t\t\taria-label={ toggleAriaLabel }\n\t\t\ttooltipPosition={ dropdownPosition }\n\t\t\tlabel={ __( 'Border color and style picker' ) }\n\t\t\tshowTooltip={ true }\n\t\t>\n\t\t\t<span className={ indicatorWrapperClassName }>\n\t\t\t\t<ColorIndicator\n\t\t\t\t\tclassName={ indicatorClassName }\n\t\t\t\t\tcolorValue={ color }\n\t\t\t\t/>\n\t\t\t</span>\n\t\t</Button>\n\t);\n\n\tconst renderContent: DropdownComponentProps[ 'renderContent' ] = ( {\n\t\tonClose,\n\t} ) => (\n\t\t<>\n\t\t\t<DropdownContentWrapper paddingSize=\"medium\">\n\t\t\t\t<VStack className={ popoverControlsClassName } spacing={ 6 }>\n\t\t\t\t\t{ showDropdownHeader ? (\n\t\t\t\t\t\t<HStack>\n\t\t\t\t\t\t\t<StyledLabel>{ __( 'Border color' ) }</StyledLabel>\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\tisSmall\n\t\t\t\t\t\t\t\tlabel={ __( 'Close border color' ) }\n\t\t\t\t\t\t\t\ticon={ closeSmall }\n\t\t\t\t\t\t\t\tonClick={ onClose }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</HStack>\n\t\t\t\t\t) : undefined }\n\t\t\t\t\t<ColorPalette\n\t\t\t\t\t\tclassName={ popoverContentClassName }\n\t\t\t\t\t\tvalue={ color }\n\t\t\t\t\t\tonChange={ onColorChange }\n\t\t\t\t\t\t{ ...{ colors, disableCustomColors } }\n\t\t\t\t\t\t__experimentalIsRenderedInSidebar={\n\t\t\t\t\t\t\t__experimentalIsRenderedInSidebar\n\t\t\t\t\t\t}\n\t\t\t\t\t\tclearable={ false }\n\t\t\t\t\t\tenableAlpha={ enableAlpha }\n\t\t\t\t\t/>\n\t\t\t\t\t{ enableStyle && (\n\t\t\t\t\t\t<BorderControlStylePicker\n\t\t\t\t\t\t\tlabel={ __( 'Style' ) }\n\t\t\t\t\t\t\tvalue={ style }\n\t\t\t\t\t\t\tonChange={ onStyleChange }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</VStack>\n\t\t\t</DropdownContentWrapper>\n\t\t\t{ showResetButton && (\n\t\t\t\t<DropdownContentWrapper paddingSize=\"none\">\n\t\t\t\t\t<Button\n\t\t\t\t\t\tclassName={ resetButtonClassName }\n\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tonReset();\n\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Reset' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</DropdownContentWrapper>\n\t\t\t) }\n\t\t</>\n\t);\n\n\treturn (\n\t\t<Dropdown\n\t\t\trenderToggle={ renderToggle }\n\t\t\trenderContent={ renderContent }\n\t\t\tpopoverProps={ {\n\t\t\t\t...__unstablePopoverProps,\n\t\t\t} }\n\t\t\t{ ...otherProps }\n\t\t\tref={ forwardedRef }\n\t\t/>\n\t);\n};\n\nconst ConnectedBorderControlDropdown = contextConnect(\n\tBorderControlDropdown,\n\t'BorderControlDropdown'\n);\n\nexport default ConnectedBorderControlDropdown;\n"],"mappings":";AAAA;AACA;AACA;;AAGA;AACA;AACA;AACA,SAASA,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASC,UAAU,QAAQ,kBAAkB;;AAE7C;AACA;AACA;AACA,OAAOC,wBAAwB,MAAM,gCAAgC;AACrE,OAAOC,MAAM,MAAM,cAAc;AACjC,OAAOC,cAA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ACrC0B,KAAK,EAAG/C,KAAO;IACfgD,QAAQ,EAAG7B,aAAe;IACnBvB,MAAM;IAAEiB,mBAAmB;IAClCF,iCAAiC,EAChCA,iCACA;IACDsC,SAAS,EAAG,KAAO;IACnBnC,WAAW,EAAGA;EAAa,CAC3B,CAAC,EACAC,WAAW,IACZkB,aAAA,CAACrD,wBAAwB;IACxByD,KAAK,EAAG5D,EAAE,CAAE,OAAQ,CAAG;IACvBsE,KAAK,EAAG3C,KAAO;IACf4C,QAAQ,EAAG5B;EAAe,CAC1B,CAEK,CACe,CAAC,EACvBQ,eAAe,IAChBK,aAAA,CAAC3C,sBAAsB;IAACqD,WAAW,EAAC;EAAM,GACzCV,aAAA,CAACpD,MAAM;IACN0D,SAAS,EAAGhB,oBAAsB;IAClCY,OAAO,EAAC,UAAU;IAClBD,OAAO,EAAGA,CAAA,KAAM;MACfhB,OAAO,CAAC,CAAC;MACTuB,OAAO,CAAC,CAAC;IACV;EAAG,GAEDhE,EAAE,CAAE,OAAQ,CACP,CACe,CAExB,CACF;EAED,OACCwD,aAAA,CAACjD,QAAQ;IACR+C,YAAY,EAAGA,YAAc;IAC7BS,aAAa,EAAGA,aAAe;IAC/BU,YAAY,EAAG;MACd,GAAGzB;IACJ,CAAG;IAAA,GACEC,UAAU;IACfyB,GAAG,EAAGzC;EAAc,CACpB,CAAC;AAEJ,CAAC;AAED,MAAM0C,8BAA8B,GAAGjE,cAAc,CACpDqB,qBAAqB,EACrB,uBACD,CAAC;AAED,eAAe4C,8BAA8B"}
1
+ {"version":3,"names":["__","sprintf","closeSmall","BorderControlStylePicker","Button","ColorIndicator","ColorPalette","Dropdown","HStack","VStack","contextConnect","useBorderControlDropdown","StyledLabel","DropdownContentWrapper","isMultiplePaletteArray","getAriaLabelColorValue","colorValue","replace","getColorObject","colors","matchedColor","some","origin","color","find","getToggleAriaLabel","colorObject","style","isStyleEnabled","ariaLabelValue","name","BorderControlDropdown","props","forwardedRef","__experimentalIsRenderedInSidebar","border","disableCustomColors","enableAlpha","enableStyle","indicatorClassName","indicatorWrapperClassName","onReset","onColorChange","onStyleChange","popoverContentClassName","popoverControlsClassName","resetButtonClassName","showDropdownHeader","size","__unstablePopoverProps","otherProps","toggleAriaLabel","showResetButton","dropdownPosition","undefined","renderToggle","onToggle","createElement","onClick","variant","tooltipPosition","label","showTooltip","__next40pxDefaultSize","className","renderContent","onClose","Fragment","paddingSize","spacing","icon","value","onChange","clearable","popoverProps","ref","ConnectedBorderControlDropdown"],"sources":["@wordpress/components/src/border-control/border-control-dropdown/component.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { CSSProperties } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { closeSmall } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport BorderControlStylePicker from '../border-control-style-picker';\nimport Button from '../../button';\nimport ColorIndicator from '../../color-indicator';\nimport ColorPalette from '../../color-palette';\nimport Dropdown from '../../dropdown';\nimport { HStack } from '../../h-stack';\nimport { VStack } from '../../v-stack';\nimport type { WordPressComponentProps } from '../../context';\nimport { contextConnect } from '../../context';\nimport { useBorderControlDropdown } from './hook';\nimport { StyledLabel } from '../../base-control/styles/base-control-styles';\nimport DropdownContentWrapper from '../../dropdown/dropdown-content-wrapper';\n\nimport type { ColorObject } from '../../color-palette/types';\nimport { isMultiplePaletteArray } from '../../color-palette/utils';\nimport type { DropdownProps as DropdownComponentProps } from '../../dropdown/types';\nimport type { ColorProps, DropdownProps } from '../types';\n\nconst getAriaLabelColorValue = ( colorValue: string ) => {\n\t// Leave hex values as-is. Remove the `var()` wrapper from CSS vars.\n\treturn colorValue.replace( /^var\\((.+)\\)$/, '$1' );\n};\n\nconst getColorObject = (\n\tcolorValue: CSSProperties[ 'borderColor' ],\n\tcolors: ColorProps[ 'colors' ] | undefined\n) => {\n\tif ( ! colorValue || ! colors ) {\n\t\treturn;\n\t}\n\n\tif ( isMultiplePaletteArray( colors ) ) {\n\t\t// Multiple origins\n\t\tlet matchedColor;\n\n\t\tcolors.some( ( origin ) =>\n\t\t\torigin.colors.some( ( color ) => {\n\t\t\t\tif ( color.color === colorValue ) {\n\t\t\t\t\tmatchedColor = color;\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\n\t\t\t\treturn false;\n\t\t\t} )\n\t\t);\n\n\t\treturn matchedColor;\n\t}\n\n\t// Single origin\n\treturn colors.find( ( color ) => color.color === colorValue );\n};\n\nconst getToggleAriaLabel = (\n\tcolorValue: CSSProperties[ 'borderColor' ],\n\tcolorObject: ColorObject | undefined,\n\tstyle: CSSProperties[ 'borderStyle' ],\n\tisStyleEnabled: boolean\n) => {\n\tif ( isStyleEnabled ) {\n\t\tif ( colorObject ) {\n\t\t\tconst ariaLabelValue = getAriaLabelColorValue( colorObject.color );\n\t\t\treturn style\n\t\t\t\t? sprintf(\n\t\t\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:\". %3$s: The current border style selection e.g. \"solid\".\n\t\t\t\t\t\t'Border color and style picker. The currently selected color is called \"%1$s\" and has a value of \"%2$s\". The currently selected style is \"%3$s\".',\n\t\t\t\t\t\tcolorObject.name,\n\t\t\t\t\t\tariaLabelValue,\n\t\t\t\t\t\tstyle\n\t\t\t\t )\n\t\t\t\t: sprintf(\n\t\t\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\t\t'Border color and style picker. The currently selected color is called \"%1$s\" and has a value of \"%2$s\".',\n\t\t\t\t\t\tcolorObject.name,\n\t\t\t\t\t\tariaLabelValue\n\t\t\t\t );\n\t\t}\n\n\t\tif ( colorValue ) {\n\t\t\tconst ariaLabelValue = getAriaLabelColorValue( colorValue );\n\t\t\treturn style\n\t\t\t\t? sprintf(\n\t\t\t\t\t\t// translators: %1$s: The color's hex code e.g.: \"#f00:\". %2$s: The current border style selection e.g. \"solid\".\n\t\t\t\t\t\t'Border color and style picker. The currently selected color has a value of \"%1$s\". The currently selected style is \"%2$s\".',\n\t\t\t\t\t\tariaLabelValue,\n\t\t\t\t\t\tstyle\n\t\t\t\t )\n\t\t\t\t: sprintf(\n\t\t\t\t\t\t// translators: %1$s: The color's hex code e.g: \"#f00\".\n\t\t\t\t\t\t'Border color and style picker. The currently selected color has a value of \"%1$s\".',\n\t\t\t\t\t\tariaLabelValue\n\t\t\t\t );\n\t\t}\n\n\t\treturn __( 'Border color and style picker.' );\n\t}\n\n\tif ( colorObject ) {\n\t\treturn sprintf(\n\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'Border color picker. The currently selected color is called \"%1$s\" and has a value of \"%2$s\".',\n\t\t\tcolorObject.name,\n\t\t\tgetAriaLabelColorValue( colorObject.color )\n\t\t);\n\t}\n\n\tif ( colorValue ) {\n\t\treturn sprintf(\n\t\t\t// translators: %1$s: The color's hex code e.g: \"#f00\".\n\t\t\t'Border color picker. The currently selected color has a value of \"%1$s\".',\n\t\t\tgetAriaLabelColorValue( colorValue )\n\t\t);\n\t}\n\n\treturn __( 'Border color picker.' );\n};\n\nconst BorderControlDropdown = (\n\tprops: WordPressComponentProps< DropdownProps, 'div' >,\n\tforwardedRef: React.ForwardedRef< any >\n) => {\n\tconst {\n\t\t__experimentalIsRenderedInSidebar,\n\t\tborder,\n\t\tcolors,\n\t\tdisableCustomColors,\n\t\tenableAlpha,\n\t\tenableStyle,\n\t\tindicatorClassName,\n\t\tindicatorWrapperClassName,\n\t\tonReset,\n\t\tonColorChange,\n\t\tonStyleChange,\n\t\tpopoverContentClassName,\n\t\tpopoverControlsClassName,\n\t\tresetButtonClassName,\n\t\tshowDropdownHeader,\n\t\tsize,\n\t\t__unstablePopoverProps,\n\t\t...otherProps\n\t} = useBorderControlDropdown( props );\n\n\tconst { color, style } = border || {};\n\tconst colorObject = getColorObject( color, colors );\n\n\tconst toggleAriaLabel = getToggleAriaLabel(\n\t\tcolor,\n\t\tcolorObject,\n\t\tstyle,\n\t\tenableStyle\n\t);\n\n\tconst showResetButton = color || ( style && style !== 'none' );\n\tconst dropdownPosition = __experimentalIsRenderedInSidebar\n\t\t? 'bottom left'\n\t\t: undefined;\n\n\tconst renderToggle: DropdownComponentProps[ 'renderToggle' ] = ( {\n\t\tonToggle,\n\t} ) => (\n\t\t<Button\n\t\t\tonClick={ onToggle }\n\t\t\tvariant=\"tertiary\"\n\t\t\taria-label={ toggleAriaLabel }\n\t\t\ttooltipPosition={ dropdownPosition }\n\t\t\tlabel={ __( 'Border color and style picker' ) }\n\t\t\tshowTooltip={ true }\n\t\t\t__next40pxDefaultSize={ size === '__unstable-large' ? true : false }\n\t\t>\n\t\t\t<span className={ indicatorWrapperClassName }>\n\t\t\t\t<ColorIndicator\n\t\t\t\t\tclassName={ indicatorClassName }\n\t\t\t\t\tcolorValue={ color }\n\t\t\t\t/>\n\t\t\t</span>\n\t\t</Button>\n\t);\n\n\tconst renderContent: DropdownComponentProps[ 'renderContent' ] = ( {\n\t\tonClose,\n\t} ) => (\n\t\t<>\n\t\t\t<DropdownContentWrapper paddingSize=\"medium\">\n\t\t\t\t<VStack className={ popoverControlsClassName } spacing={ 6 }>\n\t\t\t\t\t{ showDropdownHeader ? (\n\t\t\t\t\t\t<HStack>\n\t\t\t\t\t\t\t<StyledLabel>{ __( 'Border color' ) }</StyledLabel>\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t\tlabel={ __( 'Close border color' ) }\n\t\t\t\t\t\t\t\ticon={ closeSmall }\n\t\t\t\t\t\t\t\tonClick={ onClose }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</HStack>\n\t\t\t\t\t) : undefined }\n\t\t\t\t\t<ColorPalette\n\t\t\t\t\t\tclassName={ popoverContentClassName }\n\t\t\t\t\t\tvalue={ color }\n\t\t\t\t\t\tonChange={ onColorChange }\n\t\t\t\t\t\t{ ...{ colors, disableCustomColors } }\n\t\t\t\t\t\t__experimentalIsRenderedInSidebar={\n\t\t\t\t\t\t\t__experimentalIsRenderedInSidebar\n\t\t\t\t\t\t}\n\t\t\t\t\t\tclearable={ false }\n\t\t\t\t\t\tenableAlpha={ enableAlpha }\n\t\t\t\t\t/>\n\t\t\t\t\t{ enableStyle && (\n\t\t\t\t\t\t<BorderControlStylePicker\n\t\t\t\t\t\t\tlabel={ __( 'Style' ) }\n\t\t\t\t\t\t\tvalue={ style }\n\t\t\t\t\t\t\tonChange={ onStyleChange }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</VStack>\n\t\t\t</DropdownContentWrapper>\n\t\t\t{ showResetButton && (\n\t\t\t\t<DropdownContentWrapper paddingSize=\"none\">\n\t\t\t\t\t<Button\n\t\t\t\t\t\tclassName={ resetButtonClassName }\n\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tonReset();\n\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Reset' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</DropdownContentWrapper>\n\t\t\t) }\n\t\t</>\n\t);\n\n\treturn (\n\t\t<Dropdown\n\t\t\trenderToggle={ renderToggle }\n\t\t\trenderContent={ renderContent }\n\t\t\tpopoverProps={ {\n\t\t\t\t...__unstablePopoverProps,\n\t\t\t} }\n\t\t\t{ ...otherProps }\n\t\t\tref={ forwardedRef }\n\t\t/>\n\t);\n};\n\nconst ConnectedBorderControlDropdown = contextConnect(\n\tBorderControlDropdown,\n\t'BorderControlDropdown'\n);\n\nexport default ConnectedBorderControlDropdown;\n"],"mappings":";AAAA;AACA;AACA;;AAGA;AACA;AACA;AACA,SAASA,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASC,UAAU,QAAQ,kBAAkB;;AAE7C;AACA;AACA;AACA,OAAOC,wBAAwB,MAAM,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G;IACpCsE,IAAI,EAAGpE,UAAY;IACnBwD,OAAO,EAAGQ;EAAS,CACnB,CACM,CAAC,GACNZ,SAAS,EACbG,aAAA,CAACnD,YAAY;IACZ0D,SAAS,EAAGpB,uBAAyB;IACrC2B,KAAK,EAAGhD,KAAO;IACfiD,QAAQ,EAAG9B,aAAe;IACnBvB,MAAM;IAAEiB,mBAAmB;IAClCF,iCAAiC,EAChCA,iCACA;IACDuC,SAAS,EAAG,KAAO;IACnBpC,WAAW,EAAGA;EAAa,CAC3B,CAAC,EACAC,WAAW,IACZmB,aAAA,CAACtD,wBAAwB;IACxB0D,KAAK,EAAG7D,EAAE,CAAE,OAAQ,CAAG;IACvBuE,KAAK,EAAG5C,KAAO;IACf6C,QAAQ,EAAG7B;EAAe,CAC1B,CAEK,CACe,CAAC,EACvBS,eAAe,IAChBK,aAAA,CAAC5C,sBAAsB;IAACuD,WAAW,EAAC;EAAM,GACzCX,aAAA,CAACrD,MAAM;IACN4D,SAAS,EAAGlB,oBAAsB;IAClCa,OAAO,EAAC,UAAU;IAClBD,OAAO,EAAGA,CAAA,KAAM;MACfjB,OAAO,CAAC,CAAC;MACTyB,OAAO,CAAC,CAAC;IACV;EAAG,GAEDlE,EAAE,CAAE,OAAQ,CACP,CACe,CAExB,CACF;EAED,OACCyD,aAAA,CAAClD,QAAQ;IACRgD,YAAY,EAAGA,YAAc;IAC7BU,aAAa,EAAGA,aAAe;IAC/BS,YAAY,EAAG;MACd,GAAGzB;IACJ,CAAG;IAAA,GACEC,UAAU;IACfyB,GAAG,EAAG1C;EAAc,CACpB,CAAC;AAEJ,CAAC;AAED,MAAM2C,8BAA8B,GAAGlE,cAAc,CACpDqB,qBAAqB,EACrB,uBACD,CAAC;AAED,eAAe6C,8BAA8B"}
@@ -53,8 +53,8 @@ export function useBorderControlDropdown(props) {
53
53
  // Generate class names.
54
54
  const cx = useCx();
55
55
  const classes = useMemo(() => {
56
- return cx(styles.borderControlDropdown(size), className);
57
- }, [className, cx, size]);
56
+ return cx(styles.borderControlDropdown, className);
57
+ }, [className, cx]);
58
58
  const indicatorClassName = useMemo(() => {
59
59
  return cx(styles.borderColorIndicator);
60
60
  }, [cx]);
@@ -85,6 +85,7 @@ export function useBorderControlDropdown(props) {
85
85
  popoverContentClassName,
86
86
  popoverControlsClassName,
87
87
  resetButtonClassName,
88
+ size,
88
89
  __experimentalIsRenderedInSidebar
89
90
  };
90
91
  }
@@ -1 +1 @@
1
- {"version":3,"names":["useMemo","styles","parseQuantityAndUnitFromRawValue","useContextSystem","useCx","useBorderControlDropdown","props","border","className","colors","enableAlpha","enableStyle","onChange","previousStyleSelection","size","__experimentalIsRenderedInSidebar","otherProps","widthValue","width","hasZeroWidth","onColorChange","color","style","onStyleChange","onReset","undefined","cx","classes","borderControlDropdown","indicatorClassName","borderColorIndicator","indicatorWrapperClassName","colorIndicatorWrapper","popoverControlsClassName","borderControlPopoverControls","popoverContentClassName","borderControlPopoverContent","resetButtonClassName","resetButton"],"sources":["@wordpress/components/src/border-control/border-control-dropdown/hook.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport * as styles from '../styles';\nimport { parseQuantityAndUnitFromRawValue } from '../../unit-control/utils';\nimport type { WordPressComponentProps } from '../../context';\nimport { useContextSystem } from '../../context';\nimport { useCx } from '../../utils/hooks/use-cx';\n\nimport type { DropdownProps } from '../types';\n\nexport function useBorderControlDropdown(\n\tprops: WordPressComponentProps< DropdownProps, 'div' >\n) {\n\tconst {\n\t\tborder,\n\t\tclassName,\n\t\tcolors = [],\n\t\tenableAlpha = false,\n\t\tenableStyle = true,\n\t\tonChange,\n\t\tpreviousStyleSelection,\n\t\tsize = 'default',\n\t\t__experimentalIsRenderedInSidebar = false,\n\t\t...otherProps\n\t} = useContextSystem( props, 'BorderControlDropdown' );\n\n\tconst [ widthValue ] = parseQuantityAndUnitFromRawValue( border?.width );\n\tconst hasZeroWidth = widthValue === 0;\n\n\tconst onColorChange = ( color?: string ) => {\n\t\tconst style =\n\t\t\tborder?.style === 'none' ? previousStyleSelection : border?.style;\n\t\tconst width = hasZeroWidth && !! color ? '1px' : border?.width;\n\n\t\tonChange( { color, style, width } );\n\t};\n\n\tconst onStyleChange = ( style?: string ) => {\n\t\tconst width = hasZeroWidth && !! style ? '1px' : border?.width;\n\t\tonChange( { ...border, style, width } );\n\t};\n\n\tconst onReset = () => {\n\t\tonChange( {\n\t\t\t...border,\n\t\t\tcolor: undefined,\n\t\t\tstyle: undefined,\n\t\t} );\n\t};\n\n\t// Generate class names.\n\tconst cx = useCx();\n\tconst classes = useMemo( () => {\n\t\treturn cx( styles.borderControlDropdown( size ), className );\n\t}, [ className, cx, size ] );\n\n\tconst indicatorClassName = useMemo( () => {\n\t\treturn cx( styles.borderColorIndicator );\n\t}, [ cx ] );\n\n\tconst indicatorWrapperClassName = useMemo( () => {\n\t\treturn cx( styles.colorIndicatorWrapper( border, size ) );\n\t}, [ border, cx, size ] );\n\n\tconst popoverControlsClassName = useMemo( () => {\n\t\treturn cx( styles.borderControlPopoverControls );\n\t}, [ cx ] );\n\n\tconst popoverContentClassName = useMemo( () => {\n\t\treturn cx( styles.borderControlPopoverContent );\n\t}, [ cx ] );\n\n\tconst resetButtonClassName = useMemo( () => {\n\t\treturn cx( styles.resetButton );\n\t}, [ cx ] );\n\n\treturn {\n\t\t...otherProps,\n\t\tborder,\n\t\tclassName: classes,\n\t\tcolors,\n\t\tenableAlpha,\n\t\tenableStyle,\n\t\tindicatorClassName,\n\t\tindicatorWrapperClassName,\n\t\tonColorChange,\n\t\tonStyleChange,\n\t\tonReset,\n\t\tpopoverContentClassName,\n\t\tpopoverControlsClassName,\n\t\tresetButtonClassName,\n\t\t__experimentalIsRenderedInSidebar,\n\t};\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAO,QAAQ,oBAAoB;;AAE5C;AACA;AACA;AACA,OAAO,KAAKC,MAAM,MAAM,WAAW;AACnC,S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IACbG,aAAa;IACbC,OAAO;IACPW,uBAAuB;IACvBF,wBAAwB;IACxBI,oBAAoB;IACpBtB;EACD,CAAC;AACF"}
1
+ {"version":3,"names":["useMemo","styles","parseQuantityAndUnitFromRawValue","useContextSystem","useCx","useBorderControlDropdown","props","border","className","colors","enableAlpha","enableStyle","onChange","previousStyleSelection","size","__experimentalIsRenderedInSidebar","otherProps","widthValue","width","hasZeroWidth","onColorChange","color","style","onStyleChange","onReset","undefined","cx","classes","borderControlDropdown","indicatorClassName","borderColorIndicator","indicatorWrapperClassName","colorIndicatorWrapper","popoverControlsClassName","borderControlPopoverControls","popoverContentClassName","borderControlPopoverContent","resetButtonClassName","resetButton"],"sources":["@wordpress/components/src/border-control/border-control-dropdown/hook.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport * as styles from '../styles';\nimport { parseQuantityAndUnitFromRawValue } from '../../unit-control/utils';\nimport type { WordPressComponentProps } from '../../context';\nimport { useContextSystem } from '../../context';\nimport { useCx } from '../../utils/hooks/use-cx';\n\nimport type { DropdownProps } from '../types';\n\nexport function useBorderControlDropdown(\n\tprops: WordPressComponentProps< DropdownProps, 'div' >\n) {\n\tconst {\n\t\tborder,\n\t\tclassName,\n\t\tcolors = [],\n\t\tenableAlpha = false,\n\t\tenableStyle = true,\n\t\tonChange,\n\t\tpreviousStyleSelection,\n\t\tsize = 'default',\n\t\t__experimentalIsRenderedInSidebar = false,\n\t\t...otherProps\n\t} = useContextSystem( props, 'BorderControlDropdown' );\n\n\tconst [ widthValue ] = parseQuantityAndUnitFromRawValue( border?.width );\n\tconst hasZeroWidth = widthValue === 0;\n\n\tconst onColorChange = ( color?: string ) => {\n\t\tconst style =\n\t\t\tborder?.style === 'none' ? previousStyleSelection : border?.style;\n\t\tconst width = hasZeroWidth && !! color ? '1px' : border?.width;\n\n\t\tonChange( { color, style, width } );\n\t};\n\n\tconst onStyleChange = ( style?: string ) => {\n\t\tconst width = hasZeroWidth && !! style ? '1px' : border?.width;\n\t\tonChange( { ...border, style, width } );\n\t};\n\n\tconst onReset = () => {\n\t\tonChange( {\n\t\t\t...border,\n\t\t\tcolor: undefined,\n\t\t\tstyle: undefined,\n\t\t} );\n\t};\n\n\t// Generate class names.\n\tconst cx = useCx();\n\tconst classes = useMemo( () => {\n\t\treturn cx( styles.borderControlDropdown, className );\n\t}, [ className, cx ] );\n\n\tconst indicatorClassName = useMemo( () => {\n\t\treturn cx( styles.borderColorIndicator );\n\t}, [ cx ] );\n\n\tconst indicatorWrapperClassName = useMemo( () => {\n\t\treturn cx( styles.colorIndicatorWrapper( border, size ) );\n\t}, [ border, cx, size ] );\n\n\tconst popoverControlsClassName = useMemo( () => {\n\t\treturn cx( styles.borderControlPopoverControls );\n\t}, [ cx ] );\n\n\tconst popoverContentClassName = useMemo( () => {\n\t\treturn cx( styles.borderControlPopoverContent );\n\t}, [ cx ] );\n\n\tconst resetButtonClassName = useMemo( () => {\n\t\treturn cx( styles.resetButton );\n\t}, [ cx ] );\n\n\treturn {\n\t\t...otherProps,\n\t\tborder,\n\t\tclassName: classes,\n\t\tcolors,\n\t\tenableAlpha,\n\t\tenableStyle,\n\t\tindicatorClassName,\n\t\tindicatorWrapperClassName,\n\t\tonColorChange,\n\t\tonStyleChange,\n\t\tonReset,\n\t\tpopoverContentClassName,\n\t\tpopoverControlsClassName,\n\t\tresetButtonClassName,\n\t\tsize,\n\t\t__experimentalIsRenderedInSidebar,\n\t};\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAO,QAAQ,oBAAoB;;AAE5C;AACA;AACA;AACA,OAAO,KAAKC,MAAM,MAAM,WAAW;AACnC,SAASC,gCAAgC,QAAQ,0BAA0B;AAE3E,SAASC,gBAAgB,QAAQ,eAAe;AAChD,SAASC,KAAK,QAAQ,0BAA0B;AAIhD,OAAO,SAASC,wBAAwBA,CACvCC,KAAsD,EACrD;EACD,MAAM;IACLC,MAAM;IACNC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