@onivoro/server-html 0.1.0 → 0.1.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 (130) hide show
  1. package/dist/cjs/index.js +36 -0
  2. package/{src → dist/cjs}/lib/deprecated/a.function.js +0 -1
  3. package/{src → dist/cjs}/lib/deprecated/html-element-renderer.type.js +0 -1
  4. package/{src → dist/cjs}/lib/deprecated/html.function.js +0 -1
  5. package/{src → dist/cjs}/lib/deprecated/login-button.function.js +0 -1
  6. package/dist/cjs/lib/deprecated/self-closing-html-element-renderer.type.js +2 -0
  7. package/{src → dist/cjs}/lib/deprecated/self-closing-tag.function.js +0 -1
  8. package/{src → dist/cjs}/lib/deprecated/tag.function.js +0 -1
  9. package/{src → dist/cjs}/lib/deprecated/tags.js +0 -1
  10. package/{src → dist/cjs}/lib/email-body.function.js +0 -1
  11. package/{src → dist/cjs}/lib/primitives/element.function.js +0 -1
  12. package/{src → dist/cjs}/lib/primitives/elements.js +0 -1
  13. package/{src → dist/cjs}/lib/primitives/format-attributes.function.js +0 -1
  14. package/{src → dist/cjs}/lib/primitives/inline-style.function.js +0 -1
  15. package/{src → dist/cjs}/lib/primitives/self-closing-element.function.js +0 -1
  16. package/{src → dist/cjs}/lib/styles/button-styles.constant.js +0 -1
  17. package/{src → dist/cjs}/lib/styles/font-styles.constant.js +0 -1
  18. package/{src → dist/cjs}/lib/table.function.js +0 -1
  19. package/{src → dist/cjs}/lib/types/attributes.type.js +0 -1
  20. package/{src → dist/cjs}/lib/types/element-renderer.type.js +0 -1
  21. package/{src → dist/cjs}/lib/types/self-closing-element-renderer.type.js +0 -1
  22. package/dist/esm/index.d.ts +20 -0
  23. package/dist/esm/index.js +36 -0
  24. package/dist/esm/lib/deprecated/a.function.d.ts +1 -0
  25. package/dist/esm/lib/deprecated/a.function.js +8 -0
  26. package/dist/esm/lib/deprecated/html-element-renderer.type.d.ts +1 -0
  27. package/dist/esm/lib/deprecated/html-element-renderer.type.js +2 -0
  28. package/dist/esm/lib/deprecated/html.function.d.ts +1 -0
  29. package/dist/esm/lib/deprecated/html.function.js +43 -0
  30. package/dist/esm/lib/deprecated/login-button.function.d.ts +1 -0
  31. package/dist/esm/lib/deprecated/login-button.function.js +15 -0
  32. package/dist/esm/lib/deprecated/self-closing-html-element-renderer.type.d.ts +1 -0
  33. package/dist/esm/lib/deprecated/self-closing-html-element-renderer.type.js +2 -0
  34. package/dist/esm/lib/deprecated/self-closing-tag.function.d.ts +1 -0
  35. package/dist/esm/lib/deprecated/self-closing-tag.function.js +8 -0
  36. package/dist/esm/lib/deprecated/tag.function.d.ts +1 -0
  37. package/dist/esm/lib/deprecated/tag.function.js +12 -0
  38. package/dist/esm/lib/deprecated/tags.d.ts +24 -0
  39. package/dist/esm/lib/deprecated/tags.js +27 -0
  40. package/dist/esm/lib/email-body.function.d.ts +2 -0
  41. package/dist/esm/lib/email-body.function.js +25 -0
  42. package/dist/esm/lib/primitives/element.function.d.ts +2 -0
  43. package/dist/esm/lib/primitives/element.function.js +13 -0
  44. package/dist/esm/lib/primitives/elements.d.ts +26 -0
  45. package/dist/esm/lib/primitives/elements.js +34 -0
  46. package/dist/esm/lib/primitives/format-attributes.function.d.ts +1 -0
  47. package/dist/esm/lib/primitives/format-attributes.function.js +9 -0
  48. package/dist/esm/lib/primitives/inline-style.function.d.ts +1 -0
  49. package/dist/esm/lib/primitives/inline-style.function.js +10 -0
  50. package/dist/esm/lib/primitives/self-closing-element.function.d.ts +2 -0
  51. package/dist/esm/lib/primitives/self-closing-element.function.js +8 -0
  52. package/dist/esm/lib/styles/button-styles.constant.d.ts +11 -0
  53. package/dist/esm/lib/styles/button-styles.constant.js +14 -0
  54. package/dist/esm/lib/styles/font-styles.constant.d.ts +7 -0
  55. package/dist/esm/lib/styles/font-styles.constant.js +10 -0
  56. package/dist/esm/lib/table.function.d.ts +1 -0
  57. package/dist/esm/lib/table.function.js +13 -0
  58. package/dist/esm/lib/types/attributes.type.d.ts +4 -0
  59. package/dist/esm/lib/types/attributes.type.js +2 -0
  60. package/dist/esm/lib/types/element-renderer.type.d.ts +2 -0
  61. package/dist/esm/lib/types/element-renderer.type.js +2 -0
  62. package/dist/esm/lib/types/self-closing-element-renderer.type.d.ts +2 -0
  63. package/dist/esm/lib/types/self-closing-element-renderer.type.js +2 -0
  64. package/dist/types/index.d.ts +20 -0
  65. package/dist/types/lib/deprecated/a.function.d.ts +1 -0
  66. package/dist/types/lib/deprecated/html-element-renderer.type.d.ts +1 -0
  67. package/dist/types/lib/deprecated/html.function.d.ts +1 -0
  68. package/dist/types/lib/deprecated/login-button.function.d.ts +1 -0
  69. package/dist/types/lib/deprecated/self-closing-html-element-renderer.type.d.ts +1 -0
  70. package/dist/types/lib/deprecated/self-closing-tag.function.d.ts +1 -0
  71. package/dist/types/lib/deprecated/tag.function.d.ts +1 -0
  72. package/dist/types/lib/deprecated/tags.d.ts +24 -0
  73. package/dist/types/lib/email-body.function.d.ts +2 -0
  74. package/dist/types/lib/primitives/element.function.d.ts +2 -0
  75. package/dist/types/lib/primitives/elements.d.ts +26 -0
  76. package/dist/types/lib/primitives/format-attributes.function.d.ts +1 -0
  77. package/dist/types/lib/primitives/inline-style.function.d.ts +1 -0
  78. package/dist/types/lib/primitives/self-closing-element.function.d.ts +2 -0
  79. package/dist/types/lib/styles/button-styles.constant.d.ts +11 -0
  80. package/dist/types/lib/styles/font-styles.constant.d.ts +7 -0
  81. package/dist/types/lib/table.function.d.ts +1 -0
  82. package/dist/types/lib/types/attributes.type.d.ts +4 -0
  83. package/dist/types/lib/types/element-renderer.type.d.ts +2 -0
  84. package/dist/types/lib/types/self-closing-element-renderer.type.d.ts +2 -0
  85. package/package.json +40 -5
  86. package/README.md +0 -11
  87. package/src/index.js +0 -24
  88. package/src/index.js.map +0 -1
  89. package/src/lib/deprecated/a.function.js.map +0 -1
  90. package/src/lib/deprecated/html-element-renderer.type.js.map +0 -1
  91. package/src/lib/deprecated/html.function.js.map +0 -1
  92. package/src/lib/deprecated/login-button.function.js.map +0 -1
  93. package/src/lib/deprecated/self-closing-html-element-renderer.type.js +0 -3
  94. package/src/lib/deprecated/self-closing-html-element-renderer.type.js.map +0 -1
  95. package/src/lib/deprecated/self-closing-tag.function.js.map +0 -1
  96. package/src/lib/deprecated/tag.function.js.map +0 -1
  97. package/src/lib/deprecated/tags.js.map +0 -1
  98. package/src/lib/email-body.function.js.map +0 -1
  99. package/src/lib/primitives/element.function.js.map +0 -1
  100. package/src/lib/primitives/elements.js.map +0 -1
  101. package/src/lib/primitives/format-attributes.function.js.map +0 -1
  102. package/src/lib/primitives/inline-style.function.js.map +0 -1
  103. package/src/lib/primitives/self-closing-element.function.js.map +0 -1
  104. package/src/lib/styles/button-styles.constant.js.map +0 -1
  105. package/src/lib/styles/font-styles.constant.js.map +0 -1
  106. package/src/lib/table.function.js.map +0 -1
  107. package/src/lib/types/attributes.type.js.map +0 -1
  108. package/src/lib/types/element-renderer.type.js.map +0 -1
  109. package/src/lib/types/self-closing-element-renderer.type.js.map +0 -1
  110. /package/{src → dist/cjs}/index.d.ts +0 -0
  111. /package/{src → dist/cjs}/lib/deprecated/a.function.d.ts +0 -0
  112. /package/{src → dist/cjs}/lib/deprecated/html-element-renderer.type.d.ts +0 -0
  113. /package/{src → dist/cjs}/lib/deprecated/html.function.d.ts +0 -0
  114. /package/{src → dist/cjs}/lib/deprecated/login-button.function.d.ts +0 -0
  115. /package/{src → dist/cjs}/lib/deprecated/self-closing-html-element-renderer.type.d.ts +0 -0
  116. /package/{src → dist/cjs}/lib/deprecated/self-closing-tag.function.d.ts +0 -0
  117. /package/{src → dist/cjs}/lib/deprecated/tag.function.d.ts +0 -0
  118. /package/{src → dist/cjs}/lib/deprecated/tags.d.ts +0 -0
  119. /package/{src → dist/cjs}/lib/email-body.function.d.ts +0 -0
  120. /package/{src → dist/cjs}/lib/primitives/element.function.d.ts +0 -0
  121. /package/{src → dist/cjs}/lib/primitives/elements.d.ts +0 -0
  122. /package/{src → dist/cjs}/lib/primitives/format-attributes.function.d.ts +0 -0
  123. /package/{src → dist/cjs}/lib/primitives/inline-style.function.d.ts +0 -0
  124. /package/{src → dist/cjs}/lib/primitives/self-closing-element.function.d.ts +0 -0
  125. /package/{src → dist/cjs}/lib/styles/button-styles.constant.d.ts +0 -0
  126. /package/{src → dist/cjs}/lib/styles/font-styles.constant.d.ts +0 -0
  127. /package/{src → dist/cjs}/lib/table.function.d.ts +0 -0
  128. /package/{src → dist/cjs}/lib/types/attributes.type.d.ts +0 -0
  129. /package/{src → dist/cjs}/lib/types/element-renderer.type.d.ts +0 -0
  130. /package/{src → dist/cjs}/lib/types/self-closing-element-renderer.type.d.ts +0 -0
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./lib/deprecated/a.function"), exports);
18
+ __exportStar(require("./lib/deprecated/html-element-renderer.type"), exports);
19
+ __exportStar(require("./lib/deprecated/html.function"), exports);
20
+ __exportStar(require("./lib/deprecated/login-button.function"), exports);
21
+ __exportStar(require("./lib/deprecated/self-closing-html-element-renderer.type"), exports);
22
+ __exportStar(require("./lib/deprecated/self-closing-tag.function"), exports);
23
+ __exportStar(require("./lib/deprecated/tag.function"), exports);
24
+ __exportStar(require("./lib/deprecated/tags"), exports);
25
+ __exportStar(require("./lib/primitives/element.function"), exports);
26
+ __exportStar(require("./lib/primitives/elements"), exports);
27
+ __exportStar(require("./lib/primitives/format-attributes.function"), exports);
28
+ __exportStar(require("./lib/primitives/inline-style.function"), exports);
29
+ __exportStar(require("./lib/primitives/self-closing-element.function"), exports);
30
+ __exportStar(require("./lib/styles/button-styles.constant"), exports);
31
+ __exportStar(require("./lib/styles/font-styles.constant"), exports);
32
+ __exportStar(require("./lib/types/attributes.type"), exports);
33
+ __exportStar(require("./lib/types/element-renderer.type"), exports);
34
+ __exportStar(require("./lib/types/self-closing-element-renderer.type"), exports);
35
+ __exportStar(require("./lib/email-body.function"), exports);
36
+ __exportStar(require("./lib/table.function"), exports);
@@ -6,4 +6,3 @@ function a(text, href, cssClass) {
6
6
  return `<a target="_blank" href="${href}" ${classExp}>${text}</a>`;
7
7
  }
