@telperion/elements 1.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.
Files changed (86) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +102 -0
  3. package/bundle.js +164 -0
  4. package/bundle.mjs +2630 -0
  5. package/drag-drop/drag-element.cjs +438 -0
  6. package/drag-drop/drag-element.d.ts +120 -0
  7. package/drag-drop/drag-element.js +437 -0
  8. package/drag-drop/drag-element.js.map +1 -0
  9. package/drag-drop/drag-handle-element.cjs +35 -0
  10. package/drag-drop/drag-handle-element.d.ts +12 -0
  11. package/drag-drop/drag-handle-element.js +34 -0
  12. package/drag-drop/drag-handle-element.js.map +1 -0
  13. package/drag-drop/dropzone-element.cjs +117 -0
  14. package/drag-drop/dropzone-element.d.ts +17 -0
  15. package/drag-drop/dropzone-element.js +116 -0
  16. package/drag-drop/dropzone-element.js.map +1 -0
  17. package/drag-drop/index.cjs +11 -0
  18. package/drag-drop/index.d.ts +22 -0
  19. package/drag-drop/index.js +6 -0
  20. package/drag-drop/index.js.map +1 -0
  21. package/drag-drop/private-props.cjs +6 -0
  22. package/drag-drop/private-props.d.ts +3 -0
  23. package/drag-drop/private-props.js +5 -0
  24. package/drag-drop/private-props.js.map +1 -0
  25. package/drag-drop/tha-drag-event.cjs +34 -0
  26. package/drag-drop/tha-drag-event.d.ts +19 -0
  27. package/drag-drop/tha-drag-event.js +32 -0
  28. package/drag-drop/tha-drag-event.js.map +1 -0
  29. package/icon/icon-element.cjs +114 -0
  30. package/icon/icon-element.d.ts +40 -0
  31. package/icon/icon-element.js +113 -0
  32. package/icon/icon-element.js.map +1 -0
  33. package/icon/index.cjs +5 -0
  34. package/icon/index.d.ts +1 -0
  35. package/icon/index.js +3 -0
  36. package/icon/index.js.map +1 -0
  37. package/icon/material-symbols.css +22 -0
  38. package/index.cjs +11 -0
  39. package/index.d.ts +6 -0
  40. package/index.js +10 -0
  41. package/index.js.map +1 -0
  42. package/package.json +127 -0
  43. package/router/history-managed.cjs +97 -0
  44. package/router/history-managed.d.ts +76 -0
  45. package/router/history-managed.js +95 -0
  46. package/router/history-managed.js.map +1 -0
  47. package/router/history.cjs +65 -0
  48. package/router/history.d.ts +48 -0
  49. package/router/history.js +63 -0
  50. package/router/history.js.map +1 -0
  51. package/router/index.cjs +15 -0
  52. package/router/index.d.ts +6 -0
  53. package/router/index.js +8 -0
  54. package/router/index.js.map +1 -0
  55. package/router/signal-watcher-lit-element.cjs +11 -0
  56. package/router/signal-watcher-lit-element.d.ts +25 -0
  57. package/router/signal-watcher-lit-element.js +10 -0
  58. package/router/signal-watcher-lit-element.js.map +1 -0
  59. package/router/tha-route.cjs +125 -0
  60. package/router/tha-route.d.ts +90 -0
  61. package/router/tha-route.js +124 -0
  62. package/router/tha-route.js.map +1 -0
  63. package/router/tha-router-config.cjs +241 -0
  64. package/router/tha-router-config.d.ts +223 -0
  65. package/router/tha-router-config.js +240 -0
  66. package/router/tha-router-config.js.map +1 -0
  67. package/router/tha-router-link.cjs +209 -0
  68. package/router/tha-router-link.d.ts +95 -0
  69. package/router/tha-router-link.js +208 -0
  70. package/router/tha-router-link.js.map +1 -0
  71. package/router/tha-router-outlet.cjs +215 -0
  72. package/router/tha-router-outlet.d.ts +112 -0
  73. package/router/tha-router-outlet.js +214 -0
  74. package/router/tha-router-outlet.js.map +1 -0
  75. package/router/tha-router-param.cjs +278 -0
  76. package/router/tha-router-param.d.ts +226 -0
  77. package/router/tha-router-param.js +277 -0
  78. package/router/tha-router-param.js.map +1 -0
  79. package/router/tha-router.cjs +163 -0
  80. package/router/tha-router.d.ts +69 -0
  81. package/router/tha-router.js +162 -0
  82. package/router/tha-router.js.map +1 -0
  83. package/tha-url-output.cjs +79 -0
  84. package/tha-url-output.d.ts +41 -0
  85. package/tha-url-output.js +78 -0
  86. package/tha-url-output.js.map +1 -0
