@chaibuilder/sdk 1.3.0-beta.8 → 1.3.0-beta.9

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.
Files changed (63) hide show
  1. package/dist/CodeEditor-CTpbkvn0.cjs +1 -0
  2. package/dist/CodeEditor-ChxA5nBg.js +77 -0
  3. package/dist/STRINGS-eiGM83kj.js +7 -0
  4. package/dist/STRINGS-ew98weUe.cjs +1 -0
  5. package/dist/Topbar-QwR6PKnl.cjs +1 -0
  6. package/dist/Topbar-z1o2yz-v.js +113 -0
  7. package/dist/UnsplashImages-BZ4Uvn_u.cjs +1 -0
  8. package/dist/UnsplashImages-BiXwCeGg.js +189 -0
  9. package/dist/UploadImages-BeAGmTnm.js +101 -0
  10. package/dist/UploadImages-e9ItP1o-.cjs +1 -0
  11. package/dist/context-menu-BbqLeYFX.js +979 -0
  12. package/dist/context-menu-DfAXjmc8.cjs +1 -0
  13. package/dist/controls-C4n5ycp4.cjs +1 -0
  14. package/dist/controls-Com-zYCq.js +234 -0
  15. package/dist/core.cjs +1 -82
  16. package/dist/core.d.ts +8 -4
  17. package/dist/core.js +74 -74
  18. package/dist/iconBase-Cn2BsTrq.cjs +1 -0
  19. package/dist/iconBase-DHfFLkem.js +124 -0
  20. package/dist/index-Cu1kFTGh.cjs +63 -0
  21. package/dist/index-D1NbGHAC.js +9318 -0
  22. package/dist/jsx-runtime-BYECrxsp.cjs +30 -0
  23. package/dist/jsx-runtime-DGlMoOmv.js +630 -0
  24. package/dist/plugin-BOEoR5jk.js +44 -0
  25. package/dist/plugin-COMQcYlW.cjs +1 -0
  26. package/dist/plugin-Dw854zFv.js +107 -0
  27. package/dist/plugin-I9XxF65G.cjs +1 -0
  28. package/dist/render.cjs +2 -208
  29. package/dist/render.js +125 -171
  30. package/dist/runtime.cjs +1 -26
  31. package/dist/runtime.js +16 -16
  32. package/dist/style.css +2 -1529
  33. package/dist/tailwind.cjs +1 -78
  34. package/dist/tailwind.js +19 -21
  35. package/dist/ui.cjs +1 -392
  36. package/dist/ui.js +257 -268
  37. package/dist/web-blocks.cjs +3 -1241
  38. package/dist/web-blocks.js +555 -764
  39. package/package.json +1 -1
  40. package/dist/CodeEditor-1LboGb1I.cjs +0 -91
  41. package/dist/CodeEditor-BKgZeXwz.js +0 -91
  42. package/dist/STRINGS-3Sn_NeX1.cjs +0 -9
  43. package/dist/STRINGS-DdpfVlsV.js +0 -10
  44. package/dist/Topbar-B8IS6y4H.js +0 -135
  45. package/dist/Topbar-DXC7DFU1.cjs +0 -135
  46. package/dist/UnsplashImages-CjJ5szAy.cjs +0 -215
  47. package/dist/UnsplashImages-Ck9qpKR0.js +0 -215
  48. package/dist/UploadImages-DW1mj4MB.cjs +0 -117
  49. package/dist/UploadImages-DgAMZ8GR.js +0 -117
  50. package/dist/context-menu-BLbuduri.cjs +0 -1073
  51. package/dist/context-menu-BgtRnByf.js +0 -1042
  52. package/dist/controls-8EZmm0Ns.js +0 -234
  53. package/dist/controls-DaW52RjX.cjs +0 -233
  54. package/dist/iconBase-BSrIcOaG.cjs +0 -146
  55. package/dist/iconBase-CWgVxu0A.js +0 -147
  56. package/dist/index-Bjw2sUN2.cjs +0 -12139
  57. package/dist/index-D8_rAW8B.js +0 -12124
  58. package/dist/jsx-runtime-B6vEU3CM.cjs +0 -925
  59. package/dist/jsx-runtime-ClFauRgV.js +0 -926
  60. package/dist/plugin-BYwesM58.cjs +0 -54
  61. package/dist/plugin-BiDLHDo3.cjs +0 -114
  62. package/dist/plugin-BukD7GJR.js +0 -115
  63. package/dist/plugin-tVAEvXiS.js +0 -55
