@wordpress/components 25.7.0 → 25.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (630) hide show
  1. package/CHANGELOG.md +66 -1
  2. package/build/animation/index.js +6 -0
  3. package/build/animation/index.js.map +1 -1
  4. package/build/border-control/border-control-dropdown/component.js +1 -1
  5. package/build/border-control/border-control-dropdown/component.js.map +1 -1
  6. package/build/border-control/styles.js +20 -20
  7. package/build/border-control/styles.js.map +1 -1
  8. package/build/box-control/unit-control.js +1 -1
  9. package/build/box-control/unit-control.js.map +1 -1
  10. package/build/button/index.js +9 -1
  11. package/build/button/index.js.map +1 -1
  12. package/build/button/types.js.map +1 -1
  13. package/build/circular-option-picker/circular-option-picker-actions.js +53 -0
  14. package/build/circular-option-picker/circular-option-picker-actions.js.map +1 -0
  15. package/build/circular-option-picker/circular-option-picker-context.js +14 -0
  16. package/build/circular-option-picker/circular-option-picker-context.js.map +1 -0
  17. package/build/circular-option-picker/circular-option-picker-option-group.js +26 -0
  18. package/build/circular-option-picker/circular-option-picker-option-group.js.map +1 -0
  19. package/build/circular-option-picker/circular-option-picker-option.js +122 -0
  20. package/build/circular-option-picker/circular-option-picker-option.js.map +1 -0
  21. package/build/circular-option-picker/circular-option-picker.js +172 -0
  22. package/build/circular-option-picker/circular-option-picker.js.map +1 -0
  23. package/build/circular-option-picker/index.js +29 -137
  24. package/build/circular-option-picker/index.js.map +1 -1
  25. package/build/circular-option-picker/types.js.map +1 -1
  26. package/build/color-palette/index.js +58 -19
  27. package/build/color-palette/index.js.map +1 -1
  28. package/build/color-palette/types.js.map +1 -1
  29. package/build/combobox-control/index.js +0 -3
  30. package/build/combobox-control/index.js.map +1 -1
  31. package/build/composite/index.js.map +1 -1
  32. package/build/custom-gradient-picker/gradient-bar/control-points.js.map +1 -1
  33. package/build/date-time/time/index.js +6 -1
  34. package/build/date-time/time/index.js.map +1 -1
  35. package/build/date-time/time/timezone.js +1 -1
  36. package/build/date-time/time/timezone.js.map +1 -1
  37. package/build/dropdown/index.js +11 -23
  38. package/build/dropdown/index.js.map +1 -1
  39. package/build/dropdown/types.js.map +1 -1
  40. package/build/dropdown-menu/index.js +7 -1
  41. package/build/dropdown-menu/index.js.map +1 -1
  42. package/build/dropdown-menu/types.js.map +1 -1
  43. package/build/dropdown-menu-v2/styles.js +16 -16
  44. package/build/dropdown-menu-v2/styles.js.map +1 -1
  45. package/build/duotone-picker/color-list-picker/index.js +18 -3
  46. package/build/duotone-picker/color-list-picker/index.js.map +1 -1
  47. package/build/duotone-picker/duotone-picker.js +33 -1
  48. package/build/duotone-picker/duotone-picker.js.map +1 -1
  49. package/build/duotone-picker/types.js.map +1 -1
  50. package/build/focusable-iframe/index.js +0 -4
  51. package/build/focusable-iframe/index.js.map +1 -1
  52. package/build/focusable-iframe/types.js +6 -0
  53. package/build/focusable-iframe/types.js.map +1 -0
  54. package/build/form-token-field/index.js +6 -2
  55. package/build/form-token-field/index.js.map +1 -1
  56. package/build/form-token-field/types.js.map +1 -1
  57. package/build/gradient-picker/index.js +57 -15
  58. package/build/gradient-picker/index.js.map +1 -1
  59. package/build/gradient-picker/types.js.map +1 -1
  60. package/build/higher-order/navigate-regions/index.js.map +1 -1
  61. package/build/higher-order/with-focus-outside/index.js +1 -2
  62. package/build/higher-order/with-focus-outside/index.js.map +1 -1
  63. package/build/higher-order/with-spoken-messages/index.js.map +1 -1
  64. package/build/index.js +6 -0
  65. package/build/index.js.map +1 -1
  66. package/build/input-control/styles/input-control-styles.js +22 -22
  67. package/build/input-control/styles/input-control-styles.js.map +1 -1
  68. package/build/mobile/bottom-sheet/index.native.js +1 -0
  69. package/build/mobile/bottom-sheet/index.native.js.map +1 -1
  70. package/build/mobile/global-styles-context/index.native.js.map +1 -1
  71. package/build/modal/index.js +12 -3
  72. package/build/modal/index.js.map +1 -1
  73. package/build/modal/types.js.map +1 -1
  74. package/build/navigation/use-navigation-tree-nodes.js.map +1 -1
  75. package/build/notice/index.js +19 -7
  76. package/build/notice/index.js.map +1 -1
  77. package/build/palette-edit/styles.js +10 -10
  78. package/build/palette-edit/styles.js.map +1 -1
  79. package/build/placeholder/index.js +10 -4
  80. package/build/placeholder/index.js.map +1 -1
  81. package/build/popover/index.js +37 -83
  82. package/build/popover/index.js.map +1 -1
  83. package/build/popover/types.js.map +1 -1
  84. package/build/popover/utils.js +9 -41
  85. package/build/popover/utils.js.map +1 -1
  86. package/build/search-control/index.js +12 -3
  87. package/build/search-control/index.js.map +1 -1
  88. package/build/search-control/types.js.map +1 -1
  89. package/build/text/styles.js +7 -7
  90. package/build/text/styles.js.map +1 -1
  91. package/build/toggle-group-control/toggle-group-control/as-button-group.js +30 -45
  92. package/build/toggle-group-control/toggle-group-control/as-button-group.js.map +1 -1
  93. package/build/toggle-group-control/toggle-group-control/as-radio-group.js +40 -41
  94. package/build/toggle-group-control/toggle-group-control/as-radio-group.js.map +1 -1
  95. package/build/toggle-group-control/toggle-group-control/component.js +10 -5
  96. package/build/toggle-group-control/toggle-group-control/component.js.map +1 -1
  97. package/build/toggle-group-control/toggle-group-control/styles.js +9 -16
  98. package/build/toggle-group-control/toggle-group-control/styles.js.map +1 -1
  99. package/build/toggle-group-control/toggle-group-control/utils.js +44 -0
  100. package/build/toggle-group-control/toggle-group-control/utils.js.map +1 -0
  101. package/build/toggle-group-control/toggle-group-control-option-base/component.js +36 -17
  102. package/build/toggle-group-control/toggle-group-control-option-base/component.js.map +1 -1
  103. package/build/toggle-group-control/toggle-group-control-option-base/styles.js +10 -8
  104. package/build/toggle-group-control/toggle-group-control-option-base/styles.js.map +1 -1
  105. package/build/toggle-group-control/types.js.map +1 -1
  106. package/build/toolbar/toolbar/index.js +7 -1
  107. package/build/toolbar/toolbar/index.js.map +1 -1
  108. package/build/toolbar/toolbar-dropdown-menu/index.js +1 -3
  109. package/build/toolbar/toolbar-dropdown-menu/index.js.map +1 -1
  110. package/build/toolbar/toolbar-group/index.js +16 -12
  111. package/build/toolbar/toolbar-group/index.js.map +1 -1
  112. package/build/toolbar/toolbar-group/toolbar-group-collapsed.js +0 -2
  113. package/build/toolbar/toolbar-group/toolbar-group-collapsed.js.map +1 -1
  114. package/build/toolbar/toolbar-group/toolbar-group-container.js +3 -1
  115. package/build/toolbar/toolbar-group/toolbar-group-container.js.map +1 -1
  116. package/build/toolbar/toolbar-group/types.js +6 -0
  117. package/build/toolbar/toolbar-group/types.js.map +1 -0
  118. package/build/toolbar/toolbar-item/index.js +1 -1
  119. package/build/toolbar/toolbar-item/index.js.map +1 -1
  120. package/build/tooltip/index.js +51 -225
  121. package/build/tooltip/index.js.map +1 -1
  122. package/build/tooltip/types.js +6 -0
  123. package/build/tooltip/types.js.map +1 -0
  124. package/build/ui/context/context-connect.js.map +1 -1
  125. package/build/ui/context/wordpress-component.js.map +1 -1
  126. package/build/unit-control/index.js.map +1 -1
  127. package/build/unit-control/styles/unit-control-styles.js +7 -7
  128. package/build/unit-control/styles/unit-control-styles.js.map +1 -1
  129. package/build/utils/colors-values.js +1 -1
  130. package/build/utils/colors-values.js.map +1 -1
  131. package/build/utils/use-deprecated-props.js.map +1 -1
  132. package/build-module/animation/index.js +1 -1
  133. package/build-module/animation/index.js.map +1 -1
  134. package/build-module/border-control/border-control-dropdown/component.js +1 -1
  135. package/build-module/border-control/border-control-dropdown/component.js.map +1 -1
  136. package/build-module/border-control/styles.js +20 -20
  137. package/build-module/border-control/styles.js.map +1 -1
  138. package/build-module/box-control/unit-control.js +1 -1
  139. package/build-module/box-control/unit-control.js.map +1 -1
  140. package/build-module/button/index.js +9 -1
  141. package/build-module/button/index.js.map +1 -1
  142. package/build-module/button/types.js.map +1 -1
  143. package/build-module/circular-option-picker/circular-option-picker-actions.js +44 -0
  144. package/build-module/circular-option-picker/circular-option-picker-actions.js.map +1 -0
  145. package/build-module/circular-option-picker/circular-option-picker-context.js +11 -0
  146. package/build-module/circular-option-picker/circular-option-picker-context.js.map +1 -0
  147. package/build-module/circular-option-picker/circular-option-picker-option-group.js +23 -0
  148. package/build-module/circular-option-picker/circular-option-picker-option-group.js.map +1 -0
  149. package/build-module/circular-option-picker/circular-option-picker-option.js +114 -0
  150. package/build-module/circular-option-picker/circular-option-picker-option.js.map +1 -0
  151. package/build-module/circular-option-picker/circular-option-picker.js +165 -0
  152. package/build-module/circular-option-picker/circular-option-picker.js.map +1 -0
  153. package/build-module/circular-option-picker/index.js +4 -132
  154. package/build-module/circular-option-picker/index.js.map +1 -1
  155. package/build-module/circular-option-picker/types.js.map +1 -1
  156. package/build-module/color-palette/index.js +58 -19
  157. package/build-module/color-palette/index.js.map +1 -1
  158. package/build-module/color-palette/types.js.map +1 -1
  159. package/build-module/combobox-control/index.js +0 -3
  160. package/build-module/combobox-control/index.js.map +1 -1
  161. package/build-module/composite/index.js +2 -0
  162. package/build-module/composite/index.js.map +1 -1
  163. package/build-module/custom-gradient-picker/gradient-bar/control-points.js.map +1 -1
  164. package/build-module/date-time/time/index.js +6 -1
  165. package/build-module/date-time/time/index.js.map +1 -1
  166. package/build-module/date-time/time/timezone.js +1 -1
  167. package/build-module/date-time/time/timezone.js.map +1 -1
  168. package/build-module/dropdown/index.js +12 -24
  169. package/build-module/dropdown/index.js.map +1 -1
  170. package/build-module/dropdown/types.js.map +1 -1
  171. package/build-module/dropdown-menu/index.js +7 -1
  172. package/build-module/dropdown-menu/index.js.map +1 -1
  173. package/build-module/dropdown-menu/types.js.map +1 -1
  174. package/build-module/dropdown-menu-v2/styles.js +16 -16
  175. package/build-module/dropdown-menu-v2/styles.js.map +1 -1
  176. package/build-module/duotone-picker/color-list-picker/index.js +18 -3
  177. package/build-module/duotone-picker/color-list-picker/index.js.map +1 -1
  178. package/build-module/duotone-picker/duotone-picker.js +33 -1
  179. package/build-module/duotone-picker/duotone-picker.js.map +1 -1
  180. package/build-module/duotone-picker/types.js.map +1 -1
  181. package/build-module/focusable-iframe/index.js +2 -3
  182. package/build-module/focusable-iframe/index.js.map +1 -1
  183. package/build-module/focusable-iframe/types.js +2 -0
  184. package/build-module/focusable-iframe/types.js.map +1 -0
  185. package/build-module/form-token-field/index.js +6 -2
  186. package/build-module/form-token-field/index.js.map +1 -1
  187. package/build-module/form-token-field/types.js.map +1 -1
  188. package/build-module/gradient-picker/index.js +57 -15
  189. package/build-module/gradient-picker/index.js.map +1 -1
  190. package/build-module/gradient-picker/types.js.map +1 -1
  191. package/build-module/higher-order/navigate-regions/index.js.map +1 -1
  192. package/build-module/higher-order/with-focus-outside/index.js +1 -3
  193. package/build-module/higher-order/with-focus-outside/index.js.map +1 -1
  194. package/build-module/higher-order/with-spoken-messages/index.js.map +1 -1
  195. package/build-module/index.js +1 -1
  196. package/build-module/index.js.map +1 -1
  197. package/build-module/input-control/styles/input-control-styles.js +23 -23
  198. package/build-module/input-control/styles/input-control-styles.js.map +1 -1
  199. package/build-module/mobile/bottom-sheet/index.native.js +1 -0
  200. package/build-module/mobile/bottom-sheet/index.native.js.map +1 -1
  201. package/build-module/mobile/global-styles-context/index.native.js.map +1 -1
  202. package/build-module/modal/index.js +12 -3
  203. package/build-module/modal/index.js.map +1 -1
  204. package/build-module/modal/types.js.map +1 -1
  205. package/build-module/navigation/use-navigation-tree-nodes.js.map +1 -1
  206. package/build-module/notice/index.js +19 -7
  207. package/build-module/notice/index.js.map +1 -1
  208. package/build-module/palette-edit/styles.js +10 -10
  209. package/build-module/palette-edit/styles.js.map +1 -1
  210. package/build-module/placeholder/index.js +11 -4
  211. package/build-module/placeholder/index.js.map +1 -1
  212. package/build-module/popover/index.js +38 -84
  213. package/build-module/popover/index.js.map +1 -1
  214. package/build-module/popover/types.js.map +1 -1
  215. package/build-module/popover/utils.js +8 -39
  216. package/build-module/popover/utils.js.map +1 -1
  217. package/build-module/search-control/index.js +12 -3
  218. package/build-module/search-control/index.js.map +1 -1
  219. package/build-module/search-control/types.js.map +1 -1
  220. package/build-module/text/styles.js +7 -7
  221. package/build-module/text/styles.js.map +1 -1
  222. package/build-module/toggle-group-control/toggle-group-control/as-button-group.js +32 -47
  223. package/build-module/toggle-group-control/toggle-group-control/as-button-group.js.map +1 -1
  224. package/build-module/toggle-group-control/toggle-group-control/as-radio-group.js +41 -42
  225. package/build-module/toggle-group-control/toggle-group-control/as-radio-group.js.map +1 -1
  226. package/build-module/toggle-group-control/toggle-group-control/component.js +10 -6
  227. package/build-module/toggle-group-control/toggle-group-control/component.js.map +1 -1
  228. package/build-module/toggle-group-control/toggle-group-control/styles.js +8 -14
  229. package/build-module/toggle-group-control/toggle-group-control/styles.js.map +1 -1
  230. package/build-module/toggle-group-control/toggle-group-control/utils.js +42 -0
  231. package/build-module/toggle-group-control/toggle-group-control/utils.js.map +1 -0
  232. package/build-module/toggle-group-control/toggle-group-control-option-base/component.js +35 -16
  233. package/build-module/toggle-group-control/toggle-group-control-option-base/component.js.map +1 -1
  234. package/build-module/toggle-group-control/toggle-group-control-option-base/styles.js +8 -7
  235. package/build-module/toggle-group-control/toggle-group-control-option-base/styles.js.map +1 -1
  236. package/build-module/toggle-group-control/types.js.map +1 -1
  237. package/build-module/toolbar/toolbar/index.js +7 -1
  238. package/build-module/toolbar/toolbar/index.js.map +1 -1
  239. package/build-module/toolbar/toolbar-dropdown-menu/index.js +5 -3
  240. package/build-module/toolbar/toolbar-dropdown-menu/index.js.map +1 -1
  241. package/build-module/toolbar/toolbar-group/index.js +15 -12
  242. package/build-module/toolbar/toolbar-group/index.js.map +1 -1
  243. package/build-module/toolbar/toolbar-group/toolbar-group-collapsed.js +0 -2
  244. package/build-module/toolbar/toolbar-group/toolbar-group-collapsed.js.map +1 -1
  245. package/build-module/toolbar/toolbar-group/toolbar-group-container.js +3 -1
  246. package/build-module/toolbar/toolbar-group/toolbar-group-container.js.map +1 -1
  247. package/build-module/toolbar/toolbar-group/types.js +2 -0
  248. package/build-module/toolbar/toolbar-group/types.js.map +1 -0
  249. package/build-module/toolbar/toolbar-item/index.js +1 -1
  250. package/build-module/toolbar/toolbar-item/index.js.map +1 -1
  251. package/build-module/tooltip/index.js +53 -224
  252. package/build-module/tooltip/index.js.map +1 -1
  253. package/build-module/tooltip/types.js +2 -0
  254. package/build-module/tooltip/types.js.map +1 -0
  255. package/build-module/ui/context/context-connect.js.map +1 -1
  256. package/build-module/ui/context/wordpress-component.js.map +1 -1
  257. package/build-module/unit-control/index.js.map +1 -1
  258. package/build-module/unit-control/styles/unit-control-styles.js +7 -7
  259. package/build-module/unit-control/styles/unit-control-styles.js.map +1 -1
  260. package/build-module/utils/colors-values.js +1 -1
  261. package/build-module/utils/colors-values.js.map +1 -1
  262. package/build-module/utils/use-deprecated-props.js.map +1 -1
  263. package/build-style/style-rtl.css +35 -73
  264. package/build-style/style.css +35 -73
  265. package/build-types/animation/index.d.ts +1 -1
  266. package/build-types/animation/index.d.ts.map +1 -1
  267. package/build-types/base-control/hooks.d.ts +1 -1
  268. package/build-types/border-box-control/border-box-control/component.d.ts +1 -1
  269. package/build-types/border-box-control/border-box-control/hook.d.ts +46 -46
  270. package/build-types/border-box-control/border-box-control-linked-button/hook.d.ts +51 -51
  271. package/build-types/border-box-control/border-box-control-split-controls/component.d.ts +1 -1
  272. package/build-types/border-box-control/border-box-control-split-controls/hook.d.ts +46 -46
  273. package/build-types/border-box-control/border-box-control-visualizer/hook.d.ts +46 -46
  274. package/build-types/border-box-control/stories/index.story.d.ts +2 -2
  275. package/build-types/border-control/border-control/hook.d.ts +45 -45
  276. package/build-types/border-control/border-control-dropdown/hook.d.ts +45 -45
  277. package/build-types/border-control/border-control-style-picker/hook.d.ts +45 -45
  278. package/build-types/border-control/stories/index.story.d.ts +6 -6
  279. package/build-types/box-control/styles/box-control-styles.d.ts +1 -1
  280. package/build-types/button/deprecated.d.ts +16 -22
  281. package/build-types/button/deprecated.d.ts.map +1 -1
  282. package/build-types/button/index.d.ts.map +1 -1
  283. package/build-types/button/types.d.ts +0 -4
  284. package/build-types/button/types.d.ts.map +1 -1
  285. package/build-types/card/card/hook.d.ts +46 -46
  286. package/build-types/card/card-body/hook.d.ts +46 -46
  287. package/build-types/card/card-divider/hook.d.ts +47 -47
  288. package/build-types/card/card-footer/hook.d.ts +46 -46
  289. package/build-types/card/card-header/hook.d.ts +46 -46
  290. package/build-types/card/card-media/hook.d.ts +46 -46
  291. package/build-types/card/stories/index.story.d.ts +2 -2
  292. package/build-types/circular-option-picker/circular-option-picker-actions.d.ts +7 -0
  293. package/build-types/circular-option-picker/circular-option-picker-actions.d.ts.map +1 -0
  294. package/build-types/circular-option-picker/circular-option-picker-context.d.ts +7 -0
  295. package/build-types/circular-option-picker/circular-option-picker-context.d.ts.map +1 -0
  296. package/build-types/circular-option-picker/circular-option-picker-option-group.d.ts +7 -0
  297. package/build-types/circular-option-picker/circular-option-picker-option-group.d.ts.map +1 -0
  298. package/build-types/circular-option-picker/circular-option-picker-option.d.ts +4 -0
  299. package/build-types/circular-option-picker/circular-option-picker-option.d.ts.map +1 -0
  300. package/build-types/circular-option-picker/circular-option-picker.d.ts +11 -0
  301. package/build-types/circular-option-picker/circular-option-picker.d.ts.map +1 -0
  302. package/build-types/circular-option-picker/index.d.ts +5 -56
  303. package/build-types/circular-option-picker/index.d.ts.map +1 -1
  304. package/build-types/circular-option-picker/stories/index.story.d.ts +3 -1
  305. package/build-types/circular-option-picker/stories/index.story.d.ts.map +1 -1
  306. package/build-types/circular-option-picker/test/index.d.ts +2 -0
  307. package/build-types/circular-option-picker/test/index.d.ts.map +1 -0
  308. package/build-types/circular-option-picker/types.d.ts +53 -1
  309. package/build-types/circular-option-picker/types.d.ts.map +1 -1
  310. package/build-types/color-palette/index.d.ts +3 -19
  311. package/build-types/color-palette/index.d.ts.map +1 -1
  312. package/build-types/color-palette/stories/index.story.d.ts +3 -36
  313. package/build-types/color-palette/stories/index.story.d.ts.map +1 -1
  314. package/build-types/color-palette/styles.d.ts +1 -1
  315. package/build-types/color-palette/types.d.ts +31 -1
  316. package/build-types/color-palette/types.d.ts.map +1 -1
  317. package/build-types/color-picker/component.d.ts +1 -1
  318. package/build-types/color-picker/stories/index.story.d.ts +1 -1
  319. package/build-types/color-picker/styles.d.ts +6 -6
  320. package/build-types/combobox-control/index.d.ts.map +1 -1
  321. package/build-types/combobox-control/stories/index.story.d.ts +2 -2
  322. package/build-types/composite/index.d.ts +14 -1
  323. package/build-types/composite/index.d.ts.map +1 -1
  324. package/build-types/custom-gradient-picker/styles/custom-gradient-picker-styles.d.ts +2 -2
  325. package/build-types/date-time/date/styles.d.ts +3 -3
  326. package/build-types/date-time/date-time/styles.d.ts +2 -2
  327. package/build-types/date-time/time/index.d.ts.map +1 -1
  328. package/build-types/date-time/time/styles.d.ts +12 -12
  329. package/build-types/dropdown/index.d.ts.map +1 -1
  330. package/build-types/dropdown/stories/index.story.d.ts.map +1 -1
  331. package/build-types/dropdown/types.d.ts +12 -4
  332. package/build-types/dropdown/types.d.ts.map +1 -1
  333. package/build-types/dropdown-menu/index.d.ts.map +1 -1
  334. package/build-types/dropdown-menu/stories/index.story.d.ts.map +1 -1
  335. package/build-types/dropdown-menu/types.d.ts +22 -5
  336. package/build-types/dropdown-menu/types.d.ts.map +1 -1
  337. package/build-types/duotone-picker/color-list-picker/index.d.ts.map +1 -1
  338. package/build-types/duotone-picker/duotone-picker.d.ts +1 -1
  339. package/build-types/duotone-picker/duotone-picker.d.ts.map +1 -1
  340. package/build-types/duotone-picker/types.d.ts +31 -1
  341. package/build-types/duotone-picker/types.d.ts.map +1 -1
  342. package/build-types/elevation/hook.d.ts +46 -46
  343. package/build-types/external-link/styles/external-link-styles.d.ts +1 -1
  344. package/build-types/flex/flex/hook.d.ts +46 -46
  345. package/build-types/flex/flex-block/hook.d.ts +46 -46
  346. package/build-types/flex/flex-item/hook.d.ts +46 -46
  347. package/build-types/focal-point-picker/stories/index.story.d.ts +8 -8
  348. package/build-types/focal-point-picker/styles/focal-point-picker-style.d.ts +1 -1
  349. package/build-types/focusable-iframe/index.d.ts +4 -5
  350. package/build-types/focusable-iframe/index.d.ts.map +1 -1
  351. package/build-types/focusable-iframe/types.d.ts +8 -0
  352. package/build-types/focusable-iframe/types.d.ts.map +1 -0
  353. package/build-types/font-size-picker/styles.d.ts +2 -2
  354. package/build-types/form-token-field/index.d.ts.map +1 -1
  355. package/build-types/form-token-field/types.d.ts +6 -0
  356. package/build-types/form-token-field/types.d.ts.map +1 -1
  357. package/build-types/gradient-picker/index.d.ts +1 -1
  358. package/build-types/gradient-picker/index.d.ts.map +1 -1
  359. package/build-types/gradient-picker/stories/index.story.d.ts +3 -36
  360. package/build-types/gradient-picker/stories/index.story.d.ts.map +1 -1
  361. package/build-types/gradient-picker/types.d.ts +31 -1
  362. package/build-types/gradient-picker/types.d.ts.map +1 -1
  363. package/build-types/grid/hook.d.ts +46 -46
  364. package/build-types/h-stack/component.d.ts +1 -1
  365. package/build-types/h-stack/hook.d.ts +46 -46
  366. package/build-types/heading/hook.d.ts +45 -45
  367. package/build-types/higher-order/navigate-regions/index.d.ts.map +1 -1
  368. package/build-types/higher-order/with-focus-outside/index.d.ts +1 -0
  369. package/build-types/higher-order/with-focus-outside/index.d.ts.map +1 -1
  370. package/build-types/higher-order/with-focus-outside/test/index.d.ts +2 -0
  371. package/build-types/higher-order/with-focus-outside/test/index.d.ts.map +1 -0
  372. package/build-types/higher-order/with-spoken-messages/index.d.ts.map +1 -1
  373. package/build-types/index.d.ts +1 -1
  374. package/build-types/index.d.ts.map +1 -1
  375. package/build-types/isolated-event-container/test/index.d.ts +2 -0
  376. package/build-types/isolated-event-container/test/index.d.ts.map +1 -0
  377. package/build-types/item-group/item/hook.d.ts +46 -46
  378. package/build-types/item-group/item-group/hook.d.ts +46 -46
  379. package/build-types/menu-item/index.d.ts +1 -1
  380. package/build-types/menu-item/stories/index.story.d.ts +4 -4
  381. package/build-types/modal/index.d.ts.map +1 -1
  382. package/build-types/modal/stories/index.story.d.ts.map +1 -1
  383. package/build-types/modal/types.d.ts +1 -1
  384. package/build-types/modal/types.d.ts.map +1 -1
  385. package/build-types/navigable-container/menu.d.ts +1 -1
  386. package/build-types/navigation/back-button/index.d.ts +1 -1
  387. package/build-types/navigation/styles/navigation-styles.d.ts +5 -3
  388. package/build-types/navigation/styles/navigation-styles.d.ts.map +1 -1
  389. package/build-types/navigator/navigator-back-button/component.d.ts +2 -3
  390. package/build-types/navigator/navigator-back-button/component.d.ts.map +1 -1
  391. package/build-types/navigator/navigator-back-button/hook.d.ts +53 -54
  392. package/build-types/navigator/navigator-back-button/hook.d.ts.map +1 -1
  393. package/build-types/navigator/navigator-button/component.d.ts +2 -3
  394. package/build-types/navigator/navigator-button/component.d.ts.map +1 -1
  395. package/build-types/navigator/navigator-button/hook.d.ts +53 -54
  396. package/build-types/navigator/navigator-button/hook.d.ts.map +1 -1
  397. package/build-types/navigator/navigator-to-parent-button/component.d.ts +2 -3
  398. package/build-types/navigator/navigator-to-parent-button/component.d.ts.map +1 -1
  399. package/build-types/notice/index.d.ts.map +1 -1
  400. package/build-types/number-control/index.d.ts +3 -3
  401. package/build-types/number-control/stories/index.story.d.ts +3 -3
  402. package/build-types/palette-edit/styles.d.ts +4 -4
  403. package/build-types/palette-edit/styles.d.ts.map +1 -1
  404. package/build-types/placeholder/index.d.ts.map +1 -1
  405. package/build-types/popover/index.d.ts +1 -1
  406. package/build-types/popover/index.d.ts.map +1 -1
  407. package/build-types/popover/overlay-middlewares.d.ts +1 -1
  408. package/build-types/popover/stories/e2e/index.story.d.ts +1 -1
  409. package/build-types/popover/types.d.ts +0 -4
  410. package/build-types/popover/types.d.ts.map +1 -1
  411. package/build-types/popover/utils.d.ts +2 -6
  412. package/build-types/popover/utils.d.ts.map +1 -1
  413. package/build-types/range-control/index.d.ts +1 -1
  414. package/build-types/range-control/styles/range-control-styles.d.ts +3 -3
  415. package/build-types/resizable-box/index.d.ts +1 -1
  416. package/build-types/resizable-box/resize-tooltip/index.d.ts +1 -1
  417. package/build-types/resizable-box/resize-tooltip/label.d.ts +1 -1
  418. package/build-types/resizable-box/stories/index.story.d.ts +2 -2
  419. package/build-types/scrollable/hook.d.ts +46 -46
  420. package/build-types/search-control/index.d.ts +4 -2
  421. package/build-types/search-control/index.d.ts.map +1 -1
  422. package/build-types/search-control/stories/index.story.d.ts +8 -4
  423. package/build-types/search-control/stories/index.story.d.ts.map +1 -1
  424. package/build-types/search-control/types.d.ts +12 -0
  425. package/build-types/search-control/types.d.ts.map +1 -1
  426. package/build-types/spacer/hook.d.ts +46 -46
  427. package/build-types/spinner/index.d.ts +1 -1
  428. package/build-types/surface/hook.d.ts +46 -46
  429. package/build-types/text/hook.d.ts +46 -46
  430. package/build-types/text/styles.d.ts.map +1 -1
  431. package/build-types/text-control/index.d.ts +3 -3
  432. package/build-types/toggle-control/stories/index.story.d.ts +2 -2
  433. package/build-types/toggle-group-control/toggle-group-control/as-button-group.d.ts +2 -4
  434. package/build-types/toggle-group-control/toggle-group-control/as-button-group.d.ts.map +1 -1
  435. package/build-types/toggle-group-control/toggle-group-control/as-radio-group.d.ts +2 -4
  436. package/build-types/toggle-group-control/toggle-group-control/as-radio-group.d.ts.map +1 -1
  437. package/build-types/toggle-group-control/toggle-group-control/component.d.ts +2 -2
  438. package/build-types/toggle-group-control/toggle-group-control/component.d.ts.map +1 -1
  439. package/build-types/toggle-group-control/toggle-group-control/styles.d.ts +1 -5
  440. package/build-types/toggle-group-control/toggle-group-control/styles.d.ts.map +1 -1
  441. package/build-types/toggle-group-control/toggle-group-control/utils.d.ts +18 -0
  442. package/build-types/toggle-group-control/toggle-group-control/utils.d.ts.map +1 -0
  443. package/build-types/toggle-group-control/toggle-group-control-option/component.d.ts +1 -1
  444. package/build-types/toggle-group-control/toggle-group-control-option-base/component.d.ts +5 -1
  445. package/build-types/toggle-group-control/toggle-group-control-option-base/component.d.ts.map +1 -1
  446. package/build-types/toggle-group-control/toggle-group-control-option-base/styles.d.ts +1 -0
  447. package/build-types/toggle-group-control/toggle-group-control-option-base/styles.d.ts.map +1 -1
  448. package/build-types/toggle-group-control/toggle-group-control-option-icon/component.d.ts +1 -1
  449. package/build-types/toggle-group-control/types.d.ts +13 -24
  450. package/build-types/toggle-group-control/types.d.ts.map +1 -1
  451. package/build-types/toolbar/stories/index.story.d.ts.map +1 -1
  452. package/build-types/toolbar/toolbar/index.d.ts.map +1 -1
  453. package/build-types/toolbar/toolbar-button/index.d.ts +16 -22
  454. package/build-types/toolbar/toolbar-button/index.d.ts.map +1 -1
  455. package/build-types/toolbar/toolbar-dropdown-menu/index.d.ts +3 -1
  456. package/build-types/toolbar/toolbar-dropdown-menu/index.d.ts.map +1 -1
  457. package/build-types/toolbar/toolbar-group/index.d.ts +10 -14
  458. package/build-types/toolbar/toolbar-group/index.d.ts.map +1 -1
  459. package/build-types/toolbar/toolbar-group/toolbar-group-collapsed.d.ts +3 -5
  460. package/build-types/toolbar/toolbar-group/toolbar-group-collapsed.d.ts.map +1 -1
  461. package/build-types/toolbar/toolbar-group/toolbar-group-container.d.ts +7 -5
  462. package/build-types/toolbar/toolbar-group/toolbar-group-container.d.ts.map +1 -1
  463. package/build-types/toolbar/toolbar-group/types.d.ts +77 -0
  464. package/build-types/toolbar/toolbar-group/types.d.ts.map +1 -0
  465. package/build-types/toolbar/toolbar-item/index.d.ts.map +1 -1
  466. package/build-types/tools-panel/tools-panel/hook.d.ts +46 -46
  467. package/build-types/tools-panel/tools-panel-header/hook.d.ts +46 -46
  468. package/build-types/tools-panel/tools-panel-item/hook.d.ts +46 -46
  469. package/build-types/tooltip/index.d.ts +8 -5
  470. package/build-types/tooltip/index.d.ts.map +1 -1
  471. package/build-types/tooltip/stories/index.story.d.ts +13 -0
  472. package/build-types/tooltip/stories/index.story.d.ts.map +1 -0
  473. package/build-types/tooltip/test/index.d.ts +2 -0
  474. package/build-types/tooltip/test/index.d.ts.map +1 -0
  475. package/build-types/tooltip/test/utils/index.d.ts +11 -0
  476. package/build-types/tooltip/test/utils/index.d.ts.map +1 -0
  477. package/build-types/tooltip/types.d.ts +61 -0
  478. package/build-types/tooltip/types.d.ts.map +1 -0
  479. package/build-types/truncate/hook.d.ts +46 -46
  480. package/build-types/ui/tooltip/content.d.ts +1 -1
  481. package/build-types/unit-control/index.d.ts +1 -1
  482. package/build-types/unit-control/index.d.ts.map +1 -1
  483. package/build-types/unit-control/styles/unit-control-styles.d.ts +3 -3
  484. package/build-types/unit-control/styles/unit-control-styles.d.ts.map +1 -1
  485. package/build-types/unit-control/unit-select-control.d.ts +1 -1
  486. package/build-types/utils/use-deprecated-props.d.ts +1 -1
  487. package/build-types/v-stack/component.d.ts +1 -1
  488. package/build-types/v-stack/hook.d.ts +46 -46
  489. package/build-types/v-stack/stories/index.story.d.ts +2 -2
  490. package/package.json +20 -20
  491. package/src/animation/index.tsx +1 -0
  492. package/src/border-control/border-control/README.md +2 -2
  493. package/src/border-control/border-control-dropdown/component.tsx +1 -1
  494. package/src/border-control/styles.ts +7 -7
  495. package/src/border-control/test/index.js +79 -69
  496. package/src/box-control/unit-control.tsx +1 -1
  497. package/src/button/README.md +0 -6
  498. package/src/button/index.tsx +9 -1
  499. package/src/button/test/index.tsx +19 -0
  500. package/src/button/types.ts +0 -4
  501. package/src/circular-option-picker/README.md +14 -0
  502. package/src/circular-option-picker/circular-option-picker-actions.tsx +60 -0
  503. package/src/circular-option-picker/circular-option-picker-context.tsx +12 -0
  504. package/src/circular-option-picker/circular-option-picker-option-group.tsx +34 -0
  505. package/src/circular-option-picker/circular-option-picker-option.tsx +139 -0
  506. package/src/circular-option-picker/circular-option-picker.tsx +202 -0
  507. package/src/circular-option-picker/index.tsx +7 -174
  508. package/src/circular-option-picker/stories/index.story.tsx +34 -9
  509. package/src/circular-option-picker/style.scss +11 -7
  510. package/src/circular-option-picker/test/index.tsx +133 -0
  511. package/src/circular-option-picker/types.ts +64 -1
  512. package/src/color-palette/README.md +14 -0
  513. package/src/color-palette/index.tsx +69 -28
  514. package/src/color-palette/stories/index.story.tsx +16 -2
  515. package/src/color-palette/test/index.tsx +32 -30
  516. package/src/color-palette/types.ts +34 -1
  517. package/src/combobox-control/index.tsx +7 -5
  518. package/src/composite/{index.js → index.ts} +3 -0
  519. package/src/confirm-dialog/stories/index.story.js +13 -14
  520. package/src/confirm-dialog/test/index.js +10 -18
  521. package/src/custom-gradient-picker/gradient-bar/control-points.tsx +1 -1
  522. package/src/custom-gradient-picker/gradient-bar/test/utils.ts +5 -5
  523. package/src/date-time/time/index.tsx +8 -1
  524. package/src/date-time/time/timezone.tsx +1 -1
  525. package/src/dropdown/README.md +13 -3
  526. package/src/dropdown/index.tsx +16 -34
  527. package/src/dropdown/stories/index.story.tsx +10 -7
  528. package/src/dropdown/types.ts +12 -4
  529. package/src/dropdown-menu/README.md +18 -0
  530. package/src/dropdown-menu/index.tsx +8 -1
  531. package/src/dropdown-menu/stories/index.story.tsx +5 -0
  532. package/src/dropdown-menu/types.ts +23 -6
  533. package/src/dropdown-menu-v2/styles.ts +1 -1
  534. package/src/duotone-picker/README.md +14 -0
  535. package/src/duotone-picker/color-list-picker/index.tsx +28 -12
  536. package/src/duotone-picker/duotone-picker.tsx +33 -0
  537. package/src/duotone-picker/types.ts +34 -1
  538. package/src/focusable-iframe/{index.js → index.tsx} +7 -4
  539. package/src/focusable-iframe/types.ts +9 -0
  540. package/src/form-token-field/README.md +1 -0
  541. package/src/form-token-field/index.tsx +5 -1
  542. package/src/form-token-field/style.scss +5 -9
  543. package/src/form-token-field/test/index.tsx +36 -1
  544. package/src/form-token-field/types.ts +7 -1
  545. package/src/gradient-picker/README.md +14 -0
  546. package/src/gradient-picker/index.tsx +60 -11
  547. package/src/gradient-picker/types.ts +34 -1
  548. package/src/higher-order/navigate-regions/index.tsx +5 -6
  549. package/src/higher-order/with-filters/test/index.tsx +36 -43
  550. package/src/higher-order/with-focus-outside/{index.js → index.tsx} +8 -5
  551. package/src/higher-order/with-focus-outside/test/{index.js → index.tsx} +13 -11
  552. package/src/higher-order/with-notices/test/index.tsx +1 -1
  553. package/src/higher-order/with-spoken-messages/index.tsx +7 -8
  554. package/src/index.ts +5 -1
  555. package/src/input-control/styles/input-control-styles.tsx +2 -2
  556. package/src/isolated-event-container/test/{index.js → index.tsx} +1 -1
  557. package/src/mobile/bottom-sheet/index.native.js +1 -0
  558. package/src/mobile/global-styles-context/index.native.js +7 -8
  559. package/src/modal/README.md +7 -1
  560. package/src/modal/index.tsx +27 -3
  561. package/src/modal/stories/index.story.tsx +2 -1
  562. package/src/modal/test/index.tsx +231 -0
  563. package/src/modal/types.ts +3 -1
  564. package/src/navigation/use-navigation-tree-nodes.tsx +1 -1
  565. package/src/notice/index.tsx +18 -6
  566. package/src/notice/style.scss +0 -1
  567. package/src/notice/test/__snapshots__/index.tsx.snap +9 -1
  568. package/src/palette-edit/styles.js +2 -1
  569. package/src/placeholder/index.tsx +16 -8
  570. package/src/placeholder/style.scss +2 -16
  571. package/src/placeholder/test/index.tsx +34 -15
  572. package/src/popover/index.tsx +47 -110
  573. package/src/popover/test/index.tsx +3 -3
  574. package/src/popover/types.ts +0 -5
  575. package/src/popover/utils.ts +19 -67
  576. package/src/search-control/README.md +7 -0
  577. package/src/search-control/index.tsx +10 -1
  578. package/src/search-control/style.scss +14 -7
  579. package/src/search-control/types.ts +12 -0
  580. package/src/tab-panel/test/index.tsx +5 -0
  581. package/src/text/styles.js +2 -1
  582. package/src/theme/README.md +5 -5
  583. package/src/toggle-group-control/test/__snapshots__/index.tsx.snap +567 -59
  584. package/src/toggle-group-control/test/index.tsx +110 -56
  585. package/src/toggle-group-control/toggle-group-control/README.md +0 -1
  586. package/src/toggle-group-control/toggle-group-control/as-button-group.tsx +39 -57
  587. package/src/toggle-group-control/toggle-group-control/as-radio-group.tsx +52 -48
  588. package/src/toggle-group-control/toggle-group-control/component.tsx +12 -6
  589. package/src/toggle-group-control/toggle-group-control/styles.ts +2 -19
  590. package/src/toggle-group-control/toggle-group-control/utils.ts +50 -0
  591. package/src/toggle-group-control/toggle-group-control-option-base/component.tsx +70 -20
  592. package/src/toggle-group-control/toggle-group-control-option-base/styles.ts +17 -3
  593. package/src/toggle-group-control/types.ts +14 -32
  594. package/src/toolbar/stories/index.story.tsx +3 -5
  595. package/src/toolbar/test/toolbar-group.tsx +13 -7
  596. package/src/toolbar/toolbar/index.tsx +9 -1
  597. package/src/toolbar/toolbar-dropdown-menu/{index.js → index.tsx} +11 -4
  598. package/src/toolbar/toolbar-group/README.md +2 -2
  599. package/src/toolbar/toolbar-group/{index.js → index.tsx} +19 -14
  600. package/src/toolbar/toolbar-group/{toolbar-group-collapsed.js → toolbar-group-collapsed.tsx} +10 -4
  601. package/src/toolbar/toolbar-group/toolbar-group-container.tsx +16 -0
  602. package/src/toolbar/toolbar-group/types.ts +92 -0
  603. package/src/toolbar/toolbar-item/index.tsx +3 -1
  604. package/src/tooltip/README.md +31 -28
  605. package/src/tooltip/index.tsx +106 -0
  606. package/src/tooltip/stories/index.story.tsx +59 -0
  607. package/src/tooltip/style.scss +2 -27
  608. package/src/tooltip/test/index.tsx +335 -0
  609. package/src/tooltip/test/utils/index.tsx +20 -0
  610. package/src/tooltip/types.ts +61 -0
  611. package/src/ui/context/context-connect.ts +3 -3
  612. package/src/ui/context/wordpress-component.ts +4 -4
  613. package/src/unit-control/index.tsx +9 -4
  614. package/src/unit-control/styles/unit-control-styles.ts +3 -1
  615. package/src/unit-control/test/utils.ts +1 -1
  616. package/src/utils/colors-values.js +1 -1
  617. package/src/utils/use-deprecated-props.ts +1 -1
  618. package/tsconfig.tsbuildinfo +1 -1
  619. package/build/toggle-group-control/toggle-group-control/toggle-group-control-backdrop.js +0 -78
  620. package/build/toggle-group-control/toggle-group-control/toggle-group-control-backdrop.js.map +0 -1
  621. package/build-module/toggle-group-control/toggle-group-control/toggle-group-control-backdrop.js +0 -76
  622. package/build-module/toggle-group-control/toggle-group-control/toggle-group-control-backdrop.js.map +0 -1
  623. package/build-types/toggle-group-control/toggle-group-control/toggle-group-control-backdrop.d.ts +0 -9
  624. package/build-types/toggle-group-control/toggle-group-control/toggle-group-control-backdrop.d.ts.map +0 -1
  625. package/src/color-palette/test/__snapshots__/index.tsx.snap +0 -288
  626. package/src/toggle-group-control/toggle-group-control/toggle-group-control-backdrop.tsx +0 -84
  627. package/src/toolbar/toolbar-group/toolbar-group-container.js +0 -8
  628. package/src/tooltip/index.js +0 -293
  629. package/src/tooltip/stories/index.story.js +0 -85
  630. package/src/tooltip/test/index.js +0 -323
