@tecof/theme-editor 0.0.11 → 0.0.13
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 +11 -5
- package/dist/index.d.ts +11 -5
- package/dist/index.js +71 -28
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +71 -28
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -26,9 +26,10 @@ import ReactDOM__default from 'react-dom';
|
|
|
26
26
|
|
|
27
27
|
// src/api.ts
|
|
28
28
|
var TecofApiClient = class {
|
|
29
|
-
constructor(apiUrl, secretKey) {
|
|
29
|
+
constructor(apiUrl, secretKey, customCdnUrl) {
|
|
30
30
|
this.apiUrl = apiUrl.replace(/\/+$/, "");
|
|
31
31
|
this.secretKey = secretKey;
|
|
32
|
+
this.customCdnUrl = customCdnUrl ? customCdnUrl.replace(/\/+$/, "") : void 0;
|
|
32
33
|
}
|
|
33
34
|
get headers() {
|
|
34
35
|
return {
|
|
@@ -189,20 +190,21 @@ var TecofApiClient = class {
|
|
|
189
190
|
};
|
|
190
191
|
}
|
|
191
192
|
}
|
|
192
|
-
/** CDN base URL (
|
|
193
|
+
/** CDN base URL (defaults to apiUrl if not set) */
|
|
193
194
|
get cdnUrl() {
|
|
194
|
-
return this.apiUrl;
|
|
195
|
+
return this.customCdnUrl || this.apiUrl;
|
|
195
196
|
}
|
|
196
197
|
};
|
|
197
198
|
var TecofContext = createContext(null);
|
|
198
|
-
var TecofProvider = ({ apiUrl, secretKey, children }) => {
|
|
199
|
+
var TecofProvider = ({ apiUrl, secretKey, cdnUrl, children }) => {
|
|
199
200
|
const value = useMemo(
|
|
200
201
|
() => ({
|
|
201
|
-
apiClient: new TecofApiClient(apiUrl, secretKey),
|
|
202
|
+
apiClient: new TecofApiClient(apiUrl, secretKey, cdnUrl),
|
|
202
203
|
secretKey,
|
|
203
|
-
apiUrl
|
|
204
|
+
apiUrl,
|
|
205
|
+
cdnUrl
|
|
204
206
|
}),
|
|
205
|
-
[apiUrl, secretKey]
|
|
207
|
+
[apiUrl, secretKey, cdnUrl]
|
|
206
208
|
);
|
|
207
209
|
return /* @__PURE__ */ jsx(TecofContext.Provider, { value, children });
|
|
208
210
|
};
|
|
@@ -22310,8 +22312,9 @@ var FileItemRenderer = ({
|
|
|
22310
22312
|
data: file2,
|
|
22311
22313
|
alt: file2.meta?.originalName || file2.name,
|
|
22312
22314
|
size: "thumbnail",
|
|
22315
|
+
fill: true,
|
|
22313
22316
|
className: "tecof-upload-file-thumb",
|
|
22314
|
-
imgStyle: {
|
|
22317
|
+
imgStyle: { objectFit: "cover", borderRadius: "10px" }
|
|
22315
22318
|
}
|
|
22316
22319
|
) : /* @__PURE__ */ jsx("div", { className: "tecof-upload-file-icon", children: /* @__PURE__ */ jsx(File2, { size: 20 }) }),
|
|
22317
22320
|
/* @__PURE__ */ jsxs("div", { className: "tecof-upload-file-info", children: [
|
|
@@ -22753,8 +22756,9 @@ var UploadField = ({
|
|
|
22753
22756
|
data: file2,
|
|
22754
22757
|
alt: file2.name,
|
|
22755
22758
|
size: "thumbnail",
|
|
22759
|
+
fill: true,
|
|
22756
22760
|
className: "tecof-upload-gallery-thumb",
|
|
22757
|
-
imgStyle: {
|
|
22761
|
+
imgStyle: { objectFit: "cover", borderRadius: "6px" }
|
|
22758
22762
|
}
|
|
22759
22763
|
) : /* @__PURE__ */ jsx("div", { className: "tecof-upload-gallery-thumb tecof-upload-gallery-file-icon-wrap", children: /* @__PURE__ */ jsx(File2, { size: 24, color: "#a1a1aa" }) }),
|
|
22760
22764
|
/* @__PURE__ */ jsx("p", { className: "tecof-upload-gallery-file-name", children: file2.meta?.originalName || file2.name })
|
|
@@ -23487,6 +23491,7 @@ var LinkField = ({
|
|
|
23487
23491
|
placeholder = "https://..."
|
|
23488
23492
|
}) => {
|
|
23489
23493
|
const { apiClient } = useTecof();
|
|
23494
|
+
const { merchantInfo, loading: langLoading, activeTab, setActiveTab } = useLanguages();
|
|
23490
23495
|
const [drawerOpen, setDrawerOpen] = useState(false);
|
|
23491
23496
|
const [pages, setPages] = useState([]);
|
|
23492
23497
|
const [loading, setLoading] = useState(false);
|
|
@@ -23495,6 +23500,30 @@ var LinkField = ({
|
|
|
23495
23500
|
const [manualUrl, setManualUrl] = useState("");
|
|
23496
23501
|
const [manualLabel, setManualLabel] = useState("");
|
|
23497
23502
|
const [manualTarget, setManualTarget] = useState("_self");
|
|
23503
|
+
const values = useMemo(() => {
|
|
23504
|
+
if (!merchantInfo) return value || [];
|
|
23505
|
+
const current = value || [];
|
|
23506
|
+
return merchantInfo.languages.map((code) => {
|
|
23507
|
+
const existing = current.find((v2) => v2.code === code);
|
|
23508
|
+
return existing || { code, value: { url: "" } };
|
|
23509
|
+
});
|
|
23510
|
+
}, [value, merchantInfo]);
|
|
23511
|
+
const activeValueItem = values.find((v2) => v2.code === activeTab);
|
|
23512
|
+
const activeValue = activeValueItem?.value || { url: "" };
|
|
23513
|
+
const updateActiveValue = useCallback((newLinkVal) => {
|
|
23514
|
+
const updated = [...values];
|
|
23515
|
+
const idx = updated.findIndex((v2) => v2.code === activeTab);
|
|
23516
|
+
if (idx >= 0) {
|
|
23517
|
+
if (newLinkVal) {
|
|
23518
|
+
updated[idx] = { ...updated[idx], value: newLinkVal };
|
|
23519
|
+
} else {
|
|
23520
|
+
updated[idx] = { ...updated[idx], value: { url: "" } };
|
|
23521
|
+
}
|
|
23522
|
+
} else if (newLinkVal) {
|
|
23523
|
+
updated.push({ code: activeTab, value: newLinkVal });
|
|
23524
|
+
}
|
|
23525
|
+
onChange(updated);
|
|
23526
|
+
}, [values, activeTab, onChange]);
|
|
23498
23527
|
useEffect(() => {
|
|
23499
23528
|
if (!drawerOpen) return;
|
|
23500
23529
|
setLoading(true);
|
|
@@ -23509,17 +23538,17 @@ var LinkField = ({
|
|
|
23509
23538
|
(p) => p.slug?.toLowerCase().includes(search.toLowerCase()) || p.title?.toLowerCase().includes(search.toLowerCase())
|
|
23510
23539
|
) : pages;
|
|
23511
23540
|
const handleSelectPage = useCallback((page) => {
|
|
23512
|
-
|
|
23541
|
+
updateActiveValue({
|
|
23513
23542
|
url: `/${page.slug}`,
|
|
23514
23543
|
label: page.title || page.slug,
|
|
23515
23544
|
target: "_self",
|
|
23516
23545
|
type: "page"
|
|
23517
23546
|
});
|
|
23518
23547
|
setDrawerOpen(false);
|
|
23519
|
-
}, [
|
|
23548
|
+
}, [updateActiveValue]);
|
|
23520
23549
|
const handleConfirmManual = useCallback(() => {
|
|
23521
23550
|
if (!manualUrl.trim()) return;
|
|
23522
|
-
|
|
23551
|
+
updateActiveValue({
|
|
23523
23552
|
url: manualUrl.trim(),
|
|
23524
23553
|
label: manualLabel.trim() || manualUrl.trim(),
|
|
23525
23554
|
target: manualTarget,
|
|
@@ -23528,28 +23557,42 @@ var LinkField = ({
|
|
|
23528
23557
|
setShowManual(false);
|
|
23529
23558
|
setManualUrl("");
|
|
23530
23559
|
setManualLabel("");
|
|
23531
|
-
}, [manualUrl, manualLabel, manualTarget,
|
|
23560
|
+
}, [manualUrl, manualLabel, manualTarget, updateActiveValue]);
|
|
23532
23561
|
const handleClear = useCallback(() => {
|
|
23533
|
-
|
|
23534
|
-
}, [
|
|
23562
|
+
updateActiveValue(null);
|
|
23563
|
+
}, [updateActiveValue]);
|
|
23535
23564
|
const handleEditManual = useCallback(() => {
|
|
23536
|
-
if (
|
|
23537
|
-
setManualUrl(
|
|
23538
|
-
setManualLabel(
|
|
23539
|
-
setManualTarget(
|
|
23565
|
+
if (activeValue && activeValue.url) {
|
|
23566
|
+
setManualUrl(activeValue.url || "");
|
|
23567
|
+
setManualLabel(activeValue.label || "");
|
|
23568
|
+
setManualTarget(activeValue.target || "_self");
|
|
23569
|
+
} else {
|
|
23570
|
+
setManualUrl("");
|
|
23571
|
+
setManualLabel("");
|
|
23572
|
+
setManualTarget("_self");
|
|
23540
23573
|
}
|
|
23541
23574
|
setShowManual(true);
|
|
23542
|
-
}, [
|
|
23543
|
-
const hasValue =
|
|
23575
|
+
}, [activeValue]);
|
|
23576
|
+
const hasValue = activeValue && activeValue.url && activeValue.url !== "";
|
|
23544
23577
|
return /* @__PURE__ */ jsxs("div", { className: "tecof-link-container", children: [
|
|
23578
|
+
merchantInfo && merchantInfo.languages.length > 1 && /* @__PURE__ */ jsx(
|
|
23579
|
+
LanguageTabBar,
|
|
23580
|
+
{
|
|
23581
|
+
languages: merchantInfo.languages,
|
|
23582
|
+
defaultLanguage: merchantInfo.defaultLanguage,
|
|
23583
|
+
activeTab,
|
|
23584
|
+
onTabChange: setActiveTab
|
|
23585
|
+
}
|
|
23586
|
+
),
|
|
23587
|
+
langLoading && /* @__PURE__ */ jsx(FieldLoading, {}),
|
|
23545
23588
|
hasValue && /* @__PURE__ */ jsxs("div", { className: "tecof-link-value-box", children: [
|
|
23546
|
-
/* @__PURE__ */ jsx("div", { className: "tecof-link-value-icon", children:
|
|
23589
|
+
/* @__PURE__ */ jsx("div", { className: "tecof-link-value-icon", children: activeValue.type === "page" ? /* @__PURE__ */ jsx(FileText, { size: 16 }) : /* @__PURE__ */ jsx(Globe, { size: 16 }) }),
|
|
23547
23590
|
/* @__PURE__ */ jsxs("div", { className: "tecof-link-value-info", children: [
|
|
23548
|
-
/* @__PURE__ */ jsx("p", { className: "tecof-link-value-label", children:
|
|
23549
|
-
/* @__PURE__ */ jsx("p", { className: "tecof-link-value-url", children:
|
|
23591
|
+
/* @__PURE__ */ jsx("p", { className: "tecof-link-value-label", children: activeValue.label || activeValue.url }),
|
|
23592
|
+
/* @__PURE__ */ jsx("p", { className: "tecof-link-value-url", children: activeValue.url })
|
|
23550
23593
|
] }),
|
|
23551
|
-
/* @__PURE__ */ jsx("span", { className: `tecof-link-value-badge ${
|
|
23552
|
-
|
|
23594
|
+
/* @__PURE__ */ jsx("span", { className: `tecof-link-value-badge ${activeValue.type === "page" ? "tecof-link-badge-page" : "tecof-link-badge-custom"}`, children: activeValue.type === "page" ? "Sayfa" : "Link" }),
|
|
23595
|
+
activeValue.target === "_blank" && /* @__PURE__ */ jsx(ExternalLink, { size: 14, color: "#a1a1aa" }),
|
|
23553
23596
|
!readOnly && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
23554
23597
|
/* @__PURE__ */ jsx("button", { type: "button", className: "tecof-link-action-btn-small", onClick: handleEditManual, title: "D\xFCzenle", children: /* @__PURE__ */ jsx(Pencil, { size: 14 }) }),
|
|
23555
23598
|
/* @__PURE__ */ jsx("button", { type: "button", className: "tecof-link-action-btn-small", onClick: handleClear, title: "Kald\u0131r", children: /* @__PURE__ */ jsx(X, { size: 14 }) })
|
|
@@ -23635,7 +23678,7 @@ var LinkField = ({
|
|
|
23635
23678
|
)
|
|
23636
23679
|
] }),
|
|
23637
23680
|
loading ? /* @__PURE__ */ jsx("div", { className: "tecof-text-center tecof-p-40 tecof-text-muted", children: "Y\xFCkleniyor..." }) : filteredPages.length === 0 ? /* @__PURE__ */ jsx("div", { className: "tecof-text-center tecof-p-40 tecof-text-muted", children: search ? "Sonu\xE7 bulunamad\u0131" : "Hen\xFCz sayfa yok" }) : /* @__PURE__ */ jsx("div", { className: "tecof-link-page-list", children: filteredPages.map((page) => {
|
|
23638
|
-
const selected =
|
|
23681
|
+
const selected = activeValue?.url === `/${page.slug}`;
|
|
23639
23682
|
return /* @__PURE__ */ jsxs(
|
|
23640
23683
|
"div",
|
|
23641
23684
|
{
|
|
@@ -23674,7 +23717,7 @@ var createLinkField = (options = {}) => {
|
|
|
23674
23717
|
field,
|
|
23675
23718
|
name: name3,
|
|
23676
23719
|
id,
|
|
23677
|
-
value: value ||
|
|
23720
|
+
value: value || [],
|
|
23678
23721
|
onChange,
|
|
23679
23722
|
readOnly,
|
|
23680
23723
|
...fieldOptions
|