@palmyit/elements 0.1.3 → 0.1.8

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.
Files changed (80) hide show
  1. package/README.md +2 -2
  2. package/dist/definitions.d.ts +54 -0
  3. package/dist/definitions.js +1743 -0
  4. package/dist/elements/button/definition.d.ts +38 -0
  5. package/dist/elements/button/template.d.ts +2 -0
  6. package/dist/elements/checkbox/definition.d.ts +10 -0
  7. package/dist/elements/checkbox/template.d.ts +2 -0
  8. package/dist/elements/container/definition.d.ts +39 -0
  9. package/dist/elements/container/template.d.ts +2 -0
  10. package/dist/elements/divider/definition.d.ts +10 -0
  11. package/dist/elements/divider/template.d.ts +2 -0
  12. package/dist/elements/icon/definition.d.ts +18 -0
  13. package/dist/elements/icon/template.d.ts +2 -0
  14. package/dist/elements/image/definition.d.ts +33 -0
  15. package/dist/elements/image/template.d.ts +2 -0
  16. package/dist/elements/list/definition.d.ts +11 -0
  17. package/dist/elements/list/template.d.ts +2 -0
  18. package/dist/elements/page/definition.d.ts +22 -0
  19. package/dist/elements/page/template.d.ts +2 -0
  20. package/dist/elements/radio/definition.d.ts +13 -0
  21. package/dist/elements/radio/template.d.ts +2 -0
  22. package/dist/elements/rich-text/definition.d.ts +8 -0
  23. package/dist/elements/rich-text/richTextMarks.d.ts +4 -0
  24. package/dist/elements/rich-text/richTextOptions.d.ts +2 -0
  25. package/dist/elements/rich-text/template.d.ts +2 -0
  26. package/dist/elements/section/definition.d.ts +39 -0
  27. package/dist/elements/section/template.d.ts +2 -0
  28. package/dist/elements/select/definition.d.ts +13 -0
  29. package/dist/elements/select/template.d.ts +2 -0
  30. package/dist/elements/table/definition.d.ts +20 -0
  31. package/dist/elements/table/template.d.ts +2 -0
  32. package/dist/elements/text/definition.d.ts +46 -0
  33. package/dist/elements/text/template.d.ts +2 -0
  34. package/dist/elements/text-area/definition.d.ts +10 -0
  35. package/dist/elements/text-area/template.d.ts +2 -0
  36. package/dist/elements/text-field/definition.d.ts +10 -0
  37. package/dist/elements/text-field/template.d.ts +2 -0
  38. package/dist/elements/video/definition.d.ts +10 -0
  39. package/dist/elements/video/template.d.ts +2 -0
  40. package/dist/manifest.json +3 -3
  41. package/dist/plmt-elements.css +2 -1
  42. package/dist/plmt-elements.js +0 -115
  43. package/dist/registry.d.ts +9 -0
  44. package/dist/render/renderHtml.d.ts +5 -0
  45. package/dist/render/styleToClasses.d.ts +35 -0
  46. package/dist/render/styleToVars.d.ts +2 -0
  47. package/dist/render/styleTokens.d.ts +57 -0
  48. package/dist/render/tags.d.ts +42 -0
  49. package/dist/render/toDom.d.ts +3 -0
  50. package/dist/render/types.d.ts +20 -0
  51. package/dist/schema/Fields/BackgroundField/backgroundValue.d.ts +16 -0
  52. package/dist/schema/Fields/ColorField/color-value.d.ts +6 -0
  53. package/dist/schema/Fields/ColorField/index.d.ts +1 -0
  54. package/dist/schema/Fields/FontStyleField.d.ts +2 -0
  55. package/dist/schema/Fields/IconPicker/iconCatalog.d.ts +3 -0
  56. package/dist/schema/addressSchema.d.ts +3 -0
  57. package/dist/schema/backgroundStyleDefinitions.d.ts +10 -0
  58. package/dist/schema/device/deviceStyle.d.ts +13 -0
  59. package/dist/schema/device/devices.d.ts +21 -0
  60. package/dist/schema/deviceSettings.d.ts +13 -0
  61. package/dist/schema/deviceVisibility.d.ts +19 -0
  62. package/dist/schema/elementConfiguration.d.ts +38 -0
  63. package/dist/schema/elementRegistry.d.ts +40 -0
  64. package/dist/schema/elementStyleDefinitions.d.ts +24 -0
  65. package/dist/schema/elementTemplates.d.ts +26 -0
  66. package/dist/schema/layoutChildren.d.ts +2 -0
  67. package/dist/schema/layoutElementConfiguration.d.ts +17 -0
  68. package/dist/schema/linkSettings.d.ts +26 -0
  69. package/dist/schema/style/backgroundStyle.d.ts +5 -0
  70. package/dist/schema/style/elementStyle.d.ts +62 -0
  71. package/dist/schema/style/page-styles.d.ts +3 -0
  72. package/dist/schema/styleItems.d.ts +53 -0
  73. package/dist/schema/styleTokensSchema.d.ts +274 -0
  74. package/dist/schema/textItems.d.ts +10 -0
  75. package/dist/styleToClasses-CZSWp6Ez.js +683 -0
  76. package/dist/templates/elementSpec.d.ts +10 -0
  77. package/dist/templates/helpers.d.ts +17 -0
  78. package/dist/templates.d.ts +13 -0
  79. package/dist/templates.js +349 -0
  80. package/package.json +31 -5
