@eldrajs/theme-core 0.0.0 → 0.1.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/CHANGELOG.md +301 -0
- package/LICENSE +21 -0
- package/README.md +68 -1
- package/dist/bridge-DfNINXLL.js +314 -0
- package/dist/bridge.d.ts +2 -0
- package/dist/bridge.js +2 -0
- package/dist/design-tokens.d.ts +68 -0
- package/dist/design-tokens.js +486 -0
- package/dist/dynamic-route.d.ts +2 -0
- package/dist/dynamic-route.js +3 -0
- package/dist/dynamicRoute-CxXY-Y_8.js +126 -0
- package/dist/dynamicRoute-pRTBoYT6.d.ts +55 -0
- package/dist/i18n.d.ts +107 -0
- package/dist/i18n.js +192 -0
- package/dist/image-framing.d.ts +2 -0
- package/dist/image-framing.js +109 -0
- package/dist/imageFraming-BUZ-yqho.d.ts +51 -0
- package/dist/index-DxrkKyG4.d.ts +488 -0
- package/dist/index.d.ts +407 -0
- package/dist/index.js +1136 -0
- package/dist/layout-CWq_v6ws.d.ts +244 -0
- package/dist/layout.d.ts +2 -0
- package/dist/layout.js +930 -0
- package/dist/links.d.ts +113 -0
- package/dist/links.js +184 -0
- package/dist/overlay-Bgi0tIbN.d.ts +201 -0
- package/dist/overlay-BvkEOiMB.js +2908 -0
- package/dist/overlay.d.ts +2 -0
- package/dist/overlay.js +6 -0
- package/dist/preview-router.d.ts +2 -0
- package/dist/preview-router.js +130 -0
- package/dist/reusable.d.ts +66 -0
- package/dist/reusable.js +92 -0
- package/dist/reusableExpansion-Bqm83nCJ.js +229 -0
- package/dist/reusableExpansion-CXvs_ckx.d.ts +42 -0
- package/dist/stega.d.ts +17 -0
- package/dist/stega.js +69 -0
- package/dist/template-layout.d.ts +3 -0
- package/dist/template-layout.js +328 -0
- package/dist/templateLayout-MjNs0gbF.d.ts +254 -0
- package/package.json +89 -2
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
//#region src/layout.d.ts
|
|
2
|
+
type LayoutBreakpoint = 'normal' | 'tablet' | 'mobile';
|
|
3
|
+
type Responsive<T> = {
|
|
4
|
+
normal: T;
|
|
5
|
+
tablet?: T;
|
|
6
|
+
mobile?: T;
|
|
7
|
+
};
|
|
8
|
+
type CssLength = `${number}px` | `${number}rem` | `${number}%`;
|
|
9
|
+
type SizingLength = CssLength | 'auto';
|
|
10
|
+
/** `width` only: a length/`auto`, plus the two intrinsic-sizing keywords —
|
|
11
|
+
* `fill` (grow to the available space) and `fit-content` (shrink to the
|
|
12
|
+
* content). `minWidth`/`maxWidth`/`minHeight` stay `SizingLength`; only
|
|
13
|
+
* `width` accepts these. */
|
|
14
|
+
type WidthLength = SizingLength | 'fill' | 'fit-content';
|
|
15
|
+
type Spacing = {
|
|
16
|
+
top: CssLength;
|
|
17
|
+
right: CssLength;
|
|
18
|
+
bottom: CssLength;
|
|
19
|
+
left: CssLength;
|
|
20
|
+
};
|
|
21
|
+
type LayoutStyle = {
|
|
22
|
+
container?: Responsive<string>;
|
|
23
|
+
margin?: Responsive<Partial<Spacing>>;
|
|
24
|
+
padding?: Responsive<Partial<Spacing>>;
|
|
25
|
+
width?: Responsive<WidthLength>;
|
|
26
|
+
minWidth?: Responsive<SizingLength>;
|
|
27
|
+
maxWidth?: Responsive<SizingLength>;
|
|
28
|
+
minHeight?: Responsive<SizingLength>;
|
|
29
|
+
alignSelf?: Responsive<'auto' | 'start' | 'center' | 'end' | 'stretch'>;
|
|
30
|
+
visible?: Responsive<boolean>;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Structural twin of @eldrajs/vite-plugin-theme's BlockSlotDefinition (theme-core
|
|
34
|
+
* cannot import from the Vite plugin, which depends on this package). Keep in
|
|
35
|
+
* sync: `id` ^[a-z][a-z0-9-]{0,47}$, `maxItems` 1..20, `minItems` only 0.
|
|
36
|
+
*/
|
|
37
|
+
interface BlockSlotDefinition {
|
|
38
|
+
id: string;
|
|
39
|
+
label: string;
|
|
40
|
+
description?: string;
|
|
41
|
+
minItems?: 0;
|
|
42
|
+
maxItems: number;
|
|
43
|
+
allowedBlockApiIds?: string[];
|
|
44
|
+
}
|
|
45
|
+
/** Theme manifest catalog checks injected by the caller (entry fetch, catalog). */
|
|
46
|
+
interface SlotValidationContext {
|
|
47
|
+
slotCatalog: Record<string, ReadonlyArray<BlockSlotDefinition>>;
|
|
48
|
+
entryApiId: (entryId: string) => string | undefined;
|
|
49
|
+
}
|
|
50
|
+
type LayoutBlockNode = {
|
|
51
|
+
id: string;
|
|
52
|
+
type: 'block';
|
|
53
|
+
entryId: string;
|
|
54
|
+
style?: LayoutStyle;
|
|
55
|
+
slots?: Record<string, LayoutBlockNode[]>;
|
|
56
|
+
};
|
|
57
|
+
type LayoutNode = LayoutBlockNode | {
|
|
58
|
+
id: string;
|
|
59
|
+
type: 'flex';
|
|
60
|
+
children: LayoutNode[];
|
|
61
|
+
style?: LayoutStyle;
|
|
62
|
+
layout: {
|
|
63
|
+
direction: Responsive<'row' | 'column'>;
|
|
64
|
+
wrap?: Responsive<'nowrap' | 'wrap'>;
|
|
65
|
+
gap?: Responsive<CssLength>;
|
|
66
|
+
justify?: Responsive<'start' | 'center' | 'end' | 'space-between' | 'space-around' | 'space-evenly'>;
|
|
67
|
+
align?: Responsive<'start' | 'center' | 'end' | 'stretch' | 'baseline'>;
|
|
68
|
+
};
|
|
69
|
+
} | {
|
|
70
|
+
id: string;
|
|
71
|
+
type: 'grid';
|
|
72
|
+
children: LayoutNode[];
|
|
73
|
+
style?: LayoutStyle;
|
|
74
|
+
layout: {
|
|
75
|
+
columns: Responsive<number>;
|
|
76
|
+
rows?: Responsive<number | 'auto'>;
|
|
77
|
+
columnGap?: Responsive<CssLength>;
|
|
78
|
+
rowGap?: Responsive<CssLength>;
|
|
79
|
+
justifyItems?: Responsive<'start' | 'center' | 'end' | 'stretch'>;
|
|
80
|
+
alignItems?: Responsive<'start' | 'center' | 'end' | 'stretch'>;
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
type LayoutContainerNode = Extract<LayoutNode, {
|
|
84
|
+
type: 'flex' | 'grid';
|
|
85
|
+
}>;
|
|
86
|
+
type LayoutDocument = {
|
|
87
|
+
version: 1 | 2 | 3;
|
|
88
|
+
root: LayoutContainerNode;
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* A theme's own tablet/normal layout breakpoints, as min-width px: mobile is
|
|
92
|
+
* `< tablet`, tablet is `tablet…normal-1`, normal is `>= normal`. The one
|
|
93
|
+
* source every breakpoint-dependent CSS (`cssForDocument`'s three `@media`
|
|
94
|
+
* ranges) and the `theme:ready` bridge negotiation (`breakpoints`, additive
|
|
95
|
+
* — see `./bridge`'s protocol) both read from.
|
|
96
|
+
*/
|
|
97
|
+
interface LayoutBreakpoints {
|
|
98
|
+
tablet: number;
|
|
99
|
+
normal: number;
|
|
100
|
+
}
|
|
101
|
+
/** The theme's breakpoints when it configures none — today's numbers,
|
|
102
|
+
* unchanged, so an unconfigured theme's CSS is byte-identical to before this
|
|
103
|
+
* type existed. */
|
|
104
|
+
declare const DEFAULT_LAYOUT_BREAKPOINTS: LayoutBreakpoints;
|
|
105
|
+
/**
|
|
106
|
+
* Validates a theme-configured breakpoints pair and falls back to
|
|
107
|
+
* `DEFAULT_LAYOUT_BREAKPOINTS`, with a console warning, on anything that
|
|
108
|
+
* cannot be turned into three non-overlapping, non-empty ranges: both must be
|
|
109
|
+
* finite integers, `320 <= tablet < normal <= 4096`. `undefined`/`null` (not
|
|
110
|
+
* configured) resolves to the defaults silently — that is the common case,
|
|
111
|
+
* not a mistake worth warning about.
|
|
112
|
+
*/
|
|
113
|
+
declare function resolveLayoutBreakpoints(breakpoints?: LayoutBreakpoints | null): LayoutBreakpoints;
|
|
114
|
+
/** @deprecated derived px ranges for `DEFAULT_LAYOUT_BREAKPOINTS`, kept for
|
|
115
|
+
* existing consumers. A theme with custom breakpoints is not reflected here —
|
|
116
|
+
* read `resolveLayoutBreakpoints`'s result instead. */
|
|
117
|
+
declare const LAYOUT_BREAKPOINTS: {
|
|
118
|
+
readonly mobileMax: number;
|
|
119
|
+
readonly tabletMin: number;
|
|
120
|
+
readonly tabletMax: number;
|
|
121
|
+
readonly normalMin: number;
|
|
122
|
+
};
|
|
123
|
+
type LayoutValidationCode = 'INVALID_TYPE' | 'UNKNOWN_KEY' | 'REQUIRED' | 'INVALID_VALUE' | 'LIMIT_EXCEEDED' | 'DUPLICATE_ID' | 'BLOCK_NOT_FOUND' | 'COMPONENT_NOT_FOUND' | 'COMPONENT_STALE' | 'COMPONENT_FOREIGN' | 'SLOT_VERSION' | 'SLOT_UNKNOWN' | 'SLOT_DISALLOWED' | 'SLOT_FULL';
|
|
124
|
+
type LayoutValidationIssue = {
|
|
125
|
+
path: string;
|
|
126
|
+
code: LayoutValidationCode;
|
|
127
|
+
};
|
|
128
|
+
declare class LayoutValidationError extends Error {
|
|
129
|
+
readonly issue: LayoutValidationIssue;
|
|
130
|
+
constructor(issue: LayoutValidationIssue);
|
|
131
|
+
}
|
|
132
|
+
type NormalizedLayoutResult = {
|
|
133
|
+
document: LayoutDocument;
|
|
134
|
+
blockEntryIds: string[];
|
|
135
|
+
};
|
|
136
|
+
type ResolvedLayoutStyle = {
|
|
137
|
+
container?: string;
|
|
138
|
+
margin?: Partial<Spacing>;
|
|
139
|
+
padding?: Partial<Spacing>;
|
|
140
|
+
width?: WidthLength;
|
|
141
|
+
minWidth?: SizingLength;
|
|
142
|
+
maxWidth?: SizingLength;
|
|
143
|
+
minHeight?: SizingLength;
|
|
144
|
+
alignSelf?: 'auto' | 'start' | 'center' | 'end' | 'stretch';
|
|
145
|
+
visible: boolean;
|
|
146
|
+
};
|
|
147
|
+
type ResolvedLayoutNode = {
|
|
148
|
+
id: string;
|
|
149
|
+
type: 'block';
|
|
150
|
+
entryId: string;
|
|
151
|
+
style: ResolvedLayoutStyle;
|
|
152
|
+
} | {
|
|
153
|
+
id: string;
|
|
154
|
+
type: 'flex';
|
|
155
|
+
children: ResolvedLayoutNode[];
|
|
156
|
+
style: ResolvedLayoutStyle;
|
|
157
|
+
layout: {
|
|
158
|
+
direction: 'row' | 'column';
|
|
159
|
+
wrap?: 'nowrap' | 'wrap';
|
|
160
|
+
gap?: CssLength;
|
|
161
|
+
justify?: 'start' | 'center' | 'end' | 'space-between' | 'space-around' | 'space-evenly';
|
|
162
|
+
align?: 'start' | 'center' | 'end' | 'stretch' | 'baseline';
|
|
163
|
+
};
|
|
164
|
+
} | {
|
|
165
|
+
id: string;
|
|
166
|
+
type: 'grid';
|
|
167
|
+
children: ResolvedLayoutNode[];
|
|
168
|
+
style: ResolvedLayoutStyle;
|
|
169
|
+
layout: {
|
|
170
|
+
columns: number;
|
|
171
|
+
rows?: number | 'auto';
|
|
172
|
+
columnGap?: CssLength;
|
|
173
|
+
rowGap?: CssLength;
|
|
174
|
+
justifyItems?: 'start' | 'center' | 'end' | 'stretch';
|
|
175
|
+
alignItems?: 'start' | 'center' | 'end' | 'stretch';
|
|
176
|
+
};
|
|
177
|
+
};
|
|
178
|
+
type ResolvedLayoutDocument = {
|
|
179
|
+
version: 1;
|
|
180
|
+
breakpoint: LayoutBreakpoint;
|
|
181
|
+
root: Extract<ResolvedLayoutNode, {
|
|
182
|
+
type: 'flex' | 'grid';
|
|
183
|
+
}>;
|
|
184
|
+
};
|
|
185
|
+
type LayoutRenderBlockNode = Omit<Extract<LayoutNode, {
|
|
186
|
+
type: 'block';
|
|
187
|
+
}>, 'slots'> & {
|
|
188
|
+
className: string;
|
|
189
|
+
slots?: Record<string, LayoutRenderBlockNode[]>;
|
|
190
|
+
};
|
|
191
|
+
type LayoutRenderNode = LayoutRenderBlockNode | (Omit<Extract<LayoutNode, {
|
|
192
|
+
type: 'flex';
|
|
193
|
+
}>, 'children'> & {
|
|
194
|
+
className: string;
|
|
195
|
+
children: LayoutRenderNode[];
|
|
196
|
+
}) | (Omit<Extract<LayoutNode, {
|
|
197
|
+
type: 'grid';
|
|
198
|
+
}>, 'children'> & {
|
|
199
|
+
className: string;
|
|
200
|
+
children: LayoutRenderNode[];
|
|
201
|
+
});
|
|
202
|
+
type LayoutRenderModel = NormalizedLayoutResult & {
|
|
203
|
+
root: Extract<LayoutRenderNode, {
|
|
204
|
+
type: 'flex' | 'grid';
|
|
205
|
+
}>;
|
|
206
|
+
css: string;
|
|
207
|
+
};
|
|
208
|
+
declare function validateLayoutDocument(value: unknown, allowedEntryIds?: ReadonlySet<string>, allowedContainerIds?: ReadonlySet<string>, slotContext?: SlotValidationContext): LayoutValidationIssue | null;
|
|
209
|
+
declare function normalizeLayoutDocument(value: unknown, allowedEntryIds?: ReadonlySet<string>, allowedContainerIds?: ReadonlySet<string>, slotContext?: SlotValidationContext): NormalizedLayoutResult;
|
|
210
|
+
declare function resolveLayoutDocument(value: unknown, breakpoint: LayoutBreakpoint, allowedEntryIds?: ReadonlySet<string>, allowedContainerIds?: ReadonlySet<string>): ResolvedLayoutDocument;
|
|
211
|
+
declare function layoutNodeClass(nodeId: string): string;
|
|
212
|
+
/** A canonical, collision-resistant node id for framework render identities. */
|
|
213
|
+
declare function layoutRenderNodeId(identity: string): string;
|
|
214
|
+
declare function generateLayoutCss(value: unknown, allowedEntryIds?: ReadonlySet<string>, allowedContainerIds?: ReadonlySet<string>, breakpoints?: LayoutBreakpoints): string;
|
|
215
|
+
declare function createLayoutRenderModel(value: unknown, allowedEntryIds?: ReadonlySet<string>, allowedContainerIds?: ReadonlySet<string>, slotContext?: SlotValidationContext, breakpoints?: LayoutBreakpoints): LayoutRenderModel;
|
|
216
|
+
/**
|
|
217
|
+
* How visible a hidden node is on the Studio canvas in edit mode — the design's
|
|
218
|
+
* 35 %: dim enough to read as "not on this device", solid enough to click,
|
|
219
|
+
* drag and see what it is.
|
|
220
|
+
*/
|
|
221
|
+
declare const EDIT_MODE_HIDDEN_OPACITY = 0.35;
|
|
222
|
+
/**
|
|
223
|
+
* Which of the three breakpoint ranges a viewport width falls in — the same
|
|
224
|
+
* ranges `cssForDocument` emits its `@media` blocks for, read from the one
|
|
225
|
+
* place that knows them, so a runtime asking "which breakpoint is in force?"
|
|
226
|
+
* and the browser evaluating the stylesheet cannot drift apart. `width` is the
|
|
227
|
+
* viewport width in CSS pixels (`window.innerWidth`), which is what a width
|
|
228
|
+
* media query is evaluated against.
|
|
229
|
+
*/
|
|
230
|
+
declare function activeLayoutBreakpoint(width: number, breakpoints?: LayoutBreakpoints | null): LayoutBreakpoint;
|
|
231
|
+
/**
|
|
232
|
+
* The breakpoints at which `style` hides its node, in `normal, tablet, mobile`
|
|
233
|
+
* order, resolved through the grammar's own inheritance (a `visible` a
|
|
234
|
+
* breakpoint does not restate is inherited from the wider one). Empty when the
|
|
235
|
+
* node is visible everywhere.
|
|
236
|
+
*
|
|
237
|
+
* This is the value of the `data-eldra-hidden` attribute a framework binding
|
|
238
|
+
* puts on the layout node, space-separated: it is rendered identically on the
|
|
239
|
+
* server and the client, carries no styling of its own, and is what the overlay
|
|
240
|
+
* finds the hidden nodes by when it marks them for edit mode.
|
|
241
|
+
*/
|
|
242
|
+
declare function hiddenLayoutBreakpoints(style?: LayoutStyle): LayoutBreakpoint[];
|
|
243
|
+
//#endregion
|
|
244
|
+
export { generateLayoutCss as A, Responsive as C, WidthLength as D, Spacing as E, resolveLayoutBreakpoints as F, resolveLayoutDocument as I, validateLayoutDocument as L, layoutNodeClass as M, layoutRenderNodeId as N, activeLayoutBreakpoint as O, normalizeLayoutDocument as P, ResolvedLayoutStyle as S, SlotValidationContext as T, LayoutValidationError as _, LAYOUT_BREAKPOINTS as a, ResolvedLayoutDocument as b, LayoutBreakpoints as c, LayoutNode as d, LayoutRenderBlockNode as f, LayoutValidationCode as g, LayoutStyle as h, EDIT_MODE_HIDDEN_OPACITY as i, hiddenLayoutBreakpoints as j, createLayoutRenderModel as k, LayoutContainerNode as l, LayoutRenderNode as m, CssLength as n, LayoutBlockNode as o, LayoutRenderModel as p, DEFAULT_LAYOUT_BREAKPOINTS as r, LayoutBreakpoint as s, BlockSlotDefinition as t, LayoutDocument as u, LayoutValidationIssue as v, SizingLength as w, ResolvedLayoutNode as x, NormalizedLayoutResult as y };
|
package/dist/layout.d.ts
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { A as generateLayoutCss, C as Responsive, D as WidthLength, E as Spacing, F as resolveLayoutBreakpoints, I as resolveLayoutDocument, L as validateLayoutDocument, M as layoutNodeClass, N as layoutRenderNodeId, O as activeLayoutBreakpoint, P as normalizeLayoutDocument, S as ResolvedLayoutStyle, T as SlotValidationContext, _ as LayoutValidationError, a as LAYOUT_BREAKPOINTS, b as ResolvedLayoutDocument, c as LayoutBreakpoints, d as LayoutNode, f as LayoutRenderBlockNode, g as LayoutValidationCode, h as LayoutStyle, i as EDIT_MODE_HIDDEN_OPACITY, j as hiddenLayoutBreakpoints, k as createLayoutRenderModel, l as LayoutContainerNode, m as LayoutRenderNode, n as CssLength, o as LayoutBlockNode, p as LayoutRenderModel, r as DEFAULT_LAYOUT_BREAKPOINTS, s as LayoutBreakpoint, t as BlockSlotDefinition, u as LayoutDocument, v as LayoutValidationIssue, w as SizingLength, x as ResolvedLayoutNode, y as NormalizedLayoutResult } from "./layout-CWq_v6ws.js";
|
|
2
|
+
export { BlockSlotDefinition, CssLength, DEFAULT_LAYOUT_BREAKPOINTS, EDIT_MODE_HIDDEN_OPACITY, LAYOUT_BREAKPOINTS, LayoutBlockNode, LayoutBreakpoint, LayoutBreakpoints, LayoutContainerNode, LayoutDocument, LayoutNode, LayoutRenderBlockNode, LayoutRenderModel, LayoutRenderNode, LayoutStyle, LayoutValidationCode, LayoutValidationError, LayoutValidationIssue, NormalizedLayoutResult, ResolvedLayoutDocument, ResolvedLayoutNode, ResolvedLayoutStyle, Responsive, SizingLength, SlotValidationContext, Spacing, WidthLength, activeLayoutBreakpoint, createLayoutRenderModel, generateLayoutCss, hiddenLayoutBreakpoints, layoutNodeClass, layoutRenderNodeId, normalizeLayoutDocument, resolveLayoutBreakpoints, resolveLayoutDocument, validateLayoutDocument };
|