@relax.js/core 1.0.3 → 1.0.5

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 (90) hide show
  1. package/README.md +194 -188
  2. package/dist/DependencyInjection.d.ts +45 -27
  3. package/dist/collections/LinkedList.d.ts +9 -8
  4. package/dist/collections/index.js +1 -1
  5. package/dist/collections/index.js.map +3 -3
  6. package/dist/collections/index.mjs +1 -1
  7. package/dist/collections/index.mjs.map +3 -3
  8. package/dist/di/index.js +1 -1
  9. package/dist/di/index.js.map +3 -3
  10. package/dist/di/index.mjs +1 -1
  11. package/dist/di/index.mjs.map +3 -3
  12. package/dist/elements/index.js +1 -1
  13. package/dist/elements/index.js.map +1 -1
  14. package/dist/errors.d.ts +20 -0
  15. package/dist/forms/FormValidator.d.ts +3 -22
  16. package/dist/forms/ValidationRules.d.ts +4 -6
  17. package/dist/forms/index.js +1 -1
  18. package/dist/forms/index.js.map +4 -4
  19. package/dist/forms/index.mjs +1 -1
  20. package/dist/forms/index.mjs.map +4 -4
  21. package/dist/forms/setFormData.d.ts +39 -1
  22. package/dist/html/TableRenderer.d.ts +1 -0
  23. package/dist/html/index.js +1 -1
  24. package/dist/html/index.js.map +3 -3
  25. package/dist/html/index.mjs +1 -1
  26. package/dist/html/index.mjs.map +3 -3
  27. package/dist/html/template.d.ts +4 -0
  28. package/dist/http/ServerSentEvents.d.ts +1 -1
  29. package/dist/http/SimpleWebSocket.d.ts +1 -1
  30. package/dist/http/http.d.ts +1 -0
  31. package/dist/http/index.js +1 -1
  32. package/dist/http/index.js.map +3 -3
  33. package/dist/http/index.mjs +1 -1
  34. package/dist/http/index.mjs.map +3 -3
  35. package/dist/i18n/icu.d.ts +1 -1
  36. package/dist/i18n/index.js +1 -1
  37. package/dist/i18n/index.js.map +2 -2
  38. package/dist/i18n/index.mjs +1 -1
  39. package/dist/i18n/index.mjs.map +2 -2
  40. package/dist/index.js +3 -3
  41. package/dist/index.js.map +3 -3
  42. package/dist/index.mjs +3 -3
  43. package/dist/index.mjs.map +3 -3
  44. package/dist/routing/NavigateRouteEvent.d.ts +4 -4
  45. package/dist/routing/index.js +3 -3
  46. package/dist/routing/index.js.map +3 -3
  47. package/dist/routing/index.mjs +3 -3
  48. package/dist/routing/index.mjs.map +3 -3
  49. package/dist/routing/navigation.d.ts +1 -1
  50. package/dist/routing/routeTargetRegistry.d.ts +1 -0
  51. package/dist/routing/types.d.ts +2 -1
  52. package/dist/templates/NodeTemplate.d.ts +3 -1
  53. package/dist/utils/index.d.ts +1 -1
  54. package/dist/utils/index.js +1 -1
  55. package/dist/utils/index.js.map +3 -3
  56. package/dist/utils/index.mjs +1 -1
  57. package/dist/utils/index.mjs.map +3 -3
  58. package/docs/Architecture.md +333 -333
  59. package/docs/DependencyInjection.md +277 -237
  60. package/docs/Errors.md +87 -87
  61. package/docs/GettingStarted.md +238 -231
  62. package/docs/Pipes.md +5 -5
  63. package/docs/Translations.md +167 -312
  64. package/docs/WhyRelaxjs.md +336 -336
  65. package/docs/api.json +93193 -0
  66. package/docs/elements/dom.md +102 -102
  67. package/docs/forms/creating-form-components.md +924 -924
  68. package/docs/forms/form-api.md +94 -94
  69. package/docs/forms/forms.md +99 -99
  70. package/docs/forms/patterns.md +311 -311
  71. package/docs/forms/reading-writing.md +465 -365
  72. package/docs/forms/validation.md +351 -351
  73. package/docs/html/TableRenderer.md +291 -291
  74. package/docs/html/html.md +175 -175
  75. package/docs/html/index.md +54 -54
  76. package/docs/html/template.md +422 -422
  77. package/docs/http/HttpClient.md +459 -459
  78. package/docs/http/ServerSentEvents.md +184 -184
  79. package/docs/http/index.md +109 -109
  80. package/docs/i18n/i18n.md +49 -4
  81. package/docs/i18n/intl-standard.md +178 -178
  82. package/docs/routing/RouteLink.md +98 -98
  83. package/docs/routing/Routing.md +332 -332
  84. package/docs/routing/layouts.md +207 -207
  85. package/docs/setup/bootstrapping.md +154 -0
  86. package/docs/setup/build-and-deploy.md +183 -0
  87. package/docs/setup/project-structure.md +170 -0
  88. package/docs/setup/vite.md +175 -0
  89. package/docs/utilities.md +143 -143
  90. package/package.json +4 -2
