@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.
- package/.build-manifest.json +61 -0
- package/README.md +34 -8
- package/drag-drop/drag-element.cjs +59 -60
- package/drag-drop/drag-element.cjs.map +1 -0
- package/drag-drop/drag-element.js +8 -8
- package/drag-drop/drag-element.js.map +1 -1
- package/drag-drop/drag-handle-element.cjs +19 -19
- package/drag-drop/drag-handle-element.cjs.map +1 -0
- package/drag-drop/drag-handle-element.js +8 -7
- package/drag-drop/drag-handle-element.js.map +1 -1
- package/drag-drop/dropzone-element.cjs +32 -32
- package/drag-drop/dropzone-element.cjs.map +1 -0
- package/drag-drop/dropzone-element.js +6 -5
- package/drag-drop/dropzone-element.js.map +1 -1
- package/drag-drop/index.cjs +23 -11
- package/drag-drop/index.cjs.map +1 -0
- package/drag-drop/{drag-element.d.ts → index.d.cts} +73 -5
- package/drag-drop/index.d.ts +172 -6
- package/drag-drop/index.js +4 -5
- package/drag-drop/index.js.map +1 -1
- package/drag-drop/private-props.cjs +10 -6
- package/drag-drop/private-props.cjs.map +1 -0
- package/drag-drop/private-props.js +4 -3
- package/drag-drop/private-props.js.map +1 -1
- package/drag-drop/tha-drag-event.cjs +8 -6
- package/drag-drop/tha-drag-event.cjs.map +1 -0
- package/drag-drop/tha-drag-event.js +4 -2
- package/drag-drop/tha-drag-event.js.map +1 -1
- package/fesm/elements.mjs +1939 -0
- package/fesm/elements.mjs.map +1 -0
- package/icon/icon-element.cjs +136 -37
- package/icon/icon-element.cjs.map +1 -0
- package/icon/icon-element.js +105 -5
- package/icon/icon-element.js.map +1 -1
- package/icon/index.cjs +16 -5
- package/icon/index.cjs.map +1 -0
- package/icon/index.d.cts +89 -0
- package/icon/index.d.ts +89 -1
- package/icon/index.js +2 -2
- package/icon/index.js.map +1 -1
- package/icon/simple-icons-sprite.cjs +129 -0
- package/icon/simple-icons-sprite.cjs.map +1 -0
- package/icon/simple-icons-sprite.js +124 -0
- package/icon/simple-icons-sprite.js.map +1 -0
- package/iife/drag-drop/index.js +73 -0
- package/iife/drag-drop/index.js.map +1 -0
- package/iife/elements.js +180 -0
- package/iife/elements.js.map +1 -0
- package/iife/icon/index.js +35 -0
- package/iife/icon/index.js.map +1 -0
- package/iife/router/index.js +142 -0
- package/iife/router/index.js.map +1 -0
- package/index.cjs +53 -11
- package/index.cjs.map +1 -0
- package/index.d.cts +6 -0
- package/index.d.ts +6 -6
- package/index.js +10 -9
- package/index.js.map +1 -1
- package/package.json +45 -83
- package/router/history-managed.cjs +22 -18
- package/router/history-managed.cjs.map +1 -0
- package/router/history-managed.js +9 -7
- package/router/history-managed.js.map +1 -1
- package/router/history.cjs +20 -16
- package/router/history.cjs.map +1 -0
- package/router/history.js +8 -6
- package/router/history.js.map +1 -1
- package/router/index.cjs +36 -15
- package/router/index.cjs.map +1 -0
- package/router/index.d.cts +895 -0
- package/router/index.d.ts +895 -6
- package/router/index.js +6 -7
- package/router/index.js.map +1 -1
- package/router/signal-watcher-lit-element.cjs +9 -6
- package/router/signal-watcher-lit-element.cjs.map +1 -0
- package/router/signal-watcher-lit-element.js +5 -3
- package/router/signal-watcher-lit-element.js.map +1 -1
- package/router/tha-route.cjs +25 -22
- package/router/tha-route.cjs.map +1 -0
- package/router/tha-route.js +8 -7
- package/router/tha-route.js.map +1 -1
- package/router/tha-router-config.cjs +17 -17
- package/router/tha-router-config.cjs.map +1 -0
- package/router/tha-router-config.js +8 -7
- package/router/tha-router-config.js.map +1 -1
- package/router/tha-router-link.cjs +36 -36
- package/router/tha-router-link.cjs.map +1 -0
- package/router/tha-router-link.js +9 -8
- package/router/tha-router-link.js.map +1 -1
- package/router/tha-router-outlet.cjs +51 -48
- package/router/tha-router-outlet.cjs.map +1 -0
- package/router/tha-router-outlet.js +12 -11
- package/router/tha-router-outlet.js.map +1 -1
- package/router/tha-router-param.cjs +21 -21
- package/router/tha-router-param.cjs.map +1 -0
- package/router/tha-router-param.js +7 -6
- package/router/tha-router-param.js.map +1 -1
- package/router/tha-router.cjs +33 -33
- package/router/tha-router.cjs.map +1 -0
- package/router/tha-router.js +11 -10
- package/router/tha-router.js.map +1 -1
- package/bundle.js +0 -164
- package/bundle.mjs +0 -2630
- package/drag-drop/drag-handle-element.d.ts +0 -12
- package/drag-drop/dropzone-element.d.ts +0 -17
- package/drag-drop/private-props.d.ts +0 -3
- package/drag-drop/tha-drag-event.d.ts +0 -19
- package/icon/icon-element.d.ts +0 -40
- package/router/history-managed.d.ts +0 -76
- package/router/history.d.ts +0 -48
- package/router/signal-watcher-lit-element.d.ts +0 -25
- package/router/tha-route.d.ts +0 -90
- package/router/tha-router-config.d.ts +0 -223
- package/router/tha-router-link.d.ts +0 -95
- package/router/tha-router-outlet.d.ts +0 -112
- package/router/tha-router-param.d.ts +0 -226
- package/router/tha-router.d.ts +0 -69
- package/tha-url-output.cjs +0 -79
- package/tha-url-output.d.ts +0 -41
- package/tha-url-output.js +0 -78
- package/tha-url-output.js.map +0 -1
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { LitElement, type TemplateResult } from "lit";
|
|
2
|
-
declare global {
|
|
3
|
-
interface HTMLElementTagNameMap {
|
|
4
|
-
"tha-drag-handle": DragHandleElement;
|
|
5
|
-
}
|
|
6
|
-
}
|
|
7
|
-
export declare class DragHandleElement extends LitElement {
|
|
8
|
-
#private;
|
|
9
|
-
connectedCallback(): void;
|
|
10
|
-
disconnectedCallback(): void;
|
|
11
|
-
protected render(): TemplateResult;
|
|
12
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { CSSResultGroup, LitElement, type TemplateResult } from "lit";
|
|
2
|
-
declare global {
|
|
3
|
-
interface HTMLElementTagNameMap {
|
|
4
|
-
"tha-dropzone": DropZoneElement;
|
|
5
|
-
}
|
|
6
|
-
}
|
|
7
|
-
export declare class DropZoneElement extends LitElement {
|
|
8
|
-
#private;
|
|
9
|
-
static styles?: CSSResultGroup;
|
|
10
|
-
accept: string[];
|
|
11
|
-
name: string;
|
|
12
|
-
itemDragged: string | null;
|
|
13
|
-
acceptableDrag: boolean;
|
|
14
|
-
protected render(): TemplateResult;
|
|
15
|
-
connectedCallback(): void;
|
|
16
|
-
disconnectedCallback(): void;
|
|
17
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { DragElement } from "./drag-element";
|
|
2
|
-
import type { DropZoneElement } from "./dropzone-element";
|
|
3
|
-
export type DragElementEventTypes = 'thadrag' | 'thadragstart' | 'thadragend' | 'thadropzoneenter' | 'thadropzoneleave' | 'thadropzoneover' | 'thadropped';
|
|
4
|
-
export type DropElementEventTypes = 'thadrop' | 'thadropend' | 'thadragenter' | 'thadragleave' | 'thadragover';
|
|
5
|
-
export type ThaDragEventTypes = DragElementEventTypes | DropElementEventTypes;
|
|
6
|
-
interface ThaDragEventDict {
|
|
7
|
-
dragTarget: WeakRef<DragElement>;
|
|
8
|
-
dropzoneTarget?: WeakRef<DropZoneElement>;
|
|
9
|
-
}
|
|
10
|
-
export declare class ThaDragEvent extends DragEvent {
|
|
11
|
-
#private;
|
|
12
|
-
readonly dragTarget: WeakRef<DragElement>;
|
|
13
|
-
readonly dropzoneTarget?: WeakRef<DropZoneElement>;
|
|
14
|
-
get name(): string | undefined;
|
|
15
|
-
get dragData(): Record<string, string> | undefined;
|
|
16
|
-
constructor(type: ThaDragEventTypes, { dragTarget, dropzoneTarget }: ThaDragEventDict, eventInitDict?: DragEventInit);
|
|
17
|
-
acceptDrop(rect?: DOMRect): void;
|
|
18
|
-
}
|
|
19
|
-
export {};
|
package/icon/icon-element.d.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { LitElement } from "lit";
|
|
2
|
-
import type { TemplateResult } from "lit";
|
|
3
|
-
declare global {
|
|
4
|
-
interface HTMLElementTagNameMap {
|
|
5
|
-
/**
|
|
6
|
-
* A framework-agnostic icon element backed by Material Symbols.
|
|
7
|
-
*
|
|
8
|
-
* Renders into the **light DOM** so the host's utility classes are styled by the consumer's
|
|
9
|
-
* Tailwind v4 build. Required attribute-driven CSS (font-family, font-variation-settings,
|
|
10
|
-
* `attr(... type(<number>))` rules) is injected once into `document.head` by the element class.
|
|
11
|
-
*
|
|
12
|
-
* Pick icons from https://fonts.google.com/icons
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* ```html
|
|
16
|
-
* <tp-icon>home</tp-icon>
|
|
17
|
-
* <tp-icon family="material" variant="round" filled grade="200" weight="700" optical-size="48">favorite</tp-icon>
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
|
-
"tp-icon": IconElement;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
export declare class IconElement extends LitElement {
|
|
24
|
-
private static GLOBAL_STYLE;
|
|
25
|
-
/** Icon family. Currently only Material Symbols is supported. */
|
|
26
|
-
family: "material";
|
|
27
|
-
/** Material Symbols variant. */
|
|
28
|
-
variant: "outlined" | "round" | "sharp";
|
|
29
|
-
/** Whether the glyph should be filled (FILL axis = 1). */
|
|
30
|
-
filled: boolean;
|
|
31
|
-
/** Material Symbols GRAD axis (-25..200). */
|
|
32
|
-
grade: number;
|
|
33
|
-
/** Material Symbols wght axis (100..700). */
|
|
34
|
-
weight: number;
|
|
35
|
-
/** Material Symbols opsz axis (20..48). Reflects as `optical-size` attribute. */
|
|
36
|
-
opticalSize: number;
|
|
37
|
-
protected createRenderRoot(): HTMLElement;
|
|
38
|
-
connectedCallback(): void;
|
|
39
|
-
protected render(): TemplateResult;
|
|
40
|
-
}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview History management mixin for Lit elements
|
|
3
|
-
*
|
|
4
|
-
* Hierarchical resolution: own history → parent history → global history
|
|
5
|
-
*
|
|
6
|
-
* @module router/history-managed
|
|
7
|
-
*/
|
|
8
|
-
import { HistoryType } from "./history";
|
|
9
|
-
import { Signal } from "@lit-labs/signals";
|
|
10
|
-
import { History } from "history";
|
|
11
|
-
import { LitElement } from "lit";
|
|
12
|
-
/**
|
|
13
|
-
* Constructor type for mixin pattern.
|
|
14
|
-
* @template T - The instance type
|
|
15
|
-
*/
|
|
16
|
-
type Constructor<T = {}> = new (...args: any[]) => T;
|
|
17
|
-
/**
|
|
18
|
-
* Symbol for accessing the resolved history instance.
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* ```typescript
|
|
22
|
-
* const history = this[HISTORY].get();
|
|
23
|
-
* history.push('/path');
|
|
24
|
-
* ```
|
|
25
|
-
*/
|
|
26
|
-
export declare const HISTORY: unique symbol;
|
|
27
|
-
/**
|
|
28
|
-
* Symbol for accessing the resolved history type.
|
|
29
|
-
* @internal
|
|
30
|
-
*/
|
|
31
|
-
export declare const HISTORY_TYPE: unique symbol;
|
|
32
|
-
/**
|
|
33
|
-
* Interface for elements with history management.
|
|
34
|
-
*
|
|
35
|
-
* Resolution order: own history → parent history → global history
|
|
36
|
-
*/
|
|
37
|
-
export interface HistoryManagedLitElementType extends Element {
|
|
38
|
-
/**
|
|
39
|
-
* History strategy: "browser" | "hash" | "memory" | "memory:name"
|
|
40
|
-
* If undefined, inherits from parent or uses global default.
|
|
41
|
-
*/
|
|
42
|
-
history: HistoryType | undefined;
|
|
43
|
-
/**
|
|
44
|
-
* Computed signal with resolved history type.
|
|
45
|
-
* @internal
|
|
46
|
-
*/
|
|
47
|
-
[HISTORY_TYPE]: Signal.Computed<HistoryType | undefined>;
|
|
48
|
-
/**
|
|
49
|
-
* Computed signal with resolved history instance.
|
|
50
|
-
* Access via: `this[HISTORY].get()`
|
|
51
|
-
* @internal
|
|
52
|
-
*/
|
|
53
|
-
[HISTORY]: Signal.Computed<History>;
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Mixin that adds hierarchical history management to Lit elements.
|
|
57
|
-
*
|
|
58
|
-
* Provides reactive history resolution: own → parent → global
|
|
59
|
-
*
|
|
60
|
-
* @example
|
|
61
|
-
* ```typescript
|
|
62
|
-
* class MyRouter extends HistoryManaged(LitElement) {
|
|
63
|
-
* connectedCallback() {
|
|
64
|
-
* super.connectedCallback();
|
|
65
|
-
* const history = this[HISTORY].get();
|
|
66
|
-
* history.listen(({ location }) => this.updateRoutes());
|
|
67
|
-
* }
|
|
68
|
-
* }
|
|
69
|
-
* ```
|
|
70
|
-
*
|
|
71
|
-
* @template T - Base class (must extend LitElement)
|
|
72
|
-
* @param superClass - The class to extend
|
|
73
|
-
* @returns Extended class with history management
|
|
74
|
-
*/
|
|
75
|
-
export declare const HistoryManaged: <T extends Constructor<LitElement>>(superClass: T) => Constructor<HistoryManagedLitElementType> & T;
|
|
76
|
-
export {};
|
package/router/history.d.ts
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
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;
|
|
@@ -1,25 +0,0 @@
|
|
|
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
|
-
});
|
package/router/tha-route.d.ts
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,223 +0,0 @@
|
|
|
1
|
-
import { LitElement } from "lit";
|
|
2
|
-
declare global {
|
|
3
|
-
interface HTMLElementTagNameMap {
|
|
4
|
-
/**
|
|
5
|
-
* A configuration element for managing router history settings.
|
|
6
|
-
*
|
|
7
|
-
* Behavior depends on placement:
|
|
8
|
-
* - **In `<head>`**: Sets global history for all routers
|
|
9
|
-
* - **In `<body>`**: Provides local history for descendant routers
|
|
10
|
-
*/
|
|
11
|
-
"tha-router-config": ThaRouterConfig;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
declare const ThaRouterConfig_base: (new (...args: any[]) => import("./history-managed").HistoryManagedLitElementType) & (new () => LitElement & {
|
|
15
|
-
updateEffect(fn: () => void, options?: import("./signal-watcher-lit-element").EffectOptions): () => void;
|
|
16
|
-
});
|
|
17
|
-
/**
|
|
18
|
-
* A custom element for configuring router history settings.
|
|
19
|
-
*
|
|
20
|
-
* This element serves dual purposes depending on its placement in the DOM:
|
|
21
|
-
*
|
|
22
|
-
* ## Global Configuration (placed in `<head>`)
|
|
23
|
-
*
|
|
24
|
-
* When placed in the `<head>` element, it sets the **global default history**
|
|
25
|
-
* for all routers in the application that don't specify their own history or
|
|
26
|
-
* inherit from a parent.
|
|
27
|
-
*
|
|
28
|
-
* ```html
|
|
29
|
-
* <head>
|
|
30
|
-
* <!-- All routers will use hash routing by default -->
|
|
31
|
-
* <tha-router-config history="hash"></tha-router-config>
|
|
32
|
-
* </head>
|
|
33
|
-
* <body>
|
|
34
|
-
* <tha-router>
|
|
35
|
-
* <!-- Uses hash history (global default) -->
|
|
36
|
-
* <tha-route path="/home">...</tha-route>
|
|
37
|
-
* </tha-router>
|
|
38
|
-
* </body>
|
|
39
|
-
* ```
|
|
40
|
-
*
|
|
41
|
-
* ## Local Configuration (placed in `<body>`)
|
|
42
|
-
*
|
|
43
|
-
* When placed in the `<body>` element, it provides history configuration
|
|
44
|
-
* for its **descendant routers only**. This allows different sections of
|
|
45
|
-
* your application to use different history strategies.
|
|
46
|
-
*
|
|
47
|
-
* ```html
|
|
48
|
-
* <body>
|
|
49
|
-
* <!-- Section 1: Hash routing -->
|
|
50
|
-
* <tha-router-config history="hash">
|
|
51
|
-
* <tha-router>
|
|
52
|
-
* <!-- Uses hash history from parent config -->
|
|
53
|
-
* <tha-route path="/dashboard">...</tha-route>
|
|
54
|
-
* </tha-router>
|
|
55
|
-
* </tha-router-config>
|
|
56
|
-
*
|
|
57
|
-
* <!-- Section 2: Memory routing (isolated) -->
|
|
58
|
-
* <tha-router-config history="memory">
|
|
59
|
-
* <tha-router>
|
|
60
|
-
* <!-- Uses memory history from parent config -->
|
|
61
|
-
* <tha-route path="/preview">...</tha-route>
|
|
62
|
-
* </tha-router>
|
|
63
|
-
* </tha-router-config>
|
|
64
|
-
* </body>
|
|
65
|
-
* ```
|
|
66
|
-
*
|
|
67
|
-
* ## Usage Patterns
|
|
68
|
-
*
|
|
69
|
-
* ### Set Global Default
|
|
70
|
-
*
|
|
71
|
-
* Place in `<head>` to configure all routers:
|
|
72
|
-
*
|
|
73
|
-
* ```html
|
|
74
|
-
* <!DOCTYPE html>
|
|
75
|
-
* <html>
|
|
76
|
-
* <head>
|
|
77
|
-
* <tha-router-config history="browser"></tha-router-config>
|
|
78
|
-
* </head>
|
|
79
|
-
* <body>
|
|
80
|
-
* <!-- All routers use browser history -->
|
|
81
|
-
* </body>
|
|
82
|
-
* </html>
|
|
83
|
-
* ```
|
|
84
|
-
*
|
|
85
|
-
* ### Override for Specific Section
|
|
86
|
-
*
|
|
87
|
-
* Use local config to override global default:
|
|
88
|
-
*
|
|
89
|
-
* ```html
|
|
90
|
-
* <head>
|
|
91
|
-
* <!-- Global: browser history -->
|
|
92
|
-
* <tha-router-config history="browser"></tha-router-config>
|
|
93
|
-
* </head>
|
|
94
|
-
* <body>
|
|
95
|
-
* <!-- Main app uses browser history -->
|
|
96
|
-
* <tha-router>...</tha-router>
|
|
97
|
-
*
|
|
98
|
-
* <!-- Admin section uses hash history -->
|
|
99
|
-
* <tha-router-config history="hash">
|
|
100
|
-
* <tha-router>...</tha-router>
|
|
101
|
-
* </tha-router-config>
|
|
102
|
-
* </body>
|
|
103
|
-
* ```
|
|
104
|
-
*
|
|
105
|
-
* ### Isolate Components with Memory History
|
|
106
|
-
*
|
|
107
|
-
* Use named memory history for component isolation:
|
|
108
|
-
*
|
|
109
|
-
* ```html
|
|
110
|
-
* <body>
|
|
111
|
-
* <!-- Each component has independent navigation -->
|
|
112
|
-
* <tha-router-config history="memory:component1">
|
|
113
|
-
* <my-widget>
|
|
114
|
-
* <tha-router>...</tha-router>
|
|
115
|
-
* </my-widget>
|
|
116
|
-
* </tha-router-config>
|
|
117
|
-
*
|
|
118
|
-
* <tha-router-config history="memory:component2">
|
|
119
|
-
* <my-widget>
|
|
120
|
-
* <tha-router>...</tha-router>
|
|
121
|
-
* </my-widget>
|
|
122
|
-
* </tha-router-config>
|
|
123
|
-
* </body>
|
|
124
|
-
* ```
|
|
125
|
-
*
|
|
126
|
-
* ### Testing with Memory History
|
|
127
|
-
*
|
|
128
|
-
* Use memory history to avoid affecting browser URL during tests:
|
|
129
|
-
*
|
|
130
|
-
* ```typescript
|
|
131
|
-
* import { fixture, html } from '@open-wc/testing';
|
|
132
|
-
*
|
|
133
|
-
* it('should navigate', async () => {
|
|
134
|
-
* const el = await fixture(html`
|
|
135
|
-
* <tha-router-config history="memory:test">
|
|
136
|
-
* <tha-router>
|
|
137
|
-
* <tha-route path="/test">Test Page</tha-route>
|
|
138
|
-
* </tha-router>
|
|
139
|
-
* </tha-router-config>
|
|
140
|
-
* `);
|
|
141
|
-
*
|
|
142
|
-
* // Test navigation without affecting browser URL
|
|
143
|
-
* });
|
|
144
|
-
* ```
|
|
145
|
-
*
|
|
146
|
-
* ## History Resolution
|
|
147
|
-
*
|
|
148
|
-
* Router components resolve their history in this order:
|
|
149
|
-
*
|
|
150
|
-
* 1. **Own `history` attribute** (highest priority)
|
|
151
|
-
* 2. **Parent `tha-router-config`** (local configuration)
|
|
152
|
-
* 3. **Global `tha-router-config`** (in `<head>`)
|
|
153
|
-
* 4. **Default** (`"browser"`)
|
|
154
|
-
*
|
|
155
|
-
* ## Best Practices
|
|
156
|
-
*
|
|
157
|
-
* ✅ **DO**: Place one `tha-router-config` in `<head>` for global settings
|
|
158
|
-
*
|
|
159
|
-
* ```html
|
|
160
|
-
* <head>
|
|
161
|
-
* <tha-router-config history="browser"></tha-router-config>
|
|
162
|
-
* </head>
|
|
163
|
-
* ```
|
|
164
|
-
*
|
|
165
|
-
* ✅ **DO**: Use local configs for sections with different routing needs
|
|
166
|
-
*
|
|
167
|
-
* ```html
|
|
168
|
-
* <tha-router-config history="memory">
|
|
169
|
-
* <component-preview>...</component-preview>
|
|
170
|
-
* </tha-router-config>
|
|
171
|
-
* ```
|
|
172
|
-
*
|
|
173
|
-
* ✅ **DO**: Use named memory history for isolated components
|
|
174
|
-
*
|
|
175
|
-
* ```html
|
|
176
|
-
* <tha-router-config history="memory:sidebar">
|
|
177
|
-
* <sidebar-nav>...</sidebar-nav>
|
|
178
|
-
* </tha-router-config>
|
|
179
|
-
* ```
|
|
180
|
-
*
|
|
181
|
-
* ❌ **DON'T**: Place multiple configs in `<head>` (last one wins)
|
|
182
|
-
*
|
|
183
|
-
* ```html
|
|
184
|
-
* <head>
|
|
185
|
-
* <tha-router-config history="browser"></tha-router-config>
|
|
186
|
-
* <tha-router-config history="hash"></tha-router-config> <!-- Overrides above -->
|
|
187
|
-
* </head>
|
|
188
|
-
* ```
|
|
189
|
-
*
|
|
190
|
-
* ❌ **DON'T**: Nest configs unnecessarily (inner configs take precedence)
|
|
191
|
-
*
|
|
192
|
-
* ```html
|
|
193
|
-
* <tha-router-config history="browser">
|
|
194
|
-
* <tha-router-config history="hash">
|
|
195
|
-
* <!-- Uses hash, not browser -->
|
|
196
|
-
* </tha-router-config>
|
|
197
|
-
* </tha-router-config>
|
|
198
|
-
* ```
|
|
199
|
-
*/
|
|
200
|
-
export declare class ThaRouterConfig extends ThaRouterConfig_base {
|
|
201
|
-
#private;
|
|
202
|
-
/**
|
|
203
|
-
* Called when the element is connected to the DOM.
|
|
204
|
-
*
|
|
205
|
-
* - If in `<head>`: Sets up a reactive effect to update global history
|
|
206
|
-
* - If in `<body>`: Only provides history to descendants (no special setup)
|
|
207
|
-
*/
|
|
208
|
-
connectedCallback(): void;
|
|
209
|
-
/**
|
|
210
|
-
* Called when the element is disconnected from the DOM.
|
|
211
|
-
*
|
|
212
|
-
* Cleans up the global history effect if it was set up.
|
|
213
|
-
*/
|
|
214
|
-
disconnectedCallback(): void;
|
|
215
|
-
/**
|
|
216
|
-
* Creates the render root for the element.
|
|
217
|
-
* Returns the element itself to render children in light DOM.
|
|
218
|
-
*
|
|
219
|
-
* @returns The element itself (not a shadow root)
|
|
220
|
-
*/
|
|
221
|
-
protected createRenderRoot(): this;
|
|
222
|
-
}
|
|
223
|
-
export {};
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import { LitElement } from "lit";
|
|
2
|
-
declare global {
|
|
3
|
-
interface HTMLElementTagNameMap {
|
|
4
|
-
/**
|
|
5
|
-
* A navigation link element for client-side routing.
|
|
6
|
-
* It handles click events to navigate using the History API without full page reloads.
|
|
7
|
-
* The `to` attribute specifies the navigation target (absolute, relative, or 'back'/'forward').
|
|
8
|
-
* The `active` attribute reflects whether the link matches the current route.
|
|
9
|
-
* The `history` attribute specifies which history instance to use.
|
|
10
|
-
*/
|
|
11
|
-
"tha-router-link": ThaRouterLink;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
/** Navigation symbols for browser history operations */
|
|
15
|
-
type LinkSymbol = 'back' | 'forward';
|
|
16
|
-
/** Absolute path starting with / */
|
|
17
|
-
type AbsolutePath = '/' | `/${string}`;
|
|
18
|
-
/** Relative path starting with ./ or ../ */
|
|
19
|
-
type RelativePath = './' | `./${string}` | `../${string}`;
|
|
20
|
-
/** Union of all supported link types */
|
|
21
|
-
type LinkType = LinkSymbol | AbsolutePath | RelativePath;
|
|
22
|
-
declare const ThaRouterLink_base: (new (...args: any[]) => import("./history-managed").HistoryManagedLitElementType) & (new () => LitElement & {
|
|
23
|
-
updateEffect(fn: () => void, options?: import("./signal-watcher-lit-element").EffectOptions): () => void;
|
|
24
|
-
});
|
|
25
|
-
/**
|
|
26
|
-
* A custom element that provides navigation links for client-side routing.
|
|
27
|
-
*
|
|
28
|
-
* The link handles click events to navigate using the History API, preventing
|
|
29
|
-
* full page reloads. It supports absolute paths, relative paths, and special
|
|
30
|
-
* symbols ('back', 'forward') for browser history navigation.
|
|
31
|
-
*
|
|
32
|
-
* The `active` attribute automatically reflects whether the link's path
|
|
33
|
-
* matches the current route, useful for styling active navigation items.
|
|
34
|
-
*
|
|
35
|
-
* @example
|
|
36
|
-
* ```html
|
|
37
|
-
* <!-- Absolute path -->
|
|
38
|
-
* <tha-router-link to="/about">About</tha-router-link>
|
|
39
|
-
*
|
|
40
|
-
* <!-- Relative path -->
|
|
41
|
-
* <tha-router-link to="./details">Details</tha-router-link>
|
|
42
|
-
* <tha-router-link to="../users">Back to Users</tha-router-link>
|
|
43
|
-
*
|
|
44
|
-
* <!-- History navigation -->
|
|
45
|
-
* <tha-router-link to="back">← Back</tha-router-link>
|
|
46
|
-
* <tha-router-link to="forward">Forward →</tha-router-link>
|
|
47
|
-
* ```
|
|
48
|
-
*/
|
|
49
|
-
export declare class ThaRouterLink extends ThaRouterLink_base {
|
|
50
|
-
#private;
|
|
51
|
-
/**
|
|
52
|
-
* The navigation target. Can be:
|
|
53
|
-
* - Absolute path: `/users`, `/about`
|
|
54
|
-
* - Relative path: `./details`, `../users`
|
|
55
|
-
* - History symbol: `back`, `forward`
|
|
56
|
-
*
|
|
57
|
-
* @attr to
|
|
58
|
-
*/
|
|
59
|
-
to: LinkType | null;
|
|
60
|
-
/**
|
|
61
|
-
* Reflects whether this link matches the current route.
|
|
62
|
-
* Automatically updated when the route changes.
|
|
63
|
-
*
|
|
64
|
-
* @attr active
|
|
65
|
-
* @readonly
|
|
66
|
-
*/
|
|
67
|
-
active: boolean;
|
|
68
|
-
/**
|
|
69
|
-
* Lifecycle callback when the element is connected to the DOM.
|
|
70
|
-
* Sets up click listener and active state tracking effect.
|
|
71
|
-
*/
|
|
72
|
-
connectedCallback(): void;
|
|
73
|
-
/**
|
|
74
|
-
* Lifecycle callback when an attribute changes.
|
|
75
|
-
* Updates signals when history or to attributes change.
|
|
76
|
-
*
|
|
77
|
-
* @param name - The attribute name that changed
|
|
78
|
-
* @param _old - The old attribute value
|
|
79
|
-
* @param value - The new attribute value
|
|
80
|
-
*/
|
|
81
|
-
attributeChangedCallback(name: string, _old: string | null, value: string | null): void;
|
|
82
|
-
/**
|
|
83
|
-
* Lifecycle callback when the element is disconnected from the DOM.
|
|
84
|
-
* Cleans up effects, listeners, and event handlers.
|
|
85
|
-
*/
|
|
86
|
-
disconnectedCallback(): void;
|
|
87
|
-
/**
|
|
88
|
-
* Creates the render root for the element.
|
|
89
|
-
* Returns the element itself to render content in light DOM.
|
|
90
|
-
*
|
|
91
|
-
* @returns The element itself (not a shadow root)
|
|
92
|
-
*/
|
|
93
|
-
protected createRenderRoot(): this;
|
|
94
|
-
}
|
|
95
|
-
export {};
|