@joist/element 3.0.8-next.0 → 3.1.0
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
CHANGED
package/src/lib/element.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
export class ElementMetadata {
|
|
4
4
|
attrs: string[] = [];
|
|
5
|
-
tagName?: (val:
|
|
5
|
+
tagName?: (val: any) => string;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
export interface ElementCtx {
|
|
@@ -17,10 +17,12 @@ export function element<T extends new (...args: any[]) => HTMLElement>(
|
|
|
17
17
|
const meta = ctx.metadata.el as ElementMetadata;
|
|
18
18
|
|
|
19
19
|
ctx.addInitializer(function (this: T) {
|
|
20
|
-
|
|
20
|
+
if (meta.tagName) {
|
|
21
|
+
const val = meta.tagName(this);
|
|
21
22
|
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
if (!customElements.get(val)) {
|
|
24
|
+
customElements.define(val, this);
|
|
25
|
+
}
|
|
24
26
|
}
|
|
25
27
|
});
|
|
26
28
|
|
package/src/lib/tag-name.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
(Symbol as any).metadata ??= Symbol('Symbol.metadata');
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { ElementMetadata } from './element.js';
|
|
4
4
|
|
|
5
|
-
export function tagName
|
|
5
|
+
export function tagName<This extends typeof HTMLElement>(
|
|
6
|
+
_val: unknown,
|
|
7
|
+
ctx: ClassFieldDecoratorContext<This, string>
|
|
8
|
+
) {
|
|
6
9
|
ctx.metadata.el ??= new ElementMetadata();
|
|
7
10
|
const meta = ctx.metadata.el as ElementMetadata;
|
|
8
|
-
|
|
9
11
|
meta.tagName = ctx.access.get;
|
|
10
12
|
}
|
package/target/lib/element.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare class ElementMetadata {
|
|
2
2
|
attrs: string[];
|
|
3
|
-
tagName?: (val:
|
|
3
|
+
tagName?: (val: any) => string;
|
|
4
4
|
}
|
|
5
5
|
export interface ElementCtx {
|
|
6
6
|
el?: ElementMetadata;
|
|
@@ -197,7 +197,7 @@ export declare function element<T extends new (...args: any[]) => HTMLElement>(B
|
|
|
197
197
|
ariaValueNow: string | null;
|
|
198
198
|
ariaValueText: string | null;
|
|
199
199
|
role: string | null;
|
|
200
|
-
animate(keyframes:
|
|
200
|
+
animate(keyframes: Keyframe[] | PropertyIndexedKeyframes | null, options?: number | KeyframeAnimationOptions | undefined): Animation;
|
|
201
201
|
getAnimations(options?: GetAnimationsOptions | undefined): Animation[];
|
|
202
202
|
after(...nodes: (string | Node)[]): void;
|
|
203
203
|
before(...nodes: (string | Node)[]): void;
|
package/target/lib/element.js
CHANGED
|
@@ -7,9 +7,11 @@ export function element(Base, ctx) {
|
|
|
7
7
|
ctx.metadata.el ??= new ElementMetadata();
|
|
8
8
|
const meta = ctx.metadata.el;
|
|
9
9
|
ctx.addInitializer(function () {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
customElements.
|
|
10
|
+
if (meta.tagName) {
|
|
11
|
+
const val = meta.tagName(this);
|
|
12
|
+
if (!customElements.get(val)) {
|
|
13
|
+
customElements.define(val, this);
|
|
14
|
+
}
|
|
13
15
|
}
|
|
14
16
|
});
|
|
15
17
|
return class JoistElement extends Base {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"element.js","sourceRoot":"","sources":["../../src/lib/element.ts"],"names":[],"mappings":"AAAC,MAAc,CAAC,QAAQ,KAAK,MAAM,CAAC,iBAAiB,CAAC,CAAC;AAEvD,MAAM,OAAO,eAAe;IAC1B,KAAK,GAAa,EAAE,CAAC;IACrB,OAAO,
|
|
1
|
+
{"version":3,"file":"element.js","sourceRoot":"","sources":["../../src/lib/element.ts"],"names":[],"mappings":"AAAC,MAAc,CAAC,QAAQ,KAAK,MAAM,CAAC,iBAAiB,CAAC,CAAC;AAEvD,M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YACH,CAAC;YAED,IAAI,KAAK,CAAC,iBAAiB,EAAE,CAAC;gBAC5B,KAAK,CAAC,iBAAiB,EAAE,CAAC;YAC5B,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/target/lib/tag-name.d.ts
CHANGED
|
@@ -1,4 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function tagName(_val: unknown, ctx: ClassFieldDecoratorContext & {
|
|
3
|
-
metadata: ElementCtx;
|
|
4
|
-
}): void;
|
|
1
|
+
export declare function tagName<This extends typeof HTMLElement>(_val: unknown, ctx: ClassFieldDecoratorContext<This, string>): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tag-name.js","sourceRoot":"","sources":["../../src/lib/tag-name.ts"],"names":[],"mappings":"AAAC,MAAc,CAAC,QAAQ,KAAK,MAAM,CAAC,iBAAiB,CAAC,CAAC;AAEvD,OAAO,
|
|
1
|
+
{"version":3,"file":"tag-name.js","sourceRoot":"","sources":["../../src/lib/tag-name.ts"],"names":[],"mappings":"AAAC,MAAc,CAAC,QAAQ,KAAK,MAAM,CAAC,iBAAiB,CAAC,CAAC;AAEvD,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C,MAAM,UAAU,OAAO,CACrB,IAAa,EACb,GAA6C;IAE7C,GAAG,CAAC,QAAQ,CAAC,EAAE,KAAK,IAAI,eAAe,EAAE,CAAC;IAC1C,MAAM,IAAI,GAAG,GAAG,CAAC,QAAQ,CAAC,EAAqB,CAAC;IAChD,IAAI,CAAC,OAAO,GAAG,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC;AAChC,CAAC"}
|