@unlayer/types 1.386.0 → 1.386.1

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 (3) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +63 -0
  3. package/package.json +2 -1
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Unlayer
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,63 @@
1
+ # @unlayer/types
2
+
3
+ TypeScript types for the [Unlayer](https://unlayer.com) email editor.
4
+
5
+ ## Install
6
+
7
+ ```sh
8
+ npm install @unlayer/types
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```ts
14
+ import type {
15
+ UnlayerEditor,
16
+ UnlayerOptions,
17
+ JSONTemplate,
18
+ ButtonValues,
19
+ BodyValues,
20
+ } from '@unlayer/types';
21
+
22
+ // Editor options
23
+ const options: UnlayerOptions = {
24
+ displayMode: 'email',
25
+ projectId: 12345,
26
+ };
27
+
28
+ // Work with designs
29
+ function handleDesign(design: JSONTemplate) {
30
+ for (const row of design.body.rows) {
31
+ for (const column of row.columns) {
32
+ for (const content of column.contents) {
33
+ if (content.type === 'button') {
34
+ // content.values type is narrowed to ButtonValues
35
+ console.info(content.values.buttonColors);
36
+ }
37
+ }
38
+ }
39
+ }
40
+ }
41
+ ```
42
+
43
+ ### Display mode generics
44
+
45
+ Export methods accept a display mode generic that narrows the design types:
46
+
47
+ ```ts
48
+ type EmailDesign = JSONTemplate<'email'>; // body.values has preheaderText
49
+ type PopupDesign = JSONTemplate<'popup'>; // body.values has popupPosition
50
+
51
+ type EmailBody = BodyValues<'email'>; // has preheaderText, lacks popupPosition
52
+ type PopupBody = BodyValues<'popup'>; // has popupPosition, lacks preheaderText
53
+
54
+ declare const unlayer: UnlayerEditor;
55
+ unlayer.exportHtml<'email'>((result) => {
56
+ const html = result.html;
57
+ const preheaderText = result.design.body.values.preheaderText; // typed, email-only field
58
+ });
59
+ ```
60
+
61
+ ## License
62
+
63
+ MIT
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@unlayer/types",
3
- "version": "1.386.0",
3
+ "version": "1.386.1",
4
+ "license": "MIT",
4
5
  "private": false,
5
6
  "types": "./dist/index.d.ts",
6
7
  "files": [