element-vir 12.0.1 → 12.1.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/declarative-element/declarative-element.d.ts +2 -1
- package/dist/declarative-element/define-element-no-inputs.d.ts +1 -1
- package/dist/declarative-element/define-element-no-inputs.js +5 -0
- package/dist/declarative-element/properties/assign-inputs.js +1 -13
- package/dist/declarative-element/properties/element-updater-proxy.d.ts +0 -1
- package/dist/declarative-element/properties/element-updater-proxy.js +0 -11
- package/package.json +7 -5
|
@@ -6,7 +6,7 @@ import { CssVarNameOrValueMap } from './properties/css-vars';
|
|
|
6
6
|
import { EventDescriptorMap, EventsInitMap } from './properties/element-events';
|
|
7
7
|
import { ElementPropertyDescriptorMap, PropertyInitMapBase } from './properties/element-properties';
|
|
8
8
|
import { HostClassNamesMap } from './properties/host-classes';
|
|
9
|
-
import { RenderCallback } from './render-callback';
|
|
9
|
+
import { RenderCallback, RenderParams } from './render-callback';
|
|
10
10
|
export type HostInstanceType<TagNameGeneric extends CustomElementTagName, InputsGeneric extends PropertyInitMapBase, StateInitMaybeAsyncGeneric extends PropertyInitMapBase, EventsInitGeneric extends EventsInitMap, HostClassKeys extends string, CssVarKeys extends string> = RequiredAndNotNullBy<DeclarativeElement<TagNameGeneric, InputsGeneric, StateInitMaybeAsyncGeneric, EventsInitGeneric, HostClassKeys, CssVarKeys, any>, 'shadowRoot'>;
|
|
11
11
|
export type DeclarativeElementDefinition<TagNameGeneric extends CustomElementTagName = any, InputsGeneric extends PropertyInitMapBase = any, StateInitMaybeAsyncGeneric extends PropertyInitMapBase = any, EventsInitGeneric extends EventsInitMap = any, HostClassKeys extends string = string, CssVarKeys extends string = string, RenderOutputGeneric = any> = (new () => HostInstanceType<TagNameGeneric, InputsGeneric, StateInitMaybeAsyncGeneric, EventsInitGeneric, HostClassKeys, CssVarKeys>) & StaticDeclarativeElementProperties<TagNameGeneric, InputsGeneric, StateInitMaybeAsyncGeneric, EventsInitGeneric, HostClassKeys, CssVarKeys, RenderOutputGeneric> & {
|
|
12
12
|
instanceType: HostInstanceType<TagNameGeneric, InputsGeneric, StateInitMaybeAsyncGeneric, EventsInitGeneric, HostClassKeys, CssVarKeys>;
|
|
@@ -24,6 +24,7 @@ export declare abstract class DeclarativeElement<TagNameGeneric extends CustomEl
|
|
|
24
24
|
static readonly hostClasses: StaticDeclarativeElementProperties<CustomElementTagName, PropertyInitMapBase, PropertyInitMapBase, EventsInitMap, string, string, unknown>['hostClasses'];
|
|
25
25
|
static readonly cssVarNames: StaticDeclarativeElementProperties<CustomElementTagName, PropertyInitMapBase, PropertyInitMapBase, EventsInitMap, string, string, unknown>['cssVarNames'];
|
|
26
26
|
static readonly cssVarValues: StaticDeclarativeElementProperties<CustomElementTagName, PropertyInitMapBase, PropertyInitMapBase, EventsInitMap, string, string, unknown>['cssVarValues'];
|
|
27
|
+
abstract lastRenderedProps: Pick<RenderParams<any, InputsGeneric, StateInitMaybeAsyncGeneric, any, any, any>, 'inputs' | 'state'>;
|
|
27
28
|
abstract render(): unknown;
|
|
28
29
|
abstract readonly instanceState: MaybeAsyncStateToSync<StateInitMaybeAsyncGeneric>;
|
|
29
30
|
abstract readonly asyncStateHandlerMap: AsyncStateHandlerMap<StateInitMaybeAsyncGeneric>;
|
|
@@ -2,4 +2,4 @@ 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 = {},
|
|
5
|
+
export declare function defineElementNoInputs<TagNameGeneric extends CustomElementTagName = '-', InputsGeneric extends PropertyInitMapBase = {}, StateInitMaybeAsyncGeneric extends PropertyInitMapBase = {}, EventsInitGeneric extends EventsInitMap = {}, HostClassKeys extends string = '', CssVarKeys extends string = '', RenderOutputGeneric = any>(initInput: DeclarativeElementInit<TagNameGeneric, InputsGeneric, StateInitMaybeAsyncGeneric, EventsInitGeneric, HostClassKeys, CssVarKeys, RenderOutputGeneric>): DeclarativeElementDefinition<TagNameGeneric, InputsGeneric, StateInitMaybeAsyncGeneric, EventsInitGeneric, HostClassKeys, CssVarKeys, RenderOutputGeneric>;
|
|
@@ -74,6 +74,10 @@ export function defineElementNoInputs(initInput) {
|
|
|
74
74
|
state: renderParams.state,
|
|
75
75
|
inputs: renderParams.inputs,
|
|
76
76
|
});
|
|
77
|
+
this.lastRenderedProps = {
|
|
78
|
+
inputs: { ...renderParams.inputs },
|
|
79
|
+
state: { ...renderParams.state },
|
|
80
|
+
};
|
|
77
81
|
return renderResult;
|
|
78
82
|
}
|
|
79
83
|
catch (caught) {
|
|
@@ -105,6 +109,7 @@ export function defineElementNoInputs(initInput) {
|
|
|
105
109
|
super();
|
|
106
110
|
this.initCalled = false;
|
|
107
111
|
this.hasRendered = false;
|
|
112
|
+
this.lastRenderedProps = undefined;
|
|
108
113
|
this.haveInputsBeenSet = false;
|
|
109
114
|
// this is set below in Object.defineProperties
|
|
110
115
|
this.definition = {};
|
|
@@ -1,19 +1,7 @@
|
|
|
1
1
|
import { getObjectTypedKeys } from '@augment-vir/common';
|
|
2
2
|
import { property } from 'lit/decorators.js';
|
|
3
|
-
import { isElementUpdaterProxy } from './element-updater-proxy';
|
|
4
|
-
function extractElementInstanceState(
|
|
5
|
-
/** Marked as partial here so that normal Element instances can also be passed in here. */
|
|
6
|
-
element) {
|
|
7
|
-
const rawInstanceState = element.instanceState;
|
|
8
|
-
if (isElementUpdaterProxy(rawInstanceState)) {
|
|
9
|
-
return rawInstanceState;
|
|
10
|
-
}
|
|
11
|
-
else {
|
|
12
|
-
return undefined;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
3
|
export function assignInputs(element, inputs) {
|
|
16
|
-
const instanceState =
|
|
4
|
+
const instanceState = element.instanceState;
|
|
17
5
|
getObjectTypedKeys(inputs).forEach((key) => {
|
|
18
6
|
if (instanceState && key in instanceState) {
|
|
19
7
|
throw new Error(`Cannot set input '${key}' on '${element.tagName}'. '${element.tagName}' already has a state property with the same name.`);
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import { DeclarativeElement } from '../declarative-element';
|
|
2
2
|
import { PropertyInitMapBase } from './element-properties';
|
|
3
|
-
export declare function isElementUpdaterProxy(input: unknown): input is PropertyInitMapBase;
|
|
4
3
|
export declare function createElementUpdaterProxy<PropertyInitGeneric extends PropertyInitMapBase>(element: DeclarativeElement, verifyExists: boolean): PropertyInitGeneric;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { isObject } from '@augment-vir/common';
|
|
2
1
|
import { AsyncStateHandler, AsyncStateInit } from './async-state';
|
|
3
2
|
function assertValidPropertyName(propKey, element, elementTagName) {
|
|
4
3
|
if (typeof propKey !== 'string' && typeof propKey !== 'number' && typeof propKey !== 'symbol') {
|
|
@@ -8,13 +7,6 @@ function assertValidPropertyName(propKey, element, elementTagName) {
|
|
|
8
7
|
throw new Error(`Property '${String(propKey)}' does not exist on '${elementTagName.toLowerCase()}'.`);
|
|
9
8
|
}
|
|
10
9
|
}
|
|
11
|
-
const elementUpdaterProxyMarker = Symbol('element-updater-proxy');
|
|
12
|
-
export function isElementUpdaterProxy(input) {
|
|
13
|
-
if (!isObject(input)) {
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
return input[elementUpdaterProxyMarker] === true;
|
|
17
|
-
}
|
|
18
10
|
export function createElementUpdaterProxy(element, verifyExists) {
|
|
19
11
|
/**
|
|
20
12
|
* Lit element updates state and inputs by setting them directly on the element, so we must do
|
|
@@ -23,9 +15,6 @@ export function createElementUpdaterProxy(element, verifyExists) {
|
|
|
23
15
|
*/
|
|
24
16
|
const elementAsProps = element;
|
|
25
17
|
function valueGetter(target, propertyKey) {
|
|
26
|
-
if (propertyKey === elementUpdaterProxyMarker) {
|
|
27
|
-
return true;
|
|
28
|
-
}
|
|
29
18
|
if (verifyExists) {
|
|
30
19
|
assertValidPropertyName(propertyKey, element, element.tagName);
|
|
31
20
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "element-vir",
|
|
3
|
-
"version": "12.0
|
|
3
|
+
"version": "12.1.0",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"custom",
|
|
6
6
|
"web",
|
|
@@ -39,13 +39,13 @@
|
|
|
39
39
|
"test:types": "tsc --noEmit"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@augment-vir/browser": "^13.
|
|
43
|
-
"@augment-vir/common": "^13.
|
|
42
|
+
"@augment-vir/browser": "^13.3.0",
|
|
43
|
+
"@augment-vir/common": "^13.3.0",
|
|
44
44
|
"lit": "2.7.2"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@augment-vir/browser-testing": "^13.
|
|
48
|
-
"@augment-vir/node-js": "^13.
|
|
47
|
+
"@augment-vir/browser-testing": "^13.3.0",
|
|
48
|
+
"@augment-vir/node-js": "^13.3.0",
|
|
49
49
|
"@istanbuljs/nyc-config-typescript": "^1.0.2",
|
|
50
50
|
"@open-wc/testing": "^3.1.8",
|
|
51
51
|
"@types/mocha": "^10.0.1",
|
|
@@ -56,9 +56,11 @@
|
|
|
56
56
|
"@web/test-runner-visual-regression": "^0.8.0",
|
|
57
57
|
"ansi-colors": "^4.1.3",
|
|
58
58
|
"cspell": "^6.31.1",
|
|
59
|
+
"esbuild": "^0.17.18",
|
|
59
60
|
"istanbul-smart-text-reporter": "^1.1.1",
|
|
60
61
|
"markdown-code-example-inserter": "^0.3.0",
|
|
61
62
|
"mocha-spec-reporter-with-file-names": "^0.0.3",
|
|
63
|
+
"npm-check-updates": "^16.10.9",
|
|
62
64
|
"nyc": "^15.1.0",
|
|
63
65
|
"prettier": "^2.8.8",
|
|
64
66
|
"prettier-plugin-interpolated-html-tags": "^0.0.3",
|