@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,302 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.BorderColorEdit = BorderColorEdit;
9
- exports.hasBorderColorValue = hasBorderColorValue;
10
- exports.resetBorderColor = resetBorderColor;
11
- exports.withBorderColorPaletteStyles = void 0;
12
-
13
- var _element = require("@wordpress/element");
14
-
15
- var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
16
-
17
- var _classnames = _interopRequireDefault(require("classnames"));
18
-
19
- var _hooks = require("@wordpress/hooks");
20
-
21
- var _i18n = require("@wordpress/i18n");
22
-
23
- var _compose = require("@wordpress/compose");
24
-
25
- var _dropdown = _interopRequireDefault(require("../components/colors-gradients/dropdown"));
26
-
27
- var _useMultipleOriginColorsAndGradients = _interopRequireDefault(require("../components/colors-gradients/use-multiple-origin-colors-and-gradients"));
28
-
29
- var _colors = require("../components/colors");
30
-
31
- var _useSetting = _interopRequireDefault(require("../components/use-setting"));
32
-
33
- var _border = require("./border");
34
-
35
- var _utils = require("./utils");
36
-
37
- /**
38
- * External dependencies
39
- */
40
-
41
- /**
42
- * WordPress dependencies
43
- */
44
-
45
- /**
46
- * Internal dependencies
47
- */
48
- // Defining empty array here instead of inline avoids unnecessary re-renders of
49
- // color control.
50
- const EMPTY_ARRAY = [];
51
- /**
52
- * Inspector control panel containing the border color related configuration.
53
- *
54
- * There is deliberate overlap between the colors and borders block supports
55
- * relating to border color. It can be argued the border color controls could
56
- * be included within either, or both, the colors and borders panels in the
57
- * inspector controls. If they share the same block attributes it should not
58
- * matter.
59
- *
60
- * @param {Object} props Block properties.
61
- *
62
- * @return {WPElement} Border color edit element.
63
- */
64
-
65
- function BorderColorEdit(props) {
66
- const {
67
- attributes: {
68
- borderColor,
69
- style
70
- },
71
- setAttributes
72
- } = props;
73
- const colorGradientSettings = (0, _useMultipleOriginColorsAndGradients.default)();
74
- const availableColors = colorGradientSettings.colors.reduce((colors, origin) => colors.concat(origin.colors), []);
75
- const {
76
- color: customBorderColor
77
- } = (style === null || style === void 0 ? void 0 : style.border) || {};
78
- const [colorValue, setColorValue] = (0, _element.useState)(() => {
79
- var _getColorObjectByAttr;
80
-
81
- return (_getColorObjectByAttr = (0, _colors.getColorObjectByAttributeValues)(availableColors, borderColor, customBorderColor)) === null || _getColorObjectByAttr === void 0 ? void 0 : _getColorObjectByAttr.color;
82
- }); // Detect changes in the color attributes and update the colorValue to keep the
83
- // UI in sync. This is necessary for situations when border controls interact with
84
- // each other: eg, setting the border width to zero causes the color and style
85
- // selections to be cleared.
86
-
87
- (0, _element.useEffect)(() => {
88
- var _getColorObjectByAttr2;
89
-
90
- setColorValue((_getColorObjectByAttr2 = (0, _colors.getColorObjectByAttributeValues)(availableColors, borderColor, customBorderColor)) === null || _getColorObjectByAttr2 === void 0 ? void 0 : _getColorObjectByAttr2.color);
91
- }, [borderColor, customBorderColor, availableColors]);
92
-
93
- const onChangeColor = value => {
94
- setColorValue(value);
95
- const colorObject = (0, _colors.getColorObjectByColorValue)(availableColors, value);
96
- const newStyle = { ...style,
97
- border: { ...(style === null || style === void 0 ? void 0 : style.border),
98
- color: colorObject !== null && colorObject !== void 0 && colorObject.slug ? undefined : value
99
- }
100
- }; // If empty slug, ensure undefined to remove attribute.
101
-
102
- const newNamedColor = colorObject !== null && colorObject !== void 0 && colorObject.slug ? colorObject.slug : undefined;
103
- setAttributes({
104
- style: (0, _utils.cleanEmptyObject)(newStyle),
105
- borderColor: newNamedColor
106
- });
107
- };
108
-
109
- const settings = [{
110
- label: (0, _i18n.__)('Color'),
111
- onColorChange: onChangeColor,
112
- colorValue,
113
- clearable: false
114
- }];
115
- return (0, _element.createElement)(_dropdown.default, (0, _extends2.default)({
116
- settings: settings,
117
- disableCustomColors: true,
118
- disableCustomGradients: true,
119
- __experimentalHasMultipleOrigins: true,
120
- __experimentalIsRenderedInSidebar: true,
121
- enableAlpha: true
122
- }, colorGradientSettings));
123
- }
124
- /**
125
- * Checks if there is a current value in the border color block support
126
- * attributes.
127
- *
128
- * @param {Object} props Block props.
129
- * @return {boolean} Whether or not the block has a border color value set.
130
- */
131
-
132
-
133
- function hasBorderColorValue(props) {
134
- var _style$border;
135
-
136
- const {
137
- attributes: {
138
- borderColor,
139
- style
140
- }
141
- } = props;
142
- return !!borderColor || !!(style !== null && style !== void 0 && (_style$border = style.border) !== null && _style$border !== void 0 && _style$border.color);
143
- }
144
- /**
145
- * Resets the border color block support attributes. This can be used when
146
- * disabling the border color support controls for a block via a progressive
147
- * discovery panel.
148
- *
149
- * @param {Object} props Block props.
150
- * @param {Object} props.attributes Block's attributes.
151
- * @param {Object} props.setAttributes Function to set block's attributes.
152
- */
153
-
154
-
155
- function resetBorderColor(_ref) {
156
- let {
157
- attributes = {},
158
- setAttributes
159
- } = _ref;
160
- const {
161
- style
162
- } = attributes;
163
- setAttributes({
164
- borderColor: undefined,
165
- style: (0, _border.removeBorderAttribute)(style, 'color')
166
- });
167
- }
168
- /**
169
- * Filters registered block settings, extending attributes to include
170
- * `borderColor` if needed.
171
- *
172
- * @param {Object} settings Original block settings.
173
- *
174
- * @return {Object} Updated block settings.
175
- */
176
-
177
-
178
- function addAttributes(settings) {
179
- if (!(0, _border.hasBorderSupport)(settings, 'color')) {
180
- return settings;
181
- } // Allow blocks to specify default value if needed.
182
-
183
-
184
- if (settings.attributes.borderColor) {
185
- return settings;
186
- } // Add new borderColor attribute to block settings.
187
-
188
-
189
- return { ...settings,
190
- attributes: { ...settings.attributes,
191
- borderColor: {
192
- type: 'string'
193
- }
194
- }
195
- };
196
- }
197
- /**
198
- * Override props assigned to save component to inject border color.
199
- *
200
- * @param {Object} props Additional props applied to save element.
201
- * @param {Object} blockType Block type definition.
202
- * @param {Object} attributes Block's attributes.
203
- *
204
- * @return {Object} Filtered props to apply to save element.
205
- */
206
-
207
-
208
- function addSaveProps(props, blockType, attributes) {
209
- var _style$border2;
210
-
211
- if (!(0, _border.hasBorderSupport)(blockType, 'color') || (0, _utils.shouldSkipSerialization)(blockType, _border.BORDER_SUPPORT_KEY, 'color')) {
212
- return props;
213
- }
214
-
215
- const {
216
- borderColor,
217
- style
218
- } = attributes;
219
- const borderColorClass = (0, _colors.getColorClassName)('border-color', borderColor);
220
- const newClassName = (0, _classnames.default)(props.className, {
221
- '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),
222
- [borderColorClass]: !!borderColorClass
223
- }); // If we are clearing the last of the previous classes in `className`
224
- // set it to `undefined` to avoid rendering empty DOM attributes.
225
-
226
- props.className = newClassName ? newClassName : undefined;
227
- return props;
228
- }
229
- /**
230
- * Filters the registered block settings to apply border color styles and
231
- * classnames to the block edit wrapper.
232
- *
233
- * @param {Object} settings Original block settings.
234
- *
235
- * @return {Object} Filtered block settings.
236
- */
237
-
238
-
239
- function addEditProps(settings) {
240
- if (!(0, _border.hasBorderSupport)(settings, 'color') || (0, _utils.shouldSkipSerialization)(settings, _border.BORDER_SUPPORT_KEY, 'color')) {
241
- return settings;
242
- }
243
-
244
- const existingGetEditWrapperProps = settings.getEditWrapperProps;
245
-
246
- settings.getEditWrapperProps = attributes => {
247
- let props = {};
248
-
249
- if (existingGetEditWrapperProps) {
250
- props = existingGetEditWrapperProps(attributes);
251
- }
252
-
253
- return addSaveProps(props, settings, attributes);
254
- };
255
-
256
- return settings;
257
- }
258
- /**
259
- * This adds inline styles for color palette colors.
260
- * Ideally, this is not needed and themes should load their palettes on the editor.
261
- *
262
- * @param {Function} BlockListBlock Original component.
263
- *
264
- * @return {Function} Wrapped component.
265
- */
266
-
267
-
268
- const withBorderColorPaletteStyles = (0, _compose.createHigherOrderComponent)(BlockListBlock => props => {
269
- var _getColorObjectByAttr3, _props$wrapperProps;
270
-
271
- const {
272
- name,
273
- attributes
274
- } = props;
275
- const {
276
- borderColor
277
- } = attributes;
278
- const colors = (0, _useSetting.default)('color.palette') || EMPTY_ARRAY;
279
-
280
- if (!(0, _border.hasBorderSupport)(name, 'color') || (0, _utils.shouldSkipSerialization)(name, _border.BORDER_SUPPORT_KEY, 'color')) {
281
- return (0, _element.createElement)(BlockListBlock, props);
282
- }
283
-
284
- const extraStyles = {
285
- borderColor: borderColor ? (_getColorObjectByAttr3 = (0, _colors.getColorObjectByAttributeValues)(colors, borderColor)) === null || _getColorObjectByAttr3 === void 0 ? void 0 : _getColorObjectByAttr3.color : undefined
286
- };
287
- let wrapperProps = props.wrapperProps;
288
- wrapperProps = { ...props.wrapperProps,
289
- style: { ...extraStyles,
290
- ...((_props$wrapperProps = props.wrapperProps) === null || _props$wrapperProps === void 0 ? void 0 : _props$wrapperProps.style)
291
- }
292
- };
293
- return (0, _element.createElement)(BlockListBlock, (0, _extends2.default)({}, props, {
294
- wrapperProps: wrapperProps
295
- }));
296
- });
297
- exports.withBorderColorPaletteStyles = withBorderColorPaletteStyles;
298
- (0, _hooks.addFilter)('blocks.registerBlockType', 'core/border/addAttributes', addAttributes);
299
- (0, _hooks.addFilter)('blocks.getSaveContent.extraProps', 'core/border/addSaveProps', addSaveProps);
300
- (0, _hooks.addFilter)('blocks.registerBlockType', 'core/border/addEditProps', addEditProps);
301
- (0, _hooks.addFilter)('editor.BlockListBlock', 'core/border/with-border-color-palette-styles', withBorderColorPaletteStyles);
302
- //# sourceMappingURL=border-color.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/hooks/border-color.js"],"names":["EMPTY_ARRAY","BorderColorEdit","props","attributes","borderColor","style","setAttributes","colorGradientSettings","availableColors","colors","reduce","origin","concat","color","customBorderColor","border","colorValue","setColorValue","onChangeColor","value","colorObject","newStyle","slug","undefined","newNamedColor","settings","label","onColorChange","clearable","hasBorderColorValue","resetBorderColor","addAttributes","type","addSaveProps","blockType","BORDER_SUPPORT_KEY","borderColorClass","newClassName","className","addEditProps","existingGetEditWrapperProps","getEditWrapperProps","withBorderColorPaletteStyles","BlockListBlock","name","extraStyles","wrapperProps"],"mappings":";;;;;;;;;;;;AAWA;;;;AARA;;AAKA;;AACA;;AACA;;AAMA;;AACA;;AACA;;AAKA;;AACA;;AAKA;;AA7BA;AACA;AACA;;AAGA;AACA;AACA;;AAMA;AACA;AACA;AAgBA;AACA;AACA,MAAMA,WAAW,GAAG,EAApB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACO,SAASC,eAAT,CAA0BC,KAA1B,EAAkC;AACxC,QAAM;AACLC,IAAAA,UAAU,EAAE;AAAEC,MAAAA,WAAF;AAAeC,MAAAA;AAAf,KADP;AAELC,IAAAA;AAFK,MAGFJ,KAHJ;AAIA,QAAMK,qBAAqB,GAAG,mDAA9B;AACA,QAAMC,eAAe,GAAGD,qBAAqB,CAACE,MAAtB,CAA6BC,MAA7B,CACvB,CAAED,MAAF,EAAUE,MAAV,KAAsBF,MAAM,CAACG,MAAP,CAAeD,MAAM,CAACF,MAAtB,CADC,EAEvB,EAFuB,CAAxB;AAIA,QAAM;AAAEI,IAAAA,KAAK,EAAEC;AAAT,MAA+B,CAAAT,KAAK,SAAL,IAAAA,KAAK,WAAL,YAAAA,KAAK,CAAEU,MAAP,KAAiB,EAAtD;AACA,QAAM,CAAEC,UAAF,EAAcC,aAAd,IAAgC,uBACrC;AAAA;;AAAA,oCACC,6CACCT,eADD,EAECJ,WAFD,EAGCU,iBAHD,CADD,0DACC,sBAIGD,KALJ;AAAA,GADqC,CAAtC,CAXwC,CAoBxC;AACA;AACA;AACA;;AACA,0BAAW,MAAM;AAAA;;AAChBI,IAAAA,aAAa,2BACZ,6CACCT,eADD,EAECJ,WAFD,EAGCU,iBAHD,CADY,2DACZ,uBAIGD,KALS,CAAb;AAOA,GARD,EAQG,CAAET,WAAF,EAAeU,iBAAf,EAAkCN,eAAlC,CARH;;AAUA,QAAMU,aAAa,GAAKC,KAAF,IAAa;AAClCF,IAAAA,aAAa,CAAEE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MAAM,GAAG,yBAAY,eAAZ,KAAiCT,WAAhD;;AAEA,MACC,CAAE,8BAAkB4C,IAAlB,EAAwB,OAAxB,CAAF,IACA,oCAAyBA,IAAzB,EAA+BT,0BAA/B,EAAmD,OAAnD,CAFD,EAGE;AACD,WAAO,4BAAC,cAAD,EAAqBjC,KAArB,CAAP;AACA;;AAED,QAAM2C,WAAW,GAAG;AACnBzC,IAAAA,WAAW,EAAEA,WAAW,6BACrB,6CAAiCK,MAAjC,EAAyCL,WAAzC,CADqB,2DACrB,uBAAwDS,KADnC,GAErBU;AAHgB,GAApB;AAMA,MAAIuB,YAAY,GAAG5C,KAAK,CAAC4C,YAAzB;AACAA,EAAAA,YAAY,GAAG,EACd,GAAG5C,KAAK,CAAC4C,YADK;AAEdzC,IAAAA,KAAK,EAAE,EACN,GAAGwC,WADG;AAEN,iCAAG3C,KAAK,CAAC4C,YAAT,wDAAG,oBAAoBzC,KAAvB;AAFM;AAFO,GAAf;AAQA,SAAO,4BAAC,cAAD,6BAAqBH,KAArB;AAA6B,IAAA,YAAY,EAAG4C;AAA5C,KAAP;AACA,CA7B0C,CAArC;;AAgCP,sBACC,0BADD,EAEC,2BAFD,EAGCf,aAHD;AAMA,sBACC,kCADD,EAEC,0BAFD,EAGCE,YAHD;AAMA,sBACC,0BADD,EAEC,0BAFD,EAGCM,YAHD;AAMA,sBACC,uBADD,EAEC,8CAFD,EAGCG,4BAHD","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { __ } from '@wordpress/i18n';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { useEffect, useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport ColorGradientSettingsDropdown from '../components/colors-gradients/dropdown';\nimport useMultipleOriginColorsAndGradients from '../components/colors-gradients/use-multiple-origin-colors-and-gradients';\nimport {\n\tgetColorClassName,\n\tgetColorObjectByColorValue,\n\tgetColorObjectByAttributeValues,\n} from '../components/colors';\nimport useSetting from '../components/use-setting';\nimport {\n\tBORDER_SUPPORT_KEY,\n\thasBorderSupport,\n\tremoveBorderAttribute,\n} from './border';\nimport { cleanEmptyObject, shouldSkipSerialization } from './utils';\n\n// Defining empty array here instead of inline avoids unnecessary re-renders of\n// color control.\nconst EMPTY_ARRAY = [];\n\n/**\n * Inspector control panel containing the border color related configuration.\n *\n * There is deliberate overlap between the colors and borders block supports\n * relating to border color. It can be argued the border color controls could\n * be included within either, or both, the colors and borders panels in the\n * inspector controls. If they share the same block attributes it should not\n * matter.\n *\n * @param {Object} props Block properties.\n *\n * @return {WPElement} Border color edit element.\n */\nexport function BorderColorEdit( props ) {\n\tconst {\n\t\tattributes: { borderColor, style },\n\t\tsetAttributes,\n\t} = props;\n\tconst colorGradientSettings = useMultipleOriginColorsAndGradients();\n\tconst availableColors = colorGradientSettings.colors.reduce(\n\t\t( colors, origin ) => colors.concat( origin.colors ),\n\t\t[]\n\t);\n\tconst { color: customBorderColor } = style?.border || {};\n\tconst [ colorValue, setColorValue ] = useState(\n\t\t() =>\n\t\t\tgetColorObjectByAttributeValues(\n\t\t\t\tavailableColors,\n\t\t\t\tborderColor,\n\t\t\t\tcustomBorderColor\n\t\t\t)?.color\n\t);\n\n\t// Detect changes in the color attributes and update the colorValue to keep the\n\t// UI in sync. This is necessary for situations when border controls interact with\n\t// each other: eg, setting the border width to zero causes the color and style\n\t// selections to be cleared.\n\tuseEffect( () => {\n\t\tsetColorValue(\n\t\t\tgetColorObjectByAttributeValues(\n\t\t\t\tavailableColors,\n\t\t\t\tborderColor,\n\t\t\t\tcustomBorderColor\n\t\t\t)?.color\n\t\t);\n\t}, [ borderColor, customBorderColor, availableColors ] );\n\n\tconst onChangeColor = ( value ) => {\n\t\tsetColorValue( value );\n\n\t\tconst colorObject = getColorObjectByColorValue(\n\t\t\tavailableColors,\n\t\t\tvalue\n\t\t);\n\t\tconst newStyle = {\n\t\t\t...style,\n\t\t\tborder: {\n\t\t\t\t...style?.border,\n\t\t\t\tcolor: colorObject?.slug ? undefined : value,\n\t\t\t},\n\t\t};\n\n\t\t// If empty slug, ensure undefined to remove attribute.\n\t\tconst newNamedColor = colorObject?.slug ? colorObject.slug : undefined;\n\n\t\tsetAttributes( {\n\t\t\tstyle: cleanEmptyObject( newStyle ),\n\t\t\tborderColor: newNamedColor,\n\t\t} );\n\t};\n\n\tconst settings = [\n\t\t{\n\t\t\tlabel: __( 'Color' ),\n\t\t\tonColorChange: onChangeColor,\n\t\t\tcolorValue,\n\t\t\tclearable: false,\n\t\t},\n\t];\n\treturn (\n\t\t<ColorGradientSettingsDropdown\n\t\t\tsettings={ settings }\n\t\t\tdisableCustomColors\n\t\t\tdisableCustomGradients\n\t\t\t__experimentalHasMultipleOrigins\n\t\t\t__experimentalIsRenderedInSidebar\n\t\t\tenableAlpha\n\t\t\t{ ...colorGradientSettings }\n\t\t/>\n\t);\n}\n\n/**\n * Checks if there is a current value in the border color block support\n * attributes.\n *\n * @param {Object} props Block props.\n * @return {boolean} Whether or not the block has a border color value set.\n */\nexport function hasBorderColorValue( props ) {\n\tconst {\n\t\tattributes: { borderColor, style },\n\t} = props;\n\n\treturn !! borderColor || !! style?.border?.color;\n}\n\n/**\n * Resets the border color block support attributes. This can be used when\n * disabling the border color support controls for a block via a progressive\n * discovery panel.\n *\n * @param {Object} props Block props.\n * @param {Object} props.attributes Block's attributes.\n * @param {Object} props.setAttributes Function to set block's attributes.\n */\nexport function resetBorderColor( { attributes = {}, setAttributes } ) {\n\tconst { style } = attributes;\n\n\tsetAttributes( {\n\t\tborderColor: undefined,\n\t\tstyle: removeBorderAttribute( style, 'color' ),\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 { borderColor, style } = attributes;\n\tconst borderColorClass = getColorClassName( 'border-color', borderColor );\n\n\tconst newClassName = classnames( props.className, {\n\t\t'has-border-color': borderColor || style?.border?.color,\n\t\t[ borderColorClass ]: !! borderColorClass,\n\t} );\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 * 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 } = attributes;\n\t\tconst colors = useSetting( 'color.palette' ) || EMPTY_ARRAY;\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 extraStyles = {\n\t\t\tborderColor: borderColor\n\t\t\t\t? getColorObjectByAttributeValues( colors, borderColor )?.color\n\t\t\t\t: undefined,\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...extraStyles,\n\t\t\t\t...props.wrapperProps?.style,\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,96 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.BorderStyleEdit = void 0;
9
- exports.hasBorderStyleValue = hasBorderStyleValue;
10
- exports.resetBorderStyle = resetBorderStyle;
11
-
12
- var _element = require("@wordpress/element");
13
-
14
- var _borderStyleControl = _interopRequireDefault(require("../components/border-style-control"));
15
-
16
- var _utils = require("./utils");
17
-
18
- var _border = require("./border");
19
-
20
- /**
21
- * Internal dependencies
22
- */
23
-
24
- /**
25
- * Inspector control for configuring border style property.
26
- *
27
- * @param {Object} props Block properties.
28
- *
29
- * @return {WPElement} Border style edit element.
30
- */
31
- const BorderStyleEdit = props => {
32
- var _style$border;
33
-
34
- const {
35
- attributes: {
36
- style
37
- },
38
- setAttributes
39
- } = props;
40
-
41
- const onChange = newBorderStyle => {
42
- const newStyleAttributes = { ...style,
43
- border: { ...(style === null || style === void 0 ? void 0 : style.border),
44
- style: newBorderStyle
45
- }
46
- };
47
- setAttributes({
48
- style: (0, _utils.cleanEmptyObject)(newStyleAttributes)
49
- });
50
- };
51
-
52
- return (0, _element.createElement)(_borderStyleControl.default, {
53
- value: style === null || style === void 0 ? void 0 : (_style$border = style.border) === null || _style$border === void 0 ? void 0 : _style$border.style,
54
- onChange: onChange
55
- });
56
- };
57
- /**
58
- * Checks if there is a current value in the border style block support
59
- * attributes.
60
- *
61
- * @param {Object} props Block props.
62
- * @return {boolean} Whether or not the block has a border style value set.
63
- */
64
-
65
-
66
- exports.BorderStyleEdit = BorderStyleEdit;
67
-
68
- function hasBorderStyleValue(props) {
69
- var _props$attributes$sty, _props$attributes$sty2;
70
-
71
- return !!((_props$attributes$sty = props.attributes.style) !== null && _props$attributes$sty !== void 0 && (_props$attributes$sty2 = _props$attributes$sty.border) !== null && _props$attributes$sty2 !== void 0 && _props$attributes$sty2.style);
72
- }
73
- /**
74
- * Resets the border style block support attribute. This can be used when
75
- * disabling the border style support control for a block via a progressive
76
- * discovery panel.
77
- *
78
- * @param {Object} props Block props.
79
- * @param {Object} props.attributes Block's attributes.
80
- * @param {Object} props.setAttributes Function to set block's attributes.
81
- */
82
-
83
-
84
- function resetBorderStyle(_ref) {
85
- let {
86
- attributes = {},
87
- setAttributes
88
- } = _ref;
89
- const {
90
- style
91
- } = attributes;
92
- setAttributes({
93
- style: (0, _border.removeBorderAttribute)(style, 'style')
94
- });
95
- }
96
- //# sourceMappingURL=border-style.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/hooks/border-style.js"],"names":["BorderStyleEdit","props","attributes","style","setAttributes","onChange","newBorderStyle","newStyleAttributes","border","hasBorderStyleValue","resetBorderStyle"],"mappings":";;;;;;;;;;;;;AAGA;;AACA;;AACA;;AALA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,eAAe,GAAKC,KAAF,IAAa;AAAA;;AAC3C,QAAM;AACLC,IAAAA,UAAU,EAAE;AAAEC,MAAAA;AAAF,KADP;AAELC,IAAAA;AAFK,MAGFH,KAHJ;;AAKA,QAAMI,QAAQ,GAAKC,cAAF,IAAsB;AACtC,UAAMC,kBAAkB,GAAG,EAC1B,GAAGJ,KADuB;AAE1BK,MAAAA,MAAM,EAAE,EACP,IAAGL,KAAH,aAAGA,KAAH,uBAAGA,KAAK,CAAEK,MAAV,CADO;AAEPL,QAAAA,KAAK,EAAEG;AAFA;AAFkB,KAA3B;AAQAF,IAAAA,aAAa,CAAE;AAAED,MAAAA,KAAK,EAAE,6BAAkBI,kBAAlB;AAAT,KAAF,CAAb;AACA,GAVD;;AAYA,SACC,4BAAC,2BAAD;AACC,IAAA,KAAK,EAAGJ,KAAH,aAAGA,KAAH,wCAAGA,KAAK,CAAEK,MAAV,kDAAG,cAAeL,KADxB;AAEC,IAAA,QAAQ,EAAGE;AAFZ,IADD;AAMA,CAxBM;AA0BP;AACA;AACA;AACA;AACA;AACA;AACA;;;;;AACO,SAASI,mBAAT,CAA8BR,KAA9B,EAAsC;AAAA;;AAC5C,SAAO,CAAC,2BAAEA,KAAK,CAACC,UAAN,CAAiBC,KAAnB,4EAAE,sBAAwBK,MAA1B,mDAAE,uBAAgCL,KAAlC,CAAR;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASO,gBAAT,OAAgE;AAAA,MAArC;AAAER,IAAAA,UAAU,GAAG,EAAf;AAAmBE,IAAAA;AAAnB,GAAqC;AACtE,QAAM;AAAED,IAAAA;AAAF,MAAYD,UAAlB;AACAE,EAAAA,aAAa,CAAE;AAAED,IAAAA,KAAK,EAAE,mCAAuBA,KAAvB,EAA8B,OAA9B;AAAT,GAAF,CAAb;AACA","sourcesContent":["/**\n * Internal dependencies\n */\nimport BorderStyleControl from '../components/border-style-control';\nimport { cleanEmptyObject } from './utils';\nimport { removeBorderAttribute } from './border';\n\n/**\n * Inspector control for configuring border style property.\n *\n * @param {Object} props Block properties.\n *\n * @return {WPElement} Border style edit element.\n */\nexport const BorderStyleEdit = ( props ) => {\n\tconst {\n\t\tattributes: { style },\n\t\tsetAttributes,\n\t} = props;\n\n\tconst onChange = ( newBorderStyle ) => {\n\t\tconst newStyleAttributes = {\n\t\t\t...style,\n\t\t\tborder: {\n\t\t\t\t...style?.border,\n\t\t\t\tstyle: newBorderStyle,\n\t\t\t},\n\t\t};\n\n\t\tsetAttributes( { style: cleanEmptyObject( newStyleAttributes ) } );\n\t};\n\n\treturn (\n\t\t<BorderStyleControl\n\t\t\tvalue={ style?.border?.style }\n\t\t\tonChange={ onChange }\n\t\t/>\n\t);\n};\n\n/**\n * Checks if there is a current value in the border style block support\n * attributes.\n *\n * @param {Object} props Block props.\n * @return {boolean} Whether or not the block has a border style value set.\n */\nexport function hasBorderStyleValue( props ) {\n\treturn !! props.attributes.style?.border?.style;\n}\n\n/**\n * Resets the border style block support attribute. This can be used when\n * disabling the border style support control for a block via a progressive\n * discovery panel.\n *\n * @param {Object} props Block props.\n * @param {Object} props.attributes Block's attributes.\n * @param {Object} props.setAttributes Function to set block's attributes.\n */\nexport function resetBorderStyle( { attributes = {}, setAttributes } ) {\n\tconst { style } = attributes;\n\tsetAttributes( { style: removeBorderAttribute( style, 'style' ) } );\n}\n"]}
@@ -1,162 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.BorderWidthEdit = void 0;
9
- exports.hasBorderWidthValue = hasBorderWidthValue;
10
- exports.resetBorderWidth = resetBorderWidth;
11
-
12
- var _element = require("@wordpress/element");
13
-
14
- var _components = require("@wordpress/components");
15
-
16
- var _i18n = require("@wordpress/i18n");
17
-
18
- var _utils = require("./utils");
19
-
20
- var _border = require("./border");
21
-
22
- var _useSetting = _interopRequireDefault(require("../components/use-setting"));
23
-
24
- /**
25
- * WordPress dependencies
26
- */
27
-
28
- /**
29
- * Internal dependencies
30
- */
31
- const MIN_BORDER_WIDTH = 0;
32
- /**
33
- * Inspector control for configuring border width property.
34
- *
35
- * @param {Object} props Block properties.
36
- *
37
- * @return {WPElement} Border width edit element.
38
- */
39
-
40
- const BorderWidthEdit = props => {
41
- const {
42
- attributes: {
43
- borderColor,
44
- style
45
- },
46
- setAttributes
47
- } = props;
48
- const {
49
- width,
50
- color: customBorderColor,
51
- style: borderStyle
52
- } = (style === null || style === void 0 ? void 0 : style.border) || {}; // Used to temporarily track previous border color & style selections to be
53
- // able to restore them when border width changes from zero value.
54
-
55
- const [styleSelection, setStyleSelection] = (0, _element.useState)();
56
- const [colorSelection, setColorSelection] = (0, _element.useState)();
57
- const [customColorSelection, setCustomColorSelection] = (0, _element.useState)();
58
-
59
- const onChange = newWidth => {
60
- let newStyle = { ...style,
61
- border: { ...(style === null || style === void 0 ? void 0 : style.border),
62
- width: newWidth
63
- }
64
- }; // Used to clear named border color attribute.
65
-
66
- let borderPaletteColor = borderColor;
67
- const hasZeroWidth = parseFloat(newWidth) === 0;
68
- const hadPreviousZeroWidth = parseFloat(width) === 0; // Setting the border width explicitly to zero will also set the
69
- // border style to `none` and clear border color attributes.
70
-
71
- if (hasZeroWidth && !hadPreviousZeroWidth) {
72
- // Before clearing color and style selections, keep track of
73
- // the current selections so they can be restored when the width
74
- // changes to a non-zero value.
75
- setColorSelection(borderColor);
76
- setCustomColorSelection(customBorderColor);
77
- setStyleSelection(borderStyle); // Clear style and color attributes.
78
-
79
- borderPaletteColor = undefined;
80
- newStyle.border.color = undefined;
81
- newStyle.border.style = 'none';
82
- }
83
-
84
- if (!hasZeroWidth && hadPreviousZeroWidth) {
85
- // Restore previous border style selection if width is now not zero and
86
- // border style was 'none'. This is to support changes to the UI which
87
- // change the border style UI to a segmented control without a "none"
88
- // option.
89
- if (borderStyle === 'none') {
90
- newStyle.border.style = styleSelection;
91
- } // Restore previous border color selection if width is no longer zero
92
- // and current border color is undefined.
93
-
94
-
95
- if (borderColor === undefined) {
96
- borderPaletteColor = colorSelection;
97
- newStyle.border.color = customColorSelection;
98
- }
99
- } // If width was reset, clean out undefined styles.
100
-
101
-
102
- if (newWidth === undefined || newWidth === '') {
103
- newStyle = (0, _utils.cleanEmptyObject)(newStyle);
104
- }
105
-
106
- setAttributes({
107
- borderColor: borderPaletteColor,
108
- style: newStyle
109
- });
110
- };
111
-
112
- const units = (0, _components.__experimentalUseCustomUnits)({
113
- availableUnits: (0, _useSetting.default)('spacing.units') || ['px', 'em', 'rem']
114
- });
115
- return (0, _element.createElement)(_components.__experimentalUnitControl, {
116
- value: width,
117
- label: (0, _i18n.__)('Width'),
118
- min: MIN_BORDER_WIDTH,
119
- onChange: onChange,
120
- units: units
121
- });
122
- };
123
- /**
124
- * Checks if there is a current value in the border width block support
125
- * attributes.
126
- *
127
- * @param {Object} props Block props.
128
- * @return {boolean} Whether or not the block has a border width value set.
129
- */
130
-
131
-
132
- exports.BorderWidthEdit = BorderWidthEdit;
133
-
134
- function hasBorderWidthValue(props) {
135
- var _props$attributes$sty, _props$attributes$sty2;
136
-
137
- return !!((_props$attributes$sty = props.attributes.style) !== null && _props$attributes$sty !== void 0 && (_props$attributes$sty2 = _props$attributes$sty.border) !== null && _props$attributes$sty2 !== void 0 && _props$attributes$sty2.width);
138
- }
139
- /**
140
- * Resets the border width block support attribute. This can be used when
141
- * disabling the border width support control for a block via a progressive
142
- * discovery panel.
143
- *
144
- * @param {Object} props Block props.
145
- * @param {Object} props.attributes Block's attributes.
146
- * @param {Object} props.setAttributes Function to set block's attributes.
147
- */
148
-
149
-
150
- function resetBorderWidth(_ref) {
151
- let {
152
- attributes = {},
153
- setAttributes
154
- } = _ref;
155
- const {
156
- style
157
- } = attributes;
158
- setAttributes({
159
- style: (0, _border.removeBorderAttribute)(style, 'width')
160
- });
161
- }
162
- //# sourceMappingURL=border-width.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/hooks/border-width.js"],"names":["MIN_BORDER_WIDTH","BorderWidthEdit","props","attributes","borderColor","style","setAttributes","width","color","customBorderColor","borderStyle","border","styleSelection","setStyleSelection","colorSelection","setColorSelection","customColorSelection","setCustomColorSelection","onChange","newWidth","newStyle","borderPaletteColor","hasZeroWidth","parseFloat","hadPreviousZeroWidth","undefined","units","availableUnits","hasBorderWidthValue","resetBorderWidth"],"mappings":";;;;;;;;;;;AAOA;;AAJA;;AAKA;;AAKA;;AACA;;AACA;;AAfA;AACA;AACA;;AAQA;AACA;AACA;AAKA,MAAMA,gBAAgB,GAAG,CAAzB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACO,MAAMC,eAAe,GAAKC,KAAF,IAAa;AAC3C,QAAM;AACLC,IAAAA,UAAU,EAAE;AAAEC,MAAAA,WAAF;AAAeC,MAAAA;AAAf,KADP;AAELC,IAAAA;AAFK,MAGFJ,KAHJ;AAKA,QAAM;AAAEK,IAAAA,KAAF;AAASC,IAAAA,KAAK,EAAEC,iBAAhB;AAAmCJ,IAAAA,KAAK,EAAEK;AAA1C,MACL,CAAAL,KAAK,SAAL,IAAAA,KAAK,WAAL,YAAAA,KAAK,CAAEM,MAAP,KAAiB,EADlB,CAN2C,CAS3C;AACA;;AACA,QAAM,CAAEC,cAAF,EAAkBC,iBAAlB,IAAwC,wBAA9C;AACA,QAAM,CAAEC,cAAF,EAAkBC,iBAAlB,IAAwC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CAgDhC;;;AACA,QAAKG,QAAQ,KAAKM,SAAb,IAA0BN,QAAQ,KAAK,EAA5C,EAAiD;AAChDC,MAAAA,QAAQ,GAAG,6BAAkBA,QAAlB,CAAX;AACA;;AAEDd,IAAAA,aAAa,CAAE;AACdF,MAAAA,WAAW,EAAEiB,kBADC;AAEdhB,MAAAA,KAAK,EAAEe;AAFO,KAAF,CAAb;AAIA,GAzDD;;AA2DA,QAAMM,KAAK,GAAG,8CAAgB;AAC7BC,IAAAA,cAAc,EAAE,yBAAY,eAAZ,KAAiC,CAAE,IAAF,EAAQ,IAAR,EAAc,KAAd;AADpB,GAAhB,CAAd;AAIA,SACC,4BAAC,qCAAD;AACC,IAAA,KAAK,EAAGpB,KADT;AAEC,IAAA,KAAK,EAAG,cAAI,OAAJ,CAFT;AAGC,IAAA,GAAG,EAAGP,gBAHP;AAIC,IAAA,QAAQ,EAAGkB,QAJZ;AAKC,IAAA,KAAK,EAAGQ;AALT,IADD;AASA,CAvFM;AAyFP;AACA;AACA;AACA;AACA;AACA;AACA;;;;;AACO,SAASE,mBAAT,CAA8B1B,KAA9B,EAAsC;AAAA;;AAC5C,SAAO,CAAC,2BAAEA,KAAK,CAACC,UAAN,CAAiBE,KAAnB,4EAAE,sBAAwBM,MAA1B,mDAAE,uBAAgCJ,KAAlC,CAAR;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASsB,gBAAT,OAAgE;AAAA,MAArC;AAAE1B,IAAAA,UAAU,GAAG,EAAf;AAAmBG,IAAAA;AAAnB,GAAqC;AACtE,QAAM;AAAED,IAAAA;AAAF,MAAYF,UAAlB;AACAG,EAAAA,aAAa,CAAE;AAAED,IAAAA,KAAK,EAAE,mCAAuBA,KAAvB,EAA8B,OAA9B;AAAT,GAAF,CAAb;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalUnitControl as UnitControl,\n\t__experimentalUseCustomUnits as useCustomUnits,\n} from '@wordpress/components';\nimport { useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { cleanEmptyObject } from './utils';\nimport { removeBorderAttribute } from './border';\nimport useSetting from '../components/use-setting';\n\nconst MIN_BORDER_WIDTH = 0;\n\n/**\n * Inspector control for configuring border width property.\n *\n * @param {Object} props Block properties.\n *\n * @return {WPElement} Border width edit element.\n */\nexport const BorderWidthEdit = ( props ) => {\n\tconst {\n\t\tattributes: { borderColor, style },\n\t\tsetAttributes,\n\t} = props;\n\n\tconst { width, color: customBorderColor, style: borderStyle } =\n\t\tstyle?.border || {};\n\n\t// Used to temporarily track previous border color & style selections to be\n\t// able to restore them when border width changes from zero value.\n\tconst [ styleSelection, setStyleSelection ] = useState();\n\tconst [ colorSelection, setColorSelection ] = useState();\n\tconst [ customColorSelection, setCustomColorSelection ] = useState();\n\n\tconst onChange = ( newWidth ) => {\n\t\tlet newStyle = {\n\t\t\t...style,\n\t\t\tborder: {\n\t\t\t\t...style?.border,\n\t\t\t\twidth: newWidth,\n\t\t\t},\n\t\t};\n\n\t\t// Used to clear named border color attribute.\n\t\tlet borderPaletteColor = borderColor;\n\n\t\tconst hasZeroWidth = parseFloat( newWidth ) === 0;\n\t\tconst hadPreviousZeroWidth = parseFloat( width ) === 0;\n\n\t\t// Setting the border width explicitly to zero will also set the\n\t\t// border style to `none` and clear border color attributes.\n\t\tif ( hasZeroWidth && ! hadPreviousZeroWidth ) {\n\t\t\t// Before clearing color and style selections, keep track of\n\t\t\t// the current selections so they can be restored when the width\n\t\t\t// changes to a non-zero value.\n\t\t\tsetColorSelection( borderColor );\n\t\t\tsetCustomColorSelection( customBorderColor );\n\t\t\tsetStyleSelection( borderStyle );\n\n\t\t\t// Clear style and color attributes.\n\t\t\tborderPaletteColor = undefined;\n\t\t\tnewStyle.border.color = undefined;\n\t\t\tnewStyle.border.style = 'none';\n\t\t}\n\n\t\tif ( ! hasZeroWidth && hadPreviousZeroWidth ) {\n\t\t\t// Restore previous border style selection if width is now not zero and\n\t\t\t// border style was 'none'. This is to support changes to the UI which\n\t\t\t// change the border style UI to a segmented control without a \"none\"\n\t\t\t// option.\n\t\t\tif ( borderStyle === 'none' ) {\n\t\t\t\tnewStyle.border.style = styleSelection;\n\t\t\t}\n\n\t\t\t// Restore previous border color selection if width is no longer zero\n\t\t\t// and current border color is undefined.\n\t\t\tif ( borderColor === undefined ) {\n\t\t\t\tborderPaletteColor = colorSelection;\n\t\t\t\tnewStyle.border.color = customColorSelection;\n\t\t\t}\n\t\t}\n\n\t\t// If width was reset, clean out undefined styles.\n\t\tif ( newWidth === undefined || newWidth === '' ) {\n\t\t\tnewStyle = cleanEmptyObject( newStyle );\n\t\t}\n\n\t\tsetAttributes( {\n\t\t\tborderColor: borderPaletteColor,\n\t\t\tstyle: newStyle,\n\t\t} );\n\t};\n\n\tconst units = useCustomUnits( {\n\t\tavailableUnits: useSetting( 'spacing.units' ) || [ 'px', 'em', 'rem' ],\n\t} );\n\n\treturn (\n\t\t<UnitControl\n\t\t\tvalue={ width }\n\t\t\tlabel={ __( 'Width' ) }\n\t\t\tmin={ MIN_BORDER_WIDTH }\n\t\t\tonChange={ onChange }\n\t\t\tunits={ units }\n\t\t/>\n\t);\n};\n\n/**\n * Checks if there is a current value in the border width block support\n * attributes.\n *\n * @param {Object} props Block props.\n * @return {boolean} Whether or not the block has a border width value set.\n */\nexport function hasBorderWidthValue( props ) {\n\treturn !! props.attributes.style?.border?.width;\n}\n\n/**\n * Resets the border width block support attribute. This can be used when\n * disabling the border width support control for a block via a progressive\n * discovery panel.\n *\n * @param {Object} props Block props.\n * @param {Object} props.attributes Block's attributes.\n * @param {Object} props.setAttributes Function to set block's attributes.\n */\nexport function resetBorderWidth( { attributes = {}, setAttributes } ) {\n\tconst { style } = attributes;\n\tsetAttributes( { style: removeBorderAttribute( style, 'width' ) } );\n}\n"]}
@@ -1,31 +0,0 @@
1
- import { createElement } from "@wordpress/element";
2
-
3
- /**
4
- * WordPress dependencies
5
- */
6
- import { useViewportMatch } from '@wordpress/compose';
7
- /**
8
- * Internal dependencies
9
- */
10
-
11
- import BlockMover from '../block-mover';
12
-
13
- function BlockMobileToolbar(_ref) {
14
- let {
15
- clientId
16
- } = _ref;
17
- const isMobile = useViewportMatch('small', '<');
18
-
19
- if (!isMobile) {
20
- return null;
21
- }
22
-
23
- return createElement("div", {
24
- className: "block-editor-block-mobile-toolbar"
25
- }, createElement(BlockMover, {
26
- clientIds: [clientId]
27
- }));
28
- }
29
-
30
- export default BlockMobileToolbar;
31
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/block-mobile-toolbar/index.js"],"names":["useViewportMatch","BlockMover","BlockMobileToolbar","clientId","isMobile"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,gBAAT,QAAiC,oBAAjC;AAEA;AACA;AACA;;AACA,OAAOC,UAAP,MAAuB,gBAAvB;;AAEA,SAASC,kBAAT,OAA4C;AAAA,MAAf;AAAEC,IAAAA;AAAF,GAAe;AAC3C,QAAMC,QAAQ,GAAGJ,gBAAgB,CAAE,OAAF,EAAW,GAAX,CAAjC;;AACA,MAAK,CAAEI,QAAP,EAAkB;AACjB,WAAO,IAAP;AACA;;AAED,SACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,cAAC,UAAD;AAAY,IAAA,SAAS,EAAG,CAAED,QAAF;AAAxB,IADD,CADD;AAKA;;AAED,eAAeD,kBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useViewportMatch } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport BlockMover from '../block-mover';\n\nfunction BlockMobileToolbar( { clientId } ) {\n\tconst isMobile = useViewportMatch( 'small', '<' );\n\tif ( ! isMobile ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<div className=\"block-editor-block-mobile-toolbar\">\n\t\t\t<BlockMover clientIds={ [ clientId ] } />\n\t\t</div>\n\t);\n}\n\nexport default BlockMobileToolbar;\n"]}