@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,65 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GLOBAL_HISTORY = exports.GLOBAL_HISTORY_TYPE = exports.DEFAULT_HISTORY_TYPE = void 0;
4
+ exports.getHistoryByType = getHistoryByType;
5
+ const signals_1 = require("@lit-labs/signals");
6
+ const history_1 = require("history");
7
+ /**
8
+ * Global registry mapping history types to their singleton instances.
9
+ * Ensures that the same history object is reused across all routers of the same type.
10
+ */
11
+ const HISTORY_MAP = {};
12
+ /**
13
+ * Default history type used when no explicit type is specified.
14
+ * Uses browser history (HTML5 History API).
15
+ */
16
+ exports.DEFAULT_HISTORY_TYPE = "browser";
17
+ /**
18
+ * Reactive signal containing the currently active global history type.
19
+ * Changing this signal will cause all routers using the global history to switch types.
20
+ */
21
+ exports.GLOBAL_HISTORY_TYPE = (0, signals_1.signal)(exports.DEFAULT_HISTORY_TYPE);
22
+ /**
23
+ * Computed signal that returns the History instance for the current global history type.
24
+ * Automatically updates when GLOBAL_HISTORY_TYPE changes.
25
+ */
26
+ exports.GLOBAL_HISTORY = (0, signals_1.computed)(() => getHistoryByType(exports.GLOBAL_HISTORY_TYPE.get()));
27
+ /**
28
+ * Retrieves or creates a History instance for the specified type.
29
+ *
30
+ * History instances are cached in HISTORY_MAP as singletons, so multiple
31
+ * calls with the same type will return the same instance. This ensures
32
+ * that navigation state is shared across all routers using the same history type.
33
+ *
34
+ * @param type - The type of history to retrieve ("browser", "hash", "memory", or "memory:name")
35
+ * @returns The History instance for the specified type
36
+ *
37
+ * @example
38
+ * ```typescript
39
+ * // Get browser history
40
+ * const browserHistory = getHistoryByType('browser');
41
+ *
42
+ * // Get hash-based history
43
+ * const hashHistory = getHistoryByType('hash');
44
+ *
45
+ * // Get isolated memory history for testing
46
+ * const testHistory = getHistoryByType('memory:test-suite-1');
47
+ * ```
48
+ */
49
+ function getHistoryByType(type) {
50
+ let history = HISTORY_MAP[type];
51
+ if (!history) {
52
+ switch (type) {
53
+ case 'browser':
54
+ history = (0, history_1.createBrowserHistory)();
55
+ break;
56
+ case 'hash':
57
+ history = (0, history_1.createHashHistory)();
58
+ break;
59
+ default:
60
+ history = (0, history_1.createMemoryHistory)();
61
+ }
62
+ HISTORY_MAP[type] = history;
63
+ }
64
+ return history;
65
+ }
@@ -0,0 +1,48 @@
1
+ import { History } from "history";
2
+ /**
3
+ * Supported history types for the router.
4
+ *
5
+ * - `"browser"` - Uses the HTML5 History API (pushState, replaceState)
6
+ * - `"hash"` - Uses hash-based routing (#/path)
7
+ * - `"memory"` - In-memory history for testing or non-browser environments
8
+ * - `"memory:${string}"` - Named memory history instances for isolation
9
+ */
10
+ export type HistoryType = "browser" | "hash" | "memory" | `memory:${string}`;
11
+ /**
12
+ * Default history type used when no explicit type is specified.
13
+ * Uses browser history (HTML5 History API).
14
+ */
15
+ export declare const DEFAULT_HISTORY_TYPE: HistoryType;
16
+ /**
17
+ * Reactive signal containing the currently active global history type.
18
+ * Changing this signal will cause all routers using the global history to switch types.
19
+ */
20
+ export declare const GLOBAL_HISTORY_TYPE: import("@lit-labs/signals").Signal.State<HistoryType>;
21
+ /**
22
+ * Computed signal that returns the History instance for the current global history type.
23
+ * Automatically updates when GLOBAL_HISTORY_TYPE changes.
24
+ */
25
+ export declare const GLOBAL_HISTORY: import("@lit-labs/signals").Signal.Computed<History>;
26
+ /**
27
+ * Retrieves or creates a History instance for the specified type.
28
+ *
29
+ * History instances are cached in HISTORY_MAP as singletons, so multiple
30
+ * calls with the same type will return the same instance. This ensures
31
+ * that navigation state is shared across all routers using the same history type.
32
+ *
33
+ * @param type - The type of history to retrieve ("browser", "hash", "memory", or "memory:name")
34
+ * @returns The History instance for the specified type
35
+ *
36
+ * @example
37
+ * ```typescript
38
+ * // Get browser history
39
+ * const browserHistory = getHistoryByType('browser');
40
+ *
41
+ * // Get hash-based history
42
+ * const hashHistory = getHistoryByType('hash');
43
+ *
44
+ * // Get isolated memory history for testing
45
+ * const testHistory = getHistoryByType('memory:test-suite-1');
46
+ * ```
47
+ */
48
+ export declare function getHistoryByType(type: HistoryType): History;
@@ -0,0 +1,63 @@
1
+ import { computed, signal } from "@lit-labs/signals";
2
+ import { createBrowserHistory, createHashHistory, createMemoryHistory } from "history";
3
+ /**
4
+ * Global registry mapping history types to their singleton instances.
5
+ * Ensures that the same history object is reused across all routers of the same type.
6
+ */
7
+ const HISTORY_MAP = {};
8
+ /**
9
+ * Default history type used when no explicit type is specified.
10
+ * Uses browser history (HTML5 History API).
11
+ */
12
+ export const DEFAULT_HISTORY_TYPE = "browser";
13
+ /**
14
+ * Reactive signal containing the currently active global history type.
15
+ * Changing this signal will cause all routers using the global history to switch types.
16
+ */
17
+ export const GLOBAL_HISTORY_TYPE = signal(DEFAULT_HISTORY_TYPE);
18
+ /**
19
+ * Computed signal that returns the History instance for the current global history type.
20
+ * Automatically updates when GLOBAL_HISTORY_TYPE changes.
21
+ */
22
+ export const GLOBAL_HISTORY = computed(() => getHistoryByType(GLOBAL_HISTORY_TYPE.get()));
23
+ /**
24
+ * Retrieves or creates a History instance for the specified type.
25
+ *
26
+ * History instances are cached in HISTORY_MAP as singletons, so multiple
27
+ * calls with the same type will return the same instance. This ensures
28
+ * that navigation state is shared across all routers using the same history type.
29
+ *
30
+ * @param type - The type of history to retrieve ("browser", "hash", "memory", or "memory:name")
31
+ * @returns The History instance for the specified type
32
+ *
33
+ * @example
34
+ * ```typescript
35
+ * // Get browser history
36
+ * const browserHistory = getHistoryByType('browser');
37
+ *
38
+ * // Get hash-based history
39
+ * const hashHistory = getHistoryByType('hash');
40
+ *
41
+ * // Get isolated memory history for testing
42
+ * const testHistory = getHistoryByType('memory:test-suite-1');
43
+ * ```
44
+ */
45
+ export function getHistoryByType(type) {
46
+ let history = HISTORY_MAP[type];
47
+ if (!history) {
48
+ switch (type) {
49
+ case 'browser':
50
+ history = createBrowserHistory();
51
+ break;
52
+ case 'hash':
53
+ history = createHashHistory();
54
+ break;
55
+ default:
56
+ history = createMemoryHistory();
57
+ }
58
+ HISTORY_MAP[type] = history;
59
+ }
60
+ return history;
61
+ }
62
+
63
+ //# sourceMappingURL=history.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../libs/elements/src/router/history.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,mBAAmB,EAAW,MAAM,SAAS,CAAC;AAYhG;;;GAGG;AACH,MAAM,WAAW,GAAG,EAAkC,CAAC;AAEvD;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAgB,SAAS,CAAC;AAE3D;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAc,oBAAoB,CAAC,CAAC;AAE7E;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,QAAQ,CAAC,GAAG,EAAE,CAAC,gBAAgB,CAAC,mBAAmB,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;AAE1F;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAiB;IAChD,IAAI,OAAO,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;IAEhC,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,QAAQ,IAAI,EAAE,CAAC;YACb,KAAK,SAAS;gBACZ,OAAO,GAAG,oBAAoB,EAAE,CAAC;gBACjC,MAAM;YACR,KAAK,MAAM;gBACT,OAAO,GAAG,iBAAiB,EAAE,CAAC;gBAC9B,MAAM;YACR;gBACE,OAAO,GAAG,mBAAmB,EAAE,CAAC;QACpC,CAAC;QAED,WAAW,CAAC,IAAmB,CAAC,GAAG,OAAO,CAAC;IAC7C,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC","file":"history.js","sourcesContent":["import { computed, signal } from \"@lit-labs/signals\";\nimport { createBrowserHistory, createHashHistory, createMemoryHistory, History } from \"history\";\n\n/**\n * Supported history types for the router.\n *\n * - `\"browser\"` - Uses the HTML5 History API (pushState, replaceState)\n * - `\"hash\"` - Uses hash-based routing (#/path)\n * - `\"memory\"` - In-memory history for testing or non-browser environments\n * - `\"memory:${string}\"` - Named memory history instances for isolation\n */\nexport type HistoryType = \"browser\" | \"hash\" | \"memory\" | `memory:${string}`;\n\n/**\n * Global registry mapping history types to their singleton instances.\n * Ensures that the same history object is reused across all routers of the same type.\n */\nconst HISTORY_MAP = {} as Record<HistoryType, History>;\n\n/**\n * Default history type used when no explicit type is specified.\n * Uses browser history (HTML5 History API).\n */\nexport const DEFAULT_HISTORY_TYPE: HistoryType = \"browser\";\n\n/**\n * Reactive signal containing the currently active global history type.\n * Changing this signal will cause all routers using the global history to switch types.\n */\nexport const GLOBAL_HISTORY_TYPE = signal<HistoryType>(DEFAULT_HISTORY_TYPE);\n\n/**\n * Computed signal that returns the History instance for the current global history type.\n * Automatically updates when GLOBAL_HISTORY_TYPE changes.\n */\nexport const GLOBAL_HISTORY = computed(() => getHistoryByType(GLOBAL_HISTORY_TYPE.get()));\n\n/**\n * Retrieves or creates a History instance for the specified type.\n *\n * History instances are cached in HISTORY_MAP as singletons, so multiple\n * calls with the same type will return the same instance. This ensures\n * that navigation state is shared across all routers using the same history type.\n *\n * @param type - The type of history to retrieve (\"browser\", \"hash\", \"memory\", or \"memory:name\")\n * @returns The History instance for the specified type\n *\n * @example\n * ```typescript\n * // Get browser history\n * const browserHistory = getHistoryByType('browser');\n *\n * // Get hash-based history\n * const hashHistory = getHistoryByType('hash');\n *\n * // Get isolated memory history for testing\n * const testHistory = getHistoryByType('memory:test-suite-1');\n * ```\n */\nexport function getHistoryByType(type: HistoryType): History {\n let history = HISTORY_MAP[type];\n\n if (!history) {\n switch (type) {\n case 'browser':\n history = createBrowserHistory();\n break;\n case 'hash':\n history = createHashHistory();\n break;\n default:\n history = createMemoryHistory();\n }\n\n HISTORY_MAP[type as HistoryType] = history;\n }\n\n return history;\n}\n"]}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ThaRouterParam = exports.ThaRouterConfig = exports.ThaRouterOutlet = exports.ThaRouterLink = exports.ThaRoute = exports.ThaRouter = void 0;
4
+ var tha_router_1 = require("./tha-router");
5
+ Object.defineProperty(exports, "ThaRouter", { enumerable: true, get: function () { return tha_router_1.ThaRouter; } });
6
+ var tha_route_1 = require("./tha-route");
7
+ Object.defineProperty(exports, "ThaRoute", { enumerable: true, get: function () { return tha_route_1.ThaRoute; } });
8
+ var tha_router_link_1 = require("./tha-router-link");
9
+ Object.defineProperty(exports, "ThaRouterLink", { enumerable: true, get: function () { return tha_router_link_1.ThaRouterLink; } });
10
+ var tha_router_outlet_1 = require("./tha-router-outlet");
11
+ Object.defineProperty(exports, "ThaRouterOutlet", { enumerable: true, get: function () { return tha_router_outlet_1.ThaRouterOutlet; } });
12
+ var tha_router_config_1 = require("./tha-router-config");
13
+ Object.defineProperty(exports, "ThaRouterConfig", { enumerable: true, get: function () { return tha_router_config_1.ThaRouterConfig; } });
14
+ var tha_router_param_1 = require("./tha-router-param");
15
+ Object.defineProperty(exports, "ThaRouterParam", { enumerable: true, get: function () { return tha_router_param_1.ThaRouterParam; } });
@@ -0,0 +1,6 @@
1
+ export { ThaRouter } from './tha-router';
2
+ export { ThaRoute } from './tha-route';
3
+ export { ThaRouterLink } from './tha-router-link';
4
+ export { ThaRouterOutlet } from './tha-router-outlet';
5
+ export { ThaRouterConfig } from './tha-router-config';
6
+ export { ThaRouterParam } from './tha-router-param';
@@ -0,0 +1,8 @@
1
+ export { ThaRouter } from './tha-router';
2
+ export { ThaRoute } from './tha-route';
3
+ export { ThaRouterLink } from './tha-router-link';
4
+ export { ThaRouterOutlet } from './tha-router-outlet';
5
+ export { ThaRouterConfig } from './tha-router-config';
6
+ export { ThaRouterParam } from './tha-router-param';
7
+
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../libs/elements/src/router/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC","file":"index.js","sourcesContent":["export { ThaRouter } from './tha-router';\nexport { ThaRoute } from './tha-route';\nexport { ThaRouterLink } from './tha-router-link';\nexport { ThaRouterOutlet } from './tha-router-outlet';\nexport { ThaRouterConfig } from './tha-router-config';\nexport { ThaRouterParam } from './tha-router-param';\n"]}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SignalWatcherLitElement = void 0;
4
+ const signals_1 = require("@lit-labs/signals");
5
+ const lit_1 = require("lit");
6
+ /**
7
+ * A LitElement base class extended with SignalWatcher capabilities.
8
+ *
9
+ * This class allows LitElement components to reactively watch for changes
10
+ */
11
+ exports.SignalWatcherLitElement = (0, signals_1.SignalWatcher)(lit_1.LitElement);
@@ -0,0 +1,25 @@
1
+ import { LitElement } from "lit";
2
+ export interface EffectOptions {
3
+ /**
4
+ * By default effects run after the element has updated. If `beforeUpdate`
5
+ * is set to `true`, the effect will run before the element updates.
6
+ */
7
+ beforeUpdate?: boolean;
8
+ /**
9
+ * By default, effects are automatically disposed when the element is
10
+ * disconnected. If `manualDispose` is set to `true`, the effect will not
11
+ * be automatically disposed, and you must call the returned function to
12
+ * dispose of the effect manually.
13
+ */
14
+ manualDispose?: boolean;
15
+ }
16
+ /**
17
+ * A LitElement base class extended with SignalWatcher capabilities.
18
+ *
19
+ * This class allows LitElement components to reactively watch for changes
20
+ */
21
+ export declare const SignalWatcherLitElement: ({
22
+ new (): LitElement & {
23
+ updateEffect(fn: () => void, options?: EffectOptions): () => void;
24
+ };
25
+ });
@@ -0,0 +1,10 @@
1
+ import { SignalWatcher } from "@lit-labs/signals";
2
+ import { LitElement } from "lit";
3
+ /**
4
+ * A LitElement base class extended with SignalWatcher capabilities.
5
+ *
6
+ * This class allows LitElement components to reactively watch for changes
7
+ */
8
+ export const SignalWatcherLitElement = SignalWatcher(LitElement);
9
+
10
+ //# sourceMappingURL=signal-watcher-lit-element.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../libs/elements/src/router/signal-watcher-lit-element.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAiBjC;;;;GAIG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,aAAa,CAAC,UAAU,CAI7D,CAAC","file":"signal-watcher-lit-element.js","sourcesContent":["import { SignalWatcher } from \"@lit-labs/signals\";\nimport { LitElement } from \"lit\";\n\nexport interface EffectOptions {\n /**\n * By default effects run after the element has updated. If `beforeUpdate`\n * is set to `true`, the effect will run before the element updates.\n */\n beforeUpdate?: boolean;\n /**\n * By default, effects are automatically disposed when the element is\n * disconnected. If `manualDispose` is set to `true`, the effect will not\n * be automatically disposed, and you must call the returned function to\n * dispose of the effect manually.\n */\n manualDispose?: boolean;\n}\n\n/**\n * A LitElement base class extended with SignalWatcher capabilities.\n *\n * This class allows LitElement components to reactively watch for changes\n */\nexport const SignalWatcherLitElement = SignalWatcher(LitElement) as ({\n new (): LitElement & {\n updateEffect(fn: () => void, options?: EffectOptions): () => void;\n }\n});\n"]}
@@ -0,0 +1,125 @@
1
+ "use strict";
2
+ var _a, _b;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.ThaRoute = exports.PATH_PATTERN = exports.FRAGMENT = void 0;
5
+ const tslib_1 = require("tslib");
6
+ const signals_1 = require("@lit-labs/signals");
7
+ const lit_1 = require("lit");
8
+ const decorators_js_1 = require("lit/decorators.js");
9
+ /**
10
+ * Symbol used to access the route's template fragment signal.
11
+ * @internal
12
+ */
13
+ exports.FRAGMENT = Symbol('ThaRoute:fragment');
14
+ /**
15
+ * Symbol used to access the route's URLPattern instance.
16
+ * @internal
17
+ */
18
+ exports.PATH_PATTERN = Symbol('ThaRoute:path-pattern');
19
+ /**
20
+ * A custom element that defines a route in the router.
21
+ *
22
+ * Each route contains a template element with the content to render when
23
+ * the route matches the current URL. The router watches for changes to
24
+ * the template content and automatically updates the outlet.
25
+ *
26
+ * The `path` attribute uses URLPattern syntax and supports:
27
+ * - Static paths: `/about`, `/users`
28
+ * - Dynamic segments: `/users/:id`, `/posts/:category/:slug`
29
+ * - Wildcards: `/blog/*`, `/docs/**`
30
+ *
31
+ * @example
32
+ * ```html
33
+ * <tha-router>
34
+ * <tha-route path="/">
35
+ * <template><h1>Home Page</h1></template>
36
+ * </tha-route>
37
+ * <tha-route path="/users/:id">
38
+ * <template><h1>User Profile</h1></template>
39
+ * </tha-route>
40
+ * <tha-router-outlet></tha-router-outlet>
41
+ * </tha-router>
42
+ * ```
43
+ */
44
+ let ThaRoute = class ThaRoute extends lit_1.LitElement {
45
+ constructor() {
46
+ super(...arguments);
47
+ /**
48
+ * Signal containing weak reference to the template's DocumentFragment.
49
+ * Automatically updates when the template content changes.
50
+ * @internal
51
+ */
52
+ this[_a] = (0, signals_1.signal)(this.#getTemplateFragment());
53
+ /**
54
+ * URLPattern instance for matching the current URL against this route's path.
55
+ * @internal
56
+ */
57
+ this[_b] = null;
58
+ /**
59
+ * The URL pattern to match for this route.
60
+ * Uses URLPattern syntax with support for dynamic segments and wildcards.
61
+ *
62
+ * @attr path
63
+ * @example "/users/:id"
64
+ * @example "/blog/*"
65
+ */
66
+ this.path = null;
67
+ /** Observes changes to child elements to detect template updates */
68
+ this.#templateObserver = new MutationObserver(() => {
69
+ this[exports.FRAGMENT].set(this.#getTemplateFragment());
70
+ });
71
+ }
72
+ static { _a = exports.FRAGMENT, _b = exports.PATH_PATTERN; }
73
+ /** Observes changes to child elements to detect template updates */
74
+ #templateObserver;
75
+ /**
76
+ * Lifecycle callback when the element is connected to the DOM.
77
+ * Sets up observer to watch for template content changes.
78
+ */
79
+ connectedCallback() {
80
+ super.connectedCallback();
81
+ this.#templateObserver.observe(this, { childList: true });
82
+ }
83
+ /**
84
+ * Lifecycle callback when an attribute changes.
85
+ * Updates the URLPattern when the path attribute changes.
86
+ *
87
+ * @param name - The attribute name that changed
88
+ * @param _old - The old attribute value
89
+ * @param value - The new attribute value
90
+ */
91
+ attributeChangedCallback(name, _old, value) {
92
+ super.attributeChangedCallback(name, _old, value);
93
+ switch (name) {
94
+ case 'path':
95
+ this[exports.PATH_PATTERN] = value ? new URLPattern({ pathname: value }) : null;
96
+ break;
97
+ }
98
+ }
99
+ /**
100
+ * Extracts the DocumentFragment from the template element.
101
+ * Returns a weak reference to prevent memory leaks.
102
+ *
103
+ * @returns Weak reference to the template fragment, or null if no template found
104
+ */
105
+ #getTemplateFragment() {
106
+ const template = this.querySelector('template');
107
+ return template ? new WeakRef(template.content) : null;
108
+ }
109
+ /**
110
+ * Lifecycle callback when the element is disconnected from the DOM.
111
+ * Cleans up the template observer.
112
+ */
113
+ disconnectedCallback() {
114
+ super.disconnectedCallback();
115
+ this.#templateObserver.disconnect();
116
+ }
117
+ };
118
+ exports.ThaRoute = ThaRoute;
119
+ tslib_1.__decorate([
120
+ (0, decorators_js_1.property)({ type: String }),
121
+ tslib_1.__metadata("design:type", Object)
122
+ ], ThaRoute.prototype, "path", void 0);
123
+ exports.ThaRoute = ThaRoute = tslib_1.__decorate([
124
+ (0, decorators_js_1.customElement)('tha-route')
125
+ ], ThaRoute);
@@ -0,0 +1,90 @@
1
+ import type { URLPattern } from "@telperion/extra-ts-types/polyfills/url-pattern";
2
+ import { LitElement } from "lit";
3
+ declare global {
4
+ interface HTMLElementTagNameMap {
5
+ /**
6
+ * A route definition element for client-side routing.
7
+ * It contains a template with the content to render when the route is active.
8
+ * The `path` attribute defines the URL pattern to match using URLPattern syntax.
9
+ * Must be a child of a tha-router element.
10
+ */
11
+ "tha-route": ThaRoute;
12
+ }
13
+ }
14
+ /**
15
+ * Symbol used to access the route's template fragment signal.
16
+ * @internal
17
+ */
18
+ export declare const FRAGMENT: unique symbol;
19
+ /**
20
+ * Symbol used to access the route's URLPattern instance.
21
+ * @internal
22
+ */
23
+ export declare const PATH_PATTERN: unique symbol;
24
+ /**
25
+ * A custom element that defines a route in the router.
26
+ *
27
+ * Each route contains a template element with the content to render when
28
+ * the route matches the current URL. The router watches for changes to
29
+ * the template content and automatically updates the outlet.
30
+ *
31
+ * The `path` attribute uses URLPattern syntax and supports:
32
+ * - Static paths: `/about`, `/users`
33
+ * - Dynamic segments: `/users/:id`, `/posts/:category/:slug`
34
+ * - Wildcards: `/blog/*`, `/docs/**`
35
+ *
36
+ * @example
37
+ * ```html
38
+ * <tha-router>
39
+ * <tha-route path="/">
40
+ * <template><h1>Home Page</h1></template>
41
+ * </tha-route>
42
+ * <tha-route path="/users/:id">
43
+ * <template><h1>User Profile</h1></template>
44
+ * </tha-route>
45
+ * <tha-router-outlet></tha-router-outlet>
46
+ * </tha-router>
47
+ * ```
48
+ */
49
+ export declare class ThaRoute extends LitElement {
50
+ #private;
51
+ /**
52
+ * Signal containing weak reference to the template's DocumentFragment.
53
+ * Automatically updates when the template content changes.
54
+ * @internal
55
+ */
56
+ [FRAGMENT]: import("@lit-labs/signals").Signal.State<WeakRef<DocumentFragment> | null>;
57
+ /**
58
+ * URLPattern instance for matching the current URL against this route's path.
59
+ * @internal
60
+ */
61
+ [PATH_PATTERN]: URLPattern | null;
62
+ /**
63
+ * The URL pattern to match for this route.
64
+ * Uses URLPattern syntax with support for dynamic segments and wildcards.
65
+ *
66
+ * @attr path
67
+ * @example "/users/:id"
68
+ * @example "/blog/*"
69
+ */
70
+ path: string | null;
71
+ /**
72
+ * Lifecycle callback when the element is connected to the DOM.
73
+ * Sets up observer to watch for template content changes.
74
+ */
75
+ connectedCallback(): void;
76
+ /**
77
+ * Lifecycle callback when an attribute changes.
78
+ * Updates the URLPattern when the path attribute changes.
79
+ *
80
+ * @param name - The attribute name that changed
81
+ * @param _old - The old attribute value
82
+ * @param value - The new attribute value
83
+ */
84
+ attributeChangedCallback(name: string, _old: string | null, value: string | null): void;
85
+ /**
86
+ * Lifecycle callback when the element is disconnected from the DOM.
87
+ * Cleans up the template observer.
88
+ */
89
+ disconnectedCallback(): void;
90
+ }
@@ -0,0 +1,124 @@
1
+ var _a, _b;
2
+ import { __decorate, __metadata } from "tslib";
3
+ import { signal } from "@lit-labs/signals";
4
+ import { LitElement } from "lit";
5
+ import { customElement, property } from "lit/decorators.js";
6
+ /**
7
+ * Symbol used to access the route's template fragment signal.
8
+ * @internal
9
+ */
10
+ export const FRAGMENT = Symbol('ThaRoute:fragment');
11
+ /**
12
+ * Symbol used to access the route's URLPattern instance.
13
+ * @internal
14
+ */
15
+ export const PATH_PATTERN = Symbol('ThaRoute:path-pattern');
16
+ /**
17
+ * A custom element that defines a route in the router.
18
+ *
19
+ * Each route contains a template element with the content to render when
20
+ * the route matches the current URL. The router watches for changes to
21
+ * the template content and automatically updates the outlet.
22
+ *
23
+ * The `path` attribute uses URLPattern syntax and supports:
24
+ * - Static paths: `/about`, `/users`
25
+ * - Dynamic segments: `/users/:id`, `/posts/:category/:slug`
26
+ * - Wildcards: `/blog/*`, `/docs/**`
27
+ *
28
+ * @example
29
+ * ```html
30
+ * <tha-router>
31
+ * <tha-route path="/">
32
+ * <template><h1>Home Page</h1></template>
33
+ * </tha-route>
34
+ * <tha-route path="/users/:id">
35
+ * <template><h1>User Profile</h1></template>
36
+ * </tha-route>
37
+ * <tha-router-outlet></tha-router-outlet>
38
+ * </tha-router>
39
+ * ```
40
+ */
41
+ let ThaRoute = class ThaRoute extends LitElement {
42
+ constructor() {
43
+ super(...arguments);
44
+ /**
45
+ * Signal containing weak reference to the template's DocumentFragment.
46
+ * Automatically updates when the template content changes.
47
+ * @internal
48
+ */
49
+ this[_a] = signal(this.#getTemplateFragment());
50
+ /**
51
+ * URLPattern instance for matching the current URL against this route's path.
52
+ * @internal
53
+ */
54
+ this[_b] = null;
55
+ /**
56
+ * The URL pattern to match for this route.
57
+ * Uses URLPattern syntax with support for dynamic segments and wildcards.
58
+ *
59
+ * @attr path
60
+ * @example "/users/:id"
61
+ * @example "/blog/*"
62
+ */
63
+ this.path = null;
64
+ /** Observes changes to child elements to detect template updates */
65
+ this.#templateObserver = new MutationObserver(() => {
66
+ this[FRAGMENT].set(this.#getTemplateFragment());
67
+ });
68
+ }
69
+ static { _a = FRAGMENT, _b = PATH_PATTERN; }
70
+ /** Observes changes to child elements to detect template updates */
71
+ #templateObserver;
72
+ /**
73
+ * Lifecycle callback when the element is connected to the DOM.
74
+ * Sets up observer to watch for template content changes.
75
+ */
76
+ connectedCallback() {
77
+ super.connectedCallback();
78
+ this.#templateObserver.observe(this, { childList: true });
79
+ }
80
+ /**
81
+ * Lifecycle callback when an attribute changes.
82
+ * Updates the URLPattern when the path attribute changes.
83
+ *
84
+ * @param name - The attribute name that changed
85
+ * @param _old - The old attribute value
86
+ * @param value - The new attribute value
87
+ */
88
+ attributeChangedCallback(name, _old, value) {
89
+ super.attributeChangedCallback(name, _old, value);
90
+ switch (name) {
91
+ case 'path':
92
+ this[PATH_PATTERN] = value ? new URLPattern({ pathname: value }) : null;
93
+ break;
94
+ }
95
+ }
96
+ /**
97
+ * Extracts the DocumentFragment from the template element.
98
+ * Returns a weak reference to prevent memory leaks.
99
+ *
100
+ * @returns Weak reference to the template fragment, or null if no template found
101
+ */
102
+ #getTemplateFragment() {
103
+ const template = this.querySelector('template');
104
+ return template ? new WeakRef(template.content) : null;
105
+ }
106
+ /**
107
+ * Lifecycle callback when the element is disconnected from the DOM.
108
+ * Cleans up the template observer.
109
+ */
110
+ disconnectedCallback() {
111
+ super.disconnectedCallback();
112
+ this.#templateObserver.disconnect();
113
+ }
114
+ };
115
+ __decorate([
116
+ property({ type: String }),
117
+ __metadata("design:type", Object)
118
+ ], ThaRoute.prototype, "path", void 0);
119
+ ThaRoute = __decorate([
120
+ customElement('tha-route')
121
+ ], ThaRoute);
122
+ export { ThaRoute };
123
+
124
+ //# sourceMappingURL=tha-route.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../libs/elements/src/router/tha-route.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAc5D;;;GAGG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,MAAM,CAAC,mBAAmB,CAAC,CAAC;AACpD;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC,uBAAuB,CAAC,CAAC;AAE5D;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEI,IAAM,QAAQ,GAAd,MAAM,QAAS,SAAQ,UAAU;IAAjC;;QACL;;;;WAIG;QACH,QAAU,GAAG,MAAM,CAAmC,IAAI,CAAC,oBAAoB,EAAE,CAAC,CAAC;QACnF;;;WAGG;QACH,QAAc,GAAsB,IAAI,CAAC;QAEzC;;;;;;;WAOG;QAEH,SAAI,GAAkB,IAAI,CAAC;QAE3B,oEAAoE;QACpE,sBAAiB,GAAG,IAAI,gBAAgB,CAAC,GAAG,EAAE;YAC5C,IAAI,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,oBAAoB,EAAE,CAAC,CAAC;QAClD,CAAC,CAAC,CAAC;IAmDL,CAAC;kBAxEE,QAAQ,OAKR,YAAY;IAab,oEAAoE;IACpE,iBAAiB,CAEd;IAEH;;;OAGG;IACM,iBAAiB;QACxB,KAAK,CAAC,iBAAiB,EAAE,CAAC;QAE1B,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC5D,CAAC;IAED;;;;;;;OAOG;IACM,wBAAwB,CAAC,IAAY,EAAE,IAAmB,EAAE,KAAoB;QACvF,KAAK,CAAC,wBAAwB,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;QAElD,QAAQ,IAAI,EAAE,CAAC;YACb,KAAK,MAAM;gBACT,IAAI,CAAC,YAAY,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,UAAU,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;gBACxE,MAAM;QACV,CAAC;IACH,CAAC;IAED;;;;;OAKG;IACH,oBAAoB;QAClB,MAAM,QAAQ,GAAG,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;QAEhD,OAAO,QAAQ,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACzD,CAAC;IAED;;;OAGG;IACM,oBAAoB;QAC3B,KAAK,CAAC,oBAAoB,EAAE,CAAC;QAE7B,IAAI,CAAC,iBAAiB,CAAC,UAAU,EAAE,CAAC;IACtC,CAAC;CACF,CAAA;AAxDC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;sCACA;AAtBhB,QAAQ;IADpB,aAAa,CAAC,WAAW,CAAC;GACd,QAAQ,CA8EpB","file":"tha-route.js","sourcesContent":["import { signal } from \"@lit-labs/signals\";\nimport type { URLPattern } from \"@telperion/extra-ts-types/polyfills/url-pattern\";\nimport { LitElement } from \"lit\";\nimport { customElement, property } from \"lit/decorators.js\";\n\ndeclare global {\n interface HTMLElementTagNameMap {\n /**\n * A route definition element for client-side routing.\n * It contains a template with the content to render when the route is active.\n * The `path` attribute defines the URL pattern to match using URLPattern syntax.\n * Must be a child of a tha-router element.\n */\n \"tha-route\": ThaRoute;\n }\n}\n\n/**\n * Symbol used to access the route's template fragment signal.\n * @internal\n */\nexport const FRAGMENT = Symbol('ThaRoute:fragment');\n/**\n * Symbol used to access the route's URLPattern instance.\n * @internal\n */\nexport const PATH_PATTERN = Symbol('ThaRoute:path-pattern');\n\n/**\n * A custom element that defines a route in the router.\n *\n * Each route contains a template element with the content to render when\n * the route matches the current URL. The router watches for changes to\n * the template content and automatically updates the outlet.\n *\n * The `path` attribute uses URLPattern syntax and supports:\n * - Static paths: `/about`, `/users`\n * - Dynamic segments: `/users/:id`, `/posts/:category/:slug`\n * - Wildcards: `/blog/*`, `/docs/**`\n *\n * @example\n * ```html\n * <tha-router>\n * <tha-route path=\"/\">\n * <template><h1>Home Page</h1></template>\n * </tha-route>\n * <tha-route path=\"/users/:id\">\n * <template><h1>User Profile</h1></template>\n * </tha-route>\n * <tha-router-outlet></tha-router-outlet>\n * </tha-router>\n * ```\n */\n@customElement('tha-route')\nexport class ThaRoute extends LitElement {\n /**\n * Signal containing weak reference to the template's DocumentFragment.\n * Automatically updates when the template content changes.\n * @internal\n */\n [FRAGMENT] = signal<WeakRef<DocumentFragment> | null>(this.#getTemplateFragment());\n /**\n * URLPattern instance for matching the current URL against this route's path.\n * @internal\n */\n [PATH_PATTERN]: URLPattern | null = null;\n\n /**\n * The URL pattern to match for this route.\n * Uses URLPattern syntax with support for dynamic segments and wildcards.\n *\n * @attr path\n * @example \"/users/:id\"\n * @example \"/blog/*\"\n */\n @property({ type: String })\n path: string | null = null;\n\n /** Observes changes to child elements to detect template updates */\n #templateObserver = new MutationObserver(() => {\n this[FRAGMENT].set(this.#getTemplateFragment());\n });\n\n /**\n * Lifecycle callback when the element is connected to the DOM.\n * Sets up observer to watch for template content changes.\n */\n override connectedCallback(): void {\n super.connectedCallback();\n\n this.#templateObserver.observe(this, { childList: true });\n }\n\n /**\n * Lifecycle callback when an attribute changes.\n * Updates the URLPattern when the path attribute changes.\n *\n * @param name - The attribute name that changed\n * @param _old - The old attribute value\n * @param value - The new attribute value\n */\n override attributeChangedCallback(name: string, _old: string | null, value: string | null): void {\n super.attributeChangedCallback(name, _old, value);\n\n switch (name) {\n case 'path':\n this[PATH_PATTERN] = value ? new URLPattern({ pathname: value }) : null;\n break;\n }\n }\n\n /**\n * Extracts the DocumentFragment from the template element.\n * Returns a weak reference to prevent memory leaks.\n *\n * @returns Weak reference to the template fragment, or null if no template found\n */\n #getTemplateFragment(): WeakRef<DocumentFragment> | null {\n const template = this.querySelector('template');\n\n return template ? new WeakRef(template.content) : null;\n }\n\n /**\n * Lifecycle callback when the element is disconnected from the DOM.\n * Cleans up the template observer.\n */\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n\n this.#templateObserver.disconnect();\n }\n}\n"]}