@wordpress/block-editor 15.19.1-next.v.202605131032.0 → 15.20.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 (352) hide show
  1. package/CHANGELOG.md +15 -1
  2. package/build/components/block-card/index.cjs +51 -41
  3. package/build/components/block-card/index.cjs.map +3 -3
  4. package/build/components/block-heading-level-dropdown/heading-level-icon.cjs.map +3 -3
  5. package/build/components/block-icon/index.cjs +7 -1
  6. package/build/components/block-icon/index.cjs.map +3 -3
  7. package/build/components/block-inspector/index.cjs +156 -11
  8. package/build/components/block-inspector/index.cjs.map +3 -3
  9. package/build/components/block-inspector/inspector-pre-tabs-slot-fill.cjs +38 -0
  10. package/build/components/block-inspector/inspector-pre-tabs-slot-fill.cjs.map +7 -0
  11. package/build/components/block-list/use-block-props/index.cjs +1 -1
  12. package/build/components/block-list/use-block-props/index.cjs.map +2 -2
  13. package/build/components/block-list/use-block-props/use-focus-handler.cjs +3 -4
  14. package/build/components/block-list/use-block-props/use-focus-handler.cjs.map +3 -3
  15. package/build/components/block-list/use-block-props/use-is-hovered.cjs +24 -14
  16. package/build/components/block-list/use-block-props/use-is-hovered.cjs.map +3 -3
  17. package/build/components/block-lock/modal.cjs.map +3 -3
  18. package/build/components/block-patterns-list/index.cjs +13 -2
  19. package/build/components/block-patterns-list/index.cjs.map +2 -2
  20. package/build/components/block-popover/index.cjs +13 -3
  21. package/build/components/block-popover/index.cjs.map +2 -2
  22. package/build/components/block-toolbar/switch-section-style.cjs.map +3 -3
  23. package/build/components/block-visibility/modal.cjs.map +3 -3
  24. package/build/components/block-visibility/viewport-visibility-info.cjs.map +3 -3
  25. package/build/components/colors-gradients/control.cjs +7 -4
  26. package/build/components/colors-gradients/control.cjs.map +2 -2
  27. package/build/components/global-styles/advanced-panel.cjs +24 -22
  28. package/build/components/global-styles/advanced-panel.cjs.map +3 -3
  29. package/build/components/global-styles/color-panel.cjs +95 -58
  30. package/build/components/global-styles/color-panel.cjs.map +2 -2
  31. package/build/components/global-styles/dimensions-panel.cjs +11 -5
  32. package/build/components/global-styles/dimensions-panel.cjs.map +2 -2
  33. package/build/components/global-styles/index.cjs +3 -0
  34. package/build/components/global-styles/index.cjs.map +2 -2
  35. package/build/components/global-styles/shadow-panel-components.cjs +38 -26
  36. package/build/components/global-styles/shadow-panel-components.cjs.map +2 -2
  37. package/build/components/global-styles/state-control-badges.cjs +69 -0
  38. package/build/components/global-styles/state-control-badges.cjs.map +7 -0
  39. package/build/components/global-styles/state-control.cjs +54 -63
  40. package/build/components/global-styles/state-control.cjs.map +3 -3
  41. package/build/components/iframe/index.cjs +0 -3
  42. package/build/components/iframe/index.cjs.map +2 -2
  43. package/build/components/iframe/use-scale-canvas.cjs +4 -1
  44. package/build/components/iframe/use-scale-canvas.cjs.map +2 -2
  45. package/build/components/inserter/hooks/use-patterns-state.cjs +4 -6
  46. package/build/components/inserter/hooks/use-patterns-state.cjs.map +2 -2
  47. package/build/components/inserter/index.cjs +1 -0
  48. package/build/components/inserter/index.cjs.map +2 -2
  49. package/build/components/inserter/media-tab/media-preview.cjs +27 -18
  50. package/build/components/inserter/media-tab/media-preview.cjs.map +2 -2
  51. package/build/components/inserter/media-tab/utils.cjs +1 -1
  52. package/build/components/inserter/media-tab/utils.cjs.map +2 -2
  53. package/build/components/inserter/panel.cjs.map +3 -3
  54. package/build/components/inspector-controls/block-support-tools-panel.cjs +10 -2
  55. package/build/components/inspector-controls/block-support-tools-panel.cjs.map +2 -2
  56. package/build/components/inspector-controls/fill.cjs +14 -4
  57. package/build/components/inspector-controls/fill.cjs.map +2 -2
  58. package/build/components/inspector-controls/groups.cjs +2 -0
  59. package/build/components/inspector-controls/groups.cjs.map +2 -2
  60. package/build/components/inspector-controls-tabs/index.cjs +13 -8
  61. package/build/components/inspector-controls-tabs/index.cjs.map +3 -3
  62. package/build/components/inspector-controls-tabs/settings-tab.cjs +1 -4
  63. package/build/components/inspector-controls-tabs/settings-tab.cjs.map +3 -3
  64. package/build/components/inspector-controls-tabs/styles-tab.cjs +9 -0
  65. package/build/components/inspector-controls-tabs/styles-tab.cjs.map +3 -3
  66. package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.cjs +11 -5
  67. package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.cjs.map +2 -2
  68. package/build/components/list-view/block-select-button.cjs +20 -8
  69. package/build/components/list-view/block-select-button.cjs.map +2 -2
  70. package/build/components/list-view/block.cjs +2 -1
  71. package/build/components/list-view/block.cjs.map +2 -2
  72. package/build/components/preset-input-control/custom-value-controls.cjs +10 -1
  73. package/build/components/preset-input-control/custom-value-controls.cjs.map +2 -2
  74. package/build/components/preset-input-control/index.cjs.map +3 -3
  75. package/build/components/provider/use-media-upload-settings.cjs +1 -0
  76. package/build/components/provider/use-media-upload-settings.cjs.map +2 -2
  77. package/build/components/rich-text/event-listeners/enter.cjs +9 -2
  78. package/build/components/rich-text/event-listeners/enter.cjs.map +3 -3
  79. package/build/components/rich-text/event-listeners/paste-handler.cjs +4 -4
  80. package/build/components/rich-text/event-listeners/paste-handler.cjs.map +3 -3
  81. package/build/hooks/background.cjs +13 -3
  82. package/build/hooks/background.cjs.map +2 -2
  83. package/build/hooks/block-fields/link/index.cjs.map +3 -3
  84. package/build/hooks/block-fields/media/index.cjs.map +3 -3
  85. package/build/hooks/block-style-state.cjs +112 -0
  86. package/build/hooks/block-style-state.cjs.map +7 -0
  87. package/build/hooks/border.cjs +13 -3
  88. package/build/hooks/border.cjs.map +2 -2
  89. package/build/hooks/color.cjs +28 -9
  90. package/build/hooks/color.cjs.map +2 -2
  91. package/build/hooks/dimensions.cjs +15 -6
  92. package/build/hooks/dimensions.cjs.map +2 -2
  93. package/build/hooks/layout-child.cjs +147 -61
  94. package/build/hooks/layout-child.cjs.map +2 -2
  95. package/build/hooks/layout.cjs +263 -56
  96. package/build/hooks/layout.cjs.map +3 -3
  97. package/build/hooks/state-utils.cjs +94 -0
  98. package/build/hooks/state-utils.cjs.map +7 -0
  99. package/build/hooks/states.cjs +124 -0
  100. package/build/hooks/states.cjs.map +7 -0
  101. package/build/hooks/style.cjs +304 -17
  102. package/build/hooks/style.cjs.map +3 -3
  103. package/build/hooks/typography.cjs +14 -5
  104. package/build/hooks/typography.cjs.map +2 -2
  105. package/build/layouts/constrained.cjs +128 -55
  106. package/build/layouts/constrained.cjs.map +3 -3
  107. package/build/layouts/flex.cjs +119 -31
  108. package/build/layouts/flex.cjs.map +3 -3
  109. package/build/layouts/grid.cjs +103 -40
  110. package/build/layouts/grid.cjs.map +3 -3
  111. package/build/private-apis.cjs +2 -0
  112. package/build/private-apis.cjs.map +2 -2
  113. package/build/store/private-actions.cjs +18 -0
  114. package/build/store/private-actions.cjs.map +2 -2
  115. package/build/store/private-keys.cjs +10 -2
  116. package/build/store/private-keys.cjs.map +2 -2
  117. package/build/store/private-selectors.cjs +26 -2
  118. package/build/store/private-selectors.cjs.map +2 -2
  119. package/build/store/reducer.cjs +70 -1
  120. package/build/store/reducer.cjs.map +2 -2
  121. package/build/store/utils.cjs +1 -1
  122. package/build/store/utils.cjs.map +2 -2
  123. package/build/utils/color-values.cjs +44 -0
  124. package/build/utils/color-values.cjs.map +7 -0
  125. package/build-module/components/block-card/index.mjs +52 -45
  126. package/build-module/components/block-card/index.mjs.map +2 -2
  127. package/build-module/components/block-heading-level-dropdown/heading-level-icon.mjs +2 -2
  128. package/build-module/components/block-heading-level-dropdown/heading-level-icon.mjs.map +2 -2
  129. package/build-module/components/block-icon/index.mjs +8 -2
  130. package/build-module/components/block-icon/index.mjs.map +2 -2
  131. package/build-module/components/block-inspector/index.mjs +166 -13
  132. package/build-module/components/block-inspector/index.mjs.map +2 -2
  133. package/build-module/components/block-inspector/inspector-pre-tabs-slot-fill.mjs +12 -0
  134. package/build-module/components/block-inspector/inspector-pre-tabs-slot-fill.mjs.map +7 -0
  135. package/build-module/components/block-list/use-block-props/index.mjs +1 -1
  136. package/build-module/components/block-list/use-block-props/index.mjs.map +2 -2
  137. package/build-module/components/block-list/use-block-props/use-focus-handler.mjs +7 -5
  138. package/build-module/components/block-list/use-block-props/use-focus-handler.mjs.map +2 -2
  139. package/build-module/components/block-list/use-block-props/use-is-hovered.mjs +28 -15
  140. package/build-module/components/block-list/use-block-props/use-is-hovered.mjs.map +2 -2
  141. package/build-module/components/block-lock/modal.mjs +4 -4
  142. package/build-module/components/block-lock/modal.mjs.map +2 -2
  143. package/build-module/components/block-patterns-list/index.mjs +14 -4
  144. package/build-module/components/block-patterns-list/index.mjs.map +2 -2
  145. package/build-module/components/block-popover/index.mjs +13 -3
  146. package/build-module/components/block-popover/index.mjs.map +2 -2
  147. package/build-module/components/block-toolbar/switch-section-style.mjs +2 -2
  148. package/build-module/components/block-toolbar/switch-section-style.mjs.map +2 -2
  149. package/build-module/components/block-visibility/modal.mjs +2 -2
  150. package/build-module/components/block-visibility/modal.mjs.map +2 -2
  151. package/build-module/components/block-visibility/viewport-visibility-info.mjs +2 -2
  152. package/build-module/components/block-visibility/viewport-visibility-info.mjs.map +2 -2
  153. package/build-module/components/colors-gradients/control.mjs +7 -4
  154. package/build-module/components/colors-gradients/control.mjs.map +2 -2
  155. package/build-module/components/global-styles/advanced-panel.mjs +25 -27
  156. package/build-module/components/global-styles/advanced-panel.mjs.map +2 -2
  157. package/build-module/components/global-styles/color-panel.mjs +96 -59
  158. package/build-module/components/global-styles/color-panel.mjs.map +2 -2
  159. package/build-module/components/global-styles/dimensions-panel.mjs +14 -5
  160. package/build-module/components/global-styles/dimensions-panel.mjs.map +2 -2
  161. package/build-module/components/global-styles/index.mjs +2 -0
  162. package/build-module/components/global-styles/index.mjs.map +2 -2
  163. package/build-module/components/global-styles/shadow-panel-components.mjs +39 -28
  164. package/build-module/components/global-styles/shadow-panel-components.mjs.map +2 -2
  165. package/build-module/components/global-styles/state-control-badges.mjs +48 -0
  166. package/build-module/components/global-styles/state-control-badges.mjs.map +7 -0
  167. package/build-module/components/global-styles/state-control.mjs +57 -71
  168. package/build-module/components/global-styles/state-control.mjs.map +2 -2
  169. package/build-module/components/iframe/index.mjs +0 -3
  170. package/build-module/components/iframe/index.mjs.map +2 -2
  171. package/build-module/components/iframe/use-scale-canvas.mjs +4 -1
  172. package/build-module/components/iframe/use-scale-canvas.mjs.map +2 -2
  173. package/build-module/components/inserter/hooks/use-patterns-state.mjs +8 -7
  174. package/build-module/components/inserter/hooks/use-patterns-state.mjs.map +2 -2
  175. package/build-module/components/inserter/index.mjs +1 -0
  176. package/build-module/components/inserter/index.mjs.map +2 -2
  177. package/build-module/components/inserter/media-tab/media-preview.mjs +27 -19
  178. package/build-module/components/inserter/media-tab/media-preview.mjs.map +2 -2
  179. package/build-module/components/inserter/media-tab/utils.mjs +1 -1
  180. package/build-module/components/inserter/media-tab/utils.mjs.map +2 -2
  181. package/build-module/components/inserter/panel.mjs +2 -2
  182. package/build-module/components/inserter/panel.mjs.map +2 -2
  183. package/build-module/components/inspector-controls/block-support-tools-panel.mjs +10 -2
  184. package/build-module/components/inspector-controls/block-support-tools-panel.mjs.map +2 -2
  185. package/build-module/components/inspector-controls/fill.mjs +18 -5
  186. package/build-module/components/inspector-controls/fill.mjs.map +2 -2
  187. package/build-module/components/inspector-controls/groups.mjs +2 -0
  188. package/build-module/components/inspector-controls/groups.mjs.map +2 -2
  189. package/build-module/components/inspector-controls-tabs/index.mjs +14 -10
  190. package/build-module/components/inspector-controls-tabs/index.mjs.map +2 -2
  191. package/build-module/components/inspector-controls-tabs/settings-tab.mjs +1 -4
  192. package/build-module/components/inspector-controls-tabs/settings-tab.mjs.map +2 -2
  193. package/build-module/components/inspector-controls-tabs/styles-tab.mjs +9 -0
  194. package/build-module/components/inspector-controls-tabs/styles-tab.mjs.map +2 -2
  195. package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.mjs +11 -5
  196. package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.mjs.map +2 -2
  197. package/build-module/components/list-view/block-select-button.mjs +20 -9
  198. package/build-module/components/list-view/block-select-button.mjs.map +2 -2
  199. package/build-module/components/list-view/block.mjs +2 -1
  200. package/build-module/components/list-view/block.mjs.map +2 -2
  201. package/build-module/components/preset-input-control/custom-value-controls.mjs +10 -2
  202. package/build-module/components/preset-input-control/custom-value-controls.mjs.map +2 -2
  203. package/build-module/components/preset-input-control/index.mjs +2 -2
  204. package/build-module/components/preset-input-control/index.mjs.map +2 -2
  205. package/build-module/components/provider/use-media-upload-settings.mjs +1 -0
  206. package/build-module/components/provider/use-media-upload-settings.mjs.map +2 -2
  207. package/build-module/components/rich-text/event-listeners/enter.mjs +9 -2
  208. package/build-module/components/rich-text/event-listeners/enter.mjs.map +2 -2
  209. package/build-module/components/rich-text/event-listeners/paste-handler.mjs +4 -4
  210. package/build-module/components/rich-text/event-listeners/paste-handler.mjs.map +2 -2
  211. package/build-module/hooks/background.mjs +18 -3
  212. package/build-module/hooks/background.mjs.map +2 -2
  213. package/build-module/hooks/block-fields/link/index.mjs +3 -3
  214. package/build-module/hooks/block-fields/link/index.mjs.map +2 -2
  215. package/build-module/hooks/block-fields/media/index.mjs +3 -3
  216. package/build-module/hooks/block-fields/media/index.mjs.map +2 -2
  217. package/build-module/hooks/block-style-state.mjs +79 -0
  218. package/build-module/hooks/block-style-state.mjs.map +7 -0
  219. package/build-module/hooks/border.mjs +18 -3
  220. package/build-module/hooks/border.mjs.map +2 -2
  221. package/build-module/hooks/color.mjs +33 -9
  222. package/build-module/hooks/color.mjs.map +2 -2
  223. package/build-module/hooks/dimensions.mjs +20 -6
  224. package/build-module/hooks/dimensions.mjs.map +2 -2
  225. package/build-module/hooks/layout-child.mjs +141 -61
  226. package/build-module/hooks/layout-child.mjs.map +2 -2
  227. package/build-module/hooks/layout.mjs +270 -58
  228. package/build-module/hooks/layout.mjs.map +2 -2
  229. package/build-module/hooks/state-utils.mjs +64 -0
  230. package/build-module/hooks/state-utils.mjs.map +7 -0
  231. package/build-module/hooks/states.mjs +85 -0
  232. package/build-module/hooks/states.mjs.map +7 -0
  233. package/build-module/hooks/style.mjs +309 -18
  234. package/build-module/hooks/style.mjs.map +2 -2
  235. package/build-module/hooks/typography.mjs +19 -5
  236. package/build-module/hooks/typography.mjs.map +2 -2
  237. package/build-module/layouts/constrained.mjs +130 -57
  238. package/build-module/layouts/constrained.mjs.map +2 -2
  239. package/build-module/layouts/flex.mjs +123 -35
  240. package/build-module/layouts/flex.mjs.map +2 -2
  241. package/build-module/layouts/grid.mjs +105 -42
  242. package/build-module/layouts/grid.mjs.map +2 -2
  243. package/build-module/private-apis.mjs +4 -0
  244. package/build-module/private-apis.mjs.map +2 -2
  245. package/build-module/store/private-actions.mjs +16 -0
  246. package/build-module/store/private-actions.mjs.map +2 -2
  247. package/build-module/store/private-keys.mjs +7 -1
  248. package/build-module/store/private-keys.mjs.map +2 -2
  249. package/build-module/store/private-selectors.mjs +25 -2
  250. package/build-module/store/private-selectors.mjs.map +2 -2
  251. package/build-module/store/reducer.mjs +69 -1
  252. package/build-module/store/reducer.mjs.map +2 -2
  253. package/build-module/store/utils.mjs +5 -2
  254. package/build-module/store/utils.mjs.map +2 -2
  255. package/build-module/utils/color-values.mjs +19 -0
  256. package/build-module/utils/color-values.mjs.map +7 -0
  257. package/build-style/content-rtl.css +18 -3
  258. package/build-style/content.css +18 -3
  259. package/build-style/style-rtl.css +14 -17
  260. package/build-style/style.css +14 -17
  261. package/package.json +41 -41
  262. package/src/components/audio-player/index.native.js +7 -3
  263. package/src/components/block-card/index.js +67 -60
  264. package/src/components/block-heading-level-dropdown/heading-level-icon.js +2 -2
  265. package/src/components/block-icon/index.js +5 -2
  266. package/src/components/block-icon/index.native.js +2 -2
  267. package/src/components/block-inspector/index.js +153 -7
  268. package/src/components/block-inspector/inspector-pre-tabs-slot-fill.js +11 -0
  269. package/src/components/block-list/block-selection-button.native.js +3 -3
  270. package/src/components/block-list/content.scss +0 -6
  271. package/src/components/block-list/use-block-props/index.js +1 -1
  272. package/src/components/block-list/use-block-props/use-focus-handler.js +8 -6
  273. package/src/components/block-list/use-block-props/use-is-hovered.js +32 -15
  274. package/src/components/block-lock/modal.js +4 -4
  275. package/src/components/block-patterns-list/index.js +14 -5
  276. package/src/components/block-patterns-list/stories/index.story.jsx +2 -0
  277. package/src/components/block-patterns-list/style.scss +0 -1
  278. package/src/components/block-popover/index.js +20 -10
  279. package/src/components/block-toolbar/switch-section-style.js +2 -2
  280. package/src/components/block-visibility/modal.js +2 -2
  281. package/src/components/block-visibility/viewport-visibility-info.js +2 -2
  282. package/src/components/colors/test/with-colors.js +1 -1
  283. package/src/components/colors-gradients/control.js +10 -8
  284. package/src/components/colors-gradients/test/control.js +98 -1
  285. package/src/components/global-styles/advanced-panel.js +44 -39
  286. package/src/components/global-styles/color-panel.js +133 -60
  287. package/src/components/global-styles/dimensions-panel.js +17 -4
  288. package/src/components/global-styles/index.js +1 -0
  289. package/src/components/global-styles/shadow-panel-components.js +29 -19
  290. package/src/components/global-styles/state-control-badges.js +58 -0
  291. package/src/components/global-styles/state-control.js +28 -36
  292. package/src/components/global-styles/test/color-panel.js +135 -0
  293. package/src/components/iframe/index.js +0 -3
  294. package/src/components/iframe/use-scale-canvas.js +8 -2
  295. package/src/components/inserter/hooks/use-patterns-state.js +12 -7
  296. package/src/components/inserter/index.js +1 -0
  297. package/src/components/inserter/media-tab/media-preview.js +29 -20
  298. package/src/components/inserter/media-tab/utils.js +1 -1
  299. package/src/components/inserter/panel.js +2 -2
  300. package/src/components/inserter/style.scss +1 -0
  301. package/src/components/inserter-button/index.native.js +5 -2
  302. package/src/components/inspector-controls/block-support-tools-panel.js +10 -2
  303. package/src/components/inspector-controls/fill.js +18 -5
  304. package/src/components/inspector-controls/groups.js +2 -0
  305. package/src/components/inspector-controls-tabs/index.js +9 -5
  306. package/src/components/inspector-controls-tabs/settings-tab.js +1 -7
  307. package/src/components/inspector-controls-tabs/styles-tab.js +6 -0
  308. package/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js +13 -7
  309. package/src/components/list-view/block-select-button.js +19 -9
  310. package/src/components/list-view/block.js +6 -1
  311. package/src/components/media-replace-flow/style.scss +0 -18
  312. package/src/components/preset-input-control/custom-value-controls.js +13 -6
  313. package/src/components/preset-input-control/index.js +2 -2
  314. package/src/components/provider/use-media-upload-settings.js +1 -0
  315. package/src/components/rich-text/event-listeners/enter.js +14 -2
  316. package/src/components/rich-text/event-listeners/paste-handler.js +5 -4
  317. package/src/components/unsupported-block-details/index.native.js +6 -2
  318. package/src/components/video-player/index.native.js +2 -2
  319. package/src/components/warning/index.native.js +2 -2
  320. package/src/hooks/background.js +59 -37
  321. package/src/hooks/block-fields/link/index.js +3 -3
  322. package/src/hooks/block-fields/media/index.js +3 -3
  323. package/src/hooks/block-style-state.js +127 -0
  324. package/src/hooks/border.js +25 -6
  325. package/src/hooks/color.js +40 -18
  326. package/src/hooks/dimensions.js +32 -11
  327. package/src/hooks/layout-child.js +179 -62
  328. package/src/hooks/layout.js +349 -75
  329. package/src/hooks/layout.scss +6 -0
  330. package/src/hooks/state-utils.js +158 -0
  331. package/src/hooks/states.js +109 -0
  332. package/src/hooks/style.js +456 -19
  333. package/src/hooks/test/block-style-state.js +270 -0
  334. package/src/hooks/test/layout.js +185 -0
  335. package/src/hooks/test/state-utils.js +193 -0
  336. package/src/hooks/test/style.js +301 -1
  337. package/src/hooks/typography.js +33 -14
  338. package/src/layouts/constrained.js +182 -95
  339. package/src/layouts/flex.js +141 -36
  340. package/src/layouts/grid.js +122 -32
  341. package/src/layouts/test/flex.js +57 -20
  342. package/src/private-apis.js +4 -0
  343. package/src/store/private-actions.js +32 -0
  344. package/src/store/private-keys.js +4 -0
  345. package/src/store/private-selectors.js +44 -2
  346. package/src/store/reducer.js +105 -1
  347. package/src/store/test/private-actions.js +26 -0
  348. package/src/store/test/private-selectors.js +90 -0
  349. package/src/store/test/reducer.js +363 -0
  350. package/src/store/utils.js +6 -2
  351. package/src/utils/color-values.js +28 -0
  352. package/src/utils/test/color-values.js +78 -0
