@chaibuilder/sdk 2.0.5 → 2.0.7
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/core.cjs +5 -5
- package/dist/core.d.ts +30 -28
- package/dist/core.js +1156 -1143
- package/dist/render.cjs +2 -2
- package/dist/render.js +60 -60
- package/package.json +1 -1
package/dist/core.js
CHANGED
|
@@ -3,50 +3,50 @@ var K = (o, n, r) => n in o ? G(o, n, { enumerable: !0, configurable: !0, writab
|
|
|
3
3
|
var V = (o, n, r) => K(o, typeof n != "symbol" ? n + "" : n, r);
|
|
4
4
|
import { jsx, Fragment, jsxs } from "react/jsx-runtime";
|
|
5
5
|
import * as React from "react";
|
|
6
|
-
import React__default, { createContext, useReducer, useEffect, useDebugValue, useCallback, useContext, useMemo, Component, Children,
|
|
7
|
-
import { O as DropdownMenu, P as DropdownMenuTrigger, Q as DropdownMenuContent, R as DropdownMenuItem, S as Skeleton, B as Button,
|
|
6
|
+
import React__default, { createContext, useReducer, useEffect, useDebugValue, useCallback, useContext, useMemo, Component, Children, useRef, useState, Suspense, createElement, memo, lazy } from "react";
|
|
7
|
+
import { O as DropdownMenu, P as DropdownMenuTrigger, Q as DropdownMenuContent, R as DropdownMenuItem, S as Skeleton, B as Button, H as Dialog, I as DialogTrigger, J as DialogContent, a7 as Popover, ak as Tooltip, al as TooltipTrigger, a8 as PopoverTrigger, am as TooltipContent, a9 as PopoverContent, v as Command, x as CommandInput, y as CommandList, z as CommandEmpty, D as CommandGroup, E as CommandItem, K as DialogHeader, M as DialogTitle, n as Badge, V as DropdownMenuLabel, W as DropdownMenuSeparator, T as DropdownMenuCheckboxItem, a2 as HoverCard, a3 as HoverCardTrigger, a4 as HoverCardContent, aj as Textarea, a5 as Input$1, ao as TooltipPortal, a as AccordionItem, b as AccordionTrigger, d as AccordionContent, A as Accordion, C as Card, q as CardHeader, t as CardDescription, u as CardContent, a6 as Label, r as CardFooter, aa as ScrollArea, af as Tabs, ag as TabsList, ah as TabsTrigger, ai as TabsContent, e as AlertDialog, f as AlertDialogTrigger, g as AlertDialogContent, h as AlertDialogHeader, j as AlertDialogTitle, k as AlertDialogDescription, i as AlertDialogFooter, m as AlertDialogCancel, l as AlertDialogAction, ae as Switch, ac as Separator, an as TooltipProvider, ad as Toaster } from "./tooltip-PKiP886L.js";
|
|
8
8
|
import { atom as atom$1, useAtomValue as useAtomValue$1, useAtom as useAtom$1, getDefaultStore as getDefaultStore$1, useSetAtom as useSetAtom$1, Provider } from "jotai";
|
|
9
|
-
import { find, filter, flatten, map, omit, isString, has, get, isObject, memoize, compact, isEmpty, noop, includes, without, each, first, keys, range, values, flattenDeep, set, startsWith, forEach, unset, chunk, cloneDeep, pick, isNull, findIndex, throttle, isFunction as isFunction$1, reverse,
|
|
9
|
+
import { find, filter, flatten, map, omit, isString, has, get, isObject, memoize, compact, isEmpty, noop, includes, without, each, first, keys, range, values, flattenDeep, set, startsWith, forEach, unset, chunk, cloneDeep, pick, isNull, findIndex, throttle, isFunction as isFunction$1, reverse, split, take, startCase, debounce, toUpper, toLower, nth, isNumber, parseInt as parseInt$1, isNaN as isNaN$1, findLast, intersection, capitalize, groupBy, uniq, flatMapDeep, some, reject, sortBy, round } from "lodash-es";
|
|
10
10
|
import { Provider as Provider$1 } from "react-wrap-balancer";
|
|
11
11
|
import { useTranslation, initReactI18next } from "react-i18next";
|
|
12
12
|
import { useTranslation as He } from "react-i18next";
|
|
13
13
|
import { g as generateUUID, a as getBreakpointValue, c as cn$1 } from "./Functions-BGzDsf1z.js";
|
|
14
14
|
import { flip } from "@floating-ui/dom";
|
|
15
15
|
import { useFloating, shift } from "@floating-ui/react-dom";
|
|
16
|
-
import { PinTopIcon, PinBottomIcon, PinLeftIcon, PinRightIcon, ArrowUpIcon, PlusIcon, CopyIcon, TrashIcon, DragHandleDots2Icon, BoxModelIcon, DotsVerticalIcon, MobileIcon, LaptopIcon, DesktopIcon, Cross2Icon, EyeOpenIcon, EyeClosedIcon, BorderAllIcon, WidthIcon, HeightIcon, ArrowRightIcon, ArrowDownIcon, ArrowLeftIcon, ArrowTopLeftIcon, ArrowTopRightIcon, ArrowBottomRightIcon, ArrowBottomLeftIcon, AlignLeftIcon, AlignCenterHorizontallyIcon, AlignRightIcon, StretchHorizontallyIcon, FontItalicIcon, UnderlineIcon, OverlineIcon, LetterCaseUppercaseIcon, Cross1Icon,
|
|
16
|
+
import { PinTopIcon, PinBottomIcon, PinLeftIcon, PinRightIcon, ArrowUpIcon, PlusIcon, CopyIcon, TrashIcon, DragHandleDots2Icon, BoxModelIcon, DotsVerticalIcon, MobileIcon, LaptopIcon, DesktopIcon, Cross2Icon, InfoCircledIcon, EyeOpenIcon, EyeClosedIcon, BorderAllIcon, WidthIcon, HeightIcon, ArrowRightIcon, ArrowDownIcon, ArrowLeftIcon, ArrowTopLeftIcon, ArrowTopRightIcon, ArrowBottomRightIcon, ArrowBottomLeftIcon, AlignLeftIcon, AlignCenterHorizontallyIcon, AlignRightIcon, StretchHorizontallyIcon, FontItalicIcon, UnderlineIcon, OverlineIcon, LetterCaseUppercaseIcon, Cross1Icon, BoxIcon, MinusIcon, TriangleDownIcon, RowSpacingIcon, CrossCircledIcon, CaretRightIcon, CardStackIcon, CardStackPlusIcon, ScissorsIcon, CheckIcon, SunIcon, ResetIcon, EraserIcon, ZoomInIcon, MixerHorizontalIcon, LightningBoltIcon } from "@radix-ui/react-icons";
|
|
17
17
|
import { useThrottledCallback, useDebouncedCallback, useResizeObserver, useIntervalEffect } from "@react-hookz/web";
|
|
18
18
|
import { useFeature, FlagsProvider } from "flagged";
|
|
19
19
|
import { getRegisteredChaiBlock, getDefaultBlockProps, useRegisteredChaiBlocks, getBlockFormSchemas, syncBlocksWithDefaults } from "@chaibuilder/runtime";
|
|
20
20
|
import { registerChaiBlock as Ue } from "@chaibuilder/runtime";
|
|
21
21
|
import { e as getDefaultExportFromCjs, d as defaultThemeOptions, g as getChaiThemeOptions, p as plugin, a as getChaiThemeCssVariables, c as getThemeFontsLinkMarkup } from "./ChaiThemeFn-Cort9tch.js";
|
|
22
|
-
import TreeModel from "tree-model";
|
|
23
|
-
import { useHotkeys } from "react-hotkeys-hook";
|
|
24
|
-
import { toast } from "sonner";
|
|
25
22
|
import { PlusIcon as PlusIcon$1, ChevronRight, DatabaseIcon, ChevronLeft, Bold, Italic, Underline as Underline$1, Strikethrough, List, ListOrdered, AlignLeft, AlignCenter, AlignRight, Link as Link$1, Unlink, Maximize2, X, Plus, PlusCircle, ChevronDown, Loader, SparklesIcon, Globe, PencilIcon, FileJson, Zap, EyeOff, MoreVertical, Eye, ChevronsDown, ChevronsUp, Languages, FileEdit, Recycle, SmileIcon, ShuffleIcon, Moon, DatabaseZapIcon, Edit2, Paintbrush, Layers } from "lucide-react";
|
|
26
|
-
import { useEditor, EditorContent } from "@tiptap/react";
|
|
27
|
-
import StarterKit from "@tiptap/starter-kit";
|
|
28
|
-
import typography from "@tailwindcss/typography";
|
|
29
|
-
import forms from "@tailwindcss/forms";
|
|
30
|
-
import aspectRatio from "@tailwindcss/aspect-ratio";
|
|
31
|
-
import containerQueries from "@tailwindcss/container-queries";
|
|
32
|
-
import { twMerge } from "tailwind-merge";
|
|
33
|
-
import { S as STYLES_KEY, g as getSplitChaiClasses, R as ROOT_TEMP_KEY } from "./getSplitClasses-DphwgQiE.js";
|
|
34
|
-
import ReactDOM from "react-dom";
|
|
35
|
-
import { ErrorBoundary } from "react-error-boundary";
|
|
36
|
-
import { Resizable } from "re-resizable";
|
|
37
23
|
import RjForm from "@rjsf/core";
|
|
38
24
|
import validator from "@rjsf/validator-ajv8";
|
|
39
25
|
import Link from "@tiptap/extension-link";
|
|
40
26
|
import TextAlign from "@tiptap/extension-text-align";
|
|
41
27
|
import Underline from "@tiptap/extension-underline";
|
|
28
|
+
import { useEditor, EditorContent } from "@tiptap/react";
|
|
29
|
+
import StarterKit from "@tiptap/starter-kit";
|
|
42
30
|
import clsx$1, { clsx } from "clsx";
|
|
31
|
+
import { twMerge } from "tailwind-merge";
|
|
43
32
|
import Autosuggest from "react-autosuggest";
|
|
33
|
+
import { toast } from "sonner";
|
|
44
34
|
import Fuse from "fuse.js";
|
|
35
|
+
import { S as STYLES_KEY, g as getSplitChaiClasses, R as ROOT_TEMP_KEY } from "./getSplitClasses-DphwgQiE.js";
|
|
45
36
|
import { parse, stringify } from "himalaya";
|
|
46
37
|
import { Tree } from "react-arborist";
|
|
47
38
|
import i18n from "i18next";
|
|
48
39
|
import { default as ze } from "i18next";
|
|
40
|
+
import { ErrorBoundary } from "react-error-boundary";
|
|
41
|
+
import { useHotkeys } from "react-hotkeys-hook";
|
|
49
42
|
import { motion } from "framer-motion";
|
|
43
|
+
import TreeModel from "tree-model";
|
|
44
|
+
import typography from "@tailwindcss/typography";
|
|
45
|
+
import forms from "@tailwindcss/forms";
|
|
46
|
+
import aspectRatio from "@tailwindcss/aspect-ratio";
|
|
47
|
+
import containerQueries from "@tailwindcss/container-queries";
|
|
48
|
+
import ReactDOM from "react-dom";
|
|
49
|
+
import { Resizable } from "re-resizable";
|
|
50
50
|
const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInitialValue = (o) => "init" in o, isActuallyWritableAtom = (o) => !!o.write, isAtomStateInitialized = (o) => "v" in o || "e" in o, returnAtomValue = (o) => {
|
|
51
51
|
if ("e" in o)
|
|
52
52
|
throw o.e;
|
|
@@ -93,65 +93,65 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
|
|
|
93
93
|
for (const i of n.p)
|
|
94
94
|
l.add(i);
|
|
95
95
|
return l;
|
|
96
|
-
}, BUILDING_BLOCKS = Symbol(), buildStore = (o = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakMap(), r = /* @__PURE__ */ new WeakMap(), a = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), c = {}, d = (
|
|
97
|
-
var
|
|
98
|
-
return (
|
|
99
|
-
}, g = (
|
|
100
|
-
var
|
|
101
|
-
return (
|
|
96
|
+
}, BUILDING_BLOCKS = Symbol(), buildStore = (o = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakMap(), r = /* @__PURE__ */ new WeakMap(), a = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), c = {}, d = (h, ...f) => h.read(...f), p = (h, ...f) => h.write(...f), u = (h, f) => {
|
|
97
|
+
var x;
|
|
98
|
+
return (x = h.unstable_onInit) == null ? void 0 : x.call(h, f);
|
|
99
|
+
}, g = (h, f) => {
|
|
100
|
+
var x;
|
|
101
|
+
return (x = h.onMount) == null ? void 0 : x.call(h, f);
|
|
102
102
|
}, ...m) => {
|
|
103
|
-
const
|
|
104
|
-
let L = o.get(
|
|
105
|
-
return L || (L = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, o.set(
|
|
103
|
+
const h = m[0] || ((B) => {
|
|
104
|
+
let L = o.get(B);
|
|
105
|
+
return L || (L = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, o.set(B, L), u == null || u(B, C)), L;
|
|
106
106
|
}), f = m[1] || (() => {
|
|
107
|
-
let
|
|
107
|
+
let B, L;
|
|
108
108
|
const v = (y) => {
|
|
109
109
|
try {
|
|
110
110
|
y();
|
|
111
|
-
} catch (
|
|
112
|
-
|
|
111
|
+
} catch (_) {
|
|
112
|
+
B || (B = !0, L = _);
|
|
113
113
|
}
|
|
114
114
|
};
|
|
115
115
|
do {
|
|
116
116
|
c.f && v(c.f);
|
|
117
|
-
const y = /* @__PURE__ */ new Set(),
|
|
117
|
+
const y = /* @__PURE__ */ new Set(), _ = y.add.bind(y);
|
|
118
118
|
a.forEach((T) => {
|
|
119
119
|
var I;
|
|
120
|
-
return (I = n.get(T)) == null ? void 0 : I.l.forEach(
|
|
121
|
-
}), a.clear(), i.forEach(
|
|
120
|
+
return (I = n.get(T)) == null ? void 0 : I.l.forEach(_);
|
|
121
|
+
}), a.clear(), i.forEach(_), i.clear(), l.forEach(_), l.clear(), y.forEach(v), a.size && x();
|
|
122
122
|
} while (a.size || i.size || l.size);
|
|
123
|
-
if (
|
|
123
|
+
if (B)
|
|
124
124
|
throw L;
|
|
125
|
-
}),
|
|
126
|
-
const
|
|
125
|
+
}), x = m[2] || (() => {
|
|
126
|
+
const B = [], L = /* @__PURE__ */ new WeakSet(), v = /* @__PURE__ */ new WeakSet(), y = Array.from(a);
|
|
127
127
|
for (; y.length; ) {
|
|
128
|
-
const
|
|
129
|
-
if (v.has(
|
|
128
|
+
const _ = y[y.length - 1], T = h(_);
|
|
129
|
+
if (v.has(_)) {
|
|
130
130
|
y.pop();
|
|
131
131
|
continue;
|
|
132
132
|
}
|
|
133
|
-
if (L.has(
|
|
134
|
-
r.get(
|
|
133
|
+
if (L.has(_)) {
|
|
134
|
+
r.get(_) === T.n && B.push([_, T]), v.add(_), y.pop();
|
|
135
135
|
continue;
|
|
136
136
|
}
|
|
137
|
-
L.add(
|
|
138
|
-
for (const I of getMountedOrPendingDependents(
|
|
137
|
+
L.add(_);
|
|
138
|
+
for (const I of getMountedOrPendingDependents(_, T, n))
|
|
139
139
|
L.has(I) || y.push(I);
|
|
140
140
|
}
|
|
141
|
-
for (let
|
|
142
|
-
const [T, I] =
|
|
141
|
+
for (let _ = B.length - 1; _ >= 0; --_) {
|
|
142
|
+
const [T, I] = B[_];
|
|
143
143
|
let R = !1;
|
|
144
144
|
for (const P of I.d.keys())
|
|
145
145
|
if (P !== T && a.has(P)) {
|
|
146
146
|
R = !0;
|
|
147
147
|
break;
|
|
148
148
|
}
|
|
149
|
-
R && (b(T),
|
|
149
|
+
R && (b(T), S(T)), r.delete(T);
|
|
150
150
|
}
|
|
151
|
-
}), b = m[3] || ((
|
|
151
|
+
}), b = m[3] || ((B) => {
|
|
152
152
|
var L, v;
|
|
153
|
-
const y =
|
|
154
|
-
if (isAtomStateInitialized(y) && (n.has(
|
|
153
|
+
const y = h(B);
|
|
154
|
+
if (isAtomStateInitialized(y) && (n.has(B) && r.get(B) !== y.n || Array.from(y.d).every(
|
|
155
155
|
([D, O]) => (
|
|
156
156
|
// Recursively, read the atom state of the dependency, and
|
|
157
157
|
// check if the atom epoch number is unchanged
|
|
@@ -160,16 +160,16 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
|
|
|
160
160
|
)))
|
|
161
161
|
return y;
|
|
162
162
|
y.d.clear();
|
|
163
|
-
let
|
|
163
|
+
let _ = !0;
|
|
164
164
|
const T = () => {
|
|
165
|
-
n.has(
|
|
165
|
+
n.has(B) && (S(B), x(), f());
|
|
166
166
|
}, I = (D) => {
|
|
167
167
|
var O;
|
|
168
|
-
if (isSelfAtom(
|
|
169
|
-
const H =
|
|
168
|
+
if (isSelfAtom(B, D)) {
|
|
169
|
+
const H = h(D);
|
|
170
170
|
if (!isAtomStateInitialized(H))
|
|
171
171
|
if (hasInitialValue(D))
|
|
172
|
-
setAtomStateValueOrPromise(D, D.init,
|
|
172
|
+
setAtomStateValueOrPromise(D, D.init, h);
|
|
173
173
|
else
|
|
174
174
|
throw new Error("no atom init");
|
|
175
175
|
return returnAtomValue(H);
|
|
@@ -178,7 +178,7 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
|
|
|
178
178
|
try {
|
|
179
179
|
return returnAtomValue($);
|
|
180
180
|
} finally {
|
|
181
|
-
y.d.set(D, $.n), isPendingPromise(y.v) && addPendingPromiseToDependency(
|
|
181
|
+
y.d.set(D, $.n), isPendingPromise(y.v) && addPendingPromiseToDependency(B, y.v, $), (O = n.get(D)) == null || O.t.add(B), _ || T();
|
|
182
182
|
}
|
|
183
183
|
};
|
|
184
184
|
let R, P;
|
|
@@ -187,99 +187,99 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
|
|
|
187
187
|
return R || (R = new AbortController()), R.signal;
|
|
188
188
|
},
|
|
189
189
|
get setSelf() {
|
|
190
|
-
return !P && isActuallyWritableAtom(
|
|
191
|
-
if (!
|
|
190
|
+
return !P && isActuallyWritableAtom(B) && (P = (...D) => {
|
|
191
|
+
if (!_)
|
|
192
192
|
try {
|
|
193
|
-
return
|
|
193
|
+
return w(B, ...D);
|
|
194
194
|
} finally {
|
|
195
|
-
|
|
195
|
+
x(), f();
|
|
196
196
|
}
|
|
197
197
|
}), P;
|
|
198
198
|
}
|
|
199
199
|
}, M = y.n;
|
|
200
200
|
try {
|
|
201
|
-
const D = d(
|
|
202
|
-
return setAtomStateValueOrPromise(
|
|
201
|
+
const D = d(B, I, N);
|
|
202
|
+
return setAtomStateValueOrPromise(B, D, h), isPromiseLike$2(D) && ((L = D.onCancel) == null || L.call(D, () => R == null ? void 0 : R.abort()), D.then(
|
|
203
203
|
T,
|
|
204
204
|
T
|
|
205
205
|
)), y;
|
|
206
206
|
} catch (D) {
|
|
207
207
|
return delete y.v, y.e = D, ++y.n, y;
|
|
208
208
|
} finally {
|
|
209
|
-
|
|
209
|
+
_ = !1, M !== y.n && r.get(B) === M && (r.set(B, y.n), a.add(B), (v = c.c) == null || v.call(c, B));
|
|
210
210
|
}
|
|
211
|
-
}), k = m[4] || ((
|
|
212
|
-
const L = [
|
|
211
|
+
}), k = m[4] || ((B) => {
|
|
212
|
+
const L = [B];
|
|
213
213
|
for (; L.length; ) {
|
|
214
|
-
const v = L.pop(), y =
|
|
215
|
-
for (const
|
|
216
|
-
const T =
|
|
217
|
-
r.set(
|
|
214
|
+
const v = L.pop(), y = h(v);
|
|
215
|
+
for (const _ of getMountedOrPendingDependents(v, y, n)) {
|
|
216
|
+
const T = h(_);
|
|
217
|
+
r.set(_, T.n), L.push(_);
|
|
218
218
|
}
|
|
219
219
|
}
|
|
220
|
-
}),
|
|
220
|
+
}), w = m[5] || ((B, ...L) => {
|
|
221
221
|
let v = !0;
|
|
222
|
-
const y = (T) => returnAtomValue(b(T)),
|
|
222
|
+
const y = (T) => returnAtomValue(b(T)), _ = (T, ...I) => {
|
|
223
223
|
var R;
|
|
224
|
-
const P =
|
|
224
|
+
const P = h(T);
|
|
225
225
|
try {
|
|
226
|
-
if (isSelfAtom(
|
|
226
|
+
if (isSelfAtom(B, T)) {
|
|
227
227
|
if (!hasInitialValue(T))
|
|
228
228
|
throw new Error("atom not writable");
|
|
229
229
|
const N = P.n, M = I[0];
|
|
230
|
-
setAtomStateValueOrPromise(T, M,
|
|
230
|
+
setAtomStateValueOrPromise(T, M, h), S(T), N !== P.n && (a.add(T), (R = c.c) == null || R.call(c, T), k(T));
|
|
231
231
|
return;
|
|
232
232
|
} else
|
|
233
|
-
return
|
|
233
|
+
return w(T, ...I);
|
|
234
234
|
} finally {
|
|
235
|
-
v || (
|
|
235
|
+
v || (x(), f());
|
|
236
236
|
}
|
|
237
237
|
};
|
|
238
238
|
try {
|
|
239
|
-
return p(
|
|
239
|
+
return p(B, y, _, ...L);
|
|
240
240
|
} finally {
|
|
241
241
|
v = !1;
|
|
242
242
|
}
|
|
243
|
-
}),
|
|
243
|
+
}), S = m[6] || ((B) => {
|
|
244
244
|
var L;
|
|
245
|
-
const v =
|
|
245
|
+
const v = h(B), y = n.get(B);
|
|
246
246
|
if (y && !isPendingPromise(v.v)) {
|
|
247
|
-
for (const [
|
|
248
|
-
if (!y.d.has(
|
|
249
|
-
const I =
|
|
250
|
-
|
|
247
|
+
for (const [_, T] of v.d)
|
|
248
|
+
if (!y.d.has(_)) {
|
|
249
|
+
const I = h(_);
|
|
250
|
+
A(_).t.add(B), y.d.add(_), T !== I.n && (a.add(_), (L = c.c) == null || L.call(c, _), k(_));
|
|
251
251
|
}
|
|
252
|
-
for (const
|
|
253
|
-
if (!v.d.has(
|
|
254
|
-
y.d.delete(
|
|
255
|
-
const T =
|
|
256
|
-
T == null || T.t.delete(
|
|
252
|
+
for (const _ of y.d || [])
|
|
253
|
+
if (!v.d.has(_)) {
|
|
254
|
+
y.d.delete(_);
|
|
255
|
+
const T = E(_);
|
|
256
|
+
T == null || T.t.delete(B);
|
|
257
257
|
}
|
|
258
258
|
}
|
|
259
|
-
}),
|
|
259
|
+
}), A = m[7] || ((B) => {
|
|
260
260
|
var L;
|
|
261
|
-
const v =
|
|
262
|
-
let y = n.get(
|
|
261
|
+
const v = h(B);
|
|
262
|
+
let y = n.get(B);
|
|
263
263
|
if (!y) {
|
|
264
|
-
b(
|
|
265
|
-
for (const
|
|
266
|
-
|
|
264
|
+
b(B);
|
|
265
|
+
for (const _ of v.d.keys())
|
|
266
|
+
A(_).t.add(B);
|
|
267
267
|
if (y = {
|
|
268
268
|
l: /* @__PURE__ */ new Set(),
|
|
269
269
|
d: new Set(v.d.keys()),
|
|
270
270
|
t: /* @__PURE__ */ new Set()
|
|
271
|
-
}, n.set(
|
|
272
|
-
const
|
|
271
|
+
}, n.set(B, y), (L = c.m) == null || L.call(c, B), isActuallyWritableAtom(B)) {
|
|
272
|
+
const _ = () => {
|
|
273
273
|
let T = !0;
|
|
274
274
|
const I = (...R) => {
|
|
275
275
|
try {
|
|
276
|
-
return
|
|
276
|
+
return w(B, ...R);
|
|
277
277
|
} finally {
|
|
278
|
-
T || (
|
|
278
|
+
T || (x(), f());
|
|
279
279
|
}
|
|
280
280
|
};
|
|
281
281
|
try {
|
|
282
|
-
const R = g(
|
|
282
|
+
const R = g(B, I);
|
|
283
283
|
R && (y.u = () => {
|
|
284
284
|
T = !0;
|
|
285
285
|
try {
|
|
@@ -292,27 +292,27 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
|
|
|
292
292
|
T = !1;
|
|
293
293
|
}
|
|
294
294
|
};
|
|
295
|
-
l.add(
|
|
295
|
+
l.add(_);
|
|
296
296
|
}
|
|
297
297
|
}
|
|
298
298
|
return y;
|
|
299
|
-
}),
|
|
299
|
+
}), E = m[8] || ((B) => {
|
|
300
300
|
var L;
|
|
301
|
-
const v =
|
|
302
|
-
let y = n.get(
|
|
303
|
-
if (y && !y.l.size && !Array.from(y.t).some((
|
|
301
|
+
const v = h(B);
|
|
302
|
+
let y = n.get(B);
|
|
303
|
+
if (y && !y.l.size && !Array.from(y.t).some((_) => {
|
|
304
304
|
var T;
|
|
305
|
-
return (T = n.get(
|
|
305
|
+
return (T = n.get(_)) == null ? void 0 : T.d.has(B);
|
|
306
306
|
})) {
|
|
307
|
-
y.u && i.add(y.u), y = void 0, n.delete(
|
|
308
|
-
for (const
|
|
309
|
-
const T =
|
|
310
|
-
T == null || T.t.delete(
|
|
307
|
+
y.u && i.add(y.u), y = void 0, n.delete(B), (L = c.u) == null || L.call(c, B);
|
|
308
|
+
for (const _ of v.d.keys()) {
|
|
309
|
+
const T = E(_);
|
|
310
|
+
T == null || T.t.delete(B);
|
|
311
311
|
}
|
|
312
312
|
return;
|
|
313
313
|
}
|
|
314
314
|
return y;
|
|
315
|
-
}),
|
|
315
|
+
}), j = [
|
|
316
316
|
// store state
|
|
317
317
|
o,
|
|
318
318
|
n,
|
|
@@ -327,32 +327,32 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
|
|
|
327
327
|
u,
|
|
328
328
|
g,
|
|
329
329
|
// building-block functions
|
|
330
|
-
x,
|
|
331
|
-
f,
|
|
332
330
|
h,
|
|
331
|
+
f,
|
|
332
|
+
x,
|
|
333
333
|
b,
|
|
334
334
|
k,
|
|
335
|
+
w,
|
|
336
|
+
S,
|
|
335
337
|
A,
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
get: (w) => returnAtomValue(b(w)),
|
|
341
|
-
set: (w, ...L) => {
|
|
338
|
+
E
|
|
339
|
+
], C = {
|
|
340
|
+
get: (B) => returnAtomValue(b(B)),
|
|
341
|
+
set: (B, ...L) => {
|
|
342
342
|
try {
|
|
343
|
-
return
|
|
343
|
+
return w(B, ...L);
|
|
344
344
|
} finally {
|
|
345
|
-
|
|
345
|
+
x(), f();
|
|
346
346
|
}
|
|
347
347
|
},
|
|
348
|
-
sub: (
|
|
349
|
-
const y =
|
|
348
|
+
sub: (B, L) => {
|
|
349
|
+
const y = A(B).l;
|
|
350
350
|
return y.add(L), f(), () => {
|
|
351
|
-
y.delete(L),
|
|
351
|
+
y.delete(L), E(B), f();
|
|
352
352
|
};
|
|
353
353
|
}
|
|
354
354
|
};
|
|
355
|
-
return Object.defineProperty(
|
|
355
|
+
return Object.defineProperty(C, BUILDING_BLOCKS, { value: j }), C;
|
|
356
356
|
}, INTERNAL_buildStoreRev1 = buildStore;
|
|
357
357
|
let keyCount = 0;
|
|
358
358
|
function atom(o, n) {
|
|
@@ -388,36 +388,36 @@ function splitAtom(o, n) {
|
|
|
388
388
|
if (p)
|
|
389
389
|
return p;
|
|
390
390
|
const u = d && r.get(d), g = [], m = [];
|
|
391
|
-
return c.forEach((
|
|
392
|
-
const
|
|
393
|
-
m[f] =
|
|
394
|
-
const b = u && u.atomList[u.keyList.indexOf(
|
|
391
|
+
return c.forEach((h, f) => {
|
|
392
|
+
const x = f;
|
|
393
|
+
m[f] = x;
|
|
394
|
+
const b = u && u.atomList[u.keyList.indexOf(x)];
|
|
395
395
|
if (b) {
|
|
396
396
|
g[f] = b;
|
|
397
397
|
return;
|
|
398
398
|
}
|
|
399
|
-
const k = (
|
|
400
|
-
const
|
|
401
|
-
if (
|
|
402
|
-
const
|
|
403
|
-
if (
|
|
404
|
-
return
|
|
399
|
+
const k = (S) => {
|
|
400
|
+
const A = S(l), E = S(o), C = a(E, A == null ? void 0 : A.arr).keyList.indexOf(x);
|
|
401
|
+
if (C < 0 || C >= E.length) {
|
|
402
|
+
const B = c[a(c).keyList.indexOf(x)];
|
|
403
|
+
if (B)
|
|
404
|
+
return B;
|
|
405
405
|
throw new Error("splitAtom: index out of bounds for read");
|
|
406
406
|
}
|
|
407
|
-
return
|
|
408
|
-
},
|
|
409
|
-
const
|
|
410
|
-
if (L < 0 || L >=
|
|
407
|
+
return E[C];
|
|
408
|
+
}, w = (S, A, E) => {
|
|
409
|
+
const j = S(l), C = S(o), L = a(C, j == null ? void 0 : j.arr).keyList.indexOf(x);
|
|
410
|
+
if (L < 0 || L >= C.length)
|
|
411
411
|
throw new Error("splitAtom: index out of bounds for write");
|
|
412
|
-
const v = isFunction(
|
|
413
|
-
Object.is(
|
|
414
|
-
...
|
|
412
|
+
const v = isFunction(E) ? E(C[L]) : E;
|
|
413
|
+
Object.is(C[L], v) || A(o, [
|
|
414
|
+
...C.slice(0, L),
|
|
415
415
|
v,
|
|
416
|
-
...
|
|
416
|
+
...C.slice(L + 1)
|
|
417
417
|
]);
|
|
418
418
|
};
|
|
419
|
-
g[f] = isWritable(o) ? atom(k,
|
|
420
|
-
}), u && u.keyList.length === m.length && u.keyList.every((
|
|
419
|
+
g[f] = isWritable(o) ? atom(k, w) : atom(k);
|
|
420
|
+
}), u && u.keyList.length === m.length && u.keyList.every((h, f) => h === m[f]) ? p = u : p = { arr: c, atomList: g, keyList: m }, r.set(c, p), p;
|
|
421
421
|
}, l = atom((c) => {
|
|
422
422
|
const d = c(l), p = c(o);
|
|
423
423
|
return a(p, d == null ? void 0 : d.arr);
|
|
@@ -490,18 +490,18 @@ function createJSONStorage(o = () => {
|
|
|
490
490
|
const i = {
|
|
491
491
|
getItem: (p, u) => {
|
|
492
492
|
var g, m;
|
|
493
|
-
const
|
|
494
|
-
if (
|
|
493
|
+
const h = (x) => {
|
|
494
|
+
if (x = x || "", a !== x) {
|
|
495
495
|
try {
|
|
496
|
-
l = JSON.parse(
|
|
496
|
+
l = JSON.parse(x, n == null ? void 0 : n.reviver);
|
|
497
497
|
} catch {
|
|
498
498
|
return u;
|
|
499
499
|
}
|
|
500
|
-
a =
|
|
500
|
+
a = x;
|
|
501
501
|
}
|
|
502
502
|
return l;
|
|
503
503
|
}, f = (m = (g = o()) == null ? void 0 : g.getItem(p)) != null ? m : null;
|
|
504
|
-
return isPromiseLike$1(f) ? f.then(
|
|
504
|
+
return isPromiseLike$1(f) ? f.then(h) : h(f);
|
|
505
505
|
},
|
|
506
506
|
setItem: (p, u) => {
|
|
507
507
|
var g;
|
|
@@ -514,10 +514,10 @@ function createJSONStorage(o = () => {
|
|
|
514
514
|
var u;
|
|
515
515
|
return (u = o()) == null ? void 0 : u.removeItem(p);
|
|
516
516
|
}
|
|
517
|
-
}, c = (p) => (u, g, m) => p(u, (
|
|
517
|
+
}, c = (p) => (u, g, m) => p(u, (h) => {
|
|
518
518
|
let f;
|
|
519
519
|
try {
|
|
520
|
-
f = JSON.parse(
|
|
520
|
+
f = JSON.parse(h || "");
|
|
521
521
|
} catch {
|
|
522
522
|
f = m;
|
|
523
523
|
}
|
|
@@ -1157,15 +1157,15 @@ const useSelectedBlocksDisplayChild = () => ({
|
|
|
1157
1157
|
if (!p || !p._parent) return;
|
|
1158
1158
|
const u = p._parent, g = r.filter((m) => m._parent === u);
|
|
1159
1159
|
if (g.length === 2) {
|
|
1160
|
-
const m = g.find((
|
|
1160
|
+
const m = g.find((h) => h._id !== d);
|
|
1161
1161
|
if (m && m._type === "Text") {
|
|
1162
|
-
const
|
|
1163
|
-
|
|
1162
|
+
const h = r.find((f) => f._id === u);
|
|
1163
|
+
h && "content" in h && (r = r.map((f) => {
|
|
1164
1164
|
if (f._id === u) {
|
|
1165
|
-
const
|
|
1165
|
+
const x = { ...f, content: m.content };
|
|
1166
1166
|
return Object.keys(m).forEach((b) => {
|
|
1167
|
-
b.startsWith("content-") && (
|
|
1168
|
-
}),
|
|
1167
|
+
b.startsWith("content-") && (x[b] = m[b]);
|
|
1168
|
+
}), x;
|
|
1169
1169
|
}
|
|
1170
1170
|
return f;
|
|
1171
1171
|
}), a.push(m._id));
|
|
@@ -1233,20 +1233,20 @@ function insertBlocksAtPosition(o, n, r, a) {
|
|
|
1233
1233
|
if (r) {
|
|
1234
1234
|
const u = o.find((g) => g._id === r);
|
|
1235
1235
|
if (u && u.content !== void 0 && u.content !== "" && !o.some((m) => m._parent === r)) {
|
|
1236
|
-
const
|
|
1236
|
+
const h = {
|
|
1237
1237
|
_id: generateUUID(),
|
|
1238
1238
|
_parent: r,
|
|
1239
1239
|
_type: "Text",
|
|
1240
1240
|
content: u.content
|
|
1241
1241
|
};
|
|
1242
1242
|
Object.keys(u).forEach((f) => {
|
|
1243
|
-
f.startsWith("content-") && (
|
|
1244
|
-
}), l.unshift(
|
|
1243
|
+
f.startsWith("content-") && (h[f] = u[f]);
|
|
1244
|
+
}), l.unshift(h), i = i.map((f) => {
|
|
1245
1245
|
if (f._id === r) {
|
|
1246
|
-
const
|
|
1247
|
-
return Object.keys(
|
|
1248
|
-
b.startsWith("content-") && (
|
|
1249
|
-
}),
|
|
1246
|
+
const x = { ...f, content: "" };
|
|
1247
|
+
return Object.keys(x).forEach((b) => {
|
|
1248
|
+
b.startsWith("content-") && (x[b] = "");
|
|
1249
|
+
}), x;
|
|
1250
1250
|
}
|
|
1251
1251
|
return f;
|
|
1252
1252
|
});
|
|
@@ -1396,68 +1396,84 @@ const useBlocksStoreManager = () => {
|
|
|
1396
1396
|
updateBlocksProps: c
|
|
1397
1397
|
} = useBlocksStoreManager();
|
|
1398
1398
|
return {
|
|
1399
|
-
moveBlocks: (
|
|
1400
|
-
const
|
|
1401
|
-
const
|
|
1402
|
-
return { _id:
|
|
1403
|
-
}),
|
|
1404
|
-
|
|
1405
|
-
undo: () => each(
|
|
1406
|
-
i([
|
|
1399
|
+
moveBlocks: (x, b, k) => {
|
|
1400
|
+
const w = map(x, (A) => {
|
|
1401
|
+
const j = n.find((L) => L._id === A)._parent || null, B = n.filter((L) => j ? L._parent === j : !L._parent).map((L) => L._id).indexOf(A);
|
|
1402
|
+
return { _id: A, oldParent: j, oldPosition: B };
|
|
1403
|
+
}), S = w.find(({ _id: A }) => A === x[0]);
|
|
1404
|
+
S && S.oldParent === b && S.oldPosition === k || (i(x, b, k), o({
|
|
1405
|
+
undo: () => each(w, ({ _id: A, oldParent: E, oldPosition: j }) => {
|
|
1406
|
+
i([A], E, j);
|
|
1407
1407
|
}),
|
|
1408
|
-
redo: () => i(
|
|
1408
|
+
redo: () => i(x, b, k)
|
|
1409
1409
|
}));
|
|
1410
1410
|
},
|
|
1411
|
-
addBlocks: (
|
|
1412
|
-
a(
|
|
1413
|
-
undo: () => l(map(
|
|
1414
|
-
redo: () => a(
|
|
1411
|
+
addBlocks: (x, b, k) => {
|
|
1412
|
+
a(x, b, k), o({
|
|
1413
|
+
undo: () => l(map(x, "_id")),
|
|
1414
|
+
redo: () => a(x, b, k)
|
|
1415
1415
|
});
|
|
1416
1416
|
},
|
|
1417
|
-
removeBlocks: (
|
|
1418
|
-
var
|
|
1419
|
-
const b = (
|
|
1420
|
-
l(map(
|
|
1421
|
-
undo: () => a(
|
|
1422
|
-
redo: () => l(map(
|
|
1417
|
+
removeBlocks: (x) => {
|
|
1418
|
+
var S;
|
|
1419
|
+
const b = (S = first(x)) == null ? void 0 : S._parent, w = n.filter((A) => b ? A._parent === b : !A._parent).indexOf(first(x));
|
|
1420
|
+
l(map(x, "_id")), o({
|
|
1421
|
+
undo: () => a(x, b, w),
|
|
1422
|
+
redo: () => l(map(x, "_id"))
|
|
1423
1423
|
});
|
|
1424
1424
|
},
|
|
1425
|
-
updateBlocks: (
|
|
1426
|
-
let
|
|
1425
|
+
updateBlocks: (x, b, k) => {
|
|
1426
|
+
let w = [];
|
|
1427
1427
|
if (k)
|
|
1428
|
-
|
|
1428
|
+
w = map(x, (S) => ({ _id: S, ...k }));
|
|
1429
1429
|
else {
|
|
1430
|
-
const
|
|
1431
|
-
|
|
1432
|
-
const
|
|
1433
|
-
return each(
|
|
1430
|
+
const S = keys(b);
|
|
1431
|
+
w = map(x, (A) => {
|
|
1432
|
+
const E = n.find((C) => C._id === A), j = { _id: A };
|
|
1433
|
+
return each(S, (C) => j[C] = E[C]), j;
|
|
1434
1434
|
});
|
|
1435
1435
|
}
|
|
1436
|
-
c(map(
|
|
1437
|
-
undo: () => c(
|
|
1438
|
-
redo: () => c(map(
|
|
1436
|
+
c(map(x, (S) => ({ _id: S, ...b }))), o({
|
|
1437
|
+
undo: () => c(w),
|
|
1438
|
+
redo: () => c(map(x, (S) => ({ _id: S, ...b })))
|
|
1439
1439
|
});
|
|
1440
1440
|
},
|
|
1441
|
-
updateBlocksRuntime: (
|
|
1442
|
-
c(map(
|
|
1441
|
+
updateBlocksRuntime: (x, b) => {
|
|
1442
|
+
c(map(x, (k) => ({ _id: k, ...b })));
|
|
1443
1443
|
},
|
|
1444
|
-
setNewBlocks: (
|
|
1445
|
-
r(
|
|
1444
|
+
setNewBlocks: (x) => {
|
|
1445
|
+
r(x), o({
|
|
1446
1446
|
undo: () => r(n),
|
|
1447
|
-
redo: () => r(
|
|
1447
|
+
redo: () => r(x)
|
|
1448
1448
|
});
|
|
1449
1449
|
},
|
|
1450
|
-
updateMultipleBlocksProps: (
|
|
1450
|
+
updateMultipleBlocksProps: (x) => {
|
|
1451
1451
|
let b = [];
|
|
1452
|
-
b = map(
|
|
1453
|
-
const
|
|
1454
|
-
return each(
|
|
1455
|
-
}), c(
|
|
1452
|
+
b = map(x, (k) => {
|
|
1453
|
+
const w = keys(k), S = n.find((E) => E._id === k._id), A = {};
|
|
1454
|
+
return each(w, (E) => A[E] = S[E]), A;
|
|
1455
|
+
}), c(x), o({
|
|
1456
1456
|
undo: () => c(b),
|
|
1457
|
-
redo: () => c(
|
|
1457
|
+
redo: () => c(x)
|
|
1458
1458
|
});
|
|
1459
1459
|
}
|
|
1460
1460
|
};
|
|
1461
|
+
}, libraryBlocksAtom = atom$1(
|
|
1462
|
+
{}
|
|
1463
|
+
), useLibraryBlocks = (o) => {
|
|
1464
|
+
const [n, r] = useAtom$1(libraryBlocksAtom), a = useBuilderProp("getUILibraryBlocks", noop), l = get(n, `${o == null ? void 0 : o.id}.blocks`, null), i = get(n, `${o == null ? void 0 : o.id}.loading`, "idle"), c = useRef("idle");
|
|
1465
|
+
useEffect(() => {
|
|
1466
|
+
(async () => {
|
|
1467
|
+
if (i === "complete" || c.current === "loading") return;
|
|
1468
|
+
c.current = "loading", r((u) => ({ ...u, [o == null ? void 0 : o.id]: { loading: "loading", blocks: [] } }));
|
|
1469
|
+
const p = await a(o);
|
|
1470
|
+
c.current = "idle", r((u) => ({ ...u, [o == null ? void 0 : o.id]: { loading: "complete", blocks: p || [] } }));
|
|
1471
|
+
})();
|
|
1472
|
+
}, [o, l, i, c, r, a]);
|
|
1473
|
+
const d = useCallback(() => {
|
|
1474
|
+
r((p) => ({ ...p, [o == null ? void 0 : o.id]: { loading: "idle", blocks: [] } }));
|
|
1475
|
+
}, [o, r]);
|
|
1476
|
+
return { data: l || [], isLoading: i === "loading", resetLibrary: d };
|
|
1461
1477
|
}, canAcceptChildBlock = (o, n) => {
|
|
1462
1478
|
if (!o) return !0;
|
|
1463
1479
|
const r = getRegisteredChaiBlock(o);
|
|
@@ -1490,17 +1506,17 @@ import.meta.vitest && describe("canDropBlock Function", () => {
|
|
|
1490
1506
|
const useAddBlock = () => {
|
|
1491
1507
|
const [o] = useBlocksStore(), [, n] = useSelectedBlockIds(), { addBlocks: r } = useBlocksStoreUndoableActions(), a = useCallback(
|
|
1492
1508
|
(i, c, d) => {
|
|
1493
|
-
var
|
|
1509
|
+
var h;
|
|
1494
1510
|
for (let f = 0; f < i.length; f++) {
|
|
1495
|
-
const { _id:
|
|
1511
|
+
const { _id: x } = i[f];
|
|
1496
1512
|
i[f]._id = generateUUID();
|
|
1497
|
-
const b = filter(i, { _parent:
|
|
1513
|
+
const b = filter(i, { _parent: x });
|
|
1498
1514
|
for (let k = 0; k < b.length; k++)
|
|
1499
1515
|
b[k]._parent = i[f]._id;
|
|
1500
1516
|
}
|
|
1501
1517
|
const p = first(i);
|
|
1502
1518
|
let u, g;
|
|
1503
|
-
return c && (u = find(o, { _id: c }), i[0]._parent = c, g = c), !(u ? canAcceptChildBlock(u == null ? void 0 : u._type, p._type) : !0) && u && (i[0]._parent = u._parent, g = u._parent), r(i, g, d), n([(
|
|
1519
|
+
return c && (u = find(o, { _id: c }), i[0]._parent = c, g = c), !(u ? canAcceptChildBlock(u == null ? void 0 : u._type, p._type) : !0) && u && (i[0]._parent = u._parent, g = u._parent), r(i, g, d), n([(h = first(i)) == null ? void 0 : h._id]), first(i);
|
|
1504
1520
|
},
|
|
1505
1521
|
[r, o, n]
|
|
1506
1522
|
);
|
|
@@ -1517,8 +1533,8 @@ const useAddBlock = () => {
|
|
|
1517
1533
|
...has(i, "_name") && { _name: i._name },
|
|
1518
1534
|
...has(i, "partialBlockId") && { partialBlockId: i.partialBlockId }
|
|
1519
1535
|
};
|
|
1520
|
-
let m,
|
|
1521
|
-
return c && (m = find(o, { _id: c }), g._parent = c,
|
|
1536
|
+
let m, h;
|
|
1537
|
+
return c && (m = find(o, { _id: c }), g._parent = c, h = c), !canAcceptChildBlock(m == null ? void 0 : m._type, g._type) && m && (g._parent = m._parent, h = m._parent), r([g], h, d), n([g._id]), g;
|
|
1522
1538
|
},
|
|
1523
1539
|
[r, a, o, n]
|
|
1524
1540
|
), addPredefinedBlock: a };
|
|
@@ -2964,39 +2980,39 @@ const getBlockWithChildren = (o, n) => {
|
|
|
2964
2980
|
return isEmpty(c) ? !1 : (has(l, "_parent") && isEmpty(l._parent) && delete l._parent, { ...l, ...c });
|
|
2965
2981
|
})
|
|
2966
2982
|
), addLangToPrompt = (o, n, r) => !n || r !== "content" ? o : `${o}. Generate content in ${get(LANGUAGES, n, n)} language.`, askAiProcessingAtom = atom$1(!1), useAskAi = () => {
|
|
2967
|
-
const [o, n] = useAtom$1(askAiProcessingAtom), [r, a] = useState(null), l = useBuilderProp("askAiCallBack", null), i = useStreamMultipleBlocksProps(), c = useUpdateMultipleBlocksProps(), [d] = useBlocksStore(), { selectedLang: p, fallbackLang: u } = useLanguages(), g = p.length ? p : u, m = (
|
|
2968
|
-
const
|
|
2969
|
-
for (const b in
|
|
2970
|
-
const k =
|
|
2983
|
+
const [o, n] = useAtom$1(askAiProcessingAtom), [r, a] = useState(null), l = useBuilderProp("askAiCallBack", null), i = useStreamMultipleBlocksProps(), c = useUpdateMultipleBlocksProps(), [d] = useBlocksStore(), { selectedLang: p, fallbackLang: u } = useLanguages(), g = p.length ? p : u, m = (h, f) => {
|
|
2984
|
+
const x = cloneDeep(f.find((b) => b._id === h));
|
|
2985
|
+
for (const b in x) {
|
|
2986
|
+
const k = x[b];
|
|
2971
2987
|
if (typeof k == "string" && startsWith(k, STYLES_KEY)) {
|
|
2972
|
-
const { baseClasses:
|
|
2973
|
-
|
|
2988
|
+
const { baseClasses: w, classes: S } = getSplitChaiClasses(k);
|
|
2989
|
+
x[b] = compact(flattenDeep([w, S])).join(" ");
|
|
2974
2990
|
} else
|
|
2975
|
-
b !== "_id" && delete
|
|
2991
|
+
b !== "_id" && delete x[b];
|
|
2976
2992
|
}
|
|
2977
|
-
return
|
|
2993
|
+
return x;
|
|
2978
2994
|
};
|
|
2979
2995
|
return {
|
|
2980
2996
|
askAi: useCallback(
|
|
2981
|
-
async (
|
|
2997
|
+
async (h, f, x, b) => {
|
|
2982
2998
|
if (l) {
|
|
2983
2999
|
n(!0), a(null);
|
|
2984
3000
|
try {
|
|
2985
|
-
const k = p === u ? "" : p,
|
|
2986
|
-
if (
|
|
2987
|
-
a(
|
|
3001
|
+
const k = p === u ? "" : p, w = h === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(f, d)), p) : [m(f, d)], S = await l(h, addLangToPrompt(x, g, h), w, k), { blocks: A, error: E } = S;
|
|
3002
|
+
if (E) {
|
|
3003
|
+
a(E);
|
|
2988
3004
|
return;
|
|
2989
3005
|
}
|
|
2990
|
-
if (
|
|
2991
|
-
const
|
|
2992
|
-
for (const
|
|
2993
|
-
|
|
2994
|
-
return
|
|
3006
|
+
if (h === "styles") {
|
|
3007
|
+
const j = A.map((C) => {
|
|
3008
|
+
for (const B in C)
|
|
3009
|
+
B !== "_id" && (C[B] = `${STYLES_KEY},${C[B]}`);
|
|
3010
|
+
return C;
|
|
2995
3011
|
});
|
|
2996
|
-
c(
|
|
3012
|
+
c(j);
|
|
2997
3013
|
} else
|
|
2998
|
-
i(
|
|
2999
|
-
b && b(
|
|
3014
|
+
i(A);
|
|
3015
|
+
b && b(S);
|
|
3000
3016
|
} catch (k) {
|
|
3001
3017
|
a(k);
|
|
3002
3018
|
} finally {
|
|
@@ -3137,11 +3153,11 @@ const useBlockHighlight = () => {
|
|
|
3137
3153
|
(a, l = null) => {
|
|
3138
3154
|
const i = [];
|
|
3139
3155
|
each(a, (c) => {
|
|
3140
|
-
const d = o.find((
|
|
3156
|
+
const d = o.find((h) => h._id === c);
|
|
3141
3157
|
l ? l === "root" && (l = null) : l = d._parent;
|
|
3142
3158
|
const g = filter(
|
|
3143
3159
|
o,
|
|
3144
|
-
(
|
|
3160
|
+
(h) => isString(l) ? h._parent === l : !h._parent
|
|
3145
3161
|
).indexOf(d) + 1, m = getDuplicatedBlocks(o, c, l);
|
|
3146
3162
|
r(m, l, g), i.push(get(m, "0._id", ""));
|
|
3147
3163
|
}), n(i);
|
|
@@ -3237,12 +3253,12 @@ const useBlockHighlight = () => {
|
|
|
3237
3253
|
const d = o(c), p = a;
|
|
3238
3254
|
let { classes: u, baseClasses: g } = getSplitChaiClasses(get(d, l.prop, `${STYLES_KEY},`));
|
|
3239
3255
|
return each(p, (m) => {
|
|
3240
|
-
const
|
|
3256
|
+
const h = m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), f = new RegExp(`(^|\\s)${h}(?=\\s|$)`, "g");
|
|
3241
3257
|
u = u.replace(f, " ").replace(/\s+/g, " ").trim();
|
|
3242
|
-
const
|
|
3243
|
-
includes(["2xl", "xl", "lg", "md", "sm"],
|
|
3258
|
+
const x = first(m.split(":"));
|
|
3259
|
+
includes(["2xl", "xl", "lg", "md", "sm"], x) && p.push(m.split(":").pop().trim());
|
|
3244
3260
|
}), each(p, (m) => {
|
|
3245
|
-
const
|
|
3261
|
+
const h = m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), f = new RegExp(`(^|\\s)${h}(?=\\s|$)`, "g");
|
|
3246
3262
|
g = g.replace(f, " ").replace(/\s+/g, " ").trim();
|
|
3247
3263
|
}), {
|
|
3248
3264
|
ids: [d._id],
|
|
@@ -3361,21 +3377,21 @@ const CONTROLS = [
|
|
|
3361
3377
|
return "VERTICAL";
|
|
3362
3378
|
}
|
|
3363
3379
|
}, isDisabledControl = (o, n, r) => !!(o && (r === "UP" || r === "LEFT") || n && (r === "DOWN" || r === "RIGHT")), useBlockController = (o, n) => {
|
|
3364
|
-
const [r] = useBlocksStore(), { document: a } = useFrame(), { moveBlocks: l } = useBlocksStoreUndoableActions(), i = get(o, "_id"), c = get(o, "_parent"), d = filter(r, (
|
|
3365
|
-
(
|
|
3366
|
-
isDisabledControl(g, m,
|
|
3380
|
+
const [r] = useBlocksStore(), { document: a } = useFrame(), { moveBlocks: l } = useBlocksStoreUndoableActions(), i = get(o, "_id"), c = get(o, "_parent"), d = filter(r, (x) => c ? get(x, "_parent") === c : !get(x, "_parent")), p = (d == null ? void 0 : d.length) <= 1, u = findIndex(d, { _id: i }), g = u <= 0, m = u + 1 === (d == null ? void 0 : d.length), h = getParentBlockOrientation(c, i, a), f = useCallback(
|
|
3381
|
+
(x) => {
|
|
3382
|
+
isDisabledControl(g, m, x) || p || (x === "UP" || x === "LEFT" ? l([i], c || null, u - 1) : (x === "DOWN" || x === "RIGHT") && l([i], c || null, u + 2), n());
|
|
3367
3383
|
},
|
|
3368
3384
|
[g, m, p, u, i, c, n]
|
|
3369
3385
|
);
|
|
3370
3386
|
return useHotkeys(
|
|
3371
3387
|
"shift+up, shift+down, shift+left, shift+right",
|
|
3372
|
-
({ key:
|
|
3388
|
+
({ key: x }) => {
|
|
3373
3389
|
var b;
|
|
3374
|
-
f((b =
|
|
3390
|
+
f((b = x == null ? void 0 : x.replace("Arrow", "")) == null ? void 0 : b.toUpperCase());
|
|
3375
3391
|
},
|
|
3376
3392
|
{ document: a == null ? void 0 : a.contentDocument },
|
|
3377
3393
|
[f]
|
|
3378
|
-
), { isOnlyChild: p, isFirstBlock: g, isLastBlock: m, moveBlock: f, orientation:
|
|
3394
|
+
), { isOnlyChild: p, isFirstBlock: g, isLastBlock: m, moveBlock: f, orientation: h };
|
|
3379
3395
|
}, BlockController = ({ block: o, updateFloatingBar: n }) => {
|
|
3380
3396
|
const { isOnlyChild: r, isFirstBlock: a, isLastBlock: l, moveBlock: i, orientation: c } = useBlockController(
|
|
3381
3397
|
o,
|
|
@@ -3414,8 +3430,8 @@ const pubsub = new PubSub(), AddBlockDropdown = ({ block: o, children: n }) => {
|
|
|
3414
3430
|
if (m === "CHILD")
|
|
3415
3431
|
pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, o);
|
|
3416
3432
|
else {
|
|
3417
|
-
const
|
|
3418
|
-
m === "BEFORE" ?
|
|
3433
|
+
const h = { _id: c || "", position: d == null ? void 0 : d.length };
|
|
3434
|
+
m === "BEFORE" ? h.position = Math.max(u, 0) : m === "AFTER" && (h.position = u + 1), pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, h);
|
|
3419
3435
|
}
|
|
3420
3436
|
};
|
|
3421
3437
|
return l(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
@@ -3445,15 +3461,15 @@ const pubsub = new PubSub(), AddBlockDropdown = ({ block: o, children: n }) => {
|
|
|
3445
3461
|
}
|
|
3446
3462
|
);
|
|
3447
3463
|
}, BlockFloatingSelector = ({ selectedBlockElement: o, block: n }) => {
|
|
3448
|
-
const r = useRemoveBlocks(), a = useDuplicateBlocks(), [, l] = useSelectedBlockIds(), [, i] = useHighlightBlockId(), [, c] = useSelectedStylingBlocks(), { hasPermission: d } = usePermissions(), [p] = useAtom$1(inlineEditingActiveAtom), { document: u } = useFrame(), { floatingStyles: g, refs: m, update:
|
|
3464
|
+
const r = useRemoveBlocks(), a = useDuplicateBlocks(), [, l] = useSelectedBlockIds(), [, i] = useHighlightBlockId(), [, c] = useSelectedStylingBlocks(), { hasPermission: d } = usePermissions(), [p] = useAtom$1(inlineEditingActiveAtom), { document: u } = useFrame(), { floatingStyles: g, refs: m, update: h } = useFloating({
|
|
3449
3465
|
placement: "top-start",
|
|
3450
3466
|
middleware: [shift(), flip()],
|
|
3451
3467
|
elements: {
|
|
3452
3468
|
reference: o
|
|
3453
3469
|
}
|
|
3454
3470
|
});
|
|
3455
|
-
useResizeObserver(o, () =>
|
|
3456
|
-
const f = get(n, "_parent", null),
|
|
3471
|
+
useResizeObserver(o, () => h(), o !== null), useResizeObserver(u == null ? void 0 : u.body, () => h(), (u == null ? void 0 : u.body) !== null);
|
|
3472
|
+
const f = get(n, "_parent", null), x = isEmpty(get(n, "_name", "")) ? get(n, "_type", "") : get(n, "_name", "");
|
|
3457
3473
|
return !o || !n || p ? null : /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(
|
|
3458
3474
|
"div",
|
|
3459
3475
|
{
|
|
@@ -3479,12 +3495,12 @@ const pubsub = new PubSub(), AddBlockDropdown = ({ block: o, children: n }) => {
|
|
|
3479
3495
|
}
|
|
3480
3496
|
}
|
|
3481
3497
|
),
|
|
3482
|
-
/* @__PURE__ */ jsx(BlockActionLabel, { label:
|
|
3498
|
+
/* @__PURE__ */ jsx(BlockActionLabel, { label: x, block: n }),
|
|
3483
3499
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 pl-1 pr-1.5", children: [
|
|
3484
3500
|
/* @__PURE__ */ jsx(AddBlockDropdown, { block: n, children: /* @__PURE__ */ jsx(PlusIcon, { className: "hover:scale-105" }) }),
|
|
3485
3501
|
canDuplicateBlock(get(n, "_type", "")) && d(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsx(CopyIcon, { className: "hover:scale-105", onClick: () => a([n == null ? void 0 : n._id]) }) : null,
|
|
3486
3502
|
canDeleteBlock(get(n, "_type", "")) && d(PERMISSIONS.DELETE_BLOCK) ? /* @__PURE__ */ jsx(TrashIcon, { className: "hover:scale-105", onClick: () => r([n == null ? void 0 : n._id]) }) : null,
|
|
3487
|
-
d(PERMISSIONS.MOVE_BLOCK) && /* @__PURE__ */ jsx(BlockController, { block: n, updateFloatingBar:
|
|
3503
|
+
d(PERMISSIONS.MOVE_BLOCK) && /* @__PURE__ */ jsx(BlockController, { block: n, updateFloatingBar: h })
|
|
3488
3504
|
] })
|
|
3489
3505
|
]
|
|
3490
3506
|
}
|
|
@@ -3545,15 +3561,15 @@ const pubsub = new PubSub(), AddBlockDropdown = ({ block: o, children: n }) => {
|
|
|
3545
3561
|
<div class="frame-root h-full"></div>
|
|
3546
3562
|
</body>
|
|
3547
3563
|
</html>`, useKeyEventWatcher = (o) => {
|
|
3548
|
-
const [n, r] = useSelectedBlockIds(), a = useSelectedBlock(), l = useRemoveBlocks(), i = useDuplicateBlocks(), { undo: c, redo: d } = useUndoManager(), [, p] = useCutBlockIds(), [, u] = useCopyBlockIds(), { canPaste: g, pasteBlocks: m } = usePasteBlocks(),
|
|
3564
|
+
const [n, r] = useSelectedBlockIds(), a = useSelectedBlock(), l = useRemoveBlocks(), i = useDuplicateBlocks(), { undo: c, redo: d } = useUndoManager(), [, p] = useCutBlockIds(), [, u] = useCopyBlockIds(), { canPaste: g, pasteBlocks: m } = usePasteBlocks(), h = o ? { document: o } : {};
|
|
3549
3565
|
useHotkeys("ctrl+z,command+z", () => c(), {}, [c]), useHotkeys("ctrl+y,command+y", () => d(), {}, [d]), useHotkeys("ctrl+x,command+x", () => p(n), {}, [n, p]), useHotkeys("ctrl+c,command+c", () => u(n), {}, [n, u]), useHotkeys(
|
|
3550
3566
|
"ctrl+v,command+v",
|
|
3551
3567
|
() => {
|
|
3552
3568
|
g(n[0]) && m(n);
|
|
3553
3569
|
},
|
|
3554
|
-
{ ...
|
|
3570
|
+
{ ...h, preventDefault: !0 },
|
|
3555
3571
|
[n, g, m]
|
|
3556
|
-
), useHotkeys("esc", () => r([]),
|
|
3572
|
+
), useHotkeys("esc", () => r([]), h, [r]), useHotkeys("ctrl+d,command+d", () => i(n), { ...h, preventDefault: !0 }, [
|
|
3557
3573
|
n,
|
|
3558
3574
|
i
|
|
3559
3575
|
]), useHotkeys(
|
|
@@ -3561,7 +3577,7 @@ const pubsub = new PubSub(), AddBlockDropdown = ({ block: o, children: n }) => {
|
|
|
3561
3577
|
(f) => {
|
|
3562
3578
|
f.preventDefault(), canDeleteBlock(get(a, "_type", "")) && l(n);
|
|
3563
3579
|
},
|
|
3564
|
-
|
|
3580
|
+
h,
|
|
3565
3581
|
[n, l]
|
|
3566
3582
|
);
|
|
3567
3583
|
}, KeyboardHandler = () => {
|
|
@@ -3641,33 +3657,33 @@ const useDnd = () => {
|
|
|
3641
3657
|
};
|
|
3642
3658
|
return iframeDocument = o, {
|
|
3643
3659
|
isDragging: n,
|
|
3644
|
-
onDragOver: (
|
|
3645
|
-
|
|
3660
|
+
onDragOver: (h) => {
|
|
3661
|
+
h.preventDefault(), h.stopPropagation(), throttledDragOver(h);
|
|
3646
3662
|
},
|
|
3647
|
-
onDrop: (
|
|
3648
|
-
var
|
|
3649
|
-
const f = dropTarget, b = getOrientation(f) === "vertical" ?
|
|
3663
|
+
onDrop: (h) => {
|
|
3664
|
+
var E;
|
|
3665
|
+
const f = dropTarget, b = getOrientation(f) === "vertical" ? h.clientY + ((E = iframeDocument == null ? void 0 : iframeDocument.defaultView) == null ? void 0 : E.scrollY) : h.clientX;
|
|
3650
3666
|
dropIndex = calculateDropIndex(b, possiblePositions);
|
|
3651
|
-
const k = d,
|
|
3652
|
-
if ((k == null ? void 0 : k._id) ===
|
|
3667
|
+
const k = d, w = f.getAttribute("data-block-id"), S = dropTarget.getAttribute("data-dnd-dragged") !== "yes";
|
|
3668
|
+
if ((k == null ? void 0 : k._id) === w || !S) {
|
|
3653
3669
|
m();
|
|
3654
3670
|
return;
|
|
3655
3671
|
}
|
|
3656
3672
|
if (!has(k, "_id")) {
|
|
3657
|
-
a(k,
|
|
3673
|
+
a(k, w === "canvas" ? null : w, dropIndex), setTimeout(m, 300);
|
|
3658
3674
|
return;
|
|
3659
3675
|
}
|
|
3660
|
-
let
|
|
3661
|
-
|
|
3676
|
+
let A = f.getAttribute("data-block-id");
|
|
3677
|
+
A === null && (A = h.target.parentElement.getAttribute("data-block-id")), c([k._id], A === "canvas" ? null : A, dropIndex), m(), setTimeout(removePlaceholder, 300);
|
|
3662
3678
|
},
|
|
3663
|
-
onDragEnter: (
|
|
3664
|
-
const f =
|
|
3665
|
-
dropTarget =
|
|
3666
|
-
const b =
|
|
3667
|
-
u(b), f.stopPropagation(), f.preventDefault(), possiblePositions = [], k && calculatePossiblePositions(
|
|
3679
|
+
onDragEnter: (h) => {
|
|
3680
|
+
const f = h, x = f.target;
|
|
3681
|
+
dropTarget = x;
|
|
3682
|
+
const b = x.getAttribute("data-block-id"), k = x.getAttribute("data-dnd-dragged") !== "yes";
|
|
3683
|
+
u(b), f.stopPropagation(), f.preventDefault(), possiblePositions = [], k && calculatePossiblePositions(x), r(!0), l(""), i([]);
|
|
3668
3684
|
},
|
|
3669
|
-
onDragLeave: (
|
|
3670
|
-
|
|
3685
|
+
onDragLeave: (h) => {
|
|
3686
|
+
h.target.getAttribute("data-block-id") === "canvas" && (u(null), r(!1), removePlaceholder(), possiblePositions = []);
|
|
3671
3687
|
}
|
|
3672
3688
|
};
|
|
3673
3689
|
};
|
|
@@ -3698,8 +3714,8 @@ const useHandleCanvasDblClick = (o, n) => {
|
|
|
3698
3714
|
const f = o.getHTML();
|
|
3699
3715
|
a([m], { content: f }), n.style.display = "none", u.style.visibility = "visible";
|
|
3700
3716
|
}), i(m);
|
|
3701
|
-
const
|
|
3702
|
-
o.commands.setContent(
|
|
3717
|
+
const h = d(m).content;
|
|
3718
|
+
o.commands.setContent(h), n.style.display = "block", u.style.visibility = "hidden", n.style.position = "absolute", n.style.top = `${u.offsetTop}px`, n.style.left = `${u.offsetLeft}px`, n.style.width = `${u.offsetWidth}px`, n.style.height = `${u.offsetHeight}px`, n.classList.add(...u.classList);
|
|
3703
3719
|
},
|
|
3704
3720
|
[l, c, d, i, a, o, n]
|
|
3705
3721
|
);
|
|
@@ -3740,17 +3756,17 @@ const useHandleCanvasDblClick = (o, n) => {
|
|
|
3740
3756
|
return;
|
|
3741
3757
|
const f = getElementByDataBlockId(n, first(r));
|
|
3742
3758
|
if (f) {
|
|
3743
|
-
const
|
|
3744
|
-
if (
|
|
3759
|
+
const x = f.getAttribute("data-style-prop");
|
|
3760
|
+
if (x) {
|
|
3745
3761
|
const b = f.getAttribute("data-style-id"), k = f.getAttribute("data-block-parent");
|
|
3746
|
-
l([{ id: b, prop:
|
|
3762
|
+
l([{ id: b, prop: x, blockId: k }]);
|
|
3747
3763
|
}
|
|
3748
3764
|
}
|
|
3749
3765
|
}, 100);
|
|
3750
3766
|
}, [n, r, l, a]);
|
|
3751
3767
|
const c = useEditor({
|
|
3752
3768
|
extensions: [StarterKit]
|
|
3753
|
-
}), d = useRef(null), p = useHandleCanvasDblClick(c, d.current), u = useHandleCanvasClick(), g = useHandleMouseMove(), m = useHandleMouseLeave(),
|
|
3769
|
+
}), d = useRef(null), p = useHandleCanvasDblClick(c, d.current), u = useHandleCanvasClick(), g = useHandleMouseMove(), m = useHandleMouseLeave(), h = useDnd();
|
|
3754
3770
|
return /* @__PURE__ */ jsx(
|
|
3755
3771
|
"div",
|
|
3756
3772
|
{
|
|
@@ -3760,8 +3776,8 @@ const useHandleCanvasDblClick = (o, n) => {
|
|
|
3760
3776
|
onDoubleClick: p,
|
|
3761
3777
|
onMouseMove: g,
|
|
3762
3778
|
onMouseLeave: m,
|
|
3763
|
-
...omit(
|
|
3764
|
-
className: "relative h-full max-w-full p-px " + (
|
|
3779
|
+
...omit(h, "isDragging"),
|
|
3780
|
+
className: "relative h-full max-w-full p-px " + (h.isDragging ? "dragging" : ""),
|
|
3765
3781
|
children: o
|
|
3766
3782
|
}
|
|
3767
3783
|
);
|
|
@@ -3770,7 +3786,7 @@ const useHandleCanvasDblClick = (o, n) => {
|
|
|
3770
3786
|
d == null ? void 0 : d.getElementById("selected-block")
|
|
3771
3787
|
), [m] = useState(
|
|
3772
3788
|
d == null ? void 0 : d.getElementById("selected-styling-block")
|
|
3773
|
-
), [
|
|
3789
|
+
), [h] = useState(
|
|
3774
3790
|
d == null ? void 0 : d.getElementById("dragged-block")
|
|
3775
3791
|
);
|
|
3776
3792
|
useEffect(() => {
|
|
@@ -3814,8 +3830,8 @@ const useHandleCanvasDblClick = (o, n) => {
|
|
|
3814
3830
|
outline: 1px solid ${r.length === 1 ? "#42a1fc !important" : "orange !important"}; outline-offset: -1px;
|
|
3815
3831
|
}`);
|
|
3816
3832
|
}, [r, g]), useEffect(() => {
|
|
3817
|
-
|
|
3818
|
-
}, [i,
|
|
3833
|
+
h.textContent = i ? `[data-block-id="${i._id}"], [data-block-id="${i._id}"] > * { pointer-events: none !important; opacity: 0.6 !important}` : "";
|
|
3834
|
+
}, [i, h]), useEffect(() => {
|
|
3819
3835
|
u && (u.textContent = '[data-highlighted="true"]{ outline: 1px solid #42a1fc !important; outline-offset: -1px;}');
|
|
3820
3836
|
}, [u]), useEffect(() => {
|
|
3821
3837
|
m && (m.textContent = `${map(l, ({ id: b }) => `[data-style-id="${b}"]`).join(",")}{
|
|
@@ -3827,10 +3843,10 @@ const useHandleCanvasDblClick = (o, n) => {
|
|
|
3827
3843
|
const f = useMemo(
|
|
3828
3844
|
() => getChaiThemeCssVariables(o),
|
|
3829
3845
|
[o]
|
|
3830
|
-
),
|
|
3846
|
+
), x = useMemo(() => getThemeFontsLinkMarkup(pick(o, ["fontFamily"])), [o]);
|
|
3831
3847
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3832
3848
|
/* @__PURE__ */ jsx("style", { id: "chai-theme", children: f }),
|
|
3833
|
-
/* @__PURE__ */ jsx("span", { id: "chai-fonts", dangerouslySetInnerHTML: { __html:
|
|
3849
|
+
/* @__PURE__ */ jsx("span", { id: "chai-fonts", dangerouslySetInnerHTML: { __html: x } })
|
|
3834
3850
|
] });
|
|
3835
3851
|
}, ResizableCanvasWrapper = ({ children: o, onMount: n, onResize: r }) => {
|
|
3836
3852
|
const [, a] = useSelectedBlockIds(), [, l] = useSelectedStylingBlocks(), i = useRef(null), c = useDebouncedCallback(
|
|
@@ -3910,10 +3926,10 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
3910
3926
|
const [r] = useAtom$1(o), a = useMemo(() => getRegisteredChaiBlock(r._type), [r._type]), { selectedLang: l, fallbackLang: i } = useLanguages(), c = useBlockRuntimeProps(), d = usePageExternalData(), [p] = useHiddenBlockIds(), [u] = useAtom$1(dataBindingActiveAtom), g = get(a, "component", null), m = useMemo(
|
|
3911
3927
|
() => u ? applyBinding(applyLanguage(r, l, a), d) : applyLanguage(r, l, a),
|
|
3912
3928
|
[r, l, a, d, u]
|
|
3913
|
-
),
|
|
3929
|
+
), h = useMemo(() => getBlockTagAttributes(r), [r, getBlockTagAttributes]), f = useMemo(
|
|
3914
3930
|
() => c(r._id, getBlockRuntimeProps(r._type)),
|
|
3915
3931
|
[r._id, r._type, c, getBlockRuntimeProps]
|
|
3916
|
-
),
|
|
3932
|
+
), x = useMemo(() => !has(a, "dataProvider") || !isFunction$1(a.dataProvider) ? {} : a.dataProvider(r, l), [r, l, a]), b = useMemo(
|
|
3917
3933
|
() => ({
|
|
3918
3934
|
blockProps: {
|
|
3919
3935
|
"data-block-id": r._id,
|
|
@@ -3922,9 +3938,9 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
3922
3938
|
inBuilder: !0,
|
|
3923
3939
|
lang: l || i,
|
|
3924
3940
|
...m,
|
|
3925
|
-
...
|
|
3941
|
+
...h,
|
|
3926
3942
|
...f,
|
|
3927
|
-
...
|
|
3943
|
+
...x
|
|
3928
3944
|
}),
|
|
3929
3945
|
[
|
|
3930
3946
|
r._id,
|
|
@@ -3932,9 +3948,9 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
3932
3948
|
l,
|
|
3933
3949
|
i,
|
|
3934
3950
|
m,
|
|
3935
|
-
|
|
3951
|
+
h,
|
|
3936
3952
|
f,
|
|
3937
|
-
|
|
3953
|
+
x
|
|
3938
3954
|
]
|
|
3939
3955
|
);
|
|
3940
3956
|
return isNull(g) || p.includes(r._id) ? null : /* @__PURE__ */ jsx(Suspense, { children: createElement(g, { ...b, children: n }) });
|
|
@@ -3966,11 +3982,11 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
3966
3982
|
if (d < n) {
|
|
3967
3983
|
const u = parseFloat((d / n).toFixed(2).toString());
|
|
3968
3984
|
let g = {};
|
|
3969
|
-
const m = p * u,
|
|
3985
|
+
const m = p * u, h = d * u;
|
|
3970
3986
|
p && (g = {
|
|
3971
3987
|
// Eureka! This is the formula to calculate the height of the scaled element. Thank you ChatGPT 4
|
|
3972
3988
|
height: 100 + (p - m) / m * 100 + "%",
|
|
3973
|
-
width: 100 + (d -
|
|
3989
|
+
width: 100 + (d - h) / h * 100 + "%"
|
|
3974
3990
|
}), i({
|
|
3975
3991
|
position: "relative",
|
|
3976
3992
|
top: 0,
|
|
@@ -3987,39 +4003,39 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
3987
4003
|
c();
|
|
3988
4004
|
}, [n, o, r, c]), l;
|
|
3989
4005
|
}, getElementByStyleId = (o, n) => o.querySelector(`[data-style-id="${n}"]`), StaticCanvas = () => {
|
|
3990
|
-
const [o] = useAtom$1(networkModeAtom), [n] = useCanvasDisplayWidth(), [, r] = useSelectedBlockIds(), a = useSelectedBlock(), [, l] = useHighlightBlockId(), i = useRef(null), c = useRef(null), [d, p] = useState({ width: 0, height: 0 }), u = useCanvasScale(d), [g, m] = useState([]), [,
|
|
3991
|
-
p((
|
|
4006
|
+
const [o] = useAtom$1(networkModeAtom), [n] = useCanvasDisplayWidth(), [, r] = useSelectedBlockIds(), a = useSelectedBlock(), [, l] = useHighlightBlockId(), i = useRef(null), c = useRef(null), [d, p] = useState({ width: 0, height: 0 }), u = useCanvasScale(d), [g, m] = useState([]), [, h] = useState([]), [, f] = useAtom$1(canvasIframeAtom), [x, b] = useSelectedStylingBlocks(), k = useBuilderProp("loading", !1), w = useBuilderProp("htmlDir", "ltr"), S = (j) => {
|
|
4007
|
+
p((C) => ({ ...C, width: j }));
|
|
3992
4008
|
};
|
|
3993
4009
|
useEffect(() => {
|
|
3994
4010
|
if (!c.current) return;
|
|
3995
|
-
const { clientWidth:
|
|
3996
|
-
p({ width:
|
|
4011
|
+
const { clientWidth: j, clientHeight: C } = c.current;
|
|
4012
|
+
p({ width: j, height: C });
|
|
3997
4013
|
}, [c, n]);
|
|
3998
|
-
const
|
|
3999
|
-
const { top:
|
|
4000
|
-
return
|
|
4014
|
+
const A = (j, C = 0) => {
|
|
4015
|
+
const { top: B } = j.getBoundingClientRect();
|
|
4016
|
+
return B + C >= 0 && B - C <= window.innerHeight;
|
|
4001
4017
|
};
|
|
4002
4018
|
useEffect(() => {
|
|
4003
|
-
var
|
|
4019
|
+
var j, C;
|
|
4004
4020
|
if (a && a.type !== "Multiple" && i.current) {
|
|
4005
|
-
const
|
|
4006
|
-
|
|
4021
|
+
const B = getElementByDataBlockId(i.current.contentDocument, a._id);
|
|
4022
|
+
B && (A(B) || (C = (j = i.current) == null ? void 0 : j.contentWindow) == null || C.scrollTo({ top: B.offsetTop, behavior: "smooth" }), m([B]));
|
|
4007
4023
|
}
|
|
4008
4024
|
}, [a]), useEffect(() => {
|
|
4009
|
-
if (!isEmpty(
|
|
4010
|
-
const
|
|
4025
|
+
if (!isEmpty(x) && i.current) {
|
|
4026
|
+
const j = getElementByStyleId(
|
|
4011
4027
|
i.current.contentDocument,
|
|
4012
|
-
first(
|
|
4028
|
+
first(x).id
|
|
4013
4029
|
);
|
|
4014
|
-
|
|
4030
|
+
h(j ? [j] : [null]);
|
|
4015
4031
|
} else
|
|
4016
|
-
|
|
4017
|
-
}, [
|
|
4018
|
-
const
|
|
4019
|
-
let
|
|
4020
|
-
return
|
|
4021
|
-
}, [o,
|
|
4022
|
-
return /* @__PURE__ */ jsx(ResizableCanvasWrapper, { onMount:
|
|
4032
|
+
h([null]);
|
|
4033
|
+
}, [x]);
|
|
4034
|
+
const E = useMemo(() => {
|
|
4035
|
+
let j = IframeInitialContent;
|
|
4036
|
+
return j = j.replace("__HTML_DIR__", w), o === "offline" && (j = j.replace("https://chaibuilder.com/offline/tailwind.cdn.js", "/offline/tailwind.cdn.js")), j;
|
|
4037
|
+
}, [o, w]);
|
|
4038
|
+
return /* @__PURE__ */ jsx(ResizableCanvasWrapper, { onMount: S, onResize: S, children: /* @__PURE__ */ jsx(
|
|
4023
4039
|
"div",
|
|
4024
4040
|
{
|
|
4025
4041
|
onClick: () => {
|
|
@@ -4036,7 +4052,7 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
4036
4052
|
id: "canvas-iframe",
|
|
4037
4053
|
style: { ...u, ...isEmpty(u) ? { width: `${n}px` } : {} },
|
|
4038
4054
|
className: "relative mx-auto box-content h-full w-full max-w-full shadow-lg transition-all duration-300 ease-linear",
|
|
4039
|
-
initialContent:
|
|
4055
|
+
initialContent: E,
|
|
4040
4056
|
children: [
|
|
4041
4057
|
/* @__PURE__ */ jsx(KeyboardHandler, {}),
|
|
4042
4058
|
/* @__PURE__ */ jsx(
|
|
@@ -4105,227 +4121,7 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
4105
4121
|
o ? /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(Skeleton, { className: "h-full" }), children: /* @__PURE__ */ jsx(Resizable, { enable: { top: !0, bottom: !1 }, className: "max-h-[400px] min-h-[200px]", children: /* @__PURE__ */ jsx(CodeEditor$1, {}) }) }) : null,
|
|
4106
4122
|
/* @__PURE__ */ jsx(Breadcrumb, {})
|
|
4107
4123
|
] }) });
|
|
4108
|
-
},
|
|
4109
|
-
{ title: "Roboto", value: "Roboto" },
|
|
4110
|
-
{ title: "Open Sans", value: "Open Sans" },
|
|
4111
|
-
{ title: "Montserrat", value: "Montserrat" },
|
|
4112
|
-
{ title: "Lato", value: "Lato" },
|
|
4113
|
-
{ title: "Poppins", value: "Poppins" },
|
|
4114
|
-
{ title: "Oswald", value: "Oswald" },
|
|
4115
|
-
{ title: "Raleway", value: "Raleway" },
|
|
4116
|
-
{ title: "Ubuntu", value: "Ubuntu" },
|
|
4117
|
-
{ title: "Nunito", value: "Nunito" },
|
|
4118
|
-
{ title: "Merriweather", value: "Merriweather" },
|
|
4119
|
-
{ title: "Nunito Sans", value: "Nunito Sans" },
|
|
4120
|
-
{ title: "Playfair Display", value: "Playfair Display" },
|
|
4121
|
-
{ title: "Rubik", value: "Rubik" },
|
|
4122
|
-
{ title: "Inter", value: "Inter" },
|
|
4123
|
-
{ title: "Lora", value: "Lora" },
|
|
4124
|
-
{ title: "Kanit", value: "Kanit" },
|
|
4125
|
-
{ title: "Fira Sans", value: "Fira Sans" },
|
|
4126
|
-
{ title: "Hind", value: "Hind" },
|
|
4127
|
-
{ title: "Quicksand", value: "Quicksand" },
|
|
4128
|
-
{ title: "Mulish", value: "Mulish" },
|
|
4129
|
-
{ title: "Barlow", value: "Barlow" },
|
|
4130
|
-
{ title: "Inconsolata", value: "Inconsolata" },
|
|
4131
|
-
{ title: "Titillium Web", value: "Titillium Web" },
|
|
4132
|
-
{ title: "Heebo", value: "Heebo" },
|
|
4133
|
-
{ title: "IBM Plex Sans", value: "IBM Plex Sans" },
|
|
4134
|
-
{ title: "DM Sans", value: "DM Sans" },
|
|
4135
|
-
{ title: "Nanum Gothic", value: "Nanum Gothic" },
|
|
4136
|
-
{ title: "Karla", value: "Karla" },
|
|
4137
|
-
{ title: "Arimo", value: "Arimo" },
|
|
4138
|
-
{ title: "Cabin", value: "Cabin" },
|
|
4139
|
-
{ title: "Oxygen", value: "Oxygen" },
|
|
4140
|
-
{ title: "Overpass", value: "Overpass" },
|
|
4141
|
-
{ title: "Assistant", value: "Assistant" },
|
|
4142
|
-
{ title: "Tajawal", value: "Tajawal" },
|
|
4143
|
-
{ title: "Play", value: "Play" },
|
|
4144
|
-
{ title: "Exo", value: "Exo" },
|
|
4145
|
-
{ title: "Cinzel", value: "Cinzel" },
|
|
4146
|
-
{ title: "Faustina", value: "Faustina" },
|
|
4147
|
-
{ title: "Philosopher", value: "Philosopher" },
|
|
4148
|
-
{ title: "Gelasio", value: "Gelasio" },
|
|
4149
|
-
{ title: "Sofia Sans Condensed", value: "Sofia Sans Condensed" },
|
|
4150
|
-
{ title: "Noto Sans Devanagari", value: "Noto Sans Devanagari" },
|
|
4151
|
-
{ title: "Actor", value: "Actor" },
|
|
4152
|
-
{ title: "Epilogue", value: "Epilogue" },
|
|
4153
|
-
{ title: "Glegoo", value: "Glegoo" },
|
|
4154
|
-
{ title: "Overlock", value: "Overlock" },
|
|
4155
|
-
{ title: "Lustria", value: "Lustria" },
|
|
4156
|
-
{ title: "Ovo", value: "Ovo" },
|
|
4157
|
-
{ title: "Suranna", value: "Suranna" },
|
|
4158
|
-
{ title: "Bebas Neue", value: "Bebas Neue" },
|
|
4159
|
-
{ title: "Manrope", value: "Manrope" }
|
|
4160
|
-
], FontSelector = ({
|
|
4161
|
-
label: o,
|
|
4162
|
-
value: n,
|
|
4163
|
-
onChange: r
|
|
4164
|
-
}) => /* @__PURE__ */ jsxs("div", { className: "space-y-0.5", children: [
|
|
4165
|
-
/* @__PURE__ */ jsx(Label, { className: "text-sm text-slate-800", children: startCase(o) }),
|
|
4166
|
-
/* @__PURE__ */ jsx(
|
|
4167
|
-
"select",
|
|
4168
|
-
{
|
|
4169
|
-
className: "mt-1 w-full cursor-pointer rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
|
|
4170
|
-
value: n,
|
|
4171
|
-
onChange: (a) => r(a.target.value),
|
|
4172
|
-
children: FONTS.map((a) => /* @__PURE__ */ jsx("option", { value: a.value, children: a.title }, a.value))
|
|
4173
|
-
}
|
|
4174
|
-
)
|
|
4175
|
-
] }), ColorPickerInput = ({ value: o, onChange: n }) => {
|
|
4176
|
-
const r = debounce((a) => n(a), 200);
|
|
4177
|
-
return /* @__PURE__ */ jsx(
|
|
4178
|
-
"div",
|
|
4179
|
-
{
|
|
4180
|
-
className: "relative flex h-6 w-6 cursor-pointer rounded-lg border border-border",
|
|
4181
|
-
style: { backgroundColor: o },
|
|
4182
|
-
children: /* @__PURE__ */ jsx(
|
|
4183
|
-
"input",
|
|
4184
|
-
{
|
|
4185
|
-
type: "color",
|
|
4186
|
-
value: o.startsWith("#") ? o : "#000000",
|
|
4187
|
-
onChange: (a) => {
|
|
4188
|
-
const l = a.target.value;
|
|
4189
|
-
/^#[0-9A-F]{6}$/i.test(l) && r(l);
|
|
4190
|
-
},
|
|
4191
|
-
className: "absolute inset-0 h-full w-full cursor-pointer rounded-lg border-0 opacity-0"
|
|
4192
|
-
}
|
|
4193
|
-
)
|
|
4194
|
-
}
|
|
4195
|
-
);
|
|
4196
|
-
}, BorderRadiusInput = ({ value: o, onChange: n, disabled: r }) => {
|
|
4197
|
-
const a = debounce((l) => n(l), 200);
|
|
4198
|
-
return /* @__PURE__ */ jsx(
|
|
4199
|
-
"input",
|
|
4200
|
-
{
|
|
4201
|
-
type: "range",
|
|
4202
|
-
min: "0",
|
|
4203
|
-
step: "1",
|
|
4204
|
-
max: "30",
|
|
4205
|
-
disabled: r,
|
|
4206
|
-
defaultValue: o.replace("px", ""),
|
|
4207
|
-
onChange: (l) => a(l.target.value),
|
|
4208
|
-
className: "flex-1 cursor-pointer"
|
|
4209
|
-
}
|
|
4210
|
-
);
|
|
4211
|
-
}, ThemeConfigPanel = React.memo(({ className: o = "" }) => {
|
|
4212
|
-
const [n] = useDarkMode(), [r, a] = React.useState(""), l = useBuilderProp("themePresets", []), i = useBuilderProp("themePanelComponent", null), { hasPermission: c } = usePermissions(), [d, p] = useTheme(), u = useThemeOptions(), { t: g } = useTranslation(), m = (A) => {
|
|
4213
|
-
a(A);
|
|
4214
|
-
}, x = () => {
|
|
4215
|
-
const A = l.find((B) => Object.keys(B)[0] === r);
|
|
4216
|
-
if (A) {
|
|
4217
|
-
const B = Object.values(A)[0];
|
|
4218
|
-
B && typeof B == "object" && "fontFamily" in B && "borderRadius" in B && "colors" in B ? p(B) : console.error("Invalid preset structure:", B);
|
|
4219
|
-
} else
|
|
4220
|
-
console.error("Preset not found:", r);
|
|
4221
|
-
}, f = useDebouncedCallback(
|
|
4222
|
-
(A, B) => {
|
|
4223
|
-
p(() => ({
|
|
4224
|
-
...d,
|
|
4225
|
-
fontFamily: {
|
|
4226
|
-
...d.fontFamily,
|
|
4227
|
-
[A.replace(/font-/g, "")]: B
|
|
4228
|
-
}
|
|
4229
|
-
}));
|
|
4230
|
-
},
|
|
4231
|
-
[d],
|
|
4232
|
-
200
|
|
4233
|
-
), h = useDebouncedCallback(
|
|
4234
|
-
(A) => {
|
|
4235
|
-
p(() => ({
|
|
4236
|
-
...d,
|
|
4237
|
-
borderRadius: `${A}px`
|
|
4238
|
-
}));
|
|
4239
|
-
},
|
|
4240
|
-
[d],
|
|
4241
|
-
200
|
|
4242
|
-
), b = useDebouncedCallback(
|
|
4243
|
-
(A, B) => {
|
|
4244
|
-
p(() => {
|
|
4245
|
-
const C = get(d, `colors.${A}`);
|
|
4246
|
-
return n ? set(C, 1, B) : set(C, 0, B), {
|
|
4247
|
-
...d,
|
|
4248
|
-
colors: {
|
|
4249
|
-
...d.colors,
|
|
4250
|
-
[A]: C
|
|
4251
|
-
}
|
|
4252
|
-
};
|
|
4253
|
-
});
|
|
4254
|
-
},
|
|
4255
|
-
[d],
|
|
4256
|
-
200
|
|
4257
|
-
), k = (A) => /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1", children: Object.entries(A.items).map(([B]) => {
|
|
4258
|
-
const C = get(d, `colors.${B}.${n ? 1 : 0}`);
|
|
4259
|
-
return /* @__PURE__ */ jsxs("div", { className: "mt-1 flex items-center gap-x-2", children: [
|
|
4260
|
-
/* @__PURE__ */ jsx(
|
|
4261
|
-
ColorPickerInput,
|
|
4262
|
-
{
|
|
4263
|
-
value: C,
|
|
4264
|
-
onChange: (j) => b(B, j)
|
|
4265
|
-
}
|
|
4266
|
-
),
|
|
4267
|
-
/* @__PURE__ */ jsx(Label, { className: "text-xs font-normal leading-tight text-slate-600", children: B.split(/(?=[A-Z])/).join(" ").replace(/-/g, " ").split(" ").map((j) => j.charAt(0).toUpperCase() + j.slice(1)).join(" ") + (!B.toLowerCase().includes("foreground") && !B.toLowerCase().includes("border") && !B.toLowerCase().includes("input") && !B.toLowerCase().includes("ring") && !B.toLowerCase().includes("background") ? " Background" : "") })
|
|
4268
|
-
] }, B);
|
|
4269
|
-
}) });
|
|
4270
|
-
return c("edit_theme") ? /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
|
|
4271
|
-
/* @__PURE__ */ jsxs("div", { className: cn$1("no-scrollbar h-full w-full overflow-y-auto", o), children: [
|
|
4272
|
-
l.length > 0 && /* @__PURE__ */ jsxs("div", { className: "flex gap-2 py-2", children: [
|
|
4273
|
-
/* @__PURE__ */ jsxs("div", { className: "w-full", children: [
|
|
4274
|
-
/* @__PURE__ */ jsx(Label, { className: "text-sm text-slate-800", children: g("Presets") }),
|
|
4275
|
-
/* @__PURE__ */ jsxs(
|
|
4276
|
-
"select",
|
|
4277
|
-
{
|
|
4278
|
-
value: r,
|
|
4279
|
-
onChange: (A) => m(A.target.value),
|
|
4280
|
-
className: "w-full space-y-0.5 rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
|
|
4281
|
-
children: [
|
|
4282
|
-
/* @__PURE__ */ jsx("option", { value: "", children: "Select preset" }),
|
|
4283
|
-
Array.isArray(l) && l.map((A) => /* @__PURE__ */ jsx("option", { value: Object.keys(A)[0], children: capitalize(Object.keys(A)[0]) }, Object.keys(A)[0]))
|
|
4284
|
-
]
|
|
4285
|
-
}
|
|
4286
|
-
)
|
|
4287
|
-
] }),
|
|
4288
|
-
/* @__PURE__ */ jsx("div", { className: "flex w-[30%] items-end", children: /* @__PURE__ */ jsx(
|
|
4289
|
-
Button,
|
|
4290
|
-
{
|
|
4291
|
-
className: "w-full text-sm",
|
|
4292
|
-
disabled: r === "",
|
|
4293
|
-
variant: "default",
|
|
4294
|
-
onClick: x,
|
|
4295
|
-
children: g("Apply")
|
|
4296
|
-
}
|
|
4297
|
-
) })
|
|
4298
|
-
] }),
|
|
4299
|
-
/* @__PURE__ */ jsxs("div", { className: cn$1("space-y-2", o), children: [
|
|
4300
|
-
(u == null ? void 0 : u.fontFamily) && /* @__PURE__ */ jsx("div", { className: "grid gap-4", children: Object.entries(u.fontFamily).map(([A, B]) => /* @__PURE__ */ jsx(
|
|
4301
|
-
FontSelector,
|
|
4302
|
-
{
|
|
4303
|
-
label: A,
|
|
4304
|
-
value: d.fontFamily[A.replace(/font-/g, "")] || B[Object.keys(B)[0]],
|
|
4305
|
-
onChange: (C) => f(A, C)
|
|
4306
|
-
},
|
|
4307
|
-
A
|
|
4308
|
-
)) }),
|
|
4309
|
-
(u == null ? void 0 : u.borderRadius) && /* @__PURE__ */ jsxs("div", { className: "space-y-0.5 py-3", children: [
|
|
4310
|
-
/* @__PURE__ */ jsx(Label, { className: "text-sm text-slate-800", children: g("Border Radius") }),
|
|
4311
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-4 py-2", children: [
|
|
4312
|
-
/* @__PURE__ */ jsx(BorderRadiusInput, { value: d.borderRadius, onChange: h }),
|
|
4313
|
-
/* @__PURE__ */ jsx("span", { className: "w-12 text-sm", children: d.borderRadius })
|
|
4314
|
-
] })
|
|
4315
|
-
] }),
|
|
4316
|
-
(u == null ? void 0 : u.colors) && /* @__PURE__ */ jsxs("div", { className: "mt-4 space-y-0.5", children: [
|
|
4317
|
-
/* @__PURE__ */ jsx(Label, { className: "text-sm text-slate-800", children: g("Colors") }),
|
|
4318
|
-
/* @__PURE__ */ jsx("div", { className: "w-full space-y-4 pt-2", children: u.colors.map((A) => k(A)) }, n ? "dark" : "light")
|
|
4319
|
-
] })
|
|
4320
|
-
] }),
|
|
4321
|
-
/* @__PURE__ */ jsx("br", {}),
|
|
4322
|
-
/* @__PURE__ */ jsx("br", {}),
|
|
4323
|
-
/* @__PURE__ */ jsx("br", {}),
|
|
4324
|
-
/* @__PURE__ */ jsx("br", {})
|
|
4325
|
-
] }),
|
|
4326
|
-
i && /* @__PURE__ */ jsx("div", { className: "absolute bottom-4 w-full", children: React.createElement(i) })
|
|
4327
|
-
] }) : /* @__PURE__ */ jsx("div", { className: "relative w-full", children: /* @__PURE__ */ jsx("div", { className: cn$1("no-scrollbar h-full w-full overflow-y-auto text-center", o), children: /* @__PURE__ */ jsx("div", { className: "mt-10 h-full items-center justify-center gap-2 text-muted-foreground", children: /* @__PURE__ */ jsx("p", { className: "text-sm", children: "You don't have permission to edit the theme. Please contact your administrator to get access." }) }) }) });
|
|
4328
|
-
}), removeSizeAttributes = (o) => {
|
|
4124
|
+
}, removeSizeAttributes = (o) => {
|
|
4329
4125
|
try {
|
|
4330
4126
|
return o.replace(/<svg([^>]*)\sheight="[^"]*"([^>]*)>/gi, "<svg$1$2>").replace(/<svg([^>]*)\swidth="[^"]*"([^>]*)>/gi, "<svg$1$2>");
|
|
4331
4127
|
} catch {
|
|
@@ -4408,19 +4204,19 @@ function NestedPathSelector({ data: o, onSelect: n, dataType: r = "value" }) {
|
|
|
4408
4204
|
}, [a, o]);
|
|
4409
4205
|
const u = (f) => Array.isArray(f) ? "array" : typeof f == "object" && f !== null ? "object" : "value", g = React.useCallback(
|
|
4410
4206
|
(f) => {
|
|
4411
|
-
const
|
|
4412
|
-
f.type === "object" ? (c((b) => [...b, f.key]), p(f.value)) :
|
|
4207
|
+
const x = (b) => r === "value" ? b === "value" || b === "object" : r === "array" ? b === "array" : b === r;
|
|
4208
|
+
f.type === "object" ? (c((b) => [...b, f.key]), p(f.value)) : x(f.type) && (n([...i, f.key].join(".")), l(!1));
|
|
4413
4209
|
},
|
|
4414
4210
|
[i, n, r]
|
|
4415
4211
|
), m = React.useCallback(() => {
|
|
4416
4212
|
if (i.length > 0) {
|
|
4417
4213
|
const f = i.slice(0, -1);
|
|
4418
|
-
c(f), p(f.reduce((
|
|
4214
|
+
c(f), p(f.reduce((x, b) => x[b], o));
|
|
4419
4215
|
}
|
|
4420
|
-
}, [i, o]),
|
|
4216
|
+
}, [i, o]), h = React.useMemo(() => Object.entries(d).map(([f, x]) => ({
|
|
4421
4217
|
key: f,
|
|
4422
|
-
value:
|
|
4423
|
-
type: u(
|
|
4218
|
+
value: x,
|
|
4219
|
+
type: u(x)
|
|
4424
4220
|
})).filter((f) => r === "value" ? f.type === "value" || f.type === "object" : r === "array" ? f.type === "array" || f.type === "object" : r === "object" ? f.type === "object" : !0), [d, r]);
|
|
4425
4221
|
return /* @__PURE__ */ jsxs(Popover, { open: a, onOpenChange: l, children: [
|
|
4426
4222
|
/* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
@@ -4446,7 +4242,7 @@ function NestedPathSelector({ data: o, onSelect: n, dataType: r = "value" }) {
|
|
|
4446
4242
|
/* @__PURE__ */ jsx(ChevronLeft, { className: "mr-2 h-4 w-4" }),
|
|
4447
4243
|
"Back"
|
|
4448
4244
|
] }),
|
|
4449
|
-
|
|
4245
|
+
h.map((f) => /* @__PURE__ */ jsxs(
|
|
4450
4246
|
CommandItem,
|
|
4451
4247
|
{
|
|
4452
4248
|
value: f.key,
|
|
@@ -4462,8 +4258,8 @@ function NestedPathSelector({ data: o, onSelect: n, dataType: r = "value" }) {
|
|
|
4462
4258
|
size: "sm",
|
|
4463
4259
|
variant: "ghost",
|
|
4464
4260
|
className: "h-6 px-2 hover:bg-primary hover:text-primary-foreground",
|
|
4465
|
-
onClick: (
|
|
4466
|
-
|
|
4261
|
+
onClick: (x) => {
|
|
4262
|
+
x.stopPropagation(), n([...i, f.key].join(".")), l(!1);
|
|
4467
4263
|
},
|
|
4468
4264
|
children: "Select"
|
|
4469
4265
|
}
|
|
@@ -4639,8 +4435,8 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4639
4435
|
z-index: 9999 !important;
|
|
4640
4436
|
}
|
|
4641
4437
|
`, document.head.appendChild(m), () => {
|
|
4642
|
-
const
|
|
4643
|
-
|
|
4438
|
+
const h = document.getElementById("rte-modal-styles");
|
|
4439
|
+
h && h.remove();
|
|
4644
4440
|
};
|
|
4645
4441
|
}
|
|
4646
4442
|
}, [o]);
|
|
@@ -4662,12 +4458,12 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4662
4458
|
],
|
|
4663
4459
|
content: a || "",
|
|
4664
4460
|
onUpdate: ({ editor: m }) => {
|
|
4665
|
-
const
|
|
4666
|
-
l(
|
|
4461
|
+
const h = m.getHTML();
|
|
4462
|
+
l(h);
|
|
4667
4463
|
},
|
|
4668
4464
|
onBlur: ({ editor: m }) => {
|
|
4669
|
-
const
|
|
4670
|
-
i(r,
|
|
4465
|
+
const h = m.getHTML();
|
|
4466
|
+
i(r, h);
|
|
4671
4467
|
},
|
|
4672
4468
|
editorProps: {
|
|
4673
4469
|
attributes: {
|
|
@@ -4684,17 +4480,17 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4684
4480
|
}, [u, o]);
|
|
4685
4481
|
const g = (m) => {
|
|
4686
4482
|
if (!u) return;
|
|
4687
|
-
const
|
|
4483
|
+
const h = `{{${m}}}`;
|
|
4688
4484
|
u.commands.focus();
|
|
4689
|
-
const { from: f, to:
|
|
4690
|
-
if (f !==
|
|
4691
|
-
u.chain().deleteSelection().insertContent(
|
|
4485
|
+
const { from: f, to: x } = u.state.selection;
|
|
4486
|
+
if (f !== x)
|
|
4487
|
+
u.chain().deleteSelection().insertContent(h).run();
|
|
4692
4488
|
else {
|
|
4693
|
-
const { state: k } = u,
|
|
4489
|
+
const { state: k } = u, w = k.selection.from, S = k.doc.textBetween(Math.max(0, w - 1), w), A = k.doc.textBetween(w, Math.min(w + 1, k.doc.content.size));
|
|
4490
|
+
let E = "";
|
|
4491
|
+
w > 0 && S !== " " && !/[.,!?;:]/.test(S) && (E = " ");
|
|
4694
4492
|
let j = "";
|
|
4695
|
-
A
|
|
4696
|
-
let _ = "";
|
|
4697
|
-
C && C !== " " && !/[.,!?;:]/.test(C) && (_ = " "), u.chain().insertContent(j + x + _).run();
|
|
4493
|
+
A && A !== " " && !/[.,!?;:]/.test(A) && (j = " "), u.chain().insertContent(E + h + j).run();
|
|
4698
4494
|
}
|
|
4699
4495
|
};
|
|
4700
4496
|
return /* @__PURE__ */ jsx(Dialog, { open: o, onOpenChange: (m) => !m && n(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "max-h-[90vh] overflow-y-auto sm:max-w-[800px]", children: [
|
|
@@ -4730,12 +4526,12 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4730
4526
|
],
|
|
4731
4527
|
content: r || "",
|
|
4732
4528
|
onUpdate: ({ editor: f }) => {
|
|
4733
|
-
const
|
|
4734
|
-
a(
|
|
4529
|
+
const x = f.getHTML();
|
|
4530
|
+
a(x), c || u(x);
|
|
4735
4531
|
},
|
|
4736
4532
|
onBlur: ({ editor: f }) => {
|
|
4737
|
-
const
|
|
4738
|
-
l(o,
|
|
4533
|
+
const x = f.getHTML();
|
|
4534
|
+
l(o, x);
|
|
4739
4535
|
},
|
|
4740
4536
|
editorProps: {
|
|
4741
4537
|
attributes: {
|
|
@@ -4750,7 +4546,7 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4750
4546
|
}, [r]);
|
|
4751
4547
|
const m = (f) => {
|
|
4752
4548
|
a(f);
|
|
4753
|
-
},
|
|
4549
|
+
}, h = () => {
|
|
4754
4550
|
d(!1), g && g.commands.setContent(p);
|
|
4755
4551
|
};
|
|
4756
4552
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -4762,7 +4558,7 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4762
4558
|
RTEModal,
|
|
4763
4559
|
{
|
|
4764
4560
|
isOpen: c,
|
|
4765
|
-
onClose:
|
|
4561
|
+
onClose: h,
|
|
4766
4562
|
id: o,
|
|
4767
4563
|
value: p,
|
|
4768
4564
|
onChange: m,
|
|
@@ -4776,31 +4572,31 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4776
4572
|
onChange: r
|
|
4777
4573
|
}) => {
|
|
4778
4574
|
var L;
|
|
4779
|
-
const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (v, y) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState("page"), [m,
|
|
4575
|
+
const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (v, y) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState("page"), [m, h] = useState(""), [f, x] = useState([]), [b, k] = useState(-1), w = useRef(null), S = (L = n == null ? void 0 : n.find((v) => v.key === u)) == null ? void 0 : L.name;
|
|
4780
4576
|
useEffect(() => {
|
|
4781
|
-
if (
|
|
4577
|
+
if (h(""), x([]), k(-1), p(!1), !o || i || !startsWith(o, "pageType:")) return;
|
|
4782
4578
|
const v = split(o, ":"), y = get(v, 1, "page") || "page";
|
|
4783
4579
|
g(y), (async () => {
|
|
4784
|
-
const
|
|
4785
|
-
|
|
4580
|
+
const _ = await l(y, [get(v, 2, "page")]);
|
|
4581
|
+
_ && Array.isArray(_) && h(get(_, [0, "name"], ""));
|
|
4786
4582
|
})();
|
|
4787
4583
|
}, [o]);
|
|
4788
|
-
const
|
|
4584
|
+
const A = useDebouncedCallback(
|
|
4789
4585
|
async (v) => {
|
|
4790
4586
|
if (isEmpty(v))
|
|
4791
|
-
|
|
4587
|
+
x([]);
|
|
4792
4588
|
else {
|
|
4793
4589
|
const y = await l(u, v);
|
|
4794
|
-
|
|
4590
|
+
x(y);
|
|
4795
4591
|
}
|
|
4796
4592
|
c(!1), k(-1);
|
|
4797
4593
|
},
|
|
4798
4594
|
[u],
|
|
4799
4595
|
300
|
|
4800
|
-
),
|
|
4596
|
+
), E = (v) => {
|
|
4801
4597
|
const y = ["pageType", u, v.id];
|
|
4802
|
-
y[1] && (r(y.join(":")),
|
|
4803
|
-
},
|
|
4598
|
+
y[1] && (r(y.join(":")), h(v.name), p(!1), x([]), k(-1));
|
|
4599
|
+
}, j = (v) => {
|
|
4804
4600
|
switch (v.key) {
|
|
4805
4601
|
case "ArrowDown":
|
|
4806
4602
|
v.preventDefault(), k((y) => y < f.length - 1 ? y + 1 : y);
|
|
@@ -4810,23 +4606,23 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4810
4606
|
break;
|
|
4811
4607
|
case "Enter":
|
|
4812
4608
|
if (v.preventDefault(), f.length === 0) return;
|
|
4813
|
-
b >= 0 &&
|
|
4609
|
+
b >= 0 && E(f[b]);
|
|
4814
4610
|
break;
|
|
4815
4611
|
case "Escape":
|
|
4816
|
-
v.preventDefault(),
|
|
4612
|
+
v.preventDefault(), C();
|
|
4817
4613
|
break;
|
|
4818
4614
|
}
|
|
4819
4615
|
};
|
|
4820
4616
|
useEffect(() => {
|
|
4821
|
-
if (b >= 0 &&
|
|
4822
|
-
const v =
|
|
4617
|
+
if (b >= 0 && w.current) {
|
|
4618
|
+
const v = w.current.children[b];
|
|
4823
4619
|
v == null || v.scrollIntoView({ block: "nearest" });
|
|
4824
4620
|
}
|
|
4825
4621
|
}, [b]);
|
|
4826
|
-
const
|
|
4827
|
-
|
|
4828
|
-
},
|
|
4829
|
-
|
|
4622
|
+
const C = () => {
|
|
4623
|
+
h(""), x([]), k(-1), p(!1), r("");
|
|
4624
|
+
}, B = (v) => {
|
|
4625
|
+
h(v), p(!isEmpty(v)), c(!0), A(v);
|
|
4830
4626
|
};
|
|
4831
4627
|
return /* @__PURE__ */ jsxs("div", { children: [
|
|
4832
4628
|
/* @__PURE__ */ jsx("select", { name: "pageType", value: u, onChange: (v) => g(v.target.value), children: map(n, (v) => /* @__PURE__ */ jsx("option", { value: v.key, children: v.name }, v.key)) }),
|
|
@@ -4836,13 +4632,13 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4836
4632
|
{
|
|
4837
4633
|
type: "text",
|
|
4838
4634
|
value: m,
|
|
4839
|
-
onChange: (v) =>
|
|
4840
|
-
onKeyDown:
|
|
4841
|
-
placeholder: a(`Search ${
|
|
4635
|
+
onChange: (v) => B(v.target.value),
|
|
4636
|
+
onKeyDown: j,
|
|
4637
|
+
placeholder: a(`Search ${S ?? ""}`),
|
|
4842
4638
|
className: "w-full rounded-md border border-gray-300 p-2 pr-16"
|
|
4843
4639
|
}
|
|
4844
4640
|
),
|
|
4845
|
-
/* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children: m && /* @__PURE__ */ jsx("button", { onClick:
|
|
4641
|
+
/* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children: m && /* @__PURE__ */ jsx("button", { onClick: C, className: "text-gray-400 hover:text-gray-600", title: a("Clear search"), children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" }) }) })
|
|
4846
4642
|
] }),
|
|
4847
4643
|
(i || !isEmpty(f) || d && isEmpty(f)) && /* @__PURE__ */ jsx("div", { className: "absolute z-40 mt-2 max-h-40 w-full max-w-[250px] overflow-y-auto rounded-md border border-border bg-background shadow-lg", children: i ? /* @__PURE__ */ jsxs("div", { className: "space-y-1 p-2", children: [
|
|
4848
4644
|
/* @__PURE__ */ jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" }),
|
|
@@ -4852,10 +4648,10 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4852
4648
|
' "',
|
|
4853
4649
|
m,
|
|
4854
4650
|
'"'
|
|
4855
|
-
] }) : /* @__PURE__ */ jsx("ul", { ref:
|
|
4651
|
+
] }) : /* @__PURE__ */ jsx("ul", { ref: w, children: map(f == null ? void 0 : f.slice(0, 20), (v, y) => /* @__PURE__ */ jsxs(
|
|
4856
4652
|
"li",
|
|
4857
4653
|
{
|
|
4858
|
-
onClick: () =>
|
|
4654
|
+
onClick: () => E(v),
|
|
4859
4655
|
className: `cursor-pointer p-2 text-xs ${o != null && o.includes(v.id) ? "bg-blue-200" : y === b ? "bg-gray-100" : "hover:bg-gray-100"}`,
|
|
4860
4656
|
children: [
|
|
4861
4657
|
v.name,
|
|
@@ -4950,29 +4746,29 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4950
4746
|
u != null && u.length && !find(u, { _id: o == null ? void 0 : o.currentSlide }) && n({ ...o, currentSlide: get(u, "0._id") });
|
|
4951
4747
|
}, [o, u]);
|
|
4952
4748
|
const m = () => {
|
|
4953
|
-
const
|
|
4954
|
-
if (
|
|
4955
|
-
const b = (
|
|
4749
|
+
const x = findIndex(u, { _id: g });
|
|
4750
|
+
if (x > -1) {
|
|
4751
|
+
const b = (x + 1) % u.length, k = get(u, [b, "_id"]);
|
|
4956
4752
|
if (!k) return;
|
|
4957
4753
|
n({ ...o, currentSlide: k }), c([k]);
|
|
4958
4754
|
}
|
|
4959
|
-
},
|
|
4960
|
-
const
|
|
4961
|
-
if (
|
|
4962
|
-
const b = (
|
|
4755
|
+
}, h = () => {
|
|
4756
|
+
const x = findIndex(u, { _id: g });
|
|
4757
|
+
if (x > -1) {
|
|
4758
|
+
const b = (x - 1 + u.length) % u.length, k = get(u, [b, "_id"]);
|
|
4963
4759
|
if (!k) return;
|
|
4964
4760
|
n({ ...o, currentSlide: k }), c([k]);
|
|
4965
4761
|
}
|
|
4966
4762
|
}, f = () => {
|
|
4967
|
-
const
|
|
4763
|
+
const x = i(
|
|
4968
4764
|
{ styles: "#styles:,h-full w-full min-w-full", type: "Slide" },
|
|
4969
4765
|
p == null ? void 0 : p._id
|
|
4970
|
-
), b =
|
|
4766
|
+
), b = x == null ? void 0 : x._id;
|
|
4971
4767
|
b && (n({ ...o, currentSlide: b }), c([b]));
|
|
4972
4768
|
};
|
|
4973
4769
|
return /* @__PURE__ */ jsxs("div", { className: "space-y-1.5 px-2", children: [
|
|
4974
4770
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2 pb-2 text-[12px]", children: [
|
|
4975
|
-
/* @__PURE__ */ jsx("button", { onClick:
|
|
4771
|
+
/* @__PURE__ */ jsx("button", { onClick: h, className: "rounded bg-gray-200 p-1.5 hover:opacity-80", children: /* @__PURE__ */ jsx(ChevronLeft, { className: "h-3 w-3 stroke-[3]" }) }),
|
|
4976
4772
|
/* @__PURE__ */ jsx("div", { className: "whitespace-nowrap text-center text-[10px] text-slate-500", children: g ? /* @__PURE__ */ jsxs("span", { className: "", children: [
|
|
4977
4773
|
/* @__PURE__ */ jsxs("b", { className: "text-[12px]", children: [
|
|
4978
4774
|
" ",
|
|
@@ -5046,8 +4842,8 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
5046
4842
|
value: o == null ? void 0 : o.autoplayInterval,
|
|
5047
4843
|
className: "text-xs",
|
|
5048
4844
|
pattern: "[0-9]*",
|
|
5049
|
-
onChange: (
|
|
5050
|
-
let b =
|
|
4845
|
+
onChange: (x) => {
|
|
4846
|
+
let b = x.target.value;
|
|
5051
4847
|
b.length && (b = b.replace("-", "")), n({ ...o, autoplayInterval: b });
|
|
5052
4848
|
}
|
|
5053
4849
|
}
|
|
@@ -5087,12 +4883,12 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
5087
4883
|
formData: g,
|
|
5088
4884
|
onChange: m
|
|
5089
4885
|
}) => {
|
|
5090
|
-
const { selectedLang:
|
|
4886
|
+
const { selectedLang: h, fallbackLang: f, languages: x } = useLanguages(), b = isEmpty(x) ? "" : isEmpty(h) ? f : h, k = get(LANGUAGES, b, b), w = usePageExternalData(), S = useSelectedBlock(), A = useRegisteredChaiBlocks(), E = get(A, [S == null ? void 0 : S._type, "i18nProps"], []) || [], [j, C] = useState(null), B = useCallback(
|
|
5091
4887
|
(y) => {
|
|
5092
|
-
const
|
|
4888
|
+
const _ = (P) => /[.,!?;:]/.test(P), T = (P, N, M) => {
|
|
5093
4889
|
let D = "", O = "";
|
|
5094
4890
|
const $ = N > 0 ? P[N - 1] : "", H = N < P.length ? P[N] : "";
|
|
5095
|
-
return N > 0 && ($ === "." || !
|
|
4891
|
+
return N > 0 && ($ === "." || !_($) && $ !== " ") && (D = " "), N < P.length && !_(H) && H !== " " && (O = " "), {
|
|
5096
4892
|
text: D + M + O,
|
|
5097
4893
|
prefixLength: D.length,
|
|
5098
4894
|
suffixLength: O.length
|
|
@@ -5111,9 +4907,9 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
5111
4907
|
else {
|
|
5112
4908
|
const { state: $ } = P, H = $.selection.from, U = $.doc.textBetween(Math.max(0, H - 1), H), F = $.doc.textBetween(H, Math.min(H + 1, $.doc.content.size));
|
|
5113
4909
|
let z = "";
|
|
5114
|
-
H > 0 && U !== " " && !
|
|
4910
|
+
H > 0 && U !== " " && !_(U) && (z = " ");
|
|
5115
4911
|
let W = "";
|
|
5116
|
-
F && F !== " " && !
|
|
4912
|
+
F && F !== " " && !_(F) && (W = " "), P.chain().insertContent(z + N + W).run();
|
|
5117
4913
|
}
|
|
5118
4914
|
setTimeout(() => m(P.getHTML(), {}, o), 100);
|
|
5119
4915
|
return;
|
|
@@ -5129,20 +4925,20 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
5129
4925
|
m(U, {}, o);
|
|
5130
4926
|
}
|
|
5131
4927
|
},
|
|
5132
|
-
[o, m, g,
|
|
4928
|
+
[o, m, g, S == null ? void 0 : S._id]
|
|
5133
4929
|
);
|
|
5134
4930
|
if (d)
|
|
5135
4931
|
return null;
|
|
5136
4932
|
if (u.type === "boolean") return /* @__PURE__ */ jsx("div", { className: n, children: a });
|
|
5137
|
-
const v =
|
|
4933
|
+
const v = E == null ? void 0 : E.includes(o.replace("root.", ""));
|
|
5138
4934
|
if (u.type === "array") {
|
|
5139
|
-
const y =
|
|
4935
|
+
const y = j === o;
|
|
5140
4936
|
return /* @__PURE__ */ jsxs("div", { className: `${n} relative`, children: [
|
|
5141
4937
|
u.title && /* @__PURE__ */ jsxs(
|
|
5142
4938
|
"label",
|
|
5143
4939
|
{
|
|
5144
4940
|
htmlFor: o,
|
|
5145
|
-
onClick: () =>
|
|
4941
|
+
onClick: () => C(y ? null : o),
|
|
5146
4942
|
className: "flex cursor-pointer items-center gap-x-1 py-1 leading-tight duration-200 hover:bg-slate-100",
|
|
5147
4943
|
children: [
|
|
5148
4944
|
y ? /* @__PURE__ */ jsx(ChevronDown, { className: "h-3 w-3" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "h-3 w-3" }),
|
|
@@ -5172,7 +4968,7 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
5172
4968
|
] }),
|
|
5173
4969
|
p && u.type !== "object" ? " *" : null
|
|
5174
4970
|
] }),
|
|
5175
|
-
u.type === "string" && !u.enum && !u.oneOf &&
|
|
4971
|
+
u.type === "string" && !u.enum && !u.oneOf && w && /* @__PURE__ */ jsx(NestedPathSelector, { data: w, onSelect: B, dataType: "value" })
|
|
5176
4972
|
] }),
|
|
5177
4973
|
c,
|
|
5178
4974
|
a,
|
|
@@ -5227,8 +5023,8 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
5227
5023
|
formData: a,
|
|
5228
5024
|
onChange: ({ formData: g }, m) => {
|
|
5229
5025
|
if (!m || o !== (g == null ? void 0 : g._id)) return;
|
|
5230
|
-
const
|
|
5231
|
-
u({ formData: g },
|
|
5026
|
+
const h = take(m.split("."), 2).join(".").replace("root.", "");
|
|
5027
|
+
u({ formData: g }, h);
|
|
5232
5028
|
}
|
|
5233
5029
|
},
|
|
5234
5030
|
i
|
|
@@ -5271,35 +5067,35 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
5271
5067
|
}), a;
|
|
5272
5068
|
};
|
|
5273
5069
|
function BlockSettings() {
|
|
5274
|
-
const { selectedLang: o } = useLanguages(), n = useSelectedBlock(), r = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), l = getRegisteredChaiBlock(n == null ? void 0 : n._type), i = formDataWithSelectedLang(n, o, l), [c, d] = useState(i), [p, u] = useState(!1), g = useWrapperBlock(), m = getRegisteredChaiBlock(g == null ? void 0 : g._type),
|
|
5275
|
-
|
|
5276
|
-
},
|
|
5277
|
-
debounce(({ formData:
|
|
5278
|
-
f({ formData:
|
|
5070
|
+
const { selectedLang: o } = useLanguages(), n = useSelectedBlock(), r = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), l = getRegisteredChaiBlock(n == null ? void 0 : n._type), i = formDataWithSelectedLang(n, o, l), [c, d] = useState(i), [p, u] = useState(!1), g = useWrapperBlock(), m = getRegisteredChaiBlock(g == null ? void 0 : g._type), h = formDataWithSelectedLang(g, o, m), f = ({ formData: j }, C, B) => {
|
|
5071
|
+
C && (c == null ? void 0 : c._id) === n._id && a([n._id], { [C]: get(j, C) }, B);
|
|
5072
|
+
}, x = useCallback(
|
|
5073
|
+
debounce(({ formData: j }, C, B) => {
|
|
5074
|
+
f({ formData: j }, C, B), d(j);
|
|
5279
5075
|
}, 1500),
|
|
5280
5076
|
[n == null ? void 0 : n._id, o]
|
|
5281
|
-
), b = ({ formData:
|
|
5282
|
-
|
|
5283
|
-
}, k = ({ formData:
|
|
5284
|
-
|
|
5077
|
+
), b = ({ formData: j }, C) => {
|
|
5078
|
+
C && (r([n._id], { [C]: get(j, C) }), x({ formData: j }, C, { [C]: get(c, C) }));
|
|
5079
|
+
}, k = ({ formData: j }, C) => {
|
|
5080
|
+
C && (r([g._id], { [C]: get(j, C) }), x({ formData: j }, C, { [C]: get(c, C) }));
|
|
5285
5081
|
};
|
|
5286
5082
|
keys(get(i, "_bindings", {}));
|
|
5287
|
-
const { schema:
|
|
5288
|
-
const
|
|
5289
|
-
if (
|
|
5290
|
-
return getBlockFormSchemas(
|
|
5291
|
-
}, [n]), { wrapperSchema:
|
|
5083
|
+
const { schema: w, uiSchema: S } = useMemo(() => {
|
|
5084
|
+
const j = n == null ? void 0 : n._type;
|
|
5085
|
+
if (j)
|
|
5086
|
+
return getBlockFormSchemas(j);
|
|
5087
|
+
}, [n]), { wrapperSchema: A, wrapperUiSchema: E } = useMemo(() => {
|
|
5292
5088
|
if (!g || !(g != null && g._type))
|
|
5293
5089
|
return { wrapperSchema: {}, wrapperUiSchema: {} };
|
|
5294
|
-
const
|
|
5295
|
-
return { wrapperSchema:
|
|
5090
|
+
const j = g == null ? void 0 : g._type, { schema: C = {}, uiSchema: B = {} } = getBlockFormSchemas(j);
|
|
5091
|
+
return { wrapperSchema: C, wrapperUiSchema: B };
|
|
5296
5092
|
}, [g]);
|
|
5297
5093
|
return /* @__PURE__ */ jsxs("div", { className: "no-scrollbar overflow-x-hidden px-px", children: [
|
|
5298
5094
|
!isEmpty(g) && /* @__PURE__ */ jsxs("div", { className: "mb-4 rounded border bg-zinc-100 px-1", children: [
|
|
5299
5095
|
/* @__PURE__ */ jsxs(
|
|
5300
5096
|
"div",
|
|
5301
5097
|
{
|
|
5302
|
-
onClick: () => u((
|
|
5098
|
+
onClick: () => u((j) => !j),
|
|
5303
5099
|
className: "flex cursor-pointer items-center gap-x-1 py-2 text-xs font-medium leading-tight hover:bg-slate-100",
|
|
5304
5100
|
children: [
|
|
5305
5101
|
p ? /* @__PURE__ */ jsx(ChevronDown, { className: "h-4 w-4 stroke-[3] text-slate-400" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4 stroke-[3] text-slate-400" }),
|
|
@@ -5319,20 +5115,20 @@ function BlockSettings() {
|
|
|
5319
5115
|
{
|
|
5320
5116
|
blockId: g == null ? void 0 : g._id,
|
|
5321
5117
|
onChange: k,
|
|
5322
|
-
formData:
|
|
5323
|
-
schema:
|
|
5324
|
-
uiSchema:
|
|
5118
|
+
formData: h,
|
|
5119
|
+
schema: A,
|
|
5120
|
+
uiSchema: E
|
|
5325
5121
|
}
|
|
5326
5122
|
) })
|
|
5327
5123
|
] }),
|
|
5328
|
-
isEmpty(
|
|
5124
|
+
isEmpty(w) ? null : /* @__PURE__ */ jsx(
|
|
5329
5125
|
JSONForm,
|
|
5330
5126
|
{
|
|
5331
5127
|
blockId: n == null ? void 0 : n._id,
|
|
5332
5128
|
onChange: b,
|
|
5333
5129
|
formData: i,
|
|
5334
|
-
schema:
|
|
5335
|
-
uiSchema:
|
|
5130
|
+
schema: w,
|
|
5131
|
+
uiSchema: S
|
|
5336
5132
|
}
|
|
5337
5133
|
),
|
|
5338
5134
|
(n == null ? void 0 : n._type) === "GlobalBlock" ? /* @__PURE__ */ jsx(GlobalBlockSettings, {}) : null
|
|
@@ -5437,23 +5233,23 @@ const TabletIcon = ({ landscape: o = !1 }) => /* @__PURE__ */ jsx(
|
|
|
5437
5233
|
canvas: n = !1,
|
|
5438
5234
|
tooltip: r = !0
|
|
5439
5235
|
}) => {
|
|
5440
|
-
const [a, , l] = useScreenSizeWidth(), [i, c] = useCanvasDisplayWidth(), [d, p] = useSelectedBreakpoints(), u = d, g = p, { t: m } = useTranslation(),
|
|
5441
|
-
u.includes(k) ? u.length > 2 && g(u.filter((
|
|
5442
|
-
},
|
|
5236
|
+
const [a, , l] = useScreenSizeWidth(), [i, c] = useCanvasDisplayWidth(), [d, p] = useSelectedBreakpoints(), u = d, g = p, { t: m } = useTranslation(), h = useBuilderProp("breakpoints", WEB_BREAKPOINTS), f = (k) => {
|
|
5237
|
+
u.includes(k) ? u.length > 2 && g(u.filter((w) => w !== k)) : g((w) => [...w, k]);
|
|
5238
|
+
}, x = (k) => {
|
|
5443
5239
|
n || l(k), c(k);
|
|
5444
5240
|
}, b = getBreakpointValue(n ? i : a).toLowerCase();
|
|
5445
|
-
return
|
|
5241
|
+
return h.length < 4 ? /* @__PURE__ */ jsx("div", { className: "flex items-center rounded-md", children: map(h, (k) => /* @__PURE__ */ createElement(
|
|
5446
5242
|
BreakpointCard,
|
|
5447
5243
|
{
|
|
5448
5244
|
canvas: n,
|
|
5449
5245
|
...k,
|
|
5450
|
-
onClick:
|
|
5246
|
+
onClick: x,
|
|
5451
5247
|
key: k.breakpoint,
|
|
5452
5248
|
currentBreakpoint: b
|
|
5453
5249
|
}
|
|
5454
5250
|
)) }) : /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between rounded-md", children: [
|
|
5455
5251
|
/* @__PURE__ */ jsx("div", { className: "flex items-center", children: map(
|
|
5456
|
-
|
|
5252
|
+
h.filter((k) => includes(u, toUpper(k.breakpoint))),
|
|
5457
5253
|
(k) => /* @__PURE__ */ createElement(
|
|
5458
5254
|
BreakpointCard,
|
|
5459
5255
|
{
|
|
@@ -5461,7 +5257,7 @@ const TabletIcon = ({ landscape: o = !1 }) => /* @__PURE__ */ jsx(
|
|
|
5461
5257
|
openDelay: o,
|
|
5462
5258
|
tooltip: r,
|
|
5463
5259
|
...k,
|
|
5464
|
-
onClick:
|
|
5260
|
+
onClick: x,
|
|
5465
5261
|
key: k.breakpoint,
|
|
5466
5262
|
currentBreakpoint: b
|
|
5467
5263
|
}
|
|
@@ -5472,7 +5268,7 @@ const TabletIcon = ({ landscape: o = !1 }) => /* @__PURE__ */ jsx(
|
|
|
5472
5268
|
/* @__PURE__ */ jsxs(DropdownMenuContent, { className: "w-56 border-border text-xs", children: [
|
|
5473
5269
|
/* @__PURE__ */ jsx(DropdownMenuLabel, { children: m("Screen sizes") }),
|
|
5474
5270
|
/* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
|
|
5475
|
-
map(
|
|
5271
|
+
map(h, (k) => /* @__PURE__ */ jsx(
|
|
5476
5272
|
DropdownMenuCheckboxItem,
|
|
5477
5273
|
{
|
|
5478
5274
|
disabled: k.breakpoint === "xs",
|
|
@@ -5557,11 +5353,11 @@ function Countdown() {
|
|
|
5557
5353
|
const AskAIStyles = ({ blockId: o }) => {
|
|
5558
5354
|
const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, c] = useState(""), d = useRef(null), p = useRef(null), [u, g] = useState();
|
|
5559
5355
|
useEffect(() => {
|
|
5560
|
-
var
|
|
5561
|
-
(
|
|
5356
|
+
var h;
|
|
5357
|
+
(h = d.current) == null || h.focus();
|
|
5562
5358
|
}, []);
|
|
5563
|
-
const m = (
|
|
5564
|
-
const { usage: f } =
|
|
5359
|
+
const m = (h) => {
|
|
5360
|
+
const { usage: f } = h || {};
|
|
5565
5361
|
!l && f && g(f), p.current = setTimeout(() => g(void 0), 1e4), l || c("");
|
|
5566
5362
|
};
|
|
5567
5363
|
return /* @__PURE__ */ jsxs("div", { className: "", children: [
|
|
@@ -5571,12 +5367,12 @@ const AskAIStyles = ({ blockId: o }) => {
|
|
|
5571
5367
|
{
|
|
5572
5368
|
ref: d,
|
|
5573
5369
|
value: i,
|
|
5574
|
-
onChange: (
|
|
5370
|
+
onChange: (h) => c(h.target.value),
|
|
5575
5371
|
placeholder: n("Ask AI to edit styles"),
|
|
5576
5372
|
className: "no-scrollbar my-2 w-full border border-border p-2 text-xs",
|
|
5577
5373
|
rows: 4,
|
|
5578
|
-
onKeyDown: (
|
|
5579
|
-
|
|
5374
|
+
onKeyDown: (h) => {
|
|
5375
|
+
h.key === "Enter" && (h.preventDefault(), p.current && clearTimeout(p.current), g(void 0), r("styles", o, i, m));
|
|
5580
5376
|
}
|
|
5581
5377
|
}
|
|
5582
5378
|
),
|
|
@@ -5618,10 +5414,10 @@ const AskAIStyles = ({ blockId: o }) => {
|
|
|
5618
5414
|
};
|
|
5619
5415
|
function ManualClasses() {
|
|
5620
5416
|
var T;
|
|
5621
|
-
const o = useRef(null), [n, r] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: c } = useTranslation(), [d] = useSelectedStylingBlocks(), p = useSelectedBlock(), u = useAddClassesToBlocks(), g = useRemoveClassesFromBlocks(), [m] = useSelectedBlockIds(),
|
|
5417
|
+
const o = useRef(null), [n, r] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: c } = useTranslation(), [d] = useSelectedStylingBlocks(), p = useSelectedBlock(), u = useAddClassesToBlocks(), g = useRemoveClassesFromBlocks(), [m] = useSelectedBlockIds(), h = useBuilderProp("askAiCallBack", null), [f, x] = useState(""), b = (T = first(d)) == null ? void 0 : T.prop, { classes: k } = getSplitChaiClasses(get(p, b, "")), w = k.split(" ").filter((I) => !isEmpty(I)), S = () => {
|
|
5622
5418
|
const I = f.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
|
|
5623
|
-
u(m, I, !0),
|
|
5624
|
-
}, [
|
|
5419
|
+
u(m, I, !0), x("");
|
|
5420
|
+
}, [A, E] = useState([]), j = ({ value: I }) => {
|
|
5625
5421
|
const R = I.trim().toLowerCase(), P = R.match(/.+:/g);
|
|
5626
5422
|
let N = [];
|
|
5627
5423
|
if (P && P.length > 0) {
|
|
@@ -5632,10 +5428,10 @@ function ManualClasses() {
|
|
|
5632
5428
|
}));
|
|
5633
5429
|
} else
|
|
5634
5430
|
N = i.search(R);
|
|
5635
|
-
return
|
|
5636
|
-
},
|
|
5637
|
-
|
|
5638
|
-
},
|
|
5431
|
+
return E(map(N, "item"));
|
|
5432
|
+
}, C = () => {
|
|
5433
|
+
E([]);
|
|
5434
|
+
}, B = (I) => I.name, L = (I) => /* @__PURE__ */ jsx("div", { className: "rounded-md p-1", children: I.name }), v = useMemo(
|
|
5639
5435
|
() => ({
|
|
5640
5436
|
ref: o,
|
|
5641
5437
|
autoComplete: "off",
|
|
@@ -5645,9 +5441,9 @@ function ManualClasses() {
|
|
|
5645
5441
|
placeholder: c("Enter classes separated by space"),
|
|
5646
5442
|
value: f,
|
|
5647
5443
|
onKeyDown: (I) => {
|
|
5648
|
-
I.key === "Enter" && f.trim() !== "" &&
|
|
5444
|
+
I.key === "Enter" && f.trim() !== "" && S();
|
|
5649
5445
|
},
|
|
5650
|
-
onChange: (I, { newValue: R }) =>
|
|
5446
|
+
onChange: (I, { newValue: R }) => x(R),
|
|
5651
5447
|
className: "w-full rounded-md text-xs px-2 hover:outline-0 bg-background border-border py-1"
|
|
5652
5448
|
}),
|
|
5653
5449
|
[f, c, o]
|
|
@@ -5655,23 +5451,23 @@ function ManualClasses() {
|
|
|
5655
5451
|
debugger;
|
|
5656
5452
|
const R = n.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
|
|
5657
5453
|
g(m, [I]), u(m, R, !0), r(""), l(-1);
|
|
5658
|
-
},
|
|
5454
|
+
}, _ = () => {
|
|
5659
5455
|
if (navigator.clipboard === void 0) {
|
|
5660
5456
|
toast.error(c("Clipboard not supported"));
|
|
5661
5457
|
return;
|
|
5662
5458
|
}
|
|
5663
|
-
navigator.clipboard.writeText(
|
|
5459
|
+
navigator.clipboard.writeText(w.join(" ")), toast.success(c("Classes copied to clipboard"));
|
|
5664
5460
|
};
|
|
5665
5461
|
return /* @__PURE__ */ jsxs("div", { className: "flex w-full flex-col gap-y-1.5 border-b border-border pb-4", children: [
|
|
5666
5462
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-x-2", children: [
|
|
5667
5463
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2 text-muted-foreground", children: [
|
|
5668
5464
|
/* @__PURE__ */ jsx("span", { children: c("Classes") }),
|
|
5669
5465
|
/* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
5670
|
-
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(CopyIcon, { onClick:
|
|
5466
|
+
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(CopyIcon, { onClick: _, className: "cursor-pointer" }) }),
|
|
5671
5467
|
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: c("Copy classes to clipboard") }) })
|
|
5672
5468
|
] })
|
|
5673
5469
|
] }),
|
|
5674
|
-
|
|
5470
|
+
h ? /* @__PURE__ */ jsxs(Popover, { children: [
|
|
5675
5471
|
/* @__PURE__ */ jsx(PopoverTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(Button, { variant: "default", className: "h-6 w-fit", size: "sm", children: [
|
|
5676
5472
|
/* @__PURE__ */ jsx(SparklesIcon, { className: "h-4 w-4" }),
|
|
5677
5473
|
/* @__PURE__ */ jsx("span", { className: "ml-2", children: c("Ask AI") })
|
|
@@ -5683,10 +5479,10 @@ function ManualClasses() {
|
|
|
5683
5479
|
/* @__PURE__ */ jsx("div", { className: "relative flex w-full items-center gap-x-3", children: /* @__PURE__ */ jsx(
|
|
5684
5480
|
Autosuggest,
|
|
5685
5481
|
{
|
|
5686
|
-
suggestions:
|
|
5687
|
-
onSuggestionsFetchRequested:
|
|
5688
|
-
onSuggestionsClearRequested:
|
|
5689
|
-
getSuggestionValue:
|
|
5482
|
+
suggestions: A,
|
|
5483
|
+
onSuggestionsFetchRequested: j,
|
|
5484
|
+
onSuggestionsClearRequested: C,
|
|
5485
|
+
getSuggestionValue: B,
|
|
5690
5486
|
renderSuggestion: L,
|
|
5691
5487
|
inputProps: v,
|
|
5692
5488
|
containerProps: {
|
|
@@ -5704,14 +5500,14 @@ function ManualClasses() {
|
|
|
5704
5500
|
{
|
|
5705
5501
|
variant: "outline",
|
|
5706
5502
|
className: "h-6 border-border",
|
|
5707
|
-
onClick:
|
|
5503
|
+
onClick: S,
|
|
5708
5504
|
disabled: f.trim() === "",
|
|
5709
5505
|
size: "sm",
|
|
5710
5506
|
children: /* @__PURE__ */ jsx(PlusIcon, {})
|
|
5711
5507
|
}
|
|
5712
5508
|
)
|
|
5713
5509
|
] }),
|
|
5714
|
-
/* @__PURE__ */ jsx("div", { className: "flex w-full flex-wrap gap-2 overflow-x-hidden", children:
|
|
5510
|
+
/* @__PURE__ */ jsx("div", { className: "flex w-full flex-wrap gap-2 overflow-x-hidden", children: w.map(
|
|
5715
5511
|
(I, R) => a === R ? /* @__PURE__ */ jsx(
|
|
5716
5512
|
"input",
|
|
5717
5513
|
{
|
|
@@ -5859,29 +5655,151 @@ const BlockStylingProps = () => {
|
|
|
5859
5655
|
)) }),
|
|
5860
5656
|
/* @__PURE__ */ jsx("div", { className: "my-2 h-[1px] w-full bg-border" })
|
|
5861
5657
|
] });
|
|
5862
|
-
},
|
|
5863
|
-
|
|
5864
|
-
|
|
5865
|
-
|
|
5866
|
-
|
|
5867
|
-
|
|
5868
|
-
|
|
5869
|
-
|
|
5870
|
-
|
|
5871
|
-
|
|
5872
|
-
|
|
5873
|
-
|
|
5874
|
-
|
|
5875
|
-
|
|
5876
|
-
|
|
5877
|
-
|
|
5878
|
-
|
|
5879
|
-
|
|
5880
|
-
|
|
5881
|
-
|
|
5882
|
-
|
|
5883
|
-
|
|
5884
|
-
|
|
5658
|
+
}, StyleContext = createContext({ canReset: !1, canChange: !0 }), BlockStyleProvider = ({ children: o, canReset: n = !1, canChange: r = !0 }) => (
|
|
5659
|
+
// eslint-disable-next-line react/jsx-no-constructed-context-values
|
|
5660
|
+
/* @__PURE__ */ jsx(StyleContext.Provider, { value: { canReset: n, canChange: r }, children: o })
|
|
5661
|
+
), DropDownChoices = ({ label: o, property: n, onChange: r }) => {
|
|
5662
|
+
const { getClasses: a } = useTailwindClassList(), l = a(n), i = useCurrentClassByProperty(n), c = useMemo(() => get(i, "cls", ""), [i]), { canChange: d } = useContext(StyleContext), p = /\[.*\]/g.test(c);
|
|
5663
|
+
return /* @__PURE__ */ jsx("div", { className: o ? "w-full rounded" : "grow", children: p ? /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
|
|
5664
|
+
/* @__PURE__ */ jsx(Input$1, { className: "w-[70%] rounded py-1", readOnly: !0, value: c }),
|
|
5665
|
+
/* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
|
|
5666
|
+
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx("button", { type: "button", className: "invisible ml-3 mt-1 text-blue-600 group-hover:visible", children: /* @__PURE__ */ jsx(InfoCircledIcon, {}) }) }),
|
|
5667
|
+
/* @__PURE__ */ jsx(TooltipContent, { children: "Current value is using a Tailwind arbitrary value." })
|
|
5668
|
+
] })
|
|
5669
|
+
] }) : /* @__PURE__ */ jsx(
|
|
5670
|
+
DropDown,
|
|
5671
|
+
{
|
|
5672
|
+
rounded: o,
|
|
5673
|
+
onChange: (u) => r(u, n),
|
|
5674
|
+
selected: c,
|
|
5675
|
+
options: l,
|
|
5676
|
+
disabled: !d
|
|
5677
|
+
}
|
|
5678
|
+
) });
|
|
5679
|
+
};
|
|
5680
|
+
function DropDown({ selected: o, onChange: n, rounded: r = !1, options: a, disabled: l = !1 }) {
|
|
5681
|
+
const i = o.replace(/.*:/g, "").trim(), { undo: c, redo: d } = useUndoManager();
|
|
5682
|
+
return /* @__PURE__ */ jsxs(
|
|
5683
|
+
"select",
|
|
5684
|
+
{
|
|
5685
|
+
disabled: !a.length || l,
|
|
5686
|
+
className: `${r ? "rounded-md border border-border" : "border-0"} disable:bg-gray-500 h-full w-full truncate rounded bg-background px-2 py-1 text-xs outline-none disabled:cursor-not-allowed`,
|
|
5687
|
+
onChange: (p) => n(p.target.value),
|
|
5688
|
+
onKeyDown: (p) => {
|
|
5689
|
+
p.ctrlKey && (p.key === "z" && c(), p.key === "y" && d());
|
|
5690
|
+
},
|
|
5691
|
+
value: i,
|
|
5692
|
+
children: [
|
|
5693
|
+
/* @__PURE__ */ jsx("option", { className: "bg-transparent", value: "" }),
|
|
5694
|
+
a.map((p, u) => /* @__PURE__ */ jsx("option", { className: "bg-transparent", value: p, children: p }, `option-${u}`))
|
|
5695
|
+
]
|
|
5696
|
+
}
|
|
5697
|
+
);
|
|
5698
|
+
}
|
|
5699
|
+
const COLOR_PROP = {
|
|
5700
|
+
backgroundColor: "bg",
|
|
5701
|
+
textColor: "text",
|
|
5702
|
+
borderColor: "border",
|
|
5703
|
+
boxShadowColor: "shadow",
|
|
5704
|
+
outlineColor: "outline",
|
|
5705
|
+
divideColor: "divide",
|
|
5706
|
+
fromColor: "from",
|
|
5707
|
+
viaColor: "via",
|
|
5708
|
+
toColor: "to",
|
|
5709
|
+
ringColor: "ring",
|
|
5710
|
+
ringOffsetColor: "ring-offset"
|
|
5711
|
+
}, ColorChoice = ({ property: o, onChange: n }) => {
|
|
5712
|
+
const r = useCurrentClassByProperty(o), a = useMemo(() => get(r, "cls", ""), [r]), { canChange: l } = useContext(StyleContext), [i, c] = useState([]), [d, p] = useState({ color: "", shade: "" }), u = a.split("-"), g = get(u, "1", ""), m = get(u, "2", ""), h = useCallback(
|
|
5713
|
+
// eslint-disable-next-line no-shadow
|
|
5714
|
+
(b) => {
|
|
5715
|
+
["current", "inherit", "transparent", "black", "white"].includes(b) ? (c([]), p({ color: b })) : (c(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]), p((k) => ({ ...k, color: b, shade: k.shade ? k.shade : "500" })));
|
|
5716
|
+
},
|
|
5717
|
+
[c, p]
|
|
5718
|
+
);
|
|
5719
|
+
useEffect(() => {
|
|
5720
|
+
if (["current", "inherit", "transparent", "black", "white"].includes(g))
|
|
5721
|
+
return c([]);
|
|
5722
|
+
c(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]);
|
|
5723
|
+
}, [g]);
|
|
5724
|
+
const f = useCallback(
|
|
5725
|
+
// eslint-disable-next-line no-shadow
|
|
5726
|
+
(b) => {
|
|
5727
|
+
p({ color: g, shade: b });
|
|
5728
|
+
},
|
|
5729
|
+
[g]
|
|
5730
|
+
);
|
|
5731
|
+
useEffect(() => {
|
|
5732
|
+
p({ color: "", shade: "" });
|
|
5733
|
+
}, [r]);
|
|
5734
|
+
const { match: x } = useTailwindClassList();
|
|
5735
|
+
return useEffect(() => {
|
|
5736
|
+
const k = `${get(COLOR_PROP, o, "")}-${d.color}${d.shade ? `-${d.shade}` : ""}`;
|
|
5737
|
+
x(o, k) && n(k, o);
|
|
5738
|
+
}, [x, d, n, o]), /* @__PURE__ */ jsxs("div", { className: "flex flex-row divide-x divide-solid divide-border rounded-lg border border-transparent text-xs", children: [
|
|
5739
|
+
/* @__PURE__ */ jsx("div", { className: "grow text-center", children: /* @__PURE__ */ jsx(
|
|
5740
|
+
DropDown,
|
|
5741
|
+
{
|
|
5742
|
+
disabled: !l,
|
|
5743
|
+
rounded: !0,
|
|
5744
|
+
selected: g,
|
|
5745
|
+
onChange: h,
|
|
5746
|
+
options: [
|
|
5747
|
+
"current",
|
|
5748
|
+
"transparent",
|
|
5749
|
+
"primary",
|
|
5750
|
+
"secondary",
|
|
5751
|
+
"black",
|
|
5752
|
+
"white",
|
|
5753
|
+
"slate",
|
|
5754
|
+
"gray",
|
|
5755
|
+
"zinc",
|
|
5756
|
+
"neutral",
|
|
5757
|
+
"stone",
|
|
5758
|
+
"red",
|
|
5759
|
+
"orange",
|
|
5760
|
+
"amber",
|
|
5761
|
+
"yellow",
|
|
5762
|
+
"lime",
|
|
5763
|
+
"green",
|
|
5764
|
+
"emerald",
|
|
5765
|
+
"teal",
|
|
5766
|
+
"cyan",
|
|
5767
|
+
"sky",
|
|
5768
|
+
"blue",
|
|
5769
|
+
"indigo",
|
|
5770
|
+
"violet",
|
|
5771
|
+
"purple",
|
|
5772
|
+
"fuchsia",
|
|
5773
|
+
"pink",
|
|
5774
|
+
"rose"
|
|
5775
|
+
]
|
|
5776
|
+
}
|
|
5777
|
+
) }),
|
|
5778
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: "grow text-center", children: /* @__PURE__ */ jsx(DropDown, { rounded: !0, selected: m, disabled: !g || !l, onChange: f, options: i }) })
|
|
5779
|
+
] });
|
|
5780
|
+
}, EDITOR_ICONS = {
|
|
5781
|
+
"not-italic": () => /* @__PURE__ */ jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M9 3H11V5H9V11H11V13H5V11H7V5H5V3H9Z", fill: "white" }) }),
|
|
5782
|
+
// visibility
|
|
5783
|
+
visible: EyeOpenIcon,
|
|
5784
|
+
invisible: EyeClosedIcon,
|
|
5785
|
+
// display
|
|
5786
|
+
hidden: EyeClosedIcon,
|
|
5787
|
+
gap: BorderAllIcon,
|
|
5788
|
+
gapX: WidthIcon,
|
|
5789
|
+
gapY: HeightIcon,
|
|
5790
|
+
spaceX: WidthIcon,
|
|
5791
|
+
spaceY: HeightIcon,
|
|
5792
|
+
overscroll: BorderAllIcon,
|
|
5793
|
+
overscrollX: WidthIcon,
|
|
5794
|
+
overscrollY: HeightIcon,
|
|
5795
|
+
overflow: BorderAllIcon,
|
|
5796
|
+
overflowX: WidthIcon,
|
|
5797
|
+
overflowY: HeightIcon,
|
|
5798
|
+
top: ArrowUpIcon,
|
|
5799
|
+
right: ArrowRightIcon,
|
|
5800
|
+
bottom: ArrowDownIcon,
|
|
5801
|
+
left: ArrowLeftIcon,
|
|
5802
|
+
inset: BorderAllIcon,
|
|
5885
5803
|
insetX: WidthIcon,
|
|
5886
5804
|
insetY: HeightIcon,
|
|
5887
5805
|
border: BorderAllIcon,
|
|
@@ -6053,130 +5971,6 @@ const BlockStylingProps = () => {
|
|
|
6053
5971
|
)
|
|
6054
5972
|
] }),
|
|
6055
5973
|
static: Cross1Icon
|
|
6056
|
-
}, StyleContext = createContext({ canReset: !1, canChange: !0 }), BlockStyleProvider = ({ children: o, canReset: n = !1, canChange: r = !0 }) => (
|
|
6057
|
-
// eslint-disable-next-line react/jsx-no-constructed-context-values
|
|
6058
|
-
/* @__PURE__ */ jsx(StyleContext.Provider, { value: { canReset: n, canChange: r }, children: o })
|
|
6059
|
-
), DropDownChoices = ({ label: o, property: n, onChange: r }) => {
|
|
6060
|
-
const { getClasses: a } = useTailwindClassList(), l = a(n), i = useCurrentClassByProperty(n), c = useMemo(() => get(i, "cls", ""), [i]), { canChange: d } = useContext(StyleContext), p = /\[.*\]/g.test(c);
|
|
6061
|
-
return /* @__PURE__ */ jsx("div", { className: o ? "w-full rounded" : "grow", children: p ? /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
|
|
6062
|
-
/* @__PURE__ */ jsx(Input$1, { className: "w-[70%] rounded py-1", readOnly: !0, value: c }),
|
|
6063
|
-
/* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
|
|
6064
|
-
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx("button", { type: "button", className: "invisible ml-3 mt-1 text-blue-600 group-hover:visible", children: /* @__PURE__ */ jsx(InfoCircledIcon, {}) }) }),
|
|
6065
|
-
/* @__PURE__ */ jsx(TooltipContent, { children: "Current value is using a Tailwind arbitrary value." })
|
|
6066
|
-
] })
|
|
6067
|
-
] }) : /* @__PURE__ */ jsx(
|
|
6068
|
-
DropDown,
|
|
6069
|
-
{
|
|
6070
|
-
rounded: o,
|
|
6071
|
-
onChange: (u) => r(u, n),
|
|
6072
|
-
selected: c,
|
|
6073
|
-
options: l,
|
|
6074
|
-
disabled: !d
|
|
6075
|
-
}
|
|
6076
|
-
) });
|
|
6077
|
-
};
|
|
6078
|
-
function DropDown({ selected: o, onChange: n, rounded: r = !1, options: a, disabled: l = !1 }) {
|
|
6079
|
-
const i = o.replace(/.*:/g, "").trim(), { undo: c, redo: d } = useUndoManager();
|
|
6080
|
-
return /* @__PURE__ */ jsxs(
|
|
6081
|
-
"select",
|
|
6082
|
-
{
|
|
6083
|
-
disabled: !a.length || l,
|
|
6084
|
-
className: `${r ? "rounded-md border border-border" : "border-0"} disable:bg-gray-500 h-full w-full truncate rounded bg-background px-2 py-1 text-xs outline-none disabled:cursor-not-allowed`,
|
|
6085
|
-
onChange: (p) => n(p.target.value),
|
|
6086
|
-
onKeyDown: (p) => {
|
|
6087
|
-
p.ctrlKey && (p.key === "z" && c(), p.key === "y" && d());
|
|
6088
|
-
},
|
|
6089
|
-
value: i,
|
|
6090
|
-
children: [
|
|
6091
|
-
/* @__PURE__ */ jsx("option", { className: "bg-transparent", value: "" }),
|
|
6092
|
-
React__default.Children.toArray(
|
|
6093
|
-
a.map((p) => /* @__PURE__ */ jsx("option", { className: "bg-transparent", value: p, children: p }))
|
|
6094
|
-
)
|
|
6095
|
-
]
|
|
6096
|
-
}
|
|
6097
|
-
);
|
|
6098
|
-
}
|
|
6099
|
-
const COLOR_PROP = {
|
|
6100
|
-
backgroundColor: "bg",
|
|
6101
|
-
textColor: "text",
|
|
6102
|
-
borderColor: "border",
|
|
6103
|
-
boxShadowColor: "shadow",
|
|
6104
|
-
outlineColor: "outline",
|
|
6105
|
-
divideColor: "divide",
|
|
6106
|
-
fromColor: "from",
|
|
6107
|
-
viaColor: "via",
|
|
6108
|
-
toColor: "to",
|
|
6109
|
-
ringColor: "ring",
|
|
6110
|
-
ringOffsetColor: "ring-offset"
|
|
6111
|
-
}, ColorChoice = ({ property: o, onChange: n }) => {
|
|
6112
|
-
const r = useCurrentClassByProperty(o), a = useMemo(() => get(r, "cls", ""), [r]), { canChange: l } = useContext(StyleContext), [i, c] = useState([]), [d, p] = useState({ color: "", shade: "" }), u = a.split("-"), g = get(u, "1", ""), m = get(u, "2", ""), x = useCallback(
|
|
6113
|
-
// eslint-disable-next-line no-shadow
|
|
6114
|
-
(b) => {
|
|
6115
|
-
["current", "inherit", "transparent", "black", "white"].includes(b) ? (c([]), p({ color: b })) : (c(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]), p((k) => ({ ...k, color: b, shade: k.shade ? k.shade : "500" })));
|
|
6116
|
-
},
|
|
6117
|
-
[c, p]
|
|
6118
|
-
);
|
|
6119
|
-
useEffect(() => {
|
|
6120
|
-
if (["current", "inherit", "transparent", "black", "white"].includes(g))
|
|
6121
|
-
return c([]);
|
|
6122
|
-
c(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]);
|
|
6123
|
-
}, [g]);
|
|
6124
|
-
const f = useCallback(
|
|
6125
|
-
// eslint-disable-next-line no-shadow
|
|
6126
|
-
(b) => {
|
|
6127
|
-
p({ color: g, shade: b });
|
|
6128
|
-
},
|
|
6129
|
-
[g]
|
|
6130
|
-
);
|
|
6131
|
-
useEffect(() => {
|
|
6132
|
-
p({ color: "", shade: "" });
|
|
6133
|
-
}, [r]);
|
|
6134
|
-
const { match: h } = useTailwindClassList();
|
|
6135
|
-
return useEffect(() => {
|
|
6136
|
-
const k = `${get(COLOR_PROP, o, "")}-${d.color}${d.shade ? `-${d.shade}` : ""}`;
|
|
6137
|
-
h(o, k) && n(k, o);
|
|
6138
|
-
}, [h, d, n, o]), /* @__PURE__ */ jsxs("div", { className: "flex flex-row divide-x divide-solid divide-border rounded-lg border border-transparent text-xs", children: [
|
|
6139
|
-
/* @__PURE__ */ jsx("div", { className: "grow text-center", children: /* @__PURE__ */ jsx(
|
|
6140
|
-
DropDown,
|
|
6141
|
-
{
|
|
6142
|
-
disabled: !l,
|
|
6143
|
-
rounded: !0,
|
|
6144
|
-
selected: g,
|
|
6145
|
-
onChange: x,
|
|
6146
|
-
options: [
|
|
6147
|
-
"current",
|
|
6148
|
-
"transparent",
|
|
6149
|
-
"primary",
|
|
6150
|
-
"secondary",
|
|
6151
|
-
"black",
|
|
6152
|
-
"white",
|
|
6153
|
-
"slate",
|
|
6154
|
-
"gray",
|
|
6155
|
-
"zinc",
|
|
6156
|
-
"neutral",
|
|
6157
|
-
"stone",
|
|
6158
|
-
"red",
|
|
6159
|
-
"orange",
|
|
6160
|
-
"amber",
|
|
6161
|
-
"yellow",
|
|
6162
|
-
"lime",
|
|
6163
|
-
"green",
|
|
6164
|
-
"emerald",
|
|
6165
|
-
"teal",
|
|
6166
|
-
"cyan",
|
|
6167
|
-
"sky",
|
|
6168
|
-
"blue",
|
|
6169
|
-
"indigo",
|
|
6170
|
-
"violet",
|
|
6171
|
-
"purple",
|
|
6172
|
-
"fuchsia",
|
|
6173
|
-
"pink",
|
|
6174
|
-
"rose"
|
|
6175
|
-
]
|
|
6176
|
-
}
|
|
6177
|
-
) }),
|
|
6178
|
-
/* @__PURE__ */ jsx("button", { type: "button", className: "grow text-center", children: /* @__PURE__ */ jsx(DropDown, { rounded: !0, selected: m, disabled: !g || !l, onChange: f, options: i }) })
|
|
6179
|
-
] });
|
|
6180
5974
|
}, IconChoices = ({ property: o, onChange: n }) => {
|
|
6181
5975
|
const { getClasses: r } = useTailwindClassList(), a = r(o), { canChange: l } = useContext(StyleContext), i = useCurrentClassByProperty(o), c = useMemo(() => get(i, "cls", ""), [i]);
|
|
6182
5976
|
return /* @__PURE__ */ jsx("div", { className: "flex grow flex-wrap gap-1", children: map(a, (d) => /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
@@ -6372,50 +6166,50 @@ const COLOR_PROP = {
|
|
|
6372
6166
|
},
|
|
6373
6167
|
a
|
|
6374
6168
|
)) }), THROTTLE_TIME = 50, AdvanceChoices = (o) => {
|
|
6375
|
-
const [n, r] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: g } = o, [m,
|
|
6169
|
+
const [n, r] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: g } = o, [m, h] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [f, x] = useState(!1), [b, k] = useState(""), [w, S] = useState(!1), [A, E] = useState(!1);
|
|
6376
6170
|
useEffect(() => {
|
|
6377
6171
|
const { value: v, unit: y } = getClassValueAndUnit(i);
|
|
6378
6172
|
if (y === "") {
|
|
6379
|
-
l(v),
|
|
6173
|
+
l(v), h(p != null && p.toLowerCase().includes("width") ? "%" : first(u));
|
|
6380
6174
|
return;
|
|
6381
6175
|
}
|
|
6382
|
-
|
|
6176
|
+
h(y), l(y === "class" || isEmpty(v) ? "" : v);
|
|
6383
6177
|
}, [i, p, u]);
|
|
6384
|
-
const
|
|
6178
|
+
const j = useThrottledCallback((v) => c(v), [c], THROTTLE_TIME), C = useThrottledCallback((v) => c(v, !1), [c], THROTTLE_TIME), B = useCallback(
|
|
6385
6179
|
(v = !1) => {
|
|
6386
6180
|
const y = getUserInputValues(`${a}`, u);
|
|
6387
6181
|
if (get(y, "error", !1)) {
|
|
6388
|
-
|
|
6182
|
+
x(!0);
|
|
6389
6183
|
return;
|
|
6390
6184
|
}
|
|
6391
|
-
const
|
|
6392
|
-
if (
|
|
6393
|
-
|
|
6185
|
+
const _ = get(y, "unit") !== "" ? get(y, "unit") : m;
|
|
6186
|
+
if (_ === "auto" || _ === "none") {
|
|
6187
|
+
j(`${d}${_}`);
|
|
6394
6188
|
return;
|
|
6395
6189
|
}
|
|
6396
6190
|
if (get(y, "value") === "")
|
|
6397
6191
|
return;
|
|
6398
|
-
const I = `${get(y, "value", "").startsWith("-") ? "-" : ""}${d}[${get(y, "value", "").replace("-", "")}${
|
|
6399
|
-
v ?
|
|
6192
|
+
const I = `${get(y, "value", "").startsWith("-") ? "-" : ""}${d}[${get(y, "value", "").replace("-", "")}${_ === "-" ? "" : _}]`;
|
|
6193
|
+
v ? C(I) : j(I);
|
|
6400
6194
|
},
|
|
6401
|
-
[
|
|
6195
|
+
[j, C, a, m, d, u]
|
|
6402
6196
|
), L = useCallback(
|
|
6403
6197
|
(v) => {
|
|
6404
6198
|
const y = getUserInputValues(`${a}`, u);
|
|
6405
6199
|
if (get(y, "error", !1)) {
|
|
6406
|
-
|
|
6200
|
+
x(!0);
|
|
6407
6201
|
return;
|
|
6408
6202
|
}
|
|
6409
6203
|
if (v === "auto" || v === "none") {
|
|
6410
|
-
|
|
6204
|
+
j(`${d}${v}`);
|
|
6411
6205
|
return;
|
|
6412
6206
|
}
|
|
6413
6207
|
if (get(y, "value") === "")
|
|
6414
6208
|
return;
|
|
6415
|
-
const
|
|
6416
|
-
|
|
6209
|
+
const _ = get(y, "unit") !== "" ? get(y, "unit") : v, I = `${get(y, "value", "").startsWith("-") ? "-" : ""}${d}[${get(y, "value", "").replace("-", "")}${_ === "-" ? "" : _}]`;
|
|
6210
|
+
j(I);
|
|
6417
6211
|
},
|
|
6418
|
-
[
|
|
6212
|
+
[j, a, d, u]
|
|
6419
6213
|
);
|
|
6420
6214
|
return /* @__PURE__ */ jsx("div", { className: "flex w-full flex-col", children: /* @__PURE__ */ jsx("div", { className: "flex items-center justify-start", children: m === "class" ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
6421
6215
|
/* @__PURE__ */ jsx(
|
|
@@ -6430,37 +6224,37 @@ const COLOR_PROP = {
|
|
|
6430
6224
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx("button", { type: "button", className: "invisible ml-3 mt-1 text-blue-600 group-hover:visible", children: /* @__PURE__ */ jsx(InfoCircledIcon, {}) }) }),
|
|
6431
6225
|
/* @__PURE__ */ jsx(TooltipContent, { children: "Current value is using a Tailwind preset class." })
|
|
6432
6226
|
] })
|
|
6433
|
-
] }) : /* @__PURE__ */ jsxs("div", { className: `group relative flex items-center ${
|
|
6227
|
+
] }) : /* @__PURE__ */ jsxs("div", { className: `group relative flex items-center ${w ? "z-auto" : ""}`, children: [
|
|
6434
6228
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center rounded-md border border-border", children: [
|
|
6435
6229
|
["none", "auto"].indexOf(m) !== -1 ? null : /* @__PURE__ */ jsx(
|
|
6436
6230
|
"input",
|
|
6437
6231
|
{
|
|
6438
6232
|
readOnly: m === "class",
|
|
6439
6233
|
onKeyPress: (v) => {
|
|
6440
|
-
v.key === "Enter" &&
|
|
6234
|
+
v.key === "Enter" && B();
|
|
6441
6235
|
},
|
|
6442
6236
|
onKeyDown: (v) => {
|
|
6443
6237
|
if (v.keyCode !== 38 && v.keyCode !== 40)
|
|
6444
6238
|
return;
|
|
6445
|
-
v.preventDefault(),
|
|
6239
|
+
v.preventDefault(), E(!0);
|
|
6446
6240
|
const y = parseInt$1(v.target.value);
|
|
6447
|
-
let
|
|
6448
|
-
v.keyCode === 38 && (
|
|
6449
|
-
const T = `${
|
|
6450
|
-
|
|
6241
|
+
let _ = isNaN$1(y) ? 0 : y;
|
|
6242
|
+
v.keyCode === 38 && (_ += 1), v.keyCode === 40 && (_ -= 1);
|
|
6243
|
+
const T = `${_}`, R = `${T.startsWith("-") ? "-" : ""}${d}[${T.replace("-", "")}${m === "-" ? "" : m}]`;
|
|
6244
|
+
C(R);
|
|
6451
6245
|
},
|
|
6452
6246
|
onKeyUp: (v) => {
|
|
6453
|
-
|
|
6247
|
+
A && (v.preventDefault(), E(!1));
|
|
6454
6248
|
},
|
|
6455
|
-
onBlur: () =>
|
|
6249
|
+
onBlur: () => B(),
|
|
6456
6250
|
onChange: (v) => {
|
|
6457
|
-
|
|
6251
|
+
x(!1), l(v.target.value);
|
|
6458
6252
|
},
|
|
6459
6253
|
onClick: (v) => {
|
|
6460
6254
|
var y;
|
|
6461
6255
|
(y = v == null ? void 0 : v.target) == null || y.select(), r(!1);
|
|
6462
6256
|
},
|
|
6463
|
-
value:
|
|
6257
|
+
value: w ? b : a,
|
|
6464
6258
|
className: "h-6 w-14 rounded rounded-r-none border border-transparent bg-background pl-2 text-sm focus-visible:outline-0".concat(
|
|
6465
6259
|
" ",
|
|
6466
6260
|
f ? "border-red-500 text-red-500" : "border-foreground/20"
|
|
@@ -6486,28 +6280,28 @@ const COLOR_PROP = {
|
|
|
6486
6280
|
units: u,
|
|
6487
6281
|
current: m,
|
|
6488
6282
|
onSelect: (v) => {
|
|
6489
|
-
r(!1),
|
|
6283
|
+
r(!1), h(v), L(v);
|
|
6490
6284
|
}
|
|
6491
6285
|
}
|
|
6492
6286
|
) }) })
|
|
6493
6287
|
] })
|
|
6494
6288
|
] }),
|
|
6495
|
-
["none", "auto"].indexOf(m) !== -1 ||
|
|
6289
|
+
["none", "auto"].indexOf(m) !== -1 || w ? null : /* @__PURE__ */ jsx(
|
|
6496
6290
|
DragStyleButton,
|
|
6497
6291
|
{
|
|
6498
|
-
onDragStart: () =>
|
|
6292
|
+
onDragStart: () => S(!0),
|
|
6499
6293
|
onDragEnd: (v) => {
|
|
6500
|
-
if (k(() => ""),
|
|
6294
|
+
if (k(() => ""), S(!1), isEmpty(v))
|
|
6501
6295
|
return;
|
|
6502
6296
|
const y = `${v}`, T = `${y.startsWith("-") ? "-" : ""}${d}[${y.replace("-", "")}${m === "-" ? "" : m}]`;
|
|
6503
|
-
|
|
6297
|
+
j(T);
|
|
6504
6298
|
},
|
|
6505
6299
|
onDrag: (v) => {
|
|
6506
6300
|
if (isEmpty(v))
|
|
6507
6301
|
return;
|
|
6508
6302
|
k(v);
|
|
6509
6303
|
const y = `${v}`, T = `${y.startsWith("-") ? "-" : ""}${d}[${y.replace("-", "")}${m === "-" ? "" : m}]`;
|
|
6510
|
-
|
|
6304
|
+
C(T);
|
|
6511
6305
|
},
|
|
6512
6306
|
currentValue: a,
|
|
6513
6307
|
unit: m,
|
|
@@ -6604,35 +6398,35 @@ const COLOR_PROP = {
|
|
|
6604
6398
|
"2xl": "1536px"
|
|
6605
6399
|
}, getBreakpoint = (o) => `${o.toUpperCase()} ${BREAKPOINTS[o] ? `(${BREAKPOINTS[o]} & up)` : ""}`, BlockStyle = (o) => {
|
|
6606
6400
|
const { t: n } = useTranslation(), { type: r = "icons", label: a, property: l, onEmitChange: i = () => {
|
|
6607
|
-
}, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(), m = useCurrentClassByProperty(l),
|
|
6608
|
-
(
|
|
6609
|
-
const L = { dark: p, mq: g, mod: u, cls:
|
|
6401
|
+
}, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(), m = useCurrentClassByProperty(l), h = useAddClassesToBlocks(), f = useRemoveClassesFromBlocks(), [x] = useSelectedBlockIds(), b = useMemo(() => get(m, "fullCls", ""), [m]), k = useCallback(
|
|
6402
|
+
(C, B = !0) => {
|
|
6403
|
+
const L = { dark: p, mq: g, mod: u, cls: C, property: l, fullCls: "" };
|
|
6610
6404
|
(p || u !== "") && (L.mq = "xs");
|
|
6611
6405
|
const v = generateFullClsName(L);
|
|
6612
|
-
x
|
|
6406
|
+
h(x, [v], B);
|
|
6613
6407
|
},
|
|
6614
|
-
[
|
|
6615
|
-
),
|
|
6616
|
-
f(
|
|
6617
|
-
}, [
|
|
6408
|
+
[x, p, g, u, l, h]
|
|
6409
|
+
), w = useCallback(() => {
|
|
6410
|
+
f(x, [b], !0);
|
|
6411
|
+
}, [x, b, f]), S = useMemo(() => canChangeClass(m, g), [m, g]);
|
|
6618
6412
|
useEffect(() => {
|
|
6619
|
-
i(
|
|
6620
|
-
}, [
|
|
6621
|
-
const [, ,
|
|
6622
|
-
(
|
|
6623
|
-
|
|
6413
|
+
i(S, m);
|
|
6414
|
+
}, [S, i, m]);
|
|
6415
|
+
const [, , A] = useScreenSizeWidth(), E = useCallback(
|
|
6416
|
+
(C) => {
|
|
6417
|
+
A({
|
|
6624
6418
|
xs: 400,
|
|
6625
6419
|
sm: 640,
|
|
6626
6420
|
md: 800,
|
|
6627
6421
|
lg: 1024,
|
|
6628
6422
|
xl: 1420,
|
|
6629
6423
|
"2xl": 1920
|
|
6630
|
-
}[
|
|
6424
|
+
}[C]);
|
|
6631
6425
|
},
|
|
6632
|
-
[
|
|
6633
|
-
),
|
|
6634
|
-
return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange:
|
|
6635
|
-
/* @__PURE__ */ jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsx("span", { className: `text-[11px] ${m && !
|
|
6426
|
+
[A]
|
|
6427
|
+
), j = get(m, "dark", null) === p && get(m, "mod", null) === u && get(m, "mq", null) === g;
|
|
6428
|
+
return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange: S, canReset: m && j, children: /* @__PURE__ */ jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
|
|
6429
|
+
/* @__PURE__ */ jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsx("span", { className: `text-[11px] ${m && !j ? "text-foreground" : ""}`, children: n(a) }) }),
|
|
6636
6430
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-row items-center", children: [
|
|
6637
6431
|
/* @__PURE__ */ jsxs("div", { className: "w-[150px]", children: [
|
|
6638
6432
|
r === "arbitrary" ? /* @__PURE__ */ jsx(
|
|
@@ -6651,7 +6445,7 @@ const COLOR_PROP = {
|
|
|
6651
6445
|
r === "color" && /* @__PURE__ */ jsx(ColorChoice, { property: l, onChange: k }),
|
|
6652
6446
|
r === "dropdown" && /* @__PURE__ */ jsx(DropDownChoices, { label: a, property: l, onChange: k })
|
|
6653
6447
|
] }),
|
|
6654
|
-
/* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${b ? "visible" : "invisible"}`, children:
|
|
6448
|
+
/* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${b ? "visible" : "invisible"}`, children: j ? /* @__PURE__ */ jsx("button", { type: "button", onClick: () => w(), title: "Reset", className: "flex px-1.5 text-xs", children: /* @__PURE__ */ jsx(CrossCircledIcon, { className: "h-5 w-5 text-blue-500 hover:opacity-80" }) }) : S && m ? /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
|
|
6655
6449
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
|
|
6656
6450
|
"button",
|
|
6657
6451
|
{
|
|
@@ -6671,7 +6465,7 @@ const COLOR_PROP = {
|
|
|
6671
6465
|
"button",
|
|
6672
6466
|
{
|
|
6673
6467
|
type: "button",
|
|
6674
|
-
onClick: () =>
|
|
6468
|
+
onClick: () => E(get(m, "mq")),
|
|
6675
6469
|
className: "block w-full cursor-default text-right font-semibold text-blue-500",
|
|
6676
6470
|
children: [
|
|
6677
6471
|
"Switch to ",
|
|
@@ -6692,7 +6486,7 @@ const COLOR_PROP = {
|
|
|
6692
6486
|
units: i = basicUnits,
|
|
6693
6487
|
negative: c = !1
|
|
6694
6488
|
}) => {
|
|
6695
|
-
const { t: d } = useTranslation(), [p, u] = useState(n[0].key), g = useSelectedBlockCurrentClasses(), m = useCallback((
|
|
6489
|
+
const { t: d } = useTranslation(), [p, u] = useState(n[0].key), g = useSelectedBlockCurrentClasses(), m = useCallback((h) => map(g, "property").includes(h), [g]);
|
|
6696
6490
|
return /* @__PURE__ */ jsxs(
|
|
6697
6491
|
"div",
|
|
6698
6492
|
{
|
|
@@ -6700,25 +6494,23 @@ const COLOR_PROP = {
|
|
|
6700
6494
|
children: [
|
|
6701
6495
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-row text-xs", children: [
|
|
6702
6496
|
o && /* @__PURE__ */ jsx("span", { className: "relative w-[70px] flex-none text-xs text-foreground", children: d(o) }),
|
|
6703
|
-
/* @__PURE__ */ jsx("div", { className: "mb-3 flex grow flex-row flex-wrap gap-x-px", children:
|
|
6704
|
-
|
|
6705
|
-
|
|
6706
|
-
|
|
6707
|
-
|
|
6708
|
-
|
|
6709
|
-
|
|
6710
|
-
|
|
6711
|
-
|
|
6712
|
-
|
|
6713
|
-
|
|
6714
|
-
|
|
6715
|
-
|
|
6716
|
-
|
|
6717
|
-
|
|
6718
|
-
|
|
6719
|
-
|
|
6720
|
-
] }) }))
|
|
6721
|
-
) })
|
|
6497
|
+
/* @__PURE__ */ jsx("div", { className: "mb-3 flex grow flex-row flex-wrap gap-x-px", children: n.map(({ label: h, key: f }, x) => /* @__PURE__ */ jsx("div", { className: "first:rounded-l last:rounded-r", children: /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
6498
|
+
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
|
|
6499
|
+
"button",
|
|
6500
|
+
{
|
|
6501
|
+
type: "button",
|
|
6502
|
+
onClick: () => u(f),
|
|
6503
|
+
className: `relative cursor-pointer rounded-full p-1 text-[8px] ${f === p ? "bg-[#3E57F0] text-white" : "text-gray-600 dark:text-gray-300"}`,
|
|
6504
|
+
children: [
|
|
6505
|
+
React__default.createElement("div", {
|
|
6506
|
+
className: m(f) ? "-bottom-1.5 absolute bg-[#3E57F0] h-[2px] left-0 w-full" : ""
|
|
6507
|
+
}),
|
|
6508
|
+
React__default.createElement(get(EDITOR_ICONS, f, BoxIcon), { className: "text-inherit w-3 h-3" })
|
|
6509
|
+
]
|
|
6510
|
+
}
|
|
6511
|
+
) }),
|
|
6512
|
+
/* @__PURE__ */ jsx(TooltipContent, { children: startCase(toLower(h)) })
|
|
6513
|
+
] }) }, `option-${x}`)) })
|
|
6722
6514
|
] }),
|
|
6723
6515
|
/* @__PURE__ */ jsx("div", { className: "mt-0 flex items-center", children: /* @__PURE__ */ jsx(
|
|
6724
6516
|
BlockStyle,
|
|
@@ -6772,12 +6564,8 @@ const COLOR_PROP = {
|
|
|
6772
6564
|
), i = useMemo(() => ({}), []);
|
|
6773
6565
|
return /* @__PURE__ */ jsx(SectionContext.Provider, { value: i, children: n ? /* @__PURE__ */ jsxs(AccordionItem, { value: o.heading, className: "border-none", children: [
|
|
6774
6566
|
/* @__PURE__ */ jsx(AccordionTrigger, { className: "border-slate-150 border-t py-2 text-xs", children: /* @__PURE__ */ jsx("div", { className: "flex items-center py-2", children: /* @__PURE__ */ jsx("div", { className: "flex items-center gap-x-2 text-xs font-medium", children: startCase(r(o.heading)) }) }) }),
|
|
6775
|
-
/* @__PURE__ */ jsx(AccordionContent, { className: "py-2", children: React__default.
|
|
6776
|
-
|
|
6777
|
-
) })
|
|
6778
|
-
] }) : /* @__PURE__ */ jsx("div", { className: "py-2", children: React__default.Children.toArray(
|
|
6779
|
-
o.items.map((c) => has(c, "component") ? React__default.createElement(c.component, { key: c.label }) : has(c, "styleType") ? c.styleType === "multiple" ? /* @__PURE__ */ jsx(MultipleChoices, { ...c }, c.label) : c.styleType === "accordion" && l(c == null ? void 0 : c.conditions) ? /* @__PURE__ */ jsx(NestedOptions, { ...c }, c.label) : null : /* @__PURE__ */ jsx(BlockStyle, { ...c }, c.label))
|
|
6780
|
-
) }) });
|
|
6567
|
+
/* @__PURE__ */ jsx(AccordionContent, { className: "py-2", children: o.items.map((c) => has(c, "component") ? React__default.createElement(c.component, { key: c.label }) : has(c, "styleType") ? c.styleType === "multiple" ? /* @__PURE__ */ jsx(MultipleChoices, { ...c }, c.label) : c.styleType === "accordion" && l(c == null ? void 0 : c.conditions) ? /* @__PURE__ */ jsx(NestedOptions, { ...c }, c.label) : null : /* @__PURE__ */ jsx(BlockStyle, { ...c }, c.label)) })
|
|
6568
|
+
] }) : /* @__PURE__ */ jsx("div", { className: "py-2", children: o.items.map((c) => has(c, "component") ? React__default.createElement(c.component, { key: c.label }) : has(c, "styleType") ? c.styleType === "multiple" ? /* @__PURE__ */ jsx(MultipleChoices, { ...c }, c.label) : c.styleType === "accordion" && l(c == null ? void 0 : c.conditions) ? /* @__PURE__ */ jsx(NestedOptions, { ...c }, c.label) : null : /* @__PURE__ */ jsx(BlockStyle, { ...c }, c.label)) }) });
|
|
6781
6569
|
}, MAPPER = {
|
|
6782
6570
|
px: 1,
|
|
6783
6571
|
"%": 1,
|
|
@@ -6803,11 +6591,11 @@ function BlockStyling() {
|
|
|
6803
6591
|
}), d = useThrottledCallback(
|
|
6804
6592
|
(u) => {
|
|
6805
6593
|
const g = !get(i, "negative", !1), m = get(i, "cssProperty", "");
|
|
6806
|
-
let
|
|
6807
|
-
|
|
6594
|
+
let h = parseFloat(i.dragStartValue);
|
|
6595
|
+
h = isNaN(h) ? 0 : h;
|
|
6808
6596
|
let f = MAPPER[i.dragUnit];
|
|
6809
6597
|
(startsWith(m, "scale") || m === "opacity") && (f = 10);
|
|
6810
|
-
let b = (i.dragStartY - u.pageY) / f +
|
|
6598
|
+
let b = (i.dragStartY - u.pageY) / f + h;
|
|
6811
6599
|
g && b < 0 && (b = 0), m === "opacity" && b > 1 && (b = 1), i.onDrag(`${b}`), l(`${b}`);
|
|
6812
6600
|
},
|
|
6813
6601
|
[i],
|
|
@@ -6853,20 +6641,20 @@ const CHAI_BUILDER_EVENTS = {
|
|
|
6853
6641
|
parentId: r,
|
|
6854
6642
|
position: a
|
|
6855
6643
|
}) => {
|
|
6856
|
-
const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: c, label: d } = o, { addCoreBlock: p, addPredefinedBlock: u } = useAddBlock(), [, g] = useSelectedBlockIds(), { clearHighlight: m } = useBlockHighlight(),
|
|
6644
|
+
const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: c, label: d } = o, { addCoreBlock: p, addPredefinedBlock: u } = useAddBlock(), [, g] = useSelectedBlockIds(), { clearHighlight: m } = useBlockHighlight(), h = () => {
|
|
6857
6645
|
if (console.log("addBlockToPage", o), has(o, "blocks")) {
|
|
6858
6646
|
const b = isFunction$1(o.blocks) ? o.blocks() : o.blocks;
|
|
6859
6647
|
u(syncBlocksWithDefaults(b), r || null, a);
|
|
6860
6648
|
} else
|
|
6861
6649
|
p(o, r || null, a);
|
|
6862
6650
|
pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
6863
|
-
}, f = useFeature("dnd"), { t:
|
|
6651
|
+
}, f = useFeature("dnd"), { t: x } = useTranslation();
|
|
6864
6652
|
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
6865
6653
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
|
|
6866
6654
|
"button",
|
|
6867
6655
|
{
|
|
6868
6656
|
disabled: n,
|
|
6869
|
-
onClick:
|
|
6657
|
+
onClick: h,
|
|
6870
6658
|
type: "button",
|
|
6871
6659
|
onDragStart: (b) => {
|
|
6872
6660
|
b.dataTransfer.setData("text/plain", JSON.stringify(omit(o, ["component", "icon"]))), b.dataTransfer.setDragImage(new Image(), 0, 0), l(omit(o, ["component", "icon"])), setTimeout(() => {
|
|
@@ -6877,11 +6665,11 @@ const CHAI_BUILDER_EVENTS = {
|
|
|
6877
6665
|
className: "cursor-pointer space-y-2 rounded-lg border border-border p-3 text-center hover:bg-slate-300/50 disabled:cursor-not-allowed disabled:bg-gray-100 disabled:text-gray-400 dark:border-gray-700 dark:text-white dark:hover:bg-slate-800/50 dark:disabled:bg-gray-900 dark:disabled:text-foreground",
|
|
6878
6666
|
children: [
|
|
6879
6667
|
createElement(c || BoxIcon, { className: "w-4 h-4 mx-auto" }),
|
|
6880
|
-
/* @__PURE__ */ jsx("p", { className: "truncate text-xs", children: capitalize(
|
|
6668
|
+
/* @__PURE__ */ jsx("p", { className: "truncate text-xs", children: capitalize(x(d || i)) })
|
|
6881
6669
|
]
|
|
6882
6670
|
}
|
|
6883
6671
|
) }),
|
|
6884
|
-
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children:
|
|
6672
|
+
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: x(d || i) }) })
|
|
6885
6673
|
] }) });
|
|
6886
6674
|
}, DefaultChaiBlocks = ({
|
|
6887
6675
|
parentId: o,
|
|
@@ -7069,22 +6857,22 @@ const CHAI_BUILDER_EVENTS = {
|
|
|
7069
6857
|
}
|
|
7070
6858
|
}
|
|
7071
6859
|
}, traverseNodes = (o, n = null) => flatMapDeep(o, (r) => {
|
|
7072
|
-
var m,
|
|
6860
|
+
var m, h, f, x, b, k, w, S;
|
|
7073
6861
|
if (r.type === "comment") return [];
|
|
7074
6862
|
console.log("node ===>", r);
|
|
7075
6863
|
let a = { _id: generateUUID() };
|
|
7076
6864
|
if (n && (a._parent = n.block._id), r.type === "text")
|
|
7077
6865
|
return isEmpty(get(r, "content", "")) ? [] : n && shouldAddText(n.node, n.block) ? (set(n, "block.content", get(r, "content", "")), []) : { ...a, _type: "Text", content: get(r, "content", "") };
|
|
7078
6866
|
const l = get(r, "attributes", []), i = l.find(
|
|
7079
|
-
(
|
|
6867
|
+
(A) => A.key === "data-chai-richtext" || A.key === "chai-richtext"
|
|
7080
6868
|
), c = l.find(
|
|
7081
|
-
(
|
|
6869
|
+
(A) => A.key === "data-chai-lightbox" || A.key === "chai-lightbox"
|
|
7082
6870
|
), d = l.find(
|
|
7083
|
-
(
|
|
6871
|
+
(A) => A.key === "data-chai-dropdown" || A.key === "chai-dropdown"
|
|
7084
6872
|
), p = l.find(
|
|
7085
|
-
(
|
|
6873
|
+
(A) => A.key === "data-chai-dropdown-button" || A.key === "chai-dropdown-button"
|
|
7086
6874
|
), u = l.find(
|
|
7087
|
-
(
|
|
6875
|
+
(A) => A.key === "data-chai-dropdown-content" || A.key === "chai-dropdown-content"
|
|
7088
6876
|
);
|
|
7089
6877
|
if (a = {
|
|
7090
6878
|
...a,
|
|
@@ -7092,13 +6880,13 @@ const CHAI_BUILDER_EVENTS = {
|
|
|
7092
6880
|
...getAttrs(r),
|
|
7093
6881
|
...getStyles(r)
|
|
7094
6882
|
}, r.attributes) {
|
|
7095
|
-
const
|
|
7096
|
-
|
|
6883
|
+
const A = r.attributes.find((E) => includes(NAME_ATTRIBUTES, E.key));
|
|
6884
|
+
A && (a._name = A.value);
|
|
7097
6885
|
}
|
|
7098
6886
|
if (i)
|
|
7099
6887
|
return a.content = stringify(r.children), has(a, "styles_attrs.data-chai-richtext") && delete a.styles_attrs["data-chai-richtext"], has(a, "styles_attrs.chai-richtext") && delete a.styles_attrs["chai-richtext"], [a];
|
|
7100
6888
|
if (c) {
|
|
7101
|
-
const
|
|
6889
|
+
const A = [
|
|
7102
6890
|
"data-chai-lightbox",
|
|
7103
6891
|
"chai-lightbox",
|
|
7104
6892
|
"data-vbtype",
|
|
@@ -7110,44 +6898,44 @@ const CHAI_BUILDER_EVENTS = {
|
|
|
7110
6898
|
];
|
|
7111
6899
|
a = {
|
|
7112
6900
|
...a,
|
|
7113
|
-
href: ((m = l.find((
|
|
7114
|
-
hrefType: ((
|
|
7115
|
-
autoplay: ((f = l.find((
|
|
7116
|
-
maxWidth: ((b = (
|
|
7117
|
-
backdropColor: ((k = l.find((
|
|
7118
|
-
galleryName: ((
|
|
7119
|
-
}, forEach(
|
|
7120
|
-
has(a, `styles_attrs.${
|
|
6901
|
+
href: ((m = l.find((E) => E.key === "href")) == null ? void 0 : m.value) || "",
|
|
6902
|
+
hrefType: ((h = l.find((E) => E.key === "data-vbtype")) == null ? void 0 : h.value) || "video",
|
|
6903
|
+
autoplay: ((f = l.find((E) => E.key === "data-autoplay")) == null ? void 0 : f.value) === "true" ? "true" : "false",
|
|
6904
|
+
maxWidth: ((b = (x = l.find((E) => E.key === "data-maxwidth")) == null ? void 0 : x.value) == null ? void 0 : b.replace("px", "")) || "",
|
|
6905
|
+
backdropColor: ((k = l.find((E) => E.key === "data-overlay")) == null ? void 0 : k.value) || "",
|
|
6906
|
+
galleryName: ((w = l.find((E) => E.key === "data-gall")) == null ? void 0 : w.value) || ""
|
|
6907
|
+
}, forEach(A, (E) => {
|
|
6908
|
+
has(a, `styles_attrs.${E}`) && delete a.styles_attrs[E];
|
|
7121
6909
|
});
|
|
7122
6910
|
}
|
|
7123
6911
|
if (d && (delete a.styles_attrs, a.showDropdown = !1), u && delete a.styles_attrs, p) {
|
|
7124
6912
|
delete a.styles_attrs;
|
|
7125
|
-
const
|
|
7126
|
-
a.content = getTextContent(
|
|
7127
|
-
const
|
|
6913
|
+
const A = filter(r.children || [], (j) => (j == null ? void 0 : j.tagName) !== "span");
|
|
6914
|
+
a.content = getTextContent(A);
|
|
6915
|
+
const E = find(
|
|
7128
6916
|
r.children || [],
|
|
7129
|
-
(
|
|
6917
|
+
(j) => (j == null ? void 0 : j.tagName) === "span" && some(j.children || [], (C) => (C == null ? void 0 : C.tagName) === "svg")
|
|
7130
6918
|
);
|
|
7131
|
-
if (
|
|
7132
|
-
const
|
|
7133
|
-
if (
|
|
7134
|
-
a.icon = stringify([
|
|
7135
|
-
const { height:
|
|
7136
|
-
a.iconHeight =
|
|
6919
|
+
if (E) {
|
|
6920
|
+
const j = find(E.children || [], (C) => (C == null ? void 0 : C.tagName) === "svg");
|
|
6921
|
+
if (j) {
|
|
6922
|
+
a.icon = stringify([j]);
|
|
6923
|
+
const { height: C, width: B } = getSvgDimensions(j, "16px", "16px");
|
|
6924
|
+
a.iconHeight = C, a.iconWidth = B;
|
|
7137
6925
|
}
|
|
7138
6926
|
}
|
|
7139
6927
|
return [a];
|
|
7140
6928
|
}
|
|
7141
6929
|
if (a._type === "Input") {
|
|
7142
|
-
const
|
|
7143
|
-
|
|
6930
|
+
const A = a.inputType || "text";
|
|
6931
|
+
A === "checkbox" ? set(a, "_type", "Checkbox") : A === "radio" && set(a, "_type", "Radio");
|
|
7144
6932
|
} else if (r.tagName === "video" || r.tagName === "iframe") {
|
|
7145
|
-
const
|
|
7146
|
-
return hasVideoEmbed(
|
|
6933
|
+
const A = stringify([r]);
|
|
6934
|
+
return hasVideoEmbed(A) && (set(a, "_type", "Video"), set(a, "url", getVideoURLFromHTML(A)), set(a, "styles", `${STYLES_KEY},`), set(a, "controls", { autoPlay: !1, muted: !0, loop: !1, controls: !1 })), a.content = A, [a];
|
|
7147
6935
|
} else if (r.tagName === "svg") {
|
|
7148
|
-
const
|
|
7149
|
-
return a.styles = `${STYLES_KEY}, ${cn$1(`w-${
|
|
7150
|
-
} else if (r.tagName == "option" && n && ((
|
|
6936
|
+
const A = find(r.attributes, { key: "height" }), E = find(r.attributes, { key: "width" }), j = get(A, "value") ? `[${get(A, "value")}px]` : "24px", C = get(E, "value") ? `[${get(E, "value")}px]` : "24px", B = get(find(r.attributes, { key: "class" }), "value", "w-full h-full");
|
|
6937
|
+
return a.styles = `${STYLES_KEY}, ${cn$1(`w-${C} h-${j}`, B)}`.trim(), r.attributes = filter(r.attributes, (L) => !includes(["style", "width", "height", "class"], L.key)), a.icon = stringify([r]), [a];
|
|
6938
|
+
} else if (r.tagName == "option" && n && ((S = n.block) == null ? void 0 : S._type) === "Select")
|
|
7151
6939
|
return n.block.options.push({
|
|
7152
6940
|
label: getTextContent(r.children),
|
|
7153
6941
|
...getAttrs(r)
|
|
@@ -7220,29 +7008,29 @@ const CHAI_BUILDER_EVENTS = {
|
|
|
7220
7008
|
error: c
|
|
7221
7009
|
}), g(!0);
|
|
7222
7010
|
else if (!l && Object.keys(a || {}).length > 0) {
|
|
7223
|
-
const
|
|
7224
|
-
const k = b,
|
|
7011
|
+
const h = Object.entries(a).map(([x, b]) => {
|
|
7012
|
+
const k = b, w = k.type || "partial", S = formatReadableName(w);
|
|
7225
7013
|
return {
|
|
7226
7014
|
type: "PartialBlock",
|
|
7227
7015
|
// Set the type to PartialBlock
|
|
7228
|
-
label: formatReadableName(k.name ||
|
|
7016
|
+
label: formatReadableName(k.name || x),
|
|
7229
7017
|
description: k.description || "",
|
|
7230
7018
|
icon: Globe,
|
|
7231
|
-
group:
|
|
7019
|
+
group: S,
|
|
7232
7020
|
// Use formatted type as group
|
|
7233
7021
|
category: "partial",
|
|
7234
|
-
partialBlockId:
|
|
7022
|
+
partialBlockId: x,
|
|
7235
7023
|
// Store the original ID as partialBlockId
|
|
7236
7024
|
_name: k.name
|
|
7237
7025
|
};
|
|
7238
|
-
}), f = uniq(map(
|
|
7026
|
+
}), f = uniq(map(h, "group"));
|
|
7239
7027
|
p({
|
|
7240
|
-
blocks:
|
|
7028
|
+
blocks: h,
|
|
7241
7029
|
groups: f,
|
|
7242
7030
|
isLoading: !1,
|
|
7243
7031
|
error: null
|
|
7244
7032
|
}), g(!0);
|
|
7245
|
-
} else l ? p((
|
|
7033
|
+
} else l ? p((h) => ({ ...h, isLoading: !0, error: null })) : !l && Object.keys(a || {}).length === 0 && (p({
|
|
7246
7034
|
blocks: [],
|
|
7247
7035
|
groups: [],
|
|
7248
7036
|
isLoading: !1,
|
|
@@ -7258,7 +7046,7 @@ const CHAI_BUILDER_EVENTS = {
|
|
|
7258
7046
|
c
|
|
7259
7047
|
]);
|
|
7260
7048
|
const m = () => {
|
|
7261
|
-
p((
|
|
7049
|
+
p((h) => ({ ...h, isLoading: !0, error: null })), g(!1), i();
|
|
7262
7050
|
};
|
|
7263
7051
|
return d.isLoading ? /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center p-8 text-center text-muted-foreground", children: "Loading partial blocks..." }) : d.error || d.blocks.length === 0 ? /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center justify-center gap-4 p-8 text-center text-muted-foreground", children: [
|
|
7264
7052
|
/* @__PURE__ */ jsx("p", { children: d.error || "No partial blocks available" }),
|
|
@@ -7282,11 +7070,11 @@ const CHAI_BUILDER_EVENTS = {
|
|
|
7282
7070
|
);
|
|
7283
7071
|
}, CORE_GROUPS = ["basic", "typography", "media", "layout", "form", "advanced", "other"], ChaiBuilderBlocks = ({ groups: o, blocks: n, parentId: r, position: a, gridCols: l = "grid-cols-4" }) => {
|
|
7284
7072
|
var v;
|
|
7285
|
-
const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom), m = (v = find(c, (y) => y._id === r)) == null ? void 0 : v._type, [
|
|
7073
|
+
const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom), m = (v = find(c, (y) => y._id === r)) == null ? void 0 : v._type, [h, f] = useState("all"), [x, b] = useState(null), k = useRef(null);
|
|
7286
7074
|
useEffect(() => {
|
|
7287
7075
|
const y = setTimeout(() => {
|
|
7288
|
-
var
|
|
7289
|
-
(
|
|
7076
|
+
var _;
|
|
7077
|
+
(_ = u.current) == null || _.focus();
|
|
7290
7078
|
}, 0);
|
|
7291
7079
|
return () => clearTimeout(y);
|
|
7292
7080
|
}, [g]), useEffect(() => {
|
|
@@ -7296,29 +7084,29 @@ const CHAI_BUILDER_EVENTS = {
|
|
|
7296
7084
|
}, 500), () => {
|
|
7297
7085
|
k.current && k.current.cancel();
|
|
7298
7086
|
}), []);
|
|
7299
|
-
const
|
|
7087
|
+
const w = useCallback((y) => {
|
|
7300
7088
|
b(y), k.current && k.current(y);
|
|
7301
|
-
}, []),
|
|
7089
|
+
}, []), S = useCallback(() => {
|
|
7302
7090
|
b(null), k.current && k.current.cancel();
|
|
7303
|
-
}, []),
|
|
7091
|
+
}, []), A = useCallback((y) => {
|
|
7304
7092
|
k.current && k.current.cancel(), f(y), b(null);
|
|
7305
|
-
}, []),
|
|
7093
|
+
}, []), E = useMemo(
|
|
7306
7094
|
() => d ? values(n).filter(
|
|
7307
7095
|
(y) => {
|
|
7308
|
-
var
|
|
7309
|
-
return (((
|
|
7096
|
+
var _, T;
|
|
7097
|
+
return (((_ = y.label) == null ? void 0 : _.toLowerCase()) + " " + ((T = y.type) == null ? void 0 : T.toLowerCase())).includes(d.toLowerCase());
|
|
7310
7098
|
}
|
|
7311
7099
|
) : n,
|
|
7312
7100
|
[n, d]
|
|
7313
|
-
),
|
|
7101
|
+
), j = useMemo(
|
|
7314
7102
|
() => d ? o.filter(
|
|
7315
|
-
(y) => reject(filter(values(
|
|
7103
|
+
(y) => reject(filter(values(E), { group: y }), { hidden: !0 }).length > 0
|
|
7316
7104
|
) : o.filter((y) => reject(filter(values(n), { group: y }), { hidden: !0 }).length > 0),
|
|
7317
|
-
[n,
|
|
7318
|
-
),
|
|
7319
|
-
() => sortBy(
|
|
7320
|
-
[
|
|
7321
|
-
),
|
|
7105
|
+
[n, E, o, d]
|
|
7106
|
+
), C = useMemo(
|
|
7107
|
+
() => sortBy(j, (y) => CORE_GROUPS.indexOf(y) === -1 ? 99 : CORE_GROUPS.indexOf(y)),
|
|
7108
|
+
[j]
|
|
7109
|
+
), B = useMemo(() => h === "all" ? E : filter(values(E), { group: h }), [E, h]), L = useMemo(() => h === "all" ? C : [h], [C, h]);
|
|
7322
7110
|
return /* @__PURE__ */ jsxs("div", { className: "mx-auto flex h-full w-full max-w-3xl flex-col", children: [
|
|
7323
7111
|
/* @__PURE__ */ jsx("div", { className: "sticky top-0 z-10 bg-background/80 px-4 py-2 backdrop-blur-sm", children: /* @__PURE__ */ jsx(
|
|
7324
7112
|
Input$1,
|
|
@@ -7332,52 +7120,50 @@ const CHAI_BUILDER_EVENTS = {
|
|
|
7332
7120
|
}
|
|
7333
7121
|
) }),
|
|
7334
7122
|
/* @__PURE__ */ jsxs("div", { className: "sticky top-10 flex h-[calc(100%-48px)] overflow-hidden", children: [
|
|
7335
|
-
|
|
7123
|
+
C.length > 0 && /* @__PURE__ */ jsx("div", { className: "w-1/4 min-w-[120px] border-r", children: /* @__PURE__ */ jsx(ScrollArea, { className: "h-full", children: /* @__PURE__ */ jsxs("div", { className: "space-y-1 p-2", children: [
|
|
7336
7124
|
/* @__PURE__ */ jsx(
|
|
7337
7125
|
"button",
|
|
7338
7126
|
{
|
|
7339
|
-
onClick: () =>
|
|
7340
|
-
onMouseEnter: () =>
|
|
7341
|
-
onMouseLeave:
|
|
7342
|
-
className: `w-full rounded-md px-2 py-1.5 text-left text-sm font-medium ${
|
|
7127
|
+
onClick: () => A("all"),
|
|
7128
|
+
onMouseEnter: () => w("all"),
|
|
7129
|
+
onMouseLeave: S,
|
|
7130
|
+
className: `w-full rounded-md px-2 py-1.5 text-left text-sm font-medium ${h === "all" || x === "all" ? "bg-accent text-accent-foreground" : "hover:bg-accent/50 hover:text-accent-foreground"}`,
|
|
7343
7131
|
children: i("All")
|
|
7344
7132
|
},
|
|
7345
7133
|
"sidebar-all"
|
|
7346
7134
|
),
|
|
7347
|
-
|
|
7135
|
+
C.map((y) => /* @__PURE__ */ jsx(
|
|
7348
7136
|
"button",
|
|
7349
7137
|
{
|
|
7350
|
-
onClick: () =>
|
|
7351
|
-
onMouseEnter: () =>
|
|
7352
|
-
onMouseLeave:
|
|
7353
|
-
className: `w-full rounded-md px-2 py-1.5 text-left text-sm ${
|
|
7138
|
+
onClick: () => A(y),
|
|
7139
|
+
onMouseEnter: () => w(y),
|
|
7140
|
+
onMouseLeave: S,
|
|
7141
|
+
className: `w-full rounded-md px-2 py-1.5 text-left text-sm ${h === y || x === y ? "bg-accent text-accent-foreground" : "hover:bg-accent/50 hover:text-accent-foreground"}`,
|
|
7354
7142
|
children: capitalize(i(y.toLowerCase()))
|
|
7355
7143
|
},
|
|
7356
7144
|
`sidebar-${y}`
|
|
7357
7145
|
))
|
|
7358
7146
|
] }) }) }),
|
|
7359
|
-
/* @__PURE__ */ jsx("div", { className: "h-full w-3/4 flex-1 overflow-hidden", children: /* @__PURE__ */ jsx(ScrollArea, { id: "add-blocks-scroll-area", className: "no-scrollbar mr-4 h-full", children:
|
|
7147
|
+
/* @__PURE__ */ jsx("div", { className: "h-full w-3/4 flex-1 overflow-hidden", children: /* @__PURE__ */ jsx(ScrollArea, { id: "add-blocks-scroll-area", className: "no-scrollbar mr-4 h-full", children: j.length === 0 && d ? /* @__PURE__ */ jsx("div", { className: "flex flex-col items-center justify-center p-8 text-center text-muted-foreground", children: /* @__PURE__ */ jsxs("p", { children: [
|
|
7360
7148
|
i("No blocks found matching"),
|
|
7361
7149
|
' "',
|
|
7362
7150
|
d,
|
|
7363
7151
|
'"'
|
|
7364
7152
|
] }) }) : /* @__PURE__ */ jsx("div", { className: "space-y-6 p-4", children: L.map((y) => /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
7365
7153
|
/* @__PURE__ */ jsx("h3", { className: "px-1 text-sm font-medium", children: capitalize(i(y.toLowerCase())) }),
|
|
7366
|
-
/* @__PURE__ */ jsx("div", { className: "grid gap-2 " + l, children:
|
|
7367
|
-
|
|
7368
|
-
|
|
7369
|
-
|
|
7370
|
-
|
|
7371
|
-
|
|
7372
|
-
|
|
7373
|
-
|
|
7374
|
-
|
|
7375
|
-
|
|
7376
|
-
|
|
7377
|
-
|
|
7378
|
-
|
|
7379
|
-
))
|
|
7380
|
-
) })
|
|
7154
|
+
/* @__PURE__ */ jsx("div", { className: "grid gap-2 " + l, children: reject(
|
|
7155
|
+
h === "all" ? filter(values(B), { group: y }) : values(B),
|
|
7156
|
+
{ hidden: !0 }
|
|
7157
|
+
).map((_) => /* @__PURE__ */ jsx(
|
|
7158
|
+
CoreBlock,
|
|
7159
|
+
{
|
|
7160
|
+
parentId: r,
|
|
7161
|
+
position: a,
|
|
7162
|
+
block: _,
|
|
7163
|
+
disabled: !canAcceptChildBlock(m, _.type) || !canBeNestedInside(m, _.type)
|
|
7164
|
+
},
|
|
7165
|
+
_.type
|
|
7166
|
+
)) })
|
|
7381
7167
|
] }, y)) }) }) })
|
|
7382
7168
|
] })
|
|
7383
7169
|
] });
|
|
@@ -7387,13 +7173,13 @@ const CHAI_BUILDER_EVENTS = {
|
|
|
7387
7173
|
parentId: r = void 0,
|
|
7388
7174
|
position: a = -1
|
|
7389
7175
|
}) => {
|
|
7390
|
-
const { t: l } = useTranslation(), [i, c] = useAtom$1(addBlockTabAtom), [, d] = useAtom$1(showPredefinedBlockCategoryAtom), p = useBuilderProp("importHTMLSupport", !0), u = useBuilderProp("addBlocksDialogTabs", []), { data: g } = usePartialBlocksList(), m = Object.keys(g || {}).length > 0, { hasPermission:
|
|
7176
|
+
const { t: l } = useTranslation(), [i, c] = useAtom$1(addBlockTabAtom), [, d] = useAtom$1(showPredefinedBlockCategoryAtom), p = useBuilderProp("importHTMLSupport", !0), u = useBuilderProp("addBlocksDialogTabs", []), { data: g } = usePartialBlocksList(), m = Object.keys(g || {}).length > 0, { hasPermission: h } = usePermissions();
|
|
7391
7177
|
useEffect(() => {
|
|
7392
7178
|
i === "partials" && !m && c("library");
|
|
7393
7179
|
}, [i, m, c]);
|
|
7394
7180
|
const f = useCallback(() => {
|
|
7395
7181
|
pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
7396
|
-
}, []),
|
|
7182
|
+
}, []), x = p && h(PERMISSIONS.IMPORT_HTML);
|
|
7397
7183
|
return /* @__PURE__ */ jsxs("div", { className: cn$1("flex h-full w-full flex-col overflow-hidden", o), children: [
|
|
7398
7184
|
n ? /* @__PURE__ */ jsxs("div", { className: "mb-2 flex flex-col justify-between rounded-md bg-background/30 p-1", children: [
|
|
7399
7185
|
/* @__PURE__ */ jsx("h1", { className: "flex flex-col items-baseline px-1 text-xl font-semibold xl:flex-col", children: l("Add block") }),
|
|
@@ -7412,13 +7198,13 @@ const CHAI_BUILDER_EVENTS = {
|
|
|
7412
7198
|
/* @__PURE__ */ jsx(TabsTrigger, { value: "library", children: l("Library") }),
|
|
7413
7199
|
/* @__PURE__ */ jsx(TabsTrigger, { value: "core", children: l("Blocks") }),
|
|
7414
7200
|
m && /* @__PURE__ */ jsx(TabsTrigger, { value: "partials", children: l("Partials") }),
|
|
7415
|
-
|
|
7201
|
+
x ? /* @__PURE__ */ jsx(TabsTrigger, { value: "html", children: l("Import") }) : null,
|
|
7416
7202
|
map(u, (b) => /* @__PURE__ */ jsx(TabsTrigger, { value: b.key, children: React__default.createElement(b.tab) }))
|
|
7417
7203
|
] }),
|
|
7418
7204
|
/* @__PURE__ */ jsx(TabsContent, { value: "core", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx("div", { className: "-mx-1.5 h-full max-h-full overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "mt-2 h-full w-full", children: /* @__PURE__ */ jsx(DefaultChaiBlocks, { gridCols: "grid-cols-4", parentId: r, position: a }) }) }) }),
|
|
7419
7205
|
/* @__PURE__ */ jsx(TabsContent, { value: "library", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx(UILibrariesPanel, { parentId: r, position: a }) }),
|
|
7420
7206
|
m && /* @__PURE__ */ jsx(TabsContent, { value: "partials", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx("div", { className: "-mx-1.5 h-full max-h-full overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "mt-2 h-full w-full", children: /* @__PURE__ */ jsx(PartialBlocks, { gridCols: "grid-cols-4", parentId: r, position: a }) }) }) }),
|
|
7421
|
-
|
|
7207
|
+
x ? /* @__PURE__ */ jsx(TabsContent, { value: "html", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx(ImportHTML, { parentId: r, position: a }) }) : null,
|
|
7422
7208
|
map(u, (b) => /* @__PURE__ */ jsx(TabsContent, { value: b.key, children: React__default.createElement(b.tabContent, { close: f, parentId: r, position: a }) }))
|
|
7423
7209
|
]
|
|
7424
7210
|
}
|
|
@@ -7461,7 +7247,7 @@ function UILibrariesSelect({
|
|
|
7461
7247
|
{
|
|
7462
7248
|
className: "mt-1",
|
|
7463
7249
|
options: o.map((l) => ({
|
|
7464
|
-
value: l.
|
|
7250
|
+
value: l.id,
|
|
7465
7251
|
label: l.name
|
|
7466
7252
|
})),
|
|
7467
7253
|
defaultValue: n,
|
|
@@ -7476,18 +7262,18 @@ const BlockCard = ({
|
|
|
7476
7262
|
parentId: r = void 0,
|
|
7477
7263
|
position: a = -1
|
|
7478
7264
|
}) => {
|
|
7479
|
-
const [l, i] = useState(!1), c = useBuilderProp("getUILibraryBlock", noop), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: g } = useBlockHighlight(), m = get(o, "name", get(o, "label")),
|
|
7480
|
-
const
|
|
7481
|
-
return
|
|
7265
|
+
const [l, i] = useState(!1), c = useBuilderProp("getUILibraryBlock", noop), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: g } = useBlockHighlight(), m = get(o, "name", get(o, "label")), h = useFeature("dnd"), [, f] = useAtom$1(draggedBlockAtom), x = (w) => {
|
|
7266
|
+
const S = has(w, "styles_attrs.data-page-section");
|
|
7267
|
+
return w._type === "Box" && S;
|
|
7482
7268
|
}, b = useCallback(
|
|
7483
|
-
async (
|
|
7484
|
-
if (
|
|
7269
|
+
async (w) => {
|
|
7270
|
+
if (w.stopPropagation(), has(o, "component")) {
|
|
7485
7271
|
d(o, r, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
7486
7272
|
return;
|
|
7487
7273
|
}
|
|
7488
7274
|
i(!0);
|
|
7489
|
-
const
|
|
7490
|
-
isEmpty(
|
|
7275
|
+
const S = await c(n, o);
|
|
7276
|
+
isEmpty(S) || p(syncBlocksWithDefaults(S), r, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
7491
7277
|
},
|
|
7492
7278
|
[d, p, o, c, n, r, a]
|
|
7493
7279
|
);
|
|
@@ -7497,20 +7283,20 @@ const BlockCard = ({
|
|
|
7497
7283
|
{
|
|
7498
7284
|
onClick: l ? () => {
|
|
7499
7285
|
} : b,
|
|
7500
|
-
draggable:
|
|
7501
|
-
onDragStart: async (
|
|
7502
|
-
const
|
|
7503
|
-
let
|
|
7504
|
-
if (
|
|
7505
|
-
const
|
|
7506
|
-
if (
|
|
7507
|
-
const
|
|
7508
|
-
|
|
7509
|
-
|
|
7286
|
+
draggable: h ? "true" : "false",
|
|
7287
|
+
onDragStart: async (w) => {
|
|
7288
|
+
const S = await c(n, o);
|
|
7289
|
+
let A = r;
|
|
7290
|
+
if (x(first(S)) && (A = null), !isEmpty(S)) {
|
|
7291
|
+
const E = { blocks: S, uiLibrary: !0, parent: A };
|
|
7292
|
+
if (w.dataTransfer.setData("text/plain", JSON.stringify(E)), o.preview) {
|
|
7293
|
+
const j = new Image();
|
|
7294
|
+
j.src = o.preview, j.onload = () => {
|
|
7295
|
+
w.dataTransfer.setDragImage(j, 0, 0);
|
|
7510
7296
|
};
|
|
7511
7297
|
} else
|
|
7512
|
-
|
|
7513
|
-
f(
|
|
7298
|
+
w.dataTransfer.setDragImage(new Image(), 0, 0);
|
|
7299
|
+
f(E), setTimeout(() => {
|
|
7514
7300
|
u([]), g(), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
7515
7301
|
}, 200);
|
|
7516
7302
|
}
|
|
@@ -7529,55 +7315,45 @@ const BlockCard = ({
|
|
|
7529
7315
|
) }),
|
|
7530
7316
|
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: m }) })
|
|
7531
7317
|
] });
|
|
7532
|
-
}, libraryBlocksAtom = atom$1(
|
|
7533
|
-
{}
|
|
7534
|
-
), useLibraryBlocks = (o) => {
|
|
7535
|
-
const [n, r] = useAtom$1(libraryBlocksAtom), a = useBuilderProp("getUILibraryBlocks", noop), l = get(n, `${o == null ? void 0 : o.uuid}.blocks`, null), i = get(n, `${o == null ? void 0 : o.uuid}.loading`, "idle"), c = useRef("idle");
|
|
7536
|
-
return useEffect(() => {
|
|
7537
|
-
(async () => {
|
|
7538
|
-
if (i === "complete" || c.current === "loading") return;
|
|
7539
|
-
c.current = "loading", r((p) => ({ ...p, [o == null ? void 0 : o.uuid]: { loading: "loading", blocks: [] } }));
|
|
7540
|
-
const d = await a(o);
|
|
7541
|
-
c.current = "idle", r((p) => ({ ...p, [o == null ? void 0 : o.uuid]: { loading: "complete", blocks: d || [] } }));
|
|
7542
|
-
})();
|
|
7543
|
-
}, [o, l, i, c, r, a]), { data: l || [], isLoading: i === "loading" };
|
|
7544
7318
|
}, UILibrarySection = ({ parentId: o, position: n }) => {
|
|
7545
|
-
const [r, a] = useAtom$1(selectedLibraryAtom), l = useBuilderProp("uiLibraries", []), i =
|
|
7319
|
+
const [r, a] = useAtom$1(selectedLibraryAtom), l = useBuilderProp("uiLibraries", []), i = l.find((w) => w.id === r) || first(l), { data: c, isLoading: d } = useLibraryBlocks(i), p = groupBy([...c], "group"), [u, g] = useState(null);
|
|
7320
|
+
useEffect(() => {
|
|
7321
|
+
u || g(first(keys(p)));
|
|
7322
|
+
}, [p, u]);
|
|
7323
|
+
const m = get(p, u, []), h = useRef(null), { t: f } = useTranslation(), x = (w) => {
|
|
7546
7324
|
h.current && (clearTimeout(h.current), h.current = null), h.current = setTimeout(() => {
|
|
7547
|
-
h.current &&
|
|
7325
|
+
h.current && g(w);
|
|
7548
7326
|
}, 300);
|
|
7549
7327
|
};
|
|
7550
|
-
if (
|
|
7328
|
+
if (d)
|
|
7551
7329
|
return /* @__PURE__ */ jsxs("div", { className: "mt-4 grid h-full w-full grid-cols-12 gap-2", children: [
|
|
7552
7330
|
/* @__PURE__ */ jsx(Skeleton, { className: "col-span-3 h-full" }),
|
|
7553
7331
|
/* @__PURE__ */ jsx(Skeleton, { className: "col-span-9 h-full" })
|
|
7554
7332
|
] });
|
|
7555
|
-
const
|
|
7333
|
+
const b = filter(m, (w, S) => S % 2 === 0), k = filter(m, (w, S) => S % 2 === 1);
|
|
7556
7334
|
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx("div", { className: "relative mt-2 flex h-full max-h-full overflow-hidden bg-background", children: /* @__PURE__ */ jsxs("div", { className: "flex h-full pt-2", children: [
|
|
7557
7335
|
/* @__PURE__ */ jsxs("div", { className: "flex h-full max-h-full w-60 flex-col gap-1 px-1 pr-2", children: [
|
|
7558
|
-
/* @__PURE__ */ jsx(UILibrariesSelect, { library:
|
|
7336
|
+
/* @__PURE__ */ jsx(UILibrariesSelect, { library: i == null ? void 0 : i.id, setLibrary: a, uiLibraries: l }),
|
|
7559
7337
|
/* @__PURE__ */ jsxs("div", { className: "mt-2 flex h-full max-h-full w-full flex-1 flex-col", children: [
|
|
7560
|
-
/* @__PURE__ */ jsx("span", { className: "text-xs font-bold text-gray-500", children:
|
|
7338
|
+
/* @__PURE__ */ jsx("span", { className: "text-xs font-bold text-gray-500", children: f("Groups") }),
|
|
7561
7339
|
/* @__PURE__ */ jsx("hr", { className: "mt-1 border-border" }),
|
|
7562
|
-
/* @__PURE__ */ jsx("div", { className: "no-scrollbar mt-2 h-full max-h-full flex-1 overflow-y-auto pb-20", children:
|
|
7563
|
-
|
|
7564
|
-
|
|
7565
|
-
|
|
7566
|
-
|
|
7567
|
-
|
|
7568
|
-
|
|
7569
|
-
|
|
7570
|
-
|
|
7571
|
-
|
|
7572
|
-
|
|
7573
|
-
children:
|
|
7574
|
-
|
|
7575
|
-
|
|
7576
|
-
|
|
7577
|
-
|
|
7578
|
-
|
|
7579
|
-
))
|
|
7580
|
-
) })
|
|
7340
|
+
/* @__PURE__ */ jsx("div", { className: "no-scrollbar mt-2 h-full max-h-full flex-1 overflow-y-auto pb-20", children: map(p, (w, S) => /* @__PURE__ */ jsxs(
|
|
7341
|
+
"div",
|
|
7342
|
+
{
|
|
7343
|
+
onMouseEnter: () => x(S),
|
|
7344
|
+
onMouseLeave: () => clearTimeout(h.current),
|
|
7345
|
+
onClick: () => g(S),
|
|
7346
|
+
className: cn$1(
|
|
7347
|
+
"flex w-full cursor-pointer items-center justify-between rounded-md p-2 text-sm text-foreground transition-all ease-in-out hover:bg-gray-200 dark:hover:bg-gray-800",
|
|
7348
|
+
S === u ? "bg-blue-500 text-white hover:bg-blue-600" : ""
|
|
7349
|
+
),
|
|
7350
|
+
children: [
|
|
7351
|
+
/* @__PURE__ */ jsx("span", { children: capitalize(f(S.toLowerCase())) }),
|
|
7352
|
+
/* @__PURE__ */ jsx(CaretRightIcon, { className: "ml-2 h-5 w-5" })
|
|
7353
|
+
]
|
|
7354
|
+
},
|
|
7355
|
+
S
|
|
7356
|
+
)) })
|
|
7581
7357
|
] })
|
|
7582
7358
|
] }),
|
|
7583
7359
|
/* @__PURE__ */ jsxs(
|
|
@@ -7587,12 +7363,26 @@ const BlockCard = ({
|
|
|
7587
7363
|
className: "z-10 -mt-2 flex h-full max-h-full w-full flex-col gap-2 border-l border-border transition-all ease-linear",
|
|
7588
7364
|
children: [
|
|
7589
7365
|
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-2 px-2", children: [
|
|
7590
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children:
|
|
7591
|
-
|
|
7592
|
-
|
|
7593
|
-
|
|
7594
|
-
|
|
7595
|
-
|
|
7366
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: b.map((w, S) => /* @__PURE__ */ jsx(
|
|
7367
|
+
BlockCard,
|
|
7368
|
+
{
|
|
7369
|
+
parentId: o,
|
|
7370
|
+
position: n,
|
|
7371
|
+
block: w,
|
|
7372
|
+
library: i
|
|
7373
|
+
},
|
|
7374
|
+
`block-${S}`
|
|
7375
|
+
)) }),
|
|
7376
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: k.map((w, S) => /* @__PURE__ */ jsx(
|
|
7377
|
+
BlockCard,
|
|
7378
|
+
{
|
|
7379
|
+
parentId: o,
|
|
7380
|
+
position: n,
|
|
7381
|
+
block: w,
|
|
7382
|
+
library: i
|
|
7383
|
+
},
|
|
7384
|
+
`block-${S}`
|
|
7385
|
+
)) })
|
|
7596
7386
|
] }),
|
|
7597
7387
|
/* @__PURE__ */ jsx("br", {}),
|
|
7598
7388
|
/* @__PURE__ */ jsx("br", {}),
|
|
@@ -7835,35 +7625,35 @@ const selectParent = (o, n) => {
|
|
|
7835
7625
|
var P;
|
|
7836
7626
|
const a = useBuilderProp("outlineMenuItems", []), { t: l } = useTranslation(), [i, , c] = useHiddenBlockIds(), [d] = useAtom$1(canvasIframeAtom), { hasPermission: p } = usePermissions();
|
|
7837
7627
|
let u = null;
|
|
7838
|
-
const g = o.children.length > 0, { highlightBlock: m, clearHighlight:
|
|
7628
|
+
const g = o.children.length > 0, { highlightBlock: m, clearHighlight: h } = useBlockHighlight(), { id: f, data: x, isSelected: b, willReceiveDrop: k, isDragging: w, isEditing: S, handleClick: A } = o, E = (N) => {
|
|
7839
7629
|
N.stopPropagation(), !i.includes(f) && o.toggle();
|
|
7840
|
-
},
|
|
7630
|
+
}, j = (N) => {
|
|
7841
7631
|
N.isInternal && (u = N.isOpen, N.isOpen && N.close());
|
|
7842
|
-
},
|
|
7632
|
+
}, C = (N) => {
|
|
7843
7633
|
N.isInternal && u !== null && (u ? N.open() : N.close(), u = null);
|
|
7844
|
-
}, [
|
|
7634
|
+
}, [B, L] = useAtom$1(currentAddSelection), v = () => {
|
|
7845
7635
|
var N;
|
|
7846
7636
|
y(), o.parent.isSelected || L((N = o == null ? void 0 : o.parent) == null ? void 0 : N.id);
|
|
7847
7637
|
}, y = () => {
|
|
7848
7638
|
L(null);
|
|
7849
|
-
},
|
|
7850
|
-
y(), N.stopPropagation(), !o.isOpen && !i.includes(f) && o.toggle(),
|
|
7639
|
+
}, _ = (N) => {
|
|
7640
|
+
y(), N.stopPropagation(), !o.isOpen && !i.includes(f) && o.toggle(), A(N);
|
|
7851
7641
|
};
|
|
7852
7642
|
useEffect(() => {
|
|
7853
7643
|
const N = setTimeout(() => {
|
|
7854
|
-
k && !o.isOpen && !
|
|
7644
|
+
k && !o.isOpen && !w && !i.includes(f) && o.toggle();
|
|
7855
7645
|
}, 500);
|
|
7856
7646
|
return () => clearTimeout(N);
|
|
7857
|
-
}, [k, o,
|
|
7647
|
+
}, [k, o, w]);
|
|
7858
7648
|
const T = useMemo(() => {
|
|
7859
|
-
const N = Object.keys(
|
|
7649
|
+
const N = Object.keys(x), M = [];
|
|
7860
7650
|
for (let D = 0; D < N.length; D++)
|
|
7861
7651
|
if (N[D].endsWith("_attrs")) {
|
|
7862
|
-
const O =
|
|
7652
|
+
const O = x[N[D]], $ = Object.keys(O).join("|");
|
|
7863
7653
|
$.match(/x-data/) && M.push("data"), $.match(/x-on/) && M.push("event"), $.match(/x-show|x-if/) && M.push("show");
|
|
7864
7654
|
}
|
|
7865
7655
|
return M;
|
|
7866
|
-
}, [
|
|
7656
|
+
}, [x]), I = (N, M) => {
|
|
7867
7657
|
const D = d.contentDocument || d.contentWindow.document, O = D.querySelector(`[data-block-id=${N}]`);
|
|
7868
7658
|
O && O.setAttribute("data-drop", M);
|
|
7869
7659
|
const $ = O.getBoundingClientRect(), H = d.getBoundingClientRect();
|
|
@@ -7893,13 +7683,13 @@ const selectParent = (o, n) => {
|
|
|
7893
7683
|
"div",
|
|
7894
7684
|
{
|
|
7895
7685
|
onMouseEnter: () => m(f),
|
|
7896
|
-
onMouseLeave: () =>
|
|
7897
|
-
onClick:
|
|
7686
|
+
onMouseLeave: () => h(),
|
|
7687
|
+
onClick: _,
|
|
7898
7688
|
style: n,
|
|
7899
7689
|
"data-node-id": f,
|
|
7900
7690
|
ref: i.includes(f) ? null : r,
|
|
7901
|
-
onDragStart: () =>
|
|
7902
|
-
onDragEnd: () =>
|
|
7691
|
+
onDragStart: () => j(o),
|
|
7692
|
+
onDragEnd: () => C(o),
|
|
7903
7693
|
onDragOver: (N) => {
|
|
7904
7694
|
N.preventDefault(), I(f, "yes");
|
|
7905
7695
|
},
|
|
@@ -7928,9 +7718,9 @@ const selectParent = (o, n) => {
|
|
|
7928
7718
|
className: cn$1(
|
|
7929
7719
|
"group flex w-full cursor-pointer items-center justify-between space-x-px !rounded p-1 text-foreground/80 outline-none",
|
|
7930
7720
|
b ? "bg-blue-500 text-white" : "hover:bg-slate-200 dark:hover:bg-gray-800",
|
|
7931
|
-
k && canAcceptChildBlock(
|
|
7932
|
-
(o == null ? void 0 : o.id) ===
|
|
7933
|
-
|
|
7721
|
+
k && canAcceptChildBlock(x._type, "Icon") ? "bg-green-200" : "",
|
|
7722
|
+
(o == null ? void 0 : o.id) === B ? "bg-purple-100" : "",
|
|
7723
|
+
w && "opacity-20",
|
|
7934
7724
|
i.includes(f) ? "opacity-50" : ""
|
|
7935
7725
|
),
|
|
7936
7726
|
children: [
|
|
@@ -7939,12 +7729,12 @@ const selectParent = (o, n) => {
|
|
|
7939
7729
|
"div",
|
|
7940
7730
|
{
|
|
7941
7731
|
className: `flex h-4 w-4 rotate-0 transform cursor-pointer items-center justify-center transition-transform duration-100 ${o.isOpen ? "rotate-90" : ""}`,
|
|
7942
|
-
children: g && /* @__PURE__ */ jsx("button", { onClick:
|
|
7732
|
+
children: g && /* @__PURE__ */ jsx("button", { onClick: E, type: "button", children: /* @__PURE__ */ jsx(ChevronRight, { className: `h-3 w-3 stroke-[3] ${b ? "text-slate-200" : "text-slate-400"}` }) })
|
|
7943
7733
|
}
|
|
7944
7734
|
),
|
|
7945
7735
|
/* @__PURE__ */ jsxs("div", { className: "leading-1 flex items-center", children: [
|
|
7946
|
-
/* @__PURE__ */ jsx(TypeIcon, { type:
|
|
7947
|
-
|
|
7736
|
+
/* @__PURE__ */ jsx(TypeIcon, { type: x == null ? void 0 : x._type }),
|
|
7737
|
+
S ? /* @__PURE__ */ jsx(Input, { node: o }) : /* @__PURE__ */ jsxs(
|
|
7948
7738
|
"div",
|
|
7949
7739
|
{
|
|
7950
7740
|
className: "ml-1.5 flex items-center gap-x-1 truncate text-[13px]",
|
|
@@ -7952,7 +7742,7 @@ const selectParent = (o, n) => {
|
|
|
7952
7742
|
N.stopPropagation(), o.edit(), o.deselect();
|
|
7953
7743
|
},
|
|
7954
7744
|
children: [
|
|
7955
|
-
/* @__PURE__ */ jsx("span", { children: (
|
|
7745
|
+
/* @__PURE__ */ jsx("span", { children: (x == null ? void 0 : x._name) || (x == null ? void 0 : x._type.split("/").pop()) }),
|
|
7956
7746
|
T.includes("data") && /* @__PURE__ */ jsx(FileJson, { className: "h-3 w-3 text-orange-600" }),
|
|
7957
7747
|
T.includes("event") && /* @__PURE__ */ jsx(Zap, { className: "h-3 w-3 text-yellow-500" }),
|
|
7958
7748
|
T.includes("show") && /* @__PURE__ */ jsx(EyeOff, { className: "h-3 w-3 text-orange-600" })
|
|
@@ -7973,7 +7763,7 @@ const selectParent = (o, n) => {
|
|
|
7973
7763
|
),
|
|
7974
7764
|
/* @__PURE__ */ jsx(TooltipContent, { className: "isolate z-10", children: N.tooltip })
|
|
7975
7765
|
] })),
|
|
7976
|
-
canAddChildBlock(
|
|
7766
|
+
canAddChildBlock(x == null ? void 0 : x._type) && !i.includes(f) && p(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
7977
7767
|
/* @__PURE__ */ jsx(
|
|
7978
7768
|
TooltipTrigger,
|
|
7979
7769
|
{
|
|
@@ -8199,7 +7989,227 @@ const selectParent = (o, n) => {
|
|
|
8199
7989
|
) }),
|
|
8200
7990
|
/* @__PURE__ */ jsx(PasteAtRootContextMenu, { parentContext, setParentContext })
|
|
8201
7991
|
] });
|
|
8202
|
-
},
|
|
7992
|
+
}, FONTS = [
|
|
7993
|
+
{ title: "Roboto", value: "Roboto" },
|
|
7994
|
+
{ title: "Open Sans", value: "Open Sans" },
|
|
7995
|
+
{ title: "Montserrat", value: "Montserrat" },
|
|
7996
|
+
{ title: "Lato", value: "Lato" },
|
|
7997
|
+
{ title: "Poppins", value: "Poppins" },
|
|
7998
|
+
{ title: "Oswald", value: "Oswald" },
|
|
7999
|
+
{ title: "Raleway", value: "Raleway" },
|
|
8000
|
+
{ title: "Ubuntu", value: "Ubuntu" },
|
|
8001
|
+
{ title: "Nunito", value: "Nunito" },
|
|
8002
|
+
{ title: "Merriweather", value: "Merriweather" },
|
|
8003
|
+
{ title: "Nunito Sans", value: "Nunito Sans" },
|
|
8004
|
+
{ title: "Playfair Display", value: "Playfair Display" },
|
|
8005
|
+
{ title: "Rubik", value: "Rubik" },
|
|
8006
|
+
{ title: "Inter", value: "Inter" },
|
|
8007
|
+
{ title: "Lora", value: "Lora" },
|
|
8008
|
+
{ title: "Kanit", value: "Kanit" },
|
|
8009
|
+
{ title: "Fira Sans", value: "Fira Sans" },
|
|
8010
|
+
{ title: "Hind", value: "Hind" },
|
|
8011
|
+
{ title: "Quicksand", value: "Quicksand" },
|
|
8012
|
+
{ title: "Mulish", value: "Mulish" },
|
|
8013
|
+
{ title: "Barlow", value: "Barlow" },
|
|
8014
|
+
{ title: "Inconsolata", value: "Inconsolata" },
|
|
8015
|
+
{ title: "Titillium Web", value: "Titillium Web" },
|
|
8016
|
+
{ title: "Heebo", value: "Heebo" },
|
|
8017
|
+
{ title: "IBM Plex Sans", value: "IBM Plex Sans" },
|
|
8018
|
+
{ title: "DM Sans", value: "DM Sans" },
|
|
8019
|
+
{ title: "Nanum Gothic", value: "Nanum Gothic" },
|
|
8020
|
+
{ title: "Karla", value: "Karla" },
|
|
8021
|
+
{ title: "Arimo", value: "Arimo" },
|
|
8022
|
+
{ title: "Cabin", value: "Cabin" },
|
|
8023
|
+
{ title: "Oxygen", value: "Oxygen" },
|
|
8024
|
+
{ title: "Overpass", value: "Overpass" },
|
|
8025
|
+
{ title: "Assistant", value: "Assistant" },
|
|
8026
|
+
{ title: "Tajawal", value: "Tajawal" },
|
|
8027
|
+
{ title: "Play", value: "Play" },
|
|
8028
|
+
{ title: "Exo", value: "Exo" },
|
|
8029
|
+
{ title: "Cinzel", value: "Cinzel" },
|
|
8030
|
+
{ title: "Faustina", value: "Faustina" },
|
|
8031
|
+
{ title: "Philosopher", value: "Philosopher" },
|
|
8032
|
+
{ title: "Gelasio", value: "Gelasio" },
|
|
8033
|
+
{ title: "Sofia Sans Condensed", value: "Sofia Sans Condensed" },
|
|
8034
|
+
{ title: "Noto Sans Devanagari", value: "Noto Sans Devanagari" },
|
|
8035
|
+
{ title: "Actor", value: "Actor" },
|
|
8036
|
+
{ title: "Epilogue", value: "Epilogue" },
|
|
8037
|
+
{ title: "Glegoo", value: "Glegoo" },
|
|
8038
|
+
{ title: "Overlock", value: "Overlock" },
|
|
8039
|
+
{ title: "Lustria", value: "Lustria" },
|
|
8040
|
+
{ title: "Ovo", value: "Ovo" },
|
|
8041
|
+
{ title: "Suranna", value: "Suranna" },
|
|
8042
|
+
{ title: "Bebas Neue", value: "Bebas Neue" },
|
|
8043
|
+
{ title: "Manrope", value: "Manrope" }
|
|
8044
|
+
], FontSelector = ({
|
|
8045
|
+
label: o,
|
|
8046
|
+
value: n,
|
|
8047
|
+
onChange: r
|
|
8048
|
+
}) => /* @__PURE__ */ jsxs("div", { className: "space-y-0.5", children: [
|
|
8049
|
+
/* @__PURE__ */ jsx(Label, { className: "text-sm text-slate-800", children: startCase(o) }),
|
|
8050
|
+
/* @__PURE__ */ jsx(
|
|
8051
|
+
"select",
|
|
8052
|
+
{
|
|
8053
|
+
className: "mt-1 w-full cursor-pointer rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
|
|
8054
|
+
value: n,
|
|
8055
|
+
onChange: (a) => r(a.target.value),
|
|
8056
|
+
children: FONTS.map((a) => /* @__PURE__ */ jsx("option", { value: a.value, children: a.title }, a.value))
|
|
8057
|
+
}
|
|
8058
|
+
)
|
|
8059
|
+
] }), ColorPickerInput = ({ value: o, onChange: n }) => {
|
|
8060
|
+
const r = debounce((a) => n(a), 200);
|
|
8061
|
+
return /* @__PURE__ */ jsx(
|
|
8062
|
+
"div",
|
|
8063
|
+
{
|
|
8064
|
+
className: "relative flex h-6 w-6 cursor-pointer rounded-lg border border-border",
|
|
8065
|
+
style: { backgroundColor: o },
|
|
8066
|
+
children: /* @__PURE__ */ jsx(
|
|
8067
|
+
"input",
|
|
8068
|
+
{
|
|
8069
|
+
type: "color",
|
|
8070
|
+
value: o.startsWith("#") ? o : "#000000",
|
|
8071
|
+
onChange: (a) => {
|
|
8072
|
+
const l = a.target.value;
|
|
8073
|
+
/^#[0-9A-F]{6}$/i.test(l) && r(l);
|
|
8074
|
+
},
|
|
8075
|
+
className: "absolute inset-0 h-full w-full cursor-pointer rounded-lg border-0 opacity-0"
|
|
8076
|
+
}
|
|
8077
|
+
)
|
|
8078
|
+
}
|
|
8079
|
+
);
|
|
8080
|
+
}, BorderRadiusInput = ({ value: o, onChange: n, disabled: r }) => {
|
|
8081
|
+
const a = debounce((l) => n(l), 200);
|
|
8082
|
+
return /* @__PURE__ */ jsx(
|
|
8083
|
+
"input",
|
|
8084
|
+
{
|
|
8085
|
+
type: "range",
|
|
8086
|
+
min: "0",
|
|
8087
|
+
step: "1",
|
|
8088
|
+
max: "30",
|
|
8089
|
+
disabled: r,
|
|
8090
|
+
defaultValue: o.replace("px", ""),
|
|
8091
|
+
onChange: (l) => a(l.target.value),
|
|
8092
|
+
className: "flex-1 cursor-pointer"
|
|
8093
|
+
}
|
|
8094
|
+
);
|
|
8095
|
+
}, ThemeConfigPanel = React.memo(({ className: o = "" }) => {
|
|
8096
|
+
const [n] = useDarkMode(), [r, a] = React.useState(""), l = useBuilderProp("themePresets", []), i = useBuilderProp("themePanelComponent", null), { hasPermission: c } = usePermissions(), [d, p] = useTheme(), u = useThemeOptions(), { t: g } = useTranslation(), m = (w) => {
|
|
8097
|
+
a(w);
|
|
8098
|
+
}, h = () => {
|
|
8099
|
+
const w = l.find((S) => Object.keys(S)[0] === r);
|
|
8100
|
+
if (w) {
|
|
8101
|
+
const S = Object.values(w)[0];
|
|
8102
|
+
S && typeof S == "object" && "fontFamily" in S && "borderRadius" in S && "colors" in S ? p(S) : console.error("Invalid preset structure:", S);
|
|
8103
|
+
} else
|
|
8104
|
+
console.error("Preset not found:", r);
|
|
8105
|
+
}, f = useDebouncedCallback(
|
|
8106
|
+
(w, S) => {
|
|
8107
|
+
p(() => ({
|
|
8108
|
+
...d,
|
|
8109
|
+
fontFamily: {
|
|
8110
|
+
...d.fontFamily,
|
|
8111
|
+
[w.replace(/font-/g, "")]: S
|
|
8112
|
+
}
|
|
8113
|
+
}));
|
|
8114
|
+
},
|
|
8115
|
+
[d],
|
|
8116
|
+
200
|
|
8117
|
+
), x = useDebouncedCallback(
|
|
8118
|
+
(w) => {
|
|
8119
|
+
p(() => ({
|
|
8120
|
+
...d,
|
|
8121
|
+
borderRadius: `${w}px`
|
|
8122
|
+
}));
|
|
8123
|
+
},
|
|
8124
|
+
[d],
|
|
8125
|
+
200
|
|
8126
|
+
), b = useDebouncedCallback(
|
|
8127
|
+
(w, S) => {
|
|
8128
|
+
p(() => {
|
|
8129
|
+
const A = get(d, `colors.${w}`);
|
|
8130
|
+
return n ? set(A, 1, S) : set(A, 0, S), {
|
|
8131
|
+
...d,
|
|
8132
|
+
colors: {
|
|
8133
|
+
...d.colors,
|
|
8134
|
+
[w]: A
|
|
8135
|
+
}
|
|
8136
|
+
};
|
|
8137
|
+
});
|
|
8138
|
+
},
|
|
8139
|
+
[d],
|
|
8140
|
+
200
|
|
8141
|
+
), k = (w) => /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1", children: Object.entries(w.items).map(([S]) => {
|
|
8142
|
+
const A = get(d, `colors.${S}.${n ? 1 : 0}`);
|
|
8143
|
+
return /* @__PURE__ */ jsxs("div", { className: "mt-1 flex items-center gap-x-2", children: [
|
|
8144
|
+
/* @__PURE__ */ jsx(
|
|
8145
|
+
ColorPickerInput,
|
|
8146
|
+
{
|
|
8147
|
+
value: A,
|
|
8148
|
+
onChange: (E) => b(S, E)
|
|
8149
|
+
}
|
|
8150
|
+
),
|
|
8151
|
+
/* @__PURE__ */ jsx(Label, { className: "text-xs font-normal leading-tight text-slate-600", children: S.split(/(?=[A-Z])/).join(" ").replace(/-/g, " ").split(" ").map((E) => E.charAt(0).toUpperCase() + E.slice(1)).join(" ") + (!S.toLowerCase().includes("foreground") && !S.toLowerCase().includes("border") && !S.toLowerCase().includes("input") && !S.toLowerCase().includes("ring") && !S.toLowerCase().includes("background") ? " Background" : "") })
|
|
8152
|
+
] }, S);
|
|
8153
|
+
}) });
|
|
8154
|
+
return c("edit_theme") ? /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
|
|
8155
|
+
/* @__PURE__ */ jsxs("div", { className: cn$1("no-scrollbar h-full w-full overflow-y-auto", o), children: [
|
|
8156
|
+
l.length > 0 && /* @__PURE__ */ jsxs("div", { className: "flex gap-2 py-2", children: [
|
|
8157
|
+
/* @__PURE__ */ jsxs("div", { className: "w-full", children: [
|
|
8158
|
+
/* @__PURE__ */ jsx(Label, { className: "text-sm text-slate-800", children: g("Presets") }),
|
|
8159
|
+
/* @__PURE__ */ jsxs(
|
|
8160
|
+
"select",
|
|
8161
|
+
{
|
|
8162
|
+
value: r,
|
|
8163
|
+
onChange: (w) => m(w.target.value),
|
|
8164
|
+
className: "w-full space-y-0.5 rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
|
|
8165
|
+
children: [
|
|
8166
|
+
/* @__PURE__ */ jsx("option", { value: "", children: "Select preset" }),
|
|
8167
|
+
Array.isArray(l) && l.map((w) => /* @__PURE__ */ jsx("option", { value: Object.keys(w)[0], children: capitalize(Object.keys(w)[0]) }, Object.keys(w)[0]))
|
|
8168
|
+
]
|
|
8169
|
+
}
|
|
8170
|
+
)
|
|
8171
|
+
] }),
|
|
8172
|
+
/* @__PURE__ */ jsx("div", { className: "flex w-[30%] items-end", children: /* @__PURE__ */ jsx(
|
|
8173
|
+
Button,
|
|
8174
|
+
{
|
|
8175
|
+
className: "w-full text-sm",
|
|
8176
|
+
disabled: r === "",
|
|
8177
|
+
variant: "default",
|
|
8178
|
+
onClick: h,
|
|
8179
|
+
children: g("Apply")
|
|
8180
|
+
}
|
|
8181
|
+
) })
|
|
8182
|
+
] }),
|
|
8183
|
+
/* @__PURE__ */ jsxs("div", { className: cn$1("space-y-2", o), children: [
|
|
8184
|
+
(u == null ? void 0 : u.fontFamily) && /* @__PURE__ */ jsx("div", { className: "grid gap-4", children: Object.entries(u.fontFamily).map(([w, S]) => /* @__PURE__ */ jsx(
|
|
8185
|
+
FontSelector,
|
|
8186
|
+
{
|
|
8187
|
+
label: w,
|
|
8188
|
+
value: d.fontFamily[w.replace(/font-/g, "")] || S[Object.keys(S)[0]],
|
|
8189
|
+
onChange: (A) => f(w, A)
|
|
8190
|
+
},
|
|
8191
|
+
w
|
|
8192
|
+
)) }),
|
|
8193
|
+
(u == null ? void 0 : u.borderRadius) && /* @__PURE__ */ jsxs("div", { className: "space-y-0.5 py-3", children: [
|
|
8194
|
+
/* @__PURE__ */ jsx(Label, { className: "text-sm text-slate-800", children: g("Border Radius") }),
|
|
8195
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-4 py-2", children: [
|
|
8196
|
+
/* @__PURE__ */ jsx(BorderRadiusInput, { value: d.borderRadius, onChange: x }),
|
|
8197
|
+
/* @__PURE__ */ jsx("span", { className: "w-12 text-sm", children: d.borderRadius })
|
|
8198
|
+
] })
|
|
8199
|
+
] }),
|
|
8200
|
+
(u == null ? void 0 : u.colors) && /* @__PURE__ */ jsxs("div", { className: "mt-4 space-y-0.5", children: [
|
|
8201
|
+
/* @__PURE__ */ jsx(Label, { className: "text-sm text-slate-800", children: g("Colors") }),
|
|
8202
|
+
/* @__PURE__ */ jsx("div", { className: "w-full space-y-4 pt-2", children: u.colors.map((w) => k(w)) }, n ? "dark" : "light")
|
|
8203
|
+
] })
|
|
8204
|
+
] }),
|
|
8205
|
+
/* @__PURE__ */ jsx("br", {}),
|
|
8206
|
+
/* @__PURE__ */ jsx("br", {}),
|
|
8207
|
+
/* @__PURE__ */ jsx("br", {}),
|
|
8208
|
+
/* @__PURE__ */ jsx("br", {})
|
|
8209
|
+
] }),
|
|
8210
|
+
i && /* @__PURE__ */ jsx("div", { className: "absolute bottom-4 w-full", children: React.createElement(i) })
|
|
8211
|
+
] }) : /* @__PURE__ */ jsx("div", { className: "relative w-full", children: /* @__PURE__ */ jsx("div", { className: cn$1("no-scrollbar h-full w-full overflow-y-auto text-center", o), children: /* @__PURE__ */ jsx("div", { className: "mt-10 h-full items-center justify-center gap-2 text-muted-foreground", children: /* @__PURE__ */ jsx("p", { className: "text-sm", children: "You don't have permission to edit the theme. Please contact your administrator to get access." }) }) }) });
|
|
8212
|
+
}), Core = "Core", Import = "Import", Breakpoints = "Breakpoints", Clear = "Clear", Cancel = "Cancel", Yes = "Yes", Preview = "Preview", Settings = "Settings", Styling = "Styling", Remove = "Remove", Choose = "Choose", Cut = "Cut", Copy = "Copy", Paste = "Paste", Delete = "Delete", classes = "classes", Theme = "Theme", Outline = "Outline", Copied = "Copied", Stop = "Stop", Edit = "Edit", Tag = "Tag", Value = "Value", Images = "Images", Library = "Library", Blocks = "Blocks", Basic = "Basic", Media = "Media", Advanced = "Advanced", Form = "Form", Groups = "Groups", Accordions = "Accordions", Buttons = "Buttons", Layouts = "Layouts", FAQ = "FAQ", Hero = "Hero", Features = "Features", Footer = "Footer", Navbar = "Navbar", Icons = "Icons", Testimonials = "Testimonials", Blog = "Blog", Saved = "Saved", Unsaved = "Unsaved", Randomize = "Randomize", theme_config = { heading_font: "Heading Font", body_font: "Body Font", rounded_corner: "Rounded Corners", primary: "Primary", secondary: "Secondary", background: "Background", text_color: "Text Color", background_dark_mode: "Background (Dark Mode)", text_color_dark_mode: "Text Color (Dark Mode)" }, web_blocks = { box: "box", tag: "Tag", div: "div", level: "Level", header: "header", footer: "footer", section: "section", article: "article", aside: "aside", main: "main", nav: "navigation", figure: "figure", details: "details", summary: "summary", dialog: "dialog", strike: "strike", caption: "caption", legend: "legend", figcaption: "figure caption", mark: "mark", background_image: "Background Image", label: "Label", default: "default", icon_size: "Icon Size", icon_position: "Icon Position", start: "Start", end: "End", button: "Button", custom_html: "Custom HTML", html_code: "HTML Code", default_snippet: "The HTML snippet goes here...", placeholder: "Enter custom HTML code here", custom_script: "Custom Script", dark_mode: "Dark Mode", divider: "Divider", empty_box: "Empty Box", heading: "Heading", image: "Image", alt: "Alt", width: "Width", height: "Height", video: "Video", span: "Span", content: "Content", icon: "Icon", richtext: "Rich Text", list: "List", list_type: "List Type", listitem: "List Item", link: "Link", list_item: "List Item", none: "None", disc: "Disc", number: "Number", paragraph: "Paragraph", lightbox_link: "Lightbox Link", href: "Link", type: "Type", iframe: "iframe", inline: "inline", ajax: "ajax", autoplay: "Video autoplay", max_width: "Max Width", backdrop_color: "Background Color", gallery_name: "Gallery Name", slot: "Slot", empty_slot: "Empty Slot", text: "Text", video_url: "Video URL", controls: "Show Controls", loop: "Loop", muted: "Muted", checkbox: "Checkbox", required: "Required", checked: "Checked", submit_button: "Submit Button", form: "Form", submit_url: "Submit URL", error_message: "Error Message", success_message: "Success Message", input: "Input", value: "Value", show_label: "Show Label", field_name: "Field Name", radio: "Radio", multiple: "Multiple", options: "Options", select: "Select", multiple_choice: "Multiple Choice", textarea: "Textarea", rows: "Rows" }, Undo = "Undo", Redo = "Redo", Duplicate = "Duplicate", Close = "Close", Selected = "Selected", Select = "Select", Attributes = "Attributes", apply = "apply", presets = "presets", Orientation = "Orientation", Color = "Color", Upload = "Upload", lngEn = {
|
|
8203
8213
|
"Add block": "Add Block",
|
|
8204
8214
|
"Add blocks": "Add blocks",
|
|
8205
8215
|
"Enter or paste TailwindCSS HTML snippet": "Enter or paste TailwindCSS HTML snippet",
|
|
@@ -8659,14 +8669,14 @@ function QuickPrompts({ onClick: o }) {
|
|
|
8659
8669
|
) }) });
|
|
8660
8670
|
}
|
|
8661
8671
|
const AIUserPrompt = ({ blockId: o }) => {
|
|
8662
|
-
const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, c] = useState(""), [d, p] = useState(!0), [u, g] = useState(), m = useRef(null),
|
|
8672
|
+
const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, c] = useState(""), [d, p] = useState(!0), [u, g] = useState(), m = useRef(null), h = useRef(null);
|
|
8663
8673
|
useEffect(() => {
|
|
8664
|
-
var
|
|
8665
|
-
(
|
|
8674
|
+
var x;
|
|
8675
|
+
(x = m.current) == null || x.focus();
|
|
8666
8676
|
}, []);
|
|
8667
|
-
const f = (
|
|
8668
|
-
const { usage: b } =
|
|
8669
|
-
!l && b && g(b),
|
|
8677
|
+
const f = (x) => {
|
|
8678
|
+
const { usage: b } = x || {};
|
|
8679
|
+
!l && b && g(b), h.current = setTimeout(() => g(void 0), 1e4), l || c("");
|
|
8670
8680
|
};
|
|
8671
8681
|
return /* @__PURE__ */ jsxs("div", { className: "", children: [
|
|
8672
8682
|
/* @__PURE__ */ jsxs(
|
|
@@ -8686,12 +8696,12 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8686
8696
|
{
|
|
8687
8697
|
ref: m,
|
|
8688
8698
|
value: i,
|
|
8689
|
-
onChange: (
|
|
8699
|
+
onChange: (x) => c(x.target.value),
|
|
8690
8700
|
placeholder: n("Ask AI to edit content"),
|
|
8691
8701
|
className: "w-full",
|
|
8692
8702
|
rows: 3,
|
|
8693
|
-
onKeyDown: (
|
|
8694
|
-
|
|
8703
|
+
onKeyDown: (x) => {
|
|
8704
|
+
x.key === "Enter" && (x.preventDefault(), h.current && clearTimeout(h.current), g(void 0), r("content", o, i, f));
|
|
8695
8705
|
}
|
|
8696
8706
|
}
|
|
8697
8707
|
),
|
|
@@ -8701,7 +8711,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8701
8711
|
{
|
|
8702
8712
|
disabled: i.trim().length < 5 || a,
|
|
8703
8713
|
onClick: () => {
|
|
8704
|
-
|
|
8714
|
+
h.current && clearTimeout(h.current), g(void 0), r("content", o, i, f);
|
|
8705
8715
|
},
|
|
8706
8716
|
variant: "default",
|
|
8707
8717
|
className: "w-fit",
|
|
@@ -8733,8 +8743,8 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8733
8743
|
/* @__PURE__ */ jsx(
|
|
8734
8744
|
QuickPrompts,
|
|
8735
8745
|
{
|
|
8736
|
-
onClick: (
|
|
8737
|
-
|
|
8746
|
+
onClick: (x) => {
|
|
8747
|
+
h.current && clearTimeout(h.current), g(void 0), r("content", o, x, f);
|
|
8738
8748
|
}
|
|
8739
8749
|
}
|
|
8740
8750
|
)
|
|
@@ -8748,7 +8758,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8748
8758
|
useEffect(() => {
|
|
8749
8759
|
n && a(n);
|
|
8750
8760
|
}, [n]);
|
|
8751
|
-
const
|
|
8761
|
+
const h = async () => {
|
|
8752
8762
|
try {
|
|
8753
8763
|
d(!0), u(null), await i(r), toast.success(o("Updated AI Context")), m.current.click();
|
|
8754
8764
|
} catch (f) {
|
|
@@ -8778,7 +8788,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8778
8788
|
className: "mt-1 w-full",
|
|
8779
8789
|
rows: 10,
|
|
8780
8790
|
onKeyDown: (f) => {
|
|
8781
|
-
f.key === "Enter" && (f.preventDefault(),
|
|
8791
|
+
f.key === "Enter" && (f.preventDefault(), h());
|
|
8782
8792
|
}
|
|
8783
8793
|
}
|
|
8784
8794
|
),
|
|
@@ -8790,7 +8800,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8790
8800
|
Button,
|
|
8791
8801
|
{
|
|
8792
8802
|
disabled: r.trim().length < 5,
|
|
8793
|
-
onClick: () =>
|
|
8803
|
+
onClick: () => h(),
|
|
8794
8804
|
variant: "default",
|
|
8795
8805
|
className: "w-fit",
|
|
8796
8806
|
size: "sm",
|
|
@@ -8819,7 +8829,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8819
8829
|
AlertDialogAction,
|
|
8820
8830
|
{
|
|
8821
8831
|
onClick: () => {
|
|
8822
|
-
a(""),
|
|
8832
|
+
a(""), h();
|
|
8823
8833
|
},
|
|
8824
8834
|
children: o("Yes, Delete")
|
|
8825
8835
|
}
|
|
@@ -8976,53 +8986,53 @@ const AiAssistant = () => {
|
|
|
8976
8986
|
preloadedAttributes: n = [],
|
|
8977
8987
|
onAttributesChange: r
|
|
8978
8988
|
}) {
|
|
8979
|
-
const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, g] = useState(null), [m,
|
|
8989
|
+
const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, g] = useState(null), [m, h] = useState(""), f = useRef(null), x = useRef(null), b = usePageExternalData();
|
|
8980
8990
|
useEffect(() => {
|
|
8981
8991
|
l(n);
|
|
8982
8992
|
}, [n]);
|
|
8983
8993
|
const k = () => {
|
|
8984
8994
|
if (i.startsWith("@")) {
|
|
8985
|
-
|
|
8995
|
+
h("Attribute keys cannot start with '@'");
|
|
8986
8996
|
return;
|
|
8987
8997
|
}
|
|
8988
8998
|
if (i) {
|
|
8989
|
-
const
|
|
8990
|
-
r(
|
|
8999
|
+
const C = [...a, { key: i, value: d }];
|
|
9000
|
+
r(C), l(a), c(""), p(""), h("");
|
|
8991
9001
|
}
|
|
8992
|
-
},
|
|
8993
|
-
const
|
|
8994
|
-
r(
|
|
8995
|
-
},
|
|
8996
|
-
g(
|
|
8997
|
-
},
|
|
9002
|
+
}, w = (C) => {
|
|
9003
|
+
const B = a.filter((L, v) => v !== C);
|
|
9004
|
+
r(B), l(B);
|
|
9005
|
+
}, S = (C) => {
|
|
9006
|
+
g(C), c(a[C].key), p(a[C].value);
|
|
9007
|
+
}, A = () => {
|
|
8998
9008
|
if (i.startsWith("@")) {
|
|
8999
|
-
|
|
9009
|
+
h("Attribute keys cannot start with '@'");
|
|
9000
9010
|
return;
|
|
9001
9011
|
}
|
|
9002
9012
|
if (u !== null && i) {
|
|
9003
|
-
const
|
|
9004
|
-
|
|
9013
|
+
const C = [...a];
|
|
9014
|
+
C[u] = { key: i, value: d }, r(C), l(C), g(null), c(""), p(""), h("");
|
|
9005
9015
|
}
|
|
9006
|
-
},
|
|
9007
|
-
|
|
9008
|
-
},
|
|
9009
|
-
const
|
|
9016
|
+
}, E = (C) => {
|
|
9017
|
+
C.key === "Enter" && !C.shiftKey && (C.preventDefault(), u !== null ? A() : k());
|
|
9018
|
+
}, j = useCallback((C) => {
|
|
9019
|
+
const B = (y) => /[.,!?;:]/.test(y), L = (y, _, T) => {
|
|
9010
9020
|
let I = "", R = "";
|
|
9011
|
-
const P =
|
|
9012
|
-
return
|
|
9021
|
+
const P = _ > 0 ? y[_ - 1] : "", N = _ < y.length ? y[_] : "";
|
|
9022
|
+
return _ > 0 && (P === "." || !B(P) && P !== " ") && (I = " "), _ < y.length && !B(N) && N !== " " && (R = " "), {
|
|
9013
9023
|
text: I + T + R,
|
|
9014
9024
|
prefixLength: I.length,
|
|
9015
9025
|
suffixLength: R.length
|
|
9016
9026
|
};
|
|
9017
|
-
}, v =
|
|
9027
|
+
}, v = x.current;
|
|
9018
9028
|
if (v) {
|
|
9019
|
-
const y = v.selectionStart || 0,
|
|
9029
|
+
const y = v.selectionStart || 0, _ = v.value || "", T = v.selectionEnd || y;
|
|
9020
9030
|
if (T > y) {
|
|
9021
|
-
const M = `{{${
|
|
9031
|
+
const M = `{{${C}}}`, { text: D } = L(_, y, M), O = _.slice(0, y) + D + _.slice(T);
|
|
9022
9032
|
p(O);
|
|
9023
9033
|
return;
|
|
9024
9034
|
}
|
|
9025
|
-
const R = `{{${
|
|
9035
|
+
const R = `{{${C}}}`, { text: P } = L(_, y, R), N = _.slice(0, y) + P + _.slice(y);
|
|
9026
9036
|
p(N);
|
|
9027
9037
|
}
|
|
9028
9038
|
}, []);
|
|
@@ -9030,8 +9040,8 @@ const AiAssistant = () => {
|
|
|
9030
9040
|
/* @__PURE__ */ jsxs(
|
|
9031
9041
|
"form",
|
|
9032
9042
|
{
|
|
9033
|
-
onSubmit: (
|
|
9034
|
-
|
|
9043
|
+
onSubmit: (C) => {
|
|
9044
|
+
C.preventDefault(), u !== null ? A() : k();
|
|
9035
9045
|
},
|
|
9036
9046
|
className: "space-y-3",
|
|
9037
9047
|
children: [
|
|
@@ -9047,7 +9057,7 @@ const AiAssistant = () => {
|
|
|
9047
9057
|
id: "attrKey",
|
|
9048
9058
|
ref: f,
|
|
9049
9059
|
value: i,
|
|
9050
|
-
onChange: (
|
|
9060
|
+
onChange: (C) => c(C.target.value),
|
|
9051
9061
|
placeholder: "Enter Key",
|
|
9052
9062
|
className: "py-0 text-xs font-normal leading-tight placeholder:text-slate-400"
|
|
9053
9063
|
}
|
|
@@ -9056,7 +9066,7 @@ const AiAssistant = () => {
|
|
|
9056
9066
|
/* @__PURE__ */ jsxs("div", { className: "w-full", children: [
|
|
9057
9067
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
9058
9068
|
/* @__PURE__ */ jsx(Label, { htmlFor: "attrValue", className: "text-[11px] font-normal text-slate-600", children: "Value" }),
|
|
9059
|
-
!isEmpty(b) && /* @__PURE__ */ jsx(NestedPathSelector, { data: b, onSelect:
|
|
9069
|
+
!isEmpty(b) && /* @__PURE__ */ jsx(NestedPathSelector, { data: b, onSelect: j })
|
|
9060
9070
|
] }),
|
|
9061
9071
|
/* @__PURE__ */ jsx(
|
|
9062
9072
|
Textarea,
|
|
@@ -9066,10 +9076,10 @@ const AiAssistant = () => {
|
|
|
9066
9076
|
spellCheck: "false",
|
|
9067
9077
|
id: "attrValue",
|
|
9068
9078
|
rows: 2,
|
|
9069
|
-
ref:
|
|
9079
|
+
ref: x,
|
|
9070
9080
|
value: d,
|
|
9071
|
-
onChange: (
|
|
9072
|
-
onKeyDown:
|
|
9081
|
+
onChange: (C) => p(C.target.value),
|
|
9082
|
+
onKeyDown: E,
|
|
9073
9083
|
placeholder: "Enter Value",
|
|
9074
9084
|
className: "text-xs font-normal leading-tight placeholder:text-slate-400"
|
|
9075
9085
|
}
|
|
@@ -9081,16 +9091,16 @@ const AiAssistant = () => {
|
|
|
9081
9091
|
]
|
|
9082
9092
|
}
|
|
9083
9093
|
),
|
|
9084
|
-
/* @__PURE__ */ jsx("div", { className: "space-y-1 py-4", children: a.map((
|
|
9094
|
+
/* @__PURE__ */ jsx("div", { className: "space-y-1 py-4", children: a.map((C, B) => /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between rounded border p-2 text-sm", children: [
|
|
9085
9095
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col text-xs leading-tight", children: [
|
|
9086
|
-
/* @__PURE__ */ jsx("span", { className: "truncate text-[12px] font-light text-muted-foreground", children:
|
|
9087
|
-
/* @__PURE__ */ jsx("span", { className: "max-w-[200px] text-wrap font-normal", children:
|
|
9096
|
+
/* @__PURE__ */ jsx("span", { className: "truncate text-[12px] font-light text-muted-foreground", children: C.key }),
|
|
9097
|
+
/* @__PURE__ */ jsx("span", { className: "max-w-[200px] text-wrap font-normal", children: C.value.toString() })
|
|
9088
9098
|
] }),
|
|
9089
9099
|
/* @__PURE__ */ jsxs("div", { className: "flex-shrink-0 text-slate-400", children: [
|
|
9090
|
-
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => B
|
|
9091
|
-
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () =>
|
|
9100
|
+
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => S(B), children: /* @__PURE__ */ jsx(Edit2, { className: "h-3 w-3" }) }),
|
|
9101
|
+
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => w(B), children: /* @__PURE__ */ jsx(X, { className: "h-3 w-3" }) })
|
|
9092
9102
|
] })
|
|
9093
|
-
] },
|
|
9103
|
+
] }, B)) })
|
|
9094
9104
|
] });
|
|
9095
9105
|
}), BlockAttributesEditor = React.memo(() => {
|
|
9096
9106
|
const o = useSelectedBlock(), [n, r] = useState([]), [a] = useSelectedStylingBlocks(), l = useUpdateBlocksProps(), i = `${get(a, "0.prop")}_attrs`;
|
|
@@ -9300,11 +9310,11 @@ const RootLayout = () => {
|
|
|
9300
9310
|
usePubSub(CHAI_BUILDER_EVENTS.SHOW_BLOCK_SETTINGS, () => {
|
|
9301
9311
|
n(1);
|
|
9302
9312
|
});
|
|
9303
|
-
const c = useBuilderProp("sideBarComponents.top", []), d = useBuilderProp("sideBarComponents.bottom", []), p = (
|
|
9304
|
-
|
|
9305
|
-
}, u = (
|
|
9306
|
-
n(o ===
|
|
9307
|
-
}, g = useSidebarMenuItems(), { t: m } = useTranslation(),
|
|
9313
|
+
const c = useBuilderProp("sideBarComponents.top", []), d = useBuilderProp("sideBarComponents.bottom", []), p = (x) => {
|
|
9314
|
+
x.preventDefault();
|
|
9315
|
+
}, u = (x) => {
|
|
9316
|
+
n(o === x ? null : x);
|
|
9317
|
+
}, g = useSidebarMenuItems(), { t: m } = useTranslation(), h = [...g, ...c], f = useBuilderProp("htmlDir", "ltr");
|
|
9308
9318
|
return /* @__PURE__ */ jsx("div", { dir: f, className: "h-screen max-h-full w-screen overflow-x-hidden bg-background text-foreground", children: /* @__PURE__ */ jsxs(TooltipProvider, { children: [
|
|
9309
9319
|
/* @__PURE__ */ jsxs(
|
|
9310
9320
|
"div",
|
|
@@ -9315,21 +9325,21 @@ const RootLayout = () => {
|
|
|
9315
9325
|
/* @__PURE__ */ jsx("div", { className: "h-14 w-screen shrink-0 border-b border-border", children: /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(TopBar, {}) }) }),
|
|
9316
9326
|
/* @__PURE__ */ jsxs("main", { className: "relative flex h-[calc(100vh-56px)] max-w-full flex-1 flex-row", children: [
|
|
9317
9327
|
/* @__PURE__ */ jsxs("div", { className: "flex w-12 flex-col items-center justify-between border-r border-border py-2", children: [
|
|
9318
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-col", children:
|
|
9328
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col", children: h.map((x, b) => /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
9319
9329
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
|
|
9320
9330
|
Button,
|
|
9321
9331
|
{
|
|
9322
9332
|
variant: o === b ? "default" : "ghost",
|
|
9323
9333
|
className: "mb-2 rounded-lg p-2 transition-colors",
|
|
9324
9334
|
onClick: () => u(b),
|
|
9325
|
-
children: get(
|
|
9335
|
+
children: get(x, "icon", null)
|
|
9326
9336
|
},
|
|
9327
9337
|
b
|
|
9328
9338
|
) }),
|
|
9329
|
-
/* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: m(
|
|
9339
|
+
/* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: m(x.label) }) })
|
|
9330
9340
|
] }, "button" + b)) }),
|
|
9331
9341
|
/* @__PURE__ */ jsx("div", { className: "flex flex-col space-y-1" }),
|
|
9332
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-col", children: d == null ? void 0 : d.map((
|
|
9342
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col", children: d == null ? void 0 : d.map((x, b) => /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", {}), children: React__default.createElement(x, {}) }, `sidebar-component-${b}`)) })
|
|
9333
9343
|
] }),
|
|
9334
9344
|
/* @__PURE__ */ jsx(
|
|
9335
9345
|
motion.div,
|
|
@@ -9342,14 +9352,14 @@ const RootLayout = () => {
|
|
|
9342
9352
|
/* @__PURE__ */ jsxs(
|
|
9343
9353
|
"div",
|
|
9344
9354
|
{
|
|
9345
|
-
className: `absolute top-2 flex h-10 items-center space-x-1 bg-white py-2 text-base font-bold ${get(
|
|
9355
|
+
className: `absolute top-2 flex h-10 items-center space-x-1 bg-white py-2 text-base font-bold ${get(h, `${o}.isInternal`, !1) ? "" : "w-64"}`,
|
|
9346
9356
|
children: [
|
|
9347
|
-
/* @__PURE__ */ jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(
|
|
9348
|
-
/* @__PURE__ */ jsx("span", { children: m(
|
|
9357
|
+
/* @__PURE__ */ jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(h, `${o}.icon`, null) }),
|
|
9358
|
+
/* @__PURE__ */ jsx("span", { children: m(h[o].label) })
|
|
9349
9359
|
]
|
|
9350
9360
|
}
|
|
9351
9361
|
),
|
|
9352
|
-
/* @__PURE__ */ jsx("div", { className: "no-scrollbar max-h-full overflow-y-auto pt-10", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(
|
|
9362
|
+
/* @__PURE__ */ jsx("div", { className: "no-scrollbar max-h-full overflow-y-auto pt-10", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(h, `${o}.component`, null), {}) }) })
|
|
9353
9363
|
] })
|
|
9354
9364
|
}
|
|
9355
9365
|
),
|
|
@@ -9472,6 +9482,8 @@ const RootLayout = () => {
|
|
|
9472
9482
|
/* @__PURE__ */ jsx(Toaster, {})
|
|
9473
9483
|
] }) }) });
|
|
9474
9484
|
};
|
|
9485
|
+
if (typeof window > "u")
|
|
9486
|
+
throw new Error("@chaibuilder/sdk is only supported in the browser. Avoid using it in the server side.");
|
|
9475
9487
|
export {
|
|
9476
9488
|
AISetContext,
|
|
9477
9489
|
AIUserPrompt,
|
|
@@ -9489,8 +9501,8 @@ export {
|
|
|
9489
9501
|
ListTree as Outline,
|
|
9490
9502
|
PERMISSIONS,
|
|
9491
9503
|
Breakpoints$1 as ScreenSizes,
|
|
9492
|
-
ThemeConfigPanel
|
|
9493
|
-
UILibrariesPanel
|
|
9504
|
+
ThemeConfigPanel,
|
|
9505
|
+
UILibrariesPanel,
|
|
9494
9506
|
UndoRedo,
|
|
9495
9507
|
generateUUID as generateBlockId,
|
|
9496
9508
|
getBlocksFromHTML,
|
|
@@ -9520,6 +9532,7 @@ export {
|
|
|
9520
9532
|
useHighlightBlockId,
|
|
9521
9533
|
useLanguages,
|
|
9522
9534
|
useLayoutVariant,
|
|
9535
|
+
useLibraryBlocks,
|
|
9523
9536
|
usePartailBlocksStore,
|
|
9524
9537
|
usePartialBlocksList,
|
|
9525
9538
|
usePasteBlocks,
|