@chaibuilder/pages 0.16.14 → 0.16.15
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-B7xwscsX.js → 2AITGKQY-2rt9M99C.js} +5 -5
- package/dist/{2AITGKQY-B9AnRLq_.cjs → 2AITGKQY-Cs6RBSPQ.cjs} +1 -1
- package/dist/{NCMVHL6D-CRMC-wXy.cjs → NCMVHL6D-CsC6nsSQ.cjs} +1 -1
- package/dist/{NCMVHL6D-B1mwht0Q.js → NCMVHL6D-vUfYKc6i.js} +4 -4
- package/dist/{ZDWCUMSJ-BqqPEOij.cjs → ZDWCUMSJ-B2OZjsr6.cjs} +1 -1
- package/dist/{ZDWCUMSJ-CxKNtXtp.js → ZDWCUMSJ-CzEWKlEU.js} +1 -1
- package/dist/active-in-another-tab-B0N5S-Bh.js +34 -0
- package/dist/active-in-another-tab-BK3cZf-x.cjs +1 -0
- package/dist/{add-new-language-page-D2a6GK-7.cjs → add-new-language-page-Dt1j-8Zg.cjs} +1 -1
- package/dist/{add-new-language-page-DD0qvJJs.js → add-new-language-page-YlqcCdlK.js} +20 -20
- package/dist/{add-new-page-01GDCaa4.cjs → add-new-page-DqhQUQBz.cjs} +1 -1
- package/dist/{add-new-page-CYtuChN1.js → add-new-page-aYomeid4.js} +1 -1
- package/dist/{ai-panel-content-DfdnvlS8.js → ai-panel-content-C6cH9rrC.js} +2 -2
- package/dist/{ai-panel-content-Ouz6pu_0.cjs → ai-panel-content-MOZmNIKP.cjs} +1 -1
- package/dist/{ai-panel-default-lang-Bi2fH1so.js → ai-panel-default-lang-BZHkFsox.js} +3 -3
- package/dist/{ai-panel-default-lang-N1pb8rzQ.cjs → ai-panel-default-lang-DOk_Q0IO.cjs} +2 -2
- package/dist/{ai-panel-other-lang-2JPRSyO1.js → ai-panel-other-lang-D2A46FTg.js} +3 -3
- package/dist/{ai-panel-other-lang-BysU1464.cjs → ai-panel-other-lang-qHrdvAMa.cjs} +1 -1
- package/dist/{ai-prompt-input-JeIqWZco.cjs → ai-prompt-input-BZSjjNJd.cjs} +1 -1
- package/dist/{ai-prompt-input-DadL_cng.js → ai-prompt-input-C6gDvvLQ.js} +2 -2
- package/dist/{ai-translation-prompt-CQb1L7NM.cjs → ai-translation-prompt-BqXo2CLp.cjs} +1 -1
- package/dist/{ai-translation-prompt-B0si-R0R.js → ai-translation-prompt-DTR0wbGt.js} +1 -1
- package/dist/continue-editing-in-this-client-C3T6Jzhi.cjs +1 -0
- package/dist/continue-editing-in-this-client-D2S1yCOM.js +24 -0
- package/dist/delete-page-BF1k60U2.js +70 -0
- package/dist/delete-page-x0DWKzsR.cjs +1 -0
- package/dist/{digital-asset-manager-B5FQGtGY.cjs → digital-asset-manager-BmlFt2T_.cjs} +1 -1
- package/dist/{digital-asset-manager-jfnmWRJj.js → digital-asset-manager-C8udwDBW.js} +1 -1
- package/dist/{duplicate-page-BNjfZ7Wd.cjs → duplicate-page-Dt_QZkTk.cjs} +1 -1
- package/dist/{duplicate-page-CERjaPIW.js → duplicate-page-u_6vUVo1.js} +13 -13
- package/dist/{dynamic-page-selector-Bpz_bvRu.cjs → dynamic-page-selector-Cgs_Y_Kl.cjs} +1 -1
- package/dist/{dynamic-page-selector-XEWV4iCf.js → dynamic-page-selector-DxBHmglP.js} +1 -1
- package/dist/index-BeWL6Sj6.cjs +5 -0
- package/dist/index-DI2Rwk5v.js +4820 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -34
- package/dist/index.js +21 -22
- package/dist/{json-diff-viewer-H-2DkGza.cjs → json-diff-viewer-D2g0Yab2.cjs} +1 -1
- package/dist/{json-diff-viewer-DyvKomxd.js → json-diff-viewer-QdUwk7yF.js} +6 -6
- package/dist/{lang-panel-BWP5A-FD.js → lang-panel-B8OD0GiA.js} +24 -24
- package/dist/{lang-panel-DcZ7u4em.cjs → lang-panel-M2Zb01lF.cjs} +1 -1
- package/dist/{mark-as-template-1oVraE1x.js → mark-as-template-CJ1mlxYT.js} +7 -7
- package/dist/{mark-as-template-B_FyVRRO.cjs → mark-as-template-DONU52b1.cjs} +1 -1
- package/dist/{no-language-page-content-JO4YYUx7.cjs → no-language-page-content-DD9Ok2Ku.cjs} +1 -1
- package/dist/{no-language-page-content-CEci_4j7.js → no-language-page-content-Dtm37LTJ.js} +1 -1
- package/dist/no-language-page-dialog-D3dvenZ7.cjs +1 -0
- package/dist/no-language-page-dialog-Dj_z2_hF.js +10 -0
- package/dist/{page-creator-DJJFl7px.js → page-creator-DIMFISo4.js} +52 -52
- package/dist/{page-creator-BGgoOA92.cjs → page-creator-DTC66ujU.cjs} +1 -1
- package/dist/page-lock-CI6BYvF_.cjs +1 -0
- package/dist/page-lock-DUlNr3os.js +30 -0
- package/dist/page-locked-dialog-BKwULMV7.js +133 -0
- package/dist/page-locked-dialog-DorIbva0.cjs +1 -0
- package/dist/page-manager-new-lNVrLOJp.cjs +1 -0
- package/dist/page-manager-new-znvqI9_L.js +354 -0
- package/dist/{page-manager-search-and-filter-DbUoW8Di.js → page-manager-search-and-filter-C-_w7N27.js} +1 -1
- package/dist/{page-manager-search-and-filter-Dgh8iyGp.cjs → page-manager-search-and-filter-pe0q0qnZ.cjs} +1 -1
- package/dist/{page-revisions-content-CwoXXE53.cjs → page-revisions-content-Caaj5TEI.cjs} +1 -1
- package/dist/{page-revisions-content-CxEJGxLY.js → page-revisions-content-CyLjyxNU.js} +19 -19
- package/dist/pages.css +1 -1
- package/dist/{publish-pages-content-CfAlmivf.js → publish-pages-content-Bih1W9C4.js} +88 -88
- package/dist/publish-pages-content-D5beVcQI.cjs +1 -0
- package/dist/{save-to-lib-BCaBfh0I.js → save-to-lib-BwpkJcT2.js} +1 -1
- package/dist/{save-to-lib-DpyJA0y1.cjs → save-to-lib-DPAERsi4.cjs} +1 -1
- package/dist/{selected-block-display-BmNhvYKu.js → selected-block-display-GXSf3y2s.js} +1 -1
- package/dist/{selected-block-display-CqnwyGRp.cjs → selected-block-display-s99Y91qI.cjs} +1 -1
- package/dist/{seo-panel-BH8fcGqr.js → seo-panel-BurZA566.js} +61 -61
- package/dist/{seo-panel-D-nKfsRJ.cjs → seo-panel-BxUfalVy.cjs} +1 -1
- package/dist/{shared-json-ld-m_OsVv8h.cjs → shared-json-ld-BYAdrPeC.cjs} +1 -1
- package/dist/{shared-json-ld-zTDoJzUv.js → shared-json-ld-DHWdJvQd.js} +39 -39
- package/dist/{slug-input-vzNtu37S.cjs → slug-input-CR2B1kDJ.cjs} +1 -1
- package/dist/{slug-input-CumDDlCk.js → slug-input-Z_ny7bgX.js} +1 -1
- package/dist/take-over-request-CnEpToCM.cjs +1 -0
- package/dist/take-over-request-DF2JsIes.js +63 -0
- package/dist/{theme-panel-footer-CdUmjB-e.js → theme-panel-footer-5mxFeEua.js} +4 -4
- package/dist/{theme-panel-footer-CKccBcd9.cjs → theme-panel-footer-C2CjHoBu.cjs} +1 -1
- package/dist/{unmark-as-template-BNFOsxIg.cjs → unmark-as-template-Dn90g1eh.cjs} +1 -1
- package/dist/{unmark-as-template-6ew-7bf8.js → unmark-as-template-JRRUYTOY.js} +1 -1
- package/dist/{unpublish-page-BZQpTpU3.cjs → unpublish-page-C3C_rTRd.cjs} +1 -1
- package/dist/{unpublish-page-BomE76Wg.js → unpublish-page-FZ8rbi7u.js} +9 -9
- package/dist/{web-preview-jo8lnpEx.js → web-preview-CGBKG162.js} +1 -1
- package/dist/{web-preview-C5QTX7bS.cjs → web-preview-NdxC92Fk.cjs} +1 -1
- package/package.json +3 -3
- package/dist/delete-page-C8Nt7IYF.cjs +0 -1
- package/dist/delete-page-_96Di9yN.js +0 -40
- package/dist/index-Pdb5tSRL.cjs +0 -5
- package/dist/index-e9WlBH0R.js +0 -4960
- package/dist/page-lock-request-BoYzkcyt.cjs +0 -1
- package/dist/page-lock-request-WzpcD2ZN.js +0 -75
- package/dist/page-locked-by-dialog-Djvjp2Hx.js +0 -68
- package/dist/page-locked-by-dialog-bvI27OZ6.cjs +0 -1
- package/dist/page-manager-new-CMfGorRQ.cjs +0 -1
- package/dist/page-manager-new-DmVX0qLk.js +0 -354
- package/dist/publish-pages-content-BRu7qwAo.cjs +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./index-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./index-BeWL6Sj6.cjs"),a=require("@chaibuilder/sdk");exports.ChaiJsonInput=e.SmartJsonInput;exports.ImagePicker=e.ImagePicker;exports.LanguageSwitcher=e.LanguageSwitcher;exports.NestedPathSelector=e.NestedPathSelector;exports.PermissionChecker=e.PermissionChecker;exports.default=e.ChaiBuilderPages;exports.useActivePage=e.useActivePage;exports.useApiUrl=e.useApiUrl;exports.useBuilderFetch=e.useBuilderFetch;exports.useBuilderPageData=e.useBuilderPageData;exports.useChaiAuth=e.useChaiAuth;exports.useChaiCurrentPage=e.useCurrentPage;exports.useChaiUserInfo=e.useChaiUserInfo;exports.useClearAll=e.useClearAll;exports.useFallbackLang=e.useFallbackLang;exports.useFetch=e.useFetch;exports.useGotoPage=e.useGotoPage;exports.useLanguagePages=e.useLanguagePages;exports.usePageTypes=e.usePageTypes;exports.useReloadPage=e.useReloadPage;exports.useUpdateActivePageMetadata=e.useUpdateActivePageMetadata;exports.useUserPermissions=e.useUserRoleAndPermissions;exports.useWebsitePages=e.useWebsitePages;exports.useWebsiteSetting=e.useWebsiteSetting;Object.keys(a).forEach(s=>{s!=="default"&&!Object.prototype.hasOwnProperty.call(exports,s)&&Object.defineProperty(exports,s,{enumerable:!0,get:()=>a[s]})});
|
package/dist/index.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ declare type ChaiBuilderPagesProps = {
|
|
|
18
18
|
getPreviewUrl?: (slug: string) => string;
|
|
19
19
|
getLiveUrl?: (slug: string) => string;
|
|
20
20
|
onLogout?: () => void;
|
|
21
|
-
getAccessToken
|
|
21
|
+
getAccessToken?: () => Promise<string>;
|
|
22
22
|
currentUser: LoggedInUser | null;
|
|
23
23
|
websocket?: ChaiWebSocketClient;
|
|
24
24
|
features?: {
|
|
@@ -27,31 +27,6 @@ declare type ChaiBuilderPagesProps = {
|
|
|
27
27
|
} & Record<string, boolean>;
|
|
28
28
|
} & Pick<ChaiBuilderEditorProps, "onError" | "translations" | "locale" | "htmlDir" | "autoSave" | "autoSaveInterval" | "fallbackLang" | "languages" | "themePresets" | "flags">;
|
|
29
29
|
|
|
30
|
-
export declare class ChaiBuilderPagesRealtime implements ChaiBuilderPagesRealtimeInterface {
|
|
31
|
-
private channelId;
|
|
32
|
-
private websocket;
|
|
33
|
-
private channel;
|
|
34
|
-
private userId;
|
|
35
|
-
private clientId;
|
|
36
|
-
private pageId;
|
|
37
|
-
private callback;
|
|
38
|
-
constructor(websocket: SupabaseClient, websiteId: string, userId: string, cb: (event: string, payload?: any) => void);
|
|
39
|
-
private getClientId;
|
|
40
|
-
private getOnlineUsers;
|
|
41
|
-
private getPageOwner;
|
|
42
|
-
private getPageUserMapping;
|
|
43
|
-
private onReceiveEvent;
|
|
44
|
-
joinPage(pageId: string): Promise<void>;
|
|
45
|
-
leavePage(): Promise<void>;
|
|
46
|
-
sendEvent(event: LISTEN_EVENTS, eventPayload?: any): Promise<void>;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
declare interface ChaiBuilderPagesRealtimeInterface {
|
|
50
|
-
leavePage: () => Promise<void>;
|
|
51
|
-
joinPage: (pageId: string) => Promise<void>;
|
|
52
|
-
sendEvent: (event: LISTEN_EVENTS, payload?: EVENT_PAYLOAD) => Promise<void>;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
30
|
export declare const ChaiJsonInput: React.FC<SmartJsonInputProps>;
|
|
56
31
|
|
|
57
32
|
declare type ChaiWebsiteSetting = {
|
|
@@ -63,12 +38,6 @@ declare type ChaiWebsiteSetting = {
|
|
|
63
38
|
|
|
64
39
|
declare type ChaiWebSocketClient = SupabaseClient;
|
|
65
40
|
|
|
66
|
-
declare type EVENT_PAYLOAD = {
|
|
67
|
-
senderClientId?: string;
|
|
68
|
-
targetClientId?: string;
|
|
69
|
-
requestingClientId?: string;
|
|
70
|
-
} & Record<string, any>;
|
|
71
|
-
|
|
72
41
|
export declare const ImagePicker: default_2.FC<ImagePickerProps>;
|
|
73
42
|
|
|
74
43
|
declare interface ImagePickerProps {
|
|
@@ -89,8 +58,6 @@ export declare const LanguageSwitcher: ({ showAdd, variant, goToDefaultLang, }:
|
|
|
89
58
|
goToDefaultLang?: boolean;
|
|
90
59
|
}) => JSX.Element | null;
|
|
91
60
|
|
|
92
|
-
declare type LISTEN_EVENTS = "PAGE_LOCKED" | "USER_JOINED" | "TAKE_OVER_REQUESTED" | "UPDATE_ONLINE_USERS" | "TAKE_OVER_REQUEST_ACCEPTED" | "TAKE_OVER_REQUEST_REJECTED";
|
|
93
|
-
|
|
94
61
|
declare type LoggedInUser = {
|
|
95
62
|
id: string;
|
|
96
63
|
email: string;
|
package/dist/index.js
CHANGED
|
@@ -1,29 +1,28 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { aE as s, aS as u, aQ as t, aR as r, ax as i, aV as g, aW as o, aq as P, at as l, aN as h, a$ as n, aw as c, ao as d, aX as C, k as m, ar as p, aY as A, l as b, m as f, aZ as k, a_ as S, b0 as U, g as x, j as F } from "./index-DI2Rwk5v.js";
|
|
2
2
|
export * from "@chaibuilder/sdk";
|
|
3
3
|
export {
|
|
4
|
-
s as
|
|
5
|
-
u as
|
|
6
|
-
t as
|
|
7
|
-
i as LanguageSwitcher,
|
|
4
|
+
s as ChaiJsonInput,
|
|
5
|
+
u as ImagePicker,
|
|
6
|
+
t as LanguageSwitcher,
|
|
8
7
|
r as NestedPathSelector,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
8
|
+
i as PermissionChecker,
|
|
9
|
+
g as default,
|
|
10
|
+
o as useActivePage,
|
|
11
|
+
P as useApiUrl,
|
|
12
|
+
l as useBuilderFetch,
|
|
13
|
+
h as useBuilderPageData,
|
|
14
|
+
n as useChaiAuth,
|
|
15
|
+
c as useChaiCurrentPage,
|
|
16
|
+
d as useChaiUserInfo,
|
|
17
|
+
C as useClearAll,
|
|
18
|
+
m as useFallbackLang,
|
|
19
|
+
p as useFetch,
|
|
21
20
|
A as useGotoPage,
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
b as useLanguagePages,
|
|
22
|
+
f as usePageTypes,
|
|
24
23
|
k as useReloadPage,
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
S as useUpdateActivePageMetadata,
|
|
25
|
+
U as useUserPermissions,
|
|
27
26
|
x as useWebsitePages,
|
|
28
|
-
|
|
27
|
+
F as useWebsiteSetting
|
|
29
28
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),x=require("@chaibuilder/sdk/ui"),z=require("date-fns"),p=require("lodash-es"),N=require("lucide-react"),b=require("react"),M=require("react-diff-view"),O=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),x=require("@chaibuilder/sdk/ui"),z=require("date-fns"),p=require("lodash-es"),N=require("lucide-react"),b=require("react"),M=require("react-diff-view"),O=require("./index-BeWL6Sj6.cjs"),B=require("@tanstack/react-query");function H(t,r){const o=O.useApiUrl(),n=O.useFetch(),f=p.startsWith(t.uid,"draft:")||p.startsWith(r.uid,"live:");return B.useQuery({queryKey:["revision-comparison",t.uid,r.uid],queryFn:async()=>{if(!t.uid||!r.uid)throw new Error("Both revision IDs are required for comparison");const l=u=>u==="draft"||u==="live"?u:"revision",s=u=>p.replace(u.uid,`${u.label}:`,"");return await n(o,{action:O.ACTIONS.GET_COMPARE_DATA,data:{versions:{version1:{type:l(t.label),id:s(t)},version2:{type:l(r.label),id:s(r)}}}})},enabled:!!t.uid&&!!r.uid,staleTime:f?0:1/0})}const K=({version:t})=>{const r=t==null?void 0:t.item,{data:o}=O.useChaiUserInfo(r==null?void 0:r.currentEditor),n=t.label==="live",f=t.label==="draft";return e.jsxs("span",{className:`flex items-center gap-x-2 rounded border bg-white px-2 text-xs shadow-lg ${n?"border-green-500/30":f?"border-amber-500/30":"border-purple-500/30"}`,children:[e.jsx("div",{className:"h-full items-center rounded px-1.5 py-0.5 font-medium capitalize"+(n?" bg-green-500 text-green-50":f?" bg-amber-500 text-amber-50":" bg-purple-500 text-purple-50"),children:t.label}),e.jsxs("div",{className:"py-1 text-xs font-light leading-none text-gray-800",children:[e.jsxs("div",{children:[e.jsx("span",{className:"font-light opacity-90",children:f?"Currently editing":"Published by"}),!f&&e.jsx("span",{className:"pl-1 font-medium",children:(o==null?void 0:o.name)||"Unknown"})]}),e.jsx("div",{className:"text-[10px] leading-tight",children:z.formatDate(r.createdAt,"dd MMM yyyy, h:mm a")})]})]})},L=({version:t})=>e.jsx(K,{version:t});function V(t,r,o="data.json"){const n=JSON.stringify(t,null,2),f=JSON.stringify(r,null,2),l=n.split(`
|
|
2
2
|
`),s=f.split(`
|
|
3
3
|
`);let d=`--- a/${o}
|
|
4
4
|
`;d+=`+++ b/${o}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { jsx as e, jsxs as h } from "react/jsx-runtime";
|
|
2
|
-
import { Dialog as
|
|
2
|
+
import { Dialog as U, DialogContent as V, DialogHeader as _, DialogTitle as G, Switch as $, ScrollArea as I, Button as z, Badge as P } from "@chaibuilder/sdk/ui";
|
|
3
3
|
import { formatDate as Q } from "date-fns";
|
|
4
4
|
import { startsWith as T, replace as W, isString as X, trim as Y, isArray as Z, map as ee, isPlainObject as te, mapValues as re } from "lodash-es";
|
|
5
5
|
import { FileJson as F, Loader as ne, Check as B, Copy as H } from "lucide-react";
|
|
6
6
|
import { useState as D, useMemo as A } from "react";
|
|
7
7
|
import { parseDiff as se, Diff as le, Hunk as ae } from "react-diff-view";
|
|
8
|
-
import {
|
|
8
|
+
import { aq as ie, ar as oe, A as ce, ao as de } from "./index-DI2Rwk5v.js";
|
|
9
9
|
import { useQuery as fe } from "@tanstack/react-query";
|
|
10
10
|
function me(t, n) {
|
|
11
11
|
const o = ie(), s = oe(), u = T(t.uid, "draft:") || T(n.uid, "live:");
|
|
@@ -157,7 +157,7 @@ const pe = (t) => {
|
|
|
157
157
|
}), u;
|
|
158
158
|
};
|
|
159
159
|
function Te({ open: t, compare: n, onOpenChange: o }) {
|
|
160
|
-
const s = n[0], u = n[1], [l, r] = D(null), [d, f] = D("split"), [c, p] = D(!1), [y, j] = D(!0), [g, N] = D("blocks"), { data: m, isLoading: x } = me(s, u), { leftData: a, rightData: w, options:
|
|
160
|
+
const s = n[0], u = n[1], [l, r] = D(null), [d, f] = D("split"), [c, p] = D(!1), [y, j] = D(!0), [g, N] = D("blocks"), { data: m, isLoading: x } = me(s, u), { leftData: a, rightData: w, options: q } = A(() => {
|
|
161
161
|
var b, R;
|
|
162
162
|
const i = (b = m == null ? void 0 : m.version1) == null ? void 0 : b[g], v = (R = m == null ? void 0 : m.version2) == null ? void 0 : R[g], k = S(i), C = S(v), J = ge(m == null ? void 0 : m.version1, m == null ? void 0 : m.version2);
|
|
163
163
|
return { leftData: k, rightData: C, options: J };
|
|
@@ -175,13 +175,13 @@ function Te({ open: t, compare: n, onOpenChange: o }) {
|
|
|
175
175
|
console.error("Failed to copy:", k);
|
|
176
176
|
}
|
|
177
177
|
}, M = (i) => JSON.stringify(i, null, 2);
|
|
178
|
-
return /* @__PURE__ */ e(
|
|
179
|
-
/* @__PURE__ */ e(
|
|
178
|
+
return /* @__PURE__ */ e(U, { open: t, onOpenChange: o, children: /* @__PURE__ */ h(V, { className: "flex h-[90vh] w-[95vw] max-w-[1900px] flex-col p-6", children: [
|
|
179
|
+
/* @__PURE__ */ e(_, { className: "pb-4 pt-0", children: /* @__PURE__ */ h(G, { className: "flex items-center justify-between gap-2 leading-none", children: [
|
|
180
180
|
/* @__PURE__ */ h("div", { className: "flex items-center gap-2", children: [
|
|
181
181
|
/* @__PURE__ */ e(F, { className: "h-5 w-5" }),
|
|
182
182
|
"Compare",
|
|
183
183
|
"",
|
|
184
|
-
|
|
184
|
+
q.map((i) => /* @__PURE__ */ e(
|
|
185
185
|
"div",
|
|
186
186
|
{
|
|
187
187
|
className: `cursor-pointer rounded-full border px-2.5 py-1 text-xs leading-none ${g === i.key ? "border-blue-500 bg-blue-500 text-white" : "border-gray-600 text-gray-600 hover:bg-gray-200"}`,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as e, jsxs as s, Fragment as M } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import { useTranslation as G, useLanguages as
|
|
4
|
-
import { Dialog as
|
|
5
|
-
import { find as z, startsWith as E, isEqual as
|
|
2
|
+
import { au as j, m as T, L as I, av as F, l as H, aw as O, j as W, ax as f, ay as o } from "./index-DI2Rwk5v.js";
|
|
3
|
+
import { useTranslation as G, useLanguages as B } from "@chaibuilder/sdk";
|
|
4
|
+
import { Dialog as q, DialogContent as R, DialogHeader as J, DialogTitle as K, DialogDescription as Q, Alert as V, Label as X, Input as Y, DialogFooter as Z, Button as A, DropdownMenu as ee, DropdownMenuTrigger as se, DropdownMenuContent as ne, DropdownMenuItem as w } from "@chaibuilder/sdk/ui";
|
|
5
|
+
import { find as z, startsWith as E, isEqual as le, filter as ae, get as D, map as te, isEmpty as ie } from "lodash-es";
|
|
6
6
|
import { AlertCircle as re, StarIcon as ce, MoreHorizontal as oe, PencilIcon as de, Power as me, TrashIcon as ue } from "lucide-react";
|
|
7
7
|
import { useState as S, lazy as U, useMemo as he, Suspense as L } from "react";
|
|
8
8
|
import { toast as ge } from "sonner";
|
|
@@ -11,7 +11,7 @@ const fe = ({
|
|
|
11
11
|
page: n,
|
|
12
12
|
onClose: g
|
|
13
13
|
}) => {
|
|
14
|
-
const { t } = G(), [i, v] = S(n.slug || ""), { mutate: N, isPending: y } = j(), { data:
|
|
14
|
+
const { t } = G(), [i, v] = S(n.slug || ""), { mutate: N, isPending: y } = j(), { data: a } = T(), r = z(a, { key: n == null ? void 0 : n.pageType }), x = (m) => {
|
|
15
15
|
if (m.preventDefault(), !(n != null && n.primaryPage) && Object.keys(I).some((p) => i === `/${p}` || E(i, `/${p}/`))) {
|
|
16
16
|
ge.error(t("Error"), {
|
|
17
17
|
description: t("Slugs cannot start with a language code for primary page")
|
|
@@ -20,7 +20,7 @@ const fe = ({
|
|
|
20
20
|
}
|
|
21
21
|
N({ ...n, slug: i }, { onSuccess: g });
|
|
22
22
|
}, d = (n == null ? void 0 : n.lang) || "";
|
|
23
|
-
return /* @__PURE__ */ e(
|
|
23
|
+
return /* @__PURE__ */ e(q, { open: !!n, onOpenChange: g, children: /* @__PURE__ */ s(R, { children: [
|
|
24
24
|
/* @__PURE__ */ s(J, { children: [
|
|
25
25
|
/* @__PURE__ */ e(K, { children: t("Change Slug") }),
|
|
26
26
|
/* @__PURE__ */ e(Q, { className: "text-xs", children: /* @__PURE__ */ s(V, { variant: "destructive", className: "mt-2", children: [
|
|
@@ -84,27 +84,27 @@ const fe = ({
|
|
|
84
84
|
A,
|
|
85
85
|
{
|
|
86
86
|
type: "submit",
|
|
87
|
-
disabled: y || !E(i, `/${d}`) ||
|
|
87
|
+
disabled: y || !E(i, `/${d}`) || le(n == null ? void 0 : n.slug, i),
|
|
88
88
|
children: t(y ? "Changing..." : "Change Slug")
|
|
89
89
|
}
|
|
90
90
|
) })
|
|
91
91
|
] })
|
|
92
92
|
] }) });
|
|
93
|
-
}, Ne = U(() => import("./delete-page-
|
|
94
|
-
const { t: n } = G(), [, g] = pe(F), { selectedLang: t, fallbackLang: i, setSelectedLang: v } =
|
|
95
|
-
const
|
|
96
|
-
return
|
|
97
|
-
}, [r,
|
|
93
|
+
}, Ne = U(() => import("./delete-page-BF1k60U2.js")), ye = U(() => import("./unpublish-page-FZ8rbi7u.js")), Pe = () => {
|
|
94
|
+
const { t: n } = G(), [, g] = pe(F), { selectedLang: t, fallbackLang: i, setSelectedLang: v } = B(), { data: N, isFetching: y } = H(), { data: a } = O(), { data: r } = T(), x = he(() => {
|
|
95
|
+
const l = r == null ? void 0 : r.find((h) => h.key === (a == null ? void 0 : a.pageType));
|
|
96
|
+
return a != null && a.dynamic ? l == null ? void 0 : l.dynamicSlug : "";
|
|
97
|
+
}, [r, a == null ? void 0 : a.pageType, a == null ? void 0 : a.dynamic]), [d, m] = S(null), [u, C] = S(null), [p, _] = S(null), { data: P } = W(), $ = ae(
|
|
98
98
|
D(P, "languages") || ["en"],
|
|
99
|
-
(
|
|
99
|
+
(l) => !z(N, { lang: l }) && l !== D(P, "fallbackLang")
|
|
100
100
|
);
|
|
101
101
|
return /* @__PURE__ */ s("div", { className: "space-y-4", children: [
|
|
102
102
|
/* @__PURE__ */ e("ul", { className: "space-y-2", children: y ? /* @__PURE__ */ s("div", { className: "w-full space-y-3 py-4", children: [
|
|
103
103
|
/* @__PURE__ */ e("div", { className: "h-8 w-full animate-pulse rounded bg-gray-300" }),
|
|
104
104
|
/* @__PURE__ */ e("div", { className: "h-8 w-full animate-pulse rounded bg-gray-300" }),
|
|
105
105
|
/* @__PURE__ */ e("div", { className: "h-8 w-full animate-pulse rounded bg-gray-300" })
|
|
106
|
-
] }) : te(N, (
|
|
107
|
-
const h =
|
|
106
|
+
] }) : te(N, (l) => {
|
|
107
|
+
const h = l.lang, b = l.slug, k = !l.primaryPage;
|
|
108
108
|
return /* @__PURE__ */ s(M, { children: [
|
|
109
109
|
/* @__PURE__ */ s(
|
|
110
110
|
"li",
|
|
@@ -114,7 +114,7 @@ const fe = ({
|
|
|
114
114
|
children: [
|
|
115
115
|
/* @__PURE__ */ s("div", { className: "flex-1 gap-x-3", children: [
|
|
116
116
|
/* @__PURE__ */ s("div", { className: "flex items-center gap-x-2 text-[13px] text-slate-800", children: [
|
|
117
|
-
/* @__PURE__ */ e("div", { className: `h-2.5 w-2.5 rounded-full ${
|
|
117
|
+
/* @__PURE__ */ e("div", { className: `h-2.5 w-2.5 rounded-full ${l.online ? "bg-green-300" : "bg-gray-300"}` }),
|
|
118
118
|
D(I, k ? i : h, h)
|
|
119
119
|
] }),
|
|
120
120
|
/* @__PURE__ */ s("div", { children: [
|
|
@@ -126,7 +126,7 @@ const fe = ({
|
|
|
126
126
|
"Name:",
|
|
127
127
|
/* @__PURE__ */ s("b", { className: "font-medium", children: [
|
|
128
128
|
" ",
|
|
129
|
-
|
|
129
|
+
l.name,
|
|
130
130
|
" "
|
|
131
131
|
] })
|
|
132
132
|
] })
|
|
@@ -153,8 +153,8 @@ const fe = ({
|
|
|
153
153
|
onClick: (c) => {
|
|
154
154
|
c.stopPropagation(), g({
|
|
155
155
|
edit: !0,
|
|
156
|
-
id:
|
|
157
|
-
primaryPage:
|
|
156
|
+
id: l.id,
|
|
157
|
+
primaryPage: l.primaryPage
|
|
158
158
|
});
|
|
159
159
|
},
|
|
160
160
|
children: [
|
|
@@ -163,12 +163,12 @@ const fe = ({
|
|
|
163
163
|
]
|
|
164
164
|
}
|
|
165
165
|
) }),
|
|
166
|
-
/* @__PURE__ */ e(f, { permissions: [o.UNPUBLISH_PAGE], children: (
|
|
166
|
+
/* @__PURE__ */ e(f, { permissions: [o.UNPUBLISH_PAGE], children: (l == null ? void 0 : l.online) && /* @__PURE__ */ s(
|
|
167
167
|
w,
|
|
168
168
|
{
|
|
169
169
|
className: "flex cursor-pointer items-center gap-2",
|
|
170
170
|
onClick: (c) => {
|
|
171
|
-
c.stopPropagation(), C(
|
|
171
|
+
c.stopPropagation(), C(l);
|
|
172
172
|
},
|
|
173
173
|
children: [
|
|
174
174
|
/* @__PURE__ */ e(me, { className: "size-3" }),
|
|
@@ -181,7 +181,7 @@ const fe = ({
|
|
|
181
181
|
{
|
|
182
182
|
className: "flex cursor-pointer items-center gap-2",
|
|
183
183
|
onClick: (c) => {
|
|
184
|
-
c.stopPropagation(), m(
|
|
184
|
+
c.stopPropagation(), m(l);
|
|
185
185
|
},
|
|
186
186
|
children: [
|
|
187
187
|
/* @__PURE__ */ e(ue, { className: "size-3" }),
|
|
@@ -195,7 +195,7 @@ const fe = ({
|
|
|
195
195
|
) })
|
|
196
196
|
]
|
|
197
197
|
},
|
|
198
|
-
|
|
198
|
+
l.id
|
|
199
199
|
),
|
|
200
200
|
/* @__PURE__ */ e("div", { className: "h-1 w-full border-b" })
|
|
201
201
|
] });
|
|
@@ -208,7 +208,7 @@ const fe = ({
|
|
|
208
208
|
disabled: ie($),
|
|
209
209
|
onClick: () => {
|
|
210
210
|
g({
|
|
211
|
-
primaryPage:
|
|
211
|
+
primaryPage: a == null ? void 0 : a.id,
|
|
212
212
|
edit: !1
|
|
213
213
|
});
|
|
214
214
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),n=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),n=require("./index-BeWL6Sj6.cjs"),C=require("@chaibuilder/sdk"),i=require("@chaibuilder/sdk/ui"),r=require("lodash-es"),j=require("lucide-react"),c=require("react"),k=require("sonner"),G=require("jotai"),L=({page:s,onClose:S})=>{const{t:a}=C.useTranslation(),[o,E]=c.useState(s.slug||""),{mutate:N,isPending:y}=n.useChangeSlug(),{data:l}=n.usePageTypes(),d=r.find(l,{key:s==null?void 0:s.pageType}),f=h=>{if(h.preventDefault(),!(s!=null&&s.primaryPage)&&Object.keys(n.LANGUAGES).some(p=>o===`/${p}`||r.startsWith(o,`/${p}/`))){k.toast.error(a("Error"),{description:a("Slugs cannot start with a language code for primary page")});return}N({...s,slug:o},{onSuccess:S})},m=(s==null?void 0:s.lang)||"";return e.jsx(i.Dialog,{open:!!s,onOpenChange:S,children:e.jsxs(i.DialogContent,{children:[e.jsxs(i.DialogHeader,{children:[e.jsx(i.DialogTitle,{children:a("Change Slug")}),e.jsx(i.DialogDescription,{className:"text-xs",children:e.jsxs(i.Alert,{variant:"destructive",className:"mt-2",children:[e.jsx(j.AlertCircle,{className:"h-4 w-4"}),a("Changing the slug may have impact on your SEO. Please proceed with caution.")]})})]}),e.jsxs("form",{onSubmit:f,children:[e.jsxs("div",{className:"space-y-4 py-4 text-sm ",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{children:[e.jsxs("span",{children:[a("Type"),":"]}),e.jsxs("span",{className:"font-medium text-gray-600",children:[" ",(d==null?void 0:d.name)||(s==null?void 0:s.pageType)]})]}),e.jsxs("div",{children:[e.jsxs("span",{children:[a("Name"),":"]}),e.jsxs("span",{className:"font-medium text-gray-600",children:[" ",s.name]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs(i.Label,{htmlFor:"slug",className:"text-right",children:[a("Slug")," ",e.jsxs("small",{className:"font-light text-gray-500",children:[a("Slug should start with")," /",m]})]}),e.jsx(i.Input,{id:"slug",value:o,onChange:h=>{const x=h.target.value;r.startsWith(x,`/${m}`)&&E(x)},className:"col-span-3",required:!0,pattern:"^/.*",title:a("Slug must start with /"),placeholder:a("Enter page slug")})]})]}),e.jsx(i.DialogFooter,{children:e.jsx(i.Button,{type:"submit",disabled:y||!r.startsWith(o,`/${m}`)||r.isEqual(s==null?void 0:s.slug,o),children:a(y?"Changing...":"Change Slug")})})]})]})})},M=c.lazy(()=>Promise.resolve().then(()=>require("./delete-page-x0DWKzsR.cjs"))),T=c.lazy(()=>Promise.resolve().then(()=>require("./unpublish-page-C3C_rTRd.cjs"))),_=()=>{const{t:s}=C.useTranslation(),[,S]=G.useAtom(n.addNewLangAtom),{selectedLang:a,fallbackLang:o,setSelectedLang:E}=C.useLanguages(),{data:N,isFetching:y}=n.useLanguagePages(),{data:l}=n.useCurrentPage(),{data:d}=n.usePageTypes(),f=c.useMemo(()=>{const t=d==null?void 0:d.find(g=>g.key===(l==null?void 0:l.pageType));return l!=null&&l.dynamic?t==null?void 0:t.dynamicSlug:""},[d,l==null?void 0:l.pageType,l==null?void 0:l.dynamic]),[m,h]=c.useState(null),[x,P]=c.useState(null),[p,A]=c.useState(null),{data:b}=n.useWebsiteSetting(),I=r.filter(r.get(b,"languages")||["en"],t=>!r.find(N,{lang:t})&&t!==r.get(b,"fallbackLang"));return e.jsxs("div",{className:"space-y-4",children:[e.jsx("ul",{className:"space-y-2",children:y?e.jsxs("div",{className:"w-full space-y-3 py-4",children:[e.jsx("div",{className:"h-8 w-full animate-pulse rounded bg-gray-300"}),e.jsx("div",{className:"h-8 w-full animate-pulse rounded bg-gray-300"}),e.jsx("div",{className:"h-8 w-full animate-pulse rounded bg-gray-300"})]}):r.map(N,t=>{const g=t.lang,v=t.slug,w=!t.primaryPage,D=g===a;return e.jsxs(e.Fragment,{children:[e.jsxs("li",{className:`flex w-full cursor-pointer items-center justify-between rounded p-2 text-slate-500 ${D?"bg-gray-200":"hover:bg-gray-100"}`,onClick:()=>E(g),children:[e.jsxs("div",{className:"flex-1 gap-x-3",children:[e.jsxs("div",{className:"flex items-center gap-x-2 text-[13px] text-slate-800",children:[e.jsx("div",{className:`h-2.5 w-2.5 rounded-full ${t.online?"bg-green-300":"bg-gray-300"}`}),r.get(n.LANGUAGES,w?o:g,g)]}),e.jsxs("div",{children:[v&&e.jsxs("div",{className:"text-[11px] font-light text-slate-600",children:["Slug: ",e.jsx("b",{className:"font-mono font-medium",children:f?`${v}/${f}`:v})]}),e.jsxs("div",{className:"text-[11px] font-light text-slate-600",children:["Name:",e.jsxs("b",{className:"font-medium",children:[" ",t.name," "]})]})]})]}),w?e.jsxs("div",{className:"flex items-center gap-x-1 text-[11px] text-orange-500",children:[e.jsx(j.StarIcon,{fill:"orange",className:"h-3 w-3"}),e.jsx("b",{children:" Primary"})]}):e.jsx("div",{className:"flex items-center gap-x-3",children:e.jsx(n.PermissionChecker,{permissions:[n.PAGES_PERMISSIONS.EDIT_PAGE,n.PAGES_PERMISSIONS.DELETE_PAGE,n.PAGES_PERMISSIONS.UNPUBLISH_PAGE],children:e.jsxs(i.DropdownMenu,{children:[e.jsx(i.DropdownMenuTrigger,{asChild:!0,onClick:u=>u.stopPropagation(),children:e.jsx(i.Button,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",children:e.jsx(j.MoreHorizontal,{className:"h-4 w-4"})})}),e.jsxs(i.DropdownMenuContent,{align:"end",className:"z-[9999] text-sm",children:[e.jsx(n.PermissionChecker,{permissions:[n.PAGES_PERMISSIONS.EDIT_PAGE],children:e.jsxs(i.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:u=>{u.stopPropagation(),S({edit:!0,id:t.id,primaryPage:t.primaryPage})},children:[e.jsx(j.PencilIcon,{className:"size-3"}),s("Edit")]})}),e.jsx(n.PermissionChecker,{permissions:[n.PAGES_PERMISSIONS.UNPUBLISH_PAGE],children:(t==null?void 0:t.online)&&e.jsxs(i.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:u=>{u.stopPropagation(),P(t)},children:[e.jsx(j.Power,{className:"size-3"}),s("Unpublish")]})}),e.jsx(n.PermissionChecker,{permissions:[n.PAGES_PERMISSIONS.DELETE_PAGE],children:e.jsxs(i.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:u=>{u.stopPropagation(),h(t)},children:[e.jsx(j.TrashIcon,{className:"size-3"}),s("Delete")]})})]})]})})})]},t.id),e.jsx("div",{className:"h-1 w-full border-b"})]})})}),e.jsx(n.PermissionChecker,{permissions:[n.PAGES_PERMISSIONS.ADD_PAGE],children:e.jsx("div",{className:"flex w-full justify-center",children:e.jsx(i.Button,{variant:"default",size:"sm",disabled:r.isEmpty(I),onClick:()=>{S({primaryPage:l==null?void 0:l.id,edit:!1})},children:s("Add new language page")})})}),m&&e.jsx(c.Suspense,{children:e.jsx(M,{page:m,onClose:()=>h(null)})}),x&&e.jsx(c.Suspense,{children:e.jsx(T,{page:x,onClose:()=>P(null)})}),p&&e.jsx(c.Suspense,{children:e.jsx(L,{page:p,onClose:()=>A(null)})})]})};exports.default=_;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { jsx as e, jsxs as t } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { r as P, m as z } from "./index-DI2Rwk5v.js";
|
|
3
3
|
import { useTranslation as E } from "@chaibuilder/sdk";
|
|
4
4
|
import { Dialog as L, DialogContent as S, DialogHeader as U, DialogTitle as B, DialogDescription as R, Label as w, Textarea as j, Input as O, Button as c, DialogFooter as X } from "@chaibuilder/sdk/ui";
|
|
5
5
|
import { startCase as y } from "lodash-es";
|
|
6
6
|
import { Tag as _, File as $, ImageIcon as H, X as K } from "lucide-react";
|
|
7
|
-
import { useState as
|
|
7
|
+
import { useState as m, useRef as Z, useCallback as q } from "react";
|
|
8
8
|
import { toast as k } from "sonner";
|
|
9
|
-
const G = 1 * 1024 * 1024, se = ({ page: n, onClose:
|
|
10
|
-
const { t: a } = E(), [g, p] =
|
|
9
|
+
const G = 1 * 1024 * 1024, se = ({ page: n, onClose: d }) => {
|
|
10
|
+
const { t: a } = E(), [g, p] = m(!1), [x, I] = m(""), [l, N] = m(""), [v, u] = m(!1), i = Z(null), T = P(), { data: h } = z(), f = h == null ? void 0 : h.find((s) => s.key === n.pageType), C = (f == null ? void 0 : f.name) || y(n.pageType), D = q((s) => {
|
|
11
11
|
var b;
|
|
12
12
|
const o = (b = s.target.files) == null ? void 0 : b[0];
|
|
13
13
|
if (o) {
|
|
@@ -45,7 +45,7 @@ const G = 1 * 1024 * 1024, se = ({ page: n, onClose: m }) => {
|
|
|
45
45
|
},
|
|
46
46
|
{
|
|
47
47
|
onSuccess: () => {
|
|
48
|
-
p(!1),
|
|
48
|
+
p(!1), d();
|
|
49
49
|
},
|
|
50
50
|
onError: () => {
|
|
51
51
|
p(!1);
|
|
@@ -53,7 +53,7 @@ const G = 1 * 1024 * 1024, se = ({ page: n, onClose: m }) => {
|
|
|
53
53
|
}
|
|
54
54
|
);
|
|
55
55
|
};
|
|
56
|
-
return /* @__PURE__ */ e(L, { open: !0, onOpenChange:
|
|
56
|
+
return /* @__PURE__ */ e(L, { open: !0, onOpenChange: d, children: /* @__PURE__ */ t(S, { children: [
|
|
57
57
|
/* @__PURE__ */ t(U, { children: [
|
|
58
58
|
/* @__PURE__ */ e(B, { children: a("Mark as template") }),
|
|
59
59
|
/* @__PURE__ */ t(R, { className: "space-y-1 py-4 text-xs text-slate-500", children: [
|
|
@@ -139,7 +139,7 @@ const G = 1 * 1024 * 1024, se = ({ page: n, onClose: m }) => {
|
|
|
139
139
|
{
|
|
140
140
|
variant: "outline",
|
|
141
141
|
onClick: (s) => {
|
|
142
|
-
s.stopPropagation(),
|
|
142
|
+
s.stopPropagation(), d();
|
|
143
143
|
},
|
|
144
144
|
children: a("Cancel")
|
|
145
145
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),b=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),b=require("./index-BeWL6Sj6.cjs"),M=require("@chaibuilder/sdk"),a=require("@chaibuilder/sdk/ui"),y=require("lodash-es"),d=require("lucide-react"),l=require("react"),w=require("sonner"),q=1*1024*1024,A=({page:r,onClose:m})=>{const{t:s}=M.useTranslation(),[g,u]=l.useState(!1),[f,k]=l.useState(""),[c,j]=l.useState(""),[N,p]=l.useState(!1),i=l.useRef(null),T=b.useMarkAsTemplate(),{data:x}=b.usePageTypes(),h=x==null?void 0:x.find(t=>t.key===r.pageType),C=(h==null?void 0:h.name)||y.startCase(r.pageType),I=l.useCallback(t=>{var v;const o=(v=t.target.files)==null?void 0:v[0];if(o){if(o.size>q){w.toast.error(s("File too large"),{description:`${s("Maximum file size is 1MB. Selected file is")} ${(o.size/1024).toFixed(2)}KB.`}),i.current&&(i.current.value="");return}try{p(!0);const n=new FileReader;n.onloadend=()=>{j(n.result),p(!1)},n.readAsDataURL(o)}catch(n){console.error("Error reading file:",n),p(!1),w.toast.error(s("Failed to process image"),{description:n instanceof Error?n.message:s("Unknown error")})}}},[s]),D=()=>{j(""),i.current&&(i.current.value="")},F=()=>{var t;(t=i.current)==null||t.click()},S=()=>{u(!0),T.mutate({page:r,name:r.name,description:f.trim()||void 0,pageType:r.pageType,...c?{previewImage:c}:{}},{onSuccess:()=>{u(!1),m()},onError:()=>{u(!1)}})};return e.jsx(a.Dialog,{open:!0,onOpenChange:m,children:e.jsxs(a.DialogContent,{children:[e.jsxs(a.DialogHeader,{children:[e.jsx(a.DialogTitle,{children:s("Mark as template")}),e.jsxs(a.DialogDescription,{className:"space-y-1 py-4 text-xs text-slate-500",children:[s("Are you sure you want to mark this page as a template?"),e.jsx("br",{}),s("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(d.Tag,{className:"h-4 w-4 text-slate-500"}),e.jsxs("span",{className:"font-medium text-slate-500",children:[s("Page Name"),":"]}),e.jsx("span",{className:"font-semibold",children:y.startCase(r.name)})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(d.File,{className:"h-4 w-4 text-slate-500"}),e.jsxs("span",{className:"font-medium text-slate-500",children:[s("Type"),":"]}),e.jsx("span",{className:"font-semibold",children:C})]})]}),e.jsxs("div",{children:[e.jsx(a.Label,{htmlFor:"description",className:"text-xs font-medium",children:s("Description (Optional)")}),e.jsx(a.Textarea,{id:"description",placeholder:s("Describe this template's purpose"),className:"mt-1 h-24 resize-none text-xs",value:f,onChange:t=>k(t.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(a.Label,{htmlFor:"previewImage",className:"text-xs font-medium",children:s("Preview Image (Optional)")}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(a.Input,{type:"file",id:"previewImage",ref:i,onChange:I,accept:"image/*",className:"hidden"}),e.jsx(a.Button,{type:"button",variant:"outline",onClick:F,disabled:N,className:"w-full",children:N?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"}),s("Uploading...")]}):e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(d.ImageIcon,{className:"h-4 w-4"}),s("Select image")]})}),c&&e.jsx(a.Button,{type:"button",variant:"outline",size:"icon",onClick:D,children:e.jsx(d.X,{className:"h-4 w-4"})})]}),c&&e.jsx("div",{className:"aspect-video overflow-hidden rounded-md border",children:e.jsx("img",{src:c,alt:s("Preview"),className:"h-full max-h-[200px] w-full object-contain"})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("max 1mb")})]})]})]}),e.jsxs(a.DialogFooter,{className:g?"pointer-events-none opacity-75":"",children:[e.jsx(a.Button,{variant:"outline",onClick:t=>{t.stopPropagation(),m()},children:s("Cancel")}),e.jsx(a.Button,{variant:"default",disabled:g,onClick:S,children:s("Mark as template")})]})]})})};exports.default=A;
|
package/dist/{no-language-page-content-JO4YYUx7.cjs → no-language-page-content-DD9Ok2Ku.cjs}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),n=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),n=require("./index-BeWL6Sj6.cjs"),i=require("@chaibuilder/sdk"),t=require("@chaibuilder/sdk/ui"),w=require("lodash-es"),x=require("lucide-react"),P=()=>{const{t:a}=i.useTranslation(),[l,g]=n.useSearchParams(),c=l.get("lang"),u=n.useIsLanguagePageCreated(c),{setSelectedLang:d}=i.useLanguages(),h=()=>{const r=new URLSearchParams(window.location.search);r.delete("lang");const o=r.toString(),m=`${window.location.pathname}${o?`?${o}`:""}`;window.history.pushState({},"",m),g(r),d(""),window.dispatchEvent(new PopStateEvent("popstate"))};if(u)return null;const s=w.get(n.LANGUAGES,c);return e.jsx(n.BlurContainer,{children:e.jsxs(t.Card,{className:"mx-auto w-full max-w-md",children:[e.jsx(t.CardHeader,{className:"space-y-1",children:e.jsxs(t.CardTitle,{className:"flex items-center gap-2 text-2xl",children:[e.jsx(x.LockIcon,{className:"h-6 w-6 text-yellow-500"}),a("Page missing for"),' "',s,'" ',a("language"),"."]})}),e.jsx(t.CardContent,{className:"grid gap-4",children:e.jsxs("div",{children:[a("Page is not available in the"),' "',s,'" ',a("language. Either create the page in the"),' "',s,'"',a("language or switch to the base language.")]})}),e.jsx(t.CardFooter,{children:e.jsx(t.Button,{onClick:h,className:"w-full",variant:"destructive",children:a("Switch to default language")})})]})})};exports.default=P;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as e, jsxs as s } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { c as h, d as u, L as w, B as p } from "./index-DI2Rwk5v.js";
|
|
3
3
|
import { useTranslation as f, useLanguages as P } from "@chaibuilder/sdk";
|
|
4
4
|
import { Card as C, CardHeader as S, CardTitle as L, CardContent as x, CardFooter as N, Button as v } from "@chaibuilder/sdk/ui";
|
|
5
5
|
import { get as B } from "lodash-es";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),a=require("./index-BeWL6Sj6.cjs"),n=require("react"),s=n.lazy(()=>Promise.resolve().then(()=>require("./no-language-page-content-DD9Ok2Ku.cjs"))),g=()=>{const[r]=a.useSearchParams(),t=r.get("lang");return a.useIsLanguagePageCreated(t)?null:e.jsx(n.Suspense,{children:e.jsx(s,{})})};exports.default=g;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import { c as g, d as n } from "./index-DI2Rwk5v.js";
|
|
3
|
+
import { lazy as s, Suspense as t } from "react";
|
|
4
|
+
const o = s(() => import("./no-language-page-content-Dtm37LTJ.js")), l = () => {
|
|
5
|
+
const [e] = g(), r = e.get("lang");
|
|
6
|
+
return n(r) ? null : /* @__PURE__ */ a(t, { children: /* @__PURE__ */ a(o, {}) });
|
|
7
|
+
};
|
|
8
|
+
export {
|
|
9
|
+
l as default
|
|
10
|
+
};
|