@hyper-elements/react 0.0.0-stage → 0.3.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/GUIDE.md +176 -0
- package/LICENSE +21 -0
- package/README.md +371 -2
- package/REFERENCE.md +949 -0
- package/dist/builder.cjs +7956 -0
- package/dist/builder.cjs.map +1 -0
- package/dist/builder.d.cts +89 -0
- package/dist/builder.d.ts +89 -0
- package/dist/builder.js +7929 -0
- package/dist/builder.js.map +1 -0
- package/dist/image.cjs +472 -0
- package/dist/image.cjs.map +1 -0
- package/dist/image.d.cts +34 -0
- package/dist/image.d.ts +34 -0
- package/dist/image.js +466 -0
- package/dist/image.js.map +1 -0
- package/dist/pdf.cjs +1211 -0
- package/dist/pdf.cjs.map +1 -0
- package/dist/pdf.d.cts +29 -0
- package/dist/pdf.d.ts +29 -0
- package/dist/pdf.js +1209 -0
- package/dist/pdf.js.map +1 -0
- package/dist/primitives.cjs +4954 -0
- package/dist/primitives.cjs.map +1 -0
- package/dist/primitives.d.cts +6902 -0
- package/dist/primitives.d.ts +6902 -0
- package/dist/primitives.js +4883 -0
- package/dist/primitives.js.map +1 -0
- package/package.json +140 -3
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The builder's design JSON as a template in the new components, from its values alone: the body is the root (the
|
|
5
|
+
* builder's display mode), with its rows (rows.ts) in it, a Document's header and footer around them. Malformed JSON
|
|
6
|
+
* never throws: what can't be read is left out and said.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
type DisplayMode = "email" | "web" | "document";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A design's values as Elements 0.2's components read them, which is how the builder draws them: lengths, sides, colors,
|
|
13
|
+
* borders, line heights, weights, fonts, alignments and links (as the new engine's), email services' tags, the id an
|
|
14
|
+
* author gave a part, where it's hidden, and a text tool's link style. fromDesign() reads designs with these; today's
|
|
15
|
+
* components' lowering (src/compat) reads them with the same.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
type Values = Record<string, any>;
|
|
19
|
+
|
|
20
|
+
type DesignRow = {
|
|
21
|
+
cells: number[];
|
|
22
|
+
columns: Array<{
|
|
23
|
+
contents: Array<{
|
|
24
|
+
type: string;
|
|
25
|
+
values: Values;
|
|
26
|
+
}>;
|
|
27
|
+
values: Values;
|
|
28
|
+
}>;
|
|
29
|
+
values: Values;
|
|
30
|
+
};
|
|
31
|
+
type Design = {
|
|
32
|
+
counters?: Record<string, number>;
|
|
33
|
+
schemaVersion?: number;
|
|
34
|
+
body: {
|
|
35
|
+
rows: DesignRow[];
|
|
36
|
+
values: Values;
|
|
37
|
+
headers?: DesignRow[];
|
|
38
|
+
footers?: DesignRow[];
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* The writing half of toDesign(): a template as the builder's rows, columns and blocks (raise.ts), each with its exact
|
|
44
|
+
* values and hidden properties, written as the builder's design JSON (design.ts).
|
|
45
|
+
*/
|
|
46
|
+
|
|
47
|
+
interface DesignResult {
|
|
48
|
+
/** The builder's design JSON, for loadDesign(). */
|
|
49
|
+
design: Design;
|
|
50
|
+
/** What the builder can't hold as it is (a block of HTML, a style left out): one line each. */
|
|
51
|
+
report: string[];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* The builder adapter: a template in the new components as the Unlayer builder's design JSON, and
|
|
56
|
+
* a design (edited in the builder or not) back as a template. The design holds no Elements data: a style or prop a
|
|
57
|
+
* tool has no field for is a hidden property of that tool (manifest.ts), kept in the design with no editor yet. What
|
|
58
|
+
* the builder can't arrange comes back as the builder holds it: the same look, flatter.
|
|
59
|
+
*/
|
|
60
|
+
|
|
61
|
+
/** A template in the new components (an `<Email>`, a `<Page>` or a `<Document>`) as the builder's design JSON. */
|
|
62
|
+
declare function toDesign(element: React.ReactElement): DesignResult;
|
|
63
|
+
interface TemplateResult {
|
|
64
|
+
/** The template, to render. */
|
|
65
|
+
element: React.ReactElement;
|
|
66
|
+
/** The template as JSX source in the new components. */
|
|
67
|
+
code: string;
|
|
68
|
+
/** What of the design the template can't hold, and what was left out: one line each. */
|
|
69
|
+
report: string[];
|
|
70
|
+
}
|
|
71
|
+
interface FromDesignOptions {
|
|
72
|
+
/**
|
|
73
|
+
* The builder's display mode the design was made in: its root. "email" is an Email, "web" a Page, "document" a
|
|
74
|
+
* Document. Without one, a design with a header, a footer or a page break is a Document, any other an Email.
|
|
75
|
+
*/
|
|
76
|
+
displayMode?: DisplayMode;
|
|
77
|
+
/** The name of the component in `code`. */
|
|
78
|
+
name?: string;
|
|
79
|
+
/**
|
|
80
|
+
* Your sanitizer for a design's markup, as today's exporters take it in their config: every builder `html` block's
|
|
81
|
+
* markup, and every text's (before it's read, as theirs is), goes through it. Without one, a design's markup is
|
|
82
|
+
* kept as it is: give one where a design can hold untrusted content.
|
|
83
|
+
*/
|
|
84
|
+
toSafeHtml?: (html: string) => string;
|
|
85
|
+
}
|
|
86
|
+
/** The builder's design JSON (made by toDesign() or in the builder) as a template in the new components. */
|
|
87
|
+
declare function fromDesign(design: unknown, options?: FromDesignOptions): TemplateResult;
|
|
88
|
+
|
|
89
|
+
export { type Design, type DesignResult, type DisplayMode, type FromDesignOptions, type TemplateResult, fromDesign, toDesign };
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The builder's design JSON as a template in the new components, from its values alone: the body is the root (the
|
|
5
|
+
* builder's display mode), with its rows (rows.ts) in it, a Document's header and footer around them. Malformed JSON
|
|
6
|
+
* never throws: what can't be read is left out and said.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
type DisplayMode = "email" | "web" | "document";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A design's values as Elements 0.2's components read them, which is how the builder draws them: lengths, sides, colors,
|
|
13
|
+
* borders, line heights, weights, fonts, alignments and links (as the new engine's), email services' tags, the id an
|
|
14
|
+
* author gave a part, where it's hidden, and a text tool's link style. fromDesign() reads designs with these; today's
|
|
15
|
+
* components' lowering (src/compat) reads them with the same.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
type Values = Record<string, any>;
|
|
19
|
+
|
|
20
|
+
type DesignRow = {
|
|
21
|
+
cells: number[];
|
|
22
|
+
columns: Array<{
|
|
23
|
+
contents: Array<{
|
|
24
|
+
type: string;
|
|
25
|
+
values: Values;
|
|
26
|
+
}>;
|
|
27
|
+
values: Values;
|
|
28
|
+
}>;
|
|
29
|
+
values: Values;
|
|
30
|
+
};
|
|
31
|
+
type Design = {
|
|
32
|
+
counters?: Record<string, number>;
|
|
33
|
+
schemaVersion?: number;
|
|
34
|
+
body: {
|
|
35
|
+
rows: DesignRow[];
|
|
36
|
+
values: Values;
|
|
37
|
+
headers?: DesignRow[];
|
|
38
|
+
footers?: DesignRow[];
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* The writing half of toDesign(): a template as the builder's rows, columns and blocks (raise.ts), each with its exact
|
|
44
|
+
* values and hidden properties, written as the builder's design JSON (design.ts).
|
|
45
|
+
*/
|
|
46
|
+
|
|
47
|
+
interface DesignResult {
|
|
48
|
+
/** The builder's design JSON, for loadDesign(). */
|
|
49
|
+
design: Design;
|
|
50
|
+
/** What the builder can't hold as it is (a block of HTML, a style left out): one line each. */
|
|
51
|
+
report: string[];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* The builder adapter: a template in the new components as the Unlayer builder's design JSON, and
|
|
56
|
+
* a design (edited in the builder or not) back as a template. The design holds no Elements data: a style or prop a
|
|
57
|
+
* tool has no field for is a hidden property of that tool (manifest.ts), kept in the design with no editor yet. What
|
|
58
|
+
* the builder can't arrange comes back as the builder holds it: the same look, flatter.
|
|
59
|
+
*/
|
|
60
|
+
|
|
61
|
+
/** A template in the new components (an `<Email>`, a `<Page>` or a `<Document>`) as the builder's design JSON. */
|
|
62
|
+
declare function toDesign(element: React.ReactElement): DesignResult;
|
|
63
|
+
interface TemplateResult {
|
|
64
|
+
/** The template, to render. */
|
|
65
|
+
element: React.ReactElement;
|
|
66
|
+
/** The template as JSX source in the new components. */
|
|
67
|
+
code: string;
|
|
68
|
+
/** What of the design the template can't hold, and what was left out: one line each. */
|
|
69
|
+
report: string[];
|
|
70
|
+
}
|
|
71
|
+
interface FromDesignOptions {
|
|
72
|
+
/**
|
|
73
|
+
* The builder's display mode the design was made in: its root. "email" is an Email, "web" a Page, "document" a
|
|
74
|
+
* Document. Without one, a design with a header, a footer or a page break is a Document, any other an Email.
|
|
75
|
+
*/
|
|
76
|
+
displayMode?: DisplayMode;
|
|
77
|
+
/** The name of the component in `code`. */
|
|
78
|
+
name?: string;
|
|
79
|
+
/**
|
|
80
|
+
* Your sanitizer for a design's markup, as today's exporters take it in their config: every builder `html` block's
|
|
81
|
+
* markup, and every text's (before it's read, as theirs is), goes through it. Without one, a design's markup is
|
|
82
|
+
* kept as it is: give one where a design can hold untrusted content.
|
|
83
|
+
*/
|
|
84
|
+
toSafeHtml?: (html: string) => string;
|
|
85
|
+
}
|
|
86
|
+
/** The builder's design JSON (made by toDesign() or in the builder) as a template in the new components. */
|
|
87
|
+
declare function fromDesign(design: unknown, options?: FromDesignOptions): TemplateResult;
|
|
88
|
+
|
|
89
|
+
export { type Design, type DesignResult, type DisplayMode, type FromDesignOptions, type TemplateResult, fromDesign, toDesign };
|