@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.mjs
CHANGED
|
@@ -946,8 +946,11 @@ var LanguageField = ({
|
|
|
946
946
|
return existing || { code, value: "" };
|
|
947
947
|
});
|
|
948
948
|
}, [value, merchantInfo]);
|
|
949
|
+
const valuesRef = useRef(values);
|
|
950
|
+
valuesRef.current = values;
|
|
949
951
|
const handleChange = useCallback((code, newVal) => {
|
|
950
|
-
const
|
|
952
|
+
const current = valuesRef.current;
|
|
953
|
+
const updated = [...current];
|
|
951
954
|
const idx = updated.findIndex((v2) => v2.code === code);
|
|
952
955
|
if (idx >= 0) {
|
|
953
956
|
updated[idx] = { ...updated[idx], value: newVal };
|
|
@@ -955,10 +958,10 @@ var LanguageField = ({
|
|
|
955
958
|
updated.push({ code, value: newVal });
|
|
956
959
|
}
|
|
957
960
|
onChange(updated);
|
|
958
|
-
}, [
|
|
961
|
+
}, [onChange]);
|
|
959
962
|
const getCurrentText = useCallback(() => {
|
|
960
|
-
return
|
|
961
|
-
}, [
|
|
963
|
+
return valuesRef.current.find((v2) => v2.code === activeTab)?.value || "";
|
|
964
|
+
}, [activeTab]);
|
|
962
965
|
const handleFastFill = useCallback(() => {
|
|
963
966
|
const text2 = getCurrentText();
|
|
964
967
|
if (!text2) return;
|
|
@@ -981,7 +984,7 @@ var LanguageField = ({
|
|
|
981
984
|
try {
|
|
982
985
|
const res2 = await apiClient.translate(text2, activeTab, otherLocales, isHtml);
|
|
983
986
|
if (res2.success && Array.isArray(res2.data)) {
|
|
984
|
-
const updated = [...
|
|
987
|
+
const updated = [...valuesRef.current];
|
|
985
988
|
for (const t2 of res2.data) {
|
|
986
989
|
const idx = updated.findIndex((v2) => v2.code === t2.code);
|
|
987
990
|
if (idx >= 0) {
|
|
@@ -1001,7 +1004,7 @@ var LanguageField = ({
|
|
|
1001
1004
|
setTranslating(false);
|
|
1002
1005
|
setTimeout(() => setStatusMsg(null), 3e3);
|
|
1003
1006
|
}
|
|
1004
|
-
}, [getCurrentText, merchantInfo, activeTab,
|
|
1007
|
+
}, [getCurrentText, merchantInfo, activeTab, onChange, apiClient, isHtml]);
|
|
1005
1008
|
if (loading) return /* @__PURE__ */ jsx(FieldLoading, {});
|
|
1006
1009
|
if (error2 && !merchantInfo) return /* @__PURE__ */ jsx("div", { className: "tecof-lang-error", children: error2 });
|
|
1007
1010
|
if (!merchantInfo) return null;
|