@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
|
@@ -19,13 +19,13 @@ import { HistoryManaged, HISTORY_TYPE } from './history-managed.js';
|
|
|
19
19
|
* ```html
|
|
20
20
|
* <head>
|
|
21
21
|
* <!-- All routers will use hash routing by default -->
|
|
22
|
-
* <
|
|
22
|
+
* <tp-router-config history="hash"></tp-router-config>
|
|
23
23
|
* </head>
|
|
24
24
|
* <body>
|
|
25
|
-
* <
|
|
25
|
+
* <tp-router>
|
|
26
26
|
* <!-- Uses hash history (global default) -->
|
|
27
|
-
* <
|
|
28
|
-
* </
|
|
27
|
+
* <tp-route path="/home">...</tp-route>
|
|
28
|
+
* </tp-router>
|
|
29
29
|
* </body>
|
|
30
30
|
* ```
|
|
31
31
|
*
|
|
@@ -38,20 +38,20 @@ import { HistoryManaged, HISTORY_TYPE } from './history-managed.js';
|
|
|
38
38
|
* ```html
|
|
39
39
|
* <body>
|
|
40
40
|
* <!-- Section 1: Hash routing -->
|
|
41
|
-
* <
|
|
42
|
-
* <
|
|
41
|
+
* <tp-router-config history="hash">
|
|
42
|
+
* <tp-router>
|
|
43
43
|
* <!-- Uses hash history from parent config -->
|
|
44
|
-
* <
|
|
45
|
-
* </
|
|
46
|
-
* </
|
|
44
|
+
* <tp-route path="/dashboard">...</tp-route>
|
|
45
|
+
* </tp-router>
|
|
46
|
+
* </tp-router-config>
|
|
47
47
|
*
|
|
48
48
|
* <!-- Section 2: Memory routing (isolated) -->
|
|
49
|
-
* <
|
|
50
|
-
* <
|
|
49
|
+
* <tp-router-config history="memory">
|
|
50
|
+
* <tp-router>
|
|
51
51
|
* <!-- Uses memory history from parent config -->
|
|
52
|
-
* <
|
|
53
|
-
* </
|
|
54
|
-
* </
|
|
52
|
+
* <tp-route path="/preview">...</tp-route>
|
|
53
|
+
* </tp-router>
|
|
54
|
+
* </tp-router-config>
|
|
55
55
|
* </body>
|
|
56
56
|
* ```
|
|
57
57
|
*
|
|
@@ -65,7 +65,7 @@ import { HistoryManaged, HISTORY_TYPE } from './history-managed.js';
|
|
|
65
65
|
* <!DOCTYPE html>
|
|
66
66
|
* <html>
|
|
67
67
|
* <head>
|
|
68
|
-
* <
|
|
68
|
+
* <tp-router-config history="browser"></tp-router-config>
|
|
69
69
|
* </head>
|
|
70
70
|
* <body>
|
|
71
71
|
* <!-- All routers use browser history -->
|
|
@@ -80,16 +80,16 @@ import { HistoryManaged, HISTORY_TYPE } from './history-managed.js';
|
|
|
80
80
|
* ```html
|
|
81
81
|
* <head>
|
|
82
82
|
* <!-- Global: browser history -->
|
|
83
|
-
* <
|
|
83
|
+
* <tp-router-config history="browser"></tp-router-config>
|
|
84
84
|
* </head>
|
|
85
85
|
* <body>
|
|
86
86
|
* <!-- Main app uses browser history -->
|
|
87
|
-
* <
|
|
87
|
+
* <tp-router>...</tp-router>
|
|
88
88
|
*
|
|
89
89
|
* <!-- Admin section uses hash history -->
|
|
90
|
-
* <
|
|
91
|
-
* <
|
|
92
|
-
* </
|
|
90
|
+
* <tp-router-config history="hash">
|
|
91
|
+
* <tp-router>...</tp-router>
|
|
92
|
+
* </tp-router-config>
|
|
93
93
|
* </body>
|
|
94
94
|
* ```
|
|
95
95
|
*
|
|
@@ -100,17 +100,17 @@ import { HistoryManaged, HISTORY_TYPE } from './history-managed.js';
|
|
|
100
100
|
* ```html
|
|
101
101
|
* <body>
|
|
102
102
|
* <!-- Each component has independent navigation -->
|
|
103
|
-
* <
|
|
103
|
+
* <tp-router-config history="memory:component1">
|
|
104
104
|
* <my-widget>
|
|
105
|
-
* <
|
|
105
|
+
* <tp-router>...</tp-router>
|
|
106
106
|
* </my-widget>
|
|
107
|
-
* </
|
|
107
|
+
* </tp-router-config>
|
|
108
108
|
*
|
|
109
|
-
* <
|
|
109
|
+
* <tp-router-config history="memory:component2">
|
|
110
110
|
* <my-widget>
|
|
111
|
-
* <
|
|
111
|
+
* <tp-router>...</tp-router>
|
|
112
112
|
* </my-widget>
|
|
113
|
-
* </
|
|
113
|
+
* </tp-router-config>
|
|
114
114
|
* </body>
|
|
115
115
|
* ```
|
|
116
116
|
*
|
|
@@ -123,11 +123,11 @@ import { HistoryManaged, HISTORY_TYPE } from './history-managed.js';
|
|
|
123
123
|
*
|
|
124
124
|
* it('should navigate', async () => {
|
|
125
125
|
* const el = await fixture(html`
|
|
126
|
-
* <
|
|
127
|
-
* <
|
|
128
|
-
* <
|
|
129
|
-
* </
|
|
130
|
-
* </
|
|
126
|
+
* <tp-router-config history="memory:test">
|
|
127
|
+
* <tp-router>
|
|
128
|
+
* <tp-route path="/test">Test Page</tp-route>
|
|
129
|
+
* </tp-router>
|
|
130
|
+
* </tp-router-config>
|
|
131
131
|
* `);
|
|
132
132
|
*
|
|
133
133
|
* // Test navigation without affecting browser URL
|
|
@@ -139,56 +139,56 @@ import { HistoryManaged, HISTORY_TYPE } from './history-managed.js';
|
|
|
139
139
|
* Router components resolve their history in this order:
|
|
140
140
|
*
|
|
141
141
|
* 1. **Own `history` attribute** (highest priority)
|
|
142
|
-
* 2. **Parent `
|
|
143
|
-
* 3. **Global `
|
|
142
|
+
* 2. **Parent `tp-router-config`** (local configuration)
|
|
143
|
+
* 3. **Global `tp-router-config`** (in `<head>`)
|
|
144
144
|
* 4. **Default** (`"browser"`)
|
|
145
145
|
*
|
|
146
146
|
* ## Best Practices
|
|
147
147
|
*
|
|
148
|
-
* ✅ **DO**: Place one `
|
|
148
|
+
* ✅ **DO**: Place one `tp-router-config` in `<head>` for global settings
|
|
149
149
|
*
|
|
150
150
|
* ```html
|
|
151
151
|
* <head>
|
|
152
|
-
* <
|
|
152
|
+
* <tp-router-config history="browser"></tp-router-config>
|
|
153
153
|
* </head>
|
|
154
154
|
* ```
|
|
155
155
|
*
|
|
156
156
|
* ✅ **DO**: Use local configs for sections with different routing needs
|
|
157
157
|
*
|
|
158
158
|
* ```html
|
|
159
|
-
* <
|
|
159
|
+
* <tp-router-config history="memory">
|
|
160
160
|
* <component-preview>...</component-preview>
|
|
161
|
-
* </
|
|
161
|
+
* </tp-router-config>
|
|
162
162
|
* ```
|
|
163
163
|
*
|
|
164
164
|
* ✅ **DO**: Use named memory history for isolated components
|
|
165
165
|
*
|
|
166
166
|
* ```html
|
|
167
|
-
* <
|
|
167
|
+
* <tp-router-config history="memory:sidebar">
|
|
168
168
|
* <sidebar-nav>...</sidebar-nav>
|
|
169
|
-
* </
|
|
169
|
+
* </tp-router-config>
|
|
170
170
|
* ```
|
|
171
171
|
*
|
|
172
172
|
* ❌ **DON'T**: Place multiple configs in `<head>` (last one wins)
|
|
173
173
|
*
|
|
174
174
|
* ```html
|
|
175
175
|
* <head>
|
|
176
|
-
* <
|
|
177
|
-
* <
|
|
176
|
+
* <tp-router-config history="browser"></tp-router-config>
|
|
177
|
+
* <tp-router-config history="hash"></tp-router-config> <!-- Overrides above -->
|
|
178
178
|
* </head>
|
|
179
179
|
* ```
|
|
180
180
|
*
|
|
181
181
|
* ❌ **DON'T**: Nest configs unnecessarily (inner configs take precedence)
|
|
182
182
|
*
|
|
183
183
|
* ```html
|
|
184
|
-
* <
|
|
185
|
-
* <
|
|
184
|
+
* <tp-router-config history="browser">
|
|
185
|
+
* <tp-router-config history="hash">
|
|
186
186
|
* <!-- Uses hash, not browser -->
|
|
187
|
-
* </
|
|
188
|
-
* </
|
|
187
|
+
* </tp-router-config>
|
|
188
|
+
* </tp-router-config>
|
|
189
189
|
* ```
|
|
190
190
|
*/
|
|
191
|
-
let
|
|
191
|
+
let RouterConfigElement = class RouterConfigElement extends HistoryManaged(SignalWatcherLitElement) {
|
|
192
192
|
/**
|
|
193
193
|
* Cleanup function for the global history effect.
|
|
194
194
|
* Only used when the element is placed in `<head>`.
|
|
@@ -205,7 +205,7 @@ let ThaRouterConfig = class ThaRouterConfig extends HistoryManaged(SignalWatcher
|
|
|
205
205
|
super.connectedCallback();
|
|
206
206
|
if (!document.head.contains(this))
|
|
207
207
|
return;
|
|
208
|
-
console.log('
|
|
208
|
+
console.log('RouterConfigElement: Setting global history type to', this[HISTORY_TYPE].get());
|
|
209
209
|
// Set the global history type when this element is connected in <head>
|
|
210
210
|
this.#globalHistoryUnsubscribe = this.updateEffect(() => {
|
|
211
211
|
GLOBAL_HISTORY_TYPE.set(this[HISTORY_TYPE].get());
|
|
@@ -233,9 +233,9 @@ let ThaRouterConfig = class ThaRouterConfig extends HistoryManaged(SignalWatcher
|
|
|
233
233
|
return this;
|
|
234
234
|
}
|
|
235
235
|
};
|
|
236
|
-
|
|
237
|
-
customElement('
|
|
238
|
-
],
|
|
236
|
+
RouterConfigElement = __decorate([
|
|
237
|
+
customElement('tp-router-config')
|
|
238
|
+
], RouterConfigElement);
|
|
239
239
|
|
|
240
|
-
export {
|
|
241
|
-
//# sourceMappingURL=
|
|
240
|
+
export { RouterConfigElement };
|
|
241
|
+
//# sourceMappingURL=router-config-element.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"router-config-element.js","sources":["../../../../libs/elements/src/router/router-config-element.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;AAqBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsLG;AAEI,IAAM,mBAAmB,GAAzB,MAAM,mBAAoB,SAAQ,cAAc,CAAC,uBAAuB,CAAC,CAAA;AAC9E;;;;AAIG;IACH,yBAAyB,GAAG,IAAI;AAEhC;;;;;AAKG;IACM,iBAAiB,GAAA;QACxB,KAAK,CAAC,iBAAiB,EAAE;QAEzB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;YAAE;AAEnC,QAAA,OAAO,CAAC,GAAG,CAAC,qDAAqD,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC,GAAG,EAAE,CAAC;;QAG5F,IAAI,CAAC,yBAAyB,GAAG,IAAI,CAAC,YAAY,CAAC,MAAK;YACtD,mBAAmB,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,GAAG,EAAG,CAAC;AACpD,QAAA,CAAC,CAAC;IACJ;AAEA;;;;AAIG;IACM,oBAAoB,GAAA;QAC3B,KAAK,CAAC,oBAAoB,EAAE;AAE5B,QAAA,IAAI;YACF,IAAI,CAAC,yBAAyB,EAAE;QAClC;QAAE,MAAM,EAAC;IACX;AAEA;;;;;AAKG;IACgB,gBAAgB,GAAA;AACjC,QAAA,OAAO,IAAI;IACb;;AAhDW,mBAAmB,GAAA,UAAA,CAAA;IAD/B,aAAa,CAAC,kBAAkB;AACpB,CAAA,EAAA,mBAAmB,CAiD/B;;;;"}
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
var tslib = require('tslib');
|
|
4
4
|
var lit = require('lit');
|
|
5
5
|
var decorators_js = require('lit/decorators.js');
|
|
6
|
-
var
|
|
6
|
+
var routeElement = require('./route-element.cjs');
|
|
7
7
|
var signals = require('@lit-labs/signals');
|
|
8
|
-
var
|
|
8
|
+
var routerOutletElement = require('./router-outlet-element.cjs');
|
|
9
9
|
var noop = require('@telperion/js-utils/function/noop');
|
|
10
10
|
var defer = require('@telperion/js-utils/function/defer');
|
|
11
11
|
var signalWatcherLitElement = require('../utils/signal-watcher-lit-element.cjs');
|
|
@@ -15,34 +15,34 @@ var historyManaged = require('./history-managed.cjs');
|
|
|
15
15
|
* A custom element that manages client-side routing for single-page applications.
|
|
16
16
|
*
|
|
17
17
|
* The router watches for navigation events and matches the current URL against
|
|
18
|
-
* registered routes (
|
|
19
|
-
* in a
|
|
18
|
+
* registered routes (tp-route elements), rendering the matching route's content
|
|
19
|
+
* in a tp-router-outlet element.
|
|
20
20
|
*
|
|
21
21
|
* @example
|
|
22
22
|
* ```html
|
|
23
|
-
* <
|
|
24
|
-
* <
|
|
23
|
+
* <tp-router history="browser">
|
|
24
|
+
* <tp-route path="/">
|
|
25
25
|
* <template><h1>Home</h1></template>
|
|
26
|
-
* </
|
|
27
|
-
* <
|
|
26
|
+
* </tp-route>
|
|
27
|
+
* <tp-route path="/about">
|
|
28
28
|
* <template><h1>About</h1></template>
|
|
29
|
-
* </
|
|
30
|
-
* <
|
|
31
|
-
* </
|
|
29
|
+
* </tp-route>
|
|
30
|
+
* <tp-router-outlet></tp-router-outlet>
|
|
31
|
+
* </tp-router>
|
|
32
32
|
* ```
|
|
33
33
|
*/
|
|
34
|
-
exports.
|
|
34
|
+
exports.RouterElement = class RouterElement extends historyManaged.HistoryManaged(signalWatcherLitElement.SignalWatcherLitElement) {
|
|
35
35
|
/**
|
|
36
|
-
* Injects global styles for
|
|
37
|
-
* Ensures that only
|
|
36
|
+
* Injects global styles for tp-router elements to hide non-outlet children.
|
|
37
|
+
* Ensures that only tp-router-outlet elements are visible within the router.
|
|
38
38
|
*/
|
|
39
39
|
static {
|
|
40
40
|
const styleEl = document.createElement("style");
|
|
41
41
|
styleEl.setAttribute("type", "text/css");
|
|
42
|
-
styleEl.setAttribute("data-id", "
|
|
42
|
+
styleEl.setAttribute("data-id", "tp-router-styles");
|
|
43
43
|
styleEl.textContent = lit.css `
|
|
44
|
-
|
|
45
|
-
& > :not(
|
|
44
|
+
tp-router {
|
|
45
|
+
& > :not(tp-router-outlet) {
|
|
46
46
|
display: none;
|
|
47
47
|
}
|
|
48
48
|
}
|
|
@@ -51,13 +51,13 @@ exports.ThaRouter = class ThaRouter extends historyManaged.HistoryManaged(signal
|
|
|
51
51
|
}
|
|
52
52
|
/**
|
|
53
53
|
* Observes changes to child elements to detect when routes are added or removed.
|
|
54
|
-
* Updates the #routeEls signal whenever
|
|
54
|
+
* Updates the #routeEls signal whenever tp-route children change.
|
|
55
55
|
*/
|
|
56
56
|
#routeChildObserver = new MutationObserver((mutations) => {
|
|
57
57
|
const childListMutations = mutations.filter(mutation => mutation.type === 'childList');
|
|
58
58
|
if (!childListMutations.length)
|
|
59
59
|
return;
|
|
60
|
-
this.#routeEls.set(Array.from(this.children).filter(child => child instanceof
|
|
60
|
+
this.#routeEls.set(Array.from(this.children).filter(child => child instanceof routeElement.RouteElement).map(routeEl => new WeakRef(routeEl)));
|
|
61
61
|
});
|
|
62
62
|
/** Cleanup function for the route children rendering effect */
|
|
63
63
|
#routeChildrenEffectCleaner = noop.noop;
|
|
@@ -65,12 +65,14 @@ exports.ThaRouter = class ThaRouter extends historyManaged.HistoryManaged(signal
|
|
|
65
65
|
#historyTypeEffectCleaner = noop.noop;
|
|
66
66
|
/** Cleanup function to remove history listener */
|
|
67
67
|
#historyListenerRemover = noop.noop;
|
|
68
|
-
/** Signal containing weak references to all
|
|
68
|
+
/** Signal containing weak references to all tp-route children */
|
|
69
69
|
#routeEls = signals.signal([]);
|
|
70
70
|
/** Signal containing weak reference to the currently active route */
|
|
71
71
|
#activeRoute = signals.signal(null);
|
|
72
72
|
/** Signal containing weak reference to the assigned outlet element */
|
|
73
73
|
#outlet = signals.signal(null);
|
|
74
|
+
/** Last route marked active through SET_ACTIVE (not reactive, see #activate) */
|
|
75
|
+
#activatedRoute = null;
|
|
74
76
|
/**
|
|
75
77
|
* Lifecycle callback when the element is connected to the DOM.
|
|
76
78
|
* Sets up observers, effects, and history listeners.
|
|
@@ -83,7 +85,7 @@ exports.ThaRouter = class ThaRouter extends historyManaged.HistoryManaged(signal
|
|
|
83
85
|
this.#routeChildrenEffectCleaner = this.updateEffect(() => {
|
|
84
86
|
const activeRoute = this.#activeRoute.get()?.deref() ?? null;
|
|
85
87
|
const outlet = this.#outlet.get()?.deref() ?? null;
|
|
86
|
-
outlet?.[
|
|
88
|
+
outlet?.[routerOutletElement.RENDER_ROUTE](activeRoute);
|
|
87
89
|
});
|
|
88
90
|
// Effect to handle history type changes
|
|
89
91
|
this.#historyTypeEffectCleaner = this.updateEffect(() => {
|
|
@@ -124,15 +126,27 @@ exports.ThaRouter = class ThaRouter extends historyManaged.HistoryManaged(signal
|
|
|
124
126
|
const routes = this.#routeEls.get()
|
|
125
127
|
.map(weakRef => weakRef.deref())
|
|
126
128
|
.filter(Boolean);
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
this.#activeRoute.set(new WeakRef(route));
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
this.#activeRoute.set(null);
|
|
129
|
+
const match = routes.find(route => route[routeElement.PATH_PATTERN]?.test({ pathname: update.location.pathname })) ?? null;
|
|
130
|
+
this.#activate(match);
|
|
131
|
+
this.#activeRoute.set(match ? new WeakRef(match) : null);
|
|
135
132
|
};
|
|
133
|
+
/**
|
|
134
|
+
* Marks the matched route as active and the previous one as inactive.
|
|
135
|
+
* Re-activating the same route is intentional: it retries a failed `src`.
|
|
136
|
+
*
|
|
137
|
+
* The previous route is tracked in a plain field rather than read from
|
|
138
|
+
* the #activeRoute signal, so effects calling #handleRouteChange do not
|
|
139
|
+
* start depending on the signal they write.
|
|
140
|
+
*
|
|
141
|
+
* @param route - The matched route, or null when nothing matches
|
|
142
|
+
*/
|
|
143
|
+
#activate(route) {
|
|
144
|
+
const previous = this.#activatedRoute?.deref() ?? null;
|
|
145
|
+
if (previous && previous !== route)
|
|
146
|
+
previous[routeElement.SET_ACTIVE](false);
|
|
147
|
+
route?.[routeElement.SET_ACTIVE](true);
|
|
148
|
+
this.#activatedRoute = route ? new WeakRef(route) : null;
|
|
149
|
+
}
|
|
136
150
|
/**
|
|
137
151
|
* Lifecycle callback when the element is disconnected from the DOM.
|
|
138
152
|
* Cleans up all observers, effects, and listeners.
|
|
@@ -157,7 +171,7 @@ exports.ThaRouter = class ThaRouter extends historyManaged.HistoryManaged(signal
|
|
|
157
171
|
return this;
|
|
158
172
|
}
|
|
159
173
|
};
|
|
160
|
-
exports.
|
|
161
|
-
decorators_js.customElement("
|
|
162
|
-
], exports.
|
|
163
|
-
//# sourceMappingURL=
|
|
174
|
+
exports.RouterElement = tslib.__decorate([
|
|
175
|
+
decorators_js.customElement("tp-router")
|
|
176
|
+
], exports.RouterElement);
|
|
177
|
+
//# sourceMappingURL=router-element.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"router-element.cjs","sources":["../../../../libs/elements/src/router/router-element.ts"],"sourcesContent":[null],"names":["RouterElement","HistoryManaged","SignalWatcherLitElement","css","RouteElement","noop","signal","RENDER_ROUTE","HISTORY","defer","PATH_PATTERN","SET_ACTIVE","__decorate","customElement"],"mappings":";;;;;;;;;;;;;AA2BA;;;;;;;;;;;;;;;;;;;AAmBG;AAEUA,qBAAa,GAAnB,MAAM,aAAc,SAAQC,6BAAc,CAACC,+CAAuB,CAAC,CAAA;AACxE;;;AAGG;AACH,IAAA;QACE,MAAM,OAAO,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC;AAE/C,QAAA,OAAO,CAAC,YAAY,CAAC,MAAM,EAAE,UAAU,CAAC;AACxC,QAAA,OAAO,CAAC,YAAY,CAAC,SAAS,EAAE,kBAAkB,CAAC;AACnD,QAAA,OAAO,CAAC,WAAW,GAAGC,OAAG,CAAA;;;;;;KAMxB,CAAC,QAAQ,EAAE;AACZ,QAAA,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC;;AAGpC;;;AAGG;AACH,IAAA,mBAAmB,GAAG,IAAI,gBAAgB,CAAC,CAAC,SAAS,KAAI;AACvD,QAAA,MAAM,kBAAkB,GAAG,SAAS,CAAC,MAAM,CAAC,QAAQ,IAAI,QAAQ,CAAC,IAAI,KAAK,WAAW,CAAC;QAEtF,IAAI,CAAC,kBAAkB,CAAC,MAAM;YAAE;AAEhC,QAAA,IAAI,CAAC,SAAS,CAAC,GAAG,CAChB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,IAAI,KAAK,YAAYC,yBAAY,CAAC,CAAC,GAAG,CAAC,OAAO,IAAI,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC,CAC9G;AACH,IAAA,CAAC,CAAC;;IAGF,2BAA2B,GAAGC,SAAI;;IAElC,yBAAyB,GAAGA,SAAI;;IAEhC,uBAAuB,GAAGA,SAAI;;AAG9B,IA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CAAC,KAAK,CAAC,GAAG,IAAI;IAC1D;AAEA;;;AAGG;IACM,oBAAoB,GAAA;QAC3B,KAAK,CAAC,oBAAoB,EAAE;AAE5B,QAAA,IAAI;YACF,IAAI,CAAC,2BAA2B,EAAE;YAClC,IAAI,CAAC,yBAAyB,EAAE;QAClC;AAAE,QAAA,MAAM,cAAc;AAEtB,QAAA,IAAI,CAAC,mBAAmB,CAAC,UAAU,EAAE;QACrC,IAAI,CAAC,uBAAuB,EAAE;IAChC;AAEA;;;;;AAKG;IACgB,gBAAgB,GAAA;AACjC,QAAA,OAAO,IAAI;IACb;;AAlKWX,qBAAa,GAAAY,gBAAA,CAAA;IADzBC,2BAAa,CAAC,WAAW;AACb,CAAA,EAAAb,qBAAa,CAmKzB;;"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { __decorate } from 'tslib';
|
|
2
2
|
import { css } from 'lit';
|
|
3
3
|
import { customElement } from 'lit/decorators.js';
|
|
4
|
-
import {
|
|
4
|
+
import { RouteElement, PATH_PATTERN, SET_ACTIVE } from './route-element.js';
|
|
5
5
|
import { signal } from '@lit-labs/signals';
|
|
6
|
-
import { RENDER_ROUTE } from './
|
|
6
|
+
import { RENDER_ROUTE } from './router-outlet-element.js';
|
|
7
7
|
import { noop } from '@telperion/js-utils/function/noop';
|
|
8
8
|
import { defer } from '@telperion/js-utils/function/defer';
|
|
9
9
|
import { SignalWatcherLitElement } from '../utils/signal-watcher-lit-element.js';
|
|
@@ -13,34 +13,34 @@ import { HistoryManaged, HISTORY } from './history-managed.js';
|
|
|
13
13
|
* A custom element that manages client-side routing for single-page applications.
|
|
14
14
|
*
|
|
15
15
|
* The router watches for navigation events and matches the current URL against
|
|
16
|
-
* registered routes (
|
|
17
|
-
* in a
|
|
16
|
+
* registered routes (tp-route elements), rendering the matching route's content
|
|
17
|
+
* in a tp-router-outlet element.
|
|
18
18
|
*
|
|
19
19
|
* @example
|
|
20
20
|
* ```html
|
|
21
|
-
* <
|
|
22
|
-
* <
|
|
21
|
+
* <tp-router history="browser">
|
|
22
|
+
* <tp-route path="/">
|
|
23
23
|
* <template><h1>Home</h1></template>
|
|
24
|
-
* </
|
|
25
|
-
* <
|
|
24
|
+
* </tp-route>
|
|
25
|
+
* <tp-route path="/about">
|
|
26
26
|
* <template><h1>About</h1></template>
|
|
27
|
-
* </
|
|
28
|
-
* <
|
|
29
|
-
* </
|
|
27
|
+
* </tp-route>
|
|
28
|
+
* <tp-router-outlet></tp-router-outlet>
|
|
29
|
+
* </tp-router>
|
|
30
30
|
* ```
|
|
31
31
|
*/
|
|
32
|
-
let
|
|
32
|
+
let RouterElement = class RouterElement extends HistoryManaged(SignalWatcherLitElement) {
|
|
33
33
|
/**
|
|
34
|
-
* Injects global styles for
|
|
35
|
-
* Ensures that only
|
|
34
|
+
* Injects global styles for tp-router elements to hide non-outlet children.
|
|
35
|
+
* Ensures that only tp-router-outlet elements are visible within the router.
|
|
36
36
|
*/
|
|
37
37
|
static {
|
|
38
38
|
const styleEl = document.createElement("style");
|
|
39
39
|
styleEl.setAttribute("type", "text/css");
|
|
40
|
-
styleEl.setAttribute("data-id", "
|
|
40
|
+
styleEl.setAttribute("data-id", "tp-router-styles");
|
|
41
41
|
styleEl.textContent = css `
|
|
42
|
-
|
|
43
|
-
& > :not(
|
|
42
|
+
tp-router {
|
|
43
|
+
& > :not(tp-router-outlet) {
|
|
44
44
|
display: none;
|
|
45
45
|
}
|
|
46
46
|
}
|
|
@@ -49,13 +49,13 @@ let ThaRouter = class ThaRouter extends HistoryManaged(SignalWatcherLitElement)
|
|
|
49
49
|
}
|
|
50
50
|
/**
|
|
51
51
|
* Observes changes to child elements to detect when routes are added or removed.
|
|
52
|
-
* Updates the #routeEls signal whenever
|
|
52
|
+
* Updates the #routeEls signal whenever tp-route children change.
|
|
53
53
|
*/
|
|
54
54
|
#routeChildObserver = new MutationObserver((mutations) => {
|
|
55
55
|
const childListMutations = mutations.filter(mutation => mutation.type === 'childList');
|
|
56
56
|
if (!childListMutations.length)
|
|
57
57
|
return;
|
|
58
|
-
this.#routeEls.set(Array.from(this.children).filter(child => child instanceof
|
|
58
|
+
this.#routeEls.set(Array.from(this.children).filter(child => child instanceof RouteElement).map(routeEl => new WeakRef(routeEl)));
|
|
59
59
|
});
|
|
60
60
|
/** Cleanup function for the route children rendering effect */
|
|
61
61
|
#routeChildrenEffectCleaner = noop;
|
|
@@ -63,12 +63,14 @@ let ThaRouter = class ThaRouter extends HistoryManaged(SignalWatcherLitElement)
|
|
|
63
63
|
#historyTypeEffectCleaner = noop;
|
|
64
64
|
/** Cleanup function to remove history listener */
|
|
65
65
|
#historyListenerRemover = noop;
|
|
66
|
-
/** Signal containing weak references to all
|
|
66
|
+
/** Signal containing weak references to all tp-route children */
|
|
67
67
|
#routeEls = signal([]);
|
|
68
68
|
/** Signal containing weak reference to the currently active route */
|
|
69
69
|
#activeRoute = signal(null);
|
|
70
70
|
/** Signal containing weak reference to the assigned outlet element */
|
|
71
71
|
#outlet = signal(null);
|
|
72
|
+
/** Last route marked active through SET_ACTIVE (not reactive, see #activate) */
|
|
73
|
+
#activatedRoute = null;
|
|
72
74
|
/**
|
|
73
75
|
* Lifecycle callback when the element is connected to the DOM.
|
|
74
76
|
* Sets up observers, effects, and history listeners.
|
|
@@ -122,15 +124,27 @@ let ThaRouter = class ThaRouter extends HistoryManaged(SignalWatcherLitElement)
|
|
|
122
124
|
const routes = this.#routeEls.get()
|
|
123
125
|
.map(weakRef => weakRef.deref())
|
|
124
126
|
.filter(Boolean);
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
this.#activeRoute.set(new WeakRef(route));
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
this.#activeRoute.set(null);
|
|
127
|
+
const match = routes.find(route => route[PATH_PATTERN]?.test({ pathname: update.location.pathname })) ?? null;
|
|
128
|
+
this.#activate(match);
|
|
129
|
+
this.#activeRoute.set(match ? new WeakRef(match) : null);
|
|
133
130
|
};
|
|
131
|
+
/**
|
|
132
|
+
* Marks the matched route as active and the previous one as inactive.
|
|
133
|
+
* Re-activating the same route is intentional: it retries a failed `src`.
|
|
134
|
+
*
|
|
135
|
+
* The previous route is tracked in a plain field rather than read from
|
|
136
|
+
* the #activeRoute signal, so effects calling #handleRouteChange do not
|
|
137
|
+
* start depending on the signal they write.
|
|
138
|
+
*
|
|
139
|
+
* @param route - The matched route, or null when nothing matches
|
|
140
|
+
*/
|
|
141
|
+
#activate(route) {
|
|
142
|
+
const previous = this.#activatedRoute?.deref() ?? null;
|
|
143
|
+
if (previous && previous !== route)
|
|
144
|
+
previous[SET_ACTIVE](false);
|
|
145
|
+
route?.[SET_ACTIVE](true);
|
|
146
|
+
this.#activatedRoute = route ? new WeakRef(route) : null;
|
|
147
|
+
}
|
|
134
148
|
/**
|
|
135
149
|
* Lifecycle callback when the element is disconnected from the DOM.
|
|
136
150
|
* Cleans up all observers, effects, and listeners.
|
|
@@ -155,9 +169,9 @@ let ThaRouter = class ThaRouter extends HistoryManaged(SignalWatcherLitElement)
|
|
|
155
169
|
return this;
|
|
156
170
|
}
|
|
157
171
|
};
|
|
158
|
-
|
|
159
|
-
customElement("
|
|
160
|
-
],
|
|
172
|
+
RouterElement = __decorate([
|
|
173
|
+
customElement("tp-router")
|
|
174
|
+
], RouterElement);
|
|
161
175
|
|
|
162
|
-
export {
|
|
163
|
-
//# sourceMappingURL=
|
|
176
|
+
export { RouterElement };
|
|
177
|
+
//# sourceMappingURL=router-element.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"router-element.js","sources":["../../../../libs/elements/src/router/router-element.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;;;AA2BA;;;;;;;;;;;;;;;;;;;AAmBG;AAEI,IAAM,aAAa,GAAnB,MAAM,aAAc,SAAQ,cAAc,CAAC,uBAAuB,CAAC,CAAA;AACxE;;;AAGG;AACH,IAAA;QACE,MAAM,OAAO,GAAG,QAAQ,CA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lKW,aAAa,GAAA,UAAA,CAAA;IADzB,aAAa,CAAC,WAAW;AACb,CAAA,EAAA,aAAa,CAmKzB;;;;"}
|
|
@@ -22,18 +22,18 @@ var signalWatcherLitElement = require('../utils/signal-watcher-lit-element.cjs')
|
|
|
22
22
|
* @example
|
|
23
23
|
* ```html
|
|
24
24
|
* <!-- Absolute path -->
|
|
25
|
-
* <
|
|
25
|
+
* <tp-router-link to="/about">About</tp-router-link>
|
|
26
26
|
*
|
|
27
27
|
* <!-- Relative path -->
|
|
28
|
-
* <
|
|
29
|
-
* <
|
|
28
|
+
* <tp-router-link to="./details">Details</tp-router-link>
|
|
29
|
+
* <tp-router-link to="../users">Back to Users</tp-router-link>
|
|
30
30
|
*
|
|
31
31
|
* <!-- History navigation -->
|
|
32
|
-
* <
|
|
33
|
-
* <
|
|
32
|
+
* <tp-router-link to="back">← Back</tp-router-link>
|
|
33
|
+
* <tp-router-link to="forward">Forward →</tp-router-link>
|
|
34
34
|
* ```
|
|
35
35
|
*/
|
|
36
|
-
exports.
|
|
36
|
+
exports.RouterLinkElement = class RouterLinkElement extends historyManaged.HistoryManaged(signalWatcherLitElement.SignalWatcherLitElement) {
|
|
37
37
|
constructor() {
|
|
38
38
|
super(...arguments);
|
|
39
39
|
/**
|
|
@@ -108,13 +108,13 @@ exports.ThaRouterLink = class ThaRouterLink extends historyManaged.HistoryManage
|
|
|
108
108
|
this[historyManaged.HISTORY].get()?.push(link || '/');
|
|
109
109
|
};
|
|
110
110
|
}
|
|
111
|
-
/** Injects global styles for
|
|
111
|
+
/** Injects global styles for tp-router-link elements to show pointer cursor */
|
|
112
112
|
static {
|
|
113
113
|
const styleEl = document.createElement("style");
|
|
114
114
|
styleEl.setAttribute("type", "text/css");
|
|
115
|
-
styleEl.setAttribute("data-id", "
|
|
115
|
+
styleEl.setAttribute("data-id", "tp-router-link-styles");
|
|
116
116
|
styleEl.textContent = lit.css `
|
|
117
|
-
|
|
117
|
+
tp-router-link {
|
|
118
118
|
cursor: pointer;
|
|
119
119
|
}
|
|
120
120
|
`.toString();
|
|
@@ -198,12 +198,12 @@ exports.ThaRouterLink = class ThaRouterLink extends historyManaged.HistoryManage
|
|
|
198
198
|
tslib.__decorate([
|
|
199
199
|
decorators_js.property({ type: String }),
|
|
200
200
|
tslib.__metadata("design:type", Object)
|
|
201
|
-
], exports.
|
|
201
|
+
], exports.RouterLinkElement.prototype, "to", void 0);
|
|
202
202
|
tslib.__decorate([
|
|
203
203
|
decorators_js.property({ type: Boolean, reflect: true }),
|
|
204
204
|
tslib.__metadata("design:type", Object)
|
|
205
|
-
], exports.
|
|
206
|
-
exports.
|
|
207
|
-
decorators_js.customElement("
|
|
208
|
-
], exports.
|
|
209
|
-
//# sourceMappingURL=
|
|
205
|
+
], exports.RouterLinkElement.prototype, "active", void 0);
|
|
206
|
+
exports.RouterLinkElement = tslib.__decorate([
|
|
207
|
+
decorators_js.customElement("tp-router-link")
|
|
208
|
+
], exports.RouterLinkElement);
|
|
209
|
+
//# sourceMappingURL=router-link-element.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"router-link-element.cjs","sources":["../../../../libs/elements/src/router/router-link-element.ts"],"sourcesContent":[null],"names":["RouterLinkElement","HistoryManaged","SignalWatcherLitElement","noop","signal","computed","HISTORY","HISTORY_TYPE","compact","css","__decorate","property","customElement"],"mappings":";;;;;;;;;;;AA8BA;;;;;;;;;;;;;;;;;;;;;;;AAuBG;AAEUA,yBAAiB,GAAvB,MAAM,iBAAkB,SAAQC,6BAAc,CAACC,+CAAuB,CAAC,CAAA;AAAvE,IAAA,WAAA,GAAA;;AAeL;;;;;;;AAOG;QAEH,IAAA,CAAA,EAAE,GAAoB,IAAI;AAE1B;;;;;;AAMG;QAEH,IAAA,CAAA,MAAM,GAAG,KAAK;;QAGd,IAAA,CAAA,yBAAyB,GAAGC,SAAI;;QAEhC,IAAA,CAAA,uBAAuB,GAAGA,SAAI;;AAG9B,QAAA,IAAA,CAAA,GAAG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