@wordpress/block-editor 8.5.2 → 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 (186) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/block-list/block.native.js +3 -1
  3. package/build/components/block-list/block.native.js.map +1 -1
  4. package/build/components/block-mover/button.js +4 -4
  5. package/build/components/block-mover/button.js.map +1 -1
  6. package/build/components/block-mover/index.js +39 -65
  7. package/build/components/block-mover/index.js.map +1 -1
  8. package/build/components/block-popover/inbetween.js +183 -0
  9. package/build/components/block-popover/inbetween.js.map +1 -0
  10. package/build/components/block-popover/index.js +82 -0
  11. package/build/components/block-popover/index.js.map +1 -0
  12. package/build/components/{block-tools → block-popover}/use-popover-scroll.js +4 -1
  13. package/build/components/block-popover/use-popover-scroll.js.map +1 -0
  14. package/build/components/block-styles/index.js +1 -10
  15. package/build/components/block-styles/index.js.map +1 -1
  16. package/build/components/block-tools/back-compat.js +2 -2
  17. package/build/components/block-tools/back-compat.js.map +1 -1
  18. package/build/components/block-tools/block-selection-button.js +4 -2
  19. package/build/components/block-tools/block-selection-button.js.map +1 -1
  20. package/build/components/block-tools/index.js +5 -5
  21. package/build/components/block-tools/index.js.map +1 -1
  22. package/build/components/block-tools/insertion-point.js +14 -121
  23. package/build/components/block-tools/insertion-point.js.map +1 -1
  24. package/build/components/block-tools/{block-popover.js → selected-block-popover.js} +25 -108
  25. package/build/components/block-tools/selected-block-popover.js.map +1 -0
  26. package/build/components/duotone-control/index.js +5 -1
  27. package/build/components/duotone-control/index.js.map +1 -1
  28. package/build/components/inserter/index.native.js +30 -8
  29. package/build/components/inserter/index.native.js.map +1 -1
  30. package/build/components/rich-text/index.js +0 -5
  31. package/build/components/rich-text/index.js.map +1 -1
  32. package/build/components/rich-text/index.native.js +0 -4
  33. package/build/components/rich-text/index.native.js.map +1 -1
  34. package/build/components/use-block-display-information/index.js +3 -1
  35. package/build/components/use-block-display-information/index.js.map +1 -1
  36. package/build/hooks/border.js +468 -44
  37. package/build/hooks/border.js.map +1 -1
  38. package/build/hooks/duotone.js +66 -16
  39. package/build/hooks/duotone.js.map +1 -1
  40. package/build/hooks/index.js +8 -2
  41. package/build/hooks/index.js.map +1 -1
  42. package/build/hooks/use-border-props.js +22 -32
  43. package/build/hooks/use-border-props.js.map +1 -1
  44. package/build/index.js +7 -0
  45. package/build/index.js.map +1 -1
  46. package/build/store/actions.js +14 -2
  47. package/build/store/actions.js.map +1 -1
  48. package/build/store/reducer.js +0 -26
  49. package/build/store/reducer.js.map +1 -1
  50. package/build/store/selectors.js +9 -3
  51. package/build/store/selectors.js.map +1 -1
  52. package/build-module/components/block-list/block.native.js +3 -1
  53. package/build-module/components/block-list/block.native.js.map +1 -1
  54. package/build-module/components/block-mover/button.js +5 -5
  55. package/build-module/components/block-mover/button.js.map +1 -1
  56. package/build-module/components/block-mover/index.js +38 -63
  57. package/build-module/components/block-mover/index.js.map +1 -1
  58. package/build-module/components/block-popover/inbetween.js +165 -0
  59. package/build-module/components/block-popover/inbetween.js.map +1 -0
  60. package/build-module/components/block-popover/index.js +67 -0
  61. package/build-module/components/block-popover/index.js.map +1 -0
  62. package/build-module/components/{block-tools → block-popover}/use-popover-scroll.js +3 -1
  63. package/build-module/components/block-popover/use-popover-scroll.js.map +1 -0
  64. package/build-module/components/block-styles/index.js +1 -9
  65. package/build-module/components/block-styles/index.js.map +1 -1
  66. package/build-module/components/block-tools/back-compat.js +1 -1
  67. package/build-module/components/block-tools/back-compat.js.map +1 -1
  68. package/build-module/components/block-tools/block-selection-button.js +3 -2
  69. package/build-module/components/block-tools/block-selection-button.js.map +1 -1
  70. package/build-module/components/block-tools/index.js +3 -3
  71. package/build-module/components/block-tools/index.js.map +1 -1
  72. package/build-module/components/block-tools/insertion-point.js +16 -121
  73. package/build-module/components/block-tools/insertion-point.js.map +1 -1
  74. package/build-module/components/block-tools/{block-popover.js → selected-block-popover.js} +25 -105
  75. package/build-module/components/block-tools/selected-block-popover.js.map +1 -0
  76. package/build-module/components/duotone-control/index.js +4 -1
  77. package/build-module/components/duotone-control/index.js.map +1 -1
  78. package/build-module/components/inserter/index.native.js +31 -10
  79. package/build-module/components/inserter/index.native.js.map +1 -1
  80. package/build-module/components/rich-text/index.js +0 -4
  81. package/build-module/components/rich-text/index.js.map +1 -1
  82. package/build-module/components/rich-text/index.native.js +0 -4
  83. package/build-module/components/rich-text/index.native.js.map +1 -1
  84. package/build-module/components/use-block-display-information/index.js +3 -1
  85. package/build-module/components/use-block-display-information/index.js.map +1 -1
  86. package/build-module/hooks/border.js +458 -44
  87. package/build-module/hooks/border.js.map +1 -1
  88. package/build-module/hooks/duotone.js +63 -16
  89. package/build-module/hooks/duotone.js.map +1 -1
  90. package/build-module/hooks/index.js +2 -1
  91. package/build-module/hooks/index.js.map +1 -1
  92. package/build-module/hooks/use-border-props.js +21 -30
  93. package/build-module/hooks/use-border-props.js.map +1 -1
  94. package/build-module/index.js +1 -1
  95. package/build-module/index.js.map +1 -1
  96. package/build-module/store/actions.js +14 -2
  97. package/build-module/store/actions.js.map +1 -1
  98. package/build-module/store/reducer.js +0 -24
  99. package/build-module/store/reducer.js.map +1 -1
  100. package/build-module/store/selectors.js +8 -3
  101. package/build-module/store/selectors.js.map +1 -1
  102. package/build-style/style-rtl.css +111 -246
  103. package/build-style/style.css +111 -246
  104. package/package.json +28 -28
  105. package/src/components/block-list/block.native.js +2 -0
  106. package/src/components/block-mover/button.js +5 -7
  107. package/src/components/block-mover/index.js +37 -60
  108. package/src/components/block-mover/stories/index.js +110 -0
  109. package/src/components/block-mover/style.scss +48 -138
  110. package/src/components/block-popover/README.md +41 -0
  111. package/src/components/block-popover/inbetween.js +180 -0
  112. package/src/components/block-popover/index.js +73 -0
  113. package/src/components/block-popover/style.scss +24 -0
  114. package/src/components/{block-tools → block-popover}/use-popover-scroll.js +3 -1
  115. package/src/components/block-styles/index.js +1 -12
  116. package/src/components/block-switcher/style.scss +0 -4
  117. package/src/components/block-toolbar/style.scss +0 -12
  118. package/src/components/block-tools/back-compat.js +1 -1
  119. package/src/components/block-tools/block-selection-button.js +3 -1
  120. package/src/components/block-tools/index.js +6 -4
  121. package/src/components/block-tools/insertion-point.js +19 -152
  122. package/src/components/block-tools/{block-popover.js → selected-block-popover.js} +24 -116
  123. package/src/components/block-tools/style.scss +11 -123
  124. package/src/components/border-radius-control/style.scss +5 -2
  125. package/src/components/default-block-appender/style.scss +1 -2
  126. package/src/components/duotone-control/index.js +8 -1
  127. package/src/components/gradients/README.md +29 -0
  128. package/src/components/inserter/index.native.js +60 -25
  129. package/src/components/inserter/style.native.scss +24 -3
  130. package/src/components/navigable-toolbar/README.md +16 -0
  131. package/src/components/rich-text/index.js +0 -2
  132. package/src/components/rich-text/index.native.js +0 -4
  133. package/src/components/use-block-display-information/index.js +2 -0
  134. package/src/hooks/border.js +438 -72
  135. package/src/hooks/border.scss +48 -0
  136. package/src/hooks/duotone.js +98 -62
  137. package/src/hooks/index.js +2 -1
  138. package/src/hooks/use-border-props.js +15 -32
  139. package/src/index.js +1 -0
  140. package/src/store/actions.js +14 -2
  141. package/src/store/reducer.js +0 -21
  142. package/src/store/selectors.js +12 -3
  143. package/src/store/test/actions.js +0 -18
  144. package/src/store/test/reducer.js +0 -19
  145. package/src/store/test/selectors.js +0 -19
  146. package/src/style.scss +1 -1
  147. package/build/components/block-mobile-toolbar/index.js +0 -42
  148. package/build/components/block-mobile-toolbar/index.js.map +0 -1
  149. package/build/components/block-tools/block-popover.js.map +0 -1
  150. package/build/components/block-tools/use-popover-scroll.js.map +0 -1
  151. package/build/components/list-view/appender.js +0 -93
  152. package/build/components/list-view/appender.js.map +0 -1
  153. package/build/components/list-view/list-item.js +0 -62
  154. package/build/components/list-view/list-item.js.map +0 -1
  155. package/build/components/rich-text/use-caret-in-format.js +0 -43
  156. package/build/components/rich-text/use-caret-in-format.js.map +0 -1
  157. package/build/hooks/border-color.js +0 -302
  158. package/build/hooks/border-color.js.map +0 -1
  159. package/build/hooks/border-style.js +0 -96
  160. package/build/hooks/border-style.js.map +0 -1
  161. package/build/hooks/border-width.js +0 -162
  162. package/build/hooks/border-width.js.map +0 -1
  163. package/build-module/components/block-mobile-toolbar/index.js +0 -31
  164. package/build-module/components/block-mobile-toolbar/index.js.map +0 -1
  165. package/build-module/components/block-tools/block-popover.js.map +0 -1
  166. package/build-module/components/block-tools/use-popover-scroll.js.map +0 -1
  167. package/build-module/components/list-view/appender.js +0 -76
  168. package/build-module/components/list-view/appender.js.map +0 -1
  169. package/build-module/components/list-view/list-item.js +0 -47
  170. package/build-module/components/list-view/list-item.js.map +0 -1
  171. package/build-module/components/rich-text/use-caret-in-format.js +0 -33
  172. package/build-module/components/rich-text/use-caret-in-format.js.map +0 -1
  173. package/build-module/hooks/border-color.js +0 -276
  174. package/build-module/hooks/border-color.js.map +0 -1
  175. package/build-module/hooks/border-style.js +0 -78
  176. package/build-module/hooks/border-style.js.map +0 -1
  177. package/build-module/hooks/border-width.js +0 -143
  178. package/build-module/hooks/border-width.js.map +0 -1
  179. package/src/components/block-mobile-toolbar/index.js +0 -24
  180. package/src/components/block-mobile-toolbar/style.scss +0 -29
  181. package/src/components/list-view/appender.js +0 -82
  182. package/src/components/list-view/list-item.js +0 -59
  183. package/src/components/rich-text/use-caret-in-format.js +0 -28
  184. package/src/hooks/border-color.js +0 -315
  185. package/src/hooks/border-style.js +0 -64
  186. package/src/hooks/border-width.js +0 -139
