@wordpress/block-editor 8.5.0 → 8.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 (274) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/block-alignment-control/ui.js +1 -1
  3. package/build/components/block-alignment-control/ui.js.map +1 -1
  4. package/build/components/block-content-overlay/index.js +13 -4
  5. package/build/components/block-content-overlay/index.js.map +1 -1
  6. package/build/components/block-list/block.native.js +3 -1
  7. package/build/components/block-list/block.native.js.map +1 -1
  8. package/build/components/block-lock/index.js +8 -0
  9. package/build/components/block-lock/index.js.map +1 -1
  10. package/build/components/block-lock/menu-item.js +5 -20
  11. package/build/components/block-lock/menu-item.js.map +1 -1
  12. package/build/components/block-lock/modal.js +33 -12
  13. package/build/components/block-lock/modal.js.map +1 -1
  14. package/build/components/block-lock/toolbar.js +7 -20
  15. package/build/components/block-lock/toolbar.js.map +1 -1
  16. package/build/components/block-lock/use-block-lock.js +50 -0
  17. package/build/components/block-lock/use-block-lock.js.map +1 -0
  18. package/build/components/block-mover/button.js +4 -4
  19. package/build/components/block-mover/button.js.map +1 -1
  20. package/build/components/block-mover/index.js +39 -65
  21. package/build/components/block-mover/index.js.map +1 -1
  22. package/build/components/block-pattern-setup/index.js +37 -22
  23. package/build/components/block-pattern-setup/index.js.map +1 -1
  24. package/build/components/block-pattern-setup/setup-toolbar.js +1 -1
  25. package/build/components/block-pattern-setup/setup-toolbar.js.map +1 -1
  26. package/build/components/block-popover/inbetween.js +183 -0
  27. package/build/components/block-popover/inbetween.js.map +1 -0
  28. package/build/components/block-popover/index.js +82 -0
  29. package/build/components/block-popover/index.js.map +1 -0
  30. package/build/components/{block-tools → block-popover}/use-popover-scroll.js +4 -1
  31. package/build/components/block-popover/use-popover-scroll.js.map +1 -0
  32. package/build/components/block-preview/auto.js +6 -3
  33. package/build/components/block-preview/auto.js.map +1 -1
  34. package/build/components/block-preview/index.js +4 -2
  35. package/build/components/block-preview/index.js.map +1 -1
  36. package/build/components/block-styles/index.js +1 -10
  37. package/build/components/block-styles/index.js.map +1 -1
  38. package/build/components/block-switcher/index.js +7 -2
  39. package/build/components/block-switcher/index.js.map +1 -1
  40. package/build/components/block-tools/back-compat.js +2 -2
  41. package/build/components/block-tools/back-compat.js.map +1 -1
  42. package/build/components/block-tools/block-selection-button.js +4 -2
  43. package/build/components/block-tools/block-selection-button.js.map +1 -1
  44. package/build/components/block-tools/index.js +5 -5
  45. package/build/components/block-tools/index.js.map +1 -1
  46. package/build/components/block-tools/insertion-point.js +14 -121
  47. package/build/components/block-tools/insertion-point.js.map +1 -1
  48. package/build/components/block-tools/{block-popover.js → selected-block-popover.js} +25 -108
  49. package/build/components/block-tools/selected-block-popover.js.map +1 -0
  50. package/build/components/copy-handler/index.js +44 -9
  51. package/build/components/copy-handler/index.js.map +1 -1
  52. package/build/components/duotone-control/index.js +5 -1
  53. package/build/components/duotone-control/index.js.map +1 -1
  54. package/build/components/inserter/index.native.js +30 -8
  55. package/build/components/inserter/index.native.js.map +1 -1
  56. package/build/components/link-control/index.js +6 -7
  57. package/build/components/link-control/index.js.map +1 -1
  58. package/build/components/list-view/block-select-button.js +4 -10
  59. package/build/components/list-view/block-select-button.js.map +1 -1
  60. package/build/components/list-view/block.js +13 -2
  61. package/build/components/list-view/block.js.map +1 -1
  62. package/build/components/rich-text/index.js +0 -5
  63. package/build/components/rich-text/index.js.map +1 -1
  64. package/build/components/rich-text/index.native.js +0 -4
  65. package/build/components/rich-text/index.native.js.map +1 -1
  66. package/build/components/use-block-display-information/index.js +3 -1
  67. package/build/components/use-block-display-information/index.js.map +1 -1
  68. package/build/hooks/border.js +468 -44
  69. package/build/hooks/border.js.map +1 -1
  70. package/build/hooks/duotone.js +66 -16
  71. package/build/hooks/duotone.js.map +1 -1
  72. package/build/hooks/index.js +8 -2
  73. package/build/hooks/index.js.map +1 -1
  74. package/build/hooks/use-border-props.js +22 -32
  75. package/build/hooks/use-border-props.js.map +1 -1
  76. package/build/index.js +7 -0
  77. package/build/index.js.map +1 -1
  78. package/build/store/actions.js +36 -31
  79. package/build/store/actions.js.map +1 -1
  80. package/build/store/reducer.js +0 -26
  81. package/build/store/reducer.js.map +1 -1
  82. package/build/store/selectors.js +131 -6
  83. package/build/store/selectors.js.map +1 -1
  84. package/build/store/utils.js +27 -0
  85. package/build/store/utils.js.map +1 -0
  86. package/build-module/components/block-alignment-control/ui.js +2 -2
  87. package/build-module/components/block-alignment-control/ui.js.map +1 -1
  88. package/build-module/components/block-content-overlay/index.js +13 -4
  89. package/build-module/components/block-content-overlay/index.js.map +1 -1
  90. package/build-module/components/block-list/block.native.js +3 -1
  91. package/build-module/components/block-list/block.native.js.map +1 -1
  92. package/build-module/components/block-lock/index.js +1 -0
  93. package/build-module/components/block-lock/index.js.map +1 -1
  94. package/build-module/components/block-lock/menu-item.js +4 -18
  95. package/build-module/components/block-lock/menu-item.js.map +1 -1
  96. package/build-module/components/block-lock/modal.js +31 -12
  97. package/build-module/components/block-lock/modal.js.map +1 -1
  98. package/build-module/components/block-lock/toolbar.js +6 -18
  99. package/build-module/components/block-lock/toolbar.js.map +1 -1
  100. package/build-module/components/block-lock/use-block-lock.js +41 -0
  101. package/build-module/components/block-lock/use-block-lock.js.map +1 -0
  102. package/build-module/components/block-mover/button.js +5 -5
  103. package/build-module/components/block-mover/button.js.map +1 -1
  104. package/build-module/components/block-mover/index.js +38 -63
  105. package/build-module/components/block-mover/index.js.map +1 -1
  106. package/build-module/components/block-pattern-setup/index.js +39 -24
  107. package/build-module/components/block-pattern-setup/index.js.map +1 -1
  108. package/build-module/components/block-pattern-setup/setup-toolbar.js +1 -1
  109. package/build-module/components/block-pattern-setup/setup-toolbar.js.map +1 -1
  110. package/build-module/components/block-popover/inbetween.js +165 -0
  111. package/build-module/components/block-popover/inbetween.js.map +1 -0
  112. package/build-module/components/block-popover/index.js +67 -0
  113. package/build-module/components/block-popover/index.js.map +1 -0
  114. package/build-module/components/{block-tools → block-popover}/use-popover-scroll.js +3 -1
  115. package/build-module/components/block-popover/use-popover-scroll.js.map +1 -0
  116. package/build-module/components/block-preview/auto.js +6 -3
  117. package/build-module/components/block-preview/auto.js.map +1 -1
  118. package/build-module/components/block-preview/index.js +4 -2
  119. package/build-module/components/block-preview/index.js.map +1 -1
  120. package/build-module/components/block-styles/index.js +1 -9
  121. package/build-module/components/block-styles/index.js.map +1 -1
  122. package/build-module/components/block-switcher/index.js +7 -2
  123. package/build-module/components/block-switcher/index.js.map +1 -1
  124. package/build-module/components/block-tools/back-compat.js +1 -1
  125. package/build-module/components/block-tools/back-compat.js.map +1 -1
  126. package/build-module/components/block-tools/block-selection-button.js +3 -2
  127. package/build-module/components/block-tools/block-selection-button.js.map +1 -1
  128. package/build-module/components/block-tools/index.js +3 -3
  129. package/build-module/components/block-tools/index.js.map +1 -1
  130. package/build-module/components/block-tools/insertion-point.js +16 -121
  131. package/build-module/components/block-tools/insertion-point.js.map +1 -1
  132. package/build-module/components/block-tools/{block-popover.js → selected-block-popover.js} +25 -105
  133. package/build-module/components/block-tools/selected-block-popover.js.map +1 -0
  134. package/build-module/components/copy-handler/index.js +44 -9
  135. package/build-module/components/copy-handler/index.js.map +1 -1
  136. package/build-module/components/duotone-control/index.js +4 -1
  137. package/build-module/components/duotone-control/index.js.map +1 -1
  138. package/build-module/components/inserter/index.native.js +31 -10
  139. package/build-module/components/inserter/index.native.js.map +1 -1
  140. package/build-module/components/link-control/index.js +6 -7
  141. package/build-module/components/link-control/index.js.map +1 -1
  142. package/build-module/components/list-view/block-select-button.js +4 -9
  143. package/build-module/components/list-view/block-select-button.js.map +1 -1
  144. package/build-module/components/list-view/block.js +13 -2
  145. package/build-module/components/list-view/block.js.map +1 -1
  146. package/build-module/components/rich-text/index.js +0 -4
  147. package/build-module/components/rich-text/index.js.map +1 -1
  148. package/build-module/components/rich-text/index.native.js +0 -4
  149. package/build-module/components/rich-text/index.native.js.map +1 -1
  150. package/build-module/components/use-block-display-information/index.js +3 -1
  151. package/build-module/components/use-block-display-information/index.js.map +1 -1
  152. package/build-module/hooks/border.js +458 -44
  153. package/build-module/hooks/border.js.map +1 -1
  154. package/build-module/hooks/duotone.js +63 -16
  155. package/build-module/hooks/duotone.js.map +1 -1
  156. package/build-module/hooks/index.js +2 -1
  157. package/build-module/hooks/index.js.map +1 -1
  158. package/build-module/hooks/use-border-props.js +21 -30
  159. package/build-module/hooks/use-border-props.js.map +1 -1
  160. package/build-module/index.js +1 -1
  161. package/build-module/index.js.map +1 -1
  162. package/build-module/store/actions.js +19 -16
  163. package/build-module/store/actions.js.map +1 -1
  164. package/build-module/store/reducer.js +0 -24
  165. package/build-module/store/reducer.js.map +1 -1
  166. package/build-module/store/selectors.js +120 -5
  167. package/build-module/store/selectors.js.map +1 -1
  168. package/build-module/store/utils.js +20 -0
  169. package/build-module/store/utils.js.map +1 -0
  170. package/build-style/style-rtl.css +145 -272
  171. package/build-style/style.css +145 -272
  172. package/package.json +28 -28
  173. package/src/components/block-alignment-control/ui.js +2 -2
  174. package/src/components/block-content-overlay/index.js +19 -2
  175. package/src/components/block-list/block.native.js +2 -0
  176. package/src/components/block-lock/index.js +1 -0
  177. package/src/components/block-lock/menu-item.js +3 -23
  178. package/src/components/block-lock/modal.js +37 -13
  179. package/src/components/block-lock/style.scss +1 -2
  180. package/src/components/block-lock/toolbar.js +4 -21
  181. package/src/components/block-lock/use-block-lock.js +45 -0
  182. package/src/components/block-mover/button.js +5 -7
  183. package/src/components/block-mover/index.js +37 -60
  184. package/src/components/block-mover/stories/index.js +110 -0
  185. package/src/components/block-mover/style.scss +48 -138
  186. package/src/components/block-pattern-setup/index.js +84 -59
  187. package/src/components/block-pattern-setup/setup-toolbar.js +3 -1
  188. package/src/components/block-pattern-setup/style.scss +32 -26
  189. package/src/components/block-popover/README.md +41 -0
  190. package/src/components/block-popover/inbetween.js +180 -0
  191. package/src/components/block-popover/index.js +73 -0
  192. package/src/components/block-popover/style.scss +24 -0
  193. package/src/components/{block-tools → block-popover}/use-popover-scroll.js +3 -1
  194. package/src/components/block-preview/auto.js +10 -1
  195. package/src/components/block-preview/index.js +2 -0
  196. package/src/components/block-styles/index.js +1 -12
  197. package/src/components/block-switcher/index.js +13 -1
  198. package/src/components/block-switcher/style.scss +4 -4
  199. package/src/components/block-switcher/test/__snapshots__/index.js.snap +15 -13
  200. package/src/components/block-toolbar/style.scss +0 -12
  201. package/src/components/block-tools/back-compat.js +1 -1
  202. package/src/components/block-tools/block-selection-button.js +3 -1
  203. package/src/components/block-tools/index.js +6 -4
  204. package/src/components/block-tools/insertion-point.js +19 -152
  205. package/src/components/block-tools/{block-popover.js → selected-block-popover.js} +24 -116
  206. package/src/components/block-tools/style.scss +11 -123
  207. package/src/components/border-radius-control/style.scss +5 -2
  208. package/src/components/copy-handler/index.js +52 -10
  209. package/src/components/default-block-appender/style.scss +1 -2
  210. package/src/components/duotone-control/index.js +8 -1
  211. package/src/components/gradients/README.md +29 -0
  212. package/src/components/inserter/index.native.js +60 -25
  213. package/src/components/inserter/style.native.scss +24 -3
  214. package/src/components/link-control/index.js +5 -5
  215. package/src/components/list-view/block-select-button.js +2 -10
  216. package/src/components/list-view/block.js +16 -7
  217. package/src/components/navigable-toolbar/README.md +16 -0
  218. package/src/components/rich-text/index.js +0 -2
  219. package/src/components/rich-text/index.native.js +0 -4
  220. package/src/components/use-block-display-information/index.js +2 -0
  221. package/src/hooks/border.js +438 -72
  222. package/src/hooks/border.scss +48 -0
  223. package/src/hooks/duotone.js +98 -62
  224. package/src/hooks/index.js +2 -1
  225. package/src/hooks/use-border-props.js +15 -32
  226. package/src/index.js +1 -0
  227. package/src/store/actions.js +19 -15
  228. package/src/store/reducer.js +0 -21
  229. package/src/store/selectors.js +160 -5
  230. package/src/store/test/actions.js +0 -18
  231. package/src/store/test/reducer.js +0 -19
  232. package/src/store/test/selectors.js +0 -19
  233. package/src/store/utils.js +19 -0
  234. package/src/style.scss +1 -1
  235. package/build/components/block-mobile-toolbar/index.js +0 -42
  236. package/build/components/block-mobile-toolbar/index.js.map +0 -1
  237. package/build/components/block-tools/block-popover.js.map +0 -1
  238. package/build/components/block-tools/use-popover-scroll.js.map +0 -1
  239. package/build/components/list-view/appender.js +0 -93
  240. package/build/components/list-view/appender.js.map +0 -1
  241. package/build/components/list-view/list-item.js +0 -62
  242. package/build/components/list-view/list-item.js.map +0 -1
  243. package/build/components/rich-text/use-caret-in-format.js +0 -43
  244. package/build/components/rich-text/use-caret-in-format.js.map +0 -1
  245. package/build/hooks/border-color.js +0 -302
  246. package/build/hooks/border-color.js.map +0 -1
  247. package/build/hooks/border-style.js +0 -96
  248. package/build/hooks/border-style.js.map +0 -1
  249. package/build/hooks/border-width.js +0 -162
  250. package/build/hooks/border-width.js.map +0 -1
  251. package/build-module/components/block-mobile-toolbar/index.js +0 -31
  252. package/build-module/components/block-mobile-toolbar/index.js.map +0 -1
  253. package/build-module/components/block-tools/block-popover.js.map +0 -1
  254. package/build-module/components/block-tools/use-popover-scroll.js.map +0 -1
  255. package/build-module/components/list-view/appender.js +0 -76
  256. package/build-module/components/list-view/appender.js.map +0 -1
  257. package/build-module/components/list-view/list-item.js +0 -47
  258. package/build-module/components/list-view/list-item.js.map +0 -1
  259. package/build-module/components/rich-text/use-caret-in-format.js +0 -33
  260. package/build-module/components/rich-text/use-caret-in-format.js.map +0 -1
  261. package/build-module/hooks/border-color.js +0 -276
  262. package/build-module/hooks/border-color.js.map +0 -1
  263. package/build-module/hooks/border-style.js +0 -78
  264. package/build-module/hooks/border-style.js.map +0 -1
  265. package/build-module/hooks/border-width.js +0 -143
  266. package/build-module/hooks/border-width.js.map +0 -1
  267. package/src/components/block-mobile-toolbar/index.js +0 -24
  268. package/src/components/block-mobile-toolbar/style.scss +0 -29
  269. package/src/components/list-view/appender.js +0 -82
  270. package/src/components/list-view/list-item.js +0 -59
  271. package/src/components/rich-text/use-caret-in-format.js +0 -28
  272. package/src/hooks/border-color.js +0 -315
  273. package/src/hooks/border-style.js +0 -64
  274. package/src/hooks/border-width.js +0 -139
