@wordpress/components 25.15.0 → 25.16.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/CHANGELOG.md +26 -0
- package/build/border-box-control/border-box-control/component.js.map +1 -1
- package/build/border-box-control/border-box-control/hook.js +3 -1
- package/build/border-box-control/border-box-control/hook.js.map +1 -1
- package/build/border-box-control/types.js.map +1 -1
- package/build/border-control/border-control/component.js +5 -1
- package/build/border-control/border-control/component.js.map +1 -1
- package/build/border-control/border-control/hook.js +18 -15
- package/build/border-control/border-control/hook.js.map +1 -1
- package/build/border-control/border-control-dropdown/component.js +2 -1
- package/build/border-control/border-control-dropdown/component.js.map +1 -1
- package/build/border-control/border-control-style-picker/component.js +21 -49
- package/build/border-control/border-control-style-picker/component.js.map +1 -1
- package/build/border-control/styles.js +15 -27
- package/build/border-control/styles.js.map +1 -1
- package/build/border-control/types.js.map +1 -1
- package/build/box-control/all-input-control.js +35 -29
- package/build/box-control/all-input-control.js.map +1 -1
- package/build/box-control/axial-input-controls.js +40 -54
- package/build/box-control/axial-input-controls.js.map +1 -1
- package/build/box-control/index.js +21 -24
- package/build/box-control/index.js.map +1 -1
- package/build/box-control/input-controls.js +45 -37
- package/build/box-control/input-controls.js.map +1 -1
- package/build/box-control/styles/box-control-styles.js +50 -112
- package/build/box-control/styles/box-control-styles.js.map +1 -1
- package/build/box-control/types.js.map +1 -1
- package/build/box-control/utils.js +123 -8
- package/build/box-control/utils.js.map +1 -1
- package/build/button/index.js +14 -16
- package/build/button/index.js.map +1 -1
- package/build/button/types.js.map +1 -1
- package/build/color-palette/index.native.js +11 -7
- package/build/color-palette/index.native.js.map +1 -1
- package/build/color-picker/hsl-input.js +55 -33
- package/build/color-picker/hsl-input.js.map +1 -1
- package/build/custom-select-control-v2/index.js +3 -2
- package/build/custom-select-control-v2/index.js.map +1 -1
- package/build/mobile/color-settings/palette.screen.native.js +8 -4
- package/build/mobile/color-settings/palette.screen.native.js.map +1 -1
- package/build/slot-fill/bubbles-virtually/use-slot-fills.js +1 -1
- package/build/slot-fill/bubbles-virtually/use-slot-fills.js.map +1 -1
- package/build/theme/styles.js +11 -6
- package/build/theme/styles.js.map +1 -1
- package/build/toggle-group-control/toggle-group-control/utils.js +7 -1
- package/build/toggle-group-control/toggle-group-control/utils.js.map +1 -1
- package/build/tooltip/index.js +35 -8
- package/build/tooltip/index.js.map +1 -1
- package/build/tooltip/types.js.map +1 -1
- package/build-module/border-box-control/border-box-control/component.js.map +1 -1
- package/build-module/border-box-control/border-box-control/hook.js +3 -1
- package/build-module/border-box-control/border-box-control/hook.js.map +1 -1
- package/build-module/border-box-control/types.js.map +1 -1
- package/build-module/border-control/border-control/component.js +5 -1
- package/build-module/border-control/border-control/component.js.map +1 -1
- package/build-module/border-control/border-control/hook.js +18 -15
- package/build-module/border-control/border-control/hook.js.map +1 -1
- package/build-module/border-control/border-control-dropdown/component.js +2 -1
- package/build-module/border-control/border-control-dropdown/component.js.map +1 -1
- package/build-module/border-control/border-control-style-picker/component.js +21 -48
- package/build-module/border-control/border-control-style-picker/component.js.map +1 -1
- package/build-module/border-control/styles.js +14 -24
- package/build-module/border-control/styles.js.map +1 -1
- package/build-module/border-control/types.js.map +1 -1
- package/build-module/box-control/all-input-control.js +38 -28
- package/build-module/box-control/all-input-control.js.map +1 -1
- package/build-module/box-control/axial-input-controls.js +42 -57
- package/build-module/box-control/axial-input-controls.js.map +1 -1
- package/build-module/box-control/index.js +22 -25
- package/build-module/box-control/index.js.map +1 -1
- package/build-module/box-control/input-controls.js +47 -40
- package/build-module/box-control/input-controls.js.map +1 -1
- package/build-module/box-control/styles/box-control-styles.js +45 -105
- package/build-module/box-control/styles/box-control-styles.js.map +1 -1
- package/build-module/box-control/types.js.map +1 -1
- package/build-module/box-control/utils.js +121 -7
- package/build-module/box-control/utils.js.map +1 -1
- package/build-module/button/index.js +14 -16
- package/build-module/button/index.js.map +1 -1
- package/build-module/button/types.js.map +1 -1
- package/build-module/color-palette/index.native.js +11 -7
- package/build-module/color-palette/index.native.js.map +1 -1
- package/build-module/color-picker/hsl-input.js +55 -33
- package/build-module/color-picker/hsl-input.js.map +1 -1
- package/build-module/custom-select-control-v2/index.js +3 -2
- package/build-module/custom-select-control-v2/index.js.map +1 -1
- package/build-module/mobile/color-settings/palette.screen.native.js +8 -4
- package/build-module/mobile/color-settings/palette.screen.native.js.map +1 -1
- package/build-module/slot-fill/bubbles-virtually/use-slot-fills.js +1 -1
- package/build-module/slot-fill/bubbles-virtually/use-slot-fills.js.map +1 -1
- package/build-module/theme/styles.js +11 -2
- package/build-module/theme/styles.js.map +1 -1
- package/build-module/toggle-group-control/toggle-group-control/utils.js +7 -1
- package/build-module/toggle-group-control/toggle-group-control/utils.js.map +1 -1
- package/build-module/tooltip/index.js +34 -9
- package/build-module/tooltip/index.js.map +1 -1
- package/build-module/tooltip/types.js.map +1 -1
- package/build-style/style-rtl.css +6 -4
- package/build-style/style.css +6 -4
- package/build-types/border-box-control/border-box-control/component.d.ts +1 -0
- package/build-types/border-box-control/border-box-control/component.d.ts.map +1 -1
- package/build-types/border-box-control/border-box-control/hook.d.ts.map +1 -1
- package/build-types/border-box-control/border-box-control-linked-button/hook.d.ts +3 -3
- package/build-types/border-box-control/stories/index.story.d.ts +2 -1
- package/build-types/border-box-control/stories/index.story.d.ts.map +1 -1
- package/build-types/border-box-control/types.d.ts +6 -0
- package/build-types/border-box-control/types.d.ts.map +1 -1
- package/build-types/border-control/border-control/component.d.ts +1 -0
- package/build-types/border-control/border-control/component.d.ts.map +1 -1
- package/build-types/border-control/border-control/hook.d.ts +2 -0
- package/build-types/border-control/border-control/hook.d.ts.map +1 -1
- package/build-types/border-control/border-control-dropdown/component.d.ts +1 -0
- package/build-types/border-control/border-control-dropdown/component.d.ts.map +1 -1
- package/build-types/border-control/border-control-dropdown/hook.d.ts +1 -0
- package/build-types/border-control/border-control-dropdown/hook.d.ts.map +1 -1
- package/build-types/border-control/border-control-style-picker/component.d.ts +3 -4
- package/build-types/border-control/border-control-style-picker/component.d.ts.map +1 -1
- package/build-types/border-control/stories/index.story.d.ts +12 -6
- package/build-types/border-control/stories/index.story.d.ts.map +1 -1
- package/build-types/border-control/styles.d.ts +0 -2
- package/build-types/border-control/styles.d.ts.map +1 -1
- package/build-types/border-control/types.d.ts +12 -1
- package/build-types/border-control/types.d.ts.map +1 -1
- package/build-types/box-control/all-input-control.d.ts +1 -1
- package/build-types/box-control/all-input-control.d.ts.map +1 -1
- package/build-types/box-control/axial-input-controls.d.ts +1 -1
- package/build-types/box-control/axial-input-controls.d.ts.map +1 -1
- package/build-types/box-control/index.d.ts +1 -1
- package/build-types/box-control/index.d.ts.map +1 -1
- package/build-types/box-control/input-controls.d.ts +1 -1
- package/build-types/box-control/input-controls.d.ts.map +1 -1
- package/build-types/box-control/stories/index.story.d.ts +24 -18
- package/build-types/box-control/stories/index.story.d.ts.map +1 -1
- package/build-types/box-control/styles/box-control-styles.d.ts +49 -23
- package/build-types/box-control/styles/box-control-styles.d.ts.map +1 -1
- package/build-types/box-control/types.d.ts +12 -12
- package/build-types/box-control/types.d.ts.map +1 -1
- package/build-types/box-control/utils.d.ts +2 -1
- package/build-types/box-control/utils.d.ts.map +1 -1
- package/build-types/button/deprecated.d.ts +1 -1
- package/build-types/button/index.d.ts.map +1 -1
- package/build-types/button/types.d.ts +7 -3
- package/build-types/button/types.d.ts.map +1 -1
- package/build-types/color-picker/hsl-input.d.ts.map +1 -1
- package/build-types/color-picker/styles.d.ts +1 -1
- package/build-types/custom-select-control-v2/index.d.ts.map +1 -1
- package/build-types/date-time/time/styles.d.ts +4 -4
- package/build-types/focal-point-picker/stories/index.story.d.ts +4 -4
- package/build-types/focal-point-picker/styles/focal-point-picker-style.d.ts +1 -1
- package/build-types/navigation/styles/navigation-styles.d.ts +1 -1
- package/build-types/navigator/navigator-back-button/hook.d.ts +2 -2
- package/build-types/navigator/navigator-button/hook.d.ts +2 -2
- package/build-types/number-control/index.d.ts +1 -1
- package/build-types/number-control/stories/index.story.d.ts +1 -1
- package/build-types/range-control/styles/range-control-styles.d.ts +1 -1
- package/build-types/search-control/index.d.ts +1 -1
- package/build-types/search-control/stories/index.story.d.ts +2 -2
- package/build-types/text-control/index.d.ts +1 -1
- package/build-types/textarea-control/index.d.ts +1 -1
- package/build-types/theme/styles.d.ts.map +1 -1
- package/build-types/toggle-group-control/toggle-group-control/as-button-group.d.ts +1 -1
- package/build-types/toggle-group-control/toggle-group-control/as-radio-group.d.ts +1 -1
- package/build-types/toggle-group-control/toggle-group-control/utils.d.ts.map +1 -1
- package/build-types/toggle-group-control/toggle-group-control-option/component.d.ts +1 -1
- package/build-types/toggle-group-control/toggle-group-control-option-icon/component.d.ts +1 -1
- package/build-types/toolbar/toolbar-button/index.d.ts +1 -1
- package/build-types/tooltip/index.d.ts +1 -1
- package/build-types/tooltip/index.d.ts.map +1 -1
- package/build-types/tooltip/stories/index.story.d.ts +10 -1
- package/build-types/tooltip/stories/index.story.d.ts.map +1 -1
- package/build-types/tooltip/types.d.ts +3 -0
- package/build-types/tooltip/types.d.ts.map +1 -1
- package/build-types/unit-control/index.d.ts +1 -1
- package/build-types/unit-control/styles/unit-control-styles.d.ts +1 -1
- package/package.json +19 -19
- package/src/border-box-control/border-box-control/component.tsx +0 -1
- package/src/border-box-control/border-box-control/hook.ts +5 -1
- package/src/border-box-control/types.ts +6 -0
- package/src/border-control/border-control/component.tsx +4 -0
- package/src/border-control/border-control/hook.ts +22 -16
- package/src/border-control/border-control-dropdown/component.tsx +2 -1
- package/src/border-control/border-control-style-picker/component.tsx +31 -66
- package/src/border-control/styles.ts +0 -15
- package/src/border-control/types.ts +15 -1
- package/src/box-control/all-input-control.tsx +57 -34
- package/src/box-control/axial-input-controls.tsx +79 -69
- package/src/box-control/index.tsx +47 -54
- package/src/box-control/input-controls.tsx +114 -83
- package/src/box-control/styles/box-control-styles.ts +21 -61
- package/src/box-control/test/index.tsx +126 -18
- package/src/box-control/types.ts +10 -21
- package/src/box-control/utils.ts +43 -8
- package/src/button/README.md +1 -1
- package/src/button/index.tsx +21 -33
- package/src/button/test/index.tsx +122 -0
- package/src/button/types.ts +7 -3
- package/src/circular-option-picker/test/index.tsx +10 -16
- package/src/color-palette/index.native.js +18 -7
- package/src/color-picker/hsl-input.tsx +56 -30
- package/src/color-picker/test/index.tsx +190 -16
- package/src/custom-select-control-v2/index.tsx +5 -2
- package/src/mobile/color-settings/palette.screen.native.js +7 -5
- package/src/palette-edit/test/index.tsx +326 -10
- package/src/slot-fill/bubbles-virtually/use-slot-fills.ts +1 -1
- package/src/tabs/test/index.tsx +3 -1
- package/src/theme/styles.ts +3 -1
- package/src/toggle-group-control/test/__snapshots__/index.tsx.snap +6 -6
- package/src/toggle-group-control/test/index.tsx +73 -36
- package/src/toggle-group-control/toggle-group-control/utils.ts +8 -3
- package/src/tooltip/README.md +4 -0
- package/src/tooltip/index.tsx +46 -8
- package/src/tooltip/stories/index.story.tsx +18 -1
- package/src/tooltip/test/index.tsx +77 -12
- package/src/tooltip/types.ts +4 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/build/border-control/border-control-style-picker/hook.js +0 -41
- package/build/border-control/border-control-style-picker/hook.js.map +0 -1
- package/build/box-control/styles/box-control-visualizer-styles.js +0 -93
- package/build/box-control/styles/box-control-visualizer-styles.js.map +0 -1
- package/build/box-control/unit-control.js +0 -76
- package/build/box-control/unit-control.js.map +0 -1
- package/build-module/border-control/border-control-style-picker/hook.js +0 -32
- package/build-module/border-control/border-control-style-picker/hook.js.map +0 -1
- package/build-module/box-control/styles/box-control-visualizer-styles.js +0 -86
- package/build-module/box-control/styles/box-control-visualizer-styles.js.map +0 -1
- package/build-module/box-control/unit-control.js +0 -68
- package/build-module/box-control/unit-control.js.map +0 -1
- package/build-types/border-control/border-control-style-picker/hook.d.ts +0 -267
- package/build-types/border-control/border-control-style-picker/hook.d.ts.map +0 -1
- package/build-types/box-control/styles/box-control-visualizer-styles.d.ts +0 -46
- package/build-types/box-control/styles/box-control-visualizer-styles.d.ts.map +0 -1
- package/build-types/box-control/unit-control.d.ts +0 -4
- package/build-types/box-control/unit-control.d.ts.map +0 -1
- package/src/border-control/border-control-style-picker/hook.ts +0 -35
- package/src/box-control/styles/box-control-visualizer-styles.ts +0 -75
- package/src/box-control/unit-control.tsx +0 -74
|
@@ -1,42 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useInstanceId } from '@wordpress/compose';
|
|
1
5
|
/**
|
|
2
6
|
* Internal dependencies
|
|
3
7
|
*/
|
|
4
8
|
import type { UnitControlProps } from '../unit-control/types';
|
|
9
|
+
import {
|
|
10
|
+
FlexedRangeControl,
|
|
11
|
+
StyledUnitControl,
|
|
12
|
+
} from './styles/box-control-styles';
|
|
13
|
+
import { HStack } from '../h-stack';
|
|
5
14
|
import type { BoxControlInputControlProps } from './types';
|
|
6
|
-
import
|
|
15
|
+
import { parseQuantityAndUnitFromRawValue } from '../unit-control';
|
|
7
16
|
import {
|
|
8
17
|
LABELS,
|
|
9
18
|
applyValueToSides,
|
|
10
19
|
getAllValue,
|
|
11
20
|
isValuesMixed,
|
|
12
21
|
isValuesDefined,
|
|
22
|
+
CUSTOM_VALUE_SETTINGS,
|
|
13
23
|
} from './utils';
|
|
14
24
|
|
|
15
25
|
const noop = () => {};
|
|
16
26
|
|
|
17
27
|
export default function AllInputControl( {
|
|
28
|
+
__next40pxDefaultSize,
|
|
18
29
|
onChange = noop,
|
|
19
30
|
onFocus = noop,
|
|
20
|
-
onHoverOn = noop,
|
|
21
|
-
onHoverOff = noop,
|
|
22
31
|
values,
|
|
23
32
|
sides,
|
|
24
33
|
selectedUnits,
|
|
25
34
|
setSelectedUnits,
|
|
26
35
|
...props
|
|
27
36
|
}: BoxControlInputControlProps ) {
|
|
37
|
+
const inputId = useInstanceId( AllInputControl, 'box-control-input-all' );
|
|
38
|
+
|
|
28
39
|
const allValue = getAllValue( values, selectedUnits, sides );
|
|
29
40
|
const hasValues = isValuesDefined( values );
|
|
30
41
|
const isMixed = hasValues && isValuesMixed( values, selectedUnits, sides );
|
|
31
42
|
const allPlaceholder = isMixed ? LABELS.mixed : undefined;
|
|
32
43
|
|
|
44
|
+
const [ parsedQuantity, parsedUnit ] =
|
|
45
|
+
parseQuantityAndUnitFromRawValue( allValue );
|
|
46
|
+
|
|
33
47
|
const handleOnFocus: React.FocusEventHandler< HTMLInputElement > = (
|
|
34
48
|
event
|
|
35
49
|
) => {
|
|
36
50
|
onFocus( event, { side: 'all' } );
|
|
37
51
|
};
|
|
38
52
|
|
|
39
|
-
const
|
|
53
|
+
const onValueChange = ( next?: string ) => {
|
|
40
54
|
const isNumeric = next !== undefined && ! isNaN( parseFloat( next ) );
|
|
41
55
|
const nextValue = isNumeric ? next : undefined;
|
|
42
56
|
const nextValues = applyValueToSides( values, nextValue, sides );
|
|
@@ -44,6 +58,12 @@ export default function AllInputControl( {
|
|
|
44
58
|
onChange( nextValues );
|
|
45
59
|
};
|
|
46
60
|
|
|
61
|
+
const sliderOnChange = ( next?: number ) => {
|
|
62
|
+
onValueChange(
|
|
63
|
+
next !== undefined ? [ next, parsedUnit ].join( '' ) : undefined
|
|
64
|
+
);
|
|
65
|
+
};
|
|
66
|
+
|
|
47
67
|
// Set selected unit so it can be used as fallback by unlinked controls
|
|
48
68
|
// when individual sides do not have a value containing a unit.
|
|
49
69
|
const handleOnUnitChange: UnitControlProps[ 'onUnitChange' ] = ( unit ) => {
|
|
@@ -51,36 +71,39 @@ export default function AllInputControl( {
|
|
|
51
71
|
setSelectedUnits( newUnits );
|
|
52
72
|
};
|
|
53
73
|
|
|
54
|
-
const handleOnHoverOn = () => {
|
|
55
|
-
onHoverOn( {
|
|
56
|
-
top: true,
|
|
57
|
-
bottom: true,
|
|
58
|
-
left: true,
|
|
59
|
-
right: true,
|
|
60
|
-
} );
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
const handleOnHoverOff = () => {
|
|
64
|
-
onHoverOff( {
|
|
65
|
-
top: false,
|
|
66
|
-
bottom: false,
|
|
67
|
-
left: false,
|
|
68
|
-
right: false,
|
|
69
|
-
} );
|
|
70
|
-
};
|
|
71
|
-
|
|
72
74
|
return (
|
|
73
|
-
<
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
75
|
+
<HStack>
|
|
76
|
+
<StyledUnitControl
|
|
77
|
+
{ ...props }
|
|
78
|
+
__next40pxDefaultSize={ __next40pxDefaultSize }
|
|
79
|
+
className="component-box-control__unit-control"
|
|
80
|
+
disableUnits={ isMixed }
|
|
81
|
+
id={ inputId }
|
|
82
|
+
isPressEnterToChange
|
|
83
|
+
value={ allValue }
|
|
84
|
+
onChange={ onValueChange }
|
|
85
|
+
onUnitChange={ handleOnUnitChange }
|
|
86
|
+
onFocus={ handleOnFocus }
|
|
87
|
+
placeholder={ allPlaceholder }
|
|
88
|
+
label={ LABELS.all }
|
|
89
|
+
hideLabelFromVision
|
|
90
|
+
/>
|
|
91
|
+
|
|
92
|
+
<FlexedRangeControl
|
|
93
|
+
__nextHasNoMarginBottom
|
|
94
|
+
__next40pxDefaultSize={ __next40pxDefaultSize }
|
|
95
|
+
aria-controls={ inputId }
|
|
96
|
+
label={ LABELS.all }
|
|
97
|
+
hideLabelFromVision
|
|
98
|
+
onChange={ sliderOnChange }
|
|
99
|
+
min={ 0 }
|
|
100
|
+
max={ CUSTOM_VALUE_SETTINGS[ parsedUnit ?? 'px' ]?.max ?? 10 }
|
|
101
|
+
step={
|
|
102
|
+
CUSTOM_VALUE_SETTINGS[ parsedUnit ?? 'px' ]?.step ?? 0.1
|
|
103
|
+
}
|
|
104
|
+
value={ parsedQuantity ?? 0 }
|
|
105
|
+
withInputField={ false }
|
|
106
|
+
/>
|
|
107
|
+
</HStack>
|
|
85
108
|
);
|
|
86
109
|
}
|
|
@@ -1,26 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useInstanceId } from '@wordpress/compose';
|
|
1
5
|
/**
|
|
2
6
|
* Internal dependencies
|
|
3
7
|
*/
|
|
4
8
|
import { parseQuantityAndUnitFromRawValue } from '../unit-control/utils';
|
|
5
|
-
import
|
|
6
|
-
import { LABELS } from './utils';
|
|
7
|
-
import {
|
|
9
|
+
import Tooltip from '../tooltip';
|
|
10
|
+
import { CUSTOM_VALUE_SETTINGS, LABELS } from './utils';
|
|
11
|
+
import {
|
|
12
|
+
FlexedBoxControlIcon,
|
|
13
|
+
FlexedRangeControl,
|
|
14
|
+
InputWrapper,
|
|
15
|
+
StyledUnitControl,
|
|
16
|
+
} from './styles/box-control-styles';
|
|
8
17
|
import type { BoxControlInputControlProps } from './types';
|
|
9
18
|
|
|
10
19
|
const groupedSides = [ 'vertical', 'horizontal' ] as const;
|
|
11
20
|
type GroupedSide = ( typeof groupedSides )[ number ];
|
|
12
21
|
|
|
13
22
|
export default function AxialInputControls( {
|
|
23
|
+
__next40pxDefaultSize,
|
|
14
24
|
onChange,
|
|
15
25
|
onFocus,
|
|
16
|
-
onHoverOn,
|
|
17
|
-
onHoverOff,
|
|
18
26
|
values,
|
|
19
27
|
selectedUnits,
|
|
20
28
|
setSelectedUnits,
|
|
21
29
|
sides,
|
|
22
30
|
...props
|
|
23
31
|
}: BoxControlInputControlProps ) {
|
|
32
|
+
const generatedId = useInstanceId(
|
|
33
|
+
AxialInputControls,
|
|
34
|
+
`box-control-input`
|
|
35
|
+
);
|
|
36
|
+
|
|
24
37
|
const createHandleOnFocus =
|
|
25
38
|
( side: GroupedSide ) =>
|
|
26
39
|
( event: React.FocusEvent< HTMLInputElement > ) => {
|
|
@@ -30,43 +43,7 @@ export default function AxialInputControls( {
|
|
|
30
43
|
onFocus( event, { side } );
|
|
31
44
|
};
|
|
32
45
|
|
|
33
|
-
const
|
|
34
|
-
if ( ! onHoverOn ) {
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
if ( side === 'vertical' ) {
|
|
38
|
-
onHoverOn( {
|
|
39
|
-
top: true,
|
|
40
|
-
bottom: true,
|
|
41
|
-
} );
|
|
42
|
-
}
|
|
43
|
-
if ( side === 'horizontal' ) {
|
|
44
|
-
onHoverOn( {
|
|
45
|
-
left: true,
|
|
46
|
-
right: true,
|
|
47
|
-
} );
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
const createHandleOnHoverOff = ( side: GroupedSide ) => () => {
|
|
52
|
-
if ( ! onHoverOff ) {
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
if ( side === 'vertical' ) {
|
|
56
|
-
onHoverOff( {
|
|
57
|
-
top: false,
|
|
58
|
-
bottom: false,
|
|
59
|
-
} );
|
|
60
|
-
}
|
|
61
|
-
if ( side === 'horizontal' ) {
|
|
62
|
-
onHoverOff( {
|
|
63
|
-
left: false,
|
|
64
|
-
right: false,
|
|
65
|
-
} );
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
const createHandleOnChange = ( side: GroupedSide ) => ( next?: string ) => {
|
|
46
|
+
const handleOnValueChange = ( side: GroupedSide, next?: string ) => {
|
|
70
47
|
if ( ! onChange ) {
|
|
71
48
|
return;
|
|
72
49
|
}
|
|
@@ -109,16 +86,8 @@ export default function AxialInputControls( {
|
|
|
109
86
|
? groupedSides.filter( ( side ) => sides.includes( side ) )
|
|
110
87
|
: groupedSides;
|
|
111
88
|
|
|
112
|
-
const first = filteredSides[ 0 ];
|
|
113
|
-
const last = filteredSides[ filteredSides.length - 1 ];
|
|
114
|
-
const only = first === last && first;
|
|
115
|
-
|
|
116
89
|
return (
|
|
117
|
-
|
|
118
|
-
gap={ 0 }
|
|
119
|
-
align="top"
|
|
120
|
-
className="component-box-control__vertical-horizontal-input-controls"
|
|
121
|
-
>
|
|
90
|
+
<>
|
|
122
91
|
{ filteredSides.map( ( side ) => {
|
|
123
92
|
const [ parsedQuantity, parsedUnit ] =
|
|
124
93
|
parseQuantityAndUnitFromRawValue(
|
|
@@ -128,26 +97,67 @@ export default function AxialInputControls( {
|
|
|
128
97
|
side === 'vertical'
|
|
129
98
|
? selectedUnits.top
|
|
130
99
|
: selectedUnits.left;
|
|
100
|
+
|
|
101
|
+
const inputId = [ generatedId, side ].join( '-' );
|
|
102
|
+
|
|
131
103
|
return (
|
|
132
|
-
<
|
|
133
|
-
{
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
104
|
+
<InputWrapper key={ side }>
|
|
105
|
+
<FlexedBoxControlIcon side={ side } sides={ sides } />
|
|
106
|
+
<Tooltip placement="top-end" text={ LABELS[ side ] }>
|
|
107
|
+
<StyledUnitControl
|
|
108
|
+
{ ...props }
|
|
109
|
+
__next40pxDefaultSize={ __next40pxDefaultSize }
|
|
110
|
+
className="component-box-control__unit-control"
|
|
111
|
+
id={ inputId }
|
|
112
|
+
isPressEnterToChange
|
|
113
|
+
value={ [
|
|
114
|
+
parsedQuantity,
|
|
115
|
+
selectedUnit ?? parsedUnit,
|
|
116
|
+
].join( '' ) }
|
|
117
|
+
onChange={ ( newValue ) =>
|
|
118
|
+
handleOnValueChange( side, newValue )
|
|
119
|
+
}
|
|
120
|
+
onUnitChange={ createHandleOnUnitChange(
|
|
121
|
+
side
|
|
122
|
+
) }
|
|
123
|
+
onFocus={ createHandleOnFocus( side ) }
|
|
124
|
+
label={ LABELS[ side ] }
|
|
125
|
+
hideLabelFromVision
|
|
126
|
+
key={ side }
|
|
127
|
+
/>
|
|
128
|
+
</Tooltip>
|
|
129
|
+
<FlexedRangeControl
|
|
130
|
+
__nextHasNoMarginBottom
|
|
131
|
+
__next40pxDefaultSize={ __next40pxDefaultSize }
|
|
132
|
+
aria-controls={ inputId }
|
|
133
|
+
label={ LABELS[ side ] }
|
|
134
|
+
hideLabelFromVision
|
|
135
|
+
onChange={ ( newValue ) =>
|
|
136
|
+
handleOnValueChange(
|
|
137
|
+
side,
|
|
138
|
+
newValue !== undefined
|
|
139
|
+
? [
|
|
140
|
+
newValue,
|
|
141
|
+
selectedUnit ?? parsedUnit,
|
|
142
|
+
].join( '' )
|
|
143
|
+
: undefined
|
|
144
|
+
)
|
|
145
|
+
}
|
|
146
|
+
min={ 0 }
|
|
147
|
+
max={
|
|
148
|
+
CUSTOM_VALUE_SETTINGS[ selectedUnit ?? 'px' ]
|
|
149
|
+
?.max ?? 10
|
|
150
|
+
}
|
|
151
|
+
step={
|
|
152
|
+
CUSTOM_VALUE_SETTINGS[ selectedUnit ?? 'px' ]
|
|
153
|
+
?.step ?? 0.1
|
|
154
|
+
}
|
|
155
|
+
value={ parsedQuantity ?? 0 }
|
|
156
|
+
withInputField={ false }
|
|
157
|
+
/>
|
|
158
|
+
</InputWrapper>
|
|
149
159
|
);
|
|
150
160
|
} ) }
|
|
151
|
-
|
|
161
|
+
</>
|
|
152
162
|
);
|
|
153
163
|
}
|
|
@@ -9,17 +9,16 @@ import { __ } from '@wordpress/i18n';
|
|
|
9
9
|
* Internal dependencies
|
|
10
10
|
*/
|
|
11
11
|
import { BaseControl } from '../base-control';
|
|
12
|
-
import Button from '../button';
|
|
13
|
-
import { FlexItem, FlexBlock } from '../flex';
|
|
14
12
|
import AllInputControl from './all-input-control';
|
|
15
13
|
import InputControls from './input-controls';
|
|
16
14
|
import AxialInputControls from './axial-input-controls';
|
|
17
|
-
import BoxControlIcon from './icon';
|
|
18
15
|
import LinkedButton from './linked-button';
|
|
16
|
+
import { Grid } from '../grid';
|
|
19
17
|
import {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
FlexedBoxControlIcon,
|
|
19
|
+
InputWrapper,
|
|
20
|
+
ResetButton,
|
|
21
|
+
LinkedButtonWrapper,
|
|
23
22
|
} from './styles/box-control-styles';
|
|
24
23
|
import { parseQuantityAndUnitFromRawValue } from '../unit-control/utils';
|
|
25
24
|
import {
|
|
@@ -73,6 +72,7 @@ function useUniqueId( idProp?: string ) {
|
|
|
73
72
|
* ```
|
|
74
73
|
*/
|
|
75
74
|
function BoxControl( {
|
|
75
|
+
__next40pxDefaultSize = false,
|
|
76
76
|
id: idProp,
|
|
77
77
|
inputProps = defaultInputProps,
|
|
78
78
|
onChange = noop,
|
|
@@ -152,60 +152,53 @@ function BoxControl( {
|
|
|
152
152
|
values: inputValues,
|
|
153
153
|
onMouseOver,
|
|
154
154
|
onMouseOut,
|
|
155
|
+
__next40pxDefaultSize,
|
|
155
156
|
};
|
|
156
157
|
|
|
157
158
|
return (
|
|
158
|
-
<
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
aria-label={ label }
|
|
187
|
-
{ ...inputControlProps }
|
|
188
|
-
/>
|
|
189
|
-
</FlexBlock>
|
|
190
|
-
) }
|
|
191
|
-
{ ! isLinked && splitOnAxis && (
|
|
192
|
-
<FlexBlock>
|
|
193
|
-
<AxialInputControls { ...inputControlProps } />
|
|
194
|
-
</FlexBlock>
|
|
195
|
-
) }
|
|
196
|
-
{ ! hasOneSide && (
|
|
197
|
-
<FlexItem>
|
|
198
|
-
<LinkedButton
|
|
199
|
-
onClick={ toggleLinked }
|
|
200
|
-
isLinked={ isLinked }
|
|
201
|
-
/>
|
|
202
|
-
</FlexItem>
|
|
203
|
-
) }
|
|
204
|
-
</HeaderControlWrapper>
|
|
159
|
+
<Grid
|
|
160
|
+
id={ id }
|
|
161
|
+
columns={ 3 }
|
|
162
|
+
templateColumns="1fr min-content min-content"
|
|
163
|
+
role="group"
|
|
164
|
+
aria-labelledby={ headingId }
|
|
165
|
+
>
|
|
166
|
+
<BaseControl.VisualLabel id={ headingId }>
|
|
167
|
+
{ label }
|
|
168
|
+
</BaseControl.VisualLabel>
|
|
169
|
+
{ isLinked && (
|
|
170
|
+
<InputWrapper>
|
|
171
|
+
<FlexedBoxControlIcon side={ side } sides={ sides } />
|
|
172
|
+
<AllInputControl { ...inputControlProps } />
|
|
173
|
+
</InputWrapper>
|
|
174
|
+
) }
|
|
175
|
+
{ ! hasOneSide && (
|
|
176
|
+
<LinkedButtonWrapper>
|
|
177
|
+
<LinkedButton
|
|
178
|
+
onClick={ toggleLinked }
|
|
179
|
+
isLinked={ isLinked }
|
|
180
|
+
/>
|
|
181
|
+
</LinkedButtonWrapper>
|
|
182
|
+
) }
|
|
183
|
+
|
|
184
|
+
{ ! isLinked && splitOnAxis && (
|
|
185
|
+
<AxialInputControls { ...inputControlProps } />
|
|
186
|
+
) }
|
|
205
187
|
{ ! isLinked && ! splitOnAxis && (
|
|
206
188
|
<InputControls { ...inputControlProps } />
|
|
207
189
|
) }
|
|
208
|
-
|
|
190
|
+
{ allowReset && (
|
|
191
|
+
<ResetButton
|
|
192
|
+
className="component-box-control__reset-button"
|
|
193
|
+
variant="secondary"
|
|
194
|
+
size="small"
|
|
195
|
+
onClick={ handleOnReset }
|
|
196
|
+
disabled={ ! isDirty }
|
|
197
|
+
>
|
|
198
|
+
{ __( 'Reset' ) }
|
|
199
|
+
</ResetButton>
|
|
200
|
+
) }
|
|
201
|
+
</Grid>
|
|
209
202
|
);
|
|
210
203
|
}
|
|
211
204
|
|