@telperion/elements 1.0.0 → 1.1.1

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 (121) hide show
  1. package/.build-manifest.json +61 -0
  2. package/README.md +34 -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/drag-drop/index.js +73 -0
  46. package/iife/drag-drop/index.js.map +1 -0
  47. package/iife/elements.js +180 -0
  48. package/iife/elements.js.map +1 -0
  49. package/iife/icon/index.js +35 -0
  50. package/iife/icon/index.js.map +1 -0
  51. package/iife/router/index.js +142 -0
  52. package/iife/router/index.js.map +1 -0
  53. package/index.cjs +53 -11
  54. package/index.cjs.map +1 -0
  55. package/index.d.cts +6 -0
  56. package/index.d.ts +6 -6
  57. package/index.js +10 -9
  58. package/index.js.map +1 -1
  59. package/package.json +45 -83
  60. package/router/history-managed.cjs +22 -18
  61. package/router/history-managed.cjs.map +1 -0
  62. package/router/history-managed.js +9 -7
  63. package/router/history-managed.js.map +1 -1
  64. package/router/history.cjs +20 -16
  65. package/router/history.cjs.map +1 -0
  66. package/router/history.js +8 -6
  67. package/router/history.js.map +1 -1
  68. package/router/index.cjs +36 -15
  69. package/router/index.cjs.map +1 -0
  70. package/router/index.d.cts +895 -0
  71. package/router/index.d.ts +895 -6
  72. package/router/index.js +6 -7
  73. package/router/index.js.map +1 -1
  74. package/router/signal-watcher-lit-element.cjs +9 -6
  75. package/router/signal-watcher-lit-element.cjs.map +1 -0
  76. package/router/signal-watcher-lit-element.js +5 -3
  77. package/router/signal-watcher-lit-element.js.map +1 -1
  78. package/router/tha-route.cjs +25 -22
  79. package/router/tha-route.cjs.map +1 -0
  80. package/router/tha-route.js +8 -7
  81. package/router/tha-route.js.map +1 -1
  82. package/router/tha-router-config.cjs +17 -17
  83. package/router/tha-router-config.cjs.map +1 -0
  84. package/router/tha-router-config.js +8 -7
  85. package/router/tha-router-config.js.map +1 -1
  86. package/router/tha-router-link.cjs +36 -36
  87. package/router/tha-router-link.cjs.map +1 -0
  88. package/router/tha-router-link.js +9 -8
  89. package/router/tha-router-link.js.map +1 -1
  90. package/router/tha-router-outlet.cjs +51 -48
  91. package/router/tha-router-outlet.cjs.map +1 -0
  92. package/router/tha-router-outlet.js +12 -11
  93. package/router/tha-router-outlet.js.map +1 -1
  94. package/router/tha-router-param.cjs +21 -21
  95. package/router/tha-router-param.cjs.map +1 -0
  96. package/router/tha-router-param.js +7 -6
  97. package/router/tha-router-param.js.map +1 -1
  98. package/router/tha-router.cjs +33 -33
  99. package/router/tha-router.cjs.map +1 -0
  100. package/router/tha-router.js +11 -10
  101. package/router/tha-router.js.map +1 -1
  102. package/bundle.js +0 -164
  103. package/bundle.mjs +0 -2630
  104. package/drag-drop/drag-handle-element.d.ts +0 -12
  105. package/drag-drop/dropzone-element.d.ts +0 -17
  106. package/drag-drop/private-props.d.ts +0 -3
  107. package/drag-drop/tha-drag-event.d.ts +0 -19
  108. package/icon/icon-element.d.ts +0 -40
  109. package/router/history-managed.d.ts +0 -76
  110. package/router/history.d.ts +0 -48
  111. package/router/signal-watcher-lit-element.d.ts +0 -25
  112. package/router/tha-route.d.ts +0 -90
  113. package/router/tha-router-config.d.ts +0 -223
  114. package/router/tha-router-link.d.ts +0 -95
  115. package/router/tha-router-outlet.d.ts +0 -112
  116. package/router/tha-router-param.d.ts +0 -226
  117. package/router/tha-router.d.ts +0 -69
  118. package/tha-url-output.cjs +0 -79
  119. package/tha-url-output.d.ts +0 -41
  120. package/tha-url-output.js +0 -78
  121. package/tha-url-output.js.map +0 -1
