@telperion/elements 6.1.0 → 7.1.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 (140) hide show
  1. package/.build-manifest.json +22 -1
  2. package/README.md +40 -5
  3. package/_chunks/code-cdn-element-ClAO2lep.d.cts +200 -0
  4. package/_chunks/code-cdn-element-ClAO2lep.d.ts +200 -0
  5. package/code/bundled-language-loader.cjs +18 -0
  6. package/code/bundled-language-loader.cjs.map +1 -0
  7. package/code/bundled-language-loader.js +16 -0
  8. package/code/bundled-language-loader.js.map +1 -0
  9. package/code/cdn-language-loader.cjs +41 -0
  10. package/code/cdn-language-loader.cjs.map +1 -0
  11. package/code/cdn-language-loader.js +36 -0
  12. package/code/cdn-language-loader.js.map +1 -0
  13. package/code/cdn.cjs +21 -0
  14. package/code/cdn.cjs.map +1 -0
  15. package/code/cdn.d.cts +3 -0
  16. package/code/cdn.d.ts +3 -0
  17. package/code/cdn.js +16 -0
  18. package/code/cdn.js.map +1 -0
  19. package/code/code-element-base.cjs +241 -0
  20. package/code/code-element-base.cjs.map +1 -0
  21. package/code/code-element-base.js +239 -0
  22. package/code/code-element-base.js.map +1 -0
  23. package/code/code-element.cjs +16 -0
  24. package/code/code-element.cjs.map +1 -0
  25. package/code/code-element.js +14 -0
  26. package/code/code-element.js.map +1 -0
  27. package/code/copy.cjs +41 -0
  28. package/code/copy.cjs.map +1 -0
  29. package/code/copy.js +39 -0
  30. package/code/copy.js.map +1 -0
  31. package/code/css-variables-theme.cjs +24 -0
  32. package/code/css-variables-theme.cjs.map +1 -0
  33. package/code/css-variables-theme.js +21 -0
  34. package/code/css-variables-theme.js.map +1 -0
  35. package/code/highlighter.cjs +84 -0
  36. package/code/highlighter.cjs.map +1 -0
  37. package/code/highlighter.js +80 -0
  38. package/code/highlighter.js.map +1 -0
  39. package/code/index.cjs +19 -0
  40. package/code/index.cjs.map +1 -0
  41. package/code/index.d.cts +13 -0
  42. package/code/index.d.ts +13 -0
  43. package/code/index.js +6 -0
  44. package/code/index.js.map +1 -0
  45. package/code/language-loader.cjs +22 -0
  46. package/code/language-loader.cjs.map +1 -0
  47. package/code/language-loader.js +19 -0
  48. package/code/language-loader.js.map +1 -0
  49. package/code/line-ranges.cjs +28 -0
  50. package/code/line-ranges.cjs.map +1 -0
  51. package/code/line-ranges.js +25 -0
  52. package/code/line-ranges.js.map +1 -0
  53. package/code/source.cjs +52 -0
  54. package/code/source.cjs.map +1 -0
  55. package/code/source.js +48 -0
  56. package/code/source.js.map +1 -0
  57. package/code/styles.cjs +183 -0
  58. package/code/styles.cjs.map +1 -0
  59. package/code/styles.js +181 -0
  60. package/code/styles.js.map +1 -0
  61. package/code/templates.cjs +66 -0
  62. package/code/templates.cjs.map +1 -0
  63. package/code/templates.js +63 -0
  64. package/code/templates.js.map +1 -0
  65. package/custom-elements.json +3993 -2377
  66. package/fesm/elements.mjs +501 -216
  67. package/fesm/elements.mjs.map +1 -1
  68. package/iife/code/cdn.js +263 -0
  69. package/iife/code/cdn.js.map +1 -0
  70. package/iife/elements.js +36 -36
  71. package/iife/elements.js.map +1 -1
  72. package/iife/router/index.js +23 -23
  73. package/iife/router/index.js.map +1 -1
  74. package/index.cjs +23 -18
  75. package/index.cjs.map +1 -1
  76. package/index.d.cts +1 -1
  77. package/index.d.ts +1 -1
  78. package/index.js +8 -6
  79. package/index.js.map +1 -1
  80. package/package.json +39 -2
  81. package/router/history-managed.cjs +1 -1
  82. package/router/history-managed.cjs.map +1 -1
  83. package/router/history-managed.js +1 -1
  84. package/router/history-managed.js.map +1 -1
  85. package/router/index.cjs +23 -18
  86. package/router/index.cjs.map +1 -1
  87. package/router/index.d.cts +273 -168
  88. package/router/index.d.ts +273 -168
  89. package/router/index.js +8 -6
  90. package/router/index.js.map +1 -1
  91. package/router/route-element.cjs +244 -0
  92. package/router/route-element.cjs.map +1 -0
  93. package/router/route-element.js +239 -0
  94. package/router/route-element.js.map +1 -0
  95. package/router/route-events.cjs +14 -0
  96. package/router/route-events.cjs.map +1 -0
  97. package/router/route-events.js +10 -0
  98. package/router/route-events.js.map +1 -0
  99. package/router/route-source.cjs +134 -0
  100. package/router/route-source.cjs.map +1 -0
  101. package/router/route-source.js +129 -0
  102. package/router/route-source.js.map +1 -0
  103. package/router/route-templates.cjs +18 -0
  104. package/router/route-templates.cjs.map +1 -0
  105. package/router/route-templates.js +16 -0
  106. package/router/route-templates.js.map +1 -0
  107. package/router/{tha-router-config.cjs → router-config-element.cjs} +51 -51
  108. package/router/router-config-element.cjs.map +1 -0
  109. package/router/{tha-router-config.js → router-config-element.js} +52 -52
  110. package/router/router-config-element.js.map +1 -0
  111. package/router/{tha-router.cjs → router-element.cjs} +47 -33
  112. package/router/router-element.cjs.map +1 -0
  113. package/router/{tha-router.js → router-element.js} +47 -33
  114. package/router/router-element.js.map +1 -0
  115. package/router/{tha-router-link.cjs → router-link-element.cjs} +15 -15
  116. package/router/router-link-element.cjs.map +1 -0
  117. package/router/{tha-router-link.js → router-link-element.js} +16 -16
  118. package/router/router-link-element.js.map +1 -0
  119. package/router/{tha-router-outlet.cjs → router-outlet-element.cjs} +44 -31
  120. package/router/router-outlet-element.cjs.map +1 -0
  121. package/router/{tha-router-outlet.js → router-outlet-element.js} +43 -30
  122. package/router/router-outlet-element.js.map +1 -0
  123. package/router/{tha-router-param.cjs → router-param-element.cjs} +62 -62
  124. package/router/router-param-element.cjs.map +1 -0
  125. package/router/{tha-router-param.js → router-param-element.js} +62 -62
  126. package/router/router-param-element.js.map +1 -0
  127. package/router/tha-route.cjs +0 -128
  128. package/router/tha-route.cjs.map +0 -1
  129. package/router/tha-route.js +0 -125
  130. package/router/tha-route.js.map +0 -1
  131. package/router/tha-router-config.cjs.map +0 -1
  132. package/router/tha-router-config.js.map +0 -1
  133. package/router/tha-router-link.cjs.map +0 -1
  134. package/router/tha-router-link.js.map +0 -1
  135. package/router/tha-router-outlet.cjs.map +0 -1
  136. package/router/tha-router-outlet.js.map +0 -1
  137. package/router/tha-router-param.cjs.map +0 -1
  138. package/router/tha-router-param.js.map +0 -1
  139. package/router/tha-router.cjs.map +0 -1
  140. package/router/tha-router.js.map +0 -1
package/fesm/elements.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { __decorate, __metadata } from 'tslib';
2
2
  import { LitElement, css, html as html$1 } from 'lit';
3
3
  import { property, customElement, state } from 'lit/decorators.js';
4
- import { signal, SignalWatcher, computed, html } from '@lit-labs/signals';
4
+ import { signal, computed, SignalWatcher, html } from '@lit-labs/signals';
5
5
  import { noop } from '@telperion/js-utils/function/noop';
6
6
  import { uniquify } from '@telperion/js-utils/array/uniquify';
7
7
  import { minMax } from '@telperion/js-utils/math/min-max';
@@ -15,56 +15,247 @@ import { sliceBefore } from '@telperion/js-utils/array/slice-before';
15
15
  import { debounceWithKey } from '@telperion/js-utils/function/debounce';
