@a11d/lit 0.11.1 → 0.12.0-preview.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/ComponentPart/ComponentPart.d.ts +28 -0
- package/dist/ComponentPart/ComponentPart.d.ts.map +1 -0
- package/dist/ComponentPart/ComponentPart.js +34 -0
- package/dist/ComponentPart/README.md +114 -0
- package/dist/ComponentPart/index.d.ts +2 -0
- package/dist/ComponentPart/index.d.ts.map +1 -0
- package/dist/ComponentPart/index.js +1 -0
- package/dist/Controller/Controller.d.ts +2 -0
- package/dist/Controller/Controller.d.ts.map +1 -1
- package/dist/Controller/Controller.js +4 -0
- package/dist/README.md +1 -0
- package/dist/bind/BindDirective.d.ts +11 -4
- package/dist/bind/BindDirective.d.ts.map +1 -1
- package/dist/bind/BindDirective.js +1 -1
- package/dist/bind/Binder.d.ts +5 -6
- package/dist/bind/Binder.d.ts.map +1 -1
- package/dist/event/README.md +66 -66
- package/dist/event/event.d.ts.map +1 -1
- package/dist/event/event.js +4 -2
- package/dist/eventListener/eventListener.d.ts +1 -1
- package/dist/eventListener/eventListener.d.ts.map +1 -1
- package/dist/eventListener/eventListener.js +2 -2
- package/dist/host.d.ts +18 -0
- package/dist/host.d.ts.map +1 -0
- package/dist/host.js +13 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/query/query.d.ts +2 -1
- package/dist/query/query.d.ts.map +1 -1
- package/dist/query/query.js +2 -1
- package/dist/query/queryAll.d.ts +2 -1
- package/dist/query/queryAll.d.ts.map +1 -1
- package/dist/query/queryAll.js +2 -1
- package/dist/state.d.ts +3 -2
- package/dist/state.d.ts.map +1 -1
- package/dist/state.js +30 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/updated/UpdatedController.d.ts +5 -4
- package/dist/updated/UpdatedController.d.ts.map +1 -1
- package/dist/updated/UpdatedController.js +9 -7
- package/dist/updated/getChangedPropertyKey.d.ts +10 -0
- package/dist/updated/getChangedPropertyKey.d.ts.map +1 -0
- package/dist/updated/getChangedPropertyKey.js +19 -0
- package/dist/updated/index.d.ts +2 -0
- package/dist/updated/index.d.ts.map +1 -1
- package/dist/updated/index.js +2 -0
- package/dist/updated/requestHostUpdate.d.ts +10 -0
- package/dist/updated/requestHostUpdate.d.ts.map +1 -0
- package/dist/updated/requestHostUpdate.js +19 -0
- package/dist/updated/updated.d.ts +2 -1
- package/dist/updated/updated.d.ts.map +1 -1
- package/dist/updated/updated.js +1 -1
- package/package.json +31 -31
package/README.md
CHANGED
|
@@ -11,6 +11,7 @@ npm install @a11d/lit
|
|
|
11
11
|
## Features
|
|
12
12
|
|
|
13
13
|
- **[`Component` class](/packages/Lit/Component/README.md)** - Extended base class with additional lifecycle callbacks
|
|
14
|
+
- **[`ComponentPart` class](/packages/Lit/ComponentPart/README.md)** - Break up a large component without introducing a component boundary
|
|
14
15
|
- **[`updated` Decorator](/packages/Lit/updated/README.md)** - React to property changes with callbacks
|
|
15
16
|
- **[`event` Decorator](/packages/Lit/event/README.md)** - Type-safe custom event dispatchers
|
|
16
17
|
- **[`eventListener` Decorator](/packages/Lit/eventListener/README.md)** - Declarative event listener registration
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type HTMLTemplateResult, type ReactiveElement } from 'lit';
|
|
2
|
+
import { Controller } from '../Controller/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* A part of a component, extracted into a class of its own without introducing a component boundary.
|
|
5
|
+
*
|
|
6
|
+
* A part contributes a `template` to its host and may declare its own state, queries, events and
|
|
7
|
+
* event listeners with the very same decorators a component uses. As a part shares the update
|
|
8
|
+
* lifecycle of its host, changing its state re-renders the host as a whole - no properties have to
|
|
9
|
+
* be passed down and no updates have to be propagated by hand.
|
|
10
|
+
*
|
|
11
|
+
* This makes a part the tool of choice to break up a large component, whereas a component should be
|
|
12
|
+
* introduced whenever the extracted unit is reusable on its own.
|
|
13
|
+
*/
|
|
14
|
+
export declare abstract class ComponentPart<THost extends ReactiveElement = ReactiveElement> extends Controller {
|
|
15
|
+
protected readonly host: THost;
|
|
16
|
+
constructor(host: THost);
|
|
17
|
+
/** The template of the part which its host renders. */
|
|
18
|
+
get template(): HTMLTemplateResult;
|
|
19
|
+
/**
|
|
20
|
+
* Requests an update of the host.
|
|
21
|
+
*
|
|
22
|
+
* When a property key is provided, the change is tracked in the host's `changedProperties`
|
|
23
|
+
* by a key unique to this part and property, so that it can neither collide with a property
|
|
24
|
+
* of the host nor with one of another part.
|
|
25
|
+
*/
|
|
26
|
+
requestUpdate(propertyKey?: PropertyKey, oldValue?: unknown): void;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=ComponentPart.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ComponentPart.d.ts","sourceRoot":"","sources":["../../ComponentPart/ComponentPart.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,kBAAkB,EAAE,KAAK,eAAe,EAAE,MAAM,KAAK,CAAA;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAInD;;;;;;;;;;GAUG;AACH,8BAAsB,aAAa,CAAC,KAAK,SAAS,eAAe,GAAG,eAAe,CAAE,SAAQ,UAAU;uBAC9D,IAAI,EAAE,KAAK;gBAAX,IAAI,EAAE,KAAK;IAInD,uDAAuD;IACvD,IAAI,QAAQ,IAAI,kBAAkB,CAEjC;IAED;;;;;;OAMG;IACH,aAAa,CAAC,WAAW,CAAC,EAAE,WAAW,EAAE,QAAQ,CAAC,EAAE,OAAO;CAG3D"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Controller } from '../Controller/index.js';
|
|
2
|
+
import { html } from '../Component/html.js';
|
|
3
|
+
import { requestHostUpdate } from '../updated/requestHostUpdate.js';
|
|
4
|
+
/**
|
|
5
|
+
* A part of a component, extracted into a class of its own without introducing a component boundary.
|
|
6
|
+
*
|
|
7
|
+
* A part contributes a `template` to its host and may declare its own state, queries, events and
|
|
8
|
+
* event listeners with the very same decorators a component uses. As a part shares the update
|
|
9
|
+
* lifecycle of its host, changing its state re-renders the host as a whole - no properties have to
|
|
10
|
+
* be passed down and no updates have to be propagated by hand.
|
|
11
|
+
*
|
|
12
|
+
* This makes a part the tool of choice to break up a large component, whereas a component should be
|
|
13
|
+
* introduced whenever the extracted unit is reusable on its own.
|
|
14
|
+
*/
|
|
15
|
+
export class ComponentPart extends Controller {
|
|
16
|
+
constructor(host) {
|
|
17
|
+
super(host);
|
|
18
|
+
this.host = host;
|
|
19
|
+
}
|
|
20
|
+
/** The template of the part which its host renders. */
|
|
21
|
+
get template() {
|
|
22
|
+
return html.nothing;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Requests an update of the host.
|
|
26
|
+
*
|
|
27
|
+
* When a property key is provided, the change is tracked in the host's `changedProperties`
|
|
28
|
+
* by a key unique to this part and property, so that it can neither collide with a property
|
|
29
|
+
* of the host nor with one of another part.
|
|
30
|
+
*/
|
|
31
|
+
requestUpdate(propertyKey, oldValue) {
|
|
32
|
+
requestHostUpdate(this, propertyKey, oldValue);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
# `ComponentPart` class
|
|
2
|
+
|
|
3
|
+
A `ComponentPart` is a part of a component, extracted into a class of its own **without introducing a component boundary**.
|
|
4
|
+
|
|
5
|
+
A part contributes a `template` to its host and may declare its own state, queries, events and event listeners with the very same decorators a component uses. As a part shares the update lifecycle of its host, changing the state of a part re-renders the host as a whole — no properties have to be passed down and no updates have to be propagated by hand.
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import { bind, Component, component, ComponentPart, html, state } from '@a11d/lit'
|
|
9
|
+
|
|
10
|
+
class SearchPart extends ComponentPart<PageProducts> {
|
|
11
|
+
@state() query = ''
|
|
12
|
+
|
|
13
|
+
override get template() {
|
|
14
|
+
return html`
|
|
15
|
+
<input ${bind(this, 'query')}>
|
|
16
|
+
<span>${this.host.products.filter(p => p.name.includes(this.query)).length}</span>
|
|
17
|
+
`
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
@component('page-products')
|
|
22
|
+
class PageProducts extends Component {
|
|
23
|
+
@state() products = new Array<Product>()
|
|
24
|
+
|
|
25
|
+
readonly search = new SearchPart(this)
|
|
26
|
+
|
|
27
|
+
protected override get template() {
|
|
28
|
+
return html`${this.search.template}`
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Import the host as a type
|
|
34
|
+
|
|
35
|
+
A part names its host as a type argument and must therefore **import it with `import type`**, so the import is erased and the two files do not form a cycle at runtime:
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
// SearchPart.ts
|
|
39
|
+
import type { PageProducts } from './PageProducts.js'
|
|
40
|
+
|
|
41
|
+
export class SearchPart extends ComponentPart<PageProducts> { }
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
// PageProducts.ts
|
|
46
|
+
import { SearchPart } from './SearchPart.js'
|
|
47
|
+
|
|
48
|
+
@component('page-products')
|
|
49
|
+
export class PageProducts extends Component {
|
|
50
|
+
readonly search = new SearchPart(this)
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## When to use a part
|
|
55
|
+
|
|
56
|
+
Use a **component** whenever the extracted unit is reusable on its own, and a **part** whenever a large component should merely be broken up into comprehensible units:
|
|
57
|
+
|
|
58
|
+
| | `Component` | `ComponentPart` |
|
|
59
|
+
| ---------------------- | -------------------------------------------- | -------------------------------------------- |
|
|
60
|
+
| Reusable on its own | yes | no, it belongs to its host |
|
|
61
|
+
| Data flow | properties in, events out | direct access to the host |
|
|
62
|
+
| Update propagation | by the properties passed to it | shared with the host |
|
|
63
|
+
| DOM | own shadow root | rendered into the host's shadow root |
|
|
64
|
+
| Styling | own styles | the styles of the host |
|
|
65
|
+
|
|
66
|
+
## Decorators
|
|
67
|
+
|
|
68
|
+
The decorators of this library resolve the element owning the update lifecycle through the `host` symbol, and therefore behave identically on a component and on a part:
|
|
69
|
+
|
|
70
|
+
| Decorator | Behavior on a part |
|
|
71
|
+
| ---------------- | ------------------------------------------------------------------------------------ |
|
|
72
|
+
| `state` | stored on the part, requests an update of the host whenever it changes |
|
|
73
|
+
| `updated` | invoked with the part as `this` after the host has updated |
|
|
74
|
+
| `query` | queries the render root of the host |
|
|
75
|
+
| `queryAll` | queries the render root of the host |
|
|
76
|
+
| `event` | dispatches from the host element |
|
|
77
|
+
| `eventListener` | listens on the host element, with the part as `this` |
|
|
78
|
+
| `bind` | `bind(this, 'property')` binds against the part |
|
|
79
|
+
|
|
80
|
+
As the state of a part does not exist on its host, it cannot be registered as a reactive property of it. It is instead tracked in the host's `changedProperties` by a key unique to the part and the property, so that it can neither collide with a property of the host nor with one of another part.
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
class CounterPart extends ComponentPart<PageCounter> {
|
|
84
|
+
@state({ updated(this: CounterPart, value: number) { this.host.notify(value) } }) count = 0
|
|
85
|
+
|
|
86
|
+
@query('#count') private readonly countElement!: HTMLElement | undefined
|
|
87
|
+
|
|
88
|
+
@event() readonly countChange!: EventDispatcher<number>
|
|
89
|
+
|
|
90
|
+
@eventListener('click')
|
|
91
|
+
protected handleClick() {
|
|
92
|
+
this.count++
|
|
93
|
+
this.countChange.dispatch(this.count)
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
override get template() {
|
|
97
|
+
return html`<span id='count'>${this.count}</span>`
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Lifecycle
|
|
103
|
+
|
|
104
|
+
A part is a `Controller`, so all reactive controller callbacks are available:
|
|
105
|
+
|
|
106
|
+
```ts
|
|
107
|
+
class DataPart extends ComponentPart<PageData> {
|
|
108
|
+
@state() data?: Data
|
|
109
|
+
|
|
110
|
+
override async hostConnected() {
|
|
111
|
+
this.data = await fetchData()
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../ComponentPart/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ComponentPart.js';
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { type ReactiveController, type ReactiveControllerHost } from 'lit';
|
|
2
|
+
import { host } from '../host.js';
|
|
2
3
|
type Initializer = (controller: Controller) => void;
|
|
3
4
|
export declare abstract class Controller implements ReactiveController {
|
|
4
5
|
protected readonly host: ReactiveControllerHost;
|
|
5
6
|
private static _initializers?;
|
|
6
7
|
static addInitializer(initializer: Initializer): void;
|
|
7
8
|
constructor(host: ReactiveControllerHost);
|
|
9
|
+
get [host](): import("lit").ReactiveElement;
|
|
8
10
|
hostConnected?(): void;
|
|
9
11
|
hostDisconnected?(): void;
|
|
10
12
|
hostUpdate?(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Controller.d.ts","sourceRoot":"","sources":["../../Controller/Controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,kBAAkB,EAAE,KAAK,sBAAsB,EAAE,MAAM,KAAK,CAAA;
|
|
1
|
+
{"version":3,"file":"Controller.d.ts","sourceRoot":"","sources":["../../Controller/Controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,kBAAkB,EAAE,KAAK,sBAAsB,EAAE,MAAM,KAAK,CAAA;AAC1E,OAAO,EAAE,IAAI,EAAqB,MAAM,YAAY,CAAA;AAEpD,KAAK,WAAW,GAAG,CAAC,UAAU,EAAE,UAAU,KAAK,IAAI,CAAA;AAEnD,8BAAsB,UAAW,YAAW,kBAAkB;IAMjD,SAAS,CAAC,QAAQ,CAAC,IAAI,EAAE,sBAAsB;IAL3D,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,CAAkB;IAC/C,MAAM,CAAC,cAAc,CAAC,WAAW,EAAE,WAAW;gBAIf,IAAI,EAAE,sBAAsB;IAK3D,IAAI,CAAC,IAAI,CAAC,kCAET;IAED,aAAa,CAAC,IAAI,IAAI;IACtB,gBAAgB,CAAC,IAAI,IAAI;IACzB,UAAU,CAAC,IAAI,IAAI;IACnB,WAAW,CAAC,IAAI,IAAI;CACpB"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { host } from '../host.js';
|
|
1
2
|
export class Controller {
|
|
2
3
|
static addInitializer(initializer) {
|
|
3
4
|
(this._initializers ??= new Set(Object.getPrototypeOf(this).initializers ?? [])).add(initializer);
|
|
@@ -7,4 +8,7 @@ export class Controller {
|
|
|
7
8
|
this.host.addController(this);
|
|
8
9
|
this.constructor._initializers?.forEach(initializer => initializer(this));
|
|
9
10
|
}
|
|
11
|
+
get [host]() {
|
|
12
|
+
return this.host[host];
|
|
13
|
+
}
|
|
10
14
|
}
|
package/dist/README.md
CHANGED
|
@@ -11,6 +11,7 @@ npm install @a11d/lit
|
|
|
11
11
|
## Features
|
|
12
12
|
|
|
13
13
|
- **[`Component` class](/packages/Lit/Component/README.md)** - Extended base class with additional lifecycle callbacks
|
|
14
|
+
- **[`ComponentPart` class](/packages/Lit/ComponentPart/README.md)** - Break up a large component without introducing a component boundary
|
|
14
15
|
- **[`updated` Decorator](/packages/Lit/updated/README.md)** - React to property changes with callbacks
|
|
15
16
|
- **[`event` Decorator](/packages/Lit/event/README.md)** - Type-safe custom event dispatchers
|
|
16
17
|
- **[`eventListener` Decorator](/packages/Lit/eventListener/README.md)** - Declarative event listener registration
|
|
@@ -17,7 +17,14 @@ export declare enum BindingMode {
|
|
|
17
17
|
*/
|
|
18
18
|
OneWayToSource = "one-way-to-source"
|
|
19
19
|
}
|
|
20
|
-
|
|
20
|
+
/**
|
|
21
|
+
* The source a binding can be established on.
|
|
22
|
+
*
|
|
23
|
+
* Besides `ReactiveElement`s this includes any context which forwards its updates to a host,
|
|
24
|
+
* such as a `ComponentPart`, so bindings can be declared in a part's template as well.
|
|
25
|
+
*/
|
|
26
|
+
export type BindSource = Pick<ReactiveElement, 'requestUpdate'>;
|
|
27
|
+
export type BindDirectiveParameters<Component extends BindSource, Property extends keyof Component> = [
|
|
21
28
|
component: Component,
|
|
22
29
|
property: Property,
|
|
23
30
|
options?: BindDirectiveParametersOptions<Component[Property]>
|
|
@@ -30,14 +37,14 @@ export type BindDirectiveParametersOptions<Data> = {
|
|
|
30
37
|
sourceUpdated?: (value: Data) => void;
|
|
31
38
|
};
|
|
32
39
|
type BindDirectivePart = ElementPart | AttributePart | BooleanAttributePart | PropertyPart;
|
|
33
|
-
declare class BindDirective<Component extends
|
|
40
|
+
declare class BindDirective<Component extends BindSource, Property extends keyof Component> extends AsyncDirective {
|
|
34
41
|
#private;
|
|
35
42
|
constructor(partInfo: PartInfo);
|
|
36
|
-
render():
|
|
43
|
+
render(): unknown;
|
|
37
44
|
update(part: BindDirectivePart, parameters: BindDirectiveParameters<Component, Property>): unknown;
|
|
38
45
|
disconnected(): void;
|
|
39
46
|
reconnected(): void;
|
|
40
47
|
}
|
|
41
|
-
export declare const bind: <Component extends
|
|
48
|
+
export declare const bind: <Component extends BindSource, Property extends keyof Component>(...parameters: BindDirectiveParameters<Component, Property>) => DirectiveResult<typeof BindDirective<Component, Property>>;
|
|
42
49
|
export {};
|
|
43
50
|
//# sourceMappingURL=BindDirective.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BindDirective.d.ts","sourceRoot":"","sources":["../../bind/BindDirective.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,cAAc,EAAE,KAAK,WAAW,EAAE,KAAK,QAAQ,EAAY,KAAK,aAAa,EAAE,KAAK,oBAAoB,EAAE,KAAK,YAAY,EAAE,KAAK,eAAe,EAAE,KAAK,eAAe,EAAY,MAAM,aAAa,CAAA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CACrC,CAAA;AAED,KAAK,iBAAiB,GAAG,WAAW,GAAG,aAAa,GAAG,oBAAoB,GAAG,YAAY,CAAA;AAE1F,cAAM,aAAa,CAAC,SAAS,SAAS,UAAU,EAAE,QAAQ,SAAS,MAAM,SAAS,CAAE,SAAQ,cAAc;;gBAG7F,QAAQ,EAAE,QAAQ;IAO9B,MAAM;IAIG,MAAM,CAAC,IAAI,EAAE,iBAAiB,EAAE,UAAU,EAAE,uBAAuB,CAAC,SAAS,EAAE,QAAQ,CAAC;IAYxF,YAAY;IAIZ,WAAW;CAGpB;AAED,eAAO,MAAM,IAAI,GAAI,SAAS,SAAS,UAAU,EAAE,QAAQ,SAAS,MAAM,SAAS,EAAE,GAAG,YAAY,uBAAuB,CAAC,SAAS,EAAE,QAAQ,CAAC,KACpF,eAAe,CAAC,OAAO,aAAa,CAAC,SAAS,EAAE,QAAQ,CAAC,CACpH,CAAA"}
|
package/dist/bind/Binder.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import { type BindDirectiveParametersOptions } from './BindDirective.js';
|
|
1
|
+
import { type BindDirectiveParametersOptions, type BindSource } from './BindDirective.js';
|
|
3
2
|
type BinderParameters<T> = [keyPath: KeyPath.Of<T>] | [options: BindDirectiveParametersOptions<T>];
|
|
4
3
|
/**
|
|
5
4
|
* A utility to facilitate binding to a property of a reactive element.
|
|
@@ -21,14 +20,14 @@ type BinderParameters<T> = [keyPath: KeyPath.Of<T>] | [options: BindDirectivePar
|
|
|
21
20
|
* ```
|
|
22
21
|
*/
|
|
23
22
|
export declare class Binder<T> {
|
|
24
|
-
readonly host:
|
|
23
|
+
readonly host: BindSource;
|
|
25
24
|
readonly key: string;
|
|
26
|
-
constructor(host:
|
|
25
|
+
constructor(host: BindSource, key: string);
|
|
27
26
|
bind: (...[parameter]: BinderParameters<T>) => import("lit-html/directive.js").DirectiveResult<{
|
|
28
27
|
new (partInfo: import("lit-html/directive.js").PartInfo): {
|
|
29
28
|
"__#private@#valueBinder"?: import("./ValueBinder.js").ValueBinder<import("lit-html").ElementPart | import("lit-html").AttributePart | import("lit-html").PropertyPart | import("lit-html").BooleanAttributePart>;
|
|
30
|
-
render():
|
|
31
|
-
update(part: import("lit-html").ElementPart | import("lit-html").AttributePart | import("lit-html").PropertyPart | import("lit-html").BooleanAttributePart, parameters: import("./BindDirective.js").BindDirectiveParameters<
|
|
29
|
+
render(): unknown;
|
|
30
|
+
update(part: import("lit-html").ElementPart | import("lit-html").AttributePart | import("lit-html").PropertyPart | import("lit-html").BooleanAttributePart, parameters: import("./BindDirective.js").BindDirectiveParameters<BindSource, "requestUpdate">): unknown;
|
|
32
31
|
disconnected(): void;
|
|
33
32
|
reconnected(): void;
|
|
34
33
|
isConnected: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Binder.d.ts","sourceRoot":"","sources":["../../bind/Binder.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"Binder.d.ts","sourceRoot":"","sources":["../../bind/Binder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,8BAA8B,EAAE,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAE/F,KAAK,gBAAgB,CAAC,CAAC,IACpB,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GACxB,CAAC,OAAO,EAAE,8BAA8B,CAAC,CAAC,CAAC,CAAC,CAAA;AAE/C;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,MAAM,CAAC,CAAC;IACR,QAAQ,CAAC,IAAI,EAAE,UAAU;IAAE,QAAQ,CAAC,GAAG,EAAE,MAAM;gBAAtC,IAAI,EAAE,UAAU,EAAW,GAAG,EAAE,MAAM;IAE3D,IAAI,GAAI,GAAG,aAAa,gBAAgB,CAAC,CAAC,CAAC;;;;;;;;;;;;OAI1C;IAED,SAAS,CAAC,aAAa,CAAC,UAAU,EAAE,8BAA8B,CAAC,CAAC,CAAC,GAAG,8BAA8B,CAAC,CAAC,CAAC;CAGzG"}
|
package/dist/event/README.md
CHANGED
|
@@ -1,67 +1,67 @@
|
|
|
1
|
-
# `event` Decorator
|
|
2
|
-
|
|
3
|
-
Create type-safe custom event dispatchers for your components. The `event` decorator converts a class field into an `EventDispatcher` that can dispatch custom events with typed payloads.
|
|
4
|
-
|
|
5
|
-
```ts
|
|
6
|
-
import { component, Component, html, event, EventDispatcher } from '@a11d/lit'
|
|
7
|
-
|
|
8
|
-
@component('delete-button')
|
|
9
|
-
class DeleteButton extends Component {
|
|
10
|
-
@event() readonly delete!: EventDispatcher<'single' | 'all'>
|
|
11
|
-
|
|
12
|
-
protected get template() {
|
|
13
|
-
return html`
|
|
14
|
-
<button @click=${() => this.delete.dispatch('single')}>Delete Single</button>
|
|
15
|
-
<button @click=${() => this.delete.dispatch('all')}>Delete All</button>
|
|
16
|
-
`
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
The decorator converts the field into a getter that returns an instance of either `HTMLElementEventDispatcher<T>` or `PureEventDispatcher<T>` based on the context, both implementing the `EventDispatcher<T>` interface.
|
|
22
|
-
|
|
23
|
-
## Event Options
|
|
24
|
-
|
|
25
|
-
The decorator accepts an options object to configure event behavior:
|
|
26
|
-
- `bubbles` - Whether the event bubbles up the DOM tree (default: `false`)
|
|
27
|
-
- `cancelable` - Whether the event can be cancelled (default: `false`)
|
|
28
|
-
- `composed` - Whether the event triggers listeners outside of shadow DOM (default: `false`)
|
|
29
|
-
- `type` - Custom DOM event type name (default: property name)
|
|
30
|
-
|
|
31
|
-
```ts
|
|
32
|
-
import { component, Component, html, event, EventDispatcher } from '@a11d/lit'
|
|
33
|
-
|
|
34
|
-
@component('delete-button')
|
|
35
|
-
class DeleteButton extends Component {
|
|
36
|
-
@event({ bubbles: true, composed: true }) readonly delete!: EventDispatcher<'single' | 'all'>
|
|
37
|
-
|
|
38
|
-
protected get template() {
|
|
39
|
-
return html`
|
|
40
|
-
<button @click=${() => this.delete.dispatch('single')}>Delete Single</button>
|
|
41
|
-
<button @click=${() => this.delete.dispatch('all')}>Delete All</button>
|
|
42
|
-
`
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
### Custom Event Types
|
|
48
|
-
|
|
49
|
-
By default, the DOM event type matches the property name. Use the `type` option to specify a custom event type:
|
|
50
|
-
|
|
51
|
-
```ts
|
|
52
|
-
@component('user-form')
|
|
53
|
-
class UserForm extends Component {
|
|
54
|
-
@event({ type: 'user-save', bubbles: true }) readonly save!: EventDispatcher<User>
|
|
55
|
-
@event({ type: 'user-cancel' }) readonly cancel!: EventDispatcher<void>
|
|
56
|
-
|
|
57
|
-
protected get template() {
|
|
58
|
-
return html`
|
|
59
|
-
<button @click=${() => this.save.dispatch(user)}>Save</button>
|
|
60
|
-
<button @click=${() => this.cancel.dispatch()}>Cancel</button>
|
|
61
|
-
`
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// Listen using the custom type
|
|
66
|
-
html`<user-form @user-save=${(e: CustomEvent<User>) => this.handleUserSave(e.detail)}></user-form>`
|
|
1
|
+
# `event` Decorator
|
|
2
|
+
|
|
3
|
+
Create type-safe custom event dispatchers for your components. The `event` decorator converts a class field into an `EventDispatcher` that can dispatch custom events with typed payloads.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { component, Component, html, event, EventDispatcher } from '@a11d/lit'
|
|
7
|
+
|
|
8
|
+
@component('delete-button')
|
|
9
|
+
class DeleteButton extends Component {
|
|
10
|
+
@event() readonly delete!: EventDispatcher<'single' | 'all'>
|
|
11
|
+
|
|
12
|
+
protected get template() {
|
|
13
|
+
return html`
|
|
14
|
+
<button @click=${() => this.delete.dispatch('single')}>Delete Single</button>
|
|
15
|
+
<button @click=${() => this.delete.dispatch('all')}>Delete All</button>
|
|
16
|
+
`
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
The decorator converts the field into a getter that returns an instance of either `HTMLElementEventDispatcher<T>` or `PureEventDispatcher<T>` based on the context, both implementing the `EventDispatcher<T>` interface.
|
|
22
|
+
|
|
23
|
+
## Event Options
|
|
24
|
+
|
|
25
|
+
The decorator accepts an options object to configure event behavior:
|
|
26
|
+
- `bubbles` - Whether the event bubbles up the DOM tree (default: `false`)
|
|
27
|
+
- `cancelable` - Whether the event can be cancelled (default: `false`)
|
|
28
|
+
- `composed` - Whether the event triggers listeners outside of shadow DOM (default: `false`)
|
|
29
|
+
- `type` - Custom DOM event type name (default: property name)
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
import { component, Component, html, event, EventDispatcher } from '@a11d/lit'
|
|
33
|
+
|
|
34
|
+
@component('delete-button')
|
|
35
|
+
class DeleteButton extends Component {
|
|
36
|
+
@event({ bubbles: true, composed: true }) readonly delete!: EventDispatcher<'single' | 'all'>
|
|
37
|
+
|
|
38
|
+
protected get template() {
|
|
39
|
+
return html`
|
|
40
|
+
<button @click=${() => this.delete.dispatch('single')}>Delete Single</button>
|
|
41
|
+
<button @click=${() => this.delete.dispatch('all')}>Delete All</button>
|
|
42
|
+
`
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Custom Event Types
|
|
48
|
+
|
|
49
|
+
By default, the DOM event type matches the property name. Use the `type` option to specify a custom event type:
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
@component('user-form')
|
|
53
|
+
class UserForm extends Component {
|
|
54
|
+
@event({ type: 'user-save', bubbles: true }) readonly save!: EventDispatcher<User>
|
|
55
|
+
@event({ type: 'user-cancel' }) readonly cancel!: EventDispatcher<void>
|
|
56
|
+
|
|
57
|
+
protected get template() {
|
|
58
|
+
return html`
|
|
59
|
+
<button @click=${() => this.save.dispatch(user)}>Save</button>
|
|
60
|
+
<button @click=${() => this.cancel.dispatch()}>Cancel</button>
|
|
61
|
+
`
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Listen using the custom type
|
|
66
|
+
html`<user-form @user-save=${(e: CustomEvent<User>) => this.handleUserSave(e.detail)}></user-form>`
|
|
67
67
|
```
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event.d.ts","sourceRoot":"","sources":["../../event/event.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"event.d.ts","sourceRoot":"","sources":["../../event/event.ts"],"names":[],"mappings":"AAKA,wBAAgB,KAAK,CAAC,OAAO,CAAC,EAAE,SAAS,GAAG;IAAE,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,IAC7D,WAAW,OAAO,EAAE,cAAc,MAAM,UAchD"}
|
package/dist/event/event.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { isServer } from 'lit';
|
|
2
2
|
import { HTMLElementEventDispatcher } from './HTMLElementEventDispatcher.js';
|
|
3
3
|
import { PureEventDispatcher } from './PureEventDispatcher.js';
|
|
4
|
+
import { host } from '../host.js';
|
|
4
5
|
export function event(options) {
|
|
5
6
|
return (prototype, propertyKey) => {
|
|
6
7
|
if (propertyKey === undefined) {
|
|
@@ -8,8 +9,9 @@ export function event(options) {
|
|
|
8
9
|
}
|
|
9
10
|
Object.defineProperty(prototype, propertyKey, {
|
|
10
11
|
get() {
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
const element = this[host];
|
|
13
|
+
return this[`$${propertyKey}Event$`] ??= !isServer && element instanceof HTMLElement
|
|
14
|
+
? new HTMLElementEventDispatcher(element, options?.type ?? propertyKey, options)
|
|
13
15
|
: new PureEventDispatcher();
|
|
14
16
|
}
|
|
15
17
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ReactiveElement } from 'lit';
|
|
1
|
+
import { type ReactiveElement } from 'lit';
|
|
2
2
|
import type { EventListenerTarget } from './extractEventTargets.js';
|
|
3
3
|
import type { Controller } from '../Controller/Controller.js';
|
|
4
4
|
type ShorthandEventListenerDecoratorOptions = [type: string, options?: AddEventListenerOptions | boolean];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eventListener.d.ts","sourceRoot":"","sources":["../../eventListener/eventListener.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,KAAK,CAAA;
|
|
1
|
+
{"version":3,"file":"eventListener.d.ts","sourceRoot":"","sources":["../../eventListener/eventListener.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,KAAK,CAAA;AAE1C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AACnE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAA;AAG7D,KAAK,sCAAsC,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,uBAAuB,GAAG,OAAO,CAAC,CAAA;AAEzG,KAAK,iCAAiC,GAAG;IACxC,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,CAAC,EAAE,mBAAmB,CAAA;IAC5B,OAAO,CAAC,EAAE,uBAAuB,GAAG,OAAO,CAAA;CAC3C,CAAA;AAED,KAAK,6BAA6B,GAAG,sCAAsC,GAAG,CAAC,iCAAiC,CAAC,CAAA;AAEjH,wBAAgB,cAAc,CAAC,IAAI,EAAE,6BAA6B,GAAG,iCAAiC,CAOrG;AAED,eAAO,MAAM,aAAa,GAAI,GAAG,sBAAsB,6BAA6B,MAC3E,WAAW,eAAe,GAAG,UAAU,EAAE,aAAa,MAAM,EAAE,aAAa,kBAAkB,SA0BrG,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ReactiveElement } from 'lit';
|
|
2
1
|
import { EventListenerController } from './EventListenerController.js';
|
|
2
|
+
import { host } from '../host.js';
|
|
3
3
|
export function extractOptions(args) {
|
|
4
4
|
const short = ((args) => typeof args[0] === 'string')(args);
|
|
5
5
|
return {
|
|
@@ -12,7 +12,7 @@ export const eventListener = (...eventListenerOptions) => {
|
|
|
12
12
|
return (prototype, propertyKey, descriptor) => {
|
|
13
13
|
const Constructor = prototype.constructor;
|
|
14
14
|
Constructor.addInitializer(context => {
|
|
15
|
-
const element = context
|
|
15
|
+
const element = context[host];
|
|
16
16
|
new class extends EventListenerController {
|
|
17
17
|
constructor() {
|
|
18
18
|
const { type, target, options } = extractOptions(eventListenerOptions);
|
package/dist/host.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ReactiveElement } from 'lit';
|
|
2
|
+
/**
|
|
3
|
+
* The symbol resolving the `ReactiveElement` which owns the update lifecycle of a given context.
|
|
4
|
+
*
|
|
5
|
+
* A `ReactiveElement` resolves to itself, while a `Controller` resolves to its host, which allows
|
|
6
|
+
* decorators such as `state`, `query`, `queryAll`, `event`, `eventListener` and `updated` to behave
|
|
7
|
+
* identically regardless of whether they are applied on a component or on a controller.
|
|
8
|
+
*/
|
|
9
|
+
export declare const host: unique symbol;
|
|
10
|
+
export interface HostProvider {
|
|
11
|
+
readonly [host]: ReactiveElement;
|
|
12
|
+
}
|
|
13
|
+
declare module '@lit/reactive-element' {
|
|
14
|
+
interface ReactiveElement {
|
|
15
|
+
readonly [host]: ReactiveElement;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=host.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../host.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,KAAK,CAAA;AAErC;;;;;;GAMG;AACH,eAAO,MAAM,IAAI,eAAiB,CAAA;AAElC,MAAM,WAAW,YAAY;IAC5B,QAAQ,CAAC,CAAC,IAAI,CAAC,EAAE,eAAe,CAAA;CAChC;AAED,OAAO,QAAQ,uBAAuB,CAAC;IACtC,UAAU,eAAe;QACxB,QAAQ,CAAC,CAAC,IAAI,CAAC,EAAE,eAAe,CAAA;KAChC;CACD"}
|
package/dist/host.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ReactiveElement } from 'lit';
|
|
2
|
+
/**
|
|
3
|
+
* The symbol resolving the `ReactiveElement` which owns the update lifecycle of a given context.
|
|
4
|
+
*
|
|
5
|
+
* A `ReactiveElement` resolves to itself, while a `Controller` resolves to its host, which allows
|
|
6
|
+
* decorators such as `state`, `query`, `queryAll`, `event`, `eventListener` and `updated` to behave
|
|
7
|
+
* identically regardless of whether they are applied on a component or on a controller.
|
|
8
|
+
*/
|
|
9
|
+
export const host = Symbol('host');
|
|
10
|
+
Object.defineProperty(ReactiveElement.prototype, host, {
|
|
11
|
+
configurable: true,
|
|
12
|
+
get() { return this; },
|
|
13
|
+
});
|
package/dist/index.d.ts
CHANGED
|
@@ -28,7 +28,9 @@ export * from 'lit-html/directives/until.js';
|
|
|
28
28
|
export * from 'lit-html/directives/when.js';
|
|
29
29
|
export { render, noChange } from 'lit-html';
|
|
30
30
|
export { Component, component, html } from './Component/index.js';
|
|
31
|
+
export * from './ComponentPart/index.js';
|
|
31
32
|
export * from './Controller/index.js';
|
|
33
|
+
export * from './host.js';
|
|
32
34
|
export * from './query/index.js';
|
|
33
35
|
export * from './style/index.js';
|
|
34
36
|
export * from './updated/index.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,mBAAmB,CAAA;AAC1B,cAAc,KAAK,CAAA;AACnB,OAAO,EAAE,KAAK,2BAA2B,EAAE,KAAK,4BAA4B,EAAE,KAAK,yBAAyB,EAAE,YAAY,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAC5M,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,YAAY,EAAE,IAAI,IAAI,UAAU,EA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,0BAA0B,CAAA;AACxC,cAAc,kBAAkB,CAAA;AAChC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,eAAe,CAAA;AAC7B,cAAc,YAAY,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -28,7 +28,9 @@ export * from 'lit-html/directives/until.js';
|
|
|
28
28
|
export * from 'lit-html/directives/when.js';
|
|
29
29
|
export { render, noChange } from 'lit-html';
|
|
30
30
|
export { Component, component, html } from './Component/index.js';
|
|
31
|
+
export * from './ComponentPart/index.js';
|
|
31
32
|
export * from './Controller/index.js';
|
|
33
|
+
export * from './host.js';
|
|
32
34
|
export * from './query/index.js';
|
|
33
35
|
export * from './style/index.js';
|
|
34
36
|
export * from './updated/index.js';
|
package/dist/query/query.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type { ReactiveElement } from 'lit';
|
|
2
|
-
|
|
2
|
+
import type { Controller } from '../Controller/Controller.js';
|
|
3
|
+
export declare const query: (selector: string) => (prototype: ReactiveElement | Controller, propertyKey: PropertyKey) => void;
|
|
3
4
|
//# sourceMappingURL=query.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../query/query.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,KAAK,CAAA;
|
|
1
|
+
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../query/query.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,KAAK,CAAA;AAC1C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAA;AAG7D,eAAO,MAAM,KAAK,GAAI,UAAU,MAAM,MAC7B,WAAW,eAAe,GAAG,UAAU,EAAE,aAAa,WAAW,SAOzE,CAAA"}
|
package/dist/query/query.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { host } from '../host.js';
|
|
1
2
|
export const query = (selector) => {
|
|
2
3
|
return (prototype, propertyKey) => {
|
|
3
4
|
Object.defineProperty(prototype, propertyKey, {
|
|
4
5
|
get() {
|
|
5
|
-
return this
|
|
6
|
+
return this[host]?.renderRoot?.querySelector(selector) ?? undefined;
|
|
6
7
|
}
|
|
7
8
|
});
|
|
8
9
|
};
|
package/dist/query/queryAll.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type { ReactiveElement } from 'lit';
|
|
2
|
-
|
|
2
|
+
import type { Controller } from '../Controller/Controller.js';
|
|
3
|
+
export declare const queryAll: (selector: string) => (prototype: ReactiveElement | Controller, propertyKey: PropertyKey) => void;
|
|
3
4
|
//# sourceMappingURL=queryAll.d.ts.map
|