@chaibuilder/sdk 2.0.3 → 2.0.5
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.js +37 -65
- package/package.json +3 -3
package/dist/core.js
CHANGED
|
@@ -4,20 +4,20 @@ 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
6
|
import React__default, { createContext, useReducer, useEffect, useDebugValue, useCallback, useContext, useMemo, Component, Children, useState, useRef, 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, a6 as Label, 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,
|
|
7
|
+
import { O as DropdownMenu, P as DropdownMenuTrigger, Q as DropdownMenuContent, R as DropdownMenuItem, S as Skeleton, B as Button, a6 as Label, 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, 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
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, startCase, debounce, capitalize, split, take, toUpper, toLower, nth, isNumber, parseInt as parseInt$1, isNaN as isNaN$1, findLast, intersection, 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
|
-
import { useTranslation as
|
|
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, InfoCircledIcon, BoxIcon, MinusIcon, TriangleDownIcon, RowSpacingIcon, CrossCircledIcon,
|
|
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, InfoCircledIcon, 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
|
-
import { registerChaiBlock as
|
|
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
22
|
import TreeModel from "tree-model";
|
|
23
23
|
import { useHotkeys } from "react-hotkeys-hook";
|
|
@@ -36,7 +36,6 @@ import { ErrorBoundary } from "react-error-boundary";
|
|
|
36
36
|
import { Resizable } from "re-resizable";
|
|
37
37
|
import RjForm from "@rjsf/core";
|
|
38
38
|
import validator from "@rjsf/validator-ajv8";
|
|
39
|
-
import { isEmpty as isEmpty$1, get as get$1 } from "lodash";
|
|
40
39
|
import Link from "@tiptap/extension-link";
|
|
41
40
|
import TextAlign from "@tiptap/extension-text-align";
|
|
42
41
|
import Underline from "@tiptap/extension-underline";
|
|
@@ -46,7 +45,7 @@ import Fuse from "fuse.js";
|
|
|
46
45
|
import { parse, stringify } from "himalaya";
|
|
47
46
|
import { Tree } from "react-arborist";
|
|
48
47
|
import i18n from "i18next";
|
|
49
|
-
import { default as
|
|
48
|
+
import { default as ze } from "i18next";
|
|
50
49
|
import { motion } from "framer-motion";
|
|
51
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) => {
|
|
52
51
|
if ("e" in o)
|
|
@@ -5088,7 +5087,7 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
5088
5087
|
formData: g,
|
|
5089
5088
|
onChange: m
|
|
5090
5089
|
}) => {
|
|
5091
|
-
const { selectedLang: x, fallbackLang: f, languages: h } = useLanguages(), b = isEmpty
|
|
5090
|
+
const { selectedLang: x, fallbackLang: f, languages: h } = useLanguages(), b = isEmpty(h) ? "" : isEmpty(x) ? f : x, k = get(LANGUAGES, b, b), A = usePageExternalData(), B = useSelectedBlock(), C = useRegisteredChaiBlocks(), j = get(C, [B == null ? void 0 : B._type, "i18nProps"], []) || [], [_, S] = useState(null), w = useCallback(
|
|
5092
5091
|
(y) => {
|
|
5093
5092
|
const E = (P) => /[.,!?;:]/.test(P), T = (P, N, M) => {
|
|
5094
5093
|
let D = "", O = "";
|
|
@@ -5833,7 +5832,34 @@ const BASIC_UNITS = ["px", "%", "em", "rem", "ch", "vh", "vw"], FLEX_CHILD_SECTI
|
|
|
5833
5832
|
}
|
|
5834
5833
|
];
|
|
5835
5834
|
BASIC_UNITS.concat("auto"), BASIC_UNITS.concat("auto"), [...BASIC_UNITS], BASIC_UNITS.concat("auto"), BASIC_UNITS.concat("auto"), BASIC_UNITS.concat("auto"), BASIC_UNITS.concat("auto"), BASIC_UNITS.concat("-");
|
|
5836
|
-
const
|
|
5835
|
+
const BlockStylingProps = () => {
|
|
5836
|
+
const o = useSelectedBlock(), [n, r] = useSelectedStylingBlocks(), { t: a } = useTranslation();
|
|
5837
|
+
if (!o) return null;
|
|
5838
|
+
const l = Object.keys(o).filter(
|
|
5839
|
+
(c) => typeof o[c] == "string" && o[c].startsWith("#styles:")
|
|
5840
|
+
);
|
|
5841
|
+
if (isEmpty(l) || l.length <= 1) return null;
|
|
5842
|
+
const i = (c) => find(n, (d) => d.prop === c);
|
|
5843
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-1", children: [
|
|
5844
|
+
/* @__PURE__ */ jsxs("label", { htmlFor: "block-styling-props", className: "py-1 text-xs", children: [
|
|
5845
|
+
a("Style element"),
|
|
5846
|
+
":"
|
|
5847
|
+
] }),
|
|
5848
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-2", children: map(l, (c) => /* @__PURE__ */ jsx(
|
|
5849
|
+
Badge,
|
|
5850
|
+
{
|
|
5851
|
+
className: "cursor-pointer",
|
|
5852
|
+
onClick: () => {
|
|
5853
|
+
r([{ id: `${c}-${o._id}`, blockId: o._id, prop: c }]);
|
|
5854
|
+
},
|
|
5855
|
+
variant: i(c) ? "default" : "secondary",
|
|
5856
|
+
children: startCase(c)
|
|
5857
|
+
},
|
|
5858
|
+
c
|
|
5859
|
+
)) }),
|
|
5860
|
+
/* @__PURE__ */ jsx("div", { className: "my-2 h-[1px] w-full bg-border" })
|
|
5861
|
+
] });
|
|
5862
|
+
}, EDITOR_ICONS = {
|
|
5837
5863
|
"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" }) }),
|
|
5838
5864
|
// visibility
|
|
5839
5865
|
visible: EyeOpenIcon,
|
|
@@ -6752,59 +6778,6 @@ const COLOR_PROP = {
|
|
|
6752
6778
|
] }) : /* @__PURE__ */ jsx("div", { className: "py-2", children: React__default.Children.toArray(
|
|
6753
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))
|
|
6754
6780
|
) }) });
|
|
6755
|
-
}, StylingHelpers = () => {
|
|
6756
|
-
const o = useSelectedBlock(), [n] = useSelectedStylingBlocks(), { t: r } = useTranslation(), a = useAddClassesToBlocks(), l = getRegisteredChaiBlock(o._type), i = get(first(n), "prop"), c = get(l.props, `${i}.presets`, {});
|
|
6757
|
-
if (!has(l, "props") || isEmpty(c))
|
|
6758
|
-
return null;
|
|
6759
|
-
const d = (p) => {
|
|
6760
|
-
const u = p.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
|
|
6761
|
-
a([o._id], u, !0);
|
|
6762
|
-
};
|
|
6763
|
-
return /* @__PURE__ */ jsx("div", { className: "h-10", children: /* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
6764
|
-
/* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: !0, children: /* @__PURE__ */ jsx("div", { className: "px-4", children: /* @__PURE__ */ jsxs(Button, { variant: "default", className: "w-full", size: "sm", children: [
|
|
6765
|
-
r("Apply Presets"),
|
|
6766
|
-
/* @__PURE__ */ jsx(CaretDownIcon, {})
|
|
6767
|
-
] }) }) }),
|
|
6768
|
-
/* @__PURE__ */ jsx(DropdownMenuContent, { className: "max-h-80 w-56", children: /* @__PURE__ */ jsx(ScrollArea, { className: "no-scrollbar h-full", children: isEmpty(c) ? null : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
6769
|
-
/* @__PURE__ */ jsxs(DropdownMenuLabel, { children: [
|
|
6770
|
-
l.type,
|
|
6771
|
-
" ",
|
|
6772
|
-
r("presets")
|
|
6773
|
-
] }),
|
|
6774
|
-
/* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
|
|
6775
|
-
/* @__PURE__ */ jsx(DropdownMenuGroup, { children: keys(c).map((p) => /* @__PURE__ */ jsxs(DropdownMenuItem, { className: "group text-xs", onClick: () => d(c[p]), children: [
|
|
6776
|
-
capitalize(startCase(r(p))),
|
|
6777
|
-
/* @__PURE__ */ jsx(DropdownMenuShortcut, { className: "invisible hover:font-bold hover:text-blue-600 group-hover:visible", children: r("apply") })
|
|
6778
|
-
] })) })
|
|
6779
|
-
] }) }) })
|
|
6780
|
-
] }) });
|
|
6781
|
-
}, BlockStylingProps = () => {
|
|
6782
|
-
const o = useSelectedBlock(), [n, r] = useSelectedStylingBlocks(), { t: a } = useTranslation();
|
|
6783
|
-
if (!o) return null;
|
|
6784
|
-
const l = Object.keys(o).filter(
|
|
6785
|
-
(c) => typeof o[c] == "string" && o[c].startsWith("#styles:")
|
|
6786
|
-
);
|
|
6787
|
-
if (isEmpty(l) || l.length <= 1) return null;
|
|
6788
|
-
const i = (c) => find(n, (d) => d.prop === c);
|
|
6789
|
-
return /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-1", children: [
|
|
6790
|
-
/* @__PURE__ */ jsxs("label", { htmlFor: "block-styling-props", className: "py-1 text-xs", children: [
|
|
6791
|
-
a("Style element"),
|
|
6792
|
-
":"
|
|
6793
|
-
] }),
|
|
6794
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-2", children: map(l, (c) => /* @__PURE__ */ jsx(
|
|
6795
|
-
Badge,
|
|
6796
|
-
{
|
|
6797
|
-
className: "cursor-pointer",
|
|
6798
|
-
onClick: () => {
|
|
6799
|
-
r([{ id: `${c}-${o._id}`, blockId: o._id, prop: c }]);
|
|
6800
|
-
},
|
|
6801
|
-
variant: i(c) ? "default" : "secondary",
|
|
6802
|
-
children: startCase(c)
|
|
6803
|
-
},
|
|
6804
|
-
c
|
|
6805
|
-
)) }),
|
|
6806
|
-
/* @__PURE__ */ jsx("div", { className: "my-2 h-[1px] w-full bg-border" })
|
|
6807
|
-
] });
|
|
6808
6781
|
}, MAPPER = {
|
|
6809
6782
|
px: 1,
|
|
6810
6783
|
"%": 1,
|
|
@@ -6862,7 +6835,6 @@ function BlockStyling() {
|
|
|
6862
6835
|
) : null,
|
|
6863
6836
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
|
|
6864
6837
|
/* @__PURE__ */ jsx(BlockStylingProps, {}),
|
|
6865
|
-
/* @__PURE__ */ jsx(StylingHelpers, {}),
|
|
6866
6838
|
/* @__PURE__ */ jsxs(Accordion, { defaultValue: ["Styles"], type: "multiple", className: "w-full", children: [
|
|
6867
6839
|
o && /* @__PURE__ */ jsx(StylingGroup, { section: FLEX_CHILD_SECTION, showAccordian: o || n }),
|
|
6868
6840
|
n && /* @__PURE__ */ jsx(StylingGroup, { section: GRID_CHILD_SECTION, showAccordian: o || n }),
|
|
@@ -9523,9 +9495,9 @@ export {
|
|
|
9523
9495
|
generateUUID as generateBlockId,
|
|
9524
9496
|
getBlocksFromHTML,
|
|
9525
9497
|
getClassValueAndUnit,
|
|
9526
|
-
|
|
9498
|
+
ze as i18n,
|
|
9527
9499
|
cn$1 as mergeClasses,
|
|
9528
|
-
|
|
9500
|
+
Ue as registerChaiBlock,
|
|
9529
9501
|
useAddBlock,
|
|
9530
9502
|
useAddClassesToBlocks,
|
|
9531
9503
|
useAskAi,
|
|
@@ -9569,7 +9541,7 @@ export {
|
|
|
9569
9541
|
useStylingState,
|
|
9570
9542
|
useTheme,
|
|
9571
9543
|
useThemeOptions,
|
|
9572
|
-
|
|
9544
|
+
He as useTranslation,
|
|
9573
9545
|
useUILibraryBlocks,
|
|
9574
9546
|
useUndoManager,
|
|
9575
9547
|
useUpdateBlocksProps,
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"author": "Suraj Air",
|
|
6
6
|
"license": "BSD-3-Clause",
|
|
7
7
|
"homepage": "https://chaibuilder.com",
|
|
8
|
-
"version": "2.0.
|
|
8
|
+
"version": "2.0.5",
|
|
9
9
|
"type": "module",
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
}
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@chaibuilder/runtime": "2.0.
|
|
56
|
+
"@chaibuilder/runtime": "2.0.1",
|
|
57
57
|
"@types/react": "*",
|
|
58
58
|
"@types/react-dom": "*",
|
|
59
59
|
"jotai": "2.12.1",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
}
|
|
70
70
|
},
|
|
71
71
|
"dependencies": {
|
|
72
|
-
"@chaibuilder/runtime": "2.0.
|
|
72
|
+
"@chaibuilder/runtime": "2.0.1",
|
|
73
73
|
"@floating-ui/dom": "1.6.13",
|
|
74
74
|
"@floating-ui/react-dom": "2.1.2",
|
|
75
75
|
"@mhsdesign/jit-browser-tailwindcss": "0.4.2",
|