@@ -1,115 +0,0 @@
1
- // src/PlmtElement.ts
2
- var e = class extends HTMLElement {
3
- static observedAttributes = [];
4
- attributeChangedCallback(e, t, n) {
5
- this.syncFromAttributes();
6
- }
7
- connectedCallback() {
8
- this.syncFromAttributes();
9
- }
10
- syncFromAttributes() {}
11
- };
12
- function t(e, t) {
13
- customElements.get(e) || customElements.define(e, t);
14
- }
15
- // src/elements/page/PlmtPage.ts
16
- var n = "a[href], button, input, textarea, select", r = class extends e {
17
- static observedAttributes = ["editing"];
18
- #e = (e) => {
19
- if (!this.hasAttribute("editing")) return;
20
- let t = e.target;
21
- t instanceof Element && t.closest("a[href], button[type=\"submit\"]") && (e.preventDefault(), e.stopPropagation());
22
- };
23
- connectedCallback() {
24
- super.connectedCallback(), this.addEventListener("click", this.#e, !0);
25
- }
26
- disconnectedCallback() {
27
- this.removeEventListener("click", this.#e, !0);
28
- }
29
- syncFromAttributes() {
30
- let e = this.hasAttribute("editing");
31
- for (let t of this.querySelectorAll(n)) e ? this.#t(t) : this.#n(t);
32
- }
33
- #t(e) {
34
- e instanceof HTMLInputElement || e instanceof HTMLTextAreaElement ? (e.readOnly = !0, e.tabIndex = -1) : e instanceof HTMLSelectElement ? (e.setAttribute("aria-disabled", "true"), e.tabIndex = -1) : (e instanceof HTMLButtonElement || e instanceof HTMLAnchorElement) && (e.tabIndex = -1);
35
- }
36
- #n(e) {
37
- e instanceof HTMLInputElement || e instanceof HTMLTextAreaElement ? (e.readOnly = !1, e.removeAttribute("tabindex")) : e instanceof HTMLSelectElement ? (e.removeAttribute("aria-disabled"), e.removeAttribute("tabindex")) : (e instanceof HTMLButtonElement || e instanceof HTMLAnchorElement) && e.removeAttribute("tabindex");
38
- }
39
- };
40
- t("plmt-page", r);
41
- // src/elements/section/PlmtSection.ts
42
- var i = class extends e {};
43
- t("plmt-section", i);
44
- // src/elements/container/PlmtContainer.ts
45
- var a = class extends e {};
46
- t("plmt-container", a);
47
- // src/elements/button/PlmtButton.ts
48
- var o = class extends e {};
49
- t("plmt-button", o);
50
- // src/elements/text/PlmtText.ts
51
- var s = class extends e {};
52
- t("plmt-text", s);
53
- // src/elements/rich-text/PlmtRichText.ts
54
- var c = class extends e {};
55
- t("plmt-rich-text", c);
56
- // src/elements/image/PlmtImage.ts
57
- var l = class extends e {};
58
- t("plmt-image", l);
59
- // src/elements/video/PlmtVideo.ts
60
- var u = class extends e {};
61
- t("plmt-video", u);
62
- // src/elements/list/PlmtList.ts
63
- var d = class extends e {};
64
- t("plmt-list", d);
65
- // src/elements/icon/PlmtIcon.ts
66
- var f = class extends e {
67
- static observedAttributes = ["name", "label"];
68
- syncFromAttributes() {
69
- let e = this.getAttribute("label")?.trim() ?? "";
70
- e ? (this.setAttribute("role", "img"), this.setAttribute("aria-label", e), this.removeAttribute("aria-hidden")) : (this.removeAttribute("role"), this.removeAttribute("aria-label"), this.setAttribute("aria-hidden", "true"));
71
- }
72
- };
73
- t("plmt-icon", f);
74
- // src/elements/divider/PlmtDivider.ts
75
- var p = class extends e {};
76
- t("plmt-divider", p);
77
- // src/elements/table/PlmtTable.ts
78
- var m = class extends e {};
79
- t("plmt-table", m);
80
- // src/elements/text-field/PlmtTextField.ts
81
- var h = class extends e {};
82
- t("plmt-text-field", h);
83
- // src/elements/text-area/PlmtTextArea.ts
84
- var g = class extends e {};
85
- t("plmt-text-area", g);
86
- // src/elements/checkbox/PlmtCheckbox.ts
87
- var _ = class extends e {};
88
- t("plmt-checkbox", _);
89
- // src/elements/radio/PlmtRadio.ts
90
- var v = class extends e {};
91
- t("plmt-radio", v);
92
- // src/elements/select/PlmtSelect.ts
93
- var y = class extends e {};
94
- t("plmt-select", y);
95
- // src/tags.ts
96
- var b = [
97
- "plmt-page",
98
- "plmt-section",
99
- "plmt-container",
100
- "plmt-button",
101
- "plmt-text",
102
- "plmt-rich-text",
103
- "plmt-image",
104
- "plmt-video",
105
- "plmt-list",
106
- "plmt-icon",
107
- "plmt-divider",
108
- "plmt-table",
109
- "plmt-text-field",
110
- "plmt-text-area",
111
- "plmt-checkbox",
112
- "plmt-radio",
113
- "plmt-select"
114
- ];
115
- export { b as PLMT_TAGS, o as PlmtButton, _ as PlmtCheckbox, a as PlmtContainer, p as PlmtDivider, e as PlmtElement, f as PlmtIcon, l as PlmtImage, d as PlmtList, r as PlmtPage, v as PlmtRadio, c as PlmtRichText, i as PlmtSection, y as PlmtSelect, m as PlmtTable, s as PlmtText, g as PlmtTextArea, h as PlmtTextField, u as PlmtVideo, t as define };
@@ -0,0 +1,9 @@
1
+ import { ElementType, RegisteredElementConfiguration } from './schema/elementConfiguration';
2
+ import { elementSpec, toElementTree, ShortcodeNode } from './templates/elementSpec';
3
+ import { ElementSpec, ElementSpecOptions } from './render/types';
4
+ export type ElementEntry = {
5
+ definition: RegisteredElementConfiguration;
6
+ template: (node: ShortcodeNode, options?: ElementSpecOptions) => ElementSpec | null;
7
+ };
8
+ export declare const registry: Record<ElementType, ElementEntry>;
9
+ export { elementSpec, toElementTree };
@@ -0,0 +1,5 @@
1
+ import { ElementSpec } from './types';
2
+ export declare function escapeHtml(value: unknown): string;
3
+ /** Drop script/style blocks, event handlers, and javascript: URLs from rich text. */
4
+ export declare function sanitizeRichTextHtml(html: string): string;
5
+ export declare function renderHtml(node: ElementSpec | string): string;
@@ -0,0 +1,35 @@
1
+ import { ElementType } from '../schema/elementConfiguration';
2
+ export type DeviceStyleProps = {
3
+ style?: Record<string, unknown>;
4
+ tabletStyle?: Record<string, unknown>;
5
+ mobileStyle?: Record<string, unknown>;
6
+ tabletLandscapeStyle?: Record<string, unknown>;
7
+ mobileLandscapeStyle?: Record<string, unknown>;
8
+ };
9
+ type VariantPrefix = '' | 'tablet:' | 'mobile:' | 'tablet-landscape:' | 'mobile-landscape:';
10
+ /**
11
+ * Turn one style object into utility classes. Values that cannot map onto a
12
+ * Tailwind token are collected in `unresolved` for CSS variables.
13
+ */
14
+ export declare function styleObjectToClasses(type: ElementType, style: Record<string, unknown> | undefined, variant?: VariantPrefix): {
15
+ classes: string[];
16
+ unresolved: Record<string, unknown>;
17
+ };
18
+ /**
19
+ * Classes for an element: type defaults, then desktop style, then device variants.
20
+ * Later entries win in the cascade when variants apply; within one breakpoint the
21
+ * last class for a conflicting property should not be duplicated by the caller.
22
+ */
23
+ export declare function styleToClasses(type: ElementType, props: DeviceStyleProps): string[];
24
+ /**
25
+ * Style keys that still need `--palmyit-*` variables (font family, gradients,
26
+ * off-scale lengths, hex colors outside the palette).
27
+ */
28
+ export declare function unresolvedStyleForVars(type: ElementType, style: Record<string, unknown> | undefined): Record<string, unknown>;
29
+ /** Convert page style tokens into values styleToCssVariables can write. */
30
+ export declare function pageTokensToVarValues(props: {
31
+ backgroundColor?: unknown;
32
+ textColor?: unknown;
33
+ textSize?: unknown;
34
+ }): Record<string, unknown>;
35
+ export {};
@@ -0,0 +1,2 @@
1
+ import { CssVariables } from './types';
2
+ export declare function styleToCssVariables(style: Record<string, unknown> | undefined, prefix: string): CssVariables;
@@ -0,0 +1,57 @@
1
+ /** Spacing / sizing keys on Tailwind's default scale, plus auto. */
2
+ export declare const SPACING_TOKENS: readonly ["0", "px", "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", "auto"];
3
+ export type SpacingToken = (typeof SPACING_TOKENS)[number];
4
+ export declare const BORDER_WIDTH_TOKENS: readonly ["0", "1", "2", "4", "8"];
5
+ export type BorderWidthToken = (typeof BORDER_WIDTH_TOKENS)[number];
6
+ export declare const RADIUS_TOKENS: readonly ["none", "sm", "md", "lg", "xl", "2xl", "3xl", "full", "0", "px", "0.5", "1", "1.5", "2", "2.5", "3", "3.5", "4", "5", "6", "7", "8", "9", "10", "11", "12", "14", "16"];
7
+ export type RadiusToken = (typeof RADIUS_TOKENS)[number];
8
+ export declare const TEXT_SIZE_TOKENS: readonly ["xs", "sm", "base", "lg", "xl", "2xl", "3xl", "4xl", "5xl", "6xl"];
9
+ export type TextSizeToken = (typeof TEXT_SIZE_TOKENS)[number];
10
+ export declare const LEADING_TOKENS: readonly ["none", "tight", "snug", "normal", "relaxed", "loose", "3", "4", "5", "6", "7", "8", "9", "10"];
11
+ export type LeadingToken = (typeof LEADING_TOKENS)[number];
12
+ export declare const TRACKING_TOKENS: readonly ["tighter", "tight", "normal", "wide", "wider", "widest"];
13
+ export type TrackingToken = (typeof TRACKING_TOKENS)[number];
14
+ export declare const COLOR_NAMES: readonly ["accent", "transparent", "white", "black", "slate-50", "slate-100", "slate-200", "slate-300", "slate-400", "slate-500", "slate-600", "slate-700", "slate-800", "slate-900", "slate-950"];
15
+ export type ColorName = (typeof COLOR_NAMES)[number];
16
+ export declare const OPACITY_STEPS: readonly [0, 5, 10, 15, 20, 25, 30, 40, 50, 60, 70, 75, 80, 90, 95, 100];
17
+ export type OpacityStep = (typeof OPACITY_STEPS)[number];
18
+ /** Palette color stored on an element. Hex colors remain supported for legacy docs. */
19
+ export type PaletteColor = {
20
+ name: ColorName;
21
+ opacity: OpacityStep;
22
+ };
23
+ export type StyleColor = PaletteColor | {
24
+ hex: string;
25
+ opacity: number;
26
+ };
27
+ export declare function isSpacingToken(value: string): value is SpacingToken;
28
+ export declare function isBorderWidthToken(value: string): value is BorderWidthToken;
29
+ export declare function isRadiusToken(value: string): value is RadiusToken;
30
+ export declare function isTextSizeToken(value: string): value is TextSizeToken;
31
+ export declare function isLeadingToken(value: string): value is LeadingToken;
32
+ export declare function isTrackingToken(value: string): value is TrackingToken;
33
+ export declare function isPaletteColor(value: unknown): value is PaletteColor;
34
+ export declare function isHexColor(value: unknown): value is {
35
+ hex: string;
36
+ opacity: number;
37
+ };
38
+ /** Map a CSS length (or token) onto the spacing scale when it lands exactly. */
39
+ export declare function toSpacingToken(value: unknown): SpacingToken | undefined;
40
+ export declare function toBorderWidthToken(value: unknown): BorderWidthToken | undefined;
41
+ export declare function toRadiusToken(value: unknown): RadiusToken | undefined;
42
+ export declare function toTextSizeToken(value: unknown): TextSizeToken | undefined;
43
+ export declare function toLeadingToken(value: unknown): LeadingToken | undefined;
44
+ export declare function toTrackingToken(value: unknown): TrackingToken | undefined;
45
+ export declare function toPaletteColor(value: unknown): PaletteColor | undefined;
46
+ export declare function fontWeightClass(value: unknown): string | undefined;
47
+ export declare function colorClass(prefix: 'bg' | 'text' | 'border', color: PaletteColor): string;
48
+ export declare function spacingClass(prefix: string, token: SpacingToken): string;
49
+ export declare function radiusClass(corner: string, token: RadiusToken): string;
50
+ export declare function borderWidthClass(token: BorderWidthToken): string;
51
+ export declare function textSizeClass(token: TextSizeToken): string;
52
+ export declare function leadingClass(token: LeadingToken): string;
53
+ export declare function trackingClass(token: TrackingToken): string;
54
+ /** CSS value for a text-size token, used for page theme variables. */
55
+ export declare function textSizeTokenToCss(token: TextSizeToken): string;
56
+ /** CSS value for a palette color (for page theme variables). */
57
+ export declare function paletteColorToCss(color: PaletteColor): string | undefined;
@@ -0,0 +1,42 @@
1
+ import { ElementType } from '../schema/elementConfiguration';
2
+ /** CSS class hook for each shortcode element type. */
3
+ export declare const tags: {
4
+ readonly PPage: "plmt-page";
5
+ readonly PSection: "plmt-section";
6
+ readonly PContainer: "plmt-container";
7
+ readonly PButton: "plmt-button";
8
+ readonly PText: "plmt-text";
9
+ readonly PRichText: "plmt-rich-text";
10
+ readonly PImage: "plmt-image";
11
+ readonly PVideo: "plmt-video";
12
+ readonly PList: "plmt-list";
13
+ readonly PIcon: "plmt-icon";
14
+ readonly PDivider: "plmt-divider";
15
+ readonly PTable: "plmt-table";
16
+ readonly PTextField: "plmt-text-field";
17
+ readonly PTextArea: "plmt-text-area";
18
+ readonly PCheckbox: "plmt-checkbox";
19
+ readonly PRadio: "plmt-radio";
20
+ readonly PSelect: "plmt-select";
21
+ };
22
+ export type ShortcodeTag = (typeof tags)[ElementType];
23
+ /** Semantic HTML tag for each element type (Stage 3). */
24
+ export declare const semanticTags: {
25
+ readonly PPage: "main";
26
+ readonly PSection: "section";
27
+ readonly PContainer: "div";
28
+ readonly PButton: "button";
29
+ readonly PText: "p";
30
+ readonly PRichText: "div";
31
+ readonly PImage: "img";
32
+ readonly PVideo: "video";
33
+ readonly PList: "ul";
34
+ readonly PIcon: "span";
35
+ readonly PDivider: "hr";
36
+ readonly PTable: "div";
37
+ readonly PTextField: "div";
38
+ readonly PTextArea: "div";
39
+ readonly PCheckbox: "div";
40
+ readonly PRadio: "fieldset";
41
+ readonly PSelect: "div";
42
+ };
@@ -0,0 +1,3 @@
1
+ import { ElementSpec } from './types';
2
+ /** Turn an ElementSpec into a real DOM node (for Storybook / tests). */
3
+ export declare function toDom(node: ElementSpec | string): Node;
@@ -0,0 +1,20 @@
1
+ import { ElementType } from '../schema/elementConfiguration';
2
+ export type ElementAttribute = string | number | boolean | undefined;
3
+ export type CssVariables = Record<string, string | undefined>;
4
+ export type ElementSpec = {
5
+ tag: string;
6
+ attrs: Record<string, ElementAttribute>;
7
+ styleVars: CssVariables;
8
+ children?: Array<ElementSpec | string> | {
9
+ html: string;
10
+ };
11
+ };
12
+ export type ElementSpecOptions = {
13
+ /** Layout host children (from Puck slots or recursion). Ignored for leaf elements. */
14
+ children?: Array<ElementSpec | string>;
15
+ };
16
+ export type ShortcodeNode = {
17
+ type: ElementType;
18
+ props: Record<string, unknown>;
19
+ children?: ShortcodeNode[];
20
+ };
@@ -0,0 +1,16 @@
1
+ import { StyleColor } from '../../../render/styleTokens';
2
+ export type BackgroundType = 'color' | 'gradient';
3
+ export type GradientKind = 'linear' | 'radial';
4
+ export type GradientValue = {
5
+ kind: GradientKind;
6
+ value: string;
7
+ };
8
+ export type BackgroundStyle = {
9
+ backgroundType: BackgroundType;
10
+ backgroundColor: StyleColor;
11
+ /** Present only when the author picks a gradient fill. */
12
+ backgroundGradient?: GradientValue;
13
+ };
14
+ export declare const MAX_GRADIENT_ARGS_LENGTH = 200;
15
+ export declare function isSafeGradientArgs(value: string): boolean;
16
+ export declare function gradientToCss(gradient: GradientValue): string | undefined;
@@ -0,0 +1,6 @@
1
+ export type ColorValue = {
2
+ hex: string;
3
+ opacity: number;
4
+ };
5
+ export declare function toHexAlpha(value: ColorValue): string;
6
+ export declare function fromHexAlpha(color: string): ColorValue | null;
@@ -0,0 +1 @@
1
+ export * from './color-value';
@@ -0,0 +1,2 @@
1
+ export declare const FONT_STYLES: readonly ["normal", "italic", "oblique"];
2
+ export type FontStyle = (typeof FONT_STYLES)[number];
@@ -0,0 +1,3 @@
1
+ export declare const NO_ICON = "";
2
+ export declare function isOutlineIconName(value: string): boolean;
3
+ export declare function labelForIcon(value: string): string;
@@ -0,0 +1,3 @@
1
+ import { z } from 'zod';
2
+ /** An http(s) URL or a single-slash path on the same site. Other schemes and relative paths are rejected. */
3
+ export declare const addressSchema: z.ZodString;
@@ -0,0 +1,10 @@
1
+ import { BackgroundStyle } from './Fields/BackgroundField/backgroundValue';
2
+ import { StyleDefinition } from './styleItems';
3
+ export { colorValue } from './styleTokensSchema';
4
+ type BackgroundDefinitionOptions = {
5
+ /** Omit to leave every background key unset until the user picks one. */
6
+ defaults?: BackgroundStyle;
7
+ /** A data attribute the element sets while it has a background type. */
8
+ typeAttribute?: string;
9
+ };
10
+ export declare function backgroundStyleDefinitions(prefix: string, { defaults, typeAttribute }?: BackgroundDefinitionOptions): StyleDefinition[];
@@ -0,0 +1,13 @@
1
+ import { DeviceName, Orientation } from './devices';
2
+ export type DeviceStyleProp = 'style' | 'tabletStyle' | 'mobileStyle' | 'tabletLandscapeStyle' | 'mobileLandscapeStyle';
3
+ export type DeviceStyles<TStyle> = {
4
+ style: TStyle;
5
+ } & Partial<Record<Exclude<DeviceStyleProp, 'style'>, Partial<TStyle>>>;
6
+ /** The prop a style edit on this device and orientation writes to. */
7
+ export declare function deviceStyleProp(device: DeviceName, orientation?: Orientation): DeviceStyleProp;
8
+ /** The override stored for exactly this device and orientation; Desktop has none. */
9
+ export declare function deviceOverride<TStyle>(styles: DeviceStyles<TStyle>, device: DeviceName, orientation?: Orientation): Partial<TStyle>;
10
+ /** The keys of `next` set to a different value than in `previous`. */
11
+ export declare function changedStyle<TStyle extends object>(previous: TStyle, next: Partial<TStyle>): Partial<TStyle>;
12
+ /** Desktop, then the device's portrait override, then in landscape its landscape override. */
13
+ export declare function resolveDeviceStyle<TStyle>(styles: DeviceStyles<TStyle>, device: DeviceName, orientation?: Orientation): TStyle;
@@ -0,0 +1,21 @@
1
+ export type DeviceName = 'Desktop' | 'Tablet' | 'Mobile';
2
+ export type Orientation = 'portrait' | 'landscape';
3
+ export type ViewportSize = {
4
+ width: number;
5
+ height: number | 'auto';
6
+ };
7
+ export type BuilderDevice = {
8
+ name: DeviceName;
9
+ icon: 'Monitor' | 'Tablet' | 'Smartphone';
10
+ portrait: ViewportSize;
11
+ landscape?: ViewportSize;
12
+ };
13
+ export declare const builderDevices: BuilderDevice[];
14
+ export declare const builderViewports: {
15
+ icon: "Tablet" | "Monitor" | "Smartphone";
16
+ label: DeviceName;
17
+ width: number;
18
+ height: number | "auto";
19
+ }[];
20
+ export declare function deviceForWidth(width: number | '100%'): BuilderDevice;
21
+ export declare function orientationForWidth(width: number | '100%'): Orientation;
@@ -0,0 +1,13 @@
1
+ import { DeviceStyleProp } from './device/deviceStyle';
2
+ import { ElementConfiguration } from './elementConfiguration';
3
+ import { DeviceVisibility } from './deviceVisibility';
4
+ import { StyleDefinition } from './styleItems';
5
+ type OverrideProp = Exclude<DeviceStyleProp, 'style'>;
6
+ export type DeviceStyleOverrides<TStyle> = Partial<Record<OverrideProp, Partial<TStyle>>>;
7
+ /**
8
+ * Adds the Show for devices flags to an element, and, when it has `styles`,
9
+ * portrait and landscape Tablet and Mobile overrides of those styles. Publish
10
+ * writes only flags that change visibility and overrides that are set.
11
+ */
12
+ export declare function withDeviceSettings<TProps>(configuration: ElementConfiguration<TProps>, styles?: StyleDefinition[]): ElementConfiguration<TProps & Partial<DeviceVisibility> & DeviceStyleOverrides<Record<string, unknown>>>;
13
+ export {};
@@ -0,0 +1,19 @@
1
+ import { DeviceName, Orientation } from './device/devices';
2
+ export type DeviceVisibilityProp = 'showOnDesktop' | 'showOnTablet' | 'showOnMobile' | 'showOnTabletLandscape' | 'showOnMobileLandscape';
3
+ export type DeviceVisibility = Record<DeviceVisibilityProp, boolean>;
4
+ export declare const VISIBILITY_PROP_BY_DEVICE: Record<DeviceName, DeviceVisibilityProp>;
5
+ export declare const LANDSCAPE_VISIBILITY_PROP_BY_DEVICE: Partial<Record<DeviceName, DeviceVisibilityProp>>;
6
+ export declare const VISIBILITY_PROPS: DeviceVisibilityProp[];
7
+ /** One Show for devices checkbox: a device, in one orientation when it has a landscape. */
8
+ export type DeviceChoice = {
9
+ device: DeviceName;
10
+ orientation: Orientation;
11
+ };
12
+ export declare const DEVICE_CHOICES: DeviceChoice[];
13
+ export declare function visibilityProp(device: DeviceName, orientation: Orientation): DeviceVisibilityProp;
14
+ /**
15
+ * An element without the flag is shown, so pages saved before device settings stay visible.
16
+ * An omitted landscape flag follows the device's portrait flag.
17
+ */
18
+ export declare function isShownOn(props: Partial<DeviceVisibility>, device: DeviceName, orientation?: Orientation): boolean;
19
+ export declare function shownDeviceCount(props: Partial<DeviceVisibility>): number;
@@ -0,0 +1,38 @@
1
+ import { z } from 'zod';
2
+ import { ElementTemplate } from './elementTemplates';
3
+ export type ElementType = 'PPage' | 'PSection' | 'PContainer' | 'PButton' | 'PText' | 'PRichText' | 'PImage' | 'PVideo' | 'PList' | 'PIcon' | 'PDivider' | 'PTextField' | 'PTextArea' | 'PCheckbox' | 'PRadio' | 'PSelect' | 'PTable';
4
+ export type DocumentAttributes = Record<string, unknown>;
5
+ /**
6
+ * The words the page history uses for an element. `summary` names one
7
+ * instance (a button's label). `attributes` names each editable prop path,
8
+ * such as `name` or `style.paddingTop`.
9
+ */
10
+ export type ElementHistory<TProps> = {
11
+ summary: (props: TProps) => string;
12
+ attributes: Readonly<Record<string, string>>;
13
+ };
14
+ /**
15
+ * `attributes` parses a document node's attributes (every key except `type`
16
+ * and `children`) into the props the canvas renders. `toDocumentAttributes`
17
+ * is the reverse, used on publish before the same schema runs again.
18
+ */
19
+ export type ElementConfiguration<TProps = Record<string, unknown>> = {
20
+ type: ElementType;
21
+ label: string;
22
+ attributes: z.ZodType<TProps>;
23
+ allowedChildren: readonly ElementType[];
24
+ templates: readonly ElementTemplate[];
25
+ toDocumentAttributes: (props: TProps) => DocumentAttributes;
26
+ history: ElementHistory<TProps>;
27
+ };
28
+ export type RegisteredElementConfiguration = {
29
+ type: ElementType;
30
+ label: string;
31
+ attributes: z.ZodType;
32
+ allowedChildren: readonly ElementType[];
33
+ templates: readonly ElementTemplate[];
34
+ toDocumentAttributes: (props: never) => DocumentAttributes;
35
+ history: ElementHistory<never>;
36
+ };
37
+ export declare const elementIdSchema: z.ZodString;
38
+ export declare function defineElement<TProps>(configuration: ElementConfiguration<TProps>): ElementConfiguration<TProps>;
@@ -0,0 +1,40 @@
1
+ import { ElementType } from './elementConfiguration';
2
+ export declare const elementRegistry: {
3
+ PPage: import('./elementConfiguration').ElementConfiguration<import('../definitions').PPageRootProps>;
4
+ PSection: import('./elementConfiguration').ElementConfiguration<import('./layoutElementConfiguration').LayoutElementProps & Partial<import('./deviceVisibility').DeviceVisibility> & Partial<Record<"tabletStyle" | "mobileStyle" | "tabletLandscapeStyle" | "mobileLandscapeStyle", Partial<Record<string, unknown>>>>>;
5
+ PContainer: import('./elementConfiguration').ElementConfiguration<import('./layoutElementConfiguration').LayoutElementProps & Partial<import('./deviceVisibility').DeviceVisibility> & Partial<Record<"tabletStyle" | "mobileStyle" | "tabletLandscapeStyle" | "mobileLandscapeStyle", Partial<Record<string, unknown>>>>>;
6
+ PButton: import('./elementConfiguration').ElementConfiguration<import('./linkSettings').LinkSettings & {
7
+ id: string;
8
+ name: string;
9
+ startIcon: string;
10
+ endIcon: string;
11
+ style: import('../definitions').ButtonStyle;
12
+ } & Partial<import('./deviceVisibility').DeviceVisibility> & Partial<Record<"tabletStyle" | "mobileStyle" | "tabletLandscapeStyle" | "mobileLandscapeStyle", Partial<Record<string, unknown>>>>>;
13
+ PText: import('./elementConfiguration').ElementConfiguration<import('./linkSettings').LinkSettings & {
14
+ id: string;
15
+ text: string;
16
+ style: import('../definitions').TextStyle;
17
+ } & Partial<import('./deviceVisibility').DeviceVisibility> & Partial<Record<"tabletStyle" | "mobileStyle" | "tabletLandscapeStyle" | "mobileLandscapeStyle", Partial<Record<string, unknown>>>>>;
18
+ PRichText: import('./elementConfiguration').ElementConfiguration<import('../elements/rich-text/definition').PRichTextDocumentProps & Partial<import('./deviceVisibility').DeviceVisibility> & Partial<Record<"tabletStyle" | "mobileStyle" | "tabletLandscapeStyle" | "mobileLandscapeStyle", Partial<Record<string, unknown>>>>>;
19
+ PImage: import('./elementConfiguration').ElementConfiguration<import('./linkSettings').LinkSettings & {
20
+ id: string;
21
+ src: string;
22
+ alt: string;
23
+ style: import('../definitions').ImageStyle;
24
+ } & Partial<import('./deviceVisibility').DeviceVisibility> & Partial<Record<"tabletStyle" | "mobileStyle" | "tabletLandscapeStyle" | "mobileLandscapeStyle", Partial<Record<string, unknown>>>>>;
25
+ PVideo: import('./elementConfiguration').ElementConfiguration<import('../elements/video/definition').PVideoDocumentProps & Partial<import('./deviceVisibility').DeviceVisibility> & Partial<Record<"tabletStyle" | "mobileStyle" | "tabletLandscapeStyle" | "mobileLandscapeStyle", Partial<Record<string, unknown>>>>>;
26
+ PList: import('./elementConfiguration').ElementConfiguration<import('../elements/list/definition').PListDocumentProps & Partial<import('./deviceVisibility').DeviceVisibility> & Partial<Record<"tabletStyle" | "mobileStyle" | "tabletLandscapeStyle" | "mobileLandscapeStyle", Partial<Record<string, unknown>>>>>;
27
+ PIcon: import('./elementConfiguration').ElementConfiguration<import('./linkSettings').LinkSettings & {
28
+ id: string;
29
+ icon: string;
30
+ label: string;
31
+ } & Partial<import('./deviceVisibility').DeviceVisibility> & Partial<Record<"tabletStyle" | "mobileStyle" | "tabletLandscapeStyle" | "mobileLandscapeStyle", Partial<Record<string, unknown>>>>>;
32
+ PDivider: import('./elementConfiguration').ElementConfiguration<import('../elements/divider/definition').PDividerDocumentProps & Partial<import('./deviceVisibility').DeviceVisibility> & Partial<Record<"tabletStyle" | "mobileStyle" | "tabletLandscapeStyle" | "mobileLandscapeStyle", Partial<Record<string, unknown>>>>>;
33
+ PTextField: import('./elementConfiguration').ElementConfiguration<import('../elements/text-field/definition').PTextFieldDocumentProps & Partial<import('./deviceVisibility').DeviceVisibility> & Partial<Record<"tabletStyle" | "mobileStyle" | "tabletLandscapeStyle" | "mobileLandscapeStyle", Partial<Record<string, unknown>>>>>;
34
+ PTextArea: import('./elementConfiguration').ElementConfiguration<import('../elements/text-area/definition').PTextAreaDocumentProps & Partial<import('./deviceVisibility').DeviceVisibility> & Partial<Record<"tabletStyle" | "mobileStyle" | "tabletLandscapeStyle" | "mobileLandscapeStyle", Partial<Record<string, unknown>>>>>;
35
+ PCheckbox: import('./elementConfiguration').ElementConfiguration<import('../elements/checkbox/definition').PCheckboxDocumentProps & Partial<import('./deviceVisibility').DeviceVisibility> & Partial<Record<"tabletStyle" | "mobileStyle" | "tabletLandscapeStyle" | "mobileLandscapeStyle", Partial<Record<string, unknown>>>>>;
36
+ PRadio: import('./elementConfiguration').ElementConfiguration<import('../elements/radio/definition').PRadioDocumentProps & Partial<import('./deviceVisibility').DeviceVisibility> & Partial<Record<"tabletStyle" | "mobileStyle" | "tabletLandscapeStyle" | "mobileLandscapeStyle", Partial<Record<string, unknown>>>>>;
37
+ PSelect: import('./elementConfiguration').ElementConfiguration<import('../elements/select/definition').PSelectDocumentProps & Partial<import('./deviceVisibility').DeviceVisibility> & Partial<Record<"tabletStyle" | "mobileStyle" | "tabletLandscapeStyle" | "mobileLandscapeStyle", Partial<Record<string, unknown>>>>>;
38
+ PTable: import('./elementConfiguration').ElementConfiguration<import('../elements/table/definition').PTableDocumentProps & Partial<import('./deviceVisibility').DeviceVisibility> & Partial<Record<"tabletStyle" | "mobileStyle" | "tabletLandscapeStyle" | "mobileLandscapeStyle", Partial<Record<string, unknown>>>>>;
39
+ };
40
+ export declare function isElementType(value: unknown): value is ElementType;
@@ -0,0 +1,24 @@
1
+ import { z } from 'zod';
2
+ import { ElementStyle, ElementStyleKind } from './style/elementStyle';
3
+ import { StyleDefinition } from './styleItems';
4
+ export { lengthValue, colorValue, borderWidthValue } from './styleTokensSchema';
5
+ export declare const lengthKeys: readonly [readonly ["width", "width", "Width"], readonly ["height", "height", "Height"], readonly ["minWidth", "min-width", "Min width"], readonly ["minHeight", "min-height", "Min height"], readonly ["maxWidth", "max-width", "Max width"], readonly ["maxHeight", "max-height", "Max height"], readonly ["paddingTop", "padding-top", "Padding top"], readonly ["paddingBottom", "padding-bottom", "Padding bottom"], readonly ["paddingLeft", "padding-left", "Padding left"], readonly ["paddingRight", "padding-right", "Padding right"], readonly ["marginTop", "margin-top", "Margin top"], readonly ["marginBottom", "margin-bottom", "Margin bottom"], readonly ["marginLeft", "margin-left", "Margin left"], readonly ["marginRight", "margin-right", "Margin right"], readonly ["borderRadiusTopLeft", "border-top-left-radius", "Radius top left"], readonly ["borderRadiusTopRight", "border-top-right-radius", "Radius top right"], readonly ["borderRadiusBottomRight", "border-bottom-right-radius", "Radius bottom right"], readonly ["borderRadiusBottomLeft", "border-bottom-left-radius", "Radius bottom left"]];
6
+ export type LengthKey = (typeof lengthKeys)[number][0];
7
+ export declare function elementStyleDefinitions(kind: ElementStyleKind, defaults: ElementStyle): StyleDefinition[];
8
+ export declare function elementStyleSchema(definitions: StyleDefinition[], defaults: ElementStyle): z.ZodPipe<z.ZodPipe<z.ZodDefault<z.ZodArray<z.ZodObject<{
9
+ key: z.ZodString;
10
+ variable: z.ZodOptional<z.ZodString>;
11
+ variables: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
12
+ attribute: z.ZodOptional<z.ZodString>;
13
+ value: z.ZodUnknown;
14
+ }, z.core.$strict>>>, z.ZodTransform<{
15
+ [x: string]: unknown;
16
+ }, {
17
+ key: string;
18
+ value: unknown;
19
+ variable?: string | undefined;
20
+ variables?: Record<string, string> | undefined;
21
+ attribute?: string | undefined;
22
+ }[]>>, z.ZodTransform<ElementStyle, {
23
+ [x: string]: unknown;
24
+ }>>;
@@ -0,0 +1,26 @@
1
+ import { RegisteredElementConfiguration } from './elementConfiguration';
2
+ /**
3
+ * A preset shown on the Templates tab. `shortcode` is a JSON object in the
4
+ * page-document format. A style item without its address only works for a key
5
+ * the element already has. `children` replaces that element's content.
6
+ */
7
+ export type ElementTemplate = {
8
+ shortcode: string;
9
+ name: string;
10
+ /** Image URL the Templates tab shows in place of the name. */
11
+ graphic?: string;
12
+ };
13
+ export type TemplateContentItem = {
14
+ type: string;
15
+ props: Record<string, unknown>;
16
+ };
17
+ export type ApplyTemplateResult = {
18
+ ok: true;
19
+ props: Record<string, unknown>;
20
+ content?: TemplateContentItem[];
21
+ } | {
22
+ ok: false;
23
+ message: string;
24
+ };
25
+ /** Returns the element's props with the template merged in and validated. */
26
+ export declare function applyElementTemplate(configuration: RegisteredElementConfiguration, props: Record<string, unknown>, template: ElementTemplate): ApplyTemplateResult;
@@ -0,0 +1,2 @@
1
+ import { ElementType } from './elementConfiguration';
2
+ export declare const layoutChildren: readonly ElementType[];
@@ -0,0 +1,17 @@
1
+ import { ElementStyle, ElementStyleKind } from './style/elementStyle';
2
+ import { ElementType } from './elementConfiguration';
3
+ import { ElementTemplate } from './elementTemplates';
4
+ export type LayoutElementProps = {
5
+ id: string;
6
+ style: ElementStyle;
7
+ };
8
+ type LayoutElementOptions = {
9
+ type: ElementType;
10
+ label: string;
11
+ kind: ElementStyleKind;
12
+ defaultStyle: ElementStyle;
13
+ allowedChildren: readonly ElementType[];
14
+ templates: readonly ElementTemplate[];
15
+ };
16
+ export declare function defineLayoutElement({ type, label, kind, defaultStyle, allowedChildren, templates, }: LayoutElementOptions): import('./elementConfiguration').ElementConfiguration<LayoutElementProps & Partial<import('./deviceVisibility').DeviceVisibility> & Partial<Record<"tabletStyle" | "mobileStyle" | "tabletLandscapeStyle" | "mobileLandscapeStyle", Partial<Record<string, unknown>>>>>;
17
+ export {};
@@ -0,0 +1,26 @@
1
+ import { z } from 'zod';
2
+ import { DocumentAttributes } from './elementConfiguration';
3
+ export declare const LINK_TARGETS: readonly ["_self", "_blank"];
4
+ export type LinkTarget = (typeof LINK_TARGETS)[number];
5
+ /** An empty `href` means the element is not a link. */
6
+ export type LinkSettings = {
7
+ href: string;
8
+ target: LinkTarget;
9
+ description: string;
10
+ };
11
+ export declare const defaultLinkSettings: LinkSettings;
12
+ export declare const linkSettingsShape: {
13
+ href: z.ZodDefault<z.ZodPipe<z.ZodString, z.ZodUnion<readonly [z.ZodLiteral<"">, z.ZodString]>>>;
14
+ target: z.ZodDefault<z.ZodEnum<{
15
+ _self: "_self";
16
+ _blank: "_blank";
17
+ }>>;
18
+ description: z.ZodDefault<z.ZodString>;
19
+ };
20
+ export declare const linkHistoryLabels: {
21
+ href: string;
22
+ target: string;
23
+ description: string;
24
+ };
25
+ /** Writes only what differs from no link: the address, a new tab, and a description. */
26
+ export declare function toLinkAttributes({ href, target, description }: LinkSettings): DocumentAttributes;
@@ -0,0 +1,5 @@
1
+ import { BackgroundStyle } from '../Fields/BackgroundField/backgroundValue';
2
+ type CssVarMap = Record<string, string | undefined>;
3
+ /** Writes nothing until a background type is chosen, so the element keeps its own background. */
4
+ export declare function backgroundStyleToCssVariables(style: Partial<BackgroundStyle>, prefix: string): CssVarMap;
5
+ export {};