@tecof/theme-editor 0.0.12 → 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 CHANGED
@@ -144,6 +144,10 @@ interface LinkFieldValue {
144
144
  target?: '_self' | '_blank';
145
145
  type?: 'page' | 'custom';
146
146
  }
147
+ interface LocalizedLinkFieldValue {
148
+ code: string;
149
+ value: LinkFieldValue;
150
+ }
147
151
 
148
152
  /**
149
153
  * Tecof API Client — handles communication with the Tecof backend
@@ -475,8 +479,8 @@ interface LinkFieldProps {
475
479
  field: any;
476
480
  name: string;
477
481
  id: string;
478
- value: LinkFieldValue | null;
479
- onChange: (value: LinkFieldValue | null) => void;
482
+ value: LocalizedLinkFieldValue[] | null;
483
+ onChange: (value: LocalizedLinkFieldValue[] | null) => void;
480
484
  readOnly?: boolean;
481
485
  }
482
486
  interface LinkFieldOptions {
package/dist/index.d.ts CHANGED
@@ -144,6 +144,10 @@ interface LinkFieldValue {
144
144
  target?: '_self' | '_blank';
145
145
  type?: 'page' | 'custom';
146
146
  }
147
+ interface LocalizedLinkFieldValue {
148
+ code: string;
149
+ value: LinkFieldValue;
150
+ }
147
151
 
148
152
  /**
149
153
  * Tecof API Client — handles communication with the Tecof backend
@@ -475,8 +479,8 @@ interface LinkFieldProps {
475
479
  field: any;
476
480
  name: string;
477
481
  id: string;
478
- value: LinkFieldValue | null;
479
- onChange: (value: LinkFieldValue | null) => void;
482
+ value: LocalizedLinkFieldValue[] | null;
483
+ onChange: (value: LocalizedLinkFieldValue[] | null) => void;
480
484
  readOnly?: boolean;
481
485
  }
482
486
  interface LinkFieldOptions {
package/dist/index.js CHANGED
@@ -22350,8 +22350,9 @@ var FileItemRenderer = ({
22350
22350
  data: file2,
22351
22351
  alt: file2.meta?.originalName || file2.name,
22352
22352
  size: "thumbnail",
22353
+ fill: true,
22353
22354
  className: "tecof-upload-file-thumb",
22354
- imgStyle: { width: "100%", height: "100%", objectFit: "cover", borderRadius: "10px" }
22355
+ imgStyle: { objectFit: "cover", borderRadius: "10px" }
22355
22356
  }
22356
22357
  ) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "tecof-upload-file-icon", children: /* @__PURE__ */ jsxRuntime.jsx(File2, { size: 20 }) }),
22357
22358
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "tecof-upload-file-info", children: [
@@ -22793,8 +22794,9 @@ var UploadField = ({
22793
22794
  data: file2,
22794
22795
  alt: file2.name,
22795
22796
  size: "thumbnail",
22797
+ fill: true,
22796
22798
  className: "tecof-upload-gallery-thumb",
22797
- imgStyle: { width: "100%", height: "100%", objectFit: "cover", borderRadius: "6px" }
22799
+ imgStyle: { objectFit: "cover", borderRadius: "6px" }
22798
22800
  }
22799
22801
  ) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "tecof-upload-gallery-thumb tecof-upload-gallery-file-icon-wrap", children: /* @__PURE__ */ jsxRuntime.jsx(File2, { size: 24, color: "#a1a1aa" }) }),
22800
22802
  /* @__PURE__ */ jsxRuntime.jsx("p", { className: "tecof-upload-gallery-file-name", children: file2.meta?.originalName || file2.name })
