@wordpress/block-editor 11.4.0 → 11.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (400) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/build/components/block-inspector/index.js +11 -10
  3. package/build/components/block-inspector/index.js.map +1 -1
  4. package/build/components/block-inspector/useBlockInspectorAnimationSettings.js +46 -0
  5. package/build/components/block-inspector/useBlockInspectorAnimationSettings.js.map +1 -0
  6. package/build/components/block-list/block-invalid-warning.js +63 -80
  7. package/build/components/block-list/block-invalid-warning.js.map +1 -1
  8. package/build/components/block-lock/modal.js +1 -0
  9. package/build/components/block-lock/modal.js.map +1 -1
  10. package/build/components/block-settings-menu/block-settings-dropdown.js +2 -2
  11. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  12. package/build/components/block-settings-menu-controls/index.js +1 -1
  13. package/build/components/block-settings-menu-controls/index.js.map +1 -1
  14. package/build/components/block-styles/index.js +2 -1
  15. package/build/components/block-styles/index.js.map +1 -1
  16. package/build/components/block-switcher/block-transformations-menu.native.js +1 -0
  17. package/build/components/block-switcher/block-transformations-menu.native.js.map +1 -1
  18. package/build/components/child-layout-control/index.js +107 -0
  19. package/build/components/child-layout-control/index.js.map +1 -0
  20. package/build/components/convert-to-group-buttons/use-convert-to-group-button-props.js +6 -3
  21. package/build/components/convert-to-group-buttons/use-convert-to-group-button-props.js.map +1 -1
  22. package/build/components/date-format-picker/index.js +3 -3
  23. package/build/components/date-format-picker/index.js.map +1 -1
  24. package/build/components/global-styles/border-panel.js +306 -0
  25. package/build/components/global-styles/border-panel.js.map +1 -0
  26. package/build/components/global-styles/dimensions-panel.js +594 -0
  27. package/build/components/global-styles/dimensions-panel.js.map +1 -0
  28. package/build/components/global-styles/hooks.js +127 -37
  29. package/build/components/global-styles/hooks.js.map +1 -1
  30. package/build/components/global-styles/index.js +36 -2
  31. package/build/components/global-styles/index.js.map +1 -1
  32. package/build/components/global-styles/typography-panel.js +87 -27
  33. package/build/components/global-styles/typography-panel.js.map +1 -1
  34. package/build/components/global-styles/use-global-styles-output.js +21 -14
  35. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  36. package/build/components/global-styles/utils.js +2 -0
  37. package/build/components/global-styles/utils.js.map +1 -1
  38. package/build/components/index.native.js +23 -0
  39. package/build/components/index.native.js.map +1 -1
  40. package/build/components/inserter/index.js +29 -17
  41. package/build/components/inserter/index.js.map +1 -1
  42. package/build/components/inserter/media-tab/hooks.js +10 -11
  43. package/build/components/inserter/media-tab/hooks.js.map +1 -1
  44. package/build/components/inserter/media-tab/media-list.js +5 -108
  45. package/build/components/inserter/media-tab/media-list.js.map +1 -1
  46. package/build/components/inserter/media-tab/media-preview.js +242 -0
  47. package/build/components/inserter/media-tab/media-preview.js.map +1 -0
  48. package/build/components/inserter/menu.js +1 -1
  49. package/build/components/inserter/menu.js.map +1 -1
  50. package/build/components/inserter/quick-inserter.js +4 -2
  51. package/build/components/inserter/quick-inserter.js.map +1 -1
  52. package/build/components/inserter/search-results.js +10 -3
  53. package/build/components/inserter/search-results.js.map +1 -1
  54. package/build/components/inserter/tabs.js +1 -1
  55. package/build/components/inserter/tabs.js.map +1 -1
  56. package/build/components/inspector-controls/block-support-tools-panel.js +1 -1
  57. package/build/components/inspector-controls/block-support-tools-panel.js.map +1 -1
  58. package/build/components/inspector-controls/fill.js +38 -9
  59. package/build/components/inspector-controls/fill.js.map +1 -1
  60. package/build/components/link-control/index.js +1 -1
  61. package/build/components/link-control/index.js.map +1 -1
  62. package/build/components/link-control/search-item.js +5 -2
  63. package/build/components/link-control/search-item.js.map +1 -1
  64. package/build/components/link-control/settings-drawer.js +1 -1
  65. package/build/components/link-control/settings-drawer.js.map +1 -1
  66. package/build/components/link-control/settings.js +1 -0
  67. package/build/components/link-control/settings.js.map +1 -1
  68. package/build/components/list-view/block.js +17 -3
  69. package/build/components/list-view/block.js.map +1 -1
  70. package/build/components/list-view/branch.js +2 -2
  71. package/build/components/list-view/branch.js.map +1 -1
  72. package/build/components/list-view/expander.js +2 -1
  73. package/build/components/list-view/expander.js.map +1 -1
  74. package/build/components/list-view/leaf.js +10 -6
  75. package/build/components/list-view/leaf.js.map +1 -1
  76. package/build/components/list-view/use-block-selection.js +1 -2
  77. package/build/components/list-view/use-block-selection.js.map +1 -1
  78. package/build/components/list-view/use-list-view-scroll-into-view.js +51 -0
  79. package/build/components/list-view/use-list-view-scroll-into-view.js.map +1 -0
  80. package/build/components/off-canvas-editor/appender.js +33 -13
  81. package/build/components/off-canvas-editor/appender.js.map +1 -1
  82. package/build/components/off-canvas-editor/branch.js +6 -3
  83. package/build/components/off-canvas-editor/branch.js.map +1 -1
  84. package/build/components/off-canvas-editor/index.js +8 -2
  85. package/build/components/off-canvas-editor/index.js.map +1 -1
  86. package/build/components/off-canvas-editor/leaf-more-menu.js +34 -4
  87. package/build/components/off-canvas-editor/leaf-more-menu.js.map +1 -1
  88. package/build/components/provider/use-block-sync.js +17 -3
  89. package/build/components/provider/use-block-sync.js.map +1 -1
  90. package/build/components/responsive-block-control/index.js +1 -0
  91. package/build/components/responsive-block-control/index.js.map +1 -1
  92. package/build/components/rich-text/format-toolbar-container.js +0 -3
  93. package/build/components/rich-text/format-toolbar-container.js.map +1 -1
  94. package/build/components/rich-text/index.js +9 -43
  95. package/build/components/rich-text/index.js.map +1 -1
  96. package/build/components/rich-text/use-delete.js +73 -0
  97. package/build/components/rich-text/use-delete.js.map +1 -0
  98. package/build/components/rich-text/use-input-rules.js +14 -6
  99. package/build/components/rich-text/use-input-rules.js.map +1 -1
  100. package/build/components/writing-flow/use-selection-observer.js +4 -1
  101. package/build/components/writing-flow/use-selection-observer.js.map +1 -1
  102. package/build/hooks/align.js +3 -1
  103. package/build/hooks/align.js.map +1 -1
  104. package/build/hooks/border.js +91 -240
  105. package/build/hooks/border.js.map +1 -1
  106. package/build/hooks/custom-class-name.js +4 -4
  107. package/build/hooks/custom-class-name.js.map +1 -1
  108. package/build/hooks/custom-class-name.native.js +3 -4
  109. package/build/hooks/custom-class-name.native.js.map +1 -1
  110. package/build/hooks/dimensions.js +72 -190
  111. package/build/hooks/dimensions.js.map +1 -1
  112. package/build/hooks/duotone.js +94 -25
  113. package/build/hooks/duotone.js.map +1 -1
  114. package/build/hooks/gap.js +0 -202
  115. package/build/hooks/gap.js.map +1 -1
  116. package/build/hooks/layout.js +33 -27
  117. package/build/hooks/layout.js.map +1 -1
  118. package/build/hooks/margin.js +7 -163
  119. package/build/hooks/margin.js.map +1 -1
  120. package/build/hooks/padding.js +7 -163
  121. package/build/hooks/padding.js.map +1 -1
  122. package/build/hooks/supports.js +7 -1
  123. package/build/hooks/supports.js.map +1 -1
  124. package/build/hooks/typography.js +52 -66
  125. package/build/hooks/typography.js.map +1 -1
  126. package/build/hooks/utils.js +101 -0
  127. package/build/hooks/utils.js.map +1 -1
  128. package/build/layouts/constrained.js +6 -2
  129. package/build/layouts/constrained.js.map +1 -1
  130. package/build/layouts/flex.js +1 -0
  131. package/build/layouts/flex.js.map +1 -1
  132. package/build/private-apis.js +4 -1
  133. package/build/private-apis.js.map +1 -1
  134. package/build/store/actions.js +28 -14
  135. package/build/store/actions.js.map +1 -1
  136. package/build/store/defaults.js +28 -1
  137. package/build/store/defaults.js.map +1 -1
  138. package/build/store/reducer.js +53 -47
  139. package/build/store/reducer.js.map +1 -1
  140. package/build/store/selectors.js +24 -4
  141. package/build/store/selectors.js.map +1 -1
  142. package/build/utils/parse-css-unit-to-px.js +49 -10
  143. package/build/utils/parse-css-unit-to-px.js.map +1 -1
  144. package/build-module/components/block-inspector/index.js +9 -9
  145. package/build-module/components/block-inspector/index.js.map +1 -1
  146. package/build-module/components/block-inspector/useBlockInspectorAnimationSettings.js +37 -0
  147. package/build-module/components/block-inspector/useBlockInspectorAnimationSettings.js.map +1 -0
  148. package/build-module/components/block-list/block-invalid-warning.js +66 -78
  149. package/build-module/components/block-list/block-invalid-warning.js.map +1 -1
  150. package/build-module/components/block-lock/modal.js +1 -0
  151. package/build-module/components/block-lock/modal.js.map +1 -1
  152. package/build-module/components/block-settings-menu/block-settings-dropdown.js +2 -2
  153. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  154. package/build-module/components/block-settings-menu-controls/index.js +1 -1
  155. package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
  156. package/build-module/components/block-styles/index.js +2 -1
  157. package/build-module/components/block-styles/index.js.map +1 -1
  158. package/build-module/components/block-switcher/block-transformations-menu.native.js +1 -0
  159. package/build-module/components/block-switcher/block-transformations-menu.native.js.map +1 -1
  160. package/build-module/components/child-layout-control/index.js +98 -0
  161. package/build-module/components/child-layout-control/index.js.map +1 -0
  162. package/build-module/components/convert-to-group-buttons/use-convert-to-group-button-props.js +6 -3
  163. package/build-module/components/convert-to-group-buttons/use-convert-to-group-button-props.js.map +1 -1
  164. package/build-module/components/date-format-picker/index.js +4 -4
  165. package/build-module/components/date-format-picker/index.js.map +1 -1
  166. package/build-module/components/global-styles/border-panel.js +291 -0
  167. package/build-module/components/global-styles/border-panel.js.map +1 -0
  168. package/build-module/components/global-styles/dimensions-panel.js +574 -0
  169. package/build-module/components/global-styles/dimensions-panel.js.map +1 -0
  170. package/build-module/components/global-styles/hooks.js +123 -34
  171. package/build-module/components/global-styles/hooks.js.map +1 -1
  172. package/build-module/components/global-styles/index.js +3 -1
  173. package/build-module/components/global-styles/index.js.map +1 -1
  174. package/build-module/components/global-styles/typography-panel.js +88 -27
  175. package/build-module/components/global-styles/typography-panel.js.map +1 -1
  176. package/build-module/components/global-styles/use-global-styles-output.js +21 -14
  177. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  178. package/build-module/components/global-styles/utils.js +2 -0
  179. package/build-module/components/global-styles/utils.js.map +1 -1
  180. package/build-module/components/index.native.js +2 -1
  181. package/build-module/components/index.native.js.map +1 -1
  182. package/build-module/components/inserter/index.js +28 -16
  183. package/build-module/components/inserter/index.js.map +1 -1
  184. package/build-module/components/inserter/media-tab/hooks.js +10 -11
  185. package/build-module/components/inserter/media-tab/hooks.js.map +1 -1
  186. package/build-module/components/inserter/media-tab/media-list.js +6 -105
  187. package/build-module/components/inserter/media-tab/media-list.js.map +1 -1
  188. package/build-module/components/inserter/media-tab/media-preview.js +222 -0
  189. package/build-module/components/inserter/media-tab/media-preview.js.map +1 -0
  190. package/build-module/components/inserter/menu.js +1 -1
  191. package/build-module/components/inserter/menu.js.map +1 -1
  192. package/build-module/components/inserter/quick-inserter.js +4 -2
  193. package/build-module/components/inserter/quick-inserter.js.map +1 -1
  194. package/build-module/components/inserter/search-results.js +10 -3
  195. package/build-module/components/inserter/search-results.js.map +1 -1
  196. package/build-module/components/inserter/tabs.js +1 -1
  197. package/build-module/components/inserter/tabs.js.map +1 -1
  198. package/build-module/components/inspector-controls/block-support-tools-panel.js +1 -1
  199. package/build-module/components/inspector-controls/block-support-tools-panel.js.map +1 -1
  200. package/build-module/components/inspector-controls/fill.js +39 -9
  201. package/build-module/components/inspector-controls/fill.js.map +1 -1
  202. package/build-module/components/link-control/index.js +1 -1
  203. package/build-module/components/link-control/index.js.map +1 -1
  204. package/build-module/components/link-control/search-item.js +4 -2
  205. package/build-module/components/link-control/search-item.js.map +1 -1
  206. package/build-module/components/link-control/settings-drawer.js +1 -1
  207. package/build-module/components/link-control/settings-drawer.js.map +1 -1
  208. package/build-module/components/link-control/settings.js +1 -0
  209. package/build-module/components/link-control/settings.js.map +1 -1
  210. package/build-module/components/list-view/block.js +16 -3
  211. package/build-module/components/list-view/block.js.map +1 -1
  212. package/build-module/components/list-view/branch.js +2 -2
  213. package/build-module/components/list-view/branch.js.map +1 -1
  214. package/build-module/components/list-view/expander.js +2 -1
  215. package/build-module/components/list-view/expander.js.map +1 -1
  216. package/build-module/components/list-view/leaf.js +8 -4
  217. package/build-module/components/list-view/leaf.js.map +1 -1
  218. package/build-module/components/list-view/use-block-selection.js +1 -2
  219. package/build-module/components/list-view/use-block-selection.js.map +1 -1
  220. package/build-module/components/list-view/use-list-view-scroll-into-view.js +42 -0
  221. package/build-module/components/list-view/use-list-view-scroll-into-view.js.map +1 -0
  222. package/build-module/components/off-canvas-editor/appender.js +33 -14
  223. package/build-module/components/off-canvas-editor/appender.js.map +1 -1
  224. package/build-module/components/off-canvas-editor/branch.js +6 -3
  225. package/build-module/components/off-canvas-editor/branch.js.map +1 -1
  226. package/build-module/components/off-canvas-editor/index.js +8 -2
  227. package/build-module/components/off-canvas-editor/index.js.map +1 -1
  228. package/build-module/components/off-canvas-editor/leaf-more-menu.js +36 -7
  229. package/build-module/components/off-canvas-editor/leaf-more-menu.js.map +1 -1
  230. package/build-module/components/provider/use-block-sync.js +17 -3
  231. package/build-module/components/provider/use-block-sync.js.map +1 -1
  232. package/build-module/components/responsive-block-control/index.js +1 -0
  233. package/build-module/components/responsive-block-control/index.js.map +1 -1
  234. package/build-module/components/rich-text/format-toolbar-container.js +0 -3
  235. package/build-module/components/rich-text/format-toolbar-container.js.map +1 -1
  236. package/build-module/components/rich-text/index.js +9 -43
  237. package/build-module/components/rich-text/index.js.map +1 -1
  238. package/build-module/components/rich-text/use-delete.js +62 -0
  239. package/build-module/components/rich-text/use-delete.js.map +1 -0
  240. package/build-module/components/rich-text/use-input-rules.js +14 -6
  241. package/build-module/components/rich-text/use-input-rules.js.map +1 -1
  242. package/build-module/components/writing-flow/use-selection-observer.js +4 -1
  243. package/build-module/components/writing-flow/use-selection-observer.js.map +1 -1
  244. package/build-module/hooks/align.js +3 -1
  245. package/build-module/hooks/align.js.map +1 -1
  246. package/build-module/hooks/border.js +93 -240
  247. package/build-module/hooks/border.js.map +1 -1
  248. package/build-module/hooks/custom-class-name.js +4 -4
  249. package/build-module/hooks/custom-class-name.js.map +1 -1
  250. package/build-module/hooks/custom-class-name.native.js +3 -4
  251. package/build-module/hooks/custom-class-name.native.js.map +1 -1
  252. package/build-module/hooks/dimensions.js +75 -187
  253. package/build-module/hooks/dimensions.js.map +1 -1
  254. package/build-module/hooks/duotone.js +86 -24
  255. package/build-module/hooks/duotone.js.map +1 -1
  256. package/build-module/hooks/gap.js +0 -183
  257. package/build-module/hooks/gap.js.map +1 -1
  258. package/build-module/hooks/layout.js +33 -27
  259. package/build-module/hooks/layout.js.map +1 -1
  260. package/build-module/hooks/margin.js +4 -143
  261. package/build-module/hooks/margin.js.map +1 -1
  262. package/build-module/hooks/padding.js +4 -143
  263. package/build-module/hooks/padding.js.map +1 -1
  264. package/build-module/hooks/supports.js +7 -1
  265. package/build-module/hooks/supports.js.map +1 -1
  266. package/build-module/hooks/typography.js +54 -66
  267. package/build-module/hooks/typography.js.map +1 -1
  268. package/build-module/hooks/utils.js +96 -0
  269. package/build-module/hooks/utils.js.map +1 -1
  270. package/build-module/layouts/constrained.js +6 -2
  271. package/build-module/layouts/constrained.js.map +1 -1
  272. package/build-module/layouts/flex.js +1 -0
  273. package/build-module/layouts/flex.js.map +1 -1
  274. package/build-module/private-apis.js +3 -1
  275. package/build-module/private-apis.js.map +1 -1
  276. package/build-module/store/actions.js +28 -14
  277. package/build-module/store/actions.js.map +1 -1
  278. package/build-module/store/defaults.js +28 -1
  279. package/build-module/store/defaults.js.map +1 -1
  280. package/build-module/store/reducer.js +53 -45
  281. package/build-module/store/reducer.js.map +1 -1
  282. package/build-module/store/selectors.js +22 -4
  283. package/build-module/store/selectors.js.map +1 -1
  284. package/build-module/utils/parse-css-unit-to-px.js +49 -10
  285. package/build-module/utils/parse-css-unit-to-px.js.map +1 -1
  286. package/build-style/style-rtl.css +39 -27
  287. package/build-style/style.css +39 -27
  288. package/package.json +31 -31
  289. package/src/components/block-draggable/test/__snapshots__/index.native.js.snap +24 -24
  290. package/src/components/block-inspector/index.js +11 -14
  291. package/src/components/block-inspector/style.scss +3 -0
  292. package/src/components/block-inspector/useBlockInspectorAnimationSettings.js +53 -0
  293. package/src/components/block-list/block-invalid-warning.js +72 -64
  294. package/src/components/block-lock/modal.js +1 -0
  295. package/src/components/block-lock/style.scss +0 -9
  296. package/src/components/block-mobile-toolbar/test/__snapshots__/block-actions-menu.native.js.snap +20 -20
  297. package/src/components/block-mover/test/__snapshots__/index.native.js.snap +35 -17
  298. package/src/components/block-preview/test/index.js +0 -2
  299. package/src/components/block-settings-menu/block-settings-dropdown.js +4 -1
  300. package/src/components/block-settings-menu-controls/index.js +2 -1
  301. package/src/components/block-styles/index.js +5 -1
  302. package/src/components/block-styles/style.scss +2 -2
  303. package/src/components/block-switcher/block-transformations-menu.native.js +1 -0
  304. package/src/components/child-layout-control/index.js +106 -0
  305. package/src/components/color-palette/test/__snapshots__/control.js.snap +17 -15
  306. package/src/components/convert-to-group-buttons/use-convert-to-group-button-props.js +48 -38
  307. package/src/components/date-format-picker/index.js +6 -8
  308. package/src/components/date-format-picker/style.scss +0 -5
  309. package/src/components/global-styles/border-panel.js +285 -0
  310. package/src/components/global-styles/dimensions-panel.js +627 -0
  311. package/src/components/global-styles/hooks.js +160 -44
  312. package/src/components/global-styles/index.js +7 -1
  313. package/src/components/global-styles/test/use-global-styles-output.js +1 -1
  314. package/src/components/global-styles/typography-panel.js +81 -9
  315. package/src/components/global-styles/use-global-styles-output.js +17 -16
  316. package/src/components/global-styles/utils.js +2 -0
  317. package/src/components/index.native.js +5 -0
  318. package/src/components/inner-blocks/test/__snapshots__/index.js.snap +1 -1
  319. package/src/components/inserter/index.js +30 -11
  320. package/src/components/inserter/media-tab/hooks.js +9 -8
  321. package/src/components/inserter/media-tab/media-list.js +3 -122
  322. package/src/components/inserter/media-tab/media-preview.js +268 -0
  323. package/src/components/inserter/menu.js +0 -1
  324. package/src/components/inserter/quick-inserter.js +2 -0
  325. package/src/components/inserter/search-results.js +7 -1
  326. package/src/components/inserter/style.scss +25 -0
  327. package/src/components/inserter/tabs.js +1 -9
  328. package/src/components/inserter/test/__snapshots__/index.native.js.snap +15 -15
  329. package/src/components/inspector-controls/block-support-tools-panel.js +0 -1
  330. package/src/components/inspector-controls/fill.js +32 -8
  331. package/src/components/link-control/index.js +1 -1
  332. package/src/components/link-control/search-item.js +3 -1
  333. package/src/components/link-control/settings-drawer.js +2 -1
  334. package/src/components/link-control/settings.js +1 -0
  335. package/src/components/link-control/style.scss +18 -12
  336. package/src/components/link-control/test/index.js +3 -5
  337. package/src/components/list-view/block.js +19 -1
  338. package/src/components/list-view/branch.js +1 -2
  339. package/src/components/list-view/expander.js +1 -0
  340. package/src/components/list-view/leaf.js +43 -29
  341. package/src/components/list-view/use-block-selection.js +0 -2
  342. package/src/components/list-view/use-list-view-scroll-into-view.js +48 -0
  343. package/src/components/media-replace-flow/style.scss +7 -9
  344. package/src/components/off-canvas-editor/appender.js +44 -21
  345. package/src/components/off-canvas-editor/branch.js +4 -1
  346. package/src/components/off-canvas-editor/index.js +7 -1
  347. package/src/components/off-canvas-editor/leaf-more-menu.js +57 -15
  348. package/src/components/provider/use-block-sync.js +21 -4
  349. package/src/components/responsive-block-control/index.js +1 -0
  350. package/src/components/rich-text/format-toolbar-container.js +1 -7
  351. package/src/components/rich-text/index.js +8 -44
  352. package/src/components/rich-text/use-delete.js +59 -0
  353. package/src/components/rich-text/use-input-rules.js +13 -5
  354. package/src/components/spacing-sizes-control/style.scss +1 -1
  355. package/src/components/url-popover/stories/index.js +1 -0
  356. package/src/components/url-popover/test/index.js +0 -2
  357. package/src/components/writing-flow/use-selection-observer.js +5 -1
  358. package/src/hooks/align.js +1 -1
  359. package/src/hooks/border.js +94 -225
  360. package/src/hooks/custom-class-name.js +4 -4
  361. package/src/hooks/custom-class-name.native.js +3 -4
  362. package/src/hooks/dimensions.js +85 -269
  363. package/src/hooks/duotone.js +100 -30
  364. package/src/hooks/gap.js +0 -208
  365. package/src/hooks/layout.js +38 -22
  366. package/src/hooks/margin.js +1 -164
  367. package/src/hooks/padding.js +1 -163
  368. package/src/hooks/supports.js +6 -0
  369. package/src/hooks/test/__snapshots__/align.native.js.snap +24 -24
  370. package/src/hooks/test/duotone.js +102 -0
  371. package/src/hooks/test/style.js +2 -1
  372. package/src/hooks/test/use-typography-props.js +2 -0
  373. package/src/hooks/typography.js +68 -88
  374. package/src/hooks/utils.js +126 -0
  375. package/src/layouts/constrained.js +23 -17
  376. package/src/layouts/flex.js +1 -0
  377. package/src/private-apis.js +2 -0
  378. package/src/store/actions.js +16 -6
  379. package/src/store/defaults.js +14 -1
  380. package/src/store/reducer.js +68 -43
  381. package/src/store/selectors.js +28 -4
  382. package/src/store/test/actions.js +4 -2
  383. package/src/utils/parse-css-unit-to-px.js +48 -13
  384. package/src/utils/test/parse-css-unit-to-px.js +13 -2
  385. package/tsconfig.tsbuildinfo +1 -1
  386. package/build/hooks/border-radius.js +0 -100
  387. package/build/hooks/border-radius.js.map +0 -1
  388. package/build/hooks/child-layout.js +0 -213
  389. package/build/hooks/child-layout.js.map +0 -1
  390. package/build/hooks/min-height.js +0 -139
  391. package/build/hooks/min-height.js.map +0 -1
  392. package/build-module/hooks/border-radius.js +0 -84
  393. package/build-module/hooks/border-radius.js.map +0 -1
  394. package/build-module/hooks/child-layout.js +0 -193
  395. package/build-module/hooks/child-layout.js.map +0 -1
  396. package/build-module/hooks/min-height.js +0 -116
  397. package/build-module/hooks/min-height.js.map +0 -1
  398. package/src/hooks/border-radius.js +0 -70
  399. package/src/hooks/child-layout.js +0 -195
  400. package/src/hooks/min-height.js +0 -104
