@mailquilt/templates 0.0.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/types.ts ADDED
@@ -0,0 +1,335 @@
1
+ /** Text or Block alignment. */
2
+ export type TemplateAlign = "left" | "center" | "right";
3
+
4
+ /** Border line styles supported by format v4 Boxes and Columns. */
5
+ export type TemplateBorderStyle = "solid" | "dashed" | "dotted";
6
+
7
+ /** Vertical alignment of a Column inside its Row. */
8
+ export type TemplateVerticalAlign = "top" | "middle" | "bottom";
9
+
10
+ /** Device visibility filter for a Row or Block. */
11
+ export type TemplateShowOn = "desktop" | "phone";
12
+
13
+ /** Supported Social Block network identifiers. */
14
+ export type TemplateSocialNetwork =
15
+ | "bluesky"
16
+ | "facebook"
17
+ | "instagram"
18
+ | "linkedin"
19
+ | "pinterest"
20
+ | "threads"
21
+ | "tiktok"
22
+ | "website"
23
+ | "x"
24
+ | "youtube";
25
+
26
+ /** Padding properties shared by Rows, Columns, and Blocks. */
27
+ export interface TemplatePaddingProps {
28
+ paddingTop?: number;
29
+ paddingRight?: number;
30
+ paddingBottom?: number;
31
+ paddingLeft?: number;
32
+ }
33
+
34
+ /** Border properties shared by Columns and Block Boxes. */
35
+ export interface TemplateBorderProps {
36
+ borderColor?: string;
37
+ borderStyle?: TemplateBorderStyle;
38
+ borderWidth?: number;
39
+ }
40
+
41
+ /** Box properties available on every Block type in format v4. */
42
+ export interface TemplateBoxProps
43
+ extends TemplatePaddingProps, TemplateBorderProps {
44
+ borderRadius?: number;
45
+ boxBackgroundColor?: string;
46
+ }
47
+
48
+ /** Formatting marks on inline rich-text runs. */
49
+ export type TemplateRichTextMark =
50
+ | { type: "bold" }
51
+ | { type: "italic" }
52
+ | { type: "underline" }
53
+ | { type: "link"; attrs: { href: string } };
54
+
55
+ /** Plain text run inside a rich-text paragraph. */
56
+ export interface TemplateRichTextText {
57
+ type: "text";
58
+ text: string;
59
+ marks?: TemplateRichTextMark[];
60
+ }
61
+
62
+ /** Line break inside a rich-text paragraph. */
63
+ export interface TemplateRichTextHardBreak {
64
+ type: "hardBreak";
65
+ marks?: TemplateRichTextMark[];
66
+ }
67
+
68
+ /** Atomic Merge Tag node inside a rich-text paragraph. */
69
+ export interface TemplateRichTextMergeTag {
70
+ type: "mergeTag";
71
+ attrs: { name: string };
72
+ marks?: TemplateRichTextMark[];
73
+ }
74
+
75
+ /** Inline node inside a paragraph. */
76
+ export type TemplateRichTextInline =
77
+ | TemplateRichTextText
78
+ | TemplateRichTextHardBreak
79
+ | TemplateRichTextMergeTag;
80
+
81
+ /** Paragraph node in rich text. */
82
+ export interface TemplateRichTextParagraph {
83
+ type: "paragraph";
84
+ content?: TemplateRichTextInline[];
85
+ }
86
+
87
+ /** Single item inside a bulleted or numbered List. */
88
+ export interface TemplateRichTextListItem {
89
+ type: "listItem";
90
+ content: [TemplateRichTextParagraph];
91
+ }
92
+
93
+ /** One-level bulleted or numbered List in a Text Block. */
94
+ export interface TemplateRichTextList {
95
+ type: "bulletList" | "orderedList";
96
+ content: TemplateRichTextListItem[];
97
+ }
98
+
99
+ /** Rich-text document for a Text Block. */
100
+ export interface TemplateRichTextDocument {
101
+ type: "doc";
102
+ content: (TemplateRichTextParagraph | TemplateRichTextList)[];
103
+ }
104
+
105
+ /** Rich-text document for a Heading Block (paragraphs only). */
106
+ export interface TemplateRichTextHeadingDocument {
107
+ type: "doc";
108
+ content: TemplateRichTextParagraph[];
109
+ }
110
+
111
+ export interface TemplateTextBlockProps extends TemplateBoxProps {
112
+ align?: TemplateAlign;
113
+ color?: string;
114
+ content: TemplateRichTextDocument;
115
+ fontSize?: number;
116
+ phone?: TemplatePaddingProps & { fontSize?: number };
117
+ showOn?: TemplateShowOn;
118
+ }
119
+
120
+ export interface TemplateHeadingBlockProps extends TemplateBoxProps {
121
+ align?: TemplateAlign;
122
+ color?: string;
123
+ content: TemplateRichTextHeadingDocument;
124
+ fontSize?: number;
125
+ level: 1 | 2 | 3;
126
+ phone?: TemplatePaddingProps & { fontSize?: number };
127
+ showOn?: TemplateShowOn;
128
+ }
129
+
130
+ export interface TemplateButtonBlockProps extends TemplateBoxProps {
131
+ align?: TemplateAlign;
132
+ backgroundColor?: string;
133
+ color?: string;
134
+ href?: string;
135
+ label: string;
136
+ phone?: TemplatePaddingProps & { fontSize?: number };
137
+ showOn?: TemplateShowOn;
138
+ }
139
+
140
+ export interface TemplateImageBlockProps extends TemplateBoxProps {
141
+ alt?: string;
142
+ decorative?: boolean;
143
+ href?: string;
144
+ phone?: TemplatePaddingProps & { width?: number };
145
+ showOn?: TemplateShowOn;
146
+ src?: string;
147
+ width?: number;
148
+ }
149
+
150
+ export interface TemplateDividerBlockProps extends TemplateBoxProps {
151
+ color?: string;
152
+ phone?: TemplatePaddingProps;
153
+ showOn?: TemplateShowOn;
154
+ thickness?: number;
155
+ }
156
+
157
+ export interface TemplateSpacerBlockProps extends TemplateBoxProps {
158
+ height?: number;
159
+ phone?: TemplatePaddingProps;
160
+ showOn?: TemplateShowOn;
161
+ }
162
+
163
+ export interface TemplateSocialLink {
164
+ network: TemplateSocialNetwork;
165
+ url?: string;
166
+ }
167
+
168
+ export interface TemplateSocialBlockProps extends TemplateBoxProps {
169
+ align?: TemplateAlign;
170
+ iconSize?: 32 | 40 | 48;
171
+ iconStyle?: "color" | "white";
172
+ links: TemplateSocialLink[];
173
+ phone?: TemplatePaddingProps;
174
+ showOn?: TemplateShowOn;
175
+ }
176
+
177
+ export interface TemplateMenuLink {
178
+ label?: string;
179
+ url?: string;
180
+ }
181
+
182
+ export interface TemplateMenuBlockProps extends TemplateBoxProps {
183
+ align?: TemplateAlign;
184
+ color?: string;
185
+ fontSize?: number;
186
+ gap?: number;
187
+ links: TemplateMenuLink[];
188
+ phone?: TemplatePaddingProps & { fontSize?: number };
189
+ showOn?: TemplateShowOn;
190
+ }
191
+
192
+ export interface TemplateVideoBlockProps extends TemplateBoxProps {
193
+ alt?: string;
194
+ color?: string;
195
+ label?: string;
196
+ phone?: TemplatePaddingProps;
197
+ play?: "below" | "on" | "none";
198
+ playThumbnail?: string;
199
+ showOn?: TemplateShowOn;
200
+ thumbnail?: string;
201
+ url?: string;
202
+ }
203
+
204
+ /** A Block inside a Column, structurally assignable to `@mailquilt/core`'s `Block`. */
205
+ export type TemplateBlock =
206
+ | { id: string; type: "text"; props: TemplateTextBlockProps }
207
+ | { id: string; type: "heading"; props: TemplateHeadingBlockProps }
208
+ | { id: string; type: "button"; props: TemplateButtonBlockProps }
209
+ | { id: string; type: "image"; props: TemplateImageBlockProps }
210
+ | { id: string; type: "divider"; props: TemplateDividerBlockProps }
211
+ | { id: string; type: "spacer"; props: TemplateSpacerBlockProps }
212
+ | { id: string; type: "social"; props: TemplateSocialBlockProps }
213
+ | { id: string; type: "menu"; props: TemplateMenuBlockProps }
214
+ | { id: string; type: "video"; props: TemplateVideoBlockProps };
215
+
216
+ /** Settings on a Column, structurally assignable to `@mailquilt/core`'s `ColumnProps`. */
217
+ export interface TemplateColumnProps
218
+ extends TemplatePaddingProps, TemplateBorderProps {
219
+ backgroundColor?: string;
220
+ phone?: TemplatePaddingProps;
221
+ verticalAlign?: TemplateVerticalAlign;
222
+ }
223
+
224
+ /** A Column inside a Row, structurally assignable to `@mailquilt/core`'s `Column`. */
225
+ export interface TemplateColumn {
226
+ id: string;
227
+ width: number;
228
+ props: TemplateColumnProps;
229
+ blocks: TemplateBlock[];
230
+ }
231
+
232
+ /** Settings on a Row, structurally assignable to `@mailquilt/core`'s `RowProps`. */
233
+ export interface TemplateRowProps extends TemplatePaddingProps {
234
+ backgroundColor?: string;
235
+ phone?: TemplatePaddingProps;
236
+ showOn?: TemplateShowOn;
237
+ stackOnPhone?: boolean;
238
+ }
239
+
240
+ /** A Row inside an email, structurally assignable to `@mailquilt/core`'s `Row`. */
241
+ export interface TemplateRow {
242
+ id: string;
243
+ props: TemplateRowProps;
244
+ columns: TemplateColumn[];
245
+ }
246
+
247
+ /** Email style defaults, structurally assignable to `@mailquilt/core`'s `EmailStyle`. */
248
+ export interface TemplateEmailStyle {
249
+ emailBackgroundColor?: string;
250
+ textColor?: string;
251
+ linkColor?: string;
252
+ buttonBackgroundColor?: string;
253
+ buttonBorderRadius?: number;
254
+ headingFontFamily?: string;
255
+ heading1FontSize?: number;
256
+ heading2FontSize?: number;
257
+ heading3FontSize?: number;
258
+ textFontSize?: number;
259
+ }
260
+
261
+ /** Web font entry, structurally assignable to `@mailquilt/core`'s `WebFont`. */
262
+ export interface TemplateWebFont {
263
+ name: string;
264
+ url: string;
265
+ }
266
+
267
+ /** Email settings, structurally assignable to `@mailquilt/core`'s `EmailSettings`. */
268
+ export interface TemplateEmailSettings {
269
+ width: number;
270
+ backgroundColor: string;
271
+ fontFamily: string;
272
+ preheader?: string;
273
+ language?: string;
274
+ style?: TemplateEmailStyle;
275
+ fonts?: TemplateWebFont[];
276
+ }
277
+
278
+ /** A format v4 email document, structurally assignable to `@mailquilt/core`'s `BlocksDocument`. */
279
+ export interface TemplateDocument {
280
+ kind: "blocks";
281
+ version: 4;
282
+ settings: TemplateEmailSettings;
283
+ rows: TemplateRow[];
284
+ }
285
+
286
+ /** Category IDs for Starter emails in `@mailquilt/templates`. */
287
+ export type StarterEmailCategory =
288
+ | "onboarding"
289
+ | "product"
290
+ | "editorial"
291
+ | "transactional"
292
+ | "engagement";
293
+
294
+ /** Category IDs for Saved Rows in `@mailquilt/templates`. */
295
+ export type SavedRowCategory = "header" | "hero" | "content" | "cta" | "footer";
296
+
297
+ /** Descriptive metadata for a template or Saved Row category. */
298
+ export interface CategoryInfo<Id extends string = string> {
299
+ readonly id: Id;
300
+ readonly label: string;
301
+ readonly description: string;
302
+ }
303
+
304
+ /**
305
+ * A Starter email entry ready for `<mail-quilt>`'s `starterEmails` property,
306
+ * directly assignable to `StarterEmail` from `@mailquilt/editor`.
307
+ */
308
+ export interface TemplateStarterEmail {
309
+ readonly name: string;
310
+ readonly description: string;
311
+ readonly category: StarterEmailCategory;
312
+ readonly email: TemplateDocument;
313
+ }
314
+
315
+ /**
316
+ * A Saved Row entry ready for `<mail-quilt>`'s `savedRows` property,
317
+ * directly assignable to `SavedRow` from `@mailquilt/editor`.
318
+ */
319
+ export interface TemplateSavedRow {
320
+ readonly name: string;
321
+ readonly category: SavedRowCategory;
322
+ readonly version: 4;
323
+ readonly row: TemplateRow;
324
+ }
325
+
326
+ /**
327
+ * A Merge Tag entry ready for `<mail-quilt>`'s `mergeTags` property and
328
+ * `@mailquilt/renderer`'s `checkEmail()`.
329
+ */
330
+ export interface TemplateMergeTag {
331
+ readonly name: string;
332
+ readonly label: string;
333
+ readonly sample: string;
334
+ readonly unsubscribe?: true;
335
+ }