@chaibuilder/sdk 4.0.0-beta.1 → 4.0.0-beta.2
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/README.md +27 -20
- package/dist/2SSKDMRQ-C4VFVd-q.cjs +1 -0
- package/dist/2SSKDMRQ-DSnzF_1o.js +42 -0
- package/dist/AP7HFJJL-B7YYCY9q.cjs +1228 -0
- package/dist/AP7HFJJL-Cxwj01Aq.js +9214 -0
- package/dist/IconPicker-C9-ieDWm.cjs +1 -0
- package/dist/IconPicker-RqVvq6G2.js +59 -0
- package/dist/WDYDFRGG-C7aSUcjs.js +33 -0
- package/dist/WDYDFRGG-b3T2SQbz.cjs +1 -0
- package/dist/_commonjsHelpers-C6fGbg64.js +6 -0
- package/dist/_commonjsHelpers-DwGv2jUC.cjs +1 -0
- package/dist/actions-registery-CZ1w0NKa.js +15545 -0
- package/dist/actions-registery-YnFmU21O.cjs +418 -0
- package/dist/actions.cjs +1 -0
- package/dist/actions.d.ts +3202 -0
- package/dist/actions.js +216 -0
- package/dist/active-in-another-tab-Clng6zpY.cjs +1 -0
- package/dist/active-in-another-tab-wb8qolB8.js +34 -0
- package/dist/add-new-language-page-C4BuMTaN.cjs +1 -0
- package/dist/add-new-language-page-D7NDABl1.js +401 -0
- package/dist/add-new-page-B4hc0B-g.js +31 -0
- package/dist/add-new-page-BNfwKjRd.cjs +1 -0
- package/dist/ai-panel-content-BnbURb7j.js +61 -0
- package/dist/ai-panel-content-DPy2jgKw.cjs +1 -0
- package/dist/ai-panel-default-lang-3tCHzab5.cjs +3 -0
- package/dist/ai-panel-default-lang-oVk4TDeb.js +341 -0
- package/dist/ai-panel-other-lang-BBHCCSen.cjs +1 -0
- package/dist/ai-panel-other-lang-DmQ3QMDD.js +162 -0
- package/dist/ai-prompt-input-DaTyfib-.js +655 -0
- package/dist/ai-prompt-input-b5ty81RB.cjs +1 -0
- package/dist/ai-translation-prompt-DJPe2O-n.js +28 -0
- package/dist/ai-translation-prompt-c0Q3zkT2.cjs +1 -0
- package/dist/apply-binding-6iwlED02.js +833 -0
- package/dist/apply-binding-KKp5PnpZ.cjs +1 -0
- package/dist/{code-display-337R7Dev.js → code-display-BzBq5xSn.js} +1 -1
- package/dist/code-display-Q3_sK_Ta.cjs +1 -0
- package/dist/code-editor-BQZi6-FB.cjs +1 -0
- package/dist/code-editor-DWWnphW9.js +50 -0
- package/dist/common-functions-B3a4xKt_.cjs +1 -0
- package/dist/common-functions-D2lMFR6K.js +13 -0
- package/dist/continue-editing-in-this-client-BllU94XG.js +24 -0
- package/dist/continue-editing-in-this-client-D9HyD4GP.cjs +1 -0
- package/dist/core-BoRDjj4h.cjs +1 -0
- package/dist/core-yvI6kCyw.js +56 -0
- package/dist/core.cjs +1 -1
- package/dist/core.d.ts +51 -383
- package/dist/core.js +39 -106
- package/dist/css-import-modal-BSMGKA2T.cjs +13 -0
- package/dist/{css-import-modal-DA2L6kwP.js → css-import-modal-D72a-16X.js} +39 -38
- package/dist/delete-design-token-Cd1ZDtqT.js +40 -0
- package/dist/delete-design-token-D_TLlO3I.cjs +1 -0
- package/dist/delete-page-ByQwBupJ.cjs +1 -0
- package/dist/delete-page-DC8pzvWW.js +70 -0
- package/dist/design-token-usage-BqZeR1sT.cjs +1 -0
- package/dist/design-token-usage-DE4XCDdn.js +113 -0
- package/dist/digital-asset-manager-BYLKFEYi.cjs +1 -0
- package/dist/digital-asset-manager-C_gL_0YY.js +876 -0
- package/dist/duplicate-page-BoVhko2q.js +133 -0
- package/dist/duplicate-page-vdvwLQLo.cjs +1 -0
- package/dist/dynamic-page-selector-CSndg2-y.js +85 -0
- package/dist/dynamic-page-selector-DdnbCuQZ.cjs +1 -0
- package/dist/fonts-B-Xt29pe.cjs +1 -0
- package/dist/fonts-DRly3Wzd.js +78 -0
- package/dist/{get-chai-builder-tailwind-config-C6MHaUM0.cjs → get-chai-builder-tailwind-config-B9rCyiQo.cjs} +1 -1
- package/dist/{get-chai-builder-tailwind-config-BqaIvg8p.js → get-chai-builder-tailwind-config-DjoVOuAf.js} +13 -10
- package/dist/{get-chai-builder-theme-D0IsUvK4.js → get-chai-builder-theme-BYtp20KD.js} +4 -4
- package/dist/get-chai-builder-theme-Dl72X7cz.cjs +1 -0
- package/dist/get-seo-defaults-9zHebckY.js +65 -0
- package/dist/get-seo-defaults-Cw7vFt-B.cjs +1 -0
- package/dist/image-compression-DZ9WMmyn.cjs +1 -0
- package/dist/image-compression-DsZ1oqpb.js +37 -0
- package/dist/image-editor-DTspjj_c.cjs +1 -0
- package/dist/image-editor-oypq8asR.js +108 -0
- package/dist/index-B-rSiAp_.cjs +1 -0
- package/dist/index-BDnwJqMw.js +4732 -0
- package/dist/index-CbwxUFy_.cjs +5 -0
- package/dist/index-CnSjWE1P.cjs +160 -0
- package/dist/index-Dxfyt4d4.js +39 -0
- package/dist/index-S8ibZk9Q.js +19069 -0
- package/dist/json-diff-viewer-B5dr-Y_L.js +258 -0
- package/dist/json-diff-viewer-XX1pgabt.cjs +8 -0
- package/dist/lang-panel-BPxex-M2.cjs +1 -0
- package/dist/lang-panel-Cn83SRzd.js +215 -0
- package/dist/manage-design-tokens-ConiyuPr.cjs +1 -0
- package/dist/manage-design-tokens-lP4HLS0P.js +240 -0
- package/dist/mark-as-template-DYRxre1f.cjs +1 -0
- package/dist/mark-as-template-jncsjfHm.js +156 -0
- package/dist/models-5gOsRC56.cjs +1 -0
- package/dist/models-D95ZYr_x.js +70 -0
- package/dist/nested-path-selector-content-B-8LqhXI.js +87 -0
- package/dist/nested-path-selector-content-BYtLi7mC.cjs +1 -0
- package/dist/no-language-page-content-DAbLq0gX.cjs +1 -0
- package/dist/no-language-page-content-D_zd9Rb0.js +42 -0
- package/dist/no-language-page-dialog-C5Ps6YYL.js +10 -0
- package/dist/no-language-page-dialog-fXmbQO7L.cjs +1 -0
- package/dist/page-creator-VWIB2VAs.cjs +1 -0
- package/dist/page-creator-wCMtlE6Z.js +795 -0
- package/dist/page-lock-BPCxfv9J.js +30 -0
- package/dist/page-lock-DweiYy1w.cjs +1 -0
- package/dist/page-locked-dialog-BlbgvaG2.cjs +1 -0
- package/dist/page-locked-dialog-ByGl18_m.js +133 -0
- package/dist/page-manager-new-BWFE-S-O.js +394 -0
- package/dist/page-manager-new-D0lGfNnS.cjs +1 -0
- package/dist/page-manager-search-and-filter-DpGMoOII.cjs +1 -0
- package/dist/page-manager-search-and-filter-kNJFWJ86.js +201 -0
- package/dist/page-revisions-content-DYxXZqmh.cjs +1 -0
- package/dist/page-revisions-content-Ulr8slUN.js +445 -0
- package/dist/pages.cjs +1 -0
- package/dist/pages.d.ts +492 -0
- package/dist/pages.js +27 -0
- package/dist/plugin-3ZKK6RXm.js +245 -0
- package/dist/plugin-C6rgJDNQ.cjs +22 -0
- package/dist/publish-pages-content-BTPzt_m4.js +178 -0
- package/dist/publish-pages-content-D6g8GAsd.cjs +1 -0
- package/dist/register-partial-type-BjtdfKHE.js +36 -0
- package/dist/register-partial-type-ig9fUWIJ.cjs +1 -0
- package/dist/render.cjs +2 -2
- package/dist/render.d.ts +26 -13
- package/dist/render.js +130 -124
- package/dist/rte-widget-modal-DrMzWWjw.cjs +1 -0
- package/dist/rte-widget-modal-Rk_NW3KU.js +38 -0
- package/dist/runtime.cjs +1 -1
- package/dist/runtime.d.ts +306 -7
- package/dist/runtime.js +44 -1
- package/dist/save-to-lib-BK3uTFss.js +422 -0
- package/dist/save-to-lib-DHHUO12i.cjs +1 -0
- package/dist/sdk.css +1 -1
- package/dist/selected-block-display-CU3TwIMA.js +319 -0
- package/dist/selected-block-display-DSFhddPj.cjs +16 -0
- package/dist/seo-panel-Dl0IDV09.cjs +2 -0
- package/dist/seo-panel-jbzxFioc.js +798 -0
- package/dist/shared-json-ld-BL_dv3_q.js +565 -0
- package/dist/shared-json-ld-DPNkqDC1.cjs +1 -0
- package/dist/slug-input-1qwKkXhA.js +86 -0
- package/dist/slug-input-YVLjtTI3.cjs +1 -0
- package/dist/supabase-actions.cjs +1 -0
- package/dist/supabase-actions.d.ts +284 -0
- package/dist/supabase-actions.js +524 -0
- package/dist/take-over-request-DKvKi3mM.js +63 -0
- package/dist/take-over-request-DvMIg_cZ.cjs +1 -0
- package/dist/theme-panel-footer-BMOaPLWc.cjs +1 -0
- package/dist/theme-panel-footer-DbMDLYGI.js +25 -0
- package/dist/translation-warning-modal-9wTwIy_9.js +26 -0
- package/dist/translation-warning-modal-DjTwz75c.cjs +1 -0
- package/dist/unmark-as-template-CdqIJJER.cjs +1 -0
- package/dist/unmark-as-template-Dulvf7Zw.js +39 -0
- package/dist/unpublish-page-BwSVBf0_.cjs +1 -0
- package/dist/unpublish-page-Degu5Cy9.js +27 -0
- package/dist/use-page-expand-manager-B6XTvk0E.cjs +1 -0
- package/dist/use-page-expand-manager-Cf4MUEJw.js +85 -0
- package/dist/{tailwind.cjs → utils.cjs} +1 -1
- package/dist/{tailwind.d.ts → utils.d.ts} +12 -11
- package/dist/utils.js +7 -0
- package/dist/web-blocks.cjs +1 -1
- package/dist/web-blocks.d.ts +0 -6
- package/dist/web-blocks.js +258 -251
- package/dist/web-preview-DXE4Jnf5.js +73 -0
- package/dist/web-preview-YzKxyXft.cjs +1 -0
- package/package.json +175 -105
- package/dist/IconPicker-CGWn9C4u.cjs +0 -1
- package/dist/IconPicker-QvxJ-4Ez.js +0 -64
- package/dist/apply-binding-DCno1xQL.js +0 -711
- package/dist/apply-binding-DvHNFLQD.cjs +0 -1
- package/dist/code-display-BZ1x7SqI.cjs +0 -1
- package/dist/code-editor-B28LoECM.cjs +0 -1
- package/dist/code-editor-CfG2FhJ-.js +0 -58
- package/dist/common-functions-BGzDsf1z.js +0 -14
- package/dist/common-functions-BZmyleS1.cjs +0 -1
- package/dist/css-import-modal-CENUYvcl.cjs +0 -13
- package/dist/get-chai-builder-theme-Ck_Z4Q-M.cjs +0 -1
- package/dist/index-CaGNHF7f.js +0 -12209
- package/dist/index-Gn6pJt2v.cjs +0 -166
- package/dist/mockServiceWorker.js +0 -307
- package/dist/plugin-B5627hMN.js +0 -195
- package/dist/plugin-UxTRfDum.cjs +0 -22
- package/dist/rte-widget-modal-DL739qeQ.cjs +0 -1
- package/dist/rte-widget-modal-Dte0od04.js +0 -41
- package/dist/tailwind.js +0 -7
- package/dist/tooltip-A4qGk781.cjs +0 -1
- package/dist/tooltip-tLiIOgjq.js +0 -1067
- package/dist/ui.cjs +0 -1
- package/dist/ui.d.ts +0 -415
- package/dist/ui.js +0 -129
- package/dist/vite.svg +0 -1
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
import { jsx as e, jsxs as h } from "react/jsx-runtime";
|
|
2
|
+
import { D as V, d as _, e as q, f as G, aj as $, a5 as I, B as z, ak as P } from "./index-S8ibZk9Q.js";
|
|
3
|
+
import { formatDate as Q } from "date-fns";
|
|
4
|
+
import { startsWith as T, replace as W, isString as X, trim as Y, isArray as Z, map as ee, isPlainObject as te, mapValues as re } from "lodash-es";
|
|
5
|
+
import { FileJson as B, Loader as ne, Check as F, Copy as H } from "lucide-react";
|
|
6
|
+
import { useState as D, useMemo as A } from "react";
|
|
7
|
+
import { parseDiff as se, Diff as le, Hunk as ae } from "react-diff-view";
|
|
8
|
+
import { ar as ie, as as oe, A as ce, ap as de } from "./index-BDnwJqMw.js";
|
|
9
|
+
import { useQuery as fe } from "@tanstack/react-query";
|
|
10
|
+
function me(t, n) {
|
|
11
|
+
const o = ie(), s = oe(), u = T(t.uid, "draft:") || T(n.uid, "live:");
|
|
12
|
+
return fe({
|
|
13
|
+
queryKey: ["revision-comparison", t.uid, n.uid],
|
|
14
|
+
queryFn: async () => {
|
|
15
|
+
if (!t.uid || !n.uid)
|
|
16
|
+
throw new Error("Both revision IDs are required for comparison");
|
|
17
|
+
const l = (f) => f === "draft" || f === "live" ? f : "revision", r = (f) => W(f.uid, `${f.label}:`, "");
|
|
18
|
+
return await s(o, {
|
|
19
|
+
action: ce.GET_COMPARE_DATA,
|
|
20
|
+
data: {
|
|
21
|
+
versions: {
|
|
22
|
+
version1: { type: l(t.label), id: r(t) },
|
|
23
|
+
version2: { type: l(n.label), id: r(n) }
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
},
|
|
28
|
+
enabled: !!t.uid && !!n.uid,
|
|
29
|
+
staleTime: u ? 0 : 1 / 0
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
const he = ({ version: t }) => {
|
|
33
|
+
const n = t == null ? void 0 : t.item, { data: o } = de(n == null ? void 0 : n.currentEditor), s = t.label === "live", u = t.label === "draft";
|
|
34
|
+
return /* @__PURE__ */ h(
|
|
35
|
+
"span",
|
|
36
|
+
{
|
|
37
|
+
className: `flex items-center gap-x-2 rounded border bg-white px-2 text-xs shadow-lg ${s ? "border-green-500/30" : u ? "border-amber-500/30" : "border-purple-500/30"}`,
|
|
38
|
+
children: [
|
|
39
|
+
/* @__PURE__ */ e(
|
|
40
|
+
"div",
|
|
41
|
+
{
|
|
42
|
+
className: "h-full items-center rounded px-1.5 py-0.5 font-medium capitalize" + (s ? " bg-green-500 text-green-50" : u ? " bg-amber-500 text-amber-50" : " bg-purple-500 text-purple-50"),
|
|
43
|
+
children: t.label
|
|
44
|
+
}
|
|
45
|
+
),
|
|
46
|
+
/* @__PURE__ */ h("div", { className: "py-1 text-xs font-light leading-none text-gray-800", children: [
|
|
47
|
+
/* @__PURE__ */ h("div", { children: [
|
|
48
|
+
/* @__PURE__ */ e("span", { className: "font-light opacity-90", children: u ? "Currently editing" : "Published by" }),
|
|
49
|
+
!u && /* @__PURE__ */ e("span", { className: "pl-1 font-medium", children: (o == null ? void 0 : o.name) || "Unknown" })
|
|
50
|
+
] }),
|
|
51
|
+
/* @__PURE__ */ e("div", { className: "text-[10px] leading-tight", children: Q(n.createdAt, "dd MMM yyyy, h:mm a") })
|
|
52
|
+
] })
|
|
53
|
+
]
|
|
54
|
+
}
|
|
55
|
+
);
|
|
56
|
+
}, K = ({ version: t }) => /* @__PURE__ */ e(he, { version: t });
|
|
57
|
+
function ue(t, n, o = "data.json") {
|
|
58
|
+
const s = JSON.stringify(t, null, 2), u = JSON.stringify(n, null, 2), l = s.split(`
|
|
59
|
+
`), r = u.split(`
|
|
60
|
+
`);
|
|
61
|
+
let d = `--- a/${o}
|
|
62
|
+
`;
|
|
63
|
+
d += `+++ b/${o}
|
|
64
|
+
`;
|
|
65
|
+
const f = [];
|
|
66
|
+
let c = 0, p = 0;
|
|
67
|
+
for (; c < l.length || p < r.length; ) {
|
|
68
|
+
const g = l[c] || "", N = r[p] || "";
|
|
69
|
+
if (g === N)
|
|
70
|
+
f.push(` ${g}`), c++, p++;
|
|
71
|
+
else {
|
|
72
|
+
let m = -1, x = -1;
|
|
73
|
+
for (let a = c + 1; a < l.length; a++)
|
|
74
|
+
if (r[p] === l[a]) {
|
|
75
|
+
m = a;
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
for (let a = p + 1; a < r.length; a++)
|
|
79
|
+
if (l[c] === r[a]) {
|
|
80
|
+
x = a;
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
if (m !== -1 && (x === -1 || m - c <= x - p)) {
|
|
84
|
+
for (let a = c; a < m; a++)
|
|
85
|
+
f.push(`-${l[a]}`);
|
|
86
|
+
c = m;
|
|
87
|
+
} else if (x !== -1) {
|
|
88
|
+
for (let a = p; a < x; a++)
|
|
89
|
+
f.push(`+${r[a]}`);
|
|
90
|
+
p = x;
|
|
91
|
+
} else
|
|
92
|
+
g && f.push(`-${g}`), N && f.push(`+${N}`), c++, p++;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
const y = l.length, j = r.length;
|
|
96
|
+
return d += `@@ -1,${y} +1,${j} @@
|
|
97
|
+
`, d += f.join(`
|
|
98
|
+
`) + `
|
|
99
|
+
`, d;
|
|
100
|
+
}
|
|
101
|
+
function S(t, n = !0, o = !1) {
|
|
102
|
+
if (X(t)) {
|
|
103
|
+
const s = Y(t);
|
|
104
|
+
if (T(s, "{") || T(s, "[") || n && (s === "true" || s === "false" || s === "null" || /^-?\d+(\.\d+)?([eE][+-]?\d+)?$/.test(s)))
|
|
105
|
+
try {
|
|
106
|
+
const l = JSON.parse(s);
|
|
107
|
+
return S(l, n, o);
|
|
108
|
+
} catch {
|
|
109
|
+
if (o)
|
|
110
|
+
throw new Error(`Invalid JSON string: ${s}`);
|
|
111
|
+
return {};
|
|
112
|
+
}
|
|
113
|
+
return t;
|
|
114
|
+
}
|
|
115
|
+
return Z(t) ? ee(t, (s) => S(s, n, o)) : te(t) ? re(t, (s) => S(s, n, o)) : t;
|
|
116
|
+
}
|
|
117
|
+
const pe = (t) => {
|
|
118
|
+
switch (t) {
|
|
119
|
+
case "blocks":
|
|
120
|
+
return "Blocks";
|
|
121
|
+
case "seo":
|
|
122
|
+
return "SEO";
|
|
123
|
+
case "tracking":
|
|
124
|
+
return "Tracking";
|
|
125
|
+
default:
|
|
126
|
+
return t;
|
|
127
|
+
}
|
|
128
|
+
}, ge = (t, n) => {
|
|
129
|
+
if (!t || !n) return [{ key: "blocks", label: "Blocks" }];
|
|
130
|
+
const o = Object.keys(t), s = Object.keys(n);
|
|
131
|
+
return o.filter((r) => s.includes(r)).map((r) => ({ key: r, label: pe(r) })).filter((r) => r.key.length > 0);
|
|
132
|
+
}, xe = (t, n = 3) => {
|
|
133
|
+
const o = /* @__PURE__ */ new Set();
|
|
134
|
+
t.map((r, d) => ({ change: r, index: d })).filter(({ change: r }) => r.type !== "normal").map(({ index: r }) => r).forEach((r) => {
|
|
135
|
+
const d = Math.max(0, r - n), f = Math.min(t.length - 1, r + n);
|
|
136
|
+
for (let c = d; c <= f; c++)
|
|
137
|
+
o.add(c);
|
|
138
|
+
});
|
|
139
|
+
const u = [];
|
|
140
|
+
let l = -1;
|
|
141
|
+
return t.forEach((r, d) => {
|
|
142
|
+
if (o.has(d)) {
|
|
143
|
+
if (l !== -1 && d - l > 1) {
|
|
144
|
+
const f = t[l].lineNumber != null ? t[l].lineNumber + 1 : l + 2, c = t[d].lineNumber != null ? t[d].lineNumber - 1 : d;
|
|
145
|
+
u.push({
|
|
146
|
+
content: /* @__PURE__ */ e(P, { className: "pointer-events-none w-60 -translate-x-1/2 cursor-default border-none bg-transparent py-1 shadow-none", children: /* @__PURE__ */ h("span", { className: "rounded border border-border bg-muted px-3 py-1 text-xs font-light leading-none text-muted-foreground", children: [
|
|
147
|
+
"No changes from ",
|
|
148
|
+
f,
|
|
149
|
+
" to ",
|
|
150
|
+
c,
|
|
151
|
+
" line"
|
|
152
|
+
] }) })
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
u.push(r), l = d;
|
|
156
|
+
}
|
|
157
|
+
}), u;
|
|
158
|
+
};
|
|
159
|
+
function Te({ open: t, compare: n, onOpenChange: o }) {
|
|
160
|
+
const s = n[0], u = n[1], [l, r] = D(null), [d, f] = D("split"), [c, p] = D(!1), [y, j] = D(!0), [g, N] = D("blocks"), { data: m, isLoading: x } = me(s, u), { leftData: a, rightData: w, options: U } = A(() => {
|
|
161
|
+
var b, R;
|
|
162
|
+
const i = (b = m == null ? void 0 : m.version1) == null ? void 0 : b[g], v = (R = m == null ? void 0 : m.version2) == null ? void 0 : R[g], k = S(i), C = S(v), J = ge(m == null ? void 0 : m.version1, m == null ? void 0 : m.version2);
|
|
163
|
+
return { leftData: k, rightData: C, options: J };
|
|
164
|
+
}, [m, g]), O = A(() => !a || !w ? "" : ue(a, w), [a, w]), E = A(() => {
|
|
165
|
+
if (!O) return [];
|
|
166
|
+
try {
|
|
167
|
+
return se(O);
|
|
168
|
+
} catch (i) {
|
|
169
|
+
return console.error("Failed to parse diff:", i), [];
|
|
170
|
+
}
|
|
171
|
+
}, [O]), L = async (i, v) => {
|
|
172
|
+
try {
|
|
173
|
+
await navigator.clipboard.writeText(JSON.stringify(i, null, 2)), r(v), setTimeout(() => r(null), 2e3);
|
|
174
|
+
} catch (k) {
|
|
175
|
+
console.error("Failed to copy:", k);
|
|
176
|
+
}
|
|
177
|
+
}, M = (i) => JSON.stringify(i, null, 2);
|
|
178
|
+
return /* @__PURE__ */ e(V, { open: t, onOpenChange: o, children: /* @__PURE__ */ h(_, { className: "flex h-[90vh] w-[95vw] max-w-[1900px] flex-col p-6", children: [
|
|
179
|
+
/* @__PURE__ */ e(q, { className: "pb-4 pt-0", children: /* @__PURE__ */ h(G, { className: "flex items-center justify-between gap-2 leading-none", children: [
|
|
180
|
+
/* @__PURE__ */ h("div", { className: "flex items-center gap-2", children: [
|
|
181
|
+
/* @__PURE__ */ e(B, { className: "h-5 w-5" }),
|
|
182
|
+
"Compare",
|
|
183
|
+
"",
|
|
184
|
+
U.map((i) => /* @__PURE__ */ e(
|
|
185
|
+
"div",
|
|
186
|
+
{
|
|
187
|
+
className: `cursor-pointer rounded-full border px-2.5 py-1 text-xs leading-none ${g === i.key ? "border-blue-500 bg-blue-500 text-white" : "border-gray-600 text-gray-600 hover:bg-gray-200"}`,
|
|
188
|
+
onClick: () => N(i.key),
|
|
189
|
+
children: i.label
|
|
190
|
+
},
|
|
191
|
+
i.key
|
|
192
|
+
))
|
|
193
|
+
] }),
|
|
194
|
+
/* @__PURE__ */ e("div", { className: "flex flex-1 items-center justify-end pr-8", children: /* @__PURE__ */ h("div", { className: "flex w-max items-center justify-end gap-2 rounded-md border px-1.5 py-1", children: [
|
|
195
|
+
/* @__PURE__ */ h("div", { className: "flex items-center gap-2 px-2 py-1", children: [
|
|
196
|
+
/* @__PURE__ */ e(
|
|
197
|
+
$,
|
|
198
|
+
{
|
|
199
|
+
disabled: c,
|
|
200
|
+
checked: c ? !0 : d === "split",
|
|
201
|
+
onCheckedChange: (i) => f(i ? "split" : "unified")
|
|
202
|
+
}
|
|
203
|
+
),
|
|
204
|
+
/* @__PURE__ */ e("label", { className: "text-sm", children: "Split View" })
|
|
205
|
+
] }),
|
|
206
|
+
/* @__PURE__ */ h("div", { className: "flex items-center gap-2 px-2 py-1", children: [
|
|
207
|
+
/* @__PURE__ */ e($, { checked: c, onCheckedChange: (i) => p(i) }),
|
|
208
|
+
/* @__PURE__ */ e("label", { className: "text-sm", children: "Show Raw Data" })
|
|
209
|
+
] }),
|
|
210
|
+
/* @__PURE__ */ h("div", { className: "flex items-center gap-2 px-2 py-1", children: [
|
|
211
|
+
/* @__PURE__ */ e($, { checked: y, onCheckedChange: (i) => j(i) }),
|
|
212
|
+
/* @__PURE__ */ e("label", { className: "text-sm", children: "Hide Common Data" })
|
|
213
|
+
] })
|
|
214
|
+
] }) })
|
|
215
|
+
] }) }),
|
|
216
|
+
x ? /* @__PURE__ */ e("div", { className: "flex h-full w-full items-center justify-center", children: /* @__PURE__ */ e(ne, { className: "h-6 w-6 animate-spin text-primary" }) }) : /* @__PURE__ */ e("div", { className: "flex min-h-0 flex-1 flex-col", children: /* @__PURE__ */ h("div", { className: "relative min-h-0 flex-1", children: [
|
|
217
|
+
/* @__PURE__ */ h("div", { className: "absolute -top-5 z-50 mt-0.5 flex w-full items-center justify-between gap-2", children: [
|
|
218
|
+
/* @__PURE__ */ e("div", { className: "flex w-1/2 items-center justify-center gap-2", children: /* @__PURE__ */ e(K, { version: s }) }),
|
|
219
|
+
/* @__PURE__ */ e("div", { className: "flex w-1/2 items-center justify-center gap-2", children: /* @__PURE__ */ e(K, { version: u }) })
|
|
220
|
+
] }),
|
|
221
|
+
c ? /* @__PURE__ */ h("div", { className: "grid h-full grid-cols-2 gap-3 rounded-lg border", children: [
|
|
222
|
+
/* @__PURE__ */ h("div", { className: "relative flex min-h-0 flex-col border-r", children: [
|
|
223
|
+
/* @__PURE__ */ e("div", { className: "absolute -top-4 right-4 z-50", children: /* @__PURE__ */ h(z, { variant: "outline", size: "sm", onClick: () => L(a, "left"), children: [
|
|
224
|
+
l === "left" ? /* @__PURE__ */ e(F, { className: "text-green-500" }) : /* @__PURE__ */ e(H, {}),
|
|
225
|
+
"Copy"
|
|
226
|
+
] }) }),
|
|
227
|
+
/* @__PURE__ */ e(I, { className: "flex-1 rounded-lg bg-slate-50 p-3 dark:bg-slate-900", children: /* @__PURE__ */ e("pre", { className: "whitespace-pre-wrap font-mono text-xs", children: M(a) }) })
|
|
228
|
+
] }),
|
|
229
|
+
/* @__PURE__ */ h("div", { className: "relative flex min-h-0 flex-col", children: [
|
|
230
|
+
/* @__PURE__ */ e("div", { className: "absolute -top-4 right-4 z-50", children: /* @__PURE__ */ h(z, { variant: "outline", size: "sm", onClick: () => L(w, "right"), children: [
|
|
231
|
+
l === "right" ? /* @__PURE__ */ e(F, { className: "text-green-500" }) : /* @__PURE__ */ e(H, {}),
|
|
232
|
+
"Copy"
|
|
233
|
+
] }) }),
|
|
234
|
+
/* @__PURE__ */ e(I, { className: "flex-1 rounded-lg bg-slate-50 p-3 dark:bg-slate-900", children: /* @__PURE__ */ e("pre", { className: "whitespace-pre-wrap font-mono text-xs", children: M(w) }) })
|
|
235
|
+
] })
|
|
236
|
+
] }) : /* @__PURE__ */ e(I, { className: "h-full overflow-y-auto rounded-lg border bg-slate-50 text-xs dark:bg-slate-900", children: E.length === 0 ? /* @__PURE__ */ e("div", { className: "flex h-full items-center justify-center p-6", children: /* @__PURE__ */ h("div", { className: "text-center text-muted-foreground", children: [
|
|
237
|
+
/* @__PURE__ */ e(B, { className: "mx-auto mb-2 h-8 w-8 opacity-50" }),
|
|
238
|
+
/* @__PURE__ */ e("p", { children: "No differences found or unable to parse diff" })
|
|
239
|
+
] }) }) : /* @__PURE__ */ e("div", { children: E.map((i, v) => /* @__PURE__ */ e("div", { className: "relative mb-4", children: /* @__PURE__ */ e(
|
|
240
|
+
le,
|
|
241
|
+
{
|
|
242
|
+
viewType: d,
|
|
243
|
+
diffType: i.type,
|
|
244
|
+
hunks: i.hunks,
|
|
245
|
+
className: "rounded-lg text-xs",
|
|
246
|
+
children: (k) => k.map((C, J) => {
|
|
247
|
+
const b = y ? xe(C.changes) : C.changes;
|
|
248
|
+
return (b == null ? void 0 : b.length) === 0 ? /* @__PURE__ */ e("div", { className: "absolute h-full w-full border-l pt-64 text-center font-sans text-sm", children: /* @__PURE__ */ e("span", { children: "No difference found" }) }) : /* @__PURE__ */ e(ae, { hunk: { ...C, changes: b } }, J);
|
|
249
|
+
})
|
|
250
|
+
},
|
|
251
|
+
y ? "hide-common-data" : "show-common-data"
|
|
252
|
+
) }, v)) }) })
|
|
253
|
+
] }) })
|
|
254
|
+
] }) });
|
|
255
|
+
}
|
|
256
|
+
export {
|
|
257
|
+
Te as default
|
|
258
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),x=require("./index-CnSjWE1P.cjs"),z=require("date-fns"),p=require("lodash-es"),N=require("lucide-react"),b=require("react"),M=require("react-diff-view"),O=require("./index-CbwxUFy_.cjs"),B=require("@tanstack/react-query");function H(t,r){const o=O.useApiUrl(),n=O.useFetch(),f=p.startsWith(t.uid,"draft:")||p.startsWith(r.uid,"live:");return B.useQuery({queryKey:["revision-comparison",t.uid,r.uid],queryFn:async()=>{if(!t.uid||!r.uid)throw new Error("Both revision IDs are required for comparison");const l=u=>u==="draft"||u==="live"?u:"revision",s=u=>p.replace(u.uid,`${u.label}:`,"");return await n(o,{action:O.ACTIONS.GET_COMPARE_DATA,data:{versions:{version1:{type:l(t.label),id:s(t)},version2:{type:l(r.label),id:s(r)}}}})},enabled:!!t.uid&&!!r.uid,staleTime:f?0:1/0})}const K=({version:t})=>{const r=t==null?void 0:t.item,{data:o}=O.useChaiUserInfo(r==null?void 0:r.currentEditor),n=t.label==="live",f=t.label==="draft";return e.jsxs("span",{className:`flex items-center gap-x-2 rounded border bg-white px-2 text-xs shadow-lg ${n?"border-green-500/30":f?"border-amber-500/30":"border-purple-500/30"}`,children:[e.jsx("div",{className:"h-full items-center rounded px-1.5 py-0.5 font-medium capitalize"+(n?" bg-green-500 text-green-50":f?" bg-amber-500 text-amber-50":" bg-purple-500 text-purple-50"),children:t.label}),e.jsxs("div",{className:"py-1 text-xs font-light leading-none text-gray-800",children:[e.jsxs("div",{children:[e.jsx("span",{className:"font-light opacity-90",children:f?"Currently editing":"Published by"}),!f&&e.jsx("span",{className:"pl-1 font-medium",children:(o==null?void 0:o.name)||"Unknown"})]}),e.jsx("div",{className:"text-[10px] leading-tight",children:z.formatDate(r.createdAt,"dd MMM yyyy, h:mm a")})]})]})},L=({version:t})=>e.jsx(K,{version:t});function V(t,r,o="data.json"){const n=JSON.stringify(t,null,2),f=JSON.stringify(r,null,2),l=n.split(`
|
|
2
|
+
`),s=f.split(`
|
|
3
|
+
`);let d=`--- a/${o}
|
|
4
|
+
`;d+=`+++ b/${o}
|
|
5
|
+
`;const u=[];let c=0,m=0;for(;c<l.length||m<s.length;){const g=l[c]||"",v=s[m]||"";if(g===v)u.push(` ${g}`),c++,m++;else{let h=-1,j=-1;for(let a=c+1;a<l.length;a++)if(s[m]===l[a]){h=a;break}for(let a=m+1;a<s.length;a++)if(l[c]===s[a]){j=a;break}if(h!==-1&&(j===-1||h-c<=j-m)){for(let a=c;a<h;a++)u.push(`-${l[a]}`);c=h}else if(j!==-1){for(let a=m;a<j;a++)u.push(`+${s[a]}`);m=j}else g&&u.push(`-${g}`),v&&u.push(`+${v}`),c++,m++}}const w=l.length,J=s.length;return d+=`@@ -1,${w} +1,${J} @@
|
|
6
|
+
`,d+=u.join(`
|
|
7
|
+
`)+`
|
|
8
|
+
`,d}function T(t,r=!0,o=!1){if(p.isString(t)){const n=p.trim(t);if(p.startsWith(n,"{")||p.startsWith(n,"[")||r&&(n==="true"||n==="false"||n==="null"||/^-?\d+(\.\d+)?([eE][+-]?\d+)?$/.test(n)))try{const l=JSON.parse(n);return T(l,r,o)}catch{if(o)throw new Error(`Invalid JSON string: ${n}`);return{}}return t}return p.isArray(t)?p.map(t,n=>T(n,r,o)):p.isPlainObject(t)?p.mapValues(t,n=>T(n,r,o)):t}const U=t=>{switch(t){case"blocks":return"Blocks";case"seo":return"SEO";case"tracking":return"Tracking";default:return t}},W=(t,r)=>{if(!t||!r)return[{key:"blocks",label:"Blocks"}];const o=Object.keys(t),n=Object.keys(r);return o.filter(s=>n.includes(s)).map(s=>({key:s,label:U(s)})).filter(s=>s.key.length>0)},_=(t,r=3)=>{const o=new Set;t.map((s,d)=>({change:s,index:d})).filter(({change:s})=>s.type!=="normal").map(({index:s})=>s).forEach(s=>{const d=Math.max(0,s-r),u=Math.min(t.length-1,s+r);for(let c=d;c<=u;c++)o.add(c)});const f=[];let l=-1;return t.forEach((s,d)=>{if(o.has(d)){if(l!==-1&&d-l>1){const u=t[l].lineNumber!=null?t[l].lineNumber+1:l+2,c=t[d].lineNumber!=null?t[d].lineNumber-1:d;f.push({content:e.jsx(x.Badge,{className:"pointer-events-none w-60 -translate-x-1/2 cursor-default border-none bg-transparent py-1 shadow-none",children:e.jsxs("span",{className:"rounded border border-border bg-muted px-3 py-1 text-xs font-light leading-none text-muted-foreground",children:["No changes from ",u," to ",c," line"]})})})}f.push(s),l=d}}),f};function P({open:t,compare:r,onOpenChange:o}){const n=r[0],f=r[1],[l,s]=b.useState(null),[d,u]=b.useState("split"),[c,m]=b.useState(!1),[w,J]=b.useState(!0),[g,v]=b.useState("blocks"),{data:h,isLoading:j}=H(n,f),{leftData:a,rightData:k,options:F}=b.useMemo(()=>{var y,R;const i=(y=h==null?void 0:h.version1)==null?void 0:y[g],C=(R=h==null?void 0:h.version2)==null?void 0:R[g],S=T(i),D=T(C),q=W(h==null?void 0:h.version1,h==null?void 0:h.version2);return{leftData:S,rightData:D,options:q}},[h,g]),$=b.useMemo(()=>!a||!k?"":V(a,k),[a,k]),A=b.useMemo(()=>{if(!$)return[];try{return M.parseDiff($)}catch(i){return console.error("Failed to parse diff:",i),[]}},[$]),I=async(i,C)=>{try{await navigator.clipboard.writeText(JSON.stringify(i,null,2)),s(C),setTimeout(()=>s(null),2e3)}catch(S){console.error("Failed to copy:",S)}},E=i=>JSON.stringify(i,null,2);return e.jsx(x.Dialog,{open:t,onOpenChange:o,children:e.jsxs(x.DialogContent,{className:"flex h-[90vh] w-[95vw] max-w-[1900px] flex-col p-6",children:[e.jsx(x.DialogHeader,{className:"pb-4 pt-0",children:e.jsxs(x.DialogTitle,{className:"flex items-center justify-between gap-2 leading-none",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(N.FileJson,{className:"h-5 w-5"}),"Compare","",F.map(i=>e.jsx("div",{className:`cursor-pointer rounded-full border px-2.5 py-1 text-xs leading-none ${g===i.key?"border-blue-500 bg-blue-500 text-white":"border-gray-600 text-gray-600 hover:bg-gray-200"}`,onClick:()=>v(i.key),children:i.label},i.key))]}),e.jsx("div",{className:"flex flex-1 items-center justify-end pr-8",children:e.jsxs("div",{className:"flex w-max items-center justify-end gap-2 rounded-md border px-1.5 py-1",children:[e.jsxs("div",{className:"flex items-center gap-2 px-2 py-1",children:[e.jsx(x.Switch,{disabled:c,checked:c?!0:d==="split",onCheckedChange:i=>u(i?"split":"unified")}),e.jsx("label",{className:"text-sm",children:"Split View"})]}),e.jsxs("div",{className:"flex items-center gap-2 px-2 py-1",children:[e.jsx(x.Switch,{checked:c,onCheckedChange:i=>m(i)}),e.jsx("label",{className:"text-sm",children:"Show Raw Data"})]}),e.jsxs("div",{className:"flex items-center gap-2 px-2 py-1",children:[e.jsx(x.Switch,{checked:w,onCheckedChange:i=>J(i)}),e.jsx("label",{className:"text-sm",children:"Hide Common Data"})]})]})})]})}),j?e.jsx("div",{className:"flex h-full w-full items-center justify-center",children:e.jsx(N.Loader,{className:"h-6 w-6 animate-spin text-primary"})}):e.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:e.jsxs("div",{className:"relative min-h-0 flex-1",children:[e.jsxs("div",{className:"absolute -top-5 z-50 mt-0.5 flex w-full items-center justify-between gap-2",children:[e.jsx("div",{className:"flex w-1/2 items-center justify-center gap-2",children:e.jsx(L,{version:n})}),e.jsx("div",{className:"flex w-1/2 items-center justify-center gap-2",children:e.jsx(L,{version:f})})]}),c?e.jsxs("div",{className:"grid h-full grid-cols-2 gap-3 rounded-lg border",children:[e.jsxs("div",{className:"relative flex min-h-0 flex-col border-r",children:[e.jsx("div",{className:"absolute -top-4 right-4 z-50",children:e.jsxs(x.Button,{variant:"outline",size:"sm",onClick:()=>I(a,"left"),children:[l==="left"?e.jsx(N.Check,{className:"text-green-500"}):e.jsx(N.Copy,{}),"Copy"]})}),e.jsx(x.ScrollArea,{className:"flex-1 rounded-lg bg-slate-50 p-3 dark:bg-slate-900",children:e.jsx("pre",{className:"whitespace-pre-wrap font-mono text-xs",children:E(a)})})]}),e.jsxs("div",{className:"relative flex min-h-0 flex-col",children:[e.jsx("div",{className:"absolute -top-4 right-4 z-50",children:e.jsxs(x.Button,{variant:"outline",size:"sm",onClick:()=>I(k,"right"),children:[l==="right"?e.jsx(N.Check,{className:"text-green-500"}):e.jsx(N.Copy,{}),"Copy"]})}),e.jsx(x.ScrollArea,{className:"flex-1 rounded-lg bg-slate-50 p-3 dark:bg-slate-900",children:e.jsx("pre",{className:"whitespace-pre-wrap font-mono text-xs",children:E(k)})})]})]}):e.jsx(x.ScrollArea,{className:"h-full overflow-y-auto rounded-lg border bg-slate-50 text-xs dark:bg-slate-900",children:A.length===0?e.jsx("div",{className:"flex h-full items-center justify-center p-6",children:e.jsxs("div",{className:"text-center text-muted-foreground",children:[e.jsx(N.FileJson,{className:"mx-auto mb-2 h-8 w-8 opacity-50"}),e.jsx("p",{children:"No differences found or unable to parse diff"})]})}):e.jsx("div",{children:A.map((i,C)=>e.jsx("div",{className:"relative mb-4",children:e.jsx(M.Diff,{viewType:d,diffType:i.type,hunks:i.hunks,className:"rounded-lg text-xs",children:S=>S.map((D,q)=>{const y=w?_(D.changes):D.changes;return(y==null?void 0:y.length)===0?e.jsx("div",{className:"absolute h-full w-full border-l pt-64 text-center font-sans text-sm",children:e.jsx("span",{children:"No difference found"})}):e.jsx(M.Hunk,{hunk:{...D,changes:y}},q)})},w?"hide-common-data":"show-common-data")},C))})})]})})]})})}exports.default=P;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("./index-CnSjWE1P.cjs"),n=require("./index-CbwxUFy_.cjs"),r=require("lodash-es"),j=require("lucide-react"),c=require("react"),w=require("react-i18next"),G=require("sonner"),L=require("jotai"),k=({page:s,onClose:S})=>{const{t:a}=w.useTranslation(),[o,E]=c.useState(s.slug||""),{mutate:N,isPending:y}=n.useChangeSlug(),{data:l}=n.usePageTypes(),d=r.find(l,{key:s==null?void 0:s.pageType}),f=h=>{if(h.preventDefault(),!(s!=null&&s.primaryPage)&&Object.keys(n.LANGUAGES).some(p=>o===`/${p}`||r.startsWith(o,`/${p}/`))){G.toast.error(a("Error"),{description:a("Slugs cannot start with a language code for primary page")});return}N({...s,slug:o},{onSuccess:S})},m=(s==null?void 0:s.lang)||"";return e.jsx(i.Dialog,{open:!!s,onOpenChange:S,children:e.jsxs(i.DialogContent,{children:[e.jsxs(i.DialogHeader,{children:[e.jsx(i.DialogTitle,{children:a("Change Slug")}),e.jsx(i.DialogDescription,{className:"text-xs",children:e.jsxs(i.Alert,{variant:"destructive",className:"mt-2",children:[e.jsx(j.AlertCircle,{className:"h-4 w-4"}),a("Changing the slug may have impact on your SEO. Please proceed with caution.")]})})]}),e.jsxs("form",{onSubmit:f,children:[e.jsxs("div",{className:"space-y-4 py-4 text-sm",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{children:[e.jsxs("span",{children:[a("Type"),":"]}),e.jsxs("span",{className:"font-medium text-gray-600",children:[" ",(d==null?void 0:d.name)||(s==null?void 0:s.pageType)]})]}),e.jsxs("div",{children:[e.jsxs("span",{children:[a("Name"),":"]}),e.jsxs("span",{className:"font-medium text-gray-600",children:[" ",s.name]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs(i.Label,{htmlFor:"slug",className:"text-right",children:[a("Slug")," ",e.jsxs("small",{className:"font-light text-gray-500",children:[a("Slug should start with")," /",m]})]}),e.jsx(i.Input,{id:"slug",value:o,onChange:h=>{const x=h.target.value;r.startsWith(x,`/${m}`)&&E(x)},className:"col-span-3",required:!0,pattern:"^/.*",title:a("Slug must start with /"),placeholder:a("Enter page slug")})]})]}),e.jsx(i.DialogFooter,{children:e.jsx(i.Button,{type:"submit",disabled:y||!r.startsWith(o,`/${m}`)||r.isEqual(s==null?void 0:s.slug,o),children:a(y?"Changing...":"Change Slug")})})]})]})})},M=c.lazy(()=>Promise.resolve().then(()=>require("./delete-page-ByQwBupJ.cjs"))),T=c.lazy(()=>Promise.resolve().then(()=>require("./unpublish-page-BwSVBf0_.cjs"))),_=()=>{const{t:s}=w.useTranslation(),S=L.useSetAtom(n.addNewLangAtom),{selectedLang:a,fallbackLang:o,setSelectedLang:E}=i.useLanguages(),{data:N,isFetching:y}=n.useLanguagePages(),{data:l}=n.useChaiCurrentPage(),{data:d}=n.usePageTypes(),f=c.useMemo(()=>{const t=d==null?void 0:d.find(g=>g.key===(l==null?void 0:l.pageType));return l!=null&&l.dynamic?t==null?void 0:t.dynamicSlug:""},[d,l==null?void 0:l.pageType,l==null?void 0:l.dynamic]),[m,h]=c.useState(null),[x,P]=c.useState(null),[p,I]=c.useState(null),{data:C}=n.useWebsiteSetting(),A=r.filter(r.get(C,"languages")||["en"],t=>!r.find(N,{lang:t})&&t!==r.get(C,"fallbackLang"));return e.jsxs("div",{className:"space-y-4",children:[e.jsx("ul",{className:"space-y-2",children:y?e.jsxs("div",{className:"w-full space-y-3 py-4",children:[e.jsx("div",{className:"h-8 w-full animate-pulse rounded bg-gray-300"}),e.jsx("div",{className:"h-8 w-full animate-pulse rounded bg-gray-300"}),e.jsx("div",{className:"h-8 w-full animate-pulse rounded bg-gray-300"})]}):r.map(N,t=>{const g=t.lang,v=t.slug,b=!t.primaryPage,D=g===a;return e.jsxs(e.Fragment,{children:[e.jsxs("li",{className:`flex w-full cursor-pointer items-center justify-between rounded p-2 text-slate-500 ${D?"bg-gray-200":"hover:bg-gray-100"}`,onClick:()=>E(g),children:[e.jsxs("div",{className:"flex-1 gap-x-3",children:[e.jsxs("div",{className:"flex items-center gap-x-2 text-[13px] text-slate-800",children:[e.jsx("div",{className:`h-2.5 w-2.5 rounded-full ${t.online?"bg-green-300":"bg-gray-300"}`}),r.get(n.LANGUAGES,b?o:g,g)]}),e.jsxs("div",{children:[v&&e.jsxs("div",{className:"text-[11px] font-light text-slate-600",children:["Slug: ",e.jsx("b",{className:"font-mono font-medium",children:f?`${v}/${f}`:v})]}),e.jsxs("div",{className:"text-[11px] font-light text-slate-600",children:["Name:",e.jsxs("b",{className:"font-medium",children:[" ",t.name," "]})]})]})]}),b?e.jsxs("div",{className:"flex items-center gap-x-1 text-[11px] text-orange-500",children:[e.jsx(j.StarIcon,{fill:"orange",className:"h-3 w-3"}),e.jsx("b",{children:" Primary"})]}):e.jsx("div",{className:"flex items-center gap-x-3",children:e.jsx(n.PermissionChecker,{permissions:[n.PAGES_PERMISSIONS.EDIT_PAGE,n.PAGES_PERMISSIONS.DELETE_PAGE,n.PAGES_PERMISSIONS.UNPUBLISH_PAGE],children:e.jsxs(i.DropdownMenu,{children:[e.jsx(i.DropdownMenuTrigger,{asChild:!0,onClick:u=>u.stopPropagation(),children:e.jsx(i.Button,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",children:e.jsx(j.MoreHorizontal,{className:"h-4 w-4"})})}),e.jsxs(i.DropdownMenuContent,{align:"end",className:"z-[9999] text-sm",children:[e.jsx(n.PermissionChecker,{permissions:[n.PAGES_PERMISSIONS.EDIT_PAGE],children:e.jsxs(i.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:u=>{u.stopPropagation(),S({edit:!0,id:t.id,primaryPage:t.primaryPage})},children:[e.jsx(j.PencilIcon,{className:"size-3"}),s("Edit")]})}),e.jsx(n.PermissionChecker,{permissions:[n.PAGES_PERMISSIONS.UNPUBLISH_PAGE],children:(t==null?void 0:t.online)&&e.jsxs(i.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:u=>{u.stopPropagation(),P(t)},children:[e.jsx(j.Power,{className:"size-3"}),s("Unpublish")]})}),e.jsx(n.PermissionChecker,{permissions:[n.PAGES_PERMISSIONS.DELETE_PAGE],children:e.jsxs(i.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:u=>{u.stopPropagation(),h(t)},children:[e.jsx(j.TrashIcon,{className:"size-3"}),s("Delete")]})})]})]})})})]},t.id),e.jsx("div",{className:"h-1 w-full border-b"})]})})}),e.jsx(n.PermissionChecker,{permissions:[n.PAGES_PERMISSIONS.ADD_PAGE],children:e.jsx("div",{className:"flex w-full justify-center",children:e.jsx(i.Button,{variant:"default",size:"sm",disabled:r.isEmpty(A),onClick:()=>{S({primaryPage:l==null?void 0:l.id,edit:!1})},children:s("Add new language page")})})}),m&&e.jsx(c.Suspense,{children:e.jsx(M,{page:m,onClose:()=>h(null)})}),x&&e.jsx(c.Suspense,{children:e.jsx(T,{page:x,onClose:()=>P(null)})}),p&&e.jsx(c.Suspense,{children:e.jsx(k,{page:p,onClose:()=>I(null)})})]})};exports.default=_;
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { jsx as e, jsxs as s, Fragment as M } from "react/jsx-runtime";
|
|
2
|
+
import { D as j, d as F, e as B, f as H, p as O, A as W, L as q, I as R, q as J, B as A, n as K, r as Q, s as V, t as X, v as w } from "./index-S8ibZk9Q.js";
|
|
3
|
+
import { au as Y, m as I, L as T, av as Z, l as ee, aw as se, j as ae, ax as f, ay as o } from "./index-BDnwJqMw.js";
|
|
4
|
+
import { find as G, startsWith as E, isEqual as ne, filter as te, get as D, map as le, isEmpty as ie } from "lodash-es";
|
|
5
|
+
import { AlertCircle as re, StarIcon as ce, MoreHorizontal as oe, PencilIcon as de, Power as me, TrashIcon as ue } from "lucide-react";
|
|
6
|
+
import { useState as S, useMemo as he, Suspense as L, lazy as z } from "react";
|
|
7
|
+
import { useTranslation as U } from "react-i18next";
|
|
8
|
+
import { toast as ge } from "sonner";
|
|
9
|
+
import { useSetAtom as pe } from "jotai";
|
|
10
|
+
const fe = ({ page: a, onClose: g }) => {
|
|
11
|
+
const { t: l } = U(), [i, v] = S(a.slug || ""), { mutate: N, isPending: y } = Y(), { data: t } = I(), r = G(t, { key: a == null ? void 0 : a.pageType }), x = (m) => {
|
|
12
|
+
if (m.preventDefault(), !(a != null && a.primaryPage) && Object.keys(T).some((p) => i === `/${p}` || E(i, `/${p}/`))) {
|
|
13
|
+
ge.error(l("Error"), {
|
|
14
|
+
description: l("Slugs cannot start with a language code for primary page")
|
|
15
|
+
});
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
N({ ...a, slug: i }, { onSuccess: g });
|
|
19
|
+
}, d = (a == null ? void 0 : a.lang) || "";
|
|
20
|
+
return /* @__PURE__ */ e(j, { open: !!a, onOpenChange: g, children: /* @__PURE__ */ s(F, { children: [
|
|
21
|
+
/* @__PURE__ */ s(B, { children: [
|
|
22
|
+
/* @__PURE__ */ e(H, { children: l("Change Slug") }),
|
|
23
|
+
/* @__PURE__ */ e(O, { className: "text-xs", children: /* @__PURE__ */ s(W, { variant: "destructive", className: "mt-2", children: [
|
|
24
|
+
/* @__PURE__ */ e(re, { className: "h-4 w-4" }),
|
|
25
|
+
l("Changing the slug may have impact on your SEO. Please proceed with caution.")
|
|
26
|
+
] }) })
|
|
27
|
+
] }),
|
|
28
|
+
/* @__PURE__ */ s("form", { onSubmit: x, children: [
|
|
29
|
+
/* @__PURE__ */ s("div", { className: "space-y-4 py-4 text-sm", children: [
|
|
30
|
+
/* @__PURE__ */ s("div", { className: "space-y-1", children: [
|
|
31
|
+
/* @__PURE__ */ s("div", { children: [
|
|
32
|
+
/* @__PURE__ */ s("span", { children: [
|
|
33
|
+
l("Type"),
|
|
34
|
+
":"
|
|
35
|
+
] }),
|
|
36
|
+
/* @__PURE__ */ s("span", { className: "font-medium text-gray-600", children: [
|
|
37
|
+
" ",
|
|
38
|
+
(r == null ? void 0 : r.name) || (a == null ? void 0 : a.pageType)
|
|
39
|
+
] })
|
|
40
|
+
] }),
|
|
41
|
+
/* @__PURE__ */ s("div", { children: [
|
|
42
|
+
/* @__PURE__ */ s("span", { children: [
|
|
43
|
+
l("Name"),
|
|
44
|
+
":"
|
|
45
|
+
] }),
|
|
46
|
+
/* @__PURE__ */ s("span", { className: "font-medium text-gray-600", children: [
|
|
47
|
+
" ",
|
|
48
|
+
a.name
|
|
49
|
+
] })
|
|
50
|
+
] })
|
|
51
|
+
] }),
|
|
52
|
+
/* @__PURE__ */ s("div", { className: "space-y-1", children: [
|
|
53
|
+
/* @__PURE__ */ s(q, { htmlFor: "slug", className: "text-right", children: [
|
|
54
|
+
l("Slug"),
|
|
55
|
+
" ",
|
|
56
|
+
/* @__PURE__ */ s("small", { className: "font-light text-gray-500", children: [
|
|
57
|
+
l("Slug should start with"),
|
|
58
|
+
" /",
|
|
59
|
+
d
|
|
60
|
+
] })
|
|
61
|
+
] }),
|
|
62
|
+
/* @__PURE__ */ e(
|
|
63
|
+
R,
|
|
64
|
+
{
|
|
65
|
+
id: "slug",
|
|
66
|
+
value: i,
|
|
67
|
+
onChange: (m) => {
|
|
68
|
+
const u = m.target.value;
|
|
69
|
+
E(u, `/${d}`) && v(u);
|
|
70
|
+
},
|
|
71
|
+
className: "col-span-3",
|
|
72
|
+
required: !0,
|
|
73
|
+
pattern: "^/.*",
|
|
74
|
+
title: l("Slug must start with /"),
|
|
75
|
+
placeholder: l("Enter page slug")
|
|
76
|
+
}
|
|
77
|
+
)
|
|
78
|
+
] })
|
|
79
|
+
] }),
|
|
80
|
+
/* @__PURE__ */ e(J, { children: /* @__PURE__ */ e(A, { type: "submit", disabled: y || !E(i, `/${d}`) || ne(a == null ? void 0 : a.slug, i), children: l(y ? "Changing..." : "Change Slug") }) })
|
|
81
|
+
] })
|
|
82
|
+
] }) });
|
|
83
|
+
}, Ne = z(() => import("./delete-page-DC8pzvWW.js")), ye = z(() => import("./unpublish-page-Degu5Cy9.js")), Pe = () => {
|
|
84
|
+
const { t: a } = U(), g = pe(Z), { selectedLang: l, fallbackLang: i, setSelectedLang: v } = K(), { data: N, isFetching: y } = ee(), { data: t } = se(), { data: r } = I(), x = he(() => {
|
|
85
|
+
const n = r == null ? void 0 : r.find((h) => h.key === (t == null ? void 0 : t.pageType));
|
|
86
|
+
return t != null && t.dynamic ? n == null ? void 0 : n.dynamicSlug : "";
|
|
87
|
+
}, [r, t == null ? void 0 : t.pageType, t == null ? void 0 : t.dynamic]), [d, m] = S(null), [u, C] = S(null), [p, _] = S(null), { data: P } = ae(), $ = te(
|
|
88
|
+
D(P, "languages") || ["en"],
|
|
89
|
+
(n) => !G(N, { lang: n }) && n !== D(P, "fallbackLang")
|
|
90
|
+
);
|
|
91
|
+
return /* @__PURE__ */ s("div", { className: "space-y-4", children: [
|
|
92
|
+
/* @__PURE__ */ e("ul", { className: "space-y-2", children: y ? /* @__PURE__ */ s("div", { className: "w-full space-y-3 py-4", children: [
|
|
93
|
+
/* @__PURE__ */ e("div", { className: "h-8 w-full animate-pulse rounded bg-gray-300" }),
|
|
94
|
+
/* @__PURE__ */ e("div", { className: "h-8 w-full animate-pulse rounded bg-gray-300" }),
|
|
95
|
+
/* @__PURE__ */ e("div", { className: "h-8 w-full animate-pulse rounded bg-gray-300" })
|
|
96
|
+
] }) : le(N, (n) => {
|
|
97
|
+
const h = n.lang, b = n.slug, k = !n.primaryPage;
|
|
98
|
+
return /* @__PURE__ */ s(M, { children: [
|
|
99
|
+
/* @__PURE__ */ s(
|
|
100
|
+
"li",
|
|
101
|
+
{
|
|
102
|
+
className: `flex w-full cursor-pointer items-center justify-between rounded p-2 text-slate-500 ${h === l ? "bg-gray-200" : "hover:bg-gray-100"}`,
|
|
103
|
+
onClick: () => v(h),
|
|
104
|
+
children: [
|
|
105
|
+
/* @__PURE__ */ s("div", { className: "flex-1 gap-x-3", children: [
|
|
106
|
+
/* @__PURE__ */ s("div", { className: "flex items-center gap-x-2 text-[13px] text-slate-800", children: [
|
|
107
|
+
/* @__PURE__ */ e("div", { className: `h-2.5 w-2.5 rounded-full ${n.online ? "bg-green-300" : "bg-gray-300"}` }),
|
|
108
|
+
D(T, k ? i : h, h)
|
|
109
|
+
] }),
|
|
110
|
+
/* @__PURE__ */ s("div", { children: [
|
|
111
|
+
b && /* @__PURE__ */ s("div", { className: "text-[11px] font-light text-slate-600", children: [
|
|
112
|
+
"Slug: ",
|
|
113
|
+
/* @__PURE__ */ e("b", { className: "font-mono font-medium", children: x ? `${b}/${x}` : b })
|
|
114
|
+
] }),
|
|
115
|
+
/* @__PURE__ */ s("div", { className: "text-[11px] font-light text-slate-600", children: [
|
|
116
|
+
"Name:",
|
|
117
|
+
/* @__PURE__ */ s("b", { className: "font-medium", children: [
|
|
118
|
+
" ",
|
|
119
|
+
n.name,
|
|
120
|
+
" "
|
|
121
|
+
] })
|
|
122
|
+
] })
|
|
123
|
+
] })
|
|
124
|
+
] }),
|
|
125
|
+
k ? /* @__PURE__ */ s("div", { className: "flex items-center gap-x-1 text-[11px] text-orange-500", children: [
|
|
126
|
+
/* @__PURE__ */ e(ce, { fill: "orange", className: "h-3 w-3" }),
|
|
127
|
+
/* @__PURE__ */ e("b", { children: " Primary" })
|
|
128
|
+
] }) : /* @__PURE__ */ e("div", { className: "flex items-center gap-x-3", children: /* @__PURE__ */ e(
|
|
129
|
+
f,
|
|
130
|
+
{
|
|
131
|
+
permissions: [
|
|
132
|
+
o.EDIT_PAGE,
|
|
133
|
+
o.DELETE_PAGE,
|
|
134
|
+
o.UNPUBLISH_PAGE
|
|
135
|
+
],
|
|
136
|
+
children: /* @__PURE__ */ s(Q, { children: [
|
|
137
|
+
/* @__PURE__ */ e(V, { asChild: !0, onClick: (c) => c.stopPropagation(), children: /* @__PURE__ */ e(A, { variant: "ghost", size: "sm", className: "h-8 w-8 p-0", children: /* @__PURE__ */ e(oe, { className: "h-4 w-4" }) }) }),
|
|
138
|
+
/* @__PURE__ */ s(X, { align: "end", className: "z-[9999] text-sm", children: [
|
|
139
|
+
/* @__PURE__ */ e(f, { permissions: [o.EDIT_PAGE], children: /* @__PURE__ */ s(
|
|
140
|
+
w,
|
|
141
|
+
{
|
|
142
|
+
className: "flex cursor-pointer items-center gap-2",
|
|
143
|
+
onClick: (c) => {
|
|
144
|
+
c.stopPropagation(), g({
|
|
145
|
+
edit: !0,
|
|
146
|
+
id: n.id,
|
|
147
|
+
primaryPage: n.primaryPage
|
|
148
|
+
});
|
|
149
|
+
},
|
|
150
|
+
children: [
|
|
151
|
+
/* @__PURE__ */ e(de, { className: "size-3" }),
|
|
152
|
+
a("Edit")
|
|
153
|
+
]
|
|
154
|
+
}
|
|
155
|
+
) }),
|
|
156
|
+
/* @__PURE__ */ e(f, { permissions: [o.UNPUBLISH_PAGE], children: (n == null ? void 0 : n.online) && /* @__PURE__ */ s(
|
|
157
|
+
w,
|
|
158
|
+
{
|
|
159
|
+
className: "flex cursor-pointer items-center gap-2",
|
|
160
|
+
onClick: (c) => {
|
|
161
|
+
c.stopPropagation(), C(n);
|
|
162
|
+
},
|
|
163
|
+
children: [
|
|
164
|
+
/* @__PURE__ */ e(me, { className: "size-3" }),
|
|
165
|
+
a("Unpublish")
|
|
166
|
+
]
|
|
167
|
+
}
|
|
168
|
+
) }),
|
|
169
|
+
/* @__PURE__ */ e(f, { permissions: [o.DELETE_PAGE], children: /* @__PURE__ */ s(
|
|
170
|
+
w,
|
|
171
|
+
{
|
|
172
|
+
className: "flex cursor-pointer items-center gap-2",
|
|
173
|
+
onClick: (c) => {
|
|
174
|
+
c.stopPropagation(), m(n);
|
|
175
|
+
},
|
|
176
|
+
children: [
|
|
177
|
+
/* @__PURE__ */ e(ue, { className: "size-3" }),
|
|
178
|
+
a("Delete")
|
|
179
|
+
]
|
|
180
|
+
}
|
|
181
|
+
) })
|
|
182
|
+
] })
|
|
183
|
+
] })
|
|
184
|
+
}
|
|
185
|
+
) })
|
|
186
|
+
]
|
|
187
|
+
},
|
|
188
|
+
n.id
|
|
189
|
+
),
|
|
190
|
+
/* @__PURE__ */ e("div", { className: "h-1 w-full border-b" })
|
|
191
|
+
] });
|
|
192
|
+
}) }),
|
|
193
|
+
/* @__PURE__ */ e(f, { permissions: [o.ADD_PAGE], children: /* @__PURE__ */ e("div", { className: "flex w-full justify-center", children: /* @__PURE__ */ e(
|
|
194
|
+
A,
|
|
195
|
+
{
|
|
196
|
+
variant: "default",
|
|
197
|
+
size: "sm",
|
|
198
|
+
disabled: ie($),
|
|
199
|
+
onClick: () => {
|
|
200
|
+
g({
|
|
201
|
+
primaryPage: t == null ? void 0 : t.id,
|
|
202
|
+
edit: !1
|
|
203
|
+
});
|
|
204
|
+
},
|
|
205
|
+
children: a("Add new language page")
|
|
206
|
+
}
|
|
207
|
+
) }) }),
|
|
208
|
+
d && /* @__PURE__ */ e(L, { children: /* @__PURE__ */ e(Ne, { page: d, onClose: () => m(null) }) }),
|
|
209
|
+
u && /* @__PURE__ */ e(L, { children: /* @__PURE__ */ e(ye, { page: u, onClose: () => C(null) }) }),
|
|
210
|
+
p && /* @__PURE__ */ e(L, { children: /* @__PURE__ */ e(fe, { page: p, onClose: () => _(null) }) })
|
|
211
|
+
] });
|
|
212
|
+
};
|
|
213
|
+
export {
|
|
214
|
+
Pe as default
|
|
215
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),a=require("./index-CnSjWE1P.cjs"),W=require("./apply-binding-KKp5PnpZ.cjs"),m=require("@radix-ui/react-icons"),Z=require("jotai"),$=require("nanoid"),o=require("react"),U=require("react-i18next"),N=require("sonner"),Q=require("tailwind-merge"),B=t=>{const n=t.trim();return n.length===0||n.length>25?!1:/^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$/.test(n)},_=(t,n,i,u=!1,l)=>{const x=t.trim();return x.length===0?"":x.length>25?i("Token name must be 25 characters or less"):/^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$/.test(x)?Object.entries(n).find(([c,j])=>j.name===x&&(!u||c!==l))?i("Token name already exists"):"":i("Only alphanumeric characters and hyphens allowed")},H=t=>t.replace(/\s+/g,"-"),K=o.lazy(()=>Promise.resolve().then(()=>require("./delete-design-token-D_TLlO3I.cjs"))),X=o.lazy(()=>Promise.resolve().then(()=>require("./design-token-usage-BqZeR1sT.cjs"))),J=({tokenId:t,token:n,isDisabled:i,onEdit:u,onDelete:l})=>e.jsxs("div",{className:"group relative flex items-center justify-between overflow-hidden rounded border p-2 transition-all duration-150 hover:bg-muted/90",children:[e.jsxs("div",{className:"min-w-0 flex-1 overflow-hidden",children:[e.jsx("div",{className:"text-xs font-semibold",children:n.name}),e.jsx("div",{className:"w-full max-w-52 truncate text-[10px] font-light",children:n.value})]}),e.jsxs("div",{className:"absolute right-1 top-1 flex flex-shrink-0 items-center opacity-0 transition-opacity duration-150 group-hover:opacity-100",children:[e.jsx(o.Suspense,{fallback:null,children:e.jsx(X,{tokenId:t,tokenName:n.name,children:e.jsx(a.Button,{variant:"ghost",size:"sm",className:"h-6 w-6 rounded-full p-0 hover:bg-primary/10 hover:text-primary",children:e.jsx(m.EyeOpenIcon,{className:"h-3 w-3"})})})}),e.jsx(a.Button,{variant:"ghost",size:"sm",onClick:()=>u(t),disabled:i,className:"h-6 w-6 rounded-full p-0 hover:bg-primary/10 hover:text-primary",children:e.jsx(m.Pencil1Icon,{className:"h-3 w-3"})}),e.jsx(o.Suspense,{fallback:null,children:e.jsx(K,{tokenName:n.name,tokenValue:n.value,onDelete:()=>l(t),children:e.jsx(a.Button,{variant:"ghost",size:"sm",disabled:i,className:"h-6 w-6 rounded-full p-0 hover:bg-destructive/10",children:e.jsx(m.TrashIcon,{className:"h-3 w-3 text-destructive"})})})})]})]}),Y=({})=>{const{t}=U.useTranslation(),[n,i]=Z.useAtom(a.chaiDesignTokensAtom),u=a.useIncrementActionsCount(),[l,x]=o.useState("view"),[v,p]=o.useState(null),[c,j]=o.useState(""),[h,k]=o.useState(""),[b,T]=o.useState(""),[y,E]=o.useState(""),[q,w]=o.useState(!1),f=o.useRef(null),A=o.useMemo(()=>Object.entries(n).filter(([,s])=>s.name.toLowerCase().includes(y.toLowerCase())||s.value.toLowerCase().includes(y.toLowerCase())),[n,y]);o.useEffect(()=>()=>{f.current&&clearTimeout(f.current)},[]);const I=o.useCallback((s,r)=>{!v||l!=="edit"||!s.trim()||!r.trim()||!B(s)||Object.entries(n).find(([g,V])=>V.name===s.trim()&&g!==v)||(w(!0),f.current&&clearTimeout(f.current),f.current=setTimeout(()=>{const g={...n,[v]:{name:s.trim(),value:r.trim()}};i(g),u(),w(!1)},250))},[v,l,n,i,u]),z=()=>{if(!c.trim()||!h.trim()){N.toast.error(t("Please fill in both token name and classes"));return}if(!B(c)){N.toast.error(t("Invalid design token name format"));return}if(Object.values(n).find(g=>g.name===c.trim())){N.toast.error(t("Token already exists"));return}const r=`${W.DESIGN_TOKEN_PREFIX}${$.nanoid(12)}`,d={...n,[r]:{name:c.trim(),value:h.trim()}};i(d),u(),N.toast.success(t("Token added successfully")),C()},M=s=>{const r={...n};delete r[s],i(r),u(),N.toast.success(t("Token deleted successfully"))},P=s=>{const r=n[s];r&&(p(s),j(r.name),k(r.value),T(""),x("edit"))},S=()=>{p(null),j(""),k(""),T(""),x("add")},C=()=>{f.current&&clearTimeout(f.current),p(null),j(""),k(""),T(""),w(!1),x("view")},R=s=>{const r=H(s);j(r);const d=_(r,n,t,l==="edit",v||void 0);T(d),l==="edit"&&!d&&I(r,h)},D=s=>{k(s),l==="edit"&&!b&&c.trim()&&I(c,s)},O=s=>{const r=a.orderClassesByBreakpoint(a.removeDuplicateClasses(Q.twMerge(h,s)));D(r)},L=s=>{const r=h.split(" ").filter(d=>d!==s).join(" ");D(r)},F=()=>{const s=l==="edit",r=t(s?"Edit Design Token":"Add Design Token"),d=t(s?"Update design token. Auto-saved.":"Create a reusable design token");return e.jsxs("div",{className:"flex h-full flex-col",children:[e.jsxs("div",{className:"mb-3 flex items-center gap-2 rounded-md border border-border/50 bg-muted p-1.5",children:[e.jsx(a.Button,{variant:"ghost",size:"sm",onClick:C,className:"h-6 w-6 rounded-full p-0 hover:bg-muted",children:e.jsx(m.ArrowLeftIcon,{className:"h-3 w-3"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"text-xs font-semibold text-foreground",children:r}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:d})]}),s&&q&&e.jsx("div",{className:"flex items-center gap-1 text-[10px] text-muted-foreground",children:e.jsx("div",{className:"h-1.5 w-1.5 animate-pulse rounded-full bg-primary"})})]}),e.jsxs("div",{className:"flex-1 space-y-3 overflow-y-auto",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(a.Label,{htmlFor:"token-name",className:"text-xs font-medium",children:t("Token Name")}),e.jsx(a.Input,{id:"token-name",placeholder:"Button-Primary",value:c,onChange:g=>R(g.target.value),className:"h-7 text-xs"}),b?e.jsx("span",{className:"text-[10px] text-destructive",children:b}):e.jsx("span",{className:"text-[10px] font-light text-muted-foreground",children:t("Button-Primary, Card-Header, Text-Large etc.")})]}),e.jsx(a.ManualClasses,{from:"designToken",classFromProps:h,onAddNew:O,onRemove:L}),!s&&e.jsxs("div",{className:"mt-3 flex items-center justify-end gap-2 pt-3",children:[e.jsx(a.Button,{variant:"outline",onClick:C,className:"h-7 text-xs",children:t("Cancel")}),e.jsx(a.Button,{onClick:z,disabled:!c.trim()||!h.trim()||!!b,className:"h-7 text-xs",children:t("Add Token")})]})]})]})},G=()=>e.jsxs(e.Fragment,{children:[Object.entries(n).length>0&&e.jsxs("div",{className:"flex items-center justify-between gap-x-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(m.MagnifyingGlassIcon,{className:"absolute left-2 top-1/2 h-3 w-3 -translate-y-1/2 text-muted-foreground"}),e.jsx(a.Input,{placeholder:t("Search tokens"),value:y,onChange:s=>E(s.target.value),className:"h-6 pl-7 text-xs"})]}),e.jsxs(a.Button,{variant:"outline",onClick:S,size:"sm",className:"h-6 border-primary text-xs text-primary hover:bg-primary/10 hover:text-primary",children:[e.jsx(m.PlusIcon,{className:"h-3 w-3"}),t("Add")]})]}),e.jsx("div",{className:"no-scrollbar flex flex-1 flex-col overflow-hidden pt-2",children:e.jsx(a.ScrollArea,{className:"h-full flex-1",children:e.jsxs("div",{className:"space-y-1",children:[Object.entries(n).length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center rounded-lg border border-dashed border-muted bg-muted/20 py-8",children:[e.jsx("div",{className:"mb-2 text-3xl",children:e.jsx(m.TokensIcon,{className:"h-12 w-12 text-muted-foreground"})}),e.jsx("p",{className:"mb-1 text-sm font-medium text-foreground",children:t("No design tokens yet")}),e.jsx("p",{className:"text-center text-xs text-muted-foreground",children:t("Create reusable design tokens to streamline your styling")}),e.jsxs(a.Button,{variant:"default",onClick:S,size:"sm",className:"mt-4 h-7 text-xs leading-tight",children:[e.jsx(m.PlusIcon,{className:"mr-1 h-3 w-3"}),t("Add first design token")]})]}):A.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center rounded-lg border border-dashed border-muted bg-muted/20 py-8",children:[e.jsx("div",{className:"mb-2",children:e.jsx(m.MagnifyingGlassIcon,{className:"h-10 w-10 text-muted-foreground"})}),e.jsx("p",{className:"mb-1 text-sm font-medium text-foreground",children:t("No tokens found")}),e.jsx("p",{className:"text-center text-xs text-muted-foreground",children:t("No design tokens match your search")})]}):A.map(([s,r])=>e.jsx(J,{token:r,tokenId:s,onEdit:P,onDelete:M,isDisabled:!1},s)),e.jsx("div",{className:"h-44"})]})})})]});return e.jsx("div",{className:"flex h-full w-full flex-col",children:l==="view"?G():F()})};exports.default=Y;
|