@palmyit/elements 0.0.0-stage → 0.1.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.
Files changed (60) hide show
  1. package/README.md +12 -2
  2. package/dist/definitions.d.ts +51 -0
  3. package/dist/definitions.js +1737 -0
  4. package/dist/manifest.json +7 -0
  5. package/dist/plmt-elements.css +2 -0
  6. package/dist/plmt-elements.js +0 -0
  7. package/dist/registry.d.ts +9 -0
  8. package/dist/render/renderHtml.d.ts +5 -0
  9. package/dist/render/styleToVars.d.ts +2 -0
  10. package/dist/render/tags.d.ts +42 -0
  11. package/dist/render/toDom.d.ts +3 -0
  12. package/dist/render/types.d.ts +14 -0
  13. package/dist/schema/Fields/BackgroundField/backgroundValue.d.ts +15 -0
  14. package/dist/schema/Fields/ColorField/color-value.d.ts +6 -0
  15. package/dist/schema/Fields/ColorField/index.d.ts +1 -0
  16. package/dist/schema/Fields/FontStyleField.d.ts +2 -0
  17. package/dist/schema/Fields/IconPicker/iconCatalog.d.ts +3 -0
  18. package/dist/schema/PButton/pButton.definition.d.ts +38 -0
  19. package/dist/schema/PCheckbox/pCheckbox.definition.d.ts +10 -0
  20. package/dist/schema/PContainer/pContainer.definition.d.ts +39 -0
  21. package/dist/schema/PDivider/pDivider.definition.d.ts +10 -0
  22. package/dist/schema/PIcon/pIcon.definition.d.ts +18 -0
  23. package/dist/schema/PImage/pImage.definition.d.ts +33 -0
  24. package/dist/schema/PList/pList.definition.d.ts +11 -0
  25. package/dist/schema/PPage/pPage.definition.d.ts +22 -0
  26. package/dist/schema/PRadio/pRadio.definition.d.ts +13 -0
  27. package/dist/schema/PRichText/pRichText.definition.d.ts +8 -0
  28. package/dist/schema/PRichText/richTextMarks.d.ts +4 -0
  29. package/dist/schema/PRichText/richTextOptions.d.ts +2 -0
  30. package/dist/schema/PSection/pSection.definition.d.ts +39 -0
  31. package/dist/schema/PSelect/pSelect.definition.d.ts +13 -0
  32. package/dist/schema/PTable/pTable.definition.d.ts +20 -0
  33. package/dist/schema/PText/pText.definition.d.ts +46 -0
  34. package/dist/schema/PTextArea/pTextArea.definition.d.ts +10 -0
  35. package/dist/schema/PTextField/pTextField.definition.d.ts +10 -0
  36. package/dist/schema/PVideo/pVideo.definition.d.ts +10 -0
  37. package/dist/schema/addressSchema.d.ts +3 -0
  38. package/dist/schema/backgroundStyleDefinitions.d.ts +15 -0
  39. package/dist/schema/device/deviceStyle.d.ts +13 -0
  40. package/dist/schema/device/devices.d.ts +21 -0
  41. package/dist/schema/deviceSettings.d.ts +13 -0
  42. package/dist/schema/deviceVisibility.d.ts +19 -0
  43. package/dist/schema/elementConfiguration.d.ts +38 -0
  44. package/dist/schema/elementRegistry.d.ts +40 -0
  45. package/dist/schema/elementStyleDefinitions.d.ts +24 -0
  46. package/dist/schema/elementTemplates.d.ts +26 -0
  47. package/dist/schema/layoutChildren.d.ts +2 -0
  48. package/dist/schema/layoutElementConfiguration.d.ts +17 -0
  49. package/dist/schema/linkSettings.d.ts +26 -0
  50. package/dist/schema/style/backgroundStyle.d.ts +5 -0
  51. package/dist/schema/style/elementStyle.d.ts +62 -0
  52. package/dist/schema/style/page-styles.d.ts +3 -0
  53. package/dist/schema/styleItems.d.ts +53 -0
  54. package/dist/schema/textItems.d.ts +10 -0
  55. package/dist/tags.json +19 -0
  56. package/dist/templates/elementSpec.d.ts +15 -0
  57. package/dist/templates/helpers.d.ts +9 -0
  58. package/dist/templates.d.ts +11 -0
  59. package/dist/templates.js +269 -0
  60. package/package.json +67 -4
