@chaibuilder/pages 0.15.21 → 0.15.24
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-JdTvsit7.js → 2AITGKQY-B6ojx8vV.js} +2 -2
- package/dist/{2AITGKQY-CuxhppUA.cjs → 2AITGKQY-wLnL_T-W.cjs} +1 -1
- package/dist/{NCMVHL6D-rzEn9a-Z.cjs → NCMVHL6D-DGH2CRR6.cjs} +1 -1
- package/dist/{NCMVHL6D-CTrkJrNW.js → NCMVHL6D-vsNnIwmV.js} +2 -2
- package/dist/{ZDWCUMSJ-DZa1ZX5H.cjs → ZDWCUMSJ-3BnFdOH2.cjs} +1 -1
- package/dist/{ZDWCUMSJ-DIAJ5hj-.js → ZDWCUMSJ-CoYx1TP5.js} +1 -1
- package/dist/{add-new-language-page-DPbVVRnt.cjs → add-new-language-page-VDZSKD95.cjs} +1 -1
- package/dist/{add-new-language-page-3fFJlIi4.js → add-new-language-page-d0-cAxlt.js} +2 -2
- package/dist/{add-new-page-C-DdGfOJ.js → add-new-page-Bcoxw6U5.js} +1 -1
- package/dist/{add-new-page-CgsPADOI.cjs → add-new-page-D4IkZL8h.cjs} +1 -1
- package/dist/ai-panel-content-Cn3SA_Sr.cjs +46 -0
- package/dist/ai-panel-content-qmOJKjkE.js +524 -0
- package/dist/{delete-page-ftu1i43t.cjs → delete-page-DeKAD4Ld.cjs} +1 -1
- package/dist/{delete-page-X6KE9Snl.js → delete-page-KS6p6b8f.js} +1 -1
- package/dist/{digital-asset-manager-zEPka3BT.cjs → digital-asset-manager-C9gYL2SF.cjs} +1 -1
- package/dist/{digital-asset-manager-CWneIIcn.js → digital-asset-manager-Dfe9SS09.js} +1 -1
- package/dist/{duplicate-page-D-2tkgsd.cjs → duplicate-page-CKr-HNs-.cjs} +1 -1
- package/dist/{duplicate-page-Bwp0RTTE.js → duplicate-page-vCgYnw4H.js} +2 -2
- package/dist/{dynamic-page-selector-Vl0aOeHK.js → dynamic-page-selector-A4fqWqZZ.js} +1 -1
- package/dist/{dynamic-page-selector-DDyEyh7e.cjs → dynamic-page-selector-C7w3TOdK.cjs} +1 -1
- package/dist/index-LfuCMBwI.cjs +5 -0
- package/dist/{index-DHfaX2M6.js → index-NSqs69Op.js} +850 -842
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/{json-diff-viewer-BCtaXLmG.js → json-diff-viewer-7TGemUrn.js} +1 -1
- package/dist/{json-diff-viewer-CM1kUeoR.cjs → json-diff-viewer-nLLX6kJK.cjs} +1 -1
- package/dist/{lang-panel-CaOkz8d3.js → lang-panel-C6KxjKn_.js} +2 -2
- package/dist/{lang-panel-DNQEDZ5D.cjs → lang-panel-dc9uBMtE.cjs} +1 -1
- package/dist/{mark-as-template-CD1bYgow.cjs → mark-as-template-CJ9SiEBl.cjs} +1 -1
- package/dist/{mark-as-template-XIeQkqPw.js → mark-as-template-CRUOQ_FZ.js} +1 -1
- package/dist/{no-language-page-content-BHacGf6H.cjs → no-language-page-content--8a37nsW.cjs} +1 -1
- package/dist/{no-language-page-content-CtN5VB9K.js → no-language-page-content-ByHFQjkV.js} +1 -1
- package/dist/{page-creator-C7j6rkr2.cjs → page-creator-CzUQicdh.cjs} +1 -1
- package/dist/{page-creator-Ci3yqsDv.js → page-creator-J_CNgdj5.js} +2 -2
- package/dist/{page-lock-request-BNS3-biN.cjs → page-lock-request-BE9-Oego.cjs} +1 -1
- package/dist/{page-lock-request-01G9AeVF.js → page-lock-request-CD93n5pq.js} +1 -1
- package/dist/{page-locked-by-dialog-Cei-v0MT.cjs → page-locked-by-dialog-1Lm9dcT6.cjs} +1 -1
- package/dist/{page-locked-by-dialog-BQV9X0UF.js → page-locked-by-dialog-noDLCQWF.js} +1 -1
- package/dist/{page-manager-new-XGKr4mup.cjs → page-manager-new-BoTBCqZF.cjs} +1 -1
- package/dist/{page-manager-new-DE_2H_ow.js → page-manager-new-D-U4B9y9.js} +2 -2
- package/dist/{page-manager-search-and-filter-BDw2AYXn.cjs → page-manager-search-and-filter-BJmETYq-.cjs} +1 -1
- package/dist/{page-manager-search-and-filter-B8zCpxug.js → page-manager-search-and-filter-h-YzJVcH.js} +1 -1
- package/dist/{page-revisions-content-BIdaOcUx.cjs → page-revisions-content-BNBb2qYh.cjs} +1 -1
- package/dist/{page-revisions-content-mih9gx3J.js → page-revisions-content-C7DXjFls.js} +2 -2
- package/dist/{publish-pages-content-jYi-Q1Vl.js → publish-pages-content-DAKh_sSW.js} +2 -2
- package/dist/{publish-pages-content-1knN5SPM.cjs → publish-pages-content-DsOVOiBD.cjs} +1 -1
- package/dist/{save-to-lib-CpFEdU_R.js → save-to-lib-BPR_--qN.js} +1 -1
- package/dist/{save-to-lib-B56XAto8.cjs → save-to-lib-BR1Qhw3Q.cjs} +1 -1
- package/dist/{seo-panel-D3bp2i90.js → seo-panel-C7XC-XRg.js} +1 -1
- package/dist/{seo-panel-DRb3uTUp.cjs → seo-panel-CUqtdGoF.cjs} +1 -1
- package/dist/{shared-json-ld-C4Kjka5m.js → shared-json-ld-0JD8sokD.js} +1 -1
- package/dist/{shared-json-ld-pNjN-zzY.cjs → shared-json-ld-CDffP4G3.cjs} +1 -1
- package/dist/{slug-input-BeepGXWz.cjs → slug-input-BYH90lv1.cjs} +1 -1
- package/dist/{slug-input-CKIckRno.js → slug-input-CvIDihGn.js} +1 -1
- package/dist/{theme-panel-footer-B0NRCfkL.cjs → theme-panel-footer-CUSfduTK.cjs} +1 -1
- package/dist/{theme-panel-footer-DscF7mar.js → theme-panel-footer-DPpLzCDu.js} +1 -1
- package/dist/{unmark-as-template-9-wHwCPl.cjs → unmark-as-template-Bxw4t_Xi.cjs} +1 -1
- package/dist/{unmark-as-template-Dezq0GEM.js → unmark-as-template-CjqRfFDL.js} +1 -1
- package/dist/{unpublish-page-DU3jKAJ5.cjs → unpublish-page-BjiB3d7l.cjs} +1 -1
- package/dist/{unpublish-page-COPOrCk_.js → unpublish-page-CKKU1St1.js} +1 -1
- package/dist/{web-preview-DBBTePPU.cjs → web-preview-CNMYCWxW.cjs} +1 -1
- package/dist/{web-preview-sSS97N-o.js → web-preview-D0OpieXz.js} +1 -1
- package/package.json +13 -12
- package/dist/index-DOlBrCPx.cjs +0 -5
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var xs = Object.defineProperty;
|
|
2
2
|
var ws = (e, t, n) => t in e ? xs(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
3
|
var _e = (e, t, n) => ws(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
|
-
import { v as Vn, w as jn, x as K, y as sr, z as H, s as y, C as W, D as oe, S as R, r as O, E as $e, F as Ce, G, H as A, I as He, J as ft, K as ve, P as Ro, M as V, N as $s, O as P, Q as wt, R as un, U as k, V as T, W as Cs, X as Kt, Y as Ss, Z as ks, _ as Cn, $ as Es, a0 as Ds, a1 as Ms, a2 as Nt, a3 as As, a4 as Ts, a5 as Fs, a6 as ar, a7 as Hr, a8 as qs, a9 as _t, aa as Ko, ab as Ur, ac as Is, ad as Os, ae as Kn, af as Ls, ag as Ps, ah as _s } from "./index-
|
|
4
|
+
import { v as Vn, w as jn, x as K, y as sr, z as H, s as y, C as W, D as oe, S as R, r as O, E as $e, F as Ce, G, H as A, I as He, J as ft, K as ve, P as Ro, M as V, N as $s, O as P, Q as wt, R as un, U as k, V as T, W as Cs, X as Kt, Y as Ss, Z as ks, _ as Cn, $ as Es, a0 as Ds, a1 as Ms, a2 as Nt, a3 as As, a4 as Ts, a5 as Fs, a6 as ar, a7 as Hr, a8 as qs, a9 as _t, aa as Ko, ab as Ur, ac as Is, ad as Os, ae as Kn, af as Ls, ag as Ps, ah as _s } from "./index-NSqs69Op.js";
|
|
5
5
|
var zs = (e) => e != null, Rs = (e) => e.filter(zs);
|
|
6
6
|
function Ks(e) {
|
|
7
7
|
return (...t) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),V=require("./slug-input-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),V=require("./slug-input-BYH90lv1.cjs"),f=require("./index-LfuCMBwI.cjs"),w=require("@chaibuilder/sdk"),S=require("@chaibuilder/sdk/ui"),Y=require("lodash-es"),is=require("lucide-react"),N=require("react"),X=({edit:c,lang:h,languages:a,name:u,setLang:t,setName:i,primaryPageObject:o})=>{const{t:s}=w.useTranslation();return e.jsxs("div",{className:"space-y-1",children:[e.jsx(S.Label,{htmlFor:"lang",children:s("Language")}),e.jsxs("select",{value:c?"":h,disabled:c||!a.length,onChange:l=>{const x=l.target.value;t(x),!c&&(Y.startsWith(u,o==null?void 0:o.name)||u.length===0)&&i(`${o==null?void 0:o.name} - ${f.LANGUAGES[x]}`)},className:"col-span-3 flex h-9 w-full rounded-md border border-border bg-background px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",children:[e.jsx("option",{value:"",disabled:!0,children:c?f.LANGUAGES[h]||h:a.length?s("Choose language"):s("All available language page is created.")}),a.map(l=>e.jsx("option",{value:l,children:f.LANGUAGES[l]||l},l))]})]})},Z=({lang:c,name:h,setName:a,parentHasSelectedLanguagePage:u})=>{const{t}=w.useTranslation();return e.jsxs("div",{className:"space-y-1",children:[e.jsx(S.Label,{htmlFor:"name",children:t("Page Name")}),e.jsx(S.Input,{id:"name",value:c?h:"",onChange:i=>a(i.target.value),required:!0,placeholder:t(c?"Enter page name":"Choose language to add slug"),disabled:!u||!c})]})},ds=({dynamic:c,isNonSlugPageType:h,isRootPage:a,lang:u,useLanguagePrefix:t,setUseLanguagePrefix:i,isHomePage:o,parentSlug:s,parentHasSelectedLanguagePage:l,slug:x,setSlug:d,setIsSlugValid:m,getSlug:g})=>{const{t:r}=w.useTranslation();return h?null:e.jsxs("div",{className:"space-y-1",children:[a&&u&&e.jsxs("div",{className:"flex items-center space-x-2 pb-1",children:[e.jsx("input",{type:"checkbox",id:"useLanguagePrefix",checked:t,onChange:A=>i(A.target.checked),className:"rounded border-gray-300"}),e.jsxs(S.Label,{htmlFor:"useLanguagePrefix",className:"text-sm font-normal leading-tight",children:["Add language code (",e.jsxs("span",{className:"font-mono text-gray-900",children:["/",u]}),") as slug prefix"]})]}),e.jsx(S.Label,{htmlFor:"slug",children:r("Slug")}),c?e.jsx(S.Alert,{variant:"default",className:"p-2 text-xs font-medium italic text-muted-foreground",children:r("This page will use dynamic slug as defined in primary page")}):e.jsx(V.SlugInput,{disabled:!u||!l,value:x,onChange:d,placeholder:r(u?o&&t?"Leave empty for home page":"Enter page slug":"Choose language to add slug"),parentSlug:s,onValidationChange:m,fullSlug:g()})]})},_=({parentHasSelectedLanguagePage:c,name:h,lang:a,slug:u,edit:t,id:i,primaryPageObject:o,pages:s,isNonSlugPageType:l,isHomePage:x,useLanguagePrefix:d,isSlugValid:m,isPending:g})=>{const{t:r}=w.useTranslation(),A=g||!h||!a||s.some(v=>(t?v.id!==i:!0)&&v.parent===(o==null?void 0:o.id)&&v.lang===a)||!l&&!(x&&d)&&(!m||!u);return e.jsx(S.DialogFooter,{children:c?e.jsxs(e.Fragment,{children:[e.jsx(S.Button,{type:"submit",disabled:A&&!o.dynamic,children:g?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"loader mr-2"}),r(t?"Updating...":"Adding...")]}):r(t?"Update":"Add new language page")}),s.some(v=>(t?v.id!==i:!0)&&v.parent===(o==null?void 0:o.id)&&v.lang===a)&&e.jsx("p",{className:"mt-2 text-xs text-red-500",children:r("A page for this language already exists.")})]}):a&&e.jsx(S.Alert,{variant:"destructive",children:e.jsxs("p",{className:"mx-auto w-5/6 text-center",children:[r("You need to create the")," ",e.jsx("span",{className:"font-medium",children:f.LANGUAGES[a]})," ",r("page in the parent to add here.")]})})})},cs=({onSubmit:c,edit:h,lang:a,languages:u,name:t,setLang:i,setName:o,primaryPageObject:s,parentHasSelectedLanguagePage:l,id:x,pages:d,isNonSlugPageType:m,isHomePage:g,useLanguagePrefix:r,slug:A,isSlugValid:v,isPending:E})=>e.jsxs("form",{onSubmit:c,children:[e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsx(X,{edit:h,lang:a,languages:u,name:t,setLang:i,setName:o,primaryPageObject:s}),e.jsx(Z,{lang:a,name:t,setName:o,parentHasSelectedLanguagePage:l})]}),e.jsx(_,{parentHasSelectedLanguagePage:l,name:t,lang:a,slug:A,edit:h,id:x,primaryPageObject:s,pages:d,isNonSlugPageType:m,isHomePage:g,useLanguagePrefix:r,isSlugValid:v,isPending:E})]}),rs=({loading:c,onSubmit:h,edit:a,lang:u,languages:t,name:i,setLang:o,setName:s,primaryPageObject:l,parentHasSelectedLanguagePage:x,isNonSlugPageType:d,isRootPage:m,useLanguagePrefix:g,setUseLanguagePrefix:r,isHomePage:A,parentSlug:v,slug:E,setSlug:C,isSlugValid:T,setIsSlugValid:R,getSlug:M,isPending:$,id:D,pages:L})=>c?e.jsx("div",{className:"flex h-80 items-center justify-center",children:e.jsx(is.Loader,{className:"animate-spin"})}):d?e.jsx(cs,{onSubmit:h,edit:a,lang:u,languages:t,name:i,setLang:o,setName:s,primaryPageObject:l,parentHasSelectedLanguagePage:x,id:D,pages:L,isNonSlugPageType:d,isHomePage:A,useLanguagePrefix:g,slug:E,isSlugValid:T,isPending:$}):e.jsxs("form",{onSubmit:h,children:[e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsx(X,{edit:a,lang:u,languages:t,name:i,setLang:o,setName:s,primaryPageObject:l}),e.jsx(Z,{lang:u,name:i,setName:s,parentHasSelectedLanguagePage:x}),e.jsx(ds,{dynamic:l==null?void 0:l.dynamic,isNonSlugPageType:d,isRootPage:m,lang:u,useLanguagePrefix:g,setUseLanguagePrefix:r,isHomePage:A,parentSlug:v,parentHasSelectedLanguagePage:x,slug:E,setSlug:C,isSlugValid:T,setIsSlugValid:R,getSlug:M})]}),e.jsx(_,{parentHasSelectedLanguagePage:x,name:i,lang:u,slug:E,edit:a,id:D,primaryPageObject:l,pages:L,isNonSlugPageType:d,isHomePage:A,useLanguagePrefix:g,isSlugValid:T,isPending:$})]}),hs=({id:c,isOpen:h,onClose:a,primaryPage:u,edit:t=!1,preselectedLang:i})=>{const{data:o=[]}=f.useWebsitePages(),s=N.useMemo(()=>o.find(n=>n.id===u),[o,u]),[l,x]=N.useState(""),[d,m]=N.useState(""),[g,r]=N.useState(""),[A,v]=N.useState(!0),[E,C]=N.useState(!0),{mutate:T,isPending:R}=f.useCreatePage(),{mutate:M,isPending:$}=f.useUpdatePage(),D=R||$,{data:L,isFetching:H}=f.useWebsiteSetting(),j=f.useFallbackLang(),{data:G,isFetching:b}=f.useLanguagePages(u),{data:F=[],isFetching:y}=f.useLanguagePages(s==null?void 0:s.parent),{data:z=[],isFetching:P}=f.usePageTypes(),{setSelectedLang:O}=w.useLanguages(),{t:I}=w.useTranslation(),[,ss]=f.useSearchParams(),[,es]=w.useSidebarActivePanel(),ns=H||b||y||P,U=N.useMemo(()=>Y.filter(L==null?void 0:L.languages,n=>!Y.find(G,{lang:n})),[L,G]),W=N.useMemo(()=>z.find(n=>n.key===(s==null?void 0:s.pageType)),[z,s==null?void 0:s.pageType]),J=!(W!=null&&W.hasSlug),B=(s==null?void 0:s.slug)==="/";N.useEffect(()=>{if(!t&&s&&i&&(m(i),x(`${s.name} - ${f.LANGUAGES[i]}`)),!t||!s)return;const n=G==null?void 0:G.find(us=>us.id===c);if(!n)return;x(n.name),m(n.lang);const p=n.slug||"",{initSlug:k,prefix:as}=V.parseSlugForEdit(p,s);r(k),C(as)},[t,c,G,s,i]),N.useEffect(()=>{if(i)m(i);else if((U==null?void 0:U.length)===1&&!t){const n=U[0];if(!n||!f.LANGUAGES[n])return;m(n),(!l||l===(s==null?void 0:s.name))&&x(`${s==null?void 0:s.name} - ${f.LANGUAGES[n]}`)}},[i,U,t,l,s]);const{parentSlug:K,isRootPage:q}=N.useMemo(()=>{if(B||!d)return{parentSlug:void 0,isRootPage:!(s!=null&&s.parent)};if(!(s!=null&&s.parent))return{parentSlug:E?`/${d}`:void 0,isRootPage:!0};const n=F==null?void 0:F.find(p=>p.lang===d);return{parentSlug:n==null?void 0:n.slug,isRootPage:!1}},[s==null?void 0:s.parent,F,E,d,B]),ts=N.useMemo(()=>q?!0:!!(F!=null&&F.some(n=>(n==null?void 0:n.lang)===d)),[d,F,q]),Q=()=>{let n="";return q?n=`/${E?[d,g].filter(Boolean).join("/"):g}`:n=`${V.removeSlugExtension(K)}/${g}`,n.replace(/\/{2,}/g,"/").replace(/\/$/,"")},os=n=>{const p=new URLSearchParams(window.location.search);j&&n===j?p.delete("lang"):p.set("lang",n),ss(p),window.dispatchEvent(new PopStateEvent("popstate"))},ls=n=>{n.preventDefault();const p={name:l,lang:d,primaryPage:s==null?void 0:s.id,slug:J?"":Q(),pageType:s==null?void 0:s.pageType,...t&&{id:c}},k=()=>{!t&&d&&(O(d),os(d)),es("outline"),a()};t?M(p,{onSuccess:k}):T(p,{onSuccess:k})};return e.jsx(S.Dialog,{open:h,onOpenChange:a,children:h&&e.jsxs(S.DialogContent,{className:"text-slate-600 sm:max-w-[425px]",children:[e.jsxs(S.DialogHeader,{children:[e.jsx(S.DialogTitle,{children:I(t?"Edit language":"Add new language page")}),e.jsx(S.DialogDescription,{className:"font-light",children:I("Enter the details for the language")})]}),e.jsx(rs,{id:c,pages:o,loading:ns,onSubmit:ls,edit:t,lang:d,languages:U,name:l,setLang:m,setName:x,primaryPageObject:s,parentHasSelectedLanguagePage:ts,isNonSlugPageType:J,isRootPage:q,useLanguagePrefix:E,setUseLanguagePrefix:C,isHomePage:B,parentSlug:K,slug:g,setSlug:r,isSlugValid:A,setIsSlugValid:v,getSlug:Q,isPending:D})]})})};exports.default=hs;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as t, jsxs as g, Fragment as hn } from "react/jsx-runtime";
|
|
2
|
-
import { p as fn, r as gn, S as mn } from "./slug-input-
|
|
3
|
-
import { b as xn, c as vn, d as Sn, e as pn, f as Nn, g as Z, h as Fn, i as wn, L as A } from "./index-
|
|
2
|
+
import { p as fn, r as gn, S as mn } from "./slug-input-CvIDihGn.js";
|
|
3
|
+
import { b as xn, c as vn, d as Sn, e as pn, f as Nn, g as Z, h as Fn, i as wn, L as A } from "./index-NSqs69Op.js";
|
|
4
4
|
import { useLanguages as An, useTranslation as T, useSidebarActivePanel as Cn } from "@chaibuilder/sdk";
|
|
5
5
|
import { Dialog as En, DialogContent as $n, DialogHeader as Dn, DialogTitle as Ln, DialogDescription as Tn, Label as I, Input as Un, Alert as H, DialogFooter as kn, Button as Rn } from "@chaibuilder/sdk/ui";
|
|
6
6
|
import { filter as Wn, find as Bn, startsWith as In } from "lodash-es";
|
|
@@ -2,7 +2,7 @@ import { jsx as e, jsxs as r } from "react/jsx-runtime";
|
|
|
2
2
|
import { useTranslation as a } from "@chaibuilder/sdk";
|
|
3
3
|
import { Dialog as c, DialogContent as m, DialogHeader as p, DialogTitle as h, DialogDescription as f } from "@chaibuilder/sdk/ui";
|
|
4
4
|
import { lazy as D, Suspense as u } from "react";
|
|
5
|
-
const x = D(() => import("./page-creator-
|
|
5
|
+
const x = D(() => import("./page-creator-J_CNgdj5.js")), C = ({
|
|
6
6
|
addEditPage: o,
|
|
7
7
|
setAddEditPage: i,
|
|
8
8
|
closePanel: t
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),a=require("@chaibuilder/sdk"),n=require("@chaibuilder/sdk/ui"),t=require("react"),u=t.lazy(()=>Promise.resolve().then(()=>require("./page-creator-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),a=require("@chaibuilder/sdk"),n=require("@chaibuilder/sdk/ui"),t=require("react"),u=t.lazy(()=>Promise.resolve().then(()=>require("./page-creator-CzUQicdh.cjs"))),x=({addEditPage:s,setAddEditPage:r,closePanel:c})=>{const{t:o}=a.useTranslation(),i=!!(s!=null&&s.id),l=!!s;return e.jsx(n.Dialog,{open:l,onOpenChange:()=>r(void 0),children:l&&e.jsxs(n.DialogContent,{className:"sm:max-w-[425px]",children:[e.jsxs(n.DialogHeader,{children:[e.jsxs(n.DialogTitle,{children:[o(i?"Edit":"Add New")," "]}),e.jsx(n.DialogDescription,{children:o(i?"Update your page name":"Enter details to create a new page")})]}),e.jsx(t.Suspense,{fallback:e.jsx("div",{className:"min-h-40"}),children:e.jsx(u,{closePanel:c,addEditPage:s,close:()=>r(void 0)})})]})})};exports.default=x;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),S=require("@chaibuilder/sdk"),ee=require("@chaibuilder/sdk/ui"),E=require("lodash-es"),b=require("lucide-react"),p=require("react"),Q=require("sonner"),te=require("./index-LfuCMBwI.cjs"),K=["Box","Button","Heading","Paragraph","Text","Span","Link","Image","Video","Icon","List","ListItem","Row","Column","Form","Input","FormButton","Checkbox","Radio","Select","TextArea","Label","RichText","Divider","EmptyBox","LineBreak","Table","EmptySlot"];function se(s){if(!s)return"";let t=s.trim();return t=t.replace(/^```html\n?/i,""),t=t.replace(/^```\n?/,""),t=t.replace(/\n?```$/,""),t=t.trim(),t}function ne(s){if(!s)return"";const t=se(s);return t.length===0||!t.includes("<")||!t.includes(">")?"":t}const V=s=>{const t=document.getElementById("canvas-iframe");if(!t)return null;const n=t==null?void 0:t.contentDocument;if(!n)return null;const l=n.querySelector(`[data-block-id="${s}"]`);if(!l)return null;if(s==="canvas"){const r=n.createElement("div");return r.style.height="100vh",l.appendChild(r),r}return l},re=(s,t)=>{var v;const n=V(s);if(!n)return{position:0,currentHTML:""};n.style.opacity="0.9";const l=((v=n==null?void 0:n.parentNode)==null?void 0:v.childNodes)||[],r=Array.from(l).indexOf(n),h=n.outerHTML,u=new DOMParser().parseFromString(h,"text/html");return u.querySelectorAll("[data-block-id]").forEach(o=>{const w=o.getAttribute("data-block-id"),c=E.find(t,{_id:w}),C=c==null?void 0:c._type;if(K.includes(C)){const m=JSON.stringify(c);if(m!=null&&m.includes("{{")&&(m!=null&&m.includes("}}"))){const j=Object.keys(c).filter(k=>{const a=c[k],g=typeof a=="string"?a:JSON.stringify(a);return g.includes("{{")&&g.includes("}}")});j.length>0&&(o.setAttribute("data-binding-key",j[0]),o.innerHTML=E.get(c,j[0],""))}o.removeAttribute("data-block-type"),o.removeAttribute("data-style-prop"),o.removeAttribute("data-block-parent"),o.removeAttribute("data-style-id"),o.removeAttribute("data-block-id"),o.removeAttribute("data-block-index"),o.removeAttribute("data-highlighted")}else o.innerHTML=C}),{position:r,currentHTML:u.body.innerHTML}};function ae({userInput:s,language:t="en",currentHtml:n}){const l=te.LANGUAGES[t]||"English";return n&&n.trim().length>0?`
|
|
2
|
+
MODE: EDIT
|
|
3
|
+
CURRENT HTML:
|
|
4
|
+
${n}
|
|
5
|
+
|
|
6
|
+
USER REQUEST: ${s}
|
|
7
|
+
|
|
8
|
+
EDIT MODE INSTRUCTIONS:
|
|
9
|
+
- Modify the existing HTML based on the user's request
|
|
10
|
+
- IMPORTANT: If asked for updating content, do not change layout just update same HTML with updated content
|
|
11
|
+
- CRITICAL: THINGS TO PREVENT
|
|
12
|
+
- Preserve ALL data binding placeholders in format '{{dataBindingId}}' - never remove or modify these dynamic content markers
|
|
13
|
+
- Preserve html tag with attributes data-block-type="PartialBlock" or data-block-type="CustomBlock" - never remove or modify these tag
|
|
14
|
+
- Preserve the overall structure unless specifically asked to change it
|
|
15
|
+
- Update content, styling, or layout as requested
|
|
16
|
+
- Maintain responsive design and accessibility
|
|
17
|
+
- Keep using shadcn/ui theme classes and Tailwind CSS
|
|
18
|
+
- Ensure all chai-name attributes remain descriptive and accurate
|
|
19
|
+
- Generate content in specified language: ${l}
|
|
20
|
+
- Apply the same design principles from the system prompt
|
|
21
|
+
- Make sure the edited HTML is clean and semantic`.trim():`
|
|
22
|
+
USER REQUEST: ${s}
|
|
23
|
+
|
|
24
|
+
CREATE MODE INSTRUCTIONS:
|
|
25
|
+
- Generate complete HTML structure based on user request
|
|
26
|
+
- Use creative, modern, and responsive design
|
|
27
|
+
- Apply Tailwind CSS v3+ classes exclusively
|
|
28
|
+
- Follow shadcn/ui design patterns and theming
|
|
29
|
+
- Include proper accessibility attributes
|
|
30
|
+
- Add chai-name attributes to all wrapper/container elements
|
|
31
|
+
- Use semantic HTML structure
|
|
32
|
+
- Generate contextually appropriate content in ${l}
|
|
33
|
+
- Make each element unique and meaningful
|
|
34
|
+
- Create realistic, professional content that fits the request
|
|
35
|
+
- Avoid generic placeholder text
|
|
36
|
+
- Use strategic image placement where appropriate
|
|
37
|
+
- Ensure mobile-first responsive design
|
|
38
|
+
- Apply proper hover and focus states
|
|
39
|
+
|
|
40
|
+
DESIGN REQUIREMENTS:
|
|
41
|
+
- Choose creative layout patterns that are visually striking
|
|
42
|
+
- Apply modern spacing and typography
|
|
43
|
+
- Use proper color contrast with shadcn/ui theme classes
|
|
44
|
+
- Make it responsive across all device sizes
|
|
45
|
+
- Include interactive elements with proper states
|
|
46
|
+
- Ensure accessibility compliance`.trim()}const oe=[{label:"Navbar",prompt:"Create stunning, fully responsive navbar with"},{label:"Hero section",prompt:"Create visually compelling hero section with"},{label:"Features grid",prompt:"Create comprehensive features section with"},{label:"Contact form",prompt:"Create professional contact form with"},{label:"Testimonials",prompt:"Create engaging testimonials section with"},{label:"Pricing table",prompt:"Create modern pricing table with"},{label:"FAQ section",prompt:"Create informative FAQ section with"},{label:"Footer",prompt:"Create comprehensive footer section with"},{label:"Call to action",prompt:"Create compelling call to action section with"},{label:"Team section",prompt:"Create professional team section with"},{label:"Blog grid",prompt:"Create attractive blog grid section with"},{label:"Stats section",prompt:"Create impactful statistics section with"}],le=[{label:"Update styles",prompt:"Update styles"},{label:"Update content",prompt:"Update text content"},{label:"Update layout",prompt:"Update layout"},{label:"Improve content",prompt:"Improve text content grammar and spelling"},{label:"Make content longer",prompt:"Make text content longer"},{label:"Make content shorter",prompt:"Make text content shorter"},{label:"Fix grammar",prompt:"Fix grammar of the text content"}],ie=({onSelect:s,currentBlock:t,selectedImage:n})=>{const[l,r]=p.useState(!1),h=t?le:oe;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{onClick:()=>r(!l),className:S.mergeClasses("flex h-6 w-full cursor-pointer items-center justify-between gap-2 px-2",t?"bg-green-50/80 text-green-500 hover:bg-green-50":"text-primary hover:bg-primary/5"),children:[e.jsx("span",{className:"truncate whitespace-nowrap text-xs font-medium leading-none",children:n?"Image actions":t?"Edit : "+(t._name||t._type):"Quick Prompts"}),e.jsx(b.ChevronsUpDown,{className:"h-3 w-3"})]}),l&&e.jsx("div",{className:"max-h-60 w-full overflow-y-auto bg-white px-1 pb-1",children:h.map((y,u)=>e.jsx("div",{className:"flex cursor-pointer items-center gap-x-1 p-1 text-xs leading-none hover:text-blue-700",onClick:()=>{s(`${n||t?"Update":"Add New"} ${y.label}`,y.prompt),r(!1)},children:e.jsxs("span",{className:"truncate whitespace-nowrap",children:[t?null:e.jsx("span",{className:"font-thin text-muted-foreground",children:"Add New"})," ",y.label]})},u))})]})},ce=({message:s})=>{var t;return((t=s==null?void 0:s.content)==null?void 0:t.length)<100?e.jsx("div",{className:"relative z-50 mb-3 flex w-full flex-col gap-2 overflow-hidden",children:e.jsxs("div",{className:"flex w-max items-center justify-center gap-1 rounded-md p-1 px-2 text-xs font-medium text-blue-500",children:[e.jsx(b.Loader,{className:"h-3 w-3 animate-spin"})," Processing"]})}):e.jsx("div",{className:"relative z-50 mb-3 flex w-full flex-col gap-2 overflow-hidden",children:e.jsxs("div",{className:"flex w-max items-center justify-center gap-1 rounded-md p-1 px-2 text-xs font-medium text-blue-500",children:[e.jsx(b.Loader,{className:"h-3 w-3 animate-spin"})," Generating"]})})},de=({message:s,isUser:t,isLoading:n})=>t?e.jsx("div",{className:"relative mb-3 flex w-full justify-end overflow-hidden",children:e.jsx("div",{className:"flex max-w-[95%] flex-row-reverse rounded-lg rounded-br-sm bg-blue-500 px-2 py-1.5 text-xs text-white",children:s.userMessage})}):n?e.jsx(ce,{message:s}):e.jsx("div",{className:`relative mb-3 flex w-full overflow-hidden ${t?"justify-end":n?"max-h-48 min-h-24 justify-start":"max-h-16"}`,children:e.jsxs("div",{className:"flex w-max items-center justify-center gap-1 rounded-md p-1 px-2 text-xs font-medium text-green-500",children:[e.jsx(b.CheckCircle,{className:"h-3 w-3"})," Completed"]})}),ue=({input:s,setInput:t,onSend:n,onStop:l,isLoading:r,disabled:h,currentBlock:y})=>{const u=p.useRef(null),v=p.useRef(null),[o,w]=p.useState(null),c=a=>{a.key==="Enter"&&!a.shiftKey&&(a.preventDefault(),s.trim()&&!r&&(n(s==null?void 0:s.trim(),void 0,o||void 0),w(null)))},C=()=>{const a=u.current;a&&(a.style.height="auto",a.style.height=Math.min(a.scrollHeight,120)+"px")},m=a=>{var N;const g=(N=a.target.files)==null?void 0:N[0];if(g&&g.type.startsWith("image/")){const A=new FileReader;A.onload=P=>{var i,x;const H=(i=P.target)==null?void 0:i.result;w(H),t("Generate UI based on given image "),(x=u.current)==null||x.focus()},A.readAsDataURL(g)}a.target.value=""},j=()=>{var a;(a=v.current)==null||a.click()},k=()=>{n(s==null?void 0:s.trim(),void 0,o||void 0),w(null)};return p.useEffect(()=>{C()},[s]),e.jsxs("div",{children:[!o&&e.jsx("div",{className:`mx-auto flex w-full max-w-[95%] flex-col items-center overflow-hidden rounded-t-md border-x border-t border-gray-200 bg-gray-100 ${r?"pointer-events-none opacity-50":""}`,children:e.jsx(ie,{currentBlock:y,selectedImage:o,onSelect:(a,g)=>{var N;t(g+" "),(N=u.current)==null||N.focus()}})}),e.jsxs("div",{className:"rounded-lg border border-gray-200 bg-white",children:[o&&e.jsxs("div",{className:"relative flex w-max items-center justify-start gap-x-2 px-2 pt-2",children:[e.jsx("img",{src:o,alt:"Selected attachment",className:"max-h-16 max-w-full rounded-md border"}),e.jsx("button",{onClick:()=>w(null),className:"absolute -right-0 -top-0 flex items-center rounded-full bg-red-400 p-1 text-xs text-white hover:bg-red-500",title:"Remove image",children:e.jsx(b.X,{className:"h-2 w-2"})})]}),e.jsx("textarea",{ref:u,value:s,onChange:a=>t(a.target.value),onKeyDown:c,placeholder:"Ask me anything...",className:`max-h-[200px] min-h-[60px] w-full resize-none rounded-lg border-none px-3 py-2 text-sm outline-none ${r?"cursor-not-allowed opacity-50":""}`,rows:3,disabled:r}),e.jsxs("div",{className:"flex items-center justify-between p-2",children:[e.jsx("button",{disabled:r,onClick:j,className:`p-1.5 text-gray-400 hover:text-gray-500 ${r?"cursor-not-allowed opacity-50":""}`,title:"Attach Image",children:e.jsx(b.Paperclip,{size:16})}),e.jsx("input",{disabled:r,ref:v,type:"file",accept:"image/*",onChange:m,className:"hidden"}),r?e.jsx("button",{onClick:l,className:"z-50 rounded-md bg-red-500 p-1.5 text-white transition-colors hover:bg-red-600",title:"Stop generation",children:e.jsx(b.Square,{size:16})}):e.jsx("button",{onClick:k,disabled:!s.trim()||h,className:`rounded-md bg-blue-500 p-1.5 text-white transition-colors hover:bg-blue-600 ${!s.trim()||h?"cursor-not-allowed opacity-50":""}`,children:e.jsx(b.Send,{size:16})})]})]})]})},me=()=>{const[s,t]=p.useState(""),[n,l]=p.useState([]),[r,h]=p.useState(!1),[y,u]=p.useState(null),v=p.useRef(null),{addPredefinedBlock:o}=S.useAddBlock(),w=S.useRemoveBlocks(),c=S.useSelectedBlock(),[C,m]=p.useState(null),[j]=S.useBlocksStore(),{selectedLang:k,fallbackLang:a}=S.useLanguages(),g=k||a,N=()=>{var i;(i=v.current)==null||i.scrollIntoView({behavior:"smooth"})};p.useEffect(()=>{N()},[n,r]);const A=()=>{y&&(y.abort(),u(null)),h(!1),t(""),m(null),l(i=>{const x=i[i.length-1];return x&&x.role==="assistant"&&!x.content.trim()?i.slice(0,-1):i}),Q.toast.info("Generation stopped")},P=async(i,x,O)=>{var z;if(!i||r)return;const d=c;m(c);const{position:J,currentHTML:_}=re((c==null?void 0:c._id)||"",j);if(c&&!_){Q.toast.error("Something went wrong. Please try again.");return}const q={id:Date.now().toString(),role:"user",content:ae({userInput:x||i,language:g,currentHtml:c?_:""}),userMessage:i},F={id:Date.now().toString(),role:"assistant",content:""};l(T=>[...T,q,F]),h(!0);const $=new AbortController;u($);try{const T={messages:[...n,q].map(f=>({role:f.role,content:f.content}))};O&&(T.image=O);const I=await fetch("/chai/api/chat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(T),signal:$.signal});if(!I.ok)throw new Error("Failed to get AI response");const R=(z=I.body)==null?void 0:z.getReader(),W=new TextDecoder;let L="";if(!R)throw new Error("Response body is not readable");const M=V(d?d==null?void 0:d._id:"canvas");for(;;){const{done:f,value:U}=await R.read();if(f){M&&!d&&M.remove();break}const D=W.decode(U,{stream:!0});L+=D,M&&(M.innerHTML=L,M.scrollIntoView({behavior:"smooth",block:"start"})),l(G=>G.map(B=>B.id===F.id?{...B,content:L}:B))}const X=ne(L),Y=S.getBlocksFromHTML(X),Z=E.map(Y,f=>{const U=E.get(f,"styles_attrs.data-block-type");if(U&&!K.includes(U)){const D=E.get(f,"styles_attrs.data-block-id");return{...E.find(j,{_id:D}),_parent:f==null?void 0:f._parent}}return f});d!=null&&d._id&&w([d==null?void 0:d._id]),o([...Z],d==null?void 0:d._parent,d?J:-1)}catch(T){if(T.name!=="AbortError"){const I={id:(Date.now()+1).toString(),role:"assistant",content:"Sorry, I encountered an error. Please try again."};l(R=>[...R,I])}}finally{t(""),h(!1),m(null),u(null)}},H=()=>{l([]),t(""),m(null),u(null),h(!1)};return e.jsxs(e.Fragment,{children:[r&&e.jsx("div",{className:"fixed inset-0 left-0 top-0 z-40 flex h-screen w-screen flex-col items-center justify-center bg-transparent"}),e.jsxs("div",{className:"flex h-full w-full flex-col bg-white",children:[e.jsxs("div",{className:"flex w-full items-center justify-between",children:[e.jsx("p",{className:"text-xs text-gray-500",children:"Your conversation will not be saved"}),(n==null?void 0:n.length)>0&&e.jsx(ee.Button,{variant:"outline",size:"icon",onClick:H,className:"h-6 w-6",children:e.jsx(b.Plus,{})})]}),e.jsxs("div",{className:"flex-1 space-y-3 overflow-y-auto py-4",children:[n.length===0&&e.jsx("div",{className:"flex-1 space-y-3 overflow-y-auto py-4",children:e.jsxs("div",{className:"mx-auto mt-8 text-center text-gray-500",children:[e.jsx(b.Bot,{size:48,className:"mx-auto mb-4 text-gray-300"}),e.jsx("p",{className:"mx-auto max-w-[75%] text-sm",children:"Start a conversation with the AI assistant to generate and update your sections"})]})}),n.map((i,x)=>i.role!=="system"&&e.jsx(de,{message:i,isUser:i.role==="user",isLoading:i.role==="assistant"&&r&&x===n.length-1},x)),e.jsx("div",{ref:v})]}),e.jsx("div",{className:"border-gray-200 pb-2",children:e.jsx(ue,{input:s,setInput:t,onSend:P,onStop:A,isLoading:r,currentBlock:c||C,disabled:(s==null?void 0:s.length)===0})})]})]})};exports.default=me;
|