@wordpress/block-editor 11.4.0 → 11.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (400) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/build/components/block-inspector/index.js +11 -10
  3. package/build/components/block-inspector/index.js.map +1 -1
  4. package/build/components/block-inspector/useBlockInspectorAnimationSettings.js +46 -0
  5. package/build/components/block-inspector/useBlockInspectorAnimationSettings.js.map +1 -0
  6. package/build/components/block-list/block-invalid-warning.js +63 -80
  7. package/build/components/block-list/block-invalid-warning.js.map +1 -1
  8. package/build/components/block-lock/modal.js +1 -0
  9. package/build/components/block-lock/modal.js.map +1 -1
  10. package/build/components/block-settings-menu/block-settings-dropdown.js +2 -2
  11. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  12. package/build/components/block-settings-menu-controls/index.js +1 -1
  13. package/build/components/block-settings-menu-controls/index.js.map +1 -1
  14. package/build/components/block-styles/index.js +2 -1
  15. package/build/components/block-styles/index.js.map +1 -1
  16. package/build/components/block-switcher/block-transformations-menu.native.js +1 -0
  17. package/build/components/block-switcher/block-transformations-menu.native.js.map +1 -1
  18. package/build/components/child-layout-control/index.js +107 -0
  19. package/build/components/child-layout-control/index.js.map +1 -0
  20. package/build/components/convert-to-group-buttons/use-convert-to-group-button-props.js +6 -3
  21. package/build/components/convert-to-group-buttons/use-convert-to-group-button-props.js.map +1 -1
  22. package/build/components/date-format-picker/index.js +3 -3
  23. package/build/components/date-format-picker/index.js.map +1 -1
  24. package/build/components/global-styles/border-panel.js +306 -0
  25. package/build/components/global-styles/border-panel.js.map +1 -0
  26. package/build/components/global-styles/dimensions-panel.js +594 -0
  27. package/build/components/global-styles/dimensions-panel.js.map +1 -0
  28. package/build/components/global-styles/hooks.js +127 -37
  29. package/build/components/global-styles/hooks.js.map +1 -1
  30. package/build/components/global-styles/index.js +36 -2
  31. package/build/components/global-styles/index.js.map +1 -1
  32. package/build/components/global-styles/typography-panel.js +87 -27
  33. package/build/components/global-styles/typography-panel.js.map +1 -1
  34. package/build/components/global-styles/use-global-styles-output.js +21 -14
  35. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  36. package/build/components/global-styles/utils.js +2 -0
  37. package/build/components/global-styles/utils.js.map +1 -1
  38. package/build/components/index.native.js +23 -0
  39. package/build/components/index.native.js.map +1 -1
  40. package/build/components/inserter/index.js +29 -17
  41. package/build/components/inserter/index.js.map +1 -1
  42. package/build/components/inserter/media-tab/hooks.js +10 -11
  43. package/build/components/inserter/media-tab/hooks.js.map +1 -1
  44. package/build/components/inserter/media-tab/media-list.js +5 -108
  45. package/build/components/inserter/media-tab/media-list.js.map +1 -1
  46. package/build/components/inserter/media-tab/media-preview.js +242 -0
  47. package/build/components/inserter/media-tab/media-preview.js.map +1 -0
  48. package/build/components/inserter/menu.js +1 -1
  49. package/build/components/inserter/menu.js.map +1 -1
  50. package/build/components/inserter/quick-inserter.js +4 -2
  51. package/build/components/inserter/quick-inserter.js.map +1 -1
  52. package/build/components/inserter/search-results.js +10 -3
  53. package/build/components/inserter/search-results.js.map +1 -1
  54. package/build/components/inserter/tabs.js +1 -1
  55. package/build/components/inserter/tabs.js.map +1 -1
  56. package/build/components/inspector-controls/block-support-tools-panel.js +1 -1
  57. package/build/components/inspector-controls/block-support-tools-panel.js.map +1 -1
  58. package/build/components/inspector-controls/fill.js +38 -9
  59. package/build/components/inspector-controls/fill.js.map +1 -1
  60. package/build/components/link-control/index.js +1 -1
  61. package/build/components/link-control/index.js.map +1 -1
  62. package/build/components/link-control/search-item.js +5 -2
  63. package/build/components/link-control/search-item.js.map +1 -1
  64. package/build/components/link-control/settings-drawer.js +1 -1
  65. package/build/components/link-control/settings-drawer.js.map +1 -1
  66. package/build/components/link-control/settings.js +1 -0
  67. package/build/components/link-control/settings.js.map +1 -1
  68. package/build/components/list-view/block.js +17 -3
  69. package/build/components/list-view/block.js.map +1 -1
  70. package/build/components/list-view/branch.js +2 -2
  71. package/build/components/list-view/branch.js.map +1 -1
  72. package/build/components/list-view/expander.js +2 -1
  73. package/build/components/list-view/expander.js.map +1 -1
  74. package/build/components/list-view/leaf.js +10 -6
  75. package/build/components/list-view/leaf.js.map +1 -1
  76. package/build/components/list-view/use-block-selection.js +1 -2
  77. package/build/components/list-view/use-block-selection.js.map +1 -1
  78. package/build/components/list-view/use-list-view-scroll-into-view.js +51 -0
  79. package/build/components/list-view/use-list-view-scroll-into-view.js.map +1 -0
  80. package/build/components/off-canvas-editor/appender.js +33 -13
  81. package/build/components/off-canvas-editor/appender.js.map +1 -1
  82. package/build/components/off-canvas-editor/branch.js +6 -3
  83. package/build/components/off-canvas-editor/branch.js.map +1 -1
  84. package/build/components/off-canvas-editor/index.js +8 -2
  85. package/build/components/off-canvas-editor/index.js.map +1 -1
  86. package/build/components/off-canvas-editor/leaf-more-menu.js +34 -4
  87. package/build/components/off-canvas-editor/leaf-more-menu.js.map +1 -1
  88. package/build/components/provider/use-block-sync.js +17 -3
  89. package/build/components/provider/use-block-sync.js.map +1 -1
  90. package/build/components/responsive-block-control/index.js +1 -0
  91. package/build/components/responsive-block-control/index.js.map +1 -1
  92. package/build/components/rich-text/format-toolbar-container.js +0 -3
  93. package/build/components/rich-text/format-toolbar-container.js.map +1 -1
  94. package/build/components/rich-text/index.js +9 -43
  95. package/build/components/rich-text/index.js.map +1 -1
  96. package/build/components/rich-text/use-delete.js +73 -0
  97. package/build/components/rich-text/use-delete.js.map +1 -0
  98. package/build/components/rich-text/use-input-rules.js +14 -6
  99. package/build/components/rich-text/use-input-rules.js.map +1 -1
  100. package/build/components/writing-flow/use-selection-observer.js +4 -1
  101. package/build/components/writing-flow/use-selection-observer.js.map +1 -1
  102. package/build/hooks/align.js +3 -1
  103. package/build/hooks/align.js.map +1 -1
  104. package/build/hooks/border.js +91 -240
  105. package/build/hooks/border.js.map +1 -1
  106. package/build/hooks/custom-class-name.js +4 -4
  107. package/build/hooks/custom-class-name.js.map +1 -1
  108. package/build/hooks/custom-class-name.native.js +3 -4
  109. package/build/hooks/custom-class-name.native.js.map +1 -1
  110. package/build/hooks/dimensions.js +72 -190
  111. package/build/hooks/dimensions.js.map +1 -1
  112. package/build/hooks/duotone.js +94 -25
  113. package/build/hooks/duotone.js.map +1 -1
  114. package/build/hooks/gap.js +0 -202
  115. package/build/hooks/gap.js.map +1 -1
  116. package/build/hooks/layout.js +33 -27
  117. package/build/hooks/layout.js.map +1 -1
  118. package/build/hooks/margin.js +7 -163
  119. package/build/hooks/margin.js.map +1 -1
  120. package/build/hooks/padding.js +7 -163
  121. package/build/hooks/padding.js.map +1 -1
  122. package/build/hooks/supports.js +7 -1
  123. package/build/hooks/supports.js.map +1 -1
  124. package/build/hooks/typography.js +52 -66
  125. package/build/hooks/typography.js.map +1 -1
  126. package/build/hooks/utils.js +101 -0
  127. package/build/hooks/utils.js.map +1 -1
  128. package/build/layouts/constrained.js +6 -2
  129. package/build/layouts/constrained.js.map +1 -1
  130. package/build/layouts/flex.js +1 -0
  131. package/build/layouts/flex.js.map +1 -1
  132. package/build/private-apis.js +4 -1
  133. package/build/private-apis.js.map +1 -1
  134. package/build/store/actions.js +28 -14
  135. package/build/store/actions.js.map +1 -1
  136. package/build/store/defaults.js +28 -1
  137. package/build/store/defaults.js.map +1 -1
  138. package/build/store/reducer.js +53 -47
  139. package/build/store/reducer.js.map +1 -1
  140. package/build/store/selectors.js +24 -4
  141. package/build/store/selectors.js.map +1 -1
  142. package/build/utils/parse-css-unit-to-px.js +49 -10
  143. package/build/utils/parse-css-unit-to-px.js.map +1 -1
  144. package/build-module/components/block-inspector/index.js +9 -9
  145. package/build-module/components/block-inspector/index.js.map +1 -1
  146. package/build-module/components/block-inspector/useBlockInspectorAnimationSettings.js +37 -0
  147. package/build-module/components/block-inspector/useBlockInspectorAnimationSettings.js.map +1 -0
  148. package/build-module/components/block-list/block-invalid-warning.js +66 -78
  149. package/build-module/components/block-list/block-invalid-warning.js.map +1 -1
  150. package/build-module/components/block-lock/modal.js +1 -0
  151. package/build-module/components/block-lock/modal.js.map +1 -1
  152. package/build-module/components/block-settings-menu/block-settings-dropdown.js +2 -2
  153. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  154. package/build-module/components/block-settings-menu-controls/index.js +1 -1
  155. package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
  156. package/build-module/components/block-styles/index.js +2 -1
  157. package/build-module/components/block-styles/index.js.map +1 -1
  158. package/build-module/components/block-switcher/block-transformations-menu.native.js +1 -0
  159. package/build-module/components/block-switcher/block-transformations-menu.native.js.map +1 -1
  160. package/build-module/components/child-layout-control/index.js +98 -0
  161. package/build-module/components/child-layout-control/index.js.map +1 -0
  162. package/build-module/components/convert-to-group-buttons/use-convert-to-group-button-props.js +6 -3
  163. package/build-module/components/convert-to-group-buttons/use-convert-to-group-button-props.js.map +1 -1
  164. package/build-module/components/date-format-picker/index.js +4 -4
  165. package/build-module/components/date-format-picker/index.js.map +1 -1
  166. package/build-module/components/global-styles/border-panel.js +291 -0
  167. package/build-module/components/global-styles/border-panel.js.map +1 -0
  168. package/build-module/components/global-styles/dimensions-panel.js +574 -0
  169. package/build-module/components/global-styles/dimensions-panel.js.map +1 -0
  170. package/build-module/components/global-styles/hooks.js +123 -34
  171. package/build-module/components/global-styles/hooks.js.map +1 -1
  172. package/build-module/components/global-styles/index.js +3 -1
  173. package/build-module/components/global-styles/index.js.map +1 -1
  174. package/build-module/components/global-styles/typography-panel.js +88 -27
  175. package/build-module/components/global-styles/typography-panel.js.map +1 -1
  176. package/build-module/components/global-styles/use-global-styles-output.js +21 -14
  177. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  178. package/build-module/components/global-styles/utils.js +2 -0
  179. package/build-module/components/global-styles/utils.js.map +1 -1
  180. package/build-module/components/index.native.js +2 -1
  181. package/build-module/components/index.native.js.map +1 -1
  182. package/build-module/components/inserter/index.js +28 -16
  183. package/build-module/components/inserter/index.js.map +1 -1
  184. package/build-module/components/inserter/media-tab/hooks.js +10 -11
  185. package/build-module/components/inserter/media-tab/hooks.js.map +1 -1
  186. package/build-module/components/inserter/media-tab/media-list.js +6 -105
  187. package/build-module/components/inserter/media-tab/media-list.js.map +1 -1
  188. package/build-module/components/inserter/media-tab/media-preview.js +222 -0
  189. package/build-module/components/inserter/media-tab/media-preview.js.map +1 -0
  190. package/build-module/components/inserter/menu.js +1 -1
  191. package/build-module/components/inserter/menu.js.map +1 -1
  192. package/build-module/components/inserter/quick-inserter.js +4 -2
  193. package/build-module/components/inserter/quick-inserter.js.map +1 -1
  194. package/build-module/components/inserter/search-results.js +10 -3
  195. package/build-module/components/inserter/search-results.js.map +1 -1
  196. package/build-module/components/inserter/tabs.js +1 -1
  197. package/build-module/components/inserter/tabs.js.map +1 -1
  198. package/build-module/components/inspector-controls/block-support-tools-panel.js +1 -1
  199. package/build-module/components/inspector-controls/block-support-tools-panel.js.map +1 -1
  200. package/build-module/components/inspector-controls/fill.js +39 -9
  201. package/build-module/components/inspector-controls/fill.js.map +1 -1
  202. package/build-module/components/link-control/index.js +1 -1
  203. package/build-module/components/link-control/index.js.map +1 -1
  204. package/build-module/components/link-control/search-item.js +4 -2
  205. package/build-module/components/link-control/search-item.js.map +1 -1
  206. package/build-module/components/link-control/settings-drawer.js +1 -1
  207. package/build-module/components/link-control/settings-drawer.js.map +1 -1
  208. package/build-module/components/link-control/settings.js +1 -0
  209. package/build-module/components/link-control/settings.js.map +1 -1
  210. package/build-module/components/list-view/block.js +16 -3
  211. package/build-module/components/list-view/block.js.map +1 -1
  212. package/build-module/components/list-view/branch.js +2 -2
  213. package/build-module/components/list-view/branch.js.map +1 -1
  214. package/build-module/components/list-view/expander.js +2 -1
  215. package/build-module/components/list-view/expander.js.map +1 -1
  216. package/build-module/components/list-view/leaf.js +8 -4
  217. package/build-module/components/list-view/leaf.js.map +1 -1
  218. package/build-module/components/list-view/use-block-selection.js +1 -2
  219. package/build-module/components/list-view/use-block-selection.js.map +1 -1
  220. package/build-module/components/list-view/use-list-view-scroll-into-view.js +42 -0
  221. package/build-module/components/list-view/use-list-view-scroll-into-view.js.map +1 -0
  222. package/build-module/components/off-canvas-editor/appender.js +33 -14
  223. package/build-module/components/off-canvas-editor/appender.js.map +1 -1
  224. package/build-module/components/off-canvas-editor/branch.js +6 -3
  225. package/build-module/components/off-canvas-editor/branch.js.map +1 -1
  226. package/build-module/components/off-canvas-editor/index.js +8 -2
  227. package/build-module/components/off-canvas-editor/index.js.map +1 -1
  228. package/build-module/components/off-canvas-editor/leaf-more-menu.js +36 -7
  229. package/build-module/components/off-canvas-editor/leaf-more-menu.js.map +1 -1
  230. package/build-module/components/provider/use-block-sync.js +17 -3
  231. package/build-module/components/provider/use-block-sync.js.map +1 -1
  232. package/build-module/components/responsive-block-control/index.js +1 -0
  233. package/build-module/components/responsive-block-control/index.js.map +1 -1
  234. package/build-module/components/rich-text/format-toolbar-container.js +0 -3
  235. package/build-module/components/rich-text/format-toolbar-container.js.map +1 -1
  236. package/build-module/components/rich-text/index.js +9 -43
  237. package/build-module/components/rich-text/index.js.map +1 -1
  238. package/build-module/components/rich-text/use-delete.js +62 -0
  239. package/build-module/components/rich-text/use-delete.js.map +1 -0
  240. package/build-module/components/rich-text/use-input-rules.js +14 -6
  241. package/build-module/components/rich-text/use-input-rules.js.map +1 -1
  242. package/build-module/components/writing-flow/use-selection-observer.js +4 -1
  243. package/build-module/components/writing-flow/use-selection-observer.js.map +1 -1
  244. package/build-module/hooks/align.js +3 -1
  245. package/build-module/hooks/align.js.map +1 -1
  246. package/build-module/hooks/border.js +93 -240
  247. package/build-module/hooks/border.js.map +1 -1
  248. package/build-module/hooks/custom-class-name.js +4 -4
  249. package/build-module/hooks/custom-class-name.js.map +1 -1
  250. package/build-module/hooks/custom-class-name.native.js +3 -4
  251. package/build-module/hooks/custom-class-name.native.js.map +1 -1
  252. package/build-module/hooks/dimensions.js +75 -187
  253. package/build-module/hooks/dimensions.js.map +1 -1
  254. package/build-module/hooks/duotone.js +86 -24
  255. package/build-module/hooks/duotone.js.map +1 -1
  256. package/build-module/hooks/gap.js +0 -183
  257. package/build-module/hooks/gap.js.map +1 -1
  258. package/build-module/hooks/layout.js +33 -27
  259. package/build-module/hooks/layout.js.map +1 -1
  260. package/build-module/hooks/margin.js +4 -143
  261. package/build-module/hooks/margin.js.map +1 -1
  262. package/build-module/hooks/padding.js +4 -143
  263. package/build-module/hooks/padding.js.map +1 -1
  264. package/build-module/hooks/supports.js +7 -1
  265. package/build-module/hooks/supports.js.map +1 -1
  266. package/build-module/hooks/typography.js +54 -66
  267. package/build-module/hooks/typography.js.map +1 -1
  268. package/build-module/hooks/utils.js +96 -0
  269. package/build-module/hooks/utils.js.map +1 -1
  270. package/build-module/layouts/constrained.js +6 -2
  271. package/build-module/layouts/constrained.js.map +1 -1
  272. package/build-module/layouts/flex.js +1 -0
  273. package/build-module/layouts/flex.js.map +1 -1
  274. package/build-module/private-apis.js +3 -1
  275. package/build-module/private-apis.js.map +1 -1
  276. package/build-module/store/actions.js +28 -14
  277. package/build-module/store/actions.js.map +1 -1
  278. package/build-module/store/defaults.js +28 -1
  279. package/build-module/store/defaults.js.map +1 -1
  280. package/build-module/store/reducer.js +53 -45
  281. package/build-module/store/reducer.js.map +1 -1
  282. package/build-module/store/selectors.js +22 -4
  283. package/build-module/store/selectors.js.map +1 -1
  284. package/build-module/utils/parse-css-unit-to-px.js +49 -10
  285. package/build-module/utils/parse-css-unit-to-px.js.map +1 -1
  286. package/build-style/style-rtl.css +39 -27
  287. package/build-style/style.css +39 -27
  288. package/package.json +31 -31
  289. package/src/components/block-draggable/test/__snapshots__/index.native.js.snap +24 -24
  290. package/src/components/block-inspector/index.js +11 -14
  291. package/src/components/block-inspector/style.scss +3 -0
  292. package/src/components/block-inspector/useBlockInspectorAnimationSettings.js +53 -0
  293. package/src/components/block-list/block-invalid-warning.js +72 -64
  294. package/src/components/block-lock/modal.js +1 -0
  295. package/src/components/block-lock/style.scss +0 -9
  296. package/src/components/block-mobile-toolbar/test/__snapshots__/block-actions-menu.native.js.snap +20 -20
  297. package/src/components/block-mover/test/__snapshots__/index.native.js.snap +35 -17
  298. package/src/components/block-preview/test/index.js +0 -2
  299. package/src/components/block-settings-menu/block-settings-dropdown.js +4 -1
  300. package/src/components/block-settings-menu-controls/index.js +2 -1
  301. package/src/components/block-styles/index.js +5 -1
  302. package/src/components/block-styles/style.scss +2 -2
  303. package/src/components/block-switcher/block-transformations-menu.native.js +1 -0
  304. package/src/components/child-layout-control/index.js +106 -0
  305. package/src/components/color-palette/test/__snapshots__/control.js.snap +17 -15
  306. package/src/components/convert-to-group-buttons/use-convert-to-group-button-props.js +48 -38
  307. package/src/components/date-format-picker/index.js +6 -8
  308. package/src/components/date-format-picker/style.scss +0 -5
  309. package/src/components/global-styles/border-panel.js +285 -0
  310. package/src/components/global-styles/dimensions-panel.js +627 -0
  311. package/src/components/global-styles/hooks.js +160 -44
  312. package/src/components/global-styles/index.js +7 -1
  313. package/src/components/global-styles/test/use-global-styles-output.js +1 -1
  314. package/src/components/global-styles/typography-panel.js +81 -9
  315. package/src/components/global-styles/use-global-styles-output.js +17 -16
  316. package/src/components/global-styles/utils.js +2 -0
  317. package/src/components/index.native.js +5 -0
  318. package/src/components/inner-blocks/test/__snapshots__/index.js.snap +1 -1
  319. package/src/components/inserter/index.js +30 -11
  320. package/src/components/inserter/media-tab/hooks.js +9 -8
  321. package/src/components/inserter/media-tab/media-list.js +3 -122
  322. package/src/components/inserter/media-tab/media-preview.js +268 -0
  323. package/src/components/inserter/menu.js +0 -1
  324. package/src/components/inserter/quick-inserter.js +2 -0
  325. package/src/components/inserter/search-results.js +7 -1
  326. package/src/components/inserter/style.scss +25 -0
  327. package/src/components/inserter/tabs.js +1 -9
  328. package/src/components/inserter/test/__snapshots__/index.native.js.snap +15 -15
  329. package/src/components/inspector-controls/block-support-tools-panel.js +0 -1
  330. package/src/components/inspector-controls/fill.js +32 -8
  331. package/src/components/link-control/index.js +1 -1
  332. package/src/components/link-control/search-item.js +3 -1
  333. package/src/components/link-control/settings-drawer.js +2 -1
  334. package/src/components/link-control/settings.js +1 -0
  335. package/src/components/link-control/style.scss +18 -12
  336. package/src/components/link-control/test/index.js +3 -5
  337. package/src/components/list-view/block.js +19 -1
  338. package/src/components/list-view/branch.js +1 -2
  339. package/src/components/list-view/expander.js +1 -0
  340. package/src/components/list-view/leaf.js +43 -29
  341. package/src/components/list-view/use-block-selection.js +0 -2
  342. package/src/components/list-view/use-list-view-scroll-into-view.js +48 -0
  343. package/src/components/media-replace-flow/style.scss +7 -9
  344. package/src/components/off-canvas-editor/appender.js +44 -21
  345. package/src/components/off-canvas-editor/branch.js +4 -1
  346. package/src/components/off-canvas-editor/index.js +7 -1
  347. package/src/components/off-canvas-editor/leaf-more-menu.js +57 -15
  348. package/src/components/provider/use-block-sync.js +21 -4
  349. package/src/components/responsive-block-control/index.js +1 -0
  350. package/src/components/rich-text/format-toolbar-container.js +1 -7
  351. package/src/components/rich-text/index.js +8 -44
  352. package/src/components/rich-text/use-delete.js +59 -0
  353. package/src/components/rich-text/use-input-rules.js +13 -5
  354. package/src/components/spacing-sizes-control/style.scss +1 -1
  355. package/src/components/url-popover/stories/index.js +1 -0
  356. package/src/components/url-popover/test/index.js +0 -2
  357. package/src/components/writing-flow/use-selection-observer.js +5 -1
  358. package/src/hooks/align.js +1 -1
  359. package/src/hooks/border.js +94 -225
  360. package/src/hooks/custom-class-name.js +4 -4
  361. package/src/hooks/custom-class-name.native.js +3 -4
  362. package/src/hooks/dimensions.js +85 -269
  363. package/src/hooks/duotone.js +100 -30
  364. package/src/hooks/gap.js +0 -208
  365. package/src/hooks/layout.js +38 -22
  366. package/src/hooks/margin.js +1 -164
  367. package/src/hooks/padding.js +1 -163
  368. package/src/hooks/supports.js +6 -0
  369. package/src/hooks/test/__snapshots__/align.native.js.snap +24 -24
  370. package/src/hooks/test/duotone.js +102 -0
  371. package/src/hooks/test/style.js +2 -1
  372. package/src/hooks/test/use-typography-props.js +2 -0
  373. package/src/hooks/typography.js +68 -88
  374. package/src/hooks/utils.js +126 -0
  375. package/src/layouts/constrained.js +23 -17
  376. package/src/layouts/flex.js +1 -0
  377. package/src/private-apis.js +2 -0
  378. package/src/store/actions.js +16 -6
  379. package/src/store/defaults.js +14 -1
  380. package/src/store/reducer.js +68 -43
  381. package/src/store/selectors.js +28 -4
  382. package/src/store/test/actions.js +4 -2
  383. package/src/utils/parse-css-unit-to-px.js +48 -13
  384. package/src/utils/test/parse-css-unit-to-px.js +13 -2
  385. package/tsconfig.tsbuildinfo +1 -1
  386. package/build/hooks/border-radius.js +0 -100
  387. package/build/hooks/border-radius.js.map +0 -1
  388. package/build/hooks/child-layout.js +0 -213
  389. package/build/hooks/child-layout.js.map +0 -1
  390. package/build/hooks/min-height.js +0 -139
  391. package/build/hooks/min-height.js.map +0 -1
  392. package/build-module/hooks/border-radius.js +0 -84
  393. package/build-module/hooks/border-radius.js.map +0 -1
  394. package/build-module/hooks/child-layout.js +0 -193
  395. package/build-module/hooks/child-layout.js.map +0 -1
  396. package/build-module/hooks/min-height.js +0 -116
  397. package/build-module/hooks/min-height.js.map +0 -1
  398. package/src/hooks/border-radius.js +0 -70
  399. package/src/hooks/child-layout.js +0 -195
  400. package/src/hooks/min-height.js +0 -104