@@ -0,0 +1,278 @@
1
+ "use strict";
2
+ /**
3
+ * @fileoverview Router parameter display component
4
+ *
5
+ * Provides a declarative way to display dynamic route parameter values
6
+ * directly in HTML templates without requiring JavaScript.
7
+ *
8
+ * @module router/tha-router-param
9
+ */
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.ThaRouterParam = void 0;
12
+ const tslib_1 = require("tslib");
13
+ const decorators_js_1 = require("lit/decorators.js");
14
+ const signal_watcher_lit_element_1 = require("./signal-watcher-lit-element");
15
+ const signals_1 = require("@lit-labs/signals");
16
+ const tha_router_outlet_1 = require("./tha-router-outlet");
17
+ /**
18
+ * Custom element for displaying dynamic route parameter values.
19
+ *
20
+ * This component provides a declarative way to access and display URL
21
+ * parameters extracted from dynamic route segments without writing JavaScript.
22
+ * It must be used inside a `<tha-router-outlet>` element.
23
+ *
24
+ * ## Features
25
+ *
26
+ * - **Declarative**: Access params directly in HTML
27
+ * - **Reactive**: Automatically updates when route changes
28
+ * - **Hierarchical**: Inherits params from parent outlets
29
+ * - **Type-safe**: Integrated with TypeScript definitions
30
+ *
31
+ * ## Usage
32
+ *
33
+ * ### Basic Parameter Display
34
+ *
35
+ * ```html
36
+ * <tha-router>
37
+ * <tha-route path="/users/:id">
38
+ * <template>
39
+ * <h1>User Profile</h1>
40
+ * <p>User ID: <tha-router-param name="id"></tha-router-param></p>
41
+ * </template>
42
+ * </tha-route>
43
+ * <tha-router-outlet></tha-router-outlet>
44
+ * </tha-router>
45
+ * ```
46
+ *
47
+ * When navigating to `/users/123`, the component renders: `User ID: 123`
48
+ *
49
+ * ### Multiple Parameters
50
+ *
51
+ * ```html
52
+ * <tha-route path="/blog/:year/:month/:slug">
53
+ * <template>
54
+ * <article>
55
+ * <header>
56
+ * <time>
57
+ * <tha-router-param name="year"></tha-router-param>-
58
+ * <tha-router-param name="month"></tha-router-param>
59
+ * </time>
60
+ * <h1><tha-router-param name="slug"></tha-router-param></h1>
61
+ * </header>
62
+ * </article>
63
+ * </template>
64
+ * </tha-route>
65
+ * ```
66
+ *
67
+ * For `/blog/2024/12/hello-world`, renders:
68
+ * ```html
69
+ * <time>2024-12</time>
70
+ * <h1>hello-world</h1>
71
+ * ```
72
+ *
73
+ * ### Nested Routes with Parameter Inheritance
74
+ *
75
+ * ```html
76
+ * <tha-router>
77
+ * <tha-route path="/projects/:projectId">
78
+ * <template>
79
+ * <h1>Project <tha-router-param name="projectId"></tha-router-param></h1>
80
+ *
81
+ * <!-- Nested outlet inherits projectId parameter -->
82
+ * <tha-router-outlet>
83
+ * <tha-route path="/tasks/:taskId">
84
+ * <template>
85
+ * <!-- Both params are available -->
86
+ * <h2>Task Details</h2>
87
+ * <p>Project: <tha-router-param name="projectId"></tha-router-param></p>
88
+ * <p>Task: <tha-router-param name="taskId"></tha-router-param></p>
89
+ * </template>
90
+ * </tha-route>
91
+ * </tha-router-outlet>
92
+ * </template>
93
+ * </tha-route>
94
+ * <tha-router-outlet></tha-router-outlet>
95
+ * </tha-router>
96
+ * ```
97
+ *
98
+ * ### With Styling
99
+ *
100
+ * ```html
101
+ * <style>
102
+ * tha-router-param {
103
+ * font-weight: bold;
104
+ * color: var(--primary-color);
105
+ * }
106
+ *
107
+ * tha-router-param[name="id"] {
108
+ * font-family: monospace;
109
+ * }
110
+ * </style>
111
+ *
112
+ * <tha-route path="/users/:id">
113
+ * <template>
114
+ * <span>User: <tha-router-param name="id"></tha-router-param></span>
115
+ * </template>
116
+ * </tha-route>
117
+ * ```
118
+ *
119
+ * ## How It Works
120
+ *
121
+ * 1. On connection, finds the nearest parent `<tha-router-outlet>`
122
+ * 2. Accesses the outlet's PARAMS signal containing all route parameters
123
+ * 3. Computes and displays the value for the specified parameter name
124
+ * 4. Automatically re-renders when the route (and thus params) change
125
+ *
126
+ * ## Error Handling
127
+ *
128
+ * Throws an error if not placed within a `<tha-router-outlet>`:
129
+ *
130
+ * ```javascript
131
+ * // ✗ Wrong - not inside outlet
132
+ * <tha-router-param name="id"></tha-router-param>
133
+ *
134
+ * // ✓ Correct - inside outlet
135
+ * <tha-router-outlet>
136
+ * <tha-router-param name="id"></tha-router-param>
137
+ * </tha-router-outlet>
138
+ * ```
139
+ *
140
+ * ## Alternative: Using Attributes
141
+ *
142
+ * The parent `<tha-router-outlet>` also exposes parameters as `param-*` attributes,
143
+ * which can be used as an alternative approach:
144
+ *
145
+ * ```html
146
+ * <tha-router-outlet id="outlet">
147
+ * <script>
148
+ * const outlet = document.getElementById('outlet');
149
+ * // Params available as: outlet.getAttribute('param-id')
150
+ * </script>
151
+ * </tha-router-outlet>
152
+ * ```
153
+ *
154
+ * However, `<tha-router-param>` is preferred for declarative templates.
155
+ *
156
+ * @example Basic usage
157
+ * ```html
158
+ * <tha-router>
159
+ * <tha-route path="/product/:sku">
160
+ * <template>
161
+ * <h1>Product: <tha-router-param name="sku"></tha-router-param></h1>
162
+ * </template>
163
+ * </tha-route>
164
+ * <tha-router-outlet></tha-router-outlet>
165
+ * </tha-router>
166
+ * ```
167
+ *
168
+ * @example Multiple params with formatting
169
+ * ```html
170
+ * <tha-route path="/user/:username/post/:postId">
171
+ * <template>
172
+ * <article>
173
+ * <p>@<tha-router-param name="username"></tha-router-param></p>
174
+ * <p>Post #<tha-router-param name="postId"></tha-router-param></p>
175
+ * </article>
176
+ * </template>
177
+ * </tha-route>
178
+ * ```
179
+ */
180
+ let ThaRouterParam = class ThaRouterParam extends signal_watcher_lit_element_1.SignalWatcherLitElement {
181
+ constructor() {
182
+ super(...arguments);
183
+ /**
184
+ * Signal holding reference to the parent outlet.
185
+ * Set during connectedCallback.
186
+ */
187
+ this.#outlet = (0, signals_1.signal)(null);
188
+ /**
189
+ * Signal tracking the parameter name to display.
190
+ * Updated when the 'name' attribute changes.
191
+ */
192
+ this.#name = (0, signals_1.signal)('');
193
+ /**
194
+ * Computed signal that extracts the parameter value.
195
+ * Reactively updates when the outlet's params or name changes.
196
+ */
197
+ this.#value = (0, signals_1.computed)(() => this.#outlet.get()?.[tha_router_outlet_1.PARAMS]?.get()[this.#name.get()]);
198
+ /**
199
+ * The name of the route parameter to display.
200
+ *
201
+ * Must match a parameter name defined in the route's path pattern.
202
+ * For example, for path `/users/:id`, use `name="id"`.
203
+ *
204
+ * @attr name
205
+ * @type {string}
206
+ */
207
+ this.name = '';
208
+ }
209
+ /**
210
+ * Signal holding reference to the parent outlet.
211
+ * Set during connectedCallback.
212
+ */
213
+ #outlet;
214
+ /**
215
+ * Signal tracking the parameter name to display.
216
+ * Updated when the 'name' attribute changes.
217
+ */
218
+ #name;
219
+ /**
220
+ * Computed signal that extracts the parameter value.
221
+ * Reactively updates when the outlet's params or name changes.
222
+ */
223
+ #value;
224
+ /**
225
+ * Lifecycle callback when element is connected to the DOM.
226
+ *
227
+ * Finds the parent `<tha-router-outlet>` and stores a reference.
228
+ * Throws an error if not used within an outlet.
229
+ *
230
+ * @throws {Error} If no parent tha-router-outlet is found
231
+ */
232
+ connectedCallback() {
233
+ super.connectedCallback();
234
+ const outlet = this.closest('tha-router-outlet');
235
+ if (!outlet) {
236
+ throw new Error('<tha-router-param> must be used within a <tha-router-outlet>.');
237
+ }
238
+ this.#outlet.set(outlet);
239
+ }
240
+ /**
241
+ * Lifecycle callback when observed attributes change.
242
+ *
243
+ * Updates the internal name signal when the 'name' attribute changes,
244
+ * which triggers the computed value signal to recalculate and re-render.
245
+ *
246
+ * @param name - The attribute name that changed
247
+ * @param _old - Previous attribute value (unused)
248
+ * @param value - New attribute value
249
+ */
250
+ attributeChangedCallback(name, _old, value) {
251
+ super.attributeChangedCallback(name, _old, value);
252
+ switch (name) {
253
+ case 'name':
254
+ this.#name.set(value ?? '');
255
+ break;
256
+ }
257
+ }
258
+ /**
259
+ * Renders the parameter value.
260
+ *
261
+ * The value is extracted from the outlet's params signal and
262
+ * displayed as text content. Automatically updates when the
263
+ * route changes.
264
+ *
265
+ * @returns The parameter value as a template result
266
+ */
267
+ render() {
268
+ return (0, signals_1.html) `${this.#value}`;
269
+ }
270
+ };
271
+ exports.ThaRouterParam = ThaRouterParam;
272
+ tslib_1.__decorate([
273
+ (0, decorators_js_1.property)({ type: String }),
274
+ tslib_1.__metadata("design:type", String)
275
+ ], ThaRouterParam.prototype, "name", void 0);
276
+ exports.ThaRouterParam = ThaRouterParam = tslib_1.__decorate([
277
+ (0, decorators_js_1.customElement)('tha-router-param')
278
+ ], ThaRouterParam);
@@ -0,0 +1,226 @@
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
+ }