@wordpress/block-editor 15.1.0 → 15.1.1-next.0f6f9d12c.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.
- package/build/components/block-settings-menu/block-settings-dropdown.js +6 -2
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-toolbar/block-toolbar-menu.native.js +2 -2
- package/build/components/block-toolbar/block-toolbar-menu.native.js.map +1 -1
- package/build/components/border-radius-control/constants.js +41 -0
- package/build/components/border-radius-control/constants.js.map +1 -0
- package/build/components/border-radius-control/index.js +49 -58
- package/build/components/border-radius-control/index.js.map +1 -1
- package/build/components/border-radius-control/linked-button.js +1 -1
- package/build/components/border-radius-control/linked-button.js.map +1 -1
- package/build/components/border-radius-control/single-input-control.js +204 -0
- package/build/components/border-radius-control/single-input-control.js.map +1 -0
- package/build/components/border-radius-control/utils.js +161 -4
- package/build/components/border-radius-control/utils.js.map +1 -1
- package/build/components/global-styles/border-panel.js +12 -1
- package/build/components/global-styles/border-panel.js.map +1 -1
- package/build/components/global-styles/hooks.js +1 -1
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/utils.js +5 -3
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/rich-text/index.js +9 -4
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/use-format-types.js +19 -8
- package/build/components/rich-text/use-format-types.js.map +1 -1
- package/build/hooks/duotone.js +2 -2
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/utils.js +4 -3
- package/build/hooks/utils.js.map +1 -1
- package/build/private-apis.js +2 -1
- package/build/private-apis.js.map +1 -1
- package/build/store/private-keys.js +2 -1
- package/build/store/private-keys.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +6 -2
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-toolbar/block-toolbar-menu.native.js +3 -3
- package/build-module/components/block-toolbar/block-toolbar-menu.native.js.map +1 -1
- package/build-module/components/border-radius-control/constants.js +34 -0
- package/build-module/components/border-radius-control/constants.js.map +1 -0
- package/build-module/components/border-radius-control/index.js +53 -62
- package/build-module/components/border-radius-control/index.js.map +1 -1
- package/build-module/components/border-radius-control/linked-button.js +1 -1
- package/build-module/components/border-radius-control/linked-button.js.map +1 -1
- package/build-module/components/border-radius-control/single-input-control.js +197 -0
- package/build-module/components/border-radius-control/single-input-control.js.map +1 -0
- package/build-module/components/border-radius-control/utils.js +154 -4
- package/build-module/components/border-radius-control/utils.js.map +1 -1
- package/build-module/components/global-styles/border-panel.js +12 -1
- package/build-module/components/global-styles/border-panel.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +1 -1
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/utils.js +5 -3
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/rich-text/index.js +9 -4
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/use-format-types.js +19 -8
- package/build-module/components/rich-text/use-format-types.js.map +1 -1
- package/build-module/hooks/duotone.js +3 -3
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/utils.js +4 -3
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/private-apis.js +3 -2
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/private-keys.js +1 -0
- package/build-module/store/private-keys.js.map +1 -1
- package/build-style/style-rtl.css +16 -18
- package/build-style/style.css +16 -18
- package/package.json +34 -34
- package/src/components/block-settings-menu/block-settings-dropdown.js +22 -14
- package/src/components/block-toolbar/block-toolbar-menu.native.js +3 -3
- package/src/components/border-radius-control/constants.js +46 -0
- package/src/components/border-radius-control/index.js +71 -72
- package/src/components/border-radius-control/linked-button.js +1 -1
- package/src/components/border-radius-control/single-input-control.js +277 -0
- package/src/components/border-radius-control/style.scss +16 -21
- package/src/components/border-radius-control/utils.js +178 -5
- package/src/components/global-styles/border-panel.js +12 -1
- package/src/components/global-styles/hooks.js +1 -0
- package/src/components/global-styles/utils.js +6 -1
- package/src/components/rich-text/index.js +19 -10
- package/src/components/rich-text/use-format-types.js +42 -19
- package/src/hooks/duotone.js +11 -3
- package/src/hooks/utils.js +4 -0
- package/src/private-apis.js +2 -0
- package/src/store/private-keys.js +1 -0
- package/build/components/border-radius-control/all-input-control.js +0 -65
- package/build/components/border-radius-control/all-input-control.js.map +0 -1
- package/build/components/border-radius-control/input-controls.js +0 -82
- package/build/components/border-radius-control/input-controls.js.map +0 -1
- package/build-module/components/border-radius-control/all-input-control.js +0 -58
- package/build-module/components/border-radius-control/all-input-control.js.map +0 -1
- package/build-module/components/border-radius-control/input-controls.js +0 -75
- package/build-module/components/border-radius-control/input-controls.js.map +0 -1
- package/src/components/border-radius-control/all-input-control.js +0 -67
- package/src/components/border-radius-control/input-controls.js +0 -91
package/build-style/style.css
CHANGED
|
@@ -1660,6 +1660,11 @@ iframe[name=editor-canvas] {
|
|
|
1660
1660
|
min-width: 230px;
|
|
1661
1661
|
}
|
|
1662
1662
|
|
|
1663
|
+
.components-border-radius-control__header {
|
|
1664
|
+
height: 16px;
|
|
1665
|
+
margin-bottom: 12px;
|
|
1666
|
+
}
|
|
1667
|
+
|
|
1663
1668
|
.components-border-radius-control {
|
|
1664
1669
|
border: 0;
|
|
1665
1670
|
padding: 0;
|
|
@@ -1667,22 +1672,7 @@ iframe[name=editor-canvas] {
|
|
|
1667
1672
|
margin-bottom: 12px;
|
|
1668
1673
|
}
|
|
1669
1674
|
.components-border-radius-control legend {
|
|
1670
|
-
margin-bottom: 8px;
|
|
1671
|
-
}
|
|
1672
|
-
.components-border-radius-control .components-border-radius-control__wrapper {
|
|
1673
|
-
display: flex;
|
|
1674
|
-
justify-content: space-between;
|
|
1675
|
-
align-items: flex-start;
|
|
1676
|
-
}
|
|
1677
|
-
.components-border-radius-control .components-border-radius-control__wrapper .components-border-radius-control__unit-control {
|
|
1678
|
-
width: calc((100% - 16px) / 2);
|
|
1679
1675
|
margin-bottom: 0;
|
|
1680
|
-
margin-right: 16px;
|
|
1681
|
-
flex-shrink: 0;
|
|
1682
|
-
}
|
|
1683
|
-
.components-border-radius-control .components-border-radius-control__wrapper .components-border-radius-control__range-control {
|
|
1684
|
-
flex: 1;
|
|
1685
|
-
margin-right: 12px;
|
|
1686
1676
|
}
|
|
1687
1677
|
.components-border-radius-control .components-border-radius-control__input-controls-wrapper {
|
|
1688
1678
|
display: grid;
|
|
@@ -1690,15 +1680,23 @@ iframe[name=editor-canvas] {
|
|
|
1690
1680
|
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
1691
1681
|
margin-right: 12px;
|
|
1692
1682
|
}
|
|
1693
|
-
.components-border-radius-control .
|
|
1683
|
+
.components-border-radius-control .components-border-radius-control__linked-button {
|
|
1694
1684
|
display: flex;
|
|
1695
1685
|
justify-content: center;
|
|
1696
|
-
margin-top: 8px;
|
|
1697
1686
|
}
|
|
1698
|
-
.components-border-radius-control .
|
|
1687
|
+
.components-border-radius-control .components-border-radius-control__linked-button svg {
|
|
1699
1688
|
margin-right: 0;
|
|
1700
1689
|
}
|
|
1701
1690
|
|
|
1691
|
+
.components-border-radius-control__custom-select-control,
|
|
1692
|
+
.components-border-radius-control__range-control {
|
|
1693
|
+
flex: 1;
|
|
1694
|
+
}
|
|
1695
|
+
|
|
1696
|
+
.components-border-radius-control__icon {
|
|
1697
|
+
flex: 0 0 auto;
|
|
1698
|
+
}
|
|
1699
|
+
|
|
1702
1700
|
.block-editor-color-gradient-control .block-editor-color-gradient-control__color-indicator {
|
|
1703
1701
|
margin-bottom: 12px;
|
|
1704
1702
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/block-editor",
|
|
3
|
-
"version": "15.1.0",
|
|
3
|
+
"version": "15.1.1-next.0f6f9d12c.0",
|
|
4
4
|
"description": "Generic block editor.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -37,38 +37,38 @@
|
|
|
37
37
|
"@emotion/react": "^11.7.1",
|
|
38
38
|
"@emotion/styled": "^11.6.0",
|
|
39
39
|
"@react-spring/web": "^9.4.5",
|
|
40
|
-
"@wordpress/a11y": "^4.28.0",
|
|
41
|
-
"@wordpress/api-fetch": "^7.28.0",
|
|
42
|
-
"@wordpress/blob": "^4.28.0",
|
|
43
|
-
"@wordpress/block-serialization-default-parser": "^5.28.0",
|
|
44
|
-
"@wordpress/blocks": "^15.1.0",
|
|
45
|
-
"@wordpress/commands": "^1.28.0",
|
|
46
|
-
"@wordpress/components": "^30.1.0",
|
|
47
|
-
"@wordpress/compose": "^7.28.0",
|
|
48
|
-
"@wordpress/data": "^10.28.0",
|
|
49
|
-
"@wordpress/date": "^5.28.0",
|
|
50
|
-
"@wordpress/deprecated": "^4.28.0",
|
|
51
|
-
"@wordpress/dom": "^4.28.0",
|
|
52
|
-
"@wordpress/element": "^6.28.0",
|
|
53
|
-
"@wordpress/escape-html": "^3.28.0",
|
|
54
|
-
"@wordpress/hooks": "^4.28.0",
|
|
55
|
-
"@wordpress/html-entities": "^4.28.0",
|
|
56
|
-
"@wordpress/i18n": "^6.1.0",
|
|
57
|
-
"@wordpress/icons": "^10.28.0",
|
|
58
|
-
"@wordpress/is-shallow-equal": "^5.28.0",
|
|
59
|
-
"@wordpress/keyboard-shortcuts": "^5.28.0",
|
|
60
|
-
"@wordpress/keycodes": "^4.28.0",
|
|
61
|
-
"@wordpress/notices": "^5.28.0",
|
|
62
|
-
"@wordpress/preferences": "^4.28.0",
|
|
63
|
-
"@wordpress/priority-queue": "^3.28.0",
|
|
64
|
-
"@wordpress/private-apis": "^1.28.0",
|
|
65
|
-
"@wordpress/rich-text": "^7.28.0",
|
|
66
|
-
"@wordpress/style-engine": "^2.28.0",
|
|
67
|
-
"@wordpress/token-list": "^3.28.0",
|
|
68
|
-
"@wordpress/upload-media": "^0.13.0",
|
|
69
|
-
"@wordpress/url": "^4.28.0",
|
|
70
|
-
"@wordpress/warning": "^3.28.0",
|
|
71
|
-
"@wordpress/wordcount": "^4.28.0",
|
|
40
|
+
"@wordpress/a11y": "^4.28.1-next.0f6f9d12c.0",
|
|
41
|
+
"@wordpress/api-fetch": "^7.28.1-next.0f6f9d12c.0",
|
|
42
|
+
"@wordpress/blob": "^4.28.1-next.0f6f9d12c.0",
|
|
43
|
+
"@wordpress/block-serialization-default-parser": "^5.28.1-next.0f6f9d12c.0",
|
|
44
|
+
"@wordpress/blocks": "^15.1.1-next.0f6f9d12c.0",
|
|
45
|
+
"@wordpress/commands": "^1.28.1-next.0f6f9d12c.0",
|
|
46
|
+
"@wordpress/components": "^30.2.1-next.0f6f9d12c.0",
|
|
47
|
+
"@wordpress/compose": "^7.28.1-next.0f6f9d12c.0",
|
|
48
|
+
"@wordpress/data": "^10.28.1-next.0f6f9d12c.0",
|
|
49
|
+
"@wordpress/date": "^5.28.1-next.0f6f9d12c.0",
|
|
50
|
+
"@wordpress/deprecated": "^4.28.1-next.0f6f9d12c.0",
|
|
51
|
+
"@wordpress/dom": "^4.28.1-next.0f6f9d12c.0",
|
|
52
|
+
"@wordpress/element": "^6.28.1-next.0f6f9d12c.0",
|
|
53
|
+
"@wordpress/escape-html": "^3.28.1-next.0f6f9d12c.0",
|
|
54
|
+
"@wordpress/hooks": "^4.28.1-next.0f6f9d12c.0",
|
|
55
|
+
"@wordpress/html-entities": "^4.28.1-next.0f6f9d12c.0",
|
|
56
|
+
"@wordpress/i18n": "^6.1.1-next.0f6f9d12c.0",
|
|
57
|
+
"@wordpress/icons": "^10.28.2-next.0f6f9d12c.0",
|
|
58
|
+
"@wordpress/is-shallow-equal": "^5.28.1-next.0f6f9d12c.0",
|
|
59
|
+
"@wordpress/keyboard-shortcuts": "^5.28.1-next.0f6f9d12c.0",
|
|
60
|
+
"@wordpress/keycodes": "^4.28.1-next.0f6f9d12c.0",
|
|
61
|
+
"@wordpress/notices": "^5.28.1-next.0f6f9d12c.0",
|
|
62
|
+
"@wordpress/preferences": "^4.28.1-next.0f6f9d12c.0",
|
|
63
|
+
"@wordpress/priority-queue": "^3.28.1-next.0f6f9d12c.0",
|
|
64
|
+
"@wordpress/private-apis": "^1.28.1-next.0f6f9d12c.0",
|
|
65
|
+
"@wordpress/rich-text": "^7.28.1-next.0f6f9d12c.0",
|
|
66
|
+
"@wordpress/style-engine": "^2.28.1-next.0f6f9d12c.0",
|
|
67
|
+
"@wordpress/token-list": "^3.28.1-next.0f6f9d12c.0",
|
|
68
|
+
"@wordpress/upload-media": "^0.13.1-next.0f6f9d12c.0",
|
|
69
|
+
"@wordpress/url": "^4.28.1-next.0f6f9d12c.0",
|
|
70
|
+
"@wordpress/warning": "^3.28.1-next.0f6f9d12c.0",
|
|
71
|
+
"@wordpress/wordcount": "^4.28.1-next.0f6f9d12c.0",
|
|
72
72
|
"change-case": "^4.1.2",
|
|
73
73
|
"clsx": "^2.1.1",
|
|
74
74
|
"colord": "^2.7.0",
|
|
@@ -91,5 +91,5 @@
|
|
|
91
91
|
"publishConfig": {
|
|
92
92
|
"access": "public"
|
|
93
93
|
},
|
|
94
|
-
"gitHead": "
|
|
94
|
+
"gitHead": "7d4f4367e2f76deddf4a09b540e6b2f9f4c3fe9f"
|
|
95
95
|
}
|
|
@@ -88,6 +88,7 @@ export function BlockSettingsDropdown( {
|
|
|
88
88
|
selectedBlockClientIds,
|
|
89
89
|
openedBlockSettingsMenu,
|
|
90
90
|
isContentOnly,
|
|
91
|
+
isNavigationMode,
|
|
91
92
|
isZoomOut,
|
|
92
93
|
} = useSelect(
|
|
93
94
|
( select ) => {
|
|
@@ -99,6 +100,7 @@ export function BlockSettingsDropdown( {
|
|
|
99
100
|
getBlockAttributes,
|
|
100
101
|
getOpenedBlockSettingsMenu,
|
|
101
102
|
getBlockEditingMode,
|
|
103
|
+
isNavigationMode: _isNavigationMode,
|
|
102
104
|
isZoomOut: _isZoomOut,
|
|
103
105
|
} = unlock( select( blockEditorStore ) );
|
|
104
106
|
|
|
@@ -124,6 +126,7 @@ export function BlockSettingsDropdown( {
|
|
|
124
126
|
openedBlockSettingsMenu: getOpenedBlockSettingsMenu(),
|
|
125
127
|
isContentOnly:
|
|
126
128
|
getBlockEditingMode( firstBlockClientId ) === 'contentOnly',
|
|
129
|
+
isNavigationMode: _isNavigationMode(),
|
|
127
130
|
isZoomOut: _isZoomOut(),
|
|
128
131
|
};
|
|
129
132
|
},
|
|
@@ -155,6 +158,7 @@ export function BlockSettingsDropdown( {
|
|
|
155
158
|
};
|
|
156
159
|
}, [] );
|
|
157
160
|
const hasSelectedBlocks = selectedBlockClientIds.length > 0;
|
|
161
|
+
const isContentOnlyWriteMode = isNavigationMode && isContentOnly;
|
|
158
162
|
|
|
159
163
|
async function updateSelectionAfterDuplicate( clientIdsPromise ) {
|
|
160
164
|
if ( ! __experimentalSelectBlock ) {
|
|
@@ -278,20 +282,24 @@ export function BlockSettingsDropdown( {
|
|
|
278
282
|
clientId={ firstBlockClientId }
|
|
279
283
|
/>
|
|
280
284
|
) }
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
285
|
+
{ ! isContentOnlyWriteMode && (
|
|
286
|
+
<CopyMenuItem
|
|
287
|
+
clientIds={ clientIds }
|
|
288
|
+
onCopy={ onCopy }
|
|
289
|
+
shortcut={ shortcuts.copy }
|
|
290
|
+
/>
|
|
291
|
+
) }
|
|
292
|
+
{ ! isContentOnlyWriteMode && (
|
|
293
|
+
<CopyMenuItem
|
|
294
|
+
clientIds={ clientIds }
|
|
295
|
+
label={ __( 'Cut' ) }
|
|
296
|
+
eventType="cut"
|
|
297
|
+
shortcut={ shortcuts.cut }
|
|
298
|
+
__experimentalUpdateSelection={
|
|
299
|
+
! __experimentalSelectBlock
|
|
300
|
+
}
|
|
301
|
+
/>
|
|
302
|
+
) }
|
|
295
303
|
{ canDuplicate && (
|
|
296
304
|
<MenuItem
|
|
297
305
|
onClick={ pipe(
|
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
import { __, sprintf } from '@wordpress/i18n';
|
|
27
27
|
import { withDispatch, withSelect, useSelect } from '@wordpress/data';
|
|
28
28
|
import { withInstanceId, compose } from '@wordpress/compose';
|
|
29
|
-
import {
|
|
29
|
+
import { moreHorizontal } from '@wordpress/icons';
|
|
30
30
|
import { useRef, useState } from '@wordpress/element';
|
|
31
31
|
import { store as noticesStore } from '@wordpress/notices';
|
|
32
32
|
import { store as reusableBlocksStore } from '@wordpress/reusable-blocks';
|
|
@@ -255,7 +255,7 @@ const BlockActionsMenu = ( {
|
|
|
255
255
|
<ToolbarGroup>
|
|
256
256
|
<ToolbarButton
|
|
257
257
|
title={ __( 'Open Block Actions Menu' ) }
|
|
258
|
-
icon={
|
|
258
|
+
icon={ moreHorizontal }
|
|
259
259
|
disabled
|
|
260
260
|
/>
|
|
261
261
|
</ToolbarGroup>
|
|
@@ -298,7 +298,7 @@ const BlockActionsMenu = ( {
|
|
|
298
298
|
<ToolbarButton
|
|
299
299
|
title={ __( 'Open Block Actions Menu' ) }
|
|
300
300
|
onClick={ onPickerPresent }
|
|
301
|
-
icon={
|
|
301
|
+
icon={ moreHorizontal }
|
|
302
302
|
extraProps={ {
|
|
303
303
|
hint: accessibilityHint,
|
|
304
304
|
} }
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { __ } from '@wordpress/i18n';
|
|
5
|
+
import {
|
|
6
|
+
cornerAll,
|
|
7
|
+
cornerBottomLeft,
|
|
8
|
+
cornerBottomRight,
|
|
9
|
+
cornerTopLeft,
|
|
10
|
+
cornerTopRight,
|
|
11
|
+
} from '@wordpress/icons';
|
|
12
|
+
|
|
13
|
+
export const DEFAULT_VALUES = {
|
|
14
|
+
topLeft: undefined,
|
|
15
|
+
topRight: undefined,
|
|
16
|
+
bottomLeft: undefined,
|
|
17
|
+
bottomRight: undefined,
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const RANGE_CONTROL_MAX_SIZE = 8;
|
|
21
|
+
|
|
22
|
+
export const EMPTY_ARRAY = [];
|
|
23
|
+
|
|
24
|
+
export const CORNERS = {
|
|
25
|
+
all: __( 'Border radius' ),
|
|
26
|
+
topLeft: __( 'Top left' ),
|
|
27
|
+
topRight: __( 'Top right' ),
|
|
28
|
+
bottomLeft: __( 'Bottom left' ),
|
|
29
|
+
bottomRight: __( 'Bottom right' ),
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export const ICONS = {
|
|
33
|
+
all: cornerAll,
|
|
34
|
+
topLeft: cornerTopLeft,
|
|
35
|
+
topRight: cornerTopRight,
|
|
36
|
+
bottomLeft: cornerBottomLeft,
|
|
37
|
+
bottomRight: cornerBottomRight,
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export const MIN_BORDER_RADIUS_VALUE = 0;
|
|
41
|
+
|
|
42
|
+
export const MAX_BORDER_RADIUS_VALUES = {
|
|
43
|
+
px: 100,
|
|
44
|
+
em: 20,
|
|
45
|
+
rem: 20,
|
|
46
|
+
};
|
|
@@ -3,39 +3,52 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import {
|
|
5
5
|
BaseControl,
|
|
6
|
-
RangeControl,
|
|
7
6
|
__experimentalParseQuantityAndUnitFromRawValue as parseQuantityAndUnitFromRawValue,
|
|
8
7
|
__experimentalUseCustomUnits as useCustomUnits,
|
|
8
|
+
__experimentalVStack as VStack,
|
|
9
|
+
__experimentalHStack as HStack,
|
|
9
10
|
} from '@wordpress/components';
|
|
10
|
-
import { useState } from '@wordpress/element';
|
|
11
|
+
import { useState, useMemo } from '@wordpress/element';
|
|
11
12
|
import { __ } from '@wordpress/i18n';
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* Internal dependencies
|
|
15
16
|
*/
|
|
16
|
-
import AllInputControl from './all-input-control';
|
|
17
|
-
import InputControls from './input-controls';
|
|
18
17
|
import LinkedButton from './linked-button';
|
|
19
18
|
import { useSettings } from '../use-settings';
|
|
19
|
+
import { hasDefinedValues, hasMixedValues } from './utils';
|
|
20
|
+
import SingleInputControl from './single-input-control';
|
|
20
21
|
import {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
} from './utils';
|
|
22
|
+
DEFAULT_VALUES,
|
|
23
|
+
RANGE_CONTROL_MAX_SIZE,
|
|
24
|
+
EMPTY_ARRAY,
|
|
25
|
+
} from './constants';
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
27
|
+
function useBorderRadiusSizes( presets ) {
|
|
28
|
+
const defaultSizes = presets?.default ?? EMPTY_ARRAY;
|
|
29
|
+
const customSizes = presets?.custom ?? EMPTY_ARRAY;
|
|
30
|
+
const themeSizes = presets?.theme ?? EMPTY_ARRAY;
|
|
31
|
+
|
|
32
|
+
return useMemo( () => {
|
|
33
|
+
const sizes = [
|
|
34
|
+
{ name: __( 'None' ), slug: '0', size: 0 },
|
|
35
|
+
...customSizes,
|
|
36
|
+
...themeSizes,
|
|
37
|
+
...defaultSizes,
|
|
38
|
+
];
|
|
39
|
+
|
|
40
|
+
return sizes.length > RANGE_CONTROL_MAX_SIZE
|
|
41
|
+
? [
|
|
42
|
+
{
|
|
43
|
+
name: __( 'Default' ),
|
|
44
|
+
slug: 'default',
|
|
45
|
+
size: undefined,
|
|
46
|
+
},
|
|
47
|
+
...sizes,
|
|
48
|
+
]
|
|
49
|
+
: sizes;
|
|
50
|
+
}, [ customSizes, themeSizes, defaultSizes ] );
|
|
51
|
+
}
|
|
39
52
|
|
|
40
53
|
/**
|
|
41
54
|
* Control to display border radius options.
|
|
@@ -43,14 +56,15 @@ const MAX_BORDER_RADIUS_VALUES = {
|
|
|
43
56
|
* @param {Object} props Component props.
|
|
44
57
|
* @param {Function} props.onChange Callback to handle onChange.
|
|
45
58
|
* @param {Object} props.values Border radius values.
|
|
59
|
+
* @param {Object} props.presets Border radius presets.
|
|
46
60
|
*
|
|
47
61
|
* @return {Element} Custom border radius control.
|
|
48
62
|
*/
|
|
49
|
-
export default function BorderRadiusControl( { onChange, values } ) {
|
|
63
|
+
export default function BorderRadiusControl( { onChange, values, presets } ) {
|
|
50
64
|
const [ isLinked, setIsLinked ] = useState(
|
|
51
65
|
! hasDefinedValues( values ) || ! hasMixedValues( values )
|
|
52
66
|
);
|
|
53
|
-
|
|
67
|
+
const options = useBorderRadiusSizes( presets );
|
|
54
68
|
// Tracking selected units via internal state allows filtering of CSS unit
|
|
55
69
|
// only values from being saved while maintaining preexisting unit selection
|
|
56
70
|
// behaviour. Filtering CSS unit only values prevents invalid style values.
|
|
@@ -72,64 +86,49 @@ export default function BorderRadiusControl( { onChange, values } ) {
|
|
|
72
86
|
availableUnits: availableUnits || [ 'px', 'em', 'rem' ],
|
|
73
87
|
} );
|
|
74
88
|
|
|
75
|
-
const unit = getAllUnit( selectedUnits );
|
|
76
|
-
const unitConfig = units && units.find( ( item ) => item.value === unit );
|
|
77
|
-
const step = unitConfig?.step || 1;
|
|
78
|
-
|
|
79
|
-
const [ allValue ] = parseQuantityAndUnitFromRawValue(
|
|
80
|
-
getAllValue( values )
|
|
81
|
-
);
|
|
82
|
-
|
|
83
89
|
const toggleLinked = () => setIsLinked( ! isLinked );
|
|
84
90
|
|
|
85
|
-
const handleSliderChange = ( next ) => {
|
|
86
|
-
onChange( next !== undefined ? `${ next }${ unit }` : undefined );
|
|
87
|
-
};
|
|
88
|
-
|
|
89
91
|
return (
|
|
90
92
|
<fieldset className="components-border-radius-control">
|
|
91
|
-
<
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
{ isLinked
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
min={ MIN_BORDER_RADIUS_VALUE }
|
|
101
|
-
onChange={ onChange }
|
|
102
|
-
selectedUnits={ selectedUnits }
|
|
103
|
-
setSelectedUnits={ setSelectedUnits }
|
|
104
|
-
units={ units }
|
|
105
|
-
/>
|
|
106
|
-
<RangeControl
|
|
107
|
-
__next40pxDefaultSize
|
|
108
|
-
label={ __( 'Border radius' ) }
|
|
109
|
-
hideLabelFromVision
|
|
110
|
-
className="components-border-radius-control__range-control"
|
|
111
|
-
value={ allValue ?? '' }
|
|
112
|
-
min={ MIN_BORDER_RADIUS_VALUE }
|
|
113
|
-
max={ MAX_BORDER_RADIUS_VALUES[ unit ] }
|
|
114
|
-
initialPosition={ 0 }
|
|
115
|
-
withInputField={ false }
|
|
116
|
-
onChange={ handleSliderChange }
|
|
117
|
-
step={ step }
|
|
118
|
-
__nextHasNoMarginBottom
|
|
119
|
-
/>
|
|
120
|
-
</>
|
|
121
|
-
) : (
|
|
122
|
-
<InputControls
|
|
123
|
-
min={ MIN_BORDER_RADIUS_VALUE }
|
|
93
|
+
<HStack className="components-border-radius-control__header">
|
|
94
|
+
<BaseControl.VisualLabel as="legend">
|
|
95
|
+
{ __( 'Radius' ) }
|
|
96
|
+
</BaseControl.VisualLabel>
|
|
97
|
+
<LinkedButton onClick={ toggleLinked } isLinked={ isLinked } />
|
|
98
|
+
</HStack>
|
|
99
|
+
{ isLinked ? (
|
|
100
|
+
<>
|
|
101
|
+
<SingleInputControl
|
|
124
102
|
onChange={ onChange }
|
|
125
103
|
selectedUnits={ selectedUnits }
|
|
126
104
|
setSelectedUnits={ setSelectedUnits }
|
|
127
|
-
values={ values
|
|
105
|
+
values={ values }
|
|
128
106
|
units={ units }
|
|
107
|
+
corner="all"
|
|
108
|
+
presets={ options }
|
|
129
109
|
/>
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
110
|
+
</>
|
|
111
|
+
) : (
|
|
112
|
+
<VStack>
|
|
113
|
+
{ [
|
|
114
|
+
'topLeft',
|
|
115
|
+
'topRight',
|
|
116
|
+
'bottomLeft',
|
|
117
|
+
'bottomRight',
|
|
118
|
+
].map( ( corner ) => (
|
|
119
|
+
<SingleInputControl
|
|
120
|
+
key={ corner }
|
|
121
|
+
onChange={ onChange }
|
|
122
|
+
selectedUnits={ selectedUnits }
|
|
123
|
+
setSelectedUnits={ setSelectedUnits }
|
|
124
|
+
values={ values || DEFAULT_VALUES }
|
|
125
|
+
units={ units }
|
|
126
|
+
corner={ corner }
|
|
127
|
+
presets={ options }
|
|
128
|
+
/>
|
|
129
|
+
) ) }
|
|
130
|
+
</VStack>
|
|
131
|
+
) }
|
|
133
132
|
</fieldset>
|
|
134
133
|
);
|
|
135
134
|
}
|
|
@@ -11,7 +11,7 @@ export default function LinkedButton( { isLinked, ...props } ) {
|
|
|
11
11
|
return (
|
|
12
12
|
<Button
|
|
13
13
|
{ ...props }
|
|
14
|
-
className="
|
|
14
|
+
className="components-border-radius-control__linked-button"
|
|
15
15
|
size="small"
|
|
16
16
|
icon={ isLinked ? link : linkOff }
|
|
17
17
|
iconSize={ 24 }
|