@wordpress/edit-site 5.2.0 → 5.3.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 (374) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/build/components/add-new-template/add-custom-generic-template-modal.js +8 -10
  3. package/build/components/add-new-template/add-custom-generic-template-modal.js.map +1 -1
  4. package/build/components/add-new-template/add-custom-template-modal.js +0 -1
  5. package/build/components/add-new-template/add-custom-template-modal.js.map +1 -1
  6. package/build/components/add-new-template/new-template-part.js +5 -29
  7. package/build/components/add-new-template/new-template-part.js.map +1 -1
  8. package/build/components/add-new-template/utils.js +1 -9
  9. package/build/components/add-new-template/utils.js.map +1 -1
  10. package/build/components/app/index.js +2 -7
  11. package/build/components/app/index.js.map +1 -1
  12. package/build/components/block-editor/index.js +13 -11
  13. package/build/components/block-editor/index.js.map +1 -1
  14. package/build/components/block-editor/inserter-media-categories.js +237 -0
  15. package/build/components/block-editor/inserter-media-categories.js.map +1 -0
  16. package/build/components/canvas-spinner/index.js +20 -0
  17. package/build/components/canvas-spinner/index.js.map +1 -0
  18. package/build/components/create-template-part-modal/index.js +4 -2
  19. package/build/components/create-template-part-modal/index.js.map +1 -1
  20. package/build/components/editor/index.js +4 -2
  21. package/build/components/editor/index.js.map +1 -1
  22. package/build/components/error-boundary/index.js +2 -12
  23. package/build/components/error-boundary/index.js.map +1 -1
  24. package/build/components/error-boundary/warning.js +5 -28
  25. package/build/components/error-boundary/warning.js.map +1 -1
  26. package/build/components/global-styles/block-preview-panel.js +2 -2
  27. package/build/components/global-styles/block-preview-panel.js.map +1 -1
  28. package/build/components/global-styles/border-panel.js +17 -9
  29. package/build/components/global-styles/border-panel.js.map +1 -1
  30. package/build/components/global-styles/color-palette-panel.js +13 -7
  31. package/build/components/global-styles/color-palette-panel.js.map +1 -1
  32. package/build/components/global-styles/context-menu.js +39 -4
  33. package/build/components/global-styles/context-menu.js.map +1 -1
  34. package/build/components/global-styles/custom-css.js +65 -14
  35. package/build/components/global-styles/custom-css.js.map +1 -1
  36. package/build/components/global-styles/dimensions-panel.js +49 -31
  37. package/build/components/global-styles/dimensions-panel.js.map +1 -1
  38. package/build/components/global-styles/global-styles-provider.js +13 -3
  39. package/build/components/global-styles/global-styles-provider.js.map +1 -1
  40. package/build/components/global-styles/gradients-palette-panel.js +17 -11
  41. package/build/components/global-styles/gradients-palette-panel.js.map +1 -1
  42. package/build/components/global-styles/hooks.js +21 -142
  43. package/build/components/global-styles/hooks.js.map +1 -1
  44. package/build/components/global-styles/index.js +0 -28
  45. package/build/components/global-styles/index.js.map +1 -1
  46. package/build/components/global-styles/palette.js +11 -4
  47. package/build/components/global-styles/palette.js.map +1 -1
  48. package/build/components/global-styles/preview.js +18 -15
  49. package/build/components/global-styles/preview.js.map +1 -1
  50. package/build/components/global-styles/screen-background-color.js +27 -13
  51. package/build/components/global-styles/screen-background-color.js.map +1 -1
  52. package/build/components/global-styles/screen-border.js +10 -4
  53. package/build/components/global-styles/screen-border.js.map +1 -1
  54. package/build/components/global-styles/screen-button-color.js +16 -9
  55. package/build/components/global-styles/screen-button-color.js.map +1 -1
  56. package/build/components/global-styles/screen-colors.js +43 -34
  57. package/build/components/global-styles/screen-colors.js.map +1 -1
  58. package/build/components/global-styles/screen-css.js +20 -8
  59. package/build/components/global-styles/screen-css.js.map +1 -1
  60. package/build/components/global-styles/screen-heading-color.js +23 -16
  61. package/build/components/global-styles/screen-heading-color.js.map +1 -1
  62. package/build/components/global-styles/screen-layout.js +3 -3
  63. package/build/components/global-styles/screen-layout.js.map +1 -1
  64. package/build/components/global-styles/screen-link-color.js +18 -11
  65. package/build/components/global-styles/screen-link-color.js.map +1 -1
  66. package/build/components/global-styles/screen-root.js +25 -9
  67. package/build/components/global-styles/screen-root.js.map +1 -1
  68. package/build/components/global-styles/screen-style-variations.js +8 -4
  69. package/build/components/global-styles/screen-style-variations.js.map +1 -1
  70. package/build/components/global-styles/screen-text-color.js +14 -7
  71. package/build/components/global-styles/screen-text-color.js.map +1 -1
  72. package/build/components/global-styles/screen-typography.js +18 -12
  73. package/build/components/global-styles/screen-typography.js.map +1 -1
  74. package/build/components/global-styles/shadow-panel.js +196 -0
  75. package/build/components/global-styles/shadow-panel.js.map +1 -0
  76. package/build/components/global-styles/typography-panel.js +43 -29
  77. package/build/components/global-styles/typography-panel.js.map +1 -1
  78. package/build/components/global-styles/typography-preview.js +19 -9
  79. package/build/components/global-styles/typography-preview.js.map +1 -1
  80. package/build/components/global-styles/ui.js +85 -34
  81. package/build/components/global-styles/ui.js.map +1 -1
  82. package/build/components/global-styles/utils.js +5 -334
  83. package/build/components/global-styles/utils.js.map +1 -1
  84. package/build/components/global-styles-renderer/index.js +7 -5
  85. package/build/components/global-styles-renderer/index.js.map +1 -1
  86. package/build/components/header-edit-mode/document-actions/index.js +2 -2
  87. package/build/components/header-edit-mode/document-actions/index.js.map +1 -1
  88. package/build/components/keyboard-shortcut-help-modal/index.js +0 -1
  89. package/build/components/keyboard-shortcut-help-modal/index.js.map +1 -1
  90. package/build/components/layout/index.js +6 -8
  91. package/build/components/layout/index.js.map +1 -1
  92. package/build/components/list/actions/rename-menu-item.js +8 -11
  93. package/build/components/list/actions/rename-menu-item.js.map +1 -1
  94. package/build/components/{sidebar-edit-mode/navigation-menu-sidebar/navigation-inspector.js → navigation-inspector/index.js} +1 -2
  95. package/build/components/navigation-inspector/index.js.map +1 -0
  96. package/build/components/{sidebar-edit-mode/navigation-menu-sidebar → navigation-inspector}/navigation-menu.js +13 -15
  97. package/build/components/navigation-inspector/navigation-menu.js.map +1 -0
  98. package/build/components/sidebar/index.js +3 -1
  99. package/build/components/sidebar/index.js.map +1 -1
  100. package/build/components/sidebar-edit-mode/global-styles-sidebar.js +3 -18
  101. package/build/components/sidebar-edit-mode/global-styles-sidebar.js.map +1 -1
  102. package/build/components/sidebar-edit-mode/index.js +1 -14
  103. package/build/components/sidebar-edit-mode/index.js.map +1 -1
  104. package/build/components/sidebar-navigation-screen/index.js +3 -2
  105. package/build/components/sidebar-navigation-screen/index.js.map +1 -1
  106. package/build/components/sidebar-navigation-screen-main/index.js +23 -1
  107. package/build/components/sidebar-navigation-screen-main/index.js.map +1 -1
  108. package/build/components/sidebar-navigation-screen-navigation-menus/index.js +35 -0
  109. package/build/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -0
  110. package/build/components/sidebar-navigation-screen-templates/index.js +3 -8
  111. package/build/components/sidebar-navigation-screen-templates/index.js.map +1 -1
  112. package/build/components/site-hub/index.js +2 -2
  113. package/build/components/site-hub/index.js.map +1 -1
  114. package/build/components/site-icon/index.js +1 -1
  115. package/build/components/site-icon/index.js.map +1 -1
  116. package/build/components/style-book/index.js +7 -4
  117. package/build/components/style-book/index.js.map +1 -1
  118. package/build/components/template-part-converter/convert-to-template-part.js +5 -9
  119. package/build/components/template-part-converter/convert-to-template-part.js.map +1 -1
  120. package/build/experiments.js +19 -0
  121. package/build/experiments.js.map +1 -0
  122. package/build/hooks/push-changes-to-global-styles/index.js +65 -6
  123. package/build/hooks/push-changes-to-global-styles/index.js.map +1 -1
  124. package/build/index.js +53 -60
  125. package/build/index.js.map +1 -1
  126. package/build/store/selectors.js +7 -27
  127. package/build/store/selectors.js.map +1 -1
  128. package/build/store/utils.js +77 -0
  129. package/build/store/utils.js.map +1 -0
  130. package/build/utils/template-part-create.js +71 -0
  131. package/build/utils/template-part-create.js.map +1 -0
  132. package/build-module/components/add-new-template/add-custom-generic-template-modal.js +9 -11
  133. package/build-module/components/add-new-template/add-custom-generic-template-modal.js.map +1 -1
  134. package/build-module/components/add-new-template/add-custom-template-modal.js +0 -1
  135. package/build-module/components/add-new-template/add-custom-template-modal.js.map +1 -1
  136. package/build-module/components/add-new-template/new-template-part.js +4 -27
  137. package/build-module/components/add-new-template/new-template-part.js.map +1 -1
  138. package/build-module/components/add-new-template/utils.js +0 -5
  139. package/build-module/components/add-new-template/utils.js.map +1 -1
  140. package/build-module/components/app/index.js +2 -7
  141. package/build-module/components/app/index.js.map +1 -1
  142. package/build-module/components/block-editor/index.js +14 -12
  143. package/build-module/components/block-editor/index.js.map +1 -1
  144. package/build-module/components/block-editor/inserter-media-categories.js +225 -0
  145. package/build-module/components/block-editor/inserter-media-categories.js.map +1 -0
  146. package/build-module/components/canvas-spinner/index.js +12 -0
  147. package/build-module/components/canvas-spinner/index.js.map +1 -0
  148. package/build-module/components/create-template-part-modal/index.js +5 -3
  149. package/build-module/components/create-template-part-modal/index.js.map +1 -1
  150. package/build-module/components/editor/index.js +3 -2
  151. package/build-module/components/editor/index.js.map +1 -1
  152. package/build-module/components/error-boundary/index.js +2 -12
  153. package/build-module/components/error-boundary/index.js.map +1 -1
  154. package/build-module/components/error-boundary/warning.js +5 -28
  155. package/build-module/components/error-boundary/warning.js.map +1 -1
  156. package/build-module/components/global-styles/block-preview-panel.js +2 -2
  157. package/build-module/components/global-styles/block-preview-panel.js.map +1 -1
  158. package/build-module/components/global-styles/border-panel.js +17 -11
  159. package/build-module/components/global-styles/border-panel.js.map +1 -1
  160. package/build-module/components/global-styles/color-palette-panel.js +11 -7
  161. package/build-module/components/global-styles/color-palette-panel.js.map +1 -1
  162. package/build-module/components/global-styles/context-menu.js +40 -8
  163. package/build-module/components/global-styles/context-menu.js.map +1 -1
  164. package/build-module/components/global-styles/custom-css.js +61 -15
  165. package/build-module/components/global-styles/custom-css.js.map +1 -1
  166. package/build-module/components/global-styles/dimensions-panel.js +49 -32
  167. package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
  168. package/build-module/components/global-styles/global-styles-provider.js +7 -2
  169. package/build-module/components/global-styles/global-styles-provider.js.map +1 -1
  170. package/build-module/components/global-styles/gradients-palette-panel.js +15 -11
  171. package/build-module/components/global-styles/gradients-palette-panel.js.map +1 -1
  172. package/build-module/components/global-styles/hooks.js +23 -134
  173. package/build-module/components/global-styles/hooks.js.map +1 -1
  174. package/build-module/components/global-styles/index.js +0 -2
  175. package/build-module/components/global-styles/index.js.map +1 -1
  176. package/build-module/components/global-styles/palette.js +10 -5
  177. package/build-module/components/global-styles/palette.js.map +1 -1
  178. package/build-module/components/global-styles/preview.js +18 -14
  179. package/build-module/components/global-styles/preview.js.map +1 -1
  180. package/build-module/components/global-styles/screen-background-color.js +26 -15
  181. package/build-module/components/global-styles/screen-background-color.js.map +1 -1
  182. package/build-module/components/global-styles/screen-border.js +10 -5
  183. package/build-module/components/global-styles/screen-border.js.map +1 -1
  184. package/build-module/components/global-styles/screen-button-color.js +16 -11
  185. package/build-module/components/global-styles/screen-button-color.js.map +1 -1
  186. package/build-module/components/global-styles/screen-colors.js +43 -37
  187. package/build-module/components/global-styles/screen-colors.js.map +1 -1
  188. package/build-module/components/global-styles/screen-css.js +21 -9
  189. package/build-module/components/global-styles/screen-css.js.map +1 -1
  190. package/build-module/components/global-styles/screen-heading-color.js +23 -18
  191. package/build-module/components/global-styles/screen-heading-color.js.map +1 -1
  192. package/build-module/components/global-styles/screen-layout.js +4 -4
  193. package/build-module/components/global-styles/screen-layout.js.map +1 -1
  194. package/build-module/components/global-styles/screen-link-color.js +18 -13
  195. package/build-module/components/global-styles/screen-link-color.js.map +1 -1
  196. package/build-module/components/global-styles/screen-root.js +23 -9
  197. package/build-module/components/global-styles/screen-root.js.map +1 -1
  198. package/build-module/components/global-styles/screen-style-variations.js +5 -2
  199. package/build-module/components/global-styles/screen-style-variations.js.map +1 -1
  200. package/build-module/components/global-styles/screen-text-color.js +14 -9
  201. package/build-module/components/global-styles/screen-text-color.js.map +1 -1
  202. package/build-module/components/global-styles/screen-typography.js +16 -12
  203. package/build-module/components/global-styles/screen-typography.js.map +1 -1
  204. package/build-module/components/global-styles/shadow-panel.js +177 -0
  205. package/build-module/components/global-styles/shadow-panel.js.map +1 -0
  206. package/build-module/components/global-styles/typography-panel.js +43 -31
  207. package/build-module/components/global-styles/typography-panel.js.map +1 -1
  208. package/build-module/components/global-styles/typography-preview.js +17 -9
  209. package/build-module/components/global-styles/typography-preview.js.map +1 -1
  210. package/build-module/components/global-styles/ui.js +80 -35
  211. package/build-module/components/global-styles/ui.js.map +1 -1
  212. package/build-module/components/global-styles/utils.js +4 -319
  213. package/build-module/components/global-styles/utils.js.map +1 -1
  214. package/build-module/components/global-styles-renderer/index.js +5 -5
  215. package/build-module/components/global-styles-renderer/index.js.map +1 -1
  216. package/build-module/components/header-edit-mode/document-actions/index.js +2 -2
  217. package/build-module/components/header-edit-mode/document-actions/index.js.map +1 -1
  218. package/build-module/components/keyboard-shortcut-help-modal/index.js +0 -1
  219. package/build-module/components/keyboard-shortcut-help-modal/index.js.map +1 -1
  220. package/build-module/components/layout/index.js +6 -8
  221. package/build-module/components/layout/index.js.map +1 -1
  222. package/build-module/components/list/actions/rename-menu-item.js +9 -12
  223. package/build-module/components/list/actions/rename-menu-item.js.map +1 -1
  224. package/build-module/components/{sidebar-edit-mode/navigation-menu-sidebar/navigation-inspector.js → navigation-inspector/index.js} +1 -2
  225. package/build-module/components/navigation-inspector/index.js.map +1 -0
  226. package/build-module/components/{sidebar-edit-mode/navigation-menu-sidebar → navigation-inspector}/navigation-menu.js +13 -16
  227. package/build-module/components/navigation-inspector/navigation-menu.js.map +1 -0
  228. package/build-module/components/sidebar/index.js +2 -1
  229. package/build-module/components/sidebar/index.js.map +1 -1
  230. package/build-module/components/sidebar-edit-mode/global-styles-sidebar.js +6 -21
  231. package/build-module/components/sidebar-edit-mode/global-styles-sidebar.js.map +1 -1
  232. package/build-module/components/sidebar-edit-mode/index.js +1 -13
  233. package/build-module/components/sidebar-edit-mode/index.js.map +1 -1
  234. package/build-module/components/sidebar-navigation-screen/index.js +3 -2
  235. package/build-module/components/sidebar-navigation-screen/index.js.map +1 -1
  236. package/build-module/components/sidebar-navigation-screen-main/index.js +22 -2
  237. package/build-module/components/sidebar-navigation-screen-main/index.js.map +1 -1
  238. package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js +23 -0
  239. package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -0
  240. package/build-module/components/sidebar-navigation-screen-templates/index.js +4 -9
  241. package/build-module/components/sidebar-navigation-screen-templates/index.js.map +1 -1
  242. package/build-module/components/site-hub/index.js +2 -2
  243. package/build-module/components/site-hub/index.js.map +1 -1
  244. package/build-module/components/site-icon/index.js +1 -1
  245. package/build-module/components/site-icon/index.js.map +1 -1
  246. package/build-module/components/style-book/index.js +8 -5
  247. package/build-module/components/style-book/index.js.map +1 -1
  248. package/build-module/components/template-part-converter/convert-to-template-part.js +5 -9
  249. package/build-module/components/template-part-converter/convert-to-template-part.js.map +1 -1
  250. package/build-module/experiments.js +9 -0
  251. package/build-module/experiments.js.map +1 -0
  252. package/build-module/hooks/push-changes-to-global-styles/index.js +62 -3
  253. package/build-module/hooks/push-changes-to-global-styles/index.js.map +1 -1
  254. package/build-module/index.js +52 -60
  255. package/build-module/index.js.map +1 -1
  256. package/build-module/store/selectors.js +6 -26
  257. package/build-module/store/selectors.js.map +1 -1
  258. package/build-module/store/utils.js +66 -0
  259. package/build-module/store/utils.js.map +1 -0
  260. package/build-module/utils/template-part-create.js +53 -0
  261. package/build-module/utils/template-part-create.js.map +1 -0
  262. package/build-style/style-rtl.css +314 -216
  263. package/build-style/style.css +314 -216
  264. package/package.json +32 -30
  265. package/src/components/add-new-template/add-custom-generic-template-modal.js +20 -28
  266. package/src/components/add-new-template/add-custom-template-modal.js +0 -1
  267. package/src/components/add-new-template/new-template-part.js +11 -32
  268. package/src/components/add-new-template/style.scss +0 -4
  269. package/src/components/add-new-template/utils.js +0 -14
  270. package/src/components/app/index.js +2 -2
  271. package/src/components/block-editor/index.js +12 -25
  272. package/src/components/block-editor/inserter-media-categories.js +247 -0
  273. package/src/components/block-editor/style.scss +19 -7
  274. package/src/components/canvas-spinner/index.js +12 -0
  275. package/src/components/canvas-spinner/style.scss +7 -0
  276. package/src/components/create-template-part-modal/index.js +75 -67
  277. package/src/components/create-template-part-modal/style.scss +0 -10
  278. package/src/components/editor/index.js +4 -2
  279. package/src/components/error-boundary/index.js +2 -10
  280. package/src/components/error-boundary/warning.js +6 -35
  281. package/src/components/global-styles/README.md +1 -75
  282. package/src/components/global-styles/block-preview-panel.js +2 -2
  283. package/src/components/global-styles/border-panel.js +19 -17
  284. package/src/components/global-styles/color-palette-panel.js +10 -7
  285. package/src/components/global-styles/context-menu.js +114 -44
  286. package/src/components/global-styles/custom-css.js +76 -19
  287. package/src/components/global-styles/dimensions-panel.js +46 -36
  288. package/src/components/global-styles/global-styles-provider.js +6 -2
  289. package/src/components/global-styles/gradients-palette-panel.js +17 -11
  290. package/src/components/global-styles/hooks.js +31 -155
  291. package/src/components/global-styles/index.js +0 -2
  292. package/src/components/global-styles/palette.js +9 -5
  293. package/src/components/global-styles/preview.js +19 -13
  294. package/src/components/global-styles/screen-background-color.js +37 -21
  295. package/src/components/global-styles/screen-border.js +10 -5
  296. package/src/components/global-styles/screen-button-color.js +21 -19
  297. package/src/components/global-styles/screen-colors.js +48 -65
  298. package/src/components/global-styles/screen-css.js +30 -14
  299. package/src/components/global-styles/screen-heading-color.js +32 -27
  300. package/src/components/global-styles/screen-layout.js +4 -7
  301. package/src/components/global-styles/screen-link-color.js +26 -26
  302. package/src/components/global-styles/screen-root.js +24 -9
  303. package/src/components/global-styles/screen-style-variations.js +7 -2
  304. package/src/components/global-styles/screen-text-color.js +15 -19
  305. package/src/components/global-styles/screen-typography.js +27 -12
  306. package/src/components/global-styles/shadow-panel.js +174 -0
  307. package/src/components/global-styles/style.scss +85 -1
  308. package/src/components/global-styles/typography-panel.js +60 -48
  309. package/src/components/global-styles/typography-preview.js +28 -9
  310. package/src/components/global-styles/ui.js +78 -53
  311. package/src/components/global-styles/utils.js +4 -371
  312. package/src/components/global-styles-renderer/index.js +3 -4
  313. package/src/components/header-edit-mode/document-actions/index.js +1 -1
  314. package/src/components/keyboard-shortcut-help-modal/index.js +0 -1
  315. package/src/components/layout/index.js +9 -2
  316. package/src/components/layout/style.scss +4 -5
  317. package/src/components/list/actions/rename-menu-item.js +14 -23
  318. package/src/components/list/style.scss +0 -4
  319. package/src/components/{sidebar-edit-mode/navigation-menu-sidebar/navigation-inspector.js → navigation-inspector/index.js} +1 -4
  320. package/src/components/{sidebar-edit-mode/navigation-menu-sidebar → navigation-inspector}/navigation-menu.js +10 -12
  321. package/src/components/{sidebar-edit-mode/navigation-menu-sidebar → navigation-inspector}/style.scss +0 -17
  322. package/src/components/sidebar/index.js +2 -0
  323. package/src/components/sidebar-edit-mode/global-styles-sidebar.js +8 -32
  324. package/src/components/sidebar-edit-mode/index.js +0 -11
  325. package/src/components/sidebar-edit-mode/settings-header/style.scss +8 -0
  326. package/src/components/sidebar-navigation-item/style.scss +28 -3
  327. package/src/components/sidebar-navigation-screen/index.js +4 -3
  328. package/src/components/sidebar-navigation-screen/style.scss +2 -0
  329. package/src/components/sidebar-navigation-screen-main/index.js +23 -1
  330. package/src/components/sidebar-navigation-screen-navigation-menus/index.js +25 -0
  331. package/src/components/sidebar-navigation-screen-navigation-menus/style.scss +12 -0
  332. package/src/components/sidebar-navigation-screen-templates/index.js +12 -19
  333. package/src/components/site-hub/index.js +1 -1
  334. package/src/components/site-hub/style.scss +7 -1
  335. package/src/components/site-icon/index.js +1 -1
  336. package/src/components/site-icon/style.scss +2 -2
  337. package/src/components/style-book/index.js +10 -5
  338. package/src/components/template-part-converter/convert-to-template-part.js +12 -10
  339. package/src/experiments.js +10 -0
  340. package/src/hooks/push-changes-to-global-styles/index.js +63 -5
  341. package/src/index.js +51 -59
  342. package/src/store/selectors.js +6 -26
  343. package/src/store/test/utils.js +181 -0
  344. package/src/store/utils.js +69 -0
  345. package/src/style.scss +4 -2
  346. package/src/utils/template-part-create.js +62 -0
  347. package/src/utils/test/template-part-create.js +63 -0
  348. package/build/components/global-styles/context.js +0 -22
  349. package/build/components/global-styles/context.js.map +0 -1
  350. package/build/components/global-styles/typography-utils.js +0 -92
  351. package/build/components/global-styles/typography-utils.js.map +0 -1
  352. package/build/components/global-styles/use-global-styles-output.js +0 -943
  353. package/build/components/global-styles/use-global-styles-output.js.map +0 -1
  354. package/build/components/sidebar-edit-mode/navigation-menu-sidebar/index.js +0 -42
  355. package/build/components/sidebar-edit-mode/navigation-menu-sidebar/index.js.map +0 -1
  356. package/build/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-inspector.js.map +0 -1
  357. package/build/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-menu.js.map +0 -1
  358. package/build-module/components/global-styles/context.js +0 -12
  359. package/build-module/components/global-styles/context.js.map +0 -1
  360. package/build-module/components/global-styles/typography-utils.js +0 -84
  361. package/build-module/components/global-styles/typography-utils.js.map +0 -1
  362. package/build-module/components/global-styles/use-global-styles-output.js +0 -901
  363. package/build-module/components/global-styles/use-global-styles-output.js.map +0 -1
  364. package/build-module/components/sidebar-edit-mode/navigation-menu-sidebar/index.js +0 -28
  365. package/build-module/components/sidebar-edit-mode/navigation-menu-sidebar/index.js.map +0 -1
  366. package/build-module/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-inspector.js.map +0 -1
  367. package/build-module/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-menu.js.map +0 -1
  368. package/src/components/global-styles/context.js +0 -15
  369. package/src/components/global-styles/test/typography-utils.js +0 -393
  370. package/src/components/global-styles/test/use-global-styles-output.js +0 -814
  371. package/src/components/global-styles/test/utils.js +0 -206
  372. package/src/components/global-styles/typography-utils.js +0 -87
  373. package/src/components/global-styles/use-global-styles-output.js +0 -1059
  374. package/src/components/sidebar-edit-mode/navigation-menu-sidebar/index.js +0 -37
