@chaibuilder/pages 0.15.3 → 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 (100) hide show
  1. package/dist/{2AITGKQY-o6FgGSqg.cjs → 2AITGKQY-BnzAO102.cjs} +1 -1
  2. package/dist/{2AITGKQY-DhC0sF1x.js → 2AITGKQY-tXLat8E2.js} +2 -2
  3. package/dist/{NCMVHL6D-D7HU3akD.js → NCMVHL6D-BwDANa-N.js} +2 -2
  4. package/dist/{NCMVHL6D-BPM6RHYa.cjs → NCMVHL6D-DooF4Fqf.cjs} +1 -1
  5. package/dist/{ZDWCUMSJ-Cr1v3giV.js → ZDWCUMSJ-DWeYRRkj.js} +1 -1
  6. package/dist/{ZDWCUMSJ-NVCxv9uE.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-CF9nb6i_.cjs → dynamic-page-selector-CwhL4z6F.cjs} +1 -1
  18. package/dist/{dynamic-page-selector-DTk4oull.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-BuXZJnGo.js → index-Bk8tPO5R.js} +1605 -1571
  23. package/dist/index.cjs +1 -1
  24. package/dist/index.js +8 -8
  25. package/dist/{json-diff-viewer-zBoPBSd3.cjs → json-diff-viewer-Cfa9BjZ6.cjs} +1 -1
  26. package/dist/{json-diff-viewer-oyxMD3Hc.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-BG2hc82u.cjs → page-creator-Cd2LrG4u.cjs} +1 -1
  34. package/dist/{page-creator-y6kl3nw5.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-BaTqBnko.js → page-revisions-content-CBQPYFZI.js} +18 -18
  44. package/dist/{page-revisions-content-Tb3T6zvU.cjs → page-revisions-content-D12GEp8C.cjs} +1 -1
  45. package/dist/{publish-pages-content-C9CgEWo0.js → publish-pages-content-BF5yMo_L.js} +6 -6
  46. package/dist/{publish-pages-content-BGkEZ3GK.cjs → publish-pages-content-LNCr9tKv.cjs} +1 -1
  47. package/dist/{save-to-lib-DNK4GPNw.cjs → save-to-lib-C1B6tWEF.cjs} +1 -1
  48. package/dist/{save-to-lib-DGtyTG6H.js → save-to-lib-SpilaoOL.js} +1 -1
  49. package/dist/{seo-panel-CrK7z4bR.cjs → seo-panel-DkgkJUT6.cjs} +1 -1
  50. package/dist/{seo-panel-DESVAQM5.js → seo-panel-sbYoo746.js} +1 -1
  51. package/dist/server.cjs +1 -1
  52. package/dist/server.js +96 -96
  53. package/dist/shared-json-ld-CEUgLAev.cjs +1 -0
  54. package/dist/shared-json-ld-D_YyVPk3.js +565 -0
  55. package/dist/{slug-input-DMYhARDW.cjs → slug-input-Cqj9EBju.cjs} +1 -1
  56. package/dist/{slug-input-DfAsMPg8.js → slug-input-Df-BG6xl.js} +1 -1
  57. package/dist/theme-panel-footer-B6leVWSV.js +25 -0
  58. package/dist/theme-panel-footer-Ca1UF5DA.cjs +1 -0
  59. package/dist/unmark-as-template-BOE-nKOb.cjs +1 -0
  60. package/dist/unmark-as-template-Cho9B4RN.js +39 -0
  61. package/dist/unpublish-page-BcxxZ8pr.cjs +1 -0
  62. package/dist/unpublish-page-Dr4qbwUx.js +27 -0
  63. package/dist/{web-preview-DNgPjdgZ.js → web-preview-Cq82TNaS.js} +1 -1
  64. package/dist/{web-preview-BcULgiw_.cjs → web-preview-ued-fdxs.cjs} +1 -1
  65. package/package.json +3 -4
  66. package/dist/add-new-language-page-8q4Ku3eg.js +0 -390
  67. package/dist/add-new-language-page-D3PSLiUv.cjs +0 -1
  68. package/dist/add-new-page-BpvpSM4X.js +0 -30
  69. package/dist/add-new-page-YpzILOYq.cjs +0 -1
  70. package/dist/delete-page-CXRJjJ4o.js +0 -38
  71. package/dist/delete-page-w64MO7db.cjs +0 -1
  72. package/dist/digital-asset-manager-B2m5T22s.js +0 -1001
  73. package/dist/digital-asset-manager-BGyKKd_6.cjs +0 -1
  74. package/dist/duplicate-page-CSQs2MOp.js +0 -120
  75. package/dist/duplicate-page-DB_c7V2t.cjs +0 -1
  76. package/dist/image-editor-D9MPdtxC.js +0 -107
  77. package/dist/image-editor-Da6lrqkL.cjs +0 -1
  78. package/dist/index-Cds1vIhw.cjs +0 -5
  79. package/dist/lang-panel-B_HcsPPo.js +0 -218
  80. package/dist/lang-panel-D2YUMeJZ.cjs +0 -1
  81. package/dist/mark-as-template-C4wH4UKf.cjs +0 -1
  82. package/dist/mark-as-template-CPEPYXg7.js +0 -146
  83. package/dist/no-language-page-content-CVyOpT9h.js +0 -35
  84. package/dist/no-language-page-content-ECt0SxFX.cjs +0 -1
  85. package/dist/page-lock-request-DC62b588.js +0 -64
  86. package/dist/page-lock-request-fGZbOFTp.cjs +0 -1
  87. package/dist/page-locked-by-dialog-BIC-c0Jl.cjs +0 -1
  88. package/dist/page-locked-by-dialog-D-vXaoga.js +0 -63
  89. package/dist/page-manager-new-CUfjlMed.cjs +0 -1
  90. package/dist/page-manager-new-Cto2r7Va.js +0 -354
  91. package/dist/page-manager-search-and-filter-sVnGlF46.js +0 -197
  92. package/dist/page-manager-search-and-filter-z2b4sgvb.cjs +0 -1
  93. package/dist/shared-json-ld-BMfQzOWc.js +0 -650
  94. package/dist/shared-json-ld-_ozYsSHn.cjs +0 -1
  95. package/dist/theme-panel-footer-Bj2yHtxO.cjs +0 -1
  96. package/dist/theme-panel-footer-RrxiDGoD.js +0 -25
  97. package/dist/unmark-as-template-BjetSrYF.js +0 -38
  98. package/dist/unmark-as-template-C8hTjRVk.cjs +0 -1
  99. package/dist/unpublish-page-BTPEVAkv.js +0 -26
  100. package/dist/unpublish-page-gtGfNOAq.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-Cds1vIhw.cjs"),s=require("@chaibuilder/sdk");exports.ChaiBuilderPagesRealtime=e.ChaiBuilderPagesRealtime;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.useBuilderPageData=e.useBuilderPageData;exports.useChaiAuth=e.useChaiAuth;exports.useChaiCurrentPage=e.useCurrentPage;exports.useChaiFetch=e.useChaiFetch;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(s).forEach(a=>{a!=="default"&&!Object.prototype.hasOwnProperty.call(exports,a)&&Object.defineProperty(exports,a,{enumerable:!0,get:()=>s[a]})});
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./index-0cMGDekp.cjs"),s=require("@chaibuilder/sdk");exports.ChaiBuilderPagesRealtime=e.ChaiBuilderPagesRealtime;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.useBuilderPageData=e.useBuilderPageData;exports.useChaiAuth=e.useChaiAuth;exports.useChaiCurrentPage=e.useCurrentPage;exports.useChaiFetch=e.useChaiFetch;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(s).forEach(a=>{a!=="default"&&!Object.prototype.hasOwnProperty.call(exports,a)&&Object.defineProperty(exports,a,{enumerable:!0,get:()=>s[a]})});
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { aW as s, aL as u, aK as t, aI as i, aJ as g, ar as r, aN as P, aO as h, aF as o, aT as l, aq as n, aV as c, aj as C, aP as d, f as m, am as f, aQ as p, g as b, h as A, aR as F, aS as I, aU as L, b as S, e as U } from "./index-BuXZJnGo.js";
1
+ import { aW as s, aw as u, aK as t, aI as i, aJ as g, aq as r, aN as P, aO as h, aF as l, aT as o, ap as n, aV as c, ai as C, aP as d, f as m, al as p, aQ as f, g as b, h as A, aR as F, aS as I, aU as S, b as U, e as k } from "./index-Bk8tPO5R.js";
2
2
  export * from "@chaibuilder/sdk";
