@chaibuilder/sdk 2.0.0-beta.96 → 2.0.0-beta.98
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 +7 -8
- package/dist/core.js +10 -11
- package/package.json +1 -1
package/dist/core.cjs
CHANGED
|
@@ -5102,12 +5102,12 @@ const BlockRenderer = ({ blockAtom, children }) => {
|
|
|
5102
5102
|
if (lodashEs.isNull(Component2) || hiddenBlocks.includes(block._id) || editingBlockId === block._id) return null;
|
|
5103
5103
|
return /* @__PURE__ */ jsxRuntime.jsx(React.Suspense, { children: React.createElement(Component2, { ...props, children }) });
|
|
5104
5104
|
};
|
|
5105
|
-
const GlobalBlocksRenderer = ({
|
|
5105
|
+
const GlobalBlocksRenderer = ({ globalBlockId }) => {
|
|
5106
5106
|
const { getGlobalBlocks } = useGlobalBlocksStore();
|
|
5107
|
-
const
|
|
5108
|
-
const
|
|
5109
|
-
|
|
5110
|
-
return /* @__PURE__ */ jsxRuntime.jsx(BlocksRenderer, { splitAtoms:
|
|
5107
|
+
const globalBlocks = React.useMemo(() => getGlobalBlocks(globalBlockId), [getGlobalBlocks, globalBlockId]);
|
|
5108
|
+
const globalBlocksAtoms = React.useMemo(() => splitAtom(jotai.atom(globalBlocks)), [globalBlocks]);
|
|
5109
|
+
if (lodashEs.isEmpty(globalBlocks)) return null;
|
|
5110
|
+
return /* @__PURE__ */ jsxRuntime.jsx(BlocksRenderer, { splitAtoms: globalBlocksAtoms, blocks: globalBlocks });
|
|
5111
5111
|
};
|
|
5112
5112
|
const BlocksRenderer = ({
|
|
5113
5113
|
blocks,
|
|
@@ -5116,19 +5116,18 @@ const BlocksRenderer = ({
|
|
|
5116
5116
|
}) => {
|
|
5117
5117
|
const getBlockAtom = useGetBlockAtom(splitAtoms);
|
|
5118
5118
|
const filteredBlocks = React.useMemo(
|
|
5119
|
-
() => lodashEs.filter(blocks, (block) => lodashEs.
|
|
5119
|
+
() => lodashEs.filter(blocks, (block) => !lodashEs.isEmpty(parent) ? block._parent === parent : !block._parent),
|
|
5120
5120
|
[blocks, parent]
|
|
5121
5121
|
);
|
|
5122
5122
|
const hasChildren = React.useCallback((block) => lodashEs.filter(blocks, (b) => b._parent === block._id).length > 0, [blocks]);
|
|
5123
5123
|
return lodashEs.map(filteredBlocks, (block) => {
|
|
5124
5124
|
const blockAtom = getBlockAtom(block._id);
|
|
5125
5125
|
if (!blockAtom) return null;
|
|
5126
|
-
return /* @__PURE__ */ jsxRuntime.jsx(BlockRenderer, { blockAtom, children: block._type === "GlobalBlock" ? /* @__PURE__ */ jsxRuntime.jsx(GlobalBlocksRenderer, {
|
|
5126
|
+
return /* @__PURE__ */ jsxRuntime.jsx(BlockRenderer, { blockAtom, children: block._type === "GlobalBlock" ? /* @__PURE__ */ jsxRuntime.jsx(jotai.Provider, { store: builderStore, children: /* @__PURE__ */ jsxRuntime.jsx(GlobalBlocksRenderer, { globalBlockId: lodashEs.get(block, "globalBlock", "") }) }) : hasChildren(block) ? /* @__PURE__ */ jsxRuntime.jsx(BlocksRenderer, { splitAtoms, blocks, parent: block._id }) : null }, block._id);
|
|
5127
5127
|
});
|
|
5128
5128
|
};
|
|
5129
5129
|
const PageBlocksRenderer = () => {
|
|
5130
5130
|
const [blocks] = useBlocksStore();
|
|
5131
|
-
console.log(jotai.useAtomValue(pageBlocksAtomsAtom));
|
|
5132
5131
|
return /* @__PURE__ */ jsxRuntime.jsx(BlocksRenderer, { splitAtoms: pageBlocksAtomsAtom, blocks });
|
|
5133
5132
|
};
|
|
5134
5133
|
const StaticBlocksRenderer = () => {
|
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-DHla8ofZ.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-CWgVxu0A.js";
|
|
12
12
|
import { useTranslation, initReactI18next } from "react-i18next";
|
|
13
13
|
import { useTranslation as useTranslation2 } from "react-i18next";
|
|
@@ -5087,12 +5087,12 @@ const BlockRenderer = ({ blockAtom, children }) => {
|
|
|
5087
5087
|
if (isNull(Component3) || hiddenBlocks.includes(block._id) || editingBlockId === block._id) return null;
|
|
5088
5088
|
return /* @__PURE__ */ jsx(Suspense, { children: createElement(Component3, { ...props, children }) });
|
|
5089
5089
|
};
|
|
5090
|
-
const GlobalBlocksRenderer = ({
|
|
5090
|
+
const GlobalBlocksRenderer = ({ globalBlockId }) => {
|
|
5091
5091
|
const { getGlobalBlocks } = useGlobalBlocksStore();
|
|
5092
|
-
const
|
|
5093
|
-
const
|
|
5094
|
-
|
|
5095
|
-
return /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms:
|
|
5092
|
+
const globalBlocks = useMemo(() => getGlobalBlocks(globalBlockId), [getGlobalBlocks, globalBlockId]);
|
|
5093
|
+
const globalBlocksAtoms = useMemo(() => splitAtom(atom$1(globalBlocks)), [globalBlocks]);
|
|
5094
|
+
if (isEmpty(globalBlocks)) return null;
|
|
5095
|
+
return /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: globalBlocksAtoms, blocks: globalBlocks });
|
|
5096
5096
|
};
|
|
5097
5097
|
const BlocksRenderer = ({
|
|
5098
5098
|
blocks,
|
|
@@ -5101,19 +5101,18 @@ const BlocksRenderer = ({
|
|
|
5101
5101
|
}) => {
|
|
5102
5102
|
const getBlockAtom = useGetBlockAtom(splitAtoms);
|
|
5103
5103
|
const filteredBlocks = useMemo(
|
|
5104
|
-
() => filter(blocks, (block) =>
|
|
5104
|
+
() => filter(blocks, (block) => !isEmpty(parent) ? block._parent === parent : !block._parent),
|
|
5105
5105
|
[blocks, parent]
|
|
5106
5106
|
);
|
|
5107
5107
|
const hasChildren = useCallback((block) => filter(blocks, (b) => b._parent === block._id).length > 0, [blocks]);
|
|
5108
5108
|
return map(filteredBlocks, (block) => {
|
|
5109
5109
|
const blockAtom = getBlockAtom(block._id);
|
|
5110
5110
|
if (!blockAtom) return null;
|
|
5111
|
-
return /* @__PURE__ */ jsx(BlockRenderer, { blockAtom, children: block._type === "GlobalBlock" ? /* @__PURE__ */ jsx(GlobalBlocksRenderer, {
|
|
5111
|
+
return /* @__PURE__ */ jsx(BlockRenderer, { blockAtom, children: block._type === "GlobalBlock" ? /* @__PURE__ */ jsx(Provider, { store: builderStore, children: /* @__PURE__ */ jsx(GlobalBlocksRenderer, { globalBlockId: get(block, "globalBlock", "") }) }) : hasChildren(block) ? /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms, blocks, parent: block._id }) : null }, block._id);
|
|
5112
5112
|
});
|
|
5113
5113
|
};
|
|
5114
5114
|
const PageBlocksRenderer = () => {
|
|
5115
5115
|
const [blocks] = useBlocksStore();
|
|
5116
|
-
console.log(useAtomValue$1(pageBlocksAtomsAtom));
|
|
5117
5116
|
return /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: pageBlocksAtomsAtom, blocks });
|
|
5118
5117
|
};
|
|
5119
5118
|
const StaticBlocksRenderer = () => {
|
|
@@ -5253,7 +5252,7 @@ const StaticCanvas = () => {
|
|
|
5253
5252
|
}
|
|
5254
5253
|
),
|
|
5255
5254
|
/* @__PURE__ */ jsx(HeadTags, {}),
|
|
5256
|
-
/* @__PURE__ */ jsx(Provider, { children: /* @__PURE__ */ jsxs(Canvas, { children: [
|
|
5255
|
+
/* @__PURE__ */ jsx(Provider$1, { children: /* @__PURE__ */ jsxs(Canvas, { children: [
|
|
5257
5256
|
loadingCanvas ? /* @__PURE__ */ jsx("div", { className: "h-full p-4", children: /* @__PURE__ */ jsx(Skeleton, { className: "h-full" }) }) : /* @__PURE__ */ jsx(StaticBlocksRenderer, {}),
|
|
5258
5257
|
/* @__PURE__ */ jsx(AddBlockAtBottom, {}),
|
|
5259
5258
|
/* @__PURE__ */ jsx("br", {}),
|