@@ -1,11 +1,13 @@
1
- import { createElement } from "@wordpress/element";
1
+ import { createElement, Fragment } from "@wordpress/element";
2
2
 
3
3
  /**
4
4
  * WordPress dependencies
5
5
  */
6
- import { __experimentalItemGroup as ItemGroup } from '@wordpress/components';
7
- import { typography, border, color, layout } from '@wordpress/icons';
8
- import { __ } from '@wordpress/i18n';
6
+ import { __experimentalItemGroup as ItemGroup, __experimentalHStack as HStack, __experimentalSpacer as Spacer, FlexItem, CardBody, CardDivider } from '@wordpress/components';
7
+ import { typography, border, color, layout, chevronLeft, chevronRight } from '@wordpress/icons';
8
+ import { isRTL, __ } from '@wordpress/i18n';
9
+ import { useSelect } from '@wordpress/data';
10
+ import { store as coreStore } from '@wordpress/core-data';
9
11
  /**
10
12
  * Internal dependencies
11
13
  */
@@ -16,6 +18,7 @@ import { useHasDimensionsPanel } from './dimensions-panel';
16
18
  import { useHasTypographyPanel } from './typography-panel';
17
19
  import { useHasVariationsPanel } from './variations-panel';
18
20
  import { NavigationButtonAsItem } from './navigation-button';