@@ -1,89 +1,322 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
1
2
  import { createElement } from "@wordpress/element";
2
3
 
4
+ /**
5
+ * External dependencies
6
+ */
7
+ import classnames from 'classnames';
3
8
  /**
4
9
  * WordPress dependencies
5
10
  */
11
+
6
12
  import { getBlockSupport } from '@wordpress/blocks';
7
- import { __experimentalToolsPanelItem as ToolsPanelItem } from '@wordpress/components';
13
+ import { __experimentalBorderBoxControl as BorderBoxControl, __experimentalHasSplitBorders as hasSplitBorders, __experimentalIsDefinedBorder as isDefinedBorder, __experimentalToolsPanelItem as ToolsPanelItem } from '@wordpress/components';
14
+ import { createHigherOrderComponent } from '@wordpress/compose';
8
15
  import { Platform } from '@wordpress/element';
16
+ import { addFilter } from '@wordpress/hooks';
9
17
  import { __ } from '@wordpress/i18n';
10
18
  /**
11
19
  * Internal dependencies
12
20
  */
13
21
 
14
- import { BorderColorEdit, hasBorderColorValue, resetBorderColor } from './border-color';
15
22
  import { BorderRadiusEdit, hasBorderRadiusValue, resetBorderRadius } from './border-radius';
