@relax.js/core 1.0.3 → 1.0.4

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 (234) hide show
  1. package/README.md +194 -188
  2. package/dist/DependencyInjection.d.ts +42 -24
  3. package/dist/di/index.js +1 -1
  4. package/dist/di/index.js.map +3 -3
  5. package/dist/di/index.mjs +1 -1
  6. package/dist/di/index.mjs.map +3 -3
  7. package/dist/errors.d.ts +20 -0
  8. package/dist/forms/FormValidator.d.ts +1 -20
  9. package/dist/forms/ValidationRules.d.ts +2 -0
  10. package/dist/forms/index.js +1 -1
  11. package/dist/forms/index.js.map +4 -4
  12. package/dist/forms/index.mjs +1 -1
  13. package/dist/forms/index.mjs.map +4 -4
  14. package/dist/html/TableRenderer.d.ts +1 -0
  15. package/dist/html/index.js.map +2 -2
  16. package/dist/html/index.mjs.map +2 -2
  17. package/dist/html/template.d.ts +4 -0
  18. package/dist/http/http.d.ts +1 -0
  19. package/dist/http/index.js.map +2 -2
  20. package/dist/http/index.mjs.map +2 -2
  21. package/dist/index.js +3 -3
  22. package/dist/index.js.map +3 -3
  23. package/dist/index.mjs +3 -3
  24. package/dist/index.mjs.map +3 -3
  25. package/dist/routing/index.js +3 -3
  26. package/dist/routing/index.js.map +3 -3
  27. package/dist/routing/index.mjs +3 -3
  28. package/dist/routing/index.mjs.map +3 -3
  29. package/dist/routing/routeTargetRegistry.d.ts +1 -0
  30. package/dist/routing/types.d.ts +2 -1
  31. package/dist/templates/NodeTemplate.d.ts +2 -0
  32. package/dist/utils/index.js +1 -1
  33. package/dist/utils/index.js.map +2 -2
  34. package/dist/utils/index.mjs +1 -1
  35. package/dist/utils/index.mjs.map +2 -2
  36. package/docs/Architecture.md +333 -333
  37. package/docs/DependencyInjection.md +277 -237
  38. package/docs/Errors.md +87 -87
  39. package/docs/GettingStarted.md +231 -231
  40. package/docs/Pipes.md +5 -5
  41. package/docs/Translations.md +167 -312
  42. package/docs/WhyRelaxjs.md +336 -336
  43. package/docs/api/.nojekyll +1 -0
  44. package/docs/api/assets/hierarchy.js +1 -0
  45. package/docs/api/assets/highlight.css +120 -0
  46. package/docs/api/assets/icons.js +18 -0
  47. package/docs/api/assets/icons.svg +1 -0
  48. package/docs/api/assets/main.js +60 -0
  49. package/docs/api/assets/navigation.js +1 -0
  50. package/docs/api/assets/search.js +1 -0
  51. package/docs/api/assets/style.css +1633 -0
  52. package/docs/api/classes/http.WebSocketClient.html +26 -0
  53. package/docs/api/classes/i18n.LocaleChangeEvent.html +66 -0
  54. package/docs/api/classes/index.Blueprint.html +3 -0
  55. package/docs/api/classes/index.BoundNode.html +3 -0
  56. package/docs/api/classes/index.DigitsValidation.html +10 -0
  57. package/docs/api/classes/index.FormValidator.html +32 -0
  58. package/docs/api/classes/index.HttpError.html +13 -0
  59. package/docs/api/classes/index.LinkedList.html +26 -0
  60. package/docs/api/classes/index.NavigateRouteEvent.html +76 -0
  61. package/docs/api/classes/index.Node.html +15 -0
  62. package/docs/api/classes/index.PageSelectedEvent.html +61 -0
  63. package/docs/api/classes/index.Pager.html +4 -0
  64. package/docs/api/classes/index.RangeValidation.html +15 -0
  65. package/docs/api/classes/index.RelaxError.html +17 -0
  66. package/docs/api/classes/index.RequiredValidation.html +10 -0
  67. package/docs/api/classes/index.RouteError.html +11 -0
  68. package/docs/api/classes/index.RouteGuardError.html +12 -0
  69. package/docs/api/classes/index.RouteLink.html +779 -0
  70. package/docs/api/classes/index.RouteTarget.html +788 -0
  71. package/docs/api/classes/index.SSEClient.html +13 -0
  72. package/docs/api/classes/index.SSEDataEvent.html +63 -0
  73. package/docs/api/classes/index.ServiceCollection.html +28 -0
  74. package/docs/api/classes/index.ServiceContainer.html +24 -0
  75. package/docs/api/classes/index.SortChangeEvent.html +61 -0
  76. package/docs/api/classes/index.TableRenderer.html +5 -0
  77. package/docs/api/classes/index.TableSorter.html +4 -0
  78. package/docs/api/enums/index.GuardResult.html +9 -0
  79. package/docs/api/functions/elements.formError.html +6 -0
  80. package/docs/api/functions/elements.selectOne.html +6 -0
  81. package/docs/api/functions/i18n.getCurrentLocale.html +3 -0
  82. package/docs/api/functions/i18n.loadNamespace.html +7 -0
  83. package/docs/api/functions/i18n.loadNamespaces.html +6 -0
  84. package/docs/api/functions/i18n.onMissingTranslation.html +7 -0
  85. package/docs/api/functions/i18n.setLocale.html +7 -0
  86. package/docs/api/functions/i18n.setMessageFormatter.html +7 -0
  87. package/docs/api/functions/i18n.t.html +9 -0
  88. package/docs/api/functions/index.BooleanConverter.html +6 -0
  89. package/docs/api/functions/index.ContainerService.html +13 -0
  90. package/docs/api/functions/index.DateConverter.html +11 -0
  91. package/docs/api/functions/index.Inject.html +16 -0
  92. package/docs/api/functions/index.NumberConverter.html +5 -0
  93. package/docs/api/functions/index.RegisterValidator.html +7 -0
  94. package/docs/api/functions/index.applyPipes.html +17 -0
  95. package/docs/api/functions/index.asyncHandler.html +11 -0
  96. package/docs/api/functions/index.capitalizePipe.html +4 -0
  97. package/docs/api/functions/index.clearPendingNavigations.html +1 -0
  98. package/docs/api/functions/index.compileTemplate.html +26 -0
  99. package/docs/api/functions/index.configure.html +5 -0
  100. package/docs/api/functions/index.createBluePrint.html +1 -0
  101. package/docs/api/functions/index.createConverterFromDataType.html +4 -0
  102. package/docs/api/functions/index.createConverterFromInputType.html +5 -0
  103. package/docs/api/functions/index.createPipeRegistry.html +12 -0
  104. package/docs/api/functions/index.currencyPipe.html +9 -0
  105. package/docs/api/functions/index.datePipe.html +9 -0
  106. package/docs/api/functions/index.daysAgoPipe.html +8 -0
  107. package/docs/api/functions/index.defaultPipe.html +5 -0
  108. package/docs/api/functions/index.defineRoutes.html +8 -0
  109. package/docs/api/functions/index.del.html +8 -0
  110. package/docs/api/functions/index.findRouteByName.html +5 -0
  111. package/docs/api/functions/index.findRouteByUrl.html +4 -0
  112. package/docs/api/functions/index.firstPipe.html +4 -0
  113. package/docs/api/functions/index.generateSequentialId.html +21 -0
  114. package/docs/api/functions/index.get.html +9 -0
  115. package/docs/api/functions/index.getDataConverter.html +11 -0
  116. package/docs/api/functions/index.getParentComponent.html +18 -0
  117. package/docs/api/functions/index.getValidator.html +4 -0
  118. package/docs/api/functions/index.html.html +19 -0
  119. package/docs/api/functions/index.joinPipe.html +5 -0
  120. package/docs/api/functions/index.keysPipe.html +4 -0
  121. package/docs/api/functions/index.lastPipe.html +4 -0
  122. package/docs/api/functions/index.lowercasePipe.html +4 -0
  123. package/docs/api/functions/index.mapFormToClass.html +17 -0
  124. package/docs/api/functions/index.matchRoute.html +5 -0
  125. package/docs/api/functions/index.navigate.html +8 -0
  126. package/docs/api/functions/index.onError.html +8 -0
  127. package/docs/api/functions/index.piecesPipe.html +8 -0
  128. package/docs/api/functions/index.post.html +9 -0
  129. package/docs/api/functions/index.printRoutes.html +2 -0
  130. package/docs/api/functions/index.put.html +9 -0
  131. package/docs/api/functions/index.readData.html +17 -0
  132. package/docs/api/functions/index.registerRouteTarget.html +9 -0
  133. package/docs/api/functions/index.reportError.html +10 -0
  134. package/docs/api/functions/index.request.html +8 -0
  135. package/docs/api/functions/index.resolveValue.html +18 -0
  136. package/docs/api/functions/index.setFetch.html +6 -0
  137. package/docs/api/functions/index.setFormData.html +17 -0
  138. package/docs/api/functions/index.shortenPipe.html +5 -0
  139. package/docs/api/functions/index.startRouting.html +6 -0
  140. package/docs/api/functions/index.ternaryPipe.html +6 -0
  141. package/docs/api/functions/index.trimPipe.html +4 -0
  142. package/docs/api/functions/index.unregisterRouteTarget.html +3 -0
  143. package/docs/api/functions/index.uppercasePipe.html +4 -0
  144. package/docs/api/hierarchy.html +1 -0
  145. package/docs/api/index.html +323 -0
  146. package/docs/api/interfaces/http.SimpleDataEvent.html +3 -0
  147. package/docs/api/interfaces/http.WebSocketAbstraction.html +9 -0
  148. package/docs/api/interfaces/http.WebSocketCodec.html +4 -0
  149. package/docs/api/interfaces/http.WebSocketOptions.html +20 -0
  150. package/docs/api/interfaces/index.CompiledTemplate.html +10 -0
  151. package/docs/api/interfaces/index.DataLoader.html +19 -0
  152. package/docs/api/interfaces/index.EngineConfig.html +11 -0
  153. package/docs/api/interfaces/index.ErrorContext.html +4 -0
  154. package/docs/api/interfaces/index.FormReaderOptions.html +8 -0
  155. package/docs/api/interfaces/index.HttpOptions.html +16 -0
  156. package/docs/api/interfaces/index.HttpResponse.html +17 -0
  157. package/docs/api/interfaces/index.LoadRoute.html +7 -0
  158. package/docs/api/interfaces/index.NavigateOptions.html +7 -0
  159. package/docs/api/interfaces/index.PipeRegistry.html +12 -0
  160. package/docs/api/interfaces/index.RegistrationOptions.html +22 -0
  161. package/docs/api/interfaces/index.RenderTemplate.html +7 -0
  162. package/docs/api/interfaces/index.RequestOptions.html +11 -0
  163. package/docs/api/interfaces/index.Routable.html +10 -0
  164. package/docs/api/interfaces/index.Route.html +13 -0
  165. package/docs/api/interfaces/index.RouteGuard.html +2 -0
  166. package/docs/api/interfaces/index.RouteValue.html +6 -0
  167. package/docs/api/interfaces/index.SSEOptions.html +24 -0
  168. package/docs/api/interfaces/index.ValidationContext.html +8 -0
  169. package/docs/api/interfaces/index.ValidatorOptions.html +14 -0
  170. package/docs/api/media/Architecture.md +333 -0
  171. package/docs/api/media/DependencyInjection.md +277 -0
  172. package/docs/api/media/GettingStarted.md +231 -0
  173. package/docs/api/media/HttpClient.md +459 -0
  174. package/docs/api/media/Pipes.md +211 -0
  175. package/docs/api/media/Routing.md +332 -0
  176. package/docs/api/media/WhyRelaxjs.md +336 -0
  177. package/docs/api/media/forms.md +99 -0
  178. package/docs/api/media/html.md +175 -0
  179. package/docs/api/media/i18n.md +354 -0
  180. package/docs/api/media/utilities.md +143 -0
  181. package/docs/api/media/validation.md +351 -0
  182. package/docs/api/modules/collections_Index.html +1 -0
  183. package/docs/api/modules/di.html +1 -0
  184. package/docs/api/modules/elements.html +1 -0
  185. package/docs/api/modules/forms.html +1 -0
  186. package/docs/api/modules/html.html +1 -0
  187. package/docs/api/modules/http.html +1 -0
  188. package/docs/api/modules/i18n.html +1 -0
  189. package/docs/api/modules/index.html +1 -0
  190. package/docs/api/modules/routing.html +1 -0
  191. package/docs/api/modules/utils.html +1 -0
  192. package/docs/api/modules.html +1 -0
  193. package/docs/api/types/http.WebSocketFactory.html +2 -0
  194. package/docs/api/types/i18n.MessageFormatter.html +3 -0
  195. package/docs/api/types/i18n.MissingTranslationHandler.html +1 -0
  196. package/docs/api/types/index.Constructor.html +7 -0
  197. package/docs/api/types/index.ConverterFunc.html +2 -0
  198. package/docs/api/types/index.DataType.html +2 -0
  199. package/docs/api/types/index.InputType.html +2 -0
  200. package/docs/api/types/index.PipeFunction.html +6 -0
  201. package/docs/api/types/index.RouteData.html +1 -0
  202. package/docs/api/types/index.RouteMatchResult.html +9 -0
  203. package/docs/api/types/index.RouteParamType.html +1 -0
  204. package/docs/api/types/index.RouteSegmentType.html +2 -0
  205. package/docs/api/types/index.SSEEventFactory.html +5 -0
  206. package/docs/api/types/index.ServiceScope.html +10 -0
  207. package/docs/api/types/index.SortColumn.html +3 -0
  208. package/docs/api/variables/i18n.formatICU.html +3 -0
  209. package/docs/api/variables/index.container.html +6 -0
  210. package/docs/api/variables/index.defaultPipes.html +6 -0
  211. package/docs/api/variables/index.internalRoutes.html +1 -0
  212. package/docs/api/variables/index.serviceCollection.html +6 -0
  213. package/docs/api.json +93171 -0
  214. package/docs/elements/dom.md +102 -102
  215. package/docs/forms/creating-form-components.md +924 -924
  216. package/docs/forms/form-api.md +94 -94
  217. package/docs/forms/forms.md +99 -99
  218. package/docs/forms/patterns.md +311 -311
  219. package/docs/forms/reading-writing.md +365 -365
  220. package/docs/forms/validation.md +351 -351
  221. package/docs/html/TableRenderer.md +291 -291
  222. package/docs/html/html.md +175 -175
  223. package/docs/html/index.md +54 -54
  224. package/docs/html/template.md +422 -422
  225. package/docs/http/HttpClient.md +459 -459
  226. package/docs/http/ServerSentEvents.md +184 -184
  227. package/docs/http/index.md +109 -109
  228. package/docs/i18n/i18n.md +49 -4
  229. package/docs/i18n/intl-standard.md +178 -178
  230. package/docs/routing/RouteLink.md +98 -98
  231. package/docs/routing/Routing.md +332 -332
  232. package/docs/routing/layouts.md +207 -207
  233. package/docs/utilities.md +143 -143
  234. package/package.json +4 -3
