@elementor/editor-controls 0.13.0 → 0.14.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 +18 -0
- package/dist/index.d.mts +6 -3
- package/dist/index.d.ts +6 -3
- package/dist/index.js +173 -106
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +183 -116
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
- package/src/components/repeater.tsx +1 -0
- package/src/controls/background-control/background-overlay/background-image-overlay/background-image-overlay-repeat.tsx +1 -1
- package/src/controls/background-control/background-overlay/background-image-overlay/background-image-overlay-size.tsx +8 -2
- package/src/controls/font-family-control.tsx +2 -2
- package/src/controls/gap-control.tsx +1 -1
- package/src/controls/image-control.tsx +1 -1
- package/src/controls/image-media-control.tsx +1 -1
- package/src/controls/link-control.tsx +2 -13
- package/src/controls/linked-dimensions-control.tsx +108 -88
- package/src/controls/size-control.tsx +91 -26
- package/src/controls/svg-media-control.tsx +2 -2
- package/src/index.ts +1 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elementor/editor-controls",
|
|
3
3
|
"description": "This package contains the controls model and utils for the Elementor editor",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.14.0",
|
|
5
5
|
"private": false,
|
|
6
6
|
"author": "Elementor Team",
|
|
7
7
|
"homepage": "https://elementor.com/",
|
|
@@ -40,14 +40,14 @@
|
|
|
40
40
|
"dev": "tsup --config=../../tsup.dev.ts"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@elementor/editor-props": "0.9.
|
|
43
|
+
"@elementor/editor-props": "0.9.3",
|
|
44
44
|
"@elementor/env": "0.3.5",
|
|
45
45
|
"@elementor/http": "0.1.3",
|
|
46
46
|
"@elementor/icons": "1.31.0",
|
|
47
47
|
"@elementor/session": "0.1.0",
|
|
48
48
|
"@elementor/ui": "1.26.0",
|
|
49
|
-
"@elementor/utils": "0.
|
|
50
|
-
"@elementor/wp-media": "0.4.
|
|
49
|
+
"@elementor/utils": "0.4.0",
|
|
50
|
+
"@elementor/wp-media": "0.4.2",
|
|
51
51
|
"@wordpress/i18n": "^5.13.0"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
@@ -31,7 +31,7 @@ const repeatControlOptions: ToggleButtonGroupItem< Repeaters >[] = [
|
|
|
31
31
|
},
|
|
32
32
|
{
|
|
33
33
|
value: 'no-repeat',
|
|
34
|
-
label: __( 'No-
|
|
34
|
+
label: __( 'No-repeat', 'elementor' ),
|
|
35
35
|
renderContent: ( { size } ) => <XIcon fontSize={ size } />,
|
|
36
36
|
showTooltip: true,
|
|
37
37
|
},
|
|
@@ -88,12 +88,18 @@ export const BackgroundImageOverlaySize = () => {
|
|
|
88
88
|
<PopoverGridContainer>
|
|
89
89
|
<Grid item xs={ 6 }>
|
|
90
90
|
<PropKeyProvider bind={ 'width' }>
|
|
91
|
-
<SizeControl
|
|
91
|
+
<SizeControl
|
|
92
|
+
startIcon={ <ArrowsMoveHorizontalIcon fontSize={ 'tiny' } /> }
|
|
93
|
+
extendedValues={ [ 'auto' ] }
|
|
94
|
+
/>
|
|
92
95
|
</PropKeyProvider>
|
|
93
96
|
</Grid>
|
|
94
97
|
<Grid item xs={ 6 }>
|
|
95
98
|
<PropKeyProvider bind={ 'height' }>
|
|
96
|
-
<SizeControl
|
|
99
|
+
<SizeControl
|
|
100
|
+
startIcon={ <ArrowsMoveVerticalIcon fontSize={ 'tiny' } /> }
|
|
101
|
+
extendedValues={ [ 'auto' ] }
|
|
102
|
+
/>
|
|
97
103
|
</PropKeyProvider>
|
|
98
104
|
</Grid>
|
|
99
105
|
</PopoverGridContainer>
|
|
@@ -71,7 +71,7 @@ export const FontFamilyControl = createControl( ( { fontFamilies } ) => {
|
|
|
71
71
|
<Stack>
|
|
72
72
|
<Stack direction="row" alignItems="center" pl={ 1.5 } pr={ 0.5 } py={ 1.5 }>
|
|
73
73
|
<EditIcon fontSize={ SIZE } sx={ { mr: 0.5 } } />
|
|
74
|
-
<Typography variant="subtitle2">{ __( 'Font
|
|
74
|
+
<Typography variant="subtitle2">{ __( 'Font family', 'elementor' ) }</Typography>
|
|
75
75
|
<IconButton size={ SIZE } sx={ { ml: 'auto' } } onClick={ handleClose }>
|
|
76
76
|
<XIcon fontSize={ SIZE } />
|
|
77
77
|
</IconButton>
|
|
@@ -82,7 +82,7 @@ export const FontFamilyControl = createControl( ( { fontFamilies } ) => {
|
|
|
82
82
|
fullWidth
|
|
83
83
|
size={ SIZE }
|
|
84
84
|
value={ searchValue }
|
|
85
|
-
placeholder={ __( 'Search', 'elementor' ) }
|
|
85
|
+
placeholder={ __( 'Search fonts…', 'elementor' ) }
|
|
86
86
|
onChange={ handleSearch }
|
|
87
87
|
InputProps={ {
|
|
88
88
|
startAdornment: (
|
|
@@ -22,7 +22,7 @@ export const ImageControl = createControl(
|
|
|
22
22
|
<PropProvider { ...propContext }>
|
|
23
23
|
<Stack gap={ 1.5 }>
|
|
24
24
|
<PropKeyProvider bind={ 'src' }>
|
|
25
|
-
<ControlLabel> { __( '
|
|
25
|
+
<ControlLabel> { __( 'Image', 'elementor' ) } </ControlLabel>
|
|
26
26
|
<ImageMediaControl />
|
|
27
27
|
</PropKeyProvider>
|
|
28
28
|
<PropKeyProvider bind={ 'size' }>
|
|
@@ -66,7 +66,7 @@ export const ImageMediaControl = createControl( ( props: ImageMediaControlProps
|
|
|
66
66
|
startIcon={ <UploadIcon /> }
|
|
67
67
|
onClick={ () => open( { mode: 'upload' } ) }
|
|
68
68
|
>
|
|
69
|
-
{ __( 'Upload
|
|
69
|
+
{ __( 'Upload', 'elementor' ) }
|
|
70
70
|
</Button>
|
|
71
71
|
</Stack>
|
|
72
72
|
</CardOverlay>
|
|
@@ -12,6 +12,7 @@ import { type HttpResponse, httpService } from '@elementor/http';
|
|
|
12
12
|
import { MinusIcon, PlusIcon } from '@elementor/icons';
|
|
13
13
|
import { useSessionStorage } from '@elementor/session';
|
|
14
14
|
import { Collapse, Divider, Grid, IconButton, Stack, Switch } from '@elementor/ui';
|
|
15
|
+
import { debounce } from '@elementor/utils';
|
|
15
16
|
import { __ } from '@wordpress/i18n';
|
|
16
17
|
|
|
17
18
|
import { PropKeyProvider, PropProvider, useBoundProp } from '../bound-prop-context';
|
|
@@ -191,7 +192,7 @@ const SwitchControl = () => {
|
|
|
191
192
|
return (
|
|
192
193
|
<Grid container alignItems="center" flexWrap="nowrap" justifyContent="space-between">
|
|
193
194
|
<Grid item>
|
|
194
|
-
<ControlLabel>{ __( 'Open in new tab', 'elementor' ) }</ControlLabel>
|
|
195
|
+
<ControlLabel>{ __( 'Open in a new tab', 'elementor' ) }</ControlLabel>
|
|
195
196
|
</Grid>
|
|
196
197
|
<Grid item>
|
|
197
198
|
<Switch checked={ value } onClick={ onClick } />
|
|
@@ -238,15 +239,3 @@ function generateFirstLoadedOption( unionValue: LinkPropValue[ 'value' ] | null
|
|
|
238
239
|
]
|
|
239
240
|
: [];
|
|
240
241
|
}
|
|
241
|
-
|
|
242
|
-
function debounce< TArgs extends unknown[] >( fn: ( ...args: TArgs ) => unknown, timeout: number ) {
|
|
243
|
-
let timer: ReturnType< typeof setTimeout >;
|
|
244
|
-
|
|
245
|
-
return ( ...args: TArgs ) => {
|
|
246
|
-
clearTimeout( timer );
|
|
247
|
-
|
|
248
|
-
timer = setTimeout( () => {
|
|
249
|
-
fn( ...args );
|
|
250
|
-
}, timeout );
|
|
251
|
-
};
|
|
252
|
-
}
|
|
@@ -7,111 +7,131 @@ import { __ } from '@wordpress/i18n';
|
|
|
7
7
|
import { PropKeyProvider, PropProvider, useBoundProp } from '../bound-prop-context';
|
|
8
8
|
import { ControlLabel } from '../components/control-label';
|
|
9
9
|
import { createControl } from '../create-control';
|
|
10
|
-
import { SizeControl } from './size-control';
|
|
10
|
+
import { type ExtendedValue, SizeControl } from './size-control';
|
|
11
11
|
|
|
12
|
-
export const LinkedDimensionsControl = createControl(
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
export const LinkedDimensionsControl = createControl(
|
|
13
|
+
( { label, extendedValues }: { label: string; extendedValues?: ExtendedValue[] } ) => {
|
|
14
|
+
const {
|
|
15
|
+
value: dimensionsValue,
|
|
16
|
+
setValue: setDimensionsValue,
|
|
17
|
+
propType,
|
|
18
|
+
} = useBoundProp( dimensionsPropTypeUtil );
|
|
19
|
+
const { value: sizeValue, setValue: setSizeValue } = useBoundProp( sizePropTypeUtil );
|
|
15
20
|
|
|
16
|
-
|
|
21
|
+
const isLinked = ! dimensionsValue && ! sizeValue ? true : !! sizeValue;
|
|
17
22
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
const onLinkToggle = () => {
|
|
24
|
+
if ( ! isLinked ) {
|
|
25
|
+
setSizeValue( dimensionsValue?.top?.value );
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
23
28
|
|
|
24
|
-
|
|
29
|
+
const value = sizeValue ? sizePropTypeUtil.create( sizeValue ) : null;
|
|
25
30
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
setDimensionsValue( {
|
|
32
|
+
top: value,
|
|
33
|
+
right: value,
|
|
34
|
+
bottom: value,
|
|
35
|
+
left: value,
|
|
36
|
+
} );
|
|
37
|
+
};
|
|
33
38
|
|
|
34
|
-
|
|
39
|
+
const LinkedIcon = isLinked ? LinkIcon : DetachIcon;
|
|
35
40
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
<Grid container gap={ 1 } alignItems="center">
|
|
65
|
-
<Grid item xs={ 12 }>
|
|
66
|
-
<ControlLabel>{ __( 'Right', 'elementor' ) }</ControlLabel>
|
|
67
|
-
</Grid>
|
|
68
|
-
<Grid item xs={ 12 }>
|
|
69
|
-
<Control
|
|
70
|
-
bind={ 'right' }
|
|
71
|
-
startIcon={ <SideRightIcon fontSize={ 'tiny' } /> }
|
|
72
|
-
isLinked={ isLinked }
|
|
73
|
-
/>
|
|
41
|
+
return (
|
|
42
|
+
<PropProvider propType={ propType } value={ dimensionsValue } setValue={ setDimensionsValue }>
|
|
43
|
+
<Stack direction="row" gap={ 2 } flexWrap="nowrap">
|
|
44
|
+
<ControlLabel>{ label }</ControlLabel>
|
|
45
|
+
<ToggleButton
|
|
46
|
+
aria-label={ __( 'Link Inputs', 'elementor' ) }
|
|
47
|
+
size={ 'tiny' }
|
|
48
|
+
value={ 'check' }
|
|
49
|
+
selected={ isLinked }
|
|
50
|
+
sx={ { marginLeft: 'auto' } }
|
|
51
|
+
onChange={ onLinkToggle }
|
|
52
|
+
>
|
|
53
|
+
<LinkedIcon fontSize={ 'tiny' } />
|
|
54
|
+
</ToggleButton>
|
|
55
|
+
</Stack>
|
|
56
|
+
<Stack direction="row" gap={ 2 } flexWrap="nowrap">
|
|
57
|
+
<Grid container gap={ 1 } alignItems="center">
|
|
58
|
+
<Grid item xs={ 12 }>
|
|
59
|
+
<ControlLabel>{ __( 'Top', 'elementor' ) }</ControlLabel>
|
|
60
|
+
</Grid>
|
|
61
|
+
<Grid item xs={ 12 }>
|
|
62
|
+
<Control
|
|
63
|
+
bind={ 'top' }
|
|
64
|
+
startIcon={ <SideTopIcon fontSize={ 'tiny' } /> }
|
|
65
|
+
isLinked={ isLinked }
|
|
66
|
+
extendedValues={ extendedValues }
|
|
67
|
+
/>
|
|
68
|
+
</Grid>
|
|
74
69
|
</Grid>
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
70
|
+
<Grid container gap={ 1 } alignItems="center">
|
|
71
|
+
<Grid item xs={ 12 }>
|
|
72
|
+
<ControlLabel>{ __( 'Right', 'elementor' ) }</ControlLabel>
|
|
73
|
+
</Grid>
|
|
74
|
+
<Grid item xs={ 12 }>
|
|
75
|
+
<Control
|
|
76
|
+
bind={ 'right' }
|
|
77
|
+
startIcon={ <SideRightIcon fontSize={ 'tiny' } /> }
|
|
78
|
+
isLinked={ isLinked }
|
|
79
|
+
extendedValues={ extendedValues }
|
|
80
|
+
/>
|
|
81
|
+
</Grid>
|
|
81
82
|
</Grid>
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
83
|
+
</Stack>
|
|
84
|
+
<Stack direction="row" gap={ 2 } flexWrap="nowrap">
|
|
85
|
+
<Grid container gap={ 1 } alignItems="center">
|
|
86
|
+
<Grid item xs={ 12 }>
|
|
87
|
+
<ControlLabel>{ __( 'Bottom', 'elementor' ) }</ControlLabel>
|
|
88
|
+
</Grid>
|
|
89
|
+
<Grid item xs={ 12 }>
|
|
90
|
+
<Control
|
|
91
|
+
bind={ 'bottom' }
|
|
92
|
+
startIcon={ <SideBottomIcon fontSize={ 'tiny' } /> }
|
|
93
|
+
isLinked={ isLinked }
|
|
94
|
+
extendedValues={ extendedValues }
|
|
95
|
+
/>
|
|
96
|
+
</Grid>
|
|
88
97
|
</Grid>
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
98
|
+
<Grid container gap={ 1 } alignItems="center">
|
|
99
|
+
<Grid item xs={ 12 }>
|
|
100
|
+
<ControlLabel>{ __( 'Left', 'elementor' ) }</ControlLabel>
|
|
101
|
+
</Grid>
|
|
102
|
+
<Grid item xs={ 12 }>
|
|
103
|
+
<Control
|
|
104
|
+
bind={ 'left' }
|
|
105
|
+
startIcon={ <SideLeftIcon fontSize={ 'tiny' } /> }
|
|
106
|
+
isLinked={ isLinked }
|
|
107
|
+
extendedValues={ extendedValues }
|
|
108
|
+
/>
|
|
109
|
+
</Grid>
|
|
93
110
|
</Grid>
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
/>
|
|
100
|
-
</Grid>
|
|
101
|
-
</Grid>
|
|
102
|
-
</Stack>
|
|
103
|
-
</PropProvider>
|
|
104
|
-
);
|
|
105
|
-
} );
|
|
111
|
+
</Stack>
|
|
112
|
+
</PropProvider>
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
);
|
|
106
116
|
|
|
107
|
-
const Control = ( {
|
|
117
|
+
const Control = ( {
|
|
118
|
+
bind,
|
|
119
|
+
startIcon,
|
|
120
|
+
isLinked,
|
|
121
|
+
extendedValues,
|
|
122
|
+
}: {
|
|
123
|
+
bind: PropKey;
|
|
124
|
+
startIcon: React.ReactNode;
|
|
125
|
+
isLinked: boolean;
|
|
126
|
+
extendedValues?: ExtendedValue[];
|
|
127
|
+
} ) => {
|
|
108
128
|
if ( isLinked ) {
|
|
109
|
-
return <SizeControl startIcon={ startIcon } />;
|
|
129
|
+
return <SizeControl startIcon={ startIcon } extendedValues={ extendedValues } />;
|
|
110
130
|
}
|
|
111
131
|
|
|
112
132
|
return (
|
|
113
133
|
<PropKeyProvider bind={ bind }>
|
|
114
|
-
<SizeControl startIcon={ startIcon } />
|
|
134
|
+
<SizeControl startIcon={ startIcon } extendedValues={ extendedValues } />
|
|
115
135
|
</PropKeyProvider>
|
|
116
136
|
);
|
|
117
137
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { sizePropTypeUtil } from '@elementor/editor-props';
|
|
2
|
+
import { sizePropTypeUtil, stringPropTypeUtil } from '@elementor/editor-props';
|
|
3
3
|
import { InputAdornment } from '@elementor/ui';
|
|
4
4
|
|
|
5
5
|
import { useBoundProp } from '../bound-prop-context';
|
|
@@ -8,6 +8,7 @@ import ControlActions from '../control-actions/control-actions';
|
|
|
8
8
|
import { createControl } from '../create-control';
|
|
9
9
|
import { useSyncExternalState } from '../hooks/use-sync-external-state';
|
|
10
10
|
|
|
11
|
+
export type ExtendedValue = 'auto';
|
|
11
12
|
export type Unit = 'px' | '%' | 'em' | 'rem' | 'vw' | 'vh';
|
|
12
13
|
|
|
13
14
|
const defaultUnits: Unit[] = [ 'px', '%', 'em', 'rem', 'vw', 'vh' ];
|
|
@@ -19,34 +20,98 @@ type SizeControlProps = {
|
|
|
19
20
|
placeholder?: string;
|
|
20
21
|
startIcon?: React.ReactNode;
|
|
21
22
|
units?: Unit[];
|
|
23
|
+
extendedValues?: ExtendedValue[];
|
|
22
24
|
};
|
|
23
25
|
|
|
24
|
-
export const SizeControl = createControl(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
26
|
+
export const SizeControl = createControl(
|
|
27
|
+
( { units = defaultUnits, extendedValues = [], placeholder, startIcon }: SizeControlProps ) => {
|
|
28
|
+
const { value: sizeValue, setValue: setSizeValue } = useBoundProp( sizePropTypeUtil );
|
|
29
|
+
|
|
30
|
+
const [ state, setState ] = useSyncExternalState( {
|
|
31
|
+
external: sizeValue,
|
|
32
|
+
setExternal: setSizeValue,
|
|
33
|
+
persistWhen: ( controlValue ) => !! controlValue?.size || controlValue?.size === 0,
|
|
34
|
+
fallback: ( controlValue ) => ( { unit: controlValue?.unit || defaultUnit, size: defaultSize } ),
|
|
35
|
+
} );
|
|
36
|
+
|
|
37
|
+
const handleUnitChange = ( unit: Unit ) => {
|
|
38
|
+
setState( ( prev ) => ( {
|
|
39
|
+
size: prev?.size ?? defaultSize,
|
|
40
|
+
unit,
|
|
41
|
+
} ) );
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const handleSizeChange = ( event: React.ChangeEvent< HTMLInputElement > ) => {
|
|
45
|
+
const { value: size } = event.target;
|
|
46
|
+
|
|
47
|
+
setState( ( prev ) => ( {
|
|
48
|
+
...prev,
|
|
49
|
+
size: size || size === '0' ? parseFloat( size ) : defaultSize,
|
|
50
|
+
} ) );
|
|
51
|
+
};
|
|
40
52
|
|
|
41
|
-
|
|
42
|
-
|
|
53
|
+
const inputProps = {
|
|
54
|
+
size: state.size,
|
|
55
|
+
unit: state.unit,
|
|
56
|
+
placeholder,
|
|
57
|
+
startIcon,
|
|
58
|
+
units,
|
|
59
|
+
extendedValues,
|
|
60
|
+
handleSizeChange,
|
|
61
|
+
handleUnitChange,
|
|
62
|
+
};
|
|
43
63
|
|
|
44
|
-
|
|
45
|
-
...
|
|
46
|
-
|
|
47
|
-
}
|
|
64
|
+
if ( extendedValues?.length ) {
|
|
65
|
+
return <ExtendedSizeInput { ...inputProps } />;
|
|
66
|
+
}
|
|
67
|
+
return <SizeInput { ...inputProps } />;
|
|
68
|
+
}
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
const ExtendedSizeInput = ( props: SizeInputProps ) => {
|
|
72
|
+
const { value: stringValue, setValue: setStringValue } = useBoundProp( stringPropTypeUtil );
|
|
73
|
+
const { extendedValues = [] } = props;
|
|
74
|
+
|
|
75
|
+
const unit = ( stringValue ?? props.unit ) as Unit;
|
|
76
|
+
|
|
77
|
+
const handleUnitChange = ( newUnit: Unit ) => {
|
|
78
|
+
if ( extendedValues.includes( newUnit as ExtendedValue ) ) {
|
|
79
|
+
setStringValue( newUnit );
|
|
80
|
+
} else {
|
|
81
|
+
props.handleUnitChange( newUnit );
|
|
82
|
+
}
|
|
48
83
|
};
|
|
49
84
|
|
|
85
|
+
return (
|
|
86
|
+
<SizeInput
|
|
87
|
+
{ ...props }
|
|
88
|
+
units={ [ ...props.units, ...( extendedValues as unknown as Unit[] ) ] }
|
|
89
|
+
handleUnitChange={ handleUnitChange }
|
|
90
|
+
unit={ unit }
|
|
91
|
+
/>
|
|
92
|
+
);
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
type SizeInputProps = {
|
|
96
|
+
unit: Unit;
|
|
97
|
+
size: number;
|
|
98
|
+
placeholder?: string;
|
|
99
|
+
startIcon?: React.ReactNode;
|
|
100
|
+
units: Unit[];
|
|
101
|
+
extendedValues?: ExtendedValue[];
|
|
102
|
+
handleUnitChange: ( unit: Unit ) => void;
|
|
103
|
+
handleSizeChange: ( event: React.ChangeEvent< HTMLInputElement > ) => void;
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
const SizeInput = ( {
|
|
107
|
+
units,
|
|
108
|
+
handleUnitChange,
|
|
109
|
+
handleSizeChange,
|
|
110
|
+
placeholder,
|
|
111
|
+
startIcon,
|
|
112
|
+
size,
|
|
113
|
+
unit,
|
|
114
|
+
}: SizeInputProps ) => {
|
|
50
115
|
return (
|
|
51
116
|
<ControlActions>
|
|
52
117
|
<TextFieldInnerSelection
|
|
@@ -54,7 +119,7 @@ export const SizeControl = createControl( ( { units = defaultUnits, placeholder,
|
|
|
54
119
|
<SelectionEndAdornment
|
|
55
120
|
options={ units }
|
|
56
121
|
onClick={ handleUnitChange }
|
|
57
|
-
value={
|
|
122
|
+
value={ unit ?? defaultUnit }
|
|
58
123
|
/>
|
|
59
124
|
}
|
|
60
125
|
placeholder={ placeholder }
|
|
@@ -62,9 +127,9 @@ export const SizeControl = createControl( ( { units = defaultUnits, placeholder,
|
|
|
62
127
|
startIcon ? <InputAdornment position="start">{ startIcon }</InputAdornment> : undefined
|
|
63
128
|
}
|
|
64
129
|
type="number"
|
|
65
|
-
value={ Number.isNaN(
|
|
130
|
+
value={ Number.isNaN( size ) ? '' : size }
|
|
66
131
|
onChange={ handleSizeChange }
|
|
67
132
|
/>
|
|
68
133
|
</ControlActions>
|
|
69
134
|
);
|
|
70
|
-
}
|
|
135
|
+
};
|
|
@@ -58,7 +58,7 @@ export const SvgMediaControl = createControl( () => {
|
|
|
58
58
|
|
|
59
59
|
return (
|
|
60
60
|
<Stack gap={ 1 }>
|
|
61
|
-
<ControlLabel> { __( '
|
|
61
|
+
<ControlLabel> { __( 'SVG', 'elementor' ) } </ControlLabel>
|
|
62
62
|
<ControlActions>
|
|
63
63
|
<StyledCard variant="outlined">
|
|
64
64
|
<StyledCardMediaContainer>
|
|
@@ -96,7 +96,7 @@ export const SvgMediaControl = createControl( () => {
|
|
|
96
96
|
startIcon={ <UploadIcon /> }
|
|
97
97
|
onClick={ () => open( { mode: 'upload' } ) }
|
|
98
98
|
>
|
|
99
|
-
{ __( 'Upload
|
|
99
|
+
{ __( 'Upload', 'elementor' ) }
|
|
100
100
|
</Button>
|
|
101
101
|
</Stack>
|
|
102
102
|
</CardOverlay>
|
package/src/index.ts
CHANGED
|
@@ -29,6 +29,7 @@ export type { EqualUnequalItems } from './controls/equal-unequal-sizes-control';
|
|
|
29
29
|
export type { ControlActionsItems } from './control-actions/control-actions-context';
|
|
30
30
|
export type { PropProviderProps } from './bound-prop-context';
|
|
31
31
|
export type { SetValue } from './bound-prop-context/prop-context';
|
|
32
|
+
export type { ExtendedValue } from './controls/size-control';
|
|
32
33
|
|
|
33
34
|
// providers
|
|
34
35
|
export { createControlReplacement, ControlReplacementProvider } from './create-control-replacement';
|