@wordpress/block-editor 11.4.0 → 11.5.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 (288) hide show
  1. package/CHANGELOG.md +6 -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-lock/modal.js +1 -0
  7. package/build/components/block-lock/modal.js.map +1 -1
  8. package/build/components/block-settings-menu/block-settings-dropdown.js +2 -2
  9. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  10. package/build/components/block-styles/index.js +2 -1
  11. package/build/components/block-styles/index.js.map +1 -1
  12. package/build/components/child-layout-control/index.js +107 -0
  13. package/build/components/child-layout-control/index.js.map +1 -0
  14. package/build/components/date-format-picker/index.js +3 -3
  15. package/build/components/date-format-picker/index.js.map +1 -1
  16. package/build/components/global-styles/dimensions-panel.js +594 -0
  17. package/build/components/global-styles/dimensions-panel.js.map +1 -0
  18. package/build/components/global-styles/hooks.js +72 -36
  19. package/build/components/global-styles/hooks.js.map +1 -1
  20. package/build/components/global-styles/index.js +20 -6
  21. package/build/components/global-styles/index.js.map +1 -1
  22. package/build/components/global-styles/typography-panel.js +25 -12
  23. package/build/components/global-styles/typography-panel.js.map +1 -1
  24. package/build/components/global-styles/use-global-styles-output.js +1 -1
  25. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  26. package/build/components/global-styles/utils.js +2 -0
  27. package/build/components/global-styles/utils.js.map +1 -1
  28. package/build/components/index.native.js +23 -0
  29. package/build/components/index.native.js.map +1 -1
  30. package/build/components/inserter/media-tab/hooks.js +10 -11
  31. package/build/components/inserter/media-tab/hooks.js.map +1 -1
  32. package/build/components/inserter/media-tab/media-list.js +5 -108
  33. package/build/components/inserter/media-tab/media-list.js.map +1 -1
  34. package/build/components/inserter/media-tab/media-preview.js +242 -0
  35. package/build/components/inserter/media-tab/media-preview.js.map +1 -0
  36. package/build/components/inspector-controls/block-support-tools-panel.js +1 -1
  37. package/build/components/inspector-controls/block-support-tools-panel.js.map +1 -1
  38. package/build/components/inspector-controls/fill.js +38 -9
  39. package/build/components/inspector-controls/fill.js.map +1 -1
  40. package/build/components/link-control/settings-drawer.js +1 -1
  41. package/build/components/link-control/settings-drawer.js.map +1 -1
  42. package/build/components/link-control/settings.js +1 -0
  43. package/build/components/link-control/settings.js.map +1 -1
  44. package/build/components/list-view/block.js +17 -3
  45. package/build/components/list-view/block.js.map +1 -1
  46. package/build/components/list-view/branch.js +2 -2
  47. package/build/components/list-view/branch.js.map +1 -1
  48. package/build/components/list-view/expander.js +2 -1
  49. package/build/components/list-view/expander.js.map +1 -1
  50. package/build/components/list-view/leaf.js +10 -6
  51. package/build/components/list-view/leaf.js.map +1 -1
  52. package/build/components/list-view/use-list-view-scroll-into-view.js +51 -0
  53. package/build/components/list-view/use-list-view-scroll-into-view.js.map +1 -0
  54. package/build/components/off-canvas-editor/appender.js +5 -10
  55. package/build/components/off-canvas-editor/appender.js.map +1 -1
  56. package/build/components/off-canvas-editor/branch.js +1 -0
  57. package/build/components/off-canvas-editor/branch.js.map +1 -1
  58. package/build/components/off-canvas-editor/index.js +7 -3
  59. package/build/components/off-canvas-editor/index.js.map +1 -1
  60. package/build/components/off-canvas-editor/leaf-more-menu.js +34 -4
  61. package/build/components/off-canvas-editor/leaf-more-menu.js.map +1 -1
  62. package/build/components/off-canvas-editor/link-ui.js +1 -0
  63. package/build/components/off-canvas-editor/link-ui.js.map +1 -1
  64. package/build/components/responsive-block-control/index.js +1 -0
  65. package/build/components/responsive-block-control/index.js.map +1 -1
  66. package/build/components/rich-text/index.js +9 -43
  67. package/build/components/rich-text/index.js.map +1 -1
  68. package/build/components/rich-text/use-delete.js +73 -0
  69. package/build/components/rich-text/use-delete.js.map +1 -0
  70. package/build/components/rich-text/use-input-rules.js +14 -6
  71. package/build/components/rich-text/use-input-rules.js.map +1 -1
  72. package/build/components/writing-flow/use-selection-observer.js +4 -1
  73. package/build/components/writing-flow/use-selection-observer.js.map +1 -1
  74. package/build/hooks/align.js +3 -1
  75. package/build/hooks/align.js.map +1 -1
  76. package/build/hooks/dimensions.js +72 -190
  77. package/build/hooks/dimensions.js.map +1 -1
  78. package/build/hooks/duotone.js +94 -25
  79. package/build/hooks/duotone.js.map +1 -1
  80. package/build/hooks/gap.js +0 -202
  81. package/build/hooks/gap.js.map +1 -1
  82. package/build/hooks/layout.js +14 -5
  83. package/build/hooks/layout.js.map +1 -1
  84. package/build/hooks/margin.js +7 -163
  85. package/build/hooks/margin.js.map +1 -1
  86. package/build/hooks/padding.js +7 -163
  87. package/build/hooks/padding.js.map +1 -1
  88. package/build/hooks/typography.js +50 -65
  89. package/build/hooks/typography.js.map +1 -1
  90. package/build/hooks/utils.js +75 -0
  91. package/build/hooks/utils.js.map +1 -1
  92. package/build/layouts/flex.js +1 -0
  93. package/build/layouts/flex.js.map +1 -1
  94. package/build/store/actions.js +24 -12
  95. package/build/store/actions.js.map +1 -1
  96. package/build/store/defaults.js +28 -1
  97. package/build/store/defaults.js.map +1 -1
  98. package/build/store/reducer.js +53 -47
  99. package/build/store/reducer.js.map +1 -1
  100. package/build/store/selectors.js +5 -1
  101. package/build/store/selectors.js.map +1 -1
  102. package/build/utils/parse-css-unit-to-px.js +36 -3
  103. package/build/utils/parse-css-unit-to-px.js.map +1 -1
  104. package/build-module/components/block-inspector/index.js +9 -9
  105. package/build-module/components/block-inspector/index.js.map +1 -1
  106. package/build-module/components/block-inspector/useBlockInspectorAnimationSettings.js +37 -0
  107. package/build-module/components/block-inspector/useBlockInspectorAnimationSettings.js.map +1 -0
  108. package/build-module/components/block-lock/modal.js +1 -0
  109. package/build-module/components/block-lock/modal.js.map +1 -1
  110. package/build-module/components/block-settings-menu/block-settings-dropdown.js +2 -2
  111. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  112. package/build-module/components/block-styles/index.js +2 -1
  113. package/build-module/components/block-styles/index.js.map +1 -1
  114. package/build-module/components/child-layout-control/index.js +98 -0
  115. package/build-module/components/child-layout-control/index.js.map +1 -0
  116. package/build-module/components/date-format-picker/index.js +4 -4
  117. package/build-module/components/date-format-picker/index.js.map +1 -1
  118. package/build-module/components/global-styles/dimensions-panel.js +574 -0
  119. package/build-module/components/global-styles/dimensions-panel.js.map +1 -0
  120. package/build-module/components/global-styles/hooks.js +71 -33
  121. package/build-module/components/global-styles/hooks.js.map +1 -1
  122. package/build-module/components/global-styles/index.js +2 -1
  123. package/build-module/components/global-styles/index.js.map +1 -1
  124. package/build-module/components/global-styles/typography-panel.js +26 -11
  125. package/build-module/components/global-styles/typography-panel.js.map +1 -1
  126. package/build-module/components/global-styles/use-global-styles-output.js +1 -1
  127. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  128. package/build-module/components/global-styles/utils.js +2 -0
  129. package/build-module/components/global-styles/utils.js.map +1 -1
  130. package/build-module/components/index.native.js +2 -1
  131. package/build-module/components/index.native.js.map +1 -1
  132. package/build-module/components/inserter/media-tab/hooks.js +10 -11
  133. package/build-module/components/inserter/media-tab/hooks.js.map +1 -1
  134. package/build-module/components/inserter/media-tab/media-list.js +6 -105
  135. package/build-module/components/inserter/media-tab/media-list.js.map +1 -1
  136. package/build-module/components/inserter/media-tab/media-preview.js +222 -0
  137. package/build-module/components/inserter/media-tab/media-preview.js.map +1 -0
  138. package/build-module/components/inspector-controls/block-support-tools-panel.js +1 -1
  139. package/build-module/components/inspector-controls/block-support-tools-panel.js.map +1 -1
  140. package/build-module/components/inspector-controls/fill.js +39 -9
  141. package/build-module/components/inspector-controls/fill.js.map +1 -1
  142. package/build-module/components/link-control/settings-drawer.js +1 -1
  143. package/build-module/components/link-control/settings-drawer.js.map +1 -1
  144. package/build-module/components/link-control/settings.js +1 -0
  145. package/build-module/components/link-control/settings.js.map +1 -1
  146. package/build-module/components/list-view/block.js +16 -3
  147. package/build-module/components/list-view/block.js.map +1 -1
  148. package/build-module/components/list-view/branch.js +2 -2
  149. package/build-module/components/list-view/branch.js.map +1 -1
  150. package/build-module/components/list-view/expander.js +2 -1
  151. package/build-module/components/list-view/expander.js.map +1 -1
  152. package/build-module/components/list-view/leaf.js +8 -4
  153. package/build-module/components/list-view/leaf.js.map +1 -1
  154. package/build-module/components/list-view/use-list-view-scroll-into-view.js +42 -0
  155. package/build-module/components/list-view/use-list-view-scroll-into-view.js.map +1 -0
  156. package/build-module/components/off-canvas-editor/appender.js +5 -10
  157. package/build-module/components/off-canvas-editor/appender.js.map +1 -1
  158. package/build-module/components/off-canvas-editor/branch.js +1 -0
  159. package/build-module/components/off-canvas-editor/branch.js.map +1 -1
  160. package/build-module/components/off-canvas-editor/index.js +7 -3
  161. package/build-module/components/off-canvas-editor/index.js.map +1 -1
  162. package/build-module/components/off-canvas-editor/leaf-more-menu.js +36 -7
  163. package/build-module/components/off-canvas-editor/leaf-more-menu.js.map +1 -1
  164. package/build-module/components/off-canvas-editor/link-ui.js +1 -0
  165. package/build-module/components/off-canvas-editor/link-ui.js.map +1 -1
  166. package/build-module/components/responsive-block-control/index.js +1 -0
  167. package/build-module/components/responsive-block-control/index.js.map +1 -1
  168. package/build-module/components/rich-text/index.js +9 -43
  169. package/build-module/components/rich-text/index.js.map +1 -1
  170. package/build-module/components/rich-text/use-delete.js +62 -0
  171. package/build-module/components/rich-text/use-delete.js.map +1 -0
  172. package/build-module/components/rich-text/use-input-rules.js +14 -6
  173. package/build-module/components/rich-text/use-input-rules.js.map +1 -1
  174. package/build-module/components/writing-flow/use-selection-observer.js +4 -1
  175. package/build-module/components/writing-flow/use-selection-observer.js.map +1 -1
  176. package/build-module/hooks/align.js +3 -1
  177. package/build-module/hooks/align.js.map +1 -1
  178. package/build-module/hooks/dimensions.js +75 -187
  179. package/build-module/hooks/dimensions.js.map +1 -1
  180. package/build-module/hooks/duotone.js +86 -24
  181. package/build-module/hooks/duotone.js.map +1 -1
  182. package/build-module/hooks/gap.js +0 -183
  183. package/build-module/hooks/gap.js.map +1 -1
  184. package/build-module/hooks/layout.js +14 -5
  185. package/build-module/hooks/layout.js.map +1 -1
  186. package/build-module/hooks/margin.js +4 -143
  187. package/build-module/hooks/margin.js.map +1 -1
  188. package/build-module/hooks/padding.js +4 -143
  189. package/build-module/hooks/padding.js.map +1 -1
  190. package/build-module/hooks/typography.js +52 -65
  191. package/build-module/hooks/typography.js.map +1 -1
  192. package/build-module/hooks/utils.js +70 -0
  193. package/build-module/hooks/utils.js.map +1 -1
  194. package/build-module/layouts/flex.js +1 -0
  195. package/build-module/layouts/flex.js.map +1 -1
  196. package/build-module/store/actions.js +24 -12
  197. package/build-module/store/actions.js.map +1 -1
  198. package/build-module/store/defaults.js +28 -1
  199. package/build-module/store/defaults.js.map +1 -1
  200. package/build-module/store/reducer.js +53 -45
  201. package/build-module/store/reducer.js.map +1 -1
  202. package/build-module/store/selectors.js +5 -1
  203. package/build-module/store/selectors.js.map +1 -1
  204. package/build-module/utils/parse-css-unit-to-px.js +36 -3
  205. package/build-module/utils/parse-css-unit-to-px.js.map +1 -1
  206. package/build-style/style-rtl.css +33 -21
  207. package/build-style/style.css +33 -21
  208. package/package.json +31 -31
  209. package/src/components/block-draggable/test/__snapshots__/index.native.js.snap +24 -24
  210. package/src/components/block-inspector/index.js +11 -14
  211. package/src/components/block-inspector/useBlockInspectorAnimationSettings.js +53 -0
  212. package/src/components/block-lock/modal.js +1 -0
  213. package/src/components/block-lock/style.scss +0 -9
  214. package/src/components/block-mobile-toolbar/test/__snapshots__/block-actions-menu.native.js.snap +20 -20
  215. package/src/components/block-mover/test/__snapshots__/index.native.js.snap +15 -15
  216. package/src/components/block-settings-menu/block-settings-dropdown.js +4 -1
  217. package/src/components/block-styles/index.js +5 -1
  218. package/src/components/child-layout-control/index.js +106 -0
  219. package/src/components/color-palette/test/__snapshots__/control.js.snap +1 -1
  220. package/src/components/date-format-picker/index.js +6 -8
  221. package/src/components/date-format-picker/style.scss +0 -5
  222. package/src/components/global-styles/dimensions-panel.js +627 -0
  223. package/src/components/global-styles/hooks.js +88 -45
  224. package/src/components/global-styles/index.js +5 -1
  225. package/src/components/global-styles/typography-panel.js +33 -8
  226. package/src/components/global-styles/use-global-styles-output.js +4 -3
  227. package/src/components/global-styles/utils.js +2 -0
  228. package/src/components/index.native.js +5 -0
  229. package/src/components/inner-blocks/test/__snapshots__/index.js.snap +1 -1
  230. package/src/components/inserter/media-tab/hooks.js +9 -8
  231. package/src/components/inserter/media-tab/media-list.js +3 -122
  232. package/src/components/inserter/media-tab/media-preview.js +268 -0
  233. package/src/components/inserter/style.scss +22 -0
  234. package/src/components/inserter/test/__snapshots__/index.native.js.snap +15 -15
  235. package/src/components/inspector-controls/block-support-tools-panel.js +0 -1
  236. package/src/components/inspector-controls/fill.js +32 -8
  237. package/src/components/link-control/settings-drawer.js +2 -1
  238. package/src/components/link-control/settings.js +1 -0
  239. package/src/components/link-control/style.scss +18 -8
  240. package/src/components/link-control/test/index.js +3 -3
  241. package/src/components/list-view/block.js +19 -1
  242. package/src/components/list-view/branch.js +1 -2
  243. package/src/components/list-view/expander.js +1 -0
  244. package/src/components/list-view/leaf.js +43 -29
  245. package/src/components/list-view/use-list-view-scroll-into-view.js +48 -0
  246. package/src/components/media-replace-flow/style.scss +7 -9
  247. package/src/components/off-canvas-editor/appender.js +13 -16
  248. package/src/components/off-canvas-editor/branch.js +1 -0
  249. package/src/components/off-canvas-editor/index.js +8 -2
  250. package/src/components/off-canvas-editor/leaf-more-menu.js +57 -15
  251. package/src/components/off-canvas-editor/link-ui.js +1 -0
  252. package/src/components/responsive-block-control/index.js +1 -0
  253. package/src/components/rich-text/index.js +8 -44
  254. package/src/components/rich-text/use-delete.js +59 -0
  255. package/src/components/rich-text/use-input-rules.js +13 -5
  256. package/src/components/spacing-sizes-control/style.scss +1 -1
  257. package/src/components/url-popover/stories/index.js +1 -0
  258. package/src/components/writing-flow/use-selection-observer.js +5 -1
  259. package/src/hooks/align.js +1 -1
  260. package/src/hooks/dimensions.js +85 -269
  261. package/src/hooks/duotone.js +100 -30
  262. package/src/hooks/gap.js +0 -208
  263. package/src/hooks/layout.js +19 -6
  264. package/src/hooks/margin.js +1 -164
  265. package/src/hooks/padding.js +1 -163
  266. package/src/hooks/test/__snapshots__/align.native.js.snap +24 -24
  267. package/src/hooks/test/duotone.js +102 -0
  268. package/src/hooks/typography.js +66 -88
  269. package/src/hooks/utils.js +90 -0
  270. package/src/layouts/flex.js +1 -0
  271. package/src/store/actions.js +12 -4
  272. package/src/store/defaults.js +14 -1
  273. package/src/store/reducer.js +68 -43
  274. package/src/store/selectors.js +8 -1
  275. package/src/store/test/actions.js +4 -2
  276. package/src/utils/parse-css-unit-to-px.js +35 -5
  277. package/src/utils/test/parse-css-unit-to-px.js +12 -0
  278. package/tsconfig.tsbuildinfo +1 -1
  279. package/build/hooks/child-layout.js +0 -213
  280. package/build/hooks/child-layout.js.map +0 -1
  281. package/build/hooks/min-height.js +0 -139
  282. package/build/hooks/min-height.js.map +0 -1
  283. package/build-module/hooks/child-layout.js +0 -193
  284. package/build-module/hooks/child-layout.js.map +0 -1
  285. package/build-module/hooks/min-height.js +0 -116
  286. package/build-module/hooks/min-height.js.map +0 -1
  287. package/src/hooks/child-layout.js +0 -195
  288. package/src/hooks/min-height.js +0 -104