8
8
  exports.a = a;
9
- //# sourceMappingURL=a.function.js.map
@@ -1,3 +1,2 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=html-element-renderer.type.js.map
@@ -41,4 +41,3 @@ function html(title, subtitle, markup, logoUrl) {
41
41
  ]);
42
42
  }
43
43
  exports.html = html;
44
- //# sourceMappingURL=html.function.js.map
@@ -13,4 +13,3 @@ function loginButton(text, href, extraStyles) {
13
13
  });
14
14
  }
15
15
  exports.loginButton = loginButton;
16
- //# sourceMappingURL=login-button.function.js.map
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -6,4 +6,3 @@ function selfClosingTag(tag, cssClass, attributes, styles) {
6
6
  return (0, tag_function_1.tag)(tag, [], cssClass, attributes, styles).replace(`></${tag}>`, '/>');
7
7
  }
8
8
  exports.selfClosingTag = selfClosingTag;
9
- //# sourceMappingURL=self-closing-tag.function.js.map
@@ -10,4 +10,3 @@ function tag(tag, content, cssClass, attributes, styles) {
10
10
  return `<${tag}${classExp}${attributesExp}${styleExp}>${content.join?.('')}</${tag}>`;
11
11
  }
12
12
  exports.tag = tag;
13
- //# sourceMappingURL=tag.function.js.map
@@ -25,4 +25,3 @@ exports._th = tag_function_1.tag.bind(null, 'th');
25
25
  exports._thead = tag_function_1.tag.bind(null, 'thead');
