@chaibuilder/sdk 3.1.25 → 3.1.27
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/{IconPicker-CluS-5Mv.js → IconPicker-6JSublJp.js} +1 -1
- package/dist/{IconPicker-BWE43eMO.cjs → IconPicker-DpQQDK_Q.cjs} +1 -1
- package/dist/{apply-binding-DCno1xQL.js → apply-binding-BwPhgnhk.js} +329 -202
- package/dist/apply-binding-Dblf6wMG.cjs +1 -0
- package/dist/{code-display-BOOy3Lpy.js → code-display-DuH-UOhl.js} +1 -1
- package/dist/{code-display-B1O2gN5f.cjs → code-display-Dw1tAwiJ.cjs} +1 -1
- package/dist/{code-editor-Dmq2df89.js → code-editor-8oLNN2d5.js} +6 -5
- package/dist/code-editor-Ixoxjpbw.cjs +1 -0
- package/dist/common-functions-B3a4xKt_.cjs +1 -0
- package/dist/common-functions-D2lMFR6K.js +13 -0
- package/dist/core.cjs +1 -1
- package/dist/core.d.ts +26 -5
- package/dist/core.js +3 -3
- package/dist/{css-import-modal-sHoiyimv.js → css-import-modal-CFB2YjDT.js} +1 -1
- package/dist/{css-import-modal-CrlmcFy4.cjs → css-import-modal-bGWZSlqv.cjs} +1 -1
- package/dist/index-DqxtRdta.cjs +154 -0
- package/dist/{index-CU5gEUbc.js → index-vLM3DaDo.js} +2390 -2062
- package/dist/render.cjs +2 -2
- package/dist/render.d.ts +12 -3
- package/dist/render.js +118 -116
- package/dist/{rte-widget-modal-BvND5bq_.js → rte-widget-modal-BNvlWZJ5.js} +2 -2
- package/dist/{rte-widget-modal-B-TcV_cb.cjs → rte-widget-modal-em_32UgQ.cjs} +1 -1
- package/dist/tailwind.d.ts +2 -2
- package/dist/{tooltip-CzZ7Fvt7.cjs → tooltip-Ba1-8jmj.cjs} +1 -1
- package/dist/{tooltip-Bz2MxMHf.js → tooltip-DUosa-uC.js} +83 -83
- package/dist/ui.cjs +1 -1
- package/dist/ui.d.ts +14 -14
- package/dist/ui.js +1 -1
- package/dist/web-blocks.cjs +1 -1
- package/dist/web-blocks.js +1 -1
- package/package.json +3 -1
- package/dist/apply-binding-DvHNFLQD.cjs +0 -1
- package/dist/code-editor-CmXV8E-i.cjs +0 -1
- package/dist/common-functions-BGzDsf1z.js +0 -14
- package/dist/common-functions-BZmyleS1.cjs +0 -1
- package/dist/index-Di66eAEA.cjs +0 -154
package/dist/render.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("./plugin-CSgw-f78.cjs"),d=require("./apply-binding-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("./plugin-CSgw-f78.cjs"),d=require("./apply-binding-Dblf6wMG.cjs"),m=require("react/jsx-runtime"),b=require("@chaibuilder/runtime"),t=require("lodash-es"),g=require("react"),D=require("@tailwindcss/aspect-ratio"),F=require("@tailwindcss/forms"),q=require("@tailwindcss/typography");require("tailwindcss-animate");const j=require("./get-chai-builder-theme-B1tr_NJB.cjs"),K=require("@mhsdesign/jit-browser-tailwindcss"),M=require("@tailwindcss/container-queries");async function O(e){const a={pageProps:e.pageProps,block:e.block,lang:e.lang,draft:e.draft,inBuilder:!1},n=await e.dataProvider(a);return t.has(n,"$metadata")&&t.isFunction(e.dataProviderMetadataCallback)&&e.dataProviderMetadataCallback(e.block,n.$metadata),e.children({...t.omit(n,"$metadata")})}const N=()=>m.jsx("div",{}),H=e=>{const{block:a,lang:n,fallbackLang:s,children:i,externalData:o,blocks:l,draft:r,pageProps:c,dataProviderMetadataCallback:k}=e,u=b.getRegisteredChaiBlock(a._type),p=t.get(u,"component",null),P=t.get(e.repeaterData,"index",-1),f=t.get(e.repeaterData,"dataKey",""),I=n===s?"":n,y=d.applyBindingToBlockProps(d.applyLanguage(a,I,u),o,{index:P,key:f}),h=d.getBlockTagAttributes(a,!1),T=L(l,a._id,d.getBlockRuntimeProps(a._type)),S=t.has(u,"dataProvider")&&t.isFunction(u.dataProvider),B={...y,...h,...T},_={blockProps:{},inBuilder:!1,lang:n||s,...B},v=t.get(B,"_show",!0);if(t.isNull(p)||!v)return null;if(S){const $=t.get(u,"suspenseFallback",N);return m.jsx(g.Suspense,{fallback:g.createElement($),children:m.jsx(O,{lang:n,pageProps:c,block:B,dataProvider:u.dataProvider,...k?{dataProviderMetadataCallback:k}:{},draft:r,children:x=>g.createElement(p,{..._,...x,children:i({_id:a._id,_type:a._type,...t.isArray(y.repeaterItems)?{repeaterItems:d.applyLimit(y.repeaterItems,a),$repeaterItemsKey:y.$repeaterItemsKey,repeaterTotalItems:y.repeaterTotalItems??-1}:{}})})})})}return m.jsx(g.Suspense,{children:g.createElement(p,{..._,children:i({_id:a._id,_type:a._type,...t.isArray(y.repeaterItems)?{repeaterItems:d.applyLimit(y.repeaterItems,a),$repeaterItemsKey:y.$repeaterItemsKey,repeaterTotalItems:y.repeaterTotalItems??-1}:{}})})})},E=e=>{const{blocks:a,parent:n,repeaterData:s,type:i}=e;let o=t.uniqBy(t.filter(a,r=>t.has(r,"_id")&&(t.isEmpty(n)?!r._parent:r._parent===n)),"_id");const l=r=>t.filter(a,c=>c._parent===r).length>0;return(i==="Heading"||i==="Paragraph"||i==="Link"||i==="Span")&&(o=d.adjustSpacingInContentBlocks(o)),t.map(o,r=>r?g.createElement(H,{...e,key:r._id,block:r},({_id:c,_type:k,repeaterItems:u,$repeaterItemsKey:p})=>k==="Repeater"?t.isArray(u)&&u.map((P,f)=>g.createElement(E,{...e,parent:r._id,key:`${t.get(r,"_parent","root")}-${r._id}-${f}`,repeaterData:{index:f,dataKey:p}})):l(c)?g.createElement(E,{...e,parent:r._id,key:`${t.get(r,"_parent","root")}-${r._id}`,repeaterData:s,type:r._type}):null):null)},L=(e,a,n)=>t.isEmpty(n)?{}:Object.entries(n).reduce((s,[i,o])=>{const l=[];let r=t.find(e,{_id:a});for(;r;)l.push(r),r=t.find(e,{_id:r._parent});const c=t.find(l,{_type:o.block});return c&&(s[i]=t.get(c,t.get(o,"prop"),null)),s},{});function J(e){if(t.isEmpty(e.lang)&&!t.isEmpty(e.fallbackLang))throw new Error("lang prop is required when fallbackLang is provided");if(t.isEmpty(e.blocks))return null;const a=e.lang??"en",n=e.fallbackLang??a;return m.jsx(E,{...e,lang:a,fallbackLang:n})}async function V(e){const a=await e.dataProvider;return t.has(a,"$metadata")&&t.isFunction(e.dataProviderMetadataCallback)&&e.dataProviderMetadataCallback(e.block,a.$metadata),e.children({...t.omit(a,"$metadata")})}const W=()=>m.jsx("div",{}),U=async e=>{const{block:a,lang:n,fallbackLang:s,children:i,externalData:o,blocks:l,draft:r,pageProps:c,dataProviderMetadataCallback:k,dataProviders:u}=e,p=b.getRegisteredChaiBlock(a._type),P=t.get(p,"component",null),f=t.get(e.repeaterData,"index",-1),I=t.get(e.repeaterData,"dataKey",""),y=n===s?"":n,h=d.applyBindingToBlockProps(d.applyLanguage(a,y,p),o,{index:f,key:I}),T=d.getBlockTagAttributes(a,!1),S=L(l,a._id,d.getBlockRuntimeProps(a._type)),B=t.has(p,"dataProvider")&&t.isFunction(p.dataProvider),_={...h,...T,...S},v={blockProps:{},inBuilder:!1,lang:n||s,..._},$=t.get(_,"_show",!0);if(t.isNull(P)||!$)return null;if(B){const x=t.get(u,a._id,Promise.resolve({})),R=t.get(p,"suspenseFallback",W);return m.jsx(g.Suspense,{fallback:g.createElement(R),children:m.jsx(V,{lang:n,pageProps:c,block:_,dataProvider:x,...k?{dataProviderMetadataCallback:k}:{},draft:r,children:A=>g.createElement(P,{...v,draft:r,...A,children:i({_id:a._id,_type:a._type,...t.isArray(h.repeaterItems)?{repeaterItems:d.applyLimit(h.repeaterItems,a),$repeaterItemsKey:h.$repeaterItemsKey,repeaterTotalItems:h.repeaterTotalItems??-1}:{}})})})})}return g.createElement(P,{...v,draft:r,children:i({_id:a._id,_type:a._type,...t.isArray(h.repeaterItems)?{repeaterItems:d.applyLimit(h.repeaterItems,a),$repeaterItemsKey:h.$repeaterItemsKey,repeaterTotalItems:h.repeaterTotalItems??-1}:{}})})},C=async e=>{const{blocks:a,parent:n,repeaterData:s,type:i}=e;let o=t.uniqBy(t.filter(a,r=>t.has(r,"_id")&&(t.isEmpty(n)?!r._parent:r._parent===n)),"_id");const l=r=>t.filter(a,c=>c._parent===r).length>0;return(i==="Heading"||i==="Paragraph"||i==="Link")&&(o=d.adjustSpacingInContentBlocks(o)),t.map(o,r=>r?g.createElement(U,{dataProviders:e.dataProviders,...e,key:r._id,block:r},({_id:c,_type:k,repeaterItems:u,$repeaterItemsKey:p})=>k==="Repeater"?t.isArray(u)&&u.map((P,f)=>g.createElement(C,{...e,parent:r._id,key:`${t.get(r,"_parent","root")}-${r._id}-${f}`,repeaterData:{index:f,dataKey:p}})):l(c)?g.createElement(C,{...e,parent:r._id,key:`${t.get(r,"_parent","root")}-${r._id}`,repeaterData:s,type:r._type}):null):null)};async function G(e){if(t.isEmpty(e.lang)&&!t.isEmpty(e.fallbackLang))throw new Error("lang prop is required when fallbackLang is provided");if(t.isEmpty(e.blocks))return null;const a=e.lang??"en",n=e.fallbackLang??a;if(e.dataProviders)return m.jsx(C,{...e,lang:a,fallbackLang:n,dataProviders:e.dataProviders});const i=e.blocks.filter(o=>{const l=b.getRegisteredChaiBlock(o._type);return!!(t.has(l,"dataProvider")&&t.isFunction(l.dataProvider))}).reduce((o,l)=>{const r=b.getRegisteredChaiBlock(l._type),c={pageProps:e.pageProps,block:l,lang:e.lang,draft:e.draft,inBuilder:!1};return o[l._id]=r.dataProvider(c),o},{});return m.jsx(C,{...e,lang:a,fallbackLang:n,dataProviders:i})}function z(e,a){const n=e.filter(({_type:s})=>s==="GlobalBlock"||s==="PartialBlock");for(let s=0;s<n.length;s++){const i=n[s],o=t.get(i,"partialBlockId",t.get(i,"globalBlock",""));if(o==="")continue;let l=t.cloneDeep(t.get(a,o,[]));i._parent&&(l==null?void 0:l.length)>0&&(l=l.map(c=>(t.isEmpty(c._parent)&&(c._parent=i._parent),c)));const r=e.indexOf(i);e.splice(r,1,...l)}return e}const Q=e=>{if(!e)return[];try{return JSON.parse(X(e)).filter(n=>!n._type.startsWith("@chai"))}catch{return[{_type:"Paragraph",_id:"error",content:"Invalid JSON. Please check the JSON string."}]}};function X(e){const a=/(asset:\/\/|https:\/\/asset\.localhost\/)(?:localhost\/)?[^"']+/g;return e.replace(a,n=>{const s=decodeURIComponent(n),i=s.indexOf("public");return i!==-1?s.substring(i+6):s})}async function Y(e,a=[],n=!1){return await K.createTailwindcss({tailwindConfig:{darkMode:"class",safelist:a,theme:{extend:{...j.getChaiBuilderTheme(),keyframes:{"accordion-down":{from:{height:"0"},to:{height:"var(--radix-accordion-content-height)"}},"accordion-up":{from:{height:"var(--radix-accordion-content-height)"},to:{height:"0"}}},animation:{"accordion-down":"accordion-down 0.2s ease-out","accordion-up":"accordion-up 0.2s ease-out"}}},plugins:[F,q,D,M,w.chaiBuilderPlugin],corePlugins:{preflight:n}}}).generateStylesFromContent(` ${n?"@tailwind base;":""}
|
|
2
2
|
@tailwind components;
|
|
3
|
-
@tailwind utilities;`,e)}const
|
|
3
|
+
@tailwind utilities;`,e)}const Z=(e,a)=>{const n=JSON.stringify(e).replace(/#styles:([^"]*)/g,(s,i)=>`#styles:${i.replace(/,/g," ")}`.replace(/#styles:/g,""));return Y([n],[],a)},ee=async(e,a=!1)=>await Z(e,a);exports.getChaiThemeCssVariables=w.getChaiThemeCssVariables;exports.getThemeFontsCSSImport=w.getThemeFontsCSSImport;exports.getThemeFontsLinkMarkup=w.getThemeFontsLinkMarkup;exports.applyChaiDataBinding=d.applyChaiDataBinding;exports.applyDesignTokens=d.applyDesignTokens;exports.convertHTMLToChaiBlocks=d.getBlocksFromHTML;exports.AsyncRenderChaiBlocks=G;exports.RenderChaiBlocks=J;exports.convertToBlocks=Q;exports.getMergedPartialBlocks=z;exports.getStylesForBlocks=ee;
|
package/dist/render.d.ts
CHANGED
|
@@ -2,7 +2,9 @@ import { ChaiFontViaUrl } from '@chaibuilder/runtime';
|
|
|
2
2
|
import { ChaiPageProps } from '@chaibuilder/runtime';
|
|
3
3
|
import { JSX } from 'react/jsx-runtime';
|
|
4
4
|
|
|
5
|
-
export declare const applyChaiDataBinding: (block: Record<string, string>, pageExternalData: Record<string, any>) =>
|
|
5
|
+
export declare const applyChaiDataBinding: (block: Record<string, string>, pageExternalData: Record<string, any>) => Record<string, string>;
|
|
6
|
+
|
|
7
|
+
export declare const applyDesignTokens: (blocks: ChaiBlock[], designTokens: DesignTokens) => ChaiBlock[];
|
|
6
8
|
|
|
7
9
|
export declare function AsyncRenderChaiBlocks(props: RenderChaiBlocksProps): Promise<JSX.Element>;
|
|
8
10
|
|
|
@@ -58,6 +60,13 @@ export declare const convertHTMLToChaiBlocks: (html: string) => ChaiBlock[];
|
|
|
58
60
|
*/
|
|
59
61
|
export declare const convertToBlocks: (chaiFormatContent: string) => ChaiBlock[];
|
|
60
62
|
|
|
63
|
+
declare interface DesignTokens {
|
|
64
|
+
[uniqueId: string]: {
|
|
65
|
+
name: string;
|
|
66
|
+
value: string;
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
61
70
|
export declare const getChaiThemeCssVariables: (chaiTheme: ChaiThemeValues) => string;
|
|
62
71
|
|
|
63
72
|
export declare function getMergedPartialBlocks(blocks: ChaiBlock[], partials: Record<string, ChaiBlock[]>): ChaiBlock[];
|
|
@@ -70,9 +79,9 @@ export declare function getMergedPartialBlocks(blocks: ChaiBlock[], partials: Re
|
|
|
70
79
|
*/
|
|
71
80
|
export declare const getStylesForBlocks: (blocks: ChaiBlock[], includeBaseStyles?: boolean) => Promise<string>;
|
|
72
81
|
|
|
73
|
-
export declare const getThemeFontsCSSImport: (fonts: ChaiFontViaUrl[]) =>
|
|
82
|
+
export declare const getThemeFontsCSSImport: (fonts: ChaiFontViaUrl[]) => string;
|
|
74
83
|
|
|
75
|
-
export declare const getThemeFontsLinkMarkup: (fonts: ChaiFontViaUrl[]) =>
|
|
84
|
+
export declare const getThemeFontsLinkMarkup: (fonts: ChaiFontViaUrl[]) => string;
|
|
76
85
|
|
|
77
86
|
declare type HexColor = string;
|
|
78
87
|
|
package/dist/render.js
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
import { c as Q } from "./plugin-BOcGV_IY.js";
|
|
2
|
-
import { a as
|
|
3
|
-
import { a as O, b as N, g as E, c as J, d as
|
|
4
|
-
import { f as
|
|
5
|
-
import { jsx as
|
|
6
|
-
import { getRegisteredChaiBlock as
|
|
7
|
-
import { has as
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import ae from "@tailwindcss/typography";
|
|
2
|
+
import { a as Ke, b as Re, e as Ae } from "./plugin-BOcGV_IY.js";
|
|
3
|
+
import { a as O, b as N, g as E, c as J, d as C, e as j } from "./apply-binding-BwPhgnhk.js";
|
|
4
|
+
import { f as Me, i as Oe, h as Ne } from "./apply-binding-BwPhgnhk.js";
|
|
5
|
+
import { jsx as m } from "react/jsx-runtime";
|
|
6
|
+
import { getRegisteredChaiBlock as $ } from "@chaibuilder/runtime";
|
|
7
|
+
import { has as P, isFunction as w, omit as q, get as d, isNull as H, isArray as b, uniqBy as W, filter as S, isEmpty as h, map as U, find as R, cloneDeep as X } from "lodash-es";
|
|
8
|
+
import { Suspense as A, createElement as p } from "react";
|
|
9
|
+
import Y from "@tailwindcss/aspect-ratio";
|
|
10
|
+
import Z from "@tailwindcss/forms";
|
|
11
|
+
import ee from "@tailwindcss/typography";
|
|
13
12
|
import "tailwindcss-animate";
|
|
14
|
-
import { g as
|
|
15
|
-
import { createTailwindcss as
|
|
16
|
-
import
|
|
17
|
-
async function
|
|
13
|
+
import { g as te } from "./get-chai-builder-theme-BarMkcGH.js";
|
|
14
|
+
import { createTailwindcss as ae } from "@mhsdesign/jit-browser-tailwindcss";
|
|
15
|
+
import re from "@tailwindcss/container-queries";
|
|
16
|
+
async function ne(e) {
|
|
18
17
|
const t = {
|
|
19
18
|
pageProps: e.pageProps,
|
|
20
19
|
block: e.block,
|
|
@@ -22,30 +21,30 @@ async function oe(e) {
|
|
|
22
21
|
draft: e.draft,
|
|
23
22
|
inBuilder: !1
|
|
24
23
|
}, r = await e.dataProvider(t);
|
|
25
|
-
return
|
|
24
|
+
return P(r, "$metadata") && w(e.dataProviderMetadataCallback) && e.dataProviderMetadataCallback(e.block, r.$metadata), e.children({
|
|
26
25
|
...q(r, "$metadata")
|
|
27
26
|
});
|
|
28
27
|
}
|
|
29
|
-
const
|
|
30
|
-
const { block: t, lang: r, fallbackLang: i, children: n, externalData: s, blocks: o, draft: a, pageProps: l, dataProviderMetadataCallback: k } = e, c =
|
|
28
|
+
const ie = () => /* @__PURE__ */ m("div", {}), oe = (e) => {
|
|
29
|
+
const { block: t, lang: r, fallbackLang: i, children: n, externalData: s, blocks: o, draft: a, pageProps: l, dataProviderMetadataCallback: k } = e, c = $(t._type), u = d(c, "component", null), _ = d(e.repeaterData, "index", -1), y = d(e.repeaterData, "dataKey", ""), f = O(
|
|
31
30
|
N(t, r === i ? "" : r, c),
|
|
32
31
|
s,
|
|
33
32
|
{ index: _, key: y }
|
|
34
|
-
),
|
|
35
|
-
...
|
|
36
|
-
...
|
|
37
|
-
...
|
|
38
|
-
},
|
|
33
|
+
), g = E(t, !1), x = V(o, t._id, J(t._type)), L = P(c, "dataProvider") && w(c.dataProvider), B = {
|
|
34
|
+
...f,
|
|
35
|
+
...g,
|
|
36
|
+
...x
|
|
37
|
+
}, v = {
|
|
39
38
|
blockProps: {},
|
|
40
39
|
inBuilder: !1,
|
|
41
40
|
lang: r || i,
|
|
42
41
|
...B
|
|
43
|
-
},
|
|
44
|
-
if (H(u) || !
|
|
45
|
-
if (
|
|
46
|
-
const
|
|
47
|
-
return /* @__PURE__ */
|
|
48
|
-
|
|
42
|
+
}, I = d(B, "_show", !0);
|
|
43
|
+
if (H(u) || !I) return null;
|
|
44
|
+
if (L) {
|
|
45
|
+
const D = d(c, "suspenseFallback", ie);
|
|
46
|
+
return /* @__PURE__ */ m(A, { fallback: p(D), children: /* @__PURE__ */ m(
|
|
47
|
+
ne,
|
|
49
48
|
{
|
|
50
49
|
lang: r,
|
|
51
50
|
pageProps: l,
|
|
@@ -53,51 +52,51 @@ const se = () => /* @__PURE__ */ f("div", {}), le = (e) => {
|
|
|
53
52
|
dataProvider: c.dataProvider,
|
|
54
53
|
...k ? { dataProviderMetadataCallback: k } : {},
|
|
55
54
|
draft: a,
|
|
56
|
-
children: (
|
|
57
|
-
...
|
|
58
|
-
...
|
|
55
|
+
children: (K) => p(u, {
|
|
56
|
+
...v,
|
|
57
|
+
...K,
|
|
59
58
|
children: n({
|
|
60
59
|
_id: t._id,
|
|
61
60
|
_type: t._type,
|
|
62
|
-
...
|
|
63
|
-
repeaterItems:
|
|
64
|
-
$repeaterItemsKey:
|
|
65
|
-
repeaterTotalItems:
|
|
61
|
+
...b(f.repeaterItems) ? {
|
|
62
|
+
repeaterItems: C(f.repeaterItems, t),
|
|
63
|
+
$repeaterItemsKey: f.$repeaterItemsKey,
|
|
64
|
+
repeaterTotalItems: f.repeaterTotalItems ?? -1
|
|
66
65
|
} : {}
|
|
67
66
|
})
|
|
68
67
|
})
|
|
69
68
|
}
|
|
70
69
|
) });
|
|
71
70
|
}
|
|
72
|
-
return /* @__PURE__ */
|
|
73
|
-
...
|
|
71
|
+
return /* @__PURE__ */ m(A, { children: p(u, {
|
|
72
|
+
...v,
|
|
74
73
|
children: n({
|
|
75
74
|
_id: t._id,
|
|
76
75
|
_type: t._type,
|
|
77
|
-
...
|
|
78
|
-
repeaterItems:
|
|
79
|
-
$repeaterItemsKey:
|
|
80
|
-
repeaterTotalItems:
|
|
76
|
+
...b(f.repeaterItems) ? {
|
|
77
|
+
repeaterItems: C(f.repeaterItems, t),
|
|
78
|
+
$repeaterItemsKey: f.$repeaterItemsKey,
|
|
79
|
+
repeaterTotalItems: f.repeaterTotalItems ?? -1
|
|
81
80
|
} : {}
|
|
82
81
|
})
|
|
83
82
|
}) });
|
|
84
|
-
},
|
|
83
|
+
}, F = (e) => {
|
|
85
84
|
const { blocks: t, parent: r, repeaterData: i, type: n } = e;
|
|
86
85
|
let s = W(
|
|
87
|
-
|
|
86
|
+
S(t, (a) => P(a, "_id") && (h(r) ? !a._parent : a._parent === r)),
|
|
88
87
|
"_id"
|
|
89
88
|
);
|
|
90
|
-
const o = (a) =>
|
|
91
|
-
return (n === "Heading" || n === "Paragraph" || n === "Link") && (s = j(s)), U(s, (a) => a ? /* @__PURE__ */
|
|
92
|
-
|
|
89
|
+
const o = (a) => S(t, (l) => l._parent === a).length > 0;
|
|
90
|
+
return (n === "Heading" || n === "Paragraph" || n === "Link" || n === "Span") && (s = j(s)), U(s, (a) => a ? /* @__PURE__ */ p(oe, { ...e, key: a._id, block: a }, ({ _id: l, _type: k, repeaterItems: c, $repeaterItemsKey: u }) => k === "Repeater" ? b(c) && c.map((_, y) => /* @__PURE__ */ p(
|
|
91
|
+
F,
|
|
93
92
|
{
|
|
94
93
|
...e,
|
|
95
94
|
parent: a._id,
|
|
96
95
|
key: `${d(a, "_parent", "root")}-${a._id}-${y}`,
|
|
97
96
|
repeaterData: { index: y, dataKey: u }
|
|
98
97
|
}
|
|
99
|
-
)) : o(l) ? /* @__PURE__ */
|
|
100
|
-
|
|
98
|
+
)) : o(l) ? /* @__PURE__ */ p(
|
|
99
|
+
F,
|
|
101
100
|
{
|
|
102
101
|
...e,
|
|
103
102
|
parent: a._id,
|
|
@@ -114,21 +113,21 @@ const se = () => /* @__PURE__ */ f("div", {}), le = (e) => {
|
|
|
114
113
|
const l = R(o, { _type: s.block });
|
|
115
114
|
return l && (i[n] = d(l, d(s, "prop"), null)), i;
|
|
116
115
|
}, {});
|
|
117
|
-
function
|
|
116
|
+
function Ce(e) {
|
|
118
117
|
if (h(e.lang) && !h(e.fallbackLang))
|
|
119
118
|
throw new Error("lang prop is required when fallbackLang is provided");
|
|
120
119
|
if (h(e.blocks))
|
|
121
120
|
return null;
|
|
122
121
|
const t = e.lang ?? "en", r = e.fallbackLang ?? t;
|
|
123
|
-
return /* @__PURE__ */
|
|
122
|
+
return /* @__PURE__ */ m(F, { ...e, lang: t, fallbackLang: r });
|
|
124
123
|
}
|
|
125
|
-
async function
|
|
124
|
+
async function se(e) {
|
|
126
125
|
const t = await e.dataProvider;
|
|
127
|
-
return
|
|
126
|
+
return P(t, "$metadata") && w(e.dataProviderMetadataCallback) && e.dataProviderMetadataCallback(e.block, t.$metadata), e.children({
|
|
128
127
|
...q(t, "$metadata")
|
|
129
128
|
});
|
|
130
129
|
}
|
|
131
|
-
const
|
|
130
|
+
const le = () => /* @__PURE__ */ m("div", {}), de = async (e) => {
|
|
132
131
|
const {
|
|
133
132
|
block: t,
|
|
134
133
|
lang: r,
|
|
@@ -140,77 +139,79 @@ const ce = () => /* @__PURE__ */ f("div", {}), ue = async (e) => {
|
|
|
140
139
|
pageProps: l,
|
|
141
140
|
dataProviderMetadataCallback: k,
|
|
142
141
|
dataProviders: c
|
|
143
|
-
} = e, u =
|
|
142
|
+
} = e, u = $(t._type), _ = d(u, "component", null), y = d(e.repeaterData, "index", -1), M = d(e.repeaterData, "dataKey", ""), g = O(
|
|
144
143
|
N(t, r === i ? "" : r, u),
|
|
145
144
|
s,
|
|
146
145
|
{ index: y, key: M }
|
|
147
|
-
),
|
|
148
|
-
...
|
|
149
|
-
...
|
|
150
|
-
...
|
|
151
|
-
},
|
|
146
|
+
), x = E(t, !1), L = V(o, t._id, J(t._type)), B = P(u, "dataProvider") && w(u.dataProvider), v = {
|
|
147
|
+
...g,
|
|
148
|
+
...x,
|
|
149
|
+
...L
|
|
150
|
+
}, I = {
|
|
152
151
|
blockProps: {},
|
|
153
152
|
inBuilder: !1,
|
|
154
153
|
lang: r || i,
|
|
155
|
-
...
|
|
156
|
-
},
|
|
157
|
-
if (H(_) || !
|
|
154
|
+
...v
|
|
155
|
+
}, D = d(v, "_show", !0);
|
|
156
|
+
if (H(_) || !D) return null;
|
|
158
157
|
if (B) {
|
|
159
|
-
const
|
|
160
|
-
return /* @__PURE__ */
|
|
161
|
-
|
|
158
|
+
const K = d(c, t._id, Promise.resolve({})), G = d(u, "suspenseFallback", le);
|
|
159
|
+
return /* @__PURE__ */ m(A, { fallback: p(G), children: /* @__PURE__ */ m(
|
|
160
|
+
se,
|
|
162
161
|
{
|
|
163
162
|
lang: r,
|
|
164
163
|
pageProps: l,
|
|
165
|
-
block:
|
|
166
|
-
dataProvider:
|
|
164
|
+
block: v,
|
|
165
|
+
dataProvider: K,
|
|
167
166
|
...k ? { dataProviderMetadataCallback: k } : {},
|
|
168
167
|
draft: a,
|
|
169
|
-
children: (z) =>
|
|
170
|
-
...
|
|
168
|
+
children: (z) => p(_, {
|
|
169
|
+
...I,
|
|
170
|
+
draft: a,
|
|
171
171
|
...z,
|
|
172
172
|
children: n({
|
|
173
173
|
_id: t._id,
|
|
174
174
|
_type: t._type,
|
|
175
|
-
...
|
|
176
|
-
repeaterItems:
|
|
177
|
-
$repeaterItemsKey:
|
|
178
|
-
repeaterTotalItems:
|
|
175
|
+
...b(g.repeaterItems) ? {
|
|
176
|
+
repeaterItems: C(g.repeaterItems, t),
|
|
177
|
+
$repeaterItemsKey: g.$repeaterItemsKey,
|
|
178
|
+
repeaterTotalItems: g.repeaterTotalItems ?? -1
|
|
179
179
|
} : {}
|
|
180
180
|
})
|
|
181
181
|
})
|
|
182
182
|
}
|
|
183
183
|
) });
|
|
184
184
|
}
|
|
185
|
-
return
|
|
186
|
-
...
|
|
185
|
+
return p(_, {
|
|
186
|
+
...I,
|
|
187
|
+
draft: a,
|
|
187
188
|
children: n({
|
|
188
189
|
_id: t._id,
|
|
189
190
|
_type: t._type,
|
|
190
|
-
...
|
|
191
|
-
repeaterItems:
|
|
192
|
-
$repeaterItemsKey:
|
|
193
|
-
repeaterTotalItems:
|
|
191
|
+
...b(g.repeaterItems) ? {
|
|
192
|
+
repeaterItems: C(g.repeaterItems, t),
|
|
193
|
+
$repeaterItemsKey: g.$repeaterItemsKey,
|
|
194
|
+
repeaterTotalItems: g.repeaterTotalItems ?? -1
|
|
194
195
|
} : {}
|
|
195
196
|
})
|
|
196
|
-
})
|
|
197
|
-
},
|
|
197
|
+
});
|
|
198
|
+
}, T = async (e) => {
|
|
198
199
|
const { blocks: t, parent: r, repeaterData: i, type: n } = e;
|
|
199
200
|
let s = W(
|
|
200
|
-
|
|
201
|
+
S(t, (a) => P(a, "_id") && (h(r) ? !a._parent : a._parent === r)),
|
|
201
202
|
"_id"
|
|
202
203
|
);
|
|
203
|
-
const o = (a) =>
|
|
204
|
-
return (n === "Heading" || n === "Paragraph" || n === "Link") && (s = j(s)), U(s, (a) => a ? /* @__PURE__ */
|
|
205
|
-
|
|
204
|
+
const o = (a) => S(t, (l) => l._parent === a).length > 0;
|
|
205
|
+
return (n === "Heading" || n === "Paragraph" || n === "Link") && (s = j(s)), U(s, (a) => a ? /* @__PURE__ */ p(de, { dataProviders: e.dataProviders, ...e, key: a._id, block: a }, ({ _id: l, _type: k, repeaterItems: c, $repeaterItemsKey: u }) => k === "Repeater" ? b(c) && c.map((_, y) => /* @__PURE__ */ p(
|
|
206
|
+
T,
|
|
206
207
|
{
|
|
207
208
|
...e,
|
|
208
209
|
parent: a._id,
|
|
209
210
|
key: `${d(a, "_parent", "root")}-${a._id}-${y}`,
|
|
210
211
|
repeaterData: { index: y, dataKey: u }
|
|
211
212
|
}
|
|
212
|
-
)) : o(l) ? /* @__PURE__ */
|
|
213
|
-
|
|
213
|
+
)) : o(l) ? /* @__PURE__ */ p(
|
|
214
|
+
T,
|
|
214
215
|
{
|
|
215
216
|
...e,
|
|
216
217
|
parent: a._id,
|
|
@@ -220,20 +221,20 @@ const ce = () => /* @__PURE__ */ f("div", {}), ue = async (e) => {
|
|
|
220
221
|
}
|
|
221
222
|
) : null) : null);
|
|
222
223
|
};
|
|
223
|
-
async function
|
|
224
|
+
async function $e(e) {
|
|
224
225
|
if (h(e.lang) && !h(e.fallbackLang))
|
|
225
226
|
throw new Error("lang prop is required when fallbackLang is provided");
|
|
226
227
|
if (h(e.blocks))
|
|
227
228
|
return null;
|
|
228
229
|
const t = e.lang ?? "en", r = e.fallbackLang ?? t;
|
|
229
230
|
if (e.dataProviders)
|
|
230
|
-
return /* @__PURE__ */
|
|
231
|
+
return /* @__PURE__ */ m(T, { ...e, lang: t, fallbackLang: r, dataProviders: e.dataProviders });
|
|
231
232
|
const n = e.blocks.filter((s) => {
|
|
232
|
-
const o =
|
|
233
|
-
return !!(
|
|
233
|
+
const o = $(s._type);
|
|
234
|
+
return !!(P(o, "dataProvider") && w(o.dataProvider));
|
|
234
235
|
}).reduce(
|
|
235
236
|
(s, o) => {
|
|
236
|
-
const a =
|
|
237
|
+
const a = $(o._type), l = {
|
|
237
238
|
pageProps: e.pageProps,
|
|
238
239
|
block: o,
|
|
239
240
|
lang: e.lang,
|
|
@@ -244,43 +245,43 @@ async function Le(e) {
|
|
|
244
245
|
},
|
|
245
246
|
{}
|
|
246
247
|
);
|
|
247
|
-
return /* @__PURE__ */
|
|
248
|
+
return /* @__PURE__ */ m(T, { ...e, lang: t, fallbackLang: r, dataProviders: n });
|
|
248
249
|
}
|
|
249
|
-
function
|
|
250
|
+
function Se(e, t) {
|
|
250
251
|
const r = e.filter(({ _type: i }) => i === "GlobalBlock" || i === "PartialBlock");
|
|
251
252
|
for (let i = 0; i < r.length; i++) {
|
|
252
253
|
const n = r[i], s = d(n, "partialBlockId", d(n, "globalBlock", ""));
|
|
253
254
|
if (s === "") continue;
|
|
254
|
-
let o =
|
|
255
|
+
let o = X(d(t, s, []));
|
|
255
256
|
n._parent && (o == null ? void 0 : o.length) > 0 && (o = o.map((l) => (h(l._parent) && (l._parent = n._parent), l)));
|
|
256
257
|
const a = e.indexOf(n);
|
|
257
258
|
e.splice(a, 1, ...o);
|
|
258
259
|
}
|
|
259
260
|
return e;
|
|
260
261
|
}
|
|
261
|
-
const
|
|
262
|
+
const Te = (e) => {
|
|
262
263
|
if (!e) return [];
|
|
263
264
|
try {
|
|
264
|
-
return JSON.parse(
|
|
265
|
+
return JSON.parse(ce(e)).filter((r) => !r._type.startsWith("@chai"));
|
|
265
266
|
} catch {
|
|
266
267
|
return [{ _type: "Paragraph", _id: "error", content: "Invalid JSON. Please check the JSON string." }];
|
|
267
268
|
}
|
|
268
269
|
};
|
|
269
|
-
function
|
|
270
|
+
function ce(e) {
|
|
270
271
|
const t = /(asset:\/\/|https:\/\/asset\.localhost\/)(?:localhost\/)?[^"']+/g;
|
|
271
272
|
return e.replace(t, (r) => {
|
|
272
273
|
const i = decodeURIComponent(r), n = i.indexOf("public");
|
|
273
274
|
return n !== -1 ? i.substring(n + 6) : i;
|
|
274
275
|
});
|
|
275
276
|
}
|
|
276
|
-
async function
|
|
277
|
-
return await
|
|
277
|
+
async function ue(e, t = [], r = !1) {
|
|
278
|
+
return await ae({
|
|
278
279
|
tailwindConfig: {
|
|
279
280
|
darkMode: "class",
|
|
280
281
|
safelist: t,
|
|
281
282
|
theme: {
|
|
282
283
|
extend: {
|
|
283
|
-
...
|
|
284
|
+
...te(),
|
|
284
285
|
keyframes: {
|
|
285
286
|
"accordion-down": {
|
|
286
287
|
from: {
|
|
@@ -305,7 +306,7 @@ async function pe(e, t = [], r = !1) {
|
|
|
305
306
|
}
|
|
306
307
|
}
|
|
307
308
|
},
|
|
308
|
-
plugins: [
|
|
309
|
+
plugins: [Z, ee, Y, re, Q],
|
|
309
310
|
corePlugins: { preflight: r }
|
|
310
311
|
}
|
|
311
312
|
}).generateStylesFromContent(
|
|
@@ -315,19 +316,20 @@ async function pe(e, t = [], r = !1) {
|
|
|
315
316
|
e
|
|
316
317
|
);
|
|
317
318
|
}
|
|
318
|
-
const
|
|
319
|
+
const pe = (e, t) => {
|
|
319
320
|
const r = JSON.stringify(e).replace(/#styles:([^"]*)/g, (i, n) => `#styles:${n.replace(/,/g, " ")}`.replace(/#styles:/g, ""));
|
|
320
|
-
return
|
|
321
|
-
},
|
|
321
|
+
return ue([r], [], t);
|
|
322
|
+
}, xe = async (e, t = !1) => await pe(e, t);
|
|
322
323
|
export {
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
324
|
+
$e as AsyncRenderChaiBlocks,
|
|
325
|
+
Ce as RenderChaiBlocks,
|
|
326
|
+
Me as applyChaiDataBinding,
|
|
327
|
+
Oe as applyDesignTokens,
|
|
328
|
+
Ne as convertHTMLToChaiBlocks,
|
|
329
|
+
Te as convertToBlocks,
|
|
330
|
+
Ke as getChaiThemeCssVariables,
|
|
331
|
+
Se as getMergedPartialBlocks,
|
|
332
|
+
xe as getStylesForBlocks,
|
|
333
|
+
Re as getThemeFontsCSSImport,
|
|
334
|
+
Ae as getThemeFontsLinkMarkup
|
|
333
335
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as e, jsxs as c } from "react/jsx-runtime";
|
|
2
|
-
import { d as N, N as D } from "./index-
|
|
3
|
-
import { a1 as v, a3 as S, a6 as j, a9 as w, v as y } from "./tooltip-
|
|
2
|
+
import { d as N, N as D } from "./index-vLM3DaDo.js";
|
|
3
|
+
import { a1 as v, a3 as S, a6 as j, a9 as w, v as y } from "./tooltip-DUosa-uC.js";
|
|
4
4
|
import "clsx";
|
|
5
5
|
import "tailwind-merge";
|
|
6
6
|
const b = ({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),u=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),u=require("./index-DqxtRdta.cjs"),n=require("./tooltip-Ba1-8jmj.cjs");require("clsx");require("tailwind-merge");const S=({isOpen:m,onClose:l,editor:t,rteElement:f})=>{const r=u.usePageExternalData(),j=o=>{if(!t)return;const i=`{{${o}}}`;t.commands.focus();const{from:p,to:g}=t.state.selection;if(p!==g)t.chain().deleteSelection().insertContent(i).run();else{const{state:c}=t,s=c.selection.from,x=c.doc.textBetween(Math.max(0,s-1),s),a=c.doc.textBetween(s,Math.min(s+1,c.doc.content.size));let d="";s>0&&x!==" "&&!/[.,!?;:]/.test(x)&&(d=" ");let h="";a&&a!==" "&&!/[.,!?;:]/.test(a)&&(h=" "),t.chain().insertContent(d+i+h).run()}};return e.jsx(n.Dialog,{open:m,onOpenChange:o=>!o&&l(),children:e.jsxs(n.DialogContent,{className:"max-h-[90vh] overflow-y-auto sm:max-w-[800px]",children:[e.jsx(n.DialogHeader,{children:e.jsxs(n.DialogTitle,{className:"flex items-center justify-between pr-8",children:[e.jsx("span",{children:"Rich Text Editor"}),Object.keys(r).length>0&&e.jsxs("div",{className:"flex items-center",children:[e.jsx("span",{className:"mr-2 text-sm text-muted-foreground",children:"Add field:"}),e.jsx("div",{className:"rte-path-selector",children:e.jsx(u.NestedPathSelector,{data:r,onSelect:j})})]})]})}),f,e.jsx("div",{className:"mt-4 flex justify-end",children:e.jsx(n.Button,{onClick:l,children:"Done"})})]})})};exports.default=S;
|
package/dist/tailwind.d.ts
CHANGED
|
@@ -99,7 +99,7 @@ export declare const getChaiBuilderTailwindConfig: (content: string[]) => {
|
|
|
99
99
|
};
|
|
100
100
|
|
|
101
101
|
export declare const getChaiBuilderTheme: (themeOptions?: ChaiBuilderThemeOptions) => {
|
|
102
|
-
fontFamily:
|
|
102
|
+
fontFamily: {};
|
|
103
103
|
borderRadius: {
|
|
104
104
|
lg: string;
|
|
105
105
|
md: string;
|
|
@@ -109,7 +109,7 @@ export declare const getChaiBuilderTheme: (themeOptions?: ChaiBuilderThemeOption
|
|
|
109
109
|
md?: undefined;
|
|
110
110
|
sm?: undefined;
|
|
111
111
|
};
|
|
112
|
-
colors:
|
|
112
|
+
colors: {};
|
|
113
113
|
container: {
|
|
114
114
|
center: boolean;
|
|
115
115
|
padding: string;
|