@@ -7,66 +7,29 @@ import classnames from 'classnames';
7
7
  * WordPress dependencies
8
8
  */
9
9
  import { getBlockSupport } from '@wordpress/blocks';
10
- import {
11
- __experimentalBorderBoxControl as BorderBoxControl,
12
- __experimentalHasSplitBorders as hasSplitBorders,
13
- __experimentalIsDefinedBorder as isDefinedBorder,
14
- __experimentalToolsPanelItem as ToolsPanelItem,
15
- } from '@wordpress/components';
10
+ import { __experimentalHasSplitBorders as hasSplitBorders } from '@wordpress/components';
16
11
  import { createHigherOrderComponent } from '@wordpress/compose';
17
- import { Platform } from '@wordpress/element';
12
+ import { Platform, useCallback, useMemo } from '@wordpress/element';
18
13
  import { addFilter } from '@wordpress/hooks';
19
- import { __ } from '@wordpress/i18n';
20
14
 
21
15
  /**
22
16
  * Internal dependencies
23
17
  */
24
- import {
25
- BorderRadiusEdit,
26
- hasBorderRadiusValue,
27
- resetBorderRadius,
28
- } from './border-radius';
29
18
  import { getColorClassName } from '../components/colors';
30
19
  import InspectorControls from '../components/inspector-controls';