21
+ import { IconWithCurrentColor } from './icon-with-current-color';
19
22
  import { ScreenVariations } from './screen-variations';
20
23
 
21
24
  function ContextMenu(_ref) {
@@ -29,7 +32,25 @@ function ContextMenu(_ref) {
29
32
  const hasDimensionsPanel = useHasDimensionsPanel(name);
30
33
  const hasLayoutPanel = hasDimensionsPanel;
31
34
  const hasVariationsPanel = useHasVariationsPanel(name, parentMenu);
32
- return createElement(ItemGroup, null, hasTypographyPanel && createElement(NavigationButtonAsItem, {
35
+ const {
36
+ canEditCSS
37
+ } = useSelect(select => {
38
+ var _globalStyles$_links$, _globalStyles$_links;
39
+
40
+ const {
41
+ getEntityRecord,
42
+ __experimentalGetCurrentGlobalStylesId
43
+ } = select(coreStore);
44
+
45
+ const globalStylesId = __experimentalGetCurrentGlobalStylesId();
46
+
47
+ const globalStyles = globalStylesId ? getEntityRecord('root', 'globalStyles', globalStylesId) : undefined;
48
+ return {
49
+ canEditCSS: (_globalStyles$_links$ = !!(globalStyles !== null && globalStyles !== void 0 && (_globalStyles$_links = globalStyles._links) !== null && _globalStyles$_links !== void 0 && _globalStyles$_links['wp:action-edit-css'])) !== null && _globalStyles$_links$ !== void 0 ? _globalStyles$_links$ : false
50
+ };
51
+ }, []);
52
+ const isBlocksPanel = parentMenu.includes('blocks') && !parentMenu.includes('variations');
53
+ return createElement(Fragment, null, createElement(ItemGroup, null, hasTypographyPanel && createElement(NavigationButtonAsItem, {
33
54
  icon: typography,
34
55
  path: parentMenu + '/typography',
35
56
  "aria-label": __('Typography styles')
@@ -40,15 +61,26 @@ function ContextMenu(_ref) {
40
61
  }, __('Colors')), hasBorderPanel && createElement(NavigationButtonAsItem, {
41
62
  icon: border,
42
63
  path: parentMenu + '/border',
43
- "aria-label": __('Border styles')
44
- }, __('Border')), hasLayoutPanel && createElement(NavigationButtonAsItem, {
64
+ "aria-label": __('Border & shadow styles')
65
+ }, __('Border & Shadow')), hasLayoutPanel && createElement(NavigationButtonAsItem, {
45
66
  icon: layout,
46
67
  path: parentMenu + '/layout',
47
68
  "aria-label": __('Layout styles')
48
69
  }, __('Layout')), hasVariationsPanel && createElement(ScreenVariations, {
49
70
  name: name,
50
71
  path: parentMenu
51
- }));
72
+ }), isBlocksPanel && canEditCSS && createElement(Fragment, null, createElement(CardDivider, null), createElement(CardBody, null, createElement(Spacer, {
73
+ as: "p",
74
+ paddingTop: 2,
75
+ marginBottom: 4
76
+ }, __('Add your own CSS to customize the block appearance.')), createElement(ItemGroup, null, createElement(NavigationButtonAsItem, {
77
+ path: parentMenu + '/css',
78
+ "aria-label": __('Additional block CSS')
79
+ }, createElement(HStack, {
80
+ justify: "space-between"
81
+ }, createElement(FlexItem, null, __('Additional block CSS')), createElement(IconWithCurrentColor, {
82
+ icon: isRTL() ? chevronLeft : chevronRight
83
+ }))))), createElement(CardDivider, null))));
52
84
  }
53
85
 
54
86
  export default ContextMenu;
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/global-styles/context-menu.js"],"names":["__experimentalItemGroup","ItemGroup","typography","border","color","layout","__","useHasBorderPanel","useHasColorPanel","useHasDimensionsPanel","useHasTypographyPanel","useHasVariationsPanel","NavigationButtonAsItem","ScreenVariations","ContextMenu","name","parentMenu","hasTypographyPanel","hasColorPanel","hasBorderPanel","hasDimensionsPanel","hasLayoutPanel","hasVariationsPanel"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,uBAAuB,IAAIC,SAApC,QAAqD,uBAArD;AACA,SAASC,UAAT,EAAqBC,MAArB,EAA6BC,KAA7B,EAAoCC,MAApC,QAAkD,kBAAlD;AACA,SAASC,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AACA,SAASC,iBAAT,QAAkC,gBAAlC;AACA,SAASC,gBAAT,QAAiC,eAAjC;AACA,SAASC,qBAAT,QAAsC,oBAAtC;AACA,SAASC,qBAAT,QAAsC,oBAAtC;AACA,SAASC,qBAAT,QAAsC,oBAAtC;AACA,SAASC,sBAAT,QAAuC,qBAAvC;AACA,SAASC,gBAAT,QAAiC,qBAAjC;;AAEA,SAASC,WAAT,OAAkD;AAAA,MAA5B;AAAEC,IAAAA,IAAF;AAAQC,IAAAA,UAAU,GAAG;AAArB,GAA4B;AACjD,QAAMC,kBAAkB,GAAGP,qBAAqB,CAAEK,IAAF,CAAhD;AACA,QAAMG,aAAa,GAAGV,gBAAgB,CAAEO,IAAF,CAAtC;AACA,QAAMI,cAAc,GAAGZ,iBAAiB,CAAEQ,IAAF,CAAxC;AACA,QAAMK,kBAAkB,GAAGX,qBAAqB,CAAEM,IAAF,CAAhD;AACA,QAAMM,cAAc,GAAGD,kBAAvB;AACA,QAAME,kBAAkB,GAAGX,qBAAqB,CAAEI,IAAF,EAAQC,UAAR,CAAhD;AAEA,SACC,cAAC,SAAD,QACGC,kBAAkB,IACnB,cAAC,sBAAD;AACC,IAAA,IAAI,EAAGf,UADR;AAEC,IAAA,IAAI,EAAGc,UAAU,GAAG,aAFrB;AAGC,kBAAaV,EAAE,CAAE,mBAAF;AAHhB,KAKGA,EAAE,CAAE,YAAF,CALL,CAFF,EAUGY,aAAa,IACd,cAAC,sBAAD;AACC,IAAA,IAAI,EAAGd,KADR;AAEC,IAAA,IAAI,EAAGY,UAAU,GAAG,SAFrB;AAGC,kBAAaV,EAAE,CAAE,eAAF;AAHhB,KAKGA,EAAE,CAAE,QAAF,CALL,CAXF,EAmBGa,cAAc,IACf,cAAC,sBAAD;AACC,IAAA,IAAI,EAAGhB,MADR;AAEC,IAAA,IAAI,EAAGa,UAAU,GAAG,SAFrB;AAGC,kBAAaV,EAAE,CAAE,eAAF;AAHhB,KAKGA,EAAE,CAAE,QAAF,CALL,CApBF,EA4BGe,cAAc,IACf,cAAC,sBAAD;AACC,IAAA,IAAI,EAAGhB,MADR;AAEC,IAAA,IAAI,EAAGW,UAAU,GAAG,SAFrB;AAGC,kBAAaV,EAAE,CAAE,eAAF;AAHhB,KAKGA,EAAE,CAAE,QAAF,CALL,CA7BF,EAqCGgB,kBAAkB,IACnB,cAAC,gBAAD;AAAkB,IAAA,IAAI,EAAGP,IAAzB;AAAgC,IAAA,IAAI,EAAGC;AAAvC,IAtCF,CADD;AA2CA;;AAED,eAAeF,WAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __experimentalItemGroup as ItemGroup } from '@wordpress/components';\nimport { typography, border, color, layout } from '@wordpress/icons';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { useHasBorderPanel } from './border-panel';\nimport { useHasColorPanel } from './color-utils';\nimport { useHasDimensionsPanel } from './dimensions-panel';\nimport { useHasTypographyPanel } from './typography-panel';\nimport { useHasVariationsPanel } from './variations-panel';\nimport { NavigationButtonAsItem } from './navigation-button';\nimport { ScreenVariations } from './screen-variations';\n\nfunction ContextMenu( { name, parentMenu = '' } ) {\n\tconst hasTypographyPanel = useHasTypographyPanel( name );\n\tconst hasColorPanel = useHasColorPanel( name );\n\tconst hasBorderPanel = useHasBorderPanel( name );\n\tconst hasDimensionsPanel = useHasDimensionsPanel( name );\n\tconst hasLayoutPanel = hasDimensionsPanel;\n\tconst hasVariationsPanel = useHasVariationsPanel( name, parentMenu );\n\n\treturn (\n\t\t<ItemGroup>\n\t\t\t{ hasTypographyPanel && (\n\t\t\t\t<NavigationButtonAsItem\n\t\t\t\t\ticon={ typography }\n\t\t\t\t\tpath={ parentMenu + '/typography' }\n\t\t\t\t\taria-label={ __( 'Typography styles' ) }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Typography' ) }\n\t\t\t\t</NavigationButtonAsItem>\n\t\t\t) }\n\t\t\t{ hasColorPanel && (\n\t\t\t\t<NavigationButtonAsItem\n\t\t\t\t\ticon={ color }\n\t\t\t\t\tpath={ parentMenu + '/colors' }\n\t\t\t\t\taria-label={ __( 'Colors styles' ) }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Colors' ) }\n\t\t\t\t</NavigationButtonAsItem>\n\t\t\t) }\n\t\t\t{ hasBorderPanel && (\n\t\t\t\t<NavigationButtonAsItem\n\t\t\t\t\ticon={ border }\n\t\t\t\t\tpath={ parentMenu + '/border' }\n\t\t\t\t\taria-label={ __( 'Border styles' ) }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Border' ) }\n\t\t\t\t</NavigationButtonAsItem>\n\t\t\t) }\n\t\t\t{ hasLayoutPanel && (\n\t\t\t\t<NavigationButtonAsItem\n\t\t\t\t\ticon={ layout }\n\t\t\t\t\tpath={ parentMenu + '/layout' }\n\t\t\t\t\taria-label={ __( 'Layout styles' ) }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Layout' ) }\n\t\t\t\t</NavigationButtonAsItem>\n\t\t\t) }\n\t\t\t{ hasVariationsPanel && (\n\t\t\t\t<ScreenVariations name={ name } path={ parentMenu } />\n\t\t\t) }\n\t\t</ItemGroup>\n\t);\n}\n\nexport default ContextMenu;\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/global-styles/context-menu.js"],"names":["__experimentalItemGroup","ItemGroup","__experimentalHStack","HStack","__experimentalSpacer","Spacer","FlexItem","CardBody","CardDivider","typography","border","color","layout","chevronLeft","chevronRight","isRTL","__","useSelect","store","coreStore","useHasBorderPanel","useHasColorPanel","useHasDimensionsPanel","useHasTypographyPanel","useHasVariationsPanel","NavigationButtonAsItem","IconWithCurrentColor","ScreenVariations","ContextMenu","name","parentMenu","hasTypographyPanel","hasColorPanel","hasBorderPanel","hasDimensionsPanel","hasLayoutPanel","hasVariationsPanel","canEditCSS","select","getEntityRecord","__experimentalGetCurrentGlobalStylesId","globalStylesId","globalStyles","undefined","_links","isBlocksPanel","includes"],"mappings":"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","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalItemGroup as ItemGroup,\n\t__experimentalHStack as HStack,\n\t__experimentalSpacer as Spacer,\n\tFlexItem,\n\tCardBody,\n\tCardDivider,\n} from '@wordpress/components';\nimport {\n\ttypography,\n\tborder,\n\tcolor,\n\tlayout,\n\tchevronLeft,\n\tchevronRight,\n} from '@wordpress/icons';\nimport { isRTL, __ } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { useHasBorderPanel } from './border-panel';\nimport { useHasColorPanel } from './color-utils';\nimport { useHasDimensionsPanel } from './dimensions-panel';\nimport { useHasTypographyPanel } from './typography-panel';\nimport { useHasVariationsPanel } from './variations-panel';\nimport { NavigationButtonAsItem } from './navigation-button';\nimport { IconWithCurrentColor } from './icon-with-current-color';\nimport { ScreenVariations } from './screen-variations';\n\nfunction ContextMenu( { name, parentMenu = '' } ) {\n\tconst hasTypographyPanel = useHasTypographyPanel( name );\n\tconst hasColorPanel = useHasColorPanel( name );\n\tconst hasBorderPanel = useHasBorderPanel( name );\n\tconst hasDimensionsPanel = useHasDimensionsPanel( name );\n\tconst hasLayoutPanel = hasDimensionsPanel;\n\tconst hasVariationsPanel = useHasVariationsPanel( name, parentMenu );\n\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:\n\t\t\t\t!! globalStyles?._links?.[ 'wp:action-edit-css' ] ?? false,\n\t\t};\n\t}, [] );\n\n\tconst isBlocksPanel =\n\t\tparentMenu.includes( 'blocks' ) &&\n\t\t! parentMenu.includes( 'variations' );\n\n\treturn (\n\t\t<>\n\t\t\t<ItemGroup>\n\t\t\t\t{ hasTypographyPanel && (\n\t\t\t\t\t<NavigationButtonAsItem\n\t\t\t\t\t\ticon={ typography }\n\t\t\t\t\t\tpath={ parentMenu + '/typography' }\n\t\t\t\t\t\taria-label={ __( 'Typography styles' ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Typography' ) }\n\t\t\t\t\t</NavigationButtonAsItem>\n\t\t\t\t) }\n\t\t\t\t{ hasColorPanel && (\n\t\t\t\t\t<NavigationButtonAsItem\n\t\t\t\t\t\ticon={ color }\n\t\t\t\t\t\tpath={ parentMenu + '/colors' }\n\t\t\t\t\t\taria-label={ __( 'Colors styles' ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Colors' ) }\n\t\t\t\t\t</NavigationButtonAsItem>\n\t\t\t\t) }\n\t\t\t\t{ hasBorderPanel && (\n\t\t\t\t\t<NavigationButtonAsItem\n\t\t\t\t\t\ticon={ border }\n\t\t\t\t\t\tpath={ parentMenu + '/border' }\n\t\t\t\t\t\taria-label={ __( 'Border & shadow styles' ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Border & Shadow' ) }\n\t\t\t\t\t</NavigationButtonAsItem>\n\t\t\t\t) }\n\t\t\t\t{ hasLayoutPanel && (\n\t\t\t\t\t<NavigationButtonAsItem\n\t\t\t\t\t\ticon={ layout }\n\t\t\t\t\t\tpath={ parentMenu + '/layout' }\n\t\t\t\t\t\taria-label={ __( 'Layout styles' ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Layout' ) }\n\t\t\t\t\t</NavigationButtonAsItem>\n\t\t\t\t) }\n\t\t\t\t{ hasVariationsPanel && (\n\t\t\t\t\t<ScreenVariations name={ name } path={ parentMenu } />\n\t\t\t\t) }\n\t\t\t\t{ isBlocksPanel && canEditCSS && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<CardDivider />\n\t\t\t\t\t\t<CardBody>\n\t\t\t\t\t\t\t<Spacer as=\"p\" paddingTop={ 2 } marginBottom={ 4 }>\n\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t'Add your own CSS to customize the block appearance.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</Spacer>\n\t\t\t\t\t\t\t<ItemGroup>\n\t\t\t\t\t\t\t\t<NavigationButtonAsItem\n\t\t\t\t\t\t\t\t\tpath={ parentMenu + '/css' }\n\t\t\t\t\t\t\t\t\taria-label={ __( 'Additional block CSS' ) }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<HStack justify=\"space-between\">\n\t\t\t\t\t\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t\t\t\t\t\t{ __( 'Additional block CSS' ) }\n\t\t\t\t\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t\t\t\t\t\t<IconWithCurrentColor\n\t\t\t\t\t\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t\t\t\t\t\tisRTL()\n\t\t\t\t\t\t\t\t\t\t\t\t\t? chevronLeft\n\t\t\t\t\t\t\t\t\t\t\t\t\t: chevronRight\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t</HStack>\n\t\t\t\t\t\t\t\t</NavigationButtonAsItem>\n\t\t\t\t\t\t\t</ItemGroup>\n\t\t\t\t\t\t</CardBody>\n\t\t\t\t\t\t<CardDivider />\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</ItemGroup>\n\t\t</>\n\t);\n}\n\nexport default ContextMenu;\n"]}
@@ -3,17 +3,31 @@ import { createElement, Fragment } from "@wordpress/element";
3
3
  /**
4
4
  * WordPress dependencies
5
5
  */