3
3
  export {
4
4
  s as ChaiBuilderPagesRealtime,
@@ -9,20 +9,20 @@ export {
9
9
  r as PermissionChecker,
10
10
  P as default,
11
11
  h as useActivePage,
12
- o as useBuilderPageData,
13
- l as useChaiAuth,
12
+ l as useBuilderPageData,
13
+ o as useChaiAuth,
14
14
  n as useChaiCurrentPage,
15
15
  c as useChaiFetch,
16
16
  C as useChaiUserInfo,
17
17
  d as useClearAll,
18
18
  m as useFallbackLang,
19
- f as useFetch,
20
- p as useGotoPage,
19
+ p as useFetch,
20
+ f as useGotoPage,
21
21
  b as useLanguagePages,
22
22
  A as usePageTypes,
23
23
  F as useReloadPage,
24
24
  I as useUpdateActivePageMetadata,
25
- L as useUserPermissions,
26
- S as useWebsitePages,
27
- U as useWebsiteSetting
25
+ S as useUserPermissions,
26
+ U as useWebsitePages,
27
+ k as useWebsiteSetting
28
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-Cds1vIhw.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(`
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-0cMGDekp.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}
@@ -5,7 +5,7 @@ import { startsWith as T, replace as W, isString as X, trim as Y, isArray as Z,
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 { al as ie, am as oe, A as ce, aj as de } from "./index-BuXZJnGo.js";
8
+ import { ak as ie, al as oe, A as ce, ai as de } from "./index-Bk8tPO5R.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:");
@@ -0,0 +1,225 @@
1
+ import { jsx as e, jsxs as s, Fragment as M } from "react/jsx-runtime";
2
+ import { an as j, h as T, L as I, ao as F, g as H, ap as O, e as W, aq as f, ar as o } from "./index-Bk8tPO5R.js";
3
+ import { useTranslation as G, useLanguages as q } from "@chaibuilder/sdk";
4
+ import { Dialog as B, 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 ae, filter as le, get as D, map as te, isEmpty as ie } from "lodash-es";
6
+ import { AlertCircle as re, StarIcon as ce, MoreHorizontal as oe, PencilIcon as de, Power as me, TrashIcon as ue } from "lucide-react";
7
+ import { useState as S, lazy as U, useMemo as he, Suspense as L } from "react";
8
+ import { toast as ge } from "sonner";
9
+ import { useAtom as pe } from "jotai";
10
+ const fe = ({
11
+ page: n,
12
+ onClose: g
13
+ }) => {
14
+ const { t } = G(), [i, v] = S(n.slug || ""), { mutate: N, isPending: y } = j(), { data: l } = T(), r = z(l, { key: n == null ? void 0 : n.pageType }), x = (m) => {
15
+ if (m.preventDefault(), !(n != null && n.primaryPage) && Object.keys(I).some((p) => i === `/${p}` || E(i, `/${p}/`))) {
16
+ ge.error(t("Error"), {
17
+ description: t("Slugs cannot start with a language code for primary page")
18
+ });
19
+ return;
20
+ }
21
+ N({ ...n, slug: i }, { onSuccess: g });
22
+ }, d = (n == null ? void 0 : n.lang) || "";
23
+ return /* @__PURE__ */ e(B, { open: !!n, onOpenChange: g, children: /* @__PURE__ */ s(R, { children: [
24
+ /* @__PURE__ */ s(J, { children: [
25
+ /* @__PURE__ */ e(K, { children: t("Change Slug") }),
26
+ /* @__PURE__ */ e(Q, { className: "text-xs", children: /* @__PURE__ */ s(V, { variant: "destructive", className: "mt-2", children: [
27
+ /* @__PURE__ */ e(re, { className: "h-4 w-4" }),
28
+ t("Changing the slug may have impact on your SEO. Please proceed with caution.")
29
+ ] }) })
30
+ ] }),
31
+ /* @__PURE__ */ s("form", { onSubmit: x, children: [
32
+ /* @__PURE__ */ s("div", { className: "space-y-4 py-4 text-sm ", children: [
33
+ /* @__PURE__ */ s("div", { className: "space-y-1", children: [
34
+ /* @__PURE__ */ s("div", { children: [
35
+ /* @__PURE__ */ s("span", { children: [
36
+ t("Type"),
37
+ ":"
38
+ ] }),
39
+ /* @__PURE__ */ s("span", { className: "font-medium text-gray-600", children: [
40
+ " ",
41
+ (r == null ? void 0 : r.name) || (n == null ? void 0 : n.pageType)
42
+ ] })
43
+ ] }),
44
+ /* @__PURE__ */ s("div", { children: [
45
+ /* @__PURE__ */ s("span", { children: [
46
+ t("Name"),
47
+ ":"
48
+ ] }),
49
+ /* @__PURE__ */ s("span", { className: "font-medium text-gray-600", children: [
50
+ " ",
51
+ n.name
52
+ ] })
53
+ ] })
54
+ ] }),
55
+ /* @__PURE__ */ s("div", { className: "space-y-1", children: [
56
+ /* @__PURE__ */ s(X, { htmlFor: "slug", className: "text-right", children: [
57
+ t("Slug"),
58
+ " ",
59
+ /* @__PURE__ */ s("small", { className: "font-light text-gray-500", children: [
60
+ t("Slug should start with"),
61
+ " /",
62
+ d
63
+ ] })
64
+ ] }),
65
+ /* @__PURE__ */ e(
66
+ Y,
67
+ {
68
+ id: "slug",
69
+ value: i,
70
+ onChange: (m) => {
71
+ const u = m.target.value;
72
+ E(u, `/${d}`) && v(u);
73
+ },
74
+ className: "col-span-3",
75
+ required: !0,
76
+ pattern: "^/.*",
77
+ title: t("Slug must start with /"),
78
+ placeholder: t("Enter page slug")
79
+ }
80
+ )
81
+ ] })
82
+ ] }),
83
+ /* @__PURE__ */ e(Z, { children: /* @__PURE__ */ e(
84
+ A,
85
+ {
86
+ type: "submit",
87
+ disabled: y || !E(i, `/${d}`) || ae(n == null ? void 0 : n.slug, i),
88
+ children: t(y ? "Changing..." : "Change Slug")
89
+ }
90
+ ) })
91
+ ] })
92
+ ] }) });
93
+ }, Ne = U(() => import("./delete-page-1dSWwUBg.js")), ye = U(() => import("./unpublish-page-Dr4qbwUx.js")), Pe = () => {
94
+ const { t: n } = G(), [, g] = pe(F), { selectedLang: t, fallbackLang: i, setSelectedLang: v } = q(), { data: N, isFetching: y } = H(), { data: l } = O(), { data: r } = T(), x = he(() => {
95
+ const a = r == null ? void 0 : r.find((h) => h.key === (l == null ? void 0 : l.pageType));
96
+ return l != null && l.dynamic ? a == null ? void 0 : a.dynamicSlug : "";
97
+ }, [r, l == null ? void 0 : l.pageType, l == null ? void 0 : l.dynamic]), [d, m] = S(null), [u, C] = S(null), [p, _] = S(null), { data: P } = W(), $ = le(
98
+ D(P, "languages") || ["en"],
99
+ (a) => !z(N, { lang: a }) && a !== D(P, "fallbackLang")
100
+ );
101
+ return /* @__PURE__ */ s("div", { className: "space-y-4", children: [
102
+ /* @__PURE__ */ e("ul", { className: "space-y-2", children: y ? /* @__PURE__ */ s("div", { className: "w-full space-y-3 py-4", children: [
103
+ /* @__PURE__ */ e("div", { className: "h-8 w-full animate-pulse rounded bg-gray-300" }),
104
+ /* @__PURE__ */ e("div", { className: "h-8 w-full animate-pulse rounded bg-gray-300" }),
105
+ /* @__PURE__ */ e("div", { className: "h-8 w-full animate-pulse rounded bg-gray-300" })
106
+ ] }) : te(N, (a) => {
107
+ const h = a.lang, b = a.slug, k = !a.primaryPage;
108
+ return /* @__PURE__ */ s(M, { children: [
109
+ /* @__PURE__ */ s(
110
+ "li",
111
+ {
112
+ className: `flex w-full cursor-pointer items-center justify-between rounded p-2 text-slate-500 ${h === t ? "bg-gray-200" : "hover:bg-gray-100"}`,
113
+ onClick: () => v(h),
114
+ children: [
115
+ /* @__PURE__ */ s("div", { className: "flex-1 gap-x-3", children: [
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 ${a.online ? "bg-green-300" : "bg-gray-300"}` }),
118
+ D(I, k ? i : h, h)
119
+ ] }),
120
+ /* @__PURE__ */ s("div", { children: [
121
+ b && /* @__PURE__ */ s("div", { className: "text-[11px] font-light text-slate-600", children: [
122
+ "Slug: ",
123
+ /* @__PURE__ */ e("b", { className: "font-mono font-medium", children: x ? `${b}/${x}` : b })
124
+ ] }),
125
+ /* @__PURE__ */ s("div", { className: "text-[11px] font-light text-slate-600", children: [
126
+ "Name:",
127
+ /* @__PURE__ */ s("b", { className: "font-medium", children: [
128
+ " ",
129
+ a.name,
130
+ " "
131
+ ] })
132
+ ] })
133
+ ] })
134
+ ] }),
135
+ k ? /* @__PURE__ */ s("div", { className: "flex items-center gap-x-1 text-[11px] text-orange-500", children: [
136
+ /* @__PURE__ */ e(ce, { fill: "orange", className: "h-3 w-3" }),
137
+ /* @__PURE__ */ e("b", { children: " Primary" })
138
+ ] }) : /* @__PURE__ */ e("div", { className: "flex items-center gap-x-3", children: /* @__PURE__ */ e(
139
+ f,
140
+ {
141
+ permissions: [
142
+ o.EDIT_PAGE,
143
+ o.DELETE_PAGE,
144
+ o.UNPUBLISH_PAGE
145
+ ],
146
+ children: /* @__PURE__ */ s(ee, { children: [
147
+ /* @__PURE__ */ e(se, { asChild: !0, onClick: (c) => c.stopPropagation(), children: /* @__PURE__ */ e(A, { variant: "ghost", size: "sm", className: "h-8 w-8 p-0", children: /* @__PURE__ */ e(oe, { className: "h-4 w-4" }) }) }),
148
+ /* @__PURE__ */ s(ne, { align: "end", className: "z-[9999] text-sm", children: [
149
+ /* @__PURE__ */ e(f, { permissions: [o.EDIT_PAGE], children: /* @__PURE__ */ s(
150
+ w,
151
+ {
152
+ className: "flex cursor-pointer items-center gap-2",
153
+ onClick: (c) => {
154
+ c.stopPropagation(), g({
155
+ edit: !0,
156
+ id: a.id,
157
+ primaryPage: a.primaryPage
158
+ });
159
+ },
160
+ children: [
161
+ /* @__PURE__ */ e(de, { className: "size-3" }),
162
+ n("Edit")
163
+ ]
164
+ }
165
+ ) }),
166
+ /* @__PURE__ */ e(f, { permissions: [o.UNPUBLISH_PAGE], children: (a == null ? void 0 : a.online) && /* @__PURE__ */ s(
167
+ w,
168
+ {
169
+ className: "flex cursor-pointer items-center gap-2",
170
+ onClick: (c) => {
171
+ c.stopPropagation(), C(a);
172
+ },
173
+ children: [
174
+ /* @__PURE__ */ e(me, { className: "size-3" }),
175
+ n("Unpublish")
176
+ ]
177
+ }
178
+ ) }),
179
+ /* @__PURE__ */ e(f, { permissions: [o.DELETE_PAGE], children: /* @__PURE__ */ s(
180
+ w,
181
+ {
182
+ className: "flex cursor-pointer items-center gap-2",
183
+ onClick: (c) => {
184
+ c.stopPropagation(), m(a);
185
+ },
186
+ children: [
187
+ /* @__PURE__ */ e(ue, { className: "size-3" }),
188
+ n("Delete")
189
+ ]
190
+ }
191
+ ) })
192
+ ] })
193
+ ] })
194
+ }
195
+ ) })
196
+ ]
197
+ },
198
+ a.id
199
+ ),
200
+ /* @__PURE__ */ e("div", { className: "h-1 w-full border-b" })
201
+ ] });
202
+ }) }),
203
+ /* @__PURE__ */ e(f, { permissions: [o.ADD_PAGE], children: /* @__PURE__ */ e("div", { className: "flex w-full justify-center", children: /* @__PURE__ */ e(
204
+ A,
205
+ {
206
+ variant: "default",
207
+ size: "sm",
208
+ disabled: ie($),
209
+ onClick: () => {
210
+ g({
211
+ primaryPage: l == null ? void 0 : l.id,
212
+ edit: !1
213
+ });
214
+ },
215
+ children: n("Add new language page")
216
+ }
217
+ ) }) }),
218
+ d && /* @__PURE__ */ e(L, { children: /* @__PURE__ */ e(Ne, { page: d, onClose: () => m(null) }) }),
219
+ u && /* @__PURE__ */ e(L, { children: /* @__PURE__ */ e(ye, { page: u, onClose: () => C(null) }) }),
220
+ p && /* @__PURE__ */ e(L, { children: /* @__PURE__ */ e(fe, { page: p, onClose: () => _(null) }) })
221
+ ] });
222
+ };
223
+ export {
224
+ Pe as default
225
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),n=require("./index-0cMGDekp.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-m-Cuz7rG.cjs"))),T=c.lazy(()=>Promise.resolve().then(()=>require("./unpublish-page-BcxxZ8pr.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=_;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),b=require("./index-0cMGDekp.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;
@@ -0,0 +1,153 @@
1
+ import { jsx as e, jsxs as t } from "react/jsx-runtime";
2
+ import { n as P, h as z } from "./index-Bk8tPO5R.js";
3
+ import { useTranslation as E } from "@chaibuilder/sdk";
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
+ import { startCase as y } from "lodash-es";
6
+ import { Tag as _, File as $, ImageIcon as H, X as K } from "lucide-react";
7
+ import { useState as d, useRef as Z, useCallback as q } from "react";
8
+ import { toast as k } from "sonner";
9
+ const G = 1 * 1024 * 1024, se = ({ page: n, onClose: m }) => {
10
+ const { t: a } = E(), [g, p] = d(!1), [x, I] = d(""), [l, N] = d(""), [v, u] = d(!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
+ var b;
12
+ const o = (b = s.target.files) == null ? void 0 : b[0];
13
+ if (o) {
14
+ if (o.size > G) {
15
+ k.error(a("File too large"), {
16
+ description: `${a("Maximum file size is 1MB. Selected file is")} ${(o.size / 1024).toFixed(2)}KB.`
17
+ }), i.current && (i.current.value = "");
18
+ return;
19
+ }
20
+ try {
21
+ u(!0);
22
+ const r = new FileReader();
23
+ r.onloadend = () => {
24
+ N(r.result), u(!1);
25
+ }, r.readAsDataURL(o);
26
+ } catch (r) {
27
+ console.error("Error reading file:", r), u(!1), k.error(a("Failed to process image"), {
28
+ description: r instanceof Error ? r.message : a("Unknown error")
29
+ });
30
+ }
31
+ }
32
+ }, [a]), F = () => {
33
+ N(""), i.current && (i.current.value = "");
34
+ }, M = () => {
35
+ var s;
36
+ (s = i.current) == null || s.click();
37
+ }, A = () => {
38
+ p(!0), T.mutate(
39
+ {
40
+ page: n,
41
+ name: n.name,
42
+ description: x.trim() || void 0,
43
+ pageType: n.pageType,
44
+ ...l ? { previewImage: l } : {}
45
+ },
46
+ {
47
+ onSuccess: () => {
48
+ p(!1), m();
49
+ },
50
+ onError: () => {
51
+ p(!1);
52
+ }
53
+ }
54
+ );
55
+ };
56
+ return /* @__PURE__ */ e(L, { open: !0, onOpenChange: m, children: /* @__PURE__ */ t(S, { children: [
57
+ /* @__PURE__ */ t(U, { children: [
58
+ /* @__PURE__ */ e(B, { children: a("Mark as template") }),
59
+ /* @__PURE__ */ t(R, { className: "space-y-1 py-4 text-xs text-slate-500", children: [
60
+ a("Are you sure you want to mark this page as a template?"),
61
+ /* @__PURE__ */ e("br", {}),
62
+ a("Templates can be used to create new pages with the same content.")
63
+ ] })
64
+ ] }),
65
+ /* @__PURE__ */ t("div", { className: "mb-4 space-y-4 text-xs", children: [
66
+ /* @__PURE__ */ t("div", { className: "space-y-3 rounded border bg-slate-50 p-4", children: [
67
+ /* @__PURE__ */ t("div", { className: "flex items-center gap-2", children: [
68
+ /* @__PURE__ */ e(_, { className: "h-4 w-4 text-slate-500" }),
69
+ /* @__PURE__ */ t("span", { className: "font-medium text-slate-500", children: [
70
+ a("Page Name"),
71
+ ":"
72
+ ] }),
73
+ /* @__PURE__ */ e("span", { className: "font-semibold", children: y(n.name) })
74
+ ] }),
75
+ /* @__PURE__ */ t("div", { className: "flex items-center gap-2", children: [
76
+ /* @__PURE__ */ e($, { className: "h-4 w-4 text-slate-500" }),
77
+ /* @__PURE__ */ t("span", { className: "font-medium text-slate-500", children: [
78
+ a("Type"),
79
+ ":"
80
+ ] }),
81
+ /* @__PURE__ */ e("span", { className: "font-semibold", children: C })
82
+ ] })
83
+ ] }),
84
+ /* @__PURE__ */ t("div", { children: [
85
+ /* @__PURE__ */ e(w, { htmlFor: "description", className: "text-xs font-medium", children: a("Description (Optional)") }),
86
+ /* @__PURE__ */ e(
87
+ j,
88
+ {
89
+ id: "description",
90
+ placeholder: a("Describe this template's purpose"),
91
+ className: "mt-1 h-24 resize-none text-xs",
92
+ value: x,
93
+ onChange: (s) => I(s.target.value)
94
+ }
95
+ )
96
+ ] }),
97
+ /* @__PURE__ */ t("div", { className: "space-y-2", children: [
98
+ /* @__PURE__ */ e(w, { htmlFor: "previewImage", className: "text-xs font-medium", children: a("Preview Image (Optional)") }),
99
+ /* @__PURE__ */ t("div", { className: "space-y-2", children: [
100
+ /* @__PURE__ */ t("div", { className: "flex items-center gap-2", children: [
101
+ /* @__PURE__ */ e(
102
+ O,
103
+ {
104
+ type: "file",
105
+ id: "previewImage",
106
+ ref: i,
107
+ onChange: D,
108
+ accept: "image/*",
109
+ className: "hidden"
110
+ }
111
+ ),
112
+ /* @__PURE__ */ e(
113
+ c,
114
+ {
115
+ type: "button",
116
+ variant: "outline",
117
+ onClick: M,
118
+ disabled: v,
119
+ className: "w-full",
120
+ children: v ? /* @__PURE__ */ t("span", { className: "flex items-center gap-2", children: [
121
+ /* @__PURE__ */ e("div", { className: "h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent" }),
122
+ a("Uploading...")
123
+ ] }) : /* @__PURE__ */ t("span", { className: "flex items-center gap-2", children: [
124
+ /* @__PURE__ */ e(H, { className: "h-4 w-4" }),
125
+ a("Select image")
126
+ ] })
127
+ }
128
+ ),
129
+ l && /* @__PURE__ */ e(c, { type: "button", variant: "outline", size: "icon", onClick: F, children: /* @__PURE__ */ e(K, { className: "h-4 w-4" }) })
130
+ ] }),
131
+ l && /* @__PURE__ */ e("div", { className: "aspect-video overflow-hidden rounded-md border", children: /* @__PURE__ */ e("img", { src: l, alt: a("Preview"), className: "h-full max-h-[200px] w-full object-contain" }) }),
132
+ /* @__PURE__ */ e("p", { className: "text-xs text-muted-foreground", children: a("max 1mb") })
133
+ ] })
134
+ ] })
135
+ ] }),
136
+ /* @__PURE__ */ t(X, { className: g ? "pointer-events-none opacity-75" : "", children: [
137
+ /* @__PURE__ */ e(
138
+ c,
139
+ {
140
+ variant: "outline",
141
+ onClick: (s) => {
142
+ s.stopPropagation(), m();
143
+ },
144
+ children: a("Cancel")
145
+ }
146
+ ),
147
+ /* @__PURE__ */ e(c, { variant: "default", disabled: g, onClick: A, children: a("Mark as template") })
148
+ ] })
149
+ ] }) });
150
+ };
151
+ export {
152
+ se as default
153
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),n=require("./index-0cMGDekp.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;
@@ -0,0 +1,42 @@
1
+ import { jsx as e, jsxs as s } from "react/jsx-runtime";
2
+ import { i as h, j as u, L as w, B as p } from "./index-Bk8tPO5R.js";
3
+ import { useTranslation as f, useLanguages as P } from "@chaibuilder/sdk";
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
+ import { get as B } from "lodash-es";
6
+ import { LockIcon as E } from "lucide-react";
7
+ const A = () => {
8
+ const { t: a } = f(), [c, l] = h(), r = c.get("lang"), i = u(r), { setSelectedLang: g } = P(), d = () => {
9
+ const n = new URLSearchParams(window.location.search);
10
+ n.delete("lang");
11
+ const o = n.toString(), m = `${window.location.pathname}${o ? `?${o}` : ""}`;
12
+ window.history.pushState({}, "", m), l(n), g(""), window.dispatchEvent(new PopStateEvent("popstate"));
13
+ };
14
+ if (i) return null;
15
+ const t = B(w, r);
16
+ return /* @__PURE__ */ e(p, { children: /* @__PURE__ */ s(C, { className: "mx-auto w-full max-w-md", children: [
17
+ /* @__PURE__ */ e(S, { className: "space-y-1", children: /* @__PURE__ */ s(L, { className: "flex items-center gap-2 text-2xl", children: [
18
+ /* @__PURE__ */ e(E, { className: "h-6 w-6 text-yellow-500" }),
19
+ a("Page missing for"),
20
+ ' "',
21
+ t,
22
+ '" ',
23
+ a("language"),
24
+ "."
25
+ ] }) }),
26
+ /* @__PURE__ */ e(x, { className: "grid gap-4", children: /* @__PURE__ */ s("div", { children: [
27
+ a("Page is not available in the"),
28
+ ' "',
29
+ t,
30
+ '" ',
31
+ a("language. Either create the page in the"),
32
+ ' "',
33
+ t,
34
+ '"',
35
+ a("language or switch to the base language.")
36
+ ] }) }),
37
+ /* @__PURE__ */ e(N, { children: /* @__PURE__ */ e(v, { onClick: d, className: "w-full", variant: "destructive", children: a("Switch to default language") }) })
38
+ ] }) });
39
+ };
40
+ export {
41
+ A as default
42
+ };