@wordpress/block-editor 9.3.0 → 9.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 (449) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +1 -8
  3. package/build/components/block-list/block-invalid-warning.native.js +54 -6
  4. package/build/components/block-list/block-invalid-warning.native.js.map +1 -1
  5. package/build/components/block-list/block.js +2 -2
  6. package/build/components/block-list/block.js.map +1 -1
  7. package/build/components/block-list/block.native.js +2 -1
  8. package/build/components/block-list/block.native.js.map +1 -1
  9. package/build/components/block-list/index.native.js +4 -3
  10. package/build/components/block-list/index.native.js.map +1 -1
  11. package/build/components/block-list/layout.js +20 -5
  12. package/build/components/block-list/layout.js.map +1 -1
  13. package/build/components/block-list/use-block-props/use-block-class-names.js +5 -2
  14. package/build/components/block-list/use-block-props/use-block-class-names.js.map +1 -1
  15. package/build/components/block-lock/modal.js +37 -7
  16. package/build/components/block-lock/modal.js.map +1 -1
  17. package/build/components/block-mobile-toolbar/block-actions-menu.native.js +1 -1
  18. package/build/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
  19. package/build/components/block-mover/mover-description.js +95 -32
  20. package/build/components/block-mover/mover-description.js.map +1 -1
  21. package/build/components/block-pattern-setup/index.js +8 -26
  22. package/build/components/block-pattern-setup/index.js.map +1 -1
  23. package/build/components/block-pattern-setup/setup-toolbar.js +3 -8
  24. package/build/components/block-pattern-setup/setup-toolbar.js.map +1 -1
  25. package/build/components/block-popover/inbetween.js +1 -1
  26. package/build/components/block-popover/inbetween.js.map +1 -1
  27. package/build/components/block-popover/index.js +1 -1
  28. package/build/components/block-popover/index.js.map +1 -1
  29. package/build/components/block-preview/auto.js +21 -5
  30. package/build/components/block-preview/auto.js.map +1 -1
  31. package/build/components/block-settings-menu/block-edit-visually-button.js +70 -0
  32. package/build/components/block-settings-menu/block-edit-visually-button.js.map +1 -0
  33. package/build/components/block-settings-menu/block-mode-toggle.js +1 -1
  34. package/build/components/block-settings-menu/block-mode-toggle.js.map +1 -1
  35. package/build/components/block-settings-menu/block-settings-dropdown.js +5 -2
  36. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  37. package/build/components/block-settings-menu/index.js +6 -2
  38. package/build/components/block-settings-menu/index.js.map +1 -1
  39. package/build/components/block-settings-menu-controls/index.js +5 -2
  40. package/build/components/block-settings-menu-controls/index.js.map +1 -1
  41. package/build/components/block-styles/preview.native.js.map +1 -1
  42. package/build/components/block-switcher/index.js +7 -1
  43. package/build/components/block-switcher/index.js.map +1 -1
  44. package/build/components/block-title/index.js +8 -2
  45. package/build/components/block-title/index.js.map +1 -1
  46. package/build/components/block-title/use-block-display-title.js +15 -15
  47. package/build/components/block-title/use-block-display-title.js.map +1 -1
  48. package/build/components/block-tools/block-contextual-toolbar.js +1 -1
  49. package/build/components/block-tools/block-contextual-toolbar.js.map +1 -1
  50. package/build/components/block-tools/block-selection-button.js +1 -7
  51. package/build/components/block-tools/block-selection-button.js.map +1 -1
  52. package/build/components/block-tools/index.js +4 -1
  53. package/build/components/block-tools/index.js.map +1 -1
  54. package/build/components/block-types-list/index.native.js +65 -23
  55. package/build/components/block-types-list/index.native.js.map +1 -1
  56. package/build/components/border-radius-control/index.js +2 -0
  57. package/build/components/border-radius-control/index.js.map +1 -1
  58. package/build/components/colors/with-colors.js +1 -1
  59. package/build/components/colors/with-colors.js.map +1 -1
  60. package/build/components/colors-gradients/control.js +46 -39
  61. package/build/components/colors-gradients/control.js.map +1 -1
  62. package/build/components/colors-gradients/dropdown.js +7 -3
  63. package/build/components/colors-gradients/dropdown.js.map +1 -1
  64. package/build/components/date-format-picker/index.js +1 -1
  65. package/build/components/date-format-picker/index.js.map +1 -1
  66. package/build/components/duotone/components.js +145 -0
  67. package/build/components/duotone/components.js.map +1 -0
  68. package/build/components/duotone/index.js +40 -0
  69. package/build/components/duotone/index.js.map +1 -0
  70. package/build/components/duotone/utils.js +38 -0
  71. package/build/components/duotone/utils.js.map +1 -0
  72. package/build/components/duotone-control/index.js +17 -5
  73. package/build/components/duotone-control/index.js.map +1 -1
  74. package/build/components/iframe/index.js +19 -6
  75. package/build/components/iframe/index.js.map +1 -1
  76. package/build/components/image-editor/cropper.js +4 -3
  77. package/build/components/image-editor/cropper.js.map +1 -1
  78. package/build/components/image-editor/index.js +3 -1
  79. package/build/components/image-editor/index.js.map +1 -1
  80. package/build/components/index.js +14 -0
  81. package/build/components/index.js.map +1 -1
  82. package/build/components/inserter/block-types-tab.native.js +30 -16
  83. package/build/components/inserter/block-types-tab.native.js.map +1 -1
  84. package/build/components/inserter/index.js +3 -3
  85. package/build/components/inserter/index.js.map +1 -1
  86. package/build/components/inserter/preview-panel.js +8 -8
  87. package/build/components/inserter/preview-panel.js.map +1 -1
  88. package/build/components/inserter/reusable-blocks-tab.native.js +5 -1
  89. package/build/components/inserter/reusable-blocks-tab.native.js.map +1 -1
  90. package/build/components/inserter/search-results.native.js +5 -2
  91. package/build/components/inserter/search-results.native.js.map +1 -1
  92. package/build/components/inserter/utils.native.js +21 -0
  93. package/build/components/inserter/utils.native.js.map +1 -1
  94. package/build/components/inserter-list-item/index.js +5 -1
  95. package/build/components/inserter-list-item/index.js.map +1 -1
  96. package/build/components/link-control/index.js +1 -1
  97. package/build/components/link-control/index.js.map +1 -1
  98. package/build/components/list-view/block-select-button.js +15 -7
  99. package/build/components/list-view/block-select-button.js.map +1 -1
  100. package/build/components/list-view/branch.js +1 -7
  101. package/build/components/list-view/branch.js.map +1 -1
  102. package/build/components/list-view/drop-indicator.js +1 -1
  103. package/build/components/list-view/drop-indicator.js.map +1 -1
  104. package/build/components/media-placeholder/index.js +14 -2
  105. package/build/components/media-placeholder/index.js.map +1 -1
  106. package/build/components/media-placeholder/index.native.js +4 -4
  107. package/build/components/media-placeholder/index.native.js.map +1 -1
  108. package/build/components/media-replace-flow/index.js +6 -13
  109. package/build/components/media-replace-flow/index.js.map +1 -1
  110. package/build/components/observe-typing/index.js +22 -8
  111. package/build/components/observe-typing/index.js.map +1 -1
  112. package/build/components/publish-date-time-picker/index.js +3 -0
  113. package/build/components/publish-date-time-picker/index.js.map +1 -1
  114. package/build/components/rich-text/format-toolbar-container.js +61 -12
  115. package/build/components/rich-text/format-toolbar-container.js.map +1 -1
  116. package/build/components/rich-text/index.js +2 -1
  117. package/build/components/rich-text/index.js.map +1 -1
  118. package/build/components/rich-text/use-format-types.js +36 -16
  119. package/build/components/rich-text/use-format-types.js.map +1 -1
  120. package/build/components/rich-text/use-input-rules.js +4 -13
  121. package/build/components/rich-text/use-input-rules.js.map +1 -1
  122. package/build/components/rich-text/use-paste-handler.js +20 -5
  123. package/build/components/rich-text/use-paste-handler.js.map +1 -1
  124. package/build/components/url-popover/index.js +2 -1
  125. package/build/components/url-popover/index.js.map +1 -1
  126. package/build/components/writing-flow/use-arrow-nav.js +34 -2
  127. package/build/components/writing-flow/use-arrow-nav.js.map +1 -1
  128. package/build/components/writing-flow/use-multi-selection.js +3 -47
  129. package/build/components/writing-flow/use-multi-selection.js.map +1 -1
  130. package/build/components/writing-flow/use-selection-observer.js +1 -3
  131. package/build/components/writing-flow/use-selection-observer.js.map +1 -1
  132. package/build/components/writing-flow/use-tab-nav.js +1 -1
  133. package/build/components/writing-flow/use-tab-nav.js.map +1 -1
  134. package/build/elements/index.js +11 -3
  135. package/build/elements/index.js.map +1 -1
  136. package/build/hooks/aria-label.js +71 -0
  137. package/build/hooks/aria-label.js.map +1 -0
  138. package/build/hooks/color.js +2 -4
  139. package/build/hooks/color.js.map +1 -1
  140. package/build/hooks/duotone.js +33 -160
  141. package/build/hooks/duotone.js.map +1 -1
  142. package/build/hooks/index.js +11 -7
  143. package/build/hooks/index.js.map +1 -1
  144. package/build/hooks/layout.js +59 -18
  145. package/build/hooks/layout.js.map +1 -1
  146. package/build/hooks/style.js +41 -31
  147. package/build/hooks/style.js.map +1 -1
  148. package/build/hooks/utils.js +5 -3
  149. package/build/hooks/utils.js.map +1 -1
  150. package/build/index.js +7 -7
  151. package/build/index.js.map +1 -1
  152. package/build/layouts/flex.js +42 -38
  153. package/build/layouts/flex.js.map +1 -1
  154. package/build/layouts/flow.js +35 -37
  155. package/build/layouts/flow.js.map +1 -1
  156. package/build/layouts/utils.js +35 -3
  157. package/build/layouts/utils.js.map +1 -1
  158. package/build/store/actions.js +24 -31
  159. package/build/store/actions.js.map +1 -1
  160. package/build/store/index.js +0 -4
  161. package/build/store/index.js.map +1 -1
  162. package/build/store/reducer.js +23 -12
  163. package/build/store/reducer.js.map +1 -1
  164. package/build/store/selectors.js +3 -3
  165. package/build/store/selectors.js.map +1 -1
  166. package/build/utils/selection.js +34 -0
  167. package/build/utils/selection.js.map +1 -0
  168. package/build-module/components/block-list/block-invalid-warning.native.js +50 -6
  169. package/build-module/components/block-list/block-invalid-warning.native.js.map +1 -1
  170. package/build-module/components/block-list/block.js +2 -2
  171. package/build-module/components/block-list/block.js.map +1 -1
  172. package/build-module/components/block-list/block.native.js +2 -1
  173. package/build-module/components/block-list/block.native.js.map +1 -1
  174. package/build-module/components/block-list/index.native.js +3 -1
  175. package/build-module/components/block-list/index.native.js.map +1 -1
  176. package/build-module/components/block-list/layout.js +19 -4
  177. package/build-module/components/block-list/layout.js.map +1 -1
  178. package/build-module/components/block-list/use-block-props/use-block-class-names.js +5 -2
  179. package/build-module/components/block-list/use-block-props/use-block-class-names.js.map +1 -1
  180. package/build-module/components/block-lock/modal.js +39 -8
  181. package/build-module/components/block-lock/modal.js.map +1 -1
  182. package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js +2 -2
  183. package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
  184. package/build-module/components/block-mover/mover-description.js +97 -33
  185. package/build-module/components/block-mover/mover-description.js.map +1 -1
  186. package/build-module/components/block-pattern-setup/index.js +9 -27
  187. package/build-module/components/block-pattern-setup/index.js.map +1 -1
  188. package/build-module/components/block-pattern-setup/setup-toolbar.js +3 -8
  189. package/build-module/components/block-pattern-setup/setup-toolbar.js.map +1 -1
  190. package/build-module/components/block-popover/inbetween.js +1 -1
  191. package/build-module/components/block-popover/inbetween.js.map +1 -1
  192. package/build-module/components/block-popover/index.js +1 -1
  193. package/build-module/components/block-popover/index.js.map +1 -1
  194. package/build-module/components/block-preview/auto.js +20 -5
  195. package/build-module/components/block-preview/auto.js.map +1 -1
  196. package/build-module/components/block-settings-menu/block-edit-visually-button.js +56 -0
  197. package/build-module/components/block-settings-menu/block-edit-visually-button.js.map +1 -0
  198. package/build-module/components/block-settings-menu/block-mode-toggle.js +1 -1
  199. package/build-module/components/block-settings-menu/block-mode-toggle.js.map +1 -1
  200. package/build-module/components/block-settings-menu/block-settings-dropdown.js +6 -5
  201. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  202. package/build-module/components/block-settings-menu/index.js +6 -3
  203. package/build-module/components/block-settings-menu/index.js.map +1 -1
  204. package/build-module/components/block-settings-menu-controls/index.js +7 -4
  205. package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
  206. package/build-module/components/block-styles/preview.native.js.map +1 -1
  207. package/build-module/components/block-switcher/index.js +7 -1
  208. package/build-module/components/block-switcher/index.js.map +1 -1
  209. package/build-module/components/block-title/index.js +8 -2
  210. package/build-module/components/block-title/index.js.map +1 -1
  211. package/build-module/components/block-title/use-block-display-title.js +15 -14
  212. package/build-module/components/block-title/use-block-display-title.js.map +1 -1
  213. package/build-module/components/block-tools/block-contextual-toolbar.js +1 -1
  214. package/build-module/components/block-tools/block-contextual-toolbar.js.map +1 -1
  215. package/build-module/components/block-tools/block-selection-button.js +1 -7
  216. package/build-module/components/block-tools/block-selection-button.js.map +1 -1
  217. package/build-module/components/block-tools/index.js +4 -1
  218. package/build-module/components/block-tools/index.js.map +1 -1
  219. package/build-module/components/block-types-list/index.native.js +67 -25
  220. package/build-module/components/block-types-list/index.native.js.map +1 -1
  221. package/build-module/components/border-radius-control/index.js +2 -0
  222. package/build-module/components/border-radius-control/index.js.map +1 -1
  223. package/build-module/components/colors/with-colors.js +2 -2
  224. package/build-module/components/colors/with-colors.js.map +1 -1
  225. package/build-module/components/colors-gradients/control.js +47 -40
  226. package/build-module/components/colors-gradients/control.js.map +1 -1
  227. package/build-module/components/colors-gradients/dropdown.js +8 -4
  228. package/build-module/components/colors-gradients/dropdown.js.map +1 -1
  229. package/build-module/components/date-format-picker/index.js +1 -1
  230. package/build-module/components/date-format-picker/index.js.map +1 -1
  231. package/build-module/components/duotone/components.js +130 -0
  232. package/build-module/components/duotone/components.js.map +1 -0
  233. package/build-module/components/duotone/index.js +3 -0
  234. package/build-module/components/duotone/index.js.map +1 -0
  235. package/build-module/components/duotone/utils.js +30 -0
  236. package/build-module/components/duotone/utils.js.map +1 -0
  237. package/build-module/components/duotone-control/index.js +18 -6
  238. package/build-module/components/duotone-control/index.js.map +1 -1
  239. package/build-module/components/iframe/index.js +19 -6
  240. package/build-module/components/iframe/index.js.map +1 -1
  241. package/build-module/components/image-editor/cropper.js +4 -3
  242. package/build-module/components/image-editor/cropper.js.map +1 -1
  243. package/build-module/components/image-editor/index.js +3 -1
  244. package/build-module/components/image-editor/index.js.map +1 -1
  245. package/build-module/components/index.js +1 -0
  246. package/build-module/components/index.js.map +1 -1
  247. package/build-module/components/inserter/block-types-tab.native.js +31 -15
  248. package/build-module/components/inserter/block-types-tab.native.js.map +1 -1
  249. package/build-module/components/inserter/index.js +3 -2
  250. package/build-module/components/inserter/index.js.map +1 -1
  251. package/build-module/components/inserter/preview-panel.js +9 -9
  252. package/build-module/components/inserter/preview-panel.js.map +1 -1
  253. package/build-module/components/inserter/reusable-blocks-tab.native.js +6 -2
  254. package/build-module/components/inserter/reusable-blocks-tab.native.js.map +1 -1
  255. package/build-module/components/inserter/search-results.native.js +6 -3
  256. package/build-module/components/inserter/search-results.native.js.map +1 -1
  257. package/build-module/components/inserter/utils.native.js +19 -0
  258. package/build-module/components/inserter/utils.native.js.map +1 -1
  259. package/build-module/components/inserter-list-item/index.js +4 -1
  260. package/build-module/components/inserter-list-item/index.js.map +1 -1
  261. package/build-module/components/link-control/index.js +1 -1
  262. package/build-module/components/link-control/index.js.map +1 -1
  263. package/build-module/components/list-view/block-select-button.js +16 -8
  264. package/build-module/components/list-view/block-select-button.js.map +1 -1
  265. package/build-module/components/list-view/branch.js +1 -6
  266. package/build-module/components/list-view/branch.js.map +1 -1
  267. package/build-module/components/list-view/drop-indicator.js +1 -1
  268. package/build-module/components/list-view/drop-indicator.js.map +1 -1
  269. package/build-module/components/media-placeholder/index.js +14 -2
  270. package/build-module/components/media-placeholder/index.js.map +1 -1
  271. package/build-module/components/media-placeholder/index.native.js +5 -3
  272. package/build-module/components/media-placeholder/index.native.js.map +1 -1
  273. package/build-module/components/media-replace-flow/index.js +7 -13
  274. package/build-module/components/media-replace-flow/index.js.map +1 -1
  275. package/build-module/components/observe-typing/index.js +22 -8
  276. package/build-module/components/observe-typing/index.js.map +1 -1
  277. package/build-module/components/publish-date-time-picker/index.js +2 -0
  278. package/build-module/components/publish-date-time-picker/index.js.map +1 -1
  279. package/build-module/components/rich-text/format-toolbar-container.js +58 -12
  280. package/build-module/components/rich-text/format-toolbar-container.js.map +1 -1
  281. package/build-module/components/rich-text/index.js +2 -1
  282. package/build-module/components/rich-text/index.js.map +1 -1
  283. package/build-module/components/rich-text/use-format-types.js +37 -18
  284. package/build-module/components/rich-text/use-format-types.js.map +1 -1
  285. package/build-module/components/rich-text/use-input-rules.js +3 -11
  286. package/build-module/components/rich-text/use-input-rules.js.map +1 -1
  287. package/build-module/components/rich-text/use-paste-handler.js +20 -5
  288. package/build-module/components/rich-text/use-paste-handler.js.map +1 -1
  289. package/build-module/components/url-popover/index.js +2 -1
  290. package/build-module/components/url-popover/index.js.map +1 -1
  291. package/build-module/components/writing-flow/use-arrow-nav.js +35 -3
  292. package/build-module/components/writing-flow/use-arrow-nav.js.map +1 -1
  293. package/build-module/components/writing-flow/use-multi-selection.js +3 -45
  294. package/build-module/components/writing-flow/use-multi-selection.js.map +1 -1
  295. package/build-module/components/writing-flow/use-selection-observer.js +1 -3
  296. package/build-module/components/writing-flow/use-selection-observer.js.map +1 -1
  297. package/build-module/components/writing-flow/use-tab-nav.js +1 -1
  298. package/build-module/components/writing-flow/use-tab-nav.js.map +1 -1
  299. package/build-module/elements/index.js +7 -1
  300. package/build-module/elements/index.js.map +1 -1
  301. package/build-module/hooks/aria-label.js +59 -0
  302. package/build-module/hooks/aria-label.js.map +1 -0
  303. package/build-module/hooks/color.js +2 -3
  304. package/build-module/hooks/color.js.map +1 -1
  305. package/build-module/hooks/duotone.js +22 -140
  306. package/build-module/hooks/duotone.js.map +1 -1
  307. package/build-module/hooks/index.js +2 -1
  308. package/build-module/hooks/index.js.map +1 -1
  309. package/build-module/hooks/layout.js +60 -19
  310. package/build-module/hooks/layout.js.map +1 -1
  311. package/build-module/hooks/style.js +44 -35
  312. package/build-module/hooks/style.js.map +1 -1
  313. package/build-module/hooks/utils.js +5 -2
  314. package/build-module/hooks/utils.js.map +1 -1
  315. package/build-module/index.js +1 -1
  316. package/build-module/index.js.map +1 -1
  317. package/build-module/layouts/flex.js +43 -35
  318. package/build-module/layouts/flex.js.map +1 -1
  319. package/build-module/layouts/flow.js +35 -38
  320. package/build-module/layouts/flow.js.map +1 -1
  321. package/build-module/layouts/utils.js +33 -3
  322. package/build-module/layouts/utils.js.map +1 -1
  323. package/build-module/store/actions.js +14 -20
  324. package/build-module/store/actions.js.map +1 -1
  325. package/build-module/store/index.js +0 -4
  326. package/build-module/store/index.js.map +1 -1
  327. package/build-module/store/reducer.js +23 -11
  328. package/build-module/store/reducer.js.map +1 -1
  329. package/build-module/store/selectors.js +4 -4
  330. package/build-module/store/selectors.js.map +1 -1
  331. package/build-module/utils/selection.js +24 -0
  332. package/build-module/utils/selection.js.map +1 -0
  333. package/build-style/style-rtl.css +43 -13
  334. package/build-style/style.css +43 -13
  335. package/package.json +28 -28
  336. package/src/components/block-draggable/test/helpers.native.js +3 -3
  337. package/src/components/block-list/block-invalid-warning.native.js +42 -7
  338. package/src/components/block-list/block.js +2 -2
  339. package/src/components/block-list/block.native.js +1 -0
  340. package/src/components/block-list/index.native.js +1 -1
  341. package/src/components/block-list/layout.js +15 -3
  342. package/src/components/block-list/style.scss +2 -2
  343. package/src/components/block-list/use-block-props/use-block-class-names.js +5 -1
  344. package/src/components/block-lock/modal.js +47 -9
  345. package/src/components/block-lock/style.scss +10 -0
  346. package/src/components/block-mobile-toolbar/block-actions-menu.native.js +3 -3
  347. package/src/components/block-mover/mover-description.js +131 -48
  348. package/src/components/block-mover/test/mover-description.js +55 -3
  349. package/src/components/block-pattern-setup/index.js +5 -25
  350. package/src/components/block-pattern-setup/setup-toolbar.js +2 -9
  351. package/src/components/block-pattern-setup/style.scss +4 -2
  352. package/src/components/block-popover/inbetween.js +1 -1
  353. package/src/components/block-popover/index.js +1 -1
  354. package/src/components/block-preview/auto.js +17 -3
  355. package/src/components/block-settings-menu/block-edit-visually-button.js +52 -0
  356. package/src/components/block-settings-menu/block-mode-toggle.js +1 -0
  357. package/src/components/block-settings-menu/block-settings-dropdown.js +7 -3
  358. package/src/components/block-settings-menu/index.js +15 -11
  359. package/src/components/block-settings-menu-controls/index.js +5 -4
  360. package/src/components/block-styles/preview.native.js +1 -0
  361. package/src/components/block-switcher/index.js +7 -1
  362. package/src/components/block-title/index.js +3 -2
  363. package/src/components/block-title/use-block-display-title.js +20 -12
  364. package/src/components/block-tools/block-contextual-toolbar.js +3 -1
  365. package/src/components/block-tools/block-selection-button.js +0 -5
  366. package/src/components/block-tools/index.js +4 -1
  367. package/src/components/block-types-list/index.native.js +76 -24
  368. package/src/components/block-types-list/style.native.scss +18 -0
  369. package/src/components/border-radius-control/index.js +2 -0
  370. package/src/components/color-palette/test/__snapshots__/control.js.snap +0 -4
  371. package/src/components/colors/test/__snapshots__/with-colors.js.snap +1 -1
  372. package/src/components/colors/test/with-colors.js +1 -1
  373. package/src/components/colors/with-colors.js +2 -2
  374. package/src/components/colors-gradients/control.js +78 -65
  375. package/src/components/colors-gradients/dropdown.js +9 -2
  376. package/src/components/colors-gradients/style.scss +11 -8
  377. package/src/components/colors-gradients/test/control.js +16 -23
  378. package/src/components/date-format-picker/index.js +1 -0
  379. package/src/components/duotone/components.js +133 -0
  380. package/src/components/duotone/index.js +7 -0
  381. package/src/components/duotone/utils.js +25 -0
  382. package/src/components/duotone-control/index.js +12 -7
  383. package/src/components/duotone-control/style.scss +5 -0
  384. package/src/components/iframe/index.js +25 -6
  385. package/src/components/image-editor/cropper.js +9 -3
  386. package/src/components/image-editor/index.js +2 -0
  387. package/src/components/index.js +1 -0
  388. package/src/components/inserter/block-types-tab.native.js +42 -21
  389. package/src/components/inserter/index.js +3 -5
  390. package/src/components/inserter/preview-panel.js +6 -14
  391. package/src/components/inserter/reusable-blocks-tab.native.js +4 -2
  392. package/src/components/inserter/search-results.native.js +4 -2
  393. package/src/components/inserter/style.scss +1 -1
  394. package/src/components/inserter/test/block-types-tab.native.js +2 -0
  395. package/src/components/inserter/test/utils.native.js +37 -0
  396. package/src/components/inserter/utils.native.js +11 -0
  397. package/src/components/inserter-list-item/index.js +4 -1
  398. package/src/components/link-control/index.js +1 -0
  399. package/src/components/link-control/test/fixtures/index.js +3 -4
  400. package/src/components/link-control/test/index.js +64 -73
  401. package/src/components/list-view/block-select-button.js +29 -14
  402. package/src/components/list-view/branch.js +1 -6
  403. package/src/components/list-view/drop-indicator.js +1 -1
  404. package/src/components/list-view/style.scss +18 -4
  405. package/src/components/media-placeholder/index.js +20 -0
  406. package/src/components/media-placeholder/index.native.js +9 -5
  407. package/src/components/media-replace-flow/index.js +5 -14
  408. package/src/components/media-replace-flow/test/index.js +14 -4
  409. package/src/components/media-upload/README.md +8 -0
  410. package/src/components/observe-typing/index.js +17 -14
  411. package/src/components/publish-date-time-picker/index.js +2 -0
  412. package/src/components/responsive-block-control/README.md +3 -1
  413. package/src/components/responsive-block-control/test/index.js +1 -2
  414. package/src/components/rich-text/format-toolbar-container.js +63 -14
  415. package/src/components/rich-text/index.js +1 -0
  416. package/src/components/rich-text/use-format-types.js +38 -17
  417. package/src/components/rich-text/use-input-rules.js +6 -15
  418. package/src/components/rich-text/use-paste-handler.js +17 -5
  419. package/src/components/url-popover/index.js +1 -0
  420. package/src/components/url-popover/test/__snapshots__/index.js.snap +3 -0
  421. package/src/components/writing-flow/use-arrow-nav.js +32 -1
  422. package/src/components/writing-flow/use-multi-selection.js +1 -48
  423. package/src/components/writing-flow/use-selection-observer.js +2 -3
  424. package/src/components/writing-flow/use-tab-nav.js +1 -1
  425. package/src/elements/index.js +8 -1
  426. package/src/elements/test/index.js +18 -0
  427. package/src/hooks/aria-label.js +67 -0
  428. package/src/hooks/color.js +10 -3
  429. package/src/hooks/duotone.js +18 -139
  430. package/src/hooks/index.js +2 -1
  431. package/src/hooks/layout.js +77 -29
  432. package/src/hooks/style.js +46 -39
  433. package/src/hooks/utils.js +7 -3
  434. package/src/index.js +1 -1
  435. package/src/layouts/flex.js +49 -43
  436. package/src/layouts/flow.js +35 -34
  437. package/src/layouts/test/flex.js +21 -0
  438. package/src/layouts/test/flow.js +21 -0
  439. package/src/layouts/test/utils.js +138 -0
  440. package/src/layouts/utils.js +44 -3
  441. package/src/store/actions.js +17 -31
  442. package/src/store/index.js +0 -4
  443. package/src/store/reducer.js +24 -11
  444. package/src/store/selectors.js +3 -4
  445. package/src/store/test/reducer.js +138 -10
  446. package/src/store/test/selectors.js +3 -6
  447. package/src/utils/selection.js +26 -0
  448. package/src/utils/test/selection.js +39 -0
  449. package/tsconfig.json +2 -1
