@chaibuilder/sdk 2.2.21 → 2.2.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core.cjs +3 -3
- package/dist/core.js +200 -197
- package/dist/web-blocks.cjs +1 -3
- package/dist/web-blocks.js +1 -3
- package/package.json +1 -1
package/dist/core.js
CHANGED
|
@@ -799,10 +799,10 @@ const undoRedoStateAtom = atom({
|
|
|
799
799
|
return {
|
|
800
800
|
moveBlocks: (x, y, b) => {
|
|
801
801
|
const v = map(x, (w) => {
|
|
802
|
-
const _ = r.find((N) => N._id === w)._parent || null,
|
|
803
|
-
return { _id: w, oldParent: _, oldPosition:
|
|
804
|
-
}),
|
|
805
|
-
|
|
802
|
+
const _ = r.find((N) => N._id === w)._parent || null, A = r.filter((N) => _ ? N._parent === _ : !N._parent).map((N) => N._id).indexOf(w);
|
|
803
|
+
return { _id: w, oldParent: _, oldPosition: A };
|
|
804
|
+
}), B = v.find(({ _id: w }) => w === x[0]);
|
|
805
|
+
B && B.oldParent === y && B.oldPosition === b || (i(x, y, b), o({
|
|
806
806
|
undo: () => each(v, ({ _id: w, oldParent: E, oldPosition: _ }) => {
|
|
807
807
|
i([w], E, _);
|
|
808
808
|
}),
|
|
@@ -816,8 +816,8 @@ const undoRedoStateAtom = atom({
|
|
|
816
816
|
});
|
|
817
817
|
},
|
|
818
818
|
removeBlocks: (x) => {
|
|
819
|
-
var
|
|
820
|
-
const y = (
|
|
819
|
+
var B;
|
|
820
|
+
const y = (B = first(x)) == null ? void 0 : B._parent, v = r.filter((w) => y ? w._parent === y : !w._parent).indexOf(first(x));
|
|
821
821
|
l(map(x, "_id")), o({
|
|
822
822
|
undo: () => a(x, y, v),
|
|
823
823
|
redo: () => l(map(x, "_id"))
|
|
@@ -826,17 +826,17 @@ const undoRedoStateAtom = atom({
|
|
|
826
826
|
updateBlocks: (x, y, b) => {
|
|
827
827
|
let v = [];
|
|
828
828
|
if (b)
|
|
829
|
-
v = map(x, (
|
|
829
|
+
v = map(x, (B) => ({ _id: B, ...b }));
|
|
830
830
|
else {
|
|
831
|
-
const
|
|
831
|
+
const B = keys(y);
|
|
832
832
|
v = map(x, (w) => {
|
|
833
833
|
const E = r.find((S) => S._id === w), _ = { _id: w };
|
|
834
|
-
return each(
|
|
834
|
+
return each(B, (S) => _[S] = E[S]), _;
|
|
835
835
|
});
|
|
836
836
|
}
|
|
837
|
-
c(map(x, (
|
|
837
|
+
c(map(x, (B) => ({ _id: B, ...y }))), o({
|
|
838
838
|
undo: () => c(v),
|
|
839
|
-
redo: () => c(map(x, (
|
|
839
|
+
redo: () => c(map(x, (B) => ({ _id: B, ...y })))
|
|
840
840
|
});
|
|
841
841
|
},
|
|
842
842
|
updateBlocksRuntime: (x, y) => {
|
|
@@ -851,8 +851,8 @@ const undoRedoStateAtom = atom({
|
|
|
851
851
|
updateMultipleBlocksProps: (x) => {
|
|
852
852
|
let y = [];
|
|
853
853
|
y = map(x, (b) => {
|
|
854
|
-
const v = keys(b),
|
|
855
|
-
return each(v, (E) => w[E] =
|
|
854
|
+
const v = keys(b), B = r.find((E) => E._id === b._id), w = {};
|
|
855
|
+
return each(v, (E) => w[E] = B[E]), w;
|
|
856
856
|
}), c(x), o({
|
|
857
857
|
undo: () => c(y),
|
|
858
858
|
redo: () => c(x)
|
|
@@ -2341,8 +2341,8 @@ const getBlockWithChildren = (o, r) => {
|
|
|
2341
2341
|
for (const y in x) {
|
|
2342
2342
|
const b = x[y];
|
|
2343
2343
|
if (typeof b == "string" && startsWith(b, STYLES_KEY)) {
|
|
2344
|
-
const { baseClasses: v, classes:
|
|
2345
|
-
x[y] = compact(flattenDeep([v,
|
|
2344
|
+
const { baseClasses: v, classes: B } = getSplitChaiClasses(b);
|
|
2345
|
+
x[y] = compact(flattenDeep([v, B])).join(" ");
|
|
2346
2346
|
} else
|
|
2347
2347
|
y !== "_id" && delete x[y];
|
|
2348
2348
|
}
|
|
@@ -2354,21 +2354,21 @@ const getBlockWithChildren = (o, r) => {
|
|
|
2354
2354
|
if (l) {
|
|
2355
2355
|
r(!0), a(null);
|
|
2356
2356
|
try {
|
|
2357
|
-
const b = p === u ? "" : p, v = h === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(f, d)), p) : [g(f, d)],
|
|
2357
|
+
const b = p === u ? "" : p, v = h === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(f, d)), p) : [g(f, d)], B = await l(h, addLangToPrompt(x, m, h), v, b), { blocks: w, error: E } = B;
|
|
2358
2358
|
if (E) {
|
|
2359
2359
|
a(E);
|
|
2360
2360
|
return;
|
|
2361
2361
|
}
|
|
2362
2362
|
if (h === "styles") {
|
|
2363
2363
|
const _ = w.map((S) => {
|
|
2364
|
-
for (const
|
|
2365
|
-
|
|
2364
|
+
for (const A in S)
|
|
2365
|
+
A !== "_id" && (S[A] = `${STYLES_KEY},${S[A]}`);
|
|
2366
2366
|
return S;
|
|
2367
2367
|
});
|
|
2368
2368
|
c(_);
|
|
2369
2369
|
} else
|
|
2370
2370
|
i(w);
|
|
2371
|
-
y && y(
|
|
2371
|
+
y && y(B);
|
|
2372
2372
|
} catch (b) {
|
|
2373
2373
|
a(b);
|
|
2374
2374
|
} finally {
|
|
@@ -2839,7 +2839,7 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span"],
|
|
|
2839
2839
|
pubsub.publish(CHAI_BUILDER_EVENTS.CANVAS_BLOCK_STYLE_SELECTED, { blockId: u, styleId: p, styleProp: d });
|
|
2840
2840
|
} else if (c != null && c.getAttribute("data-block-id")) {
|
|
2841
2841
|
const d = c.getAttribute("data-block-id");
|
|
2842
|
-
pubsub.publish(CHAI_BUILDER_EVENTS.CANVAS_BLOCK_SELECTED,
|
|
2842
|
+
pubsub.publish(CHAI_BUILDER_EVENTS.CANVAS_BLOCK_SELECTED, d === "canvas" ? [] : [d]);
|
|
2843
2843
|
}
|
|
2844
2844
|
r(), n.current = (/* @__PURE__ */ new Date()).getTime();
|
|
2845
2845
|
},
|
|
@@ -3493,16 +3493,16 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
|
|
|
3493
3493
|
var C;
|
|
3494
3494
|
const _ = o._type;
|
|
3495
3495
|
let S = o[n];
|
|
3496
|
-
const
|
|
3497
|
-
return g && ((C =
|
|
3496
|
+
const A = getRegisteredChaiBlock(o._type);
|
|
3497
|
+
return g && ((C = A == null ? void 0 : A.i18nProps) == null ? void 0 : C.includes(n)) && has(o, `${n}-${g}`) && (S = get(o, `${n}-${g}`)), { blockContent: S, blockType: _ };
|
|
3498
3498
|
}, [o, g]), v = useCallback(
|
|
3499
3499
|
(_) => {
|
|
3500
|
-
var
|
|
3501
|
-
const S = _ || ((
|
|
3500
|
+
var A;
|
|
3501
|
+
const S = _ || ((A = p.current) == null ? void 0 : A.innerText);
|
|
3502
3502
|
m([x], { [n]: S }), d(null), i(null), h([]);
|
|
3503
3503
|
},
|
|
3504
3504
|
[x, m, i, h, g]
|
|
3505
|
-
),
|
|
3505
|
+
), B = useDebouncedCallback(
|
|
3506
3506
|
(_) => {
|
|
3507
3507
|
m([x], { [n]: _ });
|
|
3508
3508
|
},
|
|
@@ -3528,7 +3528,7 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
|
|
|
3528
3528
|
{
|
|
3529
3529
|
blockContent: y,
|
|
3530
3530
|
editingElement: c,
|
|
3531
|
-
onChange:
|
|
3531
|
+
onChange: B,
|
|
3532
3532
|
onClose: v,
|
|
3533
3533
|
onEscape: w
|
|
3534
3534
|
}
|
|
@@ -3539,7 +3539,7 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
|
|
|
3539
3539
|
blockContent: y,
|
|
3540
3540
|
editingElement: c,
|
|
3541
3541
|
onClose: v,
|
|
3542
|
-
onChange:
|
|
3542
|
+
onChange: B,
|
|
3543
3543
|
onEscape: w
|
|
3544
3544
|
}
|
|
3545
3545
|
)) : null, [c, x, b, y, v, g]);
|
|
@@ -3586,7 +3586,7 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
|
|
|
3586
3586
|
), b = useMemo(() => getBlockTagAttributes(l), [l, getBlockTagAttributes]), v = useMemo(
|
|
3587
3587
|
() => p(l._id, getBlockRuntimeProps(l._type)),
|
|
3588
3588
|
[l._id, l._type, p, getBlockRuntimeProps]
|
|
3589
|
-
),
|
|
3589
|
+
), B = useMemo(
|
|
3590
3590
|
() => ({
|
|
3591
3591
|
blockProps: { "data-block-id": l._id, "data-block-type": l._type },
|
|
3592
3592
|
inBuilder: !0,
|
|
@@ -3609,7 +3609,7 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
|
|
|
3609
3609
|
), w = useMemo(() => !CORE_BLOCKS.includes(l._type), [l._type]);
|
|
3610
3610
|
if (isNull(h) || m.includes(l._id)) return null;
|
|
3611
3611
|
let E = /* @__PURE__ */ jsx(Suspense, { children: createElement(h, {
|
|
3612
|
-
...
|
|
3612
|
+
...B,
|
|
3613
3613
|
children: n({
|
|
3614
3614
|
_id: l._id,
|
|
3615
3615
|
_type: l._type,
|
|
@@ -3697,13 +3697,11 @@ const CanvasEventsWatcher = () => {
|
|
|
3697
3697
|
}
|
|
3698
3698
|
}, 100);
|
|
3699
3699
|
}, [a, i, n, r]), useEffect(() => () => l(), [l]), usePubSub(CHAI_BUILDER_EVENTS.CANVAS_BLOCK_SELECTED, (d) => {
|
|
3700
|
-
|
|
3701
|
-
const { blockId: p } = d;
|
|
3702
|
-
i.includes(p) || c == null || c.closeAll(), o([p]);
|
|
3700
|
+
d && (!isEmpty(d) && !includes(i, first(d)) && (c == null || c.closeAll()), o(d));
|
|
3703
3701
|
}), usePubSub(CHAI_BUILDER_EVENTS.CANVAS_BLOCK_STYLE_SELECTED, (d) => {
|
|
3704
3702
|
if (!d) return;
|
|
3705
3703
|
const { blockId: p, styleId: u, styleProp: m } = d;
|
|
3706
|
-
p && (
|
|
3704
|
+
p && (includes(i, p) || c == null || c.closeAll(), n([{ id: u, prop: m, blockId: p }]), o([p]));
|
|
3707
3705
|
}), usePubSub(CHAI_BUILDER_EVENTS.CLEAR_CANVAS_SELECTION, () => {
|
|
3708
3706
|
l(), o([]), n([]);
|
|
3709
3707
|
}), null;
|
|
@@ -4059,11 +4057,11 @@ const DataBindingSelector = ({
|
|
|
4059
4057
|
r(`{{${m}}}`, {}, n);
|
|
4060
4058
|
return;
|
|
4061
4059
|
}
|
|
4062
|
-
const h = (b) => /[.,!?;:]/.test(b), f = (b, v,
|
|
4060
|
+
const h = (b) => /[.,!?;:]/.test(b), f = (b, v, B) => {
|
|
4063
4061
|
let w = "", E = "";
|
|
4064
4062
|
const _ = v > 0 ? b[v - 1] : "", S = v < b.length ? b[v] : "";
|
|
4065
4063
|
return v > 0 && (_ === "." || !h(_) && _ !== " ") && (w = " "), v < b.length && !h(S) && S !== " " && (E = " "), {
|
|
4066
|
-
text: w +
|
|
4064
|
+
text: w + B + E,
|
|
4067
4065
|
prefixLength: w.length,
|
|
4068
4066
|
suffixLength: E.length
|
|
4069
4067
|
};
|
|
@@ -4075,13 +4073,13 @@ const DataBindingSelector = ({
|
|
|
4075
4073
|
if (b) {
|
|
4076
4074
|
const v = `{{${m}}}`;
|
|
4077
4075
|
b.commands.focus();
|
|
4078
|
-
const { from:
|
|
4079
|
-
if (
|
|
4076
|
+
const { from: B, to: w } = b.state.selection;
|
|
4077
|
+
if (B !== w)
|
|
4080
4078
|
b.chain().deleteSelection().insertContent(v).run();
|
|
4081
4079
|
else {
|
|
4082
|
-
const { state: _ } = b, S = _.selection.from,
|
|
4080
|
+
const { state: _ } = b, S = _.selection.from, A = _.doc.textBetween(Math.max(0, S - 1), S), N = _.doc.textBetween(S, Math.min(S + 1, _.doc.content.size));
|
|
4083
4081
|
let C = "";
|
|
4084
|
-
S > 0 &&
|
|
4082
|
+
S > 0 && A !== " " && !h(A) && (C = " ");
|
|
4085
4083
|
let k = "";
|
|
4086
4084
|
N && N !== " " && !h(N) && (k = " "), b.chain().insertContent(C + v + k).run();
|
|
4087
4085
|
}
|
|
@@ -4089,14 +4087,14 @@ const DataBindingSelector = ({
|
|
|
4089
4087
|
return;
|
|
4090
4088
|
}
|
|
4091
4089
|
} else {
|
|
4092
|
-
const b = x, v = b.selectionStart || 0,
|
|
4090
|
+
const b = x, v = b.selectionStart || 0, B = b.value || "", w = b.selectionEnd || v;
|
|
4093
4091
|
if (w > v) {
|
|
4094
|
-
const N = `{{${m}}}`, { text: C } = f(
|
|
4092
|
+
const N = `{{${m}}}`, { text: C } = f(B, v, N), k = B.slice(0, v) + C + B.slice(w);
|
|
4095
4093
|
r(k, {}, n);
|
|
4096
4094
|
return;
|
|
4097
4095
|
}
|
|
4098
|
-
const _ = `{{${m}}}`, { text: S } = f(
|
|
4099
|
-
r(
|
|
4096
|
+
const _ = `{{${m}}}`, { text: S } = f(B, v, _), A = B.slice(0, v) + S + B.slice(v);
|
|
4097
|
+
r(A, {}, n);
|
|
4100
4098
|
}
|
|
4101
4099
|
},
|
|
4102
4100
|
[n, r, a, c == null ? void 0 : c._id, d]
|
|
@@ -4118,7 +4116,7 @@ const DataBindingSelector = ({
|
|
|
4118
4116
|
onChange: n
|
|
4119
4117
|
}) => {
|
|
4120
4118
|
var N;
|
|
4121
|
-
const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (C, k) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, m] = useState("page"), [g, h] = useState(""), [f, x] = useState([]), [y, b] = useState(-1), v = useRef(null),
|
|
4119
|
+
const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (C, k) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, m] = useState("page"), [g, h] = useState(""), [f, x] = useState([]), [y, b] = useState(-1), v = useRef(null), B = (N = r == null ? void 0 : r.find((C) => C.key === u)) == null ? void 0 : N.name;
|
|
4122
4120
|
useEffect(() => {
|
|
4123
4121
|
if (h(""), x([]), b(-1), p(!1), !o || i || !startsWith(o, "pageType:")) return;
|
|
4124
4122
|
const C = split(o, ":"), k = get(C, 1, "page") || "page";
|
|
@@ -4167,7 +4165,7 @@ const DataBindingSelector = ({
|
|
|
4167
4165
|
}, [y]);
|
|
4168
4166
|
const S = () => {
|
|
4169
4167
|
h(""), x([]), b(-1), p(!1), n("");
|
|
4170
|
-
},
|
|
4168
|
+
}, A = (C) => {
|
|
4171
4169
|
h(C), p(!isEmpty(C)), c(!0), w(C);
|
|
4172
4170
|
};
|
|
4173
4171
|
return /* @__PURE__ */ jsxs("div", { children: [
|
|
@@ -4178,9 +4176,9 @@ const DataBindingSelector = ({
|
|
|
4178
4176
|
{
|
|
4179
4177
|
type: "text",
|
|
4180
4178
|
value: g,
|
|
4181
|
-
onChange: (C) =>
|
|
4179
|
+
onChange: (C) => A(C.target.value),
|
|
4182
4180
|
onKeyDown: _,
|
|
4183
|
-
placeholder: a(`Search ${
|
|
4181
|
+
placeholder: a(`Search ${B ?? ""}`),
|
|
4184
4182
|
className: "w-full rounded-md border border-gray-300 p-2 pr-16"
|
|
4185
4183
|
}
|
|
4186
4184
|
),
|
|
@@ -4513,9 +4511,9 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
4513
4511
|
if (f !== x)
|
|
4514
4512
|
u.chain().deleteSelection().insertContent(h).run();
|
|
4515
4513
|
else {
|
|
4516
|
-
const { state: b } = u, v = b.selection.from,
|
|
4514
|
+
const { state: b } = u, v = b.selection.from, B = b.doc.textBetween(Math.max(0, v - 1), v), w = b.doc.textBetween(v, Math.min(v + 1, b.doc.content.size));
|
|
4517
4515
|
let E = "";
|
|
4518
|
-
v > 0 &&
|
|
4516
|
+
v > 0 && B !== " " && !/[.,!?;:]/.test(B) && (E = " ");
|
|
4519
4517
|
let _ = "";
|
|
4520
4518
|
w && w !== " " && !/[.,!?;:]/.test(w) && (_ = " "), u.chain().insertContent(E + h + _).run();
|
|
4521
4519
|
}
|
|
@@ -4818,9 +4816,9 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
4818
4816
|
const { selectedLang: h, fallbackLang: f, languages: x } = useLanguages(), y = useMemo(
|
|
4819
4817
|
() => isEmpty(x) ? "" : isEmpty(h) ? f : h,
|
|
4820
4818
|
[x, h, f]
|
|
4821
|
-
), b = useMemo(() => get(LANGUAGES, y, y), [y]), v = usePageExternalData(),
|
|
4822
|
-
() => get(w, [
|
|
4823
|
-
[w,
|
|
4819
|
+
), b = useMemo(() => get(LANGUAGES, y, y), [y]), v = usePageExternalData(), B = useSelectedBlock(), w = useRegisteredChaiBlocks(), E = useMemo(
|
|
4820
|
+
() => get(w, [B == null ? void 0 : B._type, "i18nProps"], []),
|
|
4821
|
+
[w, B == null ? void 0 : B._type]
|
|
4824
4822
|
), [_, S] = useState(null);
|
|
4825
4823
|
if (d)
|
|
4826
4824
|
return null;
|
|
@@ -4942,31 +4940,36 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
4942
4940
|
}), a;
|
|
4943
4941
|
};
|
|
4944
4942
|
function BlockSettings() {
|
|
4945
|
-
const { selectedLang: o } = useLanguages(), r = useSelectedBlock(), n = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), l = getRegisteredChaiBlock(r == null ? void 0 : r._type), i = formDataWithSelectedLang(r, o, l), [c, d] = useState(i), [p, u] = useState(!1), m = useWrapperBlock(), g = getRegisteredChaiBlock(m == null ? void 0 : m._type), h = formDataWithSelectedLang(m, o, g), f = ({ formData: _ }, S,
|
|
4946
|
-
S && (c == null ? void 0 : c._id) === r._id && a([r._id], { [S]: get(_, S) },
|
|
4943
|
+
const { selectedLang: o } = useLanguages(), r = useSelectedBlock(), n = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), l = getRegisteredChaiBlock(r == null ? void 0 : r._type), i = formDataWithSelectedLang(r, o, l), [c, d] = useState(i), [p, u] = useState(!1), m = useWrapperBlock(), g = getRegisteredChaiBlock(m == null ? void 0 : m._type), h = formDataWithSelectedLang(m, o, g), f = ({ formData: _ }, S, A) => {
|
|
4944
|
+
S && (c == null ? void 0 : c._id) === r._id && a([r._id], { [S]: get(_, S) }, A);
|
|
4947
4945
|
}, x = useCallback(
|
|
4948
|
-
debounce(({ formData: _ }, S,
|
|
4949
|
-
f({ formData: _ }, S,
|
|
4946
|
+
debounce(({ formData: _ }, S, A) => {
|
|
4947
|
+
f({ formData: _ }, S, A), d(_);
|
|
4950
4948
|
}, 1500),
|
|
4951
4949
|
[r == null ? void 0 : r._id, o]
|
|
4952
4950
|
), y = ({ formData: _ }, S) => {
|
|
4953
4951
|
S && (n([r._id], { [S]: get(_, S) }), x({ formData: _ }, S, { [S]: get(c, S) }));
|
|
4954
4952
|
}, b = ({ formData: _ }, S) => {
|
|
4955
4953
|
S && (n([m._id], { [S]: get(_, S) }), x({ formData: _ }, S, { [S]: get(c, S) }));
|
|
4956
|
-
}, { schema: v, uiSchema:
|
|
4954
|
+
}, { schema: v, uiSchema: B } = useMemo(() => {
|
|
4957
4955
|
const _ = r == null ? void 0 : r._type;
|
|
4958
4956
|
if (!_)
|
|
4959
4957
|
return { schema: {}, uiSchema: {} };
|
|
4960
4958
|
try {
|
|
4961
|
-
|
|
4959
|
+
const { schema: S, uiSchema: A } = getBlockFormSchemas(_);
|
|
4960
|
+
if (_ === "Repeater") {
|
|
4961
|
+
const N = get(r, "repeaterItems", "");
|
|
4962
|
+
startsWith(N, `{{${COLLECTION_PREFIX}`) ? (set(A, "filter", { "ui:widget": "collectionSelect" }), set(A, "sort", { "ui:widget": "collectionSelect" })) : (set(A, "filter", { "ui:widget": "hidden" }), set(A, "sort", { "ui:widget": "hidden" }));
|
|
4963
|
+
}
|
|
4964
|
+
return { schema: S, uiSchema: A };
|
|
4962
4965
|
} catch {
|
|
4963
4966
|
return { schema: {}, uiSchema: {} };
|
|
4964
4967
|
}
|
|
4965
4968
|
}, [r]), { wrapperSchema: w, wrapperUiSchema: E } = useMemo(() => {
|
|
4966
4969
|
if (!m || !(m != null && m._type))
|
|
4967
4970
|
return { wrapperSchema: {}, wrapperUiSchema: {} };
|
|
4968
|
-
const _ = m == null ? void 0 : m._type, { schema: S = {}, uiSchema:
|
|
4969
|
-
return { wrapperSchema: S, wrapperUiSchema:
|
|
4971
|
+
const _ = m == null ? void 0 : m._type, { schema: S = {}, uiSchema: A = {} } = getBlockFormSchemas(_);
|
|
4972
|
+
return { wrapperSchema: S, wrapperUiSchema: A };
|
|
4970
4973
|
}, [m]);
|
|
4971
4974
|
return /* @__PURE__ */ jsxs("div", { className: "no-scrollbar overflow-x-hidden px-px", children: [
|
|
4972
4975
|
!isEmpty(m) && /* @__PURE__ */ jsxs("div", { className: "mb-4 rounded border bg-zinc-100 px-1", children: [
|
|
@@ -5006,7 +5009,7 @@ function BlockSettings() {
|
|
|
5006
5009
|
onChange: y,
|
|
5007
5010
|
formData: i,
|
|
5008
5011
|
schema: v,
|
|
5009
|
-
uiSchema:
|
|
5012
|
+
uiSchema: B
|
|
5010
5013
|
}
|
|
5011
5014
|
)
|
|
5012
5015
|
] });
|
|
@@ -5183,7 +5186,7 @@ const BlockStylingProps = () => {
|
|
|
5183
5186
|
},
|
|
5184
5187
|
a
|
|
5185
5188
|
)) }), THROTTLE_TIME = 50, AdvanceChoices = (o) => {
|
|
5186
|
-
const [r, n] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: m } = o, [g, h] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [f, x] = useState(!1), [y, b] = useState(""), [v,
|
|
5189
|
+
const [r, n] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: m } = o, [g, h] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [f, x] = useState(!1), [y, b] = useState(""), [v, B] = useState(!1), [w, E] = useState(!1);
|
|
5187
5190
|
useEffect(() => {
|
|
5188
5191
|
const { value: C, unit: k } = getClassValueAndUnit(i);
|
|
5189
5192
|
if (k === "") {
|
|
@@ -5192,7 +5195,7 @@ const BlockStylingProps = () => {
|
|
|
5192
5195
|
}
|
|
5193
5196
|
h(k), l(k === "class" || isEmpty(C) ? "" : C);
|
|
5194
5197
|
}, [i, p, u]);
|
|
5195
|
-
const _ = useThrottledCallback((C) => c(C), [c], THROTTLE_TIME), S = useThrottledCallback((C) => c(C, !1), [c], THROTTLE_TIME),
|
|
5198
|
+
const _ = useThrottledCallback((C) => c(C), [c], THROTTLE_TIME), S = useThrottledCallback((C) => c(C, !1), [c], THROTTLE_TIME), A = useCallback(
|
|
5196
5199
|
(C = !1) => {
|
|
5197
5200
|
const k = getUserInputValues(`${a}`, u);
|
|
5198
5201
|
if (get(k, "error", !1)) {
|
|
@@ -5248,7 +5251,7 @@ const BlockStylingProps = () => {
|
|
|
5248
5251
|
{
|
|
5249
5252
|
readOnly: g === "class",
|
|
5250
5253
|
onKeyPress: (C) => {
|
|
5251
|
-
C.key === "Enter" &&
|
|
5254
|
+
C.key === "Enter" && A();
|
|
5252
5255
|
},
|
|
5253
5256
|
onKeyDown: (C) => {
|
|
5254
5257
|
if (C.keyCode !== 38 && C.keyCode !== 40)
|
|
@@ -5263,7 +5266,7 @@ const BlockStylingProps = () => {
|
|
|
5263
5266
|
onKeyUp: (C) => {
|
|
5264
5267
|
w && (C.preventDefault(), E(!1));
|
|
5265
5268
|
},
|
|
5266
|
-
onBlur: () =>
|
|
5269
|
+
onBlur: () => A(),
|
|
5267
5270
|
onChange: (C) => {
|
|
5268
5271
|
x(!1), l(C.target.value);
|
|
5269
5272
|
},
|
|
@@ -5306,9 +5309,9 @@ const BlockStylingProps = () => {
|
|
|
5306
5309
|
["none", "auto"].indexOf(g) !== -1 || v ? null : /* @__PURE__ */ jsx(
|
|
5307
5310
|
DragStyleButton,
|
|
5308
5311
|
{
|
|
5309
|
-
onDragStart: () =>
|
|
5312
|
+
onDragStart: () => B(!0),
|
|
5310
5313
|
onDragEnd: (C) => {
|
|
5311
|
-
if (b(() => ""),
|
|
5314
|
+
if (b(() => ""), B(!1), isEmpty(C))
|
|
5312
5315
|
return;
|
|
5313
5316
|
const k = `${C}`, T = `${k.startsWith("-") ? "-" : ""}${d}[${k.replace("-", "")}${g === "-" ? "" : g}]`;
|
|
5314
5317
|
_(T);
|
|
@@ -5782,19 +5785,19 @@ const COLOR_PROP = {
|
|
|
5782
5785
|
}, getBreakpoint = (o) => `${o.toUpperCase()} ${BREAKPOINTS[o] ? `(${BREAKPOINTS[o]} & up)` : ""}`, BlockStyle = (o) => {
|
|
5783
5786
|
const { t: r } = useTranslation(), { type: n = "icons", label: a, property: l, onEmitChange: i = () => {
|
|
5784
5787
|
}, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, m] = useScreenSizeWidth(), g = useCurrentClassByProperty(l), h = useAddClassesToBlocks(), f = useRemoveClassesFromBlocks(), [x] = useSelectedBlockIds(), y = useMemo(() => get(g, "fullCls", ""), [g]), b = useCallback(
|
|
5785
|
-
(S,
|
|
5788
|
+
(S, A = !0) => {
|
|
5786
5789
|
const N = { dark: p, mq: m, mod: u, cls: S, property: l, fullCls: "" };
|
|
5787
5790
|
(p || u !== "") && (N.mq = "xs");
|
|
5788
5791
|
const C = generateFullClsName(N);
|
|
5789
|
-
h(x, [C],
|
|
5792
|
+
h(x, [C], A);
|
|
5790
5793
|
},
|
|
5791
5794
|
[x, p, m, u, l, h]
|
|
5792
5795
|
), v = useCallback(() => {
|
|
5793
5796
|
f(x, [y], !0);
|
|
5794
|
-
}, [x, y, f]),
|
|
5797
|
+
}, [x, y, f]), B = useMemo(() => canChangeClass(g, m), [g, m]);
|
|
5795
5798
|
useEffect(() => {
|
|
5796
|
-
i(
|
|
5797
|
-
}, [
|
|
5799
|
+
i(B, g);
|
|
5800
|
+
}, [B, i, g]);
|
|
5798
5801
|
const [, , w] = useScreenSizeWidth(), E = useCallback(
|
|
5799
5802
|
(S) => {
|
|
5800
5803
|
w({
|
|
@@ -5808,7 +5811,7 @@ const COLOR_PROP = {
|
|
|
5808
5811
|
},
|
|
5809
5812
|
[w]
|
|
5810
5813
|
), _ = get(g, "dark", null) === p && get(g, "mod", null) === u && get(g, "mq", null) === m;
|
|
5811
|
-
return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange:
|
|
5814
|
+
return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange: B, canReset: g && _, children: /* @__PURE__ */ jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
|
|
5812
5815
|
/* @__PURE__ */ jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsx("span", { className: `text-[11px] ${g && !_ ? "text-foreground" : ""}`, children: r(a) }) }),
|
|
5813
5816
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-row items-center", children: [
|
|
5814
5817
|
/* @__PURE__ */ jsxs("div", { className: "w-[150px]", children: [
|
|
@@ -5828,7 +5831,7 @@ const COLOR_PROP = {
|
|
|
5828
5831
|
n === "color" && /* @__PURE__ */ jsx(ColorChoice, { property: l, onChange: b }),
|
|
5829
5832
|
n === "dropdown" && /* @__PURE__ */ jsx(DropDownChoices, { label: a, property: l, onChange: b })
|
|
5830
5833
|
] }),
|
|
5831
|
-
/* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${y ? "visible" : "invisible"}`, children: _ ? /* @__PURE__ */ jsx("button", { type: "button", onClick: () => v(), title: "Reset", className: "flex px-1.5 text-xs", children: /* @__PURE__ */ jsx(CrossCircledIcon, { className: "h-5 w-5 text-blue-500 hover:opacity-80" }) }) :
|
|
5834
|
+
/* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${y ? "visible" : "invisible"}`, children: _ ? /* @__PURE__ */ jsx("button", { type: "button", onClick: () => v(), title: "Reset", className: "flex px-1.5 text-xs", children: /* @__PURE__ */ jsx(CrossCircledIcon, { className: "h-5 w-5 text-blue-500 hover:opacity-80" }) }) : B && g ? /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
|
|
5832
5835
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
|
|
5833
5836
|
"button",
|
|
5834
5837
|
{
|
|
@@ -6229,7 +6232,7 @@ const AskAIStyles = ({ blockId: o }) => {
|
|
|
6229
6232
|
};
|
|
6230
6233
|
function ManualClasses() {
|
|
6231
6234
|
var T;
|
|
6232
|
-
const o = useRef(null), [r, n] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: c } = useTranslation(), [d] = useSelectedStylingBlocks(), p = useSelectedBlock(), u = useAddClassesToBlocks(), m = useRemoveClassesFromBlocks(), [g] = useSelectedBlockIds(), h = useBuilderProp("askAiCallBack", null), [f, x] = useState(""), y = (T = first(d)) == null ? void 0 : T.prop, { classes: b } = getSplitChaiClasses(get(p, y, "")), v = b.split(" ").filter((I) => !isEmpty(I)),
|
|
6235
|
+
const o = useRef(null), [r, n] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: c } = useTranslation(), [d] = useSelectedStylingBlocks(), p = useSelectedBlock(), u = useAddClassesToBlocks(), m = useRemoveClassesFromBlocks(), [g] = useSelectedBlockIds(), h = useBuilderProp("askAiCallBack", null), [f, x] = useState(""), y = (T = first(d)) == null ? void 0 : T.prop, { classes: b } = getSplitChaiClasses(get(p, y, "")), v = b.split(" ").filter((I) => !isEmpty(I)), B = () => {
|
|
6233
6236
|
const I = f.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
|
|
6234
6237
|
u(g, I, !0), x("");
|
|
6235
6238
|
}, [w, E] = useState([]), _ = ({ value: I }) => {
|
|
@@ -6246,7 +6249,7 @@ function ManualClasses() {
|
|
|
6246
6249
|
return E(map(D, "item"));
|
|
6247
6250
|
}, S = () => {
|
|
6248
6251
|
E([]);
|
|
6249
|
-
},
|
|
6252
|
+
}, A = (I) => I.name, N = (I) => /* @__PURE__ */ jsx("div", { className: "rounded-md p-1", children: I.name }), C = useMemo(
|
|
6250
6253
|
() => ({
|
|
6251
6254
|
ref: o,
|
|
6252
6255
|
autoComplete: "off",
|
|
@@ -6261,7 +6264,7 @@ function ManualClasses() {
|
|
|
6261
6264
|
}, 0);
|
|
6262
6265
|
},
|
|
6263
6266
|
onKeyDown: (I) => {
|
|
6264
|
-
I.key === "Enter" && f.trim() !== "" &&
|
|
6267
|
+
I.key === "Enter" && f.trim() !== "" && B();
|
|
6265
6268
|
},
|
|
6266
6269
|
onChange: (I, { newValue: P }) => x(P),
|
|
6267
6270
|
className: "w-full rounded-md text-xs px-2 hover:outline-0 bg-background border-border py-1"
|
|
@@ -6302,7 +6305,7 @@ function ManualClasses() {
|
|
|
6302
6305
|
suggestions: w,
|
|
6303
6306
|
onSuggestionsFetchRequested: _,
|
|
6304
6307
|
onSuggestionsClearRequested: S,
|
|
6305
|
-
getSuggestionValue:
|
|
6308
|
+
getSuggestionValue: A,
|
|
6306
6309
|
renderSuggestion: N,
|
|
6307
6310
|
inputProps: C,
|
|
6308
6311
|
containerProps: {
|
|
@@ -6320,7 +6323,7 @@ function ManualClasses() {
|
|
|
6320
6323
|
{
|
|
6321
6324
|
variant: "outline",
|
|
6322
6325
|
className: "h-6 border-border",
|
|
6323
|
-
onClick:
|
|
6326
|
+
onClick: B,
|
|
6324
6327
|
disabled: f.trim() === "",
|
|
6325
6328
|
size: "sm",
|
|
6326
6329
|
children: /* @__PURE__ */ jsx(PlusIcon, {})
|
|
@@ -6745,7 +6748,7 @@ const CoreBlock = ({
|
|
|
6745
6748
|
}
|
|
6746
6749
|
}
|
|
6747
6750
|
}, traverseNodes = (o, r = null) => flatMapDeep(o, (n) => {
|
|
6748
|
-
var g, h, f, x, y, b, v,
|
|
6751
|
+
var g, h, f, x, y, b, v, B;
|
|
6749
6752
|
if (n.type === "comment") return [];
|
|
6750
6753
|
console.log("node ===>", n);
|
|
6751
6754
|
let a = { _id: generateUUID() };
|
|
@@ -6808,8 +6811,8 @@ const CoreBlock = ({
|
|
|
6808
6811
|
const _ = find(E.children || [], (S) => (S == null ? void 0 : S.tagName) === "svg");
|
|
6809
6812
|
if (_) {
|
|
6810
6813
|
a.icon = stringify([_]);
|
|
6811
|
-
const { height: S, width:
|
|
6812
|
-
a.iconHeight = S, a.iconWidth =
|
|
6814
|
+
const { height: S, width: A } = getSvgDimensions(_, "16px", "16px");
|
|
6815
|
+
a.iconHeight = S, a.iconWidth = A;
|
|
6813
6816
|
}
|
|
6814
6817
|
}
|
|
6815
6818
|
return [a];
|
|
@@ -6821,9 +6824,9 @@ const CoreBlock = ({
|
|
|
6821
6824
|
const w = stringify([n]);
|
|
6822
6825
|
return hasVideoEmbed(w) && (set(a, "_type", "Video"), set(a, "url", getVideoURLFromHTML(w)), set(a, "styles", `${STYLES_KEY},`), set(a, "controls", { autoPlay: !1, muted: !0, loop: !1, controls: !1 })), a.content = w, [a];
|
|
6823
6826
|
} else if (n.tagName === "svg") {
|
|
6824
|
-
const w = find(n.attributes, { key: "height" }), E = find(n.attributes, { key: "width" }), _ = get(w, "value") ? `[${get(w, "value")}px]` : "24px", S = get(E, "value") ? `[${get(E, "value")}px]` : "24px",
|
|
6825
|
-
return a.styles = `${STYLES_KEY}, ${cn$2(`w-${S} h-${_}`,
|
|
6826
|
-
} else if (n.tagName == "option" && r && ((
|
|
6827
|
+
const w = find(n.attributes, { key: "height" }), E = find(n.attributes, { key: "width" }), _ = get(w, "value") ? `[${get(w, "value")}px]` : "24px", S = get(E, "value") ? `[${get(E, "value")}px]` : "24px", A = get(find(n.attributes, { key: "class" }), "value", "w-full h-full");
|
|
6828
|
+
return a.styles = `${STYLES_KEY}, ${cn$2(`w-${S} h-${_}`, A)}`.trim(), n.attributes = filter(n.attributes, (N) => !includes(["style", "width", "height", "class"], N.key)), a.icon = stringify([n]), [a];
|
|
6829
|
+
} else if (n.tagName == "option" && r && ((B = r.block) == null ? void 0 : B._type) === "Select")
|
|
6827
6830
|
return r.block.options.push({
|
|
6828
6831
|
label: getTextContent(n.children),
|
|
6829
6832
|
...getAttrs(n)
|
|
@@ -6927,12 +6930,12 @@ const BlockCard = ({
|
|
|
6927
6930
|
parentId: n = void 0,
|
|
6928
6931
|
position: a = -1
|
|
6929
6932
|
}) => {
|
|
6930
|
-
const [l, i] = useState(!1), c = useBuilderProp("getUILibraryBlock", noop), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: m } = useBlockHighlight(), g = get(o, "name", get(o, "label")), h = get(o, "description", ""), f = useFeature("dnd"), [, x] = useAtom$1(draggedBlockAtom), y = (
|
|
6931
|
-
const w = has(
|
|
6932
|
-
return
|
|
6933
|
+
const [l, i] = useState(!1), c = useBuilderProp("getUILibraryBlock", noop), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: m } = useBlockHighlight(), g = get(o, "name", get(o, "label")), h = get(o, "description", ""), f = useFeature("dnd"), [, x] = useAtom$1(draggedBlockAtom), y = (B) => {
|
|
6934
|
+
const w = has(B, "styles_attrs.data-page-section");
|
|
6935
|
+
return B._type === "Box" && w;
|
|
6933
6936
|
}, b = useCallback(
|
|
6934
|
-
async (
|
|
6935
|
-
if (
|
|
6937
|
+
async (B) => {
|
|
6938
|
+
if (B.stopPropagation(), has(o, "component")) {
|
|
6936
6939
|
d(o, n, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
6937
6940
|
return;
|
|
6938
6941
|
}
|
|
@@ -6949,18 +6952,18 @@ const BlockCard = ({
|
|
|
6949
6952
|
onClick: l ? () => {
|
|
6950
6953
|
} : b,
|
|
6951
6954
|
draggable: f ? "true" : "false",
|
|
6952
|
-
onDragStart: async (
|
|
6955
|
+
onDragStart: async (B) => {
|
|
6953
6956
|
const w = await c(r, o);
|
|
6954
6957
|
let E = n;
|
|
6955
6958
|
if (y(first(w)) && (E = null), !isEmpty(w)) {
|
|
6956
6959
|
const _ = { blocks: w, uiLibrary: !0, parent: E };
|
|
6957
|
-
if (
|
|
6960
|
+
if (B.dataTransfer.setData("text/plain", JSON.stringify(_)), o.preview) {
|
|
6958
6961
|
const S = new Image();
|
|
6959
6962
|
S.src = o.preview, S.onload = () => {
|
|
6960
|
-
|
|
6963
|
+
B.dataTransfer.setDragImage(S, 0, 0);
|
|
6961
6964
|
};
|
|
6962
6965
|
} else
|
|
6963
|
-
|
|
6966
|
+
B.dataTransfer.setDragImage(new Image(), 0, 0);
|
|
6964
6967
|
x(_), setTimeout(() => {
|
|
6965
6968
|
u([]), m(), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
6966
6969
|
}, 200);
|
|
@@ -7013,13 +7016,13 @@ const BlockCard = ({
|
|
|
7013
7016
|
return;
|
|
7014
7017
|
}
|
|
7015
7018
|
}, [y, b]);
|
|
7016
|
-
const
|
|
7019
|
+
const B = get(y, b, []), w = useRef(null), { t: E } = useTranslation(), _ = (k) => {
|
|
7017
7020
|
w.current && (clearTimeout(w.current), w.current = null), w.current = setTimeout(() => {
|
|
7018
7021
|
w.current && v(k);
|
|
7019
7022
|
}, 400);
|
|
7020
7023
|
}, S = () => {
|
|
7021
7024
|
i != null && i.id && p(i.id);
|
|
7022
|
-
},
|
|
7025
|
+
}, A = () => {
|
|
7023
7026
|
m("");
|
|
7024
7027
|
};
|
|
7025
7028
|
if (d)
|
|
@@ -7027,7 +7030,7 @@ const BlockCard = ({
|
|
|
7027
7030
|
/* @__PURE__ */ jsx(Skeleton, { className: "col-span-3 h-full" }),
|
|
7028
7031
|
/* @__PURE__ */ jsx(Skeleton, { className: "col-span-9 h-full" })
|
|
7029
7032
|
] });
|
|
7030
|
-
const N = filter(
|
|
7033
|
+
const N = filter(B, (k, j) => j % 2 === 0), C = filter(B, (k, j) => j % 2 === 1);
|
|
7031
7034
|
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", { className: "flex h-full max-h-full flex-col", children: [
|
|
7032
7035
|
/* @__PURE__ */ jsx("div", { className: "flex items-center gap-2 border-border py-2", children: /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
|
|
7033
7036
|
/* @__PURE__ */ jsx(Search, { className: "absolute left-2 top-2.5 h-4 w-4 text-muted-foreground" }),
|
|
@@ -7043,7 +7046,7 @@ const BlockCard = ({
|
|
|
7043
7046
|
u && /* @__PURE__ */ jsx(
|
|
7044
7047
|
"button",
|
|
7045
7048
|
{
|
|
7046
|
-
onClick:
|
|
7049
|
+
onClick: A,
|
|
7047
7050
|
className: "absolute right-2 top-2.5 text-muted-foreground hover:text-foreground",
|
|
7048
7051
|
children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" })
|
|
7049
7052
|
}
|
|
@@ -7087,7 +7090,7 @@ const BlockCard = ({
|
|
|
7087
7090
|
onMouseEnter: () => w.current ? clearTimeout(w.current) : null,
|
|
7088
7091
|
className: "z-10 flex h-full max-h-full w-full flex-col gap-2 transition-all ease-linear",
|
|
7089
7092
|
children: [
|
|
7090
|
-
isEmpty(
|
|
7093
|
+
isEmpty(B) && !isEmpty(y) ? /* @__PURE__ */ jsx("div", { className: "flex h-full flex-col items-center justify-center p-6 text-center", children: /* @__PURE__ */ jsx("p", { className: "text-sm", children: E("No blocks found in this group") }) }) : /* @__PURE__ */ jsxs("div", { className: "grid w-full grid-cols-2 gap-2 px-2", children: [
|
|
7091
7094
|
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: N.map((k, j) => /* @__PURE__ */ jsx(
|
|
7092
7095
|
BlockCard,
|
|
7093
7096
|
{
|
|
@@ -7143,14 +7146,14 @@ const BlockCard = ({
|
|
|
7143
7146
|
}), m(!0);
|
|
7144
7147
|
else if (!l && Object.keys(a || {}).length > 0) {
|
|
7145
7148
|
const h = Object.entries(a).map(([x, y]) => {
|
|
7146
|
-
const b = y, v = b.type || "partial",
|
|
7149
|
+
const b = y, v = b.type || "partial", B = formatReadableName(v);
|
|
7147
7150
|
return {
|
|
7148
7151
|
type: "PartialBlock",
|
|
7149
7152
|
// Set the type to PartialBlock
|
|
7150
7153
|
label: formatReadableName(b.name || x),
|
|
7151
7154
|
description: b.description || "",
|
|
7152
7155
|
icon: Globe,
|
|
7153
|
-
group:
|
|
7156
|
+
group: B,
|
|
7154
7157
|
// Use formatted type as group
|
|
7155
7158
|
category: "partial",
|
|
7156
7159
|
partialBlockId: x,
|
|
@@ -7222,7 +7225,7 @@ const BlockCard = ({
|
|
|
7222
7225
|
}), []);
|
|
7223
7226
|
const v = useCallback((k) => {
|
|
7224
7227
|
y(k), b.current && b.current(k);
|
|
7225
|
-
}, []),
|
|
7228
|
+
}, []), B = useCallback(() => {
|
|
7226
7229
|
y(null), b.current && b.current.cancel();
|
|
7227
7230
|
}, []), w = useCallback((k) => {
|
|
7228
7231
|
b.current && b.current.cancel(), f(k), y(null);
|
|
@@ -7242,7 +7245,7 @@ const BlockCard = ({
|
|
|
7242
7245
|
), S = useMemo(
|
|
7243
7246
|
() => sortBy(_, (k) => CORE_GROUPS.indexOf(k) === -1 ? 99 : CORE_GROUPS.indexOf(k)),
|
|
7244
7247
|
[_]
|
|
7245
|
-
),
|
|
7248
|
+
), A = useMemo(() => h === "all" ? E : filter(values(E), { group: h }), [E, h]), N = useMemo(() => h === "all" ? S : [h], [S, h]);
|
|
7246
7249
|
return /* @__PURE__ */ jsxs("div", { className: "mx-auto flex h-full w-full max-w-3xl flex-col", children: [
|
|
7247
7250
|
/* @__PURE__ */ jsx("div", { className: "sticky top-0 z-10 bg-background/80 px-4 py-2 backdrop-blur-sm", children: /* @__PURE__ */ jsx(
|
|
7248
7251
|
Input$1,
|
|
@@ -7262,7 +7265,7 @@ const BlockCard = ({
|
|
|
7262
7265
|
{
|
|
7263
7266
|
onClick: () => w("all"),
|
|
7264
7267
|
onMouseEnter: () => v("all"),
|
|
7265
|
-
onMouseLeave:
|
|
7268
|
+
onMouseLeave: B,
|
|
7266
7269
|
className: `w-full rounded-md px-2 py-1.5 text-left text-sm font-medium ${h === "all" || x === "all" ? "bg-primary text-primary-foreground" : "hover:bg-primary/50 hover:text-primary-foreground"}`,
|
|
7267
7270
|
children: i("All")
|
|
7268
7271
|
},
|
|
@@ -7273,7 +7276,7 @@ const BlockCard = ({
|
|
|
7273
7276
|
{
|
|
7274
7277
|
onClick: () => w(k),
|
|
7275
7278
|
onMouseEnter: () => v(k),
|
|
7276
|
-
onMouseLeave:
|
|
7279
|
+
onMouseLeave: B,
|
|
7277
7280
|
className: `w-full rounded-md px-2 py-1.5 text-left text-sm ${h === k || x === k ? "bg-primary text-primary-foreground" : "hover:bg-primary/50 hover:text-primary-foreground"}`,
|
|
7278
7281
|
children: capitalize(i(k.toLowerCase()))
|
|
7279
7282
|
},
|
|
@@ -7288,7 +7291,7 @@ const BlockCard = ({
|
|
|
7288
7291
|
] }) }) : /* @__PURE__ */ jsx("div", { className: "space-y-6 p-4", children: N.map((k) => /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
7289
7292
|
/* @__PURE__ */ jsx("h3", { className: "px-1 text-sm font-medium", children: capitalize(i(k.toLowerCase())) }),
|
|
7290
7293
|
/* @__PURE__ */ jsx("div", { className: "grid gap-2 " + l, children: reject(
|
|
7291
|
-
h === "all" ? filter(values(
|
|
7294
|
+
h === "all" ? filter(values(A), { group: k }) : values(A),
|
|
7292
7295
|
{ hidden: !0 }
|
|
7293
7296
|
).map((j) => /* @__PURE__ */ jsx(
|
|
7294
7297
|
CoreBlock,
|
|
@@ -7650,19 +7653,19 @@ const Input = ({ node: o }) => {
|
|
|
7650
7653
|
var P;
|
|
7651
7654
|
const { t: a } = useTranslation(), [l, , i] = useHiddenBlockIds(), [c] = useAtom$1(canvasIframeAtom), { hasPermission: d } = usePermissions();
|
|
7652
7655
|
let p = null;
|
|
7653
|
-
const u = o.children.length > 0, { highlightBlock: m, clearHighlight: g } = useBlockHighlight(), { id: h, data: f, isSelected: x, willReceiveDrop: y, isDragging: b, isEditing: v, handleClick:
|
|
7656
|
+
const u = o.children.length > 0, { highlightBlock: m, clearHighlight: g } = useBlockHighlight(), { id: h, data: f, isSelected: x, willReceiveDrop: y, isDragging: b, isEditing: v, handleClick: B } = o, w = (L) => {
|
|
7654
7657
|
L.stopPropagation(), !l.includes(h) && o.toggle();
|
|
7655
7658
|
}, E = (L) => {
|
|
7656
7659
|
L.isInternal && (p = L.isOpen, L.isOpen && L.close());
|
|
7657
7660
|
}, _ = (L) => {
|
|
7658
7661
|
L.isInternal && p !== null && (p ? L.open() : L.close(), p = null);
|
|
7659
|
-
}, [S,
|
|
7662
|
+
}, [S, A] = useAtom$1(currentAddSelection), N = () => {
|
|
7660
7663
|
var L;
|
|
7661
|
-
C(), o.parent.isSelected ||
|
|
7664
|
+
C(), o.parent.isSelected || A((L = o == null ? void 0 : o.parent) == null ? void 0 : L.id);
|
|
7662
7665
|
}, C = () => {
|
|
7663
|
-
|
|
7666
|
+
A(null);
|
|
7664
7667
|
}, k = (L) => {
|
|
7665
|
-
C(), L.stopPropagation(), !o.isOpen && !l.includes(h) && o.toggle(),
|
|
7668
|
+
C(), L.stopPropagation(), !o.isOpen && !l.includes(h) && o.toggle(), B(L);
|
|
7666
7669
|
};
|
|
7667
7670
|
useEffect(() => {
|
|
7668
7671
|
const L = setTimeout(() => {
|
|
@@ -8072,19 +8075,19 @@ const Input = ({ node: o }) => {
|
|
|
8072
8075
|
const [r] = useDarkMode(), [n, a] = React.useState(""), l = useBuilderProp("themePresets", []), i = useBuilderProp("themePanelComponent", null), { hasPermission: c } = usePermissions(), [d, p] = useTheme(), u = useThemeOptions(), { t: m } = useTranslation(), g = (v) => {
|
|
8073
8076
|
a(v);
|
|
8074
8077
|
}, h = () => {
|
|
8075
|
-
const v = l.find((
|
|
8078
|
+
const v = l.find((B) => Object.keys(B)[0] === n);
|
|
8076
8079
|
if (v) {
|
|
8077
|
-
const
|
|
8078
|
-
|
|
8080
|
+
const B = Object.values(v)[0];
|
|
8081
|
+
B && typeof B == "object" && "fontFamily" in B && "borderRadius" in B && "colors" in B ? p(B) : console.error("Invalid preset structure:", B);
|
|
8079
8082
|
} else
|
|
8080
8083
|
console.error("Preset not found:", n);
|
|
8081
8084
|
}, f = useDebouncedCallback(
|
|
8082
|
-
(v,
|
|
8085
|
+
(v, B) => {
|
|
8083
8086
|
p(() => ({
|
|
8084
8087
|
...d,
|
|
8085
8088
|
fontFamily: {
|
|
8086
8089
|
...d.fontFamily,
|
|
8087
|
-
[v.replace(/font-/g, "")]:
|
|
8090
|
+
[v.replace(/font-/g, "")]: B
|
|
8088
8091
|
}
|
|
8089
8092
|
}));
|
|
8090
8093
|
},
|
|
@@ -8100,10 +8103,10 @@ const Input = ({ node: o }) => {
|
|
|
8100
8103
|
[d],
|
|
8101
8104
|
200
|
|
8102
8105
|
), y = useDebouncedCallback(
|
|
8103
|
-
(v,
|
|
8106
|
+
(v, B) => {
|
|
8104
8107
|
p(() => {
|
|
8105
8108
|
const w = get(d, `colors.${v}`);
|
|
8106
|
-
return r ? set(w, 1,
|
|
8109
|
+
return r ? set(w, 1, B) : set(w, 0, B), {
|
|
8107
8110
|
...d,
|
|
8108
8111
|
colors: {
|
|
8109
8112
|
...d.colors,
|
|
@@ -8114,18 +8117,18 @@ const Input = ({ node: o }) => {
|
|
|
8114
8117
|
},
|
|
8115
8118
|
[d],
|
|
8116
8119
|
200
|
|
8117
|
-
), b = (v) => /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1", children: Object.entries(v.items).map(([
|
|
8118
|
-
const w = get(d, `colors.${
|
|
8120
|
+
), b = (v) => /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1", children: Object.entries(v.items).map(([B]) => {
|
|
8121
|
+
const w = get(d, `colors.${B}.${r ? 1 : 0}`);
|
|
8119
8122
|
return /* @__PURE__ */ jsxs("div", { className: "mt-1 flex items-center gap-x-2", children: [
|
|
8120
8123
|
/* @__PURE__ */ jsx(
|
|
8121
8124
|
ColorPickerInput,
|
|
8122
8125
|
{
|
|
8123
8126
|
value: w,
|
|
8124
|
-
onChange: (E) => y(
|
|
8127
|
+
onChange: (E) => y(B, E)
|
|
8125
8128
|
}
|
|
8126
8129
|
),
|
|
8127
|
-
/* @__PURE__ */ jsx(Label, { className: "text-xs font-normal leading-tight", children:
|
|
8128
|
-
] },
|
|
8130
|
+
/* @__PURE__ */ jsx(Label, { className: "text-xs font-normal leading-tight", children: B.split(/(?=[A-Z])/).join(" ").replace(/-/g, " ").split(" ").map((E) => E.charAt(0).toUpperCase() + E.slice(1)).join(" ") + (!B.toLowerCase().includes("foreground") && !B.toLowerCase().includes("border") && !B.toLowerCase().includes("input") && !B.toLowerCase().includes("ring") && !B.toLowerCase().includes("background") ? " Background" : "") })
|
|
8131
|
+
] }, B);
|
|
8129
8132
|
}) });
|
|
8130
8133
|
return c("edit_theme") ? /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
|
|
8131
8134
|
/* @__PURE__ */ jsxs("div", { className: cn$2("no-scrollbar h-full w-full overflow-y-auto", o), children: [
|
|
@@ -8157,11 +8160,11 @@ const Input = ({ node: o }) => {
|
|
|
8157
8160
|
) })
|
|
8158
8161
|
] }),
|
|
8159
8162
|
/* @__PURE__ */ jsxs("div", { className: cn$2("space-y-2", o), children: [
|
|
8160
|
-
(u == null ? void 0 : u.fontFamily) && /* @__PURE__ */ jsx("div", { className: "grid gap-4", children: Object.entries(u.fontFamily).map(([v,
|
|
8163
|
+
(u == null ? void 0 : u.fontFamily) && /* @__PURE__ */ jsx("div", { className: "grid gap-4", children: Object.entries(u.fontFamily).map(([v, B]) => /* @__PURE__ */ jsx(
|
|
8161
8164
|
FontSelector,
|
|
8162
8165
|
{
|
|
8163
8166
|
label: v,
|
|
8164
|
-
value: d.fontFamily[v.replace(/font-/g, "")] ||
|
|
8167
|
+
value: d.fontFamily[v.replace(/font-/g, "")] || B[Object.keys(B)[0]],
|
|
8165
8168
|
onChange: (w) => f(v, w)
|
|
8166
8169
|
},
|
|
8167
8170
|
v
|
|
@@ -8881,13 +8884,13 @@ function AIChatPanel() {
|
|
|
8881
8884
|
content: "This is a sample response from the AI assistant. In a real implementation, this would be replaced with an actual response from the AI model.",
|
|
8882
8885
|
timestamp: /* @__PURE__ */ new Date()
|
|
8883
8886
|
};
|
|
8884
|
-
r((
|
|
8887
|
+
r((B) => [...B, v]), i(!1), d(null);
|
|
8885
8888
|
}, 1500);
|
|
8886
8889
|
}, h = (b) => {
|
|
8887
8890
|
b.key === "Enter" && !b.shiftKey && (b.preventDefault(), g());
|
|
8888
8891
|
}, f = (b) => {
|
|
8889
|
-
var
|
|
8890
|
-
const v = (
|
|
8892
|
+
var B;
|
|
8893
|
+
const v = (B = b.target.files) == null ? void 0 : B[0];
|
|
8891
8894
|
if (v) {
|
|
8892
8895
|
const w = new FileReader();
|
|
8893
8896
|
w.onload = (E) => {
|
|
@@ -9101,9 +9104,9 @@ const AiAssistant = () => {
|
|
|
9101
9104
|
n(S), l(a), c(""), p(""), h("");
|
|
9102
9105
|
}
|
|
9103
9106
|
}, v = (S) => {
|
|
9104
|
-
const
|
|
9105
|
-
n(
|
|
9106
|
-
},
|
|
9107
|
+
const A = a.filter((N, C) => C !== S);
|
|
9108
|
+
n(A), l(A);
|
|
9109
|
+
}, B = (S) => {
|
|
9107
9110
|
m(S), c(a[S].key), p(a[S].value);
|
|
9108
9111
|
}, w = () => {
|
|
9109
9112
|
if (i.startsWith("@")) {
|
|
@@ -9117,10 +9120,10 @@ const AiAssistant = () => {
|
|
|
9117
9120
|
}, E = (S) => {
|
|
9118
9121
|
S.key === "Enter" && !S.shiftKey && (S.preventDefault(), u !== null ? w() : b());
|
|
9119
9122
|
}, _ = useCallback((S) => {
|
|
9120
|
-
const
|
|
9123
|
+
const A = (k) => /[.,!?;:]/.test(k), N = (k, j, T) => {
|
|
9121
9124
|
let I = "", P = "";
|
|
9122
9125
|
const L = j > 0 ? k[j - 1] : "", D = j < k.length ? k[j] : "";
|
|
9123
|
-
return j > 0 && (L === "." || !
|
|
9126
|
+
return j > 0 && (L === "." || !A(L) && L !== " ") && (I = " "), j < k.length && !A(D) && D !== " " && (P = " "), {
|
|
9124
9127
|
text: I + T + P,
|
|
9125
9128
|
prefixLength: I.length,
|
|
9126
9129
|
suffixLength: P.length
|
|
@@ -9192,16 +9195,16 @@ const AiAssistant = () => {
|
|
|
9192
9195
|
]
|
|
9193
9196
|
}
|
|
9194
9197
|
),
|
|
9195
|
-
/* @__PURE__ */ jsx("div", { className: "space-y-1 py-4", children: a.map((S,
|
|
9198
|
+
/* @__PURE__ */ jsx("div", { className: "space-y-1 py-4", children: a.map((S, A) => /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between rounded border p-2 text-sm", children: [
|
|
9196
9199
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col text-xs leading-tight", children: [
|
|
9197
9200
|
/* @__PURE__ */ jsx("span", { className: "truncate text-[12px] font-light text-muted-foreground", children: S.key }),
|
|
9198
9201
|
/* @__PURE__ */ jsx("span", { className: "max-w-[200px] text-wrap font-normal", children: S.value.toString() })
|
|
9199
9202
|
] }),
|
|
9200
9203
|
/* @__PURE__ */ jsxs("div", { className: "flex-shrink-0 text-slate-400", children: [
|
|
9201
|
-
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => A
|
|
9202
|
-
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => v(
|
|
9204
|
+
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => B(A), children: /* @__PURE__ */ jsx(Edit2, { className: "h-3 w-3" }) }),
|
|
9205
|
+
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => v(A), children: /* @__PURE__ */ jsx(X, { className: "h-3 w-3" }) })
|
|
9203
9206
|
] })
|
|
9204
|
-
] },
|
|
9207
|
+
] }, A)) })
|
|
9205
9208
|
] });
|
|
9206
9209
|
}), BlockAttributesEditor = React.memo(() => {
|
|
9207
9210
|
const o = useSelectedBlock(), [r, n] = useState([]), [a] = useSelectedStylingBlocks(), l = useUpdateBlocksProps(), i = `${get(a, "0.prop")}_attrs`;
|
|
@@ -9330,7 +9333,7 @@ const RootLayout = () => {
|
|
|
9330
9333
|
S && get(S, "view", "standard") === "standard" && (a.current = r, i(get(S, "width", DEFAULT_PANEL_WIDTH)));
|
|
9331
9334
|
}
|
|
9332
9335
|
}, [r, x]);
|
|
9333
|
-
const
|
|
9336
|
+
const B = useMemo(() => {
|
|
9334
9337
|
if (r === null) return 0;
|
|
9335
9338
|
const S = find(x, { id: r });
|
|
9336
9339
|
return get(S, "view", "standard") === "standard" ? v : l;
|
|
@@ -9358,7 +9361,7 @@ const RootLayout = () => {
|
|
|
9358
9361
|
/* @__PURE__ */ jsx("div", { className: "h-14 w-screen shrink-0 border-b border-border", children: /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(o, {}) }) }),
|
|
9359
9362
|
/* @__PURE__ */ jsxs("main", { className: "relative flex h-[calc(100vh-56px)] max-w-full flex-1 flex-row", children: [
|
|
9360
9363
|
/* @__PURE__ */ jsxs("div", { id: "sidebar", className: "flex w-12 flex-col items-center justify-between border-r border-border py-2", children: [
|
|
9361
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-y-1", children: x.map((S,
|
|
9364
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-y-1", children: x.map((S, A) => /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
9362
9365
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(S, "button", NoopComponent), {
|
|
9363
9366
|
position: "top",
|
|
9364
9367
|
panelId: S.id,
|
|
@@ -9366,9 +9369,9 @@ const RootLayout = () => {
|
|
|
9366
9369
|
show: () => _(S.id)
|
|
9367
9370
|
}) }),
|
|
9368
9371
|
/* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: f(S.label) }) })
|
|
9369
|
-
] }, "button-top-" +
|
|
9372
|
+
] }, "button-top-" + A)) }),
|
|
9370
9373
|
/* @__PURE__ */ jsx("div", { className: "flex flex-col space-y-1" }),
|
|
9371
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-col", children: u == null ? void 0 : u.map((S,
|
|
9374
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col", children: u == null ? void 0 : u.map((S, A) => /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
9372
9375
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(S, "button", NoopComponent), {
|
|
9373
9376
|
position: "bottom",
|
|
9374
9377
|
panelId: S.id,
|
|
@@ -9376,15 +9379,15 @@ const RootLayout = () => {
|
|
|
9376
9379
|
show: () => _(S.id)
|
|
9377
9380
|
}) }),
|
|
9378
9381
|
/* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: f(S.label) }) })
|
|
9379
|
-
] }, "button-bottom-" +
|
|
9382
|
+
] }, "button-bottom-" + A)) })
|
|
9380
9383
|
] }),
|
|
9381
9384
|
/* @__PURE__ */ jsx(
|
|
9382
9385
|
motion.div,
|
|
9383
9386
|
{
|
|
9384
9387
|
id: "left-panel",
|
|
9385
9388
|
className: "h-full max-h-full border-r border-border",
|
|
9386
|
-
initial: { width:
|
|
9387
|
-
animate: { width:
|
|
9389
|
+
initial: { width: B },
|
|
9390
|
+
animate: { width: B },
|
|
9388
9391
|
transition: { duration: 0.3, ease: "easeInOut" },
|
|
9389
9392
|
children: r !== null && get(b, "view", "standard") === "standard" && /* @__PURE__ */ jsxs("div", { className: "no-scrollbar flex h-full flex-col overflow-hidden px-3 py-2", children: [
|
|
9390
9393
|
/* @__PURE__ */ jsx(
|
|
@@ -9588,16 +9591,16 @@ const FEATURE_TOGGLES = {
|
|
|
9588
9591
|
var x;
|
|
9589
9592
|
return (x = h.onMount) == null ? void 0 : x.call(h, f);
|
|
9590
9593
|
}, ...g) => {
|
|
9591
|
-
const h = g[0] || ((
|
|
9592
|
-
let N = o.get(
|
|
9593
|
-
return N || (N = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, o.set(
|
|
9594
|
+
const h = g[0] || ((A) => {
|
|
9595
|
+
let N = o.get(A);
|
|
9596
|
+
return N || (N = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, o.set(A, N), u == null || u(A, S)), N;
|
|
9594
9597
|
}), f = g[1] || (() => {
|
|
9595
|
-
let
|
|
9598
|
+
let A, N;
|
|
9596
9599
|
const C = (k) => {
|
|
9597
9600
|
try {
|
|
9598
9601
|
k();
|
|
9599
9602
|
} catch (j) {
|
|
9600
|
-
|
|
9603
|
+
A || (A = !0, N = j);
|
|
9601
9604
|
}
|
|
9602
9605
|
};
|
|
9603
9606
|
do {
|
|
@@ -9608,10 +9611,10 @@ const FEATURE_TOGGLES = {
|
|
|
9608
9611
|
return (I = r.get(T)) == null ? void 0 : I.l.forEach(j);
|
|
9609
9612
|
}), a.clear(), i.forEach(j), i.clear(), l.forEach(j), l.clear(), k.forEach(C), a.size && x();
|
|
9610
9613
|
} while (a.size || i.size || l.size);
|
|
9611
|
-
if (
|
|
9614
|
+
if (A)
|
|
9612
9615
|
throw N;
|
|
9613
9616
|
}), x = g[2] || (() => {
|
|
9614
|
-
const
|
|
9617
|
+
const A = [], N = /* @__PURE__ */ new WeakSet(), C = /* @__PURE__ */ new WeakSet(), k = Array.from(a);
|
|
9615
9618
|
for (; k.length; ) {
|
|
9616
9619
|
const j = k[k.length - 1], T = h(j);
|
|
9617
9620
|
if (C.has(j)) {
|
|
@@ -9619,27 +9622,27 @@ const FEATURE_TOGGLES = {
|
|
|
9619
9622
|
continue;
|
|
9620
9623
|
}
|
|
9621
9624
|
if (N.has(j)) {
|
|
9622
|
-
n.get(j) === T.n &&
|
|
9625
|
+
n.get(j) === T.n && A.push([j, T]), C.add(j), k.pop();
|
|
9623
9626
|
continue;
|
|
9624
9627
|
}
|
|
9625
9628
|
N.add(j);
|
|
9626
9629
|
for (const I of getMountedOrPendingDependents(j, T, r))
|
|
9627
9630
|
N.has(I) || k.push(I);
|
|
9628
9631
|
}
|
|
9629
|
-
for (let j =
|
|
9630
|
-
const [T, I] =
|
|
9632
|
+
for (let j = A.length - 1; j >= 0; --j) {
|
|
9633
|
+
const [T, I] = A[j];
|
|
9631
9634
|
let P = !1;
|
|
9632
9635
|
for (const L of I.d.keys())
|
|
9633
9636
|
if (L !== T && a.has(L)) {
|
|
9634
9637
|
P = !0;
|
|
9635
9638
|
break;
|
|
9636
9639
|
}
|
|
9637
|
-
P && (y(T),
|
|
9640
|
+
P && (y(T), B(T)), n.delete(T);
|
|
9638
9641
|
}
|
|
9639
|
-
}), y = g[3] || ((
|
|
9642
|
+
}), y = g[3] || ((A) => {
|
|
9640
9643
|
var N, C;
|
|
9641
|
-
const k = h(
|
|
9642
|
-
if (isAtomStateInitialized(k) && (r.has(
|
|
9644
|
+
const k = h(A);
|
|
9645
|
+
if (isAtomStateInitialized(k) && (r.has(A) && n.get(A) !== k.n || Array.from(k.d).every(
|
|
9643
9646
|
([R, $]) => (
|
|
9644
9647
|
// Recursively, read the atom state of the dependency, and
|
|
9645
9648
|
// check if the atom epoch number is unchanged
|
|
@@ -9650,10 +9653,10 @@ const FEATURE_TOGGLES = {
|
|
|
9650
9653
|
k.d.clear();
|
|
9651
9654
|
let j = !0;
|
|
9652
9655
|
const T = () => {
|
|
9653
|
-
r.has(
|
|
9656
|
+
r.has(A) && (B(A), x(), f());
|
|
9654
9657
|
}, I = (R) => {
|
|
9655
9658
|
var $;
|
|
9656
|
-
if (isSelfAtom(
|
|
9659
|
+
if (isSelfAtom(A, R)) {
|
|
9657
9660
|
const H = h(R);
|
|
9658
9661
|
if (!isAtomStateInitialized(H))
|
|
9659
9662
|
if (hasInitialValue(R))
|
|
@@ -9666,7 +9669,7 @@ const FEATURE_TOGGLES = {
|
|
|
9666
9669
|
try {
|
|
9667
9670
|
return returnAtomValue(M);
|
|
9668
9671
|
} finally {
|
|
9669
|
-
k.d.set(R, M.n), isPendingPromise(k.v) && addPendingPromiseToDependency(
|
|
9672
|
+
k.d.set(R, M.n), isPendingPromise(k.v) && addPendingPromiseToDependency(A, k.v, M), ($ = r.get(R)) == null || $.t.add(A), j || T();
|
|
9670
9673
|
}
|
|
9671
9674
|
};
|
|
9672
9675
|
let P, L;
|
|
@@ -9675,10 +9678,10 @@ const FEATURE_TOGGLES = {
|
|
|
9675
9678
|
return P || (P = new AbortController()), P.signal;
|
|
9676
9679
|
},
|
|
9677
9680
|
get setSelf() {
|
|
9678
|
-
return !L && isActuallyWritableAtom(
|
|
9681
|
+
return !L && isActuallyWritableAtom(A) && (L = (...R) => {
|
|
9679
9682
|
if (!j)
|
|
9680
9683
|
try {
|
|
9681
|
-
return v(
|
|
9684
|
+
return v(A, ...R);
|
|
9682
9685
|
} finally {
|
|
9683
9686
|
x(), f();
|
|
9684
9687
|
}
|
|
@@ -9686,18 +9689,18 @@ const FEATURE_TOGGLES = {
|
|
|
9686
9689
|
}
|
|
9687
9690
|
}, O = k.n;
|
|
9688
9691
|
try {
|
|
9689
|
-
const R = d(
|
|
9690
|
-
return setAtomStateValueOrPromise(
|
|
9692
|
+
const R = d(A, I, D);
|
|
9693
|
+
return setAtomStateValueOrPromise(A, R, h), isPromiseLike$1(R) && ((N = R.onCancel) == null || N.call(R, () => P == null ? void 0 : P.abort()), R.then(
|
|
9691
9694
|
T,
|
|
9692
9695
|
T
|
|
9693
9696
|
)), k;
|
|
9694
9697
|
} catch (R) {
|
|
9695
9698
|
return delete k.v, k.e = R, ++k.n, k;
|
|
9696
9699
|
} finally {
|
|
9697
|
-
j = !1, O !== k.n && n.get(
|
|
9700
|
+
j = !1, O !== k.n && n.get(A) === O && (n.set(A, k.n), a.add(A), (C = c.c) == null || C.call(c, A));
|
|
9698
9701
|
}
|
|
9699
|
-
}), b = g[4] || ((
|
|
9700
|
-
const N = [
|
|
9702
|
+
}), b = g[4] || ((A) => {
|
|
9703
|
+
const N = [A];
|
|
9701
9704
|
for (; N.length; ) {
|
|
9702
9705
|
const C = N.pop(), k = h(C);
|
|
9703
9706
|
for (const j of getMountedOrPendingDependents(C, k, r)) {
|
|
@@ -9705,17 +9708,17 @@ const FEATURE_TOGGLES = {
|
|
|
9705
9708
|
n.set(j, T.n), N.push(j);
|
|
9706
9709
|
}
|
|
9707
9710
|
}
|
|
9708
|
-
}), v = g[5] || ((
|
|
9711
|
+
}), v = g[5] || ((A, ...N) => {
|
|
9709
9712
|
let C = !0;
|
|
9710
9713
|
const k = (T) => returnAtomValue(y(T)), j = (T, ...I) => {
|
|
9711
9714
|
var P;
|
|
9712
9715
|
const L = h(T);
|
|
9713
9716
|
try {
|
|
9714
|
-
if (isSelfAtom(
|
|
9717
|
+
if (isSelfAtom(A, T)) {
|
|
9715
9718
|
if (!hasInitialValue(T))
|
|
9716
9719
|
throw new Error("atom not writable");
|
|
9717
9720
|
const D = L.n, O = I[0];
|
|
9718
|
-
setAtomStateValueOrPromise(T, O, h),
|
|
9721
|
+
setAtomStateValueOrPromise(T, O, h), B(T), D !== L.n && (a.add(T), (P = c.c) == null || P.call(c, T), b(T));
|
|
9719
9722
|
return;
|
|
9720
9723
|
} else
|
|
9721
9724
|
return v(T, ...I);
|
|
@@ -9724,50 +9727,50 @@ const FEATURE_TOGGLES = {
|
|
|
9724
9727
|
}
|
|
9725
9728
|
};
|
|
9726
9729
|
try {
|
|
9727
|
-
return p(
|
|
9730
|
+
return p(A, k, j, ...N);
|
|
9728
9731
|
} finally {
|
|
9729
9732
|
C = !1;
|
|
9730
9733
|
}
|
|
9731
|
-
}),
|
|
9734
|
+
}), B = g[6] || ((A) => {
|
|
9732
9735
|
var N;
|
|
9733
|
-
const C = h(
|
|
9736
|
+
const C = h(A), k = r.get(A);
|
|
9734
9737
|
if (k && !isPendingPromise(C.v)) {
|
|
9735
9738
|
for (const [j, T] of C.d)
|
|
9736
9739
|
if (!k.d.has(j)) {
|
|
9737
9740
|
const I = h(j);
|
|
9738
|
-
w(j).t.add(
|
|
9741
|
+
w(j).t.add(A), k.d.add(j), T !== I.n && (a.add(j), (N = c.c) == null || N.call(c, j), b(j));
|
|
9739
9742
|
}
|
|
9740
9743
|
for (const j of k.d || [])
|
|
9741
9744
|
if (!C.d.has(j)) {
|
|
9742
9745
|
k.d.delete(j);
|
|
9743
9746
|
const T = E(j);
|
|
9744
|
-
T == null || T.t.delete(
|
|
9747
|
+
T == null || T.t.delete(A);
|
|
9745
9748
|
}
|
|
9746
9749
|
}
|
|
9747
|
-
}), w = g[7] || ((
|
|
9750
|
+
}), w = g[7] || ((A) => {
|
|
9748
9751
|
var N;
|
|
9749
|
-
const C = h(
|
|
9750
|
-
let k = r.get(
|
|
9752
|
+
const C = h(A);
|
|
9753
|
+
let k = r.get(A);
|
|
9751
9754
|
if (!k) {
|
|
9752
|
-
y(
|
|
9755
|
+
y(A);
|
|
9753
9756
|
for (const j of C.d.keys())
|
|
9754
|
-
w(j).t.add(
|
|
9757
|
+
w(j).t.add(A);
|
|
9755
9758
|
if (k = {
|
|
9756
9759
|
l: /* @__PURE__ */ new Set(),
|
|
9757
9760
|
d: new Set(C.d.keys()),
|
|
9758
9761
|
t: /* @__PURE__ */ new Set()
|
|
9759
|
-
}, r.set(
|
|
9762
|
+
}, r.set(A, k), (N = c.m) == null || N.call(c, A), isActuallyWritableAtom(A)) {
|
|
9760
9763
|
const j = () => {
|
|
9761
9764
|
let T = !0;
|
|
9762
9765
|
const I = (...P) => {
|
|
9763
9766
|
try {
|
|
9764
|
-
return v(
|
|
9767
|
+
return v(A, ...P);
|
|
9765
9768
|
} finally {
|
|
9766
9769
|
T || (x(), f());
|
|
9767
9770
|
}
|
|
9768
9771
|
};
|
|
9769
9772
|
try {
|
|
9770
|
-
const P = m(
|
|
9773
|
+
const P = m(A, I);
|
|
9771
9774
|
P && (k.u = () => {
|
|
9772
9775
|
T = !0;
|
|
9773
9776
|
try {
|
|
@@ -9784,18 +9787,18 @@ const FEATURE_TOGGLES = {
|
|
|
9784
9787
|
}
|
|
9785
9788
|
}
|
|
9786
9789
|
return k;
|
|
9787
|
-
}), E = g[8] || ((
|
|
9790
|
+
}), E = g[8] || ((A) => {
|
|
9788
9791
|
var N;
|
|
9789
|
-
const C = h(
|
|
9790
|
-
let k = r.get(
|
|
9792
|
+
const C = h(A);
|
|
9793
|
+
let k = r.get(A);
|
|
9791
9794
|
if (k && !k.l.size && !Array.from(k.t).some((j) => {
|
|
9792
9795
|
var T;
|
|
9793
|
-
return (T = r.get(j)) == null ? void 0 : T.d.has(
|
|
9796
|
+
return (T = r.get(j)) == null ? void 0 : T.d.has(A);
|
|
9794
9797
|
})) {
|
|
9795
|
-
k.u && i.add(k.u), k = void 0, r.delete(
|
|
9798
|
+
k.u && i.add(k.u), k = void 0, r.delete(A), (N = c.u) == null || N.call(c, A);
|
|
9796
9799
|
for (const j of C.d.keys()) {
|
|
9797
9800
|
const T = E(j);
|
|
9798
|
-
T == null || T.t.delete(
|
|
9801
|
+
T == null || T.t.delete(A);
|
|
9799
9802
|
}
|
|
9800
9803
|
return;
|
|
9801
9804
|
}
|
|
@@ -9821,22 +9824,22 @@ const FEATURE_TOGGLES = {
|
|
|
9821
9824
|
y,
|
|
9822
9825
|
b,
|
|
9823
9826
|
v,
|
|
9824
|
-
|
|
9827
|
+
B,
|
|
9825
9828
|
w,
|
|
9826
9829
|
E
|
|
9827
9830
|
], S = {
|
|
9828
|
-
get: (
|
|
9829
|
-
set: (
|
|
9831
|
+
get: (A) => returnAtomValue(y(A)),
|
|
9832
|
+
set: (A, ...N) => {
|
|
9830
9833
|
try {
|
|
9831
|
-
return v(
|
|
9834
|
+
return v(A, ...N);
|
|
9832
9835
|
} finally {
|
|
9833
9836
|
x(), f();
|
|
9834
9837
|
}
|
|
9835
9838
|
},
|
|
9836
|
-
sub: (
|
|
9837
|
-
const k = w(
|
|
9839
|
+
sub: (A, N) => {
|
|
9840
|
+
const k = w(A).l;
|
|
9838
9841
|
return k.add(N), f(), () => {
|
|
9839
|
-
k.delete(N), E(
|
|
9842
|
+
k.delete(N), E(A), f();
|
|
9840
9843
|
};
|
|
9841
9844
|
}
|
|
9842
9845
|
};
|