@wordpress/editor 14.33.3-next.36001005c.0 → 14.34.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 (353) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/bindings/post-data.js +10 -17
  3. package/build/bindings/post-data.js.map +2 -2
  4. package/build/bindings/post-meta.js +7 -14
  5. package/build/bindings/post-meta.js.map +2 -2
  6. package/build/bindings/term-data.js +6 -16
  7. package/build/bindings/term-data.js.map +2 -2
  8. package/build/components/collab-sidebar/add-comment.js +26 -3
  9. package/build/components/collab-sidebar/add-comment.js.map +3 -3
  10. package/build/components/collab-sidebar/comment-author-info.js +26 -14
  11. package/build/components/collab-sidebar/comment-author-info.js.map +2 -2
  12. package/build/components/collab-sidebar/comment-indicator-toolbar.js +6 -22
  13. package/build/components/collab-sidebar/comment-indicator-toolbar.js.map +3 -3
  14. package/build/components/collab-sidebar/comments.js +105 -28
  15. package/build/components/collab-sidebar/comments.js.map +3 -3
  16. package/build/components/collab-sidebar/hooks.js +3 -4
  17. package/build/components/collab-sidebar/hooks.js.map +2 -2
  18. package/build/components/collab-sidebar/index.js +42 -57
  19. package/build/components/collab-sidebar/index.js.map +3 -3
  20. package/build/components/document-bar/index.js +16 -3
  21. package/build/components/document-bar/index.js.map +2 -2
  22. package/build/components/editor/index.js +25 -4
  23. package/build/components/editor/index.js.map +3 -3
  24. package/build/components/editor-interface/index.js +15 -10
  25. package/build/components/editor-interface/index.js.map +3 -3
  26. package/build/components/entities-saved-states/entity-type-list.js +19 -15
  27. package/build/components/entities-saved-states/entity-type-list.js.map +3 -3
  28. package/build/components/global-styles/block-link.js +70 -0
  29. package/build/components/global-styles/block-link.js.map +7 -0
  30. package/build/components/global-styles/header.js +54 -0
  31. package/build/components/global-styles/header.js.map +7 -0
  32. package/build/components/global-styles/hooks.js +176 -0
  33. package/build/components/global-styles/hooks.js.map +7 -0
  34. package/build/components/global-styles/index.js +138 -0
  35. package/build/components/global-styles/index.js.map +7 -0
  36. package/build/components/global-styles/menu.js +95 -0
  37. package/build/components/global-styles/menu.js.map +7 -0
  38. package/build/components/global-styles-provider/index.js +3 -49
  39. package/build/components/global-styles-provider/index.js.map +3 -3
  40. package/build/components/global-styles-renderer/index.js +55 -0
  41. package/build/components/global-styles-renderer/index.js.map +7 -0
  42. package/build/components/global-styles-sidebar/default-sidebar.js +66 -0
  43. package/build/components/global-styles-sidebar/default-sidebar.js.map +7 -0
  44. package/build/components/global-styles-sidebar/index.js +182 -0
  45. package/build/components/global-styles-sidebar/index.js.map +7 -0
  46. package/build/components/global-styles-sidebar/welcome-guide-image.js +37 -0
  47. package/build/components/global-styles-sidebar/welcome-guide-image.js.map +7 -0
  48. package/build/components/global-styles-sidebar/welcome-guide.js +143 -0
  49. package/build/components/global-styles-sidebar/welcome-guide.js.map +7 -0
  50. package/build/components/header/index.js +12 -12
  51. package/build/components/header/index.js.map +3 -3
  52. package/build/components/post-featured-image/index.js +32 -1
  53. package/build/components/post-featured-image/index.js.map +3 -3
  54. package/build/components/post-template/hooks.js +7 -38
  55. package/build/components/post-template/hooks.js.map +2 -2
  56. package/build/components/provider/index.js +1 -1
  57. package/build/components/provider/index.js.map +2 -2
  58. package/build/components/style-book/categories.js +86 -0
  59. package/build/components/style-book/categories.js.map +7 -0
  60. package/build/components/style-book/color-examples.js +64 -0
  61. package/build/components/style-book/color-examples.js.map +7 -0
  62. package/build/components/style-book/constants.js +319 -0
  63. package/build/components/style-book/constants.js.map +7 -0
  64. package/build/components/style-book/duotone-examples.js +68 -0
  65. package/build/components/style-book/duotone-examples.js.map +7 -0
  66. package/build/components/style-book/examples.js +237 -0
  67. package/build/components/style-book/examples.js.map +7 -0
  68. package/build/components/style-book/index.js +627 -0
  69. package/build/components/style-book/index.js.map +7 -0
  70. package/build/components/style-book/types.js +17 -0
  71. package/build/components/style-book/types.js.map +7 -0
  72. package/build/components/styles-canvas/index.js +138 -0
  73. package/build/components/styles-canvas/index.js.map +7 -0
  74. package/build/components/styles-canvas/revisions.js +121 -0
  75. package/build/components/styles-canvas/revisions.js.map +7 -0
  76. package/build/components/styles-canvas/style-book.js +68 -0
  77. package/build/components/styles-canvas/style-book.js.map +7 -0
  78. package/build/components/visual-editor/index.js +4 -3
  79. package/build/components/visual-editor/index.js.map +2 -2
  80. package/build/dataviews/fields/content-preview/content-preview-view.js.map +2 -2
  81. package/build/hooks/index.js +1 -0
  82. package/build/hooks/index.js.map +2 -2
  83. package/build/hooks/media-upload.js +15 -4
  84. package/build/hooks/media-upload.js.map +3 -3
  85. package/build/hooks/push-changes-to-global-styles/index.js +322 -0
  86. package/build/hooks/push-changes-to-global-styles/index.js.map +7 -0
  87. package/build/hooks/use-global-styles-output.js +74 -0
  88. package/build/hooks/use-global-styles-output.js.map +7 -0
  89. package/build/private-apis.js +10 -5
  90. package/build/private-apis.js.map +3 -3
  91. package/build/store/actions.js +1 -1
  92. package/build/store/actions.js.map +2 -2
  93. package/build/store/private-actions.js +23 -0
  94. package/build/store/private-actions.js.map +2 -2
  95. package/build/store/private-selectors.js +10 -0
  96. package/build/store/private-selectors.js.map +2 -2
  97. package/build/store/reducer.js +24 -0
  98. package/build/store/reducer.js.map +2 -2
  99. package/build/{components/editor-interface/content-slot-fill.js → utils/set-nested-value.js} +24 -10
  100. package/build/utils/set-nested-value.js.map +7 -0
  101. package/build-module/bindings/post-data.js +10 -17
  102. package/build-module/bindings/post-data.js.map +2 -2
  103. package/build-module/bindings/post-meta.js +7 -14
  104. package/build-module/bindings/post-meta.js.map +2 -2
  105. package/build-module/bindings/term-data.js +6 -16
  106. package/build-module/bindings/term-data.js.map +2 -2
  107. package/build-module/components/collab-sidebar/add-comment.js +27 -4
  108. package/build-module/components/collab-sidebar/add-comment.js.map +2 -2
  109. package/build-module/components/collab-sidebar/comment-author-info.js +26 -14
  110. package/build-module/components/collab-sidebar/comment-author-info.js.map +2 -2
  111. package/build-module/components/collab-sidebar/comment-indicator-toolbar.js +6 -12
  112. package/build-module/components/collab-sidebar/comment-indicator-toolbar.js.map +2 -2
  113. package/build-module/components/collab-sidebar/comments.js +114 -31
  114. package/build-module/components/collab-sidebar/comments.js.map +2 -2
  115. package/build-module/components/collab-sidebar/hooks.js +3 -4
  116. package/build-module/components/collab-sidebar/hooks.js.map +2 -2
  117. package/build-module/components/collab-sidebar/index.js +42 -57
  118. package/build-module/components/collab-sidebar/index.js.map +2 -2
  119. package/build-module/components/document-bar/index.js +16 -3
  120. package/build-module/components/document-bar/index.js.map +2 -2
  121. package/build-module/components/editor/index.js +25 -4
  122. package/build-module/components/editor/index.js.map +2 -2
  123. package/build-module/components/editor-interface/index.js +15 -10
  124. package/build-module/components/editor-interface/index.js.map +2 -2
  125. package/build-module/components/entities-saved-states/entity-type-list.js +18 -14
  126. package/build-module/components/entities-saved-states/entity-type-list.js.map +2 -2
  127. package/build-module/components/global-styles/block-link.js +46 -0
  128. package/build-module/components/global-styles/block-link.js.map +7 -0
  129. package/build-module/components/global-styles/header.js +41 -0
  130. package/build-module/components/global-styles/header.js.map +7 -0
  131. package/build-module/components/global-styles/hooks.js +154 -0
  132. package/build-module/components/global-styles/hooks.js.map +7 -0
  133. package/build-module/components/global-styles/index.js +112 -0
  134. package/build-module/components/global-styles/index.js.map +7 -0
  135. package/build-module/components/global-styles/menu.js +71 -0
  136. package/build-module/components/global-styles/menu.js.map +7 -0
  137. package/build-module/components/global-styles-provider/index.js +3 -37
  138. package/build-module/components/global-styles-provider/index.js.map +2 -2
  139. package/build-module/components/global-styles-renderer/index.js +31 -0
  140. package/build-module/components/global-styles-renderer/index.js.map +7 -0
  141. package/build-module/components/global-styles-sidebar/default-sidebar.js +49 -0
  142. package/build-module/components/global-styles-sidebar/default-sidebar.js.map +7 -0
  143. package/build-module/components/global-styles-sidebar/index.js +152 -0
  144. package/build-module/components/global-styles-sidebar/index.js.map +7 -0
  145. package/build-module/components/global-styles-sidebar/welcome-guide-image.js +17 -0
  146. package/build-module/components/global-styles-sidebar/welcome-guide-image.js.map +7 -0
  147. package/build-module/components/global-styles-sidebar/welcome-guide.js +113 -0
  148. package/build-module/components/global-styles-sidebar/welcome-guide.js.map +7 -0
  149. package/build-module/components/header/index.js +12 -12
  150. package/build-module/components/header/index.js.map +2 -2
  151. package/build-module/components/post-featured-image/index.js +35 -3
  152. package/build-module/components/post-featured-image/index.js.map +2 -2
  153. package/build-module/components/post-template/hooks.js +7 -38
  154. package/build-module/components/post-template/hooks.js.map +2 -2
  155. package/build-module/components/provider/index.js +1 -1
  156. package/build-module/components/provider/index.js.map +2 -2
  157. package/build-module/components/style-book/categories.js +64 -0
  158. package/build-module/components/style-book/categories.js.map +7 -0
  159. package/build-module/components/style-book/color-examples.js +37 -0
  160. package/build-module/components/style-book/color-examples.js.map +7 -0
  161. package/build-module/components/style-book/constants.js +290 -0
  162. package/build-module/components/style-book/constants.js.map +7 -0
  163. package/build-module/components/style-book/duotone-examples.js +48 -0
  164. package/build-module/components/style-book/duotone-examples.js.map +7 -0
  165. package/build-module/components/style-book/examples.js +208 -0
  166. package/build-module/components/style-book/examples.js.map +7 -0
  167. package/build-module/components/style-book/index.js +618 -0
  168. package/build-module/components/style-book/index.js.map +7 -0
  169. package/build-module/components/style-book/types.js +1 -0
  170. package/build-module/components/style-book/types.js.map +7 -0
  171. package/build-module/components/styles-canvas/index.js +104 -0
  172. package/build-module/components/styles-canvas/index.js.map +7 -0
  173. package/build-module/components/styles-canvas/revisions.js +107 -0
  174. package/build-module/components/styles-canvas/revisions.js.map +7 -0
  175. package/build-module/components/styles-canvas/style-book.js +38 -0
  176. package/build-module/components/styles-canvas/style-book.js.map +7 -0
  177. package/build-module/components/visual-editor/index.js +4 -3
  178. package/build-module/components/visual-editor/index.js.map +2 -2
  179. package/build-module/dataviews/fields/content-preview/content-preview-view.js.map +2 -2
  180. package/build-module/hooks/index.js +1 -0
  181. package/build-module/hooks/index.js.map +2 -2
  182. package/build-module/hooks/media-upload.js +19 -5
  183. package/build-module/hooks/media-upload.js.map +2 -2
  184. package/build-module/hooks/push-changes-to-global-styles/index.js +309 -0
  185. package/build-module/hooks/push-changes-to-global-styles/index.js.map +7 -0
  186. package/build-module/hooks/use-global-styles-output.js +49 -0
  187. package/build-module/hooks/use-global-styles-output.js.map +7 -0
  188. package/build-module/private-apis.js +10 -8
  189. package/build-module/private-apis.js.map +2 -2
  190. package/build-module/store/actions.js +1 -1
  191. package/build-module/store/actions.js.map +2 -2
  192. package/build-module/store/private-actions.js +20 -0
  193. package/build-module/store/private-actions.js.map +2 -2
  194. package/build-module/store/private-selectors.js +8 -0
  195. package/build-module/store/private-selectors.js.map +2 -2
  196. package/build-module/store/reducer.js +22 -0
  197. package/build-module/store/reducer.js.map +2 -2
  198. package/build-module/utils/set-nested-value.js +23 -0
  199. package/build-module/utils/set-nested-value.js.map +7 -0
  200. package/build-style/style-rtl.css +3011 -16
  201. package/build-style/style.css +3012 -16
  202. package/build-types/bindings/post-data.d.ts +6 -16
  203. package/build-types/bindings/post-meta.d.ts +6 -13
  204. package/build-types/bindings/term-data.d.ts +6 -16
  205. package/build-types/components/collab-sidebar/add-comment.d.ts +6 -1
  206. package/build-types/components/collab-sidebar/add-comment.d.ts.map +1 -1
  207. package/build-types/components/collab-sidebar/comment-author-info.d.ts +5 -16
  208. package/build-types/components/collab-sidebar/comment-author-info.d.ts.map +1 -1
  209. package/build-types/components/collab-sidebar/comment-indicator-toolbar.d.ts +1 -2
  210. package/build-types/components/collab-sidebar/comment-indicator-toolbar.d.ts.map +1 -1
  211. package/build-types/components/collab-sidebar/comments.d.ts +12 -26
  212. package/build-types/components/collab-sidebar/comments.d.ts.map +1 -1
  213. package/build-types/components/collab-sidebar/hooks.d.ts +0 -1
  214. package/build-types/components/collab-sidebar/hooks.d.ts.map +1 -1
  215. package/build-types/components/collab-sidebar/index.d.ts +1 -4
  216. package/build-types/components/collab-sidebar/index.d.ts.map +1 -1
  217. package/build-types/components/document-bar/index.d.ts +2 -2
  218. package/build-types/components/document-bar/index.d.ts.map +1 -1
  219. package/build-types/components/editor/index.d.ts.map +1 -1
  220. package/build-types/components/editor-interface/index.d.ts +1 -3
  221. package/build-types/components/editor-interface/index.d.ts.map +1 -1
  222. package/build-types/components/entities-saved-states/entity-type-list.d.ts.map +1 -1
  223. package/build-types/components/global-styles/block-link.d.ts +12 -0
  224. package/build-types/components/global-styles/block-link.d.ts.map +1 -0
  225. package/build-types/components/global-styles/header.d.ts +7 -0
  226. package/build-types/components/global-styles/header.d.ts.map +1 -0
  227. package/build-types/components/global-styles/hooks.d.ts +24 -0
  228. package/build-types/components/global-styles/hooks.d.ts.map +1 -0
  229. package/build-types/components/global-styles/index.d.ts +6 -0
  230. package/build-types/components/global-styles/index.d.ts.map +1 -0
  231. package/build-types/components/global-styles/menu.d.ts +13 -0
  232. package/build-types/components/global-styles/menu.d.ts.map +1 -0
  233. package/build-types/components/global-styles-provider/index.d.ts +1 -5
  234. package/build-types/components/global-styles-provider/index.d.ts.map +1 -1
  235. package/build-types/components/global-styles-renderer/index.d.ts +4 -0
  236. package/build-types/components/global-styles-renderer/index.d.ts.map +1 -0
  237. package/build-types/components/global-styles-sidebar/default-sidebar.d.ts +13 -0
  238. package/build-types/components/global-styles-sidebar/default-sidebar.d.ts.map +1 -0
  239. package/build-types/components/global-styles-sidebar/index.d.ts +2 -0
  240. package/build-types/components/global-styles-sidebar/index.d.ts.map +1 -0
  241. package/build-types/components/global-styles-sidebar/welcome-guide-image.d.ts +5 -0
  242. package/build-types/components/global-styles-sidebar/welcome-guide-image.d.ts.map +1 -0
  243. package/build-types/components/global-styles-sidebar/welcome-guide.d.ts +2 -0
  244. package/build-types/components/global-styles-sidebar/welcome-guide.d.ts.map +1 -0
  245. package/build-types/components/header/index.d.ts +1 -3
  246. package/build-types/components/header/index.d.ts.map +1 -1
  247. package/build-types/components/post-template/hooks.d.ts +1 -1
  248. package/build-types/components/post-template/hooks.d.ts.map +1 -1
  249. package/build-types/components/provider/index.d.ts.map +1 -1
  250. package/build-types/components/style-book/categories.d.ts +18 -0
  251. package/build-types/components/style-book/categories.d.ts.map +1 -0
  252. package/build-types/components/style-book/color-examples.d.ts +7 -0
  253. package/build-types/components/style-book/color-examples.d.ts.map +1 -0
  254. package/build-types/components/style-book/constants.d.ts +11 -0
  255. package/build-types/components/style-book/constants.d.ts.map +1 -0
  256. package/build-types/components/style-book/duotone-examples.d.ts +9 -0
  257. package/build-types/components/style-book/duotone-examples.d.ts.map +1 -0
  258. package/build-types/components/style-book/examples.d.ts +12 -0
  259. package/build-types/components/style-book/examples.d.ts.map +1 -0
  260. package/build-types/components/style-book/index.d.ts +31 -0
  261. package/build-types/components/style-book/index.d.ts.map +1 -0
  262. package/build-types/components/style-book/types.d.ts +72 -0
  263. package/build-types/components/style-book/types.d.ts.map +1 -0
  264. package/build-types/components/styles-canvas/index.d.ts +16 -0
  265. package/build-types/components/styles-canvas/index.d.ts.map +1 -0
  266. package/build-types/components/styles-canvas/revisions.d.ts +5 -0
  267. package/build-types/components/styles-canvas/revisions.d.ts.map +1 -0
  268. package/build-types/components/styles-canvas/style-book.d.ts +6 -0
  269. package/build-types/components/styles-canvas/style-book.d.ts.map +1 -0
  270. package/build-types/components/visual-editor/index.d.ts +1 -2
  271. package/build-types/components/visual-editor/index.d.ts.map +1 -1
  272. package/build-types/dataviews/fields/content-preview/content-preview-view.d.ts.map +1 -1
  273. package/build-types/hooks/push-changes-to-global-styles/index.d.ts +2 -0
  274. package/build-types/hooks/push-changes-to-global-styles/index.d.ts.map +1 -0
  275. package/build-types/hooks/use-global-styles-output.d.ts +18 -0
  276. package/build-types/hooks/use-global-styles-output.d.ts.map +1 -0
  277. package/build-types/private-apis.d.ts.map +1 -1
  278. package/build-types/store/actions.d.ts.map +1 -1
  279. package/build-types/store/private-actions.d.ts +20 -0
  280. package/build-types/store/private-actions.d.ts.map +1 -1
  281. package/build-types/store/private-selectors.d.ts +14 -0
  282. package/build-types/store/private-selectors.d.ts.map +1 -1
  283. package/build-types/store/reducer.d.ts +20 -0
  284. package/build-types/store/reducer.d.ts.map +1 -1
  285. package/build-types/utils/set-nested-value.d.ts +20 -0
  286. package/build-types/utils/set-nested-value.d.ts.map +1 -0
  287. package/package.json +40 -40
  288. package/src/bindings/post-data.js +9 -20
  289. package/src/bindings/post-meta.js +6 -17
  290. package/src/bindings/term-data.js +6 -21
  291. package/src/components/collab-sidebar/add-comment.js +31 -3
  292. package/src/components/collab-sidebar/comment-author-info.js +32 -25
  293. package/src/components/collab-sidebar/comment-indicator-toolbar.js +6 -22
  294. package/src/components/collab-sidebar/comments.js +108 -35
  295. package/src/components/collab-sidebar/hooks.js +3 -4
  296. package/src/components/collab-sidebar/index.js +34 -42
  297. package/src/components/collab-sidebar/style.scss +1 -22
  298. package/src/components/document-bar/index.js +18 -3
  299. package/src/components/editor/index.js +27 -1
  300. package/src/components/editor-interface/index.js +40 -39
  301. package/src/components/entities-saved-states/entity-type-list.js +19 -17
  302. package/src/components/global-styles/block-link.js +65 -0
  303. package/src/components/global-styles/header.js +48 -0
  304. package/src/components/global-styles/hooks.js +216 -0
  305. package/src/components/global-styles/index.js +125 -0
  306. package/src/components/global-styles/menu.js +101 -0
  307. package/src/components/global-styles/style.scss +11 -0
  308. package/src/components/global-styles-provider/index.js +3 -45
  309. package/src/components/global-styles-renderer/index.js +39 -0
  310. package/src/components/global-styles-sidebar/default-sidebar.js +46 -0
  311. package/src/components/global-styles-sidebar/index.js +177 -0
  312. package/src/components/global-styles-sidebar/style.scss +119 -0
  313. package/src/components/global-styles-sidebar/welcome-guide-image.js +11 -0
  314. package/src/components/global-styles-sidebar/welcome-guide.js +136 -0
  315. package/src/components/header/index.js +11 -13
  316. package/src/components/post-featured-image/index.js +44 -1
  317. package/src/components/post-template/hooks.js +10 -51
  318. package/src/components/provider/index.js +1 -4
  319. package/src/components/style-book/categories.ts +97 -0
  320. package/src/components/style-book/color-examples.tsx +56 -0
  321. package/src/components/style-book/constants.ts +308 -0
  322. package/src/components/style-book/duotone-examples.tsx +56 -0
  323. package/src/components/style-book/examples.tsx +273 -0
  324. package/src/components/style-book/index.js +794 -0
  325. package/src/components/style-book/style.scss +44 -0
  326. package/src/components/style-book/test/categories.js +166 -0
  327. package/src/components/style-book/types.ts +80 -0
  328. package/src/components/styles-canvas/index.js +126 -0
  329. package/src/components/styles-canvas/revisions.js +144 -0
  330. package/src/components/styles-canvas/style-book.js +57 -0
  331. package/src/components/styles-canvas/style.scss +40 -0
  332. package/src/components/visual-editor/index.js +2 -1
  333. package/src/dataviews/fields/content-preview/content-preview-view.tsx +2 -0
  334. package/src/hooks/index.js +1 -0
  335. package/src/hooks/media-upload.js +25 -5
  336. package/src/hooks/push-changes-to-global-styles/index.js +391 -0
  337. package/src/hooks/push-changes-to-global-styles/style.scss +4 -0
  338. package/src/hooks/use-global-styles-output.js +76 -0
  339. package/src/private-apis.js +10 -8
  340. package/src/store/actions.js +4 -1
  341. package/src/store/private-actions.js +37 -0
  342. package/src/store/private-selectors.js +20 -0
  343. package/src/store/reducer.js +36 -0
  344. package/src/style.scss +7 -0
  345. package/src/utils/set-nested-value.js +39 -0
  346. package/tsconfig.json +3 -0
  347. package/tsconfig.tsbuildinfo +1 -1
  348. package/build/components/editor-interface/content-slot-fill.js.map +0 -7
  349. package/build-module/components/editor-interface/content-slot-fill.js +0 -9
  350. package/build-module/components/editor-interface/content-slot-fill.js.map +0 -7
  351. package/build-types/components/editor-interface/content-slot-fill.d.ts +0 -14
  352. package/build-types/components/editor-interface/content-slot-fill.d.ts.map +0 -1
  353. package/src/components/editor-interface/content-slot-fill.js +0 -10
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/global-styles/index.js"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\nimport { GlobalStylesUI } from '@wordpress/global-styles-ui';\nimport { uploadMedia } from '@wordpress/media-utils';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { GlobalStylesBlockLink } from './block-link';\nimport { useGlobalStyles } from './hooks';\n\n/**\n * Hook to fetch server CSS and settings for BlockEditorProvider that are not Global Styles.\n */\nfunction useServerData() {\n\tconst {\n\t\tstyles,\n\t\t__unstableResolvedAssets,\n\t\tcolors,\n\t\tgradients,\n\t\t__experimentalDiscussionSettings,\n\t\tmediaUploadHandler,\n\t\tfontLibraryEnabled,\n\t} = useSelect( ( select ) => {\n\t\tconst { getEditorSettings } = select( editorStore );\n\t\tconst { canUser } = select( coreStore );\n\t\tconst editorSettings = getEditorSettings();\n\n\t\tconst canUserUploadMedia = canUser( 'create', {\n\t\t\tkind: 'root',\n\t\t\tname: 'media',\n\t\t} );\n\n\t\treturn {\n\t\t\tstyles: editorSettings?.styles || [],\n\t\t\t__unstableResolvedAssets:\n\t\t\t\teditorSettings?.__unstableResolvedAssets || {},\n\t\t\tcolors: editorSettings?.colors || [],\n\t\t\tgradients: editorSettings?.gradients || [],\n\t\t\t__experimentalDiscussionSettings:\n\t\t\t\teditorSettings?.__experimentalDiscussionSettings,\n\t\t\tmediaUploadHandler: canUserUploadMedia ? uploadMedia : undefined,\n\t\t\tfontLibraryEnabled: editorSettings?.fontLibraryEnabled ?? true,\n\t\t};\n\t}, [] );\n\n\t// Filter out global styles to get only server-provided styles\n\tconst serverCSS = useMemo( () => {\n\t\tif ( ! styles ) {\n\t\t\treturn [];\n\t\t}\n\t\treturn styles.filter( ( style ) => ! style.isGlobalStyles );\n\t}, [ styles ] );\n\n\t// Create server settings object\n\tconst serverSettings = useMemo( () => {\n\t\treturn {\n\t\t\t__unstableResolvedAssets,\n\t\t\tsettings: {\n\t\t\t\tcolor: {\n\t\t\t\t\tpalette: {\n\t\t\t\t\t\ttheme: colors,\n\t\t\t\t\t},\n\t\t\t\t\tgradients: {\n\t\t\t\t\t\ttheme: gradients,\n\t\t\t\t\t},\n\t\t\t\t\tduotone: {\n\t\t\t\t\t\ttheme: [],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t__experimentalDiscussionSettings,\n\t\t\tmediaUpload: mediaUploadHandler,\n\t\t};\n\t}, [\n\t\t__unstableResolvedAssets,\n\t\tcolors,\n\t\tgradients,\n\t\t__experimentalDiscussionSettings,\n\t\tmediaUploadHandler,\n\t] );\n\n\treturn { serverCSS, serverSettings, fontLibraryEnabled };\n}\n\nexport default function GlobalStylesUIWrapper( { path, onPathChange } ) {\n\tconst {\n\t\tuser: userConfig,\n\t\tbase: baseConfig,\n\t\tsetUser: setUserConfig,\n\t\tisReady,\n\t} = useGlobalStyles();\n\tconst { serverCSS, serverSettings, fontLibraryEnabled } = useServerData();\n\n\t// Show loading state while data is being fetched\n\tif ( ! isReady ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<GlobalStylesUI\n\t\t\t\tvalue={ userConfig }\n\t\t\t\tbaseValue={ baseConfig || {} }\n\t\t\t\tonChange={ setUserConfig }\n\t\t\t\tpath={ path }\n\t\t\t\tonPathChange={ onPathChange }\n\t\t\t\tfontLibraryEnabled={ fontLibraryEnabled }\n\t\t\t\tserverCSS={ serverCSS }\n\t\t\t\tserverSettings={ serverSettings }\n\t\t\t/>\n\t\t\t<GlobalStylesBlockLink\n\t\t\t\tpath={ path }\n\t\t\t\tonPathChange={ onPathChange }\n\t\t\t/>\n\t\t</>\n\t);\n}\n\nexport { useGlobalStyles, useStyle, useSetting } from './hooks';\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAyGE;AAtGF,uBAAmC;AACnC,kBAA0B;AAC1B,qBAAwB;AACxB,8BAA+B;AAC/B,yBAA4B;AAK5B,mBAAqC;AACrC,wBAAsC;AACtC,mBAAgC;AA8GhC,IAAAA,gBAAsD;AAzGtD,SAAS,gBAAgB;AACxB,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAA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I;AACvE,QAAM;AAAA,IACL,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,IACT;AAAA,EACD,QAAI,8BAAgB;AACpB,QAAM,EAAE,WAAW,gBAAgB,mBAAmB,IAAI,cAAc;AAGxE,MAAK,CAAE,SAAU;AAChB,WAAO;AAAA,EACR;AAEA,SACC,4EACC;AAAA;AAAA,MAAC;AAAA;AAAA,QACA,OAAQ;AAAA,QACR,WAAY,cAAc,CAAC;AAAA,QAC3B,UAAW;AAAA,QACX;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA;AAAA,IACD;AAAA,IACA;AAAA,MAAC;AAAA;AAAA,QACA;AAAA,QACA;AAAA;AAAA,IACD;AAAA,KACD;AAEF;",
6
+ "names": ["import_hooks", "editorStore", "coreStore"]
7
+ }
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var menu_exports = {};
20
+ __export(menu_exports, {
21
+ GlobalStylesActionMenu: () => GlobalStylesActionMenu
22
+ });
23
+ module.exports = __toCommonJS(menu_exports);
24
+ var import_jsx_runtime = require("react/jsx-runtime");
25
+ var import_components = require("@wordpress/components");
26
+ var import_data = require("@wordpress/data");
27
+ var import_i18n = require("@wordpress/i18n");
28
+ var import_preferences = require("@wordpress/preferences");
29
+ var import_icons = require("@wordpress/icons");
30
+ var import_core_data = require("@wordpress/core-data");
31
+ var import_hooks = require("./hooks");
32
+ function GlobalStylesActionMenu({
33
+ hideWelcomeGuide = false,
34
+ onChangePath
35
+ }) {
36
+ const { user, setUser } = (0, import_hooks.useGlobalStyles)();
37
+ const canReset = !!user && (Object.keys(user?.styles ?? {}).length > 0 || Object.keys(user?.settings ?? {}).length > 0);
38
+ const onReset = () => {
39
+ setUser({ styles: {}, settings: {} });
40
+ };
41
+ const { toggle } = (0, import_data.useDispatch)(import_preferences.store);
42
+ const { canEditCSS } = (0, import_data.useSelect)((select) => {
43
+ const { getEntityRecord, __experimentalGetCurrentGlobalStylesId } = select(import_core_data.store);
44
+ const globalStylesId = __experimentalGetCurrentGlobalStylesId();
45
+ const globalStyles = globalStylesId ? getEntityRecord("root", "globalStyles", globalStylesId) : void 0;
46
+ return {
47
+ canEditCSS: !!globalStyles?._links?.["wp:action-edit-css"]
48
+ };
49
+ }, []);
50
+ const loadCustomCSS = () => {
51
+ onChangePath("/css");
52
+ };
53
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
54
+ import_components.DropdownMenu,
55
+ {
56
+ icon: import_icons.moreVertical,
57
+ label: (0, import_i18n.__)("More"),
58
+ toggleProps: { size: "compact" },
59
+ children: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
60
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_components.MenuGroup, { children: [
61
+ canEditCSS && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.MenuItem, { onClick: loadCustomCSS, children: (0, import_i18n.__)("Additional CSS") }),
62
+ !hideWelcomeGuide && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
63
+ import_components.MenuItem,
64
+ {
65
+ onClick: () => {
66
+ toggle(
67
+ "core/edit-site",
68
+ "welcomeGuideStyles"
69
+ );
70
+ onClose();
71
+ },
72
+ children: (0, import_i18n.__)("Welcome Guide")
73
+ }
74
+ )
75
+ ] }),
76
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.MenuGroup, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
77
+ import_components.MenuItem,
78
+ {
79
+ onClick: () => {
80
+ onReset();
81
+ onClose();
82
+ },
83
+ disabled: !canReset,
84
+ children: (0, import_i18n.__)("Reset styles")
85
+ }
86
+ ) })
87
+ ] })
88
+ }
89
+ );
90
+ }
91
+ // Annotate the CommonJS export names for ESM import in node:
92
+ 0 && (module.exports = {
93
+ GlobalStylesActionMenu
94
+ });
95
+ //# sourceMappingURL=menu.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/global-styles/menu.js"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { DropdownMenu, MenuGroup, MenuItem } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { moreVertical } from '@wordpress/icons';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { useGlobalStyles } from './hooks';\n\n/**\n * Action menu with Reset, Welcome Guide, and Additional CSS.\n *\n * @param {Object} props Component props.\n * @param {boolean} props.hideWelcomeGuide Whether to hide the Welcome Guide option.\n * @param {Function} props.onChangePath Callback for navigation to different paths (e.g., '/css').\n * @return {JSX.Element} The Global Styles Action Menu component.\n */\nexport function GlobalStylesActionMenu( {\n\thideWelcomeGuide = false,\n\tonChangePath,\n} ) {\n\tconst { user, setUser } = useGlobalStyles();\n\n\t// Check if there are user customizations that can be reset\n\tconst canReset =\n\t\t!! user &&\n\t\t( Object.keys( user?.styles ?? {} ).length > 0 ||\n\t\t\tObject.keys( user?.settings ?? {} ).length > 0 );\n\n\t// Reset function to clear all user customizations\n\tconst onReset = () => {\n\t\tsetUser( { styles: {}, settings: {} } );\n\t};\n\tconst { toggle } = useDispatch( preferencesStore );\n\tconst { canEditCSS } = useSelect( ( select ) => {\n\t\tconst { getEntityRecord, __experimentalGetCurrentGlobalStylesId } =\n\t\t\tselect( coreStore );\n\n\t\tconst globalStylesId = __experimentalGetCurrentGlobalStylesId();\n\t\tconst globalStyles = globalStylesId\n\t\t\t? getEntityRecord( 'root', 'globalStyles', globalStylesId )\n\t\t\t: undefined;\n\n\t\treturn {\n\t\t\tcanEditCSS: !! globalStyles?._links?.[ 'wp:action-edit-css' ],\n\t\t};\n\t}, [] );\n\tconst loadCustomCSS = () => {\n\t\tonChangePath( '/css' );\n\t};\n\n\treturn (\n\t\t<DropdownMenu\n\t\t\ticon={ moreVertical }\n\t\t\tlabel={ __( 'More' ) }\n\t\t\ttoggleProps={ { size: 'compact' } }\n\t\t>\n\t\t\t{ ( { onClose } ) => (\n\t\t\t\t<>\n\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t{ canEditCSS && (\n\t\t\t\t\t\t\t<MenuItem onClick={ loadCustomCSS }>\n\t\t\t\t\t\t\t\t{ __( 'Additional CSS' ) }\n\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ ! hideWelcomeGuide && (\n\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\ttoggle(\n\t\t\t\t\t\t\t\t\t\t'core/edit-site',\n\t\t\t\t\t\t\t\t\t\t'welcomeGuideStyles'\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Welcome Guide' ) }\n\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t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EA,SACC;AAAA,IAAC;AAAA;AAAA,MACA,MAAO;AAAA,MACP,WAAQ,gBAAI,MAAO;AAAA,MACnB,aAAc,EAAE,MAAM,UAAU;AAAA,MAE9B,WAAE,EAAE,QAAQ,MACb,4EACC;AAAA,qDAAC,+BACE;AAAA,wBACD,4CAAC,8BAAS,SAAU,eACjB,8BAAI,gBAAiB,GACxB;AAAA,UAEC,CAAE,oBACH;AAAA,YAAC;AAAA;AAAA,cACA,SAAU,MAAM;AACf;AAAA,kBACC;AAAA,kBACA;AAAA,gBACD;AACA,wBAAQ;AAAA,cACT;AAAA,cAEE,8BAAI,eAAgB;AAAA;AAAA,UACvB;AAAA,WAEF;AAAA,QACA,4CAAC,+BACA;AAAA,UAAC;AAAA;AAAA,YACA,SAAU,MAAM;AACf,sBAAQ;AACR,sBAAQ;AAAA,YACT;AAAA,YACA,UAAW,CAAE;AAAA,YAEX,8BAAI,cAAe;AAAA;AAAA,QACtB,GACD;AAAA,SACD;AAAA;AAAA,EAEF;AAEF;",
6
+ "names": ["preferencesStore", "coreStore"]
7
+ }
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
6
  var __export = (target, all) => {
9
7
  for (var name in all)
@@ -17,54 +15,19 @@ var __copyProps = (to, from, except, desc) => {
17
15
  }
18
16
  return to;
19
17
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
19
  var global_styles_provider_exports = {};
30
20
  __export(global_styles_provider_exports, {
31
- GlobalStylesProvider: () => GlobalStylesProvider,
32
- mergeBaseAndUserConfigs: () => mergeBaseAndUserConfigs,
33
21
  useGlobalStylesContext: () => useGlobalStylesContext
34
22
  });
35
23
  module.exports = __toCommonJS(global_styles_provider_exports);
36
- var import_jsx_runtime = require("react/jsx-runtime");
37
- var import_deepmerge = __toESM(require("deepmerge"));
38
- var import_is_plain_object = require("is-plain-object");
39
24
  var import_block_editor = require("@wordpress/block-editor");
40
25
  var import_core_data = require("@wordpress/core-data");
41
26
  var import_data = require("@wordpress/data");
42
27
  var import_element = require("@wordpress/element");
28
+ var import_global_styles_engine = require("@wordpress/global-styles-engine");
43
29
  var import_lock_unlock = require("../../lock-unlock");
44
- const { GlobalStylesContext, cleanEmptyObject } = (0, import_lock_unlock.unlock)(
45
- import_block_editor.privateApis
46
- );
47
- function mergeBaseAndUserConfigs(base, user) {
48
- return (0, import_deepmerge.default)(base, user, {
49
- /*
50
- * We only pass as arrays the presets,
51
- * in which case we want the new array of values
52
- * to override the old array (no merging).
53
- */
54
- isMergeableObject: import_is_plain_object.isPlainObject,
55
- /*
56
- * Exceptions to the above rule.
57
- * Background images should be replaced, not merged,
58
- * as they themselves are specific object definitions for the style.
59
- */
60
- customMerge: (key) => {
61
- if (key === "backgroundImage") {
62
- return (baseConfig, userConfig) => userConfig;
63
- }
64
- return void 0;
65
- }
66
- });
67
- }
30
+ const { cleanEmptyObject } = (0, import_lock_unlock.unlock)(import_block_editor.privateApis);
68
31
  function useGlobalStylesUserConfig() {
69
32
  const { globalStylesId, isReady, settings, styles, _links } = (0, import_data.useSelect)(
70
33
  (select) => {
@@ -189,7 +152,7 @@ function useGlobalStylesContext() {
189
152
  if (!baseConfig || !userConfig) {
190
153
  return {};
191
154
  }
192
- return mergeBaseAndUserConfigs(baseConfig, userConfig);
155
+ return (0, import_global_styles_engine.mergeGlobalStyles)(baseConfig, userConfig);
193
156
  }, [userConfig, baseConfig]);
194
157
  const context = (0, import_element.useMemo)(() => {
195
158
  return {
@@ -209,17 +172,8 @@ function useGlobalStylesContext() {
209
172
  ]);
210
173
  return context;
211
174
  }
212
- function GlobalStylesProvider({ children }) {
213
- const context = useGlobalStylesContext();
214
- if (!context.isReady) {
215
- return null;
216
- }
217
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(GlobalStylesContext.Provider, { value: context, children });
218
- }
219
175
  // Annotate the CommonJS export names for ESM import in node:
220
176
  0 && (module.exports = {
221
- GlobalStylesProvider,
222
- mergeBaseAndUserConfigs,
223
177
  useGlobalStylesContext
224
178
  });
225
179
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/global-styles-provider/index.js"],
4
- "sourcesContent": ["/**\n * External dependencies\n */\nimport deepmerge from 'deepmerge';\nimport { isPlainObject } from 'is-plain-object';\n\n/**\n * WordPress dependencies\n */\nimport { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useMemo, useCallback } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\n\nconst { GlobalStylesContext, cleanEmptyObject } = unlock(\n\tblockEditorPrivateApis\n);\n\nexport function mergeBaseAndUserConfigs( base, user ) {\n\treturn deepmerge( base, user, {\n\t\t/*\n\t\t * We only pass as arrays the presets,\n\t\t * in which case we want the new array of values\n\t\t * to override the old array (no merging).\n\t\t */\n\t\tisMergeableObject: isPlainObject,\n\t\t/*\n\t\t * Exceptions to the above rule.\n\t\t * Background images should be replaced, not merged,\n\t\t * as they themselves are specific object definitions for the style.\n\t\t */\n\t\tcustomMerge: ( key ) => {\n\t\t\tif ( key === 'backgroundImage' ) {\n\t\t\t\treturn ( baseConfig, userConfig ) => userConfig;\n\t\t\t}\n\t\t\treturn undefined;\n\t\t},\n\t} );\n}\n\nfunction useGlobalStylesUserConfig() {\n\tconst { globalStylesId, isReady, settings, styles, _links } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetEntityRecord,\n\t\t\t\tgetEditedEntityRecord,\n\t\t\t\thasFinishedResolution,\n\t\t\t\tcanUser,\n\t\t\t} = select( coreStore );\n\t\t\tconst _globalStylesId =\n\t\t\t\tselect( coreStore ).__experimentalGetCurrentGlobalStylesId();\n\n\t\t\tlet record;\n\n\t\t\t/*\n\t\t\t * Ensure that the global styles ID request is complete by testing `_globalStylesId`,\n\t\t\t * before firing off the `canUser` OPTIONS request for user capabilities, otherwise it will\n\t\t\t * fetch `/wp/v2/global-styles` instead of `/wp/v2/global-styles/{id}`.\n\t\t\t * NOTE: Please keep in sync any preload paths sent to `block_editor_rest_api_preload()`,\n\t\t\t * or set using the `block_editor_rest_api_preload_paths` filter, if this changes.\n\t\t\t */\n\t\t\tconst userCanEditGlobalStyles = _globalStylesId\n\t\t\t\t? canUser( 'update', {\n\t\t\t\t\t\tkind: 'root',\n\t\t\t\t\t\tname: 'globalStyles',\n\t\t\t\t\t\tid: _globalStylesId,\n\t\t\t\t } )\n\t\t\t\t: null;\n\n\t\t\tif (\n\t\t\t\t_globalStylesId &&\n\t\t\t\t/*\n\t\t\t\t * Test that the OPTIONS request for user capabilities is complete\n\t\t\t\t * before fetching the global styles entity record.\n\t\t\t\t * This is to avoid fetching the global styles entity unnecessarily.\n\t\t\t\t */\n\t\t\t\ttypeof userCanEditGlobalStyles === 'boolean'\n\t\t\t) {\n\t\t\t\t/*\n\t\t\t\t * Fetch the global styles entity record based on the user's capabilities.\n\t\t\t\t * The default context is `edit` for users who can edit global styles.\n\t\t\t\t * Otherwise, the context is `view`.\n\t\t\t\t * NOTE: There is an equivalent conditional check using `current_user_can()` in the backend\n\t\t\t\t * to preload the global styles entity. Please keep in sync any preload paths sent to `block_editor_rest_api_preload()`,\n\t\t\t\t * or set using `block_editor_rest_api_preload_paths` filter, if this changes.\n\t\t\t\t */\n\t\t\t\tif ( userCanEditGlobalStyles ) {\n\t\t\t\t\trecord = getEditedEntityRecord(\n\t\t\t\t\t\t'root',\n\t\t\t\t\t\t'globalStyles',\n\t\t\t\t\t\t_globalStylesId\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\trecord = getEntityRecord(\n\t\t\t\t\t\t'root',\n\t\t\t\t\t\t'globalStyles',\n\t\t\t\t\t\t_globalStylesId,\n\t\t\t\t\t\t{ context: 'view' }\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlet hasResolved = false;\n\t\t\tif (\n\t\t\t\thasFinishedResolution(\n\t\t\t\t\t'__experimentalGetCurrentGlobalStylesId'\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tif ( _globalStylesId ) {\n\t\t\t\t\thasResolved = userCanEditGlobalStyles\n\t\t\t\t\t\t? hasFinishedResolution( 'getEditedEntityRecord', [\n\t\t\t\t\t\t\t\t'root',\n\t\t\t\t\t\t\t\t'globalStyles',\n\t\t\t\t\t\t\t\t_globalStylesId,\n\t\t\t\t\t\t ] )\n\t\t\t\t\t\t: hasFinishedResolution( 'getEntityRecord', [\n\t\t\t\t\t\t\t\t'root',\n\t\t\t\t\t\t\t\t'globalStyles',\n\t\t\t\t\t\t\t\t_globalStylesId,\n\t\t\t\t\t\t\t\t{ context: 'view' },\n\t\t\t\t\t\t ] );\n\t\t\t\t} else {\n\t\t\t\t\thasResolved = true;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tglobalStylesId: _globalStylesId,\n\t\t\t\tisReady: hasResolved,\n\t\t\t\tsettings: record?.settings,\n\t\t\t\tstyles: record?.styles,\n\t\t\t\t_links: record?._links,\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\tconst { getEditedEntityRecord } = useSelect( coreStore );\n\tconst { editEntityRecord } = useDispatch( coreStore );\n\tconst config = useMemo( () => {\n\t\treturn {\n\t\t\tsettings: settings ?? {},\n\t\t\tstyles: styles ?? {},\n\t\t\t_links: _links ?? {},\n\t\t};\n\t}, [ settings, styles, _links ] );\n\n\tconst setConfig = useCallback(\n\t\t/**\n\t\t * Set the global styles config.\n\t\t * @param {Function|Object} callbackOrObject If the callbackOrObject is a function, pass the current config to the callback so the consumer can merge values.\n\t\t * Otherwise, overwrite the current config with the incoming object.\n\t\t * @param {Object} options Options for editEntityRecord Core selector.\n\t\t */\n\t\t( callbackOrObject, options = {} ) => {\n\t\t\tconst record = getEditedEntityRecord(\n\t\t\t\t'root',\n\t\t\t\t'globalStyles',\n\t\t\t\tglobalStylesId\n\t\t\t);\n\n\t\t\tconst currentConfig = {\n\t\t\t\tstyles: record?.styles ?? {},\n\t\t\t\tsettings: record?.settings ?? {},\n\t\t\t\t_links: record?._links ?? {},\n\t\t\t};\n\n\t\t\tconst updatedConfig =\n\t\t\t\ttypeof callbackOrObject === 'function'\n\t\t\t\t\t? callbackOrObject( currentConfig )\n\t\t\t\t\t: callbackOrObject;\n\n\t\t\teditEntityRecord(\n\t\t\t\t'root',\n\t\t\t\t'globalStyles',\n\t\t\t\tglobalStylesId,\n\t\t\t\t{\n\t\t\t\t\tstyles: cleanEmptyObject( updatedConfig.styles ) || {},\n\t\t\t\t\tsettings: cleanEmptyObject( updatedConfig.settings ) || {},\n\t\t\t\t\t_links: cleanEmptyObject( updatedConfig._links ) || {},\n\t\t\t\t},\n\t\t\t\toptions\n\t\t\t);\n\t\t},\n\t\t[ globalStylesId, editEntityRecord, getEditedEntityRecord ]\n\t);\n\n\treturn [ isReady, config, setConfig ];\n}\n\nfunction useGlobalStylesBaseConfig() {\n\tconst baseConfig = useSelect(\n\t\t( select ) =>\n\t\t\tselect( coreStore ).__experimentalGetCurrentThemeBaseGlobalStyles(),\n\t\t[]\n\t);\n\treturn [ !! baseConfig, baseConfig ];\n}\n\nexport function useGlobalStylesContext() {\n\tconst [ isUserConfigReady, userConfig, setUserConfig ] =\n\t\tuseGlobalStylesUserConfig();\n\tconst [ isBaseConfigReady, baseConfig ] = useGlobalStylesBaseConfig();\n\n\tconst mergedConfig = useMemo( () => {\n\t\tif ( ! baseConfig || ! userConfig ) {\n\t\t\treturn {};\n\t\t}\n\n\t\treturn mergeBaseAndUserConfigs( baseConfig, userConfig );\n\t}, [ userConfig, baseConfig ] );\n\n\tconst context = useMemo( () => {\n\t\treturn {\n\t\t\tisReady: isUserConfigReady && isBaseConfigReady,\n\t\t\tuser: userConfig,\n\t\t\tbase: baseConfig,\n\t\t\tmerged: mergedConfig,\n\t\t\tsetUserConfig,\n\t\t};\n\t}, [\n\t\tmergedConfig,\n\t\tuserConfig,\n\t\tbaseConfig,\n\t\tsetUserConfig,\n\t\tisUserConfigReady,\n\t\tisBaseConfigReady,\n\t] );\n\n\treturn context;\n}\n\nexport function GlobalStylesProvider( { children } ) {\n\tconst context = useGlobalStylesContext();\n\tif ( ! context.isReady ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<GlobalStylesContext.Provider value={ context }>\n\t\t\t{ children }\n\t\t</GlobalStylesContext.Provider>\n\t);\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAoPE;AAjPF,uBAAsB;AACtB,6BAA8B;AAK9B,0BAAsD;AACtD,uBAAmC;AACnC,kBAAuC;AACvC,qBAAqC;AAKrC,yBAAuB;AAEvB,MAAM,EAAE,qBAAqB,iBAAiB,QAAI;AAAA,EACjD,oBAAAA;AACD;AAEO,SAAS,wBAAyB,MAAM,MAAO;AACrD,aAAO,iBAAAC,SAAW,MAAM,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAM7B,mBAAmB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAMnB,aAAa,CAAE,QAAS;AACvB,UAAK,QAAQ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AACxC,QAAM,CAAE,mBAAmB,YAAY,aAAc,IACpD,0BAA0B;AAC3B,QAAM,CAAE,mBAAmB,UAAW,IAAI,0BAA0B;AAEpE,QAAM,mBAAe,wBAAS,MAAM;AACnC,QAAK,CAAE,cAAc,CAAE,YAAa;AACnC,aAAO,CAAC;AAAA,IACT;AAEA,WAAO,wBAAyB,YAAY,UAAW;AAAA,EACxD,GAAG,CAAE,YAAY,UAAW,CAAE;AAE9B,QAAM,cAAU,wBAAS,MAAM;AAC9B,WAAO;AAAA,MACN,SAAS,qBAAqB;AAAA,MAC9B,MAAM;AAAA,MACN,MAAM;AAAA,MACN,QAAQ;AAAA,MACR;AAAA,IACD;AAAA,EACD,GAAG;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,CAAE;AAEF,SAAO;AACR;AAEO,SAAS,qBAAsB,EAAE,SAAS,GAAI;AACpD,QAAM,UAAU,uBAAuB;AACvC,MAAK,CAAE,QAAQ,SAAU;AACxB,WAAO;AAAA,EACR;AAEA,SACC,4CAAC,oBAAoB,UAApB,EAA6B,OAAQ,SACnC,UACH;AAEF;",
6
- "names": ["blockEditorPrivateApis", "deepmerge", "getEditedEntityRecord", "coreStore"]
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useMemo, useCallback } from '@wordpress/element';\nimport { mergeGlobalStyles } from '@wordpress/global-styles-engine';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\n\nconst { cleanEmptyObject } = unlock( blockEditorPrivateApis );\n\nfunction useGlobalStylesUserConfig() {\n\tconst { globalStylesId, isReady, settings, styles, _links } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetEntityRecord,\n\t\t\t\tgetEditedEntityRecord,\n\t\t\t\thasFinishedResolution,\n\t\t\t\tcanUser,\n\t\t\t} = select( coreStore );\n\t\t\tconst _globalStylesId =\n\t\t\t\tselect( coreStore ).__experimentalGetCurrentGlobalStylesId();\n\n\t\t\tlet record;\n\n\t\t\t/*\n\t\t\t * Ensure that the global styles ID request is complete by testing `_globalStylesId`,\n\t\t\t * before firing off the `canUser` OPTIONS request for user capabilities, otherwise it will\n\t\t\t * fetch `/wp/v2/global-styles` instead of `/wp/v2/global-styles/{id}`.\n\t\t\t * NOTE: Please keep in sync any preload paths sent to `block_editor_rest_api_preload()`,\n\t\t\t * or set using the `block_editor_rest_api_preload_paths` filter, if this changes.\n\t\t\t */\n\t\t\tconst userCanEditGlobalStyles = _globalStylesId\n\t\t\t\t? canUser( 'update', {\n\t\t\t\t\t\tkind: 'root',\n\t\t\t\t\t\tname: 'globalStyles',\n\t\t\t\t\t\tid: _globalStylesId,\n\t\t\t\t } )\n\t\t\t\t: null;\n\n\t\t\tif (\n\t\t\t\t_globalStylesId &&\n\t\t\t\t/*\n\t\t\t\t * Test that the OPTIONS request for user capabilities is complete\n\t\t\t\t * before fetching the global styles entity record.\n\t\t\t\t * This is to avoid fetching the global styles entity unnecessarily.\n\t\t\t\t */\n\t\t\t\ttypeof userCanEditGlobalStyles === 'boolean'\n\t\t\t) {\n\t\t\t\t/*\n\t\t\t\t * Fetch the global styles entity record based on the user's capabilities.\n\t\t\t\t * The default context is `edit` for users who can edit global styles.\n\t\t\t\t * Otherwise, the context is `view`.\n\t\t\t\t * NOTE: There is an equivalent conditional check using `current_user_can()` in the backend\n\t\t\t\t * to preload the global styles entity. Please keep in sync any preload paths sent to `block_editor_rest_api_preload()`,\n\t\t\t\t * or set using `block_editor_rest_api_preload_paths` filter, if this changes.\n\t\t\t\t */\n\t\t\t\tif ( userCanEditGlobalStyles ) {\n\t\t\t\t\trecord = getEditedEntityRecord(\n\t\t\t\t\t\t'root',\n\t\t\t\t\t\t'globalStyles',\n\t\t\t\t\t\t_globalStylesId\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\trecord = getEntityRecord(\n\t\t\t\t\t\t'root',\n\t\t\t\t\t\t'globalStyles',\n\t\t\t\t\t\t_globalStylesId,\n\t\t\t\t\t\t{ context: 'view' }\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlet hasResolved = false;\n\t\t\tif (\n\t\t\t\thasFinishedResolution(\n\t\t\t\t\t'__experimentalGetCurrentGlobalStylesId'\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tif ( _globalStylesId ) {\n\t\t\t\t\thasResolved = userCanEditGlobalStyles\n\t\t\t\t\t\t? hasFinishedResolution( 'getEditedEntityRecord', [\n\t\t\t\t\t\t\t\t'root',\n\t\t\t\t\t\t\t\t'globalStyles',\n\t\t\t\t\t\t\t\t_globalStylesId,\n\t\t\t\t\t\t ] )\n\t\t\t\t\t\t: hasFinishedResolution( 'getEntityRecord', [\n\t\t\t\t\t\t\t\t'root',\n\t\t\t\t\t\t\t\t'globalStyles',\n\t\t\t\t\t\t\t\t_globalStylesId,\n\t\t\t\t\t\t\t\t{ context: 'view' },\n\t\t\t\t\t\t ] );\n\t\t\t\t} else {\n\t\t\t\t\thasResolved = true;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tglobalStylesId: _globalStylesId,\n\t\t\t\tisReady: hasResolved,\n\t\t\t\tsettings: record?.settings,\n\t\t\t\tstyles: record?.styles,\n\t\t\t\t_links: record?._links,\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\tconst { getEditedEntityRecord } = useSelect( coreStore );\n\tconst { editEntityRecord } = useDispatch( coreStore );\n\tconst config = useMemo( () => {\n\t\treturn {\n\t\t\tsettings: settings ?? {},\n\t\t\tstyles: styles ?? {},\n\t\t\t_links: _links ?? {},\n\t\t};\n\t}, [ settings, styles, _links ] );\n\n\tconst setConfig = useCallback(\n\t\t/**\n\t\t * Set the global styles config.\n\t\t * @param {Function|Object} callbackOrObject If the callbackOrObject is a function, pass the current config to the callback so the consumer can merge values.\n\t\t * Otherwise, overwrite the current config with the incoming object.\n\t\t * @param {Object} options Options for editEntityRecord Core selector.\n\t\t */\n\t\t( callbackOrObject, options = {} ) => {\n\t\t\tconst record = getEditedEntityRecord(\n\t\t\t\t'root',\n\t\t\t\t'globalStyles',\n\t\t\t\tglobalStylesId\n\t\t\t);\n\n\t\t\tconst currentConfig = {\n\t\t\t\tstyles: record?.styles ?? {},\n\t\t\t\tsettings: record?.settings ?? {},\n\t\t\t\t_links: record?._links ?? {},\n\t\t\t};\n\n\t\t\tconst updatedConfig =\n\t\t\t\ttypeof callbackOrObject === 'function'\n\t\t\t\t\t? callbackOrObject( currentConfig )\n\t\t\t\t\t: callbackOrObject;\n\n\t\t\teditEntityRecord(\n\t\t\t\t'root',\n\t\t\t\t'globalStyles',\n\t\t\t\tglobalStylesId,\n\t\t\t\t{\n\t\t\t\t\tstyles: cleanEmptyObject( updatedConfig.styles ) || {},\n\t\t\t\t\tsettings: cleanEmptyObject( updatedConfig.settings ) || {},\n\t\t\t\t\t_links: cleanEmptyObject( updatedConfig._links ) || {},\n\t\t\t\t},\n\t\t\t\toptions\n\t\t\t);\n\t\t},\n\t\t[ globalStylesId, editEntityRecord, getEditedEntityRecord ]\n\t);\n\n\treturn [ isReady, config, setConfig ];\n}\n\nfunction useGlobalStylesBaseConfig() {\n\tconst baseConfig = useSelect(\n\t\t( select ) =>\n\t\t\tselect( coreStore ).__experimentalGetCurrentThemeBaseGlobalStyles(),\n\t\t[]\n\t);\n\treturn [ !! baseConfig, baseConfig ];\n}\n\nexport function useGlobalStylesContext() {\n\tconst [ isUserConfigReady, userConfig, setUserConfig ] =\n\t\tuseGlobalStylesUserConfig();\n\tconst [ isBaseConfigReady, baseConfig ] = useGlobalStylesBaseConfig();\n\n\tconst mergedConfig = useMemo( () => {\n\t\tif ( ! baseConfig || ! userConfig ) {\n\t\t\treturn {};\n\t\t}\n\n\t\treturn mergeGlobalStyles( baseConfig, userConfig );\n\t}, [ userConfig, baseConfig ] );\n\n\tconst context = useMemo( () => {\n\t\treturn {\n\t\t\tisReady: isUserConfigReady && isBaseConfigReady,\n\t\t\tuser: userConfig,\n\t\t\tbase: baseConfig,\n\t\t\tmerged: mergedConfig,\n\t\t\tsetUserConfig,\n\t\t};\n\t}, [\n\t\tmergedConfig,\n\t\tuserConfig,\n\t\tbaseConfig,\n\t\tsetUserConfig,\n\t\tisUserConfigReady,\n\t\tisBaseConfigReady,\n\t] );\n\n\treturn context;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,0BAAsD;AACtD,uBAAmC;AACnC,kBAAuC;AACvC,qBAAqC;AACrC,kCAAkC;AAKlC,yBAAuB;AAEvB,MAAM,EAAE,iBAAiB,QAAI,2BAAQ,oBAAAA,WAAuB;AAE5D,SAAS,4BAA4B;AACpC,QAAM,EAAE,gBAAgB,SAAS,UAAU,QAAQ,OAAO,QAAI;AAAA,IAC7D,CAAE,WAAY;AACb,YAAM;AAAA,QACL;AAAA,QACA,uBAAAC;AAAA,QACA;AAAA,QACA;AAAA,MACD,IAAI,OAAQ,iBAAAC,KAAU;AACtB,YAAM,kBACL,OAAQ,iBAAAA,KAAU,EAAE,uCAAuC;AAE5D,UAAI;AASJ,YAAM,0BAA0B,kBAC7B,QAAS,UAAU;AAAA,QACnB,MAAM;AAAA,QACN,MAAM;AAAA,QACN,IAAI;AAAA,MACJ,CAAE,IACF;AAEH,UACC;AAAA;AAAA;AAAA;AAAA;AAAA,MAMA,OAAO,4BAA4B,WAClC;AASD,YAAK,yBAA0B;AAC9B,mBAASD;AAAA,YACR;AAAA,YACA;AAAA,YACA;AAAA,UACD;AAAA,QACD,OAAO;AACN,mBAAS;AAAA,YACR;AAAA,YACA;AAAA,YACA;AAAA,YACA,EAAE,SAAS,OAAO;AAAA,UACnB;AAAA,QACD;AAAA,MACD;AAEA,UAAI,cAAc;AAClB,UACC;AAAA,QACC;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AAA,UACrD,UAAU,iBAAkB,cAAc,QAAS,KAAK,CAAC;AAAA,UACzD,QAAQ,iBAAkB,cAAc,MAAO,KAAK,CAAC;AAAA,QACtD;AAAA,QACA;AAAA,MACD;AAAA,IACD;AAAA,IACA,CAAE,gBAAgB,kBAAkB,qBAAsB;AAAA,EAC3D;AAEA,SAAO,CAAE,SAAS,QAAQ,SAAU;AACrC;AAEA,SAAS,4BAA4B;AACpC,QAAM,iBAAa;AAAA,IAClB,CAAE,WACD,OAAQ,iBAAAA,KAAU,EAAE,8CAA8C;AAAA,IACnE,CAAC;AAAA,EACF;AACA,SAAO,CAAE,CAAC,CAAE,YAAY,UAAW;AACpC;AAEO,SAAS,yBAAyB;AACxC,QAAM,CAAE,mBAAmB,YAAY,aAAc,IACpD,0BAA0B;AAC3B,QAAM,CAAE,mBAAmB,UAAW,IAAI,0BAA0B;AAEpE,QAAM,mBAAe,wBAAS,MAAM;AACnC,QAAK,CAAE,cAAc,CAAE,YAAa;AACnC,aAAO,CAAC;AAAA,IACT;AAEA,eAAO,+CAAmB,YAAY,UAAW;AAAA,EAClD,GAAG,CAAE,YAAY,UAAW,CAAE;AAE9B,QAAM,cAAU,wBAAS,MAAM;AAC9B,WAAO;AAAA,MACN,SAAS,qBAAqB;AAAA,MAC9B,MAAM;AAAA,MACN,MAAM;AAAA,MACN,QAAQ;AAAA,MACR;AAAA,IACD;AAAA,EACD,GAAG;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,CAAE;AAEF,SAAO;AACR;",
6
+ "names": ["blockEditorPrivateApis", "getEditedEntityRecord", "coreStore"]
7
7
  }
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var global_styles_renderer_exports = {};
20
+ __export(global_styles_renderer_exports, {
21
+ GlobalStylesRenderer: () => GlobalStylesRenderer
22
+ });
23
+ module.exports = __toCommonJS(global_styles_renderer_exports);
24
+ var import_element = require("@wordpress/element");
25
+ var import_data = require("@wordpress/data");
26
+ var import_store = require("../../store");
27
+ var import_use_global_styles_output = require("../../hooks/use-global-styles-output");
28
+ function useGlobalStylesRenderer(disableRootPadding) {
29
+ const [styles, settings] = (0, import_use_global_styles_output.useGlobalStylesOutput)(disableRootPadding);
30
+ const { getEditorSettings } = (0, import_data.useSelect)(import_store.store);
31
+ const { updateEditorSettings } = (0, import_data.useDispatch)(import_store.store);
32
+ (0, import_element.useEffect)(() => {
33
+ if (!styles || !settings) {
34
+ return;
35
+ }
36
+ const currentStoreSettings = getEditorSettings();
37
+ const nonGlobalStyles = Object.values(
38
+ currentStoreSettings.styles ?? []
39
+ ).filter((style) => !style.isGlobalStyles);
40
+ updateEditorSettings({
41
+ ...currentStoreSettings,
42
+ styles: [...nonGlobalStyles, ...styles],
43
+ __experimentalFeatures: settings
44
+ });
45
+ }, [styles, settings, updateEditorSettings, getEditorSettings]);
46
+ }
47
+ function GlobalStylesRenderer({ disableRootPadding }) {
48
+ useGlobalStylesRenderer(disableRootPadding);
49
+ return null;
50
+ }
51
+ // Annotate the CommonJS export names for ESM import in node:
52
+ 0 && (module.exports = {
53
+ GlobalStylesRenderer
54
+ });
55
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/global-styles-renderer/index.js"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useEffect } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { useGlobalStylesOutput } from '../../hooks/use-global-styles-output';\n\nfunction useGlobalStylesRenderer( disableRootPadding ) {\n\tconst [ styles, settings ] = useGlobalStylesOutput( disableRootPadding );\n\tconst { getEditorSettings } = useSelect( editorStore );\n\tconst { updateEditorSettings } = useDispatch( editorStore );\n\n\tuseEffect( () => {\n\t\tif ( ! styles || ! settings ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst currentStoreSettings = getEditorSettings();\n\t\tconst nonGlobalStyles = Object.values(\n\t\t\tcurrentStoreSettings.styles ?? []\n\t\t).filter( ( style ) => ! style.isGlobalStyles );\n\t\tupdateEditorSettings( {\n\t\t\t...currentStoreSettings,\n\t\t\tstyles: [ ...nonGlobalStyles, ...styles ],\n\t\t\t__experimentalFeatures: settings,\n\t\t} );\n\t}, [ styles, settings, updateEditorSettings, getEditorSettings ] );\n}\n\nexport function GlobalStylesRenderer( { disableRootPadding } ) {\n\tuseGlobalStylesRenderer( disableRootPadding );\n\n\treturn null;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAA0B;AAC1B,kBAAuC;AAKvC,mBAAqC;AACrC,sCAAsC;AAEtC,SAAS,wBAAyB,oBAAqB;AACtD,QAAM,CAAE,QAAQ,QAAS,QAAI,uDAAuB,kBAAmB;AACvE,QAAM,EAAE,kBAAkB,QAAI,uBAAW,aAAAA,KAAY;AACrD,QAAM,EAAE,qBAAqB,QAAI,yBAAa,aAAAA,KAAY;AAE1D,gCAAW,MAAM;AAChB,QAAK,CAAE,UAAU,CAAE,UAAW;AAC7B;AAAA,IACD;AAEA,UAAM,uBAAuB,kBAAkB;AAC/C,UAAM,kBAAkB,OAAO;AAAA,MAC9B,qBAAqB,UAAU,CAAC;AAAA,IACjC,EAAE,OAAQ,CAAE,UAAW,CAAE,MAAM,cAAe;AAC9C,yBAAsB;AAAA,MACrB,GAAG;AAAA,MACH,QAAQ,CAAE,GAAG,iBAAiB,GAAG,MAAO;AAAA,MACxC,wBAAwB;AAAA,IACzB,CAAE;AAAA,EACH,GAAG,CAAE,QAAQ,UAAU,sBAAsB,iBAAkB,CAAE;AAClE;AAEO,SAAS,qBAAsB,EAAE,mBAAmB,GAAI;AAC9D,0BAAyB,kBAAmB;AAE5C,SAAO;AACR;",
6
+ "names": ["editorStore"]
7
+ }
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var default_sidebar_exports = {};
20
+ __export(default_sidebar_exports, {
21
+ default: () => DefaultSidebar
22
+ });
23
+ module.exports = __toCommonJS(default_sidebar_exports);
24
+ var import_jsx_runtime = require("react/jsx-runtime");
25
+ var import_interface = require("@wordpress/interface");
26
+ function DefaultSidebar({
27
+ className,
28
+ identifier,
29
+ title,
30
+ icon,
31
+ children,
32
+ closeLabel,
33
+ header,
34
+ headerClassName,
35
+ panelClassName,
36
+ isActiveByDefault
37
+ }) {
38
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
39
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
40
+ import_interface.ComplementaryArea,
41
+ {
42
+ className,
43
+ scope: "core",
44
+ identifier,
45
+ title,
46
+ icon,
47
+ closeLabel,
48
+ header,
49
+ headerClassName,
50
+ panelClassName,
51
+ isActiveByDefault,
52
+ children
53
+ }
54
+ ),
55
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
56
+ import_interface.ComplementaryAreaMoreMenuItem,
57
+ {
58
+ scope: "core",
59
+ identifier,
60
+ icon,
61
+ children: title
62
+ }
63
+ )
64
+ ] });
65
+ }
66
+ //# sourceMappingURL=default-sidebar.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/global-styles-sidebar/default-sidebar.js"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tComplementaryArea,\n\tComplementaryAreaMoreMenuItem,\n} from '@wordpress/interface';\n\nexport default function DefaultSidebar( {\n\tclassName,\n\tidentifier,\n\ttitle,\n\ticon,\n\tchildren,\n\tcloseLabel,\n\theader,\n\theaderClassName,\n\tpanelClassName,\n\tisActiveByDefault,\n} ) {\n\treturn (\n\t\t<>\n\t\t\t<ComplementaryArea\n\t\t\t\tclassName={ className }\n\t\t\t\tscope=\"core\"\n\t\t\t\tidentifier={ identifier }\n\t\t\t\ttitle={ title }\n\t\t\t\ticon={ icon }\n\t\t\t\tcloseLabel={ closeLabel }\n\t\t\t\theader={ header }\n\t\t\t\theaderClassName={ headerClassName }\n\t\t\t\tpanelClassName={ panelClassName }\n\t\t\t\tisActiveByDefault={ isActiveByDefault }\n\t\t\t>\n\t\t\t\t{ children }\n\t\t\t</ComplementaryArea>\n\t\t\t<ComplementaryAreaMoreMenuItem\n\t\t\t\tscope=\"core\"\n\t\t\t\tidentifier={ identifier }\n\t\t\t\ticon={ icon }\n\t\t\t>\n\t\t\t\t{ title }\n\t\t\t</ComplementaryAreaMoreMenuItem>\n\t\t</>\n\t);\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAqBE;AAlBF,uBAGO;AAEQ,SAAR,eAAiC;AAAA,EACvC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAI;AACH,SACC,4EACC;AAAA;AAAA,MAAC;AAAA;AAAA,QACA;AAAA,QACA,OAAM;AAAA,QACN;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QAEE;AAAA;AAAA,IACH;AAAA,IACA;AAAA,MAAC;AAAA;AAAA,QACA,OAAM;AAAA,QACN;AAAA,QACA;AAAA,QAEE;AAAA;AAAA,IACH;AAAA,KACD;AAEF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,182 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var global_styles_sidebar_exports = {};
30
+ __export(global_styles_sidebar_exports, {
31
+ default: () => GlobalStylesSidebar
32
+ });
33
+ module.exports = __toCommonJS(global_styles_sidebar_exports);
34
+ var import_jsx_runtime = require("react/jsx-runtime");
35
+ var import_components = require("@wordpress/components");
36
+ var import_i18n = require("@wordpress/i18n");
37
+ var import_icons = require("@wordpress/icons");
38
+ var import_data = require("@wordpress/data");
39
+ var import_element = require("@wordpress/element");
40
+ var import_preferences = require("@wordpress/preferences");
41
+ var import_compose = require("@wordpress/compose");
42
+ var import_core_data = require("@wordpress/core-data");
43
+ var import_interface = require("@wordpress/interface");
44
+ var import_global_styles = __toESM(require("../global-styles"));
45
+ var import_menu = require("../global-styles/menu");
46
+ var import_store = require("../../store");
47
+ var import_lock_unlock = require("../../lock-unlock");
48
+ var import_default_sidebar = __toESM(require("./default-sidebar"));
49
+ var import_welcome_guide = __toESM(require("./welcome-guide"));
50
+ function GlobalStylesSidebar() {
51
+ const {
52
+ shouldResetNavigation,
53
+ stylesPath,
54
+ showStylebook,
55
+ showListViewByDefault,
56
+ hasRevisions,
57
+ activeComplementaryArea
58
+ } = (0, import_data.useSelect)((select) => {
59
+ const { getActiveComplementaryArea } = select(import_interface.store);
60
+ const { getStylesPath, getShowStylebook } = (0, import_lock_unlock.unlock)(
61
+ select(import_store.store)
62
+ );
63
+ const _isVisualEditorMode = "visual" === select(import_store.store).getEditorMode();
64
+ const _showListViewByDefault = select(import_preferences.store).get(
65
+ "core",
66
+ "showListViewByDefault"
67
+ );
68
+ const { getEntityRecord, __experimentalGetCurrentGlobalStylesId } = select(import_core_data.store);
69
+ const globalStylesId = __experimentalGetCurrentGlobalStylesId();
70
+ const globalStyles = globalStylesId ? getEntityRecord("root", "globalStyles", globalStylesId) : void 0;
71
+ return {
72
+ stylesPath: getStylesPath(),
73
+ showStylebook: getShowStylebook(),
74
+ shouldResetNavigation: "edit-site/global-styles" !== getActiveComplementaryArea("core") || !_isVisualEditorMode,
75
+ showListViewByDefault: _showListViewByDefault,
76
+ hasRevisions: !!globalStyles?._links?.["version-history"]?.[0]?.count,
77
+ activeComplementaryArea: select(import_interface.store).getActiveComplementaryArea("core")
78
+ };
79
+ }, []);
80
+ const { setStylesPath, setShowStylebook, resetStylesNavigation } = (0, import_lock_unlock.unlock)(
81
+ (0, import_data.useDispatch)(import_store.store)
82
+ );
83
+ const isMobileViewport = (0, import_compose.useViewportMatch)("medium", "<");
84
+ const isRevisionsOpened = stylesPath.startsWith("/revisions") && !showStylebook;
85
+ const isRevisionsStyleBookOpened = stylesPath.startsWith("/revisions") && showStylebook;
86
+ const previousActiveArea = (0, import_compose.usePrevious)(activeComplementaryArea);
87
+ (0, import_element.useEffect)(() => {
88
+ if (activeComplementaryArea === "edit-site/global-styles" && previousActiveArea !== "edit-site/global-styles") {
89
+ resetStylesNavigation();
90
+ }
91
+ }, [activeComplementaryArea, previousActiveArea, resetStylesNavigation]);
92
+ (0, import_element.useEffect)(() => {
93
+ if (shouldResetNavigation) {
94
+ resetStylesNavigation();
95
+ }
96
+ }, [shouldResetNavigation, resetStylesNavigation]);
97
+ const { setIsListViewOpened } = (0, import_data.useDispatch)(import_store.store);
98
+ const toggleRevisions = () => {
99
+ setIsListViewOpened(false);
100
+ if (isRevisionsOpened || isRevisionsStyleBookOpened) {
101
+ setStylesPath("/");
102
+ } else {
103
+ setStylesPath("/revisions");
104
+ }
105
+ };
106
+ const toggleStyleBook = () => {
107
+ setIsListViewOpened(showStylebook && showListViewByDefault);
108
+ setShowStylebook(!showStylebook);
109
+ };
110
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
111
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
112
+ import_default_sidebar.default,
113
+ {
114
+ className: "editor-global-styles-sidebar",
115
+ identifier: "edit-site/global-styles",
116
+ title: (0, import_i18n.__)("Styles"),
117
+ icon: import_icons.styles,
118
+ closeLabel: (0, import_i18n.__)("Close Styles"),
119
+ panelClassName: "editor-global-styles-sidebar__panel",
120
+ header: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
121
+ import_components.Flex,
122
+ {
123
+ className: "editor-global-styles-sidebar__header",
124
+ gap: 1,
125
+ children: [
126
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.FlexItem, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { className: "editor-global-styles-sidebar__header-title", children: (0, import_i18n.__)("Styles") }) }),
127
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
128
+ import_components.Flex,
129
+ {
130
+ justify: "flex-end",
131
+ gap: 1,
132
+ className: "editor-global-styles-sidebar__header-actions",
133
+ children: [
134
+ !isMobileViewport && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.FlexItem, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
135
+ import_components.Button,
136
+ {
137
+ icon: import_icons.seen,
138
+ label: (0, import_i18n.__)("Style Book"),
139
+ isPressed: showStylebook,
140
+ accessibleWhenDisabled: true,
141
+ disabled: shouldResetNavigation,
142
+ onClick: toggleStyleBook,
143
+ size: "compact"
144
+ }
145
+ ) }),
146
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.FlexItem, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
147
+ import_components.Button,
148
+ {
149
+ label: (0, import_i18n.__)("Revisions"),
150
+ icon: import_icons.backup,
151
+ onClick: toggleRevisions,
152
+ accessibleWhenDisabled: true,
153
+ disabled: !hasRevisions,
154
+ isPressed: isRevisionsOpened || isRevisionsStyleBookOpened,
155
+ size: "compact"
156
+ }
157
+ ) }),
158
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
159
+ import_menu.GlobalStylesActionMenu,
160
+ {
161
+ onChangePath: setStylesPath
162
+ }
163
+ )
164
+ ]
165
+ }
166
+ )
167
+ ]
168
+ }
169
+ ),
170
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
171
+ import_global_styles.default,
172
+ {
173
+ path: stylesPath,
174
+ onPathChange: setStylesPath
175
+ }
176
+ )
177
+ }
178
+ ),
179
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_welcome_guide.default, {})
180
+ ] });
181
+ }
182
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/global-styles-sidebar/index.js"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { FlexItem, Flex, Button } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { styles, seen, backup } from '@wordpress/icons';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useEffect } from '@wordpress/element';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { useViewportMatch, usePrevious } from '@wordpress/compose';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as interfaceStore } from '@wordpress/interface';\n\n/**\n * Internal dependencies\n */\nimport GlobalStylesUI from '../global-styles';\nimport { GlobalStylesActionMenu } from '../global-styles/menu';\nimport { store as editorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\nimport DefaultSidebar from './default-sidebar';\nimport WelcomeGuideStyles from './welcome-guide';\n\nexport default function GlobalStylesSidebar() {\n\tconst {\n\t\tshouldResetNavigation,\n\t\tstylesPath,\n\t\tshowStylebook,\n\t\tshowListViewByDefault,\n\t\thasRevisions,\n\t\tactiveComplementaryArea,\n\t} = useSelect( ( select ) => {\n\t\tconst { getActiveComplementaryArea } = select( interfaceStore );\n\t\tconst { getStylesPath, getShowStylebook } = unlock(\n\t\t\tselect( editorStore )\n\t\t);\n\t\tconst _isVisualEditorMode =\n\t\t\t'visual' === select( editorStore ).getEditorMode();\n\t\tconst _showListViewByDefault = select( preferencesStore ).get(\n\t\t\t'core',\n\t\t\t'showListViewByDefault'\n\t\t);\n\t\tconst { getEntityRecord, __experimentalGetCurrentGlobalStylesId } =\n\t\t\tselect( coreStore );\n\n\t\tconst globalStylesId = __experimentalGetCurrentGlobalStylesId();\n\t\tconst globalStyles = globalStylesId\n\t\t\t? getEntityRecord( 'root', 'globalStyles', globalStylesId )\n\t\t\t: undefined;\n\n\t\treturn {\n\t\t\tstylesPath: getStylesPath(),\n\t\t\tshowStylebook: getShowStylebook(),\n\t\t\tshouldResetNavigation:\n\t\t\t\t'edit-site/global-styles' !==\n\t\t\t\t\tgetActiveComplementaryArea( 'core' ) ||\n\t\t\t\t! _isVisualEditorMode,\n\t\t\tshowListViewByDefault: _showListViewByDefault,\n\t\t\thasRevisions:\n\t\t\t\t!! globalStyles?._links?.[ 'version-history' ]?.[ 0 ]?.count,\n\t\t\tactiveComplementaryArea:\n\t\t\t\tselect( interfaceStore ).getActiveComplementaryArea( 'core' ),\n\t\t};\n\t}, [] );\n\tconst { setStylesPath, setShowStylebook, resetStylesNavigation } = unlock(\n\t\tuseDispatch( editorStore )\n\t);\n\tconst isMobileViewport = useViewportMatch( 'medium', '<' );\n\n\t// Derive state from path and showStylebook\n\tconst isRevisionsOpened =\n\t\tstylesPath.startsWith( '/revisions' ) && ! showStylebook;\n\tconst isRevisionsStyleBookOpened =\n\t\tstylesPath.startsWith( '/revisions' ) && showStylebook;\n\n\tconst previousActiveArea = usePrevious( activeComplementaryArea );\n\n\t// Reset navigation when sidebar opens\n\tuseEffect( () => {\n\t\tif (\n\t\t\tactiveComplementaryArea === 'edit-site/global-styles' &&\n\t\t\tpreviousActiveArea !== 'edit-site/global-styles'\n\t\t) {\n\t\t\tresetStylesNavigation();\n\t\t}\n\t}, [ activeComplementaryArea, previousActiveArea, resetStylesNavigation ] );\n\n\tuseEffect( () => {\n\t\tif ( shouldResetNavigation ) {\n\t\t\tresetStylesNavigation();\n\t\t}\n\t}, [ shouldResetNavigation, resetStylesNavigation ] );\n\n\tconst { setIsListViewOpened } = useDispatch( editorStore );\n\n\tconst toggleRevisions = () => {\n\t\tsetIsListViewOpened( false );\n\t\tif ( isRevisionsOpened || isRevisionsStyleBookOpened ) {\n\t\t\t// Close revisions, go back to root\n\t\t\tsetStylesPath( '/' );\n\t\t} else {\n\t\t\t// Open revisions\n\t\t\tsetStylesPath( '/revisions' );\n\t\t}\n\t};\n\tconst toggleStyleBook = () => {\n\t\tsetIsListViewOpened( showStylebook && showListViewByDefault );\n\t\tsetShowStylebook( ! showStylebook );\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<DefaultSidebar\n\t\t\t\tclassName=\"editor-global-styles-sidebar\"\n\t\t\t\tidentifier=\"edit-site/global-styles\"\n\t\t\t\ttitle={ __( 'Styles' ) }\n\t\t\t\ticon={ styles }\n\t\t\t\tcloseLabel={ __( 'Close Styles' ) }\n\t\t\t\tpanelClassName=\"editor-global-styles-sidebar__panel\"\n\t\t\t\theader={\n\t\t\t\t\t<Flex\n\t\t\t\t\t\tclassName=\"editor-global-styles-sidebar__header\"\n\t\t\t\t\t\tgap={ 1 }\n\t\t\t\t\t>\n\t\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t\t<h2 className=\"editor-global-styles-sidebar__header-title\">\n\t\t\t\t\t\t\t\t{ __( 'Styles' ) }\n\t\t\t\t\t\t\t</h2>\n\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t\t<Flex\n\t\t\t\t\t\t\tjustify=\"flex-end\"\n\t\t\t\t\t\t\tgap={ 1 }\n\t\t\t\t\t\t\tclassName=\"editor-global-styles-sidebar__header-actions\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ ! isMobileViewport && (\n\t\t\t\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\ticon={ seen }\n\t\t\t\t\t\t\t\t\t\tlabel={ __( 'Style Book' ) }\n\t\t\t\t\t\t\t\t\t\tisPressed={ showStylebook }\n\t\t\t\t\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t\t\t\t\t\tdisabled={ shouldResetNavigation }\n\t\t\t\t\t\t\t\t\t\tonClick={ toggleStyleBook }\n\t\t\t\t\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Revisions' ) }\n\t\t\t\t\t\t\t\t\ticon={ backup }\n\t\t\t\t\t\t\t\t\tonClick={ toggleRevisions }\n\t\t\t\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t\t\t\t\tdisabled={ ! hasRevisions }\n\t\t\t\t\t\t\t\t\tisPressed={\n\t\t\t\t\t\t\t\t\t\tisRevisionsOpened ||\n\t\t\t\t\t\t\t\t\t\tisRevisionsStyleBookOpened\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t\t\t<GlobalStylesActionMenu\n\t\t\t\t\t\t\t\tonChangePath={ setStylesPath }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</Flex>\n\t\t\t\t\t</Flex>\n\t\t\t\t}\n\t\t\t>\n\t\t\t\t<GlobalStylesUI\n\t\t\t\t\tpath={ stylesPath }\n\t\t\t\t\tonPathChange={ setStylesPath }\n\t\t\t\t/>\n\t\t\t</DefaultSidebar>\n\t\t\t<WelcomeGuideStyles />\n\t\t</>\n\t);\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AA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AQ,gBAAI,YAAa;AAAA,wBACzB,WAAY;AAAA,wBACZ,wBAAsB;AAAA,wBACtB,UAAW;AAAA,wBACX,SAAU;AAAA,wBACV,MAAK;AAAA;AAAA,oBACN,GACD;AAAA,oBAED,4CAAC,8BACA;AAAA,sBAAC;AAAA;AAAA,wBACA,WAAQ,gBAAI,WAAY;AAAA,wBACxB,MAAO;AAAA,wBACP,SAAU;AAAA,wBACV,wBAAsB;AAAA,wBACtB,UAAW,CAAE;AAAA,wBACb,WACC,qBACA;AAAA,wBAED,MAAK;AAAA;AAAA,oBACN,GACD;AAAA,oBACA;AAAA,sBAAC;AAAA;AAAA,wBACA,cAAe;AAAA;AAAA,oBAChB;AAAA;AAAA;AAAA,cACD;AAAA;AAAA;AAAA,QACD;AAAA,QAGD;AAAA,UAAC,qBAAAC;AAAA,UAAA;AAAA,YACA,MAAO;AAAA,YACP,cAAe;AAAA;AAAA,QAChB;AAAA;AAAA,IACD;AAAA,IACA,4CAAC,qBAAAC,SAAA,EAAmB;AAAA,KACrB;AAEF;",
6
+ "names": ["interfaceStore", "editorStore", "preferencesStore", "coreStore", "DefaultSidebar", "GlobalStylesUI", "WelcomeGuideStyles"]
7
+ }