@chaibuilder/sdk 1.2.51 → 1.2.52
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-LyEjf6h0.js → AddBlocks-GxEmM16E.js} +17 -17
- package/dist/{AddBlocks-hOFqmmXZ.cjs → AddBlocks-fozauzIV.cjs} +1 -1
- package/dist/CanvasArea-NRtblq5d.cjs +56 -0
- package/dist/{CanvasArea-mhINqS0c.js → CanvasArea-rdY6SFYn.js} +57 -57
- package/dist/{ChaiBuilderEditor-H173PF4T.cjs → ChaiBuilderEditor-Pga_zJgw.cjs} +55 -55
- package/dist/{ChaiBuilderEditor-KEwDa8Bl.js → ChaiBuilderEditor-bNZZWYMh.js} +14537 -14536
- package/dist/CodeEditor-tqtgia3I.js +115 -0
- package/dist/CodeEditor-ye3IXW3i.cjs +1 -0
- package/dist/{CurrentPage-UzajS1xZ.js → CurrentPage-7NM90y76.js} +7 -7
- package/dist/{CurrentPage-RUx7wvBt.cjs → CurrentPage-sx7KVTmt.cjs} +1 -1
- package/dist/ListTree-7Pz6H6eE.cjs +1 -0
- package/dist/ListTree-oRbeDNod.js +25724 -0
- package/dist/{PagesPanel-LBW-4mVM.cjs → PagesPanel-Nr-908vy.cjs} +1 -1
- package/dist/{PagesPanel-p-h6o26u.js → PagesPanel-XiTUaiq_.js} +4 -4
- package/dist/{ProjectPanel-PQv2uVj2.cjs → ProjectPanel-SuFYN60H.cjs} +1 -1
- package/dist/{ProjectPanel-o0OWWnYQ.js → ProjectPanel-XfknsGkz.js} +4 -4
- package/dist/Settings-22Hy7jUT.cjs +1 -0
- package/dist/{Settings-zm-cF9rZ.js → Settings-dJ72rwnH.js} +405 -398
- package/dist/{SidePanels-0w036NaZ.cjs → SidePanels-5dnRAsJh.cjs} +1 -1
- package/dist/{SidePanels-TOHaLWC6.js → SidePanels-t9oUA51J.js} +38 -38
- package/dist/{ThemeConfiguration-MBuJmbDn.cjs → ThemeConfiguration-2Sbh29qi.cjs} +1 -1
- package/dist/{ThemeConfiguration-wJA_aBly.js → ThemeConfiguration-pcHbYiIP.js} +9 -9
- package/dist/{Topbar-Rh7dWuJD.js → Topbar-0DmS6VpB.js} +4 -4
- package/dist/{Topbar-u5HAh7Mg.cjs → Topbar-ID6Ipphd.cjs} +1 -1
- package/dist/{UILibrariesPanel-3-cWabRt.js → UILibrariesPanel-G9J4KUsZ.js} +6 -6
- package/dist/{UILibrariesPanel-xOys8g8A.cjs → UILibrariesPanel-sXY6hozJ.cjs} +1 -1
- package/dist/{UnsplashImages-Kymq8i6b.cjs → UnsplashImages-HK4_1VVL.cjs} +1 -1
- package/dist/{UnsplashImages-dhU2-pHY.js → UnsplashImages-MeS5Cu7a.js} +4 -4
- package/dist/{UploadImages-dr_gpAea.js → UploadImages-AIKATqfP.js} +2 -2
- package/dist/{UploadImages-WpaiIEbj.cjs → UploadImages-LSnxByGV.cjs} +1 -1
- package/dist/{add-page-modal-zwq1hL_o.js → add-page-modal-JkD45moJ.js} +8 -8
- package/dist/{add-page-modal-vmUMNu7F.cjs → add-page-modal-krxKdX7-.cjs} +1 -1
- package/dist/{confirm-alert-fK62IiTF.cjs → confirm-alert--QTC21Z2.cjs} +1 -1
- package/dist/{confirm-alert-73tjkqtD.js → confirm-alert-NHxthdRK.js} +2 -2
- package/dist/core.cjs +1 -1
- package/dist/core.d.ts +9 -0
- package/dist/core.js +32 -31
- package/dist/{delete-page-modal-DPNxHWfi.js → delete-page-modal-8rjPEchH.js} +3 -3
- package/dist/{delete-page-modal-G_aMq7K4.cjs → delete-page-modal-BIe0kYNH.cjs} +1 -1
- package/dist/email.cjs +1 -1
- package/dist/email.js +2 -2
- package/dist/{form-YMuxx9Ju.cjs → form-6OLp5uEG.cjs} +1 -1
- package/dist/{form-_tKI6ugY.js → form-PQYPrD_Q.js} +5 -5
- package/dist/functions--tdNWQDW.js +30 -0
- package/dist/functions-EVUeSwX1.cjs +1 -0
- package/dist/index--mLLy7QQ.cjs +1 -0
- package/dist/index-9_b2eou7.js +2201 -0
- package/dist/index-VBXQixVm.js +117 -0
- package/dist/index-seU0_UZX.cjs +1 -0
- package/dist/lib.cjs +1 -1
- package/dist/lib.js +10 -10
- package/dist/{page-viewer-WQgFhgp5.cjs → page-viewer-WwwMC1Kq.cjs} +1 -1
- package/dist/{page-viewer-UZMtWQDj.js → page-viewer-sKluQ_e1.js} +9 -9
- package/dist/{project-general-setting-Zz7qcIW7.js → project-general-setting-Lc2ByvTt.js} +6 -6
- package/dist/{project-general-setting-Yh4fQsQH.cjs → project-general-setting-pRO1ikDV.cjs} +1 -1
- package/dist/{project-seo-setting-wFOVAoC2.js → project-seo-setting-530_6o9S.js} +3 -3
- package/dist/{project-seo-setting-_gNPOTsp.cjs → project-seo-setting-BzSrXFVv.cjs} +1 -1
- package/dist/render.cjs +1 -1
- package/dist/render.js +2 -2
- package/dist/{single-page-detail-EMxzuAe1.cjs → single-page-detail-_VP4zaCI.cjs} +1 -1
- package/dist/{single-page-detail-1Vveonuh.js → single-page-detail-qDxxtedN.js} +5 -5
- package/dist/studio.cjs +1 -1
- package/dist/studio.js +3 -3
- package/dist/ui.cjs +1 -1
- package/dist/ui.js +98 -98
- package/dist/useCanvasSettings-5y2fSCpN.js +6 -0
- package/dist/useCanvasSettings-pURFQG4q.cjs +1 -0
- package/dist/web-blocks.cjs +1 -1
- package/dist/web-blocks.js +317 -317
- package/package.json +3 -2
- package/dist/CanvasArea-luy5nUGR.cjs +0 -56
- package/dist/CodeEditor-XaHQMfpT.js +0 -97
- package/dist/CodeEditor-jh9xwRXT.cjs +0 -1
- package/dist/ListTree-BWBPjCzR.js +0 -409
- package/dist/ListTree-S6pMJlmj.cjs +0 -1
- package/dist/Settings-DclX-cDC.cjs +0 -1
- package/dist/functions-JO0EW8GX.js +0 -30
- package/dist/functions-ZZVUnIjD.cjs +0 -1
- package/dist/index-9gfJqJ6E.cjs +0 -1
- package/dist/index-YpnaudSM.js +0 -63
- package/dist/index-ecnGWzh9.cjs +0 -1
- package/dist/index-vpfLlP7N.js +0 -2201
- package/dist/useCodeEditor-2KOfsFsx.js +0 -7
- package/dist/useCodeEditor-gE1NWoNH.cjs +0 -1
|
@@ -1,409 +0,0 @@
|
|
|
1
|
-
import { j as jsxRuntimeExports } from "./jsx-runtime-WbnYoNE9.js";
|
|
2
|
-
import React__default, { memo, useMemo, useCallback, useEffect, useRef } from "react";
|
|
3
|
-
import { useAtom } from "jotai";
|
|
4
|
-
import { useDebouncedCallback } from "@react-hookz/web";
|
|
5
|
-
import { Tree } from "react-arborist";
|
|
6
|
-
import { i as useBlocksStore, K as useSelectedBlockIds, G as useRemoveBlocks, L as useSelectedBlock, bs as ContextMenuItem, aJ as canDeleteBlock, w as useDuplicateBlocks, bt as ContextMenuContent, aI as canDuplicateBlock, bu as ContextMenu, bv as ContextMenuTrigger, h as useBuilderProp, z as useHighlightBlockId, aL as canAcceptChildBlock, ab as Tooltip, ac as TooltipTrigger, ad as TooltipContent, bw as treeDSBlocks, P as useUpdateBlocksProps, X as useSelectedStylingBlocks, aA as useBlocksStoreUndoableActions, aG as treeRefAtom } from "./ChaiBuilderEditor-KEwDa8Bl.js";
|
|
7
|
-
import { c as cn } from "./Functions-7jnEwJyw.js";
|
|
8
|
-
import { BoxModelIcon, BoxIcon, DragHandleHorizontalIcon, ViewHorizontalIcon, BorderAllIcon, BorderTopIcon, TableIcon, DropdownMenuIcon, RadiobuttonIcon, InputIcon, ButtonIcon, CheckboxIcon, GroupIcon, SpaceBetweenVerticallyIcon, ColumnsIcon, RowsIcon, TextIcon, SketchLogoIcon, DividerHorizontalIcon, CodeIcon, CursorTextIcon, VideoIcon, Link1Icon, HeadingIcon, ImageIcon, TrashIcon, CopyIcon, TriangleRightIcon } from "@radix-ui/react-icons";
|
|
9
|
-
import { DatabaseIcon } from "lucide-react";
|
|
10
|
-
import { find, first, isEmpty } from "lodash-es";
|
|
11
|
-
import { useTranslation } from "react-i18next";
|
|
12
|
-
import "./_commonjsHelpers-UyOWmZb0.js";
|
|
13
|
-
import "clsx";
|
|
14
|
-
import "react-dom";
|
|
15
|
-
import "@radix-ui/react-scroll-area";
|
|
16
|
-
import "@floating-ui/react-dom";
|
|
17
|
-
import "i18next";
|
|
18
|
-
import "flagged";
|
|
19
|
-
import "./MODIFIERS-fd5XOmum.js";
|
|
20
|
-
import "@chaibuilder/runtime";
|
|
21
|
-
import "tree-model";
|
|
22
|
-
import "./utils-VpVqnC9m.js";
|
|
23
|
-
import "tailwind-merge";
|
|
24
|
-
import "@radix-ui/react-toggle";
|
|
25
|
-
import "class-variance-authority";
|
|
26
|
-
import "@radix-ui/react-switch";
|
|
27
|
-
import "@radix-ui/react-slot";
|
|
28
|
-
import "@radix-ui/react-accordion";
|
|
29
|
-
import "@radix-ui/react-alert-dialog";
|
|
30
|
-
import "@radix-ui/react-dialog";
|
|
31
|
-
import "@radix-ui/react-label";
|
|
32
|
-
import "@radix-ui/react-tabs";
|
|
33
|
-
import "@radix-ui/react-tooltip";
|
|
34
|
-
import "@radix-ui/react-popover";
|
|
35
|
-
import "@radix-ui/react-menubar";
|
|
36
|
-
import "@radix-ui/react-hover-card";
|
|
37
|
-
import "@radix-ui/react-select";
|
|
38
|
-
import "@radix-ui/react-dropdown-menu";
|
|
39
|
-
import "@radix-ui/react-separator";
|
|
40
|
-
import "@radix-ui/react-toast";
|
|
41
|
-
import "cmdk";
|
|
42
|
-
import "@radix-ui/react-context-menu";
|
|
43
|
-
import "react-icons-picker";
|
|
44
|
-
import "react-quill";
|
|
45
|
-
import "react-hotkeys-hook";
|
|
46
|
-
import "./index-YpnaudSM.js";
|
|
47
|
-
const TypeIcon = (o) => {
|
|
48
|
-
switch (o.type) {
|
|
49
|
-
case "Image":
|
|
50
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(ImageIcon, {});
|
|
51
|
-
case "Heading":
|
|
52
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(HeadingIcon, {});
|
|
53
|
-
case "Text":
|
|
54
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(TextIcon, {});
|
|
55
|
-
case "Link":
|
|
56
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(Link1Icon, {});
|
|
57
|
-
case "Video":
|
|
58
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(VideoIcon, {});
|
|
59
|
-
case "RichText":
|
|
60
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(CursorTextIcon, {});
|
|
61
|
-
case "Button":
|
|
62
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(ButtonIcon, {});
|
|
63
|
-
case "CustomHTML":
|
|
64
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(CodeIcon, {});
|
|
65
|
-
case "Divider":
|
|
66
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(DividerHorizontalIcon, {});
|
|
67
|
-
case "Icon":
|
|
68
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(SketchLogoIcon, {});
|
|
69
|
-
case "List":
|
|
70
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(RowsIcon, {});
|
|
71
|
-
case "Paragraph":
|
|
72
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(TextIcon, {});
|
|
73
|
-
case "Row":
|
|
74
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(RowsIcon, {});
|
|
75
|
-
case "ListItem":
|
|
76
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(ColumnsIcon, {});
|
|
77
|
-
case "LineBreak":
|
|
78
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(SpaceBetweenVerticallyIcon, {});
|
|
79
|
-
case "Form":
|
|
80
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(GroupIcon, {});
|
|
81
|
-
case "Checkbox":
|
|
82
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(CheckboxIcon, {});
|
|
83
|
-
case "FormButton":
|
|
84
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(ButtonIcon, {});
|
|
85
|
-
case "Input":
|
|
86
|
-
case "TextArea":
|
|
87
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(InputIcon, {});
|
|
88
|
-
case "Radio":
|
|
89
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(RadiobuttonIcon, {});
|
|
90
|
-
case "Select":
|
|
91
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(DropdownMenuIcon, {});
|
|
92
|
-
case "Table":
|
|
93
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(TableIcon, {});
|
|
94
|
-
case "TableHead":
|
|
95
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(BorderTopIcon, {});
|
|
96
|
-
case "TableBody":
|
|
97
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(BorderAllIcon, {});
|
|
98
|
-
case "TableRow":
|
|
99
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(ViewHorizontalIcon, {});
|
|
100
|
-
case "TableCell":
|
|
101
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(DragHandleHorizontalIcon, {});
|
|
102
|
-
case "DataProvider":
|
|
103
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(DatabaseIcon, { size: 16 });
|
|
104
|
-
case "Box":
|
|
105
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(BoxIcon, {});
|
|
106
|
-
default:
|
|
107
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(BoxModelIcon, {});
|
|
108
|
-
}
|
|
109
|
-
}, placeholderStyle = {
|
|
110
|
-
display: "flex",
|
|
111
|
-
alignItems: "center",
|
|
112
|
-
zIndex: 1
|
|
113
|
-
}, DefaultCursor = React__default.memo(function({ top: r, left: n }) {
|
|
114
|
-
const c = {
|
|
115
|
-
position: "absolute",
|
|
116
|
-
pointerEvents: "none",
|
|
117
|
-
top: r + "px",
|
|
118
|
-
left: n + "px",
|
|
119
|
-
right: 0
|
|
120
|
-
};
|
|
121
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { style: { ...placeholderStyle, ...c }, children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-0.5 flex-1 rounded-[1px] bg-green-500" }) });
|
|
122
|
-
}), Overlay = memo(function({ children: r, isDragging: n }) {
|
|
123
|
-
return n ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "pointer-events-none fixed left-0 top-0 z-[100] h-full w-full", children: r }) : null;
|
|
124
|
-
}), DefaultDragPreview = memo(({ id: o, isDragging: r, mouse: n }) => {
|
|
125
|
-
const [c] = useBlocksStore(), i = useMemo(() => c.find((x) => x._id === o), [c, o]), u = useMemo(
|
|
126
|
-
() => ({
|
|
127
|
-
transform: `translate(${(n == null ? void 0 : n.x) - 10}px, ${(n == null ? void 0 : n.y) - 10}px)`
|
|
128
|
-
}),
|
|
129
|
-
[n]
|
|
130
|
-
);
|
|
131
|
-
return n ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: /* @__PURE__ */ jsxRuntimeExports.jsx(Overlay, { isDragging: r, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
132
|
-
"div",
|
|
133
|
-
{
|
|
134
|
-
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",
|
|
135
|
-
style: u,
|
|
136
|
-
children: /* @__PURE__ */ jsxRuntimeExports.jsxs("button", { type: "button", className: "flex !cursor-grab items-center p-0.5", "aria-label": `Type: ${i == null ? void 0 : i._type}`, children: [
|
|
137
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "-mt-0.5 h-3 w-3", children: /* @__PURE__ */ jsxRuntimeExports.jsx(TypeIcon, { type: i == null ? void 0 : i._type }) }),
|
|
138
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "ml-2 truncate text-[11px]", children: (i == null ? void 0 : i._name) || (i == null ? void 0 : i._type) })
|
|
139
|
-
] })
|
|
140
|
-
}
|
|
141
|
-
) }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "hidden" });
|
|
142
|
-
}), RemoveBlocks = () => {
|
|
143
|
-
const [o] = useSelectedBlockIds(), r = useRemoveBlocks(), n = useSelectedBlock();
|
|
144
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
145
|
-
ContextMenuItem,
|
|
146
|
-
{
|
|
147
|
-
disabled: !canDeleteBlock(n == null ? void 0 : n._type),
|
|
148
|
-
className: "flex items-center gap-x-4 text-xs",
|
|
149
|
-
onClick: () => r(o),
|
|
150
|
-
children: [
|
|
151
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(TrashIcon, {}),
|
|
152
|
-
" Remove"
|
|
153
|
-
]
|
|
154
|
-
}
|
|
155
|
-
);
|
|
156
|
-
}, BlockContextMenuContent = () => {
|
|
157
|
-
const [o] = useSelectedBlockIds(), r = useDuplicateBlocks(), n = useSelectedBlock(), c = useCallback(() => {
|
|
158
|
-
r(o);
|
|
159
|
-
}, [o, r]);
|
|
160
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsxs(ContextMenuContent, { className: "text-xs", children: [
|
|
161
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
162
|
-
ContextMenuItem,
|
|
163
|
-
{
|
|
164
|
-
disabled: !canDuplicateBlock(n == null ? void 0 : n._type),
|
|
165
|
-
className: "flex items-center gap-x-4 text-xs",
|
|
166
|
-
onClick: c,
|
|
167
|
-
children: [
|
|
168
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(CopyIcon, {}),
|
|
169
|
-
" Duplicate"
|
|
170
|
-
]
|
|
171
|
-
}
|
|
172
|
-
),
|
|
173
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(RemoveBlocks, {})
|
|
174
|
-
] });
|
|
175
|
-
}, BlockContextMenu = ({ children: o }) => /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(ContextMenu, { children: [
|
|
176
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(ContextMenuTrigger, { children: o }),
|
|
177
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(BlockContextMenuContent, {})
|
|
178
|
-
] }) }), defaultShortcuts = [
|
|
179
|
-
{ key: "ArrowDown", command: "selectNext" },
|
|
180
|
-
{ key: "ArrowUp", command: "selectPrev" },
|
|
181
|
-
{ key: "ArrowLeft", command: "selectParent", when: "isLeaf || isClosed" },
|
|
182
|
-
{ key: "ArrowLeft", command: "close", when: "isOpen" },
|
|
183
|
-
{ key: "ArrowRight", command: "open", when: "isClosed" },
|
|
184
|
-
{ key: "ArrowRight", command: "selectNext", when: "isOpen" },
|
|
185
|
-
{ key: "Home", command: "selectFirst" },
|
|
186
|
-
{ key: "End", command: "selectLast" }
|
|
187
|
-
];
|
|
188
|
-
function selectFirst(o) {
|
|
189
|
-
o.firstNode && o.select(o.firstNode.id);
|
|
190
|
-
}
|
|
191
|
-
function selectLast(o) {
|
|
192
|
-
o.lastNode && o.select(o.lastNode.id);
|
|
193
|
-
}
|
|
194
|
-
function selectNext(o) {
|
|
195
|
-
const r = o.selectedNodes[0].next || o.firstNode;
|
|
196
|
-
o.select(r.id);
|
|
197
|
-
}
|
|
198
|
-
function selectPrev(o) {
|
|
199
|
-
const r = o.selectedNodes[0].prev || o.lastNode;
|
|
200
|
-
o.select(r.id);
|
|
201
|
-
}
|
|
202
|
-
const selectParent = (o, r) => {
|
|
203
|
-
var c;
|
|
204
|
-
const n = ((c = o.selectedIds[0]) == null ? void 0 : c.parent) || null;
|
|
205
|
-
n && r && o.select(n.id);
|
|
206
|
-
}, open = (o, r) => {
|
|
207
|
-
const n = o.selectedNodes[0];
|
|
208
|
-
n.isInternal && r && n.open();
|
|
209
|
-
}, close = (o, r) => {
|
|
210
|
-
const n = o.selectedNodes[0];
|
|
211
|
-
n.isInternal && r && n.close();
|
|
212
|
-
}, Node = memo(({ node: o, style: r, dragHandle: n }) => {
|
|
213
|
-
const c = useBuilderProp("outlineMenuItems", []), [, i] = useHighlightBlockId(), u = o.children.length > 0, { id: x, data: l, isSelected: d, willReceiveDrop: p, isDragging: m, isEditing: j, handleClick: f } = o, R = useDebouncedCallback((a) => i(a), [], 300), h = (a) => {
|
|
214
|
-
a.stopPropagation(), o.toggle();
|
|
215
|
-
}, I = (a) => {
|
|
216
|
-
a.stopPropagation(), o.isOpen || o.toggle(), f(a);
|
|
217
|
-
};
|
|
218
|
-
return useEffect(() => {
|
|
219
|
-
const a = setTimeout(() => {
|
|
220
|
-
p && !o.isOpen && o.toggle();
|
|
221
|
-
}, 500);
|
|
222
|
-
return () => clearTimeout(a);
|
|
223
|
-
}, [p, o]), /* @__PURE__ */ jsxRuntimeExports.jsx(BlockContextMenu, { id: x, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
224
|
-
"div",
|
|
225
|
-
{
|
|
226
|
-
onClick: I,
|
|
227
|
-
onMouseEnter: () => R(x),
|
|
228
|
-
style: r,
|
|
229
|
-
"data-node-id": x,
|
|
230
|
-
ref: n,
|
|
231
|
-
className: cn(
|
|
232
|
-
"group flex !h-fit w-full items-center justify-between space-x-px py-px outline-none",
|
|
233
|
-
d ? "bg-blue-500 text-white" : "text-gray-600 hover:bg-gray-200 dark:hover:bg-gray-800",
|
|
234
|
-
p && canAcceptChildBlock(l._type, "Icon") ? "bg-green-200" : "",
|
|
235
|
-
m && "opacity-20"
|
|
236
|
-
),
|
|
237
|
-
children: [
|
|
238
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center", children: [
|
|
239
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
240
|
-
"div",
|
|
241
|
-
{
|
|
242
|
-
className: `flex h-4 w-4 rotate-0 transform cursor-pointer items-center justify-center text-xs transition-transform duration-100 ${o.isOpen ? "rotate-90" : ""}`,
|
|
243
|
-
children: u && /* @__PURE__ */ jsxRuntimeExports.jsx("button", { onClick: h, type: "button", children: /* @__PURE__ */ jsxRuntimeExports.jsx(TriangleRightIcon, {}) })
|
|
244
|
-
}
|
|
245
|
-
),
|
|
246
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center", children: [
|
|
247
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "-mt-0.5 h-3 w-3", children: /* @__PURE__ */ jsxRuntimeExports.jsx(TypeIcon, { type: l == null ? void 0 : l._type }) }),
|
|
248
|
-
j ? /* @__PURE__ */ jsxRuntimeExports.jsx(Input, { node: o }) : /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
249
|
-
"div",
|
|
250
|
-
{
|
|
251
|
-
className: "ml-2 truncate text-[11px]",
|
|
252
|
-
onDoubleClick: (a) => {
|
|
253
|
-
a.stopPropagation(), o.edit(), o.deselect();
|
|
254
|
-
},
|
|
255
|
-
children: (l == null ? void 0 : l._name) || (l == null ? void 0 : l._type.split("/").pop())
|
|
256
|
-
}
|
|
257
|
-
)
|
|
258
|
-
] })
|
|
259
|
-
] }),
|
|
260
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "invisible flex items-center space-x-1 pr-2 group-hover:visible", children: c.map((a) => /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
|
|
261
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
262
|
-
TooltipTrigger,
|
|
263
|
-
{
|
|
264
|
-
className: "cursor-pointer rounded bg-transparent hover:bg-white hover:text-blue-500",
|
|
265
|
-
asChild: !0,
|
|
266
|
-
children: React__default.createElement(a.item, { blockId: x })
|
|
267
|
-
}
|
|
268
|
-
),
|
|
269
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { className: "z-[9999]", children: a.tooltip })
|
|
270
|
-
] })) })
|
|
271
|
-
]
|
|
272
|
-
}
|
|
273
|
-
) });
|
|
274
|
-
}), Input = ({ node: o }) => {
|
|
275
|
-
var r, n;
|
|
276
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
277
|
-
"input",
|
|
278
|
-
{
|
|
279
|
-
autoFocus: !0,
|
|
280
|
-
className: "ml-2 w-full rounded-sm border border-black/30 bg-transparent px-1 text-[11px] outline-none",
|
|
281
|
-
type: "text",
|
|
282
|
-
defaultValue: ((r = o.data) == null ? void 0 : r._name) || ((n = o.data) == null ? void 0 : n._type),
|
|
283
|
-
onFocus: (c) => c.currentTarget.select(),
|
|
284
|
-
onBlur: (c) => o.submit(c.currentTarget.value),
|
|
285
|
-
onKeyDown: (c) => {
|
|
286
|
-
c.key === "Enter" && o.submit(c.currentTarget.value);
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
);
|
|
290
|
-
}, useCanMove = () => {
|
|
291
|
-
const [o] = useBlocksStore();
|
|
292
|
-
return (r, n) => {
|
|
293
|
-
var u;
|
|
294
|
-
const c = (u = find(o, { _id: n })) == null ? void 0 : u._type, i = first(r.map((x) => {
|
|
295
|
-
var l;
|
|
296
|
-
return (l = find(o, { _id: x })) == null ? void 0 : l._type;
|
|
297
|
-
}));
|
|
298
|
-
return canAcceptChildBlock(c, i);
|
|
299
|
-
};
|
|
300
|
-
}, ListTree = () => {
|
|
301
|
-
const [treeData] = useAtom(treeDSBlocks), [ids, setIds] = useSelectedBlockIds(), updateBlockProps = useUpdateBlocksProps(), [, setStyleBlocks] = useSelectedStylingBlocks(), { moveBlocks } = useBlocksStoreUndoableActions(), canMove = useCanMove(), treeRef = useRef(null), [, setTreeRef] = useAtom(treeRefAtom), { t } = useTranslation(), clearSelection = () => {
|
|
302
|
-
setIds([]), setStyleBlocks([]);
|
|
303
|
-
};
|
|
304
|
-
useEffect(() => {
|
|
305
|
-
setTreeRef(treeRef.current);
|
|
306
|
-
}, [treeRef.current]);
|
|
307
|
-
const onRename = ({ id: o, name: r, node: n }) => {
|
|
308
|
-
updateBlockProps([o], { _name: r }, n.data._name);
|
|
309
|
-
}, onMove = ({ dragIds: o, parentId: r, index: n }) => {
|
|
310
|
-
canMove(o, r) && moveBlocks(o, r, n);
|
|
311
|
-
}, onSelect = (o) => {
|
|
312
|
-
if (o.length === 0)
|
|
313
|
-
return;
|
|
314
|
-
const r = o[0] ? o[0].id : "";
|
|
315
|
-
setStyleBlocks([]), setIds([r]);
|
|
316
|
-
}, onContextMenu = (o) => {
|
|
317
|
-
var c;
|
|
318
|
-
o.preventDefault();
|
|
319
|
-
const r = o.target, n = r.getAttribute("data-node-id") || ((c = r.closest("[data-node-id]")) == null ? void 0 : c.getAttribute("data-node-id"));
|
|
320
|
-
n && (setStyleBlocks([]), setIds([n]));
|
|
321
|
-
}, debouncedDisableDrop = useDebouncedCallback(
|
|
322
|
-
({ parentNode: o, dragNodes: r }) => {
|
|
323
|
-
var n;
|
|
324
|
-
return !canAcceptChildBlock(o == null ? void 0 : o.data._type, (n = r[0]) == null ? void 0 : n.data._type);
|
|
325
|
-
},
|
|
326
|
-
[],
|
|
327
|
-
300
|
|
328
|
-
), handleKeyDown = (e) => {
|
|
329
|
-
if (!treeRef.current)
|
|
330
|
-
return;
|
|
331
|
-
const tree = treeRef.current, selectedNode = tree.selectedNodes[0];
|
|
332
|
-
if (!selectedNode)
|
|
333
|
-
return;
|
|
334
|
-
setIds[selectedNode.id], setStyleBlocks([]);
|
|
335
|
-
const isLeaf = !selectedNode.isInternal, isClosed = !selectedNode.isOpen, isOpen = selectedNode.isOpen, shortcut = defaultShortcuts.find((s) => s.key === e.key && (!s.when || eval(s.when)));
|
|
336
|
-
if (shortcut)
|
|
337
|
-
switch (e.preventDefault(), shortcut.command) {
|
|
338
|
-
case "selectNext":
|
|
339
|
-
selectNext(tree);
|
|
340
|
-
break;
|
|
341
|
-
case "selectPrev":
|
|
342
|
-
selectPrev(tree);
|
|
343
|
-
break;
|
|
344
|
-
case "selectParent":
|
|
345
|
-
selectParent(tree, isLeaf || isClosed);
|
|
346
|
-
break;
|
|
347
|
-
case "close":
|
|
348
|
-
close(tree, isOpen);
|
|
349
|
-
break;
|
|
350
|
-
case "open":
|
|
351
|
-
open(tree, isClosed);
|
|
352
|
-
break;
|
|
353
|
-
case "selectFirst":
|
|
354
|
-
selectFirst(tree);
|
|
355
|
-
break;
|
|
356
|
-
case "selectLast":
|
|
357
|
-
selectLast(tree);
|
|
358
|
-
break;
|
|
359
|
-
default:
|
|
360
|
-
break;
|
|
361
|
-
}
|
|
362
|
-
};
|
|
363
|
-
return isEmpty(treeData) ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex h-full w-full items-center justify-center p-8 text-center", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "mb-1.5 text-sm text-gray-400", children: [
|
|
364
|
-
t("Page is empty."),
|
|
365
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("br", {}),
|
|
366
|
-
" ",
|
|
367
|
-
t("Add blocks to get started by clicking the"),
|
|
368
|
-
" ",
|
|
369
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "font-bold", children: "(+)" }),
|
|
370
|
-
" ",
|
|
371
|
-
t("button")
|
|
372
|
-
] }) }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: cn("-mx-1 -mt-1 flex h-full select-none flex-col space-y-1"), onClick: () => clearSelection(), children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
373
|
-
"div",
|
|
374
|
-
{
|
|
375
|
-
id: "outline-view",
|
|
376
|
-
className: "no-scrollbar h-full overflow-y-auto p-1 px-2 text-xs",
|
|
377
|
-
onKeyDown: (o) => {
|
|
378
|
-
treeRef.current.isEditing || handleKeyDown(o);
|
|
379
|
-
},
|
|
380
|
-
children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
381
|
-
Tree,
|
|
382
|
-
{
|
|
383
|
-
ref: treeRef,
|
|
384
|
-
height: 800,
|
|
385
|
-
className: "no-scrollbar !h-full max-w-full !overflow-y-auto !overflow-x-hidden",
|
|
386
|
-
selection: ids[0] || "",
|
|
387
|
-
onRename,
|
|
388
|
-
openByDefault: !1,
|
|
389
|
-
onMove,
|
|
390
|
-
rowHeight: 20,
|
|
391
|
-
data: treeData,
|
|
392
|
-
renderCursor: DefaultCursor,
|
|
393
|
-
onSelect,
|
|
394
|
-
childrenAccessor: (o) => o.children,
|
|
395
|
-
width: "100%",
|
|
396
|
-
renderDragPreview: DefaultDragPreview,
|
|
397
|
-
indent: 10,
|
|
398
|
-
onContextMenu,
|
|
399
|
-
disableDrop: debouncedDisableDrop,
|
|
400
|
-
idAccessor: "_id",
|
|
401
|
-
children: Node
|
|
402
|
-
}
|
|
403
|
-
)
|
|
404
|
-
}
|
|
405
|
-
) });
|
|
406
|
-
};
|
|
407
|
-
export {
|
|
408
|
-
ListTree as default
|
|
409
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const jsxRuntime=require("./jsx-runtime-Z_BpKhVy.cjs"),React=require("react"),jotai=require("jotai"),web=require("@react-hookz/web"),reactArborist=require("react-arborist"),ui=require("./ChaiBuilderEditor-H173PF4T.cjs"),Functions=require("./Functions-N3yhPYKY.cjs"),reactIcons=require("@radix-ui/react-icons"),lucideReact=require("lucide-react"),lodashEs=require("lodash-es"),reactI18next=require("react-i18next");require("./_commonjsHelpers-wDK0ZLPo.cjs");require("clsx");require("react-dom");require("@radix-ui/react-scroll-area");require("@floating-ui/react-dom");require("i18next");require("flagged");require("./MODIFIERS-mVmfEGgo.cjs");require("@chaibuilder/runtime");require("tree-model");require("./utils-D_vtk3zK.cjs");require("tailwind-merge");require("@radix-ui/react-toggle");require("class-variance-authority");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-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-quill");require("react-hotkeys-hook");require("./index-ecnGWzh9.cjs");const TypeIcon=n=>{switch(n.type){case"Image":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.ImageIcon,{});case"Heading":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.HeadingIcon,{});case"Text":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.TextIcon,{});case"Link":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.Link1Icon,{});case"Video":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.VideoIcon,{});case"RichText":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.CursorTextIcon,{});case"Button":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.ButtonIcon,{});case"CustomHTML":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.CodeIcon,{});case"Divider":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.DividerHorizontalIcon,{});case"Icon":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.SketchLogoIcon,{});case"List":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.RowsIcon,{});case"Paragraph":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.TextIcon,{});case"Row":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.RowsIcon,{});case"ListItem":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.ColumnsIcon,{});case"LineBreak":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.SpaceBetweenVerticallyIcon,{});case"Form":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.GroupIcon,{});case"Checkbox":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.CheckboxIcon,{});case"FormButton":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.ButtonIcon,{});case"Input":case"TextArea":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.InputIcon,{});case"Radio":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.RadiobuttonIcon,{});case"Select":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.DropdownMenuIcon,{});case"Table":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.TableIcon,{});case"TableHead":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.BorderTopIcon,{});case"TableBody":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.BorderAllIcon,{});case"TableRow":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.ViewHorizontalIcon,{});case"TableCell":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.DragHandleHorizontalIcon,{});case"DataProvider":return jsxRuntime.jsxRuntimeExports.jsx(lucideReact.DatabaseIcon,{size:16});case"Box":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.BoxIcon,{});default:return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.BoxModelIcon,{})}},placeholderStyle={display:"flex",alignItems:"center",zIndex:1},DefaultCursor=React.memo(function({top:o,left:r}){const i={position:"absolute",pointerEvents:"none",top:o+"px",left:r+"px",right:0};return jsxRuntime.jsxRuntimeExports.jsx("div",{style:{...placeholderStyle,...i},children:jsxRuntime.jsxRuntimeExports.jsx("div",{className:"h-0.5 flex-1 rounded-[1px] bg-green-500"})})}),Overlay=React.memo(function({children:o,isDragging:r}){return r?jsxRuntime.jsxRuntimeExports.jsx("div",{className:"pointer-events-none fixed left-0 top-0 z-[100] h-full w-full",children:o}):null}),DefaultDragPreview=React.memo(({id:n,isDragging:o,mouse:r})=>{const[i]=ui.useBlocksStore(),c=React.useMemo(()=>i.find(a=>a._id===n),[i,n]),l=React.useMemo(()=>({transform:`translate(${(r==null?void 0:r.x)-10}px, ${(r==null?void 0:r.y)-10}px)`}),[r]);return r?jsxRuntime.jsxRuntimeExports.jsx("div",{children:jsxRuntime.jsxRuntimeExports.jsx(Overlay,{isDragging:o,children:jsxRuntime.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:l,children:jsxRuntime.jsxRuntimeExports.jsxs("button",{type:"button",className:"flex !cursor-grab items-center p-0.5","aria-label":`Type: ${c==null?void 0:c._type}`,children:[jsxRuntime.jsxRuntimeExports.jsx("div",{className:"-mt-0.5 h-3 w-3",children:jsxRuntime.jsxRuntimeExports.jsx(TypeIcon,{type:c==null?void 0:c._type})}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"ml-2 truncate text-[11px]",children:(c==null?void 0:c._name)||(c==null?void 0:c._type)})]})})})}):jsxRuntime.jsxRuntimeExports.jsx("div",{className:"hidden"})}),RemoveBlocks=()=>{const[n]=ui.useSelectedBlockIds(),o=ui.useRemoveBlocks(),r=ui.useSelectedBlock();return jsxRuntime.jsxRuntimeExports.jsxs(ui.ContextMenuItem,{disabled:!ui.canDeleteBlock(r==null?void 0:r._type),className:"flex items-center gap-x-4 text-xs",onClick:()=>o(n),children:[jsxRuntime.jsxRuntimeExports.jsx(reactIcons.TrashIcon,{})," Remove"]})},BlockContextMenuContent=()=>{const[n]=ui.useSelectedBlockIds(),o=ui.useDuplicateBlocks(),r=ui.useSelectedBlock(),i=React.useCallback(()=>{o(n)},[n,o]);return jsxRuntime.jsxRuntimeExports.jsxs(ui.ContextMenuContent,{className:"text-xs",children:[jsxRuntime.jsxRuntimeExports.jsxs(ui.ContextMenuItem,{disabled:!ui.canDuplicateBlock(r==null?void 0:r._type),className:"flex items-center gap-x-4 text-xs",onClick:i,children:[jsxRuntime.jsxRuntimeExports.jsx(reactIcons.CopyIcon,{})," Duplicate"]}),jsxRuntime.jsxRuntimeExports.jsx(RemoveBlocks,{})]})},BlockContextMenu=({children:n})=>jsxRuntime.jsxRuntimeExports.jsx(jsxRuntime.jsxRuntimeExports.Fragment,{children:jsxRuntime.jsxRuntimeExports.jsxs(ui.ContextMenu,{children:[jsxRuntime.jsxRuntimeExports.jsx(ui.ContextMenuTrigger,{children:n}),jsxRuntime.jsxRuntimeExports.jsx(BlockContextMenuContent,{})]})}),defaultShortcuts=[{key:"ArrowDown",command:"selectNext"},{key:"ArrowUp",command:"selectPrev"},{key:"ArrowLeft",command:"selectParent",when:"isLeaf || isClosed"},{key:"ArrowLeft",command:"close",when:"isOpen"},{key:"ArrowRight",command:"open",when:"isClosed"},{key:"ArrowRight",command:"selectNext",when:"isOpen"},{key:"Home",command:"selectFirst"},{key:"End",command:"selectLast"}];function selectFirst(n){n.firstNode&&n.select(n.firstNode.id)}function selectLast(n){n.lastNode&&n.select(n.lastNode.id)}function selectNext(n){const o=n.selectedNodes[0].next||n.firstNode;n.select(o.id)}function selectPrev(n){const o=n.selectedNodes[0].prev||n.lastNode;n.select(o.id)}const selectParent=(n,o)=>{var i;const r=((i=n.selectedIds[0])==null?void 0:i.parent)||null;r&&o&&n.select(r.id)},open=(n,o)=>{const r=n.selectedNodes[0];r.isInternal&&o&&r.open()},close=(n,o)=>{const r=n.selectedNodes[0];r.isInternal&&o&&r.close()},Node=React.memo(({node:n,style:o,dragHandle:r})=>{const i=ui.useBuilderProp("outlineMenuItems",[]),[,c]=ui.useHighlightBlockId(),l=n.children.length>0,{id:a,data:u,isSelected:d,willReceiveDrop:m,isDragging:j,isEditing:p,handleClick:R}=n,h=web.useDebouncedCallback(x=>c(x),[],300),f=x=>{x.stopPropagation(),n.toggle()},I=x=>{x.stopPropagation(),n.isOpen||n.toggle(),R(x)};return React.useEffect(()=>{const x=setTimeout(()=>{m&&!n.isOpen&&n.toggle()},500);return()=>clearTimeout(x)},[m,n]),jsxRuntime.jsxRuntimeExports.jsx(BlockContextMenu,{id:a,children:jsxRuntime.jsxRuntimeExports.jsxs("div",{onClick:I,onMouseEnter:()=>h(a),style:o,"data-node-id":a,ref:r,className:Functions.cn("group flex !h-fit w-full items-center justify-between space-x-px py-px outline-none",d?"bg-blue-500 text-white":"text-gray-600 hover:bg-gray-200 dark:hover:bg-gray-800",m&&ui.canAcceptChildBlock(u._type,"Icon")?"bg-green-200":"",j&&"opacity-20"),children:[jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex items-center",children:[jsxRuntime.jsxRuntimeExports.jsx("div",{className:`flex h-4 w-4 rotate-0 transform cursor-pointer items-center justify-center text-xs transition-transform duration-100 ${n.isOpen?"rotate-90":""}`,children:l&&jsxRuntime.jsxRuntimeExports.jsx("button",{onClick:f,type:"button",children:jsxRuntime.jsxRuntimeExports.jsx(reactIcons.TriangleRightIcon,{})})}),jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex items-center",children:[jsxRuntime.jsxRuntimeExports.jsx("div",{className:"-mt-0.5 h-3 w-3",children:jsxRuntime.jsxRuntimeExports.jsx(TypeIcon,{type:u==null?void 0:u._type})}),p?jsxRuntime.jsxRuntimeExports.jsx(Input,{node:n}):jsxRuntime.jsxRuntimeExports.jsx("div",{className:"ml-2 truncate text-[11px]",onDoubleClick:x=>{x.stopPropagation(),n.edit(),n.deselect()},children:(u==null?void 0:u._name)||(u==null?void 0:u._type.split("/").pop())})]})]}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"invisible flex items-center space-x-1 pr-2 group-hover:visible",children:i.map(x=>jsxRuntime.jsxRuntimeExports.jsxs(ui.Tooltip,{children:[jsxRuntime.jsxRuntimeExports.jsx(ui.TooltipTrigger,{className:"cursor-pointer rounded bg-transparent hover:bg-white hover:text-blue-500",asChild:!0,children:React.createElement(x.item,{blockId:a})}),jsxRuntime.jsxRuntimeExports.jsx(ui.TooltipContent,{className:"z-[9999]",children:x.tooltip})]}))})]})})}),Input=({node:n})=>{var o,r;return jsxRuntime.jsxRuntimeExports.jsx("input",{autoFocus:!0,className:"ml-2 w-full rounded-sm border border-black/30 bg-transparent px-1 text-[11px] outline-none",type:"text",defaultValue:((o=n.data)==null?void 0:o._name)||((r=n.data)==null?void 0:r._type),onFocus:i=>i.currentTarget.select(),onBlur:i=>n.submit(i.currentTarget.value),onKeyDown:i=>{i.key==="Enter"&&n.submit(i.currentTarget.value)}})},useCanMove=()=>{const[n]=ui.useBlocksStore();return(o,r)=>{var l;const i=(l=lodashEs.find(n,{_id:r}))==null?void 0:l._type,c=lodashEs.first(o.map(a=>{var u;return(u=lodashEs.find(n,{_id:a}))==null?void 0:u._type}));return ui.canAcceptChildBlock(i,c)}},ListTree=()=>{const[treeData]=jotai.useAtom(ui.treeDSBlocks),[ids,setIds]=ui.useSelectedBlockIds(),updateBlockProps=ui.useUpdateBlocksProps(),[,setStyleBlocks]=ui.useSelectedStylingBlocks(),{moveBlocks}=ui.useBlocksStoreUndoableActions(),canMove=useCanMove(),treeRef=React.useRef(null),[,setTreeRef]=jotai.useAtom(ui.treeRefAtom),{t}=reactI18next.useTranslation(),clearSelection=()=>{setIds([]),setStyleBlocks([])};React.useEffect(()=>{setTreeRef(treeRef.current)},[treeRef.current]);const onRename=({id:n,name:o,node:r})=>{updateBlockProps([n],{_name:o},r.data._name)},onMove=({dragIds:n,parentId:o,index:r})=>{canMove(n,o)&&moveBlocks(n,o,r)},onSelect=n=>{if(n.length===0)return;const o=n[0]?n[0].id:"";setStyleBlocks([]),setIds([o])},onContextMenu=n=>{var i;n.preventDefault();const o=n.target,r=o.getAttribute("data-node-id")||((i=o.closest("[data-node-id]"))==null?void 0:i.getAttribute("data-node-id"));r&&(setStyleBlocks([]),setIds([r]))},debouncedDisableDrop=web.useDebouncedCallback(({parentNode:n,dragNodes:o})=>{var r;return!ui.canAcceptChildBlock(n==null?void 0:n.data._type,(r=o[0])==null?void 0:r.data._type)},[],300),handleKeyDown=e=>{if(!treeRef.current)return;const tree=treeRef.current,selectedNode=tree.selectedNodes[0];if(!selectedNode)return;setIds[selectedNode.id],setStyleBlocks([]);const isLeaf=!selectedNode.isInternal,isClosed=!selectedNode.isOpen,isOpen=selectedNode.isOpen,shortcut=defaultShortcuts.find(s=>s.key===e.key&&(!s.when||eval(s.when)));if(shortcut)switch(e.preventDefault(),shortcut.command){case"selectNext":selectNext(tree);break;case"selectPrev":selectPrev(tree);break;case"selectParent":selectParent(tree,isLeaf||isClosed);break;case"close":close(tree,isOpen);break;case"open":open(tree,isClosed);break;case"selectFirst":selectFirst(tree);break;case"selectLast":selectLast(tree);break;default:break}};return lodashEs.isEmpty(treeData)?jsxRuntime.jsxRuntimeExports.jsx("div",{children:jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex h-full w-full items-center justify-center p-8 text-center",children:jsxRuntime.jsxRuntimeExports.jsxs("p",{className:"mb-1.5 text-sm text-gray-400",children:[t("Page is empty."),jsxRuntime.jsxRuntimeExports.jsx("br",{})," ",t("Add blocks to get started by clicking the")," ",jsxRuntime.jsxRuntimeExports.jsx("span",{className:"font-bold",children:"(+)"})," ",t("button")]})})}):jsxRuntime.jsxRuntimeExports.jsx("div",{className:Functions.cn("-mx-1 -mt-1 flex h-full select-none flex-col space-y-1"),onClick:()=>clearSelection(),children:jsxRuntime.jsxRuntimeExports.jsx("div",{id:"outline-view",className:"no-scrollbar h-full overflow-y-auto p-1 px-2 text-xs",onKeyDown:n=>{treeRef.current.isEditing||handleKeyDown(n)},children:jsxRuntime.jsxRuntimeExports.jsx(reactArborist.Tree,{ref:treeRef,height:800,className:"no-scrollbar !h-full max-w-full !overflow-y-auto !overflow-x-hidden",selection:ids[0]||"",onRename,openByDefault:!1,onMove,rowHeight:20,data:treeData,renderCursor:DefaultCursor,onSelect,childrenAccessor:n=>n.children,width:"100%",renderDragPreview:DefaultDragPreview,indent:10,onContextMenu,disableDrop:debouncedDisableDrop,idAccessor:"_id",children:Node})})})};exports.default=ListTree;
|