@elementor/editor-controls 4.3.0-965 → 4.3.0-967
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/dist/index.d.mts +15 -21
- package/dist/index.d.ts +15 -21
- package/dist/index.js +22 -21
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +22 -21
- package/dist/index.mjs.map +1 -1
- package/package.json +16 -16
- package/src/components/size-control/size-input.tsx +4 -4
- package/src/controls/email-form-action-control/email-chips-field.tsx +47 -37
- package/src/controls/email-form-action-control/fields.tsx +3 -1
- package/src/controls/email-form-action-control/index.tsx +2 -4
- package/src/controls/size-control/types.ts +3 -10
- package/src/controls/size-control.tsx +8 -6
- package/src/utils/size-control.ts +15 -10
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": "4.3.0-
|
|
4
|
+
"version": "4.3.0-967",
|
|
5
5
|
"private": false,
|
|
6
6
|
"author": "Elementor Team",
|
|
7
7
|
"homepage": "https://elementor.com/",
|
|
@@ -40,23 +40,23 @@
|
|
|
40
40
|
"dev": "tsup --config=../../tsup.dev.ts"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@elementor/editor-current-user": "4.3.0-
|
|
44
|
-
"@elementor/editor-elements": "4.3.0-
|
|
45
|
-
"@elementor/editor-props": "4.3.0-
|
|
46
|
-
"@elementor/editor-responsive": "4.3.0-
|
|
47
|
-
"@elementor/editor-ui": "4.3.0-
|
|
48
|
-
"@elementor/editor-v1-adapters": "4.3.0-
|
|
49
|
-
"@elementor/env": "4.3.0-
|
|
50
|
-
"@elementor/events": "4.3.0-
|
|
51
|
-
"@elementor/http-client": "4.3.0-
|
|
43
|
+
"@elementor/editor-current-user": "4.3.0-967",
|
|
44
|
+
"@elementor/editor-elements": "4.3.0-967",
|
|
45
|
+
"@elementor/editor-props": "4.3.0-967",
|
|
46
|
+
"@elementor/editor-responsive": "4.3.0-967",
|
|
47
|
+
"@elementor/editor-ui": "4.3.0-967",
|
|
48
|
+
"@elementor/editor-v1-adapters": "4.3.0-967",
|
|
49
|
+
"@elementor/env": "4.3.0-967",
|
|
50
|
+
"@elementor/events": "4.3.0-967",
|
|
51
|
+
"@elementor/http-client": "4.3.0-967",
|
|
52
52
|
"@elementor/icons": "~1.75.1",
|
|
53
|
-
"@elementor/locations": "4.3.0-
|
|
54
|
-
"@elementor/query": "4.3.0-
|
|
55
|
-
"@elementor/schema": "4.3.0-
|
|
56
|
-
"@elementor/session": "4.3.0-
|
|
53
|
+
"@elementor/locations": "4.3.0-967",
|
|
54
|
+
"@elementor/query": "4.3.0-967",
|
|
55
|
+
"@elementor/schema": "4.3.0-967",
|
|
56
|
+
"@elementor/session": "4.3.0-967",
|
|
57
57
|
"@elementor/ui": "1.37.5",
|
|
58
|
-
"@elementor/utils": "4.3.0-
|
|
59
|
-
"@elementor/wp-media": "4.3.0-
|
|
58
|
+
"@elementor/utils": "4.3.0-967",
|
|
59
|
+
"@elementor/wp-media": "4.3.0-967",
|
|
60
60
|
"@monaco-editor/react": "^4.7.0",
|
|
61
61
|
"@tiptap/extension-bold": "^3.11.1",
|
|
62
62
|
"@tiptap/extension-document": "^3.11.1",
|
|
@@ -4,19 +4,19 @@ import { Box, InputAdornment, type PopupState } from '@elementor/ui';
|
|
|
4
4
|
|
|
5
5
|
import ControlActions from '../../control-actions/control-actions';
|
|
6
6
|
import { useTypingBuffer } from '../../hooks/use-typing-buffer';
|
|
7
|
-
import {
|
|
7
|
+
import { isUnitExtendedOption, type SizeUnit } from '../../utils/size-control';
|
|
8
8
|
import { SelectionEndAdornment, TextFieldInnerSelection } from '../size-control/text-field-inner-selection';
|
|
9
9
|
|
|
10
10
|
type SizeInputProps = {
|
|
11
|
-
unit:
|
|
11
|
+
unit: SizeUnit;
|
|
12
12
|
size: number | string;
|
|
13
13
|
placeholder?: string;
|
|
14
14
|
startIcon?: React.ReactNode;
|
|
15
|
-
units:
|
|
15
|
+
units: SizeUnit[];
|
|
16
16
|
onBlur?: ( event: React.FocusEvent< HTMLInputElement > ) => void;
|
|
17
17
|
onFocus?: ( event: React.FocusEvent< HTMLInputElement > ) => void;
|
|
18
18
|
onClick?: ( event: React.MouseEvent< HTMLInputElement > ) => void;
|
|
19
|
-
handleUnitChange: ( unit:
|
|
19
|
+
handleUnitChange: ( unit: SizeUnit ) => void;
|
|
20
20
|
handleSizeChange: ( event: React.ChangeEvent< HTMLInputElement > ) => void;
|
|
21
21
|
popupState: PopupState;
|
|
22
22
|
disabled?: boolean;
|
|
@@ -6,16 +6,15 @@ import { Autocomplete, Grid, TextField } from '@elementor/ui';
|
|
|
6
6
|
import { useBoundProp } from '../../bound-prop-context';
|
|
7
7
|
import { ChipsList } from '../../components/chips-list';
|
|
8
8
|
import { ControlFormLabel } from '../../components/control-form-label';
|
|
9
|
+
import ControlActions from '../../control-actions/control-actions';
|
|
10
|
+
import { createControl } from '../../create-control';
|
|
9
11
|
import { CHIP_TRIGGER_KEYS, isValidEmail } from './utils';
|
|
10
12
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
type EmailChipsFieldProps = {
|
|
14
|
-
fieldLabel: string;
|
|
13
|
+
type EmailChipsControlProps = {
|
|
15
14
|
placeholder?: string;
|
|
16
15
|
};
|
|
17
16
|
|
|
18
|
-
export const
|
|
17
|
+
export const EmailChipsControl = createControl( ( { placeholder }: EmailChipsControlProps ) => {
|
|
19
18
|
const { value, setValue, disabled } = useBoundProp( stringArrayPropTypeUtil );
|
|
20
19
|
const [ inputValue, setInputValue ] = useState( '' );
|
|
21
20
|
|
|
@@ -68,37 +67,48 @@ export const EmailChipsField = ( { fieldLabel, placeholder }: EmailChipsFieldPro
|
|
|
68
67
|
};
|
|
69
68
|
|
|
70
69
|
return (
|
|
71
|
-
<
|
|
72
|
-
<
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
<ChipsList getLabel={ ( option ) => option } getTagProps={ getTagProps } values={ tagValues } />
|
|
99
|
-
) }
|
|
100
|
-
/>
|
|
101
|
-
</Grid>
|
|
102
|
-
</Grid>
|
|
70
|
+
<ControlActions>
|
|
71
|
+
<Autocomplete
|
|
72
|
+
fullWidth
|
|
73
|
+
multiple
|
|
74
|
+
freeSolo
|
|
75
|
+
size="tiny"
|
|
76
|
+
disabled={ disabled }
|
|
77
|
+
inputValue={ inputValue }
|
|
78
|
+
onInputChange={ ( _, val, reason ) => {
|
|
79
|
+
if ( reason !== 'reset' ) {
|
|
80
|
+
setInputValue( val );
|
|
81
|
+
}
|
|
82
|
+
} }
|
|
83
|
+
value={ selectedValues }
|
|
84
|
+
onChange={ handleChange }
|
|
85
|
+
options={ [] }
|
|
86
|
+
onBlur={ handleBlur }
|
|
87
|
+
getOptionLabel={ ( option ) => option }
|
|
88
|
+
isOptionEqualToValue={ ( option, val ) => option === val }
|
|
89
|
+
renderInput={ ( params ) => (
|
|
90
|
+
<TextField { ...params } placeholder={ placeholder } onKeyDown={ handleKeyDown } />
|
|
91
|
+
) }
|
|
92
|
+
renderTags={ ( tagValues, getTagProps ) => (
|
|
93
|
+
<ChipsList getLabel={ ( option ) => option } getTagProps={ getTagProps } values={ tagValues } />
|
|
94
|
+
) }
|
|
95
|
+
/>
|
|
96
|
+
</ControlActions>
|
|
103
97
|
);
|
|
98
|
+
} );
|
|
99
|
+
|
|
100
|
+
type EmailChipsFieldProps = {
|
|
101
|
+
fieldLabel: string;
|
|
102
|
+
placeholder?: string;
|
|
104
103
|
};
|
|
104
|
+
|
|
105
|
+
export const EmailChipsField = ( { fieldLabel, placeholder }: EmailChipsFieldProps ) => (
|
|
106
|
+
<Grid container direction="column" gap={ 0.5 }>
|
|
107
|
+
<Grid item>
|
|
108
|
+
<ControlFormLabel>{ fieldLabel }</ControlFormLabel>
|
|
109
|
+
</Grid>
|
|
110
|
+
<Grid item>
|
|
111
|
+
<EmailChipsControl placeholder={ placeholder } />
|
|
112
|
+
</Grid>
|
|
113
|
+
</Grid>
|
|
114
|
+
);
|
|
@@ -14,7 +14,9 @@ import { EmailField } from './email-field';
|
|
|
14
14
|
import { shouldShowMentionsInfo } from './utils';
|
|
15
15
|
|
|
16
16
|
export const SendToField = ( { placeholder }: { placeholder?: string } ) => (
|
|
17
|
-
<
|
|
17
|
+
<PropKeyProvider bind="to">
|
|
18
|
+
<EmailChipsField fieldLabel={ __( 'Send to', 'elementor' ) } placeholder={ placeholder } />
|
|
19
|
+
</PropKeyProvider>
|
|
18
20
|
);
|
|
19
21
|
|
|
20
22
|
export const SubjectField = () => (
|
|
@@ -4,7 +4,7 @@ import { CollapsibleContent } from '@elementor/editor-ui';
|
|
|
4
4
|
import { Box, Divider, Stack } from '@elementor/ui';
|
|
5
5
|
import { __ } from '@wordpress/i18n';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { PropProvider, useBoundProp } from '../../bound-prop-context';
|
|
8
8
|
import { ControlLabel } from '../../components/control-label';
|
|
9
9
|
import { createControl } from '../../create-control';
|
|
10
10
|
import {
|
|
@@ -30,9 +30,7 @@ export const EmailFormActionControl = createControl(
|
|
|
30
30
|
<ControlLabel>
|
|
31
31
|
{ label ? label + ' ' + __( 'settings', 'elementor' ) : __( 'Email settings', 'elementor' ) }
|
|
32
32
|
</ControlLabel>
|
|
33
|
-
<
|
|
34
|
-
<SendToField placeholder={ toPlaceholder } />
|
|
35
|
-
</PropKeyProvider>
|
|
33
|
+
<SendToField placeholder={ toPlaceholder } />
|
|
36
34
|
<SubjectField />
|
|
37
35
|
<MessageField />
|
|
38
36
|
<FromEmailField />
|
|
@@ -1,17 +1,10 @@
|
|
|
1
1
|
import type { CreateOptions } from '@elementor/editor-props';
|
|
2
2
|
|
|
3
3
|
import { type SetValueMeta } from '../../bound-prop-context';
|
|
4
|
+
import { type ExtendedOption } from '../../utils/size-control';
|
|
4
5
|
|
|
5
|
-
type
|
|
6
|
-
type
|
|
7
|
-
type TimeUnit = 's' | 'ms';
|
|
8
|
-
|
|
9
|
-
type Unit = LengthUnit | AngleUnit | TimeUnit;
|
|
10
|
-
|
|
11
|
-
export type ExtendedSizeOption = 'auto' | 'custom';
|
|
12
|
-
|
|
13
|
-
export type SizeUnit = Unit | ExtendedSizeOption;
|
|
14
|
-
|
|
6
|
+
export type ExtendedSizeOption = ExtendedOption;
|
|
7
|
+
export type { SizeUnit } from '../../utils/size-control';
|
|
15
8
|
export type SizeVariant = 'length' | 'angle' | 'time';
|
|
16
9
|
|
|
17
10
|
export type SetSizeValue< T > = ( value: T, options?: CreateOptions, meta?: SetValueMeta ) => void;
|
|
@@ -19,10 +19,12 @@ import {
|
|
|
19
19
|
isUnitExtendedOption,
|
|
20
20
|
type LengthUnit,
|
|
21
21
|
lengthUnits,
|
|
22
|
+
type SizeUnit,
|
|
22
23
|
type TimeUnit,
|
|
23
24
|
timeUnits,
|
|
24
25
|
type Unit,
|
|
25
26
|
} from '../utils/size-control';
|
|
27
|
+
import { getPropTypeSettings } from './size-control/utils/settings/get-prop-type-settings';
|
|
26
28
|
|
|
27
29
|
type SizeValue = SizePropValue[ 'value' ];
|
|
28
30
|
|
|
@@ -65,7 +67,7 @@ export type SizeControlProps = LengthSizeControlProps | AngleSizeControlProps |
|
|
|
65
67
|
type State = {
|
|
66
68
|
numeric: number;
|
|
67
69
|
custom: string;
|
|
68
|
-
unit:
|
|
70
|
+
unit: SizeUnit;
|
|
69
71
|
};
|
|
70
72
|
|
|
71
73
|
const defaultSelectedUnit: Record< SizeControlProps[ 'variant' ], Unit > = {
|
|
@@ -133,7 +135,7 @@ export const SizeControl = createControl(
|
|
|
133
135
|
const { size: controlSize = DEFAULT_SIZE, unit: controlUnit = actualDefaultUnit } =
|
|
134
136
|
extractValueFromState( state, true ) || {};
|
|
135
137
|
|
|
136
|
-
const handleUnitChange = ( newUnit:
|
|
138
|
+
const handleUnitChange = ( newUnit: SizeUnit ) => {
|
|
137
139
|
if ( newUnit === 'custom' ) {
|
|
138
140
|
popupState.open( anchorRef?.current );
|
|
139
141
|
}
|
|
@@ -217,17 +219,17 @@ function resolveUnits(
|
|
|
217
219
|
variant: SizeVariant,
|
|
218
220
|
externalUnits?: Unit[],
|
|
219
221
|
actualExtendedOptions?: ExtendedOption[]
|
|
220
|
-
) {
|
|
222
|
+
): SizeUnit[] {
|
|
221
223
|
const fallback = [ ...defaultUnits[ variant ] ];
|
|
222
224
|
|
|
223
225
|
if ( ! enablePropTypeUnits ) {
|
|
224
226
|
return [ ...( externalUnits ?? fallback ), ...( actualExtendedOptions || [] ) ];
|
|
225
227
|
}
|
|
226
228
|
|
|
227
|
-
return ( propType
|
|
229
|
+
return getPropTypeSettings( propType )?.available_units ?? fallback;
|
|
228
230
|
}
|
|
229
231
|
|
|
230
|
-
function formatSize< TSize extends string | number >( size: TSize, unit:
|
|
232
|
+
function formatSize< TSize extends string | number >( size: TSize, unit: SizeUnit ): TSize {
|
|
231
233
|
if ( isUnitExtendedOption( unit ) ) {
|
|
232
234
|
return unit === 'auto' ? ( '' as TSize ) : ( String( size ?? '' ) as TSize );
|
|
233
235
|
}
|
|
@@ -237,7 +239,7 @@ function formatSize< TSize extends string | number >( size: TSize, unit: Unit |
|
|
|
237
239
|
|
|
238
240
|
function createStateFromSizeProp(
|
|
239
241
|
sizeValue: SizeValue | null,
|
|
240
|
-
defaultUnit:
|
|
242
|
+
defaultUnit: SizeUnit,
|
|
241
243
|
defaultSize: string | number = '',
|
|
242
244
|
customState: string = ''
|
|
243
245
|
): State {
|
|
@@ -1,18 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
export const angleUnits = [ 'deg', 'rad', 'grad', 'turn' ] as const;
|
|
3
|
-
export const timeUnits = [ 's', 'ms' ] as const;
|
|
4
|
-
const defaultExtendedOptions = [ 'auto', 'custom' ] as const;
|
|
1
|
+
import type { SizePropValue } from '@elementor/editor-props';
|
|
5
2
|
|
|
6
|
-
export
|
|
3
|
+
export type SizeUnit = SizePropValue[ 'value' ][ 'unit' ];
|
|
4
|
+
|
|
5
|
+
export type ExtendedOption = Extract< SizeUnit, 'auto' | 'custom' >;
|
|
6
|
+
export type Unit = Exclude< SizeUnit, ExtendedOption >;
|
|
7
|
+
|
|
8
|
+
export const lengthUnits = [ 'px', '%', 'em', 'rem', 'vw', 'vh', 'ch' ] as const satisfies readonly Unit[];
|
|
9
|
+
export const angleUnits = [ 'deg', 'rad', 'grad', 'turn' ] as const satisfies readonly Unit[];
|
|
10
|
+
export const timeUnits = [ 's', 'ms' ] as const satisfies readonly Unit[];
|
|
11
|
+
|
|
12
|
+
export const DEFAULT_UNIT = 'px' satisfies Unit;
|
|
7
13
|
export const DEFAULT_SIZE = NaN;
|
|
8
14
|
|
|
9
|
-
export type LengthUnit = ( typeof lengthUnits )[ number ]
|
|
15
|
+
export type LengthUnit = Extract< Unit, ( typeof lengthUnits )[ number ] | 'fr' >;
|
|
10
16
|
export type AngleUnit = ( typeof angleUnits )[ number ];
|
|
11
17
|
export type TimeUnit = ( typeof timeUnits )[ number ];
|
|
12
|
-
export type ExtendedOption = ( typeof defaultExtendedOptions )[ number ];
|
|
13
18
|
|
|
14
|
-
|
|
19
|
+
const extendedOptions = [ 'auto', 'custom' ] as const satisfies readonly ExtendedOption[];
|
|
15
20
|
|
|
16
|
-
export function isUnitExtendedOption( unit:
|
|
17
|
-
return
|
|
21
|
+
export function isUnitExtendedOption( unit: SizeUnit ): unit is ExtendedOption {
|
|
22
|
+
return extendedOptions.includes( unit as ExtendedOption );
|
|
18
23
|
}
|