@elementor/editor-controls 4.3.0-995 → 4.3.0-996
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 +17 -21
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +17 -21
- package/dist/index.mjs.map +1 -1
- package/package.json +16 -16
- package/src/controls/chips-control.tsx +13 -25
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-996",
|
|
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-996",
|
|
44
|
+
"@elementor/editor-elements": "4.3.0-996",
|
|
45
|
+
"@elementor/editor-props": "4.3.0-996",
|
|
46
|
+
"@elementor/editor-responsive": "4.3.0-996",
|
|
47
|
+
"@elementor/editor-ui": "4.3.0-996",
|
|
48
|
+
"@elementor/editor-v1-adapters": "4.3.0-996",
|
|
49
|
+
"@elementor/env": "4.3.0-996",
|
|
50
|
+
"@elementor/events": "4.3.0-996",
|
|
51
|
+
"@elementor/http-client": "4.3.0-996",
|
|
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-996",
|
|
54
|
+
"@elementor/query": "4.3.0-996",
|
|
55
|
+
"@elementor/schema": "4.3.0-996",
|
|
56
|
+
"@elementor/session": "4.3.0-996",
|
|
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-996",
|
|
59
|
+
"@elementor/wp-media": "4.3.0-996",
|
|
60
60
|
"@monaco-editor/react": "^4.7.0",
|
|
61
61
|
"@tiptap/extension-bold": "^3.11.1",
|
|
62
62
|
"@tiptap/extension-document": "^3.11.1",
|
|
@@ -23,37 +23,21 @@ const SIZE = 'tiny';
|
|
|
23
23
|
const toChipsOption = ( val: string, options: ChipsOption[] ): ChipsOption =>
|
|
24
24
|
options.find( ( opt ) => opt.value === val ) ?? { label: val, value: val };
|
|
25
25
|
|
|
26
|
-
const optionValue = ( option: ChipsOption | string ): string => {
|
|
27
|
-
if ( 'string' === typeof option ) {
|
|
28
|
-
return option;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
return 'string' === typeof option?.value ? option.value : '';
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
const optionLabel = ( option: ChipsOption | string ): string => {
|
|
35
|
-
if ( 'string' === typeof option ) {
|
|
36
|
-
return option;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if ( 'string' === typeof option?.label ) {
|
|
40
|
-
return option.label;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return optionValue( option );
|
|
44
|
-
};
|
|
45
|
-
|
|
46
26
|
export const ChipsControl = createControl( ( { options, freeChips }: ChipsControlProps ) => {
|
|
47
27
|
const { value, setValue, disabled } = useBoundProp( stringArrayPropTypeUtil );
|
|
48
28
|
|
|
49
29
|
const selectedValues: string[] = ( value || [] )
|
|
50
30
|
.map( ( item ) => stringPropTypeUtil.extract( item ) )
|
|
51
|
-
.filter( ( val ): val is string =>
|
|
31
|
+
.filter( ( val ): val is string => val !== null );
|
|
52
32
|
|
|
53
33
|
const selectedOptions = selectedValues.map( ( val ) => toChipsOption( val, options ) );
|
|
54
34
|
|
|
55
35
|
const handleChange = ( _: SyntheticEvent, newValue: ( ChipsOption | string )[] ) => {
|
|
56
|
-
setValue(
|
|
36
|
+
setValue(
|
|
37
|
+
newValue.map( ( option ) =>
|
|
38
|
+
stringPropTypeUtil.create( typeof option === 'string' ? option : option.value )
|
|
39
|
+
)
|
|
40
|
+
);
|
|
57
41
|
};
|
|
58
42
|
|
|
59
43
|
return (
|
|
@@ -68,11 +52,15 @@ export const ChipsControl = createControl( ( { options, freeChips }: ChipsContro
|
|
|
68
52
|
filterSelectedOptions
|
|
69
53
|
onChange={ handleChange }
|
|
70
54
|
options={ options }
|
|
71
|
-
getOptionLabel={
|
|
72
|
-
isOptionEqualToValue={ ( option, val ) =>
|
|
55
|
+
getOptionLabel={ ( option ) => ( typeof option === 'string' ? option : option.label ) }
|
|
56
|
+
isOptionEqualToValue={ ( option, val ) => option.value === val.value }
|
|
73
57
|
renderInput={ ( params ) => <TextField { ...params } /> }
|
|
74
58
|
renderTags={ ( tagValues, getTagProps ) => (
|
|
75
|
-
<ChipsList
|
|
59
|
+
<ChipsList
|
|
60
|
+
getLabel={ ( option ) => ( typeof option === 'string' ? option : option.label ) }
|
|
61
|
+
getTagProps={ getTagProps }
|
|
62
|
+
values={ tagValues }
|
|
63
|
+
/>
|
|
76
64
|
) }
|
|
77
65
|
/>
|
|
78
66
|
</ControlActions>
|