@@ -83,6 +83,10 @@ function getInlineStyles() {
83
83
  const ignoredStyles = ['spacing.blockGap'];
84
84
  const output = {};
85
85
  Object.keys(_blocks.__EXPERIMENTAL_STYLE_PROPERTY).forEach(propKey => {
86
+ if (_blocks.__EXPERIMENTAL_STYLE_PROPERTY[propKey].rootOnly) {
87
+ return;
88
+ }
89
+
86
90
  const path = _blocks.__EXPERIMENTAL_STYLE_PROPERTY[propKey].value;
87
91
  const subPaths = _blocks.__EXPERIMENTAL_STYLE_PROPERTY[propKey].properties; // Ignore styles on elements because they are handled on the server.
88
92
 
@@ -115,26 +119,6 @@ function getInlineStyles() {
115
119
  });
116
120
  return output;
117
121
  }
118
-
119
- function compileElementsStyles(selector) {
120
- let elements = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
121
- return Object.entries(elements).map(_ref => {
122
- let [element, styles] = _ref;
123
- const elementStyles = getInlineStyles(styles);
124
-
125
- if (!(0, _lodash.isEmpty)(elementStyles)) {
126
- // The .editor-styles-wrapper selector is required on elements styles. As it is
127
- // added to all other editor styles, not providing it causes reset and global
128
- // styles to override element styles because of higher specificity.
129
- return [`.editor-styles-wrapper .${selector} ${_blocks.__EXPERIMENTAL_ELEMENTS[element]}{`, ...Object.entries(elementStyles).map(_ref2 => {
130
- let [cssProperty, value] = _ref2;
131
- return `\t${(0, _lodash.kebabCase)(cssProperty)}: ${value};`;
132
- }), '}'].join('\n');
133
- }
134
-
135
- return '';
136
- }).join('\n');
137
- }
138
122
  /**
139
123
  * Filters registered block settings, extending attributes to include `style` attribute.
140
124
  *
@@ -227,8 +211,8 @@ function addSaveProps(props, blockType, attributes) {
227
211
  let {
228
212
  style
229
213
  } = attributes;
230
- Object.entries(skipPaths).forEach(_ref3 => {
231
- let [indicator, path] = _ref3;
214
+ Object.entries(skipPaths).forEach(_ref => {
215
+ let [indicator, path] = _ref;
232
216
  const skipSerialization = (0, _blocks.getBlockSupport)(blockType, indicator);
233
217
 
234
218
  if (skipSerialization === true) {
@@ -299,23 +283,49 @@ const withBlockControls = (0, _compose.createHigherOrderComponent)(BlockEdit =>
299
283
 
300
284
  exports.withBlockControls = withBlockControls;
301
285
  const withElementsStyles = (0, _compose.createHigherOrderComponent)(BlockListBlock => props => {
302
- var _props$attributes$sty, _props$attributes$sty2;
286
+ var _props$attributes$sty2, _props$attributes$sty3;
303
287
 
304
288
  const blockElementsContainerIdentifier = `wp-elements-${(0, _compose.useInstanceId)(BlockListBlock)}`;
305
- const skipLinkColorSerialization = (0, _utils.shouldSkipSerialization)(props.name, _color.COLOR_SUPPORT_KEY, 'link'); // The Elements API only supports link colors for now,
306
- // hence the specific omission of `link` in the elements styles.
307
- // This might need to be refactored or removed if the Elements API
308
- // changes or `link` supports styles beyond `color`.
289
+ const skipLinkColorSerialization = (0, _utils.shouldSkipSerialization)(props.name, _color.COLOR_SUPPORT_KEY, 'link');
290
+ const styles = (0, _element.useMemo)(() => {
291
+ var _props$attributes$sty;
292
+
293
+ const rawElementsStyles = (_props$attributes$sty = props.attributes.style) === null || _props$attributes$sty === void 0 ? void 0 : _props$attributes$sty.elements;
294
+ const elementCssRules = [];
295
+
296
+ if (rawElementsStyles && Object.keys(rawElementsStyles).length > 0) {
297
+ var _rawElementsStyles$li;
298
+
299
+ // Remove values based on whether serialization has been skipped for a specific style.
300
+ const filteredElementsStyles = { ...rawElementsStyles,
301
+ link: { ...rawElementsStyles.link,
302
+ color: !skipLinkColorSerialization ? (_rawElementsStyles$li = rawElementsStyles.link) === null || _rawElementsStyles$li === void 0 ? void 0 : _rawElementsStyles$li.color : undefined
303
+ }
304
+ };
305
+
306
+ for (const [elementName, elementStyles] of Object.entries(filteredElementsStyles)) {
307
+ const cssRule = (0, _styleEngine.generate)(elementStyles, {
308
+ // The .editor-styles-wrapper selector is required on elements styles. As it is
309
+ // added to all other editor styles, not providing it causes reset and global
310
+ // styles to override element styles because of higher specificity.
311
+ selector: `.editor-styles-wrapper .${blockElementsContainerIdentifier} ${_blocks.__EXPERIMENTAL_ELEMENTS[elementName]}`
312
+ });
313
+
314
+ if (!!cssRule) {
315
+ elementCssRules.push(cssRule);
316
+ }
317
+ }
318
+ }
309
319
 
310
- const elements = skipLinkColorSerialization ? (0, _lodash.omit)((_props$attributes$sty = props.attributes.style) === null || _props$attributes$sty === void 0 ? void 0 : _props$attributes$sty.elements, ['link']) : (_props$attributes$sty2 = props.attributes.style) === null || _props$attributes$sty2 === void 0 ? void 0 : _props$attributes$sty2.elements;
311
- const styles = compileElementsStyles(blockElementsContainerIdentifier, elements);
320
+ return elementCssRules.length > 0 ? elementCssRules : undefined;
321
+ }, [(_props$attributes$sty2 = props.attributes.style) === null || _props$attributes$sty2 === void 0 ? void 0 : _props$attributes$sty2.elements]);
312
322
  const element = (0, _element.useContext)(_blockList.default.__unstableElementContext);
313
- return (0, _element.createElement)(_element.Fragment, null, elements && element && (0, _element.createPortal)((0, _element.createElement)("style", {
323
+ return (0, _element.createElement)(_element.Fragment, null, styles && element && (0, _element.createPortal)((0, _element.createElement)("style", {
314
324
  dangerouslySetInnerHTML: {
315
325
  __html: styles
316
326
  }
317
327
  }), element), (0, _element.createElement)(BlockListBlock, (0, _extends2.default)({}, props, {
318
- className: elements ? (0, _classnames.default)(props.className, blockElementsContainerIdentifier) : props.className
328
+ className: (_props$attributes$sty3 = props.attributes.style) !== null && _props$attributes$sty3 !== void 0 && _props$attributes$sty3.elements ? (0, _classnames.default)(props.className, blockElementsContainerIdentifier) : props.className
319
329
  })));
320
330
  });
321
331
  (0, _hooks.addFilter)('blocks.registerBlockType', 'core/style/addAttribute', addAttribute);
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/hooks/style.js"],"names":["styleSupportKeys","TYPOGRAPHY_SUPPORT_KEYS","BORDER_SUPPORT_KEY","COLOR_SUPPORT_KEY","SPACING_SUPPORT_KEY","hasStyleSupport","blockType","some","key","VARIABLE_REFERENCE_PREFIX","VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE","VARIABLE_PATH_SEPARATOR_TOKEN_STYLE","compileStyleValue","uncompiledValue","startsWith","variable","slice","length","split","join","getInlineStyles","styles","ignoredStyles","output","Object","keys","STYLE_PROPERTY","forEach","propKey","path","value","subPaths","properties","styleValue","useEngine","entries","entry","name","subPath","includes","extraRules","rule","compileElementsStyles","selector","elements","map","element","elementStyles","ELEMENTS","cssProperty","addAttribute","settings","attributes","style","assign","type","skipSerializationPathsEdit","TYPOGRAPHY_SUPPORT_KEY","skipSerializationPathsSave","renamedFeatures","gradients","addSaveProps","props","skipPaths","indicator","skipSerialization","Array","isArray","featureName","feature","addEditProps","existingGetEditWrapperProps","getEditWrapperProps","withBlockControls","BlockEdit","shouldDisplayControls","withElementsStyles","BlockListBlock","blockElementsContainerIdentifier","skipLinkColorSerialization","BlockList","__unstableElementContext","__html","className"],"mappings":";;;;;;;;;;;;AASA;;;;AANA;;AACA;;AAMA;;AACA;;AAMA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AAjCA;AACA;AACA;;AAIA;AACA;AACA;;AAYA;AACA;AACA;AAaA,MAAMA,gBAAgB,GAAG,CACxB,GAAGC,mCADqB,EAExBC,0BAFwB,EAGxBC,wBAHwB,EAIxBC,+BAJwB,CAAzB;;AAOA,MAAMC,eAAe,GAAKC,SAAF,IACvBN,gBAAgB,CAACO,IAAjB,CAAyBC,GAAF,IAAW,6BAAiBF,SAAjB,EAA4BE,GAA5B,CAAlC,CADD;;AAGA,MAAMC,yBAAyB,GAAG,MAAlC;AACA,MAAMC,uCAAuC,GAAG,GAAhD;AACA,MAAMC,mCAAmC,GAAG,IAA5C;;AACA,SAASC,iBAAT,CAA4BC,eAA5B,EAA8C;AAAA;;AAC7C,MAAKA,eAAL,aAAKA,eAAL,wCAAKA,eAAe,CAAEC,UAAtB,kDAAK,2BAAAD,eAAe,EAAgBJ,yBAAhB,CAApB,EAAkE;AACjE,UAAMM,QAAQ,GAAGF,eAAe,CAC9BG,KADe,CACRP,yBAAyB,CAACQ,MADlB,EAEfC,KAFe,CAERR,uCAFQ,EAGfS,IAHe,CAGTR,mCAHS,CAAjB;AAIA,WAAQ,aAAaI,QAAU,GAA/B;AACA;;AACD,SAAOF,eAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASO,eAAT,GAAwC;AAAA,MAAdC,MAAc,uEAAL,EAAK;AAC9C,QAAMC,aAAa,GAAG,CAAE,kBAAF,CAAtB;AACA,QAAMC,MAAM,GAAG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D,EAGCS,YAHD;AAMA,sBACC,kBADD,EAEC,gCAFD,EAGCG,iBAHD;AAMA,sBACC,uBADD,EAEC,kCAFD,EAGCG,kBAHD","sourcesContent":["/**\n * External dependencies\n */\nimport { get, has, isEmpty, kebabCase, omit } from 'lodash';\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useContext, createPortal } from '@wordpress/element';\nimport { addFilter } from '@wordpress/hooks';\nimport {\n\tgetBlockSupport,\n\thasBlockSupport,\n\t__EXPERIMENTAL_STYLE_PROPERTY as STYLE_PROPERTY,\n\t__EXPERIMENTAL_ELEMENTS as ELEMENTS,\n} from '@wordpress/blocks';\nimport { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';\nimport { getCSSRules } from '@wordpress/style-engine';\n\n/**\n * Internal dependencies\n */\nimport BlockList from '../components/block-list';\nimport { BORDER_SUPPORT_KEY, BorderPanel } from './border';\nimport { COLOR_SUPPORT_KEY, ColorEdit } from './color';\nimport {\n\tTypographyPanel,\n\tTYPOGRAPHY_SUPPORT_KEY,\n\tTYPOGRAPHY_SUPPORT_KEYS,\n} from './typography';\nimport { SPACING_SUPPORT_KEY, DimensionsPanel } from './dimensions';\nimport useDisplayBlockControls from '../components/use-display-block-controls';\nimport { shouldSkipSerialization } from './utils';\n\nconst styleSupportKeys = [\n\t...TYPOGRAPHY_SUPPORT_KEYS,\n\tBORDER_SUPPORT_KEY,\n\tCOLOR_SUPPORT_KEY,\n\tSPACING_SUPPORT_KEY,\n];\n\nconst hasStyleSupport = ( blockType ) =>\n\tstyleSupportKeys.some( ( key ) => hasBlockSupport( blockType, key ) );\n\nconst VARIABLE_REFERENCE_PREFIX = 'var:';\nconst VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE = '|';\nconst VARIABLE_PATH_SEPARATOR_TOKEN_STYLE = '--';\nfunction compileStyleValue( uncompiledValue ) {\n\tif ( uncompiledValue?.startsWith?.( VARIABLE_REFERENCE_PREFIX ) ) {\n\t\tconst variable = uncompiledValue\n\t\t\t.slice( VARIABLE_REFERENCE_PREFIX.length )\n\t\t\t.split( VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE )\n\t\t\t.join( VARIABLE_PATH_SEPARATOR_TOKEN_STYLE );\n\t\treturn `var(--wp--${ variable })`;\n\t}\n\treturn uncompiledValue;\n}\n\n/**\n * Returns the inline styles to add depending on the style object\n *\n * @param {Object} styles Styles configuration.\n *\n * @return {Object} Flattened CSS variables declaration.\n */\nexport function getInlineStyles( styles = {} ) {\n\tconst ignoredStyles = [ 'spacing.blockGap' ];\n\tconst output = {};\n\tObject.keys( STYLE_PROPERTY ).forEach( ( propKey ) => {\n\t\tconst path = STYLE_PROPERTY[ propKey ].value;\n\t\tconst subPaths = STYLE_PROPERTY[ propKey ].properties;\n\t\t// Ignore styles on elements because they are handled on the server.\n\t\tif ( has( styles, path ) && 'elements' !== path?.[ 0 ] ) {\n\t\t\t// Checking if style value is a string allows for shorthand css\n\t\t\t// option and backwards compatibility for border radius support.\n\t\t\tconst styleValue = get( styles, path );\n\n\t\t\tif ( ! STYLE_PROPERTY[ propKey ].useEngine ) {\n\t\t\t\tif ( !! subPaths && typeof styleValue !== 'string' ) {\n\t\t\t\t\tObject.entries( subPaths ).forEach( ( entry ) => {\n\t\t\t\t\t\tconst [ name, subPath ] = entry;\n\t\t\t\t\t\tconst value = get( styleValue, [ subPath ] );\n\n\t\t\t\t\t\tif ( value ) {\n\t\t\t\t\t\t\toutput[ name ] = compileStyleValue( value );\n\t\t\t\t\t\t}\n\t\t\t\t\t} );\n\t\t\t\t} else if ( ! ignoredStyles.includes( path.join( '.' ) ) ) {\n\t\t\t\t\toutput[ propKey ] = compileStyleValue(\n\t\t\t\t\t\tget( styles, path )\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} );\n\n\t// The goal is to move everything to server side generated engine styles\n\t// This is temporary as we absorb more and more styles into the engine.\n\tconst extraRules = getCSSRules( styles );\n\textraRules.forEach( ( rule ) => {\n\t\toutput[ rule.key ] = rule.value;\n\t} );\n\n\treturn output;\n}\n\nfunction compileElementsStyles( selector, elements = {} ) {\n\treturn Object.entries( elements )\n\t\t.map( ( [ element, styles ] ) => {\n\t\t\tconst elementStyles = getInlineStyles( styles );\n\t\t\tif ( ! isEmpty( elementStyles ) ) {\n\t\t\t\t// The .editor-styles-wrapper selector is required on elements styles. As it is\n\t\t\t\t// added to all other editor styles, not providing it causes reset and global\n\t\t\t\t// styles to override element styles because of higher specificity.\n\t\t\t\treturn [\n\t\t\t\t\t`.editor-styles-wrapper .${ selector } ${ ELEMENTS[ element ] }{`,\n\t\t\t\t\t...Object.entries( elementStyles ).map(\n\t\t\t\t\t\t( [ cssProperty, value ] ) =>\n\t\t\t\t\t\t\t`\\t${ kebabCase( cssProperty ) }: ${ value };`\n\t\t\t\t\t),\n\t\t\t\t\t'}',\n\t\t\t\t].join( '\\n' );\n\t\t\t}\n\t\t\treturn '';\n\t\t} )\n\t\t.join( '\\n' );\n}\n\n/**\n * Filters registered block settings, extending attributes to include `style` attribute.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nfunction addAttribute( settings ) {\n\tif ( ! hasStyleSupport( settings ) ) {\n\t\treturn settings;\n\t}\n\n\t// Allow blocks to specify their own attribute definition with default values if needed.\n\tif ( ! settings.attributes.style ) {\n\t\tObject.assign( settings.attributes, {\n\t\t\tstyle: {\n\t\t\t\ttype: 'object',\n\t\t\t},\n\t\t} );\n\t}\n\n\treturn settings;\n}\n\n/**\n * A dictionary of paths to flag skipping block support serialization as the key,\n * with values providing the style paths to be omitted from serialization.\n *\n * @constant\n * @type {Record<string, string[]>}\n */\nconst skipSerializationPathsEdit = {\n\t[ `${ BORDER_SUPPORT_KEY }.__experimentalSkipSerialization` ]: [ 'border' ],\n\t[ `${ COLOR_SUPPORT_KEY }.__experimentalSkipSerialization` ]: [\n\t\tCOLOR_SUPPORT_KEY,\n\t],\n\t[ `${ TYPOGRAPHY_SUPPORT_KEY }.__experimentalSkipSerialization` ]: [\n\t\tTYPOGRAPHY_SUPPORT_KEY,\n\t],\n\t[ `${ SPACING_SUPPORT_KEY }.__experimentalSkipSerialization` ]: [\n\t\t'spacing',\n\t],\n};\n\n/**\n * A dictionary of paths to flag skipping block support serialization as the key,\n * with values providing the style paths to be omitted from serialization.\n *\n * Extends the Edit skip paths to enable skipping additional paths in just\n * the Save component. This allows a block support to be serialized within the\n * editor, while using an alternate approach, such as server-side rendering, when\n * the support is saved.\n *\n * @constant\n * @type {Record<string, string[]>}\n */\nconst skipSerializationPathsSave = {\n\t...skipSerializationPathsEdit,\n\t[ `${ SPACING_SUPPORT_KEY }` ]: [ 'spacing.blockGap' ],\n};\n\n/**\n * A dictionary used to normalize feature names between support flags, style\n * object properties and __experimentSkipSerialization configuration arrays.\n *\n * This allows not having to provide a migration for a support flag and possible\n * backwards compatibility bridges, while still achieving consistency between\n * the support flag and the skip serialization array.\n *\n * @constant\n * @type {Record<string, string>}\n */\nconst renamedFeatures = { gradients: 'gradient' };\n\n/**\n * Override props assigned to save component to inject the CSS variables definition.\n *\n * @param {Object} props Additional props applied to save element.\n * @param {Object} blockType Block type.\n * @param {Object} attributes Block attributes.\n * @param {?Record<string, string[]>} skipPaths An object of keys and paths to skip serialization.\n *\n * @return {Object} Filtered props applied to save element.\n */\nexport function addSaveProps(\n\tprops,\n\tblockType,\n\tattributes,\n\tskipPaths = skipSerializationPathsSave\n) {\n\tif ( ! hasStyleSupport( blockType ) ) {\n\t\treturn props;\n\t}\n\n\tlet { style } = attributes;\n\tObject.entries( skipPaths ).forEach( ( [ indicator, path ] ) => {\n\t\tconst skipSerialization = getBlockSupport( blockType, indicator );\n\n\t\tif ( skipSerialization === true ) {\n\t\t\tstyle = omit( style, path );\n\t\t}\n\n\t\tif ( Array.isArray( skipSerialization ) ) {\n\t\t\tskipSerialization.forEach( ( featureName ) => {\n\t\t\t\tconst feature = renamedFeatures[ featureName ] || featureName;\n\t\t\t\tstyle = omit( style, [ [ ...path, feature ] ] );\n\t\t\t} );\n\t\t}\n\t} );\n\n\tprops.style = {\n\t\t...getInlineStyles( style ),\n\t\t...props.style,\n\t};\n\n\treturn props;\n}\n\n/**\n * Filters registered block settings to extend the block edit wrapper\n * to apply the desired styles and classnames properly.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object}.Filtered block settings.\n */\nexport function addEditProps( settings ) {\n\tif ( ! hasStyleSupport( settings ) ) {\n\t\treturn settings;\n\t}\n\n\tconst existingGetEditWrapperProps = settings.getEditWrapperProps;\n\tsettings.getEditWrapperProps = ( attributes ) => {\n\t\tlet props = {};\n\t\tif ( existingGetEditWrapperProps ) {\n\t\t\tprops = existingGetEditWrapperProps( attributes );\n\t\t}\n\n\t\treturn addSaveProps(\n\t\t\tprops,\n\t\t\tsettings,\n\t\t\tattributes,\n\t\t\tskipSerializationPathsEdit\n\t\t);\n\t};\n\n\treturn settings;\n}\n\n/**\n * Override the default edit UI to include new inspector controls for\n * all the custom styles configs.\n *\n * @param {Function} BlockEdit Original component.\n *\n * @return {Function} Wrapped component.\n */\nexport const withBlockControls = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tconst shouldDisplayControls = useDisplayBlockControls();\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ shouldDisplayControls && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<ColorEdit { ...props } />\n\t\t\t\t\t\t<TypographyPanel { ...props } />\n\t\t\t\t\t\t<BorderPanel { ...props } />\n\t\t\t\t\t\t<DimensionsPanel { ...props } />\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t\t<BlockEdit { ...props } />\n\t\t\t</>\n\t\t);\n\t},\n\t'withToolbarControls'\n);\n\n/**\n * Override the default block element to include duotone styles.\n *\n * @param {Function} BlockListBlock Original component\n * @return {Function} Wrapped component\n */\nconst withElementsStyles = createHigherOrderComponent(\n\t( BlockListBlock ) => ( props ) => {\n\t\tconst blockElementsContainerIdentifier = `wp-elements-${ useInstanceId(\n\t\t\tBlockListBlock\n\t\t) }`;\n\n\t\tconst skipLinkColorSerialization = shouldSkipSerialization(\n\t\t\tprops.name,\n\t\t\tCOLOR_SUPPORT_KEY,\n\t\t\t'link'\n\t\t);\n\n\t\t// The Elements API only supports link colors for now,\n\t\t// hence the specific omission of `link` in the elements styles.\n\t\t// This might need to be refactored or removed if the Elements API\n\t\t// changes or `link` supports styles beyond `color`.\n\t\tconst elements = skipLinkColorSerialization\n\t\t\t? omit( props.attributes.style?.elements, [ 'link' ] )\n\t\t\t: props.attributes.style?.elements;\n\n\t\tconst styles = compileElementsStyles(\n\t\t\tblockElementsContainerIdentifier,\n\t\t\telements\n\t\t);\n\t\tconst element = useContext( BlockList.__unstableElementContext );\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ elements &&\n\t\t\t\t\telement &&\n\t\t\t\t\tcreatePortal(\n\t\t\t\t\t\t<style\n\t\t\t\t\t\t\tdangerouslySetInnerHTML={ {\n\t\t\t\t\t\t\t\t__html: styles,\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>,\n\t\t\t\t\t\telement\n\t\t\t\t\t) }\n\n\t\t\t\t<BlockListBlock\n\t\t\t\t\t{ ...props }\n\t\t\t\t\tclassName={\n\t\t\t\t\t\telements\n\t\t\t\t\t\t\t? classnames(\n\t\t\t\t\t\t\t\t\tprops.className,\n\t\t\t\t\t\t\t\t\tblockElementsContainerIdentifier\n\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t: props.className\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t</>\n\t\t);\n\t}\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/style/addAttribute',\n\taddAttribute\n);\n\naddFilter(\n\t'blocks.getSaveContent.extraProps',\n\t'core/style/addSaveProps',\n\taddSaveProps\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/style/addEditProps',\n\taddEditProps\n);\n\naddFilter(\n\t'editor.BlockEdit',\n\t'core/style/with-block-controls',\n\twithBlockControls\n);\n\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/editor/with-elements-styles',\n\twithElementsStyles\n);\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/hooks/style.js"],"names":["styleSupportKeys","TYPOGRAPHY_SUPPORT_KEYS","BORDER_SUPPORT_KEY","COLOR_SUPPORT_KEY","SPACING_SUPPORT_KEY","hasStyleSupport","blockType","some","key","VARIABLE_REFERENCE_PREFIX","VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE","VARIABLE_PATH_SEPARATOR_TOKEN_STYLE","compileStyleValue","uncompiledValue","startsWith","variable","slice","length","split","join","getInlineStyles","styles","ignoredStyles","output","Object","keys","STYLE_PROPERTY","forEach","propKey","rootOnly","path","value","subPaths","properties","styleValue","useEngine","entries","entry","name","subPath","includes","extraRules","rule","addAttribute","settings","attributes","style","assign","type","skipSerializationPathsEdit","TYPOGRAPHY_SUPPORT_KEY","skipSerializationPathsSave","renamedFeatures","gradients","addSaveProps","props","skipPaths","indicator","skipSerialization","Array","isArray","featureName","feature","addEditProps","existingGetEditWrapperProps","getEditWrapperProps","withBlockControls","BlockEdit","shouldDisplayControls","withElementsStyles","BlockListBlock","blockElementsContainerIdentifier","skipLinkColorSerialization","rawElementsStyles","elements","elementCssRules","filteredElementsStyles","link","color","undefined","elementName","elementStyles","cssRule","selector","ELEMENTS","push","element","BlockList","__unstableElementContext","__html","className"],"mappings":";;;;;;;;;;;;AASA;;;;AANA;;AACA;;AAMA;;AACA;;AAMA;;AACA;;AAQA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AApCA;AACA;AACA;;AAIA;AACA;AACA;;AAeA;AACA;AACA;AAaA,MAAMA,gBAAgB,GAAG,CACxB,GAAGC,mCADqB,EAExBC,0BAFwB,EAGxBC,wBAHwB,EAIxBC,+BAJwB,CAAzB;;AAOA,MAAMC,eAAe,GAAKC,SAAF,IACvBN,gBAAgB,CAACO,IAAjB,CAAyBC,GAAF,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;AAJvD,SAA/B,CAAhB;;AAMA,YAAK,CAAC,CAAEE,OAAR,EAAkB;AACjBP,UAAAA,eAAe,CAACU,IAAhB,CAAsBH,OAAtB;AACA;AACD;AACD;;AACD,WAAOP,eAAe,CAAC1D,MAAhB,GAAyB,CAAzB,GAA6B0D,eAA7B,GAA+CI,SAAtD;AACA,GAjCc,EAiCZ,2BAAExB,KAAK,CAACV,UAAN,CAAiBC,KAAnB,2DAAE,uBAAwB4B,QAA1B,CAjCY,CAAf;AAmCA,QAAMY,OAAO,GAAG,yBAAYC,mBAAUC,wBAAtB,CAAhB;AAEA,SACC,qDACGnE,MAAM,IACPiE,OADC,IAED,2BACC;AACC,IAAA,uBAAuB,EAAG;AACzBG,MAAAA,MAAM,EAAEpE;AADiB;AAD3B,IADD,EAMCiE,OAND,CAHF,EAYC,4BAAC,cAAD,6BACM/B,KADN;AAEC,IAAA,SAAS,EACR,0BAAAA,KAAK,CAACV,UAAN,CAAiBC,KAAjB,0EAAwB4B,QAAxB,GACG,yBACAnB,KAAK,CAACmC,SADN,EAEAnB,gCAFA,CADH,GAKGhB,KAAK,CAACmC;AARX,KAZD,CADD;AA0BA,CA3EyB,CAA3B;AA8EA,sBACC,0BADD,EAEC,yBAFD,EAGC/C,YAHD;AAMA,sBACC,kCADD,EAEC,yBAFD,EAGCW,YAHD;AAMA,sBACC,0BADD,EAEC,yBAFD,EAGCS,YAHD;AAMA,sBACC,kBADD,EAEC,gCAFD,EAGCG,iBAHD;AAMA,sBACC,uBADD,EAEC,kCAFD,EAGCG,kBAHD","sourcesContent":["/**\n * External dependencies\n */\nimport { get, has, omit } from 'lodash';\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useContext, useMemo, createPortal } from '@wordpress/element';\nimport { addFilter } from '@wordpress/hooks';\nimport {\n\tgetBlockSupport,\n\thasBlockSupport,\n\t__EXPERIMENTAL_STYLE_PROPERTY as STYLE_PROPERTY,\n\t__EXPERIMENTAL_ELEMENTS as ELEMENTS,\n} from '@wordpress/blocks';\nimport { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';\nimport {\n\tgetCSSRules,\n\tgenerate as generateStyles,\n} from '@wordpress/style-engine';\n\n/**\n * Internal dependencies\n */\nimport BlockList from '../components/block-list';\nimport { BORDER_SUPPORT_KEY, BorderPanel } from './border';\nimport { COLOR_SUPPORT_KEY, ColorEdit } from './color';\nimport {\n\tTypographyPanel,\n\tTYPOGRAPHY_SUPPORT_KEY,\n\tTYPOGRAPHY_SUPPORT_KEYS,\n} from './typography';\nimport { SPACING_SUPPORT_KEY, DimensionsPanel } from './dimensions';\nimport useDisplayBlockControls from '../components/use-display-block-controls';\nimport { shouldSkipSerialization } from './utils';\n\nconst styleSupportKeys = [\n\t...TYPOGRAPHY_SUPPORT_KEYS,\n\tBORDER_SUPPORT_KEY,\n\tCOLOR_SUPPORT_KEY,\n\tSPACING_SUPPORT_KEY,\n];\n\nconst hasStyleSupport = ( blockType ) =>\n\tstyleSupportKeys.some( ( key ) => hasBlockSupport( blockType, key ) );\n\nconst VARIABLE_REFERENCE_PREFIX = 'var:';\nconst VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE = '|';\nconst VARIABLE_PATH_SEPARATOR_TOKEN_STYLE = '--';\nfunction compileStyleValue( uncompiledValue ) {\n\tif ( uncompiledValue?.startsWith?.( VARIABLE_REFERENCE_PREFIX ) ) {\n\t\tconst variable = uncompiledValue\n\t\t\t.slice( VARIABLE_REFERENCE_PREFIX.length )\n\t\t\t.split( VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE )\n\t\t\t.join( VARIABLE_PATH_SEPARATOR_TOKEN_STYLE );\n\t\treturn `var(--wp--${ variable })`;\n\t}\n\treturn uncompiledValue;\n}\n\n/**\n * Returns the inline styles to add depending on the style object\n *\n * @param {Object} styles Styles configuration.\n *\n * @return {Object} Flattened CSS variables declaration.\n */\nexport function getInlineStyles( styles = {} ) {\n\tconst ignoredStyles = [ 'spacing.blockGap' ];\n\tconst output = {};\n\tObject.keys( STYLE_PROPERTY ).forEach( ( propKey ) => {\n\t\tif ( STYLE_PROPERTY[ propKey ].rootOnly ) {\n\t\t\treturn;\n\t\t}\n\t\tconst path = STYLE_PROPERTY[ propKey ].value;\n\t\tconst subPaths = STYLE_PROPERTY[ propKey ].properties;\n\t\t// Ignore styles on elements because they are handled on the server.\n\t\tif ( has( styles, path ) && 'elements' !== path?.[ 0 ] ) {\n\t\t\t// Checking if style value is a string allows for shorthand css\n\t\t\t// option and backwards compatibility for border radius support.\n\t\t\tconst styleValue = get( styles, path );\n\n\t\t\tif ( ! STYLE_PROPERTY[ propKey ].useEngine ) {\n\t\t\t\tif ( !! subPaths && typeof styleValue !== 'string' ) {\n\t\t\t\t\tObject.entries( subPaths ).forEach( ( entry ) => {\n\t\t\t\t\t\tconst [ name, subPath ] = entry;\n\t\t\t\t\t\tconst value = get( styleValue, [ subPath ] );\n\n\t\t\t\t\t\tif ( value ) {\n\t\t\t\t\t\t\toutput[ name ] = compileStyleValue( value );\n\t\t\t\t\t\t}\n\t\t\t\t\t} );\n\t\t\t\t} else if ( ! ignoredStyles.includes( path.join( '.' ) ) ) {\n\t\t\t\t\toutput[ propKey ] = compileStyleValue(\n\t\t\t\t\t\tget( styles, path )\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} );\n\n\t// The goal is to move everything to server side generated engine styles\n\t// This is temporary as we absorb more and more styles into the engine.\n\tconst extraRules = getCSSRules( styles );\n\textraRules.forEach( ( rule ) => {\n\t\toutput[ rule.key ] = rule.value;\n\t} );\n\n\treturn output;\n}\n\n/**\n * Filters registered block settings, extending attributes to include `style` attribute.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nfunction addAttribute( settings ) {\n\tif ( ! hasStyleSupport( settings ) ) {\n\t\treturn settings;\n\t}\n\n\t// Allow blocks to specify their own attribute definition with default values if needed.\n\tif ( ! settings.attributes.style ) {\n\t\tObject.assign( settings.attributes, {\n\t\t\tstyle: {\n\t\t\t\ttype: 'object',\n\t\t\t},\n\t\t} );\n\t}\n\n\treturn settings;\n}\n\n/**\n * A dictionary of paths to flag skipping block support serialization as the key,\n * with values providing the style paths to be omitted from serialization.\n *\n * @constant\n * @type {Record<string, string[]>}\n */\nconst skipSerializationPathsEdit = {\n\t[ `${ BORDER_SUPPORT_KEY }.__experimentalSkipSerialization` ]: [ 'border' ],\n\t[ `${ COLOR_SUPPORT_KEY }.__experimentalSkipSerialization` ]: [\n\t\tCOLOR_SUPPORT_KEY,\n\t],\n\t[ `${ TYPOGRAPHY_SUPPORT_KEY }.__experimentalSkipSerialization` ]: [\n\t\tTYPOGRAPHY_SUPPORT_KEY,\n\t],\n\t[ `${ SPACING_SUPPORT_KEY }.__experimentalSkipSerialization` ]: [\n\t\t'spacing',\n\t],\n};\n\n/**\n * A dictionary of paths to flag skipping block support serialization as the key,\n * with values providing the style paths to be omitted from serialization.\n *\n * Extends the Edit skip paths to enable skipping additional paths in just\n * the Save component. This allows a block support to be serialized within the\n * editor, while using an alternate approach, such as server-side rendering, when\n * the support is saved.\n *\n * @constant\n * @type {Record<string, string[]>}\n */\nconst skipSerializationPathsSave = {\n\t...skipSerializationPathsEdit,\n\t[ `${ SPACING_SUPPORT_KEY }` ]: [ 'spacing.blockGap' ],\n};\n\n/**\n * A dictionary used to normalize feature names between support flags, style\n * object properties and __experimentSkipSerialization configuration arrays.\n *\n * This allows not having to provide a migration for a support flag and possible\n * backwards compatibility bridges, while still achieving consistency between\n * the support flag and the skip serialization array.\n *\n * @constant\n * @type {Record<string, string>}\n */\nconst renamedFeatures = { gradients: 'gradient' };\n\n/**\n * Override props assigned to save component to inject the CSS variables definition.\n *\n * @param {Object} props Additional props applied to save element.\n * @param {Object} blockType Block type.\n * @param {Object} attributes Block attributes.\n * @param {?Record<string, string[]>} skipPaths An object of keys and paths to skip serialization.\n *\n * @return {Object} Filtered props applied to save element.\n */\nexport function addSaveProps(\n\tprops,\n\tblockType,\n\tattributes,\n\tskipPaths = skipSerializationPathsSave\n) {\n\tif ( ! hasStyleSupport( blockType ) ) {\n\t\treturn props;\n\t}\n\n\tlet { style } = attributes;\n\tObject.entries( skipPaths ).forEach( ( [ indicator, path ] ) => {\n\t\tconst skipSerialization = getBlockSupport( blockType, indicator );\n\n\t\tif ( skipSerialization === true ) {\n\t\t\tstyle = omit( style, path );\n\t\t}\n\n\t\tif ( Array.isArray( skipSerialization ) ) {\n\t\t\tskipSerialization.forEach( ( featureName ) => {\n\t\t\t\tconst feature = renamedFeatures[ featureName ] || featureName;\n\t\t\t\tstyle = omit( style, [ [ ...path, feature ] ] );\n\t\t\t} );\n\t\t}\n\t} );\n\n\tprops.style = {\n\t\t...getInlineStyles( style ),\n\t\t...props.style,\n\t};\n\n\treturn props;\n}\n\n/**\n * Filters registered block settings to extend the block edit wrapper\n * to apply the desired styles and classnames properly.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object}.Filtered block settings.\n */\nexport function addEditProps( settings ) {\n\tif ( ! hasStyleSupport( settings ) ) {\n\t\treturn settings;\n\t}\n\n\tconst existingGetEditWrapperProps = settings.getEditWrapperProps;\n\tsettings.getEditWrapperProps = ( attributes ) => {\n\t\tlet props = {};\n\t\tif ( existingGetEditWrapperProps ) {\n\t\t\tprops = existingGetEditWrapperProps( attributes );\n\t\t}\n\n\t\treturn addSaveProps(\n\t\t\tprops,\n\t\t\tsettings,\n\t\t\tattributes,\n\t\t\tskipSerializationPathsEdit\n\t\t);\n\t};\n\n\treturn settings;\n}\n\n/**\n * Override the default edit UI to include new inspector controls for\n * all the custom styles configs.\n *\n * @param {Function} BlockEdit Original component.\n *\n * @return {Function} Wrapped component.\n */\nexport const withBlockControls = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tconst shouldDisplayControls = useDisplayBlockControls();\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ shouldDisplayControls && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<ColorEdit { ...props } />\n\t\t\t\t\t\t<TypographyPanel { ...props } />\n\t\t\t\t\t\t<BorderPanel { ...props } />\n\t\t\t\t\t\t<DimensionsPanel { ...props } />\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t\t<BlockEdit { ...props } />\n\t\t\t</>\n\t\t);\n\t},\n\t'withToolbarControls'\n);\n\n/**\n * Override the default block element to include duotone styles.\n *\n * @param {Function} BlockListBlock Original component\n * @return {Function} Wrapped component\n */\nconst withElementsStyles = createHigherOrderComponent(\n\t( BlockListBlock ) => ( props ) => {\n\t\tconst blockElementsContainerIdentifier = `wp-elements-${ useInstanceId(\n\t\t\tBlockListBlock\n\t\t) }`;\n\n\t\tconst skipLinkColorSerialization = shouldSkipSerialization(\n\t\t\tprops.name,\n\t\t\tCOLOR_SUPPORT_KEY,\n\t\t\t'link'\n\t\t);\n\n\t\tconst styles = useMemo( () => {\n\t\t\tconst rawElementsStyles = props.attributes.style?.elements;\n\t\t\tconst elementCssRules = [];\n\t\t\tif (\n\t\t\t\trawElementsStyles &&\n\t\t\t\tObject.keys( rawElementsStyles ).length > 0\n\t\t\t) {\n\t\t\t\t// Remove values based on whether serialization has been skipped for a specific style.\n\t\t\t\tconst filteredElementsStyles = {\n\t\t\t\t\t...rawElementsStyles,\n\t\t\t\t\tlink: {\n\t\t\t\t\t\t...rawElementsStyles.link,\n\t\t\t\t\t\tcolor: ! skipLinkColorSerialization\n\t\t\t\t\t\t\t? rawElementsStyles.link?.color\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t},\n\t\t\t\t};\n\n\t\t\t\tfor ( const [ elementName, elementStyles ] of Object.entries(\n\t\t\t\t\tfilteredElementsStyles\n\t\t\t\t) ) {\n\t\t\t\t\tconst cssRule = generateStyles( elementStyles, {\n\t\t\t\t\t\t// The .editor-styles-wrapper selector is required on elements styles. As it is\n\t\t\t\t\t\t// added to all other editor styles, not providing it causes reset and global\n\t\t\t\t\t\t// styles to override element styles because of higher specificity.\n\t\t\t\t\t\tselector: `.editor-styles-wrapper .${ blockElementsContainerIdentifier } ${ ELEMENTS[ elementName ] }`,\n\t\t\t\t\t} );\n\t\t\t\t\tif ( !! cssRule ) {\n\t\t\t\t\t\telementCssRules.push( cssRule );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn elementCssRules.length > 0 ? elementCssRules : undefined;\n\t\t}, [ props.attributes.style?.elements ] );\n\n\t\tconst element = useContext( BlockList.__unstableElementContext );\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ styles &&\n\t\t\t\t\telement &&\n\t\t\t\t\tcreatePortal(\n\t\t\t\t\t\t<style\n\t\t\t\t\t\t\tdangerouslySetInnerHTML={ {\n\t\t\t\t\t\t\t\t__html: styles,\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>,\n\t\t\t\t\t\telement\n\t\t\t\t\t) }\n\n\t\t\t\t<BlockListBlock\n\t\t\t\t\t{ ...props }\n\t\t\t\t\tclassName={\n\t\t\t\t\t\tprops.attributes.style?.elements\n\t\t\t\t\t\t\t? classnames(\n\t\t\t\t\t\t\t\t\tprops.className,\n\t\t\t\t\t\t\t\t\tblockElementsContainerIdentifier\n\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t: props.className\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t</>\n\t\t);\n\t}\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/style/addAttribute',\n\taddAttribute\n);\n\naddFilter(\n\t'blocks.getSaveContent.extraProps',\n\t'core/style/addSaveProps',\n\taddSaveProps\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/style/addEditProps',\n\taddEditProps\n);\n\naddFilter(\n\t'editor.BlockEdit',\n\t'core/style/with-block-controls',\n\twithBlockControls\n);\n\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/editor/with-elements-styles',\n\twithElementsStyles\n);\n"]}
@@ -19,19 +19,21 @@ var _blocks = require("@wordpress/blocks");
19
19
  /**
20
20
  * WordPress dependencies
21
21
  */
