@wordpress/block-editor 11.5.0 → 11.7.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 (345) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +4 -0
  3. package/build/components/block-list/block-html.js +1 -3
  4. package/build/components/block-list/block-html.js.map +1 -1
  5. package/build/components/block-list/block-invalid-warning.js +63 -80
  6. package/build/components/block-list/block-invalid-warning.js.map +1 -1
  7. package/build/components/block-preview/auto.js +6 -23
  8. package/build/components/block-preview/auto.js.map +1 -1
  9. package/build/components/block-settings-menu-controls/index.js +1 -1
  10. package/build/components/block-settings-menu-controls/index.js.map +1 -1
  11. package/build/components/block-switcher/block-transformations-menu.native.js +1 -0
  12. package/build/components/block-switcher/block-transformations-menu.native.js.map +1 -1
  13. package/build/components/convert-to-group-buttons/use-convert-to-group-button-props.js +6 -3
  14. package/build/components/convert-to-group-buttons/use-convert-to-group-button-props.js.map +1 -1
  15. package/build/components/editor-styles/index.js +20 -2
  16. package/build/components/editor-styles/index.js.map +1 -1
  17. package/build/components/global-styles/border-panel.js +306 -0
  18. package/build/components/global-styles/border-panel.js.map +1 -0
  19. package/build/components/global-styles/color-panel.js +583 -0
  20. package/build/components/global-styles/color-panel.js.map +1 -0
  21. package/build/components/global-styles/dimensions-panel.js +8 -30
  22. package/build/components/global-styles/dimensions-panel.js.map +1 -1
  23. package/build/components/global-styles/get-block-css-selector.js +129 -0
  24. package/build/components/global-styles/get-block-css-selector.js.map +1 -0
  25. package/build/components/global-styles/hooks.js +109 -3
  26. package/build/components/global-styles/hooks.js.map +1 -1
  27. package/build/components/global-styles/index.js +36 -0
  28. package/build/components/global-styles/index.js.map +1 -1
  29. package/build/components/global-styles/typography-panel.js +66 -45
  30. package/build/components/global-styles/typography-panel.js.map +1 -1
  31. package/build/components/global-styles/use-global-styles-output.js +180 -99
  32. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  33. package/build/components/global-styles/utils.js +2 -1
  34. package/build/components/global-styles/utils.js.map +1 -1
  35. package/build/components/image-size-control/index.js +8 -5
  36. package/build/components/image-size-control/index.js.map +1 -1
  37. package/build/components/inserter/index.js +29 -17
  38. package/build/components/inserter/index.js.map +1 -1
  39. package/build/components/inserter/menu.js +1 -1
  40. package/build/components/inserter/menu.js.map +1 -1
  41. package/build/components/inserter/quick-inserter.js +4 -2
  42. package/build/components/inserter/quick-inserter.js.map +1 -1
  43. package/build/components/inserter/search-results.js +10 -3
  44. package/build/components/inserter/search-results.js.map +1 -1
  45. package/build/components/inserter/tabs.js +1 -1
  46. package/build/components/inserter/tabs.js.map +1 -1
  47. package/build/components/inspector-controls-tabs/position-controls-panel.js +43 -7
  48. package/build/components/inspector-controls-tabs/position-controls-panel.js.map +1 -1
  49. package/build/components/line-height-control/index.js +15 -1
  50. package/build/components/line-height-control/index.js.map +1 -1
  51. package/build/components/link-control/index.js +1 -1
  52. package/build/components/link-control/index.js.map +1 -1
  53. package/build/components/link-control/search-item.js +5 -2
  54. package/build/components/link-control/search-item.js.map +1 -1
  55. package/build/components/list-view/appender.js +105 -0
  56. package/build/components/list-view/appender.js.map +1 -0
  57. package/build/components/list-view/block.js +5 -5
  58. package/build/components/list-view/block.js.map +1 -1
  59. package/build/components/list-view/branch.js +25 -5
  60. package/build/components/list-view/branch.js.map +1 -1
  61. package/build/components/list-view/index.js +37 -13
  62. package/build/components/list-view/index.js.map +1 -1
  63. package/build/components/list-view/use-block-selection.js +1 -2
  64. package/build/components/list-view/use-block-selection.js.map +1 -1
  65. package/build/components/media-replace-flow/index.js +13 -4
  66. package/build/components/media-replace-flow/index.js.map +1 -1
  67. package/build/components/off-canvas-editor/appender.js +28 -3
  68. package/build/components/off-canvas-editor/appender.js.map +1 -1
  69. package/build/components/off-canvas-editor/branch.js +5 -3
  70. package/build/components/off-canvas-editor/branch.js.map +1 -1
  71. package/build/components/off-canvas-editor/index.js +9 -7
  72. package/build/components/off-canvas-editor/index.js.map +1 -1
  73. package/build/components/off-canvas-editor/link-ui.js +0 -1
  74. package/build/components/off-canvas-editor/link-ui.js.map +1 -1
  75. package/build/components/provider/use-block-sync.js +17 -3
  76. package/build/components/provider/use-block-sync.js.map +1 -1
  77. package/build/components/rich-text/format-edit.js +2 -30
  78. package/build/components/rich-text/format-edit.js.map +1 -1
  79. package/build/components/rich-text/format-toolbar-container.js +0 -3
  80. package/build/components/rich-text/format-toolbar-container.js.map +1 -1
  81. package/build/components/writing-flow/use-input.js +4 -8
  82. package/build/components/writing-flow/use-input.js.map +1 -1
  83. package/build/hooks/border.js +90 -240
  84. package/build/hooks/border.js.map +1 -1
  85. package/build/hooks/color.js +92 -229
  86. package/build/hooks/color.js.map +1 -1
  87. package/build/hooks/content-lock-ui.js +4 -2
  88. package/build/hooks/content-lock-ui.js.map +1 -1
  89. package/build/hooks/{color-panel.js → contrast-checker.js} +11 -49
  90. package/build/hooks/contrast-checker.js.map +1 -0
  91. package/build/hooks/custom-class-name.js +4 -4
  92. package/build/hooks/custom-class-name.js.map +1 -1
  93. package/build/hooks/custom-class-name.native.js +3 -4
  94. package/build/hooks/custom-class-name.native.js.map +1 -1
  95. package/build/hooks/dimensions.js +0 -1
  96. package/build/hooks/dimensions.js.map +1 -1
  97. package/build/hooks/duotone.js +3 -1
  98. package/build/hooks/duotone.js.map +1 -1
  99. package/build/hooks/layout.js +19 -22
  100. package/build/hooks/layout.js.map +1 -1
  101. package/build/hooks/position.js +2 -2
  102. package/build/hooks/position.js.map +1 -1
  103. package/build/hooks/style.js +23 -26
  104. package/build/hooks/style.js.map +1 -1
  105. package/build/hooks/supports.js +7 -1
  106. package/build/hooks/supports.js.map +1 -1
  107. package/build/hooks/typography.js +2 -2
  108. package/build/hooks/typography.js.map +1 -1
  109. package/build/hooks/utils.js +50 -75
  110. package/build/hooks/utils.js.map +1 -1
  111. package/build/layouts/constrained.js +6 -2
  112. package/build/layouts/constrained.js.map +1 -1
  113. package/build/layouts/grid.js +165 -0
  114. package/build/layouts/grid.js.map +1 -0
  115. package/build/layouts/index.js +3 -1
  116. package/build/layouts/index.js.map +1 -1
  117. package/build/private-apis.js +7 -1
  118. package/build/private-apis.js.map +1 -1
  119. package/build/store/actions.js +10 -8
  120. package/build/store/actions.js.map +1 -1
  121. package/build/store/selectors.js +19 -3
  122. package/build/store/selectors.js.map +1 -1
  123. package/build/utils/object.js +76 -0
  124. package/build/utils/object.js.map +1 -0
  125. package/build/utils/parse-css-unit-to-px.js +15 -9
  126. package/build/utils/parse-css-unit-to-px.js.map +1 -1
  127. package/build-module/components/block-list/block-html.js +1 -3
  128. package/build-module/components/block-list/block-html.js.map +1 -1
  129. package/build-module/components/block-list/block-invalid-warning.js +66 -78
  130. package/build-module/components/block-list/block-invalid-warning.js.map +1 -1
  131. package/build-module/components/block-preview/auto.js +6 -22
  132. package/build-module/components/block-preview/auto.js.map +1 -1
  133. package/build-module/components/block-settings-menu-controls/index.js +1 -1
  134. package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
  135. package/build-module/components/block-switcher/block-transformations-menu.native.js +1 -0
  136. package/build-module/components/block-switcher/block-transformations-menu.native.js.map +1 -1
  137. package/build-module/components/convert-to-group-buttons/use-convert-to-group-button-props.js +6 -3
  138. package/build-module/components/convert-to-group-buttons/use-convert-to-group-button-props.js.map +1 -1
  139. package/build-module/components/editor-styles/index.js +19 -2
  140. package/build-module/components/editor-styles/index.js.map +1 -1
  141. package/build-module/components/global-styles/border-panel.js +291 -0
  142. package/build-module/components/global-styles/border-panel.js.map +1 -0
  143. package/build-module/components/global-styles/color-panel.js +554 -0
  144. package/build-module/components/global-styles/color-panel.js.map +1 -0
  145. package/build-module/components/global-styles/dimensions-panel.js +7 -30
  146. package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
  147. package/build-module/components/global-styles/get-block-css-selector.js +120 -0
  148. package/build-module/components/global-styles/get-block-css-selector.js.map +1 -0
  149. package/build-module/components/global-styles/hooks.js +104 -3
  150. package/build-module/components/global-styles/hooks.js.map +1 -1
  151. package/build-module/components/global-styles/index.js +3 -0
  152. package/build-module/components/global-styles/index.js.map +1 -1
  153. package/build-module/components/global-styles/typography-panel.js +65 -46
  154. package/build-module/components/global-styles/typography-panel.js.map +1 -1
  155. package/build-module/components/global-styles/use-global-styles-output.js +181 -100
  156. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  157. package/build-module/components/global-styles/utils.js +2 -1
  158. package/build-module/components/global-styles/utils.js.map +1 -1
  159. package/build-module/components/image-size-control/index.js +8 -5
  160. package/build-module/components/image-size-control/index.js.map +1 -1
  161. package/build-module/components/inserter/index.js +28 -16
  162. package/build-module/components/inserter/index.js.map +1 -1
  163. package/build-module/components/inserter/menu.js +1 -1
  164. package/build-module/components/inserter/menu.js.map +1 -1
  165. package/build-module/components/inserter/quick-inserter.js +4 -2
  166. package/build-module/components/inserter/quick-inserter.js.map +1 -1
  167. package/build-module/components/inserter/search-results.js +10 -3
  168. package/build-module/components/inserter/search-results.js.map +1 -1
  169. package/build-module/components/inserter/tabs.js +1 -1
  170. package/build-module/components/inserter/tabs.js.map +1 -1
  171. package/build-module/components/inspector-controls-tabs/position-controls-panel.js +42 -7
  172. package/build-module/components/inspector-controls-tabs/position-controls-panel.js.map +1 -1
  173. package/build-module/components/line-height-control/index.js +15 -1
  174. package/build-module/components/line-height-control/index.js.map +1 -1
  175. package/build-module/components/link-control/index.js +1 -1
  176. package/build-module/components/link-control/index.js.map +1 -1
  177. package/build-module/components/link-control/search-item.js +4 -2
  178. package/build-module/components/link-control/search-item.js.map +1 -1
  179. package/build-module/components/list-view/appender.js +88 -0
  180. package/build-module/components/list-view/appender.js.map +1 -0
  181. package/build-module/components/list-view/block.js +5 -4
  182. package/build-module/components/list-view/block.js.map +1 -1
  183. package/build-module/components/list-view/branch.js +22 -5
  184. package/build-module/components/list-view/branch.js.map +1 -1
  185. package/build-module/components/list-view/index.js +32 -12
  186. package/build-module/components/list-view/index.js.map +1 -1
  187. package/build-module/components/list-view/use-block-selection.js +1 -2
  188. package/build-module/components/list-view/use-block-selection.js.map +1 -1
  189. package/build-module/components/media-replace-flow/index.js +12 -4
  190. package/build-module/components/media-replace-flow/index.js.map +1 -1
  191. package/build-module/components/off-canvas-editor/appender.js +28 -4
  192. package/build-module/components/off-canvas-editor/appender.js.map +1 -1
  193. package/build-module/components/off-canvas-editor/branch.js +5 -3
  194. package/build-module/components/off-canvas-editor/branch.js.map +1 -1
  195. package/build-module/components/off-canvas-editor/index.js +9 -7
  196. package/build-module/components/off-canvas-editor/index.js.map +1 -1
  197. package/build-module/components/off-canvas-editor/link-ui.js +0 -1
  198. package/build-module/components/off-canvas-editor/link-ui.js.map +1 -1
  199. package/build-module/components/provider/use-block-sync.js +17 -3
  200. package/build-module/components/provider/use-block-sync.js.map +1 -1
  201. package/build-module/components/rich-text/format-edit.js +3 -31
  202. package/build-module/components/rich-text/format-edit.js.map +1 -1
  203. package/build-module/components/rich-text/format-toolbar-container.js +0 -3
  204. package/build-module/components/rich-text/format-toolbar-container.js.map +1 -1
  205. package/build-module/components/writing-flow/use-input.js +4 -8
  206. package/build-module/components/writing-flow/use-input.js.map +1 -1
  207. package/build-module/hooks/border.js +92 -240
  208. package/build-module/hooks/border.js.map +1 -1
  209. package/build-module/hooks/color.js +90 -232
  210. package/build-module/hooks/color.js.map +1 -1
  211. package/build-module/hooks/content-lock-ui.js +4 -2
  212. package/build-module/hooks/content-lock-ui.js.map +1 -1
  213. package/build-module/hooks/{color-panel.js → contrast-checker.js} +10 -44
  214. package/build-module/hooks/contrast-checker.js.map +1 -0
  215. package/build-module/hooks/custom-class-name.js +4 -4
  216. package/build-module/hooks/custom-class-name.js.map +1 -1
  217. package/build-module/hooks/custom-class-name.native.js +3 -4
  218. package/build-module/hooks/custom-class-name.native.js.map +1 -1
  219. package/build-module/hooks/dimensions.js +0 -1
  220. package/build-module/hooks/dimensions.js.map +1 -1
  221. package/build-module/hooks/duotone.js +4 -2
  222. package/build-module/hooks/duotone.js.map +1 -1
  223. package/build-module/hooks/layout.js +19 -22
  224. package/build-module/hooks/layout.js.map +1 -1
  225. package/build-module/hooks/position.js +3 -3
  226. package/build-module/hooks/position.js.map +1 -1
  227. package/build-module/hooks/style.js +23 -26
  228. package/build-module/hooks/style.js.map +1 -1
  229. package/build-module/hooks/supports.js +7 -1
  230. package/build-module/hooks/supports.js.map +1 -1
  231. package/build-module/hooks/typography.js +2 -2
  232. package/build-module/hooks/typography.js.map +1 -1
  233. package/build-module/hooks/utils.js +48 -72
  234. package/build-module/hooks/utils.js.map +1 -1
  235. package/build-module/layouts/constrained.js +6 -2
  236. package/build-module/layouts/constrained.js.map +1 -1
  237. package/build-module/layouts/grid.js +151 -0
  238. package/build-module/layouts/grid.js.map +1 -0
  239. package/build-module/layouts/index.js +2 -1
  240. package/build-module/layouts/index.js.map +1 -1
  241. package/build-module/private-apis.js +5 -1
  242. package/build-module/private-apis.js.map +1 -1
  243. package/build-module/store/actions.js +10 -8
  244. package/build-module/store/actions.js.map +1 -1
  245. package/build-module/store/selectors.js +17 -3
  246. package/build-module/store/selectors.js.map +1 -1
  247. package/build-module/utils/object.js +69 -0
  248. package/build-module/utils/object.js.map +1 -0
  249. package/build-module/utils/parse-css-unit-to-px.js +15 -9
  250. package/build-module/utils/parse-css-unit-to-px.js.map +1 -1
  251. package/build-style/style-rtl.css +32 -12
  252. package/build-style/style.css +32 -12
  253. package/package.json +31 -31
  254. package/src/components/block-draggable/content.scss +1 -1
  255. package/src/components/block-inspector/style.scss +3 -0
  256. package/src/components/block-list/block-html.js +1 -1
  257. package/src/components/block-list/block-invalid-warning.js +72 -64
  258. package/src/components/block-mover/test/__snapshots__/index.native.js.snap +20 -2
  259. package/src/components/block-preview/auto.js +2 -17
  260. package/src/components/block-preview/test/index.js +0 -2
  261. package/src/components/block-settings-menu-controls/index.js +2 -1
  262. package/src/components/block-styles/style.scss +2 -2
  263. package/src/components/block-switcher/block-transformations-menu.native.js +1 -0
  264. package/src/components/color-palette/test/__snapshots__/control.js.snap +16 -14
  265. package/src/components/colors-gradients/style.scss +8 -8
  266. package/src/components/convert-to-group-buttons/use-convert-to-group-button-props.js +48 -38
  267. package/src/components/editor-styles/index.js +29 -1
  268. package/src/components/global-styles/border-panel.js +285 -0
  269. package/src/components/global-styles/color-panel.js +706 -0
  270. package/src/components/global-styles/dimensions-panel.js +13 -42
  271. package/src/components/global-styles/get-block-css-selector.js +129 -0
  272. package/src/components/global-styles/hooks.js +154 -1
  273. package/src/components/global-styles/index.js +3 -0
  274. package/src/components/global-styles/test/use-global-styles-output.js +31 -2
  275. package/src/components/global-styles/typography-panel.js +67 -45
  276. package/src/components/global-styles/use-global-styles-output.js +176 -93
  277. package/src/components/global-styles/utils.js +3 -0
  278. package/src/components/image-size-control/index.js +4 -3
  279. package/src/components/image-size-control/test/index.js +2 -2
  280. package/src/components/inner-blocks/README.md +1 -1
  281. package/src/components/inserter/index.js +30 -11
  282. package/src/components/inserter/menu.js +0 -1
  283. package/src/components/inserter/quick-inserter.js +2 -0
  284. package/src/components/inserter/search-results.js +7 -1
  285. package/src/components/inserter/style.scss +3 -0
  286. package/src/components/inserter/tabs.js +1 -9
  287. package/src/components/inspector-controls-tabs/position-controls-panel.js +40 -9
  288. package/src/components/line-height-control/index.js +10 -1
  289. package/src/components/link-control/index.js +1 -1
  290. package/src/components/link-control/search-item.js +3 -1
  291. package/src/components/link-control/style.scss +0 -4
  292. package/src/components/link-control/test/index.js +0 -2
  293. package/src/components/list-view/appender.js +101 -0
  294. package/src/components/list-view/block.js +5 -4
  295. package/src/components/list-view/branch.js +30 -1
  296. package/src/components/list-view/index.js +43 -10
  297. package/src/components/list-view/style.scss +19 -0
  298. package/src/components/list-view/use-block-selection.js +0 -2
  299. package/src/components/media-replace-flow/index.js +36 -24
  300. package/src/components/media-replace-flow/style.scss +5 -2
  301. package/src/components/off-canvas-editor/appender.js +31 -5
  302. package/src/components/off-canvas-editor/branch.js +3 -1
  303. package/src/components/off-canvas-editor/index.js +7 -7
  304. package/src/components/off-canvas-editor/link-ui.js +0 -1
  305. package/src/components/provider/use-block-sync.js +21 -4
  306. package/src/components/rich-text/format-edit.js +2 -32
  307. package/src/components/rich-text/format-toolbar-container.js +1 -7
  308. package/src/components/url-popover/test/index.js +0 -2
  309. package/src/components/writing-flow/use-input.js +4 -5
  310. package/src/hooks/border.js +93 -225
  311. package/src/hooks/color.js +120 -296
  312. package/src/hooks/content-lock-ui.js +6 -2
  313. package/src/hooks/{color-panel.js → contrast-checker.js} +10 -46
  314. package/src/hooks/custom-class-name.js +4 -4
  315. package/src/hooks/custom-class-name.native.js +3 -4
  316. package/src/hooks/dimensions.js +0 -1
  317. package/src/hooks/duotone.js +8 -5
  318. package/src/hooks/layout.js +19 -16
  319. package/src/hooks/position.js +3 -3
  320. package/src/hooks/style.js +29 -28
  321. package/src/hooks/supports.js +6 -0
  322. package/src/hooks/test/style.js +2 -1
  323. package/src/hooks/test/use-typography-props.js +2 -0
  324. package/src/hooks/test/utils.js +0 -104
  325. package/src/hooks/typography.js +2 -1
  326. package/src/hooks/utils.js +63 -70
  327. package/src/layouts/constrained.js +23 -17
  328. package/src/layouts/grid.js +172 -0
  329. package/src/layouts/index.js +2 -1
  330. package/src/layouts/test/grid.js +21 -0
  331. package/src/private-apis.js +4 -0
  332. package/src/store/actions.js +10 -8
  333. package/src/store/selectors.js +20 -3
  334. package/src/utils/object.js +69 -0
  335. package/src/utils/parse-css-unit-to-px.js +14 -9
  336. package/src/utils/test/object.js +107 -0
  337. package/src/utils/test/parse-css-unit-to-px.js +1 -2
  338. package/tsconfig.tsbuildinfo +1 -1
  339. package/build/hooks/border-radius.js +0 -100
  340. package/build/hooks/border-radius.js.map +0 -1
  341. package/build/hooks/color-panel.js.map +0 -1
  342. package/build-module/hooks/border-radius.js +0 -84
  343. package/build-module/hooks/border-radius.js.map +0 -1
  344. package/build-module/hooks/color-panel.js.map +0 -1
  345. package/src/hooks/border-radius.js +0 -70