16
16
  import { DomClone } from '@telperion/dom-utils';
17
17
 
18
- var _a$3, _b;
18
+ /** Fired on a `<tp-route>` when its `src` content has loaded. Bubbles and is composed. */
19
+ const ROUTE_LOAD_EVENT = "tp-route-load";
20
+ /** Fired on a `<tp-route>` when its `src` content failed to load. Bubbles and is composed. */
21
+ const ROUTE_ERROR_EVENT = "tp-route-error";
22
+ function createRouteSourceEvent(type, detail) {
23
+ return new CustomEvent(type, { detail, bubbles: true, composed: true });
24
+ }
25
+
26
+ const NO_SOURCE = Object.freeze({ status: "none", url: null, fragment: null, error: null });
27
+ /**
28
+ * Default {@link RouteSourceLoader}: a plain `fetch` that rejects on non-2xx
29
+ * responses.
30
+ */
31
+ const defaultRouteSourceLoader = async (url, signal) => {
32
+ const response = await fetch(url, { signal });
33
+ if (!response.ok) {
34
+ throw new Error(`Failed to load route source "${url}": ${response.status} ${response.statusText}`);
35
+ }
36
+ return response.text();
37
+ };
38
+ /**
39
+ * Resolves a `src` attribute value against the document base URL.
40
+ */
41
+ function resolveRouteSrc(src, base = document.baseURI) {
42
+ return new URL(src, base).href;
43
+ }
44
+ /**
45
+ * Parses an HTML string into an inert `DocumentFragment`.
46
+ *
47
+ * Parsing goes through a detached `<template>`, so `<script>` elements are
48
+ * never executed (not even when the fragment is later cloned into the
49
+ * document) and `<html>` / `<head>` / `<body>` wrappers are dropped.
50
+ */
51
+ function parseRouteHtml(html) {
52
+ const template = document.createElement("template");
53
+ template.innerHTML = html;
54
+ return template.content;
55
+ }
56
+ /**
57
+ * Loads, parses and caches the remote content of a single route.
58
+ *
59
+ * - Content is requested once per URL and cached until the URL changes.
60
+ * - Concurrent {@link load} calls share the in-flight request.
61
+ * - Changing the URL or calling {@link abort} cancels the in-flight request;
62
+ * late responses for a superseded request are ignored.
63
+ * - Failures are not cached: the next {@link load} retries.
64
+ */
65
+ class RouteSource {
66
+ #controller;
67
+ #pending;
68
+ #onChange;
69
+ /**
70
+ * @param onChange - Called synchronously after every state transition.
71
+ */
72
+ constructor(onChange = () => undefined) {
73
+ /** Reactive snapshot of the current state. */
74
+ this.state = signal(NO_SOURCE);
75
+ this.#controller = null;
76
+ this.#pending = null;
77
+ this.#onChange = onChange;
78
+ }
79
+ /** Current absolute URL, or `null` when the route has no `src`. */
80
+ get url() {
81
+ return this.state.get().url;
82
+ }
83
+ /**
84
+ * Points the source at a new URL. A no-op when the URL is unchanged;
85
+ * otherwise any in-flight request is cancelled and the cache is dropped.
86
+ */
87
+ setUrl(url) {
88
+ if (url === this.url)
89
+ return;
90
+ this.#cancel();
91
+ this.#set(url ? { status: "idle", url, fragment: null, error: null } : NO_SOURCE);
92
+ }
93
+ /**
94
+ * Ensures the content for the current URL is loaded.
95
+ *
96
+ * @returns A promise that settles once the content is loaded or failed.
97
+ * It never rejects; failures are reported through {@link state}.
98
+ */
99
+ load(loader) {
100
+ const { status, url } = this.state.get();
101
+ if (!url || status === "loaded")
102
+ return Promise.resolve();
103
+ if (this.#pending)
104
+ return this.#pending;
105
+ const controller = new AbortController();
106
+ this.#controller = controller;
107
+ this.#set({ status: "loading", url, fragment: null, error: null });
108
+ const pending = this.#request(loader, url, controller).finally(() => {
109
+ if (this.#controller !== controller)
110
+ return;
111
+ this.#controller = null;
112
+ this.#pending = null;
113
+ });
114
+ this.#pending = pending;
115
+ return pending;
116
+ }
117
+ /**
118
+ * Cancels the in-flight request, if any. Already loaded content is kept.
119
+ */
120
+ abort() {
121
+ if (!this.#controller)
122
+ return;
123
+ const { url } = this.state.get();
124
+ this.#cancel();
125
+ this.#set({ status: "idle", url, fragment: null, error: null });
126
+ }
127
+ async #request(loader, url, controller) {
128
+ try {
129
+ const html = await loader(url, controller.signal);
130
+ if (controller.signal.aborted)
131
+ return;
132
+ this.#set({ status: "loaded", url, fragment: parseRouteHtml(html), error: null });
133
+ }
134
+ catch (error) {
135
+ if (controller.signal.aborted)
136
+ return;
137
+ this.#set({ status: "error", url, fragment: null, error });
138
+ }
139
+ }
140
+ #cancel() {
141
+ this.#controller?.abort();
142
+ this.#controller = null;
143
+ this.#pending = null;
144
+ }
145
+ #set(state) {
146
+ this.state.set(state);
147
+ this.#onChange(state);
148
+ }
149
+ }
150
+
19
151
  /**
20
- * Symbol used to access the route's template fragment signal.
152
+ * Collects the direct `<template>` children of a route element by role.
153
+ * For each role the first matching template wins.
154
+ */
155
+ function readRouteTemplates(route) {
156
+ const templates = Array.from(route.children).filter((child) => child instanceof HTMLTemplateElement);
157
+ const find = (predicate) => templates.find(predicate)?.content ?? null;
158
+ return {
159
+ content: find(template => !template.hasAttribute("data-loading") && !template.hasAttribute("data-error")),
160
+ loading: find(template => template.hasAttribute("data-loading")),
161
+ error: find(template => template.hasAttribute("data-error")),
162
+ };
163
+ }
164
+
165
+ var _a$3, _b, _c;
166
+ /**
167
+ * Symbol used to access the route's content fragment signal.
21
168
  * @internal
22
169
  */
23
- const FRAGMENT = Symbol('ThaRoute:fragment');
170
+ const FRAGMENT = Symbol('RouteElement:fragment');
24
171
  /**
25
172
  * Symbol used to access the route's URLPattern instance.
26
173
  * @internal
27
174
  */
28
- const PATH_PATTERN = Symbol('ThaRoute:path-pattern');
175
+ const PATH_PATTERN = Symbol('RouteElement:path-pattern');
176
+ /**
177
+ * Symbol used to access the status signal of the route's `src` content.
178
+ * @internal
179
+ */
180
+ const SOURCE_STATUS = Symbol('RouteElement:source-status');
181
+ /**
182
+ * Symbol used by the router to mark the route as active or inactive.
183
+ * @internal
184
+ */
185
+ const SET_ACTIVE = Symbol('RouteElement:set-active');
186
+ /** Boolean attributes reflecting the status of the route's `src` content. */
187
+ const STATUS_ATTRIBUTES = ['loading', 'loaded', 'error'];
29
188
  /**
30
189
  * A custom element that defines a route in the router.
31
190
  *
32
- * Each route contains a template element with the content to render when
33
- * the route matches the current URL. The router watches for changes to
34
- * the template content and automatically updates the outlet.
191
+ * The route's content comes from either:
192
+ * - an inline `<template>` child, or
193
+ * - a `src` URL, fetched the first time the route becomes active and cached
194
+ * until `src` changes. Optional `<template data-loading>` and
195
+ * `<template data-error>` children are rendered while loading and on failure.
35
196
  *
36
197
  * The `path` attribute uses URLPattern syntax and supports:
37
198
  * - Static paths: `/about`, `/users`
38
199
  * - Dynamic segments: `/users/:id`, `/posts/:category/:slug`
39
200
  * - Wildcards: `/blog/*`, `/docs/**`
40
201
  *
202
+ * While a `src` is involved, the route reflects its status as one of the
203
+ * boolean attributes `loading`, `loaded` or `error`.
204
+ *
205
+ * @fires tp-route-load - The `src` content has loaded. `detail: { src }`
206
+ * @fires tp-route-error - The `src` content failed to load. `detail: { src, error }`
207
+ *
41
208
  * @example
42
209
  * ```html
43
- * <tha-router>
44
- * <tha-route path="/">
210
+ * <tp-router>
211
+ * <tp-route path="/">
45
212
  * <template><h1>Home Page</h1></template>
46
- * </tha-route>
47
- * <tha-route path="/users/:id">
48
- * <template><h1>User Profile</h1></template>
49
- * </tha-route>
50
- * <tha-router-outlet></tha-router-outlet>
51
- * </tha-router>
213
+ * </tp-route>
214
+ * <tp-route path="/docs/:slug" src="/partials/docs.html">
215
+ * <template data-loading><p>Loading…</p></template>
216
+ * <template data-error><p>Could not load the docs.</p></template>
217
+ * </tp-route>
218
+ * <tp-router-outlet></tp-router-outlet>
219
+ * </tp-router>
52
220
  * ```
53
221
  */