@@ -23527,6 +23529,7 @@ var LinkField = ({
23527
23529
  placeholder = "https://..."
23528
23530
  }) => {
23529
23531
  const { apiClient } = useTecof();
23532
+ const { merchantInfo, loading: langLoading, activeTab, setActiveTab } = useLanguages();
23530
23533
  const [drawerOpen, setDrawerOpen] = React__default.useState(false);
23531
23534
  const [pages, setPages] = React__default.useState([]);
23532
23535
  const [loading, setLoading] = React__default.useState(false);
@@ -23535,6 +23538,30 @@ var LinkField = ({
23535
23538
  const [manualUrl, setManualUrl] = React__default.useState("");
23536
23539
  const [manualLabel, setManualLabel] = React__default.useState("");
23537
23540
  const [manualTarget, setManualTarget] = React__default.useState("_self");
23541
+ const values = React__default.useMemo(() => {
23542
+ if (!merchantInfo) return value || [];
23543
+ const current = value || [];
23544
+ return merchantInfo.languages.map((code) => {
23545
+ const existing = current.find((v2) => v2.code === code);
23546
+ return existing || { code, value: { url: "" } };
23547
+ });
23548
+ }, [value, merchantInfo]);
23549
+ const activeValueItem = values.find((v2) => v2.code === activeTab);
23550
+ const activeValue = activeValueItem?.value || { url: "" };
23551
+ const updateActiveValue = React__default.useCallback((newLinkVal) => {
23552
+ const updated = [...values];
23553
+ const idx = updated.findIndex((v2) => v2.code === activeTab);
23554
+ if (idx >= 0) {
23555
+ if (newLinkVal) {
23556
+ updated[idx] = { ...updated[idx], value: newLinkVal };
23557
+ } else {
23558
+ updated[idx] = { ...updated[idx], value: { url: "" } };
23559
+ }
23560
+ } else if (newLinkVal) {
23561
+ updated.push({ code: activeTab, value: newLinkVal });
23562
+ }
23563
+ onChange(updated);
23564
+ }, [values, activeTab, onChange]);
23538
23565
  React__default.useEffect(() => {
23539
23566
  if (!drawerOpen) return;
23540
23567
  setLoading(true);
@@ -23549,17 +23576,17 @@ var LinkField = ({
23549
23576
  (p) => p.slug?.toLowerCase().includes(search.toLowerCase()) || p.title?.toLowerCase().includes(search.toLowerCase())
23550
23577
  ) : pages;
23551
23578
  const handleSelectPage = React__default.useCallback((page) => {
23552
- onChange({
23579
+ updateActiveValue({
23553
23580
  url: `/${page.slug}`,
23554
23581
  label: page.title || page.slug,
23555
23582
  target: "_self",
23556
23583
  type: "page"
23557
23584
  });
23558
23585
  setDrawerOpen(false);
23559
- }, [onChange]);
23586
+ }, [updateActiveValue]);
23560
23587
  const handleConfirmManual = React__default.useCallback(() => {
23561
23588
  if (!manualUrl.trim()) return;
23562
- onChange({
23589
+ updateActiveValue({
23563
23590
  url: manualUrl.trim(),
23564
23591
  label: manualLabel.trim() || manualUrl.trim(),
23565
23592
  target: manualTarget,
@@ -23568,28 +23595,42 @@ var LinkField = ({
23568
23595
  setShowManual(false);
23569
23596
  setManualUrl("");
23570
23597
  setManualLabel("");
23571
- }, [manualUrl, manualLabel, manualTarget, onChange]);
23598
+ }, [manualUrl, manualLabel, manualTarget, updateActiveValue]);
23572
23599
  const handleClear = React__default.useCallback(() => {
23573
- onChange(null);
23574
- }, [onChange]);
23600
+ updateActiveValue(null);
23601
+ }, [updateActiveValue]);
23575
23602
  const handleEditManual = React__default.useCallback(() => {
23576
- if (value) {
23577
- setManualUrl(value.url || "");
23578
- setManualLabel(value.label || "");
23579
- setManualTarget(value.target || "_self");
23603
+ if (activeValue && activeValue.url) {
23604
+ setManualUrl(activeValue.url || "");
23605
+ setManualLabel(activeValue.label || "");
23606
+ setManualTarget(activeValue.target || "_self");
23607
+ } else {
23608
+ setManualUrl("");
23609
+ setManualLabel("");
23610
+ setManualTarget("_self");
23580
23611
  }
23581
23612
  setShowManual(true);
23582
- }, [value]);
23583
- const hasValue = value && value.url;
23613
+ }, [activeValue]);
23614
+ const hasValue = activeValue && activeValue.url && activeValue.url !== "";
23584
23615
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "tecof-link-container", children: [
23616
+ merchantInfo && merchantInfo.languages.length > 1 && /* @__PURE__ */ jsxRuntime.jsx(
23617
+ LanguageTabBar,
23618
+ {
23619
+ languages: merchantInfo.languages,
23620
+ defaultLanguage: merchantInfo.defaultLanguage,
23621
+ activeTab,
23622
+ onTabChange: setActiveTab
23623
+ }
23624
+ ),
23625
+ langLoading && /* @__PURE__ */ jsxRuntime.jsx(FieldLoading, {}),
23585
23626
  hasValue && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "tecof-link-value-box", children: [
23586
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "tecof-link-value-icon", children: value.type === "page" ? /* @__PURE__ */ jsxRuntime.jsx(FileText, { size: 16 }) : /* @__PURE__ */ jsxRuntime.jsx(Globe, { size: 16 }) }),
23627
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "tecof-link-value-icon", children: activeValue.type === "page" ? /* @__PURE__ */ jsxRuntime.jsx(FileText, { size: 16 }) : /* @__PURE__ */ jsxRuntime.jsx(Globe, { size: 16 }) }),
23587
23628
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "tecof-link-value-info", children: [
23588
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "tecof-link-value-label", children: value.label || value.url }),
23589
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "tecof-link-value-url", children: value.url })
23629
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "tecof-link-value-label", children: activeValue.label || activeValue.url }),
23630
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "tecof-link-value-url", children: activeValue.url })
23590
23631
  ] }),