@@ -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,gBA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E,CAAE,eAAF,CADX;AAEC,MAAA,GAAG,EAAG,CAFP;AAGC,MAAA,QAAQ,EAAGyD,QAHZ;AAIC,MAAA,KAAK,EAAGR,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"]}
@@ -131,6 +131,7 @@ export function useLayoutStyles() {
131
131
 
132
132
  function LayoutPanel(_ref) {
133
133
  let {
134
+ clientId,
134
135
  setAttributes,
135
136
  attributes,
136
137
  name: blockName
@@ -139,12 +140,19 @@ function LayoutPanel(_ref) {
139
140
  layout
140
141
  } = attributes;
141
142
  const defaultThemeLayout = useSetting('layout');
142
- const themeSupportsLayout = useSelect(select => {
143
+ const {
144
+ themeSupportsLayout,
145
+ isContentLocked
146
+ } = useSelect(select => {
143
147
  const {
144
- getSettings
148
+ getSettings,
149
+ __unstableGetContentLockingParent
145
150
  } = select(blockEditorStore);
146
- return getSettings().supportsLayout;
147
- }, []);
151
+ return {
152
+ themeSupportsLayout: getSettings().supportsLayout,
153
+ isContentLocked: __unstableGetContentLockingParent(clientId)
154
+ };
155
+ }, [clientId]);
148
156
  const layoutBlockSupport = getBlockSupport(blockName, layoutBlockSupportKey, {});
149
157
  const {
150
158
  allowSwitching,
@@ -195,6 +203,7 @@ function LayoutPanel(_ref) {
195
203
  return createElement(Fragment, null, createElement(InspectorControls, null, createElement(PanelBody, {
196
204
  title: __('Layout')
197
205
  }, showInheritToggle && createElement(Fragment, null, createElement(ToggleControl, {
206
+ __nextHasNoMarginBottom: true,
198
207
  className: "block-editor-hooks__toggle-control",
199
208
  label: __('Inner blocks use content width'),
200
209
  checked: (layoutType === null || layoutType === void 0 ? void 0 : layoutType.name) === 'constrained' || hasContentSizeOrLegacySettings,
@@ -215,7 +224,7 @@ function LayoutPanel(_ref) {
215
224
  layout: usedLayout,
216
225
  onChange: onChangeLayout,
217
226
  layoutBlockSupport: layoutBlockSupport
218
- }))), !inherit && layoutType && createElement(layoutType.toolBarControls, {
227
+ }))), !inherit && !isContentLocked && layoutType && createElement(layoutType.toolBarControls, {
219
228
  layout: usedLayout,
220
229
  onChange: onChangeLayout,
221
230
  layoutBlockSupport: layoutBlockSupport
@@ -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,gBAAT,GAAwC;AAAA;;AAAA,MAAbC,KAAa,uEAAL,EAAK;AAC9C,QAAMC,oBAAoB,GAAGnB,SAAS,CAAIoB,MAAF,IAAc;AAAA;;AACrD,UAAM;AAAEC,MAAAA;AAAF,QAAkBD,MAAM,CAAEX,gBAAF,C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GR6F,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","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","clientId","setAttributes","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","shouldRender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BAHQ,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( {\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, 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,163 +1,24 @@
1
- import { createElement, Fragment } from "@wordpress/element";
1
+ import { createElement } from "@wordpress/element";
2
2
 
3
3
  /**
4
4
  * WordPress dependencies
5
5
  */
6
- import { __ } from '@wordpress/i18n';
7
- import { Platform, useMemo, useRef, useState, useEffect } from '@wordpress/element';
8
- import { getBlockSupport } from '@wordpress/blocks';
9
- import { __experimentalUseCustomUnits as useCustomUnits, __experimentalBoxControl as BoxControl } from '@wordpress/components';
6
+ import { useMemo, useRef, useState, useEffect } from '@wordpress/element';
10
7
  import isShallowEqual from '@wordpress/is-shallow-equal';
11
8
  /**
12
9
  * Internal dependencies
13
10
  */
14
11
 
15
- import useSetting from '../components/use-setting';
16
- import { AXIAL_SIDES, SPACING_SUPPORT_KEY, useCustomSides, useIsDimensionsSupportValid } from './dimensions';
17
- import { cleanEmptyObject } from './utils';
18
12
  import BlockPopover from '../components/block-popover';
19
- import SpacingSizesControl from '../components/spacing-sizes-control';
20
13
  import { getSpacingPresetCssVar } from '../components/spacing-sizes-control/utils';
21
- /**
22
- * Determines if there is margin support.
23
- *
24
- * @param {string|Object} blockType Block name or Block Type object.
25
- *
26
- * @return {boolean} Whether there is support.
27
- */
28
-
29
- export function hasMarginSupport(blockType) {
30
- const support = getBlockSupport(blockType, SPACING_SUPPORT_KEY);
31
- return !!(true === support || support !== null && support !== void 0 && support.margin);
32
- }
33
- /**
34
- * Checks if there is a current value in the margin block support attributes.
35
- *
36
- * @param {Object} props Block props.
37
- * @return {boolean} Whether or not the block has a margin value set.
38
- */
39
-
40
- export function hasMarginValue(props) {
41
- var _props$attributes$sty, _props$attributes$sty2;
42
-
43
- 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.margin) !== undefined;
44
- }
45
- /**
46
- * Resets the margin block support attributes. This can be used when disabling
47
- * the margin support controls for a block via a `ToolsPanel`.
48
- *
49
- * @param {Object} props Block props.
50
- * @param {Object} props.attributes Block's attributes.
51
- * @param {Object} props.setAttributes Function to set block's attributes.
52
- */
53
-
54
- export function resetMargin(_ref) {
55
- let {
56
- attributes = {},
57
- setAttributes
58
- } = _ref;
59
- const {
60
- style
61
- } = attributes;
62
- setAttributes({
63
- style: cleanEmptyObject({ ...style,
64
- spacing: { ...(style === null || style === void 0 ? void 0 : style.spacing),
65
- margin: undefined
66
- }
67
- })
68
- });
69
- }
70
- /**
71
- * Custom hook that checks if margin settings have been disabled.
72
- *
73
- * @param {string} name The name of the block.
74
- *
75
- * @return {boolean} Whether margin setting is disabled.
76
- */
77
-
78
- export function useIsMarginDisabled() {
79
- let {
80
- name: blockName
81
- } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
82
- const isDisabled = !useSetting('spacing.margin');
83
- const isInvalid = !useIsDimensionsSupportValid(blockName, 'margin');
84
- return !hasMarginSupport(blockName) || isDisabled || isInvalid;
85
- }
86
- /**
87
- * Inspector control panel containing the margin related configuration
88
- *
89
- * @param {Object} props Block props.
90
- *
91
- * @return {WPElement} Margin edit element.
92
- */
93
-
94
- export function MarginEdit(props) {
95
- var _style$spacing, _style$spacing2;
96
-
97
- const {
98
- name: blockName,
99
- attributes: {
100
- style
101
- },
102
- setAttributes,
103
- onMouseOver,
104
- onMouseOut
105
- } = props;
106
- const spacingSizes = useSetting('spacing.spacingSizes');
107
- const units = useCustomUnits({
108
- availableUnits: useSetting('spacing.units') || ['%', 'px', 'em', 'rem', 'vw']
109
- });
110
- const sides = useCustomSides(blockName, 'margin');
111
- const splitOnAxis = sides && sides.some(side => AXIAL_SIDES.includes(side));
112
-
113
- if (useIsMarginDisabled(props)) {
114
- return null;
115
- }
116
-
117
- const onChange = next => {
118
- const newStyle = { ...style,
119
- spacing: { ...(style === null || style === void 0 ? void 0 : style.spacing),
120
- margin: next
121
- }
122
- };
123
- setAttributes({
124
- style: cleanEmptyObject(newStyle)
125
- });
126
- };
127
-
128
- return Platform.select({
129
- web: createElement(Fragment, null, (!spacingSizes || (spacingSizes === null || spacingSizes === void 0 ? void 0 : spacingSizes.length) === 0) && createElement(BoxControl, {
130
- values: style === null || style === void 0 ? void 0 : (_style$spacing = style.spacing) === null || _style$spacing === void 0 ? void 0 : _style$spacing.margin,
131
- onChange: onChange,
132
- label: __('Margin'),
133
- sides: sides,
134
- units: units,
135
- allowReset: false,
136
- splitOnAxis: splitOnAxis,
137
- onMouseOver: onMouseOver,
138
- onMouseOut: onMouseOut
139
- }), (spacingSizes === null || spacingSizes === void 0 ? void 0 : spacingSizes.length) > 0 && createElement(SpacingSizesControl, {
140
- values: style === null || style === void 0 ? void 0 : (_style$spacing2 = style.spacing) === null || _style$spacing2 === void 0 ? void 0 : _style$spacing2.margin,
141
- onChange: onChange,
142
- label: __('Margin'),
143
- sides: sides,
144
- units: units,
145
- allowReset: false,
146
- splitOnAxis: false,
147
- onMouseOver: onMouseOver,
148
- onMouseOut: onMouseOut
149
- })),
150
- native: null
151
- });
152
- }
153
- export function MarginVisualizer(_ref2) {
14
+ export function MarginVisualizer(_ref) {
154
15
  var _attributes$style, _attributes$style$spa;
155
16
 
156
17
  let {
157
18
  clientId,
158
19
  attributes,
159
20
  forceShow
160
- } = _ref2;
21
+ } = _ref;
161
22
  const margin = attributes === null || attributes === void 0 ? void 0 : (_attributes$style = attributes.style) === null || _attributes$style === void 0 ? void 0 : (_attributes$style$spa = _attributes$style.spacing) === null || _attributes$style$spa === void 0 ? void 0 : _attributes$style$spa.margin;
162
23
  const style = useMemo(() => {
163
24
  const marginTop = margin !== null && margin !== void 0 && margin.top ? getSpacingPresetCssVar(margin === null || margin === void 0 ? void 0 : margin.top) : 0;