6
- import { TextareaControl, Panel, PanelBody } from '@wordpress/components';
6
+ import { useState } from '@wordpress/element';
7
+ import { TextareaControl, Panel, PanelBody, __experimentalVStack as VStack, Tooltip, Icon } from '@wordpress/components';
7
8
  import { __ } from '@wordpress/i18n';
9
+ import { experiments as blockEditorExperiments, transformStyles } from '@wordpress/block-editor';
10
+ import { info } from '@wordpress/icons';
8
11
  /**
9
12
  * Internal dependencies
10
13
  */
11
14
 
12
- import { useStyle } from './hooks';
15
+ import { unlock } from '../../experiments';
16
+ import Subtitle from './subtitle';
17
+ const {
18
+ useGlobalStyle
19
+ } = unlock(blockEditorExperiments);
13
20
 
14
- function CustomCSSControl() {
15
- const [customCSS, setCustomCSS] = useStyle('css');
16
- const [themeCSS] = useStyle('css', null, 'base');
21
+ function CustomCSSControl(_ref) {
22
+ let {
23
+ blockName
24
+ } = _ref;
25
+ // If blockName is defined, we are customizing CSS at the block level:
26
+ // styles.blocks.blockName.css
27
+ const block = !!blockName ? blockName : null;
28
+ const [customCSS, setCustomCSS] = useGlobalStyle('css', block);
29
+ const [themeCSS] = useGlobalStyle('css', block, 'base');
30
+ const [cssError, setCSSError] = useState(null);
17
31
  const ignoreThemeCustomCSS = '/* IgnoreThemeCustomCSS */'; // If there is custom css from theme.json show it in the edit box
18
32
  // so the user can selectively overwrite it, rather than have the user CSS
19
33
  // completely overwrite the theme CSS by default.
@@ -29,23 +43,55 @@ function CustomCSSControl() {
29
43
  }
30
44
 
31
45
  setCustomCSS(value);
46
+
47
+ if (cssError) {
48
+ const [transformed] = transformStyles([{
49
+ css: value
50
+ }], '.editor-styles-wrapper');
51
+
52
+ if (transformed) {
53
+ setCSSError(null);
54
+ }
55
+ }
56
+ }
57
+
58
+ function handleOnBlur(event) {
59
+ var _event$target;
60
+
61
+ if (!(event !== null && event !== void 0 && (_event$target = event.target) !== null && _event$target !== void 0 && _event$target.value)) {
62
+ setCSSError(null);
63
+ return;
64
+ }
65
+
66
+ const [transformed] = transformStyles([{
67
+ css: event.target.value
68
+ }], '.editor-styles-wrapper');
69
+ setCSSError(transformed === null ? __('There is an error with your CSS structure.') : null);
32
70
  }
33
71
 
34
72
  const originalThemeCustomCSS = themeCSS && customCSS && themeCustomCSS !== customCSS ? themeCSS : undefined;
35
- return createElement(Fragment, null, createElement(TextareaControl, {
36
- __nextHasNoMarginBottom: true,
37
- value: (customCSS === null || customCSS === void 0 ? void 0 : customCSS.replace(ignoreThemeCustomCSS, '')) || themeCustomCSS,
38
- onChange: value => handleOnChange(value),
39
- rows: 15,
40
- className: "edit-site-global-styles__custom-css-input",
41
- spellCheck: false,
42
- help: __("Enter your custom CSS in the textarea and preview in the editor. Changes won't take effect until you've saved the template.")
43
- }), originalThemeCustomCSS && createElement(Panel, null, createElement(PanelBody, {
73
+ return createElement(Fragment, null, originalThemeCustomCSS && createElement(Panel, null, createElement(PanelBody, {
44
74
  title: __('Original Theme Custom CSS'),
45
75
  initialOpen: false
46
76
  }, createElement("pre", {
47
77
  className: "edit-site-global-styles__custom-css-theme-css"
48
- }, originalThemeCustomCSS))));
78
+ }, originalThemeCustomCSS))), createElement(VStack, {
79
+ spacing: 3
80
+ }, createElement(Subtitle, null, __('ADDITIONAL CSS')), createElement(TextareaControl, {
81
+ __nextHasNoMarginBottom: true,
82
+ value: (customCSS === null || customCSS === void 0 ? void 0 : customCSS.replace(ignoreThemeCustomCSS, '')) || themeCustomCSS,
83
+ onChange: value => handleOnChange(value),
84
+ onBlur: handleOnBlur,
85
+ className: "edit-site-global-styles__custom-css-input",
86
+ spellCheck: false
87
+ }), cssError && createElement(Tooltip, {
88
+ text: cssError
89
+ }, createElement("div", {
90
+ className: "edit-site-global-styles__custom-css-validation-wrapper"
91
+ }, createElement(Icon, {
92
+ icon: info,
93
+ className: "edit-site-global-styles__custom-css-validation-icon"
94
+ })))));
49
95
  }