@@ -10,66 +10,20 @@ import classnames from 'classnames';
10
10
  */
11
11
 
12
12
  import { getBlockSupport } from '@wordpress/blocks';
13
- import { __experimentalBorderBoxControl as BorderBoxControl, __experimentalHasSplitBorders as hasSplitBorders, __experimentalIsDefinedBorder as isDefinedBorder, __experimentalToolsPanelItem as ToolsPanelItem } from '@wordpress/components';
13
+ import { __experimentalHasSplitBorders as hasSplitBorders } from '@wordpress/components';
14
14
  import { createHigherOrderComponent } from '@wordpress/compose';
15
- import { Platform } from '@wordpress/element';
15
+ import { Platform, useCallback, useMemo } from '@wordpress/element';
16
16
  import { addFilter } from '@wordpress/hooks';
17
- import { __ } from '@wordpress/i18n';
18
17
  /**
19
18
  * Internal dependencies
20
19
  */
21
20
 
22
- import { BorderRadiusEdit, hasBorderRadiusValue, resetBorderRadius } from './border-radius';
23
21
  import { getColorClassName } from '../components/colors';
24
22
  import InspectorControls from '../components/inspector-controls';
25
23
  import useMultipleOriginColorsAndGradients from '../components/colors-gradients/use-multiple-origin-colors-and-gradients';
