@telperion/elements 1.0.0 → 1.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 (115) hide show
  1. package/.build-manifest.json +58 -0
  2. package/README.md +14 -8
  3. package/drag-drop/drag-element.cjs +59 -60
  4. package/drag-drop/drag-element.cjs.map +1 -0
  5. package/drag-drop/drag-element.js +8 -8
  6. package/drag-drop/drag-element.js.map +1 -1
  7. package/drag-drop/drag-handle-element.cjs +19 -19
  8. package/drag-drop/drag-handle-element.cjs.map +1 -0
  9. package/drag-drop/drag-handle-element.js +8 -7
  10. package/drag-drop/drag-handle-element.js.map +1 -1
  11. package/drag-drop/dropzone-element.cjs +32 -32
  12. package/drag-drop/dropzone-element.cjs.map +1 -0
  13. package/drag-drop/dropzone-element.js +6 -5
  14. package/drag-drop/dropzone-element.js.map +1 -1
  15. package/drag-drop/index.cjs +23 -11
  16. package/drag-drop/index.cjs.map +1 -0
  17. package/drag-drop/{drag-element.d.ts → index.d.cts} +73 -5
  18. package/drag-drop/index.d.ts +172 -6
  19. package/drag-drop/index.js +4 -5
  20. package/drag-drop/index.js.map +1 -1
  21. package/drag-drop/private-props.cjs +10 -6
  22. package/drag-drop/private-props.cjs.map +1 -0
  23. package/drag-drop/private-props.js +4 -3
  24. package/drag-drop/private-props.js.map +1 -1
  25. package/drag-drop/tha-drag-event.cjs +8 -6
  26. package/drag-drop/tha-drag-event.cjs.map +1 -0
  27. package/drag-drop/tha-drag-event.js +4 -2
  28. package/drag-drop/tha-drag-event.js.map +1 -1
  29. package/fesm/elements.mjs +1939 -0
  30. package/fesm/elements.mjs.map +1 -0
  31. package/icon/icon-element.cjs +136 -37
  32. package/icon/icon-element.cjs.map +1 -0
  33. package/icon/icon-element.js +105 -5
  34. package/icon/icon-element.js.map +1 -1
  35. package/icon/index.cjs +16 -5
  36. package/icon/index.cjs.map +1 -0
  37. package/icon/index.d.cts +89 -0
  38. package/icon/index.d.ts +89 -1
  39. package/icon/index.js +2 -2
  40. package/icon/index.js.map +1 -1
  41. package/icon/simple-icons-sprite.cjs +129 -0
  42. package/icon/simple-icons-sprite.cjs.map +1 -0
  43. package/icon/simple-icons-sprite.js +124 -0
  44. package/icon/simple-icons-sprite.js.map +1 -0
  45. package/iife/elements.js +180 -0
  46. package/iife/elements.js.map +1 -0
  47. package/index.cjs +53 -11
  48. package/index.cjs.map +1 -0
  49. package/index.d.cts +6 -0
  50. package/index.d.ts +6 -6
  51. package/index.js +10 -9
  52. package/index.js.map +1 -1
  53. package/package.json +41 -83
  54. package/router/history-managed.cjs +22 -18
  55. package/router/history-managed.cjs.map +1 -0
  56. package/router/history-managed.js +9 -7
  57. package/router/history-managed.js.map +1 -1
  58. package/router/history.cjs +20 -16
  59. package/router/history.cjs.map +1 -0
  60. package/router/history.js +8 -6
  61. package/router/history.js.map +1 -1
  62. package/router/index.cjs +36 -15
  63. package/router/index.cjs.map +1 -0
  64. package/router/index.d.cts +895 -0
  65. package/router/index.d.ts +895 -6
  66. package/router/index.js +6 -7
  67. package/router/index.js.map +1 -1
  68. package/router/signal-watcher-lit-element.cjs +9 -6
  69. package/router/signal-watcher-lit-element.cjs.map +1 -0
  70. package/router/signal-watcher-lit-element.js +5 -3
  71. package/router/signal-watcher-lit-element.js.map +1 -1
  72. package/router/tha-route.cjs +25 -22
  73. package/router/tha-route.cjs.map +1 -0
  74. package/router/tha-route.js +8 -7
  75. package/router/tha-route.js.map +1 -1
  76. package/router/tha-router-config.cjs +17 -17
  77. package/router/tha-router-config.cjs.map +1 -0
  78. package/router/tha-router-config.js +8 -7
  79. package/router/tha-router-config.js.map +1 -1
  80. package/router/tha-router-link.cjs +36 -36
  81. package/router/tha-router-link.cjs.map +1 -0
  82. package/router/tha-router-link.js +9 -8
  83. package/router/tha-router-link.js.map +1 -1
  84. package/router/tha-router-outlet.cjs +51 -48
  85. package/router/tha-router-outlet.cjs.map +1 -0
  86. package/router/tha-router-outlet.js +12 -11
  87. package/router/tha-router-outlet.js.map +1 -1
  88. package/router/tha-router-param.cjs +21 -21
  89. package/router/tha-router-param.cjs.map +1 -0
  90. package/router/tha-router-param.js +7 -6
  91. package/router/tha-router-param.js.map +1 -1
  92. package/router/tha-router.cjs +33 -33
  93. package/router/tha-router.cjs.map +1 -0
  94. package/router/tha-router.js +11 -10
  95. package/router/tha-router.js.map +1 -1
  96. package/bundle.js +0 -164
  97. package/bundle.mjs +0 -2630
  98. package/drag-drop/drag-handle-element.d.ts +0 -12
  99. package/drag-drop/dropzone-element.d.ts +0 -17
  100. package/drag-drop/private-props.d.ts +0 -3
  101. package/drag-drop/tha-drag-event.d.ts +0 -19
  102. package/icon/icon-element.d.ts +0 -40
  103. package/router/history-managed.d.ts +0 -76
  104. package/router/history.d.ts +0 -48
  105. package/router/signal-watcher-lit-element.d.ts +0 -25
  106. package/router/tha-route.d.ts +0 -90
  107. package/router/tha-router-config.d.ts +0 -223
  108. package/router/tha-router-link.d.ts +0 -95
  109. package/router/tha-router-outlet.d.ts +0 -112
  110. package/router/tha-router-param.d.ts +0 -226
  111. package/router/tha-router.d.ts +0 -69
  112. package/tha-url-output.cjs +0 -79
  113. package/tha-url-output.d.ts +0 -41
  114. package/tha-url-output.js +0 -78
  115. package/tha-url-output.js.map +0 -1
