@tecof/theme-editor 0.0.23 → 0.0.24
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 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +9 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -984,8 +984,11 @@ var LanguageField = ({
|
|
|
984
984
|
return existing || { code, value: "" };
|
|
985
985
|
});
|
|
986
986
|
}, [value, merchantInfo]);
|
|
987
|
+
const valuesRef = React__default.useRef(values);
|
|
988
|
+
valuesRef.current = values;
|
|
987
989
|
const handleChange = React__default.useCallback((code, newVal) => {
|
|
988
|
-
const
|
|
990
|
+
const current = valuesRef.current;
|
|
991
|
+
const updated = [...current];
|
|
989
992
|
const idx = updated.findIndex((v2) => v2.code === code);
|
|
990
993
|
if (idx >= 0) {
|
|
991
994
|
updated[idx] = { ...updated[idx], value: newVal };
|
|
@@ -993,10 +996,10 @@ var LanguageField = ({
|
|
|
993
996
|
updated.push({ code, value: newVal });
|
|
994
997
|
}
|
|
995
998
|
onChange(updated);
|
|
996
|
-
}, [
|
|
999
|
+
}, [onChange]);
|
|
997
1000
|
const getCurrentText = React__default.useCallback(() => {
|
|
998
|
-
return
|
|
999
|
-
}, [
|
|
1001
|
+
return valuesRef.current.find((v2) => v2.code === activeTab)?.value || "";
|
|
1002
|
+
}, [activeTab]);
|
|
1000
1003
|
const handleFastFill = React__default.useCallback(() => {
|
|
1001
1004
|
const text2 = getCurrentText();
|
|
1002
1005
|
if (!text2) return;
|
|
@@ -1019,7 +1022,7 @@ var LanguageField = ({
|
|
|
1019
1022
|
try {
|
|
1020
1023
|
const res2 = await apiClient.translate(text2, activeTab, otherLocales, isHtml);
|
|
1021
1024
|
if (res2.success && Array.isArray(res2.data)) {
|
|
1022
|
-
const updated = [...
|
|
1025
|
+
const updated = [...valuesRef.current];
|
|
1023
1026
|
for (const t2 of res2.data) {
|
|
1024
1027
|
const idx = updated.findIndex((v2) => v2.code === t2.code);
|
|
1025
1028
|
if (idx >= 0) {
|
|
@@ -1039,7 +1042,7 @@ var LanguageField = ({
|
|
|
1039
1042
|
setTranslating(false);
|
|
1040
1043
|
setTimeout(() => setStatusMsg(null), 3e3);
|
|
1041
1044
|
}
|
|
1042
|
-
}, [getCurrentText, merchantInfo, activeTab,
|
|
1045
|
+
}, [getCurrentText, merchantInfo, activeTab, onChange, apiClient, isHtml]);
|
|
1043
1046
|
if (loading) return /* @__PURE__ */ jsxRuntime.jsx(FieldLoading, {});
|
|
1044
1047
|
if (error2 && !merchantInfo) return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "tecof-lang-error", children: error2 });
|
|
1045
1048
|
if (!merchantInfo) return null;
|