@onivoro/server-html 0.1.1 → 24.24.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.
Files changed (174) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +281 -0
  3. package/package.json +25 -39
  4. package/{dist/cjs → src}/index.d.ts +2 -0
  5. package/src/index.js +25 -0
  6. package/src/index.js.map +1 -0
  7. package/{dist/esm → src}/lib/deprecated/a.function.d.ts +1 -0
  8. package/{dist/esm → src}/lib/deprecated/a.function.js +2 -2
  9. package/src/lib/deprecated/a.function.js.map +1 -0
  10. package/{dist/cjs → src}/lib/deprecated/html-element-renderer.type.d.ts +1 -0
  11. package/{dist/esm → src}/lib/deprecated/html-element-renderer.type.js +1 -0
  12. package/src/lib/deprecated/html-element-renderer.type.js.map +1 -0
  13. package/{dist/cjs → src}/lib/deprecated/html.function.d.ts +1 -0
  14. package/{dist/cjs → src}/lib/deprecated/html.function.js +2 -2
  15. package/src/lib/deprecated/html.function.js.map +1 -0
  16. package/{dist/cjs → src}/lib/deprecated/login-button.function.d.ts +1 -0
  17. package/{dist/cjs → src}/lib/deprecated/login-button.function.js +2 -2
  18. package/src/lib/deprecated/login-button.function.js.map +1 -0
  19. package/{dist/cjs → src}/lib/deprecated/self-closing-html-element-renderer.type.d.ts +1 -0
  20. package/{dist/esm → src}/lib/deprecated/self-closing-html-element-renderer.type.js +1 -0
  21. package/src/lib/deprecated/self-closing-html-element-renderer.type.js.map +1 -0
  22. package/{dist/cjs → src}/lib/deprecated/self-closing-tag.function.d.ts +1 -0
  23. package/{dist/esm → src}/lib/deprecated/self-closing-tag.function.js +2 -2
  24. package/src/lib/deprecated/self-closing-tag.function.js.map +1 -0
  25. package/{dist/cjs → src}/lib/deprecated/tag.function.d.ts +1 -0
  26. package/{dist/esm → src}/lib/deprecated/tag.function.js +2 -2
  27. package/src/lib/deprecated/tag.function.js.map +1 -0
  28. package/{dist/cjs → src}/lib/deprecated/tags.d.ts +2 -1
  29. package/{dist/esm → src}/lib/deprecated/tags.js +1 -0
  30. package/src/lib/deprecated/tags.js.map +1 -0
  31. package/src/lib/dom/index.d.ts +139 -0
  32. package/src/lib/dom/index.js +142 -0
  33. package/src/lib/dom/index.js.map +1 -0
  34. package/src/lib/dom/lib/constants/style-manager.constant.d.ts +12 -0
  35. package/src/lib/dom/lib/constants/style-manager.constant.js +28 -0
  36. package/src/lib/dom/lib/constants/style-manager.constant.js.map +1 -0
  37. package/src/lib/dom/lib/functions/as-element-factory.function.d.ts +4 -0
  38. package/src/lib/dom/lib/functions/as-element-factory.function.js +22 -0
  39. package/src/lib/dom/lib/functions/as-element-factory.function.js.map +1 -0
  40. package/src/lib/dom/lib/functions/as-id.function.d.ts +2 -0
  41. package/src/lib/dom/lib/functions/as-id.function.js +9 -0
  42. package/src/lib/dom/lib/functions/as-id.function.js.map +1 -0
  43. package/src/lib/dom/lib/functions/extract-style.function.d.ts +2 -0
  44. package/src/lib/dom/lib/functions/extract-style.function.js +7 -0
  45. package/src/lib/dom/lib/functions/extract-style.function.js.map +1 -0
  46. package/src/lib/dom/lib/functions/set-element-attributes.function.d.ts +2 -0
  47. package/src/lib/dom/lib/functions/set-element-attributes.function.js +6 -0
  48. package/src/lib/dom/lib/functions/set-element-attributes.function.js.map +1 -0
  49. package/src/lib/dom/lib/functions/set-element-style.function.d.ts +2 -0
  50. package/src/lib/dom/lib/functions/set-element-style.function.js +6 -0
  51. package/src/lib/dom/lib/functions/set-element-style.function.js.map +1 -0
  52. package/src/lib/dom/lib/functions/set-element-styles.function.d.ts +2 -0
  53. package/src/lib/dom/lib/functions/set-element-styles.function.js +6 -0
  54. package/src/lib/dom/lib/functions/set-element-styles.function.js.map +1 -0
  55. package/src/lib/dom/lib/functions/style-on-focus.function.d.ts +2 -0
  56. package/src/lib/dom/lib/functions/style-on-focus.function.js +8 -0
  57. package/src/lib/dom/lib/functions/style-on-focus.function.js.map +1 -0
  58. package/src/lib/dom/lib/functions/style-on-pointer-enter.function.d.ts +2 -0
  59. package/src/lib/dom/lib/functions/style-on-pointer-enter.function.js +8 -0
  60. package/src/lib/dom/lib/functions/style-on-pointer-enter.function.js.map +1 -0
  61. package/src/lib/dom/lib/functions/style-on.function.d.ts +2 -0
  62. package/src/lib/dom/lib/functions/style-on.function.js +6 -0
  63. package/src/lib/dom/lib/functions/style-on.function.js.map +1 -0
  64. package/src/lib/dom/lib/functions/styled.function.d.ts +2 -0
  65. package/src/lib/dom/lib/functions/styled.function.js +16 -0
  66. package/src/lib/dom/lib/functions/styled.function.js.map +1 -0
  67. package/src/lib/dom/lib/types/css-properties.type.d.ts +5 -0
  68. package/{dist/cjs/lib/deprecated/self-closing-html-element-renderer.type.js → src/lib/dom/lib/types/css-properties.type.js} +1 -0
  69. package/src/lib/dom/lib/types/css-properties.type.js.map +1 -0
  70. package/src/lib/dom/lib/types/element-props.type.d.ts +10 -0
  71. package/{dist/cjs/lib/deprecated/html-element-renderer.type.js → src/lib/dom/lib/types/element-props.type.js} +1 -0
  72. package/src/lib/dom/lib/types/element-props.type.js.map +1 -0
  73. package/{dist/cjs → src}/lib/email-body.function.d.ts +1 -0
  74. package/{dist/esm → src}/lib/email-body.function.js +2 -2
  75. package/src/lib/email-body.function.js.map +1 -0
  76. package/{dist/cjs → src}/lib/primitives/element.function.d.ts +1 -0
  77. package/{dist/esm → src}/lib/primitives/element.function.js +2 -2
  78. package/src/lib/primitives/element.function.js.map +1 -0
  79. package/{dist/cjs → src}/lib/primitives/elements.d.ts +2 -1
  80. package/{dist/esm → src}/lib/primitives/elements.js +1 -2
  81. package/src/lib/primitives/elements.js.map +1 -0
  82. package/src/lib/primitives/format-attributes.function.d.ts +2 -0
  83. package/{dist/esm → src}/lib/primitives/format-attributes.function.js +5 -2
  84. package/src/lib/primitives/format-attributes.function.js.map +1 -0
  85. package/src/lib/primitives/inline-style.function.d.ts +3 -0
  86. package/src/lib/primitives/inline-style.function.js +14 -0
  87. package/src/lib/primitives/inline-style.function.js.map +1 -0
  88. package/{dist/types → src}/lib/primitives/self-closing-element.function.d.ts +2 -1
  89. package/{dist/cjs → src}/lib/primitives/self-closing-element.function.js +2 -2
  90. package/src/lib/primitives/self-closing-element.function.js.map +1 -0
  91. package/{dist/cjs → src}/lib/styles/button-styles.constant.d.ts +1 -0
  92. package/{dist/cjs → src}/lib/styles/button-styles.constant.js +1 -0
  93. package/src/lib/styles/button-styles.constant.js.map +1 -0
  94. package/{dist/types → src}/lib/styles/font-styles.constant.d.ts +1 -0
  95. package/{dist/cjs → src}/lib/styles/font-styles.constant.js +1 -0
  96. package/src/lib/styles/font-styles.constant.js.map +1 -0
  97. package/{dist/cjs → src}/lib/table.function.d.ts +1 -0
  98. package/{dist/cjs → src}/lib/table.function.js +2 -2
  99. package/src/lib/table.function.js.map +1 -0
  100. package/src/lib/types/attributes.type.d.ts +7 -0
  101. package/{dist/esm → src}/lib/types/attributes.type.js +1 -0
  102. package/src/lib/types/attributes.type.js.map +1 -0
  103. package/{dist/cjs → src}/lib/types/element-renderer.type.d.ts +1 -0
  104. package/{dist/esm → src}/lib/types/element-renderer.type.js +1 -0
  105. package/src/lib/types/element-renderer.type.js.map +1 -0
  106. package/{dist/types → src}/lib/types/self-closing-element-renderer.type.d.ts +1 -0
  107. package/{dist/cjs → src}/lib/types/self-closing-element-renderer.type.js +1 -0
  108. package/src/lib/types/self-closing-element-renderer.type.js.map +1 -0
  109. package/dist/cjs/index.js +0 -36
  110. package/dist/cjs/lib/deprecated/a.function.d.ts +0 -1
  111. package/dist/cjs/lib/deprecated/a.function.js +0 -8
  112. package/dist/cjs/lib/deprecated/self-closing-tag.function.js +0 -8
  113. package/dist/cjs/lib/deprecated/tag.function.js +0 -12
  114. package/dist/cjs/lib/deprecated/tags.js +0 -27
  115. package/dist/cjs/lib/email-body.function.js +0 -25
  116. package/dist/cjs/lib/primitives/element.function.js +0 -13
  117. package/dist/cjs/lib/primitives/elements.js +0 -34
  118. package/dist/cjs/lib/primitives/format-attributes.function.d.ts +0 -1
  119. package/dist/cjs/lib/primitives/format-attributes.function.js +0 -9
  120. package/dist/cjs/lib/primitives/inline-style.function.d.ts +0 -1
  121. package/dist/cjs/lib/primitives/inline-style.function.js +0 -10
  122. package/dist/cjs/lib/primitives/self-closing-element.function.d.ts +0 -2
  123. package/dist/cjs/lib/styles/font-styles.constant.d.ts +0 -7
  124. package/dist/cjs/lib/types/attributes.type.d.ts +0 -4
  125. package/dist/cjs/lib/types/attributes.type.js +0 -2
  126. package/dist/cjs/lib/types/element-renderer.type.js +0 -2
  127. package/dist/cjs/lib/types/self-closing-element-renderer.type.d.ts +0 -2
  128. package/dist/esm/index.d.ts +0 -20
  129. package/dist/esm/index.js +0 -36
  130. package/dist/esm/lib/deprecated/html-element-renderer.type.d.ts +0 -1
  131. package/dist/esm/lib/deprecated/html.function.d.ts +0 -1
  132. package/dist/esm/lib/deprecated/html.function.js +0 -43
  133. package/dist/esm/lib/deprecated/login-button.function.d.ts +0 -1
  134. package/dist/esm/lib/deprecated/login-button.function.js +0 -15
  135. package/dist/esm/lib/deprecated/self-closing-html-element-renderer.type.d.ts +0 -1
  136. package/dist/esm/lib/deprecated/self-closing-tag.function.d.ts +0 -1
  137. package/dist/esm/lib/deprecated/tag.function.d.ts +0 -1
  138. package/dist/esm/lib/deprecated/tags.d.ts +0 -24
  139. package/dist/esm/lib/email-body.function.d.ts +0 -2
  140. package/dist/esm/lib/primitives/element.function.d.ts +0 -2
  141. package/dist/esm/lib/primitives/elements.d.ts +0 -26
  142. package/dist/esm/lib/primitives/format-attributes.function.d.ts +0 -1
  143. package/dist/esm/lib/primitives/inline-style.function.d.ts +0 -1
  144. package/dist/esm/lib/primitives/inline-style.function.js +0 -10
  145. package/dist/esm/lib/primitives/self-closing-element.function.d.ts +0 -2
  146. package/dist/esm/lib/primitives/self-closing-element.function.js +0 -8
  147. package/dist/esm/lib/styles/button-styles.constant.d.ts +0 -11
  148. package/dist/esm/lib/styles/button-styles.constant.js +0 -14
  149. package/dist/esm/lib/styles/font-styles.constant.d.ts +0 -7
  150. package/dist/esm/lib/styles/font-styles.constant.js +0 -10
  151. package/dist/esm/lib/table.function.d.ts +0 -1
  152. package/dist/esm/lib/table.function.js +0 -13
  153. package/dist/esm/lib/types/attributes.type.d.ts +0 -4
  154. package/dist/esm/lib/types/element-renderer.type.d.ts +0 -2
  155. package/dist/esm/lib/types/self-closing-element-renderer.type.d.ts +0 -2
  156. package/dist/esm/lib/types/self-closing-element-renderer.type.js +0 -2
  157. package/dist/types/index.d.ts +0 -20
  158. package/dist/types/lib/deprecated/a.function.d.ts +0 -1
  159. package/dist/types/lib/deprecated/html-element-renderer.type.d.ts +0 -1
  160. package/dist/types/lib/deprecated/html.function.d.ts +0 -1
  161. package/dist/types/lib/deprecated/login-button.function.d.ts +0 -1
  162. package/dist/types/lib/deprecated/self-closing-html-element-renderer.type.d.ts +0 -1
  163. package/dist/types/lib/deprecated/self-closing-tag.function.d.ts +0 -1
  164. package/dist/types/lib/deprecated/tag.function.d.ts +0 -1
  165. package/dist/types/lib/deprecated/tags.d.ts +0 -24
  166. package/dist/types/lib/email-body.function.d.ts +0 -2
  167. package/dist/types/lib/primitives/element.function.d.ts +0 -2
  168. package/dist/types/lib/primitives/elements.d.ts +0 -26
  169. package/dist/types/lib/primitives/format-attributes.function.d.ts +0 -1
  170. package/dist/types/lib/primitives/inline-style.function.d.ts +0 -1
  171. package/dist/types/lib/styles/button-styles.constant.d.ts +0 -11
  172. package/dist/types/lib/table.function.d.ts +0 -1
  173. package/dist/types/lib/types/attributes.type.d.ts +0 -4
  174. package/dist/types/lib/types/element-renderer.type.d.ts +0 -2
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Onivoro
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,281 @@
1
+ # @onivoro/server-html
2
+
3
+ A TypeScript library for server-side HTML generation with a functional approach. This package provides a comprehensive set of utilities for creating HTML documents, email templates, and structured markup programmatically.
4
+
5
+ ## Features
6
+
7
+ - **Functional HTML Generation**: Create HTML elements using functional composition
8
+ - **Type-Safe**: Full TypeScript support with proper type definitions
9
+ - **Email Templates**: Pre-built email body and table components
10
+ - **Styling Support**: Built-in style constants and inline styling utilities
11
+ - **Flexible Attributes**: Support for CSS classes, inline styles, and custom attributes
12
+ - **Element Primitives**: Complete set of HTML element builders
13
+ - **Server-Side Focused**: Optimized for server-side rendering scenarios
14
+
15
+ ## Installation
16
+
17
+ ```bash
18
+ npm install @onivoro/server-html
19
+ ```
20
+
21
+ ## Quick Start
22
+
23
+ ```typescript
24
+ import { div, h1, p, button } from '@onivoro/server-html';
25
+
26
+ // Basic element creation
27
+ const title = h1(['Welcome to My Site']);
28
+ const description = p(['This is a sample paragraph.']);
29
+
30
+ // Element with attributes and styling
31
+ const styledDiv = div([title, description], {
32
+ cssClass: 'container',
33
+ style: {
34
+ 'max-width': '800px',
35
+ margin: '0 auto',
36
+ padding: '2rem'
37
+ }
38
+ });
39
+
40
+ // Button with built-in styling
41
+ const actionButton = button(['Click Me'], {
42
+ href: '/action',
43
+ style: { 'background-color': '#007bff', color: 'white' }
44
+ });
45
+
46
+ ## DOM API Compatibility
47
+
48
+ Use the familiar $-prefixed element factories from @vanilla-mint/dom for server-side rendering:
49
+
50
+ ```typescript
51
+ import { $div, $h1, $p, styled } from '@onivoro/server-html';
52
+
53
+ const html = $div({
54
+ className: 'container',
55
+ style: { display: 'flex', flexDirection: 'column' },
56
+ children: [
57
+ $h1({ textContent: 'Server-Side Rendering', style: { fontWeight: 700 }}),
58
+ $p({ textContent: 'This markup was generated on the server.' })
59
+ ]
60
+ });
61
+ ```
62
+
63
+ ## Core Concepts
64
+
65
+ ## Core Concepts
66
+
67
+ ### Element Builders
68
+
69
+ The library provides functional element builders for all common HTML elements:
70
+
71
+ ```typescript
72
+ import {
73
+ div, h1, h2, h3, h4, h5, h6, p,
74
+ button, anchor, img, table, thead,
75
+ tbody, tr, th, td, main, header
76
+ } from '@onivoro/server-html';
77
+
78
+ // All elements follow the same pattern:
79
+ // elementName(content, attributes?)
80
+ const heading = h1(['Page Title']);
81
+ const paragraph = p(['Some content'], { cssClass: 'lead' });
82
+ ```
83
+
84
+ ### Attributes and Styling
85
+
86
+ ```typescript
87
+ import { div } from '@onivoro/server-html';
88
+
89
+ const styledElement = div(['Content'], {
90
+ // CSS class
91
+ cssClass: 'my-class',
92
+
93
+ // Inline styles
94
+ style: {
95
+ 'background-color': '#f8f9fa',
96
+ padding: '1rem',
97
+ 'border-radius': '4px'
98
+ },
99
+
100
+ // Custom attributes
101
+ id: 'unique-id',
102
+ 'data-testid': 'test-element'
103
+ });
104
+ ```
105
+
106
+ ## Email Templates
107
+
108
+ ### Email Body Component
109
+
110
+ Create structured email templates with headers and content:
111
+
112
+ ```typescript
113
+ import { emailBody } from '@onivoro/server-html';
114
+
115
+ const email = emailBody(
116
+ 'Welcome!', // title
117
+ 'Thanks for joining us', // subtitle
118
+ [ // content markup
119
+ '<p>We\'re excited to have you on board.</p>',
120
+ '<p>Get started by exploring our features.</p>'
121
+ ],
122
+ 'https://example.com/logo.png', // optional logo URL
123
+ { // optional extra styles
124
+ 'background-color': '#ffffff',
125
+ 'font-family': 'Arial, sans-serif'
126
+ }
127
+ );
128
+ ```
129
+
130
+ ### Data Tables
131
+
132
+ Generate HTML tables with automatic styling:
133
+
134
+ ```typescript
135
+ import { table } from '@onivoro/server-html';
136
+
137
+ const dataTable = table(
138
+ ['Name', 'Email', 'Role'], // columns
139
+ [ // rows
140
+ ['John Doe', 'john@example.com', 'Admin'],
141
+ ['Jane Smith', 'jane@example.com', 'User'],
142
+ ['Bob Johnson', 'bob@example.com', 'Editor']
143
+ ]
144
+ );
145
+ ```
146
+
147
+ ## Styling Utilities
148
+
149
+ ### Pre-built Styles
150
+
151
+ ```typescript
152
+ import { buttonStyles, fontStyles } from '@onivoro/server-html';
153
+
154
+ // buttonStyles includes:
155
+ // - padding, border, border-radius
156
+ // - font-weight, text-align
157
+ // - display and box-sizing
158
+
159
+ // fontStyles includes:
160
+ // - font-family and other typography settings
161
+ ```
162
+
163
+ ### Inline Style Helpers
164
+
165
+ ```typescript
166
+ import { inlineStyle, formatAttributes } from '@onivoro/server-html';
167
+
168
+ // Convert style object to inline style string
169
+ const styleString = inlineStyle({
170
+ 'font-size': '16px',
171
+ color: '#333'
172
+ });
173
+ // Result: 'style="font-size:16px;color:#333"'
174
+
175
+ // Format attributes for HTML
176
+ const attrString = formatAttributes({
177
+ id: 'my-id',
178
+ 'data-value': '123'
179
+ });
180
+ // Result: 'id="my-id" data-value="123"'
181
+ ```
182
+
183
+ ## Advanced Usage
184
+
185
+ ### Custom Element Creation
186
+
187
+ ```typescript
188
+ import { element, selfClosingElement } from '@onivoro/server-html';
189
+
190
+ // Create custom elements
191
+ const customElement = element('custom-tag', ['content'], {
192
+ 'custom-attr': 'value'
193
+ });
194
+
195
+ // Create self-closing elements
196
+ const input = selfClosingElement('input', {
197
+ type: 'text',
198
+ name: 'username'
199
+ });
200
+ ```
201
+
202
+ ### Complex Layouts
203
+
204
+ ```typescript
205
+ import { div, header, main, h1, p, button } from '@onivoro/server-html';
206
+
207
+ const pageLayout = div([
208
+ header([
209
+ h1(['My Application']),
210
+ ], { cssClass: 'header' }),
211
+
212
+ main([
213
+ div([
214
+ h1(['Welcome']),
215
+ p(['This is the main content area.']),
216
+ button(['Get Started'], {
217
+ style: { 'background-color': '#28a745', color: 'white' }
218
+ })
219
+ ], { cssClass: 'content' })
220
+ ], { cssClass: 'main' })
221
+ ], { cssClass: 'page-wrapper' });
222
+ ```
223
+
224
+ ## API Reference
225
+
226
+ ### Element Builders
227
+
228
+ | Function | Description | Usage |
229
+ |----------|-------------|--------|
230
+ | `div(content, attrs?)` | Create a div element | `div(['content'])` |
231
+ | `h1-h6(content, attrs?)` | Create heading elements | `h1(['Title'])` |
232
+ | `p(content, attrs?)` | Create paragraph | `p(['Text'])` |
233
+ | `button(content, attrs?)` | Create button with built-in styles | `button(['Click'])` |
234
+ | `anchor(content, attrs?)` | Create anchor with button styles | `anchor(['Link'])` |
235
+ | `img(attrs)` | Create image element | `img({ src: 'url' })` |
236
+
237
+ ### Table Elements
238
+
239
+ | Function | Description |
240
+ |----------|-------------|
241
+ | `tab(content, attrs?)` | Table wrapper |
242
+ | `thead(content, attrs?)` | Table header |
243
+ | `tbody(content, attrs?)` | Table body |
244
+ | `tr(content, attrs?)` | Table row |
245
+ | `th(content, attrs?)` | Table header cell |
246
+ | `td(content, attrs?)` | Table data cell |
247
+
248
+ ### Utilities
249
+
250
+ | Function | Description |
251
+ |----------|-------------|
252
+ | `emailBody(title, subtitle, content, logo?, styles?)` | Email template |
253
+ | `table(columns, rows)` | Data table generator |
254
+ | `formatAttributes(attrs)` | Format HTML attributes |
255
+ | `inlineStyle(styles)` | Convert style object to string |
256
+
257
+ ## Type Definitions
258
+
259
+ ```typescript
260
+ type TAttributes = Record<string, any> & {
261
+ cssClass?: string;
262
+ style?: Record<string, string>;
263
+ };
264
+
265
+ type TElementRenderer = (
266
+ content: Array<string | number>,
267
+ attributes?: TAttributes
268
+ ) => string;
269
+
270
+ type TSelfClosingElementRenderer = (
271
+ attributes?: TAttributes
272
+ ) => string;
273
+ ```
274
+
275
+ ## Contributing
276
+
277
+ This package is part of the Onivoro monorepo. Please refer to the main repository for contribution guidelines.
278
+
279
+ ## License
280
+
281
+ This library is licensed under the MIT License. See the LICENSE file in this package for details.
package/package.json CHANGED
@@ -1,41 +1,27 @@
1
1
  {
2
- "name": "@onivoro/server-html",
3
- "version": "0.1.1",
4
- "repository": {
5
- "url": "git+https://github.com/onivoro/server-html.git"
6
- },
7
- "main": "dist/cjs/index.js",
8
- "module": "dist/esm/index.js",
9
- "types": "dist/types/index.d.ts",
10
- "files": [
11
- "dist/*"
12
- ],
13
- "scripts": {
14
- "onx": "onx",
15
- "build": "onx Build",
16
- "deploy": "onx Publish",
17
- "test": "onx Test",
18
- "update": "onx Update"
19
- },
20
- "exports": {
21
- ".": {
22
- "types": "./dist/types/index.d.ts",
23
- "require": "./dist/cjs/index.js",
24
- "import": "./dist/esm/index.js",
25
- "default": "./dist/esm/lib.js"
26
- }
27
- },
28
- "onx": {
29
- "platform": "server"
30
- },
31
- "devDependencies": {
32
- "@onivoro/cli": "*",
33
- "@types/jest": "*",
34
- "@types/node": "18.19.1",
35
- "typescript": "*"
36
- },
37
- "engines": {
38
- "node": "18.19.1",
39
- "npm": "10.2.4"
40
- }
2
+ "name": "@onivoro/server-html",
3
+ "version": "24.24.0",
4
+ "license": "MIT",
5
+ "type": "commonjs",
6
+ "main": "./src/index.js",
7
+ "types": "./src/index.d.ts",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/onivoro/monorepo.git"
11
+ },
12
+ "dependencies": {
13
+ "tslib": "^2.3.0"
14
+ },
15
+ "peerDependencies": {
16
+ "csstype": "^3.1.3"
17
+ },
18
+ "devDependencies": {
19
+ "csstype": "^3.1.3"
20
+ },
21
+ "files": [
22
+ "**/*.js",
23
+ "**/*.d.ts",
24
+ "**/*.js.map",
25
+ "README.md"
26
+ ]
41
27
  }
@@ -18,3 +18,5 @@ export * from './lib/types/element-renderer.type';
18
18
  export * from './lib/types/self-closing-element-renderer.type';
19
19
  export * from './lib/email-body.function';
20
20
  export * from './lib/table.function';
21
+ export * from './lib/dom';
22
+ //# sourceMappingURL=index.d.ts.map
package/src/index.js ADDED
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./lib/deprecated/a.function"), exports);
5
+ tslib_1.__exportStar(require("./lib/deprecated/html-element-renderer.type"), exports);
6
+ tslib_1.__exportStar(require("./lib/deprecated/html.function"), exports);
7
+ tslib_1.__exportStar(require("./lib/deprecated/login-button.function"), exports);
8
+ tslib_1.__exportStar(require("./lib/deprecated/self-closing-html-element-renderer.type"), exports);
9
+ tslib_1.__exportStar(require("./lib/deprecated/self-closing-tag.function"), exports);
10
+ tslib_1.__exportStar(require("./lib/deprecated/tag.function"), exports);
11
+ tslib_1.__exportStar(require("./lib/deprecated/tags"), exports);
12
+ tslib_1.__exportStar(require("./lib/primitives/element.function"), exports);
13
+ tslib_1.__exportStar(require("./lib/primitives/elements"), exports);
14
+ tslib_1.__exportStar(require("./lib/primitives/format-attributes.function"), exports);
15
+ tslib_1.__exportStar(require("./lib/primitives/inline-style.function"), exports);
16
+ tslib_1.__exportStar(require("./lib/primitives/self-closing-element.function"), exports);
17
+ tslib_1.__exportStar(require("./lib/styles/button-styles.constant"), exports);
18
+ tslib_1.__exportStar(require("./lib/styles/font-styles.constant"), exports);
19
+ tslib_1.__exportStar(require("./lib/types/attributes.type"), exports);
20
+ tslib_1.__exportStar(require("./lib/types/element-renderer.type"), exports);
21
+ tslib_1.__exportStar(require("./lib/types/self-closing-element-renderer.type"), exports);
22
+ tslib_1.__exportStar(require("./lib/email-body.function"), exports);
23
+ tslib_1.__exportStar(require("./lib/table.function"), exports);
24
+ tslib_1.__exportStar(require("./lib/dom"), exports);
25
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../libs/server/html/src/index.ts"],"names":[],"mappings":";;;AAAA,sEAA4C;AAC5C,sFAA4D;AAC5D,yEAA+C;AAC/C,iFAAuD;AACvD,mGAAyE;AACzE,qFAA2D;AAC3D,wEAA8C;AAC9C,gEAAsC;AAEtC,4EAAkD;AAClD,oEAA0C;AAC1C,sFAA4D;AAC5D,iFAAuD;AACvD,yFAA+D;AAE/D,8EAAoD;AACpD,4EAAkD;AAElD,sEAA4C;AAC5C,4EAAkD;AAClD,yFAA+D;AAE/D,oEAA0C;AAC1C,+DAAqC;AACrC,oDAA0B"}
@@ -1 +1,2 @@
1
1
  export declare function a(text: string, href: string, cssClass?: string): string;
2
+ //# sourceMappingURL=a.function.d.ts.map
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.a = void 0;
3
+ exports.a = a;
4
4
  function a(text, href, cssClass) {
5
5
  const classExp = cssClass ? `class="${cssClass}"` : '';
6
6
  return `<a target="_blank" href="${href}" ${classExp}>${text}</a>`;
7
7
  }
8
- exports.a = a;
8
+ //# sourceMappingURL=a.function.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"a.function.js","sourceRoot":"","sources":["../../../../../../../libs/server/html/src/lib/deprecated/a.function.ts"],"names":[],"mappings":";;AAAA,cAGC;AAHD,SAAgB,CAAC,CAAC,IAAY,EAAE,IAAY,EAAE,QAAiB;IAC7D,MAAM,QAAQ,GAAG,QAAQ,CAAC,CAAC,CAAC,UAAU,QAAQ,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IACvD,OAAO,4BAA4B,IAAI,KAAK,QAAQ,IAAI,IAAI,MAAM,CAAC;AACrE,CAAC"}
@@ -1 +1,2 @@
1
1
  export type THtmlElementRenderer = (content: Array<string | number>, cssClass?: string, attributes?: Record<string, any>, styles?: Record<string, string>) => string;
2
+ //# sourceMappingURL=html-element-renderer.type.d.ts.map
@@ -1,2 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=html-element-renderer.type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"html-element-renderer.type.js","sourceRoot":"","sources":["../../../../../../../libs/server/html/src/lib/deprecated/html-element-renderer.type.ts"],"names":[],"mappings":""}
@@ -1 +1,2 @@
1
1
  export declare function html(title: string, subtitle: string, markup: Array<string | number>, logoUrl?: string): string;
2
+ //# sourceMappingURL=html.function.d.ts.map
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.html = void 0;
3
+ exports.html = html;
4
4
  const tags_1 = require("./tags");
5
5
  function html(title, subtitle, markup, logoUrl) {
6
6
  return (0, tags_1._htm)([
@@ -40,4 +40,4 @@ function html(title, subtitle, markup, logoUrl) {
40
40
  ]),
41
41
  ]);
42
42
  }
43
- exports.html = html;
43
+ //# sourceMappingURL=html.function.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"html.function.js","sourceRoot":"","sources":["../../../../../../../libs/server/html/src/lib/deprecated/html.function.ts"],"names":[],"mappings":";;AAEA,oBA4CC;AA9CD,iCAA4I;AAE5I,SAAgB,IAAI,CAClB,KAAa,EACb,QAAgB,EAChB,MAA8B,EAC9B,OAAgB;IAEhB,OAAO,IAAA,WAAG,EAAC;QACT,IAAA,YAAI,EAAC;YACH,IAAA,aAAK,EAAC;gBACJ,QAAQ;gBACR,gBAAgB;gBAChB,6JAA6J;gBAC7J,kBAAkB;gBAClB,sCAAsC;gBACtC,qCAAqC;gBACrC,yBAAyB;gBACzB,GAAG;gBACH,4DAA4D;gBAC5D,2CAA2C;gBAC3C,kDAAkD;gBAClD,sGAAsG;gBACtG,8GAA8G;gBAC9G,wDAAwD;gBACxD,wDAAwD;gBACxD,2HAA2H;gBAC3H,yBAAyB;gBACzB,yCAAyC;gBACzC,gFAAgF;gBAChF,iHAAiH;aAClH,CAAC;SACH,CAAC;QACF,IAAA,YAAI,EAAC;YACH,IAAA,cAAM,EACJ;gBACE,OAAO;oBACL,CAAC,CAAC,sCAAsC,OAAO,MAAM;oBACrD,CAAC,CAAC,SAAS;gBACb,IAAA,UAAE,EAAC,CAAC,KAAK,CAAC,CAAC;gBACX,IAAA,UAAE,EAAC,CAAC,QAAQ,CAAC,CAAC;aACf,CAAC,MAAM,CAAC,OAAO,CAAa,CAC9B;YACD,IAAA,YAAI,EAAC,MAAM,CAAC;SACb,CAAC;KACH,CAAC,CAAC;AACL,CAAC"}
@@ -1 +1,2 @@
1
1
  export declare function loginButton(text: string, href: string, extraStyles?: Record<string, string>): string;
2
+ //# sourceMappingURL=login-button.function.d.ts.map
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.loginButton = void 0;
3
+ exports.loginButton = loginButton;
4
4
  const elements_1 = require("../primitives/elements");
5
5
  const button_styles_constant_1 = require("../styles/button-styles.constant");
6
6
  function loginButton(text, href, extraStyles) {
@@ -12,4 +12,4 @@ function loginButton(text, href, extraStyles) {
12
12
  }
13
13
  });
14
14
  }
15
- exports.loginButton = loginButton;
15
+ //# sourceMappingURL=login-button.function.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"login-button.function.js","sourceRoot":"","sources":["../../../../../../../libs/server/html/src/lib/deprecated/login-button.function.ts"],"names":[],"mappings":";;AAGA,kCAQC;AAXD,qDAAgD;AAChD,6EAAgE;AAEhE,SAAgB,WAAW,CAAC,IAAY,EAAE,IAAY,EAAE,WAAoC;IAC1F,OAAO,IAAA,iBAAM,EAAC,CAAC,IAAI,CAAC,EAAE;QACpB,IAAI;QACJ,KAAK,EAAE;YACL,GAAG,qCAAY;YACf,GAAG,CAAC,WAAW,IAAI,EAAE,CAAC;SACvB;KACF,CAAC,CAAC;AACL,CAAC"}
@@ -1 +1,2 @@
1
1
  export type TSelfClosingHtmlElementRenderer = (cssClass?: string, attributes?: Record<string, any>, styles?: Record<string, string>) => string;
2
+ //# sourceMappingURL=self-closing-html-element-renderer.type.d.ts.map
@@ -1,2 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=self-closing-html-element-renderer.type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"self-closing-html-element-renderer.type.js","sourceRoot":"","sources":["../../../../../../../libs/server/html/src/lib/deprecated/self-closing-html-element-renderer.type.ts"],"names":[],"mappings":""}
@@ -1 +1,2 @@
1
1
  export declare function selfClosingTag(tag: string, cssClass?: string, attributes?: Record<string, any>, styles?: Record<string, string>): string;
2
+ //# sourceMappingURL=self-closing-tag.function.d.ts.map
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.selfClosingTag = void 0;
3
+ exports.selfClosingTag = selfClosingTag;
4
4
  const tag_function_1 = require("./tag.function");
5
5
  function selfClosingTag(tag, cssClass, attributes, styles) {
6
6
  return (0, tag_function_1.tag)(tag, [], cssClass, attributes, styles).replace(`></${tag}>`, '/>');
7
7
  }
8
- exports.selfClosingTag = selfClosingTag;
8
+ //# sourceMappingURL=self-closing-tag.function.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"self-closing-tag.function.js","sourceRoot":"","sources":["../../../../../../../libs/server/html/src/lib/deprecated/self-closing-tag.function.ts"],"names":[],"mappings":";;AAEA,wCAaC;AAfD,iDAAoD;AAEpD,SAAgB,cAAc,CAC1B,GAAW,EACX,QAAiB,EACjB,UAAgC,EAChC,MAA+B;IAE/B,OAAO,IAAA,kBAAW,EACd,GAAG,EACH,EAAE,EACF,QAAQ,EACR,UAAU,EACV,MAAM,CACT,CAAC,OAAO,CAAC,MAAM,GAAG,GAAG,EAAE,IAAI,CAAC,CAAA;AACjC,CAAC"}
@@ -1 +1,2 @@
1
1
  export declare function tag(tag: string, content: Array<string | number>, cssClass?: string, attributes?: Record<string, any>, styles?: Record<string, string>): string;
2
+ //# sourceMappingURL=tag.function.d.ts.map
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.tag = void 0;
3
+ exports.tag = tag;
4
4
  const format_attributes_function_1 = require("../primitives/format-attributes.function");
5
5
  const inline_style_function_1 = require("../primitives/inline-style.function");
6
6
  function tag(tag, content, cssClass, attributes, styles) {
@@ -9,4 +9,4 @@ function tag(tag, content, cssClass, attributes, styles) {
9
9
  const styleExp = styles ? ` ${(0, inline_style_function_1.inlineStyle)(styles)}` : '';
10
10
  return `<${tag}${classExp}${attributesExp}${styleExp}>${content.join?.('')}</${tag}>`;
11
11
  }
12
- exports.tag = tag;
12
+ //# sourceMappingURL=tag.function.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tag.function.js","sourceRoot":"","sources":["../../../../../../../libs/server/html/src/lib/deprecated/tag.function.ts"],"names":[],"mappings":";;AAGA,kBAYC;AAfD,yFAA4E;AAC5E,+EAAkE;AAElE,SAAgB,GAAG,CACf,GAAW,EACX,OAA+B,EAC/B,QAAiB,EACjB,UAAgC,EAChC,MAA+B;IAE/B,MAAM,QAAQ,GAAG,QAAQ,CAAC,CAAC,CAAC,WAAW,QAAQ,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IACxD,MAAM,aAAa,GAAG,UAAU,CAAC,CAAC,CAAC,IAAI,IAAA,6CAAgB,EAAC,UAAU,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAC3E,MAAM,QAAQ,GAAG,MAAM,CAAC,CAAC,CAAC,IAAI,IAAA,mCAAW,EAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAEzD,OAAO,IAAI,GAAG,GAAG,QAAQ,GAAG,aAAa,GAAG,QAAQ,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,KAAK,GAAG,GAAG,CAAC;AAC1F,CAAC"}
@@ -21,4 +21,5 @@ export declare const _td: THtmlElementRenderer;
21
21
  export declare const _th: THtmlElementRenderer;
22
22
  export declare const _thead: THtmlElementRenderer;
23
23
  export declare const _tr: THtmlElementRenderer;
24
- export declare const _style: any;
24
+ export declare const _style: (content: (string | number)[], cssClass?: string | undefined, attributes?: Record<string, any> | undefined, styles?: Record<string, string> | undefined) => string;
25
+ //# sourceMappingURL=tags.d.ts.map
@@ -25,3 +25,4 @@ 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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tags.js","sourceRoot":"","sources":["../../../../../../../libs/server/html/src/lib/deprecated/tags.ts"],"names":[],"mappings":";;;AAEA,2EAA6D;AAC7D,iDAAqC;AAExB,QAAA,KAAK,GAAyB,kBAAG,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AACrD,QAAA,IAAI,GAAyB,kBAAG,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AACnD,QAAA,GAAG,GAAyB,kBAAG,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AACjD,QAAA,GAAG,GAAyB,kBAAG,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AACjD,QAAA,GAAG,GAAyB,kBAAG,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AACjD,QAAA,GAAG,GAAyB,kBAAG,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AACjD,QAAA,GAAG,GAAyB,kBAAG,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AACjD,QAAA,GAAG,GAAyB,kBAAG,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AACjD,QAAA,KAAK,GAAyB,kBAAG,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AACrD,QAAA,OAAO,GAAyB,kBAAG,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;AACzD,QAAA,IAAI,GAAyB,kBAAG,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AACpD,QAAA,IAAI,GAAoC,0CAAc,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AACzE,QAAA,KAAK,GAAyB,kBAAG,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AACrD,QAAA,EAAE,GAAyB,kBAAG,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;AAC/C,QAAA,IAAI,GAAyB,kBAAG,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AACnD,QAAA,IAAI,GAAyB,kBAAG,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AACrD,QAAA,MAAM,GAAyB,kBAAG,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AACvD,QAAA,GAAG,GAAyB,kBAAG,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AACjD,QAAA,GAAG,GAAyB,kBAAG,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AACjD,QAAA,MAAM,GAAyB,kBAAG,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AACvD,QAAA,GAAG,GAAyB,kBAAG,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AAEjD,QAAA,MAAM,GAAG,kBAAG,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC"}