50
96
 
51
97
  export default CustomCSSControl;
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/global-styles/custom-css.js"],"names":["TextareaControl","Panel","PanelBody","__","useStyle","CustomCSSControl","customCSS","setCustomCSS","themeCSS","ignoreThemeCustomCSS","themeCustomCSS","undefined","handleOnChange","value","originalThemeCustomCSS","replace"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,eAAT,EAA0BC,KAA1B,EAAiCC,SAAjC,QAAkD,uBAAlD;AACA,SAASC,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AACA,SAASC,QAAT,QAAyB,SAAzB;;AAEA,SAASC,gBAAT,GAA4B;AAC3B,QAAM,CAAEC,SAAF,EAAaC,YAAb,IAA8BH,QAAQ,CAAE,KAAF,CAA5C;AACA,QAAM,CAAEI,QAAF,IAAeJ,QAAQ,CAAE,KAAF,EAAS,IAAT,EAAe,MAAf,CAA7B;AACA,QAAMK,oBAAoB,GAAG,4BAA7B,CAH2B,CAK3B;AACA;AACA;;AACA,QAAMC,cAAc,GACnB,CAAEJ,SAAF,IAAeE,QAAf,GACI,MAAML,EAAE,CACT,wBADS,CAEN,QAAQK,QAAU,QAAQL,EAAE,CAAE,sBAAF,CAA4B,KAH9D,GAIGQ,SALJ;;AAOA,WAASC,cAAT,CAAyBC,KAAzB,EAAiC;AAChC;AACA;AACA,QAAKL,QAAQ,IAAIK,KAAK,KAAK,EAA3B,EAAgC;AAC/BN,MAAAA,YAAY,CAAEE,oBAAF,CAAZ;AACA;AACA;;AACDF,IAAAA,YAAY,CAAEM,KAAF,CAAZ;AACA;;AAED,QAAMC,sBAAsB,GAC3BN,QAAQ,IAAIF,SAAZ,IAAyBI,cAAc,KAAKJ,SAA5C,GACGE,QADH,GAEGG,SAHJ;AAKA,SACC,8BACC,cAAC,eAAD;AACC,IAAA,uBAAuB,MADxB;AAEC,IAAA,KAAK,EACJ,CAAAL,SAAS,SAAT,IAAAA,SAAS,WAAT,YAAAA,SAAS,CAAES,OAAX,CAAoBN,oBAApB,EAA0C,EAA1C,MACAC,cAJF;AAMC,IAAA,QAAQ,EAAKG,KAAF,IAAaD,cAAc,CAAEC,KAAF,CANvC;AAOC,IAAA,IAAI,EAAG,EAPR;AAQC,IAAA,SAAS,EAAC,2CARX;AASC,IAAA,UAAU,EAAG,KATd;AAUC,IAAA,IAAI,EAAGV,EAAE,CACR,6HADQ;AAVV,IADD,EAeGW,sBAAsB,IACvB,cAAC,KAAD,QACC,cAAC,SAAD;AACC,IAAA,KAAK,EAAGX,EAAE,CAAE,2BAAF,CADX;AAEC,IAAA,WAAW,EAAG;AAFf,KAIC;AAAK,IAAA,SAAS,EAAC;AAAf,KACGW,sBADH,CAJD,CADD,CAhBF,CADD;AA8BA;;AAED,eAAeT,gBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { TextareaControl, Panel, PanelBody } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { useStyle } from './hooks';\n\nfunction CustomCSSControl() {\n\tconst [ customCSS, setCustomCSS ] = useStyle( 'css' );\n\tconst [ themeCSS ] = useStyle( 'css', null, 'base' );\n\tconst ignoreThemeCustomCSS = '/* IgnoreThemeCustomCSS */';\n\n\t// If there is custom css from theme.json show it in the edit box\n\t// so the user can selectively overwrite it, rather than have the user CSS\n\t// completely overwrite the theme CSS by default.\n\tconst themeCustomCSS =\n\t\t! customCSS && themeCSS\n\t\t\t? `/* ${ __(\n\t\t\t\t\t'Theme Custom CSS start'\n\t\t\t ) } */\\n${ themeCSS }\\n/* ${ __( 'Theme Custom CSS end' ) } */`\n\t\t\t: undefined;\n\n\tfunction handleOnChange( value ) {\n\t\t// If there is theme custom CSS, but the user clears the input box then save the\n\t\t// ignoreThemeCustomCSS string so that the theme custom CSS is not re-applied.\n\t\tif ( themeCSS && value === '' ) {\n\t\t\tsetCustomCSS( ignoreThemeCustomCSS );\n\t\t\treturn;\n\t\t}\n\t\tsetCustomCSS( value );\n\t}\n\n\tconst originalThemeCustomCSS =\n\t\tthemeCSS && customCSS && themeCustomCSS !== customCSS\n\t\t\t? themeCSS\n\t\t\t: undefined;\n\n\treturn (\n\t\t<>\n\t\t\t<TextareaControl\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\tvalue={\n\t\t\t\t\tcustomCSS?.replace( ignoreThemeCustomCSS, '' ) ||\n\t\t\t\t\tthemeCustomCSS\n\t\t\t\t}\n\t\t\t\tonChange={ ( value ) => handleOnChange( value ) }\n\t\t\t\trows={ 15 }\n\t\t\t\tclassName=\"edit-site-global-styles__custom-css-input\"\n\t\t\t\tspellCheck={ false }\n\t\t\t\thelp={ __(\n\t\t\t\t\t\"Enter your custom CSS in the textarea and preview in the editor. Changes won't take effect until you've saved the template.\"\n\t\t\t\t) }\n\t\t\t/>\n\t\t\t{ originalThemeCustomCSS && (\n\t\t\t\t<Panel>\n\t\t\t\t\t<PanelBody\n\t\t\t\t\t\ttitle={ __( 'Original Theme Custom CSS' ) }\n\t\t\t\t\t\tinitialOpen={ false }\n\t\t\t\t\t>\n\t\t\t\t\t\t<pre className=\"edit-site-global-styles__custom-css-theme-css\">\n\t\t\t\t\t\t\t{ originalThemeCustomCSS }\n\t\t\t\t\t\t</pre>\n\t\t\t\t\t</PanelBody>\n\t\t\t\t</Panel>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default CustomCSSControl;\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/global-styles/custom-css.js"],"names":["useState","TextareaControl","Panel","PanelBody","__experimentalVStack","VStack","Tooltip","Icon","__","experiments","blockEditorExperiments","transformStyles","info","unlock","Subtitle","useGlobalStyle","CustomCSSControl","blockName","block","customCSS","setCustomCSS","themeCSS","cssError","setCSSError","ignoreThemeCustomCSS","themeCustomCSS","undefined","handleOnChange","value","transformed","css","handleOnBlur","event","target","originalThemeCustomCSS","replace"],"mappings":"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","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState } from '@wordpress/element';\nimport {\n\tTextareaControl,\n\tPanel,\n\tPanelBody,\n\t__experimentalVStack as VStack,\n\tTooltip,\n\tIcon,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport {\n\texperiments as blockEditorExperiments,\n\ttransformStyles,\n} from '@wordpress/block-editor';\nimport { info } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../experiments';\nimport Subtitle from './subtitle';\n\nconst { useGlobalStyle } = unlock( blockEditorExperiments );\nfunction CustomCSSControl( { blockName } ) {\n\t// If blockName is defined, we are customizing CSS at the block level:\n\t// styles.blocks.blockName.css\n\tconst block = !! blockName ? blockName : null;\n\n\tconst [ customCSS, setCustomCSS ] = useGlobalStyle( 'css', block );\n\tconst [ themeCSS ] = useGlobalStyle( 'css', block, 'base' );\n\tconst [ cssError, setCSSError ] = useState( null );\n\tconst ignoreThemeCustomCSS = '/* IgnoreThemeCustomCSS */';\n\n\t// If there is custom css from theme.json show it in the edit box\n\t// so the user can selectively overwrite it, rather than have the user CSS\n\t// completely overwrite the theme CSS by default.\n\tconst themeCustomCSS =\n\t\t! customCSS && themeCSS\n\t\t\t? `/* ${ __(\n\t\t\t\t\t'Theme Custom CSS start'\n\t\t\t ) } */\\n${ themeCSS }\\n/* ${ __( 'Theme Custom CSS end' ) } */`\n\t\t\t: undefined;\n\n\tfunction handleOnChange( value ) {\n\t\t// If there is theme custom CSS, but the user clears the input box then save the\n\t\t// ignoreThemeCustomCSS string so that the theme custom CSS is not re-applied.\n\t\tif ( themeCSS && value === '' ) {\n\t\t\tsetCustomCSS( ignoreThemeCustomCSS );\n\t\t\treturn;\n\t\t}\n\t\tsetCustomCSS( value );\n\t\tif ( cssError ) {\n\t\t\tconst [ transformed ] = transformStyles(\n\t\t\t\t[ { css: value } ],\n\t\t\t\t'.editor-styles-wrapper'\n\t\t\t);\n\t\t\tif ( transformed ) {\n\t\t\t\tsetCSSError( null );\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction handleOnBlur( event ) {\n\t\tif ( ! event?.target?.value ) {\n\t\t\tsetCSSError( null );\n\t\t\treturn;\n\t\t}\n\n\t\tconst [ transformed ] = transformStyles(\n\t\t\t[ { css: event.target.value } ],\n\t\t\t'.editor-styles-wrapper'\n\t\t);\n\n\t\tsetCSSError(\n\t\t\ttransformed === null\n\t\t\t\t? __( 'There is an error with your CSS structure.' )\n\t\t\t\t: null\n\t\t);\n\t}\n\n\tconst originalThemeCustomCSS =\n\t\tthemeCSS && customCSS && themeCustomCSS !== customCSS\n\t\t\t? themeCSS\n\t\t\t: undefined;\n\n\treturn (\n\t\t<>\n\t\t\t{ originalThemeCustomCSS && (\n\t\t\t\t<Panel>\n\t\t\t\t\t<PanelBody\n\t\t\t\t\t\ttitle={ __( 'Original Theme Custom CSS' ) }\n\t\t\t\t\t\tinitialOpen={ false }\n\t\t\t\t\t>\n\t\t\t\t\t\t<pre className=\"edit-site-global-styles__custom-css-theme-css\">\n\t\t\t\t\t\t\t{ originalThemeCustomCSS }\n\t\t\t\t\t\t</pre>\n\t\t\t\t\t</PanelBody>\n\t\t\t\t</Panel>\n\t\t\t) }\n\t\t\t<VStack spacing={ 3 }>\n\t\t\t\t<Subtitle>{ __( 'ADDITIONAL CSS' ) }</Subtitle>\n\t\t\t\t<TextareaControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\tvalue={\n\t\t\t\t\t\tcustomCSS?.replace( ignoreThemeCustomCSS, '' ) ||\n\t\t\t\t\t\tthemeCustomCSS\n\t\t\t\t\t}\n\t\t\t\t\tonChange={ ( value ) => handleOnChange( value ) }\n\t\t\t\t\tonBlur={ handleOnBlur }\n\t\t\t\t\tclassName=\"edit-site-global-styles__custom-css-input\"\n\t\t\t\t\tspellCheck={ false }\n\t\t\t\t/>\n\t\t\t\t{ cssError && (\n\t\t\t\t\t<Tooltip text={ cssError }>\n\t\t\t\t\t\t<div className=\"edit-site-global-styles__custom-css-validation-wrapper\">\n\t\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\t\ticon={ info }\n\t\t\t\t\t\t\t\tclassName=\"edit-site-global-styles__custom-css-validation-icon\"\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</Tooltip>\n\t\t\t\t) }\n\t\t\t</VStack>\n\t\t</>\n\t);\n}\n\nexport default CustomCSSControl;\n"]}
@@ -10,13 +10,18 @@ import classnames from 'classnames';
10
10
 