@@ -10,13 +10,14 @@ import { get, isEmpty, kebabCase, set } from 'lodash';
10
10
 
11
11
  import { __EXPERIMENTAL_STYLE_PROPERTY as STYLE_PROPERTY, __EXPERIMENTAL_ELEMENTS as ELEMENTS, getBlockTypes, store as blocksStore } from '@wordpress/blocks';
12
12
  import { useSelect } from '@wordpress/data';
13
- import { useContext, useMemo } from '@wordpress/element';
13
+ import { renderToString, useContext, useMemo } from '@wordpress/element';
14
14
  import { getCSSRules } from '@wordpress/style-engine';
15
15
  /**
16
16
  * Internal dependencies
17
17
  */
18
18
 
19
19
  import { PRESET_METADATA, ROOT_BLOCK_SELECTOR, scopeSelector } from './utils';
20
+ import { getBlockCSSSelector } from './get-block-css-selector';
20
21
  import { getTypographyFontSizeValue } from './typography-utils';
21
22
  import { GlobalStylesContext } from './context';
22
23
  import { useGlobalSetting } from './hooks';
@@ -84,13 +85,14 @@ function getPresetsDeclarations() {
84
85
  /**
85
86
  * Transform given preset tree into a set of preset class declarations.
86
87
  *
87
- * @param {string} blockSelector
88
- * @param {Object} blockPresets
88
+ * @param {?string} blockSelector
89
+ * @param {Object} blockPresets
89
90
  * @return {string} CSS declarations for the preset classes.
90
91
  */
91
92
 
92
93
 
93
- function getPresetsClasses(blockSelector) {
94
+ function getPresetsClasses() {
95
+ let blockSelector = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '*';
94
96
  let blockPresets = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
95
97
  return PRESET_METADATA.reduce((declarations, _ref2) => {
96
98
  let {
@@ -133,10 +135,10 @@ function getPresetsSvgFilters() {
133
135
  return PRESET_METADATA.filter( // Duotone are the only type of filters for now.
134
136
  metadata => metadata.path.at(-1) === 'duotone').flatMap(metadata => {
135
137
  const presetByOrigin = get(blockPresets, metadata.path, {});
136
- return ['default', 'theme'].filter(origin => presetByOrigin[origin]).flatMap(origin => presetByOrigin[origin].map(preset => createElement(PresetDuotoneFilter, {
138
+ return ['default', 'theme'].filter(origin => presetByOrigin[origin]).flatMap(origin => presetByOrigin[origin].map(preset => renderToString(createElement(PresetDuotoneFilter, {
137
139
  preset: preset,
138
140
  key: preset.slug
139
- })));
141
+ })))).join('');
140
142
  });
141
143
  }
142
144
 
@@ -177,6 +179,76 @@ function concatFeatureVariationSelectorString(featureSelector, styleVariationSel
177
179
  });
178
180
  return combinedSelectors.join(', ');
179
181
  }
182
+ /**
183
+ * Generate style declarations for a block's custom feature and subfeature
184
+ * selectors.
185
+ *
186
+ * NOTE: The passed `styles` object will be mutated by this function.
187
+ *
188
+ * @param {Object} selectors Custom selectors object for a block.
189
+ * @param {Object} styles A block's styles object.
190
+ *
191
+ * @return {Object} Style declarations.
192
+ */
193
+
194
+
195
+ const getFeatureDeclarations = (selectors, styles) => {
196
+ const declarations = {};
197
+ Object.entries(selectors).forEach(_ref5 => {
198
+ let [feature, selector] = _ref5;
199
+
200
+ // We're only processing features/subfeatures that have styles.
201
+ if (feature === 'root' || !(styles !== null && styles !== void 0 && styles[feature])) {
202
+ return;
203
+ }
204
+
205
+ const isShorthand = typeof selector === 'string'; // If we have a selector object instead of shorthand process it.
206
+
207
+ if (!isShorthand) {
208
+ Object.entries(selector).forEach(_ref6 => {
209
+ let [subfeature, subfeatureSelector] = _ref6;
210
+
211
+ // Don't process root feature selector yet or any
212
+ // subfeature that doesn't have a style.
213
+ if (subfeature === 'root' || !(styles !== null && styles !== void 0 && styles[feature][subfeature])) {
214
+ return;
215
+ } // Create a temporary styles object and build
216
+ // declarations for subfeature.
217
+
218
+
219
+ const subfeatureStyles = {
220
+ [feature]: {
221
+ [subfeature]: styles[feature][subfeature]
222
+ }
223
+ };
224
+ const newDeclarations = getStylesDeclarations(subfeatureStyles); // Merge new declarations in with any others that
225
+ // share the same selector.
226
+
227
+ declarations[subfeatureSelector] = [...(declarations[subfeatureSelector] || []), ...newDeclarations]; // Remove the subfeature's style now it will be
228
+ // included under its own selector not the block's.
229
+
230
+ delete styles[feature][subfeature];
231
+ });
232
+ } // Now subfeatures have been processed and removed, we can
233
+ // process root, or shorthand, feature selectors.
234
+
235
+
236
+ if (isShorthand || selector.root) {
237
+ const featureSelector = isShorthand ? selector : selector.root; // Create temporary style object and build declarations for feature.
238
+
239
+ const featureStyles = {
240
+ [feature]: styles[feature]
241
+ };
242
+ const newDeclarations = getStylesDeclarations(featureStyles); // Merge new declarations with any others that share the selector.
243
+
244
+ declarations[featureSelector] = [...(declarations[featureSelector] || []), ...newDeclarations]; // Remove the feature from the block's styles now as it will be
245
+ // included under its own selector not the block's.
246
+
247
+ delete styles[feature];
248
+ }
249
+ });
250
+ return declarations;
251
+ };
180
252
  /**
181
253
  * Transform given style tree into a set of style declarations.
182
254
  *
@@ -198,13 +270,13 @@ export function getStylesDeclarations() {
198
270
  let useRootPaddingAlign = arguments.length > 2 ? arguments[2] : undefined;
199
271
  let tree = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
200
272
  const isRoot = ROOT_BLOCK_SELECTOR === selector;
201
- const output = Object.entries(STYLE_PROPERTY).reduce((declarations, _ref5) => {
273
+ const output = Object.entries(STYLE_PROPERTY).reduce((declarations, _ref7) => {
202
274
  let [key, {
203
275
  value,
204
276
  properties,
205
277
  useEngine,
206
278
  rootOnly
207
- }] = _ref5;
279
+ }] = _ref7;
208
280
 
209
281
  if (rootOnly && !isRoot) {
210
282
  return declarations;
@@ -303,7 +375,7 @@ export function getStylesDeclarations() {
303
375
  * @return {string} Generated CSS rules for the layout styles.
304
376
  */
305
377
 
306
- export function getLayoutStyles(_ref6) {
378
+ export function getLayoutStyles(_ref8) {
307
379
  var _style$spacing, _tree$settings2, _tree$settings2$layou, _tree$settings3, _tree$settings3$layou;
308
380
 
309
381
  let {
@@ -313,7 +385,7 @@ export function getLayoutStyles(_ref6) {
313
385
  hasBlockGapSupport,
314
386
  hasFallbackGapSupport,
315
387
  fallbackGapValue
316
- } = _ref6;
388
+ } = _ref8;
317
389
  let ruleset = '';
318
390
  let gapValue = hasBlockGapSupport ? 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,
319
391
  // and use a fallback value if one is provided for the current block.
@@ -327,12 +399,12 @@ export function getLayoutStyles(_ref6) {
327
399
  }
328
400
 
329
401
  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) {
330
- Object.values(tree.settings.layout.definitions).forEach(_ref7 => {
402
+ Object.values(tree.settings.layout.definitions).forEach(_ref9 => {
331
403
  let {
332
404
  className,
333
405
  name,
334
406
  spacingStyles
335
- } = _ref7;
407
+ } = _ref9;
336
408
 
337
409
  // Allow outputting fallback gap styles for flex layout type when block gap support isn't available.
338
410
  if (!hasBlockGapSupport && 'flex' !== name) {
@@ -344,8 +416,8 @@ export function getLayoutStyles(_ref6) {
344
416
  const declarations = [];
345
417
 
346
418
  if (spacingStyle.rules) {
347
- Object.entries(spacingStyle.rules).forEach(_ref8 => {
348
- let [cssProperty, cssValue] = _ref8;
419
+ Object.entries(spacingStyle.rules).forEach(_ref10 => {
420
+ let [cssProperty, cssValue] = _ref10;
349
421
  declarations.push(`${cssProperty}: ${cssValue ? cssValue : gapValue}`);
350
422
  });
351
423
  }
@@ -357,7 +429,7 @@ export function getLayoutStyles(_ref6) {
357
429
  // For fallback gap styles, use lower specificity, to ensure styles do not unintentionally override theme styles.
358
430
  combinedSelector = selector === 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) || ''})`;
359
431
  } else {
360
- combinedSelector = selector === 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) || ''}`;
432
+ combinedSelector = selector === ROOT_BLOCK_SELECTOR ? `${selector} .${className}${(spacingStyle === null || spacingStyle === void 0 ? void 0 : spacingStyle.selector) || ''}` : `${selector}-${className}${selector}-${className}${(spacingStyle === null || spacingStyle === void 0 ? void 0 : spacingStyle.selector) || ''}`;
361
433
  }
362
434
 
363
435
  ruleset += `${combinedSelector} { ${declarations.join('; ')}; }`;
@@ -374,12 +446,12 @@ export function getLayoutStyles(_ref6) {
374
446
 
375
447
  if (selector === 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) {
376
448
  const validDisplayModes = ['block', 'flex', 'grid'];
377
- Object.values(tree.settings.layout.definitions).forEach(_ref9 => {
449
+ Object.values(tree.settings.layout.definitions).forEach(_ref11 => {
378
450
  let {
379
451
  className,
380
452
  displayMode,
381
453
  baseStyles
382
- } = _ref9;
454
+ } = _ref11;
383
455
 
384
456
  if (displayMode && validDisplayModes.includes(displayMode)) {
385
457
  ruleset += `${selector} .${className} { display:${displayMode}; }`;
@@ -390,8 +462,8 @@ export function getLayoutStyles(_ref6) {
390
462
  const declarations = [];
391
463
 
392
464
  if (baseStyle.rules) {
393
- Object.entries(baseStyle.rules).forEach(_ref10 => {
394
- let [cssProperty, cssValue] = _ref10;
465
+ Object.entries(baseStyle.rules).forEach(_ref12 => {
466
+ let [cssProperty, cssValue] = _ref12;
395
467
  declarations.push(`${cssProperty}: ${cssValue}`);
396
468
  });
397
469
  }
@@ -416,8 +488,8 @@ export const getNodesWithStyles = (tree, blockSelectors) => {
416
488
  return nodes;
417
489
  }
418
490
 
419
- const pickStyleKeys = treeToPickFrom => Object.fromEntries(Object.entries(treeToPickFrom !== null && treeToPickFrom !== void 0 ? treeToPickFrom : {}).filter(_ref11 => {
420
- let [key] = _ref11;
491
+ const pickStyleKeys = treeToPickFrom => Object.fromEntries(Object.entries(treeToPickFrom !== null && treeToPickFrom !== void 0 ? treeToPickFrom : {}).filter(_ref13 => {
492
+ let [key] = _ref13;
421
493
  return ['border', 'color', 'dimensions', 'spacing', 'typography', 'filter', 'outline', 'shadow'].includes(key);
422
494
  })); // Top-level.
423
495
 
@@ -431,25 +503,25 @@ export const getNodesWithStyles = (tree, blockSelectors) => {
431
503
  });
432
504
  }
433
505
 
434
- Object.entries(ELEMENTS).forEach(_ref12 => {
435
- var _tree$styles;
506
+ Object.entries(ELEMENTS).forEach(_ref14 => {
507
+ var _tree$styles, _tree$styles$elements;
436
508
 
437
- let [name, selector] = _ref12;
509
+ let [name, selector] = _ref14;
438
510
 
439
- if (!!((_tree$styles = tree.styles) !== null && _tree$styles !== void 0 && _tree$styles.elements[name])) {
440
- var _tree$styles2;
511
+ if (!!((_tree$styles = tree.styles) !== null && _tree$styles !== void 0 && (_tree$styles$elements = _tree$styles.elements) !== null && _tree$styles$elements !== void 0 && _tree$styles$elements[name])) {
512
+ var _tree$styles2, _tree$styles2$element;
441
513
 
442
514
  nodes.push({
443
- styles: (_tree$styles2 = tree.styles) === null || _tree$styles2 === void 0 ? void 0 : _tree$styles2.elements[name],
515
+ styles: (_tree$styles2 = tree.styles) === null || _tree$styles2 === void 0 ? void 0 : (_tree$styles2$element = _tree$styles2.elements) === null || _tree$styles2$element === void 0 ? void 0 : _tree$styles2$element[name],
444
516
  selector
445
517
  });
446
518
  }
447
519
  }); // Iterate over blocks: they can have styles & elements.
448
520
 
449
- 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 => {
521
+ 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(_ref15 => {
450
522
  var _blockSelectors$block, _node$elements;
451
523
 
452
- let [blockName, node] = _ref13;
524
+ let [blockName, node] = _ref15;
453
525
  const blockStyles = pickStyleKeys(node);
454
526
 
455
527
  if (node !== null && node !== void 0 && node.variations) {
@@ -461,24 +533,28 @@ export const getNodesWithStyles = (tree, blockSelectors) => {
461
533
  }
462
534
 
463
535
  if (!!blockStyles && !!(blockSelectors !== null && blockSelectors !== void 0 && (_blockSelectors$block = blockSelectors[blockName]) !== null && _blockSelectors$block !== void 0 && _blockSelectors$block.selector)) {
536
+ var _blockSelectors$block2;
537
+
464
538
  nodes.push({
465
539
  duotoneSelector: blockSelectors[blockName].duotoneSelector,
466
540
  fallbackGapValue: blockSelectors[blockName].fallbackGapValue,
467
541
  hasLayoutSupport: blockSelectors[blockName].hasLayoutSupport,
468
- selector: blockSelectors[blockName].selector,
542
+ selector: (_blockSelectors$block2 = blockSelectors[blockName]) === null || _blockSelectors$block2 === void 0 ? void 0 : _blockSelectors$block2.selector,
469
543
  styles: blockStyles,
470
544
  featureSelectors: blockSelectors[blockName].featureSelectors,
471
545
  styleVariationSelectors: blockSelectors[blockName].styleVariationSelectors
472
546
  });
473
547
  }
474
548
 
475
- Object.entries((_node$elements = node === null || node === void 0 ? void 0 : node.elements) !== null && _node$elements !== void 0 ? _node$elements : {}).forEach(_ref14 => {
476
- let [elementName, value] = _ref14;
549
+ Object.entries((_node$elements = node === null || node === void 0 ? void 0 : node.elements) !== null && _node$elements !== void 0 ? _node$elements : {}).forEach(_ref16 => {
550
+ let [elementName, value] = _ref16;
477
551
 
478
552
  if (!!value && !!(blockSelectors !== null && blockSelectors !== void 0 && blockSelectors[blockName]) && !!(ELEMENTS !== null && ELEMENTS !== void 0 && ELEMENTS[elementName])) {
553
+ var _blockSelectors$block3;
554
+
479
555
  nodes.push({
480
556
  styles: value,
481
- selector: blockSelectors[blockName].selector.split(',').map(sel => {
557
+ selector: (_blockSelectors$block3 = blockSelectors[blockName]) === null || _blockSelectors$block3 === void 0 ? void 0 : _blockSelectors$block3.selector.split(',').map(sel => {
482
558
  const elementSelectors = ELEMENTS[elementName].split(',');
483
559
  return elementSelectors.map(elementSelector => sel + ' ' + elementSelector);
484
560
  }).join(',')
@@ -499,10 +575,10 @@ export const getNodesWithSettings = (tree, blockSelectors) => {
499
575
 
500
576
  const pickPresets = treeToPickFrom => {
501
577
  const presets = {};
502
- PRESET_METADATA.forEach(_ref15 => {
578
+ PRESET_METADATA.forEach(_ref17 => {
503
579
  let {
504
580
  path
505
- } = _ref15;
581
+ } = _ref17;
506
582
  const value = get(treeToPickFrom, path, false);
507
583
 
508
584
  if (value !== false) {
@@ -525,16 +601,18 @@ export const getNodesWithSettings = (tree, blockSelectors) => {
525
601
  } // Blocks.
526
602
 
527
603
 
528
- 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 => {
529
- let [blockName, node] = _ref16;
604
+ 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(_ref18 => {
605
+ let [blockName, node] = _ref18;
530
606
  const blockPresets = pickPresets(node);
531
607
  const blockCustom = node.custom;
532
608
 
533
609
  if (!isEmpty(blockPresets) || !!blockCustom) {
610
+ var _blockSelectors$block4;
611
+
534
612
  nodes.push({
535
613
  presets: blockPresets,
536
614
  custom: blockCustom,
537
- selector: blockSelectors[blockName].selector
615
+ selector: (_blockSelectors$block4 = blockSelectors[blockName]) === null || _blockSelectors$block4 === void 0 ? void 0 : _blockSelectors$block4.selector
538
616
  });
539
617
  }
540
618
  });
@@ -543,12 +621,12 @@ export const getNodesWithSettings = (tree, blockSelectors) => {
543
621
  export const toCustomProperties = (tree, blockSelectors) => {
544
622
  const settings = getNodesWithSettings(tree, blockSelectors);
545
623
  let ruleset = '';
546
- settings.forEach(_ref17 => {
624
+ settings.forEach(_ref19 => {
547
625
  let {
548
626
  presets,
549
627
  custom,
550
628
  selector
551
- } = _ref17;
629
+ } = _ref19;
552
630
  const declarations = getPresetsDeclarations(presets, tree === null || tree === void 0 ? void 0 : tree.settings);
553
631
  const customProps = flattenTree(custom, '--wp--custom--', '--');
554
632
 
@@ -607,7 +685,7 @@ export const toStyles = function (tree, blockSelectors, hasBlockGapSupport, hasF
607
685
  }
608
686
 
609
687
  ruleset += '}';
610
- nodesWithStyles.forEach(_ref18 => {
688
+ nodesWithStyles.forEach(_ref20 => {
611
689
  let {
612
690
  selector,
613
691
  duotoneSelector,
@@ -616,54 +694,43 @@ export const toStyles = function (tree, blockSelectors, hasBlockGapSupport, hasF
616
694
  hasLayoutSupport,
617
695
  featureSelectors,
618
696
  styleVariationSelectors
619
- } = _ref18;
697
+ } = _ref20;
620
698
 
621
699
  // Process styles for block support features with custom feature level
622
700
  // CSS selectors set.
623
701
  if (featureSelectors) {
624
- Object.entries(featureSelectors).forEach(_ref19 => {
625
- let [featureName, featureSelector] = _ref19;
626
-
627
- if (styles !== null && styles !== void 0 && styles[featureName]) {
628
- const featureStyles = {
629
- [featureName]: styles[featureName]
630
- };
631
- const featureDeclarations = getStylesDeclarations(featureStyles);
632
- delete styles[featureName];
633
-
634
- if (!!featureDeclarations.length) {
635
- ruleset = ruleset + `${featureSelector}{${featureDeclarations.join(';')} }`;
636
- }
702
+ const featureDeclarations = getFeatureDeclarations(featureSelectors, styles);
703
+ Object.entries(featureDeclarations).forEach(_ref21 => {
704
+ let [cssSelector, declarations] = _ref21;
705
+
706
+ if (!!declarations.length) {
707
+ const rules = declarations.join(';');
708
+ ruleset = ruleset + `${cssSelector}{${rules}}`;
637
709
  }
638
710
  });
639
711
  }
640
712
 
641
713
  if (styleVariationSelectors) {
642
- Object.entries(styleVariationSelectors).forEach(_ref20 => {
714
+ Object.entries(styleVariationSelectors).forEach(_ref22 => {
643
715
  var _styles$variations;
644
716
 
645
- let [styleVariationName, styleVariationSelector] = _ref20;
717
+ let [styleVariationName, styleVariationSelector] = _ref22;
646
718
 
647
719
  if (styles !== null && styles !== void 0 && (_styles$variations = styles.variations) !== null && _styles$variations !== void 0 && _styles$variations[styleVariationName]) {
648
720
  var _styles$variations3;
649
721
 
650
722
  // If the block uses any custom selectors for block support, add those first.
651
723
  if (featureSelectors) {
652
- Object.entries(featureSelectors).forEach(_ref21 => {
653
- var _styles$variations2, _styles$variations2$s;
654
-
655
- let [featureName, featureSelector] = _ref21;
724
+ var _styles$variations2;
656
725
 
657
- 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]) {
658
- const featureStyles = {
659
- [featureName]: styles.variations[styleVariationName][featureName]
660
- };
661
- const featureDeclarations = getStylesDeclarations(featureStyles);
662
- delete styles.variations[styleVariationName][featureName];
726
+ const featureDeclarations = getFeatureDeclarations(featureSelectors, styles === null || styles === void 0 ? void 0 : (_styles$variations2 = styles.variations) === null || _styles$variations2 === void 0 ? void 0 : _styles$variations2[styleVariationName]);
727
+ Object.entries(featureDeclarations).forEach(_ref23 => {
728
+ let [baseSelector, declarations] = _ref23;
663
729
 
664
- if (!!featureDeclarations.length) {
665
- ruleset = ruleset + `${concatFeatureVariationSelectorString(featureSelector, styleVariationSelector)}{${featureDeclarations.join(';')} }`;
666
- }
730
+ if (!!declarations.length) {
731
+ const cssSelector = concatFeatureVariationSelectorString(baseSelector, styleVariationSelector);
732
+ const rules = declarations.join(';');
733
+ ruleset = ruleset + `${cssSelector}{${rules}}`;
667
734
  }
668
735
  });
669
736
  } // Otherwise add regular selectors.
@@ -714,14 +781,14 @@ export const toStyles = function (tree, blockSelectors, hasBlockGapSupport, hasF
714
781
  } // Check for pseudo selector in `styles` and handle separately.
715
782
 
716
783
 
717
- const pseudoSelectorStyles = Object.entries(styles).filter(_ref22 => {
718
- let [key] = _ref22;
784
+ const pseudoSelectorStyles = Object.entries(styles).filter(_ref24 => {
785
+ let [key] = _ref24;
719
786
  return key.startsWith(':');
720
787
  });
721
788
 
722
789
  if (pseudoSelectorStyles !== null && pseudoSelectorStyles !== void 0 && pseudoSelectorStyles.length) {
723
- pseudoSelectorStyles.forEach(_ref23 => {
724
- let [pseudoKey, pseudoStyle] = _ref23;
790
+ pseudoSelectorStyles.forEach(_ref25 => {
791
+ let [pseudoKey, pseudoStyle] = _ref25;
725
792
  const pseudoDeclarations = getStylesDeclarations(pseudoStyle);
726
793
 
727
794
  if (!(pseudoDeclarations !== null && pseudoDeclarations !== void 0 && pseudoDeclarations.length)) {
@@ -757,11 +824,11 @@ export const toStyles = function (tree, blockSelectors, hasBlockGapSupport, hasF
757
824
  ruleset = ruleset + `.wp-site-blocks > * + * { margin-block-start: ${gapValue}; }`;
758
825
  }
759
826
 
760
- nodesWithSettings.forEach(_ref24 => {
827
+ nodesWithSettings.forEach(_ref26 => {
761
828
  let {
762
829
  selector,
763
830
  presets
764
- } = _ref24;
831
+ } = _ref26;
765
832
 
766
833
  if (ROOT_BLOCK_SELECTOR === selector) {
767
834
  // Do not add extra specificity for top-level classes.
@@ -778,23 +845,43 @@ export const toStyles = function (tree, blockSelectors, hasBlockGapSupport, hasF
778
845
  };
779
846
  export function toSvgFilters(tree, blockSelectors) {
780
847
  const nodesWithSettings = getNodesWithSettings(tree, blockSelectors);
781
- return nodesWithSettings.flatMap(_ref25 => {
848
+ return nodesWithSettings.flatMap(_ref27 => {
782
849
  let {
783
850
  presets
784
- } = _ref25;
851
+ } = _ref27;
785
852
  return getPresetsSvgFilters(presets);
786
853
  });
787
854
  }
855
+
856
+ const getSelectorsConfig = (blockType, rootSelector) => {
857
+ if (!isEmpty(blockType === null || blockType === void 0 ? void 0 : blockType.selectors)) {
858
+ return blockType.selectors;
859
+ }
860
+
861
+ const config = {
862
+ root: rootSelector
863
+ };
864
+ Object.entries(BLOCK_SUPPORT_FEATURE_LEVEL_SELECTORS).forEach(_ref28 => {
865
+ let [featureKey, featureName] = _ref28;
866
+ const featureSelector = getBlockCSSSelector(blockType, featureKey);
867
+
868
+ if (featureSelector) {
869
+ config[featureName] = featureSelector;
870
+ }
871
+ });
872
+ return config;
873
+ };
874
+
788
875
  export const getBlockSelectors = (blockTypes, getBlockStyles) => {
789
876
  const result = {};
790
877
  blockTypes.forEach(blockType => {
791
- var _blockType$supports$_, _blockType$supports, _blockType$supports$c, _blockType$supports2, _blockType$supports2$, _blockType$supports3, _blockType$supports4, _blockType$supports4$, _blockType$supports4$2;
878
+ var _blockType$supports, _blockType$supports2, _blockType$supports2$, _blockType$supports2$2;
792
879
 
793
880
  const name = blockType.name;
794
- 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('/', '-');
795
- 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;
796
- const hasLayoutSupport = !!(blockType !== null && blockType !== void 0 && (_blockType$supports3 = blockType.supports) !== null && _blockType$supports3 !== void 0 && _blockType$supports3.__experimentalLayout);
797
- 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;
881
+ const selector = getBlockCSSSelector(blockType, 'root');
882
+ const duotoneSelector = getBlockCSSSelector(blockType, 'filter.duotone');
883
+ const hasLayoutSupport = !!(blockType !== null && blockType !== void 0 && (_blockType$supports = blockType.supports) !== null && _blockType$supports !== void 0 && _blockType$supports.__experimentalLayout);
884
+ const fallbackGapValue = blockType === null || blockType === void 0 ? void 0 : (_blockType$supports2 = blockType.supports) === null || _blockType$supports2 === void 0 ? void 0 : (_blockType$supports2$ = _blockType$supports2.spacing) === null || _blockType$supports2$ === void 0 ? void 0 : (_blockType$supports2$2 = _blockType$supports2$.blockGap) === null || _blockType$supports2$2 === void 0 ? void 0 : _blockType$supports2$2.__experimentalDefault;
798
885
  const blockStyleVariations = getBlockStyles(name);
799
886
  const styleVariationSelectors = {};
800
887
 
@@ -806,17 +893,7 @@ export const getBlockSelectors = (blockTypes, getBlockStyles) => {
806
893
  } // For each block support feature add any custom selectors.
807
894
 
808
895
 
809
- const featureSelectors = {};
810
- Object.entries(BLOCK_SUPPORT_FEATURE_LEVEL_SELECTORS).forEach(_ref26 => {
811
- var _blockType$supports5, _blockType$supports5$;
812
-
813
- let [featureKey, featureName] = _ref26;
814
- 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;
815
-
816
- if (featureSelector) {
817
- featureSelectors[featureName] = scopeSelector(selector, featureSelector);
818
- }
819
- });
896
+ const featureSelectors = getSelectorsConfig(blockType, selector);
820
897
  result[name] = {
821
898
  duotoneSelector,
822
899
  fallbackGapValue,
@@ -838,9 +915,9 @@ export const getBlockSelectors = (blockTypes, getBlockStyles) => {
838
915
  */
839
916
 
840
917
  function updateConfigWithSeparator(config) {
841
- var _config$styles, _config$styles2, _config$styles2$block, _config$styles3, _config$styles3$block, _config$styles4, _config$styles4$block;
918
+ var _config$styles, _config$styles$blocks, _config$styles2, _config$styles2$block, _config$styles2$block2, _config$styles3, _config$styles3$block, _config$styles3$block2, _config$styles4, _config$styles4$block, _config$styles4$block2;
842
919
 
843
- 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);
920
+ const needsSeparatorStyleUpdate = ((_config$styles = config.styles) === null || _config$styles === void 0 ? void 0 : (_config$styles$blocks = _config$styles.blocks) === null || _config$styles$blocks === 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) === null || _config$styles2$block === void 0 ? void 0 : (_config$styles2$block2 = _config$styles2$block['core/separator'].color) === null || _config$styles2$block2 === void 0 ? void 0 : _config$styles2$block2.background) && !((_config$styles3 = config.styles) !== null && _config$styles3 !== void 0 && (_config$styles3$block = _config$styles3.blocks) !== null && _config$styles3$block !== void 0 && (_config$styles3$block2 = _config$styles3$block['core/separator'].color) !== null && _config$styles3$block2 !== void 0 && _config$styles3$block2.text) && !((_config$styles4 = config.styles) !== null && _config$styles4 !== void 0 && (_config$styles4$block = _config$styles4.blocks) !== null && _config$styles4$block !== void 0 && (_config$styles4$block2 = _config$styles4$block['core/separator'].border) !== null && _config$styles4$block2 !== void 0 && _config$styles4$block2.color);
844
921
 
845
922
  if (needsSeparatorStyleUpdate) {
846
923
  var _config$styles5;
@@ -900,8 +977,8 @@ export function useGlobalStylesOutput() {
900
977
  const blockSelectors = getBlockSelectors(getBlockTypes(), getBlockStyles);
901
978
  const customProperties = toCustomProperties(mergedConfig, blockSelectors);
902
979
  const globalStyles = toStyles(mergedConfig, blockSelectors, hasBlockGapSupport, hasFallbackGapSupport, disableLayoutStyles);
903
- const filters = toSvgFilters(mergedConfig, blockSelectors);
904
- const stylesheets = [{
980
+ const svgs = toSvgFilters(mergedConfig, blockSelectors);
981
+ const styles = [{
905
982
  css: customProperties,
906
983
  isGlobalStyles: true
907
984
  }, {
@@ -911,6 +988,10 @@ export function useGlobalStylesOutput() {
911
988
  {
912
989
  css: (_mergedConfig$styles$ = mergedConfig.styles.css) !== null && _mergedConfig$styles$ !== void 0 ? _mergedConfig$styles$ : '',
913
990
  isGlobalStyles: true
991
+ }, {
992
+ assets: svgs,
993
+ __unstableType: 'svg',
994
+ isGlobalStyles: true
914
995
  }]; // Loop through the blocks to check if there are custom CSS values.
915
996
  // If there are, get the block selector and push the selector together with
916
997
  // the CSS value to the 'stylesheets' array.
@@ -922,13 +1003,13 @@ export function useGlobalStylesOutput() {
922
1003
  var _mergedConfig$styles$3;
923
1004
 
924
1005
  const selector = blockSelectors[blockType.name].selector;
925
- stylesheets.push({
1006
+ styles.push({
926
1007
  css: processCSSNesting((_mergedConfig$styles$3 = mergedConfig.styles.blocks[blockType.name]) === null || _mergedConfig$styles$3 === void 0 ? void 0 : _mergedConfig$styles$3.css, selector),
927
1008
  isGlobalStyles: true
928
1009
  });
929
1010
  }
930
1011
  });
931
- return [stylesheets, mergedConfig.settings, filters];
1012
+ return [styles, mergedConfig.settings];
932
1013
  }, [hasBlockGapSupport, hasFallbackGapSupport, mergedConfig, disableLayoutStyles]);
933
1014
  }
934
1015
  //# sourceMappingURL=use-global-styles-output.js.map