@@ -1,178 +1,178 @@
1
- # The Modern Intl Standard
2
-
3
- The browser's built-in [`Intl`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl) object provides locale-aware formatting for numbers, dates, strings, and more. It is supported in all modern browsers and Node.js, so no polyfills or libraries are needed.
4
-
5
- Relaxjs uses `Intl` internally (e.g. `Intl.PluralRules` for ICU pluralization) and exposes the current locale via `getCurrentLocale()` so pipes and components can pass it directly to `Intl` APIs.
6
-
7
- ## Intl.PluralRules
8
-
9
- Determines the plural category (`zero`, `one`, `two`, `few`, `many`, `other`) for a number in a given locale. Different languages have different rules. English has two categories (`one` / `other`), Arabic has six.
10
-
11
- ```typescript
12
- const en = new Intl.PluralRules('en');
13
- en.select(1); // 'one'
14
- en.select(0); // 'other'
15
- en.select(5); // 'other'
16
-
17
- const sv = new Intl.PluralRules('sv');
18
- sv.select(1); // 'one' → en
19
- sv.select(0); // 'other' → flera
20
- sv.select(5); // 'other' → flera
21
- ```
22
-
23
- The returned strings (`one`, `other`, `few`, etc.) are category identifiers, not localized text. The locale determines *which numbers* map to *which categories*. English and Swedish both use `one`/`other`, while languages like Arabic use all six categories (`zero`, `one`, `two`, `few`, `many`, `other`).
24
-
25
- This is the engine behind ICU `{count, plural, ...}` messages. The Relaxjs ICU formatter delegates to `Intl.PluralRules` for category selection.
26
-
27
- [MDN: Intl.PluralRules](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/PluralRules)
28
-
29
- ## Intl.NumberFormat
30
-
31
- Formats numbers according to locale conventions: thousands separators, decimal marks, currency, percentages, units, and compact notation.
32
-
33
- ```typescript
34
- new Intl.NumberFormat('en').format(1234.5); // '1,234.5'
35
- new Intl.NumberFormat('sv').format(1234.5); // '1 234,5'
36
-
37
- new Intl.NumberFormat('en', {
38
- style: 'currency', currency: 'USD'
39
- }).format(42); // '$42.00'
40
-
41
- new Intl.NumberFormat('sv', {
42
- style: 'currency', currency: 'SEK'
43
- }).format(42); // '42,00 kr'
44
-
45
- new Intl.NumberFormat('en', {
46
- notation: 'compact'
47
- }).format(1_500_000); // '1.5M'
48
- ```
49
-
50
- The Relaxjs `currency` pipe uses `Intl.NumberFormat` with `getCurrentLocale()`.
51
-
52
- [MDN: Intl.NumberFormat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat)
53
-
54
- ## Intl.DateTimeFormat
55
-
56
- Formats dates and times according to locale conventions and configurable options.
57
-
58
- ```typescript
59
- const date = new Date('2025-06-15T14:30:00');
60
-
61
- new Intl.DateTimeFormat('en').format(date); // '6/15/2025'
62
- new Intl.DateTimeFormat('sv').format(date); // '2025-06-15'
63
-
64
- new Intl.DateTimeFormat('en', {
65
- dateStyle: 'long', timeStyle: 'short'
66
- }).format(date); // 'June 15, 2025 at 2:30 PM'
67
-
68
- new Intl.DateTimeFormat('sv', {
69
- weekday: 'long', month: 'long', day: 'numeric'
70
- }).format(date); // 'söndag 15 juni'
71
- ```
72
-
73
- The Relaxjs `date` pipe uses `Intl.DateTimeFormat` with `getCurrentLocale()`.
74
-
75
- [MDN: Intl.DateTimeFormat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat)
76
-
77
- ## Intl.RelativeTimeFormat
78
-
79
- Formats relative time descriptions ("3 days ago", "in 2 hours") with locale-aware phrasing.
80
-
81
- ```typescript
82
- const rtf = new Intl.RelativeTimeFormat('en', { numeric: 'auto' });
83
- rtf.format(-1, 'day'); // 'yesterday'
84
- rtf.format(0, 'day'); // 'today'
85
- rtf.format(3, 'day'); // 'in 3 days'
86
-
87
- const svRtf = new Intl.RelativeTimeFormat('sv', { numeric: 'auto' });
88
- svRtf.format(-1, 'day'); // 'igår'
89
- svRtf.format(-3, 'day'); // 'för 3 dagar sedan'
90
- ```
91
-
92
- [MDN: Intl.RelativeTimeFormat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat)
93
-
94
- ## Intl.Collator
95
-
96
- Provides locale-sensitive string comparison for sorting. Handles accents, case, and locale-specific sort orders (e.g. Swedish å/ä/ö sort after z).
97
-
98
- ```typescript
99
- const col = new Intl.Collator('sv');
100
- ['ö', 'a', 'å', 'ä'].sort(col.compare); // ['a', 'å', 'ä', 'ö']
101
-
102
- const enCol = new Intl.Collator('en', { sensitivity: 'base' });
103
- enCol.compare('café', 'cafe'); // 0 (equal, ignoring accent)
104
- ```
105
-
106
- [MDN: Intl.Collator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Collator)
107
-
108
- ## Intl.Segmenter
109
-
110
- Splits text into meaningful segments (graphemes, words, or sentences) while respecting locale rules. Essential for languages without spaces between words (Chinese, Japanese, Thai).
111
-
112
- ```typescript
113
- const seg = new Intl.Segmenter('en', { granularity: 'word' });
114
- const words = [...seg.segment('Hello world!')].filter(s => s.isWordLike);
115
- // [{segment: 'Hello'}, {segment: 'world'}]
116
- ```
117
-
118
- [MDN: Intl.Segmenter](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter)
119
-
120
- ## Intl.ListFormat
121
-
122
- Formats lists with locale-appropriate conjunctions and punctuation.
123
-
124
- ```typescript
125
- new Intl.ListFormat('en', { type: 'conjunction' })
126
- .format(['Alice', 'Bob', 'Charlie']); // 'Alice, Bob, and Charlie'
127
-
128
- new Intl.ListFormat('sv', { type: 'conjunction' })
129
- .format(['Alice', 'Bob', 'Charlie']); // 'Alice, Bob och Charlie'
130
- ```
131
-
132
- [MDN: Intl.ListFormat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat)
133
-
134
- ## Intl.DisplayNames
135
-
136
- Translates language, region, currency, and script codes into human-readable names.
137
-
138
- ```typescript
139
- new Intl.DisplayNames('en', { type: 'language' }).of('sv'); // 'Swedish'
140
- new Intl.DisplayNames('sv', { type: 'language' }).of('en'); // 'engelska'
141
- new Intl.DisplayNames('en', { type: 'currency' }).of('SEK'); // 'Swedish Krona'
142
- ```
143
-
144
- [MDN: Intl.DisplayNames](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames)
145
-
146
- ## ICU Message Format
147
-
148
- ICU (International Components for Unicode) defines a message syntax used across platforms. The three core patterns:
149
-
150
- ### Simple Interpolation
151
-
152
- ```
153
- Hello, {name}!
154
- ```
155
-
156
- ### Plural
157
-
158
- Selects a branch based on `Intl.PluralRules`. The `#` token inserts the numeric value. Exact matches (`=0`, `=1`) take priority over category matches.
159
-
160
- ```
161
- {count, plural, =0 {No items} one {# item} other {# items}}
162
- ```
163
-
164
- ### Select
165
-
166
- Selects a branch based on an exact string match. Always include an `other` fallback.
167
-
168
- ```
169
- {gender, select, male {He} female {She} other {They}} liked your post.
170
- ```
171
-
172
- [ICU User Guide: Formatting Messages](https://unicode-org.github.io/icu/userguide/format_parse/messages/)
173
-
174
- ## Further Reading
175
-
176
- - [MDN: Intl](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl), full API reference
177
- - [ICU Message Format](https://unicode-org.github.io/icu/userguide/format_parse/messages/), the message syntax standard
178
- - [Can I Use: Intl](https://caniuse.com/?search=Intl), browser support tables
1
+ # The Modern Intl Standard
2
+
3
+ The browser's built-in [`Intl`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl) object provides locale-aware formatting for numbers, dates, strings, and more. It is supported in all modern browsers and Node.js, so no polyfills or libraries are needed.
4
+
5
+ Relaxjs uses `Intl` internally (e.g. `Intl.PluralRules` for ICU pluralization) and exposes the current locale via `getCurrentLocale()` so pipes and components can pass it directly to `Intl` APIs.
6
+
7
+ ## Intl.PluralRules
8
+
9
+ Determines the plural category (`zero`, `one`, `two`, `few`, `many`, `other`) for a number in a given locale. Different languages have different rules. English has two categories (`one` / `other`), Arabic has six.
10
+
11
+ ```typescript
12
+ const en = new Intl.PluralRules('en');
13
+ en.select(1); // 'one'
14
+ en.select(0); // 'other'
15
+ en.select(5); // 'other'
16
+
17
+ const sv = new Intl.PluralRules('sv');
18
+ sv.select(1); // 'one' → en
19
+ sv.select(0); // 'other' → flera
20
+ sv.select(5); // 'other' → flera
21
+ ```
22
+
23
+ The returned strings (`one`, `other`, `few`, etc.) are category identifiers, not localized text. The locale determines *which numbers* map to *which categories*. English and Swedish both use `one`/`other`, while languages like Arabic use all six categories (`zero`, `one`, `two`, `few`, `many`, `other`).
24
+
25
+ This is the engine behind ICU `{count, plural, ...}` messages. The Relaxjs ICU formatter delegates to `Intl.PluralRules` for category selection.
26
+
27
+ [MDN: Intl.PluralRules](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/PluralRules)
28
+
29
+ ## Intl.NumberFormat
30
+
31
+ Formats numbers according to locale conventions: thousands separators, decimal marks, currency, percentages, units, and compact notation.
32
+
33
+ ```typescript
34
+ new Intl.NumberFormat('en').format(1234.5); // '1,234.5'
35
+ new Intl.NumberFormat('sv').format(1234.5); // '1 234,5'
36
+
37
+ new Intl.NumberFormat('en', {
38
+ style: 'currency', currency: 'USD'
39
+ }).format(42); // '$42.00'
40
+
41
+ new Intl.NumberFormat('sv', {
42
+ style: 'currency', currency: 'SEK'
43
+ }).format(42); // '42,00 kr'
44
+
45
+ new Intl.NumberFormat('en', {
46
+ notation: 'compact'
47
+ }).format(1_500_000); // '1.5M'
48
+ ```
49
+
50
+ The Relaxjs `currency` pipe uses `Intl.NumberFormat` with `getCurrentLocale()`.
51
+
52
+ [MDN: Intl.NumberFormat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat)
53
+
54
+ ## Intl.DateTimeFormat
55
+
56
+ Formats dates and times according to locale conventions and configurable options.
57
+
58
+ ```typescript
59
+ const date = new Date('2025-06-15T14:30:00');
60
+
61
+ new Intl.DateTimeFormat('en').format(date); // '6/15/2025'
62
+ new Intl.DateTimeFormat('sv').format(date); // '2025-06-15'
63
+
64
+ new Intl.DateTimeFormat('en', {
65
+ dateStyle: 'long', timeStyle: 'short'
66
+ }).format(date); // 'June 15, 2025 at 2:30 PM'
67
+
68
+ new Intl.DateTimeFormat('sv', {
69
+ weekday: 'long', month: 'long', day: 'numeric'
70
+ }).format(date); // 'söndag 15 juni'
71
+ ```
72
+
73
+ The Relaxjs `date` pipe uses `Intl.DateTimeFormat` with `getCurrentLocale()`.
74
+
75
+ [MDN: Intl.DateTimeFormat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat)
76
+
77
+ ## Intl.RelativeTimeFormat
78
+
79
+ Formats relative time descriptions ("3 days ago", "in 2 hours") with locale-aware phrasing.
80
+
81
+ ```typescript
82
+ const rtf = new Intl.RelativeTimeFormat('en', { numeric: 'auto' });
83
+ rtf.format(-1, 'day'); // 'yesterday'
84
+ rtf.format(0, 'day'); // 'today'
85
+ rtf.format(3, 'day'); // 'in 3 days'
86
+
87
+ const svRtf = new Intl.RelativeTimeFormat('sv', { numeric: 'auto' });
88
+ svRtf.format(-1, 'day'); // 'igår'
89
+ svRtf.format(-3, 'day'); // 'för 3 dagar sedan'
90
+ ```
91
+
92
+ [MDN: Intl.RelativeTimeFormat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat)
93
+
94
+ ## Intl.Collator
95
+
96
+ Provides locale-sensitive string comparison for sorting. Handles accents, case, and locale-specific sort orders (e.g. Swedish å/ä/ö sort after z).
97
+
98
+ ```typescript
99
+ const col = new Intl.Collator('sv');
100
+ ['ö', 'a', 'å', 'ä'].sort(col.compare); // ['a', 'å', 'ä', 'ö']
101
+
102
+ const enCol = new Intl.Collator('en', { sensitivity: 'base' });
103
+ enCol.compare('café', 'cafe'); // 0 (equal, ignoring accent)
104
+ ```
105
+
106
+ [MDN: Intl.Collator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Collator)
107
+
108
+ ## Intl.Segmenter
109
+
110
+ Splits text into meaningful segments (graphemes, words, or sentences) while respecting locale rules. Essential for languages without spaces between words (Chinese, Japanese, Thai).
111
+
112
+ ```typescript
113
+ const seg = new Intl.Segmenter('en', { granularity: 'word' });
114
+ const words = [...seg.segment('Hello world!')].filter(s => s.isWordLike);
115
+ // [{segment: 'Hello'}, {segment: 'world'}]
116
+ ```
117
+
118
+ [MDN: Intl.Segmenter](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter)
119
+
120
+ ## Intl.ListFormat
121
+
122
+ Formats lists with locale-appropriate conjunctions and punctuation.
123
+
124
+ ```typescript
125
+ new Intl.ListFormat('en', { type: 'conjunction' })
126
+ .format(['Alice', 'Bob', 'Charlie']); // 'Alice, Bob, and Charlie'
127
+
128
+ new Intl.ListFormat('sv', { type: 'conjunction' })
129
+ .format(['Alice', 'Bob', 'Charlie']); // 'Alice, Bob och Charlie'
130
+ ```
131
+
132
+ [MDN: Intl.ListFormat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat)
133
+
134
+ ## Intl.DisplayNames
135
+
136
+ Translates language, region, currency, and script codes into human-readable names.
137
+
138
+ ```typescript
139
+ new Intl.DisplayNames('en', { type: 'language' }).of('sv'); // 'Swedish'
140
+ new Intl.DisplayNames('sv', { type: 'language' }).of('en'); // 'engelska'
141
+ new Intl.DisplayNames('en', { type: 'currency' }).of('SEK'); // 'Swedish Krona'
142
+ ```
143
+
144
+ [MDN: Intl.DisplayNames](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames)
145
+
146
+ ## ICU Message Format
147
+
148
+ ICU (International Components for Unicode) defines a message syntax used across platforms. The three core patterns:
149
+
150
+ ### Simple Interpolation
151
+
152
+ ```
153
+ Hello, {name}!
154
+ ```
155
+
156
+ ### Plural
157
+
158
+ Selects a branch based on `Intl.PluralRules`. The `#` token inserts the numeric value. Exact matches (`=0`, `=1`) take priority over category matches.
159
+
160
+ ```
161
+ {count, plural, =0 {No items} one {# item} other {# items}}
162
+ ```
163
+
164
+ ### Select
165
+
166
+ Selects a branch based on an exact string match. Always include an `other` fallback.
167
+
168
+ ```
169
+ {gender, select, male {He} female {She} other {They}} liked your post.
170
+ ```
171
+
172
+ [ICU User Guide: Formatting Messages](https://unicode-org.github.io/icu/userguide/format_parse/messages/)
173
+
174
+ ## Further Reading
175
+
176
+ - [MDN: Intl](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl), full API reference
177
+ - [ICU Message Format](https://unicode-org.github.io/icu/userguide/format_parse/messages/), the message syntax standard
178
+ - [Can I Use: Intl](https://caniuse.com/?search=Intl), browser support tables
@@ -1,98 +1,98 @@
1
- # RouteLink
2
-
3
- A clickable element that triggers client-side navigation to a named route.
4
-
5
- ## Usage
6
-
7
- ### Basic Navigation
8
-
9
- ```html
10
- <r-link name="home">Home</r-link>
11
- <r-link name="about">About Us</r-link>
12
- ```
13
-
14
- ### With Route Parameters
15
-
16
- ```html
17
- <r-link name="user" param-id="123">View User</r-link>
18
- <r-link name="product" param-id="456" param-tab="details">Product Details</r-link>
19
- ```
20
-
21
- ### With Target
22
-
23
- ```html
24
- <r-link name="settings" target="sidebar">Settings</r-link>
25
- <r-link name="preview" target="modal">Preview</r-link>
26
- ```
27
-
28
- ### Complex Parameters via JSON
29
-
30
- ```html
31
- <r-link name="search" params='{"query":"typescript","page":1}'>
32
- Search Results
33
- </r-link>
34
- ```
35
-
36
- ## Attributes
37
-
38
- | Attribute | Type | Description |
39
- |-----------|------|-------------|
40
- | `name` | `string` | Route name to navigate to (required) |
41
- | `target` | `string` | Target `r-route-target` name |
42
- | `params` | `string` | JSON object with additional route data |
43
- | `param-*` | `string` | Individual route parameters (e.g., `param-id="123"`) |
44
-
45
- ## Behavior
46
-
47
- 1. Renders as an inline element with `cursor: pointer`
48
- 2. Sets `role="link"` and `tabindex="0"` for accessibility
49
- 3. On click, calls `navigate()` with the route name and collected parameters
50
- 4. Prevents default click behavior
51
-
52
- ## Combining Parameters
53
-
54
- Both `param-*` attributes and `params` JSON can be used together:
55
-
56
- ```html
57
- <r-link name="product"
58
- param-id="789"
59
- params='{"source":"email","campaign":"summer"}'>
60
- View Product
61
- </r-link>
62
- ```
63
-
64
- All parameters are merged into a single flat object:
65
- ```typescript
66
- { id: '789', source: 'email', campaign: 'summer' }
67
- ```
68
-
69
- ## Styling
70
-
71
- Style as any inline element:
72
-
73
- ```css
74
- r-link {
75
- color: var(--accent-primary);
76
- text-decoration: underline;
77
- }
78
-
79
- r-link:hover {
80
- color: var(--accent-hover);
81
- }
82
-
83
- r-link:focus {
84
- outline: 2px solid var(--accent-primary);
85
- outline-offset: 2px;
86
- }
87
- ```
88
-
89
- ## Comparison with Native Links
90
-
91
- | Feature | `<a href>` | `<r-link>` |
92
- |---------|------------|---------|
93
- | Navigation | Full page reload | Client-side routing |
94
- | Parameters | Query string | Route params + data |
95
- | Target | Window/frame | Route target |
96
- | SEO | Crawlable | Requires SSR |
97
-
98
- Use `<r-link>` for SPA navigation within the app. Use native `<a>` for external links or when SEO is critical.
1
+ # RouteLink
2
+
3
+ A clickable element that triggers client-side navigation to a named route.
4
+
5
+ ## Usage
6
+
7
+ ### Basic Navigation
8
+
9
+ ```html
10
+ <r-link name="home">Home</r-link>
11
+ <r-link name="about">About Us</r-link>
12
+ ```
13
+
14
+ ### With Route Parameters
15
+
16
+ ```html
17
+ <r-link name="user" param-id="123">View User</r-link>
18
+ <r-link name="product" param-id="456" param-tab="details">Product Details</r-link>
19
+ ```
20
+
21
+ ### With Target
22
+
23
+ ```html
24
+ <r-link name="settings" target="sidebar">Settings</r-link>
25
+ <r-link name="preview" target="modal">Preview</r-link>
26
+ ```
27
+
28
+ ### Complex Parameters via JSON
29
+
30
+ ```html
31
+ <r-link name="search" params='{"query":"typescript","page":1}'>
32
+ Search Results
33
+ </r-link>
34
+ ```
35
+
36
+ ## Attributes
37
+
38
+ | Attribute | Type | Description |
39
+ |-----------|------|-------------|
40
+ | `name` | `string` | Route name to navigate to (required) |
41
+ | `target` | `string` | Target `r-route-target` name |
42
+ | `params` | `string` | JSON object with additional route data |
43
+ | `param-*` | `string` | Individual route parameters (e.g., `param-id="123"`) |
44
+
45
+ ## Behavior
46
+
47
+ 1. Renders as an inline element with `cursor: pointer`
48
+ 2. Sets `role="link"` and `tabindex="0"` for accessibility
49
+ 3. On click, calls `navigate()` with the route name and collected parameters
50
+ 4. Prevents default click behavior
51
+
52
+ ## Combining Parameters
53
+
54
+ Both `param-*` attributes and `params` JSON can be used together:
55
+
56
+ ```html
57
+ <r-link name="product"
58
+ param-id="789"
59
+ params='{"source":"email","campaign":"summer"}'>
60
+ View Product
61
+ </r-link>
62
+ ```
63
+
64
+ All parameters are merged into a single flat object:
65
+ ```typescript
66
+ { id: '789', source: 'email', campaign: 'summer' }
67
+ ```
68
+
69
+ ## Styling
70
+
71
+ Style as any inline element:
72
+
73
+ ```css
74
+ r-link {
75
+ color: var(--accent-primary);
76
+ text-decoration: underline;
77
+ }
78
+
79
+ r-link:hover {
80
+ color: var(--accent-hover);
81
+ }
82
+
83
+ r-link:focus {
84
+ outline: 2px solid var(--accent-primary);
85
+ outline-offset: 2px;
86
+ }
87
+ ```
88
+
89
+ ## Comparison with Native Links
90
+
91
+ | Feature | `<a href>` | `<r-link>` |
92
+ |---------|------------|---------|
93
+ | Navigation | Full page reload | Client-side routing |
94
+ | Parameters | Query string | Route params + data |
95
+ | Target | Window/frame | Route target |
96
+ | SEO | Crawlable | Requires SSR |
97
+
98
+ Use `<r-link>` for SPA navigation within the app. Use native `<a>` for external links or when SEO is critical.