@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/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # Change Log
2
2
 
3
+ ## 1.22.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 202ff33: Set max global classes creation limit.
8
+
9
+ ### Patch Changes
10
+
11
+ - 3e108d9: update elementor/ui
12
+ - 700303b: Prevent creation attempt to invalid css class.
13
+ - Updated dependencies [3e108d9]
14
+ - Updated dependencies [202ff33]
15
+ - Updated dependencies [593f222]
16
+ - @elementor/editor-controls@0.19.1
17
+ - @elementor/editor-panels@0.13.1
18
+ - @elementor/editor-ui@0.4.3
19
+ - @elementor/locations@0.7.7
20
+ - @elementor/editor@0.18.4
21
+ - @elementor/menus@0.1.4
22
+ - @elementor/editor-styles-repository@0.8.0
23
+ - @elementor/editor-elements@0.6.6
24
+
3
25
  ## 1.21.0
4
26
 
5
27
  ### Minor Changes
package/dist/index.js CHANGED
@@ -163,7 +163,7 @@ function MultiCombobox({
163
163
  const optionsAndActions = selectedOrInputValue.filter((option) => typeof option !== "string");
164
164
  if (reason === "createOption") {
165
165
  const [firstAction] = filterActions(actions, { options: options13, inputValue: inputValue ?? "" });
166
- if (firstAction.value) {
166
+ if (firstAction?.value) {
167
167
  return run(firstAction.apply, firstAction.value);
168
168
  }
169
169
  }
@@ -590,6 +590,9 @@ function useCreateActions({
590
590
  return {
591
591
  // translators: %s is the label of the new class.
592
592
  label: (value) => (0, import_i18n3.__)('Create new "%s"', "elementor").replace("%s", value),
593
+ // translators: %s is the singular label of css class provider (e.g "Global CSS Class").
594
+ group: (0, import_i18n3.__)("Create New %s", "elementor").replace("%s", provider.labels?.singular ?? ""),
595
+ condition: (_, inputValue) => isLabelValid(inputValue) && !hasReachedLimit(provider),
593
596
  apply: (label) => {
594
597
  const createdId = create(label);
595
598
  if (!createdId) {
@@ -597,13 +600,19 @@ function useCreateActions({
597
600
  }
598
601
  pushAppliedId(createdId);
599
602
  setActiveId(createdId);
600
- },
601
- condition: (_, inputValue) => import_editor_styles_repository4.stylesRepository.isLabelValid(inputValue) && !import_editor_styles_repository4.stylesRepository.isLabelExist(inputValue),
602
- // translators: %s is the singular label of css class provider (e.g "Global CSS Class").
603
- group: (0, import_i18n3.__)("Create New %s", "elementor").replace("%s", provider.labels?.singular ?? "")
603
+ }
604
604
  };
605
605
  });
606
606
  }
607
+ function hasReachedLimit(provider) {
608
+ if (provider.limit === void 0) {
609
+ return false;
610
+ }
611
+ return provider.actions.get().length >= provider.limit;
612
+ }
613
+ function isLabelValid(newLabel) {
614
+ return import_editor_styles_repository4.stylesRepository.isLabelValid(newLabel) && !import_editor_styles_repository4.stylesRepository.isLabelExist(newLabel);
615
+ }
607
616
  function useAppliedOptions(options13, appliedIds) {
608
617
  const applied = options13.filter((option) => option.value && appliedIds.includes(option.value));
609
618
  const hasElementsProviderStyleApplied = applied.some(