11
11
  import { __ } from '@wordpress/i18n';
12
12
  import { __experimentalToolsPanel as ToolsPanel, __experimentalToolsPanelItem as ToolsPanelItem, __experimentalBoxControl as BoxControl, __experimentalHStack as HStack, __experimentalUnitControl as UnitControl, __experimentalUseCustomUnits as useCustomUnits, __experimentalView as View } from '@wordpress/components';
13
- import { __experimentalUseCustomSides as useCustomSides, __experimentalHeightControl as HeightControl, __experimentalSpacingSizesControl as SpacingSizesControl } from '@wordpress/block-editor';
13
+ import { __experimentalUseCustomSides as useCustomSides, HeightControl, __experimentalSpacingSizesControl as SpacingSizesControl, experiments as blockEditorExperiments } from '@wordpress/block-editor';
14
14
  import { Icon, positionCenter, stretchWide } from '@wordpress/icons';
15
15
  /**
16
16
  * Internal dependencies
17
17
  */
18
18
 
19
- import { getSupportedGlobalStylesPanels, useSetting, useStyle } from './hooks';
19
+ import { getSupportedGlobalStylesPanels } from './hooks';
20
+ import { unlock } from '../../experiments';
21
+ const {
22
+ useGlobalSetting,
23
+ useGlobalStyle
24
+ } = unlock(blockEditorExperiments);
20
25
  const AXIAL_SIDES = ['horizontal', 'vertical'];
