@chaibuilder/sdk 2.0.0-beta.97 → 2.0.0-beta.99
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 +1 -1
- package/dist/core.js +47 -47
- package/package.json +1 -1
package/dist/core.js
CHANGED
|
@@ -5,9 +5,9 @@ import { jsx, Fragment, jsxs } from "react/jsx-runtime";
|
|
|
5
5
|
import * as React from "react";
|
|
6
6
|
import React__default, { createContext, useReducer, useEffect, useDebugValue, useCallback, useContext, useMemo, Component, Children, useState, useRef, Suspense, createElement, memo, lazy } from "react";
|
|
7
7
|
import { ag as useToast, S as Skeleton, B as Button, L as Label, D as Dialog, s as DialogTrigger, a as DialogContent, h as Badge, T as Textarea, O as Tooltip, P as TooltipTrigger, Q as TooltipContent, V as Popover, W as PopoverTrigger, X as PopoverContent, I as Input$1, U as TooltipPortal, e as AccordionItem, f as AccordionTrigger, g as AccordionContent, $ as DropdownMenu, a0 as DropdownMenuTrigger, a1 as DropdownMenuContent, G as ScrollArea, a5 as DropdownMenuLabel, a6 as DropdownMenuSeparator, a8 as DropdownMenuGroup, a2 as DropdownMenuItem, a7 as DropdownMenuShortcut, A as Accordion, C as Card, x as CardHeader, E as CardDescription, F as CardContent, y as CardFooter, J as Tabs, K as TabsList, M as TabsTrigger, N as TabsContent, aj as ContextMenu, ak as ContextMenuTrigger, al as ContextMenuContent, am as ContextMenuItem, j as AlertDialog, k as AlertDialogTrigger, l as AlertDialogContent, m as AlertDialogHeader, o as AlertDialogTitle, p as AlertDialogDescription, n as AlertDialogFooter, r as AlertDialogCancel, q as AlertDialogAction, a3 as DropdownMenuCheckboxItem, Y as HoverCard, Z as HoverCardTrigger, _ as HoverCardContent, b as Switch, ae as Separator, R as TooltipProvider, ai as Toaster } from "./context-menu-D5ViOi6K.js";
|
|
8
|
-
import { atom as atom$1, useAtomValue as useAtomValue$1, useAtom as useAtom$1, getDefaultStore as getDefaultStore$1, useSetAtom as useSetAtom$1 } from "jotai";
|
|
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
9
|
import { has, get, find, filter, flatten, map, omit, isString, includes, without, compact, each, set, first, isObject, memoize, isEmpty, noop, keys, range, values, flattenDeep, startsWith, isNull, forEach, unset, chunk, cloneDeep, pick, throttle, isFunction as isFunction$1, reverse, startCase, debounce, capitalize, split, findIndex, take, nth, toLower, isNumber, parseInt as parseInt$1, isNaN as isNaN$1, findLast, intersection, groupBy, uniq, flatMapDeep, some, reject, sortBy, toUpper, round } from "lodash-es";
|
|
10
|
-
import { Provider } from "react-wrap-balancer";
|
|
10
|
+
import { Provider as Provider$1 } from "react-wrap-balancer";
|
|
11
11
|
import { g as generateUUID, a as getBreakpointValue, c as cn, G as GenIcon } from "./iconBase-DHfFLkem.js";
|
|
12
12
|
import { useTranslation, initReactI18next } from "react-i18next";
|
|
13
13
|
import { useTranslation as Te } from "react-i18next";
|
|
@@ -17,7 +17,7 @@ import { ArrowUpIcon, PlusIcon, CopyIcon, TrashIcon, DragHandleDots2Icon, BoxMod
|
|
|
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
|
-
import { registerChaiBlock as
|
|
20
|
+
import { registerChaiBlock as Pe } 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
22
|
import TreeModel from "tree-model";
|
|
23
23
|
import { useHotkeys } from "react-hotkeys-hook";
|
|
@@ -136,22 +136,22 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
|
|
|
136
136
|
}
|
|
137
137
|
for (let N = S.length - 1; N >= 0; --N) {
|
|
138
138
|
const [I, L] = S[N];
|
|
139
|
-
let
|
|
139
|
+
let R = !1;
|
|
140
140
|
for (const T of L.d.keys())
|
|
141
141
|
if (T !== I && a.has(T)) {
|
|
142
|
-
|
|
142
|
+
R = !0;
|
|
143
143
|
break;
|
|
144
144
|
}
|
|
145
|
-
|
|
145
|
+
R && (x(I), _(I)), r.delete(I);
|
|
146
146
|
}
|
|
147
147
|
}), x = m[3] || ((S) => {
|
|
148
148
|
var E, k;
|
|
149
149
|
const v = h(S);
|
|
150
150
|
if (isAtomStateInitialized(v) && (n.has(S) && r.get(S) !== v.n || Array.from(v.d).every(
|
|
151
|
-
([
|
|
151
|
+
([P, M]) => (
|
|
152
152
|
// Recursively, read the atom state of the dependency, and
|
|
153
153
|
// check if the atom epoch number is unchanged
|
|
154
|
-
x(
|
|
154
|
+
x(P).n === M
|
|
155
155
|
)
|
|
156
156
|
)))
|
|
157
157
|
return v;
|
|
@@ -159,34 +159,34 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
|
|
|
159
159
|
let N = !0;
|
|
160
160
|
const I = () => {
|
|
161
161
|
n.has(S) && (_(S), f(), b());
|
|
162
|
-
}, L = (
|
|
162
|
+
}, L = (P) => {
|
|
163
163
|
var M;
|
|
164
|
-
if (isSelfAtom(S,
|
|
165
|
-
const V = h(
|
|
164
|
+
if (isSelfAtom(S, P)) {
|
|
165
|
+
const V = h(P);
|
|
166
166
|
if (!isAtomStateInitialized(V))
|
|
167
|
-
if (hasInitialValue(
|
|
168
|
-
setAtomStateValueOrPromise(
|
|
167
|
+
if (hasInitialValue(P))
|
|
168
|
+
setAtomStateValueOrPromise(P, P.init, h);
|
|
169
169
|
else
|
|
170
170
|
throw new Error("no atom init");
|
|
171
171
|
return returnAtomValue(V);
|
|
172
172
|
}
|
|
173
|
-
const O = x(
|
|
173
|
+
const O = x(P);
|
|
174
174
|
try {
|
|
175
175
|
return returnAtomValue(O);
|
|
176
176
|
} finally {
|
|
177
|
-
v.d.set(
|
|
177
|
+
v.d.set(P, O.n), isPendingPromise(v.v) && addPendingPromiseToDependency(S, v.v, O), (M = n.get(P)) == null || M.t.add(S), N || I();
|
|
178
178
|
}
|
|
179
179
|
};
|
|
180
|
-
let
|
|
180
|
+
let R, T;
|
|
181
181
|
const D = {
|
|
182
182
|
get signal() {
|
|
183
|
-
return
|
|
183
|
+
return R || (R = new AbortController()), R.signal;
|
|
184
184
|
},
|
|
185
185
|
get setSelf() {
|
|
186
|
-
return !T && isActuallyWritableAtom(S) && (T = (...
|
|
186
|
+
return !T && isActuallyWritableAtom(S) && (T = (...P) => {
|
|
187
187
|
if (!N)
|
|
188
188
|
try {
|
|
189
|
-
return B(S, ...
|
|
189
|
+
return B(S, ...P);
|
|
190
190
|
} finally {
|
|
191
191
|
f(), b();
|
|
192
192
|
}
|
|
@@ -194,13 +194,13 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
|
|
|
194
194
|
}
|
|
195
195
|
}, $ = v.n;
|
|
196
196
|
try {
|
|
197
|
-
const
|
|
198
|
-
return setAtomStateValueOrPromise(S,
|
|
197
|
+
const P = d(S, L, D);
|
|
198
|
+
return setAtomStateValueOrPromise(S, P, h), isPromiseLike$2(P) && ((E = P.onCancel) == null || E.call(P, () => R == null ? void 0 : R.abort()), P.then(
|
|
199
199
|
I,
|
|
200
200
|
I
|
|
201
201
|
)), v;
|
|
202
|
-
} catch (
|
|
203
|
-
return delete v.v, v.e =
|
|
202
|
+
} catch (P) {
|
|
203
|
+
return delete v.v, v.e = P, ++v.n, v;
|
|
204
204
|
} finally {
|
|
205
205
|
N = !1, $ !== v.n && r.get(S) === $ && (r.set(S, v.n), a.add(S), (k = c.c) == null || k.call(c, S));
|
|
206
206
|
}
|
|
@@ -216,14 +216,14 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
|
|
|
216
216
|
}), B = m[5] || ((S, ...E) => {
|
|
217
217
|
let k = !0;
|
|
218
218
|
const v = (I) => returnAtomValue(x(I)), N = (I, ...L) => {
|
|
219
|
-
var
|
|
219
|
+
var R;
|
|
220
220
|
const T = h(I);
|
|
221
221
|
try {
|
|
222
222
|
if (isSelfAtom(S, I)) {
|
|
223
223
|
if (!hasInitialValue(I))
|
|
224
224
|
throw new Error("atom not writable");
|
|
225
225
|
const D = T.n, $ = L[0];
|
|
226
|
-
setAtomStateValueOrPromise(I, $, h), _(I), D !== T.n && (a.add(I), (
|
|
226
|
+
setAtomStateValueOrPromise(I, $, h), _(I), D !== T.n && (a.add(I), (R = c.c) == null || R.call(c, I), y(I));
|
|
227
227
|
return;
|
|
228
228
|
} else
|
|
229
229
|
return B(I, ...L);
|
|
@@ -267,19 +267,19 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
|
|
|
267
267
|
}, n.set(S, v), (E = c.m) == null || E.call(c, S), isActuallyWritableAtom(S)) {
|
|
268
268
|
const N = () => {
|
|
269
269
|
let I = !0;
|
|
270
|
-
const L = (...
|
|
270
|
+
const L = (...R) => {
|
|
271
271
|
try {
|
|
272
|
-
return B(S, ...
|
|
272
|
+
return B(S, ...R);
|
|
273
273
|
} finally {
|
|
274
274
|
I || (f(), b());
|
|
275
275
|
}
|
|
276
276
|
};
|
|
277
277
|
try {
|
|
278
|
-
const
|
|
279
|
-
|
|
278
|
+
const R = g(S, L);
|
|
279
|
+
R && (v.u = () => {
|
|
280
280
|
I = !0;
|
|
281
281
|
try {
|
|
282
|
-
|
|
282
|
+
R();
|
|
283
283
|
} finally {
|
|
284
284
|
I = !1;
|
|
285
285
|
}
|
|
@@ -3805,25 +3805,25 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
3805
3805
|
[r, l, i, h, b, f, x]
|
|
3806
3806
|
);
|
|
3807
3807
|
return isNull(m) || p.includes(r._id) || u === r._id ? null : /* @__PURE__ */ jsx(Suspense, { children: createElement(m, { ...y, children: n }) });
|
|
3808
|
-
}, GlobalBlocksRenderer = ({
|
|
3809
|
-
const { getGlobalBlocks: n } = useGlobalBlocksStore(),
|
|
3810
|
-
return /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms:
|
|
3808
|
+
}, GlobalBlocksRenderer = ({ globalBlockId: o }) => {
|
|
3809
|
+
const { getGlobalBlocks: n } = useGlobalBlocksStore(), r = useMemo(() => n(o), [n, o]), a = useMemo(() => splitAtom(atom$1(r)), [r]);
|
|
3810
|
+
return isEmpty(r) ? null : /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: a, blocks: r });
|
|
3811
3811
|
}, BlocksRenderer = ({
|
|
3812
3812
|
blocks: o,
|
|
3813
3813
|
parent: n = null,
|
|
3814
3814
|
splitAtoms: r = void 0
|
|
3815
3815
|
}) => {
|
|
3816
3816
|
const a = useGetBlockAtom(r), l = useMemo(
|
|
3817
|
-
() => filter(o, (c) =>
|
|
3817
|
+
() => filter(o, (c) => has(c, "_id") && (isEmpty(n) ? !c._parent : c._parent === n)),
|
|
3818
3818
|
[o, n]
|
|
3819
3819
|
), i = useCallback((c) => filter(o, (d) => d._parent === c._id).length > 0, [o]);
|
|
3820
3820
|
return map(l, (c) => {
|
|
3821
3821
|
const d = a(c._id);
|
|
3822
|
-
return d ? /* @__PURE__ */ jsx(BlockRenderer, { blockAtom: d, children: c._type === "GlobalBlock" ? /* @__PURE__ */ jsx(GlobalBlocksRenderer, {
|
|
3822
|
+
return d ? /* @__PURE__ */ jsx(BlockRenderer, { blockAtom: d, children: c._type === "GlobalBlock" ? /* @__PURE__ */ jsx(Provider, { store: builderStore, children: /* @__PURE__ */ jsx(GlobalBlocksRenderer, { globalBlockId: get(c, "globalBlock", "") }) }) : i(c) ? /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: r, blocks: o, parent: c._id }) : null }, c._id) : null;
|
|
3823
3823
|
});
|
|
3824
3824
|
}, PageBlocksRenderer = () => {
|
|
3825
3825
|
const [o] = useBlocksStore();
|
|
3826
|
-
return
|
|
3826
|
+
return /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: pageBlocksAtomsAtom, blocks: o });
|
|
3827
3827
|
}, StaticBlocksRenderer = () => {
|
|
3828
3828
|
const [o] = useBlocksStore(), n = isEmpty(o) ? null : /* @__PURE__ */ jsx(PageBlocksRenderer, {});
|
|
3829
3829
|
return /* @__PURE__ */ jsx(Fragment, { children: n });
|
|
@@ -3914,7 +3914,7 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
3914
3914
|
}
|
|
3915
3915
|
),
|
|
3916
3916
|
/* @__PURE__ */ jsx(HeadTags, {}),
|
|
3917
|
-
/* @__PURE__ */ jsx(Provider, { children: /* @__PURE__ */ jsxs(Canvas, { children: [
|
|
3917
|
+
/* @__PURE__ */ jsx(Provider$1, { children: /* @__PURE__ */ jsxs(Canvas, { children: [
|
|
3918
3918
|
y ? /* @__PURE__ */ jsx("div", { className: "h-full p-4", children: /* @__PURE__ */ jsx(Skeleton, { className: "h-full" }) }) : /* @__PURE__ */ jsx(StaticBlocksRenderer, {}),
|
|
3919
3919
|
/* @__PURE__ */ jsx(AddBlockAtBottom, {}),
|
|
3920
3920
|
/* @__PURE__ */ jsx("br", {}),
|
|
@@ -5859,8 +5859,8 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
5859
5859
|
const v = parseInt$1(k.target.value);
|
|
5860
5860
|
let N = isNaN$1(v) ? 0 : v;
|
|
5861
5861
|
k.keyCode === 38 && (N += 1), k.keyCode === 40 && (N -= 1);
|
|
5862
|
-
const I = `${N}`,
|
|
5863
|
-
j(
|
|
5862
|
+
const I = `${N}`, R = `${I.startsWith("-") ? "-" : ""}${d}[${I.replace("-", "")}${m === "-" ? "" : m}]`;
|
|
5863
|
+
j(R);
|
|
5864
5864
|
},
|
|
5865
5865
|
onKeyUp: (k) => {
|
|
5866
5866
|
w && (k.preventDefault(), C(!1));
|
|
@@ -7130,7 +7130,7 @@ function BiExpandVertical(o) {
|
|
|
7130
7130
|
return GenIcon({ tag: "svg", attr: { viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { d: "m12 19.24-4.95-4.95-1.41 1.42L12 22.07l6.36-6.36-1.41-1.42L12 19.24zM5.64 8.29l1.41 1.42L12 4.76l4.95 4.95 1.41-1.42L12 1.93 5.64 8.29z" }, child: [] }] })(o);
|
|
7131
7131
|
}
|
|
7132
7132
|
const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, dragHandle: r }) => {
|
|
7133
|
-
var
|
|
7133
|
+
var R;
|
|
7134
7134
|
const a = useBuilderProp("outlineMenuItems", []), { t: l } = useTranslation(), [i, , c] = useHiddenBlockIds(), [d] = useAtom$1(canvasIframeAtom);
|
|
7135
7135
|
let p = null;
|
|
7136
7136
|
const u = o.children.length > 0, { highlightBlock: g, clearHighlight: m } = useBlockHighlight(), { id: h, data: b, isSelected: f, willReceiveDrop: x, isDragging: y, isEditing: B, handleClick: _ } = o, w = (T) => {
|
|
@@ -7157,15 +7157,15 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, drag
|
|
|
7157
7157
|
const T = Object.keys(b), D = [];
|
|
7158
7158
|
for (let $ = 0; $ < T.length; $++)
|
|
7159
7159
|
if (T[$].endsWith("_attrs")) {
|
|
7160
|
-
const
|
|
7160
|
+
const P = b[T[$]], M = Object.keys(P).join("|");
|
|
7161
7161
|
M.match(/x-data/) && D.push("data"), M.match(/x-on/) && D.push("event"), M.match(/x-show|x-if/) && D.push("show");
|
|
7162
7162
|
}
|
|
7163
7163
|
return D;
|
|
7164
7164
|
}, [b]), I = (T, D) => {
|
|
7165
|
-
const $ = d.contentDocument || d.contentWindow.document,
|
|
7166
|
-
|
|
7167
|
-
const M =
|
|
7168
|
-
M.top >= O.top && M.left >= O.left && M.bottom <= O.bottom && M.right <= O.right || ($.documentElement.scrollTop =
|
|
7165
|
+
const $ = d.contentDocument || d.contentWindow.document, P = $.querySelector(`[data-block-id=${T}]`);
|
|
7166
|
+
P && P.setAttribute("data-drop", D);
|
|
7167
|
+
const M = P.getBoundingClientRect(), O = d.getBoundingClientRect();
|
|
7168
|
+
M.top >= O.top && M.left >= O.left && M.bottom <= O.bottom && M.right <= O.right || ($.documentElement.scrollTop = P.offsetTop - O.top);
|
|
7169
7169
|
}, L = (T) => {
|
|
7170
7170
|
k();
|
|
7171
7171
|
const D = get(o, "parent.id");
|
|
@@ -7207,7 +7207,7 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, drag
|
|
|
7207
7207
|
T.preventDefault(), I(h, "no");
|
|
7208
7208
|
},
|
|
7209
7209
|
children: [
|
|
7210
|
-
(o == null ? void 0 : o.rowIndex) > 0 && (o.parent.isOpen && canAddChildBlock(get(o, "parent.data._type")) || ((
|
|
7210
|
+
(o == null ? void 0 : o.rowIndex) > 0 && (o.parent.isOpen && canAddChildBlock(get(o, "parent.data._type")) || ((R = o == null ? void 0 : o.parent) == null ? void 0 : R.id) === "__REACT_ARBORIST_INTERNAL_ROOT__") && /* @__PURE__ */ jsx("div", { className: "group relative ml-5 h-full w-full cursor-pointer", children: /* @__PURE__ */ jsx(
|
|
7211
7211
|
"div",
|
|
7212
7212
|
{
|
|
7213
7213
|
onClick: (T) => {
|
|
@@ -8859,7 +8859,7 @@ export {
|
|
|
8859
8859
|
getClassValueAndUnit,
|
|
8860
8860
|
De as i18n,
|
|
8861
8861
|
cn as mergeClasses,
|
|
8862
|
-
|
|
8862
|
+
Pe as registerChaiBlock,
|
|
8863
8863
|
useAddBlock,
|
|
8864
8864
|
useAddClassesToBlocks,
|
|
8865
8865
|
useAskAi,
|