@a11d/lit
Enhanced utilities and base classes for Lit, providing additional lifecycle hooks, decorators, and directives for building web components.
It re-exports lit together with its directives, replacing html and some of its decorators with its own, so a project imports everything from @a11d/lit rather than from lit.
Installation
npm install @a11d/lit
Features
Componentclass - The base class for components, extendingLitElementwith atemplategetter and additional lifecycle callbacks.ComponentPartclass - A part of a component, extracted into a class of its own without introducing a component boundary.Controllerclass - A base class for reactive controllers that registers itself with its host.ElementRef/ElementRefsclasses - The element or elements a template designates, with whatever it declares about them.styleDirective - Apply inline styles to elements with proper typing and reactivity.updatedDecorator - React to property changes with callbacks.eventListenerDecorator - Declaratively register event listeners on methods.eventDecorator - Create type-safe custom event dispatchers for your components.bindDirective - Two-way data binding for Lit components.
Exports
| Name | Kind | Description |
|---|---|---|
Component | class | |
ComponentPart | class | A part of a component, extracted into a class of its own without introducing a component boundary. |
Controller | class | |
ElementRef | class | A single element, designated by the template and read back wherever it is needed. |
ElementRefs | class | The elements a template designates, each with the options it declares. |
StyleDirective | class | |
UpdatedController | class | |
EventListenerController | class | |
PureEventDispatcher | class | |
HTMLElementEventDispatcher | class | |
Binder | class | A utility to facilitate binding to a property of a reactive element. |
BindingIntegration | class | |
html | function | |
queryConnectedInstances | function | Decorator that adds a property of type "Set" to a component class which contains all connected instances of that component. |
extractEventTargets | function | |
extractOptions | function | |
event | function | |
bindingDefaultProperty | function | |
associatedEvent | function | |
BindingMode | enum | |
component | const | |
host | const | The symbol resolving the ReactiveElement which owns the update lifecycle of a given context. |
query | const | |
queryAll | const | |
queryAllAsNodeList | const | |
style | const | |
updated | const | |
eventListener | const | |
extractEventHandler | const | The function an event listener runs, which for a template's event binding also passes on what the bound function returns. |
bindingDefaultPropertyKey | const | |
associatedEventsByPropertiesKey | const | |
bind | const | |
bindingIntegrations | const | |
bindingIntegration | const | |
property | const | |
state | const | |
ElementRefLifecycle | interface | The lifecycle of the element or elements a reference holds. |
BindSource | type | The source a binding can be established on. |