54
- let ThaRoute = class ThaRoute extends LitElement {
222
+ let RouteElement = class RouteElement extends LitElement {
55
223
  constructor() {
56
224
  super(...arguments);
225
+ /** The route's `<template>` children, grouped by role. */
226
+ this.#templates = signal(readRouteTemplates(this));
227
+ /** Loader and cache for the `src` content. */
228
+ this.#source = new RouteSource(state => this.#onSourceChange(state));
229
+ /** Whether the router currently matches this route. */
230
+ this.#active = false;
231
+ /**
232
+ * Signal with the fragment to render for this route:
233
+ * - no `src`: the inline template's content
234
+ * - `src` loaded: the fetched content
235
+ * - `src` failed: the `data-error` template's content
236
+ * - otherwise: the `data-loading` template's content
237
+ * @internal
238
+ */
239
+ this[_a$3] = computed(() => {
240
+ const templates = this.#templates.get();
241
+ const { status, fragment } = this.#source.state.get();
242
+ switch (status) {
243
+ case 'none': return templates.content;
244
+ case 'loaded': return fragment;
245
+ case 'error': return templates.error;
246
+ default: return templates.loading;
247
+ }
248
+ });
57
249
  /**
58
- * Signal containing weak reference to the template's DocumentFragment.
59
- * Automatically updates when the template content changes.
250
+ * Signal with the status of the route's `src` content.
60
251
  * @internal
61
252
  */
62
- this[_a$3] = signal(this.#getTemplateFragment());
253
+ this[_b] = computed(() => this.#source.state.get().status);
63
254
  /**
64
255
  * URLPattern instance for matching the current URL against this route's path.
65
256
  * @internal
66
257
  */
67
- this[_b] = null;
258
+ this[_c] = null;
68
259
  /**
69
260
  * The URL pattern to match for this route.
70
261
  * Uses URLPattern syntax with support for dynamic segments and wildcards.
@@ -74,12 +265,35 @@ let ThaRoute = class ThaRoute extends LitElement {
74
265
  * @example "/blog/*"
75
266
  */
76
267
  this.path = null;
268
+ /**
269
+ * URL of an HTML file to use as the route's content, resolved against
270
+ * `document.baseURI`. Fetched the first time the route becomes active and
271
+ * cached until it changes. Takes precedence over the inline `<template>`.
272
+ *
273
+ * The fetched HTML is trusted like `innerHTML`: it is inserted as-is,
274
+ * although its `<script>` elements do not run.
275
+ *
276
+ * @attr src
277
+ * @example "/partials/about.html"
278
+ */
279
+ this.src = null;
280
+ /**
281
+ * Function that fetches the `src` content. Override it to add headers,
282
+ * credentials or caching, or to stub requests in tests. It receives the
283
+ * absolute URL and an `AbortSignal`, and must reject on failure.
284
+ */
285
+ this.loader = defaultRouteSourceLoader;
77
286
  /** Observes changes to child elements to detect template updates */
78
287
  this.#templateObserver = new MutationObserver(() => {
79
- this[FRAGMENT].set(this.#getTemplateFragment());
288
+ this.#templates.set(readRouteTemplates(this));
80
289
  });
81
290
  }
82
- static { _a$3 = FRAGMENT, _b = PATH_PATTERN; }
291
+ /** The route's `<template>` children, grouped by role. */
292
+ #templates;
293
+ /** Loader and cache for the `src` content. */
294
+ #source;
295
+ /** Whether the router currently matches this route. */
296
+ #active;
83
297
  /** Observes changes to child elements to detect template updates */
84
298
  #templateObserver;
85
299
  /**
@@ -89,10 +303,15 @@ let ThaRoute = class ThaRoute extends LitElement {
89
303
  connectedCallback() {
90
304
  super.connectedCallback();
91
305
  this.#templateObserver.observe(this, { childList: true });
306
+ this.#templates.set(readRouteTemplates(this));
307
+ // Resume a request cancelled by a previous disconnect
308
+ if (this.#active)
309
+ this.#syncSource();
92
310
  }
93
311
  /**
94
312
  * Lifecycle callback when an attribute changes.
95
- * Updates the URLPattern when the path attribute changes.
313
+ * Updates the URLPattern when the path attribute changes, and the content
314
+ * source when the src attribute changes.
96
315
  *
97
316
  * @param name - The attribute name that changed
98
317
  * @param _old - The old attribute value
@@ -104,34 +323,73 @@ let ThaRoute = class ThaRoute extends LitElement {
104
323
  case 'path':
105
324
  this[PATH_PATTERN] = value ? new URLPattern({ pathname: value }) : null;
106
325
  break;
326
+ case 'src':
327
+ this.#syncSource();
328
+ break;
107
329
  }
108
330
  }
109
331
  /**
110
- * Extracts the DocumentFragment from the template element.
111
- * Returns a weak reference to prevent memory leaks.
332
+ * Picks up `src` changes made through the property. Loads the new content
333
+ * right away when the route is active.
334
+ */
335
+ willUpdate(changed) {
336
+ super.willUpdate(changed);
337
+ if (changed.has('src'))
338
+ this.#syncSource();
339
+ }
340
+ /**
341
+ * Called by the router when this route starts or stops matching.
342
+ * Activating a route with a `src` loads its content unless already cached.
112
343
  *
113
- * @returns Weak reference to the template fragment, or null if no template found
344
+ * @internal
345
+ */
346
+ [(_a$3 = FRAGMENT, _b = SOURCE_STATUS, _c = PATH_PATTERN, SET_ACTIVE)](active) {
347
+ this.#active = active;
348
+ this.#syncSource();
349
+ }
350
+ /**
351
+ * Points the source at the current `src` and loads it when active.
114
352
  */
115
- #getTemplateFragment() {
116
- const template = this.querySelector('template');
117
- return template ? new WeakRef(template.content) : null;
353
+ #syncSource() {
354
+ this.#source.setUrl(this.src ? resolveRouteSrc(this.src) : null);
355
+ if (this.#active)
356
+ void this.#source.load(this.loader);
357
+ }
358
+ /**
359
+ * Reflects the source status as attributes and dispatches load/error events.
360
+ */
361
+ #onSourceChange({ status, url, error }) {
362
+ for (const attribute of STATUS_ATTRIBUTES) {
363
+ this.toggleAttribute(attribute, attribute === status);
364
+ }
365
+ if (!url)
366
+ return;
367
+ if (status === 'loaded')
368
+ this.dispatchEvent(createRouteSourceEvent(ROUTE_LOAD_EVENT, { src: url }));
369
+ if (status === 'error')
370
+ this.dispatchEvent(createRouteSourceEvent(ROUTE_ERROR_EVENT, { src: url, error }));
118
371
  }
119
372
  /**
120
373
  * Lifecycle callback when the element is disconnected from the DOM.
121
- * Cleans up the template observer.
374
+ * Cleans up the template observer and cancels any in-flight request.
122
375
  */
123
376
  disconnectedCallback() {
124
377
  super.disconnectedCallback();
125
378
  this.#templateObserver.disconnect();
379
+ this.#source.abort();
126
380
  }
127
381
  };
128
382
  __decorate([
129
383
  property({ type: String }),
130
384
  __metadata("design:type", Object)
131
- ], ThaRoute.prototype, "path", void 0);
132
- ThaRoute = __decorate([
133
- customElement('tha-route')
134
- ], ThaRoute);
385
+ ], RouteElement.prototype, "path", void 0);
386
+ __decorate([
387
+ property({ type: String }),
388
+ __metadata("design:type", Object)
389
+ ], RouteElement.prototype, "src", void 0);
390
+ RouteElement = __decorate([
391
+ customElement('tp-route')
392
+ ], RouteElement);
135
393
 
