@chaibuilder/sdk 2.0.4 → 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.js CHANGED
@@ -4,7 +4,7 @@ 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, aa as ScrollArea, Y as DropdownMenuGroup, X as DropdownMenuShortcut, A as Accordion, C as Card, q as CardHeader, t as CardDescription, u as CardContent, r as CardFooter, 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";
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";
@@ -13,7 +13,7 @@ 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, CaretDownIcon, CaretRightIcon, CardStackIcon, CardStackPlusIcon, ScissorsIcon, CheckIcon, SunIcon, ResetIcon, EraserIcon, ZoomInIcon, MixerHorizontalIcon, LightningBoltIcon } from "@radix-ui/react-icons";
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";
@@ -5832,7 +5832,34 @@ const BASIC_UNITS = ["px", "%", "em", "rem", "ch", "vh", "vw"], FLEX_CHILD_SECTI
5832
5832
  }
5833
5833
  ];
5834
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("-");
5835
- const EDITOR_ICONS = {
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 = {
5836
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" }) }),
5837
5864
  // visibility
5838
5865
  visible: EyeOpenIcon,
@@ -6751,59 +6778,6 @@ const COLOR_PROP = {
6751
6778
  ] }) : /* @__PURE__ */ jsx("div", { className: "py-2", children: React__default.Children.toArray(
6752
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))
6753
6780
  ) }) });
6754
- }, StylingHelpers = () => {
6755
- 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`, {});
6756
- if (!has(l, "props") || isEmpty(c))
6757
- return null;
6758
- const d = (p) => {
6759
- const u = p.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
6760
- a([o._id], u, !0);
6761
- };
6762
- return /* @__PURE__ */ jsx("div", { className: "h-10", children: /* @__PURE__ */ jsxs(DropdownMenu, { children: [
6763
- /* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: !0, children: /* @__PURE__ */ jsx("div", { className: "px-4", children: /* @__PURE__ */ jsxs(Button, { variant: "default", className: "w-full", size: "sm", children: [
6764
- r("Apply Presets"),
6765
- /* @__PURE__ */ jsx(CaretDownIcon, {})
6766
- ] }) }) }),
6767
- /* @__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: [
6768
- /* @__PURE__ */ jsxs(DropdownMenuLabel, { children: [
6769
- l.type,
6770
- " ",
6771
- r("presets")
6772
- ] }),
6773
- /* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
6774
- /* @__PURE__ */ jsx(DropdownMenuGroup, { children: keys(c).map((p) => /* @__PURE__ */ jsxs(DropdownMenuItem, { className: "group text-xs", onClick: () => d(c[p]), children: [
6775
- capitalize(startCase(r(p))),
6776
- /* @__PURE__ */ jsx(DropdownMenuShortcut, { className: "invisible hover:font-bold hover:text-blue-600 group-hover:visible", children: r("apply") })
6777
- ] })) })
6778
- ] }) }) })
6779
- ] }) });
6780
- }, BlockStylingProps = () => {
6781
- const o = useSelectedBlock(), [n, r] = useSelectedStylingBlocks(), { t: a } = useTranslation();
6782
- if (!o) return null;
6783
- const l = Object.keys(o).filter(
6784
- (c) => typeof o[c] == "string" && o[c].startsWith("#styles:")
6785
- );
6786
- if (isEmpty(l) || l.length <= 1) return null;
6787
- const i = (c) => find(n, (d) => d.prop === c);
6788
- return /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-1", children: [
6789
- /* @__PURE__ */ jsxs("label", { htmlFor: "block-styling-props", className: "py-1 text-xs", children: [
6790
- a("Style element"),
6791
- ":"
6792
- ] }),
6793
- /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-2", children: map(l, (c) => /* @__PURE__ */ jsx(
6794
- Badge,
6795
- {
6796
- className: "cursor-pointer",
6797
- onClick: () => {
6798
- r([{ id: `${c}-${o._id}`, blockId: o._id, prop: c }]);
6799
- },
6800
- variant: i(c) ? "default" : "secondary",
6801
- children: startCase(c)
6802
- },
6803
- c
6804
- )) }),
6805
- /* @__PURE__ */ jsx("div", { className: "my-2 h-[1px] w-full bg-border" })
6806
- ] });
6807
6781
  }, MAPPER = {
6808
6782
  px: 1,
6809
6783
  "%": 1,
@@ -6861,7 +6835,6 @@ function BlockStyling() {
6861
6835
  ) : null,
6862
6836
  /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
6863
6837
  /* @__PURE__ */ jsx(BlockStylingProps, {}),
6864
- /* @__PURE__ */ jsx(StylingHelpers, {}),
6865
6838
  /* @__PURE__ */ jsxs(Accordion, { defaultValue: ["Styles"], type: "multiple", className: "w-full", children: [
6866
6839
  o && /* @__PURE__ */ jsx(StylingGroup, { section: FLEX_CHILD_SECTION, showAccordian: o || n }),
6867
6840
  n && /* @__PURE__ */ jsx(StylingGroup, { section: GRID_CHILD_SECTION, showAccordian: o || n }),
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.4",
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.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.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",