22
-
22
+ const identity = x => x;
23
23
  /**
24
24
  * Removed falsy values from nested object.
25
25
  *
26
26
  * @param {*} object
27
27
  * @return {*} Object cleaned from falsy values
28
28
  */
29
+
30
+
29
31
  const cleanEmptyObject = object => {
30
- if (!(0, _lodash.isObject)(object) || Array.isArray(object)) {
32
+ if (object === null || typeof object !== 'object' || Array.isArray(object)) {
31
33
  return object;
32
34
  }
33
35
 
34
- const cleanedNestedObjects = (0, _lodash.pickBy)((0, _lodash.mapValues)(object, cleanEmptyObject), _lodash.identity);
36
+ const cleanedNestedObjects = (0, _lodash.pickBy)((0, _lodash.mapValues)(object, cleanEmptyObject), identity);
35
37
  return (0, _lodash.isEmpty)(cleanedNestedObjects) ? undefined : cleanedNestedObjects;
36
38
  };
37
39
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/hooks/utils.js"],"names":["cleanEmptyObject","object","Array","isArray","cleanedNestedObjects","identity","undefined","immutableSet","path","value","clone","transformStyles","activeSupports","migrationPaths","result","source","index","results","isActive","length","innerBlocks","referenceBlockAttributes","attributes","returnBlock","support","forEach","styleValue","shouldSkipSerialization","blockType","featureSet","feature","skipSerialization","__experimentalSkipSerialization","includes"],"mappings":";;;;;;;;;;AAGA;;AAgBA;;AAnBA;AACA;AACA;;AAcA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,gBAAgB,GAAKC,MAAF,IAAc;AAC7C,MAAK,CAAE,sBAAUA,MAAV,CAAF,IAAwBC,KAAK,CAACC,OAAN,CAAeF,MAAf,CAA7B,EAAuD;AACtD,WAAOA,MAAP;AACA;;AACD,QAAMG,oBAAoB,GAAG,oBAC5B,uBAAWH,MAAX,EAAmBD,gBAAnB,CAD4B,EAE5BK,gBAF4B,CAA7B;AAIA,SAAO,qBAASD,oBAAT,IAAkCE,SAAlC,GAA8CF,oBAArD;AACA,CATM;;;;AAWA,SAASG,YAAT,CAAuBN,MAAvB,EAA+BO,IAA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,GAAG,EACb,GAAGA,WADU;AAEbD,YAAAA,UAAU,EAAEf,YAAY,CACvBgB,WAAW,CAACD,UADW,EAEvBd,IAFuB,EAGvBkB,UAHuB;AAFX,WAAd;AAQA;AACD,OAZD;AAaA;AACD,GAhBD;AAiBA,SAAOH,WAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASI,uBAAT,CAAkCC,SAAlC,EAA6CC,UAA7C,EAAyDC,OAAzD,EAAmE;AACzE,QAAMN,OAAO,GAAG,6BAAiBI,SAAjB,EAA4BC,UAA5B,CAAhB;AACA,QAAME,iBAAiB,GAAGP,OAAH,aAAGA,OAAH,uBAAGA,OAAO,CAAEQ,+BAAnC;;AAEA,MAAK9B,KAAK,CAACC,OAAN,CAAe4B,iBAAf,CAAL,EAA0C;AACzC,WAAOA,iBAAiB,CAACE,QAAlB,CAA4BH,OAA5B,CAAP;AACA;;AAED,SAAOC,iBAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport {\n\tpickBy,\n\tisEmpty,\n\tisObject,\n\tidentity,\n\tmapValues,\n\tforEach,\n\tget,\n\tsetWith,\n\tclone,\n\tevery,\n} from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { getBlockSupport } from '@wordpress/blocks';\n\n/**\n * Removed falsy values from nested object.\n *\n * @param {*} object\n * @return {*} Object cleaned from falsy values\n */\nexport const cleanEmptyObject = ( object ) => {\n\tif ( ! isObject( object ) || Array.isArray( object ) ) {\n\t\treturn object;\n\t}\n\tconst cleanedNestedObjects = pickBy(\n\t\tmapValues( object, cleanEmptyObject ),\n\t\tidentity\n\t);\n\treturn isEmpty( cleanedNestedObjects ) ? undefined : cleanedNestedObjects;\n};\n\nexport function immutableSet( object, path, value ) {\n\treturn setWith( object ? clone( object ) : {}, path, value, clone );\n}\n\nexport function transformStyles(\n\tactiveSupports,\n\tmigrationPaths,\n\tresult,\n\tsource,\n\tindex,\n\tresults\n) {\n\t// If there are no active supports return early.\n\tif ( every( activeSupports, ( isActive ) => ! isActive ) ) {\n\t\treturn result;\n\t}\n\t// If the condition verifies we are probably in the presence of a wrapping transform\n\t// e.g: nesting paragraphs in a group or columns and in that case the styles should not be transformed.\n\tif ( results.length === 1 && result.innerBlocks.length === source.length ) {\n\t\treturn result;\n\t}\n\t// For cases where we have a transform from one block to multiple blocks\n\t// or multiple blocks to one block we apply the styles of the first source block\n\t// to the result(s).\n\tlet referenceBlockAttributes = source[ 0 ]?.attributes;\n\t// If we are in presence of transform between more than one block in the source\n\t// that has more than one block in the result\n\t// we apply the styles on source N to the result N,\n\t// if source N does not exists we do nothing.\n\tif ( results.length > 1 && source.length > 1 ) {\n\t\tif ( source[ index ] ) {\n\t\t\treferenceBlockAttributes = source[ index ]?.attributes;\n\t\t} else {\n\t\t\treturn result;\n\t\t}\n\t}\n\tlet returnBlock = result;\n\tforEach( activeSupports, ( isActive, support ) => {\n\t\tif ( isActive ) {\n\t\t\tmigrationPaths[ support ].forEach( ( path ) => {\n\t\t\t\tconst styleValue = get( referenceBlockAttributes, path );\n\t\t\t\tif ( styleValue ) {\n\t\t\t\t\treturnBlock = {\n\t\t\t\t\t\t...returnBlock,\n\t\t\t\t\t\tattributes: immutableSet(\n\t\t\t\t\t\t\treturnBlock.attributes,\n\t\t\t\t\t\t\tpath,\n\t\t\t\t\t\t\tstyleValue\n\t\t\t\t\t\t),\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\t} );\n\treturn returnBlock;\n}\n\n/**\n * Check whether serialization of specific block support feature or set should\n * be skipped.\n *\n * @param {string|Object} blockType Block name or block type object.\n * @param {string} featureSet Name of block support feature set.\n * @param {string} feature Name of the individual feature to check.\n *\n * @return {boolean} Whether serialization should occur.\n */\nexport function shouldSkipSerialization( blockType, featureSet, feature ) {\n\tconst support = getBlockSupport( blockType, featureSet );\n\tconst skipSerialization = support?.__experimentalSkipSerialization;\n\n\tif ( Array.isArray( skipSerialization ) ) {\n\t\treturn skipSerialization.includes( feature );\n\t}\n\n\treturn skipSerialization;\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/hooks/utils.js"],"names":["identity","x","cleanEmptyObject","object","Array","isArray","cleanedNestedObjects","undefined","immutableSet","path","value","clone","transformStyles","activeSupports","migrationPaths","result","source","index","results","isActive","length","innerBlocks","referenceBlockAttributes","attributes","returnBlock","support","forEach","styleValue","shouldSkipSerialization","blockType","featureSet","feature","skipSerialization","__experimentalSkipSerialization","includes"],"mappings":";;;;;;;;;;AAGA;;AAcA;;AAjBA;AACA;AACA;;AAYA;AACA;AACA;AAGA,MAAMA,QAAQ,GAAKC,CAAF,IAASA,CAA1B;AAEA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAMC,gBAAgB,GAAKC,MAAF,IAAc;AAC7C,MACCA,MAAM,KAAK,IAAX,IACA,OAAOA,MAAP,KAAkB,QADlB,IAEAC,KAAK,CAACC,OAAN,CAAeF,MAAf,CAHD,EAIE;AACD,WAAOA,MAAP;AACA;;AACD,QAAMG,oBAAoB,GAAG,oBAC5B,uBAAWH,MAAX,EAAmBD,gBAAnB,CAD4B,EAE5BF,QAF4B,CAA7B;AAIA,SAAO,qBAASM,oBAAT,IAAkCC,SAAlC,GAA8CD,oBAArD;AACA,CAbM;;;;AAeA,SAASE,YAAT,CAAuBL,MAAvB,EAA+BM,IAA/B,EAAqCC,KAArC,EAA6C;AACnD,SAAO,qBAASP,MAAM,GAAG,mBAAOA,MAAP,CAAH,GAAqB,EAApC,EAAwCM,IAAxC,EAA8CC,KAA9C,EAAqDC,aAArD,CAAP;AACA;;AAEM,SAASC,eAAT,CACNC,cADM,EAENC,cAFM,EAGNC,MAHM,EAINC,MAJM,EAKNC,KALM,EAMNC,OANM,EAOL;AAAA;;AACD;AACA,MAAK,mBAAOL,cAAP,EAAyBM,QAAF,IAAgB,CAAEA,QAAzC,CAAL,EAA2D;AAC1D,WAAOJ,MAAP;AACA,GAJA,CAKD;AACA;;;AACA,MAAKG,OA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iB,GAAGP,OAAH,aAAGA,OAAH,uBAAGA,OAAO,CAAEQ,+BAAnC;;AAEA,MAAK7B,KAAK,CAACC,OAAN,CAAe2B,iBAAf,CAAL,EAA0C;AACzC,WAAOA,iBAAiB,CAACE,QAAlB,CAA4BH,OAA5B,CAAP;AACA;;AAED,SAAOC,iBAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport {\n\tpickBy,\n\tisEmpty,\n\tmapValues,\n\tforEach,\n\tget,\n\tsetWith,\n\tclone,\n\tevery,\n} from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { getBlockSupport } from '@wordpress/blocks';\n\nconst identity = ( x ) => x;\n\n/**\n * Removed falsy values from nested object.\n *\n * @param {*} object\n * @return {*} Object cleaned from falsy values\n */\nexport const cleanEmptyObject = ( object ) => {\n\tif (\n\t\tobject === null ||\n\t\ttypeof object !== 'object' ||\n\t\tArray.isArray( object )\n\t) {\n\t\treturn object;\n\t}\n\tconst cleanedNestedObjects = pickBy(\n\t\tmapValues( object, cleanEmptyObject ),\n\t\tidentity\n\t);\n\treturn isEmpty( cleanedNestedObjects ) ? undefined : cleanedNestedObjects;\n};\n\nexport function immutableSet( object, path, value ) {\n\treturn setWith( object ? clone( object ) : {}, path, value, clone );\n}\n\nexport function transformStyles(\n\tactiveSupports,\n\tmigrationPaths,\n\tresult,\n\tsource,\n\tindex,\n\tresults\n) {\n\t// If there are no active supports return early.\n\tif ( every( activeSupports, ( isActive ) => ! isActive ) ) {\n\t\treturn result;\n\t}\n\t// If the condition verifies we are probably in the presence of a wrapping transform\n\t// e.g: nesting paragraphs in a group or columns and in that case the styles should not be transformed.\n\tif ( results.length === 1 && result.innerBlocks.length === source.length ) {\n\t\treturn result;\n\t}\n\t// For cases where we have a transform from one block to multiple blocks\n\t// or multiple blocks to one block we apply the styles of the first source block\n\t// to the result(s).\n\tlet referenceBlockAttributes = source[ 0 ]?.attributes;\n\t// If we are in presence of transform between more than one block in the source\n\t// that has more than one block in the result\n\t// we apply the styles on source N to the result N,\n\t// if source N does not exists we do nothing.\n\tif ( results.length > 1 && source.length > 1 ) {\n\t\tif ( source[ index ] ) {\n\t\t\treferenceBlockAttributes = source[ index ]?.attributes;\n\t\t} else {\n\t\t\treturn result;\n\t\t}\n\t}\n\tlet returnBlock = result;\n\tforEach( activeSupports, ( isActive, support ) => {\n\t\tif ( isActive ) {\n\t\t\tmigrationPaths[ support ].forEach( ( path ) => {\n\t\t\t\tconst styleValue = get( referenceBlockAttributes, path );\n\t\t\t\tif ( styleValue ) {\n\t\t\t\t\treturnBlock = {\n\t\t\t\t\t\t...returnBlock,\n\t\t\t\t\t\tattributes: immutableSet(\n\t\t\t\t\t\t\treturnBlock.attributes,\n\t\t\t\t\t\t\tpath,\n\t\t\t\t\t\t\tstyleValue\n\t\t\t\t\t\t),\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\t} );\n\treturn returnBlock;\n}\n\n/**\n * Check whether serialization of specific block support feature or set should\n * be skipped.\n *\n * @param {string|Object} blockType Block name or block type object.\n * @param {string} featureSet Name of block support feature set.\n * @param {string} feature Name of the individual feature to check.\n *\n * @return {boolean} Whether serialization should occur.\n */\nexport function shouldSkipSerialization( blockType, featureSet, feature ) {\n\tconst support = getBlockSupport( blockType, featureSet );\n\tconst skipSerialization = support?.__experimentalSkipSerialization;\n\n\tif ( Array.isArray( skipSerialization ) ) {\n\t\treturn skipSerialization.includes( feature );\n\t}\n\n\treturn skipSerialization;\n}\n"]}
package/build/index.js CHANGED
@@ -4,13 +4,13 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  var _exportNames = {
7
- __unstablePresetDuotoneFilter: true,
8
7
  __experimentalGetBorderClassesAndStyles: true,
9
8
  __experimentalUseBorderProps: true,
10
9
  __experimentalGetColorClassesAndStyles: true,
11
10
  __experimentalUseColorProps: true,
12
11
  __experimentalUseCustomSides: true,
13
12
  __experimentalGetSpacingClassesAndStyles: true,
13
+ __experimentalGetGapCSSValue: true,
14
14
  useCachedTruthy: true,
15
15
  storeConfig: true,
16
16
  store: true,
@@ -34,6 +34,12 @@ Object.defineProperty(exports, "__experimentalGetColorClassesAndStyles", {
34
34
  return _hooks.getColorClassesAndStyles;
35
35
  }
36
36
  });
37
+ Object.defineProperty(exports, "__experimentalGetGapCSSValue", {
38
+ enumerable: true,
39
+ get: function () {
40
+ return _hooks.getGapCSSValue;
41
+ }
42
+ });
37
43
  Object.defineProperty(exports, "__experimentalGetSpacingClassesAndStyles", {
38
44
  enumerable: true,
39
45
  get: function () {
@@ -58,12 +64,6 @@ Object.defineProperty(exports, "__experimentalUseCustomSides", {
58
64
  return _hooks.useCustomSides;
59
65
  }
60
66
  });
61
- Object.defineProperty(exports, "__unstablePresetDuotoneFilter", {
62
- enumerable: true,
63
- get: function () {
64
- return _hooks.PresetDuotoneFilter;
65
- }
66
- });
67
67
  Object.defineProperty(exports, "store", {
68
68
  enumerable: true,
69
69
  get: function () {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA;;AAWA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AACA","sourcesContent":["/**\n * Internal dependencies\n */\nimport './hooks';\nexport {\n\tPresetDuotoneFilter as __unstablePresetDuotoneFilter,\n\tgetBorderClassesAndStyles as __experimentalGetBorderClassesAndStyles,\n\tuseBorderProps as __experimentalUseBorderProps,\n\tgetColorClassesAndStyles as __experimentalGetColorClassesAndStyles,\n\tuseColorProps as __experimentalUseColorProps,\n\tuseCustomSides as __experimentalUseCustomSides,\n\tgetSpacingClassesAndStyles as __experimentalGetSpacingClassesAndStyles,\n\tuseCachedTruthy,\n} from './hooks';\nexport * from './components';\nexport * from './elements';\nexport * from './utils';\nexport { storeConfig, store } from './store';\nexport { SETTINGS_DEFAULTS } from './store/defaults';\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA;;AAWA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AACA","sourcesContent":["/**\n * Internal dependencies\n */\nimport './hooks';\nexport {\n\tgetBorderClassesAndStyles as __experimentalGetBorderClassesAndStyles,\n\tuseBorderProps as __experimentalUseBorderProps,\n\tgetColorClassesAndStyles as __experimentalGetColorClassesAndStyles,\n\tuseColorProps as __experimentalUseColorProps,\n\tuseCustomSides as __experimentalUseCustomSides,\n\tgetSpacingClassesAndStyles as __experimentalGetSpacingClassesAndStyles,\n\tgetGapCSSValue as __experimentalGetGapCSSValue,\n\tuseCachedTruthy,\n} from './hooks';\nexport * from './components';\nexport * from './elements';\nexport * from './utils';\nexport { storeConfig, store } from './store';\nexport { SETTINGS_DEFAULTS } from './store/defaults';\n"]}
@@ -1,7 +1,5 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
3
  Object.defineProperty(exports, "__esModule", {
6
4
  value: true
7
5
  });
@@ -15,14 +13,10 @@ var _icons = require("@wordpress/icons");
15
13
 
16
14
  var _components = require("@wordpress/components");
17
15
 
18
- var _blocks = require("@wordpress/blocks");
19
-
20
16
  var _utils = require("./utils");
21
17
 
22
18
  var _gap = require("../hooks/gap");
23
19
 
24
- var _useSetting = _interopRequireDefault(require("../components/use-setting"));
25
-
26
20
  var _components2 = require("../components");
27
21
 
28
22
  var _utils2 = require("../hooks/utils");
@@ -103,49 +97,59 @@ var _default = {
103
97
  isToolbar: true
104
98
  }));
105
99
  },
106
- save: function FlexLayoutStyle(_ref3) {
100
+ getLayoutStyle: function getLayoutStyle(_ref3) {
107
101
  var _style$spacing, _style$spacing2;
108
102
 
109
103
  let {
110
104
  selector,
111
105
  layout,
112
106
  style,
113
- blockName
107
+ blockName,
108
+ hasBlockGapSupport,
109
+ layoutDefinitions
114
110
  } = _ref3;
115
111
  const {
116
112
  orientation = 'horizontal'
117
- } = layout;
118
- const blockGapSupport = (0, _useSetting.default)('spacing.blockGap');
119
- const fallbackValue = (0, _blocks.getBlockSupport)(blockName, ['spacing', 'blockGap', '__experimentalDefault']) || '0.5em';
120
- const hasBlockGapStylesSupport = blockGapSupport !== null; // If a block's block.json skips serialization for spacing or spacing.blockGap,
113
+ } = layout; // If a block's block.json skips serialization for spacing or spacing.blockGap,
121
114
  // don't apply the user-defined value to the styles.
122
115
 
123
- const blockGapValue = style !== null && style !== void 0 && (_style$spacing = style.spacing) !== null && _style$spacing !== void 0 && _style$spacing.blockGap && !(0, _utils2.shouldSkipSerialization)(blockName, 'spacing', 'blockGap') ? (0, _gap.getGapCSSValue)(style === null || style === void 0 ? void 0 : (_style$spacing2 = style.spacing) === null || _style$spacing2 === void 0 ? void 0 : _style$spacing2.blockGap, fallbackValue) : `var( --wp--style--block-gap, ${fallbackValue} )`;
124
- const justifyContent = justifyContentMap[layout.justifyContent] || justifyContentMap.left;
116
+ const blockGapValue = style !== null && style !== void 0 && (_style$spacing = style.spacing) !== null && _style$spacing !== void 0 && _style$spacing.blockGap && !(0, _utils2.shouldSkipSerialization)(blockName, 'spacing', 'blockGap') ? (0, _gap.getGapCSSValue)(style === null || style === void 0 ? void 0 : (_style$spacing2 = style.spacing) === null || _style$spacing2 === void 0 ? void 0 : _style$spacing2.blockGap) : undefined;
117
+ const justifyContent = justifyContentMap[layout.justifyContent];
125
118
  const flexWrap = flexWrapOptions.includes(layout.flexWrap) ? layout.flexWrap : 'wrap';
126
- const verticalAlignment = verticalAlignmentMap[layout.verticalAlignment] || verticalAlignmentMap.center;
127
- const rowOrientation = `
128
- flex-direction: row;
129
- align-items: ${verticalAlignment};
130
- justify-content: ${justifyContent};
131
- `;
119
+ const verticalAlignment = verticalAlignmentMap[layout.verticalAlignment];
132
120
  const alignItems = alignItemsMap[layout.justifyContent] || alignItemsMap.left;
133
- const columnOrientation = `
134
- flex-direction: column;
135
- align-items: ${alignItems};
136
- `;
137
- return (0, _element.createElement)("style", null, `
138
- ${(0, _utils.appendSelectors)(selector)} {
139
- display: flex;
140
- flex-wrap: ${flexWrap};
141
- gap: ${hasBlockGapStylesSupport ? blockGapValue : fallbackValue};
142
- ${orientation === 'horizontal' ? rowOrientation : columnOrientation}
143
- }
144
-
145
- ${(0, _utils.appendSelectors)(selector, '> *')} {
146
- margin: 0;
147
- }
148
- `);
121
+ let output = '';
122
+ const rules = [];
123
+
124
+ if (flexWrap && flexWrap !== 'wrap') {
125
+ rules.push(`flex-wrap: ${flexWrap}`);
126
+ }
127
+
128
+ if (orientation === 'horizontal') {
129
+ if (verticalAlignment) {
130
+ rules.push(`align-items: ${verticalAlignment}`);
131
+ }
132
+
133
+ if (justifyContent) {
134
+ rules.push(`justify-content: ${justifyContent}`);
135
+ }
136
+ } else {
137
+ rules.push('flex-direction: column');
138
+ rules.push(`align-items: ${alignItems}`);
139
+ }
140
+
141
+ if (rules.length) {
142
+ output = `${(0, _utils.appendSelectors)(selector)} {
143
+ ${rules.join('; ')};
144
+ }`;
145
+ } // Output blockGap styles based on rules contained in layout definitions in theme.json.
146
+
147
+
148
+ if (hasBlockGapSupport && blockGapValue) {
149
+ output += (0, _utils.getBlockGapCSS)(selector, layoutDefinitions, 'flex', blockGapValue);
150
+ }
151
+
152
+ return output;
149
153
  },
150
154
 
151
155
  getOrientation(layout) {
@@ -313,14 +317,14 @@ function OrientationControl(_ref8) {
313
317
  return (0, _element.createElement)("fieldset", {
314
318
  className: "block-editor-hooks__flex-layout-orientation-controls"
315
319
  }, (0, _element.createElement)("legend", null, (0, _i18n.__)('Orientation')), (0, _element.createElement)(_components.Button, {
316
- label: 'horizontal',
320
+ label: (0, _i18n.__)('Horizontal'),
317
321
  icon: _icons.arrowRight,
318
322
  isPressed: orientation === 'horizontal',
319
323
  onClick: () => onChange({ ...layout,
320
324
  orientation: 'horizontal'
321
325
  })
322
326
  }), (0, _element.createElement)(_components.Button, {
323
- label: 'vertical',
327
+ label: (0, _i18n.__)('Vertical'),
324
328
  icon: _icons.arrowDown,
325
329
  isPressed: orientation === 'vertical',
326
330
  onClick: () => onChange({ ...layout,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/layouts/flex.js"],"names":["justifyContentMap","left","right","center","alignItemsMap","verticalAlignmentMap","top","bottom","flexWrapOptions","name","label","inspectorControls","FlexLayoutInspectorControls","layout","onChange","layoutBlockSupport","allowOrientation","toolBarControls","FlexLayoutToolbarControls","allowSwitching","allowVerticalAlignment","orientation","save","FlexLayoutStyle","selector","style","blockName","blockGapSupport","fallbackValue","hasBlockGapStylesSupport","blockGapValue","spacing","blockGap","justifyContent","flexWrap","includes","verticalAlignment","rowOrientation","alignItems","columnOrientation","getOrientation","getAlignments","FlexLayoutVerticalAlignmentControl","isToolbar","onVerticalAlignmentChange","value","verticalAlignmentOptions","map","icon","FlexLayoutJustifyContentControl","onJustificationChange","allowedControls","push","position","isAlternate","justificationOptions","justifyLeft","justifyCenter","justifyRight","justifySpaceBetween","FlexWrapControl","OrientationControl","arrowRight","arrowDown"],"mappings":";;;;;;;;;;;AAGA;;AACA;;AAQA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AAKA;;AA1BA;A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IAAAA,MAAF;AAAUC,IAAAA;AAAV,GAAuB;AACnD,QAAM;AAAEO,IAAAA,WAAW,GAAG;AAAhB,MAAiCR,MAAvC;AACA,SACC;AAAU,IAAA,SAAS,EAAC;AAApB,KACC,4CAAU,cAAI,aAAJ,CAAV,CADD,EAEC,4BAAC,kBAAD;AACC,IAAA,KAAK,EAAG,YADT;AAEC,IAAA,IAAI,EAAGiD,iBAFR;AAGC,IAAA,SAAS,EAAGzC,WAAW,KAAK,YAH7B;AAIC,IAAA,OAAO,EAAG,MACTP,QAAQ,CAAE,EACT,GAAGD,MADM;AAETQ,MAAAA,WAAW,EAAE;AAFJ,KAAF;AALV,IAFD,EAaC,4BAAC,kBAAD;AACC,IAAA,KAAK,EAAG,UADT;AAEC,IAAA,IAAI,EAAG0C,gBAFR;AAGC,IAAA,SAAS,EAAG1C,WAAW,KAAK,UAH7B;AAIC,IAAA,OAAO,EAAG,MACTP,QAAQ,CAAE,EACT,GAAGD,MADM;AAETQ,MAAAA,WAAW,EAAE;AAFJ,KAAF;AALV,IAbD,CADD;AA2BA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tjustifyLeft,\n\tjustifyCenter,\n\tjustifyRight,\n\tjustifySpaceBetween,\n\tarrowRight,\n\tarrowDown,\n} from '@wordpress/icons';\nimport { Button, ToggleControl, Flex, FlexItem } from '@wordpress/components';\nimport { getBlockSupport } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { appendSelectors } from './utils';\nimport { getGapCSSValue } from '../hooks/gap';\nimport useSetting from '../components/use-setting';\nimport {\n\tBlockControls,\n\tJustifyContentControl,\n\tBlockVerticalAlignmentControl,\n} from '../components';\nimport { shouldSkipSerialization } from '../hooks/utils';\n\n// Used with the default, horizontal flex orientation.\nconst justifyContentMap = {\n\tleft: 'flex-start',\n\tright: 'flex-end',\n\tcenter: 'center',\n\t'space-between': 'space-between',\n};\n\n// Used with the vertical (column) flex orientation.\nconst alignItemsMap = {\n\tleft: 'flex-start',\n\tright: 'flex-end',\n\tcenter: 'center',\n};\n\nconst verticalAlignmentMap = {\n\ttop: 'flex-start',\n\tcenter: 'center',\n\tbottom: 'flex-end',\n};\n\nconst flexWrapOptions = [ 'wrap', 'nowrap' ];\n\nexport default {\n\tname: 'flex',\n\tlabel: __( 'Flex' ),\n\tinspectorControls: function FlexLayoutInspectorControls( {\n\t\tlayout = {},\n\t\tonChange,\n\t\tlayoutBlockSupport = {},\n\t} ) {\n\t\tconst { allowOrientation = true } = layoutBlockSupport;\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<Flex>\n\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t<FlexLayoutJustifyContentControl\n\t\t\t\t\t\t\tlayout={ layout }\n\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</FlexItem>\n\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t{ allowOrientation && (\n\t\t\t\t\t\t\t<OrientationControl\n\t\t\t\t\t\t\t\tlayout={ layout }\n\t\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</FlexItem>\n\t\t\t\t</Flex>\n\t\t\t\t<FlexWrapControl layout={ layout } onChange={ onChange } />\n\t\t\t</>\n\t\t);\n\t},\n\ttoolBarControls: function FlexLayoutToolbarControls( {\n\t\tlayout = {},\n\t\tonChange,\n\t\tlayoutBlockSupport,\n\t} ) {\n\t\tif ( layoutBlockSupport?.allowSwitching ) {\n\t\t\treturn null;\n\t\t}\n\t\tconst { allowVerticalAlignment = true } = layoutBlockSupport;\n\t\treturn (\n\t\t\t<BlockControls group=\"block\" __experimentalShareWithChildBlocks>\n\t\t\t\t<FlexLayoutJustifyContentControl\n\t\t\t\t\tlayout={ layout }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\tisToolbar\n\t\t\t\t/>\n\t\t\t\t{ allowVerticalAlignment &&\n\t\t\t\t\tlayout?.orientation !== 'vertical' && (\n\t\t\t\t\t\t<FlexLayoutVerticalAlignmentControl\n\t\t\t\t\t\t\tlayout={ layout }\n\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\tisToolbar\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t</BlockControls>\n\t\t);\n\t},\n\tsave: function FlexLayoutStyle( { selector, layout, style, blockName } ) {\n\t\tconst { orientation = 'horizontal' } = layout;\n\t\tconst blockGapSupport = useSetting( 'spacing.blockGap' );\n\t\tconst fallbackValue =\n\t\t\tgetBlockSupport( blockName, [\n\t\t\t\t'spacing',\n\t\t\t\t'blockGap',\n\t\t\t\t'__experimentalDefault',\n\t\t\t] ) || '0.5em';\n\n\t\tconst hasBlockGapStylesSupport = blockGapSupport !== null;\n\t\t// If a block's block.json skips serialization for spacing or spacing.blockGap,\n\t\t// don't apply the user-defined value to the styles.\n\t\tconst blockGapValue =\n\t\t\tstyle?.spacing?.blockGap &&\n\t\t\t! shouldSkipSerialization( blockName, 'spacing', 'blockGap' )\n\t\t\t\t? getGapCSSValue( style?.spacing?.blockGap, fallbackValue )\n\t\t\t\t: `var( --wp--style--block-gap, ${ fallbackValue } )`;\n\t\tconst justifyContent =\n\t\t\tjustifyContentMap[ layout.justifyContent ] ||\n\t\t\tjustifyContentMap.left;\n\t\tconst flexWrap = flexWrapOptions.includes( layout.flexWrap )\n\t\t\t? layout.flexWrap\n\t\t\t: 'wrap';\n\t\tconst verticalAlignment =\n\t\t\tverticalAlignmentMap[ layout.verticalAlignment ] ||\n\t\t\tverticalAlignmentMap.center;\n\t\tconst rowOrientation = `\n\t\tflex-direction: row;\n\t\talign-items: ${ verticalAlignment };\n\t\tjustify-content: ${ justifyContent };\n\t\t`;\n\t\tconst alignItems =\n\t\t\talignItemsMap[ layout.justifyContent ] || alignItemsMap.left;\n\t\tconst columnOrientation = `\n\t\tflex-direction: column;\n\t\talign-items: ${ alignItems };\n\t\t`;\n\n\t\treturn (\n\t\t\t<style>{ `\n\t\t\t\t${ appendSelectors( selector ) } {\n\t\t\t\t\tdisplay: flex;\n\t\t\t\t\tflex-wrap: ${ flexWrap };\n\t\t\t\t\tgap: ${ hasBlockGapStylesSupport ? blockGapValue : fallbackValue };\n\t\t\t\t\t${ orientation === 'horizontal' ? rowOrientation : columnOrientation }\n\t\t\t\t}\n\n\t\t\t\t${ appendSelectors( selector, '> *' ) } {\n\t\t\t\t\tmargin: 0;\n\t\t\t\t}\n\t\t\t` }</style>\n\t\t);\n\t},\n\tgetOrientation( layout ) {\n\t\tconst { orientation = 'horizontal' } = layout;\n\t\treturn orientation;\n\t},\n\tgetAlignments() {\n\t\treturn [];\n\t},\n};\n\nfunction FlexLayoutVerticalAlignmentControl( {\n\tlayout,\n\tonChange,\n\tisToolbar = false,\n} ) {\n\tconst { verticalAlignment = verticalAlignmentMap.center } = layout;\n\n\tconst onVerticalAlignmentChange = ( value ) => {\n\t\tonChange( {\n\t\t\t...layout,\n\t\t\tverticalAlignment: value,\n\t\t} );\n\t};\n\tif ( isToolbar ) {\n\t\treturn (\n\t\t\t<BlockVerticalAlignmentControl\n\t\t\t\tonChange={ onVerticalAlignmentChange }\n\t\t\t\tvalue={ verticalAlignment }\n\t\t\t/>\n\t\t);\n\t}\n\n\tconst verticalAlignmentOptions = [\n\t\t{\n\t\t\tvalue: 'flex-start',\n\t\t\tlabel: __( 'Align items top' ),\n\t\t},\n\t\t{\n\t\t\tvalue: 'center',\n\t\t\tlabel: __( 'Align items center' ),\n\t\t},\n\t\t{\n\t\t\tvalue: 'flex-end',\n\t\t\tlabel: __( 'Align items bottom' ),\n\t\t},\n\t];\n\n\treturn (\n\t\t<fieldset className=\"block-editor-hooks__flex-layout-vertical-alignment-control\">\n\t\t\t<legend>{ __( 'Vertical alignment' ) }</legend>\n\t\t\t<div>\n\t\t\t\t{ verticalAlignmentOptions.map( ( value, icon, label ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tkey={ value }\n\t\t\t\t\t\t\tlabel={ label }\n\t\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\t\tisPressed={ verticalAlignment === value }\n\t\t\t\t\t\t\tonClick={ () => onVerticalAlignmentChange( value ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t\t</div>\n\t\t</fieldset>\n\t);\n}\n\nfunction FlexLayoutJustifyContentControl( {\n\tlayout,\n\tonChange,\n\tisToolbar = false,\n} ) {\n\tconst { justifyContent = 'left', orientation = 'horizontal' } = layout;\n\tconst onJustificationChange = ( value ) => {\n\t\tonChange( {\n\t\t\t...layout,\n\t\t\tjustifyContent: value,\n\t\t} );\n\t};\n\tconst allowedControls = [ 'left', 'center', 'right' ];\n\tif ( orientation === 'horizontal' ) {\n\t\tallowedControls.push( 'space-between' );\n\t}\n\tif ( isToolbar ) {\n\t\treturn (\n\t\t\t<JustifyContentControl\n\t\t\t\tallowedControls={ allowedControls }\n\t\t\t\tvalue={ justifyContent }\n\t\t\t\tonChange={ onJustificationChange }\n\t\t\t\tpopoverProps={ {\n\t\t\t\t\tposition: 'bottom right',\n\t\t\t\t\tisAlternate: true,\n\t\t\t\t} }\n\t\t\t/>\n\t\t);\n\t}\n\n\tconst justificationOptions = [\n\t\t{\n\t\t\tvalue: 'left',\n\t\t\ticon: justifyLeft,\n\t\t\tlabel: __( 'Justify items left' ),\n\t\t},\n\t\t{\n\t\t\tvalue: 'center',\n\t\t\ticon: justifyCenter,\n\t\t\tlabel: __( 'Justify items center' ),\n\t\t},\n\t\t{\n\t\t\tvalue: 'right',\n\t\t\ticon: justifyRight,\n\t\t\tlabel: __( 'Justify items right' ),\n\t\t},\n\t];\n\tif ( orientation === 'horizontal' ) {\n\t\tjustificationOptions.push( {\n\t\t\tvalue: 'space-between',\n\t\t\ticon: justifySpaceBetween,\n\t\t\tlabel: __( 'Space between items' ),\n\t\t} );\n\t}\n\n\treturn (\n\t\t<fieldset className=\"block-editor-hooks__flex-layout-justification-controls\">\n\t\t\t<legend>{ __( 'Justification' ) }</legend>\n\t\t\t<div>\n\t\t\t\t{ justificationOptions.map( ( { value, icon, label } ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tkey={ value }\n\t\t\t\t\t\t\tlabel={ label }\n\t\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\t\tisPressed={ justifyContent === value }\n\t\t\t\t\t\t\tonClick={ () => onJustificationChange( value ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t\t</div>\n\t\t</fieldset>\n\t);\n}\n\nfunction FlexWrapControl( { layout, onChange } ) {\n\tconst { flexWrap = 'wrap' } = layout;\n\treturn (\n\t\t<ToggleControl\n\t\t\tlabel={ __( 'Allow to wrap to multiple lines' ) }\n\t\t\tonChange={ ( value ) => {\n\t\t\t\tonChange( {\n\t\t\t\t\t...layout,\n\t\t\t\t\tflexWrap: value ? 'wrap' : 'nowrap',\n\t\t\t\t} );\n\t\t\t} }\n\t\t\tchecked={ flexWrap === 'wrap' }\n\t\t/>\n\t);\n}\n\nfunction OrientationControl( { layout, onChange } ) {\n\tconst { orientation = 'horizontal' } = layout;\n\treturn (\n\t\t<fieldset className=\"block-editor-hooks__flex-layout-orientation-controls\">\n\t\t\t<legend>{ __( 'Orientation' ) }</legend>\n\t\t\t<Button\n\t\t\t\tlabel={ 'horizontal' }\n\t\t\t\ticon={ arrowRight }\n\t\t\t\tisPressed={ orientation === 'horizontal' }\n\t\t\t\tonClick={ () =>\n\t\t\t\t\tonChange( {\n\t\t\t\t\t\t...layout,\n\t\t\t\t\t\torientation: 'horizontal',\n\t\t\t\t\t} )\n\t\t\t\t}\n\t\t\t/>\n\t\t\t<Button\n\t\t\t\tlabel={ 'vertical' }\n\t\t\t\ticon={ arrowDown }\n\t\t\t\tisPressed={ orientation === 'vertical' }\n\t\t\t\tonClick={ () =>\n\t\t\t\t\tonChange( {\n\t\t\t\t\t\t...layout,\n\t\t\t\t\t\torientation: 'vertical',\n\t\t\t\t\t} )\n\t\t\t\t}\n\t\t\t/>\n\t\t</fieldset>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/layouts/flex.js"],"names":["justifyContentMap","left","right","center","alignItemsMap","verticalAlignmentMap","top","bottom","flexWrapOptions","name","label","inspectorControls","FlexLayoutInspectorControls","layout","onChange","layoutBlockSupport","allowOrientation","toolBarControls","FlexLayoutToolbarControls","allowSwitching","allowVerticalAlignment","orientation","getLayoutStyle","selector","style","blockName","hasBlockGapSupport","layoutDefinitions","blockGapValue","spacing","blockGap","undefined","justifyContent","flexWrap","includes","verticalAlignment","alignItems","output","rules","push","length","join","getOrientation","getAlignments","FlexLayoutVerticalAlignmentControl","isToolbar","onVerticalAlignmentChange","value","verticalAlignmentOptions","map","icon","FlexLayoutJustifyContentControl","onJustificationChange","allowedControls","position","isAlternate","justificationOptions","justifyLeft","justifyCenter","justifyRight","justifySpaceBetween","FlexWrapControl","OrientationControl","arrowRight","arrowDown"],"mappings":";;;;;;;;;AAGA;;AACA;;AAQA;;AAKA;;AACA;;AACA;;AAKA;;AAxBA;AACA;AACA;;AAYA;AACA;AACA;AAUA;AACA,MAAMA,iBAAiB,GAAG;AACzBC,EAAAA,IAAI,EAAE,YADmB;AAEzBC,EAAAA,KAAK,EAAE,UAFkB;AAGzBC,EAAAA,MAAM,EAAE,QAHiB;AAIzB,mBAAiB;AAJQ,CAA1B,C,CAOA;;AACA,MAAMC,aAAa,GAAG;AACrBH,EAAAA,IAAI,EAAE,YADe;AAErBC,EAAAA,KAAK,EAAE,UAFc;AAGrBC,EAAAA,MAAM,EAAE;AAHa,CAAtB;AAMA,MAAME,oBAAoB,GAAG;AAC5BC,EAAAA,GAAG,EAAE,YADuB;AAE5BH,EAAAA,MAAM,EAAE,QAFoB;AAG5BI,EAAAA,MAAM,EAAE;AAHoB,CAA7B;AAMA,MAAMC,eAAe,GAAG,CAAE,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AIC,IAAA,OAAO,EAAG,MACTP,QAAQ,CAAE,EACT,GAAGD,MADM;AAETQ,MAAAA,WAAW,EAAE;AAFJ,KAAF;AALV,IAFD,EAaC,4BAAC,kBAAD;AACC,IAAA,KAAK,EAAG,cAAI,UAAJ,CADT;AAEC,IAAA,IAAI,EAAG2C,gBAFR;AAGC,IAAA,SAAS,EAAG3C,WAAW,KAAK,UAH7B;AAIC,IAAA,OAAO,EAAG,MACTP,QAAQ,CAAE,EACT,GAAGD,MADM;AAETQ,MAAAA,WAAW,EAAE;AAFJ,KAAF;AALV,IAbD,CADD;AA2BA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tjustifyLeft,\n\tjustifyCenter,\n\tjustifyRight,\n\tjustifySpaceBetween,\n\tarrowRight,\n\tarrowDown,\n} from '@wordpress/icons';\nimport { Button, ToggleControl, Flex, FlexItem } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { appendSelectors, getBlockGapCSS } from './utils';\nimport { getGapCSSValue } from '../hooks/gap';\nimport {\n\tBlockControls,\n\tJustifyContentControl,\n\tBlockVerticalAlignmentControl,\n} from '../components';\nimport { shouldSkipSerialization } from '../hooks/utils';\n\n// Used with the default, horizontal flex orientation.\nconst justifyContentMap = {\n\tleft: 'flex-start',\n\tright: 'flex-end',\n\tcenter: 'center',\n\t'space-between': 'space-between',\n};\n\n// Used with the vertical (column) flex orientation.\nconst alignItemsMap = {\n\tleft: 'flex-start',\n\tright: 'flex-end',\n\tcenter: 'center',\n};\n\nconst verticalAlignmentMap = {\n\ttop: 'flex-start',\n\tcenter: 'center',\n\tbottom: 'flex-end',\n};\n\nconst flexWrapOptions = [ 'wrap', 'nowrap' ];\n\nexport default {\n\tname: 'flex',\n\tlabel: __( 'Flex' ),\n\tinspectorControls: function FlexLayoutInspectorControls( {\n\t\tlayout = {},\n\t\tonChange,\n\t\tlayoutBlockSupport = {},\n\t} ) {\n\t\tconst { allowOrientation = true } = layoutBlockSupport;\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<Flex>\n\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t<FlexLayoutJustifyContentControl\n\t\t\t\t\t\t\tlayout={ layout }\n\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</FlexItem>\n\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t{ allowOrientation && (\n\t\t\t\t\t\t\t<OrientationControl\n\t\t\t\t\t\t\t\tlayout={ layout }\n\t\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</FlexItem>\n\t\t\t\t</Flex>\n\t\t\t\t<FlexWrapControl layout={ layout } onChange={ onChange } />\n\t\t\t</>\n\t\t);\n\t},\n\ttoolBarControls: function FlexLayoutToolbarControls( {\n\t\tlayout = {},\n\t\tonChange,\n\t\tlayoutBlockSupport,\n\t} ) {\n\t\tif ( layoutBlockSupport?.allowSwitching ) {\n\t\t\treturn null;\n\t\t}\n\t\tconst { allowVerticalAlignment = true } = layoutBlockSupport;\n\t\treturn (\n\t\t\t<BlockControls group=\"block\" __experimentalShareWithChildBlocks>\n\t\t\t\t<FlexLayoutJustifyContentControl\n\t\t\t\t\tlayout={ layout }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\tisToolbar\n\t\t\t\t/>\n\t\t\t\t{ allowVerticalAlignment &&\n\t\t\t\t\tlayout?.orientation !== 'vertical' && (\n\t\t\t\t\t\t<FlexLayoutVerticalAlignmentControl\n\t\t\t\t\t\t\tlayout={ layout }\n\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\tisToolbar\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t</BlockControls>\n\t\t);\n\t},\n\tgetLayoutStyle: function getLayoutStyle( {\n\t\tselector,\n\t\tlayout,\n\t\tstyle,\n\t\tblockName,\n\t\thasBlockGapSupport,\n\t\tlayoutDefinitions,\n\t} ) {\n\t\tconst { orientation = 'horizontal' } = layout;\n\n\t\t// If a block's block.json skips serialization for spacing or spacing.blockGap,\n\t\t// don't apply the user-defined value to the styles.\n\t\tconst blockGapValue =\n\t\t\tstyle?.spacing?.blockGap &&\n\t\t\t! shouldSkipSerialization( blockName, 'spacing', 'blockGap' )\n\t\t\t\t? getGapCSSValue( style?.spacing?.blockGap )\n\t\t\t\t: undefined;\n\t\tconst justifyContent = justifyContentMap[ layout.justifyContent ];\n\t\tconst flexWrap = flexWrapOptions.includes( layout.flexWrap )\n\t\t\t? layout.flexWrap\n\t\t\t: 'wrap';\n\t\tconst verticalAlignment =\n\t\t\tverticalAlignmentMap[ layout.verticalAlignment ];\n\t\tconst alignItems =\n\t\t\talignItemsMap[ layout.justifyContent ] || alignItemsMap.left;\n\n\t\tlet output = '';\n\t\tconst rules = [];\n\n\t\tif ( flexWrap && flexWrap !== 'wrap' ) {\n\t\t\trules.push( `flex-wrap: ${ flexWrap }` );\n\t\t}\n\n\t\tif ( orientation === 'horizontal' ) {\n\t\t\tif ( verticalAlignment ) {\n\t\t\t\trules.push( `align-items: ${ verticalAlignment }` );\n\t\t\t}\n\t\t\tif ( justifyContent ) {\n\t\t\t\trules.push( `justify-content: ${ justifyContent }` );\n\t\t\t}\n\t\t} else {\n\t\t\trules.push( 'flex-direction: column' );\n\t\t\trules.push( `align-items: ${ alignItems }` );\n\t\t}\n\n\t\tif ( rules.length ) {\n\t\t\toutput = `${ appendSelectors( selector ) } {\n\t\t\t\t${ rules.join( '; ' ) };\n\t\t\t}`;\n\t\t}\n\n\t\t// Output blockGap styles based on rules contained in layout definitions in theme.json.\n\t\tif ( hasBlockGapSupport && blockGapValue ) {\n\t\t\toutput += getBlockGapCSS(\n\t\t\t\tselector,\n\t\t\t\tlayoutDefinitions,\n\t\t\t\t'flex',\n\t\t\t\tblockGapValue\n\t\t\t);\n\t\t}\n\t\treturn output;\n\t},\n\tgetOrientation( layout ) {\n\t\tconst { orientation = 'horizontal' } = layout;\n\t\treturn orientation;\n\t},\n\tgetAlignments() {\n\t\treturn [];\n\t},\n};\n\nfunction FlexLayoutVerticalAlignmentControl( {\n\tlayout,\n\tonChange,\n\tisToolbar = false,\n} ) {\n\tconst { verticalAlignment = verticalAlignmentMap.center } = layout;\n\n\tconst onVerticalAlignmentChange = ( value ) => {\n\t\tonChange( {\n\t\t\t...layout,\n\t\t\tverticalAlignment: value,\n\t\t} );\n\t};\n\tif ( isToolbar ) {\n\t\treturn (\n\t\t\t<BlockVerticalAlignmentControl\n\t\t\t\tonChange={ onVerticalAlignmentChange }\n\t\t\t\tvalue={ verticalAlignment }\n\t\t\t/>\n\t\t);\n\t}\n\n\tconst verticalAlignmentOptions = [\n\t\t{\n\t\t\tvalue: 'flex-start',\n\t\t\tlabel: __( 'Align items top' ),\n\t\t},\n\t\t{\n\t\t\tvalue: 'center',\n\t\t\tlabel: __( 'Align items center' ),\n\t\t},\n\t\t{\n\t\t\tvalue: 'flex-end',\n\t\t\tlabel: __( 'Align items bottom' ),\n\t\t},\n\t];\n\n\treturn (\n\t\t<fieldset className=\"block-editor-hooks__flex-layout-vertical-alignment-control\">\n\t\t\t<legend>{ __( 'Vertical alignment' ) }</legend>\n\t\t\t<div>\n\t\t\t\t{ verticalAlignmentOptions.map( ( value, icon, label ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tkey={ value }\n\t\t\t\t\t\t\tlabel={ label }\n\t\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\t\tisPressed={ verticalAlignment === value }\n\t\t\t\t\t\t\tonClick={ () => onVerticalAlignmentChange( value ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t\t</div>\n\t\t</fieldset>\n\t);\n}\n\nfunction FlexLayoutJustifyContentControl( {\n\tlayout,\n\tonChange,\n\tisToolbar = false,\n} ) {\n\tconst { justifyContent = 'left', orientation = 'horizontal' } = layout;\n\tconst onJustificationChange = ( value ) => {\n\t\tonChange( {\n\t\t\t...layout,\n\t\t\tjustifyContent: value,\n\t\t} );\n\t};\n\tconst allowedControls = [ 'left', 'center', 'right' ];\n\tif ( orientation === 'horizontal' ) {\n\t\tallowedControls.push( 'space-between' );\n\t}\n\tif ( isToolbar ) {\n\t\treturn (\n\t\t\t<JustifyContentControl\n\t\t\t\tallowedControls={ allowedControls }\n\t\t\t\tvalue={ justifyContent }\n\t\t\t\tonChange={ onJustificationChange }\n\t\t\t\tpopoverProps={ {\n\t\t\t\t\tposition: 'bottom right',\n\t\t\t\t\tisAlternate: true,\n\t\t\t\t} }\n\t\t\t/>\n\t\t);\n\t}\n\n\tconst justificationOptions = [\n\t\t{\n\t\t\tvalue: 'left',\n\t\t\ticon: justifyLeft,\n\t\t\tlabel: __( 'Justify items left' ),\n\t\t},\n\t\t{\n\t\t\tvalue: 'center',\n\t\t\ticon: justifyCenter,\n\t\t\tlabel: __( 'Justify items center' ),\n\t\t},\n\t\t{\n\t\t\tvalue: 'right',\n\t\t\ticon: justifyRight,\n\t\t\tlabel: __( 'Justify items right' ),\n\t\t},\n\t];\n\tif ( orientation === 'horizontal' ) {\n\t\tjustificationOptions.push( {\n\t\t\tvalue: 'space-between',\n\t\t\ticon: justifySpaceBetween,\n\t\t\tlabel: __( 'Space between items' ),\n\t\t} );\n\t}\n\n\treturn (\n\t\t<fieldset className=\"block-editor-hooks__flex-layout-justification-controls\">\n\t\t\t<legend>{ __( 'Justification' ) }</legend>\n\t\t\t<div>\n\t\t\t\t{ justificationOptions.map( ( { value, icon, label } ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tkey={ value }\n\t\t\t\t\t\t\tlabel={ label }\n\t\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\t\tisPressed={ justifyContent === value }\n\t\t\t\t\t\t\tonClick={ () => onJustificationChange( value ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t\t</div>\n\t\t</fieldset>\n\t);\n}\n\nfunction FlexWrapControl( { layout, onChange } ) {\n\tconst { flexWrap = 'wrap' } = layout;\n\treturn (\n\t\t<ToggleControl\n\t\t\tlabel={ __( 'Allow to wrap to multiple lines' ) }\n\t\t\tonChange={ ( value ) => {\n\t\t\t\tonChange( {\n\t\t\t\t\t...layout,\n\t\t\t\t\tflexWrap: value ? 'wrap' : 'nowrap',\n\t\t\t\t} );\n\t\t\t} }\n\t\t\tchecked={ flexWrap === 'wrap' }\n\t\t/>\n\t);\n}\n\nfunction OrientationControl( { layout, onChange } ) {\n\tconst { orientation = 'horizontal' } = layout;\n\treturn (\n\t\t<fieldset className=\"block-editor-hooks__flex-layout-orientation-controls\">\n\t\t\t<legend>{ __( 'Orientation' ) }</legend>\n\t\t\t<Button\n\t\t\t\tlabel={ __( 'Horizontal' ) }\n\t\t\t\ticon={ arrowRight }\n\t\t\t\tisPressed={ orientation === 'horizontal' }\n\t\t\t\tonClick={ () =>\n\t\t\t\t\tonChange( {\n\t\t\t\t\t\t...layout,\n\t\t\t\t\t\torientation: 'horizontal',\n\t\t\t\t\t} )\n\t\t\t\t}\n\t\t\t/>\n\t\t\t<Button\n\t\t\t\tlabel={ __( 'Vertical' ) }\n\t\t\t\ticon={ arrowDown }\n\t\t\t\tisPressed={ orientation === 'vertical' }\n\t\t\t\tonClick={ () =>\n\t\t\t\t\tonChange( {\n\t\t\t\t\t\t...layout,\n\t\t\t\t\t\torientation: 'vertical',\n\t\t\t\t\t} )\n\t\t\t\t}\n\t\t\t/>\n\t\t</fieldset>\n\t);\n}\n"]}