@elementor/editor-editing-panel 1.21.0 → 1.22.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elementor/editor-editing-panel",
3
- "version": "1.21.0",
3
+ "version": "1.22.0",
4
4
  "private": false,
5
5
  "author": "Elementor Team",
6
6
  "homepage": "https://elementor.com/",
@@ -39,23 +39,23 @@
39
39
  "dev": "tsup --config=../../tsup.dev.ts"
40
40
  },
41
41
  "dependencies": {
42
- "@elementor/editor": "0.18.3",
43
- "@elementor/editor-controls": "0.19.0",
42
+ "@elementor/editor": "0.18.4",
43
+ "@elementor/editor-controls": "0.19.1",
44
44
  "@elementor/editor-current-user": "0.3.0",
45
- "@elementor/editor-elements": "0.6.5",
46
- "@elementor/editor-panels": "0.13.0",
45
+ "@elementor/editor-elements": "0.6.6",
46
+ "@elementor/editor-panels": "0.13.1",
47
47
  "@elementor/editor-props": "0.11.1",
48
48
  "@elementor/editor-responsive": "0.13.3",
49
49
  "@elementor/editor-styles": "0.6.4",
50
- "@elementor/editor-styles-repository": "0.7.8",
51
- "@elementor/editor-ui": "0.4.2",
50
+ "@elementor/editor-styles-repository": "0.8.0",
51
+ "@elementor/editor-ui": "0.4.3",
52
52
  "@elementor/editor-v1-adapters": "0.11.0",
53
53
  "@elementor/icons": "1.37.0",
54
- "@elementor/locations": "0.7.6",
55
- "@elementor/menus": "0.1.3",
54
+ "@elementor/locations": "0.7.7",
55
+ "@elementor/menus": "0.1.4",
56
56
  "@elementor/schema": "0.1.2",
57
57
  "@elementor/session": "0.1.0",
58
- "@elementor/ui": "1.26.0",
58
+ "@elementor/ui": "1.32.1",
59
59
  "@elementor/utils": "0.4.0",
60
60
  "@wordpress/i18n": "^5.13.0"
61
61
  },
@@ -165,6 +165,9 @@ function useCreateActions( {
165
165
  return {
166
166
  // translators: %s is the label of the new class.
167
167
  label: ( value ) => __( 'Create new "%s"', 'elementor' ).replace( '%s', value ),
168
+ // translators: %s is the singular label of css class provider (e.g "Global CSS Class").
169
+ group: __( 'Create New %s', 'elementor' ).replace( '%s', provider.labels?.singular ?? '' ),
170
+ condition: ( _, inputValue ) => isLabelValid( inputValue ) && ! hasReachedLimit( provider ),
168
171
  apply: ( label ) => {
169
172
  const createdId = create( label );
170
173
 
@@ -175,14 +178,22 @@ function useCreateActions( {
175
178
  pushAppliedId( createdId );
176
179
  setActiveId( createdId );
177
180
  },
178
- condition: ( _, inputValue ) =>
179
- stylesRepository.isLabelValid( inputValue ) && ! stylesRepository.isLabelExist( inputValue ),
180
- // translators: %s is the singular label of css class provider (e.g "Global CSS Class").
181
- group: __( 'Create New %s', 'elementor' ).replace( '%s', provider.labels?.singular ?? '' ),
182
181
  };
183
182
  } );
184
183
  }
185
184
 
185
+ function hasReachedLimit( provider: StylesProvider ) {
186
+ if ( provider.limit === undefined ) {
187
+ return false;
188
+ }
189
+
190
+ return provider.actions.get().length >= provider.limit;
191
+ }
192
+
193
+ function isLabelValid( newLabel: string ) {
194
+ return stylesRepository.isLabelValid( newLabel ) && ! stylesRepository.isLabelExist( newLabel );
195
+ }
196
+
186
197
  function useAppliedOptions( options: StyleDefOption[], appliedIds: StyleDefinitionID[] ) {
187
198
  const applied = options.filter( ( option ) => option.value && appliedIds.includes( option.value ) );
188
199
 
@@ -72,7 +72,7 @@ export function MultiCombobox< TOption extends Option >( {
72
72
  if ( reason === 'createOption' ) {
73
73
  const [ firstAction ] = filterActions( actions, { options, inputValue: inputValue ?? '' } );
74
74
 
75
- if ( firstAction.value ) {
75
+ if ( firstAction?.value ) {
76
76
  return run( firstAction.apply, firstAction.value );
77
77
  }
78
78
  }