element-vir 17.0.2 → 17.0.3
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/define-element-no-inputs.js +2 -3
- package/dist/declarative-element/directives/test-id.directive.d.ts +2 -2
- package/dist/declarative-element/properties/element-updater-proxy.d.ts +2 -0
- package/dist/declarative-element/properties/element-updater-proxy.js +10 -8
- package/package.json +14 -12
|
@@ -4,7 +4,6 @@ var __setFunctionName = (this && this.__setFunctionName) || function (f, name, p
|
|
|
4
4
|
};
|
|
5
5
|
import { ensureError, getObjectTypedKeys, kebabCaseToCamelCase, } from '@augment-vir/common';
|
|
6
6
|
import { defineCssVars } from 'lit-css-vars';
|
|
7
|
-
import { property } from 'lit/decorators.js';
|
|
8
7
|
import { css } from '../template-transforms/vir-css/vir-css';
|
|
9
8
|
import { DeclarativeElement, } from './declarative-element';
|
|
10
9
|
import { IgnoreInputsNotBeenSetBeforeWarningSymbol, defaultDeclarativeElementDefinitionOptions, } from './definition-options';
|
|
@@ -12,7 +11,7 @@ import { hasDeclarativeElementParent } from './has-declarative-element-parent';
|
|
|
12
11
|
import { assignInputs } from './properties/assign-inputs';
|
|
13
12
|
import { assertValidCssProperties } from './properties/css-properties';
|
|
14
13
|
import { createEventDescriptorMap } from './properties/element-events';
|
|
15
|
-
import { createElementUpdaterProxy } from './properties/element-updater-proxy';
|
|
14
|
+
import { bindReactiveProperty, createElementUpdaterProxy } from './properties/element-updater-proxy';
|
|
16
15
|
import { createHostClassNamesMap } from './properties/host-classes';
|
|
17
16
|
import { applyHostClasses, hostClassNamesToStylesInput } from './properties/styles';
|
|
18
17
|
import { createRenderParams } from './render-callback';
|
|
@@ -146,7 +145,7 @@ export function defineElementNoInputs(initInput) {
|
|
|
146
145
|
this.instanceState = createElementUpdaterProxy(this, !initInput.options?.allowPolymorphicState);
|
|
147
146
|
const stateInitStatic = initInput.stateInitStatic || {};
|
|
148
147
|
getObjectTypedKeys(stateInitStatic).forEach((stateKey) => {
|
|
149
|
-
|
|
148
|
+
bindReactiveProperty(this, stateKey);
|
|
150
149
|
this.instanceState[stateKey] = stateInitStatic[stateKey];
|
|
151
150
|
});
|
|
152
151
|
this.definition = anonymousClass;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export declare const testId: (attributeValue: string) => import("
|
|
2
|
-
new (partInfo: import("
|
|
1
|
+
export declare const testId: (attributeValue: string) => import("lit-html/directive").DirectiveResult<{
|
|
2
|
+
new (partInfo: import("lit-html/directive").PartInfo): {
|
|
3
3
|
readonly element: Element;
|
|
4
4
|
render(testId: string): symbol;
|
|
5
5
|
readonly _$isConnected: boolean;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import { DeclarativeElement } from '../declarative-element';
|
|
2
2
|
import { PropertyInitMapBase } from './element-properties';
|
|
3
|
+
/** Binds the given property key as a reactive property on the given element. */
|
|
4
|
+
export declare function bindReactiveProperty(element: HTMLElement, propertyKey: PropertyKey): void;
|
|
3
5
|
export declare function createElementUpdaterProxy<PropertyInitGeneric extends PropertyInitMapBase>(element: DeclarativeElement, verifyExists: boolean): PropertyInitGeneric;
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { property } from 'lit/decorators.js';
|
|
2
2
|
import { isElementVirStateSetup } from './element-vir-state-setup';
|
|
3
3
|
import { isObservableProperty, } from './observable-property/observable-property';
|
|
4
|
+
/** Binds the given property key as a reactive property on the given element. */
|
|
5
|
+
export function bindReactiveProperty(element, propertyKey) {
|
|
6
|
+
if (!(propertyKey in element)) {
|
|
7
|
+
property()(element, propertyKey);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
4
10
|
function assertValidPropertyName(propKey, element, elementTagName) {
|
|
5
11
|
if (typeof propKey !== 'string' && typeof propKey !== 'number' && typeof propKey !== 'symbol') {
|
|
6
12
|
throw new Error(`Property name must be a string, got type '${typeof propKey}' from: '${String(propKey)}' for '${elementTagName.toLowerCase()}'`);
|
|
@@ -21,11 +27,7 @@ export function createElementUpdaterProxy(element, verifyExists) {
|
|
|
21
27
|
assertValidPropertyName(propertyKey, element, element.tagName);
|
|
22
28
|
}
|
|
23
29
|
else {
|
|
24
|
-
|
|
25
|
-
* No need to check if it's already a property or not, as the property function already
|
|
26
|
-
* makes that check.
|
|
27
|
-
*/
|
|
28
|
-
property()(element, propertyKey);
|
|
30
|
+
bindReactiveProperty(element, propertyKey);
|
|
29
31
|
}
|
|
30
32
|
}
|
|
31
33
|
function valueGetter(target, propertyKey) {
|
|
@@ -34,7 +36,7 @@ export function createElementUpdaterProxy(element, verifyExists) {
|
|
|
34
36
|
}
|
|
35
37
|
const propsProxy = new Proxy({}, {
|
|
36
38
|
get: valueGetter,
|
|
37
|
-
set
|
|
39
|
+
set(target, propertyKey, rawNewValue) {
|
|
38
40
|
const newValue = isElementVirStateSetup(rawNewValue)
|
|
39
41
|
? rawNewValue._elementVirStateSetup()
|
|
40
42
|
: rawNewValue;
|
|
@@ -76,7 +78,7 @@ export function createElementUpdaterProxy(element, verifyExists) {
|
|
|
76
78
|
setValueOnElement(newValue);
|
|
77
79
|
return true;
|
|
78
80
|
},
|
|
79
|
-
ownKeys
|
|
81
|
+
ownKeys(target) {
|
|
80
82
|
return Reflect.ownKeys(target);
|
|
81
83
|
},
|
|
82
84
|
getOwnPropertyDescriptor(target, propertyName) {
|
|
@@ -91,7 +93,7 @@ export function createElementUpdaterProxy(element, verifyExists) {
|
|
|
91
93
|
}
|
|
92
94
|
return undefined;
|
|
93
95
|
},
|
|
94
|
-
has
|
|
96
|
+
has(target, propertyName) {
|
|
95
97
|
return Reflect.has(target, propertyName);
|
|
96
98
|
},
|
|
97
99
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "element-vir",
|
|
3
|
-
"version": "17.0.
|
|
3
|
+
"version": "17.0.3",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"custom",
|
|
6
6
|
"web",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"docs": "virmator docs",
|
|
30
30
|
"format": "virmator format",
|
|
31
31
|
"publish": "virmator publish \"npm run compile && npm run test:all\"",
|
|
32
|
-
"start": "npm install && virmator frontend",
|
|
32
|
+
"start": "npm run compile && npm install && virmator frontend",
|
|
33
33
|
"test": "virmator test-web",
|
|
34
34
|
"test:all": "concurrently -c auto --kill-others-on-fail --colors --names types,tests,spelling,format,docs \"npm run test:types\" \"npm run test:coverage\" \"npm run test:spelling\" \"npm run test:format\" \"npm run test:docs\"",
|
|
35
35
|
"test:coverage": "virmator test-web coverage",
|
|
@@ -41,8 +41,9 @@
|
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@augment-vir/common": "^22.0.0",
|
|
44
|
-
"lit": "^
|
|
45
|
-
"lit-css-vars": "^3.0.
|
|
44
|
+
"lit": "^3.1.0",
|
|
45
|
+
"lit-css-vars": "^3.0.6",
|
|
46
|
+
"lit-html": "^3.1.0",
|
|
46
47
|
"object-shape-tester": "^1.0.2",
|
|
47
48
|
"run-time-assertions": "^0.2.1"
|
|
48
49
|
},
|
|
@@ -51,8 +52,8 @@
|
|
|
51
52
|
"@augment-vir/node-js": "^22.0.0",
|
|
52
53
|
"@istanbuljs/nyc-config-typescript": "^1.0.2",
|
|
53
54
|
"@open-wc/testing": "^4.0.0",
|
|
54
|
-
"@types/chai": "^4.3.
|
|
55
|
-
"@types/mocha": "^10.0.
|
|
55
|
+
"@types/chai": "^4.3.11",
|
|
56
|
+
"@types/mocha": "^10.0.6",
|
|
56
57
|
"@web/dev-server-esbuild": "^1.0.1",
|
|
57
58
|
"@web/test-runner": "^0.18.0",
|
|
58
59
|
"@web/test-runner-commands": "^0.9.0",
|
|
@@ -62,8 +63,9 @@
|
|
|
62
63
|
"concurrently": "^8.2.2",
|
|
63
64
|
"cspell": "^8.0.0",
|
|
64
65
|
"dependency-cruiser": "^15.3.0",
|
|
65
|
-
"element-book": "^10.1.
|
|
66
|
-
"
|
|
66
|
+
"element-book": "^10.1.9",
|
|
67
|
+
"element-vir": "file:./",
|
|
68
|
+
"esbuild": "^0.19.7",
|
|
67
69
|
"istanbul-smart-text-reporter": "^1.1.3",
|
|
68
70
|
"markdown-code-example-inserter": "^0.3.3",
|
|
69
71
|
"mocha-spec-reporter-with-file-names": "^0.0.3",
|
|
@@ -78,16 +80,16 @@
|
|
|
78
80
|
"prettier-plugin-sort-json": "^3.1.0",
|
|
79
81
|
"prettier-plugin-toml": "^1.0.0",
|
|
80
82
|
"ts-node": "^10.9.1",
|
|
81
|
-
"type-fest": "^4.8.
|
|
83
|
+
"type-fest": "^4.8.2",
|
|
82
84
|
"typedoc": "^0.25.3",
|
|
83
85
|
"typescript": "~5.2.2",
|
|
86
|
+
"vira": "^2.5.4",
|
|
84
87
|
"virmator": "^11.1.3",
|
|
85
88
|
"vite": "^4.5.0",
|
|
86
89
|
"vite-tsconfig-paths": "^4.2.1"
|
|
87
90
|
},
|
|
88
91
|
"overrides": {
|
|
89
|
-
"lit": "^
|
|
90
|
-
"
|
|
91
|
-
"@open-wc/testing-helpers": "2.3.0"
|
|
92
|
+
"lit": "^3.1.0",
|
|
93
|
+
"element-vir": "*"
|
|
92
94
|
}
|
|
93
95
|
}
|