@wunderweb/react 0.0.0-stage → 0.5.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.
@@ -0,0 +1,743 @@
1
+ import { BASE, Classes, Classes as Classes$1, Resp, Resp as Resp$1, at, tw } from "@wunderweb/core/tailwind";
2
+ import { GateData, PageConsent } from "@wunderweb/core/consent";
3
+ import { CSSProperties, ComponentType, ReactNode } from "react";
4
+ import { ImageCandidate, ImageSize } from "@wunderweb/core";
5
+ //#region src/core-types.d.ts
6
+ /** Per-breakpoint value, mobile first. */
7
+ type Responsive<T> = {
8
+ [breakpoint: string]: T | undefined;
9
+ };
10
+ /** Min viewport width in px. */
11
+ type Breakpoint = string;
12
+ /** Theme color token. */
13
+ type Color = string;
14
+ /** Theme button style. */
15
+ type ButtonVariant = string;
16
+ /** Content width of a box; its background stays full width. */
17
+ type ContainerSize = string;
18
+ /** Spacing scale step, 1 = 0.25rem (4px). */
19
+ type Spacing = 0 | 0.5 | 1 | 1.5 | 2 | 2.5 | 3 | 3.5 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 14 | 16 | 20 | 24 | 28 | 32 | 36 | 40 | 44 | 48 | 52 | 56 | 60 | 64 | 72 | 80 | 96;
20
+ /** Spacing step; negative pulls the box over its neighbour. */
21
+ type SignedSpacing = -96 | -80 | -72 | -64 | -56 | -48 | -40 | -32 | -28 | -24 | -20 | -16 | -12 | -10 | -8 | -6 | -4 | -3 | -2 | -1 | 0 | 0.5 | 1 | 1.5 | 2 | 2.5 | 3 | 3.5 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 14 | 16 | 20 | 24 | 28 | 32 | 36 | 40 | 44 | 48 | 52 | 56 | 60 | 64 | 72 | 80 | 96;
22
+ /** Corner radius token. */
23
+ type Radius = "none" | "sm" | "md" | "lg" | "xl" | "2xl" | "3xl" | "full";
24
+ /** Elevation token. */
25
+ type Shadow = "none" | "sm" | "md" | "lg" | "xl" | "2xl";
26
+ /** Named max width (Tailwind scale). */
27
+ type NamedWidth = "xs" | "sm" | "md" | "lg" | "xl" | "2xl" | "3xl" | "4xl" | "5xl" | "6xl" | "7xl" | "prose";
28
+ /** Share of the viewport height. */
29
+ type NamedHeight = "25vh" | "50vh" | "75vh" | "100vh";
30
+ /**
31
+ * CSS pixels.
32
+ * min 0, max 4000
33
+ */
34
+ type Px = number;
35
+ type MaxWidth = NamedWidth | Px;
36
+ type MinHeight = NamedHeight | Px;
37
+ type Size = "sm" | "md" | "lg" | "xl";
38
+ /**
39
+ * CSS hex color, e.g. #f5ede4.
40
+ * pattern ^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$
41
+ */
42
+ type Hex = string;
43
+ type Paint = Color | Hex;
44
+ /** min 0, max 1 */
45
+ type Opacity = number;
46
+ /**
47
+ * Blur radius in px.
48
+ * min 0
49
+ */
50
+ type Blur = number;
51
+ /** min 1, max 24 */
52
+ type Span = number;
53
+ /** min 0, max 100 */
54
+ type Percent = number;
55
+ /** min 1, max 600 */
56
+ type Seconds = number;
57
+ /**
58
+ * px
59
+ * min 1, max 8
60
+ */
61
+ type BorderWidth = number;
62
+ /** Inline SVG markup: one <svg> root, no scripts, handlers or root style. */
63
+ type Svg$1 = string;
64
+ /**
65
+ * Absolute http(s) URL, root-relative path, mailto:, tel:, #anchor, page:<id>[#anchor] (page in the current locale) or consent:settings (opens the cookie settings; needs a consent section in the site config).
66
+ * pattern ^(https?://|/(?!/)|#|mailto:|tel:|page:[a-z][a-z0-9-]*(#[a-z][a-z0-9_-]*)?$|consent:settings$)
67
+ */
68
+ type Url = string;
69
+ /**
70
+ * Element id, target of #anchor links.
71
+ * pattern ^[a-z][a-z0-9_-]*$
72
+ */
73
+ type Anchor = string;
74
+ /**
75
+ * Site path without locale prefix and trailing slash.
76
+ * pattern ^/([a-z0-9][a-z0-9._~-]*(/[a-z0-9][a-z0-9._~-]*)*)?$
77
+ */
78
+ type Path = string;
79
+ /**
80
+ * Fragment id.
81
+ * pattern ^[a-z][a-z0-9-]*$
82
+ */
83
+ type Ref = string;
84
+ /**
85
+ * width:height, e.g. 16:9.
86
+ * pattern ^[1-9][0-9]?:[1-9][0-9]?$
87
+ */
88
+ type AspectRatio = string;
89
+ /** cover | contain | fill stretch the asset; anchors keep its natural size. */
90
+ type BackgroundPosition = "cover" | "contain" | "fill" | "top-left" | "top" | "top-right" | "left" | "center" | "right" | "bottom-left" | "bottom" | "bottom-right";
91
+ type Corner = "top-left" | "top" | "top-right" | "left" | "center" | "right" | "bottom-left" | "bottom" | "bottom-right";
92
+ /** remote-video = YouTube / Vimeo URL. */
93
+ type AssetKind = "image" | "video" | "remote-video";
94
+ type LinkTarget = "_self" | "_blank";
95
+ type Align = "start" | "center" | "end" | "stretch";
96
+ type Justify = "start" | "center" | "end" | "between";
97
+ type TextAlign = "start" | "center" | "end" | "justify";
98
+ /** Shape of a box edge; cuts into the neighbour. */
99
+ type EdgeShape = "straight" | "wave" | "slant" | "curve";
100
+ type GradientKind = "linear" | "radial";
101
+ type Shape = "rect" | "rounded" | "circle";
102
+ type LineStyle = "solid" | "dashed" | "dotted";
103
+ /** Image or video. A root-relative url resolves against the configured asset base (e.g. an S3 bucket). */
104
+ interface Asset {
105
+ kind: AssetKind;
106
+ url: Url;
107
+ alt?: string;
108
+ width?: number;
109
+ height?: number;
110
+ /** Video preview image. */
111
+ poster?: Url;
112
+ }
113
+ interface Link {
114
+ url: Url;
115
+ label?: string;
116
+ target?: LinkTarget;
117
+ rel?: string;
118
+ }
119
+ /** Needs url or opens, unless the field holding it is marked actionOptional (e.g. a form submit). */
120
+ interface Button {
121
+ /** Visible text; with iconOnly the accessible name. */
122
+ label: string;
123
+ /** #anchor scrolls, e.g. to a form. */
124
+ url?: Url;
125
+ /** Fragment shown in a dialog; the page renders each dialog once. With an #anchor url the dialog is the fallback, used when the anchor is not on the page. */
126
+ opens?: Ref;
127
+ /** Show only the icon, e.g. a scroll-down chevron. */
128
+ iconOnly?: boolean;
129
+ variant?: ButtonVariant;
130
+ icon?: Svg$1;
131
+ size?: Size;
132
+ target?: LinkTarget;
133
+ rel?: string;
134
+ title?: string;
135
+ }
136
+ /** SVG or short text glyph (e.g. a step number). Needs svg or text. */
137
+ interface Icon {
138
+ svg?: Svg$1;
139
+ /** Glyph instead of an SVG, e.g. "1". */
140
+ text?: string;
141
+ color?: Paint;
142
+ /** Fills the shape behind the icon. */
143
+ background?: Paint;
144
+ shape?: Shape;
145
+ size?: Size;
146
+ }
147
+ interface Sides {
148
+ top?: Spacing;
149
+ right?: Spacing;
150
+ bottom?: Spacing;
151
+ left?: Spacing;
152
+ }
153
+ /** Negative only vertically (overlap with the block above / below). */
154
+ interface SignedSides {
155
+ top?: SignedSpacing;
156
+ right?: Spacing;
157
+ bottom?: SignedSpacing;
158
+ left?: Spacing;
159
+ }
160
+ /** Inside of the box: its children are stacked (before, content, after). */
161
+ interface BoxLayout {
162
+ /** Constrain the children to the page container; background stays full width. */
163
+ container?: ContainerSize;
164
+ /** Horizontal alignment of the children. */
165
+ alignX?: Align;
166
+ /** Vertical distribution of the children (needs height, e.g. minHeight). */
167
+ alignY?: Justify;
168
+ padding?: Responsive<Sides>;
169
+ /** Gap between the children. */
170
+ gap?: Responsive<Spacing>;
171
+ minHeight?: Responsive<MinHeight>;
172
+ /** Inherited by all text in the box. A text-align-* class on an element wins over it (unless a block documents otherwise). */
173
+ textAlign?: Responsive<TextAlign>;
174
+ /** Clip overflowing children, e.g. decorations. */
175
+ clip?: boolean;
176
+ }
177
+ /** Outside of the box: how it sits in its parent. */
178
+ interface Placement {
179
+ maxWidth?: Responsive<MaxWidth>;
180
+ /** Horizontal self-alignment, e.g. center a narrow block. */
181
+ x?: Responsive<Align>;
182
+ /** Vertical self-alignment in a row or cell. */
183
+ y?: Responsive<Align>;
184
+ margin?: Responsive<SignedSides>;
185
+ /** Only in slots whose block allows it (rule childPlace), e.g. grid tiles. */
186
+ colSpan?: Responsive<Span>;
187
+ /** Only in slots whose block allows it (rule childPlace), e.g. grid tiles. */
188
+ rowSpan?: Responsive<Span>;
189
+ }
190
+ interface GradientStop {
191
+ color: Paint;
192
+ /** Position of the stop. */
193
+ at?: Percent;
194
+ opacity?: Opacity;
195
+ }
196
+ interface Gradient {
197
+ kind: GradientKind;
198
+ /** Linear only, degrees; 180 = top to bottom. */
199
+ angle?: number;
200
+ /** Radial only. */
201
+ center?: Corner;
202
+ stops: GradientStop[];
203
+ }
204
+ /** Layers, back to front - base, asset, color overlay, gradients, content. */
205
+ interface Background {
206
+ /** Fill behind the asset (shows while it loads or where it is transparent). */
207
+ base?: Color;
208
+ /** Overlay color over the asset; with opacity a tint. */
209
+ color?: Paint;
210
+ asset?: Asset;
211
+ /** @default "cover" */
212
+ position?: BackgroundPosition;
213
+ /** Applies to the color overlay if set, else to the asset. */
214
+ opacity?: Opacity;
215
+ /** Blurs the asset. */
216
+ blur?: Blur;
217
+ /** First is on top. */
218
+ gradients?: Gradient[];
219
+ /** The asset scrolls slower than the page. */
220
+ parallax?: boolean;
221
+ }
222
+ interface Border {
223
+ width: BorderWidth;
224
+ color?: Paint;
225
+ style?: LineStyle;
226
+ }
227
+ /** Unset = block default. */
228
+ interface Appearance {
229
+ textColor?: Color;
230
+ rounded?: Radius;
231
+ shadow?: Shadow;
232
+ border?: Border;
233
+ }
234
+ interface Edges {
235
+ top?: EdgeShape;
236
+ bottom?: EdgeShape;
237
+ }
238
+ /** Graphic pinned to the box, e.g. an ornament overlapping its edge. Takes no space, never clipped by its own box; clipped by the nearest ancestor with layout.clip. */
239
+ interface Decoration {
240
+ svg: Svg$1;
241
+ anchor: Corner;
242
+ /** px from the anchored side; negative = outside the box. */
243
+ offsetX?: number;
244
+ /** px from the anchored side. */
245
+ offsetY?: number;
246
+ width?: Px;
247
+ visible?: Responsive<boolean>;
248
+ }
249
+ /** Override for Include.with. */
250
+ interface Slot {
251
+ /** Slot id in the fragment. */
252
+ slot: Anchor;
253
+ /** Replacement: any PageBlock-role block except Include; must be allowed where the slot sits (checked after substitution). */
254
+ block: PageBlock;
255
+ }
256
+ /** Locale = content folder. Pages with the same id in different locales are translations. */
257
+ interface Page$1 {
258
+ /** Translation id, shared across locales; target of page:<id> links. Unset = file name. */
259
+ id?: Ref;
260
+ title: string;
261
+ /** Meta description. */
262
+ description?: string;
263
+ /** Social preview image. */
264
+ image?: Asset;
265
+ noindex?: boolean;
266
+ /** URL path without the locale prefix, e.g. /meine-seite; / = home. */
267
+ path: Path;
268
+ /**
269
+ * false = no site header and footer.
270
+ * @default true
271
+ */
272
+ chrome?: boolean;
273
+ /** Header fragment. Unset = site default. */
274
+ header?: Ref;
275
+ /** Footer fragment. Unset = site default. */
276
+ footer?: Ref;
277
+ blocks: PageBlock[];
278
+ }
279
+ /** Reusable blocks, placed with Include (shared sections, header, footer). */
280
+ interface Fragment {
281
+ fragment: Ref;
282
+ title?: string;
283
+ blocks: PageBlock[];
284
+ }
285
+ /**
286
+ * Top-level block of a page or fragment.
287
+ * Role.
288
+ */
289
+ type PageBlock = Row | IncludeBlock;
290
+ /**
291
+ * Block that lays out Content side by side or in a grid.
292
+ * Role.
293
+ */
294
+ type Row = Content;
295
+ /**
296
+ * Block holding Leaf blocks, or a Leaf.
297
+ * Role.
298
+ */
299
+ type Content = Leaf;
300
+ /**
301
+ * Content block without block slots (text, media, card, …).
302
+ * Role.
303
+ */
304
+ type Leaf = never;
305
+ /**
306
+ * Block allowed in the surround slots (before / after) of any block.
307
+ * Role.
308
+ */
309
+ type Inline = never;
310
+ interface Box {
311
+ anchor?: Anchor;
312
+ /** In a fragment: id a page can replace via Include.with. */
313
+ slot?: Anchor;
314
+ layout?: BoxLayout;
315
+ place?: Placement;
316
+ background?: Background;
317
+ appearance?: Appearance;
318
+ edges?: Edges;
319
+ decorations?: Decoration[];
320
+ /** Per breakpoint, e.g. {base: false, lg: true}. Hides the whole block including before / after and background. */
321
+ visible?: Responsive<boolean>;
322
+ }
323
+ interface Surround {
324
+ before?: Inline[];
325
+ after?: Inline[];
326
+ }
327
+ interface Linkable {
328
+ /** Makes the whole block clickable. */
329
+ link?: Link;
330
+ }
331
+ /**
332
+ * Places a fragment's blocks here.
333
+ * Roles: PageBlock.
334
+ */
335
+ interface IncludeBlock {
336
+ type: "Include";
337
+ ref: Ref;
338
+ /** Per-page content for slots of the fragment: a block with the same slot id is replaced. */
339
+ with?: Slot[];
340
+ }
341
+ interface BlockMap {}
342
+ type BlockType = keyof BlockMap;
343
+ type AnyBlock = BlockMap[BlockType];
344
+ type LayoutDocument = Page$1 | Fragment;
345
+ //#endregion
346
+ //#region src/render.d.ts
347
+ interface PageData {
348
+ locale: string;
349
+ alternates: Record<string, string>;
350
+ homes: Record<string, string>;
351
+ header: BlockLike[];
352
+ blocks: BlockLike[];
353
+ footer: BlockLike[];
354
+ /**
355
+ * Dialogs the page opens (fragment ref → blocks), from the loader. Each is
356
+ * rendered once after the footer, however many buttons open it.
357
+ */
358
+ dialogs?: Record<string, BlockLike[]>;
359
+ /** Consent texts and config (site config `consent`), for gates. */
360
+ consent?: PageConsent | undefined;
361
+ }
362
+ /** Where a rendered block is authored (the loader's source map entry). */
363
+ interface BlockSource {
364
+ file: string;
365
+ path: string;
366
+ via?: {
367
+ file: string;
368
+ path: string;
369
+ }[];
370
+ }
371
+ /** Props of an adapter's boundary around each block (e.g. a client error boundary). */
372
+ interface BoundaryProps {
373
+ type: string;
374
+ path: string;
375
+ revision: number | undefined;
376
+ /** What to show when the block fails. */
377
+ fallback: ReactNode;
378
+ children: ReactNode;
379
+ }
380
+ /** Annotate mode: what the edit service knows about the rendered page. */
381
+ interface Annotation {
382
+ /** Revision the page shows (stamped on <main>). */
383
+ revision?: number;
384
+ /** Rendered path → authored location: block keys. */
385
+ sources?: Record<string, BlockSource>;
386
+ /** Rendered path → findings: blocks with errors render as placeholders. */
387
+ findings?: Record<string, {
388
+ level: string;
389
+ message: string;
390
+ at?: string;
391
+ }[]>;
392
+ /** Editor origins the page's bridge talks to; without: no bridge. */
393
+ editorOrigins?: string[];
394
+ /** Adapter boundary around each block, e.g. a client error boundary. */
395
+ boundary?: ComponentType<BoundaryProps>;
396
+ }
397
+ interface RenderOptions {
398
+ registry: Registry;
399
+ breakpoints: string[];
400
+ /** Edit mode annotation (rendered paths, revision, keys, boundaries, bridge). */
401
+ annotate?: boolean | Annotation | undefined;
402
+ /** @deprecated Alias of `annotate: true` (one release). */
403
+ inspect?: boolean | undefined;
404
+ }
405
+ /** Script element with the page data in annotate mode. */
406
+ export declare const PAGE_DATA_ID = "wc-page";
407
+ /** @deprecated Use PAGE_DATA_ID. */
408
+ export declare const INSPECT_ID = "wc-page";
409
+ /** Context for a page: render() resolves blocks through the registry. */
410
+ export declare function createContext(page: Pick<PageData, "locale" | "alternates" | "homes" | "consent">, opts: RenderOptions): RenderContext;
411
+ export declare function Blocks({ blocks, ctx, keyPrefix, priority }: {
412
+ blocks: BlockRef | readonly BlockRef[] | undefined;
413
+ ctx: RenderContext;
414
+ keyPrefix?: string | undefined;
415
+ /**
416
+ * The first block gets `ctx.priority` (its background image loads at
417
+ * once, with high priority), unless it is hidden at some breakpoint: an
418
+ * eager image loads even where it is not shown. Page sets it for main.
419
+ */
420
+ priority?: boolean | undefined;
421
+ }): ReactNode;
422
+ export declare function Block({ block, ctx }: {
423
+ block: BlockLike;
424
+ ctx: RenderContext;
425
+ }): ReactNode;
426
+ /** Language switch data: locale → url of the translation, else the locale home. */
427
+ export declare function languageLinks(ctx: Pick<RenderContext, "alternates" | "homes">): Record<string, {
428
+ url: string;
429
+ translated: boolean;
430
+ }>;
431
+ /** A full page: header, main content, footer. */
432
+ export declare function Page({ page, ...opts }: {
433
+ page: PageData;
434
+ } & RenderOptions): import("react").JSX.Element;
435
+ //#endregion
436
+ //#region src/registry.d.ts
437
+ /** Context passed to every block component. */
438
+ interface RenderContext {
439
+ locale: string;
440
+ /** Same page in other locales: locale → url. */
441
+ alternates: Record<string, string>;
442
+ /** Locale homes: locale → url. */
443
+ homes: Record<string, string>;
444
+ registry: Registry;
445
+ /** Theme breakpoints, ascending, e.g. ["base", "md", "lg"]. */
446
+ breakpoints: string[];
447
+ /** Renders child blocks, e.g. the slots of a block (any generated block type). */
448
+ render: (blocks: BlockRef | readonly BlockRef[] | undefined, key?: string) => ReactNode;
449
+ /** Annotate mode: block → rendered path, e.g. "blocks/2/start". */
450
+ paths?: WeakMap<object, string>;
451
+ /** Annotate mode: rendered path of the block being rendered. */
452
+ path?: string | undefined;
453
+ /** Annotate mode: revision, sources, findings, boundary. */
454
+ annotation?: Annotation;
455
+ /** Consent texts and config of the page (site config `consent`); unset = none. */
456
+ consent?: PageConsent | undefined;
457
+ /**
458
+ * The block being rendered is the page's first (`Blocks` with
459
+ * `priority`): its background image loads at once, with high priority
460
+ * (likely the largest contentful paint). Never set for child blocks:
461
+ * `render` renders them without it.
462
+ */
463
+ priority?: boolean | undefined;
464
+ }
465
+ type BlockLike = {
466
+ type: string;
467
+ [k: string]: unknown;
468
+ };
469
+ /** Any block value, e.g. a generated TextBlock or a role union like Content. */
470
+ type BlockRef = {
471
+ readonly type: string;
472
+ };
473
+ interface BlockProps<B> {
474
+ block: B;
475
+ ctx: RenderContext;
476
+ }
477
+ type BlockComponent<B = BlockLike> = ComponentType<BlockProps<B>>;
478
+ type Components<M> = { [K in keyof M]: BlockComponent<M[K]>; };
479
+ interface Registry {
480
+ components: Record<string, BlockComponent>;
481
+ }
482
+ /**
483
+ * Marks a block component that renders its box itself:
484
+ *
485
+ * export const Buttons = ownBox(function Buttons({ block, ctx }) {
486
+ * return <BoxFrame block={block} ctx={ctx} flat>…</BoxFrame>;
487
+ * });
488
+ */
489
+ export declare function ownBox<C extends object>(component: C): C;
490
+ export declare function hasOwnBox(component: object): boolean;
491
+ /** Registry from a component map (usually the generated one, possibly with overrides). */
492
+ export declare function createRegistry<M extends object>(components: Components<M>): Registry;
493
+ //#endregion
494
+ //#region src/box.d.ts
495
+ interface Box$1 {
496
+ anchor?: string;
497
+ layout?: BoxLayout;
498
+ place?: Placement;
499
+ background?: Background;
500
+ appearance?: {
501
+ textColor?: string;
502
+ rounded?: string;
503
+ shadow?: string;
504
+ border?: {
505
+ width: number;
506
+ color?: string;
507
+ style?: string;
508
+ };
509
+ };
510
+ edges?: {
511
+ top?: string;
512
+ bottom?: string;
513
+ };
514
+ decorations?: Decoration[];
515
+ visible?: Resp$1<boolean>;
516
+ before?: BlockLike[];
517
+ after?: BlockLike[];
518
+ link?: {
519
+ url: string;
520
+ label?: string;
521
+ target?: string;
522
+ rel?: string;
523
+ };
524
+ }
525
+ interface FrameProps {
526
+ block: BlockLike & Box$1;
527
+ ctx: RenderContext;
528
+ children: ReactNode;
529
+ /** Classes for the inner element, e.g. grid classes of Tiles. */
530
+ innerClass?: string | undefined;
531
+ innerStyle?: CSSProperties;
532
+ /** Extra outer classes, e.g. a card's flex column. */
533
+ outerClass?: string | undefined;
534
+ /** Element for the outer box, e.g. "section". */
535
+ as?: "div" | "section" | "header" | "footer" | "nav" | "article";
536
+ /** Blocks without layout of their own (value-like leaves) skip the inner wrapper. */
537
+ flat?: boolean;
538
+ }
539
+ /** Renders a block's box (Box, Surround and Linkable traits) around its content. */
540
+ export declare function BoxFrame({ block, ctx, children, innerClass, innerStyle, outerClass, as, flat }: FrameProps): import("react").JSX.Element;
541
+ /** Default box: wraps a component that renders only the inside. */
542
+ export declare function withBox<B>(Inner: BlockComponent<B>): BlockComponent<B>;
543
+ /** Token → class, hex → inline style. */
544
+ export declare function paint(c: Classes$1, kind: "bg" | "text" | "border", v: string | undefined): void;
545
+ /** CSS color value of a Paint (token → theme variable). */
546
+ export declare function cssColor(v: string | undefined, opacity?: number): string | undefined;
547
+ export declare function gradientCss(g: Gradient): string;
548
+ //#endregion
549
+ //#region src/consent.d.ts
550
+ /** The stored choice: category id → granted. */
551
+ type ConsentChoice = Record<string, boolean>;
552
+ /** window.wcConsent, set by the consent script. */
553
+ interface ConsentApi {
554
+ /** The stored choice, null while the visitor has not decided. */
555
+ get(): ConsentChoice | null;
556
+ /** Stores the full choice (missing categories: refused) and applies it. */
557
+ set(choice: ConsentChoice): void;
558
+ /** Grants one category, merged into the stored choice. */
559
+ grant(category: string): void;
560
+ /** Opens the settings dialog with the stored choice. */
561
+ open(): void;
562
+ /** Called on every change; returns the unsubscribe function. */
563
+ onChange(fn: (choice: ConsentChoice, previous: ConsentChoice | null) => void): () => void;
564
+ }
565
+ /** Detail of the `wc-consent` event on document. */
566
+ interface ConsentEventDetail {
567
+ choice: ConsentChoice;
568
+ previous: ConsentChoice | null;
569
+ }
570
+ /** DOM event fired on document on every consent change. */
571
+ export declare const CONSENT_EVENT = "wc-consent";
572
+ /** Labels of a gate; `{vendor}` is filled in. */
573
+ type GateLabels = Partial<GateData["text"]>;
574
+ /**
575
+ * Third-party content behind consent, for project blocks (e.g. an iframe
576
+ * Embed). Without a consent config the content renders directly.
577
+ */
578
+ export declare function ConsentGate({ ctx, category, vendor, fallback, labels, poster, className, children }: {
579
+ ctx: Pick<RenderContext, "consent">;
580
+ /** Consent category the content needs, e.g. "media". */
581
+ category: string;
582
+ /** Who receives data when it loads, e.g. "Google Kalender". */
583
+ vendor: string;
584
+ /** Link to the original, opened in a new tab. */
585
+ fallback: string;
586
+ labels?: GateLabels;
587
+ /**
588
+ * Preview image, shown before consent: only a root-relative url (the
589
+ * site itself); others are ignored, so no vendor sees the visit.
590
+ */
591
+ poster?: string | undefined;
592
+ /** Classes of the gate's box (size it like the content). */
593
+ className?: string | undefined;
594
+ /** What loads after consent. */
595
+ children: ReactNode;
596
+ }): import("react").JSX.Element;
597
+ /**
598
+ * Head part of the consent script for a page: first in <head>, before any
599
+ * other script. `extraHosts` extend the hosts where tags load (tests:
600
+ * localhost; never production).
601
+ */
602
+ export declare function consentHeadScript(consent: PageConsent, extraHosts?: string[]): string;
603
+ /** Body part of the consent script, after the banner and the settings dialog. */
604
+ export declare const consentScript = "(function(){const l=window,o=document,f=l.__wcConsent;if(!f||l.wcConsent)return;const s=f.config,d=Object.keys(s.categories),h=o.getElementById(\"wc-consent-banner\"),i=o.getElementById(\"wc-consent-settings\"),m=new Set;let c=f.choice,u=null;const g=t=>t?{...t}:null,v=t=>Object.fromEntries(d.map(e=>[e,t?.[e]===!0])),C=t=>Object.fromEntries(d.flatMap(e=>s.categories[e].map(n=>[n,t[e]?\"granted\":\"denied\"]))),S=t=>{const e=[],n=s.categories[t]||[];return n.includes(\"analytics_storage\")&&e.push(/^_ga($|_)/),n.includes(\"ad_storage\")&&e.push(/^_gcl_/),s.meta?.category===t&&e.push(/^_fb[pc]$/),e},M=t=>{const e=t.flatMap(S),n=location.hostname.split(\".\"),a=[\"\"];for(let r=0;r<n.length-1;r++)a.push(`; domain=.${n.slice(r).join(\".\")}`);for(const r of o.cookie.split(\";\")){const w=r.split(\"=\")[0].trim();if(w&&e.some(b=>b.test(w)))for(const b of a)o.cookie=`${w}=; Max-Age=0; path=/${b}`}},E=()=>{if(!s.meta||!f.allowed||l.fbq)return;const t=function e(){const n=arguments;e.callMethod?e.callMethod.apply(e,n):e.queue.push(n)};l.fbq=t,l._fbq=l._fbq||t,t.push=t,t.loaded=!0,t.version=\"2.0\",t.queue=[],f.later(()=>{const e=o.createElement(\"script\");e.async=!0,e.src=\"https://connect.facebook.net/en_US/fbevents.js\",o.head.appendChild(e)}),t(\"init\",s.meta.id),t(\"track\",\"PageView\")},q=t=>{const e=t.querySelector(\"template[data-wc-consent-content]\");e&&t.replaceWith(e.content.cloneNode(!0))},k=()=>{for(const t of o.querySelectorAll(\"[data-wc-consent-gate]\"))c?.[t.getAttribute(\"data-wc-consent-gate\")]&&q(t)},j=()=>{d.some(t=>s.categories[t].length)&&l.gtag(\"consent\",\"update\",C(c)),s.meta&&c[s.meta.category]&&E(),k()},p=t=>{const e=c;c=v(t);try{localStorage.setItem(s.key,JSON.stringify({v:s.version,t:Date.now(),c}))}catch{}h&&(h.hidden=!0),j();const n={choice:g(c),previous:g(e)};o.dispatchEvent(new CustomEvent(\"wc-consent\",{detail:n}));for(const r of m)try{r(g(c),g(e))}catch(w){console.error(w)}const a=e?d.filter(r=>e[r]&&!c[r]):[];a.length&&(M(a),location.reload())},y=()=>{if(i){for(const t of i.querySelectorAll(\"input[data-wc-consent-category]\"))t.checked=c?.[t.getAttribute(\"data-wc-consent-category\")]===!0;u=o.activeElement,i.open||i.showModal()}},O=()=>{i?.open&&i.close()};i?.addEventListener(\"keydown\",t=>{if(t.key!==\"Tab\")return;const e=[...i.querySelectorAll(\"a[href], button, input:not([disabled])\")],n=e[0],a=e[e.length-1];t.shiftKey&&o.activeElement===n?(t.preventDefault(),a.focus()):!t.shiftKey&&o.activeElement===a&&(t.preventDefault(),n.focus())}),i?.addEventListener(\"close\",()=>{u?.isConnected&&u.offsetParent!==null&&u.focus(),u=null});const _=t=>Object.fromEntries(d.map(e=>[e,t])),D={accept:()=>p(_(!0)),reject:()=>p(_(!1)),save:()=>{const t={};for(const e of i.querySelectorAll(\"input[data-wc-consent-category]\"))t[e.getAttribute(\"data-wc-consent-category\")]=e.checked;p(t)},settings:y,close:()=>{}};o.addEventListener(\"click\",t=>{const e=t.target instanceof Element?t.target:null,n=e?.closest(\"[data-wc-consent-action]\");if(n){t.preventDefault();const r=D[n.getAttribute(\"data-wc-consent-action\")];n.closest(\"#wc-consent-settings\")&&O(),r?.();return}if(e?.closest('[data-wc-consent-open], a[href=\"#wc-consent-settings\"]')){t.preventDefault(),y();return}const a=e?.closest(\"[data-wc-consent-gate]\");a&&e.closest(\"[data-wc-consent-load]\")?q(a):a&&e.closest(\"[data-wc-consent-allow]\")&&l.wcConsent.grant(a.getAttribute(\"data-wc-consent-gate\"))}),l.wcConsent={get:()=>g(c),set:p,grant:t=>p({...v(c),[t]:!0}),open:y,onChange:t=>(m.add(t),()=>m.delete(t))},!c&&h&&(h.hidden=!1);const A=()=>{for(const t of o.querySelectorAll(\"[data-wc-consent-actions]\"))t.hidden=!1;c&&(s.meta&&c[s.meta.category]&&E(),k())};o.readyState===\"loading\"?o.addEventListener(\"DOMContentLoaded\",A):A()})()";
605
+ //#endregion
606
+ //#region src/elements.d.ts
607
+ /** Options of a media element (e.g. the fields of a Media block). */
608
+ interface MediaOptions {
609
+ asset: Asset;
610
+ /** "16:9": crop to ratio. Unset = natural size. */
611
+ aspectRatio?: string | undefined;
612
+ fit?: "cover" | "contain" | undefined;
613
+ /** Cover the whole parent height. */
614
+ fill?: boolean | undefined;
615
+ rounded?: string | undefined;
616
+ shadow?: string | undefined;
617
+ /** Video only. false = muted autoplaying loop without controls. */
618
+ controls?: boolean | undefined;
619
+ loop?: boolean | undefined;
620
+ muted?: boolean | undefined;
621
+ play?: string | undefined;
622
+ }
623
+ /** Image, video or remote video (YouTube / Vimeo) of an Asset. */
624
+ export declare function MediaElement({ block }: {
625
+ block: MediaOptions;
626
+ }): import("react").JSX.Element;
627
+ /**
628
+ * YouTube / Vimeo embed (privacy-enhanced YouTube host). With `consent`
629
+ * (the loader sets it on remote videos of a site with consent) a consent
630
+ * gate stands in until the media category is granted.
631
+ */
632
+ export declare function RemoteVideo({ url, title, className, consent }: {
633
+ url: string;
634
+ title: string | undefined;
635
+ className: string;
636
+ /** Gate data (vendor, texts, site-owned poster) from the loader. */
637
+ consent?: GateData | undefined;
638
+ }): import("react").JSX.Element;
639
+ /**
640
+ * Button: a link styled by theme CSS via `.wc-button[data-variant]`.
641
+ * `opens` toggles the page's popover with the fragment (no client JS). The
642
+ * page renders each dialog once (see Page); the loader has already decided
643
+ * between an #anchor url and its dialog (Button.opens as fallback).
644
+ * `url: consent:settings` renders a button the consent script answers by
645
+ * opening the consent settings (same look as the other buttons).
646
+ * Theme extensions of Button render through `children` (extra label
647
+ * content, e.g. a subtitle) and `attrs` (e.g. data-* for analytics).
648
+ */
649
+ export declare function ButtonEl({ button: b, className, children, attrs }: {
650
+ button: Button;
651
+ /** Not needed by the element; accepted so components pass it uniformly. */
652
+ ctx?: RenderContext;
653
+ className?: string | undefined;
654
+ /** Extra label content after the label text, e.g. a subtitle. */
655
+ children?: ReactNode;
656
+ /** Extra attributes on the link / button element. */
657
+ attrs?: Record<string, string | undefined>;
658
+ }): import("react").JSX.Element;
659
+ /** Element id of the dialog showing a fragment. */
660
+ export declare function dialogId(ref: string): string;
661
+ /** Icon: SVG or text glyph, sized by Icon.size, optional shape behind it. */
662
+ export declare function IconEl({ icon }: {
663
+ icon: Icon;
664
+ }): import("react").JSX.Element;
665
+ //#endregion
666
+ //#region src/html.d.ts
667
+ export declare function RichText({ html, className }: {
668
+ html: string | undefined;
669
+ className?: string;
670
+ }): import("react").JSX.Element | null;
671
+ export declare function Svg({ svg, className, style }: {
672
+ svg: string | undefined;
673
+ className?: string;
674
+ style?: CSSProperties;
675
+ }): import("react").JSX.Element | null;
676
+ //#endregion
677
+ //#region src/images.d.ts
678
+ /**
679
+ * An image Asset as the loader resolves it with responsive images; a cover
680
+ * background of the first block may also have its `portrait` center crop.
681
+ */
682
+ type ImageAsset = Asset & {
683
+ srcset?: ImageCandidate[] | undefined;
684
+ portrait?: ImageCandidate | undefined;
685
+ };
686
+ /**
687
+ * The url for a video's `poster` attribute: the loader's `posterSrc` (e.g.
688
+ * an image server's converted, width-capped copy), else the original.
689
+ */
690
+ export declare function posterOf(asset: Asset): string | undefined;
691
+ /** Where a cover background shows its `portrait` crop: phones held upright, whose hero box is tall. */
692
+ export declare const PORTRAIT_MEDIA = "(orientation: portrait) and (max-width: 767px)";
693
+ /** The box an image is drawn in (what its CSS fixes). */
694
+ interface ImageBox {
695
+ /** CSS width in `unit`; unset: unknown (sizes "auto, 100vw"). */
696
+ width?: number | undefined;
697
+ /** CSS height in `unit`. */
698
+ height?: number | undefined;
699
+ /**
700
+ * Unit of width and height: "rem" for boxes sized in rem (Tailwind's
701
+ * `size-14`, `h-12`), so they follow the user's default font size.
702
+ * Default "px".
703
+ */
704
+ unit?: "px" | "rem" | undefined;
705
+ /** Box aspect ratio (width / height), e.g. of a 16:9 crop; width and height imply it. */
706
+ ratio?: number | undefined;
707
+ /**
708
+ * `object-fit` in a box whose shape the CSS fixes. Unset: the box takes
709
+ * its shape from the image (`h-auto` with a width, `w-auto` with a height).
710
+ */
711
+ fit?: "cover" | "contain" | "fill" | undefined;
712
+ }
713
+ /** Width / height. */
714
+ export declare function ratioOf(size: ImageSize): number;
715
+ /**
716
+ * How much wider than its box `object-fit: cover` draws an image of `size`
717
+ * in a box of `boxRatio` (width / height): 1 if the height limits it.
718
+ */
719
+ export declare function coverScale(size: ImageSize, boxRatio: number): number;
720
+ /** Real pixel size of an image Asset: its original (last srcset entry), else its width / height. */
721
+ export declare function imageSize(asset: ImageAsset): ImageSize | undefined;
722
+ /**
723
+ * `srcSet` of only the full-size candidate (the original's pixels, e.g. as
724
+ * AVIF / WebP from an image server), for an image whose drawn width is
725
+ * unknown: the browser takes it over `src` at every density. Empty when it
726
+ * is the original itself.
727
+ */
728
+ export declare function fullSrcSet(asset: ImageAsset): {
729
+ srcSet?: string;
730
+ };
731
+ /**
732
+ * `srcSet` and `sizes` for an image drawn in `box`; empty when the asset
733
+ * has no copies or none is safe to offer (the img keeps its `src`).
734
+ */
735
+ export declare function imageSrcSet(asset: ImageAsset, box?: ImageBox, opts?: {
736
+ /** The img loads eagerly (no `loading="lazy"`): no `sizes="auto"`. */
737
+ eager?: boolean | undefined;
738
+ }): {
739
+ srcSet?: string;
740
+ sizes?: string;
741
+ };
742
+ //#endregion
743
+ export { type Align, type Anchor, type Annotation, type AnyBlock, type Appearance, type AspectRatio, type Asset, type AssetKind, BASE, type Background, type BackgroundPosition, type BlockComponent, type BlockLike, type BlockMap, type BlockProps, type BlockRef, type BlockSource, type BlockType, type Blur, type Border, type BorderWidth, type BoundaryProps, type Box, type BoxLayout, type Breakpoint, type Button, type ButtonVariant, Classes, type Color, type Components, type ConsentApi, type ConsentChoice, type ConsentEventDetail, type ContainerSize, type Content, type Corner, type Decoration, type EdgeShape, type Edges, type Fragment, type FrameProps, type GateLabels, type Gradient, type GradientKind, type GradientStop, type Hex, type Icon, type ImageAsset, type ImageBox, type IncludeBlock, type Inline, type Justify, type LayoutDocument, type Leaf, type LineStyle, type Link, type LinkTarget, type Linkable, type MaxWidth, type MediaOptions, type MinHeight, type NamedHeight, type NamedWidth, type Opacity, type PageBlock, type PageData, type Paint, type Path, type Percent, type Placement, type Px, type Radius, type Ref, type Registry, type RenderContext, type RenderOptions, type Resp, type Responsive, type Row, type Seconds, type Shadow, type Shape, type Sides, type SignedSides, type SignedSpacing, type Size, type Slot, type Spacing, type Span, type Surround, type TextAlign, type Url, at, tw };