16
- import { BorderStyleEdit, hasBorderStyleValue, resetBorderStyle } from './border-style';
17
- import { BorderWidthEdit, hasBorderWidthValue, resetBorderWidth } from './border-width';
23
+ import { getColorClassName } from '../components/colors';
18
24
  import InspectorControls from '../components/inspector-controls';
25
+ import useMultipleOriginColorsAndGradients from '../components/colors-gradients/use-multiple-origin-colors-and-gradients';
19
26
  import useSetting from '../components/use-setting';
20
- import { cleanEmptyObject } from './utils';
27
+ import { cleanEmptyObject, shouldSkipSerialization } from './utils';
21
28
  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
+
74
+ const getColorByProperty = (colors, property, value) => {
75
+ let matchedColor;
76
+ colors.some(origin => origin.colors.some(color => {
77
+ if (color[property] === value) {
78
+ matchedColor = color;
79
+ return true;
80
+ }
81
+
82
+ return false;
83
+ }));
84
+ return matchedColor;
85
+ };
86
+
87
+ export const getMultiOriginColor = _ref2 => {
88
+ let {
89
+ colors,
90
+ namedColor,
91
+ customColor
92
+ } = _ref2;
93
+
94
+ // Search each origin (default, theme, or user) for matching color by name.
95
+ if (namedColor) {
96
+ const colorObject = getColorByProperty(colors, 'slug', namedColor);
97
+
98
+ if (colorObject) {
99
+ return colorObject;
100
+ }
101
+ } // Skip if no custom color or matching named color.
102
+
103
+
104
+ if (!customColor) {
105
+ return {
106
+ color: undefined
107
+ };
108
+ } // Attempt to find color via custom color value or build new object.
109
+
110
+
111
+ const colorObject = getColorByProperty(colors, 'color', customColor);
112
+ return colorObject ? colorObject : {
113
+ color: customColor
114
+ };
115
+ };
116
+
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
+ function getColorSlugFromVariable(value) {
172
+ const namedColor = /var:preset\|color\|(.+)/.exec(value);
173
+
174
+ if (namedColor && namedColor[1]) {
175
+ return namedColor[1];
176
+ }
177
+
178
+ return null;
179
+ }
180
+
22
181
  export function BorderPanel(props) {
23
182
  const {
24
- clientId
183
+ attributes,
184
+ clientId,
185
+ setAttributes
25
186
  } = props;
187
+ const {
188
+ style
189
+ } = attributes;
190
+ const {
191
+ colors
192
+ } = useMultipleOriginColorsAndGradients();
193
+ const isSupported = hasBorderSupport(props.name);
26
194
  const isColorSupported = useSetting('border.color') && hasBorderSupport(props.name, 'color');
27
195
  const isRadiusSupported = useSetting('border.radius') && hasBorderSupport(props.name, 'radius');
28
196
  const isStyleSupported = useSetting('border.style') && hasBorderSupport(props.name, 'style');
29
197
  const isWidthSupported = useSetting('border.width') && hasBorderSupport(props.name, 'width');
30
198
  const isDisabled = [!isColorSupported, !isRadiusSupported, !isStyleSupported, !isWidthSupported].every(Boolean);
31
199
 
32
- if (isDisabled) {
200
+ if (isDisabled || !isSupported) {
33
201
  return null;
34
202
  }
35
203
 
36
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);
37
206
 
38
- const createResetAllFilter = function (borderAttribute) {
39
- let topLevelAttributes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
40
- return newAttributes => {
41
- var _newAttributes$style;
207
+ const onBorderChange = newBorder => {
208
+ var _style$border2;
42
209
 
43
- return { ...newAttributes,
44
- ...topLevelAttributes,
45
- style: { ...newAttributes.style,
46
- border: { ...((_newAttributes$style = newAttributes.style) === null || _newAttributes$style === void 0 ? void 0 : _newAttributes$style.border),
47
- [borderAttribute]: undefined
48
- }
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
49
232
  }
50
233
  };
51
- };
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.
265
+
266
+
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
276
+ });
52
277
  };