26
26
  exports._tr = tag_function_1.tag.bind(null, 'tr');
27
27
  exports._style = tag_function_1.tag.bind(null, 'style');
28
- //# sourceMappingURL=tags.js.map
@@ -23,4 +23,3 @@ function emailBody(title, subtitle, markup, logoUrl, extraStyles = {}) {
23
23
  ]);
24
24
  }
25
25
  exports.emailBody = emailBody;
26
- //# sourceMappingURL=email-body.function.js.map
@@ -11,4 +11,3 @@ function element(tag, content, attributes) {
11
11
  return `<${tag}${classExp}${attributesExp}${styleExp}>${content.join?.('')}</${tag}>`;
12
12
  }
13
13
  exports.element = element;
14
- //# sourceMappingURL=element.function.js.map
@@ -32,4 +32,3 @@ exports.tr = element_function_1.element.bind(null, 'tr');
32
32
  // todo: make this take a Record<string, Record<string, string>> instead of the terrible raw string formatting used now
33
33
  // todo: apply kebab-casing to camelCased keys so that consumers can write { fontWeight: 600 } instead of {'font-weight': 600 } (do this for all style properties of primitives' attributes)
34
34
  exports.style = element_function_1.element.bind(null, 'style');
35
- //# sourceMappingURL=elements.js.map
@@ -7,4 +7,3 @@ function formatAttributes(attributes) {
7
7
  .join(' ');
8
8
  }
