@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
package/router/index.js CHANGED
@@ -1,8 +1,7 @@
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
-
1
+ export { ThaRouter } from './tha-router.js';
2
+ export { ThaRoute } from './tha-route.js';
3
+ export { ThaRouterLink } from './tha-router-link.js';
4
+ export { ThaRouterOutlet } from './tha-router-outlet.js';
5
+ export { ThaRouterConfig } from './tha-router-config.js';
6
+ export { ThaRouterParam } from './tha-router-param.js';
8
7
  //# sourceMappingURL=index.js.map
@@ -1 +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"]}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
@@ -1,11 +1,14 @@
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");
1
+ 'use strict';
2
+
3
+ var signals = require('@lit-labs/signals');
4
+ var lit = require('lit');
5
+
6
6
  /**
7
7
  * A LitElement base class extended with SignalWatcher capabilities.
8
8
  *
9
9
  * This class allows LitElement components to reactively watch for changes
10
10
  */
11
- exports.SignalWatcherLitElement = (0, signals_1.SignalWatcher)(lit_1.LitElement);
11
+ const SignalWatcherLitElement = signals.SignalWatcher(lit.LitElement);
12
+
13
+ exports.SignalWatcherLitElement = SignalWatcherLitElement;
14
+ //# sourceMappingURL=signal-watcher-lit-element.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signal-watcher-lit-element.cjs","sources":["../../../../libs/elements/src/router/signal-watcher-lit-element.ts"],"sourcesContent":[null],"names":["SignalWatcher","LitElement"],"mappings":";;;;;AAkBA;;;;AAIG;MACU,uBAAuB,GAAGA,qBAAa,CAACC,cAAU;;;;"}
@@ -1,10 +1,12 @@
1
- import { SignalWatcher } from "@lit-labs/signals";
2
- import { LitElement } from "lit";
1
+ import { SignalWatcher } from '@lit-labs/signals';
2
+ import { LitElement } from 'lit';
3
+
3
4
  /**
4
5
  * A LitElement base class extended with SignalWatcher capabilities.
5
6
  *
6
7
  * This class allows LitElement components to reactively watch for changes
7
8
  */
8
- export const SignalWatcherLitElement = SignalWatcher(LitElement);
9
+ const SignalWatcherLitElement = SignalWatcher(LitElement);
9
10
 
11
+ export { SignalWatcherLitElement };
10
12
  //# sourceMappingURL=signal-watcher-lit-element.js.map