@@ -11,8 +11,6 @@ var _toolbarButton = _interopRequireDefault(require("../toolbar-button"));
11
11
  var _toolbarGroupContainer = _interopRequireDefault(require("./toolbar-group-container"));
12
12
  var _toolbarGroupCollapsed = _interopRequireDefault(require("./toolbar-group-collapsed"));
13
13
  var _toolbarContext = _interopRequireDefault(require("../toolbar-context"));
14
- // @ts-nocheck
15
-
16
14
  /**
17
15
  * External dependencies
18
16
  */
@@ -25,6 +23,10 @@ var _toolbarContext = _interopRequireDefault(require("../toolbar-context"));
25
23
  * Internal dependencies
26
24
  */
27
25
 
26
+ function isNestedArray(arr) {
27
+ return Array.isArray(arr) && Array.isArray(arr[0]);
28
+ }
29
+
28
30
  /**
29
31
  * Renders a collapsible group of controls
30
32
  *
@@ -48,12 +50,12 @@ var _toolbarContext = _interopRequireDefault(require("../toolbar-context"));
48
50
  * Either `controls` or `children` is required, otherwise this components
49
51
  * renders nothing.
50
52
  *
51
- * @param {Object} props Component props.
52
- * @param {Array} [props.controls] The controls to render in this toolbar.
53
- * @param {WPElement} [props.children] Any other things to render inside the toolbar besides the controls.
54
- * @param {string} [props.className] Class to set on the container div.
55
- * @param {boolean} [props.isCollapsed] Turns ToolbarGroup into a dropdown menu.
56
- * @param {string} [props.title] ARIA label for dropdown menu if is collapsed.
53
+ * @param props Component props.
54
+ * @param [props.controls] The controls to render in this toolbar.
55
+ * @param [props.children] Any other things to render inside the toolbar besides the controls.
56
+ * @param [props.className] Class to set on the container div.
57
+ * @param [props.isCollapsed] Turns ToolbarGroup into a dropdown menu.
58
+ * @param [props.title] ARIA label for dropdown menu if is collapsed.
57
59
  */