package/dist/render.js CHANGED
@@ -1,209 +1,163 @@
1
- import { last, flattenDeep, memoize, filter, isEmpty, omit, isString, get, each, cloneDeep, forEach, keys, has, includes, replace } from "lodash-es";
2
- import { S as STYLES_KEY, a as SLOT_KEY } from "./STRINGS-DdpfVlsV.js";
3
- import { j as jsxRuntimeExports } from "./jsx-runtime-ClFauRgV.js";
4
- import React__default from "react";
5
- import { twMerge } from "tailwind-merge";
6
- import { getBlockComponent } from "@chaibuilder/runtime";
7
- import { createTailwindcss } from "@mhsdesign/jit-browser-tailwindcss";
8
- import forms from "@tailwindcss/forms";
9
- import typography from "@tailwindcss/typography";
10
- import aspectRatio from "@tailwindcss/aspect-ratio";
11
- import { g as getChaiBuilderTheme, c as chaiBuilderPlugin } from "./plugin-tVAEvXiS.js";
12
- const addPrefixToClasses = (classes, prefix = "") => {
13
- const classesArray = classes.replace(STYLES_KEY, "").split(",");
14
- const array = classesArray.map((item) => {
15
- const classes2 = item.split(" ");
16
- const newClasses = classes2.map((item2) => {
17
- if (item2 === "") return "";
18
- if (item2.includes(":")) {
19
- const values = item2.split(":");
20
- values[values.length - 1] = prefix + last(values);
21
- return values.join(":");
22
- }
23
- return `${prefix}${item2}`;
24
- });
25
- return newClasses.join(" ");
26
- });
27
- return flattenDeep(array).join(" ");
28
- };
29
- const convertToBlocks = (chaiFormatContent) => {
30
- if (!chaiFormatContent) return [];
1
+ import { last as T, flattenDeep as $, memoize as N, filter as _, isEmpty as d, omit as R, isString as j, get as l, each as J, cloneDeep as P, forEach as I, keys as x, has as K, includes as C, replace as L } from "lodash-es";
2
+ import { S as f, a as B } from "./STRINGS-eiGM83kj.js";
3
+ import { j as u } from "./jsx-runtime-DGlMoOmv.js";
4
+ import w from "react";
5
+ import { twMerge as W } from "tailwind-merge";
6
+ import { getBlockComponent as Y } from "@chaibuilder/runtime";
7
+ import { createTailwindcss as v } from "@mhsdesign/jit-browser-tailwindcss";
8
+ import F from "@tailwindcss/forms";
9
+ import U from "@tailwindcss/typography";
10
+ import z from "@tailwindcss/aspect-ratio";
11
+ import { g as M, c as q } from "./plugin-BOEoR5jk.js";
12
+ const D = (t, r = "") => {
13
+ const s = t.replace(f, "").split(",").map((n) => n.split(" ").map((a) => {
14
+ if (a === "") return "";
15
+ if (a.includes(":")) {
16
+ const c = a.split(":");
17
+ return c[c.length - 1] = r + T(c), c.join(":");
18
+ }
19
+ return `${r}${a}`;
20
+ }).join(" "));
21
+ return $(s).join(" ");
22
+ }, ft = (t) => {
23
+ if (!t) return [];
31
24
  try {
32
- const blocks = JSON.parse(removeAssetPrefix(chaiFormatContent));
33
- return blocks.filter((block) => !block._type.startsWith("@chai"));
34
- } catch (error) {
25
+ return JSON.parse(G(t)).filter((e) => !e._type.startsWith("@chai"));
26
+ } catch {
35
27
  return [{ _type: "Paragraph", _id: "error", content: "Invalid JSON. Please check the JSON string." }];
36
28
  }
37
29
  };
38
- function removeAssetPrefix(input) {
39
- const regex = /(asset:\/\/|https:\/\/asset\.localhost\/)(?:localhost\/)?[^"']+/g;
40
- return input.replace(regex, (match) => {
41
- const decodedUrl = decodeURIComponent(match);
42
- const publicIndex = decodedUrl.indexOf("public");
43
- if (publicIndex !== -1) {
44
- return decodedUrl.substring(publicIndex + 6);
45
- }
46
- return decodedUrl;
30
+ function G(t) {
31
+ const r = /(asset:\/\/|https:\/\/asset\.localhost\/)(?:localhost\/)?[^"']+/g;
32
+ return t.replace(r, (e) => {
33
+ const s = decodeURIComponent(e), n = s.indexOf("public");
34
+ return n !== -1 ? s.substring(n + 6) : s;
47
35
  });
48
36
  }
49
- const getSlots = (block) => {
50
- const slots = {};
51
- Object.keys(block).forEach((key) => {
52
- if (isString(block[key]) && block[key].startsWith(SLOT_KEY)) {
53
- slots[key] = block[key].replace(SLOT_KEY, "").split(",");
54
- }
55
- });
56
- return slots;
57
- };
58
- const generateClassNames = memoize((styles, classPrefix) => {
59
- const stylesArray = styles.replace(STYLES_KEY, "").split(",");
60
- const classes = twMerge(stylesArray[0], stylesArray[1]);
61
- if (classPrefix === "") return classes.replace(STYLES_KEY, "").trim();
62
- return addPrefixToClasses(classes, classPrefix).replace(STYLES_KEY, "").trim();
37
+ const H = (t) => {
38
+ const r = {};
39
+ return Object.keys(t).forEach((e) => {
40
+ j(t[e]) && t[e].startsWith(B) && (r[e] = t[e].replace(B, "").split(","));
41
+ }), r;
42
+ }, Q = N((t, r) => {
43
+ const e = t.replace(f, "").split(","), s = W(e[0], e[1]);
44
+ return r === "" ? s.replace(f, "").trim() : D(s, r).replace(f, "").trim();
63
45
  });
64
- function getElementAttrs(block, key) {
65
- const attrs = get(block, `${key}_attrs`, {});
66
- if (has(attrs, "data-ai-key")) {
67
- delete attrs["data-ai-key"];
68
- }
69
- const attrsKeys = keys(attrs).join(" ");
70
- if (includes(attrsKeys, "x-show") && !includes(attrsKeys, "x-transition")) {
71
- attrs["x-transition"] = "";
72
- }
73
- return attrs;
46
+ function V(t, r) {
47
+ const e = l(t, `${r}_attrs`, {});
48
+ K(e, "data-ai-key") && delete e["data-ai-key"];
49
+ const s = x(e).join(" ");
50
+ return C(s, "x-show") && !C(s, "x-transition") && (e["x-transition"] = ""), e;
74
51
  }
75
- function getStyleAttrs(block, classPrefix) {
76
- const styles = {};
77
- Object.keys(block).forEach((key) => {
78
- if (isString(block[key]) && block[key].startsWith(STYLES_KEY)) {
79
- const classes = generateClassNames(block[key], classPrefix);
80
- styles[key] = {
81
- className: classes,
82
- ...getElementAttrs(block, key)
52
+ function X(t, r) {
53
+ const e = {};
54
+ return Object.keys(t).forEach((s) => {
55
+ if (j(t[s]) && t[s].startsWith(f)) {
56
+ const n = Q(t[s], r);
57
+ e[s] = {
58
+ className: n,
59
+ ...V(t, s)
83
60
  };
84
61
  }
85
- });
86
- return styles;
62
+ }), e;
87
63
  }
88
- function applyBindings(block, chaiData) {
89
- const bindings = get(block, "_bindings", {});
90
- if (isEmpty(bindings)) return { ...block };
91
- each(bindings, (value, key) => {
92
- if (isString(value) && get(chaiData, value, null)) {
93
- block[key] = get(chaiData, value, null);
94
- }
95
- });
96
- return block;
64
+ function Z(t, r) {
65
+ const e = l(t, "_bindings", {});
66
+ return d(e) ? { ...t } : (J(e, (s, n) => {
67
+ j(s) && l(r, s, null) && (t[n] = l(r, s, null));
68
+ }), t);
97
69
  }
98
- function applyLanguage(_block, lang, blockDefinition) {
99
- if (isEmpty(lang)) return _block;
100
- const block = cloneDeep(_block);
101
- forEach(keys(block), (key) => {
102
- if (get(blockDefinition, ["props", key, "i18n"]) && !isEmpty(lang)) {
103
- block[key] = get(block, `${key}-${lang}`, block[key]);
104
- }
105
- });
106
- return block;
70
+ function b(t, r, e) {
71
+ if (d(r)) return t;
72
+ const s = P(t);
73
+ return I(x(s), (n) => {
74
+ l(e, ["props", n, "i18n"]) && !d(r) && (s[n] = l(s, `${n}-${r}`, s[n]));
75
+ }), s;
107
76
  }
108
- function RenderChaiBlocks({
109
- blocks,
110
- parent,
111
- classPrefix = "",
112
- externalData = {},
113
- blockModifierCallback,
114
- lang
77
+ function E({
78
+ blocks: t,
79
+ parent: r,
80
+ classPrefix: e = "",
81
+ externalData: s = {},
82
+ blockModifierCallback: n,
83
+ lang: p
115
84
  }) {
116
- const allBlocks = blocks;
117
- const getStyles = (block) => getStyleAttrs(block, classPrefix);
118
- const filteredBlocks = parent ? filter(blocks, { _parent: parent }) : filter(blocks, (block) => isEmpty(block._parent));
119
- return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: React__default.Children.toArray(
120
- filteredBlocks.map((block, index) => {
121
- const slots = getSlots(block);
122
- const attrs = {};
123
- if (!isEmpty(slots)) {
124
- Object.keys(slots).forEach((key) => {
125
- attrs[key] = React__default.Children.toArray(
126
- slots[key].map((slotId) => /* @__PURE__ */ jsxRuntimeExports.jsx(
127
- RenderChaiBlocks,
128
- {
129
- externalData,
130
- classPrefix,
131
- blocks: allBlocks,
132
- parent: slotId,
133
- lang
134
- }
135
- ))
136
- );
137
- });
138
- }
139
- const blocks2 = filter(allBlocks, { _parent: block._id });
140
- attrs.children = blocks2.length > 0 ? /* @__PURE__ */ jsxRuntimeExports.jsx(
141
- RenderChaiBlocks,
85
+ const m = t, a = (i) => X(i, e), c = r ? _(t, { _parent: r }) : _(t, (i) => d(i._parent));
86
+ return /* @__PURE__ */ u.jsx(u.Fragment, { children: w.Children.toArray(
87
+ c.map((i, O) => {
88
+ const h = H(i), y = {};
89
+ d(h) || Object.keys(h).forEach((o) => {
90
+ y[o] = w.Children.toArray(
91
+ h[o].map((S) => /* @__PURE__ */ u.jsx(
92
+ E,
93
+ {
94
+ externalData: s,
95
+ classPrefix: e,
96
+ blocks: m,
97
+ parent: S,
98
+ lang: p
99
+ }
100
+ ))
101
+ );
102
+ });
103
+ const A = _(m, { _parent: i._id });
104
+ y.children = A.length > 0 ? /* @__PURE__ */ u.jsx(
105
+ E,
142
106
  {
143
- externalData,
144
- classPrefix,
145
- parent: block._id,
146
- blocks: allBlocks,
147
- lang
107
+ externalData: s,
108
+ classPrefix: e,
109
+ parent: i._id,
110
+ blocks: m,
111
+ lang: p
148
112
  }
149
113
  ) : null;
150
- const blockDefinition = getBlockComponent(block._type);
151
- if (blockDefinition !== null) {
152
- let syncedBlock = block;
153
- const Component = blockDefinition.component;
154
- syncedBlock = { ...blockDefinition.defaults, ...block };
155
- if (blockModifierCallback) {
156
- syncedBlock = blockModifierCallback(syncedBlock);
157
- }
158
- return React__default.createElement(
159
- Component,
160
- omit(
114
+ const g = Y(i._type);
115
+ if (g !== null) {
116
+ let o = i;
117
+ const S = g.component;
118
+ return o = { ...g.defaults, ...i }, n && (o = n(o)), w.createElement(
119
+ S,
120
+ R(
161
121
  {
162
122
  blockProps: {},
163
- inBuilder: false,
164
- ...syncedBlock,
165
- index,
166
- ...applyBindings(applyLanguage(block, lang, blockDefinition), externalData),
167
- ...getStyles(syncedBlock),
168
- ...attrs
123
+ inBuilder: !1,
124
+ ...o,
125
+ index: O,
126
+ ...Z(b(i, p, g), s),
127
+ ...a(o),
128
+ ...y
169
129
  },
170
130
  ["_parent"]
171
131
  )
172
132
  );
173
133
  }
174
- return /* @__PURE__ */ jsxRuntimeExports.jsxs("noscript", { children: [
175
- block._type,
134
+ return /* @__PURE__ */ u.jsxs("noscript", { children: [
135
+ i._type,
176
136
  " not found"
177
137
  ] });
178
138
  })
179
139
  ) });
180
140
  }
181
- async function getTailwindCSS(theme, markupString, safelist = [], prefix = "", includeBaseStyles = false) {
182
- const tailwind = createTailwindcss({
141
+ async function k(t, r, e = [], s = "", n = !1) {
142
+ return await v({
183
143
  tailwindConfig: {
184
144
  darkMode: "class",
185
- safelist,
186
- theme: { extend: getChaiBuilderTheme(theme) },
187
- plugins: [forms, typography, aspectRatio, chaiBuilderPlugin],
188
- corePlugins: { preflight: includeBaseStyles },
189
- ...prefix ? { prefix: `${prefix}` } : {}
145
+ safelist: e,
146
+ theme: { extend: M(t) },
147
+ plugins: [F, U, z, q],
148
+ corePlugins: { preflight: n },
149
+ ...s ? { prefix: `${s}` } : {}
190
150
  }
191
- });
192
- return await tailwind.generateStylesFromContent(
193
- ` ${includeBaseStyles ? "@tailwind base;" : ""}
151
+ }).generateStylesFromContent(
152
+ ` ${n ? "@tailwind base;" : ""}
194
153
  @tailwind components;
195
154
  @tailwind utilities;`,
196
- markupString
155
+ r
197
156
  );
198
157
  }
199
- const getBlocksTailwindCSS = (blocks, theme, includeBaseStyles = false) => {
200
- return getTailwindCSS(theme, [replace(JSON.stringify(blocks), /#styles:,?/g, "")], [], "", includeBaseStyles);
201
- };
202
- const getStylesForBlocks = async (blocks, theme = {}, includeBaseStyles = true) => {
203
- return await getBlocksTailwindCSS(blocks, theme, includeBaseStyles);
204
- };
158
+ const tt = (t, r, e = !1) => k(r, [L(JSON.stringify(t), /#styles:,?/g, "")], [], "", e), dt = async (t, r = {}, e = !0) => await tt(t, r, e);
205
159
  export {
206
- RenderChaiBlocks,
207
- convertToBlocks,
208
- getStylesForBlocks
160
+ E as RenderChaiBlocks,
161
+ ft as convertToBlocks,
162
+ dt as getStylesForBlocks
209
163
  };
package/dist/runtime.cjs CHANGED
@@ -1,26 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const runtime = require("@chaibuilder/runtime");
4
- const controls = require("./controls-DaW52RjX.cjs");
5
- exports.Checkbox = controls.c;
6
- exports.Code = controls.l;
7
- exports.Color = controls.h;
8
- exports.Icon = controls.q;
9
- exports.Image = controls.x;
10
- exports.InfoField = controls.u;
11
- exports.Link = controls.w;
12
- exports.List = controls.S;
13
- exports.Model = controls.b;
14
- exports.MultilineText = controls.f;
15
- exports.Numeric = controls.s;
16
- exports.RichText = controls.m;
17
- exports.SelectOption = controls.y;
18
- exports.SingleLineText = controls.g;
19
- exports.Slot = controls.r;
20
- exports.Styles = controls.T;
21
- Object.keys(runtime).forEach((k) => {
22
- if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
23
- enumerable: true,
24
- get: () => runtime[k]
25
- });
26
- });
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@chaibuilder/runtime"),e=require("./controls-C4n5ycp4.cjs");exports.Checkbox=e.c;exports.Code=e.l;exports.Color=e.h;exports.Icon=e.q;exports.Image=e.x;exports.InfoField=e.u;exports.Link=e.w;exports.List=e.S;exports.Model=e.b;exports.MultilineText=e.f;exports.Numeric=e.s;exports.RichText=e.m;exports.SelectOption=e.y;exports.SingleLineText=e.g;exports.Slot=e.r;exports.Styles=e.T;Object.keys(o).forEach(t=>{t!=="default"&&!Object.prototype.hasOwnProperty.call(exports,t)&&Object.defineProperty(exports,t,{enumerable:!0,get:()=>o[t]})});
package/dist/runtime.js CHANGED
@@ -1,20 +1,20 @@
1
1
  export * from "@chaibuilder/runtime";
2
- import { c, l, h, q, x, u, w, S, b, f, s, m, y, g, r, T } from "./controls-8EZmm0Ns.js";
2
+ import { c as o, l as t, h as i, q as l, x as n, u as r, w as x, S as c, b as m, f as S, s as f, m as T, y as d, g, r as h, T as p } from "./controls-Com-zYCq.js";
3
3
  export {
4
- c as Checkbox,
5
- l as Code,
6
- h as Color,
7
- q as Icon,
8
- x as Image,
9
- u as InfoField,
10
- w as Link,
11
- S as List,
12
- b as Model,
13
- f as MultilineText,
14
- s as Numeric,
15
- m as RichText,
16
- y as SelectOption,
4
+ o as Checkbox,
5
+ t as Code,
6
+ i as Color,
7
+ l as Icon,
8
+ n as Image,
9
+ r as InfoField,
10
+ x as Link,
11
+ c as List,
12
+ m as Model,
13
+ S as MultilineText,
14
+ f as Numeric,
15
+ T as RichText,
16
+ d as SelectOption,
17
17
  g as SingleLineText,
18
- r as Slot,
19
- T as Styles
18
+ h as Slot,
19
+ p as Styles
20
20
  };