23591
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: `tecof-link-value-badge ${value.type === "page" ? "tecof-link-badge-page" : "tecof-link-badge-custom"}`, children: value.type === "page" ? "Sayfa" : "Link" }),
23592
- value.target === "_blank" && /* @__PURE__ */ jsxRuntime.jsx(ExternalLink, { size: 14, color: "#a1a1aa" }),
23632
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: `tecof-link-value-badge ${activeValue.type === "page" ? "tecof-link-badge-page" : "tecof-link-badge-custom"}`, children: activeValue.type === "page" ? "Sayfa" : "Link" }),
23633
+ activeValue.target === "_blank" && /* @__PURE__ */ jsxRuntime.jsx(ExternalLink, { size: 14, color: "#a1a1aa" }),
23593
23634
  !readOnly && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
23594
23635
  /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "tecof-link-action-btn-small", onClick: handleEditManual, title: "D\xFCzenle", children: /* @__PURE__ */ jsxRuntime.jsx(Pencil, { size: 14 }) }),
23595
23636
  /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "tecof-link-action-btn-small", onClick: handleClear, title: "Kald\u0131r", children: /* @__PURE__ */ jsxRuntime.jsx(X, { size: 14 }) })
@@ -23675,7 +23716,7 @@ var LinkField = ({
23675
23716
  )
23676
23717
  ] }),
23677
23718
  loading ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "tecof-text-center tecof-p-40 tecof-text-muted", children: "Y\xFCkleniyor..." }) : filteredPages.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "tecof-text-center tecof-p-40 tecof-text-muted", children: search ? "Sonu\xE7 bulunamad\u0131" : "Hen\xFCz sayfa yok" }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "tecof-link-page-list", children: filteredPages.map((page) => {
23678
- const selected = value?.url === `/${page.slug}`;
23719
+ const selected = activeValue?.url === `/${page.slug}`;
23679
23720
  return /* @__PURE__ */ jsxRuntime.jsxs(
23680
23721
  "div",
23681
23722
  {
@@ -23714,7 +23755,7 @@ var createLinkField = (options = {}) => {
23714
23755
  field,
23715
23756
  name: name3,
23716
23757
  id,
23717
- value: value || { url: "" },
23758
+ value: value || [],
23718
23759
  onChange,
23719
23760
  readOnly,
23720
23761
  ...fieldOptions