@chaibuilder/pages 0.15.5 → 0.15.7
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/{2AITGKQY-D4uLyw6-.cjs → 2AITGKQY-BGvx_OEz.cjs} +1 -1
- package/dist/{2AITGKQY-DYwNjBFe.js → 2AITGKQY-CCad8XK8.js} +2 -2
- package/dist/{NCMVHL6D-C-L7-X3f.cjs → NCMVHL6D-C_u5lHQe.cjs} +1 -1
- package/dist/{NCMVHL6D-DVB60g_2.js → NCMVHL6D-Iv9ufIUy.js} +2 -2
- package/dist/{ZDWCUMSJ-BORULBXb.cjs → ZDWCUMSJ-BqZPKNlU.cjs} +1 -1
- package/dist/{ZDWCUMSJ-Dp6ML_tn.js → ZDWCUMSJ-DT4dg62a.js} +1 -1
- package/dist/add-new-language-page-CfH8Ernl.js +401 -0
- package/dist/add-new-language-page-DlQjzp--.cjs +1 -0
- package/dist/add-new-page-DH-nv7ae.cjs +1 -0
- package/dist/add-new-page-DX1aQA56.js +31 -0
- package/dist/delete-page-DE-nabXs.js +40 -0
- package/dist/delete-page-WPGzECyJ.cjs +1 -0
- package/dist/digital-asset-manager-CGLE6VEW.cjs +1 -0
- package/dist/digital-asset-manager-DtWIJGhf.js +913 -0
- package/dist/duplicate-page-C1r3iBDY.js +133 -0
- package/dist/duplicate-page-CByLwz0z.cjs +1 -0
- package/dist/{dynamic-page-selector-8g1-84iW.js → dynamic-page-selector-Bk8_xgFx.js} +1 -1
- package/dist/{dynamic-page-selector-Cz6zWaKo.cjs → dynamic-page-selector-GwGV0Q6Z.cjs} +1 -1
- package/dist/image-editor-CeSSNbFY.js +108 -0
- package/dist/image-editor-CnDnY97s.cjs +1 -0
- package/dist/index-BELYt0c9.cjs +5 -0
- package/dist/{index-zaGKeGBW.js → index-Djepisz3.js} +1168 -1219
- package/dist/index.cjs +1 -1
- package/dist/index.js +10 -10
- package/dist/{json-diff-viewer-c3ft4c4A.cjs → json-diff-viewer-BUhKwjf9.cjs} +1 -1
- package/dist/{json-diff-viewer-BF0qFBif.js → json-diff-viewer-zKpzQFxw.js} +1 -1
- package/dist/lang-panel-BYF6aLAt.cjs +1 -0
- package/dist/lang-panel-CtpuO-KH.js +225 -0
- package/dist/mark-as-template-0kikl0oL.js +153 -0
- package/dist/mark-as-template-wRAGJGtp.cjs +1 -0
- package/dist/no-language-page-content-B1M_x_U7.js +42 -0
- package/dist/no-language-page-content-DX9WXKXs.cjs +1 -0
- package/dist/{page-creator-Crc5BzeB.js → page-creator-BDJ6iDX9.js} +2 -2
- package/dist/{page-creator-CsZpQ7Gy.cjs → page-creator-DuN5JD41.cjs} +1 -1
- package/dist/page-lock-request-Bc_vwJhy.js +75 -0
- package/dist/page-lock-request-PRQo0DDm.cjs +1 -0
- package/dist/page-locked-by-dialog-DiKNpVwH.js +68 -0
- package/dist/page-locked-by-dialog-Dk0G2l7a.cjs +1 -0
- package/dist/page-manager-new-CUHqC9Og.js +354 -0
- package/dist/page-manager-new-KBhn93Yd.cjs +1 -0
- package/dist/page-manager-search-and-filter-CJ4AK1_7.js +201 -0
- package/dist/page-manager-search-and-filter-Ck5_TfNx.cjs +1 -0
- package/dist/{page-revisions-content-dSFvGFEO.cjs → page-revisions-content-Cw2cumYS.cjs} +1 -1
- package/dist/{page-revisions-content-PRgwV04S.js → page-revisions-content-q1Ch2-IQ.js} +18 -18
- package/dist/{publish-pages-content-akIgltlm.cjs → publish-pages-content-B8Uuw29Q.cjs} +1 -1
- package/dist/{publish-pages-content-C24iBibw.js → publish-pages-content-DEHD8qkl.js} +6 -6
- package/dist/{save-to-lib-C3H1ZPb-.cjs → save-to-lib-B83ZH4XX.cjs} +1 -1
- package/dist/{save-to-lib-DSPvtFSd.js → save-to-lib-QEOpf_Bd.js} +1 -1
- package/dist/{seo-panel-rZ8s88c0.js → seo-panel-DEQfOfZs.js} +17 -17
- package/dist/{seo-panel-Ce6aTIyt.cjs → seo-panel-DvDEatlO.cjs} +1 -1
- package/dist/{shared-json-ld-DMYOwp6B.js → shared-json-ld-Cyv9JitF.js} +26 -25
- package/dist/{shared-json-ld-hCiviuBf.cjs → shared-json-ld-D5F8RuF2.cjs} +1 -1
- package/dist/{slug-input-BN8eQgxP.cjs → slug-input-3vWL9FPC.cjs} +1 -1
- package/dist/{slug-input-Dhzaobv6.js → slug-input-D4e2anEs.js} +1 -1
- package/dist/theme-panel-footer-4dbLfEph.cjs +1 -0
- package/dist/theme-panel-footer-D3Gub87c.js +25 -0
- package/dist/unmark-as-template-BENGNo7g.js +39 -0
- package/dist/unmark-as-template-Dkc7zLZr.cjs +1 -0
- package/dist/unpublish-page-Cui0tgvd.cjs +1 -0
- package/dist/unpublish-page-D5tWKVLY.js +27 -0
- package/dist/{web-preview-BEyjKFDL.js → web-preview-CHNZZcqH.js} +1 -1
- package/dist/{web-preview-TTKtpSUi.cjs → web-preview-CcPTcMio.cjs} +1 -1
- package/package.json +3 -3
- package/dist/add-new-language-page-D4VPifNs.cjs +0 -1
- package/dist/add-new-language-page-DENCjC_f.js +0 -390
- package/dist/add-new-page-BuK6We-q.cjs +0 -1
- package/dist/add-new-page-CD-9ppdS.js +0 -30
- package/dist/delete-page-B-TP6nJ7.cjs +0 -1
- package/dist/delete-page-CatRlDfx.js +0 -38
- package/dist/digital-asset-manager-DL2nAqUC.cjs +0 -1
- package/dist/digital-asset-manager-KakxBkBC.js +0 -917
- package/dist/duplicate-page-D4Oiy71Q.cjs +0 -1
- package/dist/duplicate-page-DEmh0df0.js +0 -120
- package/dist/image-editor-D9MPdtxC.js +0 -107
- package/dist/image-editor-Da6lrqkL.cjs +0 -1
- package/dist/index-Blg1T7nL.cjs +0 -5
- package/dist/lang-panel-D1FKTNui.js +0 -218
- package/dist/lang-panel-ExS97Zgk.cjs +0 -1
- package/dist/mark-as-template-CcnkROAU.cjs +0 -1
- package/dist/mark-as-template-v-I05xcZ.js +0 -146
- package/dist/no-language-page-content-Bm5CcsUo.js +0 -35
- package/dist/no-language-page-content-Ddz2hnYs.cjs +0 -1
- package/dist/page-lock-request-Dx6OrOwM.cjs +0 -1
- package/dist/page-lock-request-WKfG7Sd3.js +0 -64
- package/dist/page-locked-by-dialog-BvdAXZPw.cjs +0 -1
- package/dist/page-locked-by-dialog-jy3lYV3l.js +0 -63
- package/dist/page-manager-new-CNHlSwfe.js +0 -354
- package/dist/page-manager-new-CUlpwqpH.cjs +0 -1
- package/dist/page-manager-search-and-filter-CuAn82Db.js +0 -197
- package/dist/page-manager-search-and-filter-eFsGtm5W.cjs +0 -1
- package/dist/theme-panel-footer-0GrdOHO_.cjs +0 -1
- package/dist/theme-panel-footer-BzEy5bsg.js +0 -25
- package/dist/unmark-as-template-DXEs6foh.cjs +0 -1
- package/dist/unmark-as-template-Dsiyocm9.js +0 -38
- package/dist/unpublish-page-c1mqQEa_.cjs +0 -1
- package/dist/unpublish-page-yGyz2jiw.js +0 -26
|
@@ -1,218 +0,0 @@
|
|
|
1
|
-
import { jsx as e, jsxs as s, Fragment as $ } from "react/jsx-runtime";
|
|
2
|
-
import { ao as M, h as k, L as I, ap as j, g as F, aq as H, e as O, ar as g, as as c, C as x } from "./index-zaGKeGBW.js";
|
|
3
|
-
import { Dialog as W, DialogContent as B, DialogHeader as q, DialogTitle as R, DialogDescription as J, Alert as K, Label as Q, Input as V, DialogFooter as X, Button as A, DropdownMenu as Y, DropdownMenuTrigger as Z, DropdownMenuContent as ee, DropdownMenuItem as b } from "@chaibuilder/sdk/ui";
|
|
4
|
-
import { find as G, startsWith as w, isEqual as se, filter as ae, get as D, map as le, isEmpty as ne } from "lodash-es";
|
|
5
|
-
import { AlertCircle as te, StarIcon as ie, MoreHorizontal as re, PencilIcon as ce, Power as oe, TrashIcon as de } from "lucide-react";
|
|
6
|
-
import { useState as S, lazy as U, useMemo as me, Suspense as L } from "react";
|
|
7
|
-
import { toast as ue } from "sonner";
|
|
8
|
-
import { useLanguages as he } from "@chaibuilder/sdk";
|
|
9
|
-
import { useAtom as ge } from "jotai";
|
|
10
|
-
const pe = ({
|
|
11
|
-
page: a,
|
|
12
|
-
onClose: p
|
|
13
|
-
}) => {
|
|
14
|
-
const [t, v] = S(a.slug || ""), { mutate: N, isPending: f } = M(), { data: n } = k(), i = G(n, { key: a == null ? void 0 : a.pageType }), y = (d) => {
|
|
15
|
-
if (d.preventDefault(), !(a != null && a.primaryPage) && Object.keys(I).some((h) => t === `/${h}` || w(t, `/${h}/`))) {
|
|
16
|
-
ue.error("Error", {
|
|
17
|
-
description: "Slugs cannot start with a language code for primary page"
|
|
18
|
-
});
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
N({ ...a, slug: t }, { onSuccess: p });
|
|
22
|
-
}, o = (a == null ? void 0 : a.lang) || "";
|
|
23
|
-
return /* @__PURE__ */ e(W, { open: !!a, onOpenChange: p, children: /* @__PURE__ */ s(B, { children: [
|
|
24
|
-
/* @__PURE__ */ s(q, { children: [
|
|
25
|
-
/* @__PURE__ */ e(R, { children: "Change Slug" }),
|
|
26
|
-
/* @__PURE__ */ e(J, { className: "text-xs", children: /* @__PURE__ */ s(K, { variant: "destructive", className: "mt-2", children: [
|
|
27
|
-
/* @__PURE__ */ e(te, { className: "h-4 w-4" }),
|
|
28
|
-
"Changing the slug may have impact on your SEO. Please proceed with caution."
|
|
29
|
-
] }) })
|
|
30
|
-
] }),
|
|
31
|
-
/* @__PURE__ */ s("form", { onSubmit: y, children: [
|
|
32
|
-
/* @__PURE__ */ s("div", { className: "space-y-4 py-4 text-sm ", children: [
|
|
33
|
-
/* @__PURE__ */ s("div", { className: "space-y-1", children: [
|
|
34
|
-
/* @__PURE__ */ s("div", { children: [
|
|
35
|
-
/* @__PURE__ */ e("span", { children: "Type:" }),
|
|
36
|
-
/* @__PURE__ */ s("span", { className: "font-medium text-gray-600", children: [
|
|
37
|
-
" ",
|
|
38
|
-
(i == null ? void 0 : i.name) || (a == null ? void 0 : a.pageType)
|
|
39
|
-
] })
|
|
40
|
-
] }),
|
|
41
|
-
/* @__PURE__ */ s("div", { children: [
|
|
42
|
-
/* @__PURE__ */ e("span", { children: "Name:" }),
|
|
43
|
-
/* @__PURE__ */ s("span", { className: "font-medium text-gray-600", children: [
|
|
44
|
-
" ",
|
|
45
|
-
a.name
|
|
46
|
-
] })
|
|
47
|
-
] })
|
|
48
|
-
] }),
|
|
49
|
-
/* @__PURE__ */ s("div", { className: "space-y-1", children: [
|
|
50
|
-
/* @__PURE__ */ s(Q, { htmlFor: "slug", className: "text-right", children: [
|
|
51
|
-
"Slug",
|
|
52
|
-
" ",
|
|
53
|
-
/* @__PURE__ */ s("small", { className: "font-light text-gray-500", children: [
|
|
54
|
-
"Slug should start with /",
|
|
55
|
-
o
|
|
56
|
-
] })
|
|
57
|
-
] }),
|
|
58
|
-
/* @__PURE__ */ e(
|
|
59
|
-
V,
|
|
60
|
-
{
|
|
61
|
-
id: "slug",
|
|
62
|
-
value: t,
|
|
63
|
-
onChange: (d) => {
|
|
64
|
-
const m = d.target.value;
|
|
65
|
-
w(m, `/${o}`) && v(m);
|
|
66
|
-
},
|
|
67
|
-
className: "col-span-3",
|
|
68
|
-
required: !0,
|
|
69
|
-
pattern: "^/.*",
|
|
70
|
-
title: "Slug must start with /",
|
|
71
|
-
placeholder: "Enter page slug"
|
|
72
|
-
}
|
|
73
|
-
)
|
|
74
|
-
] })
|
|
75
|
-
] }),
|
|
76
|
-
/* @__PURE__ */ e(X, { children: /* @__PURE__ */ e(
|
|
77
|
-
A,
|
|
78
|
-
{
|
|
79
|
-
type: "submit",
|
|
80
|
-
disabled: f || !w(t, `/${o}`) || se(a == null ? void 0 : a.slug, t),
|
|
81
|
-
children: f ? "Changing..." : "Change Slug"
|
|
82
|
-
}
|
|
83
|
-
) })
|
|
84
|
-
] })
|
|
85
|
-
] }) });
|
|
86
|
-
}, Ne = U(() => import("./delete-page-CatRlDfx.js")), fe = U(() => import("./unpublish-page-yGyz2jiw.js")), Ae = () => {
|
|
87
|
-
const [, a] = ge(j), { selectedLang: p, fallbackLang: t, setSelectedLang: v } = he(), { data: N, isFetching: f } = F(), { data: n } = H(), { data: i } = k(), y = me(() => {
|
|
88
|
-
const l = i == null ? void 0 : i.find((u) => u.key === (n == null ? void 0 : n.pageType));
|
|
89
|
-
return n != null && n.dynamic ? l == null ? void 0 : l.dynamicSlug : "";
|
|
90
|
-
}, [i, n == null ? void 0 : n.pageType, n == null ? void 0 : n.dynamic]), [o, d] = S(null), [m, C] = S(null), [h, _] = S(null), { data: P } = O(), z = ae(
|
|
91
|
-
D(P, "languages") || ["en"],
|
|
92
|
-
(l) => !G(N, { lang: l }) && l !== D(P, "fallbackLang")
|
|
93
|
-
);
|
|
94
|
-
return /* @__PURE__ */ s("div", { className: "space-y-4", children: [
|
|
95
|
-
/* @__PURE__ */ e("ul", { className: "space-y-2", children: f ? /* @__PURE__ */ s("div", { className: "w-full space-y-3 py-4", children: [
|
|
96
|
-
/* @__PURE__ */ e("div", { className: "h-8 w-full animate-pulse rounded bg-gray-300" }),
|
|
97
|
-
/* @__PURE__ */ e("div", { className: "h-8 w-full animate-pulse rounded bg-gray-300" }),
|
|
98
|
-
/* @__PURE__ */ e("div", { className: "h-8 w-full animate-pulse rounded bg-gray-300" })
|
|
99
|
-
] }) : le(N, (l) => {
|
|
100
|
-
const u = l.lang, E = l.slug, T = !l.primaryPage;
|
|
101
|
-
return /* @__PURE__ */ s($, { children: [
|
|
102
|
-
/* @__PURE__ */ s(
|
|
103
|
-
"li",
|
|
104
|
-
{
|
|
105
|
-
className: `flex w-full cursor-pointer items-center justify-between rounded p-2 text-slate-500 ${u === p ? "bg-gray-200" : "hover:bg-gray-100"}`,
|
|
106
|
-
onClick: () => v(u),
|
|
107
|
-
children: [
|
|
108
|
-
/* @__PURE__ */ s("div", { className: "flex-1 gap-x-3", children: [
|
|
109
|
-
/* @__PURE__ */ s("div", { className: "flex items-center gap-x-2 text-[13px] text-slate-800", children: [
|
|
110
|
-
/* @__PURE__ */ e("div", { className: `h-2.5 w-2.5 rounded-full ${l.online ? "bg-green-300" : "bg-gray-300"}` }),
|
|
111
|
-
D(I, T ? t : u, u)
|
|
112
|
-
] }),
|
|
113
|
-
/* @__PURE__ */ s("div", { children: [
|
|
114
|
-
E && /* @__PURE__ */ s("div", { className: "text-[11px] font-light text-slate-600", children: [
|
|
115
|
-
"Slug: ",
|
|
116
|
-
/* @__PURE__ */ e("b", { className: "font-mono font-medium", children: y ? `${E}/${y}` : E })
|
|
117
|
-
] }),
|
|
118
|
-
/* @__PURE__ */ s("div", { className: "text-[11px] font-light text-slate-600", children: [
|
|
119
|
-
"Name:",
|
|
120
|
-
/* @__PURE__ */ s("b", { className: "font-medium", children: [
|
|
121
|
-
" ",
|
|
122
|
-
l.name,
|
|
123
|
-
" "
|
|
124
|
-
] })
|
|
125
|
-
] })
|
|
126
|
-
] })
|
|
127
|
-
] }),
|
|
128
|
-
T ? /* @__PURE__ */ s("div", { className: "flex items-center gap-x-1 text-[11px] text-orange-500", children: [
|
|
129
|
-
/* @__PURE__ */ e(ie, { fill: "orange", className: "h-3 w-3" }),
|
|
130
|
-
/* @__PURE__ */ e("b", { children: " Primary" })
|
|
131
|
-
] }) : /* @__PURE__ */ e("div", { className: "flex items-center gap-x-3", children: /* @__PURE__ */ e(
|
|
132
|
-
g,
|
|
133
|
-
{
|
|
134
|
-
permissions: [
|
|
135
|
-
c.EDIT_PAGE,
|
|
136
|
-
c.DELETE_PAGE,
|
|
137
|
-
c.UNPUBLISH_PAGE
|
|
138
|
-
],
|
|
139
|
-
children: /* @__PURE__ */ s(Y, { children: [
|
|
140
|
-
/* @__PURE__ */ e(Z, { asChild: !0, onClick: (r) => r.stopPropagation(), children: /* @__PURE__ */ e(A, { variant: "ghost", size: "sm", className: "h-8 w-8 p-0", children: /* @__PURE__ */ e(re, { className: "h-4 w-4" }) }) }),
|
|
141
|
-
/* @__PURE__ */ s(ee, { align: "end", className: "z-[9999] text-sm", children: [
|
|
142
|
-
/* @__PURE__ */ e(g, { permissions: [c.EDIT_PAGE], children: /* @__PURE__ */ s(
|
|
143
|
-
b,
|
|
144
|
-
{
|
|
145
|
-
className: "flex cursor-pointer items-center gap-2",
|
|
146
|
-
onClick: (r) => {
|
|
147
|
-
r.stopPropagation(), a({
|
|
148
|
-
edit: !0,
|
|
149
|
-
id: l.id,
|
|
150
|
-
primaryPage: l.primaryPage
|
|
151
|
-
});
|
|
152
|
-
},
|
|
153
|
-
children: [
|
|
154
|
-
/* @__PURE__ */ e(ce, { className: "size-3" }),
|
|
155
|
-
x.EDIT
|
|
156
|
-
]
|
|
157
|
-
}
|
|
158
|
-
) }),
|
|
159
|
-
/* @__PURE__ */ e(g, { permissions: [c.UNPUBLISH_PAGE], children: (l == null ? void 0 : l.online) && /* @__PURE__ */ s(
|
|
160
|
-
b,
|
|
161
|
-
{
|
|
162
|
-
className: "flex cursor-pointer items-center gap-2",
|
|
163
|
-
onClick: (r) => {
|
|
164
|
-
r.stopPropagation(), C(l);
|
|
165
|
-
},
|
|
166
|
-
children: [
|
|
167
|
-
/* @__PURE__ */ e(oe, { className: "size-3" }),
|
|
168
|
-
x.UNPUBLISH
|
|
169
|
-
]
|
|
170
|
-
}
|
|
171
|
-
) }),
|
|
172
|
-
/* @__PURE__ */ e(g, { permissions: [c.DELETE_PAGE], children: /* @__PURE__ */ s(
|
|
173
|
-
b,
|
|
174
|
-
{
|
|
175
|
-
className: "flex cursor-pointer items-center gap-2",
|
|
176
|
-
onClick: (r) => {
|
|
177
|
-
r.stopPropagation(), d(l);
|
|
178
|
-
},
|
|
179
|
-
children: [
|
|
180
|
-
/* @__PURE__ */ e(de, { className: "size-3" }),
|
|
181
|
-
x.DELETE
|
|
182
|
-
]
|
|
183
|
-
}
|
|
184
|
-
) })
|
|
185
|
-
] })
|
|
186
|
-
] })
|
|
187
|
-
}
|
|
188
|
-
) })
|
|
189
|
-
]
|
|
190
|
-
},
|
|
191
|
-
l.id
|
|
192
|
-
),
|
|
193
|
-
/* @__PURE__ */ e("div", { className: "h-1 w-full border-b" })
|
|
194
|
-
] });
|
|
195
|
-
}) }),
|
|
196
|
-
/* @__PURE__ */ e(g, { permissions: [c.ADD_PAGE], children: /* @__PURE__ */ e("div", { className: "flex w-full justify-center", children: /* @__PURE__ */ e(
|
|
197
|
-
A,
|
|
198
|
-
{
|
|
199
|
-
variant: "default",
|
|
200
|
-
size: "sm",
|
|
201
|
-
disabled: ne(z),
|
|
202
|
-
onClick: () => {
|
|
203
|
-
a({
|
|
204
|
-
primaryPage: n == null ? void 0 : n.id,
|
|
205
|
-
edit: !1
|
|
206
|
-
});
|
|
207
|
-
},
|
|
208
|
-
children: x.ADD_NEW_LANGUAGE
|
|
209
|
-
}
|
|
210
|
-
) }) }),
|
|
211
|
-
o && /* @__PURE__ */ e(L, { children: /* @__PURE__ */ e(Ne, { page: o, onClose: () => d(null) }) }),
|
|
212
|
-
m && /* @__PURE__ */ e(L, { children: /* @__PURE__ */ e(fe, { page: m, onClose: () => C(null) }) }),
|
|
213
|
-
h && /* @__PURE__ */ e(L, { children: /* @__PURE__ */ e(pe, { page: h, onClose: () => _(null) }) })
|
|
214
|
-
] });
|
|
215
|
-
};
|
|
216
|
-
export {
|
|
217
|
-
Ae as default
|
|
218
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("./index-Blg1T7nL.cjs"),i=require("@chaibuilder/sdk/ui"),a=require("lodash-es"),g=require("lucide-react"),r=require("react"),w=require("sonner"),D=require("@chaibuilder/sdk"),T=require("jotai"),L=({page:n,onClose:S})=>{const[c,y]=r.useState(n.slug||""),{mutate:N,isPending:p}=s.useChangeSlug(),{data:l}=s.usePageTypes(),o=a.find(l,{key:n==null?void 0:n.pageType}),E=m=>{if(m.preventDefault(),!(n!=null&&n.primaryPage)&&Object.keys(s.LANGUAGES).some(j=>c===`/${j}`||a.startsWith(c,`/${j}/`))){w.toast.error("Error",{description:"Slugs cannot start with a language code for primary page"});return}N({...n,slug:c},{onSuccess:S})},u=(n==null?void 0:n.lang)||"";return e.jsx(i.Dialog,{open:!!n,onOpenChange:S,children:e.jsxs(i.DialogContent,{children:[e.jsxs(i.DialogHeader,{children:[e.jsx(i.DialogTitle,{children:"Change Slug"}),e.jsx(i.DialogDescription,{className:"text-xs",children:e.jsxs(i.Alert,{variant:"destructive",className:"mt-2",children:[e.jsx(g.AlertCircle,{className:"h-4 w-4"}),"Changing the slug may have impact on your SEO. Please proceed with caution."]})})]}),e.jsxs("form",{onSubmit:E,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.jsx("span",{children:"Type:"}),e.jsxs("span",{className:"font-medium text-gray-600",children:[" ",(o==null?void 0:o.name)||(n==null?void 0:n.pageType)]})]}),e.jsxs("div",{children:[e.jsx("span",{children:"Name:"}),e.jsxs("span",{className:"font-medium text-gray-600",children:[" ",n.name]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs(i.Label,{htmlFor:"slug",className:"text-right",children:["Slug"," ",e.jsxs("small",{className:"font-light text-gray-500",children:["Slug should start with /",u]})]}),e.jsx(i.Input,{id:"slug",value:c,onChange:m=>{const h=m.target.value;a.startsWith(h,`/${u}`)&&y(h)},className:"col-span-3",required:!0,pattern:"^/.*",title:"Slug must start with /",placeholder:"Enter page slug"})]})]}),e.jsx(i.DialogFooter,{children:e.jsx(i.Button,{type:"submit",disabled:p||!a.startsWith(c,`/${u}`)||a.isEqual(n==null?void 0:n.slug,c),children:p?"Changing...":"Change Slug"})})]})]})})},G=r.lazy(()=>Promise.resolve().then(()=>require("./delete-page-B-TP6nJ7.cjs"))),k=r.lazy(()=>Promise.resolve().then(()=>require("./unpublish-page-c1mqQEa_.cjs"))),M=()=>{const[,n]=T.useAtom(s.addNewLangAtom),{selectedLang:S,fallbackLang:c,setSelectedLang:y}=D.useLanguages(),{data:N,isFetching:p}=s.useLanguagePages(),{data:l}=s.useCurrentPage(),{data:o}=s.usePageTypes(),E=r.useMemo(()=>{const t=o==null?void 0:o.find(x=>x.key===(l==null?void 0:l.pageType));return l!=null&&l.dynamic?t==null?void 0:t.dynamicSlug:""},[o,l==null?void 0:l.pageType,l==null?void 0:l.dynamic]),[u,m]=r.useState(null),[h,f]=r.useState(null),[j,b]=r.useState(null),{data:C}=s.useWebsiteSetting(),A=a.filter(a.get(C,"languages")||["en"],t=>!a.find(N,{lang:t})&&t!==a.get(C,"fallbackLang"));return e.jsxs("div",{className:"space-y-4",children:[e.jsx("ul",{className:"space-y-2",children:p?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"})]}):a.map(N,t=>{const x=t.lang,P=t.slug,v=!t.primaryPage,I=x===S;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 ${I?"bg-gray-200":"hover:bg-gray-100"}`,onClick:()=>y(x),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"}`}),a.get(s.LANGUAGES,v?c:x,x)]}),e.jsxs("div",{children:[P&&e.jsxs("div",{className:"text-[11px] font-light text-slate-600",children:["Slug: ",e.jsx("b",{className:"font-mono font-medium",children:E?`${P}/${E}`:P})]}),e.jsxs("div",{className:"text-[11px] font-light text-slate-600",children:["Name:",e.jsxs("b",{className:"font-medium",children:[" ",t.name," "]})]})]})]}),v?e.jsxs("div",{className:"flex items-center gap-x-1 text-[11px] text-orange-500",children:[e.jsx(g.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(s.PermissionChecker,{permissions:[s.PAGES_PERMISSIONS.EDIT_PAGE,s.PAGES_PERMISSIONS.DELETE_PAGE,s.PAGES_PERMISSIONS.UNPUBLISH_PAGE],children:e.jsxs(i.DropdownMenu,{children:[e.jsx(i.DropdownMenuTrigger,{asChild:!0,onClick:d=>d.stopPropagation(),children:e.jsx(i.Button,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",children:e.jsx(g.MoreHorizontal,{className:"h-4 w-4"})})}),e.jsxs(i.DropdownMenuContent,{align:"end",className:"z-[9999] text-sm",children:[e.jsx(s.PermissionChecker,{permissions:[s.PAGES_PERMISSIONS.EDIT_PAGE],children:e.jsxs(i.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:d=>{d.stopPropagation(),n({edit:!0,id:t.id,primaryPage:t.primaryPage})},children:[e.jsx(g.PencilIcon,{className:"size-3"}),s.CONTENT.EDIT]})}),e.jsx(s.PermissionChecker,{permissions:[s.PAGES_PERMISSIONS.UNPUBLISH_PAGE],children:(t==null?void 0:t.online)&&e.jsxs(i.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:d=>{d.stopPropagation(),f(t)},children:[e.jsx(g.Power,{className:"size-3"}),s.CONTENT.UNPUBLISH]})}),e.jsx(s.PermissionChecker,{permissions:[s.PAGES_PERMISSIONS.DELETE_PAGE],children:e.jsxs(i.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:d=>{d.stopPropagation(),m(t)},children:[e.jsx(g.TrashIcon,{className:"size-3"}),s.CONTENT.DELETE]})})]})]})})})]},t.id),e.jsx("div",{className:"h-1 w-full border-b"})]})})}),e.jsx(s.PermissionChecker,{permissions:[s.PAGES_PERMISSIONS.ADD_PAGE],children:e.jsx("div",{className:"flex w-full justify-center",children:e.jsx(i.Button,{variant:"default",size:"sm",disabled:a.isEmpty(A),onClick:()=>{n({primaryPage:l==null?void 0:l.id,edit:!1})},children:s.CONTENT.ADD_NEW_LANGUAGE})})}),u&&e.jsx(r.Suspense,{children:e.jsx(G,{page:u,onClose:()=>m(null)})}),h&&e.jsx(r.Suspense,{children:e.jsx(k,{page:h,onClose:()=>f(null)})}),j&&e.jsx(r.Suspense,{children:e.jsx(L,{page:j,onClose:()=>b(null)})})]})};exports.default=M;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),v=require("./index-Blg1T7nL.cjs"),s=require("@chaibuilder/sdk/ui"),b=require("lodash-es"),o=require("lucide-react"),i=require("react"),y=require("sonner"),S=1*1024*1024,M=({page:n,onClose:d})=>{const[h,m]=i.useState(!1),[g,w]=i.useState(""),[l,f]=i.useState(""),[j,u]=i.useState(!1),r=i.useRef(null),k=v.useMarkAsTemplate(),{data:p}=v.usePageTypes(),x=p==null?void 0:p.find(a=>a.key===n.pageType),C=(x==null?void 0:x.name)||b.startCase(n.pageType),I=i.useCallback(a=>{var N;const c=(N=a.target.files)==null?void 0:N[0];if(c){if(c.size>S){y.toast.error("File too large",{description:`Maximum file size is 1MB. Selected file is ${(c.size/1024).toFixed(2)}KB.`}),r.current&&(r.current.value="");return}try{u(!0);const t=new FileReader;t.onloadend=()=>{f(t.result),u(!1)},t.readAsDataURL(c)}catch(t){console.error("Error reading file:",t),u(!1),y.toast.error("Failed to process image",{description:t instanceof Error?t.message:"Unknown error"})}}},[]),T=()=>{f(""),r.current&&(r.current.value="")},D=()=>{var a;(a=r.current)==null||a.click()},F=()=>{m(!0),k.mutate({page:n,name:n.name,description:g.trim()||void 0,pageType:n.pageType,...l?{previewImage:l}:{}},{onSuccess:()=>{m(!1),d()},onError:()=>{m(!1)}})};return e.jsx(s.Dialog,{open:!0,onOpenChange:d,children:e.jsxs(s.DialogContent,{children:[e.jsxs(s.DialogHeader,{children:[e.jsx(s.DialogTitle,{children:"Mark as template"}),e.jsxs(s.DialogDescription,{className:"space-y-1 py-4 text-xs text-slate-500",children:["Are you sure you want to mark this page as a template?",e.jsx("br",{}),"Templates can be used to create new pages with the same content."]})]}),e.jsxs("div",{className:"mb-4 space-y-4 text-xs",children:[e.jsxs("div",{className:"space-y-3 rounded border bg-slate-50 p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(o.Tag,{className:"h-4 w-4 text-slate-500"}),e.jsx("span",{className:"font-medium text-slate-500",children:"Page Name:"}),e.jsx("span",{className:"font-semibold",children:b.startCase(n.name)})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(o.File,{className:"h-4 w-4 text-slate-500"}),e.jsx("span",{className:"font-medium text-slate-500",children:"Type:"}),e.jsx("span",{className:"font-semibold",children:C})]})]}),e.jsxs("div",{children:[e.jsx(s.Label,{htmlFor:"description",className:"text-xs font-medium",children:"Description (Optional)"}),e.jsx(s.Textarea,{id:"description",placeholder:"Describe this template's purpose",className:"mt-1 h-24 resize-none text-xs",value:g,onChange:a=>w(a.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(s.Label,{htmlFor:"previewImage",className:"text-xs font-medium",children:"Preview Image (Optional)"}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(s.Input,{type:"file",id:"previewImage",ref:r,onChange:I,accept:"image/*",className:"hidden"}),e.jsx(s.Button,{type:"button",variant:"outline",onClick:D,disabled:j,className:"w-full",children:j?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),"Uploading..."]}):e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(o.ImageIcon,{className:"h-4 w-4"}),"Select image"]})}),l&&e.jsx(s.Button,{type:"button",variant:"outline",size:"icon",onClick:T,children:e.jsx(o.X,{className:"h-4 w-4"})})]}),l&&e.jsx("div",{className:"aspect-video overflow-hidden rounded-md border",children:e.jsx("img",{src:l,alt:"Preview",className:"h-full max-h-[200px] w-full object-contain"})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"max 1mb"})]})]})]}),e.jsxs(s.DialogFooter,{className:h?"pointer-events-none opacity-75":"",children:[e.jsx(s.Button,{variant:"outline",onClick:a=>{a.stopPropagation(),d()},children:"Cancel"}),e.jsx(s.Button,{variant:"default",disabled:h,onClick:F,children:"Mark as template"})]})]})})};exports.default=M;
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
import { jsx as e, jsxs as a } from "react/jsx-runtime";
|
|
2
|
-
import { n as A, h as P } from "./index-zaGKeGBW.js";
|
|
3
|
-
import { Dialog as z, DialogContent as E, DialogHeader as L, DialogTitle as S, DialogDescription as U, Label as b, Textarea as B, Input as R, Button as o, DialogFooter as j } from "@chaibuilder/sdk/ui";
|
|
4
|
-
import { startCase as w } from "lodash-es";
|
|
5
|
-
import { Tag as O, File as X, ImageIcon as _, X as H } from "lucide-react";
|
|
6
|
-
import { useState as c, useRef as K, useCallback as Z } from "react";
|
|
7
|
-
import { toast as y } from "sonner";
|
|
8
|
-
const $ = 1 * 1024 * 1024, ee = ({ page: r, onClose: d }) => {
|
|
9
|
-
const [f, m] = c(!1), [g, k] = c(""), [i, x] = c(""), [N, p] = c(!1), n = K(null), I = A(), { data: u } = P(), h = u == null ? void 0 : u.find((t) => t.key === r.pageType), C = (h == null ? void 0 : h.name) || w(r.pageType), T = Z((t) => {
|
|
10
|
-
var v;
|
|
11
|
-
const l = (v = t.target.files) == null ? void 0 : v[0];
|
|
12
|
-
if (l) {
|
|
13
|
-
if (l.size > $) {
|
|
14
|
-
y.error("File too large", {
|
|
15
|
-
description: `Maximum file size is 1MB. Selected file is ${(l.size / 1024).toFixed(2)}KB.`
|
|
16
|
-
}), n.current && (n.current.value = "");
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
try {
|
|
20
|
-
p(!0);
|
|
21
|
-
const s = new FileReader();
|
|
22
|
-
s.onloadend = () => {
|
|
23
|
-
x(s.result), p(!1);
|
|
24
|
-
}, s.readAsDataURL(l);
|
|
25
|
-
} catch (s) {
|
|
26
|
-
console.error("Error reading file:", s), p(!1), y.error("Failed to process image", {
|
|
27
|
-
description: s instanceof Error ? s.message : "Unknown error"
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}, []), D = () => {
|
|
32
|
-
x(""), n.current && (n.current.value = "");
|
|
33
|
-
}, F = () => {
|
|
34
|
-
var t;
|
|
35
|
-
(t = n.current) == null || t.click();
|
|
36
|
-
}, M = () => {
|
|
37
|
-
m(!0), I.mutate(
|
|
38
|
-
{
|
|
39
|
-
page: r,
|
|
40
|
-
name: r.name,
|
|
41
|
-
description: g.trim() || void 0,
|
|
42
|
-
pageType: r.pageType,
|
|
43
|
-
...i ? { previewImage: i } : {}
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
onSuccess: () => {
|
|
47
|
-
m(!1), d();
|
|
48
|
-
},
|
|
49
|
-
onError: () => {
|
|
50
|
-
m(!1);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
);
|
|
54
|
-
};
|
|
55
|
-
return /* @__PURE__ */ e(z, { open: !0, onOpenChange: d, children: /* @__PURE__ */ a(E, { children: [
|
|
56
|
-
/* @__PURE__ */ a(L, { children: [
|
|
57
|
-
/* @__PURE__ */ e(S, { children: "Mark as template" }),
|
|
58
|
-
/* @__PURE__ */ a(U, { className: "space-y-1 py-4 text-xs text-slate-500", children: [
|
|
59
|
-
"Are you sure you want to mark this page as a template?",
|
|
60
|
-
/* @__PURE__ */ e("br", {}),
|
|
61
|
-
"Templates can be used to create new pages with the same content."
|
|
62
|
-
] })
|
|
63
|
-
] }),
|
|
64
|
-
/* @__PURE__ */ a("div", { className: "mb-4 space-y-4 text-xs", children: [
|
|
65
|
-
/* @__PURE__ */ a("div", { className: "space-y-3 rounded border bg-slate-50 p-4", children: [
|
|
66
|
-
/* @__PURE__ */ a("div", { className: "flex items-center gap-2", children: [
|
|
67
|
-
/* @__PURE__ */ e(O, { className: "h-4 w-4 text-slate-500" }),
|
|
68
|
-
/* @__PURE__ */ e("span", { className: "font-medium text-slate-500", children: "Page Name:" }),
|
|
69
|
-
/* @__PURE__ */ e("span", { className: "font-semibold", children: w(r.name) })
|
|
70
|
-
] }),
|
|
71
|
-
/* @__PURE__ */ a("div", { className: "flex items-center gap-2", children: [
|
|
72
|
-
/* @__PURE__ */ e(X, { className: "h-4 w-4 text-slate-500" }),
|
|
73
|
-
/* @__PURE__ */ e("span", { className: "font-medium text-slate-500", children: "Type:" }),
|
|
74
|
-
/* @__PURE__ */ e("span", { className: "font-semibold", children: C })
|
|
75
|
-
] })
|
|
76
|
-
] }),
|
|
77
|
-
/* @__PURE__ */ a("div", { children: [
|
|
78
|
-
/* @__PURE__ */ e(b, { htmlFor: "description", className: "text-xs font-medium", children: "Description (Optional)" }),
|
|
79
|
-
/* @__PURE__ */ e(
|
|
80
|
-
B,
|
|
81
|
-
{
|
|
82
|
-
id: "description",
|
|
83
|
-
placeholder: "Describe this template's purpose",
|
|
84
|
-
className: "mt-1 h-24 resize-none text-xs",
|
|
85
|
-
value: g,
|
|
86
|
-
onChange: (t) => k(t.target.value)
|
|
87
|
-
}
|
|
88
|
-
)
|
|
89
|
-
] }),
|
|
90
|
-
/* @__PURE__ */ a("div", { className: "space-y-2", children: [
|
|
91
|
-
/* @__PURE__ */ e(b, { htmlFor: "previewImage", className: "text-xs font-medium", children: "Preview Image (Optional)" }),
|
|
92
|
-
/* @__PURE__ */ a("div", { className: "space-y-2", children: [
|
|
93
|
-
/* @__PURE__ */ a("div", { className: "flex items-center gap-2", children: [
|
|
94
|
-
/* @__PURE__ */ e(
|
|
95
|
-
R,
|
|
96
|
-
{
|
|
97
|
-
type: "file",
|
|
98
|
-
id: "previewImage",
|
|
99
|
-
ref: n,
|
|
100
|
-
onChange: T,
|
|
101
|
-
accept: "image/*",
|
|
102
|
-
className: "hidden"
|
|
103
|
-
}
|
|
104
|
-
),
|
|
105
|
-
/* @__PURE__ */ e(
|
|
106
|
-
o,
|
|
107
|
-
{
|
|
108
|
-
type: "button",
|
|
109
|
-
variant: "outline",
|
|
110
|
-
onClick: F,
|
|
111
|
-
disabled: N,
|
|
112
|
-
className: "w-full",
|
|
113
|
-
children: N ? /* @__PURE__ */ a("span", { className: "flex items-center gap-2", children: [
|
|
114
|
-
/* @__PURE__ */ e("div", { className: "h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent" }),
|
|
115
|
-
"Uploading..."
|
|
116
|
-
] }) : /* @__PURE__ */ a("span", { className: "flex items-center gap-2", children: [
|
|
117
|
-
/* @__PURE__ */ e(_, { className: "h-4 w-4" }),
|
|
118
|
-
"Select image"
|
|
119
|
-
] })
|
|
120
|
-
}
|
|
121
|
-
),
|
|
122
|
-
i && /* @__PURE__ */ e(o, { type: "button", variant: "outline", size: "icon", onClick: D, children: /* @__PURE__ */ e(H, { className: "h-4 w-4" }) })
|
|
123
|
-
] }),
|
|
124
|
-
i && /* @__PURE__ */ e("div", { className: "aspect-video overflow-hidden rounded-md border", children: /* @__PURE__ */ e("img", { src: i, alt: "Preview", className: "h-full max-h-[200px] w-full object-contain" }) }),
|
|
125
|
-
/* @__PURE__ */ e("p", { className: "text-xs text-muted-foreground", children: "max 1mb" })
|
|
126
|
-
] })
|
|
127
|
-
] })
|
|
128
|
-
] }),
|
|
129
|
-
/* @__PURE__ */ a(j, { className: f ? "pointer-events-none opacity-75" : "", children: [
|
|
130
|
-
/* @__PURE__ */ e(
|
|
131
|
-
o,
|
|
132
|
-
{
|
|
133
|
-
variant: "outline",
|
|
134
|
-
onClick: (t) => {
|
|
135
|
-
t.stopPropagation(), d();
|
|
136
|
-
},
|
|
137
|
-
children: "Cancel"
|
|
138
|
-
}
|
|
139
|
-
),
|
|
140
|
-
/* @__PURE__ */ e(o, { variant: "default", disabled: f, onClick: M, children: "Mark as template" })
|
|
141
|
-
] })
|
|
142
|
-
] }) });
|
|
143
|
-
};
|
|
144
|
-
export {
|
|
145
|
-
ee as default
|
|
146
|
-
};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { jsx as a, jsxs as n } from "react/jsx-runtime";
|
|
2
|
-
import { i as m, j as h, L as u, B as w } from "./index-zaGKeGBW.js";
|
|
3
|
-
import { useLanguages as p } from "@chaibuilder/sdk";
|
|
4
|
-
import { Card as f, CardHeader as P, CardTitle as C, CardContent as S, CardFooter as L, Button as x } from "@chaibuilder/sdk/ui";
|
|
5
|
-
import { get as N } from "lodash-es";
|
|
6
|
-
import { LockIcon as v } from "lucide-react";
|
|
7
|
-
const k = () => {
|
|
8
|
-
const [o, c] = m(), r = o.get("lang"), l = h(r), { setSelectedLang: i } = p(), g = () => {
|
|
9
|
-
const t = new URLSearchParams(window.location.search);
|
|
10
|
-
t.delete("lang");
|
|
11
|
-
const s = t.toString(), d = `${window.location.pathname}${s ? `?${s}` : ""}`;
|
|
12
|
-
window.history.pushState({}, "", d), c(t), i(""), window.dispatchEvent(new PopStateEvent("popstate"));
|
|
13
|
-
};
|
|
14
|
-
if (l) return null;
|
|
15
|
-
const e = N(u, r);
|
|
16
|
-
return /* @__PURE__ */ a(w, { children: /* @__PURE__ */ n(f, { className: "mx-auto w-full max-w-md", children: [
|
|
17
|
-
/* @__PURE__ */ a(P, { className: "space-y-1", children: /* @__PURE__ */ n(C, { className: "flex items-center gap-2 text-2xl", children: [
|
|
18
|
-
/* @__PURE__ */ a(v, { className: "h-6 w-6 text-yellow-500" }),
|
|
19
|
-
'Page missing for "',
|
|
20
|
-
e,
|
|
21
|
-
'" language.'
|
|
22
|
-
] }) }),
|
|
23
|
-
/* @__PURE__ */ a(S, { className: "grid gap-4", children: /* @__PURE__ */ n("div", { children: [
|
|
24
|
-
'Page is not available in the "',
|
|
25
|
-
e,
|
|
26
|
-
'" language. Either create the page in the "',
|
|
27
|
-
e,
|
|
28
|
-
'" language or switch to the base language.'
|
|
29
|
-
] }) }),
|
|
30
|
-
/* @__PURE__ */ a(L, { children: /* @__PURE__ */ a(x, { onClick: g, className: "w-full", variant: "destructive", children: "Switch to default language" }) })
|
|
31
|
-
] }) });
|
|
32
|
-
};
|
|
33
|
-
export {
|
|
34
|
-
k as default
|
|
35
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("./index-Blg1T7nL.cjs"),h=require("@chaibuilder/sdk"),a=require("@chaibuilder/sdk/ui"),m=require("lodash-es"),w=require("lucide-react"),x=()=>{const[o,i]=t.useSearchParams(),r=o.get("lang"),l=t.useIsLanguagePageCreated(r),{setSelectedLang:g}=h.useLanguages(),u=()=>{const s=new URLSearchParams(window.location.search);s.delete("lang");const c=s.toString(),d=`${window.location.pathname}${c?`?${c}`:""}`;window.history.pushState({},"",d),i(s),g(""),window.dispatchEvent(new PopStateEvent("popstate"))};if(l)return null;const n=m.get(t.LANGUAGES,r);return e.jsx(t.BlurContainer,{children:e.jsxs(a.Card,{className:"mx-auto w-full max-w-md",children:[e.jsx(a.CardHeader,{className:"space-y-1",children:e.jsxs(a.CardTitle,{className:"flex items-center gap-2 text-2xl",children:[e.jsx(w.LockIcon,{className:"h-6 w-6 text-yellow-500"}),'Page missing for "',n,'" language.']})}),e.jsx(a.CardContent,{className:"grid gap-4",children:e.jsxs("div",{children:['Page is not available in the "',n,'" language. Either create the page in the "',n,'" language or switch to the base language.']})}),e.jsx(a.CardFooter,{children:e.jsx(a.Button,{onClick:u,className:"w-full",variant:"destructive",children:"Switch to default language"})})]})})};exports.default=x;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),c=require("./index-Blg1T7nL.cjs"),a=require("@chaibuilder/sdk/ui"),t=require("lucide-react"),h=require("react"),g=({userId:l})=>{const{data:n}=c.useChaiUserInfo(l);return(n==null?void 0:n.name)||"Unknown"},C=({isChecking:l,lockingStatus:n,onContinue:x})=>{const[o,u]=h.useState(!1),i=n==="page_is_active_in_other_tab",r=(n==null?void 0:n.length)>0,{pageLock:s,acceptTakeOver:d,rejectTakeOver:j}=c.usePageLockRequestTakeOver(),m=()=>{u(!0),r||i?x():d(),setTimeout(()=>{u(!1)},3e3)};return h.useEffect(()=>{(s==null?void 0:s.requestedBy)==="ANOTHER_TAB"&&d()},[s,d]),(s==null?void 0:s.requestedBy)==="ANOTHER_TAB"?null:l?e.jsx(c.BlurContainer,{children:e.jsx(t.Loader,{className:"h-5 w-5 animate-spin text-primary"})}):e.jsx(c.BlurContainer,{children:e.jsxs(a.Card,{className:"mx-auto w-full max-w-md",children:[e.jsx(a.CardHeader,{className:"space-y-1",children:e.jsxs(a.CardTitle,{className:"flex items-center gap-2 text-xl font-medium",children:[o?e.jsx(t.Loader,{className:"h-6 w-6 animate-spin text-gray-500"}):i?e.jsx(t.TableIcon,{className:"h-6 w-6 text-green-500"}):r?e.jsx(t.CheckCircle,{className:"h-6 w-6 text-green-500"}):e.jsx(t.Target,{className:"h-6 w-6 text-green-500"}),i?"Page is active in other tab":r?"You can edit the page now.":"Page take over request"]})}),e.jsx(a.CardContent,{className:"grid gap-4",children:e.jsx("div",{children:i?e.jsx("p",{children:'You are already editing this page in another tab. To continue editing here, click on "Continue editing here".'}):r?e.jsx("p",{children:"This page is released by other user you can continue editing now."}):e.jsxs("p",{children:[e.jsxs("b",{children:[" ",e.jsx(g,{userId:s==null?void 0:s.requestedBy})]})," ","has requested to take over this page.",e.jsx("br",{})," If you accept, your unsaved changes will be saved."]})})}),e.jsxs(a.CardFooter,{className:"flex items-center justify-end gap-2",children:[e.jsx(a.Button,{disabled:o,onClick:m,className:r?"":"bg-green-500 hover:bg-green-600",children:i?e.jsxs(e.Fragment,{children:[e.jsx(t.Edit,{className:"h-5 w-5"})," Continue editing here"]}):r?e.jsxs(e.Fragment,{children:[e.jsx(t.Edit,{className:"h-5 w-5"})," Continue to edit"]}):e.jsxs(e.Fragment,{children:[e.jsx(t.Check,{className:"h-5 w-5"})," Accept"]})}),!r&&e.jsxs(a.Button,{variant:"outline",onClick:j,children:[e.jsx(t.X,{className:"h-5 w-5"})," Reject"]})]})]})})};exports.default=C;
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { jsx as e, jsxs as a, Fragment as l } from "react/jsx-runtime";
|
|
2
|
-
import { aj as N, ak as w, B as h } from "./index-zaGKeGBW.js";
|
|
3
|
-
import { Card as x, CardHeader as T, CardTitle as b, CardContent as v, CardFooter as y, Button as m } from "@chaibuilder/sdk/ui";
|
|
4
|
-
import { Loader as u, TableIcon as B, CheckCircle as q, Target as _, Edit as f, Check as j, X as A } from "lucide-react";
|
|
5
|
-
import { useState as I, useEffect as O } from "react";
|
|
6
|
-
const k = ({ userId: i }) => {
|
|
7
|
-
const { data: r } = N(i);
|
|
8
|
-
return (r == null ? void 0 : r.name) || "Unknown";
|
|
9
|
-
}, F = ({
|
|
10
|
-
isChecking: i,
|
|
11
|
-
lockingStatus: r,
|
|
12
|
-
onContinue: g
|
|
13
|
-
}) => {
|
|
14
|
-
const [d, o] = I(!1), s = r === "page_is_active_in_other_tab", n = (r == null ? void 0 : r.length) > 0, { pageLock: t, acceptTakeOver: c, rejectTakeOver: p } = w(), C = () => {
|
|
15
|
-
o(!0), n || s ? g() : c(), setTimeout(() => {
|
|
16
|
-
o(!1);
|
|
17
|
-
}, 3e3);
|
|
18
|
-
};
|
|
19
|
-
return O(() => {
|
|
20
|
-
(t == null ? void 0 : t.requestedBy) === "ANOTHER_TAB" && c();
|
|
21
|
-
}, [t, c]), (t == null ? void 0 : t.requestedBy) === "ANOTHER_TAB" ? null : i ? /* @__PURE__ */ e(h, { children: /* @__PURE__ */ e(u, { className: "h-5 w-5 animate-spin text-primary" }) }) : /* @__PURE__ */ e(h, { children: /* @__PURE__ */ a(x, { className: "mx-auto w-full max-w-md", children: [
|
|
22
|
-
/* @__PURE__ */ e(T, { className: "space-y-1", children: /* @__PURE__ */ a(b, { className: "flex items-center gap-2 text-xl font-medium", children: [
|
|
23
|
-
d ? /* @__PURE__ */ e(u, { className: "h-6 w-6 animate-spin text-gray-500" }) : s ? /* @__PURE__ */ e(B, { className: "h-6 w-6 text-green-500" }) : n ? /* @__PURE__ */ e(q, { className: "h-6 w-6 text-green-500" }) : /* @__PURE__ */ e(_, { className: "h-6 w-6 text-green-500" }),
|
|
24
|
-
s ? "Page is active in other tab" : n ? "You can edit the page now." : "Page take over request"
|
|
25
|
-
] }) }),
|
|
26
|
-
/* @__PURE__ */ e(v, { className: "grid gap-4", children: /* @__PURE__ */ e("div", { children: s ? /* @__PURE__ */ e("p", { children: 'You are already editing this page in another tab. To continue editing here, click on "Continue editing here".' }) : n ? /* @__PURE__ */ e("p", { children: "This page is released by other user you can continue editing now." }) : /* @__PURE__ */ a("p", { children: [
|
|
27
|
-
/* @__PURE__ */ a("b", { children: [
|
|
28
|
-
" ",
|
|
29
|
-
/* @__PURE__ */ e(k, { userId: t == null ? void 0 : t.requestedBy })
|
|
30
|
-
] }),
|
|
31
|
-
" ",
|
|
32
|
-
"has requested to take over this page.",
|
|
33
|
-
/* @__PURE__ */ e("br", {}),
|
|
34
|
-
" If you accept, your unsaved changes will be saved."
|
|
35
|
-
] }) }) }),
|
|
36
|
-
/* @__PURE__ */ a(y, { className: "flex items-center justify-end gap-2", children: [
|
|
37
|
-
/* @__PURE__ */ e(
|
|
38
|
-
m,
|
|
39
|
-
{
|
|
40
|
-
disabled: d,
|
|
41
|
-
onClick: C,
|
|
42
|
-
className: n ? "" : "bg-green-500 hover:bg-green-600",
|
|
43
|
-
children: s ? /* @__PURE__ */ a(l, { children: [
|
|
44
|
-
/* @__PURE__ */ e(f, { className: "h-5 w-5" }),
|
|
45
|
-
" Continue editing here"
|
|
46
|
-
] }) : n ? /* @__PURE__ */ a(l, { children: [
|
|
47
|
-
/* @__PURE__ */ e(f, { className: "h-5 w-5" }),
|
|
48
|
-
" Continue to edit"
|
|
49
|
-
] }) : /* @__PURE__ */ a(l, { children: [
|
|
50
|
-
/* @__PURE__ */ e(j, { className: "h-5 w-5" }),
|
|
51
|
-
" Accept"
|
|
52
|
-
] })
|
|
53
|
-
}
|
|
54
|
-
),
|
|
55
|
-
!n && /* @__PURE__ */ a(m, { variant: "outline", onClick: p, children: [
|
|
56
|
-
/* @__PURE__ */ e(A, { className: "h-5 w-5" }),
|
|
57
|
-
" Reject"
|
|
58
|
-
] })
|
|
59
|
-
] })
|
|
60
|
-
] }) });
|
|
61
|
-
};
|
|
62
|
-
export {
|
|
63
|
-
F as default
|
|
64
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("@chaibuilder/sdk/ui"),m=require("date-fns"),r=require("lucide-react"),h=require("react"),j=require("./index-Blg1T7nL.cjs");function p({avatar:d,name:a,email:l,lastSaved:n,onTakeOver:u,isRequestRejected:c,isFetchingUserInfo:t}){const[i,o]=h.useState(!1),x=()=>{o(!0),setTimeout(()=>{o(!1)},15e3),u()};return e.jsx(j.BlurContainer,{children:e.jsxs(s.Card,{className:"mx-auto w-full max-w-md",children:[e.jsx(s.CardHeader,{className:"space-y-1",children:e.jsxs(s.CardTitle,{className:"flex items-center gap-2 text-xl",children:[e.jsx(r.LockKeyhole,{className:"h-8 w-8 rounded-md bg-sky-500/20 p-1.5 text-sky-500"}),"Page is locked for editing"]})}),e.jsx(s.CardContent,{className:"w-md grid w-full pt-2",children:e.jsxs("div",{children:[e.jsxs("div",{className:"relative mx-auto flex w-96 items-center space-x-4 rounded-md border border-green-500 px-2 pb-2 pt-4",children:[e.jsx("div",{className:"absolute -top-2.5 left-3 w-max rounded-full bg-green-500 px-3 py-1 text-xs font-medium leading-3 text-white",children:"Locked By"}),d&&!t?e.jsx("img",{src:d,alt:a,className:"h-14 w-14 rounded-full border border-gray-300"}):e.jsx(r.UserIcon,{className:"h-14 w-14 flex-shrink-0 rounded-full bg-gradient-to-br from-purple-400 to-pink-500 p-2 text-white"}),e.jsxs("div",{className:t?"space-y-1.5":"space-y-0",children:[t?e.jsx(s.Skeleton,{className:"h-4 w-40 rounded"}):e.jsx("span",{className:"truncate font-medium text-black",children:a}),l&&!t?e.jsx("p",{className:"truncate text-sm text-muted-foreground",children:l}):e.jsx(s.Skeleton,{className:"h-4 w-60 rounded"}),n&&!t?e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Last saved:"," ",m.formatDistanceToNow(new Date(n),{addSuffix:!0})]}):e.jsx(s.Skeleton,{className:"h-4 w-40 rounded"})]})]}),e.jsx("div",{className:"mt-4 text-sm",children:e.jsxs("p",{className:"py-4 text-center text-gray-600",children:["This page is currently being edited by ",e.jsx("span",{className:"font-bold",children:a}),".",e.jsx("br",{}),e.jsx("br",{})," You can either wait until they finish editing or request to take over the page."]})}),c&&e.jsxs("div",{className:"mt-4 flex w-full items-center justify-center gap-x-2 rounded border border-red-500 bg-red-50 p-2 text-center font-medium text-red-500",children:[e.jsx(r.Info,{className:"h-5 w-5"})," Page take over request is rejected"]})]})}),e.jsx(s.CardFooter,{children:e.jsxs(s.Button,{disabled:i,onClick:x,className:"w-full",variant:"destructive",children:[e.jsx(r.KeyIcon,{className:"h-5 w-5"}),i?"Page take is requested.":c?"Request take over again":"Request take over"]})})]})})}exports.default=p;
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { jsx as e, jsxs as t } from "react/jsx-runtime";
|
|
2
|
-
import { Card as p, CardHeader as x, CardTitle as f, CardContent as h, Skeleton as d, CardFooter as N, Button as g } from "@chaibuilder/sdk/ui";
|
|
3
|
-
import { formatDistanceToNow as b } from "date-fns";
|
|
4
|
-
import { LockKeyhole as w, UserIcon as k, Info as y, KeyIcon as v } from "lucide-react";
|
|
5
|
-
import { useState as C } from "react";
|
|
6
|
-
import { B } from "./index-zaGKeGBW.js";
|
|
7
|
-
function K({
|
|
8
|
-
avatar: s,
|
|
9
|
-
name: a,
|
|
10
|
-
email: l,
|
|
11
|
-
lastSaved: o,
|
|
12
|
-
onTakeOver: m,
|
|
13
|
-
isRequestRejected: i,
|
|
14
|
-
isFetchingUserInfo: r
|
|
15
|
-
}) {
|
|
16
|
-
const [n, c] = C(!1), u = () => {
|
|
17
|
-
c(!0), setTimeout(() => {
|
|
18
|
-
c(!1);
|
|
19
|
-
}, 15e3), m();
|
|
20
|
-
};
|
|
21
|
-
return /* @__PURE__ */ e(B, { children: /* @__PURE__ */ t(p, { className: "mx-auto w-full max-w-md", children: [
|
|
22
|
-
/* @__PURE__ */ e(x, { className: "space-y-1", children: /* @__PURE__ */ t(f, { className: "flex items-center gap-2 text-xl", children: [
|
|
23
|
-
/* @__PURE__ */ e(w, { className: "h-8 w-8 rounded-md bg-sky-500/20 p-1.5 text-sky-500" }),
|
|
24
|
-
"Page is locked for editing"
|
|
25
|
-
] }) }),
|
|
26
|
-
/* @__PURE__ */ e(h, { className: "w-md grid w-full pt-2", children: /* @__PURE__ */ t("div", { children: [
|
|
27
|
-
/* @__PURE__ */ t("div", { className: "relative mx-auto flex w-96 items-center space-x-4 rounded-md border border-green-500 px-2 pb-2 pt-4", children: [
|
|
28
|
-
/* @__PURE__ */ e("div", { className: "absolute -top-2.5 left-3 w-max rounded-full bg-green-500 px-3 py-1 text-xs font-medium leading-3 text-white", children: "Locked By" }),
|
|
29
|
-
s && !r ? /* @__PURE__ */ e("img", { src: s, alt: a, className: "h-14 w-14 rounded-full border border-gray-300" }) : /* @__PURE__ */ e(k, { className: "h-14 w-14 flex-shrink-0 rounded-full bg-gradient-to-br from-purple-400 to-pink-500 p-2 text-white" }),
|
|
30
|
-
/* @__PURE__ */ t("div", { className: r ? "space-y-1.5" : "space-y-0", children: [
|
|
31
|
-
r ? /* @__PURE__ */ e(d, { className: "h-4 w-40 rounded" }) : /* @__PURE__ */ e("span", { className: "truncate font-medium text-black", children: a }),
|
|
32
|
-
l && !r ? /* @__PURE__ */ e("p", { className: "truncate text-sm text-muted-foreground", children: l }) : /* @__PURE__ */ e(d, { className: "h-4 w-60 rounded" }),
|
|
33
|
-
o && !r ? /* @__PURE__ */ t("p", { className: "text-sm text-muted-foreground", children: [
|
|
34
|
-
"Last saved:",
|
|
35
|
-
" ",
|
|
36
|
-
b(new Date(o), {
|
|
37
|
-
addSuffix: !0
|
|
38
|
-
})
|
|
39
|
-
] }) : /* @__PURE__ */ e(d, { className: "h-4 w-40 rounded" })
|
|
40
|
-
] })
|
|
41
|
-
] }),
|
|
42
|
-
/* @__PURE__ */ e("div", { className: "mt-4 text-sm", children: /* @__PURE__ */ t("p", { className: "py-4 text-center text-gray-600", children: [
|
|
43
|
-
"This page is currently being edited by ",
|
|
44
|
-
/* @__PURE__ */ e("span", { className: "font-bold", children: a }),
|
|
45
|
-
".",
|
|
46
|
-
/* @__PURE__ */ e("br", {}),
|
|
47
|
-
/* @__PURE__ */ e("br", {}),
|
|
48
|
-
" You can either wait until they finish editing or request to take over the page."
|
|
49
|
-
] }) }),
|
|
50
|
-
i && /* @__PURE__ */ t("div", { className: "mt-4 flex w-full items-center justify-center gap-x-2 rounded border border-red-500 bg-red-50 p-2 text-center font-medium text-red-500", children: [
|
|
51
|
-
/* @__PURE__ */ e(y, { className: "h-5 w-5" }),
|
|
52
|
-
" Page take over request is rejected"
|
|
53
|
-
] })
|
|
54
|
-
] }) }),
|
|
55
|
-
/* @__PURE__ */ e(N, { children: /* @__PURE__ */ t(g, { disabled: n, onClick: u, className: "w-full", variant: "destructive", children: [
|
|
56
|
-
/* @__PURE__ */ e(v, { className: "h-5 w-5" }),
|
|
57
|
-
n ? "Page take is requested." : i ? "Request take over again" : "Request take over"
|
|
58
|
-
] }) })
|
|
59
|
-
] }) });
|
|
60
|
-
}
|
|
61
|
-
export {
|
|
62
|
-
K as default
|
|
63
|
-
};
|