@wordpress/components 23.1.0 → 23.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (280) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/LICENSE.md +1 -1
  3. package/build/color-picker/component.js +1 -0
  4. package/build/color-picker/component.js.map +1 -1
  5. package/build/color-picker/styles.js +8 -10
  6. package/build/color-picker/styles.js.map +1 -1
  7. package/build/combobox-control/index.js +5 -1
  8. package/build/combobox-control/index.js.map +1 -1
  9. package/build/focal-point-picker/utils.js +1 -1
  10. package/build/focal-point-picker/utils.js.map +1 -1
  11. package/build/index.js +7 -17
  12. package/build/index.js.map +1 -1
  13. package/build/index.native.js +8 -18
  14. package/build/index.native.js.map +1 -1
  15. package/build/item-group/item/component.js +27 -3
  16. package/build/item-group/item/component.js.map +1 -1
  17. package/build/item-group/item-group/component.js +26 -3
  18. package/build/item-group/item-group/component.js.map +1 -1
  19. package/build/item-group/styles.js +14 -14
  20. package/build/item-group/styles.js.map +1 -1
  21. package/build/panel/row.js +5 -3
  22. package/build/panel/row.js.map +1 -1
  23. package/build/query-controls/index.js +1 -0
  24. package/build/query-controls/index.js.map +1 -1
  25. package/build/resizable-box/index.js +5 -4
  26. package/build/resizable-box/index.js.map +1 -1
  27. package/build/responsive-wrapper/index.js +18 -1
  28. package/build/responsive-wrapper/index.js.map +1 -1
  29. package/build/responsive-wrapper/types.js +6 -0
  30. package/build/responsive-wrapper/types.js.map +1 -0
  31. package/build/sandbox/index.js +35 -24
  32. package/build/sandbox/index.js.map +1 -1
  33. package/build/sandbox/types.js +6 -0
  34. package/build/sandbox/types.js.map +1 -0
  35. package/build/tab-panel/index.js +10 -5
  36. package/build/tab-panel/index.js.map +1 -1
  37. package/build/toolbar/index.js +42 -60
  38. package/build/toolbar/index.js.map +1 -1
  39. package/build/toolbar/toolbar/index.js +74 -0
  40. package/build/toolbar/toolbar/index.js.map +1 -0
  41. package/build/toolbar/{toolbar-container.js → toolbar/toolbar-container.js} +0 -0
  42. package/build/toolbar/toolbar/toolbar-container.js.map +1 -0
  43. package/build/toolbar/{toolbar-container.native.js → toolbar/toolbar-container.native.js} +0 -0
  44. package/build/toolbar/toolbar/toolbar-container.native.js.map +1 -0
  45. package/build/{toolbar-button → toolbar/toolbar-button}/index.js +1 -1
  46. package/build/toolbar/toolbar-button/index.js.map +1 -0
  47. package/build/{toolbar-button → toolbar/toolbar-button}/toolbar-button-container.js +0 -0
  48. package/build/toolbar/toolbar-button/toolbar-button-container.js.map +1 -0
  49. package/build/{toolbar-button → toolbar/toolbar-button}/toolbar-button-container.native.js +0 -0
  50. package/build/toolbar/toolbar-button/toolbar-button-container.native.js.map +1 -0
  51. package/build/{toolbar-context → toolbar/toolbar-context}/index.js +0 -0
  52. package/build/toolbar/toolbar-context/index.js.map +1 -0
  53. package/build/{toolbar-dropdown-menu → toolbar/toolbar-dropdown-menu}/index.js +1 -1
  54. package/build/toolbar/toolbar-dropdown-menu/index.js.map +1 -0
  55. package/build/{toolbar-group → toolbar/toolbar-group}/index.js +0 -0
  56. package/build/toolbar/toolbar-group/index.js.map +1 -0
  57. package/build/{toolbar-group → toolbar/toolbar-group}/toolbar-group-collapsed.js +1 -1
  58. package/build/toolbar/toolbar-group/toolbar-group-collapsed.js.map +1 -0
  59. package/build/{toolbar-group → toolbar/toolbar-group}/toolbar-group-collapsed.native.js +1 -1
  60. package/build/toolbar/toolbar-group/toolbar-group-collapsed.native.js.map +1 -0
  61. package/build/{toolbar-group → toolbar/toolbar-group}/toolbar-group-container.js +0 -0
  62. package/build/toolbar/toolbar-group/toolbar-group-container.js.map +1 -0
  63. package/build/{toolbar-group → toolbar/toolbar-group}/toolbar-group-container.native.js +0 -0
  64. package/build/toolbar/toolbar-group/toolbar-group-container.native.js.map +1 -0
  65. package/build/{toolbar-item → toolbar/toolbar-item}/index.js +0 -0
  66. package/build/toolbar/toolbar-item/index.js.map +1 -0
  67. package/build/{toolbar-item → toolbar/toolbar-item}/index.native.js +0 -0
  68. package/build/toolbar/toolbar-item/index.native.js.map +1 -0
  69. package/build/tree-grid/index.js +3 -3
  70. package/build/tree-grid/index.js.map +1 -1
  71. package/build-module/color-picker/component.js +1 -0
  72. package/build-module/color-picker/component.js.map +1 -1
  73. package/build-module/color-picker/styles.js +8 -9
  74. package/build-module/color-picker/styles.js.map +1 -1
  75. package/build-module/combobox-control/index.js +5 -1
  76. package/build-module/combobox-control/index.js.map +1 -1
  77. package/build-module/focal-point-picker/utils.js +1 -1
  78. package/build-module/focal-point-picker/utils.js.map +1 -1
  79. package/build-module/index.js +1 -6
  80. package/build-module/index.js.map +1 -1
  81. package/build-module/index.native.js +1 -6
  82. package/build-module/index.native.js.map +1 -1
  83. package/build-module/item-group/item/component.js +26 -2
  84. package/build-module/item-group/item/component.js.map +1 -1
  85. package/build-module/item-group/item-group/component.js +25 -2
  86. package/build-module/item-group/item-group/component.js.map +1 -1
  87. package/build-module/item-group/styles.js +14 -14
  88. package/build-module/item-group/styles.js.map +1 -1
  89. package/build-module/panel/row.js +5 -3
  90. package/build-module/panel/row.js.map +1 -1
  91. package/build-module/query-controls/index.js +1 -0
  92. package/build-module/query-controls/index.js.map +1 -1
  93. package/build-module/resizable-box/index.js +3 -2
  94. package/build-module/resizable-box/index.js.map +1 -1
  95. package/build-module/responsive-wrapper/index.js +20 -1
  96. package/build-module/responsive-wrapper/index.js.map +1 -1
  97. package/build-module/responsive-wrapper/types.js +2 -0
  98. package/build-module/responsive-wrapper/types.js.map +1 -0
  99. package/build-module/sandbox/index.js +37 -23
  100. package/build-module/sandbox/index.js.map +1 -1
  101. package/build-module/sandbox/types.js +2 -0
  102. package/build-module/sandbox/types.js.map +1 -0
  103. package/build-module/tab-panel/index.js +10 -5
  104. package/build-module/tab-panel/index.js.map +1 -1
  105. package/build-module/toolbar/index.js +6 -58
  106. package/build-module/toolbar/index.js.map +1 -1
  107. package/build-module/toolbar/toolbar/index.js +59 -0
  108. package/build-module/toolbar/toolbar/index.js.map +1 -0
  109. package/build-module/toolbar/{toolbar-container.js → toolbar/toolbar-container.js} +0 -0
  110. package/{build → build-module/toolbar}/toolbar/toolbar-container.js.map +1 -1
  111. package/build-module/toolbar/{toolbar-container.native.js → toolbar/toolbar-container.native.js} +0 -0
  112. package/build-module/toolbar/toolbar/toolbar-container.native.js.map +1 -0
  113. package/build-module/{toolbar-button → toolbar/toolbar-button}/index.js +1 -1
  114. package/build-module/toolbar/toolbar-button/index.js.map +1 -0
  115. package/build-module/{toolbar-button → toolbar/toolbar-button}/toolbar-button-container.js +0 -0
  116. package/build-module/toolbar/toolbar-button/toolbar-button-container.js.map +1 -0
  117. package/build-module/{toolbar-button → toolbar/toolbar-button}/toolbar-button-container.native.js +0 -0
  118. package/build-module/toolbar/toolbar-button/toolbar-button-container.native.js.map +1 -0
  119. package/build-module/{toolbar-context → toolbar/toolbar-context}/index.js +0 -0
  120. package/build-module/toolbar/toolbar-context/index.js.map +1 -0
  121. package/build-module/{toolbar-dropdown-menu → toolbar/toolbar-dropdown-menu}/index.js +1 -1
  122. package/build-module/toolbar/toolbar-dropdown-menu/index.js.map +1 -0
  123. package/build-module/{toolbar-group → toolbar/toolbar-group}/index.js +0 -0
  124. package/build-module/toolbar/toolbar-group/index.js.map +1 -0
  125. package/build-module/{toolbar-group → toolbar/toolbar-group}/toolbar-group-collapsed.js +1 -1
  126. package/build-module/toolbar/toolbar-group/toolbar-group-collapsed.js.map +1 -0
  127. package/build-module/{toolbar-group → toolbar/toolbar-group}/toolbar-group-collapsed.native.js +1 -1
  128. package/build-module/toolbar/toolbar-group/toolbar-group-collapsed.native.js.map +1 -0
  129. package/build-module/{toolbar-group → toolbar/toolbar-group}/toolbar-group-container.js +0 -0
  130. package/build-module/toolbar/toolbar-group/toolbar-group-container.js.map +1 -0
  131. package/build-module/{toolbar-group → toolbar/toolbar-group}/toolbar-group-container.native.js +0 -0
  132. package/build-module/toolbar/toolbar-group/toolbar-group-container.native.js.map +1 -0
  133. package/build-module/{toolbar-item → toolbar/toolbar-item}/index.js +0 -0
  134. package/build-module/toolbar/toolbar-item/index.js.map +1 -0
  135. package/build-module/{toolbar-item → toolbar/toolbar-item}/index.native.js +0 -0
  136. package/build-module/toolbar/toolbar-item/index.native.js.map +1 -0
  137. package/build-module/tree-grid/index.js +3 -3
  138. package/build-module/tree-grid/index.js.map +1 -1
  139. package/build-style/style-rtl.css +1 -1
  140. package/build-style/style.css +1 -1
  141. package/build-types/color-picker/component.d.ts.map +1 -1
  142. package/build-types/color-picker/styles.d.ts.map +1 -1
  143. package/build-types/dashicon/types.d.ts +0 -4
  144. package/build-types/dashicon/types.d.ts.map +1 -1
  145. package/build-types/focal-point-picker/utils.d.ts.map +1 -1
  146. package/build-types/item-group/item/component.d.ts +24 -2
  147. package/build-types/item-group/item/component.d.ts.map +1 -1
  148. package/build-types/item-group/item-group/component.d.ts +23 -2
  149. package/build-types/item-group/item-group/component.d.ts.map +1 -1
  150. package/build-types/item-group/stories/index.d.ts +15 -0
  151. package/build-types/item-group/stories/index.d.ts.map +1 -0
  152. package/build-types/item-group/styles.d.ts.map +1 -1
  153. package/build-types/radio-context/index.d.ts +6 -0
  154. package/build-types/radio-context/index.d.ts.map +1 -0
  155. package/build-types/resizable-box/index.d.ts +6 -7
  156. package/build-types/resizable-box/index.d.ts.map +1 -1
  157. package/build-types/resizable-box/stories/index.d.ts +61 -0
  158. package/build-types/resizable-box/stories/index.d.ts.map +1 -0
  159. package/build-types/responsive-wrapper/index.d.ts +24 -0
  160. package/build-types/responsive-wrapper/index.d.ts.map +1 -0
  161. package/build-types/responsive-wrapper/stories/index.d.ts +12 -0
  162. package/build-types/responsive-wrapper/stories/index.d.ts.map +1 -0
  163. package/build-types/responsive-wrapper/types.d.ts +22 -0
  164. package/build-types/responsive-wrapper/types.d.ts.map +1 -0
  165. package/build-types/sandbox/index.d.ts +19 -0
  166. package/build-types/sandbox/index.d.ts.map +1 -0
  167. package/build-types/sandbox/stories/index.d.ts +12 -0
  168. package/build-types/sandbox/stories/index.d.ts.map +1 -0
  169. package/build-types/sandbox/test/index.d.ts +2 -0
  170. package/build-types/sandbox/test/index.d.ts.map +1 -0
  171. package/build-types/sandbox/types.d.ts +36 -0
  172. package/build-types/sandbox/types.d.ts.map +1 -0
  173. package/build-types/tab-panel/index.d.ts.map +1 -1
  174. package/build-types/tab-panel/stories/index.d.ts +1 -0
  175. package/build-types/tab-panel/stories/index.d.ts.map +1 -1
  176. package/build-types/tab-panel/types.d.ts +10 -4
  177. package/build-types/tab-panel/types.d.ts.map +1 -1
  178. package/package.json +17 -17
  179. package/src/color-picker/component.tsx +1 -0
  180. package/src/color-picker/stories/index.js +20 -60
  181. package/src/color-picker/styles.ts +0 -5
  182. package/src/combobox-control/index.js +9 -1
  183. package/src/dashicon/types.ts +0 -6
  184. package/src/focal-point-picker/stories/index.tsx +1 -1
  185. package/src/focal-point-picker/utils.ts +4 -1
  186. package/src/guide/stories/index.js +14 -41
  187. package/src/index.js +8 -6
  188. package/src/index.native.js +8 -6
  189. package/src/item-group/item/component.tsx +26 -2
  190. package/src/item-group/item-group/component.tsx +25 -2
  191. package/src/item-group/stories/index.tsx +103 -0
  192. package/src/item-group/styles.ts +1 -0
  193. package/src/item-group/test/__snapshots__/index.js.snap +11 -10
  194. package/src/notice/stories/index.js +30 -58
  195. package/src/panel/row.js +3 -3
  196. package/src/panel/stories/index.js +62 -80
  197. package/src/placeholder/style.scss +1 -1
  198. package/src/query-controls/index.js +1 -0
  199. package/src/resizable-box/README.md +2 -2
  200. package/src/resizable-box/index.tsx +7 -6
  201. package/src/resizable-box/stories/index.tsx +92 -0
  202. package/src/responsive-wrapper/README.md +29 -0
  203. package/src/responsive-wrapper/{index.js → index.tsx} +23 -2
  204. package/src/responsive-wrapper/stories/index.tsx +38 -0
  205. package/src/responsive-wrapper/types.ts +20 -0
  206. package/src/sandbox/README.md +45 -2
  207. package/src/sandbox/{index.js → index.tsx} +47 -24
  208. package/src/sandbox/stories/index.tsx +32 -0
  209. package/src/sandbox/test/{index.js → index.tsx} +9 -4
  210. package/src/sandbox/types.ts +34 -0
  211. package/src/slot-fill/stories/index.js +12 -17
  212. package/src/style.scss +3 -3
  213. package/src/tab-panel/README.md +1 -0
  214. package/src/tab-panel/index.tsx +19 -5
  215. package/src/tab-panel/stories/index.tsx +20 -0
  216. package/src/tab-panel/test/index.tsx +89 -0
  217. package/src/tab-panel/types.ts +10 -4
  218. package/src/toolbar/index.js +6 -52
  219. package/src/toolbar/stories/index.js +2 -9
  220. package/src/{toolbar-button/stories/index.js → toolbar/stories/toolbar-button.js} +1 -2
  221. package/src/{toolbar-group/stories/index.js → toolbar/stories/toolbar-group.js} +1 -1
  222. package/src/toolbar/test/index.js +1 -2
  223. package/src/{toolbar-group/test/index.js → toolbar/test/toolbar-group.js} +1 -1
  224. package/src/toolbar/{README.md → toolbar/README.md} +0 -0
  225. package/src/toolbar/toolbar/index.js +52 -0
  226. package/src/toolbar/{style.native.scss → toolbar/style.native.scss} +0 -0
  227. package/src/toolbar/{style.scss → toolbar/style.scss} +0 -0
  228. package/src/toolbar/{toolbar-container.js → toolbar/toolbar-container.js} +0 -0
  229. package/src/toolbar/{toolbar-container.native.js → toolbar/toolbar-container.native.js} +0 -0
  230. package/src/{toolbar-button → toolbar/toolbar-button}/README.md +0 -0
  231. package/src/{toolbar-button → toolbar/toolbar-button}/index.js +1 -1
  232. package/src/{toolbar-button → toolbar/toolbar-button}/style.scss +0 -0
  233. package/src/{toolbar-button → toolbar/toolbar-button}/toolbar-button-container.js +0 -0
  234. package/src/{toolbar-button → toolbar/toolbar-button}/toolbar-button-container.native.js +0 -0
  235. package/src/{toolbar-context → toolbar/toolbar-context}/index.js +0 -0
  236. package/src/{toolbar-dropdown-menu → toolbar/toolbar-dropdown-menu}/README.md +0 -0
  237. package/src/{toolbar-dropdown-menu → toolbar/toolbar-dropdown-menu}/index.js +1 -1
  238. package/src/{toolbar-group → toolbar/toolbar-group}/README.md +0 -0
  239. package/src/{toolbar-group → toolbar/toolbar-group}/index.js +0 -0
  240. package/src/{toolbar-group → toolbar/toolbar-group}/style.native.scss +0 -0
  241. package/src/{toolbar-group → toolbar/toolbar-group}/style.scss +0 -0
  242. package/src/{toolbar-group → toolbar/toolbar-group}/toolbar-group-collapsed.js +1 -1
  243. package/src/{toolbar-group → toolbar/toolbar-group}/toolbar-group-collapsed.native.js +1 -1
  244. package/src/{toolbar-group → toolbar/toolbar-group}/toolbar-group-container.js +0 -0
  245. package/src/{toolbar-group → toolbar/toolbar-group}/toolbar-group-container.native.js +0 -0
  246. package/src/{toolbar-item → toolbar/toolbar-item}/README.md +0 -0
  247. package/src/{toolbar-item → toolbar/toolbar-item}/index.js +0 -0
  248. package/src/{toolbar-item → toolbar/toolbar-item}/index.native.js +0 -0
  249. package/src/tree-grid/index.js +2 -4
  250. package/tsconfig.json +0 -7
  251. package/tsconfig.tsbuildinfo +1 -1
  252. package/build/toolbar/toolbar-container.native.js.map +0 -1
  253. package/build/toolbar-button/index.js.map +0 -1
  254. package/build/toolbar-button/toolbar-button-container.js.map +0 -1
  255. package/build/toolbar-button/toolbar-button-container.native.js.map +0 -1
  256. package/build/toolbar-context/index.js.map +0 -1
  257. package/build/toolbar-dropdown-menu/index.js.map +0 -1
  258. package/build/toolbar-group/index.js.map +0 -1
  259. package/build/toolbar-group/toolbar-group-collapsed.js.map +0 -1
  260. package/build/toolbar-group/toolbar-group-collapsed.native.js.map +0 -1
  261. package/build/toolbar-group/toolbar-group-container.js.map +0 -1
  262. package/build/toolbar-group/toolbar-group-container.native.js.map +0 -1
  263. package/build/toolbar-item/index.js.map +0 -1
  264. package/build/toolbar-item/index.native.js.map +0 -1
  265. package/build-module/toolbar/toolbar-container.js.map +0 -1
  266. package/build-module/toolbar/toolbar-container.native.js.map +0 -1
  267. package/build-module/toolbar-button/index.js.map +0 -1
  268. package/build-module/toolbar-button/toolbar-button-container.js.map +0 -1
  269. package/build-module/toolbar-button/toolbar-button-container.native.js.map +0 -1
  270. package/build-module/toolbar-context/index.js.map +0 -1
  271. package/build-module/toolbar-dropdown-menu/index.js.map +0 -1
  272. package/build-module/toolbar-group/index.js.map +0 -1
  273. package/build-module/toolbar-group/toolbar-group-collapsed.js.map +0 -1
  274. package/build-module/toolbar-group/toolbar-group-collapsed.native.js.map +0 -1
  275. package/build-module/toolbar-group/toolbar-group-container.js.map +0 -1
  276. package/build-module/toolbar-group/toolbar-group-container.native.js.map +0 -1
  277. package/build-module/toolbar-item/index.js.map +0 -1
  278. package/build-module/toolbar-item/index.native.js.map +0 -1
  279. package/src/item-group/stories/index.js +0 -270
  280. package/src/resizable-box/stories/index.js +0 -97
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/responsive-wrapper/index.js"],"names":["classnames","cloneElement","Children","useResizeObserver","ResponsiveWrapper","naturalWidth","naturalHeight","children","isInline","containerResizeListener","width","containerWidth","count","imageStyle","paddingBottom","TagName","className","props"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,YAAT,EAAuBC,QAAvB,QAAuC,oBAAvC;AACA,SAASC,iBAAT,QAAkC,oBAAlC;;AAEA,SAASC,iBAAT,OAKI;AAAA,MALwB;AAC3BC,IAAAA,YAD2B;AAE3BC,IAAAA,aAF2B;AAG3BC,IAAAA,QAH2B;AAI3BC,IAAAA,QAAQ,GAAG;AAJgB,GAKxB;AACH,QAAM,CAAEC,uBAAF,EAA2B;AAAEC,IAAAA,KAAK,EAAEC;AAAT,GAA3B,IACLR,iBAAiB,EADlB;;AAEA,MAAKD,QAAQ,CAACU,KAAT,CAAgBL,QAAhB,MAA+B,CAApC,EAAwC;AACvC,WAAO,IAAP;AACA;;AACD,QAAMM,UAAU,GAAG;AAClBC,IAAAA,aAAa,EACZT,YAAY,GAAGM,cAAf,GACGL,aADH,GAEKA,aAAa,GAAGD,YAAlB,GAAmC,GAAnC,GAAyC;AAJ3B,GAAnB;AAMA,QAAMU,OAAO,GAAGP,QAAQ,GAAG,MAAH,GAAY,KAApC;AACA,SACC,cAAC,OAAD;AAAS,IAAA,SAAS,EAAC;AAAnB,KACGC,uBADH,EAEC,cAAC,OAAD;AAAS,IAAA,KAAK,EAAGI;AAAjB,IAFD,EAGGZ,YAAY,CAAEM,QAAF,EAAY;AACzBS,IAAAA,SAAS,EAAEhB,UAAU,CACpB,wCADoB,EAEpBO,QAAQ,CAACU,KAAT,CAAeD,SAFK;AADI,GAAZ,CAHf,CADD;AAYA;;AAED,eAAeZ,iBAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { cloneElement, Children } from '@wordpress/element';\nimport { useResizeObserver } from '@wordpress/compose';\n\nfunction ResponsiveWrapper( {\n\tnaturalWidth,\n\tnaturalHeight,\n\tchildren,\n\tisInline = false,\n} ) {\n\tconst [ containerResizeListener, { width: containerWidth } ] =\n\t\tuseResizeObserver();\n\tif ( Children.count( children ) !== 1 ) {\n\t\treturn null;\n\t}\n\tconst imageStyle = {\n\t\tpaddingBottom:\n\t\t\tnaturalWidth < containerWidth\n\t\t\t\t? naturalHeight\n\t\t\t\t: ( naturalHeight / naturalWidth ) * 100 + '%',\n\t};\n\tconst TagName = isInline ? 'span' : 'div';\n\treturn (\n\t\t<TagName className=\"components-responsive-wrapper\">\n\t\t\t{ containerResizeListener }\n\t\t\t<TagName style={ imageStyle } />\n\t\t\t{ cloneElement( children, {\n\t\t\t\tclassName: classnames(\n\t\t\t\t\t'components-responsive-wrapper__content',\n\t\t\t\t\tchildren.props.className\n\t\t\t\t),\n\t\t\t} ) }\n\t\t</TagName>\n\t);\n}\n\nexport default ResponsiveWrapper;\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/responsive-wrapper/index.tsx"],"names":["classnames","cloneElement","Children","useResizeObserver","ResponsiveWrapper","naturalWidth","naturalHeight","children","isInline","containerResizeListener","width","containerWidth","count","imageStyle","paddingBottom","TagName","className","props"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,YAAT,EAAuBC,QAAvB,QAAuC,oBAAvC;AACA,SAASC,iBAAT,QAAkC,oBAAlC;AAEA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,iBAAT,OAK4B;AAAA,MALA;AAC3BC,IAAAA,YAD2B;AAE3BC,IAAAA,aAF2B;AAG3BC,IAAAA,QAH2B;AAI3BC,IAAAA,QAAQ,GAAG;AAJgB,GAKA;AAC3B,QAAM,CAAEC,uBAAF,EAA2B;AAAEC,IAAAA,KAAK,EAAEC;AAAT,GAA3B,IACLR,iBAAiB,EADlB;;AAEA,MAAKD,QAAQ,CAACU,KAAT,CAAgBL,QAAhB,MAA+B,CAApC,EAAwC;AACvC,WAAO,IAAP;AACA;;AACD,QAAMM,UAAU,GAAG;AAClBC,IAAAA,aAAa,EACZT,YAAY,IAAKM,cAAL,aAAKA,cAAL,cAAKA,cAAL,GAAuB,CAAvB,CAAZ,GACGL,aADH,GAEKA,aAAa,GAAGD,YAAlB,GAAmC,GAAnC,GAAyC;AAJ3B,GAAnB;AAMA,QAAMU,OAAO,GAAGP,QAAQ,GAAG,MAAH,GAAY,KAApC;AACA,SACC,cAAC,OAAD;AAAS,IAAA,SAAS,EAAC;AAAnB,KACGC,uBADH,EAEC,cAAC,OAAD;AAAS,IAAA,KAAK,EAAGI;AAAjB,IAFD,EAGGZ,YAAY,CAAEM,QAAF,EAAY;AACzBS,IAAAA,SAAS,EAAEhB,UAAU,CACpB,wCADoB,EAEpBO,QAAQ,CAACU,KAAT,CAAeD,SAFK;AADI,GAAZ,CAHf,CADD;AAYA;;AAED,eAAeZ,iBAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { cloneElement, Children } from '@wordpress/element';\nimport { useResizeObserver } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport type { ResponsiveWrapperProps } from './types';\n\n/**\n * A wrapper component that maintains its aspect ratio when resized.\n *\n * ```jsx\n * import { ResponsiveWrapper } from '@wordpress/components';\n *\n * const MyResponsiveWrapper = () => (\n * \t<ResponsiveWrapper naturalWidth={ 2000 } naturalHeight={ 680 }>\n * \t\t<img\n * \t\t\tsrc=\"https://s.w.org/style/images/about/WordPress-logotype-standard.png\"\n * \t\t\talt=\"WordPress\"\n * \t\t/>\n * \t</ResponsiveWrapper>\n * );\n * ```\n */\nfunction ResponsiveWrapper( {\n\tnaturalWidth,\n\tnaturalHeight,\n\tchildren,\n\tisInline = false,\n}: ResponsiveWrapperProps ) {\n\tconst [ containerResizeListener, { width: containerWidth } ] =\n\t\tuseResizeObserver();\n\tif ( Children.count( children ) !== 1 ) {\n\t\treturn null;\n\t}\n\tconst imageStyle = {\n\t\tpaddingBottom:\n\t\t\tnaturalWidth < ( containerWidth ?? 0 )\n\t\t\t\t? naturalHeight\n\t\t\t\t: ( naturalHeight / naturalWidth ) * 100 + '%',\n\t};\n\tconst TagName = isInline ? 'span' : 'div';\n\treturn (\n\t\t<TagName className=\"components-responsive-wrapper\">\n\t\t\t{ containerResizeListener }\n\t\t\t<TagName style={ imageStyle } />\n\t\t\t{ cloneElement( children, {\n\t\t\t\tclassName: classnames(\n\t\t\t\t\t'components-responsive-wrapper__content',\n\t\t\t\t\tchildren.props.className\n\t\t\t\t),\n\t\t\t} ) }\n\t\t</TagName>\n\t);\n}\n\nexport default ResponsiveWrapper;\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
@@ -5,6 +5,9 @@ import { createElement } from "@wordpress/element";
5
5
  */
6
6
  import { renderToString, useRef, useState, useEffect } from '@wordpress/element';
7
7
  import { useFocusableIframe, useMergeRefs } from '@wordpress/compose';
8
+ /**
9
+ * Internal dependencies
10
+ */
8
11
 
9
12
  const observeAndResizeJS = function () {
10
13
  const {
@@ -58,7 +61,8 @@ const observeAndResizeJS = function () {
58
61
  // get an DOM mutations for that, so do the resize when the window is resized, too.
59
62
 
60
63
  window.addEventListener('resize', sendResize, true);
61
- };
64
+ }; // TODO: These styles shouldn't be coupled with WordPress.
65
+
62
66
 
63
67
  const style = `
64
68
  body {
@@ -82,7 +86,19 @@ const style = `
82
86
  margin-bottom: 0 !important;
83
87
  }
84
88
  `;
85
- export default function Sandbox(_ref) {
89
+ /**
90
+ * This component provides an isolated environment for arbitrary HTML via iframes.
91
+ *
92
+ * ```jsx
93
+ * import { SandBox } from '@wordpress/components';
94
+ *
95
+ * const MySandBox = () => (
96
+ * <SandBox html="<p>Content</p>" title="SandBox" type="embed" />
97
+ * );
98
+ * ```
99
+ */
100
+
101
+ function SandBox(_ref) {
86
102
  let {
87
103
  html = '',
88
104
  title = '',
@@ -97,13 +113,15 @@ export default function Sandbox(_ref) {
97
113
 
98
114
  function isFrameAccessible() {
99
115
  try {
100
- return !!ref.current.contentDocument.body;
116
+ var _ref$current, _ref$current$contentD;
117
+
118
+ return !!((_ref$current = ref.current) !== null && _ref$current !== void 0 && (_ref$current$contentD = _ref$current.contentDocument) !== null && _ref$current$contentD !== void 0 && _ref$current$contentD.body);
101
119
  } catch (e) {
102
120
  return false;
103
121
  }
104
122
  }
105
123
 
106
- function trySandbox() {
124
+ function trySandBox() {
107
125
  let forceRerender = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
108
126
 
109
127
  if (!isFrameAccessible()) {
@@ -114,11 +132,8 @@ export default function Sandbox(_ref) {
114
132
  contentDocument,
115
133
  ownerDocument
116
134
  } = ref.current;
117
- const {
118
- body
119
- } = contentDocument;
120
135
 
121
- if (!forceRerender && null !== body.getAttribute('data-resizable-iframe-connected')) {
136
+ if (!forceRerender && null !== (contentDocument === null || contentDocument === void 0 ? void 0 : contentDocument.body.getAttribute('data-resizable-iframe-connected'))) {
122
137
  return;
123
138
  } // Put the html snippet into a html document, and then write it to the iframe's document
124
139
  // we can use this in the future to inject custom styles or scripts.
@@ -163,10 +178,12 @@ export default function Sandbox(_ref) {
163
178
  }
164
179
 
165
180
  useEffect(() => {
166
- trySandbox();
181
+ var _iframe$ownerDocument;
182
+
183
+ trySandBox();
167
184
 
168
- function tryNoForceSandbox() {
169
- trySandbox(false);
185
+ function tryNoForceSandBox() {
186
+ trySandBox(false);
170
187
  }
171
188
 
172
189
  function checkMessageForResize(event) {
@@ -196,32 +213,27 @@ export default function Sandbox(_ref) {
196
213
  }
197
214
 
198
215
  const iframe = ref.current;
199
- const {
200
- ownerDocument
201
- } = iframe;
202
- const {
203
- defaultView
204
- } = ownerDocument; // This used to be registered using <iframe onLoad={} />, but it made the iframe blank
216
+ const defaultView = iframe === null || iframe === void 0 ? void 0 : (_iframe$ownerDocument = iframe.ownerDocument) === null || _iframe$ownerDocument === void 0 ? void 0 : _iframe$ownerDocument.defaultView; // This used to be registered using <iframe onLoad={} />, but it made the iframe blank
205
217
  // after reordering the containing block. See these two issues for more details:
206
218
  // https://github.com/WordPress/gutenberg/issues/6146
207
219
  // https://github.com/facebook/react/issues/18752
208
220
 
209
- iframe.addEventListener('load', tryNoForceSandbox, false);
210
- defaultView.addEventListener('message', checkMessageForResize);
221
+ iframe === null || iframe === void 0 ? void 0 : iframe.addEventListener('load', tryNoForceSandBox, false);
222
+ defaultView === null || defaultView === void 0 ? void 0 : defaultView.addEventListener('message', checkMessageForResize);
211
223
  return () => {
212
- iframe === null || iframe === void 0 ? void 0 : iframe.removeEventListener('load', tryNoForceSandbox, false);
213
- defaultView.addEventListener('message', checkMessageForResize);
224
+ iframe === null || iframe === void 0 ? void 0 : iframe.removeEventListener('load', tryNoForceSandBox, false);
225
+ defaultView === null || defaultView === void 0 ? void 0 : defaultView.addEventListener('message', checkMessageForResize);
214
226
  }; // Ignore reason: passing `exhaustive-deps` will likely involve a more detailed refactor.
215
227
  // See https://github.com/WordPress/gutenberg/pull/44378
216
228
  // eslint-disable-next-line react-hooks/exhaustive-deps
217
229
  }, []);
218
230
  useEffect(() => {
219
- trySandbox(); // Ignore reason: passing `exhaustive-deps` will likely involve a more detailed refactor.
231
+ trySandBox(); // Ignore reason: passing `exhaustive-deps` will likely involve a more detailed refactor.
220
232
  // See https://github.com/WordPress/gutenberg/pull/44378
221
233
  // eslint-disable-next-line react-hooks/exhaustive-deps
222
234
  }, [title, styles, scripts]);
223
235
  useEffect(() => {
224
- trySandbox(true); // Ignore reason: passing `exhaustive-deps` will likely involve a more detailed refactor.
236
+ trySandBox(true); // Ignore reason: passing `exhaustive-deps` will likely involve a more detailed refactor.
225
237
  // See https://github.com/WordPress/gutenberg/pull/44378
226
238
  // eslint-disable-next-line react-hooks/exhaustive-deps
227
239
  }, [html, type]);
@@ -235,4 +247,6 @@ export default function Sandbox(_ref) {
235
247
  height: Math.ceil(height)
236
248
  });
237
249
  }
250
+
251
+ export default SandBox;
238
252
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/sandbox/index.js"],"names":["renderToString","useRef","useState","useEffect","useFocusableIframe","useMergeRefs","observeAndResizeJS","MutationObserver","window","document","body","parent","sendResize","clientBoundingRect","getBoundingClientRect","postMessage","action","width","height","observer","observe","attributes","attributeOldValue","characterData","characterDataOldValue","childList","subtree","addEventListener","removeViewportStyles","ruleOrNode","style","forEach","test","Array","prototype","call","querySelectorAll","styleSheets","stylesheet","cssRules","rules","position","setAttribute","Sandbox","html","title","type","styles","scripts","onFocus","ref","setWidth","setHeight","isFrameAccessible","current","contentDocument","e","trySandbox","forceRerender","ownerDocument","getAttribute","htmlDoc","documentElement","lang","__html","map","i","toString","src","open","write","close","tryNoForceSandbox","checkMessageForResize","event","iframe","contentWindow","source","data","JSON","parse","defaultView","removeEventListener","Math","ceil"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,cADD,EAECC,MAFD,EAGCC,QAHD,EAICC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AAI,CAACC,IAAL,CAAWnE,KAAX,CANT;AAOC,IAAA,MAAM,EAAGkE,IAAI,CAACC,IAAL,CAAWlE,MAAX;AAPV,IADD;AAWA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\trenderToString,\n\tuseRef,\n\tuseState,\n\tuseEffect,\n} from '@wordpress/element';\nimport { useFocusableIframe, useMergeRefs } from '@wordpress/compose';\n\nconst observeAndResizeJS = function () {\n\tconst { MutationObserver } = window;\n\n\tif ( ! MutationObserver || ! document.body || ! window.parent ) {\n\t\treturn;\n\t}\n\n\tfunction sendResize() {\n\t\tconst clientBoundingRect = document.body.getBoundingClientRect();\n\n\t\twindow.parent.postMessage(\n\t\t\t{\n\t\t\t\taction: 'resize',\n\t\t\t\twidth: clientBoundingRect.width,\n\t\t\t\theight: clientBoundingRect.height,\n\t\t\t},\n\t\t\t'*'\n\t\t);\n\t}\n\n\tconst observer = new MutationObserver( sendResize );\n\tobserver.observe( document.body, {\n\t\tattributes: true,\n\t\tattributeOldValue: false,\n\t\tcharacterData: true,\n\t\tcharacterDataOldValue: false,\n\t\tchildList: true,\n\t\tsubtree: true,\n\t} );\n\n\twindow.addEventListener( 'load', sendResize, true );\n\n\t// Hack: Remove viewport unit styles, as these are relative\n\t// the iframe root and interfere with our mechanism for\n\t// determining the unconstrained page bounds.\n\tfunction removeViewportStyles( ruleOrNode ) {\n\t\tif ( ruleOrNode.style ) {\n\t\t\t[ 'width', 'height', 'minHeight', 'maxHeight' ].forEach( function (\n\t\t\t\tstyle\n\t\t\t) {\n\t\t\t\tif (\n\t\t\t\t\t/^\\\\d+(vmin|vmax|vh|vw)$/.test( ruleOrNode.style[ style ] )\n\t\t\t\t) {\n\t\t\t\t\truleOrNode.style[ style ] = '';\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\t}\n\n\tArray.prototype.forEach.call(\n\t\tdocument.querySelectorAll( '[style]' ),\n\t\tremoveViewportStyles\n\t);\n\tArray.prototype.forEach.call(\n\t\tdocument.styleSheets,\n\t\tfunction ( stylesheet ) {\n\t\t\tArray.prototype.forEach.call(\n\t\t\t\tstylesheet.cssRules || stylesheet.rules,\n\t\t\t\tremoveViewportStyles\n\t\t\t);\n\t\t}\n\t);\n\n\tdocument.body.style.position = 'absolute';\n\tdocument.body.style.width = '100%';\n\tdocument.body.setAttribute( 'data-resizable-iframe-connected', '' );\n\n\tsendResize();\n\n\t// Resize events can change the width of elements with 100% width, but we don't\n\t// get an DOM mutations for that, so do the resize when the window is resized, too.\n\twindow.addEventListener( 'resize', sendResize, true );\n};\n\nconst style = `\n\tbody {\n\t\tmargin: 0;\n\t}\n\thtml,\n\tbody,\n\tbody > div {\n\t\twidth: 100%;\n\t}\n\thtml.wp-has-aspect-ratio,\n\tbody.wp-has-aspect-ratio,\n\tbody.wp-has-aspect-ratio > div,\n\tbody.wp-has-aspect-ratio > div iframe {\n\t\twidth: 100%;\n\t\theight: 100%;\n\t\toverflow: hidden; /* If it has an aspect ratio, it shouldn't scroll. */\n\t}\n\tbody > div > * {\n\t\tmargin-top: 0 !important; /* Has to have !important to override inline styles. */\n\t\tmargin-bottom: 0 !important;\n\t}\n`;\n\nexport default function Sandbox( {\n\thtml = '',\n\ttitle = '',\n\ttype,\n\tstyles = [],\n\tscripts = [],\n\tonFocus,\n} ) {\n\tconst ref = useRef();\n\tconst [ width, setWidth ] = useState( 0 );\n\tconst [ height, setHeight ] = useState( 0 );\n\n\tfunction isFrameAccessible() {\n\t\ttry {\n\t\t\treturn !! ref.current.contentDocument.body;\n\t\t} catch ( e ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\tfunction trySandbox( forceRerender = false ) {\n\t\tif ( ! isFrameAccessible() ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { contentDocument, ownerDocument } = ref.current;\n\t\tconst { body } = contentDocument;\n\n\t\tif (\n\t\t\t! forceRerender &&\n\t\t\tnull !== body.getAttribute( 'data-resizable-iframe-connected' )\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Put the html snippet into a html document, and then write it to the iframe's document\n\t\t// we can use this in the future to inject custom styles or scripts.\n\t\t// Scripts go into the body rather than the head, to support embedded content such as Instagram\n\t\t// that expect the scripts to be part of the body.\n\t\tconst htmlDoc = (\n\t\t\t<html\n\t\t\t\tlang={ ownerDocument.documentElement.lang }\n\t\t\t\tclassName={ type }\n\t\t\t>\n\t\t\t\t<head>\n\t\t\t\t\t<title>{ title }</title>\n\t\t\t\t\t<style dangerouslySetInnerHTML={ { __html: style } } />\n\t\t\t\t\t{ styles.map( ( rules, i ) => (\n\t\t\t\t\t\t<style\n\t\t\t\t\t\t\tkey={ i }\n\t\t\t\t\t\t\tdangerouslySetInnerHTML={ { __html: rules } }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) ) }\n\t\t\t\t</head>\n\t\t\t\t<body\n\t\t\t\t\tdata-resizable-iframe-connected=\"data-resizable-iframe-connected\"\n\t\t\t\t\tclassName={ type }\n\t\t\t\t>\n\t\t\t\t\t<div dangerouslySetInnerHTML={ { __html: html } } />\n\t\t\t\t\t<script\n\t\t\t\t\t\ttype=\"text/javascript\"\n\t\t\t\t\t\tdangerouslySetInnerHTML={ {\n\t\t\t\t\t\t\t__html: `(${ observeAndResizeJS.toString() })();`,\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t\t{ scripts.map( ( src ) => (\n\t\t\t\t\t\t<script key={ src } src={ src } />\n\t\t\t\t\t) ) }\n\t\t\t\t</body>\n\t\t\t</html>\n\t\t);\n\n\t\t// Writing the document like this makes it act in the same way as if it was\n\t\t// loaded over the network, so DOM creation and mutation, script execution, etc.\n\t\t// all work as expected.\n\t\tcontentDocument.open();\n\t\tcontentDocument.write( '<!DOCTYPE html>' + renderToString( htmlDoc ) );\n\t\tcontentDocument.close();\n\t}\n\n\tuseEffect( () => {\n\t\ttrySandbox();\n\n\t\tfunction tryNoForceSandbox() {\n\t\t\ttrySandbox( false );\n\t\t}\n\n\t\tfunction checkMessageForResize( event ) {\n\t\t\tconst iframe = ref.current;\n\n\t\t\t// Verify that the mounted element is the source of the message.\n\t\t\tif ( ! iframe || iframe.contentWindow !== event.source ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Attempt to parse the message data as JSON if passed as string.\n\t\t\tlet data = event.data || {};\n\n\t\t\tif ( 'string' === typeof data ) {\n\t\t\t\ttry {\n\t\t\t\t\tdata = JSON.parse( data );\n\t\t\t\t} catch ( e ) {}\n\t\t\t}\n\n\t\t\t// Update the state only if the message is formatted as we expect,\n\t\t\t// i.e. as an object with a 'resize' action.\n\t\t\tif ( 'resize' !== data.action ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tsetWidth( data.width );\n\t\t\tsetHeight( data.height );\n\t\t}\n\n\t\tconst iframe = ref.current;\n\t\tconst { ownerDocument } = iframe;\n\t\tconst { defaultView } = ownerDocument;\n\n\t\t// This used to be registered using <iframe onLoad={} />, but it made the iframe blank\n\t\t// after reordering the containing block. See these two issues for more details:\n\t\t// https://github.com/WordPress/gutenberg/issues/6146\n\t\t// https://github.com/facebook/react/issues/18752\n\t\tiframe.addEventListener( 'load', tryNoForceSandbox, false );\n\t\tdefaultView.addEventListener( 'message', checkMessageForResize );\n\n\t\treturn () => {\n\t\t\tiframe?.removeEventListener( 'load', tryNoForceSandbox, false );\n\t\t\tdefaultView.addEventListener( 'message', checkMessageForResize );\n\t\t};\n\t\t// Ignore reason: passing `exhaustive-deps` will likely involve a more detailed refactor.\n\t\t// See https://github.com/WordPress/gutenberg/pull/44378\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [] );\n\n\tuseEffect( () => {\n\t\ttrySandbox();\n\t\t// Ignore reason: passing `exhaustive-deps` will likely involve a more detailed refactor.\n\t\t// See https://github.com/WordPress/gutenberg/pull/44378\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [ title, styles, scripts ] );\n\n\tuseEffect( () => {\n\t\ttrySandbox( true );\n\t\t// Ignore reason: passing `exhaustive-deps` will likely involve a more detailed refactor.\n\t\t// See https://github.com/WordPress/gutenberg/pull/44378\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [ html, type ] );\n\n\treturn (\n\t\t<iframe\n\t\t\tref={ useMergeRefs( [ ref, useFocusableIframe() ] ) }\n\t\t\ttitle={ title }\n\t\t\tclassName=\"components-sandbox\"\n\t\t\tsandbox=\"allow-scripts allow-same-origin allow-presentation\"\n\t\t\tonFocus={ onFocus }\n\t\t\twidth={ Math.ceil( width ) }\n\t\t\theight={ Math.ceil( height ) }\n\t\t/>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/sandbox/index.tsx"],"names":["renderToString","useRef","useState","useEffect","useFocusableIframe","useMergeRefs","observeAndResizeJS","MutationObserver","window","document","body","parent","sendResize","clientBoundingRect","getBoundingClientRect","postMessage","action","width","height","observer","observe","attributes","attributeOldValue","characterData","characterDataOldValue","childList","subtree","addEventListener","removeViewportStyles","ruleOrNode","style","forEach","test","Array","prototype","call","querySelectorAll","styleSheets","stylesheet","cssRules","rules","position","setAttribute","SandBox","html","title","type","styles","scripts","onFocus","ref","setWidth","setHeight","isFrameAccessible","current","contentDocument","e","trySandBox","forceRerender","ownerDocument","getAttribute","htmlDoc","documentElement","lang","__html","map","i","toString","src","open","write","close","tryNoForceSandBox","checkMessageForResize","event","iframe","contentWindow","source","data","JSON","parse","defaultView","removeEventListener","Math","ceil"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,cADD,EAECC,MAFD,EAGCC,QAHD,EAICC,SAJD,QAKO,oBALP;AAMA,SAASC,kBAAT,EAA6BC,YAA7B,QAAiD,oBAAjD;AAEA;AACA;AACA;;AAGA,MAAMC,kBAAkB,GAAG,YAAY;AACtC,QAAM;AAAEC,IAAAA;AAAF,MAAuBC,MAA7B;;AAEA,MAAK,CAAED,gBAAF,IAAsB,CAAEE,QAAQ,CAACC,IAAjC,IAAyC,CAAEF,MAAM,CAACG,MAAvD,EAAgE;AAC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AAGkE,IAAI,CAACC,IAAL,CAAWlE,MAAX;AAPV,IADD;AAWA;;AAED,eAAeyB,OAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\trenderToString,\n\tuseRef,\n\tuseState,\n\tuseEffect,\n} from '@wordpress/element';\nimport { useFocusableIframe, useMergeRefs } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport type { SandBoxProps } from './types';\n\nconst observeAndResizeJS = function () {\n\tconst { MutationObserver } = window;\n\n\tif ( ! MutationObserver || ! document.body || ! window.parent ) {\n\t\treturn;\n\t}\n\n\tfunction sendResize() {\n\t\tconst clientBoundingRect = document.body.getBoundingClientRect();\n\n\t\twindow.parent.postMessage(\n\t\t\t{\n\t\t\t\taction: 'resize',\n\t\t\t\twidth: clientBoundingRect.width,\n\t\t\t\theight: clientBoundingRect.height,\n\t\t\t},\n\t\t\t'*'\n\t\t);\n\t}\n\n\tconst observer = new MutationObserver( sendResize );\n\tobserver.observe( document.body, {\n\t\tattributes: true,\n\t\tattributeOldValue: false,\n\t\tcharacterData: true,\n\t\tcharacterDataOldValue: false,\n\t\tchildList: true,\n\t\tsubtree: true,\n\t} );\n\n\twindow.addEventListener( 'load', sendResize, true );\n\n\t// Hack: Remove viewport unit styles, as these are relative\n\t// the iframe root and interfere with our mechanism for\n\t// determining the unconstrained page bounds.\n\tfunction removeViewportStyles( ruleOrNode: ElementCSSInlineStyle ) {\n\t\tif ( ruleOrNode.style ) {\n\t\t\t(\n\t\t\t\t[ 'width', 'height', 'minHeight', 'maxHeight' ] as const\n\t\t\t ).forEach( function ( style ) {\n\t\t\t\tif (\n\t\t\t\t\t/^\\\\d+(vmin|vmax|vh|vw)$/.test( ruleOrNode.style[ style ] )\n\t\t\t\t) {\n\t\t\t\t\truleOrNode.style[ style ] = '';\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\t}\n\n\tArray.prototype.forEach.call(\n\t\tdocument.querySelectorAll( '[style]' ),\n\t\tremoveViewportStyles\n\t);\n\tArray.prototype.forEach.call(\n\t\tdocument.styleSheets,\n\t\tfunction ( stylesheet ) {\n\t\t\tArray.prototype.forEach.call(\n\t\t\t\tstylesheet.cssRules || stylesheet.rules,\n\t\t\t\tremoveViewportStyles\n\t\t\t);\n\t\t}\n\t);\n\n\tdocument.body.style.position = 'absolute';\n\tdocument.body.style.width = '100%';\n\tdocument.body.setAttribute( 'data-resizable-iframe-connected', '' );\n\n\tsendResize();\n\n\t// Resize events can change the width of elements with 100% width, but we don't\n\t// get an DOM mutations for that, so do the resize when the window is resized, too.\n\twindow.addEventListener( 'resize', sendResize, true );\n};\n\n// TODO: These styles shouldn't be coupled with WordPress.\nconst style = `\n\tbody {\n\t\tmargin: 0;\n\t}\n\thtml,\n\tbody,\n\tbody > div {\n\t\twidth: 100%;\n\t}\n\thtml.wp-has-aspect-ratio,\n\tbody.wp-has-aspect-ratio,\n\tbody.wp-has-aspect-ratio > div,\n\tbody.wp-has-aspect-ratio > div iframe {\n\t\twidth: 100%;\n\t\theight: 100%;\n\t\toverflow: hidden; /* If it has an aspect ratio, it shouldn't scroll. */\n\t}\n\tbody > div > * {\n\t\tmargin-top: 0 !important; /* Has to have !important to override inline styles. */\n\t\tmargin-bottom: 0 !important;\n\t}\n`;\n\n/**\n * This component provides an isolated environment for arbitrary HTML via iframes.\n *\n * ```jsx\n * import { SandBox } from '@wordpress/components';\n *\n * const MySandBox = () => (\n * \t<SandBox html=\"<p>Content</p>\" title=\"SandBox\" type=\"embed\" />\n * );\n * ```\n */\nfunction SandBox( {\n\thtml = '',\n\ttitle = '',\n\ttype,\n\tstyles = [],\n\tscripts = [],\n\tonFocus,\n}: SandBoxProps ) {\n\tconst ref = useRef< HTMLIFrameElement >();\n\tconst [ width, setWidth ] = useState( 0 );\n\tconst [ height, setHeight ] = useState( 0 );\n\n\tfunction isFrameAccessible() {\n\t\ttry {\n\t\t\treturn !! ref.current?.contentDocument?.body;\n\t\t} catch ( e ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\tfunction trySandBox( forceRerender = false ) {\n\t\tif ( ! isFrameAccessible() ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { contentDocument, ownerDocument } =\n\t\t\tref.current as HTMLIFrameElement & {\n\t\t\t\tcontentDocument: Document;\n\t\t\t};\n\n\t\tif (\n\t\t\t! forceRerender &&\n\t\t\tnull !==\n\t\t\t\tcontentDocument?.body.getAttribute(\n\t\t\t\t\t'data-resizable-iframe-connected'\n\t\t\t\t)\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Put the html snippet into a html document, and then write it to the iframe's document\n\t\t// we can use this in the future to inject custom styles or scripts.\n\t\t// Scripts go into the body rather than the head, to support embedded content such as Instagram\n\t\t// that expect the scripts to be part of the body.\n\t\tconst htmlDoc = (\n\t\t\t<html\n\t\t\t\tlang={ ownerDocument.documentElement.lang }\n\t\t\t\tclassName={ type }\n\t\t\t>\n\t\t\t\t<head>\n\t\t\t\t\t<title>{ title }</title>\n\t\t\t\t\t<style dangerouslySetInnerHTML={ { __html: style } } />\n\t\t\t\t\t{ styles.map( ( rules, i ) => (\n\t\t\t\t\t\t<style\n\t\t\t\t\t\t\tkey={ i }\n\t\t\t\t\t\t\tdangerouslySetInnerHTML={ { __html: rules } }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) ) }\n\t\t\t\t</head>\n\t\t\t\t<body\n\t\t\t\t\tdata-resizable-iframe-connected=\"data-resizable-iframe-connected\"\n\t\t\t\t\tclassName={ type }\n\t\t\t\t>\n\t\t\t\t\t<div dangerouslySetInnerHTML={ { __html: html } } />\n\t\t\t\t\t<script\n\t\t\t\t\t\ttype=\"text/javascript\"\n\t\t\t\t\t\tdangerouslySetInnerHTML={ {\n\t\t\t\t\t\t\t__html: `(${ observeAndResizeJS.toString() })();`,\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t\t{ scripts.map( ( src ) => (\n\t\t\t\t\t\t<script key={ src } src={ src } />\n\t\t\t\t\t) ) }\n\t\t\t\t</body>\n\t\t\t</html>\n\t\t);\n\n\t\t// Writing the document like this makes it act in the same way as if it was\n\t\t// loaded over the network, so DOM creation and mutation, script execution, etc.\n\t\t// all work as expected.\n\t\tcontentDocument.open();\n\t\tcontentDocument.write( '<!DOCTYPE html>' + renderToString( htmlDoc ) );\n\t\tcontentDocument.close();\n\t}\n\n\tuseEffect( () => {\n\t\ttrySandBox();\n\n\t\tfunction tryNoForceSandBox() {\n\t\t\ttrySandBox( false );\n\t\t}\n\n\t\tfunction checkMessageForResize( event: MessageEvent ) {\n\t\t\tconst iframe = ref.current;\n\n\t\t\t// Verify that the mounted element is the source of the message.\n\t\t\tif ( ! iframe || iframe.contentWindow !== event.source ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Attempt to parse the message data as JSON if passed as string.\n\t\t\tlet data = event.data || {};\n\n\t\t\tif ( 'string' === typeof data ) {\n\t\t\t\ttry {\n\t\t\t\t\tdata = JSON.parse( data );\n\t\t\t\t} catch ( e ) {}\n\t\t\t}\n\n\t\t\t// Update the state only if the message is formatted as we expect,\n\t\t\t// i.e. as an object with a 'resize' action.\n\t\t\tif ( 'resize' !== data.action ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tsetWidth( data.width );\n\t\t\tsetHeight( data.height );\n\t\t}\n\n\t\tconst iframe = ref.current;\n\t\tconst defaultView = iframe?.ownerDocument?.defaultView;\n\n\t\t// This used to be registered using <iframe onLoad={} />, but it made the iframe blank\n\t\t// after reordering the containing block. See these two issues for more details:\n\t\t// https://github.com/WordPress/gutenberg/issues/6146\n\t\t// https://github.com/facebook/react/issues/18752\n\t\tiframe?.addEventListener( 'load', tryNoForceSandBox, false );\n\t\tdefaultView?.addEventListener( 'message', checkMessageForResize );\n\n\t\treturn () => {\n\t\t\tiframe?.removeEventListener( 'load', tryNoForceSandBox, false );\n\t\t\tdefaultView?.addEventListener( 'message', checkMessageForResize );\n\t\t};\n\t\t// Ignore reason: passing `exhaustive-deps` will likely involve a more detailed refactor.\n\t\t// See https://github.com/WordPress/gutenberg/pull/44378\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [] );\n\n\tuseEffect( () => {\n\t\ttrySandBox();\n\t\t// Ignore reason: passing `exhaustive-deps` will likely involve a more detailed refactor.\n\t\t// See https://github.com/WordPress/gutenberg/pull/44378\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [ title, styles, scripts ] );\n\n\tuseEffect( () => {\n\t\ttrySandBox( true );\n\t\t// Ignore reason: passing `exhaustive-deps` will likely involve a more detailed refactor.\n\t\t// See https://github.com/WordPress/gutenberg/pull/44378\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [ html, type ] );\n\n\treturn (\n\t\t<iframe\n\t\t\tref={ useMergeRefs( [ ref, useFocusableIframe() ] ) }\n\t\t\ttitle={ title }\n\t\t\tclassName=\"components-sandbox\"\n\t\t\tsandbox=\"allow-scripts allow-same-origin allow-presentation\"\n\t\t\tonFocus={ onFocus }\n\t\t\twidth={ Math.ceil( width ) }\n\t\t\theight={ Math.ceil( height ) }\n\t\t/>\n\t);\n}\n\nexport default SandBox;\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
@@ -21,7 +21,6 @@ import Button from '../button';
21
21
  const TabButton = _ref => {
22
22
  let {
23
23
  tabId,
24
- onClick,
25
24
  children,
26
25
  selected,
27
26
  ...rest
@@ -31,7 +30,7 @@ const TabButton = _ref => {
31
30
  tabIndex: selected ? null : -1,
32
31
  "aria-selected": selected,
33
32
  id: tabId,
34
- onClick: onClick
33
+ __experimentalIsFocusable: true
35
34
  }, rest), children);
36
35
  };
37
36
  /**
@@ -105,10 +104,15 @@ export function TabPanel(_ref2) {
105
104
  });
106
105
  const selectedId = `${instanceId}-${(_selectedTab$name = selectedTab === null || selectedTab === void 0 ? void 0 : selectedTab.name) !== null && _selectedTab$name !== void 0 ? _selectedTab$name : 'none'}`;
107
106
  useEffect(() => {
108
- if (!(selectedTab !== null && selectedTab !== void 0 && selectedTab.name) && tabs.length > 0) {
109
- handleTabSelection(initialTabName || tabs[0].name);
107
+ const firstEnabledTab = tabs.find(tab => !tab.disabled);
108
+ const initialTab = tabs.find(tab => tab.name === initialTabName);
109
+
110
+ if (!(selectedTab !== null && selectedTab !== void 0 && selectedTab.name) && firstEnabledTab) {
111
+ handleTabSelection(initialTab && !initialTab.disabled ? initialTab.name : firstEnabledTab.name);
112
+ } else if (selectedTab !== null && selectedTab !== void 0 && selectedTab.disabled && firstEnabledTab) {
113
+ handleTabSelection(firstEnabledTab.name);
110
114
  }
111
- }, [tabs, selectedTab === null || selectedTab === void 0 ? void 0 : selectedTab.name, initialTabName, handleTabSelection]);
115
+ }, [tabs, selectedTab === null || selectedTab === void 0 ? void 0 : selectedTab.name, selectedTab === null || selectedTab === void 0 ? void 0 : selectedTab.disabled, initialTabName, handleTabSelection]);
112
116
  return createElement("div", {
113
117
  className: className
114
118
  }, createElement(NavigableMenu, {
@@ -125,6 +129,7 @@ export function TabPanel(_ref2) {
125
129
  selected: tab.name === selected,
126
130
  key: tab.name,
127
131
  onClick: () => handleTabSelection(tab.name),
132
+ disabled: tab.disabled,
128
133
  label: tab.icon && tab.title,
129
134
  icon: tab.icon,
130
135
  showTooltip: !!tab.icon
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/tab-panel/index.tsx"],"names":["classnames","useState","useEffect","useCallback","useInstanceId","NavigableMenu","Button","TabButton","tabId","onClick","children","selected","rest","TabPanel","className","tabs","selectOnMove","initialTabName","orientation","activeClass","onSelect","instanceId","setSelected","handleTabSelection","tabKey","activateTabAutomatically","_childIndex","child","click","selectedTab","find","name","selectedId","length","undefined","map","tab","icon","title"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,QAAT,EAAm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B,SAFiB,EAGrB;AACC,OAAEK,WAAF,GAAiBiB,GAAG,CAACL,IAAJ,KAAapB;AAD/B,KAHqB,CADvB;AAQC,IAAA,KAAK,EAAI,GAAGU,UAAY,IAAIe,GAAG,CAACL,IAAM,EARvC;AASC,qBAAiB,GAAGV,UAAY,IAAIe,GAAG,CAACL,IAAM,OAT/C;AAUC,IAAA,QAAQ,EAAGK,GAAG,CAACL,IAAJ,KAAapB,QAVzB;AAWC,IAAA,GAAG,EAAGyB,GAAG,CAACL,IAXX;AAYC,IAAA,OAAO,EAAG,MAAMR,kBAAkB,CAAEa,GAAG,CAACL,IAAN,CAZnC;AAaC,IAAA,KAAK,EAAGK,GAAG,CAACC,IAAJ,IAAYD,GAAG,CAACE,KAbzB;AAcC,IAAA,IAAI,EAAGF,GAAG,CAACC,IAdZ;AAeC,IAAA,WAAW,EAAG,CAAC,CAAED,GAAG,CAACC;AAftB,KAiBG,CAAED,GAAG,CAACC,IAAN,IAAcD,GAAG,CAACE,KAjBrB,CADC,CARH,CADD,EA+BGT,WAAW,IACZ;AACC,IAAA,GAAG,EAAGG,UADP;AAEC,uBAAkBA,UAFnB;AAGC,IAAA,IAAI,EAAC,UAHN;AAIC,IAAA,EAAE,EAAI,GAAGA,UAAY,OAJtB;AAKC,IAAA,SAAS,EAAC;AALX,KAOGtB,QAAQ,CAAEmB,WAAF,CAPX,CAhCF,CADD;AA6CA;AAED,eAAehB,QAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useState, useEffect, useCallback } from '@wordpress/element';\nimport { useInstanceId } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { NavigableMenu } from '../navigable-container';\nimport Button from '../button';\nimport type { TabButtonProps, TabPanelProps } from './types';\nimport type { WordPressComponentProps } from '../ui/context';\n\nconst TabButton = ( {\n\ttabId,\n\tonClick,\n\tchildren,\n\tselected,\n\t...rest\n}: TabButtonProps ) => (\n\t<Button\n\t\trole=\"tab\"\n\t\ttabIndex={ selected ? null : -1 }\n\t\taria-selected={ selected }\n\t\tid={ tabId }\n\t\tonClick={ onClick }\n\t\t{ ...rest }\n\t>\n\t\t{ children }\n\t</Button>\n);\n\n/**\n * TabPanel is an ARIA-compliant tabpanel.\n *\n * TabPanels organize content across different screens, data sets, and interactions.\n * It has two sections: a list of tabs, and the view to show when tabs are chosen.\n *\n * ```jsx\n * import { TabPanel } from '@wordpress/components';\n *\n * const onSelect = ( tabName ) => {\n * console.log( 'Selecting tab', tabName );\n * };\n *\n * const MyTabPanel = () => (\n * <TabPanel\n * className=\"my-tab-panel\"\n * activeClass=\"active-tab\"\n * onSelect={ onSelect }\n * tabs={ [\n * {\n * name: 'tab1',\n * title: 'Tab 1',\n * className: 'tab-one',\n * },\n * {\n * name: 'tab2',\n * title: 'Tab 2',\n * className: 'tab-two',\n * },\n * ] }\n * >\n * { ( tab ) => <p>{ tab.title }</p> }\n * </TabPanel>\n * );\n * ```\n */\nexport function TabPanel( {\n\tclassName,\n\tchildren,\n\ttabs,\n\tselectOnMove = true,\n\tinitialTabName,\n\torientation = 'horizontal',\n\tactiveClass = 'is-active',\n\tonSelect,\n}: WordPressComponentProps< TabPanelProps, 'div', false > ) {\n\tconst instanceId = useInstanceId( TabPanel, 'tab-panel' );\n\tconst [ selected, setSelected ] = useState< string >();\n\n\tconst handleTabSelection = useCallback(\n\t\t( tabKey: string ) => {\n\t\t\tsetSelected( tabKey );\n\t\t\tonSelect?.( tabKey );\n\t\t},\n\t\t[ onSelect ]\n\t);\n\n\t// Simulate a click on the newly focused tab, which causes the component\n\t// to show the `tab-panel` associated with the clicked tab.\n\tconst activateTabAutomatically = (\n\t\t_childIndex: number,\n\t\tchild: HTMLButtonElement\n\t) => {\n\t\tchild.click();\n\t};\n\tconst selectedTab = tabs.find( ( { name } ) => name === selected );\n\tconst selectedId = `${ instanceId }-${ selectedTab?.name ?? 'none' }`;\n\n\tuseEffect( () => {\n\t\tif ( ! selectedTab?.name && tabs.length > 0 ) {\n\t\t\thandleTabSelection( initialTabName || tabs[ 0 ].name );\n\t\t}\n\t}, [ tabs, selectedTab?.name, initialTabName, handleTabSelection ] );\n\n\treturn (\n\t\t<div className={ className }>\n\t\t\t<NavigableMenu\n\t\t\t\trole=\"tablist\"\n\t\t\t\torientation={ orientation }\n\t\t\t\tonNavigate={\n\t\t\t\t\tselectOnMove ? activateTabAutomatically : undefined\n\t\t\t\t}\n\t\t\t\tclassName=\"components-tab-panel__tabs\"\n\t\t\t>\n\t\t\t\t{ tabs.map( ( tab ) => (\n\t\t\t\t\t<TabButton\n\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t'components-tab-panel__tabs-item',\n\t\t\t\t\t\t\ttab.className,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t[ activeClass ]: tab.name === selected,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t) }\n\t\t\t\t\t\ttabId={ `${ instanceId }-${ tab.name }` }\n\t\t\t\t\t\taria-controls={ `${ instanceId }-${ tab.name }-view` }\n\t\t\t\t\t\tselected={ tab.name === selected }\n\t\t\t\t\t\tkey={ tab.name }\n\t\t\t\t\t\tonClick={ () => handleTabSelection( tab.name ) }\n\t\t\t\t\t\tlabel={ tab.icon && tab.title }\n\t\t\t\t\t\ticon={ tab.icon }\n\t\t\t\t\t\tshowTooltip={ !! tab.icon }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ ! tab.icon && tab.title }\n\t\t\t\t\t</TabButton>\n\t\t\t\t) ) }\n\t\t\t</NavigableMenu>\n\t\t\t{ selectedTab && (\n\t\t\t\t<div\n\t\t\t\t\tkey={ selectedId }\n\t\t\t\t\taria-labelledby={ selectedId }\n\t\t\t\t\trole=\"tabpanel\"\n\t\t\t\t\tid={ `${ selectedId }-view` }\n\t\t\t\t\tclassName=\"components-tab-panel__tab-content\"\n\t\t\t\t>\n\t\t\t\t\t{ children( selectedTab ) }\n\t\t\t\t</div>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n\nexport default TabPanel;\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/tab-panel/index.tsx"],"names":["classnames","useState","useEffect","useCallback","useInstanceId","NavigableMenu","Button","TabButton","tabId","children","selected","rest","TabPanel","className","tabs","selectOnMove","initialTabName","orientation","activeClass","onSelect","instanceId","setSelected","handleTabSelection","tabKey","activateTabAutomatically","_childIndex","child","click","selectedTab","find","name","selectedId","firstEnabledTab","tab","disabled","initialTab","undefined","map","icon","title"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,QAAT,EAAmBC,SAAnB,EAA8BC,WAA9B,QAAiD,oBAAjD;AACA,SAASC,aAAT,QAA8B,oBAA9B;AAEA;AACA;AACA;;AACA,SAASC,aAAT,QAA8B,wBAA9B;AACA,OAAOC,MAAP,MAAmB,WAAnB;;AAIA,MAAMC,SAAS,GAAG;AAAA,MAAE;AACnBC,IAAAA,KADmB;AAEnBC,IAAAA,QAFmB;AAGnBC,IAAAA,QAHmB;AAInB,OAAGC;AAJgB,GAAF;AAAA,SAMjB,cAAC,MAAD;AACC,IAAA,IAAI,EAAC,KADN;AAEC,IAAA,QAAQ,EAAGD,QAAQ,GAAG,IAAH,GAAU,CAAC,CAF/B;AAGC,qBAAgBA,QAHjB;AAIC,IAAA,EAAE,EAAGF,KAJN;AAKC,IAAA,yBAAyB;AAL1B,KAMMG,IANN,GAQGF,QARH,CANiB;AAAA,CAAlB;AAkBA;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;AACA;AACA;AACA;AACA;AACA;;;AACA,OAAO,SAASG,QAAT,QASqD;AAAA;;AAAA,MATlC;AACzBC,IAAAA,SADyB;AAEzBJ,IAAAA,QAFyB;AAGzBK,IAAAA,IAHyB;A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ACC,QAbhB;AAcC,IAAA,KAAK,EAAGD,GAAG,CAACK,IAAJ,IAAYL,GAAG,CAACM,KAdzB;AAeC,IAAA,IAAI,EAAGN,GAAG,CAACK,IAfZ;AAgBC,IAAA,WAAW,EAAG,CAAC,CAAEL,GAAG,CAACK;AAhBtB,KAkBG,CAAEL,GAAG,CAACK,IAAN,IAAcL,GAAG,CAACM,KAlBrB,CADC,CARH,CADD,EAgCGX,WAAW,IACZ;AACC,IAAA,GAAG,EAAGG,UADP;AAEC,uBAAkBA,UAFnB;AAGC,IAAA,IAAI,EAAC,UAHN;AAIC,IAAA,EAAE,EAAI,GAAGA,UAAY,OAJtB;AAKC,IAAA,SAAS,EAAC;AALX,KAOGtB,QAAQ,CAAEmB,WAAF,CAPX,CAjCF,CADD;AA8CA;AAED,eAAehB,QAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useState, useEffect, useCallback } from '@wordpress/element';\nimport { useInstanceId } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { NavigableMenu } from '../navigable-container';\nimport Button from '../button';\nimport type { TabButtonProps, TabPanelProps } from './types';\nimport type { WordPressComponentProps } from '../ui/context';\n\nconst TabButton = ( {\n\ttabId,\n\tchildren,\n\tselected,\n\t...rest\n}: TabButtonProps ) => (\n\t<Button\n\t\trole=\"tab\"\n\t\ttabIndex={ selected ? null : -1 }\n\t\taria-selected={ selected }\n\t\tid={ tabId }\n\t\t__experimentalIsFocusable\n\t\t{ ...rest }\n\t>\n\t\t{ children }\n\t</Button>\n);\n\n/**\n * TabPanel is an ARIA-compliant tabpanel.\n *\n * TabPanels organize content across different screens, data sets, and interactions.\n * It has two sections: a list of tabs, and the view to show when tabs are chosen.\n *\n * ```jsx\n * import { TabPanel } from '@wordpress/components';\n *\n * const onSelect = ( tabName ) => {\n * console.log( 'Selecting tab', tabName );\n * };\n *\n * const MyTabPanel = () => (\n * <TabPanel\n * className=\"my-tab-panel\"\n * activeClass=\"active-tab\"\n * onSelect={ onSelect }\n * tabs={ [\n * {\n * name: 'tab1',\n * title: 'Tab 1',\n * className: 'tab-one',\n * },\n * {\n * name: 'tab2',\n * title: 'Tab 2',\n * className: 'tab-two',\n * },\n * ] }\n * >\n * { ( tab ) => <p>{ tab.title }</p> }\n * </TabPanel>\n * );\n * ```\n */\nexport function TabPanel( {\n\tclassName,\n\tchildren,\n\ttabs,\n\tselectOnMove = true,\n\tinitialTabName,\n\torientation = 'horizontal',\n\tactiveClass = 'is-active',\n\tonSelect,\n}: WordPressComponentProps< TabPanelProps, 'div', false > ) {\n\tconst instanceId = useInstanceId( TabPanel, 'tab-panel' );\n\tconst [ selected, setSelected ] = useState< string >();\n\n\tconst handleTabSelection = useCallback(\n\t\t( tabKey: string ) => {\n\t\t\tsetSelected( tabKey );\n\t\t\tonSelect?.( tabKey );\n\t\t},\n\t\t[ onSelect ]\n\t);\n\n\t// Simulate a click on the newly focused tab, which causes the component\n\t// to show the `tab-panel` associated with the clicked tab.\n\tconst activateTabAutomatically = (\n\t\t_childIndex: number,\n\t\tchild: HTMLButtonElement\n\t) => {\n\t\tchild.click();\n\t};\n\tconst selectedTab = tabs.find( ( { name } ) => name === selected );\n\tconst selectedId = `${ instanceId }-${ selectedTab?.name ?? 'none' }`;\n\n\tuseEffect( () => {\n\t\tconst firstEnabledTab = tabs.find( ( tab ) => ! tab.disabled );\n\t\tconst initialTab = tabs.find( ( tab ) => tab.name === initialTabName );\n\t\tif ( ! selectedTab?.name && firstEnabledTab ) {\n\t\t\thandleTabSelection(\n\t\t\t\tinitialTab && ! initialTab.disabled\n\t\t\t\t\t? initialTab.name\n\t\t\t\t\t: firstEnabledTab.name\n\t\t\t);\n\t\t} else if ( selectedTab?.disabled && firstEnabledTab ) {\n\t\t\thandleTabSelection( firstEnabledTab.name );\n\t\t}\n\t}, [\n\t\ttabs,\n\t\tselectedTab?.name,\n\t\tselectedTab?.disabled,\n\t\tinitialTabName,\n\t\thandleTabSelection,\n\t] );\n\n\treturn (\n\t\t<div className={ className }>\n\t\t\t<NavigableMenu\n\t\t\t\trole=\"tablist\"\n\t\t\t\torientation={ orientation }\n\t\t\t\tonNavigate={\n\t\t\t\t\tselectOnMove ? activateTabAutomatically : undefined\n\t\t\t\t}\n\t\t\t\tclassName=\"components-tab-panel__tabs\"\n\t\t\t>\n\t\t\t\t{ tabs.map( ( tab ) => (\n\t\t\t\t\t<TabButton\n\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t'components-tab-panel__tabs-item',\n\t\t\t\t\t\t\ttab.className,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t[ activeClass ]: tab.name === selected,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t) }\n\t\t\t\t\t\ttabId={ `${ instanceId }-${ tab.name }` }\n\t\t\t\t\t\taria-controls={ `${ instanceId }-${ tab.name }-view` }\n\t\t\t\t\t\tselected={ tab.name === selected }\n\t\t\t\t\t\tkey={ tab.name }\n\t\t\t\t\t\tonClick={ () => handleTabSelection( tab.name ) }\n\t\t\t\t\t\tdisabled={ tab.disabled }\n\t\t\t\t\t\tlabel={ tab.icon && tab.title }\n\t\t\t\t\t\ticon={ tab.icon }\n\t\t\t\t\t\tshowTooltip={ !! tab.icon }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ ! tab.icon && tab.title }\n\t\t\t\t\t</TabButton>\n\t\t\t\t) ) }\n\t\t\t</NavigableMenu>\n\t\t\t{ selectedTab && (\n\t\t\t\t<div\n\t\t\t\t\tkey={ selectedId }\n\t\t\t\t\taria-labelledby={ selectedId }\n\t\t\t\t\trole=\"tabpanel\"\n\t\t\t\t\tid={ `${ selectedId }-view` }\n\t\t\t\t\tclassName=\"components-tab-panel__tab-content\"\n\t\t\t\t>\n\t\t\t\t\t{ children( selectedTab ) }\n\t\t\t\t</div>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n\nexport default TabPanel;\n"]}
@@ -1,59 +1,7 @@
1
- import _extends from "@babel/runtime/helpers/esm/extends";
2
- import { createElement } from "@wordpress/element";
3
-
4
- /**
5
- * External dependencies
6
- */
7
- import classnames from 'classnames';
8
- /**
9
- * WordPress dependencies
10
- */
11
-
12
- import { forwardRef } from '@wordpress/element';
13
- import deprecated from '@wordpress/deprecated';
14
- /**
15
- * Internal dependencies
16
- */
17
-
18
- import ToolbarGroup from '../toolbar-group';
19
- import ToolbarContainer from './toolbar-container';
20
- /**
21
- * Renders a toolbar.
22
- *
23
- * To add controls, simply pass `ToolbarButton` components as children.
24
- *
25
- * @param {Object} props Component props.
26
- * @param {string} [props.className] Class to set on the container div.
27
- * @param {string} [props.label] ARIA label for toolbar container.
28
- * @param {Object} ref React Element ref.
29
- */
30
-
31
- function Toolbar(_ref, ref) {
32
- let {
33
- className,
34
- label,
35
- ...props
36
- } = _ref;
37
-
38
- if (!label) {
39
- deprecated('Using Toolbar without label prop', {
40
- since: '5.6',
41
- alternative: 'ToolbarGroup component',
42
- link: 'https://developer.wordpress.org/block-editor/components/toolbar/'
43
- });
44
- return createElement(ToolbarGroup, _extends({}, props, {
45
- className: className
46
- }));
47
- } // `ToolbarGroup` already uses components-toolbar for compatibility reasons.
48
-
49
-
50
- const finalClassName = classnames('components-accessible-toolbar', className);
51
- return createElement(ToolbarContainer, _extends({
52
- className: finalClassName,
53
- label: label,
54
- ref: ref
55
- }, props));
56
- }
57
-
58
- export default forwardRef(Toolbar);
1
+ export { default as Toolbar } from './toolbar';
2
+ export { default as ToolbarButton } from './toolbar-button';
3
+ export { default as ToolbarContext } from './toolbar-context';
4
+ export { default as ToolbarDropdownMenu } from './toolbar-dropdown-menu';
5
+ export { default as ToolbarGroup } from './toolbar-group';
6
+ export { default as ToolbarItem } from './toolbar-item';
59
7
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/toolbar/index.js"],"names":["classnames","forwardRef","deprecated","ToolbarGroup","ToolbarContainer","Toolbar","ref","className","label","props","since","alternative","link","finalClassName"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,UAAT,QAA2B,oBAA3B;AACA,OAAOC,UAAP,MAAuB,uBAAvB;AAEA;AACA;AACA;;AACA,OAAOC,YAAP,MAAyB,kBAAzB;AACA,OAAOC,gBAAP,MAA6B,qBAA7B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,OAAT,OAAkDC,GAAlD,EAAwD;AAAA,MAAtC;AAAEC,IAAAA,SAAF;AAAaC,IAAAA,KAAb;AAAoB,OAAGC;AAAvB,GAAsC;;AACvD,MAAK,CAAED,KAAP,EAAe;AACdN,IAAAA,UAAU,CAAE,kCAAF,EAAsC;AAC/CQ,MAAAA,KAAK,EAAE,KADwC;AAE/CC,MAAAA,WAAW,EAAE,wBAFkC;AAG/CC,MAAAA,IAAI,EAAE;AAHyC,KAAtC,CAAV;AAKA,WAAO,cAAC,YAAD,eAAmBH,KAAnB;AAA2B,MAAA,SAAS,EAAGF;AAAvC,OAAP;AACA,GARsD,CASvD;;;AACA,QAAMM,cAAc,GAAGb,UAAU,CAChC,+BADgC,EAEhCO,SAFgC,CAAjC;AAIA,SACC,cAAC,gBAAD;AACC,IAAA,SAAS,EAAGM,cADb;AAEC,IAAA,KAAK,EAAGL,KAFT;AAGC,IAAA,GAAG,EAAGF;AAHP,KAIMG,KAJN,EADD;AAQA;;AAED,eAAeR,UAAU,CAAEI,OAAF,CAAzB","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { forwardRef } from '@wordpress/element';\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport ToolbarGroup from '../toolbar-group';\nimport ToolbarContainer from './toolbar-container';\n\n/**\n * Renders a toolbar.\n *\n * To add controls, simply pass `ToolbarButton` components as children.\n *\n * @param {Object} props Component props.\n * @param {string} [props.className] Class to set on the container div.\n * @param {string} [props.label] ARIA label for toolbar container.\n * @param {Object} ref React Element ref.\n */\nfunction Toolbar( { className, label, ...props }, ref ) {\n\tif ( ! label ) {\n\t\tdeprecated( 'Using Toolbar without label prop', {\n\t\t\tsince: '5.6',\n\t\t\talternative: 'ToolbarGroup component',\n\t\t\tlink: 'https://developer.wordpress.org/block-editor/components/toolbar/',\n\t\t} );\n\t\treturn <ToolbarGroup { ...props } className={ className } />;\n\t}\n\t// `ToolbarGroup` already uses components-toolbar for compatibility reasons.\n\tconst finalClassName = classnames(\n\t\t'components-accessible-toolbar',\n\t\tclassName\n\t);\n\treturn (\n\t\t<ToolbarContainer\n\t\t\tclassName={ finalClassName }\n\t\t\tlabel={ label }\n\t\t\tref={ ref }\n\t\t\t{ ...props }\n\t\t/>\n\t);\n}\n\nexport default forwardRef( Toolbar );\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/toolbar/index.js"],"names":["default","Toolbar","ToolbarButton","ToolbarContext","ToolbarDropdownMenu","ToolbarGroup","ToolbarItem"],"mappings":"AAAA,SAASA,OAAO,IAAIC,OAApB,QAAmC,WAAnC;AACA,SAASD,OAAO,IAAIE,aAApB,QAAyC,kBAAzC;AACA,SAASF,OAAO,IAAIG,cAApB,QAA0C,mBAA1C;AACA,SAASH,OAAO,IAAII,mBAApB,QAA+C,yBAA/C;AACA,SAASJ,OAAO,IAAIK,YAApB,QAAwC,iBAAxC;AACA,SAASL,OAAO,IAAIM,WAApB,QAAuC,gBAAvC","sourcesContent":["export { default as Toolbar } from './toolbar';\nexport { default as ToolbarButton } from './toolbar-button';\nexport { default as ToolbarContext } from './toolbar-context';\nexport { default as ToolbarDropdownMenu } from './toolbar-dropdown-menu';\nexport { default as ToolbarGroup } from './toolbar-group';\nexport { default as ToolbarItem } from './toolbar-item';\n"]}
@@ -0,0 +1,59 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import { createElement } from "@wordpress/element";
3
+
4
+ /**
5
+ * External dependencies
6
+ */
7
+ import classnames from 'classnames';
8
+ /**
9
+ * WordPress dependencies
10
+ */
11
+
12
+ import { forwardRef } from '@wordpress/element';
13
+ import deprecated from '@wordpress/deprecated';
14
+ /**
15
+ * Internal dependencies
16
+ */
17
+
18
+ import ToolbarGroup from '../toolbar-group';
19
+ import ToolbarContainer from './toolbar-container';
20
+ /**
21
+ * Renders a toolbar.
22
+ *
23
+ * To add controls, simply pass `ToolbarButton` components as children.
24
+ *
25
+ * @param {Object} props Component props.
26
+ * @param {string} [props.className] Class to set on the container div.
27
+ * @param {string} [props.label] ARIA label for toolbar container.
28
+ * @param {Object} ref React Element ref.
29
+ */
30
+
31
+ function Toolbar(_ref, ref) {
32
+ let {
33
+ className,
34
+ label,
35
+ ...props
36
+ } = _ref;
37
+
38
+ if (!label) {
39
+ deprecated('Using Toolbar without label prop', {
40
+ since: '5.6',
41
+ alternative: 'ToolbarGroup component',
42
+ link: 'https://developer.wordpress.org/block-editor/components/toolbar/'
43
+ });
44
+ return createElement(ToolbarGroup, _extends({}, props, {
45
+ className: className
46
+ }));
47
+ } // `ToolbarGroup` already uses components-toolbar for compatibility reasons.
48
+
49
+
50
+ const finalClassName = classnames('components-accessible-toolbar', className);
51
+ return createElement(ToolbarContainer, _extends({
52
+ className: finalClassName,
53
+ label: label,
54
+ ref: ref
55
+ }, props));
56
+ }
57
+
58
+ export default forwardRef(Toolbar);
59
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/components/src/toolbar/toolbar/index.js"],"names":["classnames","forwardRef","deprecated","ToolbarGroup","ToolbarContainer","Toolbar","ref","className","label","props","since","alternative","link","finalClassName"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,UAAT,QAA2B,oBAA3B;AACA,OAAOC,UAAP,MAAuB,uBAAvB;AAEA;AACA;AACA;;AACA,OAAOC,YAAP,MAAyB,kBAAzB;AACA,OAAOC,gBAAP,MAA6B,qBAA7B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,OAAT,OAAkDC,GAAlD,EAAwD;AAAA,MAAtC;AAAEC,IAAAA,SAAF;AAAaC,IAAAA,KAAb;AAAoB,OAAGC;AAAvB,GAAsC;;AACvD,MAAK,CAAED,KAAP,EAAe;AACdN,IAAAA,UAAU,CAAE,kCAAF,EAAsC;AAC/CQ,MAAAA,KAAK,EAAE,KADwC;AAE/CC,MAAAA,WAAW,EAAE,wBAFkC;AAG/CC,MAAAA,IAAI,EAAE;AAHyC,KAAtC,CAAV;AAKA,WAAO,cAAC,YAAD,eAAmBH,KAAnB;AAA2B,MAAA,SAAS,EAAGF;AAAvC,OAAP;AACA,GARsD,CASvD;;;AACA,QAAMM,cAAc,GAAGb,UAAU,CAChC,+BADgC,EAEhCO,SAFgC,CAAjC;AAIA,SACC,cAAC,gBAAD;AACC,IAAA,SAAS,EAAGM,cADb;AAEC,IAAA,KAAK,EAAGL,KAFT;AAGC,IAAA,GAAG,EAAGF;AAHP,KAIMG,KAJN,EADD;AAQA;;AAED,eAAeR,UAAU,CAAEI,OAAF,CAAzB","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { forwardRef } from '@wordpress/element';\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport ToolbarGroup from '../toolbar-group';\nimport ToolbarContainer from './toolbar-container';\n\n/**\n * Renders a toolbar.\n *\n * To add controls, simply pass `ToolbarButton` components as children.\n *\n * @param {Object} props Component props.\n * @param {string} [props.className] Class to set on the container div.\n * @param {string} [props.label] ARIA label for toolbar container.\n * @param {Object} ref React Element ref.\n */\nfunction Toolbar( { className, label, ...props }, ref ) {\n\tif ( ! label ) {\n\t\tdeprecated( 'Using Toolbar without label prop', {\n\t\t\tsince: '5.6',\n\t\t\talternative: 'ToolbarGroup component',\n\t\t\tlink: 'https://developer.wordpress.org/block-editor/components/toolbar/',\n\t\t} );\n\t\treturn <ToolbarGroup { ...props } className={ className } />;\n\t}\n\t// `ToolbarGroup` already uses components-toolbar for compatibility reasons.\n\tconst finalClassName = classnames(\n\t\t'components-accessible-toolbar',\n\t\tclassName\n\t);\n\treturn (\n\t\t<ToolbarContainer\n\t\t\tclassName={ finalClassName }\n\t\t\tlabel={ label }\n\t\t\tref={ ref }\n\t\t\t{ ...props }\n\t\t/>\n\t);\n}\n\nexport default forwardRef( Toolbar );\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/toolbar/toolbar-container.js"],"names":["ToolbarContainer","ref","label","props","toolbarState","loop","baseId","id","rtl"],"mappings":";;;;;;;;;AAQA;;;;AALA;;AAMA;;AAKA;;AAdA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;AAGA,SAASA,gBAAT,OAAgDC,GAAhD,EAAsD;AAAA,MAA3B;AAAEC,IAAAA,KAAF;AAAS,OAAGC;AAAZ,GAA2B;AACrD;AACA;AACA;AACA,QAAMC,YAAY,GAAG,8BAAiB;AACrCC,IAAAA,IAAI,EAAE,IAD+B;AAErCC,IAAAA,MAAM,EAAEH,KAAK,CAACI,EAFuB;AAGrCC,IAAAA,GAAG,EAAE;AAHgC,GAAjB,CAArB;AAMA,SACC;AACA,gCAAC,uBAAD,CAAgB,QAAhB;AAAyB,MAAA,KAAK,EAAGJ;AAAjC,OACC,4BAAC,gBAAD;AACC,MAAA,GAAG,EAAGH,GADP;AAEC,oBAAaC;AAFd,OAGME,YAHN,EAIMD,KAJN,EADD;AAFD;AAWA;;eAEc,yBAAYH,gBAAZ,C","sourcesContent":["/**\n * External dependencies\n */\nimport { useToolbarState, Toolbar } from 'reakit/Toolbar';\n\n/**\n * WordPress dependencies\n */\nimport { forwardRef } from '@wordpress/element';\nimport { isRTL } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport ToolbarContext from '../toolbar-context';\n\nfunction ToolbarContainer( { label, ...props }, ref ) {\n\t// https://reakit.io/docs/basic-concepts/#state-hooks\n\t// Passing baseId for server side rendering (which includes snapshots)\n\t// If an id prop is passed to Toolbar, toolbar items will use it as a base for their ids\n\tconst toolbarState = useToolbarState( {\n\t\tloop: true,\n\t\tbaseId: props.id,\n\t\trtl: isRTL(),\n\t} );\n\n\treturn (\n\t\t// This will provide state for `ToolbarButton`'s\n\t\t<ToolbarContext.Provider value={ toolbarState }>\n\t\t\t<Toolbar\n\t\t\t\tref={ ref }\n\t\t\t\taria-label={ label }\n\t\t\t\t{ ...toolbarState }\n\t\t\t\t{ ...props }\n\t\t\t/>\n\t\t</ToolbarContext.Provider>\n\t);\n}\n\nexport default forwardRef( ToolbarContainer );\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/toolbar/toolbar/toolbar-container.js"],"names":["useToolbarState","Toolbar","forwardRef","isRTL","ToolbarContext","ToolbarContainer","ref","label","props","toolbarState","loop","baseId","id","rtl"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,eAAT,EAA0BC,OAA1B,QAAyC,gBAAzC;AAEA;AACA;AACA;;AACA,SAASC,UAAT,QAA2B,oBAA3B;AACA,SAASC,KAAT,QAAsB,iBAAtB;AAEA;AACA;AACA;;AACA,OAAOC,cAAP,MAA2B,oBAA3B;;AAEA,SAASC,gBAAT,OAAgDC,GAAhD,EAAsD;AAAA,MAA3B;AAAEC,IAAAA,KAAF;AAAS,OAAGC;AAAZ,GAA2B;AACrD;AACA;AACA;AACA,QAAMC,YAAY,GAAGT,eAAe,CAAE;AACrCU,IAAAA,IAAI,EAAE,IAD+B;AAErCC,IAAAA,MAAM,EAAEH,KAAK,CAACI,EAFuB;AAGrCC,IAAAA,GAAG,EAAEV,KAAK;AAH2B,GAAF,CAApC;AAMA,SACC;AACA,kBAAC,cAAD,CAAgB,QAAhB;AAAyB,MAAA,KAAK,EAAGM;AAAjC,OACC,cAAC,OAAD;AACC,MAAA,GAAG,EAAGH,GADP;AAEC,oBAAaC;AAFd,OAGME,YAHN,EAIMD,KAJN,EADD;AAFD;AAWA;;AAED,eAAeN,UAAU,CAAEG,gBAAF,CAAzB","sourcesContent":["/**\n * External dependencies\n */\nimport { useToolbarState, Toolbar } from 'reakit/Toolbar';\n\n/**\n * WordPress dependencies\n */\nimport { forwardRef } from '@wordpress/element';\nimport { isRTL } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport ToolbarContext from '../toolbar-context';\n\nfunction ToolbarContainer( { label, ...props }, ref ) {\n\t// https://reakit.io/docs/basic-concepts/#state-hooks\n\t// Passing baseId for server side rendering (which includes snapshots)\n\t// If an id prop is passed to Toolbar, toolbar items will use it as a base for their ids\n\tconst toolbarState = useToolbarState( {\n\t\tloop: true,\n\t\tbaseId: props.id,\n\t\trtl: isRTL(),\n\t} );\n\n\treturn (\n\t\t// This will provide state for `ToolbarButton`'s\n\t\t<ToolbarContext.Provider value={ toolbarState }>\n\t\t\t<Toolbar\n\t\t\t\tref={ ref }\n\t\t\t\taria-label={ label }\n\t\t\t\t{ ...toolbarState }\n\t\t\t\t{ ...props }\n\t\t\t/>\n\t\t</ToolbarContext.Provider>\n\t);\n}\n\nexport default forwardRef( ToolbarContainer );\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/components/src/toolbar/toolbar/toolbar-container.native.js"],"names":["View","ToolbarContainer","children"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,IAAT,QAAqB,cAArB;;AAEA,MAAMC,gBAAgB,GAAG;AAAA,MAAE;AAAEC,IAAAA;AAAF,GAAF;AAAA,SAAoB,cAAC,IAAD,QAAQA,QAAR,CAApB;AAAA,CAAzB;;AAEA,eAAeD,gBAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { View } from 'react-native';\n\nconst ToolbarContainer = ( { children } ) => <View>{ children }</View>;\n\nexport default ToolbarContainer;\n"]}
@@ -14,7 +14,7 @@ import { useContext, forwardRef } from '@wordpress/element';
14
14
  * Internal dependencies
15
15
  */
16
16
 
17
- import Button from '../button';
17
+ import Button from '../../button';
18
18
  import ToolbarItem from '../toolbar-item';
19
19
  import ToolbarContext from '../toolbar-context';
20
20
  import ToolbarButtonContainer from './toolbar-button-container';
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/components/src/toolbar/toolbar-button/index.js"],"names":["classnames","useContext","forwardRef","Button","ToolbarItem","ToolbarContext","ToolbarButtonContainer","ToolbarButton","ref","containerClassName","className","extraProps","children","title","isActive","isDisabled","props","accessibleToolbarState","icon","shortcut","subscript","event","stopPropagation","onClick","toolbarItemProps"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AACA;AACA;AACA;;AACA,SAASC,UAAT,EAAqBC,UAArB,QAAuC,oBAAvC;AACA;AACA;AACA;;AACA,OAAOC,MAAP,MAAmB,cAAnB;AACA,OAAOC,WAAP,MAAwB,iBAAxB;AACA,OAAOC,cAAP,MAA2B,oBAA3B;AACA,OAAOC,sBAAP,MAAmC,4BAAnC;;AAEA,SAASC,aAAT,OAWCC,GAXD,EAYE;AAAA,MAXD;AACCC,IAAAA,kBADD;AAECC,IAAAA,SAFD;AAGCC,IAAAA,UAHD;AAICC,IAAAA,QAJD;AAKCC,IAAAA,KALD;AAMCC,IAAAA,QAND;AAOCC,IAAAA,UAPD;AAQC,OAAGC;AARJ,GAWC;AACD,QAAMC,sBAAsB,GAAGhB,UAAU,CAAEI,cAAF,CAAzC;;AAEA,MAAK,CAAEY,sBAAP,EAAgC;AAC/B,WACC,cAAC,sBAAD;AAAwB,MAAA,SAAS,EAAGR;AAApC,OACC,cAAC,MAAD;AACC,MAAA,GAAG,EAAGD,GADP;AAEC,MAAA,IAAI,EAAGQ,KAAK,CAACE,IAFd;AAGC,MAAA,KAAK,EAAGL,KAHT;AAIC,MAAA,QAAQ,EAAGG,KAAK,CAACG,QAJlB;AAKC,wBAAiBH,KAAK,CAACI,SALxB;AAMC,MAAA,OAAO,EAAKC,KAAF,IAAa;AACtBA,QAAAA,KAAK,CAACC,eAAN;;AACA,YAAKN,KAAK,CAACO,OAAX,EAAqB;AACpBP,UAAAA,KAAK,CAACO,OAAN,CAAeF,KAAf;AACA;AACD,OAXF;AAYC,MAAA,SAAS,EAAGrB,UAAU,CACrB,6BADqB,EAErBU,SAFqB,CAZvB;AAgBC,MAAA,SAAS,EAAGI,QAhBb;AAiBC,MAAA,QAAQ,EAAGC,UAjBZ;AAkBC;AAlBD,OAmBMJ,UAnBN,EAoBMK,KApBN,GAsBGJ,QAtBH,CADD,CADD;AA4BA,GAhCA,CAkCD;AACA;AACA;;;AACA,SACC,cAAC,WAAD;AACC,IAAA,SAAS,EAAGZ,UAAU,CAAE,2BAAF,EAA+BU,SAA/B;AADvB,KAEMC,UAFN,EAGMK,KAHN;AAIC,IAAA,GAAG,EAAGR;AAJP,MAMKgB,gBAAF,IACD,cAAC,MAAD;AACC,IAAA,KAAK,EAAGX,KADT;AAEC,IAAA,SAAS,EAAGC,QAFb;AAGC,IAAA,QAAQ,EAAGC;AAHZ,KAIMS,gBAJN,GAMGZ,QANH,CAPF,CADD;AAmBA;;AAED,eAAeV,UAAU,CAAEK,aAAF,CAAzB","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n/**\n * WordPress dependencies\n */\nimport { useContext, forwardRef } from '@wordpress/element';\n/**\n * Internal dependencies\n */\nimport Button from '../../button';\nimport ToolbarItem from '../toolbar-item';\nimport ToolbarContext from '../toolbar-context';\nimport ToolbarButtonContainer from './toolbar-button-container';\n\nfunction ToolbarButton(\n\t{\n\t\tcontainerClassName,\n\t\tclassName,\n\t\textraProps,\n\t\tchildren,\n\t\ttitle,\n\t\tisActive,\n\t\tisDisabled,\n\t\t...props\n\t},\n\tref\n) {\n\tconst accessibleToolbarState = useContext( ToolbarContext );\n\n\tif ( ! accessibleToolbarState ) {\n\t\treturn (\n\t\t\t<ToolbarButtonContainer className={ containerClassName }>\n\t\t\t\t<Button\n\t\t\t\t\tref={ ref }\n\t\t\t\t\ticon={ props.icon }\n\t\t\t\t\tlabel={ title }\n\t\t\t\t\tshortcut={ props.shortcut }\n\t\t\t\t\tdata-subscript={ props.subscript }\n\t\t\t\t\tonClick={ ( event ) => {\n\t\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\t\tif ( props.onClick ) {\n\t\t\t\t\t\t\tprops.onClick( event );\n\t\t\t\t\t\t}\n\t\t\t\t\t} }\n\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t'components-toolbar__control',\n\t\t\t\t\t\tclassName\n\t\t\t\t\t) }\n\t\t\t\t\tisPressed={ isActive }\n\t\t\t\t\tdisabled={ isDisabled }\n\t\t\t\t\tdata-toolbar-item\n\t\t\t\t\t{ ...extraProps }\n\t\t\t\t\t{ ...props }\n\t\t\t\t>\n\t\t\t\t\t{ children }\n\t\t\t\t</Button>\n\t\t\t</ToolbarButtonContainer>\n\t\t);\n\t}\n\n\t// ToobarItem will pass all props to the render prop child, which will pass\n\t// all props to Button. This means that ToolbarButton has the same API as\n\t// Button.\n\treturn (\n\t\t<ToolbarItem\n\t\t\tclassName={ classnames( 'components-toolbar-button', className ) }\n\t\t\t{ ...extraProps }\n\t\t\t{ ...props }\n\t\t\tref={ ref }\n\t\t>\n\t\t\t{ ( toolbarItemProps ) => (\n\t\t\t\t<Button\n\t\t\t\t\tlabel={ title }\n\t\t\t\t\tisPressed={ isActive }\n\t\t\t\t\tdisabled={ isDisabled }\n\t\t\t\t\t{ ...toolbarItemProps }\n\t\t\t\t>\n\t\t\t\t\t{ children }\n\t\t\t\t</Button>\n\t\t\t) }\n\t\t</ToolbarItem>\n\t);\n}\n\nexport default forwardRef( ToolbarButton );\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/components/src/toolbar/toolbar-button/toolbar-button-container.js"],"names":["ToolbarButtonContainer","props","className","children"],"mappings":";;AAAA,MAAMA,sBAAsB,GAAKC,KAAF,IAC9B;AAAK,EAAA,SAAS,EAAGA,KAAK,CAACC;AAAvB,GAAqCD,KAAK,CAACE,QAA3C,CADD;;AAGA,eAAeH,sBAAf","sourcesContent":["const ToolbarButtonContainer = ( props ) => (\n\t<div className={ props.className }>{ props.children }</div>\n);\nexport default ToolbarButtonContainer;\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/components/src/toolbar/toolbar-button/toolbar-button-container.native.js"],"names":["View","props","children"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,IAAT,QAAqB,cAArB;AAEA,gBAAiBC,KAAF,IAAa,cAAC,IAAD,QAAQA,KAAK,CAACC,QAAd,CAA5B","sourcesContent":["/**\n * External dependencies\n */\nimport { View } from 'react-native';\n\nexport default ( props ) => <View>{ props.children }</View>;\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/components/src/toolbar/toolbar-context/index.js"],"names":["createContext","ToolbarContext"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,aAAT,QAA8B,oBAA9B;AAEA,MAAMC,cAAc,GAAGD,aAAa,EAApC;AAEA,eAAeC,cAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createContext } from '@wordpress/element';\n\nconst ToolbarContext = createContext();\n\nexport default ToolbarContext;\n"]}
@@ -11,7 +11,7 @@ import { forwardRef, useContext } from '@wordpress/element';
11
11
 
12
12
  import ToolbarItem from '../toolbar-item';
13
13
  import ToolbarContext from '../toolbar-context';
14
- import DropdownMenu from '../dropdown-menu';
14
+ import DropdownMenu from '../../dropdown-menu';
15
15
 
16
16
  function ToolbarDropdownMenu(props, ref) {
17
17
  const accessibleToolbarState = useContext(ToolbarContext);
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/components/src/toolbar/toolbar-dropdown-menu/index.js"],"names":["forwardRef","useContext","ToolbarItem","ToolbarContext","DropdownMenu","ToolbarDropdownMenu","props","ref","accessibleToolbarState","toggleProps","toolbarItemProps","variant","popoverProps"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,UAAT,EAAqBC,UAArB,QAAuC,oBAAvC;AAEA;AACA;AACA;;AACA,OAAOC,WAAP,MAAwB,iBAAxB;AACA,OAAOC,cAAP,MAA2B,oBAA3B;AACA,OAAOC,YAAP,MAAyB,qBAAzB;;AAEA,SAASC,mBAAT,CAA8BC,KAA9B,EAAqCC,GAArC,EAA2C;AAC1C,QAAMC,sBAAsB,GAAGP,UAAU,CAAEE,cAAF,CAAzC;;AAEA,MAAK,CAAEK,sBAAP,EAAgC;AAC/B,WAAO,cAAC,YAAD,EAAmBF,KAAnB,CAAP;AACA,GALyC,CAO1C;AACA;AACA;;;AACA,SACC,cAAC,WAAD;AAAa,IAAA,GAAG,EAAGC;AAAnB,KAA8BD,KAAK,CAACG,WAApC,GACKC,gBAAF,IACD,cAAC,YAAD,eACMJ,KADN;AAEC,IAAA,YAAY,EAAG;AACdK,MAAAA,OAAO,EAAE,SADK;AAEd,SAAGL,KAAK,CAACM;AAFK,KAFhB;AAMC,IAAA,WAAW,EAAGF;AANf,KAFF,CADD;AAcA;;AAED,eAAeV,UAAU,CAAEK,mBAAF,CAAzB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { forwardRef, useContext } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport ToolbarItem from '../toolbar-item';\nimport ToolbarContext from '../toolbar-context';\nimport DropdownMenu from '../../dropdown-menu';\n\nfunction ToolbarDropdownMenu( props, ref ) {\n\tconst accessibleToolbarState = useContext( ToolbarContext );\n\n\tif ( ! accessibleToolbarState ) {\n\t\treturn <DropdownMenu { ...props } />;\n\t}\n\n\t// ToobarItem will pass all props to the render prop child, which will pass\n\t// all props to the toggle of DropdownMenu. This means that ToolbarDropdownMenu\n\t// has the same API as DropdownMenu.\n\treturn (\n\t\t<ToolbarItem ref={ ref } { ...props.toggleProps }>\n\t\t\t{ ( toolbarItemProps ) => (\n\t\t\t\t<DropdownMenu\n\t\t\t\t\t{ ...props }\n\t\t\t\t\tpopoverProps={ {\n\t\t\t\t\t\tvariant: 'toolbar',\n\t\t\t\t\t\t...props.popoverProps,\n\t\t\t\t\t} }\n\t\t\t\t\ttoggleProps={ toolbarItemProps }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</ToolbarItem>\n\t);\n}\n\nexport default forwardRef( ToolbarDropdownMenu );\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/components/src/toolbar/toolbar-group/index.js"],"names":["classnames","useContext","ToolbarButton","ToolbarGroupContainer","ToolbarGroupCollapsed","ToolbarContext","ToolbarGroup","controls","children","className","isCollapsed","title","props","accessibleToolbarState","length","finalClassName","controlSets","Array","isArray","flatMap","controlSet","indexOfSet","map","control","indexOfControl","join"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,UAAT,QAA2B,oBAA3B;AAEA;AACA;AACA;;AACA,OAAOC,aAAP,MAA0B,mBAA1B;AACA,OAAOC,qBAAP,MAAkC,2BAAlC;AACA,OAAOC,qBAAP,MAAkC,2BAAlC;AACA,OAAOC,cAAP,MAA2B,oBAA3B;AAEA;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,SAASC,YAAT,OAOI;AAAA;;AAAA,MAPmB;AACtBC,IAAAA,QAAQ,GAAG,EADW;AAEtBC,IAAAA,QAFsB;AAGtBC,IAAAA,SAHsB;AAItBC,IAAAA,WAJsB;AAKtBC,IAAAA,KALsB;AAMtB,OAAGC;AANmB,GAOnB;AACH;AACA;AACA,QAAMC,sBAAsB,GAAGZ,UAAU,CAAEI,cAAF,CAAzC;;AAEA,MAAK,CAAE,CAAEE,QAAF,IAAc,CAAEA,QAAQ,CAACO,MAA3B,KAAuC,CAAEN,QAA9C,EAAyD;AACxD,WAAO,IAAP;AACA;;AAED,QAAMO,cAAc,GAAGf,UAAU,EAChC;AACA;AACAa,EAAAA,sBAAsB,GACnB,0BADmB,GAEnB,oBAL6B,EAMhCJ,SANgC,CAAjC,CATG,CAkBH;;AACA,MAAIO,WAAW,GAAGT,QAAlB;;AACA,MAAK,CAAEU,KAAK,CAACC,OAAN,CAAeF,WAAW,CAAE,CAAF,CAA1B,CAAP,EAA2C;AAC1CA,IAAAA,WAAW,GAAG,CAAEA,WAAF,CAAd;AACA;;AAED,MAAKN,WAAL,EAAmB;AAClB,WACC,cAAC,qBAAD;AACC,MAAA,KAAK,EAAGC,KADT;AAEC,MAAA,QAAQ,EAAGK,WAFZ;AAGC,MAAA,SAAS,EAAGD,cAHb;AAIC,MAAA,QAAQ,EAAGP;AAJZ,OAKMI,KALN,EADD;AASA;;AAED,SACC,cAAC,qBAAD;AAAuB,IAAA,SAAS,EAAGG;AAAnC,KAAyDH,KAAzD,mBACGI,WADH,iDACG,aAAaG,OAAb,CAAsB,CAAEC,UAAF,EAAcC,UAAd,KACvBD,UAAU,CAACE,GAAX,CAAgB,CAAEC,OAAF,EAAWC,cAAX,KACf,cAAC,aAAD;AACC,IAAA,GAAG,EAAG,CAAEH,UAAF,EAAcG,cAAd,EAA+BC,IAA/B,EADP;AAEC,IAAA,kBAAkB,EACjBJ,UAAU,GAAG,CAAb,IAAkBG,cAAc,KAAK,CAArC,GACG,kBADH,GAEG;AALL,KAOMD,OAPN,EADD,CADC,CADH,EAcGf,QAdH,CADD;AAkBA;;AAED,eAAeF,YAAf","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';\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"]}
@@ -9,7 +9,7 @@ import { useContext } from '@wordpress/element';
9
9
  * Internal dependencies
10
10
  */
11
11
 
12
- import DropdownMenu from '../dropdown-menu';
12
+ import DropdownMenu from '../../dropdown-menu';
13
13
  import ToolbarContext from '../toolbar-context';
14
14
  import ToolbarItem from '../toolbar-item';
15
15
 
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/components/src/toolbar/toolbar-group/toolbar-group-collapsed.js"],"names":["useContext","DropdownMenu","ToolbarContext","ToolbarItem","ToolbarGroupCollapsed","controls","toggleProps","props","accessibleToolbarState","renderDropdownMenu","internalToggleProps"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,UAAT,QAA2B,oBAA3B;AAEA;AACA;AACA;;AACA,OAAOC,YAAP,MAAyB,qBAAzB;AACA,OAAOC,cAAP,MAA2B,oBAA3B;AACA,OAAOC,WAAP,MAAwB,iBAAxB;;AAEA,SAASC,qBAAT,OAA2E;AAAA,MAA3C;AAAEC,IAAAA,QAAQ,GAAG,EAAb;AAAiBC,IAAAA,WAAjB;AAA8B,OAAGC;AAAjC,GAA2C;AAC1E;AACA;AACA,QAAMC,sBAAsB,GAAGR,UAAU,CAAEE,cAAF,CAAzC;;AAEA,QAAMO,kBAAkB,GAAKC,mBAAF,IAC1B,cAAC,YAAD;AACC,IAAA,QAAQ,EAAGL,QADZ;AAEC,IAAA,WAAW,EAAG,EACb,GAAGK,mBADU;AAEb,2BAAqB;AAFR;AAFf,KAMMH,KANN,EADD;;AAWA,MAAKC,sBAAL,EAA8B;AAC7B,WACC,cAAC,WAAD,EAAkBF,WAAlB,EAAkCG,kBAAlC,CADD;AAGA;;AAED,SAAOA,kBAAkB,CAAEH,WAAF,CAAzB;AACA;;AAED,eAAeF,qBAAf","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';\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"]}