@charisol/plexo-sdk 2.0.4 → 2.0.6

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.
@@ -29,9 +29,17 @@ export interface BuiltPage {
29
29
  tree: HNode;
30
30
  css: string;
31
31
  usesRuntime: boolean;
32
+ /** Every font family the page uses (Google, uploaded or otherwise), by name. */
32
33
  fonts: string[];
34
+ /** Stylesheet addresses for the Google Fonts the page uses (only those families, only the weights they have). Empty when none. */
35
+ fontLinks: string[];
33
36
  warnings: string[];
34
37
  }
38
+ /**
39
+ * A plain CSS gradient (`linear-gradient(135deg, var(--a), #fff 40%)`): only letters, digits, spaces and the few characters a
40
+ * gradient needs, with nothing that could fetch a file or end the declaration, and balanced brackets.
41
+ */
42
+ export declare function safeGradient(v: string): boolean;
35
43
  /**
36
44
  * Turns one page into markup and CSS. This is the single compile step both outputs share (HTML and React print the
37
45
  * same tree), and it is where the visible canvas of each screen is enforced:
@@ -41,4 +49,5 @@ export interface BuiltPage {
41
49
  * - the same box model and constraints the editor uses (computeNodeCss) decide where everything lands.
42
50
  */
43
51
  export declare function buildPage(page: PageDefinition, opts?: CompileOptions): BuiltPage;
52
+ /** @deprecated use `BuiltPage.fontLinks` (one address per family group, with the right weights). Kept for older callers: the first Google Fonts address, or null. */
44
53
  export declare function googleFontsHref(fonts: string[]): string | null;
