@elementor/editor-variables 4.0.0-641 → 4.0.0-642
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.mjs
CHANGED
|
@@ -1240,12 +1240,17 @@ var MenuOption = ({
|
|
|
1240
1240
|
};
|
|
1241
1241
|
var getDefaultName = (variables, baseName) => {
|
|
1242
1242
|
const pattern = new RegExp(`^${baseName}-(\\d+)$`, "i");
|
|
1243
|
-
|
|
1243
|
+
const takenNumbers = /* @__PURE__ */ new Set();
|
|
1244
1244
|
Object.values(variables).forEach((variable) => {
|
|
1245
|
-
|
|
1246
|
-
|
|
1245
|
+
const match = variable.label.match(pattern);
|
|
1246
|
+
if (match) {
|
|
1247
|
+
takenNumbers.add(parseInt(match[1], 10));
|
|
1247
1248
|
}
|
|
1248
1249
|
});
|
|
1250
|
+
let counter = 1;
|
|
1251
|
+
while (takenNumbers.has(counter)) {
|
|
1252
|
+
counter++;
|
|
1253
|
+
}
|
|
1249
1254
|
return `${baseName}-${counter}`;
|
|
1250
1255
|
};
|
|
1251
1256
|
|