element-vir 12.4.4 → 12.4.6
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.
|
@@ -7,9 +7,9 @@ import { ElementPropertyDescriptorMap, PropertyInitMapBase } from './properties/
|
|
|
7
7
|
import { HostClassNamesMap } from './properties/host-classes';
|
|
8
8
|
import { AllowObservablePropertySetter, FlattenObservablePropertyGetters, ObservablePropertyHandlerMap } from './properties/observable-property/observable-property-handler';
|
|
9
9
|
import { RenderCallback, RenderParams } from './render-callback';
|
|
10
|
-
export type
|
|
11
|
-
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 () =>
|
|
12
|
-
instanceType:
|
|
10
|
+
export type DeclarativeElementHost<TagNameGeneric extends CustomElementTagName = any, InputsGeneric extends PropertyInitMapBase = any, StateInitGeneric extends PropertyInitMapBase = any, EventsInitGeneric extends EventsInitMap = any, HostClassKeys extends string = string, CssVarKeys extends string = string> = RequiredAndNotNullBy<DeclarativeElement<TagNameGeneric, InputsGeneric, StateInitGeneric, EventsInitGeneric, HostClassKeys, CssVarKeys, any>, 'shadowRoot'>;
|
|
11
|
+
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 () => DeclarativeElementHost<TagNameGeneric, InputsGeneric, StateInitGeneric, EventsInitGeneric, HostClassKeys, CssVarKeys>) & StaticDeclarativeElementProperties<TagNameGeneric, InputsGeneric, StateInitGeneric, EventsInitGeneric, HostClassKeys, CssVarKeys, RenderOutputGeneric> & {
|
|
12
|
+
instanceType: DeclarativeElementHost<TagNameGeneric, InputsGeneric, StateInitGeneric, EventsInitGeneric, HostClassKeys, CssVarKeys>;
|
|
13
13
|
};
|
|
14
14
|
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 {
|
|
15
15
|
static readonly tagName: StaticDeclarativeElementProperties<CustomElementTagName, PropertyInitMapBase, PropertyInitMapBase, EventsInitMap, string, string, unknown>['tagName'];
|
|
@@ -2,22 +2,32 @@ import { getObjectTypedKeys } from '@augment-vir/common';
|
|
|
2
2
|
import { property } from 'lit/decorators.js';
|
|
3
3
|
export function assignInputs(element, inputs) {
|
|
4
4
|
const instanceState = element.instanceState;
|
|
5
|
-
getObjectTypedKeys(inputs).forEach((
|
|
6
|
-
if (instanceState &&
|
|
7
|
-
throw new Error(`Cannot set input '${
|
|
5
|
+
getObjectTypedKeys(inputs).forEach((newInputKey) => {
|
|
6
|
+
if (instanceState && newInputKey in instanceState) {
|
|
7
|
+
throw new Error(`Cannot set input '${newInputKey}' on '${element.tagName}'. '${element.tagName}' already has a state property with the same name.`);
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
10
|
* No need to check if it's already a property or not, as the property function already
|
|
11
11
|
* makes that check.
|
|
12
12
|
*/
|
|
13
|
-
property()(element,
|
|
13
|
+
property()(element, newInputKey);
|
|
14
14
|
if ('instanceInputs' in element) {
|
|
15
|
-
element.instanceInputs[
|
|
15
|
+
element.instanceInputs[newInputKey] =
|
|
16
|
+
inputs[newInputKey];
|
|
16
17
|
}
|
|
17
18
|
else {
|
|
18
|
-
element[
|
|
19
|
+
element[newInputKey] = inputs[newInputKey];
|
|
19
20
|
}
|
|
20
21
|
});
|
|
22
|
+
/** Wipe out all inputs that weren't set to undefined (as expected) */
|
|
23
|
+
if ('instanceInputs' in element) {
|
|
24
|
+
getObjectTypedKeys(element.instanceInputs).forEach((existingKey) => {
|
|
25
|
+
if (!(existingKey in inputs)) {
|
|
26
|
+
element.instanceInputs[existingKey] =
|
|
27
|
+
undefined;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|
|
21
31
|
markInputsAsHavingBeenSet(element);
|
|
22
32
|
}
|
|
23
33
|
export function markInputsAsHavingBeenSet(element) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TypedEvent } from '../typed-event/typed-event';
|
|
2
|
-
import { DeclarativeElement,
|
|
2
|
+
import { DeclarativeElement, DeclarativeElementHost } from './declarative-element';
|
|
3
3
|
import { CustomElementTagName } from './declarative-element-init';
|
|
4
4
|
import { EventDescriptorMap, EventInitMapEventDetailExtractor, EventsInitMap } from './properties/element-events';
|
|
5
5
|
import { PropertyInitMapBase } from './properties/element-properties';
|
|
@@ -11,7 +11,7 @@ export type RenderParams<TagNameGeneric extends CustomElementTagName, InputsGene
|
|
|
11
11
|
state: Readonly<FlattenObservablePropertyGetters<StateInitGeneric>>;
|
|
12
12
|
updateState: UpdateStateCallback<StateInitGeneric>;
|
|
13
13
|
events: EventDescriptorMap<EventsInitGeneric>;
|
|
14
|
-
host:
|
|
14
|
+
host: DeclarativeElementHost<TagNameGeneric, InputsGeneric, StateInitGeneric, EventsInitGeneric, HostClassKeys, CssVarKeys>;
|
|
15
15
|
dispatch: <EventTypeNameGeneric extends keyof EventsInitGeneric>(event: TypedEvent<EventTypeNameGeneric extends string ? EventTypeNameGeneric : never, EventInitMapEventDetailExtractor<EventTypeNameGeneric, EventsInitGeneric>> | Event) => boolean;
|
|
16
16
|
inputs: Readonly<FlattenObservablePropertyGetters<InputsGeneric>>;
|
|
17
17
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "element-vir",
|
|
3
|
-
"version": "12.4.
|
|
3
|
+
"version": "12.4.6",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"custom",
|
|
6
6
|
"web",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"istanbul-smart-text-reporter": "^1.1.1",
|
|
61
61
|
"markdown-code-example-inserter": "^0.3.0",
|
|
62
62
|
"mocha-spec-reporter-with-file-names": "^0.0.3",
|
|
63
|
-
"npm-check-updates": "^16.10.
|
|
63
|
+
"npm-check-updates": "^16.10.12",
|
|
64
64
|
"nyc": "^15.1.0",
|
|
65
65
|
"prettier": "^2.8.8",
|
|
66
66
|
"prettier-plugin-interpolated-html-tags": "^0.0.3",
|