26
- import useSetting from '../components/use-setting';
27
- import { cleanEmptyObject, shouldSkipSerialization } from './utils';
24
+ import { cleanEmptyObject, shouldSkipSerialization, useBlockSettings } from './utils';
25
+ import { useHasBorderPanel, BorderPanel as StylesBorderPanel } from '../components/global-styles';
28
26
  export const BORDER_SUPPORT_KEY = '__experimentalBorder';
29
- const borderSides = ['top', 'right', 'bottom', 'left'];
30
-
31
- const hasBorderValue = props => {
32
- const {
33
- borderColor,
34
- style
35
- } = props.attributes;
36
- return isDefinedBorder(style === null || style === void 0 ? void 0 : style.border) || !!borderColor;
37
- }; // The border color, style, and width are omitted so they get undefined. The
38
- // border radius is separate and must retain its selection.
39
-
40
-
41
- const resetBorder = _ref => {
42
- var _style$border;
43
-
44
- let {
45
- attributes = {},
46
- setAttributes
47
- } = _ref;
48
- const {
49
- style
50
- } = attributes;
51
- setAttributes({
52
- borderColor: undefined,
53
- style: { ...style,
54
- border: cleanEmptyObject({
55
- radius: style === null || style === void 0 ? void 0 : (_style$border = style.border) === null || _style$border === void 0 ? void 0 : _style$border.radius
56
- })
57
- }
58
- });
59
- };
60
-
61
- const resetBorderFilter = newAttributes => {
62
- var _newAttributes$style, _newAttributes$style$;
63
-
64
- return { ...newAttributes,
65
- borderColor: undefined,
66
- style: { ...newAttributes.style,
67
- border: {
68
- radius: (_newAttributes$style = newAttributes.style) === null || _newAttributes$style === void 0 ? void 0 : (_newAttributes$style$ = _newAttributes$style.border) === null || _newAttributes$style$ === void 0 ? void 0 : _newAttributes$style$.radius
69
- }
70
- }
71
- };
72
- };
73
27
 
