@onivoro/server-html 0.0.5 → 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 (131) hide show
  1. package/dist/cjs/index.d.ts +20 -0
  2. package/dist/cjs/index.js +36 -0
  3. package/{src/lib → dist/cjs/lib/deprecated}/a.function.js +0 -1
  4. package/{src/lib → dist/cjs/lib/deprecated}/html-element-renderer.type.js +0 -1
  5. package/{src/lib → dist/cjs/lib/deprecated}/html.function.js +0 -1
  6. package/{src/lib → dist/cjs/lib/deprecated}/login-button.function.js +3 -8
  7. package/dist/cjs/lib/deprecated/self-closing-html-element-renderer.type.js +2 -0
  8. package/{src/lib → dist/cjs/lib/deprecated}/self-closing-tag.function.js +0 -1
  9. package/{src/lib → dist/cjs/lib/deprecated}/tag.function.js +2 -3
  10. package/{src/lib → dist/cjs/lib/deprecated}/tags.js +0 -1
  11. package/{src → dist/cjs}/lib/email-body.function.d.ts +1 -1
  12. package/{src → dist/cjs}/lib/email-body.function.js +3 -7
  13. package/dist/cjs/lib/primitives/element.function.d.ts +2 -0
  14. package/{src/lib → dist/cjs/lib/primitives}/element.function.js +0 -1
  15. package/{src/lib → dist/cjs/lib/primitives}/elements.d.ts +3 -2
  16. package/{src/lib → dist/cjs/lib/primitives}/elements.js +8 -3
  17. package/{src/lib → dist/cjs/lib/primitives}/format-attributes.function.js +0 -1
  18. package/{src/lib → dist/cjs/lib/primitives}/inline-style.function.js +0 -1
  19. package/{src/lib → dist/cjs/lib/primitives}/self-closing-element.function.d.ts +1 -1
  20. package/{src/lib → dist/cjs/lib/primitives}/self-closing-element.function.js +0 -1
  21. package/dist/cjs/lib/styles/button-styles.constant.d.ts +11 -0
  22. package/dist/cjs/lib/styles/button-styles.constant.js +14 -0
  23. package/dist/cjs/lib/styles/font-styles.constant.d.ts +7 -0
  24. package/dist/cjs/lib/styles/font-styles.constant.js +10 -0
  25. package/dist/cjs/lib/table.function.js +13 -0
  26. package/{src/lib → dist/cjs/lib/types}/attributes.type.js +0 -1
  27. package/{src/lib → dist/cjs/lib/types}/element-renderer.type.js +0 -1
  28. package/{src/lib → dist/cjs/lib/types}/self-closing-element-renderer.type.js +0 -1
  29. package/dist/esm/index.d.ts +20 -0
  30. package/dist/esm/index.js +36 -0
  31. package/dist/esm/lib/deprecated/a.function.d.ts +1 -0
  32. package/dist/esm/lib/deprecated/a.function.js +8 -0
  33. package/dist/esm/lib/deprecated/html-element-renderer.type.d.ts +1 -0
  34. package/dist/esm/lib/deprecated/html-element-renderer.type.js +2 -0
  35. package/dist/esm/lib/deprecated/html.function.d.ts +1 -0
  36. package/dist/esm/lib/deprecated/html.function.js +43 -0
  37. package/dist/esm/lib/deprecated/login-button.function.d.ts +1 -0
  38. package/dist/esm/lib/deprecated/login-button.function.js +15 -0
  39. package/dist/esm/lib/deprecated/self-closing-html-element-renderer.type.d.ts +1 -0
  40. package/dist/esm/lib/deprecated/self-closing-html-element-renderer.type.js +2 -0
  41. package/dist/esm/lib/deprecated/self-closing-tag.function.d.ts +1 -0
  42. package/dist/esm/lib/deprecated/self-closing-tag.function.js +8 -0
  43. package/dist/esm/lib/deprecated/tag.function.d.ts +1 -0
  44. package/dist/esm/lib/deprecated/tag.function.js +12 -0
  45. package/dist/esm/lib/deprecated/tags.d.ts +24 -0
  46. package/dist/esm/lib/deprecated/tags.js +27 -0
  47. package/dist/esm/lib/email-body.function.d.ts +2 -0
  48. package/dist/esm/lib/email-body.function.js +25 -0
  49. package/dist/esm/lib/primitives/element.function.d.ts +2 -0
  50. package/dist/esm/lib/primitives/element.function.js +13 -0
  51. package/dist/esm/lib/primitives/elements.d.ts +26 -0
  52. package/dist/esm/lib/primitives/elements.js +34 -0
  53. package/dist/esm/lib/primitives/format-attributes.function.d.ts +1 -0
  54. package/dist/esm/lib/primitives/format-attributes.function.js +9 -0
  55. package/dist/esm/lib/primitives/inline-style.function.d.ts +1 -0
  56. package/dist/esm/lib/primitives/inline-style.function.js +10 -0
  57. package/dist/esm/lib/primitives/self-closing-element.function.d.ts +2 -0
  58. package/dist/esm/lib/primitives/self-closing-element.function.js +8 -0
  59. package/dist/esm/lib/styles/button-styles.constant.d.ts +11 -0
  60. package/dist/esm/lib/styles/button-styles.constant.js +14 -0
  61. package/dist/esm/lib/styles/font-styles.constant.d.ts +7 -0
  62. package/dist/esm/lib/styles/font-styles.constant.js +10 -0
  63. package/dist/esm/lib/table.function.d.ts +1 -0
  64. package/dist/esm/lib/table.function.js +13 -0
  65. package/dist/esm/lib/types/attributes.type.d.ts +4 -0
  66. package/dist/esm/lib/types/attributes.type.js +2 -0
  67. package/dist/esm/lib/types/element-renderer.type.d.ts +2 -0
  68. package/dist/esm/lib/types/element-renderer.type.js +2 -0
  69. package/dist/esm/lib/types/self-closing-element-renderer.type.d.ts +2 -0
  70. package/dist/esm/lib/types/self-closing-element-renderer.type.js +2 -0
  71. package/dist/types/index.d.ts +20 -0
  72. package/dist/types/lib/deprecated/a.function.d.ts +1 -0
  73. package/dist/types/lib/deprecated/html-element-renderer.type.d.ts +1 -0
  74. package/dist/types/lib/deprecated/html.function.d.ts +1 -0
  75. package/dist/types/lib/deprecated/login-button.function.d.ts +1 -0
  76. package/dist/types/lib/deprecated/self-closing-html-element-renderer.type.d.ts +1 -0
  77. package/dist/types/lib/deprecated/self-closing-tag.function.d.ts +1 -0
  78. package/dist/types/lib/deprecated/tag.function.d.ts +1 -0
  79. package/dist/types/lib/deprecated/tags.d.ts +24 -0
  80. package/dist/types/lib/email-body.function.d.ts +2 -0
  81. package/dist/types/lib/primitives/element.function.d.ts +2 -0
  82. package/dist/types/lib/primitives/elements.d.ts +26 -0
  83. package/dist/types/lib/primitives/format-attributes.function.d.ts +1 -0
  84. package/dist/types/lib/primitives/inline-style.function.d.ts +1 -0
  85. package/dist/types/lib/primitives/self-closing-element.function.d.ts +2 -0
  86. package/dist/types/lib/styles/button-styles.constant.d.ts +11 -0
  87. package/dist/types/lib/styles/font-styles.constant.d.ts +7 -0
  88. package/dist/types/lib/table.function.d.ts +1 -0
  89. package/dist/types/lib/types/attributes.type.d.ts +4 -0
  90. package/dist/types/lib/types/element-renderer.type.d.ts +2 -0
  91. package/dist/types/lib/types/self-closing-element-renderer.type.d.ts +2 -0
  92. package/package.json +40 -5
  93. package/README.md +0 -11
  94. package/src/index.d.ts +0 -18
  95. package/src/index.js +0 -22
  96. package/src/index.js.map +0 -1
  97. package/src/lib/a.function.js.map +0 -1
  98. package/src/lib/attributes.type.js.map +0 -1
  99. package/src/lib/element-renderer.type.js.map +0 -1
  100. package/src/lib/element.function.d.ts +0 -2
  101. package/src/lib/element.function.js.map +0 -1
  102. package/src/lib/elements.js.map +0 -1
  103. package/src/lib/email-body.function.js.map +0 -1
  104. package/src/lib/format-attributes.function.js.map +0 -1
  105. package/src/lib/html-element-renderer.type.js.map +0 -1
  106. package/src/lib/html.function.js.map +0 -1
  107. package/src/lib/inline-style.function.js.map +0 -1
  108. package/src/lib/login-button.function.js.map +0 -1
  109. package/src/lib/self-closing-element-renderer.type.js.map +0 -1
  110. package/src/lib/self-closing-element.function.js.map +0 -1
  111. package/src/lib/self-closing-html-element-renderer.type.js +0 -3
  112. package/src/lib/self-closing-html-element-renderer.type.js.map +0 -1
  113. package/src/lib/self-closing-tag.function.js.map +0 -1
  114. package/src/lib/table.function.js +0 -12
  115. package/src/lib/table.function.js.map +0 -1
  116. package/src/lib/tag.function.js.map +0 -1
  117. package/src/lib/tags.js.map +0 -1
  118. /package/{src/lib → dist/cjs/lib/deprecated}/a.function.d.ts +0 -0
  119. /package/{src/lib → dist/cjs/lib/deprecated}/html-element-renderer.type.d.ts +0 -0
  120. /package/{src/lib → dist/cjs/lib/deprecated}/html.function.d.ts +0 -0
  121. /package/{src/lib → dist/cjs/lib/deprecated}/login-button.function.d.ts +0 -0
  122. /package/{src/lib → dist/cjs/lib/deprecated}/self-closing-html-element-renderer.type.d.ts +0 -0
  123. /package/{src/lib → dist/cjs/lib/deprecated}/self-closing-tag.function.d.ts +0 -0
  124. /package/{src/lib → dist/cjs/lib/deprecated}/tag.function.d.ts +0 -0
  125. /package/{src/lib → dist/cjs/lib/deprecated}/tags.d.ts +0 -0
  126. /package/{src/lib → dist/cjs/lib/primitives}/format-attributes.function.d.ts +0 -0
  127. /package/{src/lib → dist/cjs/lib/primitives}/inline-style.function.d.ts +0 -0
  128. /package/{src → dist/cjs}/lib/table.function.d.ts +0 -0
  129. /package/{src/lib → dist/cjs/lib/types}/attributes.type.d.ts +0 -0
  130. /package/{src/lib → dist/cjs/lib/types}/element-renderer.type.d.ts +0 -0
  131. /package/{src/lib → dist/cjs/lib/types}/self-closing-element-renderer.type.d.ts +0 -0