@@ -1,112 +0,0 @@
1
- import type { ThaRouter } from "./tha-router";
2
- import { ThaRoute } from "./tha-route";
3
- import { SignalWatcherLitElement } from "./signal-watcher-lit-element";
4
- declare global {
5
- interface HTMLElementTagNameMap {
6
- /**
7
- * An outlet element that renders the active route's content from a tha-router.
8
- * It automatically binds to the nearest parent tha-router or to a specific router via the `for` attribute.
9
- * The outlet clones and renders the template content from the active tha-route element.
10
- * The `routePath` and `routeID` attributes reflect the current route's path and ID.
11
- */
12
- "tha-router-outlet": ThaRouterOutlet;
13
- }
14
- }
15
- /**
16
- * Symbol used by the router to call the internal render method on the outlet.
17
- * @internal
18
- */
19
- export declare const RENDER_ROUTE: unique symbol;
20
- export declare const PARAMS: unique symbol;
21
- /**
22
- * A custom element that serves as a rendering target for router content.
23
- *
24
- * The outlet automatically binds to its parent tha-router or to a specific router
25
- * identified by the `for` attribute. When the router's active route changes,
26
- * the outlet clones and renders the route's template content.
27
- *
28
- * @example
29
- * ```html
30
- * <tha-router>
31
- * <tha-route path="/"><template><h1>Home</h1></template></tha-route>
32
- * <tha-router-outlet></tha-router-outlet>
33
- * </tha-router>
34
- * ```
35
- *
36
- * @example
37
- * ```html
38
- * <!-- Bind to a specific router by ID -->
39
- * <tha-router id="main-router">
40
- * <tha-route path="/"><template><h1>Home</h1></template></tha-route>
41
- * </tha-router>
42
- * <tha-router-outlet for="main-router"></tha-router-outlet>
43
- * ```
44
- */
45
- export declare class ThaRouterOutlet extends SignalWatcherLitElement {
46
- #private;
47
- [PARAMS]: import("@lit-labs/signals").Signal.Computed<Readonly<{
48
- [x: string]: string | undefined;
49
- }>>;
50
- params: Record<string, string | undefined>;
51
- /**
52
- * The ID of a specific tha-router element to bind to.
53
- * If not set, binds to the nearest parent tha-router.
54
- *
55
- * @attr for
56
- */
57
- for: string | null;
58
- /**
59
- * Reflects the path attribute of the currently active route.
60
- * Automatically updated when the active route changes.
61
- *
62
- * @attr routepath
63
- * @readonly
64
- */
65
- routePath: string | null;
66
- /**
67
- * Reflects the ID of the currently active route.
68
- * Automatically updated when the active route changes.
69
- *
70
- * @attr routeid
71
- * @readonly
72
- */
73
- routeID: string | undefined;
74
- /**
75
- * Lifecycle callback when the element is connected to the DOM.
76
- * Initializes the outlet and binds to a router.
77
- */
78
- connectedCallback(): void;
79
- /**
80
- * Binds this outlet to a tha-router element.
81
- *
82
- * If no router is provided, automatically searches for one:
83
- * - If `for` attribute is set, finds router by ID in the same root
84
- * - Otherwise, finds the nearest parent tha-router
85
- *
86
- * Unbinds from the previous router if already bound to a different one.
87
- *
88
- * @param router - Optional router to bind to
89
- * @returns The bound router, or null if no router found
90
- */
91
- bindToRouter(): ThaRouter | null;
92
- /**
93
- * Internal method called by the router to set the active route.
94
- * Updates the routeToRender signal which triggers re-rendering.
95
- *
96
- * @param route - The route to render, or null to clear
97
- * @internal
98
- */
99
- [RENDER_ROUTE](route: ThaRoute | null): void;
100
- /**
101
- * Lifecycle callback when the element is disconnected from the DOM.
102
- * Unbinds from the router and cleans up effects.
103
- */
104
- disconnectedCallback(): void;
105
- /**
106
- * Creates the render root for the element.
107
- * Returns the element itself to render content in light DOM.
108
- *
109
- * @returns The element itself (not a shadow root)
110
- */
111
- protected createRenderRoot(): this;
112
- }
@@ -1,226 +0,0 @@
1
- /**
2
- * @fileoverview Router parameter display component
3
- *
4
- * Provides a declarative way to display dynamic route parameter values
5
- * directly in HTML templates without requiring JavaScript.
6
- *
7
- * @module router/tha-router-param
8
- */
9
- import { SignalWatcherLitElement } from "./signal-watcher-lit-element";
10
- declare global {
11
- interface HTMLElementTagNameMap {
12
- /**
13
- * A component that displays the value of a route parameter.
14
- *
15
- * Must be used within a tha-router-outlet element. Automatically
16
- * updates when route parameters change.
17
- */
18
- 'tha-router-param': ThaRouterParam;
19
- }
20
- }
21
- /**
22
- * Custom element for displaying dynamic route parameter values.
23
- *
24
- * This component provides a declarative way to access and display URL
25
- * parameters extracted from dynamic route segments without writing JavaScript.
26
- * It must be used inside a `<tha-router-outlet>` element.
27
- *
28
- * ## Features
29
- *
30
- * - **Declarative**: Access params directly in HTML
31
- * - **Reactive**: Automatically updates when route changes
32
- * - **Hierarchical**: Inherits params from parent outlets
33
- * - **Type-safe**: Integrated with TypeScript definitions
34
- *
35
- * ## Usage
36
- *
37
- * ### Basic Parameter Display
38
- *
39
- * ```html
40
- * <tha-router>
41
- * <tha-route path="/users/:id">
42
- * <template>
43
- * <h1>User Profile</h1>
44
- * <p>User ID: <tha-router-param name="id"></tha-router-param></p>
45
- * </template>
46
- * </tha-route>
47
- * <tha-router-outlet></tha-router-outlet>
48
- * </tha-router>
49
- * ```
50
- *
51
- * When navigating to `/users/123`, the component renders: `User ID: 123`
52
- *
53
- * ### Multiple Parameters
54
- *
55
- * ```html
56
- * <tha-route path="/blog/:year/:month/:slug">
57
- * <template>
58
- * <article>
59
- * <header>
60
- * <time>
61
- * <tha-router-param name="year"></tha-router-param>-
62
- * <tha-router-param name="month"></tha-router-param>
63
- * </time>
64
- * <h1><tha-router-param name="slug"></tha-router-param></h1>
65
- * </header>
66
- * </article>
67
- * </template>
68
- * </tha-route>
69
- * ```
70
- *
71
- * For `/blog/2024/12/hello-world`, renders:
72
- * ```html
73
- * <time>2024-12</time>
74
- * <h1>hello-world</h1>
75
- * ```
76
- *
77
- * ### Nested Routes with Parameter Inheritance
78
- *
79
- * ```html
80
- * <tha-router>
81
- * <tha-route path="/projects/:projectId">
82
- * <template>
83
- * <h1>Project <tha-router-param name="projectId"></tha-router-param></h1>
84
- *
85
- * <!-- Nested outlet inherits projectId parameter -->
86
- * <tha-router-outlet>
87
- * <tha-route path="/tasks/:taskId">
88
- * <template>
89
- * <!-- Both params are available -->
90
- * <h2>Task Details</h2>
91
- * <p>Project: <tha-router-param name="projectId"></tha-router-param></p>
92
- * <p>Task: <tha-router-param name="taskId"></tha-router-param></p>
93
- * </template>
94
- * </tha-route>
95
- * </tha-router-outlet>
96
- * </template>
97
- * </tha-route>
98
- * <tha-router-outlet></tha-router-outlet>
99
- * </tha-router>
100
- * ```
101
- *
102
- * ### With Styling
103
- *
104
- * ```html
105
- * <style>
106
- * tha-router-param {
107
- * font-weight: bold;
108
- * color: var(--primary-color);
109
- * }
110
- *
111
- * tha-router-param[name="id"] {
112
- * font-family: monospace;
113
- * }
114
- * </style>
115
- *
116
- * <tha-route path="/users/:id">
117
- * <template>
118
- * <span>User: <tha-router-param name="id"></tha-router-param></span>
119
- * </template>
120
- * </tha-route>
121
- * ```
122
- *
123
- * ## How It Works
124
- *
125
- * 1. On connection, finds the nearest parent `<tha-router-outlet>`
126
- * 2. Accesses the outlet's PARAMS signal containing all route parameters
127
- * 3. Computes and displays the value for the specified parameter name
128
- * 4. Automatically re-renders when the route (and thus params) change
129
- *
130
- * ## Error Handling
131
- *
132
- * Throws an error if not placed within a `<tha-router-outlet>`:
133
- *
134
- * ```javascript
135
- * // ✗ Wrong - not inside outlet
136
- * <tha-router-param name="id"></tha-router-param>
137
- *
138
- * // ✓ Correct - inside outlet
139
- * <tha-router-outlet>
140
- * <tha-router-param name="id"></tha-router-param>
141
- * </tha-router-outlet>
142
- * ```
143
- *
144
- * ## Alternative: Using Attributes
145
- *
146
- * The parent `<tha-router-outlet>` also exposes parameters as `param-*` attributes,
147
- * which can be used as an alternative approach:
148
- *
149
- * ```html
150
- * <tha-router-outlet id="outlet">
151
- * <script>
152
- * const outlet = document.getElementById('outlet');
153
- * // Params available as: outlet.getAttribute('param-id')
154
- * </script>
155
- * </tha-router-outlet>
156
- * ```
157
- *
158
- * However, `<tha-router-param>` is preferred for declarative templates.
159
- *
160
- * @example Basic usage
161
- * ```html
162
- * <tha-router>
163
- * <tha-route path="/product/:sku">
164
- * <template>
165
- * <h1>Product: <tha-router-param name="sku"></tha-router-param></h1>
166
- * </template>
167
- * </tha-route>
168
- * <tha-router-outlet></tha-router-outlet>
169
- * </tha-router>
170
- * ```
171
- *
172
- * @example Multiple params with formatting
173
- * ```html
174
- * <tha-route path="/user/:username/post/:postId">
175
- * <template>
176
- * <article>
177
- * <p>@<tha-router-param name="username"></tha-router-param></p>
178
- * <p>Post #<tha-router-param name="postId"></tha-router-param></p>
179
- * </article>
180
- * </template>
181
- * </tha-route>
182
- * ```
183
- */
184
- export declare class ThaRouterParam extends SignalWatcherLitElement {
185
- #private;
186
- /**
187
- * The name of the route parameter to display.
188
- *
189
- * Must match a parameter name defined in the route's path pattern.
190
- * For example, for path `/users/:id`, use `name="id"`.
191
- *
192
- * @attr name
193
- * @type {string}
194
- */
195
- name: string;
196
- /**
197
- * Lifecycle callback when element is connected to the DOM.
198
- *
199
- * Finds the parent `<tha-router-outlet>` and stores a reference.
200
- * Throws an error if not used within an outlet.
201
- *
202
- * @throws {Error} If no parent tha-router-outlet is found
203
- */
204
- connectedCallback(): void;
205
- /**
206
- * Lifecycle callback when observed attributes change.
207
- *
208
- * Updates the internal name signal when the 'name' attribute changes,
209
- * which triggers the computed value signal to recalculate and re-render.
210
- *
211
- * @param name - The attribute name that changed
212
- * @param _old - Previous attribute value (unused)
213
- * @param value - New attribute value
214
- */
215
- attributeChangedCallback(name: string, _old: string | null, value: string | null): void;
216
- /**
217
- * Renders the parameter value.
218
- *
219
- * The value is extracted from the outlet's params signal and
220
- * displayed as text content. Automatically updates when the
221
- * route changes.
222
- *
223
- * @returns The parameter value as a template result
224
- */
225
- protected render(): import("lit").TemplateResult;
226
- }
@@ -1,69 +0,0 @@
1
- import { LitElement } from "lit";
2
- import { ThaRouterOutlet } from "./tha-router-outlet";
3
- declare global {
4
- interface HTMLElementTagNameMap {
5
- /**
6
- * A router element that manages client-side routing for single-page applications.
7
- * It watches for navigation events and matches the current URL against registered routes
8
- * (tha-route elements), rendering the matching route's content in a tha-router-outlet element.
9
- * The `history` attribute specifies the history management strategy:
10
- * - 'browser' for HTML5 History API (default)
11
- * - 'hash' for hash-based routing
12
- * - 'memory' for in-memory history (testing)
13
- * - 'memory:name' for named memory history instances
14
- */
15
- "tha-router": ThaRouter;
16
- }
17
- }
18
- declare const ThaRouter_base: (new (...args: any[]) => import("./history-managed").HistoryManagedLitElementType) & (new () => LitElement & {
19
- updateEffect(fn: () => void, options?: import("./signal-watcher-lit-element").EffectOptions): () => void;
20
- });
21
- /**
22
- * A custom element that manages client-side routing for single-page applications.
23
- *
24
- * The router watches for navigation events and matches the current URL against
25
- * registered routes (tha-route elements), rendering the matching route's content
26
- * in a tha-router-outlet element.
27
- *
28
- * @example
29
- * ```html
30
- * <tha-router history="browser">
31
- * <tha-route path="/">
32
- * <template><h1>Home</h1></template>
33
- * </tha-route>
34
- * <tha-route path="/about">
35
- * <template><h1>About</h1></template>
36
- * </tha-route>
37
- * <tha-router-outlet></tha-router-outlet>
38
- * </tha-router>
39
- * ```
40
- */
41
- export declare class ThaRouter extends ThaRouter_base {
42
- #private;
43
- /**
44
- * Lifecycle callback when the element is connected to the DOM.
45
- * Sets up observers, effects, and history listeners.
46
- */
47
- connectedCallback(): void;
48
- /**
49
- * Assigns a router outlet to this router.
50
- * The outlet will be used to render the active route's content.
51
- *
52
- * @param outlet - The outlet element to assign, or null to unassign
53
- * @internal
54
- */
55
- assignOutlet(outlet: ThaRouterOutlet | null): void;
56
- /**
57
- * Lifecycle callback when the element is disconnected from the DOM.
58
- * Cleans up all observers, effects, and listeners.
59
- */
60
- disconnectedCallback(): void;
61
- /**
62
- * Creates the render root for the element.
63
- * Returns the element itself to render children in light DOM.
64
- *
65
- * @returns The element itself (not a shadow root)
66
- */
67
- protected createRenderRoot(): this;
68
- }
69
- export {};
@@ -1,79 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ThaUrlOutput = void 0;
4
- const tslib_1 = require("tslib");
5
- const decorators_js_1 = require("lit/decorators.js");
6
- const signals_1 = require("@lit-labs/signals");
7
- const history_managed_1 = require("../src/router/history-managed");
8
- const signal_watcher_lit_element_1 = require("../src/router/signal-watcher-lit-element");
9
- const noop_1 = require("@telperion/js-utils/function/noop");
10
- /**
11
- * A custom element for displaying router history URL and actual browser URL.
12
- *
13
- * This component is useful for debugging and demonstrations to visualize:
14
- * - The URL from the router's history object (pathname + search + hash)
15
- * - The actual browser window URL (from window.location)
16
- *
17
- * This helps understand the difference between router-managed navigation
18
- * (especially with memory or hash history) and the browser's actual location.
19
- *
20
- * @example
21
- * ```html
22
- * <!-- Show URLs for browser history -->
23
- * <tha-url-output history="browser"></tha-url-output>
24
- *
25
- * <!-- Show URLs for hash history -->
26
- * <tha-url-output history="hash"></tha-url-output>
27
- *
28
- * <!-- Show URLs for memory history (browser URL won't change) -->
29
- * <tha-url-output history="memory"></tha-url-output>
30
- * ```
31
- */
32
- let ThaUrlOutput = class ThaUrlOutput extends (0, history_managed_1.HistoryManaged)(signal_watcher_lit_element_1.SignalWatcherLitElement) {
33
- #historyChangeUnsubscribe = noop_1.noop;
34
- #historyEventsUnsubscribe = noop_1.noop;
35
- #browserUrl = (0, signals_1.signal)(location.href);
36
- #historyUrl = (0, signals_1.signal)(this[history_managed_1.HISTORY].get().location.pathname + this[history_managed_1.HISTORY].get().location.search + this[history_managed_1.HISTORY].get().location.hash);
37
- connectedCallback() {
38
- super.connectedCallback();
39
- addEventListener('popstate', this.#onLocationChange);
40
- addEventListener('pushstate', this.#onLocationChange);
41
- addEventListener('hashchange', this.#onLocationChange);
42
- this.#historyChangeUnsubscribe = this.updateEffect(() => {
43
- const history = this[history_managed_1.HISTORY].get();
44
- this.#historyUrl.set(history.location.pathname + history.location.search + history.location.hash);
45
- this.#historyEventsUnsubscribe();
46
- this.#historyEventsUnsubscribe = history.listen(({ location }) => {
47
- this.#historyUrl.set(location.pathname + location.search + location.hash);
48
- });
49
- });
50
- }
51
- render() {
52
- return (0, signals_1.html) `
53
- <div>
54
- <strong>History URL:</strong> ${this.#historyUrl}
55
- </div>
56
- <div>
57
- <strong>Browser URL:</strong> ${this.#browserUrl}
58
- </div>
59
- `;
60
- }
61
- #onLocationChange = () => {
62
- this.#browserUrl.set(window.location.href);
63
- };
64
- disconnectedCallback() {
65
- super.disconnectedCallback();
66
- removeEventListener('popstate', this.#onLocationChange);
67
- removeEventListener('pushstate', this.#onLocationChange);
68
- removeEventListener('hashchange', this.#onLocationChange);
69
- this.#historyEventsUnsubscribe();
70
- try {
71
- this.#historyChangeUnsubscribe();
72
- }
73
- catch { }
74
- }
75
- };
76
- exports.ThaUrlOutput = ThaUrlOutput;
77
- exports.ThaUrlOutput = ThaUrlOutput = tslib_1.__decorate([
78
- (0, decorators_js_1.customElement)('tha-url-output')
79
- ], ThaUrlOutput);
@@ -1,41 +0,0 @@
1
- declare global {
2
- interface HTMLElementTagNameMap {
3
- /**
4
- * A debugging component that displays the current history URL and the actual browser URL.
5
- * Useful for understanding the difference between router state and browser location.
6
- */
7
- "tha-url-output": ThaUrlOutput;
8
- }
9
- }
10
- declare const ThaUrlOutput_base: (new (...args: any[]) => import("../src/router/history-managed").HistoryManagedLitElementType) & (new () => import("lit").LitElement & {
11
- updateEffect(fn: () => void, options?: import("../src/router/signal-watcher-lit-element").EffectOptions): () => void;
12
- });
13
- /**
14
- * A custom element for displaying router history URL and actual browser URL.
15
- *
16
- * This component is useful for debugging and demonstrations to visualize:
17
- * - The URL from the router's history object (pathname + search + hash)
18
- * - The actual browser window URL (from window.location)
19
- *
20
- * This helps understand the difference between router-managed navigation
21
- * (especially with memory or hash history) and the browser's actual location.
22
- *
23
- * @example
24
- * ```html
25
- * <!-- Show URLs for browser history -->
26
- * <tha-url-output history="browser"></tha-url-output>
27
- *
28
- * <!-- Show URLs for hash history -->
29
- * <tha-url-output history="hash"></tha-url-output>
30
- *
31
- * <!-- Show URLs for memory history (browser URL won't change) -->
32
- * <tha-url-output history="memory"></tha-url-output>
33
- * ```
34
- */
35
- export declare class ThaUrlOutput extends ThaUrlOutput_base {
36
- #private;
37
- connectedCallback(): void;
38
- protected render(): import("lit").TemplateResult;
39
- disconnectedCallback(): void;
40
- }
41
- export {};
package/tha-url-output.js DELETED
@@ -1,78 +0,0 @@
1
- import { __decorate } from "tslib";
2
- import { customElement } from "lit/decorators.js";
3
- import { html, signal } from "@lit-labs/signals";
4
- import { HISTORY, HistoryManaged } from "../src/router/history-managed";
5
- import { SignalWatcherLitElement } from "../src/router/signal-watcher-lit-element";
6
- import { noop } from "@telperion/js-utils/function/noop";
7
- /**
8
- * A custom element for displaying router history URL and actual browser URL.
9
- *
10
- * This component is useful for debugging and demonstrations to visualize:
11
- * - The URL from the router's history object (pathname + search + hash)
12
- * - The actual browser window URL (from window.location)
13
- *
14
- * This helps understand the difference between router-managed navigation
15
- * (especially with memory or hash history) and the browser's actual location.
16
- *
17
- * @example
18
- * ```html
19
- * <!-- Show URLs for browser history -->
20
- * <tha-url-output history="browser"></tha-url-output>
21
- *
22
- * <!-- Show URLs for hash history -->
23
- * <tha-url-output history="hash"></tha-url-output>
24
- *
25
- * <!-- Show URLs for memory history (browser URL won't change) -->
26
- * <tha-url-output history="memory"></tha-url-output>
27
- * ```
28
- */
29
- let ThaUrlOutput = class ThaUrlOutput extends HistoryManaged(SignalWatcherLitElement) {
30
- #historyChangeUnsubscribe = noop;
31
- #historyEventsUnsubscribe = noop;
32
- #browserUrl = signal(location.href);
33
- #historyUrl = signal(this[HISTORY].get().location.pathname + this[HISTORY].get().location.search + this[HISTORY].get().location.hash);
34
- connectedCallback() {
35
- super.connectedCallback();
36
- addEventListener('popstate', this.#onLocationChange);
37
- addEventListener('pushstate', this.#onLocationChange);
38
- addEventListener('hashchange', this.#onLocationChange);
39
- this.#historyChangeUnsubscribe = this.updateEffect(() => {
40
- const history = this[HISTORY].get();
41
- this.#historyUrl.set(history.location.pathname + history.location.search + history.location.hash);
42
- this.#historyEventsUnsubscribe();
43
- this.#historyEventsUnsubscribe = history.listen(({ location }) => {
44
- this.#historyUrl.set(location.pathname + location.search + location.hash);
45
- });
46
- });
47
- }
48
- render() {
49
- return html `
50
- <div>
51
- <strong>History URL:</strong> ${this.#historyUrl}
52
- </div>
53
- <div>
54
- <strong>Browser URL:</strong> ${this.#browserUrl}
55
- </div>
56
- `;
57
- }
58
- #onLocationChange = () => {
59
- this.#browserUrl.set(window.location.href);
60
- };
61
- disconnectedCallback() {
62
- super.disconnectedCallback();
63
- removeEventListener('popstate', this.#onLocationChange);
64
- removeEventListener('pushstate', this.#onLocationChange);
65
- removeEventListener('hashchange', this.#onLocationChange);
66
- this.#historyEventsUnsubscribe();
67
- try {
68
- this.#historyChangeUnsubscribe();
69
- }
70
- catch { }
71
- }
72
- };
73
- ThaUrlOutput = __decorate([
74
- customElement('tha-url-output')
75
- ], ThaUrlOutput);
76
- export { ThaUrlOutput };
77
-
78
- //# sourceMappingURL=tha-url-output.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../libs/elements/.storybook/tha-url-output.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,EAAS,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AACxE,OAAO,EAAE,uBAAuB,EAAE,MAAM,0CAA0C,CAAC;AACnF,OAAO,EAAE,IAAI,EAAE,MAAM,mCAAmC,CAAC;AAYzD;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEI,IAAM,YAAY,GAAlB,MAAM,YAAa,SAAQ,cAAc,CAAC,uBAAuB,CAAC;IACvE,yBAAyB,GAAG,IAAI,CAAC;IACjC,yBAAyB,GAAG,IAAI,CAAC;IAEjC,WAAW,GAAG,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IACpC,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,EAAG,CAAC,QAAQ,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,EAAG,CAAC,QAAQ,CAAC,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,EAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAEhI,iBAAiB;QACxB,KAAK,CAAC,iBAAiB,EAAE,CAAC;QAE1B,gBAAgB,CAAC,UAAU,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;QACrD,gBAAgB,CAAC,WAAW,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;QACtD,gBAAgB,CAAC,YAAY,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;QAEvD,IAAI,CAAC,yBAAyB,GAAG,IAAI,CAAC,YAAY,CAAC,GAAG,EAAE;YACtD,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,CAAC;YAEpC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;YAElG,IAAI,CAAC,yBAAyB,EAAE,CAAC;YACjC,IAAI,CAAC,yBAAyB,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE;gBAC/D,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,QAAQ,CAAC,QAAQ,GAAG,QAAQ,CAAC,MAAM,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;YAC5E,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAA;IACJ,CAAC;IAEkB,MAAM;QACvB,OAAO,IAAI,CAAA;;wCAEyB,IAAI,CAAC,WAAW;;;wCAGhB,IAAI,CAAC,WAAW;;KAEnD,CAAC;IACJ,CAAC;IAED,iBAAiB,GAAG,GAAG,EAAE;QACvB,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC7C,CAAC,CAAC;IAEO,oBAAoB;QAC3B,KAAK,CAAC,oBAAoB,EAAE,CAAC;QAE7B,mBAAmB,CAAC,UAAU,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;QACxD,mBAAmB,CAAC,WAAW,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;QACzD,mBAAmB,CAAC,YAAY,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;QAE1D,IAAI,CAAC,yBAAyB,EAAE,CAAC;QAEjC,IAAI,CAAC;YACH,IAAI,CAAC,yBAAyB,EAAE,CAAC;QACnC,CAAC;QAAC,MAAM,CAAC,CAAA,CAAC;IACZ,CAAC;CACF,CAAA;AAtDY,YAAY;IADxB,aAAa,CAAC,gBAAgB,CAAC;GACnB,YAAY,CAsDxB","file":"tha-url-output.js","sourcesContent":["import { customElement } from \"lit/decorators.js\";\nimport { html, signal, watch } from \"@lit-labs/signals\";\nimport { HISTORY, HistoryManaged } from \"../src/router/history-managed\";\nimport { SignalWatcherLitElement } from \"../src/router/signal-watcher-lit-element\";\nimport { noop } from \"@telperion/js-utils/function/noop\";\n\ndeclare global {\n interface HTMLElementTagNameMap {\n /**\n * A debugging component that displays the current history URL and the actual browser URL.\n * Useful for understanding the difference between router state and browser location.\n */\n \"tha-url-output\": ThaUrlOutput;\n }\n}\n\n/**\n * A custom element for displaying router history URL and actual browser URL.\n *\n * This component is useful for debugging and demonstrations to visualize:\n * - The URL from the router's history object (pathname + search + hash)\n * - The actual browser window URL (from window.location)\n *\n * This helps understand the difference between router-managed navigation\n * (especially with memory or hash history) and the browser's actual location.\n *\n * @example\n * ```html\n * <!-- Show URLs for browser history -->\n * <tha-url-output history=\"browser\"></tha-url-output>\n *\n * <!-- Show URLs for hash history -->\n * <tha-url-output history=\"hash\"></tha-url-output>\n *\n * <!-- Show URLs for memory history (browser URL won't change) -->\n * <tha-url-output history=\"memory\"></tha-url-output>\n * ```\n */\n@customElement('tha-url-output')\nexport class ThaUrlOutput extends HistoryManaged(SignalWatcherLitElement) {\n #historyChangeUnsubscribe = noop;\n #historyEventsUnsubscribe = noop;\n\n #browserUrl = signal(location.href);\n #historyUrl = signal(this[HISTORY].get()!.location.pathname + this[HISTORY].get()!.location.search + this[HISTORY].get()!.location.hash);\n\n override connectedCallback(): void {\n super.connectedCallback();\n\n addEventListener('popstate', this.#onLocationChange);\n addEventListener('pushstate', this.#onLocationChange);\n addEventListener('hashchange', this.#onLocationChange);\n\n this.#historyChangeUnsubscribe = this.updateEffect(() => {\n const history = this[HISTORY].get();\n\n this.#historyUrl.set(history.location.pathname + history.location.search + history.location.hash);\n\n this.#historyEventsUnsubscribe();\n this.#historyEventsUnsubscribe = history.listen(({ location }) => {\n this.#historyUrl.set(location.pathname + location.search + location.hash);\n });\n })\n }\n\n protected override render() {\n return html`\n <div>\n <strong>History URL:</strong> ${this.#historyUrl}\n </div>\n <div>\n <strong>Browser URL:</strong> ${this.#browserUrl}\n </div>\n `;\n }\n\n #onLocationChange = () => {\n this.#browserUrl.set(window.location.href);\n };\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n\n removeEventListener('popstate', this.#onLocationChange);\n removeEventListener('pushstate', this.#onLocationChange);\n removeEventListener('hashchange', this.#onLocationChange);\n\n this.#historyEventsUnsubscribe();\n\n try {\n this.#historyChangeUnsubscribe();\n } catch {}\n }\n}\n"]}