@@ -7,7 +7,7 @@ import {
7
7
  __experimentalToggleGroupControl as ToggleGroupControl,
8
8
  __experimentalToggleGroupControlOptionIcon as ToggleGroupControlOptionIcon,
9
9
  __experimentalInputControlPrefixWrapper as InputControlPrefixWrapper,
10
- __experimentalVStack as VStack,
10
+ __experimentalToolsPanelItem as ToolsPanelItem,
11
11
  } from '@wordpress/components';
12
12
  import { __ } from '@wordpress/i18n';
13
13
  import {
@@ -27,7 +27,7 @@ import { useSettings } from '../components/use-settings';
27
27
  import { appendSelectors, getBlockGapCSS, getAlignmentsInfo } from './utils';
28
28
  import { getGapCSSValue } from '../hooks/gap';
29
29
  import { BlockControls, JustifyContentControl } from '../components';
30
- import { shouldSkipSerialization } from '../hooks/utils';
30
+ import { cleanEmptyObject, shouldSkipSerialization } from '../hooks/utils';
31
31
  import { LAYOUT_DEFINITIONS } from './definitions';
32
32
 
33
33
  export default {
@@ -37,6 +37,8 @@ export default {
37
37
  layout,
38
38
  onChange,
39
39
  layoutBlockSupport = {},
40
+ resetLayout = {},
41
+ clientId,
40
42
  } ) {
41
43
  const { wideSize, contentSize, justifyContent = 'center' } = layout;
42
44
  const {
@@ -70,92 +72,143 @@ export default {
70
72
  const units = useCustomUnits( {
71
73
  availableUnits: availableUnits || [ '%', 'px', 'em', 'rem', 'vw' ],
72
74
  } );
75
+ const hasLayoutValue = ( key, defaultValue ) =>
76
+ ( layout?.[ key ] ?? defaultValue ) !==
77
+ ( resetLayout?.[ key ] ?? defaultValue );
78
+ const resetContentSize = () =>
79
+ onChange(
80
+ cleanEmptyObject( {
81
+ ...layout,
82
+ contentSize: resetLayout?.contentSize,
83
+ } )
84
+ );
85
+ const resetWideSize = () =>
86
+ onChange(
87
+ cleanEmptyObject( {
88
+ ...layout,
89
+ wideSize: resetLayout?.wideSize,
90
+ } )
91
+ );
92
+ const resetJustification = () =>
93
+ onChange(
94
+ cleanEmptyObject( {
95
+ ...layout,
96
+ justifyContent: resetLayout?.justifyContent,
97
+ } )
98
+ );
99
+ const hasContentSizeValue = () => hasLayoutValue( 'contentSize' );
100
+ const hasWideSizeValue = () => hasLayoutValue( 'wideSize' );
101
+ const hasJustificationValue = () =>
102
+ hasLayoutValue( 'justifyContent', 'center' );
103
+
73
104
  return (
74
- <VStack
75
- spacing={ 4 }
76
- className="block-editor-hooks__layout-constrained"
77
- >
105
+ <>
78
106
  { allowCustomContentAndWideSize && (
79
107
  <>
80
- <UnitControl
81
- __next40pxDefaultSize
108
+ <ToolsPanelItem
82
109
  label={ __( 'Content width' ) }
83
- labelPosition="top"
84
- value={ contentSize || wideSize || '' }
85
- onChange={ ( nextWidth ) => {
86
- nextWidth =
87
- 0 > parseFloat( nextWidth )
88
- ? '0'
89
- : nextWidth;
90
- onChange( {
91
- ...layout,
92
- contentSize:
93
- nextWidth !== ''
94
- ? nextWidth
95
- : undefined,
96
- } );
97
- } }
98
- units={ units }
99
- prefix={
100
- <InputControlPrefixWrapper variant="icon">
101
- <Icon icon={ alignNone } />
102
- </InputControlPrefixWrapper>
103
- }
104
- />
105
- <UnitControl
106
- __next40pxDefaultSize
110
+ hasValue={ hasContentSizeValue }
111
+ onDeselect={ resetContentSize }
112
+ panelId={ clientId }
113
+ >
114
+ <UnitControl
115
+ __next40pxDefaultSize
116
+ label={ __( 'Content width' ) }
117
+ labelPosition="top"
118
+ value={ contentSize || wideSize || '' }
119
+ onChange={ ( nextWidth ) => {
120
+ nextWidth =
121
+ 0 > parseFloat( nextWidth )
122
+ ? '0'
123
+ : nextWidth;
124
+ onChange(
125
+ cleanEmptyObject( {
126
+ ...layout,
127
+ contentSize:
128
+ nextWidth !== ''
129
+ ? nextWidth
130
+ : undefined,
131
+ } )
132
+ );
133
+ } }
134
+ units={ units }
135
+ prefix={
136
+ <InputControlPrefixWrapper variant="icon">
137
+ <Icon icon={ alignNone } />
138
+ </InputControlPrefixWrapper>
139
+ }
140
+ />
141
+ </ToolsPanelItem>
142
+ <ToolsPanelItem
107
143
  label={ __( 'Wide width' ) }
108
- labelPosition="top"
109
- value={ wideSize || contentSize || '' }
110
- onChange={ ( nextWidth ) => {
111
- nextWidth =
112
- 0 > parseFloat( nextWidth )
113
- ? '0'
114
- : nextWidth;
115
- onChange( {
116
- ...layout,
117
- wideSize:
118
- nextWidth !== ''
119
- ? nextWidth
120
- : undefined,
121
- } );
122
- } }
123
- units={ units }
124
- prefix={
125
- <InputControlPrefixWrapper variant="icon">
126
- <Icon icon={ stretchWide } />
127
- </InputControlPrefixWrapper>
128
- }
129
- />
130
- <p className="block-editor-hooks__layout-constrained-helptext">
131
- { __(
132
- 'Customize the width for all elements that are assigned to the center or wide columns.'
133
- ) }
134
- </p>
144
+ hasValue={ hasWideSizeValue }
145
+ onDeselect={ resetWideSize }
146
+ panelId={ clientId }
147
+ >
148
+ <UnitControl
149
+ __next40pxDefaultSize
150
+ label={ __( 'Wide width' ) }
151
+ labelPosition="top"
152
+ value={ wideSize || contentSize || '' }
153
+ onChange={ ( nextWidth ) => {
154
+ nextWidth =
155
+ 0 > parseFloat( nextWidth )
156
+ ? '0'
157
+ : nextWidth;
158
+ onChange(
159
+ cleanEmptyObject( {
160
+ ...layout,
161
+ wideSize:
162
+ nextWidth !== ''
163
+ ? nextWidth
164
+ : undefined,
165
+ } )
166
+ );
167
+ } }
168
+ units={ units }
169
+ prefix={
170
+ <InputControlPrefixWrapper variant="icon">
171
+ <Icon icon={ stretchWide } />
172
+ </InputControlPrefixWrapper>
173
+ }
174
+ />
175
+ <p className="block-editor-hooks__layout-constrained-helptext">
176
+ { __(
177
+ 'Customize the width for all elements that are assigned to the center or wide columns.'
178
+ ) }
179
+ </p>
180
+ </ToolsPanelItem>
135
181
  </>
136
182
  ) }
137
183
  { allowJustification && (
138
- <ToggleGroupControl
139
- __next40pxDefaultSize
184
+ <ToolsPanelItem
140
185
  label={ __( 'Justification' ) }
141
- value={ justifyContent }
142
- onChange={ onJustificationChange }
186
+ hasValue={ hasJustificationValue }
187
+ onDeselect={ resetJustification }
188
+ panelId={ clientId }
143
189
  >
144
- { justificationOptions.map(
145
- ( { value, icon, label } ) => {
146
- return (
147
- <ToggleGroupControlOptionIcon
148
- key={ value }
149
- value={ value }
150
- icon={ icon }
151
- label={ label }
152
- />
153
- );
154
- }
155
- ) }
156
- </ToggleGroupControl>
190
+ <ToggleGroupControl
191
+ __next40pxDefaultSize
192
+ label={ __( 'Justification' ) }
193
+ value={ justifyContent }
194
+ onChange={ onJustificationChange }
195
+ >
196
+ { justificationOptions.map(
197
+ ( { value, icon, label } ) => {
198
+ return (
199
+ <ToggleGroupControlOptionIcon
200
+ key={ value }
201
+ value={ value }
202
+ icon={ icon }
203
+ label={ label }
204
+ />
205
+ );
206
+ }
207
+ ) }
208
+ </ToggleGroupControl>
209
+ </ToolsPanelItem>
157
210
  ) }
158
- </VStack>
211
+ </>
159
212
  );
160
213
  },
161
214
  toolBarControls: function DefaultLayoutToolbarControls( {
@@ -180,13 +233,26 @@ export default {
180
233
  getLayoutStyle: function getLayoutStyle( {
181
234
  selector,
182
235
  layout = {},
236
+ viewportOverrides,
183
237
  style,
184
238
  blockName,
185
239
  hasBlockGapSupport,
186
240
  layoutDefinitions = LAYOUT_DEFINITIONS,
187
241
  } ) {
188
- const { contentSize, wideSize, justifyContent } = layout;
242
+ const hasViewportOverrides = viewportOverrides !== undefined;
243
+ const effectiveLayout = hasViewportOverrides
244
+ ? { ...layout, ...viewportOverrides }
245
+ : layout;
246
+ const hasViewportOverride = ( key ) =>
247
+ Object.hasOwn( viewportOverrides || {}, key );
248
+ const { contentSize, wideSize, justifyContent } = effectiveLayout;
189
249
  const blockGapStyleValue = getGapCSSValue( style?.spacing?.blockGap );
250
+ const hasBlockGapOverride =
251
+ ! hasViewportOverrides ||
252
+ Object.hasOwn( style?.spacing || {}, 'blockGap' );
253
+ const hasBlockSpacingOverride =
254
+ ! hasViewportOverrides ||
255
+ Object.hasOwn( style?.spacing || {}, 'padding' );
190
256
 
191
257
  // If a block's block.json skips serialization for spacing or
192
258
  // spacing.blockGap, don't apply the user-defined value to the styles.
@@ -205,16 +271,29 @@ export default {
205
271
  const marginRight =
206
272
  justifyContent === 'right' ? '0 !important' : 'auto !important';
207
273
 
274
+ const hasJustificationOverride =
275
+ hasViewportOverrides && hasViewportOverride( 'justifyContent' );
276
+ const shouldOutputConstrainedSizes =
277
+ ! hasViewportOverrides ||
278
+ hasViewportOverride( 'contentSize' ) ||
279
+ hasViewportOverride( 'wideSize' );
280
+ const constrainedSizeDeclarations = [
281
+ `max-width: ${ contentSize ?? wideSize }`,
282
+ ];
283
+ if ( ! hasViewportOverrides || hasJustificationOverride ) {
284
+ constrainedSizeDeclarations.push(
285
+ `margin-left: ${ marginLeft }`,
286
+ `margin-right: ${ marginRight }`
287
+ );
288
+ }
208
289
  let output =
209
- !! contentSize || !! wideSize
290
+ shouldOutputConstrainedSizes && ( !! contentSize || !! wideSize )
210
291
  ? `
211
- ${ appendSelectors(
212
- selector,
213
- '> :where(:not(.alignleft):not(.alignright):not(.alignfull))'
214
- ) } {
215
- max-width: ${ contentSize ?? wideSize };
216
- margin-left: ${ marginLeft };
217
- margin-right: ${ marginRight };
292
+ ${ appendSelectors(
293
+ selector,
294
+ '> :where(:not(.alignleft):not(.alignright):not(.alignfull))'
295
+ ) } {
296
+ ${ constrainedSizeDeclarations.join( '; ' ) };
218
297
  }
219
298
  ${ appendSelectors( selector, '> .alignwide' ) } {
220
299
  max-width: ${ wideSize ?? contentSize };
@@ -222,25 +301,33 @@ export default {
222
301
  ${ appendSelectors( selector, '> .alignfull' ) } {
223
302
  max-width: none;
224
303
  }
225
- `
304
+ `
226
305
  : '';
227
306
 
228
- if ( justifyContent === 'left' ) {
307
+ if ( hasJustificationOverride && ! shouldOutputConstrainedSizes ) {
229
308
  output += `${ appendSelectors(
230
309
  selector,
231
310
  '> :where(:not(.alignleft):not(.alignright):not(.alignfull))'
232
311
  ) }
312
+ { margin-left: ${ marginLeft }; margin-right: ${ marginRight }; }`;
313
+ } else if ( ! hasViewportOverrides ) {
314
+ if ( justifyContent === 'left' ) {
315
+ output += `${ appendSelectors(
316
+ selector,
317
+ '> :where(:not(.alignleft):not(.alignright):not(.alignfull))'
318
+ ) }
233
319
  { margin-left: ${ marginLeft }; }`;
234
- } else if ( justifyContent === 'right' ) {
235
- output += `${ appendSelectors(
236
- selector,
237
- '> :where(:not(.alignleft):not(.alignright):not(.alignfull))'
238
- ) }
320
+ } else if ( justifyContent === 'right' ) {
321
+ output += `${ appendSelectors(
322
+ selector,
323
+ '> :where(:not(.alignleft):not(.alignright):not(.alignfull))'
324
+ ) }
239
325
  { margin-right: ${ marginRight }; }`;
326
+ }
240
327
  }
241
328
 
242
329
  // If there is custom padding, add negative margins for alignfull blocks.
243
- if ( style?.spacing?.padding ) {
330
+ if ( hasBlockSpacingOverride && style?.spacing?.padding ) {
244
331
  // The style object might be storing a preset so we need to make sure we get a usable value.
245
332
  const paddingValues = getCSSRules( style );
246
333
  paddingValues.forEach( ( rule ) => {
@@ -269,7 +356,7 @@ export default {
269
356
  }
270
357
 
271
358
  // Output blockGap styles based on rules contained in layout definitions in theme.json.
272
- if ( hasBlockGapSupport && blockGapValue ) {
359
+ if ( hasBlockGapSupport && hasBlockGapOverride && blockGapValue ) {
273
360
  output += getBlockGapCSS(
274
361
  selector,
275
362
  layoutDefinitions,
@@ -12,11 +12,11 @@ import {
12
12
  arrowDown,
13
13
  } from '@wordpress/icons';
14
14
  import {
15
- ToggleControl,
16
15
  Flex,
17
- FlexItem,
16
+ ToggleControl,
18
17
  __experimentalToggleGroupControl as ToggleGroupControl,
19
18
  __experimentalToggleGroupControlOptionIcon as ToggleGroupControlOptionIcon,
19
+ __experimentalToolsPanelItem as ToolsPanelItem,
20
20
  } from '@wordpress/components';
21
21
 
22
22
  /**
@@ -30,7 +30,7 @@ import {
30
30
  JustifyContentControl,
31
31
  BlockVerticalAlignmentControl,
32
32
  } from '../components';
33
- import { shouldSkipSerialization } from '../hooks/utils';
33
+ import { cleanEmptyObject, shouldSkipSerialization } from '../hooks/utils';
34
34
  import { LAYOUT_DEFINITIONS } from './definitions';
35
35
 
36
36
  // Used with the default, horizontal flex orientation.
@@ -71,34 +71,110 @@ export default {
71
71
  layout = {},
72
72
  onChange,
73
73
  layoutBlockSupport = {},
74
+ resetLayout = {},
75
+ clientId,
74
76
  } ) {
75
77
  const {
76
78
  allowOrientation = true,
77
79
  allowJustification = true,
78
80
  allowWrap = true,
79
81
  } = layoutBlockSupport;
82
+ const hasLayoutValue = ( key, defaultValue ) =>
83
+ ( layout?.[ key ] ?? defaultValue ) !==
84
+ ( resetLayout?.[ key ] ?? defaultValue );
85
+ const hasJustificationValue = () =>
86
+ hasLayoutValue( 'justifyContent', 'left' );
87
+ const hasOrientationValue = () =>
88
+ hasLayoutValue( 'orientation', 'horizontal' );
89
+ const hasWrapValue = () => hasLayoutValue( 'flexWrap', 'wrap' );
90
+ const resetJustification = () =>
91
+ onChange(
92
+ cleanEmptyObject( {
93
+ ...layout,
94
+ justifyContent: resetLayout?.justifyContent,
95
+ } )
96
+ );
97
+ const resetOrientation = () => {
98
+ const { verticalAlignment, justifyContent } = layout;
99
+ const nextOrientation = resetLayout?.orientation;
100
+ const isHorizontal =
101
+ ! nextOrientation || nextOrientation === 'horizontal';
102
+ onChange(
103
+ cleanEmptyObject( {
104
+ ...layout,
105
+ orientation: nextOrientation,
106
+ verticalAlignment:
107
+ resetLayout?.verticalAlignment ??
108
+ ( isHorizontal && verticalAlignment === 'space-between'
109
+ ? 'center'
110
+ : verticalAlignment ),
111
+ justifyContent:
112
+ resetLayout?.justifyContent ??
113
+ ( isHorizontal && justifyContent === 'stretch'
114
+ ? 'left'
115
+ : justifyContent ),
116
+ } )
117
+ );
118
+ };
119
+ const resetWrap = () =>
120
+ onChange(
121
+ cleanEmptyObject( {
122
+ ...layout,
123
+ flexWrap: resetLayout?.flexWrap,
124
+ } )
125
+ );
126
+
80
127
  return (
81
128
  <>
82
- <Flex>
83
- { allowJustification && (
84
- <FlexItem>
85
- <FlexLayoutJustifyContentControl
86
- layout={ layout }
87
- onChange={ onChange }
88
- />
89
- </FlexItem>
90
- ) }
91
- { allowOrientation && (
92
- <FlexItem>
93
- <OrientationControl
94
- layout={ layout }
95
- onChange={ onChange }
96
- />
97
- </FlexItem>
98
- ) }
99
- </Flex>
129
+ { ( allowJustification || allowOrientation ) && (
130
+ <Flex
131
+ align="flex-start"
132
+ className="block-editor-hooks__flex-layout-controls"
133
+ gap={ 4 }
134
+ justify="flex-start"
135
+ >
136
+ { allowJustification && (
137
+ <ToolsPanelItem
138
+ label={ __( 'Justification' ) }
139
+ hasValue={ hasJustificationValue }
140
+ onDeselect={ resetJustification }
141
+ isShownByDefault
142
+ panelId={ clientId }
143
+ >
144
+ <FlexLayoutJustifyContentControl
145
+ layout={ layout }
146
+ onChange={ onChange }
147
+ />
148
+ </ToolsPanelItem>
149
+ ) }
150
+ { allowOrientation && (
151
+ <ToolsPanelItem
152
+ label={ __( 'Orientation' ) }
153
+ hasValue={ hasOrientationValue }
154
+ onDeselect={ resetOrientation }
155
+ isShownByDefault
156
+ panelId={ clientId }
157
+ >
158
+ <OrientationControl
159
+ layout={ layout }
160
+ onChange={ onChange }
161
+ />
162
+ </ToolsPanelItem>
163
+ ) }
164
+ </Flex>
165
+ ) }
100
166
  { allowWrap && (
101
- <FlexWrapControl layout={ layout } onChange={ onChange } />
167
+ <ToolsPanelItem
168
+ label={ __( 'Wrapping' ) }
169
+ hasValue={ hasWrapValue }
170
+ onDeselect={ resetWrap }
171
+ panelId={ clientId }
172
+ >
173
+ <FlexWrapControl
174
+ layout={ layout }
175
+ onChange={ onChange }
176
+ />
177
+ </ToolsPanelItem>
102
178
  ) }
103
179
  </>
104
180
  );
@@ -135,14 +211,21 @@ export default {
135
211
  },
136
212
  getLayoutStyle: function getLayoutStyle( {
137
213
  selector,
138
- layout,
214
+ layout = {},
215
+ viewportOverrides,
139
216
  style,
140
217
  blockName,
141
218
  hasBlockGapSupport,
142
219
  globalBlockGapValue,
143
220
  layoutDefinitions = LAYOUT_DEFINITIONS,
144
221
  } ) {
145
- const { orientation = 'horizontal' } = layout;
222
+ const hasViewportOverrides = viewportOverrides !== undefined;
223
+ const effectiveLayout = hasViewportOverrides
224
+ ? { ...layout, ...viewportOverrides }
225
+ : layout;
226
+ const hasViewportOverride = ( key ) =>
227
+ Object.hasOwn( viewportOverrides || {}, key );
228
+ const { orientation = 'horizontal' } = effectiveLayout;
146
229
 
147
230
  // Determine the fallback gap value using global styles (theme.json),
148
231
  // falling back to '0.5em' for backwards compatibility.
@@ -163,35 +246,57 @@ export default {
163
246
  ! shouldSkipSerialization( blockName, 'spacing', 'blockGap' )
164
247
  ? getGapCSSValue( style?.spacing?.blockGap, fallbackGapValue )
165
248
  : undefined;
166
- const justifyContent = justifyContentMap[ layout.justifyContent ];
167
- const flexWrap = flexWrapOptions.includes( layout.flexWrap )
168
- ? layout.flexWrap
249
+ const hasBlockGapOverride =
250
+ ! hasViewportOverrides ||
251
+ Object.hasOwn( style?.spacing || {}, 'blockGap' );
252
+ const justifyContent =
253
+ justifyContentMap[ effectiveLayout.justifyContent ];
254
+ const flexWrap = flexWrapOptions.includes( effectiveLayout.flexWrap )
255
+ ? effectiveLayout.flexWrap
169
256
  : 'wrap';
170
257
  const verticalAlignment =
171
- verticalAlignmentMap[ layout.verticalAlignment ];
258
+ verticalAlignmentMap[ effectiveLayout.verticalAlignment ];
172
259
  const alignItems =
173
- alignItemsMap[ layout.justifyContent ] || alignItemsMap.left;
260
+ alignItemsMap[ effectiveLayout.justifyContent ] ||
261
+ alignItemsMap.left;
174
262
 
175
263
  let output = '';
176
264
  const rules = [];
177
265
 
178
- if ( flexWrap && flexWrap !== 'wrap' ) {
266
+ const shouldOutputFlexWrap =
267
+ ! hasViewportOverrides || hasViewportOverride( 'flexWrap' );
268
+ const shouldOutputFlexOrientation =
269
+ ! hasViewportOverrides || hasViewportOverride( 'orientation' );
270
+ const shouldOutputFlexJustification =
271
+ ! hasViewportOverrides ||
272
+ hasViewportOverride( 'justifyContent' ) ||
273
+ hasViewportOverride( 'orientation' );
274
+ const shouldOutputFlexAlignment =
275
+ ! hasViewportOverrides ||
276
+ hasViewportOverride( 'verticalAlignment' ) ||
277
+ hasViewportOverride( 'orientation' );
278
+
279
+ if ( shouldOutputFlexWrap && flexWrap && flexWrap !== 'wrap' ) {
179
280
  rules.push( `flex-wrap: ${ flexWrap }` );
180
281
  }
181
282
 
182
283
  if ( orientation === 'horizontal' ) {
183
- if ( verticalAlignment ) {
284
+ if ( shouldOutputFlexAlignment && verticalAlignment ) {
184
285
  rules.push( `align-items: ${ verticalAlignment }` );
185
286
  }
186
- if ( justifyContent ) {
287
+ if ( shouldOutputFlexJustification && justifyContent ) {
187
288
  rules.push( `justify-content: ${ justifyContent }` );
188
289
  }
189
290
  } else {
190
- if ( verticalAlignment ) {
291
+ if ( shouldOutputFlexAlignment && verticalAlignment ) {
191
292
  rules.push( `justify-content: ${ verticalAlignment }` );
192
293
  }
193
- rules.push( 'flex-direction: column' );
194
- rules.push( `align-items: ${ alignItems }` );
294
+ if ( shouldOutputFlexOrientation ) {
295
+ rules.push( 'flex-direction: column' );
296
+ }
297
+ if ( shouldOutputFlexJustification ) {
298
+ rules.push( `align-items: ${ alignItems }` );
299
+ }
195
300
  }
196
301
 
197
302
  if ( rules.length ) {
@@ -201,7 +306,7 @@ export default {
201
306
  }
202
307
 
203
308
  // Output blockGap styles based on rules contained in layout definitions in theme.json.
204
- if ( hasBlockGapSupport && blockGapValue ) {
309
+ if ( hasBlockGapSupport && hasBlockGapOverride && blockGapValue ) {
205
310
  output += getBlockGapCSS(
206
311
  selector,
207
312
  layoutDefinitions,