31
20
  import useMultipleOriginColorsAndGradients from '../components/colors-gradients/use-multiple-origin-colors-and-gradients';
32
- import useSetting from '../components/use-setting';
33
- import { cleanEmptyObject, shouldSkipSerialization } from './utils';
21
+ import {
22
+ cleanEmptyObject,
23
+ shouldSkipSerialization,
24
+ useBlockSettings,
25
+ } from './utils';
26
+ import {
27
+ useHasBorderPanel,
28
+ BorderPanel as StylesBorderPanel,
29
+ } from '../components/global-styles';
34
30
 
35
31
  export const BORDER_SUPPORT_KEY = '__experimentalBorder';
36
32
 
37
- const borderSides = [ 'top', 'right', 'bottom', 'left' ];
38
-
39
- const hasBorderValue = ( props ) => {
40
- const { borderColor, style } = props.attributes;
41
- return isDefinedBorder( style?.border ) || !! borderColor;
42
- };
43
-
44
- // The border color, style, and width are omitted so they get undefined. The
45
- // border radius is separate and must retain its selection.
46
- const resetBorder = ( { attributes = {}, setAttributes } ) => {
47
- const { style } = attributes;
48
- setAttributes( {
49
- borderColor: undefined,
50
- style: {
51
- ...style,
52
- border: cleanEmptyObject( {
53
- radius: style?.border?.radius,
54
- } ),
55
- },
56
- } );
57
- };
58
-
59
- const resetBorderFilter = ( newAttributes ) => ( {
60
- ...newAttributes,
61
- borderColor: undefined,
62
- style: {
63
- ...newAttributes.style,
64
- border: {
65
- radius: newAttributes.style?.border?.radius,
66
- },
67
- },
68
- } );
69
-
70
33
  const getColorByProperty = ( colors, property, value ) => {
71
34
  let matchedColor;
72
35
 
@@ -103,51 +66,6 @@ export const getMultiOriginColor = ( { colors, namedColor, customColor } ) => {
103
66
  return colorObject ? colorObject : { color: customColor };
104
67
  };
105
68
 
106
- const getBorderObject = ( attributes, colors ) => {
107
- const { borderColor, style } = attributes;
108
- const { border: borderStyles } = style || {};
109
-
110
- // If we have a named color for a flat border. Fetch that color object and
111
- // apply that color's value to the color property within the style object.
112
- if ( borderColor ) {
113
- const { color } = getMultiOriginColor( {
114
- colors,
115
- namedColor: borderColor,
116
- } );
117
-
118
- return color ? { ...borderStyles, color } : borderStyles;
119
- }
120
-
121
- // Individual side border color slugs are stored within the border style
122
- // object. If we don't have a border styles object we have nothing further
123
- // to hydrate.
124
- if ( ! borderStyles ) {
125
- return borderStyles;
126
- }
127
-
128
- // If we have named colors for the individual side borders, retrieve their
129
- // related color objects and apply the real color values to the split
130
- // border objects.
131
- const hydratedBorderStyles = { ...borderStyles };
132
- borderSides.forEach( ( side ) => {
133
- const colorSlug = getColorSlugFromVariable(
134
- hydratedBorderStyles[ side ]?.color
135
- );
136
- if ( colorSlug ) {
137
- const { color } = getMultiOriginColor( {
138
- colors,
139
- namedColor: colorSlug,
140
- } );
141
- hydratedBorderStyles[ side ] = {
142
- ...hydratedBorderStyles[ side ],
143
- color,
144
- };
145
- }
146
- } );
147
-
148
- return hydratedBorderStyles;
149
- };
150
-
151
69
  function getColorSlugFromVariable( value ) {
152
70
  const namedColor = /var:preset\|color\|(.+)/.exec( value );
153
71
  if ( namedColor && namedColor[ 1 ] ) {
@@ -156,150 +74,101 @@ function getColorSlugFromVariable( value ) {
156
74
  return null;
157
75
  }
158
76
 
159
- export function BorderPanel( props ) {
160
- const { attributes, clientId, setAttributes } = props;
161
- const { style } = attributes;
162
- const { colors } = useMultipleOriginColorsAndGradients();
163
-
164
- const isSupported = hasBorderSupport( props.name );
165
- const isColorSupported =
166
- useSetting( 'border.color' ) && hasBorderSupport( props.name, 'color' );
167
- const isRadiusSupported =
168
- useSetting( 'border.radius' ) &&
169
- hasBorderSupport( props.name, 'radius' );
170
- const isStyleSupported =
171
- useSetting( 'border.style' ) && hasBorderSupport( props.name, 'style' );
172
- const isWidthSupported =
173
- useSetting( 'border.width' ) && hasBorderSupport( props.name, 'width' );
174
-
175
- const isDisabled = [
176
- ! isColorSupported,
177
- ! isRadiusSupported,
178
- ! isStyleSupported,
179
- ! isWidthSupported,
180
- ].every( Boolean );
181
-
182
- if ( isDisabled || ! isSupported ) {
183
- return null;
77
+ function styleToAttributes( style ) {
78
+ if ( hasSplitBorders( style?.border ) ) {
79
+ return {
80
+ style,
81
+ borderColor: undefined,
82
+ };
184
83
  }
185
84
 
186
- const defaultBorderControls = getBlockSupport( props.name, [
187
- BORDER_SUPPORT_KEY,
188
- '__experimentalDefaultControls',
189
- ] );
85
+ const borderColorValue = style?.border?.color;
86
+ const borderColorSlug = borderColorValue?.startsWith( 'var:preset|color|' )
87
+ ? borderColorSlug.substring( 'var:preset|color|'.length )
88
+ : undefined;
89
+ const updatedStyle = { ...style };
90
+ updatedStyle.border = {
91
+ ...updatedStyle.border,
92
+ color: borderColorSlug ? undefined : borderColorValue,
93
+ };
94
+ return {
95
+ style: cleanEmptyObject( updatedStyle ),
96
+ borderColor: borderColorSlug,
97
+ };
98
+ }
190
99
 
191
- const showBorderByDefault =
192
- defaultBorderControls?.color || defaultBorderControls?.width;
193
-
194
- const onBorderChange = ( newBorder ) => {
195
- // Filter out named colors and apply them to appropriate block
196
- // attributes so that CSS classes can be used to apply those colors.
197
- // e.g. has-primary-border-top-color.
198
-
199
- let newBorderStyles = { ...newBorder };
200
- let newBorderColor;
201
-
202
- if ( hasSplitBorders( newBorder ) ) {
203
- // For each side check if the side has a color value set
204
- // If so, determine if it belongs to a named color, in which case
205
- // we update the color property.
206
- //
207
- // This deliberately overwrites `newBorderStyles` to avoid mutating
208
- // the passed object which causes problems otherwise.
209
- newBorderStyles = {
210
- top: { ...newBorder.top },
211
- right: { ...newBorder.right },
212
- bottom: { ...newBorder.bottom },
213
- left: { ...newBorder.left },
100
+ function attributesToStyle( attributes ) {
101
+ if ( hasSplitBorders( attributes.style?.border ) ) {
102
+ return attributes.style;
103
+ }
104
+ return {
105
+ ...attributes.style,
106
+ border: {
107
+ ...attributes.style?.border,
108
+ color: attributes.borderColor
109
+ ? 'var:preset|color|' + attributes.borderColor
110
+ : attributes.style?.border?.color,
111
+ },
112
+ };
113
+ }
114
+
115
+ function BordersInspectorControl( { children, resetAllFilter } ) {
116
+ const attributesResetAllFilter = useCallback(
117
+ ( attributes ) => {
118
+ const existingStyle = attributesToStyle( attributes );
119
+ const updatedStyle = resetAllFilter( existingStyle );
120
+ return {
121
+ ...attributes,
122
+ ...styleToAttributes( updatedStyle ),
214
123
  };
124
+ },
125
+ [ resetAllFilter ]
126
+ );
215
127
 
216
- borderSides.forEach( ( side ) => {
217
- if ( newBorder[ side ]?.color ) {
218
- const colorObject = getMultiOriginColor( {
219
- colors,
220
- customColor: newBorder[ side ]?.color,
221
- } );
222
-
223
- if ( colorObject.slug ) {
224
- newBorderStyles[
225
- side
226
- ].color = `var:preset|color|${ colorObject.slug }`;
227
- }
228
- }
229
- } );
230
- } else if ( newBorder?.color ) {
231
- // We have a flat border configuration. Apply named color slug to
232
- // `borderColor` attribute and clear color style property if found.
233
- const customColor = newBorder?.color;
234
- const colorObject = getMultiOriginColor( { colors, customColor } );
235
-
236
- if ( colorObject.slug ) {
237
- newBorderColor = colorObject.slug;
238
- newBorderStyles.color = undefined;
239
- }
240
- }
128
+ return (
129
+ <InspectorControls
130
+ group="border"
131
+ resetAllFilter={ attributesResetAllFilter }
132
+ >
133
+ { children }
134
+ </InspectorControls>
135
+ );
136
+ }
241
137
 
242
- // Ensure previous border radius styles are maintained and clean
243
- // overall result for empty objects or properties.
244
- const newStyle = cleanEmptyObject( {
245
- ...style,
246
- border: { radius: style?.border?.radius, ...newBorderStyles },
138
+ export function BorderPanel( props ) {
139
+ const { clientId, name, attributes, setAttributes } = props;
140
+ const settings = useBlockSettings( name );
141
+ const isEnabled = useHasBorderPanel( settings );
142
+ const value = useMemo( () => {
143
+ return attributesToStyle( {
144
+ style: attributes.style,
145
+ borderColor: attributes.borderColor,
247
146
  } );
147
+ }, [ attributes.style, attributes.borderColor ] );
248
148
 
249
- setAttributes( {
250
- style: newStyle,
251
- borderColor: newBorderColor,
252
- } );
149
+ const onChange = ( newStyle ) => {
150
+ setAttributes( styleToAttributes( newStyle ) );
253
151
  };
254
152
 
255
- const hydratedBorder = getBorderObject( attributes, colors );
153
+ if ( ! isEnabled ) {
154
+ return null;
155
+ }
156
+
157
+ const defaultControls = getBlockSupport( props.name, [
158
+ BORDER_SUPPORT_KEY,
159
+ '__experimentalDefaultControls',
160
+ ] );
256
161
 
257
162
  return (
258
- <InspectorControls group="border">
259
- { ( isWidthSupported || isColorSupported ) && (
260
- <ToolsPanelItem
261
- hasValue={ () => hasBorderValue( props ) }
262
- label={ __( 'Border' ) }
263
- onDeselect={ () => resetBorder( props ) }
264
- isShownByDefault={ showBorderByDefault }
265
- resetAllFilter={ resetBorderFilter }
266
- panelId={ clientId }
267
- >
268
- <BorderBoxControl
269
- colors={ colors }
270
- enableAlpha={ true }
271
- enableStyle={ isStyleSupported }
272
- onChange={ onBorderChange }
273
- popoverOffset={ 40 }
274
- popoverPlacement="left-start"
275
- size="__unstable-large"
276
- value={ hydratedBorder }
277
- __experimentalIsRenderedInSidebar={ true }
278
- />
279
- </ToolsPanelItem>
280
- ) }
281
- { isRadiusSupported && (
282
- <ToolsPanelItem
283
- hasValue={ () => hasBorderRadiusValue( props ) }
284
- label={ __( 'Radius' ) }
285
- onDeselect={ () => resetBorderRadius( props ) }
286
- isShownByDefault={ defaultBorderControls?.radius }
287
- resetAllFilter={ ( newAttributes ) => ( {
288
- ...newAttributes,
289
- style: {
290
- ...newAttributes.style,
291
- border: {
292
- ...newAttributes.style?.border,
293
- radius: undefined,
294
- },
295
- },
296
- } ) }
297
- panelId={ clientId }
298
- >
299
- <BorderRadiusEdit { ...props } />
300
- </ToolsPanelItem>
301
- ) }
302
- </InspectorControls>
163
+ <StylesBorderPanel
164
+ as={ BordersInspectorControl }
165
+ panelId={ clientId }
166
+ name={ name }
167
+ settings={ settings }
168
+ value={ value }
169
+ onChange={ onChange }
170
+ defaultControls={ defaultControls }
171
+ />
303
172
  );
304
173
  }
305
174
 
@@ -18,8 +18,7 @@ import { createHigherOrderComponent } from '@wordpress/compose';
18
18
  import { InspectorControls } from '../components';
19
19
 
20
20
  /**
21
- * Filters registered block settings, extending attributes with anchor using ID
22
- * of the first node.
21
+ * Filters registered block settings, extending attributes to include `className`.
23
22
  *
24
23
  * @param {Object} settings Original block settings.
25
24
  *
@@ -42,6 +41,7 @@ export function addAttribute( settings ) {
42
41
  /**
43
42
  * Override the default edit UI to include a new block inspector control for
44
43
  * assigning the custom class name, if block supports custom class name.
44
+ * The control is displayed within the Advanced panel in the block inspector.
45
45
  *
46
46
  * @param {WPComponent} BlockEdit Original component.
47
47
  *
@@ -89,8 +89,8 @@ export const withInspectorControl = createHigherOrderComponent(
89
89
  );
90
90
 
91
91
  /**
92
- * Override props assigned to save component to inject anchor ID, if block
93
- * supports anchor. This is only applied if the block's save result is an
92
+ * Override props assigned to save component to inject the className, if block
93
+ * supports customClassName. This is only applied if the block's save result is an
94
94
  * element and not a markup string.
95
95
  *
96
96
  * @param {Object} extraProps Additional props applied to save element.
@@ -10,8 +10,7 @@ import { addFilter } from '@wordpress/hooks';
10
10
  import { hasBlockSupport } from '@wordpress/blocks';
11
11
 
12
12
  /**
13
- * Filters registered block settings, extending attributes with anchor using ID
14
- * of the first node.
13
+ * Filters registered block settings, extending attributes to include `className`.
15
14
  *
16
15
  * @param {Object} settings Original block settings.
17
16
  *
@@ -32,8 +31,8 @@ export function addAttribute( settings ) {
32
31
  }
33
32
 
34
33
  /**
35
- * Override props assigned to save component to inject anchor ID, if block
36
- * supports anchor. This is only applied if the block's save result is an
34
+ * Override props assigned to save component to inject the className, if block
35
+ * supports customClassName. This is only applied if the block's save result is an
37
36
  * element and not a markup string.
38
37
  *
39
38
  * @param {Object} extraProps Additional props applied to save element.