9
9
  exports.formatAttributes = formatAttributes;
10
- //# sourceMappingURL=format-attributes.function.js.map
@@ -8,4 +8,3 @@ function inlineStyle(styles) {
8
8
  return `style="${rules}"`;
9
9
  }
10
10
  exports.inlineStyle = inlineStyle;
11
- //# sourceMappingURL=inline-style.function.js.map
@@ -6,4 +6,3 @@ function selfClosingElement(tag, attributes) {
6
6
  return (0, element_function_1.element)(tag, [], attributes).replace(`></${tag}>`, '/>');
7
7
  }
8
8
  exports.selfClosingElement = selfClosingElement;
9
- //# sourceMappingURL=self-closing-element.function.js.map
@@ -12,4 +12,3 @@ exports.buttonStyles = {
12
12
  'box-sizing': 'border-box',
13
13
  color: 'inherit'
14
14
  };
15
- //# sourceMappingURL=button-styles.constant.js.map
@@ -8,4 +8,3 @@ exports.fontStyles = {
8
8
  '-moz-osx-font-smoothing': `grayscale`,
9
9
  color: 'rgba(0, 0, 0, 0.5) !important',
10
10
  };
11
- //# sourceMappingURL=font-styles.constant.js.map
@@ -11,4 +11,3 @@ function table(columns, rows) {
11
11
  ], { style: { 'border-collapse': 'collapse', width: '100%', color } });
12
12
  }
13
13
  exports.table = table;
