@chaibuilder/sdk 2.2.28 → 2.2.30
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.d.ts +7 -0
- package/dist/core.js +721 -676
- package/dist/render.cjs +2 -2
- package/dist/render.js +76 -68
- package/dist/web-blocks.cjs +1 -1
- package/dist/web-blocks.js +18 -24
- package/package.json +3 -3
package/dist/render.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("./plugin-CSgw-f78.cjs"),p=require("./apply-binding-DpBwzIf9.cjs"),r=require("lodash-es"),x=require("@tailwindcss/aspect-ratio"),I=require("@tailwindcss/forms"),q=require("@tailwindcss/typography");require("tailwindcss-animate");const $=require("./get-chai-builder-theme-B1tr_NJB.cjs"),E=require("@mhsdesign/jit-browser-tailwindcss"),F=require("@tailwindcss/container-queries"),m=require("react/jsx-runtime"),u=require("react"),L=require("@chaibuilder/runtime");function R(e,t){const n=e.filter(({_type:i})=>i==="GlobalBlock"||i==="PartialBlock");for(let i=0;i<n.length;i++){const l=n[i],s=r.get(l,"partialBlockId",r.get(l,"globalBlock",""));if(s==="")continue;let a=r.cloneDeep(r.get(t,s,[]));l._parent&&(a==null?void 0:a.length)>0&&(a=a.map(c=>(r.isEmpty(c._parent)&&(c._parent=l._parent),c)));const o=e.indexOf(l);e.splice(o,1,...a)}return e}const D=e=>{if(!e)return[];try{return JSON.parse(j(e)).filter(n=>!n._type.startsWith("@chai"))}catch{return[{_type:"Paragraph",_id:"error",content:"Invalid JSON. Please check the JSON string."}]}};function j(e){const t=/(asset:\/\/|https:\/\/asset\.localhost\/)(?:localhost\/)?[^"']+/g;return e.replace(t,n=>{const i=decodeURIComponent(n),l=i.indexOf("public");return l!==-1?i.substring(l+6):i})}async function M(e,t,n=[],i="",l){return await E.createTailwindcss({tailwindConfig:{darkMode:"class",safelist:n,theme:{extend:$.getChaiBuilderTheme(e)},plugins:[I,q,x,F,y.chaiBuilderPlugin],corePlugins:{preflight:l},...i?{prefix:`${i}`}:{}}}).generateStylesFromContent(` ${l?"@tailwind base;":""}
|
|
2
2
|
@tailwind components;
|
|
3
|
-
@tailwind utilities;`,t)}const O=(e,t,
|
|
3
|
+
@tailwind utilities;`,t)}const O=(e,t,n)=>{const i=JSON.stringify(e).replace(/#styles:([^"]*)/g,(l,s)=>`#styles:${s.replace(/,/g," ")}`.replace(/#styles:/g,""));return M(t,[i],[],"",n)},A=async(e,t=y.defaultThemeOptions,n=!1)=>await O(e,t,n);async function K(e){const t=await e.dataProvider({pageProps:e.pageProps,block:e.block,lang:e.lang,draft:e.draft,inBuilder:!1});return r.has(t,"$metadata")&&r.isFunction(e.dataProviderMetadataCallback)&&e.dataProviderMetadataCallback(e.block,t.$metadata),e.children({...r.omit(t,"$metadata")})}const N=()=>m.jsx("div",{}),J=e=>{const{block:t,lang:n,fallbackLang:i,children:l,externalData:s,blocks:a,draft:o,pageProps:c,dataProviderMetadataCallback:h}=e,d=L.getRegisteredChaiBlock(t._type),f=r.get(d,"component",null),k=r.get(e.repeaterData,"index",-1),P=r.get(e.repeaterData,"dataKey",""),b=n===i?"":n,g=p.applyBindingToBlockProps(p.applyLanguage(t,b,d),s,{index:k,key:P}),C=p.getBlockTagAttributes(t,!1),w=V(a,t._id,p.getBlockRuntimeProps(t._type)),S=r.has(d,"dataProvider")&&r.isFunction(d.dataProvider),_={blockProps:{},inBuilder:!1,lang:n||i,...g,...C,...w};if(r.isNull(f))return null;if(S){const T=r.get(d,"suspenseFallback",N);return m.jsx(u.Suspense,{fallback:u.createElement(T),children:m.jsx(K,{lang:n,pageProps:c,block:t,dataProvider:d.dataProvider,...h?{dataProviderMetadataCallback:h}:{},draft:o,children:v=>u.createElement(f,{..._,...v,children:l({_id:t._id,_type:t._type,...r.isArray(g.repeaterItems)?{repeaterItems:p.applyLimit(g.repeaterItems,t),$repeaterItemsKey:g.$repeaterItemsKey}:{}})})})})}return m.jsx(u.Suspense,{children:u.createElement(f,{..._,children:l({_id:t._id,_type:t._type,...r.isArray(g.repeaterItems)?{repeaterItems:p.applyLimit(g.repeaterItems,t),$repeaterItemsKey:g.$repeaterItemsKey}:{}})})})},B=e=>{const{blocks:t,parent:n,repeaterData:i}=e;let l=r.uniqBy(r.filter(t,a=>r.has(a,"_id")&&(r.isEmpty(n)?!a._parent:a._parent===n)),"_id");const s=a=>r.filter(t,o=>o._parent===a).length>0;return r.map(l,a=>a?u.createElement(J,{...e,key:a._id,block:a},({_id:o,_type:c,repeaterItems:h,$repeaterItemsKey:d})=>c==="Repeater"?r.isArray(h)&&h.map((f,k)=>u.createElement(B,{...e,parent:a._id,key:`${r.get(a,"_parent","root")}-${a._id}-${k}`,repeaterData:{index:k,dataKey:d}})):s(o)?u.createElement(B,{...e,parent:a._id,key:`${r.get(a,"_parent","root")}-${a._id}`,repeaterData:i}):null):null)},V=(e,t,n)=>r.isEmpty(n)?{}:Object.entries(n).reduce((i,[l,s])=>{const a=[];let o=r.find(e,{_id:t});for(;o;)a.push(o),o=r.find(e,{_id:o._parent});const c=r.find(a,{_type:s.block});return c&&(i[l]=r.get(c,r.get(s,"prop"),null)),i},{});function U(e){if(r.isEmpty(e.lang)&&!r.isEmpty(e.fallbackLang))throw new Error("lang prop is required when fallbackLang is provided");if(r.isEmpty(e.blocks))return null;const t=e.lang??"en",n=e.fallbackLang??t;return m.jsx(B,{...e,lang:t,fallbackLang:n})}exports.getChaiThemeCssVariables=y.getChaiThemeCssVariables;exports.getThemeFontsCSSImport=y.getThemeFontsCSSImport;exports.getThemeFontsLinkMarkup=y.getThemeFontsLinkMarkup;exports.applyChaiDataBinding=p.applyChaiDataBinding;exports.RenderChaiBlocks=U;exports.convertToBlocks=D;exports.getMergedPartialBlocks=R;exports.getStylesForBlocks=A;
|
package/dist/render.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { d as
|
|
2
|
-
import { a as
|
|
1
|
+
import { d as R, c as F } from "./plugin-BOcGV_IY.js";
|
|
2
|
+
import { a as Ce, b as Se, e as ve } from "./plugin-BOcGV_IY.js";
|
|
3
3
|
import { a as O, b as K, g as M, c as A, d as w } from "./apply-binding-CkrtJykq.js";
|
|
4
|
-
import { e as
|
|
5
|
-
import { get as
|
|
4
|
+
import { e as Ie } from "./apply-binding-CkrtJykq.js";
|
|
5
|
+
import { get as s, cloneDeep as N, isEmpty as u, has as B, isFunction as v, omit as J, isNull as E, isArray as _, uniqBy as j, filter as C, map as q, find as y } from "lodash-es";
|
|
6
6
|
import U from "@tailwindcss/aspect-ratio";
|
|
7
7
|
import V from "@tailwindcss/forms";
|
|
8
8
|
import G from "@tailwindcss/typography";
|
|
@@ -10,43 +10,43 @@ import "tailwindcss-animate";
|
|
|
10
10
|
import { g as W } from "./get-chai-builder-theme-BarMkcGH.js";
|
|
11
11
|
import { createTailwindcss as z } from "@mhsdesign/jit-browser-tailwindcss";
|
|
12
12
|
import H from "@tailwindcss/container-queries";
|
|
13
|
-
import { jsx as
|
|
14
|
-
import { Suspense as S, createElement as
|
|
15
|
-
import { getRegisteredChaiBlock as
|
|
16
|
-
function
|
|
17
|
-
const
|
|
18
|
-
for (let n = 0; n <
|
|
19
|
-
const i =
|
|
13
|
+
import { jsx as m } from "react/jsx-runtime";
|
|
14
|
+
import { Suspense as S, createElement as g } from "react";
|
|
15
|
+
import { getRegisteredChaiBlock as Q } from "@chaibuilder/runtime";
|
|
16
|
+
function ye(e, t) {
|
|
17
|
+
const r = e.filter(({ _type: n }) => n === "GlobalBlock" || n === "PartialBlock");
|
|
18
|
+
for (let n = 0; n < r.length; n++) {
|
|
19
|
+
const i = r[n], l = s(i, "partialBlockId", s(i, "globalBlock", ""));
|
|
20
20
|
if (l === "") continue;
|
|
21
|
-
let
|
|
22
|
-
i._parent && (
|
|
21
|
+
let a = N(s(t, l, []));
|
|
22
|
+
i._parent && (a == null ? void 0 : a.length) > 0 && (a = a.map((c) => (u(c._parent) && (c._parent = i._parent), c)));
|
|
23
23
|
const o = e.indexOf(i);
|
|
24
|
-
e.splice(o, 1, ...
|
|
24
|
+
e.splice(o, 1, ...a);
|
|
25
25
|
}
|
|
26
26
|
return e;
|
|
27
27
|
}
|
|
28
|
-
const
|
|
28
|
+
const _e = (e) => {
|
|
29
29
|
if (!e) return [];
|
|
30
30
|
try {
|
|
31
|
-
return JSON.parse(
|
|
31
|
+
return JSON.parse(X(e)).filter((r) => !r._type.startsWith("@chai"));
|
|
32
32
|
} catch {
|
|
33
33
|
return [{ _type: "Paragraph", _id: "error", content: "Invalid JSON. Please check the JSON string." }];
|
|
34
34
|
}
|
|
35
35
|
};
|
|
36
|
-
function
|
|
36
|
+
function X(e) {
|
|
37
37
|
const t = /(asset:\/\/|https:\/\/asset\.localhost\/)(?:localhost\/)?[^"']+/g;
|
|
38
|
-
return e.replace(t, (
|
|
39
|
-
const n = decodeURIComponent(
|
|
38
|
+
return e.replace(t, (r) => {
|
|
39
|
+
const n = decodeURIComponent(r), i = n.indexOf("public");
|
|
40
40
|
return i !== -1 ? n.substring(i + 6) : n;
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
|
-
async function
|
|
43
|
+
async function Y(e, t, r = [], n = "", i) {
|
|
44
44
|
return await z({
|
|
45
45
|
tailwindConfig: {
|
|
46
46
|
darkMode: "class",
|
|
47
|
-
safelist:
|
|
47
|
+
safelist: r,
|
|
48
48
|
theme: { extend: W(e) },
|
|
49
|
-
plugins: [V, G, U, H,
|
|
49
|
+
plugins: [V, G, U, H, F],
|
|
50
50
|
corePlugins: { preflight: i },
|
|
51
51
|
...n ? { prefix: `${n}` } : {}
|
|
52
52
|
}
|
|
@@ -57,11 +57,11 @@ async function Z(e, t, a = [], n = "", i) {
|
|
|
57
57
|
t
|
|
58
58
|
);
|
|
59
59
|
}
|
|
60
|
-
const
|
|
60
|
+
const Z = (e, t, r) => {
|
|
61
61
|
const n = JSON.stringify(e).replace(/#styles:([^"]*)/g, (i, l) => `#styles:${l.replace(/,/g, " ")}`.replace(/#styles:/g, ""));
|
|
62
|
-
return
|
|
63
|
-
}, Pe = async (e, t =
|
|
64
|
-
async function
|
|
62
|
+
return Y(t, [n], [], "", r);
|
|
63
|
+
}, Pe = async (e, t = R, r = !1) => await Z(e, t, r);
|
|
64
|
+
async function ee(e) {
|
|
65
65
|
const t = await e.dataProvider({
|
|
66
66
|
pageProps: e.pageProps,
|
|
67
67
|
block: e.block,
|
|
@@ -69,37 +69,37 @@ async function te(e) {
|
|
|
69
69
|
draft: e.draft,
|
|
70
70
|
inBuilder: !1
|
|
71
71
|
});
|
|
72
|
-
return
|
|
72
|
+
return B(t, "$metadata") && v(e.dataProviderMetadataCallback) && e.dataProviderMetadataCallback(e.block, t.$metadata), e.children({
|
|
73
73
|
...J(t, "$metadata")
|
|
74
74
|
});
|
|
75
75
|
}
|
|
76
|
-
const
|
|
77
|
-
const { block: t, lang:
|
|
78
|
-
K(t,
|
|
76
|
+
const te = () => /* @__PURE__ */ m("div", {}), ae = (e) => {
|
|
77
|
+
const { block: t, lang: r, fallbackLang: n, children: i, externalData: l, blocks: a, draft: o, pageProps: c, dataProviderMetadataCallback: f } = e, d = Q(t._type), h = s(d, "component", null), k = s(e.repeaterData, "index", -1), x = s(e.repeaterData, "dataKey", ""), p = O(
|
|
78
|
+
K(t, r === n ? "" : r, d),
|
|
79
79
|
l,
|
|
80
80
|
{ index: k, key: x }
|
|
81
|
-
), I = M(t, !1),
|
|
81
|
+
), I = M(t, !1), $ = re(a, t._id, A(t._type)), T = B(d, "dataProvider") && v(d.dataProvider), b = {
|
|
82
82
|
blockProps: {},
|
|
83
83
|
inBuilder: !1,
|
|
84
|
-
lang:
|
|
84
|
+
lang: r || n,
|
|
85
85
|
...p,
|
|
86
86
|
...I,
|
|
87
|
-
|
|
87
|
+
...$
|
|
88
88
|
};
|
|
89
89
|
if (E(h)) return null;
|
|
90
|
-
if (
|
|
91
|
-
const L =
|
|
92
|
-
return /* @__PURE__ */
|
|
93
|
-
|
|
90
|
+
if (T) {
|
|
91
|
+
const L = s(d, "suspenseFallback", te);
|
|
92
|
+
return /* @__PURE__ */ m(S, { fallback: g(L), children: /* @__PURE__ */ m(
|
|
93
|
+
ee,
|
|
94
94
|
{
|
|
95
|
-
lang:
|
|
96
|
-
pageProps:
|
|
95
|
+
lang: r,
|
|
96
|
+
pageProps: c,
|
|
97
97
|
block: t,
|
|
98
98
|
dataProvider: d.dataProvider,
|
|
99
|
-
...
|
|
99
|
+
...f ? { dataProviderMetadataCallback: f } : {},
|
|
100
100
|
draft: o,
|
|
101
|
-
children: (D) =>
|
|
102
|
-
...
|
|
101
|
+
children: (D) => g(h, {
|
|
102
|
+
...b,
|
|
103
103
|
...D,
|
|
104
104
|
children: i({
|
|
105
105
|
_id: t._id,
|
|
@@ -113,8 +113,8 @@ const ae = () => /* @__PURE__ */ u("div", {}), re = (e) => {
|
|
|
113
113
|
}
|
|
114
114
|
) });
|
|
115
115
|
}
|
|
116
|
-
return /* @__PURE__ */
|
|
117
|
-
...
|
|
116
|
+
return /* @__PURE__ */ m(S, { children: g(h, {
|
|
117
|
+
...b,
|
|
118
118
|
children: i({
|
|
119
119
|
_id: t._id,
|
|
120
120
|
_type: t._type,
|
|
@@ -124,45 +124,53 @@ const ae = () => /* @__PURE__ */ u("div", {}), re = (e) => {
|
|
|
124
124
|
} : {}
|
|
125
125
|
})
|
|
126
126
|
}) });
|
|
127
|
-
},
|
|
128
|
-
const { blocks: t, parent:
|
|
127
|
+
}, P = (e) => {
|
|
128
|
+
const { blocks: t, parent: r, repeaterData: n } = e;
|
|
129
129
|
let i = j(
|
|
130
|
-
C(t, (
|
|
130
|
+
C(t, (a) => B(a, "_id") && (u(r) ? !a._parent : a._parent === r)),
|
|
131
131
|
"_id"
|
|
132
132
|
);
|
|
133
|
-
const l = (
|
|
134
|
-
return q(i, (
|
|
135
|
-
|
|
133
|
+
const l = (a) => C(t, (o) => o._parent === a).length > 0;
|
|
134
|
+
return q(i, (a) => a ? /* @__PURE__ */ g(ae, { ...e, key: a._id, block: a }, ({ _id: o, _type: c, repeaterItems: f, $repeaterItemsKey: d }) => c === "Repeater" ? _(f) && f.map((h, k) => /* @__PURE__ */ g(
|
|
135
|
+
P,
|
|
136
136
|
{
|
|
137
137
|
...e,
|
|
138
|
-
parent:
|
|
139
|
-
key: `${
|
|
138
|
+
parent: a._id,
|
|
139
|
+
key: `${s(a, "_parent", "root")}-${a._id}-${k}`,
|
|
140
140
|
repeaterData: { index: k, dataKey: d }
|
|
141
141
|
}
|
|
142
|
-
)
|
|
143
|
-
|
|
144
|
-
|
|
142
|
+
)) : l(o) ? /* @__PURE__ */ g(
|
|
143
|
+
P,
|
|
144
|
+
{
|
|
145
|
+
...e,
|
|
146
|
+
parent: a._id,
|
|
147
|
+
key: `${s(a, "_parent", "root")}-${a._id}`,
|
|
148
|
+
repeaterData: n
|
|
149
|
+
}
|
|
150
|
+
) : null) : null);
|
|
151
|
+
}, re = (e, t, r) => u(r) ? {} : Object.entries(r).reduce((n, [i, l]) => {
|
|
152
|
+
const a = [];
|
|
145
153
|
let o = y(e, { _id: t });
|
|
146
154
|
for (; o; )
|
|
147
|
-
|
|
148
|
-
const
|
|
149
|
-
return
|
|
155
|
+
a.push(o), o = y(e, { _id: o._parent });
|
|
156
|
+
const c = y(a, { _type: l.block });
|
|
157
|
+
return c && (n[i] = s(c, s(l, "prop"), null)), n;
|
|
150
158
|
}, {});
|
|
151
159
|
function Be(e) {
|
|
152
|
-
if (
|
|
160
|
+
if (u(e.lang) && !u(e.fallbackLang))
|
|
153
161
|
throw new Error("lang prop is required when fallbackLang is provided");
|
|
154
|
-
if (
|
|
162
|
+
if (u(e.blocks))
|
|
155
163
|
return null;
|
|
156
|
-
const t = e.lang ?? "en",
|
|
157
|
-
return /* @__PURE__ */
|
|
164
|
+
const t = e.lang ?? "en", r = e.fallbackLang ?? t;
|
|
165
|
+
return /* @__PURE__ */ m(P, { ...e, lang: t, fallbackLang: r });
|
|
158
166
|
}
|
|
159
167
|
export {
|
|
160
168
|
Be as RenderChaiBlocks,
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
169
|
+
Ie as applyChaiDataBinding,
|
|
170
|
+
_e as convertToBlocks,
|
|
171
|
+
Ce as getChaiThemeCssVariables,
|
|
172
|
+
ye as getMergedPartialBlocks,
|
|
165
173
|
Pe as getStylesForBlocks,
|
|
166
|
-
|
|
167
|
-
|
|
174
|
+
Se as getThemeFontsCSSImport,
|
|
175
|
+
ve as getThemeFontsLinkMarkup
|
|
168
176
|
};
|
package/dist/web-blocks.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@chaibuilder/runtime"),i=require("react/jsx-runtime"),f=require("./common-functions-BZmyleS1.cjs"),k=require("react"),g=require("@radix-ui/react-icons"),d=require("lodash-es"),C=require("lucide-react");function v(e){const l=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(l,t,r.get?r:{enumerable:!0,get:()=>e[t]})}}return l.default=e,Object.freeze(l)}const h=v(k),x=({className:e="",inBuilder:l})=>l?i.jsx("div",{className:f.cn("pointer-events-none flex h-20 flex-col items-center justify-center p-2",e),children:i.jsx("div",{className:"h-full w-full rounded bg-gray-200 p-2 dark:bg-gray-800",children:i.jsx("div",{className:"flex h-full w-full items-center justify-center outline-dashed outline-1 -outline-offset-1 outline-gray-400 duration-300 dark:outline-gray-700"})})}):null,j=e=>{const{blockProps:l,inBuilder:t,backgroundImage:r,children:s,tag:n="div",styles:a}=e;let c=s;s||(c=i.jsx(x,{inBuilder:t}));let p={};return r&&(p={backgroundImage:`url(${r})`}),h.createElement(n,{...l,...a,style:p},c)},L={type:"Box",description:"Similar to a div or section elements in HTML",label:"Box",category:"core",group:"basic",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),backgroundImage:{type:"string",default:"",title:"Background Image",ui:{"ui:widget":"image"}},tag:{type:"string",default:"div",title:"Tag",oneOf:[{const:"div",title:"div"},{const:"header",title:"header"},{const:"footer",title:"footer"},{const:"section",title:"section"},{const:"article",title:"article"},{const:"aside",title:"aside"},{const:"main",title:"main"},{const:"nav",title:"nav"},{const:"figure",title:"figure"},{const:"details",title:"details"},{const:"summary",title:"summary"},{const:"dialog",title:"dialog"},{const:"strike",title:"strike"},{const:"caption",title:"caption"},{const:"legend",title:"legend"},{const:"figcaption",title:"figcaption"},{const:"mark",title:"mark"}]}}}),canAcceptBlock:()=>!0},_=e=>{const{blockProps:l,iconSize:t,icon:r,content:s,styles:n,children:a,iconPos:c,link:p,inBuilder:u}=e,b=r,y=a||i.jsxs(i.Fragment,{children:[i.jsx("span",{"data-ai-key":"content",children:s}),b&&i.jsx("div",{style:{width:t+"px"},className:c+" "+(c==="order-first"?"mr-2":"ml-2")||"",dangerouslySetInnerHTML:{__html:b}})]}),m=k.createElement("button",{...l,...n,type:"button","aria-label":s},y);return d.isEmpty(d.get(p,"href"))?m:u?i.jsx("span",{children:m}):i.jsx("a",{"aria-label":s,href:d.get(p,"href")||"/",target:d.get(p,"target","_self"),children:m})},T={type:"Button",description:"similar to a button element in HTML",label:"Button",category:"core",icon:g.ButtonIcon,group:"basic",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp("text-primary-foreground bg-primary px-4 py-2 rounded-lg flex items-center"),content:{type:"string",title:"Button label",default:"Button"},icon:{type:"string",title:"Icon",default:"",ui:{"ui:widget":"icon"}},iconSize:{type:"number",title:"Icon size",default:16},iconPos:{type:"string",title:"Icon position",default:"order-last",enum:["order-first","order-last"]},link:{type:"object",properties:{type:{type:"string"},href:{type:"string"},target:{type:"string"}},default:{type:"url",href:"",target:"_self"},ui:{"ui:field":"link"}}}}),i18nProps:["content"],aiProps:["content"]},E=e=>{const{blockProps:l,iconSize:t,icon:r,content:s,styles:n}=e,a=r,c=i.jsxs(i.Fragment,{children:[i.jsx("span",{"data-ai-key":"content",children:s}),a&&i.jsx("div",{style:{width:t+"px"},dangerouslySetInnerHTML:{__html:a}})]});return k.createElement("button",{...l,...n,type:"button","aria-label":s},c)},N={type:"CopyButton",description:"A copy button component",label:"Copy Button",category:"core",icon:g.CopyIcon,group:"basic",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp("p-2 rounded-md flex items-center"),content:{type:"string",title:"Button label",default:"Button"},icon:{type:"string",title:"Icon",default:"<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='lucide lucide-copy'><path d='M8 17L19 8M8 17V7a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v10'/></svg>",ui:{"ui:widget":"icon"}},iconSize:{type:"number",title:"Icon size",default:20}}}),i18nProps:["content"],aiProps:["content"]},R=e=>{const{blockProps:l,styles:t,htmlCode:r,inBuilder:s}=e;return s?i.jsxs("div",{className:"relative",children:[s?i.jsx("div",{...l,...t,className:"absolute z-20 h-full w-full"}):null,h.createElement("div",{...t,dangerouslySetInnerHTML:{__html:r.replace(/<script.*?>.*?<\/script>/g,"")}})]}):h.createElement("div",{...l,...t,dangerouslySetInnerHTML:{__html:r}})},M={type:"CustomHTML",description:"similar to a div or section elements in HTML",label:"Custom HTML",category:"core",icon:g.CodeIcon,group:"advanced",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),htmlCode:{type:"string",default:"<div><p>Enter your HTML code here...</p></div>",ui:{"ui:widget":"code"}}}})},$=e=>{const{scripts:l,inBuilder:t,blockProps:r}=e;return t?i.jsx("div",{...r,children:i.jsx("div",{className:f.cn("pointer-events-none flex flex-col items-center justify-center p-2",""),children:i.jsx("div",{className:"h-full w-full rounded bg-gray-200 p-1 dark:bg-gray-800",children:i.jsx("p",{className:"text-left text-xs text-gray-400",children:"Scripts will be only executed in preview and live mode. Place your script at the bottom of the"})})})}):i.jsx("div",{dangerouslySetInnerHTML:{__html:l}})},A={type:"CustomScript",description:"similar to a script element in HTML",label:"Custom Script",category:"core",icon:C.FileCode,group:"advanced",...o.registerChaiBlockSchema({properties:{scripts:{type:"string",title:"Script",default:"",format:"code",placeholder:"<script>console.log('Hello, world!');<\/script>"}}})},H=e=>{const{blockProps:l,styles:t}=e;return k.createElement("hr",{...t,...l})},U={type:"Divider",description:"A horizontal line component",label:"Divider",category:"core",icon:g.DividerHorizontalIcon,group:"basic",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp("bg-gray-900 h-0.5 py-2 my-1")}})},D=e=>{const{blockProps:l,styles:t,backgroundImage:r}=e;let s={};return r&&(s={backgroundImage:`url(${r})`}),h.createElement("div",{...l,...t,style:s})},q={type:"EmptyBox",description:"A box component with no children",label:"Empty Box",category:"core",group:"basic",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),backgroundImage:{type:"string",title:"Background Image",default:"",ui:{"ui:widget":"image"}}}})},z=e=>{const{blockProps:l,fieldName:t,label:r,styles:s,inputStyles:n,required:a,checked:c,showLabel:p=!0}=e,u=f.generateUUID();return p?i.jsxs("div",{...s,...l,children:[i.jsx("input",{...n,name:t,id:u,type:"checkbox",required:a,defaultChecked:c}),r&&i.jsx("label",{htmlFor:u,children:r})]}):i.jsx("input",{id:u,...l,...n,...s,type:"checkbox",required:a,name:t})},F={type:"Checkbox",label:"web_blocks.checkbox",category:"core",icon:g.CheckboxIcon,group:"form",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp("flex items-center gap-x-2"),inputStyles:o.StylesProp(""),fieldName:{type:"string",title:"Field Name",default:"fieldName"},label:{type:"string",title:"Label",default:"Label"},checked:{type:"boolean",title:"Checked",default:!1},required:{type:"boolean",title:"Required",default:!1},showLabel:{type:"boolean",title:"Show Label",default:!0}}}),aiProps:["label"],i18nProps:["label"]},V=e=>{const{children:l,blockProps:t,errorMessage:r,successMessage:s,action:n,styles:a,inBuilder:c}=e;let p=l;l||(p=i.jsx(x,{inBuilder:c}));const u={"x-data":"{}","x-on:submit.prevent":"post"},b={"x-html":"",":class":"{'text-red-500': formStatus === 'ERROR', 'text-green-500': formStatus === 'SUCCESS'}"};return i.jsxs("form",{...u,"data-error":r,"data-success":s,method:"post",action:n,...t,...a,children:[i.jsx("div",{...b}),p]})},O={type:"Form",label:"Form",category:"core",icon:C.GroupIcon,group:"form",blocks:()=>[{_type:"Form",_id:"form",styles:"#styles:p-1 space-y-2,"},{_type:"Input",_id:"form_input",_parent:"form",styles:"#styles:,"},{_type:"FormButton",_id:"form_submit_btn",_parent:"form",styles:"#styles:bg-black text-white rounded px-3 py-1,"}],...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),action:{type:"string",title:"Submit URL",default:"/api/form"},errorMessage:{type:"string",title:"Error Message",default:"Something went wrong. Please try again",ui:{"ui:widget":"richtext"}},successMessage:{type:"string",title:"Success Message",default:"Thank you for your submission.",ui:{"ui:widget":"richtext"}}}}),i18nProps:["errorMessage","successMessage"],aiProps:["errorMessage","successMessage"],canAcceptBlock:()=>!0},G=e=>{const{blockProps:l,inBuilder:t,label:r,styles:s,inputStyles:n,icon:a,iconSize:c,iconPos:p}=e,u=f.generateUUID(),b={"x-bind:disabled":"formLoading"};return i.jsxs("button",{id:u,...b,...n,...s,...l||{},type:t?"button":"submit","aria-label":r,children:[r,a&&i.jsx("div",{style:{width:c+"px"},className:p+" "+(p==="order-first"?"mr-2":"ml-2")||"",dangerouslySetInnerHTML:{__html:a}})]})},Y={type:"FormButton",label:"Submit Button",category:"core",icon:g.ButtonIcon,group:"form",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp("text-white bg-primary disabled:bg-gray-400 px-4 py-2 rounded-global flex items-center gap-x-2"),inputStyles:o.StylesProp(""),label:{type:"string",title:"Label",default:"Submit",ai:!0,i18n:!0},icon:{type:"string",title:"Icon",default:"",ui:{"ui:widget":"icon"}},iconSize:{type:"number",title:"Icon size",default:24},iconPos:{type:"string",title:"Icon Position",default:"order-last",enum:["order-first","order-last"]}}}),i18nProps:["label"],aiProps:["label"]},W=e=>{const{blockProps:l,fieldName:t,label:r,placeholder:s,styles:n,inputStyles:a,showLabel:c,required:p,inputType:u,autocomplete:b}=e,y=f.generateUUID();return c?i.jsxs("div",{...n,...l,children:[c&&i.jsx("label",{htmlFor:y,children:r}),i.jsx("input",{name:t,...a,id:y,type:u,placeholder:s,required:p,autoComplete:b?"on":"off"})]}):i.jsx("input",{id:y,name:t,...l,...a,...n,type:u,placeholder:s,required:p,autoComplete:b?"on":"off"})},X={type:"Input",label:"web_blocks.input",category:"core",icon:g.InputIcon,group:"form",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),inputStyles:o.StylesProp("w-full p-1"),fieldName:{type:"string",title:"Field Name",default:"fieldName"},showLabel:{type:"boolean",title:"Show Label",default:!0},label:{type:"string",title:"Label",default:"Label",ai:!0,i18n:!0},placeholder:{type:"string",title:"Placeholder",default:"Placeholder"},inputType:{type:"string",title:"Input Type",default:"text",enum:["text","email","password","number","tel","hidden","range","color","date","time","name","postal-code"]},required:{type:"boolean",title:"Required",default:!1},autocomplete:{type:"boolean",title:"Autocomplete",default:!0}}}),aiProps:["label","placeholder"],i18nProps:["label","placeholder"]},J=e=>{const{blockProps:l,content:t,styles:r,children:s}=e,n={...r,...l};return s?h.createElement("label",n,s):h.createElement("label",{...n,dangerouslySetInnerHTML:{__html:t}})},Q={type:"Label",label:"Label",category:"core",icon:g.LetterCaseToggleIcon,group:"form",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(),content:{type:"string",title:"Content",default:""}}}),aiProps:["content"],i18nProps:["content"]},Z=e=>{const{blockProps:l,fieldName:t,label:r,styles:s,inputStyles:n,required:a,checked:c,showLabel:p=!0}=e,u=f.generateUUID();return p?i.jsxs("div",{...s,...l,children:[i.jsx("input",{...n,name:t,id:u,type:"radio",required:a,defaultChecked:c}),r&&i.jsx("label",{htmlFor:u,children:r})]}):i.jsx("input",{id:u,...l,...n,...s,type:"radio",required:a,checked:c,name:t})},K={type:"Radio",label:"web_blocks.radio",category:"core",icon:g.RadiobuttonIcon,group:"form",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp("flex items-center gap-x-2"),inputStyles:o.StylesProp(""),fieldName:{type:"string",title:"Field Name",default:"fieldName"},label:{type:"string",title:"Label",default:"Label"},checked:{type:"boolean",title:"Checked",default:!1},required:{type:"boolean",title:"Required",default:!1},showLabel:{type:"boolean",title:"Show Label",default:!0}}}),aiProps:["label"],i18nProps:["label"]},ee=e=>{const{blockProps:l,fieldName:t,label:r,placeholder:s,styles:n,inputStyles:a,required:c,showLabel:p,_multiple:u,options:b}=e,y=f.generateUUID();return p?i.jsxs("div",{...n,...l,children:[p&&i.jsx("label",{htmlFor:y,children:r}),i.jsxs("select",{...a,id:y,required:c,multiple:u,name:t,children:[i.jsx("option",{value:"",disabled:!0,selected:!0,hidden:!0,children:s}),d.map(b,m=>i.jsx("option",{value:m==null?void 0:m.value,children:m==null?void 0:m.label},m==null?void 0:m.value))]})]}):i.jsxs("select",{id:y,...n,...l,required:c,multiple:u,name:t,children:[i.jsx("option",{value:"",disabled:!0,selected:!0,hidden:!0,children:s}),d.map(b,m=>i.jsx("option",{value:m==null?void 0:m.value,children:m==null?void 0:m.label},m==null?void 0:m.value))]})},te={type:"Select",label:"web_blocks.select",category:"core",icon:g.DropdownMenuIcon,group:"form",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),inputStyles:o.StylesProp("w-full p-1"),fieldName:{type:"string",title:"Field Name",default:"fieldName"},showLabel:{type:"boolean",title:"Show Label",default:!0},label:{type:"string",title:"Label",default:"Label"},placeholder:{type:"string",title:"Placeholder",default:"Placeholder"},required:{type:"boolean",title:"Required",default:!1},_multiple:{type:"boolean",title:"Multiple",default:!1},options:{title:"Options",type:"array",default:[],items:{type:"object",properties:{label:{type:"string",title:"Label",default:""},value:{type:"string",title:"Value",default:""}}}}}}),aiProps:["label","placeholder"],i18nProps:["label","placeholder"]},oe=e=>{const{blockProps:l,fieldName:t,label:r,placeholder:s,styles:n,inputStyles:a,rows:c,showLabel:p,required:u}=e,b=f.generateUUID();return p?i.jsxs("div",{...n,...l,children:[p&&i.jsx("label",{htmlFor:b,children:r}),i.jsx("textarea",{name:t,...a,id:b,placeholder:s,rows:c,required:u})]}):i.jsx("textarea",{id:b,name:t,...l,...a,...n,placeholder:s,rows:c,required:u})},le={type:"TextArea",label:"web_blocks.textarea",category:"core",icon:g.InputIcon,group:"form",...o.registerChaiBlockSchema({properties:{fieldName:{type:"string",title:"Field Name",default:"fieldName"},styles:o.StylesProp(""),inputStyles:o.StylesProp("w-full p-1"),showLabel:{type:"boolean",title:"Show Label",default:!0},label:{type:"string",title:"Label",default:"Label",ui:{"ui:widget":"textarea","ui:autosize":!0,"ui:rows":3}},placeholder:{type:"string",title:"Placeholder",default:"Placeholder"},rows:{type:"number",title:"Rows",default:3},required:{type:"boolean",title:"Required",default:!1}}}),aiProps:["label","placeholder"],i18nProps:["label","placeholder"]},re=e=>{const{blockProps:l,inBuilder:t,children:r,globalBlock:s}=e;return t&&!s?i.jsxs("div",{className:"flex flex-col items-center justify-center gap-y-1 rounded-lg bg-gray-100 py-4 dark:bg-gray-800",...l,children:[i.jsxs("h1",{children:["Global Block - ",s]}),i.jsx("p",{children:"Choose a block from the sidebar to add it to this page."})]}):h.createElement("span",{...l},r)},se={type:"GlobalBlock",description:"A global block component",label:"Global Block",icon:C.GlobeIcon,category:"core",group:"basic",hidden:!0,...o.registerChaiBlockSchema({properties:{globalBlock:{type:"string",title:"Global Block",default:"",ui:{"ui:widget":"hidden"}}}})},ie=e=>{const{blockProps:l,styles:t,content:r,tag:s="h1",children:n=null}=e;return n?h.createElement(s,{...t,...l},n):h.createElement(s,{...t,...l,dangerouslySetInnerHTML:{__html:r}})},ne={type:"Heading",description:"A heading component similar to h1, h2, h3, h4, h5, h6 elements in HTML",label:"Heading",category:"core",icon:g.HeadingIcon,group:"typography",...o.registerChaiBlockSchema({properties:{tag:{type:"string",default:"h2",title:"Level",enum:["h1","h2","h3","h4","h5","h6"]},styles:o.StylesProp("text-3xl"),content:{type:"string",default:"Heading goes here",title:"Content",ui:{"ui:widget":"textarea"}}}}),aiProps:["content"],i18nProps:["content"],canAcceptBlock:e=>e==="Span"||e==="Text"},ae=e=>{const{blockProps:l,styles:t}=e;return k.createElement("br",{...l,...t})},ce={type:"LineBreak",label:"Line Break",category:"core",group:"basic",hidden:!0,...o.registerChaiBlockSchema({properties:{styles:o.StylesProp("")}}),canAcceptBlock:()=>!0,canDelete:()=>!1,canMove:()=>!1,canDuplicate:()=>!1},pe=e=>{const{blockProps:l,children:t,styles:r}=e;return t?k.createElement("table",{...l,...r},t):i.jsx(x,{})},de=e=>{const{blockProps:l,children:t,styles:r}=e;return t?k.createElement("thead",{...l,...r},t):i.jsx(x,{})},ue=e=>{const{blockProps:l,children:t,styles:r}=e;return t?k.createElement("tbody",{...l,...r},t):i.jsx(x,{})},ge=e=>{const{blockProps:l,children:t,styles:r}=e;return t?k.createElement("tr",{...l,...r},t):i.jsx(x,{})},me=e=>{const{blockProps:l,children:t,content:r,styles:s}=e;return!t&&d.isEmpty(r)?i.jsx(x,{}):t?k.createElement("td",{...l,...s},t):k.createElement("td",{...l,...s,dangerouslySetInnerHTML:{__html:r}})};o.registerChaiBlock(pe,{type:"Table",label:"Table",category:"core",group:"table",hidden:!0,icon:g.TableIcon,...o.registerChaiBlockSchema({properties:{styles:o.StylesProp("")}}),blocks:B("Table")});o.registerChaiBlock(de,{type:"TableHead",label:"Table Head",category:"core",group:"table",hidden:!0,icon:g.BorderTopIcon,...o.registerChaiBlockSchema({properties:{styles:o.StylesProp("")}}),blocks:B("TableHead")});o.registerChaiBlock(ue,{type:"TableBody",label:"Table Body",category:"core",group:"table",hidden:!0,icon:g.BorderAllIcon,...o.registerChaiBlockSchema({properties:{styles:o.StylesProp("")}}),blocks:B("TableBody")});o.registerChaiBlock(ge,{type:"TableRow",label:"Table Row",category:"core",group:"table",hidden:!0,icon:g.ViewHorizontalIcon,...o.registerChaiBlockSchema({properties:{styles:o.StylesProp("")}}),blocks:B("TableRow")});o.registerChaiBlock(me,{type:"TableCell",label:"Table Cell",category:"core",group:"table",hidden:!0,icon:g.DragHandleHorizontalIcon,...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),content:{type:"string",default:"Heading goes here",title:"Content",ui:{"ui:widget":"textarea"}}}}),blocks:B("TableCell"),i18nProps:["content"],aiProps:["content"]});function B(e){const l=(n,a)=>({_id:f.generateUUID(),_parent:n,_type:"TableCell",styles:"#styles:,",content:`${e==="TableHead"?"Table Head":"Table Cell "+a}`}),t=n=>{const a=f.generateUUID(),c={_type:"TableRow",_id:a,styles:"#styles:,border-b"};return n&&(c._parent=n),[c,l(a,"1"),l(a,"2"),l(a,"3")]},r=n=>{const a=f.generateUUID(),c={_id:a,_type:"TableHead",styles:"#styles:,font-medium"};return n&&(c._parent=n),[c,...t(a)]},s=n=>{const a=f.generateUUID(),c={_id:a,_type:"TableBody",styles:"#styles:,"};return n&&(c._parent=n),[c,...t(a),...t(a)]};if(e==="Table"){const n=f.generateUUID();return[{_id:n,_type:"Table",styles:"#styles:,w-full text-left text-gray-500 dark:text-gray-400"},...r(n),...s(n)]}return e==="TableRow"?t():e==="TableHead"?r():e==="TableBody"?s():[]}const I=(e,...l)=>({...e,className:f.cn(e.className,...l)}),ye=e=>{const{blockProps:l,icon:t,styles:r,width:s,inBuilder:n,height:a}=e,c=I(r,"");if(d.isEmpty(t))return i.jsx(x,{inBuilder:n,className:"h-8 w-14"});const p=t.replace(/<svg /g,'<svg class="w-[inherit] h-[inherit]" ');return h.createElement("span",{...l,...c,style:{width:s?`${s}px`:"auto",height:a?`${a}px`:"auto"},dangerouslySetInnerHTML:{__html:p}})},he={type:"Icon",label:"web_blocks.icon",category:"core",icon:g.SketchLogoIcon,group:"media",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),icon:{type:"string",title:"Icon",default:'<svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><path d="M8 16c4.418 0 8-3.582 8-8s-3.582-8-8-8-8 3.582-8 8 3.582 8 8 8zM8 1.5c3.59 0 6.5 2.91 6.5 6.5s-2.91 6.5-6.5 6.5-6.5-2.91-6.5-6.5 2.91-6.5 6.5-6.5zM8 9.356c1.812 0 3.535-0.481 5-1.327-0.228 2.788-2.393 4.971-5 4.971s-4.772-2.186-5-4.973c1.465 0.845 3.188 1.329 5 1.329zM4 5.5c0-0.828 0.448-1.5 1-1.5s1 0.672 1 1.5c0 0.828-0.448 1.5-1 1.5s-1-0.672-1-1.5zM10 5.5c0-0.828 0.448-1.5 1-1.5s1 0.672 1 1.5c0 0.828-0.448 1.5-1 1.5s-1-0.672-1-1.5z"></path></svg>',ui:{"ui:widget":"icon"}},width:{type:"number",default:16,title:"Width"},height:{type:"number",default:16,title:"Height"}}})},be=e=>{const{blockProps:l,image:t,mobileImage:r,styles:s,alt:n,height:a,width:c,lazyLoading:p}=e;return d.isEmpty(t)?i.jsx(x,{className:"h-36"}):i.jsxs("picture",{children:[r&&i.jsx("source",{srcSet:r,media:"(max-width: 480px)"}),i.jsx("img",{...l,...s,src:t,alt:n,loading:p?"lazy":"eager",width:c,height:a})]})},fe={type:"Image",description:"A image component",label:"Image",category:"core",icon:g.ImageIcon,group:"media",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),image:{type:"string",title:"Image",default:"https://fakeimg.pl/400x200?text=Choose&font=bebas",ui:{"ui:widget":"image"}},alt:{type:"string",title:"Alt text",default:"",ui:{"ui:placeholder":"Enter alt text"}},lazyLoading:{type:"boolean",title:"Lazy Load",default:!0},width:{type:"number",title:"Width",default:"",ui:{"ui:placeholder":"Enter width"}},height:{type:"number",title:"Height",default:"",ui:{"ui:placeholder":"Enter height"}},mobileImage:{type:"string",title:"Mobile Image",default:"",ui:{"ui:widget":"image"}},assetId:{type:"string",title:"Asset ID",default:"",ui:{"ui:widget":"hidden"}}}}),aiProps:["alt"],i18nProps:["alt"]},ke=e=>{const{blockProps:l,link:t,children:r,styles:s,inBuilder:n,content:a}=e;let c={};return!r&&d.isEmpty(a)&&(c={minHeight:"50px",display:"flex",alignItems:"center",justifyContent:"center"}),n?r?i.jsx("span",{...l,style:c,...s,children:r}):k.createElement("span",{...l,...s,style:c},a):r?i.jsx("a",{"aria-label":a,href:(t==null?void 0:t.href)||"#/",target:t==null?void 0:t.target,...l,...s,children:r}):k.createElement("a",{...l,...s,href:(t==null?void 0:t.href)||"#",target:(t==null?void 0:t.target)||"_self","aria-label":a},a)},xe={type:"Link",description:"A link component",label:"Link",category:"core",icon:g.Link1Icon,group:"basic",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),content:{type:"string",default:"Link goes here",title:"Content"},link:{type:"object",properties:{type:{type:"string"},href:{type:"string"},target:{type:"string"}},default:{type:"url",href:"",target:"_self"},ui:{"ui:field":"link"}}}}),aiProps:["content"],i18nProps:["content"],canAcceptBlock:e=>e!=="Link"},Ce=e=>{const{blockProps:l,children:t,listType:r,styles:s,tag:n,inBuilder:a}=e,c=f.cn(d.get(s,"className",""),r);return!t&&d.isEmpty(s==null?void 0:s.className)?i.jsx(x,{inBuilder:a}):h.createElement(n||(r==="list-decimal"?"ol":"ul"),{...l,...s,className:c},t)},Be={type:"List",description:"A list component",label:"List",icon:g.RowsIcon,category:"core",group:"basic",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),listType:{type:"string",title:"List Type",default:"list-none",oneOf:[{enum:["list-none"],title:"List None"},{enum:["list-disc"],title:"Disc"},{enum:["list-decimal"],title:"Decimal"}]}}}),canAcceptBlock:e=>e==="ListItem",blocks:[{_type:"List",_id:"a",listType:"list-none",styles:"#styles:,"},{_type:"ListItem",_id:"b",_parent:"a",styles:"#styles:,",content:"Item 1"},{_type:"ListItem",_id:"c",_parent:"a",styles:"#styles:,",content:"Item 2"},{_type:"ListItem",_id:"d",_parent:"a",styles:"#styles:,",content:"Item 3"}]},Se=e=>{const{blockProps:l,content:t,styles:r,children:s,tag:n}=e;return s?h.createElement(n||"li",{...r,...l},s):h.createElement(n||"li",{...r,...l,dangerouslySetInnerHTML:{__html:t}})},we={type:"ListItem",description:"A list item component",label:"List Item",icon:g.ColumnsIcon,category:"core",group:"basic",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),content:{type:"string",default:"List item",title:"Content",ui:{"ui:widget":"textarea"}}}}),i18nProps:["content"],aiProps:["content"],canAcceptBlock:e=>e!=="ListItem",canBeNested:e=>e==="List"||e==="Repeater"},Pe=e=>{const{blockProps:l,styles:t,content:r}=e;return d.isNull(e.children)?h.createElement("p",{...t,...l,dangerouslySetInnerHTML:{__html:r}}):h.createElement("p",{...t,...l},e.children)},Ie={type:"Paragraph",description:"A paragraph component",label:"Paragraph",category:"core",icon:g.TextIcon,group:"typography",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),content:{type:"string",title:"Content",default:"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse varius enim in eros elementum tristique. Duis cursus, mi quis viverra ornare, eros dolor interdum nulla, ut commodo diam libero vitae erat. Aenean faucibus nibh et justo cursus id rutrum lorem imperdiet. Nunc ut sem vitae risus tristique posuere.",ui:{"ui:widget":"textarea","ui:autosize":!0,"ui:rows":5}}}}),i18nProps:["content"],aiProps:["content"],canAcceptBlock:e=>e==="Span"||e==="Link"||e==="Text"},ve=e=>{const{blockProps:l,inBuilder:t,children:r,partialBlockId:s}=e;return t&&!s?i.jsxs("div",{className:"flex flex-col items-center justify-center gap-y-1 rounded-lg bg-gray-100 py-4 dark:bg-gray-800",...l,children:[i.jsxs("h1",{children:["Partial Block - ",s]}),i.jsx("p",{children:"Choose a block from the sidebar to add it to this page."})]}):h.createElement("span",{...l},r)},je={type:"PartialBlock",description:"A partial block component",label:"Partial Block",icon:C.GlobeIcon,category:"core",group:"basic",hidden:!0,...o.registerChaiBlockSchema({properties:{partialBlockId:{type:"string",title:"Partial Block",default:"",ui:{"ui:widget":"hidden"}}}})},S={SMALL:{1:"col-span-1",2:"col-span-2",3:"col-span-3",4:"col-span-4",5:"col-span-5",6:"col-span-6",7:"col-span-7",8:"col-span-8",9:"col-span-9",10:"col-span-10",11:"col-span-11",12:"col-span-12"},MEDIUM:{1:"md:col-span-1",2:"md:col-span-2",3:"md:col-span-3",4:"md:col-span-4",5:"md:col-span-5",6:"md:col-span-6",7:"md:col-span-7",8:"md:col-span-8",9:"md:col-span-9",10:"md:col-span-10",11:"md:col-span-11",12:"md:col-span-12"},LARGE:{1:"lg:col-span-1",2:"lg:col-span-2",3:"lg:col-span-3",4:"lg:col-span-4",5:"lg:col-span-5",6:"lg:col-span-6",7:"lg:col-span-7",8:"lg:col-span-8",9:"lg:col-span-9",10:"lg:col-span-10",11:"lg:col-span-11",12:"lg:col-span-12"}},Le=e=>{const{blockProps:l,children:t,styles:r,colSpan:s,tabletColSpan:n,desktopColSpan:a}=e,p={className:[d.get(r,"className",""),d.get(S,["SMALL",isNaN(s)||!s?6:s],""),n?d.get(S,["MEDIUM",n||s],""):"",a?d.get(S,["LARGE",n||s],""):""].join(" ")};return i.jsx("div",{...l,...r,...p,children:t||i.jsx("div",{className:"h-full min-h-12 w-full border-2 border-dashed border-gray-400 bg-gray-100 dark:bg-gray-900"})})},_e={type:"Column",description:"A column component",label:"Column",group:"basic",category:"core",icon:C.Columns,wrapper:!0,canDelete:()=>!0,canAcceptBlock:()=>!0,canBeNested:e=>e==="Row",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),colSpan:{type:"number",title:"Column Span",default:6,enum:[1,2,3,4,5,6,7,8,9,10,11,12]},tabletColSpan:{type:"number",title:"Column Span (Tablet)",default:null,enumNames:["Default",1,2,3,4,5,6,7,8,9,10,11,12],enum:[null,1,2,3,4,5,6,7,8,9,10,11,12]},desktopColSpan:{type:"number",title:"Column Span (Desktop)",default:null,enumNames:["Default",1,2,3,4,5,6,7,8,9,10,11,12],enum:[null,1,2,3,4,5,6,7,8,9,10,11,12]}}})},Te=e=>{const{blockProps:l,children:t,styles:r,gutter:s}=e,a={className:[d.get(r,"className","")," grid grid-cols-12"].join()};return typeof(r==null?void 0:r.style)=="object"?r.style.gap=`${s}px`:a.style={gap:`${s}px`},i.jsx("div",{...l,...r,...a,children:t})},Ee={type:"Row",description:"A row component",label:"Row",group:"basic",icon:C.Rows,blocks:()=>[{_type:"Row",_id:"row",styles:"#styles:,p-1"},{_type:"Column",id:"column",_parent:"row",styles:"#styles:,"},{_type:"Column",id:"column",_parent:"row",styles:"#styles:,"}],category:"core",wrapper:!0,canAcceptBlock:e=>e==="Column",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),colCount:{type:"number",default:2,minimum:0,ui:{"ui:widget":"colCount"}},gutter:{type:"number",title:"Gutter (in px)",default:16,minimum:0}}})},Ne=e=>{const{blockProps:l,content:t,styles:r}=e,s=I(r,"prose dark:prose-invert prose-p:m-0 prose-p:min-h-[1rem] prose-blockquote:m-2 prose-blockquote:ml-4 prose-ul:m-0 prose-ol:m-0 prose-li:m-0","max-w-full");return i.jsx("div",{...l,...s,dangerouslySetInnerHTML:{__html:t}})},Re={type:"RichText",description:"A rich text block",label:"Rich Text",category:"core",icon:g.CursorTextIcon,group:"typography",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),content:{type:"string",title:"Content",default:"<p>This is a rich text block. You can add text, and other content here.</p>",ui:{"ui:widget":"richtext"}}}}),aiProps:["content"],i18nProps:["content"]},Me=e=>{const{blockProps:l,styles:t,content:r,children:s=null,tag:n}=e;return s?h.createElement("span",{...t,...l},s):h.createElement(n||"span",{...t,...l,dangerouslySetInnerHTML:{__html:r||""}})},$e={type:"Span",description:"A span component",label:"Span",category:"core",group:"typography",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),content:{type:"string",title:"Content",default:"",ui:{"ui:widget":"textarea","ui:autosize":!0,"ui:rows":3}}}}),aiProps:["content"],i18nProps:["content"],canAcceptBlock:()=>!0},Ae=e=>e.inBuilder||e.forceWrapper?i.jsx("span",{...e.blockProps,children:e.content}):`${e.content}`,He={type:"Text",description:"A text component with no styling",label:"Text",hidden:!0,category:"core",group:"typography",icon:g.SpaceBetweenVerticallyIcon,...o.registerChaiBlockSchema({properties:{styles:o.StylesProp("text-black"),content:{title:"Content",type:"string",default:""}}}),aiProps:["content"],i18nProps:["content"]},Ue={type:"object",title:"Controls",default:{autoplay:!0,controls:!1,loop:!0,muted:!0},properties:{autoplay:{type:"boolean",title:"Autoplay",default:!1},controls:{type:"boolean",title:"Show Controls",default:!0},loop:{type:"boolean",title:"Loop Video",default:!1},muted:{type:"boolean",title:"Muted",default:!1}}},w=/^(https?:\/\/)?(www\.)?youtube\.com\/(watch\?v=|embed\/)([a-zA-Z0-9_-]{11})/,P=/(?:https?:\/\/)?(?:www\.)?(?:vimeo\.com\/(?:channels\/[\w]+\/|groups\/[^\/]+\/videos\/|album\/\d+\/video\/|video\/)?|player\.vimeo\.com\/video\/)(\d+)/,De=(e,l)=>{const t=d.get(l,"autoplay",!1),r=d.get(l,"controls",!1),s=d.get(l,"loop",!1),n=t||d.get(l,"muted",!0);if(w.test(e)){const a=e.match(w);if(a){const c=a[4];let p=`https://www.youtube.com/embed/${c}`,u=t?"autoplay=1":"";return u+=s?`&loop=1&playlist=${c}`:"",u+=n?"&mute=1&muted=1":"",u+=r?"&controls=1":"&controls=0",`${p}?${u}`}}if(P.test(e)){const a=e.match(P);if(a){const c=a[1];let p="";return p+=t?"autoplay=1":"",p+=r?"&controls=1":"&controls=0",p+=n?"&muted=1":"",p+=s?"&loop=1":"",`https://player.vimeo.com/video/${c}?${p}`}}return null},qe=e=>{const{url:l,blockProps:t,styles:r,controls:s,videoSource:n,inBuilder:a}=e,c=De(l,s);return i.jsxs("div",{...d.omit(r,"className"),className:"relative w-full overflow-hidden",style:{paddingBottom:"56.25%"},children:[!c&&a?i.jsx("div",{className:"absolute flex h-full w-full items-center justify-center bg-gray-300 text-center",children:d.isEmpty(l)?`Provided ${n} video link in settings Video URL.`:`Provided ${n} video link is invalid.`}):i.jsx("iframe",{width:"100%",src:c,...d.pick(r,"className")}),a&&i.jsx("div",{...t,className:"absolute top-0 h-full w-full"})]})},ze=e=>{const{url:l,styles:t,controls:r,sources:s,poster:n,blockProps:a}=e;let c=n;const p=[...d.get(s,"srcsets",[])||[]];l&&typeof l=="string"&&p.push({url:l,width:"9999"});const u=p.sort((y,m)=>parseInt(y.width)-parseInt(m.width)).filter(y=>!d.isEmpty(y.url)&&!d.isEmpty(y.width));u.length===0&&!c&&(c="https://placehold.co/300x200/EEE/ccc?text=Choose%20Video");const b=d.get(r,"autoplay",!1)||d.get(r,"muted",!0);return(c||!d.isEmpty(u))&&i.jsx("div",{className:"relative w-full overflow-hidden",style:{paddingBottom:"56.25%"},children:k.createElement("video",{...t,...a,key:JSON.stringify(u),controls:d.get(r,"controls",!1),autoPlay:d.get(r,"autoplay",!1),loop:d.get(r,"loop",!1),poster:c,...b?{muted:!0}:{}},u.map(y=>{if(!y.url||y.url.length<4||isNaN(y.width))return null;const m=`(max-width: ${y.width}px)`;return i.jsx("source",{src:y.url,media:m,type:y.type},y.url)}),"Your browser does not support the video tag.")})},Fe=e=>{const{videoSource:l}=e;return l==="Custom"?i.jsx(ze,{...e}):l==="Youtube"||l==="Vimeo"?i.jsx(qe,{...e}):i.jsxs("div",{children:["Invalid video source : ",l]})},Ve={type:"Video",label:"Video",category:"core",icon:g.VideoIcon,group:"media",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp("absolute h-full w-full object-cover"),videoSource:{type:"string",default:"Custom",enum:["Custom","Youtube","Vimeo"],title:"Video source"}},allOf:[{if:{properties:{videoSource:{const:"Custom"}}},then:{properties:{url:{type:"string",title:"Video URL",default:""},poster:{type:"string",title:"Poster URL",default:""},sources:{type:"object",default:{srcsets:[]}},controls:{...Ue}}}},{if:{properties:{videoSource:{const:"Youtube"}}},then:{properties:{url:{type:"string",title:"Youtube Video URL",default:""}}}},{if:{properties:{videoSource:{const:"Vimeo"}}},then:{properties:{url:{type:"string",title:"Vimeo Video URL",default:""}}}}],ui:{url:{"ui:placeholder":"Enter Video URL"},sources:{"ui:field":"sources"},poster:{"ui:placeholder":"Enter poster URL"}}}),i18nProps:["url"]},Oe=({children:e,tag:l,blockProps:t,styles:r,inBuilder:s,$loading:n})=>{let a=e;return d.isEmpty(a)&&s&&(a=i.jsx("div",{className:"col-span-3 flex items-center justify-center bg-orange-50 p-5 text-sm text-muted-foreground",children:"Choose a collection to display items"})),h.createElement(l,{...t,...r},n?Array.from({length:2}).map((c,p)=>i.jsxs("div",{className:"animate-pulse rounded-md bg-primary/10 p-5",children:[i.jsx("div",{className:"h-6 w-1/2 rounded-md bg-primary/10"}),i.jsx("div",{className:"mt-2 h-4 w-1/2 rounded-md bg-primary/10"})]},p)):a)},Ge={type:"Repeater",label:"Repeater",icon:g.LoopIcon,group:"basic",dataProviderMode:"live",dataProviderDependencies:["filter","sort","limit","repeaterItems"],blocks:()=>[{_id:"A",_type:"Repeater",tag:"ul"},{_id:"B",_name:"Repeater Item",_type:"RepeaterItem",parentTag:"ul",_parent:"A"}],...o.registerChaiBlockSchema({properties:{styles:o.stylesProp("grid gap-4 md:grid-cols-2 xl:grid-cols-3"),repeaterItems:{title:"Collection",type:"string",binding:"array",default:"",ui:{"ui:widget":"repeaterBinding","ui:readonly":!0}},tag:{title:"Tag",type:"string",default:"ul",enum:["div","ul","ol"]},limit:{title:"Limit",type:"number",default:3},filter:{title:"Filter by",type:"string",default:"",ui:{"ui:widget":"collectionSelect"}},sort:{title:"Sort by",type:"string",default:"",ui:{"ui:widget":"collectionSelect"}}}})},Ye=({children:e,blockProps:l,styles:t,parentTag:r,inBuilder:s})=>{let n="li";switch(r){case"ul":n="li";break;case"ol":n="li";break;default:n="div"}return!e&&s?h.createElement(n,{...l,...t},i.jsx("div",{className:"col-span-3 flex items-center justify-center bg-orange-50 p-5 text-sm text-muted-foreground",children:"Add children to repeater item"})):h.createElement(n,{...l,...t},e)},We={type:"RepeaterItem",label:"Repeater Item",icon:g.LoopIcon,hidden:!0,group:"basic",...o.registerChaiBlockSchema({properties:{styles:o.stylesProp(""),parentTag:o.closestBlockProp("Repeater","tag")}}),canAcceptBlock:e=>e!=="RepeaterItem",canDelete:()=>!1,canMove:()=>!1,canDuplicate:()=>!1},Xe=({children:e,blockProps:l,styles:t})=>h.createElement("div",{...l,...t},e),Je={type:"RepeaterEmptyState",label:"Empty State",hidden:!0,group:"basic",...o.registerChaiBlockSchema({properties:{styles:o.stylesProp("p-5 flex items-center justify-center")}}),canAcceptBlock:()=>!0,canDelete:()=>!1,canMove:()=>!1,canDuplicate:()=>!1},Qe=()=>{o.registerChaiBlock(j,L),o.registerChaiBlock(D,q),o.registerChaiBlock(_,T),o.registerChaiBlock(ie,ne),o.registerChaiBlock(Pe,Ie),o.registerChaiBlock(Me,$e),o.registerChaiBlock(Ne,Re),o.registerChaiBlock(ke,xe),o.registerChaiBlock(Ce,Be),o.registerChaiBlock(Se,we),o.registerChaiBlock(ye,he),o.registerChaiBlock(be,fe),o.registerChaiBlock(Fe,Ve),o.registerChaiBlock(R,M),o.registerChaiBlock($,A),o.registerChaiBlock(Ae,He),o.registerChaiBlock(V,O),o.registerChaiBlock(G,Y),o.registerChaiBlock(W,X),o.registerChaiBlock(z,F),o.registerChaiBlock(Z,K),o.registerChaiBlock(ee,te),o.registerChaiBlock(oe,le),o.registerChaiBlock(J,Q),o.registerChaiBlock(ae,ce),o.registerChaiBlock(H,U),o.registerChaiBlock(re,se),o.registerChaiBlock(ve,je),o.registerChaiBlock(Te,Ee),o.registerChaiBlock(Le,_e),o.registerChaiBlock(E,N),o.registerChaiBlock(Oe,Ge),o.registerChaiBlock(Ye,We),o.registerChaiBlock(Xe,Je)};exports.loadWebBlocks=Qe;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@chaibuilder/runtime"),i=require("react/jsx-runtime"),f=require("./common-functions-BZmyleS1.cjs"),k=require("react"),g=require("@radix-ui/react-icons"),d=require("lodash-es"),C=require("lucide-react");function v(e){const l=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(l,t,r.get?r:{enumerable:!0,get:()=>e[t]})}}return l.default=e,Object.freeze(l)}const h=v(k),x=({className:e="",inBuilder:l})=>l?i.jsx("div",{className:f.cn("pointer-events-none flex h-20 flex-col items-center justify-center p-2",e),children:i.jsx("div",{className:"h-full w-full rounded bg-gray-200 p-2 dark:bg-gray-800",children:i.jsx("div",{className:"flex h-full w-full items-center justify-center outline-dashed outline-1 -outline-offset-1 outline-gray-400 duration-300 dark:outline-gray-700"})})}):null,j=e=>{const{blockProps:l,inBuilder:t,backgroundImage:r,children:s,tag:n="div",styles:a}=e;let c=s;s||(c=i.jsx(x,{inBuilder:t}));let p={};return r&&(p={backgroundImage:`url(${r})`}),h.createElement(n,{...l,...a,style:p},c)},L={type:"Box",description:"Similar to a div or section elements in HTML",label:"Box",category:"core",group:"basic",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),backgroundImage:{type:"string",default:"",title:"Background Image",ui:{"ui:widget":"image"}},tag:{type:"string",default:"div",title:"Tag",oneOf:[{const:"div",title:"div"},{const:"header",title:"header"},{const:"footer",title:"footer"},{const:"section",title:"section"},{const:"article",title:"article"},{const:"aside",title:"aside"},{const:"main",title:"main"},{const:"nav",title:"nav"},{const:"figure",title:"figure"},{const:"details",title:"details"},{const:"summary",title:"summary"},{const:"dialog",title:"dialog"},{const:"strike",title:"strike"},{const:"caption",title:"caption"},{const:"legend",title:"legend"},{const:"figcaption",title:"figcaption"},{const:"mark",title:"mark"}]}}}),canAcceptBlock:()=>!0},_=e=>{const{blockProps:l,iconSize:t,icon:r,content:s,styles:n,children:a,iconPos:c,link:p,inBuilder:u}=e,b=r,y=a||i.jsxs(i.Fragment,{children:[i.jsx("span",{"data-ai-key":"content",children:s}),b&&i.jsx("div",{style:{width:t+"px"},className:c+" "+(c==="order-first"?"mr-2":"ml-2")||"",dangerouslySetInnerHTML:{__html:b}})]}),m=k.createElement("button",{...l,...n,type:"button","aria-label":s},y);return d.isEmpty(d.get(p,"href"))?m:u?i.jsx("span",{children:m}):i.jsx("a",{"aria-label":s,href:d.get(p,"href")||"/",target:d.get(p,"target","_self"),children:m})},T={type:"Button",description:"similar to a button element in HTML",label:"Button",category:"core",icon:g.ButtonIcon,group:"basic",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp("text-primary-foreground bg-primary px-4 py-2 rounded-lg flex items-center"),content:{type:"string",title:"Button label",default:"Button"},icon:{type:"string",title:"Icon",default:"",ui:{"ui:widget":"icon"}},iconSize:{type:"number",title:"Icon size",default:16},iconPos:{type:"string",title:"Icon position",default:"order-last",enum:["order-first","order-last"]},link:{type:"object",properties:{type:{type:"string"},href:{type:"string"},target:{type:"string"}},default:{type:"url",href:"",target:"_self"},ui:{"ui:field":"link"}}}}),i18nProps:["content"],aiProps:["content"]},E=e=>{const{blockProps:l,iconSize:t,icon:r,content:s,styles:n}=e,a=r,c=i.jsxs(i.Fragment,{children:[i.jsx("span",{"data-ai-key":"content",children:s}),a&&i.jsx("div",{style:{width:t+"px"},dangerouslySetInnerHTML:{__html:a}})]});return k.createElement("button",{...l,...n,type:"button","aria-label":s},c)},N={type:"CopyButton",description:"A copy button component",label:"Copy Button",category:"core",icon:g.CopyIcon,group:"basic",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp("p-2 rounded-md flex items-center"),content:{type:"string",title:"Button label",default:"Button"},icon:{type:"string",title:"Icon",default:"<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='lucide lucide-copy'><path d='M8 17L19 8M8 17V7a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v10'/></svg>",ui:{"ui:widget":"icon"}},iconSize:{type:"number",title:"Icon size",default:20}}}),i18nProps:["content"],aiProps:["content"]},R=e=>{const{blockProps:l,styles:t,htmlCode:r,inBuilder:s}=e;return s?i.jsxs("div",{className:"relative",children:[s?i.jsx("div",{...l,...t,className:"absolute z-20 h-full w-full"}):null,h.createElement("div",{...t,dangerouslySetInnerHTML:{__html:r.replace(/<script.*?>.*?<\/script>/g,"")}})]}):h.createElement("div",{...l,...t,dangerouslySetInnerHTML:{__html:r}})},M={type:"CustomHTML",description:"similar to a div or section elements in HTML",label:"Custom HTML",category:"core",icon:g.CodeIcon,group:"advanced",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),htmlCode:{type:"string",default:"<div><p>Enter your HTML code here...</p></div>",ui:{"ui:widget":"code"}}}})},$=e=>{const{scripts:l,inBuilder:t,blockProps:r}=e;return t?i.jsx("div",{...r,children:i.jsx("div",{className:f.cn("pointer-events-none flex flex-col items-center justify-center p-2",""),children:i.jsx("div",{className:"h-full w-full rounded bg-gray-200 p-1 dark:bg-gray-800",children:i.jsx("p",{className:"text-left text-xs text-gray-400",children:"Scripts will be only executed in preview and live mode. Place your script at the bottom of the"})})})}):i.jsx("div",{dangerouslySetInnerHTML:{__html:l}})},A={type:"CustomScript",description:"similar to a script element in HTML",label:"Custom Script",category:"core",icon:C.FileCode,group:"advanced",...o.registerChaiBlockSchema({properties:{scripts:{type:"string",title:"Script",default:"",format:"code",placeholder:"<script>console.log('Hello, world!');<\/script>"}}})},H=e=>{const{blockProps:l,styles:t}=e;return k.createElement("hr",{...t,...l})},U={type:"Divider",description:"A horizontal line component",label:"Divider",category:"core",icon:g.DividerHorizontalIcon,group:"basic",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp("bg-gray-900 h-0.5 py-2 my-1")}})},D=e=>{const{blockProps:l,styles:t,backgroundImage:r}=e;let s={};return r&&(s={backgroundImage:`url(${r})`}),h.createElement("div",{...l,...t,style:s})},q={type:"EmptyBox",description:"A box component with no children",label:"Empty Box",category:"core",group:"basic",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),backgroundImage:{type:"string",title:"Background Image",default:"",ui:{"ui:widget":"image"}}}})},z=e=>{const{blockProps:l,fieldName:t,label:r,styles:s,inputStyles:n,required:a,checked:c,showLabel:p=!0}=e,u=f.generateUUID();return p?i.jsxs("div",{...s,...l,children:[i.jsx("input",{...n,name:t,id:u,type:"checkbox",required:a,defaultChecked:c}),r&&i.jsx("label",{htmlFor:u,children:r})]}):i.jsx("input",{id:u,...l,...n,...s,type:"checkbox",required:a,name:t})},F={type:"Checkbox",label:"web_blocks.checkbox",category:"core",icon:g.CheckboxIcon,group:"form",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp("flex items-center gap-x-2"),inputStyles:o.StylesProp(""),fieldName:{type:"string",title:"Field Name",default:"fieldName"},label:{type:"string",title:"Label",default:"Label"},checked:{type:"boolean",title:"Checked",default:!1},required:{type:"boolean",title:"Required",default:!1},showLabel:{type:"boolean",title:"Show Label",default:!0}}}),aiProps:["label"],i18nProps:["label"]},V=e=>{const{children:l,blockProps:t,errorMessage:r,successMessage:s,action:n,styles:a,inBuilder:c}=e;let p=l;l||(p=i.jsx(x,{inBuilder:c}));const u={"x-data":"{}","x-on:submit.prevent":"post"},b={"x-html":"",":class":"{'text-red-500': formStatus === 'ERROR', 'text-green-500': formStatus === 'SUCCESS'}"};return i.jsxs("form",{...u,"data-error":r,"data-success":s,method:"post",action:n,...t,...a,children:[i.jsx("div",{...b}),p]})},O={type:"Form",label:"Form",category:"core",icon:C.GroupIcon,group:"form",blocks:()=>[{_type:"Form",_id:"form",styles:"#styles:p-1 space-y-2,"},{_type:"Input",_id:"form_input",_parent:"form",styles:"#styles:,"},{_type:"FormButton",_id:"form_submit_btn",_parent:"form",styles:"#styles:bg-black text-white rounded px-3 py-1,"}],...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),action:{type:"string",title:"Submit URL",default:"/api/form"},errorMessage:{type:"string",title:"Error Message",default:"Something went wrong. Please try again",ui:{"ui:widget":"richtext"}},successMessage:{type:"string",title:"Success Message",default:"Thank you for your submission.",ui:{"ui:widget":"richtext"}}}}),i18nProps:["errorMessage","successMessage"],aiProps:["errorMessage","successMessage"],canAcceptBlock:()=>!0},G=e=>{const{blockProps:l,inBuilder:t,label:r,styles:s,inputStyles:n,icon:a,iconSize:c,iconPos:p}=e,u=f.generateUUID(),b={"x-bind:disabled":"formLoading"};return i.jsxs("button",{id:u,...b,...n,...s,...l||{},type:t?"button":"submit","aria-label":r,children:[r,a&&i.jsx("div",{style:{width:c+"px"},className:p+" "+(p==="order-first"?"mr-2":"ml-2")||"",dangerouslySetInnerHTML:{__html:a}})]})},Y={type:"FormButton",label:"Submit Button",category:"core",icon:g.ButtonIcon,group:"form",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp("text-white bg-primary disabled:bg-gray-400 px-4 py-2 rounded-global flex items-center gap-x-2"),inputStyles:o.StylesProp(""),label:{type:"string",title:"Label",default:"Submit",ai:!0,i18n:!0},icon:{type:"string",title:"Icon",default:"",ui:{"ui:widget":"icon"}},iconSize:{type:"number",title:"Icon size",default:24},iconPos:{type:"string",title:"Icon Position",default:"order-last",enum:["order-first","order-last"]}}}),i18nProps:["label"],aiProps:["label"]},W=e=>{const{blockProps:l,fieldName:t,label:r,placeholder:s,styles:n,inputStyles:a,showLabel:c,required:p,inputType:u,autocomplete:b}=e,y=f.generateUUID();return c?i.jsxs("div",{...n,...l,children:[c&&i.jsx("label",{htmlFor:y,children:r}),i.jsx("input",{name:t,...a,id:y,type:u,placeholder:s,required:p,autoComplete:b?"on":"off"})]}):i.jsx("input",{id:y,name:t,...l,...a,...n,type:u,placeholder:s,required:p,autoComplete:b?"on":"off"})},X={type:"Input",label:"web_blocks.input",category:"core",icon:g.InputIcon,group:"form",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),inputStyles:o.StylesProp("w-full p-1"),fieldName:{type:"string",title:"Field Name",default:"fieldName"},showLabel:{type:"boolean",title:"Show Label",default:!0},label:{type:"string",title:"Label",default:"Label",ai:!0,i18n:!0},placeholder:{type:"string",title:"Placeholder",default:"Placeholder"},inputType:{type:"string",title:"Input Type",default:"text",enum:["text","email","password","number","tel","hidden","range","color","date","time","name","postal-code"]},required:{type:"boolean",title:"Required",default:!1},autocomplete:{type:"boolean",title:"Autocomplete",default:!0}}}),aiProps:["label","placeholder"],i18nProps:["label","placeholder"]},J=e=>{const{blockProps:l,content:t,styles:r,children:s}=e,n={...r,...l};return s?h.createElement("label",n,s):h.createElement("label",{...n,dangerouslySetInnerHTML:{__html:t}})},Q={type:"Label",label:"Label",category:"core",icon:g.LetterCaseToggleIcon,group:"form",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(),content:{type:"string",title:"Content",default:""}}}),aiProps:["content"],i18nProps:["content"]},Z=e=>{const{blockProps:l,fieldName:t,label:r,styles:s,inputStyles:n,required:a,checked:c,showLabel:p=!0}=e,u=f.generateUUID();return p?i.jsxs("div",{...s,...l,children:[i.jsx("input",{...n,name:t,id:u,type:"radio",required:a,defaultChecked:c}),r&&i.jsx("label",{htmlFor:u,children:r})]}):i.jsx("input",{id:u,...l,...n,...s,type:"radio",required:a,checked:c,name:t})},K={type:"Radio",label:"web_blocks.radio",category:"core",icon:g.RadiobuttonIcon,group:"form",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp("flex items-center gap-x-2"),inputStyles:o.StylesProp(""),fieldName:{type:"string",title:"Field Name",default:"fieldName"},label:{type:"string",title:"Label",default:"Label"},checked:{type:"boolean",title:"Checked",default:!1},required:{type:"boolean",title:"Required",default:!1},showLabel:{type:"boolean",title:"Show Label",default:!0}}}),aiProps:["label"],i18nProps:["label"]},ee=e=>{const{blockProps:l,fieldName:t,label:r,placeholder:s,styles:n,inputStyles:a,required:c,showLabel:p,_multiple:u,options:b}=e,y=f.generateUUID();return p?i.jsxs("div",{...n,...l,children:[p&&i.jsx("label",{htmlFor:y,children:r}),i.jsxs("select",{...a,id:y,required:c,multiple:u,name:t,children:[i.jsx("option",{value:"",disabled:!0,selected:!0,hidden:!0,children:s}),d.map(b,m=>i.jsx("option",{value:m==null?void 0:m.value,children:m==null?void 0:m.label},m==null?void 0:m.value))]})]}):i.jsxs("select",{id:y,...n,...l,required:c,multiple:u,name:t,children:[i.jsx("option",{value:"",disabled:!0,selected:!0,hidden:!0,children:s}),d.map(b,m=>i.jsx("option",{value:m==null?void 0:m.value,children:m==null?void 0:m.label},m==null?void 0:m.value))]})},te={type:"Select",label:"web_blocks.select",category:"core",icon:g.DropdownMenuIcon,group:"form",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),inputStyles:o.StylesProp("w-full p-1"),fieldName:{type:"string",title:"Field Name",default:"fieldName"},showLabel:{type:"boolean",title:"Show Label",default:!0},label:{type:"string",title:"Label",default:"Label"},placeholder:{type:"string",title:"Placeholder",default:"Placeholder"},required:{type:"boolean",title:"Required",default:!1},_multiple:{type:"boolean",title:"Multiple",default:!1},options:{title:"Options",type:"array",default:[],items:{type:"object",properties:{label:{type:"string",title:"Label",default:""},value:{type:"string",title:"Value",default:""}}}}}}),aiProps:["label","placeholder"],i18nProps:["label","placeholder"]},oe=e=>{const{blockProps:l,fieldName:t,label:r,placeholder:s,styles:n,inputStyles:a,rows:c,showLabel:p,required:u}=e,b=f.generateUUID();return p?i.jsxs("div",{...n,...l,children:[p&&i.jsx("label",{htmlFor:b,children:r}),i.jsx("textarea",{name:t,...a,id:b,placeholder:s,rows:c,required:u})]}):i.jsx("textarea",{id:b,name:t,...l,...a,...n,placeholder:s,rows:c,required:u})},le={type:"TextArea",label:"web_blocks.textarea",category:"core",icon:g.InputIcon,group:"form",...o.registerChaiBlockSchema({properties:{fieldName:{type:"string",title:"Field Name",default:"fieldName"},styles:o.StylesProp(""),inputStyles:o.StylesProp("w-full p-1"),showLabel:{type:"boolean",title:"Show Label",default:!0},label:{type:"string",title:"Label",default:"Label",ui:{"ui:widget":"textarea","ui:autosize":!0,"ui:rows":3}},placeholder:{type:"string",title:"Placeholder",default:"Placeholder"},rows:{type:"number",title:"Rows",default:3},required:{type:"boolean",title:"Required",default:!1}}}),aiProps:["label","placeholder"],i18nProps:["label","placeholder"]},re=e=>{const{blockProps:l,inBuilder:t,children:r,globalBlock:s}=e;return t&&!s?i.jsxs("div",{className:"flex flex-col items-center justify-center gap-y-1 rounded-lg bg-gray-100 py-4 dark:bg-gray-800",...l,children:[i.jsxs("h1",{children:["Global Block - ",s]}),i.jsx("p",{children:"Choose a block from the sidebar to add it to this page."})]}):h.createElement("span",{...l},r)},se={type:"GlobalBlock",description:"A global block component",label:"Global Block",icon:C.GlobeIcon,category:"core",group:"basic",hidden:!0,...o.registerChaiBlockSchema({properties:{globalBlock:{type:"string",title:"Global Block",default:"",ui:{"ui:widget":"hidden"}}}})},ie=e=>{const{blockProps:l,styles:t,content:r,tag:s="h1",children:n=null}=e;return n?h.createElement(s,{...t,...l},n):h.createElement(s,{...t,...l,dangerouslySetInnerHTML:{__html:r}})},ne={type:"Heading",description:"A heading component similar to h1, h2, h3, h4, h5, h6 elements in HTML",label:"Heading",category:"core",icon:g.HeadingIcon,group:"typography",...o.registerChaiBlockSchema({properties:{tag:{type:"string",default:"h2",title:"Level",enum:["h1","h2","h3","h4","h5","h6"]},styles:o.StylesProp("text-3xl"),content:{type:"string",default:"Heading goes here",title:"Content",ui:{"ui:widget":"textarea"}}}}),aiProps:["content"],i18nProps:["content"],canAcceptBlock:e=>e==="Span"||e==="Text"},ae=e=>{const{blockProps:l,styles:t}=e;return k.createElement("br",{...l,...t})},ce={type:"LineBreak",label:"Line Break",category:"core",group:"basic",hidden:!0,...o.registerChaiBlockSchema({properties:{styles:o.StylesProp("")}}),canAcceptBlock:()=>!0,canDelete:()=>!1,canMove:()=>!1,canDuplicate:()=>!1},pe=e=>{const{blockProps:l,children:t,styles:r}=e;return t?k.createElement("table",{...l,...r},t):i.jsx(x,{})},de=e=>{const{blockProps:l,children:t,styles:r}=e;return t?k.createElement("thead",{...l,...r},t):i.jsx(x,{})},ue=e=>{const{blockProps:l,children:t,styles:r}=e;return t?k.createElement("tbody",{...l,...r},t):i.jsx(x,{})},ge=e=>{const{blockProps:l,children:t,styles:r}=e;return t?k.createElement("tr",{...l,...r},t):i.jsx(x,{})},me=e=>{const{blockProps:l,children:t,content:r,styles:s}=e;return!t&&d.isEmpty(r)?i.jsx(x,{}):t?k.createElement("td",{...l,...s},t):k.createElement("td",{...l,...s,dangerouslySetInnerHTML:{__html:r}})};o.registerChaiBlock(pe,{type:"Table",label:"Table",category:"core",group:"table",hidden:!0,icon:g.TableIcon,...o.registerChaiBlockSchema({properties:{styles:o.StylesProp("")}}),blocks:B("Table")});o.registerChaiBlock(de,{type:"TableHead",label:"Table Head",category:"core",group:"table",hidden:!0,icon:g.BorderTopIcon,...o.registerChaiBlockSchema({properties:{styles:o.StylesProp("")}}),blocks:B("TableHead")});o.registerChaiBlock(ue,{type:"TableBody",label:"Table Body",category:"core",group:"table",hidden:!0,icon:g.BorderAllIcon,...o.registerChaiBlockSchema({properties:{styles:o.StylesProp("")}}),blocks:B("TableBody")});o.registerChaiBlock(ge,{type:"TableRow",label:"Table Row",category:"core",group:"table",hidden:!0,icon:g.ViewHorizontalIcon,...o.registerChaiBlockSchema({properties:{styles:o.StylesProp("")}}),blocks:B("TableRow")});o.registerChaiBlock(me,{type:"TableCell",label:"Table Cell",category:"core",group:"table",hidden:!0,icon:g.DragHandleHorizontalIcon,...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),content:{type:"string",default:"Heading goes here",title:"Content",ui:{"ui:widget":"textarea"}}}}),blocks:B("TableCell"),i18nProps:["content"],aiProps:["content"]});function B(e){const l=(n,a)=>({_id:f.generateUUID(),_parent:n,_type:"TableCell",styles:"#styles:,",content:`${e==="TableHead"?"Table Head":"Table Cell "+a}`}),t=n=>{const a=f.generateUUID(),c={_type:"TableRow",_id:a,styles:"#styles:,border-b"};return n&&(c._parent=n),[c,l(a,"1"),l(a,"2"),l(a,"3")]},r=n=>{const a=f.generateUUID(),c={_id:a,_type:"TableHead",styles:"#styles:,font-medium"};return n&&(c._parent=n),[c,...t(a)]},s=n=>{const a=f.generateUUID(),c={_id:a,_type:"TableBody",styles:"#styles:,"};return n&&(c._parent=n),[c,...t(a),...t(a)]};if(e==="Table"){const n=f.generateUUID();return[{_id:n,_type:"Table",styles:"#styles:,w-full text-left text-gray-500 dark:text-gray-400"},...r(n),...s(n)]}return e==="TableRow"?t():e==="TableHead"?r():e==="TableBody"?s():[]}const I=(e,...l)=>({...e,className:f.cn(e.className,...l)}),ye=e=>{const{blockProps:l,icon:t,styles:r,width:s,inBuilder:n,height:a}=e,c=I(r,"");if(d.isEmpty(t))return i.jsx(x,{inBuilder:n,className:"h-8 w-14"});const p=t.replace(/<svg /g,'<svg class="w-[inherit] h-[inherit]" ');return h.createElement("span",{...l,...c,style:{width:s?`${s}px`:"auto",height:a?`${a}px`:"auto"},dangerouslySetInnerHTML:{__html:p}})},he={type:"Icon",label:"web_blocks.icon",category:"core",icon:g.SketchLogoIcon,group:"media",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),icon:{type:"string",title:"Icon",default:'<svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><path d="M8 16c4.418 0 8-3.582 8-8s-3.582-8-8-8-8 3.582-8 8 3.582 8 8 8zM8 1.5c3.59 0 6.5 2.91 6.5 6.5s-2.91 6.5-6.5 6.5-6.5-2.91-6.5-6.5 2.91-6.5 6.5-6.5zM8 9.356c1.812 0 3.535-0.481 5-1.327-0.228 2.788-2.393 4.971-5 4.971s-4.772-2.186-5-4.973c1.465 0.845 3.188 1.329 5 1.329zM4 5.5c0-0.828 0.448-1.5 1-1.5s1 0.672 1 1.5c0 0.828-0.448 1.5-1 1.5s-1-0.672-1-1.5zM10 5.5c0-0.828 0.448-1.5 1-1.5s1 0.672 1 1.5c0 0.828-0.448 1.5-1 1.5s-1-0.672-1-1.5z"></path></svg>',ui:{"ui:widget":"icon"}},width:{type:"number",default:16,title:"Width"},height:{type:"number",default:16,title:"Height"}}})},be=e=>{const{blockProps:l,image:t,mobileImage:r,styles:s,alt:n,height:a,width:c,lazyLoading:p}=e;return d.isEmpty(t)?i.jsx(x,{className:"h-36"}):i.jsxs("picture",{children:[r&&i.jsx("source",{srcSet:r,media:"(max-width: 480px)"}),i.jsx("img",{...l,...s,src:t,alt:n,loading:p?"lazy":"eager",width:c,height:a})]})},fe={type:"Image",description:"A image component",label:"Image",category:"core",icon:g.ImageIcon,group:"media",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),image:{type:"string",title:"Image",default:"https://fakeimg.pl/400x200?text=Choose&font=bebas",ui:{"ui:widget":"image"}},alt:{type:"string",title:"Alt text",default:"",ui:{"ui:placeholder":"Enter alt text"}},lazyLoading:{type:"boolean",title:"Lazy Load",default:!0},width:{type:"number",title:"Width",default:"",ui:{"ui:placeholder":"Enter width"}},height:{type:"number",title:"Height",default:"",ui:{"ui:placeholder":"Enter height"}},mobileImage:{type:"string",title:"Mobile Image",default:"",ui:{"ui:widget":"image"}},assetId:{type:"string",title:"Asset ID",default:"",ui:{"ui:widget":"hidden"}}}}),aiProps:["alt"],i18nProps:["alt"]},ke=e=>{const{blockProps:l,link:t,children:r,styles:s,inBuilder:n,content:a}=e;let c={};return!r&&d.isEmpty(a)&&(c={minHeight:"50px",display:"flex",alignItems:"center",justifyContent:"center"}),n?r?i.jsx("span",{...l,style:c,...s,children:r}):k.createElement("span",{...l,...s,style:c},a):r?i.jsx("a",{"aria-label":a,href:(t==null?void 0:t.href)||"#/",target:t==null?void 0:t.target,...l,...s,children:r}):k.createElement("a",{...l,...s,href:(t==null?void 0:t.href)||"#",target:(t==null?void 0:t.target)||"_self","aria-label":a},a)},xe={type:"Link",description:"A link component",label:"Link",category:"core",icon:g.Link1Icon,group:"basic",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),content:{type:"string",default:"Link goes here",title:"Content"},link:{type:"object",properties:{type:{type:"string"},href:{type:"string"},target:{type:"string"}},default:{type:"url",href:"",target:"_self"},ui:{"ui:field":"link"}}}}),aiProps:["content"],i18nProps:["content"],canAcceptBlock:e=>e!=="Link"},Ce=e=>{const{blockProps:l,children:t,listType:r,styles:s,tag:n,inBuilder:a}=e,c=f.cn(d.get(s,"className",""),r);return!t&&d.isEmpty(s==null?void 0:s.className)?i.jsx(x,{inBuilder:a}):h.createElement(n||(r==="list-decimal"?"ol":"ul"),{...l,...s,className:c},t)},Be={type:"List",description:"A list component",label:"List",icon:g.RowsIcon,category:"core",group:"basic",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),listType:{type:"string",title:"List Type",default:"list-none",oneOf:[{enum:["list-none"],title:"List None"},{enum:["list-disc"],title:"Disc"},{enum:["list-decimal"],title:"Decimal"}]}}}),canAcceptBlock:e=>e==="ListItem",blocks:[{_type:"List",_id:"a",listType:"list-none",styles:"#styles:,"},{_type:"ListItem",_id:"b",_parent:"a",styles:"#styles:,",content:"Item 1"},{_type:"ListItem",_id:"c",_parent:"a",styles:"#styles:,",content:"Item 2"},{_type:"ListItem",_id:"d",_parent:"a",styles:"#styles:,",content:"Item 3"}]},Se=e=>{const{blockProps:l,content:t,styles:r,children:s,tag:n}=e;return s?h.createElement(n||"li",{...r,...l},s):h.createElement(n||"li",{...r,...l,dangerouslySetInnerHTML:{__html:t}})},we={type:"ListItem",description:"A list item component",label:"List Item",icon:g.ColumnsIcon,category:"core",group:"basic",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),content:{type:"string",default:"List item",title:"Content",ui:{"ui:widget":"textarea"}}}}),i18nProps:["content"],aiProps:["content"],canAcceptBlock:e=>e!=="ListItem",canBeNested:e=>e==="List"||e==="Repeater"},Pe=e=>{const{blockProps:l,styles:t,content:r}=e;return d.isNull(e.children)?h.createElement("p",{...t,...l,dangerouslySetInnerHTML:{__html:r}}):h.createElement("p",{...t,...l},e.children)},Ie={type:"Paragraph",description:"A paragraph component",label:"Paragraph",category:"core",icon:g.TextIcon,group:"typography",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),content:{type:"string",title:"Content",default:"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse varius enim in eros elementum tristique. Duis cursus, mi quis viverra ornare, eros dolor interdum nulla, ut commodo diam libero vitae erat. Aenean faucibus nibh et justo cursus id rutrum lorem imperdiet. Nunc ut sem vitae risus tristique posuere.",ui:{"ui:widget":"textarea","ui:autosize":!0,"ui:rows":5}}}}),i18nProps:["content"],aiProps:["content"],canAcceptBlock:e=>e==="Span"||e==="Link"||e==="Text"},ve=e=>{const{blockProps:l,inBuilder:t,children:r,partialBlockId:s}=e;return t&&!s?i.jsxs("div",{className:"flex flex-col items-center justify-center gap-y-1 rounded-lg bg-gray-100 py-4 dark:bg-gray-800",...l,children:[i.jsxs("h1",{children:["Partial Block - ",s]}),i.jsx("p",{children:"Choose a block from the sidebar to add it to this page."})]}):h.createElement("span",{...l},r)},je={type:"PartialBlock",description:"A partial block component",label:"Partial Block",icon:C.GlobeIcon,category:"core",group:"basic",hidden:!0,...o.registerChaiBlockSchema({properties:{partialBlockId:{type:"string",title:"Partial Block",default:"",ui:{"ui:widget":"hidden"}}}})},S={SMALL:{1:"col-span-1",2:"col-span-2",3:"col-span-3",4:"col-span-4",5:"col-span-5",6:"col-span-6",7:"col-span-7",8:"col-span-8",9:"col-span-9",10:"col-span-10",11:"col-span-11",12:"col-span-12"},MEDIUM:{1:"md:col-span-1",2:"md:col-span-2",3:"md:col-span-3",4:"md:col-span-4",5:"md:col-span-5",6:"md:col-span-6",7:"md:col-span-7",8:"md:col-span-8",9:"md:col-span-9",10:"md:col-span-10",11:"md:col-span-11",12:"md:col-span-12"},LARGE:{1:"lg:col-span-1",2:"lg:col-span-2",3:"lg:col-span-3",4:"lg:col-span-4",5:"lg:col-span-5",6:"lg:col-span-6",7:"lg:col-span-7",8:"lg:col-span-8",9:"lg:col-span-9",10:"lg:col-span-10",11:"lg:col-span-11",12:"lg:col-span-12"}},Le=e=>{const{blockProps:l,children:t,styles:r,colSpan:s,tabletColSpan:n,desktopColSpan:a}=e,p={className:[d.get(r,"className",""),d.get(S,["SMALL",isNaN(s)||!s?6:s],""),n?d.get(S,["MEDIUM",n||s],""):"",a?d.get(S,["LARGE",n||s],""):""].join(" ")};return i.jsx("div",{...l,...r,...p,children:t||i.jsx("div",{className:"h-full min-h-12 w-full border-2 border-dashed border-gray-400 bg-gray-100 dark:bg-gray-900"})})},_e={type:"Column",description:"A column component",label:"Column",group:"basic",category:"core",icon:C.Columns,wrapper:!0,canDelete:()=>!0,canAcceptBlock:()=>!0,canBeNested:e=>e==="Row",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),colSpan:{type:"number",title:"Column Span",default:6,enum:[1,2,3,4,5,6,7,8,9,10,11,12]},tabletColSpan:{type:"number",title:"Column Span (Tablet)",default:null,enumNames:["Default",1,2,3,4,5,6,7,8,9,10,11,12],enum:[null,1,2,3,4,5,6,7,8,9,10,11,12]},desktopColSpan:{type:"number",title:"Column Span (Desktop)",default:null,enumNames:["Default",1,2,3,4,5,6,7,8,9,10,11,12],enum:[null,1,2,3,4,5,6,7,8,9,10,11,12]}}})},Te=e=>{const{blockProps:l,children:t,styles:r,gutter:s}=e,a={className:[d.get(r,"className","")," grid grid-cols-12"].join()};return typeof(r==null?void 0:r.style)=="object"?r.style.gap=`${s}px`:a.style={gap:`${s}px`},i.jsx("div",{...l,...r,...a,children:t})},Ee={type:"Row",description:"A row component",label:"Row",group:"basic",icon:C.Rows,blocks:()=>[{_type:"Row",_id:"row",styles:"#styles:,p-1"},{_type:"Column",id:"column",_parent:"row",styles:"#styles:,"},{_type:"Column",id:"column",_parent:"row",styles:"#styles:,"}],category:"core",wrapper:!0,canAcceptBlock:e=>e==="Column",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),colCount:{type:"number",default:2,minimum:0,ui:{"ui:widget":"colCount"}},gutter:{type:"number",title:"Gutter (in px)",default:16,minimum:0}}})},Ne=e=>{const{blockProps:l,content:t,styles:r}=e,s=I(r,"prose dark:prose-invert prose-p:m-0 prose-p:min-h-[1rem] prose-blockquote:m-2 prose-blockquote:ml-4 prose-ul:m-0 prose-ol:m-0 prose-li:m-0","max-w-full");return i.jsx("div",{...l,...s,dangerouslySetInnerHTML:{__html:t}})},Re={type:"RichText",description:"A rich text block",label:"Rich Text",category:"core",icon:g.CursorTextIcon,group:"typography",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),content:{type:"string",title:"Content",default:"<p>This is a rich text block. You can add text, and other content here.</p>",ui:{"ui:widget":"richtext"}}}}),aiProps:["content"],i18nProps:["content"]},Me=e=>{const{blockProps:l,styles:t,content:r,children:s=null,tag:n}=e;return s?h.createElement("span",{...t,...l},s):h.createElement(n||"span",{...t,...l,dangerouslySetInnerHTML:{__html:r||""}})},$e={type:"Span",description:"A span component",label:"Span",category:"core",group:"typography",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),content:{type:"string",title:"Content",default:"",ui:{"ui:widget":"textarea","ui:autosize":!0,"ui:rows":3}}}}),aiProps:["content"],i18nProps:["content"],canAcceptBlock:()=>!0},Ae=e=>e.inBuilder||e.forceWrapper?i.jsx("span",{...e.blockProps,children:e.content}):`${e.content}`,He={type:"Text",description:"A text component with no styling",label:"Text",hidden:!0,category:"core",group:"typography",icon:g.SpaceBetweenVerticallyIcon,...o.registerChaiBlockSchema({properties:{styles:o.StylesProp("text-black"),content:{title:"Content",type:"string",default:""}}}),aiProps:["content"],i18nProps:["content"]},Ue={type:"object",title:"Controls",default:{autoplay:!0,controls:!1,loop:!0,muted:!0},properties:{autoplay:{type:"boolean",title:"Autoplay",default:!1},controls:{type:"boolean",title:"Show Controls",default:!0},loop:{type:"boolean",title:"Loop Video",default:!1},muted:{type:"boolean",title:"Muted",default:!1}}},w=/^(https?:\/\/)?(www\.)?youtube\.com\/(watch\?v=|embed\/)([a-zA-Z0-9_-]{11})/,P=/(?:https?:\/\/)?(?:www\.)?(?:vimeo\.com\/(?:channels\/[\w]+\/|groups\/[^\/]+\/videos\/|album\/\d+\/video\/|video\/)?|player\.vimeo\.com\/video\/)(\d+)/,De=(e,l)=>{const t=d.get(l,"autoplay",!1),r=d.get(l,"controls",!1),s=d.get(l,"loop",!1),n=t||d.get(l,"muted",!0);if(w.test(e)){const a=e.match(w);if(a){const c=a[4];let p=`https://www.youtube.com/embed/${c}`,u=t?"autoplay=1":"";return u+=s?`&loop=1&playlist=${c}`:"",u+=n?"&mute=1&muted=1":"",u+=r?"&controls=1":"&controls=0",`${p}?${u}`}}if(P.test(e)){const a=e.match(P);if(a){const c=a[1];let p="";return p+=t?"autoplay=1":"",p+=r?"&controls=1":"&controls=0",p+=n?"&muted=1":"",p+=s?"&loop=1":"",`https://player.vimeo.com/video/${c}?${p}`}}return null},qe=e=>{const{url:l,blockProps:t,styles:r,controls:s,videoSource:n,inBuilder:a}=e,c=De(l,s);return i.jsxs("div",{...d.omit(r,"className"),className:"relative w-full overflow-hidden",style:{paddingBottom:"56.25%"},children:[!c&&a?i.jsx("div",{className:"absolute flex h-full w-full items-center justify-center bg-gray-300 text-center",children:d.isEmpty(l)?`Provided ${n} video link in settings Video URL.`:`Provided ${n} video link is invalid.`}):i.jsx("iframe",{width:"100%",src:c,...d.pick(r,"className")}),a&&i.jsx("div",{...t,className:"absolute top-0 h-full w-full"})]})},ze=e=>{const{url:l,styles:t,controls:r,sources:s,poster:n,blockProps:a}=e;let c=n;const p=[...d.get(s,"srcsets",[])||[]];l&&typeof l=="string"&&p.push({url:l,width:"9999"});const u=p.sort((y,m)=>parseInt(y.width)-parseInt(m.width)).filter(y=>!d.isEmpty(y.url)&&!d.isEmpty(y.width));u.length===0&&!c&&(c="https://placehold.co/300x200/EEE/ccc?text=Choose%20Video");const b=d.get(r,"autoplay",!1)||d.get(r,"muted",!0);return(c||!d.isEmpty(u))&&i.jsx("div",{className:"relative w-full overflow-hidden",style:{paddingBottom:"56.25%"},children:k.createElement("video",{...t,...a,key:JSON.stringify(u),controls:d.get(r,"controls",!1),autoPlay:d.get(r,"autoplay",!1),loop:d.get(r,"loop",!1),poster:c,...b?{muted:!0}:{}},u.map(y=>{if(!y.url||y.url.length<4||isNaN(y.width))return null;const m=`(max-width: ${y.width}px)`;return i.jsx("source",{src:y.url,media:m,type:y.type},y.url)}),"Your browser does not support the video tag.")})},Fe=e=>{const{videoSource:l}=e;return l==="Custom"?i.jsx(ze,{...e}):l==="Youtube"||l==="Vimeo"?i.jsx(qe,{...e}):i.jsxs("div",{children:["Invalid video source : ",l]})},Ve={type:"Video",label:"Video",category:"core",icon:g.VideoIcon,group:"media",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp("absolute h-full w-full object-cover"),videoSource:{type:"string",default:"Custom",enum:["Custom","Youtube","Vimeo"],title:"Video source"}},allOf:[{if:{properties:{videoSource:{const:"Custom"}}},then:{properties:{url:{type:"string",title:"Video URL",default:""},poster:{type:"string",title:"Poster URL",default:""},sources:{type:"object",default:{srcsets:[]}},controls:{...Ue}}}},{if:{properties:{videoSource:{const:"Youtube"}}},then:{properties:{url:{type:"string",title:"Youtube Video URL",default:""}}}},{if:{properties:{videoSource:{const:"Vimeo"}}},then:{properties:{url:{type:"string",title:"Vimeo Video URL",default:""}}}}],ui:{url:{"ui:placeholder":"Enter Video URL"},sources:{"ui:field":"sources"},poster:{"ui:placeholder":"Enter poster URL"}}}),i18nProps:["url"]},Oe=e=>{const{children:l,tag:t,styles:r,blockProps:s,inBuilder:n,$loading:a}=e;let c=l;return d.isEmpty(c)&&n&&(c=i.jsx("div",{className:"col-span-3 flex items-center justify-center bg-orange-50 p-5 text-sm text-muted-foreground",children:"Choose a collection to display items"})),h.createElement(t,{...s,...r},a&&n?Array.from({length:2}).map((p,u)=>i.jsxs("div",{className:"animate-pulse rounded-md bg-primary/10 p-5",children:[i.jsx("div",{className:"h-6 w-1/2 rounded-md bg-primary/10"}),i.jsx("div",{className:"mt-2 h-4 w-1/2 rounded-md bg-primary/10"})]},u)):c)},Ge={type:"Repeater",label:"Repeater",icon:g.LoopIcon,group:"basic",dataProviderMode:"live",dataProviderDependencies:["filter","sort","limit","repeaterItems"],blocks:()=>[{_id:"A",_type:"Repeater",tag:"ul"},{_id:"B",_name:"Repeater Item",_type:"RepeaterItem",parentTag:"ul",_parent:"A"}],...o.registerChaiBlockSchema({properties:{styles:o.stylesProp("grid gap-4 md:grid-cols-2 xl:grid-cols-3"),repeaterItems:{title:"Collection",type:"string",binding:"array",default:"",ui:{"ui:widget":"repeaterBinding","ui:readonly":!0}},tag:{title:"Tag",type:"string",default:"ul",enum:["div","ul","ol"]},limit:{title:"Limit",type:"number",default:3},filter:{title:"Filter by",type:"string",default:"",ui:{"ui:widget":"collectionSelect"}},sort:{title:"Sort by",type:"string",default:"",ui:{"ui:widget":"collectionSelect"}}}})},Ye=({children:e,blockProps:l,styles:t,parentTag:r,inBuilder:s})=>{let n="li";switch(r){case"ul":n="li";break;case"ol":n="li";break;default:n="div"}return!e&&s?h.createElement(n,{...l,...t},i.jsx("div",{className:"col-span-3 flex items-center justify-center bg-orange-50 p-5 text-sm text-muted-foreground",children:"Add children to repeater item"})):h.createElement(n,{...l,...t},e)},We={type:"RepeaterItem",label:"Repeater Item",icon:g.LoopIcon,hidden:!0,group:"basic",...o.registerChaiBlockSchema({properties:{styles:o.stylesProp(""),parentTag:o.closestBlockProp("Repeater","tag")}}),canAcceptBlock:e=>e!=="RepeaterItem",canDelete:()=>!1,canMove:()=>!1,canDuplicate:()=>!1},Xe=({children:e,blockProps:l,styles:t})=>h.createElement("div",{...l,...t},e),Je={type:"RepeaterEmptyState",label:"Empty State",hidden:!0,group:"basic",...o.registerChaiBlockSchema({properties:{styles:o.stylesProp("p-5 flex items-center justify-center")}}),canAcceptBlock:()=>!0,canDelete:()=>!1,canMove:()=>!1,canDuplicate:()=>!1},Qe=()=>{o.registerChaiBlock(j,L),o.registerChaiBlock(D,q),o.registerChaiBlock(_,T),o.registerChaiBlock(ie,ne),o.registerChaiBlock(Pe,Ie),o.registerChaiBlock(Me,$e),o.registerChaiBlock(Ne,Re),o.registerChaiBlock(ke,xe),o.registerChaiBlock(Ce,Be),o.registerChaiBlock(Se,we),o.registerChaiBlock(ye,he),o.registerChaiBlock(be,fe),o.registerChaiBlock(Fe,Ve),o.registerChaiBlock(R,M),o.registerChaiBlock($,A),o.registerChaiBlock(Ae,He),o.registerChaiBlock(V,O),o.registerChaiBlock(G,Y),o.registerChaiBlock(W,X),o.registerChaiBlock(z,F),o.registerChaiBlock(Z,K),o.registerChaiBlock(ee,te),o.registerChaiBlock(oe,le),o.registerChaiBlock(J,Q),o.registerChaiBlock(ae,ce),o.registerChaiBlock(H,U),o.registerChaiBlock(re,se),o.registerChaiBlock(ve,je),o.registerChaiBlock(Te,Ee),o.registerChaiBlock(Le,_e),o.registerChaiBlock(E,N),o.registerChaiBlock(Oe,Ge),o.registerChaiBlock(Ye,We),o.registerChaiBlock(Xe,Je)};exports.loadWebBlocks=Qe;
|
package/dist/web-blocks.js
CHANGED
|
@@ -5,7 +5,7 @@ import * as b from "react";
|
|
|
5
5
|
import { createElement as w } from "react";
|
|
6
6
|
import { ButtonIcon as R, CopyIcon as z, CodeIcon as D, DividerHorizontalIcon as j, CheckboxIcon as V, InputIcon as M, LetterCaseToggleIcon as q, RadiobuttonIcon as F, DropdownMenuIcon as U, HeadingIcon as G, TableIcon as O, BorderTopIcon as Y, BorderAllIcon as W, ViewHorizontalIcon as X, DragHandleHorizontalIcon as J, SketchLogoIcon as Q, ImageIcon as Z, Link1Icon as K, RowsIcon as ee, ColumnsIcon as te, TextIcon as oe, CursorTextIcon as le, SpaceBetweenVerticallyIcon as re, VideoIcon as ne, LoopIcon as E } from "@radix-ui/react-icons";
|
|
7
7
|
import { isEmpty as C, get as h, map as S, isNull as ie, omit as se, pick as ae } from "lodash-es";
|
|
8
|
-
import { FileCode as ce, GroupIcon as pe, GlobeIcon as
|
|
8
|
+
import { FileCode as ce, GroupIcon as pe, GlobeIcon as $, Columns as de, Rows as ue } from "lucide-react";
|
|
9
9
|
const x = ({ className: e = "", inBuilder: o }) => o ? /* @__PURE__ */ s("div", { className: B("pointer-events-none flex h-20 flex-col items-center justify-center p-2", e), children: /* @__PURE__ */ s("div", { className: "h-full w-full rounded bg-gray-200 p-2 dark:bg-gray-800", children: /* @__PURE__ */ s("div", { className: "flex h-full w-full items-center justify-center outline-dashed outline-1 -outline-offset-1 outline-gray-400 duration-300 dark:outline-gray-700" }) }) }) : null, me = (e) => {
|
|
10
10
|
const { blockProps: o, inBuilder: t, backgroundImage: l, children: r, tag: n = "div", styles: i } = e;
|
|
11
11
|
let a = r;
|
|
@@ -565,13 +565,13 @@ const x = ({ className: e = "", inBuilder: o }) => o ? /* @__PURE__ */ s("div",
|
|
|
565
565
|
}),
|
|
566
566
|
aiProps: ["label", "placeholder"],
|
|
567
567
|
i18nProps: ["label", "placeholder"]
|
|
568
|
-
},
|
|
568
|
+
}, $e = (e) => {
|
|
569
569
|
const { blockProps: o, content: t, styles: l, children: r } = e, n = { ...l, ...o };
|
|
570
570
|
return r ? b.createElement("label", n, r) : b.createElement("label", {
|
|
571
571
|
...n,
|
|
572
572
|
dangerouslySetInnerHTML: { __html: t }
|
|
573
573
|
});
|
|
574
|
-
},
|
|
574
|
+
}, Ae = {
|
|
575
575
|
type: "Label",
|
|
576
576
|
label: "Label",
|
|
577
577
|
category: "core",
|
|
@@ -815,7 +815,7 @@ const x = ({ className: e = "", inBuilder: o }) => o ? /* @__PURE__ */ s("div",
|
|
|
815
815
|
type: "GlobalBlock",
|
|
816
816
|
description: "A global block component",
|
|
817
817
|
label: "Global Block",
|
|
818
|
-
icon:
|
|
818
|
+
icon: $,
|
|
819
819
|
category: "core",
|
|
820
820
|
group: "basic",
|
|
821
821
|
hidden: !0,
|
|
@@ -1022,11 +1022,11 @@ function I(e) {
|
|
|
1022
1022
|
}
|
|
1023
1023
|
return e === "TableRow" ? t() : e === "TableHead" ? l() : e === "TableBody" ? r() : [];
|
|
1024
1024
|
}
|
|
1025
|
-
const
|
|
1025
|
+
const A = (e, ...o) => ({
|
|
1026
1026
|
...e,
|
|
1027
1027
|
className: B(e.className, ...o)
|
|
1028
1028
|
}), et = (e) => {
|
|
1029
|
-
const { blockProps: o, icon: t, styles: l, width: r, inBuilder: n, height: i } = e, a =
|
|
1029
|
+
const { blockProps: o, icon: t, styles: l, width: r, inBuilder: n, height: i } = e, a = A(l, "");
|
|
1030
1030
|
if (C(t))
|
|
1031
1031
|
return /* @__PURE__ */ s(x, { inBuilder: n, className: "h-8 w-14" });
|
|
1032
1032
|
const c = t.replace(/<svg /g, '<svg class="w-[inherit] h-[inherit]" ');
|
|
@@ -1329,7 +1329,7 @@ const $ = (e, ...o) => ({
|
|
|
1329
1329
|
type: "PartialBlock",
|
|
1330
1330
|
description: "A partial block component",
|
|
1331
1331
|
label: "Partial Block",
|
|
1332
|
-
icon:
|
|
1332
|
+
icon: $,
|
|
1333
1333
|
category: "core",
|
|
1334
1334
|
group: "basic",
|
|
1335
1335
|
hidden: !0,
|
|
@@ -1465,7 +1465,7 @@ const $ = (e, ...o) => ({
|
|
|
1465
1465
|
}
|
|
1466
1466
|
})
|
|
1467
1467
|
}, ht = (e) => {
|
|
1468
|
-
const { blockProps: o, content: t, styles: l } = e, r =
|
|
1468
|
+
const { blockProps: o, content: t, styles: l } = e, r = A(
|
|
1469
1469
|
l,
|
|
1470
1470
|
"prose dark:prose-invert prose-p:m-0 prose-p:min-h-[1rem] prose-blockquote:m-2 prose-blockquote:ml-4 prose-ul:m-0 prose-ol:m-0 prose-li:m-0",
|
|
1471
1471
|
"max-w-full"
|
|
@@ -1710,22 +1710,16 @@ const $ = (e, ...o) => ({
|
|
|
1710
1710
|
}
|
|
1711
1711
|
}),
|
|
1712
1712
|
i18nProps: ["url"]
|
|
1713
|
-
}, Tt = ({
|
|
1714
|
-
children: e
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
}) => {
|
|
1721
|
-
let i = e;
|
|
1722
|
-
return C(i) && r && (i = /* @__PURE__ */ s("div", { className: "col-span-3 flex items-center justify-center bg-orange-50 p-5 text-sm text-muted-foreground", children: "Choose a collection to display items" })), b.createElement(
|
|
1723
|
-
o,
|
|
1724
|
-
{ ...t, ...l },
|
|
1725
|
-
n ? Array.from({ length: 2 }).map((a, c) => /* @__PURE__ */ f("div", { className: "animate-pulse rounded-md bg-primary/10 p-5", children: [
|
|
1713
|
+
}, Tt = (e) => {
|
|
1714
|
+
const { children: o, tag: t, styles: l, blockProps: r, inBuilder: n, $loading: i } = e;
|
|
1715
|
+
let a = o;
|
|
1716
|
+
return C(a) && n && (a = /* @__PURE__ */ s("div", { className: "col-span-3 flex items-center justify-center bg-orange-50 p-5 text-sm text-muted-foreground", children: "Choose a collection to display items" })), b.createElement(
|
|
1717
|
+
t,
|
|
1718
|
+
{ ...r, ...l },
|
|
1719
|
+
i && n ? Array.from({ length: 2 }).map((c, m) => /* @__PURE__ */ f("div", { className: "animate-pulse rounded-md bg-primary/10 p-5", children: [
|
|
1726
1720
|
/* @__PURE__ */ s("div", { className: "h-6 w-1/2 rounded-md bg-primary/10" }),
|
|
1727
1721
|
/* @__PURE__ */ s("div", { className: "mt-2 h-4 w-1/2 rounded-md bg-primary/10" })
|
|
1728
|
-
] },
|
|
1722
|
+
] }, m)) : a
|
|
1729
1723
|
);
|
|
1730
1724
|
}, Nt = {
|
|
1731
1725
|
type: "Repeater",
|
|
@@ -1828,7 +1822,7 @@ const $ = (e, ...o) => ({
|
|
|
1828
1822
|
children: e,
|
|
1829
1823
|
blockProps: o,
|
|
1830
1824
|
styles: t
|
|
1831
|
-
}) => b.createElement("div", { ...o, ...t }, e),
|
|
1825
|
+
}) => b.createElement("div", { ...o, ...t }, e), $t = {
|
|
1832
1826
|
type: "RepeaterEmptyState",
|
|
1833
1827
|
label: "Empty State",
|
|
1834
1828
|
hidden: !0,
|
|
@@ -1841,7 +1835,7 @@ const $ = (e, ...o) => ({
|
|
|
1841
1835
|
canMove: () => !1,
|
|
1842
1836
|
canDuplicate: () => !1
|
|
1843
1837
|
}, Ft = () => {
|
|
1844
|
-
p(me, ye), p(Be, Le), p(ge, be), p(Ge, Oe), p(pt, dt), p(wt, vt), p(ht, kt), p(rt, nt), p(it, st), p(at, ct), p(et, tt), p(ot, lt), p(St, _t), p(ke, we), p(ve, Ce), p(Ct, xt), p(_e, Te), p(Ne, Re), p(Me, Ee), p(Pe, Se), p(He, ze), p(De, je), p(Ve, qe), p(
|
|
1838
|
+
p(me, ye), p(Be, Le), p(ge, be), p(Ge, Oe), p(pt, dt), p(wt, vt), p(ht, kt), p(rt, nt), p(it, st), p(at, ct), p(et, tt), p(ot, lt), p(St, _t), p(ke, we), p(ve, Ce), p(Ct, xt), p(_e, Te), p(Ne, Re), p(Me, Ee), p(Pe, Se), p(He, ze), p(De, je), p(Ve, qe), p($e, Ae), p(Ye, We), p(xe, Ie), p(Fe, Ue), p(ut, mt), p(bt, ft), p(yt, gt), p(fe, he), p(Tt, Nt), p(Rt, Mt), p(Et, $t);
|
|
1845
1839
|
};
|
|
1846
1840
|
export {
|
|
1847
1841
|
Ft as loadWebBlocks
|