53
278
 
279
+ const hydratedBorder = getBorderObject(attributes, colors);
54
280
  return createElement(InspectorControls, {
55
281
  __experimentalGroup: "border"
56
- }, isWidthSupported && createElement(ToolsPanelItem, {
57
- className: "single-column",
58
- hasValue: () => hasBorderWidthValue(props),
59
- label: __('Width'),
60
- onDeselect: () => resetBorderWidth(props),
61
- isShownByDefault: defaultBorderControls === null || defaultBorderControls === void 0 ? void 0 : defaultBorderControls.width,
62
- resetAllFilter: createResetAllFilter('width'),
63
- panelId: clientId
64
- }, createElement(BorderWidthEdit, props)), isStyleSupported && createElement(ToolsPanelItem, {
65
- className: "single-column",
66
- hasValue: () => hasBorderStyleValue(props),
67
- label: __('Style'),
68
- onDeselect: () => resetBorderStyle(props),
69
- isShownByDefault: defaultBorderControls === null || defaultBorderControls === void 0 ? void 0 : defaultBorderControls.style,
70
- resetAllFilter: createResetAllFilter('style'),
71
- panelId: clientId
72
- }, createElement(BorderStyleEdit, props)), isColorSupported && createElement(ToolsPanelItem, {
73
- hasValue: () => hasBorderColorValue(props),
74
- label: __('Color'),
75
- onDeselect: () => resetBorderColor(props),
76
- isShownByDefault: defaultBorderControls === null || defaultBorderControls === void 0 ? void 0 : defaultBorderControls.color,
77
- resetAllFilter: createResetAllFilter('color', {
78
- borderColor: undefined
79
- }),
282
+ }, (isWidthSupported || isColorSupported) && createElement(ToolsPanelItem, {
283
+ hasValue: () => hasBorderValue(props),
284
+ label: __('Border'),
285
+ onDeselect: () => resetBorder(props),
286
+ isShownByDefault: showBorderByDefault,
287
+ resetAllFilter: resetBorderFilter,
80
288
  panelId: clientId
81
- }, createElement(BorderColorEdit, props)), isRadiusSupported && createElement(ToolsPanelItem, {
289
+ }, createElement(BorderBoxControl, {
290
+ colors: colors,
291
+ enableAlpha: true,
292
+ onChange: onBorderChange,
293
+ popoverClassNames: {
294
+ linked: 'block-editor__border-box-control__popover',
295
+ top: 'block-editor__border-box-control__popover-top',
296
+ right: 'block-editor__border-box-control__popover-right',
297
+ bottom: 'block-editor__border-box-control__popover-bottom',
298
+ left: 'block-editor__border-box-control__popover-left'
299
+ },
300
+ showStyle: isStyleSupported,
301
+ value: hydratedBorder,
302
+ __experimentalHasMultipleOrigins: true,
303
+ __experimentalIsRenderedInSidebar: true
304
+ })), isRadiusSupported && createElement(ToolsPanelItem, {
82
305
  hasValue: () => hasBorderRadiusValue(props),
83
306
  label: __('Radius'),
84
307
  onDeselect: () => resetBorderRadius(props),
85
308
  isShownByDefault: defaultBorderControls === null || defaultBorderControls === void 0 ? void 0 : defaultBorderControls.radius,
86
- resetAllFilter: createResetAllFilter('radius'),
309
+ resetAllFilter: newAttributes => {
310
+ var _newAttributes$style2;
311
+
312
+ return { ...newAttributes,
313
+ style: { ...newAttributes.style,
314
+ border: { ...((_newAttributes$style2 = newAttributes.style) === null || _newAttributes$style2 === void 0 ? void 0 : _newAttributes$style2.border),
315
+ radius: undefined
316
+ }
317
+ }
318
+ };
319
+ },
87
320
  panelId: clientId
88
321
  }, createElement(BorderRadiusEdit, props)));
89
322
  }