@@ -8,6 +8,14 @@ export interface CompiledHtml {
8
8
  css: string;
9
9
  /** The optional runtime as a script body ('' when the page doesn't need one or `runtime: 'none'`). */
10
10
  script: string;
11
+ /**
12
+ * `<link>` tags for the page's web fonts (preconnect + one stylesheet per Google Fonts group, with only the families and
13
+ * weights used and `display=swap`); '' when the page uses none. A host that places `html` + `css` in its own page puts this
14
+ * in that page's `<head>`. Fonts the owner uploaded need nothing here: their `@font-face` rules are already at the top of `css`.
15
+ */
16
+ head: string;
17
+ /** The same stylesheet addresses as plain strings (for hosts that build their own head). */
18
+ fontLinks: string[];
11
19
  /** A complete standalone document with all of the above (fonts included). */
12
20
  document: string;
13
21
  /** Things the owner should fix, in plain words (e.g. a form with nowhere to send messages). */
@@ -21,11 +21,17 @@ export interface SanitizeV2Options {
21
21
  allowEmbedScripts?: boolean;
22
22
  /** Extra inline `<script>` bodies to keep, matched byte for byte (e.g. the owner's custom code the host vetted). */
23
23
  allowedScripts?: string[];
24
+ /**
25
+ * https origins where the site's own uploaded fonts live (e.g. `https://cdn.example.com`), so `@font-face` may load from them.
26
+ * Without this, a font file may only come from Google Fonts (fonts.gstatic.com), the site's own paths (`/fonts/x.woff2`) or an
27
+ * embedded `data:font/…` address — never from anywhere else.
28
+ */
29
+ fontOrigins?: string[];
24
30
  }
25
31
  /**
26
32
  * Keeps the parts of a stylesheet (or a `style=""` declaration list) that are safe, and everything else byte for byte.
27
33
  * Rules and declarations that could run script or fetch from somewhere strange are removed whole.
28
34
  */
29
- export declare function sanitizeCss(css: string): string;
35
+ export declare function sanitizeCss(css: string, opts?: Pick<SanitizeV2Options, 'fontOrigins'>): string;
30
36
  /** Sanitises V2 compiler output (a fragment or a whole document) with an allow-list. See the file header. */
31
37
  export declare function sanitizeV2Html(html: string, opts?: SanitizeV2Options): string;
@@ -0,0 +1,2 @@
1
+ /** Makes the fonts a design uses (Google's and the owner's own) available to the editor canvas. Renders nothing. */
2
+ export declare const EditorFonts: () => null;
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ /** The name to show for a stored value: a stack ("'Inter', ui-sans-serif…") or a bare name. */
3
+ export declare const fontNameOf: (value: string | undefined) => string;
4
+ /**
5
+ * One font picker for everything: search, every family shown in its own letters, grouped the way people think about type
6
+ * (Your fonts, Popular, Serif, Sans serif…), and — when the host can store files — "Add a font" to use the brand's own.
7
+ * `onChange` gets the CSS font stack to store (`'Inter', ui-sans-serif, …`); `value` can be a stack or a bare name.
8
+ */
9
+ export declare const FontPicker: React.FC<{
10
+ value: string | undefined;
11
+ onChange: (stack: string, name: string) => void;
12
+ label?: string;
13
+ placeholder?: string;
14
+ className?: string;
15
+ }>;
@@ -0,0 +1,13 @@
1
+ import { type CustomFont } from '../../design/customFonts';
2
+ import { type FontRequest } from '../../design/fonts';
3
+ import type { DesignSystem } from '../../design/types';
4
+ import type { DocumentNode } from '../../types/editor';
5
+ export declare function addStylesheet(href: string): void;
6
+ /** The picker shows each family in its own letters; this loads just those letters for one family. */
7
+ export declare function loadFontPreview(family: string): void;
8
+ /** Every font family a design uses: text elements' own fonts and the design system's font tokens. */
9
+ export declare function familiesInUse(root: DocumentNode, ds: DesignSystem): FontRequest[];
10
+ /** Loads the Google fonts a design uses into the editor. Uploaded fonts are handled by `syncCustomFonts`. */
11
+ export declare function loadFontsInUse(root: DocumentNode, ds: DesignSystem): void;
12
+ /** Keeps one `<style>` of `@font-face` rules for the owner's uploaded fonts in step with the design system. */
13
+ export declare function syncCustomFonts(fonts: CustomFont[] | undefined): void;
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import type { DocumentNode } from '../../types/editor';
3
+ /**
4
+ * Font, weight, size and line height of a text element. The numbers are what the text really is on this screen — an H1 shows
5
+ * its heading size, not a made-up 16 — and changing one starts from there. Choosing a level (H1–H6) moves the size with it,
6
+ * until the person types a size of their own (then a small "reset" brings the design's size back).
7
+ */
8
+ export declare const TypeControls: React.FC<{
9
+ node: DocumentNode;
10
+ }>;
@@ -6,7 +6,7 @@ export declare function designSystemVars(ds: DesignSystem): Record<string, strin
6
6
  export declare function plexoVars(ds: DesignSystem, viewport: ViewportMode): Record<string, string>;
7
7
  /** What the editor's frame for one screen size sets, so every element on it resolves tokens the way the published page will. */
8
8
  export declare function frameVars(ds: DesignSystem, viewport: ViewportMode): Record<string, string>;
9
- /** Google Fonts a page needs: the families behind the font tokens it uses, minus system fonts. */
9
+ /** Font families (Google or uploaded) a page needs: the families behind the font tokens it uses, minus system fonts. */
10
10
  export declare function fontsNeeded(ds: DesignSystem, css: string): string[];
11
11
  /**
12
12
  * The design system as CSS for a published page: only the variables the page uses (a page doesn't ship Strata's whole
@@ -0,0 +1,49 @@
1
+ import type { DesignSystem } from './types';
2
+ /**
3
+ * Fonts a site owner uploaded. They live in the design system (so they are saved with the site, shared by every page and
4
+ * synced nowhere else): a family name, and for each look of it (weight, italic) the address of the font file. The SDK never
5
+ * uploads anything itself — the host's `onUploadFont` stores the file and hands back its address.
6
+ */
7
+ export type CustomFontFormat = 'woff2' | 'woff' | 'truetype' | 'opentype';
8
+ export interface CustomFontVariant {
9
+ /** 100–900 in steps of 100. */
10
+ weight: number;
11
+ style: 'normal' | 'italic';
12
+ /** Where the file lives: an https address, a path on the site, or (for tiny test fonts) an embedded `data:` address. */
13
+ url: string;
14
+ format: CustomFontFormat;
15
+ }
16
+ export interface CustomFont {
17
+ /** What the font is called in the picker and in the page's CSS. Letters, digits and spaces only. */
18
+ family: string;
19
+ variants: CustomFontVariant[];
20
+ }
21
+ /** Limits that keep a hand-edited or AI-written design from bloating a page. */
22
+ export declare const MAX_CUSTOM_FONTS = 12;
23
+ export declare const MAX_FONT_VARIANTS = 12;
24
+ export declare const MAX_FONT_URL = 2000;
25
+ /** A `data:` font is stored inside the design, so it is kept small (about 400 KB of font). */
26
+ export declare const MAX_FONT_DATA_URL = 560000;
27
+ /** The biggest font file the editor accepts. */
28
+ export declare const MAX_FONT_FILE_BYTES = 3000000;
29
+ export declare const FONT_FILE_ACCEPT = ".woff2,.woff,.ttf,.otf,font/woff2,font/woff,font/ttf,font/otf";
30
+ /** Is this an address a font may load from: https, a path on the site, or an embedded font? (No quotes, brackets or spaces ever.) */
31
+ export declare function isFontUrl(url: unknown): url is string;
32
+ /** Cleans untrusted custom-font data: bad entries are dropped, extras are cut, duplicates merged. Always returns a safe list. */
33
+ export declare function sanitizeCustomFonts(input: unknown): CustomFont[];
34
+ export declare const customFontsOf: (ds: Pick<DesignSystem, "fonts"> | undefined) => CustomFont[];
35
+ export declare const findCustomFont: (fonts: CustomFont[] | undefined, family: string) => CustomFont | undefined;
36
+ /** Adds one look of a family (creating the family if needed) — what happens after an upload. Replaces a look with the same weight and style. */
37
+ export declare function addCustomFont(ds: DesignSystem, family: string, variant: CustomFontVariant): DesignSystem;
38
+ export declare function removeCustomFont(ds: DesignSystem, family: string): DesignSystem;
39
+ /** `@font-face` rules (with `font-display: swap`) for the custom families in `used` (lower-case names), or all of them when `used` is omitted. */
40
+ export declare function customFontFaceCss(fonts: CustomFont[] | undefined, used?: ReadonlySet<string>): string;
41
+ export interface GuessedFont {
42
+ family: string;
43
+ weight: number;
44
+ style: 'normal' | 'italic';
45
+ format: CustomFontFormat | null;
46
+ }
47
+ /** Best guess of a font's name, weight, style and kind of file from its file name ("Brandon-Bold-Italic.woff2"), so the owner mostly just confirms. */
48
+ export declare function guessFontFromFile(fileName: string, mimeType?: string): GuessedFont;
49
+ export declare const WEIGHT_LABELS: Record<number, string>;
@@ -1,10 +1,44 @@
1
- /** Fonts offered in the picker: a short, good list, each with a sensible fallback stack. */
1
+ /**
2
+ * Fonts the editor offers: Google Fonts (every family V1 had, plus the most used ones), each with its group, the weights it
3
+ * really has, and a sensible fallback stack. The weights matter: asking Google for a weight a family doesn't have makes the
4
+ * whole stylesheet fail, so both the picker and the compilers go by this table.
5
+ */
6
+ export type FontKind = 'sans' | 'serif' | 'display' | 'mono' | 'handwriting';
2
7
  export interface FontChoice {
3
8
  name: string;
4
- kind: 'sans' | 'serif' | 'display' | 'mono';
9
+ kind: FontKind;
5
10
  stack: string;
11
+ /** The weights this family comes in (100–900). */
12
+ weights: number[];
13
+ /** Among the most used fonts (shown first, under "Popular"). */
14
+ popular: boolean;
6
15
  }
16
+ /** The fonts shown first, under "Popular": well-loved, readable, and a good mix of looks. */
17
+ export declare const POPULAR_FONTS: string[];
7
18
  export declare const FONT_CHOICES: FontChoice[];
19
+ /** The catalogue entry for a family name (case-insensitive), if it is one of ours. */
20
+ export declare const findFont: (name: string) => FontChoice | undefined;
21
+ /** Fonts every browser already has — nothing to load. */
22
+ export declare const SYSTEM_FONTS: ReadonlySet<string>;
23
+ export declare const isSystemFont: (name: string) => boolean;
8
24
  /** The first family of a font stack, unquoted ("'Plus Jakarta Sans', ui-sans-serif…" → "Plus Jakarta Sans"). */
9
25
  export declare function primaryFamily(stack: string): string;
26
+ /** A family name worth loading: plain letters, digits and spaces (anything else can't safely go in a URL or a stylesheet). */
27
+ export declare const isLoadableFamily: (name: string) => boolean;
28
+ /** The stack to store for a font name: ours with its fallbacks, or any other name with a sans fallback. */
10
29
  export declare const stackFor: (name: string) => string;
30
+ export interface FontRequest {
31
+ family: string;
32
+ /** Weights the design actually uses, on top of the usual four. */
33
+ weights?: number[];
34
+ }
35
+ /** The weights to ask Google for: the usual four plus the ones used, but only those the family really has. */
36
+ export declare function weightsToLoad(family: string, used?: number[]): number[];
37
+ /**
38
+ * The Google Fonts stylesheets a page needs: one address for all the families we know (with exactly the weights they have,
39
+ * so it can't fail), and one each for any other name — so a name Google doesn't know can't break the rest.
40
+ * `display=swap` shows text straight away in a fallback font and swaps when the font arrives.
41
+ */
42
+ export declare function googleFontsHrefs(requests: Array<string | FontRequest>): string[];
43
+ /** A tiny stylesheet for showing a family's own name in the picker (only the letters needed, so it is a few KB). */
44
+ export declare function googleFontPreviewHref(family: string): string | null;
@@ -0,0 +1 @@
1
+ export declare const GOOGLE_FONTS_DATA: string[];
@@ -2,8 +2,11 @@ export type { DesignSystem, DesignToken, DesignComponent, DesignOptions, StrataL
2
2
  export { createDefaultDesignSystem } from './baseline';
3
3
  export { tokenCssValue, ref, refKey, tokenMap, getToken, getValue, setToken, setTokens, removeToken, resolveValue, resolveKey, nameFromKey } from './tokens';
4
4
  export { deriveShades, readableOn, tint } from './shades';
5
- export { FONT_CHOICES, primaryFamily, stackFor, type FontChoice } from './fonts';
5
+ export { FONT_CHOICES, POPULAR_FONTS, primaryFamily, stackFor, findFont, isSystemFont, isLoadableFamily, weightsToLoad, googleFontsHrefs, googleFontPreviewHref, type FontChoice, type FontKind, type FontRequest } from './fonts';
6
+ export { sanitizeCustomFonts, customFontFaceCss, addCustomFont, removeCustomFont, findCustomFont, customFontsOf, guessFontFromFile, isFontUrl, MAX_CUSTOM_FONTS, MAX_FONT_VARIANTS, MAX_FONT_FILE_BYTES, FONT_FILE_ACCEPT, WEIGHT_LABELS, type CustomFont, type CustomFontVariant, type CustomFontFormat } from './customFonts';
6
7
  export { THEME_PRESETS, applyTheme, setPrimaryColor, setSecondaryColor, setNeutralScale, neutralScaleOf, setRoundness, roundnessOf, setFonts, setStatusColor, setDensity, type StatusKind, type ThemePreset, type NeutralScale, type Roundness } from './themes';
8
+ export { effectiveTypeMetrics, evalCssLength, textStyleOf, ROOT_FONT_PX, type TypeMetrics } from './typeScale';
9
+ export { levelTextStyle, isHeadingTextStyle } from './textStyles';
7
10
  export { TEXT_STYLES, TEXT_STYLE_IDS, isTextStyle, textStyleDef, textStyleVars, textStyleCss, type TextStyleId, type TextStyleDef } from './textStyles';
8
11
  export { designSystemVars, plexoVars, frameVars, designSystemCss, fontsNeeded } from './css';
9
12
  export { componentStyle, componentVariants } from './components';
@@ -9,6 +9,14 @@ export declare function deriveShades(hex: string): {
9
9
  } | null;
10
10
  /** White or near-black, whichever reads better on `background`. */
11
11
  export declare function readableOn(background: string): '#FFFFFF' | '#111827';
12
+ /** WCAG contrast ratio between two colours (1 to 21), or null if either can't be read as a plain colour. */
13
+ export declare function contrastRatio(a: string, b: string): number | null;
14
+ /**
15
+ * The text colour (white or near-black) that reads best on `background` — whichever has the higher contrast, so a
16
+ * light fill like brass or lime gets dark text. If `preferred` (say the design system's own "text on buttons" colour)
17
+ * already meets AA (4.5:1) on it, that wins.
18
+ */
19
+ export declare function accessibleTextOn(background: string, preferred?: string): string | null;
12
20
  /** A brand colour with its saturation nudged — used to keep derived tints from looking washed out. */
13
21
  export declare function withSaturation(hex: string, factor: number): string;
14
22
  /** Mixes a colour towards white (`amount` 0–1): the pale background that goes with a status colour. */
@@ -4,7 +4,7 @@ import type { ViewportMode } from '../types/editor';
4
4
  * font sizes. Change the design system's fonts or sizes and every piece of text follows; on a phone the big ones step down
5
5
  * on their own. They are derived from the tokens, so there is nothing extra to keep in sync with Strata.
6
6
  */
7
- export type TextStyleId = 'display' | 'h1' | 'h2' | 'h3' | 'h4' | 'lead' | 'body' | 'small' | 'eyebrow';
7
+ export type TextStyleId = 'display' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'lead' | 'body' | 'small' | 'eyebrow';
8
8
  export interface TextStyleDef {
9
9
  id: TextStyleId;
10
10
  label: string;
@@ -17,7 +17,7 @@ export interface TextStyleDef {
17
17
  letterSpacing?: string;
18
18
  textTransform?: string;
19
19
  /** The HTML heading level text with this style should use, if any. */
20
- tag?: 1 | 2 | 3 | 4;
20
+ tag?: 1 | 2 | 3 | 4 | 5 | 6;
21
21
  }
22
22
  export declare const TEXT_STYLES: TextStyleDef[];
23
23
  export declare const TEXT_STYLE_IDS: TextStyleId[];
@@ -27,3 +27,7 @@ export declare const textStyleDef: (id: TextStyleId) => TextStyleDef;
27
27
  export declare function textStyleVars(viewport: ViewportMode): Record<string, string>;
28
28
  /** What a style sets on an element — all by reference to the variables above. */
29
29
  export declare function textStyleCss(id: TextStyleId): Record<string, string>;
30
+ /** The text style a heading of this level gets when nothing else says (H1 → "Heading 1", … H6 → "Heading 6"). */
31
+ export declare const levelTextStyle: (level: number | undefined) => TextStyleId;
32
+ /** Is this one of the heading styles (so changing a heading's level should move it to the new level's style)? */
33
+ export declare const isHeadingTextStyle: (id: unknown) => boolean;
@@ -0,0 +1,56 @@
1
+ import type { DocumentNode, ElementStyles, ViewportMode } from '../types/editor';
2
+ import { type TextStyleId } from './textStyles';
3
+ import type { DesignSystem, DesignToken } from './types';
4
+ /**
5
+ * What a piece of text really looks like: its size, line height, weight and font, worked out the way the page does — from the
6
+ * element's own settings first, then its text style (Heading 1, Body…), which points at the design system's type scale.
7
+ * The editor shows these numbers instead of guessing "16", so an H1 reads as its real size and editing it starts from there.
8
+ */
9
+ export declare const ROOT_FONT_PX = 16;
10
+ interface Ctx {
11
+ tokens: Map<string, DesignToken>;
12
+ /** Width of the screen being designed, for `vw` and container units. */
13
+ width: number;
14
+ /** The element's own font size, for `em`. */
15
+ fontPx: number;
16
+ }
17
+ /** Evaluates a CSS length expression (px, rem, em, %, vw, calc/min/max/clamp) to pixels (or a plain number). Null when it can't. */
18
+ export declare function evalCssLength(input: string, ctx: Pick<Ctx, 'width' | 'fontPx'> & {
19
+ tokens?: Map<string, DesignToken>;
20
+ }): number | null;
21
+ /**
22
+ * Big sizes set directly on an element (a 96px number, a 4.5rem headline) would otherwise stay that big on a phone. Text that
23
+ * follows a text style already steps down; this does the same for explicit sizes: anything over 40px shrinks (to 80% on a
24
+ * tablet, 60% on a phone) but never below 40px, and nothing at or under 40px changes. An element that sets its own size for
25
+ * a screen keeps it — this only fills the gap when the owner hasn't chosen one.
26
+ */
27
+ export declare const STEP_DOWN: Record<'tablet' | 'mobile', number>;
28
+ /** Does this element take its font size from a bigger screen (so it should be stepped down), rather than choosing its own for `viewport`? */
29
+ export declare function fontSizeSteps(node: Pick<DocumentNode, 'responsive'>, viewport: ViewportMode): viewport is 'tablet' | 'mobile';
30
+ /** The size in pixels after stepping down (see STEP_DOWN). */
31
+ export declare function stepDownPx(px: number, viewport: 'tablet' | 'mobile'): number;
32
+ /** The same step-down for a CSS size value. Plain px/rem sizes are worked out; token and calc() sizes become a CSS max()/min() so they follow the design system. Anything else is left alone. */
33
+ export declare function stepDownFontSize(value: string, viewport: 'tablet' | 'mobile'): string;
34
+ export interface TypeMetrics {
35
+ /** Real size in pixels (rounded to 0.1). */
36
+ fontSize: number;
37
+ /** Line height as a multiple of the size (1.25). */
38
+ lineHeight: number;
39
+ fontWeight: number;
40
+ /** The font's name ("Inter"). */
41
+ fontFamily: string;
42
+ /** The text style it comes from, if any ("h1"). */
43
+ textStyle: TextStyleId | null;
44
+ /** Did the element set its own size / line height / font (as opposed to following the design system)? */
45
+ own: {
46
+ fontSize: boolean;
47
+ lineHeight: boolean;
48
+ fontWeight: boolean;
49
+ fontFamily: boolean;
50
+ };
51
+ }
52
+ /** The text style a node follows: its own, or for a heading with none, the style for its level. */
53
+ export declare function textStyleOf(node: Pick<DocumentNode, 'type' | 'props'>, styles: ElementStyles): TextStyleId | null;
54
+ /** Works out what the text really looks like on one screen — what the Typography panel shows. */
55
+ export declare function effectiveTypeMetrics(node: Pick<DocumentNode, 'type' | 'props'> & Partial<Pick<DocumentNode, 'responsive'>>, styles: ElementStyles, ds: DesignSystem, viewport: ViewportMode): TypeMetrics;
56
+ export {};
@@ -78,4 +78,6 @@ export interface DesignSystem {
78
78
  components: DesignComponent[];
79
79
  options?: DesignOptions;
80
80
  strata?: StrataLink;
81
+ /** Fonts the owner uploaded (see `CustomFont`). Plexo-only: never synced to Strata. */
82
+ fonts?: import('./customFonts').CustomFont[];
81
83
  }
@@ -122,6 +122,19 @@ export interface V2HostConfig {
122
122
  autoSaveDuration?: number;
123
123
  /** Upload an image, return its public URL. Absent → small images are embedded in the design. */
124
124
  onUpload?: (file: File) => Promise<string> | string;
125
+ /**
126
+ * Store a font file the site owner chose and return its public address (an `https://` URL, or a path on the site such as
127
+ * `/fonts/brand-bold.woff2`). Absent → the "Add a font" button is hidden (the SDK never uploads anything itself).
128
+ * `info` is what the owner confirmed (name, weight, italic) — handy for naming the stored file. The address ends up in the
129
+ * site's design system and, at publish time, in an `@font-face` rule: it must be reachable by visitors' browsers, and when
130
+ * it is on another origin the host passes that origin to `sanitizeV2Html({ fontOrigins })`.
131
+ */
132
+ onUploadFont?: (file: File, info: {
133
+ family: string;
134
+ weight: number;
135
+ style: 'normal' | 'italic';
136
+ format: import('../design/customFonts').CustomFontFormat;
137
+ }) => Promise<string> | string;
125
138
  /** Stock photo search, brokered by the host so API keys stay server-side. */
126
139
  stockImages?: {
127
140
  providers: StockImageProvider[];
@@ -71,6 +71,12 @@ export interface FormProps {
71
71
  /** Where submissions are sent. Empty → the host's form endpoint (see compile options). */
72
72
  action?: string;
73
73
  successMessage?: string;
74
+ /** The send button's fill (a colour or a design-system colour like `var(--color-brand-primary-500)`). Empty → the site's main colour. */
75
+ buttonColor?: string;
76
+ /** The send button's label colour. Empty → picked automatically so it stays readable on the fill. */
77
+ buttonTextColor?: string;
78
+ /** The send button's corners: `0px`, `8px`, `999px`… (or a design-system radius). Empty → the default. */
79
+ buttonRadius?: string;
74
80
  }
75
81
  export interface AccordionItem {
76
82
  title: string;
@@ -3,3 +3,7 @@ export declare const ICONS: Record<string, IconShape[]>;
3
3
  /** Icon names in the order the picker shows them, by theme. */
4
4
  export declare const ICON_GROUPS: Record<string, string[]>;
5
5
  export declare const ICON_NAMES: string[];
6
+ /** What an icon name we don't have draws: a plain ring, so a mistyped name looks neutral rather than like a star. */
7
+ export declare const FALLBACK_ICON: IconShape[];
8
+ /** The shapes for an icon name. No name at all is the star (the default icon); a name we don't have is a plain ring. */
9
+ export declare function iconShapes(name: unknown): IconShape[];
@@ -4,8 +4,19 @@ export declare const escapeAttr: (s: string) => string;
4
4
  export declare function safeHref(value: unknown): string;
5
5
  /** An image address: http(s), relative, or an embedded raster/SVG image. Empty/unsafe → '' (the builders show a placeholder). */
6
6
  export declare function safeImageSrc(value: unknown): string;
7
+ /**
8
+ * The address inside a section/element `backgroundImage` value. Accepts a plain address (`https://…/a.jpg`, `/a.jpg`) or the
9
+ * standard CSS form `url("…")` / `url('…')` / `url(…)`, and returns just the address — or '' when it isn't a safe image address
10
+ * (only https/http, site-relative and embedded `data:image` are allowed; no `javascript:`, no other schemes, and no `;`, braces,
11
+ * angle brackets or backslashes in an ordinary address).
12
+ */
13
+ export declare function backgroundImageAddress(value: unknown): string;
7
14
  /** A CSS colour: hex, rgb()/hsl() with plain numbers, or a named colour. Otherwise undefined. */
8
15
  export declare function safeColor(value: unknown): string | undefined;
16
+ /** A colour, or one design-system colour reference (`var(--color-brand-primary-500)`) — what a style value that may point at a token can be. */
17
+ export declare function safeColorOrToken(value: unknown): string | undefined;
18
+ /** A corner radius: a length (`12px`, `0.5rem`, `999px`) or a design-system radius reference. */
19
+ export declare function safeRadius(value: unknown): string | undefined;
9
20
  /** Space-separated class names made only of letters, digits and `_ - : / [ ] . % # !` — enough for utility classes, no quotes or spaces inside a token. */
10
21
  export declare function safeClassList(value: unknown): string;
11
22
  /** An identifier safe for ids, form field names and class suffixes. */
@@ -70,3 +70,10 @@ export declare function applyBlockTweak(root: DocumentNode, nodeId: string, patc
70
70
  export declare const isManagedChild: (root: DocumentNode, nodeId: string) => boolean;
71
71
  /** Swaps a managed section for another node (same position). */
72
72
  export declare function replaceNodeById(root: DocumentNode, id: string, next: DocumentNode): DocumentNode;
73
+ /**
74
+ * Changes a heading's level (H1–H6). The level is the heading's meaning (and its tag on the published page); unless the
75
+ * heading has a size of its own, it also moves to the new level's text style, so an H2 really is the design system's H2 size.
76
+ * Inside a ready-made section the change is kept as a tweak, so it survives edits to the section's words and a change of layout.
77
+ * Returns the new tree (the same one if nothing changes).
78
+ */
79
+ export declare function setHeadingLevel(root: DocumentNode, nodeId: string, level: number): DocumentNode;
@@ -30,6 +30,10 @@ export interface NodeOverride {
30
30
  };
31
31
  responsiveVisibility?: import('../types/editor').ResponsiveVisibility;
32
32
  hidden?: boolean;
33
+ /** Settings of the element itself that a person can change on the page: a heading's level (H1–H6). */
34
+ props?: {
35
+ level?: 1 | 2 | 3 | 4 | 5 | 6;
36
+ };
33
37
  }
34
38
  export interface BlockSpec {
35
39
  kind: SectionKind;
@@ -4,6 +4,8 @@ export type SizingMode = 'hug' | 'fill' | 'fixed';
4
4
  export type LayoutMode = 'flow' | 'grid' | 'free';
5
5
  export type HorizontalConstraint = 'left' | 'right' | 'center' | 'stretch' | 'scale';
6
6
  export type VerticalConstraint = 'top' | 'bottom' | 'center' | 'stretch' | 'scale';
7
+ /** Cross-axis alignment values (`start`/`end` follow reading direction; `baseline` lines text up). */
8
+ export type AlignValue = 'flex-start' | 'center' | 'flex-end' | 'stretch' | 'start' | 'end' | 'baseline';
7
9
  export interface ElementStyles {
8
10
  layoutMode?: LayoutMode;
9
11
  position?: 'static' | 'relative' | 'absolute';
@@ -40,12 +42,17 @@ export interface ElementStyles {
40
42
  display?: 'block' | 'flex' | 'grid' | 'inline-block' | 'inline-flex';
41
43
  flexDirection?: 'row' | 'column' | 'row-reverse' | 'column-reverse';
42
44
  justifyContent?: 'flex-start' | 'center' | 'flex-end' | 'space-between' | 'space-around';
43
- alignItems?: 'flex-start' | 'center' | 'flex-end' | 'stretch';
45
+ alignItems?: AlignValue;
46
+ /** Where rows of a wrapped or grid layout sit when the box is taller than they need: `start` keeps them together at the top. */
47
+ alignContent?: 'start' | 'center' | 'end' | 'stretch' | 'space-between' | 'flex-start' | 'flex-end';
48
+ /** How this one element lines up inside a flex or grid parent, overriding the parent's `alignItems`. */
49
+ alignSelf?: AlignValue;
44
50
  gap?: string;
45
51
  width?: string;
46
52
  customWidth?: string;
47
53
  isFullWidth?: boolean;
48
54
  maxWidth?: string;
55
+ minWidth?: string;
49
56
  height?: string;
50
57
  minHeight?: string;
51
58
  maxHeight?: string;
@@ -88,6 +95,14 @@ export interface ElementStyles {
88
95
  borderStyle?: 'solid' | 'dashed' | 'dotted' | 'none';
89
96
  borderColor?: string;
90
97
  boxShadow?: string;
98
+ /** What happens to content that spills out of the box. */
99
+ overflow?: 'hidden' | 'visible' | 'auto' | 'clip';
100
+ /** `nowrap` keeps a line of text on one line. */
101
+ whiteSpace?: 'normal' | 'nowrap';
102
+ /** Which part of a picture stays in view when it is cropped to fit: `center`, `top`, `20% 30%`… */
103
+ objectPosition?: string;
104
+ /** Frosted-glass blur behind the box, in px (0 to 40) — for a translucent header or card over a picture. */
105
+ backdropFilter?: number;
91
106
  linkColor?: string;
92
107
  linkHoverColor?: string;
93
108
  underlineLinks?: boolean;
@@ -1,41 +1,41 @@
1
- import { D as e, G as t, J as n, K as r, O as i, Qt as a, St as o, T as s, U as c, W as l, X as u, Y as d, Z as f, Zt as p, _ as m, _t as h, a as g, an as _, b as v, bt as y, c as b, cn as x, d as S, f as C, gt as w, ht as T, i as E, l as D, m as O, n as k, o as A, p as j, q as M, r as N, s as P, sn as F, t as I, u as L, un as R, vt as z, w as B, xt as V, yt as H } from "./v1-B92O2-af.js";
2
- import { n as U, t as W } from "./lint-D-2x-Yeb.js";
1
+ import { $ as e, $t as t, C as n, D as r, E as i, J as a, K as o, Q as s, Qt as c, St as l, X as u, Y as d, Z as f, _t as p, a as m, bt as h, c as g, cn as _, d as v, dn as y, et as b, f as x, g as S, gt as C, ht as w, i as T, l as E, n as D, o as O, p as k, pn as A, q as j, r as M, s as N, t as P, u as F, un as I, vt as L, w as R, xt as z, y as B, yt as V } from "./v1-C2tXaSOb.js";
2
+ import { n as H, t as U } from "./lint-CTTecyu_.js";
3
3
  //#region src/v2/compile/react.ts
4
- var G = /^[A-Z][A-Za-z0-9]*$/, K = (e) => JSON.stringify(e);
5
- function q(e) {
6
- let t = "";
7
- for (let [n, r] of Object.entries(e.attrs ?? {})) {
8
- if (r === void 0 || r === !1) continue;
9
- let e = a(n);
10
- r === !0 ? t += ` ${e}` : typeof r == "number" ? t += ` ${e}={${r}}` : t += ` ${e}={${K(String(r))}}`;
4
+ var W = /^[A-Z][A-Za-z0-9]*$/, G = (e) => JSON.stringify(e);
5
+ function K(e) {
6
+ let n = "";
7
+ for (let [r, i] of Object.entries(e.attrs ?? {})) {
8
+ if (i === void 0 || i === !1) continue;
9
+ let e = t(r);
10
+ i === !0 ? n += ` ${e}` : typeof i == "number" ? n += ` ${e}={${i}}` : n += ` ${e}={${G(String(i))}}`;
11
11
  }
12
- return e.style && (t += ` style={${JSON.stringify(e.style)}}`), t;
12
+ return e.style && (n += ` style={${JSON.stringify(e.style)}}`), n;
13
13
  }
14
- function J(e, t) {
14
+ function q(e, t) {
15
15
  let n = " ".repeat(t);
16
- if (typeof e == "string") return `${n}{${K(e)}}`;
17
- let r = q(e);
18
- return p.has(e.tag) || !e.children?.length ? `${n}<${e.tag}${r} />` : `${n}<${e.tag}${r}>\n${e.children.map((e) => J(e, t + 1)).join("\n")}\n${n}</${e.tag}>`;
16
+ if (typeof e == "string") return `${n}{${G(e)}}`;
17
+ let r = K(e);
18
+ return c.has(e.tag) || !e.children?.length ? `${n}<${e.tag}${r} />` : `${n}<${e.tag}${r}>\n${e.children.map((e) => q(e, t + 1)).join("\n")}\n${n}</${e.tag}>`;
19
19
  }
20
- function Y(e) {
20
+ function J(e) {
21
21
  let t = e.replace(/[^A-Za-z0-9]+/g, " ").trim().split(" ").filter(Boolean).map((e) => e[0].toUpperCase() + e.slice(1)).join("");
22
22
  return /^[A-Z]/.test(t) ? t : `Design${t}`;
23
23
  }
24
- function X(e, t) {
25
- if (!G.test(t.componentName)) throw Error(`"${t.componentName}" isn't a valid component name — use PascalCase letters and numbers.`);
26
- let n = j(e, t), r = t.runtime !== "none" && n.usesRuntime, a = O(n.fonts), o = "`" + n.css.replace(/\\/g, "\\\\").replace(/`/g, "\\`").replace(/\$\{/g, "\\${") + "`";
24
+ function Y(e, t) {
25
+ if (!W.test(t.componentName)) throw Error(`"${t.componentName}" isn't a valid component name — use PascalCase letters and numbers.`);
26
+ let n = k(e, t), i = t.runtime !== "none" && n.usesRuntime, a = n.fontLinks, o = "`" + n.css.replace(/\\/g, "\\\\").replace(/`/g, "\\`").replace(/\$\{/g, "\\${") + "`";
27
27
  return {
28
28
  code: `// Generated by Plexo from a visual design. Edit it visually in the app editor's Design view
29
29
  // (which regenerates this file), or turn it into regular code by editing here.
30
- ${r ? "// @ts-nocheck — the small runtime below is plain JavaScript.\nimport { useEffect, useRef } from \"react\";" : "import type { ReactElement } from \"react\";"}
30
+ ${i ? "// @ts-nocheck — the small runtime below is plain JavaScript.\nimport { useEffect, useRef } from \"react\";" : "import type { ReactElement } from \"react\";"}
31
31
 
32
32
  const CSS = ${o};
33
- ${a ? `const FONTS = ${K(a)};\n` : ""}${r ? `\n/** Carousel autoplay, the live timer and in-page form sending. */\nconst plexoInit = ${i};\n` : ""}
34
- export default function ${t.componentName}()${r ? "" : ": ReactElement"} {
35
- ${r ? " const root = useRef<HTMLDivElement>(null);\n useEffect(() => (root.current ? plexoInit(root.current) : undefined), []);\n" : ""} return (
33
+ ${a.length ? `const FONTS: string[] = ${JSON.stringify(a)};\n` : ""}${i ? `\n/** Carousel autoplay, the live timer and in-page form sending. */\nconst plexoInit = ${r};\n` : ""}
34
+ export default function ${t.componentName}()${i ? "" : ": ReactElement"} {
35
+ ${i ? " const root = useRef<HTMLDivElement>(null);\n useEffect(() => (root.current ? plexoInit(root.current) : undefined), []);\n" : ""} return (
36
36
  <>
37
- ${a ? " <link rel=\"stylesheet\" href={FONTS} />\n" : ""} <style>{CSS}</style>
38
- ${r ? J(n.tree, 3).replace("<div", "<div ref={root}") : J(n.tree, 3)}
37
+ ${a.length ? " {FONTS.map((href) => <link key={href} rel=\"stylesheet\" href={href} />)}\n" : ""} <style>{CSS}</style>
38
+ ${i ? q(n.tree, 3).replace("<div", "<div ref={root}") : q(n.tree, 3)}
39
39
  </>
40
40
  );
41
41
  }
@@ -44,4 +44,4 @@ ${r ? J(n.tree, 3).replace("<div", "<div ref={root}") : J(n.tree, 3)}
44
44
  };
45
45
  }
46
46
  //#endregion
47
- export { F as FRAME_WIDTH, B as MAX_CUSTOM_JS, E as MAX_DEPTH, g as MAX_NODES, x as MEDIA_QUERY, w as PAGE_TEMPLATES, c as SOL_SYSTEM_PROMPT, I as V1_DYNAMIC_EQUIVALENTS, k as V2_DYNAMIC_READY, r as applyCommands, d as blankPages, h as buildPageFromTemplate, z as buildTemplateSections, T as catalogSchema, S as compilePageToHtml, X as compilePageToReact, Y as componentNameFor, _ as computePlacements, D as convertLegacyDesign, N as convertV1Design, R as createDefaultDesignSystem, l as describeCommand, u as describeDesign, f as describeSection, H as getPageTemplate, L as isLegacyDesign, y as isPageEmpty, W as lintDesignSystem, V as listPageTemplates, A as parsePages, t as parseSolReply, v as parseVideoUrl, s as prepareCustomJs, C as printHtml, U as repairDesignSystem, m as resolveFormDestination, P as sanitizeCss, b as sanitizeV2Html, M as setPageTemplateResolver, n as solCommandSchema, o as templateSeed, e as validHtmlId };
47
+ export { I as FRAME_WIDTH, n as MAX_CUSTOM_JS, T as MAX_DEPTH, m as MAX_NODES, y as MEDIA_QUERY, C as PAGE_TEMPLATES, o as SOL_SYSTEM_PROMPT, P as V1_DYNAMIC_EQUIVALENTS, D as V2_DYNAMIC_READY, d as applyCommands, s as blankPages, p as buildPageFromTemplate, L as buildTemplateSections, w as catalogSchema, v as compilePageToHtml, Y as compilePageToReact, J as componentNameFor, _ as computePlacements, E as convertLegacyDesign, M as convertV1Design, A as createDefaultDesignSystem, j as describeCommand, e as describeDesign, b as describeSection, V as getPageTemplate, F as isLegacyDesign, h as isPageEmpty, U as lintDesignSystem, z as listPageTemplates, O as parsePages, a as parseSolReply, B as parseVideoUrl, R as prepareCustomJs, x as printHtml, H as repairDesignSystem, S as resolveFormDestination, N as sanitizeCss, g as sanitizeV2Html, u as setPageTemplateResolver, f as solCommandSchema, l as templateSeed, i as validHtmlId };
package/dist/v2-strata.js CHANGED
@@ -1,2 +1,2 @@
1
- import { a as e, c as t, d as n, i as r, l as i, n as a, o, r as s, s as c, t as l, u } from "./client-DlVJt_6V.js";
1
+ import { a as e, c as t, d as n, i as r, l as i, n as a, o, r as s, s as c, t as l, u } from "./client-CAWtj9sV.js";
2
2
  export { l as StrataError, c as applySync, t as baseOf, a as componentFromStrata, s as createStrataClient, i as hasAnything, o as planAutoUpdate, u as planSync, r as projectFromStrata, n as summarize, e as tokenFromStrata };