@wordpress/block-editor 11.4.0 → 11.6.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 (400) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/build/components/block-inspector/index.js +11 -10
  3. package/build/components/block-inspector/index.js.map +1 -1
  4. package/build/components/block-inspector/useBlockInspectorAnimationSettings.js +46 -0
  5. package/build/components/block-inspector/useBlockInspectorAnimationSettings.js.map +1 -0
  6. package/build/components/block-list/block-invalid-warning.js +63 -80
  7. package/build/components/block-list/block-invalid-warning.js.map +1 -1
  8. package/build/components/block-lock/modal.js +1 -0
  9. package/build/components/block-lock/modal.js.map +1 -1
  10. package/build/components/block-settings-menu/block-settings-dropdown.js +2 -2
  11. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  12. package/build/components/block-settings-menu-controls/index.js +1 -1
  13. package/build/components/block-settings-menu-controls/index.js.map +1 -1
  14. package/build/components/block-styles/index.js +2 -1
  15. package/build/components/block-styles/index.js.map +1 -1
  16. package/build/components/block-switcher/block-transformations-menu.native.js +1 -0
  17. package/build/components/block-switcher/block-transformations-menu.native.js.map +1 -1
  18. package/build/components/child-layout-control/index.js +107 -0
  19. package/build/components/child-layout-control/index.js.map +1 -0
  20. package/build/components/convert-to-group-buttons/use-convert-to-group-button-props.js +6 -3
  21. package/build/components/convert-to-group-buttons/use-convert-to-group-button-props.js.map +1 -1
  22. package/build/components/date-format-picker/index.js +3 -3
  23. package/build/components/date-format-picker/index.js.map +1 -1
  24. package/build/components/global-styles/border-panel.js +306 -0
  25. package/build/components/global-styles/border-panel.js.map +1 -0
  26. package/build/components/global-styles/dimensions-panel.js +594 -0
  27. package/build/components/global-styles/dimensions-panel.js.map +1 -0
  28. package/build/components/global-styles/hooks.js +127 -37
  29. package/build/components/global-styles/hooks.js.map +1 -1
  30. package/build/components/global-styles/index.js +36 -2
  31. package/build/components/global-styles/index.js.map +1 -1
  32. package/build/components/global-styles/typography-panel.js +87 -27
  33. package/build/components/global-styles/typography-panel.js.map +1 -1
  34. package/build/components/global-styles/use-global-styles-output.js +21 -14
  35. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  36. package/build/components/global-styles/utils.js +2 -0
  37. package/build/components/global-styles/utils.js.map +1 -1
  38. package/build/components/index.native.js +23 -0
  39. package/build/components/index.native.js.map +1 -1
  40. package/build/components/inserter/index.js +29 -17
  41. package/build/components/inserter/index.js.map +1 -1
  42. package/build/components/inserter/media-tab/hooks.js +10 -11
  43. package/build/components/inserter/media-tab/hooks.js.map +1 -1
  44. package/build/components/inserter/media-tab/media-list.js +5 -108
  45. package/build/components/inserter/media-tab/media-list.js.map +1 -1
  46. package/build/components/inserter/media-tab/media-preview.js +242 -0
  47. package/build/components/inserter/media-tab/media-preview.js.map +1 -0
  48. package/build/components/inserter/menu.js +1 -1
  49. package/build/components/inserter/menu.js.map +1 -1
  50. package/build/components/inserter/quick-inserter.js +4 -2
  51. package/build/components/inserter/quick-inserter.js.map +1 -1
  52. package/build/components/inserter/search-results.js +10 -3
  53. package/build/components/inserter/search-results.js.map +1 -1
  54. package/build/components/inserter/tabs.js +1 -1
  55. package/build/components/inserter/tabs.js.map +1 -1
  56. package/build/components/inspector-controls/block-support-tools-panel.js +1 -1
  57. package/build/components/inspector-controls/block-support-tools-panel.js.map +1 -1
  58. package/build/components/inspector-controls/fill.js +38 -9
  59. package/build/components/inspector-controls/fill.js.map +1 -1
  60. package/build/components/link-control/index.js +1 -1
  61. package/build/components/link-control/index.js.map +1 -1
  62. package/build/components/link-control/search-item.js +5 -2
  63. package/build/components/link-control/search-item.js.map +1 -1
  64. package/build/components/link-control/settings-drawer.js +1 -1
  65. package/build/components/link-control/settings-drawer.js.map +1 -1
  66. package/build/components/link-control/settings.js +1 -0
  67. package/build/components/link-control/settings.js.map +1 -1
  68. package/build/components/list-view/block.js +17 -3
  69. package/build/components/list-view/block.js.map +1 -1
  70. package/build/components/list-view/branch.js +2 -2
  71. package/build/components/list-view/branch.js.map +1 -1
  72. package/build/components/list-view/expander.js +2 -1
  73. package/build/components/list-view/expander.js.map +1 -1
  74. package/build/components/list-view/leaf.js +10 -6
  75. package/build/components/list-view/leaf.js.map +1 -1
  76. package/build/components/list-view/use-block-selection.js +1 -2
  77. package/build/components/list-view/use-block-selection.js.map +1 -1
  78. package/build/components/list-view/use-list-view-scroll-into-view.js +51 -0
  79. package/build/components/list-view/use-list-view-scroll-into-view.js.map +1 -0
  80. package/build/components/off-canvas-editor/appender.js +33 -13
  81. package/build/components/off-canvas-editor/appender.js.map +1 -1
  82. package/build/components/off-canvas-editor/branch.js +6 -3
  83. package/build/components/off-canvas-editor/branch.js.map +1 -1
  84. package/build/components/off-canvas-editor/index.js +8 -2
  85. package/build/components/off-canvas-editor/index.js.map +1 -1
  86. package/build/components/off-canvas-editor/leaf-more-menu.js +34 -4
  87. package/build/components/off-canvas-editor/leaf-more-menu.js.map +1 -1
  88. package/build/components/provider/use-block-sync.js +17 -3
  89. package/build/components/provider/use-block-sync.js.map +1 -1
  90. package/build/components/responsive-block-control/index.js +1 -0
  91. package/build/components/responsive-block-control/index.js.map +1 -1
  92. package/build/components/rich-text/format-toolbar-container.js +0 -3
  93. package/build/components/rich-text/format-toolbar-container.js.map +1 -1
  94. package/build/components/rich-text/index.js +9 -43
  95. package/build/components/rich-text/index.js.map +1 -1
  96. package/build/components/rich-text/use-delete.js +73 -0
  97. package/build/components/rich-text/use-delete.js.map +1 -0
  98. package/build/components/rich-text/use-input-rules.js +14 -6
  99. package/build/components/rich-text/use-input-rules.js.map +1 -1
  100. package/build/components/writing-flow/use-selection-observer.js +4 -1
  101. package/build/components/writing-flow/use-selection-observer.js.map +1 -1
  102. package/build/hooks/align.js +3 -1
  103. package/build/hooks/align.js.map +1 -1
  104. package/build/hooks/border.js +91 -240
  105. package/build/hooks/border.js.map +1 -1
  106. package/build/hooks/custom-class-name.js +4 -4
  107. package/build/hooks/custom-class-name.js.map +1 -1
  108. package/build/hooks/custom-class-name.native.js +3 -4
  109. package/build/hooks/custom-class-name.native.js.map +1 -1
  110. package/build/hooks/dimensions.js +72 -190
  111. package/build/hooks/dimensions.js.map +1 -1
  112. package/build/hooks/duotone.js +94 -25
  113. package/build/hooks/duotone.js.map +1 -1
  114. package/build/hooks/gap.js +0 -202
  115. package/build/hooks/gap.js.map +1 -1
  116. package/build/hooks/layout.js +33 -27
  117. package/build/hooks/layout.js.map +1 -1
  118. package/build/hooks/margin.js +7 -163
  119. package/build/hooks/margin.js.map +1 -1
  120. package/build/hooks/padding.js +7 -163
  121. package/build/hooks/padding.js.map +1 -1
  122. package/build/hooks/supports.js +7 -1
  123. package/build/hooks/supports.js.map +1 -1
  124. package/build/hooks/typography.js +52 -66
  125. package/build/hooks/typography.js.map +1 -1
  126. package/build/hooks/utils.js +101 -0
  127. package/build/hooks/utils.js.map +1 -1
  128. package/build/layouts/constrained.js +6 -2
  129. package/build/layouts/constrained.js.map +1 -1
  130. package/build/layouts/flex.js +1 -0
  131. package/build/layouts/flex.js.map +1 -1
  132. package/build/private-apis.js +4 -1
  133. package/build/private-apis.js.map +1 -1
  134. package/build/store/actions.js +28 -14
  135. package/build/store/actions.js.map +1 -1
  136. package/build/store/defaults.js +28 -1
  137. package/build/store/defaults.js.map +1 -1
  138. package/build/store/reducer.js +53 -47
  139. package/build/store/reducer.js.map +1 -1
  140. package/build/store/selectors.js +24 -4
  141. package/build/store/selectors.js.map +1 -1
  142. package/build/utils/parse-css-unit-to-px.js +49 -10
  143. package/build/utils/parse-css-unit-to-px.js.map +1 -1
  144. package/build-module/components/block-inspector/index.js +9 -9
  145. package/build-module/components/block-inspector/index.js.map +1 -1
  146. package/build-module/components/block-inspector/useBlockInspectorAnimationSettings.js +37 -0
  147. package/build-module/components/block-inspector/useBlockInspectorAnimationSettings.js.map +1 -0
  148. package/build-module/components/block-list/block-invalid-warning.js +66 -78
  149. package/build-module/components/block-list/block-invalid-warning.js.map +1 -1
  150. package/build-module/components/block-lock/modal.js +1 -0
  151. package/build-module/components/block-lock/modal.js.map +1 -1
  152. package/build-module/components/block-settings-menu/block-settings-dropdown.js +2 -2
  153. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  154. package/build-module/components/block-settings-menu-controls/index.js +1 -1
  155. package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
  156. package/build-module/components/block-styles/index.js +2 -1
  157. package/build-module/components/block-styles/index.js.map +1 -1
  158. package/build-module/components/block-switcher/block-transformations-menu.native.js +1 -0
  159. package/build-module/components/block-switcher/block-transformations-menu.native.js.map +1 -1
  160. package/build-module/components/child-layout-control/index.js +98 -0
  161. package/build-module/components/child-layout-control/index.js.map +1 -0
  162. package/build-module/components/convert-to-group-buttons/use-convert-to-group-button-props.js +6 -3
  163. package/build-module/components/convert-to-group-buttons/use-convert-to-group-button-props.js.map +1 -1
  164. package/build-module/components/date-format-picker/index.js +4 -4
  165. package/build-module/components/date-format-picker/index.js.map +1 -1
  166. package/build-module/components/global-styles/border-panel.js +291 -0
  167. package/build-module/components/global-styles/border-panel.js.map +1 -0
  168. package/build-module/components/global-styles/dimensions-panel.js +574 -0
  169. package/build-module/components/global-styles/dimensions-panel.js.map +1 -0
  170. package/build-module/components/global-styles/hooks.js +123 -34
  171. package/build-module/components/global-styles/hooks.js.map +1 -1
  172. package/build-module/components/global-styles/index.js +3 -1
  173. package/build-module/components/global-styles/index.js.map +1 -1
  174. package/build-module/components/global-styles/typography-panel.js +88 -27
  175. package/build-module/components/global-styles/typography-panel.js.map +1 -1
  176. package/build-module/components/global-styles/use-global-styles-output.js +21 -14
  177. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  178. package/build-module/components/global-styles/utils.js +2 -0
  179. package/build-module/components/global-styles/utils.js.map +1 -1
  180. package/build-module/components/index.native.js +2 -1
  181. package/build-module/components/index.native.js.map +1 -1
  182. package/build-module/components/inserter/index.js +28 -16
  183. package/build-module/components/inserter/index.js.map +1 -1
  184. package/build-module/components/inserter/media-tab/hooks.js +10 -11
  185. package/build-module/components/inserter/media-tab/hooks.js.map +1 -1
  186. package/build-module/components/inserter/media-tab/media-list.js +6 -105
  187. package/build-module/components/inserter/media-tab/media-list.js.map +1 -1
  188. package/build-module/components/inserter/media-tab/media-preview.js +222 -0
  189. package/build-module/components/inserter/media-tab/media-preview.js.map +1 -0
  190. package/build-module/components/inserter/menu.js +1 -1
  191. package/build-module/components/inserter/menu.js.map +1 -1
  192. package/build-module/components/inserter/quick-inserter.js +4 -2
  193. package/build-module/components/inserter/quick-inserter.js.map +1 -1
  194. package/build-module/components/inserter/search-results.js +10 -3
  195. package/build-module/components/inserter/search-results.js.map +1 -1
  196. package/build-module/components/inserter/tabs.js +1 -1
  197. package/build-module/components/inserter/tabs.js.map +1 -1
  198. package/build-module/components/inspector-controls/block-support-tools-panel.js +1 -1
  199. package/build-module/components/inspector-controls/block-support-tools-panel.js.map +1 -1
  200. package/build-module/components/inspector-controls/fill.js +39 -9
  201. package/build-module/components/inspector-controls/fill.js.map +1 -1
  202. package/build-module/components/link-control/index.js +1 -1
  203. package/build-module/components/link-control/index.js.map +1 -1
  204. package/build-module/components/link-control/search-item.js +4 -2
  205. package/build-module/components/link-control/search-item.js.map +1 -1
  206. package/build-module/components/link-control/settings-drawer.js +1 -1
  207. package/build-module/components/link-control/settings-drawer.js.map +1 -1
  208. package/build-module/components/link-control/settings.js +1 -0
  209. package/build-module/components/link-control/settings.js.map +1 -1
  210. package/build-module/components/list-view/block.js +16 -3
  211. package/build-module/components/list-view/block.js.map +1 -1
  212. package/build-module/components/list-view/branch.js +2 -2
  213. package/build-module/components/list-view/branch.js.map +1 -1
  214. package/build-module/components/list-view/expander.js +2 -1
  215. package/build-module/components/list-view/expander.js.map +1 -1
  216. package/build-module/components/list-view/leaf.js +8 -4
  217. package/build-module/components/list-view/leaf.js.map +1 -1
  218. package/build-module/components/list-view/use-block-selection.js +1 -2
  219. package/build-module/components/list-view/use-block-selection.js.map +1 -1
  220. package/build-module/components/list-view/use-list-view-scroll-into-view.js +42 -0
  221. package/build-module/components/list-view/use-list-view-scroll-into-view.js.map +1 -0
  222. package/build-module/components/off-canvas-editor/appender.js +33 -14
  223. package/build-module/components/off-canvas-editor/appender.js.map +1 -1
  224. package/build-module/components/off-canvas-editor/branch.js +6 -3
  225. package/build-module/components/off-canvas-editor/branch.js.map +1 -1
  226. package/build-module/components/off-canvas-editor/index.js +8 -2
  227. package/build-module/components/off-canvas-editor/index.js.map +1 -1
  228. package/build-module/components/off-canvas-editor/leaf-more-menu.js +36 -7
  229. package/build-module/components/off-canvas-editor/leaf-more-menu.js.map +1 -1
  230. package/build-module/components/provider/use-block-sync.js +17 -3
  231. package/build-module/components/provider/use-block-sync.js.map +1 -1
  232. package/build-module/components/responsive-block-control/index.js +1 -0
  233. package/build-module/components/responsive-block-control/index.js.map +1 -1
  234. package/build-module/components/rich-text/format-toolbar-container.js +0 -3
  235. package/build-module/components/rich-text/format-toolbar-container.js.map +1 -1
  236. package/build-module/components/rich-text/index.js +9 -43
  237. package/build-module/components/rich-text/index.js.map +1 -1
  238. package/build-module/components/rich-text/use-delete.js +62 -0
  239. package/build-module/components/rich-text/use-delete.js.map +1 -0
  240. package/build-module/components/rich-text/use-input-rules.js +14 -6
  241. package/build-module/components/rich-text/use-input-rules.js.map +1 -1
  242. package/build-module/components/writing-flow/use-selection-observer.js +4 -1
  243. package/build-module/components/writing-flow/use-selection-observer.js.map +1 -1
  244. package/build-module/hooks/align.js +3 -1
  245. package/build-module/hooks/align.js.map +1 -1
  246. package/build-module/hooks/border.js +93 -240
  247. package/build-module/hooks/border.js.map +1 -1
  248. package/build-module/hooks/custom-class-name.js +4 -4
  249. package/build-module/hooks/custom-class-name.js.map +1 -1
  250. package/build-module/hooks/custom-class-name.native.js +3 -4
  251. package/build-module/hooks/custom-class-name.native.js.map +1 -1
  252. package/build-module/hooks/dimensions.js +75 -187
  253. package/build-module/hooks/dimensions.js.map +1 -1
  254. package/build-module/hooks/duotone.js +86 -24
  255. package/build-module/hooks/duotone.js.map +1 -1
  256. package/build-module/hooks/gap.js +0 -183
  257. package/build-module/hooks/gap.js.map +1 -1
  258. package/build-module/hooks/layout.js +33 -27
  259. package/build-module/hooks/layout.js.map +1 -1
  260. package/build-module/hooks/margin.js +4 -143
  261. package/build-module/hooks/margin.js.map +1 -1
  262. package/build-module/hooks/padding.js +4 -143
  263. package/build-module/hooks/padding.js.map +1 -1
  264. package/build-module/hooks/supports.js +7 -1
  265. package/build-module/hooks/supports.js.map +1 -1
  266. package/build-module/hooks/typography.js +54 -66
  267. package/build-module/hooks/typography.js.map +1 -1
  268. package/build-module/hooks/utils.js +96 -0
  269. package/build-module/hooks/utils.js.map +1 -1
  270. package/build-module/layouts/constrained.js +6 -2
  271. package/build-module/layouts/constrained.js.map +1 -1
  272. package/build-module/layouts/flex.js +1 -0
  273. package/build-module/layouts/flex.js.map +1 -1
  274. package/build-module/private-apis.js +3 -1
  275. package/build-module/private-apis.js.map +1 -1
  276. package/build-module/store/actions.js +28 -14
  277. package/build-module/store/actions.js.map +1 -1
  278. package/build-module/store/defaults.js +28 -1
  279. package/build-module/store/defaults.js.map +1 -1
  280. package/build-module/store/reducer.js +53 -45
  281. package/build-module/store/reducer.js.map +1 -1
  282. package/build-module/store/selectors.js +22 -4
  283. package/build-module/store/selectors.js.map +1 -1
  284. package/build-module/utils/parse-css-unit-to-px.js +49 -10
  285. package/build-module/utils/parse-css-unit-to-px.js.map +1 -1
  286. package/build-style/style-rtl.css +39 -27
  287. package/build-style/style.css +39 -27
  288. package/package.json +31 -31
  289. package/src/components/block-draggable/test/__snapshots__/index.native.js.snap +24 -24
  290. package/src/components/block-inspector/index.js +11 -14
  291. package/src/components/block-inspector/style.scss +3 -0
  292. package/src/components/block-inspector/useBlockInspectorAnimationSettings.js +53 -0
  293. package/src/components/block-list/block-invalid-warning.js +72 -64
  294. package/src/components/block-lock/modal.js +1 -0
  295. package/src/components/block-lock/style.scss +0 -9
  296. package/src/components/block-mobile-toolbar/test/__snapshots__/block-actions-menu.native.js.snap +20 -20
  297. package/src/components/block-mover/test/__snapshots__/index.native.js.snap +35 -17
  298. package/src/components/block-preview/test/index.js +0 -2
  299. package/src/components/block-settings-menu/block-settings-dropdown.js +4 -1
  300. package/src/components/block-settings-menu-controls/index.js +2 -1
  301. package/src/components/block-styles/index.js +5 -1
  302. package/src/components/block-styles/style.scss +2 -2
  303. package/src/components/block-switcher/block-transformations-menu.native.js +1 -0
  304. package/src/components/child-layout-control/index.js +106 -0
  305. package/src/components/color-palette/test/__snapshots__/control.js.snap +17 -15
  306. package/src/components/convert-to-group-buttons/use-convert-to-group-button-props.js +48 -38
  307. package/src/components/date-format-picker/index.js +6 -8
  308. package/src/components/date-format-picker/style.scss +0 -5
  309. package/src/components/global-styles/border-panel.js +285 -0
  310. package/src/components/global-styles/dimensions-panel.js +627 -0
  311. package/src/components/global-styles/hooks.js +160 -44
  312. package/src/components/global-styles/index.js +7 -1
  313. package/src/components/global-styles/test/use-global-styles-output.js +1 -1
  314. package/src/components/global-styles/typography-panel.js +81 -9
  315. package/src/components/global-styles/use-global-styles-output.js +17 -16
  316. package/src/components/global-styles/utils.js +2 -0
  317. package/src/components/index.native.js +5 -0
  318. package/src/components/inner-blocks/test/__snapshots__/index.js.snap +1 -1
  319. package/src/components/inserter/index.js +30 -11
  320. package/src/components/inserter/media-tab/hooks.js +9 -8
  321. package/src/components/inserter/media-tab/media-list.js +3 -122
  322. package/src/components/inserter/media-tab/media-preview.js +268 -0
  323. package/src/components/inserter/menu.js +0 -1
  324. package/src/components/inserter/quick-inserter.js +2 -0
  325. package/src/components/inserter/search-results.js +7 -1
  326. package/src/components/inserter/style.scss +25 -0
  327. package/src/components/inserter/tabs.js +1 -9
  328. package/src/components/inserter/test/__snapshots__/index.native.js.snap +15 -15
  329. package/src/components/inspector-controls/block-support-tools-panel.js +0 -1
  330. package/src/components/inspector-controls/fill.js +32 -8
  331. package/src/components/link-control/index.js +1 -1
  332. package/src/components/link-control/search-item.js +3 -1
  333. package/src/components/link-control/settings-drawer.js +2 -1
  334. package/src/components/link-control/settings.js +1 -0
  335. package/src/components/link-control/style.scss +18 -12
  336. package/src/components/link-control/test/index.js +3 -5
  337. package/src/components/list-view/block.js +19 -1
  338. package/src/components/list-view/branch.js +1 -2
  339. package/src/components/list-view/expander.js +1 -0
  340. package/src/components/list-view/leaf.js +43 -29
  341. package/src/components/list-view/use-block-selection.js +0 -2
  342. package/src/components/list-view/use-list-view-scroll-into-view.js +48 -0
  343. package/src/components/media-replace-flow/style.scss +7 -9
  344. package/src/components/off-canvas-editor/appender.js +44 -21
  345. package/src/components/off-canvas-editor/branch.js +4 -1
  346. package/src/components/off-canvas-editor/index.js +7 -1
  347. package/src/components/off-canvas-editor/leaf-more-menu.js +57 -15
  348. package/src/components/provider/use-block-sync.js +21 -4
  349. package/src/components/responsive-block-control/index.js +1 -0
  350. package/src/components/rich-text/format-toolbar-container.js +1 -7
  351. package/src/components/rich-text/index.js +8 -44
  352. package/src/components/rich-text/use-delete.js +59 -0
  353. package/src/components/rich-text/use-input-rules.js +13 -5
  354. package/src/components/spacing-sizes-control/style.scss +1 -1
  355. package/src/components/url-popover/stories/index.js +1 -0
  356. package/src/components/url-popover/test/index.js +0 -2
  357. package/src/components/writing-flow/use-selection-observer.js +5 -1
  358. package/src/hooks/align.js +1 -1
  359. package/src/hooks/border.js +94 -225
  360. package/src/hooks/custom-class-name.js +4 -4
  361. package/src/hooks/custom-class-name.native.js +3 -4
  362. package/src/hooks/dimensions.js +85 -269
  363. package/src/hooks/duotone.js +100 -30
  364. package/src/hooks/gap.js +0 -208
  365. package/src/hooks/layout.js +38 -22
  366. package/src/hooks/margin.js +1 -164
  367. package/src/hooks/padding.js +1 -163
  368. package/src/hooks/supports.js +6 -0
  369. package/src/hooks/test/__snapshots__/align.native.js.snap +24 -24
  370. package/src/hooks/test/duotone.js +102 -0
  371. package/src/hooks/test/style.js +2 -1
  372. package/src/hooks/test/use-typography-props.js +2 -0
  373. package/src/hooks/typography.js +68 -88
  374. package/src/hooks/utils.js +126 -0
  375. package/src/layouts/constrained.js +23 -17
  376. package/src/layouts/flex.js +1 -0
  377. package/src/private-apis.js +2 -0
  378. package/src/store/actions.js +16 -6
  379. package/src/store/defaults.js +14 -1
  380. package/src/store/reducer.js +68 -43
  381. package/src/store/selectors.js +28 -4
  382. package/src/store/test/actions.js +4 -2
  383. package/src/utils/parse-css-unit-to-px.js +48 -13
  384. package/src/utils/test/parse-css-unit-to-px.js +13 -2
  385. package/tsconfig.tsbuildinfo +1 -1
  386. package/build/hooks/border-radius.js +0 -100
  387. package/build/hooks/border-radius.js.map +0 -1
  388. package/build/hooks/child-layout.js +0 -213
  389. package/build/hooks/child-layout.js.map +0 -1
  390. package/build/hooks/min-height.js +0 -139
  391. package/build/hooks/min-height.js.map +0 -1
  392. package/build-module/hooks/border-radius.js +0 -84
  393. package/build-module/hooks/border-radius.js.map +0 -1
  394. package/build-module/hooks/child-layout.js +0 -193
  395. package/build-module/hooks/child-layout.js.map +0 -1
  396. package/build-module/hooks/min-height.js +0 -116
  397. package/build-module/hooks/min-height.js.map +0 -1
  398. package/src/hooks/border-radius.js +0 -70
  399. package/src/hooks/child-layout.js +0 -195
  400. package/src/hooks/min-height.js +0 -104
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/hooks/duotone.js"],"names":["classnames","extend","namesPlugin","getBlockSupport","hasBlockSupport","createHigherOrderComponent","useInstanceId","addFilter","useMemo","useContext","createPortal","useSelect","BlockControls","__experimentalDuotoneControl","DuotoneControl","useSetting","BlockList","__unstableDuotoneFilter","DuotoneFilter","__unstableDuotoneStylesheet","DuotoneStylesheet","__unstableDuotoneUnsetStylesheet","DuotoneUnsetStylesheet","store","blockEditorStore","EMPTY_ARRAY","InlineDuotone","selector","id","colors","useMultiOriginPresets","presetSetting","defaultSetting","disableDefault","userPresets","themePresets","defaultPresets","DuotonePanel","attributes","setAttributes","style","duotone","color","duotonePalette","colorPalette","disableCustomColors","disableCustomDuotone","length","newDuotone","newStyle","addDuotoneAttributes","settings","Object","assign","type","withDuotoneControls","BlockEdit","props","hasDuotoneSupport","name","isContentLocked","select","__unstableGetContentLockingParent","clientId","scopeSelector","scope","scopes","split","selectors","selectorsScoped","forEach","outer","inner","push","trim","join","withDuotoneStyles","BlockListBlock","duotoneSupport","selectorsGroup","className","element","__unstableElementContext"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AACA,SAASC,MAAT,QAAuB,QAAvB;AACA,OAAOC,WAAP,MAAwB,sBAAxB;AAEA;AACA;AACA;;AACA,SAASC,eAAT,EAA0BC,eAA1B,QAAiD,mBAAjD;AACA,SAASC,0BAAT,EAAqCC,aAArC,QAA0D,oBAA1D;AACA,SAASC,SAAT,QAA0B,kBAA1B;AACA,SAASC,OAAT,EAAkBC,UAAlB,EAA8BC,YAA9B,QAAkD,oBAAlD;AACA,SAASC,SAAT,QAA0B,iBAA1B;AAEA;AACA;AACA;;AACA,SACCC,aADD,EAECC,4BAA4B,IAAIC,cAFjC,EAGCC,UAHD,QAIO,eAJP;AAKA,OAAOC,SAAP,MAAsB,0BAAtB;AACA,SACCC,uBAAuB,IAAIC,aAD5B,EAECC,2BAA2B,IAAIC,iBAFhC,EAGCC,gCAAgC,IAAIC,sBAHrC,QAIO,uBAJP;AAKA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,UAA1C;AAEA,MAAMC,WAAW,GAAG,EAApB;AAEAxB,MAAM,CAAE,CAAEC,WAAF,CAAF,CAAN;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASwB,aAAT,OAAmD;AAAA,MAA3B;AAAEC,IAAAA,QAAF;AAAYC,IAAAA,EAAZ;AAAgBC,IAAAA;AAAhB,GAA2B;;AAClD,MAAKA,MAAM,KAAK,OAAhB,EAA0B;AACzB,WAAO,cAAC,sBAAD;AAAwB,MAAA,QAAQ,EAAGF;AAAnC,MAAP;AACA;;AAED,SACC,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xCkD,EAyCnD,mBAzCmD,CAApD;AA4CAzE,SAAS,CACR,0BADQ,EAER,oCAFQ,EAGR2C,oBAHQ,CAAT;AAKA3C,SAAS,CACR,kBADQ,EAER,0CAFQ,EAGRgD,mBAHQ,CAAT;AAKAhD,SAAS,CACR,uBADQ,EAER,iCAFQ,EAGRqE,iBAHQ,CAAT","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport { extend } from 'colord';\nimport namesPlugin from 'colord/plugins/names';\n\n/**\n * WordPress dependencies\n */\nimport { getBlockSupport, hasBlockSupport } from '@wordpress/blocks';\nimport { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';\nimport { addFilter } from '@wordpress/hooks';\nimport { useMemo, useContext, createPortal } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport {\n\tBlockControls,\n\t__experimentalDuotoneControl as DuotoneControl,\n\tuseSetting,\n} from '../components';\nimport BlockList from '../components/block-list';\nimport {\n\t__unstableDuotoneFilter as DuotoneFilter,\n\t__unstableDuotoneStylesheet as DuotoneStylesheet,\n\t__unstableDuotoneUnsetStylesheet as DuotoneUnsetStylesheet,\n} from '../components/duotone';\nimport { store as blockEditorStore } from '../store';\n\nconst EMPTY_ARRAY = [];\n\nextend( [ namesPlugin ] );\n\n/**\n * SVG and stylesheet needed for rendering the duotone filter.\n *\n * @param {Object} props Duotone props.\n * @param {string} props.selector Selector to apply the filter to.\n * @param {string} props.id Unique id for this duotone filter.\n * @param {string[]|\"unset\"} props.colors Array of RGB color strings ordered from dark to light.\n *\n * @return {WPElement} Duotone element.\n */\nfunction InlineDuotone( { selector, id, colors } ) {\n\tif ( colors === 'unset' ) {\n\t\treturn <DuotoneUnsetStylesheet selector={ selector } />;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<DuotoneFilter id={ id } colors={ colors } />\n\t\t\t<DuotoneStylesheet id={ id } selector={ selector } />\n\t\t</>\n\t);\n}\n\nfunction useMultiOriginPresets( { presetSetting, defaultSetting } ) {\n\tconst disableDefault = ! useSetting( defaultSetting );\n\tconst userPresets =\n\t\tuseSetting( `${ presetSetting }.custom` ) || EMPTY_ARRAY;\n\tconst themePresets =\n\t\tuseSetting( `${ presetSetting }.theme` ) || EMPTY_ARRAY;\n\tconst defaultPresets =\n\t\tuseSetting( `${ presetSetting }.default` ) || EMPTY_ARRAY;\n\treturn useMemo(\n\t\t() => [\n\t\t\t...userPresets,\n\t\t\t...themePresets,\n\t\t\t...( disableDefault ? EMPTY_ARRAY : defaultPresets ),\n\t\t],\n\t\t[ disableDefault, userPresets, themePresets, defaultPresets ]\n\t);\n}\n\nfunction DuotonePanel( { attributes, setAttributes } ) {\n\tconst style = attributes?.style;\n\tconst duotone = style?.color?.duotone;\n\n\tconst duotonePalette = useMultiOriginPresets( {\n\t\tpresetSetting: 'color.duotone',\n\t\tdefaultSetting: 'color.defaultDuotone',\n\t} );\n\tconst colorPalette = useMultiOriginPresets( {\n\t\tpresetSetting: 'color.palette',\n\t\tdefaultSetting: 'color.defaultPalette',\n\t} );\n\tconst disableCustomColors = ! useSetting( 'color.custom' );\n\tconst disableCustomDuotone =\n\t\t! useSetting( 'color.customDuotone' ) ||\n\t\t( colorPalette?.length === 0 && disableCustomColors );\n\n\tif ( duotonePalette?.length === 0 && disableCustomDuotone ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<BlockControls group=\"block\" __experimentalShareWithChildBlocks>\n\t\t\t<DuotoneControl\n\t\t\t\tduotonePalette={ duotonePalette }\n\t\t\t\tcolorPalette={ colorPalette }\n\t\t\t\tdisableCustomDuotone={ disableCustomDuotone }\n\t\t\t\tdisableCustomColors={ disableCustomColors }\n\t\t\t\tvalue={ duotone }\n\t\t\t\tonChange={ ( newDuotone ) => {\n\t\t\t\t\tconst newStyle = {\n\t\t\t\t\t\t...style,\n\t\t\t\t\t\tcolor: {\n\t\t\t\t\t\t\t...style?.color,\n\t\t\t\t\t\t\tduotone: newDuotone,\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t\tsetAttributes( { style: newStyle } );\n\t\t\t\t} }\n\t\t\t/>\n\t\t</BlockControls>\n\t);\n}\n\n/**\n * Filters registered block settings, extending attributes to include\n * the `duotone` attribute.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nfunction addDuotoneAttributes( settings ) {\n\tif ( ! hasBlockSupport( settings, 'color.__experimentalDuotone' ) ) {\n\t\treturn settings;\n\t}\n\n\t// Allow blocks to specify their own attribute definition with default\n\t// values if needed.\n\tif ( ! settings.attributes.style ) {\n\t\tObject.assign( settings.attributes, {\n\t\t\tstyle: {\n\t\t\t\ttype: 'object',\n\t\t\t},\n\t\t} );\n\t}\n\n\treturn settings;\n}\n\n/**\n * Override the default edit UI to include toolbar controls for duotone if the\n * block supports duotone.\n *\n * @param {Function} BlockEdit Original component.\n *\n * @return {Function} Wrapped component.\n */\nconst withDuotoneControls = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tconst hasDuotoneSupport = hasBlockSupport(\n\t\t\tprops.name,\n\t\t\t'color.__experimentalDuotone'\n\t\t);\n\t\tconst isContentLocked = useSelect(\n\t\t\t( select ) => {\n\t\t\t\treturn select(\n\t\t\t\t\tblockEditorStore\n\t\t\t\t).__unstableGetContentLockingParent( props.clientId );\n\t\t\t},\n\t\t\t[ props.clientId ]\n\t\t);\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<BlockEdit { ...props } />\n\t\t\t\t{ hasDuotoneSupport && ! isContentLocked && (\n\t\t\t\t\t<DuotonePanel { ...props } />\n\t\t\t\t) }\n\t\t\t</>\n\t\t);\n\t},\n\t'withDuotoneControls'\n);\n\n/**\n * Function that scopes a selector with another one. This works a bit like\n * SCSS nesting except the `&` operator isn't supported.\n *\n * @example\n * ```js\n * const scope = '.a, .b .c';\n * const selector = '> .x, .y';\n * const merged = scopeSelector( scope, selector );\n * // merged is '.a > .x, .a .y, .b .c > .x, .b .c .y'\n * ```\n *\n * @param {string} scope Selector to scope to.\n * @param {string} selector Original selector.\n *\n * @return {string} Scoped selector.\n */\nfunction scopeSelector( scope, selector ) {\n\tconst scopes = scope.split( ',' );\n\tconst selectors = selector.split( ',' );\n\n\tconst selectorsScoped = [];\n\tscopes.forEach( ( outer ) => {\n\t\tselectors.forEach( ( inner ) => {\n\t\t\tselectorsScoped.push( `${ outer.trim() } ${ inner.trim() }` );\n\t\t} );\n\t} );\n\n\treturn selectorsScoped.join( ', ' );\n}\n\n/**\n * Override the default block element to include duotone styles.\n *\n * @param {Function} BlockListBlock Original component.\n *\n * @return {Function} Wrapped component.\n */\nconst withDuotoneStyles = createHigherOrderComponent(\n\t( BlockListBlock ) => ( props ) => {\n\t\tconst duotoneSupport = getBlockSupport(\n\t\t\tprops.name,\n\t\t\t'color.__experimentalDuotone'\n\t\t);\n\t\tconst colors = props?.attributes?.style?.color?.duotone;\n\n\t\tif ( ! duotoneSupport || ! colors ) {\n\t\t\treturn <BlockListBlock { ...props } />;\n\t\t}\n\n\t\tconst id = `wp-duotone-${ useInstanceId( BlockListBlock ) }`;\n\n\t\t// Extra .editor-styles-wrapper specificity is needed in the editor\n\t\t// since we're not using inline styles to apply the filter. We need to\n\t\t// override duotone applied by global styles and theme.json.\n\t\tconst selectorsGroup = scopeSelector(\n\t\t\t`.editor-styles-wrapper .${ id }`,\n\t\t\tduotoneSupport\n\t\t);\n\n\t\tconst className = classnames( props?.className, id );\n\n\t\tconst element = useContext( BlockList.__unstableElementContext );\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ element &&\n\t\t\t\t\tcreatePortal(\n\t\t\t\t\t\t<InlineDuotone\n\t\t\t\t\t\t\tselector={ selectorsGroup }\n\t\t\t\t\t\t\tid={ id }\n\t\t\t\t\t\t\tcolors={ colors }\n\t\t\t\t\t\t/>,\n\t\t\t\t\t\telement\n\t\t\t\t\t) }\n\t\t\t\t<BlockListBlock { ...props } className={ className } />\n\t\t\t</>\n\t\t);\n\t},\n\t'withDuotoneStyles'\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/editor/duotone/add-attributes',\n\taddDuotoneAttributes\n);\naddFilter(\n\t'editor.BlockEdit',\n\t'core/editor/duotone/with-editor-controls',\n\twithDuotoneControls\n);\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/editor/duotone/with-styles',\n\twithDuotoneStyles\n);\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/hooks/duotone.js"],"names":["classnames","extend","namesPlugin","getBlockSupport","hasBlockSupport","createHigherOrderComponent","useInstanceId","addFilter","useMemo","useContext","createPortal","useSelect","BlockControls","__experimentalDuotoneControl","DuotoneControl","useSetting","BlockList","__unstableDuotoneFilter","DuotoneFilter","__unstableDuotoneStylesheet","DuotoneStylesheet","__unstableDuotoneUnsetStylesheet","DuotoneUnsetStylesheet","store","blockEditorStore","EMPTY_ARRAY","InlineDuotone","selector","id","colors","useMultiOriginPresets","presetSetting","defaultSetting","disableDefault","userPresets","themePresets","defaultPresets","getColorsFromDuotonePreset","duotone","duotonePalette","preset","find","slug","undefined","getDuotonePresetFromColors","Array","isArray","duotonePreset","every","val","index","DuotonePanel","attributes","setAttributes","style","duotoneStyle","color","colorPalette","disableCustomColors","disableCustomDuotone","length","duotonePresetOrColors","newDuotone","maybePreset","newStyle","addDuotoneAttributes","settings","Object","assign","type","withDuotoneControls","BlockEdit","props","hasDuotoneSupport","name","isContentLocked","select","__unstableGetContentLockingParent","clientId","scopeSelector","scope","scopes","split","selectors","selectorsScoped","forEach","outer","inner","push","trim","join","BlockDuotoneStyles","element","__unstableElementContext","duotoneSupportSelectors","selectorsGroup","withDuotoneStyles","BlockListBlock","duotoneSupport","className"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AACA,SAASC,MAAT,QAAuB,QAAvB;AACA,OAAOC,WAAP,MAAwB,sBAAxB;AAEA;AACA;AACA;;AACA,SAASC,eAAT,EAA0BC,eAA1B,QAAiD,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EAAG,kBAAmBE,KAAtB,oFAAG,sBAA0BE,KAA7B,2DAAG,uBAAiClB,OAAtD,CAVkC,CAYlC;AACA;AACA;AACA;;AACA,SACC,8BACG4D,cAAc,IAAI3C,YAAlB,IACD,cAAC,kBAAD;AACC,IAAA,IAAI,EAAGiB,KAAH,aAAGA,KAAH,uBAAGA,KAAK,CAAEE,IADf;AAEC,IAAA,YAAY,EAAGnB,YAFhB;AAGC,IAAA,EAAE,EAAG3B;AAHN,IAFF,EAQC,cAAC,cAAD,eAAqB4C,KAArB;AAA6B,IAAA,SAAS,EAAG2B;AAAzC,KARD,CADD;AAYA,CA7BkD,EA8BnD,mBA9BmD,CAApD;AAiCA5F,SAAS,CACR,0BADQ,EAER,oCAFQ,EAGR0D,oBAHQ,CAAT;AAKA1D,SAAS,CACR,kBADQ,EAER,0CAFQ,EAGR+D,mBAHQ,CAAT;AAKA/D,SAAS,CACR,uBADQ,EAER,iCAFQ,EAGRyF,iBAHQ,CAAT","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport { extend } from 'colord';\nimport namesPlugin from 'colord/plugins/names';\n\n/**\n * WordPress dependencies\n */\nimport { getBlockSupport, hasBlockSupport } from '@wordpress/blocks';\nimport { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';\nimport { addFilter } from '@wordpress/hooks';\nimport { useMemo, useContext, createPortal } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport {\n\tBlockControls,\n\t__experimentalDuotoneControl as DuotoneControl,\n\tuseSetting,\n} from '../components';\nimport BlockList from '../components/block-list';\nimport {\n\t__unstableDuotoneFilter as DuotoneFilter,\n\t__unstableDuotoneStylesheet as DuotoneStylesheet,\n\t__unstableDuotoneUnsetStylesheet as DuotoneUnsetStylesheet,\n} from '../components/duotone';\nimport { store as blockEditorStore } from '../store';\n\nconst EMPTY_ARRAY = [];\n\nextend( [ namesPlugin ] );\n\n/**\n * SVG and stylesheet needed for rendering the duotone filter.\n *\n * @param {Object} props Duotone props.\n * @param {string} props.selector Selector to apply the filter to.\n * @param {string} props.id Unique id for this duotone filter.\n * @param {string[]|\"unset\"} props.colors Array of RGB color strings ordered from dark to light.\n *\n * @return {WPElement} Duotone element.\n */\nfunction InlineDuotone( { selector, id, colors } ) {\n\tif ( colors === 'unset' ) {\n\t\treturn <DuotoneUnsetStylesheet selector={ selector } />;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<DuotoneFilter id={ id } colors={ colors } />\n\t\t\t<DuotoneStylesheet id={ id } selector={ selector } />\n\t\t</>\n\t);\n}\n\nfunction useMultiOriginPresets( { presetSetting, defaultSetting } ) {\n\tconst disableDefault = ! useSetting( defaultSetting );\n\tconst userPresets =\n\t\tuseSetting( `${ presetSetting }.custom` ) || EMPTY_ARRAY;\n\tconst themePresets =\n\t\tuseSetting( `${ presetSetting }.theme` ) || EMPTY_ARRAY;\n\tconst defaultPresets =\n\t\tuseSetting( `${ presetSetting }.default` ) || EMPTY_ARRAY;\n\treturn useMemo(\n\t\t() => [\n\t\t\t...userPresets,\n\t\t\t...themePresets,\n\t\t\t...( disableDefault ? EMPTY_ARRAY : defaultPresets ),\n\t\t],\n\t\t[ disableDefault, userPresets, themePresets, defaultPresets ]\n\t);\n}\n\nexport function getColorsFromDuotonePreset( duotone, duotonePalette ) {\n\tif ( ! duotone ) {\n\t\treturn;\n\t}\n\tconst preset = duotonePalette?.find( ( { slug } ) => {\n\t\treturn duotone === `var:preset|duotone|${ slug }`;\n\t} );\n\n\treturn preset ? preset.colors : undefined;\n}\n\nexport function getDuotonePresetFromColors( colors, duotonePalette ) {\n\tif ( ! colors || ! Array.isArray( colors ) ) {\n\t\treturn;\n\t}\n\n\tconst preset = duotonePalette?.find( ( duotonePreset ) => {\n\t\treturn duotonePreset?.colors?.every(\n\t\t\t( val, index ) => val === colors[ index ]\n\t\t);\n\t} );\n\n\treturn preset ? `var:preset|duotone|${ preset.slug }` : undefined;\n}\n\nfunction DuotonePanel( { attributes, setAttributes } ) {\n\tconst style = attributes?.style;\n\tconst duotoneStyle = style?.color?.duotone;\n\n\tconst duotonePalette = useMultiOriginPresets( {\n\t\tpresetSetting: 'color.duotone',\n\t\tdefaultSetting: 'color.defaultDuotone',\n\t} );\n\tconst colorPalette = useMultiOriginPresets( {\n\t\tpresetSetting: 'color.palette',\n\t\tdefaultSetting: 'color.defaultPalette',\n\t} );\n\tconst disableCustomColors = ! useSetting( 'color.custom' );\n\tconst disableCustomDuotone =\n\t\t! useSetting( 'color.customDuotone' ) ||\n\t\t( colorPalette?.length === 0 && disableCustomColors );\n\n\tif ( duotonePalette?.length === 0 && disableCustomDuotone ) {\n\t\treturn null;\n\t}\n\n\tconst duotonePresetOrColors = ! Array.isArray( duotoneStyle )\n\t\t? getColorsFromDuotonePreset( duotoneStyle, duotonePalette )\n\t\t: duotoneStyle;\n\n\treturn (\n\t\t<BlockControls group=\"block\" __experimentalShareWithChildBlocks>\n\t\t\t<DuotoneControl\n\t\t\t\tduotonePalette={ duotonePalette }\n\t\t\t\tcolorPalette={ colorPalette }\n\t\t\t\tdisableCustomDuotone={ disableCustomDuotone }\n\t\t\t\tdisableCustomColors={ disableCustomColors }\n\t\t\t\tvalue={ duotonePresetOrColors }\n\t\t\t\tonChange={ ( newDuotone ) => {\n\t\t\t\t\tconst maybePreset = getDuotonePresetFromColors(\n\t\t\t\t\t\tnewDuotone,\n\t\t\t\t\t\tduotonePalette\n\t\t\t\t\t);\n\n\t\t\t\t\tconst newStyle = {\n\t\t\t\t\t\t...style,\n\t\t\t\t\t\tcolor: {\n\t\t\t\t\t\t\t...style?.color,\n\t\t\t\t\t\t\tduotone: maybePreset ?? newDuotone, // use preset or fallback to custom colors.\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t\tsetAttributes( { style: newStyle } );\n\t\t\t\t} }\n\t\t\t/>\n\t\t</BlockControls>\n\t);\n}\n\n/**\n * Filters registered block settings, extending attributes to include\n * the `duotone` attribute.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nfunction addDuotoneAttributes( settings ) {\n\tif ( ! hasBlockSupport( settings, 'color.__experimentalDuotone' ) ) {\n\t\treturn settings;\n\t}\n\n\t// Allow blocks to specify their own attribute definition with default\n\t// values if needed.\n\tif ( ! settings.attributes.style ) {\n\t\tObject.assign( settings.attributes, {\n\t\t\tstyle: {\n\t\t\t\ttype: 'object',\n\t\t\t},\n\t\t} );\n\t}\n\n\treturn settings;\n}\n\n/**\n * Override the default edit UI to include toolbar controls for duotone if the\n * block supports duotone.\n *\n * @param {Function} BlockEdit Original component.\n *\n * @return {Function} Wrapped component.\n */\nconst withDuotoneControls = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tconst hasDuotoneSupport = hasBlockSupport(\n\t\t\tprops.name,\n\t\t\t'color.__experimentalDuotone'\n\t\t);\n\t\tconst isContentLocked = useSelect(\n\t\t\t( select ) => {\n\t\t\t\treturn select(\n\t\t\t\t\tblockEditorStore\n\t\t\t\t).__unstableGetContentLockingParent( props.clientId );\n\t\t\t},\n\t\t\t[ props.clientId ]\n\t\t);\n\n\t\t// CAUTION: code added before this line will be executed\n\t\t// for all blocks, not just those that support duotone. Code added\n\t\t// above this line should be carefully evaluated for its impact on\n\t\t// performance.\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ hasDuotoneSupport && ! isContentLocked && (\n\t\t\t\t\t<DuotonePanel { ...props } />\n\t\t\t\t) }\n\t\t\t\t<BlockEdit { ...props } />\n\t\t\t</>\n\t\t);\n\t},\n\t'withDuotoneControls'\n);\n\n/**\n * Function that scopes a selector with another one. This works a bit like\n * SCSS nesting except the `&` operator isn't supported.\n *\n * @example\n * ```js\n * const scope = '.a, .b .c';\n * const selector = '> .x, .y';\n * const merged = scopeSelector( scope, selector );\n * // merged is '.a > .x, .a .y, .b .c > .x, .b .c .y'\n * ```\n *\n * @param {string} scope Selector to scope to.\n * @param {string} selector Original selector.\n *\n * @return {string} Scoped selector.\n */\nfunction scopeSelector( scope, selector ) {\n\tconst scopes = scope.split( ',' );\n\tconst selectors = selector.split( ',' );\n\n\tconst selectorsScoped = [];\n\tscopes.forEach( ( outer ) => {\n\t\tselectors.forEach( ( inner ) => {\n\t\t\tselectorsScoped.push( `${ outer.trim() } ${ inner.trim() }` );\n\t\t} );\n\t} );\n\n\treturn selectorsScoped.join( ', ' );\n}\n\nfunction BlockDuotoneStyles( { name, duotoneStyle, id } ) {\n\tconst duotonePalette = useMultiOriginPresets( {\n\t\tpresetSetting: 'color.duotone',\n\t\tdefaultSetting: 'color.defaultDuotone',\n\t} );\n\n\tconst element = useContext( BlockList.__unstableElementContext );\n\n\t// Portals cannot exist without a container.\n\t// Guard against empty Duotone styles.\n\tif ( ! element || ! duotoneStyle ) {\n\t\treturn null;\n\t}\n\n\tlet colors = duotoneStyle;\n\n\tif ( ! Array.isArray( colors ) && colors !== 'unset' ) {\n\t\tcolors = getColorsFromDuotonePreset( colors, duotonePalette );\n\t}\n\n\tconst duotoneSupportSelectors = getBlockSupport(\n\t\tname,\n\t\t'color.__experimentalDuotone'\n\t);\n\n\t// Extra .editor-styles-wrapper specificity is needed in the editor\n\t// since we're not using inline styles to apply the filter. We need to\n\t// override duotone applied by global styles and theme.json.\n\tconst selectorsGroup = scopeSelector(\n\t\t`.editor-styles-wrapper .${ id }`,\n\t\tduotoneSupportSelectors\n\t);\n\n\treturn createPortal(\n\t\t<InlineDuotone\n\t\t\tselector={ selectorsGroup }\n\t\t\tid={ id }\n\t\t\tcolors={ colors }\n\t\t/>,\n\t\telement\n\t);\n}\n\n/**\n * Override the default block element to include duotone styles.\n *\n * @param {Function} BlockListBlock Original component.\n *\n * @return {Function} Wrapped component.\n */\nconst withDuotoneStyles = createHigherOrderComponent(\n\t( BlockListBlock ) => ( props ) => {\n\t\tconst duotoneSupport = getBlockSupport(\n\t\t\tprops.name,\n\t\t\t'color.__experimentalDuotone'\n\t\t);\n\n\t\tconst id = `wp-duotone-${ useInstanceId( BlockListBlock ) }`;\n\t\tconst className = duotoneSupport\n\t\t\t? classnames( props?.className, id )\n\t\t\t: props?.className;\n\t\tconst duotoneStyle = props?.attributes?.style?.color?.duotone;\n\n\t\t// CAUTION: code added before this line will be executed\n\t\t// for all blocks, not just those that support duotone. Code added\n\t\t// above this line should be carefully evaluated for its impact on\n\t\t// performance.\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ duotoneSupport && duotoneStyle && (\n\t\t\t\t\t<BlockDuotoneStyles\n\t\t\t\t\t\tname={ props?.name }\n\t\t\t\t\t\tduotoneStyle={ duotoneStyle }\n\t\t\t\t\t\tid={ id }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t<BlockListBlock { ...props } className={ className } />\n\t\t\t</>\n\t\t);\n\t},\n\t'withDuotoneStyles'\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/editor/duotone/add-attributes',\n\taddDuotoneAttributes\n);\naddFilter(\n\t'editor.BlockEdit',\n\t'core/editor/duotone/with-editor-controls',\n\twithDuotoneControls\n);\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/editor/duotone/with-styles',\n\twithDuotoneStyles\n);\n"]}
@@ -1,45 +1,7 @@
1
- import { createElement, Fragment } from "@wordpress/element";
2
-
3
- /**
4
- * WordPress dependencies
5
- */
6
- import { __ } from '@wordpress/i18n';
7
- import { Platform } from '@wordpress/element';
8
- import { getBlockSupport } from '@wordpress/blocks';
9
- import { __experimentalUseCustomUnits as useCustomUnits, __experimentalBoxControl as BoxControl, __experimentalUnitControl as UnitControl } from '@wordpress/components';
10
1
  /**
11
2
  * Internal dependencies
12
3
  */
13
-
14
- import { __unstableUseBlockRef as useBlockRef } from '../components/block-list/use-block-props/use-block-refs';
15
4
  import { getSpacingPresetCssVar } from '../components/spacing-sizes-control/utils';
16
- import SpacingSizesControl from '../components/spacing-sizes-control';
17
- import useSetting from '../components/use-setting';
18
- import { AXIAL_SIDES, SPACING_SUPPORT_KEY, useCustomSides, useIsDimensionsSupportValid } from './dimensions';
19
- import { cleanEmptyObject } from './utils';
20
- /**
21
- * Determines if there is gap support.
22
- *
23
- * @param {string|Object} blockType Block name or Block Type object.
24
- * @return {boolean} Whether there is support.
25
- */
26
-
27
- export function hasGapSupport(blockType) {
28
- const support = getBlockSupport(blockType, SPACING_SUPPORT_KEY);
29
- return !!(true === support || support !== null && support !== void 0 && support.blockGap);
30
- }
31
- /**
32
- * Checks if there is a current value in the gap block support attributes.
33
- *
34
- * @param {Object} props Block props.
35
- * @return {boolean} Whether or not the block has a gap value set.
36
- */
37
-
38
- export function hasGapValue(props) {
39
- var _props$attributes$sty, _props$attributes$sty2;
40
-
41
- return ((_props$attributes$sty = props.attributes.style) === null || _props$attributes$sty === void 0 ? void 0 : (_props$attributes$sty2 = _props$attributes$sty.spacing) === null || _props$attributes$sty2 === void 0 ? void 0 : _props$attributes$sty2.blockGap) !== undefined;
42
- }
43
5
  /**
44
6
  * Returns a BoxControl object value from a given blockGap style value.
45
7
  * The string check is for backwards compatibility before Gutenberg supported
@@ -80,149 +42,4 @@ export function getGapCSSValue(blockGapValue) {
80
42
  const column = getSpacingPresetCssVar(blockGapBoxControlValue === null || blockGapBoxControlValue === void 0 ? void 0 : blockGapBoxControlValue.left) || defaultValue;
81
43
  return row === column ? row : `${row} ${column}`;
82
44
  }
83
- /**
84
- * Resets the gap block support attribute. This can be used when disabling
85
- * the gap support controls for a block via a progressive discovery panel.
86
- *
87
- * @param {Object} props Block props.
88
- * @param {Object} props.attributes Block's attributes.
89
- * @param {Object} props.setAttributes Function to set block's attributes.
90
- */
91
-
92
- export function resetGap(_ref) {
93
- let {
94
- attributes = {},
95
- setAttributes
96
- } = _ref;
97
- const {
98
- style
99
- } = attributes;
100
- setAttributes({
101
- style: { ...style,
102
- spacing: { ...(style === null || style === void 0 ? void 0 : style.spacing),
103
- blockGap: undefined
104
- }
105
- }
106
- });
107
- }
108
- /**
109
- * Custom hook that checks if gap settings have been disabled.
110
- *
111
- * @param {string} name The name of the block.
112
- * @return {boolean} Whether the gap setting is disabled.
113
- */
114
-
115
- export function useIsGapDisabled() {
116
- let {
117
- name: blockName
118
- } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
119
- const isDisabled = !useSetting('spacing.blockGap');
120
- const isInvalid = !useIsDimensionsSupportValid(blockName, 'blockGap');
121
- return !hasGapSupport(blockName) || isDisabled || isInvalid;
122
- }
123
- /**
124
- * Inspector control panel containing the gap related configuration
125
- *
126
- * @param {Object} props
127
- *
128
- * @return {WPElement} Gap edit element.
129
- */
130
-
131
- export function GapEdit(props) {
132
- var _style$spacing;
133
-
134
- const {
135
- clientId,
136
- attributes: {
137
- style
138
- },
139
- name: blockName,
140
- setAttributes
141
- } = props;
142
- const spacingSizes = useSetting('spacing.spacingSizes');
143
- const units = useCustomUnits({
144
- availableUnits: useSetting('spacing.units') || ['%', 'px', 'em', 'rem', 'vw']
145
- });
146
- const sides = useCustomSides(blockName, 'blockGap');
147
- const ref = useBlockRef(clientId);
148
-
149
- if (useIsGapDisabled(props)) {
150
- return null;
151
- }
152
-
153
- const splitOnAxis = sides && sides.some(side => AXIAL_SIDES.includes(side));
154
-
155
- const onChange = next => {
156
- var _window;
157
-
158
- let blockGap = next; // If splitOnAxis activated we need to return a BoxControl object to the BoxControl component.
159
-
160
- if (!!next && splitOnAxis) {
161
- blockGap = { ...getGapBoxControlValueFromStyle(next)
162
- };
163
- } else if (next !== null && next !== void 0 && next.hasOwnProperty('top')) {
164
- // If splitOnAxis is not enabled, treat the 'top' value as the shorthand gap value.
165
- blockGap = next.top;
166
- }
167
-
168
- const newStyle = { ...style,
169
- spacing: { ...(style === null || style === void 0 ? void 0 : style.spacing),
170
- blockGap
171
- }
172
- };
173
- setAttributes({
174
- style: cleanEmptyObject(newStyle)
175
- }); // In Safari, changing the `gap` CSS value on its own will not trigger the layout
176
- // to be recalculated / re-rendered. To force the updated gap to re-render, here
177
- // we replace the block's node with itself.
178
-
179
- const isSafari = ((_window = window) === null || _window === void 0 ? void 0 : _window.navigator.userAgent) && window.navigator.userAgent.includes('Safari') && !window.navigator.userAgent.includes('Chrome ') && !window.navigator.userAgent.includes('Chromium ');
180
-
181
- if (ref.current && isSafari) {
182
- var _ref$current$parentNo;
183
-
184
- (_ref$current$parentNo = ref.current.parentNode) === null || _ref$current$parentNo === void 0 ? void 0 : _ref$current$parentNo.replaceChild(ref.current, ref.current);
185
- }
186
- };
187
-
188
- const gapValue = getGapBoxControlValueFromStyle(style === null || style === void 0 ? void 0 : (_style$spacing = style.spacing) === null || _style$spacing === void 0 ? void 0 : _style$spacing.blockGap); // The BoxControl component expects a full complement of side values.
189
- // Gap row and column values translate to top/bottom and left/right respectively.
190
-
191
- const boxControlGapValue = splitOnAxis ? { ...gapValue,
192
- right: gapValue === null || gapValue === void 0 ? void 0 : gapValue.left,
193
- bottom: gapValue === null || gapValue === void 0 ? void 0 : gapValue.top
194
- } : {
195
- top: gapValue === null || gapValue === void 0 ? void 0 : gapValue.top
196
- };
197
- return Platform.select({
198
- web: createElement(Fragment, null, (!spacingSizes || (spacingSizes === null || spacingSizes === void 0 ? void 0 : spacingSizes.length) === 0) && (splitOnAxis ? createElement(BoxControl, {
199
- label: __('Block spacing'),
200
- min: 0,
201
- onChange: onChange,
202
- units: units,
203
- sides: sides,
204
- values: boxControlGapValue,
205
- allowReset: false,
206
- splitOnAxis: splitOnAxis
207
- }) : createElement(UnitControl, {
208
- label: __('Block spacing'),
209
- __unstableInputWidth: "80px",
210
- min: 0,
211
- onChange: onChange,
212
- units: units // Default to `row` for combined values.
213
- ,
214
- value: boxControlGapValue
215
- })), (spacingSizes === null || spacingSizes === void 0 ? void 0 : spacingSizes.length) > 0 && createElement(SpacingSizesControl, {
216
- values: boxControlGapValue,
217
- onChange: onChange,
218
- label: __('Block spacing'),
219
- sides: splitOnAxis ? sides : ['top'] // Use 'top' as the shorthand property in non-axial configurations.
220
- ,
221
- units: units,
222
- allowReset: false,
223
- splitOnAxis: splitOnAxis
224
- })),
225
- native: null
226
- });
227
- }
228
45
  //# sourceMappingURL=gap.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/hooks/gap.js"],"names":["__","Platform","getBlockSupport","__experimentalUseCustomUnits","useCustomUnits","__experimentalBoxControl","BoxControl","__experimentalUnitControl","UnitControl","__unstableUseBlockRef","useBlockRef","getSpacingPresetCssVar","SpacingSizesControl","useSetting","AXIAL_SIDES","SPACING_SUPPORT_KEY","useCustomSides","useIsDimensionsSupportValid","cleanEmptyObject","hasGapSupport","blockType","support","blockGap","hasGapValue","props","attributes","style","spacing","undefined","getGapBoxControlValueFromStyle","blockGapValue","isValueString","top","left","getGapCSSValue","defaultValue","blockGapBoxControlValue","row","column","resetGap","setAttributes","useIsGapDisabled","name","blockName","isDisabled","isInvalid","GapEdit","clientId","spacingSizes","units","availableUnits","sides","ref","splitOnAxis","some","side","includes","onChange","next","hasOwnProperty","newStyle","isSafari","window","navigator","userAgent","current","parentNode","replaceChild","gapValue","boxControlGapValue","right","bottom","select","web","length","native"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SAASC,QAAT,QAAyB,oBAAzB;AACA,SAASC,eAAT,QAAgC,mBAAhC;AACA,SACCC,4BAA4B,IAAIC,cADjC,EAECC,wBAAwB,IAAIC,UAF7B,EAGCC,yBAAyB,IAAIC,WAH9B,QAIO,uBAJP;AAMA;AACA;AACA;;AACA,SAASC,qBAAqB,IAAIC,WAAlC,QAAqD,yDAArD;AACA,SAASC,sBAAT,QAAuC,2CAAvC;AACA,OAAOC,mBAAP,MAAgC,qCAAhC;AACA,OAAOC,UAAP,MAAuB,2BAAvB;AACA,SACCC,WADD,EAECC,mBAFD,EAGCC,cAHD,EAICC,2BAJD,QAKO,cALP;AAMA,SAASC,gBAAT,QAAiC,SAAjC;AAEA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,aAAT,CAAwBC,SAAxB,EAAoC;AAC1C,QAAMC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,KAJT;AAKC,MAAA,KAAK,EAAGE,KALT;AAMC,MAAA,MAAM,EAAGkB,kBANV;AAOC,MAAA,UAAU,EAAG,KAPd;AAQC,MAAA,WAAW,EAAGhB;AARf,MADY,GAYZ,cAAC,WAAD;AACC,MAAA,KAAK,EAAGrD,EAAE,CAAE,eAAF,CADX;AAEC,MAAA,oBAAoB,EAAC,MAFtB;AAGC,MAAA,GAAG,EAAG,CAHP;AAIC,MAAA,QAAQ,EAAGyD,QAJZ;AAKC,MAAA,KAAK,EAAGR,KALT,CAMC;AAND;AAOC,MAAA,KAAK,EAAGoB;AAPT,MAbA,CADH,EAwBG,CAAArB,YAAY,SAAZ,IAAAA,YAAY,WAAZ,YAAAA,YAAY,CAAE0B,MAAd,IAAuB,CAAvB,IACD,cAAC,mBAAD;AACC,MAAA,MAAM,EAAGL,kBADV;AAEC,MAAA,QAAQ,EAAGZ,QAFZ;AAGC,MAAA,KAAK,EAAGzD,EAAE,CAAE,eAAF,CAHX;AAIC,MAAA,KAAK,EAAGqD,WAAW,GAAGF,KAAH,GAAW,CAAE,KAAF,CAJ/B,CAI2C;AAJ3C;AAKC,MAAA,KAAK,EAAGF,KALT;AAMC,MAAA,UAAU,EAAG,KANd;AAOC,MAAA,WAAW,EAAGI;AAPf,MAzBF,CAFsB;AAuCvBsB,IAAAA,MAAM,EAAE;AAvCe,GAAjB,CAAP;AAyCA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { Platform } from '@wordpress/element';\nimport { getBlockSupport } from '@wordpress/blocks';\nimport {\n\t__experimentalUseCustomUnits as useCustomUnits,\n\t__experimentalBoxControl as BoxControl,\n\t__experimentalUnitControl as UnitControl,\n} from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { __unstableUseBlockRef as useBlockRef } from '../components/block-list/use-block-props/use-block-refs';\nimport { getSpacingPresetCssVar } from '../components/spacing-sizes-control/utils';\nimport SpacingSizesControl from '../components/spacing-sizes-control';\nimport useSetting from '../components/use-setting';\nimport {\n\tAXIAL_SIDES,\n\tSPACING_SUPPORT_KEY,\n\tuseCustomSides,\n\tuseIsDimensionsSupportValid,\n} from './dimensions';\nimport { cleanEmptyObject } from './utils';\n\n/**\n * Determines if there is gap support.\n *\n * @param {string|Object} blockType Block name or Block Type object.\n * @return {boolean} Whether there is support.\n */\nexport function hasGapSupport( blockType ) {\n\tconst support = getBlockSupport( blockType, SPACING_SUPPORT_KEY );\n\treturn !! ( true === support || support?.blockGap );\n}\n\n/**\n * Checks if there is a current value in the gap block support attributes.\n *\n * @param {Object} props Block props.\n * @return {boolean} Whether or not the block has a gap value set.\n */\nexport function hasGapValue( props ) {\n\treturn props.attributes.style?.spacing?.blockGap !== undefined;\n}\n\n/**\n * Returns a BoxControl object value from a given blockGap style value.\n * The string check is for backwards compatibility before Gutenberg supported\n * split gap values (row and column) and the value was a string n + unit.\n *\n * @param {string? | Object?} blockGapValue A block gap string or axial object value, e.g., '10px' or { top: '10px', left: '10px'}.\n * @return {Object|null} A value to pass to the BoxControl component.\n */\nexport function getGapBoxControlValueFromStyle( blockGapValue ) {\n\tif ( ! blockGapValue ) {\n\t\treturn null;\n\t}\n\n\tconst isValueString = typeof blockGapValue === 'string';\n\treturn {\n\t\ttop: isValueString ? blockGapValue : blockGapValue?.top,\n\t\tleft: isValueString ? blockGapValue : blockGapValue?.left,\n\t};\n}\n\n/**\n * Returns a CSS value for the `gap` property from a given blockGap style.\n *\n * @param {string? | Object?} blockGapValue A block gap string or axial object value, e.g., '10px' or { top: '10px', left: '10px'}.\n * @param {string?} defaultValue A default gap value.\n * @return {string|null} The concatenated gap value (row and column).\n */\nexport function getGapCSSValue( blockGapValue, defaultValue = '0' ) {\n\tconst blockGapBoxControlValue =\n\t\tgetGapBoxControlValueFromStyle( blockGapValue );\n\tif ( ! blockGapBoxControlValue ) {\n\t\treturn null;\n\t}\n\n\tconst row =\n\t\tgetSpacingPresetCssVar( blockGapBoxControlValue?.top ) || defaultValue;\n\tconst column =\n\t\tgetSpacingPresetCssVar( blockGapBoxControlValue?.left ) || defaultValue;\n\n\treturn row === column ? row : `${ row } ${ column }`;\n}\n\n/**\n * Resets the gap block support attribute. This can be used when disabling\n * the gap support controls for a block via a progressive discovery panel.\n *\n * @param {Object} props Block props.\n * @param {Object} props.attributes Block's attributes.\n * @param {Object} props.setAttributes Function to set block's attributes.\n */\nexport function resetGap( { attributes = {}, setAttributes } ) {\n\tconst { style } = attributes;\n\n\tsetAttributes( {\n\t\tstyle: {\n\t\t\t...style,\n\t\t\tspacing: {\n\t\t\t\t...style?.spacing,\n\t\t\t\tblockGap: undefined,\n\t\t\t},\n\t\t},\n\t} );\n}\n\n/**\n * Custom hook that checks if gap settings have been disabled.\n *\n * @param {string} name The name of the block.\n * @return {boolean} Whether the gap setting is disabled.\n */\nexport function useIsGapDisabled( { name: blockName } = {} ) {\n\tconst isDisabled = ! useSetting( 'spacing.blockGap' );\n\tconst isInvalid = ! useIsDimensionsSupportValid( blockName, 'blockGap' );\n\n\treturn ! hasGapSupport( blockName ) || isDisabled || isInvalid;\n}\n\n/**\n * Inspector control panel containing the gap related configuration\n *\n * @param {Object} props\n *\n * @return {WPElement} Gap edit element.\n */\nexport function GapEdit( props ) {\n\tconst {\n\t\tclientId,\n\t\tattributes: { style },\n\t\tname: blockName,\n\t\tsetAttributes,\n\t} = props;\n\n\tconst spacingSizes = useSetting( 'spacing.spacingSizes' );\n\n\tconst units = useCustomUnits( {\n\t\tavailableUnits: useSetting( 'spacing.units' ) || [\n\t\t\t'%',\n\t\t\t'px',\n\t\t\t'em',\n\t\t\t'rem',\n\t\t\t'vw',\n\t\t],\n\t} );\n\tconst sides = useCustomSides( blockName, 'blockGap' );\n\tconst ref = useBlockRef( clientId );\n\n\tif ( useIsGapDisabled( props ) ) {\n\t\treturn null;\n\t}\n\n\tconst splitOnAxis =\n\t\tsides && sides.some( ( side ) => AXIAL_SIDES.includes( side ) );\n\n\tconst onChange = ( next ) => {\n\t\tlet blockGap = next;\n\n\t\t// If splitOnAxis activated we need to return a BoxControl object to the BoxControl component.\n\t\tif ( !! next && splitOnAxis ) {\n\t\t\tblockGap = { ...getGapBoxControlValueFromStyle( next ) };\n\t\t} else if ( next?.hasOwnProperty( 'top' ) ) {\n\t\t\t// If splitOnAxis is not enabled, treat the 'top' value as the shorthand gap value.\n\t\t\tblockGap = next.top;\n\t\t}\n\n\t\tconst newStyle = {\n\t\t\t...style,\n\t\t\tspacing: {\n\t\t\t\t...style?.spacing,\n\t\t\t\tblockGap,\n\t\t\t},\n\t\t};\n\n\t\tsetAttributes( {\n\t\t\tstyle: cleanEmptyObject( newStyle ),\n\t\t} );\n\n\t\t// In Safari, changing the `gap` CSS value on its own will not trigger the layout\n\t\t// to be recalculated / re-rendered. To force the updated gap to re-render, here\n\t\t// we replace the block's node with itself.\n\t\tconst isSafari =\n\t\t\twindow?.navigator.userAgent &&\n\t\t\twindow.navigator.userAgent.includes( 'Safari' ) &&\n\t\t\t! window.navigator.userAgent.includes( 'Chrome ' ) &&\n\t\t\t! window.navigator.userAgent.includes( 'Chromium ' );\n\n\t\tif ( ref.current && isSafari ) {\n\t\t\tref.current.parentNode?.replaceChild( ref.current, ref.current );\n\t\t}\n\t};\n\n\tconst gapValue = getGapBoxControlValueFromStyle( style?.spacing?.blockGap );\n\n\t// The BoxControl component expects a full complement of side values.\n\t// Gap row and column values translate to top/bottom and left/right respectively.\n\tconst boxControlGapValue = splitOnAxis\n\t\t? {\n\t\t\t\t...gapValue,\n\t\t\t\tright: gapValue?.left,\n\t\t\t\tbottom: gapValue?.top,\n\t\t }\n\t\t: {\n\t\t\t\ttop: gapValue?.top,\n\t\t };\n\n\treturn Platform.select( {\n\t\tweb: (\n\t\t\t<>\n\t\t\t\t{ ( ! spacingSizes || spacingSizes?.length === 0 ) &&\n\t\t\t\t\t( splitOnAxis ? (\n\t\t\t\t\t\t<BoxControl\n\t\t\t\t\t\t\tlabel={ __( 'Block spacing' ) }\n\t\t\t\t\t\t\tmin={ 0 }\n\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\tunits={ units }\n\t\t\t\t\t\t\tsides={ sides }\n\t\t\t\t\t\t\tvalues={ boxControlGapValue }\n\t\t\t\t\t\t\tallowReset={ false }\n\t\t\t\t\t\t\tsplitOnAxis={ splitOnAxis }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<UnitControl\n\t\t\t\t\t\t\tlabel={ __( 'Block spacing' ) }\n\t\t\t\t\t\t\t__unstableInputWidth=\"80px\"\n\t\t\t\t\t\t\tmin={ 0 }\n\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\tunits={ units }\n\t\t\t\t\t\t\t// Default to `row` for combined values.\n\t\t\t\t\t\t\tvalue={ boxControlGapValue }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) ) }\n\t\t\t\t{ spacingSizes?.length > 0 && (\n\t\t\t\t\t<SpacingSizesControl\n\t\t\t\t\t\tvalues={ boxControlGapValue }\n\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\tlabel={ __( 'Block spacing' ) }\n\t\t\t\t\t\tsides={ splitOnAxis ? sides : [ 'top' ] } // Use 'top' as the shorthand property in non-axial configurations.\n\t\t\t\t\t\tunits={ units }\n\t\t\t\t\t\tallowReset={ false }\n\t\t\t\t\t\tsplitOnAxis={ splitOnAxis }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</>\n\t\t),\n\t\tnative: null,\n\t} );\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/hooks/gap.js"],"names":["getSpacingPresetCssVar","getGapBoxControlValueFromStyle","blockGapValue","isValueString","top","left","getGapCSSValue","defaultValue","blockGapBoxControlValue","row","column"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,sBAAT,QAAuC,2CAAvC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,8BAAT,CAAyCC,aAAzC,EAAyD;AAC/D,MAAK,CAAEA,aAAP,EAAuB;AACtB,WAAO,IAAP;AACA;;AAED,QAAMC,aAAa,GAAG,OAAOD,aAAP,KAAyB,QAA/C;AACA,SAAO;AACNE,IAAAA,GAAG,EAAED,aAAa,GAAGD,aAAH,GAAmBA,aAAnB,aAAmBA,aAAnB,uBAAmBA,aAAa,CAAEE,GAD9C;AAENC,IAAAA,IAAI,EAAEF,aAAa,GAAGD,aAAH,GAAmBA,aAAnB,aAAmBA,aAAnB,uBAAmBA,aAAa,CAAEG;AAF/C,GAAP;AAIA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,cAAT,CAAyBJ,aAAzB,EAA6D;AAAA,MAArBK,YAAqB,uEAAN,GAAM;AACnE,QAAMC,uBAAuB,GAC5BP,8BAA8B,CAAEC,aAAF,CAD/B;;AAEA,MAAK,CAAEM,uBAAP,EAAiC;AAChC,WAAO,IAAP;AACA;;AAED,QAAMC,GAAG,GACRT,sBAAsB,CAAEQ,uBAAF,aAAEA,uBAAF,uBAAEA,uBAAuB,CAAEJ,GAA3B,CAAtB,IAA0DG,YAD3D;AAEA,QAAMG,MAAM,GACXV,sBAAsB,CAAEQ,uBAAF,aAAEA,uBAAF,uBAAEA,uBAAuB,CAAEH,IAA3B,CAAtB,IAA2DE,YAD5D;AAGA,SAAOE,GAAG,KAAKC,MAAR,GAAiBD,GAAjB,GAAwB,GAAGA,GAAK,IAAIC,MAAQ,EAAnD;AACA","sourcesContent":["/**\n * Internal dependencies\n */\nimport { getSpacingPresetCssVar } from '../components/spacing-sizes-control/utils';\n\n/**\n * Returns a BoxControl object value from a given blockGap style value.\n * The string check is for backwards compatibility before Gutenberg supported\n * split gap values (row and column) and the value was a string n + unit.\n *\n * @param {string? | Object?} blockGapValue A block gap string or axial object value, e.g., '10px' or { top: '10px', left: '10px'}.\n * @return {Object|null} A value to pass to the BoxControl component.\n */\nexport function getGapBoxControlValueFromStyle( blockGapValue ) {\n\tif ( ! blockGapValue ) {\n\t\treturn null;\n\t}\n\n\tconst isValueString = typeof blockGapValue === 'string';\n\treturn {\n\t\ttop: isValueString ? blockGapValue : blockGapValue?.top,\n\t\tleft: isValueString ? blockGapValue : blockGapValue?.left,\n\t};\n}\n\n/**\n * Returns a CSS value for the `gap` property from a given blockGap style.\n *\n * @param {string? | Object?} blockGapValue A block gap string or axial object value, e.g., '10px' or { top: '10px', left: '10px'}.\n * @param {string?} defaultValue A default gap value.\n * @return {string|null} The concatenated gap value (row and column).\n */\nexport function getGapCSSValue( blockGapValue, defaultValue = '0' ) {\n\tconst blockGapBoxControlValue =\n\t\tgetGapBoxControlValueFromStyle( blockGapValue );\n\tif ( ! blockGapBoxControlValue ) {\n\t\treturn null;\n\t}\n\n\tconst row =\n\t\tgetSpacingPresetCssVar( blockGapBoxControlValue?.top ) || defaultValue;\n\tconst column =\n\t\tgetSpacingPresetCssVar( blockGapBoxControlValue?.left ) || defaultValue;\n\n\treturn row === column ? row : `${ row } ${ column }`;\n}\n"]}
@@ -31,7 +31,8 @@ const layoutBlockSupportKey = '__experimentalLayout';
31
31
  /**
32
32
  * Generates the utility classnames for the given block's layout attributes.
33
33
  *
34
- * @param { Object } block Block object.
34
+ * @param { Object } blockAttributes Block attributes.
35
+ * @param { string } blockName Block name.
35
36
  *
36
37
  * @return { Array } Array of CSS classname strings.
37
38
  */
@@ -39,7 +40,8 @@ const layoutBlockSupportKey = '__experimentalLayout';
39
40
  export function useLayoutClasses() {
40
41
  var _globalLayoutSettings, _globalLayoutSettings2;
41
42
 
42
- let block = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
43
+ let blockAttributes = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
44
+ let blockName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
43
45
  const rootPaddingAlignment = useSelect(select => {
44
46
  var _getSettings$__experi;
45
47
 
@@ -49,16 +51,12 @@ export function useLayoutClasses() {
49
51
  return (_getSettings$__experi = getSettings().__experimentalFeatures) === null || _getSettings$__experi === void 0 ? void 0 : _getSettings$__experi.useRootPaddingAwareAlignments;
50
52
  }, []);
51
53
  const globalLayoutSettings = useSetting('layout') || {};
52
- const {
53
- attributes = {},
54
- name
55
- } = block;
56
54
  const {
57
55
  layout
58
- } = attributes;
56
+ } = blockAttributes;
59
57
  const {
60
58
  default: defaultBlockLayout
61
- } = getBlockSupport(name, layoutBlockSupportKey) || {};
59
+ } = getBlockSupport(blockName, layoutBlockSupportKey) || {};
62
60
  const usedLayout = layout !== null && layout !== void 0 && layout.inherit || layout !== null && layout !== void 0 && layout.contentSize || layout !== null && layout !== void 0 && layout.wideSize ? { ...layout,
63
61
  type: 'constrained'
64
62
  } : layout || defaultBlockLayout || {};
@@ -67,7 +65,9 @@ export function useLayoutClasses() {
67
65
  if (globalLayoutSettings !== null && globalLayoutSettings !== void 0 && (_globalLayoutSettings = globalLayoutSettings.definitions) !== null && _globalLayoutSettings !== void 0 && (_globalLayoutSettings2 = _globalLayoutSettings[(usedLayout === null || usedLayout === void 0 ? void 0 : usedLayout.type) || 'default']) !== null && _globalLayoutSettings2 !== void 0 && _globalLayoutSettings2.className) {
68
66
  var _globalLayoutSettings3, _globalLayoutSettings4;
69
67
 
70
- layoutClassnames.push(globalLayoutSettings === null || globalLayoutSettings === void 0 ? void 0 : (_globalLayoutSettings3 = globalLayoutSettings.definitions) === null || _globalLayoutSettings3 === void 0 ? void 0 : (_globalLayoutSettings4 = _globalLayoutSettings3[(usedLayout === null || usedLayout === void 0 ? void 0 : usedLayout.type) || 'default']) === null || _globalLayoutSettings4 === void 0 ? void 0 : _globalLayoutSettings4.className);
68
+ const baseClassName = globalLayoutSettings === null || globalLayoutSettings === void 0 ? void 0 : (_globalLayoutSettings3 = globalLayoutSettings.definitions) === null || _globalLayoutSettings3 === void 0 ? void 0 : (_globalLayoutSettings4 = _globalLayoutSettings3[(usedLayout === null || usedLayout === void 0 ? void 0 : usedLayout.type) || 'default']) === null || _globalLayoutSettings4 === void 0 ? void 0 : _globalLayoutSettings4.className;
69
+ const compoundClassName = `wp-block-${blockName.split('/').pop()}-${baseClassName}`;
70
+ layoutClassnames.push(baseClassName, compoundClassName);
71
71
  }
72
72
 
73
73
  if ((usedLayout !== null && usedLayout !== void 0 && usedLayout.inherit || usedLayout !== null && usedLayout !== void 0 && usedLayout.contentSize || (usedLayout === null || usedLayout === void 0 ? void 0 : usedLayout.type) === 'constrained') && rootPaddingAlignment) {
@@ -91,8 +91,9 @@ export function useLayoutClasses() {
91
91
  /**
92
92
  * Generates a CSS rule with the given block's layout styles.
93
93
  *
94
- * @param { Object } block Block object.
95
- * @param { string } selector A selector to use in generating the CSS rule.
94
+ * @param { Object } blockAttributes Block attributes.
95
+ * @param { string } blockName Block name.
96
+ * @param { string } selector A selector to use in generating the CSS rule.
96
97
  *
97
98
  * @return { string } CSS rule.
98
99
  */
@@ -100,16 +101,13 @@ export function useLayoutClasses() {
100
101
  export function useLayoutStyles() {
101
102
  var _fullLayoutType$getLa;
102
103
 
103
- let block = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
104
- let selector = arguments.length > 1 ? arguments[1] : undefined;
105
- const {
106
- attributes = {},
107
- name
108
- } = block;
104
+ let blockAttributes = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
105
+ let blockName = arguments.length > 1 ? arguments[1] : undefined;
106
+ let selector = arguments.length > 2 ? arguments[2] : undefined;
109
107
  const {
110
108
  layout = {},
111
109
  style = {}
112
- } = attributes; // Update type for blocks using legacy layouts.
110
+ } = blockAttributes; // Update type for blocks using legacy layouts.
113
111
 
114
112
  const usedLayout = layout !== null && layout !== void 0 && layout.inherit || layout !== null && layout !== void 0 && layout.contentSize || layout !== null && layout !== void 0 && layout.wideSize ? { ...layout,
115
113
  type: 'constrained'
@@ -119,7 +117,7 @@ export function useLayoutStyles() {
119
117
  const blockGapSupport = useSetting('spacing.blockGap');
120
118
  const hasBlockGapSupport = blockGapSupport !== null;
121
119
  const css = fullLayoutType === null || fullLayoutType === void 0 ? void 0 : (_fullLayoutType$getLa = fullLayoutType.getLayoutStyle) === null || _fullLayoutType$getLa === void 0 ? void 0 : _fullLayoutType$getLa.call(fullLayoutType, {
122
- blockName: name,
120
+ blockName,
123
121
  selector,
124
122
  layout,
125
123
  layoutDefinitions: globalLayoutSettings === null || globalLayoutSettings === void 0 ? void 0 : globalLayoutSettings.definitions,
@@ -131,6 +129,7 @@ export function useLayoutStyles() {
131
129
 
132
130
  function LayoutPanel(_ref) {
133
131
  let {
132
+ clientId,
134
133
  setAttributes,
135
134
  attributes,
136
135
  name: blockName
@@ -139,12 +138,19 @@ function LayoutPanel(_ref) {
139
138
  layout
140
139
  } = attributes;
141
140
  const defaultThemeLayout = useSetting('layout');
142
- const themeSupportsLayout = useSelect(select => {
141
+ const {
142
+ themeSupportsLayout,
143
+ isContentLocked
144
+ } = useSelect(select => {
143
145
  const {
144
- getSettings
146
+ getSettings,
147
+ __unstableGetContentLockingParent
145
148
  } = select(blockEditorStore);
146
- return getSettings().supportsLayout;
147
- }, []);
149
+ return {
150
+ themeSupportsLayout: getSettings().supportsLayout,
151
+ isContentLocked: __unstableGetContentLockingParent(clientId)
152
+ };
153
+ }, [clientId]);
148
154
  const layoutBlockSupport = getBlockSupport(blockName, layoutBlockSupportKey, {});
149
155
  const {
150
156
  allowSwitching,
@@ -195,6 +201,7 @@ function LayoutPanel(_ref) {
195
201
  return createElement(Fragment, null, createElement(InspectorControls, null, createElement(PanelBody, {
196
202
  title: __('Layout')
197
203
  }, showInheritToggle && createElement(Fragment, null, createElement(ToggleControl, {
204
+ __nextHasNoMarginBottom: true,
198
205
  className: "block-editor-hooks__toggle-control",
199
206
  label: __('Inner blocks use content width'),
200
207
  checked: (layoutType === null || layoutType === void 0 ? void 0 : layoutType.name) === 'constrained' || hasContentSizeOrLegacySettings,
@@ -215,7 +222,7 @@ function LayoutPanel(_ref) {
215
222
  layout: usedLayout,
216
223
  onChange: onChangeLayout,
217
224
  layoutBlockSupport: layoutBlockSupport
218
- }))), !inherit && layoutType && createElement(layoutType.toolBarControls, {
225
+ }))), !inherit && !isContentLocked && layoutType && createElement(layoutType.toolBarControls, {
219
226
  layout: usedLayout,
220
227
  onChange: onChangeLayout,
221
228
  layoutBlockSupport: layoutBlockSupport
@@ -295,8 +302,7 @@ export const withInspectorControls = createHigherOrderComponent(BlockEdit => pro
295
302
  export const withLayoutStyles = createHigherOrderComponent(BlockListBlock => props => {
296
303
  const {
297
304
  name,
298
- attributes,
299
- block
305
+ attributes
300
306
  } = props;
301
307
  const hasLayoutBlockSupport = hasBlockSupport(name, layoutBlockSupportKey);
302
308
  const disableLayoutStyles = useSelect(select => {
@@ -318,7 +324,7 @@ export const withLayoutStyles = createHigherOrderComponent(BlockListBlock => pro
318
324
  const usedLayout = layout !== null && layout !== void 0 && layout.inherit || layout !== null && layout !== void 0 && layout.contentSize || layout !== null && layout !== void 0 && layout.wideSize ? { ...layout,
319
325
  type: 'constrained'
320
326
  } : layout || defaultBlockLayout || {};
321
- const layoutClasses = hasLayoutBlockSupport ? useLayoutClasses(block) : null; // Higher specificity to override defaults from theme.json.
327
+ const layoutClasses = hasLayoutBlockSupport ? useLayoutClasses(attributes, name) : null; // Higher specificity to override defaults from theme.json.
322
328
 
323
329
  const selector = `.wp-container-${id}.wp-container-${id}`;
324
330
  const blockGapSupport = useSetting('spacing.blockGap');
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/hooks/layout.js"],"names":["classnames","kebabCase","createHigherOrderComponent","useInstanceId","addFilter","getBlockSupport","hasBlockSupport","useSelect","Button","ButtonGroup","ToggleControl","PanelBody","__","useContext","createPortal","store","blockEditorStore","InspectorControls","useSetting","LayoutStyle","BlockList","getLayoutType","getLayoutTypes","layoutBlockSupportKey","useLayoutClasses","block","rootPaddingAlignment","select","getSettings","__experimentalFeatures","useRootPaddingAwareAlignments","globalLayoutSettings","attributes","name","layout","default","defaultBlockLayout","usedLayout","inherit","contentSize","wideSize","type","layoutClassnames","definitions","className","push","orientation","justifyContent","flexWrap","useLayoutStyles","selector","style","fullLayoutType","blockGapSupport","hasBlockGapSupport","css","getLayoutStyle","blockName","layoutDefinitions","LayoutPanel","setAttributes","defaultThemeLayout","themeSupportsLayout","supportsLayout","layoutBlockSupport","allowSwitching","allowEditing","allowInheriting","showInheritToggle","layoutType","constrainedType","displayControlsForLegacyLayouts","hasContentSizeOrLegacySettings","onChangeType","newType","onChangeLayout","newLayout","LayoutTypeSwitcher","onChange","map","label","addAttribute","settings","withInspectorControls","BlockEdit","props","supportLayout","withLayoutStyles","BlockListBlock","hasLayoutBlockSupport","disableLayoutStyles","shouldRenderLayoutStyles","id","element","__unstableElementContext","layoutClasses","layoutClassNames","withChildLayoutStyles","selfStretch","flexSize","hasChildLayout","shouldRenderChildLayoutStyles"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AACA,SAASC,SAAT,QAA0B,QAA1B;AAEA;AACA;AACA;;AACA,SAASC,0BAAT,EAAqCC,aAArC,QAA0D,oBAA1D;AACA,SAASC,SAAT,QAA0B,kBAA1B;AACA,SAASC,eAAT,EAA0BC,eAA1B,QAAiD,mBAAjD;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SACCC,MADD,EAECC,WAFD,EAGCC,aAHD,EAICC,SAJD,QAKO,uBALP;AAMA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,UAAT,EAAqBC,YAArB,QAAyC,oBAAzC;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,UAA1C;AACA,SAASC,iBAAT,QAAkC,eAAlC;AACA,OAAOC,UAAP,MAAuB,2BAAvB;AACA,SAASC,WAAT,QAA4B,iCAA5B;AACA,OAAOC,SAAP,MAAsB,0BAAtB;AACA,SAASC,aAAT,EAAwBC,cAAxB,QAA8C,YAA9C;AAEA,MAAMC,qBAAqB,GAAG,sBAA9B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,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A7C6D,CAAxD;AAgDPxC,SAAS,CACR,0BADQ,EAER,0BAFQ,EAGR6E,YAHQ,CAAT;AAKA7E,SAAS,CACR,uBADQ,EAER,uCAFQ,EAGRmF,gBAHQ,CAAT;AAKAnF,SAAS,CACR,uBADQ,EAER,6CAFQ,EAGR6F,qBAHQ,CAAT;AAKA7F,SAAS,CACR,kBADQ,EAER,4CAFQ,EAGR+E,qBAHQ,CAAT","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport { kebabCase } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';\nimport { addFilter } from '@wordpress/hooks';\nimport { getBlockSupport, hasBlockSupport } from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tButton,\n\tButtonGroup,\n\tToggleControl,\n\tPanelBody,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useContext, createPortal } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../store';\nimport { InspectorControls } from '../components';\nimport useSetting from '../components/use-setting';\nimport { LayoutStyle } from '../components/block-list/layout';\nimport BlockList from '../components/block-list';\nimport { getLayoutType, getLayoutTypes } from '../layouts';\n\nconst layoutBlockSupportKey = '__experimentalLayout';\n\n/**\n * Generates the utility classnames for the given block's layout attributes.\n *\n * @param { Object } block Block object.\n *\n * @return { Array } Array of CSS classname strings.\n */\nexport function useLayoutClasses( block = {} ) {\n\tconst rootPaddingAlignment = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn getSettings().__experimentalFeatures\n\t\t\t?.useRootPaddingAwareAlignments;\n\t}, [] );\n\tconst globalLayoutSettings = useSetting( 'layout' ) || {};\n\n\tconst { attributes = {}, name } = block;\n\tconst { layout } = attributes;\n\n\tconst { default: defaultBlockLayout } =\n\t\tgetBlockSupport( name, layoutBlockSupportKey ) || {};\n\tconst usedLayout =\n\t\tlayout?.inherit || layout?.contentSize || layout?.wideSize\n\t\t\t? { ...layout, type: 'constrained' }\n\t\t\t: layout || defaultBlockLayout || {};\n\n\tconst layoutClassnames = [];\n\n\tif (\n\t\tglobalLayoutSettings?.definitions?.[ usedLayout?.type || 'default' ]\n\t\t\t?.className\n\t) {\n\t\tlayoutClassnames.push(\n\t\t\tglobalLayoutSettings?.definitions?.[ usedLayout?.type || 'default' ]\n\t\t\t\t?.className\n\t\t);\n\t}\n\n\tif (\n\t\t( usedLayout?.inherit ||\n\t\t\tusedLayout?.contentSize ||\n\t\t\tusedLayout?.type === 'constrained' ) &&\n\t\trootPaddingAlignment\n\t) {\n\t\tlayoutClassnames.push( 'has-global-padding' );\n\t}\n\n\tif ( usedLayout?.orientation ) {\n\t\tlayoutClassnames.push( `is-${ kebabCase( usedLayout.orientation ) }` );\n\t}\n\n\tif ( usedLayout?.justifyContent ) {\n\t\tlayoutClassnames.push(\n\t\t\t`is-content-justification-${ kebabCase(\n\t\t\t\tusedLayout.justifyContent\n\t\t\t) }`\n\t\t);\n\t}\n\n\tif ( usedLayout?.flexWrap && usedLayout.flexWrap === 'nowrap' ) {\n\t\tlayoutClassnames.push( 'is-nowrap' );\n\t}\n\n\treturn layoutClassnames;\n}\n\n/**\n * Generates a CSS rule with the given block's layout styles.\n *\n * @param { Object } block Block object.\n * @param { string } selector A selector to use in generating the CSS rule.\n *\n * @return { string } CSS rule.\n */\nexport function useLayoutStyles( block = {}, selector ) {\n\tconst { attributes = {}, name } = block;\n\tconst { layout = {}, style = {} } = attributes;\n\t// Update type for blocks using legacy layouts.\n\tconst usedLayout =\n\t\tlayout?.inherit || layout?.contentSize || layout?.wideSize\n\t\t\t? { ...layout, type: 'constrained' }\n\t\t\t: layout || {};\n\tconst fullLayoutType = getLayoutType( usedLayout?.type || 'default' );\n\tconst globalLayoutSettings = useSetting( 'layout' ) || {};\n\tconst blockGapSupport = useSetting( 'spacing.blockGap' );\n\tconst hasBlockGapSupport = blockGapSupport !== null;\n\tconst css = fullLayoutType?.getLayoutStyle?.( {\n\t\tblockName: name,\n\t\tselector,\n\t\tlayout,\n\t\tlayoutDefinitions: globalLayoutSettings?.definitions,\n\t\tstyle,\n\t\thasBlockGapSupport,\n\t} );\n\treturn css;\n}\n\nfunction LayoutPanel( { setAttributes, attributes, name: blockName } ) {\n\tconst { layout } = attributes;\n\tconst defaultThemeLayout = useSetting( 'layout' );\n\tconst themeSupportsLayout = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn getSettings().supportsLayout;\n\t}, [] );\n\n\tconst layoutBlockSupport = getBlockSupport(\n\t\tblockName,\n\t\tlayoutBlockSupportKey,\n\t\t{}\n\t);\n\tconst {\n\t\tallowSwitching,\n\t\tallowEditing = true,\n\t\tallowInheriting = true,\n\t\tdefault: defaultBlockLayout,\n\t} = layoutBlockSupport;\n\n\tif ( ! allowEditing ) {\n\t\treturn null;\n\t}\n\n\t// Only show the inherit toggle if it's supported,\n\t// a default theme layout is set (e.g. one that provides `contentSize` and/or `wideSize` values),\n\t// and either the default / flow or the constrained layout type is in use, as the toggle switches from one to the other.\n\tconst showInheritToggle = !! (\n\t\tallowInheriting &&\n\t\t!! defaultThemeLayout &&\n\t\t( ! layout?.type ||\n\t\t\tlayout?.type === 'default' ||\n\t\t\tlayout?.type === 'constrained' ||\n\t\t\tlayout?.inherit )\n\t);\n\n\tconst usedLayout = layout || defaultBlockLayout || {};\n\tconst {\n\t\tinherit = false,\n\t\ttype = 'default',\n\t\tcontentSize = null,\n\t} = usedLayout;\n\t/**\n\t * `themeSupportsLayout` is only relevant to the `default/flow` or\n\t * `constrained` layouts and it should not be taken into account when other\n\t * `layout` types are used.\n\t */\n\tif (\n\t\t( type === 'default' || type === 'constrained' ) &&\n\t\t! themeSupportsLayout\n\t) {\n\t\treturn null;\n\t}\n\tconst layoutType = getLayoutType( type );\n\tconst constrainedType = getLayoutType( 'constrained' );\n\tconst displayControlsForLegacyLayouts =\n\t\t! usedLayout.type && ( contentSize || inherit );\n\tconst hasContentSizeOrLegacySettings = !! inherit || !! contentSize;\n\n\tconst onChangeType = ( newType ) =>\n\t\tsetAttributes( { layout: { type: newType } } );\n\tconst onChangeLayout = ( newLayout ) =>\n\t\tsetAttributes( { layout: newLayout } );\n\n\treturn (\n\t\t<>\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody title={ __( 'Layout' ) }>\n\t\t\t\t\t{ showInheritToggle && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t\tclassName=\"block-editor-hooks__toggle-control\"\n\t\t\t\t\t\t\t\tlabel={ __( 'Inner blocks use content width' ) }\n\t\t\t\t\t\t\t\tchecked={\n\t\t\t\t\t\t\t\t\tlayoutType?.name === 'constrained' ||\n\t\t\t\t\t\t\t\t\thasContentSizeOrLegacySettings\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\tlayout: {\n\t\t\t\t\t\t\t\t\t\t\ttype:\n\t\t\t\t\t\t\t\t\t\t\t\tlayoutType?.name ===\n\t\t\t\t\t\t\t\t\t\t\t\t\t'constrained' ||\n\t\t\t\t\t\t\t\t\t\t\t\thasContentSizeOrLegacySettings\n\t\t\t\t\t\t\t\t\t\t\t\t\t? 'default'\n\t\t\t\t\t\t\t\t\t\t\t\t\t: 'constrained',\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\thelp={\n\t\t\t\t\t\t\t\t\tlayoutType?.name === 'constrained' ||\n\t\t\t\t\t\t\t\t\thasContentSizeOrLegacySettings\n\t\t\t\t\t\t\t\t\t\t? __(\n\t\t\t\t\t\t\t\t\t\t\t\t'Nested blocks use content width with options for full and wide widths.'\n\t\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t\t\t\t'Nested blocks will fill the width of this container. Toggle to constrain.'\n\t\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</>\n\t\t\t\t\t) }\n\n\t\t\t\t\t{ ! inherit && allowSwitching && (\n\t\t\t\t\t\t<LayoutTypeSwitcher\n\t\t\t\t\t\t\ttype={ type }\n\t\t\t\t\t\t\tonChange={ onChangeType }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\n\t\t\t\t\t{ layoutType && layoutType.name !== 'default' && (\n\t\t\t\t\t\t<layoutType.inspectorControls\n\t\t\t\t\t\t\tlayout={ usedLayout }\n\t\t\t\t\t\t\tonChange={ onChangeLayout }\n\t\t\t\t\t\t\tlayoutBlockSupport={ layoutBlockSupport }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\t{ constrainedType && displayControlsForLegacyLayouts && (\n\t\t\t\t\t\t<constrainedType.inspectorControls\n\t\t\t\t\t\t\tlayout={ usedLayout }\n\t\t\t\t\t\t\tonChange={ onChangeLayout }\n\t\t\t\t\t\t\tlayoutBlockSupport={ layoutBlockSupport }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</PanelBody>\n\t\t\t</InspectorControls>\n\t\t\t{ ! inherit && layoutType && (\n\t\t\t\t<layoutType.toolBarControls\n\t\t\t\t\tlayout={ usedLayout }\n\t\t\t\t\tonChange={ onChangeLayout }\n\t\t\t\t\tlayoutBlockSupport={ layoutBlockSupport }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nfunction LayoutTypeSwitcher( { type, onChange } ) {\n\treturn (\n\t\t<ButtonGroup>\n\t\t\t{ getLayoutTypes().map( ( { name, label } ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tkey={ name }\n\t\t\t\t\t\tisPressed={ type === name }\n\t\t\t\t\t\tonClick={ () => onChange( name ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ label }\n\t\t\t\t\t</Button>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</ButtonGroup>\n\t);\n}\n\n/**\n * Filters registered block settings, extending attributes to include `layout`.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nexport function addAttribute( settings ) {\n\tif ( 'type' in ( settings.attributes?.layout ?? {} ) ) {\n\t\treturn settings;\n\t}\n\tif ( hasBlockSupport( settings, layoutBlockSupportKey ) ) {\n\t\tsettings.attributes = {\n\t\t\t...settings.attributes,\n\t\t\tlayout: {\n\t\t\t\ttype: 'object',\n\t\t\t},\n\t\t};\n\t}\n\n\treturn settings;\n}\n\n/**\n * Override the default edit UI to include layout controls\n *\n * @param {Function} BlockEdit Original component.\n *\n * @return {Function} Wrapped component.\n */\nexport const withInspectorControls = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tconst { name: blockName } = props;\n\t\tconst supportLayout = hasBlockSupport(\n\t\t\tblockName,\n\t\t\tlayoutBlockSupportKey\n\t\t);\n\n\t\treturn [\n\t\t\tsupportLayout && <LayoutPanel key=\"layout\" { ...props } />,\n\t\t\t<BlockEdit key=\"edit\" { ...props } />,\n\t\t];\n\t},\n\t'withInspectorControls'\n);\n\n/**\n * Override the default block element to add the layout styles.\n *\n * @param {Function} BlockListBlock Original component.\n *\n * @return {Function} Wrapped component.\n */\nexport const withLayoutStyles = createHigherOrderComponent(\n\t( BlockListBlock ) => ( props ) => {\n\t\tconst { name, attributes, block } = props;\n\t\tconst hasLayoutBlockSupport = hasBlockSupport(\n\t\t\tname,\n\t\t\tlayoutBlockSupportKey\n\t\t);\n\t\tconst disableLayoutStyles = useSelect( ( select ) => {\n\t\t\tconst { getSettings } = select( blockEditorStore );\n\t\t\treturn !! getSettings().disableLayoutStyles;\n\t\t} );\n\t\tconst shouldRenderLayoutStyles =\n\t\t\thasLayoutBlockSupport && ! disableLayoutStyles;\n\t\tconst id = useInstanceId( BlockListBlock );\n\t\tconst defaultThemeLayout = useSetting( 'layout' ) || {};\n\t\tconst element = useContext( BlockList.__unstableElementContext );\n\t\tconst { layout } = attributes;\n\t\tconst { default: defaultBlockLayout } =\n\t\t\tgetBlockSupport( name, layoutBlockSupportKey ) || {};\n\t\tconst usedLayout =\n\t\t\tlayout?.inherit || layout?.contentSize || layout?.wideSize\n\t\t\t\t? { ...layout, type: 'constrained' }\n\t\t\t\t: layout || defaultBlockLayout || {};\n\t\tconst layoutClasses = hasLayoutBlockSupport\n\t\t\t? useLayoutClasses( block )\n\t\t\t: null;\n\t\t// Higher specificity to override defaults from theme.json.\n\t\tconst selector = `.wp-container-${ id }.wp-container-${ id }`;\n\t\tconst blockGapSupport = useSetting( 'spacing.blockGap' );\n\t\tconst hasBlockGapSupport = blockGapSupport !== null;\n\n\t\t// Get CSS string for the current layout type.\n\t\t// The CSS and `style` element is only output if it is not empty.\n\t\tlet css;\n\t\tif ( shouldRenderLayoutStyles ) {\n\t\t\tconst fullLayoutType = getLayoutType(\n\t\t\t\tusedLayout?.type || 'default'\n\t\t\t);\n\t\t\tcss = fullLayoutType?.getLayoutStyle?.( {\n\t\t\t\tblockName: name,\n\t\t\t\tselector,\n\t\t\t\tlayout: usedLayout,\n\t\t\t\tlayoutDefinitions: defaultThemeLayout?.definitions,\n\t\t\t\tstyle: attributes?.style,\n\t\t\t\thasBlockGapSupport,\n\t\t\t} );\n\t\t}\n\n\t\t// Attach a `wp-container-` id-based class name as well as a layout class name such as `is-layout-flex`.\n\t\tconst layoutClassNames = classnames(\n\t\t\t{\n\t\t\t\t[ `wp-container-${ id }` ]: shouldRenderLayoutStyles && !! css, // Only attach a container class if there is generated CSS to be attached.\n\t\t\t},\n\t\t\tlayoutClasses\n\t\t);\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ shouldRenderLayoutStyles &&\n\t\t\t\t\telement &&\n\t\t\t\t\t!! css &&\n\t\t\t\t\tcreatePortal(\n\t\t\t\t\t\t<LayoutStyle\n\t\t\t\t\t\t\tblockName={ name }\n\t\t\t\t\t\t\tselector={ selector }\n\t\t\t\t\t\t\tcss={ css }\n\t\t\t\t\t\t\tlayout={ usedLayout }\n\t\t\t\t\t\t\tstyle={ attributes?.style }\n\t\t\t\t\t\t/>,\n\t\t\t\t\t\telement\n\t\t\t\t\t) }\n\t\t\t\t<BlockListBlock\n\t\t\t\t\t{ ...props }\n\t\t\t\t\t__unstableLayoutClassNames={ layoutClassNames }\n\t\t\t\t/>\n\t\t\t</>\n\t\t);\n\t}\n);\n\n/**\n * Override the default block element to add the child layout styles.\n *\n * @param {Function} BlockListBlock Original component.\n *\n * @return {Function} Wrapped component.\n */\nexport const withChildLayoutStyles = createHigherOrderComponent(\n\t( BlockListBlock ) => ( props ) => {\n\t\tconst { attributes } = props;\n\t\tconst { style: { layout = {} } = {} } = attributes;\n\t\tconst { selfStretch, flexSize } = layout;\n\t\tconst hasChildLayout = selfStretch || flexSize;\n\t\tconst disableLayoutStyles = useSelect( ( select ) => {\n\t\t\tconst { getSettings } = select( blockEditorStore );\n\t\t\treturn !! getSettings().disableLayoutStyles;\n\t\t} );\n\t\tconst shouldRenderChildLayoutStyles =\n\t\t\thasChildLayout && ! disableLayoutStyles;\n\n\t\tconst element = useContext( BlockList.__unstableElementContext );\n\t\tconst id = useInstanceId( BlockListBlock );\n\t\tconst selector = `.wp-container-content-${ id }`;\n\n\t\tlet css = '';\n\n\t\tif ( selfStretch === 'fixed' && flexSize ) {\n\t\t\tcss += `${ selector } {\n\t\t\t\tflex-basis: ${ flexSize };\n\t\t\t\tbox-sizing: border-box;\n\t\t\t}`;\n\t\t} else if ( selfStretch === 'fill' ) {\n\t\t\tcss += `${ selector } {\n\t\t\t\tflex-grow: 1;\n\t\t\t}`;\n\t\t}\n\n\t\t// Attach a `wp-container-content` id-based classname.\n\t\tconst className = classnames( props?.className, {\n\t\t\t[ `wp-container-content-${ id }` ]:\n\t\t\t\tshouldRenderChildLayoutStyles && !! css, // Only attach a container class if there is generated CSS to be attached.\n\t\t} );\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ shouldRenderChildLayoutStyles &&\n\t\t\t\t\telement &&\n\t\t\t\t\t!! css &&\n\t\t\t\t\tcreatePortal( <style>{ css }</style>, element ) }\n\t\t\t\t<BlockListBlock { ...props } className={ className } />\n\t\t\t</>\n\t\t);\n\t}\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/layout/addAttribute',\n\taddAttribute\n);\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/editor/layout/with-layout-styles',\n\twithLayoutStyles\n);\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/editor/layout/with-child-layout-styles',\n\twithChildLayoutStyles\n);\naddFilter(\n\t'editor.BlockEdit',\n\t'core/editor/layout/with-inspector-controls',\n\twithInspectorControls\n);\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/hooks/layout.js"],"names":["classnames","kebabCase","createHigherOrderComponent","useInstanceId","addFilter","getBlockSupport","hasBlockSupport","useSelect","Button","ButtonGroup","ToggleControl","PanelBody","__","useContext","createPortal","store","blockEditorStore","InspectorControls","useSetting","LayoutStyle","BlockList","getLayoutType","getLayoutTypes","layoutBlockSupportKey","useLayoutClasses","blockAttributes","blockName","rootPaddingAlignment","select","getSettings","__experimentalFeatures","useRootPaddingAwareAlignments","globalLayoutSettings","layout","default","defaultBlockLayout","usedLayout","inherit","contentSize","wideSize","type","layoutClassnames","definitions","className","baseClassName","compoundClassName","split","pop","push","orientation","justifyContent","flexWrap","useLayoutStyles","selector","style","fullLayoutType","blockGapSupport","hasBlockGapSupport","css","getLayoutStyle","layoutDefinitions","LayoutPanel","clientId","setAttributes","attributes","name","defaultThemeLayout","themeSupportsLayout","isContentLocked","__unstableGetContentLockingParent","supportsLayout","layoutBlockSupport","allowSwitching","allowEditing","allowInheriting","showInheritToggle","layoutType","constrainedType","displayControlsForLegacyLayouts","hasContentSizeOrLegacySettings","onChangeType","newType","onChangeLayout","newLayout","LayoutTypeSwitcher","onChange","map","label","addAttribute","settings","withInspectorControls","BlockEdit","props","supportLayout","withLayoutStyles","BlockListBlock","hasLayoutBlockSupport","disableLayoutStyles","shouldRenderLayoutStyles","id","element","__unstableElementContext","layoutClasses","layoutClassNames","withChildLayoutStyles","selfStretch","flexSize","hasChildLayout","shouldRenderChildLayoutStyles"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AACA,SAASC,SAAT,QAA0B,QAA1B;AAEA;AACA;AACA;;AACA,SAASC,0BAAT,EAAqCC,aAArC,QAA0D,oBAA1D;AACA,SAASC,SAAT,QAA0B,kBAA1B;AACA,SAASC,eAAT,EAA0BC,eAA1B,QAAiD,mBAAjD;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SACCC,MADD,EAECC,WAFD,EAGCC,aAHD,EAICC,SAJD,QAKO,uBALP;AAMA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,UAAT,EAAqBC,YAArB,QAAyC,oBAAzC;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,UAA1C;AACA,SAASC,iBAAT,QAAkC,eAAlC;AACA,OAAOC,UAAP,MAAuB,2BAAvB;AACA,SAASC,WAAT,QAA4B,iCAA5B;AACA,OAAOC,SAAP,MAAsB,0BAAtB;AACA,SAASC,aAAT,EAAwBC,cAAxB,QAA8C,YAA9C;AAEA,MAAMC,qBAAqB,GAAG,sBAA9B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,gBAAT,GAAkE;AAAA;;AAAA,MAAvCC,eAAuC,uEAArB,EAAqB;AAAA,MAAjBC,SAAiB,uEAAL,EAAK;AACxE,QAAMC,oBAAoB,GAAGpB,SAAS,CAAIqB,MAAF,IAAc;AAAA;;AACrD,UAAM;AAAEC,MAAAA;AAAF,QAAkBD,MAAM,CAAEZ,gBAAF,CAA9B;AACA,oCAAOa,WAAW,GAAGC,sBAArB,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D;AAAzC,KALD,CADD;AASA,CA7C6D,CAAxD;AAgDPvC,SAAS,CACR,0BADQ,EAER,0BAFQ,EAGRoF,YAHQ,CAAT;AAKApF,SAAS,CACR,uBADQ,EAER,uCAFQ,EAGR0F,gBAHQ,CAAT;AAKA1F,SAAS,CACR,uBADQ,EAER,6CAFQ,EAGRoG,qBAHQ,CAAT;AAKApG,SAAS,CACR,kBADQ,EAER,4CAFQ,EAGRsF,qBAHQ,CAAT","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport { kebabCase } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';\nimport { addFilter } from '@wordpress/hooks';\nimport { getBlockSupport, hasBlockSupport } from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tButton,\n\tButtonGroup,\n\tToggleControl,\n\tPanelBody,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useContext, createPortal } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../store';\nimport { InspectorControls } from '../components';\nimport useSetting from '../components/use-setting';\nimport { LayoutStyle } from '../components/block-list/layout';\nimport BlockList from '../components/block-list';\nimport { getLayoutType, getLayoutTypes } from '../layouts';\n\nconst layoutBlockSupportKey = '__experimentalLayout';\n\n/**\n * Generates the utility classnames for the given block's layout attributes.\n *\n * @param { Object } blockAttributes Block attributes.\n * @param { string } blockName Block name.\n *\n * @return { Array } Array of CSS classname strings.\n */\nexport function useLayoutClasses( blockAttributes = {}, blockName = '' ) {\n\tconst rootPaddingAlignment = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn getSettings().__experimentalFeatures\n\t\t\t?.useRootPaddingAwareAlignments;\n\t}, [] );\n\tconst globalLayoutSettings = useSetting( 'layout' ) || {};\n\n\tconst { layout } = blockAttributes;\n\n\tconst { default: defaultBlockLayout } =\n\t\tgetBlockSupport( blockName, layoutBlockSupportKey ) || {};\n\tconst usedLayout =\n\t\tlayout?.inherit || layout?.contentSize || layout?.wideSize\n\t\t\t? { ...layout, type: 'constrained' }\n\t\t\t: layout || defaultBlockLayout || {};\n\n\tconst layoutClassnames = [];\n\n\tif (\n\t\tglobalLayoutSettings?.definitions?.[ usedLayout?.type || 'default' ]\n\t\t\t?.className\n\t) {\n\t\tconst baseClassName =\n\t\t\tglobalLayoutSettings?.definitions?.[ usedLayout?.type || 'default' ]\n\t\t\t\t?.className;\n\t\tconst compoundClassName = `wp-block-${ blockName\n\t\t\t.split( '/' )\n\t\t\t.pop() }-${ baseClassName }`;\n\t\tlayoutClassnames.push( baseClassName, compoundClassName );\n\t}\n\n\tif (\n\t\t( usedLayout?.inherit ||\n\t\t\tusedLayout?.contentSize ||\n\t\t\tusedLayout?.type === 'constrained' ) &&\n\t\trootPaddingAlignment\n\t) {\n\t\tlayoutClassnames.push( 'has-global-padding' );\n\t}\n\n\tif ( usedLayout?.orientation ) {\n\t\tlayoutClassnames.push( `is-${ kebabCase( usedLayout.orientation ) }` );\n\t}\n\n\tif ( usedLayout?.justifyContent ) {\n\t\tlayoutClassnames.push(\n\t\t\t`is-content-justification-${ kebabCase(\n\t\t\t\tusedLayout.justifyContent\n\t\t\t) }`\n\t\t);\n\t}\n\n\tif ( usedLayout?.flexWrap && usedLayout.flexWrap === 'nowrap' ) {\n\t\tlayoutClassnames.push( 'is-nowrap' );\n\t}\n\n\treturn layoutClassnames;\n}\n\n/**\n * Generates a CSS rule with the given block's layout styles.\n *\n * @param { Object } blockAttributes Block attributes.\n * @param { string } blockName Block name.\n * @param { string } selector A selector to use in generating the CSS rule.\n *\n * @return { string } CSS rule.\n */\nexport function useLayoutStyles( blockAttributes = {}, blockName, selector ) {\n\tconst { layout = {}, style = {} } = blockAttributes;\n\t// Update type for blocks using legacy layouts.\n\tconst usedLayout =\n\t\tlayout?.inherit || layout?.contentSize || layout?.wideSize\n\t\t\t? { ...layout, type: 'constrained' }\n\t\t\t: layout || {};\n\tconst fullLayoutType = getLayoutType( usedLayout?.type || 'default' );\n\tconst globalLayoutSettings = useSetting( 'layout' ) || {};\n\tconst blockGapSupport = useSetting( 'spacing.blockGap' );\n\tconst hasBlockGapSupport = blockGapSupport !== null;\n\tconst css = fullLayoutType?.getLayoutStyle?.( {\n\t\tblockName,\n\t\tselector,\n\t\tlayout,\n\t\tlayoutDefinitions: globalLayoutSettings?.definitions,\n\t\tstyle,\n\t\thasBlockGapSupport,\n\t} );\n\treturn css;\n}\n\nfunction LayoutPanel( {\n\tclientId,\n\tsetAttributes,\n\tattributes,\n\tname: blockName,\n} ) {\n\tconst { layout } = attributes;\n\tconst defaultThemeLayout = useSetting( 'layout' );\n\tconst { themeSupportsLayout, isContentLocked } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getSettings, __unstableGetContentLockingParent } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\treturn {\n\t\t\t\tthemeSupportsLayout: getSettings().supportsLayout,\n\t\t\t\tisContentLocked: __unstableGetContentLockingParent( clientId ),\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst layoutBlockSupport = getBlockSupport(\n\t\tblockName,\n\t\tlayoutBlockSupportKey,\n\t\t{}\n\t);\n\tconst {\n\t\tallowSwitching,\n\t\tallowEditing = true,\n\t\tallowInheriting = true,\n\t\tdefault: defaultBlockLayout,\n\t} = layoutBlockSupport;\n\n\tif ( ! allowEditing ) {\n\t\treturn null;\n\t}\n\n\t// Only show the inherit toggle if it's supported,\n\t// a default theme layout is set (e.g. one that provides `contentSize` and/or `wideSize` values),\n\t// and either the default / flow or the constrained layout type is in use, as the toggle switches from one to the other.\n\tconst showInheritToggle = !! (\n\t\tallowInheriting &&\n\t\t!! defaultThemeLayout &&\n\t\t( ! layout?.type ||\n\t\t\tlayout?.type === 'default' ||\n\t\t\tlayout?.type === 'constrained' ||\n\t\t\tlayout?.inherit )\n\t);\n\n\tconst usedLayout = layout || defaultBlockLayout || {};\n\tconst {\n\t\tinherit = false,\n\t\ttype = 'default',\n\t\tcontentSize = null,\n\t} = usedLayout;\n\t/**\n\t * `themeSupportsLayout` is only relevant to the `default/flow` or\n\t * `constrained` layouts and it should not be taken into account when other\n\t * `layout` types are used.\n\t */\n\tif (\n\t\t( type === 'default' || type === 'constrained' ) &&\n\t\t! themeSupportsLayout\n\t) {\n\t\treturn null;\n\t}\n\tconst layoutType = getLayoutType( type );\n\tconst constrainedType = getLayoutType( 'constrained' );\n\tconst displayControlsForLegacyLayouts =\n\t\t! usedLayout.type && ( contentSize || inherit );\n\tconst hasContentSizeOrLegacySettings = !! inherit || !! contentSize;\n\n\tconst onChangeType = ( newType ) =>\n\t\tsetAttributes( { layout: { type: newType } } );\n\tconst onChangeLayout = ( newLayout ) =>\n\t\tsetAttributes( { layout: newLayout } );\n\n\treturn (\n\t\t<>\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody title={ __( 'Layout' ) }>\n\t\t\t\t\t{ showInheritToggle && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\tclassName=\"block-editor-hooks__toggle-control\"\n\t\t\t\t\t\t\t\tlabel={ __( 'Inner blocks use content width' ) }\n\t\t\t\t\t\t\t\tchecked={\n\t\t\t\t\t\t\t\t\tlayoutType?.name === 'constrained' ||\n\t\t\t\t\t\t\t\t\thasContentSizeOrLegacySettings\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\tlayout: {\n\t\t\t\t\t\t\t\t\t\t\ttype:\n\t\t\t\t\t\t\t\t\t\t\t\tlayoutType?.name ===\n\t\t\t\t\t\t\t\t\t\t\t\t\t'constrained' ||\n\t\t\t\t\t\t\t\t\t\t\t\thasContentSizeOrLegacySettings\n\t\t\t\t\t\t\t\t\t\t\t\t\t? 'default'\n\t\t\t\t\t\t\t\t\t\t\t\t\t: 'constrained',\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\thelp={\n\t\t\t\t\t\t\t\t\tlayoutType?.name === 'constrained' ||\n\t\t\t\t\t\t\t\t\thasContentSizeOrLegacySettings\n\t\t\t\t\t\t\t\t\t\t? __(\n\t\t\t\t\t\t\t\t\t\t\t\t'Nested blocks use content width with options for full and wide widths.'\n\t\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t\t\t\t'Nested blocks will fill the width of this container. Toggle to constrain.'\n\t\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</>\n\t\t\t\t\t) }\n\n\t\t\t\t\t{ ! inherit && allowSwitching && (\n\t\t\t\t\t\t<LayoutTypeSwitcher\n\t\t\t\t\t\t\ttype={ type }\n\t\t\t\t\t\t\tonChange={ onChangeType }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\n\t\t\t\t\t{ layoutType && layoutType.name !== 'default' && (\n\t\t\t\t\t\t<layoutType.inspectorControls\n\t\t\t\t\t\t\tlayout={ usedLayout }\n\t\t\t\t\t\t\tonChange={ onChangeLayout }\n\t\t\t\t\t\t\tlayoutBlockSupport={ layoutBlockSupport }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\t{ constrainedType && displayControlsForLegacyLayouts && (\n\t\t\t\t\t\t<constrainedType.inspectorControls\n\t\t\t\t\t\t\tlayout={ usedLayout }\n\t\t\t\t\t\t\tonChange={ onChangeLayout }\n\t\t\t\t\t\t\tlayoutBlockSupport={ layoutBlockSupport }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</PanelBody>\n\t\t\t</InspectorControls>\n\t\t\t{ ! inherit && ! isContentLocked && layoutType && (\n\t\t\t\t<layoutType.toolBarControls\n\t\t\t\t\tlayout={ usedLayout }\n\t\t\t\t\tonChange={ onChangeLayout }\n\t\t\t\t\tlayoutBlockSupport={ layoutBlockSupport }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nfunction LayoutTypeSwitcher( { type, onChange } ) {\n\treturn (\n\t\t<ButtonGroup>\n\t\t\t{ getLayoutTypes().map( ( { name, label } ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tkey={ name }\n\t\t\t\t\t\tisPressed={ type === name }\n\t\t\t\t\t\tonClick={ () => onChange( name ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ label }\n\t\t\t\t\t</Button>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</ButtonGroup>\n\t);\n}\n\n/**\n * Filters registered block settings, extending attributes to include `layout`.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nexport function addAttribute( settings ) {\n\tif ( 'type' in ( settings.attributes?.layout ?? {} ) ) {\n\t\treturn settings;\n\t}\n\tif ( hasBlockSupport( settings, layoutBlockSupportKey ) ) {\n\t\tsettings.attributes = {\n\t\t\t...settings.attributes,\n\t\t\tlayout: {\n\t\t\t\ttype: 'object',\n\t\t\t},\n\t\t};\n\t}\n\n\treturn settings;\n}\n\n/**\n * Override the default edit UI to include layout controls\n *\n * @param {Function} BlockEdit Original component.\n *\n * @return {Function} Wrapped component.\n */\nexport const withInspectorControls = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tconst { name: blockName } = props;\n\t\tconst supportLayout = hasBlockSupport(\n\t\t\tblockName,\n\t\t\tlayoutBlockSupportKey\n\t\t);\n\n\t\treturn [\n\t\t\tsupportLayout && <LayoutPanel key=\"layout\" { ...props } />,\n\t\t\t<BlockEdit key=\"edit\" { ...props } />,\n\t\t];\n\t},\n\t'withInspectorControls'\n);\n\n/**\n * Override the default block element to add the layout styles.\n *\n * @param {Function} BlockListBlock Original component.\n *\n * @return {Function} Wrapped component.\n */\nexport const withLayoutStyles = createHigherOrderComponent(\n\t( BlockListBlock ) => ( props ) => {\n\t\tconst { name, attributes } = props;\n\t\tconst hasLayoutBlockSupport = hasBlockSupport(\n\t\t\tname,\n\t\t\tlayoutBlockSupportKey\n\t\t);\n\t\tconst disableLayoutStyles = useSelect( ( select ) => {\n\t\t\tconst { getSettings } = select( blockEditorStore );\n\t\t\treturn !! getSettings().disableLayoutStyles;\n\t\t} );\n\t\tconst shouldRenderLayoutStyles =\n\t\t\thasLayoutBlockSupport && ! disableLayoutStyles;\n\t\tconst id = useInstanceId( BlockListBlock );\n\t\tconst defaultThemeLayout = useSetting( 'layout' ) || {};\n\t\tconst element = useContext( BlockList.__unstableElementContext );\n\t\tconst { layout } = attributes;\n\t\tconst { default: defaultBlockLayout } =\n\t\t\tgetBlockSupport( name, layoutBlockSupportKey ) || {};\n\t\tconst usedLayout =\n\t\t\tlayout?.inherit || layout?.contentSize || layout?.wideSize\n\t\t\t\t? { ...layout, type: 'constrained' }\n\t\t\t\t: layout || defaultBlockLayout || {};\n\t\tconst layoutClasses = hasLayoutBlockSupport\n\t\t\t? useLayoutClasses( attributes, name )\n\t\t\t: null;\n\t\t// Higher specificity to override defaults from theme.json.\n\t\tconst selector = `.wp-container-${ id }.wp-container-${ id }`;\n\t\tconst blockGapSupport = useSetting( 'spacing.blockGap' );\n\t\tconst hasBlockGapSupport = blockGapSupport !== null;\n\n\t\t// Get CSS string for the current layout type.\n\t\t// The CSS and `style` element is only output if it is not empty.\n\t\tlet css;\n\t\tif ( shouldRenderLayoutStyles ) {\n\t\t\tconst fullLayoutType = getLayoutType(\n\t\t\t\tusedLayout?.type || 'default'\n\t\t\t);\n\t\t\tcss = fullLayoutType?.getLayoutStyle?.( {\n\t\t\t\tblockName: name,\n\t\t\t\tselector,\n\t\t\t\tlayout: usedLayout,\n\t\t\t\tlayoutDefinitions: defaultThemeLayout?.definitions,\n\t\t\t\tstyle: attributes?.style,\n\t\t\t\thasBlockGapSupport,\n\t\t\t} );\n\t\t}\n\n\t\t// Attach a `wp-container-` id-based class name as well as a layout class name such as `is-layout-flex`.\n\t\tconst layoutClassNames = classnames(\n\t\t\t{\n\t\t\t\t[ `wp-container-${ id }` ]: shouldRenderLayoutStyles && !! css, // Only attach a container class if there is generated CSS to be attached.\n\t\t\t},\n\t\t\tlayoutClasses\n\t\t);\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ shouldRenderLayoutStyles &&\n\t\t\t\t\telement &&\n\t\t\t\t\t!! css &&\n\t\t\t\t\tcreatePortal(\n\t\t\t\t\t\t<LayoutStyle\n\t\t\t\t\t\t\tblockName={ name }\n\t\t\t\t\t\t\tselector={ selector }\n\t\t\t\t\t\t\tcss={ css }\n\t\t\t\t\t\t\tlayout={ usedLayout }\n\t\t\t\t\t\t\tstyle={ attributes?.style }\n\t\t\t\t\t\t/>,\n\t\t\t\t\t\telement\n\t\t\t\t\t) }\n\t\t\t\t<BlockListBlock\n\t\t\t\t\t{ ...props }\n\t\t\t\t\t__unstableLayoutClassNames={ layoutClassNames }\n\t\t\t\t/>\n\t\t\t</>\n\t\t);\n\t}\n);\n\n/**\n * Override the default block element to add the child layout styles.\n *\n * @param {Function} BlockListBlock Original component.\n *\n * @return {Function} Wrapped component.\n */\nexport const withChildLayoutStyles = createHigherOrderComponent(\n\t( BlockListBlock ) => ( props ) => {\n\t\tconst { attributes } = props;\n\t\tconst { style: { layout = {} } = {} } = attributes;\n\t\tconst { selfStretch, flexSize } = layout;\n\t\tconst hasChildLayout = selfStretch || flexSize;\n\t\tconst disableLayoutStyles = useSelect( ( select ) => {\n\t\t\tconst { getSettings } = select( blockEditorStore );\n\t\t\treturn !! getSettings().disableLayoutStyles;\n\t\t} );\n\t\tconst shouldRenderChildLayoutStyles =\n\t\t\thasChildLayout && ! disableLayoutStyles;\n\n\t\tconst element = useContext( BlockList.__unstableElementContext );\n\t\tconst id = useInstanceId( BlockListBlock );\n\t\tconst selector = `.wp-container-content-${ id }`;\n\n\t\tlet css = '';\n\n\t\tif ( selfStretch === 'fixed' && flexSize ) {\n\t\t\tcss += `${ selector } {\n\t\t\t\tflex-basis: ${ flexSize };\n\t\t\t\tbox-sizing: border-box;\n\t\t\t}`;\n\t\t} else if ( selfStretch === 'fill' ) {\n\t\t\tcss += `${ selector } {\n\t\t\t\tflex-grow: 1;\n\t\t\t}`;\n\t\t}\n\n\t\t// Attach a `wp-container-content` id-based classname.\n\t\tconst className = classnames( props?.className, {\n\t\t\t[ `wp-container-content-${ id }` ]:\n\t\t\t\tshouldRenderChildLayoutStyles && !! css, // Only attach a container class if there is generated CSS to be attached.\n\t\t} );\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ shouldRenderChildLayoutStyles &&\n\t\t\t\t\telement &&\n\t\t\t\t\t!! css &&\n\t\t\t\t\tcreatePortal( <style>{ css }</style>, element ) }\n\t\t\t\t<BlockListBlock { ...props } className={ className } />\n\t\t\t</>\n\t\t);\n\t}\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/layout/addAttribute',\n\taddAttribute\n);\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/editor/layout/with-layout-styles',\n\twithLayoutStyles\n);\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/editor/layout/with-child-layout-styles',\n\twithChildLayoutStyles\n);\naddFilter(\n\t'editor.BlockEdit',\n\t'core/editor/layout/with-inspector-controls',\n\twithInspectorControls\n);\n"]}