@@ -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('./PPage/pPage.definition').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('./PButton/pButton.definition').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('./PText/pText.definition').TextStyle;
17
+ } & Partial<import('./deviceVisibility').DeviceVisibility> & Partial<Record<"tabletStyle" | "mobileStyle" | "tabletLandscapeStyle" | "mobileLandscapeStyle", Partial<Record<string, unknown>>>>>;
18
+ PRichText: import('./elementConfiguration').ElementConfiguration<import('./PRichText/pRichText.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('./PImage/pImage.definition').ImageStyle;
24
+ } & Partial<import('./deviceVisibility').DeviceVisibility> & Partial<Record<"tabletStyle" | "mobileStyle" | "tabletLandscapeStyle" | "mobileLandscapeStyle", Partial<Record<string, unknown>>>>>;
25
+ PVideo: import('./elementConfiguration').ElementConfiguration<import('./PVideo/pVideo.definition').PVideoDocumentProps & Partial<import('./deviceVisibility').DeviceVisibility> & Partial<Record<"tabletStyle" | "mobileStyle" | "tabletLandscapeStyle" | "mobileLandscapeStyle", Partial<Record<string, unknown>>>>>;
26
+ PList: import('./elementConfiguration').ElementConfiguration<import('./PList/pList.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('./PDivider/pDivider.definition').PDividerDocumentProps & Partial<import('./deviceVisibility').DeviceVisibility> & Partial<Record<"tabletStyle" | "mobileStyle" | "tabletLandscapeStyle" | "mobileLandscapeStyle", Partial<Record<string, unknown>>>>>;
33
+ PTextField: import('./elementConfiguration').ElementConfiguration<import('./PTextField/pTextField.definition').PTextFieldDocumentProps & Partial<import('./deviceVisibility').DeviceVisibility> & Partial<Record<"tabletStyle" | "mobileStyle" | "tabletLandscapeStyle" | "mobileLandscapeStyle", Partial<Record<string, unknown>>>>>;
34
+ PTextArea: import('./elementConfiguration').ElementConfiguration<import('./PTextArea/pTextArea.definition').PTextAreaDocumentProps & Partial<import('./deviceVisibility').DeviceVisibility> & Partial<Record<"tabletStyle" | "mobileStyle" | "tabletLandscapeStyle" | "mobileLandscapeStyle", Partial<Record<string, unknown>>>>>;
35
+ PCheckbox: import('./elementConfiguration').ElementConfiguration<import('./PCheckbox/pCheckbox.definition').PCheckboxDocumentProps & Partial<import('./deviceVisibility').DeviceVisibility> & Partial<Record<"tabletStyle" | "mobileStyle" | "tabletLandscapeStyle" | "mobileLandscapeStyle", Partial<Record<string, unknown>>>>>;
36
+ PRadio: import('./elementConfiguration').ElementConfiguration<import('./PRadio/pRadio.definition').PRadioDocumentProps & Partial<import('./deviceVisibility').DeviceVisibility> & Partial<Record<"tabletStyle" | "mobileStyle" | "tabletLandscapeStyle" | "mobileLandscapeStyle", Partial<Record<string, unknown>>>>>;
37
+ PSelect: import('./elementConfiguration').ElementConfiguration<import('./PSelect/pSelect.definition').PSelectDocumentProps & Partial<import('./deviceVisibility').DeviceVisibility> & Partial<Record<"tabletStyle" | "mobileStyle" | "tabletLandscapeStyle" | "mobileLandscapeStyle", Partial<Record<string, unknown>>>>>;
38
+ PTable: import('./elementConfiguration').ElementConfiguration<import('./PTable/pTable.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 declare const lengthValue: z.ZodString;
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 {};
@@ -0,0 +1,62 @@
1
+ import { BackgroundStyle } from '../Fields/BackgroundField/backgroundValue';
2
+ import { ColorValue } from '../Fields/ColorField/color-value';
3
+ export declare const BORDER_LINE_STYLES: readonly ["none", "solid", "dashed", "dotted", "double"];
4
+ export type BorderLineStyle = (typeof BORDER_LINE_STYLES)[number];
5
+ export declare const FLEX_DIRECTIONS: readonly ["row", "column", "row-reverse", "column-reverse"];
6
+ export declare const FLEX_WRAPS: readonly ["nowrap", "wrap", "wrap-reverse"];
7
+ export declare const FLEX_JUSTIFY_CONTENTS: readonly ["flex-start", "center", "flex-end", "space-between", "space-around", "space-evenly"];
8
+ export declare const FLEX_ALIGN_ITEMS: readonly ["stretch", "flex-start", "center", "flex-end", "baseline"];
9
+ export declare const FLEX_ALIGN_CONTENTS: readonly ["stretch", "flex-start", "center", "flex-end", "space-between", "space-around", "space-evenly"];
10
+ export type FlexDirection = (typeof FLEX_DIRECTIONS)[number];
11
+ export type FlexWrap = (typeof FLEX_WRAPS)[number];
12
+ export type FlexJustifyContent = (typeof FLEX_JUSTIFY_CONTENTS)[number];
13
+ export type FlexAlignItems = (typeof FLEX_ALIGN_ITEMS)[number];
14
+ export type FlexAlignContent = (typeof FLEX_ALIGN_CONTENTS)[number];
15
+ export type ElementLayout = 'block' | 'flex' | 'grid';
16
+ export type ElementOverflow = 'show' | 'hide';
17
+ export type GridColumnCount = 2 | 3 | 4;
18
+ export type ElementStyleKind = 'section' | 'container';
19
+ export type ElementStyle = {
20
+ layout: ElementLayout;
21
+ gridColumns?: GridColumnCount;
22
+ flexDirection: FlexDirection;
23
+ flexWrap: FlexWrap;
24
+ justifyContent: FlexJustifyContent;
25
+ alignItems: FlexAlignItems;
26
+ alignContent: FlexAlignContent;
27
+ rowGap: string;
28
+ columnGap: string;
29
+ overflow: ElementOverflow;
30
+ overflowVertical: boolean;
31
+ overflowHorizontal: boolean;
32
+ width: string;
33
+ height: string;
34
+ minWidth: string;
35
+ minHeight: string;
36
+ maxWidth: string;
37
+ maxHeight: string;
38
+ paddingTop: string;
39
+ paddingBottom: string;
40
+ paddingLeft: string;
41
+ paddingRight: string;
42
+ marginTop: string;
43
+ marginBottom: string;
44
+ marginLeft: string;
45
+ marginRight: string;
46
+ borderRadiusTopLeft: string;
47
+ borderRadiusTopRight: string;
48
+ borderRadiusBottomRight: string;
49
+ borderRadiusBottomLeft: string;
50
+ borderWidth: string;
51
+ borderStyle: BorderLineStyle;
52
+ borderColor: ColorValue;
53
+ } & BackgroundStyle;
54
+ export declare const defaultElementStyle: ElementStyle;
55
+ export declare const LENGTH_PATTERN: RegExp;
56
+ type CssVarMap = Record<string, string | undefined>;
57
+ export declare function sanitizeLength(value: string): string | undefined;
58
+ export declare function sanitizeAutoAsZero(value: string): string | undefined;
59
+ export declare function sanitizeMaxLength(value: string): string | undefined;
60
+ export declare function sanitizeBorderWidth(value: string): string | undefined;
61
+ export declare function elementStyleToCssVariables(storedStyle: ElementStyle, kind: ElementStyleKind): CssVarMap;
62
+ export {};
@@ -0,0 +1,3 @@
1
+ import { ColorValue } from '../Fields/ColorField/color-value';
2
+ export declare function colorValueToCss(value: ColorValue): string | undefined;
3
+ export declare function textSizeToCss(size: number): string | undefined;
@@ -0,0 +1,53 @@
1
+ import { z } from 'zod';
2
+ export type StyleItem = {
3
+ key: string;
4
+ variable?: string;
5
+ variables?: Record<string, string>;
6
+ attribute?: string;
7
+ value: unknown;
8
+ };
9
+ export type StyleDefinition = {
10
+ key: string;
11
+ variable?: string;
12
+ variables?: Record<string, string>;
13
+ attribute?: string;
14
+ value: z.ZodType;
15
+ /** Omit when the key has no default and is left out until set. */
16
+ defaultValue?: unknown;
17
+ /** How the page history names this key. */
18
+ label?: string;
19
+ };
20
+ type StyleValues = Record<string, unknown>;
21
+ export declare function styleItemsSchema(definitions: StyleDefinition[]): z.ZodPipe<z.ZodDefault<z.ZodArray<z.ZodObject<{
22
+ key: z.ZodString;
23
+ variable: z.ZodOptional<z.ZodString>;
24
+ variables: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
25
+ attribute: z.ZodOptional<z.ZodString>;
26
+ value: z.ZodUnknown;
27
+ }, z.core.$strict>>>, z.ZodTransform<StyleValues, {
28
+ key: string;
29
+ value: unknown;
30
+ variable?: string | undefined;
31
+ variables?: Record<string, string> | undefined;
32
+ attribute?: string | undefined;
33
+ }[]>>;
34
+ /** A device override: only the keys the document sets, with no defaults filled in. */
35
+ export declare function styleOverrideItemsSchema(definitions: StyleDefinition[]): z.ZodPipe<z.ZodDefault<z.ZodArray<z.ZodObject<{
36
+ key: z.ZodString;
37
+ variable: z.ZodOptional<z.ZodString>;
38
+ variables: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
39
+ attribute: z.ZodOptional<z.ZodString>;
40
+ value: z.ZodUnknown;
41
+ }, z.core.$strict>>>, z.ZodTransform<StyleValues, {
42
+ key: string;
43
+ value: unknown;
44
+ variable?: string | undefined;
45
+ variables?: Record<string, string> | undefined;
46
+ attribute?: string | undefined;
47
+ }[]>>;
48
+ /** History labels keyed by the prop path that holds each style key. */
49
+ export declare function styleLabels(definitions: StyleDefinition[], pathPrefix?: string): Record<string, string>;
50
+ /** Keys missing from `values` (or an absent `values`) use the definition default. */
51
+ export declare function toStyleItems(values: StyleValues | undefined, definitions: StyleDefinition[]): StyleItem[];
52
+ export declare function toStyleOverrideItems(values: StyleValues | undefined, definitions: StyleDefinition[]): StyleItem[];
53
+ export {};
@@ -0,0 +1,10 @@
1
+ import { z } from 'zod';
2
+ /** One entry of a repeating text value: a list item, an option, or a column heading. */
3
+ export type TextItem = {
4
+ text: string;
5
+ };
6
+ export declare function textItemsSchema(emptyListMessage: string, blankItemMessage: string): z.ZodArray<z.ZodObject<{
7
+ text: z.ZodString;
8
+ }, z.core.$strict>>;
9
+ /** Keeps only `text`, dropping keys the editor adds to array items. */
10
+ export declare function toTextItems(items: readonly TextItem[]): TextItem[];
package/dist/tags.json ADDED
@@ -0,0 +1,19 @@
1
+ [
2
+ "plmt-page",
3
+ "plmt-section",
4
+ "plmt-container",
5
+ "plmt-button",
6
+ "plmt-text",
7
+ "plmt-rich-text",
8
+ "plmt-image",
9
+ "plmt-video",
10
+ "plmt-list",
11
+ "plmt-icon",
12
+ "plmt-divider",
13
+ "plmt-table",
14
+ "plmt-text-field",
15
+ "plmt-text-area",
16
+ "plmt-checkbox",
17
+ "plmt-radio",
18
+ "plmt-select"
19
+ ]
@@ -0,0 +1,15 @@
1
+ import { ElementType } from '../schema/elementConfiguration';
2
+ import { ElementSpec, ElementSpecOptions } from '../render/types';
3
+ export type ShortcodeNode = {
4
+ type: ElementType;
5
+ props: Record<string, unknown>;
6
+ children?: ShortcodeNode[];
7
+ };
8
+ /**
9
+ * Convert one shortcode node into a semantic HTML element spec without recursing
10
+ * into layout children. Pass `options.children` for slots (builder) or let
11
+ * {@link toElementTree} fill them via recursion.
12
+ */
13
+ export declare function elementSpec(node: ShortcodeNode, options?: ElementSpecOptions): ElementSpec | null;
14
+ /** Convert a parsed shortcode node into a semantic HTML element tree. */
15
+ export declare function toElementTree(node: ShortcodeNode): ElementSpec | null;
@@ -0,0 +1,9 @@
1
+ import { ElementAttribute, CssVariables, ElementSpec } from '../render/types';
2
+ import { tags, ShortcodeTag } from '../render/tags';
3
+ export declare function spec(tag: string, attrs?: Record<string, ElementAttribute>, children?: ElementSpec['children'], styleVars?: CssVariables): ElementSpec;
4
+ export declare function withClass(className: ShortcodeTag, attrs?: Record<string, ElementAttribute>): Record<string, ElementAttribute>;
5
+ export declare function linked(props: Record<string, unknown>, children: Array<ElementSpec | string>): Array<ElementSpec | string>;
6
+ export declare function cssPrefix(type: string): string;
7
+ export declare function nodeId(props: Record<string, unknown>): string;
8
+ export declare function hostAttrs(props: Record<string, unknown>, className: ShortcodeTag): Record<string, ElementAttribute>;
9
+ export { tags };
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Element markup templates and HTML render helpers.
3
+ * Import from `@palmyit/elements/templates`.
4
+ */
5
+ export type { ElementAttribute, CssVariables, ElementSpec, ElementSpecOptions, } from './render/types';
6
+ export { escapeHtml, sanitizeRichTextHtml, renderHtml } from './render/renderHtml';
7
+ export { toDom } from './render/toDom';
8
+ export { styleToCssVariables } from './render/styleToVars';
9
+ export { tags, type ShortcodeTag } from './render/tags';
10
+ export { elementSpec, toElementTree, type ShortcodeNode, } from './templates/elementSpec';
11
+ export { spec, linked, hostAttrs, nodeId, cssPrefix } from './templates/helpers';