@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.mjs CHANGED
@@ -22312,8 +22312,9 @@ var FileItemRenderer = ({
22312
22312
  data: file2,
22313
22313
  alt: file2.meta?.originalName || file2.name,
22314
22314
  size: "thumbnail",
22315
+ fill: true,
22315
22316
  className: "tecof-upload-file-thumb",
22316
- imgStyle: { width: "100%", height: "100%", objectFit: "cover", borderRadius: "10px" }
22317
+ imgStyle: { objectFit: "cover", borderRadius: "10px" }
22317
22318
  }
22318
22319
  ) : /* @__PURE__ */ jsx("div", { className: "tecof-upload-file-icon", children: /* @__PURE__ */ jsx(File2, { size: 20 }) }),
22319
22320
  /* @__PURE__ */ jsxs("div", { className: "tecof-upload-file-info", children: [
@@ -22755,8 +22756,9 @@ var UploadField = ({
22755
22756
  data: file2,
22756
22757
  alt: file2.name,
22757
22758
  size: "thumbnail",
22759
+ fill: true,
22758
22760
  className: "tecof-upload-gallery-thumb",
22759
- imgStyle: { width: "100%", height: "100%", objectFit: "cover", borderRadius: "6px" }
22761
+ imgStyle: { objectFit: "cover", borderRadius: "6px" }
22760
22762
  }
22761
22763
  ) : /* @__PURE__ */ jsx("div", { className: "tecof-upload-gallery-thumb tecof-upload-gallery-file-icon-wrap", children: /* @__PURE__ */ jsx(File2, { size: 24, color: "#a1a1aa" }) }),
22762
22764
  /* @__PURE__ */ jsx("p", { className: "tecof-upload-gallery-file-name", children: file2.meta?.originalName || file2.name })
@@ -23489,6 +23491,7 @@ var LinkField = ({
23489
23491
  placeholder = "https://..."
23490
23492
  }) => {
23491
23493
  const { apiClient } = useTecof();
23494
+ const { merchantInfo, loading: langLoading, activeTab, setActiveTab } = useLanguages();
23492
23495
  const [drawerOpen, setDrawerOpen] = useState(false);
23493
23496
  const [pages, setPages] = useState([]);
23494
23497
  const [loading, setLoading] = useState(false);
@@ -23497,6 +23500,30 @@ var LinkField = ({
23497
23500
  const [manualUrl, setManualUrl] = useState("");
23498
23501
  const [manualLabel, setManualLabel] = useState("");
23499
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]);
23500
23527
  useEffect(() => {
23501
23528
  if (!drawerOpen) return;
23502
23529
  setLoading(true);
@@ -23511,17 +23538,17 @@ var LinkField = ({
23511
23538
  (p) => p.slug?.toLowerCase().includes(search.toLowerCase()) || p.title?.toLowerCase().includes(search.toLowerCase())
23512
23539
  ) : pages;
23513
23540
  const handleSelectPage = useCallback((page) => {
23514
- onChange({
23541
+ updateActiveValue({
23515
23542
  url: `/${page.slug}`,
23516
23543
  label: page.title || page.slug,
23517
23544
  target: "_self",
23518
23545
  type: "page"
23519
23546
  });
23520
23547
  setDrawerOpen(false);
23521
- }, [onChange]);
23548
+ }, [updateActiveValue]);
23522
23549
  const handleConfirmManual = useCallback(() => {
23523
23550
  if (!manualUrl.trim()) return;
23524
- onChange({
23551
+ updateActiveValue({
23525
23552
  url: manualUrl.trim(),
23526
23553
  label: manualLabel.trim() || manualUrl.trim(),
23527
23554
  target: manualTarget,
@@ -23530,28 +23557,42 @@ var LinkField = ({
23530
23557
  setShowManual(false);
23531
23558
  setManualUrl("");
23532
23559
  setManualLabel("");
23533
- }, [manualUrl, manualLabel, manualTarget, onChange]);
23560
+ }, [manualUrl, manualLabel, manualTarget, updateActiveValue]);
23534
23561
  const handleClear = useCallback(() => {
23535
- onChange(null);
23536
- }, [onChange]);
23562
+ updateActiveValue(null);
23563
+ }, [updateActiveValue]);
23537
23564
  const handleEditManual = useCallback(() => {
23538
- if (value) {
23539
- setManualUrl(value.url || "");
23540
- setManualLabel(value.label || "");
23541
- setManualTarget(value.target || "_self");
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");
23542
23573
  }
23543
23574
  setShowManual(true);
23544
- }, [value]);
23545
- const hasValue = value && value.url;
23575
+ }, [activeValue]);
23576
+ const hasValue = activeValue && activeValue.url && activeValue.url !== "";
23546
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, {}),
23547
23588
  hasValue && /* @__PURE__ */ jsxs("div", { className: "tecof-link-value-box", children: [
23548
- /* @__PURE__ */ jsx("div", { className: "tecof-link-value-icon", children: value.type === "page" ? /* @__PURE__ */ jsx(FileText, { size: 16 }) : /* @__PURE__ */ jsx(Globe, { size: 16 }) }),
23589
+ /* @__PURE__ */ jsx("div", { className: "tecof-link-value-icon", children: activeValue.type === "page" ? /* @__PURE__ */ jsx(FileText, { size: 16 }) : /* @__PURE__ */ jsx(Globe, { size: 16 }) }),
23549
23590
  /* @__PURE__ */ jsxs("div", { className: "tecof-link-value-info", children: [
23550
- /* @__PURE__ */ jsx("p", { className: "tecof-link-value-label", children: value.label || value.url }),
23551
- /* @__PURE__ */ jsx("p", { className: "tecof-link-value-url", children: value.url })
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 })
23552
23593
  ] }),
23553
- /* @__PURE__ */ jsx("span", { className: `tecof-link-value-badge ${value.type === "page" ? "tecof-link-badge-page" : "tecof-link-badge-custom"}`, children: value.type === "page" ? "Sayfa" : "Link" }),
23554
- value.target === "_blank" && /* @__PURE__ */ jsx(ExternalLink, { size: 14, color: "#a1a1aa" }),
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" }),
23555
23596
  !readOnly && /* @__PURE__ */ jsxs(Fragment, { children: [
23556
23597
  /* @__PURE__ */ jsx("button", { type: "button", className: "tecof-link-action-btn-small", onClick: handleEditManual, title: "D\xFCzenle", children: /* @__PURE__ */ jsx(Pencil, { size: 14 }) }),
23557
23598
  /* @__PURE__ */ jsx("button", { type: "button", className: "tecof-link-action-btn-small", onClick: handleClear, title: "Kald\u0131r", children: /* @__PURE__ */ jsx(X, { size: 14 }) })
@@ -23637,7 +23678,7 @@ var LinkField = ({
23637
23678
  )
23638
23679
  ] }),
23639
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) => {
23640
- const selected = value?.url === `/${page.slug}`;
23681
+ const selected = activeValue?.url === `/${page.slug}`;
23641
23682
  return /* @__PURE__ */ jsxs(
23642
23683
  "div",
23643
23684
  {
@@ -23676,7 +23717,7 @@ var createLinkField = (options = {}) => {
23676
23717
  field,
23677
23718
  name: name3,
23678
23719
  id,
23679
- value: value || { url: "" },
23720
+ value: value || [],
23680
23721
  onChange,
23681
23722
  readOnly,
23682
23723
  ...fieldOptions