@@ -132,4 +365,185 @@ export function removeBorderAttribute(style, attribute) {
132
365
  }
133
366
  });
134
367
  }
368
+ /**
369
+ * Filters registered block settings, extending attributes to include
370
+ * `borderColor` if needed.
371
+ *
372
+ * @param {Object} settings Original block settings.
373
+ *
374
+ * @return {Object} Updated block settings.
375
+ */
376
+
377
+ function addAttributes(settings) {
378
+ if (!hasBorderSupport(settings, 'color')) {
379
+ return settings;
380
+ } // Allow blocks to specify default value if needed.
381
+
382
+
383
+ if (settings.attributes.borderColor) {
384
+ return settings;
385
+ } // Add new borderColor attribute to block settings.
386
+
387
+
388
+ return { ...settings,
389
+ attributes: { ...settings.attributes,
390
+ borderColor: {
391
+ type: 'string'
392
+ }
393
+ }
394
+ };
395
+ }
396
+ /**
397
+ * Override props assigned to save component to inject border color.
398
+ *
399
+ * @param {Object} props Additional props applied to save element.
400
+ * @param {Object} blockType Block type definition.
401
+ * @param {Object} attributes Block's attributes.
402
+ *
403
+ * @return {Object} Filtered props to apply to save element.
404
+ */
405
+
406
+
407
+ function addSaveProps(props, blockType, attributes) {
408
+ if (!hasBorderSupport(blockType, 'color') || shouldSkipSerialization(blockType, BORDER_SUPPORT_KEY, 'color')) {
409
+ return props;
410
+ }
411
+
412
+ const borderClasses = getBorderClasses(attributes);
413
+ const newClassName = classnames(props.className, borderClasses); // If we are clearing the last of the previous classes in `className`
414
+ // set it to `undefined` to avoid rendering empty DOM attributes.
415
+
416
+ props.className = newClassName ? newClassName : undefined;
417
+ return props;
418
+ }
419
+ /**
420
+ * Generates a CSS class name consisting of all the applicable border color
421
+ * classes given the current block attributes.
422
+ *
423
+ * @param {Object} attributes Block's attributes.
424
+ *
425
+ * @return {string} CSS class name.
426
+ */
427
+
428
+
429
+ export function getBorderClasses(attributes) {
430
+ var _style$border3;
431
+
432
+ const {
433
+ borderColor,
434
+ style
435
+ } = attributes;
436
+ const borderColorClass = getColorClassName('border-color', borderColor);
437
+ return classnames({
438
+ '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),
439
+ [borderColorClass]: !!borderColorClass
440
+ });
441
+ }
442
+ /**
443
+ * Filters the registered block settings to apply border color styles and
444
+ * classnames to the block edit wrapper.
445
+ *
446
+ * @param {Object} settings Original block settings.
447
+ *
448
+ * @return {Object} Filtered block settings.
449
+ */
450
+
451
+ function addEditProps(settings) {
452
+ if (!hasBorderSupport(settings, 'color') || shouldSkipSerialization(settings, BORDER_SUPPORT_KEY, 'color')) {
453
+ return settings;
454
+ }
455
+
456
+ const existingGetEditWrapperProps = settings.getEditWrapperProps;
457
+
458
+ settings.getEditWrapperProps = attributes => {
459
+ let props = {};
460
+
461
+ if (existingGetEditWrapperProps) {
462
+ props = existingGetEditWrapperProps(attributes);
463
+ }
464
+
465
+ return addSaveProps(props, settings, attributes);
466
+ };
467
+
468
+ return settings;
469
+ }
470
+ /**
471
+ * This adds inline styles for color palette colors.
472
+ * Ideally, this is not needed and themes should load their palettes on the editor.
473
+ *
474
+ * @param {Function} BlockListBlock Original component.
475
+ *
476
+ * @return {Function} Wrapped component.
477
+ */
478
+
479
+
480
+ export const withBorderColorPaletteStyles = createHigherOrderComponent(BlockListBlock => props => {
481
+ var _style$border4, _style$border4$top, _style$border5, _style$border5$right, _style$border6, _style$border6$bottom, _style$border7, _style$border7$left, _props$wrapperProps;
482
+
483
+ const {
484
+ name,
485
+ attributes
486
+ } = props;
487
+ const {
488
+ borderColor,
489
+ style
490
+ } = attributes;
491
+ const {
492
+ colors
493
+ } = useMultipleOriginColorsAndGradients();
494
+
495
+ if (!hasBorderSupport(name, 'color') || shouldSkipSerialization(name, BORDER_SUPPORT_KEY, 'color')) {
496
+ return createElement(BlockListBlock, props);
497
+ }
498
+
499
+ const {
500
+ color: borderColorValue
501
+ } = getMultiOriginColor({
502
+ colors,
503
+ namedColor: borderColor
504
+ });
505
+ const {
506
+ color: borderTopColor
507
+ } = getMultiOriginColor({
508
+ colors,
509
+ 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)
510
+ });
511
+ const {
512
+ color: borderRightColor
513
+ } = getMultiOriginColor({
514
+ colors,
515
+ 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)
516
+ });
517
+ const {
518
+ color: borderBottomColor
519
+ } = getMultiOriginColor({
520
+ colors,
521
+ 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)
522
+ });
523
+ const {
524
+ color: borderLeftColor
525
+ } = getMultiOriginColor({
526
+ colors,
527
+ 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)
528
+ });
529
+ const extraStyles = {
530
+ borderTopColor: borderTopColor || borderColorValue,
531
+ borderRightColor: borderRightColor || borderColorValue,
532
+ borderBottomColor: borderBottomColor || borderColorValue,
533
+ borderLeftColor: borderLeftColor || borderColorValue
534
+ };
535
+ let wrapperProps = props.wrapperProps;
536
+ wrapperProps = { ...props.wrapperProps,
537
+ style: { ...((_props$wrapperProps = props.wrapperProps) === null || _props$wrapperProps === void 0 ? void 0 : _props$wrapperProps.style),
538
+ ...extraStyles
539
+ }
540
+ };
541
+ return createElement(BlockListBlock, _extends({}, props, {
542
+ wrapperProps: wrapperProps
543
+ }));
544
+ });
545
+ addFilter('blocks.registerBlockType', 'core/border/addAttributes', addAttributes);
546
+ addFilter('blocks.getSaveContent.extraProps', 'core/border/addSaveProps', addSaveProps);
547
+ addFilter('blocks.registerBlockType', 'core/border/addEditProps', addEditProps);
548
+ addFilter('editor.BlockListBlock', 'core/border/with-border-color-palette-styles', withBorderColorPaletteStyles);
135
549
  //# sourceMappingURL=border.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/hooks/border.js"],"names":["getBlockSupport","__experimentalToolsPanelItem","ToolsPanelItem","Platform","__","BorderColorEdit","hasBorderColorValue","resetBorderColor","BorderRadiusEdit","hasBorderRadiusValue","resetBorderRadius","BorderStyleEdit","hasBorderStyleValue","resetBorderStyle","BorderWidthEdit","hasBorderWidthValue","resetBorderWidth","InspectorControls","useSetting","cleanEmptyObject","BORDER_SUPPORT_KEY","BorderPanel","props","clientId","isColorSupported","hasBorderSupport","name","isRadiusSupported","isStyleSupported","isWidthSupported","isDisabled","every","Boolean","defaultBorderControls","createResetAllFilter","borderAttribute","topLevelAttributes","newAttributes","style","border","undefined","width","color","borderColor","radius","blockName","feature","OS","support","removeBorderAttribute","attribute"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,eAAT,QAAgC,mBAAhC;AACA,SAASC,4BAA4B,IAAIC,cAAzC,QAA+D,uBAA/D;AACA,SAASC,QAAT,QAAyB,oBAAzB;AACA,SAASC,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AACA,SACCC,eADD,EAECC,mBAFD,EAGCC,gBAHD,QAIO,gBAJP;AAKA,SACCC,gBADD,EAECC,oBAFD,EAGCC,iBAHD,QAI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AAKF,OAAO,KAAK,KAAjB,EAAyB;AACxB,WAAO,CAAC,EACPE,OAAO,SAAP,IAAAA,OAAO,WAAP,IAAAA,OAAO,CAAEN,KAAT,IACAM,OADA,aACAA,OADA,eACAA,OAAO,CAAEJ,MADT,IAEAI,OAFA,aAEAA,OAFA,eAEAA,OAAO,CAAEP,KAFT,IAGAO,OAHA,aAGAA,OAHA,eAGAA,OAAO,CAAEV,KAJF,CAAR;AAMA;;AAED,SAAO,CAAC,EAAEU,OAAF,aAAEA,OAAF,eAAEA,OAAO,CAAIF,OAAJ,CAAT,CAAR;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASG,qBAAT,CAAgCX,KAAhC,EAAuCY,SAAvC,EAAmD;AACzD,SAAO/B,gBAAgB,CAAE,EACxB,GAAGmB,KADqB;AAExBC,IAAAA,MAAM,EAAE,EACP,IAAGD,KAAH,aAAGA,KAAH,uBAAGA,KAAK,CAAEC,MAAV,CADO;AAEP,OAAEW,SAAF,GAAeV;AAFR;AAFgB,GAAF,CAAvB;AAOA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { getBlockSupport } from '@wordpress/blocks';\nimport { __experimentalToolsPanelItem as ToolsPanelItem } from '@wordpress/components';\nimport { Platform } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport {\n\tBorderColorEdit,\n\thasBorderColorValue,\n\tresetBorderColor,\n} from './border-color';\nimport {\n\tBorderRadiusEdit,\n\thasBorderRadiusValue,\n\tresetBorderRadius,\n} from './border-radius';\nimport {\n\tBorderStyleEdit,\n\thasBorderStyleValue,\n\tresetBorderStyle,\n} from './border-style';\nimport {\n\tBorderWidthEdit,\n\thasBorderWidthValue,\n\tresetBorderWidth,\n} from './border-width';\nimport InspectorControls from '../components/inspector-controls';\nimport useSetting from '../components/use-setting';\nimport { cleanEmptyObject } from './utils';\n\nexport const BORDER_SUPPORT_KEY = '__experimentalBorder';\n\nexport function BorderPanel( props ) {\n\tconst { clientId } = props;\n\n\tconst isColorSupported =\n\t\tuseSetting( 'border.color' ) && hasBorderSupport( props.name, 'color' );\n\n\tconst isRadiusSupported =\n\t\tuseSetting( 'border.radius' ) &&\n\t\thasBorderSupport( props.name, 'radius' );\n\n\tconst isStyleSupported =\n\t\tuseSetting( 'border.style' ) && hasBorderSupport( props.name, 'style' );\n\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 ) {\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 createResetAllFilter = (\n\t\tborderAttribute,\n\t\ttopLevelAttributes = {}\n\t) => ( newAttributes ) => ( {\n\t\t...newAttributes,\n\t\t...topLevelAttributes,\n\t\tstyle: {\n\t\t\t...newAttributes.style,\n\t\t\tborder: {\n\t\t\t\t...newAttributes.style?.border,\n\t\t\t\t[ borderAttribute ]: undefined,\n\t\t\t},\n\t\t},\n\t} );\n\n\treturn (\n\t\t<InspectorControls __experimentalGroup=\"border\">\n\t\t\t{ isWidthSupported && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\tclassName=\"single-column\"\n\t\t\t\t\thasValue={ () => hasBorderWidthValue( props ) }\n\t\t\t\t\tlabel={ __( 'Width' ) }\n\t\t\t\t\tonDeselect={ () => resetBorderWidth( props ) }\n\t\t\t\t\tisShownByDefault={ defaultBorderControls?.width }\n\t\t\t\t\tresetAllFilter={ createResetAllFilter( 'width' ) }\n\t\t\t\t\tpanelId={ clientId }\n\t\t\t\t>\n\t\t\t\t\t<BorderWidthEdit { ...props } />\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t\t{ isStyleSupported && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\tclassName=\"single-column\"\n\t\t\t\t\thasValue={ () => hasBorderStyleValue( props ) }\n\t\t\t\t\tlabel={ __( 'Style' ) }\n\t\t\t\t\tonDeselect={ () => resetBorderStyle( props ) }\n\t\t\t\t\tisShownByDefault={ defaultBorderControls?.style }\n\t\t\t\t\tresetAllFilter={ createResetAllFilter( 'style' ) }\n\t\t\t\t\tpanelId={ clientId }\n\t\t\t\t>\n\t\t\t\t\t<BorderStyleEdit { ...props } />\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t\t{ isColorSupported && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ () => hasBorderColorValue( props ) }\n\t\t\t\t\tlabel={ __( 'Color' ) }\n\t\t\t\t\tonDeselect={ () => resetBorderColor( props ) }\n\t\t\t\t\tisShownByDefault={ defaultBorderControls?.color }\n\t\t\t\t\tresetAllFilter={ createResetAllFilter( 'color', {\n\t\t\t\t\t\tborderColor: undefined,\n\t\t\t\t\t} ) }\n\t\t\t\t\tpanelId={ clientId }\n\t\t\t\t>\n\t\t\t\t\t<BorderColorEdit { ...props } />\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={ createResetAllFilter( 'radius' ) }\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"]}
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","linked","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,QAAlB,EAA4B,MAA5B,CAApB;;AAEA,MAAMC,cAAc,GAAKC,KAAF,IAAa;AACnC,QAAM;AAAEC,IAAAA,WAAF;AAAeC,IAAAA;AAAf,MAAyBF,KAAK,CAACG,UAArC;AACA,SAAOtB,eAAe,CAAEqB,KAAF,aAAEA,KAAF,uBAAEA,KAAK,CAA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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,QAAMkE,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,GAAGrF,KAAK,CAACqF,YAAzB;AACAA,EAAAA,YAAY,GAAG,EACd,GAAGrF,KAAK,CAACqF,YADK;AAEdnF,IAAAA,KAAK,EAAE,EACN,2BAAGF,KAAK,CAACqF,YAAT,wDAAG,oBAAoBnF,KAAvB,CADM;AAEN,SAAGkF;AAFG;AAFO,GAAf;AAQA,SAAO,cAAC,cAAD,eAAqBpF,KAArB;AAA6B,IAAA,YAAY,EAAGqF;AAA5C,KAAP;AACA,CAtDoE,CAA/D;AAyDPnG,SAAS,CACR,0BADQ,EAER,2BAFQ,EAGR8E,aAHQ,CAAT;AAMA9E,SAAS,CACR,kCADQ,EAER,0BAFQ,EAGRiF,YAHQ,CAAT;AAMAjF,SAAS,CACR,0BADQ,EAER,0BAFQ,EAGRwF,YAHQ,CAAT;AAMAxF,SAAS,CACR,uBADQ,EAER,8CAFQ,EAGR2F,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 __experimentalGroup=\"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\tonChange={ onBorderChange }\n\t\t\t\t\t\tpopoverClassNames={ {\n\t\t\t\t\t\t\tlinked: 'block-editor__border-box-control__popover',\n\t\t\t\t\t\t\ttop:\n\t\t\t\t\t\t\t\t'block-editor__border-box-control__popover-top',\n\t\t\t\t\t\t\tright:\n\t\t\t\t\t\t\t\t'block-editor__border-box-control__popover-right',\n\t\t\t\t\t\t\tbottom:\n\t\t\t\t\t\t\t\t'block-editor__border-box-control__popover-bottom',\n\t\t\t\t\t\t\tleft:\n\t\t\t\t\t\t\t\t'block-editor__border-box-control__popover-left',\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tshowStyle={ isStyleSupported }\n\t\t\t\t\t\tvalue={ hydratedBorder }\n\t\t\t\t\t\t__experimentalHasMultipleOrigins={ true }\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"]}