package/router/index.d.ts CHANGED
@@ -1,6 +1,895 @@
1
- export { ThaRouter } from './tha-router';
2
- export { ThaRoute } from './tha-route';
3
- export { ThaRouterLink } from './tha-router-link';
4
- export { ThaRouterOutlet } from './tha-router-outlet';
5
- export { ThaRouterConfig } from './tha-router-config';
6
- export { ThaRouterParam } from './tha-router-param';
1
+ import { LitElement } from 'lit';
2
+ import { Signal as Signal$1 } from '@lit-labs/signals';
3
+ import { History } from 'history';
4
+ import { URLPattern } from '@telperion/extra-ts-types/polyfills/url-pattern';
5
+
6
+ interface EffectOptions {
7
+ /**
8
+ * By default effects run after the element has updated. If `beforeUpdate`
9
+ * is set to `true`, the effect will run before the element updates.
10
+ */
11
+ beforeUpdate?: boolean;
12
+ /**
13
+ * By default, effects are automatically disposed when the element is
14
+ * disconnected. If `manualDispose` is set to `true`, the effect will not
15
+ * be automatically disposed, and you must call the returned function to
16
+ * dispose of the effect manually.
17
+ */
18
+ manualDispose?: boolean;
19
+ }
20
+ /**
21
+ * A LitElement base class extended with SignalWatcher capabilities.
22
+ *
23
+ * This class allows LitElement components to reactively watch for changes
24
+ */
25
+ declare const SignalWatcherLitElement: ({
26
+ new (): LitElement & {
27
+ updateEffect(fn: () => void, options?: EffectOptions): () => void;
28
+ };
29
+ });
30
+
31
+ /**
32
+ * Supported history types for the router.
33
+ *
34
+ * - `"browser"` - Uses the HTML5 History API (pushState, replaceState)
35
+ * - `"hash"` - Uses hash-based routing (#/path)
36
+ * - `"memory"` - In-memory history for testing or non-browser environments
37
+ * - `"memory:${string}"` - Named memory history instances for isolation
38
+ */
39
+ type HistoryType = "browser" | "hash" | "memory" | `memory:${string}`;
40
+
41
+ /**
42
+ * @fileoverview History management mixin for Lit elements
43
+ *
44
+ * Hierarchical resolution: own history → parent history → global history
45
+ *
46
+ * @module router/history-managed
47
+ */
48
+
49
+ /**
50
+ * Symbol for accessing the resolved history instance.
51
+ *
52
+ * @example
53
+ * ```typescript
54
+ * const history = this[HISTORY].get();
55
+ * history.push('/path');
56
+ * ```
57
+ */
58
+ declare const HISTORY: unique symbol;
59
+ /**
60
+ * Symbol for accessing the resolved history type.
61
+ * @internal
62
+ */
63
+ declare const HISTORY_TYPE: unique symbol;
64
+ /**
65
+ * Interface for elements with history management.
66
+ *
67
+ * Resolution order: own history → parent history → global history
68
+ */
69
+ interface HistoryManagedLitElementType extends Element {
70
+ /**
71
+ * History strategy: "browser" | "hash" | "memory" | "memory:name"
72
+ * If undefined, inherits from parent or uses global default.
73
+ */
74
+ history: HistoryType | undefined;
75
+ /**
76
+ * Computed signal with resolved history type.
77
+ * @internal
78
+ */
79
+ [HISTORY_TYPE]: Signal$1.Computed<HistoryType | undefined>;
80
+ /**
81
+ * Computed signal with resolved history instance.
82
+ * Access via: `this[HISTORY].get()`
83
+ * @internal
84
+ */
85
+ [HISTORY]: Signal$1.Computed<History>;
86
+ }
87
+
88
+ declare global {
89
+ interface HTMLElementTagNameMap {
90
+ /**
91
+ * A route definition element for client-side routing.
92
+ * It contains a template with the content to render when the route is active.
93
+ * The `path` attribute defines the URL pattern to match using URLPattern syntax.
94
+ * Must be a child of a tha-router element.
95
+ */
96
+ "tha-route": ThaRoute;
97
+ }
98
+ }
99
+ /**
100
+ * Symbol used to access the route's template fragment signal.
101
+ * @internal
102
+ */
103
+ declare const FRAGMENT: unique symbol;
104
+ /**
105
+ * Symbol used to access the route's URLPattern instance.
106
+ * @internal
107
+ */
108
+ declare const PATH_PATTERN: unique symbol;
109
+ /**
110
+ * A custom element that defines a route in the router.
111
+ *
112
+ * Each route contains a template element with the content to render when
113
+ * the route matches the current URL. The router watches for changes to
114
+ * the template content and automatically updates the outlet.
115
+ *
116
+ * The `path` attribute uses URLPattern syntax and supports:
117
+ * - Static paths: `/about`, `/users`
118
+ * - Dynamic segments: `/users/:id`, `/posts/:category/:slug`
119
+ * - Wildcards: `/blog/*`, `/docs/**`
120
+ *
121
+ * @example
122
+ * ```html
123
+ * <tha-router>
124
+ * <tha-route path="/">
125
+ * <template><h1>Home Page</h1></template>
126
+ * </tha-route>
127
+ * <tha-route path="/users/:id">
128
+ * <template><h1>User Profile</h1></template>
129
+ * </tha-route>
130
+ * <tha-router-outlet></tha-router-outlet>
131
+ * </tha-router>
132
+ * ```
133
+ */
134
+ declare class ThaRoute extends LitElement {
135
+ #private;
136
+ /**
137
+ * Signal containing weak reference to the template's DocumentFragment.
138
+ * Automatically updates when the template content changes.
139
+ * @internal
140
+ */
141
+ [FRAGMENT]: Signal.State<T>;
142
+ /**
143
+ * URLPattern instance for matching the current URL against this route's path.
144
+ * @internal
145
+ */
146
+ [PATH_PATTERN]: URLPattern | null;
147
+ /**
148
+ * The URL pattern to match for this route.
149
+ * Uses URLPattern syntax with support for dynamic segments and wildcards.
150
+ *
151
+ * @attr path
152
+ * @example "/users/:id"
153
+ * @example "/blog/*"
154
+ */
155
+ path: string | null;
156
+ /**
157
+ * Lifecycle callback when the element is connected to the DOM.
158
+ * Sets up observer to watch for template content changes.
159
+ */
160
+ connectedCallback(): void;
161
+ /**
162
+ * Lifecycle callback when an attribute changes.
163
+ * Updates the URLPattern when the path attribute changes.
164
+ *
165
+ * @param name - The attribute name that changed
166
+ * @param _old - The old attribute value
167
+ * @param value - The new attribute value
168
+ */
169
+ attributeChangedCallback(name: string, _old: string | null, value: string | null): void;
170
+ /**
171
+ * Lifecycle callback when the element is disconnected from the DOM.
172
+ * Cleans up the template observer.
173
+ */
174
+ disconnectedCallback(): void;
175
+ }
176
+
177
+ declare global {
178
+ interface HTMLElementTagNameMap {
179
+ /**
180
+ * An outlet element that renders the active route's content from a tha-router.
181
+ * It automatically binds to the nearest parent tha-router or to a specific router via the `for` attribute.
182
+ * The outlet clones and renders the template content from the active tha-route element.
183
+ * The `routePath` and `routeID` attributes reflect the current route's path and ID.
184
+ */
185
+ "tha-router-outlet": ThaRouterOutlet;
186
+ }
187
+ }
188
+ /**
189
+ * Symbol used by the router to call the internal render method on the outlet.
190
+ * @internal
191
+ */
192
+ declare const RENDER_ROUTE: unique symbol;
193
+ declare const PARAMS: unique symbol;
194
+ /**
195
+ * A custom element that serves as a rendering target for router content.
196
+ *
197
+ * The outlet automatically binds to its parent tha-router or to a specific router
198
+ * identified by the `for` attribute. When the router's active route changes,
199
+ * the outlet clones and renders the route's template content.
200
+ *
201
+ * @example
202
+ * ```html
203
+ * <tha-router>
204
+ * <tha-route path="/"><template><h1>Home</h1></template></tha-route>
205
+ * <tha-router-outlet></tha-router-outlet>
206
+ * </tha-router>
207
+ * ```
208
+ *
209
+ * @example
210
+ * ```html
211
+ * <!-- Bind to a specific router by ID -->
212
+ * <tha-router id="main-router">
213
+ * <tha-route path="/"><template><h1>Home</h1></template></tha-route>
214
+ * </tha-router>
215
+ * <tha-router-outlet for="main-router"></tha-router-outlet>
216
+ * ```
217
+ */
218
+ declare class ThaRouterOutlet extends SignalWatcherLitElement {
219
+ #private;
220
+ [PARAMS]: Signal.Computed<T>;
221
+ params: Record<string, string | undefined>;
222
+ /**
223
+ * The ID of a specific tha-router element to bind to.
224
+ * If not set, binds to the nearest parent tha-router.
225
+ *
226
+ * @attr for
227
+ */
228
+ for: string | null;
229
+ /**
230
+ * Reflects the path attribute of the currently active route.
231
+ * Automatically updated when the active route changes.
232
+ *
233
+ * @attr routepath
234
+ * @readonly
235
+ */
236
+ routePath: string | null;
237
+ /**
238
+ * Reflects the ID of the currently active route.
239
+ * Automatically updated when the active route changes.
240
+ *
241
+ * @attr routeid
242
+ * @readonly
243
+ */
244
+ routeID: string | undefined;
245
+ /**
246
+ * Lifecycle callback when the element is connected to the DOM.
247
+ * Initializes the outlet and binds to a router.
248
+ */
249
+ connectedCallback(): void;
250
+ /**
251
+ * Binds this outlet to a tha-router element.
252
+ *
253
+ * If no router is provided, automatically searches for one:
254
+ * - If `for` attribute is set, finds router by ID in the same root
255
+ * - Otherwise, finds the nearest parent tha-router
256
+ *
257
+ * Unbinds from the previous router if already bound to a different one.
258
+ *
259
+ * @param router - Optional router to bind to
260
+ * @returns The bound router, or null if no router found
261
+ */
262
+ bindToRouter(): ThaRouter | null;
263
+ /**
264
+ * Internal method called by the router to set the active route.
265
+ * Updates the routeToRender signal which triggers re-rendering.
266
+ *
267
+ * @param route - The route to render, or null to clear
268
+ * @internal
269
+ */
270
+ [RENDER_ROUTE](route: ThaRoute | null): void;
271
+ /**
272
+ * Lifecycle callback when the element is disconnected from the DOM.
273
+ * Unbinds from the router and cleans up effects.
274
+ */
275
+ disconnectedCallback(): void;
276
+ /**
277
+ * Creates the render root for the element.
278
+ * Returns the element itself to render content in light DOM.
279
+ *
280
+ * @returns The element itself (not a shadow root)
281
+ */
282
+ protected createRenderRoot(): this;
283
+ }
284
+
285
+ declare global {
286
+ interface HTMLElementTagNameMap {
287
+ /**
288
+ * A router element that manages client-side routing for single-page applications.
289
+ * It watches for navigation events and matches the current URL against registered routes
290
+ * (tha-route elements), rendering the matching route's content in a tha-router-outlet element.
291
+ * The `history` attribute specifies the history management strategy:
292
+ * - 'browser' for HTML5 History API (default)
293
+ * - 'hash' for hash-based routing
294
+ * - 'memory' for in-memory history (testing)
295
+ * - 'memory:name' for named memory history instances
296
+ */
297
+ "tha-router": ThaRouter;
298
+ }
299
+ }
300
+ declare const ThaRouter_base: (new (...args: any[]) => HistoryManagedLitElementType) & (new () => LitElement & {
301
+ updateEffect(fn: () => void, options?: EffectOptions): () => void;
302
+ });
303
+ /**
304
+ * A custom element that manages client-side routing for single-page applications.
305
+ *
306
+ * The router watches for navigation events and matches the current URL against
307
+ * registered routes (tha-route elements), rendering the matching route's content
308
+ * in a tha-router-outlet element.
309
+ *
310
+ * @example
311
+ * ```html
312
+ * <tha-router history="browser">
313
+ * <tha-route path="/">
314
+ * <template><h1>Home</h1></template>
315
+ * </tha-route>
316
+ * <tha-route path="/about">
317
+ * <template><h1>About</h1></template>
318
+ * </tha-route>
319
+ * <tha-router-outlet></tha-router-outlet>
320
+ * </tha-router>
321
+ * ```
322
+ */
323
+ declare class ThaRouter extends ThaRouter_base {
324
+ #private;
325
+ /**
326
+ * Lifecycle callback when the element is connected to the DOM.
327
+ * Sets up observers, effects, and history listeners.
328
+ */
329
+ connectedCallback(): void;
330
+ /**
331
+ * Assigns a router outlet to this router.
332
+ * The outlet will be used to render the active route's content.
333
+ *
334
+ * @param outlet - The outlet element to assign, or null to unassign
335
+ * @internal
336
+ */
337
+ assignOutlet(outlet: ThaRouterOutlet | null): void;
338
+ /**
339
+ * Lifecycle callback when the element is disconnected from the DOM.
340
+ * Cleans up all observers, effects, and listeners.
341
+ */
342
+ disconnectedCallback(): void;
343
+ /**
344
+ * Creates the render root for the element.
345
+ * Returns the element itself to render children in light DOM.
346
+ *
347
+ * @returns The element itself (not a shadow root)
348
+ */
349
+ protected createRenderRoot(): this;
350
+ }
351
+
352
+ declare global {
353
+ interface HTMLElementTagNameMap {
354
+ /**
355
+ * A navigation link element for client-side routing.
356
+ * It handles click events to navigate using the History API without full page reloads.
357
+ * The `to` attribute specifies the navigation target (absolute, relative, or 'back'/'forward').
358
+ * The `active` attribute reflects whether the link matches the current route.
359
+ * The `history` attribute specifies which history instance to use.
360
+ */
361
+ "tha-router-link": ThaRouterLink;
362
+ }
363
+ }
364
+ /** Navigation symbols for browser history operations */
365
+ type LinkSymbol = 'back' | 'forward';
366
+ /** Absolute path starting with / */
367
+ type AbsolutePath = '/' | `/${string}`;
368
+ /** Relative path starting with ./ or ../ */
369
+ type RelativePath = './' | `./${string}` | `../${string}`;
370
+ /** Union of all supported link types */
371
+ type LinkType = LinkSymbol | AbsolutePath | RelativePath;
372
+ declare const ThaRouterLink_base: (new (...args: any[]) => HistoryManagedLitElementType) & (new () => LitElement & {
373
+ updateEffect(fn: () => void, options?: EffectOptions): () => void;
374
+ });
375
+ /**
376
+ * A custom element that provides navigation links for client-side routing.
377
+ *
378
+ * The link handles click events to navigate using the History API, preventing
379
+ * full page reloads. It supports absolute paths, relative paths, and special
380
+ * symbols ('back', 'forward') for browser history navigation.
381
+ *
382
+ * The `active` attribute automatically reflects whether the link's path
383
+ * matches the current route, useful for styling active navigation items.
384
+ *
385
+ * @example
386
+ * ```html
387
+ * <!-- Absolute path -->
388
+ * <tha-router-link to="/about">About</tha-router-link>
389
+ *
390
+ * <!-- Relative path -->
391
+ * <tha-router-link to="./details">Details</tha-router-link>
392
+ * <tha-router-link to="../users">Back to Users</tha-router-link>
393
+ *
394
+ * <!-- History navigation -->
395
+ * <tha-router-link to="back">← Back</tha-router-link>
396
+ * <tha-router-link to="forward">Forward →</tha-router-link>
397
+ * ```
398
+ */
399
+ declare class ThaRouterLink extends ThaRouterLink_base {
400
+ #private;
401
+ /**
402
+ * The navigation target. Can be:
403
+ * - Absolute path: `/users`, `/about`
404
+ * - Relative path: `./details`, `../users`
405
+ * - History symbol: `back`, `forward`
406
+ *
407
+ * @attr to
408
+ */
409
+ to: LinkType | null;
410
+ /**
411
+ * Reflects whether this link matches the current route.
412
+ * Automatically updated when the route changes.
413
+ *
414
+ * @attr active
415
+ * @readonly
416
+ */
417
+ active: boolean;
418
+ /**
419
+ * Lifecycle callback when the element is connected to the DOM.
420
+ * Sets up click listener and active state tracking effect.
421
+ */
422
+ connectedCallback(): void;
423
+ /**
424
+ * Lifecycle callback when an attribute changes.
425
+ * Updates signals when history or to attributes change.
426
+ *
427
+ * @param name - The attribute name that changed
428
+ * @param _old - The old attribute value
429
+ * @param value - The new attribute value
430
+ */
431
+ attributeChangedCallback(name: string, _old: string | null, value: string | null): void;
432
+ /**
433
+ * Lifecycle callback when the element is disconnected from the DOM.
434
+ * Cleans up effects, listeners, and event handlers.
435
+ */
436
+ disconnectedCallback(): void;
437
+ /**
438
+ * Creates the render root for the element.
439
+ * Returns the element itself to render content in light DOM.
440
+ *
441
+ * @returns The element itself (not a shadow root)
442
+ */
443
+ protected createRenderRoot(): this;
444
+ }
445
+
446
+ declare global {
447
+ interface HTMLElementTagNameMap {
448
+ /**
449
+ * A configuration element for managing router history settings.
450
+ *
451
+ * Behavior depends on placement:
452
+ * - **In `<head>`**: Sets global history for all routers
453
+ * - **In `<body>`**: Provides local history for descendant routers
454
+ */
455
+ "tha-router-config": ThaRouterConfig;
456
+ }
457
+ }
458
+ declare const ThaRouterConfig_base: (new (...args: any[]) => HistoryManagedLitElementType) & (new () => LitElement & {
459
+ updateEffect(fn: () => void, options?: EffectOptions): () => void;
460
+ });
461
+ /**
462
+ * A custom element for configuring router history settings.
463
+ *
464
+ * This element serves dual purposes depending on its placement in the DOM:
465
+ *
466
+ * ## Global Configuration (placed in `<head>`)
467
+ *
468
+ * When placed in the `<head>` element, it sets the **global default history**
469
+ * for all routers in the application that don't specify their own history or
470
+ * inherit from a parent.
471
+ *
472
+ * ```html
473
+ * <head>
474
+ * <!-- All routers will use hash routing by default -->
475
+ * <tha-router-config history="hash"></tha-router-config>
476
+ * </head>
477
+ * <body>
478
+ * <tha-router>
479
+ * <!-- Uses hash history (global default) -->
480
+ * <tha-route path="/home">...</tha-route>
481
+ * </tha-router>
482
+ * </body>
483
+ * ```
484
+ *
485
+ * ## Local Configuration (placed in `<body>`)
486
+ *
487
+ * When placed in the `<body>` element, it provides history configuration
488
+ * for its **descendant routers only**. This allows different sections of
489
+ * your application to use different history strategies.
490
+ *
491
+ * ```html
492
+ * <body>
493
+ * <!-- Section 1: Hash routing -->
494
+ * <tha-router-config history="hash">
495
+ * <tha-router>
496
+ * <!-- Uses hash history from parent config -->
497
+ * <tha-route path="/dashboard">...</tha-route>
498
+ * </tha-router>
499
+ * </tha-router-config>
500
+ *
501
+ * <!-- Section 2: Memory routing (isolated) -->
502
+ * <tha-router-config history="memory">
503
+ * <tha-router>
504
+ * <!-- Uses memory history from parent config -->
505
+ * <tha-route path="/preview">...</tha-route>
506
+ * </tha-router>
507
+ * </tha-router-config>
508
+ * </body>
509
+ * ```
510
+ *
511
+ * ## Usage Patterns
512
+ *
513
+ * ### Set Global Default
514
+ *
515
+ * Place in `<head>` to configure all routers:
516
+ *
517
+ * ```html
518
+ * <!DOCTYPE html>
519
+ * <html>
520
+ * <head>
521
+ * <tha-router-config history="browser"></tha-router-config>
522
+ * </head>
523
+ * <body>
524
+ * <!-- All routers use browser history -->
525
+ * </body>
526
+ * </html>
527
+ * ```
528
+ *
529
+ * ### Override for Specific Section
530
+ *
531
+ * Use local config to override global default:
532
+ *
533
+ * ```html
534
+ * <head>
535
+ * <!-- Global: browser history -->
536
+ * <tha-router-config history="browser"></tha-router-config>
537
+ * </head>
538
+ * <body>
539
+ * <!-- Main app uses browser history -->
540
+ * <tha-router>...</tha-router>
541
+ *
542
+ * <!-- Admin section uses hash history -->
543
+ * <tha-router-config history="hash">
544
+ * <tha-router>...</tha-router>
545
+ * </tha-router-config>
546
+ * </body>
547
+ * ```
548
+ *
549
+ * ### Isolate Components with Memory History
550
+ *
551
+ * Use named memory history for component isolation:
552
+ *
553
+ * ```html
554
+ * <body>
555
+ * <!-- Each component has independent navigation -->
556
+ * <tha-router-config history="memory:component1">
557
+ * <my-widget>
558
+ * <tha-router>...</tha-router>
559
+ * </my-widget>
560
+ * </tha-router-config>
561
+ *
562
+ * <tha-router-config history="memory:component2">
563
+ * <my-widget>
564
+ * <tha-router>...</tha-router>
565
+ * </my-widget>
566
+ * </tha-router-config>
567
+ * </body>
568
+ * ```
569
+ *
570
+ * ### Testing with Memory History
571
+ *
572
+ * Use memory history to avoid affecting browser URL during tests:
573
+ *
574
+ * ```typescript
575
+ * import { fixture, html } from '@open-wc/testing';
576
+ *
577
+ * it('should navigate', async () => {
578
+ * const el = await fixture(html`
579
+ * <tha-router-config history="memory:test">
580
+ * <tha-router>
581
+ * <tha-route path="/test">Test Page</tha-route>
582
+ * </tha-router>
583
+ * </tha-router-config>
584
+ * `);
585
+ *
586
+ * // Test navigation without affecting browser URL
587
+ * });
588
+ * ```
589
+ *
590
+ * ## History Resolution
591
+ *
592
+ * Router components resolve their history in this order:
593
+ *
594
+ * 1. **Own `history` attribute** (highest priority)
595
+ * 2. **Parent `tha-router-config`** (local configuration)
596
+ * 3. **Global `tha-router-config`** (in `<head>`)
597
+ * 4. **Default** (`"browser"`)
598
+ *
599
+ * ## Best Practices
600
+ *
601
+ * ✅ **DO**: Place one `tha-router-config` in `<head>` for global settings
602
+ *
603
+ * ```html
604
+ * <head>
605
+ * <tha-router-config history="browser"></tha-router-config>
606
+ * </head>
607
+ * ```
608
+ *
609
+ * ✅ **DO**: Use local configs for sections with different routing needs
610
+ *
611
+ * ```html
612
+ * <tha-router-config history="memory">
613
+ * <component-preview>...</component-preview>
614
+ * </tha-router-config>
615
+ * ```
616
+ *
617
+ * ✅ **DO**: Use named memory history for isolated components
618
+ *
619
+ * ```html
620
+ * <tha-router-config history="memory:sidebar">
621
+ * <sidebar-nav>...</sidebar-nav>
622
+ * </tha-router-config>
623
+ * ```
624
+ *
625
+ * ❌ **DON'T**: Place multiple configs in `<head>` (last one wins)
626
+ *
627
+ * ```html
628
+ * <head>
629
+ * <tha-router-config history="browser"></tha-router-config>
630
+ * <tha-router-config history="hash"></tha-router-config> <!-- Overrides above -->
631
+ * </head>
632
+ * ```
633
+ *
634
+ * ❌ **DON'T**: Nest configs unnecessarily (inner configs take precedence)
635
+ *
636
+ * ```html
637
+ * <tha-router-config history="browser">
638
+ * <tha-router-config history="hash">
639
+ * <!-- Uses hash, not browser -->
640
+ * </tha-router-config>
641
+ * </tha-router-config>
642
+ * ```
643
+ */
644
+ declare class ThaRouterConfig extends ThaRouterConfig_base {
645
+ #private;
646
+ /**
647
+ * Called when the element is connected to the DOM.
648
+ *
649
+ * - If in `<head>`: Sets up a reactive effect to update global history
650
+ * - If in `<body>`: Only provides history to descendants (no special setup)
651
+ */
652
+ connectedCallback(): void;
653
+ /**
654
+ * Called when the element is disconnected from the DOM.
655
+ *
656
+ * Cleans up the global history effect if it was set up.
657
+ */
658
+ disconnectedCallback(): void;
659
+ /**
660
+ * Creates the render root for the element.
661
+ * Returns the element itself to render children in light DOM.
662
+ *
663
+ * @returns The element itself (not a shadow root)
664
+ */
665
+ protected createRenderRoot(): this;
666
+ }
667
+
668
+ /**
669
+ * @fileoverview Router parameter display component
670
+ *
671
+ * Provides a declarative way to display dynamic route parameter values
672
+ * directly in HTML templates without requiring JavaScript.
673
+ *
674
+ * @module router/tha-router-param
675
+ */
676
+
677
+ declare global {
678
+ interface HTMLElementTagNameMap {
679
+ /**
680
+ * A component that displays the value of a route parameter.
681
+ *
682
+ * Must be used within a tha-router-outlet element. Automatically
683
+ * updates when route parameters change.
684
+ */
685
+ 'tha-router-param': ThaRouterParam;
686
+ }
687
+ }
688
+ /**
689
+ * Custom element for displaying dynamic route parameter values.
690
+ *
691
+ * This component provides a declarative way to access and display URL
692
+ * parameters extracted from dynamic route segments without writing JavaScript.
693
+ * It must be used inside a `<tha-router-outlet>` element.
694
+ *
695
+ * ## Features
696
+ *
697
+ * - **Declarative**: Access params directly in HTML
698
+ * - **Reactive**: Automatically updates when route changes
699
+ * - **Hierarchical**: Inherits params from parent outlets
700
+ * - **Type-safe**: Integrated with TypeScript definitions
701
+ *
702
+ * ## Usage
703
+ *
704
+ * ### Basic Parameter Display
705
+ *
706
+ * ```html
707
+ * <tha-router>
708
+ * <tha-route path="/users/:id">
709
+ * <template>
710
+ * <h1>User Profile</h1>
711
+ * <p>User ID: <tha-router-param name="id"></tha-router-param></p>
712
+ * </template>
713
+ * </tha-route>
714
+ * <tha-router-outlet></tha-router-outlet>
715
+ * </tha-router>
716
+ * ```
717
+ *
718
+ * When navigating to `/users/123`, the component renders: `User ID: 123`
719
+ *
720
+ * ### Multiple Parameters
721
+ *
722
+ * ```html
723
+ * <tha-route path="/blog/:year/:month/:slug">
724
+ * <template>
725
+ * <article>
726
+ * <header>
727
+ * <time>
728
+ * <tha-router-param name="year"></tha-router-param>-
729
+ * <tha-router-param name="month"></tha-router-param>
730
+ * </time>
731
+ * <h1><tha-router-param name="slug"></tha-router-param></h1>
732
+ * </header>
733
+ * </article>
734
+ * </template>
735
+ * </tha-route>
736
+ * ```
737
+ *
738
+ * For `/blog/2024/12/hello-world`, renders:
739
+ * ```html
740
+ * <time>2024-12</time>
741
+ * <h1>hello-world</h1>
742
+ * ```
743
+ *
744
+ * ### Nested Routes with Parameter Inheritance
745
+ *
746
+ * ```html
747
+ * <tha-router>
748
+ * <tha-route path="/projects/:projectId">
749
+ * <template>
750
+ * <h1>Project <tha-router-param name="projectId"></tha-router-param></h1>
751
+ *
752
+ * <!-- Nested outlet inherits projectId parameter -->
753
+ * <tha-router-outlet>
754
+ * <tha-route path="/tasks/:taskId">
755
+ * <template>
756
+ * <!-- Both params are available -->
757
+ * <h2>Task Details</h2>
758
+ * <p>Project: <tha-router-param name="projectId"></tha-router-param></p>
759
+ * <p>Task: <tha-router-param name="taskId"></tha-router-param></p>
760
+ * </template>
761
+ * </tha-route>
762
+ * </tha-router-outlet>
763
+ * </template>
764
+ * </tha-route>
765
+ * <tha-router-outlet></tha-router-outlet>
766
+ * </tha-router>
767
+ * ```
768
+ *
769
+ * ### With Styling
770
+ *
771
+ * ```html
772
+ * <style>
773
+ * tha-router-param {
774
+ * font-weight: bold;
775
+ * color: var(--primary-color);
776
+ * }
777
+ *
778
+ * tha-router-param[name="id"] {
779
+ * font-family: monospace;
780
+ * }
781
+ * </style>
782
+ *
783
+ * <tha-route path="/users/:id">
784
+ * <template>
785
+ * <span>User: <tha-router-param name="id"></tha-router-param></span>
786
+ * </template>
787
+ * </tha-route>
788
+ * ```
789
+ *
790
+ * ## How It Works
791
+ *
792
+ * 1. On connection, finds the nearest parent `<tha-router-outlet>`
793
+ * 2. Accesses the outlet's PARAMS signal containing all route parameters
794
+ * 3. Computes and displays the value for the specified parameter name
795
+ * 4. Automatically re-renders when the route (and thus params) change
796
+ *
797
+ * ## Error Handling
798
+ *
799
+ * Throws an error if not placed within a `<tha-router-outlet>`:
800
+ *
801
+ * ```javascript
802
+ * // ✗ Wrong - not inside outlet
803
+ * <tha-router-param name="id"></tha-router-param>
804
+ *
805
+ * // ✓ Correct - inside outlet
806
+ * <tha-router-outlet>
807
+ * <tha-router-param name="id"></tha-router-param>
808
+ * </tha-router-outlet>
809
+ * ```
810
+ *
811
+ * ## Alternative: Using Attributes
812
+ *
813
+ * The parent `<tha-router-outlet>` also exposes parameters as `param-*` attributes,
814
+ * which can be used as an alternative approach:
815
+ *
816
+ * ```html
817
+ * <tha-router-outlet id="outlet">
818
+ * <script>
819
+ * const outlet = document.getElementById('outlet');
820
+ * // Params available as: outlet.getAttribute('param-id')
821
+ * </script>
822
+ * </tha-router-outlet>
823
+ * ```
824
+ *
825
+ * However, `<tha-router-param>` is preferred for declarative templates.
826
+ *
827
+ * @example Basic usage
828
+ * ```html
829
+ * <tha-router>
830
+ * <tha-route path="/product/:sku">
831
+ * <template>
832
+ * <h1>Product: <tha-router-param name="sku"></tha-router-param></h1>
833
+ * </template>
834
+ * </tha-route>
835
+ * <tha-router-outlet></tha-router-outlet>
836
+ * </tha-router>
837
+ * ```
838
+ *
839
+ * @example Multiple params with formatting
840
+ * ```html
841
+ * <tha-route path="/user/:username/post/:postId">
842
+ * <template>
843
+ * <article>
844
+ * <p>@<tha-router-param name="username"></tha-router-param></p>
845
+ * <p>Post #<tha-router-param name="postId"></tha-router-param></p>
846
+ * </article>
847
+ * </template>
848
+ * </tha-route>
849
+ * ```
850
+ */
851
+ declare class ThaRouterParam extends SignalWatcherLitElement {
852
+ #private;
853
+ /**
854
+ * The name of the route parameter to display.
855
+ *
856
+ * Must match a parameter name defined in the route's path pattern.
857
+ * For example, for path `/users/:id`, use `name="id"`.
858
+ *
859
+ * @attr name
860
+ * @type {string}
861
+ */
862
+ name: string;
863
+ /**
864
+ * Lifecycle callback when element is connected to the DOM.
865
+ *
866
+ * Finds the parent `<tha-router-outlet>` and stores a reference.
867
+ * Throws an error if not used within an outlet.
868
+ *
869
+ * @throws {Error} If no parent tha-router-outlet is found
870
+ */
871
+ connectedCallback(): void;
872
+ /**
873
+ * Lifecycle callback when observed attributes change.
874
+ *
875
+ * Updates the internal name signal when the 'name' attribute changes,
876
+ * which triggers the computed value signal to recalculate and re-render.
877
+ *
878
+ * @param name - The attribute name that changed
879
+ * @param _old - Previous attribute value (unused)
880
+ * @param value - New attribute value
881
+ */
882
+ attributeChangedCallback(name: string, _old: string | null, value: string | null): void;
883
+ /**
884
+ * Renders the parameter value.
885
+ *
886
+ * The value is extracted from the outlet's params signal and
887
+ * displayed as text content. Automatically updates when the
888
+ * route changes.
889
+ *
890
+ * @returns The parameter value as a template result
891
+ */
892
+ protected render(): TemplateResult;
893
+ }
894
+
895
+ export { ThaRoute, ThaRouter, ThaRouterConfig, ThaRouterLink, ThaRouterOutlet, ThaRouterParam };