@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
@@ -10,6 +10,7 @@ import { get, set } from 'lodash';
10
10
  import { useContext, useCallback, useMemo } from '@wordpress/element';
11
11
  import { useSelect } from '@wordpress/data';
12
12
  import { store as blocksStore } from '@wordpress/blocks';
13
+ import { _x } from '@wordpress/i18n';
13
14
  /**
14
15
  * Internal dependencies
15
16
  */
@@ -21,7 +22,7 @@ const EMPTY_CONFIG = {
21
22
  settings: {},
22
23
  styles: {}
23
24
  };
24
- const VALID_SETTINGS = ['appearanceTools', 'useRootPaddingAwareAlignments', 'border.color', 'border.radius', 'border.style', 'border.width', 'shadow.presets', 'shadow.defaultPresets', 'color.background', 'color.custom', 'color.customDuotone', 'color.customGradient', 'color.defaultDuotone', 'color.defaultGradients', 'color.defaultPalette', 'color.duotone', 'color.gradients', 'color.link', 'color.palette', 'color.text', 'custom', 'dimensions.minHeight', 'layout.contentSize', 'layout.definitions', 'layout.wideSize', 'position.fixed', 'position.sticky', 'spacing.customSpacingSize', 'spacing.spacingSizes', 'spacing.spacingScale', 'spacing.blockGap', 'spacing.margin', 'spacing.padding', 'spacing.units', 'typography.fuild', 'typography.customFontSize', 'typography.dropCap', 'typography.fontFamilies', 'typography.fontSizes', 'typography.fontStyle', 'typography.fontWeight', 'typography.letterSpacing', 'typography.lineHeight', 'typography.textDecoration', 'typography.textTransform'];
25
+ const VALID_SETTINGS = ['appearanceTools', 'useRootPaddingAwareAlignments', 'border.color', 'border.radius', 'border.style', 'border.width', 'shadow.presets', 'shadow.defaultPresets', 'color.background', 'color.custom', 'color.customDuotone', 'color.customGradient', 'color.defaultDuotone', 'color.defaultGradients', 'color.defaultPalette', 'color.duotone', 'color.gradients', 'color.link', 'color.palette', 'color.text', 'custom', 'dimensions.minHeight', 'layout.contentSize', 'layout.definitions', 'layout.wideSize', 'position.fixed', 'position.sticky', 'spacing.customSpacingSize', 'spacing.spacingSizes', 'spacing.spacingScale', 'spacing.blockGap', 'spacing.margin', 'spacing.padding', 'spacing.units', 'typography.fluid', 'typography.customFontSize', 'typography.dropCap', 'typography.fontFamilies', 'typography.fontSizes', 'typography.fontStyle', 'typography.fontWeight', 'typography.letterSpacing', 'typography.lineHeight', 'typography.textColumns', 'typography.textDecoration', 'typography.textTransform'];
25
26
  export const useGlobalStylesReset = () => {
26
27
  const {
27
28
  user: config,
@@ -105,7 +106,7 @@ export function useGlobalStyle(path, blockName) {
105
106
 
106
107
  switch (source) {
107
108
  case 'all':
108
- rawResult = // The stlyes.css path is allowed to be empty, so don't revert to base if undefined.
109
+ rawResult = // The styles.css path is allowed to be empty, so don't revert to base if undefined.
109
110
  finalPath === 'styles.css' ? get(userConfig, finalPath) : get(mergedConfig, finalPath);
110
111
  result = shouldDecodeEncode ? getValueFromVariable(mergedConfig, blockName, rawResult) : rawResult;
111
112
  break;
@@ -126,50 +127,138 @@ export function useGlobalStyle(path, blockName) {
126
127
 
127
128
  return [result, setStyle];
128
129
  }
129
- export function useSupportedStyles(name, element) {
130
- const {
131
- supportedPanels
132
- } = useSelect(select => {
133
- return {
134
- supportedPanels: unlock(select(blocksStore)).getSupportedStyles(name, element)
135
- };
136
- }, [name, element]);
137
- return supportedPanels;
138
- }
139
130
  /**
140
- * Given a settings object and a list of supported panels,
141
- * returns a new settings object with the unsupported panels removed.
131
+ * React hook that overrides a global settings object with block and element specific settings.
142
132
  *
143
- * @param {Object} settings Settings object.
144
- * @param {string[]} supports Supported style panels.
133
+ * @param {Object} parentSettings Settings object.
134
+ * @param {blockName?} blockName Block name.
135
+ * @param {element?} element Element name.
145
136
  *
146
137
  * @return {Object} Merge of settings and supports.
147
138
  */
148
139
 
149
- export function overrideSettingsWithSupports(settings, supports) {
150
- const updatedSettings = { ...settings
151
- };
140
+ export function useSettingsForBlockElement(parentSettings, blockName, element) {
141
+ const {
142
+ supportedStyles,
143
+ supports
144
+ } = useSelect(select => {
145
+ var _select$getBlockType;
152
146
 
153
- if (!supports.includes('fontSize')) {
154
- updatedSettings.typography = { ...updatedSettings.typography,
155
- fontSizes: {},
156
- customFontSize: false
147
+ return {
148
+ supportedStyles: unlock(select(blocksStore)).getSupportedStyles(blockName, element),
149
+ supports: (_select$getBlockType = select(blocksStore).getBlockType(blockName)) === null || _select$getBlockType === void 0 ? void 0 : _select$getBlockType.supports
157
150
  };
158
- }
159
-
160
- if (!supports.includes('fontFamily')) {
161
- updatedSettings.typography = { ...updatedSettings.typography,
162
- fontFamilies: {}
151
+ }, [blockName, element]);
152
+ return useMemo(() => {
153
+ const updatedSettings = { ...parentSettings
163
154
  };
164
- }
165
155
 
166
- ['lineHeight', 'fontStyle', 'fontWeight', 'letterSpacing', 'textTransform'].forEach(key => {
167
- if (!supports.includes(key)) {
156
+ if (!supportedStyles.includes('fontSize')) {
168
157
  updatedSettings.typography = { ...updatedSettings.typography,
169
- [key]: false
158
+ fontSizes: {},
159
+ customFontSize: false
160
+ };
161
+ }
162
+
163
+ if (!supportedStyles.includes('fontFamily')) {
164
+ updatedSettings.typography = { ...updatedSettings.typography,
165
+ fontFamilies: {}
166
+ };
167
+ }
168
+
169
+ ['lineHeight', 'fontStyle', 'fontWeight', 'letterSpacing', 'textTransform', 'textDecoration'].forEach(key => {
170
+ if (!supportedStyles.includes(key)) {
171
+ updatedSettings.typography = { ...updatedSettings.typography,
172
+ [key]: false
173
+ };
174
+ }
175
+ }); // The column-count style is named text column to reduce confusion with
176
+ // the columns block and manage expectations from the support.
177
+ // See: https://github.com/WordPress/gutenberg/pull/33587
178
+
179
+ if (!supportedStyles.includes('columnCount')) {
180
+ updatedSettings.typography = { ...updatedSettings.typography,
181
+ textColumns: false
182
+ };
183
+ }
184
+
185
+ ['contentSize', 'wideSize'].forEach(key => {
186
+ if (!supportedStyles.includes(key)) {
187
+ updatedSettings.layout = { ...updatedSettings.layout,
188
+ [key]: false
189
+ };
190
+ }
191
+ });
192
+ ['padding', 'margin', 'blockGap'].forEach(key => {
193
+ var _supports$spacing, _supports$spacing2, _supports$spacing3, _supports$spacing3$ke;
194
+
195
+ if (!supportedStyles.includes(key)) {
196
+ updatedSettings.spacing = { ...updatedSettings.spacing,
197
+ [key]: false
198
+ };
199
+ }
200
+
201
+ const sides = Array.isArray(supports === null || supports === void 0 ? void 0 : (_supports$spacing = supports.spacing) === null || _supports$spacing === void 0 ? void 0 : _supports$spacing[key]) ? supports === null || supports === void 0 ? void 0 : (_supports$spacing2 = supports.spacing) === null || _supports$spacing2 === void 0 ? void 0 : _supports$spacing2[key] : supports === null || supports === void 0 ? void 0 : (_supports$spacing3 = supports.spacing) === null || _supports$spacing3 === void 0 ? void 0 : (_supports$spacing3$ke = _supports$spacing3[key]) === null || _supports$spacing3$ke === void 0 ? void 0 : _supports$spacing3$ke.sides;
202
+
203
+ if (sides !== null && sides !== void 0 && sides.length) {
204
+ var _updatedSettings$spac;
205
+
206
+ updatedSettings.spacing = { ...updatedSettings.spacing,
207
+ [key]: { ...((_updatedSettings$spac = updatedSettings.spacing) === null || _updatedSettings$spac === void 0 ? void 0 : _updatedSettings$spac[key]),
208
+ sides
209
+ }
210
+ };
211
+ }
212
+ });
213
+
214
+ if (!supportedStyles.includes('minHeight')) {
215
+ updatedSettings.dimensions = { ...updatedSettings.dimensions,
216
+ minHeight: false
170
217
  };
171
218
  }
172
- });
173
- return updatedSettings;
219
+
220
+ ['radius', 'color', 'style', 'width'].forEach(key => {
221
+ if (!supportedStyles.includes('border' + key.charAt(0).toUpperCase() + key.slice(1))) {
222
+ updatedSettings.border = { ...updatedSettings.border,
223
+ [key]: false
224
+ };
225
+ }
226
+ });
227
+ return updatedSettings;
228
+ }, [parentSettings, supportedStyles, supports]);
229
+ }
230
+ export function useColorsPerOrigin(settings) {
231
+ var _settings$color, _settings$color$palet, _settings$color2, _settings$color2$pale, _settings$color3, _settings$color3$pale, _settings$color4;
232
+
233
+ const customColors = settings === null || settings === void 0 ? void 0 : (_settings$color = settings.color) === null || _settings$color === void 0 ? void 0 : (_settings$color$palet = _settings$color.palette) === null || _settings$color$palet === void 0 ? void 0 : _settings$color$palet.custom;
234
+ const themeColors = settings === null || settings === void 0 ? void 0 : (_settings$color2 = settings.color) === null || _settings$color2 === void 0 ? void 0 : (_settings$color2$pale = _settings$color2.palette) === null || _settings$color2$pale === void 0 ? void 0 : _settings$color2$pale.theme;
235
+ const defaultColors = settings === null || settings === void 0 ? void 0 : (_settings$color3 = settings.color) === null || _settings$color3 === void 0 ? void 0 : (_settings$color3$pale = _settings$color3.palette) === null || _settings$color3$pale === void 0 ? void 0 : _settings$color3$pale.default;
236
+ const shouldDisplayDefaultColors = settings === null || settings === void 0 ? void 0 : (_settings$color4 = settings.color) === null || _settings$color4 === void 0 ? void 0 : _settings$color4.defaultPalette;
237
+ return useMemo(() => {
238
+ const result = [];
239
+
240
+ if (themeColors && themeColors.length) {
241
+ result.push({
242
+ name: _x('Theme', 'Indicates this palette comes from the theme.'),
243
+ colors: themeColors
244
+ });
245
+ }
246
+
247
+ if (shouldDisplayDefaultColors && defaultColors && defaultColors.length) {
248
+ result.push({
249
+ name: _x('Default', 'Indicates this palette comes from WordPress.'),
250
+ colors: defaultColors
251
+ });
252
+ }
253
+
254
+ if (customColors && customColors.length) {
255
+ result.push({
256
+ name: _x('Custom', 'Indicates this palette is created by the user.'),
257
+ colors: customColors
258
+ });
259
+ }
260
+
261
+ return result;
262
+ }, [customColors, themeColors, defaultColors, shouldDisplayDefaultColors]);
174
263
  }
175
264
  //# sourceMappingURL=hooks.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/global-styles/hooks.js"],"names":["fastDeepEqual","get","set","useContext","useCallback","useMemo","useSelect","store","blocksStore","getValueFromVariable","getPresetVariableFromValue","GlobalStylesContext","unlock","EMPTY_CONFIG","settings","styles","VALID_SETTINGS","useGlobalStylesReset","user","config","setUserConfig","canReset","useGlobalSetting","propertyPath","blockName","source","configs","appendedBlockPath","appendedPropertyPath","contextualPath","globalPath","sourceKey","settingValue","configToUse","result","forEach","setting","value","setSetting","newValue","currentConfig","newUserConfig","JSON","parse","stringify","useGlobalStyle","path","shouldDecodeEncode","merged","mergedConfig","base","baseConfig","userConfig","appendedPath","finalPath","setStyle","rawResult","useSupportedStyles","name","element","supportedPanels","select","getSupportedStyles","overrideSettingsWithSupports","supports","updatedSettings","includes","typography","fontSizes","customFontSize","fontFamilies","key"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,aAAP,MAA0B,qBAA1B;AACA,SAASC,GAAT,EAAcC,GAAd,QAAyB,QAAzB;AAEA;AACA;AACA;;AACA,SAASC,UAAT,EAAqBC,WAArB,EAAkCC,OAAlC,QAAiD,oBAAjD;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,KAAK,IAAIC,WAAlB,QAAqC,mBAArC;AAEA;AACA;AACA;;AACA,SAASC,oBAAT,EAA+BC,0BAA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EhD,MAAM,CACtBiD,MAAM,CAAErD,WAAF,CADgB,CAAN,CAEfsD,kBAFe,CAEKJ,IAFL,EAEWC,OAFX;AADX,KAAP;AAKA,GAPmC,EAQpC,CAAED,IAAF,EAAQC,OAAR,CARoC,CAArC;AAWA,SAAOC,eAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASG,4BAAT,CAAuCjD,QAAvC,EAAiDkD,QAAjD,EAA4D;AAClE,QAAMC,eAAe,GAAG,EAAE,GAAGnD;AAAL,GAAxB;;AAEA,MAAK,CAAEkD,QAAQ,CAACE,QAAT,CAAmB,UAAnB,CAAP,EAAyC;AACxCD,IAAAA,eAAe,CAACE,UAAhB,GAA6B,EAC5B,GAAGF,eAAe,CAACE,UADS;AAE5BC,MAAAA,SAAS,EAAE,EAFiB;AAG5BC,MAAAA,cAAc,EAAE;AAHY,KAA7B;AAKA;;AAED,MAAK,CAAEL,QAAQ,CAACE,QAAT,CAAmB,YAAnB,CAAP,EAA2C;AAC1CD,IAAAA,eAAe,CAACE,UAAhB,GAA6B,EAC5B,GAAGF,eAAe,CAACE,UADS;AAE5BG,MAAAA,YAAY,EAAE;AAFc,KAA7B;AAIA;;AAED,GACC,YADD,EAEC,WAFD,EAGC,YAHD,EAIC,eAJD,EAKC,eALD,EAMEnC,OANF,CAMaoC,GAAF,IAAW;AACrB,QAAK,CAAEP,QAAQ,CAACE,QAAT,CAAmBK,GAAnB,CAAP,EAAkC;AACjCN,MAAAA,eAAe,CAACE,UAAhB,GAA6B,EAC5B,GAAGF,eAAe,CAACE,UADS;AAE5B,SAAEI,GAAF,GAAS;AAFmB,OAA7B;AAIA;AACD,GAbD;AAeA,SAAON,eAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport fastDeepEqual from 'fast-deep-equal/es6';\nimport { get, set } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useContext, useCallback, useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { store as blocksStore } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { getValueFromVariable, getPresetVariableFromValue } from './utils';\nimport { GlobalStylesContext } from './context';\nimport { unlock } from '../../lock-unlock';\n\nconst EMPTY_CONFIG = { settings: {}, styles: {} };\n\nconst VALID_SETTINGS = [\n\t'appearanceTools',\n\t'useRootPaddingAwareAlignments',\n\t'border.color',\n\t'border.radius',\n\t'border.style',\n\t'border.width',\n\t'shadow.presets',\n\t'shadow.defaultPresets',\n\t'color.background',\n\t'color.custom',\n\t'color.customDuotone',\n\t'color.customGradient',\n\t'color.defaultDuotone',\n\t'color.defaultGradients',\n\t'color.defaultPalette',\n\t'color.duotone',\n\t'color.gradients',\n\t'color.link',\n\t'color.palette',\n\t'color.text',\n\t'custom',\n\t'dimensions.minHeight',\n\t'layout.contentSize',\n\t'layout.definitions',\n\t'layout.wideSize',\n\t'position.fixed',\n\t'position.sticky',\n\t'spacing.customSpacingSize',\n\t'spacing.spacingSizes',\n\t'spacing.spacingScale',\n\t'spacing.blockGap',\n\t'spacing.margin',\n\t'spacing.padding',\n\t'spacing.units',\n\t'typography.fuild',\n\t'typography.customFontSize',\n\t'typography.dropCap',\n\t'typography.fontFamilies',\n\t'typography.fontSizes',\n\t'typography.fontStyle',\n\t'typography.fontWeight',\n\t'typography.letterSpacing',\n\t'typography.lineHeight',\n\t'typography.textDecoration',\n\t'typography.textTransform',\n];\n\nexport const useGlobalStylesReset = () => {\n\tconst { user: config, setUserConfig } = useContext( GlobalStylesContext );\n\tconst canReset = !! config && ! fastDeepEqual( config, EMPTY_CONFIG );\n\treturn [\n\t\tcanReset,\n\t\tuseCallback(\n\t\t\t() => setUserConfig( () => EMPTY_CONFIG ),\n\t\t\t[ setUserConfig ]\n\t\t),\n\t];\n};\n\nexport function useGlobalSetting( propertyPath, blockName, source = 'all' ) {\n\tconst { setUserConfig, ...configs } = useContext( GlobalStylesContext );\n\n\tconst appendedBlockPath = blockName ? '.blocks.' + blockName : '';\n\tconst appendedPropertyPath = propertyPath ? '.' + propertyPath : '';\n\tconst contextualPath = `settings${ appendedBlockPath }${ appendedPropertyPath }`;\n\tconst globalPath = `settings${ appendedPropertyPath }`;\n\tconst sourceKey = source === 'all' ? 'merged' : source;\n\n\tconst settingValue = useMemo( () => {\n\t\tconst configToUse = configs[ sourceKey ];\n\t\tif ( ! configToUse ) {\n\t\t\tthrow 'Unsupported source';\n\t\t}\n\n\t\tif ( propertyPath ) {\n\t\t\treturn (\n\t\t\t\tget( configToUse, contextualPath ) ??\n\t\t\t\tget( configToUse, globalPath )\n\t\t\t);\n\t\t}\n\n\t\tconst result = {};\n\t\tVALID_SETTINGS.forEach( ( setting ) => {\n\t\t\tconst value =\n\t\t\t\tget(\n\t\t\t\t\tconfigToUse,\n\t\t\t\t\t`settings${ appendedBlockPath }.${ setting }`\n\t\t\t\t) ?? get( configToUse, `settings.${ setting }` );\n\t\t\tif ( value ) {\n\t\t\t\tset( result, setting, value );\n\t\t\t}\n\t\t} );\n\t\treturn result;\n\t}, [\n\t\tconfigs,\n\t\tsourceKey,\n\t\tpropertyPath,\n\t\tcontextualPath,\n\t\tglobalPath,\n\t\tappendedBlockPath,\n\t] );\n\n\tconst setSetting = ( newValue ) => {\n\t\tsetUserConfig( ( currentConfig ) => {\n\t\t\t// Deep clone `currentConfig` to avoid mutating it later.\n\t\t\tconst newUserConfig = JSON.parse( JSON.stringify( currentConfig ) );\n\t\t\tset( newUserConfig, contextualPath, newValue );\n\n\t\t\treturn newUserConfig;\n\t\t} );\n\t};\n\n\treturn [ settingValue, setSetting ];\n}\n\nexport function useGlobalStyle(\n\tpath,\n\tblockName,\n\tsource = 'all',\n\t{ shouldDecodeEncode = true } = {}\n) {\n\tconst {\n\t\tmerged: mergedConfig,\n\t\tbase: baseConfig,\n\t\tuser: userConfig,\n\t\tsetUserConfig,\n\t} = useContext( GlobalStylesContext );\n\tconst appendedPath = path ? '.' + path : '';\n\tconst finalPath = ! blockName\n\t\t? `styles${ appendedPath }`\n\t\t: `styles.blocks.${ blockName }${ appendedPath }`;\n\n\tconst setStyle = ( newValue ) => {\n\t\tsetUserConfig( ( currentConfig ) => {\n\t\t\t// Deep clone `currentConfig` to avoid mutating it later.\n\t\t\tconst newUserConfig = JSON.parse( JSON.stringify( currentConfig ) );\n\t\t\tset(\n\t\t\t\tnewUserConfig,\n\t\t\t\tfinalPath,\n\t\t\t\tshouldDecodeEncode\n\t\t\t\t\t? getPresetVariableFromValue(\n\t\t\t\t\t\t\tmergedConfig.settings,\n\t\t\t\t\t\t\tblockName,\n\t\t\t\t\t\t\tpath,\n\t\t\t\t\t\t\tnewValue\n\t\t\t\t\t )\n\t\t\t\t\t: newValue\n\t\t\t);\n\t\t\treturn newUserConfig;\n\t\t} );\n\t};\n\n\tlet rawResult, result;\n\tswitch ( source ) {\n\t\tcase 'all':\n\t\t\trawResult =\n\t\t\t\t// The stlyes.css path is allowed to be empty, so don't revert to base if undefined.\n\t\t\t\tfinalPath === 'styles.css'\n\t\t\t\t\t? get( userConfig, finalPath )\n\t\t\t\t\t: get( mergedConfig, finalPath );\n\t\t\tresult = shouldDecodeEncode\n\t\t\t\t? getValueFromVariable( mergedConfig, blockName, rawResult )\n\t\t\t\t: rawResult;\n\t\t\tbreak;\n\t\tcase 'user':\n\t\t\trawResult = get( userConfig, finalPath );\n\t\t\tresult = shouldDecodeEncode\n\t\t\t\t? getValueFromVariable( mergedConfig, blockName, rawResult )\n\t\t\t\t: rawResult;\n\t\t\tbreak;\n\t\tcase 'base':\n\t\t\trawResult = get( baseConfig, finalPath );\n\t\t\tresult = shouldDecodeEncode\n\t\t\t\t? getValueFromVariable( baseConfig, blockName, rawResult )\n\t\t\t\t: rawResult;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tthrow 'Unsupported source';\n\t}\n\n\treturn [ result, setStyle ];\n}\n\nexport function useSupportedStyles( name, element ) {\n\tconst { supportedPanels } = useSelect(\n\t\t( select ) => {\n\t\t\treturn {\n\t\t\t\tsupportedPanels: unlock(\n\t\t\t\t\tselect( blocksStore )\n\t\t\t\t).getSupportedStyles( name, element ),\n\t\t\t};\n\t\t},\n\t\t[ name, element ]\n\t);\n\n\treturn supportedPanels;\n}\n\n/**\n * Given a settings object and a list of supported panels,\n * returns a new settings object with the unsupported panels removed.\n *\n * @param {Object} settings Settings object.\n * @param {string[]} supports Supported style panels.\n *\n * @return {Object} Merge of settings and supports.\n */\nexport function overrideSettingsWithSupports( settings, supports ) {\n\tconst updatedSettings = { ...settings };\n\n\tif ( ! supports.includes( 'fontSize' ) ) {\n\t\tupdatedSettings.typography = {\n\t\t\t...updatedSettings.typography,\n\t\t\tfontSizes: {},\n\t\t\tcustomFontSize: false,\n\t\t};\n\t}\n\n\tif ( ! supports.includes( 'fontFamily' ) ) {\n\t\tupdatedSettings.typography = {\n\t\t\t...updatedSettings.typography,\n\t\t\tfontFamilies: {},\n\t\t};\n\t}\n\n\t[\n\t\t'lineHeight',\n\t\t'fontStyle',\n\t\t'fontWeight',\n\t\t'letterSpacing',\n\t\t'textTransform',\n\t].forEach( ( key ) => {\n\t\tif ( ! supports.includes( key ) ) {\n\t\t\tupdatedSettings.typography = {\n\t\t\t\t...updatedSettings.typography,\n\t\t\t\t[ key ]: false,\n\t\t\t};\n\t\t}\n\t} );\n\n\treturn updatedSettings;\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/global-styles/hooks.js"],"names":["fastDeepEqual","get","set","useContext","useCallback","useMemo","useSelect","store","blocksStore","_x","getValueFromVariable","getPresetVariableFromValue","GlobalStylesContext","unlock","EMPTY_CONFIG","settings","styles","VALID_SETTINGS","useGlobalStylesReset","user","config","setUserConfig","canReset","useGlobalSetting","propertyPath","blockName","source","configs","appendedBlockPath","appendedPropertyPath","contextualPath","globalPath","sourceKey","settingValue","configToUse","result","forEach","setting","value","setSetting","newValue","currentConfig","newUserConfig","JSON","parse","stringify","useGlobalStyle","path","shouldDecodeEncode","merged","mergedConfig","base","baseConfig","userConfig","appendedPath","finalPath","setStyle","rawResult","useSettingsForBlockElement","parentSettings","element","supportedStyles","supports","select","getSupportedStyles","getBlockType","updatedSettings","includes","typography","fontSizes","customFontSize","fontFamilies","key","textColumns","layout","spacing","sides","Array","isArray","length","dimensions","minHeight","charAt","toUpperCase","slice","border","useColorsPerOrigin","customColors","color","palette","custom","themeColors","theme","defaultColors","default","shouldDisplayDefaultColors","defaultPalette","push","name","colors"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,aAAP,MAA0B,qBAA1B;AACA,SAASC,GAAT,EAAcC,GAAd,QAAyB,QAAzB;AAEA;AACA;AACA;;AACA,SAASC,UAAT,EAAqBC,WAArB,EAAkCC,OAAlC,QAAiD,oBAAjD;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,KAAK,IAAIC,WAAlB,QAAqC,mBAArC;AACA,SAASC,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AACA,SAASC,oBAAT,EAA+BC,0BAA/B,QAAiE,SAAjE;AACA,SAASC,mBAAT,QAAoC,WAApC;AACA,SAASC,MAAT,QAAuB,mBAAvB;AAEA,MAAMC,YAAY,GAAG;AAAEC,EAAAA,QAAQ,EAAE,EAAZ;AAAgBC,EAAAA,MAAM,EAAE;AAAxB,CAArB;AAEA,MAAMC,cAAc,GAAG,CACtB,iBADsB,EAEtB,+BAFsB,EAGtB,cAHsB,EAItB,eAJsB,EAKtB,cALsB,EAMtB,cANsB,EAOtB,gBAPsB,EAQtB,uBARsB,EAStB,kBATsB,EAUtB,cAVsB,EAWtB,qBAXsB,EAYtB,sBAZsB,EAatB,sBAbsB,EActB,wBAdsB,EAetB,sBAfsB,EAgBtB,eAhBsB,EAiBtB,iBAjBsB,EAkBtB,YAlBsB,EAmBtB,eAnBsB,EAoBtB,YApBsB,EAqBtB,QArBsB,EAsBtB,sBAtBsB,EAuBtB,oBAvBsB,EAwBtB,oBAxBsB,EAyBtB,iBAzBsB,EA0BtB,gBA1BsB,EA2BtB,iBA3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Aa;AACZC,QAAAA,IAAI,EAAEzF,EAAE,CACP,QADO,EAEP,gDAFO,CADI;AAKZ0F,QAAAA,MAAM,EAAEZ;AALI,OAAb;AAOA;;AACD,WAAOpD,MAAP;AACA,GAlCa,EAkCX,CACFoD,YADE,EAEFI,WAFE,EAGFE,aAHE,EAIFE,0BAJE,CAlCW,CAAd;AAwCA","sourcesContent":["/**\n * External dependencies\n */\nimport fastDeepEqual from 'fast-deep-equal/es6';\nimport { get, set } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useContext, useCallback, useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { _x } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { getValueFromVariable, getPresetVariableFromValue } from './utils';\nimport { GlobalStylesContext } from './context';\nimport { unlock } from '../../lock-unlock';\n\nconst EMPTY_CONFIG = { settings: {}, styles: {} };\n\nconst VALID_SETTINGS = [\n\t'appearanceTools',\n\t'useRootPaddingAwareAlignments',\n\t'border.color',\n\t'border.radius',\n\t'border.style',\n\t'border.width',\n\t'shadow.presets',\n\t'shadow.defaultPresets',\n\t'color.background',\n\t'color.custom',\n\t'color.customDuotone',\n\t'color.customGradient',\n\t'color.defaultDuotone',\n\t'color.defaultGradients',\n\t'color.defaultPalette',\n\t'color.duotone',\n\t'color.gradients',\n\t'color.link',\n\t'color.palette',\n\t'color.text',\n\t'custom',\n\t'dimensions.minHeight',\n\t'layout.contentSize',\n\t'layout.definitions',\n\t'layout.wideSize',\n\t'position.fixed',\n\t'position.sticky',\n\t'spacing.customSpacingSize',\n\t'spacing.spacingSizes',\n\t'spacing.spacingScale',\n\t'spacing.blockGap',\n\t'spacing.margin',\n\t'spacing.padding',\n\t'spacing.units',\n\t'typography.fluid',\n\t'typography.customFontSize',\n\t'typography.dropCap',\n\t'typography.fontFamilies',\n\t'typography.fontSizes',\n\t'typography.fontStyle',\n\t'typography.fontWeight',\n\t'typography.letterSpacing',\n\t'typography.lineHeight',\n\t'typography.textColumns',\n\t'typography.textDecoration',\n\t'typography.textTransform',\n];\n\nexport const useGlobalStylesReset = () => {\n\tconst { user: config, setUserConfig } = useContext( GlobalStylesContext );\n\tconst canReset = !! config && ! fastDeepEqual( config, EMPTY_CONFIG );\n\treturn [\n\t\tcanReset,\n\t\tuseCallback(\n\t\t\t() => setUserConfig( () => EMPTY_CONFIG ),\n\t\t\t[ setUserConfig ]\n\t\t),\n\t];\n};\n\nexport function useGlobalSetting( propertyPath, blockName, source = 'all' ) {\n\tconst { setUserConfig, ...configs } = useContext( GlobalStylesContext );\n\n\tconst appendedBlockPath = blockName ? '.blocks.' + blockName : '';\n\tconst appendedPropertyPath = propertyPath ? '.' + propertyPath : '';\n\tconst contextualPath = `settings${ appendedBlockPath }${ appendedPropertyPath }`;\n\tconst globalPath = `settings${ appendedPropertyPath }`;\n\tconst sourceKey = source === 'all' ? 'merged' : source;\n\n\tconst settingValue = useMemo( () => {\n\t\tconst configToUse = configs[ sourceKey ];\n\t\tif ( ! configToUse ) {\n\t\t\tthrow 'Unsupported source';\n\t\t}\n\n\t\tif ( propertyPath ) {\n\t\t\treturn (\n\t\t\t\tget( configToUse, contextualPath ) ??\n\t\t\t\tget( configToUse, globalPath )\n\t\t\t);\n\t\t}\n\n\t\tconst result = {};\n\t\tVALID_SETTINGS.forEach( ( setting ) => {\n\t\t\tconst value =\n\t\t\t\tget(\n\t\t\t\t\tconfigToUse,\n\t\t\t\t\t`settings${ appendedBlockPath }.${ setting }`\n\t\t\t\t) ?? get( configToUse, `settings.${ setting }` );\n\t\t\tif ( value ) {\n\t\t\t\tset( result, setting, value );\n\t\t\t}\n\t\t} );\n\t\treturn result;\n\t}, [\n\t\tconfigs,\n\t\tsourceKey,\n\t\tpropertyPath,\n\t\tcontextualPath,\n\t\tglobalPath,\n\t\tappendedBlockPath,\n\t] );\n\n\tconst setSetting = ( newValue ) => {\n\t\tsetUserConfig( ( currentConfig ) => {\n\t\t\t// Deep clone `currentConfig` to avoid mutating it later.\n\t\t\tconst newUserConfig = JSON.parse( JSON.stringify( currentConfig ) );\n\t\t\tset( newUserConfig, contextualPath, newValue );\n\n\t\t\treturn newUserConfig;\n\t\t} );\n\t};\n\n\treturn [ settingValue, setSetting ];\n}\n\nexport function useGlobalStyle(\n\tpath,\n\tblockName,\n\tsource = 'all',\n\t{ shouldDecodeEncode = true } = {}\n) {\n\tconst {\n\t\tmerged: mergedConfig,\n\t\tbase: baseConfig,\n\t\tuser: userConfig,\n\t\tsetUserConfig,\n\t} = useContext( GlobalStylesContext );\n\tconst appendedPath = path ? '.' + path : '';\n\tconst finalPath = ! blockName\n\t\t? `styles${ appendedPath }`\n\t\t: `styles.blocks.${ blockName }${ appendedPath }`;\n\n\tconst setStyle = ( newValue ) => {\n\t\tsetUserConfig( ( currentConfig ) => {\n\t\t\t// Deep clone `currentConfig` to avoid mutating it later.\n\t\t\tconst newUserConfig = JSON.parse( JSON.stringify( currentConfig ) );\n\t\t\tset(\n\t\t\t\tnewUserConfig,\n\t\t\t\tfinalPath,\n\t\t\t\tshouldDecodeEncode\n\t\t\t\t\t? getPresetVariableFromValue(\n\t\t\t\t\t\t\tmergedConfig.settings,\n\t\t\t\t\t\t\tblockName,\n\t\t\t\t\t\t\tpath,\n\t\t\t\t\t\t\tnewValue\n\t\t\t\t\t )\n\t\t\t\t\t: newValue\n\t\t\t);\n\t\t\treturn newUserConfig;\n\t\t} );\n\t};\n\n\tlet rawResult, result;\n\tswitch ( source ) {\n\t\tcase 'all':\n\t\t\trawResult =\n\t\t\t\t// The styles.css path is allowed to be empty, so don't revert to base if undefined.\n\t\t\t\tfinalPath === 'styles.css'\n\t\t\t\t\t? get( userConfig, finalPath )\n\t\t\t\t\t: get( mergedConfig, finalPath );\n\t\t\tresult = shouldDecodeEncode\n\t\t\t\t? getValueFromVariable( mergedConfig, blockName, rawResult )\n\t\t\t\t: rawResult;\n\t\t\tbreak;\n\t\tcase 'user':\n\t\t\trawResult = get( userConfig, finalPath );\n\t\t\tresult = shouldDecodeEncode\n\t\t\t\t? getValueFromVariable( mergedConfig, blockName, rawResult )\n\t\t\t\t: rawResult;\n\t\t\tbreak;\n\t\tcase 'base':\n\t\t\trawResult = get( baseConfig, finalPath );\n\t\t\tresult = shouldDecodeEncode\n\t\t\t\t? getValueFromVariable( baseConfig, blockName, rawResult )\n\t\t\t\t: rawResult;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tthrow 'Unsupported source';\n\t}\n\n\treturn [ result, setStyle ];\n}\n\n/**\n * React hook that overrides a global settings object with block and element specific settings.\n *\n * @param {Object} parentSettings Settings object.\n * @param {blockName?} blockName Block name.\n * @param {element?} element Element name.\n *\n * @return {Object} Merge of settings and supports.\n */\nexport function useSettingsForBlockElement(\n\tparentSettings,\n\tblockName,\n\telement\n) {\n\tconst { supportedStyles, supports } = useSelect(\n\t\t( select ) => {\n\t\t\treturn {\n\t\t\t\tsupportedStyles: unlock(\n\t\t\t\t\tselect( blocksStore )\n\t\t\t\t).getSupportedStyles( blockName, element ),\n\t\t\t\tsupports:\n\t\t\t\t\tselect( blocksStore ).getBlockType( blockName )?.supports,\n\t\t\t};\n\t\t},\n\t\t[ blockName, element ]\n\t);\n\n\treturn useMemo( () => {\n\t\tconst updatedSettings = { ...parentSettings };\n\n\t\tif ( ! supportedStyles.includes( 'fontSize' ) ) {\n\t\t\tupdatedSettings.typography = {\n\t\t\t\t...updatedSettings.typography,\n\t\t\t\tfontSizes: {},\n\t\t\t\tcustomFontSize: false,\n\t\t\t};\n\t\t}\n\n\t\tif ( ! supportedStyles.includes( 'fontFamily' ) ) {\n\t\t\tupdatedSettings.typography = {\n\t\t\t\t...updatedSettings.typography,\n\t\t\t\tfontFamilies: {},\n\t\t\t};\n\t\t}\n\n\t\t[\n\t\t\t'lineHeight',\n\t\t\t'fontStyle',\n\t\t\t'fontWeight',\n\t\t\t'letterSpacing',\n\t\t\t'textTransform',\n\t\t\t'textDecoration',\n\t\t].forEach( ( key ) => {\n\t\t\tif ( ! supportedStyles.includes( key ) ) {\n\t\t\t\tupdatedSettings.typography = {\n\t\t\t\t\t...updatedSettings.typography,\n\t\t\t\t\t[ key ]: false,\n\t\t\t\t};\n\t\t\t}\n\t\t} );\n\n\t\t// The column-count style is named text column to reduce confusion with\n\t\t// the columns block and manage expectations from the support.\n\t\t// See: https://github.com/WordPress/gutenberg/pull/33587\n\t\tif ( ! supportedStyles.includes( 'columnCount' ) ) {\n\t\t\tupdatedSettings.typography = {\n\t\t\t\t...updatedSettings.typography,\n\t\t\t\ttextColumns: false,\n\t\t\t};\n\t\t}\n\n\t\t[ 'contentSize', 'wideSize' ].forEach( ( key ) => {\n\t\t\tif ( ! supportedStyles.includes( key ) ) {\n\t\t\t\tupdatedSettings.layout = {\n\t\t\t\t\t...updatedSettings.layout,\n\t\t\t\t\t[ key ]: false,\n\t\t\t\t};\n\t\t\t}\n\t\t} );\n\n\t\t[ 'padding', 'margin', 'blockGap' ].forEach( ( key ) => {\n\t\t\tif ( ! supportedStyles.includes( key ) ) {\n\t\t\t\tupdatedSettings.spacing = {\n\t\t\t\t\t...updatedSettings.spacing,\n\t\t\t\t\t[ key ]: false,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst sides = Array.isArray( supports?.spacing?.[ key ] )\n\t\t\t\t? supports?.spacing?.[ key ]\n\t\t\t\t: supports?.spacing?.[ key ]?.sides;\n\t\t\tif ( sides?.length ) {\n\t\t\t\tupdatedSettings.spacing = {\n\t\t\t\t\t...updatedSettings.spacing,\n\t\t\t\t\t[ key ]: {\n\t\t\t\t\t\t...updatedSettings.spacing?.[ key ],\n\t\t\t\t\t\tsides,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t}\n\t\t} );\n\n\t\tif ( ! supportedStyles.includes( 'minHeight' ) ) {\n\t\t\tupdatedSettings.dimensions = {\n\t\t\t\t...updatedSettings.dimensions,\n\t\t\t\tminHeight: false,\n\t\t\t};\n\t\t}\n\n\t\t[ 'radius', 'color', 'style', 'width' ].forEach( ( key ) => {\n\t\t\tif (\n\t\t\t\t! supportedStyles.includes(\n\t\t\t\t\t'border' + key.charAt( 0 ).toUpperCase() + key.slice( 1 )\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tupdatedSettings.border = {\n\t\t\t\t\t...updatedSettings.border,\n\t\t\t\t\t[ key ]: false,\n\t\t\t\t};\n\t\t\t}\n\t\t} );\n\n\t\treturn updatedSettings;\n\t}, [ parentSettings, supportedStyles, supports ] );\n}\n\nexport function useColorsPerOrigin( settings ) {\n\tconst customColors = settings?.color?.palette?.custom;\n\tconst themeColors = settings?.color?.palette?.theme;\n\tconst defaultColors = settings?.color?.palette?.default;\n\tconst shouldDisplayDefaultColors = settings?.color?.defaultPalette;\n\n\treturn useMemo( () => {\n\t\tconst result = [];\n\t\tif ( themeColors && themeColors.length ) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Theme',\n\t\t\t\t\t'Indicates this palette comes from the theme.'\n\t\t\t\t),\n\t\t\t\tcolors: themeColors,\n\t\t\t} );\n\t\t}\n\t\tif (\n\t\t\tshouldDisplayDefaultColors &&\n\t\t\tdefaultColors &&\n\t\t\tdefaultColors.length\n\t\t) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Default',\n\t\t\t\t\t'Indicates this palette comes from WordPress.'\n\t\t\t\t),\n\t\t\t\tcolors: defaultColors,\n\t\t\t} );\n\t\t}\n\t\tif ( customColors && customColors.length ) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Custom',\n\t\t\t\t\t'Indicates this palette is created by the user.'\n\t\t\t\t),\n\t\t\t\tcolors: customColors,\n\t\t\t} );\n\t\t}\n\t\treturn result;\n\t}, [\n\t\tcustomColors,\n\t\tthemeColors,\n\t\tdefaultColors,\n\t\tshouldDisplayDefaultColors,\n\t] );\n}\n"]}
@@ -1,5 +1,7 @@
1
- export { useGlobalStylesReset, useGlobalSetting, useGlobalStyle, overrideSettingsWithSupports } from './hooks';
1
+ export { useGlobalStylesReset, useGlobalSetting, useGlobalStyle, useSettingsForBlockElement, useColorsPerOrigin } from './hooks';
2
2
  export { useGlobalStylesOutput } from './use-global-styles-output';
3
3
  export { GlobalStylesContext } from './context';
4
4
  export { default as TypographyPanel, useHasTypographyPanel } from './typography-panel';
5
+ export { default as DimensionsPanel, useHasDimensionsPanel } from './dimensions-panel';
6
+ export { default as BorderPanel, useHasBorderPanel } from './border-panel';
5
7
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/global-styles/index.js"],"names":["useGlobalStylesReset","useGlobalSetting","useGlobalStyle","overrideSettingsWithSupports","useGlobalStylesOutput","GlobalStylesContext","default","TypographyPanel","useHasTypographyPanel"],"mappings":"AAAA,SACCA,oBADD,EAECC,gBAFD,EAGCC,cAHD,EAICC,4BAJD,QAKO,SALP;AAMA,SAASC,qBAAT,QAAsC,4BAAtC;AACA,SAASC,mBAAT,QAAoC,WAApC;AACA,SACCC,OAAO,IAAIC,eADZ,EAECC,qBAFD,QAGO,oBAHP","sourcesContent":["export {\n\tuseGlobalStylesReset,\n\tuseGlobalSetting,\n\tuseGlobalStyle,\n\toverrideSettingsWithSupports,\n} from './hooks';\nexport { useGlobalStylesOutput } from './use-global-styles-output';\nexport { GlobalStylesContext } from './context';\nexport {\n\tdefault as TypographyPanel,\n\tuseHasTypographyPanel,\n} from './typography-panel';\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/global-styles/index.js"],"names":["useGlobalStylesReset","useGlobalSetting","useGlobalStyle","useSettingsForBlockElement","useColorsPerOrigin","useGlobalStylesOutput","GlobalStylesContext","default","TypographyPanel","useHasTypographyPanel","DimensionsPanel","useHasDimensionsPanel","BorderPanel","useHasBorderPanel"],"mappings":"AAAA,SACCA,oBADD,EAECC,gBAFD,EAGCC,cAHD,EAICC,0BAJD,EAKCC,kBALD,QAMO,SANP;AAOA,SAASC,qBAAT,QAAsC,4BAAtC;AACA,SAASC,mBAAT,QAAoC,WAApC;AACA,SACCC,OAAO,IAAIC,eADZ,EAECC,qBAFD,QAGO,oBAHP;AAIA,SACCF,OAAO,IAAIG,eADZ,EAECC,qBAFD,QAGO,oBAHP;AAIA,SAASJ,OAAO,IAAIK,WAApB,EAAiCC,iBAAjC,QAA0D,gBAA1D","sourcesContent":["export {\n\tuseGlobalStylesReset,\n\tuseGlobalSetting,\n\tuseGlobalStyle,\n\tuseSettingsForBlockElement,\n\tuseColorsPerOrigin,\n} from './hooks';\nexport { useGlobalStylesOutput } from './use-global-styles-output';\nexport { GlobalStylesContext } from './context';\nexport {\n\tdefault as TypographyPanel,\n\tuseHasTypographyPanel,\n} from './typography-panel';\nexport {\n\tdefault as DimensionsPanel,\n\tuseHasDimensionsPanel,\n} from './dimensions-panel';\nexport { default as BorderPanel, useHasBorderPanel } from './border-panel';\n"]}
@@ -1,11 +1,11 @@
1
- import _extends from "@babel/runtime/helpers/esm/extends";
2
1
  import { createElement } from "@wordpress/element";
3
2
 
4
3
  /**
5
4
  * WordPress dependencies
6
5
  */
7
- import { FontSizePicker, __experimentalToolsPanel as ToolsPanel, __experimentalToolsPanelItem as ToolsPanelItem } from '@wordpress/components';
6
+ import { FontSizePicker, __experimentalNumberControl as NumberControl, __experimentalToolsPanel as ToolsPanel, __experimentalToolsPanelItem as ToolsPanelItem } from '@wordpress/components';
8
7
  import { __ } from '@wordpress/i18n';
8
+ import { useCallback } from '@wordpress/element';
9
9
  /**
10
10
  * Internal dependencies
11
11
  */
@@ -17,6 +17,8 @@ import LetterSpacingControl from '../letter-spacing-control';
17
17
  import TextTransformControl from '../text-transform-control';
18
18
  import TextDecorationControl from '../text-decoration-control';
19
19
  import { getValueFromVariable } from './utils';
20
+ const MIN_TEXT_COLUMNS = 1;
21
+ const MAX_TEXT_COLUMNS = 6;
20
22
  export function useHasTypographyPanel(settings) {
21
23
  const hasFontFamily = useHasFontFamilyControl(settings);
22
24
  const hasLineHeight = useHasLineHeightControl(settings);
@@ -24,8 +26,9 @@ export function useHasTypographyPanel(settings) {
24
26
  const hasLetterSpacing = useHasLetterSpacingControl(settings);
25
27
  const hasTextTransform = useHasTextTransformControl(settings);
26
28
  const hasTextDecoration = useHasTextDecorationControl(settings);
29
+ const hasTextColumns = useHasTextColumnsControl(settings);
27
30
  const hasFontSize = useHasFontSizeControl(settings);
28
- return hasFontFamily || hasLineHeight || hasFontAppearance || hasLetterSpacing || hasTextTransform || hasFontSize || hasTextDecoration;
31
+ return hasFontFamily || hasLineHeight || hasFontAppearance || hasLetterSpacing || hasTextTransform || hasFontSize || hasTextDecoration || hasTextColumns;
29
32
  }
30
33
 
31
34
  function useHasFontSizeControl(settings) {
@@ -94,12 +97,31 @@ function useHasTextDecorationControl(settings) {
94
97
  return settings === null || settings === void 0 ? void 0 : (_settings$typography11 = settings.typography) === null || _settings$typography11 === void 0 ? void 0 : _settings$typography11.textDecoration;
95
98
  }
96
99
 
100
+ function useHasTextColumnsControl(settings) {
101
+ var _settings$typography12;
102
+
103
+ return settings === null || settings === void 0 ? void 0 : (_settings$typography12 = settings.typography) === null || _settings$typography12 === void 0 ? void 0 : _settings$typography12.textColumns;
104
+ }
105
+
97
106
  function TypographyToolsPanel(_ref3) {
98
- let { ...props
107
+ let {
108
+ resetAllFilter,
109
+ onChange,
110
+ value,
111
+ panelId,
112
+ children
99
113
  } = _ref3;
100
- return createElement(ToolsPanel, _extends({
101
- label: __('Typography')
102
- }, props));
114
+
115
+ const resetAll = () => {
116
+ const updatedValue = resetAllFilter(value);
117
+ onChange(updatedValue);
118
+ };
119
+
120
+ return createElement(ToolsPanel, {
121
+ label: __('Typography'),
122
+ resetAll: resetAll,
123
+ panelId: panelId
124
+ }, children);
103
125
  }
104
126
 
105
127
  const DEFAULT_CONTROLS = {
@@ -109,10 +131,11 @@ const DEFAULT_CONTROLS = {
109
131
  lineHeight: true,
110
132
  letterSpacing: true,
111
133
  textTransform: true,
112
- textDecoration: true
134
+ textDecoration: true,
135
+ textColumns: true
113
136
  };
114
137
  export default function TypographyPanel(_ref4) {
115
- var _settings$typography12, _ref5, _fontFamiliesPerOrigi2, _inheritedValue$typog, _settings$typography13, _settings$typography$2, _settings$typography14, _ref7, _fontSizesPerOrigin$c2, _inheritedValue$typog2, _settings$typography15, _settings$typography16, _inheritedValue$typog3, _inheritedValue$typog4, _inheritedValue$typog5, _inheritedValue$typog6, _inheritedValue$typog7, _inheritedValue$typog8;
138
+ var _settings$typography13, _ref5, _fontFamiliesPerOrigi2, _inheritedValue$typog, _settings$typography14, _settings$typography$2, _settings$typography15, _ref7, _fontSizesPerOrigin$c2, _inheritedValue$typog2, _settings$typography16, _settings$typography17, _inheritedValue$typog3, _inheritedValue$typog4, _inheritedValue$typog5, _inheritedValue$typog6, _inheritedValue$typog7, _inheritedValue$typog8, _inheritedValue$typog9;
116
139
 
117
140
  let {
118
141
  as: Wrapper = TypographyToolsPanel,
@@ -130,7 +153,7 @@ export default function TypographyPanel(_ref4) {
130
153
 
131
154
 
132
155
  const hasFontFamilyEnabled = useHasFontFamilyControl(settings);
133
- const fontFamiliesPerOrigin = settings === null || settings === void 0 ? void 0 : (_settings$typography12 = settings.typography) === null || _settings$typography12 === void 0 ? void 0 : _settings$typography12.fontFamilies;
156
+ const fontFamiliesPerOrigin = settings === null || settings === void 0 ? void 0 : (_settings$typography13 = settings.typography) === null || _settings$typography13 === void 0 ? void 0 : _settings$typography13.fontFamilies;
134
157
  const fontFamilies = (_ref5 = (_fontFamiliesPerOrigi2 = fontFamiliesPerOrigin === null || fontFamiliesPerOrigin === void 0 ? void 0 : fontFamiliesPerOrigin.custom) !== null && _fontFamiliesPerOrigi2 !== void 0 ? _fontFamiliesPerOrigi2 : fontFamiliesPerOrigin === null || fontFamiliesPerOrigin === void 0 ? void 0 : fontFamiliesPerOrigin.theme) !== null && _ref5 !== void 0 ? _ref5 : fontFamiliesPerOrigin === null || fontFamiliesPerOrigin === void 0 ? void 0 : fontFamiliesPerOrigin.default;
135
158
  const fontFamily = decodeValue(inheritedValue === null || inheritedValue === void 0 ? void 0 : (_inheritedValue$typog = inheritedValue.typography) === null || _inheritedValue$typog === void 0 ? void 0 : _inheritedValue$typog.fontFamily);
136
159
 
@@ -160,8 +183,8 @@ export default function TypographyPanel(_ref4) {
160
183
 
161
184
 
162
185
  const hasFontSizeEnabled = useHasFontSizeControl(settings);
163
- const disableCustomFontSizes = !(settings !== null && settings !== void 0 && (_settings$typography13 = settings.typography) !== null && _settings$typography13 !== void 0 && _settings$typography13.customFontSize);
164
- const fontSizesPerOrigin = (_settings$typography$2 = settings === null || settings === void 0 ? void 0 : (_settings$typography14 = settings.typography) === null || _settings$typography14 === void 0 ? void 0 : _settings$typography14.fontSizes) !== null && _settings$typography$2 !== void 0 ? _settings$typography$2 : {};
186
+ const disableCustomFontSizes = !(settings !== null && settings !== void 0 && (_settings$typography14 = settings.typography) !== null && _settings$typography14 !== void 0 && _settings$typography14.customFontSize);
187
+ const fontSizesPerOrigin = (_settings$typography$2 = settings === null || settings === void 0 ? void 0 : (_settings$typography15 = settings.typography) === null || _settings$typography15 === void 0 ? void 0 : _settings$typography15.fontSizes) !== null && _settings$typography$2 !== void 0 ? _settings$typography$2 : {};
165
188
  const fontSizes = (_ref7 = (_fontSizesPerOrigin$c2 = fontSizesPerOrigin === null || fontSizesPerOrigin === void 0 ? void 0 : fontSizesPerOrigin.custom) !== null && _fontSizesPerOrigin$c2 !== void 0 ? _fontSizesPerOrigin$c2 : fontSizesPerOrigin === null || fontSizesPerOrigin === void 0 ? void 0 : fontSizesPerOrigin.theme) !== null && _ref7 !== void 0 ? _ref7 : fontSizesPerOrigin.default;
166
189
  const fontSize = decodeValue(inheritedValue === null || inheritedValue === void 0 ? void 0 : (_inheritedValue$typog2 = inheritedValue.typography) === null || _inheritedValue$typog2 === void 0 ? void 0 : _inheritedValue$typog2.fontSize);
167
190
 
@@ -185,8 +208,8 @@ export default function TypographyPanel(_ref4) {
185
208
 
186
209
  const hasAppearanceControl = useHasAppearanceControl(settings);
187
210
  const appearanceControlLabel = useAppearanceControlLabel(settings);
188
- const hasFontStyles = settings === null || settings === void 0 ? void 0 : (_settings$typography15 = settings.typography) === null || _settings$typography15 === void 0 ? void 0 : _settings$typography15.fontStyle;
189
- const hasFontWeights = settings === null || settings === void 0 ? void 0 : (_settings$typography16 = settings.typography) === null || _settings$typography16 === void 0 ? void 0 : _settings$typography16.fontWeight;
211
+ const hasFontStyles = settings === null || settings === void 0 ? void 0 : (_settings$typography16 = settings.typography) === null || _settings$typography16 === void 0 ? void 0 : _settings$typography16.fontStyle;
212
+ const hasFontWeights = settings === null || settings === void 0 ? void 0 : (_settings$typography17 = settings.typography) === null || _settings$typography17 === void 0 ? void 0 : _settings$typography17.fontWeight;
190
213
  const fontStyle = decodeValue(inheritedValue === null || inheritedValue === void 0 ? void 0 : (_inheritedValue$typog3 = inheritedValue.typography) === null || _inheritedValue$typog3 === void 0 ? void 0 : _inheritedValue$typog3.fontStyle);
191
214
  const fontWeight = decodeValue(inheritedValue === null || inheritedValue === void 0 ? void 0 : (_inheritedValue$typog4 = inheritedValue.typography) === null || _inheritedValue$typog4 === void 0 ? void 0 : _inheritedValue$typog4.fontWeight);
192
215
 
@@ -251,11 +274,31 @@ export default function TypographyPanel(_ref4) {
251
274
  return !!(value !== null && value !== void 0 && (_value$typography6 = value.typography) !== null && _value$typography6 !== void 0 && _value$typography6.letterSpacing);
252
275
  };
253
276
 
254
- const resetLetterSpacing = () => setLetterSpacing(undefined); // Text Transform
277
+ const resetLetterSpacing = () => setLetterSpacing(undefined); // Text Columns
278
+
279
+
280
+ const hasTextColumnsControl = useHasTextColumnsControl(settings);
281
+ const textColumns = decodeValue(inheritedValue === null || inheritedValue === void 0 ? void 0 : (_inheritedValue$typog7 = inheritedValue.typography) === null || _inheritedValue$typog7 === void 0 ? void 0 : _inheritedValue$typog7.textColumns);
282
+
283
+ const setTextColumns = newValue => {
284
+ onChange({ ...value,
285
+ typography: { ...(value === null || value === void 0 ? void 0 : value.typography),
286
+ textColumns: newValue
287
+ }
288
+ });
289
+ };
290
+
291
+ const hasTextColumns = () => {
292
+ var _value$typography7;
293
+
294
+ return !!(value !== null && value !== void 0 && (_value$typography7 = value.typography) !== null && _value$typography7 !== void 0 && _value$typography7.textColumns);
295
+ };
296
+
297
+ const resetTextColumns = () => setTextColumns(undefined); // Text Transform
255
298
 
256
299
 
257
300
  const hasTextTransformControl = useHasTextTransformControl(settings);
258
- const textTransform = decodeValue(inheritedValue === null || inheritedValue === void 0 ? void 0 : (_inheritedValue$typog7 = inheritedValue.typography) === null || _inheritedValue$typog7 === void 0 ? void 0 : _inheritedValue$typog7.textTransform);
301
+ const textTransform = decodeValue(inheritedValue === null || inheritedValue === void 0 ? void 0 : (_inheritedValue$typog8 = inheritedValue.typography) === null || _inheritedValue$typog8 === void 0 ? void 0 : _inheritedValue$typog8.textTransform);
259
302
 
260
303
  const setTextTransform = newValue => {
261
304
  onChange({ ...value,
@@ -266,16 +309,16 @@ export default function TypographyPanel(_ref4) {
266
309
  };
267
310
 
268
311
  const hasTextTransform = () => {
269
- var _value$typography7;
312
+ var _value$typography8;
270
313
 
271
- return !!(value !== null && value !== void 0 && (_value$typography7 = value.typography) !== null && _value$typography7 !== void 0 && _value$typography7.textTransform);
314
+ return !!(value !== null && value !== void 0 && (_value$typography8 = value.typography) !== null && _value$typography8 !== void 0 && _value$typography8.textTransform);
272
315
  };
273
316
 
274
317
  const resetTextTransform = () => setTextTransform(undefined); // Text Decoration
275
318
 
276
319
 
277
320
  const hasTextDecorationControl = useHasTextDecorationControl(settings);
278
- const textDecoration = decodeValue(inheritedValue === null || inheritedValue === void 0 ? void 0 : (_inheritedValue$typog8 = inheritedValue.typography) === null || _inheritedValue$typog8 === void 0 ? void 0 : _inheritedValue$typog8.textDecoration);
321
+ const textDecoration = decodeValue(inheritedValue === null || inheritedValue === void 0 ? void 0 : (_inheritedValue$typog9 = inheritedValue.typography) === null || _inheritedValue$typog9 === void 0 ? void 0 : _inheritedValue$typog9.textDecoration);
279
322
 
280
323
  const setTextDecoration = newValue => {
281
324
  onChange({ ...value,
@@ -286,21 +329,23 @@ export default function TypographyPanel(_ref4) {
286
329
  };
287
330
 
288
331
  const hasTextDecoration = () => {
289
- var _value$typography8;
332
+ var _value$typography9;
290
333
 
291
- return !!(value !== null && value !== void 0 && (_value$typography8 = value.typography) !== null && _value$typography8 !== void 0 && _value$typography8.textDecoration);
334
+ return !!(value !== null && value !== void 0 && (_value$typography9 = value.typography) !== null && _value$typography9 !== void 0 && _value$typography9.textDecoration);
292
335
  };
293
336
 
294
337
  const resetTextDecoration = () => setTextDecoration(undefined);
295
338
 
296
- const resetAll = () => {
297
- onChange({ ...value,
339
+ const resetAllFilter = useCallback(previousValue => {
340
+ return { ...previousValue,
298
341
  typography: {}
299
- });
300
- };
301
-
342
+ };
343
+ }, []);
302
344
  return createElement(Wrapper, {
303
- resetAll: resetAll
345
+ resetAllFilter: resetAllFilter,
346
+ value: value,
347
+ onChange: onChange,
348
+ panelId: panelId
304
349
  }, hasFontFamilyEnabled && createElement(ToolsPanelItem, {
305
350
  label: __('Font family'),
306
351
  hasValue: hasFontFamily,
@@ -370,6 +415,22 @@ export default function TypographyPanel(_ref4) {
370
415
  onChange: setLetterSpacing,
371
416
  size: "__unstable-large",
372
417
  __unstableInputWidth: "auto"
418
+ })), hasTextColumnsControl && createElement(ToolsPanelItem, {
419
+ className: "single-column",
420
+ label: __('Text columns'),
421
+ hasValue: hasTextColumns,
422
+ onDeselect: resetTextColumns,
423
+ isShownByDefault: defaultControls.textColumns,
424
+ panelId: panelId
425
+ }, createElement(NumberControl, {
426
+ label: __('Text columns'),
427
+ max: MAX_TEXT_COLUMNS,
428
+ min: MIN_TEXT_COLUMNS,
429
+ onChange: setTextColumns,
430
+ size: "__unstable-large",
431
+ spinControls: "custom",
432
+ value: textColumns,
433
+ initialPosition: 1
373
434
  })), hasTextDecorationControl && createElement(ToolsPanelItem, {
374
435
  className: "single-column",
375
436
  label: __('Text decoration'),