@wordpress/block-editor 11.2.0 → 11.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (675) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/README.md +28 -4
  3. package/build/components/alignment-control/ui.js +1 -1
  4. package/build/components/alignment-control/ui.js.map +1 -1
  5. package/build/components/autocomplete/index.js +2 -7
  6. package/build/components/autocomplete/index.js.map +1 -1
  7. package/build/components/block-actions/index.js +7 -2
  8. package/build/components/block-actions/index.js.map +1 -1
  9. package/build/components/block-alignment-matrix-control/index.js +2 -2
  10. package/build/components/block-alignment-matrix-control/index.js.map +1 -1
  11. package/build/components/block-card/index.js +2 -4
  12. package/build/components/block-card/index.js.map +1 -1
  13. package/build/components/block-edit/index.js +8 -0
  14. package/build/components/block-edit/index.js.map +1 -1
  15. package/build/components/block-inspector/index.js +15 -14
  16. package/build/components/block-inspector/index.js.map +1 -1
  17. package/build/components/block-list/use-in-between-inserter.js +5 -0
  18. package/build/components/block-list/use-in-between-inserter.js.map +1 -1
  19. package/build/components/block-lock/modal.js +0 -1
  20. package/build/components/block-lock/modal.js.map +1 -1
  21. package/build/components/block-mover/mover-description.js +2 -2
  22. package/build/components/block-mover/mover-description.js.map +1 -1
  23. package/build/components/block-navigation/dropdown.js +3 -1
  24. package/build/components/block-navigation/dropdown.js.map +1 -1
  25. package/build/components/block-pattern-setup/index.js +1 -1
  26. package/build/components/block-pattern-setup/index.js.map +1 -1
  27. package/build/components/block-pattern-setup/use-patterns-setup.js +2 -2
  28. package/build/components/block-pattern-setup/use-patterns-setup.js.map +1 -1
  29. package/build/components/block-patterns-list/index.js +31 -3
  30. package/build/components/block-patterns-list/index.js.map +1 -1
  31. package/build/components/block-preview/auto.js +9 -11
  32. package/build/components/block-preview/auto.js.map +1 -1
  33. package/build/components/block-preview/index.js +32 -8
  34. package/build/components/block-preview/index.js.map +1 -1
  35. package/build/components/block-selection-clearer/index.js +1 -1
  36. package/build/components/block-selection-clearer/index.js.map +1 -1
  37. package/build/components/block-settings/container.native.js +7 -33
  38. package/build/components/block-settings/container.native.js.map +1 -1
  39. package/build/components/block-settings-menu/block-settings-dropdown.js +12 -6
  40. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  41. package/build/components/block-settings-menu-controls/index.js +2 -8
  42. package/build/components/block-settings-menu-controls/index.js.map +1 -1
  43. package/build/components/block-switcher/utils.js +1 -1
  44. package/build/components/block-switcher/utils.js.map +1 -1
  45. package/build/components/block-tools/selected-block-popover.js +55 -47
  46. package/build/components/block-tools/selected-block-popover.js.map +1 -1
  47. package/build/components/block-vertical-alignment-control/icons.js +15 -1
  48. package/build/components/block-vertical-alignment-control/icons.js.map +1 -1
  49. package/build/components/block-vertical-alignment-control/ui.js +9 -4
  50. package/build/components/block-vertical-alignment-control/ui.js.map +1 -1
  51. package/build/components/color-style-selector/index.js +3 -1
  52. package/build/components/color-style-selector/index.js.map +1 -1
  53. package/build/components/date-format-picker/index.js +3 -4
  54. package/build/components/date-format-picker/index.js.map +1 -1
  55. package/build/components/font-family/index.js +1 -7
  56. package/build/components/font-family/index.js.map +1 -1
  57. package/build/components/font-sizes/fluid-utils.js +1 -1
  58. package/build/components/font-sizes/fluid-utils.js.map +1 -1
  59. package/build/components/font-sizes/utils.js +1 -1
  60. package/build/components/font-sizes/utils.js.map +1 -1
  61. package/build/components/global-styles/context.js +22 -0
  62. package/build/components/global-styles/context.js.map +1 -0
  63. package/build/components/global-styles/hooks.js +142 -0
  64. package/build/components/global-styles/hooks.js.map +1 -0
  65. package/build/components/global-styles/index.js +42 -0
  66. package/build/components/global-styles/index.js.map +1 -0
  67. package/build/components/global-styles/typography-utils.js +92 -0
  68. package/build/components/global-styles/typography-utils.js.map +1 -0
  69. package/build/components/global-styles/use-global-styles-output.js +974 -0
  70. package/build/components/global-styles/use-global-styles-output.js.map +1 -0
  71. package/build/components/global-styles/utils.js +340 -0
  72. package/build/components/global-styles/utils.js.map +1 -0
  73. package/build/components/height-control/index.js +13 -1
  74. package/build/components/height-control/index.js.map +1 -1
  75. package/build/components/iframe/index.js +5 -3
  76. package/build/components/iframe/index.js.map +1 -1
  77. package/build/components/image-editor/constants.js +1 -1
  78. package/build/components/image-editor/constants.js.map +1 -1
  79. package/build/components/image-editor/context.js +1 -2
  80. package/build/components/image-editor/context.js.map +1 -1
  81. package/build/components/image-editor/cropper.js +3 -1
  82. package/build/components/image-editor/cropper.js.map +1 -1
  83. package/build/components/image-editor/index.js +13 -9
  84. package/build/components/image-editor/index.js.map +1 -1
  85. package/build/components/image-editor/use-transform-image.js +11 -35
  86. package/build/components/image-editor/use-transform-image.js.map +1 -1
  87. package/build/components/image-size-control/index.js +1 -7
  88. package/build/components/image-size-control/index.js.map +1 -1
  89. package/build/components/index.js +8 -24
  90. package/build/components/index.js.map +1 -1
  91. package/build/components/inner-blocks/index.js +22 -32
  92. package/build/components/inner-blocks/index.js.map +1 -1
  93. package/build/components/inner-blocks/index.native.js +8 -23
  94. package/build/components/inner-blocks/index.native.js.map +1 -1
  95. package/build/components/inner-blocks/use-block-context.js +53 -0
  96. package/build/components/inner-blocks/use-block-context.js.map +1 -0
  97. package/build/components/inserter/block-patterns-explorer/explorer.js +0 -1
  98. package/build/components/inserter/block-patterns-explorer/explorer.js.map +1 -1
  99. package/build/components/inserter/block-patterns-tab.js +9 -2
  100. package/build/components/inserter/block-patterns-tab.js.map +1 -1
  101. package/build/components/inserter/block-types-tab.js +2 -2
  102. package/build/components/inserter/block-types-tab.js.map +1 -1
  103. package/build/components/inserter/hooks/use-patterns-state.js +1 -7
  104. package/build/components/inserter/hooks/use-patterns-state.js.map +1 -1
  105. package/build/components/inserter/index.js +5 -4
  106. package/build/components/inserter/index.js.map +1 -1
  107. package/build/components/inserter/media-tab/hooks.js +142 -56
  108. package/build/components/inserter/media-tab/hooks.js.map +1 -1
  109. package/build/components/inserter/media-tab/media-list.js +74 -21
  110. package/build/components/inserter/media-tab/media-list.js.map +1 -1
  111. package/build/components/inserter/media-tab/media-panel.js +11 -13
  112. package/build/components/inserter/media-tab/media-panel.js.map +1 -1
  113. package/build/components/inserter/media-tab/media-tab.js +6 -3
  114. package/build/components/inserter/media-tab/media-tab.js.map +1 -1
  115. package/build/components/inserter/media-tab/utils.js +26 -15
  116. package/build/components/inserter/media-tab/utils.js.map +1 -1
  117. package/build/components/inserter/menu.js +4 -0
  118. package/build/components/inserter/menu.js.map +1 -1
  119. package/build/components/inserter/preview-panel.js +5 -3
  120. package/build/components/inserter/preview-panel.js.map +1 -1
  121. package/build/components/inserter/search-results.js +2 -7
  122. package/build/components/inserter/search-results.js.map +1 -1
  123. package/build/components/inserter-list-item/index.js +1 -9
  124. package/build/components/inserter-list-item/index.js.map +1 -1
  125. package/build/components/inspector-controls/fill.js +15 -2
  126. package/build/components/inspector-controls/fill.js.map +1 -1
  127. package/build/components/inspector-controls/fill.native.js +14 -1
  128. package/build/components/inspector-controls/fill.native.js.map +1 -1
  129. package/build/components/inspector-controls/groups.js +4 -0
  130. package/build/components/inspector-controls/groups.js.map +1 -1
  131. package/build/components/inspector-controls/index.js +2 -2
  132. package/build/components/inspector-controls/index.js.map +1 -1
  133. package/build/components/inspector-controls/slot.js +14 -1
  134. package/build/components/inspector-controls/slot.js.map +1 -1
  135. package/build/components/inspector-controls/slot.native.js +14 -1
  136. package/build/components/inspector-controls/slot.native.js.map +1 -1
  137. package/build/components/inspector-controls-tabs/advanced-controls-panel.js +1 -1
  138. package/build/components/inspector-controls-tabs/advanced-controls-panel.js.map +1 -1
  139. package/build/components/inspector-controls-tabs/index.js +2 -2
  140. package/build/components/inspector-controls-tabs/index.js.map +1 -1
  141. package/build/components/inspector-controls-tabs/position-controls-panel.js +1 -1
  142. package/build/components/inspector-controls-tabs/position-controls-panel.js.map +1 -1
  143. package/build/components/inspector-controls-tabs/styles-tab.js +6 -4
  144. package/build/components/inspector-controls-tabs/styles-tab.js.map +1 -1
  145. package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js +17 -12
  146. package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -1
  147. package/build/components/justify-content-control/ui.js +8 -1
  148. package/build/components/justify-content-control/ui.js.map +1 -1
  149. package/build/components/link-control/index.js +45 -17
  150. package/build/components/link-control/index.js.map +1 -1
  151. package/build/components/list-view/block.js +1 -1
  152. package/build/components/list-view/block.js.map +1 -1
  153. package/build/components/list-view/use-list-view-drop-zone.js +1 -1
  154. package/build/components/list-view/use-list-view-drop-zone.js.map +1 -1
  155. package/build/components/media-upload/index.native.js +4 -1
  156. package/build/components/media-upload/index.native.js.map +1 -1
  157. package/build/components/off-canvas-editor/appender.js +50 -3
  158. package/build/components/off-canvas-editor/appender.js.map +1 -1
  159. package/build/components/off-canvas-editor/block-contents.js +3 -1
  160. package/build/components/off-canvas-editor/block-contents.js.map +1 -1
  161. package/build/components/off-canvas-editor/block-select-button.js +10 -4
  162. package/build/components/off-canvas-editor/block-select-button.js.map +1 -1
  163. package/build/components/off-canvas-editor/block.js +6 -27
  164. package/build/components/off-canvas-editor/block.js.map +1 -1
  165. package/build/components/off-canvas-editor/branch.js +25 -10
  166. package/build/components/off-canvas-editor/branch.js.map +1 -1
  167. package/build/components/off-canvas-editor/index.js +27 -20
  168. package/build/components/off-canvas-editor/index.js.map +1 -1
  169. package/build/components/off-canvas-editor/link-ui.js +2 -2
  170. package/build/components/off-canvas-editor/link-ui.js.map +1 -1
  171. package/build/components/off-canvas-editor/use-list-view-drop-zone.js +1 -1
  172. package/build/components/off-canvas-editor/use-list-view-drop-zone.js.map +1 -1
  173. package/build/components/provider/index.js +21 -9
  174. package/build/components/provider/index.js.map +1 -1
  175. package/build/components/provider/index.native.js +5 -6
  176. package/build/components/provider/index.native.js.map +1 -1
  177. package/build/components/rich-text/use-before-input-rules.js +11 -3
  178. package/build/components/rich-text/use-before-input-rules.js.map +1 -1
  179. package/build/components/rich-text/utils.js +1 -1
  180. package/build/components/rich-text/utils.js.map +1 -1
  181. package/build/components/spacing-sizes-control/utils.js +2 -8
  182. package/build/components/spacing-sizes-control/utils.js.map +1 -1
  183. package/build/components/tool-selector/index.js +3 -1
  184. package/build/components/tool-selector/index.js.map +1 -1
  185. package/build/components/url-popover/image-url-input-ui.js +7 -8
  186. package/build/components/url-popover/image-url-input-ui.js.map +1 -1
  187. package/build/components/use-block-display-information/index.js +1 -1
  188. package/build/components/use-block-display-information/index.js.map +1 -1
  189. package/build/experiments.js +45 -0
  190. package/build/experiments.js.map +1 -0
  191. package/build/experiments.native.js +40 -0
  192. package/build/experiments.native.js.map +1 -0
  193. package/build/hooks/anchor.js +2 -1
  194. package/build/hooks/anchor.js.map +1 -1
  195. package/build/hooks/border.js +1 -1
  196. package/build/hooks/border.js.map +1 -1
  197. package/build/hooks/child-layout.js +5 -1
  198. package/build/hooks/child-layout.js.map +1 -1
  199. package/build/hooks/color-panel.js +1 -1
  200. package/build/hooks/color-panel.js.map +1 -1
  201. package/build/hooks/color.js +3 -3
  202. package/build/hooks/color.js.map +1 -1
  203. package/build/hooks/custom-class-name.js +2 -1
  204. package/build/hooks/custom-class-name.js.map +1 -1
  205. package/build/hooks/dimensions.js +7 -5
  206. package/build/hooks/dimensions.js.map +1 -1
  207. package/build/hooks/margin.js +1 -0
  208. package/build/hooks/margin.js.map +1 -1
  209. package/build/hooks/padding.js +1 -0
  210. package/build/hooks/padding.js.map +1 -1
  211. package/build/hooks/position.js +39 -17
  212. package/build/hooks/position.js.map +1 -1
  213. package/build/hooks/typography.js +1 -1
  214. package/build/hooks/typography.js.map +1 -1
  215. package/build/hooks/use-color-props.js +3 -3
  216. package/build/hooks/use-color-props.js.map +1 -1
  217. package/build/hooks/utils.js +69 -3
  218. package/build/hooks/utils.js.map +1 -1
  219. package/build/index.js +10 -1
  220. package/build/index.js.map +1 -1
  221. package/build/layouts/constrained.js +3 -0
  222. package/build/layouts/constrained.js.map +1 -1
  223. package/build/layouts/flex.js +59 -9
  224. package/build/layouts/flex.js.map +1 -1
  225. package/build/layouts/flow.js +0 -18
  226. package/build/layouts/flow.js.map +1 -1
  227. package/build/store/actions.js +3 -30
  228. package/build/store/actions.js.map +1 -1
  229. package/build/store/defaults.js +5 -2
  230. package/build/store/defaults.js.map +1 -1
  231. package/build/store/index.js +11 -2
  232. package/build/store/index.js.map +1 -1
  233. package/build/store/private-actions.js +78 -0
  234. package/build/store/private-actions.js.map +1 -0
  235. package/build/store/private-selectors.js +32 -0
  236. package/build/store/private-selectors.js.map +1 -0
  237. package/build/store/reducer.js +1 -1
  238. package/build/store/reducer.js.map +1 -1
  239. package/build/store/selectors.js +60 -48
  240. package/build/store/selectors.js.map +1 -1
  241. package/build/utils/block-variation-transforms.js +1 -1
  242. package/build/utils/block-variation-transforms.js.map +1 -1
  243. package/build/utils/parse-css-unit-to-px.js +1 -1
  244. package/build/utils/parse-css-unit-to-px.js.map +1 -1
  245. package/build/utils/transform-styles/index.js +1 -7
  246. package/build/utils/transform-styles/index.js.map +1 -1
  247. package/build-module/components/alignment-control/ui.js +1 -1
  248. package/build-module/components/alignment-control/ui.js.map +1 -1
  249. package/build-module/components/autocomplete/index.js +2 -6
  250. package/build-module/components/autocomplete/index.js.map +1 -1
  251. package/build-module/components/block-actions/index.js +7 -2
  252. package/build-module/components/block-actions/index.js.map +1 -1
  253. package/build-module/components/block-alignment-matrix-control/index.js +2 -2
  254. package/build-module/components/block-alignment-matrix-control/index.js.map +1 -1
  255. package/build-module/components/block-card/index.js +2 -4
  256. package/build-module/components/block-card/index.js.map +1 -1
  257. package/build-module/components/block-edit/index.js +7 -0
  258. package/build-module/components/block-edit/index.js.map +1 -1
  259. package/build-module/components/block-inspector/index.js +15 -14
  260. package/build-module/components/block-inspector/index.js.map +1 -1
  261. package/build-module/components/block-list/use-in-between-inserter.js +5 -0
  262. package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
  263. package/build-module/components/block-lock/modal.js +0 -1
  264. package/build-module/components/block-lock/modal.js.map +1 -1
  265. package/build-module/components/block-mover/mover-description.js +2 -2
  266. package/build-module/components/block-mover/mover-description.js.map +1 -1
  267. package/build-module/components/block-navigation/dropdown.js +3 -1
  268. package/build-module/components/block-navigation/dropdown.js.map +1 -1
  269. package/build-module/components/block-pattern-setup/index.js +1 -1
  270. package/build-module/components/block-pattern-setup/index.js.map +1 -1
  271. package/build-module/components/block-pattern-setup/use-patterns-setup.js +2 -2
  272. package/build-module/components/block-pattern-setup/use-patterns-setup.js.map +1 -1
  273. package/build-module/components/block-patterns-list/index.js +32 -3
  274. package/build-module/components/block-patterns-list/index.js.map +1 -1
  275. package/build-module/components/block-preview/auto.js +9 -11
  276. package/build-module/components/block-preview/auto.js.map +1 -1
  277. package/build-module/components/block-preview/index.js +31 -8
  278. package/build-module/components/block-preview/index.js.map +1 -1
  279. package/build-module/components/block-selection-clearer/index.js +1 -1
  280. package/build-module/components/block-selection-clearer/index.js.map +1 -1
  281. package/build-module/components/block-settings/container.native.js +6 -30
  282. package/build-module/components/block-settings/container.native.js.map +1 -1
  283. package/build-module/components/block-settings-menu/block-settings-dropdown.js +12 -6
  284. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  285. package/build-module/components/block-settings-menu-controls/index.js +2 -7
  286. package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
  287. package/build-module/components/block-switcher/utils.js +1 -1
  288. package/build-module/components/block-switcher/utils.js.map +1 -1
  289. package/build-module/components/block-tools/selected-block-popover.js +55 -48
  290. package/build-module/components/block-tools/selected-block-popover.js.map +1 -1
  291. package/build-module/components/block-vertical-alignment-control/icons.js +12 -0
  292. package/build-module/components/block-vertical-alignment-control/icons.js.map +1 -1
  293. package/build-module/components/block-vertical-alignment-control/ui.js +10 -5
  294. package/build-module/components/block-vertical-alignment-control/ui.js.map +1 -1
  295. package/build-module/components/color-style-selector/index.js +3 -1
  296. package/build-module/components/color-style-selector/index.js.map +1 -1
  297. package/build-module/components/date-format-picker/index.js +4 -5
  298. package/build-module/components/date-format-picker/index.js.map +1 -1
  299. package/build-module/components/font-family/index.js +1 -6
  300. package/build-module/components/font-family/index.js.map +1 -1
  301. package/build-module/components/font-sizes/fluid-utils.js +1 -1
  302. package/build-module/components/font-sizes/fluid-utils.js.map +1 -1
  303. package/build-module/components/font-sizes/utils.js +1 -1
  304. package/build-module/components/font-sizes/utils.js.map +1 -1
  305. package/build-module/components/global-styles/context.js +12 -0
  306. package/build-module/components/global-styles/context.js.map +1 -0
  307. package/build-module/components/global-styles/hooks.js +121 -0
  308. package/build-module/components/global-styles/hooks.js.map +1 -0
  309. package/build-module/components/global-styles/index.js +4 -0
  310. package/build-module/components/global-styles/index.js.map +1 -0
  311. package/build-module/components/global-styles/typography-utils.js +84 -0
  312. package/build-module/components/global-styles/typography-utils.js.map +1 -0
  313. package/build-module/components/global-styles/use-global-styles-output.js +930 -0
  314. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -0
  315. package/build-module/components/global-styles/utils.js +321 -0
  316. package/build-module/components/global-styles/utils.js.map +1 -0
  317. package/build-module/components/height-control/index.js +14 -1
  318. package/build-module/components/height-control/index.js.map +1 -1
  319. package/build-module/components/iframe/index.js +6 -4
  320. package/build-module/components/iframe/index.js.map +1 -1
  321. package/build-module/components/image-editor/constants.js +1 -1
  322. package/build-module/components/image-editor/constants.js.map +1 -1
  323. package/build-module/components/image-editor/context.js +1 -2
  324. package/build-module/components/image-editor/context.js.map +1 -1
  325. package/build-module/components/image-editor/cropper.js +3 -1
  326. package/build-module/components/image-editor/cropper.js.map +1 -1
  327. package/build-module/components/image-editor/index.js +13 -3
  328. package/build-module/components/image-editor/index.js.map +1 -1
  329. package/build-module/components/image-editor/use-transform-image.js +12 -37
  330. package/build-module/components/image-editor/use-transform-image.js.map +1 -1
  331. package/build-module/components/image-size-control/index.js +1 -6
  332. package/build-module/components/image-size-control/index.js.map +1 -1
  333. package/build-module/components/index.js +2 -3
  334. package/build-module/components/index.js.map +1 -1
  335. package/build-module/components/inner-blocks/index.js +21 -32
  336. package/build-module/components/inner-blocks/index.js.map +1 -1
  337. package/build-module/components/inner-blocks/index.native.js +9 -22
  338. package/build-module/components/inner-blocks/index.native.js.map +1 -1
  339. package/build-module/components/inner-blocks/use-block-context.js +43 -0
  340. package/build-module/components/inner-blocks/use-block-context.js.map +1 -0
  341. package/build-module/components/inserter/block-patterns-explorer/explorer.js +0 -1
  342. package/build-module/components/inserter/block-patterns-explorer/explorer.js.map +1 -1
  343. package/build-module/components/inserter/block-patterns-tab.js +9 -2
  344. package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
  345. package/build-module/components/inserter/block-types-tab.js +3 -3
  346. package/build-module/components/inserter/block-types-tab.js.map +1 -1
  347. package/build-module/components/inserter/hooks/use-patterns-state.js +1 -6
  348. package/build-module/components/inserter/hooks/use-patterns-state.js.map +1 -1
  349. package/build-module/components/inserter/index.js +5 -4
  350. package/build-module/components/inserter/index.js.map +1 -1
  351. package/build-module/components/inserter/media-tab/hooks.js +145 -56
  352. package/build-module/components/inserter/media-tab/hooks.js.map +1 -1
  353. package/build-module/components/inserter/media-tab/media-list.js +74 -24
  354. package/build-module/components/inserter/media-tab/media-list.js.map +1 -1
  355. package/build-module/components/inserter/media-tab/media-panel.js +14 -14
  356. package/build-module/components/inserter/media-tab/media-panel.js.map +1 -1
  357. package/build-module/components/inserter/media-tab/media-tab.js +7 -4
  358. package/build-module/components/inserter/media-tab/media-tab.js.map +1 -1
  359. package/build-module/components/inserter/media-tab/utils.js +27 -15
  360. package/build-module/components/inserter/media-tab/utils.js.map +1 -1
  361. package/build-module/components/inserter/menu.js +4 -0
  362. package/build-module/components/inserter/menu.js.map +1 -1
  363. package/build-module/components/inserter/preview-panel.js +5 -3
  364. package/build-module/components/inserter/preview-panel.js.map +1 -1
  365. package/build-module/components/inserter/search-results.js +2 -6
  366. package/build-module/components/inserter/search-results.js.map +1 -1
  367. package/build-module/components/inserter-list-item/index.js +1 -9
  368. package/build-module/components/inserter-list-item/index.js.map +1 -1
  369. package/build-module/components/inspector-controls/fill.js +14 -2
  370. package/build-module/components/inspector-controls/fill.js.map +1 -1
  371. package/build-module/components/inspector-controls/fill.native.js +13 -1
  372. package/build-module/components/inspector-controls/fill.native.js.map +1 -1
  373. package/build-module/components/inspector-controls/groups.js +4 -0
  374. package/build-module/components/inspector-controls/groups.js.map +1 -1
  375. package/build-module/components/inspector-controls/index.js +2 -2
  376. package/build-module/components/inspector-controls/index.js.map +1 -1
  377. package/build-module/components/inspector-controls/slot.js +13 -1
  378. package/build-module/components/inspector-controls/slot.js.map +1 -1
  379. package/build-module/components/inspector-controls/slot.native.js +13 -1
  380. package/build-module/components/inspector-controls/slot.native.js.map +1 -1
  381. package/build-module/components/inspector-controls-tabs/advanced-controls-panel.js +1 -1
  382. package/build-module/components/inspector-controls-tabs/advanced-controls-panel.js.map +1 -1
  383. package/build-module/components/inspector-controls-tabs/index.js +2 -2
  384. package/build-module/components/inspector-controls-tabs/index.js.map +1 -1
  385. package/build-module/components/inspector-controls-tabs/position-controls-panel.js +1 -1
  386. package/build-module/components/inspector-controls-tabs/position-controls-panel.js.map +1 -1
  387. package/build-module/components/inspector-controls-tabs/styles-tab.js +6 -4
  388. package/build-module/components/inspector-controls-tabs/styles-tab.js.map +1 -1
  389. package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js +17 -12
  390. package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -1
  391. package/build-module/components/justify-content-control/ui.js +9 -2
  392. package/build-module/components/justify-content-control/ui.js.map +1 -1
  393. package/build-module/components/link-control/index.js +45 -16
  394. package/build-module/components/link-control/index.js.map +1 -1
  395. package/build-module/components/list-view/block.js +1 -1
  396. package/build-module/components/list-view/block.js.map +1 -1
  397. package/build-module/components/list-view/use-list-view-drop-zone.js +1 -1
  398. package/build-module/components/list-view/use-list-view-drop-zone.js.map +1 -1
  399. package/build-module/components/media-upload/index.native.js +4 -1
  400. package/build-module/components/media-upload/index.native.js.map +1 -1
  401. package/build-module/components/off-canvas-editor/appender.js +47 -4
  402. package/build-module/components/off-canvas-editor/appender.js.map +1 -1
  403. package/build-module/components/off-canvas-editor/block-contents.js +2 -1
  404. package/build-module/components/off-canvas-editor/block-contents.js.map +1 -1
  405. package/build-module/components/off-canvas-editor/block-select-button.js +9 -4
  406. package/build-module/components/off-canvas-editor/block-select-button.js.map +1 -1
  407. package/build-module/components/off-canvas-editor/block.js +6 -25
  408. package/build-module/components/off-canvas-editor/block.js.map +1 -1
  409. package/build-module/components/off-canvas-editor/branch.js +23 -11
  410. package/build-module/components/off-canvas-editor/branch.js.map +1 -1
  411. package/build-module/components/off-canvas-editor/index.js +27 -19
  412. package/build-module/components/off-canvas-editor/index.js.map +1 -1
  413. package/build-module/components/off-canvas-editor/link-ui.js +2 -2
  414. package/build-module/components/off-canvas-editor/link-ui.js.map +1 -1
  415. package/build-module/components/off-canvas-editor/use-list-view-drop-zone.js +1 -1
  416. package/build-module/components/off-canvas-editor/use-list-view-drop-zone.js.map +1 -1
  417. package/build-module/components/provider/index.js +16 -9
  418. package/build-module/components/provider/index.js.map +1 -1
  419. package/build-module/components/provider/index.native.js +4 -4
  420. package/build-module/components/provider/index.native.js.map +1 -1
  421. package/build-module/components/rich-text/use-before-input-rules.js +10 -2
  422. package/build-module/components/rich-text/use-before-input-rules.js.map +1 -1
  423. package/build-module/components/rich-text/utils.js +1 -1
  424. package/build-module/components/rich-text/utils.js.map +1 -1
  425. package/build-module/components/spacing-sizes-control/utils.js +2 -7
  426. package/build-module/components/spacing-sizes-control/utils.js.map +1 -1
  427. package/build-module/components/tool-selector/index.js +3 -1
  428. package/build-module/components/tool-selector/index.js.map +1 -1
  429. package/build-module/components/url-popover/image-url-input-ui.js +8 -8
  430. package/build-module/components/url-popover/image-url-input-ui.js.map +1 -1
  431. package/build-module/components/use-block-display-information/index.js +1 -1
  432. package/build-module/components/use-block-display-information/index.js.map +1 -1
  433. package/build-module/experiments.js +25 -0
  434. package/build-module/experiments.js.map +1 -0
  435. package/build-module/experiments.native.js +23 -0
  436. package/build-module/experiments.native.js.map +1 -0
  437. package/build-module/hooks/anchor.js +2 -1
  438. package/build-module/hooks/anchor.js.map +1 -1
  439. package/build-module/hooks/border.js +1 -1
  440. package/build-module/hooks/border.js.map +1 -1
  441. package/build-module/hooks/child-layout.js +5 -1
  442. package/build-module/hooks/child-layout.js.map +1 -1
  443. package/build-module/hooks/color-panel.js +1 -1
  444. package/build-module/hooks/color-panel.js.map +1 -1
  445. package/build-module/hooks/color.js +3 -3
  446. package/build-module/hooks/color.js.map +1 -1
  447. package/build-module/hooks/custom-class-name.js +2 -1
  448. package/build-module/hooks/custom-class-name.js.map +1 -1
  449. package/build-module/hooks/dimensions.js +6 -5
  450. package/build-module/hooks/dimensions.js.map +1 -1
  451. package/build-module/hooks/margin.js +1 -0
  452. package/build-module/hooks/margin.js.map +1 -1
  453. package/build-module/hooks/padding.js +1 -0
  454. package/build-module/hooks/padding.js.map +1 -1
  455. package/build-module/hooks/position.js +36 -16
  456. package/build-module/hooks/position.js.map +1 -1
  457. package/build-module/hooks/typography.js +1 -1
  458. package/build-module/hooks/typography.js.map +1 -1
  459. package/build-module/hooks/use-color-props.js +3 -3
  460. package/build-module/hooks/use-color-props.js.map +1 -1
  461. package/build-module/hooks/utils.js +70 -4
  462. package/build-module/hooks/utils.js.map +1 -1
  463. package/build-module/index.js +1 -0
  464. package/build-module/index.js.map +1 -1
  465. package/build-module/layouts/constrained.js +3 -0
  466. package/build-module/layouts/constrained.js.map +1 -1
  467. package/build-module/layouts/flex.js +60 -10
  468. package/build-module/layouts/flex.js.map +1 -1
  469. package/build-module/layouts/flow.js +0 -18
  470. package/build-module/layouts/flow.js.map +1 -1
  471. package/build-module/store/actions.js +2 -26
  472. package/build-module/store/actions.js.map +1 -1
  473. package/build-module/store/defaults.js +5 -2
  474. package/build-module/store/defaults.js.map +1 -1
  475. package/build-module/store/index.js +8 -2
  476. package/build-module/store/index.js.map +1 -1
  477. package/build-module/store/private-actions.js +66 -0
  478. package/build-module/store/private-actions.js.map +1 -0
  479. package/build-module/store/private-selectors.js +23 -0
  480. package/build-module/store/private-selectors.js.map +1 -0
  481. package/build-module/store/reducer.js +1 -1
  482. package/build-module/store/reducer.js.map +1 -1
  483. package/build-module/store/selectors.js +48 -37
  484. package/build-module/store/selectors.js.map +1 -1
  485. package/build-module/utils/block-variation-transforms.js +1 -1
  486. package/build-module/utils/block-variation-transforms.js.map +1 -1
  487. package/build-module/utils/parse-css-unit-to-px.js +1 -1
  488. package/build-module/utils/parse-css-unit-to-px.js.map +1 -1
  489. package/build-module/utils/transform-styles/index.js +1 -6
  490. package/build-module/utils/transform-styles/index.js.map +1 -1
  491. package/build-style/content-rtl.css +283 -3
  492. package/build-style/content.css +283 -3
  493. package/build-style/style-rtl.css +105 -221
  494. package/build-style/style.css +105 -221
  495. package/package.json +30 -29
  496. package/src/components/alignment-control/test/__snapshots__/index.js.snap +3 -3
  497. package/src/components/alignment-control/test/index.js +5 -15
  498. package/src/components/alignment-control/ui.js +1 -1
  499. package/src/components/autocomplete/index.js +3 -6
  500. package/src/components/block-actions/index.js +9 -0
  501. package/src/components/block-alignment-control/test/index.js +3 -11
  502. package/src/components/block-alignment-matrix-control/index.js +1 -2
  503. package/src/components/block-card/index.js +1 -4
  504. package/src/components/block-content-overlay/content.scss +4 -4
  505. package/src/components/block-edit/index.js +15 -1
  506. package/src/components/block-icon/content.scss +31 -0
  507. package/src/components/block-inspector/index.js +13 -17
  508. package/src/components/block-list/use-in-between-inserter.js +5 -0
  509. package/src/components/block-lock/modal.js +0 -1
  510. package/src/components/block-mover/mover-description.js +2 -2
  511. package/src/components/block-mover/stories/index.js +3 -3
  512. package/src/components/block-navigation/dropdown.js +1 -1
  513. package/src/components/block-pattern-setup/index.js +1 -4
  514. package/src/components/block-pattern-setup/use-patterns-setup.js +2 -5
  515. package/src/components/block-patterns-list/index.js +29 -3
  516. package/src/components/block-preview/README.md +9 -9
  517. package/src/components/block-preview/auto.js +9 -11
  518. package/src/components/block-preview/content.scss +23 -0
  519. package/src/components/block-preview/index.js +40 -10
  520. package/src/components/block-preview/style.scss +0 -23
  521. package/src/components/block-selection-clearer/index.js +1 -1
  522. package/src/components/block-selection-clearer/test/index.js +6 -6
  523. package/src/components/block-settings/container.native.js +7 -26
  524. package/src/components/block-settings-menu/block-settings-dropdown.js +13 -5
  525. package/src/components/block-settings-menu-controls/index.js +2 -10
  526. package/src/components/block-switcher/test/index.js +43 -44
  527. package/src/components/block-switcher/utils.js +1 -1
  528. package/src/components/block-tools/selected-block-popover.js +77 -80
  529. package/src/components/block-tools/style.scss +0 -1
  530. package/src/components/block-variation-picker/{style.scss → content.scss} +0 -0
  531. package/src/components/block-vertical-alignment-control/icons.js +12 -0
  532. package/src/components/block-vertical-alignment-control/test/index.js +3 -11
  533. package/src/components/block-vertical-alignment-control/ui.js +16 -6
  534. package/src/components/color-style-selector/index.js +1 -1
  535. package/src/components/colors/test/with-colors.js +2 -8
  536. package/src/components/date-format-picker/index.js +23 -24
  537. package/src/components/date-format-picker/style.scss +0 -6
  538. package/src/components/default-block-appender/content.scss +18 -0
  539. package/src/components/default-block-appender/test/index.js +2 -8
  540. package/src/components/font-family/index.js +1 -6
  541. package/src/components/font-sizes/fluid-utils.js +1 -1
  542. package/src/components/font-sizes/utils.js +1 -1
  543. package/src/components/global-styles/README.md +77 -0
  544. package/src/components/global-styles/context.js +15 -0
  545. package/src/components/global-styles/hooks.js +145 -0
  546. package/src/components/global-styles/index.js +7 -0
  547. package/src/components/global-styles/test/typography-utils.js +393 -0
  548. package/src/components/global-styles/test/use-global-styles-output.js +814 -0
  549. package/src/components/global-styles/test/utils.js +206 -0
  550. package/src/components/global-styles/typography-utils.js +87 -0
  551. package/src/components/global-styles/use-global-styles-output.js +1088 -0
  552. package/src/components/global-styles/utils.js +373 -0
  553. package/src/components/height-control/README.md +55 -0
  554. package/src/components/height-control/index.js +13 -1
  555. package/src/components/iframe/index.js +8 -2
  556. package/src/components/image-editor/constants.js +1 -1
  557. package/src/components/image-editor/context.js +5 -9
  558. package/src/components/image-editor/cropper.js +3 -1
  559. package/src/components/image-editor/index.js +13 -4
  560. package/src/components/image-editor/use-transform-image.js +14 -55
  561. package/src/components/image-size-control/index.js +1 -6
  562. package/src/components/index.js +2 -6
  563. package/src/components/inner-blocks/index.js +29 -33
  564. package/src/components/inner-blocks/index.native.js +27 -47
  565. package/src/components/inner-blocks/use-block-context.js +47 -0
  566. package/src/components/inserter/block-patterns-explorer/explorer.js +0 -1
  567. package/src/components/inserter/block-patterns-tab.js +9 -1
  568. package/src/components/inserter/block-types-tab.js +3 -4
  569. package/src/components/inserter/hooks/use-patterns-state.js +1 -6
  570. package/src/components/inserter/index.js +3 -4
  571. package/src/components/inserter/media-tab/hooks.js +167 -65
  572. package/src/components/inserter/media-tab/media-list.js +94 -26
  573. package/src/components/inserter/media-tab/media-panel.js +9 -20
  574. package/src/components/inserter/media-tab/media-tab.js +12 -4
  575. package/src/components/inserter/media-tab/utils.js +20 -10
  576. package/src/components/inserter/menu.js +8 -0
  577. package/src/components/inserter/preview-panel.js +4 -2
  578. package/src/components/inserter/search-results.js +2 -6
  579. package/src/components/inserter/stories/index.js +9 -9
  580. package/src/components/inserter/style.scss +58 -11
  581. package/src/components/inserter-list-item/index.js +0 -7
  582. package/src/components/inspector-controls/README.md +3 -7
  583. package/src/components/inspector-controls/fill.js +15 -1
  584. package/src/components/inspector-controls/fill.native.js +14 -1
  585. package/src/components/inspector-controls/groups.js +3 -0
  586. package/src/components/inspector-controls/index.js +2 -6
  587. package/src/components/inspector-controls/slot.js +14 -1
  588. package/src/components/inspector-controls/slot.native.js +14 -1
  589. package/src/components/inspector-controls-tabs/advanced-controls-panel.js +1 -1
  590. package/src/components/inspector-controls-tabs/index.js +2 -4
  591. package/src/components/inspector-controls-tabs/position-controls-panel.js +1 -1
  592. package/src/components/inspector-controls-tabs/styles-tab.js +5 -7
  593. package/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js +21 -10
  594. package/src/components/justify-content-control/ui.js +9 -0
  595. package/src/components/link-control/index.js +59 -23
  596. package/src/components/link-control/style.scss +7 -24
  597. package/src/components/link-control/test/index.js +134 -5
  598. package/src/components/list-view/block.js +1 -1
  599. package/src/components/list-view/use-list-view-drop-zone.js +1 -1
  600. package/src/components/media-replace-flow/test/index.js +4 -12
  601. package/src/components/media-upload/index.native.js +2 -2
  602. package/src/components/off-canvas-editor/README.md +2 -2
  603. package/src/components/off-canvas-editor/appender.js +93 -37
  604. package/src/components/off-canvas-editor/block-contents.js +2 -1
  605. package/src/components/off-canvas-editor/block-select-button.js +12 -1
  606. package/src/components/off-canvas-editor/block.js +3 -42
  607. package/src/components/off-canvas-editor/branch.js +32 -5
  608. package/src/components/off-canvas-editor/index.js +20 -20
  609. package/src/components/off-canvas-editor/link-ui.js +2 -2
  610. package/src/components/off-canvas-editor/style.scss +5 -1
  611. package/src/components/off-canvas-editor/use-list-view-drop-zone.js +1 -1
  612. package/src/components/provider/index.js +33 -14
  613. package/src/components/provider/index.native.js +4 -3
  614. package/src/components/provider/test/experimental-provider.js +94 -0
  615. package/src/components/provider/test/use-block-sync.js +10 -0
  616. package/src/components/responsive-block-control/test/index.js +1 -5
  617. package/src/components/rich-text/use-before-input-rules.js +10 -2
  618. package/src/components/rich-text/utils.js +1 -1
  619. package/src/components/spacing-sizes-control/utils.js +2 -7
  620. package/src/components/tool-selector/index.js +1 -1
  621. package/src/components/url-input/test/button.js +24 -24
  622. package/src/components/url-popover/image-url-input-ui.js +7 -8
  623. package/src/components/url-popover/style.scss +0 -10
  624. package/src/components/use-block-display-information/index.js +1 -1
  625. package/src/components/warning/{style.scss → content.scss} +0 -0
  626. package/src/components/warning/test/index.js +1 -5
  627. package/src/content.scss +7 -0
  628. package/src/experiments.js +27 -0
  629. package/src/experiments.native.js +25 -0
  630. package/src/hooks/anchor.js +2 -1
  631. package/src/hooks/border.js +1 -1
  632. package/src/hooks/child-layout.js +6 -1
  633. package/src/hooks/color-panel.js +1 -1
  634. package/src/hooks/color.js +3 -3
  635. package/src/hooks/custom-class-name.js +2 -1
  636. package/src/hooks/dimensions.js +6 -6
  637. package/src/hooks/layout.scss +4 -0
  638. package/src/hooks/margin.js +1 -0
  639. package/src/hooks/padding.js +1 -0
  640. package/src/hooks/position.js +56 -36
  641. package/src/hooks/test/align.native.js +1 -1
  642. package/src/hooks/test/utils.js +104 -0
  643. package/src/hooks/typography.js +1 -1
  644. package/src/hooks/use-color-props.js +3 -3
  645. package/src/hooks/utils.js +68 -2
  646. package/src/index.js +1 -0
  647. package/src/layouts/constrained.js +3 -0
  648. package/src/layouts/flex.js +66 -14
  649. package/src/layouts/flow.js +0 -9
  650. package/src/store/actions.js +2 -26
  651. package/src/store/defaults.js +7 -2
  652. package/src/store/index.js +8 -2
  653. package/src/store/private-actions.js +65 -0
  654. package/src/store/private-selectors.js +20 -0
  655. package/src/store/reducer.js +1 -1
  656. package/src/store/selectors.js +103 -62
  657. package/src/store/test/actions.js +0 -18
  658. package/src/store/test/private-actions.js +22 -0
  659. package/src/store/test/private-selectors.js +52 -0
  660. package/src/store/test/selectors.js +52 -54
  661. package/src/style.scss +3 -5
  662. package/src/utils/block-variation-transforms.js +1 -1
  663. package/src/utils/parse-css-unit-to-px.js +3 -1
  664. package/src/utils/test/parse-css-unit-to-px.js +16 -24
  665. package/src/utils/transform-styles/index.js +1 -6
  666. package/build/components/inner-blocks/get-block-context.js +0 -45
  667. package/build/components/inner-blocks/get-block-context.js.map +0 -1
  668. package/build/components/off-canvas-editor/block-edit-button.js +0 -50
  669. package/build/components/off-canvas-editor/block-edit-button.js.map +0 -1
  670. package/build-module/components/inner-blocks/get-block-context.js +0 -37
  671. package/build-module/components/inner-blocks/get-block-context.js.map +0 -1
  672. package/build-module/components/off-canvas-editor/block-edit-button.js +0 -35
  673. package/build-module/components/off-canvas-editor/block-edit-button.js.map +0 -1
  674. package/src/components/inner-blocks/get-block-context.js +0 -39
  675. package/src/components/off-canvas-editor/block-edit-button.js +0 -27
