@joist/element 4.2.3-next.5 → 4.2.3-next.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.
- package/package.json +2 -5
- package/src/lib/element.ts +13 -23
- package/src/lib/listen.test.ts +75 -0
- package/target/lib/element.js +12 -14
- package/target/lib/element.js.map +1 -1
- package/target/lib/listen.test.js +97 -0
- package/target/lib/listen.test.js.map +1 -1
- package/src/lib/templating/README.md +0 -406
- package/src/lib/templating/bind.ts +0 -40
- package/src/lib/templating/define.ts +0 -5
- package/src/lib/templating/elements/async.element.test.ts +0 -90
- package/src/lib/templating/elements/async.element.ts +0 -122
- package/src/lib/templating/elements/for.element.test.ts +0 -221
- package/src/lib/templating/elements/for.element.ts +0 -188
- package/src/lib/templating/elements/if.element.test.ts +0 -90
- package/src/lib/templating/elements/if.element.ts +0 -93
- package/src/lib/templating/elements/props.element.test.ts +0 -62
- package/src/lib/templating/elements/props.element.ts +0 -80
- package/src/lib/templating/elements/scope.ts +0 -45
- package/src/lib/templating/elements/value.element.test.ts +0 -20
- package/src/lib/templating/elements/value.element.ts +0 -41
- package/src/lib/templating/events.ts +0 -21
- package/src/lib/templating/token.test.ts +0 -74
- package/src/lib/templating/token.ts +0 -34
- package/src/lib/templating.ts +0 -2
- package/target/lib/templating/bind.d.ts +0 -1
- package/target/lib/templating/bind.js +0 -30
- package/target/lib/templating/bind.js.map +0 -1
- package/target/lib/templating/define.d.ts +0 -5
- package/target/lib/templating/define.js +0 -6
- package/target/lib/templating/define.js.map +0 -1
- package/target/lib/templating/elements/async.element.d.ts +0 -17
- package/target/lib/templating/elements/async.element.js +0 -115
- package/target/lib/templating/elements/async.element.js.map +0 -1
- package/target/lib/templating/elements/async.element.test.d.ts +0 -1
- package/target/lib/templating/elements/async.element.test.js +0 -75
- package/target/lib/templating/elements/async.element.test.js.map +0 -1
- package/target/lib/templating/elements/for.element.d.ts +0 -24
- package/target/lib/templating/elements/for.element.js +0 -189
- package/target/lib/templating/elements/for.element.js.map +0 -1
- package/target/lib/templating/elements/for.element.test.d.ts +0 -2
- package/target/lib/templating/elements/for.element.test.js +0 -153
- package/target/lib/templating/elements/for.element.test.js.map +0 -1
- package/target/lib/templating/elements/if.element.d.ts +0 -12
- package/target/lib/templating/elements/if.element.js +0 -85
- package/target/lib/templating/elements/if.element.js.map +0 -1
- package/target/lib/templating/elements/if.element.test.d.ts +0 -1
- package/target/lib/templating/elements/if.element.test.js +0 -78
- package/target/lib/templating/elements/if.element.test.js.map +0 -1
- package/target/lib/templating/elements/props.element.d.ts +0 -11
- package/target/lib/templating/elements/props.element.js +0 -92
- package/target/lib/templating/elements/props.element.js.map +0 -1
- package/target/lib/templating/elements/props.element.test.d.ts +0 -1
- package/target/lib/templating/elements/props.element.test.js +0 -53
- package/target/lib/templating/elements/props.element.test.js.map +0 -1
- package/target/lib/templating/elements/scope.d.ts +0 -13
- package/target/lib/templating/elements/scope.js +0 -59
- package/target/lib/templating/elements/scope.js.map +0 -1
- package/target/lib/templating/elements/value.element.d.ts +0 -9
- package/target/lib/templating/elements/value.element.js +0 -56
- package/target/lib/templating/elements/value.element.js.map +0 -1
- package/target/lib/templating/elements/value.element.test.d.ts +0 -1
- package/target/lib/templating/elements/value.element.test.js +0 -16
- package/target/lib/templating/elements/value.element.test.js.map +0 -1
- package/target/lib/templating/events.d.ts +0 -12
- package/target/lib/templating/events.js +0 -10
- package/target/lib/templating/events.js.map +0 -1
- package/target/lib/templating/token.d.ts +0 -8
- package/target/lib/templating/token.js +0 -27
- package/target/lib/templating/token.js.map +0 -1
- package/target/lib/templating/token.test.d.ts +0 -1
- package/target/lib/templating/token.test.js +0 -56
- package/target/lib/templating/token.test.js.map +0 -1
- package/target/lib/templating.d.ts +0 -2
- package/target/lib/templating.js +0 -3
- package/target/lib/templating.js.map +0 -1
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { attr } from "../../attr.js";
|
|
2
|
-
import { element } from "../../element.js";
|
|
3
|
-
import { css, html } from "../../tags.js";
|
|
4
|
-
|
|
5
|
-
import { JoistValueEvent } from "../events.js";
|
|
6
|
-
import { JToken } from "../token.js";
|
|
7
|
-
|
|
8
|
-
export class JAttrToken extends JToken {
|
|
9
|
-
mapTo: string;
|
|
10
|
-
mapsToProp: boolean;
|
|
11
|
-
|
|
12
|
-
constructor(attr: Attr) {
|
|
13
|
-
if (!attr.name.startsWith("$")) {
|
|
14
|
-
throw new Error(
|
|
15
|
-
`Invalid attribute token: ${attr.name}, should start with $`,
|
|
16
|
-
);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
super(attr.value);
|
|
20
|
-
|
|
21
|
-
this.mapsToProp = attr.name.startsWith("$.");
|
|
22
|
-
|
|
23
|
-
this.mapTo = attr.name.slice(this.mapsToProp ? 2 : 1);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
@element({
|
|
28
|
-
tagName: "j-props",
|
|
29
|
-
// prettier-ignore
|
|
30
|
-
shadowDom: [css`:host{display: contents;}`, html`<slot></slot>`],
|
|
31
|
-
})
|
|
32
|
-
export class JoistIfElement extends HTMLElement {
|
|
33
|
-
@attr()
|
|
34
|
-
accessor target = "";
|
|
35
|
-
|
|
36
|
-
connectedCallback(): void {
|
|
37
|
-
this.#bindProps([this]); // bind own props
|
|
38
|
-
this.#bindProps(this.children); // bind child props
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
#bindProps(children: Iterable<Element>) {
|
|
42
|
-
for (const child of children) {
|
|
43
|
-
for (const attr of child.attributes) {
|
|
44
|
-
if (attr.name.startsWith("$")) {
|
|
45
|
-
const token = new JAttrToken(attr);
|
|
46
|
-
|
|
47
|
-
this.dispatchEvent(
|
|
48
|
-
new JoistValueEvent(token, ({ newValue, oldValue }) => {
|
|
49
|
-
if (newValue === oldValue) {
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
let valueToWrite = newValue;
|
|
54
|
-
|
|
55
|
-
if (typeof newValue === "object" && newValue !== null) {
|
|
56
|
-
valueToWrite = token.readTokenValueFrom(newValue);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
if (token.isNegated) {
|
|
60
|
-
valueToWrite = !valueToWrite;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
if (token.mapsToProp) {
|
|
64
|
-
Reflect.set(child, token.mapTo, valueToWrite);
|
|
65
|
-
} else {
|
|
66
|
-
if (valueToWrite === true) {
|
|
67
|
-
child.setAttribute(token.mapTo, "");
|
|
68
|
-
} else if (valueToWrite === false) {
|
|
69
|
-
child.removeAttribute(token.mapTo);
|
|
70
|
-
} else {
|
|
71
|
-
child.setAttribute(token.mapTo, String(valueToWrite));
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}),
|
|
75
|
-
);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { attr } from "../../attr.js";
|
|
2
|
-
import { element } from "../../element.js";
|
|
3
|
-
import { listen } from "../../listen.js";
|
|
4
|
-
import { css, html } from "../../tags.js";
|
|
5
|
-
import type { JoistValueEvent } from "../events.js";
|
|
6
|
-
|
|
7
|
-
declare global {
|
|
8
|
-
interface HTMLElementTagNameMap {
|
|
9
|
-
"j-scope": JoistScopeElement;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
@element({
|
|
14
|
-
tagName: "j-value",
|
|
15
|
-
// prettier-ignore
|
|
16
|
-
shadowDom: [css`:host{display: contents;}`, html`<slot></slot>`],
|
|
17
|
-
})
|
|
18
|
-
export class JoistScopeElement extends HTMLElement {
|
|
19
|
-
@attr()
|
|
20
|
-
accessor name = "";
|
|
21
|
-
|
|
22
|
-
@attr()
|
|
23
|
-
accessor value = "";
|
|
24
|
-
|
|
25
|
-
#binding: JoistValueEvent | null = null;
|
|
26
|
-
|
|
27
|
-
@listen("joist::value")
|
|
28
|
-
onJoistValueFound(e: JoistValueEvent): void {
|
|
29
|
-
if (e.token.bindTo === this.name) {
|
|
30
|
-
e.stopPropagation();
|
|
31
|
-
|
|
32
|
-
this.#binding = e;
|
|
33
|
-
|
|
34
|
-
this.#binding.update({ oldValue: null, newValue: this.value });
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
attributeChangedCallback(
|
|
39
|
-
_: string,
|
|
40
|
-
oldValue: string,
|
|
41
|
-
newValue: string,
|
|
42
|
-
): void {
|
|
43
|
-
this.#binding?.update({ oldValue, newValue });
|
|
44
|
-
}
|
|
45
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import "./value.element.js";
|
|
2
|
-
|
|
3
|
-
import { fixtureSync, html } from "@open-wc/testing";
|
|
4
|
-
import { assert } from "chai";
|
|
5
|
-
|
|
6
|
-
import type { JoistValueEvent } from "../events.js";
|
|
7
|
-
|
|
8
|
-
it("should render content when the bind value is truthy", () => {
|
|
9
|
-
const element = fixtureSync(html`
|
|
10
|
-
<div
|
|
11
|
-
@joist::value=${(e: JoistValueEvent) => {
|
|
12
|
-
e.update({ oldValue: null, newValue: "Hello World" });
|
|
13
|
-
}}
|
|
14
|
-
>
|
|
15
|
-
<j-value bind="test"></j-value>
|
|
16
|
-
</div>
|
|
17
|
-
`);
|
|
18
|
-
|
|
19
|
-
assert.equal(element.textContent?.trim(), "Hello World");
|
|
20
|
-
});
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { attr } from "../../attr.js";
|
|
2
|
-
import { element } from "../../element.js";
|
|
3
|
-
import { css, html } from "../../tags.js";
|
|
4
|
-
import { JoistValueEvent } from "../events.js";
|
|
5
|
-
import { JToken } from "../token.js";
|
|
6
|
-
|
|
7
|
-
declare global {
|
|
8
|
-
interface HTMLElementTagNameMap {
|
|
9
|
-
"j-value": JoistValueElement;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
@element({
|
|
14
|
-
tagName: "j-value",
|
|
15
|
-
// prettier-ignore
|
|
16
|
-
shadowDom: [css`:host{display: contents;}`, html`<slot></slot>`],
|
|
17
|
-
})
|
|
18
|
-
export class JoistValueElement extends HTMLElement {
|
|
19
|
-
@attr()
|
|
20
|
-
accessor bind = "";
|
|
21
|
-
|
|
22
|
-
connectedCallback(): void {
|
|
23
|
-
const token = new JToken(this.bind);
|
|
24
|
-
|
|
25
|
-
this.dispatchEvent(
|
|
26
|
-
new JoistValueEvent(token, (value) => {
|
|
27
|
-
let valueToWrite: string;
|
|
28
|
-
|
|
29
|
-
if (typeof value.newValue === "object" && value.newValue !== null) {
|
|
30
|
-
valueToWrite = String(token.readTokenValueFrom(value.newValue));
|
|
31
|
-
} else {
|
|
32
|
-
valueToWrite = String(value.newValue);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
if (this.textContent !== valueToWrite) {
|
|
36
|
-
this.textContent = valueToWrite;
|
|
37
|
-
}
|
|
38
|
-
}),
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { Change } from "@joist/observable";
|
|
2
|
-
|
|
3
|
-
import type { JToken } from "./token.js";
|
|
4
|
-
|
|
5
|
-
declare global {
|
|
6
|
-
interface HTMLElementEventMap {
|
|
7
|
-
"joist::value": JoistValueEvent;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export class JoistValueEvent extends Event {
|
|
12
|
-
readonly token: JToken;
|
|
13
|
-
readonly update: (value: Change<unknown>) => void;
|
|
14
|
-
|
|
15
|
-
constructor(bindTo: JToken, update: (value: Change<unknown>) => void) {
|
|
16
|
-
super("joist::value", { bubbles: true, composed: true });
|
|
17
|
-
|
|
18
|
-
this.token = bindTo;
|
|
19
|
-
this.update = update;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { assert } from "chai";
|
|
2
|
-
|
|
3
|
-
import { JToken } from "./token.js";
|
|
4
|
-
|
|
5
|
-
describe("JToken", () => {
|
|
6
|
-
describe("constructor", () => {
|
|
7
|
-
it("should initialize with a raw token", () => {
|
|
8
|
-
const token = new JToken("example.token");
|
|
9
|
-
assert.equal(token.rawToken, "example.token");
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
it("should set isNegated to true if the token starts with '!'", () => {
|
|
13
|
-
const token = new JToken("!example.token");
|
|
14
|
-
assert.isTrue(token.isNegated);
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it("should set isNegated to false if the token does not start with '!'", () => {
|
|
18
|
-
const token = new JToken("example.token");
|
|
19
|
-
assert.isFalse(token.isNegated);
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it("should correctly parse the bindTo property", () => {
|
|
23
|
-
const token = new JToken("example.token");
|
|
24
|
-
assert.equal(token.bindTo, "example");
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it("should correctly parse the path property", () => {
|
|
28
|
-
const token = new JToken("example.token.part");
|
|
29
|
-
assert.deepEqual(token.path, ["token", "part"]);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it("should remove '!' from bindTo if present", () => {
|
|
33
|
-
const token = new JToken("!example.token");
|
|
34
|
-
assert.equal(token.bindTo, "example");
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
describe("readTokenValueFrom", () => {
|
|
39
|
-
it("should read the value from a nested object", () => {
|
|
40
|
-
const token = new JToken("example.token.part");
|
|
41
|
-
const obj = { token: { part: 42 } };
|
|
42
|
-
const value = token.readTokenValueFrom<number>(obj);
|
|
43
|
-
assert.equal(value, 42);
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it("should return undefined if the path does not exist", () => {
|
|
47
|
-
const token = new JToken("example.nonexistent.path");
|
|
48
|
-
const obj = { token: { part: 42 } };
|
|
49
|
-
const value = token.readTokenValueFrom(obj);
|
|
50
|
-
assert.isUndefined(value);
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
it("should handle empty paths gracefully", () => {
|
|
54
|
-
const token = new JToken("example");
|
|
55
|
-
const obj = { foo: 42 };
|
|
56
|
-
const value = token.readTokenValueFrom(obj);
|
|
57
|
-
|
|
58
|
-
assert.deepEqual(value, { foo: 42 });
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
it("should throw an error if the object is null or undefined", () => {
|
|
62
|
-
const token = new JToken("example.token");
|
|
63
|
-
assert.throws(
|
|
64
|
-
() => token.readTokenValueFrom<any>(null as any),
|
|
65
|
-
TypeError,
|
|
66
|
-
);
|
|
67
|
-
|
|
68
|
-
assert.throws(
|
|
69
|
-
() => token.readTokenValueFrom<any>(undefined as any),
|
|
70
|
-
TypeError,
|
|
71
|
-
);
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
});
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
export class JToken {
|
|
2
|
-
rawToken: string;
|
|
3
|
-
isNegated = false;
|
|
4
|
-
bindTo: string;
|
|
5
|
-
path: string[] = [];
|
|
6
|
-
|
|
7
|
-
constructor(rawToken: string) {
|
|
8
|
-
this.rawToken = rawToken;
|
|
9
|
-
|
|
10
|
-
this.isNegated = this.rawToken.startsWith("!");
|
|
11
|
-
|
|
12
|
-
this.path = this.rawToken.split(".");
|
|
13
|
-
this.bindTo = this.path.shift() ?? "";
|
|
14
|
-
this.bindTo = this.bindTo.replaceAll("!", "");
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
readTokenValueFrom<T = unknown>(obj: object): T {
|
|
18
|
-
let pointer: any = obj;
|
|
19
|
-
|
|
20
|
-
if (!this.path.length) {
|
|
21
|
-
return pointer;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
for (const part of this.path) {
|
|
25
|
-
pointer = pointer[part];
|
|
26
|
-
|
|
27
|
-
if (pointer === undefined) {
|
|
28
|
-
break;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return pointer;
|
|
33
|
-
}
|
|
34
|
-
}
|
package/src/lib/templating.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function bind(): <This extends HTMLElement, Value>(base: ClassAccessorDecoratorTarget<This, Value>, ctx: ClassAccessorDecoratorContext<This, Value>) => ClassAccessorDecoratorResult<This, Value>;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { instanceMetadataStore, observe } from "@joist/observable";
|
|
2
|
-
export function bind() {
|
|
3
|
-
return function bindDecorator(base, ctx) {
|
|
4
|
-
const internalObserve = observe()(base, ctx);
|
|
5
|
-
return {
|
|
6
|
-
init(value) {
|
|
7
|
-
this.addEventListener("joist::value", (e) => {
|
|
8
|
-
if (e.token.bindTo === ctx.name) {
|
|
9
|
-
const instanceMeta = instanceMetadataStore.read(this);
|
|
10
|
-
e.stopPropagation();
|
|
11
|
-
e.update({ oldValue: null, newValue: ctx.access.get(this) });
|
|
12
|
-
instanceMeta.bindings.add((changes) => {
|
|
13
|
-
const key = ctx.name;
|
|
14
|
-
const res = changes.get(key);
|
|
15
|
-
if (res) {
|
|
16
|
-
e.update(res);
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
if (internalObserve.init) {
|
|
22
|
-
return internalObserve.init.call(this, value);
|
|
23
|
-
}
|
|
24
|
-
return value;
|
|
25
|
-
},
|
|
26
|
-
set: internalObserve.set,
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
//# sourceMappingURL=bind.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bind.js","sourceRoot":"","sources":["../../../src/lib/templating/bind.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAEnE,MAAM,UAAU,IAAI;IAClB,OAAO,SAAS,aAAa,CAC3B,IAA+C,EAC/C,GAA+C;QAE/C,MAAM,eAAe,GAAG,O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ACnC,OAAO,0BAA0B,CAAC;AAClC,OAAO,6BAA6B,CAAC;AACrC,OAAO,6BAA6B,CAAC"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
declare global {
|
|
2
|
-
interface HTMLElementTagNameMap {
|
|
3
|
-
"j-async": JoistAsyncElement;
|
|
4
|
-
}
|
|
5
|
-
}
|
|
6
|
-
export type AsyncState<T = unknown, E = unknown> = {
|
|
7
|
-
status: "loading" | "error" | "success";
|
|
8
|
-
data?: T;
|
|
9
|
-
error?: E;
|
|
10
|
-
};
|
|
11
|
-
export declare class JoistAsyncElement extends HTMLElement {
|
|
12
|
-
#private;
|
|
13
|
-
accessor bind: string;
|
|
14
|
-
accessor state: AsyncState | null;
|
|
15
|
-
connectedCallback(): void;
|
|
16
|
-
disconnectedCallback(): void;
|
|
17
|
-
}
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import { __esDecorate, __runInitializers } from "tslib";
|
|
2
|
-
import { attr } from "../../attr.js";
|
|
3
|
-
import { element } from "../../element.js";
|
|
4
|
-
import { queryAll } from "../../query-all.js";
|
|
5
|
-
import { css, html } from "../../tags.js";
|
|
6
|
-
import { bind } from "../bind.js";
|
|
7
|
-
import { JoistValueEvent } from "../events.js";
|
|
8
|
-
import { JToken } from "../token.js";
|
|
9
|
-
let JoistAsyncElement = (() => {
|
|
10
|
-
let _classDecorators = [element({
|
|
11
|
-
tagName: "j-async",
|
|
12
|
-
shadowDom: [css `:host{display: contents;}`, html `<slot></slot>`],
|
|
13
|
-
})];
|
|
14
|
-
let _classDescriptor;
|
|
15
|
-
let _classExtraInitializers = [];
|
|
16
|
-
let _classThis;
|
|
17
|
-
let _classSuper = HTMLElement;
|
|
18
|
-
let _bind_decorators;
|
|
19
|
-
let _bind_initializers = [];
|
|
20
|
-
let _bind_extraInitializers = [];
|
|
21
|
-
let _state_decorators;
|
|
22
|
-
let _state_initializers = [];
|
|
23
|
-
let _state_extraInitializers = [];
|
|
24
|
-
var JoistAsyncElement = class extends _classSuper {
|
|
25
|
-
static { _classThis = this; }
|
|
26
|
-
static {
|
|
27
|
-
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
28
|
-
_bind_decorators = [attr()];
|
|
29
|
-
_state_decorators = [bind()];
|
|
30
|
-
__esDecorate(this, null, _bind_decorators, { kind: "accessor", name: "bind", static: false, private: false, access: { has: obj => "bind" in obj, get: obj => obj.bind, set: (obj, value) => { obj.bind = value; } }, metadata: _metadata }, _bind_initializers, _bind_extraInitializers);
|
|
31
|
-
__esDecorate(this, null, _state_decorators, { kind: "accessor", name: "state", static: false, private: false, access: { has: obj => "state" in obj, get: obj => obj.state, set: (obj, value) => { obj.state = value; } }, metadata: _metadata }, _state_initializers, _state_extraInitializers);
|
|
32
|
-
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
33
|
-
JoistAsyncElement = _classThis = _classDescriptor.value;
|
|
34
|
-
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
35
|
-
__runInitializers(_classThis, _classExtraInitializers);
|
|
36
|
-
}
|
|
37
|
-
#bind_accessor_storage = __runInitializers(this, _bind_initializers, "");
|
|
38
|
-
get bind() { return this.#bind_accessor_storage; }
|
|
39
|
-
set bind(value) { this.#bind_accessor_storage = value; }
|
|
40
|
-
#state_accessor_storage = (__runInitializers(this, _bind_extraInitializers), __runInitializers(this, _state_initializers, null));
|
|
41
|
-
get state() { return this.#state_accessor_storage; }
|
|
42
|
-
set state(value) { this.#state_accessor_storage = value; }
|
|
43
|
-
#templates = (__runInitializers(this, _state_extraInitializers), queryAll("template", this));
|
|
44
|
-
#currentNodes = [];
|
|
45
|
-
#cachedTemplates = {
|
|
46
|
-
loading: undefined,
|
|
47
|
-
error: undefined,
|
|
48
|
-
success: undefined,
|
|
49
|
-
};
|
|
50
|
-
connectedCallback() {
|
|
51
|
-
this.#clean();
|
|
52
|
-
const templates = Array.from(this.#templates());
|
|
53
|
-
this.#cachedTemplates = {
|
|
54
|
-
loading: templates.find((t) => t.hasAttribute("loading")),
|
|
55
|
-
error: templates.find((t) => t.hasAttribute("error")),
|
|
56
|
-
success: templates.find((t) => t.hasAttribute("success")),
|
|
57
|
-
};
|
|
58
|
-
const token = new JToken(this.bind);
|
|
59
|
-
this.dispatchEvent(new JoistValueEvent(token, ({ newValue, oldValue }) => {
|
|
60
|
-
if (newValue !== oldValue) {
|
|
61
|
-
if (newValue instanceof Promise) {
|
|
62
|
-
this.#handlePromise(newValue);
|
|
63
|
-
}
|
|
64
|
-
else {
|
|
65
|
-
console.warn("j-async bind value must be a Promise or AsyncState");
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}));
|
|
69
|
-
}
|
|
70
|
-
async #handlePromise(promise) {
|
|
71
|
-
try {
|
|
72
|
-
this.#handleState({ status: "loading" });
|
|
73
|
-
const data = await promise;
|
|
74
|
-
this.#handleState({ status: "success", data });
|
|
75
|
-
}
|
|
76
|
-
catch (error) {
|
|
77
|
-
this.#handleState({ status: "error", error });
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
#handleState(state) {
|
|
81
|
-
this.#clean();
|
|
82
|
-
let template = undefined;
|
|
83
|
-
this.state = state;
|
|
84
|
-
switch (state.status) {
|
|
85
|
-
case "loading":
|
|
86
|
-
template = this.#cachedTemplates.loading;
|
|
87
|
-
break;
|
|
88
|
-
case "error":
|
|
89
|
-
template = this.#cachedTemplates.error;
|
|
90
|
-
break;
|
|
91
|
-
case "success":
|
|
92
|
-
template = this.#cachedTemplates.success;
|
|
93
|
-
break;
|
|
94
|
-
}
|
|
95
|
-
if (template) {
|
|
96
|
-
const content = document.importNode(template.content, true);
|
|
97
|
-
const nodes = Array.from(content.childNodes);
|
|
98
|
-
this.appendChild(content);
|
|
99
|
-
this.#currentNodes = nodes;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
#clean() {
|
|
103
|
-
for (const node of this.#currentNodes) {
|
|
104
|
-
node.parentNode?.removeChild(node);
|
|
105
|
-
}
|
|
106
|
-
this.#currentNodes = [];
|
|
107
|
-
}
|
|
108
|
-
disconnectedCallback() {
|
|
109
|
-
this.#clean();
|
|
110
|
-
}
|
|
111
|
-
};
|
|
112
|
-
return JoistAsyncElement = _classThis;
|
|
113
|
-
})();
|
|
114
|
-
export { JoistAsyncElement };
|
|
115
|
-
//# sourceMappingURL=async.element.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"async.element.js","sourceRoot":"","sources":["../../../../src/lib/templating/elements/async.element.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAElC,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;IAmBxB,iBAAiB;4BAL7B,OAAO,CAAC;YACP,OAAO,EAAE,SAAS;YAElB,SAAS,EAAE,CAAC,GAAG,CAAA,2BAA2B,EAAE,IAAI,CAAA,eAAe,CAAC;SACjE,CAAC;;;;sBACqC,WAAW;;;;;;;iCAAnB,SAAQ,WAAW;;;;gCAC/C,IAAI,EAAE;iCAGN,IAAI,EAAE;YAFP,iKAAS,IAAI,6BAAJ,IAAI,mFAAM;YAGnB,oKAAS,KAAK,6BAAL,KAAK,qFAA2B;YAL3C,6KA+FC;;;YA/FY,uDAAiB;;QAE5B,qEAAgB,EAAE,EAAC;QAAnB,IAAS,IAAI,0CAAM;QAAnB,IAAS,IAA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YAC7B,CAAC;QACH,CAAC;QAED,MAAM;YACJ,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;gBACtC,IAAI,CAAC,UAAU,EAAE,WAAW,CAAC,IAAI,CAAC,CAAC;YACrC,CAAC;YACD,IAAI,CAAC,aAAa,GAAG,EAAE,CAAC;QAC1B,CAAC;QAED,oBAAoB;YAClB,IAAI,CAAC,MAAM,EAAE,CAAC;QAChB,CAAC;;;;SA9FU,iBAAiB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import "./async.element.js";
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import "./async.element.js";
|
|
2
|
-
import { fixtureSync, html } from "@open-wc/testing";
|
|
3
|
-
import { assert } from "chai";
|
|
4
|
-
it("should show loading template when promise is pending", async () => {
|
|
5
|
-
const element = fixtureSync(html `
|
|
6
|
-
<div
|
|
7
|
-
@joist::value=${(e) => {
|
|
8
|
-
e.update({ oldValue: null, newValue: new Promise(() => { }) });
|
|
9
|
-
}}
|
|
10
|
-
>
|
|
11
|
-
<j-async bind="test">
|
|
12
|
-
<template loading>Loading...</template>
|
|
13
|
-
<template success>Success!</template>
|
|
14
|
-
<template error>Error!</template>
|
|
15
|
-
</j-async>
|
|
16
|
-
</div>
|
|
17
|
-
`);
|
|
18
|
-
assert.equal(element.textContent?.trim(), "Loading...");
|
|
19
|
-
});
|
|
20
|
-
it("should show success template when promise resolves", async () => {
|
|
21
|
-
const element = fixtureSync(html `
|
|
22
|
-
<div
|
|
23
|
-
@joist::value=${(e) => {
|
|
24
|
-
e.update({ oldValue: null, newValue: Promise.resolve("data") });
|
|
25
|
-
}}
|
|
26
|
-
>
|
|
27
|
-
<j-async bind="test">
|
|
28
|
-
<template loading>Loading...</template>
|
|
29
|
-
<template success>Success!</template>
|
|
30
|
-
<template error>Error!</template>
|
|
31
|
-
</j-async>
|
|
32
|
-
</div>
|
|
33
|
-
`);
|
|
34
|
-
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
35
|
-
assert.equal(element.textContent?.trim(), "Success!");
|
|
36
|
-
});
|
|
37
|
-
it("should show error template when promise rejects", async () => {
|
|
38
|
-
const element = fixtureSync(html `
|
|
39
|
-
<div
|
|
40
|
-
@joist::value=${(e) => {
|
|
41
|
-
e.update({ oldValue: null, newValue: Promise.reject("error") });
|
|
42
|
-
}}
|
|
43
|
-
>
|
|
44
|
-
<j-async bind="test">
|
|
45
|
-
<template loading>Loading...</template>
|
|
46
|
-
<template success>Success!</template>
|
|
47
|
-
<template error>Error!</template>
|
|
48
|
-
</j-async>
|
|
49
|
-
</div>
|
|
50
|
-
`);
|
|
51
|
-
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
52
|
-
assert.equal(element.textContent?.trim(), "Error!");
|
|
53
|
-
});
|
|
54
|
-
it("should handle state transitions", async () => {
|
|
55
|
-
const element = fixtureSync(html `
|
|
56
|
-
<div
|
|
57
|
-
@joist::value=${(e) => {
|
|
58
|
-
const promise = new Promise((resolve) => {
|
|
59
|
-
setTimeout(() => resolve("data"), 100);
|
|
60
|
-
});
|
|
61
|
-
e.update({ oldValue: null, newValue: promise });
|
|
62
|
-
}}
|
|
63
|
-
>
|
|
64
|
-
<j-async bind="test">
|
|
65
|
-
<template loading>Loading...</template>
|
|
66
|
-
<template success>Success!</template>
|
|
67
|
-
<template error>Error!</template>
|
|
68
|
-
</j-async>
|
|
69
|
-
</div>
|
|
70
|
-
`);
|
|
71
|
-
assert.equal(element.textContent?.trim(), "Loading...");
|
|
72
|
-
await new Promise((resolve) => setTimeout(resolve, 150));
|
|
73
|
-
assert.equal(element.textContent?.trim(), "Success!");
|
|
74
|
-
});
|
|
75
|
-
//# sourceMappingURL=async.element.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"async.element.test.js","sourceRoot":"","sources":["../../../../src/lib/templating/elements/async.element.test.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,CAAC;AAE5B,OAAO,EAAE,WAAW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|
|
5
|
-
}
|
|
6
|
-
}
|
|
7
|
-
export interface EachCtx<T> {
|
|
8
|
-
value: T | null;
|
|
9
|
-
index: number | null;
|
|
10
|
-
position: number | null;
|
|
11
|
-
}
|
|
12
|
-
export declare class JForScope<T = unknown> extends HTMLElement {
|
|
13
|
-
accessor each: EachCtx<T>;
|
|
14
|
-
accessor key: string;
|
|
15
|
-
}
|
|
16
|
-
export declare class JositForElement extends HTMLElement {
|
|
17
|
-
#private;
|
|
18
|
-
accessor bind: string;
|
|
19
|
-
accessor key: string;
|
|
20
|
-
connectedCallback(): void;
|
|
21
|
-
createFromEmpty(): void;
|
|
22
|
-
updateItems(): void;
|
|
23
|
-
disconnectedCallback(): void;
|
|
24
|
-
}
|