@@ -1 +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"]}
1
+ {"version":3,"file":"signal-watcher-lit-element.js","sources":["../../../../libs/elements/src/router/signal-watcher-lit-element.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAkBA;;;;AAIG;MACU,uBAAuB,GAAG,aAAa,CAAC,UAAU;;;;"}
@@ -1,21 +1,21 @@
1
- "use strict";
1
+ 'use strict';
2
+
3
+ var tslib = require('tslib');
4
+ var signals = require('@lit-labs/signals');
5
+ var lit = require('lit');
6
+ var decorators_js = require('lit/decorators.js');
7
+
2
8
  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
9
  /**
10
10
  * Symbol used to access the route's template fragment signal.
11
11
  * @internal
12
12
  */
13
- exports.FRAGMENT = Symbol('ThaRoute:fragment');
13
+ const FRAGMENT = Symbol('ThaRoute:fragment');
14
14
  /**
15
15
  * Symbol used to access the route's URLPattern instance.
16
16
  * @internal
17
17
  */
18
- exports.PATH_PATTERN = Symbol('ThaRoute:path-pattern');
18
+ const PATH_PATTERN = Symbol('ThaRoute:path-pattern');
19
19
  /**
20
20
  * A custom element that defines a route in the router.
21
21
  *
@@ -41,7 +41,7 @@ exports.PATH_PATTERN = Symbol('ThaRoute:path-pattern');
41
41
  * </tha-router>
42
42
  * ```
43
43
  */
44
- let ThaRoute = class ThaRoute extends lit_1.LitElement {
44
+ exports.ThaRoute = class ThaRoute extends lit.LitElement {
45
45
  constructor() {
46
46
  super(...arguments);
47
47
  /**
@@ -49,7 +49,7 @@ let ThaRoute = class ThaRoute extends lit_1.LitElement {
49
49
  * Automatically updates when the template content changes.
50
50
  * @internal
51
51
  */
52
- this[_a] = (0, signals_1.signal)(this.#getTemplateFragment());
52
+ this[_a] = signals.signal(this.#getTemplateFragment());
53
53
  /**
54
54
  * URLPattern instance for matching the current URL against this route's path.
55
55
  * @internal
@@ -66,10 +66,10 @@ let ThaRoute = class ThaRoute extends lit_1.LitElement {
66
66
  this.path = null;
67
67
  /** Observes changes to child elements to detect template updates */
68
68
  this.#templateObserver = new MutationObserver(() => {
69
- this[exports.FRAGMENT].set(this.#getTemplateFragment());
69
+ this[FRAGMENT].set(this.#getTemplateFragment());
70
70
  });
71
71
  }
72
- static { _a = exports.FRAGMENT, _b = exports.PATH_PATTERN; }
72
+ static { _a = FRAGMENT, _b = PATH_PATTERN; }
73
73
  /** Observes changes to child elements to detect template updates */
74
74
  #templateObserver;
75
75
  /**
@@ -92,7 +92,7 @@ let ThaRoute = class ThaRoute extends lit_1.LitElement {
92
92
  super.attributeChangedCallback(name, _old, value);
93
93
  switch (name) {
94
94
  case 'path':
95
- this[exports.PATH_PATTERN] = value ? new URLPattern({ pathname: value }) : null;
95
+ this[PATH_PATTERN] = value ? new URLPattern({ pathname: value }) : null;
96
96
  break;
97
97
  }
98
98
  }
@@ -115,11 +115,14 @@ let ThaRoute = class ThaRoute extends lit_1.LitElement {
115
115
  this.#templateObserver.disconnect();
116
116
  }
117
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);
118
+ tslib.__decorate([
119
+ decorators_js.property({ type: String }),
120
+ tslib.__metadata("design:type", Object)
121
+ ], exports.ThaRoute.prototype, "path", void 0);
122
+ exports.ThaRoute = tslib.__decorate([
123
+ decorators_js.customElement('tha-route')
124
+ ], exports.ThaRoute);
125
+
126
+ exports.FRAGMENT = FRAGMENT;
127
+ exports.PATH_PATTERN = PATH_PATTERN;
128
+ //# sourceMappingURL=tha-route.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tha-route.cjs","sources":["../../../../libs/elements/src/router/tha-route.ts"],"sourcesContent":[null],"names":["ThaRoute","LitElement","signal","__decorate","property","customElement"],"mappings":";;;;;;;;AAiBA;;;AAGG;MACU,QAAQ,GAAG,MAAM,CAAC,mBAAmB;AAClD;;;AAGG;MACU,YAAY,GAAG,MAAM,CAAC,uBAAuB;AAE1D;;;;;;;;;;;;;;;;;;;;;;;;AAwBG;AAEUA,gBAAQ,GAAd,MAAM,QAAS,SAAQC,cAAU,CAAA;AAAjC,IAAA,WAAA,GAAA;;AACL;;;;AAIG;QACH,IAAA,CAAA,EAAA,CAAU,GAAGC,cAAM,CAAmC,IAAI,CAAC,oBAAoB,EAAE,CAAC;AAClF;;;AAGG;QACH,IAAA,CAAA,EAAA,CAAc,GAAsB,IAAI;AAExC;;;;;;;AAOG;QAEH,IAAA,CAAA,IAAI,GAAkB,IAAI;;AAG1B,QAAA,IAAA,CAAA,iBAAiB,GAAG,IAAI,gBAAgB,CAAC,MAAK;YAC5C,IAAI,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,oBAAoB,EAAE,CAAC;AACjD,QAAA,CAAC,CAAC;IAmDJ;AAxEG,IAAA,SAAA,EAAA,GAAA,QAAQ,OAKR,YAAY,CAAA;;AAcb,IAAA,iBAAiB;AAIjB;;;AAGG;IACM,iBAAiB,GAAA;QACxB,KAAK,CAAC,iBAAiB,EAAE;AAEzB,QAAA,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;IAC3D;AAEA;;;;;;;AAOG;AACM,IAAA,wBAAwB,CAAC,IAAY,EAAE,IAAmB,EAAE,KAAoB,EAAA;QACvF,KAAK,CAAC,wBAAwB,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC;QAEjD,QAAQ,IAAI;AACV,YAAA,KAAK,MAAM;gBACT,IAAI,CAAC,YAAY,CAAC,GAAG,KAAK,GAAG,IAAI,UAAU,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI;gBACvE;;IAEN;AAEA;;;;;AAKG;IACH,oBAAoB,GAAA;QAClB,MAAM,QAAQ,GAAG,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC;AAE/C,QAAA,OAAO,QAAQ,GAAG,IAAI,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,IAAI;IACxD;AAEA;;;AAGG;IACM,oBAAoB,GAAA;QAC3B,KAAK,CAAC,oBAAoB,EAAE;AAE5B,QAAA,IAAI,CAAC,iBAAiB,CAAC,UAAU,EAAE;IACrC;;AAvDAC,gBAAA,CAAA;AADC,IAAAC,sBAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;AACA,CAAA,EAAAJ,gBAAA,CAAA,SAAA,EAAA,MAAA,EAAA,MAAA,CAAA;AAtBhBA,gBAAQ,GAAAG,gBAAA,CAAA;IADpBE,2BAAa,CAAC,WAAW;AACb,CAAA,EAAAL,gBAAQ,CA8EpB;;;;;"}
@@ -1,18 +1,19 @@
1
+ import { __decorate, __metadata } from 'tslib';
2
+ import { signal } from '@lit-labs/signals';
3
+ import { LitElement } from 'lit';
4
+ import { property, customElement } from 'lit/decorators.js';
5
+
1
6
  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
  /**
7
8
  * Symbol used to access the route's template fragment signal.
8
9
  * @internal
9
10
  */
10
- export const FRAGMENT = Symbol('ThaRoute:fragment');
11
+ const FRAGMENT = Symbol('ThaRoute:fragment');
11
12
  /**
12
13
  * Symbol used to access the route's URLPattern instance.
13
14
  * @internal
14
15
  */
15
- export const PATH_PATTERN = Symbol('ThaRoute:path-pattern');
16
+ const PATH_PATTERN = Symbol('ThaRoute:path-pattern');
16
17
  /**
17
18
  * A custom element that defines a route in the router.
18
19
  *
@@ -119,6 +120,6 @@ __decorate([
119
120
  ThaRoute = __decorate([
120
121
  customElement('tha-route')
121
122
  ], ThaRoute);
122
- export { ThaRoute };
123
123
 
124
+ export { FRAGMENT, PATH_PATTERN, ThaRoute };
124
125
  //# sourceMappingURL=tha-route.js.map
@@ -1 +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"]}
1
+ {"version":3,"file":"tha-route.js","sources":["../../../../libs/elements/src/router/tha-route.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;AAiBA;;;AAGG;MACU,QAAQ,GAAG,MAAM,CAAC,mBAAmB;AAClD;;;AAGG;MACU,YAAY,GAAG,MAAM,CAAC,uBAAuB;AAE1D;;;;;;;;;;;;;;;;;;;;;;;;AAwBG;AAEI,IAAM,QAAQ,GAAd,MAAM,QAAS,SAAQ,UAAU,CAAA;AAAjC,IAAA,WAAA,GAAA;;AACL;;;;AAIG;QACH,IAAA,CAAA,EAAA,CAAU,GAAG,MAAM,CAAmC,IAAI,CAAC,oBAAoB,EAAE,CAAC;AAClF;;;AAGG;QACH,IAAA,CAAA,EAAA,CAAc,GAAsB,IAAI;AAExC;;;;;;;AAOG;QAEH,IAAA,CAAA,IAAI,GAAkB,IAAI;;AAG1B,QAAA,IAAA,CAAA,iBAAiB,GAAG,IAAI,gBAAgB,CAAC,MAAK;YAC5C,IAAI,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,oBAAoB,EAAE,CAAC;AACjD,QAAA,CAAC,CAAC;IAmDJ;AAxEG,IAAA,SAA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
- const decorators_js_1 = require("lit/decorators.js");
6
- const history_1 = require("./history");
7
- const history_managed_1 = require("./history-managed");
8
- const signal_watcher_lit_element_1 = require("./signal-watcher-lit-element");
9
- const noop_1 = require("@telperion/js-utils/function/noop");
1
+ 'use strict';
2
+
3
+ var tslib = require('tslib');
4
+ var decorators_js = require('lit/decorators.js');
5
+ var history = require('./history.cjs');
6
+ var historyManaged = require('./history-managed.cjs');
7
+ var signalWatcherLitElement = require('./signal-watcher-lit-element.cjs');
8
+ var noop = require('@telperion/js-utils/function/noop');
9
+
10
10
  /**
11
11
  * A custom element for configuring router history settings.
12
12
  *
@@ -190,13 +190,13 @@ const noop_1 = require("@telperion/js-utils/function/noop");
190
190
  * </tha-router-config>
191
191
  * ```
192
192
  */
193
- let ThaRouterConfig = class ThaRouterConfig extends (0, history_managed_1.HistoryManaged)(signal_watcher_lit_element_1.SignalWatcherLitElement) {
193
+ exports.ThaRouterConfig = class ThaRouterConfig extends historyManaged.HistoryManaged(signalWatcherLitElement.SignalWatcherLitElement) {
194
194
  /**
195
195
  * Cleanup function for the global history effect.
196
196
  * Only used when the element is placed in `<head>`.
197
197
  * @private
198
198
  */
199
- #globalHistoryUnsubscribe = noop_1.noop;
199
+ #globalHistoryUnsubscribe = noop.noop;
200
200
  /**
201
201
  * Called when the element is connected to the DOM.
202
202
  *
@@ -207,10 +207,10 @@ let ThaRouterConfig = class ThaRouterConfig extends (0, history_managed_1.Histor
207
207
  super.connectedCallback();
208
208
  if (!document.head.contains(this))
209
209
  return;
210
- console.log('ThaRouterConfig: Setting global history type to', this[history_managed_1.HISTORY_TYPE].get());
210
+ console.log('ThaRouterConfig: Setting global history type to', this[historyManaged.HISTORY_TYPE].get());
211
211
  // Set the global history type when this element is connected in <head>
212
212
  this.#globalHistoryUnsubscribe = this.updateEffect(() => {
213
- history_1.GLOBAL_HISTORY_TYPE.set(this[history_managed_1.HISTORY_TYPE].get());
213
+ history.GLOBAL_HISTORY_TYPE.set(this[historyManaged.HISTORY_TYPE].get());
214
214
  });
215
215
  }
216
216
  /**
@@ -235,7 +235,7 @@ let ThaRouterConfig = class ThaRouterConfig extends (0, history_managed_1.Histor
235
235
  return this;
236
236
  }
237
237
  };
238
- exports.ThaRouterConfig = ThaRouterConfig;
239
- exports.ThaRouterConfig = ThaRouterConfig = tslib_1.__decorate([
240
- (0, decorators_js_1.customElement)('tha-router-config')
241
- ], ThaRouterConfig);
238
+ exports.ThaRouterConfig = tslib.__decorate([
239
+ decorators_js.customElement('tha-router-config')
240
+ ], exports.ThaRouterConfig);
241
+ //# sourceMappingURL=tha-router-config.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tha-router-config.cjs","sources":["../../../../libs/elements/src/router/tha-router-config.ts"],"sourcesContent":[null],"names":["ThaRouterConfig","HistoryManaged","SignalWatcherLitElement","noop","HISTORY_TYPE","GLOBAL_HISTORY_TYPE","__decorate","customElement"],"mappings":";;;;;;;;;AAoBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsLG;AAEUA,uBAAe,GAArB,MAAM,eAAgB,SAAQC,6BAAc,CAACC,+CAAuB,CAAC,CAAA;AAC1E;;;;AAIG;IACH,yBAAyB,GAAGC,SAAI;AAEhC;;;;;AAKG;IACM,iBAAiB,GAAA;QACxB,KAAK,CAAC,iBAAiB,EAAE;QAEzB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;YAAE;AAEnC,QAAA,OAAO,CAAC,GAAG,CAAC,iDAAiD,EAAE,IAAI,CAACC,2BAAY,CAAC,CAAC,GAAG,EAAE,CAAC;;QAGxF,IAAI,CAAC,yBAAyB,GAAG,IAAI,CAAC,YAAY,CAAC,MAAK;YACtDC,2BAAmB,CAAC,GAAG,CAAC,IAAI,CAACD,2BAAY,CAAC,CAAC,GAAG,EAAG,CAAC;AACpD,QAAA,CAAC,CAAC;IACJ;AAEA;;;;AAIG;IACM,oBAAoB,GAAA;QAC3B,KAAK,CAAC,oBAAoB,EAAE;AAE5B,QAAA,IAAI;YACF,IAAI,CAAC,yBAAyB,EAAE;QAClC;QAAE,MAAM,EAAC;IACX;AAEA;;;;;AAKG;IACgB,gBAAgB,GAAA;AACjC,QAAA,OAAO,IAAI;IACb;;AAhDWJ,uBAAe,GAAAM,gBAAA,CAAA;IAD3BC,2BAAa,CAAC,mBAAmB;AACrB,CAAA,EAAAP,uBAAe,CAiD3B;;"}
@@ -1,9 +1,10 @@
1
- import { __decorate } from "tslib";
2
- import { customElement } from "lit/decorators.js";
3
- import { GLOBAL_HISTORY_TYPE } from "./history";
4
- import { HISTORY_TYPE, HistoryManaged } from "./history-managed";
5
- import { SignalWatcherLitElement } from "./signal-watcher-lit-element";
6
- import { noop } from "@telperion/js-utils/function/noop";
1
+ import { __decorate } from 'tslib';
2
+ import { customElement } from 'lit/decorators.js';
3
+ import { GLOBAL_HISTORY_TYPE } from './history.js';
4
+ import { HistoryManaged, HISTORY_TYPE } from './history-managed.js';
5
+ import { SignalWatcherLitElement } from './signal-watcher-lit-element.js';
6
+ import { noop } from '@telperion/js-utils/function/noop';
7
+
7
8
  /**
8
9
  * A custom element for configuring router history settings.
9
10
  *
@@ -235,6 +236,6 @@ let ThaRouterConfig = class ThaRouterConfig extends HistoryManaged(SignalWatcher
235
236
  ThaRouterConfig = __decorate([
236
237
  customElement('tha-router-config')
237
238
  ], ThaRouterConfig);
238
- export { ThaRouterConfig };
239
239
 
240
+ export { ThaRouterConfig };
240
241
  //# sourceMappingURL=tha-router-config.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../libs/elements/src/router/tha-router-config.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,aAAa,EAAE,MAAM,mB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gB,gBAAgB;QACjC,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAA;AAjDY,eAAe;IAD3B,aAAa,CAAC,mBAAmB,CAAC;GACtB,eAAe,CAiD3B","file":"tha-router-config.js","sourcesContent":["import { LitElement } from \"lit\";\nimport { customElement } from \"lit/decorators.js\";\nimport { GLOBAL_HISTORY_TYPE } from \"./history\";\nimport { HISTORY_TYPE, HistoryManaged } from \"./history-managed\";\nimport { SignalWatcherLitElement } from \"./signal-watcher-lit-element\";\nimport { noop } from \"@telperion/js-utils/function/noop\";\n\ndeclare global {\n interface HTMLElementTagNameMap {\n /**\n * A configuration element for managing router history settings.\n *\n * Behavior depends on placement:\n * - **In `<head>`**: Sets global history for all routers\n * - **In `<body>`**: Provides local history for descendant routers\n */\n \"tha-router-config\": ThaRouterConfig;\n }\n}\n\n/**\n * A custom element for configuring router history settings.\n *\n * This element serves dual purposes depending on its placement in the DOM:\n *\n * ## Global Configuration (placed in `<head>`)\n *\n * When placed in the `<head>` element, it sets the **global default history**\n * for all routers in the application that don't specify their own history or\n * inherit from a parent.\n *\n * ```html\n * <head>\n * <!-- All routers will use hash routing by default -->\n * <tha-router-config history=\"hash\"></tha-router-config>\n * </head>\n * <body>\n * <tha-router>\n * <!-- Uses hash history (global default) -->\n * <tha-route path=\"/home\">...</tha-route>\n * </tha-router>\n * </body>\n * ```\n *\n * ## Local Configuration (placed in `<body>`)\n *\n * When placed in the `<body>` element, it provides history configuration\n * for its **descendant routers only**. This allows different sections of\n * your application to use different history strategies.\n *\n * ```html\n * <body>\n * <!-- Section 1: Hash routing -->\n * <tha-router-config history=\"hash\">\n * <tha-router>\n * <!-- Uses hash history from parent config -->\n * <tha-route path=\"/dashboard\">...</tha-route>\n * </tha-router>\n * </tha-router-config>\n *\n * <!-- Section 2: Memory routing (isolated) -->\n * <tha-router-config history=\"memory\">\n * <tha-router>\n * <!-- Uses memory history from parent config -->\n * <tha-route path=\"/preview\">...</tha-route>\n * </tha-router>\n * </tha-router-config>\n * </body>\n * ```\n *\n * ## Usage Patterns\n *\n * ### Set Global Default\n *\n * Place in `<head>` to configure all routers:\n *\n * ```html\n * <!DOCTYPE html>\n * <html>\n * <head>\n * <tha-router-config history=\"browser\"></tha-router-config>\n * </head>\n * <body>\n * <!-- All routers use browser history -->\n * </body>\n * </html>\n * ```\n *\n * ### Override for Specific Section\n *\n * Use local config to override global default:\n *\n * ```html\n * <head>\n * <!-- Global: browser history -->\n * <tha-router-config history=\"browser\"></tha-router-config>\n * </head>\n * <body>\n * <!-- Main app uses browser history -->\n * <tha-router>...</tha-router>\n *\n * <!-- Admin section uses hash history -->\n * <tha-router-config history=\"hash\">\n * <tha-router>...</tha-router>\n * </tha-router-config>\n * </body>\n * ```\n *\n * ### Isolate Components with Memory History\n *\n * Use named memory history for component isolation:\n *\n * ```html\n * <body>\n * <!-- Each component has independent navigation -->\n * <tha-router-config history=\"memory:component1\">\n * <my-widget>\n * <tha-router>...</tha-router>\n * </my-widget>\n * </tha-router-config>\n *\n * <tha-router-config history=\"memory:component2\">\n * <my-widget>\n * <tha-router>...</tha-router>\n * </my-widget>\n * </tha-router-config>\n * </body>\n * ```\n *\n * ### Testing with Memory History\n *\n * Use memory history to avoid affecting browser URL during tests:\n *\n * ```typescript\n * import { fixture, html } from '@open-wc/testing';\n *\n * it('should navigate', async () => {\n * const el = await fixture(html`\n * <tha-router-config history=\"memory:test\">\n * <tha-router>\n * <tha-route path=\"/test\">Test Page</tha-route>\n * </tha-router>\n * </tha-router-config>\n * `);\n *\n * // Test navigation without affecting browser URL\n * });\n * ```\n *\n * ## History Resolution\n *\n * Router components resolve their history in this order:\n *\n * 1. **Own `history` attribute** (highest priority)\n * 2. **Parent `tha-router-config`** (local configuration)\n * 3. **Global `tha-router-config`** (in `<head>`)\n * 4. **Default** (`\"browser\"`)\n *\n * ## Best Practices\n *\n * ✅ **DO**: Place one `tha-router-config` in `<head>` for global settings\n *\n * ```html\n * <head>\n * <tha-router-config history=\"browser\"></tha-router-config>\n * </head>\n * ```\n *\n * ✅ **DO**: Use local configs for sections with different routing needs\n *\n * ```html\n * <tha-router-config history=\"memory\">\n * <component-preview>...</component-preview>\n * </tha-router-config>\n * ```\n *\n * ✅ **DO**: Use named memory history for isolated components\n *\n * ```html\n * <tha-router-config history=\"memory:sidebar\">\n * <sidebar-nav>...</sidebar-nav>\n * </tha-router-config>\n * ```\n *\n * ❌ **DON'T**: Place multiple configs in `<head>` (last one wins)\n *\n * ```html\n * <head>\n * <tha-router-config history=\"browser\"></tha-router-config>\n * <tha-router-config history=\"hash\"></tha-router-config> <!-- Overrides above -->\n * </head>\n * ```\n *\n * ❌ **DON'T**: Nest configs unnecessarily (inner configs take precedence)\n *\n * ```html\n * <tha-router-config history=\"browser\">\n * <tha-router-config history=\"hash\">\n * <!-- Uses hash, not browser -->\n * </tha-router-config>\n * </tha-router-config>\n * ```\n */\n@customElement('tha-router-config')\nexport class ThaRouterConfig extends HistoryManaged(SignalWatcherLitElement) {\n /**\n * Cleanup function for the global history effect.\n * Only used when the element is placed in `<head>`.\n * @private\n */\n #globalHistoryUnsubscribe = noop;\n\n /**\n * Called when the element is connected to the DOM.\n *\n * - If in `<head>`: Sets up a reactive effect to update global history\n * - If in `<body>`: Only provides history to descendants (no special setup)\n */\n override connectedCallback(): void {\n super.connectedCallback();\n\n if (!document.head.contains(this)) return;\n\n console.log('ThaRouterConfig: Setting global history type to', this[HISTORY_TYPE].get());\n\n // Set the global history type when this element is connected in <head>\n this.#globalHistoryUnsubscribe = this.updateEffect(() => {\n GLOBAL_HISTORY_TYPE.set(this[HISTORY_TYPE].get()!);\n });\n }\n\n /**\n * Called when the element is disconnected from the DOM.\n *\n * Cleans up the global history effect if it was set up.\n */\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n\n try {\n this.#globalHistoryUnsubscribe();\n } catch {}\n }\n\n /**\n * Creates the render root for the element.\n * Returns the element itself to render children in light DOM.\n *\n * @returns The element itself (not a shadow root)\n */\n protected override createRenderRoot() {\n return this;\n }\n}\n"]}
1
+ {"version":3,"file":"tha-router-config.js","sources":["../../../../libs/elements/src/router/tha-router-config.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;AAoBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsLG;AAEI,IAAM,eAAe,GAArB,MAAM,eAAgB,SAAQ,cAAc,CAAC,uBAAuB,CAAC,CAAA;AAC1E;;;;AAIG;IACH,yBAAyB,GAAG,IAAI;AAEhC;;;;;AAKG;IACM,iBAAiB,GAAA;QACxB,KAAK,CAAC,iBAAiB,EAAE;QAEzB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;YAAE;AAEnC,QAAA,OAAO,CAAC,GAAG,CAAC,iDAAiD,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC,GAAG,EAAE,CAAC;;QAGxF,IAAI,CAAC,yBAAyB,GAAG,IAAI,CAAC,YAAY,CAAC,MAAK;YACtD,mBAAmB,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,GAAG,EAAG,CAAC;AACpD,QAAA,CAAC,CAAC;IACJ;AAEA;;;;AAIG;IACM,oBAAoB,GAAA;QAC3B,KAAK,CAAC,oBAAoB,EAAE;AAE5B,QAAA,IAAI;YACF,IAAI,CAAC,yBAAyB,EAAE;QAClC;QAAE,MAAM,EAAC;IACX;AAEA;;;;;AAKG;IACgB,gBAAgB,GAAA;AACjC,QAAA,OAAO,IAAI;IACb;;AAhDW,eAAe,GAAA,UAAA,CAAA;IAD3B,aAAa,CAAC,mBAAmB;AACrB,CAAA,EAAA,eAAe,CAiD3B;;;;"}
@@ -1,14 +1,14 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ThaRouterLink = void 0;
4
- const tslib_1 = require("tslib");
5
- const lit_1 = require("lit");
6
- const decorators_js_1 = require("lit/decorators.js");
7
- const signals_1 = require("@lit-labs/signals");
8
- const compact_1 = require("@telperion/js-utils/array/compact");
9
- const noop_1 = require("@telperion/js-utils/function/noop");
10
- const history_managed_1 = require("./history-managed");
11
- const signal_watcher_lit_element_1 = require("./signal-watcher-lit-element");
1
+ 'use strict';
2
+
3
+ var tslib = require('tslib');
4
+ var lit = require('lit');
5
+ var decorators_js = require('lit/decorators.js');
6
+ var signals = require('@lit-labs/signals');
7
+ var compact = require('@telperion/js-utils/array/compact');
8
+ var noop = require('@telperion/js-utils/function/noop');
9
+ var historyManaged = require('./history-managed.cjs');
10
+ var signalWatcherLitElement = require('./signal-watcher-lit-element.cjs');
11
+
12
12
  /**
13
13
  * A custom element that provides navigation links for client-side routing.
14
14
  *
@@ -33,7 +33,7 @@ const signal_watcher_lit_element_1 = require("./signal-watcher-lit-element");
33
33
  * <tha-router-link to="forward">Forward →</tha-router-link>
34
34
  * ```
35
35
  */
36
- let ThaRouterLink = class ThaRouterLink extends (0, history_managed_1.HistoryManaged)(signal_watcher_lit_element_1.SignalWatcherLitElement) {
36
+ exports.ThaRouterLink = class ThaRouterLink extends historyManaged.HistoryManaged(signalWatcherLitElement.SignalWatcherLitElement) {
37
37
  constructor() {
38
38
  super(...arguments);
39
39
  /**
@@ -54,13 +54,13 @@ let ThaRouterLink = class ThaRouterLink extends (0, history_managed_1.HistoryMan
54
54
  */
55
55
  this.active = false;
56
56
  /** Cleanup function for the active state effect */
57
- this.#activeStateEffectCleaner = noop_1.noop;
57
+ this.#activeStateEffectCleaner = noop.noop;
58
58
  /** Cleanup function to remove history listener */
59
- this.#historyListenerRemover = noop_1.noop;
59
+ this.#historyListenerRemover = noop.noop;
60
60
  /** Signal containing the current 'to' value */
61
- this.#to = (0, signals_1.signal)(null);
61
+ this.#to = signals.signal(null);
62
62
  /** Computed URLPattern for matching against the current route */
63
- this.#urlPattern = (0, signals_1.computed)(() => {
63
+ this.#urlPattern = signals.computed(() => {
64
64
  const to = this.#to.get();
65
65
  if (!to || to === 'back' || to === 'forward')
66
66
  return null;
@@ -83,8 +83,8 @@ let ThaRouterLink = class ThaRouterLink extends (0, history_managed_1.HistoryMan
83
83
  * @param event - The click event
84
84
  */
85
85
  this.#handleClick = (event) => {
86
- const history = this[history_managed_1.HISTORY].get();
87
- console.log(this[history_managed_1.HISTORY_TYPE].get());
86
+ const history = this[historyManaged.HISTORY].get();
87
+ console.log(this[historyManaged.HISTORY_TYPE].get());
88
88
  if (this.to === 'back')
89
89
  return history.back();
90
90
  if (this.to === 'forward')
@@ -92,8 +92,8 @@ let ThaRouterLink = class ThaRouterLink extends (0, history_managed_1.HistoryMan
92
92
  const currentPath = history.location.pathname + history.location.search + history.location.hash;
93
93
  let link = this.to;
94
94
  if (link?.startsWith('.')) {
95
- const segments = (0, compact_1.compact)(currentPath.split('/'));
96
- const linkSegments = (0, compact_1.compact)(link.split('/'));
95
+ const segments = compact.compact(currentPath.split('/'));
96
+ const linkSegments = compact.compact(link.split('/'));
97
97
  for (const segment of linkSegments) {
98
98
  if (segment === '..') {
99
99
  segments.pop();
@@ -105,7 +105,7 @@ let ThaRouterLink = class ThaRouterLink extends (0, history_managed_1.HistoryMan
105
105
  link = '/' + segments.join('/');
106
106
  }
107
107
  link = link?.replaceAll('//', '/');
108
- this[history_managed_1.HISTORY].get()?.push(link || '/');
108
+ this[historyManaged.HISTORY].get()?.push(link || '/');
109
109
  };
110
110
  }
111
111
  /** Injects global styles for tha-router-link elements to show pointer cursor */
@@ -113,7 +113,7 @@ let ThaRouterLink = class ThaRouterLink extends (0, history_managed_1.HistoryMan
113
113
  const styleEl = document.createElement("style");
114
114
  styleEl.setAttribute("type", "text/css");
115
115
  styleEl.setAttribute("data-id", "tha-router-link-styles");
116
- styleEl.textContent = (0, lit_1.css) `
116
+ styleEl.textContent = lit.css `
117
117
  tha-router-link {
118
118
  cursor: pointer;
119
119
  }
@@ -136,12 +136,12 @@ let ThaRouterLink = class ThaRouterLink extends (0, history_managed_1.HistoryMan
136
136
  super.connectedCallback();
137
137
  this.addEventListener('click', this.#handleClick);
138
138
  this.#activeStateEffectCleaner = this.updateEffect(() => {
139
- const history = this[history_managed_1.HISTORY].get();
139
+ const history = this[historyManaged.HISTORY].get();
140
140
  const pattern = this.#urlPattern.get();
141
141
  this.active = pattern?.test({ pathname: history?.location.pathname ?? '' }) ?? false;
142
142
  this.#historyListenerRemover = history?.listen(() => {
143
143
  this.active = pattern?.test({ pathname: history.location.pathname }) ?? false;
144
- }) ?? noop_1.noop;
144
+ }) ?? noop.noop;
145
145
  });
146
146
  }
147
147
  /**
@@ -195,15 +195,15 @@ let ThaRouterLink = class ThaRouterLink extends (0, history_managed_1.HistoryMan
195
195
  return this;
196
196
  }
197
197
  };
198
- exports.ThaRouterLink = ThaRouterLink;
199
- tslib_1.__decorate([
200
- (0, decorators_js_1.property)({ type: String }),
201
- tslib_1.__metadata("design:type", Object)
202
- ], ThaRouterLink.prototype, "to", void 0);
203
- tslib_1.__decorate([
204
- (0, decorators_js_1.property)({ type: Boolean, reflect: true }),
205
- tslib_1.__metadata("design:type", Object)
206
- ], ThaRouterLink.prototype, "active", void 0);
207
- exports.ThaRouterLink = ThaRouterLink = tslib_1.__decorate([
208
- (0, decorators_js_1.customElement)("tha-router-link")
209
- ], ThaRouterLink);
198
+ tslib.__decorate([
199
+ decorators_js.property({ type: String }),
200
+ tslib.__metadata("design:type", Object)
201
+ ], exports.ThaRouterLink.prototype, "to", void 0);
202
+ tslib.__decorate([
203
+ decorators_js.property({ type: Boolean, reflect: true }),
204
+ tslib.__metadata("design:type", Object)
205
+ ], exports.ThaRouterLink.prototype, "active", void 0);
206
+ exports.ThaRouterLink = tslib.__decorate([
207
+ decorators_js.customElement("tha-router-link")
208
+ ], exports.ThaRouterLink);
209
+ //# sourceMappingURL=tha-router-link.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tha-router-link.cjs","sources":["../../../../libs/elements/src/router/tha-router-link.ts"],"sourcesContent":[null],"names":["ThaRouterLink","HistoryManaged","SignalWatcherLitElement","noop","signal","computed","HISTORY","HISTORY_TYPE","compact","css","__decorate","property","customElement"],"mappings":";;;;;;;;;;;AA8BA;;;;;;;;;;;;;;;;;;;;;;;AAuBG;AAEUA,qBAAa,GAAnB,MAAM,aAAc,SAAQC,6BAAc,CAACC,+CAAuB,CAAC,CAAA;AAAnE,IAAA,WAAA,GAAA;;AAeL;;;;;;;AAOG;QAEH,IAAA,CAAA,EAAE,GAAoB,IAAI;AAE1B;;;;;;AAMG;QAEH,IAAA,CAAA,MAAM,GAAG,KAAK;;QAGd,IAAA,CAAA,yBAAyB,GAAGC,SAAI;;QAEhC,IAAA,CAAA,uBAAuB,GAAGA,SAAI;;AAG9B,QAAA,IAAA,CAAA,GAAG,GAAGC,cAAM,CAAkB,IAAI,CAAC;;AAEnC,QAAA,IAAA,CAAA,WAAW,GAAGC,gBAAQ,CAAC,MAAK;YAC1B,MAAM,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE;YACzB,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,MAAM,IAAI,EAAE,KAAK,SAAS;AAAE,gBAAA,OAAO,IAAI;AAEzD,YAAA,IAAI;gBACF,OAAO,IAAI,UAAU,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;YACzC;AAAE,YAAA,MAAM;AACN,gBAAA,OAAO,IAAI;YACb;AACF,QAAA,CAAC,CAAC;AAyCF;;;;;;;;;;AAUG;AACH,QAAA,IAAA,CAAA,YAAY,GAAG,CAAC,KAAiB,KAAI;YACnC,MAAM,OAAO,GAAG,IAAI,CAACC,sBAAO,CAAC,CAAC,GAAG,EAAE;YAEnC,OAAO,CAAC,GAAG,CAAC,IAAI,CAACC,2BAAY,CAAC,CAAC,GAAG,EAAE,CAAC;AAErC,YAAA,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,CAAC,GAAG,CAAC,GAAG,CAAC,KAAwB,CAAC;gBACtC;;IAEN;AAEA;;;;;;;;;;AAUG;AACH,IAAA,YAAY;AA+BZ;;;AAGG;IACM,oBAAoB,GAAA;QAC3B,KAAK,CAAC,oBAAoB,EAAE;AAE5B,QAAA,IAAI;YACF,IAAI,CAAC,yBAAyB,EAAE;QAClC;QAAE,MAAM,EAAC;QAET,IAAI,CAAC,uBAAuB,EAAE;QAC9B,IAAI,CAAC,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,YAAY,CAAC;IACtD;AAEA;;;;;AAKG;IACgB,gBAAgB,GAAA;AACjC,QAAA,OAAO,IAAI;IACb;;AAvIAO,gBAAA,CAAA;AADC,IAAAC,sBAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;AACA,CAAA,EAAAX,qBAAA,CAAA,SAAA,EAAA,IAAA,EAAA,MAAA,CAAA;AAU3BU,gBAAA,CAAA;IADCC,sBAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;;AAC5B,CAAA,EAAAX,qBAAA,CAAA,SAAA,EAAA,QAAA,EAAA,MAAA,CAAA;AAlCJA,qBAAa,GAAAU,gBAAA,CAAA;IADzBE,2BAAa,CAAC,iBAAiB;AACnB,CAAA,EAAAZ,qBAAa,CAgKzB;;"}
@@ -1,11 +1,12 @@
1
- import { __decorate, __metadata } from "tslib";
2
- import { css } from "lit";
3
- import { customElement, property } from "lit/decorators.js";
4
- import { computed, signal } from "@lit-labs/signals";
1
+ import { __decorate, __metadata } from 'tslib';
2
+ import { css } from 'lit';
3
+ import { property, customElement } from 'lit/decorators.js';
4
+ import { signal, computed } from '@lit-labs/signals';
5
5
  import { compact } from '@telperion/js-utils/array/compact';
6
- import { noop } from "@telperion/js-utils/function/noop";
7
- import { HISTORY, HISTORY_TYPE, HistoryManaged } from "./history-managed";
8
- import { SignalWatcherLitElement } from "./signal-watcher-lit-element";
6
+ import { noop } from '@telperion/js-utils/function/noop';
7
+ import { HistoryManaged, HISTORY, HISTORY_TYPE } from './history-managed.js';
8
+ import { SignalWatcherLitElement } from './signal-watcher-lit-element.js';
9
+
9
10
  /**
10
11
  * A custom element that provides navigation links for client-side routing.
11
12
  *
@@ -203,6 +204,6 @@ __decorate([
203
204
  ThaRouterLink = __decorate([
204
205
  customElement("tha-router-link")
205
206
  ], ThaRouterLink);
206
- export { ThaRouterLink };
207
207
 
208
+ export { ThaRouterLink };
208
209
  //# sourceMappingURL=tha-router-link.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../libs/elements/src/router/tha-router-link.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAc,MAAM,KAAK,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,mCAAmC,CAAC;AAC5D,OAAO,EAAE,IAAI,EAAE,MAAM,mCAAmC,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAwBvE;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEI,IAAM,aAAa,GAAnB,MAAM,aAAc,SAAQ,cAAc,CAAC,uBAAuB,CAAC;IAAnE;;QAeL;;;;;;;WAOG;QAEH,OAAE,GAAoB,IAAI,CAAC;QAE3B;;;;;;WAMG;QAEH,WAAM,GAAG,KAAK,CAAC;QAEf,mDAAmD;QACnD,8BAAyB,GAAG,IAAI,CAAC;QACjC,kDAAkD;QAClD,4BAAuB,GAAG,IAAI,CAAC;QAE/B,+CAA+C;QAC/C,QAAG,GAAG,MAAM,CAAkB,IAAI,CAAC,CAAC;QACpC,iEAAiE;QACjE,gBAAW,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AI,CAAC;IACd,CAAC;CACF,CAAA;AAxIC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;yCACA;AAU3B;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;;6CAC5B;AAlCJ,aAAa;IADzB,aAAa,CAAC,iBAAiB,CAAC;GACpB,aAAa,CAgKzB","file":"tha-router-link.js","sourcesContent":["import { css, LitElement } from \"lit\";\nimport { customElement, property } from \"lit/decorators.js\";\nimport { computed, signal } from \"@lit-labs/signals\";\nimport { compact } from '@telperion/js-utils/array/compact';\nimport { noop } from \"@telperion/js-utils/function/noop\";\nimport { HISTORY, HISTORY_TYPE, HistoryManaged } from \"./history-managed\";\nimport { SignalWatcherLitElement } from \"./signal-watcher-lit-element\";\n\ndeclare global {\n interface HTMLElementTagNameMap {\n /**\n * A navigation link element for client-side routing.\n * It handles click events to navigate using the History API without full page reloads.\n * The `to` attribute specifies the navigation target (absolute, relative, or 'back'/'forward').\n * The `active` attribute reflects whether the link matches the current route.\n * The `history` attribute specifies which history instance to use.\n */\n \"tha-router-link\": ThaRouterLink;\n }\n}\n\n/** Navigation symbols for browser history operations */\ntype LinkSymbol = 'back' | 'forward';\n/** Absolute path starting with / */\ntype AbsolutePath = '/' | `/${string}`;\n/** Relative path starting with ./ or ../ */\ntype RelativePath = './' | `./${string}` | `../${string}`;\n/** Union of all supported link types */\ntype LinkType = LinkSymbol | AbsolutePath | RelativePath;\n\n/**\n * A custom element that provides navigation links for client-side routing.\n *\n * The link handles click events to navigate using the History API, preventing\n * full page reloads. It supports absolute paths, relative paths, and special\n * symbols ('back', 'forward') for browser history navigation.\n *\n * The `active` attribute automatically reflects whether the link's path\n * matches the current route, useful for styling active navigation items.\n *\n * @example\n * ```html\n * <!-- Absolute path -->\n * <tha-router-link to=\"/about\">About</tha-router-link>\n *\n * <!-- Relative path -->\n * <tha-router-link to=\"./details\">Details</tha-router-link>\n * <tha-router-link to=\"../users\">Back to Users</tha-router-link>\n *\n * <!-- History navigation -->\n * <tha-router-link to=\"back\">← Back</tha-router-link>\n * <tha-router-link to=\"forward\">Forward →</tha-router-link>\n * ```\n */\n@customElement(\"tha-router-link\")\nexport class ThaRouterLink extends HistoryManaged(SignalWatcherLitElement) {\n /** Injects global styles for tha-router-link elements to show pointer cursor */\n static {\n const styleEl = document.createElement(\"style\");\n\n styleEl.setAttribute(\"type\", \"text/css\");\n styleEl.setAttribute(\"data-id\", \"tha-router-link-styles\");\n styleEl.textContent = css`\n tha-router-link {\n cursor: pointer;\n }\n `.toString();\n document.head.appendChild(styleEl);\n }\n\n /**\n * The navigation target. Can be:\n * - Absolute path: `/users`, `/about`\n * - Relative path: `./details`, `../users`\n * - History symbol: `back`, `forward`\n *\n * @attr to\n */\n @property({ type: String })\n to: LinkType | null = null;\n\n /**\n * Reflects whether this link matches the current route.\n * Automatically updated when the route changes.\n *\n * @attr active\n * @readonly\n */\n @property({ type: Boolean, reflect: true })\n active = false;\n\n /** Cleanup function for the active state effect */\n #activeStateEffectCleaner = noop;\n /** Cleanup function to remove history listener */\n #historyListenerRemover = noop;\n\n /** Signal containing the current 'to' value */\n #to = signal<LinkType | null>(null);\n /** Computed URLPattern for matching against the current route */\n #urlPattern = computed(() => {\n const to = this.#to.get();\n if (!to || to === 'back' || to === 'forward') return null;\n\n try {\n return new URLPattern({ pathname: to });\n } catch {\n return null;\n }\n });\n\n /**\n * Lifecycle callback when the element is connected to the DOM.\n * Sets up click listener and active state tracking effect.\n */\n override connectedCallback(): void {\n super.connectedCallback();\n\n this.addEventListener('click', this.#handleClick);\n\n this.#activeStateEffectCleaner = (this as any).updateEffect(() => {\n const history = this[HISTORY].get();\n const pattern = this.#urlPattern.get();\n\n this.active = pattern?.test({ pathname: history?.location.pathname ?? '' }) ?? false;\n\n this.#historyListenerRemover = history?.listen(() => {\n this.active = pattern?.test({ pathname: history.location.pathname }) ?? false;\n }) ?? noop;\n });\n }\n\n /**\n * Lifecycle callback when an attribute changes.\n * Updates signals when history or to attributes change.\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 'to':\n this.#to.set(value as LinkType | null);\n break;\n }\n }\n\n /**\n * Handles click events to perform navigation.\n *\n * - For 'back'/'forward', calls the corresponding history method\n * - For relative paths, resolves them against the current location\n * - For absolute paths, navigates directly\n *\n * Prevents default link behavior to avoid full page reloads.\n *\n * @param event - The click event\n */\n #handleClick = (event: MouseEvent) => {\n const history = this[HISTORY].get();\n\n console.log(this[HISTORY_TYPE].get());\n\n if (this.to === 'back') return history.back();\n if (this.to === 'forward') return history.forward();\n\n const currentPath = history.location.pathname + history.location.search + history.location.hash;\n\n let link = this.to;\n if (link?.startsWith('.')) {\n const segments = compact(currentPath.split('/'));\n const linkSegments = compact(link!.split('/'));\n\n for (const segment of linkSegments) {\n if (segment === '..') {\n segments.pop();\n } else if (segment !== '.') {\n segments.push(segment);\n }\n }\n\n link = '/' + segments.join('/');\n }\n\n link = link?.replaceAll('//', '/') as '/';\n\n this[HISTORY].get()?.push(link || '/');\n };\n\n /**\n * Lifecycle callback when the element is disconnected from the DOM.\n * Cleans up effects, listeners, and event handlers.\n */\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n\n try {\n this.#activeStateEffectCleaner();\n } catch {}\n\n this.#historyListenerRemover();\n this.removeEventListener('click', this.#handleClick);\n }\n\n /**\n * Creates the render root for the element.\n * Returns the element itself to render content in light DOM.\n *\n * @returns The element itself (not a shadow root)\n */\n protected override createRenderRoot() {\n return this;\n }\n}\n"]}
1
+ {"version":3,"file":"tha-router-link.js","sources":["../../../../libs/elements/src/router/tha-router-link.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;AA8BA;;;;;;;;;;;;;;;;;;;;;;;AAuBG;AAEI,IAAM,aAAa,GAAnB,MAAM,aA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