@elementor/editor-variables 3.33.0-164 → 3.33.0-166
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 +9 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +9 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +14 -14
- package/src/components/fields/label-field.tsx +5 -1
- package/src/components/variables-manager/variables-manager-table.tsx +1 -0
- package/src/utils/validations.ts +7 -1
package/dist/index.js
CHANGED
|
@@ -800,7 +800,7 @@ var mapServerError = (error) => {
|
|
|
800
800
|
}
|
|
801
801
|
return void 0;
|
|
802
802
|
};
|
|
803
|
-
var validateLabel = (name) => {
|
|
803
|
+
var validateLabel = (name, variables) => {
|
|
804
804
|
if (!name.trim()) {
|
|
805
805
|
return ERROR_MESSAGES.MISSING_VARIABLE_NAME;
|
|
806
806
|
}
|
|
@@ -815,6 +815,9 @@ var validateLabel = (name) => {
|
|
|
815
815
|
if (VARIABLE_LABEL_MAX_LENGTH < name.length) {
|
|
816
816
|
return ERROR_MESSAGES.VARIABLE_LABEL_MAX_LENGTH;
|
|
817
817
|
}
|
|
818
|
+
if (Object.values(variables ?? {}).some((variable) => variable.label === name)) {
|
|
819
|
+
return ERROR_MESSAGES.DUPLICATED_LABEL;
|
|
820
|
+
}
|
|
818
821
|
return "";
|
|
819
822
|
};
|
|
820
823
|
var labelHint = (name) => {
|
|
@@ -1030,14 +1033,15 @@ var LabelField = ({
|
|
|
1030
1033
|
size = "tiny",
|
|
1031
1034
|
focusOnShow = false,
|
|
1032
1035
|
selectOnShow = false,
|
|
1033
|
-
showWarningInfotip = false
|
|
1036
|
+
showWarningInfotip = false,
|
|
1037
|
+
variables
|
|
1034
1038
|
}) => {
|
|
1035
1039
|
const [label, setLabel] = (0, import_react6.useState)(value);
|
|
1036
1040
|
const [errorMessage, setErrorMessage] = (0, import_react6.useState)("");
|
|
1037
1041
|
const fieldRef = (0, import_react6.useRef)(null);
|
|
1038
1042
|
const handleChange = (newValue) => {
|
|
1039
1043
|
setLabel(newValue);
|
|
1040
|
-
const errorMsg2 = validateLabel(newValue);
|
|
1044
|
+
const errorMsg2 = validateLabel(newValue, variables);
|
|
1041
1045
|
setErrorMessage(errorMsg2);
|
|
1042
1046
|
onErrorChange?.(errorMsg2);
|
|
1043
1047
|
onChange(isLabelEqual(newValue, error?.value ?? "") || errorMsg2 ? "" : newValue);
|
|
@@ -1437,7 +1441,8 @@ var VariablesManagerTable = ({
|
|
|
1437
1441
|
error,
|
|
1438
1442
|
focusOnShow: true,
|
|
1439
1443
|
selectOnShow: autoEditVariableId === row.id,
|
|
1440
|
-
showWarningInfotip: true
|
|
1444
|
+
showWarningInfotip: true,
|
|
1445
|
+
variables
|
|
1441
1446
|
}
|
|
1442
1447
|
),
|
|
1443
1448
|
autoEdit: autoEditVariableId === row.id,
|