@telperion/elements 7.0.0 → 8.0.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.
- package/.build-manifest.json +12 -1
- package/README.md +36 -5
- package/custom-elements.json +4182 -2038
- package/date/date-element.cjs +231 -0
- package/date/date-element.cjs.map +1 -0
- package/date/date-element.js +229 -0
- package/date/date-element.js.map +1 -0
- package/date/format-pattern.cjs +49 -0
- package/date/format-pattern.cjs.map +1 -0
- package/date/format-pattern.js +47 -0
- package/date/format-pattern.js.map +1 -0
- package/date/format.cjs +57 -0
- package/date/format.cjs.map +1 -0
- package/date/format.js +51 -0
- package/date/format.js.map +1 -0
- package/date/index.cjs +17 -0
- package/date/index.cjs.map +1 -0
- package/date/index.d.cts +171 -0
- package/date/index.d.ts +171 -0
- package/date/index.js +6 -0
- package/date/index.js.map +1 -0
- package/date/intl.cjs +36 -0
- package/date/intl.cjs.map +1 -0
- package/date/intl.js +32 -0
- package/date/intl.js.map +1 -0
- package/date/locale.cjs +36 -0
- package/date/locale.cjs.map +1 -0
- package/date/locale.js +34 -0
- package/date/locale.js.map +1 -0
- package/date/names.cjs +41 -0
- package/date/names.cjs.map +1 -0
- package/date/names.js +37 -0
- package/date/names.js.map +1 -0
- package/date/parse-fields.cjs +80 -0
- package/date/parse-fields.cjs.map +1 -0
- package/date/parse-fields.js +75 -0
- package/date/parse-fields.js.map +1 -0
- package/date/parse-iso.cjs +41 -0
- package/date/parse-iso.cjs.map +1 -0
- package/date/parse-iso.js +39 -0
- package/date/parse-iso.js.map +1 -0
- package/date/parse-numeric.cjs +53 -0
- package/date/parse-numeric.cjs.map +1 -0
- package/date/parse-numeric.js +50 -0
- package/date/parse-numeric.js.map +1 -0
- package/date/parse-pattern.cjs +123 -0
- package/date/parse-pattern.cjs.map +1 -0
- package/date/parse-pattern.js +121 -0
- package/date/parse-pattern.js.map +1 -0
- package/date/parse.cjs +35 -0
- package/date/parse.cjs.map +1 -0
- package/date/parse.js +33 -0
- package/date/parse.js.map +1 -0
- package/date/relative.cjs +47 -0
- package/date/relative.cjs.map +1 -0
- package/date/relative.js +44 -0
- package/date/relative.js.map +1 -0
- package/date/resolution.cjs +62 -0
- package/date/resolution.cjs.map +1 -0
- package/date/resolution.js +59 -0
- package/date/resolution.js.map +1 -0
- package/date/styles.cjs +21 -0
- package/date/styles.cjs.map +1 -0
- package/date/styles.js +19 -0
- package/date/styles.js.map +1 -0
- package/date/ticker.cjs +71 -0
- package/date/ticker.cjs.map +1 -0
- package/date/ticker.js +69 -0
- package/date/ticker.js.map +1 -0
- package/date/tokens.cjs +94 -0
- package/date/tokens.cjs.map +1 -0
- package/date/tokens.js +91 -0
- package/date/tokens.js.map +1 -0
- package/date/zone.cjs +110 -0
- package/date/zone.cjs.map +1 -0
- package/date/zone.js +101 -0
- package/date/zone.js.map +1 -0
- package/fesm/elements.mjs +1553 -217
- package/fesm/elements.mjs.map +1 -1
- package/iife/date/index.js +53 -0
- package/iife/date/index.js.map +1 -0
- package/iife/elements.js +59 -41
- package/iife/elements.js.map +1 -1
- package/iife/router/index.js +23 -23
- package/iife/router/index.js.map +1 -1
- package/index.cjs +34 -18
- package/index.cjs.map +1 -1
- package/index.d.cts +2 -1
- package/index.d.ts +2 -1
- package/index.js +13 -6
- package/index.js.map +1 -1
- package/package.json +31 -3
- package/router/history-managed.cjs +1 -1
- package/router/history-managed.cjs.map +1 -1
- package/router/history-managed.js +1 -1
- package/router/history-managed.js.map +1 -1
- package/router/index.cjs +23 -18
- package/router/index.cjs.map +1 -1
- package/router/index.d.cts +273 -168
- package/router/index.d.ts +273 -168
- package/router/index.js +8 -6
- package/router/index.js.map +1 -1
- package/router/route-element.cjs +244 -0
- package/router/route-element.cjs.map +1 -0
- package/router/route-element.js +239 -0
- package/router/route-element.js.map +1 -0
- package/router/route-events.cjs +14 -0
- package/router/route-events.cjs.map +1 -0
- package/router/route-events.js +10 -0
- package/router/route-events.js.map +1 -0
- package/router/route-source.cjs +134 -0
- package/router/route-source.cjs.map +1 -0
- package/router/route-source.js +129 -0
- package/router/route-source.js.map +1 -0
- package/router/route-templates.cjs +18 -0
- package/router/route-templates.cjs.map +1 -0
- package/router/route-templates.js +16 -0
- package/router/route-templates.js.map +1 -0
- package/router/{tha-router-config.cjs → router-config-element.cjs} +51 -51
- package/router/router-config-element.cjs.map +1 -0
- package/router/{tha-router-config.js → router-config-element.js} +52 -52
- package/router/router-config-element.js.map +1 -0
- package/router/{tha-router.cjs → router-element.cjs} +47 -33
- package/router/router-element.cjs.map +1 -0
- package/router/{tha-router.js → router-element.js} +47 -33
- package/router/router-element.js.map +1 -0
- package/router/{tha-router-link.cjs → router-link-element.cjs} +15 -15
- package/router/router-link-element.cjs.map +1 -0
- package/router/{tha-router-link.js → router-link-element.js} +16 -16
- package/router/router-link-element.js.map +1 -0
- package/router/{tha-router-outlet.cjs → router-outlet-element.cjs} +44 -31
- package/router/router-outlet-element.cjs.map +1 -0
- package/router/{tha-router-outlet.js → router-outlet-element.js} +43 -30
- package/router/router-outlet-element.js.map +1 -0
- package/router/{tha-router-param.cjs → router-param-element.cjs} +62 -62
- package/router/router-param-element.cjs.map +1 -0
- package/router/{tha-router-param.js → router-param-element.js} +62 -62
- package/router/router-param-element.js.map +1 -0
- package/router/tha-route.cjs +0 -128
- package/router/tha-route.cjs.map +0 -1
- package/router/tha-route.js +0 -125
- package/router/tha-route.js.map +0 -1
- package/router/tha-router-config.cjs.map +0 -1
- package/router/tha-router-config.js.map +0 -1
- package/router/tha-router-link.cjs.map +0 -1
- package/router/tha-router-link.js.map +0 -1
- package/router/tha-router-outlet.cjs.map +0 -1
- package/router/tha-router-outlet.js.map +0 -1
- package/router/tha-router-param.cjs.map +0 -1
- package/router/tha-router-param.js.map +0 -1
- package/router/tha-router.cjs.map +0 -1
- package/router/tha-router.js.map +0 -1
package/router/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { S as SignalWatcherLitElement, E as EffectOptions } from '../_chunks/signal-watcher-lit-element-B-vV0yNG.js';
|
|
2
2
|
import { Signal as Signal$1 } from '@lit-labs/signals';
|
|
3
3
|
import { History } from 'history';
|
|
4
|
-
import { LitElement } from 'lit';
|
|
4
|
+
import { LitElement, PropertyValues } from 'lit';
|
|
5
5
|
import { URLPattern } from '@telperion/extra-ts-types/polyfills/url-pattern';
|
|
6
6
|
import '../_chunks/shade-mixer-lit-element-sw8t_VC5.js';
|
|
7
7
|
|
|
@@ -62,19 +62,43 @@ interface HistoryManagedLitElementType extends Element {
|
|
|
62
62
|
[HISTORY]: Signal$1.Computed<History>;
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
+
/**
|
|
66
|
+
* Fetches the raw HTML of a route's `src`.
|
|
67
|
+
*
|
|
68
|
+
* Must reject on failure (network error, non-2xx status, …) and should honour
|
|
69
|
+
* `signal` so superseded requests can be cancelled.
|
|
70
|
+
*/
|
|
71
|
+
type RouteSourceLoader = (url: string, signal: AbortSignal) => Promise<string>;
|
|
72
|
+
/**
|
|
73
|
+
* Lifecycle of a route's remote content.
|
|
74
|
+
*
|
|
75
|
+
* - `none`: the route has no `src`; its inline `<template>` is used.
|
|
76
|
+
* - `idle`: a `src` is set but has not been requested yet.
|
|
77
|
+
* - `loading`: the request is in flight.
|
|
78
|
+
* - `loaded`: the content was fetched and parsed.
|
|
79
|
+
* - `error`: the last request failed; the next activation retries.
|
|
80
|
+
*/
|
|
81
|
+
type RouteSourceStatus = "none" | "idle" | "loading" | "loaded" | "error";
|
|
82
|
+
/**
|
|
83
|
+
* Default {@link RouteSourceLoader}: a plain `fetch` that rejects on non-2xx
|
|
84
|
+
* responses.
|
|
85
|
+
*/
|
|
86
|
+
declare const defaultRouteSourceLoader: RouteSourceLoader;
|
|
87
|
+
|
|
65
88
|
declare global {
|
|
66
89
|
interface HTMLElementTagNameMap {
|
|
67
90
|
/**
|
|
68
91
|
* A route definition element for client-side routing.
|
|
69
|
-
* It contains a template with the content to render when the route is active
|
|
92
|
+
* It contains a template with the content to render when the route is active,
|
|
93
|
+
* or a `src` URL to load the content from when the route first becomes active.
|
|
70
94
|
* The `path` attribute defines the URL pattern to match using URLPattern syntax.
|
|
71
|
-
* Must be a child of a
|
|
95
|
+
* Must be a child of a tp-router element.
|
|
72
96
|
*/
|
|
73
|
-
"
|
|
97
|
+
"tp-route": RouteElement;
|
|
74
98
|
}
|
|
75
99
|
}
|
|
76
100
|
/**
|
|
77
|
-
* Symbol used to access the route's
|
|
101
|
+
* Symbol used to access the route's content fragment signal.
|
|
78
102
|
* @internal
|
|
79
103
|
*/
|
|
80
104
|
declare const FRAGMENT: unique symbol;
|
|
@@ -83,39 +107,66 @@ declare const FRAGMENT: unique symbol;
|
|
|
83
107
|
* @internal
|
|
84
108
|
*/
|
|
85
109
|
declare const PATH_PATTERN: unique symbol;
|
|
110
|
+
/**
|
|
111
|
+
* Symbol used to access the status signal of the route's `src` content.
|
|
112
|
+
* @internal
|
|
113
|
+
*/
|
|
114
|
+
declare const SOURCE_STATUS: unique symbol;
|
|
115
|
+
/**
|
|
116
|
+
* Symbol used by the router to mark the route as active or inactive.
|
|
117
|
+
* @internal
|
|
118
|
+
*/
|
|
119
|
+
declare const SET_ACTIVE: unique symbol;
|
|
86
120
|
/**
|
|
87
121
|
* A custom element that defines a route in the router.
|
|
88
122
|
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
123
|
+
* The route's content comes from either:
|
|
124
|
+
* - an inline `<template>` child, or
|
|
125
|
+
* - a `src` URL, fetched the first time the route becomes active and cached
|
|
126
|
+
* until `src` changes. Optional `<template data-loading>` and
|
|
127
|
+
* `<template data-error>` children are rendered while loading and on failure.
|
|
92
128
|
*
|
|
93
129
|
* The `path` attribute uses URLPattern syntax and supports:
|
|
94
130
|
* - Static paths: `/about`, `/users`
|
|
95
131
|
* - Dynamic segments: `/users/:id`, `/posts/:category/:slug`
|
|
96
132
|
* - Wildcards: `/blog/*`, `/docs/**`
|
|
97
133
|
*
|
|
134
|
+
* While a `src` is involved, the route reflects its status as one of the
|
|
135
|
+
* boolean attributes `loading`, `loaded` or `error`.
|
|
136
|
+
*
|
|
137
|
+
* @fires tp-route-load - The `src` content has loaded. `detail: { src }`
|
|
138
|
+
* @fires tp-route-error - The `src` content failed to load. `detail: { src, error }`
|
|
139
|
+
*
|
|
98
140
|
* @example
|
|
99
141
|
* ```html
|
|
100
|
-
* <
|
|
101
|
-
* <
|
|
142
|
+
* <tp-router>
|
|
143
|
+
* <tp-route path="/">
|
|
102
144
|
* <template><h1>Home Page</h1></template>
|
|
103
|
-
* </
|
|
104
|
-
* <
|
|
105
|
-
* <template><
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
145
|
+
* </tp-route>
|
|
146
|
+
* <tp-route path="/docs/:slug" src="/partials/docs.html">
|
|
147
|
+
* <template data-loading><p>Loading…</p></template>
|
|
148
|
+
* <template data-error><p>Could not load the docs.</p></template>
|
|
149
|
+
* </tp-route>
|
|
150
|
+
* <tp-router-outlet></tp-router-outlet>
|
|
151
|
+
* </tp-router>
|
|
109
152
|
* ```
|
|
110
153
|
*/
|
|
111
|
-
declare class
|
|
154
|
+
declare class RouteElement extends LitElement {
|
|
112
155
|
#private;
|
|
113
156
|
/**
|
|
114
|
-
* Signal
|
|
115
|
-
*
|
|
157
|
+
* Signal with the fragment to render for this route:
|
|
158
|
+
* - no `src`: the inline template's content
|
|
159
|
+
* - `src` loaded: the fetched content
|
|
160
|
+
* - `src` failed: the `data-error` template's content
|
|
161
|
+
* - otherwise: the `data-loading` template's content
|
|
162
|
+
* @internal
|
|
163
|
+
*/
|
|
164
|
+
[FRAGMENT]: Signal.Computed<T>;
|
|
165
|
+
/**
|
|
166
|
+
* Signal with the status of the route's `src` content.
|
|
116
167
|
* @internal
|
|
117
168
|
*/
|
|
118
|
-
[
|
|
169
|
+
[SOURCE_STATUS]: Signal.Computed<T>;
|
|
119
170
|
/**
|
|
120
171
|
* URLPattern instance for matching the current URL against this route's path.
|
|
121
172
|
* @internal
|
|
@@ -130,6 +181,24 @@ declare class ThaRoute extends LitElement {
|
|
|
130
181
|
* @example "/blog/*"
|
|
131
182
|
*/
|
|
132
183
|
path: string | null;
|
|
184
|
+
/**
|
|
185
|
+
* URL of an HTML file to use as the route's content, resolved against
|
|
186
|
+
* `document.baseURI`. Fetched the first time the route becomes active and
|
|
187
|
+
* cached until it changes. Takes precedence over the inline `<template>`.
|
|
188
|
+
*
|
|
189
|
+
* The fetched HTML is trusted like `innerHTML`: it is inserted as-is,
|
|
190
|
+
* although its `<script>` elements do not run.
|
|
191
|
+
*
|
|
192
|
+
* @attr src
|
|
193
|
+
* @example "/partials/about.html"
|
|
194
|
+
*/
|
|
195
|
+
src: string | null;
|
|
196
|
+
/**
|
|
197
|
+
* Function that fetches the `src` content. Override it to add headers,
|
|
198
|
+
* credentials or caching, or to stub requests in tests. It receives the
|
|
199
|
+
* absolute URL and an `AbortSignal`, and must reject on failure.
|
|
200
|
+
*/
|
|
201
|
+
loader: RouteSourceLoader;
|
|
133
202
|
/**
|
|
134
203
|
* Lifecycle callback when the element is connected to the DOM.
|
|
135
204
|
* Sets up observer to watch for template content changes.
|
|
@@ -137,16 +206,29 @@ declare class ThaRoute extends LitElement {
|
|
|
137
206
|
connectedCallback(): void;
|
|
138
207
|
/**
|
|
139
208
|
* Lifecycle callback when an attribute changes.
|
|
140
|
-
* Updates the URLPattern when the path attribute changes
|
|
209
|
+
* Updates the URLPattern when the path attribute changes, and the content
|
|
210
|
+
* source when the src attribute changes.
|
|
141
211
|
*
|
|
142
212
|
* @param name - The attribute name that changed
|
|
143
213
|
* @param _old - The old attribute value
|
|
144
214
|
* @param value - The new attribute value
|
|
145
215
|
*/
|
|
146
216
|
attributeChangedCallback(name: string, _old: string | null, value: string | null): void;
|
|
217
|
+
/**
|
|
218
|
+
* Picks up `src` changes made through the property. Loads the new content
|
|
219
|
+
* right away when the route is active.
|
|
220
|
+
*/
|
|
221
|
+
protected willUpdate(changed: PropertyValues<this>): void;
|
|
222
|
+
/**
|
|
223
|
+
* Called by the router when this route starts or stops matching.
|
|
224
|
+
* Activating a route with a `src` loads its content unless already cached.
|
|
225
|
+
*
|
|
226
|
+
* @internal
|
|
227
|
+
*/
|
|
228
|
+
[SET_ACTIVE](active: boolean): void;
|
|
147
229
|
/**
|
|
148
230
|
* Lifecycle callback when the element is disconnected from the DOM.
|
|
149
|
-
* Cleans up the template observer.
|
|
231
|
+
* Cleans up the template observer and cancels any in-flight request.
|
|
150
232
|
*/
|
|
151
233
|
disconnectedCallback(): void;
|
|
152
234
|
}
|
|
@@ -154,12 +236,12 @@ declare class ThaRoute extends LitElement {
|
|
|
154
236
|
declare global {
|
|
155
237
|
interface HTMLElementTagNameMap {
|
|
156
238
|
/**
|
|
157
|
-
* An outlet element that renders the active route's content from a
|
|
158
|
-
* It automatically binds to the nearest parent
|
|
159
|
-
* The outlet clones and renders the template content from the active
|
|
239
|
+
* An outlet element that renders the active route's content from a tp-router.
|
|
240
|
+
* It automatically binds to the nearest parent tp-router or to a specific router via the `for` attribute.
|
|
241
|
+
* The outlet clones and renders the template content from the active tp-route element.
|
|
160
242
|
* The `routePath` and `routeID` attributes reflect the current route's path and ID.
|
|
161
243
|
*/
|
|
162
|
-
"
|
|
244
|
+
"tp-router-outlet": RouterOutletElement;
|
|
163
245
|
}
|
|
164
246
|
}
|
|
165
247
|
/**
|
|
@@ -171,34 +253,37 @@ declare const PARAMS: unique symbol;
|
|
|
171
253
|
/**
|
|
172
254
|
* A custom element that serves as a rendering target for router content.
|
|
173
255
|
*
|
|
174
|
-
* The outlet automatically binds to its parent
|
|
256
|
+
* The outlet automatically binds to its parent tp-router or to a specific router
|
|
175
257
|
* identified by the `for` attribute. When the router's active route changes,
|
|
176
258
|
* the outlet clones and renders the route's template content.
|
|
177
259
|
*
|
|
260
|
+
* While the active route's `src` content is pending, the outlet has the
|
|
261
|
+
* `route-loading` attribute; when it failed, the `route-error` attribute.
|
|
262
|
+
*
|
|
178
263
|
* @example
|
|
179
264
|
* ```html
|
|
180
|
-
* <
|
|
181
|
-
* <
|
|
182
|
-
* <
|
|
183
|
-
* </
|
|
265
|
+
* <tp-router>
|
|
266
|
+
* <tp-route path="/"><template><h1>Home</h1></template></tp-route>
|
|
267
|
+
* <tp-router-outlet></tp-router-outlet>
|
|
268
|
+
* </tp-router>
|
|
184
269
|
* ```
|
|
185
270
|
*
|
|
186
271
|
* @example
|
|
187
272
|
* ```html
|
|
188
273
|
* <!-- Bind to a specific router by ID -->
|
|
189
|
-
* <
|
|
190
|
-
* <
|
|
191
|
-
* </
|
|
192
|
-
* <
|
|
274
|
+
* <tp-router id="main-router">
|
|
275
|
+
* <tp-route path="/"><template><h1>Home</h1></template></tp-route>
|
|
276
|
+
* </tp-router>
|
|
277
|
+
* <tp-router-outlet for="main-router"></tp-router-outlet>
|
|
193
278
|
* ```
|
|
194
279
|
*/
|
|
195
|
-
declare class
|
|
280
|
+
declare class RouterOutletElement extends SignalWatcherLitElement {
|
|
196
281
|
#private;
|
|
197
282
|
[PARAMS]: Signal.Computed<T>;
|
|
198
283
|
params: Record<string, string | undefined>;
|
|
199
284
|
/**
|
|
200
|
-
* The ID of a specific
|
|
201
|
-
* If not set, binds to the nearest parent
|
|
285
|
+
* The ID of a specific tp-router element to bind to.
|
|
286
|
+
* If not set, binds to the nearest parent tp-router.
|
|
202
287
|
*
|
|
203
288
|
* @attr for
|
|
204
289
|
*/
|
|
@@ -225,18 +310,18 @@ declare class ThaRouterOutlet extends SignalWatcherLitElement {
|
|
|
225
310
|
*/
|
|
226
311
|
connectedCallback(): void;
|
|
227
312
|
/**
|
|
228
|
-
* Binds this outlet to a
|
|
313
|
+
* Binds this outlet to a tp-router element.
|
|
229
314
|
*
|
|
230
315
|
* If no router is provided, automatically searches for one:
|
|
231
316
|
* - If `for` attribute is set, finds router by ID in the same root
|
|
232
|
-
* - Otherwise, finds the nearest parent
|
|
317
|
+
* - Otherwise, finds the nearest parent tp-router
|
|
233
318
|
*
|
|
234
319
|
* Unbinds from the previous router if already bound to a different one.
|
|
235
320
|
*
|
|
236
321
|
* @param router - Optional router to bind to
|
|
237
322
|
* @returns The bound router, or null if no router found
|
|
238
323
|
*/
|
|
239
|
-
bindToRouter():
|
|
324
|
+
bindToRouter(): RouterElement | null;
|
|
240
325
|
/**
|
|
241
326
|
* Internal method called by the router to set the active route.
|
|
242
327
|
* Updates the routeToRender signal which triggers re-rendering.
|
|
@@ -244,7 +329,7 @@ declare class ThaRouterOutlet extends SignalWatcherLitElement {
|
|
|
244
329
|
* @param route - The route to render, or null to clear
|
|
245
330
|
* @internal
|
|
246
331
|
*/
|
|
247
|
-
[RENDER_ROUTE](route:
|
|
332
|
+
[RENDER_ROUTE](route: RouteElement | null): void;
|
|
248
333
|
/**
|
|
249
334
|
* Lifecycle callback when the element is disconnected from the DOM.
|
|
250
335
|
* Unbinds from the router and cleans up effects.
|
|
@@ -264,40 +349,40 @@ declare global {
|
|
|
264
349
|
/**
|
|
265
350
|
* A router element that manages client-side routing for single-page applications.
|
|
266
351
|
* It watches for navigation events and matches the current URL against registered routes
|
|
267
|
-
* (
|
|
352
|
+
* (tp-route elements), rendering the matching route's content in a tp-router-outlet element.
|
|
268
353
|
* The `history` attribute specifies the history management strategy:
|
|
269
354
|
* - 'browser' for HTML5 History API (default)
|
|
270
355
|
* - 'hash' for hash-based routing
|
|
271
356
|
* - 'memory' for in-memory history (testing)
|
|
272
357
|
* - 'memory:name' for named memory history instances
|
|
273
358
|
*/
|
|
274
|
-
"
|
|
359
|
+
"tp-router": RouterElement;
|
|
275
360
|
}
|
|
276
361
|
}
|
|
277
|
-
declare const
|
|
362
|
+
declare const RouterElement_base: (new (...args: any[]) => HistoryManagedLitElementType) & (new () => LitElement & {
|
|
278
363
|
updateEffect(fn: () => void, options?: EffectOptions): () => void;
|
|
279
364
|
});
|
|
280
365
|
/**
|
|
281
366
|
* A custom element that manages client-side routing for single-page applications.
|
|
282
367
|
*
|
|
283
368
|
* The router watches for navigation events and matches the current URL against
|
|
284
|
-
* registered routes (
|
|
285
|
-
* in a
|
|
369
|
+
* registered routes (tp-route elements), rendering the matching route's content
|
|
370
|
+
* in a tp-router-outlet element.
|
|
286
371
|
*
|
|
287
372
|
* @example
|
|
288
373
|
* ```html
|
|
289
|
-
* <
|
|
290
|
-
* <
|
|
374
|
+
* <tp-router history="browser">
|
|
375
|
+
* <tp-route path="/">
|
|
291
376
|
* <template><h1>Home</h1></template>
|
|
292
|
-
* </
|
|
293
|
-
* <
|
|
377
|
+
* </tp-route>
|
|
378
|
+
* <tp-route path="/about">
|
|
294
379
|
* <template><h1>About</h1></template>
|
|
295
|
-
* </
|
|
296
|
-
* <
|
|
297
|
-
* </
|
|
380
|
+
* </tp-route>
|
|
381
|
+
* <tp-router-outlet></tp-router-outlet>
|
|
382
|
+
* </tp-router>
|
|
298
383
|
* ```
|
|
299
384
|
*/
|
|
300
|
-
declare class
|
|
385
|
+
declare class RouterElement extends RouterElement_base {
|
|
301
386
|
#private;
|
|
302
387
|
/**
|
|
303
388
|
* Lifecycle callback when the element is connected to the DOM.
|
|
@@ -311,7 +396,7 @@ declare class ThaRouter extends ThaRouter_base {
|
|
|
311
396
|
* @param outlet - The outlet element to assign, or null to unassign
|
|
312
397
|
* @internal
|
|
313
398
|
*/
|
|
314
|
-
assignOutlet(outlet:
|
|
399
|
+
assignOutlet(outlet: RouterOutletElement | null): void;
|
|
315
400
|
/**
|
|
316
401
|
* Lifecycle callback when the element is disconnected from the DOM.
|
|
317
402
|
* Cleans up all observers, effects, and listeners.
|
|
@@ -335,7 +420,7 @@ declare global {
|
|
|
335
420
|
* The `active` attribute reflects whether the link matches the current route.
|
|
336
421
|
* The `history` attribute specifies which history instance to use.
|
|
337
422
|
*/
|
|
338
|
-
"
|
|
423
|
+
"tp-router-link": RouterLinkElement;
|
|
339
424
|
}
|
|
340
425
|
}
|
|
341
426
|
/** Navigation symbols for browser history operations */
|
|
@@ -346,7 +431,7 @@ type AbsolutePath = '/' | `/${string}`;
|
|
|
346
431
|
type RelativePath = './' | `./${string}` | `../${string}`;
|
|
347
432
|
/** Union of all supported link types */
|
|
348
433
|
type LinkType = LinkSymbol | AbsolutePath | RelativePath;
|
|
349
|
-
declare const
|
|
434
|
+
declare const RouterLinkElement_base: (new (...args: any[]) => HistoryManagedLitElementType) & (new () => LitElement & {
|
|
350
435
|
updateEffect(fn: () => void, options?: EffectOptions): () => void;
|
|
351
436
|
});
|
|
352
437
|
/**
|
|
@@ -362,18 +447,18 @@ declare const ThaRouterLink_base: (new (...args: any[]) => HistoryManagedLitElem
|
|
|
362
447
|
* @example
|
|
363
448
|
* ```html
|
|
364
449
|
* <!-- Absolute path -->
|
|
365
|
-
* <
|
|
450
|
+
* <tp-router-link to="/about">About</tp-router-link>
|
|
366
451
|
*
|
|
367
452
|
* <!-- Relative path -->
|
|
368
|
-
* <
|
|
369
|
-
* <
|
|
453
|
+
* <tp-router-link to="./details">Details</tp-router-link>
|
|
454
|
+
* <tp-router-link to="../users">Back to Users</tp-router-link>
|
|
370
455
|
*
|
|
371
456
|
* <!-- History navigation -->
|
|
372
|
-
* <
|
|
373
|
-
* <
|
|
457
|
+
* <tp-router-link to="back">← Back</tp-router-link>
|
|
458
|
+
* <tp-router-link to="forward">Forward →</tp-router-link>
|
|
374
459
|
* ```
|
|
375
460
|
*/
|
|
376
|
-
declare class
|
|
461
|
+
declare class RouterLinkElement extends RouterLinkElement_base {
|
|
377
462
|
#private;
|
|
378
463
|
/**
|
|
379
464
|
* The navigation target. Can be:
|
|
@@ -429,10 +514,10 @@ declare global {
|
|
|
429
514
|
* - **In `<head>`**: Sets global history for all routers
|
|
430
515
|
* - **In `<body>`**: Provides local history for descendant routers
|
|
431
516
|
*/
|
|
432
|
-
"
|
|
517
|
+
"tp-router-config": RouterConfigElement;
|
|
433
518
|
}
|
|
434
519
|
}
|
|
435
|
-
declare const
|
|
520
|
+
declare const RouterConfigElement_base: (new (...args: any[]) => HistoryManagedLitElementType) & (new () => LitElement & {
|
|
436
521
|
updateEffect(fn: () => void, options?: EffectOptions): () => void;
|
|
437
522
|
});
|
|
438
523
|
/**
|
|
@@ -449,13 +534,13 @@ declare const ThaRouterConfig_base: (new (...args: any[]) => HistoryManagedLitEl
|
|
|
449
534
|
* ```html
|
|
450
535
|
* <head>
|
|
451
536
|
* <!-- All routers will use hash routing by default -->
|
|
452
|
-
* <
|
|
537
|
+
* <tp-router-config history="hash"></tp-router-config>
|
|
453
538
|
* </head>
|
|
454
539
|
* <body>
|
|
455
|
-
* <
|
|
540
|
+
* <tp-router>
|
|
456
541
|
* <!-- Uses hash history (global default) -->
|
|
457
|
-
* <
|
|
458
|
-
* </
|
|
542
|
+
* <tp-route path="/home">...</tp-route>
|
|
543
|
+
* </tp-router>
|
|
459
544
|
* </body>
|
|
460
545
|
* ```
|
|
461
546
|
*
|
|
@@ -468,20 +553,20 @@ declare const ThaRouterConfig_base: (new (...args: any[]) => HistoryManagedLitEl
|
|
|
468
553
|
* ```html
|
|
469
554
|
* <body>
|
|
470
555
|
* <!-- Section 1: Hash routing -->
|
|
471
|
-
* <
|
|
472
|
-
* <
|
|
556
|
+
* <tp-router-config history="hash">
|
|
557
|
+
* <tp-router>
|
|
473
558
|
* <!-- Uses hash history from parent config -->
|
|
474
|
-
* <
|
|
475
|
-
* </
|
|
476
|
-
* </
|
|
559
|
+
* <tp-route path="/dashboard">...</tp-route>
|
|
560
|
+
* </tp-router>
|
|
561
|
+
* </tp-router-config>
|
|
477
562
|
*
|
|
478
563
|
* <!-- Section 2: Memory routing (isolated) -->
|
|
479
|
-
* <
|
|
480
|
-
* <
|
|
564
|
+
* <tp-router-config history="memory">
|
|
565
|
+
* <tp-router>
|
|
481
566
|
* <!-- Uses memory history from parent config -->
|
|
482
|
-
* <
|
|
483
|
-
* </
|
|
484
|
-
* </
|
|
567
|
+
* <tp-route path="/preview">...</tp-route>
|
|
568
|
+
* </tp-router>
|
|
569
|
+
* </tp-router-config>
|
|
485
570
|
* </body>
|
|
486
571
|
* ```
|
|
487
572
|
*
|
|
@@ -495,7 +580,7 @@ declare const ThaRouterConfig_base: (new (...args: any[]) => HistoryManagedLitEl
|
|
|
495
580
|
* <!DOCTYPE html>
|
|
496
581
|
* <html>
|
|
497
582
|
* <head>
|
|
498
|
-
* <
|
|
583
|
+
* <tp-router-config history="browser"></tp-router-config>
|
|
499
584
|
* </head>
|
|
500
585
|
* <body>
|
|
501
586
|
* <!-- All routers use browser history -->
|
|
@@ -510,16 +595,16 @@ declare const ThaRouterConfig_base: (new (...args: any[]) => HistoryManagedLitEl
|
|
|
510
595
|
* ```html
|
|
511
596
|
* <head>
|
|
512
597
|
* <!-- Global: browser history -->
|
|
513
|
-
* <
|
|
598
|
+
* <tp-router-config history="browser"></tp-router-config>
|
|
514
599
|
* </head>
|
|
515
600
|
* <body>
|
|
516
601
|
* <!-- Main app uses browser history -->
|
|
517
|
-
* <
|
|
602
|
+
* <tp-router>...</tp-router>
|
|
518
603
|
*
|
|
519
604
|
* <!-- Admin section uses hash history -->
|
|
520
|
-
* <
|
|
521
|
-
* <
|
|
522
|
-
* </
|
|
605
|
+
* <tp-router-config history="hash">
|
|
606
|
+
* <tp-router>...</tp-router>
|
|
607
|
+
* </tp-router-config>
|
|
523
608
|
* </body>
|
|
524
609
|
* ```
|
|
525
610
|
*
|
|
@@ -530,17 +615,17 @@ declare const ThaRouterConfig_base: (new (...args: any[]) => HistoryManagedLitEl
|
|
|
530
615
|
* ```html
|
|
531
616
|
* <body>
|
|
532
617
|
* <!-- Each component has independent navigation -->
|
|
533
|
-
* <
|
|
618
|
+
* <tp-router-config history="memory:component1">
|
|
534
619
|
* <my-widget>
|
|
535
|
-
* <
|
|
620
|
+
* <tp-router>...</tp-router>
|
|
536
621
|
* </my-widget>
|
|
537
|
-
* </
|
|
622
|
+
* </tp-router-config>
|
|
538
623
|
*
|
|
539
|
-
* <
|
|
624
|
+
* <tp-router-config history="memory:component2">
|
|
540
625
|
* <my-widget>
|
|
541
|
-
* <
|
|
626
|
+
* <tp-router>...</tp-router>
|
|
542
627
|
* </my-widget>
|
|
543
|
-
* </
|
|
628
|
+
* </tp-router-config>
|
|
544
629
|
* </body>
|
|
545
630
|
* ```
|
|
546
631
|
*
|
|
@@ -553,11 +638,11 @@ declare const ThaRouterConfig_base: (new (...args: any[]) => HistoryManagedLitEl
|
|
|
553
638
|
*
|
|
554
639
|
* it('should navigate', async () => {
|
|
555
640
|
* const el = await fixture(html`
|
|
556
|
-
* <
|
|
557
|
-
* <
|
|
558
|
-
* <
|
|
559
|
-
* </
|
|
560
|
-
* </
|
|
641
|
+
* <tp-router-config history="memory:test">
|
|
642
|
+
* <tp-router>
|
|
643
|
+
* <tp-route path="/test">Test Page</tp-route>
|
|
644
|
+
* </tp-router>
|
|
645
|
+
* </tp-router-config>
|
|
561
646
|
* `);
|
|
562
647
|
*
|
|
563
648
|
* // Test navigation without affecting browser URL
|
|
@@ -569,56 +654,56 @@ declare const ThaRouterConfig_base: (new (...args: any[]) => HistoryManagedLitEl
|
|
|
569
654
|
* Router components resolve their history in this order:
|
|
570
655
|
*
|
|
571
656
|
* 1. **Own `history` attribute** (highest priority)
|
|
572
|
-
* 2. **Parent `
|
|
573
|
-
* 3. **Global `
|
|
657
|
+
* 2. **Parent `tp-router-config`** (local configuration)
|
|
658
|
+
* 3. **Global `tp-router-config`** (in `<head>`)
|
|
574
659
|
* 4. **Default** (`"browser"`)
|
|
575
660
|
*
|
|
576
661
|
* ## Best Practices
|
|
577
662
|
*
|
|
578
|
-
* ✅ **DO**: Place one `
|
|
663
|
+
* ✅ **DO**: Place one `tp-router-config` in `<head>` for global settings
|
|
579
664
|
*
|
|
580
665
|
* ```html
|
|
581
666
|
* <head>
|
|
582
|
-
* <
|
|
667
|
+
* <tp-router-config history="browser"></tp-router-config>
|
|
583
668
|
* </head>
|
|
584
669
|
* ```
|
|
585
670
|
*
|
|
586
671
|
* ✅ **DO**: Use local configs for sections with different routing needs
|
|
587
672
|
*
|
|
588
673
|
* ```html
|
|
589
|
-
* <
|
|
674
|
+
* <tp-router-config history="memory">
|
|
590
675
|
* <component-preview>...</component-preview>
|
|
591
|
-
* </
|
|
676
|
+
* </tp-router-config>
|
|
592
677
|
* ```
|
|
593
678
|
*
|
|
594
679
|
* ✅ **DO**: Use named memory history for isolated components
|
|
595
680
|
*
|
|
596
681
|
* ```html
|
|
597
|
-
* <
|
|
682
|
+
* <tp-router-config history="memory:sidebar">
|
|
598
683
|
* <sidebar-nav>...</sidebar-nav>
|
|
599
|
-
* </
|
|
684
|
+
* </tp-router-config>
|
|
600
685
|
* ```
|
|
601
686
|
*
|
|
602
687
|
* ❌ **DON'T**: Place multiple configs in `<head>` (last one wins)
|
|
603
688
|
*
|
|
604
689
|
* ```html
|
|
605
690
|
* <head>
|
|
606
|
-
* <
|
|
607
|
-
* <
|
|
691
|
+
* <tp-router-config history="browser"></tp-router-config>
|
|
692
|
+
* <tp-router-config history="hash"></tp-router-config> <!-- Overrides above -->
|
|
608
693
|
* </head>
|
|
609
694
|
* ```
|
|
610
695
|
*
|
|
611
696
|
* ❌ **DON'T**: Nest configs unnecessarily (inner configs take precedence)
|
|
612
697
|
*
|
|
613
698
|
* ```html
|
|
614
|
-
* <
|
|
615
|
-
* <
|
|
699
|
+
* <tp-router-config history="browser">
|
|
700
|
+
* <tp-router-config history="hash">
|
|
616
701
|
* <!-- Uses hash, not browser -->
|
|
617
|
-
* </
|
|
618
|
-
* </
|
|
702
|
+
* </tp-router-config>
|
|
703
|
+
* </tp-router-config>
|
|
619
704
|
* ```
|
|
620
705
|
*/
|
|
621
|
-
declare class
|
|
706
|
+
declare class RouterConfigElement extends RouterConfigElement_base {
|
|
622
707
|
#private;
|
|
623
708
|
/**
|
|
624
709
|
* Called when the element is connected to the DOM.
|
|
@@ -648,7 +733,7 @@ declare class ThaRouterConfig extends ThaRouterConfig_base {
|
|
|
648
733
|
* Provides a declarative way to display dynamic route parameter values
|
|
649
734
|
* directly in HTML templates without requiring JavaScript.
|
|
650
735
|
*
|
|
651
|
-
* @module router/
|
|
736
|
+
* @module router/tp-router-param
|
|
652
737
|
*/
|
|
653
738
|
|
|
654
739
|
declare global {
|
|
@@ -656,10 +741,10 @@ declare global {
|
|
|
656
741
|
/**
|
|
657
742
|
* A component that displays the value of a route parameter.
|
|
658
743
|
*
|
|
659
|
-
* Must be used within a
|
|
744
|
+
* Must be used within a tp-router-outlet element. Automatically
|
|
660
745
|
* updates when route parameters change.
|
|
661
746
|
*/
|
|
662
|
-
'
|
|
747
|
+
'tp-router-param': RouterParamElement;
|
|
663
748
|
}
|
|
664
749
|
}
|
|
665
750
|
/**
|
|
@@ -667,7 +752,7 @@ declare global {
|
|
|
667
752
|
*
|
|
668
753
|
* This component provides a declarative way to access and display URL
|
|
669
754
|
* parameters extracted from dynamic route segments without writing JavaScript.
|
|
670
|
-
* It must be used inside a `<
|
|
755
|
+
* It must be used inside a `<tp-router-outlet>` element.
|
|
671
756
|
*
|
|
672
757
|
* ## Features
|
|
673
758
|
*
|
|
@@ -681,15 +766,15 @@ declare global {
|
|
|
681
766
|
* ### Basic Parameter Display
|
|
682
767
|
*
|
|
683
768
|
* ```html
|
|
684
|
-
* <
|
|
685
|
-
* <
|
|
769
|
+
* <tp-router>
|
|
770
|
+
* <tp-route path="/users/:id">
|
|
686
771
|
* <template>
|
|
687
772
|
* <h1>User Profile</h1>
|
|
688
|
-
* <p>User ID: <
|
|
773
|
+
* <p>User ID: <tp-router-param name="id"></tp-router-param></p>
|
|
689
774
|
* </template>
|
|
690
|
-
* </
|
|
691
|
-
* <
|
|
692
|
-
* </
|
|
775
|
+
* </tp-route>
|
|
776
|
+
* <tp-router-outlet></tp-router-outlet>
|
|
777
|
+
* </tp-router>
|
|
693
778
|
* ```
|
|
694
779
|
*
|
|
695
780
|
* When navigating to `/users/123`, the component renders: `User ID: 123`
|
|
@@ -697,19 +782,19 @@ declare global {
|
|
|
697
782
|
* ### Multiple Parameters
|
|
698
783
|
*
|
|
699
784
|
* ```html
|
|
700
|
-
* <
|
|
785
|
+
* <tp-route path="/blog/:year/:month/:slug">
|
|
701
786
|
* <template>
|
|
702
787
|
* <article>
|
|
703
788
|
* <header>
|
|
704
789
|
* <time>
|
|
705
|
-
* <
|
|
706
|
-
* <
|
|
790
|
+
* <tp-router-param name="year"></tp-router-param>-
|
|
791
|
+
* <tp-router-param name="month"></tp-router-param>
|
|
707
792
|
* </time>
|
|
708
|
-
* <h1><
|
|
793
|
+
* <h1><tp-router-param name="slug"></tp-router-param></h1>
|
|
709
794
|
* </header>
|
|
710
795
|
* </article>
|
|
711
796
|
* </template>
|
|
712
|
-
* </
|
|
797
|
+
* </tp-route>
|
|
713
798
|
* ```
|
|
714
799
|
*
|
|
715
800
|
* For `/blog/2024/12/hello-world`, renders:
|
|
@@ -721,111 +806,111 @@ declare global {
|
|
|
721
806
|
* ### Nested Routes with Parameter Inheritance
|
|
722
807
|
*
|
|
723
808
|
* ```html
|
|
724
|
-
* <
|
|
725
|
-
* <
|
|
809
|
+
* <tp-router>
|
|
810
|
+
* <tp-route path="/projects/:projectId">
|
|
726
811
|
* <template>
|
|
727
|
-
* <h1>Project <
|
|
812
|
+
* <h1>Project <tp-router-param name="projectId"></tp-router-param></h1>
|
|
728
813
|
*
|
|
729
814
|
* <!-- Nested outlet inherits projectId parameter -->
|
|
730
|
-
* <
|
|
731
|
-
* <
|
|
815
|
+
* <tp-router-outlet>
|
|
816
|
+
* <tp-route path="/tasks/:taskId">
|
|
732
817
|
* <template>
|
|
733
818
|
* <!-- Both params are available -->
|
|
734
819
|
* <h2>Task Details</h2>
|
|
735
|
-
* <p>Project: <
|
|
736
|
-
* <p>Task: <
|
|
820
|
+
* <p>Project: <tp-router-param name="projectId"></tp-router-param></p>
|
|
821
|
+
* <p>Task: <tp-router-param name="taskId"></tp-router-param></p>
|
|
737
822
|
* </template>
|
|
738
|
-
* </
|
|
739
|
-
* </
|
|
823
|
+
* </tp-route>
|
|
824
|
+
* </tp-router-outlet>
|
|
740
825
|
* </template>
|
|
741
|
-
* </
|
|
742
|
-
* <
|
|
743
|
-
* </
|
|
826
|
+
* </tp-route>
|
|
827
|
+
* <tp-router-outlet></tp-router-outlet>
|
|
828
|
+
* </tp-router>
|
|
744
829
|
* ```
|
|
745
830
|
*
|
|
746
831
|
* ### With Styling
|
|
747
832
|
*
|
|
748
833
|
* ```html
|
|
749
834
|
* <style>
|
|
750
|
-
*
|
|
835
|
+
* tp-router-param {
|
|
751
836
|
* font-weight: bold;
|
|
752
837
|
* color: var(--primary-color);
|
|
753
838
|
* }
|
|
754
839
|
*
|
|
755
|
-
*
|
|
840
|
+
* tp-router-param[name="id"] {
|
|
756
841
|
* font-family: monospace;
|
|
757
842
|
* }
|
|
758
843
|
* </style>
|
|
759
844
|
*
|
|
760
|
-
* <
|
|
845
|
+
* <tp-route path="/users/:id">
|
|
761
846
|
* <template>
|
|
762
|
-
* <span>User: <
|
|
847
|
+
* <span>User: <tp-router-param name="id"></tp-router-param></span>
|
|
763
848
|
* </template>
|
|
764
|
-
* </
|
|
849
|
+
* </tp-route>
|
|
765
850
|
* ```
|
|
766
851
|
*
|
|
767
852
|
* ## How It Works
|
|
768
853
|
*
|
|
769
|
-
* 1. On connection, finds the nearest parent `<
|
|
854
|
+
* 1. On connection, finds the nearest parent `<tp-router-outlet>`
|
|
770
855
|
* 2. Accesses the outlet's PARAMS signal containing all route parameters
|
|
771
856
|
* 3. Computes and displays the value for the specified parameter name
|
|
772
857
|
* 4. Automatically re-renders when the route (and thus params) change
|
|
773
858
|
*
|
|
774
859
|
* ## Error Handling
|
|
775
860
|
*
|
|
776
|
-
* Throws an error if not placed within a `<
|
|
861
|
+
* Throws an error if not placed within a `<tp-router-outlet>`:
|
|
777
862
|
*
|
|
778
863
|
* ```javascript
|
|
779
864
|
* // ✗ Wrong - not inside outlet
|
|
780
|
-
* <
|
|
865
|
+
* <tp-router-param name="id"></tp-router-param>
|
|
781
866
|
*
|
|
782
867
|
* // ✓ Correct - inside outlet
|
|
783
|
-
* <
|
|
784
|
-
* <
|
|
785
|
-
* </
|
|
868
|
+
* <tp-router-outlet>
|
|
869
|
+
* <tp-router-param name="id"></tp-router-param>
|
|
870
|
+
* </tp-router-outlet>
|
|
786
871
|
* ```
|
|
787
872
|
*
|
|
788
873
|
* ## Alternative: Using Attributes
|
|
789
874
|
*
|
|
790
|
-
* The parent `<
|
|
875
|
+
* The parent `<tp-router-outlet>` also exposes parameters as `param-*` attributes,
|
|
791
876
|
* which can be used as an alternative approach:
|
|
792
877
|
*
|
|
793
878
|
* ```html
|
|
794
|
-
* <
|
|
879
|
+
* <tp-router-outlet id="outlet">
|
|
795
880
|
* <script>
|
|
796
881
|
* const outlet = document.getElementById('outlet');
|
|
797
882
|
* // Params available as: outlet.getAttribute('param-id')
|
|
798
883
|
* </script>
|
|
799
|
-
* </
|
|
884
|
+
* </tp-router-outlet>
|
|
800
885
|
* ```
|
|
801
886
|
*
|
|
802
|
-
* However, `<
|
|
887
|
+
* However, `<tp-router-param>` is preferred for declarative templates.
|
|
803
888
|
*
|
|
804
889
|
* @example Basic usage
|
|
805
890
|
* ```html
|
|
806
|
-
* <
|
|
807
|
-
* <
|
|
891
|
+
* <tp-router>
|
|
892
|
+
* <tp-route path="/product/:sku">
|
|
808
893
|
* <template>
|
|
809
|
-
* <h1>Product: <
|
|
894
|
+
* <h1>Product: <tp-router-param name="sku"></tp-router-param></h1>
|
|
810
895
|
* </template>
|
|
811
|
-
* </
|
|
812
|
-
* <
|
|
813
|
-
* </
|
|
896
|
+
* </tp-route>
|
|
897
|
+
* <tp-router-outlet></tp-router-outlet>
|
|
898
|
+
* </tp-router>
|
|
814
899
|
* ```
|
|
815
900
|
*
|
|
816
901
|
* @example Multiple params with formatting
|
|
817
902
|
* ```html
|
|
818
|
-
* <
|
|
903
|
+
* <tp-route path="/user/:username/post/:postId">
|
|
819
904
|
* <template>
|
|
820
905
|
* <article>
|
|
821
|
-
* <p>@<
|
|
822
|
-
* <p>Post #<
|
|
906
|
+
* <p>@<tp-router-param name="username"></tp-router-param></p>
|
|
907
|
+
* <p>Post #<tp-router-param name="postId"></tp-router-param></p>
|
|
823
908
|
* </article>
|
|
824
909
|
* </template>
|
|
825
|
-
* </
|
|
910
|
+
* </tp-route>
|
|
826
911
|
* ```
|
|
827
912
|
*/
|
|
828
|
-
declare class
|
|
913
|
+
declare class RouterParamElement extends SignalWatcherLitElement {
|
|
829
914
|
#private;
|
|
830
915
|
/**
|
|
831
916
|
* The name of the route parameter to display.
|
|
@@ -840,10 +925,10 @@ declare class ThaRouterParam extends SignalWatcherLitElement {
|
|
|
840
925
|
/**
|
|
841
926
|
* Lifecycle callback when element is connected to the DOM.
|
|
842
927
|
*
|
|
843
|
-
* Finds the parent `<
|
|
928
|
+
* Finds the parent `<tp-router-outlet>` and stores a reference.
|
|
844
929
|
* Throws an error if not used within an outlet.
|
|
845
930
|
*
|
|
846
|
-
* @throws {Error} If no parent
|
|
931
|
+
* @throws {Error} If no parent tp-router-outlet is found
|
|
847
932
|
*/
|
|
848
933
|
connectedCallback(): void;
|
|
849
934
|
/**
|
|
@@ -869,4 +954,24 @@ declare class ThaRouterParam extends SignalWatcherLitElement {
|
|
|
869
954
|
protected render(): TemplateResult;
|
|
870
955
|
}
|
|
871
956
|
|
|
872
|
-
|
|
957
|
+
/** Fired on a `<tp-route>` when its `src` content has loaded. Bubbles and is composed. */
|
|
958
|
+
declare const ROUTE_LOAD_EVENT = "tp-route-load";
|
|
959
|
+
/** Fired on a `<tp-route>` when its `src` content failed to load. Bubbles and is composed. */
|
|
960
|
+
declare const ROUTE_ERROR_EVENT = "tp-route-error";
|
|
961
|
+
/** `detail` of {@link ROUTE_LOAD_EVENT} and {@link ROUTE_ERROR_EVENT}. */
|
|
962
|
+
interface RouteSourceEventDetail {
|
|
963
|
+
/** Absolute URL that was requested. */
|
|
964
|
+
src: string;
|
|
965
|
+
/** Failure reason; only present on {@link ROUTE_ERROR_EVENT}. */
|
|
966
|
+
error?: unknown;
|
|
967
|
+
}
|
|
968
|
+
type RouteSourceEvent = CustomEvent<RouteSourceEventDetail>;
|
|
969
|
+
declare global {
|
|
970
|
+
interface HTMLElementEventMap {
|
|
971
|
+
[ROUTE_LOAD_EVENT]: RouteSourceEvent;
|
|
972
|
+
[ROUTE_ERROR_EVENT]: RouteSourceEvent;
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
|
|
976
|
+
export { ROUTE_ERROR_EVENT, ROUTE_LOAD_EVENT, RouteElement, RouterConfigElement, RouterElement, RouterLinkElement, RouterOutletElement, RouterParamElement, defaultRouteSourceLoader };
|
|
977
|
+
export type { RouteSourceEvent, RouteSourceEventDetail, RouteSourceLoader, RouteSourceStatus };
|