21
26
  export function useHasDimensionsPanel(name) {
22
27
  const hasContentSize = useHasContentSize(name);
@@ -30,43 +35,51 @@ export function useHasDimensionsPanel(name) {
30
35
 
31
36
  function useHasContentSize(name) {
32
37
  const supports = getSupportedGlobalStylesPanels(name);
33
- const [settings] = useSetting('layout.contentSize', name);
38
+ const [settings] = useGlobalSetting('layout.contentSize', name);
34
39
  return settings && supports.includes('contentSize');
35
40
  }
36
41
 
37
42
  function useHasWideSize(name) {
38
43
  const supports = getSupportedGlobalStylesPanels(name);
39
- const [settings] = useSetting('layout.wideSize', name);
44
+ const [settings] = useGlobalSetting('layout.wideSize', name);
40
45
  return settings && supports.includes('wideSize');
41
46
  }
42
47
 
43
48
  function useHasPadding(name) {
44
49
  const supports = getSupportedGlobalStylesPanels(name);
45
- const [settings] = useSetting('spacing.padding', name);
50
+ const [settings] = useGlobalSetting('spacing.padding', name);
46
51
  return settings && supports.includes('padding');
47
52
  }
48
53
 
49
54
  function useHasMargin(name) {
50
55
  const supports = getSupportedGlobalStylesPanels(name);
51
- const [settings] = useSetting('spacing.margin', name);
56
+ const [settings] = useGlobalSetting('spacing.margin', name);
52
57
  return settings && supports.includes('margin');
53
58
  }
54
59
 
55
60
  function useHasGap(name) {
56
61
  const supports = getSupportedGlobalStylesPanels(name);
57
- const [settings] = useSetting('spacing.blockGap', name);
62
+ const [settings] = useGlobalSetting('spacing.blockGap', name);
58
63
  return settings && supports.includes('blockGap');
59
64
  }
60
65
 
61
66
  function useHasMinHeight(name) {
62
67
  const supports = getSupportedGlobalStylesPanels(name);
63
- const [settings] = useSetting('dimensions.minHeight', name);
68
+ const [settings] = useGlobalSetting('dimensions.minHeight', name);
64
69
  return settings && supports.includes('minHeight');
65
70
  }
66
71
 
67
72
  function useHasSpacingPresets() {
68
- const [settings] = useSetting('spacing.spacingSizes');
69
- return settings && settings.length > 0;
73
+ var _ref, _ref2;
74
+
75
+ const [settings] = useGlobalSetting('spacing.spacingSizes');
76
+ const {
77
+ custom,
78
+ theme,
79
+ default: defaultPresets
80
+ } = settings || {};
81
+ const presets = (_ref = (_ref2 = custom !== null && custom !== void 0 ? custom : theme) !== null && _ref2 !== void 0 ? _ref2 : defaultPresets) !== null && _ref !== void 0 ? _ref : [];
82
+ return settings && presets.length > 0;
70
83
  }
71
84
 
72
85
  function filterValuesBySides(values, sides) {
@@ -129,8 +142,8 @@ function splitGapValue(value) {
129
142
 
130
143
 
131
144
  function useContentSizeProps(name) {
132
- const [contentSizeValue, setContentSizeValue] = useSetting('layout.contentSize', name);
133
- const [userSetContentSizeValue] = useSetting('layout.contentSize', name, 'user');
145
+ const [contentSizeValue, setContentSizeValue] = useGlobalSetting('layout.contentSize', name);
146
+ const [userSetContentSizeValue] = useGlobalSetting('layout.contentSize', name, 'user');
134
147
 
135
148
  const hasUserSetContentSizeValue = () => !!userSetContentSizeValue;
136
149
 
@@ -146,8 +159,8 @@ function useContentSizeProps(name) {
146
159
 
147
160
 
148
161
  function useWideSizeProps(name) {
149
- const [wideSizeValue, setWideSizeValue] = useSetting('layout.wideSize', name);
150
- const [userSetWideSizeValue] = useSetting('layout.wideSize', name, 'user');
162
+ const [wideSizeValue, setWideSizeValue] = useGlobalSetting('layout.wideSize', name);
163
+ const [userSetWideSizeValue] = useGlobalSetting('layout.wideSize', name, 'user');
151
164
 
152
165
  const hasUserSetWideSizeValue = () => !!userSetWideSizeValue;
153
166
 
@@ -163,8 +176,9 @@ function useWideSizeProps(name) {
163
176
 
164
177
 
165
178
  function usePaddingProps(name) {
166
- let variationPath = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
167
- const [rawPadding, setRawPadding] = useStyle(variationPath + 'spacing.padding', name);
179
+ let variation = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
180
+ const prefix = variation ? `variations.${variation}.` : '';
181
+ const [rawPadding, setRawPadding] = useGlobalStyle(prefix + 'spacing.padding', name);
168
182
  const paddingValues = splitStyleValue(rawPadding);
169
183
  const paddingSides = useCustomSides(name, 'padding');
170
184
  const isAxialPadding = paddingSides && paddingSides.some(side => AXIAL_SIDES.includes(side));
@@ -176,7 +190,7 @@ function usePaddingProps(name) {
176
190
 
177
191
  const resetPaddingValue = () => setPaddingValues({});
178
192
 
179
- const [userSetPaddingValue] = useStyle(variationPath + 'spacing.padding', name, 'user'); // The `hasPaddingValue` check does not need a parsed value, as `userSetPaddingValue` will be `undefined` if not set.
193
+ const [userSetPaddingValue] = useGlobalStyle(prefix + 'spacing.padding', name, 'user'); // The `hasPaddingValue` check does not need a parsed value, as `userSetPaddingValue` will be `undefined` if not set.
180
194
 
181
195
  const hasPaddingValue = () => !!userSetPaddingValue;
182
196
 
@@ -192,8 +206,9 @@ function usePaddingProps(name) {
192
206
 
193
207
 
194
208
  function useMarginProps(name) {
195
- let variationPath = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
196
- const [rawMargin, setRawMargin] = useStyle(variationPath + 'spacing.margin', name);
209
+ let variation = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
210
+ const prefix = variation ? `variations.${variation}.` : '';
211
+ const [rawMargin, setRawMargin] = useGlobalStyle(prefix + 'spacing.margin', name);
197
212
  const marginValues = splitStyleValue(rawMargin);
198
213
  const marginSides = useCustomSides(name, 'margin');
199
214
  const isAxialMargin = marginSides && marginSides.some(side => AXIAL_SIDES.includes(side));
@@ -219,15 +234,16 @@ function useMarginProps(name) {
219
234
 
220
235
 
221
236
  function useBlockGapProps(name) {
222
- let variationPath = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
223
- const [gapValue, setGapValue] = useStyle(variationPath + 'spacing.blockGap', name);
237
+ let variation = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
238
+ const prefix = variation ? `variations.${variation}.` : '';
239
+ const [gapValue, setGapValue] = useGlobalStyle(prefix + 'spacing.blockGap', name);
224
240
  const gapValues = splitGapValue(gapValue);
225
241
  const gapSides = useCustomSides(name, 'blockGap');
226
242
  const isAxialGap = gapSides && gapSides.some(side => AXIAL_SIDES.includes(side));
227
243
 
228
244
  const resetGapValue = () => setGapValue(undefined);
229
245
 
230
- const [userSetGapValue] = useStyle(variationPath + 'spacing.blockGap', name, 'user');
246
+ const [userSetGapValue] = useGlobalStyle(prefix + 'spacing.blockGap', name, 'user');
231
247
 
232
248
  const hasGapValue = () => !!userSetGapValue;
233
249
 
@@ -261,8 +277,9 @@ function useBlockGapProps(name) {
261
277
 
262
278
 
263
279
  function useMinHeightProps(name) {
264
- let variationPath = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
265
- const [minHeightValue, setMinHeightValue] = useStyle(variationPath + 'dimensions.minHeight', name);
280
+ let variation = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
281
+ const prefix = variation ? `variations.${variation}.` : '';
282
+ const [minHeightValue, setMinHeightValue] = useGlobalStyle(prefix + 'dimensions.minHeight', name);
266
283
 
267
284
  const resetMinHeightValue = () => setMinHeightValue(undefined);
268
285
 
@@ -276,11 +293,11 @@ function useMinHeightProps(name) {
276
293
  };
277
294
  }
278
295
 
279
- export default function DimensionsPanel(_ref) {
296
+ export default function DimensionsPanel(_ref3) {
280
297
  let {
281
298
  name,
282
- variationPath = ''
283
- } = _ref;
299
+ variation = ''
300
+ } = _ref3;
284
301
  const showContentSizeControl = useHasContentSize(name);
285
302
  const showWideSizeControl = useHasWideSize(name);
286
303
  const showPaddingControl = useHasPadding(name);
@@ -289,7 +306,7 @@ export default function DimensionsPanel(_ref) {
289
306
  const showMinHeightControl = useHasMinHeight(name);
290
307
  const showSpacingPresetsControl = useHasSpacingPresets();
291
308
  const units = useCustomUnits({
292
- availableUnits: useSetting('spacing.units', name)[0] || ['%', 'px', 'em', 'rem', 'vw']
309
+ availableUnits: useGlobalSetting('spacing.units', name)[0] || ['%', 'px', 'em', 'rem', 'vw']
293
310
  }); // Props for managing `layout.contentSize`.
294
311
 
295
312
  const {
@@ -313,7 +330,7 @@ export default function DimensionsPanel(_ref) {
313
330
  setPaddingValues,
314
331
  resetPaddingValue,
315
332
  hasPaddingValue
316
- } = usePaddingProps(name, variationPath); // Props for managing `spacing.margin`.
333
+ } = usePaddingProps(name, variation); // Props for managing `spacing.margin`.
317
334
 
318
335
  const {
319
336
  marginValues,
@@ -322,7 +339,7 @@ export default function DimensionsPanel(_ref) {
322
339
  setMarginValues,
323
340
  resetMarginValue,
324
341
  hasMarginValue
325
- } = useMarginProps(name, variationPath); // Props for managing `spacing.blockGap`.
342
+ } = useMarginProps(name, variation); // Props for managing `spacing.blockGap`.
326
343
 
327
344
  const {
328
345
  gapValue,
@@ -333,14 +350,14 @@ export default function DimensionsPanel(_ref) {
333
350
  setGapValues,
334
351
  resetGapValue,
335
352
  hasGapValue
336
- } = useBlockGapProps(name, variationPath); // Props for managing `dimensions.minHeight`.
353
+ } = useBlockGapProps(name, variation); // Props for managing `dimensions.minHeight`.
337
354
 
338
355
  const {
339
356
  minHeightValue,
340
357
  setMinHeightValue,
341
358
  resetMinHeightValue,
342
359
  hasMinHeightValue
343
- } = useMinHeightProps(name, variationPath);
360
+ } = useMinHeightProps(name, variation);
344
361
 
345
362
  const resetAll = () => {
346
363
  resetPaddingValue();