136
394
  /**
137
395
  * Base class that powers Telperion's shared color/design system.
@@ -376,7 +634,7 @@ const HistoryManaged = (superClass) => {
376
634
  this.#parentHistoryType = computed(() => {
377
635
  // Start above this element: `closest()` matches the element itself, and an outlet or config
378
636
  // resolving its own history type would read its own computed (a signal cycle)
379
- const parent = this.parentElement?.closest('tha-router-config, tha-router-outlet');
637
+ const parent = this.parentElement?.closest('tp-router-config, tp-router-outlet');
380
638
  return parent?.[HISTORY_TYPE]?.get();
381
639
  });
382
640
  /** Resolved history type: own → parent → global */
@@ -413,33 +671,36 @@ var _a$2;
413
671
  * Symbol used by the router to call the internal render method on the outlet.
414
672
  * @internal
415
673
  */
416
- const RENDER_ROUTE = Symbol('ThaRouterOutlet:renderRoute');
417
- const PARAMS = Symbol('ThaRouterOutlet:params');
674
+ const RENDER_ROUTE = Symbol('RouterOutletElement:renderRoute');
675
+ const PARAMS = Symbol('RouterOutletElement:params');
418
676
  /**
419
677
  * A custom element that serves as a rendering target for router content.
420
678
  *
421
- * The outlet automatically binds to its parent tha-router or to a specific router
679
+ * The outlet automatically binds to its parent tp-router or to a specific router
422
680
  * identified by the `for` attribute. When the router's active route changes,
423
681
  * the outlet clones and renders the route's template content.
424
682
  *
683
+ * While the active route's `src` content is pending, the outlet has the
684
+ * `route-loading` attribute; when it failed, the `route-error` attribute.
685
+ *
425
686
  * @example
426
687
  * ```html
427
- * <tha-router>
428
- * <tha-route path="/"><template><h1>Home</h1></template></tha-route>
429
- * <tha-router-outlet></tha-router-outlet>
430
- * </tha-router>
688
+ * <tp-router>
689
+ * <tp-route path="/"><template><h1>Home</h1></template></tp-route>
690
+ * <tp-router-outlet></tp-router-outlet>
691
+ * </tp-router>
431
692
  * ```
432
693
  *
433
694
  * @example
434
695
  * ```html
435
696
  * <!-- Bind to a specific router by ID -->
436
- * <tha-router id="main-router">
437
- * <tha-route path="/"><template><h1>Home</h1></template></tha-route>
438
- * </tha-router>
439
- * <tha-router-outlet for="main-router"></tha-router-outlet>
697
+ * <tp-router id="main-router">
698
+ * <tp-route path="/"><template><h1>Home</h1></template></tp-route>
699
+ * </tp-router>
700
+ * <tp-router-outlet for="main-router"></tp-router-outlet>
440
701
  * ```
441
702
  */
442
- let ThaRouterOutlet = class ThaRouterOutlet extends SignalWatcherLitElement {
703
+ let RouterOutletElement = class RouterOutletElement extends SignalWatcherLitElement {
443
704
  constructor() {
444
705
  super(...arguments);
445
706
  /** Weak reference to the bound router instance */
@@ -459,19 +720,21 @@ let ThaRouterOutlet = class ThaRouterOutlet extends SignalWatcherLitElement {
459
720
  });
460
721
  this[_a$2] = computed(() => {
461
722
  const ownParams = this.#ownParams.get() ?? {};
462
- const parent = this.parentElement?.closest('tha-router-outlet');
723
+ const parent = this.parentElement?.closest('tp-router-outlet');
463
724
  const parentParams = parent?.[PARAMS].get() ?? {};
464
725
  return Object.freeze({ ...parentParams, ...ownParams });
465
726
  });
466
727
  this.params = {};
728
+ /** Nodes inserted for the current route (elements and text alike) */
729
+ this.#renderedNodes = [];
467
730
  /** Cleanup function for the fragment update effect */
468
731
  this.#fragmentUpdateCleaner = noop;
469
732
  /** Cleanup function for the attribute update effect */
470
733
  this.#attrUpdateCleaner = noop;
471
734
  this.#paramsUpdateCleaner = noop;
472
735
  /**
473
- * The ID of a specific tha-router element to bind to.
474
- * If not set, binds to the nearest parent tha-router.
736
+ * The ID of a specific tp-router element to bind to.
737
+ * If not set, binds to the nearest parent tp-router.
475
738
  *
476
739
  * @attr for
477
740
  */
@@ -500,6 +763,8 @@ let ThaRouterOutlet = class ThaRouterOutlet extends SignalWatcherLitElement {
500
763
  /** Computed signal that extracts the fragment from the route to render */
501
764
  #fragmentToRender;
502
765
  #ownParams;
766
+ /** Nodes inserted for the current route (elements and text alike) */
767
+ #renderedNodes;
503
768
  /** Cleanup function for the fragment update effect */
504
769
  #fragmentUpdateCleaner;
505
770
  /** Cleanup function for the attribute update effect */
@@ -515,16 +780,22 @@ let ThaRouterOutlet = class ThaRouterOutlet extends SignalWatcherLitElement {
515
780
  this.bindToRouter();
516
781
  });
517
782
  this.#fragmentUpdateCleaner = this.updateEffect(() => {
518
- Array.from(this.renderRoot.children).forEach(child => child.remove());
519
- const fragment = this.#fragmentToRender.get()?.deref() ?? null;
783
+ this.#renderedNodes.forEach(node => node.parentNode?.removeChild(node));
784
+ this.#renderedNodes = [];
785
+ const fragment = this.#fragmentToRender.get();
520
786
  if (!fragment)
521
787
  return;
522
- this.renderRoot.appendChild(fragment.cloneNode(true));
788
+ const clone = fragment.cloneNode(true);
789
+ this.#renderedNodes = Array.from(clone.childNodes);
790
+ this.renderRoot.appendChild(clone);
523
791
  });
524
792
  this.#attrUpdateCleaner = this.updateEffect(() => {
525
793
  const route = this.#routeToRender.get()?.deref() ?? null;
526
794
  this.routePath = route?.getAttribute('path') ?? null;
527
795
  this.routeID = route?.id ? route?.id : undefined;
796
+ const status = route?.[SOURCE_STATUS].get() ?? null;
797
+ this.toggleAttribute('route-loading', status === 'idle' || status === 'loading');
798
+ this.toggleAttribute('route-error', status === 'error');
528
799
  });
529
800
  this.#paramsUpdateCleaner = this.updateEffect(() => {
530
801
  const params = this[PARAMS].get();
@@ -544,10 +815,10 @@ let ThaRouterOutlet = class ThaRouterOutlet extends SignalWatcherLitElement {
544
815
  if (!router) {
545
816
  if (this.for) {
546
817
  const root = this.getRootNode();
547
- router = root.querySelector(`tha-router#${this.for}`) ?? undefined;
818
+ router = root.querySelector(`tp-router#${this.for}`) ?? undefined;
548
819
  }
549
820
  else {
550
- router = this.closest('tha-router') ?? undefined;
821
+ router = this.closest('tp-router') ?? undefined;
551
822
  }
552
823
  }
553
824
  const prevRouter = this.#boundRouter?.get()?.deref() ?? null;
@@ -595,55 +866,55 @@ let ThaRouterOutlet = class ThaRouterOutlet extends SignalWatcherLitElement {
595
866
  __decorate([
596
867
  state(),
597
868
  __metadata("design:type", Object)
598
- ], ThaRouterOutlet.prototype, "params", void 0);
869
+ ], RouterOutletElement.prototype, "params", void 0);
599
870
  __decorate([
600
871
  property({ type: String }),
601
872
  __metadata("design:type", Object)
602
- ], ThaRouterOutlet.prototype, "for", void 0);
873
+ ], RouterOutletElement.prototype, "for", void 0);
603
874
  __decorate([
604
875
  property({ type: String, reflect: true }),
605
876
  __metadata("design:type", Object)
606
- ], ThaRouterOutlet.prototype, "routePath", void 0);
877
+ ], RouterOutletElement.prototype, "routePath", void 0);
607
878
  __decorate([
608
879
  property({ type: String, reflect: true }),
609
880
  __metadata("design:type", Object)
610
- ], ThaRouterOutlet.prototype, "routeID", void 0);
611
- ThaRouterOutlet = __decorate([
612
- customElement("tha-router-outlet")
613
- ], ThaRouterOutlet);
881
+ ], RouterOutletElement.prototype, "routeID", void 0);
882
+ RouterOutletElement = __decorate([
883
+ customElement("tp-router-outlet")
884
+ ], RouterOutletElement);
614
885
 