package/docs/html/html.md CHANGED
@@ -1,175 +1,175 @@
1
- # html Template Engine
2
-
3
- A lightweight HTML template engine with update capabilities. Creates templates that can be re-rendered with new data without recreating DOM nodes.
4
-
5
- ## Usage
6
-
7
- ```typescript
8
- import { html } from 'relaxjs/html';
9
-
10
- // Create a template
11
- const userCard = html`
12
- <div class="user-card">
13
- <h2>{{name}}</h2>
14
- <p>{{email}}</p>
15
- </div>
16
- `;
17
-
18
- // Render with data
19
- const result = userCard({ name: 'John', email: 'john@example.com' });
20
- container.appendChild(result.fragment);
21
-
22
- // Update with new data (no DOM recreation)
23
- result.update({ name: 'Jane', email: 'jane@example.com' });
24
- ```
25
-
26
- ## Features
27
-
28
- ### Mustache Bindings
29
-
30
- Use `{{property}}` syntax to bind context properties to text content or attributes:
31
-
32
- ```typescript
33
- const template = html`
34
- <a href="{{url}}" class="{{linkClass}}">{{linkText}}</a>
35
- `;
36
- ```
37
-
38
- ### Template Literal Substitutions
39
-
40
- Use `${}` for static values or functions:
41
-
42
- ```typescript
43
- const staticClass = 'container';
44
- const template = html`<div class="${staticClass}">{{content}}</div>`;
45
- ```
46
-
47
- ### Event Handlers
48
-
49
- Bind event handlers with context:
50
-
51
- ```typescript
52
- const row = html`
53
- <tr>
54
- <td>{{name}}</td>
55
- <td>
56
- <button onclick=${function() { this.onEdit(this.id); }}>Edit</button>
57
- </td>
58
- </tr>
59
- `;
60
-
61
- const result = row({
62
- id: 42,
63
- name: 'Item',
64
- onEdit(id) { console.log('Edit:', id); }
65
- });
66
- ```
67
-
68
- ### Context Functions
69
-
70
- Call methods from the context object:
71
-
72
- ```typescript
73
- const template = html`<div>{{formatPrice}}</div>`;
74
-
75
- const result = template({
76
- price: 99.99,
77
- formatPrice() {
78
- return `$${this.price.toFixed(2)}`;
79
- }
80
- });
81
- ```
82
-
83
- ### Function Arguments
84
-
85
- Pass arguments to context functions using the pipe syntax:
86
-
87
- ```typescript
88
- const template = html`<div>{{greet|name}}</div>`;
89
-
90
- const result = template({
91
- name: 'John',
92
- greet(name) { return `Hello, ${name}!`; }
93
- });
94
- // Result: <div>Hello, John!</div>
95
- ```
96
-
97
- The value after `|` is resolved from the context and passed to the function. Multiple arguments use comma separation:
98
-
99
- ```typescript
100
- const template = html`<div>{{format|name,title}}</div>`;
101
-
102
- const result = template({
103
- name: 'John',
104
- title: 'Developer',
105
- format(name, title) { return `${name} - ${title}`; }
106
- });
107
- ```
108
-
109
- For value transformations using pipes (like `uppercase`, `currency`), use [compileTemplate](template.md) instead.
110
-
111
- ## API
112
-
113
- ### `html` (tagged template literal)
114
-
115
- ```typescript
116
- function html(
117
- templateStrings: TemplateStringsArray,
118
- ...substitutions: any[]
119
- ): (context: any) => RenderTemplate
120
- ```
121
-
122
- Creates a template function that accepts a context object and returns a `RenderTemplate`.
123
-
124
- ### `RenderTemplate`
125
-
126
- ```typescript
127
- interface RenderTemplate {
128
- fragment: DocumentFragment;
129
- update(context: any): void;
130
- }
131
- ```
132
-
133
- - `fragment`: The rendered DOM fragment. Add to the DOM once.
134
- - `update(context)`: Re-renders with new data without recreating DOM nodes.
135
-
136
- ## Design
137
-
138
- This template engine is designed for **single-use updateable templates**:
139
-
140
- 1. Create the template once
141
- 2. Render and add `fragment` to the DOM
142
- 3. Call `update()` to push changes to the existing nodes
143
-
144
- For reusable templates that create multiple independent instances, use `compileTemplate` from [template](template.md).
145
-
146
- ## Property vs Attribute Binding
147
-
148
- The engine automatically detects when to set element properties vs attributes:
149
-
150
- ```typescript
151
- // Sets input.value property (not attribute)
152
- const input = html`<input value="{{val}}">`;
153
-
154
- // Sets data-id attribute
155
- const div = html`<div data-id="{{id}}"></div>`;
156
- ```
157
-
158
- ## Custom Elements
159
-
160
- Custom elements are automatically upgraded when encountered in templates.
161
-
162
- ## Limitations
163
-
164
- The `html` template is optimized for simple, updateable templates. For advanced features, use [compileTemplate](template.md):
165
-
166
- | Feature | `html` | `compileTemplate` |
167
- |---------|--------|-------------------|
168
- | Mustache bindings | | |
169
- | Event handlers | | |
170
- | In-place updates | | |
171
- | Nested paths (`user.name`) | | |
172
- | Loops (`loop="item in items"`) | | |
173
- | Conditionals (`if`, `unless`) | | |
174
- | Pipe transformations | | |
175
- | Function calls with args | (via `\|`) | |
1
+ # html Template Engine
2
+
3
+ A lightweight HTML template engine with update capabilities. Creates templates that can be re-rendered with new data without recreating DOM nodes.
4
+
5
+ ## Usage
6
+
7
+ ```typescript
8
+ import { html } from '@relax.js/core/html';
9
+
10
+ // Create a template
11
+ const userCard = html`
12
+ <div class="user-card">
13
+ <h2>{{name}}</h2>
14
+ <p>{{email}}</p>
15
+ </div>
16
+ `;
17
+
18
+ // Render with data
19
+ const result = userCard({ name: 'John', email: 'john@example.com' });
20
+ container.appendChild(result.fragment);
21
+
22
+ // Update with new data (no DOM recreation)
23
+ result.update({ name: 'Jane', email: 'jane@example.com' });
24
+ ```
25
+
26
+ ## Features
27
+
28
+ ### Mustache Bindings
29
+
30
+ Use `{{property}}` syntax to bind context properties to text content or attributes:
31
+
32
+ ```typescript
33
+ const template = html`
34
+ <a href="{{url}}" class="{{linkClass}}">{{linkText}}</a>
35
+ `;
36
+ ```
37
+
38
+ ### Template Literal Substitutions
39
+
40
+ Use `${}` for static values or functions:
41
+
42
+ ```typescript
43
+ const staticClass = 'container';
44
+ const template = html`<div class="${staticClass}">{{content}}</div>`;
45
+ ```
46
+
47
+ ### Event Handlers
48
+
49
+ Bind event handlers with context:
50
+
51
+ ```typescript
52
+ const row = html`
53
+ <tr>
54
+ <td>{{name}}</td>
55
+ <td>
56
+ <button onclick=${function() { this.onEdit(this.id); }}>Edit</button>
57
+ </td>
58
+ </tr>
59
+ `;
60
+
61
+ const result = row({
62
+ id: 42,
63
+ name: 'Item',
64
+ onEdit(id) { console.log('Edit:', id); }
65
+ });
66
+ ```
67
+
68
+ ### Context Functions
69
+
70
+ Call methods from the context object:
71
+
72
+ ```typescript
73
+ const template = html`<div>{{formatPrice}}</div>`;
74
+
75
+ const result = template({
76
+ price: 99.99,
77
+ formatPrice() {
78
+ return `$${this.price.toFixed(2)}`;
79
+ }
80
+ });
81
+ ```
82
+
83
+ ### Function Arguments
84
+
85
+ Pass arguments to context functions using the pipe syntax:
86
+
87
+ ```typescript
88
+ const template = html`<div>{{greet|name}}</div>`;
89
+
90
+ const result = template({
91
+ name: 'John',
92
+ greet(name) { return `Hello, ${name}!`; }
93
+ });
94
+ // Result: <div>Hello, John!</div>
95
+ ```
96
+
97
+ The value after `|` is resolved from the context and passed to the function. Multiple arguments use comma separation:
98
+
99
+ ```typescript
100
+ const template = html`<div>{{format|name,title}}</div>`;
101
+
102
+ const result = template({
103
+ name: 'John',
104
+ title: 'Developer',
105
+ format(name, title) { return `${name} - ${title}`; }
106
+ });
107
+ ```
108
+
109
+ For value transformations using pipes (like `uppercase`, `currency`), use [compileTemplate](template.md) instead.
110
+
111
+ ## API
112
+
113
+ ### `html` (tagged template literal)
114
+
115
+ ```typescript
116
+ function html(
117
+ templateStrings: TemplateStringsArray,
118
+ ...substitutions: any[]
119
+ ): (context: any) => RenderTemplate
120
+ ```
121
+
122
+ Creates a template function that accepts a context object and returns a `RenderTemplate`.
123
+
124
+ ### `RenderTemplate`
125
+
126
+ ```typescript
127
+ interface RenderTemplate {
128
+ fragment: DocumentFragment;
129
+ update(context: any): void;
130
+ }
131
+ ```
132
+
133
+ - `fragment`: The rendered DOM fragment. Add to the DOM once.
134
+ - `update(context)`: Re-renders with new data without recreating DOM nodes.
135
+
136
+ ## Design
137
+
138
+ This template engine is designed for **single-use updateable templates**:
139
+
140
+ 1. Create the template once
141
+ 2. Render and add `fragment` to the DOM
142
+ 3. Call `update()` to push changes to the existing nodes
143
+
144
+ For reusable templates that create multiple independent instances, use `compileTemplate` from [template](template.md).
145
+
146
+ ## Property vs Attribute Binding
147
+
148
+ The engine automatically detects when to set element properties vs attributes:
149
+
150
+ ```typescript
151
+ // Sets input.value property (not attribute)
152
+ const input = html`<input value="{{val}}">`;
153
+
154
+ // Sets data-id attribute
155
+ const div = html`<div data-id="{{id}}"></div>`;
156
+ ```
157
+
158
+ ## Custom Elements
159
+
160
+ Custom elements are automatically upgraded when encountered in templates.
161
+
162
+ ## Limitations
163
+
164
+ The `html` template is optimized for simple, updateable templates. For advanced features, use [compileTemplate](template.md):
165
+
166
+ | Feature | `html` | `compileTemplate` |
167
+ |---------|--------|-------------------|
168
+ | Mustache bindings | Yes | Yes |
169
+ | Event handlers | Yes | No |
170
+ | In-place updates | Yes | Yes |
171
+ | Nested paths (`user.name`) | No | Yes |
172
+ | Loops (`loop="item in items"`) | No | Yes |
173
+ | Conditionals (`if`, `unless`) | No | Yes |
174
+ | Pipe transformations | No | Yes |
175
+ | Function calls with args | Yes (via `\|`) | Yes |
@@ -1,54 +1,54 @@
1
- # HTML & Templating
2
-
3
- This module provides templating utilities for rendering dynamic HTML content.
4
-
5
- ## Available Features
6
-
7
- | Feature | Description | Use Case |
8
- |---------|-------------|----------|
9
- | [html](html.md) | Tagged template literal with update support | Single-use templates with in-place updates |
10
- | [compileTemplate](template.md) | Full-featured template compiler | Reusable templates with loops, conditionals, pipes |
11
- | [Pipes](../Pipes.md) | Value transformation functions | Format dates, currencies, text in templates |
12
- | [TableRenderer](TableRenderer.md) | Table row renderer for Web Components | Data tables with row updates and button handlers |
13
-
14
- ## Quick Comparison
15
-
16
- ### html
17
-
18
- Best for: Single templates that need efficient updates
19
-
20
- ```typescript
21
- const card = html`<div>{{name}}</div>`;
22
- const result = card({ name: 'John' });
23
- container.appendChild(result.fragment);
24
- result.update({ name: 'Jane' }); // Updates in place
25
- ```
26
-
27
- ### compileTemplate
28
-
29
- Best for: Complex templates with loops and conditionals
30
-
31
- ```typescript
32
- const { content, render } = compileTemplate(`
33
- <ul>
34
- <li loop="item in items" if="item.visible">{{item.name}}</li>
35
- </ul>
36
- `);
37
- render({ items: [...] });
38
- ```
39
-
40
- ### TableRenderer
41
-
42
- Best for: Data tables in Web Components
43
-
44
- ```typescript
45
- const renderer = new TableRenderer(table, template, 'id', this);
46
- renderer.render(data);
47
- renderer.updateRow(id, newData);
48
- ```
49
-
50
- ## Choosing the Right Tool
51
-
52
- - **Need in-place updates?** → Use `html`
53
- - **Need loops/conditionals?** → Use `compileTemplate`
54
- - **Building a data table?** → Use `TableRenderer`
1
+ # HTML & Templating
2
+
3
+ This module provides templating utilities for rendering dynamic HTML content.
4
+
5
+ ## Available Features
6
+
7
+ | Feature | Description | Use Case |
8
+ |---------|-------------|----------|
9
+ | [html](html.md) | Tagged template literal with update support | Single-use templates with in-place updates |
10
+ | [compileTemplate](template.md) | Full-featured template compiler | Reusable templates with loops, conditionals, pipes |
11
+ | [Pipes](../Pipes.md) | Value transformation functions | Format dates, currencies, text in templates |
12
+ | [TableRenderer](TableRenderer.md) | Table row renderer for Web Components | Data tables with row updates and button handlers |
13
+
14
+ ## Quick Comparison
15
+
16
+ ### html
17
+
18
+ Best for: Single templates that need efficient updates
19
+
20
+ ```typescript
21
+ const card = html`<div>{{name}}</div>`;
22
+ const result = card({ name: 'John' });
23
+ container.appendChild(result.fragment);
24
+ result.update({ name: 'Jane' }); // Updates in place
25
+ ```
26
+
27
+ ### compileTemplate
28
+
29
+ Best for: Complex templates with loops and conditionals
30
+
31
+ ```typescript
32
+ const { content, render } = compileTemplate(`
33
+ <ul>
34
+ <li loop="item in items" if="item.visible">{{item.name}}</li>
35
+ </ul>
36
+ `);
37
+ render({ items: [...] });
38
+ ```
39
+
40
+ ### TableRenderer
41
+
42
+ Best for: Data tables in Web Components
43
+
44
+ ```typescript
45
+ const renderer = new TableRenderer(table, template, 'id', this);
46
+ renderer.render(data);
47
+ renderer.updateRow(id, newData);
48
+ ```
49
+
50
+ ## Choosing the Right Tool
51
+
52
+ - **Need in-place updates?** → Use `html`
53
+ - **Need loops/conditionals?** → Use `compileTemplate`
54
+ - **Building a data table?** → Use `TableRenderer`