14
- //# sourceMappingURL=table.function.js.map
@@ -1,3 +1,2 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=attributes.type.js.map
@@ -1,3 +1,2 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=element-renderer.type.js.map
@@ -1,3 +1,2 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=self-closing-element-renderer.type.js.map
@@ -0,0 +1,20 @@
1
+ export * from './lib/deprecated/a.function';
2
+ export * from './lib/deprecated/html-element-renderer.type';
3
+ export * from './lib/deprecated/html.function';
4
+ export * from './lib/deprecated/login-button.function';
5
+ export * from './lib/deprecated/self-closing-html-element-renderer.type';
6
+ export * from './lib/deprecated/self-closing-tag.function';
7
+ export * from './lib/deprecated/tag.function';
8
+ export * from './lib/deprecated/tags';
9
+ export * from './lib/primitives/element.function';
10
+ export * from './lib/primitives/elements';
11
+ export * from './lib/primitives/format-attributes.function';
12
+ export * from './lib/primitives/inline-style.function';
13
+ export * from './lib/primitives/self-closing-element.function';
14
+ export * from './lib/styles/button-styles.constant';
15
+ export * from './lib/styles/font-styles.constant';
16
+ export * from './lib/types/attributes.type';
17
+ export * from './lib/types/element-renderer.type';
18
+ export * from './lib/types/self-closing-element-renderer.type';
19
+ export * from './lib/email-body.function';
20
+ export * from './lib/table.function';
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./lib/deprecated/a.function"), exports);
18
+ __exportStar(require("./lib/deprecated/html-element-renderer.type"), exports);
19
+ __exportStar(require("./lib/deprecated/html.function"), exports);
20
+ __exportStar(require("./lib/deprecated/login-button.function"), exports);
21
+ __exportStar(require("./lib/deprecated/self-closing-html-element-renderer.type"), exports);
22
+ __exportStar(require("./lib/deprecated/self-closing-tag.function"), exports);
23
+ __exportStar(require("./lib/deprecated/tag.function"), exports);
24
+ __exportStar(require("./lib/deprecated/tags"), exports);
25
+ __exportStar(require("./lib/primitives/element.function"), exports);
26
+ __exportStar(require("./lib/primitives/elements"), exports);
27
+ __exportStar(require("./lib/primitives/format-attributes.function"), exports);
28
+ __exportStar(require("./lib/primitives/inline-style.function"), exports);
29
+ __exportStar(require("./lib/primitives/self-closing-element.function"), exports);
30
+ __exportStar(require("./lib/styles/button-styles.constant"), exports);
31
+ __exportStar(require("./lib/styles/font-styles.constant"), exports);
32
+ __exportStar(require("./lib/types/attributes.type"), exports);
33
+ __exportStar(require("./lib/types/element-renderer.type"), exports);
34
+ __exportStar(require("./lib/types/self-closing-element-renderer.type"), exports);
35
+ __exportStar(require("./lib/email-body.function"), exports);
36
+ __exportStar(require("./lib/table.function"), exports);
@@ -0,0 +1 @@
1
+ export declare function a(text: string, href: string, cssClass?: string): string;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.a = void 0;
4
+ function a(text, href, cssClass) {
5
+ const classExp = cssClass ? `class="${cssClass}"` : '';
6
+ return `<a target="_blank" href="${href}" ${classExp}>${text}</a>`;
7
+ }
8
+ exports.a = a;
@@ -0,0 +1 @@
1
+ export type THtmlElementRenderer = (content: Array<string | number>, cssClass?: string, attributes?: Record<string, any>, styles?: Record<string, string>) => string;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1 @@
1
+ export declare function html(title: string, subtitle: string, markup: Array<string | number>, logoUrl?: string): string;
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.html = void 0;
4
+ const tags_1 = require("./tags");
5
+ function html(title, subtitle, markup, logoUrl) {
6
+ return (0, tags_1._htm)([
7
+ (0, tags_1._head)([
8
+ (0, tags_1._style)([
9
+ 'body {',
10
+ 'padding: 64px;',
11
+ `font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";`,
12
+ `font-size: 1rem;`,
13
+ `-webkit-font-smoothing: antialiased;`,
14
+ `-moz-osx-font-smoothing: grayscale;`,
15
+ 'color: rgb(34, 30, 31);',
16
+ '}',
17
+ 'h1, h2, h3, h4, pre { color: rgb(34, 30, 31) !important; }',
18
+ 'td, th { text-align: left; padding: 8px;}',
19
+ 'table { border-collapse: collapse; width: 100%;}',
20
+ 'tbody { border-width: 1px; border-style: solid; border-left-style: none; border-right-style: none; }',
21
+ '.focal, a { padding: 12px 24px; font-weight: bold; display: block; text-align: center; border-radius: 4px; }',
22
+ '.mw-880 { max-width: 880px !important; margin: auto; }',
23
+ '.mw-440 { max-width: 440px !important; margin: auto; }',
24
+ 'pre { padding: 12px 24px; font-weight: bold; display: block; text-align: center; border-radius: 4px; border: solid 1px; }',
25
+ 'a { max-width: 240px; }',
26
+ '.bg-gray { background-color: #efefef; }',
27
+ '.drop-shadow, .button { filter: drop-shadow(2px 2px 1px rgba(0, 0, 0, 0.3)); }',
28
+ '.button { text-decoration: none; margin: 32px 0; background-color: rgb(205, 62, 71); color: white !important; }',
29
+ ]),
30
+ ]),
31
+ (0, tags_1._body)([
32
+ (0, tags_1._header)([
33
+ logoUrl
34
+ ? `<img height="64" width="auto" src="${logoUrl}" />`
35
+ : undefined,
36
+ (0, tags_1._h1)([title]),
37
+ (0, tags_1._h2)([subtitle]),
38
+ ].filter(Boolean)),
39
+ (0, tags_1._main)(markup),
40
+ ]),
41
+ ]);
42
+ }
43
+ exports.html = html;
@@ -0,0 +1 @@
1
+ export declare function loginButton(text: string, href: string, extraStyles?: Record<string, string>): string;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.loginButton = void 0;
4
+ const elements_1 = require("../primitives/elements");
5
+ const button_styles_constant_1 = require("../styles/button-styles.constant");
6
+ function loginButton(text, href, extraStyles) {
7
+ return (0, elements_1.anchor)([text], {
8
+ href,
9
+ style: {
10
+ ...button_styles_constant_1.buttonStyles,
11
+ ...(extraStyles || {})
12
+ }
13
+ });
14
+ }
15
+ exports.loginButton = loginButton;
@@ -0,0 +1 @@
1
+ export type TSelfClosingHtmlElementRenderer = (cssClass?: string, attributes?: Record<string, any>, styles?: Record<string, string>) => string;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1 @@
1
+ export declare function selfClosingTag(tag: string, cssClass?: string, attributes?: Record<string, any>, styles?: Record<string, string>): string;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.selfClosingTag = void 0;
4
+ const tag_function_1 = require("./tag.function");
5
+ function selfClosingTag(tag, cssClass, attributes, styles) {
6
+ return (0, tag_function_1.tag)(tag, [], cssClass, attributes, styles).replace(`></${tag}>`, '/>');
7
+ }
8
+ exports.selfClosingTag = selfClosingTag;
@@ -0,0 +1 @@
1
+ export declare function tag(tag: string, content: Array<string | number>, cssClass?: string, attributes?: Record<string, any>, styles?: Record<string, string>): string;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.tag = void 0;
4
+ const format_attributes_function_1 = require("../primitives/format-attributes.function");
5
+ const inline_style_function_1 = require("../primitives/inline-style.function");
6
+ function tag(tag, content, cssClass, attributes, styles) {
7
+ const classExp = cssClass ? ` class="${cssClass}"` : '';
8
+ const attributesExp = attributes ? ` ${(0, format_attributes_function_1.formatAttributes)(attributes)}` : '';
9
+ const styleExp = styles ? ` ${(0, inline_style_function_1.inlineStyle)(styles)}` : '';
10
+ return `<${tag}${classExp}${attributesExp}${styleExp}>${content.join?.('')}</${tag}>`;
11
+ }
12
+ exports.tag = tag;
@@ -0,0 +1,24 @@
1
+ import { THtmlElementRenderer } from "./html-element-renderer.type";
2
+ import { TSelfClosingHtmlElementRenderer } from "./self-closing-html-element-renderer.type";
3
+ export declare const _body: THtmlElementRenderer;
4
+ export declare const _div: THtmlElementRenderer;
5
+ export declare const _h1: THtmlElementRenderer;
6
+ export declare const _h2: THtmlElementRenderer;
7
+ export declare const _h3: THtmlElementRenderer;
8
+ export declare const _h4: THtmlElementRenderer;
9
+ export declare const _h5: THtmlElementRenderer;
10
+ export declare const _h6: THtmlElementRenderer;
11
+ export declare const _head: THtmlElementRenderer;
12
+ export declare const _header: THtmlElementRenderer;
13
+ export declare const _htm: THtmlElementRenderer;
14
+ export declare const _img: TSelfClosingHtmlElementRenderer;
15
+ export declare const _main: THtmlElementRenderer;
16
+ export declare const _p: THtmlElementRenderer;
17
+ export declare const _pre: THtmlElementRenderer;
18
+ export declare const _tab: THtmlElementRenderer;
19
+ export declare const _tbody: THtmlElementRenderer;
20
+ export declare const _td: THtmlElementRenderer;
21
+ export declare const _th: THtmlElementRenderer;
22
+ export declare const _thead: THtmlElementRenderer;
23
+ export declare const _tr: THtmlElementRenderer;
24
+ export declare const _style: any;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports._style = exports._tr = exports._thead = exports._th = exports._td = exports._tbody = exports._tab = exports._pre = exports._p = exports._main = exports._img = exports._htm = exports._header = exports._head = exports._h6 = exports._h5 = exports._h4 = exports._h3 = exports._h2 = exports._h1 = exports._div = exports._body = void 0;
4
+ const self_closing_tag_function_1 = require("./self-closing-tag.function");
5
+ const tag_function_1 = require("./tag.function");
6
+ exports._body = tag_function_1.tag.bind(null, 'body');
7
+ exports._div = tag_function_1.tag.bind(null, 'div');
8
+ exports._h1 = tag_function_1.tag.bind(null, 'h1');
9
+ exports._h2 = tag_function_1.tag.bind(null, 'h2');
10
+ exports._h3 = tag_function_1.tag.bind(null, 'h3');
11
+ exports._h4 = tag_function_1.tag.bind(null, 'h4');
12
+ exports._h5 = tag_function_1.tag.bind(null, 'h5');
13
+ exports._h6 = tag_function_1.tag.bind(null, 'h6');
14
+ exports._head = tag_function_1.tag.bind(null, 'head');
15
+ exports._header = tag_function_1.tag.bind(null, 'header');
16
+ exports._htm = tag_function_1.tag.bind(null, 'html');
17
+ exports._img = self_closing_tag_function_1.selfClosingTag.bind(null, 'img');
18
+ exports._main = tag_function_1.tag.bind(null, 'main');
19
+ exports._p = tag_function_1.tag.bind(null, 'p');
20
+ exports._pre = tag_function_1.tag.bind(null, 'pre');
21
+ exports._tab = tag_function_1.tag.bind(null, 'table');
22
+ exports._tbody = tag_function_1.tag.bind(null, 'tbody');
23
+ exports._td = tag_function_1.tag.bind(null, 'td');
24
+ exports._th = tag_function_1.tag.bind(null, 'th');
25
+ exports._thead = tag_function_1.tag.bind(null, 'thead');
26
+ exports._tr = tag_function_1.tag.bind(null, 'tr');
27
+ exports._style = tag_function_1.tag.bind(null, 'style');
@@ -0,0 +1,2 @@
1
+ import { TAttributes } from './types/attributes.type';
2
+ export declare function emailBody(title: string, subtitle: string, markup: Array<string | number>, logoUrl?: string, extraStyles?: TAttributes['style']): string;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.emailBody = void 0;
4
+ const elements_1 = require("./primitives/elements");
5
+ const font_styles_constant_1 = require("./styles/font-styles.constant");
6
+ function emailBody(title, subtitle, markup, logoUrl, extraStyles = {}) {
7
+ return (0, elements_1.div)([
8
+ (0, elements_1.div)([
9
+ (0, elements_1.div)([
10
+ logoUrl
11
+ ? `<img height="64" width="auto" src="${logoUrl}" />`
12
+ : undefined,
13
+ title ? (0, elements_1.h1)([title]) : undefined,
14
+ subtitle ? (0, elements_1.h2)([subtitle]) : undefined,
15
+ ].filter(Boolean)),
16
+ (0, elements_1.div)(markup),
17
+ ], {
18
+ style: {
19
+ ...font_styles_constant_1.fontStyles,
20
+ ...(extraStyles || {})
21
+ }
22
+ }),
23
+ ]);
24
+ }
25
+ exports.emailBody = emailBody;
@@ -0,0 +1,2 @@
1
+ import { TAttributes } from "../types/attributes.type";
2
+ export declare function element(tag: string, content: Array<string | number>, attributes?: TAttributes): string;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.element = void 0;
4
+ const format_attributes_function_1 = require("./format-attributes.function");
5
+ const inline_style_function_1 = require("./inline-style.function");
6
+ function element(tag, content, attributes) {
7
+ const { cssClass = '', style = undefined, ...attrs } = attributes || {};
8
+ const classExp = cssClass ? ` class="${cssClass}"` : '';
9
+ const attributesExp = attrs ? ` ${(0, format_attributes_function_1.formatAttributes)(attrs)}` : '';
10
+ const styleExp = style ? ` ${(0, inline_style_function_1.inlineStyle)(style)}` : '';
11
+ return `<${tag}${classExp}${attributesExp}${styleExp}>${content.join?.('')}</${tag}>`;
12
+ }
13
+ exports.element = element;
@@ -0,0 +1,26 @@
1
+ import { TElementRenderer } from "../types/element-renderer.type";
2
+ import { TSelfClosingElementRenderer } from "../types/self-closing-element-renderer.type";
3
+ export declare const anchor: TElementRenderer;
4
+ export declare const body: TElementRenderer;
5
+ export declare const button: TElementRenderer;
6
+ export declare const div: TElementRenderer;
7
+ export declare const h1: TElementRenderer;
8
+ export declare const h2: TElementRenderer;
9
+ export declare const h3: TElementRenderer;
10
+ export declare const h4: TElementRenderer;
11
+ export declare const h5: TElementRenderer;
12
+ export declare const h6: TElementRenderer;
13
+ export declare const head: TElementRenderer;
14
+ export declare const header: TElementRenderer;
15
+ export declare const htm: TElementRenderer;
16
+ export declare const img: TSelfClosingElementRenderer;
17
+ export declare const main: TElementRenderer;
18
+ export declare const p: TElementRenderer;
19
+ export declare const pre: TElementRenderer;
20
+ export declare const tab: TElementRenderer;
21
+ export declare const tbody: TElementRenderer;
22
+ export declare const td: TElementRenderer;
23
+ export declare const th: TElementRenderer;
24
+ export declare const thead: TElementRenderer;
25
+ export declare const tr: TElementRenderer;
26
+ export declare const style: any;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.style = exports.tr = exports.thead = exports.th = exports.td = exports.tbody = exports.tab = exports.pre = exports.p = exports.main = exports.img = exports.htm = exports.header = exports.head = exports.h6 = exports.h5 = exports.h4 = exports.h3 = exports.h2 = exports.h1 = exports.div = exports.button = exports.body = exports.anchor = void 0;
4
+ const element_function_1 = require("./element.function");
5
+ const self_closing_element_function_1 = require("./self-closing-element.function");
6
+ const button_styles_constant_1 = require("../styles/button-styles.constant");
7
+ const anchor = (content, attributes) => (0, element_function_1.element)('a', content, { ...attributes, style: { ...button_styles_constant_1.buttonStyles, ...attributes?.style } });
8
+ exports.anchor = anchor;
9
+ exports.body = element_function_1.element.bind(null, 'body');
10
+ const button = (content, attributes) => (0, element_function_1.element)('button', content, { ...attributes, style: { ...button_styles_constant_1.buttonStyles, ...attributes?.style } });
11
+ exports.button = button;
12
+ exports.div = element_function_1.element.bind(null, 'div');
13
+ exports.h1 = element_function_1.element.bind(null, 'h1');
14
+ exports.h2 = element_function_1.element.bind(null, 'h2');
15
+ exports.h3 = element_function_1.element.bind(null, 'h3');
16
+ exports.h4 = element_function_1.element.bind(null, 'h4');
17
+ exports.h5 = element_function_1.element.bind(null, 'h5');
18
+ exports.h6 = element_function_1.element.bind(null, 'h6');
19
+ exports.head = element_function_1.element.bind(null, 'head');
20
+ exports.header = element_function_1.element.bind(null, 'header');
21
+ exports.htm = element_function_1.element.bind(null, 'html');
22
+ exports.img = self_closing_element_function_1.selfClosingElement.bind(null, 'img');
23
+ exports.main = element_function_1.element.bind(null, 'main');
24
+ exports.p = element_function_1.element.bind(null, 'p');
25
+ exports.pre = element_function_1.element.bind(null, 'pre');
26
+ exports.tab = element_function_1.element.bind(null, 'table');
27
+ exports.tbody = element_function_1.element.bind(null, 'tbody');
28
+ exports.td = element_function_1.element.bind(null, 'td');
29
+ exports.th = element_function_1.element.bind(null, 'th');
30
+ exports.thead = element_function_1.element.bind(null, 'thead');
31
+ exports.tr = element_function_1.element.bind(null, 'tr');
32
+ // todo: make this take a Record<string, Record<string, string>> instead of the terrible raw string formatting used now
33
+ // todo: apply kebab-casing to camelCased keys so that consumers can write { fontWeight: 600 } instead of {'font-weight': 600 } (do this for all style properties of primitives' attributes)
34
+ exports.style = element_function_1.element.bind(null, 'style');
@@ -0,0 +1 @@
1
+ export declare function formatAttributes(attributes: Record<string, any>): string;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.formatAttributes = void 0;
4
+ function formatAttributes(attributes) {
5
+ return Object.entries(attributes)
6
+ .map(([k, v]) => `${k}="${v}"`)
7
+ .join(' ');
8
+ }
9
+ exports.formatAttributes = formatAttributes;
@@ -0,0 +1 @@
1
+ export declare function inlineStyle(styles: Record<string, string>): string;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.inlineStyle = void 0;
4
+ function inlineStyle(styles) {
5
+ const rules = Object.entries(styles)
6
+ .map(([k, v]) => `${k}: ${v};`)
7
+ .join(' ');
8
+ return `style="${rules}"`;
9
+ }
10
+ exports.inlineStyle = inlineStyle;
@@ -0,0 +1,2 @@
1
+ import { TAttributes } from "../types/attributes.type";
2
+ export declare function selfClosingElement(tag: string, attributes: TAttributes): string;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.selfClosingElement = void 0;
4
+ const element_function_1 = require("./element.function");
5
+ function selfClosingElement(tag, attributes) {
6
+ return (0, element_function_1.element)(tag, [], attributes).replace(`></${tag}>`, '/>');
7
+ }
8
+ exports.selfClosingElement = selfClosingElement;
@@ -0,0 +1,11 @@
1
+ export declare const buttonStyles: {
2
+ padding: string;
3
+ border: string;
4
+ 'border-radius': string;
5
+ display: string;
6
+ 'font-weight': string;
7
+ 'text-align': string;
8
+ 'text-decoration': string;
9
+ 'box-sizing': string;
10
+ color: string;
11
+ };
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buttonStyles = void 0;
4
+ exports.buttonStyles = {
5
+ padding: '1rem 1.5rem',
6
+ border: 'solid 1px',
7
+ 'border-radius': '4px',
8
+ display: 'inline-block',
9
+ 'font-weight': '600',
10
+ 'text-align': 'center',
11
+ 'text-decoration': 'none',
12
+ 'box-sizing': 'border-box',
13
+ color: 'inherit'
14
+ };
@@ -0,0 +1,7 @@
1
+ export declare const fontStyles: {
2
+ 'font-family': string;
3
+ 'font-size': string;
4
+ '-webkit-font-smoothing': string;
5
+ '-moz-osx-font-smoothing': string;
6
+ color: string;
7
+ };
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fontStyles = void 0;
4
+ exports.fontStyles = {
5
+ 'font-family': `-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol' !important`,
6
+ 'font-size': `1rem;`,
7
+ '-webkit-font-smoothing': `antialiased`,
8
+ '-moz-osx-font-smoothing': `grayscale`,
9
+ color: 'rgba(0, 0, 0, 0.5) !important',
10
+ };
@@ -0,0 +1 @@
1
+ export declare function table(columns: string[], rows: Array<any[]>): string;