@kyro-cms/studio 0.0.0-stage → 0.2.0

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/src/react.tsx ADDED
@@ -0,0 +1,306 @@
1
+ import { pageFontStylesheet } from "./fonts";
2
+ import { extendedLayoutStyle, layoutItemStyle } from "./layout-styles";
3
+ import React from "react";
4
+ import type {
5
+ StudioBlock,
6
+ StudioComponent,
7
+ StudioContext,
8
+ StudioIssue,
9
+ StudioRegistry,
10
+ StudioRenderProps,
11
+ } from "./types";
12
+ import { contentComponents, Hero } from "./blocks";
13
+ import { attr, list, text, reference, safeStudioUrl } from "./primitives";
14
+ import { getStudioReferenceIssues } from "./references";
15
+ import { studioPageStyles } from "./styles";
16
+ export { Hero, studioPageStyles };
17
+ export { safeStudioUrl } from "./primitives";
18
+ export type {
19
+ StudioBlock,
20
+ StudioComponent,
21
+ StudioContext,
22
+ StudioIssue,
23
+ StudioRegistry,
24
+ StudioRenderProps,
25
+ } from "./types";
26
+ export function createStudioRegistry(components: StudioComponent[]): StudioRegistry {
27
+ const registry = new Map<string, StudioComponent>();
28
+ for (const component of components) {
29
+ if (!component.type || registry.has(component.type))
30
+ throw new Error(`Duplicate or empty Studio component: ${component.type}`);
31
+ registry.set(component.type, component);
32
+ }
33
+ return registry;
34
+ }
35
+ const contentTypes = contentComponents.map((c) => c.type);
36
+ const allowed: Record<string, string[]> = {
37
+ section: ["container", "row", "grid", ...contentTypes, "spacer", "divider"],
38
+ container: ["row", "grid", ...contentTypes, "spacer", "divider"],
39
+ row: ["column"],
40
+ grid: ["column", ...contentTypes, "spacer", "divider"],
41
+ column: [...contentTypes, "spacer", "divider"],
42
+ };
43
+ const widths: Record<string, string> = { narrow: "720px", content: "1120px", wide: "1440px", full: "100%" };
44
+ const space: Record<string, number> = { none: 0, small: 16, medium: 32, large: 64 };
45
+ const colors: Record<string, string> = {
46
+ white: "var(--studio-surface)",
47
+ muted: "var(--studio-muted-surface)",
48
+ peach: "var(--studio-soft)",
49
+ dark: "var(--studio-inverse)",
50
+ };
51
+ function Layout(props: StudioRenderProps) {
52
+ const { block } = props;
53
+ const settings = block.layout || {};
54
+ const background = colors[settings.background] || "transparent";
55
+ const mediaField = settings.backgroundType === "video" ? "backgroundVideo" : "backgroundImage";
56
+ const media = reference(settings[mediaField], "media", props);
57
+ const mediaUrl = safeStudioUrl(media?.url);
58
+ const mediaBackground = ["image", "video"].includes(settings.backgroundType);
59
+ return (
60
+ <div
61
+ {...attr(props, "layout")}
62
+ id={typeof settings.htmlId === "string" ? settings.htmlId.trim().replace(/\s+/g, "-") : undefined}
63
+ className={`kyro-layout kyro-layout-${block.blockType} ${typeof settings.cssClasses === "string" ? settings.cssClasses : ""}`}
64
+ data-empty={!list(block.children).length}
65
+ data-tablet-padding={typeof settings.tabletPadding === "number" || undefined}
66
+ data-tablet-gap={typeof settings.tabletGap === "number" || undefined}
67
+ data-tablet-columns={typeof settings.tabletColumns === "number" || undefined}
68
+ data-tablet-direction={settings.tabletDirection || undefined}
69
+ data-mobile-padding={typeof settings.mobilePadding === "number" || undefined}
70
+ data-mobile-gap={typeof settings.mobileGap === "number" || undefined}
71
+ data-mobile-columns={typeof settings.mobileColumns === "number" || undefined}
72
+ data-mobile-direction={settings.mobileDirection || undefined}
73
+ style={{
74
+ position: "relative",
75
+ isolation: "isolate",
76
+ maxWidth: widths[settings.width] || "100%",
77
+ marginInline: "auto",
78
+ padding: space[settings.padding] ?? 0,
79
+ gap: space[settings.gap] ?? 16,
80
+ background,
81
+ flexDirection: settings.direction === "row" || settings.direction === "column" ? settings.direction : undefined,
82
+ flexWrap: settings.wrap === "wrap" || settings.wrap === "nowrap" ? settings.wrap : undefined,
83
+ minHeight: Number.isFinite(settings.minHeight) ? Math.max(0, Math.min(2400, settings.minHeight)) : undefined,
84
+ borderRadius: Number.isFinite(settings.radius) ? Math.max(0, Math.min(200, settings.radius)) : undefined,
85
+ overflow: ["visible", "hidden", "auto"].includes(settings.overflow) ? settings.overflow : undefined,
86
+ color: settings.background === "dark" ? "var(--studio-inverse-text)" : undefined,
87
+ ...(settings.background === "dark"
88
+ ? { "--studio-ink": "var(--studio-inverse-text)", "--studio-muted": "var(--studio-inverse-text)" }
89
+ : {}),
90
+ alignItems: ({ start: "start", center: "center", end: "end", stretch: "stretch" } as const)[
91
+ settings.align as "start"
92
+ ],
93
+ justifyContent: ({ start: "start", center: "center", end: "end", between: "space-between" } as const)[
94
+ settings.justify as "start"
95
+ ],
96
+ gridTemplateColumns:
97
+ block.blockType === "grid"
98
+ ? `repeat(${Math.max(1, Math.min(4, Number(settings.columns) || 2))},minmax(0,1fr))`
99
+ : undefined,
100
+ ...extendedLayoutStyle(settings),
101
+ }}
102
+ >
103
+ {mediaBackground && mediaUrl && (settings.backgroundType === "video" ?
104
+ <video src={mediaUrl} autoPlay={!props.editing} muted loop playsInline aria-hidden="true" tabIndex={-1}
105
+ className="kyro-layout-background-media" style={{ objectFit: "cover", objectPosition: settings.backgroundPosition || "center" }} /> :
106
+ <div aria-hidden="true" className="kyro-layout-background-media" style={{ backgroundImage: `url(${JSON.stringify(mediaUrl)})`, backgroundSize: settings.backgroundSize || "cover", backgroundPosition: settings.backgroundPosition || "center", backgroundRepeat: "no-repeat" }} />)}
107
+ {mediaBackground && settings.overlayColor && <div aria-hidden="true" className="kyro-layout-background-media" style={{ background: settings.overlayColor, opacity: Math.max(0, Math.min(100, Number(settings.overlayOpacity) || 0)) / 100 }} />}
108
+ {renderNodes(
109
+ list(block.children),
110
+ props.editing || false,
111
+ props.context,
112
+ props.context?.registry || defaultStudioRegistry,
113
+ props.nodePath ? `${props.nodePath}.children` : "children",
114
+ false,
115
+ undefined,
116
+ 0,
117
+ block.blockType === "grid" ? Math.max(1, Math.min(4, Number(settings.columns) || 2)) : undefined,
118
+ )}
119
+ {props.editing && !list(block.children).length && (
120
+ <div className="kyro-layout-placeholder">Select this {block.blockType}, then insert content inside.</div>
121
+ )}
122
+ </div>
123
+ );
124
+ }
125
+ const layouts: StudioComponent[] = [
126
+ ...Object.keys(allowed).map((type) => ({
127
+ type,
128
+ label: type[0].toUpperCase() + type.slice(1),
129
+ category: "Layout",
130
+ Component: Layout,
131
+ allowedChildren: allowed[type],
132
+ defaults: {
133
+ layout: {
134
+ width: type === "container" ? "content" : "full",
135
+ padding: type === "section" ? "large" : "none",
136
+ gap: "medium",
137
+ background: "white",
138
+ columns: 2,
139
+ },
140
+ children: [],
141
+ },
142
+ })),
143
+ {
144
+ type: "spacer",
145
+ label: "Spacer",
146
+ category: "Layout",
147
+ Component: (p: StudioRenderProps) => (
148
+ <div
149
+ {...attr(p, "size")}
150
+ style={{
151
+ height: Math.max(0, Math.min(240, Number.isFinite(Number(p.block.size)) ? Number(p.block.size) : 32)),
152
+ }}
153
+ />
154
+ ),
155
+ defaults: { size: 32 },
156
+ },
157
+ {
158
+ type: "divider",
159
+ label: "Divider",
160
+ category: "Layout",
161
+ Component: (p: StudioRenderProps) => (
162
+ <hr {...attr(p, "label")} style={{ border: 0, borderTop: "1px solid var(--studio-border)", margin: "24px 0" }} />
163
+ ),
164
+ },
165
+ ];
166
+ const registeredComponents = new Map(createStudioRegistry([...contentComponents, ...layouts]));
167
+ export const defaultStudioRegistry: StudioRegistry = registeredComponents;
168
+ let componentSnapshot = [...registeredComponents.values()];
169
+ const listeners = new Set<() => void>();
170
+ export function registerStudioComponent(component: StudioComponent) {
171
+ if (!component.type || !component.label || !component.Component)
172
+ throw new Error("A Studio component needs a type, label, and renderer");
173
+ registeredComponents.set(component.type, component);
174
+ componentSnapshot = [...registeredComponents.values()];
175
+ listeners.forEach((f) => f());
176
+ }
177
+ export function getStudioComponents() {
178
+ return componentSnapshot;
179
+ }
180
+ export function subscribeStudioComponents(listener: () => void) {
181
+ listeners.add(listener);
182
+ return () => {
183
+ listeners.delete(listener);
184
+ };
185
+ }
186
+ export function getStudioIssues(
187
+ blocks: StudioBlock[],
188
+ context?: StudioContext,
189
+ registry: StudioRegistry = defaultStudioRegistry,
190
+ ): StudioIssue[] {
191
+ const issues: StudioIssue[] = [...getStudioReferenceIssues(blocks, context)];
192
+ const walk = (nodes: StudioBlock[], prefix: string) => {
193
+ if (prefix.split(".").length > 24) {
194
+ issues.push({ code: "nesting-depth", path: prefix, message: "Layout nesting exceeds the supported depth." });
195
+ return;
196
+ }
197
+ nodes.forEach((block, index) => {
198
+ const path = `${prefix}${index}`;
199
+ const def = registry.get(block.blockType);
200
+ if (!def) issues.push({ code: "unknown-block", path, message: `No renderer registered for ${block.blockType}.` });
201
+ if (def?.requiresFormAdapter && !context?.renderForm)
202
+ issues.push({
203
+ code: "form-adapter",
204
+ path,
205
+ message: "Connect a form submission adapter before publishing this form.",
206
+ });
207
+ const children = list(block.children);
208
+ if (children.length && !def?.allowedChildren)
209
+ issues.push({ code: "invalid-nesting", path, message: `${block.blockType} does not accept nested sections.` });
210
+ children.forEach((child, n) => {
211
+ if (def?.allowedChildren && !def.allowedChildren.includes(child.blockType))
212
+ issues.push({
213
+ code: "invalid-nesting",
214
+ path: `${path}.children.${n}`,
215
+ message: `${child.blockType} is not allowed inside ${block.blockType}.`,
216
+ });
217
+ });
218
+ walk(children, `${path}.children.`);
219
+ walk(list(block.elements), `${path}.elements.`);
220
+ });
221
+ };
222
+ walk(blocks, "");
223
+ return issues;
224
+ }
225
+ function renderNodes(
226
+ blocks: StudioBlock[],
227
+ editing: boolean,
228
+ context: StudioContext | undefined,
229
+ registry: StudioRegistry,
230
+ prefix: string,
231
+ root: boolean,
232
+ renderUnknown?: (block: StudioBlock, index: number) => React.ReactNode,
233
+ startIndex = 0,
234
+ parentColumns?: number,
235
+ ): React.ReactNode {
236
+ return blocks.map((block, index) => {
237
+ const path = root ? String(index + startIndex) : `${prefix}.${index}`;
238
+ const definition = registry.get(block.blockType);
239
+ if (!definition) {
240
+ if (renderUnknown) return <React.Fragment key={block.id || path}>{renderUnknown(block, index)}</React.Fragment>;
241
+ if (editing)
242
+ return (
243
+ <div key={block.id || path} className="kyro-card" data-kyro-node-path={path}>
244
+ Missing renderer: {block.blockType}
245
+ </div>
246
+ );
247
+ throw new Error(`Kyro Studio: no renderer for ${block.blockType} at ${path}`);
248
+ }
249
+ const props = { block, editing, context, nodePath: path };
250
+ // Fields are relative to the selected block; node paths identify nested owners.
251
+ return (
252
+ <div
253
+ className="kyro-block"
254
+ style={layoutItemStyle(parentColumns && block.layout?.columnSpan ? { ...block.layout, columnSpan: Math.min(parentColumns, block.layout.columnSpan) } : block.layout)}
255
+ key={block.id || path}
256
+ data-kyro-block-id={editing ? block.id : undefined}
257
+ data-kyro-block-index={editing && root ? index + startIndex : undefined}
258
+ data-kyro-node-path={editing ? path : undefined}
259
+ data-kyro-node-type={editing ? block.blockType : undefined}
260
+ tabIndex={editing ? 0 : undefined}
261
+ role={editing ? "button" : undefined}
262
+ aria-label={editing ? `Select ${definition.label}` : undefined}
263
+ >
264
+ <definition.Component {...props} />
265
+ {list(block.elements).length > 0 && (
266
+ <div className="kyro-elements">
267
+ {renderNodes(list(block.elements), editing, context, registry, `${path}.elements`, false, renderUnknown)}
268
+ </div>
269
+ )}
270
+ </div>
271
+ );
272
+ });
273
+ }
274
+ export function StudioPage({
275
+ blocks,
276
+ registry = defaultStudioRegistry,
277
+ editing = false,
278
+ startIndex = 0,
279
+ renderUnknown,
280
+ context,
281
+ theme = "system",
282
+ includeStyles = true,
283
+ }: {
284
+ blocks: StudioBlock[];
285
+ registry?: StudioRegistry;
286
+ editing?: boolean;
287
+ startIndex?: number;
288
+ renderUnknown?: (block: StudioBlock, index: number) => React.ReactNode;
289
+ context?: StudioContext;
290
+ theme?: "system" | "light" | "dark";
291
+ includeStyles?: boolean;
292
+ }) {
293
+ if (!editing) {
294
+ const issues = getStudioIssues(blocks, context, registry).filter(
295
+ (issue) => !(renderUnknown && issue.code === "unknown-block"),
296
+ );
297
+ if (issues.length) throw new Error(`Kyro Studio: ${issues.map((i) => i.message).join(" ")}`);
298
+ }
299
+ return (
300
+ <div className="kyro-page" data-theme={theme}>
301
+ {pageFontStylesheet(blocks) && <link rel="stylesheet" href={pageFontStylesheet(blocks)} />}
302
+ {includeStyles && <style>{studioPageStyles}</style>}
303
+ {renderNodes(blocks, editing, { ...context, registry }, registry, "", true, renderUnknown, startIndex)}
304
+ </div>
305
+ );
306
+ }
@@ -0,0 +1,71 @@
1
+ import type { StudioBlock, StudioContext, StudioIssue } from "./types";
2
+ import { safeStudioUrl } from "./primitives";
3
+ export interface StudioReference {
4
+ collection: string;
5
+ id: string;
6
+ path: string;
7
+ }
8
+ const mediaFields = new Set(["image", "backgroundImage", "backgroundVideo", "coverImage", "avatar", "companyLogo", "logo", "file"]);
9
+ export function collectStudioReferences(blocks: StudioBlock[]): StudioReference[] {
10
+ const refs: StudioReference[] = [];
11
+ const add = (value: any, collection: string, path: string) => {
12
+ if (!value) return;
13
+ if (value?.relationTo) collection = value.relationTo;
14
+ value = value?.value ?? value;
15
+ if (typeof value === "object" && (value.url || value.title || value.name || value.fields)) return;
16
+ if (collection === "media" && typeof value === "string" && safeStudioUrl(value)) return;
17
+ const id = typeof value === "string" ? value : value?.id;
18
+ if (id) refs.push({ collection, id: String(id), path });
19
+ };
20
+ const walk = (value: any, path: string, depth = 0) => {
21
+ if (depth > 20 || value == null) return;
22
+ if (Array.isArray(value)) {
23
+ value.forEach((v, i) => walk(v, `${path}.${i}`, depth + 1));
24
+ return;
25
+ }
26
+ if (typeof value !== "object") return;
27
+ for (const [key, v] of Object.entries(value)) {
28
+ const p = path ? `${path}.${key}` : key;
29
+ if (mediaFields.has(key)) add(v, "media", p);
30
+ else if (key === "form") add(v, "forms", p);
31
+ else if (key === "selectedItems" && Array.isArray(v))
32
+ v.forEach((item, i) => add(item, item?.relationTo || "*", `${p}.${i}`));
33
+ else walk(v, p, depth + 1);
34
+ }
35
+ };
36
+ blocks.forEach((b, i) => walk(b, String(i)));
37
+ return refs;
38
+ }
39
+ export function getStudioReferenceIssues(blocks: StudioBlock[], context?: StudioContext): StudioIssue[] {
40
+ return collectStudioReferences(blocks)
41
+ .filter((ref) => !context?.references?.has(`${ref.collection}/${ref.id}`))
42
+ .map((ref) => ({
43
+ code: "unresolved-reference",
44
+ path: ref.path,
45
+ message: `Resolve ${ref.collection} reference ${ref.id} before publishing.`,
46
+ }));
47
+ }
48
+ /** Runs on a frontend server or client. The caller supplies its authenticated API/SDK read. */
49
+ export async function resolveStudioReferences(
50
+ blocks: StudioBlock[],
51
+ fetchReference: (collection: string, id: string) => Promise<Record<string, any> | undefined>,
52
+ ): Promise<Map<string, Record<string, any>>> {
53
+ const pending = [
54
+ ...new Map(collectStudioReferences(blocks).map((ref) => [`${ref.collection}/${ref.id}`, ref])).values(),
55
+ ];
56
+ const references = new Map<string, Record<string, any>>();
57
+ // Bound concurrency; never put credentials in serialized page content.
58
+ for (let start = 0; start < pending.length; start += 6)
59
+ await Promise.all(
60
+ pending.slice(start, start + 6).map(async (ref) => {
61
+ if (ref.collection === "*") return;
62
+ try {
63
+ const doc = await fetchReference(ref.collection, ref.id);
64
+ if (doc) references.set(`${ref.collection}/${ref.id}`, doc);
65
+ } catch {
66
+ /* Unresolved references are surfaced by preflight. */
67
+ }
68
+ }),
69
+ );
70
+ return references;
71
+ }
package/src/styles.ts ADDED
@@ -0,0 +1,8 @@
1
+ export const studioPageStyles = `
2
+ .kyro-page{--studio-accent:#ff570a;--studio-ink:#201a17;--studio-muted:#70645c;--studio-border:#e9e3dd;--studio-soft:#fff6f0;--studio-surface:#fff;--studio-muted-surface:#f7f5f2;--studio-inverse:#201a17;--studio-inverse-text:#fff;color:var(--studio-ink);background:var(--studio-surface);font-family:Geist,Inter,Arial,sans-serif;line-height:1.6;overflow-wrap:anywhere}.kyro-page *{box-sizing:border-box}.kyro-page h1,.kyro-page h2,.kyro-page h3{line-height:1.15;letter-spacing:-.035em;margin:0 0 16px;font-weight:500}.kyro-page h1{font-size:clamp(32px,5.5vw,68px)}.kyro-page h2{font-size:clamp(26px,3.5vw,44px)}.kyro-page h3{font-size:22px}.kyro-page p{margin:0 0 16px;white-space:pre-wrap}.kyro-page img{display:block;max-width:100%;height:auto;object-fit:cover;border-radius:8px}.kyro-page a{color:inherit}.kyro-page figure{margin:0}.kyro-page figcaption,.kyro-page small{color:var(--studio-muted);font-size:13px}.kyro-page button,.kyro-page input,.kyro-page textarea{font:inherit}.kyro-page input,.kyro-page textarea{display:block;max-width:100%;border:1px solid var(--studio-border);border-radius:6px;padding:10px;background:var(--studio-surface);color:var(--studio-ink)}.kyro-section{padding:clamp(24px,5vw,64px) clamp(20px,6vw,80px)}.kyro-section-intro{max-width:720px;margin-bottom:32px}.kyro-section-intro p{color:var(--studio-muted);font-size:18px}.kyro-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,240px),1fr));gap:24px}.kyro-split{display:grid;grid-template-columns:minmax(0,1.15fr) minmax(0,1fr);gap:clamp(24px,5vw,64px);align-items:center}.kyro-single{grid-template-columns:minmax(0,1fr)}.kyro-split>div{min-width:0}.kyro-hero{padding:clamp(32px,7vw,96px) clamp(24px,6vw,80px);background:var(--studio-soft);min-height:360px}.kyro-hero p{font-size:clamp(16px,1.7vw,20px);color:var(--studio-muted);max-width:680px;margin-top:24px}.kyro-hero img{aspect-ratio:4/3;width:100%}.kyro-actions{display:flex;flex-wrap:wrap;gap:12px;margin-top:24px}.kyro-action{display:inline-flex;align-items:center;justify-content:center;padding:12px 20px;border-radius:6px;text-decoration:none;background:var(--studio-accent);color:#20130b;border:1px solid #e3c8b6;font-size:14px}.kyro-action:nth-child(n+2){background:transparent}.kyro-card{border:1px solid var(--studio-border);padding:24px;border-radius:8px;min-width:0}.kyro-card img{margin-bottom:20px;width:100%;aspect-ratio:4/3}.kyro-card p{color:var(--studio-muted)}.kyro-page blockquote{font-size:clamp(20px,2vw,28px);line-height:1.5;margin:16px 0}.kyro-avatar{width:44px!important;height:44px!important;border-radius:50%!important;aspect-ratio:1!important}.kyro-logo{max-width:140px;max-height:64px;object-fit:contain!important}.kyro-logos{display:flex;flex-wrap:wrap;align-items:center;gap:40px}.kyro-logos a{display:flex;align-items:center;gap:12px}.kyro-stat{font-size:clamp(28px,4vw,52px);letter-spacing:-.04em;line-height:1.1}.kyro-stat small{font-size:14px;letter-spacing:0}.kyro-featured{border-color:var(--studio-accent);background:var(--studio-soft)}.kyro-faq{border-top:1px solid var(--studio-border);padding:20px 0}.kyro-faq summary{cursor:pointer;font-size:18px;font-weight:500}.kyro-faq p{padding-top:16px;max-width:75ch;color:var(--studio-muted)}.kyro-faq-footer{display:inline-block;margin-top:24px}.kyro-checkpoint{margin-bottom:24px}.kyro-checkpoint img{max-width:80px;margin-bottom:12px}.kyro-steps{list-style:none;padding:0}.kyro-cta{background:var(--studio-soft);padding:clamp(24px,5vw,64px);border-radius:8px}.kyro-media-placeholder{display:flex;align-items:center;justify-content:center;background:var(--studio-muted-surface);color:var(--studio-muted);min-height:140px;border:1px dashed var(--studio-border);border-radius:8px;font-size:14px}.kyro-image [style*=aspect-ratio] img{width:100%;height:100%}.kyro-image figcaption{padding-top:8px}.kyro-video-preview{display:grid;place-items:center;position:relative;aspect-ratio:16/9;background:#201a17;color:white;overflow:hidden;border-radius:8px}.kyro-video-preview>span{font-size:56px}.kyro-video-preview img{position:absolute;inset:0;width:100%;height:100%;opacity:.5}.kyro-video-preview p,.kyro-video-preview small{position:relative;z-index:1;margin:0;padding:16px;color:#fff}.kyro-page iframe,.kyro-page video{width:100%;aspect-ratio:16/9;border:0;border-radius:8px}.kyro-form-preview{padding:24px;border:1px solid var(--studio-border);border-radius:8px}.kyro-form-preview label{display:block;margin-bottom:16px}.kyro-form-preview input,.kyro-form-preview textarea{width:100%;margin-top:6px}.kyro-form-preview input[type=checkbox]{width:auto}.kyro-form-preview button{padding:10px 20px;border:0;background:var(--studio-accent);border-radius:6px}.kyro-form-preview small{display:block;margin-top:16px}.kyro-rich-content ul,.kyro-rich-content ol{padding-inline-start:24px}.kyro-rich-content pre{overflow:auto;padding:16px;background:var(--studio-muted-surface);border-radius:6px}.kyro-tabs,.kyro-carousel-controls{display:flex;flex-wrap:wrap;gap:6px;margin-bottom:24px}.kyro-tabs button,.kyro-carousel-controls button{padding:8px 14px;border:1px solid var(--studio-border);background:var(--studio-surface);border-radius:6px;cursor:pointer}.kyro-tabs [aria-selected=true],.kyro-carousel-controls [aria-pressed=true]{background:var(--studio-soft);border-color:var(--studio-accent)}.kyro-layout{min-width:0}.kyro-layout>.kyro-layout-background-media{position:absolute;inset:0;width:100%;height:100%;border-radius:inherit;pointer-events:none;z-index:-1;aspect-ratio:auto}.kyro-layout>.kyro-block{position:relative}.kyro-layout[data-empty=true]{min-height:100px}.kyro-layout-placeholder{padding:24px;border:1px dashed #c9b8aa;color:var(--studio-muted);font-size:13px;text-align:center}.kyro-layout-column>.kyro-block>.kyro-section,.kyro-elements>.kyro-block>.kyro-section{padding:16px 0}.kyro-elements{padding:16px clamp(20px,6vw,80px)}.kyro-elements:empty{display:none}.kyro-layout-container,.kyro-layout-section,.kyro-layout-column{display:flex;flex-direction:column}.kyro-layout-row{display:flex;flex-wrap:wrap}.kyro-layout-row>.kyro-block{flex:1 1 240px;min-width:0}.kyro-layout-column{height:100%}.kyro-layout-grid{display:grid}.kyro-layout-grid>.kyro-block{min-width:0}
3
+ .kyro-badge{display:inline-flex;border-radius:100px;padding:4px 12px;background:var(--studio-soft);color:var(--studio-ink);font-size:13px}.kyro-notice{padding:24px;border-inline-start:3px solid var(--studio-accent);background:var(--studio-soft);border-radius:6px}
4
+ .kyro-page[data-theme=dark]{--studio-accent:#ff783b;--studio-ink:#f4eee8;--studio-muted:#b2a79c;--studio-border:#3b342e;--studio-soft:#2b211b;--studio-surface:#151515;--studio-muted-surface:#201e1c;--studio-inverse:#f4eee8;--studio-inverse-text:#201a17;}
5
+ @media(prefers-color-scheme:dark){.kyro-page[data-theme=system]{--studio-accent:#ff783b;--studio-ink:#f4eee8;--studio-muted:#b2a79c;--studio-border:#3b342e;--studio-soft:#2b211b;--studio-surface:#151515;--studio-muted-surface:#201e1c;--studio-inverse:#f4eee8;--studio-inverse-text:#201a17;}}
6
+ @media(max-width:600px){.kyro-layout[style*="flex-direction:row"],.kyro-layout[style*="flex-direction: row"]{flex-direction:column!important}.kyro-split{grid-template-columns:minmax(0,1fr)}.kyro-layout-grid{grid-template-columns:minmax(0,1fr)!important}.kyro-layout-row{flex-direction:column}.kyro-layout-row>.kyro-block{flex-basis:auto}.kyro-hero img{max-height:320px}.kyro-grid{gap:20px}}
7
+ @media(max-width:1024px){.kyro-layout-grid>.kyro-block{grid-column:auto!important} .kyro-layout[data-tablet-padding]{padding:var(--layout-tablet-padding)!important} .kyro-layout[data-tablet-gap]{gap:var(--layout-tablet-gap)!important} .kyro-layout[data-tablet-direction]{flex-direction:var(--layout-tablet-direction)!important} .kyro-layout-grid[data-tablet-columns]{grid-template-columns:repeat(var(--layout-tablet-columns),minmax(0,1fr))!important}}@media(max-width:600px){ .kyro-layout[data-mobile-padding]{padding:var(--layout-mobile-padding)!important} .kyro-layout[data-mobile-gap]{gap:var(--layout-mobile-gap)!important} .kyro-layout[data-mobile-direction]{flex-direction:var(--layout-mobile-direction)!important} .kyro-layout-grid[data-mobile-columns]{grid-template-columns:repeat(var(--layout-mobile-columns),minmax(0,1fr))!important}}
8
+ `;
package/src/types.ts ADDED
@@ -0,0 +1,36 @@
1
+ import type { ComponentType, ReactNode } from "react";
2
+ export interface StudioBlock extends Record<string, any> {
3
+ id?: string;
4
+ blockType: string;
5
+ children?: StudioBlock[];
6
+ elements?: StudioBlock[];
7
+ }
8
+ export interface StudioContext {
9
+ registry?: StudioRegistry;
10
+ references?: ReadonlyMap<string, Record<string, any>>;
11
+ renderForm?: (form: Record<string, any>, props: StudioRenderProps) => ReactNode;
12
+ }
13
+ export interface StudioRenderProps {
14
+ block: StudioBlock;
15
+ editing?: boolean;
16
+ pathPrefix?: string;
17
+ nodePath?: string;
18
+ context?: StudioContext;
19
+ }
20
+ export interface StudioComponent {
21
+ type: string;
22
+ label: string;
23
+ category?: string;
24
+ description?: string;
25
+ Component: ComponentType<StudioRenderProps>;
26
+ defaults?: Record<string, unknown>;
27
+ editableFields?: string[];
28
+ requiresFormAdapter?: boolean;
29
+ allowedChildren?: string[];
30
+ }
31
+ export type StudioRegistry = ReadonlyMap<string, StudioComponent>;
32
+ export interface StudioIssue {
33
+ code: string;
34
+ path: string;
35
+ message: string;
36
+ }