615
886
  /**
616
887
  * A custom element that manages client-side routing for single-page applications.
617
888
  *
618
889
  * The router watches for navigation events and matches the current URL against
619
- * registered routes (tha-route elements), rendering the matching route's content
620
- * in a tha-router-outlet element.
890
+ * registered routes (tp-route elements), rendering the matching route's content
891
+ * in a tp-router-outlet element.
621
892
  *
622
893
  * @example
623
894
  * ```html
624
- * <tha-router history="browser">
625
- * <tha-route path="/">
895
+ * <tp-router history="browser">
896
+ * <tp-route path="/">
626
897
  * <template><h1>Home</h1></template>
627
- * </tha-route>
628
- * <tha-route path="/about">
898
+ * </tp-route>
899
+ * <tp-route path="/about">
629
900
  * <template><h1>About</h1></template>
630
- * </tha-route>
631
- * <tha-router-outlet></tha-router-outlet>
632
- * </tha-router>
901
+ * </tp-route>
902
+ * <tp-router-outlet></tp-router-outlet>
903
+ * </tp-router>
633
904
  * ```
634
905
  */
635
- let ThaRouter = class ThaRouter extends HistoryManaged(SignalWatcherLitElement) {
906
+ let RouterElement = class RouterElement extends HistoryManaged(SignalWatcherLitElement) {
636
907
  /**
637
- * Injects global styles for tha-router elements to hide non-outlet children.
638
- * Ensures that only tha-router-outlet elements are visible within the router.
908
+ * Injects global styles for tp-router elements to hide non-outlet children.
909
+ * Ensures that only tp-router-outlet elements are visible within the router.
639
910
  */
640
911
  static {
641
912
  const styleEl = document.createElement("style");
642
913
  styleEl.setAttribute("type", "text/css");
643
- styleEl.setAttribute("data-id", "tha-router-styles");
914
+ styleEl.setAttribute("data-id", "tp-router-styles");
644
915
  styleEl.textContent = css `
645
- tha-router {
646
- & > :not(tha-router-outlet) {
916
+ tp-router {
917
+ & > :not(tp-router-outlet) {
647
918
  display: none;
648
919
  }
649
920
  }
@@ -652,13 +923,13 @@ let ThaRouter = class ThaRouter extends HistoryManaged(SignalWatcherLitElement)
652
923
  }
653
924
  /**
654
925
  * Observes changes to child elements to detect when routes are added or removed.
655
- * Updates the #routeEls signal whenever tha-route children change.
926
+ * Updates the #routeEls signal whenever tp-route children change.
656
927
  */
657
928
  #routeChildObserver = new MutationObserver((mutations) => {
658
929
  const childListMutations = mutations.filter(mutation => mutation.type === 'childList');
659
930
  if (!childListMutations.length)
660
931
  return;
661
- this.#routeEls.set(Array.from(this.children).filter(child => child instanceof ThaRoute).map(routeEl => new WeakRef(routeEl)));
932
+ this.#routeEls.set(Array.from(this.children).filter(child => child instanceof RouteElement).map(routeEl => new WeakRef(routeEl)));
662
933
  });
663
934
  /** Cleanup function for the route children rendering effect */
664
935
  #routeChildrenEffectCleaner = noop;
@@ -666,12 +937,14 @@ let ThaRouter = class ThaRouter extends HistoryManaged(SignalWatcherLitElement)
666
937
  #historyTypeEffectCleaner = noop;
667
938
  /** Cleanup function to remove history listener */
668
939
  #historyListenerRemover = noop;
669
- /** Signal containing weak references to all tha-route children */
940
+ /** Signal containing weak references to all tp-route children */
670
941
  #routeEls = signal([]);
671
942
  /** Signal containing weak reference to the currently active route */
672
943
  #activeRoute = signal(null);
673
944
  /** Signal containing weak reference to the assigned outlet element */
674
945
  #outlet = signal(null);
946
+ /** Last route marked active through SET_ACTIVE (not reactive, see #activate) */
947
+ #activatedRoute = null;
675
948
  /**
676
949
  * Lifecycle callback when the element is connected to the DOM.
677
950
  * Sets up observers, effects, and history listeners.
@@ -725,15 +998,27 @@ let ThaRouter = class ThaRouter extends HistoryManaged(SignalWatcherLitElement)
725
998
  const routes = this.#routeEls.get()
726
999
  .map(weakRef => weakRef.deref())
727
1000
  .filter(Boolean);
728
- for (const route of routes) {
729
- const pathPattern = route[PATH_PATTERN];
730
- if (pathPattern?.test({ pathname: update.location.pathname })) {
731
- this.#activeRoute.set(new WeakRef(route));
732
- return;
733
- }
734
- }
735
- this.#activeRoute.set(null);
1001
+ const match = routes.find(route => route[PATH_PATTERN]?.test({ pathname: update.location.pathname })) ?? null;
1002
+ this.#activate(match);
1003
+ this.#activeRoute.set(match ? new WeakRef(match) : null);
736
1004
  };
1005
+ /**
1006
+ * Marks the matched route as active and the previous one as inactive.
1007
+ * Re-activating the same route is intentional: it retries a failed `src`.
1008
+ *
1009
+ * The previous route is tracked in a plain field rather than read from
1010
+ * the #activeRoute signal, so effects calling #handleRouteChange do not
1011
+ * start depending on the signal they write.
1012
+ *
1013
+ * @param route - The matched route, or null when nothing matches
1014
+ */
1015
+ #activate(route) {
1016
+ const previous = this.#activatedRoute?.deref() ?? null;
1017
+ if (previous && previous !== route)
1018
+ previous[SET_ACTIVE](false);
1019
+ route?.[SET_ACTIVE](true);
1020
+ this.#activatedRoute = route ? new WeakRef(route) : null;
1021
+ }
737
1022
  /**
738
1023
  * Lifecycle callback when the element is disconnected from the DOM.
739
1024
  * Cleans up all observers, effects, and listeners.
@@ -758,9 +1043,9 @@ let ThaRouter = class ThaRouter extends HistoryManaged(SignalWatcherLitElement)
758
1043
  return this;
759
1044
  }
760
1045
  };
761
- ThaRouter = __decorate([
762
- customElement("tha-router")
763
- ], ThaRouter);
1046
+ RouterElement = __decorate([
1047
+ customElement("tp-router")
1048
+ ], RouterElement);
764
1049
 
765
1050
  /**
766
1051
  * A custom element that provides navigation links for client-side routing.
@@ -775,18 +1060,18 @@ ThaRouter = __decorate([
775
1060
  * @example
776
1061
  * ```html
777
1062
  * <!-- Absolute path -->
778
- * <tha-router-link to="/about">About</tha-router-link>
1063
+ * <tp-router-link to="/about">About</tp-router-link>
779
1064
  *
780
1065
  * <!-- Relative path -->
781
- * <tha-router-link to="./details">Details</tha-router-link>
782
- * <tha-router-link to="../users">Back to Users</tha-router-link>
1066
+ * <tp-router-link to="./details">Details</tp-router-link>
1067
+ * <tp-router-link to="../users">Back to Users</tp-router-link>
783
1068
  *
784
1069
  * <!-- History navigation -->
785
- * <tha-router-link to="back">← Back</tha-router-link>
786
- * <tha-router-link to="forward">Forward →</tha-router-link>
1070
+ * <tp-router-link to="back">← Back</tp-router-link>
1071
+ * <tp-router-link to="forward">Forward →</tp-router-link>
787
1072
  * ```
788
1073
  */
789
- let ThaRouterLink = class ThaRouterLink extends HistoryManaged(SignalWatcherLitElement) {
1074
+ let RouterLinkElement = class RouterLinkElement extends HistoryManaged(SignalWatcherLitElement) {
790
1075
  constructor() {
791
1076
  super(...arguments);
792
1077
  /**
@@ -861,13 +1146,13 @@ let ThaRouterLink = class ThaRouterLink extends HistoryManaged(SignalWatcherLitE
861
1146
  this[HISTORY].get()?.push(link || '/');
862
1147
  };
863
1148
  }
864
- /** Injects global styles for tha-router-link elements to show pointer cursor */
1149
+ /** Injects global styles for tp-router-link elements to show pointer cursor */
865
1150
  static {
866
1151
  const styleEl = document.createElement("style");
867
1152
  styleEl.setAttribute("type", "text/css");
868
- styleEl.setAttribute("data-id", "tha-router-link-styles");
1153
+ styleEl.setAttribute("data-id", "tp-router-link-styles");
869
1154
  styleEl.textContent = css `
870
- tha-router-link {
1155
+ tp-router-link {
871
1156
  cursor: pointer;
872
1157
  }
873
1158
  `.toString();
@@ -951,14 +1236,14 @@ let ThaRouterLink = class ThaRouterLink extends HistoryManaged(SignalWatcherLitE
951
1236
  __decorate([
952
1237
  property({ type: String }),
953
1238
  __metadata("design:type", Object)
954
- ], ThaRouterLink.prototype, "to", void 0);
1239
+ ], RouterLinkElement.prototype, "to", void 0);
955
1240
  __decorate([
956
1241
  property({ type: Boolean, reflect: true }),
957
1242
  __metadata("design:type", Object)
958
- ], ThaRouterLink.prototype, "active", void 0);
959
- ThaRouterLink = __decorate([
960
- customElement("tha-router-link")
961
- ], ThaRouterLink);
1243
+ ], RouterLinkElement.prototype, "active", void 0);
1244
+ RouterLinkElement = __decorate([
1245
+ customElement("tp-router-link")
1246
+ ], RouterLinkElement);
962
1247
 
963
1248
  /**
964
1249
  * A custom element for configuring router history settings.
@@ -974,13 +1259,13 @@ ThaRouterLink = __decorate([
974
1259
  * ```html
975
1260
  * <head>
976
1261
  * <!-- All routers will use hash routing by default -->
977
- * <tha-router-config history="hash"></tha-router-config>
1262
+ * <tp-router-config history="hash"></tp-router-config>
978
1263
  * </head>
979
1264
  * <body>
980
- * <tha-router>
1265
+ * <tp-router>
981
1266
  * <!-- Uses hash history (global default) -->
982
- * <tha-route path="/home">...</tha-route>
983
- * </tha-router>
1267
+ * <tp-route path="/home">...</tp-route>
1268
+ * </tp-router>
984
1269
  * </body>
985
1270
  * ```
986
1271
  *
@@ -993,20 +1278,20 @@ ThaRouterLink = __decorate([
993
1278
  * ```html
994
1279
  * <body>
995
1280
  * <!-- Section 1: Hash routing -->
996
- * <tha-router-config history="hash">
997
- * <tha-router>
1281
+ * <tp-router-config history="hash">
1282
+ * <tp-router>
998
1283
  * <!-- Uses hash history from parent config -->
999
- * <tha-route path="/dashboard">...</tha-route>
1000
- * </tha-router>
1001
- * </tha-router-config>
1284
+ * <tp-route path="/dashboard">...</tp-route>
1285
+ * </tp-router>
1286
+ * </tp-router-config>
1002
1287
  *
1003
1288
  * <!-- Section 2: Memory routing (isolated) -->
1004
- * <tha-router-config history="memory">
1005
- * <tha-router>
1289
+ * <tp-router-config history="memory">
1290
+ * <tp-router>
1006
1291
  * <!-- Uses memory history from parent config -->
1007
- * <tha-route path="/preview">...</tha-route>
1008
- * </tha-router>
1009
- * </tha-router-config>
1292
+ * <tp-route path="/preview">...</tp-route>
1293
+ * </tp-router>
1294
+ * </tp-router-config>
1010
1295
  * </body>
1011
1296
  * ```
1012
1297
  *
@@ -1020,7 +1305,7 @@ ThaRouterLink = __decorate([
1020
1305
  * <!DOCTYPE html>
1021
1306
  * <html>
1022
1307
  * <head>
1023
- * <tha-router-config history="browser"></tha-router-config>
1308
+ * <tp-router-config history="browser"></tp-router-config>
1024
1309
  * </head>
1025
1310
  * <body>
1026
1311
  * <!-- All routers use browser history -->
@@ -1035,16 +1320,16 @@ ThaRouterLink = __decorate([
1035
1320
  * ```html
1036
1321
  * <head>
1037
1322
  * <!-- Global: browser history -->
1038
- * <tha-router-config history="browser"></tha-router-config>
1323
+ * <tp-router-config history="browser"></tp-router-config>
1039
1324
  * </head>
1040
1325
  * <body>
1041
1326
  * <!-- Main app uses browser history -->
1042
- * <tha-router>...</tha-router>
1327
+ * <tp-router>...</tp-router>
1043
1328
  *
1044
1329
  * <!-- Admin section uses hash history -->
1045
- * <tha-router-config history="hash">
1046
- * <tha-router>...</tha-router>
1047
- * </tha-router-config>
1330
+ * <tp-router-config history="hash">
1331
+ * <tp-router>...</tp-router>
1332
+ * </tp-router-config>
1048
1333
  * </body>
1049
1334
  * ```
1050
1335
  *
@@ -1055,17 +1340,17 @@ ThaRouterLink = __decorate([
1055
1340
  * ```html
1056
1341
  * <body>
1057
1342
  * <!-- Each component has independent navigation -->
1058
- * <tha-router-config history="memory:component1">
1343
+ * <tp-router-config history="memory:component1">
1059
1344
  * <my-widget>
1060
- * <tha-router>...</tha-router>
1345
+ * <tp-router>...</tp-router>
1061
1346
  * </my-widget>
1062
- * </tha-router-config>
1347
+ * </tp-router-config>
1063
1348
  *
1064
- * <tha-router-config history="memory:component2">
1349
+ * <tp-router-config history="memory:component2">
1065
1350
  * <my-widget>
1066
- * <tha-router>...</tha-router>
1351
+ * <tp-router>...</tp-router>
1067
1352
  * </my-widget>
1068
- * </tha-router-config>
1353
+ * </tp-router-config>
1069
1354
  * </body>
1070
1355
  * ```
1071
1356
  *
@@ -1078,11 +1363,11 @@ ThaRouterLink = __decorate([
1078
1363
  *
1079
1364
  * it('should navigate', async () => {
1080
1365
  * const el = await fixture(html`
1081
- * <tha-router-config history="memory:test">
1082
- * <tha-router>
1083
- * <tha-route path="/test">Test Page</tha-route>
1084
- * </tha-router>
1085
- * </tha-router-config>
1366
+ * <tp-router-config history="memory:test">
1367
+ * <tp-router>
1368
+ * <tp-route path="/test">Test Page</tp-route>
1369
+ * </tp-router>
1370
+ * </tp-router-config>
1086
1371
  * `);
1087
1372
  *
1088
1373
  * // Test navigation without affecting browser URL
@@ -1094,56 +1379,56 @@ ThaRouterLink = __decorate([
1094
1379
  * Router components resolve their history in this order:
1095
1380
  *
1096
1381
  * 1. **Own `history` attribute** (highest priority)
1097
- * 2. **Parent `tha-router-config`** (local configuration)
1098
- * 3. **Global `tha-router-config`** (in `<head>`)
1382
+ * 2. **Parent `tp-router-config`** (local configuration)
1383
+ * 3. **Global `tp-router-config`** (in `<head>`)
1099
1384
  * 4. **Default** (`"browser"`)
1100
1385
  *
1101
1386
  * ## Best Practices
1102
1387
  *
1103
- * ✅ **DO**: Place one `tha-router-config` in `<head>` for global settings
1388
+ * ✅ **DO**: Place one `tp-router-config` in `<head>` for global settings
1104
1389
  *
1105
1390
  * ```html
1106
1391
  * <head>
1107
- * <tha-router-config history="browser"></tha-router-config>
1392
+ * <tp-router-config history="browser"></tp-router-config>
1108
1393
  * </head>
1109
1394
  * ```
1110
1395
  *
1111
1396
  * ✅ **DO**: Use local configs for sections with different routing needs
1112
1397
  *
1113
1398
  * ```html
1114
- * <tha-router-config history="memory">
1399
+ * <tp-router-config history="memory">
1115
1400
  * <component-preview>...</component-preview>
1116
- * </tha-router-config>
1401
+ * </tp-router-config>
1117
1402
  * ```
1118
1403
  *
1119
1404
  * ✅ **DO**: Use named memory history for isolated components
1120
1405
  *
1121
1406
  * ```html
1122
- * <tha-router-config history="memory:sidebar">
1407
+ * <tp-router-config history="memory:sidebar">
1123
1408
  * <sidebar-nav>...</sidebar-nav>
1124
- * </tha-router-config>
1409
+ * </tp-router-config>
1125
1410
  * ```
1126
1411
  *
1127
1412
  * ❌ **DON'T**: Place multiple configs in `<head>` (last one wins)
1128
1413
  *
1129
1414
  * ```html
1130
1415
  * <head>
1131
- * <tha-router-config history="browser"></tha-router-config>
1132
- * <tha-router-config history="hash"></tha-router-config> <!-- Overrides above -->
1416
+ * <tp-router-config history="browser"></tp-router-config>
1417
+ * <tp-router-config history="hash"></tp-router-config> <!-- Overrides above -->
1133
1418
  * </head>
1134
1419
  * ```
1135
1420
  *
1136
1421
  * ❌ **DON'T**: Nest configs unnecessarily (inner configs take precedence)
1137
1422
  *
1138
1423
  * ```html
1139
- * <tha-router-config history="browser">
1140
- * <tha-router-config history="hash">
1424
+ * <tp-router-config history="browser">
1425
+ * <tp-router-config history="hash">
1141
1426
  * <!-- Uses hash, not browser -->
1142
- * </tha-router-config>
1143
- * </tha-router-config>
1427
+ * </tp-router-config>
1428
+ * </tp-router-config>
1144
1429
  * ```
1145
1430
  */
1146
- let ThaRouterConfig = class ThaRouterConfig extends HistoryManaged(SignalWatcherLitElement) {
1431
+ let RouterConfigElement = class RouterConfigElement extends HistoryManaged(SignalWatcherLitElement) {
1147
1432
  /**
1148
1433
  * Cleanup function for the global history effect.
1149
1434
  * Only used when the element is placed in `<head>`.
@@ -1160,7 +1445,7 @@ let ThaRouterConfig = class ThaRouterConfig extends HistoryManaged(SignalWatcher
1160
1445
  super.connectedCallback();
1161
1446
  if (!document.head.contains(this))
1162
1447
  return;
1163
- console.log('ThaRouterConfig: Setting global history type to', this[HISTORY_TYPE].get());
1448
+ console.log('RouterConfigElement: Setting global history type to', this[HISTORY_TYPE].get());
1164
1449
  // Set the global history type when this element is connected in <head>
1165
1450
  this.#globalHistoryUnsubscribe = this.updateEffect(() => {
1166
1451
  GLOBAL_HISTORY_TYPE.set(this[HISTORY_TYPE].get());
@@ -1188,9 +1473,9 @@ let ThaRouterConfig = class ThaRouterConfig extends HistoryManaged(SignalWatcher
1188
1473
  return this;
1189
1474
  }
1190
1475
  };
1191
- ThaRouterConfig = __decorate([
1192
- customElement('tha-router-config')
1193
- ], ThaRouterConfig);
1476
+ RouterConfigElement = __decorate([
1477
+ customElement('tp-router-config')
1478
+ ], RouterConfigElement);
1194
1479
 
1195
1480
  /**
1196
1481
  * @fileoverview Router parameter display component
@@ -1198,14 +1483,14 @@ ThaRouterConfig = __decorate([
1198
1483
  * Provides a declarative way to display dynamic route parameter values
1199
1484
  * directly in HTML templates without requiring JavaScript.
1200
1485
  *
1201
- * @module router/tha-router-param
1486
+ * @module router/tp-router-param
1202
1487
  */
1203
1488
  /**
1204
1489
  * Custom element for displaying dynamic route parameter values.
1205
1490
  *
1206
1491
  * This component provides a declarative way to access and display URL
1207
1492
  * parameters extracted from dynamic route segments without writing JavaScript.
1208
- * It must be used inside a `<tha-router-outlet>` element.
1493
+ * It must be used inside a `<tp-router-outlet>` element.
1209
1494
  *
1210
1495
  * ## Features
1211
1496
  *
@@ -1219,15 +1504,15 @@ ThaRouterConfig = __decorate([
1219
1504
  * ### Basic Parameter Display
1220
1505
  *
1221
1506
  * ```html
1222
- * <tha-router>
1223
- * <tha-route path="/users/:id">
1507
+ * <tp-router>
1508
+ * <tp-route path="/users/:id">
1224
1509
  * <template>
1225
1510
  * <h1>User Profile</h1>
1226
- * <p>User ID: <tha-router-param name="id"></tha-router-param></p>
1511
+ * <p>User ID: <tp-router-param name="id"></tp-router-param></p>
1227
1512
  * </template>
1228
- * </tha-route>
1229
- * <tha-router-outlet></tha-router-outlet>
1230
- * </tha-router>
1513
+ * </tp-route>
1514
+ * <tp-router-outlet></tp-router-outlet>
1515
+ * </tp-router>
1231
1516
  * ```
1232
1517
  *
1233
1518
  * When navigating to `/users/123`, the component renders: `User ID: 123`
@@ -1235,19 +1520,19 @@ ThaRouterConfig = __decorate([
1235
1520
  * ### Multiple Parameters
1236
1521
  *
1237
1522
  * ```html
1238
- * <tha-route path="/blog/:year/:month/:slug">
1523
+ * <tp-route path="/blog/:year/:month/:slug">
1239
1524
  * <template>
1240
1525
  * <article>
1241
1526
  * <header>
1242
1527
  * <time>
1243
- * <tha-router-param name="year"></tha-router-param>-
1244
- * <tha-router-param name="month"></tha-router-param>
1528
+ * <tp-router-param name="year"></tp-router-param>-
1529
+ * <tp-router-param name="month"></tp-router-param>
1245
1530
  * </time>
1246
- * <h1><tha-router-param name="slug"></tha-router-param></h1>
1531
+ * <h1><tp-router-param name="slug"></tp-router-param></h1>
1247
1532
  * </header>
1248
1533
  * </article>
1249
1534
  * </template>
1250
- * </tha-route>
1535
+ * </tp-route>
1251
1536
  * ```
1252
1537
  *
1253
1538
  * For `/blog/2024/12/hello-world`, renders:
@@ -1259,111 +1544,111 @@ ThaRouterConfig = __decorate([
1259
1544
  * ### Nested Routes with Parameter Inheritance
1260
1545
  *
1261
1546
  * ```html
1262
- * <tha-router>
1263
- * <tha-route path="/projects/:projectId">
1547
+ * <tp-router>
1548
+ * <tp-route path="/projects/:projectId">
1264
1549
  * <template>
1265
- * <h1>Project <tha-router-param name="projectId"></tha-router-param></h1>
1550
+ * <h1>Project <tp-router-param name="projectId"></tp-router-param></h1>
1266
1551
  *
1267
1552
  * <!-- Nested outlet inherits projectId parameter -->
1268
- * <tha-router-outlet>
1269
- * <tha-route path="/tasks/:taskId">
1553
+ * <tp-router-outlet>
1554
+ * <tp-route path="/tasks/:taskId">
1270
1555
  * <template>
1271
1556
  * <!-- Both params are available -->
1272
1557
  * <h2>Task Details</h2>
1273
- * <p>Project: <tha-router-param name="projectId"></tha-router-param></p>
1274
- * <p>Task: <tha-router-param name="taskId"></tha-router-param></p>
1558
+ * <p>Project: <tp-router-param name="projectId"></tp-router-param></p>
1559
+ * <p>Task: <tp-router-param name="taskId"></tp-router-param></p>
1275
1560
  * </template>
1276
- * </tha-route>
1277
- * </tha-router-outlet>
1561
+ * </tp-route>
1562
+ * </tp-router-outlet>
1278
1563
  * </template>
1279
- * </tha-route>
1280
- * <tha-router-outlet></tha-router-outlet>
1281
- * </tha-router>
1564
+ * </tp-route>
1565
+ * <tp-router-outlet></tp-router-outlet>
1566
+ * </tp-router>
1282
1567
  * ```
1283
1568
  *
1284
1569
  * ### With Styling
1285
1570
  *
1286
1571
  * ```html
1287
1572
  * <style>
1288
- * tha-router-param {
1573
+ * tp-router-param {
1289
1574
  * font-weight: bold;
1290
1575
  * color: var(--primary-color);
1291
1576
  * }
1292
1577
  *
1293
- * tha-router-param[name="id"] {
1578
+ * tp-router-param[name="id"] {
1294
1579
  * font-family: monospace;
1295
1580
  * }
1296
1581
  * </style>
1297
1582
  *
1298
- * <tha-route path="/users/:id">
1583
+ * <tp-route path="/users/:id">
1299
1584
  * <template>
1300
- * <span>User: <tha-router-param name="id"></tha-router-param></span>
1585
+ * <span>User: <tp-router-param name="id"></tp-router-param></span>
1301
1586
  * </template>
1302
- * </tha-route>
1587
+ * </tp-route>
1303
1588
  * ```
1304
1589
  *
1305
1590
  * ## How It Works
1306
1591
  *
1307
- * 1. On connection, finds the nearest parent `<tha-router-outlet>`
1592
+ * 1. On connection, finds the nearest parent `<tp-router-outlet>`
1308
1593
  * 2. Accesses the outlet's PARAMS signal containing all route parameters
1309
1594
  * 3. Computes and displays the value for the specified parameter name
1310
1595
  * 4. Automatically re-renders when the route (and thus params) change
1311
1596
  *
1312
1597
  * ## Error Handling
1313
1598
  *
1314
- * Throws an error if not placed within a `<tha-router-outlet>`:
1599
+ * Throws an error if not placed within a `<tp-router-outlet>`:
1315
1600
  *
1316
1601
  * ```javascript
1317
1602
  * // ✗ Wrong - not inside outlet
1318
- * <tha-router-param name="id"></tha-router-param>
1603
+ * <tp-router-param name="id"></tp-router-param>
1319
1604
  *
1320
1605
  * // ✓ Correct - inside outlet
1321
- * <tha-router-outlet>
1322
- * <tha-router-param name="id"></tha-router-param>
1323
- * </tha-router-outlet>
1606
+ * <tp-router-outlet>
1607
+ * <tp-router-param name="id"></tp-router-param>
1608
+ * </tp-router-outlet>
1324
1609
  * ```
1325
1610
  *
1326
1611
  * ## Alternative: Using Attributes
1327
1612
  *
1328
- * The parent `<tha-router-outlet>` also exposes parameters as `param-*` attributes,
1613
+ * The parent `<tp-router-outlet>` also exposes parameters as `param-*` attributes,
1329
1614
  * which can be used as an alternative approach:
1330
1615
  *
1331
1616
  * ```html
1332
- * <tha-router-outlet id="outlet">
1617
+ * <tp-router-outlet id="outlet">
1333
1618
  * <script>
1334
1619
  * const outlet = document.getElementById('outlet');
1335
1620
  * // Params available as: outlet.getAttribute('param-id')
1336
1621
  * </script>
1337
- * </tha-router-outlet>
1622
+ * </tp-router-outlet>
1338
1623
  * ```
1339
1624
  *
1340
- * However, `<tha-router-param>` is preferred for declarative templates.
1625
+ * However, `<tp-router-param>` is preferred for declarative templates.
1341
1626
  *
1342
1627
  * @example Basic usage
1343
1628
  * ```html
1344
- * <tha-router>
1345
- * <tha-route path="/product/:sku">
1629
+ * <tp-router>
1630
+ * <tp-route path="/product/:sku">
1346
1631
  * <template>
1347
- * <h1>Product: <tha-router-param name="sku"></tha-router-param></h1>
1632
+ * <h1>Product: <tp-router-param name="sku"></tp-router-param></h1>
1348
1633
  * </template>
1349
- * </tha-route>
1350
- * <tha-router-outlet></tha-router-outlet>
1351
- * </tha-router>
1634
+ * </tp-route>
1635
+ * <tp-router-outlet></tp-router-outlet>
1636
+ * </tp-router>
1352
1637
  * ```
1353
1638
  *
1354
1639
  * @example Multiple params with formatting
1355
1640
  * ```html
1356
- * <tha-route path="/user/:username/post/:postId">
1641
+ * <tp-route path="/user/:username/post/:postId">
1357
1642
  * <template>
1358
1643
  * <article>
1359
- * <p>@<tha-router-param name="username"></tha-router-param></p>
1360
- * <p>Post #<tha-router-param name="postId"></tha-router-param></p>
1644
+ * <p>@<tp-router-param name="username"></tp-router-param></p>
1645
+ * <p>Post #<tp-router-param name="postId"></tp-router-param></p>
1361
1646
  * </article>
1362
1647
  * </template>
1363
- * </tha-route>
1648
+ * </tp-route>
1364
1649
  * ```
1365
1650
  */
1366
- let ThaRouterParam = class ThaRouterParam extends SignalWatcherLitElement {
1651
+ let RouterParamElement = class RouterParamElement extends SignalWatcherLitElement {
1367
1652
  constructor() {
1368
1653
  super(...arguments);
1369
1654
  /**
@@ -1410,16 +1695,16 @@ let ThaRouterParam = class ThaRouterParam extends SignalWatcherLitElement {
1410
1695
  /**
1411
1696
  * Lifecycle callback when element is connected to the DOM.
1412
1697
  *
1413
- * Finds the parent `<tha-router-outlet>` and stores a reference.
1698
+ * Finds the parent `<tp-router-outlet>` and stores a reference.
1414
1699
  * Throws an error if not used within an outlet.
1415
1700
  *
1416
- * @throws {Error} If no parent tha-router-outlet is found
1701
+ * @throws {Error} If no parent tp-router-outlet is found
1417
1702
  */
1418
1703
  connectedCallback() {
1419
1704
  super.connectedCallback();
1420
- const outlet = this.closest('tha-router-outlet');
1705
+ const outlet = this.closest('tp-router-outlet');
1421
1706
  if (!outlet) {
1422
- throw new Error('<tha-router-param> must be used within a <tha-router-outlet>.');
1707
+ throw new Error('<tp-router-param> must be used within a <tp-router-outlet>.');
1423
1708
  }
1424
1709
  this.#outlet.set(outlet);
1425
1710
  }
@@ -1457,10 +1742,10 @@ let ThaRouterParam = class ThaRouterParam extends SignalWatcherLitElement {
1457
1742
  __decorate([
1458
1743
  property({ type: String }),
1459
1744
  __metadata("design:type", String)
1460
- ], ThaRouterParam.prototype, "name", void 0);
1461
- ThaRouterParam = __decorate([
1462
- customElement('tha-router-param')
1463
- ], ThaRouterParam);
1745
+ ], RouterParamElement.prototype, "name", void 0);
1746
+ RouterParamElement = __decorate([
1747
+ customElement('tp-router-param')
1748
+ ], RouterParamElement);
1464
1749
 
1465
1750
  const ACCEPT_DROP_PROP = Symbol('Accept Drop');
1466
1751
  const REGISTER_HANDLE_PROP = Symbol('Register Handle');
@@ -4253,5 +4538,5 @@ class PortalOutletFallbackElement extends HTMLElement {
4253
4538
  if (!customElements.get("tp-portal-outlet-fallback"))
4254
4539
  customElements.define("tp-portal-outlet-fallback", PortalOutletFallbackElement);
4255
4540
 
4256
- export { ButtonElement, DetailsSetElement, DragElement, DragHandleElement, DropZoneElement, OptionElement, PopoverElement, PortalElement, PortalOutletElement, PortalOutletFallbackElement, SelectChangeEvent, SelectElement, SelectedContentElement, ThaDragEvent, ThaRoute, ThaRouter, ThaRouterConfig, ThaRouterLink, ThaRouterOutlet, ThaRouterParam };
4541
+ export { ButtonElement, DetailsSetElement, DragElement, DragHandleElement, DropZoneElement, OptionElement, PopoverElement, PortalElement, PortalOutletElement, PortalOutletFallbackElement, ROUTE_ERROR_EVENT, ROUTE_LOAD_EVENT, RouteElement, RouterConfigElement, RouterElement, RouterLinkElement, RouterOutletElement, RouterParamElement, SelectChangeEvent, SelectElement, SelectedContentElement, ThaDragEvent, defaultRouteSourceLoader };
4257
4542
  //# sourceMappingURL=elements.mjs.map