lit-ui-router 0.0.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/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # lit-ui-router
2
+
3
+ A UI Router implementation for Lit.
package/dist/core.d.ts ADDED
@@ -0,0 +1,27 @@
1
+ import { PathNode, StateObject, UIRouter, ViewConfig, _ViewDeclaration } from '@uirouter/core';
2
+ import { RoutedLitElement, LitViewDeclaration, LitViewDeclarationTemplate, NormalizedLitViewDeclaration } from './interface.js';
3
+ export declare class LitViewConfig implements ViewConfig {
4
+ path: PathNode[];
5
+ viewDecl: _ViewDeclaration;
6
+ $id: number;
7
+ loaded: boolean;
8
+ constructor(path: PathNode[], viewDecl: _ViewDeclaration);
9
+ load(): Promise<Awaited<this>>;
10
+ }
11
+ export declare function isLitViewDeclarationTemplate(config: LitViewDeclaration): config is LitViewDeclarationTemplate;
12
+ export declare function isRoutedLitElement(component?: unknown): component is RoutedLitElement;
13
+ /**
14
+ * This is a [[StateBuilder.builder]] function for lit `views`.
15
+ *
16
+ * When the [[StateBuilder]] builds a [[State]] object from a raw [[StateDeclaration]], this builder
17
+ * handles the `views` property with logic specific to lit-ui-router.
18
+ *
19
+ * If no `views: {}` property exists on the [[StateDeclaration]], then it creates the `views` object and
20
+ * applies the state-level configuration to a view named `$default`.
21
+ */
22
+ export declare function litViewsBuilder(state: StateObject): Record<string, NormalizedLitViewDeclaration>;
23
+ export declare class UIRouterLit extends UIRouter {
24
+ constructor();
25
+ private started;
26
+ start(): void;
27
+ }
package/dist/core.js ADDED
@@ -0,0 +1,80 @@
1
+ import { forEach, isFunction, pick, servicesPlugin, UIRouter, ViewService, } from '@uirouter/core';
2
+ import { html, LitElement } from 'lit';
3
+ /** @internal */
4
+ let viewConfigIdCounter = 0;
5
+ export class LitViewConfig {
6
+ constructor(path, viewDecl) {
7
+ this.path = path;
8
+ this.viewDecl = viewDecl;
9
+ this.$id = viewConfigIdCounter++;
10
+ this.loaded = true;
11
+ }
12
+ load() {
13
+ return Promise.resolve(this);
14
+ }
15
+ }
16
+ export function isLitViewDeclarationTemplate(config) {
17
+ return isFunction(config);
18
+ }
19
+ export function isRoutedLitElement(component) {
20
+ return component?.prototype instanceof LitElement;
21
+ }
22
+ /**
23
+ * This is a [[StateBuilder.builder]] function for lit `views`.
24
+ *
25
+ * When the [[StateBuilder]] builds a [[State]] object from a raw [[StateDeclaration]], this builder
26
+ * handles the `views` property with logic specific to lit-ui-router.
27
+ *
28
+ * If no `views: {}` property exists on the [[StateDeclaration]], then it creates the `views` object and
29
+ * applies the state-level configuration to a view named `$default`.
30
+ */
31
+ export function litViewsBuilder(state) {
32
+ const views = {}, viewsObject = state.views || {
33
+ $default: pick(state, ['component']),
34
+ };
35
+ forEach(viewsObject, function (config, name) {
36
+ name = name || '$default'; // Account for views: { "": { template... } }
37
+ if (isLitViewDeclarationTemplate(config))
38
+ config = { component: config };
39
+ if (Object.keys(config || {}).length === 0)
40
+ return;
41
+ config.$type = 'lit';
42
+ config.$context = state;
43
+ config.$name = name;
44
+ const normalized = ViewService.normalizeUIViewTarget(config.$context, config.$name);
45
+ config.$uiViewName = normalized.uiViewName;
46
+ config.$uiViewContextAnchor = normalized.uiViewContextAnchor;
47
+ if (isRoutedLitElement(config.component)) {
48
+ const Component = config.component;
49
+ let component;
50
+ config.component = (props) => {
51
+ component = (Component.sticky && component) || new Component(props);
52
+ component._uiViewProps = props;
53
+ return html `${component}`;
54
+ };
55
+ }
56
+ views[name] = viewsObject[name] = config;
57
+ });
58
+ return views;
59
+ }
60
+ const viewConfigFactory = (path, config) => new LitViewConfig(path, config);
61
+ export class UIRouterLit extends UIRouter {
62
+ constructor() {
63
+ super();
64
+ this.started = false;
65
+ this.plugin(servicesPlugin);
66
+ // Apply lit ui-view handling code
67
+ this.viewService._pluginapi._viewConfigFactory('lit', viewConfigFactory);
68
+ this.stateRegistry.decorator('views', litViewsBuilder);
69
+ }
70
+ start() {
71
+ if (this.started) {
72
+ throw new Error('start() called multiple times');
73
+ }
74
+ this.urlMatcherFactory.$get();
75
+ this.urlService.listen();
76
+ this.urlService.sync();
77
+ this.started = true;
78
+ }
79
+ }
80
+ //# sourceMappingURL=core.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core.js","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,UAAU,EAEV,IAAI,EACJ,cAAc,EAGd,QAAQ,EAER,WAAW,GAEZ,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAUvC,gBAAgB;AAChB,IAAI,mBAAmB,GAAG,CAAC,CAAC;AAC5B,MAAM,OAAO,aAAa;IAIxB,YACS,IAAgB,EAChB,QAA0B;QAD1B,SAAI,GAAJ,IAAI,CAAY;QAChB,aAAQ,GAAR,QAAQ,CAAkB;QALnC,QAAG,GAAW,mBAAmB,EAAE,CAAC;QACpC,WAAM,GAAG,IAAI,CAAC;IAKX,CAAC;IAEJ,IAAI;QACF,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;CACF;AAED,MAAM,UAAU,4BAA4B,CAC1C,MAA0B;IAE1B,OAAO,UAAU,CAAC,MAAM,CAAC,CAAC;AAC5B,CAAC;AAED,MAAM,UAAU,kBAAkB,CAChC,SAAmB;IAEnB,OAAQ,SAAoC,EAAE,SAAS,YAAY,UAAU,CAAC;AAChF,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,eAAe,CAAC,KAAkB;IAChD,MAAM,KAAK,GAAiD,EAAE,EAC5D,WAAW,GAAG,KAAK,CAAC,KAAK,IAAI;QAC3B,QAAQ,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,WAAW,CAAC,CAAC;KACrC,CAAC;IAEJ,OAAO,CACL,WAAW,EACX,UAAU,MAAoC,EAAE,IAAY;QAC1D,IAAI,GAAG,IAAI,I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AC,CAAC;AAElC,MAAM,OAAO,WAAY,SAAQ,QAAQ;IACvC;QACE,KAAK,EAAE,CAAC;QAOF,YAAO,GAAG,KAAK,CAAC;QANtB,IAAI,CAAC,MAAM,CAAiB,cAAc,CAAC,CAAC;QAC5C,kCAAkC;QAClC,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,kBAAkB,CAAC,KAAK,EAAE,iBAAiB,CAAC,CAAC;QACzE,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;IACzD,CAAC;IAID,KAAK;QACH,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;QACnD,CAAC;QACD,IAAI,CAAC,iBAAiB,CAAC,IAAI,EAAE,CAAC;QAC9B,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC;QACzB,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC;QACvB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;IACtB,CAAC;CACF"}
@@ -0,0 +1,319 @@
1
+ {
2
+ "schemaVersion": "1.0.0",
3
+ "readme": "",
4
+ "modules": [
5
+ {
6
+ "kind": "javascript-module",
7
+ "path": "src/ui-view.ts",
8
+ "declarations": [
9
+ {
10
+ "kind": "class",
11
+ "description": "",
12
+ "name": "UiView",
13
+ "members": [
14
+ {
15
+ "kind": "field",
16
+ "name": "name",
17
+ "type": {
18
+ "text": "string"
19
+ },
20
+ "default": "''",
21
+ "attribute": "name"
22
+ },
23
+ {
24
+ "kind": "field",
25
+ "name": "uiRouter",
26
+ "type": {
27
+ "text": "UIRouterLit"
28
+ },
29
+ "description": "<code>&lt;ui-view&gt;</code> can be used without <code>&lt;ui-router&gt;</code>\nby providing the <code>uiRouter</code> property directly."
30
+ },
31
+ {
32
+ "kind": "field",
33
+ "name": "viewAddress",
34
+ "type": {
35
+ "text": "UiViewAddress"
36
+ },
37
+ "privacy": "private"
38
+ },
39
+ {
40
+ "kind": "field",
41
+ "name": "component",
42
+ "type": {
43
+ "text": "RoutedLitTemplate | null"
44
+ },
45
+ "privacy": "private",
46
+ "default": "null"
47
+ },
48
+ {
49
+ "kind": "field",
50
+ "name": "inner",
51
+ "privacy": "private"
52
+ },
53
+ {
54
+ "kind": "field",
55
+ "name": "viewId",
56
+ "privacy": "private",
57
+ "default": "viewIdCounter++"
58
+ },
59
+ {
60
+ "kind": "field",
61
+ "name": "_uiViewData",
62
+ "type": {
63
+ "text": "ActiveUIView"
64
+ },
65
+ "privacy": "private"
66
+ },
67
+ {
68
+ "kind": "field",
69
+ "name": "resolveContext",
70
+ "type": {
71
+ "text": "ResolveContext"
72
+ },
73
+ "privacy": "private"
74
+ },
75
+ {
76
+ "kind": "method",
77
+ "name": "_viewConfigUpdated",
78
+ "privacy": "private",
79
+ "parameters": [
80
+ {
81
+ "name": "config",
82
+ "type": {
83
+ "text": "ViewConfig"
84
+ }
85
+ }
86
+ ]
87
+ },
88
+ {
89
+ "kind": "method",
90
+ "name": "_applyUpdatedConfig",
91
+ "privacy": "private",
92
+ "parameters": [
93
+ {
94
+ "name": "config",
95
+ "type": {
96
+ "text": "LitViewConfig"
97
+ }
98
+ }
99
+ ]
100
+ },
101
+ {
102
+ "kind": "field",
103
+ "name": "parentView",
104
+ "type": {
105
+ "text": "UiView"
106
+ },
107
+ "privacy": "private"
108
+ },
109
+ {
110
+ "kind": "field",
111
+ "name": "onUiViewContextEvent",
112
+ "privacy": "private"
113
+ },
114
+ {
115
+ "kind": "field",
116
+ "name": "uiViewContextEventName",
117
+ "type": {
118
+ "text": "string"
119
+ },
120
+ "privacy": "private",
121
+ "static": true,
122
+ "default": "'ui-view-context'"
123
+ },
124
+ {
125
+ "kind": "method",
126
+ "name": "uiViewContextEvent",
127
+ "privacy": "private",
128
+ "static": true,
129
+ "return": {
130
+ "type": {
131
+ "text": "UiViewContextEvent"
132
+ }
133
+ }
134
+ },
135
+ {
136
+ "kind": "method",
137
+ "name": "seekParentView",
138
+ "privacy": "private"
139
+ },
140
+ {
141
+ "kind": "field",
142
+ "name": "onUiRouterContextEvent",
143
+ "privacy": "private"
144
+ },
145
+ {
146
+ "kind": "method",
147
+ "name": "seekRouter",
148
+ "privacy": "private"
149
+ },
150
+ {
151
+ "kind": "method",
152
+ "name": "captureContent",
153
+ "privacy": "private"
154
+ },
155
+ {
156
+ "kind": "field",
157
+ "name": "disconnectedHandlers",
158
+ "type": {
159
+ "text": "deregisterFn[]"
160
+ },
161
+ "privacy": "private",
162
+ "default": "[]"
163
+ },
164
+ {
165
+ "kind": "method",
166
+ "name": "setupUiView",
167
+ "privacy": "private"
168
+ },
169
+ {
170
+ "kind": "method",
171
+ "name": "_invokeUiCanExitHook",
172
+ "privacy": "private",
173
+ "parameters": [
174
+ {
175
+ "name": "trans",
176
+ "type": {
177
+ "text": "Transition"
178
+ }
179
+ }
180
+ ],
181
+ "description": "For each transition, checks the component loaded in the ui-view for:\n\n- has a uiCanExit() component hook\n- is being exited\n\nIf both are true, adds the uiCanExit component function as a hook to that singular Transition."
182
+ },
183
+ {
184
+ "kind": "method",
185
+ "name": "_invokeUiOnParamsChangedHook",
186
+ "privacy": "private",
187
+ "parameters": [
188
+ {
189
+ "name": "$transition$",
190
+ "type": {
191
+ "text": "Transition"
192
+ }
193
+ }
194
+ ],
195
+ "description": "For each transition, checks if any param values changed and notify component"
196
+ }
197
+ ],
198
+ "events": [
199
+ {
200
+ "type": {
201
+ "text": "CustomEvent"
202
+ },
203
+ "description": "This event is fired to obtain the <code>uiRouter</code> instance, when not directly provided. Once obtained, the <code>&lt;ui-view&gt;</code> listens and provides the <code>uiRouter</code> to descendants.",
204
+ "name": "ui-router-context"
205
+ },
206
+ {
207
+ "type": {
208
+ "text": "CustomEvent"
209
+ },
210
+ "description": "This event is fired to obtain the parent <code>&lt;ui-view&gt;</code>.",
211
+ "name": "ui-view-context"
212
+ }
213
+ ],
214
+ "attributes": [
215
+ {
216
+ "name": "name",
217
+ "type": {
218
+ "text": "string"
219
+ },
220
+ "default": "''",
221
+ "fieldName": "name"
222
+ }
223
+ ],
224
+ "superclass": {
225
+ "name": "LitElement",
226
+ "package": "lit"
227
+ },
228
+ "summary": "This is the <code>&lt;ui-view&gt;</code> component.\n\nThe <code>&lt;ui-view&gt;</code> component is a viewport for routed components.\nRouted components will be rendered inside the <code>&lt;ui-view&gt;</code> viewport.",
229
+ "tagName": "ui-view",
230
+ "customElement": true
231
+ }
232
+ ],
233
+ "exports": [
234
+ {
235
+ "kind": "js",
236
+ "name": "UiView",
237
+ "declaration": {
238
+ "name": "UiView",
239
+ "module": "src/ui-view.ts"
240
+ }
241
+ },
242
+ {
243
+ "kind": "custom-element-definition",
244
+ "name": "ui-view",
245
+ "declaration": {
246
+ "name": "UiView",
247
+ "module": "src/ui-view.ts"
248
+ }
249
+ }
250
+ ]
251
+ },
252
+ {
253
+ "kind": "javascript-module",
254
+ "path": "src/ui-router.ts",
255
+ "declarations": [
256
+ {
257
+ "kind": "class",
258
+ "description": "",
259
+ "name": "UIRouterLitElement",
260
+ "slots": [
261
+ {
262
+ "description": "<code>&lt;ui-router&gt;</code> renders slotted content.",
263
+ "name": ""
264
+ }
265
+ ],
266
+ "members": [
267
+ {
268
+ "kind": "field",
269
+ "name": "uiRouter",
270
+ "type": {
271
+ "text": "UIRouterLit | undefined"
272
+ },
273
+ "description": "Root <code>uiRouter</code> singleton.\nIf not provided, the element creates and assigns a new instance."
274
+ },
275
+ {
276
+ "kind": "field",
277
+ "name": "onUiRouterContextEvent",
278
+ "privacy": "private"
279
+ }
280
+ ],
281
+ "events": [
282
+ {
283
+ "type": {
284
+ "text": "CustomEvent"
285
+ },
286
+ "description": "<code>&lt;ui-router&gt;</code> listens to the <code>ui-router-context</code> event and provides the <code>uiRouter</code> instance.",
287
+ "name": "ui-router-context"
288
+ }
289
+ ],
290
+ "superclass": {
291
+ "name": "LitElement",
292
+ "package": "lit"
293
+ },
294
+ "summary": "This is the root ui-router component.",
295
+ "tagName": "ui-router",
296
+ "customElement": true
297
+ }
298
+ ],
299
+ "exports": [
300
+ {
301
+ "kind": "js",
302
+ "name": "UIRouterLitElement",
303
+ "declaration": {
304
+ "name": "UIRouterLitElement",
305
+ "module": "src/ui-router.ts"
306
+ }
307
+ },
308
+ {
309
+ "kind": "custom-element-definition",
310
+ "name": "ui-router",
311
+ "declaration": {
312
+ "name": "UIRouterLitElement",
313
+ "module": "src/ui-router.ts"
314
+ }
315
+ }
316
+ ]
317
+ }
318
+ ]
319
+ }
@@ -0,0 +1,6 @@
1
+ export * from './interface.js';
2
+ export * from './core.js';
3
+ export * from './ui-router.js';
4
+ export * from './ui-view.js';
5
+ export * from './ui-sref.js';
6
+ export * from './ui-sref-active.js';
package/dist/index.js ADDED
@@ -0,0 +1,7 @@
1
+ export * from './interface.js';
2
+ export * from './core.js';
3
+ export * from './ui-router.js';
4
+ export * from './ui-view.js';
5
+ export * from './ui-sref.js';
6
+ export * from './ui-sref-active.js';
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC"}
@@ -0,0 +1,81 @@
1
+ import { Transition, HookResult, _ViewDeclaration, StateDeclaration, TypedMap, UIRouter } from '@uirouter/core';
2
+ import { TemplateResult, LitElement } from 'lit';
3
+ export interface UiOnParamsChanged {
4
+ /**
5
+ * A UI-Router view has an Lit `Component` (see [[LitViewDeclaration.component]]).
6
+ * The `Component` may define component-level hooks which UI-Router will call at the appropriate times.
7
+ * These callbacks are similar to Transition Hooks ([[IHookRegistry]]), but are only called if the view/component is currently active.
8
+ *
9
+ * The uiOnParamsChanged callback is called when parameter values change.
10
+ *
11
+ * This callback is used to respond dynamic parameter values changing.
12
+ * It is called when a transition changed one or more dynamic parameter values,
13
+ * and the routed component was not destroyed.
14
+ *
15
+ * It receives two parameters:
16
+ *
17
+ * - An object with (only) changed parameter values.
18
+ * The keys are the parameter names and the values are the new parameter values.
19
+ * - The [[Transition]] which changed the parameter values.
20
+ *
21
+ */
22
+ uiOnParamsChanged(newParams: {
23
+ [paramName: string]: any;
24
+ }, trans?: Transition): void;
25
+ }
26
+ export interface UiOnExit {
27
+ /**
28
+ * A UI-Router view has an Lit `Component` (see [[LitViewDeclaration.component]]).
29
+ * The `Component` may define component-level hooks which UI-Router will call at the appropriate times.
30
+ * These callbacks are similar to Transition Hooks ([[IHookRegistry]]), but are only called if the view/component is currently active.
31
+ *
32
+ * The uiCanExit callback is called when the routed component's state is about to be exited.
33
+ *
34
+ * The callback can be used to cancel or alter the new Transition that would otherwise exit the component's state.
35
+ *
36
+ * This callback is used to inform a view that it is about to be exited, due to a new [[Transition]].
37
+ * The callback can ask for user confirmation, and cancel or alter the new Transition. The callback should
38
+ * return a value, or a promise for a value. If a promise is returned, the new Transition waits until the
39
+ * promise settles.
40
+ *
41
+ * Called when:
42
+ * - The component is still active inside a `ui-view`
43
+ * - A new Transition is about to run
44
+ * - The new Transition will exit the view's state
45
+ *
46
+ * Called with:
47
+ * - The `Transition` that is about to exit the component's state
48
+ *
49
+ * @return a hook result which may cancel or alter the pending Transition (see [[HookResult]])
50
+ */
51
+ uiCanExit(newTransition?: Transition): HookResult;
52
+ }
53
+ export type UIViewResolves = TypedMap<any>;
54
+ export interface UIViewInjectedProps {
55
+ transition?: Transition;
56
+ resolves?: UIViewResolves;
57
+ router: UIRouter;
58
+ }
59
+ export type RoutedLitTemplate = ((props?: UIViewInjectedProps) => TemplateResult) | ((props: UIViewInjectedProps) => TemplateResult);
60
+ export interface LitViewDeclarationTemplate extends _ViewDeclaration {
61
+ (props?: UIViewInjectedProps): TemplateResult;
62
+ }
63
+ export interface RoutedLitElement {
64
+ new (props?: UIViewInjectedProps): LitElement & {
65
+ _uiViewProps?: UIViewInjectedProps;
66
+ };
67
+ sticky?: boolean;
68
+ }
69
+ export type RoutedLitComponent = RoutedLitTemplate | RoutedLitElement;
70
+ export interface LitViewDeclarationElement extends RoutedLitElement, _ViewDeclaration {
71
+ }
72
+ export interface LitViewDeclarationObject extends _ViewDeclaration {
73
+ component: RoutedLitComponent;
74
+ }
75
+ export type LitViewDeclaration = LitViewDeclarationObject | LitViewDeclarationElement | LitViewDeclarationTemplate;
76
+ export interface LitStateDeclaration extends StateDeclaration {
77
+ component?: LitViewDeclaration;
78
+ }
79
+ export interface NormalizedLitViewDeclaration extends _ViewDeclaration {
80
+ component: RoutedLitTemplate;
81
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interface.js","sourceRoot":"","sources":["../src/interface.ts"],"names":[],"mappings":""}
@@ -0,0 +1,42 @@
1
+ import { LitElement } from 'lit';
2
+ import { UIRouterLit } from './core.js';
3
+ interface UiRouterContextEventDetail {
4
+ uiRouter?: UIRouterLit;
5
+ }
6
+ export type UiRouterContextEvent = CustomEvent<UiRouterContextEventDetail>;
7
+ /**
8
+ * @summary
9
+ *
10
+ * This is the root ui-router component.
11
+ *
12
+ *
13
+ * @slot - <code>&lt;ui-router&gt;</code> renders slotted content.
14
+ *
15
+ * @event {CustomEvent} ui-router-context
16
+ *
17
+ * <code>&lt;ui-router&gt;</code> listens to the
18
+ * <code>ui-router-context</code> event
19
+ * and provides the <code>uiRouter</code> instance.
20
+ */
21
+ export declare class UIRouterLitElement extends LitElement {
22
+ /**
23
+ * Root <code>uiRouter</code> singleton.
24
+ * If not provided, the element creates and assigns a new instance.
25
+ */
26
+ uiRouter: UIRouterLit | undefined;
27
+ /** @internal */
28
+ static uiRouterContextEventName: string;
29
+ /** @internal */
30
+ static uiRouterContextEvent(uiRouter?: UIRouterLit): UiRouterContextEvent;
31
+ /** @internal */
32
+ static seekRouter(candidate: Element): UIRouterLit | undefined;
33
+ /** @internal */
34
+ static onUiRouterContextEvent(uiRouter?: UIRouterLit): (event: UiRouterContextEvent) => void;
35
+ private onUiRouterContextEvent;
36
+ connectedCallback(): Promise<void>;
37
+ render(): import("lit").TemplateResult<1>;
38
+ }
39
+ export interface UIRouterLitElement {
40
+ constructor: typeof UIRouterLitElement;
41
+ }
42
+ export {};
@@ -0,0 +1,73 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { html, LitElement } from 'lit';
8
+ import { customElement, property } from 'lit/decorators.js';
9
+ import { UIRouterLit } from './core.js';
10
+ /**
11
+ * @summary
12
+ *
13
+ * This is the root ui-router component.
14
+ *
15
+ *
16
+ * @slot - <code>&lt;ui-router&gt;</code> renders slotted content.
17
+ *
18
+ * @event {CustomEvent} ui-router-context
19
+ *
20
+ * <code>&lt;ui-router&gt;</code> listens to the
21
+ * <code>ui-router-context</code> event
22
+ * and provides the <code>uiRouter</code> instance.
23
+ */
24
+ let UIRouterLitElement = class UIRouterLitElement extends LitElement {
25
+ constructor() {
26
+ super(...arguments);
27
+ this.onUiRouterContextEvent = (event) => {
28
+ this.constructor.onUiRouterContextEvent(this.uiRouter)(event);
29
+ };
30
+ }
31
+ /** @internal */
32
+ static { this.uiRouterContextEventName = 'ui-router-context'; }
33
+ /** @internal */
34
+ static uiRouterContextEvent(uiRouter) {
35
+ return new CustomEvent(this.uiRouterContextEventName, {
36
+ bubbles: true,
37
+ composed: true,
38
+ detail: {
39
+ uiRouter,
40
+ },
41
+ });
42
+ }
43
+ /** @internal */
44
+ static seekRouter(candidate) {
45
+ const uiRouterContextEvent = this.uiRouterContextEvent();
46
+ candidate.dispatchEvent(uiRouterContextEvent);
47
+ return uiRouterContextEvent.detail.uiRouter;
48
+ }
49
+ /** @internal */
50
+ static onUiRouterContextEvent(uiRouter) {
51
+ return (event) => {
52
+ event.stopPropagation();
53
+ event.detail.uiRouter = uiRouter;
54
+ };
55
+ }
56
+ async connectedCallback() {
57
+ super.connectedCallback();
58
+ this.uiRouter = this.uiRouter || new UIRouterLit();
59
+ this.addEventListener(this.constructor.uiRouterContextEventName, this.onUiRouterContextEvent);
60
+ this.dispatchEvent(this.constructor.uiRouterContextEvent(this.uiRouter));
61
+ }
62
+ render() {
63
+ return html `<slot></slot>`;
64
+ }
65
+ };
66
+ __decorate([
67
+ property({ attribute: false })
68
+ ], UIRouterLitElement.prototype, "uiRouter", void 0);
69
+ UIRouterLitElement = __decorate([
70
+ customElement('ui-router')
71
+ ], UIRouterLitElement);
72
+ export { UIRouterLitElement };
73
+ //# sourceMappingURL=ui-router.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ui-router.js","sourceRoot":"","sources":["../src/ui-router.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE5D,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAQxC;;;;;;;;;;;;;GAaG;AAEI,IAAM,kBAAkB,GAAxB,MAAM,kBAAmB,SAAQ,UAAU;IAA3C;;QAqCG,2BAAsB,GAAG,CAAC,KAA2B,EAAE,EAAE;YAC/D,IAAI,CAAC,WAAW,CAAC,sBAAsB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,CAAC;QAChE,CAAC,CAAC;IAiBJ,CAAC;IAhDC,gBAAgB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