@chaibuilder/pages 0.15.5 → 0.15.6

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.
Files changed (96) hide show
  1. package/dist/{2AITGKQY-D4uLyw6-.cjs → 2AITGKQY-BnzAO102.cjs} +1 -1
  2. package/dist/{2AITGKQY-DYwNjBFe.js → 2AITGKQY-tXLat8E2.js} +2 -2
  3. package/dist/{NCMVHL6D-DVB60g_2.js → NCMVHL6D-BwDANa-N.js} +2 -2
  4. package/dist/{NCMVHL6D-C-L7-X3f.cjs → NCMVHL6D-DooF4Fqf.cjs} +1 -1
  5. package/dist/{ZDWCUMSJ-Dp6ML_tn.js → ZDWCUMSJ-DWeYRRkj.js} +1 -1
  6. package/dist/{ZDWCUMSJ-BORULBXb.cjs → ZDWCUMSJ-DiH9kc7o.cjs} +1 -1
  7. package/dist/add-new-language-page-BCUrfgTy.cjs +1 -0
  8. package/dist/add-new-language-page-DZhjVBBf.js +401 -0
  9. package/dist/add-new-page-DWHANcUx.cjs +1 -0
  10. package/dist/add-new-page-DYuuentN.js +31 -0
  11. package/dist/delete-page-1dSWwUBg.js +40 -0
  12. package/dist/delete-page-m-Cuz7rG.cjs +1 -0
  13. package/dist/digital-asset-manager-BWZlrwFf.js +913 -0
  14. package/dist/digital-asset-manager-By_JTIbb.cjs +1 -0
  15. package/dist/duplicate-page-Dzs8ya8l.cjs +1 -0
  16. package/dist/duplicate-page-fUuBTAs7.js +133 -0
  17. package/dist/{dynamic-page-selector-Cz6zWaKo.cjs → dynamic-page-selector-CwhL4z6F.cjs} +1 -1
  18. package/dist/{dynamic-page-selector-8g1-84iW.js → dynamic-page-selector-X2qgdiNQ.js} +1 -1
  19. package/dist/image-editor-CeSSNbFY.js +108 -0
  20. package/dist/image-editor-CnDnY97s.cjs +1 -0
  21. package/dist/index-0cMGDekp.cjs +5 -0
  22. package/dist/{index-zaGKeGBW.js → index-Bk8tPO5R.js} +1168 -1219
  23. package/dist/index.cjs +1 -1
  24. package/dist/index.js +10 -10
  25. package/dist/{json-diff-viewer-c3ft4c4A.cjs → json-diff-viewer-Cfa9BjZ6.cjs} +1 -1
  26. package/dist/{json-diff-viewer-BF0qFBif.js → json-diff-viewer-Cm84g19X.js} +1 -1
  27. package/dist/lang-panel-CaSKOJ8G.js +225 -0
  28. package/dist/lang-panel-CkSfJqr8.cjs +1 -0
  29. package/dist/mark-as-template-Ci82hbOm.cjs +1 -0
  30. package/dist/mark-as-template-CwsW86Zv.js +153 -0
  31. package/dist/no-language-page-content-CPt4aPy9.cjs +1 -0
  32. package/dist/no-language-page-content-DDz81nqg.js +42 -0
  33. package/dist/{page-creator-CsZpQ7Gy.cjs → page-creator-Cd2LrG4u.cjs} +1 -1
  34. package/dist/{page-creator-Crc5BzeB.js → page-creator-Dr566_Yf.js} +2 -2
  35. package/dist/page-lock-request-Bw_Wye1t.cjs +1 -0
  36. package/dist/page-lock-request-ECxkQMdS.js +75 -0
  37. package/dist/page-locked-by-dialog-AbutJT_V.cjs +1 -0
  38. package/dist/page-locked-by-dialog-CnkVUpjt.js +68 -0
  39. package/dist/page-manager-new-DLMvOata.cjs +1 -0
  40. package/dist/page-manager-new-DkqNLZ5C.js +354 -0
  41. package/dist/page-manager-search-and-filter-B98nz9xS.js +201 -0
  42. package/dist/page-manager-search-and-filter-CfEfWFeo.cjs +1 -0
  43. package/dist/{page-revisions-content-PRgwV04S.js → page-revisions-content-CBQPYFZI.js} +18 -18
  44. package/dist/{page-revisions-content-dSFvGFEO.cjs → page-revisions-content-D12GEp8C.cjs} +1 -1
  45. package/dist/{publish-pages-content-C24iBibw.js → publish-pages-content-BF5yMo_L.js} +6 -6
  46. package/dist/{publish-pages-content-akIgltlm.cjs → publish-pages-content-LNCr9tKv.cjs} +1 -1
  47. package/dist/{save-to-lib-C3H1ZPb-.cjs → save-to-lib-C1B6tWEF.cjs} +1 -1
  48. package/dist/{save-to-lib-DSPvtFSd.js → save-to-lib-SpilaoOL.js} +1 -1
  49. package/dist/{seo-panel-Ce6aTIyt.cjs → seo-panel-DkgkJUT6.cjs} +1 -1
  50. package/dist/{seo-panel-rZ8s88c0.js → seo-panel-sbYoo746.js} +17 -17
  51. package/dist/{shared-json-ld-hCiviuBf.cjs → shared-json-ld-CEUgLAev.cjs} +1 -1
  52. package/dist/{shared-json-ld-DMYOwp6B.js → shared-json-ld-D_YyVPk3.js} +27 -27
  53. package/dist/{slug-input-BN8eQgxP.cjs → slug-input-Cqj9EBju.cjs} +1 -1
  54. package/dist/{slug-input-Dhzaobv6.js → slug-input-Df-BG6xl.js} +1 -1
  55. package/dist/theme-panel-footer-B6leVWSV.js +25 -0
  56. package/dist/theme-panel-footer-Ca1UF5DA.cjs +1 -0
  57. package/dist/unmark-as-template-BOE-nKOb.cjs +1 -0
  58. package/dist/unmark-as-template-Cho9B4RN.js +39 -0
  59. package/dist/unpublish-page-BcxxZ8pr.cjs +1 -0
  60. package/dist/unpublish-page-Dr4qbwUx.js +27 -0
  61. package/dist/{web-preview-BEyjKFDL.js → web-preview-Cq82TNaS.js} +1 -1
  62. package/dist/{web-preview-TTKtpSUi.cjs → web-preview-ued-fdxs.cjs} +1 -1
  63. package/package.json +3 -3
  64. package/dist/add-new-language-page-D4VPifNs.cjs +0 -1
  65. package/dist/add-new-language-page-DENCjC_f.js +0 -390
  66. package/dist/add-new-page-BuK6We-q.cjs +0 -1
  67. package/dist/add-new-page-CD-9ppdS.js +0 -30
  68. package/dist/delete-page-B-TP6nJ7.cjs +0 -1
  69. package/dist/delete-page-CatRlDfx.js +0 -38
  70. package/dist/digital-asset-manager-DL2nAqUC.cjs +0 -1
  71. package/dist/digital-asset-manager-KakxBkBC.js +0 -917
  72. package/dist/duplicate-page-D4Oiy71Q.cjs +0 -1
  73. package/dist/duplicate-page-DEmh0df0.js +0 -120
  74. package/dist/image-editor-D9MPdtxC.js +0 -107
  75. package/dist/image-editor-Da6lrqkL.cjs +0 -1
  76. package/dist/index-Blg1T7nL.cjs +0 -5
  77. package/dist/lang-panel-D1FKTNui.js +0 -218
  78. package/dist/lang-panel-ExS97Zgk.cjs +0 -1
  79. package/dist/mark-as-template-CcnkROAU.cjs +0 -1
  80. package/dist/mark-as-template-v-I05xcZ.js +0 -146
  81. package/dist/no-language-page-content-Bm5CcsUo.js +0 -35
  82. package/dist/no-language-page-content-Ddz2hnYs.cjs +0 -1
  83. package/dist/page-lock-request-Dx6OrOwM.cjs +0 -1
  84. package/dist/page-lock-request-WKfG7Sd3.js +0 -64
  85. package/dist/page-locked-by-dialog-BvdAXZPw.cjs +0 -1
  86. package/dist/page-locked-by-dialog-jy3lYV3l.js +0 -63
  87. package/dist/page-manager-new-CNHlSwfe.js +0 -354
  88. package/dist/page-manager-new-CUlpwqpH.cjs +0 -1
  89. package/dist/page-manager-search-and-filter-CuAn82Db.js +0 -197
  90. package/dist/page-manager-search-and-filter-eFsGtm5W.cjs +0 -1
  91. package/dist/theme-panel-footer-0GrdOHO_.cjs +0 -1
  92. package/dist/theme-panel-footer-BzEy5bsg.js +0 -25
  93. package/dist/unmark-as-template-DXEs6foh.cjs +0 -1
  94. package/dist/unmark-as-template-Dsiyocm9.js +0 -38
  95. package/dist/unpublish-page-c1mqQEa_.cjs +0 -1
  96. package/dist/unpublish-page-yGyz2jiw.js +0 -26
