@wordpress/block-editor 9.7.0 → 9.7.1-next.d6164808d3.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-alignment-control/use-available-alignments.js +1 -1
- package/build/components/block-alignment-control/use-available-alignments.js.map +1 -1
- package/build/components/block-edit-visually-button/index.js +46 -0
- package/build/components/block-edit-visually-button/index.js.map +1 -0
- package/build/components/block-popover/inbetween.js +4 -2
- package/build/components/block-popover/inbetween.js.map +1 -1
- package/build/components/block-settings-menu/index.js +2 -6
- package/build/components/block-settings-menu/index.js.map +1 -1
- package/build/components/block-switcher/index.js +10 -16
- package/build/components/block-switcher/index.js.map +1 -1
- package/build/components/block-toolbar/index.js +5 -1
- package/build/components/block-toolbar/index.js.map +1 -1
- package/build/components/border-radius-control/all-input-control.js +31 -3
- package/build/components/border-radius-control/all-input-control.js.map +1 -1
- package/build/components/border-radius-control/index.js +20 -6
- package/build/components/border-radius-control/index.js.map +1 -1
- package/build/components/border-radius-control/input-controls.js +21 -6
- package/build/components/border-radius-control/input-controls.js.map +1 -1
- package/build/components/border-radius-control/utils.js +13 -16
- package/build/components/border-radius-control/utils.js.map +1 -1
- package/build/components/colors/with-colors.js +17 -4
- package/build/components/colors/with-colors.js.map +1 -1
- package/build/components/copy-handler/index.js +6 -0
- package/build/components/copy-handler/index.js.map +1 -1
- package/build/components/date-format-picker/index.js +2 -7
- package/build/components/date-format-picker/index.js.map +1 -1
- package/build/components/duotone/components.js +5 -5
- package/build/components/duotone/components.js.map +1 -1
- package/build/components/font-family/index.js +1 -1
- package/build/components/font-family/index.js.map +1 -1
- package/build/components/font-sizes/with-font-sizes.js +17 -4
- package/build/components/font-sizes/with-font-sizes.js.map +1 -1
- package/build/components/index.js +9 -0
- package/build/components/index.js.map +1 -1
- package/build/components/inserter/search-items.js +22 -4
- package/build/components/inserter/search-items.js.map +1 -1
- package/build/components/link-control/link-preview.js +0 -1
- package/build/components/link-control/link-preview.js.map +1 -1
- package/build/components/list-view/block-select-button.js +5 -2
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/list-view/use-block-selection.js +1 -7
- package/build/components/list-view/use-block-selection.js.map +1 -1
- package/build/components/rich-text/use-enter.js +0 -4
- package/build/components/rich-text/use-enter.js.map +1 -1
- package/build/components/rich-text/use-format-types.js +8 -11
- package/build/components/rich-text/use-format-types.js.map +1 -1
- package/build/components/spacing-sizes-control/all-input-control.js +53 -0
- package/build/components/spacing-sizes-control/all-input-control.js.map +1 -0
- package/build/components/spacing-sizes-control/axial-input-controls.js +69 -0
- package/build/components/spacing-sizes-control/axial-input-controls.js.map +1 -0
- package/build/components/spacing-sizes-control/index.js +100 -0
- package/build/components/spacing-sizes-control/index.js.map +1 -0
- package/build/components/spacing-sizes-control/input-controls.js +52 -0
- package/build/components/spacing-sizes-control/input-controls.js.map +1 -0
- package/build/components/spacing-sizes-control/linked-button.js +38 -0
- package/build/components/spacing-sizes-control/linked-button.js.map +1 -0
- package/build/components/spacing-sizes-control/spacing-input-control.js +208 -0
- package/build/components/spacing-sizes-control/spacing-input-control.js.map +1 -0
- package/build/components/spacing-sizes-control/utils.js +202 -0
- package/build/components/spacing-sizes-control/utils.js.map +1 -0
- package/build/components/url-input/index.js +1 -1
- package/build/components/url-input/index.js.map +1 -1
- package/build/components/writing-flow/use-multi-selection.js +4 -2
- package/build/components/writing-flow/use-multi-selection.js.map +1 -1
- package/build/components/writing-flow/use-selection-observer.js +10 -2
- package/build/components/writing-flow/use-selection-observer.js.map +1 -1
- package/build/hooks/border-radius.js +2 -7
- package/build/hooks/border-radius.js.map +1 -1
- package/build/hooks/border.js +2 -2
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/color.js +4 -1
- package/build/hooks/color.js.map +1 -1
- package/build/hooks/dimensions.js +15 -0
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/duotone.js +4 -4
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/gap.js +6 -4
- package/build/hooks/gap.js.map +1 -1
- package/build/hooks/generated-class-name.js +1 -7
- package/build/hooks/generated-class-name.js.map +1 -1
- package/build/hooks/layout.js +20 -12
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/margin.js +28 -12
- package/build/hooks/margin.js.map +1 -1
- package/build/hooks/padding.js +19 -8
- package/build/hooks/padding.js.map +1 -1
- package/build/hooks/style.js +4 -50
- package/build/hooks/style.js.map +1 -1
- package/build/layouts/constrained.js +215 -0
- package/build/layouts/constrained.js.map +1 -0
- package/build/layouts/flex.js +1 -1
- package/build/layouts/flex.js.map +1 -1
- package/build/layouts/flow.js +7 -169
- package/build/layouts/flow.js.map +1 -1
- package/build/layouts/index.js +3 -1
- package/build/layouts/index.js.map +1 -1
- package/build/layouts/utils.js +43 -0
- package/build/layouts/utils.js.map +1 -1
- package/build/store/actions.js +25 -3
- package/build/store/actions.js.map +1 -1
- package/build/store/selectors.js +4 -6
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/block-alignment-control/use-available-alignments.js +1 -1
- package/build-module/components/block-alignment-control/use-available-alignments.js.map +1 -1
- package/build-module/components/block-edit-visually-button/index.js +35 -0
- package/build-module/components/block-edit-visually-button/index.js.map +1 -0
- package/build-module/components/block-popover/inbetween.js +4 -2
- package/build-module/components/block-popover/inbetween.js.map +1 -1
- package/build-module/components/block-settings-menu/index.js +3 -6
- package/build-module/components/block-settings-menu/index.js.map +1 -1
- package/build-module/components/block-switcher/index.js +10 -16
- package/build-module/components/block-switcher/index.js.map +1 -1
- package/build-module/components/block-toolbar/index.js +4 -1
- package/build-module/components/block-toolbar/index.js.map +1 -1
- package/build-module/components/border-radius-control/all-input-control.js +32 -4
- package/build-module/components/border-radius-control/all-input-control.js.map +1 -1
- package/build-module/components/border-radius-control/index.js +20 -6
- package/build-module/components/border-radius-control/index.js.map +1 -1
- package/build-module/components/border-radius-control/input-controls.js +22 -7
- package/build-module/components/border-radius-control/input-controls.js.map +1 -1
- package/build-module/components/border-radius-control/utils.js +13 -16
- package/build-module/components/border-radius-control/utils.js.map +1 -1
- package/build-module/components/colors/with-colors.js +16 -3
- package/build-module/components/colors/with-colors.js.map +1 -1
- package/build-module/components/copy-handler/index.js +7 -1
- package/build-module/components/copy-handler/index.js.map +1 -1
- package/build-module/components/date-format-picker/index.js +2 -6
- package/build-module/components/date-format-picker/index.js.map +1 -1
- package/build-module/components/duotone/components.js +5 -5
- package/build-module/components/duotone/components.js.map +1 -1
- package/build-module/components/font-family/index.js +1 -1
- package/build-module/components/font-family/index.js.map +1 -1
- package/build-module/components/font-sizes/with-font-sizes.js +16 -3
- package/build-module/components/font-sizes/with-font-sizes.js.map +1 -1
- package/build-module/components/index.js +1 -0
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/inserter/search-items.js +19 -5
- package/build-module/components/inserter/search-items.js.map +1 -1
- package/build-module/components/link-control/link-preview.js +0 -1
- package/build-module/components/link-control/link-preview.js.map +1 -1
- package/build-module/components/list-view/block-select-button.js +5 -2
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/list-view/use-block-selection.js +1 -6
- package/build-module/components/list-view/use-block-selection.js.map +1 -1
- package/build-module/components/rich-text/use-enter.js +0 -4
- package/build-module/components/rich-text/use-enter.js.map +1 -1
- package/build-module/components/rich-text/use-format-types.js +8 -10
- package/build-module/components/rich-text/use-format-types.js.map +1 -1
- package/build-module/components/spacing-sizes-control/all-input-control.js +41 -0
- package/build-module/components/spacing-sizes-control/all-input-control.js.map +1 -0
- package/build-module/components/spacing-sizes-control/axial-input-controls.js +57 -0
- package/build-module/components/spacing-sizes-control/axial-input-controls.js.map +1 -0
- package/build-module/components/spacing-sizes-control/index.js +83 -0
- package/build-module/components/spacing-sizes-control/index.js.map +1 -0
- package/build-module/components/spacing-sizes-control/input-controls.js +41 -0
- package/build-module/components/spacing-sizes-control/input-controls.js.map +1 -0
- package/build-module/components/spacing-sizes-control/linked-button.js +28 -0
- package/build-module/components/spacing-sizes-control/linked-button.js.map +1 -0
- package/build-module/components/spacing-sizes-control/spacing-input-control.js +192 -0
- package/build-module/components/spacing-sizes-control/spacing-input-control.js.map +1 -0
- package/build-module/components/spacing-sizes-control/utils.js +174 -0
- package/build-module/components/spacing-sizes-control/utils.js.map +1 -0
- package/build-module/components/url-input/index.js +1 -1
- package/build-module/components/url-input/index.js.map +1 -1
- package/build-module/components/writing-flow/use-multi-selection.js +4 -2
- package/build-module/components/writing-flow/use-multi-selection.js.map +1 -1
- package/build-module/components/writing-flow/use-selection-observer.js +10 -2
- package/build-module/components/writing-flow/use-selection-observer.js.map +1 -1
- package/build-module/hooks/border-radius.js +2 -7
- package/build-module/hooks/border-radius.js.map +1 -1
- package/build-module/hooks/border.js +2 -2
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/color.js +4 -1
- package/build-module/hooks/color.js.map +1 -1
- package/build-module/hooks/dimensions.js +13 -0
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/duotone.js +4 -4
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/gap.js +3 -2
- package/build-module/hooks/gap.js.map +1 -1
- package/build-module/hooks/generated-class-name.js +1 -6
- package/build-module/hooks/generated-class-name.js.map +1 -1
- package/build-module/hooks/layout.js +20 -12
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/margin.js +26 -12
- package/build-module/hooks/margin.js.map +1 -1
- package/build-module/hooks/padding.js +17 -8
- package/build-module/hooks/padding.js.map +1 -1
- package/build-module/hooks/style.js +7 -53
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/layouts/constrained.js +197 -0
- package/build-module/layouts/constrained.js.map +1 -0
- package/build-module/layouts/flex.js +1 -1
- package/build-module/layouts/flex.js.map +1 -1
- package/build-module/layouts/flow.js +8 -163
- package/build-module/layouts/flow.js.map +1 -1
- package/build-module/layouts/index.js +2 -1
- package/build-module/layouts/index.js.map +1 -1
- package/build-module/layouts/utils.js +40 -0
- package/build-module/layouts/utils.js.map +1 -1
- package/build-module/store/actions.js +25 -3
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/selectors.js +5 -7
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +115 -20
- package/build-style/style.css +115 -20
- package/package.json +30 -28
- package/src/components/block-alignment-control/use-available-alignments.js +1 -1
- package/src/components/block-edit-visually-button/index.js +39 -0
- package/src/components/block-popover/inbetween.js +4 -1
- package/src/components/block-settings-menu/index.js +11 -15
- package/src/components/block-switcher/index.js +9 -13
- package/src/components/block-switcher/test/index.js +1 -0
- package/src/components/block-toolbar/index.js +2 -0
- package/src/components/border-radius-control/all-input-control.js +41 -4
- package/src/components/border-radius-control/index.js +25 -5
- package/src/components/border-radius-control/input-controls.js +40 -13
- package/src/components/border-radius-control/test/utils.js +22 -60
- package/src/components/border-radius-control/utils.js +12 -16
- package/src/components/colors/with-colors.js +11 -1
- package/src/components/copy-handler/index.js +18 -0
- package/src/components/date-format-picker/index.js +12 -14
- package/src/components/date-format-picker/style.scss +0 -4
- package/src/components/duotone/components.js +5 -5
- package/src/components/duotone-control/style.scss +0 -4
- package/src/components/font-appearance-control/style.scss +0 -2
- package/src/components/font-family/index.js +1 -1
- package/src/components/font-sizes/with-font-sizes.js +11 -1
- package/src/components/index.js +1 -0
- package/src/components/inserter/search-items.js +17 -5
- package/src/components/link-control/link-preview.js +0 -1
- package/src/components/link-control/test/index.js +540 -893
- package/src/components/list-view/block-select-button.js +7 -2
- package/src/components/list-view/style.scss +11 -4
- package/src/components/list-view/use-block-selection.js +2 -8
- package/src/components/media-replace-flow/style.scss +1 -0
- package/src/components/rich-text/use-enter.js +0 -3
- package/src/components/rich-text/use-format-types.js +6 -6
- package/src/components/spacing-sizes-control/all-input-control.js +40 -0
- package/src/components/spacing-sizes-control/axial-input-controls.js +62 -0
- package/src/components/spacing-sizes-control/index.js +91 -0
- package/src/components/spacing-sizes-control/input-controls.js +46 -0
- package/src/components/spacing-sizes-control/linked-button.js +25 -0
- package/src/components/spacing-sizes-control/spacing-input-control.js +280 -0
- package/src/components/spacing-sizes-control/style.scss +122 -0
- package/src/components/spacing-sizes-control/test/utils.js +156 -0
- package/src/components/spacing-sizes-control/utils.js +195 -0
- package/src/components/url-input/index.js +1 -1
- package/src/components/url-input/style.scss +2 -2
- package/src/components/url-popover/style.scss +0 -3
- package/src/components/writing-flow/use-multi-selection.js +4 -1
- package/src/components/writing-flow/use-selection-observer.js +10 -2
- package/src/hooks/border-radius.js +2 -6
- package/src/hooks/border.js +2 -2
- package/src/hooks/color.js +13 -3
- package/src/hooks/dimensions.js +15 -0
- package/src/hooks/duotone.js +4 -4
- package/src/hooks/gap.js +7 -2
- package/src/hooks/generated-class-name.js +6 -9
- package/src/hooks/layout.js +45 -14
- package/src/hooks/margin.js +49 -17
- package/src/hooks/padding.js +41 -14
- package/src/hooks/style.js +5 -56
- package/src/hooks/test/gap.js +22 -0
- package/src/hooks/typography.scss +0 -1
- package/src/layouts/constrained.js +217 -0
- package/src/layouts/flex.js +1 -1
- package/src/layouts/flow.js +6 -173
- package/src/layouts/index.js +2 -1
- package/src/layouts/test/constrained.js +21 -0
- package/src/layouts/utils.js +34 -0
- package/src/store/actions.js +32 -4
- package/src/store/selectors.js +5 -4
- package/src/style.scss +1 -0
- package/build/components/block-settings-menu/block-edit-visually-button.js +0 -70
- package/build/components/block-settings-menu/block-edit-visually-button.js.map +0 -1
- package/build-module/components/block-settings-menu/block-edit-visually-button.js +0 -56
- package/build-module/components/block-settings-menu/block-edit-visually-button.js.map +0 -1
- package/src/components/block-settings-menu/block-edit-visually-button.js +0 -52
|
@@ -7,14 +7,50 @@ import { __ } from '@wordpress/i18n';
|
|
|
7
7
|
/**
|
|
8
8
|
* Internal dependencies
|
|
9
9
|
*/
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
getAllValue,
|
|
12
|
+
getAllUnit,
|
|
13
|
+
hasMixedValues,
|
|
14
|
+
hasDefinedValues,
|
|
15
|
+
} from './utils';
|
|
16
|
+
|
|
17
|
+
export default function AllInputControl( {
|
|
18
|
+
onChange,
|
|
19
|
+
selectedUnits,
|
|
20
|
+
setSelectedUnits,
|
|
21
|
+
values,
|
|
22
|
+
...props
|
|
23
|
+
} ) {
|
|
24
|
+
let allValue = getAllValue( values );
|
|
25
|
+
|
|
26
|
+
if ( allValue === undefined ) {
|
|
27
|
+
// If we don't have any value set the unit to any current selection
|
|
28
|
+
// or the most common unit from the individual radii values.
|
|
29
|
+
allValue = getAllUnit( selectedUnits );
|
|
30
|
+
}
|
|
11
31
|
|
|
12
|
-
export default function AllInputControl( { onChange, values, ...props } ) {
|
|
13
|
-
const allValue = getAllValue( values );
|
|
14
32
|
const hasValues = hasDefinedValues( values );
|
|
15
33
|
const isMixed = hasValues && hasMixedValues( values );
|
|
16
34
|
const allPlaceholder = isMixed ? __( 'Mixed' ) : null;
|
|
17
35
|
|
|
36
|
+
// Filter out CSS-unit-only values to prevent invalid styles.
|
|
37
|
+
const handleOnChange = ( next ) => {
|
|
38
|
+
const isNumeric = ! isNaN( parseFloat( next ) );
|
|
39
|
+
const nextValue = isNumeric ? next : undefined;
|
|
40
|
+
onChange( nextValue );
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
// Store current unit selection for use as fallback for individual
|
|
44
|
+
// radii controls.
|
|
45
|
+
const handleOnUnitChange = ( unit ) => {
|
|
46
|
+
setSelectedUnits( {
|
|
47
|
+
topLeft: unit,
|
|
48
|
+
topRight: unit,
|
|
49
|
+
bottomLeft: unit,
|
|
50
|
+
bottomRight: unit,
|
|
51
|
+
} );
|
|
52
|
+
};
|
|
53
|
+
|
|
18
54
|
return (
|
|
19
55
|
<UnitControl
|
|
20
56
|
{ ...props }
|
|
@@ -22,7 +58,8 @@ export default function AllInputControl( { onChange, values, ...props } ) {
|
|
|
22
58
|
disableUnits={ isMixed }
|
|
23
59
|
isOnly
|
|
24
60
|
value={ allValue }
|
|
25
|
-
onChange={
|
|
61
|
+
onChange={ handleOnChange }
|
|
62
|
+
onUnitChange={ handleOnUnitChange }
|
|
26
63
|
placeholder={ allPlaceholder }
|
|
27
64
|
/>
|
|
28
65
|
);
|
|
@@ -25,10 +25,10 @@ import {
|
|
|
25
25
|
} from './utils';
|
|
26
26
|
|
|
27
27
|
const DEFAULT_VALUES = {
|
|
28
|
-
topLeft:
|
|
29
|
-
topRight:
|
|
30
|
-
bottomLeft:
|
|
31
|
-
bottomRight:
|
|
28
|
+
topLeft: undefined,
|
|
29
|
+
topRight: undefined,
|
|
30
|
+
bottomLeft: undefined,
|
|
31
|
+
bottomRight: undefined,
|
|
32
32
|
};
|
|
33
33
|
const MIN_BORDER_RADIUS_VALUE = 0;
|
|
34
34
|
const MAX_BORDER_RADIUS_VALUES = {
|
|
@@ -51,11 +51,27 @@ export default function BorderRadiusControl( { onChange, values } ) {
|
|
|
51
51
|
! hasDefinedValues( values ) || ! hasMixedValues( values )
|
|
52
52
|
);
|
|
53
53
|
|
|
54
|
+
// Tracking selected units via internal state allows filtering of CSS unit
|
|
55
|
+
// only values from being saved while maintaining preexisting unit selection
|
|
56
|
+
// behaviour. Filtering CSS unit only values prevents invalid style values.
|
|
57
|
+
const [ selectedUnits, setSelectedUnits ] = useState( {
|
|
58
|
+
flat:
|
|
59
|
+
typeof values === 'string'
|
|
60
|
+
? parseQuantityAndUnitFromRawValue( values )[ 1 ]
|
|
61
|
+
: undefined,
|
|
62
|
+
topLeft: parseQuantityAndUnitFromRawValue( values?.topLeft )[ 1 ],
|
|
63
|
+
topRight: parseQuantityAndUnitFromRawValue( values?.topRight )[ 1 ],
|
|
64
|
+
bottomLeft: parseQuantityAndUnitFromRawValue( values?.bottomLeft )[ 1 ],
|
|
65
|
+
bottomRight: parseQuantityAndUnitFromRawValue(
|
|
66
|
+
values?.bottomRight
|
|
67
|
+
)[ 1 ],
|
|
68
|
+
} );
|
|
69
|
+
|
|
54
70
|
const units = useCustomUnits( {
|
|
55
71
|
availableUnits: useSetting( 'spacing.units' ) || [ 'px', 'em', 'rem' ],
|
|
56
72
|
} );
|
|
57
73
|
|
|
58
|
-
const unit = getAllUnit(
|
|
74
|
+
const unit = getAllUnit( selectedUnits );
|
|
59
75
|
const unitConfig = units && units.find( ( item ) => item.value === unit );
|
|
60
76
|
const step = unitConfig?.step || 1;
|
|
61
77
|
|
|
@@ -82,6 +98,8 @@ export default function BorderRadiusControl( { onChange, values } ) {
|
|
|
82
98
|
values={ values }
|
|
83
99
|
min={ MIN_BORDER_RADIUS_VALUE }
|
|
84
100
|
onChange={ onChange }
|
|
101
|
+
selectedUnits={ selectedUnits }
|
|
102
|
+
setSelectedUnits={ setSelectedUnits }
|
|
85
103
|
units={ units }
|
|
86
104
|
/>
|
|
87
105
|
<RangeControl
|
|
@@ -101,6 +119,8 @@ export default function BorderRadiusControl( { onChange, values } ) {
|
|
|
101
119
|
<InputControls
|
|
102
120
|
min={ MIN_BORDER_RADIUS_VALUE }
|
|
103
121
|
onChange={ onChange }
|
|
122
|
+
selectedUnits={ selectedUnits }
|
|
123
|
+
setSelectedUnits={ setSelectedUnits }
|
|
104
124
|
values={ values || DEFAULT_VALUES }
|
|
105
125
|
units={ units }
|
|
106
126
|
/>
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import {
|
|
5
|
+
__experimentalParseQuantityAndUnitFromRawValue as parseQuantityAndUnitFromRawValue,
|
|
5
6
|
__experimentalUnitControl as UnitControl,
|
|
6
7
|
Tooltip,
|
|
7
8
|
} from '@wordpress/components';
|
|
@@ -16,6 +17,8 @@ const CORNERS = {
|
|
|
16
17
|
|
|
17
18
|
export default function BoxInputControls( {
|
|
18
19
|
onChange,
|
|
20
|
+
selectedUnits,
|
|
21
|
+
setSelectedUnits,
|
|
19
22
|
values: valuesProp,
|
|
20
23
|
...props
|
|
21
24
|
} ) {
|
|
@@ -24,12 +27,22 @@ export default function BoxInputControls( {
|
|
|
24
27
|
return;
|
|
25
28
|
}
|
|
26
29
|
|
|
30
|
+
// Filter out CSS-unit-only values to prevent invalid styles.
|
|
31
|
+
const isNumeric = ! isNaN( parseFloat( next ) );
|
|
32
|
+
const nextValue = isNumeric ? next : undefined;
|
|
33
|
+
|
|
27
34
|
onChange( {
|
|
28
35
|
...values,
|
|
29
|
-
[ corner ]:
|
|
36
|
+
[ corner ]: nextValue,
|
|
30
37
|
} );
|
|
31
38
|
};
|
|
32
39
|
|
|
40
|
+
const createHandleOnUnitChange = ( side ) => ( next ) => {
|
|
41
|
+
const newUnits = { ...selectedUnits };
|
|
42
|
+
newUnits[ side ] = next;
|
|
43
|
+
setSelectedUnits( newUnits );
|
|
44
|
+
};
|
|
45
|
+
|
|
33
46
|
// For shorthand style & backwards compatibility, handle flat string value.
|
|
34
47
|
const values =
|
|
35
48
|
typeof valuesProp !== 'string'
|
|
@@ -46,18 +59,32 @@ export default function BoxInputControls( {
|
|
|
46
59
|
// https://github.com/WordPress/gutenberg/pull/24966#issuecomment-685875026
|
|
47
60
|
return (
|
|
48
61
|
<div className="components-border-radius-control__input-controls-wrapper">
|
|
49
|
-
{ Object.entries( CORNERS ).map( ( [
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
62
|
+
{ Object.entries( CORNERS ).map( ( [ corner, label ] ) => {
|
|
63
|
+
const [ parsedQuantity, parsedUnit ] =
|
|
64
|
+
parseQuantityAndUnitFromRawValue( values[ corner ] );
|
|
65
|
+
|
|
66
|
+
const computedUnit = values[ corner ]
|
|
67
|
+
? parsedUnit
|
|
68
|
+
: selectedUnits[ corner ] || selectedUnits.flat;
|
|
69
|
+
|
|
70
|
+
return (
|
|
71
|
+
<Tooltip text={ label } position="top" key={ corner }>
|
|
72
|
+
<div className="components-border-radius-control__tooltip-wrapper">
|
|
73
|
+
<UnitControl
|
|
74
|
+
{ ...props }
|
|
75
|
+
aria-label={ label }
|
|
76
|
+
value={ [ parsedQuantity, computedUnit ].join(
|
|
77
|
+
''
|
|
78
|
+
) }
|
|
79
|
+
onChange={ createHandleOnChange( corner ) }
|
|
80
|
+
onUnitChange={ createHandleOnUnitChange(
|
|
81
|
+
corner
|
|
82
|
+
) }
|
|
83
|
+
/>
|
|
84
|
+
</div>
|
|
85
|
+
</Tooltip>
|
|
86
|
+
);
|
|
87
|
+
} ) }
|
|
61
88
|
</div>
|
|
62
89
|
);
|
|
63
90
|
}
|
|
@@ -9,73 +9,35 @@ import {
|
|
|
9
9
|
mode,
|
|
10
10
|
} from '../utils';
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
expect( getAllUnit( '32apples' ) ).toBe( 'px' );
|
|
20
|
-
} );
|
|
12
|
+
const defaultUnitSelections = {
|
|
13
|
+
flat: undefined,
|
|
14
|
+
topLeft: '%',
|
|
15
|
+
topRight: 'rem',
|
|
16
|
+
bottomLeft: 'rem',
|
|
17
|
+
bottomRight: 'vw',
|
|
18
|
+
};
|
|
21
19
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
20
|
+
describe( 'getAllUnit', () => {
|
|
21
|
+
it( 'should return flat radius unit when selected', () => {
|
|
22
|
+
const selectedUnits = { ...defaultUnitSelections, flat: 'em' };
|
|
23
|
+
expect( getAllUnit( selectedUnits ) ).toBe( 'em' );
|
|
25
24
|
} );
|
|
26
25
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
bottomLeft: '2em',
|
|
31
|
-
bottomRight: '2em',
|
|
32
|
-
topLeft: '0',
|
|
33
|
-
topRight: '2px',
|
|
34
|
-
};
|
|
35
|
-
expect( getAllUnit( values ) ).toBe( 'em' );
|
|
36
|
-
} );
|
|
37
|
-
|
|
38
|
-
it( 'should return the real value when the most common value is undefined', () => {
|
|
39
|
-
const values = {
|
|
40
|
-
bottomLeft: '0',
|
|
41
|
-
bottomRight: '0',
|
|
42
|
-
topLeft: '0',
|
|
43
|
-
topRight: '2em',
|
|
44
|
-
};
|
|
45
|
-
expect( getAllUnit( values ) ).toBe( 'em' );
|
|
46
|
-
} );
|
|
26
|
+
it( 'should return most common corner unit', () => {
|
|
27
|
+
expect( getAllUnit( defaultUnitSelections ) ).toBe( 'rem' );
|
|
28
|
+
} );
|
|
47
29
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
bottomRight: '1em',
|
|
52
|
-
topLeft: '2px',
|
|
53
|
-
topRight: '2em',
|
|
54
|
-
};
|
|
55
|
-
expect( getAllUnit( values ) ).toBe( 'em' );
|
|
56
|
-
} );
|
|
30
|
+
it( 'should return a real unit when the most common is undefined', () => {
|
|
31
|
+
expect( getAllUnit( { bottomRight: '%' } ) ).toBe( '%' );
|
|
32
|
+
} );
|
|
57
33
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
bottomRight: undefined,
|
|
62
|
-
topLeft: undefined,
|
|
63
|
-
topRight: '0',
|
|
64
|
-
};
|
|
65
|
-
expect( getAllUnit( values ) ).toBe( 'px' );
|
|
66
|
-
} );
|
|
34
|
+
it( 'should return most common corner unit when some are unselected', () => {
|
|
35
|
+
const selectedUnits = { ...defaultUnitSelections, topLeft: undefined };
|
|
36
|
+
expect( getAllUnit( selectedUnits ) ).toBe( 'rem' );
|
|
67
37
|
} );
|
|
68
38
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
expect( getAllUnit( [] ) ).toBe( 'px' );
|
|
72
|
-
} );
|
|
73
|
-
it( 'should return px when passed a boolean', () => {
|
|
74
|
-
expect( getAllUnit( false ) ).toBe( 'px' );
|
|
75
|
-
} );
|
|
76
|
-
it( 'should return px when passed undefined', () => {
|
|
77
|
-
expect( getAllUnit( false ) ).toBe( 'px' );
|
|
78
|
-
} );
|
|
39
|
+
it( 'should fallback to px when all values are undefined', () => {
|
|
40
|
+
expect( getAllUnit( {} ) ).toBe( 'px' );
|
|
79
41
|
} );
|
|
80
42
|
} );
|
|
81
43
|
|
|
@@ -28,24 +28,20 @@ export function mode( inputArray ) {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
|
-
* Returns the most common CSS unit
|
|
32
|
-
* Falls back to `px` as a default unit.
|
|
31
|
+
* Returns the most common CSS unit from the current CSS unit selections.
|
|
33
32
|
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
33
|
+
* - If a single flat border radius is set, its unit will be used
|
|
34
|
+
* - If individual corner selections, the most common of those will be used
|
|
35
|
+
* - Failing any unit selections a default of 'px' is returned.
|
|
36
|
+
*
|
|
37
|
+
* @param {Object} selectedUnits Unit selections for flat radius & each corner.
|
|
38
|
+
* @return {string} Most common CSS unit from current selections. Default: `px`.
|
|
36
39
|
*/
|
|
37
|
-
export function getAllUnit(
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
const allUnits = Object.values( values ).map( ( value ) => {
|
|
44
|
-
const [ , unit ] = parseQuantityAndUnitFromRawValue( value );
|
|
45
|
-
return unit;
|
|
46
|
-
} );
|
|
47
|
-
|
|
48
|
-
return mode( allUnits ) || 'px';
|
|
40
|
+
export function getAllUnit( selectedUnits = {} ) {
|
|
41
|
+
const { flat, ...cornerUnits } = selectedUnits;
|
|
42
|
+
return (
|
|
43
|
+
flat || mode( Object.values( cornerUnits ).filter( Boolean ) ) || 'px'
|
|
44
|
+
);
|
|
49
45
|
}
|
|
50
46
|
|
|
51
47
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { kebabCase, reduce
|
|
4
|
+
import { kebabCase, reduce } from 'lodash';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
@@ -20,6 +20,16 @@ import {
|
|
|
20
20
|
} from './utils';
|
|
21
21
|
import useSetting from '../use-setting';
|
|
22
22
|
|
|
23
|
+
/**
|
|
24
|
+
* Capitalizes the first letter in a string.
|
|
25
|
+
*
|
|
26
|
+
* @param {string} str The string whose first letter the function will capitalize.
|
|
27
|
+
*
|
|
28
|
+
* @return {string} Capitalized string.
|
|
29
|
+
*/
|
|
30
|
+
const upperFirst = ( [ firstLetter, ...rest ] ) =>
|
|
31
|
+
firstLetter.toUpperCase() + rest.join( '' );
|
|
32
|
+
|
|
23
33
|
/**
|
|
24
34
|
* Higher order component factory for injecting the `colorsArray` argument as
|
|
25
35
|
* the colors prop in the `withCustomColors` HOC.
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
serialize,
|
|
7
7
|
pasteHandler,
|
|
8
8
|
store as blocksStore,
|
|
9
|
+
createBlock,
|
|
9
10
|
} from '@wordpress/blocks';
|
|
10
11
|
import {
|
|
11
12
|
documentHasSelection,
|
|
@@ -155,6 +156,23 @@ export function useClipboardHandler() {
|
|
|
155
156
|
);
|
|
156
157
|
blocks = [ head, ...inBetweenBlocks, tail ];
|
|
157
158
|
}
|
|
159
|
+
|
|
160
|
+
const wrapperBlockName = event.clipboardData.getData(
|
|
161
|
+
'__unstableWrapperBlockName'
|
|
162
|
+
);
|
|
163
|
+
|
|
164
|
+
if ( wrapperBlockName ) {
|
|
165
|
+
blocks = createBlock(
|
|
166
|
+
wrapperBlockName,
|
|
167
|
+
JSON.parse(
|
|
168
|
+
event.clipboardData.getData(
|
|
169
|
+
'__unstableWrapperBlockAttributes'
|
|
170
|
+
)
|
|
171
|
+
),
|
|
172
|
+
blocks
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
|
|
158
176
|
const serialized = serialize( blocks );
|
|
159
177
|
|
|
160
178
|
event.clipboardData.setData(
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { uniq } from 'lodash';
|
|
5
|
-
|
|
6
1
|
/**
|
|
7
2
|
* WordPress dependencies
|
|
8
3
|
*/
|
|
@@ -83,15 +78,17 @@ function NonDefaultControls( { format, onChange } ) {
|
|
|
83
78
|
// 2022) in German (de). The resultant array is de-duplicated as some
|
|
84
79
|
// languages will use the same format string for short, medium, and long
|
|
85
80
|
// formats.
|
|
86
|
-
const suggestedFormats =
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
81
|
+
const suggestedFormats = [
|
|
82
|
+
...new Set( [
|
|
83
|
+
'Y-m-d',
|
|
84
|
+
_x( 'n/j/Y', 'short date format' ),
|
|
85
|
+
_x( 'n/j/Y g:i A', 'short date format with time' ),
|
|
86
|
+
_x( 'M j, Y', 'medium date format' ),
|
|
87
|
+
_x( 'M j, Y g:i A', 'medium date format with time' ),
|
|
88
|
+
_x( 'F j, Y', 'long date format' ),
|
|
89
|
+
_x( 'M j', 'short date format without the year' ),
|
|
90
|
+
] ),
|
|
91
|
+
];
|
|
95
92
|
|
|
96
93
|
const suggestedOptions = suggestedFormats.map(
|
|
97
94
|
( suggestedFormat, index ) => ( {
|
|
@@ -116,6 +113,7 @@ function NonDefaultControls( { format, onChange } ) {
|
|
|
116
113
|
<>
|
|
117
114
|
<BaseControl className="block-editor-date-format-picker__custom-format-select-control">
|
|
118
115
|
<CustomSelectControl
|
|
116
|
+
__nextUnconstrainedWidth
|
|
119
117
|
label={ __( 'Choose a format' ) }
|
|
120
118
|
options={ [ ...suggestedOptions, customOption ] }
|
|
121
119
|
value={
|
|
@@ -11,9 +11,9 @@ import { __unstableGetValuesFromColors as getValuesFromColors } from './index';
|
|
|
11
11
|
/**
|
|
12
12
|
* SVG and stylesheet needed for rendering the duotone filter.
|
|
13
13
|
*
|
|
14
|
-
* @param {Object}
|
|
15
|
-
* @param {string}
|
|
16
|
-
* @param {string}
|
|
14
|
+
* @param {Object} props Duotone props.
|
|
15
|
+
* @param {string} props.selector Selector to apply the filter to.
|
|
16
|
+
* @param {string} props.id Unique id for this duotone filter.
|
|
17
17
|
*
|
|
18
18
|
* @return {WPElement} Duotone element.
|
|
19
19
|
*/
|
|
@@ -29,8 +29,8 @@ ${ selector } {
|
|
|
29
29
|
/**
|
|
30
30
|
* Stylesheet for disabling a global styles duotone filter.
|
|
31
31
|
*
|
|
32
|
-
* @param {Object}
|
|
33
|
-
* @param {string}
|
|
32
|
+
* @param {Object} props Duotone props.
|
|
33
|
+
* @param {string} props.selector Selector to disable the filter for.
|
|
34
34
|
*
|
|
35
35
|
* @return {WPElement} Filter none style element.
|
|
36
36
|
*/
|
|
@@ -18,10 +18,6 @@ $swatch-columns: math.floor(math.div($popover-width + $swatch-gap - 2 * $popover
|
|
|
18
18
|
padding: 0;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
.components-custom-gradient-picker__gradient-bar {
|
|
22
|
-
margin: $grid-unit-20 0 $grid-unit-15;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
21
|
.components-circular-option-picker__swatches {
|
|
26
22
|
display: grid;
|
|
27
23
|
grid-template-columns: repeat($swatch-columns, $swatch-size);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { find, pickBy, reduce, some
|
|
4
|
+
import { find, pickBy, reduce, some } from 'lodash';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
@@ -17,6 +17,16 @@ import useSetting from '../use-setting';
|
|
|
17
17
|
|
|
18
18
|
const DEFAULT_FONT_SIZES = [];
|
|
19
19
|
|
|
20
|
+
/**
|
|
21
|
+
* Capitalizes the first letter in a string.
|
|
22
|
+
*
|
|
23
|
+
* @param {string} str The string whose first letter the function will capitalize.
|
|
24
|
+
*
|
|
25
|
+
* @return {string} Capitalized string.
|
|
26
|
+
*/
|
|
27
|
+
const upperFirst = ( [ firstLetter, ...rest ] ) =>
|
|
28
|
+
firstLetter.toUpperCase() + rest.join( '' );
|
|
29
|
+
|
|
20
30
|
/**
|
|
21
31
|
* Higher-order component, which handles font size logic for class generation,
|
|
22
32
|
* font size value retrieval, and font size change handling.
|
package/src/components/index.js
CHANGED
|
@@ -93,6 +93,7 @@ export { default as URLInputButton } from './url-input/button';
|
|
|
93
93
|
export { default as URLPopover } from './url-popover';
|
|
94
94
|
export { __experimentalImageURLInputUI } from './url-popover/image-url-input-ui';
|
|
95
95
|
export { default as withColorContext } from './color-palette/with-color-context';
|
|
96
|
+
export { default as __experimentalSpacingSizesControl } from './spacing-sizes-control';
|
|
96
97
|
|
|
97
98
|
/*
|
|
98
99
|
* Content Related Components
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import { noCase } from 'change-case';
|
|
5
|
+
import removeAccents from 'remove-accents';
|
|
6
|
+
import { find } from 'lodash';
|
|
5
7
|
|
|
6
8
|
// Default search helpers.
|
|
7
9
|
const defaultGetName = ( item ) => item.name || '';
|
|
@@ -21,7 +23,7 @@ const defaultGetCollection = () => null;
|
|
|
21
23
|
function normalizeSearchInput( input = '' ) {
|
|
22
24
|
// Disregard diacritics.
|
|
23
25
|
// Input: "média"
|
|
24
|
-
input =
|
|
26
|
+
input = removeAccents( input );
|
|
25
27
|
|
|
26
28
|
// Accommodate leading slash, matching autocomplete expectations.
|
|
27
29
|
// Input: "/media"
|
|
@@ -34,6 +36,17 @@ function normalizeSearchInput( input = '' ) {
|
|
|
34
36
|
return input;
|
|
35
37
|
}
|
|
36
38
|
|
|
39
|
+
/**
|
|
40
|
+
* Extracts words from an input string.
|
|
41
|
+
*
|
|
42
|
+
* @param {string} input The input string.
|
|
43
|
+
*
|
|
44
|
+
* @return {Array} Words, extracted from the input string.
|
|
45
|
+
*/
|
|
46
|
+
function extractWords( input = '' ) {
|
|
47
|
+
return noCase( input ).split( ' ' ).filter( Boolean );
|
|
48
|
+
}
|
|
49
|
+
|
|
37
50
|
/**
|
|
38
51
|
* Converts the search term into a list of normalized terms.
|
|
39
52
|
*
|
|
@@ -42,8 +55,7 @@ function normalizeSearchInput( input = '' ) {
|
|
|
42
55
|
* @return {string[]} The normalized list of search terms.
|
|
43
56
|
*/
|
|
44
57
|
export const getNormalizedSearchTerms = ( input = '' ) => {
|
|
45
|
-
|
|
46
|
-
return words( normalizeSearchInput( input ) );
|
|
58
|
+
return extractWords( normalizeSearchInput( input ) );
|
|
47
59
|
};
|
|
48
60
|
|
|
49
61
|
const removeMatchingTerms = ( unmatchedTerms, unprocessedTerms ) => {
|
|
@@ -150,7 +162,7 @@ export function getItemSearchRank( item, searchTerm, config = {} ) {
|
|
|
150
162
|
category,
|
|
151
163
|
collection,
|
|
152
164
|
].join( ' ' );
|
|
153
|
-
const normalizedSearchTerms =
|
|
165
|
+
const normalizedSearchTerms = extractWords( normalizedSearchInput );
|
|
154
166
|
const unmatchedTerms = removeMatchingTerms(
|
|
155
167
|
normalizedSearchTerms,
|
|
156
168
|
terms
|