@@ -1,276 +0,0 @@
1
- import _extends from "@babel/runtime/helpers/esm/extends";
2
- import { createElement } from "@wordpress/element";
3
-
4
- /**
5
- * External dependencies
6
- */
7
- import classnames from 'classnames';
8
- /**
9
- * WordPress dependencies
10
- */
11
-
12
- import { addFilter } from '@wordpress/hooks';
13
- import { __ } from '@wordpress/i18n';
14
- import { createHigherOrderComponent } from '@wordpress/compose';
15
- import { useEffect, useState } from '@wordpress/element';
16
- /**
17
- * Internal dependencies
18
- */
19
-
20
- import ColorGradientSettingsDropdown from '../components/colors-gradients/dropdown';
21
- import useMultipleOriginColorsAndGradients from '../components/colors-gradients/use-multiple-origin-colors-and-gradients';
22
- import { getColorClassName, getColorObjectByColorValue, getColorObjectByAttributeValues } from '../components/colors';
23
- import useSetting from '../components/use-setting';
24
- import { BORDER_SUPPORT_KEY, hasBorderSupport, removeBorderAttribute } from './border';
25
- import { cleanEmptyObject, shouldSkipSerialization } from './utils'; // Defining empty array here instead of inline avoids unnecessary re-renders of
26
- // color control.
27
-
28
- const EMPTY_ARRAY = [];
29
- /**
30
- * Inspector control panel containing the border color related configuration.
31
- *
32
- * There is deliberate overlap between the colors and borders block supports
33
- * relating to border color. It can be argued the border color controls could
34
- * be included within either, or both, the colors and borders panels in the
35
- * inspector controls. If they share the same block attributes it should not
36
- * matter.
37
- *
38
- * @param {Object} props Block properties.
39
- *
40
- * @return {WPElement} Border color edit element.
41
- */
42
-
43
- export function BorderColorEdit(props) {
44
- const {
45
- attributes: {
46
- borderColor,
47
- style
48
- },
49
- setAttributes
50
- } = props;
51
- const colorGradientSettings = useMultipleOriginColorsAndGradients();
52
- const availableColors = colorGradientSettings.colors.reduce((colors, origin) => colors.concat(origin.colors), []);
53
- const {
54
- color: customBorderColor
55
- } = (style === null || style === void 0 ? void 0 : style.border) || {};
56
- const [colorValue, setColorValue] = useState(() => {
57
- var _getColorObjectByAttr;
58
-
59
- return (_getColorObjectByAttr = getColorObjectByAttributeValues(availableColors, borderColor, customBorderColor)) === null || _getColorObjectByAttr === void 0 ? void 0 : _getColorObjectByAttr.color;
60
- }); // Detect changes in the color attributes and update the colorValue to keep the
61
- // UI in sync. This is necessary for situations when border controls interact with
62
- // each other: eg, setting the border width to zero causes the color and style
63
- // selections to be cleared.
64
-
65
- useEffect(() => {
66
- var _getColorObjectByAttr2;
67
-
68
- setColorValue((_getColorObjectByAttr2 = getColorObjectByAttributeValues(availableColors, borderColor, customBorderColor)) === null || _getColorObjectByAttr2 === void 0 ? void 0 : _getColorObjectByAttr2.color);
69
- }, [borderColor, customBorderColor, availableColors]);
70
-
71
- const onChangeColor = value => {
72
- setColorValue(value);
73
- const colorObject = getColorObjectByColorValue(availableColors, value);
74
- const newStyle = { ...style,
75
- border: { ...(style === null || style === void 0 ? void 0 : style.border),
76
- color: colorObject !== null && colorObject !== void 0 && colorObject.slug ? undefined : value
77
- }
78
- }; // If empty slug, ensure undefined to remove attribute.
79
-
80
- const newNamedColor = colorObject !== null && colorObject !== void 0 && colorObject.slug ? colorObject.slug : undefined;
81
- setAttributes({
82
- style: cleanEmptyObject(newStyle),
83
- borderColor: newNamedColor
84
- });
85
- };
86
-
87
- const settings = [{
88
- label: __('Color'),
89
- onColorChange: onChangeColor,
90
- colorValue,
91
- clearable: false
92
- }];
93
- return createElement(ColorGradientSettingsDropdown, _extends({
94
- settings: settings,
95
- disableCustomColors: true,
96
- disableCustomGradients: true,
97
- __experimentalHasMultipleOrigins: true,
98
- __experimentalIsRenderedInSidebar: true,
99
- enableAlpha: true
100
- }, colorGradientSettings));
101
- }
102
- /**
103
- * Checks if there is a current value in the border color block support
104
- * attributes.
105
- *
106
- * @param {Object} props Block props.
107
- * @return {boolean} Whether or not the block has a border color value set.
108
- */
109
-
110
- export function hasBorderColorValue(props) {
111
- var _style$border;
112
-
113
- const {
114
- attributes: {
115
- borderColor,
116
- style
117
- }
118
- } = props;
119
- return !!borderColor || !!(style !== null && style !== void 0 && (_style$border = style.border) !== null && _style$border !== void 0 && _style$border.color);
120
- }
121
- /**
122
- * Resets the border color block support attributes. This can be used when
123
- * disabling the border color support controls for a block via a progressive
124
- * discovery panel.
125
- *
126
- * @param {Object} props Block props.
127
- * @param {Object} props.attributes Block's attributes.
128
- * @param {Object} props.setAttributes Function to set block's attributes.
129
- */
130
-
131
- export function resetBorderColor(_ref) {
132
- let {
133
- attributes = {},
134
- setAttributes
135
- } = _ref;
136
- const {
137
- style
138
- } = attributes;
139
- setAttributes({
140
- borderColor: undefined,
141
- style: removeBorderAttribute(style, 'color')
142
- });
143
- }
144
- /**
145
- * Filters registered block settings, extending attributes to include
146
- * `borderColor` if needed.
147
- *
148
- * @param {Object} settings Original block settings.
149
- *
150
- * @return {Object} Updated block settings.
151
- */
152
-
153
- function addAttributes(settings) {
154
- if (!hasBorderSupport(settings, 'color')) {
155
- return settings;
156
- } // Allow blocks to specify default value if needed.
157
-
158
-
159
- if (settings.attributes.borderColor) {
160
- return settings;
161
- } // Add new borderColor attribute to block settings.
162
-
163
-
164
- return { ...settings,
165
- attributes: { ...settings.attributes,
166
- borderColor: {
167
- type: 'string'
168
- }
169
- }
170
- };
171
- }
172
- /**
173
- * Override props assigned to save component to inject border color.
174
- *
175
- * @param {Object} props Additional props applied to save element.
176
- * @param {Object} blockType Block type definition.
177
- * @param {Object} attributes Block's attributes.
178
- *
179
- * @return {Object} Filtered props to apply to save element.
180
- */
181
-
182
-
183
- function addSaveProps(props, blockType, attributes) {
184
- var _style$border2;
185
-
186
- if (!hasBorderSupport(blockType, 'color') || shouldSkipSerialization(blockType, BORDER_SUPPORT_KEY, 'color')) {
187
- return props;
188
- }
189
-
190
- const {
191
- borderColor,
192
- style
193
- } = attributes;
194
- const borderColorClass = getColorClassName('border-color', borderColor);
195
- const newClassName = classnames(props.className, {
196
- '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),
197
- [borderColorClass]: !!borderColorClass
198
- }); // If we are clearing the last of the previous classes in `className`
199
- // set it to `undefined` to avoid rendering empty DOM attributes.
200
-
201
- props.className = newClassName ? newClassName : undefined;
202
- return props;
203
- }
204
- /**
205
- * Filters the registered block settings to apply border color styles and
206
- * classnames to the block edit wrapper.
207
- *
208
- * @param {Object} settings Original block settings.
209
- *
210
- * @return {Object} Filtered block settings.
211
- */
212
-
213
-
214
- function addEditProps(settings) {
215
- if (!hasBorderSupport(settings, 'color') || shouldSkipSerialization(settings, BORDER_SUPPORT_KEY, 'color')) {
216
- return settings;
217
- }
218
-
219
- const existingGetEditWrapperProps = settings.getEditWrapperProps;
220
-
221
- settings.getEditWrapperProps = attributes => {
222
- let props = {};
223
-
224
- if (existingGetEditWrapperProps) {
225
- props = existingGetEditWrapperProps(attributes);
226
- }
227
-
228
- return addSaveProps(props, settings, attributes);
229
- };
230
-
231
- return settings;
232
- }
233
- /**
234
- * This adds inline styles for color palette colors.
235
- * Ideally, this is not needed and themes should load their palettes on the editor.
236
- *
237
- * @param {Function} BlockListBlock Original component.
238
- *
239
- * @return {Function} Wrapped component.
240
- */
241
-
242
-
243
- export const withBorderColorPaletteStyles = createHigherOrderComponent(BlockListBlock => props => {
244
- var _getColorObjectByAttr3, _props$wrapperProps;
245
-
246
- const {
247
- name,
248
- attributes
249
- } = props;
250
- const {
251
- borderColor
252
- } = attributes;
253
- const colors = useSetting('color.palette') || EMPTY_ARRAY;
254
-
255
- if (!hasBorderSupport(name, 'color') || shouldSkipSerialization(name, BORDER_SUPPORT_KEY, 'color')) {
256
- return createElement(BlockListBlock, props);
257
- }
258
-
259
- const extraStyles = {
260
- borderColor: borderColor ? (_getColorObjectByAttr3 = getColorObjectByAttributeValues(colors, borderColor)) === null || _getColorObjectByAttr3 === void 0 ? void 0 : _getColorObjectByAttr3.color : undefined
261
- };
262
- let wrapperProps = props.wrapperProps;
263
- wrapperProps = { ...props.wrapperProps,
264
- style: { ...extraStyles,
265
- ...((_props$wrapperProps = props.wrapperProps) === null || _props$wrapperProps === void 0 ? void 0 : _props$wrapperProps.style)
266
- }
267
- };
268
- return createElement(BlockListBlock, _extends({}, props, {
269
- wrapperProps: wrapperProps
270
- }));
271
- });
272
- addFilter('blocks.registerBlockType', 'core/border/addAttributes', addAttributes);
273
- addFilter('blocks.getSaveContent.extraProps', 'core/border/addSaveProps', addSaveProps);
274
- addFilter('blocks.registerBlockType', 'core/border/addEditProps', addEditProps);
275
- addFilter('editor.BlockListBlock', 'core/border/with-border-color-palette-styles', withBorderColorPaletteStyles);
276
- //# sourceMappingURL=border-color.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/hooks/border-color.js"],"names":["classnames","addFilter","__","createHigherOrderComponent","useEffect","useState","ColorGradientSettingsDropdown","useMultipleOriginColorsAndGradients","getColorClassName","getColorObjectByColorValue","getColorObjectByAttributeValues","useSetting","BORDER_SUPPORT_KEY","hasBorderSupport","removeBorderAttribute","cleanEmptyObject","shouldSkipSerialization","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","borderColorClass","newClassName","className","addEditProps","existingGetEditWrapperProps","getEditWrapperProps","withBorderColorPaletteStyles","BlockListBlock","name","extraStyles","wrapperProps"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,SAAT,QAA0B,kBAA1B;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,0BAAT,QAA2C,oBAA3C;AACA,SAASC,SAAT,EAAoBC,QAApB,QAAoC,oBAApC;AAEA;AACA;AACA;;AACA,OAAOC,6BAAP,MAA0C,yCAA1C;AACA,OAAOC,mCAAP,MAAgD,yEAAhD;AACA,SACCC,iBADD,EAECC,0BAFD,EAGCC,+BAHD,QAIO,sBAJP;AAKA,OAAOC,UAAP,MAAuB,2BAAvB;AACA,SACCC,kBADD,EAECC,gBAFD,EAGCC,qBAHD,QAIO,UAJP;AAKA,SAASC,gBAAT,EAA2BC,uBAA3B,QAA0D,SAA1D,C,CAEA;AACA;;AACA,MAAMC,WAAW,GAAG,EAApB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,eAAT,CAA0BC,KAA1B,EAAkC;AACxC,QAAM;AACLC,IAAAA,UAAU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,OAA5B,CAFxB,EAGE;AACD,WAAO,cAAC,cAAD,EAAqBO,KAArB,CAAP;AACA;;AAED,QAAM0C,WAAW,GAAG;AACnBxC,IAAAA,WAAW,EAAEA,WAAW,6BACrBX,+BAA+B,CAAEgB,MAAF,EAAUL,WAAV,CADV,2DACrB,uBAAwDS,KADnC,GAErBU;AAHgB,GAApB;AAMA,MAAIsB,YAAY,GAAG3C,KAAK,CAAC2C,YAAzB;AACAA,EAAAA,YAAY,GAAG,EACd,GAAG3C,KAAK,CAAC2C,YADK;AAEdxC,IAAAA,KAAK,EAAE,EACN,GAAGuC,WADG;AAEN,iCAAG1C,KAAK,CAAC2C,YAAT,wDAAG,oBAAoBxC,KAAvB;AAFM;AAFO,GAAf;AAQA,SAAO,cAAC,cAAD,eAAqBH,KAArB;AAA6B,IAAA,YAAY,EAAG2C;AAA5C,KAAP;AACA,CA7BoE,CAA/D;AAgCP7D,SAAS,CACR,0BADQ,EAER,2BAFQ,EAGR+C,aAHQ,CAAT;AAMA/C,SAAS,CACR,kCADQ,EAER,0BAFQ,EAGRiD,YAHQ,CAAT;AAMAjD,SAAS,CACR,0BADQ,EAER,0BAFQ,EAGRsD,YAHQ,CAAT;AAMAtD,SAAS,CACR,uBADQ,EAER,8CAFQ,EAGRyD,4BAHQ,CAAT","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,78 +0,0 @@
1
- import { createElement } from "@wordpress/element";
2
-
3
- /**
4
- * Internal dependencies
5
- */
6
- import BorderStyleControl from '../components/border-style-control';
7
- import { cleanEmptyObject } from './utils';
8
- import { removeBorderAttribute } from './border';
9
- /**
10
- * Inspector control for configuring border style property.
11
- *
12
- * @param {Object} props Block properties.
13
- *
14
- * @return {WPElement} Border style edit element.
15
- */
16
-
17
- export const BorderStyleEdit = props => {
18
- var _style$border;
19
-
20
- const {
21
- attributes: {
22
- style
23
- },
24
- setAttributes
25
- } = props;
26
-
27
- const onChange = newBorderStyle => {
28
- const newStyleAttributes = { ...style,
29
- border: { ...(style === null || style === void 0 ? void 0 : style.border),
30
- style: newBorderStyle
31
- }
32
- };
33
- setAttributes({
34
- style: cleanEmptyObject(newStyleAttributes)
35
- });
36
- };
37
-
38
- return createElement(BorderStyleControl, {
39
- value: style === null || style === void 0 ? void 0 : (_style$border = style.border) === null || _style$border === void 0 ? void 0 : _style$border.style,
40
- onChange: onChange
41
- });
42
- };
43
- /**
44
- * Checks if there is a current value in the border style block support
45
- * attributes.
46
- *
47
- * @param {Object} props Block props.
48
- * @return {boolean} Whether or not the block has a border style value set.
49
- */
50
-
51
- export function hasBorderStyleValue(props) {
52
- var _props$attributes$sty, _props$attributes$sty2;
53
-
54
- 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);
55
- }
56
- /**
57
- * Resets the border style block support attribute. This can be used when
58
- * disabling the border style support control for a block via a progressive
59
- * discovery panel.
60
- *
61
- * @param {Object} props Block props.
62
- * @param {Object} props.attributes Block's attributes.
63
- * @param {Object} props.setAttributes Function to set block's attributes.
64
- */
65
-
66
- export function resetBorderStyle(_ref) {
67
- let {
68
- attributes = {},
69
- setAttributes
70
- } = _ref;
71
- const {
72
- style
73
- } = attributes;
74
- setAttributes({
75
- style: removeBorderAttribute(style, 'style')
76
- });
77
- }
78
- //# sourceMappingURL=border-style.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/hooks/border-style.js"],"names":["BorderStyleControl","cleanEmptyObject","removeBorderAttribute","BorderStyleEdit","props","attributes","style","setAttributes","onChange","newBorderStyle","newStyleAttributes","border","hasBorderStyleValue","resetBorderStyle"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,kBAAP,MAA+B,oCAA/B;AACA,SAASC,gBAAT,QAAiC,SAAjC;AACA,SA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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,143 +0,0 @@
1
- import { createElement } from "@wordpress/element";
2
-
3
- /**
4
- * WordPress dependencies
5
- */
6
- import { __experimentalUnitControl as UnitControl, __experimentalUseCustomUnits as useCustomUnits } from '@wordpress/components';
7
- import { useState } from '@wordpress/element';
8
- import { __ } from '@wordpress/i18n';
9
- /**
10
- * Internal dependencies
11
- */
12
-
13
- import { cleanEmptyObject } from './utils';
14
- import { removeBorderAttribute } from './border';
15
- import useSetting from '../components/use-setting';
16
- const MIN_BORDER_WIDTH = 0;
17
- /**
18
- * Inspector control for configuring border width property.
19
- *
20
- * @param {Object} props Block properties.
21
- *
22
- * @return {WPElement} Border width edit element.
23
- */
24
-
25
- export const BorderWidthEdit = props => {
26
- const {
27
- attributes: {
28
- borderColor,
29
- style
30
- },
31
- setAttributes
32
- } = props;
33
- const {
34
- width,
35
- color: customBorderColor,
36
- style: borderStyle
37
- } = (style === null || style === void 0 ? void 0 : style.border) || {}; // Used to temporarily track previous border color & style selections to be
38
- // able to restore them when border width changes from zero value.
39
-
40
- const [styleSelection, setStyleSelection] = useState();
41
- const [colorSelection, setColorSelection] = useState();
42
- const [customColorSelection, setCustomColorSelection] = useState();
43
-
44
- const onChange = newWidth => {
45
- let newStyle = { ...style,
46
- border: { ...(style === null || style === void 0 ? void 0 : style.border),
47
- width: newWidth
48
- }
49
- }; // Used to clear named border color attribute.
50
-
51
- let borderPaletteColor = borderColor;
52
- const hasZeroWidth = parseFloat(newWidth) === 0;
53
- const hadPreviousZeroWidth = parseFloat(width) === 0; // Setting the border width explicitly to zero will also set the
54
- // border style to `none` and clear border color attributes.
55
-
56
- if (hasZeroWidth && !hadPreviousZeroWidth) {
57
- // Before clearing color and style selections, keep track of
58
- // the current selections so they can be restored when the width
59
- // changes to a non-zero value.
60
- setColorSelection(borderColor);
61
- setCustomColorSelection(customBorderColor);
62
- setStyleSelection(borderStyle); // Clear style and color attributes.
63
-
64
- borderPaletteColor = undefined;
65
- newStyle.border.color = undefined;
66
- newStyle.border.style = 'none';
67
- }
68
-
69
- if (!hasZeroWidth && hadPreviousZeroWidth) {
70
- // Restore previous border style selection if width is now not zero and
71
- // border style was 'none'. This is to support changes to the UI which
72
- // change the border style UI to a segmented control without a "none"
73
- // option.
74
- if (borderStyle === 'none') {
75
- newStyle.border.style = styleSelection;
76
- } // Restore previous border color selection if width is no longer zero
77
- // and current border color is undefined.
78
-
79
-
80
- if (borderColor === undefined) {
81
- borderPaletteColor = colorSelection;
82
- newStyle.border.color = customColorSelection;
83
- }
84
- } // If width was reset, clean out undefined styles.
85
-
86
-
87
- if (newWidth === undefined || newWidth === '') {
88
- newStyle = cleanEmptyObject(newStyle);
89
- }
90
-
91
- setAttributes({
92
- borderColor: borderPaletteColor,
93
- style: newStyle
94
- });
95
- };
96
-
97
- const units = useCustomUnits({
98
- availableUnits: useSetting('spacing.units') || ['px', 'em', 'rem']
99
- });
100
- return createElement(UnitControl, {
101
- value: width,
102
- label: __('Width'),
103
- min: MIN_BORDER_WIDTH,
104
- onChange: onChange,
105
- units: units
106
- });
107
- };
108
- /**
109
- * Checks if there is a current value in the border width block support
110
- * attributes.
111
- *
112
- * @param {Object} props Block props.
113
- * @return {boolean} Whether or not the block has a border width value set.
114
- */
115
-
116
- export function hasBorderWidthValue(props) {
117
- var _props$attributes$sty, _props$attributes$sty2;
118
-
119
- 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);
120
- }
121
- /**
122
- * Resets the border width block support attribute. This can be used when
123
- * disabling the border width support control for a block via a progressive
124
- * discovery panel.
125
- *
126
- * @param {Object} props Block props.
127
- * @param {Object} props.attributes Block's attributes.
128
- * @param {Object} props.setAttributes Function to set block's attributes.
129
- */
130
-
131
- export function resetBorderWidth(_ref) {
132
- let {
133
- attributes = {},
134
- setAttributes
135
- } = _ref;
136
- const {
137
- style
138
- } = attributes;
139
- setAttributes({
140
- style: removeBorderAttribute(style, 'width')
141
- });
142
- }
143
- //# sourceMappingURL=border-width.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/hooks/border-width.js"],"names":["__experimentalUnitControl","UnitControl","__experimentalUseCustomUnits","useCustomUnits","useState","__","cleanEmptyObject","removeBorderAttribute","useSetting","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":";;AAAA;AACA;AACA;AACA,SACCA,yBAAyB,IAAIC,WAD9B,EAECC,4BAA4B,IAAIC,cAFjC,QAGO,uBAHP;AAIA,SAASC,QAAT,QAAyB,oBAAzB;AACA,SAASC,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AACA,SAASC,gBAAT,QAAiC,SAAjC;AACA,SAASC,qBAAT,QAAsC,UAAtC;AACA,OAAOC,UAAP,MAAuB,2BAAvB;AAEA,MAAMC,gBAAgB,GAAG,CAAzB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,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,IAAwClB,QAAQ,EAAtD;AACA,QAAM,CAAEmB,cAAF,EAAkBC,iBAAlB,IAAwCpB,QAAQ,EAAtD;AACA,QAAM,CAAEqB,oBAAF,EAAwBC,uBAAxB,IAAoDtB,QAAQ,EAAlE;;AAEA,QAAMuB,QAAQ,GAAKC,QAAF,IAAgB;AAChC,QAAIC,QAAQ,GAAG,EACd,GAAGf,KADW;AAEdM,MAAAA,MAAM,EAAE,EACP,IAAGN,KAAH,aAAGA,KAAH,uBAAGA,KAAK,CA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EAAEe;AAFO,KAAF,CAAb;AAIA,GAzDD;;AA2DA,QAAMM,KAAK,GAAGhC,cAAc,CAAE;AAC7BiC,IAAAA,cAAc,EAAE5B,UAAU,CAAE,eAAF,CAAV,IAAiC,CAAE,IAAF,EAAQ,IAAR,EAAc,KAAd;AADpB,GAAF,CAA5B;AAIA,SACC,cAAC,WAAD;AACC,IAAA,KAAK,EAAGQ,KADT;AAEC,IAAA,KAAK,EAAGX,EAAE,CAAE,OAAF,CAFX;AAGC,IAAA,GAAG,EAAGI,gBAHP;AAIC,IAAA,QAAQ,EAAGkB,QAJZ;AAKC,IAAA,KAAK,EAAGQ;AALT,IADD;AASA,CAvFM;AAyFP;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,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;;AACA,OAAO,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,EAAEP,qBAAqB,CAAEO,KAAF,EAAS,OAAT;AAA9B,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,24 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { useViewportMatch } from '@wordpress/compose';
5
-
6
- /**
7
- * Internal dependencies
8
- */
9
- import BlockMover from '../block-mover';
10
-
11
- function BlockMobileToolbar( { clientId } ) {
12
- const isMobile = useViewportMatch( 'small', '<' );
13
- if ( ! isMobile ) {
14
- return null;
15
- }
16
-
17
- return (
18
- <div className="block-editor-block-mobile-toolbar">
19
- <BlockMover clientIds={ [ clientId ] } />
20
- </div>
21
- );
22
- }
23
-
24
- export default BlockMobileToolbar;
@@ -1,29 +0,0 @@
1
- .block-editor-block-mobile-toolbar {
2
- display: flex;
3
- flex-direction: row;
4
- border-right: $border-width solid $gray-300;
5
-
6
- .block-editor-block-mover-button {
7
- width: $button-size;
8
- height: $button-size;
9
- border-radius: $radius-block-ui;
10
- padding: 3px;
11
- margin: 0;
12
- justify-content: center;
13
- align-items: center;
14
-
15
- .dashicon {
16
- margin: auto;
17
- }
18
- }
19
-
20
- // Movers
21
- .block-editor-block-mover {
22
- display: flex;
23
- margin-right: auto;
24
-
25
- .block-editor-block-mover-button {
26
- float: left;
27
- }
28
- }
29
- }