@charisol/plexo-sdk 2.0.5 → 2.0.7
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/README.md +8 -0
- package/dist/plexo-sdk.css +1 -1
- package/dist/{v1-DgwxU8IH.js → v1-iodIbfkY.js} +2222 -1741
- package/dist/v2/components/design/bits.d.ts +1 -1
- package/dist/v2/components/properties/ElementInspector.d.ts +11 -0
- package/dist/v2/components/properties/ElementSettings.d.ts +2 -2
- package/dist/v2/components/properties/inspectorBits.d.ts +39 -0
- package/dist/v2/design/shades.d.ts +8 -0
- package/dist/v2/design/typeScale.d.ts +14 -1
- package/dist/v2/host/HostContext.d.ts +5 -0
- package/dist/v2/index.d.ts +1 -0
- package/dist/v2/render/boxTags.d.ts +2 -0
- package/dist/v2/render/elementProps.d.ts +6 -0
- package/dist/v2/render/iconSet.d.ts +4 -0
- package/dist/v2/render/nodeStyle.d.ts +4 -0
- package/dist/v2/render/sanitize.d.ts +11 -0
- package/dist/v2/theme/theme.d.ts +24 -0
- package/dist/v2/types/editor.d.ts +24 -2
- package/dist/v2-compile.js +17 -17
- package/dist/v2.js +5468 -4898
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
export declare const field = "w-full bg-
|
|
2
|
+
export declare const field = "w-full bg-px-raised border border-px-line2 rounded px-2 py-1.5 text-xs text-px-text focus:outline-none focus:border-px-accent";
|
|
3
3
|
export declare const Section: React.FC<{
|
|
4
4
|
title: string;
|
|
5
5
|
hint?: string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { DocumentNode } from '../../types/editor';
|
|
3
|
+
/**
|
|
4
|
+
* The right-hand panel for one selected element: one panel with three friendly tabs.
|
|
5
|
+
* - Design: what it says and how it looks (text, colours, shadows, borders).
|
|
6
|
+
* - Layout: how it sits and is sized (flow, size, spacing, position, stacking).
|
|
7
|
+
* - Advanced: the technical extras (tag, id, classes, overflow, cursor, accessibility, transitions).
|
|
8
|
+
*/
|
|
9
|
+
export declare const ElementInspector: React.FC<{
|
|
10
|
+
node: DocumentNode;
|
|
11
|
+
}>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { DocumentNode } from '../../types/editor';
|
|
3
|
-
export declare const input = "w-full bg-
|
|
4
|
-
export declare const smallBtn = "w-6 h-6 rounded flex items-center justify-center text-
|
|
3
|
+
export declare const input = "w-full bg-px-raised border border-px-line2 rounded px-2 py-1 text-xs text-px-text placeholder-px-faint focus:outline-none focus:border-px-accent";
|
|
4
|
+
export declare const smallBtn = "w-6 h-6 rounded flex items-center justify-center text-px-muted hover:text-white hover:bg-px-line2 disabled:opacity-30 disabled:hover:bg-transparent cursor-pointer";
|
|
5
5
|
export declare const Group: React.FC<{
|
|
6
6
|
title: string;
|
|
7
7
|
children: React.ReactNode;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/** Small building blocks shared by the inspector's three tabs, so every control looks and behaves the same. */
|
|
3
|
+
export declare const inputCls = "w-full min-w-0 bg-px-raised border border-px-line2 rounded-lg px-2 py-1 text-xs text-px-text placeholder:text-px-faint focus:outline-none focus:border-px-accent/60";
|
|
4
|
+
/** A titled group of controls that can be folded away. Open by default so nothing is hidden from a first-time user. */
|
|
5
|
+
export declare const Group: React.FC<{
|
|
6
|
+
title: string;
|
|
7
|
+
defaultOpen?: boolean;
|
|
8
|
+
hint?: string;
|
|
9
|
+
children: React.ReactNode;
|
|
10
|
+
}>;
|
|
11
|
+
/** A label on the left, its control on the right. */
|
|
12
|
+
export declare const Field: React.FC<{
|
|
13
|
+
label: string;
|
|
14
|
+
children: React.ReactNode;
|
|
15
|
+
stack?: boolean;
|
|
16
|
+
}>;
|
|
17
|
+
/** A row of choices where exactly one is on (like Hug / Fill / Fixed). */
|
|
18
|
+
export declare function Choice<T extends string>({ options, value, onChange, label }: {
|
|
19
|
+
options: Array<{
|
|
20
|
+
id: T;
|
|
21
|
+
label: React.ReactNode;
|
|
22
|
+
title?: string;
|
|
23
|
+
}>;
|
|
24
|
+
value: T | undefined;
|
|
25
|
+
onChange: (id: T) => void;
|
|
26
|
+
label: string;
|
|
27
|
+
}): React.JSX.Element;
|
|
28
|
+
/** A number in pixels. Stores `"12px"`; empty means "not set". */
|
|
29
|
+
export declare const PxInput: React.FC<{
|
|
30
|
+
value: string | undefined;
|
|
31
|
+
onChange: (v: string | undefined) => void;
|
|
32
|
+
label: string;
|
|
33
|
+
placeholder?: string;
|
|
34
|
+
min?: number;
|
|
35
|
+
max?: number;
|
|
36
|
+
}>;
|
|
37
|
+
export declare const Hint: React.FC<{
|
|
38
|
+
children: React.ReactNode;
|
|
39
|
+
}>;
|
|
@@ -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. */
|
|
@@ -18,6 +18,19 @@ interface Ctx {
|
|
|
18
18
|
export declare function evalCssLength(input: string, ctx: Pick<Ctx, 'width' | 'fontPx'> & {
|
|
19
19
|
tokens?: Map<string, DesignToken>;
|
|
20
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;
|
|
21
34
|
export interface TypeMetrics {
|
|
22
35
|
/** Real size in pixels (rounded to 0.1). */
|
|
23
36
|
fontSize: number;
|
|
@@ -39,5 +52,5 @@ export interface TypeMetrics {
|
|
|
39
52
|
/** The text style a node follows: its own, or for a heading with none, the style for its level. */
|
|
40
53
|
export declare function textStyleOf(node: Pick<DocumentNode, 'type' | 'props'>, styles: ElementStyles): TextStyleId | null;
|
|
41
54
|
/** Works out what the text really looks like on one screen — what the Typography panel shows. */
|
|
42
|
-
export declare function effectiveTypeMetrics(node: Pick<DocumentNode, 'type' | 'props'
|
|
55
|
+
export declare function effectiveTypeMetrics(node: Pick<DocumentNode, 'type' | 'props'> & Partial<Pick<DocumentNode, 'responsive'>>, styles: ElementStyles, ds: DesignSystem, viewport: ViewportMode): TypeMetrics;
|
|
43
56
|
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { PageDefinition } from '../types/editor';
|
|
3
3
|
import type { StrataAdapter } from '../strata/types';
|
|
4
|
+
import type { V2Theme } from '../theme/theme';
|
|
4
5
|
/**
|
|
5
6
|
* What the app embedding the editor can plug in. Every field is optional: with no props the
|
|
6
7
|
* editor is a complete, offline visual builder (blank page, embedded images, no AI). A field
|
|
@@ -162,6 +163,10 @@ export interface V2HostConfig {
|
|
|
162
163
|
/** Clicking a node reports it via onRequestComment instead of selecting it. */
|
|
163
164
|
commentMode?: boolean;
|
|
164
165
|
onRequestComment?: (target: CommentTarget) => void;
|
|
166
|
+
/** The host's own settings for the page being edited (name, address, search and sharing details…). Shown in a "Page settings" panel in the left rail, so it needs no button in the top bar. */
|
|
167
|
+
pageSettings?: React.ReactNode;
|
|
168
|
+
/** The editor's colours: `{ accent, background, text }`, any of them. Absent → Plexo's own lime-on-black look. */
|
|
169
|
+
theme?: V2Theme;
|
|
165
170
|
/** The host's pages (see PageSource). Absent → the editor keeps its own list. */
|
|
166
171
|
pageSource?: PageSource;
|
|
167
172
|
/** Way home + hiding the host's sidebar for more room (see HostShell). */
|
package/dist/v2/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
export { V2Editor } from './V2Editor';
|
|
10
10
|
export type { V2EditorProps, V2EditorRef } from './V2Editor';
|
|
11
|
+
export type { V2Theme } from './theme/theme';
|
|
11
12
|
export type { V2HostConfig, SaveState, StockImageProvider, StockImageResult, LibrarySection, MediaAsset, LinkTarget, CommentTarget, AskSolContext, PageSource, HostPage, HostShell, } from './host/HostContext';
|
|
12
13
|
export type { DocumentNode, PageDefinition, NodeType, ElementStyles, ViewportMode, } from './types/editor';
|
|
13
14
|
export { convertLegacyDesign, isLegacyDesign } from './migrate/legacy';
|
|
@@ -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[];
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import type { DocumentNode, ElementStyles, ViewportMode } from '../types/editor';
|
|
2
|
+
/** `transition` for an element, from the allow-listed property / duration / easing choices (nothing otherwise). */
|
|
3
|
+
export declare function transitionCss(styles: ElementStyles): string | undefined;
|
|
2
4
|
export type CssMap = Record<string, string | number | undefined>;
|
|
3
5
|
export interface NodeCssOptions {
|
|
4
6
|
viewport: ViewportMode;
|
|
5
7
|
/** True when the parent lays its children out as a grid. */
|
|
6
8
|
isGridChild: boolean;
|
|
7
9
|
isRootPage: boolean;
|
|
10
|
+
/** True when building the published page. Cursor and transitions are for visitors; on the editing canvas they would fight dragging. */
|
|
11
|
+
forPublish?: boolean;
|
|
8
12
|
}
|
|
9
13
|
export interface NodeCss {
|
|
10
14
|
css: CssMap;
|
|
@@ -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. */
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { CSSProperties } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* The editor's colours. A host passes any of the three (the rest follow from them); nothing passed = Plexo's own look.
|
|
4
|
+
* <V2Editor theme={{ accent: '#96F02E', background: '#000000', text: '#ffffff' }} />
|
|
5
|
+
* Every shade the editor uses (panels, borders, hover states, muted text) is mixed from these three, so a host never
|
|
6
|
+
* has to list a palette, and a light background with dark text works just as well as a dark one.
|
|
7
|
+
*/
|
|
8
|
+
export interface V2Theme {
|
|
9
|
+
/** The highlight colour: active tools, primary buttons, selections. Default #96F02E (lime). */
|
|
10
|
+
accent?: string;
|
|
11
|
+
/** The editor's own background. Default #101010. */
|
|
12
|
+
background?: string;
|
|
13
|
+
/** The main text colour. Default #EDEDED. */
|
|
14
|
+
text?: string;
|
|
15
|
+
}
|
|
16
|
+
/** The CSS variables for a theme, set on the editor's root element. */
|
|
17
|
+
export declare function themeVars(theme?: V2Theme): CSSProperties;
|
|
18
|
+
/** The three colours as hex, plus the panel colour — for controls that take colours as props instead of reading the variables. */
|
|
19
|
+
export declare const resolveTheme: (theme?: V2Theme) => {
|
|
20
|
+
accent: string;
|
|
21
|
+
background: string;
|
|
22
|
+
text: string;
|
|
23
|
+
surface: string;
|
|
24
|
+
};
|
|
@@ -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?:
|
|
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,12 +95,27 @@ 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;
|
|
94
109
|
underlineOnHover?: boolean;
|
|
95
110
|
horizontalAlign?: 'left' | 'center' | 'right';
|
|
96
111
|
customClasses?: string;
|
|
112
|
+
/** What the element animates when something about it changes (a hover colour, a screen-size change). Allow-listed; see render/nodeStyle. */
|
|
113
|
+
transitionProperty?: 'none' | 'all' | 'opacity' | 'transform' | 'colors';
|
|
114
|
+
/** Milliseconds, 0–2000. */
|
|
115
|
+
transitionDuration?: number;
|
|
116
|
+
transitionEasing?: 'ease' | 'linear' | 'ease-in' | 'ease-out' | 'ease-in-out';
|
|
117
|
+
/** The mouse pointer over the element on the published page. */
|
|
118
|
+
cursor?: 'auto' | 'pointer' | 'default' | 'text' | 'grab' | 'not-allowed';
|
|
97
119
|
}
|
|
98
120
|
export interface ResponsiveOverrides {
|
|
99
121
|
tablet?: Partial<ElementStyles>;
|
|
@@ -133,7 +155,7 @@ export interface PageDefinition {
|
|
|
133
155
|
rootNode: DocumentNode;
|
|
134
156
|
}
|
|
135
157
|
export type ViewportMode = 'desktop' | 'tablet' | 'mobile';
|
|
136
|
-
export type LeftSidebarTab = 'sections' | 'add' | 'layers' | 'pages' | 'strata' | 'library' | 'sol' | 'insert';
|
|
158
|
+
export type LeftSidebarTab = 'sections' | 'add' | 'layers' | 'pages' | 'strata' | 'library' | 'pageSettings' | 'sol' | 'insert';
|
|
137
159
|
export type ViewMode = 'design' | 'code' | 'json' | 'html' | 'plaintext';
|
|
138
160
|
export interface DragDropState {
|
|
139
161
|
draggingNodeId: string | null;
|
package/dist/v2-compile.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { $ as e,
|
|
1
|
+
import { $ as e, Ct as t, E as n, J as r, O as i, Q as a, St as o, T as s, X as c, Y as l, Z as u, _t as d, a as f, bt as p, c as m, d as h, en as g, et as _, f as v, fn as y, hn as b, i as x, k as S, l as C, n as w, nt as T, o as E, p as D, pn as O, r as k, s as A, t as j, tn as M, tt as N, u as P, un as F, v as I, vt as L, wt as R, x as z, xt as B, yt as V } from "./v1-iodIbfkY.js";
|
|
2
2
|
import { n as H, t as U } from "./lint-CTTecyu_.js";
|
|
3
3
|
//#region src/v2/compile/react.ts
|
|
4
4
|
var W = /^[A-Z][A-Za-z0-9]*$/, G = (e) => JSON.stringify(e);
|
|
5
5
|
function K(e) {
|
|
6
|
-
let
|
|
7
|
-
for (let [
|
|
8
|
-
if (
|
|
9
|
-
let e =
|
|
10
|
-
|
|
6
|
+
let t = "";
|
|
7
|
+
for (let [n, r] of Object.entries(e.attrs ?? {})) {
|
|
8
|
+
if (r === void 0 || r === !1) continue;
|
|
9
|
+
let e = M(n);
|
|
10
|
+
r === !0 ? t += ` ${e}` : typeof r == "number" ? t += ` ${e}={${r}}` : t += ` ${e}={${G(String(r))}}`;
|
|
11
11
|
}
|
|
12
|
-
return e.style && (
|
|
12
|
+
return e.style && (t += ` style={${JSON.stringify(e.style)}}`), t;
|
|
13
13
|
}
|
|
14
14
|
function q(e, t) {
|
|
15
15
|
let n = " ".repeat(t);
|
|
16
16
|
if (typeof e == "string") return `${n}{${G(e)}}`;
|
|
17
17
|
let r = K(e);
|
|
18
|
-
return
|
|
18
|
+
return g.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
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("");
|
|
@@ -23,19 +23,19 @@ function J(e) {
|
|
|
23
23
|
}
|
|
24
24
|
function Y(e, t) {
|
|
25
25
|
if (!W.test(t.componentName)) throw Error(`"${t.componentName}" isn't a valid component name — use PascalCase letters and numbers.`);
|
|
26
|
-
let n =
|
|
26
|
+
let n = D(e, t), r = t.runtime !== "none" && n.usesRuntime, i = n.fontLinks, a = "`" + 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
|
-
${
|
|
30
|
+
${r ? "// @ts-nocheck — the small runtime below is plain JavaScript.\nimport { useEffect, useRef } from \"react\";" : "import type { ReactElement } from \"react\";"}
|
|
31
31
|
|
|
32
|
-
const CSS = ${
|
|
33
|
-
${
|
|
34
|
-
export default function ${t.componentName}()${
|
|
35
|
-
${
|
|
32
|
+
const CSS = ${a};
|
|
33
|
+
${i.length ? `const FONTS: string[] = ${JSON.stringify(i)};\n` : ""}${r ? `\n/** Carousel autoplay, the live timer and in-page form sending. */\nconst plexoInit = ${S};\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 (
|
|
36
36
|
<>
|
|
37
|
-
${
|
|
38
|
-
${
|
|
37
|
+
${i.length ? " {FONTS.map((href) => <link key={href} rel=\"stylesheet\" href={href} />)}\n" : ""} <style>{CSS}</style>
|
|
38
|
+
${r ? q(n.tree, 3).replace("<div", "<div ref={root}") : q(n.tree, 3)}
|
|
39
39
|
</>
|
|
40
40
|
);
|
|
41
41
|
}
|
|
@@ -44,4 +44,4 @@ ${i ? q(n.tree, 3).replace("<div", "<div ref={root}") : q(n.tree, 3)}
|
|
|
44
44
|
};
|
|
45
45
|
}
|
|
46
46
|
//#endregion
|
|
47
|
-
export {
|
|
47
|
+
export { y as FRAME_WIDTH, s as MAX_CUSTOM_JS, x as MAX_DEPTH, f as MAX_NODES, O as MEDIA_QUERY, L as PAGE_TEMPLATES, r as SOL_SYSTEM_PROMPT, j as V1_DYNAMIC_EQUIVALENTS, w as V2_DYNAMIC_READY, u as applyCommands, _ as blankPages, V as buildPageFromTemplate, p as buildTemplateSections, d as catalogSchema, h as compilePageToHtml, Y as compilePageToReact, J as componentNameFor, F as computePlacements, C as convertLegacyDesign, k as convertV1Design, b as createDefaultDesignSystem, l as describeCommand, N as describeDesign, T as describeSection, B as getPageTemplate, P as isLegacyDesign, o as isPageEmpty, U as lintDesignSystem, t as listPageTemplates, E as parsePages, c as parseSolReply, z as parseVideoUrl, n as prepareCustomJs, v as printHtml, H as repairDesignSystem, I as resolveFormDestination, A as sanitizeCss, m as sanitizeV2Html, a as setPageTemplateResolver, e as solCommandSchema, R as templateSeed, i as validHtmlId };
|