74
28
  const getColorByProperty = (colors, property, value) => {
75
29
  let matchedColor;
@@ -84,12 +38,12 @@ const getColorByProperty = (colors, property, value) => {
84
38
  return matchedColor;
85
39
  };
86
40
 
87
- export const getMultiOriginColor = _ref2 => {
41
+ export const getMultiOriginColor = _ref => {
88
42
  let {
89
43
  colors,
90
44
  namedColor,
91
45
  customColor
92
- } = _ref2;
46
+ } = _ref;
93
47
 
94
48
  // Search each origin (default, theme, or user) for matching color by name.
95
49
  if (namedColor) {
@@ -114,60 +68,6 @@ export const getMultiOriginColor = _ref2 => {
114
68
  };
115
69
  };
116
70
 
117
- const getBorderObject = (attributes, colors) => {
118
- const {
119
- borderColor,
120
- style
121
- } = attributes;
122
- const {
123
- border: borderStyles
124
- } = style || {}; // If we have a named color for a flat border. Fetch that color object and
125
- // apply that color's value to the color property within the style object.
126
-
127
- if (borderColor) {
128
- const {
129
- color
130
- } = getMultiOriginColor({
131
- colors,
132
- namedColor: borderColor
133
- });
134
- return color ? { ...borderStyles,
135
- color
136
- } : borderStyles;
137
- } // Individual side border color slugs are stored within the border style
138
- // object. If we don't have a border styles object we have nothing further
139
- // to hydrate.
140
-
141
-
142
- if (!borderStyles) {
143
- return borderStyles;
144
- } // If we have named colors for the individual side borders, retrieve their
145
- // related color objects and apply the real color values to the split
146
- // border objects.
147
-
148
-
149
- const hydratedBorderStyles = { ...borderStyles
150
- };
151
- borderSides.forEach(side => {
152
- var _hydratedBorderStyles;
153
-
154
- const colorSlug = getColorSlugFromVariable((_hydratedBorderStyles = hydratedBorderStyles[side]) === null || _hydratedBorderStyles === void 0 ? void 0 : _hydratedBorderStyles.color);
155
-
156
- if (colorSlug) {
157
- const {
158
- color
159
- } = getMultiOriginColor({
160
- colors,
161
- namedColor: colorSlug
162
- });
163
- hydratedBorderStyles[side] = { ...hydratedBorderStyles[side],
164
- color
165
- };
166
- }
167
- });
168
- return hydratedBorderStyles;
169
- };
170
-
171
71
  function getColorSlugFromVariable(value) {
172
72
  const namedColor = /var:preset\|color\|(.+)/.exec(value);
173
73
 
@@ -178,142 +78,95 @@ function getColorSlugFromVariable(value) {
178
78
  return null;
179
79
  }
180
80
 
181
- export function BorderPanel(props) {
182
- const {
183
- attributes,
184
- clientId,
185
- setAttributes
186
- } = props;
187
- const {
188
- style
189
- } = attributes;
190
- const {
191
- colors
192
- } = useMultipleOriginColorsAndGradients();
193
- const isSupported = hasBorderSupport(props.name);
194
- const isColorSupported = useSetting('border.color') && hasBorderSupport(props.name, 'color');
195
- const isRadiusSupported = useSetting('border.radius') && hasBorderSupport(props.name, 'radius');
196
- const isStyleSupported = useSetting('border.style') && hasBorderSupport(props.name, 'style');
197
- const isWidthSupported = useSetting('border.width') && hasBorderSupport(props.name, 'width');
198
- const isDisabled = [!isColorSupported, !isRadiusSupported, !isStyleSupported, !isWidthSupported].every(Boolean);
199
-
200
- if (isDisabled || !isSupported) {
201
- return null;
81
+ function styleToAttributes(style) {
82
+ var _style$border;
83
+
84
+ if (hasSplitBorders(style === null || style === void 0 ? void 0 : style.border)) {
85
+ return {
86
+ style,
87
+ borderColor: undefined
88
+ };
202
89
  }
203
90
 
204
- const defaultBorderControls = getBlockSupport(props.name, [BORDER_SUPPORT_KEY, '__experimentalDefaultControls']);
205
- const showBorderByDefault = (defaultBorderControls === null || defaultBorderControls === void 0 ? void 0 : defaultBorderControls.color) || (defaultBorderControls === null || defaultBorderControls === void 0 ? void 0 : defaultBorderControls.width);
91
+ const borderColorValue = style === null || style === void 0 ? void 0 : (_style$border = style.border) === null || _style$border === void 0 ? void 0 : _style$border.color;
92
+ const borderColorSlug = borderColorValue !== null && borderColorValue !== void 0 && borderColorValue.startsWith('var:preset|color|') ? borderColorSlug.substring('var:preset|color|'.length) : undefined;
93
+ const updatedStyle = { ...style
94
+ };
95
+ updatedStyle.border = { ...updatedStyle.border,
96
+ color: borderColorSlug ? undefined : borderColorValue
97
+ };
98
+ return {
99
+ style: cleanEmptyObject(updatedStyle),
100
+ borderColor: borderColorSlug
101
+ };
102
+ }
206
103
 
207
- const onBorderChange = newBorder => {
208
- var _style$border2;
104
+ function attributesToStyle(attributes) {
105
+ var _attributes$style, _attributes$style2, _attributes$style3, _attributes$style3$bo;
209
106
 
210
- // Filter out named colors and apply them to appropriate block
211
- // attributes so that CSS classes can be used to apply those colors.
212
- // e.g. has-primary-border-top-color.
213
- let newBorderStyles = { ...newBorder
214
- };
215
- let newBorderColor;
216
-
217
- if (hasSplitBorders(newBorder)) {
218
- // For each side check if the side has a color value set
219
- // If so, determine if it belongs to a named color, in which case
220
- // we update the color property.
221
- //
222
- // This deliberately overwrites `newBorderStyles` to avoid mutating
223
- // the passed object which causes problems otherwise.
224
- newBorderStyles = {
225
- top: { ...newBorder.top
226
- },
227
- right: { ...newBorder.right
228
- },
229
- bottom: { ...newBorder.bottom
230
- },
231
- left: { ...newBorder.left
232
- }
233
- };
234
- borderSides.forEach(side => {
235
- var _newBorder$side;
236
-
237
- if ((_newBorder$side = newBorder[side]) !== null && _newBorder$side !== void 0 && _newBorder$side.color) {
238
- var _newBorder$side2;
239
-
240
- const colorObject = getMultiOriginColor({
241
- colors,
242
- customColor: (_newBorder$side2 = newBorder[side]) === null || _newBorder$side2 === void 0 ? void 0 : _newBorder$side2.color
243
- });
244
-
245
- if (colorObject.slug) {
246
- newBorderStyles[side].color = `var:preset|color|${colorObject.slug}`;
247
- }
248
- }
249
- });
250
- } else if (newBorder !== null && newBorder !== void 0 && newBorder.color) {
251
- // We have a flat border configuration. Apply named color slug to
252
- // `borderColor` attribute and clear color style property if found.
253
- const customColor = newBorder === null || newBorder === void 0 ? void 0 : newBorder.color;
254
- const colorObject = getMultiOriginColor({
255
- colors,
256
- customColor
257
- });
258
-
259
- if (colorObject.slug) {
260
- newBorderColor = colorObject.slug;
261
- newBorderStyles.color = undefined;
262
- }
263
- } // Ensure previous border radius styles are maintained and clean
264
- // overall result for empty objects or properties.
107
+ if (hasSplitBorders((_attributes$style = attributes.style) === null || _attributes$style === void 0 ? void 0 : _attributes$style.border)) {
108
+ return attributes.style;
109
+ }
110
+
111
+ return { ...attributes.style,
112
+ border: { ...((_attributes$style2 = attributes.style) === null || _attributes$style2 === void 0 ? void 0 : _attributes$style2.border),
113
+ color: attributes.borderColor ? 'var:preset|color|' + attributes.borderColor : (_attributes$style3 = attributes.style) === null || _attributes$style3 === void 0 ? void 0 : (_attributes$style3$bo = _attributes$style3.border) === null || _attributes$style3$bo === void 0 ? void 0 : _attributes$style3$bo.color
114
+ }
115
+ };
116
+ }
265
117
 
118
+ function BordersInspectorControl(_ref2) {
119
+ let {
120
+ children,
121
+ resetAllFilter
122
+ } = _ref2;
123
+ const attributesResetAllFilter = useCallback(attributes => {
124
+ const existingStyle = attributesToStyle(attributes);
125
+ const updatedStyle = resetAllFilter(existingStyle);
126
+ return { ...attributes,
127
+ ...styleToAttributes(updatedStyle)
128
+ };
129
+ }, [resetAllFilter]);
130
+ return createElement(InspectorControls, {
131
+ group: "border",
132
+ resetAllFilter: attributesResetAllFilter
133
+ }, children);
134
+ }
266
135
 
267
- const newStyle = cleanEmptyObject({ ...style,
268
- border: {
269
- radius: style === null || style === void 0 ? void 0 : (_style$border2 = style.border) === null || _style$border2 === void 0 ? void 0 : _style$border2.radius,
270
- ...newBorderStyles
271
- }
272
- });
273
- setAttributes({
274
- style: newStyle,
275
- borderColor: newBorderColor
136
+ export function BorderPanel(props) {
137
+ const {
138
+ clientId,
139
+ name,
140
+ attributes,
141
+ setAttributes
142
+ } = props;
143
+ const settings = useBlockSettings(name);
144
+ const isEnabled = useHasBorderPanel(settings);
145
+ const value = useMemo(() => {
146
+ return attributesToStyle({
147
+ style: attributes.style,
148
+ borderColor: attributes.borderColor
276
149
  });
150
+ }, [attributes.style, attributes.borderColor]);
151
+
152
+ const onChange = newStyle => {
153
+ setAttributes(styleToAttributes(newStyle));
277
154
  };
278
155
 
279
- const hydratedBorder = getBorderObject(attributes, colors);
280
- return createElement(InspectorControls, {
281
- group: "border"
282
- }, (isWidthSupported || isColorSupported) && createElement(ToolsPanelItem, {
283
- hasValue: () => hasBorderValue(props),
284
- label: __('Border'),
285
- onDeselect: () => resetBorder(props),
286
- isShownByDefault: showBorderByDefault,
287
- resetAllFilter: resetBorderFilter,
288
- panelId: clientId
289
- }, createElement(BorderBoxControl, {
290
- colors: colors,
291
- enableAlpha: true,
292
- enableStyle: isStyleSupported,
293
- onChange: onBorderChange,
294
- popoverOffset: 40,
295
- popoverPlacement: "left-start",
296
- size: "__unstable-large",
297
- value: hydratedBorder,
298
- __experimentalIsRenderedInSidebar: true
299
- })), isRadiusSupported && createElement(ToolsPanelItem, {
300
- hasValue: () => hasBorderRadiusValue(props),
301
- label: __('Radius'),
302
- onDeselect: () => resetBorderRadius(props),
303
- isShownByDefault: defaultBorderControls === null || defaultBorderControls === void 0 ? void 0 : defaultBorderControls.radius,
304
- resetAllFilter: newAttributes => {
305
- var _newAttributes$style2;
306
-
307
- return { ...newAttributes,
308
- style: { ...newAttributes.style,
309
- border: { ...((_newAttributes$style2 = newAttributes.style) === null || _newAttributes$style2 === void 0 ? void 0 : _newAttributes$style2.border),
310
- radius: undefined
311
- }
312
- }
313
- };
314
- },
315
- panelId: clientId
316
- }, createElement(BorderRadiusEdit, props)));
156
+ if (!isEnabled) {
157
+ return null;
158
+ }
159
+
160
+ const defaultControls = getBlockSupport(props.name, [BORDER_SUPPORT_KEY, '__experimentalDefaultControls']);
161
+ return createElement(StylesBorderPanel, {
162
+ as: BordersInspectorControl,
163
+ panelId: clientId,
164
+ name: name,
165
+ settings: settings,
166
+ value: value,
167
+ onChange: onChange,
168
+ defaultControls: defaultControls
169
+ });
317
170
  }
318
171
  /**
319
172
  * Determine whether there is block support for border properties.
@@ -422,7 +275,7 @@ function addSaveProps(props, blockType, attributes) {
422
275
 
423
276
 
424
277
  export function getBorderClasses(attributes) {
425
- var _style$border3;
278
+ var _style$border2;
426
279
 
427
280
  const {
428
281
  borderColor,
@@ -430,7 +283,7 @@ export function getBorderClasses(attributes) {
430
283
  } = attributes;
431
284
  const borderColorClass = getColorClassName('border-color', borderColor);
432
285
  return classnames({
433
- 'has-border-color': borderColor || (style === null || style === void 0 ? void 0 : (_style$border3 = style.border) === null || _style$border3 === void 0 ? void 0 : _style$border3.color),
286
+ 'has-border-color': borderColor || (style === null || style === void 0 ? void 0 : (_style$border2 = style.border) === null || _style$border2 === void 0 ? void 0 : _style$border2.color),
434
287
  [borderColorClass]: !!borderColorClass
435
288
  });
436
289
  }
@@ -473,7 +326,7 @@ function addEditProps(settings) {
473
326
 
474
327
 
475
328
  export const withBorderColorPaletteStyles = createHigherOrderComponent(BlockListBlock => props => {
476
- var _style$border4, _style$border4$top, _style$border5, _style$border5$right, _style$border6, _style$border6$bottom, _style$border7, _style$border7$left, _props$wrapperProps;
329
+ var _style$border3, _style$border3$top, _style$border4, _style$border4$right, _style$border5, _style$border5$bottom, _style$border6, _style$border6$left, _props$wrapperProps;
477
330
 
478
331
  const {
479
332
  name,
@@ -501,25 +354,25 @@ export const withBorderColorPaletteStyles = createHigherOrderComponent(BlockList
501
354
  color: borderTopColor
502
355
  } = getMultiOriginColor({
503
356
  colors,
504
- namedColor: getColorSlugFromVariable(style === null || style === void 0 ? void 0 : (_style$border4 = style.border) === null || _style$border4 === void 0 ? void 0 : (_style$border4$top = _style$border4.top) === null || _style$border4$top === void 0 ? void 0 : _style$border4$top.color)
357
+ namedColor: getColorSlugFromVariable(style === null || style === void 0 ? void 0 : (_style$border3 = style.border) === null || _style$border3 === void 0 ? void 0 : (_style$border3$top = _style$border3.top) === null || _style$border3$top === void 0 ? void 0 : _style$border3$top.color)
505
358
  });
506
359
  const {
507
360
  color: borderRightColor
508
361
  } = getMultiOriginColor({
509
362
  colors,
510
- namedColor: getColorSlugFromVariable(style === null || style === void 0 ? void 0 : (_style$border5 = style.border) === null || _style$border5 === void 0 ? void 0 : (_style$border5$right = _style$border5.right) === null || _style$border5$right === void 0 ? void 0 : _style$border5$right.color)
363
+ namedColor: getColorSlugFromVariable(style === null || style === void 0 ? void 0 : (_style$border4 = style.border) === null || _style$border4 === void 0 ? void 0 : (_style$border4$right = _style$border4.right) === null || _style$border4$right === void 0 ? void 0 : _style$border4$right.color)
511
364
  });
512
365
  const {
513
366
  color: borderBottomColor
514
367
  } = getMultiOriginColor({
515
368
  colors,
516
- namedColor: getColorSlugFromVariable(style === null || style === void 0 ? void 0 : (_style$border6 = style.border) === null || _style$border6 === void 0 ? void 0 : (_style$border6$bottom = _style$border6.bottom) === null || _style$border6$bottom === void 0 ? void 0 : _style$border6$bottom.color)
369
+ namedColor: getColorSlugFromVariable(style === null || style === void 0 ? void 0 : (_style$border5 = style.border) === null || _style$border5 === void 0 ? void 0 : (_style$border5$bottom = _style$border5.bottom) === null || _style$border5$bottom === void 0 ? void 0 : _style$border5$bottom.color)
517
370
  });
518
371
  const {
519
372
  color: borderLeftColor
520
373
  } = getMultiOriginColor({
521
374
  colors,
522
- namedColor: getColorSlugFromVariable(style === null || style === void 0 ? void 0 : (_style$border7 = style.border) === null || _style$border7 === void 0 ? void 0 : (_style$border7$left = _style$border7.left) === null || _style$border7$left === void 0 ? void 0 : _style$border7$left.color)
375
+ namedColor: getColorSlugFromVariable(style === null || style === void 0 ? void 0 : (_style$border6 = style.border) === null || _style$border6 === void 0 ? void 0 : (_style$border6$left = _style$border6.left) === null || _style$border6$left === void 0 ? void 0 : _style$border6$left.color)
523
376
  });
524
377
  const extraStyles = {
525
378
  borderTopColor: borderTopColor || borderColorValue,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/hooks/border.js"],"names":["classnames","getBlockSupport","__experimentalBorderBoxControl","BorderBoxControl","__experimentalHasSplitBorders","hasSplitBorders","__experimentalIsDefinedBorder","isDefinedBorder","__experimentalToolsPanelItem","ToolsPanelItem","createHigherOrderComponent","Platform","addFilter","__","BorderRadiusEdit","hasBorderRadiusValue","resetBorderRadius","getColorClassName","InspectorControls","useMultipleOriginColorsAndGradients","useSetting","cleanEmptyObject","shouldSkipSerialization","BORDER_SUPPORT_KEY","borderSides","hasBorderValue","props","borderColor","style","attributes","border","resetBorder","setAttributes","undefined","radius","resetBorderFilter","newAttributes","getColorByProperty","colors","property","value","matchedColor","some","origin","color","getMultiOriginColor","namedColor","customColor","colorObject","getBorderObject","borderStyles","hydratedBorderStyles","forEach","side","colorSlug","getColorSlugFromVariable","exec","BorderPanel","clientId","isSupported","hasBorderSupport","name","isColorSupported","isRadiusSupported","isStyleSupported","isWidthSupported","isDisabled","every","Boolean","defaultBorderControls","showBorderByDefault","width","onBorderChange","newBorder","newBorderStyles","newBorderColor","top","right","bottom","left","slug","newStyle","hydratedBorder","blockName","feature","OS","support","removeBorderAttribute","attribute","addAttributes","settings","type","addSaveProps","blockType","borderClasses","getBorderClasses","newClassName","className","borderColorClass","addEditProps","existingGetEditWrapperProps","getEditWrapperProps","withBorderColorPaletteStyles","BlockListBlock","borderColorValue","borderTopColor","borderRightColor","borderBottomColor","borderLeftColor","extraStyles","wrapperProps"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,eAAT,QAAgC,mBAAhC;AACA,SACCC,8BAA8B,IAAIC,gBADnC,EAECC,6BAA6B,IAAIC,eAFlC,EAGCC,6BAA6B,IAAIC,eAHlC,EAICC,4BAA4B,IAAIC,cAJjC,QAKO,uBALP;AAMA,SAASC,0BAAT,QAA2C,oBAA3C;AACA,SAASC,QAAT,QAAyB,oBAAzB;AACA,SAASC,SAAT,QAA0B,kBAA1B;AACA,SAASC,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AACA,SACCC,gBADD,EAECC,oBAFD,EAGCC,iBAHD,QAIO,iBAJP;AAKA,SAASC,iBAAT,QAAkC,sBAAlC;AACA,OAAOC,iBAAP,MAA8B,kCAA9B;AACA,OAAOC,mCAAP,MAAgD,yEAAhD;AACA,OAAOC,UAAP,MAAuB,2BAAvB;AACA,SAASC,gBAAT,EAA2BC,uBAA3B,QAA0D,SAA1D;AAEA,OAAO,MAAMC,kBAAkB,GAAG,sBAA3B;AAEP,MAAMC,WAAW,GAAG,CAAE,KAAF,EAAS,OAAT,EAAkB,QA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AAA,KAAK,EAAEgE;AAAT,MAA6B/D,mBAAmB,CAAE;AACvDP,IAAAA,MADuD;AAEvDQ,IAAAA,UAAU,EAAES,wBAAwB,CAAE3B,KAAF,aAAEA,KAAF,yCAAEA,KAAK,CAAEE,MAAT,0EAAE,eAAeiD,IAAjB,wDAAE,oBAAqBnC,KAAvB;AAFmB,GAAF,CAAtD;AAKA,QAAMiE,WAAW,GAAG;AACnBJ,IAAAA,cAAc,EAAEA,cAAc,IAAID,gBADf;AAEnBE,IAAAA,gBAAgB,EAAEA,gBAAgB,IAAIF,gBAFnB;AAGnBG,IAAAA,iBAAiB,EAAEA,iBAAiB,IAAIH,gBAHrB;AAInBI,IAAAA,eAAe,EAAEA,eAAe,IAAIJ;AAJjB,GAApB;AAOA,MAAIM,YAAY,GAAGpF,KAAK,CAACoF,YAAzB;AACAA,EAAAA,YAAY,GAAG,EACd,GAAGpF,KAAK,CAACoF,YADK;AAEdlF,IAAAA,KAAK,EAAE,EACN,2BAAGF,KAAK,CAACoF,YAAT,wDAAG,oBAAoBlF,KAAvB,CADM;AAEN,SAAGiF;AAFG;AAFO,GAAf;AAQA,SAAO,cAAC,cAAD,eAAqBnF,KAArB;AAA6B,IAAA,YAAY,EAAGoF;AAA5C,KAAP;AACA,CAtDoE,CAA/D;AAyDPlG,SAAS,CACR,0BADQ,EAER,2BAFQ,EAGR6E,aAHQ,CAAT;AAMA7E,SAAS,CACR,kCADQ,EAER,0BAFQ,EAGRgF,YAHQ,CAAT;AAMAhF,SAAS,CACR,0BADQ,EAER,0BAFQ,EAGRuF,YAHQ,CAAT;AAMAvF,SAAS,CACR,uBADQ,EAER,8CAFQ,EAGR0F,4BAHQ,CAAT","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { getBlockSupport } from '@wordpress/blocks';\nimport {\n\t__experimentalBorderBoxControl as BorderBoxControl,\n\t__experimentalHasSplitBorders as hasSplitBorders,\n\t__experimentalIsDefinedBorder as isDefinedBorder,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { Platform } from '@wordpress/element';\nimport { addFilter } from '@wordpress/hooks';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport {\n\tBorderRadiusEdit,\n\thasBorderRadiusValue,\n\tresetBorderRadius,\n} from './border-radius';\nimport { getColorClassName } from '../components/colors';\nimport InspectorControls from '../components/inspector-controls';\nimport useMultipleOriginColorsAndGradients from '../components/colors-gradients/use-multiple-origin-colors-and-gradients';\nimport useSetting from '../components/use-setting';\nimport { cleanEmptyObject, shouldSkipSerialization } from './utils';\n\nexport const BORDER_SUPPORT_KEY = '__experimentalBorder';\n\nconst borderSides = [ 'top', 'right', 'bottom', 'left' ];\n\nconst hasBorderValue = ( props ) => {\n\tconst { borderColor, style } = props.attributes;\n\treturn isDefinedBorder( style?.border ) || !! borderColor;\n};\n\n// The border color, style, and width are omitted so they get undefined. The\n// border radius is separate and must retain its selection.\nconst resetBorder = ( { attributes = {}, setAttributes } ) => {\n\tconst { style } = attributes;\n\tsetAttributes( {\n\t\tborderColor: undefined,\n\t\tstyle: {\n\t\t\t...style,\n\t\t\tborder: cleanEmptyObject( {\n\t\t\t\tradius: style?.border?.radius,\n\t\t\t} ),\n\t\t},\n\t} );\n};\n\nconst resetBorderFilter = ( newAttributes ) => ( {\n\t...newAttributes,\n\tborderColor: undefined,\n\tstyle: {\n\t\t...newAttributes.style,\n\t\tborder: {\n\t\t\tradius: newAttributes.style?.border?.radius,\n\t\t},\n\t},\n} );\n\nconst getColorByProperty = ( colors, property, value ) => {\n\tlet matchedColor;\n\n\tcolors.some( ( origin ) =>\n\t\torigin.colors.some( ( color ) => {\n\t\t\tif ( color[ property ] === value ) {\n\t\t\t\tmatchedColor = color;\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\treturn false;\n\t\t} )\n\t);\n\n\treturn matchedColor;\n};\n\nexport const getMultiOriginColor = ( { colors, namedColor, customColor } ) => {\n\t// Search each origin (default, theme, or user) for matching color by name.\n\tif ( namedColor ) {\n\t\tconst colorObject = getColorByProperty( colors, 'slug', namedColor );\n\t\tif ( colorObject ) {\n\t\t\treturn colorObject;\n\t\t}\n\t}\n\n\t// Skip if no custom color or matching named color.\n\tif ( ! customColor ) {\n\t\treturn { color: undefined };\n\t}\n\n\t// Attempt to find color via custom color value or build new object.\n\tconst colorObject = getColorByProperty( colors, 'color', customColor );\n\treturn colorObject ? colorObject : { color: customColor };\n};\n\nconst getBorderObject = ( attributes, colors ) => {\n\tconst { borderColor, style } = attributes;\n\tconst { border: borderStyles } = style || {};\n\n\t// If we have a named color for a flat border. Fetch that color object and\n\t// apply that color's value to the color property within the style object.\n\tif ( borderColor ) {\n\t\tconst { color } = getMultiOriginColor( {\n\t\t\tcolors,\n\t\t\tnamedColor: borderColor,\n\t\t} );\n\n\t\treturn color ? { ...borderStyles, color } : borderStyles;\n\t}\n\n\t// Individual side border color slugs are stored within the border style\n\t// object. If we don't have a border styles object we have nothing further\n\t// to hydrate.\n\tif ( ! borderStyles ) {\n\t\treturn borderStyles;\n\t}\n\n\t// If we have named colors for the individual side borders, retrieve their\n\t// related color objects and apply the real color values to the split\n\t// border objects.\n\tconst hydratedBorderStyles = { ...borderStyles };\n\tborderSides.forEach( ( side ) => {\n\t\tconst colorSlug = getColorSlugFromVariable(\n\t\t\thydratedBorderStyles[ side ]?.color\n\t\t);\n\t\tif ( colorSlug ) {\n\t\t\tconst { color } = getMultiOriginColor( {\n\t\t\t\tcolors,\n\t\t\t\tnamedColor: colorSlug,\n\t\t\t} );\n\t\t\thydratedBorderStyles[ side ] = {\n\t\t\t\t...hydratedBorderStyles[ side ],\n\t\t\t\tcolor,\n\t\t\t};\n\t\t}\n\t} );\n\n\treturn hydratedBorderStyles;\n};\n\nfunction getColorSlugFromVariable( value ) {\n\tconst namedColor = /var:preset\\|color\\|(.+)/.exec( value );\n\tif ( namedColor && namedColor[ 1 ] ) {\n\t\treturn namedColor[ 1 ];\n\t}\n\treturn null;\n}\n\nexport function BorderPanel( props ) {\n\tconst { attributes, clientId, setAttributes } = props;\n\tconst { style } = attributes;\n\tconst { colors } = useMultipleOriginColorsAndGradients();\n\n\tconst isSupported = hasBorderSupport( props.name );\n\tconst isColorSupported =\n\t\tuseSetting( 'border.color' ) && hasBorderSupport( props.name, 'color' );\n\tconst isRadiusSupported =\n\t\tuseSetting( 'border.radius' ) &&\n\t\thasBorderSupport( props.name, 'radius' );\n\tconst isStyleSupported =\n\t\tuseSetting( 'border.style' ) && hasBorderSupport( props.name, 'style' );\n\tconst isWidthSupported =\n\t\tuseSetting( 'border.width' ) && hasBorderSupport( props.name, 'width' );\n\n\tconst isDisabled = [\n\t\t! isColorSupported,\n\t\t! isRadiusSupported,\n\t\t! isStyleSupported,\n\t\t! isWidthSupported,\n\t].every( Boolean );\n\n\tif ( isDisabled || ! isSupported ) {\n\t\treturn null;\n\t}\n\n\tconst defaultBorderControls = getBlockSupport( props.name, [\n\t\tBORDER_SUPPORT_KEY,\n\t\t'__experimentalDefaultControls',\n\t] );\n\n\tconst showBorderByDefault =\n\t\tdefaultBorderControls?.color || defaultBorderControls?.width;\n\n\tconst onBorderChange = ( newBorder ) => {\n\t\t// Filter out named colors and apply them to appropriate block\n\t\t// attributes so that CSS classes can be used to apply those colors.\n\t\t// e.g. has-primary-border-top-color.\n\n\t\tlet newBorderStyles = { ...newBorder };\n\t\tlet newBorderColor;\n\n\t\tif ( hasSplitBorders( newBorder ) ) {\n\t\t\t// For each side check if the side has a color value set\n\t\t\t// If so, determine if it belongs to a named color, in which case\n\t\t\t// we update the color property.\n\t\t\t//\n\t\t\t// This deliberately overwrites `newBorderStyles` to avoid mutating\n\t\t\t// the passed object which causes problems otherwise.\n\t\t\tnewBorderStyles = {\n\t\t\t\ttop: { ...newBorder.top },\n\t\t\t\tright: { ...newBorder.right },\n\t\t\t\tbottom: { ...newBorder.bottom },\n\t\t\t\tleft: { ...newBorder.left },\n\t\t\t};\n\n\t\t\tborderSides.forEach( ( side ) => {\n\t\t\t\tif ( newBorder[ side ]?.color ) {\n\t\t\t\t\tconst colorObject = getMultiOriginColor( {\n\t\t\t\t\t\tcolors,\n\t\t\t\t\t\tcustomColor: newBorder[ side ]?.color,\n\t\t\t\t\t} );\n\n\t\t\t\t\tif ( colorObject.slug ) {\n\t\t\t\t\t\tnewBorderStyles[\n\t\t\t\t\t\t\tside\n\t\t\t\t\t\t].color = `var:preset|color|${ colorObject.slug }`;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} );\n\t\t} else if ( newBorder?.color ) {\n\t\t\t// We have a flat border configuration. Apply named color slug to\n\t\t\t// `borderColor` attribute and clear color style property if found.\n\t\t\tconst customColor = newBorder?.color;\n\t\t\tconst colorObject = getMultiOriginColor( { colors, customColor } );\n\n\t\t\tif ( colorObject.slug ) {\n\t\t\t\tnewBorderColor = colorObject.slug;\n\t\t\t\tnewBorderStyles.color = undefined;\n\t\t\t}\n\t\t}\n\n\t\t// Ensure previous border radius styles are maintained and clean\n\t\t// overall result for empty objects or properties.\n\t\tconst newStyle = cleanEmptyObject( {\n\t\t\t...style,\n\t\t\tborder: { radius: style?.border?.radius, ...newBorderStyles },\n\t\t} );\n\n\t\tsetAttributes( {\n\t\t\tstyle: newStyle,\n\t\t\tborderColor: newBorderColor,\n\t\t} );\n\t};\n\n\tconst hydratedBorder = getBorderObject( attributes, colors );\n\n\treturn (\n\t\t<InspectorControls group=\"border\">\n\t\t\t{ ( isWidthSupported || isColorSupported ) && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ () => hasBorderValue( props ) }\n\t\t\t\t\tlabel={ __( 'Border' ) }\n\t\t\t\t\tonDeselect={ () => resetBorder( props ) }\n\t\t\t\t\tisShownByDefault={ showBorderByDefault }\n\t\t\t\t\tresetAllFilter={ resetBorderFilter }\n\t\t\t\t\tpanelId={ clientId }\n\t\t\t\t>\n\t\t\t\t\t<BorderBoxControl\n\t\t\t\t\t\tcolors={ colors }\n\t\t\t\t\t\tenableAlpha={ true }\n\t\t\t\t\t\tenableStyle={ isStyleSupported }\n\t\t\t\t\t\tonChange={ onBorderChange }\n\t\t\t\t\t\tpopoverOffset={ 40 }\n\t\t\t\t\t\tpopoverPlacement=\"left-start\"\n\t\t\t\t\t\tsize=\"__unstable-large\"\n\t\t\t\t\t\tvalue={ hydratedBorder }\n\t\t\t\t\t\t__experimentalIsRenderedInSidebar={ true }\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t\t{ isRadiusSupported && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ () => hasBorderRadiusValue( props ) }\n\t\t\t\t\tlabel={ __( 'Radius' ) }\n\t\t\t\t\tonDeselect={ () => resetBorderRadius( props ) }\n\t\t\t\t\tisShownByDefault={ defaultBorderControls?.radius }\n\t\t\t\t\tresetAllFilter={ ( newAttributes ) => ( {\n\t\t\t\t\t\t...newAttributes,\n\t\t\t\t\t\tstyle: {\n\t\t\t\t\t\t\t...newAttributes.style,\n\t\t\t\t\t\t\tborder: {\n\t\t\t\t\t\t\t\t...newAttributes.style?.border,\n\t\t\t\t\t\t\t\tradius: undefined,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t} ) }\n\t\t\t\t\tpanelId={ clientId }\n\t\t\t\t>\n\t\t\t\t\t<BorderRadiusEdit { ...props } />\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t</InspectorControls>\n\t);\n}\n\n/**\n * Determine whether there is block support for border properties.\n *\n * @param {string} blockName Block name.\n * @param {string} feature Border feature to check support for.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasBorderSupport( blockName, feature = 'any' ) {\n\tif ( Platform.OS !== 'web' ) {\n\t\treturn false;\n\t}\n\n\tconst support = getBlockSupport( blockName, BORDER_SUPPORT_KEY );\n\n\tif ( support === true ) {\n\t\treturn true;\n\t}\n\n\tif ( feature === 'any' ) {\n\t\treturn !! (\n\t\t\tsupport?.color ||\n\t\t\tsupport?.radius ||\n\t\t\tsupport?.width ||\n\t\t\tsupport?.style\n\t\t);\n\t}\n\n\treturn !! support?.[ feature ];\n}\n\n/**\n * Returns a new style object where the specified border attribute has been\n * removed.\n *\n * @param {Object} style Styles from block attributes.\n * @param {string} attribute The border style attribute to clear.\n *\n * @return {Object} Style object with the specified attribute removed.\n */\nexport function removeBorderAttribute( style, attribute ) {\n\treturn cleanEmptyObject( {\n\t\t...style,\n\t\tborder: {\n\t\t\t...style?.border,\n\t\t\t[ attribute ]: undefined,\n\t\t},\n\t} );\n}\n\n/**\n * Filters registered block settings, extending attributes to include\n * `borderColor` if needed.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Updated block settings.\n */\nfunction addAttributes( settings ) {\n\tif ( ! hasBorderSupport( settings, 'color' ) ) {\n\t\treturn settings;\n\t}\n\n\t// Allow blocks to specify default value if needed.\n\tif ( settings.attributes.borderColor ) {\n\t\treturn settings;\n\t}\n\n\t// Add new borderColor attribute to block settings.\n\treturn {\n\t\t...settings,\n\t\tattributes: {\n\t\t\t...settings.attributes,\n\t\t\tborderColor: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t},\n\t};\n}\n\n/**\n * Override props assigned to save component to inject border color.\n *\n * @param {Object} props Additional props applied to save element.\n * @param {Object} blockType Block type definition.\n * @param {Object} attributes Block's attributes.\n *\n * @return {Object} Filtered props to apply to save element.\n */\nfunction addSaveProps( props, blockType, attributes ) {\n\tif (\n\t\t! hasBorderSupport( blockType, 'color' ) ||\n\t\tshouldSkipSerialization( blockType, BORDER_SUPPORT_KEY, 'color' )\n\t) {\n\t\treturn props;\n\t}\n\n\tconst borderClasses = getBorderClasses( attributes );\n\tconst newClassName = classnames( props.className, borderClasses );\n\n\t// If we are clearing the last of the previous classes in `className`\n\t// set it to `undefined` to avoid rendering empty DOM attributes.\n\tprops.className = newClassName ? newClassName : undefined;\n\n\treturn props;\n}\n\n/**\n * Generates a CSS class name consisting of all the applicable border color\n * classes given the current block attributes.\n *\n * @param {Object} attributes Block's attributes.\n *\n * @return {string} CSS class name.\n */\nexport function getBorderClasses( attributes ) {\n\tconst { borderColor, style } = attributes;\n\tconst borderColorClass = getColorClassName( 'border-color', borderColor );\n\n\treturn classnames( {\n\t\t'has-border-color': borderColor || style?.border?.color,\n\t\t[ borderColorClass ]: !! borderColorClass,\n\t} );\n}\n\n/**\n * Filters the registered block settings to apply border color styles and\n * classnames to the block edit wrapper.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nfunction addEditProps( settings ) {\n\tif (\n\t\t! hasBorderSupport( settings, 'color' ) ||\n\t\tshouldSkipSerialization( settings, BORDER_SUPPORT_KEY, 'color' )\n\t) {\n\t\treturn settings;\n\t}\n\n\tconst existingGetEditWrapperProps = settings.getEditWrapperProps;\n\tsettings.getEditWrapperProps = ( attributes ) => {\n\t\tlet props = {};\n\n\t\tif ( existingGetEditWrapperProps ) {\n\t\t\tprops = existingGetEditWrapperProps( attributes );\n\t\t}\n\n\t\treturn addSaveProps( props, settings, attributes );\n\t};\n\n\treturn settings;\n}\n\n/**\n * This adds inline styles for color palette colors.\n * Ideally, this is not needed and themes should load their palettes on the editor.\n *\n * @param {Function} BlockListBlock Original component.\n *\n * @return {Function} Wrapped component.\n */\nexport const withBorderColorPaletteStyles = createHigherOrderComponent(\n\t( BlockListBlock ) => ( props ) => {\n\t\tconst { name, attributes } = props;\n\t\tconst { borderColor, style } = attributes;\n\t\tconst { colors } = useMultipleOriginColorsAndGradients();\n\n\t\tif (\n\t\t\t! hasBorderSupport( name, 'color' ) ||\n\t\t\tshouldSkipSerialization( name, BORDER_SUPPORT_KEY, 'color' )\n\t\t) {\n\t\t\treturn <BlockListBlock { ...props } />;\n\t\t}\n\n\t\tconst { color: borderColorValue } = getMultiOriginColor( {\n\t\t\tcolors,\n\t\t\tnamedColor: borderColor,\n\t\t} );\n\t\tconst { color: borderTopColor } = getMultiOriginColor( {\n\t\t\tcolors,\n\t\t\tnamedColor: getColorSlugFromVariable( style?.border?.top?.color ),\n\t\t} );\n\t\tconst { color: borderRightColor } = getMultiOriginColor( {\n\t\t\tcolors,\n\t\t\tnamedColor: getColorSlugFromVariable( style?.border?.right?.color ),\n\t\t} );\n\n\t\tconst { color: borderBottomColor } = getMultiOriginColor( {\n\t\t\tcolors,\n\t\t\tnamedColor: getColorSlugFromVariable(\n\t\t\t\tstyle?.border?.bottom?.color\n\t\t\t),\n\t\t} );\n\t\tconst { color: borderLeftColor } = getMultiOriginColor( {\n\t\t\tcolors,\n\t\t\tnamedColor: getColorSlugFromVariable( style?.border?.left?.color ),\n\t\t} );\n\n\t\tconst extraStyles = {\n\t\t\tborderTopColor: borderTopColor || borderColorValue,\n\t\t\tborderRightColor: borderRightColor || borderColorValue,\n\t\t\tborderBottomColor: borderBottomColor || borderColorValue,\n\t\t\tborderLeftColor: borderLeftColor || borderColorValue,\n\t\t};\n\n\t\tlet wrapperProps = props.wrapperProps;\n\t\twrapperProps = {\n\t\t\t...props.wrapperProps,\n\t\t\tstyle: {\n\t\t\t\t...props.wrapperProps?.style,\n\t\t\t\t...extraStyles,\n\t\t\t},\n\t\t};\n\n\t\treturn <BlockListBlock { ...props } wrapperProps={ wrapperProps } />;\n\t}\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/border/addAttributes',\n\taddAttributes\n);\n\naddFilter(\n\t'blocks.getSaveContent.extraProps',\n\t'core/border/addSaveProps',\n\taddSaveProps\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/border/addEditProps',\n\taddEditProps\n);\n\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/border/with-border-color-palette-styles',\n\twithBorderColorPaletteStyles\n);\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/hooks/border.js"],"names":["classnames","getBlockSupport","__experimentalHasSplitBorders","hasSplitBorders","createHigherOrderComponent","Platform","useCallback","useMemo","addFilter","getColorClassName","InspectorControls","useMultipleOriginColorsAndGradients","cleanEmptyObject","shouldSkipSerialization","useBlockSettings","useHasBorderPanel","BorderPanel","StylesBorderPanel","BORDER_SUPPORT_KEY","getColorByProperty","colors","property","value","matchedColor","some","origin","color","getMultiOriginColor","namedColor","customColor","colorObject","undefined","getColorSlugFromVariable","exec","styleToAttributes","style","border","borderColor","borderColorValue","borderColorSlug","startsWith","substring","length","updatedStyle","attributesToStyle","attributes","BordersInspectorControl","children","resetAllFilter","attributesResetAllFilter","existingStyle","props","clientId","name","setAttributes","settings","isEnabled","onChange","newStyle","defaultControls","hasBorderSupport","blockName","feature","OS","support","radius","width","removeBorderAttribute","attribute","addAttributes","type","addSaveProps","blockType","borderClasses","getBorderClasses","newClassName","className","borderColorClass","addEditProps","existingGetEditWrapperProps","getEditWrapperProps","withBorderColorPaletteStyles","BlockListBlock","borderTopColor","top","borderRightColor","right","borderBottomColor","bottom","borderLeftColor","left","extraStyles","wrapperProps"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,eAAT,QAAgC,mBAAhC;AACA,SAASC,6BAA6B,IAAIC,eAA1C,QAAiE,uBAAjE;AACA,SAASC,0BAAT,QAA2C,oBAA3C;AACA,SAASC,QAAT,EAAmBC,WAAnB,EAAgCC,OAAhC,QAA+C,oBAA/C;AACA,SAASC,SAAT,QAA0B,kBAA1B;AAEA;AACA;AACA;;AACA,SAASC,iBAAT,QAAkC,sBAAlC;AACA,OAAOC,iBAAP,MAA8B,kCAA9B;AACA,OAAOC,mCAAP,MAAgD,yEAAhD;AACA,SACCC,gBADD,EAECC,uBAFD,EAGCC,gBAHD,QAIO,SAJP;AAKA,SACCC,iBADD,EAECC,WAAW,IAAIC,iBAFhB,QAGO,6BAHP;AAKA,OAAO,MAAMC,kBAAkB,GAAG,sBAA3B;;AAEP,MAAMC,kBAAkB,GAAG,CAAEC,MAAF,EAAUC,Q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AT,0EAAE,eAAesD,IAAjB,wDAAE,oBAAqBhE,KAAvB;AAFmB,GAAF,CAAtD;AAKA,QAAMiE,WAAW,GAAG;AACnBR,IAAAA,cAAc,EAAEA,cAAc,IAAI7C,gBADf;AAEnB+C,IAAAA,gBAAgB,EAAEA,gBAAgB,IAAI/C,gBAFnB;AAGnBiD,IAAAA,iBAAiB,EAAEA,iBAAiB,IAAIjD,gBAHrB;AAInBmD,IAAAA,eAAe,EAAEA,eAAe,IAAInD;AAJjB,GAApB;AAOA,MAAIsD,YAAY,GAAGzC,KAAK,CAACyC,YAAzB;AACAA,EAAAA,YAAY,GAAG,EACd,GAAGzC,KAAK,CAACyC,YADK;AAEdzD,IAAAA,KAAK,EAAE,EACN,2BAAGgB,KAAK,CAACyC,YAAT,wDAAG,oBAAoBzD,KAAvB,CADM;AAEN,SAAGwD;AAFG;AAFO,GAAf;AAQA,SAAO,cAAC,cAAD,eAAqBxC,KAArB;AAA6B,IAAA,YAAY,EAAGyC;AAA5C,KAAP;AACA,CAtDoE,CAA/D;AAyDPpF,SAAS,CACR,0BADQ,EAER,2BAFQ,EAGR6D,aAHQ,CAAT;AAMA7D,SAAS,CACR,kCADQ,EAER,0BAFQ,EAGR+D,YAHQ,CAAT;AAMA/D,SAAS,CACR,0BADQ,EAER,0BAFQ,EAGRsE,YAHQ,CAAT;AAMAtE,SAAS,CACR,uBADQ,EAER,8CAFQ,EAGRyE,4BAHQ,CAAT","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { getBlockSupport } from '@wordpress/blocks';\nimport { __experimentalHasSplitBorders as hasSplitBorders } from '@wordpress/components';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { Platform, useCallback, useMemo } from '@wordpress/element';\nimport { addFilter } from '@wordpress/hooks';\n\n/**\n * Internal dependencies\n */\nimport { getColorClassName } from '../components/colors';\nimport InspectorControls from '../components/inspector-controls';\nimport useMultipleOriginColorsAndGradients from '../components/colors-gradients/use-multiple-origin-colors-and-gradients';\nimport {\n\tcleanEmptyObject,\n\tshouldSkipSerialization,\n\tuseBlockSettings,\n} from './utils';\nimport {\n\tuseHasBorderPanel,\n\tBorderPanel as StylesBorderPanel,\n} from '../components/global-styles';\n\nexport const BORDER_SUPPORT_KEY = '__experimentalBorder';\n\nconst getColorByProperty = ( colors, property, value ) => {\n\tlet matchedColor;\n\n\tcolors.some( ( origin ) =>\n\t\torigin.colors.some( ( color ) => {\n\t\t\tif ( color[ property ] === value ) {\n\t\t\t\tmatchedColor = color;\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\treturn false;\n\t\t} )\n\t);\n\n\treturn matchedColor;\n};\n\nexport const getMultiOriginColor = ( { colors, namedColor, customColor } ) => {\n\t// Search each origin (default, theme, or user) for matching color by name.\n\tif ( namedColor ) {\n\t\tconst colorObject = getColorByProperty( colors, 'slug', namedColor );\n\t\tif ( colorObject ) {\n\t\t\treturn colorObject;\n\t\t}\n\t}\n\n\t// Skip if no custom color or matching named color.\n\tif ( ! customColor ) {\n\t\treturn { color: undefined };\n\t}\n\n\t// Attempt to find color via custom color value or build new object.\n\tconst colorObject = getColorByProperty( colors, 'color', customColor );\n\treturn colorObject ? colorObject : { color: customColor };\n};\n\nfunction getColorSlugFromVariable( value ) {\n\tconst namedColor = /var:preset\\|color\\|(.+)/.exec( value );\n\tif ( namedColor && namedColor[ 1 ] ) {\n\t\treturn namedColor[ 1 ];\n\t}\n\treturn null;\n}\n\nfunction styleToAttributes( style ) {\n\tif ( hasSplitBorders( style?.border ) ) {\n\t\treturn {\n\t\t\tstyle,\n\t\t\tborderColor: undefined,\n\t\t};\n\t}\n\n\tconst borderColorValue = style?.border?.color;\n\tconst borderColorSlug = borderColorValue?.startsWith( 'var:preset|color|' )\n\t\t? borderColorSlug.substring( 'var:preset|color|'.length )\n\t\t: undefined;\n\tconst updatedStyle = { ...style };\n\tupdatedStyle.border = {\n\t\t...updatedStyle.border,\n\t\tcolor: borderColorSlug ? undefined : borderColorValue,\n\t};\n\treturn {\n\t\tstyle: cleanEmptyObject( updatedStyle ),\n\t\tborderColor: borderColorSlug,\n\t};\n}\n\nfunction attributesToStyle( attributes ) {\n\tif ( hasSplitBorders( attributes.style?.border ) ) {\n\t\treturn attributes.style;\n\t}\n\treturn {\n\t\t...attributes.style,\n\t\tborder: {\n\t\t\t...attributes.style?.border,\n\t\t\tcolor: attributes.borderColor\n\t\t\t\t? 'var:preset|color|' + attributes.borderColor\n\t\t\t\t: attributes.style?.border?.color,\n\t\t},\n\t};\n}\n\nfunction BordersInspectorControl( { children, resetAllFilter } ) {\n\tconst attributesResetAllFilter = useCallback(\n\t\t( attributes ) => {\n\t\t\tconst existingStyle = attributesToStyle( attributes );\n\t\t\tconst updatedStyle = resetAllFilter( existingStyle );\n\t\t\treturn {\n\t\t\t\t...attributes,\n\t\t\t\t...styleToAttributes( updatedStyle ),\n\t\t\t};\n\t\t},\n\t\t[ resetAllFilter ]\n\t);\n\n\treturn (\n\t\t<InspectorControls\n\t\t\tgroup=\"border\"\n\t\t\tresetAllFilter={ attributesResetAllFilter }\n\t\t>\n\t\t\t{ children }\n\t\t</InspectorControls>\n\t);\n}\n\nexport function BorderPanel( props ) {\n\tconst { clientId, name, attributes, setAttributes } = props;\n\tconst settings = useBlockSettings( name );\n\tconst isEnabled = useHasBorderPanel( settings );\n\tconst value = useMemo( () => {\n\t\treturn attributesToStyle( {\n\t\t\tstyle: attributes.style,\n\t\t\tborderColor: attributes.borderColor,\n\t\t} );\n\t}, [ attributes.style, attributes.borderColor ] );\n\n\tconst onChange = ( newStyle ) => {\n\t\tsetAttributes( styleToAttributes( newStyle ) );\n\t};\n\n\tif ( ! isEnabled ) {\n\t\treturn null;\n\t}\n\n\tconst defaultControls = getBlockSupport( props.name, [\n\t\tBORDER_SUPPORT_KEY,\n\t\t'__experimentalDefaultControls',\n\t] );\n\n\treturn (\n\t\t<StylesBorderPanel\n\t\t\tas={ BordersInspectorControl }\n\t\t\tpanelId={ clientId }\n\t\t\tname={ name }\n\t\t\tsettings={ settings }\n\t\t\tvalue={ value }\n\t\t\tonChange={ onChange }\n\t\t\tdefaultControls={ defaultControls }\n\t\t/>\n\t);\n}\n\n/**\n * Determine whether there is block support for border properties.\n *\n * @param {string} blockName Block name.\n * @param {string} feature Border feature to check support for.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasBorderSupport( blockName, feature = 'any' ) {\n\tif ( Platform.OS !== 'web' ) {\n\t\treturn false;\n\t}\n\n\tconst support = getBlockSupport( blockName, BORDER_SUPPORT_KEY );\n\n\tif ( support === true ) {\n\t\treturn true;\n\t}\n\n\tif ( feature === 'any' ) {\n\t\treturn !! (\n\t\t\tsupport?.color ||\n\t\t\tsupport?.radius ||\n\t\t\tsupport?.width ||\n\t\t\tsupport?.style\n\t\t);\n\t}\n\n\treturn !! support?.[ feature ];\n}\n\n/**\n * Returns a new style object where the specified border attribute has been\n * removed.\n *\n * @param {Object} style Styles from block attributes.\n * @param {string} attribute The border style attribute to clear.\n *\n * @return {Object} Style object with the specified attribute removed.\n */\nexport function removeBorderAttribute( style, attribute ) {\n\treturn cleanEmptyObject( {\n\t\t...style,\n\t\tborder: {\n\t\t\t...style?.border,\n\t\t\t[ attribute ]: undefined,\n\t\t},\n\t} );\n}\n\n/**\n * Filters registered block settings, extending attributes to include\n * `borderColor` if needed.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Updated block settings.\n */\nfunction addAttributes( settings ) {\n\tif ( ! hasBorderSupport( settings, 'color' ) ) {\n\t\treturn settings;\n\t}\n\n\t// Allow blocks to specify default value if needed.\n\tif ( settings.attributes.borderColor ) {\n\t\treturn settings;\n\t}\n\n\t// Add new borderColor attribute to block settings.\n\treturn {\n\t\t...settings,\n\t\tattributes: {\n\t\t\t...settings.attributes,\n\t\t\tborderColor: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t},\n\t};\n}\n\n/**\n * Override props assigned to save component to inject border color.\n *\n * @param {Object} props Additional props applied to save element.\n * @param {Object} blockType Block type definition.\n * @param {Object} attributes Block's attributes.\n *\n * @return {Object} Filtered props to apply to save element.\n */\nfunction addSaveProps( props, blockType, attributes ) {\n\tif (\n\t\t! hasBorderSupport( blockType, 'color' ) ||\n\t\tshouldSkipSerialization( blockType, BORDER_SUPPORT_KEY, 'color' )\n\t) {\n\t\treturn props;\n\t}\n\n\tconst borderClasses = getBorderClasses( attributes );\n\tconst newClassName = classnames( props.className, borderClasses );\n\n\t// If we are clearing the last of the previous classes in `className`\n\t// set it to `undefined` to avoid rendering empty DOM attributes.\n\tprops.className = newClassName ? newClassName : undefined;\n\n\treturn props;\n}\n\n/**\n * Generates a CSS class name consisting of all the applicable border color\n * classes given the current block attributes.\n *\n * @param {Object} attributes Block's attributes.\n *\n * @return {string} CSS class name.\n */\nexport function getBorderClasses( attributes ) {\n\tconst { borderColor, style } = attributes;\n\tconst borderColorClass = getColorClassName( 'border-color', borderColor );\n\n\treturn classnames( {\n\t\t'has-border-color': borderColor || style?.border?.color,\n\t\t[ borderColorClass ]: !! borderColorClass,\n\t} );\n}\n\n/**\n * Filters the registered block settings to apply border color styles and\n * classnames to the block edit wrapper.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nfunction addEditProps( settings ) {\n\tif (\n\t\t! hasBorderSupport( settings, 'color' ) ||\n\t\tshouldSkipSerialization( settings, BORDER_SUPPORT_KEY, 'color' )\n\t) {\n\t\treturn settings;\n\t}\n\n\tconst existingGetEditWrapperProps = settings.getEditWrapperProps;\n\tsettings.getEditWrapperProps = ( attributes ) => {\n\t\tlet props = {};\n\n\t\tif ( existingGetEditWrapperProps ) {\n\t\t\tprops = existingGetEditWrapperProps( attributes );\n\t\t}\n\n\t\treturn addSaveProps( props, settings, attributes );\n\t};\n\n\treturn settings;\n}\n\n/**\n * This adds inline styles for color palette colors.\n * Ideally, this is not needed and themes should load their palettes on the editor.\n *\n * @param {Function} BlockListBlock Original component.\n *\n * @return {Function} Wrapped component.\n */\nexport const withBorderColorPaletteStyles = createHigherOrderComponent(\n\t( BlockListBlock ) => ( props ) => {\n\t\tconst { name, attributes } = props;\n\t\tconst { borderColor, style } = attributes;\n\t\tconst { colors } = useMultipleOriginColorsAndGradients();\n\n\t\tif (\n\t\t\t! hasBorderSupport( name, 'color' ) ||\n\t\t\tshouldSkipSerialization( name, BORDER_SUPPORT_KEY, 'color' )\n\t\t) {\n\t\t\treturn <BlockListBlock { ...props } />;\n\t\t}\n\n\t\tconst { color: borderColorValue } = getMultiOriginColor( {\n\t\t\tcolors,\n\t\t\tnamedColor: borderColor,\n\t\t} );\n\t\tconst { color: borderTopColor } = getMultiOriginColor( {\n\t\t\tcolors,\n\t\t\tnamedColor: getColorSlugFromVariable( style?.border?.top?.color ),\n\t\t} );\n\t\tconst { color: borderRightColor } = getMultiOriginColor( {\n\t\t\tcolors,\n\t\t\tnamedColor: getColorSlugFromVariable( style?.border?.right?.color ),\n\t\t} );\n\n\t\tconst { color: borderBottomColor } = getMultiOriginColor( {\n\t\t\tcolors,\n\t\t\tnamedColor: getColorSlugFromVariable(\n\t\t\t\tstyle?.border?.bottom?.color\n\t\t\t),\n\t\t} );\n\t\tconst { color: borderLeftColor } = getMultiOriginColor( {\n\t\t\tcolors,\n\t\t\tnamedColor: getColorSlugFromVariable( style?.border?.left?.color ),\n\t\t} );\n\n\t\tconst extraStyles = {\n\t\t\tborderTopColor: borderTopColor || borderColorValue,\n\t\t\tborderRightColor: borderRightColor || borderColorValue,\n\t\t\tborderBottomColor: borderBottomColor || borderColorValue,\n\t\t\tborderLeftColor: borderLeftColor || borderColorValue,\n\t\t};\n\n\t\tlet wrapperProps = props.wrapperProps;\n\t\twrapperProps = {\n\t\t\t...props.wrapperProps,\n\t\t\tstyle: {\n\t\t\t\t...props.wrapperProps?.style,\n\t\t\t\t...extraStyles,\n\t\t\t},\n\t\t};\n\n\t\treturn <BlockListBlock { ...props } wrapperProps={ wrapperProps } />;\n\t}\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/border/addAttributes',\n\taddAttributes\n);\n\naddFilter(\n\t'blocks.getSaveContent.extraProps',\n\t'core/border/addSaveProps',\n\taddSaveProps\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/border/addEditProps',\n\taddEditProps\n);\n\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/border/with-border-color-palette-styles',\n\twithBorderColorPaletteStyles\n);\n"]}
@@ -19,8 +19,7 @@ import { createHigherOrderComponent } from '@wordpress/compose';
19
19
 
20
20
  import { InspectorControls } from '../components';
21
21
  /**
22
- * Filters registered block settings, extending attributes with anchor using ID
23
- * of the first node.
22
+ * Filters registered block settings, extending attributes to include `className`.
24
23
  *
25
24
  * @param {Object} settings Original block settings.
26
25
  *
@@ -42,6 +41,7 @@ export function addAttribute(settings) {
42
41
  /**
43
42
  * Override the default edit UI to include a new block inspector control for
44
43
  * assigning the custom class name, if block supports custom class name.
44
+ * The control is displayed within the Advanced panel in the block inspector.
45
45
  *
46
46
  * @param {WPComponent} BlockEdit Original component.
47
47
  *
@@ -73,8 +73,8 @@ export const withInspectorControl = createHigherOrderComponent(BlockEdit => {
73
73
  };
74
74
  }, 'withInspectorControl');
75
75
  /**
76
- * Override props assigned to save component to inject anchor ID, if block
77
- * supports anchor. This is only applied if the block's save result is an
76
+ * Override props assigned to save component to inject the className, if block
77
+ * supports customClassName. This is only applied if the block's save result is an
78
78
  * element and not a markup string.
79
79
  *
80
80
  * @param {Object} extraProps Additional props applied to save element.
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/hooks/custom-class-name.js"],"names":["classnames","addFilter","TextControl","__","hasBlockSupport","createHigherOrderComponent","InspectorControls","addAttribute","settings","attributes","className","type","withInspectorControl","BlockEdit","props","hasCustomClassName","name","isSelected","nextValue","setAttributes","undefined","addSaveProps","extraProps","blockType","addTransforms","result","source","index","results","length","innerBlocks","originClassName"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP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,MAAP;AACA,GAlB8D,CAoB/D;AACA;AACA;AACA;;;AACA,MAAKC,MAAM,CAAEC,KAAF,CAAX,EAAuB;AAAA;;AACtB,UAAMI,eAAe,oBAAGL,MAAM,CAAEC,KAAF,CAAT,kDAAG,cAAiBlB,UAAjB,CAA4BC,SAApD;;AACA,QAAKqB,eAAL,EAAuB;AACtB,aAAO,EACN,GAAGN,MADG;AAENhB,QAAAA,UAAU,EAAE,EACX,GAAGgB,MAAM,CAAChB,UADC;AAEXC,UAAAA,SAAS,EAAEqB;AAFA;AAFN,OAAP;AAOA;AACD;;AACD,SAAON,MAAP;AACA;AAEDxB,SAAS,CACR,0BADQ,EAER,kCAFQ,EAGRM,YAHQ,CAAT;AAKAN,SAAS,CACR,kBADQ,EAER,sDAFQ,EAGRW,oBAHQ,CAAT;AAKAX,SAAS,CACR,kCADQ,EAER,mCAFQ,EAGRoB,YAHQ,CAAT;AAMApB,SAAS,CACR,2CADQ,EAER,0BAFQ,EAGRuB,aAHQ,CAAT","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { TextControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { hasBlockSupport } from '@wordpress/blocks';\nimport { createHigherOrderComponent } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { InspectorControls } from '../components';\n\n/**\n * Filters registered block settings, extending attributes with anchor using ID\n * of the first node.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nexport function addAttribute( settings ) {\n\tif ( hasBlockSupport( settings, 'customClassName', true ) ) {\n\t\t// Gracefully handle if settings.attributes is undefined.\n\t\tsettings.attributes = {\n\t\t\t...settings.attributes,\n\t\t\tclassName: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t};\n\t}\n\n\treturn settings;\n}\n\n/**\n * Override the default edit UI to include a new block inspector control for\n * assigning the custom class name, if block supports custom class name.\n *\n * @param {WPComponent} BlockEdit Original component.\n *\n * @return {WPComponent} Wrapped component.\n */\nexport const withInspectorControl = createHigherOrderComponent(\n\t( BlockEdit ) => {\n\t\treturn ( props ) => {\n\t\t\tconst hasCustomClassName = hasBlockSupport(\n\t\t\t\tprops.name,\n\t\t\t\t'customClassName',\n\t\t\t\ttrue\n\t\t\t);\n\t\t\tif ( hasCustomClassName && props.isSelected ) {\n\t\t\t\treturn (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<BlockEdit { ...props } />\n\t\t\t\t\t\t<InspectorControls group=\"advanced\">\n\t\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\t\t\t\tlabel={ __( 'Additional CSS class(es)' ) }\n\t\t\t\t\t\t\t\tvalue={ props.attributes.className || '' }\n\t\t\t\t\t\t\t\tonChange={ ( nextValue ) => {\n\t\t\t\t\t\t\t\t\tprops.setAttributes( {\n\t\t\t\t\t\t\t\t\t\tclassName:\n\t\t\t\t\t\t\t\t\t\t\tnextValue !== ''\n\t\t\t\t\t\t\t\t\t\t\t\t? nextValue\n\t\t\t\t\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t\t\t'Separate multiple classes with spaces.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</InspectorControls>\n\t\t\t\t\t</>\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn <BlockEdit { ...props } />;\n\t\t};\n\t},\n\t'withInspectorControl'\n);\n\n/**\n * Override props assigned to save component to inject anchor ID, if block\n * supports anchor. This is only applied if the block's save result is an\n * element and not a markup string.\n *\n * @param {Object} extraProps Additional props applied to save element.\n * @param {Object} blockType Block type.\n * @param {Object} attributes Current block attributes.\n *\n * @return {Object} Filtered props applied to save element.\n */\nexport function addSaveProps( extraProps, blockType, attributes ) {\n\tif (\n\t\thasBlockSupport( blockType, 'customClassName', true ) &&\n\t\tattributes.className\n\t) {\n\t\textraProps.className = classnames(\n\t\t\textraProps.className,\n\t\t\tattributes.className\n\t\t);\n\t}\n\n\treturn extraProps;\n}\n\nexport function addTransforms( result, source, index, results ) {\n\tif ( ! hasBlockSupport( result.name, 'customClassName', true ) ) {\n\t\treturn result;\n\t}\n\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 class should not be kept.\n\tif ( results.length === 1 && result.innerBlocks.length === source.length ) {\n\t\treturn result;\n\t}\n\n\t// If we are transforming one block to multiple blocks or multiple blocks to one block,\n\t// we ignore the class during the transform.\n\tif (\n\t\t( results.length === 1 && source.length > 1 ) ||\n\t\t( results.length > 1 && source.length === 1 )\n\t) {\n\t\treturn result;\n\t}\n\n\t// If we are in presence of transform between one or more block in the source\n\t// that have one or more blocks in the result\n\t// we apply the class on source N to the result N,\n\t// if source N does not exists we do nothing.\n\tif ( source[ index ] ) {\n\t\tconst originClassName = source[ index ]?.attributes.className;\n\t\tif ( originClassName ) {\n\t\t\treturn {\n\t\t\t\t...result,\n\t\t\t\tattributes: {\n\t\t\t\t\t...result.attributes,\n\t\t\t\t\tclassName: originClassName,\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\t}\n\treturn result;\n}\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/custom-class-name/attribute',\n\taddAttribute\n);\naddFilter(\n\t'editor.BlockEdit',\n\t'core/editor/custom-class-name/with-inspector-control',\n\twithInspectorControl\n);\naddFilter(\n\t'blocks.getSaveContent.extraProps',\n\t'core/custom-class-name/save-props',\n\taddSaveProps\n);\n\naddFilter(\n\t'blocks.switchToBlockType.transformedBlock',\n\t'core/color/addTransforms',\n\taddTransforms\n);\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/hooks/custom-class-name.js"],"names":["classnames","addFilter","TextControl","__","hasBlockSupport","createHigherOrderComponent","InspectorControls","addAttribute","settings","attributes","className","type","withInspectorControl","BlockEdit","props","hasCustomClassName","name","isSelected","nextValue","setAttributes","undefined","addSaveProps","extraProps","blockType","addTransforms","result","source","index","results","length","innerBlocks","originClassName"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,SAAT,QAA0B,kBAA1B;AACA,SAASC,WAAT,QAA4B,uBAA5B;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,eAAT,QAAgC,mBAAhC;AACA,SAASC,0BAAT,QAA2C,oBAA3C;AAEA;AACA;AACA;;AACA,SAASC,iBAAT,QAAkC,eAAlC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,YAAT,CAAuBC,QAAvB,EAAkC;AACxC,MAAKJ,eAAe,CAAEI,QAAF,EAAY,iBAAZ,EAA+B,IAA/B,CAApB,EAA4D;AAC3D;AACAA,IAAAA,QAAQ,CAACC,UAAT,GAAsB,EACrB,GAAGD,QAAQ,CAACC,UADS;AAErBC,MAAAA,SAAS,EAAE;AACVC,QAAAA,IAAI,EAAE;AADI;AAFU,KAAtB;AAMA;;AAED,SAAOH,QAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMI,oBAAoB,GAAGP,0BAA0B,CAC3DQ,SAAF,IAAiB;AAChB,SAASC,KAAF,IAAa;AACnB,UAAMC,kBAAkB,GAAGX,eAAe,CACzCU,KAAK,CAACE,IADmC,EAEzC,iBAFyC,EAGzC,IAHyC,CAA1C;;AAKA,QAAKD,kBAAkB,IAAID,KAAK,CAACG,UAAjC,EAA8C;AAC7C,aACC,8BACC,cAAC,SAAD,EAAgBH,KAAhB,CADD,EAEC,cAAC,iBAAD;AAAmB,QAAA,KAAK,EAAC;AAAzB,SACC,cAAC,WAAD;AACC,QAAA,uBAAuB,MADxB;AAE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OJ,MAAP;AACA,GAT8D,CAW/D;AACA;;;AACA,MACGG,OAAO,CAACC,MAAR,KAAmB,CAAnB,IAAwBH,MAAM,CAACG,MAAP,GAAgB,CAA1C,IACED,OAAO,CAACC,MAAR,GAAiB,CAAjB,IAAsBH,MAAM,CAACG,MAAP,KAAkB,CAF3C,EAGE;AACD,WAAOJ,MAAP;AACA,GAlB8D,CAoB/D;AACA;AACA;AACA;;;AACA,MAAKC,MAAM,CAAEC,KAAF,CAAX,EAAuB;AAAA;;AACtB,UAAMI,eAAe,oBAAGL,MAAM,CAAEC,KAAF,CAAT,kDAAG,cAAiBlB,UAAjB,CAA4BC,SAApD;;AACA,QAAKqB,eAAL,EAAuB;AACtB,aAAO,EACN,GAAGN,MADG;AAENhB,QAAAA,UAAU,EAAE,EACX,GAAGgB,MAAM,CAAChB,UADC;AAEXC,UAAAA,SAAS,EAAEqB;AAFA;AAFN,OAAP;AAOA;AACD;;AACD,SAAON,MAAP;AACA;AAEDxB,SAAS,CACR,0BADQ,EAER,kCAFQ,EAGRM,YAHQ,CAAT;AAKAN,SAAS,CACR,kBADQ,EAER,sDAFQ,EAGRW,oBAHQ,CAAT;AAKAX,SAAS,CACR,kCADQ,EAER,mCAFQ,EAGRoB,YAHQ,CAAT;AAMApB,SAAS,CACR,2CADQ,EAER,0BAFQ,EAGRuB,aAHQ,CAAT","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { TextControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { hasBlockSupport } from '@wordpress/blocks';\nimport { createHigherOrderComponent } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { InspectorControls } from '../components';\n\n/**\n * Filters registered block settings, extending attributes to include `className`.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nexport function addAttribute( settings ) {\n\tif ( hasBlockSupport( settings, 'customClassName', true ) ) {\n\t\t// Gracefully handle if settings.attributes is undefined.\n\t\tsettings.attributes = {\n\t\t\t...settings.attributes,\n\t\t\tclassName: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t};\n\t}\n\n\treturn settings;\n}\n\n/**\n * Override the default edit UI to include a new block inspector control for\n * assigning the custom class name, if block supports custom class name.\n * The control is displayed within the Advanced panel in the block inspector.\n *\n * @param {WPComponent} BlockEdit Original component.\n *\n * @return {WPComponent} Wrapped component.\n */\nexport const withInspectorControl = createHigherOrderComponent(\n\t( BlockEdit ) => {\n\t\treturn ( props ) => {\n\t\t\tconst hasCustomClassName = hasBlockSupport(\n\t\t\t\tprops.name,\n\t\t\t\t'customClassName',\n\t\t\t\ttrue\n\t\t\t);\n\t\t\tif ( hasCustomClassName && props.isSelected ) {\n\t\t\t\treturn (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<BlockEdit { ...props } />\n\t\t\t\t\t\t<InspectorControls group=\"advanced\">\n\t\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\t\t\t\tlabel={ __( 'Additional CSS class(es)' ) }\n\t\t\t\t\t\t\t\tvalue={ props.attributes.className || '' }\n\t\t\t\t\t\t\t\tonChange={ ( nextValue ) => {\n\t\t\t\t\t\t\t\t\tprops.setAttributes( {\n\t\t\t\t\t\t\t\t\t\tclassName:\n\t\t\t\t\t\t\t\t\t\t\tnextValue !== ''\n\t\t\t\t\t\t\t\t\t\t\t\t? nextValue\n\t\t\t\t\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t\t\t'Separate multiple classes with spaces.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</InspectorControls>\n\t\t\t\t\t</>\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn <BlockEdit { ...props } />;\n\t\t};\n\t},\n\t'withInspectorControl'\n);\n\n/**\n * Override props assigned to save component to inject the className, if block\n * supports customClassName. This is only applied if the block's save result is an\n * element and not a markup string.\n *\n * @param {Object} extraProps Additional props applied to save element.\n * @param {Object} blockType Block type.\n * @param {Object} attributes Current block attributes.\n *\n * @return {Object} Filtered props applied to save element.\n */\nexport function addSaveProps( extraProps, blockType, attributes ) {\n\tif (\n\t\thasBlockSupport( blockType, 'customClassName', true ) &&\n\t\tattributes.className\n\t) {\n\t\textraProps.className = classnames(\n\t\t\textraProps.className,\n\t\t\tattributes.className\n\t\t);\n\t}\n\n\treturn extraProps;\n}\n\nexport function addTransforms( result, source, index, results ) {\n\tif ( ! hasBlockSupport( result.name, 'customClassName', true ) ) {\n\t\treturn result;\n\t}\n\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 class should not be kept.\n\tif ( results.length === 1 && result.innerBlocks.length === source.length ) {\n\t\treturn result;\n\t}\n\n\t// If we are transforming one block to multiple blocks or multiple blocks to one block,\n\t// we ignore the class during the transform.\n\tif (\n\t\t( results.length === 1 && source.length > 1 ) ||\n\t\t( results.length > 1 && source.length === 1 )\n\t) {\n\t\treturn result;\n\t}\n\n\t// If we are in presence of transform between one or more block in the source\n\t// that have one or more blocks in the result\n\t// we apply the class on source N to the result N,\n\t// if source N does not exists we do nothing.\n\tif ( source[ index ] ) {\n\t\tconst originClassName = source[ index ]?.attributes.className;\n\t\tif ( originClassName ) {\n\t\t\treturn {\n\t\t\t\t...result,\n\t\t\t\tattributes: {\n\t\t\t\t\t...result.attributes,\n\t\t\t\t\tclassName: originClassName,\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\t}\n\treturn result;\n}\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/custom-class-name/attribute',\n\taddAttribute\n);\naddFilter(\n\t'editor.BlockEdit',\n\t'core/editor/custom-class-name/with-inspector-control',\n\twithInspectorControl\n);\naddFilter(\n\t'blocks.getSaveContent.extraProps',\n\t'core/custom-class-name/save-props',\n\taddSaveProps\n);\n\naddFilter(\n\t'blocks.switchToBlockType.transformedBlock',\n\t'core/color/addTransforms',\n\taddTransforms\n);\n"]}