@@ -0,0 +1,974 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getBlockSelectors = void 0;
7
+ exports.getLayoutStyles = getLayoutStyles;
8
+ exports.getNodesWithStyles = exports.getNodesWithSettings = void 0;
9
+ exports.getStylesDeclarations = getStylesDeclarations;
10
+ exports.toStyles = exports.toCustomProperties = void 0;
11
+ exports.toSvgFilters = toSvgFilters;
12
+ exports.useGlobalStylesOutput = useGlobalStylesOutput;
13
+
14
+ var _element = require("@wordpress/element");
15
+
16
+ var _lodash = require("lodash");
17
+
18
+ var _blocks = require("@wordpress/blocks");
19
+
20
+ var _data = require("@wordpress/data");
21
+
22
+ var _styleEngine = require("@wordpress/style-engine");
23
+
24
+ var _utils = require("./utils");
25
+
26
+ var _typographyUtils = require("./typography-utils");
27
+
28
+ var _context = require("./context");
29
+
30
+ var _hooks = require("./hooks");
31
+
32
+ var _components = require("../duotone/components");
33
+
34
+ var _gap = require("../../hooks/gap");
35
+
36
+ var _store = require("../../store");
37
+
38
+ /**
39
+ * External dependencies
40
+ */
41
+
42
+ /**
43
+ * WordPress dependencies
44
+ */
45
+
46
+ /**
47
+ * Internal dependencies
48
+ */
49
+ // List of block support features that can have their related styles
50
+ // generated under their own feature level selector rather than the block's.
51
+ const BLOCK_SUPPORT_FEATURE_LEVEL_SELECTORS = {
52
+ __experimentalBorder: 'border',
53
+ color: 'color',
54
+ spacing: 'spacing',
55
+ typography: 'typography'
56
+ };
57
+
58
+ function compileStyleValue(uncompiledValue) {
59
+ var _uncompiledValue$star;
60
+
61
+ const VARIABLE_REFERENCE_PREFIX = 'var:';
62
+ const VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE = '|';
63
+ const VARIABLE_PATH_SEPARATOR_TOKEN_STYLE = '--';
64
+
65
+ if (uncompiledValue !== null && uncompiledValue !== void 0 && (_uncompiledValue$star = uncompiledValue.startsWith) !== null && _uncompiledValue$star !== void 0 && _uncompiledValue$star.call(uncompiledValue, VARIABLE_REFERENCE_PREFIX)) {
66
+ const variable = uncompiledValue.slice(VARIABLE_REFERENCE_PREFIX.length).split(VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE).join(VARIABLE_PATH_SEPARATOR_TOKEN_STYLE);
67
+ return `var(--wp--${variable})`;
68
+ }
69
+
70
+ return uncompiledValue;
71
+ }
72
+ /**
73
+ * Transform given preset tree into a set of style declarations.
74
+ *
75
+ * @param {Object} blockPresets
76
+ * @param {Object} mergedSettings Merged theme.json settings.
77
+ *
78
+ * @return {Array<Object>} An array of style declarations.
79
+ */
80
+
81
+
82
+ function getPresetsDeclarations() {
83
+ let blockPresets = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
84
+ let mergedSettings = arguments.length > 1 ? arguments[1] : undefined;
85
+ return _utils.PRESET_METADATA.reduce((declarations, _ref) => {
86
+ let {
87
+ path,
88
+ valueKey,
89
+ valueFunc,
90
+ cssVarInfix
91
+ } = _ref;
92
+ const presetByOrigin = (0, _lodash.get)(blockPresets, path, []);
93
+ ['default', 'theme', 'custom'].forEach(origin => {
94
+ if (presetByOrigin[origin]) {
95
+ presetByOrigin[origin].forEach(value => {
96
+ if (valueKey && !valueFunc) {
97
+ declarations.push(`--wp--preset--${cssVarInfix}--${(0, _lodash.kebabCase)(value.slug)}: ${value[valueKey]}`);
98
+ } else if (valueFunc && typeof valueFunc === 'function') {
99
+ declarations.push(`--wp--preset--${cssVarInfix}--${(0, _lodash.kebabCase)(value.slug)}: ${valueFunc(value, mergedSettings)}`);
100
+ }
101
+ });
102
+ }
103
+ });
104
+ return declarations;
105
+ }, []);
106
+ }
107
+ /**
108
+ * Transform given preset tree into a set of preset class declarations.
109
+ *
110
+ * @param {string} blockSelector
111
+ * @param {Object} blockPresets
112
+ * @return {string} CSS declarations for the preset classes.
113
+ */
114
+
115
+
116
+ function getPresetsClasses(blockSelector) {
117
+ let blockPresets = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
118
+ return _utils.PRESET_METADATA.reduce((declarations, _ref2) => {
119
+ let {
120
+ path,
121
+ cssVarInfix,
122
+ classes
123
+ } = _ref2;
124
+
125
+ if (!classes) {
126
+ return declarations;
127
+ }
128
+
129
+ const presetByOrigin = (0, _lodash.get)(blockPresets, path, []);
130
+ ['default', 'theme', 'custom'].forEach(origin => {
131
+ if (presetByOrigin[origin]) {
132
+ presetByOrigin[origin].forEach(_ref3 => {
133
+ let {
134
+ slug
135
+ } = _ref3;
136
+ classes.forEach(_ref4 => {
137
+ let {
138
+ classSuffix,
139
+ propertyName
140
+ } = _ref4;
141
+ const classSelectorToUse = `.has-${(0, _lodash.kebabCase)(slug)}-${classSuffix}`;
142
+ const selectorToUse = blockSelector.split(',') // Selector can be "h1, h2, h3"
143
+ .map(selector => `${selector}${classSelectorToUse}`).join(',');
144
+ const value = `var(--wp--preset--${cssVarInfix}--${(0, _lodash.kebabCase)(slug)})`;
145
+ declarations += `${selectorToUse}{${propertyName}: ${value} !important;}`;
146
+ });
147
+ });
148
+ }
149
+ });
150
+ return declarations;
151
+ }, '');
152
+ }
153
+
154
+ function getPresetsSvgFilters() {
155
+ let blockPresets = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
156
+ return _utils.PRESET_METADATA.filter( // Duotone are the only type of filters for now.
157
+ metadata => metadata.path.at(-1) === 'duotone').flatMap(metadata => {
158
+ const presetByOrigin = (0, _lodash.get)(blockPresets, metadata.path, {});
159
+ return ['default', 'theme'].filter(origin => presetByOrigin[origin]).flatMap(origin => presetByOrigin[origin].map(preset => (0, _element.createElement)(_components.PresetDuotoneFilter, {
160
+ preset: preset,
161
+ key: preset.slug
162
+ })));
163
+ });
164
+ }
165
+
166
+ function flattenTree() {
167
+ let input = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
168
+ let prefix = arguments.length > 1 ? arguments[1] : undefined;
169
+ let token = arguments.length > 2 ? arguments[2] : undefined;
170
+ let result = [];
171
+ Object.keys(input).forEach(key => {
172
+ const newKey = prefix + (0, _lodash.kebabCase)(key.replace('/', '-'));
173
+ const newLeaf = input[key];
174
+
175
+ if (newLeaf instanceof Object) {
176
+ const newPrefix = newKey + token;
177
+ result = [...result, ...flattenTree(newLeaf, newPrefix, token)];
178
+ } else {
179
+ result.push(`${newKey}: ${newLeaf}`);
180
+ }
181
+ });
182
+ return result;
183
+ }
184
+ /**
185
+ * Gets variation selector string from feature selector.
186
+ *
187
+ * @param {string} featureSelector The feature selector.
188
+ *
189
+ * @param {string} styleVariationSelector The style variation selector.
190
+ * @return {string} Combined selector string.
191
+ *
192
+ */
193
+
194
+
195
+ function concatFeatureVariationSelectorString(featureSelector, styleVariationSelector) {
196
+ const featureSelectors = featureSelector.split(',');
197
+ const combinedSelectors = [];
198
+ featureSelectors.forEach(selector => {
199
+ combinedSelectors.push(`${styleVariationSelector.trim()}${selector.trim()}`);
200
+ });
201
+ return combinedSelectors.join(', ');
202
+ }
203
+ /**
204
+ * Transform given style tree into a set of style declarations.
205
+ *
206
+ * @param {Object} blockStyles Block styles.
207
+ *
208
+ * @param {string} selector The selector these declarations should attach to.
209
+ *
210
+ * @param {boolean} useRootPaddingAlign Whether to use CSS custom properties in root selector.
211
+ *
212
+ * @param {Object} tree A theme.json tree containing layout definitions.
213
+ *
214
+ * @return {Array} An array of style declarations.
215
+ */
216
+
217
+
218
+ function getStylesDeclarations() {
219
+ let blockStyles = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
220
+ let selector = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
221
+ let useRootPaddingAlign = arguments.length > 2 ? arguments[2] : undefined;
222
+ let tree = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
223
+ const isRoot = _utils.ROOT_BLOCK_SELECTOR === selector;
224
+ const output = Object.entries(_blocks.__EXPERIMENTAL_STYLE_PROPERTY).reduce((declarations, _ref5) => {
225
+ let [key, {
226
+ value,
227
+ properties,
228
+ useEngine,
229
+ rootOnly
230
+ }] = _ref5;
231
+
232
+ if (rootOnly && !isRoot) {
233
+ return declarations;
234
+ }
235
+
236
+ const pathToValue = value;
237
+
238
+ if (pathToValue[0] === 'elements' || useEngine) {
239
+ return declarations;
240
+ }
241
+
242
+ const styleValue = (0, _lodash.get)(blockStyles, pathToValue); // Root-level padding styles don't currently support strings with CSS shorthand values.
243
+ // This may change: https://github.com/WordPress/gutenberg/issues/40132.
244
+
245
+ if (key === '--wp--style--root--padding' && (typeof styleValue === 'string' || !useRootPaddingAlign)) {
246
+ return declarations;
247
+ }
248
+
249
+ if (!!properties && typeof styleValue !== 'string') {
250
+ Object.entries(properties).forEach(entry => {
251
+ const [name, prop] = entry;
252
+
253
+ if (!(0, _lodash.get)(styleValue, [prop], false)) {
254
+ // Do not create a declaration
255
+ // for sub-properties that don't have any value.
256
+ return;
257
+ }
258
+
259
+ const cssProperty = name.startsWith('--') ? name : (0, _lodash.kebabCase)(name);
260
+ declarations.push(`${cssProperty}: ${compileStyleValue((0, _lodash.get)(styleValue, [prop]))}`);
261
+ });
262
+ } else if ((0, _lodash.get)(blockStyles, pathToValue, false)) {
263
+ const cssProperty = key.startsWith('--') ? key : (0, _lodash.kebabCase)(key);
264
+ declarations.push(`${cssProperty}: ${compileStyleValue((0, _lodash.get)(blockStyles, pathToValue))}`);
265
+ }
266
+
267
+ return declarations;
268
+ }, []); // The goal is to move everything to server side generated engine styles
269
+ // This is temporary as we absorb more and more styles into the engine.
270
+
271
+ const extraRules = (0, _styleEngine.getCSSRules)(blockStyles);
272
+ extraRules.forEach(rule => {
273
+ var _ruleValue;
274
+
275
+ // Don't output padding properties if padding variables are set.
276
+ if (isRoot && useRootPaddingAlign && rule.key.startsWith('padding')) {
277
+ return;
278
+ }
279
+
280
+ const cssProperty = rule.key.startsWith('--') ? rule.key : (0, _lodash.kebabCase)(rule.key);
281
+ let ruleValue = rule.value;
282
+
283
+ if (typeof ruleValue !== 'string' && (_ruleValue = ruleValue) !== null && _ruleValue !== void 0 && _ruleValue.ref) {
284
+ var _ruleValue2;
285
+
286
+ const refPath = ruleValue.ref.split('.');
287
+ ruleValue = (0, _lodash.get)(tree, refPath); // Presence of another ref indicates a reference to another dynamic value.
288
+ // Pointing to another dynamic value is not supported.
289
+
290
+ if (!ruleValue || !!((_ruleValue2 = ruleValue) !== null && _ruleValue2 !== void 0 && _ruleValue2.ref)) {
291
+ return;
292
+ }
293
+ } // Calculate fluid typography rules where available.
294
+
295
+
296
+ if (cssProperty === 'font-size') {
297
+ var _tree$settings;
298
+
299
+ /*
300
+ * getTypographyFontSizeValue() will check
301
+ * if fluid typography has been activated and also
302
+ * whether the incoming value can be converted to a fluid value.
303
+ * Values that already have a "clamp()" function will not pass the test,
304
+ * and therefore the original $value will be returned.
305
+ */
306
+ ruleValue = (0, _typographyUtils.getTypographyFontSizeValue)({
307
+ size: ruleValue
308
+ }, tree === null || tree === void 0 ? void 0 : (_tree$settings = tree.settings) === null || _tree$settings === void 0 ? void 0 : _tree$settings.typography);
309
+ }
310
+
311
+ output.push(`${cssProperty}: ${ruleValue}`);
312
+ });
313
+ return output;
314
+ }
315
+ /**
316
+ * Get generated CSS for layout styles by looking up layout definitions provided
317
+ * in theme.json, and outputting common layout styles, and specific blockGap values.
318
+ *
319
+ * @param {Object} props
320
+ * @param {Object} props.tree A theme.json tree containing layout definitions.
321
+ * @param {Object} props.style A style object containing spacing values.
322
+ * @param {string} props.selector Selector used to group together layout styling rules.
323
+ * @param {boolean} props.hasBlockGapSupport Whether or not the theme opts-in to blockGap support.
324
+ * @param {boolean} props.hasFallbackGapSupport Whether or not the theme allows fallback gap styles.
325
+ * @param {?string} props.fallbackGapValue An optional fallback gap value if no real gap value is available.
326
+ * @return {string} Generated CSS rules for the layout styles.
327
+ */
328
+
329
+
330
+ function getLayoutStyles(_ref6) {
331
+ var _style$spacing, _tree$settings2, _tree$settings2$layou, _tree$settings3, _tree$settings3$layou;
332
+
333
+ let {
334
+ tree,
335
+ style,
336
+ selector,
337
+ hasBlockGapSupport,
338
+ hasFallbackGapSupport,
339
+ fallbackGapValue
340
+ } = _ref6;
341
+ let ruleset = '';
342
+ let gapValue = hasBlockGapSupport ? (0, _gap.getGapCSSValue)(style === null || style === void 0 ? void 0 : (_style$spacing = style.spacing) === null || _style$spacing === void 0 ? void 0 : _style$spacing.blockGap) : ''; // Ensure a fallback gap value for the root layout definitions,
343
+ // and use a fallback value if one is provided for the current block.
344
+
345
+ if (hasFallbackGapSupport) {
346
+ if (selector === _utils.ROOT_BLOCK_SELECTOR) {
347
+ gapValue = !gapValue ? '0.5em' : gapValue;
348
+ } else if (!hasBlockGapSupport && fallbackGapValue) {
349
+ gapValue = fallbackGapValue;
350
+ }
351
+ }
352
+
353
+ if (gapValue && tree !== null && tree !== void 0 && (_tree$settings2 = tree.settings) !== null && _tree$settings2 !== void 0 && (_tree$settings2$layou = _tree$settings2.layout) !== null && _tree$settings2$layou !== void 0 && _tree$settings2$layou.definitions) {
354
+ Object.values(tree.settings.layout.definitions).forEach(_ref7 => {
355
+ let {
356
+ className,
357
+ name,
358
+ spacingStyles
359
+ } = _ref7;
360
+
361
+ // Allow outputting fallback gap styles for flex layout type when block gap support isn't available.
362
+ if (!hasBlockGapSupport && 'flex' !== name) {
363
+ return;
364
+ }
365
+
366
+ if (spacingStyles !== null && spacingStyles !== void 0 && spacingStyles.length) {
367
+ spacingStyles.forEach(spacingStyle => {
368
+ const declarations = [];
369
+
370
+ if (spacingStyle.rules) {
371
+ Object.entries(spacingStyle.rules).forEach(_ref8 => {
372
+ let [cssProperty, cssValue] = _ref8;
373
+ declarations.push(`${cssProperty}: ${cssValue ? cssValue : gapValue}`);
374
+ });
375
+ }
376
+
377
+ if (declarations.length) {
378
+ let combinedSelector = '';
379
+
380
+ if (!hasBlockGapSupport) {
381
+ // For fallback gap styles, use lower specificity, to ensure styles do not unintentionally override theme styles.
382
+ combinedSelector = selector === _utils.ROOT_BLOCK_SELECTOR ? `:where(.${className}${(spacingStyle === null || spacingStyle === void 0 ? void 0 : spacingStyle.selector) || ''})` : `:where(${selector}.${className}${(spacingStyle === null || spacingStyle === void 0 ? void 0 : spacingStyle.selector) || ''})`;
383
+ } else {
384
+ combinedSelector = selector === _utils.ROOT_BLOCK_SELECTOR ? `${selector} .${className}${(spacingStyle === null || spacingStyle === void 0 ? void 0 : spacingStyle.selector) || ''}` : `${selector}.${className}${(spacingStyle === null || spacingStyle === void 0 ? void 0 : spacingStyle.selector) || ''}`;
385
+ }
386
+
387
+ ruleset += `${combinedSelector} { ${declarations.join('; ')}; }`;
388
+ }
389
+ });
390
+ }
391
+ }); // For backwards compatibility, ensure the legacy block gap CSS variable is still available.
392
+
393
+ if (selector === _utils.ROOT_BLOCK_SELECTOR && hasBlockGapSupport) {
394
+ ruleset += `${selector} { --wp--style--block-gap: ${gapValue}; }`;
395
+ }
396
+ } // Output base styles
397
+
398
+
399
+ if (selector === _utils.ROOT_BLOCK_SELECTOR && tree !== null && tree !== void 0 && (_tree$settings3 = tree.settings) !== null && _tree$settings3 !== void 0 && (_tree$settings3$layou = _tree$settings3.layout) !== null && _tree$settings3$layou !== void 0 && _tree$settings3$layou.definitions) {
400
+ const validDisplayModes = ['block', 'flex', 'grid'];
401
+ Object.values(tree.settings.layout.definitions).forEach(_ref9 => {
402
+ let {
403
+ className,
404
+ displayMode,
405
+ baseStyles
406
+ } = _ref9;
407
+
408
+ if (displayMode && validDisplayModes.includes(displayMode)) {
409
+ ruleset += `${selector} .${className} { display:${displayMode}; }`;
410
+ }
411
+
412
+ if (baseStyles !== null && baseStyles !== void 0 && baseStyles.length) {
413
+ baseStyles.forEach(baseStyle => {
414
+ const declarations = [];
415
+
416
+ if (baseStyle.rules) {
417
+ Object.entries(baseStyle.rules).forEach(_ref10 => {
418
+ let [cssProperty, cssValue] = _ref10;
419
+ declarations.push(`${cssProperty}: ${cssValue}`);
420
+ });
421
+ }
422
+
423
+ if (declarations.length) {
424
+ const combinedSelector = `${selector} .${className}${(baseStyle === null || baseStyle === void 0 ? void 0 : baseStyle.selector) || ''}`;
425
+ ruleset += `${combinedSelector} { ${declarations.join('; ')}; }`;
426
+ }
427
+ });
428
+ }
429
+ });
430
+ }
431
+
432
+ return ruleset;
433
+ }
434
+
435
+ const getNodesWithStyles = (tree, blockSelectors) => {
436
+ var _tree$styles$blocks, _tree$styles3;
437
+
438
+ const nodes = [];
439
+
440
+ if (!(tree !== null && tree !== void 0 && tree.styles)) {
441
+ return nodes;
442
+ }
443
+
444
+ const pickStyleKeys = treeToPickFrom => Object.fromEntries(Object.entries(treeToPickFrom !== null && treeToPickFrom !== void 0 ? treeToPickFrom : {}).filter(_ref11 => {
445
+ let [key] = _ref11;
446
+ return ['border', 'color', 'dimensions', 'spacing', 'typography', 'filter', 'outline', 'shadow'].includes(key);
447
+ })); // Top-level.
448
+
449
+
450
+ const styles = pickStyleKeys(tree.styles);
451
+
452
+ if (!!styles) {
453
+ nodes.push({
454
+ styles,
455
+ selector: _utils.ROOT_BLOCK_SELECTOR
456
+ });
457
+ }
458
+
459
+ Object.entries(_blocks.__EXPERIMENTAL_ELEMENTS).forEach(_ref12 => {
460
+ var _tree$styles;
461
+
462
+ let [name, selector] = _ref12;
463
+
464
+ if (!!((_tree$styles = tree.styles) !== null && _tree$styles !== void 0 && _tree$styles.elements[name])) {
465
+ var _tree$styles2;
466
+
467
+ nodes.push({
468
+ styles: (_tree$styles2 = tree.styles) === null || _tree$styles2 === void 0 ? void 0 : _tree$styles2.elements[name],
469
+ selector
470
+ });
471
+ }
472
+ }); // Iterate over blocks: they can have styles & elements.
473
+
474
+ Object.entries((_tree$styles$blocks = (_tree$styles3 = tree.styles) === null || _tree$styles3 === void 0 ? void 0 : _tree$styles3.blocks) !== null && _tree$styles$blocks !== void 0 ? _tree$styles$blocks : {}).forEach(_ref13 => {
475
+ var _blockSelectors$block, _node$elements;
476
+
477
+ let [blockName, node] = _ref13;
478
+ const blockStyles = pickStyleKeys(node);
479
+
480
+ if (node !== null && node !== void 0 && node.variations) {
481
+ const variations = {};
482
+ Object.keys(node.variations).forEach(variation => {
483
+ variations[variation] = pickStyleKeys(node.variations[variation]);
484
+ });
485
+ blockStyles.variations = variations;
486
+ }
487
+
488
+ if (!!blockStyles && !!(blockSelectors !== null && blockSelectors !== void 0 && (_blockSelectors$block = blockSelectors[blockName]) !== null && _blockSelectors$block !== void 0 && _blockSelectors$block.selector)) {
489
+ nodes.push({
490
+ duotoneSelector: blockSelectors[blockName].duotoneSelector,
491
+ fallbackGapValue: blockSelectors[blockName].fallbackGapValue,
492
+ hasLayoutSupport: blockSelectors[blockName].hasLayoutSupport,
493
+ selector: blockSelectors[blockName].selector,
494
+ styles: blockStyles,
495
+ featureSelectors: blockSelectors[blockName].featureSelectors,
496
+ styleVariationSelectors: blockSelectors[blockName].styleVariationSelectors
497
+ });
498
+ }
499
+
500
+ Object.entries((_node$elements = node === null || node === void 0 ? void 0 : node.elements) !== null && _node$elements !== void 0 ? _node$elements : {}).forEach(_ref14 => {
501
+ let [elementName, value] = _ref14;
502
+
503
+ if (!!value && !!(blockSelectors !== null && blockSelectors !== void 0 && blockSelectors[blockName]) && !!(_blocks.__EXPERIMENTAL_ELEMENTS !== null && _blocks.__EXPERIMENTAL_ELEMENTS !== void 0 && _blocks.__EXPERIMENTAL_ELEMENTS[elementName])) {
504
+ nodes.push({
505
+ styles: value,
506
+ selector: blockSelectors[blockName].selector.split(',').map(sel => {
507
+ const elementSelectors = _blocks.__EXPERIMENTAL_ELEMENTS[elementName].split(',');
508
+
509
+ return elementSelectors.map(elementSelector => sel + ' ' + elementSelector);
510
+ }).join(',')
511
+ });
512
+ }
513
+ });
514
+ });
515
+ return nodes;
516
+ };
517
+
518
+ exports.getNodesWithStyles = getNodesWithStyles;
519
+
520
+ const getNodesWithSettings = (tree, blockSelectors) => {
521
+ var _tree$settings4, _tree$settings$blocks, _tree$settings5;
522
+
523
+ const nodes = [];
524
+
525
+ if (!(tree !== null && tree !== void 0 && tree.settings)) {
526
+ return nodes;
527
+ }
528
+
529
+ const pickPresets = treeToPickFrom => {
530
+ const presets = {};
531
+
532
+ _utils.PRESET_METADATA.forEach(_ref15 => {
533
+ let {
534
+ path
535
+ } = _ref15;
536
+ const value = (0, _lodash.get)(treeToPickFrom, path, false);
537
+
538
+ if (value !== false) {
539
+ (0, _lodash.set)(presets, path, value);
540
+ }
541
+ });
542
+
543
+ return presets;
544
+ }; // Top-level.
545
+
546
+
547
+ const presets = pickPresets(tree.settings);
548
+ const custom = (_tree$settings4 = tree.settings) === null || _tree$settings4 === void 0 ? void 0 : _tree$settings4.custom;
549
+
550
+ if (!(0, _lodash.isEmpty)(presets) || !!custom) {
551
+ nodes.push({
552
+ presets,
553
+ custom,
554
+ selector: _utils.ROOT_BLOCK_SELECTOR
555
+ });
556
+ } // Blocks.
557
+
558
+
559
+ Object.entries((_tree$settings$blocks = (_tree$settings5 = tree.settings) === null || _tree$settings5 === void 0 ? void 0 : _tree$settings5.blocks) !== null && _tree$settings$blocks !== void 0 ? _tree$settings$blocks : {}).forEach(_ref16 => {
560
+ let [blockName, node] = _ref16;
561
+ const blockPresets = pickPresets(node);
562
+ const blockCustom = node.custom;
563
+
564
+ if (!(0, _lodash.isEmpty)(blockPresets) || !!blockCustom) {
565
+ nodes.push({
566
+ presets: blockPresets,
567
+ custom: blockCustom,
568
+ selector: blockSelectors[blockName].selector
569
+ });
570
+ }
571
+ });
572
+ return nodes;
573
+ };
574
+
575
+ exports.getNodesWithSettings = getNodesWithSettings;
576
+
577
+ const toCustomProperties = (tree, blockSelectors) => {
578
+ const settings = getNodesWithSettings(tree, blockSelectors);
579
+ let ruleset = '';
580
+ settings.forEach(_ref17 => {
581
+ let {
582
+ presets,
583
+ custom,
584
+ selector
585
+ } = _ref17;
586
+ const declarations = getPresetsDeclarations(presets, tree === null || tree === void 0 ? void 0 : tree.settings);
587
+ const customProps = flattenTree(custom, '--wp--custom--', '--');
588
+
589
+ if (customProps.length > 0) {
590
+ declarations.push(...customProps);
591
+ }
592
+
593
+ if (declarations.length > 0) {
594
+ ruleset = ruleset + `${selector}{${declarations.join(';')};}`;
595
+ }
596
+ });
597
+ return ruleset;
598
+ };
599
+
600
+ exports.toCustomProperties = toCustomProperties;
601
+
602
+ const toStyles = function (tree, blockSelectors, hasBlockGapSupport, hasFallbackGapSupport) {
603
+ var _tree$settings6, _tree$settings7;
604
+
605
+ let disableLayoutStyles = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
606
+ const nodesWithStyles = getNodesWithStyles(tree, blockSelectors);
607
+ const nodesWithSettings = getNodesWithSettings(tree, blockSelectors);
608
+ const useRootPaddingAlign = tree === null || tree === void 0 ? void 0 : (_tree$settings6 = tree.settings) === null || _tree$settings6 === void 0 ? void 0 : _tree$settings6.useRootPaddingAwareAlignments;
609
+ const {
610
+ contentSize,
611
+ wideSize
612
+ } = (tree === null || tree === void 0 ? void 0 : (_tree$settings7 = tree.settings) === null || _tree$settings7 === void 0 ? void 0 : _tree$settings7.layout) || {};
613
+ /*
614
+ * Reset default browser margin on the root body element.
615
+ * This is set on the root selector **before** generating the ruleset
616
+ * from the `theme.json`. This is to ensure that if the `theme.json` declares
617
+ * `margin` in its `spacing` declaration for the `body` element then these
618
+ * user-generated values take precedence in the CSS cascade.
619
+ * @link https://github.com/WordPress/gutenberg/issues/36147.
620
+ */
621
+
622
+ let ruleset = 'body {margin: 0;';
623
+
624
+ if (contentSize) {
625
+ ruleset += ` --wp--style--global--content-size: ${contentSize};`;
626
+ }
627
+
628
+ if (wideSize) {
629
+ ruleset += ` --wp--style--global--wide-size: ${wideSize};`;
630
+ }
631
+
632
+ if (useRootPaddingAlign) {
633
+ ruleset += `padding-right: 0; padding-left: 0; padding-top: var(--wp--style--root--padding-top); padding-bottom: var(--wp--style--root--padding-bottom) }
634
+ .has-global-padding { padding-right: var(--wp--style--root--padding-right); padding-left: var(--wp--style--root--padding-left); }
635
+ .has-global-padding :where(.has-global-padding) { padding-right: 0; padding-left: 0; }
636
+ .has-global-padding > .alignfull { margin-right: calc(var(--wp--style--root--padding-right) * -1); margin-left: calc(var(--wp--style--root--padding-left) * -1); }
637
+ .has-global-padding :where(.has-global-padding) > .alignfull { margin-right: 0; margin-left: 0; }
638
+ .has-global-padding > .alignfull:where(:not(.has-global-padding)) > :where([class*="wp-block-"]:not(.alignfull):not([class*="__"]),p,h1,h2,h3,h4,h5,h6,ul,ol) { padding-right: var(--wp--style--root--padding-right); padding-left: var(--wp--style--root--padding-left); }
639
+ .has-global-padding :where(.has-global-padding) > .alignfull:where(:not(.has-global-padding)) > :where([class*="wp-block-"]:not(.alignfull):not([class*="__"]),p,h1,h2,h3,h4,h5,h6,ul,ol) { padding-right: 0; padding-left: 0;`;
640
+ }
641
+
642
+ ruleset += '}';
643
+ nodesWithStyles.forEach(_ref18 => {
644
+ let {
645
+ selector,
646
+ duotoneSelector,
647
+ styles,
648
+ fallbackGapValue,
649
+ hasLayoutSupport,
650
+ featureSelectors,
651
+ styleVariationSelectors
652
+ } = _ref18;
653
+
654
+ // Process styles for block support features with custom feature level
655
+ // CSS selectors set.
656
+ if (featureSelectors) {
657
+ Object.entries(featureSelectors).forEach(_ref19 => {
658
+ let [featureName, featureSelector] = _ref19;
659
+
660
+ if (styles !== null && styles !== void 0 && styles[featureName]) {
661
+ const featureStyles = {
662
+ [featureName]: styles[featureName]
663
+ };
664
+ const featureDeclarations = getStylesDeclarations(featureStyles);
665
+ delete styles[featureName];
666
+
667
+ if (!!featureDeclarations.length) {
668
+ ruleset = ruleset + `${featureSelector}{${featureDeclarations.join(';')} }`;
669
+ }
670
+ }
671
+ });
672
+ }
673
+
674
+ if (styleVariationSelectors) {
675
+ Object.entries(styleVariationSelectors).forEach(_ref20 => {
676
+ var _styles$variations;
677
+
678
+ let [styleVariationName, styleVariationSelector] = _ref20;
679
+
680
+ if (styles !== null && styles !== void 0 && (_styles$variations = styles.variations) !== null && _styles$variations !== void 0 && _styles$variations[styleVariationName]) {
681
+ var _styles$variations3;
682
+
683
+ // If the block uses any custom selectors for block support, add those first.
684
+ if (featureSelectors) {
685
+ Object.entries(featureSelectors).forEach(_ref21 => {
686
+ var _styles$variations2, _styles$variations2$s;
687
+
688
+ let [featureName, featureSelector] = _ref21;
689
+
690
+ if (styles !== null && styles !== void 0 && (_styles$variations2 = styles.variations) !== null && _styles$variations2 !== void 0 && (_styles$variations2$s = _styles$variations2[styleVariationName]) !== null && _styles$variations2$s !== void 0 && _styles$variations2$s[featureName]) {
691
+ const featureStyles = {
692
+ [featureName]: styles.variations[styleVariationName][featureName]
693
+ };
694
+ const featureDeclarations = getStylesDeclarations(featureStyles);
695
+ delete styles.variations[styleVariationName][featureName];
696
+
697
+ if (!!featureDeclarations.length) {
698
+ ruleset = ruleset + `${concatFeatureVariationSelectorString(featureSelector, styleVariationSelector)}{${featureDeclarations.join(';')} }`;
699
+ }
700
+ }
701
+ });
702
+ } // Otherwise add regular selectors.
703
+
704
+
705
+ const styleVariationDeclarations = getStylesDeclarations(styles === null || styles === void 0 ? void 0 : (_styles$variations3 = styles.variations) === null || _styles$variations3 === void 0 ? void 0 : _styles$variations3[styleVariationName], styleVariationSelector, useRootPaddingAlign, tree);
706
+
707
+ if (!!styleVariationDeclarations.length) {
708
+ ruleset = ruleset + `${styleVariationSelector}{${styleVariationDeclarations.join(';')}}`;
709
+ }
710
+ }
711
+ });
712
+ }
713
+
714
+ const duotoneStyles = {};
715
+
716
+ if (styles !== null && styles !== void 0 && styles.filter) {
717
+ duotoneStyles.filter = styles.filter;
718
+ delete styles.filter;
719
+ } // Process duotone styles (they use color.__experimentalDuotone selector).
720
+
721
+
722
+ if (duotoneSelector) {
723
+ const duotoneDeclarations = getStylesDeclarations(duotoneStyles);
724
+
725
+ if (duotoneDeclarations.length > 0) {
726
+ ruleset = ruleset + `${duotoneSelector}{${duotoneDeclarations.join(';')};}`;
727
+ }
728
+ } // Process blockGap and layout styles.
729
+
730
+
731
+ if (!disableLayoutStyles && (_utils.ROOT_BLOCK_SELECTOR === selector || hasLayoutSupport)) {
732
+ ruleset += getLayoutStyles({
733
+ tree,
734
+ style: styles,
735
+ selector,
736
+ hasBlockGapSupport,
737
+ hasFallbackGapSupport,
738
+ fallbackGapValue
739
+ });
740
+ } // Process the remaining block styles (they use either normal block class or __experimentalSelector).
741
+
742
+
743
+ const declarations = getStylesDeclarations(styles, selector, useRootPaddingAlign, tree);
744
+
745
+ if (declarations !== null && declarations !== void 0 && declarations.length) {
746
+ ruleset = ruleset + `${selector}{${declarations.join(';')};}`;
747
+ } // Check for pseudo selector in `styles` and handle separately.
748
+
749
+
750
+ const pseudoSelectorStyles = Object.entries(styles).filter(_ref22 => {
751
+ let [key] = _ref22;
752
+ return key.startsWith(':');
753
+ });
754
+
755
+ if (pseudoSelectorStyles !== null && pseudoSelectorStyles !== void 0 && pseudoSelectorStyles.length) {
756
+ pseudoSelectorStyles.forEach(_ref23 => {
757
+ let [pseudoKey, pseudoStyle] = _ref23;
758
+ const pseudoDeclarations = getStylesDeclarations(pseudoStyle);
759
+
760
+ if (!(pseudoDeclarations !== null && pseudoDeclarations !== void 0 && pseudoDeclarations.length)) {
761
+ return;
762
+ } // `selector` maybe provided in a form
763
+ // where block level selectors have sub element
764
+ // selectors appended to them as a comma separated
765
+ // string.
766
+ // e.g. `h1 a,h2 a,h3 a,h4 a,h5 a,h6 a`;
767
+ // Split and append pseudo selector to create
768
+ // the proper rules to target the elements.
769
+
770
+
771
+ const _selector = selector.split(',').map(sel => sel + pseudoKey).join(',');
772
+
773
+ const pseudoRule = `${_selector}{${pseudoDeclarations.join(';')};}`;
774
+ ruleset = ruleset + pseudoRule;
775
+ });
776
+ }
777
+ });
778
+ /* Add alignment / layout styles */
779
+
780
+ ruleset = ruleset + '.wp-site-blocks > .alignleft { float: left; margin-right: 2em; }';
781
+ ruleset = ruleset + '.wp-site-blocks > .alignright { float: right; margin-left: 2em; }';
782
+ ruleset = ruleset + '.wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }';
783
+
784
+ if (hasBlockGapSupport) {
785
+ var _tree$styles4, _tree$styles4$spacing;
786
+
787
+ // Use fallback of `0.5em` just in case, however if there is blockGap support, there should nearly always be a real value.
788
+ const gapValue = (0, _gap.getGapCSSValue)(tree === null || tree === void 0 ? void 0 : (_tree$styles4 = tree.styles) === null || _tree$styles4 === void 0 ? void 0 : (_tree$styles4$spacing = _tree$styles4.spacing) === null || _tree$styles4$spacing === void 0 ? void 0 : _tree$styles4$spacing.blockGap) || '0.5em';
789
+ ruleset = ruleset + '.wp-site-blocks > * { margin-block-start: 0; margin-block-end: 0; }';
790
+ ruleset = ruleset + `.wp-site-blocks > * + * { margin-block-start: ${gapValue}; }`;
791
+ }
792
+
793
+ nodesWithSettings.forEach(_ref24 => {
794
+ let {
795
+ selector,
796
+ presets
797
+ } = _ref24;
798
+
799
+ if (_utils.ROOT_BLOCK_SELECTOR === selector) {
800
+ // Do not add extra specificity for top-level classes.
801
+ selector = '';
802
+ }
803
+
804
+ const classes = getPresetsClasses(selector, presets);
805
+
806
+ if (!(0, _lodash.isEmpty)(classes)) {
807
+ ruleset = ruleset + classes;
808
+ }
809
+ });
810
+ return ruleset;
811
+ };
812
+
813
+ exports.toStyles = toStyles;
814
+
815
+ function toSvgFilters(tree, blockSelectors) {
816
+ const nodesWithSettings = getNodesWithSettings(tree, blockSelectors);
817
+ return nodesWithSettings.flatMap(_ref25 => {
818
+ let {
819
+ presets
820
+ } = _ref25;
821
+ return getPresetsSvgFilters(presets);
822
+ });
823
+ }
824
+
825
+ const getBlockSelectors = (blockTypes, getBlockStyles) => {
826
+ const result = {};
827
+ blockTypes.forEach(blockType => {
828
+ var _blockType$supports$_, _blockType$supports, _blockType$supports$c, _blockType$supports2, _blockType$supports2$, _blockType$supports3, _blockType$supports4, _blockType$supports4$, _blockType$supports4$2;
829
+
830
+ const name = blockType.name;
831
+ const selector = (_blockType$supports$_ = blockType === null || blockType === void 0 ? void 0 : (_blockType$supports = blockType.supports) === null || _blockType$supports === void 0 ? void 0 : _blockType$supports.__experimentalSelector) !== null && _blockType$supports$_ !== void 0 ? _blockType$supports$_ : '.wp-block-' + name.replace('core/', '').replace('/', '-');
832
+ const duotoneSelector = (_blockType$supports$c = blockType === null || blockType === void 0 ? void 0 : (_blockType$supports2 = blockType.supports) === null || _blockType$supports2 === void 0 ? void 0 : (_blockType$supports2$ = _blockType$supports2.color) === null || _blockType$supports2$ === void 0 ? void 0 : _blockType$supports2$.__experimentalDuotone) !== null && _blockType$supports$c !== void 0 ? _blockType$supports$c : null;
833
+ const hasLayoutSupport = !!(blockType !== null && blockType !== void 0 && (_blockType$supports3 = blockType.supports) !== null && _blockType$supports3 !== void 0 && _blockType$supports3.__experimentalLayout);
834
+ const fallbackGapValue = blockType === null || blockType === void 0 ? void 0 : (_blockType$supports4 = blockType.supports) === null || _blockType$supports4 === void 0 ? void 0 : (_blockType$supports4$ = _blockType$supports4.spacing) === null || _blockType$supports4$ === void 0 ? void 0 : (_blockType$supports4$2 = _blockType$supports4$.blockGap) === null || _blockType$supports4$2 === void 0 ? void 0 : _blockType$supports4$2.__experimentalDefault;
835
+ const blockStyleVariations = getBlockStyles(name);
836
+ const styleVariationSelectors = {};
837
+
838
+ if (blockStyleVariations !== null && blockStyleVariations !== void 0 && blockStyleVariations.length) {
839
+ blockStyleVariations.forEach(variation => {
840
+ const styleVariationSelector = `.is-style-${variation.name}${selector}`;
841
+ styleVariationSelectors[variation.name] = styleVariationSelector;
842
+ });
843
+ } // For each block support feature add any custom selectors.
844
+
845
+
846
+ const featureSelectors = {};
847
+ Object.entries(BLOCK_SUPPORT_FEATURE_LEVEL_SELECTORS).forEach(_ref26 => {
848
+ var _blockType$supports5, _blockType$supports5$;
849
+
850
+ let [featureKey, featureName] = _ref26;
851
+ const featureSelector = blockType === null || blockType === void 0 ? void 0 : (_blockType$supports5 = blockType.supports) === null || _blockType$supports5 === void 0 ? void 0 : (_blockType$supports5$ = _blockType$supports5[featureKey]) === null || _blockType$supports5$ === void 0 ? void 0 : _blockType$supports5$.__experimentalSelector;
852
+
853
+ if (featureSelector) {
854
+ featureSelectors[featureName] = (0, _utils.scopeSelector)(selector, featureSelector);
855
+ }
856
+ });
857
+ result[name] = {
858
+ duotoneSelector,
859
+ fallbackGapValue,
860
+ featureSelectors: Object.keys(featureSelectors).length ? featureSelectors : undefined,
861
+ hasLayoutSupport,
862
+ name,
863
+ selector,
864
+ styleVariationSelectors: Object.keys(styleVariationSelectors).length ? styleVariationSelectors : undefined
865
+ };
866
+ });
867
+ return result;
868
+ };
869
+ /**
870
+ * If there is a separator block whose color is defined in theme.json via background,
871
+ * update the separator color to the same value by using border color.
872
+ *
873
+ * @param {Object} config Theme.json configuration file object.
874
+ * @return {Object} configTheme.json configuration file object updated.
875
+ */
876
+
877
+
878
+ exports.getBlockSelectors = getBlockSelectors;
879
+
880
+ function updateConfigWithSeparator(config) {
881
+ var _config$styles, _config$styles2, _config$styles2$block, _config$styles3, _config$styles3$block, _config$styles4, _config$styles4$block;
882
+
883
+ const needsSeparatorStyleUpdate = ((_config$styles = config.styles) === null || _config$styles === void 0 ? void 0 : _config$styles.blocks['core/separator']) && ((_config$styles2 = config.styles) === null || _config$styles2 === void 0 ? void 0 : (_config$styles2$block = _config$styles2.blocks['core/separator'].color) === null || _config$styles2$block === void 0 ? void 0 : _config$styles2$block.background) && !((_config$styles3 = config.styles) !== null && _config$styles3 !== void 0 && (_config$styles3$block = _config$styles3.blocks['core/separator'].color) !== null && _config$styles3$block !== void 0 && _config$styles3$block.text) && !((_config$styles4 = config.styles) !== null && _config$styles4 !== void 0 && (_config$styles4$block = _config$styles4.blocks['core/separator'].border) !== null && _config$styles4$block !== void 0 && _config$styles4$block.color);
884
+
885
+ if (needsSeparatorStyleUpdate) {
886
+ var _config$styles5;
887
+
888
+ return { ...config,
889
+ styles: { ...config.styles,
890
+ blocks: { ...config.styles.blocks,
891
+ 'core/separator': { ...config.styles.blocks['core/separator'],
892
+ color: { ...config.styles.blocks['core/separator'].color,
893
+ text: (_config$styles5 = config.styles) === null || _config$styles5 === void 0 ? void 0 : _config$styles5.blocks['core/separator'].color.background
894
+ }
895
+ }
896
+ }
897
+ }
898
+ };
899
+ }
900
+
901
+ return config;
902
+ }
903
+
904
+ const processCSSNesting = (css, blockSelector) => {
905
+ let processedCSS = ''; // Split CSS nested rules.
906
+
907
+ const parts = css.split('&');
908
+ parts.forEach(part => {
909
+ processedCSS += !part.includes('{') ? blockSelector + '{' + part + '}' // If the part doesn't contain braces, it applies to the root level.
910
+ : blockSelector + part; // Prepend the selector, which effectively replaces the "&" character.
911
+ });
912
+ return processedCSS;
913
+ };
914
+
915
+ function useGlobalStylesOutput() {
916
+ let {
917
+ merged: mergedConfig
918
+ } = (0, _element.useContext)(_context.GlobalStylesContext);
919
+ const [blockGap] = (0, _hooks.useGlobalSetting)('spacing.blockGap');
920
+ const hasBlockGapSupport = blockGap !== null;
921
+ const hasFallbackGapSupport = !hasBlockGapSupport; // This setting isn't useful yet: it exists as a placeholder for a future explicit fallback styles support.
922
+
923
+ const disableLayoutStyles = (0, _data.useSelect)(select => {
924
+ const {
925
+ getSettings
926
+ } = select(_store.store);
927
+ return !!getSettings().disableLayoutStyles;
928
+ });
929
+ const getBlockStyles = (0, _data.useSelect)(select => {
930
+ return select(_blocks.store).getBlockStyles;
931
+ }, []);
932
+ return (0, _element.useMemo)(() => {
933
+ var _mergedConfig, _mergedConfig2, _mergedConfig$styles$;
934
+
935
+ if (!((_mergedConfig = mergedConfig) !== null && _mergedConfig !== void 0 && _mergedConfig.styles) || !((_mergedConfig2 = mergedConfig) !== null && _mergedConfig2 !== void 0 && _mergedConfig2.settings)) {
936
+ return [];
937
+ }
938
+
939
+ mergedConfig = updateConfigWithSeparator(mergedConfig);
940
+ const blockSelectors = getBlockSelectors((0, _blocks.getBlockTypes)(), getBlockStyles);
941
+ const customProperties = toCustomProperties(mergedConfig, blockSelectors);
942
+ const globalStyles = toStyles(mergedConfig, blockSelectors, hasBlockGapSupport, hasFallbackGapSupport, disableLayoutStyles);
943
+ const filters = toSvgFilters(mergedConfig, blockSelectors);
944
+ const stylesheets = [{
945
+ css: customProperties,
946
+ isGlobalStyles: true
947
+ }, {
948
+ css: globalStyles,
949
+ isGlobalStyles: true
950
+ }, // Load custom CSS in own stylesheet so that any invalid CSS entered in the input won't break all the global styles in the editor.
951
+ {
952
+ css: (_mergedConfig$styles$ = mergedConfig.styles.css) !== null && _mergedConfig$styles$ !== void 0 ? _mergedConfig$styles$ : '',
953
+ isGlobalStyles: true
954
+ }]; // Loop through the blocks to check if there are custom CSS values.
955
+ // If there are, get the block selector and push the selector together with
956
+ // the CSS value to the 'stylesheets' array.
957
+
958
+ (0, _blocks.getBlockTypes)().forEach(blockType => {
959
+ var _mergedConfig$styles$2;
960
+
961
+ if ((_mergedConfig$styles$2 = mergedConfig.styles.blocks[blockType.name]) !== null && _mergedConfig$styles$2 !== void 0 && _mergedConfig$styles$2.css) {
962
+ var _mergedConfig$styles$3;
963
+
964
+ const selector = blockSelectors[blockType.name].selector;
965
+ stylesheets.push({
966
+ css: processCSSNesting((_mergedConfig$styles$3 = mergedConfig.styles.blocks[blockType.name]) === null || _mergedConfig$styles$3 === void 0 ? void 0 : _mergedConfig$styles$3.css, selector),
967
+ isGlobalStyles: true
968
+ });
969
+ }
970
+ });
971
+ return [stylesheets, mergedConfig.settings, filters];
972
+ }, [hasBlockGapSupport, hasFallbackGapSupport, mergedConfig, disableLayoutStyles]);
973
+ }
974
+ //# sourceMappingURL=use-global-styles-output.js.map