@chaibuilder/sdk 1.2.22 → 1.2.23
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/AddBlocks-b0Vk6eqO.js +206 -0
- package/dist/AddBlocks-bgu08YJC.cjs +1 -0
- package/dist/BrandingOptions-AljW1cXz.cjs +1 -0
- package/dist/{BrandingOptions-4961TxX2.js → BrandingOptions-eUSoIgjj.js} +10 -9
- package/dist/CanvasArea-dp1tzDkK.cjs +55 -0
- package/dist/CanvasArea-ulUy_rmB.js +951 -0
- package/dist/{Class-MmCxz2Ay.cjs → Class-PoYusiA5.cjs} +1 -1
- package/dist/{Class-3k8xjeiM.js → Class-lGzsNBOK.js} +1 -1
- package/dist/{CurrentPage-oPZN6Gwj.js → CurrentPage-SFhXzQMy.js} +9 -10
- package/dist/CurrentPage-rWHgPomd.cjs +1 -0
- package/dist/ListTree-5n8U4-IF.cjs +1 -0
- package/dist/ListTree-ZeVWczTF.js +309 -0
- package/dist/MODIFIERS-0g14w5RS.cjs +1 -0
- package/dist/{MODIFIERS-WQdaNvb8.js → MODIFIERS-dytZ-osO.js} +4 -8
- package/dist/{PagesPanel-pRKHw-AZ.js → PagesPanel-IkZjy0Gn.js} +9 -10
- package/dist/PagesPanel-sBN51kKZ.cjs +1 -0
- package/dist/{ProjectPanel-iU6DY-Yp.js → ProjectPanel-e98TJLfI.js} +10 -11
- package/dist/ProjectPanel-lbQH31jc.cjs +1 -0
- package/dist/STRINGS--j49GZJP.js +7 -0
- package/dist/STRINGS-gPz7CUOk.cjs +1 -0
- package/dist/{Settings-BhSrj-cE.js → Settings-FZWm8Fc3.js} +862 -865
- package/dist/Settings-qytQoyTv.cjs +1 -0
- package/dist/SidePanels-YRIM1IPq.cjs +1 -0
- package/dist/{SidePanels-OLOUpKn4.js → SidePanels-wrkkpcGE.js} +119 -123
- package/dist/{Topbar-Ny9T-7Zb.js → Topbar-LUyDFBkK.js} +6 -5
- package/dist/Topbar-NOSnWo7V.cjs +1 -0
- package/dist/{UnsplashImages-Y8RGFVSh.js → UnsplashImages-eZedbK2J.js} +16 -15
- package/dist/UnsplashImages-f-ObKOC-.cjs +1 -0
- package/dist/{UploadImages-dd8LfyFr.js → UploadImages-71QziLbr.js} +11 -10
- package/dist/UploadImages-oOnccvT9.cjs +1 -0
- package/dist/add-page-modal-g3fd00P5.cjs +1 -0
- package/dist/{add-page-modal-Jni6CY1x.js → add-page-modal-yQ6qL6Ui.js} +10 -11
- package/dist/{confirm-alert-sc8RaWvD.js → confirm-alert-3flAvzWH.js} +6 -5
- package/dist/confirm-alert-LQsGNYz8.cjs +1 -0
- package/dist/core.cjs +1 -1
- package/dist/core.d.ts +1 -0
- package/dist/core.js +48 -49
- package/dist/defaultTheme-7VqqhOcp.cjs +1 -0
- package/dist/{defaultTheme-gunU_Fe5.js → defaultTheme-D8B4-wHO.js} +1 -1
- package/dist/{delete-page-modal-0WiMZFxr.js → delete-page-modal-iMmkPec0.js} +9 -10
- package/dist/delete-page-modal-tzZmqGzE.cjs +1 -0
- package/dist/email.cjs +1 -1
- package/dist/email.d.ts +1 -0
- package/dist/email.js +16 -16
- package/dist/{form-n1Q6u16z.cjs → form-LBHtTduy.cjs} +1 -1
- package/dist/{form-Nj6Kdn3g.js → form-zKUMQFuB.js} +1 -1
- package/dist/html-to-json-efmv1pCj.cjs +1 -0
- package/dist/{html-to-json-C5sExaSD.js → html-to-json-ngX9ef2u.js} +31 -29
- package/dist/{index-nwAgi0aD.cjs → index--dUsFH1I.cjs} +1 -1
- package/dist/{index-IPJAbzzO.js → index-HD1UKc4P.js} +1091 -1063
- package/dist/{index-0bwkNnA0.cjs → index-bOWwCMRF.cjs} +42 -42
- package/dist/index-fvMaxES9.cjs +1 -0
- package/dist/{index-_VPpjzJu.js → index-m4WGov7e.js} +4 -4
- package/dist/{index-UP_4awU9.js → index-uLtBNl55.js} +4479 -4484
- package/dist/lib.cjs +3 -3
- package/dist/lib.js +17 -16
- package/dist/page-viewer-5gTszT-n.cjs +1 -0
- package/dist/{page-viewer-L1Dmgj-c.js → page-viewer-7AwzWRtB.js} +14 -15
- package/dist/project-general-setting-52CTYL_w.cjs +1 -0
- package/dist/{project-general-setting-sUP7JqWK.js → project-general-setting-pYPoqvqd.js} +10 -11
- package/dist/project-seo-setting-jTweI1DX.cjs +1 -0
- package/dist/{project-seo-setting-NNvAGt4T.js → project-seo-setting-zXKOcjep.js} +7 -6
- package/dist/render.cjs +1 -1
- package/dist/render.js +14 -13
- package/dist/single-page-detail-jy2SPcp1.cjs +1 -0
- package/dist/{single-page-detail-FXg_NebW.js → single-page-detail-q2TDxN-P.js} +11 -12
- package/dist/studio.cjs +1 -1
- package/dist/studio.d.ts +1 -0
- package/dist/studio.js +8 -9
- package/dist/ui.cjs +1 -1
- package/dist/ui.js +138 -137
- package/dist/web-blocks.cjs +6 -1
- package/dist/web-blocks.js +462 -354
- package/package.json +3 -5
- package/dist/AddBlocks-157fSrJX.cjs +0 -1
- package/dist/AddBlocks-WgpssWmQ.js +0 -223
- package/dist/BrandingOptions-nwXR9TMl.cjs +0 -1
- package/dist/CanvasArea-MajWGr9z.js +0 -908
- package/dist/CanvasArea-MmTlc5Vb.cjs +0 -55
- package/dist/CurrentPage-LpLr0lDI.cjs +0 -1
- package/dist/ListTree-dvxHTXs4.js +0 -167
- package/dist/ListTree-gTmusfso.cjs +0 -1
- package/dist/MODIFIERS-9EwxLM8V.cjs +0 -1
- package/dist/Outline-2OxsXs1-.js +0 -294
- package/dist/Outline-7CCnnzmK.cjs +0 -1
- package/dist/PagesPanel-8536oBWB.cjs +0 -1
- package/dist/ProjectPanel-oILsUWOH.cjs +0 -1
- package/dist/Settings-jHiYmt0y.cjs +0 -1
- package/dist/SidePanels-bcJJocSq.cjs +0 -1
- package/dist/Topbar-NMvzqQHW.cjs +0 -1
- package/dist/TypeIcon-ElNNPazl.cjs +0 -1
- package/dist/TypeIcon-qO96rNbV.js +0 -69
- package/dist/UnsplashImages-6tZv1q2_.cjs +0 -1
- package/dist/UploadImages-VLlVg9Ur.cjs +0 -1
- package/dist/add-page-modal-IsqDdK7X.cjs +0 -1
- package/dist/confirm-alert-f26zJ7Js.cjs +0 -1
- package/dist/defaultTheme-7Lk2zq60.cjs +0 -1
- package/dist/delete-page-modal-c3b-GCap.cjs +0 -1
- package/dist/html-to-json-FGufPv9R.cjs +0 -1
- package/dist/index-9PHdn80L.cjs +0 -1
- package/dist/page-viewer-TnxHhq7S.cjs +0 -1
- package/dist/project-general-setting-1Ot1RU43.cjs +0 -1
- package/dist/project-seo-setting-3-vBkx2v.cjs +0 -1
- package/dist/single-page-detail-btEKYXjE.cjs +0 -1
- package/dist/useAddBlockByDrop-V8xo-PNQ.js +0 -20
- package/dist/useAddBlockByDrop-qRHgy8_0.cjs +0 -1
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use strict";var ne=Object.defineProperty;var oe=(e,t,s)=>t in e?ne(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var D=(e,t,s)=>(oe(e,typeof t!="symbol"?t+"":t,s),s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./jsx-runtime-Z_BpKhVy.cjs"),p=require("react"),a=require("lodash-es"),b=require("@radix-ui/react-icons"),o=require("./index-9PHdn80L.cjs"),L=require("react-i18next"),R=require("jotai"),z=require("react-dom"),v=require("prop-types"),ie=require("react-quill"),re=require("./useAddBlockByDrop-qRHgy8_0.cjs"),Z=require("flagged"),le=require("@floating-ui/dom"),W=require("@floating-ui/react-dom"),ae=require("@react-hookz/web"),ce=require("@bobthered/tailwindcss-palette-generator"),de=require("react-wrap-balancer"),ue=require("tailwind-merge"),q=require("./MODIFIERS-9EwxLM8V.cjs"),pe=require("@chaibuilder/runtime"),O=require("./index-0bwkNnA0.cjs");require("./_commonjsHelpers-wDK0ZLPo.cjs");require("./Functions-N3yhPYKY.cjs");require("clsx");require("@radix-ui/react-toggle");require("class-variance-authority");require("./Class-MmCxz2Ay.cjs");require("@radix-ui/react-switch");require("@radix-ui/react-slot");require("@radix-ui/react-accordion");require("@radix-ui/react-alert-dialog");require("@radix-ui/react-dialog");require("@radix-ui/react-label");require("@radix-ui/react-scroll-area");require("@radix-ui/react-tabs");require("@radix-ui/react-tooltip");require("@radix-ui/react-popover");require("@radix-ui/react-menubar");require("@radix-ui/react-hover-card");require("@radix-ui/react-select");require("@radix-ui/react-dropdown-menu");require("@radix-ui/react-separator");require("@radix-ui/react-toast");require("cmdk");require("@radix-ui/react-context-menu");require("react-icons-picker");require("i18next");require("react-dnd");require("@minoru/react-dnd-treeview");require("react-hotkeys-hook");const xe=()=>{const{hasUndo:e,hasRedo:t,undo:s,redo:l}=o.useUndoManager();return n.jsxRuntimeExports.jsxs("div",{className:"flex items-center",children:[n.jsxRuntimeExports.jsx(o.Button,{disabled:!e(),size:"sm",onClick:s,className:"rounded-full",variant:"ghost",children:n.jsxRuntimeExports.jsx(b.ResetIcon,{})}),n.jsxRuntimeExports.jsx(o.Button,{disabled:!t(),onClick:l,size:"sm",className:"rounded-full",variant:"ghost",children:n.jsxRuntimeExports.jsx(b.ResetIcon,{className:"rotate-180 scale-y-[-1] transform"})})]})};function me(){const[e,t]=o.useDarkMode(),{t:s}=L.useTranslation();return n.jsxRuntimeExports.jsxs("div",{className:"flex items-center",children:[n.jsxRuntimeExports.jsx(o.Label,{htmlFor:"dark-mode-switch",children:s("dark_mode")}),n.jsxRuntimeExports.jsxs(o.Switch,{id:"dark-mode-switch",checked:e,onCheckedChange:()=>{t(!e)},className:`${e?"bg-violet-600":"bg-violet-300"}
|
|
2
|
-
relative ml-2 inline-flex h-[20px] w-[40px] shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus-visible:ring-2 focus-visible:ring-white focus-visible:ring-opacity-75`,children:[n.jsxRuntimeExports.jsx("span",{className:"sr-only",children:s("use_setting")}),n.jsxRuntimeExports.jsx("span",{"aria-hidden":"true",className:`${e?"translate-x-5":"translate-x-0"}
|
|
3
|
-
pointer-events-none -mt-px inline-block h-[18px] w-[20px] transform rounded-full bg-white shadow-lg ring-0 transition duration-200 ease-in-out`})]})]})}const K=({landscape:e=!1})=>n.jsxRuntimeExports.jsxs("svg",{className:e?"rotate-90":"",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 13 13",xmlSpace:"preserve",width:13,height:13,children:[n.jsxRuntimeExports.jsx("g",{strokeWidth:0}),n.jsxRuntimeExports.jsx("g",{strokeLinecap:"round",strokeLinejoin:"round"}),n.jsxRuntimeExports.jsx("path",{d:"M10.65 0H2.349a.851.851 0 0 0-.851.852v11.299c0 .47.382.852.851.852h8.3a.851.851 0 0 0 .851-.852V.852A.851.851 0 0 0 10.65 0zM6.599 12.466a.367.367 0 1 1 0-.735.367.367 0 0 1 0 .735zm3.9-1.267H2.5V1h8.001v10.199z",style:{fill:"#000"}})]}),ge=[{title:"mobile_xs_title",content:"mobile_xs_content",breakpoint:"xs",icon:n.jsxRuntimeExports.jsx(b.MobileIcon,{}),width:400},{title:"mobile_sm_title",content:"mobile_sm_content",breakpoint:"sm",icon:n.jsxRuntimeExports.jsx(b.MobileIcon,{className:"rotate-90"}),width:640},{title:"tablet_md_title",content:"tablet_md_content",breakpoint:"md",icon:n.jsxRuntimeExports.jsx(K,{}),width:800},{title:"tablet_lg_title",content:"tablet_lg_content",breakpoint:"lg",icon:n.jsxRuntimeExports.jsx(K,{landscape:!0}),width:1024},{title:"desktop_xl_title",content:"desktop_xl_content",breakpoint:"xl",icon:n.jsxRuntimeExports.jsx(b.LaptopIcon,{}),width:1420},{title:"large_desktop_2xl_title",content:"large_desktop_2xl_content",breakpoint:"2xl",icon:n.jsxRuntimeExports.jsx(b.DesktopIcon,{}),width:1920}],Y=({title:e,content:t,currentBreakpoint:s,breakpoint:l,width:r,icon:d,onClick:u})=>{const{t:i}=L.useTranslation();return n.jsxRuntimeExports.jsxs(o.HoverCard,{children:[n.jsxRuntimeExports.jsx(o.HoverCardTrigger,{asChild:!0,children:n.jsxRuntimeExports.jsx(o.Button,{onClick:()=>u(r),size:"sm",variant:l===s?"secondary":"ghost",children:d})}),n.jsxRuntimeExports.jsx(o.HoverCardContent,{className:"w-52 border-border",children:n.jsxRuntimeExports.jsx("div",{className:"flex justify-between space-x-4",children:n.jsxRuntimeExports.jsxs("div",{className:"space-y-1",children:[n.jsxRuntimeExports.jsx("h4",{className:"text-sm font-semibold",children:i(e)}),n.jsxRuntimeExports.jsx("p",{className:"text-xs",children:i(t)})]})})})]})},he=()=>{const[,e,t]=o.useCanvasWidth(),[s,l]=o.useSelectedBreakpoints(),{t:r}=L.useTranslation(),d=o.useBuilderProp("breakpoints",ge),u=i=>{s.includes(i)?s.length>2&&l(s.filter(c=>c!==i)):l(c=>[...c,i])};return d.length<4?n.jsxRuntimeExports.jsx("div",{className:"flex items-center rounded-md",children:a.map(d,i=>p.createElement(Y,{...i,onClick:t,key:i.breakpoint,currentBreakpoint:e}))}):n.jsxRuntimeExports.jsxs("div",{className:"flex items-center rounded-md",children:[a.map(d.filter(i=>a.includes(s,a.toUpper(i.breakpoint))),i=>p.createElement(Y,{...i,onClick:t,key:i.breakpoint,currentBreakpoint:e})),n.jsxRuntimeExports.jsxs(o.DropdownMenu,{children:[n.jsxRuntimeExports.jsx(o.DropdownMenuTrigger,{asChild:!0,children:n.jsxRuntimeExports.jsx("span",{className:"cursor-pointer px-2.5 hover:opacity-80",children:n.jsxRuntimeExports.jsx(b.DotsVerticalIcon,{className:"scale-90 transform"})})}),n.jsxRuntimeExports.jsxs(o.DropdownMenuContent,{className:"w-56 border-border text-xs",children:[n.jsxRuntimeExports.jsx(o.DropdownMenuLabel,{children:r("Breakpoints")}),n.jsxRuntimeExports.jsx(o.DropdownMenuSeparator,{}),a.map(d,i=>n.jsxRuntimeExports.jsx(o.DropdownMenuCheckboxItem,{disabled:i.breakpoint==="xs",onCheckedChange:()=>u(a.toUpper(i.breakpoint)),checked:a.includes(s,a.toUpper(i.breakpoint)),children:r(i.title)},i.breakpoint))]})]})]})},fe=()=>{const{t:e}=L.useTranslation(),{setNewBlocks:t}=o.useBlocksStoreUndoableActions(),[,s]=o.useSelectedBlockIds(),[,l]=o.useSelectedStylingBlocks(),r=p.useCallback(()=>{t([]),s([]),l([])},[t]);return n.jsxRuntimeExports.jsx("div",{className:"flex items-center",children:n.jsxRuntimeExports.jsxs(o.AlertDialog,{children:[n.jsxRuntimeExports.jsx(o.AlertDialogTrigger,{asChild:!0,children:n.jsxRuntimeExports.jsxs(o.Button,{size:"sm",variant:"ghost",className:"flex items-center gap-x-1",children:[n.jsxRuntimeExports.jsx(b.EraserIcon,{})," ",e("clear")]})}),n.jsxRuntimeExports.jsxs(o.AlertDialogContent,{className:"border-border",children:[n.jsxRuntimeExports.jsxs(o.AlertDialogHeader,{children:[n.jsxRuntimeExports.jsx(o.AlertDialogTitle,{children:e("clear_canvas_title")}),n.jsxRuntimeExports.jsx(o.AlertDialogDescription,{children:e("clear_canvas_description")})]}),n.jsxRuntimeExports.jsxs(o.AlertDialogFooter,{children:[n.jsxRuntimeExports.jsx(o.AlertDialogCancel,{children:e("cancel")}),n.jsxRuntimeExports.jsx(o.AlertDialogAction,{onClick:r,children:e("yes")})]})]})]})})},je=()=>{const e=o.useBuilderProp("darkMode",!1),[t]=o.useCanvasZoom();return n.jsxRuntimeExports.jsxs("div",{className:"flex h-10 items-center justify-between border-b bg-background/70 px-2",children:[n.jsxRuntimeExports.jsxs("div",{className:"flex h-full space-x-2",children:[e?n.jsxRuntimeExports.jsxs(n.jsxRuntimeExports.Fragment,{children:[n.jsxRuntimeExports.jsx(me,{}),n.jsxRuntimeExports.jsx(o.Separator,{orientation:"vertical"})]}):null,n.jsxRuntimeExports.jsx(he,{}),n.jsxRuntimeExports.jsx(o.Separator,{orientation:"vertical"}),n.jsxRuntimeExports.jsxs("div",{className:"flex w-12 items-center justify-center gap-x-1 space-x-0 font-medium",children:[n.jsxRuntimeExports.jsx(b.ZoomInIcon,{className:"h-3.5 w-3.5 flex-shrink-0"})," ",n.jsxRuntimeExports.jsxs("div",{className:"text-xs leading-3",children:[a.round(t,0),"%"]})]}),n.jsxRuntimeExports.jsx(o.Separator,{orientation:"vertical"}),n.jsxRuntimeExports.jsx(xe,{})]}),n.jsxRuntimeExports.jsxs("div",{className:"flex h-full items-center space-x-2",children:[n.jsxRuntimeExports.jsx(o.Separator,{orientation:"vertical"}),n.jsxRuntimeExports.jsx(fe,{})]})]})},ye=`<!doctype html>
|
|
4
|
-
<html class="scroll-smooth h-full overflow-y-auto">
|
|
5
|
-
<head>
|
|
6
|
-
<meta charset="UTF-8">
|
|
7
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
8
|
-
<script src="https://cdn.tailwindcss.com?plugins=forms,typography,aspect-ratio"><\/script>
|
|
9
|
-
<style>
|
|
10
|
-
html { height: 100%; overflow:auto; }
|
|
11
|
-
body { height: 100%; }
|
|
12
|
-
.air-highlight{ outline: 1px solid #42a1fc !important; outline-offset: -1px;}
|
|
13
|
-
.air-highlight-multi{ outline: 1px solid #29e503 !important; outline-offset: -1px;}
|
|
14
|
-
body{ -webkit-touch-callout: none; -webkit-user-select: none; -khtml-user-select: none;
|
|
15
|
-
-moz-user-select: none;-ms-user-select: none; user-select: none; }
|
|
16
|
-
html{
|
|
17
|
-
-ms-overflow-style: none; /* IE and Edge */
|
|
18
|
-
scrollbar-width: none; /* Firefox */
|
|
19
|
-
}
|
|
20
|
-
/** IMPORTANT: Make fields content editable in SAFARI */
|
|
21
|
-
[contenteditable] {-webkit-user-select: text;user-select: text;}
|
|
22
|
-
|
|
23
|
-
html::-webkit-scrollbar { width: 0 !important }
|
|
24
|
-
.aspect-auto{aspect-ratio: auto;}
|
|
25
|
-
.aspect-square{aspect-ratio: 1/1;}
|
|
26
|
-
.aspect-video{aspect-ratio: 16/9;}
|
|
27
|
-
.dragging [data-dnd="leaf"] { pointer-events: none; } .dragging [data-dnd="leaf"] * { pointer-events: none; }
|
|
28
|
-
.dragging [data-dnd="ignore"], .dragging [data-dnd="ignore"] * { pointer-events: none; }
|
|
29
|
-
a{ pointer-events: none !important; }
|
|
30
|
-
[contenteditable="true"], [contenteditable="true"] * { cursor: text !important; }
|
|
31
|
-
[contenteditable="true"] {
|
|
32
|
-
outline: none;
|
|
33
|
-
box-shadow: 0 0 0px 4px rgba(36, 150, 255, 0.2);
|
|
34
|
-
-webkit-user-select: text;
|
|
35
|
-
-moz-user-select: text;
|
|
36
|
-
user-select: text;
|
|
37
|
-
}
|
|
38
|
-
.frame-root .frame-content { height: 100%; }
|
|
39
|
-
</style>
|
|
40
|
-
<style id="hidden-blocks"></style>
|
|
41
|
-
<style id="selected-block"></style>
|
|
42
|
-
<style id="selected-styling-block"></style>
|
|
43
|
-
<style id="highlighted-block"></style>
|
|
44
|
-
<style id="dragged-block"></style>
|
|
45
|
-
|
|
46
|
-
</head>
|
|
47
|
-
<body class="font-body antialiased h-full">
|
|
48
|
-
<div class="frame-root h-full"></div>
|
|
49
|
-
<script src="https://cdn.jsdelivr.net/npm/quill@2.0.0/dist/quill.js"><\/script>
|
|
50
|
-
</body>
|
|
51
|
-
</html>`,Ee=e=>{const[t]=o.useCanvasWidth(),[,s]=o.useCanvasZoom(),[l,r]=p.useState({}),d=p.useCallback(()=>{const{width:u,height:i}=e;if(u<t){const c=parseFloat((u/t).toFixed(2).toString());let x={};const m=i*c;i&&(x={height:100+(i-m)/m*100+"%"}),r({position:"relative",top:0,transform:`scale(${c})`,transformOrigin:"top left",...x,maxWidth:"none"}),s(c*100)}else r({}),s(100)},[t,e,s]);return p.useEffect(()=>{d()},[t,e,s,d]),l};let Q,G;typeof document<"u"&&(Q=document);typeof window<"u"&&(G=window);const J=p.createContext({document:Q,window:G}),F=()=>p.useContext(J),{Provider:ke,Consumer:Ve}=J;class X extends p.Component{componentDidMount(){this.props.contentDidMount()}componentDidUpdate(){this.props.contentDidUpdate()}render(){return p.Children.only(this.props.children)}}D(X,"propTypes",{children:v.element.isRequired,contentDidMount:v.func.isRequired,contentDidUpdate:v.func.isRequired});class $ extends p.Component{constructor(s,l){super(s,l);D(this,"setRef",s=>{this.nodeRef.current=s;const{forwardedRef:l}=this.props;typeof l=="function"?l(s):l&&(l.current=s)});D(this,"handleLoad",()=>{clearInterval(this.loadCheck),this.state.iframeLoaded||this.setState({iframeLoaded:!0})});D(this,"loadCheck",()=>setInterval(()=>{this.handleLoad()},500));this._isMounted=!1,this.nodeRef=p.createRef(),this.state={iframeLoaded:!1}}componentDidMount(){this._isMounted=!0,this.getDoc()&&this.nodeRef.current.contentWindow.addEventListener("DOMContentLoaded",this.handleLoad)}componentWillUnmount(){this._isMounted=!1,this.nodeRef.current.removeEventListener("DOMContentLoaded",this.handleLoad)}getDoc(){return this.nodeRef.current?this.nodeRef.current.contentDocument:null}getMountTarget(){const s=this.getDoc();return this.props.mountTarget?s.querySelector(this.props.mountTarget):s.body.children[0]}renderFrameContents(){if(!this._isMounted)return null;const s=this.getDoc();if(!s)return null;const l=this.props.contentDidMount,r=this.props.contentDidUpdate,d=s.defaultView||s.parentView,u=n.jsxRuntimeExports.jsx(X,{contentDidMount:l,contentDidUpdate:r,children:n.jsxRuntimeExports.jsx(ke,{value:{document:s,window:d},children:n.jsxRuntimeExports.jsx("div",{className:"frame-content",children:this.props.children})})}),i=this.getMountTarget();return[z.createPortal(this.props.head,this.getDoc().head),z.createPortal(u,i)]}render(){const s={...this.props,srcDoc:this.props.initialContent,children:void 0};return delete s.head,delete s.initialContent,delete s.mountTarget,delete s.contentDidMount,delete s.contentDidUpdate,delete s.forwardedRef,n.jsxRuntimeExports.jsx("iframe",{...s,ref:this.setRef,onLoad:this.handleLoad,children:this.state.iframeLoaded&&this.renderFrameContents()})}}D($,"propTypes",{style:v.object,head:v.node,initialContent:v.string,mountTarget:v.string,contentDidMount:v.func,contentDidUpdate:v.func,children:v.oneOfType([v.element,v.arrayOf(v.element)])}),D($,"defaultProps",{style:{},head:null,children:void 0,mountTarget:void 0,contentDidMount:()=>{},contentDidUpdate:()=>{},initialContent:'<!DOCTYPE html><html><head></head><body><div class="frame-root"></div></body></html>'});const ve=p.forwardRef((e,t)=>n.jsxRuntimeExports.jsx($,{...e,forwardedRef:t}));let B=null,M=[],_=null,ee=null;function be(e){const t=window.getComputedStyle(e),s=parseInt(t.paddingLeft,10),l=parseInt(t.paddingTop,10),r=parseInt(t.paddingRight,10),d=parseInt(t.paddingBottom,10);return{paddingLeft:s,paddingTop:l,paddingRight:r,paddingBottom:d}}const V=(e,t,s)=>{if(!B)return;const l=e.getBoundingClientRect(),r=B==null?void 0:B.getElementById("placeholder"),{paddingLeft:d,paddingTop:u,paddingRight:i,paddingBottom:c}=be(e);r.style.width=t==="vertical"?l.width-d-i+"px":"2px",r.style.height=t==="vertical"?"2px":l.height-u-c+"px",r.style.display="block";const x=M.reduce((m,h)=>Math.abs(h-s)<Math.abs(m-s)?h:m);ee=M.indexOf(x),t==="vertical"?(r.style.top=e.offsetTop+x+"px",r.style.left=e.offsetLeft+d+"px"):(r.style.top=e.offsetTop+u+"px",r.style.left=e.offsetLeft+x+"px")},Re=e=>{const t=te(e),s=window.getComputedStyle(e),l=t==="horizontal",r=parseInt(s.paddingLeft),d=parseInt(s.paddingTop);let u=l?r:d;M=[u],Array.from(e.children).forEach(i=>{const c=window.getComputedStyle(i),x=parseInt(l?c.marginLeft+c.marginRight:c.marginTop+c.marginBottom),m=l?i.offsetWidth:i.offsetHeight;M.push(u+m+x),u+=m+x})};function te(e){const t=window.getComputedStyle(e).display,s=window.getComputedStyle(e).flexDirection;if(t==="flex")return s==="column"||s==="column-reverse"?"vertical":"horizontal";if(t==="grid"){const l=window.getComputedStyle(e).gridTemplateRows,r=window.getComputedStyle(e).gridTemplateColumns;if(l.includes("auto"))return"vertical";if(r.includes("auto"))return"horizontal"}return t==="block"?"vertical":"horizontal"}const we=a.throttle(e=>{const t=e.target,s=te(t);if(s==="vertical"){const l=e.clientY-t.offsetTop;V(t,s,l)}else{const l=e.clientX-t.offsetLeft;V(t,s,l)}},200),Se=e=>{e.preventDefault(),e.stopPropagation(),we(e)};function P(){const e=B==null?void 0:B.getElementById("placeholder");e.style.display="none"}const Be=()=>{const{document:e}=F(),[t,s]=R.useAtom(o.draggingFlagAtom),l=re.useAddBlockByDrop(),r=Z.useFeature("dnd"),[,d]=o.useHighlightBlockId(),[,u]=o.useSelectedBlockIds();return B=e,{isDragging:t,"data-dnd":"branch",onDragOver:r?Se:a.noop,onDrop:r?i=>{_==null||_.classList.remove("outline","outline-green-300","outline-2","-outline-offset-2");const c=JSON.parse(i.dataTransfer.getData("text/plain"));let x=i.target.getAttribute("data-block-id");x===null&&(x=i.target.parentElement.getAttribute("data-block-id")),l({block:c,dropTargetId:x||null,relativeIndex:ee}),s(!1),P(),setTimeout(()=>{P()},300)}:a.noop,onDragEnter:r?i=>{const c=i;_=c.target,c.stopPropagation(),c.preventDefault(),M=[];const x=c.target;Re(x),x.classList.add("outline","outline-green-300","outline-2","-outline-offset-2"),s(!0),d(""),u([])}:a.noop,onDragLeave:r?i=>{const c=i;_=null,c.stopPropagation(),c.preventDefault(),c.target.classList.remove("outline","outline-green-300","outline-2","-outline-offset-2")}:a.noop,onMouseOut:r?()=>{s(!1),P()}:a.noop}};function U(e){return e.getAttribute("data-block-id")?e:e.closest("[data-block-id]")}function Ce(e){e.container.innerHTML="",e.container.parentNode.removeChild(e.container);var t=document.querySelector(".ql-toolbar");t&&t.parentNode.removeChild(t),e=null}const Ie=()=>{const e=["Heading","Paragraph","Text","Link","Span","Button"],t=o.useUpdateBlocksProps(),[,s]=o.useHighlightBlockId(),[l,r]=R.useAtom(o.inlineEditingActiveAtom);return d=>{var h;if(l)return;const u=U(d.target),i=u.getAttribute("data-block-type");if(!i||!e.includes(i))return;const c=u.cloneNode(!0);u.style.display="none",Array.from(c.attributes).forEach(f=>{f.name!=="class"&&c.removeAttribute(f.name)}),i==="Text"&&(c.style.display="inline-block"),u.parentNode.insertBefore(c,u.nextSibling);const x=new ie.Quill(c,{placeholder:"Type here..."});function m(){const f=x.getText(0,x.getLength());t([u.getAttribute("data-block-id")],{content:f}),u.removeAttribute("style"),c.removeEventListener("blur",m,!0),Ce(x),r(""),s("")}c.addEventListener("blur",m,!0),x.focus(),(h=c.querySelector(".ql-clipboard"))==null||h.remove(),r(u.getAttribute("data-block-id"))}},De=()=>{const[,e]=o.useSelectedStylingBlocks(),[,t]=o.useSelectedBlockIds(),[s]=R.useAtom(o.inlineEditingActiveAtom);return l=>{if(s)return;l.stopPropagation();const r=U(l.target);if(r!=null&&r.getAttribute("data-block-parent")){const d=r.getAttribute("data-style-prop"),u=r.getAttribute("data-style-id"),i=r.getAttribute("data-block-parent");e([{id:u,prop:d,blockId:i}]),t([i])}else r!=null&&r.getAttribute("data-block-id")&&t([r.getAttribute("data-block-id")])}},Ae=a.throttle((e,t)=>{const s=U(e.target);s!=null&&s.getAttribute("data-style-id")&&t(s.getAttribute("data-style-id"))},100),_e=()=>{const[,e]=o.useHighlightBlockId(),[t]=R.useAtom(o.inlineEditingActiveAtom);return s=>{t||Ae(s,e)}},Me=({children:e})=>{const{document:t}=F(),[s]=o.useSelectedBlockIds(),[l,r]=o.useSelectedStylingBlocks();p.useEffect(()=>{setTimeout(()=>{if(!a.isEmpty(l))return;const x=se(t,a.first(s));if(x){const m=x.getAttribute("data-style-prop");if(m){const h=x.getAttribute("data-style-id"),f=x.getAttribute("data-block-parent");r([{id:h,prop:m,blockId:f}])}}},100)},[t,s,r,l]);const d=Ie(),u=De(),i=_e(),c=Be();return n.jsxRuntimeExports.jsx("div",{"data-block-id":"container",id:"canvas",onClick:u,onDoubleClick:d,onMouseMove:i,...a.omit(c,"isDragging"),className:"relative mb-5 h-full max-w-full "+(c.isDragging?"dragging":""),children:e})},se=(e,t)=>e.querySelector(`[data-block-id="${t}"]`),Te=()=>{const{window:e}=F(),[t,s]=o.useSelectedBlockIds(),[l]=o.useBlocksStore(),[,r]=o.useSelectedStylingBlocks(),{undo:d,redo:u}=o.useUndoManager(),i=o.useDuplicateBlocks(),[,c]=o.usePreviewMode(),x=o.useRemoveBlocks(),{savePage:m}=o.useSavePage(),[h]=R.useAtom(o.inlineEditingActiveAtom),[,f]=R.useAtom(o.editLayerNameAtom),k=j=>{j.key==="Enter"&&(j.preventDefault(),t.length===1&&f(a.first(t)))},w=j=>{const g=l.find(E=>E._id===j);return g?g._parent:null};return p.useEffect(()=>{const j=g=>{if(g.key==="Escape"){s([]),r([]);return}if(k(g),!h&&(g.key==="Delete"||g.key==="Backspace")&&(g.preventDefault(),x(t)),g.ctrlKey||g.metaKey){if(g.key==="ArrowUp"){g.preventDefault();const E=t.length>0?w(t[0]):null;E&&s([E])}if(["z","y","d","x","c","p","s","v"].includes(g.key)){if(h&&["x","z","v"].includes(g.key))return!0;g.preventDefault()}g.key==="s"&&(g.stopPropagation(),g.preventDefault(),m()),g.key==="z"&&d(),g.key==="y"&&u(),g.key==="d"&&i(t)}};return e.removeEventListener("keydown",j),e.addEventListener("keydown",j),()=>{e.removeEventListener("keydown",j)}},[t,s,d,x,c,u,i,h,m,e]),null},Ne=({block:e,label:t})=>{const[,s]=o.useSelectedBlockIds(),[,l]=o.useHighlightBlockId(),[,r]=R.useAtom(o.draggedBlockIdAtom),d=Z.useFeature("dnd");return n.jsxRuntimeExports.jsxs("div",{className:"mr-10 flex cursor-grab items-center space-x-1 px-1",draggable:d?"true":"false",onDragStart:u=>{u.dataTransfer.setData("text/plain",JSON.stringify(a.pick(e,["_id","_type"]))),r(e._id),setTimeout(()=>{s([]),l(null)},200)},children:[n.jsxRuntimeExports.jsx(b.DragHandleDots2Icon,{}),t]})},qe=({selectedBlockElement:e,block:t})=>{const s=o.useRemoveBlocks(),l=o.useDuplicateBlocks(),[,r]=o.useSelectedBlockIds(),[,d]=o.useSelectedStylingBlocks(),[u]=R.useAtom(o.inlineEditingActiveAtom),{floatingStyles:i,refs:c,update:x}=W.useFloating({placement:"top-start",middleware:[W.shift(),le.flip()],elements:{reference:e}});ae.useResizeObserver(e,()=>x(),e!==null);const m=a.get(t,"_parent",null),h=a.isEmpty(a.get(t,"_name",""))?a.get(t,"_type",""):a.get(t,"_name","");return!e||!t||u?null:n.jsxRuntimeExports.jsxs("div",{role:"button",tabIndex:0,ref:c.setFloating,style:i,onClick:f=>{f.stopPropagation(),f.preventDefault()},onKeyDown:f=>f.stopPropagation(),className:"z-[99999] flex h-6 items-center bg-blue-500 py-2 text-xs text-white",children:[n.jsxRuntimeExports.jsx(Ne,{label:h,block:t}),n.jsxRuntimeExports.jsxs("div",{className:"flex gap-2 px-1",children:[m&&n.jsxRuntimeExports.jsx(b.ArrowUpIcon,{className:"hover:scale-105",onClick:()=>{d([]),r([m])}}),o.canDuplicateBlock(a.get(t,"_type",""))?n.jsxRuntimeExports.jsx(b.CopyIcon,{className:"hover:scale-105",onClick:()=>l([t==null?void 0:t._id])}):null,o.canDeleteBlock(a.get(t,"_type",""))?n.jsxRuntimeExports.jsx(b.TrashIcon,{className:"hover:scale-105",onClick:()=>s([t==null?void 0:t._id])}):null]})]})},Le=({model:e})=>{const[t]=o.useBrandingOptions(),[s]=o.useSelectedBlockIds(),[l]=o.useDarkMode(),[r]=o.useHighlightBlockId(),[d]=o.useSelectedStylingBlocks(),[u]=R.useAtom(o.draggedBlockIdAtom),{document:i,window:c}=F(),[x]=p.useState(i==null?void 0:i.getElementById("highlighted-block")),[m]=p.useState(i==null?void 0:i.getElementById("selected-block")),[h]=p.useState(i==null?void 0:i.getElementById("selected-styling-block")),[f]=p.useState(i==null?void 0:i.getElementById("dragged-block"));p.useEffect(()=>{l?i==null||i.documentElement.classList.add("dark"):i==null||i.documentElement.classList.remove("dark")},[l,i]);const k=a.get(t,"headingFont","DM Sans"),w=a.get(t,"bodyFont","DM Sans");return p.useEffect(()=>{const j=a.get(t,"primaryColor","#000"),g=a.get(t,"secondaryColor","#FFF"),E=ce.tailwindcssPaletteGenerator({colors:[j,g],names:["primary","secondary"]});E.primary.DEFAULT=j,E.secondary.DEFAULT=g;const A=a.get(t,"roundedCorners","0");!c||!c.tailwind||(c.tailwind.config={darkMode:"class",theme:{fontFamily:{heading:[k],body:[w]},extend:{borderRadius:{global:`${A||"0"}px`},colors:E}},plugins:[c.tailwind.plugin.withOptions(({prefix:T="ui"}={})=>({addVariant:N})=>{for(const S of["open","checked","selected","active","disabled"])N(`${T}-${S}`,[`&[data-headlessui-state~="${S}"]`,`:where([data-headlessui-state~="${S}"]) &`]),N(`${T}-not-${S}`,[`&[data-headlessui-state]:not([data-headlessui-state~="${S}"])`,`:where([data-headlessui-state]:not([data-headlessui-state~="${S}"])) &:not([data-headlessui-state])`])})]})},[t,c,k,w]),p.useEffect(()=>{m&&(m.textContent=`${a.map(s,j=>`[data-block-id="${j}"]`).join(",")}{
|
|
52
|
-
outline: 1px solid ${s.length===1?"#42a1fc":"orange"} !important; outline-offset: -1px;
|
|
53
|
-
}`)},[s,m]),p.useEffect(()=>{if(!u){f.textContent="";return}f.textContent=`[data-block-id="${u}"]{ pointer-events: none !important; opacity: 0.2 !important}`},[u]),p.useEffect(()=>{x&&(x.textContent=r?`[data-style-id="${r}"]{ outline: 1px solid #42a1fc !important; outline-offset: -1px;}`:"")},[r,s,x]),p.useEffect(()=>{h&&(h.textContent=`${a.map(d,({id:j})=>`[data-style-id="${j}"]`).join(",")}{
|
|
54
|
-
outline: 1px solid #42a1fc !important; outline-offset: -1px;
|
|
55
|
-
}`)},[d,h]),p.useEffect(()=>{const j=a.get(t,"bodyTextLightColor","#64748b"),g=a.get(t,"bodyTextDarkColor","#94a3b8"),E=a.get(t,"bodyBgLightColor","#FFFFFF"),A=a.get(t,"bodyBgDarkColor","#0f172a");i.body.className=`font-body antialiased text-[${j}] bg-[${E}] dark:text-[${g}] dark:bg-[${A}]`},[t,i,e]),e==="page"?n.jsxRuntimeExports.jsxs(n.jsxRuntimeExports.Fragment,{children:[k&&n.jsxRuntimeExports.jsx("link",{id:"heading-font",rel:"stylesheet",type:"text/css",href:`https://fonts.googleapis.com/css2?family=${k.replace(/ /g,"+")}:wght@300;400;500;600;700;800;900&display=swap`,media:"all"}),w&&k!==w&&n.jsxRuntimeExports.jsx("link",{id:"body-font",rel:"stylesheet",type:"text/css",href:`https://fonts.googleapis.com/css2?family=${w.replace(/ /g,"+")}:wght@300;400;500;600;700;800;900&display=swap`,media:"all"}),k&&n.jsxRuntimeExports.jsx("style",{children:`h1,h2,h3,h4,h5,h6{font-family: "${k}",ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";}`})]}):null},Fe=e=>{const t={};return Object.keys(e).forEach(s=>{a.isString(e[s])&&e[s].startsWith(q.SLOT_KEY)&&(t[s]=e[s].replace(q.SLOT_KEY,"").split(","))}),t},Pe=a.memoize(e=>{const t=e.replace(q.STYLES_KEY,"").split(",");return ue.twMerge(t[0],t[1])});function $e(e,t){return a.get(e,`${t}_attrs`,{})}function He(e){const t={};return Object.keys(e).forEach(s=>{if(a.isString(e[s])&&e[s].startsWith(q.STYLES_KEY)){const l=Pe(e[s]);t[s]={className:l,"data-style-prop":s,"data-block-parent":e._id,"data-style-id":`${s}-${e._id}`,...$e(e,s)}}}),t}function Oe(e,t){const s=a.get(e,"_bindings",{});return a.isEmpty(s)?{...e}:(a.each(s,(l,r)=>{a.isString(l)&&a.get(t,l,null)&&(e[r]=a.get(t,l,null))}),e)}function H({blocks:e}){const[t]=o.useBlocksStore(),s=p.useCallback(d=>He(d),[]),[l]=O.useChaiExternalData(),[r]=R.useAtom(o.inlineEditingActiveAtom);return n.jsxRuntimeExports.jsx(n.jsxRuntimeExports.Fragment,{children:p.Children.toArray(e.map((d,u)=>{if(r===d._id)return null;const i=Fe(d),c={};a.isEmpty(i)||Object.keys(i).forEach(f=>{c[f]=p.Children.toArray(i[f].map(k=>n.jsxRuntimeExports.jsx(H,{blocks:[a.find(t,{_id:k})]})))});const x=a.filter(t,{_parent:d._id});c.children=x.length?n.jsxRuntimeExports.jsx(H,{blocks:x}):null;const m=pe.getBlockComponent(d._type),h=a.get(m,"builderComponent",a.get(m,"component",null));return a.isNull(h)?n.jsxRuntimeExports.jsx("noscript",{children:`<!-- ${d==null?void 0:d._type} not registered -->`}):n.jsxRuntimeExports.jsx(p.Suspense,{children:p.createElement(h,{blockProps:{"data-block-id":d._id,"data-block-type":d._type,"data-dnd":a.has(m,"canAcceptBlock")?"branch":"leaf"},inBuilder:!0,index:u,...Oe(d,l),...s(d),...c})})}))})}const Ue=()=>{const[e]=o.useBlocksStore(),t=a.isEmpty(e)?null:n.jsxRuntimeExports.jsx(O.BlocksExternalDataProvider,{children:n.jsxRuntimeExports.jsx(H,{blocks:a.filter(e,s=>a.isEmpty(s._parent))})});return n.jsxRuntimeExports.jsx(de.Provider,{children:t})},ze=(e,t)=>e.querySelector(`[data-style-id="${t}"]`),We=()=>{const[e]=R.useAtom(o.networkModeAtom),[t]=o.usePreviewMode(),[s]=o.useCanvasWidth(),[,l]=o.useSelectedBlockIds(),r=o.useSelectedBlock(),[,d]=o.useHighlightBlockId(),u=p.useRef(null),i=p.useRef(null),[c,x]=p.useState({width:0,height:0}),m=Ee(c),[h,f]=p.useState(0),[k,w]=p.useState([]),[,j]=p.useState([]),[,g]=R.useAtom(o.canvasIframeAtom),[E,A]=o.useSelectedStylingBlocks(),T=o.useBuilderProp("loading",!1);p.useEffect(()=>{const{clientWidth:y,clientHeight:C}=i.current;x({width:y,height:C}),h===0&&f(y)},[i,s,h]);const N=(y,C=0)=>{const{top:I}=y.getBoundingClientRect();return I+C>=0&&I-C<=window.innerHeight};p.useEffect(()=>{var y,C;if(r&&r.type!=="Multiple"&&u.current){const I=se(u.current.contentDocument,r._id);I&&(N(I)||(C=(y=u.current)==null?void 0:y.contentWindow)==null||C.scrollTo({top:I.offsetTop,behavior:"smooth"}),w([I]))}},[r]),p.useEffect(()=>{if(!a.isEmpty(E)&&u.current){const y=ze(u.current.contentDocument,a.first(E).id);j(y?[y]:[null])}else j([null])},[E]);const S=p.useMemo(()=>{let y=ye;return e==="offline"&&(y=y.replace("https://old.chaibuilder.com/offline/tailwind.cdn.js","/offline/tailwind.cdn.js"),y=y.replace("https://unpkg.com/aos@next/dist/aos.css","/offline/aos.css"),y=y.replace("https://unpkg.com/aos@next/dist/aos.js","/offline/aos.js")),y},[e]);return n.jsxRuntimeExports.jsx("div",{onClick:()=>{l([]),A([])},onMouseLeave:()=>setTimeout(()=>d(""),300),className:"relative mx-auto h-full w-full overflow-hidden",style:h>0&&!a.isEmpty(m)?{width:t?"100%":h}:{},ref:i,children:n.jsxRuntimeExports.jsxs(ve,{contentDidMount:()=>g(u.current),ref:u,id:"canvas-iframe",style:{width:`${s}px`,...m},className:"relative mx-auto box-content h-full max-w-full shadow-lg transition-all duration-300 ease-linear",initialContent:S,children:[n.jsxRuntimeExports.jsx(Te,{}),n.jsxRuntimeExports.jsx(qe,{block:r,selectedBlockElement:a.first(k)}),n.jsxRuntimeExports.jsx(Le,{model:"page"}),n.jsxRuntimeExports.jsx(Me,{children:T?n.jsxRuntimeExports.jsx("div",{className:"h-full p-4",children:n.jsxRuntimeExports.jsx(o.Skeleton,{className:"h-full"})}):n.jsxRuntimeExports.jsx(Ue,{})}),n.jsxRuntimeExports.jsx("br",{}),n.jsxRuntimeExports.jsx("div",{id:"placeholder",className:"absolute z-[99999] max-w-full bg-green-500 transition-transform"})]})})},Ke=()=>n.jsxRuntimeExports.jsxs("div",{className:"flex h-full w-full flex-col",children:[n.jsxRuntimeExports.jsx(je,{}),n.jsxRuntimeExports.jsx("div",{className:"relative h-full overflow-hidden bg-slate-800/90 bg-[linear-gradient(to_right,#222_0.5px,transparent_0.5px),linear-gradient(to_bottom,#222_0.5px,transparent_0.5px)] bg-[size:12px_12px] px-2",children:n.jsxRuntimeExports.jsx(p.Suspense,{fallback:n.jsxRuntimeExports.jsx(o.Skeleton,{className:"h-full"}),children:n.jsxRuntimeExports.jsx(O.ErrorBoundary,{children:n.jsxRuntimeExports.jsx(We,{})})})})]});exports.default=Ke;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./jsx-runtime-Z_BpKhVy.cjs"),t=require("./index-9PHdn80L.cjs"),i=require("lodash-es"),h=require("sonner"),l=require("react"),o=require("./index-nwAgi0aD.cjs"),j=require("lucide-react");require("./_commonjsHelpers-wDK0ZLPo.cjs");require("./Functions-N3yhPYKY.cjs");require("clsx");require("tailwind-merge");require("@chaibuilder/runtime");require("jotai");require("./MODIFIERS-9EwxLM8V.cjs");require("@react-hookz/web");require("@radix-ui/react-toggle");require("class-variance-authority");require("./Class-MmCxz2Ay.cjs");require("@radix-ui/react-switch");require("@radix-ui/react-slot");require("@radix-ui/react-accordion");require("@radix-ui/react-icons");require("@radix-ui/react-alert-dialog");require("@radix-ui/react-dialog");require("@radix-ui/react-label");require("@radix-ui/react-scroll-area");require("@radix-ui/react-tabs");require("@radix-ui/react-tooltip");require("@radix-ui/react-popover");require("@radix-ui/react-menubar");require("@radix-ui/react-hover-card");require("@radix-ui/react-select");require("@radix-ui/react-dropdown-menu");require("@radix-ui/react-separator");require("@radix-ui/react-toast");require("cmdk");require("@radix-ui/react-context-menu");require("react-icons-picker");require("react-dom");require("react-quill");require("react-i18next");require("./index-0bwkNnA0.cjs");require("i18next");require("@floating-ui/react-dom");require("flagged");require("react-dnd");require("@minoru/react-dnd-treeview");require("react-hotkeys-hook");require("./html-to-json-FGufPv9R.cjs");require("himalaya");require("./index-ecnGWzh9.cjs");const p=()=>{const{data:s}=o.useProject(),{data:u,isLoading:x}=o.usePages(),{syncState:d}=t.useSavePage(),m=o.useChangePage(),[n,a]=o.useCurrentPage(),c=i.sortBy(i.filter(u,{type:"STATIC"}),r=>i.get(r,"uuid")===(s==null?void 0:s.homepage)?0:1);l.useEffect(()=>{!i.isEmpty(u)&&s.homepage&&!i.find(u,{uuid:n})&&a(s.homepage)},[n,u,s,a]),l.useEffect(()=>()=>a(null),[a]);const q=r=>{if(d!=="SAVED")h.toast.error("You have unsaved changes. Please save before changing the page.");else{const g=i.find(c,{uuid:r});m(g)}};return x||i.isEmpty(n)?null:e.jsxRuntimeExports.jsx("nav",{className:"flex rounded-lg border border-gray-200 bg-gray-50 px-3 pr-0 py-1 text-gray-700 dark:border-gray-700 dark:bg-gray-800","aria-label":"Breadcrumb",children:e.jsxRuntimeExports.jsxs("ol",{className:"inline-flex items-center space-x-1 md:space-x-3",children:[e.jsxRuntimeExports.jsx("li",{className:"inline-flex items-center",children:e.jsxRuntimeExports.jsxs("div",{className:"inline-flex items-center text-sm font-medium text-gray-500 dark:text-gray-400",children:[e.jsxRuntimeExports.jsx(j.BriefcaseIcon,{className:"w-4 h-4 mr-2"}),i.capitalize(s.name)]})}),e.jsxRuntimeExports.jsx("li",{"aria-current":"page",children:e.jsxRuntimeExports.jsxs("div",{className:"flex items-center",children:[e.jsxRuntimeExports.jsx("svg",{className:"mx-1 h-3 w-3 text-gray-400","aria-hidden":"true",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 6 10",children:e.jsxRuntimeExports.jsx("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"m1 9 4-4-4-4"})}),e.jsxRuntimeExports.jsxs(t.Select,{value:n||"",onValueChange:q,children:[e.jsxRuntimeExports.jsx(t.SelectTrigger,{className:"h-max border-0 py-0 text-sm font-medium text-gray-600 shadow-none outline-none ring-0 focus:ring-0 dark:text-gray-400",children:e.jsxRuntimeExports.jsx(t.SelectValue,{placeholder:"Page"})}),e.jsxRuntimeExports.jsx(t.SelectContent,{className:"z-[999]",children:i.map(c,r=>e.jsxRuntimeExports.jsx(t.SelectItem,{value:r.uuid,children:r==null?void 0:r.name},r.uuid))})]})]})})]})})};exports.default=p;
|
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
import { j as e } from "./jsx-runtime-WbnYoNE9.js";
|
|
2
|
-
import b, { memo as h, useMemo as g, useEffect as N } from "react";
|
|
3
|
-
import { useAtom as w } from "jotai";
|
|
4
|
-
import { useDebouncedCallback as D } from "@react-hookz/web";
|
|
5
|
-
import { Tree as T } from "react-arborist";
|
|
6
|
-
import { E as S, Y as k, h as B, ap as C, aq as _, ar as I, by as P, r as R, ac as A, aM as E, bf as M } from "./index-IPJAbzzO.js";
|
|
7
|
-
import { c as f } from "./Functions-7jnEwJyw.js";
|
|
8
|
-
import { TriangleRightIcon as z } from "@radix-ui/react-icons";
|
|
9
|
-
import { T as y } from "./TypeIcon-qO96rNbV.js";
|
|
10
|
-
import "./_commonjsHelpers-UyOWmZb0.js";
|
|
11
|
-
import "lodash-es";
|
|
12
|
-
import "@chaibuilder/runtime";
|
|
13
|
-
import "./MODIFIERS-WQdaNvb8.js";
|
|
14
|
-
import "@radix-ui/react-toggle";
|
|
15
|
-
import "class-variance-authority";
|
|
16
|
-
import "./Class-3k8xjeiM.js";
|
|
17
|
-
import "clsx";
|
|
18
|
-
import "tailwind-merge";
|
|
19
|
-
import "@radix-ui/react-switch";
|
|
20
|
-
import "@radix-ui/react-slot";
|
|
21
|
-
import "@radix-ui/react-accordion";
|
|
22
|
-
import "@radix-ui/react-alert-dialog";
|
|
23
|
-
import "@radix-ui/react-dialog";
|
|
24
|
-
import "@radix-ui/react-label";
|
|
25
|
-
import "@radix-ui/react-scroll-area";
|
|
26
|
-
import "@radix-ui/react-tabs";
|
|
27
|
-
import "@radix-ui/react-tooltip";
|
|
28
|
-
import "@radix-ui/react-popover";
|
|
29
|
-
import "@radix-ui/react-menubar";
|
|
30
|
-
import "@radix-ui/react-hover-card";
|
|
31
|
-
import "@radix-ui/react-select";
|
|
32
|
-
import "@radix-ui/react-dropdown-menu";
|
|
33
|
-
import "@radix-ui/react-separator";
|
|
34
|
-
import "@radix-ui/react-toast";
|
|
35
|
-
import "cmdk";
|
|
36
|
-
import "@radix-ui/react-context-menu";
|
|
37
|
-
import "react-icons-picker";
|
|
38
|
-
import "react-dom";
|
|
39
|
-
import "react-quill";
|
|
40
|
-
import "react-i18next";
|
|
41
|
-
import "lucide-react";
|
|
42
|
-
const H = {
|
|
43
|
-
display: "flex",
|
|
44
|
-
alignItems: "center",
|
|
45
|
-
zIndex: 1
|
|
46
|
-
}, O = b.memo(function({ top: n, left: t }) {
|
|
47
|
-
const l = {
|
|
48
|
-
position: "absolute",
|
|
49
|
-
pointerEvents: "none",
|
|
50
|
-
top: n + "px",
|
|
51
|
-
left: t + "px",
|
|
52
|
-
right: 0
|
|
53
|
-
};
|
|
54
|
-
return /* @__PURE__ */ e.jsx("div", { style: { ...H, ...l }, children: /* @__PURE__ */ e.jsx("div", { className: "h-0.5 flex-1 rounded-[1px] bg-green-500" }) });
|
|
55
|
-
}), $ = h(function({ children: n, isDragging: t }) {
|
|
56
|
-
return t ? /* @__PURE__ */ e.jsx("div", { className: "pointer-events-none fixed left-0 top-0 z-[100] h-full w-full", children: n }) : null;
|
|
57
|
-
}), q = h(({ id: s, isDragging: n, mouse: t }) => {
|
|
58
|
-
const [l] = S(), r = g(() => l.find((p) => p._id === s), [l, s]), a = g(
|
|
59
|
-
() => ({
|
|
60
|
-
transform: `translate(${(t == null ? void 0 : t.x) - 10}px, ${(t == null ? void 0 : t.y) - 10}px)`
|
|
61
|
-
}),
|
|
62
|
-
[t]
|
|
63
|
-
);
|
|
64
|
-
return t ? /* @__PURE__ */ e.jsx("div", { children: /* @__PURE__ */ e.jsx($, { isDragging: n, children: /* @__PURE__ */ e.jsx(
|
|
65
|
-
"div",
|
|
66
|
-
{
|
|
67
|
-
className: "pointer-events-none absolute z-50 rounded border border-gray-200 bg-gray-100/80 font-semibold text-blue-600 shadow-md dark:border-gray-700 dark:bg-gray-800",
|
|
68
|
-
style: a,
|
|
69
|
-
children: /* @__PURE__ */ e.jsxs("button", { type: "button", className: "flex !cursor-grab items-center p-0.5", "aria-label": `Type: ${r == null ? void 0 : r._type}`, children: [
|
|
70
|
-
/* @__PURE__ */ e.jsx("div", { className: "-mt-0.5 h-3 w-3", children: /* @__PURE__ */ e.jsx(y, { type: r == null ? void 0 : r._type }) }),
|
|
71
|
-
/* @__PURE__ */ e.jsx("div", { className: "ml-2 truncate text-[11px]", children: (r == null ? void 0 : r._name) || (r == null ? void 0 : r._type) })
|
|
72
|
-
] })
|
|
73
|
-
}
|
|
74
|
-
) }) }) : /* @__PURE__ */ e.jsx("div", { className: "hidden" });
|
|
75
|
-
}), L = h(({ node: s, style: n, dragHandle: t }) => {
|
|
76
|
-
const [, l] = k(), r = B("outlineMenuItems", []), a = s.children.length > 0, { id: p, isSelected: d, data: c, handleClick: x, willReceiveDrop: o, isDragging: m } = s, u = D((i) => l(i), [], 300), v = (i) => {
|
|
77
|
-
i.stopPropagation(), s.toggle();
|
|
78
|
-
}, j = (i) => {
|
|
79
|
-
i.stopPropagation(), x(i);
|
|
80
|
-
};
|
|
81
|
-
return N(() => {
|
|
82
|
-
const i = setTimeout(() => {
|
|
83
|
-
o && a && !s.isOpen && s.toggle();
|
|
84
|
-
}, 500);
|
|
85
|
-
return () => clearTimeout(i);
|
|
86
|
-
}, [o, a, s]), /* @__PURE__ */ e.jsxs(
|
|
87
|
-
"div",
|
|
88
|
-
{
|
|
89
|
-
onClick: j,
|
|
90
|
-
onMouseEnter: () => u(p),
|
|
91
|
-
style: n,
|
|
92
|
-
ref: t,
|
|
93
|
-
className: f(
|
|
94
|
-
"group flex !h-fit w-full items-center justify-between space-x-px py-px",
|
|
95
|
-
d ? "bg-blue-500 text-white" : "text-gray-600 hover:bg-gray-200 dark:hover:bg-gray-800",
|
|
96
|
-
o && a && "bg-gray-200 text-gray-600",
|
|
97
|
-
m && "opacity-20"
|
|
98
|
-
),
|
|
99
|
-
children: [
|
|
100
|
-
/* @__PURE__ */ e.jsxs("div", { className: "flex items-center", children: [
|
|
101
|
-
/* @__PURE__ */ e.jsx(
|
|
102
|
-
"div",
|
|
103
|
-
{
|
|
104
|
-
className: `flex h-4 w-4 rotate-0 transform cursor-pointer items-center justify-center text-xs transition-transform duration-100 ${s.isOpen ? "rotate-90" : ""}`,
|
|
105
|
-
children: a && /* @__PURE__ */ e.jsx("button", { onClick: v, type: "button", children: /* @__PURE__ */ e.jsx(z, {}) })
|
|
106
|
-
}
|
|
107
|
-
),
|
|
108
|
-
/* @__PURE__ */ e.jsxs("button", { type: "button", className: "flex items-center", children: [
|
|
109
|
-
/* @__PURE__ */ e.jsx("div", { className: "-mt-0.5 h-3 w-3", children: /* @__PURE__ */ e.jsx(y, { type: c == null ? void 0 : c._type }) }),
|
|
110
|
-
/* @__PURE__ */ e.jsx("div", { className: "ml-2 truncate text-[11px]", children: c == null ? void 0 : c._type })
|
|
111
|
-
] })
|
|
112
|
-
] }),
|
|
113
|
-
/* @__PURE__ */ e.jsx("div", { className: "invisible flex items-center space-x-1 pr-2 group-hover:visible", children: r.map((i) => /* @__PURE__ */ e.jsxs(C, { children: [
|
|
114
|
-
/* @__PURE__ */ e.jsx(
|
|
115
|
-
_,
|
|
116
|
-
{
|
|
117
|
-
className: "cursor-pointer rounded bg-transparent hover:bg-white hover:text-blue-500",
|
|
118
|
-
asChild: !0,
|
|
119
|
-
children: i.item(p)
|
|
120
|
-
}
|
|
121
|
-
),
|
|
122
|
-
/* @__PURE__ */ e.jsx(I, { className: "z-[9999]", children: i.tooltip })
|
|
123
|
-
] })) })
|
|
124
|
-
]
|
|
125
|
-
},
|
|
126
|
-
p
|
|
127
|
-
);
|
|
128
|
-
}), _e = () => {
|
|
129
|
-
const [s] = w(P), [n, t] = R(), [, l] = A(), { moveBlocks: r } = E(), a = () => {
|
|
130
|
-
t([]), l([]);
|
|
131
|
-
}, p = ({ id: o, name: m }) => {
|
|
132
|
-
console.log("onRename", { id: o, name: m });
|
|
133
|
-
}, d = ({ dragIds: o, parentId: m, index: u }) => {
|
|
134
|
-
r(o, m, u);
|
|
135
|
-
}, c = ({ ids: o }) => {
|
|
136
|
-
console.log("onDelete", { ids: o });
|
|
137
|
-
}, x = (o) => {
|
|
138
|
-
if (o.length === 0)
|
|
139
|
-
return;
|
|
140
|
-
const m = o[0] ? o[0].id : "";
|
|
141
|
-
l([]), t([m]);
|
|
142
|
-
};
|
|
143
|
-
return /* @__PURE__ */ e.jsx("div", { className: f("-mx-1 -mt-1 flex h-full select-none flex-col space-y-1"), onClick: () => a(), children: /* @__PURE__ */ e.jsx(M, { id: "outline-view", className: "no-scrollbar h-full overflow-y-auto p-1 px-2 text-xs", children: /* @__PURE__ */ e.jsx(
|
|
144
|
-
T,
|
|
145
|
-
{
|
|
146
|
-
className: "max-w-full !overflow-hidden",
|
|
147
|
-
selection: n[0] || "",
|
|
148
|
-
onRename: p,
|
|
149
|
-
openByDefault: !1,
|
|
150
|
-
onMove: d,
|
|
151
|
-
rowHeight: 20,
|
|
152
|
-
onDelete: c,
|
|
153
|
-
data: s,
|
|
154
|
-
renderCursor: O,
|
|
155
|
-
onSelect: x,
|
|
156
|
-
childrenAccessor: (o) => o.children,
|
|
157
|
-
width: "100%",
|
|
158
|
-
renderDragPreview: q,
|
|
159
|
-
indent: 10,
|
|
160
|
-
idAccessor: "_id",
|
|
161
|
-
children: L
|
|
162
|
-
}
|
|
163
|
-
) }) });
|
|
164
|
-
};
|
|
165
|
-
export {
|
|
166
|
-
_e as default
|
|
167
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./jsx-runtime-Z_BpKhVy.cjs"),p=require("react"),v=require("jotai"),R=require("@react-hookz/web"),b=require("react-arborist"),o=require("./index-9PHdn80L.cjs"),j=require("./Functions-N3yhPYKY.cjs"),E=require("@radix-ui/react-icons"),f=require("./TypeIcon-ElNNPazl.cjs");require("./_commonjsHelpers-wDK0ZLPo.cjs");require("lodash-es");require("@chaibuilder/runtime");require("./MODIFIERS-9EwxLM8V.cjs");require("@radix-ui/react-toggle");require("class-variance-authority");require("./Class-MmCxz2Ay.cjs");require("clsx");require("tailwind-merge");require("@radix-ui/react-switch");require("@radix-ui/react-slot");require("@radix-ui/react-accordion");require("@radix-ui/react-alert-dialog");require("@radix-ui/react-dialog");require("@radix-ui/react-label");require("@radix-ui/react-scroll-area");require("@radix-ui/react-tabs");require("@radix-ui/react-tooltip");require("@radix-ui/react-popover");require("@radix-ui/react-menubar");require("@radix-ui/react-hover-card");require("@radix-ui/react-select");require("@radix-ui/react-dropdown-menu");require("@radix-ui/react-separator");require("@radix-ui/react-toast");require("cmdk");require("@radix-ui/react-context-menu");require("react-icons-picker");require("react-dom");require("react-quill");require("react-i18next");require("lucide-react");const N={display:"flex",alignItems:"center",zIndex:1},w=p.memo(function({top:l,left:t}){const c={position:"absolute",pointerEvents:"none",top:l+"px",left:t+"px",right:0};return e.jsxRuntimeExports.jsx("div",{style:{...N,...c},children:e.jsxRuntimeExports.jsx("div",{className:"h-0.5 flex-1 rounded-[1px] bg-green-500"})})}),T=p.memo(function({children:l,isDragging:t}){return t?e.jsxRuntimeExports.jsx("div",{className:"pointer-events-none fixed left-0 top-0 z-[100] h-full w-full",children:l}):null}),S=p.memo(({id:i,isDragging:l,mouse:t})=>{const[c]=o.useBlocksStore(),r=p.useMemo(()=>c.find(a=>a._id===i),[c,i]),u=p.useMemo(()=>({transform:`translate(${(t==null?void 0:t.x)-10}px, ${(t==null?void 0:t.y)-10}px)`}),[t]);return t?e.jsxRuntimeExports.jsx("div",{children:e.jsxRuntimeExports.jsx(T,{isDragging:l,children:e.jsxRuntimeExports.jsx("div",{className:"pointer-events-none absolute z-50 rounded border border-gray-200 bg-gray-100/80 font-semibold text-blue-600 shadow-md dark:border-gray-700 dark:bg-gray-800",style:u,children:e.jsxRuntimeExports.jsxs("button",{type:"button",className:"flex !cursor-grab items-center p-0.5","aria-label":`Type: ${r==null?void 0:r._type}`,children:[e.jsxRuntimeExports.jsx("div",{className:"-mt-0.5 h-3 w-3",children:e.jsxRuntimeExports.jsx(f.TypeIcon,{type:r==null?void 0:r._type})}),e.jsxRuntimeExports.jsx("div",{className:"ml-2 truncate text-[11px]",children:(r==null?void 0:r._name)||(r==null?void 0:r._type)})]})})})}):e.jsxRuntimeExports.jsx("div",{className:"hidden"})}),D=p.memo(({node:i,style:l,dragHandle:t})=>{const[,c]=o.useHighlightBlockId(),r=o.useBuilderProp("outlineMenuItems",[]),u=i.children.length>0,{id:a,isSelected:m,data:x,handleClick:h,willReceiveDrop:s,isDragging:d}=i,g=R.useDebouncedCallback(n=>c(n),[],300),y=n=>{n.stopPropagation(),i.toggle()},q=n=>{n.stopPropagation(),h(n)};return p.useEffect(()=>{const n=setTimeout(()=>{s&&u&&!i.isOpen&&i.toggle()},500);return()=>clearTimeout(n)},[s,u,i]),e.jsxRuntimeExports.jsxs("div",{onClick:q,onMouseEnter:()=>g(a),style:l,ref:t,className:j.cn("group flex !h-fit w-full items-center justify-between space-x-px py-px",m?"bg-blue-500 text-white":"text-gray-600 hover:bg-gray-200 dark:hover:bg-gray-800",s&&u&&"bg-gray-200 text-gray-600",d&&"opacity-20"),children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center",children:[e.jsxRuntimeExports.jsx("div",{className:`flex h-4 w-4 rotate-0 transform cursor-pointer items-center justify-center text-xs transition-transform duration-100 ${i.isOpen?"rotate-90":""}`,children:u&&e.jsxRuntimeExports.jsx("button",{onClick:y,type:"button",children:e.jsxRuntimeExports.jsx(E.TriangleRightIcon,{})})}),e.jsxRuntimeExports.jsxs("button",{type:"button",className:"flex items-center",children:[e.jsxRuntimeExports.jsx("div",{className:"-mt-0.5 h-3 w-3",children:e.jsxRuntimeExports.jsx(f.TypeIcon,{type:x==null?void 0:x._type})}),e.jsxRuntimeExports.jsx("div",{className:"ml-2 truncate text-[11px]",children:x==null?void 0:x._type})]})]}),e.jsxRuntimeExports.jsx("div",{className:"invisible flex items-center space-x-1 pr-2 group-hover:visible",children:r.map(n=>e.jsxRuntimeExports.jsxs(o.Tooltip,{children:[e.jsxRuntimeExports.jsx(o.TooltipTrigger,{className:"cursor-pointer rounded bg-transparent hover:bg-white hover:text-blue-500",asChild:!0,children:n.item(a)}),e.jsxRuntimeExports.jsx(o.TooltipContent,{className:"z-[9999]",children:n.tooltip})]}))})]},a)}),I=()=>{const[i]=v.useAtom(o.treeDSBlocks),[l,t]=o.useSelectedBlockIds(),[,c]=o.useSelectedStylingBlocks(),{moveBlocks:r}=o.useBlocksStoreUndoableActions(),u=()=>{t([]),c([])},a=({id:s,name:d})=>{console.log("onRename",{id:s,name:d})},m=({dragIds:s,parentId:d,index:g})=>{r(s,d,g)},x=({ids:s})=>{console.log("onDelete",{ids:s})},h=s=>{if(s.length===0)return;const d=s[0]?s[0].id:"";c([]),t([d])};return e.jsxRuntimeExports.jsx("div",{className:j.cn("-mx-1 -mt-1 flex h-full select-none flex-col space-y-1"),onClick:()=>u(),children:e.jsxRuntimeExports.jsx(o.ScrollArea,{id:"outline-view",className:"no-scrollbar h-full overflow-y-auto p-1 px-2 text-xs",children:e.jsxRuntimeExports.jsx(b.Tree,{className:"max-w-full !overflow-hidden",selection:l[0]||"",onRename:a,openByDefault:!1,onMove:m,rowHeight:20,onDelete:x,data:i,renderCursor:w,onSelect:h,childrenAccessor:s=>s.children,width:"100%",renderDragPreview:S,indent:10,idAccessor:"_id",children:D})})})};exports.default=I;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const e="#styles:",o="#slots:",t="#i18n",i="outline",n=["hover","focus","focus-within","focus-visible","active","visited","target","first","last","only","odd","even","first-of-type","last-of-type","only-of-type","empty","disabled","checked","indeterminate","default","required","valid","invalid","in-range","out-of-range","placeholder-shown","autofill","read-only","open","before","after","first-letter","first-line","marker","selection","file","placeholder","ui-open","ui-disabled","ui-active","ui-selected","ui-checked","ui-not-open","ui-not-disabled","ui-not-active","ui-not-selected","ui-not-checked"],r={bodyFont:"Inter",headingFont:"Inter",roundedCorners:5,primaryColor:"#570df8",secondaryColor:"#f002b8",bodyBgDarkColor:"#031022",bodyBgLightColor:"#fcfcfc",bodyTextDarkColor:"#ffffff",bodyTextLightColor:"#000000"};exports.BRANDING_OPTIONS_DEFAULTS=r;exports.I18N_KEY=t;exports.MODIFIERS=n;exports.OUTLINE_KEY=i;exports.SLOT_KEY=o;exports.STYLES_KEY=e;
|
package/dist/Outline-2OxsXs1-.js
DELETED
|
@@ -1,294 +0,0 @@
|
|
|
1
|
-
import { j as e } from "./jsx-runtime-WbnYoNE9.js";
|
|
2
|
-
import { nth as w, startsWith as E, map as B, isUndefined as _, find as M, isEmpty as R, includes as A } from "lodash-es";
|
|
3
|
-
import { TriangleRightIcon as P, TrashIcon as H, CopyIcon as L, DoubleArrowDownIcon as $, StackIcon as F } from "@radix-ui/react-icons";
|
|
4
|
-
import { useDrop as K, useDragLayer as U } from "react-dnd";
|
|
5
|
-
import { useDragOver as Y, Tree as q } from "@minoru/react-dnd-treeview";
|
|
6
|
-
import { useTranslation as Q } from "react-i18next";
|
|
7
|
-
import { Y as V, X as W, h as X, ap as z, aq as G, ar as J, r as y, s as Z, a1 as I, bs as C, aS as ee, t as te, bt as se, aR as oe, bu as ne, bv as re, E as ie, aM as le, ac as ae, bw as ce, bf as de, bx as me } from "./index-IPJAbzzO.js";
|
|
8
|
-
import { T as N } from "./TypeIcon-qO96rNbV.js";
|
|
9
|
-
import { useMemo as pe, useCallback as xe } from "react";
|
|
10
|
-
import { a as ue } from "./MODIFIERS-WQdaNvb8.js";
|
|
11
|
-
import { c as D } from "./Functions-7jnEwJyw.js";
|
|
12
|
-
import { a as ge, d as he } from "./index-UP_4awU9.js";
|
|
13
|
-
import { u as fe } from "./useAddBlockByDrop-V8xo-PNQ.js";
|
|
14
|
-
import "./_commonjsHelpers-UyOWmZb0.js";
|
|
15
|
-
import "@chaibuilder/runtime";
|
|
16
|
-
import "jotai";
|
|
17
|
-
import "@react-hookz/web";
|
|
18
|
-
import "@radix-ui/react-toggle";
|
|
19
|
-
import "class-variance-authority";
|
|
20
|
-
import "./Class-3k8xjeiM.js";
|
|
21
|
-
import "clsx";
|
|
22
|
-
import "tailwind-merge";
|
|
23
|
-
import "@radix-ui/react-switch";
|
|
24
|
-
import "@radix-ui/react-slot";
|
|
25
|
-
import "@radix-ui/react-accordion";
|
|
26
|
-
import "@radix-ui/react-alert-dialog";
|
|
27
|
-
import "@radix-ui/react-dialog";
|
|
28
|
-
import "@radix-ui/react-label";
|
|
29
|
-
import "@radix-ui/react-scroll-area";
|
|
30
|
-
import "@radix-ui/react-tabs";
|
|
31
|
-
import "@radix-ui/react-tooltip";
|
|
32
|
-
import "@radix-ui/react-popover";
|
|
33
|
-
import "@radix-ui/react-menubar";
|
|
34
|
-
import "@radix-ui/react-hover-card";
|
|
35
|
-
import "@radix-ui/react-select";
|
|
36
|
-
import "@radix-ui/react-dropdown-menu";
|
|
37
|
-
import "@radix-ui/react-separator";
|
|
38
|
-
import "@radix-ui/react-toast";
|
|
39
|
-
import "cmdk";
|
|
40
|
-
import "@radix-ui/react-context-menu";
|
|
41
|
-
import "react-icons-picker";
|
|
42
|
-
import "react-dom";
|
|
43
|
-
import "react-quill";
|
|
44
|
-
import "lucide-react";
|
|
45
|
-
import "i18next";
|
|
46
|
-
import "@floating-ui/react-dom";
|
|
47
|
-
import "flagged";
|
|
48
|
-
import "react-hotkeys-hook";
|
|
49
|
-
function be(t = "") {
|
|
50
|
-
const s = {
|
|
51
|
-
xs: "390px",
|
|
52
|
-
sm: "640px",
|
|
53
|
-
md: "768px",
|
|
54
|
-
lg: "1024px",
|
|
55
|
-
xl: "1366px",
|
|
56
|
-
"2xl": "1536px"
|
|
57
|
-
};
|
|
58
|
-
if (new RegExp(/\bsr-only\b/).test(t))
|
|
59
|
-
return "Sr Only";
|
|
60
|
-
if (new RegExp(/\b(sm|md|lg|xl|2xl):hidden\b/).test(t))
|
|
61
|
-
return "Visible on mobile";
|
|
62
|
-
if (t.match(/(^| )hidden( |$)/g)) {
|
|
63
|
-
const a = new RegExp(
|
|
64
|
-
// checks if any of the display property is set for any higher media query
|
|
65
|
-
/\b(sm|md|lg|xl|2xl):(block|grid|flex|inline|inline-grid|inline-flex|inline-block)\b/
|
|
66
|
-
), r = t.match(a);
|
|
67
|
-
if (w(r, 1))
|
|
68
|
-
return `Visible >=${s[w(r, 1)]}`;
|
|
69
|
-
}
|
|
70
|
-
return "";
|
|
71
|
-
}
|
|
72
|
-
function je(t) {
|
|
73
|
-
return t.split("/").pop();
|
|
74
|
-
}
|
|
75
|
-
const ye = (t) => {
|
|
76
|
-
let s = "";
|
|
77
|
-
return Object.keys(t).forEach((n) => {
|
|
78
|
-
E(t[n], ue) && (s = t[n]);
|
|
79
|
-
}), s;
|
|
80
|
-
}, ve = (t) => {
|
|
81
|
-
var x;
|
|
82
|
-
const [, s] = V(), [n] = W(), l = X("outlineMenuItems", []), { isSelected: a } = t, { id: r, data: c } = t.node, u = t.depth * 10, m = (i) => {
|
|
83
|
-
i.stopPropagation(), t.onToggle(t.node.id);
|
|
84
|
-
}, g = Y(r, t.isOpen, t.onToggle), p = pe(() => {
|
|
85
|
-
const i = ye(t.node.data);
|
|
86
|
-
return be(i);
|
|
87
|
-
}, [t.node.data]);
|
|
88
|
-
return (
|
|
89
|
-
// eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions
|
|
90
|
-
/* @__PURE__ */ e.jsx(
|
|
91
|
-
"div",
|
|
92
|
-
{
|
|
93
|
-
onMouseEnter: () => s(r),
|
|
94
|
-
className: D(
|
|
95
|
-
"group flex w-full items-center justify-between space-x-px py-px",
|
|
96
|
-
a ? "bg-blue-500 text-white" : "text-gray-600 hover:bg-gray-200 dark:hover:bg-gray-800"
|
|
97
|
-
),
|
|
98
|
-
onClick: (i) => {
|
|
99
|
-
i.stopPropagation(), !n.includes(r) && t.onSelect(r);
|
|
100
|
-
},
|
|
101
|
-
onContextMenu: () => t.onSelect(r),
|
|
102
|
-
style: { paddingInlineStart: u },
|
|
103
|
-
...g,
|
|
104
|
-
children: /* @__PURE__ */ e.jsxs("div", { className: "flex w-full items-center justify-between pr-2", children: [
|
|
105
|
-
/* @__PURE__ */ e.jsxs("div", { className: "flex items-center", children: [
|
|
106
|
-
/* @__PURE__ */ e.jsx(
|
|
107
|
-
"div",
|
|
108
|
-
{
|
|
109
|
-
className: `flex h-4 w-4 rotate-0 transform cursor-pointer items-center justify-center text-xs transition-transform duration-100 ${t.isOpen ? "rotate-90" : ""}`,
|
|
110
|
-
children: t.node.droppable && /* @__PURE__ */ e.jsx("button", { onClick: m, type: "button", children: /* @__PURE__ */ e.jsx(P, {}) })
|
|
111
|
-
}
|
|
112
|
-
),
|
|
113
|
-
/* @__PURE__ */ e.jsxs("button", { type: "button", className: "flex items-center", children: [
|
|
114
|
-
/* @__PURE__ */ e.jsx("div", { className: "-mt-1 h-3 w-3", children: /* @__PURE__ */ e.jsx(N, { type: c == null ? void 0 : c._type }) }),
|
|
115
|
-
/* @__PURE__ */ e.jsx("div", { className: "ml-2 truncate text-[11px]", children: ((x = t.node.data) == null ? void 0 : x._name) || je(t.node.text) }),
|
|
116
|
-
p ? /* @__PURE__ */ e.jsxs(
|
|
117
|
-
"span",
|
|
118
|
-
{
|
|
119
|
-
className: "ml-2 flex items-center truncate text-[10px] italic " + (a ? "text-gray-200" : "text-gray-500"),
|
|
120
|
-
children: [
|
|
121
|
-
"(",
|
|
122
|
-
p,
|
|
123
|
-
")"
|
|
124
|
-
]
|
|
125
|
-
}
|
|
126
|
-
) : null
|
|
127
|
-
] })
|
|
128
|
-
] }),
|
|
129
|
-
/* @__PURE__ */ e.jsx("div", { className: "invisible flex items-center space-x-1 group-hover:visible", children: l.map((i) => /* @__PURE__ */ e.jsxs(z, { children: [
|
|
130
|
-
/* @__PURE__ */ e.jsx(
|
|
131
|
-
G,
|
|
132
|
-
{
|
|
133
|
-
className: "cursor-pointer rounded bg-transparent hover:bg-white hover:text-blue-500",
|
|
134
|
-
asChild: !0,
|
|
135
|
-
children: i.item(r)
|
|
136
|
-
}
|
|
137
|
-
),
|
|
138
|
-
/* @__PURE__ */ e.jsx(J, { children: i.tooltip })
|
|
139
|
-
] })) })
|
|
140
|
-
] })
|
|
141
|
-
}
|
|
142
|
-
)
|
|
143
|
-
);
|
|
144
|
-
}, ke = (t) => {
|
|
145
|
-
var n;
|
|
146
|
-
const { item: s } = t.monitorProps;
|
|
147
|
-
return /* @__PURE__ */ e.jsxs("div", { className: "flex w-max items-center bg-blue-200 bg-opacity-30 p-1 font-semibold text-blue-700", children: [
|
|
148
|
-
/* @__PURE__ */ e.jsx("div", { className: "", children: /* @__PURE__ */ e.jsx(N, { type: (n = s == null ? void 0 : s.data) == null ? void 0 : n._type }) }),
|
|
149
|
-
/* @__PURE__ */ e.jsx("div", { className: "ml-2 truncate text-[11px]", children: s.text })
|
|
150
|
-
] });
|
|
151
|
-
}, we = (t) => {
|
|
152
|
-
const s = t.depth * 10 + 16;
|
|
153
|
-
return /* @__PURE__ */ e.jsx("div", { className: "absolute right-0 top-0 h-0.5 -translate-y-1/2 transform bg-green-500", style: { left: s } });
|
|
154
|
-
}, Be = () => {
|
|
155
|
-
const [t] = y(), s = Z(), n = I();
|
|
156
|
-
return /* @__PURE__ */ e.jsxs(
|
|
157
|
-
C,
|
|
158
|
-
{
|
|
159
|
-
disabled: !ee(n == null ? void 0 : n._type),
|
|
160
|
-
className: "flex items-center gap-x-4 text-xs",
|
|
161
|
-
onClick: () => s(t),
|
|
162
|
-
children: [
|
|
163
|
-
/* @__PURE__ */ e.jsx(H, {}),
|
|
164
|
-
" Remove"
|
|
165
|
-
]
|
|
166
|
-
}
|
|
167
|
-
);
|
|
168
|
-
}, Ie = () => {
|
|
169
|
-
const [t] = y(), s = te(), n = I(), l = xe(() => {
|
|
170
|
-
s(t);
|
|
171
|
-
}, [t, s]);
|
|
172
|
-
return /* @__PURE__ */ e.jsxs(se, { className: "text-xs", children: [
|
|
173
|
-
/* @__PURE__ */ e.jsxs(
|
|
174
|
-
C,
|
|
175
|
-
{
|
|
176
|
-
disabled: !oe(n == null ? void 0 : n._type),
|
|
177
|
-
className: "flex items-center gap-x-4 text-xs",
|
|
178
|
-
onClick: l,
|
|
179
|
-
children: [
|
|
180
|
-
/* @__PURE__ */ e.jsx(L, {}),
|
|
181
|
-
" Duplicate"
|
|
182
|
-
]
|
|
183
|
-
}
|
|
184
|
-
),
|
|
185
|
-
/* @__PURE__ */ e.jsx(Be, {})
|
|
186
|
-
] });
|
|
187
|
-
}, Ce = ({ children: t }) => /* @__PURE__ */ e.jsx(e.Fragment, { children: /* @__PURE__ */ e.jsxs(ne, { children: [
|
|
188
|
-
/* @__PURE__ */ e.jsx(re, { children: t }),
|
|
189
|
-
/* @__PURE__ */ e.jsx(Ie, {})
|
|
190
|
-
] }) });
|
|
191
|
-
function Ne(t) {
|
|
192
|
-
return B(t, (s) => {
|
|
193
|
-
const { data: n } = s;
|
|
194
|
-
return {
|
|
195
|
-
...n,
|
|
196
|
-
_parent: s.parent === 0 ? null : s.parent
|
|
197
|
-
};
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
const kt = () => {
|
|
201
|
-
const [t] = ie(), { setNewBlocks: s } = le(), [n, l, a] = y(), [, r] = ae(), { t: c } = Q(), u = ge(), m = fe(), [g] = ce(), p = async (o, d) => {
|
|
202
|
-
const { dragSource: f, relativeIndex: b, dropTargetId: j, monitor: v } = d;
|
|
203
|
-
if (f) {
|
|
204
|
-
const k = Ne(o);
|
|
205
|
-
s(k), he("Handle Drop -> New Blocks -> ", k);
|
|
206
|
-
const T = v.getItem();
|
|
207
|
-
l([T.id]);
|
|
208
|
-
} else
|
|
209
|
-
await m({ block: v.getItem(), dropTargetId: j, relativeIndex: b });
|
|
210
|
-
}, x = B(t, (o) => ({
|
|
211
|
-
id: o._id,
|
|
212
|
-
text: o._type,
|
|
213
|
-
parent: o._parent || 0,
|
|
214
|
-
droppable: !_(M(t, { _parent: o._id })),
|
|
215
|
-
data: o
|
|
216
|
-
})), i = () => {
|
|
217
|
-
l([]), r([]);
|
|
218
|
-
}, [{ isOver: h }, S] = K(() => ({
|
|
219
|
-
accept: ["CHAI_BLOCK"],
|
|
220
|
-
collect: (o) => ({
|
|
221
|
-
canDrop: o.canDrop(),
|
|
222
|
-
isOver: o.isOver()
|
|
223
|
-
}),
|
|
224
|
-
drop: (o) => {
|
|
225
|
-
(async () => await m({
|
|
226
|
-
block: o,
|
|
227
|
-
dropTargetId: "",
|
|
228
|
-
relativeIndex: 0
|
|
229
|
-
}))();
|
|
230
|
-
}
|
|
231
|
-
})), { isDragging: O } = U((o) => ({
|
|
232
|
-
isDragging: o.isDragging()
|
|
233
|
-
}));
|
|
234
|
-
return /* @__PURE__ */ e.jsx(e.Fragment, { children: /* @__PURE__ */ e.jsx(
|
|
235
|
-
"div",
|
|
236
|
-
{
|
|
237
|
-
onClick: () => i(),
|
|
238
|
-
className: D(
|
|
239
|
-
"-mx-1 -mt-1 flex h-full select-none flex-col space-y-1",
|
|
240
|
-
O ? "bg-green-50/80" : "bg-background"
|
|
241
|
-
),
|
|
242
|
-
children: R(t) ? /* @__PURE__ */ e.jsxs(
|
|
243
|
-
"div",
|
|
244
|
-
{
|
|
245
|
-
ref: S,
|
|
246
|
-
className: `mx-1 mt-4 h-full max-w-full p-6 text-center text-sm text-gray-400 ${h ? "bg-blue-200" : ""}`,
|
|
247
|
-
children: [
|
|
248
|
-
h ? /* @__PURE__ */ e.jsx($, { className: "mx-auto h-12 w-12 animate-bounce" }) : /* @__PURE__ */ e.jsx(F, { className: "mx-auto h-10 w-10" }),
|
|
249
|
-
/* @__PURE__ */ e.jsx("p", { className: "mt-2", children: c(h ? "drop_here_message" : "tree_view_no_blocks") })
|
|
250
|
-
]
|
|
251
|
-
}
|
|
252
|
-
) : /* @__PURE__ */ e.jsx(de, { id: "layers-view", className: "no-scrollbar h-full overflow-y-auto p-1", children: /* @__PURE__ */ e.jsx(
|
|
253
|
-
q,
|
|
254
|
-
{
|
|
255
|
-
initialOpen: u,
|
|
256
|
-
extraAcceptTypes: ["CHAI_BLOCK"],
|
|
257
|
-
tree: x,
|
|
258
|
-
rootId: 0,
|
|
259
|
-
render: (o, { depth: d, isOpen: f, onToggle: b }) => /* @__PURE__ */ e.jsx(Ce, { id: o.id, children: /* @__PURE__ */ e.jsx(
|
|
260
|
-
ve,
|
|
261
|
-
{
|
|
262
|
-
onSelect: (j) => {
|
|
263
|
-
r([]), l([j]);
|
|
264
|
-
},
|
|
265
|
-
isSelected: A(n, o.id),
|
|
266
|
-
node: o,
|
|
267
|
-
depth: d,
|
|
268
|
-
isOpen: f,
|
|
269
|
-
onToggle: b,
|
|
270
|
-
toggleIds: a
|
|
271
|
-
}
|
|
272
|
-
) }),
|
|
273
|
-
dragPreviewRender: (o) => /* @__PURE__ */ e.jsx(ke, { monitorProps: o }),
|
|
274
|
-
onDrop: p,
|
|
275
|
-
classes: {
|
|
276
|
-
root: "h-[90%] " + (g ? "pl-2" : "pt-2"),
|
|
277
|
-
draggingSource: "opacity-30",
|
|
278
|
-
dropTarget: "bg-green-100",
|
|
279
|
-
placeholder: "relative"
|
|
280
|
-
},
|
|
281
|
-
sort: !1,
|
|
282
|
-
insertDroppableFirst: !1,
|
|
283
|
-
canDrop: me,
|
|
284
|
-
dropTargetOffset: 2,
|
|
285
|
-
enableAnimateExpand: !0,
|
|
286
|
-
placeholderRender: (o, { depth: d }) => /* @__PURE__ */ e.jsx(we, { node: o, depth: d })
|
|
287
|
-
}
|
|
288
|
-
) })
|
|
289
|
-
}
|
|
290
|
-
) });
|
|
291
|
-
};
|
|
292
|
-
export {
|
|
293
|
-
kt as default
|
|
294
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./jsx-runtime-Z_BpKhVy.cjs"),l=require("lodash-es"),p=require("@radix-ui/react-icons"),v=require("react-dnd"),B=require("@minoru/react-dnd-treeview"),T=require("react-i18next"),s=require("./index-9PHdn80L.cjs"),w=require("./TypeIcon-ElNNPazl.cjs"),S=require("react"),M=require("./MODIFIERS-9EwxLM8V.cjs"),C=require("./Functions-N3yhPYKY.cjs"),I=require("./index-0bwkNnA0.cjs"),_=require("./useAddBlockByDrop-qRHgy8_0.cjs");require("./_commonjsHelpers-wDK0ZLPo.cjs");require("@chaibuilder/runtime");require("jotai");require("@react-hookz/web");require("@radix-ui/react-toggle");require("class-variance-authority");require("./Class-MmCxz2Ay.cjs");require("clsx");require("tailwind-merge");require("@radix-ui/react-switch");require("@radix-ui/react-slot");require("@radix-ui/react-accordion");require("@radix-ui/react-alert-dialog");require("@radix-ui/react-dialog");require("@radix-ui/react-label");require("@radix-ui/react-scroll-area");require("@radix-ui/react-tabs");require("@radix-ui/react-tooltip");require("@radix-ui/react-popover");require("@radix-ui/react-menubar");require("@radix-ui/react-hover-card");require("@radix-ui/react-select");require("@radix-ui/react-dropdown-menu");require("@radix-ui/react-separator");require("@radix-ui/react-toast");require("cmdk");require("@radix-ui/react-context-menu");require("react-icons-picker");require("react-dom");require("react-quill");require("lucide-react");require("i18next");require("@floating-ui/react-dom");require("flagged");require("react-hotkeys-hook");function A(t=""){const r={xs:"390px",sm:"640px",md:"768px",lg:"1024px",xl:"1366px","2xl":"1536px"};if(new RegExp(/\bsr-only\b/).test(t))return"Sr Only";if(new RegExp(/\b(sm|md|lg|xl|2xl):hidden\b/).test(t))return"Visible on mobile";if(t.match(/(^| )hidden( |$)/g)){const u=new RegExp(/\b(sm|md|lg|xl|2xl):(block|grid|flex|inline|inline-grid|inline-flex|inline-block)\b/),i=t.match(u);if(l.nth(i,1))return`Visible >=${r[l.nth(i,1)]}`}return""}function P(t){return t.split("/").pop()}const H=t=>{let r="";return Object.keys(t).forEach(o=>{l.startsWith(t[o],M.STYLES_KEY)&&(r=t[o])}),r},F=t=>{var j;const[,r]=s.useHighlightBlockId(),[o]=s.useHiddenBlockIds(),x=s.useBuilderProp("outlineMenuItems",[]),{isSelected:u}=t,{id:i,data:a}=t.node,h=t.depth*10,m=c=>{c.stopPropagation(),t.onToggle(t.node.id)},E=B.useDragOver(i,t.isOpen,t.onToggle),g=S.useMemo(()=>{const c=H(t.node.data);return A(c)},[t.node.data]);return e.jsxRuntimeExports.jsx("div",{onMouseEnter:()=>r(i),className:C.cn("group flex w-full items-center justify-between space-x-px py-px",u?"bg-blue-500 text-white":"text-gray-600 hover:bg-gray-200 dark:hover:bg-gray-800"),onClick:c=>{c.stopPropagation(),!o.includes(i)&&t.onSelect(i)},onContextMenu:()=>t.onSelect(i),style:{paddingInlineStart:h},...E,children:e.jsxRuntimeExports.jsxs("div",{className:"flex w-full items-center justify-between pr-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center",children:[e.jsxRuntimeExports.jsx("div",{className:`flex h-4 w-4 rotate-0 transform cursor-pointer items-center justify-center text-xs transition-transform duration-100 ${t.isOpen?"rotate-90":""}`,children:t.node.droppable&&e.jsxRuntimeExports.jsx("button",{onClick:m,type:"button",children:e.jsxRuntimeExports.jsx(p.TriangleRightIcon,{})})}),e.jsxRuntimeExports.jsxs("button",{type:"button",className:"flex items-center",children:[e.jsxRuntimeExports.jsx("div",{className:"-mt-1 h-3 w-3",children:e.jsxRuntimeExports.jsx(w.TypeIcon,{type:a==null?void 0:a._type})}),e.jsxRuntimeExports.jsx("div",{className:"ml-2 truncate text-[11px]",children:((j=t.node.data)==null?void 0:j._name)||P(t.node.text)}),g?e.jsxRuntimeExports.jsxs("span",{className:"ml-2 flex items-center truncate text-[10px] italic "+(u?"text-gray-200":"text-gray-500"),children:["(",g,")"]}):null]})]}),e.jsxRuntimeExports.jsx("div",{className:"invisible flex items-center space-x-1 group-hover:visible",children:x.map(c=>e.jsxRuntimeExports.jsxs(s.Tooltip,{children:[e.jsxRuntimeExports.jsx(s.TooltipTrigger,{className:"cursor-pointer rounded bg-transparent hover:bg-white hover:text-blue-500",asChild:!0,children:c.item(i)}),e.jsxRuntimeExports.jsx(s.TooltipContent,{children:c.tooltip})]}))})]})})},L=t=>{var o;const{item:r}=t.monitorProps;return e.jsxRuntimeExports.jsxs("div",{className:"flex w-max items-center bg-blue-200 bg-opacity-30 p-1 font-semibold text-blue-700",children:[e.jsxRuntimeExports.jsx("div",{className:"",children:e.jsxRuntimeExports.jsx(w.TypeIcon,{type:(o=r==null?void 0:r.data)==null?void 0:o._type})}),e.jsxRuntimeExports.jsx("div",{className:"ml-2 truncate text-[11px]",children:r.text})]})},$=t=>{const r=t.depth*10+16;return e.jsxRuntimeExports.jsx("div",{className:"absolute right-0 top-0 h-0.5 -translate-y-1/2 transform bg-green-500",style:{left:r}})},K=()=>{const[t]=s.useSelectedBlockIds(),r=s.useRemoveBlocks(),o=s.useSelectedBlock();return e.jsxRuntimeExports.jsxs(s.ContextMenuItem,{disabled:!s.canDeleteBlock(o==null?void 0:o._type),className:"flex items-center gap-x-4 text-xs",onClick:()=>r(t),children:[e.jsxRuntimeExports.jsx(p.TrashIcon,{})," Remove"]})},U=()=>{const[t]=s.useSelectedBlockIds(),r=s.useDuplicateBlocks(),o=s.useSelectedBlock(),x=S.useCallback(()=>{r(t)},[t,r]);return e.jsxRuntimeExports.jsxs(s.ContextMenuContent,{className:"text-xs",children:[e.jsxRuntimeExports.jsxs(s.ContextMenuItem,{disabled:!s.canDuplicateBlock(o==null?void 0:o._type),className:"flex items-center gap-x-4 text-xs",onClick:x,children:[e.jsxRuntimeExports.jsx(p.CopyIcon,{})," Duplicate"]}),e.jsxRuntimeExports.jsx(K,{})]})},Q=({children:t})=>e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsxs(s.ContextMenu,{children:[e.jsxRuntimeExports.jsx(s.ContextMenuTrigger,{children:t}),e.jsxRuntimeExports.jsx(U,{})]})});function V(t){return l.map(t,r=>{const{data:o}=r;return{...o,_parent:r.parent===0?null:r.parent}})}const Y=()=>{const[t]=s.useBlocksStore(),{setNewBlocks:r}=s.useBlocksStoreUndoableActions(),[o,x,u]=s.useSelectedBlockIds(),[,i]=s.useSelectedStylingBlocks(),{t:a}=T.useTranslation(),h=I.useExpandedIds(),m=_.useAddBlockByDrop(),[E]=s.useBlocksContainer(),g=async(n,d)=>{const{dragSource:b,relativeIndex:f,dropTargetId:q,monitor:y}=d;if(b){const k=V(n);r(k),I.debugLog("Handle Drop -> New Blocks -> ",k);const O=y.getItem();x([O.id])}else await m({block:y.getItem(),dropTargetId:q,relativeIndex:f})},j=l.map(t,n=>({id:n._id,text:n._type,parent:n._parent||0,droppable:!l.isUndefined(l.find(t,{_parent:n._id})),data:n})),c=()=>{x([]),i([])},[{isOver:R},D]=v.useDrop(()=>({accept:["CHAI_BLOCK"],collect:n=>({canDrop:n.canDrop(),isOver:n.isOver()}),drop:n=>{(async()=>await m({block:n,dropTargetId:"",relativeIndex:0}))()}})),{isDragging:N}=v.useDragLayer(n=>({isDragging:n.isDragging()}));return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsx("div",{onClick:()=>c(),className:C.cn("-mx-1 -mt-1 flex h-full select-none flex-col space-y-1",N?"bg-green-50/80":"bg-background"),children:l.isEmpty(t)?e.jsxRuntimeExports.jsxs("div",{ref:D,className:`mx-1 mt-4 h-full max-w-full p-6 text-center text-sm text-gray-400 ${R?"bg-blue-200":""}`,children:[R?e.jsxRuntimeExports.jsx(p.DoubleArrowDownIcon,{className:"mx-auto h-12 w-12 animate-bounce"}):e.jsxRuntimeExports.jsx(p.StackIcon,{className:"mx-auto h-10 w-10"}),e.jsxRuntimeExports.jsx("p",{className:"mt-2",children:a(R?"drop_here_message":"tree_view_no_blocks")})]}):e.jsxRuntimeExports.jsx(s.ScrollArea,{id:"layers-view",className:"no-scrollbar h-full overflow-y-auto p-1",children:e.jsxRuntimeExports.jsx(B.Tree,{initialOpen:h,extraAcceptTypes:["CHAI_BLOCK"],tree:j,rootId:0,render:(n,{depth:d,isOpen:b,onToggle:f})=>e.jsxRuntimeExports.jsx(Q,{id:n.id,children:e.jsxRuntimeExports.jsx(F,{onSelect:q=>{i([]),x([q])},isSelected:l.includes(o,n.id),node:n,depth:d,isOpen:b,onToggle:f,toggleIds:u})}),dragPreviewRender:n=>e.jsxRuntimeExports.jsx(L,{monitorProps:n}),onDrop:g,classes:{root:"h-[90%] "+(E?"pl-2":"pt-2"),draggingSource:"opacity-30",dropTarget:"bg-green-100",placeholder:"relative"},sort:!1,insertDroppableFirst:!1,canDrop:s.canDropBlock,dropTargetOffset:2,enableAnimateExpand:!0,placeholderRender:(n,{depth:d})=>e.jsxRuntimeExports.jsx($,{node:n,depth:d})})})})})};exports.default=Y;
|