@@ -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);
@@ -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
@@ -1,20 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.loginButton = void 0;
4
- const elements_1 = require("./elements");
4
+ const elements_1 = require("../primitives/elements");
5
+ const button_styles_constant_1 = require("../styles/button-styles.constant");
5
6
  function loginButton(text, href, extraStyles) {
6
7
  return (0, elements_1.anchor)([text], {
7
8
  href,
8
9
  style: {
9
- padding: '1rem 1.5rem',
10
- border: 'solid 1px',
11
- 'border-radius': '4px',
12
- display: 'inline-block',
13
- 'text-align': 'center',
14
- 'text-decoration': 'none',
10
+ ...button_styles_constant_1.buttonStyles,
15
11
  ...(extraStyles || {})
16
12
  }
17
13
  });
18
14
  }
19
15
  exports.loginButton = loginButton;
20
- //# 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
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.tag = void 0;
4
- const format_attributes_function_1 = require("./format-attributes.function");
5
- const inline_style_function_1 = require("./inline-style.function");
4
+ const format_attributes_function_1 = require("../primitives/format-attributes.function");
5
+ const inline_style_function_1 = require("../primitives/inline-style.function");
6
6
  function tag(tag, content, cssClass, attributes, styles) {
7
7
  const classExp = cssClass ? ` class="${cssClass}"` : '';
8
8
  const attributesExp = attributes ? ` ${(0, format_attributes_function_1.formatAttributes)(attributes)}` : '';
@@ -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
@@ -1,2 +1,2 @@
1
- import { TAttributes } from './attributes.type';
1
+ import { TAttributes } from './types/attributes.type';
2
2
  export declare function emailBody(title: string, subtitle: string, markup: Array<string | number>, logoUrl?: string, extraStyles?: TAttributes['style']): string;
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.emailBody = void 0;
4
- const elements_1 = require("./elements");
4
+ const elements_1 = require("./primitives/elements");
5
+ const font_styles_constant_1 = require("./styles/font-styles.constant");
5
6
  function emailBody(title, subtitle, markup, logoUrl, extraStyles = {}) {
6
7
  return (0, elements_1.div)([
7
8
  (0, elements_1.div)([
@@ -15,15 +16,10 @@ function emailBody(title, subtitle, markup, logoUrl, extraStyles = {}) {
15
16
  (0, elements_1.div)(markup),
16
17
  ], {
17
18
  style: {
18
- 'font-family': `-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol' !important`,
19
- 'font-size': `1rem;`,
20
- '-webkit-font-smoothing': `antialiased`,
21
- '-moz-osx-font-smoothing': `grayscale`,
22
- color: 'rgba(0, 0, 0, 0.6) !important',
19
+ ...font_styles_constant_1.fontStyles,
23
20
  ...(extraStyles || {})
24
21
  }
25
22
  }),
26
23
  ]);
27
24
  }
28
25
  exports.emailBody = emailBody;
29
- //# sourceMappingURL=email-body.function.js.map
@@ -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;
@@ -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
@@ -1,7 +1,8 @@
1
- import { TElementRenderer } from "./element-renderer.type";
2
- import { TSelfClosingElementRenderer } from "./self-closing-element-renderer.type";
1
+ import { TElementRenderer } from "../types/element-renderer.type";
2
+ import { TSelfClosingElementRenderer } from "../types/self-closing-element-renderer.type";
3
3
  export declare const anchor: TElementRenderer;
4
4
  export declare const body: TElementRenderer;
5
+ export declare const button: TElementRenderer;
5
6
  export declare const div: TElementRenderer;
6
7
  export declare const h1: TElementRenderer;
7
8
  export declare const h2: TElementRenderer;
@@ -1,10 +1,14 @@
1
1
  "use strict";
2
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 = exports.anchor = void 0;
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
4
  const element_function_1 = require("./element.function");
5
5
  const self_closing_element_function_1 = require("./self-closing-element.function");
6
- exports.anchor = element_function_1.element.bind(null, 'a');
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;
7
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;
8
12
  exports.div = element_function_1.element.bind(null, 'div');
9
13
  exports.h1 = element_function_1.element.bind(null, 'h1');
10
14
  exports.h2 = element_function_1.element.bind(null, 'h2');
@@ -25,5 +29,6 @@ exports.td = element_function_1.element.bind(null, 'td');
25
29
  exports.th = element_function_1.element.bind(null, 'th');
26
30
  exports.thead = element_function_1.element.bind(null, 'thead');
27
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)
28
34
  exports.style = element_function_1.element.bind(null, 'style');
29
- //# 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
@@ -1,2 +1,2 @@
1
- import { TAttributes } from "./attributes.type";
1
+ import { TAttributes } from "../types/attributes.type";
2
2
  export declare function selfClosingElement(tag: string, attributes: TAttributes): string;
@@ -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
@@ -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,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.table = void 0;
4
+ const elements_1 = require("./primitives/elements");
5
+ const padding = '0.5rem';
6
+ const color = 'inherit';
7
+ function table(columns, rows) {
8
+ return (0, elements_1.tab)([
9
+ (0, elements_1.thead)([(0, elements_1.tr)(columns.map((c) => (0, elements_1.th)([c], { style: { 'text-align': 'left', padding, color } })), { style: { 'border-bottom-color': color, 'border-bottom-style': 'solid', 'border-top-style': 'none', 'border-left-style': 'none', 'border-right-style': 'none' } })]),
10
+ (0, elements_1.tbody)(rows.map((row, i) => (0, elements_1.tr)(row.map((cell) => (0, elements_1.td)([cell], { style: { padding, color } })), { style: { 'background-color': i % 2 ? '' : 'rgba(0, 0, 0, 0.2)', padding, color } }))),
11
+ ], { style: { 'border-collapse': 'collapse', width: '100%', color } });
12
+ }
13
+ exports.table = table;
@@ -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;