@chaibuilder/sdk 1.2.9 → 1.2.10-7.beta.2
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/README.md +26 -21
- package/dist/CodeEditor-2fowVPcS.cjs +143 -0
- package/dist/CodeEditor-b6uePnTe.js +143 -0
- package/dist/STRINGS-RCf9qnaS.cjs +9 -0
- package/dist/STRINGS-t8UhMYZ6.js +10 -0
- package/dist/Topbar-O21Nrw2O.cjs +137 -0
- package/dist/Topbar-xFfdTq1m.js +137 -0
- package/dist/UnsplashImages-awQiGFMX.cjs +280 -0
- package/dist/UnsplashImages-qQmFIWEy.js +280 -0
- package/dist/UploadImages-a8Hl0tyg.cjs +170 -0
- package/dist/UploadImages-cudxJepv.js +170 -0
- package/dist/context-menu-VMB9i0d8.cjs +1074 -0
- package/dist/context-menu-mp3Gu2KA.js +1043 -0
- package/dist/controls-4t-C_rP2.cjs +233 -0
- package/dist/controls-fQIu127i.js +234 -0
- package/dist/core.cjs +135 -1
- package/dist/core.d.ts +344 -119
- package/dist/core.js +111 -88
- package/dist/iconBase-OGxLGBQ1.cjs +156 -0
- package/dist/iconBase-Ofd16yeE.js +157 -0
- package/dist/index-R7v8ZYnu.js +12110 -0
- package/dist/index-WHVUpVPa.cjs +12125 -0
- package/dist/jsx-runtime-_yxTjXEh.js +931 -0
- package/dist/jsx-runtime-vPqyLgmD.cjs +930 -0
- package/dist/mockServiceWorker.js +18 -10
- package/dist/plugin-RAiM74uD.cjs +116 -0
- package/dist/plugin-T1qbgBUO.js +55 -0
- package/dist/plugin-YcxlCmRm.js +117 -0
- package/dist/plugin-cYi6q9KC.cjs +54 -0
- package/dist/render.cjs +215 -1
- package/dist/render.d.ts +21 -40
- package/dist/render.js +190 -98
- package/dist/runtime.cjs +28 -0
- package/dist/runtime.d.ts +5 -0
- package/dist/runtime.js +21 -0
- package/dist/style.css +1524 -1
- package/dist/tailwind.cjs +80 -1
- package/dist/tailwind.d.ts +49 -8
- package/dist/tailwind.js +23 -25
- package/dist/ui.cjs +410 -1
- package/dist/ui.d.ts +3 -13
- package/dist/ui.js +374 -163
- package/dist/web-blocks.cjs +1246 -9
- package/dist/web-blocks.d.ts +1 -1
- package/dist/web-blocks.js +961 -789
- package/package.json +66 -83
- package/dist/AddBlocks-tMxKPoen.js +0 -225
- package/dist/AddBlocks-x2LkOHSj.cjs +0 -1
- package/dist/BrandingOptions-EzT9UYd6.cjs +0 -1
- package/dist/BrandingOptions-QJJ1y5ez.js +0 -194
- package/dist/CanvasArea-mlNKmCOh.js +0 -1425
- package/dist/CanvasArea-xs4wM64L.cjs +0 -60
- package/dist/CurrentPage-aaU4F7wi.cjs +0 -1
- package/dist/CurrentPage-lBy25sZn.js +0 -111
- package/dist/Functions-7jnEwJyw.js +0 -15
- package/dist/Functions-N3yhPYKY.cjs +0 -1
- package/dist/Layers-3Xs4A5i8.js +0 -404
- package/dist/Layers-eaHy5PK9.cjs +0 -1
- package/dist/MODIFIERS-2FeVfZQ9.cjs +0 -1
- package/dist/MODIFIERS-RiXS5Mn1.js +0 -67
- package/dist/MarkAsGlobalBlock-BjP-Rqlf.js +0 -88
- package/dist/MarkAsGlobalBlock-X5dNmZcb.cjs +0 -1
- package/dist/PagesPanel--BZhafnt.js +0 -69
- package/dist/PagesPanel-gGKCV394.cjs +0 -1
- package/dist/ProjectPanel-YcLkM-DW.js +0 -90
- package/dist/ProjectPanel-yFJRy0_E.cjs +0 -1
- package/dist/Settings-7wlLcvoh.cjs +0 -1
- package/dist/Settings-TAgX4hov.js +0 -2186
- package/dist/SidePanels-5H4j0mIs.cjs +0 -1
- package/dist/SidePanels-btVQQkVK.js +0 -349
- package/dist/Topbar-V8xCetWF.cjs +0 -1
- package/dist/Topbar-j4t4AgCq.js +0 -116
- package/dist/UnsplashImages-41Y3q5_Q.js +0 -200
- package/dist/UnsplashImages-DbHky6cj.cjs +0 -1
- package/dist/UploadImages-DnQ95_NW.cjs +0 -1
- package/dist/UploadImages-xBg-kbKv.js +0 -138
- package/dist/_commonjsHelpers-UyOWmZb0.js +0 -8
- package/dist/_commonjsHelpers-wDK0ZLPo.cjs +0 -1
- package/dist/add-page-modal-MwS7iXn_.cjs +0 -1
- package/dist/add-page-modal-cm8damU2.js +0 -108
- package/dist/confirm-alert-U7-NcG7G.cjs +0 -1
- package/dist/confirm-alert-i4pM3mOt.js +0 -62
- package/dist/controls-Dy1qa8Dc.cjs +0 -1
- package/dist/controls-XPXGHKht.js +0 -182
- package/dist/delete-page-modal-5o4jXu-z.cjs +0 -1
- package/dist/delete-page-modal-YrIBvfFA.js +0 -88
- package/dist/email-blocks.cjs +0 -1
- package/dist/email-blocks.d.ts +0 -3
- package/dist/email-blocks.js +0 -274
- package/dist/form-OVmsLOrc.js +0 -125
- package/dist/form-VbouZlAW.cjs +0 -1
- package/dist/functions-Ox_svtKm.cjs +0 -1
- package/dist/functions-xIebp8Aw.js +0 -23
- package/dist/html-to-json-2PeOCVey.cjs +0 -1
- package/dist/html-to-json-57841sEK.js +0 -183
- package/dist/index-H6vIwGfD.cjs +0 -1
- package/dist/index-N50dZnlC.cjs +0 -206
- package/dist/index-e0c8PmRQ.js +0 -205
- package/dist/index-gi1LIOCw.cjs +0 -1
- package/dist/index-niHREMmR.js +0 -2938
- package/dist/index-pZhGT8uT.js +0 -41620
- package/dist/jsx-runtime-WbnYoNE9.js +0 -634
- package/dist/jsx-runtime-Z_BpKhVy.cjs +0 -27
- package/dist/lib.cjs +0 -4
- package/dist/lib.d.ts +0 -78
- package/dist/lib.js +0 -1322
- package/dist/page-viewer-SLt8XgYv.cjs +0 -1
- package/dist/page-viewer-feqJr1QI.js +0 -115
- package/dist/project-general-setting-SgagORzW.js +0 -83
- package/dist/project-general-setting-ym0yCdOq.cjs +0 -1
- package/dist/project-seo-setting-Snn2nZgS.cjs +0 -1
- package/dist/project-seo-setting-wxAGEkd_.js +0 -85
- package/dist/server.cjs +0 -1
- package/dist/server.d.ts +0 -299
- package/dist/server.js +0 -216
- package/dist/single-page-detail-IPod1o5P.cjs +0 -1
- package/dist/single-page-detail-dnWMyg6P.js +0 -222
- package/dist/studio.cjs +0 -1
- package/dist/studio.d.ts +0 -13
- package/dist/studio.js +0 -58
- package/dist/useAddBlockByDrop-_nwI4W3q.js +0 -20
- package/dist/useAddBlockByDrop-inkD7Lck.cjs +0 -1
- package/dist/utils-AvyFzbPC.js +0 -1075
- package/dist/utils-PTxFk6qT.cjs +0 -1
package/dist/render.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { JSX as JSX_2 } from 'react/jsx-runtime';
|
|
2
|
-
import { default as React_2 } from 'react';
|
|
3
2
|
|
|
4
3
|
declare type ChaiBlock = {
|
|
5
4
|
_id: string;
|
|
@@ -9,51 +8,33 @@ declare type ChaiBlock = {
|
|
|
9
8
|
_bindings?: Record<string, string>;
|
|
10
9
|
} & Record<string, any>;
|
|
11
10
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
subPages?: {
|
|
24
|
-
uuid: string;
|
|
25
|
-
blocks: ChaiBlock[];
|
|
26
|
-
providers: {
|
|
27
|
-
providerKey: string;
|
|
28
|
-
args: Record<string, any>;
|
|
29
|
-
}[];
|
|
30
|
-
}[];
|
|
31
|
-
project: {
|
|
32
|
-
name?: string;
|
|
33
|
-
favicon?: string;
|
|
34
|
-
brandingOptions: Record<string, string | number>;
|
|
35
|
-
seoData?: Record<string, string>;
|
|
36
|
-
primaryLanguage?: string;
|
|
37
|
-
languages?: string[];
|
|
38
|
-
homepage?: string;
|
|
39
|
-
};
|
|
40
|
-
};
|
|
11
|
+
declare type ChaiBuilderTailwindTheme<T extends Record<string, unknown> = Record<string, unknown>> = {
|
|
12
|
+
primaryColor: string;
|
|
13
|
+
secondaryColor: string;
|
|
14
|
+
headingFont: string;
|
|
15
|
+
bodyFont: string;
|
|
16
|
+
roundedCorners: string;
|
|
17
|
+
bodyBgLightColor: string;
|
|
18
|
+
bodyBgDarkColor: string;
|
|
19
|
+
bodyTextLightColor: string;
|
|
20
|
+
bodyTextDarkColor: string;
|
|
21
|
+
} & T;
|
|
41
22
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
externalData?: Record<string, any>;
|
|
48
|
-
};
|
|
23
|
+
/**
|
|
24
|
+
* This function converts the chai format content to chai blocks
|
|
25
|
+
* @param chaiFormatContent
|
|
26
|
+
*/
|
|
27
|
+
export declare const convertToBlocks: (chaiFormatContent: string) => ChaiBlock[];
|
|
49
28
|
|
|
50
|
-
export declare
|
|
29
|
+
export declare const getStylesForBlocks: (blocks: ChaiBlock[], theme?: ChaiBuilderTailwindTheme | Record<string, string>, includeBaseStyles?: boolean) => Promise<string>;
|
|
30
|
+
|
|
31
|
+
export declare function RenderChaiBlocks({ blocks, parent, classPrefix, externalData, blockModifierCallback, lang, }: {
|
|
51
32
|
blocks: ChaiBlock[];
|
|
52
33
|
parent?: string;
|
|
53
34
|
classPrefix?: string;
|
|
54
35
|
externalData?: Record<string, any>;
|
|
36
|
+
blockModifierCallback?: (block: ChaiBlock) => ChaiBlock;
|
|
37
|
+
lang?: string;
|
|
55
38
|
}): JSX_2.Element;
|
|
56
39
|
|
|
57
|
-
export declare const RenderChaiPage: ({ pageData, externalData, before, after, classPrefix, }: ChaiPageProps) => JSX_2.Element;
|
|
58
|
-
|
|
59
40
|
export { }
|
package/dist/render.js
CHANGED
|
@@ -1,123 +1,215 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import { getBlockComponent
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
import "
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
import { last, flattenDeep, memoize, filter, isEmpty, omit, isString, get, each, cloneDeep, forEach, keys, has, includes, replace } from "lodash-es";
|
|
2
|
+
import { S as STYLES_KEY, a as SLOT_KEY } from "./STRINGS-t8UhMYZ6.js";
|
|
3
|
+
import { j as jsxRuntimeExports } from "./jsx-runtime-_yxTjXEh.js";
|
|
4
|
+
import React__default from "react";
|
|
5
|
+
import { twMerge } from "tailwind-merge";
|
|
6
|
+
import { getBlockComponent } from "@chaibuilder/runtime";
|
|
7
|
+
import { createTailwindcss } from "@mhsdesign/jit-browser-tailwindcss";
|
|
8
|
+
import forms from "@tailwindcss/forms";
|
|
9
|
+
import typography from "@tailwindcss/typography";
|
|
10
|
+
import aspectRatio from "@tailwindcss/aspect-ratio";
|
|
11
|
+
import { g as getChaiBuilderTheme, c as chaiBuilderPlugin } from "./plugin-T1qbgBUO.js";
|
|
12
|
+
import "./plugin-YcxlCmRm.js";
|
|
13
|
+
const addPrefixToClasses = (classes, prefix = "") => {
|
|
14
|
+
const classesArray = classes.replace(STYLES_KEY, "").split(",");
|
|
15
|
+
const array = classesArray.map((item) => {
|
|
16
|
+
const classes2 = item.split(" ");
|
|
17
|
+
const newClasses = classes2.map((item2) => {
|
|
18
|
+
if (item2 === "")
|
|
19
|
+
return "";
|
|
20
|
+
if (item2.includes(":")) {
|
|
21
|
+
const values = item2.split(":");
|
|
22
|
+
values[values.length - 1] = prefix + last(values);
|
|
23
|
+
return values.join(":");
|
|
24
|
+
}
|
|
25
|
+
return `${prefix}${item2}`;
|
|
26
|
+
});
|
|
27
|
+
return newClasses.join(" ");
|
|
28
|
+
});
|
|
29
|
+
return flattenDeep(array).join(" ");
|
|
30
|
+
};
|
|
31
|
+
const convertToBlocks = (chaiFormatContent) => {
|
|
32
|
+
if (!chaiFormatContent)
|
|
33
|
+
return [];
|
|
34
|
+
try {
|
|
35
|
+
const blocks = JSON.parse(removeAssetPrefix(chaiFormatContent));
|
|
36
|
+
return blocks.filter((block) => !block._type.startsWith("@chai"));
|
|
37
|
+
} catch (error) {
|
|
38
|
+
return [{ _type: "Paragraph", _id: "error", content: "Invalid JSON. Please check the JSON string." }];
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
function removeAssetPrefix(input) {
|
|
42
|
+
const regex = /(asset:\/\/|https:\/\/asset\.localhost\/)(?:localhost\/)?[^"']+/g;
|
|
43
|
+
return input.replace(regex, (match) => {
|
|
44
|
+
const decodedUrl = decodeURIComponent(match);
|
|
45
|
+
const publicIndex = decodedUrl.indexOf("public");
|
|
46
|
+
if (publicIndex !== -1) {
|
|
47
|
+
return decodedUrl.substring(publicIndex + 6);
|
|
48
|
+
}
|
|
49
|
+
return decodedUrl;
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
const getSlots = (block) => {
|
|
53
|
+
const slots = {};
|
|
54
|
+
Object.keys(block).forEach((key) => {
|
|
55
|
+
if (isString(block[key]) && block[key].startsWith(SLOT_KEY)) {
|
|
56
|
+
slots[key] = block[key].replace(SLOT_KEY, "").split(",");
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
return slots;
|
|
60
|
+
};
|
|
61
|
+
const generateClassNames = memoize((styles, classPrefix) => {
|
|
62
|
+
const stylesArray = styles.replace(STYLES_KEY, "").split(",");
|
|
63
|
+
const classes = twMerge(stylesArray[0], stylesArray[1]);
|
|
64
|
+
if (classPrefix === "")
|
|
65
|
+
return classes.replace(STYLES_KEY, "").trim();
|
|
66
|
+
return addPrefixToClasses(classes, classPrefix).replace(STYLES_KEY, "").trim();
|
|
18
67
|
});
|
|
19
|
-
function
|
|
20
|
-
|
|
68
|
+
function getElementAttrs(block, key) {
|
|
69
|
+
const attrs = get(block, `${key}_attrs`, {});
|
|
70
|
+
if (has(attrs, "data-ai-key")) {
|
|
71
|
+
delete attrs["data-ai-key"];
|
|
72
|
+
}
|
|
73
|
+
const attrsKeys = keys(attrs).join(" ");
|
|
74
|
+
if (includes(attrsKeys, "x-show") && !includes(attrsKeys, "x-transition")) {
|
|
75
|
+
attrs["x-transition"] = "";
|
|
76
|
+
}
|
|
77
|
+
return attrs;
|
|
21
78
|
}
|
|
22
|
-
function
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
if (
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
className:
|
|
29
|
-
...
|
|
79
|
+
function getStyleAttrs(block, classPrefix) {
|
|
80
|
+
const styles = {};
|
|
81
|
+
Object.keys(block).forEach((key) => {
|
|
82
|
+
if (isString(block[key]) && block[key].startsWith(STYLES_KEY)) {
|
|
83
|
+
const classes = generateClassNames(block[key], classPrefix);
|
|
84
|
+
styles[key] = {
|
|
85
|
+
className: classes,
|
|
86
|
+
...getElementAttrs(block, key)
|
|
30
87
|
};
|
|
31
88
|
}
|
|
32
|
-
})
|
|
89
|
+
});
|
|
90
|
+
return styles;
|
|
91
|
+
}
|
|
92
|
+
function applyBindings(block, chaiData) {
|
|
93
|
+
const bindings = get(block, "_bindings", {});
|
|
94
|
+
if (isEmpty(bindings))
|
|
95
|
+
return { ...block };
|
|
96
|
+
each(bindings, (value, key) => {
|
|
97
|
+
if (isString(value) && get(chaiData, value, null)) {
|
|
98
|
+
block[key] = get(chaiData, value, null);
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
return block;
|
|
33
102
|
}
|
|
34
|
-
function
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
103
|
+
function applyLanguage(_block, lang, blockDefinition) {
|
|
104
|
+
if (isEmpty(lang))
|
|
105
|
+
return _block;
|
|
106
|
+
const block = cloneDeep(_block);
|
|
107
|
+
forEach(keys(block), (key) => {
|
|
108
|
+
if (get(blockDefinition, ["props", key, "i18n"]) && !isEmpty(lang)) {
|
|
109
|
+
block[key] = get(block, `${key}-${lang}`, block[key]);
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
return block;
|
|
39
113
|
}
|
|
40
|
-
function
|
|
41
|
-
blocks
|
|
42
|
-
parent
|
|
43
|
-
classPrefix
|
|
44
|
-
externalData
|
|
114
|
+
function RenderChaiBlocks({
|
|
115
|
+
blocks,
|
|
116
|
+
parent,
|
|
117
|
+
classPrefix = "",
|
|
118
|
+
externalData = {},
|
|
119
|
+
blockModifierCallback,
|
|
120
|
+
lang
|
|
45
121
|
}) {
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
122
|
+
const allBlocks = blocks;
|
|
123
|
+
const getStyles = (block) => getStyleAttrs(block, classPrefix);
|
|
124
|
+
const filteredBlocks = parent ? filter(blocks, { _parent: parent }) : filter(blocks, (block) => isEmpty(block._parent));
|
|
125
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: React__default.Children.toArray(
|
|
126
|
+
filteredBlocks.map((block, index) => {
|
|
127
|
+
const slots = getSlots(block);
|
|
128
|
+
const attrs = {};
|
|
129
|
+
if (!isEmpty(slots)) {
|
|
130
|
+
Object.keys(slots).forEach((key) => {
|
|
131
|
+
attrs[key] = React__default.Children.toArray(
|
|
132
|
+
slots[key].map((slotId) => /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
133
|
+
RenderChaiBlocks,
|
|
134
|
+
{
|
|
135
|
+
externalData,
|
|
136
|
+
classPrefix,
|
|
137
|
+
blocks: allBlocks,
|
|
138
|
+
parent: slotId,
|
|
139
|
+
lang
|
|
140
|
+
}
|
|
141
|
+
))
|
|
142
|
+
);
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
const blocks2 = filter(allBlocks, { _parent: block._id });
|
|
146
|
+
attrs.children = blocks2.length > 0 ? /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
147
|
+
RenderChaiBlocks,
|
|
66
148
|
{
|
|
67
|
-
externalData
|
|
68
|
-
classPrefix
|
|
69
|
-
parent:
|
|
70
|
-
blocks:
|
|
149
|
+
externalData,
|
|
150
|
+
classPrefix,
|
|
151
|
+
parent: block._id,
|
|
152
|
+
blocks: allBlocks,
|
|
153
|
+
lang
|
|
71
154
|
}
|
|
72
155
|
) : null;
|
|
73
|
-
const
|
|
74
|
-
if (
|
|
75
|
-
let
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
156
|
+
const blockDefinition = getBlockComponent(block._type);
|
|
157
|
+
if (blockDefinition !== null) {
|
|
158
|
+
let syncedBlock = block;
|
|
159
|
+
const Component = blockDefinition.component;
|
|
160
|
+
syncedBlock = { ...blockDefinition.defaults, ...block };
|
|
161
|
+
if (blockModifierCallback) {
|
|
162
|
+
syncedBlock = blockModifierCallback(syncedBlock);
|
|
163
|
+
}
|
|
164
|
+
return React__default.createElement(
|
|
165
|
+
Component,
|
|
166
|
+
omit(
|
|
80
167
|
{
|
|
81
168
|
blockProps: {},
|
|
82
|
-
inBuilder:
|
|
83
|
-
...
|
|
84
|
-
index
|
|
85
|
-
...
|
|
86
|
-
...
|
|
87
|
-
...
|
|
169
|
+
inBuilder: false,
|
|
170
|
+
...syncedBlock,
|
|
171
|
+
index,
|
|
172
|
+
...applyBindings(applyLanguage(block, lang, blockDefinition), externalData),
|
|
173
|
+
...getStyles(syncedBlock),
|
|
174
|
+
...attrs
|
|
88
175
|
},
|
|
89
176
|
["_parent"]
|
|
90
177
|
)
|
|
91
178
|
);
|
|
92
179
|
}
|
|
93
|
-
return /* @__PURE__ */
|
|
94
|
-
|
|
180
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("noscript", { children: [
|
|
181
|
+
block._type,
|
|
95
182
|
" not found"
|
|
96
183
|
] });
|
|
97
184
|
})
|
|
98
185
|
) });
|
|
99
186
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
187
|
+
async function getTailwindCSS(theme, markupString, safelist = [], prefix = "", includeBaseStyles = false) {
|
|
188
|
+
const tailwind = createTailwindcss({
|
|
189
|
+
tailwindConfig: {
|
|
190
|
+
darkMode: "class",
|
|
191
|
+
safelist,
|
|
192
|
+
theme: { extend: getChaiBuilderTheme(theme) },
|
|
193
|
+
plugins: [forms, typography, aspectRatio, chaiBuilderPlugin],
|
|
194
|
+
corePlugins: { preflight: includeBaseStyles },
|
|
195
|
+
...prefix ? { prefix: `${prefix}` } : {}
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
return await tailwind.generateStylesFromContent(
|
|
199
|
+
` ${includeBaseStyles ? "@tailwind base;" : ""}
|
|
200
|
+
@tailwind components;
|
|
201
|
+
@tailwind utilities;`,
|
|
202
|
+
markupString
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
const getBlocksTailwindCSS = (blocks, theme, includeBaseStyles = false) => {
|
|
206
|
+
return getTailwindCSS(theme, [replace(JSON.stringify(blocks), /#styles:,?/g, "")], [], "", includeBaseStyles);
|
|
207
|
+
};
|
|
208
|
+
const getStylesForBlocks = async (blocks, theme = {}, includeBaseStyles = true) => {
|
|
209
|
+
return await getBlocksTailwindCSS(blocks, theme, includeBaseStyles);
|
|
119
210
|
};
|
|
120
211
|
export {
|
|
121
|
-
|
|
122
|
-
|
|
212
|
+
RenderChaiBlocks,
|
|
213
|
+
convertToBlocks,
|
|
214
|
+
getStylesForBlocks
|
|
123
215
|
};
|
package/dist/runtime.cjs
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const runtime = require("@chaibuilder/runtime");
|
|
4
|
+
const controls = require("./controls-4t-C_rP2.cjs");
|
|
5
|
+
require("lodash-es");
|
|
6
|
+
exports.Checkbox = controls.c;
|
|
7
|
+
exports.Code = controls.l;
|
|
8
|
+
exports.Color = controls.h;
|
|
9
|
+
exports.Icon = controls.q;
|
|
10
|
+
exports.Image = controls.x;
|
|
11
|
+
exports.InfoField = controls.u;
|
|
12
|
+
exports.Link = controls.w;
|
|
13
|
+
exports.List = controls.S;
|
|
14
|
+
exports.Model = controls.b;
|
|
15
|
+
exports.MultilineText = controls.f;
|
|
16
|
+
exports.Numeric = controls.s;
|
|
17
|
+
exports.RichText = controls.m;
|
|
18
|
+
exports.SelectOption = controls.y;
|
|
19
|
+
exports.SingleLineText = controls.g;
|
|
20
|
+
exports.Slot = controls.r;
|
|
21
|
+
exports.Styles = controls.T;
|
|
22
|
+
Object.keys(runtime).forEach((k) => {
|
|
23
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k))
|
|
24
|
+
Object.defineProperty(exports, k, {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: () => runtime[k]
|
|
27
|
+
});
|
|
28
|
+
});
|
package/dist/runtime.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export * from "@chaibuilder/runtime";
|
|
2
|
+
import { c, l, h, q, x, u, w, S, b, f, s, m, y, g, r, T } from "./controls-fQIu127i.js";
|
|
3
|
+
import "lodash-es";
|
|
4
|
+
export {
|
|
5
|
+
c as Checkbox,
|
|
6
|
+
l as Code,
|
|
7
|
+
h as Color,
|
|
8
|
+
q as Icon,
|
|
9
|
+
x as Image,
|
|
10
|
+
u as InfoField,
|
|
11
|
+
w as Link,
|
|
12
|
+
S as List,
|
|
13
|
+
b as Model,
|
|
14
|
+
f as MultilineText,
|
|
15
|
+
s as Numeric,
|
|
16
|
+
m as RichText,
|
|
17
|
+
y as SelectOption,
|
|
18
|
+
g as SingleLineText,
|
|
19
|
+
r as Slot,
|
|
20
|
+
T as Styles
|
|
21
|
+
};
|