@@ -1,354 +0,0 @@
1
- import { jsxs as p, jsx as s, Fragment as D } from "react/jsx-runtime";
2
- import { au as pe, f as oe, aj as be, T as H, aD as ye, L as ge, h as ke, b as Ne, i as we, ap as ve, aE as Se, aF as _ } from "./index-zaGKeGBW.js";
3
- import { u as J } from "./use-page-expand-manager-D6T75I11.js";
4
- import { compact as ie, filter as j, isEmpty as v, uniqBy as Ae, keyBy as ce, mapValues as Le, startCase as Te, toLower as C, includes as O, find as M, get as q, map as Ee } from "lodash-es";
5
- import { useLanguages as re } from "@chaibuilder/sdk";
6
- import { useAtom as Ce } from "jotai";
7
- import { NotepadText as Ue, MoreHorizontal as $e, Lock as Fe, Edit as Me, Plus as je, ChevronRight as ze, StarsIcon as Be, Hash as Ie, File as de } from "lucide-react";
8
- import { useMemo as Q, lazy as U, useState as N, useCallback as ae, useEffect as F, Suspense as E } from "react";
9
- const le = (e, n) => !e || !Array.isArray(e) ? [] : v(n) ? e : ie(
10
- j(e, (r) => {
11
- const t = C(n);
12
- return O(C((r == null ? void 0 : r.name) || ""), t) || O(C((r == null ? void 0 : r.slug) || ""), t);
13
- })
14
- ), Ge = (e, n) => {
15
- const r = /* @__PURE__ */ new Set(), t = ce(e, "id");
16
- return n.forEach((l) => {
17
- let o = l;
18
- for (; o.parent && t[o.parent]; )
19
- r.add(o.parent), o = t[o.parent];
20
- }), Array.from(r).map((l) => t[l]);
21
- }, V = (e, n, r) => v(n) ? e : e.map((t) => {
22
- if (!r(t.pageType))
23
- return {
24
- ...t,
25
- shouldExpandOnSearch: !0,
26
- children: t.children ? V(t.children, n, r) : []
27
- };
28
- const l = t.children && t.children.some(
29
- (o) => O(C(o.name || ""), C(n)) || O(C(o.slug || ""), C(n))
30
- );
31
- return {
32
- ...t,
33
- shouldExpandOnSearch: l,
34
- children: t.children ? V(t.children, n, r) : []
35
- };
36
- }), De = (e) => {
37
- if (!e || !e.length) return [];
38
- const n = {};
39
- e.forEach((t) => {
40
- n[t.id] = { ...t, children: [] };
41
- });
42
- const r = [];
43
- return Object.values(n).forEach((t) => {
44
- t.parent && n[t.parent] ? n[t.parent].children.push(t) : r.push(t);
45
- }), r;
46
- }, ue = (e) => !e || !e.length ? [] : [...e].sort(
47
- (r, t) => (r.name || "").localeCompare(t.name || "")
48
- ).map((r) => ({
49
- ...r,
50
- children: r.children ? ue(r.children) : []
51
- })), Oe = (e, n, r, t) => {
52
- if (!e || !e.length) return [];
53
- let l = e;
54
- if (r !== "all" && (l = ie(j(e, { pageType: r }))), v(n))
55
- l = le(l, n);
56
- else {
57
- const d = le(l, n), i = Ge(e, d);
58
- l = Ae([...d, ...i], "id");
59
- }
60
- const o = ue(De(l)), b = V(o, n, t), f = j(b, (d) => t(d.pageType)).sort((d, i) => (d.name || "").localeCompare(i.name || "")), P = j(b, (d) => !t(d.pageType));
61
- let m = [];
62
- if (r === "all") {
63
- const d = ce(P, "pageType");
64
- m = Object.values(
65
- Le(d, (i, x) => ({
66
- ...i,
67
- id: x,
68
- name: Te(x),
69
- isPartialGroup: !0,
70
- children: b.filter((S) => S.pageType === x)
71
- }))
72
- );
73
- } else
74
- m = P.sort((d, i) => (d.name || "").localeCompare(i.name || ""));
75
- return [...f, ...m];
76
- }, Re = ({ page: e }) => {
77
- var t, l;
78
- const { isExpanded: n, toggleExpanded: r } = J(e == null ? void 0 : e.id);
79
- return /* @__PURE__ */ s(
80
- "button",
81
- {
82
- onClick: (o) => {
83
- o.stopPropagation(), r();
84
- },
85
- disabled: !((t = e == null ? void 0 : e.children) != null && t.length),
86
- className: `flex h-[calc(100%-2px)] w-5 items-center justify-center rounded text-gray-400 transition-colors hover:bg-gray-200 hover:px-1 hover:text-gray-500 ${(l = e == null ? void 0 : e.children) != null && l.length ? "hover:text-blue-400" : "opacity-0"}`,
87
- children: /* @__PURE__ */ s(
88
- ze,
89
- {
90
- size: 12,
91
- className: `stroke-[4] transition-transform duration-200 ${n ? "rotate-90" : ""}`
92
- }
93
- )
94
- }
95
- );
96
- }, We = ({ page: e, pageType: n }) => /* @__PURE__ */ s("div", { className: "flex h-full items-center justify-center gap-x-1", children: e.dynamic ? /* @__PURE__ */ s(Be, { size: 12, className: "text-yellow-400" }) : n != null && n.icon ? /* @__PURE__ */ s(
97
- "div",
98
- {
99
- className: "flex h-4 max-h-4 w-4 max-w-4 items-center justify-center stroke-[1] text-slate-500",
100
- dangerouslySetInnerHTML: { __html: n.icon }
101
- }
102
- ) : n != null && n.hasSlug ? /* @__PURE__ */ s(de, { size: 12, className: "stroke-[1] text-slate-500" }) : /* @__PURE__ */ s(Ie, { size: 12, className: "stroke-[1] text-slate-500" }) }), He = ({ isOnline: e }) => /* @__PURE__ */ s("div", { className: `h-2 w-2 rounded-full ${e ? "bg-green-300" : "bg-gray-300"}` }), _e = ({
103
- page: e,
104
- pageTypes: n,
105
- currentPage: r,
106
- onClickAction: t,
107
- languagePages: l,
108
- selectedLanguage: o,
109
- showUntranslatedPages: b
110
- }) => {
111
- const [f] = pe(), P = oe(), m = r === e.id, d = !!e.isTemplate, i = Q(() => M(n, { key: e.pageType }), [n, e.pageType]), x = f == null ? void 0 : f[e.id], { data: S } = be(x), y = S ? S == null ? void 0 : S.name : null;
112
- let u = q(l, e == null ? void 0 : e.id);
113
- u = q(u, "lang") === o ? u : null;
114
- const A = o === P || !!u, L = (u == null ? void 0 : u.name) || (e == null ? void 0 : e.name) || "No name";
115
- let g = (u == null ? void 0 : u.slug) || (e == null ? void 0 : e.slug) || "";
116
- const z = g + (e != null && e.dynamic ? `/${i == null ? void 0 : i.dynamicSlug}` : "") + (e != null && e.dynamicSlugCustom ? `${e.dynamicSlugCustom}` : "");
117
- if (g.startsWith("/") && !b) {
118
- const c = g.split("/").pop();
119
- g = g.endsWith(c) && e.dynamic ? "" : `/${c}`;
120
- }
121
- const B = Q(() => {
122
- const c = "flex h-7 min-w-0 flex-1 cursor-pointer select-none items-center gap-x-1.5 rounded px-px text-xs duration-300 border-[1px]", T = `${m ? "border-primary/30 bg-primary/5" : "border-transparent hover:border-gray-200 hover:bg-gray-100"}`;
123
- return A ? `${c} ${T} ${y ? "opacity-60" : ""}` : `${c} bg-gray-100 opacity-50 group-hover:border-gray-200 border-transparent group-hover:bg-blue-100`;
124
- }, [A, m, y]);
125
- return /* @__PURE__ */ p("div", { className: "group relative", children: [
126
- /* @__PURE__ */ p(
127
- "div",
128
- {
129
- onClick: () => !e.isPartialGroup && A && t("select", e == null ? void 0 : e.id),
130
- className: B,
131
- children: [
132
- /* @__PURE__ */ s(Re, { page: e }),
133
- !e.isPartialGroup && /* @__PURE__ */ s(He, { isOnline: u ? u.online : e.online }),
134
- !e.isPartialGroup && /* @__PURE__ */ s(We, { page: e, pageType: i }),
135
- /* @__PURE__ */ s(H, { content: L, side: "top", showTooltip: L.length > 35, children: /* @__PURE__ */ s("span", { className: "max-w-[40%] truncate font-medium text-black", children: L }) }),
136
- (g || e.dynamic) && /* @__PURE__ */ s(H, { content: z, side: "top", showTooltip: !0, children: /* @__PURE__ */ p("span", { className: "max-w-[40%] truncate font-mono text-xs text-muted-foreground", children: [
137
- g,
138
- e.dynamic && (i == null ? void 0 : i.dynamicSlug) && /* @__PURE__ */ p("span", { className: "text-xs text-gray-500", children: [
139
- "/",
140
- i == null ? void 0 : i.dynamicSlug,
141
- e.dynamicSlugCustom
142
- ] })
143
- ] }) }),
144
- d && /* @__PURE__ */ s(H, { content: "Template", side: "top", children: /* @__PURE__ */ s("span", { className: "text-blue-500", children: /* @__PURE__ */ s(Ue, { size: 16 }) }) }),
145
- !e.isPartialGroup && A && !y ? /* @__PURE__ */ s("div", { className: "duration absolute right-0.5 top-[3px]", children: /* @__PURE__ */ s(
146
- ye,
147
- {
148
- isLanguagePage: !!u,
149
- page: u || e,
150
- setDuplicatePage: (c) => t("duplicate", c),
151
- setAddEditPage: (c) => t("edit", u || c),
152
- setUnpublishPage: (c) => t("unpublish", c),
153
- setDeletePage: (c) => t("delete", u || c),
154
- setMarkAsTemplate: (c) => t("markAsTemplate", c),
155
- setUnmarkAsTemplate: (c) => t("unmarkAsTemplate", c),
156
- children: /* @__PURE__ */ s("div", { className: "m-0 cursor-pointer rounded border border-transparent p-0.5 duration-100 hover:border-gray-400 hover:bg-white", children: /* @__PURE__ */ s($e, { className: "h-4 w-4", onClick: (c) => c.stopPropagation() }) })
157
- }
158
- ) }) : y ? /* @__PURE__ */ s("span", { className: "duration absolute right-1.5 top-1/2 -translate-y-1/2 text-xs text-gray-500", children: /* @__PURE__ */ s(Fe, { className: "h-3.5 w-3.5 fill-red-200 text-red-500" }) }) : null
159
- ]
160
- }
161
- ),
162
- /* @__PURE__ */ s(D, { children: y && /* @__PURE__ */ p("button", { className: "absolute right-0 top-0 flex h-full items-center gap-x-1 rounded bg-red-50 px-2 py-0.5 text-xs font-light text-red-500 opacity-0 group-hover:opacity-100", children: [
163
- /* @__PURE__ */ s(Me, { size: 12, className: "stroke-[3]" }),
164
- " ",
165
- /* @__PURE__ */ s("span", { className: "font-medium", children: y }),
166
- " is editing this page"
167
- ] }) }),
168
- /* @__PURE__ */ s(D, { children: !A && !e.isPartialGroup && !y && /* @__PURE__ */ p(
169
- "button",
170
- {
171
- onClick: (c) => {
172
- c.stopPropagation(), t("addLanguagePage", { language: o, page: e });
173
- },
174
- className: "absolute left-1/2 top-1 flex -translate-x-1/2 items-center gap-x-1 rounded bg-blue-500 px-2 py-0.5 text-xs text-white opacity-0 duration-200 hover:bg-blue-700 group-hover:opacity-100",
175
- children: [
176
- /* @__PURE__ */ s(je, { size: 12, className: "stroke-[3]" }),
177
- " ",
178
- /* @__PURE__ */ p("span", { className: "text-[10px]", children: [
179
- "Add ",
180
- q(ge, o),
181
- " Page"
182
- ] })
183
- ]
184
- }
185
- ) })
186
- ] });
187
- }, me = ({
188
- pages: e,
189
- tier: n,
190
- pageTypes: r,
191
- currentPage: t,
192
- onClickAction: l,
193
- languagePages: o,
194
- selectedLanguage: b,
195
- showUntranslatedPages: f
196
- }) => {
197
- const { expandedPages: P } = J();
198
- return /* @__PURE__ */ s("div", { className: "space-y-0.5", style: { paddingLeft: `${n * 10}px` }, children: e.map((m) => /* @__PURE__ */ p(D, { children: [
199
- /* @__PURE__ */ s(
200
- _e,
201
- {
202
- page: m,
203
- pageTypes: r,
204
- currentPage: t,
205
- onClickAction: l,
206
- languagePages: o,
207
- selectedLanguage: b,
208
- showUntranslatedPages: f
209
- }
210
- ),
211
- m.children && m.children.length > 0 && (P == null ? void 0 : P.includes(m.id)) && /* @__PURE__ */ s(
212
- me,
213
- {
214
- pages: m.children,
215
- tier: n + 1,
216
- pageTypes: r,
217
- currentPage: t,
218
- onClickAction: l,
219
- languagePages: o,
220
- selectedLanguage: b,
221
- showUntranslatedPages: f
222
- }
223
- )
224
- ] }, m.id)) });
225
- }, qe = U(() => import("./page-manager-search-and-filter-CuAn82Db.js")), Qe = U(() => import("./add-new-page-CD-9ppdS.js")), Ve = U(() => import("./delete-page-CatRlDfx.js")), Je = U(() => import("./duplicate-page-DEmh0df0.js")), Ke = U(() => import("./mark-as-template-v-I05xcZ.js")), Xe = U(() => import("./unmark-as-template-Dsiyocm9.js")), Ye = U(() => import("./unpublish-page-yGyz2jiw.js")), ot = ({ close: e }) => {
226
- const { languages: n, setSelectedLang: r } = re(), { data: t } = ke(), { data: l, isFetching: o } = Ne(), [b, f] = we(), { updateForSelectedPage: P, expandPagesOnSearch: m } = J(null), d = oe(), i = b.get("page"), [x, S] = N(""), [y, u] = N(null), [A, L] = N(null), [g, z] = N(null), [B, c] = N(null), [T, R] = N(""), [K, X] = N(null), [Y, Z] = N(null), [k, he] = N(d), [fe, Pe] = N(!1), [, ee] = Ce(ve), I = fe && k !== d, { data: $, isFetching: xe } = Se(k), te = ae(
227
- (h) => {
228
- var a;
229
- return (a = M(t, { key: h })) == null ? void 0 : a.hasSlug;
230
- },
231
- [t]
232
- ), w = Q(() => l ? I ? j(l, (h) => !($ != null && $[h.id])) : Oe(l, x, T, te) : [], [l, te, x, T, $, I]);
233
- F(() => {
234
- r(d);
235
- }, [d, r]), F(() => {
236
- if (!v(T)) return;
237
- const h = sessionStorage.getItem("pageTypeFilter") || "all";
238
- !v(t) && h && (M(t, { key: h }) ? R(h) : R("all"));
239
- }, [t, T]), F(() => {
240
- if (i && !o && !M(l, { id: i })) {
241
- const a = M(l, { slug: "/" });
242
- if (a) {
243
- const G = new URLSearchParams({ page: a.id });
244
- _(G, f);
245
- } else
246
- _(new URLSearchParams({}), f, !0);
247
- }
248
- }, [l, i, o, f]), F(() => {
249
- i && !o && !v(w) && P(w, i);
250
- }, [i, o, w, P]), F(() => {
251
- !v(x) && !v(w) && m(w);
252
- }, [x, w, m]);
253
- const { setSelectedLang: W } = re(), se = ae(
254
- (h) => {
255
- const a = new URLSearchParams({ page: h });
256
- k !== d ? (a.set("lang", k), W(k)) : W(""), _(a, f), e();
257
- },
258
- [e, f, W, k, d]
259
- ), ne = (h, a) => {
260
- var G;
261
- if (a)
262
- switch (h) {
263
- case "add":
264
- L(a);
265
- break;
266
- case "select":
267
- se(a);
268
- break;
269
- case "edit":
270
- k !== d ? ee({
271
- edit: !0,
272
- id: a == null ? void 0 : a.id,
273
- primaryPage: a == null ? void 0 : a.primaryPage
274
- }) : L(a);
275
- break;
276
- case "delete":
277
- u(a);
278
- break;
279
- case "unpublish":
280
- z(a);
281
- break;
282
- case "markAsTemplate":
283
- c(a);
284
- break;
285
- case "unmarkAsTemplate":
286
- Z(a);
287
- break;
288
- case "duplicate":
289
- X(a);
290
- break;
291
- case "addLanguagePage":
292
- ee({
293
- edit: !1,
294
- primaryPage: ((G = a == null ? void 0 : a.page) == null ? void 0 : G.id) || "",
295
- preselectedLang: (a == null ? void 0 : a.language) || k
296
- });
297
- break;
298
- }
299
- };
300
- return /* @__PURE__ */ p(D, { children: [
301
- /* @__PURE__ */ p("div", { className: "flex h-full flex-col justify-between", children: [
302
- /* @__PURE__ */ s(E, { children: /* @__PURE__ */ s(
303
- qe,
304
- {
305
- pages: w,
306
- search: x,
307
- setSearch: S,
308
- languages: [d, ...n],
309
- selectedLanguage: k,
310
- setSelectedLanguage: he,
311
- selectedPageType: T,
312
- setSelectedPageType: R,
313
- onAddPage: (h) => ne("add", h),
314
- showUntranslatedPages: I,
315
- setShowUntranslatedPages: Pe
316
- }
317
- ) }),
318
- /* @__PURE__ */ s("div", { className: "flex-1 overflow-y-auto px-4 pb-6 pt-2", children: o || xe ? /* @__PURE__ */ s("div", { className: "space-y-2", children: Ee([...Array(15).keys()], (h) => /* @__PURE__ */ s("div", { className: "h-7 w-full animate-pulse rounded border border-gray-300 bg-gray-200" }, h)) }) : v(w) ? /* @__PURE__ */ p("div", { className: "flex h-[70vh] flex-col items-center justify-center gap-y-1 text-sm font-medium text-slate-500", children: [
319
- /* @__PURE__ */ s(de, { className: "h-6 w-6 stroke-[1]" }),
320
- "Empty List!",
321
- /* @__PURE__ */ s("span", { className: "font-light", children: "Add new page to start" })
322
- ] }) : /* @__PURE__ */ s(
323
- me,
324
- {
325
- tier: 0,
326
- pages: w,
327
- pageTypes: t,
328
- currentPage: i || "",
329
- onClickAction: ne,
330
- languagePages: $,
331
- selectedLanguage: k,
332
- showUntranslatedPages: I
333
- }
334
- ) })
335
- ] }),
336
- A && /* @__PURE__ */ s(E, { children: /* @__PURE__ */ s(
337
- Qe,
338
- {
339
- closePanel: e,
340
- editPage: se,
341
- addEditPage: A,
342
- setAddEditPage: L
343
- }
344
- ) }),
345
- y && /* @__PURE__ */ s(E, { children: /* @__PURE__ */ s(Ve, { page: y, onClose: () => u(null) }) }),
346
- g && /* @__PURE__ */ s(E, { children: /* @__PURE__ */ s(Ye, { page: g, onClose: () => z(null) }) }),
347
- B && /* @__PURE__ */ s(E, { children: /* @__PURE__ */ s(Ke, { page: B, onClose: () => c(null) }) }),
348
- Y && /* @__PURE__ */ s(E, { children: /* @__PURE__ */ s(Xe, { page: Y, onClose: () => Z(null) }) }),
349
- K && /* @__PURE__ */ s(E, { children: /* @__PURE__ */ s(Je, { page: K, onClose: () => X(null), closePanel: e }) })
350
- ] });
351
- };
352
- export {
353
- ot as default
354
- };
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),x=require("./index-Blg1T7nL.cjs"),B=require("./use-page-expand-manager-2KjeYfVS.cjs"),n=require("lodash-es"),Q=require("@chaibuilder/sdk"),se=require("jotai"),v=require("lucide-react"),l=require("react"),V=(e,r)=>!e||!Array.isArray(e)?[]:n.isEmpty(r)?e:n.compact(n.filter(e,a=>{const t=n.toLower(r);return n.includes(n.toLower((a==null?void 0:a.name)||""),t)||n.includes(n.toLower((a==null?void 0:a.slug)||""),t)})),te=(e,r)=>{const a=new Set,t=n.keyBy(e,"id");return r.forEach(o=>{let c=o;for(;c.parent&&t[c.parent];)a.add(c.parent),c=t[c.parent]}),Array.from(a).map(o=>t[o])},$=(e,r,a)=>n.isEmpty(r)?e:e.map(t=>{if(!a(t.pageType))return{...t,shouldExpandOnSearch:!0,children:t.children?$(t.children,r,a):[]};const o=t.children&&t.children.some(c=>n.includes(n.toLower(c.name||""),n.toLower(r))||n.includes(n.toLower(c.slug||""),n.toLower(r)));return{...t,shouldExpandOnSearch:o,children:t.children?$(t.children,r,a):[]}}),ne=e=>{if(!e||!e.length)return[];const r={};e.forEach(t=>{r[t.id]={...t,children:[]}});const a=[];return Object.values(r).forEach(t=>{t.parent&&r[t.parent]?r[t.parent].children.push(t):a.push(t)}),a},J=e=>!e||!e.length?[]:[...e].sort((a,t)=>(a.name||"").localeCompare(t.name||"")).map(a=>({...a,children:a.children?J(a.children):[]})),re=(e,r,a,t)=>{if(!e||!e.length)return[];let o=e;if(a!=="all"&&(o=n.compact(n.filter(e,{pageType:a}))),n.isEmpty(r))o=V(o,r);else{const m=V(o,r),d=te(e,m);o=n.uniqBy([...m,...d],"id")}const c=J(ne(o)),b=$(c,r,t),y=n.filter(b,m=>t(m.pageType)).sort((m,d)=>(m.name||"").localeCompare(d.name||"")),p=n.filter(b,m=>!t(m.pageType));let f=[];if(a==="all"){const m=n.keyBy(p,"pageType");f=Object.values(n.mapValues(m,(d,j)=>({...d,id:j,name:n.startCase(j),isPartialGroup:!0,children:b.filter(N=>N.pageType===j)})))}else f=p.sort((m,d)=>(m.name||"").localeCompare(d.name||""));return[...y,...f]},ae=({page:e})=>{var t,o;const{isExpanded:r,toggleExpanded:a}=B.usePageExpandManager(e==null?void 0:e.id);return s.jsx("button",{onClick:c=>{c.stopPropagation(),a()},disabled:!((t=e==null?void 0:e.children)!=null&&t.length),className:`flex h-[calc(100%-2px)] w-5 items-center justify-center rounded text-gray-400 transition-colors hover:bg-gray-200 hover:px-1 hover:text-gray-500 ${(o=e==null?void 0:e.children)!=null&&o.length?"hover:text-blue-400":"opacity-0"}`,children:s.jsx(v.ChevronRight,{size:12,className:`stroke-[4] transition-transform duration-200 ${r?"rotate-90":""}`})})},le=({page:e,pageType:r})=>s.jsx("div",{className:"flex h-full items-center justify-center gap-x-1",children:e.dynamic?s.jsx(v.StarsIcon,{size:12,className:"text-yellow-400"}):r!=null&&r.icon?s.jsx("div",{className:"flex h-4 max-h-4 w-4 max-w-4 items-center justify-center stroke-[1] text-slate-500",dangerouslySetInnerHTML:{__html:r.icon}}):r!=null&&r.hasSlug?s.jsx(v.File,{size:12,className:"stroke-[1] text-slate-500"}):s.jsx(v.Hash,{size:12,className:"stroke-[1] text-slate-500"})}),ie=({isOnline:e})=>s.jsx("div",{className:`h-2 w-2 rounded-full ${e?"bg-green-300":"bg-gray-300"}`}),oe=({page:e,pageTypes:r,currentPage:a,onClickAction:t,languagePages:o,selectedLanguage:c,showUntranslatedPages:b})=>{const[y]=x.usePageUserMapping(),p=x.useFallbackLang(),f=a===e.id,m=!!e.isTemplate,d=l.useMemo(()=>n.find(r,{key:e.pageType}),[r,e.pageType]),j=y==null?void 0:y[e.id],{data:N}=x.useChaiUserInfo(j),g=N?N==null?void 0:N.name:null;let h=n.get(o,e==null?void 0:e.id);h=n.get(h,"lang")===c?h:null;const E=c===p||!!h,L=(h==null?void 0:h.name)||(e==null?void 0:e.name)||"No name";let S=(h==null?void 0:h.slug)||(e==null?void 0:e.slug)||"";const C=S+(e!=null&&e.dynamic?`/${d==null?void 0:d.dynamicSlug}`:"")+(e!=null&&e.dynamicSlugCustom?`${e.dynamicSlugCustom}`:"");if(S.startsWith("/")&&!b){const u=S.split("/").pop();S=S.endsWith(u)&&e.dynamic?"":`/${u}`}const q=l.useMemo(()=>{const u="flex h-7 min-w-0 flex-1 cursor-pointer select-none items-center gap-x-1.5 rounded px-px text-xs duration-300 border-[1px]",T=`${f?"border-primary/30 bg-primary/5":"border-transparent hover:border-gray-200 hover:bg-gray-100"}`;return E?`${u} ${T} ${g?"opacity-60":""}`:`${u} bg-gray-100 opacity-50 group-hover:border-gray-200 border-transparent group-hover:bg-blue-100`},[E,f,g]);return s.jsxs("div",{className:"group relative",children:[s.jsxs("div",{onClick:()=>!e.isPartialGroup&&E&&t("select",e==null?void 0:e.id),className:q,children:[s.jsx(ae,{page:e}),!e.isPartialGroup&&s.jsx(ie,{isOnline:h?h.online:e.online}),!e.isPartialGroup&&s.jsx(le,{page:e,pageType:d}),s.jsx(x.Tooltip,{content:L,side:"top",showTooltip:L.length>35,children:s.jsx("span",{className:"max-w-[40%] truncate font-medium text-black",children:L})}),(S||e.dynamic)&&s.jsx(x.Tooltip,{content:C,side:"top",showTooltip:!0,children:s.jsxs("span",{className:"max-w-[40%] truncate font-mono text-xs text-muted-foreground",children:[S,e.dynamic&&(d==null?void 0:d.dynamicSlug)&&s.jsxs("span",{className:"text-xs text-gray-500",children:["/",d==null?void 0:d.dynamicSlug,e.dynamicSlugCustom]})]})}),m&&s.jsx(x.Tooltip,{content:"Template",side:"top",children:s.jsx("span",{className:"text-blue-500",children:s.jsx(v.NotepadText,{size:16})})}),!e.isPartialGroup&&E&&!g?s.jsx("div",{className:"duration absolute right-0.5 top-[3px]",children:s.jsx(x.PageActionsDropdown,{isLanguagePage:!!h,page:h||e,setDuplicatePage:u=>t("duplicate",u),setAddEditPage:u=>t("edit",h||u),setUnpublishPage:u=>t("unpublish",u),setDeletePage:u=>t("delete",h||u),setMarkAsTemplate:u=>t("markAsTemplate",u),setUnmarkAsTemplate:u=>t("unmarkAsTemplate",u),children:s.jsx("div",{className:"m-0 cursor-pointer rounded border border-transparent p-0.5 duration-100 hover:border-gray-400 hover:bg-white",children:s.jsx(v.MoreHorizontal,{className:"h-4 w-4",onClick:u=>u.stopPropagation()})})})}):g?s.jsx("span",{className:"duration absolute right-1.5 top-1/2 -translate-y-1/2 text-xs text-gray-500",children:s.jsx(v.Lock,{className:"h-3.5 w-3.5 fill-red-200 text-red-500"})}):null]}),s.jsx(s.Fragment,{children:g&&s.jsxs("button",{className:"absolute right-0 top-0 flex h-full items-center gap-x-1 rounded bg-red-50 px-2 py-0.5 text-xs font-light text-red-500 opacity-0 group-hover:opacity-100",children:[s.jsx(v.Edit,{size:12,className:"stroke-[3]"})," ",s.jsx("span",{className:"font-medium",children:g})," is editing this page"]})}),s.jsx(s.Fragment,{children:!E&&!e.isPartialGroup&&!g&&s.jsxs("button",{onClick:u=>{u.stopPropagation(),t("addLanguagePage",{language:c,page:e})},className:"absolute left-1/2 top-1 flex -translate-x-1/2 items-center gap-x-1 rounded bg-blue-500 px-2 py-0.5 text-xs text-white opacity-0 duration-200 hover:bg-blue-700 group-hover:opacity-100",children:[s.jsx(v.Plus,{size:12,className:"stroke-[3]"})," ",s.jsxs("span",{className:"text-[10px]",children:["Add ",n.get(x.LANGUAGES,c)," Page"]})]})})]})},K=({pages:e,tier:r,pageTypes:a,currentPage:t,onClickAction:o,languagePages:c,selectedLanguage:b,showUntranslatedPages:y})=>{const{expandedPages:p}=B.usePageExpandManager();return s.jsx("div",{className:"space-y-0.5",style:{paddingLeft:`${r*10}px`},children:e.map(f=>s.jsxs(s.Fragment,{children:[s.jsx(oe,{page:f,pageTypes:a,currentPage:t,onClickAction:o,languagePages:c,selectedLanguage:b,showUntranslatedPages:y}),f.children&&f.children.length>0&&(p==null?void 0:p.includes(f.id))&&s.jsx(K,{pages:f.children,tier:r+1,pageTypes:a,currentPage:t,onClickAction:o,languagePages:c,selectedLanguage:b,showUntranslatedPages:y})]},f.id))})},ce=l.lazy(()=>Promise.resolve().then(()=>require("./page-manager-search-and-filter-eFsGtm5W.cjs"))),de=l.lazy(()=>Promise.resolve().then(()=>require("./add-new-page-BuK6We-q.cjs"))),ue=l.lazy(()=>Promise.resolve().then(()=>require("./delete-page-B-TP6nJ7.cjs"))),me=l.lazy(()=>Promise.resolve().then(()=>require("./duplicate-page-D4Oiy71Q.cjs"))),he=l.lazy(()=>Promise.resolve().then(()=>require("./mark-as-template-CcnkROAU.cjs"))),xe=l.lazy(()=>Promise.resolve().then(()=>require("./unmark-as-template-DXEs6foh.cjs"))),fe=l.lazy(()=>Promise.resolve().then(()=>require("./unpublish-page-c1mqQEa_.cjs"))),Pe=({close:e})=>{const{languages:r,setSelectedLang:a}=Q.useLanguages(),{data:t}=x.usePageTypes(),{data:o,isFetching:c}=x.useWebsitePages(),[b,y]=x.useSearchParams(),{updateForSelectedPage:p,expandPagesOnSearch:f}=B.usePageExpandManager(null),m=x.useFallbackLang(),d=b.get("page"),[j,N]=l.useState(""),[g,h]=l.useState(null),[E,L]=l.useState(null),[S,C]=l.useState(null),[q,u]=l.useState(null),[T,F]=l.useState(""),[I,G]=l.useState(null),[O,R]=l.useState(null),[k,X]=l.useState(m),[Y,Z]=l.useState(!1),[,D]=se.useAtom(x.addNewLangAtom),M=Y&&k!==m,{data:A,isFetching:ee}=x.useWebsiteLanguagePages(k),W=l.useCallback(P=>{var i;return(i=n.find(t,{key:P}))==null?void 0:i.hasSlug},[t]),w=l.useMemo(()=>o?M?n.filter(o,P=>!(A!=null&&A[P.id])):re(o,j,T,W):[],[o,W,j,T,A,M]);l.useEffect(()=>{a(m)},[m,a]),l.useEffect(()=>{if(!n.isEmpty(T))return;const P=sessionStorage.getItem("pageTypeFilter")||"all";!n.isEmpty(t)&&P&&(n.find(t,{key:P})?F(P):F("all"))},[t,T]),l.useEffect(()=>{if(d&&!c&&!n.find(o,{id:d})){const i=n.find(o,{slug:"/"});if(i){const z=new URLSearchParams({page:i.id});x.navigateToPage(z,y)}else x.navigateToPage(new URLSearchParams({}),y,!0)}},[o,d,c,y]),l.useEffect(()=>{d&&!c&&!n.isEmpty(w)&&p(w,d)},[d,c,w,p]),l.useEffect(()=>{!n.isEmpty(j)&&!n.isEmpty(w)&&f(w)},[j,w,f]);const{setSelectedLang:U}=Q.useLanguages(),H=l.useCallback(P=>{const i=new URLSearchParams({page:P});k!==m?(i.set("lang",k),U(k)):U(""),x.navigateToPage(i,y),e()},[e,y,U,k,m]),_=(P,i)=>{var z;if(i)switch(P){case"add":L(i);break;case"select":H(i);break;case"edit":k!==m?D({edit:!0,id:i==null?void 0:i.id,primaryPage:i==null?void 0:i.primaryPage}):L(i);break;case"delete":h(i);break;case"unpublish":C(i);break;case"markAsTemplate":u(i);break;case"unmarkAsTemplate":R(i);break;case"duplicate":G(i);break;case"addLanguagePage":D({edit:!1,primaryPage:((z=i==null?void 0:i.page)==null?void 0:z.id)||"",preselectedLang:(i==null?void 0:i.language)||k});break}};return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex h-full flex-col justify-between",children:[s.jsx(l.Suspense,{children:s.jsx(ce,{pages:w,search:j,setSearch:N,languages:[m,...r],selectedLanguage:k,setSelectedLanguage:X,selectedPageType:T,setSelectedPageType:F,onAddPage:P=>_("add",P),showUntranslatedPages:M,setShowUntranslatedPages:Z})}),s.jsx("div",{className:"flex-1 overflow-y-auto px-4 pb-6 pt-2",children:c||ee?s.jsx("div",{className:"space-y-2",children:n.map([...Array(15).keys()],P=>s.jsx("div",{className:"h-7 w-full animate-pulse rounded border border-gray-300 bg-gray-200"},P))}):n.isEmpty(w)?s.jsxs("div",{className:"flex h-[70vh] flex-col items-center justify-center gap-y-1 text-sm font-medium text-slate-500",children:[s.jsx(v.File,{className:"h-6 w-6 stroke-[1]"}),"Empty List!",s.jsx("span",{className:"font-light",children:"Add new page to start"})]}):s.jsx(K,{tier:0,pages:w,pageTypes:t,currentPage:d||"",onClickAction:_,languagePages:A,selectedLanguage:k,showUntranslatedPages:M})})]}),E&&s.jsx(l.Suspense,{children:s.jsx(de,{closePanel:e,editPage:H,addEditPage:E,setAddEditPage:L})}),g&&s.jsx(l.Suspense,{children:s.jsx(ue,{page:g,onClose:()=>h(null)})}),S&&s.jsx(l.Suspense,{children:s.jsx(fe,{page:S,onClose:()=>C(null)})}),q&&s.jsx(l.Suspense,{children:s.jsx(he,{page:q,onClose:()=>u(null)})}),O&&s.jsx(l.Suspense,{children:s.jsx(xe,{page:O,onClose:()=>R(null)})}),I&&s.jsx(l.Suspense,{children:s.jsx(me,{page:I,onClose:()=>G(null),closePanel:e})})]})};exports.default=Pe;
@@ -1,197 +0,0 @@
1
- import { jsx as e, jsxs as r, Fragment as w } from "react/jsx-runtime";
2
- import { f as P, L, h as F, A as I } from "./index-zaGKeGBW.js";
3
- import { u as z } from "./use-page-expand-manager-D6T75I11.js";
4
- import { Button as m, Tooltip as f, TooltipTrigger as v, TooltipContent as g, Select as j, SelectTrigger as $, SelectContent as G, Input as S, SelectItem as b } from "@chaibuilder/sdk/ui";
5
- import { useQueryClient as T } from "@tanstack/react-query";
6
- import { isEmpty as y, filter as u, map as C, get as o } from "lodash-es";
7
- import { Star as D, Plus as M, FilterXIcon as R, Filter as W, ListFilter as q, Search as A, ChevronsUpDown as B, ChevronsDownUp as K, RefreshCw as Q } from "lucide-react";
8
- import { useState as _ } from "react";
9
- const O = ({ selectedPageType: a, setSelectedPageType: i }) => {
10
- const [s, l] = _(""), { data: n } = F(), c = (t) => {
11
- if (!s) return !0;
12
- const d = s.toLowerCase(), h = (x) => String(o(t, x, "")).toLowerCase().includes(d);
13
- return h("name") || h("key");
14
- }, p = n.find((t) => t.key === a);
15
- return /* @__PURE__ */ r(j, { onValueChange: i, value: a, children: [
16
- /* @__PURE__ */ e(
17
- $,
18
- {
19
- className: `${a === "all" ? "bg-gray-100/30 hover:bg-gray-100" : "gap-x-1 border bg-gray-100/30 hover:bg-gray-100"} h-9 w-max min-w-[150px] overflow-hidden whitespace-nowrap rounded p-0 px-2 py-1 text-xs text-gray-600 shadow-none ring-0 focus:ring-0 [&>svg]:hidden`,
20
- children: /* @__PURE__ */ r("div", { className: "flex w-full items-center justify-between gap-x-1.5", children: [
21
- /* @__PURE__ */ e("span", { className: "max-w-[150px] overflow-hidden truncate whitespace-nowrap font-medium leading-tight", children: (p == null ? void 0 : p.name) || "All" }),
22
- /* @__PURE__ */ e(
23
- q,
24
- {
25
- className: `${a !== "all" ? "fill-sky-50 text-sky-500" : ""} pointer-events-none h-4 w-4 text-muted-foreground hover:bg-blue-300`
26
- }
27
- )
28
- ] })
29
- }
30
- ),
31
- /* @__PURE__ */ r(G, { children: [
32
- /* @__PURE__ */ e("div", { className: "sticky top-0 z-10 bg-white pb-2", children: /* @__PURE__ */ r("div", { className: "relative", children: [
33
- /* @__PURE__ */ e(A, { strokeWidth: 2, className: "absolute left-2 top-2.5 h-3.5 w-3.5 text-gray-400" }),
34
- /* @__PURE__ */ e(
35
- S,
36
- {
37
- placeholder: "Search page types...",
38
- className: "h-8 w-full rounded border pl-8 text-xs shadow-none",
39
- value: s,
40
- onChange: (t) => l(t.target.value),
41
- onKeyDown: (t) => t.stopPropagation()
42
- }
43
- )
44
- ] }) }),
45
- /* @__PURE__ */ e(b, { value: "all", children: "All" }),
46
- !y(u(n, (t) => t.hasSlug && c(t))) && /* @__PURE__ */ r(w, { children: [
47
- /* @__PURE__ */ e("div", { className: "mt-2 border-t px-2 py-1.5 pt-2 text-xs font-semibold text-gray-500", children: "Pages" }),
48
- C(
49
- [...u(n, (t) => t.hasSlug && c(t))].sort(
50
- (t, d) => o(t, "name", "").localeCompare(o(d, "name", ""))
51
- ),
52
- (t) => /* @__PURE__ */ e(b, { value: o(t, "key"), children: o(t, "name") }, o(t, "key"))
53
- )
54
- ] }),
55
- !y(u(n, (t) => !t.hasSlug && c(t))) && /* @__PURE__ */ r(w, { children: [
56
- /* @__PURE__ */ e("div", { className: "mt-2 border-t px-2 py-1.5 pt-2 text-xs font-semibold text-gray-500", children: "Partials" }),
57
- C(
58
- [...u(n, (t) => !t.hasSlug && c(t))].sort(
59
- (t, d) => o(t, "name", "").localeCompare(o(d, "name", ""))
60
- ),
61
- (t) => /* @__PURE__ */ e(b, { value: o(t, "key"), children: o(t, "name") }, o(t, "key"))
62
- )
63
- ] }),
64
- y(u(n, c)) && /* @__PURE__ */ e("div", { className: "px-3 py-2 text-center text-sm text-gray-500", children: "No matching page types found" })
65
- ] })
66
- ] });
67
- }, U = ({ search: a, setSearch: i }) => /* @__PURE__ */ r("div", { className: "relative flex h-9 flex-1 items-center gap-2 rounded-md border px-2.5", children: [
68
- /* @__PURE__ */ e("label", { htmlFor: "page-search-input", className: "sr-only", children: "Search Pages" }),
69
- /* @__PURE__ */ e(
70
- A,
71
- {
72
- className: `${a ? "fill-sky-50 text-sky-500" : ""} pointer-events-none h-4 w-4 text-muted-foreground`,
73
- "aria-hidden": "true"
74
- }
75
- ),
76
- /* @__PURE__ */ e(
77
- S,
78
- {
79
- id: "page-search-input",
80
- placeholder: "Search pages",
81
- value: a,
82
- onChange: (s) => i(s.target.value),
83
- className: "border-none px-1.5 shadow-none outline-none ring-0 transition-none focus:outline-none focus:ring-0 focus-visible:ring-0",
84
- autoComplete: "off"
85
- }
86
- )
87
- ] }), V = ({ pages: a }) => {
88
- const { expandAll: i, collapseAll: s, expandedPages: l } = z(null);
89
- return /* @__PURE__ */ r("div", { className: "flex gap-1", children: [
90
- /* @__PURE__ */ r(f, { children: [
91
- /* @__PURE__ */ e(v, { asChild: !0, children: /* @__PURE__ */ e(m, { variant: "outline", size: "icon", onClick: () => i(a), className: "rounded p-1 text-gray-500", children: /* @__PURE__ */ e(B, {}) }) }),
92
- /* @__PURE__ */ e(g, { children: "Expand All" })
93
- ] }),
94
- /* @__PURE__ */ r(f, { children: [
95
- /* @__PURE__ */ e(v, { asChild: !0, children: /* @__PURE__ */ e(
96
- m,
97
- {
98
- disabled: l.length === 0,
99
- variant: "outline",
100
- size: "icon",
101
- onClick: () => s(),
102
- className: "rounded p-1 text-gray-500",
103
- children: /* @__PURE__ */ e(K, {})
104
- }
105
- ) }),
106
- /* @__PURE__ */ e(g, { children: "Collapse All" })
107
- ] })
108
- ] });
109
- }, X = ({ languages: a, selectedLanguage: i, setSelectedLanguage: s }) => {
110
- const l = P();
111
- return /* @__PURE__ */ e("div", { className: "scrollbar-hide flex gap-1 overflow-x-auto pb-1", children: a.map((n) => /* @__PURE__ */ r(
112
- m,
113
- {
114
- variant: i === n ? "default" : "outline",
115
- size: "sm",
116
- className: `h-6 flex-shrink-0 whitespace-nowrap rounded px-3 text-xs font-normal ${i === n ? "bg-black text-white hover:bg-black" : "text-gray-500"}`,
117
- onClick: () => s(n.toLowerCase()),
118
- children: [
119
- n === l && /* @__PURE__ */ e(D, { size: 4, className: `p-0.5 ${i === l ? "fill-white" : "fill-black"}` }),
120
- L[n] || ""
121
- ]
122
- },
123
- n
124
- )) });
125
- }, k = () => {
126
- const a = T();
127
- return /* @__PURE__ */ r(f, { children: [
128
- /* @__PURE__ */ e(v, { asChild: !0, children: /* @__PURE__ */ e(
129
- m,
130
- {
131
- size: "sm",
132
- variant: "ghost",
133
- onClick: () => a.invalidateQueries({ queryKey: [I.GET_WEBSITE_PAGES] }),
134
- className: "mt-1 h-6 w-6",
135
- children: /* @__PURE__ */ e(Q, {})
136
- }
137
- ) }),
138
- /* @__PURE__ */ e(g, { side: "bottom", children: "Refresh pages list" })
139
- ] });
140
- }, le = ({
141
- pages: a,
142
- search: i,
143
- setSearch: s,
144
- languages: l,
145
- onAddPage: n,
146
- selectedLanguage: c,
147
- setSelectedLanguage: p,
148
- selectedPageType: t,
149
- setSelectedPageType: d,
150
- showUntranslatedPages: h,
151
- setShowUntranslatedPages: x
152
- }) => {
153
- const N = l.length > 1;
154
- return /* @__PURE__ */ r("div", { className: "space-y-3 border-b border-b-gray-200 px-4 pb-1", children: [
155
- /* @__PURE__ */ r("div", { className: "flex items-center gap-x-2", children: [
156
- /* @__PURE__ */ e(O, { selectedPageType: t, setSelectedPageType: d }),
157
- /* @__PURE__ */ e(U, { search: i, setSearch: s }),
158
- /* @__PURE__ */ e(V, { pages: a }),
159
- /* @__PURE__ */ r(m, { variant: "default", onClick: n, className: "rounded px-3 font-normal", children: [
160
- /* @__PURE__ */ e(M, { strokeWidth: 2, className: "stroke-white stroke-[3]" }),
161
- /* @__PURE__ */ e("span", { className: "font-normal text-white", children: "Add Page" })
162
- ] }),
163
- !N && /* @__PURE__ */ e(k, {})
164
- ] }),
165
- N ? /* @__PURE__ */ r("div", { className: "flex items-center justify-between gap-2", children: [
166
- /* @__PURE__ */ e(
167
- X,
168
- {
169
- languages: l,
170
- selectedLanguage: c,
171
- setSelectedLanguage: (E) => {
172
- p(E), x(h && (l == null ? void 0 : l[0]) !== c);
173
- }
174
- }
175
- ),
176
- /* @__PURE__ */ r("div", { className: "flex items-center gap-x-2", children: [
177
- (l == null ? void 0 : l[0]) !== c && /* @__PURE__ */ r(f, { children: [
178
- /* @__PURE__ */ e(v, { asChild: !0, children: /* @__PURE__ */ e(
179
- m,
180
- {
181
- variant: "ghost",
182
- onClick: () => x(!h),
183
- className: "h-6 rounded px-3 py-1 text-xs font-normal",
184
- children: h ? /* @__PURE__ */ e(R, {}) : /* @__PURE__ */ e(W, {})
185
- }
186
- ) }),
187
- /* @__PURE__ */ e(g, { side: "bottom", children: "Toggle Untranslated Pages" })
188
- ] }),
189
- /* @__PURE__ */ e(k, {})
190
- ] })
191
- ] }) : /* @__PURE__ */ e("div", { className: "flex items-center justify-between gap-2" })
192
- ] });
193
- };
194
- export {
195
- X as LanguageSelector,
196
- le as default
197
- };
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),m=require("./index-Blg1T7nL.cjs"),y=require("./use-page-expand-manager-2KjeYfVS.cjs"),s=require("@chaibuilder/sdk/ui"),b=require("@tanstack/react-query"),r=require("lodash-es"),c=require("lucide-react"),N=require("react"),w=({selectedPageType:n,setSelectedPageType:a})=>{const[o,l]=N.useState(""),{data:i}=m.usePageTypes(),d=t=>{if(!o)return!0;const x=o.toLowerCase(),h=p=>String(r.get(t,p,"")).toLowerCase().includes(x);return h("name")||h("key")},u=i.find(t=>t.key===n);return e.jsxs(s.Select,{onValueChange:a,value:n,children:[e.jsx(s.SelectTrigger,{className:`${n==="all"?"bg-gray-100/30 hover:bg-gray-100":"gap-x-1 border bg-gray-100/30 hover:bg-gray-100"} h-9 w-max min-w-[150px] overflow-hidden whitespace-nowrap rounded p-0 px-2 py-1 text-xs text-gray-600 shadow-none ring-0 focus:ring-0 [&>svg]:hidden`,children:e.jsxs("div",{className:"flex w-full items-center justify-between gap-x-1.5",children:[e.jsx("span",{className:"max-w-[150px] overflow-hidden truncate whitespace-nowrap font-medium leading-tight",children:(u==null?void 0:u.name)||"All"}),e.jsx(c.ListFilter,{className:`${n!=="all"?"fill-sky-50 text-sky-500":""} pointer-events-none h-4 w-4 text-muted-foreground hover:bg-blue-300`})]})}),e.jsxs(s.SelectContent,{children:[e.jsx("div",{className:"sticky top-0 z-10 bg-white pb-2",children:e.jsxs("div",{className:"relative",children:[e.jsx(c.Search,{strokeWidth:2,className:"absolute left-2 top-2.5 h-3.5 w-3.5 text-gray-400"}),e.jsx(s.Input,{placeholder:"Search page types...",className:"h-8 w-full rounded border pl-8 text-xs shadow-none",value:o,onChange:t=>l(t.target.value),onKeyDown:t=>t.stopPropagation()})]})}),e.jsx(s.SelectItem,{value:"all",children:"All"}),!r.isEmpty(r.filter(i,t=>t.hasSlug&&d(t)))&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mt-2 border-t px-2 py-1.5 pt-2 text-xs font-semibold text-gray-500",children:"Pages"}),r.map([...r.filter(i,t=>t.hasSlug&&d(t))].sort((t,x)=>r.get(t,"name","").localeCompare(r.get(x,"name",""))),t=>e.jsx(s.SelectItem,{value:r.get(t,"key"),children:r.get(t,"name")},r.get(t,"key")))]}),!r.isEmpty(r.filter(i,t=>!t.hasSlug&&d(t)))&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mt-2 border-t px-2 py-1.5 pt-2 text-xs font-semibold text-gray-500",children:"Partials"}),r.map([...r.filter(i,t=>!t.hasSlug&&d(t))].sort((t,x)=>r.get(t,"name","").localeCompare(r.get(x,"name",""))),t=>e.jsx(s.SelectItem,{value:r.get(t,"key"),children:r.get(t,"name")},r.get(t,"key")))]}),r.isEmpty(r.filter(i,d))&&e.jsx("div",{className:"px-3 py-2 text-center text-sm text-gray-500",children:"No matching page types found"})]})]})},C=({search:n,setSearch:a})=>e.jsxs("div",{className:"relative flex h-9 flex-1 items-center gap-2 rounded-md border px-2.5",children:[e.jsx("label",{htmlFor:"page-search-input",className:"sr-only",children:"Search Pages"}),e.jsx(c.Search,{className:`${n?"fill-sky-50 text-sky-500":""} pointer-events-none h-4 w-4 text-muted-foreground`,"aria-hidden":"true"}),e.jsx(s.Input,{id:"page-search-input",placeholder:"Search pages",value:n,onChange:o=>a(o.target.value),className:"border-none px-1.5 shadow-none outline-none ring-0 transition-none focus:outline-none focus:ring-0 focus-visible:ring-0",autoComplete:"off"})]}),S=({pages:n})=>{const{expandAll:a,collapseAll:o,expandedPages:l}=y.usePageExpandManager(null);return e.jsxs("div",{className:"flex gap-1",children:[e.jsxs(s.Tooltip,{children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsx(s.Button,{variant:"outline",size:"icon",onClick:()=>a(n),className:"rounded p-1 text-gray-500",children:e.jsx(c.ChevronsUpDown,{})})}),e.jsx(s.TooltipContent,{children:"Expand All"})]}),e.jsxs(s.Tooltip,{children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsx(s.Button,{disabled:l.length===0,variant:"outline",size:"icon",onClick:()=>o(),className:"rounded p-1 text-gray-500",children:e.jsx(c.ChevronsDownUp,{})})}),e.jsx(s.TooltipContent,{children:"Collapse All"})]})]})},f=({languages:n,selectedLanguage:a,setSelectedLanguage:o})=>{const l=m.useFallbackLang();return e.jsx("div",{className:"scrollbar-hide flex gap-1 overflow-x-auto pb-1",children:n.map(i=>e.jsxs(s.Button,{variant:a===i?"default":"outline",size:"sm",className:`h-6 flex-shrink-0 whitespace-nowrap rounded px-3 text-xs font-normal ${a===i?"bg-black text-white hover:bg-black":"text-gray-500"}`,onClick:()=>o(i.toLowerCase()),children:[i===l&&e.jsx(c.Star,{size:4,className:`p-0.5 ${a===l?"fill-white":"fill-black"}`}),m.LANGUAGES[i]||""]},i))})},j=()=>{const n=b.useQueryClient();return e.jsxs(s.Tooltip,{children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsx(s.Button,{size:"sm",variant:"ghost",onClick:()=>n.invalidateQueries({queryKey:[m.ACTIONS.GET_WEBSITE_PAGES]}),className:"mt-1 h-6 w-6",children:e.jsx(c.RefreshCw,{})})}),e.jsx(s.TooltipContent,{side:"bottom",children:"Refresh pages list"})]})},k=({pages:n,search:a,setSearch:o,languages:l,onAddPage:i,selectedLanguage:d,setSelectedLanguage:u,selectedPageType:t,setSelectedPageType:x,showUntranslatedPages:h,setShowUntranslatedPages:p})=>{const g=l.length>1;return e.jsxs("div",{className:"space-y-3 border-b border-b-gray-200 px-4 pb-1",children:[e.jsxs("div",{className:"flex items-center gap-x-2",children:[e.jsx(w,{selectedPageType:t,setSelectedPageType:x}),e.jsx(C,{search:a,setSearch:o}),e.jsx(S,{pages:n}),e.jsxs(s.Button,{variant:"default",onClick:i,className:"rounded px-3 font-normal",children:[e.jsx(c.Plus,{strokeWidth:2,className:"stroke-white stroke-[3]"}),e.jsx("span",{className:"font-normal text-white",children:"Add Page"})]}),!g&&e.jsx(j,{})]}),g?e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx(f,{languages:l,selectedLanguage:d,setSelectedLanguage:v=>{u(v),p(h&&(l==null?void 0:l[0])!==d)}}),e.jsxs("div",{className:"flex items-center gap-x-2",children:[(l==null?void 0:l[0])!==d&&e.jsxs(s.Tooltip,{children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsx(s.Button,{variant:"ghost",onClick:()=>p(!h),className:"h-6 rounded px-3 py-1 text-xs font-normal",children:h?e.jsx(c.FilterXIcon,{}):e.jsx(c.Filter,{})})}),e.jsx(s.TooltipContent,{side:"bottom",children:"Toggle Untranslated Pages"})]}),e.jsx(j,{})]})]}):e.jsx("div",{className:"flex items-center justify-between gap-2"})]})};exports.LanguageSelector=f;exports.default=k;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("./index-Blg1T7nL.cjs"),d=require("@chaibuilder/sdk"),a=require("@chaibuilder/sdk/ui"),l=()=>{const[t]=d.useTheme(),{mutate:o,isPending:i}=s.usePublishPages(),{mutateAsync:n,isPending:u}=s.useUpdateWebsiteSettings(),r=()=>{n({settings:{theme:t}})},c=async()=>{await n({settings:{theme:t}}),o({ids:["THEME"]},{onSuccess:()=>{s.throwConfetti("BOTTOM_RIGHT")}})};return e.jsxs("div",{className:"flex items-center justify-center gap-x-3 border-t bg-white py-3",children:[e.jsx(a.Button,{size:"sm",variant:"outline",disabled:i||u,onClick:r,children:"Save draft"}),e.jsx(a.Button,{size:"sm",disabled:i||u,onClick:c,children:"Publish"})]})};exports.default=l;
@@ -1,25 +0,0 @@
1
- import { jsxs as h, jsx as n } from "react/jsx-runtime";
2
- import { u as l, a as m, t as r } from "./index-zaGKeGBW.js";
3
- import { useTheme as d } from "@chaibuilder/sdk";
4
- import { Button as a } from "@chaibuilder/sdk/ui";
5
- const P = () => {
6
- const [e] = d(), { mutate: o, isPending: s } = l(), { mutateAsync: t, isPending: i } = m();
7
- return /* @__PURE__ */ h("div", { className: "flex items-center justify-center gap-x-3 border-t bg-white py-3", children: [
8
- /* @__PURE__ */ n(a, { size: "sm", variant: "outline", disabled: s || i, onClick: () => {
9
- t({ settings: { theme: e } });
10
- }, children: "Save draft" }),
11
- /* @__PURE__ */ n(a, { size: "sm", disabled: s || i, onClick: async () => {
12
- await t({ settings: { theme: e } }), o(
13
- { ids: ["THEME"] },
14
- {
15
- onSuccess: () => {
16
- r("BOTTOM_RIGHT");
17
- }
18
- }
19
- );
20
- }, children: "Publish" })
21
- ] });
22
- };
23
- export {
24
- P as default
25
- };
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),c=require("./index-Blg1T7nL.cjs"),t=require("@chaibuilder/sdk/ui"),u=require("react"),d=({page:i,onClose:a})=>{const[s,n]=u.useState(!1),r=c.useUnmarkAsTemplate(),o=()=>{n(!0),r.mutate(i,{onSuccess:()=>{n(!1),a()},onError:()=>{n(!1)}})};return e.jsx(t.Dialog,{open:!0,onOpenChange:a,children:e.jsxs(t.DialogContent,{children:[e.jsxs(t.DialogHeader,{children:[e.jsx(t.DialogTitle,{children:"Unmark as template"}),e.jsx(t.DialogDescription,{className:"space-y-1 py-4 text-xs text-slate-500",children:"Are you sure you want to unmark this page as a template?"})]}),e.jsxs(t.DialogFooter,{className:s?"pointer-events-none opacity-75":"",children:[e.jsx(t.Button,{variant:"outline",onClick:l=>{l.stopPropagation(),a()},children:"Cancel"}),e.jsx(t.Button,{variant:"default",disabled:s,onClick:o,children:"Unmark as template"})]})]})})};exports.default=d;