element-vir 14.2.0 → 14.2.2
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 -1
- package/dist/declarative-element/declarative-element.d.ts +4 -5
- package/dist/declarative-element/directives/assign-with-clean-up.directive.js +2 -2
- package/dist/declarative-element/directives/assign.directive.d.ts +10 -1
- package/dist/declarative-element/directives/assign.directive.js +11 -4
- package/package.json +10 -10
- package/www-static/index.css +7 -0
package/README.md
CHANGED
|
@@ -637,7 +637,7 @@ export const MyWithRenderIf = defineElement<{shouldRender: boolean}>()({
|
|
|
637
637
|
|
|
638
638
|
### `asyncProp`
|
|
639
639
|
|
|
640
|
-
Use `
|
|
640
|
+
Use `renderAsync` or `isRenderReady` in conjunction with `asyncProp` to seamlessly render and update element state based on async values:
|
|
641
641
|
|
|
642
642
|
<!-- example-link: src/readme-examples/my-with-async-prop.element.ts -->
|
|
643
643
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { RequiredAndNotNullBy, RequiredBy } from '@augment-vir/common';
|
|
2
|
+
import { AllowObservablePropertySetter } from 'element-vir';
|
|
2
3
|
import { CSSResult, LitElement } from 'lit';
|
|
3
4
|
import { WrappedMinimalDefinition } from '../template-transforms/minimal-element-definition';
|
|
4
5
|
import { CustomElementTagName, DeclarativeElementInit } from './declarative-element-init';
|
|
@@ -7,7 +8,7 @@ import { CssVars } from './properties/css-vars';
|
|
|
7
8
|
import { EventDescriptorMap, EventsInitMap } from './properties/element-events';
|
|
8
9
|
import { ElementPropertyDescriptorMap, PropertyInitMapBase } from './properties/element-properties';
|
|
9
10
|
import { HostClassNamesMap } from './properties/host-classes';
|
|
10
|
-
import {
|
|
11
|
+
import { FlattenObservablePropertyGetters, ObservablePropertyHandlerMap } from './properties/observable-property/observable-property-handler';
|
|
11
12
|
import { RenderCallback, RenderParams, UpdateStateCallback } from './render-callback';
|
|
12
13
|
export type DeclarativeElementHost<TagName extends CustomElementTagName = any, Inputs extends PropertyInitMapBase = any, StateInit extends PropertyInitMapBase = any, EventsInit extends EventsInitMap = any, HostClassKeys extends BaseCssPropertyName<TagName> = any, CssVarKeys extends BaseCssPropertyName<TagName> = any> = RequiredAndNotNullBy<Omit<DeclarativeElement<TagName, Inputs, StateInit, EventsInit, HostClassKeys, CssVarKeys, any>, Exclude<keyof StaticDeclarativeElementProperties<any, any, any, any, any, any, any>, keyof HTMLElement>>, 'shadowRoot'>;
|
|
13
14
|
export type DeclarativeElementDefinition<TagName extends CustomElementTagName = any, Inputs extends PropertyInitMapBase = any, StateInit extends PropertyInitMapBase = any, EventsInit extends EventsInitMap = any, HostClassKeys extends BaseCssPropertyName<TagName> = any, CssVarKeys extends BaseCssPropertyName<TagName> = any, RenderOutputGeneric = any> = (new () => DeclarativeElementHost<TagName, Inputs, StateInit, EventsInit, HostClassKeys, CssVarKeys>) & StaticDeclarativeElementProperties<TagName, Inputs, StateInit, EventsInit, HostClassKeys, CssVarKeys, RenderOutputGeneric> & {
|
|
@@ -40,16 +41,14 @@ export declare abstract class DeclarativeElement<TagName extends CustomElementTa
|
|
|
40
41
|
}
|
|
41
42
|
export interface StaticDeclarativeElementProperties<TagName extends CustomElementTagName, Inputs extends PropertyInitMapBase, StateInit extends PropertyInitMapBase, EventsInit extends EventsInitMap, HostClassKeys extends BaseCssPropertyName<TagName>, CssVarKeys extends BaseCssPropertyName<TagName>, RenderOutputGeneric> {
|
|
42
43
|
/** Assign inputs to an element directly on its interpolated tag. */
|
|
43
|
-
readonly assign: <const SpecificInputs extends {
|
|
44
|
-
[Prop in keyof Inputs]: unknown;
|
|
45
|
-
}>(inputsObject: {} extends Required<Inputs> ? never : AllowObservablePropertySetter<Inputs, SpecificInputs>) => WrappedMinimalDefinition;
|
|
44
|
+
readonly assign: <const SpecificInputs extends AllowObservablePropertySetter<Inputs, SpecificInputs>>(inputsObject: {} extends Required<Inputs> ? never : SpecificInputs) => WrappedMinimalDefinition;
|
|
46
45
|
assignedInputs: Inputs | undefined;
|
|
47
46
|
/** Pass through the render callback for direct unit testability */
|
|
48
47
|
readonly renderCallback: RenderCallback<TagName, Inputs, StateInit, EventsInit, HostClassKeys, CssVarKeys, RenderOutputGeneric>;
|
|
49
48
|
readonly events: EventDescriptorMap<EventsInit>;
|
|
50
49
|
readonly stateInitStatic: ElementPropertyDescriptorMap<StateInit>;
|
|
51
50
|
readonly init: RequiredBy<DeclarativeElementInit<TagName, Inputs, StateInit, EventsInit, HostClassKeys, CssVarKeys, RenderOutputGeneric>, 'stateInitStatic' | 'events'>;
|
|
52
|
-
readonly inputsType:
|
|
51
|
+
readonly inputsType: Inputs;
|
|
53
52
|
readonly stateType: Readonly<FlattenObservablePropertyGetters<StateInit>>;
|
|
54
53
|
readonly updateStateType: UpdateStateCallback<StateInit>;
|
|
55
54
|
readonly isStrictInstance: (element: unknown) => element is DeclarativeElement<TagName, Inputs, StateInit, EventsInit, HostClassKeys, CssVarKeys, RenderOutputGeneric>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { noChange } from 'lit';
|
|
2
2
|
import { AsyncDirective } from 'lit/async-directive.js';
|
|
3
3
|
import { directive } from 'lit/directive.js';
|
|
4
|
-
import {
|
|
4
|
+
import { assignInputs } from '../properties/assign-inputs';
|
|
5
5
|
import { extractElement } from './directive-helpers';
|
|
6
6
|
/**
|
|
7
7
|
* Assign values but include a cleanup callback which gets called when a new value gets assigned so
|
|
@@ -33,7 +33,7 @@ class AssignWithCleanupDirectiveClass extends AsyncDirective {
|
|
|
33
33
|
if (this.hasBeenAssigned) {
|
|
34
34
|
cleanupCallback(this.lastValue);
|
|
35
35
|
}
|
|
36
|
-
|
|
36
|
+
assignInputs(this.element, inputsObject);
|
|
37
37
|
this.hasBeenAssigned = true;
|
|
38
38
|
this.lastValue = inputsObject;
|
|
39
39
|
this.lastCallback = cleanupCallback;
|
|
@@ -17,7 +17,16 @@ export type ElementDefinitionWithInputsType<InputsType extends PropertyInitMapBa
|
|
|
17
17
|
export declare function assign<const SpecificDeclarativeElement extends ElementDefinitionWithInputsType, const SpecificInput extends {
|
|
18
18
|
[Prop in keyof SpecificDeclarativeElement['inputsType']]: unknown;
|
|
19
19
|
}>(declarativeElement: SpecificDeclarativeElement, inputsObject: {} extends Required<SpecificDeclarativeElement['inputsType']> ? never : AllowObservablePropertySetter<SpecificDeclarativeElement['inputsType'], SpecificInput>): DirectiveResult;
|
|
20
|
+
/**
|
|
21
|
+
* Assign an object matching an element's inputs to its inputs.
|
|
22
|
+
*
|
|
23
|
+
* @deprecated Instead of using this directive, assign inputs directly on the element's
|
|
24
|
+
* interpolation opening tag interpolation.
|
|
25
|
+
* @example
|
|
26
|
+
* html`<${MyElement} ${assign(MyElement, {value: 1})}>...`
|
|
27
|
+
* should be
|
|
28
|
+
* html`<${MyElement.assign({value: 1})}>...`
|
|
29
|
+
*/
|
|
20
30
|
export declare function assign<const SpecificDeclarativeElement extends ElementDefinitionWithInputsType, const SpecificInput extends {
|
|
21
31
|
[Prop in keyof SpecificDeclarativeElement['inputsType']]: unknown;
|
|
22
32
|
}>(inputsObject: SpecificInput extends typeof HTMLElement ? never : SpecificInput): DirectiveResult;
|
|
23
|
-
export declare function assignInputsObject<DeclarativeElementDefinitionGeneric extends ElementDefinitionWithInputsType>(expectedElementConstructor: DeclarativeElementDefinitionGeneric | undefined, element: Element, assignmentObject: DeclarativeElementDefinitionGeneric['inputsType']): void;
|
|
@@ -2,6 +2,16 @@ import { noChange } from 'lit';
|
|
|
2
2
|
import { directive, Directive } from 'lit/directive.js';
|
|
3
3
|
import { assignInputs } from '../properties/assign-inputs';
|
|
4
4
|
import { extractElement } from './directive-helpers';
|
|
5
|
+
/**
|
|
6
|
+
* Assign an object matching an element's inputs to its inputs.
|
|
7
|
+
*
|
|
8
|
+
* @deprecated Instead of using this directive, assign inputs directly on the element's
|
|
9
|
+
* interpolation opening tag interpolation.
|
|
10
|
+
* @example
|
|
11
|
+
* html`<${MyElement} ${assign(MyElement, {value: 1})}>...`
|
|
12
|
+
* should be
|
|
13
|
+
* html`<${MyElement.assign({value: 1})}>...`
|
|
14
|
+
*/
|
|
5
15
|
export function assign(declarativeElementOrInputs, inputsObject) {
|
|
6
16
|
/**
|
|
7
17
|
* The directive generics (in listenDirective) are not strong enough to maintain their values.
|
|
@@ -20,10 +30,7 @@ const assignDirective = directive(class extends Directive {
|
|
|
20
30
|
this.element = extractElement(partInfo, 'assign');
|
|
21
31
|
}
|
|
22
32
|
render(elementDefinition, inputsObject) {
|
|
23
|
-
|
|
33
|
+
assignInputs(this.element, inputsObject);
|
|
24
34
|
return noChange;
|
|
25
35
|
}
|
|
26
36
|
});
|
|
27
|
-
export function assignInputsObject(expectedElementConstructor, element, assignmentObject) {
|
|
28
|
-
assignInputs(element, assignmentObject);
|
|
29
|
-
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "element-vir",
|
|
3
|
-
"version": "14.2.
|
|
3
|
+
"version": "14.2.2",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"custom",
|
|
6
6
|
"web",
|
|
@@ -39,15 +39,15 @@
|
|
|
39
39
|
"test:types": "tsc --noEmit"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@augment-vir/browser": "^15.4.
|
|
43
|
-
"@augment-vir/common": "^15.4.
|
|
44
|
-
"element-vir": "^14.1
|
|
42
|
+
"@augment-vir/browser": "^15.4.1",
|
|
43
|
+
"@augment-vir/common": "^15.4.1",
|
|
44
|
+
"element-vir": "^14.2.1",
|
|
45
45
|
"lit": "2.7.6",
|
|
46
46
|
"lit-css-vars": "^2.0.3"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@augment-vir/browser-testing": "^15.4.
|
|
50
|
-
"@augment-vir/node-js": "^15.4.
|
|
49
|
+
"@augment-vir/browser-testing": "^15.4.1",
|
|
50
|
+
"@augment-vir/node-js": "^15.4.1",
|
|
51
51
|
"@istanbuljs/nyc-config-typescript": "^1.0.2",
|
|
52
52
|
"@open-wc/testing": "^3.2.0",
|
|
53
53
|
"@types/chai": "^4.3.5",
|
|
@@ -56,11 +56,11 @@
|
|
|
56
56
|
"@web/test-runner": "^0.17.0",
|
|
57
57
|
"@web/test-runner-commands": "^0.8.0",
|
|
58
58
|
"@web/test-runner-playwright": "^0.10.1",
|
|
59
|
-
"@web/test-runner-visual-regression": "^0.8.
|
|
59
|
+
"@web/test-runner-visual-regression": "^0.8.2",
|
|
60
60
|
"ansi-colors": "^4.1.3",
|
|
61
61
|
"concurrently": "^8.2.0",
|
|
62
62
|
"cspell": "^6.31.2",
|
|
63
|
-
"esbuild": "^0.18.
|
|
63
|
+
"esbuild": "^0.18.15",
|
|
64
64
|
"istanbul-smart-text-reporter": "^1.1.2",
|
|
65
65
|
"markdown-code-example-inserter": "^0.3.1",
|
|
66
66
|
"mocha-spec-reporter-with-file-names": "^0.0.3",
|
|
@@ -77,8 +77,8 @@
|
|
|
77
77
|
"ts-node": "^10.9.1",
|
|
78
78
|
"type-fest": "^4.0.0",
|
|
79
79
|
"typescript": "~5.1.6",
|
|
80
|
-
"virmator": "^7.2.
|
|
81
|
-
"vite": "^4.4.
|
|
80
|
+
"virmator": "^7.2.5",
|
|
81
|
+
"vite": "^4.4.5",
|
|
82
82
|
"vite-tsconfig-paths": "^4.2.0"
|
|
83
83
|
},
|
|
84
84
|
"overrides": {
|