@elementor/editor-controls 4.1.0-755 → 4.1.0-757
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.js +15 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +15 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -15
- package/src/controls/select-control.tsx +30 -20
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.1.0-
|
|
4
|
+
"version": "4.1.0-757",
|
|
5
5
|
"private": false,
|
|
6
6
|
"author": "Elementor Team",
|
|
7
7
|
"homepage": "https://elementor.com/",
|
|
@@ -40,22 +40,22 @@
|
|
|
40
40
|
"dev": "tsup --config=../../tsup.dev.ts"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@elementor/editor-current-user": "4.1.0-
|
|
44
|
-
"@elementor/editor-elements": "4.1.0-
|
|
45
|
-
"@elementor/editor-props": "4.1.0-
|
|
46
|
-
"@elementor/editor-responsive": "4.1.0-
|
|
47
|
-
"@elementor/editor-ui": "4.1.0-
|
|
48
|
-
"@elementor/editor-v1-adapters": "4.1.0-
|
|
49
|
-
"@elementor/env": "4.1.0-
|
|
50
|
-
"@elementor/http-client": "4.1.0-
|
|
43
|
+
"@elementor/editor-current-user": "4.1.0-757",
|
|
44
|
+
"@elementor/editor-elements": "4.1.0-757",
|
|
45
|
+
"@elementor/editor-props": "4.1.0-757",
|
|
46
|
+
"@elementor/editor-responsive": "4.1.0-757",
|
|
47
|
+
"@elementor/editor-ui": "4.1.0-757",
|
|
48
|
+
"@elementor/editor-v1-adapters": "4.1.0-757",
|
|
49
|
+
"@elementor/env": "4.1.0-757",
|
|
50
|
+
"@elementor/http-client": "4.1.0-757",
|
|
51
51
|
"@elementor/icons": "^1.68.0",
|
|
52
|
-
"@elementor/locations": "4.1.0-
|
|
53
|
-
"@elementor/events": "4.1.0-
|
|
54
|
-
"@elementor/query": "4.1.0-
|
|
55
|
-
"@elementor/session": "4.1.0-
|
|
52
|
+
"@elementor/locations": "4.1.0-757",
|
|
53
|
+
"@elementor/events": "4.1.0-757",
|
|
54
|
+
"@elementor/query": "4.1.0-757",
|
|
55
|
+
"@elementor/session": "4.1.0-757",
|
|
56
56
|
"@elementor/ui": "1.36.17",
|
|
57
|
-
"@elementor/utils": "4.1.0-
|
|
58
|
-
"@elementor/wp-media": "4.1.0-
|
|
57
|
+
"@elementor/utils": "4.1.0-757",
|
|
58
|
+
"@elementor/wp-media": "4.1.0-757",
|
|
59
59
|
"@wordpress/i18n": "^5.13.0",
|
|
60
60
|
"@monaco-editor/react": "^4.7.0",
|
|
61
61
|
"dayjs": "^1.11.18",
|
|
@@ -47,26 +47,9 @@ export const SelectControl = createControl(
|
|
|
47
47
|
size="tiny"
|
|
48
48
|
MenuProps={ MenuProps }
|
|
49
49
|
aria-label={ ariaLabel || placeholder }
|
|
50
|
-
renderValue={ ( selectedValue: string | null ) =>
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
if ( ! selectedValue || selectedValue === '' ) {
|
|
55
|
-
if ( placeholder ) {
|
|
56
|
-
const placeholderOption = findOptionByValue( placeholder );
|
|
57
|
-
const displayText = placeholderOption?.label || placeholder;
|
|
58
|
-
|
|
59
|
-
return (
|
|
60
|
-
<Typography component="span" variant="caption" color="text.tertiary">
|
|
61
|
-
{ displayText }
|
|
62
|
-
</Typography>
|
|
63
|
-
);
|
|
64
|
-
}
|
|
65
|
-
return '';
|
|
66
|
-
}
|
|
67
|
-
const option = findOptionByValue( selectedValue );
|
|
68
|
-
return option?.label || selectedValue;
|
|
69
|
-
} }
|
|
50
|
+
renderValue={ ( selectedValue: string | null ) =>
|
|
51
|
+
getSelectRenderValue( options, placeholder, selectedValue )
|
|
52
|
+
}
|
|
70
53
|
value={ value ?? '' }
|
|
71
54
|
onChange={ handleChange }
|
|
72
55
|
disabled={ isDisabled }
|
|
@@ -82,3 +65,30 @@ export const SelectControl = createControl(
|
|
|
82
65
|
);
|
|
83
66
|
}
|
|
84
67
|
);
|
|
68
|
+
|
|
69
|
+
function getSelectRenderValue(
|
|
70
|
+
options: SelectOption[],
|
|
71
|
+
placeholder: string | null | undefined,
|
|
72
|
+
selectedValue: string | null
|
|
73
|
+
): React.ReactNode {
|
|
74
|
+
const optionWithValue = ( v: string | null ) => options.find( ( { value } ) => value === v );
|
|
75
|
+
|
|
76
|
+
if ( ! isUnsetSelectValue( selectedValue ) ) {
|
|
77
|
+
return optionWithValue( selectedValue )?.label ?? selectedValue;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if ( placeholder ) {
|
|
81
|
+
const text = optionWithValue( placeholder )?.label ?? placeholder;
|
|
82
|
+
return (
|
|
83
|
+
<Typography component="span" variant="inherit" color="text.tertiary">
|
|
84
|
+
{ text }
|
|
85
|
+
</Typography>
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return options.find( ( { value } ) => isUnsetSelectValue( value ) )?.label ?? '';
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function isUnsetSelectValue( value: string | null | undefined ): boolean {
|
|
93
|
+
return value === null || value === undefined || value === '';
|
|
94
|
+
}
|