@a11d/lit 0.0.12 → 0.0.13
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/dist/Component/Component.d.ts +5 -5
- package/package.json +1 -1
- package/dist/Component/nothing.d.ts +0 -2
- package/dist/Component/nothing.js +0 -2
- package/dist/Controller/Controller.d.ts +0 -9
- package/dist/Controller/Controller.js +0 -6
- package/dist/Controller/index.d.ts +0 -1
- package/dist/Controller/index.js +0 -1
- package/dist/decorateLitElement.d.ts +0 -7
- package/dist/decorateLitElement.js +0 -19
- package/dist/event/EventDispatcher.d.ts +0 -6
- package/dist/event/EventDispatcher.js +0 -1
- package/dist/event/HTMLElementEventDispatcher.d.ts +0 -10
- package/dist/event/HTMLElementEventDispatcher.js +0 -23
- package/dist/event/PureEventDispatcher.d.ts +0 -6
- package/dist/event/PureEventDispatcher.js +0 -16
- package/dist/event/event.d.ts +0 -1
- package/dist/event/event.js +0 -20
- package/dist/event/index.d.ts +0 -3
- package/dist/event/index.js +0 -3
- package/dist/eventListener/eventListener.d.ts +0 -13
- package/dist/eventListener/eventListener.js +0 -76
- package/dist/eventListener/index.d.ts +0 -1
- package/dist/eventListener/index.js +0 -1
- package/dist/index.js +0 -32
- package/dist/query/index.d.ts +0 -3
- package/dist/query/index.js +0 -3
- package/dist/query/query.d.ts +0 -2
- package/dist/query/query.js +0 -9
- package/dist/query/queryAll.d.ts +0 -2
- package/dist/query/queryAll.js +0 -9
- package/dist/query/queryAllAsNodeList.d.ts +0 -2
- package/dist/query/queryAllAsNodeList.js +0 -2
- package/dist/types.d.ts +0 -2
- package/dist/types.js +0 -1
- package/dist/updated/index.d.ts +0 -3
- package/dist/updated/index.js +0 -3
- package/dist/updated/property.d.ts +0 -5
- package/dist/updated/property.js +0 -10
- package/dist/updated/state.d.ts +0 -6
- package/dist/updated/state.js +0 -10
- package/dist/updated/updated.d.ts +0 -3
- package/dist/updated/updated.js +0 -21
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { LitElement, PropertyValues } from 'lit';
|
|
2
|
-
export declare const component: (tagName: string) => (classOrDescriptor:
|
|
2
|
+
export declare const component: (tagName: string) => (classOrDescriptor: {
|
|
3
3
|
prototype: HTMLElement;
|
|
4
|
-
}) => any;
|
|
4
|
+
} | import("@lit/reactive-element/decorators/base").ClassDescriptor) => any;
|
|
5
5
|
export declare abstract class Component extends LitElement {
|
|
6
6
|
/** Invoked after first update i.e. render is completed */
|
|
7
7
|
protected initialized(): void;
|
|
@@ -10,9 +10,9 @@ export declare abstract class Component extends LitElement {
|
|
|
10
10
|
/** Invoked every time the component is disconnected from the Document Object Model (DOM) */
|
|
11
11
|
protected disconnected(): void;
|
|
12
12
|
/** @deprecated Use template getter instead */
|
|
13
|
-
protected render(): import("lit-html").TemplateResult<
|
|
14
|
-
protected get template(): import("lit-html").TemplateResult<
|
|
15
|
-
firstUpdated(props: PropertyValues): void;
|
|
13
|
+
protected render(): import("lit-html").TemplateResult<1 | 2>;
|
|
14
|
+
protected get template(): import("lit-html").TemplateResult<1 | 2>;
|
|
15
|
+
protected firstUpdated(props: PropertyValues): void;
|
|
16
16
|
connectedCallback(): void;
|
|
17
17
|
disconnectedCallback(): void;
|
|
18
18
|
}
|
package/package.json
CHANGED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { ReactiveController, ReactiveControllerHost } from 'lit';
|
|
2
|
-
export declare abstract class Controller implements ReactiveController {
|
|
3
|
-
protected readonly host: ReactiveControllerHost;
|
|
4
|
-
constructor(host: ReactiveControllerHost);
|
|
5
|
-
hostConnected?(): void;
|
|
6
|
-
hostDisconnected?(): void;
|
|
7
|
-
hostUpdate?(): void;
|
|
8
|
-
hostUpdated?(): void;
|
|
9
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './Controller';
|
package/dist/Controller/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './Controller';
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { LitElement } from 'lit';
|
|
2
|
-
export declare const decorateLitElement: <T>({ constructorPropertyName, prototype, initialValue, lifecycleHooks }: {
|
|
3
|
-
constructorPropertyName: string;
|
|
4
|
-
prototype: LitElement;
|
|
5
|
-
initialValue: T;
|
|
6
|
-
lifecycleHooks: Map<string, (this: LitElement, data: T, ...args: Array<any>) => any>;
|
|
7
|
-
}) => T;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export const decorateLitElement = ({ constructorPropertyName, prototype, initialValue, lifecycleHooks }) => {
|
|
2
|
-
const p = prototype;
|
|
3
|
-
const constructor = prototype.constructor;
|
|
4
|
-
const existingValue = Object.getOwnPropertyDescriptor(constructor, constructorPropertyName)?.value;
|
|
5
|
-
if (existingValue) {
|
|
6
|
-
return existingValue;
|
|
7
|
-
}
|
|
8
|
-
const inheritedValue = constructor[constructorPropertyName];
|
|
9
|
-
const value = inheritedValue ? Object.assign(initialValue, inheritedValue) : initialValue;
|
|
10
|
-
Object.defineProperty(constructor, constructorPropertyName, { value });
|
|
11
|
-
for (const [lifecycleName, lifecycleFunction] of lifecycleHooks) {
|
|
12
|
-
const originalFunction = p[lifecycleName];
|
|
13
|
-
p[lifecycleName] = function (...args) {
|
|
14
|
-
originalFunction.call(this, ...args);
|
|
15
|
-
lifecycleFunction.call(this, value, ...args);
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
return value;
|
|
19
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export declare class HTMLElementEventDispatcher<T = void> implements EventDispatcher<T> {
|
|
2
|
-
private readonly element;
|
|
3
|
-
private readonly type;
|
|
4
|
-
private readonly options?;
|
|
5
|
-
private readonly handlersMap;
|
|
6
|
-
constructor(element: HTMLElement, type: string, options?: EventInit | undefined);
|
|
7
|
-
dispatch(value: T): void;
|
|
8
|
-
subscribe(handler: EventHandler<T>): void;
|
|
9
|
-
unsubscribe(handler: EventHandler<T>): void;
|
|
10
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
export class HTMLElementEventDispatcher {
|
|
2
|
-
constructor(element, type, options) {
|
|
3
|
-
this.element = element;
|
|
4
|
-
this.type = type;
|
|
5
|
-
this.options = options;
|
|
6
|
-
this.handlersMap = new Map();
|
|
7
|
-
}
|
|
8
|
-
dispatch(value) {
|
|
9
|
-
this.element.dispatchEvent(new CustomEvent(this.type, { detail: value, ...this.options }));
|
|
10
|
-
}
|
|
11
|
-
subscribe(handler) {
|
|
12
|
-
const nativeHandler = (event) => handler(event.detail);
|
|
13
|
-
this.element.addEventListener(this.type, nativeHandler);
|
|
14
|
-
this.handlersMap.set(handler, nativeHandler);
|
|
15
|
-
}
|
|
16
|
-
unsubscribe(handler) {
|
|
17
|
-
const nativeHandler = this.handlersMap.get(handler);
|
|
18
|
-
if (nativeHandler) {
|
|
19
|
-
this.element.removeEventListener(this.type, nativeHandler);
|
|
20
|
-
}
|
|
21
|
-
this.handlersMap.delete(handler);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export class PureEventDispatcher {
|
|
2
|
-
constructor() {
|
|
3
|
-
this.handlers = new Set();
|
|
4
|
-
}
|
|
5
|
-
subscribe(handler) {
|
|
6
|
-
this.handlers.add(handler);
|
|
7
|
-
}
|
|
8
|
-
unsubscribe(handler) {
|
|
9
|
-
this.handlers.delete(handler);
|
|
10
|
-
}
|
|
11
|
-
dispatch(data) {
|
|
12
|
-
for (const handler of this.handlers) {
|
|
13
|
-
handler(data);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
}
|
package/dist/event/event.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function event(options?: EventInit): (prototype: unknown, propertyKey?: string) => void;
|
package/dist/event/event.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { HTMLElementEventDispatcher } from './HTMLElementEventDispatcher';
|
|
2
|
-
import { PureEventDispatcher } from './PureEventDispatcher';
|
|
3
|
-
export function event(options) {
|
|
4
|
-
return (prototype, propertyKey) => {
|
|
5
|
-
if (propertyKey === undefined) {
|
|
6
|
-
return;
|
|
7
|
-
}
|
|
8
|
-
const eventFieldName = `$${propertyKey}Event$`;
|
|
9
|
-
Object.defineProperty(prototype, propertyKey, {
|
|
10
|
-
get() {
|
|
11
|
-
if (!this[eventFieldName]) {
|
|
12
|
-
this[eventFieldName] = this instanceof HTMLElement
|
|
13
|
-
? new HTMLElementEventDispatcher(this, propertyKey, options)
|
|
14
|
-
: new PureEventDispatcher();
|
|
15
|
-
}
|
|
16
|
-
return this[eventFieldName];
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
};
|
|
20
|
-
}
|
package/dist/event/index.d.ts
DELETED
package/dist/event/index.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { LitElement } from 'lit';
|
|
2
|
-
declare type ShorthandEventListenerDecoratorOptions = [type: string, options?: EventListenerOptions | boolean];
|
|
3
|
-
declare type FullEventListenerDecoratorOptions = [
|
|
4
|
-
{
|
|
5
|
-
type: string;
|
|
6
|
-
target?: EventTarget | ((this: any) => EventTarget);
|
|
7
|
-
options?: EventListenerOptions | boolean;
|
|
8
|
-
}
|
|
9
|
-
];
|
|
10
|
-
declare type EventListenerDecoratorOptions = ShorthandEventListenerDecoratorOptions | FullEventListenerDecoratorOptions;
|
|
11
|
-
export declare const eventListener: (...eventListenerOptions: EventListenerDecoratorOptions) => (prototype: LitElement, propertyKey: string, descriptor?: PropertyDescriptor) => void;
|
|
12
|
-
export declare const extractEventHandler: <TEvent extends Event = Event>(eventListener: EventListenerOrEventListenerObject) => (event: TEvent) => void;
|
|
13
|
-
export {};
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { decorateLitElement } from '../decorateLitElement';
|
|
2
|
-
function extractArguments(args) {
|
|
3
|
-
const short = ((args) => typeof args[0] === 'string')(args);
|
|
4
|
-
return {
|
|
5
|
-
type: short ? args[0] : args[0].type,
|
|
6
|
-
target: short ? undefined : args[0].target,
|
|
7
|
-
options: short ? args[1] : args[0].options,
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
|
-
function extractEventTarget(target) {
|
|
11
|
-
return typeof target === 'function' ? target.call(this) : target ?? this;
|
|
12
|
-
}
|
|
13
|
-
export const eventListener = (...eventListenerOptions) => {
|
|
14
|
-
return (prototype, propertyKey, descriptor) => {
|
|
15
|
-
decorateLitElement({
|
|
16
|
-
prototype,
|
|
17
|
-
constructorPropertyName: '$eventListeners$',
|
|
18
|
-
initialValue: new Map,
|
|
19
|
-
lifecycleHooks: new Map([
|
|
20
|
-
['connectedCallback', function (eventListeners) {
|
|
21
|
-
for (const [key, { type, target, options, descriptor, property }] of eventListeners) {
|
|
22
|
-
if (this.constructor.name === extractConstructorNameFromUniquePropertyKey(key)) {
|
|
23
|
-
defineBoundListener.call(this, property, descriptor);
|
|
24
|
-
extractEventTarget.call(this, target)
|
|
25
|
-
?.addEventListener(type, getBoundListener.call(this, property), options);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}],
|
|
29
|
-
['disconnectedCallback', function (eventListeners) {
|
|
30
|
-
for (const { type, target, options, property } of eventListeners.values()) {
|
|
31
|
-
extractEventTarget.call(this, target)
|
|
32
|
-
?.removeEventListener(type, getBoundListener.call(this, property), options);
|
|
33
|
-
}
|
|
34
|
-
}],
|
|
35
|
-
])
|
|
36
|
-
}).set(getUniquePropertyKey(prototype.constructor, propertyKey), { descriptor, property: propertyKey, ...extractArguments(eventListenerOptions) });
|
|
37
|
-
};
|
|
38
|
-
};
|
|
39
|
-
const getUniquePropertyKey = (constructor, property) => `${constructor.name}.${property}`;
|
|
40
|
-
const extractConstructorNameFromUniquePropertyKey = (uniquePropertyKey) => uniquePropertyKey.split('.')[0];
|
|
41
|
-
function getBoundListener(propertyKey) {
|
|
42
|
-
return Object.getOwnPropertyDescriptor(this, getBoundMethodKey(propertyKey))?.value;
|
|
43
|
-
}
|
|
44
|
-
function defineBoundListener(propertyKey, descriptor) {
|
|
45
|
-
const unboundFunction = !descriptor
|
|
46
|
-
? Object.getOwnPropertyDescriptor(this, propertyKey)?.value
|
|
47
|
-
: typeof descriptor.get === 'function'
|
|
48
|
-
? descriptor.get
|
|
49
|
-
: descriptor.value;
|
|
50
|
-
if (isEventListenerOrEventListenerObject(unboundFunction) === false) {
|
|
51
|
-
throw new TypeError(`${getUniquePropertyKey(this.constructor, propertyKey)} is not a function`);
|
|
52
|
-
}
|
|
53
|
-
Object.defineProperty(this, getBoundMethodKey(propertyKey), {
|
|
54
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
55
|
-
value: unboundFunction.bind(this),
|
|
56
|
-
configurable: true,
|
|
57
|
-
enumerable: false,
|
|
58
|
-
writable: false,
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
const getBoundMethodKey = (method) => `$BOUND_${method}$`;
|
|
62
|
-
const isEventListenerOrEventListenerObject = (listener) => {
|
|
63
|
-
const isListener = typeof listener === 'function';
|
|
64
|
-
// @ts-expect-error 'in' operator seemingly does not narrow down the type
|
|
65
|
-
const isListenerObject = typeof listener === 'object' && listener !== null && 'handleEvent' in listener && typeof listener.handleEvent === 'function';
|
|
66
|
-
return isListener || isListenerObject;
|
|
67
|
-
};
|
|
68
|
-
export const extractEventHandler = (eventListener) => {
|
|
69
|
-
if ('_$committedValue' in eventListener) {
|
|
70
|
-
const eventPart = eventListener;
|
|
71
|
-
const handler = eventListener['_$committedValue'];
|
|
72
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
73
|
-
return handler.bind(eventPart.element);
|
|
74
|
-
}
|
|
75
|
-
return typeof eventListener === 'function' ? eventListener : eventListener.handleEvent;
|
|
76
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './eventListener';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './eventListener';
|
package/dist/index.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/* eslint-disable import/export */
|
|
2
|
-
export * from 'lit';
|
|
3
|
-
export { eventOptions, queryAssignedElements, queryAssignedNodes, queryAsync } from 'lit/decorators.js';
|
|
4
|
-
export * from 'lit-html';
|
|
5
|
-
export * from 'lit-html/directive.js';
|
|
6
|
-
export * from 'lit-html/directives/async-append.js';
|
|
7
|
-
export * from 'lit-html/directives/async-replace.js';
|
|
8
|
-
export * from 'lit-html/directives/cache.js';
|
|
9
|
-
export * from 'lit-html/directives/choose.js';
|
|
10
|
-
export * from 'lit-html/directives/class-map.js';
|
|
11
|
-
export * from 'lit-html/directives/guard.js';
|
|
12
|
-
export * from 'lit-html/directives/if-defined.js';
|
|
13
|
-
export * from 'lit-html/directives/join.js';
|
|
14
|
-
export * from 'lit-html/directives/keyed.js';
|
|
15
|
-
export * from 'lit-html/directives/live.js';
|
|
16
|
-
export * from 'lit-html/directives/map.js';
|
|
17
|
-
export * from 'lit-html/directives/range.js';
|
|
18
|
-
export * from 'lit-html/directives/ref.js';
|
|
19
|
-
export * from 'lit-html/directives/repeat.js';
|
|
20
|
-
export * from 'lit-html/directives/style-map.js';
|
|
21
|
-
export * from 'lit-html/directives/template-content.js';
|
|
22
|
-
export * from 'lit-html/directives/unsafe-html.js';
|
|
23
|
-
export * from 'lit-html/directives/unsafe-svg.js';
|
|
24
|
-
export * from 'lit-html/directives/until.js';
|
|
25
|
-
export * from 'lit-html/directives/when.js';
|
|
26
|
-
import './types';
|
|
27
|
-
export { Component, nothing, component } from './Component';
|
|
28
|
-
export * from './Controller';
|
|
29
|
-
export * from './query';
|
|
30
|
-
export * from './updated';
|
|
31
|
-
export * from './eventListener';
|
|
32
|
-
export * from './event';
|
package/dist/query/index.d.ts
DELETED
package/dist/query/index.js
DELETED
package/dist/query/query.d.ts
DELETED
package/dist/query/query.js
DELETED
package/dist/query/queryAll.d.ts
DELETED
package/dist/query/queryAll.js
DELETED
package/dist/types.d.ts
DELETED
package/dist/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
package/dist/updated/index.d.ts
DELETED
package/dist/updated/index.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { PropertyDeclaration, LitElement } from 'lit';
|
|
2
|
-
import { updated, UpdatedCallback } from './updated';
|
|
3
|
-
export declare const property: <T>(options?: (PropertyDeclaration<unknown, unknown> & {
|
|
4
|
-
updated?: UpdatedCallback<T> | undefined;
|
|
5
|
-
}) | undefined) => (prototype: LitElement, propertyKey: PropertyKey) => any;
|
package/dist/updated/property.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { property as litProperty } from 'lit/decorators.js';
|
|
2
|
-
import { updated } from './updated';
|
|
3
|
-
export const property = (options) => {
|
|
4
|
-
return (prototype, propertyKey) => {
|
|
5
|
-
if (options?.updated) {
|
|
6
|
-
updated(options.updated)(prototype, propertyKey);
|
|
7
|
-
}
|
|
8
|
-
return litProperty(options)(prototype, propertyKey);
|
|
9
|
-
};
|
|
10
|
-
};
|
package/dist/updated/state.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { LitElement } from 'lit';
|
|
2
|
-
import { InternalPropertyDeclaration } from 'lit/decorators.js';
|
|
3
|
-
import { updated, UpdatedCallback } from './updated';
|
|
4
|
-
export declare const state: <T>(options?: (InternalPropertyDeclaration<unknown> & {
|
|
5
|
-
updated?: UpdatedCallback<T> | undefined;
|
|
6
|
-
}) | undefined) => (prototype: LitElement, propertyKey: PropertyKey) => any;
|
package/dist/updated/state.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { state as litState } from 'lit/decorators.js';
|
|
2
|
-
import { updated } from './updated';
|
|
3
|
-
export const state = (options) => {
|
|
4
|
-
return (prototype, propertyKey) => {
|
|
5
|
-
if (options?.updated) {
|
|
6
|
-
updated(options.updated)(prototype, propertyKey);
|
|
7
|
-
}
|
|
8
|
-
return litState(options)(prototype, propertyKey);
|
|
9
|
-
};
|
|
10
|
-
};
|
package/dist/updated/updated.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { decorateLitElement } from '../decorateLitElement';
|
|
2
|
-
export const updated = (callback) => {
|
|
3
|
-
return (prototype, propertyKey) => {
|
|
4
|
-
decorateLitElement({
|
|
5
|
-
prototype,
|
|
6
|
-
constructorPropertyName: '$observers$',
|
|
7
|
-
initialValue: new Map,
|
|
8
|
-
lifecycleHooks: new Map([
|
|
9
|
-
['updated', function (observers, changedProperties) {
|
|
10
|
-
for (const [propertyKey, value] of changedProperties) {
|
|
11
|
-
const key = propertyKey;
|
|
12
|
-
const observer = observers?.get(key);
|
|
13
|
-
if (observer !== undefined) {
|
|
14
|
-
observer.call(this, this[key], value);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
}]
|
|
18
|
-
])
|
|
19
|
-
}).set(propertyKey, callback);
|
|
20
|
-
};
|
|
21
|
-
};
|