@elementor/editor-variables 4.0.0-641 → 4.0.0-643

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 CHANGED
@@ -1264,12 +1264,17 @@ var MenuOption = ({
1264
1264
  };
1265
1265
  var getDefaultName = (variables, baseName) => {
1266
1266
  const pattern = new RegExp(`^${baseName}-(\\d+)$`, "i");
1267
- let counter = 1;
1267
+ const takenNumbers = /* @__PURE__ */ new Set();
1268
1268
  Object.values(variables).forEach((variable) => {
1269
- if (pattern.test(variable.label)) {
1270
- counter = Math.max(counter, parseInt(variable.label.match(pattern)?.[1] ?? "0", 10) + 1);
1269
+ const match = variable.label.match(pattern);
1270
+ if (match) {
1271
+ takenNumbers.add(parseInt(match[1], 10));
1271
1272
  }
1272
1273
  });
1274
+ let counter = 1;
1275
+ while (takenNumbers.has(counter)) {
1276
+ counter++;
1277
+ }
1273
1278
  return `${baseName}-${counter}`;
1274
1279
  };
1275
1280