@chaibuilder/sdk 2.0.0-beta.80 → 2.0.0-beta.82
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/ChaiThemeFn-DcE5RdLQ.cjs +236 -0
- package/dist/ChaiThemeFn-DzirXKjI.js +237 -0
- package/dist/CodeEditor-C8_JzwHn.cjs +81 -0
- package/dist/CodeEditor-DdIk_PEV.js +81 -0
- package/dist/Topbar-62QmCKWL.cjs +18 -0
- package/dist/Topbar-Cqt0j3Yt.js +18 -0
- package/dist/context-menu-DHla8ofZ.js +893 -0
- package/dist/context-menu-DawHUIXd.cjs +923 -0
- package/dist/core.cjs +11709 -5
- package/dist/core.js +6845 -3957
- package/dist/getSplitClasses-BuALfSLX.js +54 -0
- package/dist/getSplitClasses-mbQmvwI3.cjs +53 -0
- package/dist/iconBase-BSrIcOaG.cjs +146 -0
- package/dist/iconBase-CWgVxu0A.js +147 -0
- package/dist/plugin-BcTnEZwx.cjs +26 -0
- package/dist/plugin-DGEKY3uC.js +27 -0
- package/dist/render.cjs +247 -2
- package/dist/render.js +205 -150
- package/dist/runtime.cjs +9 -1
- package/dist/sdk.css +1336 -1
- package/dist/tailwind.cjs +78 -1
- package/dist/tailwind.js +21 -19
- package/dist/ui.cjs +378 -1
- package/dist/ui.js +254 -244
- package/dist/web-blocks.cjs +1679 -2
- package/dist/web-blocks.js +747 -518
- package/package.json +1 -1
- package/dist/ChaiThemeFn-Cort9tch.js +0 -201
- package/dist/ChaiThemeFn-DQu-2Eh9.cjs +0 -13
- package/dist/CodeEditor-B2x4yruH.cjs +0 -1
- package/dist/CodeEditor-VcQsGvTM.js +0 -65
- package/dist/Topbar-BQsjWb-A.js +0 -16
- package/dist/Topbar-DEw_kBMz.cjs +0 -1
- package/dist/context-menu-C4lLV8gP.cjs +0 -1
- package/dist/context-menu-D5ViOi6K.js +0 -831
- package/dist/getSplitClasses-DodqA_KW.cjs +0 -1
- package/dist/getSplitClasses-DphwgQiE.js +0 -48
- package/dist/iconBase-Cn2BsTrq.cjs +0 -1
- package/dist/iconBase-DHfFLkem.js +0 -124
- package/dist/plugin-2xcljWGM.cjs +0 -1
- package/dist/plugin-kUMxtQR5.js +0 -24
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const lodashEs = require("lodash-es");
|
|
3
|
+
function getDefaultExportFromCjs(x) {
|
|
4
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
5
|
+
}
|
|
6
|
+
const defaultThemeOptions = {
|
|
7
|
+
fontFamily: {
|
|
8
|
+
"font-heading": "Inter",
|
|
9
|
+
"font-body": "Inter"
|
|
10
|
+
},
|
|
11
|
+
borderRadius: "10px",
|
|
12
|
+
colors: [
|
|
13
|
+
{
|
|
14
|
+
group: "Body",
|
|
15
|
+
items: {
|
|
16
|
+
background: ["#FFFFFF", "#121212"],
|
|
17
|
+
foreground: ["#121212", "#FFFFFF"]
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
group: "Primary",
|
|
22
|
+
items: {
|
|
23
|
+
primary: ["#2563EB", "#3B82F6"],
|
|
24
|
+
"primary-foreground": ["#FFFFFF", "#FFFFFF"]
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
group: "Secondary",
|
|
29
|
+
items: {
|
|
30
|
+
secondary: ["#F3F4F6", "#374151"],
|
|
31
|
+
"secondary-foreground": ["#1F2937", "#F9FAFB"]
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
group: "Border, Input & Ring",
|
|
36
|
+
items: {
|
|
37
|
+
border: ["#E5E7EB", "#374151"],
|
|
38
|
+
input: ["#E5E7EB", "#374151"],
|
|
39
|
+
ring: ["#2563EB", "#3B82F6"]
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
group: "Card",
|
|
44
|
+
items: {
|
|
45
|
+
card: ["#FFFFFF", "#1F2937"],
|
|
46
|
+
"card-foreground": ["#121212", "#FFFFFF"]
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
group: "Popover",
|
|
51
|
+
items: {
|
|
52
|
+
popover: ["#FFFFFF", "#1F2937"],
|
|
53
|
+
"popover-foreground": ["#121212", "#FFFFFF"]
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
group: "Muted",
|
|
58
|
+
items: {
|
|
59
|
+
muted: ["#F3F4F6", "#374151"],
|
|
60
|
+
"muted-foreground": ["#6B7280", "#9CA3AF"]
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
group: "Accent",
|
|
65
|
+
items: {
|
|
66
|
+
accent: ["#F3F4F6", "#374151"],
|
|
67
|
+
"accent-foreground": ["#1F2937", "#FFFFFF"]
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
group: "Destructive",
|
|
72
|
+
items: {
|
|
73
|
+
destructive: ["#DC2626", "#EF4444"],
|
|
74
|
+
"destructive-foreground": ["#FFFFFF", "#FFFFFF"]
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
]
|
|
78
|
+
};
|
|
79
|
+
var createPlugin$1 = {};
|
|
80
|
+
var createPlugin = {};
|
|
81
|
+
var hasRequiredCreatePlugin$1;
|
|
82
|
+
function requireCreatePlugin$1() {
|
|
83
|
+
if (hasRequiredCreatePlugin$1) return createPlugin;
|
|
84
|
+
hasRequiredCreatePlugin$1 = 1;
|
|
85
|
+
(function(exports2) {
|
|
86
|
+
Object.defineProperty(exports2, "__esModule", {
|
|
87
|
+
value: true
|
|
88
|
+
});
|
|
89
|
+
Object.defineProperty(exports2, "default", {
|
|
90
|
+
enumerable: true,
|
|
91
|
+
get: function() {
|
|
92
|
+
return _default;
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
function createPlugin2(plugin2, config) {
|
|
96
|
+
return {
|
|
97
|
+
handler: plugin2,
|
|
98
|
+
config
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
createPlugin2.withOptions = function(pluginFunction, configFunction = () => ({})) {
|
|
102
|
+
const optionsFunction = function(options) {
|
|
103
|
+
return {
|
|
104
|
+
__options: options,
|
|
105
|
+
handler: pluginFunction(options),
|
|
106
|
+
config: configFunction(options)
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
optionsFunction.__isOptionsFunction = true;
|
|
110
|
+
optionsFunction.__pluginFunction = pluginFunction;
|
|
111
|
+
optionsFunction.__configFunction = configFunction;
|
|
112
|
+
return optionsFunction;
|
|
113
|
+
};
|
|
114
|
+
const _default = createPlugin2;
|
|
115
|
+
})(createPlugin);
|
|
116
|
+
return createPlugin;
|
|
117
|
+
}
|
|
118
|
+
var hasRequiredCreatePlugin;
|
|
119
|
+
function requireCreatePlugin() {
|
|
120
|
+
if (hasRequiredCreatePlugin) return createPlugin$1;
|
|
121
|
+
hasRequiredCreatePlugin = 1;
|
|
122
|
+
(function(exports2) {
|
|
123
|
+
Object.defineProperty(exports2, "__esModule", {
|
|
124
|
+
value: true
|
|
125
|
+
});
|
|
126
|
+
Object.defineProperty(exports2, "default", {
|
|
127
|
+
enumerable: true,
|
|
128
|
+
get: function() {
|
|
129
|
+
return _default;
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
const _createPlugin = /* @__PURE__ */ _interop_require_default(requireCreatePlugin$1());
|
|
133
|
+
function _interop_require_default(obj) {
|
|
134
|
+
return obj && obj.__esModule ? obj : {
|
|
135
|
+
default: obj
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
const _default = _createPlugin.default;
|
|
139
|
+
})(createPlugin$1);
|
|
140
|
+
return createPlugin$1;
|
|
141
|
+
}
|
|
142
|
+
var plugin$1;
|
|
143
|
+
var hasRequiredPlugin;
|
|
144
|
+
function requirePlugin() {
|
|
145
|
+
if (hasRequiredPlugin) return plugin$1;
|
|
146
|
+
hasRequiredPlugin = 1;
|
|
147
|
+
let createPlugin2 = requireCreatePlugin();
|
|
148
|
+
plugin$1 = (createPlugin2.__esModule ? createPlugin2 : { default: createPlugin2 }).default;
|
|
149
|
+
return plugin$1;
|
|
150
|
+
}
|
|
151
|
+
var pluginExports = requirePlugin();
|
|
152
|
+
const plugin = /* @__PURE__ */ getDefaultExportFromCjs(pluginExports);
|
|
153
|
+
const getChaiThemeOptions = (chaiThemeOptions) => {
|
|
154
|
+
const theme = {
|
|
155
|
+
fontFamily: chaiThemeOptions.fontFamily ? lodashEs.keys(chaiThemeOptions.fontFamily).reduce(
|
|
156
|
+
(acc, key) => ({
|
|
157
|
+
...acc,
|
|
158
|
+
[key.replace("font-", "")]: `var(--${key})`
|
|
159
|
+
}),
|
|
160
|
+
{}
|
|
161
|
+
) : {},
|
|
162
|
+
borderRadius: chaiThemeOptions.borderRadius ? {
|
|
163
|
+
lg: `var(--radius)`,
|
|
164
|
+
md: `calc(var(--radius) - 2px)`,
|
|
165
|
+
sm: `calc(var(--radius) - 4px)`
|
|
166
|
+
} : {},
|
|
167
|
+
colors: chaiThemeOptions.colors ? lodashEs.flatten(chaiThemeOptions.colors.map((color) => Object.entries(color.items))).reduce(
|
|
168
|
+
(acc, [key]) => ({ ...acc, [key]: `hsl(var(--${key}))` }),
|
|
169
|
+
{}
|
|
170
|
+
) : {}
|
|
171
|
+
};
|
|
172
|
+
return theme;
|
|
173
|
+
};
|
|
174
|
+
function hexToHSL(hex) {
|
|
175
|
+
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
|
|
176
|
+
let r = parseInt(result[1], 16);
|
|
177
|
+
let g = parseInt(result[2], 16);
|
|
178
|
+
let b = parseInt(result[3], 16);
|
|
179
|
+
r /= 255, g /= 255, b /= 255;
|
|
180
|
+
const max = Math.max(r, g, b), min = Math.min(r, g, b);
|
|
181
|
+
let h;
|
|
182
|
+
let s;
|
|
183
|
+
const l = (max + min) / 2;
|
|
184
|
+
if (max == min) {
|
|
185
|
+
h = s = 0;
|
|
186
|
+
} else {
|
|
187
|
+
const d = max - min;
|
|
188
|
+
s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
|
|
189
|
+
switch (max) {
|
|
190
|
+
case r:
|
|
191
|
+
h = (g - b) / d + (g < b ? 6 : 0);
|
|
192
|
+
break;
|
|
193
|
+
case g:
|
|
194
|
+
h = (b - r) / d + 2;
|
|
195
|
+
break;
|
|
196
|
+
case b:
|
|
197
|
+
h = (r - g) / d + 4;
|
|
198
|
+
break;
|
|
199
|
+
}
|
|
200
|
+
h /= 6;
|
|
201
|
+
}
|
|
202
|
+
return `${Math.round(h * 360)} ${Math.round(s * 100)}% ${Math.round(l * 100)}%`;
|
|
203
|
+
}
|
|
204
|
+
const getChaiThemeCssVariables = (chaiTheme) => {
|
|
205
|
+
return `:root {
|
|
206
|
+
${chaiTheme.fontFamily && Object.entries(chaiTheme.fontFamily).map(([key, value]) => `--font-${key}: "${value}";`).join("\n ")}
|
|
207
|
+
${chaiTheme.borderRadius && `--radius: ${chaiTheme.borderRadius};`}
|
|
208
|
+
${chaiTheme.colors && Object.entries(chaiTheme.colors).map(([key, value]) => `--${key}: ${hexToHSL(value[0])};`).join("\n ")}
|
|
209
|
+
}
|
|
210
|
+
.dark {
|
|
211
|
+
${chaiTheme.colors && Object.entries(chaiTheme.colors).map(([key, value]) => `--${key}: ${hexToHSL(value[1])};`).join("\n ")}
|
|
212
|
+
}`;
|
|
213
|
+
};
|
|
214
|
+
const getThemeFontsLinkMarkup = (chaiTheme) => {
|
|
215
|
+
if (lodashEs.isEmpty(chaiTheme.fontFamily)) return "";
|
|
216
|
+
const links = lodashEs.uniq(Object.entries(chaiTheme.fontFamily).map(([, value]) => value));
|
|
217
|
+
return links.map((link) => {
|
|
218
|
+
const googleFontUrl = `https://fonts.googleapis.com/css2?family=${link.replace(/\s+/g, "+")}&display=swap`;
|
|
219
|
+
return `<link rel="stylesheet" href="${googleFontUrl}">`;
|
|
220
|
+
}).join("\n");
|
|
221
|
+
};
|
|
222
|
+
const getThemeFontsCSSImport = (chaiTheme) => {
|
|
223
|
+
if (lodashEs.isEmpty(chaiTheme.fontFamily)) return "";
|
|
224
|
+
const links = lodashEs.uniq(Object.entries(chaiTheme.fontFamily).map(([, value]) => value));
|
|
225
|
+
return links.map((link) => {
|
|
226
|
+
const googleFontUrl = `https://fonts.googleapis.com/css2?family=${link.replace(/\s+/g, "+")}&display=swap`;
|
|
227
|
+
return `@import url("${googleFontUrl}");`;
|
|
228
|
+
}).join("\n");
|
|
229
|
+
};
|
|
230
|
+
exports.defaultThemeOptions = defaultThemeOptions;
|
|
231
|
+
exports.getChaiThemeCssVariables = getChaiThemeCssVariables;
|
|
232
|
+
exports.getChaiThemeOptions = getChaiThemeOptions;
|
|
233
|
+
exports.getDefaultExportFromCjs = getDefaultExportFromCjs;
|
|
234
|
+
exports.getThemeFontsCSSImport = getThemeFontsCSSImport;
|
|
235
|
+
exports.getThemeFontsLinkMarkup = getThemeFontsLinkMarkup;
|
|
236
|
+
exports.plugin = plugin;
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import { isEmpty, uniq, keys, flatten } from "lodash-es";
|
|
2
|
+
function getDefaultExportFromCjs(x) {
|
|
3
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
4
|
+
}
|
|
5
|
+
const defaultThemeOptions = {
|
|
6
|
+
fontFamily: {
|
|
7
|
+
"font-heading": "Inter",
|
|
8
|
+
"font-body": "Inter"
|
|
9
|
+
},
|
|
10
|
+
borderRadius: "10px",
|
|
11
|
+
colors: [
|
|
12
|
+
{
|
|
13
|
+
group: "Body",
|
|
14
|
+
items: {
|
|
15
|
+
background: ["#FFFFFF", "#121212"],
|
|
16
|
+
foreground: ["#121212", "#FFFFFF"]
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
group: "Primary",
|
|
21
|
+
items: {
|
|
22
|
+
primary: ["#2563EB", "#3B82F6"],
|
|
23
|
+
"primary-foreground": ["#FFFFFF", "#FFFFFF"]
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
group: "Secondary",
|
|
28
|
+
items: {
|
|
29
|
+
secondary: ["#F3F4F6", "#374151"],
|
|
30
|
+
"secondary-foreground": ["#1F2937", "#F9FAFB"]
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
group: "Border, Input & Ring",
|
|
35
|
+
items: {
|
|
36
|
+
border: ["#E5E7EB", "#374151"],
|
|
37
|
+
input: ["#E5E7EB", "#374151"],
|
|
38
|
+
ring: ["#2563EB", "#3B82F6"]
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
group: "Card",
|
|
43
|
+
items: {
|
|
44
|
+
card: ["#FFFFFF", "#1F2937"],
|
|
45
|
+
"card-foreground": ["#121212", "#FFFFFF"]
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
group: "Popover",
|
|
50
|
+
items: {
|
|
51
|
+
popover: ["#FFFFFF", "#1F2937"],
|
|
52
|
+
"popover-foreground": ["#121212", "#FFFFFF"]
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
group: "Muted",
|
|
57
|
+
items: {
|
|
58
|
+
muted: ["#F3F4F6", "#374151"],
|
|
59
|
+
"muted-foreground": ["#6B7280", "#9CA3AF"]
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
group: "Accent",
|
|
64
|
+
items: {
|
|
65
|
+
accent: ["#F3F4F6", "#374151"],
|
|
66
|
+
"accent-foreground": ["#1F2937", "#FFFFFF"]
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
group: "Destructive",
|
|
71
|
+
items: {
|
|
72
|
+
destructive: ["#DC2626", "#EF4444"],
|
|
73
|
+
"destructive-foreground": ["#FFFFFF", "#FFFFFF"]
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
]
|
|
77
|
+
};
|
|
78
|
+
var createPlugin$1 = {};
|
|
79
|
+
var createPlugin = {};
|
|
80
|
+
var hasRequiredCreatePlugin$1;
|
|
81
|
+
function requireCreatePlugin$1() {
|
|
82
|
+
if (hasRequiredCreatePlugin$1) return createPlugin;
|
|
83
|
+
hasRequiredCreatePlugin$1 = 1;
|
|
84
|
+
(function(exports) {
|
|
85
|
+
Object.defineProperty(exports, "__esModule", {
|
|
86
|
+
value: true
|
|
87
|
+
});
|
|
88
|
+
Object.defineProperty(exports, "default", {
|
|
89
|
+
enumerable: true,
|
|
90
|
+
get: function() {
|
|
91
|
+
return _default;
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
function createPlugin2(plugin2, config) {
|
|
95
|
+
return {
|
|
96
|
+
handler: plugin2,
|
|
97
|
+
config
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
createPlugin2.withOptions = function(pluginFunction, configFunction = () => ({})) {
|
|
101
|
+
const optionsFunction = function(options) {
|
|
102
|
+
return {
|
|
103
|
+
__options: options,
|
|
104
|
+
handler: pluginFunction(options),
|
|
105
|
+
config: configFunction(options)
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
optionsFunction.__isOptionsFunction = true;
|
|
109
|
+
optionsFunction.__pluginFunction = pluginFunction;
|
|
110
|
+
optionsFunction.__configFunction = configFunction;
|
|
111
|
+
return optionsFunction;
|
|
112
|
+
};
|
|
113
|
+
const _default = createPlugin2;
|
|
114
|
+
})(createPlugin);
|
|
115
|
+
return createPlugin;
|
|
116
|
+
}
|
|
117
|
+
var hasRequiredCreatePlugin;
|
|
118
|
+
function requireCreatePlugin() {
|
|
119
|
+
if (hasRequiredCreatePlugin) return createPlugin$1;
|
|
120
|
+
hasRequiredCreatePlugin = 1;
|
|
121
|
+
(function(exports) {
|
|
122
|
+
Object.defineProperty(exports, "__esModule", {
|
|
123
|
+
value: true
|
|
124
|
+
});
|
|
125
|
+
Object.defineProperty(exports, "default", {
|
|
126
|
+
enumerable: true,
|
|
127
|
+
get: function() {
|
|
128
|
+
return _default;
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
const _createPlugin = /* @__PURE__ */ _interop_require_default(requireCreatePlugin$1());
|
|
132
|
+
function _interop_require_default(obj) {
|
|
133
|
+
return obj && obj.__esModule ? obj : {
|
|
134
|
+
default: obj
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
const _default = _createPlugin.default;
|
|
138
|
+
})(createPlugin$1);
|
|
139
|
+
return createPlugin$1;
|
|
140
|
+
}
|
|
141
|
+
var plugin$1;
|
|
142
|
+
var hasRequiredPlugin;
|
|
143
|
+
function requirePlugin() {
|
|
144
|
+
if (hasRequiredPlugin) return plugin$1;
|
|
145
|
+
hasRequiredPlugin = 1;
|
|
146
|
+
let createPlugin2 = requireCreatePlugin();
|
|
147
|
+
plugin$1 = (createPlugin2.__esModule ? createPlugin2 : { default: createPlugin2 }).default;
|
|
148
|
+
return plugin$1;
|
|
149
|
+
}
|
|
150
|
+
var pluginExports = requirePlugin();
|
|
151
|
+
const plugin = /* @__PURE__ */ getDefaultExportFromCjs(pluginExports);
|
|
152
|
+
const getChaiThemeOptions = (chaiThemeOptions) => {
|
|
153
|
+
const theme = {
|
|
154
|
+
fontFamily: chaiThemeOptions.fontFamily ? keys(chaiThemeOptions.fontFamily).reduce(
|
|
155
|
+
(acc, key) => ({
|
|
156
|
+
...acc,
|
|
157
|
+
[key.replace("font-", "")]: `var(--${key})`
|
|
158
|
+
}),
|
|
159
|
+
{}
|
|
160
|
+
) : {},
|
|
161
|
+
borderRadius: chaiThemeOptions.borderRadius ? {
|
|
162
|
+
lg: `var(--radius)`,
|
|
163
|
+
md: `calc(var(--radius) - 2px)`,
|
|
164
|
+
sm: `calc(var(--radius) - 4px)`
|
|
165
|
+
} : {},
|
|
166
|
+
colors: chaiThemeOptions.colors ? flatten(chaiThemeOptions.colors.map((color) => Object.entries(color.items))).reduce(
|
|
167
|
+
(acc, [key]) => ({ ...acc, [key]: `hsl(var(--${key}))` }),
|
|
168
|
+
{}
|
|
169
|
+
) : {}
|
|
170
|
+
};
|
|
171
|
+
return theme;
|
|
172
|
+
};
|
|
173
|
+
function hexToHSL(hex) {
|
|
174
|
+
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
|
|
175
|
+
let r = parseInt(result[1], 16);
|
|
176
|
+
let g = parseInt(result[2], 16);
|
|
177
|
+
let b = parseInt(result[3], 16);
|
|
178
|
+
r /= 255, g /= 255, b /= 255;
|
|
179
|
+
const max = Math.max(r, g, b), min = Math.min(r, g, b);
|
|
180
|
+
let h;
|
|
181
|
+
let s;
|
|
182
|
+
const l = (max + min) / 2;
|
|
183
|
+
if (max == min) {
|
|
184
|
+
h = s = 0;
|
|
185
|
+
} else {
|
|
186
|
+
const d = max - min;
|
|
187
|
+
s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
|
|
188
|
+
switch (max) {
|
|
189
|
+
case r:
|
|
190
|
+
h = (g - b) / d + (g < b ? 6 : 0);
|
|
191
|
+
break;
|
|
192
|
+
case g:
|
|
193
|
+
h = (b - r) / d + 2;
|
|
194
|
+
break;
|
|
195
|
+
case b:
|
|
196
|
+
h = (r - g) / d + 4;
|
|
197
|
+
break;
|
|
198
|
+
}
|
|
199
|
+
h /= 6;
|
|
200
|
+
}
|
|
201
|
+
return `${Math.round(h * 360)} ${Math.round(s * 100)}% ${Math.round(l * 100)}%`;
|
|
202
|
+
}
|
|
203
|
+
const getChaiThemeCssVariables = (chaiTheme) => {
|
|
204
|
+
return `:root {
|
|
205
|
+
${chaiTheme.fontFamily && Object.entries(chaiTheme.fontFamily).map(([key, value]) => `--font-${key}: "${value}";`).join("\n ")}
|
|
206
|
+
${chaiTheme.borderRadius && `--radius: ${chaiTheme.borderRadius};`}
|
|
207
|
+
${chaiTheme.colors && Object.entries(chaiTheme.colors).map(([key, value]) => `--${key}: ${hexToHSL(value[0])};`).join("\n ")}
|
|
208
|
+
}
|
|
209
|
+
.dark {
|
|
210
|
+
${chaiTheme.colors && Object.entries(chaiTheme.colors).map(([key, value]) => `--${key}: ${hexToHSL(value[1])};`).join("\n ")}
|
|
211
|
+
}`;
|
|
212
|
+
};
|
|
213
|
+
const getThemeFontsLinkMarkup = (chaiTheme) => {
|
|
214
|
+
if (isEmpty(chaiTheme.fontFamily)) return "";
|
|
215
|
+
const links = uniq(Object.entries(chaiTheme.fontFamily).map(([, value]) => value));
|
|
216
|
+
return links.map((link) => {
|
|
217
|
+
const googleFontUrl = `https://fonts.googleapis.com/css2?family=${link.replace(/\s+/g, "+")}&display=swap`;
|
|
218
|
+
return `<link rel="stylesheet" href="${googleFontUrl}">`;
|
|
219
|
+
}).join("\n");
|
|
220
|
+
};
|
|
221
|
+
const getThemeFontsCSSImport = (chaiTheme) => {
|
|
222
|
+
if (isEmpty(chaiTheme.fontFamily)) return "";
|
|
223
|
+
const links = uniq(Object.entries(chaiTheme.fontFamily).map(([, value]) => value));
|
|
224
|
+
return links.map((link) => {
|
|
225
|
+
const googleFontUrl = `https://fonts.googleapis.com/css2?family=${link.replace(/\s+/g, "+")}&display=swap`;
|
|
226
|
+
return `@import url("${googleFontUrl}");`;
|
|
227
|
+
}).join("\n");
|
|
228
|
+
};
|
|
229
|
+
export {
|
|
230
|
+
getChaiThemeCssVariables as a,
|
|
231
|
+
getThemeFontsCSSImport as b,
|
|
232
|
+
getThemeFontsLinkMarkup as c,
|
|
233
|
+
defaultThemeOptions as d,
|
|
234
|
+
getDefaultExportFromCjs as e,
|
|
235
|
+
getChaiThemeOptions as g,
|
|
236
|
+
plugin as p
|
|
237
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
+
const reactIcons = require("@radix-ui/react-icons");
|
|
5
|
+
const web = require("@react-hookz/web");
|
|
6
|
+
const React = require("react");
|
|
7
|
+
const reactI18next = require("react-i18next");
|
|
8
|
+
const contextMenu = require("./context-menu-DawHUIXd.cjs");
|
|
9
|
+
const core = require("./core.cjs");
|
|
10
|
+
const sanitizeHTML = (html) => {
|
|
11
|
+
const doc = document.createElement("div");
|
|
12
|
+
doc.innerHTML = html;
|
|
13
|
+
return doc.innerHTML;
|
|
14
|
+
};
|
|
15
|
+
function CodeEditor() {
|
|
16
|
+
const { t } = reactI18next.useTranslation();
|
|
17
|
+
const [dirty, setDirty] = React.useState(false);
|
|
18
|
+
const [code, setCode] = React.useState("");
|
|
19
|
+
const [codeEditor, setCodeEditor] = core.useCodeEditor();
|
|
20
|
+
const [ids] = core.useSelectedBlockIds();
|
|
21
|
+
const updateBlockProps = core.useUpdateBlocksProps();
|
|
22
|
+
const updateRealTime = core.useUpdateBlocksPropsRealtime();
|
|
23
|
+
const saveCodeContentRealTime = web.useThrottledCallback(
|
|
24
|
+
(value) => {
|
|
25
|
+
const html = sanitizeHTML(value);
|
|
26
|
+
updateRealTime([codeEditor.blockId], { [codeEditor.blockProp]: html });
|
|
27
|
+
},
|
|
28
|
+
[],
|
|
29
|
+
300
|
|
30
|
+
);
|
|
31
|
+
const saveCodeContent = React.useCallback(() => {
|
|
32
|
+
if (dirty) {
|
|
33
|
+
const html = sanitizeHTML(code);
|
|
34
|
+
updateBlockProps([codeEditor.blockId], { [codeEditor.blockProp]: html });
|
|
35
|
+
}
|
|
36
|
+
}, [dirty, code]);
|
|
37
|
+
React.useEffect(() => {
|
|
38
|
+
if (!ids.includes(codeEditor == null ? void 0 : codeEditor.blockId)) {
|
|
39
|
+
saveCodeContent();
|
|
40
|
+
setCodeEditor(null);
|
|
41
|
+
}
|
|
42
|
+
}, [ids]);
|
|
43
|
+
const handleClickOutside = () => {
|
|
44
|
+
setCodeEditor(null);
|
|
45
|
+
};
|
|
46
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "h-full text-white bg-black border-t-4 border-black rounded-t-lg", children: [
|
|
47
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { onClick: handleClickOutside, className: "fixed inset-0 z-[100000] cursor-default bg-gray-400/20" }),
|
|
48
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative z-[100001] h-full w-full flex-col gap-y-1", children: [
|
|
49
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between px-2 py-2 -mt-1", children: [
|
|
50
|
+
/* @__PURE__ */ jsxRuntime.jsxs("h3", { className: "space-x-3 text-sm font-semibold", children: [
|
|
51
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: t("HTML Code Editor |") }),
|
|
52
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs text-gray-400", children: t("Scripts will be only executed in preview and live mode.") })
|
|
53
|
+
] }),
|
|
54
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex gap-x-2", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
55
|
+
contextMenu.Button,
|
|
56
|
+
{
|
|
57
|
+
onClick: () => setCodeEditor(null),
|
|
58
|
+
size: "sm",
|
|
59
|
+
variant: "destructive",
|
|
60
|
+
className: "h-6 w-fit",
|
|
61
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(reactIcons.Cross2Icon, {})
|
|
62
|
+
}
|
|
63
|
+
) })
|
|
64
|
+
] }),
|
|
65
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
66
|
+
"textarea",
|
|
67
|
+
{
|
|
68
|
+
className: "w-full h-full p-2 font-mono text-xs bg-black text-white/90",
|
|
69
|
+
value: code || codeEditor.initialCode,
|
|
70
|
+
onChange: (e) => {
|
|
71
|
+
const value = e.target.value;
|
|
72
|
+
setDirty(true);
|
|
73
|
+
setCode(value);
|
|
74
|
+
saveCodeContentRealTime(value);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
)
|
|
78
|
+
] })
|
|
79
|
+
] });
|
|
80
|
+
}
|
|
81
|
+
exports.default = CodeEditor;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Cross2Icon } from "@radix-ui/react-icons";
|
|
3
|
+
import { useThrottledCallback } from "@react-hookz/web";
|
|
4
|
+
import { useState, useCallback, useEffect } from "react";
|
|
5
|
+
import { useTranslation } from "react-i18next";
|
|
6
|
+
import { B as Button } from "./context-menu-DHla8ofZ.js";
|
|
7
|
+
import { useCodeEditor, useSelectedBlockIds, useUpdateBlocksProps, useUpdateBlocksPropsRealtime } from "./core.js";
|
|
8
|
+
const sanitizeHTML = (html) => {
|
|
9
|
+
const doc = document.createElement("div");
|
|
10
|
+
doc.innerHTML = html;
|
|
11
|
+
return doc.innerHTML;
|
|
12
|
+
};
|
|
13
|
+
function CodeEditor() {
|
|
14
|
+
const { t } = useTranslation();
|
|
15
|
+
const [dirty, setDirty] = useState(false);
|
|
16
|
+
const [code, setCode] = useState("");
|
|
17
|
+
const [codeEditor, setCodeEditor] = useCodeEditor();
|
|
18
|
+
const [ids] = useSelectedBlockIds();
|
|
19
|
+
const updateBlockProps = useUpdateBlocksProps();
|
|
20
|
+
const updateRealTime = useUpdateBlocksPropsRealtime();
|
|
21
|
+
const saveCodeContentRealTime = useThrottledCallback(
|
|
22
|
+
(value) => {
|
|
23
|
+
const html = sanitizeHTML(value);
|
|
24
|
+
updateRealTime([codeEditor.blockId], { [codeEditor.blockProp]: html });
|
|
25
|
+
},
|
|
26
|
+
[],
|
|
27
|
+
300
|
|
28
|
+
);
|
|
29
|
+
const saveCodeContent = useCallback(() => {
|
|
30
|
+
if (dirty) {
|
|
31
|
+
const html = sanitizeHTML(code);
|
|
32
|
+
updateBlockProps([codeEditor.blockId], { [codeEditor.blockProp]: html });
|
|
33
|
+
}
|
|
34
|
+
}, [dirty, code]);
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
if (!ids.includes(codeEditor == null ? void 0 : codeEditor.blockId)) {
|
|
37
|
+
saveCodeContent();
|
|
38
|
+
setCodeEditor(null);
|
|
39
|
+
}
|
|
40
|
+
}, [ids]);
|
|
41
|
+
const handleClickOutside = () => {
|
|
42
|
+
setCodeEditor(null);
|
|
43
|
+
};
|
|
44
|
+
return /* @__PURE__ */ jsxs("div", { className: "h-full text-white bg-black border-t-4 border-black rounded-t-lg", children: [
|
|
45
|
+
/* @__PURE__ */ jsx("button", { onClick: handleClickOutside, className: "fixed inset-0 z-[100000] cursor-default bg-gray-400/20" }),
|
|
46
|
+
/* @__PURE__ */ jsxs("div", { className: "relative z-[100001] h-full w-full flex-col gap-y-1", children: [
|
|
47
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between px-2 py-2 -mt-1", children: [
|
|
48
|
+
/* @__PURE__ */ jsxs("h3", { className: "space-x-3 text-sm font-semibold", children: [
|
|
49
|
+
/* @__PURE__ */ jsx("span", { children: t("HTML Code Editor |") }),
|
|
50
|
+
/* @__PURE__ */ jsx("span", { className: "text-xs text-gray-400", children: t("Scripts will be only executed in preview and live mode.") })
|
|
51
|
+
] }),
|
|
52
|
+
/* @__PURE__ */ jsx("div", { className: "flex gap-x-2", children: /* @__PURE__ */ jsx(
|
|
53
|
+
Button,
|
|
54
|
+
{
|
|
55
|
+
onClick: () => setCodeEditor(null),
|
|
56
|
+
size: "sm",
|
|
57
|
+
variant: "destructive",
|
|
58
|
+
className: "h-6 w-fit",
|
|
59
|
+
children: /* @__PURE__ */ jsx(Cross2Icon, {})
|
|
60
|
+
}
|
|
61
|
+
) })
|
|
62
|
+
] }),
|
|
63
|
+
/* @__PURE__ */ jsx(
|
|
64
|
+
"textarea",
|
|
65
|
+
{
|
|
66
|
+
className: "w-full h-full p-2 font-mono text-xs bg-black text-white/90",
|
|
67
|
+
value: code || codeEditor.initialCode,
|
|
68
|
+
onChange: (e) => {
|
|
69
|
+
const value = e.target.value;
|
|
70
|
+
setDirty(true);
|
|
71
|
+
setCode(value);
|
|
72
|
+
saveCodeContentRealTime(value);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
)
|
|
76
|
+
] })
|
|
77
|
+
] });
|
|
78
|
+
}
|
|
79
|
+
export {
|
|
80
|
+
CodeEditor as default
|
|
81
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
+
const React = require("react");
|
|
5
|
+
const contextMenu = require("./context-menu-DawHUIXd.cjs");
|
|
6
|
+
require("react-i18next");
|
|
7
|
+
const core = require("./core.cjs");
|
|
8
|
+
const Topbar = () => {
|
|
9
|
+
const leftComponents = core.useBuilderProp("topBarComponents.left", []);
|
|
10
|
+
const centerComponents = core.useBuilderProp("topBarComponents.center", []);
|
|
11
|
+
const rightComponents = core.useBuilderProp("topBarComponents.right", []);
|
|
12
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex h-14 items-center justify-between px-2", children: [
|
|
13
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center space-x-2", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center space-x-2 font-bold", children: leftComponents.map((Component, index) => /* @__PURE__ */ jsxRuntime.jsx(React.Suspense, { fallback: /* @__PURE__ */ jsxRuntime.jsx(contextMenu.Skeleton, { className: "h-10" }), children: /* @__PURE__ */ jsxRuntime.jsx(Component, {}) }, `left-${index}`)) }) }),
|
|
14
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center space-x-2", children: centerComponents.map((Component, index) => /* @__PURE__ */ jsxRuntime.jsx(React.Suspense, { fallback: /* @__PURE__ */ jsxRuntime.jsx(contextMenu.Skeleton, { className: "h-10" }), children: /* @__PURE__ */ jsxRuntime.jsx(Component, {}) }, `center-${index}`)) }),
|
|
15
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center space-x-1", children: rightComponents.map((Component, index) => /* @__PURE__ */ jsxRuntime.jsx(React.Suspense, { fallback: /* @__PURE__ */ jsxRuntime.jsx(contextMenu.Skeleton, { className: "h-10" }), children: /* @__PURE__ */ jsxRuntime.jsx(Component, {}) }, `right-${index}`)) })
|
|
16
|
+
] });
|
|
17
|
+
};
|
|
18
|
+
exports.default = Topbar;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Suspense } from "react";
|
|
3
|
+
import { S as Skeleton } from "./context-menu-DHla8ofZ.js";
|
|
4
|
+
import "react-i18next";
|
|
5
|
+
import { useBuilderProp } from "./core.js";
|
|
6
|
+
const Topbar = () => {
|
|
7
|
+
const leftComponents = useBuilderProp("topBarComponents.left", []);
|
|
8
|
+
const centerComponents = useBuilderProp("topBarComponents.center", []);
|
|
9
|
+
const rightComponents = useBuilderProp("topBarComponents.right", []);
|
|
10
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex h-14 items-center justify-between px-2", children: [
|
|
11
|
+
/* @__PURE__ */ jsx("div", { className: "flex items-center space-x-2", children: /* @__PURE__ */ jsx("div", { className: "flex items-center space-x-2 font-bold", children: leftComponents.map((Component, index) => /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(Skeleton, { className: "h-10" }), children: /* @__PURE__ */ jsx(Component, {}) }, `left-${index}`)) }) }),
|
|
12
|
+
/* @__PURE__ */ jsx("div", { className: "flex items-center space-x-2", children: centerComponents.map((Component, index) => /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(Skeleton, { className: "h-10" }), children: /* @__PURE__ */ jsx(Component, {}) }, `center-${index}`)) }),
|
|
13
|
+
/* @__PURE__ */ jsx("div", { className: "flex items-center space-x-1", children: rightComponents.map((Component, index) => /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(Skeleton, { className: "h-10" }), children: /* @__PURE__ */ jsx(Component, {}) }, `right-${index}`)) })
|
|
14
|
+
] });
|
|
15
|
+
};
|
|
16
|
+
export {
|
|
17
|
+
Topbar as default
|
|
18
|
+
};
|