@elementor/editor-variables 3.33.0-159 → 3.33.0-160
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 +31 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +31 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +14 -14
- package/src/components/variables-manager/variable-editable-cell.tsx +17 -4
- package/src/components/variables-manager/variables-manager-table.tsx +17 -1
package/dist/index.js
CHANGED
|
@@ -1131,11 +1131,15 @@ var VariableEditableCell = React9.memo(
|
|
|
1131
1131
|
const [value, setValue] = (0, import_react8.useState)(initialValue);
|
|
1132
1132
|
const [isEditing, setIsEditing] = (0, import_react8.useState)(false);
|
|
1133
1133
|
const { labelFieldError, setLabelFieldError } = useLabelError();
|
|
1134
|
+
const [valueFieldError, setValueFieldError] = (0, import_react8.useState)("");
|
|
1134
1135
|
const rowRef = (0, import_react8.useRef)(null);
|
|
1135
1136
|
const handleSave = (0, import_react8.useCallback)(() => {
|
|
1136
|
-
|
|
1137
|
+
const hasError = fieldType === "label" && labelFieldError?.message || fieldType === "value" && valueFieldError;
|
|
1138
|
+
if (!hasError) {
|
|
1139
|
+
onChange(value);
|
|
1140
|
+
}
|
|
1137
1141
|
setIsEditing(false);
|
|
1138
|
-
}, [value, onChange]);
|
|
1142
|
+
}, [value, onChange, fieldType, labelFieldError, valueFieldError]);
|
|
1139
1143
|
(0, import_react8.useEffect)(() => {
|
|
1140
1144
|
onRowRef?.(rowRef?.current);
|
|
1141
1145
|
}, [onRowRef]);
|
|
@@ -1169,11 +1173,18 @@ var VariableEditableCell = React9.memo(
|
|
|
1169
1173
|
value,
|
|
1170
1174
|
message: errorMsg
|
|
1171
1175
|
});
|
|
1176
|
+
} else {
|
|
1177
|
+
setValueFieldError(errorMsg);
|
|
1172
1178
|
}
|
|
1173
1179
|
},
|
|
1174
|
-
[fieldType, value, setLabelFieldError]
|
|
1180
|
+
[fieldType, value, setLabelFieldError, setValueFieldError]
|
|
1175
1181
|
);
|
|
1176
|
-
|
|
1182
|
+
let currentError;
|
|
1183
|
+
if (fieldType === "label") {
|
|
1184
|
+
currentError = labelFieldError;
|
|
1185
|
+
} else if (fieldType === "value") {
|
|
1186
|
+
currentError = { value, message: valueFieldError };
|
|
1187
|
+
}
|
|
1177
1188
|
const editableContent = editableElement({
|
|
1178
1189
|
value,
|
|
1179
1190
|
onChange: handleChange,
|
|
@@ -1405,9 +1416,23 @@ var VariablesManagerTable = ({
|
|
|
1405
1416
|
});
|
|
1406
1417
|
}
|
|
1407
1418
|
},
|
|
1408
|
-
editableElement:
|
|
1419
|
+
editableElement: ({
|
|
1420
|
+
value,
|
|
1421
|
+
onChange,
|
|
1422
|
+
onValidationChange,
|
|
1423
|
+
error
|
|
1424
|
+
}) => row.valueField({
|
|
1425
|
+
value,
|
|
1426
|
+
onChange,
|
|
1427
|
+
onValidationChange: (errorMsg) => {
|
|
1428
|
+
onValidationChange?.(errorMsg);
|
|
1429
|
+
onFieldError?.(!!errorMsg);
|
|
1430
|
+
},
|
|
1431
|
+
error
|
|
1432
|
+
}),
|
|
1409
1433
|
onRowRef: handleRowRef(row.id),
|
|
1410
|
-
gap: 0.25
|
|
1434
|
+
gap: 0.25,
|
|
1435
|
+
fieldType: "value"
|
|
1411
1436
|
},
|
|
1412
1437
|
row.startIcon && row.startIcon({ value: row.value }),
|
|
1413
1438
|
/* @__PURE__ */ React10.createElement(
|