58
60
  function ToolbarGroup({
59
61
  controls = [],
@@ -75,9 +77,11 @@ function ToolbarGroup({
75
77
  accessibleToolbarState ? 'components-toolbar-group' : 'components-toolbar', className);
76
78
 
77
79
  // Normalize controls to nested array of objects (sets of controls)
78
- let controlSets = controls;
79
- if (!Array.isArray(controlSets[0])) {
80
- controlSets = [controlSets];
80
+ let controlSets;
81
+ if (isNestedArray(controls)) {
82
+ controlSets = controls;
83
+ } else {
84
+ controlSets = [controls];
81
85
  }
82
86
  if (isCollapsed) {
83
87
  return (0, _element.createElement)(_toolbarGroupCollapsed.default, {
@@ -93,7 +97,7 @@ function ToolbarGroup({
93
97
  ...props
94
98
  }, controlSets?.flatMap((controlSet, indexOfSet) => controlSet.map((control, indexOfControl) => (0, _element.createElement)(_toolbarButton.default, {
95
99
  key: [indexOfSet, indexOfControl].join(),
96
- containerClassName: indexOfSet > 0 && indexOfControl === 0 ? 'has-left-divider' : null,
100
+ containerClassName: indexOfSet > 0 && indexOfControl === 0 ? 'has-left-divider' : undefined,
97
101
  ...control
98
102
  }))), children);
99
103
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_element","require","_classnames","_interopRequireDefault","_toolbarButton","_toolbarGroupContainer","_toolbarGroupCollapsed","_toolbarContext","ToolbarGroup","controls","children","className","isCollapsed","title","props","accessibleToolbarState","useContext","ToolbarContext","length","finalClassName","classnames","controlSets","Array","isArray","createElement","default","label","flatMap","controlSet","indexOfSet","map","control","indexOfControl","key","join","containerClassName","_default","exports"],"sources":["@wordpress/components/src/toolbar/toolbar-group/index.js"],"sourcesContent":["// @ts-nocheck\n\n/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useContext } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport ToolbarButton from '../toolbar-button';\nimport ToolbarGroupContainer from './toolbar-group-container';\nimport ToolbarGroupCollapsed from './toolbar-group-collapsed';\nimport ToolbarContext from '../toolbar-context';\n\n/**\n * Renders a collapsible group of controls\n *\n * The `controls` prop accepts an array of sets. A set is an array of controls.\n * Controls have the following shape:\n *\n * ```\n * {\n * icon: string,\n * title: string,\n * subscript: string,\n * onClick: Function,\n * isActive: boolean,\n * isDisabled: boolean\n * }\n * ```\n *\n * For convenience it is also possible to pass only an array of controls. It is\n * then assumed this is the only set.\n *\n * Either `controls` or `children` is required, otherwise this components\n * renders nothing.\n *\n * @param {Object} props Component props.\n * @param {Array} [props.controls] The controls to render in this toolbar.\n * @param {WPElement} [props.children] Any other things to render inside the toolbar besides the controls.\n * @param {string} [props.className] Class to set on the container div.\n * @param {boolean} [props.isCollapsed] Turns ToolbarGroup into a dropdown menu.\n * @param {string} [props.title] ARIA label for dropdown menu if is collapsed.\n */\nfunction ToolbarGroup( {\n\tcontrols = [],\n\tchildren,\n\tclassName,\n\tisCollapsed,\n\ttitle,\n\t...props\n} ) {\n\t// It'll contain state if `ToolbarGroup` is being used within\n\t// `<Toolbar label=\"label\" />`\n\tconst accessibleToolbarState = useContext( ToolbarContext );\n\n\tif ( ( ! controls || ! controls.length ) && ! children ) {\n\t\treturn null;\n\t}\n\n\tconst finalClassName = classnames(\n\t\t// Unfortunately, there's legacy code referencing to `.components-toolbar`\n\t\t// So we can't get rid of it\n\t\taccessibleToolbarState\n\t\t\t? 'components-toolbar-group'\n\t\t\t: 'components-toolbar',\n\t\tclassName\n\t);\n\n\t// Normalize controls to nested array of objects (sets of controls)\n\tlet controlSets = controls;\n\tif ( ! Array.isArray( controlSets[ 0 ] ) ) {\n\t\tcontrolSets = [ controlSets ];\n\t}\n\n\tif ( isCollapsed ) {\n\t\treturn (\n\t\t\t<ToolbarGroupCollapsed\n\t\t\t\tlabel={ title }\n\t\t\t\tcontrols={ controlSets }\n\t\t\t\tclassName={ finalClassName }\n\t\t\t\tchildren={ children }\n\t\t\t\t{ ...props }\n\t\t\t/>\n\t\t);\n\t}\n\n\treturn (\n\t\t<ToolbarGroupContainer className={ finalClassName } { ...props }>\n\t\t\t{ controlSets?.flatMap( ( controlSet, indexOfSet ) =>\n\t\t\t\tcontrolSet.map( ( control, indexOfControl ) => (\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\tkey={ [ indexOfSet, indexOfControl ].join() }\n\t\t\t\t\t\tcontainerClassName={\n\t\t\t\t\t\t\tindexOfSet > 0 && indexOfControl === 0\n\t\t\t\t\t\t\t\t? 'has-left-divider'\n\t\t\t\t\t\t\t\t: null\n\t\t\t\t\t\t}\n\t\t\t\t\t\t{ ...control }\n\t\t\t\t\t/>\n\t\t\t\t) )\n\t\t\t) }\n\t\t\t{ children }\n\t\t</ToolbarGroupContainer>\n\t);\n}\n\nexport default ToolbarGroup;\n"],"mappings":";;;;;;;AAUA,IAAAA,QAAA,GAAAC,OAAA;AALA,IAAAC,WAAA,GAAAC,sBAAA,CAAAF,OAAA;AAUA,IAAAG,cAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,sBAAA,GAAAF,sBAAA,CAAAF,OAAA;AACA,IAAAK,sBAAA,GAAAH,sBAAA,CAAAF,OAAA;AACA,IAAAM,eAAA,GAAAJ,sBAAA,CAAAF,OAAA;AAlBA;;AAEA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASO,YAAYA,CAAE;EACtBC,QAAQ,GAAG,EAAE;EACbC,QAAQ;EACRC,SAAS;EACTC,WAAW;EACXC,KAAK;EACL,GAAGC;AACJ,CAAC,EAAG;EACH;EACA;EACA,MAAMC,sBAAsB,GAAG,IAAAC,mBAAU,EAAEC,uBAAe,CAAC;EAE3D,IAAK,CAAE,CAAER,QAAQ,IAAI,CAAEA,QAAQ,CAACS,MAAM,KAAM,CAAER,QAAQ,EAAG;IACxD,OAAO,IAAI;EACZ;EAEA,MAAMS,cAAc,GAAG,IAAAC,mBAAU;EAChC;EACA;EACAL,sBAAsB,GACnB,0BAA0B,GAC1B,oBAAoB,EACvBJ,SACD,CAAC;;EAED;EACA,IAAIU,WAAW,GAAGZ,QAAQ;EAC1B,IAAK,CAAEa,KAAK,CAACC,OAAO,CAAEF,WAAW,CAAE,CAAC,CAAG,CAAC,EAAG;IAC1CA,WAAW,GAAG,CAAEA,WAAW,CAAE;EAC9B;EAEA,IAAKT,WAAW,EAAG;IAClB,OACC,IAAAZ,QAAA,CAAAwB,aAAA,EAAClB,sBAAA,CAAAmB,OAAqB;MACrBC,KAAK,EAAGb,KAAO;MACfJ,QAAQ,EAAGY,WAAa;MACxBV,SAAS,EAAGQ,cAAgB;MAC5BT,QAAQ,EAAGA,QAAU;MAAA,GAChBI;IAAK,CACV,CAAC;EAEJ;EAEA,OACC,IAAAd,QAAA,CAAAwB,aAAA,EAACnB,sBAAA,CAAAoB,OAAqB;IAACd,SAAS,EAAGQ,cAAgB;IAAA,GAAML;EAAK,GAC3DO,WAAW,EAAEM,OAAO,CAAE,CAAEC,UAAU,EAAEC,UAAU,KAC/CD,UAAU,CAACE,GAAG,CAAE,CAAEC,OAAO,EAAEC,cAAc,KACxC,IAAAhC,QAAA,CAAAwB,aAAA,EAACpB,cAAA,CAAAqB,OAAa;IACbQ,GAAG,EAAG,CAAEJ,UAAU,EAAEG,cAAc,CAAE,CAACE,IAAI,CAAC,CAAG;IAC7CC,kBAAkB,EACjBN,UAAU,GAAG,CAAC,IAAIG,cAAc,KAAK,CAAC,GACnC,kBAAkB,GAClB,IACH;IAAA,GACID;EAAO,CACZ,CACA,CACH,CAAC,EACCrB,QACoB,CAAC;AAE1B;AAAC,IAAA0B,QAAA,GAEc5B,YAAY;AAAA6B,OAAA,CAAAZ,OAAA,GAAAW,QAAA"}
1
+ {"version":3,"names":["_element","require","_classnames","_interopRequireDefault","_toolbarButton","_toolbarGroupContainer","_toolbarGroupCollapsed","_toolbarContext","isNestedArray","arr","Array","isArray","ToolbarGroup","controls","children","className","isCollapsed","title","props","accessibleToolbarState","useContext","ToolbarContext","length","finalClassName","classnames","controlSets","createElement","default","label","flatMap","controlSet","indexOfSet","map","control","indexOfControl","key","join","containerClassName","undefined","_default","exports"],"sources":["@wordpress/components/src/toolbar/toolbar-group/index.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useContext } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport ToolbarButton from '../toolbar-button';\nimport ToolbarGroupContainer from './toolbar-group-container';\nimport ToolbarGroupCollapsed from './toolbar-group-collapsed';\nimport ToolbarContext from '../toolbar-context';\nimport type { ToolbarGroupProps, ToolbarGroupControls } from './types';\n\nfunction isNestedArray< T = any >( arr: T[] | T[][] ): arr is T[][] {\n\treturn Array.isArray( arr ) && Array.isArray( arr[ 0 ] );\n}\n\n/**\n * Renders a collapsible group of controls\n *\n * The `controls` prop accepts an array of sets. A set is an array of controls.\n * Controls have the following shape:\n *\n * ```\n * {\n * icon: string,\n * title: string,\n * subscript: string,\n * onClick: Function,\n * isActive: boolean,\n * isDisabled: boolean\n * }\n * ```\n *\n * For convenience it is also possible to pass only an array of controls. It is\n * then assumed this is the only set.\n *\n * Either `controls` or `children` is required, otherwise this components\n * renders nothing.\n *\n * @param props Component props.\n * @param [props.controls] The controls to render in this toolbar.\n * @param [props.children] Any other things to render inside the toolbar besides the controls.\n * @param [props.className] Class to set on the container div.\n * @param [props.isCollapsed] Turns ToolbarGroup into a dropdown menu.\n * @param [props.title] ARIA label for dropdown menu if is collapsed.\n */\nfunction ToolbarGroup( {\n\tcontrols = [],\n\tchildren,\n\tclassName,\n\tisCollapsed,\n\ttitle,\n\t...props\n}: ToolbarGroupProps ) {\n\t// It'll contain state if `ToolbarGroup` is being used within\n\t// `<Toolbar label=\"label\" />`\n\tconst accessibleToolbarState = useContext( ToolbarContext );\n\n\tif ( ( ! controls || ! controls.length ) && ! children ) {\n\t\treturn null;\n\t}\n\n\tconst finalClassName = classnames(\n\t\t// Unfortunately, there's legacy code referencing to `.components-toolbar`\n\t\t// So we can't get rid of it\n\t\taccessibleToolbarState\n\t\t\t? 'components-toolbar-group'\n\t\t\t: 'components-toolbar',\n\t\tclassName\n\t);\n\n\t// Normalize controls to nested array of objects (sets of controls)\n\tlet controlSets: ToolbarGroupControls[][];\n\tif ( isNestedArray( controls ) ) {\n\t\tcontrolSets = controls;\n\t} else {\n\t\tcontrolSets = [ controls ];\n\t}\n\n\tif ( isCollapsed ) {\n\t\treturn (\n\t\t\t<ToolbarGroupCollapsed\n\t\t\t\tlabel={ title }\n\t\t\t\tcontrols={ controlSets }\n\t\t\t\tclassName={ finalClassName }\n\t\t\t\tchildren={ children }\n\t\t\t\t{ ...props }\n\t\t\t/>\n\t\t);\n\t}\n\n\treturn (\n\t\t<ToolbarGroupContainer className={ finalClassName } { ...props }>\n\t\t\t{ controlSets?.flatMap( ( controlSet, indexOfSet ) =>\n\t\t\t\tcontrolSet.map( ( control, indexOfControl: number ) => (\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\tkey={ [ indexOfSet, indexOfControl ].join() }\n\t\t\t\t\t\tcontainerClassName={\n\t\t\t\t\t\t\tindexOfSet > 0 && indexOfControl === 0\n\t\t\t\t\t\t\t\t? 'has-left-divider'\n\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t}\n\t\t\t\t\t\t{ ...control }\n\t\t\t\t\t/>\n\t\t\t\t) )\n\t\t\t) }\n\t\t\t{ children }\n\t\t</ToolbarGroupContainer>\n\t);\n}\n\nexport default ToolbarGroup;\n"],"mappings":";;;;;;;AAQA,IAAAA,QAAA,GAAAC,OAAA;AALA,IAAAC,WAAA,GAAAC,sBAAA,CAAAF,OAAA;AAUA,IAAAG,cAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,sBAAA,GAAAF,sBAAA,CAAAF,OAAA;AACA,IAAAK,sBAAA,GAAAH,sBAAA,CAAAF,OAAA;AACA,IAAAM,eAAA,GAAAJ,sBAAA,CAAAF,OAAA;AAhBA;AACA;AACA;;AAGA;AACA;AACA;;AAG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Z,SAAS,EAAGQ,cAAgB;IAAA,GAAML;EAAK,GAC3DO,WAAW,EAAEI,OAAO,CAAE,CAAEC,UAAU,EAAEC,UAAU,KAC/CD,UAAU,CAACE,GAAG,CAAE,CAAEC,OAAO,EAAEC,cAAsB,KAChD,IAAAlC,QAAA,CAAA0B,aAAA,EAACtB,cAAA,CAAAuB,OAAa;IACbQ,GAAG,EAAG,CAAEJ,UAAU,EAAEG,cAAc,CAAE,CAACE,IAAI,CAAC,CAAG;IAC7CC,kBAAkB,EACjBN,UAAU,GAAG,CAAC,IAAIG,cAAc,KAAK,CAAC,GACnC,kBAAkB,GAClBI,SACH;IAAA,GACIL;EAAO,CACZ,CACA,CACH,CAAC,EACCnB,QACoB,CAAC;AAE1B;AAAC,IAAAyB,QAAA,GAEc3B,YAAY;AAAA4B,OAAA,CAAAb,OAAA,GAAAY,QAAA"}
@@ -9,8 +9,6 @@ var _element = require("@wordpress/element");
9
9
  var _dropdownMenu = _interopRequireDefault(require("../../dropdown-menu"));
10
10
  var _toolbarContext = _interopRequireDefault(require("../toolbar-context"));
11
11
  var _toolbarItem = _interopRequireDefault(require("../toolbar-item"));
12
- // @ts-nocheck
13
-
14
12
  /**
15
13
  * WordPress dependencies
16
14
  */
@@ -1 +1 @@
1
- {"version":3,"names":["_element","require","_dropdownMenu","_interopRequireDefault","_toolbarContext","_toolbarItem","ToolbarGroupCollapsed","controls","toggleProps","props","accessibleToolbarState","useContext","ToolbarContext","renderDropdownMenu","internalToggleProps","createElement","default","_default","exports"],"sources":["@wordpress/components/src/toolbar/toolbar-group/toolbar-group-collapsed.js"],"sourcesContent":["// @ts-nocheck\n\n/**\n * WordPress dependencies\n */\nimport { useContext } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport DropdownMenu from '../../dropdown-menu';\nimport ToolbarContext from '../toolbar-context';\nimport ToolbarItem from '../toolbar-item';\n\nfunction ToolbarGroupCollapsed( { controls = [], toggleProps, ...props } ) {\n\t// It'll contain state if `ToolbarGroup` is being used within\n\t// `<Toolbar label=\"label\" />`\n\tconst accessibleToolbarState = useContext( ToolbarContext );\n\n\tconst renderDropdownMenu = ( internalToggleProps ) => (\n\t\t<DropdownMenu\n\t\t\tcontrols={ controls }\n\t\t\ttoggleProps={ {\n\t\t\t\t...internalToggleProps,\n\t\t\t\t'data-toolbar-item': true,\n\t\t\t} }\n\t\t\t{ ...props }\n\t\t/>\n\t);\n\n\tif ( accessibleToolbarState ) {\n\t\treturn (\n\t\t\t<ToolbarItem { ...toggleProps }>{ renderDropdownMenu }</ToolbarItem>\n\t\t);\n\t}\n\n\treturn renderDropdownMenu( toggleProps );\n}\n\nexport default ToolbarGroupCollapsed;\n"],"mappings":";;;;;;;AAKA,IAAAA,QAAA,GAAAC,OAAA;AAKA,IAAAC,aAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,eAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,YAAA,GAAAF,sBAAA,CAAAF,OAAA;AAZA;;AAEA;AACA;AACA;;AAGA;AACA;AACA;;AAKA,SAASK,qBAAqBA,CAAE;EAAEC,QAAQ,GAAG,EAAE;EAAEC,WAAW;EAAE,GAAGC;AAAM,CAAC,EAAG;EAC1E;EACA;EACA,MAAMC,sBAAsB,GAAG,IAAAC,mBAAU,EAAEC,uBAAe,CAAC;EAE3D,MAAMC,kBAAkB,GAAKC,mBAAmB,IAC/C,IAAAd,QAAA,CAAAe,aAAA,EAACb,aAAA,CAAAc,OAAY;IACZT,QAAQ,EAAGA,QAAU;IACrBC,WAAW,EAAG;MACb,GAAGM,mBAAmB;MACtB,mBAAmB,EAAE;IACtB,CAAG;IAAA,GACEL;EAAK,CACV,CACD;EAED,IAAKC,sBAAsB,EAAG;IAC7B,OACC,IAAAV,QAAA,CAAAe,aAAA,EAACV,YAAA,CAAAW,OAAW;MAAA,GAAMR;IAAW,GAAKK,kBAAiC,CAAC;EAEtE;EAEA,OAAOA,kBAAkB,CAAEL,WAAY,CAAC;AACzC;AAAC,IAAAS,QAAA,GAEcX,qBAAqB;AAAAY,OAAA,CAAAF,OAAA,GAAAC,QAAA"}
1
+ {"version":3,"names":["_element","require","_dropdownMenu","_interopRequireDefault","_toolbarContext","_toolbarItem","ToolbarGroupCollapsed","controls","toggleProps","props","accessibleToolbarState","useContext","ToolbarContext","renderDropdownMenu","internalToggleProps","createElement","default","_default","exports"],"sources":["@wordpress/components/src/toolbar/toolbar-group/toolbar-group-collapsed.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useContext } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport DropdownMenu from '../../dropdown-menu';\nimport ToolbarContext from '../toolbar-context';\nimport ToolbarItem from '../toolbar-item';\nimport type { ToolbarGroupCollapsedProps } from './types';\nimport type { DropdownMenuProps } from '../../dropdown-menu/types';\n\nfunction ToolbarGroupCollapsed( {\n\tcontrols = [],\n\ttoggleProps,\n\t...props\n}: ToolbarGroupCollapsedProps ) {\n\t// It'll contain state if `ToolbarGroup` is being used within\n\t// `<Toolbar label=\"label\" />`\n\tconst accessibleToolbarState = useContext( ToolbarContext );\n\n\tconst renderDropdownMenu = (\n\t\tinternalToggleProps?: DropdownMenuProps[ 'toggleProps' ]\n\t) => (\n\t\t<DropdownMenu\n\t\t\tcontrols={ controls }\n\t\t\ttoggleProps={ {\n\t\t\t\t...internalToggleProps,\n\t\t\t\t'data-toolbar-item': true,\n\t\t\t} }\n\t\t\t{ ...props }\n\t\t/>\n\t);\n\n\tif ( accessibleToolbarState ) {\n\t\treturn (\n\t\t\t<ToolbarItem { ...toggleProps }>{ renderDropdownMenu }</ToolbarItem>\n\t\t);\n\t}\n\n\treturn renderDropdownMenu( toggleProps );\n}\n\nexport default ToolbarGroupCollapsed;\n"],"mappings":";;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AAKA,IAAAC,aAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,eAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,YAAA,GAAAF,sBAAA,CAAAF,OAAA;AAVA;AACA;AACA;;AAGA;AACA;AACA;;AAOA,SAASK,qBAAqBA,CAAE;EAC/BC,QAAQ,GAAG,EAAE;EACbC,WAAW;EACX,GAAGC;AACwB,CAAC,EAAG;EAC/B;EACA;EACA,MAAMC,sBAAsB,GAAG,IAAAC,mBAAU,EAAEC,uBAAe,CAAC;EAE3D,MAAMC,kBAAkB,GACvBC,mBAAwD,IAExD,IAAAd,QAAA,CAAAe,aAAA,EAACb,aAAA,CAAAc,OAAY;IACZT,QAAQ,EAAGA,QAAU;IACrBC,WAAW,EAAG;MACb,GAAGM,mBAAmB;MACtB,mBAAmB,EAAE;IACtB,CAAG;IAAA,GACEL;EAAK,CACV,CACD;EAED,IAAKC,sBAAsB,EAAG;IAC7B,OACC,IAAAV,QAAA,CAAAe,aAAA,EAACV,YAAA,CAAAW,OAAW;MAAA,GAAMR;IAAW,GAAKK,kBAAiC,CAAC;EAEtE;EAEA,OAAOA,kBAAkB,CAAEL,WAAY,CAAC;AACzC;AAAC,IAAAS,QAAA,GAEcX,qBAAqB;AAAAY,OAAA,CAAAF,OAAA,GAAAC,QAAA"}
@@ -5,7 +5,9 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  var _element = require("@wordpress/element");
8
- // @ts-nocheck
8
+ /**
9
+ * Internal dependencies
10
+ */
9
11
 
10
12
  const ToolbarGroupContainer = ({
11
13
  className,
@@ -1 +1 @@
1
- {"version":3,"names":["ToolbarGroupContainer","className","children","props","_element","createElement","_default","exports","default"],"sources":["@wordpress/components/src/toolbar/toolbar-group/toolbar-group-container.js"],"sourcesContent":["// @ts-nocheck\n\nconst ToolbarGroupContainer = ( { className, children, ...props } ) => (\n\t<div className={ className } { ...props }>\n\t\t{ children }\n\t</div>\n);\nexport default ToolbarGroupContainer;\n"],"mappings":";;;;;;;AAAA;;AAEA,MAAMA,qBAAqB,GAAGA,CAAE;EAAEC,SAAS;EAAEC,QAAQ;EAAE,GAAGC;AAAM,CAAC,KAChE,IAAAC,QAAA,CAAAC,aAAA;EAAKJ,SAAS,EAAGA,SAAW;EAAA,GAAME;AAAK,GACpCD,QACE,CACL;AAAC,IAAAI,QAAA,GACaN,qBAAqB;AAAAO,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
1
+ {"version":3,"names":["ToolbarGroupContainer","className","children","props","_element","createElement","_default","exports","default"],"sources":["@wordpress/components/src/toolbar/toolbar-group/toolbar-group-container.tsx"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport type { WordPressComponentProps } from '../../ui/context';\nimport type { ToolbarGroupContainerProps } from './types';\n\nconst ToolbarGroupContainer = ( {\n\tclassName,\n\tchildren,\n\t...props\n}: WordPressComponentProps< ToolbarGroupContainerProps, 'div', false > ) => (\n\t<div className={ className } { ...props }>\n\t\t{ children }\n\t</div>\n);\nexport default ToolbarGroupContainer;\n"],"mappings":";;;;;;;AAAA;AACA;AACA;;AAIA,MAAMA,qBAAqB,GAAGA,CAAE;EAC/BC,SAAS;EACTC,QAAQ;EACR,GAAGC;AACiE,CAAC,KACrE,IAAAC,QAAA,CAAAC,aAAA;EAAKJ,SAAS,EAAGA,SAAW;EAAA,GAAME;AAAK,GACpCD,QACE,CACL;AAAC,IAAAI,QAAA,GACaN,qBAAqB;AAAAO,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["@wordpress/components/src/toolbar/toolbar-group/types.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { ReactNode } from 'react';\n\n/**\n * Internal dependencies\n */\nimport type {\n\tDropdownMenuProps,\n\tDropdownOption,\n} from '../../dropdown-menu/types';\n\n/**\n * WordPress dependencies\n */\nimport type { Props as IconProps } from '../../icon';\n\nexport type ToolbarGroupControls = DropdownOption & {\n\t/**\n\t * An optional subscript associated to the control.\n\t */\n\tsubscript?: string;\n};\n\ntype ToolbarGroupPropsBase = {\n\t/**\n\t * The controls to render in this toolbar.\n\t */\n\tcontrols?: ToolbarGroupControls[] | ToolbarGroupControls[][];\n\n\t/**\n\t * Class to set on the container div.\n\t */\n\tclassName?: string;\n\n\t/**\n\t * Any other things to render inside the toolbar besides the controls.\n\t */\n\tchildren?: ReactNode;\n\n\t/**\n\t * The Dashicon icon slug to be shown for the option.\n\t */\n\ticon?: IconProps[ 'icon' ];\n};\n\nexport type ToolbarGroupProps = ToolbarGroupPropsBase &\n\t(\n\t\t| {\n\t\t\t\t/**\n\t\t\t\t * When true, turns `ToolbarGroup` into a dropdown menu.\n\t\t\t\t */\n\t\t\t\tisCollapsed?: false;\n\t\t\t\t/**\n\t\t\t\t * Any other things to render inside the toolbar besides the controls.\n\t\t\t\t */\n\t\t\t\tchildren?: ReactNode;\n\t\t\t\ttitle?: never;\n\t\t }\n\t\t| {\n\t\t\t\t/**\n\t\t\t\t * When true, turns `ToolbarGroup` into a dropdown menu.\n\t\t\t\t */\n\t\t\t\tisCollapsed: true;\n\t\t\t\t/**\n\t\t\t\t * Any other things to render inside the toolbar besides the controls.\n\t\t\t\t */\n\t\t\t\tchildren?: ToolbarGroupCollapsedProps[ 'children' ];\n\t\t\t\t/**\n\t\t\t\t * ARIA label for dropdown menu if is collapsed.\n\t\t\t\t */\n\t\t\t\ttitle: string;\n\t\t }\n\t);\n\nexport type ToolbarGroupCollapsedProps = DropdownMenuProps;\n\nexport type ToolbarGroupContainerProps = {\n\t/**\n\t * Children to be rendered inside the toolbar.\n\t */\n\tchildren?: ReactNode;\n\t/**\n\t * Class to set on the container div.\n\t */\n\tclassName?: string;\n\t/**\n\t * Props to be passed.\n\t */\n\tprops?: any;\n};\n"],"mappings":""}
@@ -48,7 +48,7 @@ function ToolbarItem({
48
48
  }
49
49
  return children(allProps);
50
50
  }
51
- const render = isRenderProp ? children : Component && (0, _element.createElement)(Component, null);
51
+ const render = isRenderProp ? children : Component && (0, _element.createElement)(Component, null, children);
52
52
  return (0, _element.createElement)(_toolbar.ToolbarItem, {
53
53
  ...allProps,
54
54
  store: accessibleToolbarStore,
@@ -1 +1 @@
1
- {"version":3,"names":["_element","require","_toolbar","_warning","_interopRequireDefault","_toolbarContext","ToolbarItem","children","as","Component","props","ref","accessibleToolbarStore","useContext","ToolbarContext","isRenderProp","SCRIPT_DEBUG","warning","allProps","createElement","render","store","_default","forwardRef","exports","default"],"sources":["@wordpress/components/src/toolbar/toolbar-item/index.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport { ToolbarItem as BaseToolbarItem } from '@ariakit/react/toolbar';\nimport type { ForwardedRef } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { forwardRef, useContext } from '@wordpress/element';\nimport warning from '@wordpress/warning';\n\n/**\n * Internal dependencies\n */\nimport ToolbarContext from '../toolbar-context';\nimport type { ToolbarItemProps } from './types';\n\nfunction ToolbarItem(\n\t{ children, as: Component, ...props }: ToolbarItemProps,\n\tref: ForwardedRef< any >\n) {\n\tconst accessibleToolbarStore = useContext( ToolbarContext );\n\tconst isRenderProp = typeof children === 'function';\n\n\tif ( ! isRenderProp && ! Component ) {\n\t\twarning(\n\t\t\t'`ToolbarItem` is a generic headless component. You must pass either a `children` prop as a function or an `as` prop as a component. ' +\n\t\t\t\t'See https://developer.wordpress.org/block-editor/components/toolbar-item/'\n\t\t);\n\t\treturn null;\n\t}\n\n\tconst allProps = { ...props, ref, 'data-toolbar-item': true };\n\n\tif ( ! accessibleToolbarStore ) {\n\t\tif ( Component ) {\n\t\t\treturn <Component { ...allProps }>{ children }</Component>;\n\t\t}\n\t\tif ( ! isRenderProp ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn children( allProps );\n\t}\n\n\tconst render = isRenderProp ? children : Component && <Component />;\n\n\treturn (\n\t\t<BaseToolbarItem\n\t\t\t{ ...allProps }\n\t\t\tstore={ accessibleTo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;IACbG,KAAK,EAAGT,sBAAwB;IAChCQ,MAAM,EAAGA;EAAQ,CACjB,CAAC;AAEJ;AAAC,IAAAE,QAAA,GAEc,IAAAC,mBAAU,EAAEjB,WAAY,CAAC;AAAAkB,OAAA,CAAAC,OAAA,GAAAH,QAAA"}
1
+ {"version":3,"names":["_element","require","_toolbar","_warning","_interopRequireDefault","_toolbarContext","ToolbarItem","children","as","Component","props","ref","accessibleToolbarStore","useContext","ToolbarContext","isRenderProp","SCRIPT_DEBUG","warning","allProps","createElement","render","store","_default","forwardRef","exports","default"],"sources":["@wordpress/components/src/toolbar/toolbar-item/index.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport { ToolbarItem as BaseToolbarItem } from '@ariakit/react/toolbar';\nimport type { ForwardedRef } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { forwardRef, useContext } from '@wordpress/element';\nimport warning from '@wordpress/warning';\n\n/**\n * Internal dependencies\n */\nimport ToolbarContext from '../toolbar-context';\nimport type { ToolbarItemProps } from './types';\n\nfunction ToolbarItem(\n\t{ children, as: Component, ...props }: ToolbarItemProps,\n\tref: ForwardedRef< any >\n) {\n\tconst accessibleToolbarStore = useContext( ToolbarContext );\n\tconst isRenderProp = typeof children === 'function';\n\n\tif ( ! isRenderProp && ! Component ) {\n\t\twarning(\n\t\t\t'`ToolbarItem` is a generic headless component. You must pass either a `children` prop as a function or an `as` prop as a component. ' +\n\t\t\t\t'See https://developer.wordpress.org/block-editor/components/toolbar-item/'\n\t\t);\n\t\treturn null;\n\t}\n\n\tconst allProps = { ...props, ref, 'data-toolbar-item': true };\n\n\tif ( ! accessibleToolbarStore ) {\n\t\tif ( Component ) {\n\t\t\treturn <Component { ...allProps }>{ children }</Component>;\n\t\t}\n\t\tif ( ! isRenderProp ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn children( allProps );\n\t}\n\n\tconst render = isRenderProp\n\t\t? children\n\t\t: Component && <Component>{ children }</Component>;\n\n\treturn (\n\t\t<BaseToolbar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AAA,EAACjB,QAAA,CAAAI,WAAe;IAAA,GACVY,QAAQ;IACbG,KAAK,EAAGT,sBAAwB;IAChCQ,MAAM,EAAGA;EAAQ,CACjB,CAAC;AAEJ;AAAC,IAAAE,QAAA,GAEc,IAAAC,mBAAU,EAAEjB,WAAY,CAAC;AAAAkB,OAAA,CAAAC,OAAA,GAAAH,QAAA"}
@@ -6,12 +6,13 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.default = exports.TOOLTIP_DELAY = void 0;
8
8
  var _element = require("@wordpress/element");
9
- var _classnames = _interopRequireDefault(require("classnames"));
9
+ var Ariakit = _interopRequireWildcard(require("@ariakit/react/tooltip"));
10
10
  var _compose = require("@wordpress/compose");
11
- var _popover = _interopRequireDefault(require("../popover"));
11
+ var _deprecated = _interopRequireDefault(require("@wordpress/deprecated"));
12
12
  var _shortcut = _interopRequireDefault(require("../shortcut"));
13
- // @ts-nocheck
14
-
13
+ var _utils = require("../popover/utils");
14
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
15
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
15
16
  /**
16
17
  * External dependencies
17
18
  */
@@ -21,241 +22,66 @@ var _shortcut = _interopRequireDefault(require("../shortcut"));
21
22
  */
22
23
 
23
24
  /**
24
- * Internal dependencies
25
- */
26
-
27
- /**
28
- * Time over children to wait before showing tooltip
29
- *
30
- * @type {number}
25
+ * Time over anchor to wait before showing tooltip
31
26
  */
32
27
  const TOOLTIP_DELAY = 700;
33
28
  exports.TOOLTIP_DELAY = TOOLTIP_DELAY;
34
- const eventCatcher = (0, _element.createElement)("div", {
35
- className: "event-catcher"
36
- });
37
- const getDisabledElement = ({
38
- eventHandlers,
39
- child,
40
- childrenWithPopover,
41
- mergedRefs
42
- }) => {
43
- return (0, _element.cloneElement)((0, _element.createElement)("span", {
44
- className: "disabled-element-wrapper"
45
- }, (0, _element.cloneElement)(eventCatcher, eventHandlers), (0, _element.cloneElement)(child, {
46
- children: childrenWithPopover,
47
- ref: mergedRefs
48
- })), {
49
- ...eventHandlers
50
- });
51
- };
52
- const getRegularElement = ({
53
- child,
54
- eventHandlers,
55
- childrenWithPopover,
56
- mergedRefs
57
- }) => {
58
- return (0, _element.cloneElement)(child, {
59
- ...eventHandlers,
60
- children: childrenWithPopover,
61
- ref: mergedRefs
62
- });
63
- };
64
- const addPopoverToGrandchildren = ({
65
- anchor,
66
- grandchildren,
67
- isOver,
68
- offset,
69
- position,
70
- shortcut,
71
- text,
72
- className,
73
- ...props
74
- }) => (0, _element.concatChildren)(grandchildren, isOver && (0, _element.createElement)(_popover.default, {
75
- focusOnMount: false,
76
- position: position,
77
- className: (0, _classnames.default)('components-tooltip', className),
78
- "aria-hidden": "true",
79
- animate: false,
80
- offset: offset,
81
- anchor: anchor,
82
- shift: true,
83
- ...props
84
- }, text, (0, _element.createElement)(_shortcut.default, {
85
- className: "components-tooltip__shortcut",
86
- shortcut: shortcut
87
- })));
88
- const emitToChild = (children, eventName, event) => {
89
- if (_element.Children.count(children) !== 1) {
90
- return;
91
- }
92
- const child = _element.Children.only(children);
93
-
94
- // If the underlying element is disabled, do not emit the event.
95
- if (child.props.disabled) {
96
- return;
97
- }
98
- if (typeof child.props[eventName] === 'function') {
99
- child.props[eventName](event);
100
- }
101
- };
102
29
  function Tooltip(props) {
103
30
  const {
104
31
  children,
105
- position = 'bottom middle',
106
- text,
107
- shortcut,
108
32
  delay = TOOLTIP_DELAY,
109
- ...popoverProps
33
+ hideOnClick = true,
34
+ placement,
35
+ position,
36
+ shortcut,
37
+ text
110
38
  } = props;
111
- /**
112
- * Whether a mouse is currently pressed, used in determining whether
113
- * to handle a focus event as displaying the tooltip immediately.
114
- *
115
- * @type {boolean}
116
- */
117
- const [isMouseDown, setIsMouseDown] = (0, _element.useState)(false);
118
- const [isOver, setIsOver] = (0, _element.useState)(false);
119
- const delayedSetIsOver = (0, _compose.useDebounce)(setIsOver, delay);
120
- // Using internal state (instead of a ref) for the popover anchor to make sure
121
- // that the component re-renders when the anchor updates.
122
- const [popoverAnchor, setPopoverAnchor] = (0, _element.useState)(null);
123
-
124
- // Create a reference to the Tooltip's child, to be passed to the Popover
125
- // so that the Tooltip can be correctly positioned. Also, merge with the
126
- // existing ref for the first child, so that its ref is preserved.
127
- const existingChildRef = _element.Children.toArray(children)[0]?.ref;
128
- const mergedChildRefs = (0, _compose.useMergeRefs)([setPopoverAnchor, existingChildRef]);
129
- const createMouseDown = event => {
130
- // In firefox, the mouse down event is also fired when the select
131
- // list is chosen.
132
- // Cancel further processing because re-rendering of child components
133
- // causes onChange to be triggered with the old value.
134
- // See https://github.com/WordPress/gutenberg/pull/42483
135
- if (event.target.tagName === 'OPTION') {
136
- return;
137
- }
138
-
139
- // Preserve original child callback behavior.
140
- emitToChild(children, 'onMouseDown', event);
141
-
142
- // On mouse down, the next `mouseup` should revert the value of the
143
- // instance property and remove its own event handler. The bind is
144
- // made on the document since the `mouseup` might not occur within
145
- // the bounds of the element.
146
- document.addEventListener('mouseup', cancelIsMouseDown);
147
- setIsMouseDown(true);
148
- };
149
- const createMouseUp = event => {
150
- // In firefox, the mouse up event is also fired when the select
151
- // list is chosen.
152
- // Cancel further processing because re-rendering of child components
153
- // causes onChange to be triggered with the old value.
154
- // See https://github.com/WordPress/gutenberg/pull/42483
155
- if (event.target.tagName === 'OPTION') {
156
- return;
157
- }
158
- emitToChild(children, 'onMouseUp', event);
159
- document.removeEventListener('mouseup', cancelIsMouseDown);
160
- setIsMouseDown(false);
161
- };
162
- const createMouseEvent = type => {
163
- if (type === 'mouseUp') return createMouseUp;
164
- if (type === 'mouseDown') return createMouseDown;
165
- };
166
-
167
- /**
168
- * Prebound `isInMouseDown` handler, created as a constant reference to
169
- * assure ability to remove in component unmount.
170
- *
171
- * @type {Function}
172
- */
173
- const cancelIsMouseDown = createMouseEvent('mouseUp');
174
- const createToggleIsOver = (eventName, isDelayed) => {
175
- return event => {
176
- // Preserve original child callback behavior.
177
- emitToChild(children, eventName, event);
178
-
179
- // Mouse events behave unreliably in React for disabled elements,
180
- // firing on mouseenter but not mouseleave. Further, the default
181
- // behavior for disabled elements in some browsers is to ignore
182
- // mouse events. Don't bother trying to handle them.
183
- //
184
- // See: https://github.com/facebook/react/issues/4251
185
- if (event.currentTarget.disabled) {
186
- return;
187
- }
188
-
189
- // A focus event will occur as a result of a mouse click, but it
190
- // should be disambiguated between interacting with the button and
191
- // using an explicit focus shift as a cue to display the tooltip.
192
- if ('focus' === event.type && isMouseDown) {
193
- return;
194
- }
195
-
196
- // Needed in case unsetting is over while delayed set pending, i.e.
197
- // quickly blur/mouseleave before delayedSetIsOver is called.
198
- delayedSetIsOver.cancel();
199
- const _isOver = ['focus', 'mouseenter'].includes(event.type);
200
- if (_isOver === isOver) {
201
- return;
202
- }
203
- if (isDelayed) {
204
- delayedSetIsOver(_isOver);
205
- } else {
206
- setIsOver(_isOver);
207
- }
208
- };
209
- };
210
- const clearOnUnmount = () => {
211
- delayedSetIsOver.cancel();
212
- document.removeEventListener('mouseup', cancelIsMouseDown);
213
- };
214
-
215
- // Ignore reason: updating the deps array here could cause unexpected changes in behavior.
216
- // Deferring until a more detailed investigation/refactor can be performed.
217
- // eslint-disable-next-line react-hooks/exhaustive-deps
218
- (0, _element.useEffect)(() => clearOnUnmount, []);
219
- if (_element.Children.count(children) !== 1) {
39
+ const baseId = (0, _compose.useInstanceId)(Tooltip, 'tooltip');
40
+ const describedById = text || shortcut ? baseId : undefined;
41
+ const isOnlyChild = _element.Children.count(children) === 1;
42
+ // console error if more than one child element is added
43
+ if (!isOnlyChild) {
220
44
  if ('development' === process.env.NODE_ENV) {
221
45
  // eslint-disable-next-line no-console
222
46
  console.error('Tooltip should be called with only a single child element.');
223
47
  }
224
- return children;
225
48
  }
226
- const eventHandlers = {
227
- onMouseEnter: createToggleIsOver('onMouseEnter', true),
228
- onMouseLeave: createToggleIsOver('onMouseLeave'),
229
- onClick: createToggleIsOver('onClick'),
230
- onFocus: createToggleIsOver('onFocus'),
231
- onBlur: createToggleIsOver('onBlur'),
232
- onMouseDown: createMouseEvent('mouseDown')
233
- };
234
- const child = _element.Children.only(children);
235
- const {
236
- children: grandchildren,
237
- disabled
238
- } = child.props;
239
- const getElementWithPopover = disabled ? getDisabledElement : getRegularElement;
240
- const popoverData = {
241
- anchor: popoverAnchor,
242
- isOver,
243
- offset: 4,
244
- position,
245
- shortcut,
246
- text
247
- };
248
- const childrenWithPopover = addPopoverToGrandchildren({
249
- grandchildren,
250
- ...popoverData,
251
- ...popoverProps
252
- });
253
- return getElementWithPopover({
254
- child,
255
- eventHandlers,
256
- childrenWithPopover,
257
- mergedRefs: mergedChildRefs
49
+
50
+ // Compute tooltip's placement:
51
+ // - give priority to `placement` prop, if defined
52
+ // - otherwise, compute it from the legacy `position` prop (if defined)
53
+ // - finally, fallback to the default placement: 'bottom'
54
+ let computedPlacement;
55
+ if (placement !== undefined) {
56
+ computedPlacement = placement;
57
+ } else if (position !== undefined) {
58
+ computedPlacement = (0, _utils.positionToPlacement)(position);
59
+ (0, _deprecated.default)('`position` prop in wp.components.tooltip', {
60
+ since: '6.4',
61
+ alternative: '`placement` prop'
62
+ });
63
+ }
64
+ computedPlacement = computedPlacement || 'bottom';
65
+ const tooltipStore = Ariakit.useTooltipStore({
66
+ placement: computedPlacement,
67
+ timeout: delay
258
68
  });
69
+ const isTooltipOpen = tooltipStore.useState('open');
70
+ return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(Ariakit.TooltipAnchor, {
71
+ onBlur: tooltipStore.hide,
72
+ onClick: hideOnClick ? tooltipStore.hide : undefined,
73
+ store: tooltipStore,
74
+ render: isOnlyChild ? children : undefined
75
+ }, isOnlyChild ? undefined : children), isOnlyChild && (text || shortcut) && isTooltipOpen && (0, _element.createElement)(Ariakit.Tooltip, {
76
+ className: "components-tooltip",
77
+ gutter: 4,
78
+ id: describedById,
79
+ overflowPadding: 0.5,
80
+ store: tooltipStore
81
+ }, text, shortcut && (0, _element.createElement)(_shortcut.default, {
82
+ className: text ? 'components-tooltip__shortcut' : '',
83
+ shortcut: shortcut
84
+ })));
259
85
  }
260
86
  var _default = Tooltip;
261
87
  exports.default = _default;
@@ -1 +1 @@
1
- {"version":3,"names":["_element","require","_classnames","_interopRequireDefault","_compose","_popover","_shortcut","TOOLTIP_DELAY","exports","eventCatcher","createElement","className","getDisabledElement","eventHandlers","child","childrenWithPopover","mergedRefs","cloneElement","children","ref","getRegularElement","addPopoverToGrandchildren","anchor","grandchildren","isOver","offset","position","shortcut","text","props","concatChildren","default","focusOnMount","classNames","animate","shift","emitToChild","eventName","event","Children","count","only","disabled","Tooltip","delay","popoverProps","isMouseDown","setIsMouseDown","useState","setIsOver","delayedSetIsOver","useDebounce","popoverAnchor","setPopoverAnchor","existingChildRef","toArray","mergedChildRefs","useMergeRefs","createMouseDown","target","tagName","document","addEventListener","cancelIsMouseDown","createMouseUp","removeEventListener","createMouseEvent","type","createToggleIsOver","isDelayed","currentTarget","cancel","_isOver","includes","clearOnUnmount","useEffect","process","env","NODE_ENV","console","error","onMouseEnter","onMouseLeave","onClick","onFocus","onBlur","onMouseDown","getElementWithPopover","popoverData","_default"],"sources":["@wordpress/components/src/tooltip/index.js"],"sourcesContent":["// @ts-nocheck\n\n/**\n * External dependencies\n */\nimport classNames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tChildren,\n\tcloneElement,\n\tconcatChildren,\n\tuseEffect,\n\tuseState,\n} from '@wordpress/element';\nimport { useDebounce, useMergeRefs } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport Popover from '../popover';\nimport Shortcut from '../shortcut';\n\n/**\n * Time over children to wait before showing tooltip\n *\n * @type {number}\n */\nexport const TOOLTIP_DELAY = 700;\n\nconst eventCatcher = <div className=\"event-catcher\" />;\n\nconst getDisabledElement = ( {\n\teventHandlers,\n\tchild,\n\tchildrenWithPopover,\n\tmergedRefs,\n} ) => {\n\treturn cloneElement(\n\t\t<span className=\"disabled-element-wrapper\">\n\t\t\t{ cloneElement( eventCatcher, eventHandlers ) }\n\t\t\t{ cloneElement( child, {\n\t\t\t\tchildren: childrenWithPopover,\n\t\t\t\tref: mergedRefs,\n\t\t\t} ) }\n\t\t</span>,\n\t\t{ ...eventHandlers }\n\t);\n};\n\nconst getRegularElement = ( {\n\tchild,\n\teventHandlers,\n\tchildrenWithPopover,\n\tmergedRefs,\n} ) => {\n\treturn cloneElement( child, {\n\t\t...eventHandlers,\n\t\tchildren: childrenWithPopover,\n\t\tref: mergedRefs,\n\t} );\n};\n\nconst addPopoverToGrandchildren = ( {\n\tanchor,\n\tgrandchildren,\n\tisOver,\n\toffset,\n\tposition,\n\tshortcut,\n\ttext,\n\tclassName,\n\t...props\n} ) =>\n\tconcatChildren(\n\t\tgrandchildren,\n\t\tisOver && (\n\t\t\t<Popover\n\t\t\t\tfocusOnMount={ false }\n\t\t\t\tposition={ position }\n\t\t\t\tclassName={ classNames( 'components-tooltip', className ) }\n\t\t\t\taria-hidden=\"true\"\n\t\t\t\tanimate={ false }\n\t\t\t\toffset={ offset }\n\t\t\t\tanchor={ anchor }\n\t\t\t\tshift\n\t\t\t\t{ ...props }\n\t\t\t>\n\t\t\t\t{ text }\n\t\t\t\t<Shortcut\n\t\t\t\t\tclassName=\"components-tooltip__shortcut\"\n\t\t\t\t\tshortcut={ shortcut }\n\t\t\t\t/>\n\t\t\t</Popover>\n\t\t)\n\t);\n\nconst emitToChild = ( children, eventName, event ) => {\n\tif ( Children.count( children ) !== 1 ) {\n\t\treturn;\n\t}\n\n\tconst child = Children.only( children );\n\n\t// If the underlying element is disabled, do not emit the event.\n\tif ( child.props.disabled ) {\n\t\treturn;\n\t}\n\n\tif ( typeof child.props[ eventName ] === 'function' ) {\n\t\tchild.props[ eventName ]( event );\n\t}\n};\n\nfunction Tooltip( props ) {\n\tconst {\n\t\tchildren,\n\t\tposition = 'bottom middle',\n\t\ttext,\n\t\tshortcut,\n\t\tdelay = TOOLTIP_DELAY,\n\t\t...popoverProps\n\t} = props;\n\t/**\n\t * Whether a mouse is currently pressed, used in determining whether\n\t * to handle a focus event as displaying the tooltip immediately.\n\t *\n\t * @type {boolean}\n\t */\n\tconst [ isMouseDown, setIsMouseDown ] = useState( false );\n\tconst [ isOver, setIsOver ] = useState( false );\n\tconst delayedSetIsOver = useDebounce( setIsOver, delay );\n\t// Using internal state (instead of a ref) for the popover anchor to make sure\n\t// that the component re-renders when the anchor updates.\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState( null );\n\n\t// Create a reference to the Tooltip's child, to be passed to the Popover\n\t// so that the Tooltip can be correctly positioned. Also, merge with the\n\t// existing ref for the first child, so that its ref is preserved.\n\tconst existingChildRef = Children.toArray( children )[ 0 ]?.ref;\n\tconst mergedChildRefs = useMergeRefs( [\n\t\tsetPopoverAnchor,\n\t\texistingChildRef,\n\t] );\n\n\tconst createMouseDown = ( event ) => {\n\t\t// In firefox, the mouse down event is also fired when the select\n\t\t// list is chosen.\n\t\t// Cancel further processing because re-rendering of child components\n\t\t// causes onChange to be triggered with the old value.\n\t\t// See https://github.com/WordPress/gutenberg/pull/42483\n\t\tif ( event.target.tagName === 'OPTION' ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Preserve original child callback behavior.\n\t\temitToChild( children, 'onMouseDown', event );\n\n\t\t// On mouse down, the next `mouseup` should revert the value of the\n\t\t// instance property and remove its own event handler. The bind is\n\t\t// made on the document since the `mouseup` might not occur within\n\t\t// the bounds of the element.\n\t\tdocument.addEventListener( 'mouseup', cancelIsMouseDown );\n\t\tsetIsMouseDown( true );\n\t};\n\n\tconst createMouseUp = ( event ) => {\n\t\t// In firefox, the mouse up event is also fired when the select\n\t\t// list is chosen.\n\t\t// Cancel further processing because re-rendering of child components\n\t\t// causes onChange to be triggered with the old value.\n\t\t// See https://github.com/WordPress/gutenberg/pull/42483\n\t\tif ( event.target.tagName === 'OPTION' ) {\n\t\t\treturn;\n\t\t}\n\n\t\temitToChild( children, 'onMouseUp', event );\n\t\tdocument.removeEventListener( 'mouseup', cancelIsMouseDown );\n\t\tsetIsMouseDown( false );\n\t};\n\n\tconst createMouseEvent = ( type ) => {\n\t\tif ( type === 'mouseUp' ) return createMouseUp;\n\t\tif ( type === 'mouseDown' ) return createMouseDown;\n\t};\n\n\t/**\n\t * Prebound `isInMouseDown` handler, created as a constant reference to\n\t * assure ability to remove in component unmount.\n\t *\n\t * @type {Function}\n\t */\n\tconst cancelIsMouseDown = createMouseEvent( 'mouseUp' );\n\n\tconst createToggleIsOver = ( eventName, isDelayed ) => {\n\t\treturn ( event ) => {\n\t\t\t// Preserve original child callback behavior.\n\t\t\temitToChild( children, eventName, event );\n\n\t\t\t// Mouse events behave unreliably in React for disabled elements,\n\t\t\t// firing on mouseenter but not mouseleave. Further, the default\n\t\t\t// behavior for disabled elements in some browsers is to ignore\n\t\t\t// mouse events. Don't bother trying to handle them.\n\t\t\t//\n\t\t\t// See: https://github.com/facebook/react/issues/4251\n\t\t\tif ( event.currentTarget.disabled ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// A focus event will occur as a result of a mouse click, but it\n\t\t\t// should be disambiguated between interacting with the button and\n\t\t\t// using an explicit focus shift as a cue to display the tooltip.\n\t\t\tif ( 'focus' === event.type && isMouseDown ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Needed in case unsetting is over while delayed set pending, i.e.\n\t\t\t// quickly blur/mouseleave before delayedSetIsOver is called.\n\t\t\tdelayedSetIsOver.cancel();\n\n\t\t\tconst _isOver = [ 'focus', 'mouseenter' ].includes( event.type );\n\t\t\tif ( _isOver === isOver ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( isDelayed ) {\n\t\t\t\tdelayedSetIsOver( _isOver );\n\t\t\t} else {\n\t\t\t\tsetIsOver( _isOver );\n\t\t\t}\n\t\t};\n\t};\n\tconst clearOnUnmount = () => {\n\t\tdelayedSetIsOver.cancel();\n\t\tdocument.removeEventListener( 'mouseup', cancelIsMouseDown );\n\t};\n\n\t// Ignore reason: updating the deps array here could cause unexpected changes in behavior.\n\t// Deferring until a more detailed investigation/refactor can be performed.\n\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\tuseEffect( () => clearOnUnmount, [] );\n\n\tif ( Children.count( children ) !== 1 ) {\n\t\tif ( 'development' === process.env.NODE_ENV ) {\n\t\t\t// eslint-disable-next-line no-console\n\t\t\tconsole.error(\n\t\t\t\t'Tooltip should be called with only a single child element.'\n\t\t\t);\n\t\t}\n\n\t\treturn children;\n\t}\n\n\tconst eventHandlers = {\n\t\tonMouseEnter: createToggleIsOver( 'onMouseEnter', true ),\n\t\tonMouseLeave: createToggleIsOver( 'onMouseLeave' ),\n\t\tonClick: createToggleIsOver( 'onClick' ),\n\t\tonFocus: createToggleIsOver( 'onFocus' ),\n\t\tonBlur: createToggleIsOver( 'onBlur' ),\n\t\tonMouseDown: createMouseEvent( 'mouseDown' ),\n\t};\n\n\tconst child = Children.only( children );\n\tconst { children: grandchildren, disabled } = child.props;\n\tconst getElementWithPopover = disabled\n\t\t? getDisabledElement\n\t\t: getRegularElement;\n\n\tconst popoverData = {\n\t\tanchor: popoverAnchor,\n\t\tisOver,\n\t\toffset: 4,\n\t\tposition,\n\t\tshortcut,\n\t\ttext,\n\t};\n\tconst childrenWithPopover = addPopoverToGrandchildren( {\n\t\tgrandchildren,\n\t\t...popoverData,\n\t\t...popoverProps,\n\t} );\n\n\treturn getElementWithPopover( {\n\t\tchild,\n\t\teventHandlers,\n\t\tchildrenWithPopover,\n\t\tmergedRefs: mergedChildRefs,\n\t} );\n}\n\nexport default Tooltip;\n"],"mappings":";;;;;;;AAUA,IAAAA,QAAA,GAAAC,OAAA;AALA,IAAAC,WAAA,GAAAC,sBAAA,CAAAF,OAAA;AAYA,IAAAG,QAAA,GAAAH,OAAA;AAKA,IAAAI,QAAA,GAAAF,sBAAA,CAAAF,OAAA;AACA,IAAAK,SAAA,GAAAH,sBAAA,CAAAF,OAAA;AAvBA;;AAEA;AACA;AACA;;AAGA;AACA;AACA;;AAUA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACO,MAAMM,aAAa,GAAG,GAAG;AAACC,OAAA,CAAAD,aAAA,GAAAA,aAAA;AAEjC,MAAME,YAAY,GAAG,IAAAT,QAAA,CAAAU,aAAA;EAAKC,SAAS,EAAC;AAAe,CAAE,CAAC;AAEtD,MAAMC,kBAAkB,GAAGA,CAAE;EAC5BC,aAAa;EACbC,KAAK;EACLC,mBAAmB;EACnBC;AACD,CAAC,KAAM;EACN,OAAO,IAAAC,qBAAY,EAClB,IAAAjB,QAAA,CAAAU,aAAA;IAAMC,SAAS,EAAC;EAA0B,GACvC,IAAAM,qBAAY,EAAER,YAAY,EAAEI,aAAc,CAAC,EAC3C,IAAAI,qBAAY,EAAEH,KAAK,EAAE;IACtBI,QAAQ,EAAEH,mBAAmB;IAC7BI,GAAG,EAAEH;EACN,CAAE,CACG,CAAC,EACP;IAAE,GAAGH;EAAc,CACpB,CAAC;AACF,CAAC;AAED,MAAMO,iBAAiB,GAAGA,CAAE;EAC3BN,KAAK;EACLD,aAAa;EACbE,mBAAmB;EACnBC;AACD,CAAC,KAAM;EACN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;IACbE,mBAAmB;IACnBC,UAAU,EAAEwC;EACb,CAAE,CAAC;AACJ;AAAC,IAAAiC,QAAA,GAEc9C,OAAO;AAAAnC,OAAA,CAAAuB,OAAA,GAAA0D,QAAA"}
1
+ {"version":3,"names":["_element","require","Ariakit","_interopRequireWildcard","_compose","_deprecated","_interopRequireDefault","_shortcut","_utils","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","TOOLTIP_DELAY","exports","Tooltip","props","children","delay","hideOnClick","placement","position","shortcut","text","baseId","useInstanceId","describedById","undefined","isOnlyChild","Children","count","process","env","NODE_ENV","console","error","computedPlacement","positionToPlacement","deprecated","since","alternative","tooltipStore","useTooltipStore","timeout","isTooltipOpen","useState","createElement","Fragment","TooltipAnchor","onBlur","hide","onClick","store","render","className","gutter","id","overflowPadding","_default"],"sources":["@wordpress/components/src/tooltip/index.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport * as Ariakit from '@ariakit/react/tooltip';\n\n/**\n * WordPress dependencies\n */\nimport { useInstanceId } from '@wordpress/compose';\nimport { Children } from '@wordpress/element';\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport type { TooltipProps } from './types';\nimport Shortcut from '../shortcut';\nimport { positionToPlacement } from '../popover/utils';\n\n/**\n * Time over anchor to wait before showing tooltip\n */\nexport const TOOLTIP_DELAY = 700;\n\nfunction Tooltip( props: TooltipProps ) {\n\tconst {\n\t\tchildren,\n\t\tdelay = TOOLTIP_DELAY,\n\t\thideOnClick = true,\n\t\tplacement,\n\t\tposition,\n\t\tshortcut,\n\t\ttext,\n\t} = props;\n\n\tconst baseId = useInstanceId( Tooltip, 'tooltip' );\n\tconst describedById = text || shortcut ? baseId : undefined;\n\n\tconst isOnlyChild = Children.count( children ) === 1;\n\t// console error if more than one child element is added\n\tif ( ! isOnlyChild ) {\n\t\tif ( 'development' === process.env.NODE_ENV ) {\n\t\t\t// eslint-disable-next-line no-console\n\t\t\tconsole.error(\n\t\t\t\t'Tooltip should be called with only a single child element.'\n\t\t\t);\n\t\t}\n\t}\n\n\t// Compute tooltip's placement:\n\t// - give priority to `placement` prop, if defined\n\t// - otherwise, compute it from the legacy `position` prop (if defined)\n\t// - finally, fallback to the default placement: 'bottom'\n\tlet computedPlacement;\n\tif ( placement !== undefined ) {\n\t\tcomputedPlacement = placement;\n\t} else if ( position !== undefined ) {\n\t\tcomputedPlacement = positionToPlacement( position );\n\t\tdeprecated( '`position` prop in wp.components.tooltip', {\n\t\t\tsince: '6.4',\n\t\t\talternative: '`placement` prop',\n\t\t} );\n\t}\n\tcomputedPlacement = computedPlacement || 'bottom';\n\n\tconst tooltipStore = Ariakit.useTooltipStore( {\n\t\tplacement: computedPlacement,\n\t\ttimeout: delay,\n\t} );\n\n\tconst isTooltipOpen = tooltipStore.useState( 'open' );\n\n\treturn (\n\t\t<>\n\t\t\t<Ariakit.TooltipAnchor\n\t\t\t\tonBlur={ tooltipStore.hide }\n\t\t\t\tonClick={ hideOnClick ? tooltipStore.hide : undefined }\n\t\t\t\tstore={ tooltipStore }\n\t\t\t\trender={ isOnlyChild ? children : undefined }\n\t\t\t>\n\t\t\t\t{ isOnlyChild ? undefined : children }\n\t\t\t</Ariakit.TooltipAnchor>\n\t\t\t{ isOnlyChild && ( text || shortcut ) && isTooltipOpen && (\n\t\t\t\t<Ariakit.Tooltip\n\t\t\t\t\tclassName=\"components-tooltip\"\n\t\t\t\t\tgutter={ 4 }\n\t\t\t\t\tid={ describedById }\n\t\t\t\t\toverflowPadding={ 0.5 }\n\t\t\t\t\tstore={ tooltipStore }\n\t\t\t\t>\n\t\t\t\t\t{ text }\n\t\t\t\t\t{ shortcut && (\n\t\t\t\t\t\t<Shortcut\n\t\t\t\t\t\t\tclassName={\n\t\t\t\t\t\t\t\ttext ? 'components-tooltip__shortcut' :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 "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["@wordpress/components/src/tooltip/types.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { Placement } from '@floating-ui/react-dom';\n\n/**\n * Internal dependencies\n */\nimport type { PopoverProps } from '../popover/types';\nimport type { ShortcutProps } from '../shortcut/types';\n\nexport type TooltipProps = {\n\t/**\n\t * The anchor for the tooltip.\n\t *\n\t * **Note**: Accepts only one child element.\n\t */\n\tchildren: React.ReactElement;\n\t/**\n\t * Option to hide the tooltip when the anchor is clicked.\n\t *\n\t * @default true\n\t */\n\thideOnClick?: boolean;\n\t/**\n\t * The amount of time in milliseconds to wait before showing the tooltip.\n\t *\n\t * @default 700\n\t */\n\tdelay?: number;\n\t/**\n\t * Where the tooltip should be positioned relative to its parent.\n\t *\n\t * @default bottom\n\t */\n\tplacement?: Placement;\n\t/**\n\t * _Note: this prop is deprecated. Please use the `placement` prop instead._\n\t *\n\t * Legacy way of specifying the tooltip's position relative to its parent.\n\t *\n\t * Specify y- and x-axis as a space-separated string. Supports `\"top\"`,\n\t * `\"bottom\"` y axis, and `\"left\"`, `\"center\"`, `\"right\"` x axis.\n\t *\n\t * @deprecated\n\t * @default bottom\n\t */\n\tposition?: PopoverProps[ 'position' ];\n\t/**\n\t * An option for adding accessible keyboard shortcuts.\n\t *\n\t * If shortcut is a string, it is expecting the display text. If shortcut is an\n\t * object, it will accept the properties of `display` (string) and `ariaLabel`\n\t * (string).\n\t */\n\tshortcut?: ShortcutProps[ 'shortcut' ];\n\t/**\n\t * The text shown in the tooltip when anchor element is focused or hovered.\n\t */\n\ttext?: string;\n};\n"],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"names":["_element","require","_warning","_interopRequireDefault","_constants","_getStyledClassNameFromKey","contextConnect","Component","namespace","_contextConnect","forwardsRef","contextConnectWithoutRef","options","WrappedComponent","forwardRef","SCRIPT_DEBUG","warn","mergedNamespace","CONNECT_STATIC_NAMESPACE","Array","isArray","Object","assign","Set","displayName","selector","getStyledClassNameFromKey","getConnectNamespace","namespaces","type","hasConnectNamespace","match","includes","some","result"],"sources":["@wordpress/components/src/ui/context/context-connect.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { ForwardedRef, ReactChild, ReactNode } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { forwardRef } from '@wordpress/element';\nimport warn from '@wordpress/warning';\n\n/**\n * Internal dependencies\n */\nimport { CONNECT_STATIC_NAMESPACE } from './constants';\nimport { getStyledClassNameFromKey } from './get-styled-class-name-from-key';\nimport type { WordPressComponentFromProps } from '.';\n\ntype AcceptsTwoArgs<\n\tF extends ( ...args: any ) => any,\n\tErrorMessage = never\n> = Parameters< F >[ 'length' ] extends 2 ? {} : ErrorMessage;\n\ntype ContextConnectOptions = {\n\tforwardsRef?: boolean;\n};\n\n/**\n * Forwards ref (React.ForwardRef) and \"Connects\" (or registers) a component\n * within the Context system under a specified namespace.\n *\n * @param Component The component to register into the Context system.\n * @param namespace The namespace to register the component under.\n * @return The connected WordPressComponent\n */\nexport function contextConnect<\n\tC extends ( props: any, ref: ForwardedRef< any > ) => JSX.Element | null\n>(\n\tComponent: C &\n\t\tAcceptsTwoArgs<\n\t\t\tC,\n\t\t\t'Warning: Your component function does not take a ref as the second argument. Did you mean to use `contextConnectWithoutRef`?'\n\t\t>,\n\tnamespace: string\n) {\n\treturn _contextConnect( Component, namespace, { forwardsRef: true } );\n}\n\n/**\n * \"Connects\" (or registers) a component within the Context system under a specified namespace.\n * Does not forward a ref.\n *\n * @param Component The component to register into the Context system.\n * @param namespace The namespace to register the component under.\n * @return The connected WordPressComponent\n */\nexport function contextConnectWithoutRef< P >(\n\tComponent: ( props: P ) => JSX.Element | null,\n\tnamespace: string\n) {\n\treturn _contextConnect( Component, namespace );\n}\n\n// This is an (experimental) evolution of the initial connect() HOC.\n// The hope is that we can improve render performance by removing functional\n// component wrappers.\nfunction _contextConnect<\n\tC extends ( props: any, ref: ForwardedRef< any > ) => JSX.Element | null,\n\tO extends ContextConnectOptions\n>(\n\tComponent: C,\n\tnamespace: string,\n\toptions?: O\n): WordPressComponentFromProps<\n\tParameters< C >[ 0 ],\n\tO[ 'forwardsRef' ] extends true ? true : false\n> {\n\tconst WrappedComponent = options?.forwardsRef\n\t\t? forwardRef< any, Parameters< C >[ 0 ] >( Component )\n\t\t: Component;\n\n\tif ( typeof namespace === 'undefined' ) {\n\t\twarn( 'contextConnect: Please provide a namespace' );\n\t}\n\n\t// @ts-expect-error internal property\n\tlet mergedNamespace = WrappedComponent[ CONNECT_STATIC_NAMESPACE ] || [\n\t\tnamespace,\n\t];\n\n\t/**\n\t * Consolidate (merge) namespaces before attaching it to the WrappedComponent.\n\t */\n\tif ( Array.isArray( namespace ) ) {\n\t\tmergedNamespace = [ ...mergedNamespace, ...namespace ];\n\t}\n\tif ( typeof namespace === 'string' ) {\n\t\tmergedNamespace = [ ...mergedNamespace, namespace ];\n\t}\n\n\t// @ts-expect-error We can't rely on inferred types here because of the\n\t// `as` prop polymorphism we're handling in https://github.com/WordPress/gutenberg/blob/9620bae6fef4fde7cc2b7833f416e240207cda29/packages/components/src/ui/context/wordpress-component.ts#L32-L33\n\treturn Object.assign( WrappedComponent, {\n\t\t[ CONNECT_STATIC_NAMESPACE ]: [ ...new Set( mergedNamespace ) ],\n\t\tdisplayName: namespace,\n\t\tselector: `.${ getStyledClassNameFromKey( namespace ) }`,\n\t} );\n}\n\n/**\n * Attempts to retrieve the connected namespace from a component.\n *\n * @param Component The component to retrieve a namespace from.\n * @return The connected namespaces.\n */\nexport function getConnectNamespace(\n\tComponent: ReactChild | undefined | {}\n): string[] {\n\tif ( ! Component ) return [];\n\n\tlet namespaces = [];\n\n\t// @ts-ignore internal property\n\tif ( Component[ CONNECT_STATIC_NAMESPACE ] ) {\n\t\t// @ts-ignore internal property\n\t\tnamespaces = Component[ CONNECT_STATIC_NAMESPACE ];\n\t}\n\n\t// @ts-ignore\n\tif ( Component.type && Component.type[ CONNECT_STATIC_NAMESPACE ] ) {\n\t\t// @ts-ignore\n\t\tnamespaces = Component.type[ CONNECT_STATIC_NAMESPACE ];\n\t}\n\n\treturn namespaces;\n}\n\n/**\n * Checks to see if a component is connected within the Context system.\n *\n * @param Component The component to retrieve a namespace from.\n * @param match The namespace to check.\n */\nexport function hasConnectNamespace(\n\tComponent: ReactNode,\n\tmatch: string[] | string\n): boolean {\n\tif ( ! Component ) return false;\n\n\tif ( typeof match === 'string' ) {\n\t\treturn getConnectNamespace( Component ).includes( match );\n\t}\n\tif ( Array.isArray( match ) ) {\n\t\treturn match.some( ( result ) =>\n\t\t\tgetConnectNamespace( Component ).includes( result )\n\t\t);\n\t}\n\n\treturn false;\n}\n"],"mappings":";;;;;;;;;;AAQA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAC,sBAAA,CAAAF,OAAA;AAKA,IAAAG,UAAA,GAAAH,OAAA;AACA,IAAAI,0BAAA,GAAAJ,OAAA;AAfA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;;AAcA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASK,cAAcA,CAG7BC,SAIE,EACFC,SAAiB,EAChB;EACD,OAAOC,eAAe,CAAEF,SAAS,EAAEC,SAAS,EAAE;IAAEE,WAAW,EAAE;EAAK,CAAE,CAAC;AACtE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,wBAAwBA,CACvCJ,SAA6C,EAC7CC,SAAiB,EAChB;EACD,OAAOC,eAAe,CAAEF,SAAS,EAAEC,SAAU,CAAC;AAC/C;;AAEA;AACA;AACA;AACA,SAASC,eAAeA,CAIvBF,SAAY,EACZC,SAAiB,EACjBI,OAAW,EAIV;EACD,MAAMC,gBAAgB,GAAGD,OAAO,EAAEF,WAAW,GAC1C,IAAAI,mBAAU,EAA+BP,SAAU,CAAC,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AmBA,CAClCvB,SAAoB,EACpBwB,KAAwB,EACd;EACV,IAAK,CAAExB,SAAS,EAAG,OAAO,KAAK;EAE/B,IAAK,OAAOwB,KAAK,KAAK,QAAQ,EAAG;IAChC,OAAOJ,mBAAmB,CAAEpB,SAAU,CAAC,CAACyB,QAAQ,CAAED,KAAM,CAAC;EAC1D;EACA,IAAKZ,KAAK,CAACC,OAAO,CAAEW,KAAM,CAAC,EAAG;IAC7B,OAAOA,KAAK,CAACE,IAAI,CAAIC,MAAM,IAC1BP,mBAAmB,CAAEpB,SAAU,CAAC,CAACyB,QAAQ,CAAEE,MAAO,CACnD,CAAC;EACF;EAEA,OAAO,KAAK;AACb"}
1
+ {"version":3,"names":["_element","require","_warning","_interopRequireDefault","_constants","_getStyledClassNameFromKey","contextConnect","Component","namespace","_contextConnect","forwardsRef","contextConnectWithoutRef","options","WrappedComponent","forwardRef","SCRIPT_DEBUG","warn","mergedNamespace","CONNECT_STATIC_NAMESPACE","Array","isArray","Object","assign","Set","displayName","selector","getStyledClassNameFromKey","getConnectNamespace","namespaces","type","hasConnectNamespace","match","includes","some","result"],"sources":["@wordpress/components/src/ui/context/context-connect.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { ForwardedRef, ReactChild, ReactNode } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { forwardRef } from '@wordpress/element';\nimport warn from '@wordpress/warning';\n\n/**\n * Internal dependencies\n */\nimport { CONNECT_STATIC_NAMESPACE } from './constants';\nimport { getStyledClassNameFromKey } from './get-styled-class-name-from-key';\nimport type { WordPressComponentFromProps } from '.';\n\ntype AcceptsTwoArgs<\n\tF extends ( ...args: any ) => any,\n\tErrorMessage = never,\n> = Parameters< F >[ 'length' ] extends 2 ? {} : ErrorMessage;\n\ntype ContextConnectOptions = {\n\tforwardsRef?: boolean;\n};\n\n/**\n * Forwards ref (React.ForwardRef) and \"Connects\" (or registers) a component\n * within the Context system under a specified namespace.\n *\n * @param Component The component to register into the Context system.\n * @param namespace The namespace to register the component under.\n * @return The connected WordPressComponent\n */\nexport function contextConnect<\n\tC extends ( props: any, ref: ForwardedRef< any > ) => JSX.Element | null,\n>(\n\tComponent: C &\n\t\tAcceptsTwoArgs<\n\t\t\tC,\n\t\t\t'Warning: Your component function does not take a ref as the second argument. Did you mean to use `contextConnectWithoutRef`?'\n\t\t>,\n\tnamespace: string\n) {\n\treturn _contextConnect( Component, namespace, { forwardsRef: true } );\n}\n\n/**\n * \"Connects\" (or registers) a component within the Context system under a specified namespace.\n * Does not forward a ref.\n *\n * @param Component The component to register into the Context system.\n * @param namespace The namespace to register the component under.\n * @return The connected WordPressComponent\n */\nexport function contextConnectWithoutRef< P >(\n\tComponent: ( props: P ) => JSX.Element | null,\n\tnamespace: string\n) {\n\treturn _contextConnect( Component, namespace );\n}\n\n// This is an (experimental) evolution of the initial connect() HOC.\n// The hope is that we can improve render performance by removing functional\n// component wrappers.\nfunction _contextConnect<\n\tC extends ( props: any, ref: ForwardedRef< any > ) => JSX.Element | null,\n\tO extends ContextConnectOptions,\n>(\n\tComponent: C,\n\tnamespace: string,\n\toptions?: O\n): WordPressComponentFromProps<\n\tParameters< C >[ 0 ],\n\tO[ 'forwardsRef' ] extends true ? true : false\n> {\n\tconst WrappedComponent = options?.forwardsRef\n\t\t? forwardRef< any, Parameters< C >[ 0 ] >( Component )\n\t\t: Component;\n\n\tif ( typeof namespace === 'undefined' ) {\n\t\twarn( 'contextConnect: Please provide a namespace' );\n\t}\n\n\t// @ts-expect-error internal property\n\tlet mergedNamespace = WrappedComponent[ CONNECT_STATIC_NAMESPACE ] || [\n\t\tnamespace,\n\t];\n\n\t/**\n\t * Consolidate (merge) namespaces before attaching it to the WrappedComponent.\n\t */\n\tif ( Array.isArray( namespace ) ) {\n\t\tmergedNamespace = [ ...mergedNamespace, ...namespace ];\n\t}\n\tif ( typeof namespace === 'string' ) {\n\t\tmergedNamespace = [ ...mergedNamespace, namespace ];\n\t}\n\n\t// @ts-expect-error We can't rely on inferred types here because of the\n\t// `as` prop polymorphism we're handling in https://github.com/WordPress/gutenberg/blob/9620bae6fef4fde7cc2b7833f416e240207cda29/packages/components/src/ui/context/wordpress-component.ts#L32-L33\n\treturn Object.assign( WrappedComponent, {\n\t\t[ CONNECT_STATIC_NAMESPACE ]: [ ...new Set( mergedNamespace ) ],\n\t\tdisplayName: namespace,\n\t\tselector: `.${ getStyledClassNameFromKey( namespace ) }`,\n\t} );\n}\n\n/**\n * Attempts to retrieve the connected namespace from a component.\n *\n * @param Component The component to retrieve a namespace from.\n * @return The connected namespaces.\n */\nexport function getConnectNamespace(\n\tComponent: ReactChild | undefined | {}\n): string[] {\n\tif ( ! Component ) return [];\n\n\tlet namespaces = [];\n\n\t// @ts-ignore internal property\n\tif ( Component[ CONNECT_STATIC_NAMESPACE ] ) {\n\t\t// @ts-ignore internal property\n\t\tnamespaces = Component[ CONNECT_STATIC_NAMESPACE ];\n\t}\n\n\t// @ts-ignore\n\tif ( Component.type && Component.type[ CONNECT_STATIC_NAMESPACE ] ) {\n\t\t// @ts-ignore\n\t\tnamespaces = Component.type[ CONNECT_STATIC_NAMESPACE ];\n\t}\n\n\treturn namespaces;\n}\n\n/**\n * Checks to see if a component is connected within the Context system.\n *\n * @param Component The component to retrieve a namespace from.\n * @param match The namespace to check.\n */\nexport function hasConnectNamespace(\n\tComponent: ReactNode,\n\tmatch: string[] | string\n): boolean {\n\tif ( ! Component ) return false;\n\n\tif ( typeof match === 'string' ) {\n\t\treturn getConnectNamespace( Component ).includes( match );\n\t}\n\tif ( Array.isArray( match ) ) {\n\t\treturn match.some( ( result ) =>\n\t\t\tgetConnectNamespace( Component ).includes( result )\n\t\t);\n\t}\n\n\treturn false;\n}\n"],"mappings":";;;;;;;;;;AAQA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAC,sBAAA,CAAAF,OAAA;AAKA,IAAAG,UAAA,GAAAH,OAAA;AACA,IAAAI,0BAAA,GAAAJ,OAAA;AAfA;AACA;AACA;;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AElB,SAAU,CAAG;EACxD,CAAE,CAAC;AACJ;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,SAASmB,mBAAmBA,CAClCpB,SAAsC,EAC3B;EACX,IAAK,CAAEA,SAAS,EAAG,OAAO,EAAE;EAE5B,IAAIqB,UAAU,GAAG,EAAE;;EAEnB;EACA,IAAKrB,SAAS,CAAEW,mCAAwB,CAAE,EAAG;IAC5C;IACAU,UAAU,GAAGrB,SAAS,CAAEW,mCAAwB,CAAE;EACnD;;EAEA;EACA,IAAKX,SAAS,CAACsB,IAAI,IAAItB,SAAS,CAACsB,IAAI,CAAEX,mCAAwB,CAAE,EAAG;IACnE;IACAU,UAAU,GAAGrB,SAAS,CAACsB,IAAI,CAAEX,mCAAwB,CAAE;EACxD;EAEA,OAAOU,UAAU;AAClB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,mBAAmBA,CAClCvB,SAAoB,EACpBwB,KAAwB,EACd;EACV,IAAK,CAAExB,SAAS,EAAG,OAAO,KAAK;EAE/B,IAAK,OAAOwB,KAAK,KAAK,QAAQ,EAAG;IAChC,OAAOJ,mBAAmB,CAAEpB,SAAU,CAAC,CAACyB,QAAQ,CAAED,KAAM,CAAC;EAC1D;EACA,IAAKZ,KAAK,CAACC,OAAO,CAAEW,KAAM,CAAC,EAAG;IAC7B,OAAOA,KAAK,CAACE,IAAI,CAAIC,MAAM,IAC1BP,mBAAmB,CAAEpB,SAAU,CAAC,CAACyB,QAAQ,CAAEE,MAAO,CACnD,CAAC;EACF;EAEA,OAAO,KAAK;AACb"}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["@wordpress/components/src/ui/context/wordpress-component.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport type * as React from 'react';\n\n// Based on https://github.com/reakit/reakit/blob/master/packages/reakit-utils/src/types.ts\nexport type WordPressComponentProps<\n\t/** Prop types. */\n\tP,\n\t/** The HTML element to inherit props from. */\n\tT extends React.ElementType,\n\t/** Supports polymorphism through the `as` prop. */\n\tIsPolymorphic extends boolean = true\n> = P &\n\t// The `children` prop is being explicitly omitted since it is otherwise implicitly added\n\t// by `ComponentPropsWithRef`. The context is that components should require the `children`\n\t// prop explicitely when needed (see https://github.com/WordPress/gutenberg/pull/31817).\n\tOmit< React.ComponentPropsWithoutRef< T >, 'as' | keyof P | 'children' > &\n\t( IsPolymorphic extends true\n\t\t? {\n\t\t\t\t/** The HTML element or React component to render the component as. */\n\t\t\t\tas?: T | keyof JSX.IntrinsicElements;\n\t\t }\n\t\t: {} );\n\nexport type WordPressComponent<\n\tT extends React.ElementType,\n\tO,\n\tIsPolymorphic extends boolean\n> = {\n\t< TT extends React.ElementType >(\n\t\tprops: WordPressComponentProps< O, TT, IsPolymorphic > &\n\t\t\t( IsPolymorphic extends true ? { as: TT } : {} )\n\t): JSX.Element | null;\n\t(\n\t\tprops: WordPressComponentProps< O, T, IsPolymorphic >\n\t): JSX.Element | null;\n\tdisplayName?: string;\n\t/**\n\t * A CSS selector used to fake component interpolation in styled components\n\t * for components not generated by `styled`. Anything passed to `contextConnect`\n\t * will get this property.\n\t *\n\t * We restrict it to a class to align with the already existing class names that\n\t * are generated by the context system.\n\t */\n\tselector?: `.${ string }`;\n};\n\nexport type WordPressComponentFromProps<\n\tProps,\n\tForwardsRef extends boolean = true\n> = Props extends WordPressComponentProps< infer P, infer T, infer I >\n\t? WordPressComponent<\n\t\t\tT,\n\t\t\tP & ( ForwardsRef extends true ? React.RefAttributes< any > : {} ),\n\t\t\tI\n\t >\n\t: never;\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["@wordpress/components/src/ui/context/wordpress-component.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport type * as React from 'react';\n\n// Based on https://github.com/reakit/reakit/blob/master/packages/reakit-utils/src/types.ts\nexport type WordPressComponentProps<\n\t/** Prop types. */\n\tP,\n\t/** The HTML element to inherit props from. */\n\tT extends React.ElementType,\n\t/** Supports polymorphism through the `as` prop. */\n\tIsPolymorphic extends boolean = true,\n> = P &\n\t// The `children` prop is being explicitly omitted since it is otherwise implicitly added\n\t// by `ComponentPropsWithRef`. The context is that components should require the `children`\n\t// prop explicitly when needed (see https://github.com/WordPress/gutenberg/pull/31817).\n\tOmit< React.ComponentPropsWithoutRef< T >, 'as' | keyof P | 'children' > &\n\t( IsPolymorphic extends true\n\t\t? {\n\t\t\t\t/** The HTML element or React component to render the component as. */\n\t\t\t\tas?: T | keyof JSX.IntrinsicElements;\n\t\t }\n\t\t: {} );\n\nexport type WordPressComponent<\n\tT extends React.ElementType,\n\tO,\n\tIsPolymorphic extends boolean,\n> = {\n\t< TT extends React.ElementType >(\n\t\tprops: WordPressComponentProps< O, TT, IsPolymorphic > &\n\t\t\t( IsPolymorphic extends true ? { as: TT } : {} )\n\t): JSX.Element | null;\n\t(\n\t\tprops: WordPressComponentProps< O, T, IsPolymorphic >\n\t): JSX.Element | null;\n\tdisplayName?: string;\n\t/**\n\t * A CSS selector used to fake component interpolation in styled components\n\t * for components not generated by `styled`. Anything passed to `contextConnect`\n\t * will get this property.\n\t *\n\t * We restrict it to a class to align with the already existing class names that\n\t * are generated by the context system.\n\t */\n\tselector?: `.${ string }`;\n};\n\nexport type WordPressComponentFromProps<\n\tProps,\n\tForwardsRef extends boolean = true,\n> = Props extends WordPressComponentProps< infer P, infer T, infer I >\n\t? WordPressComponent<\n\t\t\tT,\n\t\t\tP & ( ForwardsRef extends true ? React.RefAttributes< any > : {} ),\n\t\t\tI\n\t >\n\t: never;\n"],"mappings":""}