@joist/templating 4.2.4-next.7 → 4.2.4-next.9
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 +1 -1
- package/src/lib/define.ts +1 -0
- package/src/lib/elements/scope.element.test.ts +32 -0
- package/src/lib/elements/scope.element.ts +19 -0
- package/target/lib/define.d.ts +1 -0
- package/target/lib/define.js +1 -0
- package/target/lib/define.js.map +1 -1
- package/target/lib/elements/scope.element.d.ts +8 -0
- package/target/lib/elements/scope.element.js +38 -0
- package/target/lib/elements/scope.element.js.map +1 -0
- package/target/lib/elements/scope.element.test.d.ts +2 -0
- package/target/lib/elements/scope.element.test.js +25 -0
- package/target/lib/elements/scope.element.test.js.map +1 -0
- package/src/lib/elements/scope.ts +0 -39
- package/target/lib/elements/scope.d.ts +0 -13
- package/target/lib/elements/scope.js +0 -56
- package/target/lib/elements/scope.js.map +0 -1
package/package.json
CHANGED
package/src/lib/define.ts
CHANGED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import "./scope.element.js";
|
|
2
|
+
import "./value.element.js";
|
|
3
|
+
|
|
4
|
+
import { fixtureSync, html } from "@open-wc/testing";
|
|
5
|
+
import { assert } from "chai";
|
|
6
|
+
import { JoistScopeElement } from "./scope.element.js";
|
|
7
|
+
|
|
8
|
+
describe("j-scope", () => {
|
|
9
|
+
it("should render its children", () => {
|
|
10
|
+
const element = fixtureSync<JoistScopeElement>(html`
|
|
11
|
+
<j-scope>
|
|
12
|
+
<div>Test Content</div>
|
|
13
|
+
</j-scope>
|
|
14
|
+
`);
|
|
15
|
+
|
|
16
|
+
assert.equal(element.textContent?.trim(), "Test Content");
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it("should set and get scope property", async () => {
|
|
20
|
+
const element = fixtureSync<JoistScopeElement>(html`
|
|
21
|
+
<j-scope>
|
|
22
|
+
<j-val bind="scope.foo"></j-val>
|
|
23
|
+
</j-scope>
|
|
24
|
+
`);
|
|
25
|
+
|
|
26
|
+
element.scope = { foo: "bar" };
|
|
27
|
+
|
|
28
|
+
await Promise.resolve();
|
|
29
|
+
|
|
30
|
+
assert.equal(element.textContent?.trim(), "bar");
|
|
31
|
+
});
|
|
32
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { element, css, html } from "@joist/element";
|
|
2
|
+
|
|
3
|
+
import { bind } from "../bind.js";
|
|
4
|
+
|
|
5
|
+
declare global {
|
|
6
|
+
interface HTMLElementTagNameMap {
|
|
7
|
+
"j-scope": JoistScopeElement;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
@element({
|
|
12
|
+
tagName: "j-scope",
|
|
13
|
+
// prettier-ignore
|
|
14
|
+
shadowDom: [css`:host{display: contents;}`, html`<slot></slot>`],
|
|
15
|
+
})
|
|
16
|
+
export class JoistScopeElement extends HTMLElement {
|
|
17
|
+
@bind()
|
|
18
|
+
accessor scope: any = null;
|
|
19
|
+
}
|
package/target/lib/define.d.ts
CHANGED
package/target/lib/define.js
CHANGED
package/target/lib/define.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"define.js","sourceRoot":"","sources":["../../src/lib/define.ts"],"names":[],"mappings":"AAAA,OAAO,6BAA6B,CAAC;AACrC,OAAO,2BAA2B,CAAC;AACnC,OAAO,0BAA0B,CAAC;AAClC,OAAO,4BAA4B,CAAC;AACpC,OAAO,6BAA6B,CAAC"}
|
|
1
|
+
{"version":3,"file":"define.js","sourceRoot":"","sources":["../../src/lib/define.ts"],"names":[],"mappings":"AAAA,OAAO,6BAA6B,CAAC;AACrC,OAAO,2BAA2B,CAAC;AACnC,OAAO,0BAA0B,CAAC;AAClC,OAAO,4BAA4B,CAAC;AACpC,OAAO,6BAA6B,CAAC;AACrC,OAAO,6BAA6B,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { __esDecorate, __runInitializers } from "tslib";
|
|
2
|
+
import { element, css, html } from "@joist/element";
|
|
3
|
+
import { bind } from "../bind.js";
|
|
4
|
+
let JoistScopeElement = (() => {
|
|
5
|
+
let _classDecorators = [element({
|
|
6
|
+
tagName: "j-scope",
|
|
7
|
+
shadowDom: [css `:host{display: contents;}`, html `<slot></slot>`],
|
|
8
|
+
})];
|
|
9
|
+
let _classDescriptor;
|
|
10
|
+
let _classExtraInitializers = [];
|
|
11
|
+
let _classThis;
|
|
12
|
+
let _classSuper = HTMLElement;
|
|
13
|
+
let _scope_decorators;
|
|
14
|
+
let _scope_initializers = [];
|
|
15
|
+
let _scope_extraInitializers = [];
|
|
16
|
+
var JoistScopeElement = class extends _classSuper {
|
|
17
|
+
static { _classThis = this; }
|
|
18
|
+
static {
|
|
19
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
20
|
+
_scope_decorators = [bind()];
|
|
21
|
+
__esDecorate(this, null, _scope_decorators, { kind: "accessor", name: "scope", static: false, private: false, access: { has: obj => "scope" in obj, get: obj => obj.scope, set: (obj, value) => { obj.scope = value; } }, metadata: _metadata }, _scope_initializers, _scope_extraInitializers);
|
|
22
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
23
|
+
JoistScopeElement = _classThis = _classDescriptor.value;
|
|
24
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
25
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
26
|
+
}
|
|
27
|
+
#scope_accessor_storage = __runInitializers(this, _scope_initializers, null);
|
|
28
|
+
get scope() { return this.#scope_accessor_storage; }
|
|
29
|
+
set scope(value) { this.#scope_accessor_storage = value; }
|
|
30
|
+
constructor() {
|
|
31
|
+
super(...arguments);
|
|
32
|
+
__runInitializers(this, _scope_extraInitializers);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
return JoistScopeElement = _classThis;
|
|
36
|
+
})();
|
|
37
|
+
export { JoistScopeElement };
|
|
38
|
+
//# sourceMappingURL=scope.element.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scope.element.js","sourceRoot":"","sources":["../../../src/lib/elements/scope.element.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAEpD,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;IAarB,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;;;;iCAC/C,IAAI,EAAE;YACP,oKAAS,KAAK,6BAAL,KAAK,qFAAa;YAF7B,6KAGC;;;YAHY,uDAAiB;;QAE5B,uEAAsB,IAAI,EAAC;QAA3B,IAAS,KAAK,2CAAa;QAA3B,IAAS,KAAK,iDAAa;;;;;;;;SAFhB,iBAAiB"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import "./scope.element.js";
|
|
2
|
+
import "./value.element.js";
|
|
3
|
+
import { fixtureSync, html } from "@open-wc/testing";
|
|
4
|
+
import { assert } from "chai";
|
|
5
|
+
describe("j-scope", () => {
|
|
6
|
+
it("should render its children", () => {
|
|
7
|
+
const element = fixtureSync(html `
|
|
8
|
+
<j-scope>
|
|
9
|
+
<div>Test Content</div>
|
|
10
|
+
</j-scope>
|
|
11
|
+
`);
|
|
12
|
+
assert.equal(element.textContent?.trim(), "Test Content");
|
|
13
|
+
});
|
|
14
|
+
it("should set and get scope property", async () => {
|
|
15
|
+
const element = fixtureSync(html `
|
|
16
|
+
<j-scope>
|
|
17
|
+
<j-val bind="scope.foo"></j-val>
|
|
18
|
+
</j-scope>
|
|
19
|
+
`);
|
|
20
|
+
element.scope = { foo: "bar" };
|
|
21
|
+
await Promise.resolve();
|
|
22
|
+
assert.equal(element.textContent?.trim(), "bar");
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
//# sourceMappingURL=scope.element.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scope.element.test.js","sourceRoot":"","sources":["../../../src/lib/elements/scope.element.test.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,CAAC;AAC5B,OAAO,oBAAoB,CAAC;AAE5B,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAG9B,QAAQ,CAAC,SAAS,EAAE,GAAG,EAAE;IACvB,EAAE,CAAC,4BAA4B,EAAE,GAAG,EAAE;QACpC,MAAM,OAAO,GAAG,WAAW,CAAoB,IAAI,CAAA;;;;KAIlD,CAAC,CAAC;QAEH,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,WAAW,EAAE,IAAI,EAAE,EAAE,cAAc,CAAC,CAAC;IAC5D,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,mCAAmC,EAAE,KAAK,IAAI,EAAE;QACjD,MAAM,OAAO,GAAG,WAAW,CAAoB,IAAI,CAAA;;;;KAIlD,CAAC,CAAC;QAEH,OAAO,CAAC,KAAK,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC;QAE/B,MAAM,OAAO,CAAC,OAAO,EAAE,CAAC;QAExB,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,WAAW,EAAE,IAAI,EAAE,EAAE,KAAK,CAAC,CAAC;IACnD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { attr, element, css, html, listen } from "@joist/element";
|
|
2
|
-
|
|
3
|
-
import type { JoistValueEvent } from "../events.js";
|
|
4
|
-
|
|
5
|
-
declare global {
|
|
6
|
-
interface HTMLElementTagNameMap {
|
|
7
|
-
"j-scope": JoistScopeElement;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
@element({
|
|
12
|
-
tagName: "j-val",
|
|
13
|
-
// prettier-ignore
|
|
14
|
-
shadowDom: [css`:host{display: contents;}`, html`<slot></slot>`],
|
|
15
|
-
})
|
|
16
|
-
export class JoistScopeElement extends HTMLElement {
|
|
17
|
-
@attr()
|
|
18
|
-
accessor name = "";
|
|
19
|
-
|
|
20
|
-
@attr()
|
|
21
|
-
accessor value = "";
|
|
22
|
-
|
|
23
|
-
#binding: JoistValueEvent | null = null;
|
|
24
|
-
|
|
25
|
-
@listen("joist::value")
|
|
26
|
-
onJoistValueFound(e: JoistValueEvent): void {
|
|
27
|
-
if (e.expression.bindTo === this.name) {
|
|
28
|
-
e.stopPropagation();
|
|
29
|
-
|
|
30
|
-
this.#binding = e;
|
|
31
|
-
|
|
32
|
-
this.#binding.update({ oldValue: null, newValue: this.value });
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
attributeChangedCallback(_: string, oldValue: string, newValue: string): void {
|
|
37
|
-
this.#binding?.update({ oldValue, newValue });
|
|
38
|
-
}
|
|
39
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { JoistValueEvent } from "../events.js";
|
|
2
|
-
declare global {
|
|
3
|
-
interface HTMLElementTagNameMap {
|
|
4
|
-
"j-scope": JoistScopeElement;
|
|
5
|
-
}
|
|
6
|
-
}
|
|
7
|
-
export declare class JoistScopeElement extends HTMLElement {
|
|
8
|
-
#private;
|
|
9
|
-
accessor name: string;
|
|
10
|
-
accessor value: string;
|
|
11
|
-
onJoistValueFound(e: JoistValueEvent): void;
|
|
12
|
-
attributeChangedCallback(_: string, oldValue: string, newValue: string): void;
|
|
13
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { __esDecorate, __runInitializers } from "tslib";
|
|
2
|
-
import { attr, element, css, html, listen } from "@joist/element";
|
|
3
|
-
let JoistScopeElement = (() => {
|
|
4
|
-
let _classDecorators = [element({
|
|
5
|
-
tagName: "j-val",
|
|
6
|
-
shadowDom: [css `:host{display: contents;}`, html `<slot></slot>`],
|
|
7
|
-
})];
|
|
8
|
-
let _classDescriptor;
|
|
9
|
-
let _classExtraInitializers = [];
|
|
10
|
-
let _classThis;
|
|
11
|
-
let _classSuper = HTMLElement;
|
|
12
|
-
let _instanceExtraInitializers = [];
|
|
13
|
-
let _name_decorators;
|
|
14
|
-
let _name_initializers = [];
|
|
15
|
-
let _name_extraInitializers = [];
|
|
16
|
-
let _value_decorators;
|
|
17
|
-
let _value_initializers = [];
|
|
18
|
-
let _value_extraInitializers = [];
|
|
19
|
-
let _onJoistValueFound_decorators;
|
|
20
|
-
var JoistScopeElement = class extends _classSuper {
|
|
21
|
-
static { _classThis = this; }
|
|
22
|
-
static {
|
|
23
|
-
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
24
|
-
_name_decorators = [attr()];
|
|
25
|
-
_value_decorators = [attr()];
|
|
26
|
-
_onJoistValueFound_decorators = [listen("joist::value")];
|
|
27
|
-
__esDecorate(this, null, _name_decorators, { kind: "accessor", name: "name", static: false, private: false, access: { has: obj => "name" in obj, get: obj => obj.name, set: (obj, value) => { obj.name = value; } }, metadata: _metadata }, _name_initializers, _name_extraInitializers);
|
|
28
|
-
__esDecorate(this, null, _value_decorators, { kind: "accessor", name: "value", static: false, private: false, access: { has: obj => "value" in obj, get: obj => obj.value, set: (obj, value) => { obj.value = value; } }, metadata: _metadata }, _value_initializers, _value_extraInitializers);
|
|
29
|
-
__esDecorate(this, null, _onJoistValueFound_decorators, { kind: "method", name: "onJoistValueFound", static: false, private: false, access: { has: obj => "onJoistValueFound" in obj, get: obj => obj.onJoistValueFound }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
30
|
-
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
31
|
-
JoistScopeElement = _classThis = _classDescriptor.value;
|
|
32
|
-
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
33
|
-
__runInitializers(_classThis, _classExtraInitializers);
|
|
34
|
-
}
|
|
35
|
-
#name_accessor_storage = (__runInitializers(this, _instanceExtraInitializers), __runInitializers(this, _name_initializers, ""));
|
|
36
|
-
get name() { return this.#name_accessor_storage; }
|
|
37
|
-
set name(value) { this.#name_accessor_storage = value; }
|
|
38
|
-
#value_accessor_storage = (__runInitializers(this, _name_extraInitializers), __runInitializers(this, _value_initializers, ""));
|
|
39
|
-
get value() { return this.#value_accessor_storage; }
|
|
40
|
-
set value(value) { this.#value_accessor_storage = value; }
|
|
41
|
-
#binding = (__runInitializers(this, _value_extraInitializers), null);
|
|
42
|
-
onJoistValueFound(e) {
|
|
43
|
-
if (e.expression.bindTo === this.name) {
|
|
44
|
-
e.stopPropagation();
|
|
45
|
-
this.#binding = e;
|
|
46
|
-
this.#binding.update({ oldValue: null, newValue: this.value });
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
attributeChangedCallback(_, oldValue, newValue) {
|
|
50
|
-
this.#binding?.update({ oldValue, newValue });
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
return JoistScopeElement = _classThis;
|
|
54
|
-
})();
|
|
55
|
-
export { JoistScopeElement };
|
|
56
|
-
//# sourceMappingURL=scope.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"scope.js","sourceRoot":"","sources":["../../../src/lib/elements/scope.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;IAerD,iBAAiB;4BAL7B,OAAO,CAAC;YACP,OAAO,EAAE,OAAO;YAEhB,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;6CAKN,MAAM,CAAC,cAAc,CAAC;YAPvB,iKAAS,IAAI,6BAAJ,IAAI,mFAAM;YAGnB,oKAAS,KAAK,6BAAL,KAAK,qFAAM;YAKpB,sMAAA,iBAAiB,6DAQhB;YAlBH,6KAuBC;;;YAvBY,uDAAiB;;QAE5B,0BAFW,mDAAiB,8CAEZ,EAAE,GAAC;QAAnB,IAAS,IAAI,0CAAM;QAAnB,IAAS,IAAI,gDAAM;QAGnB,0HAAiB,EAAE,GAAC;QAApB,IAAS,KAAK,2CAAM;QAApB,IAAS,KAAK,iDAAM;QAEpB,QAAQ,uDAA2B,IAAI,EAAC;QAGxC,iBAAiB,CAAC,CAAkB;YAClC,IAAI,CAAC,CAAC,UAAU,CAAC,MAAM,KAAK,IAAI,CAAC,IAAI,EAAE,CAAC;gBACtC,CAAC,CAAC,eAAe,EAAE,CAAC;gBAEpB,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC;gBAElB,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;YACjE,CAAC;QACH,CAAC;QAED,wBAAwB,CAAC,CAAS,EAAE,QAAgB,EAAE,QAAgB;YACpE,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC;QAChD,CAAC;;;;SAtBU,iBAAiB"}
|