element-vir 10.1.0 → 10.2.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/dist/augments/type.d.ts +1 -0
- package/dist/declarative-element/declarative-element-init.d.ts +5 -4
- package/dist/declarative-element/declarative-element.d.ts +23 -23
- package/dist/declarative-element/define-element-no-inputs.d.ts +1 -1
- package/dist/declarative-element/define-element-no-inputs.js +4 -1
- package/dist/declarative-element/define-element.d.ts +1 -1
- package/dist/declarative-element/directives/assign-with-clean-up.directive.d.ts +3 -3
- package/dist/declarative-element/directives/assign.directive.d.ts +7 -4
- package/dist/declarative-element/directives/render-promise.directive.d.ts +11 -10
- package/dist/declarative-element/directives/render-promise.directive.js +3 -0
- package/dist/declarative-element/render-callback.d.ts +5 -8
- package/dist/declarative-element/wrap-define-element.d.ts +6 -6
- package/package.json +1 -1
package/dist/augments/type.d.ts
CHANGED
|
@@ -7,4 +7,5 @@ export type NonEmptyString<T> = T extends '' ? never : T;
|
|
|
7
7
|
*/
|
|
8
8
|
export declare function ensureInstanceOf<T>(value: unknown, constructor: new (...args: any) => T, message?: string): asserts value is T;
|
|
9
9
|
export type PickAndBlockOthers<OriginalObject, PickKeys extends keyof OriginalObject> = Pick<OriginalObject, PickKeys> & Partial<Record<Exclude<keyof OriginalObject, PickKeys>, never>>;
|
|
10
|
+
export type RequireNonVoidReturn<NonVoid, ActualType> = void extends NonVoid ? NonVoid extends void ? 'missing return statement' : ActualType : ActualType;
|
|
10
11
|
//# sourceMappingURL=type.d.ts.map
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CSSResult } from 'lit';
|
|
2
|
+
import { RequireNonVoidReturn } from '../augments/type';
|
|
2
3
|
import { DeclarativeElementDefinitionOptions } from './definition-options';
|
|
3
4
|
import { CssVarsInitMap } from './properties/css-vars';
|
|
4
5
|
import { EventsInitMap } from './properties/element-events';
|
|
@@ -7,7 +8,7 @@ import { HostClassesInitMap } from './properties/host-classes';
|
|
|
7
8
|
import { StylesCallback } from './properties/styles';
|
|
8
9
|
import { InitCallback, RenderCallback } from './render-callback';
|
|
9
10
|
export type CustomElementTagName = `${string}-${string}`;
|
|
10
|
-
export type DeclarativeElementInit<TagNameGeneric extends CustomElementTagName, InputsGeneric extends PropertyInitMapBase, StateInitGeneric extends PropertyInitMapBase, EventsInitGeneric extends EventsInitMap, HostClassKeysGeneric extends string, CssVarKeysGeneric extends string> = {
|
|
11
|
+
export type DeclarativeElementInit<TagNameGeneric extends CustomElementTagName, InputsGeneric extends PropertyInitMapBase, StateInitGeneric extends PropertyInitMapBase, EventsInitGeneric extends EventsInitMap, HostClassKeysGeneric extends string, CssVarKeysGeneric extends string, RenderOutputGeneric> = {
|
|
11
12
|
/**
|
|
12
13
|
* HTML tag name. This should not be used directly, as interpolating it with the html tagged
|
|
13
14
|
* template from this package is preferred.
|
|
@@ -37,9 +38,9 @@ export type DeclarativeElementInit<TagNameGeneric extends CustomElementTagName,
|
|
|
37
38
|
*/
|
|
38
39
|
cssVars?: CssVarsInitMap<CssVarKeysGeneric>;
|
|
39
40
|
/** Called as part of the first renderCallback call, before the first renderCallback call. */
|
|
40
|
-
initCallback?: InitCallback<TagNameGeneric, InputsGeneric, StateInitGeneric, EventsInitGeneric, HostClassKeysGeneric, CssVarKeysGeneric>;
|
|
41
|
-
renderCallback: RenderCallback<TagNameGeneric, InputsGeneric, StateInitGeneric, EventsInitGeneric, HostClassKeysGeneric, CssVarKeysGeneric
|
|
42
|
-
cleanupCallback?: InitCallback<TagNameGeneric, InputsGeneric, StateInitGeneric, EventsInitGeneric, HostClassKeysGeneric, CssVarKeysGeneric>;
|
|
41
|
+
initCallback?: InitCallback<TagNameGeneric, InputsGeneric, StateInitGeneric, EventsInitGeneric, HostClassKeysGeneric, CssVarKeysGeneric, RenderOutputGeneric>;
|
|
42
|
+
renderCallback: RequireNonVoidReturn<RenderOutputGeneric, RenderCallback<TagNameGeneric, InputsGeneric, StateInitGeneric, EventsInitGeneric, HostClassKeysGeneric, CssVarKeysGeneric, RenderOutputGeneric>>;
|
|
43
|
+
cleanupCallback?: InitCallback<TagNameGeneric, InputsGeneric, StateInitGeneric, EventsInitGeneric, HostClassKeysGeneric, CssVarKeysGeneric, RenderOutputGeneric>;
|
|
43
44
|
options?: Partial<DeclarativeElementDefinitionOptions> | undefined;
|
|
44
45
|
};
|
|
45
46
|
//# sourceMappingURL=declarative-element-init.d.ts.map
|
|
@@ -5,41 +5,41 @@ import { CssVarNameOrValueMap } from './properties/css-vars';
|
|
|
5
5
|
import { EventDescriptorMap, EventsInitMap } from './properties/element-events';
|
|
6
6
|
import { ElementPropertyDescriptorMap, PropertyInitMapBase } from './properties/element-properties';
|
|
7
7
|
import { HostClassNamesMap } from './properties/host-classes';
|
|
8
|
-
import { RenderCallback
|
|
9
|
-
export type HostInstanceType<TagNameGeneric extends CustomElementTagName, InputsGeneric extends PropertyInitMapBase, StateInitGeneric extends PropertyInitMapBase, EventsInitGeneric extends EventsInitMap, HostClassKeys extends string, CssVarKeys extends string> = RequiredAndNotNullBy<DeclarativeElement<TagNameGeneric, InputsGeneric, StateInitGeneric, EventsInitGeneric, HostClassKeys, CssVarKeys>, 'shadowRoot'>;
|
|
10
|
-
export type DeclarativeElementDefinition<TagNameGeneric extends CustomElementTagName = any, InputsGeneric extends PropertyInitMapBase = any, StateInitGeneric extends PropertyInitMapBase = any, EventsInitGeneric extends EventsInitMap = any, HostClassKeys extends string = string, CssVarKeys extends string = string> = (new () => HostInstanceType<TagNameGeneric, InputsGeneric, StateInitGeneric, EventsInitGeneric, HostClassKeys, CssVarKeys>) & StaticDeclarativeElementProperties<TagNameGeneric, InputsGeneric, StateInitGeneric, EventsInitGeneric, HostClassKeys, CssVarKeys> & {
|
|
11
|
-
instanceType: HostInstanceType<TagNameGeneric, InputsGeneric, StateInitGeneric, EventsInitGeneric, HostClassKeys, CssVarKeys>;
|
|
8
|
+
import { RenderCallback } from './render-callback';
|
|
9
|
+
export type HostInstanceType<TagNameGeneric extends CustomElementTagName, InputsGeneric extends PropertyInitMapBase, StateInitGeneric extends PropertyInitMapBase, EventsInitGeneric extends EventsInitMap, HostClassKeys extends string, CssVarKeys extends string, RenderOutputGeneric> = RequiredAndNotNullBy<DeclarativeElement<TagNameGeneric, InputsGeneric, StateInitGeneric, EventsInitGeneric, HostClassKeys, CssVarKeys, RenderOutputGeneric>, 'shadowRoot'>;
|
|
10
|
+
export type DeclarativeElementDefinition<TagNameGeneric extends CustomElementTagName = any, InputsGeneric extends PropertyInitMapBase = any, StateInitGeneric extends PropertyInitMapBase = any, EventsInitGeneric extends EventsInitMap = any, HostClassKeys extends string = string, CssVarKeys extends string = string, RenderOutputGeneric = any> = (new () => HostInstanceType<TagNameGeneric, InputsGeneric, StateInitGeneric, EventsInitGeneric, HostClassKeys, CssVarKeys, RenderOutputGeneric>) & StaticDeclarativeElementProperties<TagNameGeneric, InputsGeneric, StateInitGeneric, EventsInitGeneric, HostClassKeys, CssVarKeys, RenderOutputGeneric> & {
|
|
11
|
+
instanceType: HostInstanceType<TagNameGeneric, InputsGeneric, StateInitGeneric, EventsInitGeneric, HostClassKeys, CssVarKeys, RenderOutputGeneric>;
|
|
12
12
|
};
|
|
13
|
-
export declare abstract class DeclarativeElement<TagNameGeneric extends CustomElementTagName = any, InputsGeneric extends PropertyInitMapBase = any, StateInitGeneric extends PropertyInitMapBase = any, EventsInitGeneric extends EventsInitMap = any, HostClassKeys extends string = string, CssVarKeys extends string = string> extends LitElement {
|
|
14
|
-
static readonly tagName: StaticDeclarativeElementProperties<CustomElementTagName, PropertyInitMapBase, PropertyInitMapBase, EventsInitMap, string, string>['tagName'];
|
|
15
|
-
static readonly styles: StaticDeclarativeElementProperties<CustomElementTagName, PropertyInitMapBase, PropertyInitMapBase, EventsInitMap, string, string>['styles'];
|
|
16
|
-
static readonly isStrictInstance: StaticDeclarativeElementProperties<CustomElementTagName, PropertyInitMapBase, PropertyInitMapBase, EventsInitMap, string, string>['isStrictInstance'];
|
|
17
|
-
static readonly renderCallback: StaticDeclarativeElementProperties<CustomElementTagName, PropertyInitMapBase, PropertyInitMapBase, EventsInitMap, string, string>['renderCallback'];
|
|
18
|
-
static readonly inputsType: StaticDeclarativeElementProperties<CustomElementTagName, PropertyInitMapBase, PropertyInitMapBase, EventsInitMap, string, string>['inputsType'];
|
|
19
|
-
static readonly stateType: StaticDeclarativeElementProperties<CustomElementTagName, PropertyInitMapBase, PropertyInitMapBase, EventsInitMap, string, string>['stateType'];
|
|
20
|
-
static readonly events: StaticDeclarativeElementProperties<CustomElementTagName, PropertyInitMapBase, PropertyInitMapBase, EventsInitMap, string, string>['events'];
|
|
21
|
-
static readonly stateInit: StaticDeclarativeElementProperties<CustomElementTagName, PropertyInitMapBase, PropertyInitMapBase, EventsInitMap, string, string>['stateInit'];
|
|
22
|
-
static readonly init: StaticDeclarativeElementProperties<CustomElementTagName, PropertyInitMapBase, PropertyInitMapBase, EventsInitMap, string, string>['init'];
|
|
23
|
-
static readonly hostClasses: StaticDeclarativeElementProperties<CustomElementTagName, PropertyInitMapBase, PropertyInitMapBase, EventsInitMap, string, string>['hostClasses'];
|
|
24
|
-
static readonly cssVarNames: StaticDeclarativeElementProperties<CustomElementTagName, PropertyInitMapBase, PropertyInitMapBase, EventsInitMap, string, string>['cssVarNames'];
|
|
25
|
-
static readonly cssVarValues: StaticDeclarativeElementProperties<CustomElementTagName, PropertyInitMapBase, PropertyInitMapBase, EventsInitMap, string, string>['cssVarValues'];
|
|
26
|
-
abstract render():
|
|
13
|
+
export declare abstract class DeclarativeElement<TagNameGeneric extends CustomElementTagName = any, InputsGeneric extends PropertyInitMapBase = any, StateInitGeneric extends PropertyInitMapBase = any, EventsInitGeneric extends EventsInitMap = any, HostClassKeys extends string = string, CssVarKeys extends string = string, RenderOutputGeneric = any> extends LitElement {
|
|
14
|
+
static readonly tagName: StaticDeclarativeElementProperties<CustomElementTagName, PropertyInitMapBase, PropertyInitMapBase, EventsInitMap, string, string, unknown>['tagName'];
|
|
15
|
+
static readonly styles: StaticDeclarativeElementProperties<CustomElementTagName, PropertyInitMapBase, PropertyInitMapBase, EventsInitMap, string, string, unknown>['styles'];
|
|
16
|
+
static readonly isStrictInstance: StaticDeclarativeElementProperties<CustomElementTagName, PropertyInitMapBase, PropertyInitMapBase, EventsInitMap, string, string, unknown>['isStrictInstance'];
|
|
17
|
+
static readonly renderCallback: StaticDeclarativeElementProperties<CustomElementTagName, PropertyInitMapBase, PropertyInitMapBase, EventsInitMap, string, string, unknown>['renderCallback'];
|
|
18
|
+
static readonly inputsType: StaticDeclarativeElementProperties<CustomElementTagName, PropertyInitMapBase, PropertyInitMapBase, EventsInitMap, string, string, unknown>['inputsType'];
|
|
19
|
+
static readonly stateType: StaticDeclarativeElementProperties<CustomElementTagName, PropertyInitMapBase, PropertyInitMapBase, EventsInitMap, string, string, unknown>['stateType'];
|
|
20
|
+
static readonly events: StaticDeclarativeElementProperties<CustomElementTagName, PropertyInitMapBase, PropertyInitMapBase, EventsInitMap, string, string, unknown>['events'];
|
|
21
|
+
static readonly stateInit: StaticDeclarativeElementProperties<CustomElementTagName, PropertyInitMapBase, PropertyInitMapBase, EventsInitMap, string, string, unknown>['stateInit'];
|
|
22
|
+
static readonly init: StaticDeclarativeElementProperties<CustomElementTagName, PropertyInitMapBase, PropertyInitMapBase, EventsInitMap, string, string, unknown>['init'];
|
|
23
|
+
static readonly hostClasses: StaticDeclarativeElementProperties<CustomElementTagName, PropertyInitMapBase, PropertyInitMapBase, EventsInitMap, string, string, unknown>['hostClasses'];
|
|
24
|
+
static readonly cssVarNames: StaticDeclarativeElementProperties<CustomElementTagName, PropertyInitMapBase, PropertyInitMapBase, EventsInitMap, string, string, unknown>['cssVarNames'];
|
|
25
|
+
static readonly cssVarValues: StaticDeclarativeElementProperties<CustomElementTagName, PropertyInitMapBase, PropertyInitMapBase, EventsInitMap, string, string, unknown>['cssVarValues'];
|
|
26
|
+
abstract render(): unknown;
|
|
27
27
|
abstract readonly instanceState: StateInitGeneric;
|
|
28
28
|
abstract readonly instanceInputs: InputsGeneric;
|
|
29
29
|
abstract assignInputs(inputs: InputsGeneric): void;
|
|
30
30
|
abstract haveInputsBeenSet: boolean;
|
|
31
31
|
abstract markInputsAsHavingBeenSet(): void;
|
|
32
|
-
abstract readonly definition: DeclarativeElementDefinition<TagNameGeneric, InputsGeneric, StateInitGeneric, EventsInitGeneric, HostClassKeys, CssVarKeys>;
|
|
32
|
+
abstract readonly definition: DeclarativeElementDefinition<TagNameGeneric, InputsGeneric, StateInitGeneric, EventsInitGeneric, HostClassKeys, CssVarKeys, RenderOutputGeneric>;
|
|
33
33
|
}
|
|
34
|
-
export interface StaticDeclarativeElementProperties<TagNameGeneric extends CustomElementTagName, InputsGeneric extends PropertyInitMapBase, StateInitGeneric extends PropertyInitMapBase, EventsInitGeneric extends EventsInitMap, HostClassKeys extends string, CssVarKeys extends string> {
|
|
34
|
+
export interface StaticDeclarativeElementProperties<TagNameGeneric extends CustomElementTagName, InputsGeneric extends PropertyInitMapBase, StateInitGeneric extends PropertyInitMapBase, EventsInitGeneric extends EventsInitMap, HostClassKeys extends string, CssVarKeys extends string, RenderOutputGeneric> {
|
|
35
35
|
/** Pass through the render callback for direct unit testability */
|
|
36
|
-
readonly renderCallback: RenderCallback<TagNameGeneric, InputsGeneric, StateInitGeneric, EventsInitGeneric, HostClassKeys, CssVarKeys>;
|
|
36
|
+
readonly renderCallback: RenderCallback<TagNameGeneric, InputsGeneric, StateInitGeneric, EventsInitGeneric, HostClassKeys, CssVarKeys, RenderOutputGeneric>;
|
|
37
37
|
events: EventDescriptorMap<EventsInitGeneric>;
|
|
38
38
|
stateInit: ElementPropertyDescriptorMap<StateInitGeneric>;
|
|
39
|
-
init: RequiredBy<DeclarativeElementInit<TagNameGeneric, InputsGeneric, StateInitGeneric, EventsInitGeneric, HostClassKeys, CssVarKeys>, 'stateInit' | 'events'>;
|
|
39
|
+
init: RequiredBy<DeclarativeElementInit<TagNameGeneric, InputsGeneric, StateInitGeneric, EventsInitGeneric, HostClassKeys, CssVarKeys, RenderOutputGeneric>, 'stateInit' | 'events'>;
|
|
40
40
|
inputsType: InputsGeneric;
|
|
41
41
|
stateType: StateInitGeneric;
|
|
42
|
-
isStrictInstance: (element: unknown) => element is DeclarativeElement<TagNameGeneric, InputsGeneric, StateInitGeneric, EventsInitGeneric, HostClassKeys, CssVarKeys>;
|
|
42
|
+
isStrictInstance: (element: unknown) => element is DeclarativeElement<TagNameGeneric, InputsGeneric, StateInitGeneric, EventsInitGeneric, HostClassKeys, CssVarKeys, RenderOutputGeneric>;
|
|
43
43
|
hostClasses: HostClassNamesMap<string, HostClassKeys>;
|
|
44
44
|
cssVarNames: CssVarNameOrValueMap<CssVarKeys>;
|
|
45
45
|
cssVarValues: CssVarNameOrValueMap<CssVarKeys>;
|
|
@@ -2,5 +2,5 @@ import { DeclarativeElementDefinition } from './declarative-element';
|
|
|
2
2
|
import { CustomElementTagName, DeclarativeElementInit } from './declarative-element-init';
|
|
3
3
|
import { EventsInitMap } from './properties/element-events';
|
|
4
4
|
import { PropertyInitMapBase } from './properties/element-properties';
|
|
5
|
-
export declare function defineElementNoInputs<TagNameGeneric extends CustomElementTagName = '-', InputsGeneric extends PropertyInitMapBase = {}, StateInitGeneric extends PropertyInitMapBase = {}, EventsInitGeneric extends EventsInitMap = {}, HostClassKeys extends string = '', CssVarKeys extends string = ''>(initInput: DeclarativeElementInit<TagNameGeneric, InputsGeneric, StateInitGeneric, EventsInitGeneric, HostClassKeys, CssVarKeys>): DeclarativeElementDefinition<TagNameGeneric, InputsGeneric, StateInitGeneric, EventsInitGeneric, HostClassKeys, CssVarKeys>;
|
|
5
|
+
export declare function defineElementNoInputs<TagNameGeneric extends CustomElementTagName = '-', InputsGeneric extends PropertyInitMapBase = {}, StateInitGeneric extends PropertyInitMapBase = {}, EventsInitGeneric extends EventsInitMap = {}, HostClassKeys extends string = '', CssVarKeys extends string = '', RenderOutputGeneric = any>(initInput: DeclarativeElementInit<TagNameGeneric, InputsGeneric, StateInitGeneric, EventsInitGeneric, HostClassKeys, CssVarKeys, RenderOutputGeneric>): DeclarativeElementDefinition<TagNameGeneric, InputsGeneric, StateInitGeneric, EventsInitGeneric, HostClassKeys, CssVarKeys, RenderOutputGeneric>;
|
|
6
6
|
//# sourceMappingURL=define-element-no-inputs.d.ts.map
|
|
@@ -19,6 +19,9 @@ import { applyHostClasses, hostClassNamesToStylesInput } from './properties/styl
|
|
|
19
19
|
import { createRenderParams } from './render-callback';
|
|
20
20
|
export function defineElementNoInputs(initInput) {
|
|
21
21
|
var _a;
|
|
22
|
+
if (!initInput.renderCallback || typeof initInput.renderCallback === 'string') {
|
|
23
|
+
throw new Error(`Failed to define element '${initInput.tagName}': renderCallback is not a function`);
|
|
24
|
+
}
|
|
22
25
|
const eventsMap = createEventDescriptorMap(initInput.events);
|
|
23
26
|
const hostClassNames = createHostClassNamesMap(initInput.tagName, initInput.hostClasses);
|
|
24
27
|
const cssVarNames = createCssVarNamesMap(initInput.tagName, initInput.cssVars);
|
|
@@ -63,7 +66,7 @@ export function defineElementNoInputs(initInput) {
|
|
|
63
66
|
this.initCalled = true;
|
|
64
67
|
initInput.initCallback(renderParams);
|
|
65
68
|
}
|
|
66
|
-
const renderResult =
|
|
69
|
+
const renderResult = typedRenderCallback(renderParams);
|
|
67
70
|
applyHostClasses({
|
|
68
71
|
host: renderParams.host,
|
|
69
72
|
hostClassesInit: initInput.hostClasses,
|
|
@@ -2,5 +2,5 @@ import { DeclarativeElementDefinition } from './declarative-element';
|
|
|
2
2
|
import { DeclarativeElementInit } from './declarative-element-init';
|
|
3
3
|
import { EventsInitMap } from './properties/element-events';
|
|
4
4
|
import { PropertyInitMapBase } from './properties/element-properties';
|
|
5
|
-
export declare function defineElement<InputsGeneric extends PropertyInitMapBase = {}>(): <TagNameGeneric extends `${string}-${string}`, StateInitGeneric extends PropertyInitMapBase = {}, EventsInitGeneric extends EventsInitMap = {}, HostClassKeysGeneric extends string = "", CssVarKeysGeneric extends string = "">(initInput: DeclarativeElementInit<TagNameGeneric, InputsGeneric, StateInitGeneric, EventsInitGeneric, HostClassKeysGeneric, CssVarKeysGeneric>) => DeclarativeElementDefinition<TagNameGeneric, InputsGeneric, StateInitGeneric, EventsInitGeneric, HostClassKeysGeneric, CssVarKeysGeneric>;
|
|
5
|
+
export declare function defineElement<InputsGeneric extends PropertyInitMapBase = {}>(): <TagNameGeneric extends `${string}-${string}`, StateInitGeneric extends PropertyInitMapBase = {}, EventsInitGeneric extends EventsInitMap = {}, HostClassKeysGeneric extends string = "", CssVarKeysGeneric extends string = "", RenderOutputGeneric = any>(initInput: DeclarativeElementInit<TagNameGeneric, InputsGeneric, StateInitGeneric, EventsInitGeneric, HostClassKeysGeneric, CssVarKeysGeneric, RenderOutputGeneric>) => DeclarativeElementDefinition<TagNameGeneric, InputsGeneric, StateInitGeneric, EventsInitGeneric, HostClassKeysGeneric, CssVarKeysGeneric, RenderOutputGeneric>;
|
|
6
6
|
//# sourceMappingURL=define-element.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AsyncDirective } from 'lit/async-directive.js';
|
|
2
2
|
import { PartInfo } from 'lit/directive.js';
|
|
3
|
-
import {
|
|
3
|
+
import { ElementDefinitionWithInputsType } from './assign.directive';
|
|
4
4
|
export type CleanupCallback<T> = (oldValue: T) => void;
|
|
5
5
|
/**
|
|
6
6
|
* Assign values but include a cleanup callback which gets called when a new value gets assigned so
|
|
@@ -10,7 +10,7 @@ export type CleanupCallback<T> = (oldValue: T) => void;
|
|
|
10
10
|
*
|
|
11
11
|
* Example use case: 3D graphics applications with classes that setup buffers and the like.
|
|
12
12
|
*/
|
|
13
|
-
export declare function assignWithCleanup<DeclarativeElementGeneric extends
|
|
13
|
+
export declare function assignWithCleanup<DeclarativeElementGeneric extends ElementDefinitionWithInputsType>(elementDefinition: DeclarativeElementGeneric, inputsObject: DeclarativeElementGeneric extends ElementDefinitionWithInputsType<infer InputsGeneric> ? InputsGeneric : never, cleanupCallback: CleanupCallback<DeclarativeElementGeneric extends ElementDefinitionWithInputsType<infer InputsGeneric> ? InputsGeneric : never>): import("lit-html/directive").DirectiveResult<typeof AssignWithCleanupDirectiveClass>;
|
|
14
14
|
declare class AssignWithCleanupDirectiveClass extends AsyncDirective {
|
|
15
15
|
private readonly element;
|
|
16
16
|
private lastValue;
|
|
@@ -18,7 +18,7 @@ declare class AssignWithCleanupDirectiveClass extends AsyncDirective {
|
|
|
18
18
|
private hasBeenAssigned;
|
|
19
19
|
constructor(partInfo: PartInfo);
|
|
20
20
|
disconnected(): void;
|
|
21
|
-
render(elementDefinition:
|
|
21
|
+
render(elementDefinition: ElementDefinitionWithInputsType, inputsObject: Record<PropertyKey, unknown>, cleanupCallback: CleanupCallback<any>): symbol;
|
|
22
22
|
}
|
|
23
23
|
export {};
|
|
24
24
|
//# sourceMappingURL=assign-with-clean-up.directive.d.ts.map
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { DirectiveResult } from 'lit/directive.js';
|
|
2
|
-
import {
|
|
2
|
+
import { PropertyInitMapBase } from '../properties/element-properties';
|
|
3
|
+
export type ElementDefinitionWithInputsType<InputsType extends PropertyInitMapBase = PropertyInitMapBase> = {
|
|
4
|
+
inputsType: InputsType;
|
|
5
|
+
};
|
|
3
6
|
/** Assign an object matching an element's inputs to its inputs. */
|
|
4
|
-
export declare function assign<DeclarativeElementGeneric extends
|
|
5
|
-
export declare function assign<DeclarativeElementGeneric extends
|
|
6
|
-
export declare function assignInputsObject<DeclarativeElementDefinitionGeneric extends
|
|
7
|
+
export declare function assign<DeclarativeElementGeneric extends ElementDefinitionWithInputsType>(declarativeElement: DeclarativeElementGeneric, inputsObject: DeclarativeElementGeneric['inputsType']): DirectiveResult;
|
|
8
|
+
export declare function assign<DeclarativeElementGeneric extends ElementDefinitionWithInputsType>(inputsObject: Record<string, any>): DirectiveResult;
|
|
9
|
+
export declare function assignInputsObject<DeclarativeElementDefinitionGeneric extends ElementDefinitionWithInputsType>(expectedElementConstructor: DeclarativeElementDefinitionGeneric | undefined, element: Element, assignmentObject: DeclarativeElementDefinitionGeneric['inputsType']): void;
|
|
7
10
|
//# sourceMappingURL=assign.directive.d.ts.map
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { CachedPromise, GetCachedPromiseInput } from '@electrovir/cached-promise';
|
|
2
2
|
import { RequireExactlyOne } from 'type-fest';
|
|
3
|
-
import {
|
|
4
|
-
export type RenderPromiseInput<
|
|
5
|
-
promise: Promise<
|
|
6
|
-
resolved:
|
|
3
|
+
import { RequireNonVoidReturn } from '../../augments/type';
|
|
4
|
+
export type RenderPromiseInput<ValueType> = RequireExactlyOne<{
|
|
5
|
+
promise: Promise<ValueType>;
|
|
6
|
+
resolved: ValueType;
|
|
7
7
|
error: Error;
|
|
8
8
|
}>;
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
export type RenderPromiseRenderer<ValueType, RenderOutput> = RequireNonVoidReturn<RenderOutput, (input: RenderPromiseInput<ValueType>) => RenderOutput>;
|
|
10
|
+
export declare function renderPromise<ValueType, RenderOutput>(maybePromise: Promise<ValueType> | ValueType, renderer: RenderPromiseRenderer<ValueType, RenderOutput>): RenderOutput | import("lit-html/directive").DirectiveResult<typeof import("lit-html/directives/until").UntilDirective>;
|
|
11
|
+
export type RenderCachedPromiseInputs<ValueType, RenderOutput> = {
|
|
12
|
+
cachedPromise: CachedPromise<ValueType>;
|
|
13
|
+
render: RenderPromiseRenderer<ValueType, RenderOutput>;
|
|
14
|
+
} & GetCachedPromiseInput<ValueType>;
|
|
15
|
+
export declare function renderCachedPromise<ValueType, RenderOutput>({ cachedPromise, render, triggers, createPromise, }: RenderCachedPromiseInputs<ValueType, RenderOutput>): import("lit-html/directive").DirectiveResult<typeof import("lit-html/directives/until").UntilDirective> | RenderOutput;
|
|
15
16
|
//# sourceMappingURL=render-promise.directive.d.ts.map
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { ensureError } from '@augment-vir/common';
|
|
2
2
|
import { until } from 'lit/directives/until.js';
|
|
3
3
|
export function renderPromise(maybePromise, renderer) {
|
|
4
|
+
if (typeof renderer === 'string') {
|
|
5
|
+
throw new Error(`Cannot pass string renderer`);
|
|
6
|
+
}
|
|
4
7
|
if (maybePromise instanceof Promise) {
|
|
5
8
|
return until(maybePromise
|
|
6
9
|
.catch((error) => {
|
|
@@ -1,21 +1,18 @@
|
|
|
1
|
-
import { TemplateResult } from 'lit';
|
|
2
|
-
import { Primitive } from 'type-fest';
|
|
3
1
|
import { TypedEvent } from '../typed-event/typed-event';
|
|
4
2
|
import { DeclarativeElement, HostInstanceType } from './declarative-element';
|
|
5
3
|
import { CustomElementTagName } from './declarative-element-init';
|
|
6
4
|
import { EventDescriptorMap, EventInitMapEventDetailExtractor, EventsInitMap } from './properties/element-events';
|
|
7
5
|
import { PropertyInitMapBase } from './properties/element-properties';
|
|
8
|
-
export type
|
|
9
|
-
export type
|
|
10
|
-
export type InitCallback<TagNameGeneric extends CustomElementTagName, InputsGeneric extends PropertyInitMapBase, StateGeneric extends PropertyInitMapBase, EventsInitGeneric extends EventsInitMap, HostClassKeys extends string, CssVarKeys extends string> = (params: RenderParams<TagNameGeneric, InputsGeneric, StateGeneric, EventsInitGeneric, HostClassKeys, CssVarKeys>) => void;
|
|
6
|
+
export type RenderCallback<TagNameGeneric extends CustomElementTagName = any, InputsGeneric extends PropertyInitMapBase = any, StateGeneric extends PropertyInitMapBase = any, EventsInitGeneric extends EventsInitMap = any, HostClassKeys extends string = any, CssVarKeys extends string = any, RenderOutputGeneric = any> = (params: RenderParams<TagNameGeneric, InputsGeneric, StateGeneric, EventsInitGeneric, HostClassKeys, CssVarKeys, RenderOutputGeneric>) => RenderOutputGeneric;
|
|
7
|
+
export type InitCallback<TagNameGeneric extends CustomElementTagName, InputsGeneric extends PropertyInitMapBase, StateGeneric extends PropertyInitMapBase, EventsInitGeneric extends EventsInitMap, HostClassKeys extends string, CssVarKeys extends string, RenderOutputGeneric> = (params: RenderParams<TagNameGeneric, InputsGeneric, StateGeneric, EventsInitGeneric, HostClassKeys, CssVarKeys, RenderOutputGeneric>) => void;
|
|
11
8
|
export type UpdateStateCallback<StateGeneric extends PropertyInitMapBase> = (newState: Partial<StateGeneric>) => void;
|
|
12
|
-
export type RenderParams<TagNameGeneric extends CustomElementTagName, InputsGeneric extends PropertyInitMapBase, StateInitGeneric extends PropertyInitMapBase, EventsInitGeneric extends EventsInitMap, HostClassKeys extends string, CssVarKeys extends string> = {
|
|
9
|
+
export type RenderParams<TagNameGeneric extends CustomElementTagName, InputsGeneric extends PropertyInitMapBase, StateInitGeneric extends PropertyInitMapBase, EventsInitGeneric extends EventsInitMap, HostClassKeys extends string, CssVarKeys extends string, RenderOutputGeneric> = {
|
|
13
10
|
state: Readonly<StateInitGeneric>;
|
|
14
11
|
updateState: UpdateStateCallback<StateInitGeneric>;
|
|
15
12
|
events: EventDescriptorMap<EventsInitGeneric>;
|
|
16
|
-
host: HostInstanceType<TagNameGeneric, InputsGeneric, StateInitGeneric, EventsInitGeneric, HostClassKeys, CssVarKeys>;
|
|
13
|
+
host: HostInstanceType<TagNameGeneric, InputsGeneric, StateInitGeneric, EventsInitGeneric, HostClassKeys, CssVarKeys, RenderOutputGeneric>;
|
|
17
14
|
dispatch: <EventTypeNameGeneric extends keyof EventsInitGeneric>(event: TypedEvent<EventTypeNameGeneric extends string ? EventTypeNameGeneric : never, EventInitMapEventDetailExtractor<EventTypeNameGeneric, EventsInitGeneric>> | Event) => boolean;
|
|
18
15
|
inputs: InputsGeneric;
|
|
19
16
|
};
|
|
20
|
-
export declare function createRenderParams<TagNameGeneric extends CustomElementTagName, InputsGeneric extends PropertyInitMapBase, StateGeneric extends PropertyInitMapBase, EventsInitGeneric extends EventsInitMap, HostClassKeys extends string, CssVarKeys extends string>(element: DeclarativeElement<TagNameGeneric, InputsGeneric, StateGeneric, EventsInitGeneric, HostClassKeys, CssVarKeys>, eventsMap: EventDescriptorMap<EventsInitGeneric>): RenderParams<TagNameGeneric, InputsGeneric, StateGeneric, EventsInitGeneric, HostClassKeys, CssVarKeys>;
|
|
17
|
+
export declare function createRenderParams<TagNameGeneric extends CustomElementTagName, InputsGeneric extends PropertyInitMapBase, StateGeneric extends PropertyInitMapBase, EventsInitGeneric extends EventsInitMap, HostClassKeys extends string, CssVarKeys extends string, RenderOutputGeneric>(element: DeclarativeElement<TagNameGeneric, InputsGeneric, StateGeneric, EventsInitGeneric, HostClassKeys, CssVarKeys, RenderOutputGeneric>, eventsMap: EventDescriptorMap<EventsInitGeneric>): RenderParams<TagNameGeneric, InputsGeneric, StateGeneric, EventsInitGeneric, HostClassKeys, CssVarKeys, RenderOutputGeneric>;
|
|
21
18
|
//# sourceMappingURL=render-callback.d.ts.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { PartialAndNullable } from '@augment-vir/common';
|
|
2
2
|
import { CustomElementTagName, DeclarativeElementInit, EventsInitMap, PropertyInitMapBase } from '..';
|
|
3
|
-
export type WrapDefineElementOptions<TagNameRequirementGeneric extends CustomElementTagName = CustomElementTagName, InputsRequirementGeneric extends PropertyInitMapBase = {}, StateInitRequirementGeneric extends PropertyInitMapBase = {}, EventsInitRequirementGeneric extends EventsInitMap = {}, HostClassKeysRequirementGeneric extends string = '', CssVarKeysRequirementGeneric extends string = ''> = PartialAndNullable<{
|
|
4
|
-
assertInputs: (inputInit: DeclarativeElementInit<TagNameRequirementGeneric, InputsRequirementGeneric, StateInitRequirementGeneric, EventsInitRequirementGeneric, HostClassKeysRequirementGeneric, CssVarKeysRequirementGeneric>) => void;
|
|
5
|
-
transformInputs: (inputInit: DeclarativeElementInit<TagNameRequirementGeneric, InputsRequirementGeneric, StateInitRequirementGeneric, EventsInitRequirementGeneric, HostClassKeysRequirementGeneric, CssVarKeysRequirementGeneric>) => DeclarativeElementInit<TagNameRequirementGeneric, InputsRequirementGeneric, StateInitRequirementGeneric, EventsInitRequirementGeneric, HostClassKeysRequirementGeneric, CssVarKeysRequirementGeneric>;
|
|
3
|
+
export type WrapDefineElementOptions<TagNameRequirementGeneric extends CustomElementTagName = CustomElementTagName, InputsRequirementGeneric extends PropertyInitMapBase = {}, StateInitRequirementGeneric extends PropertyInitMapBase = {}, EventsInitRequirementGeneric extends EventsInitMap = {}, HostClassKeysRequirementGeneric extends string = '', CssVarKeysRequirementGeneric extends string = '', RenderOutputGeneric = any> = PartialAndNullable<{
|
|
4
|
+
assertInputs: (inputInit: DeclarativeElementInit<TagNameRequirementGeneric, InputsRequirementGeneric, StateInitRequirementGeneric, EventsInitRequirementGeneric, HostClassKeysRequirementGeneric, CssVarKeysRequirementGeneric, RenderOutputGeneric>) => void;
|
|
5
|
+
transformInputs: (inputInit: DeclarativeElementInit<TagNameRequirementGeneric, InputsRequirementGeneric, StateInitRequirementGeneric, EventsInitRequirementGeneric, HostClassKeysRequirementGeneric, CssVarKeysRequirementGeneric, RenderOutputGeneric>) => DeclarativeElementInit<TagNameRequirementGeneric, InputsRequirementGeneric, StateInitRequirementGeneric, EventsInitRequirementGeneric, HostClassKeysRequirementGeneric, CssVarKeysRequirementGeneric, RenderOutputGeneric>;
|
|
6
6
|
}>;
|
|
7
|
-
export declare function wrapDefineElement<TagNameRequirementGeneric extends CustomElementTagName = CustomElementTagName, InputsRequirementGeneric extends PropertyInitMapBase = {}, StateInitRequirementGeneric extends PropertyInitMapBase = {}, EventsInitRequirementGeneric extends EventsInitMap = {}, HostClassKeysRequirementGeneric extends string = string, CssVarKeysRequirementGeneric extends string = string>(options?: WrapDefineElementOptions | undefined): {
|
|
8
|
-
defineElement: <InputsGeneric extends InputsRequirementGeneric>() => <TagNameGeneric extends TagNameRequirementGeneric, StateInitGeneric extends StateInitRequirementGeneric, EventsInitGeneric extends EventsInitRequirementGeneric, HostClassKeysGeneric extends HostClassKeysRequirementGeneric, CssVarKeysGeneric extends CssVarKeysRequirementGeneric>(inputs: DeclarativeElementInit<TagNameGeneric, InputsGeneric, StateInitGeneric, EventsInitGeneric, HostClassKeysGeneric, CssVarKeysGeneric>) => import("./declarative-element").DeclarativeElementDefinition<TagNameGeneric, InputsGeneric, StateInitGeneric, EventsInitGeneric, HostClassKeysGeneric, CssVarKeysGeneric>;
|
|
9
|
-
defineElementNoInputs: <TagNameGeneric_1 extends TagNameRequirementGeneric, InputsGeneric_1 extends InputsRequirementGeneric, StateInitGeneric_1 extends StateInitRequirementGeneric, EventsInitGeneric_1 extends EventsInitRequirementGeneric, HostClassKeysGeneric_1 extends HostClassKeysRequirementGeneric, CssVarKeysGeneric_1 extends CssVarKeysRequirementGeneric>(inputs: DeclarativeElementInit<TagNameGeneric_1, InputsGeneric_1, StateInitGeneric_1, EventsInitGeneric_1, HostClassKeysGeneric_1, CssVarKeysGeneric_1>) => import("./declarative-element").DeclarativeElementDefinition<TagNameGeneric_1, InputsGeneric_1, StateInitGeneric_1, EventsInitGeneric_1, HostClassKeysGeneric_1, CssVarKeysGeneric_1>;
|
|
7
|
+
export declare function wrapDefineElement<TagNameRequirementGeneric extends CustomElementTagName = CustomElementTagName, InputsRequirementGeneric extends PropertyInitMapBase = {}, StateInitRequirementGeneric extends PropertyInitMapBase = {}, EventsInitRequirementGeneric extends EventsInitMap = {}, HostClassKeysRequirementGeneric extends string = string, CssVarKeysRequirementGeneric extends string = string, RenderOutputGeneric = any>(options?: WrapDefineElementOptions | undefined): {
|
|
8
|
+
defineElement: <InputsGeneric extends InputsRequirementGeneric>() => <TagNameGeneric extends TagNameRequirementGeneric, StateInitGeneric extends StateInitRequirementGeneric, EventsInitGeneric extends EventsInitRequirementGeneric, HostClassKeysGeneric extends HostClassKeysRequirementGeneric, CssVarKeysGeneric extends CssVarKeysRequirementGeneric>(inputs: DeclarativeElementInit<TagNameGeneric, InputsGeneric, StateInitGeneric, EventsInitGeneric, HostClassKeysGeneric, CssVarKeysGeneric, RenderOutputGeneric>) => import("./declarative-element").DeclarativeElementDefinition<TagNameGeneric, InputsGeneric, StateInitGeneric, EventsInitGeneric, HostClassKeysGeneric, CssVarKeysGeneric, RenderOutputGeneric>;
|
|
9
|
+
defineElementNoInputs: <TagNameGeneric_1 extends TagNameRequirementGeneric, InputsGeneric_1 extends InputsRequirementGeneric, StateInitGeneric_1 extends StateInitRequirementGeneric, EventsInitGeneric_1 extends EventsInitRequirementGeneric, HostClassKeysGeneric_1 extends HostClassKeysRequirementGeneric, CssVarKeysGeneric_1 extends CssVarKeysRequirementGeneric>(inputs: DeclarativeElementInit<TagNameGeneric_1, InputsGeneric_1, StateInitGeneric_1, EventsInitGeneric_1, HostClassKeysGeneric_1, CssVarKeysGeneric_1, RenderOutputGeneric>) => import("./declarative-element").DeclarativeElementDefinition<TagNameGeneric_1, InputsGeneric_1, StateInitGeneric_1, EventsInitGeneric_1, HostClassKeysGeneric_1, CssVarKeysGeneric_1, RenderOutputGeneric>;
|
|
10
10
|
};
|
|
11
11
|
//# sourceMappingURL=wrap-define-element.d.ts.map
|