@elementor/editor-variables 4.0.0-609 → 4.0.0-621
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
|
@@ -1224,7 +1224,7 @@ var MenuOption = ({
|
|
|
1224
1224
|
promotionRef.current?.toggle();
|
|
1225
1225
|
return;
|
|
1226
1226
|
}
|
|
1227
|
-
const defaultName = getDefaultName(variables, config.
|
|
1227
|
+
const defaultName = getDefaultName(variables, config.variableType);
|
|
1228
1228
|
onCreate(config.key, defaultName, config.defaultValue);
|
|
1229
1229
|
trackVariablesManagerEvent({ action: "add", varType: config.variableType });
|
|
1230
1230
|
onClose();
|
|
@@ -1238,15 +1238,15 @@ var MenuOption = ({
|
|
|
1238
1238
|
}
|
|
1239
1239
|
));
|
|
1240
1240
|
};
|
|
1241
|
-
var getDefaultName = (variables,
|
|
1242
|
-
const
|
|
1241
|
+
var getDefaultName = (variables, baseName) => {
|
|
1242
|
+
const pattern = new RegExp(`^${baseName}-(\\d+)$`, "i");
|
|
1243
1243
|
let counter = 1;
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
}
|
|
1249
|
-
return
|
|
1244
|
+
Object.values(variables).forEach((variable) => {
|
|
1245
|
+
if (pattern.test(variable.label)) {
|
|
1246
|
+
counter = Math.max(counter, parseInt(variable.label.match(pattern)?.[1] ?? "0", 10) + 1);
|
|
1247
|
+
}
|
|
1248
|
+
});
|
|
1249
|
+
return `${baseName}-${counter}`;
|
|
1250
1250
|
};
|
|
1251
1251
|
|
|
1252
1252
|
// src/components/variables-manager/variables-manager-table.tsx
|