@tecof/theme-editor 0.0.24 → 0.0.26
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.d.mts +35 -2
- package/dist/index.d.ts +35 -2
- package/dist/index.js +156 -33
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +157 -35
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +224 -57
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import * as react from 'react';
|
|
3
|
-
import react__default, { ReactElement } from 'react';
|
|
3
|
+
import react__default, { ReactElement, Component, ReactNode, ErrorInfo } from 'react';
|
|
4
4
|
|
|
5
5
|
interface ThemeColors {
|
|
6
6
|
primary: string;
|
|
@@ -578,6 +578,39 @@ declare const createColorField: (options?: ColorFieldOptions) => {
|
|
|
578
578
|
render: ({ value, onChange, readOnly, field, name, id }: ColorFieldProps) => react_jsx_runtime.JSX.Element;
|
|
579
579
|
};
|
|
580
580
|
|
|
581
|
+
interface FieldErrorBoundaryProps {
|
|
582
|
+
/** The field name (for error reporting) */
|
|
583
|
+
fieldName?: string;
|
|
584
|
+
/** Fallback UI to show when a field crashes */
|
|
585
|
+
fallback?: ReactNode;
|
|
586
|
+
/** Optional error callback */
|
|
587
|
+
onError?: (error: Error, errorInfo: ErrorInfo) => void;
|
|
588
|
+
children: ReactNode;
|
|
589
|
+
}
|
|
590
|
+
interface FieldErrorBoundaryState {
|
|
591
|
+
hasError: boolean;
|
|
592
|
+
error: Error | null;
|
|
593
|
+
}
|
|
594
|
+
/**
|
|
595
|
+
* Error boundary for Puck custom fields.
|
|
596
|
+
* Catches render errors in child components and shows a friendly fallback
|
|
597
|
+
* instead of crashing the entire editor.
|
|
598
|
+
*
|
|
599
|
+
* @example
|
|
600
|
+
* ```tsx
|
|
601
|
+
* <FieldErrorBoundary fieldName="title">
|
|
602
|
+
* <LanguageField ... />
|
|
603
|
+
* </FieldErrorBoundary>
|
|
604
|
+
* ```
|
|
605
|
+
*/
|
|
606
|
+
declare class FieldErrorBoundary extends Component<FieldErrorBoundaryProps, FieldErrorBoundaryState> {
|
|
607
|
+
constructor(props: FieldErrorBoundaryProps);
|
|
608
|
+
static getDerivedStateFromError(error: Error): FieldErrorBoundaryState;
|
|
609
|
+
componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
|
|
610
|
+
handleRetry: () => void;
|
|
611
|
+
render(): string | number | bigint | boolean | Iterable<ReactNode> | Promise<string | number | bigint | boolean | react.ReactPortal | react.ReactElement<unknown, string | react.JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | react_jsx_runtime.JSX.Element | null | undefined;
|
|
612
|
+
}
|
|
613
|
+
|
|
581
614
|
declare function hexToHsl(hex: string): HSL;
|
|
582
615
|
declare function hslToHex(h: number, s: number, l: number): string;
|
|
583
616
|
declare function lighten(hex: string, amount: number): string;
|
|
@@ -586,4 +619,4 @@ declare function generateCSSVariables(theme: ThemeConfig): string;
|
|
|
586
619
|
declare function getDefaultTheme(): ThemeConfig;
|
|
587
620
|
declare function mergeTheme(base: ThemeConfig, overrides: Partial<ThemeConfig>): ThemeConfig;
|
|
588
621
|
|
|
589
|
-
export { type ApiResponse, CodeEditorField, ColorField, EditorField, type HSL, LanguageField, type LanguageFieldValue, LinkField, type LinkFieldValue, type MerchantInfoData, type PageApiData, type PuckContentItem, type PuckPageData, TecofApiClient, TecofEditor, type TecofEditorProps, TecofPicture, type TecofPictureProps, TecofProvider, type TecofProviderProps, TecofRender, type TecofRenderProps, type ThemeColors, type ThemeConfig, type ThemeSpacing, type ThemeTypography, UploadField, type UploadedFile, createCodeEditorField, createColorField, createEditorField, createLanguageField, createLinkField, createUploadField, darken, generateCSSVariables, getDefaultTheme, hexToHsl, hslToHex, lighten, mergeTheme, useTecof };
|
|
622
|
+
export { type ApiResponse, CodeEditorField, ColorField, EditorField, FieldErrorBoundary, type HSL, LanguageField, type LanguageFieldValue, LinkField, type LinkFieldValue, type MerchantInfoData, type PageApiData, type PuckContentItem, type PuckPageData, TecofApiClient, TecofEditor, type TecofEditorProps, TecofPicture, type TecofPictureProps, TecofProvider, type TecofProviderProps, TecofRender, type TecofRenderProps, type ThemeColors, type ThemeConfig, type ThemeSpacing, type ThemeTypography, UploadField, type UploadedFile, createCodeEditorField, createColorField, createEditorField, createLanguageField, createLinkField, createUploadField, darken, generateCSSVariables, getDefaultTheme, hexToHsl, hslToHex, lighten, mergeTheme, useTecof };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import * as react from 'react';
|
|
3
|
-
import react__default, { ReactElement } from 'react';
|
|
3
|
+
import react__default, { ReactElement, Component, ReactNode, ErrorInfo } from 'react';
|
|
4
4
|
|
|
5
5
|
interface ThemeColors {
|
|
6
6
|
primary: string;
|
|
@@ -578,6 +578,39 @@ declare const createColorField: (options?: ColorFieldOptions) => {
|
|
|
578
578
|
render: ({ value, onChange, readOnly, field, name, id }: ColorFieldProps) => react_jsx_runtime.JSX.Element;
|
|
579
579
|
};
|
|
580
580
|
|
|
581
|
+
interface FieldErrorBoundaryProps {
|
|
582
|
+
/** The field name (for error reporting) */
|
|
583
|
+
fieldName?: string;
|
|
584
|
+
/** Fallback UI to show when a field crashes */
|
|
585
|
+
fallback?: ReactNode;
|
|
586
|
+
/** Optional error callback */
|
|
587
|
+
onError?: (error: Error, errorInfo: ErrorInfo) => void;
|
|
588
|
+
children: ReactNode;
|
|
589
|
+
}
|
|
590
|
+
interface FieldErrorBoundaryState {
|
|
591
|
+
hasError: boolean;
|
|
592
|
+
error: Error | null;
|
|
593
|
+
}
|
|
594
|
+
/**
|
|
595
|
+
* Error boundary for Puck custom fields.
|
|
596
|
+
* Catches render errors in child components and shows a friendly fallback
|
|
597
|
+
* instead of crashing the entire editor.
|
|
598
|
+
*
|
|
599
|
+
* @example
|
|
600
|
+
* ```tsx
|
|
601
|
+
* <FieldErrorBoundary fieldName="title">
|
|
602
|
+
* <LanguageField ... />
|
|
603
|
+
* </FieldErrorBoundary>
|
|
604
|
+
* ```
|
|
605
|
+
*/
|
|
606
|
+
declare class FieldErrorBoundary extends Component<FieldErrorBoundaryProps, FieldErrorBoundaryState> {
|
|
607
|
+
constructor(props: FieldErrorBoundaryProps);
|
|
608
|
+
static getDerivedStateFromError(error: Error): FieldErrorBoundaryState;
|
|
609
|
+
componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
|
|
610
|
+
handleRetry: () => void;
|
|
611
|
+
render(): string | number | bigint | boolean | Iterable<ReactNode> | Promise<string | number | bigint | boolean | react.ReactPortal | react.ReactElement<unknown, string | react.JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | react_jsx_runtime.JSX.Element | null | undefined;
|
|
612
|
+
}
|
|
613
|
+
|
|
581
614
|
declare function hexToHsl(hex: string): HSL;
|
|
582
615
|
declare function hslToHex(h: number, s: number, l: number): string;
|
|
583
616
|
declare function lighten(hex: string, amount: number): string;
|
|
@@ -586,4 +619,4 @@ declare function generateCSSVariables(theme: ThemeConfig): string;
|
|
|
586
619
|
declare function getDefaultTheme(): ThemeConfig;
|
|
587
620
|
declare function mergeTheme(base: ThemeConfig, overrides: Partial<ThemeConfig>): ThemeConfig;
|
|
588
621
|
|
|
589
|
-
export { type ApiResponse, CodeEditorField, ColorField, EditorField, type HSL, LanguageField, type LanguageFieldValue, LinkField, type LinkFieldValue, type MerchantInfoData, type PageApiData, type PuckContentItem, type PuckPageData, TecofApiClient, TecofEditor, type TecofEditorProps, TecofPicture, type TecofPictureProps, TecofProvider, type TecofProviderProps, TecofRender, type TecofRenderProps, type ThemeColors, type ThemeConfig, type ThemeSpacing, type ThemeTypography, UploadField, type UploadedFile, createCodeEditorField, createColorField, createEditorField, createLanguageField, createLinkField, createUploadField, darken, generateCSSVariables, getDefaultTheme, hexToHsl, hslToHex, lighten, mergeTheme, useTecof };
|
|
622
|
+
export { type ApiResponse, CodeEditorField, ColorField, EditorField, FieldErrorBoundary, type HSL, LanguageField, type LanguageFieldValue, LinkField, type LinkFieldValue, type MerchantInfoData, type PageApiData, type PuckContentItem, type PuckPageData, TecofApiClient, TecofEditor, type TecofEditorProps, TecofPicture, type TecofPictureProps, TecofProvider, type TecofProviderProps, TecofRender, type TecofRenderProps, type ThemeColors, type ThemeConfig, type ThemeSpacing, type ThemeTypography, UploadField, type UploadedFile, createCodeEditorField, createColorField, createEditorField, createLanguageField, createLinkField, createUploadField, darken, generateCSSVariables, getDefaultTheme, hexToHsl, hslToHex, lighten, mergeTheme, useTecof };
|
package/dist/index.js
CHANGED
|
@@ -545,8 +545,9 @@ var TecofPicture = React__default.memo(({
|
|
|
545
545
|
const { apiClient } = useTecof();
|
|
546
546
|
const cdnUrl = apiClient.cdnUrl;
|
|
547
547
|
if (!data3) return null;
|
|
548
|
+
const buildPath = (fileName) => data3?.folder && data3.folder !== "/" ? `${data3.folder.replace(/^\//, "")}/${fileName}` : fileName;
|
|
548
549
|
const isExternal = data3?.type === "external" || data3?.provider === "external";
|
|
549
|
-
const fileURL = isExternal ? data3?.url || "" : `${cdnUrl}/${data3?.name}`;
|
|
550
|
+
const fileURL = isExternal ? data3?.url || "" : `${cdnUrl}/${buildPath(data3?.name)}`;
|
|
550
551
|
const isImageType2 = isExternal ? true : isImage(data3?.type);
|
|
551
552
|
const isVideoType = isExternal ? false : isVideo(data3?.type);
|
|
552
553
|
if (!fileURL) return null;
|
|
@@ -741,7 +742,7 @@ var Icon = React__default.forwardRef(
|
|
|
741
742
|
|
|
742
743
|
// node_modules/lucide-react/dist/esm/createLucideIcon.js
|
|
743
744
|
var createLucideIcon = (iconName, iconNode) => {
|
|
744
|
-
const
|
|
745
|
+
const Component2 = React__default.forwardRef(
|
|
745
746
|
({ className, ...props }, ref) => React__default.createElement(Icon, {
|
|
746
747
|
ref,
|
|
747
748
|
iconNode,
|
|
@@ -753,8 +754,8 @@ var createLucideIcon = (iconName, iconNode) => {
|
|
|
753
754
|
...props
|
|
754
755
|
})
|
|
755
756
|
);
|
|
756
|
-
|
|
757
|
-
return
|
|
757
|
+
Component2.displayName = toPascalCase(iconName);
|
|
758
|
+
return Component2;
|
|
758
759
|
};
|
|
759
760
|
|
|
760
761
|
// node_modules/lucide-react/dist/esm/icons/check.js
|
|
@@ -936,6 +937,50 @@ var __iconNode21 = [
|
|
|
936
937
|
["path", { d: "m6 6 12 12", key: "d8bk6v" }]
|
|
937
938
|
];
|
|
938
939
|
var X = createLucideIcon("x", __iconNode21);
|
|
940
|
+
var FieldErrorBoundary = class extends React__default.Component {
|
|
941
|
+
constructor(props) {
|
|
942
|
+
super(props);
|
|
943
|
+
this.handleRetry = () => {
|
|
944
|
+
this.setState({ hasError: false, error: null });
|
|
945
|
+
};
|
|
946
|
+
this.state = { hasError: false, error: null };
|
|
947
|
+
}
|
|
948
|
+
static getDerivedStateFromError(error2) {
|
|
949
|
+
return { hasError: true, error: error2 };
|
|
950
|
+
}
|
|
951
|
+
componentDidCatch(error2, errorInfo) {
|
|
952
|
+
console.error(
|
|
953
|
+
`[TecofEditor] Field "${this.props.fieldName || "unknown"}" crashed:`,
|
|
954
|
+
error2,
|
|
955
|
+
errorInfo
|
|
956
|
+
);
|
|
957
|
+
this.props.onError?.(error2, errorInfo);
|
|
958
|
+
}
|
|
959
|
+
render() {
|
|
960
|
+
if (this.state.hasError) {
|
|
961
|
+
if (this.props.fallback) {
|
|
962
|
+
return this.props.fallback;
|
|
963
|
+
}
|
|
964
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "tecof-field-error-boundary", children: [
|
|
965
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "tecof-field-error-icon", children: "\u26A0\uFE0F" }),
|
|
966
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "tecof-field-error-content", children: [
|
|
967
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "tecof-field-error-title", children: "Bu alan y\xFCklenemedi" }),
|
|
968
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "tecof-field-error-detail", children: this.state.error?.message || "Beklenmeyen bir hata olu\u015Ftu" })
|
|
969
|
+
] }),
|
|
970
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
971
|
+
"button",
|
|
972
|
+
{
|
|
973
|
+
type: "button",
|
|
974
|
+
className: "tecof-field-error-retry",
|
|
975
|
+
onClick: this.handleRetry,
|
|
976
|
+
children: "Tekrar Dene"
|
|
977
|
+
}
|
|
978
|
+
)
|
|
979
|
+
] });
|
|
980
|
+
}
|
|
981
|
+
return this.props.children;
|
|
982
|
+
}
|
|
983
|
+
};
|
|
939
984
|
var LanguageTabBar = ({
|
|
940
985
|
languages,
|
|
941
986
|
defaultLanguage,
|
|
@@ -963,6 +1008,73 @@ var FieldLoading = () => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "te
|
|
|
963
1008
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "tecof-lang-loading-dot" }),
|
|
964
1009
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "tecof-lang-loading-dot" })
|
|
965
1010
|
] });
|
|
1011
|
+
var StableInput = ({
|
|
1012
|
+
value: externalValue,
|
|
1013
|
+
onChange,
|
|
1014
|
+
disabled,
|
|
1015
|
+
placeholder,
|
|
1016
|
+
className
|
|
1017
|
+
}) => {
|
|
1018
|
+
const [localValue, setLocalValue] = React__default.useState(externalValue);
|
|
1019
|
+
const lastEmitted = React__default.useRef(externalValue);
|
|
1020
|
+
React__default.useEffect(() => {
|
|
1021
|
+
if (externalValue !== lastEmitted.current) {
|
|
1022
|
+
setLocalValue(externalValue);
|
|
1023
|
+
lastEmitted.current = externalValue;
|
|
1024
|
+
}
|
|
1025
|
+
}, [externalValue]);
|
|
1026
|
+
const handleChange = (e3) => {
|
|
1027
|
+
const val = e3.target.value;
|
|
1028
|
+
setLocalValue(val);
|
|
1029
|
+
lastEmitted.current = val;
|
|
1030
|
+
onChange(val);
|
|
1031
|
+
};
|
|
1032
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1033
|
+
"input",
|
|
1034
|
+
{
|
|
1035
|
+
type: "text",
|
|
1036
|
+
value: localValue,
|
|
1037
|
+
onChange: handleChange,
|
|
1038
|
+
disabled,
|
|
1039
|
+
placeholder,
|
|
1040
|
+
className
|
|
1041
|
+
}
|
|
1042
|
+
);
|
|
1043
|
+
};
|
|
1044
|
+
var StableTextarea = ({
|
|
1045
|
+
value: externalValue,
|
|
1046
|
+
onChange,
|
|
1047
|
+
disabled,
|
|
1048
|
+
placeholder,
|
|
1049
|
+
className,
|
|
1050
|
+
rows
|
|
1051
|
+
}) => {
|
|
1052
|
+
const [localValue, setLocalValue] = React__default.useState(externalValue);
|
|
1053
|
+
const lastEmitted = React__default.useRef(externalValue);
|
|
1054
|
+
React__default.useEffect(() => {
|
|
1055
|
+
if (externalValue !== lastEmitted.current) {
|
|
1056
|
+
setLocalValue(externalValue);
|
|
1057
|
+
lastEmitted.current = externalValue;
|
|
1058
|
+
}
|
|
1059
|
+
}, [externalValue]);
|
|
1060
|
+
const handleChange = (e3) => {
|
|
1061
|
+
const val = e3.target.value;
|
|
1062
|
+
setLocalValue(val);
|
|
1063
|
+
lastEmitted.current = val;
|
|
1064
|
+
onChange(val);
|
|
1065
|
+
};
|
|
1066
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1067
|
+
"textarea",
|
|
1068
|
+
{
|
|
1069
|
+
value: localValue,
|
|
1070
|
+
onChange: handleChange,
|
|
1071
|
+
rows,
|
|
1072
|
+
disabled,
|
|
1073
|
+
placeholder,
|
|
1074
|
+
className
|
|
1075
|
+
}
|
|
1076
|
+
);
|
|
1077
|
+
};
|
|
966
1078
|
var LanguageField = ({
|
|
967
1079
|
value,
|
|
968
1080
|
onChange,
|
|
@@ -986,6 +1098,8 @@ var LanguageField = ({
|
|
|
986
1098
|
}, [value, merchantInfo]);
|
|
987
1099
|
const valuesRef = React__default.useRef(values);
|
|
988
1100
|
valuesRef.current = values;
|
|
1101
|
+
const onChangeRef = React__default.useRef(onChange);
|
|
1102
|
+
onChangeRef.current = onChange;
|
|
989
1103
|
const handleChange = React__default.useCallback((code, newVal) => {
|
|
990
1104
|
const current = valuesRef.current;
|
|
991
1105
|
const updated = [...current];
|
|
@@ -995,8 +1109,8 @@ var LanguageField = ({
|
|
|
995
1109
|
} else {
|
|
996
1110
|
updated.push({ code, value: newVal });
|
|
997
1111
|
}
|
|
998
|
-
|
|
999
|
-
}, [
|
|
1112
|
+
onChangeRef.current(updated);
|
|
1113
|
+
}, []);
|
|
1000
1114
|
const getCurrentText = React__default.useCallback(() => {
|
|
1001
1115
|
return valuesRef.current.find((v2) => v2.code === activeTab)?.value || "";
|
|
1002
1116
|
}, [activeTab]);
|
|
@@ -1008,10 +1122,10 @@ var LanguageField = ({
|
|
|
1008
1122
|
code,
|
|
1009
1123
|
value: text2
|
|
1010
1124
|
}));
|
|
1011
|
-
|
|
1125
|
+
onChangeRef.current(updated);
|
|
1012
1126
|
setStatusMsg({ text: "T\xFCm dillere kopyaland\u0131", type: "success" });
|
|
1013
1127
|
setTimeout(() => setStatusMsg(null), 2e3);
|
|
1014
|
-
}, [getCurrentText, merchantInfo
|
|
1128
|
+
}, [getCurrentText, merchantInfo]);
|
|
1015
1129
|
const handleTranslate = React__default.useCallback(async () => {
|
|
1016
1130
|
const text2 = getCurrentText();
|
|
1017
1131
|
if (!text2 || !merchantInfo) return;
|
|
@@ -1031,7 +1145,7 @@ var LanguageField = ({
|
|
|
1031
1145
|
updated.push({ code: t2.code, value: t2.value });
|
|
1032
1146
|
}
|
|
1033
1147
|
}
|
|
1034
|
-
|
|
1148
|
+
onChangeRef.current(updated);
|
|
1035
1149
|
setStatusMsg({ text: "\xC7eviri tamamland\u0131", type: "success" });
|
|
1036
1150
|
} else {
|
|
1037
1151
|
setStatusMsg({ text: res2.message || "\xC7eviri hatas\u0131", type: "error" });
|
|
@@ -1042,7 +1156,7 @@ var LanguageField = ({
|
|
|
1042
1156
|
setTranslating(false);
|
|
1043
1157
|
setTimeout(() => setStatusMsg(null), 3e3);
|
|
1044
1158
|
}
|
|
1045
|
-
}, [getCurrentText, merchantInfo, activeTab,
|
|
1159
|
+
}, [getCurrentText, merchantInfo, activeTab, apiClient, isHtml]);
|
|
1046
1160
|
if (loading) return /* @__PURE__ */ jsxRuntime.jsx(FieldLoading, {});
|
|
1047
1161
|
if (error2 && !merchantInfo) return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "tecof-lang-error", children: error2 });
|
|
1048
1162
|
if (!merchantInfo) return null;
|
|
@@ -1063,21 +1177,20 @@ var LanguageField = ({
|
|
|
1063
1177
|
if (activeTab !== code) return null;
|
|
1064
1178
|
const currentValue = values.find((v2) => v2.code === code)?.value || "";
|
|
1065
1179
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "tecof-lang-input-wrapper", children: isTextarea ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1066
|
-
|
|
1180
|
+
StableTextarea,
|
|
1067
1181
|
{
|
|
1068
1182
|
value: currentValue,
|
|
1069
|
-
onChange: (
|
|
1183
|
+
onChange: (val) => handleChange(code, val),
|
|
1070
1184
|
rows: textareaRows,
|
|
1071
1185
|
placeholder: placeholder || `${code.toUpperCase()} text...`,
|
|
1072
1186
|
disabled: readOnly,
|
|
1073
1187
|
className: "tecof-lang-input tecof-lang-textarea"
|
|
1074
1188
|
}
|
|
1075
1189
|
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
1076
|
-
|
|
1190
|
+
StableInput,
|
|
1077
1191
|
{
|
|
1078
|
-
type: "text",
|
|
1079
1192
|
value: currentValue,
|
|
1080
|
-
onChange: (
|
|
1193
|
+
onChange: (val) => handleChange(code, val),
|
|
1081
1194
|
placeholder: placeholder || `${code.toUpperCase()} text...`,
|
|
1082
1195
|
disabled: readOnly,
|
|
1083
1196
|
className: "tecof-lang-input"
|
|
@@ -1125,7 +1238,7 @@ var createLanguageField = (options = {}) => {
|
|
|
1125
1238
|
label,
|
|
1126
1239
|
labelIcon,
|
|
1127
1240
|
visible,
|
|
1128
|
-
render: ({ value, onChange, readOnly, field, name: name3, id }) => /* @__PURE__ */ jsxRuntime.jsx(core.FieldLabel, { label: label || "", icon: labelIcon, readOnly, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1241
|
+
render: ({ value, onChange, readOnly, field, name: name3, id }) => /* @__PURE__ */ jsxRuntime.jsx(core.FieldLabel, { label: label || "", icon: labelIcon, readOnly, children: /* @__PURE__ */ jsxRuntime.jsx(FieldErrorBoundary, { fieldName: name3, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1129
1242
|
LanguageField,
|
|
1130
1243
|
{
|
|
1131
1244
|
field,
|
|
@@ -1136,7 +1249,7 @@ var createLanguageField = (options = {}) => {
|
|
|
1136
1249
|
readOnly,
|
|
1137
1250
|
...fieldOptions
|
|
1138
1251
|
}
|
|
1139
|
-
) })
|
|
1252
|
+
) }) })
|
|
1140
1253
|
};
|
|
1141
1254
|
};
|
|
1142
1255
|
var createExtensions = () => [
|
|
@@ -1370,16 +1483,21 @@ var EditorField = ({
|
|
|
1370
1483
|
return existing || { code, value: "" };
|
|
1371
1484
|
});
|
|
1372
1485
|
}, [value, merchantInfo]);
|
|
1486
|
+
const valuesRef = React__default.useRef(values);
|
|
1487
|
+
valuesRef.current = values;
|
|
1488
|
+
const onChangeRef = React__default.useRef(onChange);
|
|
1489
|
+
onChangeRef.current = onChange;
|
|
1373
1490
|
const handleChange = React__default.useCallback((code, html) => {
|
|
1374
|
-
const
|
|
1491
|
+
const current = valuesRef.current;
|
|
1492
|
+
const updated = [...current];
|
|
1375
1493
|
const idx = updated.findIndex((v2) => v2.code === code);
|
|
1376
1494
|
if (idx >= 0) {
|
|
1377
1495
|
updated[idx] = { ...updated[idx], value: html };
|
|
1378
1496
|
} else {
|
|
1379
1497
|
updated.push({ code, value: html });
|
|
1380
1498
|
}
|
|
1381
|
-
|
|
1382
|
-
}, [
|
|
1499
|
+
onChangeRef.current(updated);
|
|
1500
|
+
}, []);
|
|
1383
1501
|
if (loading) return /* @__PURE__ */ jsxRuntime.jsx(FieldLoading, {});
|
|
1384
1502
|
if (error2 && !merchantInfo) return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "tecof-lang-error", children: error2 });
|
|
1385
1503
|
if (!merchantInfo) return null;
|
|
@@ -1416,7 +1534,7 @@ var createEditorField = (options = {}) => {
|
|
|
1416
1534
|
label,
|
|
1417
1535
|
labelIcon,
|
|
1418
1536
|
visible,
|
|
1419
|
-
render: ({ value, onChange, readOnly, field, name: name3, id }) => /* @__PURE__ */ jsxRuntime.jsx(core.FieldLabel, { label: label || "", icon: labelIcon, readOnly, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1537
|
+
render: ({ value, onChange, readOnly, field, name: name3, id }) => /* @__PURE__ */ jsxRuntime.jsx(core.FieldLabel, { label: label || "", icon: labelIcon, readOnly, children: /* @__PURE__ */ jsxRuntime.jsx(FieldErrorBoundary, { fieldName: name3, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1420
1538
|
EditorField,
|
|
1421
1539
|
{
|
|
1422
1540
|
field,
|
|
@@ -1427,7 +1545,7 @@ var createEditorField = (options = {}) => {
|
|
|
1427
1545
|
readOnly,
|
|
1428
1546
|
...fieldOptions
|
|
1429
1547
|
}
|
|
1430
|
-
) })
|
|
1548
|
+
) }) })
|
|
1431
1549
|
};
|
|
1432
1550
|
};
|
|
1433
1551
|
|
|
@@ -22937,7 +23055,7 @@ var createUploadField = (options = {}) => {
|
|
|
22937
23055
|
label,
|
|
22938
23056
|
labelIcon,
|
|
22939
23057
|
visible,
|
|
22940
|
-
render: ({ value, onChange, readOnly, field, name: name3, id }) => /* @__PURE__ */ jsxRuntime.jsx(core.FieldLabel, { label: label || "", icon: labelIcon, readOnly, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
23058
|
+
render: ({ value, onChange, readOnly, field, name: name3, id }) => /* @__PURE__ */ jsxRuntime.jsx(core.FieldLabel, { label: label || "", icon: labelIcon, readOnly, children: /* @__PURE__ */ jsxRuntime.jsx(FieldErrorBoundary, { fieldName: name3, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
22941
23059
|
UploadField,
|
|
22942
23060
|
{
|
|
22943
23061
|
field,
|
|
@@ -22948,7 +23066,7 @@ var createUploadField = (options = {}) => {
|
|
|
22948
23066
|
readOnly,
|
|
22949
23067
|
...fieldOptions
|
|
22950
23068
|
}
|
|
22951
|
-
) })
|
|
23069
|
+
) }) })
|
|
22952
23070
|
};
|
|
22953
23071
|
};
|
|
22954
23072
|
|
|
@@ -23632,7 +23750,7 @@ var createCodeEditorField = (options = {}) => {
|
|
|
23632
23750
|
label,
|
|
23633
23751
|
labelIcon,
|
|
23634
23752
|
visible,
|
|
23635
|
-
render: ({ value, onChange, readOnly, field, name: name3, id }) => /* @__PURE__ */ jsxRuntime.jsx(core.FieldLabel, { label: label || "", icon: labelIcon, readOnly, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
23753
|
+
render: ({ value, onChange, readOnly, field, name: name3, id }) => /* @__PURE__ */ jsxRuntime.jsx(core.FieldLabel, { label: label || "", icon: labelIcon, readOnly, children: /* @__PURE__ */ jsxRuntime.jsx(FieldErrorBoundary, { fieldName: name3, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
23636
23754
|
CodeEditorField,
|
|
23637
23755
|
{
|
|
23638
23756
|
field,
|
|
@@ -23643,7 +23761,7 @@ var createCodeEditorField = (options = {}) => {
|
|
|
23643
23761
|
readOnly,
|
|
23644
23762
|
...fieldOptions
|
|
23645
23763
|
}
|
|
23646
|
-
) })
|
|
23764
|
+
) }) })
|
|
23647
23765
|
};
|
|
23648
23766
|
};
|
|
23649
23767
|
var LinkField = ({
|
|
@@ -23671,10 +23789,14 @@ var LinkField = ({
|
|
|
23671
23789
|
return existing || { code, value: { url: "" } };
|
|
23672
23790
|
});
|
|
23673
23791
|
}, [value, merchantInfo]);
|
|
23792
|
+
const valuesRef = React__default.useRef(values);
|
|
23793
|
+
valuesRef.current = values;
|
|
23794
|
+
const onChangeRef = React__default.useRef(onChange);
|
|
23795
|
+
onChangeRef.current = onChange;
|
|
23674
23796
|
const activeValueItem = values.find((v2) => v2.code === activeTab);
|
|
23675
23797
|
const activeValue = activeValueItem?.value || { url: "" };
|
|
23676
23798
|
const updateActiveValue = React__default.useCallback((newLinkVal) => {
|
|
23677
|
-
const updated = [...
|
|
23799
|
+
const updated = [...valuesRef.current];
|
|
23678
23800
|
const idx = updated.findIndex((v2) => v2.code === activeTab);
|
|
23679
23801
|
if (idx >= 0) {
|
|
23680
23802
|
if (newLinkVal) {
|
|
@@ -23685,8 +23807,8 @@ var LinkField = ({
|
|
|
23685
23807
|
} else if (newLinkVal) {
|
|
23686
23808
|
updated.push({ code: activeTab, value: newLinkVal });
|
|
23687
23809
|
}
|
|
23688
|
-
|
|
23689
|
-
}, [
|
|
23810
|
+
onChangeRef.current(updated);
|
|
23811
|
+
}, [activeTab]);
|
|
23690
23812
|
React__default.useEffect(() => {
|
|
23691
23813
|
if (!drawerOpen) return;
|
|
23692
23814
|
setLoading(true);
|
|
@@ -23875,7 +23997,7 @@ var createLinkField = (options = {}) => {
|
|
|
23875
23997
|
label,
|
|
23876
23998
|
labelIcon,
|
|
23877
23999
|
visible,
|
|
23878
|
-
render: ({ value, onChange, readOnly, field, name: name3, id }) => /* @__PURE__ */ jsxRuntime.jsx(core.FieldLabel, { label: label || "", icon: labelIcon, readOnly, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
24000
|
+
render: ({ value, onChange, readOnly, field, name: name3, id }) => /* @__PURE__ */ jsxRuntime.jsx(core.FieldLabel, { label: label || "", icon: labelIcon, readOnly, children: /* @__PURE__ */ jsxRuntime.jsx(FieldErrorBoundary, { fieldName: name3, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
23879
24001
|
LinkField,
|
|
23880
24002
|
{
|
|
23881
24003
|
field,
|
|
@@ -23886,7 +24008,7 @@ var createLinkField = (options = {}) => {
|
|
|
23886
24008
|
readOnly,
|
|
23887
24009
|
...fieldOptions
|
|
23888
24010
|
}
|
|
23889
|
-
) })
|
|
24011
|
+
) }) })
|
|
23890
24012
|
};
|
|
23891
24013
|
};
|
|
23892
24014
|
var isValidHex = (hex) => /^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})$/.test(hex);
|
|
@@ -24056,7 +24178,7 @@ var createColorField = (options = {}) => {
|
|
|
24056
24178
|
label,
|
|
24057
24179
|
labelIcon,
|
|
24058
24180
|
visible,
|
|
24059
|
-
render: ({ value, onChange, readOnly, field, name: name3, id }) => /* @__PURE__ */ jsxRuntime.jsx(core.FieldLabel, { label: label || "", icon: labelIcon, readOnly, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
24181
|
+
render: ({ value, onChange, readOnly, field, name: name3, id }) => /* @__PURE__ */ jsxRuntime.jsx(core.FieldLabel, { label: label || "", icon: labelIcon, readOnly, children: /* @__PURE__ */ jsxRuntime.jsx(FieldErrorBoundary, { fieldName: name3, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
24060
24182
|
ColorField,
|
|
24061
24183
|
{
|
|
24062
24184
|
field,
|
|
@@ -24067,7 +24189,7 @@ var createColorField = (options = {}) => {
|
|
|
24067
24189
|
readOnly,
|
|
24068
24190
|
...fieldOptions
|
|
24069
24191
|
}
|
|
24070
|
-
) })
|
|
24192
|
+
) }) })
|
|
24071
24193
|
};
|
|
24072
24194
|
};
|
|
24073
24195
|
|
|
@@ -24335,6 +24457,7 @@ filepond-plugin-image-edit/dist/filepond-plugin-image-edit.esm.js:
|
|
|
24335
24457
|
exports.CodeEditorField = CodeEditorField;
|
|
24336
24458
|
exports.ColorField = ColorField;
|
|
24337
24459
|
exports.EditorField = EditorField;
|
|
24460
|
+
exports.FieldErrorBoundary = FieldErrorBoundary;
|
|
24338
24461
|
exports.LanguageField = LanguageField;
|
|
24339
24462
|
exports.LinkField = LinkField;
|
|
24340
24463
|
exports.TecofApiClient = TecofApiClient;
|