vivth 1.5.2 → 1.5.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/README.md CHANGED
@@ -198,6 +198,7 @@ npm i vivth
198
198
  - [neutral.E](#e)
199
199
  - [neutral.NewStyleSheetAsync](#newstylesheetasync)
200
200
  - [neutral.NewStyleSheetSync](#newstylesheetsync)
201
+ - [neutral.WC_DefineCustomElement](#wc_definecustomelement)
201
202
  - [neutral.WC_TagName_type](#wc_tagname_type)
202
203
  - [neutral.EnsureValidTag](#ensurevalidtag)
203
204
  - [neutral.IsInViewPortSignal](#isinviewportsignal)
@@ -6722,15 +6723,13 @@ const esWatcherInstance = this.registerObjectWithAutoCleanup(
6722
6723
  #### reference: `WC_createElement_bind`
6723
6724
 
6724
6725
  - typesafe factory generator for creating element of `WC_extendsA`/`WC_extendsB` class;
6725
- - this function is returned by static method `.define`;
6726
- > - bind it with static property;
6727
6726
  - uses `lit-html` under the hood;
6728
6727
 
6729
6728
  ```js
6730
6729
  /**
6731
6730
  * @template {(new (...args: any[]) => HTMLElement) & {
6732
6731
  * tagName: string;
6733
- * extendIs: string;
6732
+ * extendIsValue: string;
6734
6733
  * observedAttributes?: readonly string[];
6735
6734
  * namedSlots?: readonly string[];
6736
6735
  * props?: Record<string, keyof TypeMap|(new (...args:any[])=>any)>;
@@ -6758,9 +6757,7 @@ const esWatcherInstance = this.registerObjectWithAutoCleanup(
6758
6757
  - <i>example</i>:
6759
6758
 
6760
6759
  ```js
6761
- // webcomponent context via `WC_extends`
6762
- static createElement = this.define(...args);
6763
- //
6760
+
6764
6761
  ```
6765
6762
 
6766
6763
  \*) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
@@ -7103,6 +7100,43 @@ text.nodeValue = "hello world";
7103
7100
 
7104
7101
  ---
7105
7102
 
7103
+ <h2 id="wc_definecustomelement">neutral.WC_DefineCustomElement</h2>
7104
+
7105
+ #### reference: `WC_DefineCustomElement`
7106
+
7107
+ - helper funtion for wecomponent instantiator;
7108
+ - it uses WC_createElement_bind, which uses `lit-html`;
7109
+ - alternatively, if you want to create a baseline component that are not to be , you can just
7110
+
7111
+ ```js
7112
+ /**
7113
+ * @template {new (...args: any[]) => HTMLElement} BASE_CONSTRUCTOR
7114
+ * @template {{
7115
+ * class?:string;
7116
+ * style?:string;
7117
+ * observedAttributes?: readonly string[];
7118
+ * namedSlots?: readonly string[];
7119
+ * props?: Record<string, keyof TypeMap|(new (...args:any[])=>any)>;
7120
+ * }} STANDARD
7121
+ * @template {(BASE_CONSTRUCTOR) & {
7122
+ * tagName: string;
7123
+ * extendIsValue: string;
7124
+ * observedAttributes?: STANDARD["observedAttributes"];
7125
+ * namedSlots?: STANDARD["namedSlots"];
7126
+ * props?: STANDARD["props"];
7127
+ * }} CREATEARGS
7128
+ * @template {string} TAG
7129
+ * @param {WC_TagName_type<TAG>} tagName
7130
+ * @param {CREATEARGS} classRef
7131
+ * @param {ElementDefinitionOptions} elementDefinitionOptions
7132
+ * @returns {ReturnType<typeof WC_createElement_bind<CREATEARGS>>}
7133
+ */
7134
+ ```
7135
+
7136
+ \*) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
7137
+
7138
+ ---
7139
+
7106
7140
  <h2 id="wc_tagname_type">neutral.WC_TagName_type</h2>
7107
7141
 
7108
7142
  - jsdoc types:
@@ -7379,7 +7413,7 @@ text.nodeValue = "hello world";
7379
7413
  * }} STANDARD
7380
7414
  * @template {(BASE_CONSTRUCTOR) & {
7381
7415
  * tagName: string;
7382
- * extendIs: string;
7416
+ * extendIsValue: string;
7383
7417
  * observedAttributes?: STANDARD["observedAttributes"];
7384
7418
  * namedSlots?: STANDARD["namedSlots"];
7385
7419
  * props?: STANDARD["props"];
@@ -7418,7 +7452,7 @@ text.nodeValue = "hello world";
7418
7452
  * })=>OBJ;
7419
7453
  * }) & {
7420
7454
  * tagName:string;
7421
- * extendIs:string;
7455
+ * extendIsValue:string;
7422
7456
  * namedSlots: STANDARD["namedSlots"];
7423
7457
  * observedAttributes: STANDARD["observedAttributes"];
7424
7458
  * createNamedSlot: typeof WC_createNamedSlot<STANDARD>;
@@ -7441,7 +7475,9 @@ text.nodeValue = "hello world";
7441
7475
 
7442
7476
  ```js
7443
7477
  export MyWebComponent extends WC_extendsA(HTMLElement, {...options}){
7444
- static create = this.define('my-webcomponent');
7478
+ static create = WC_DefineCustomElement('my-webcomponent', this);
7479
+ // you can skip the defining with WC_DefineCustomElement if the class are meant to be extended abstract;
7480
+ // or if you want to opt out from using `lit-html` template;
7445
7481
  }
7446
7482
  ```
7447
7483
 
@@ -7564,7 +7600,7 @@ text.nodeValue = "hello world";
7564
7600
  * }} STANDARD
7565
7601
  * @template {(BASE_CONSTRUCTOR) & {
7566
7602
  * tagName: string;
7567
- * extendIs: string;
7603
+ * extendIsValue: string;
7568
7604
  * observedAttributes?: STANDARD["observedAttributes"];
7569
7605
  * namedSlots?: STANDARD["namedSlots"];
7570
7606
  * props?: STANDARD["props"];
@@ -7605,7 +7641,7 @@ text.nodeValue = "hello world";
7605
7641
  * })=>OBJ;
7606
7642
  * }) & {
7607
7643
  * tagName:string;
7608
- * extendIs:string;
7644
+ * extendIsValue:string;
7609
7645
  * namedSlots: STANDARD["namedSlots"];
7610
7646
  * observedAttributes: STANDARD["observedAttributes"];
7611
7647
  * createNamedSlot: typeof WC_createNamedSlot<STANDARD>;
@@ -7624,6 +7660,16 @@ text.nodeValue = "hello world";
7624
7660
  */
7625
7661
  ```
7626
7662
 
7663
+ - <i>example</i>:
7664
+
7665
+ ```js
7666
+ export MyWebComponent extends WC_extendsA(HTMLElement, {...options}){
7667
+ static create = WC_DefineCustomElement('my-webcomponent', this);
7668
+ // you can skip the defining if the class are meant to be extended abstract;
7669
+ // or if you want to opt out from using `lit-html` template;
7670
+ }
7671
+ ```
7672
+
7627
7673
  #### reference: `WC_extendsB_instance.props`
7628
7674
 
7629
7675
  - props objects from define -> createElement;
@@ -105,6 +105,7 @@ export { CSS } from "../../../src/web/common/CSS.mjs";
105
105
  export { E } from "../../../src/web/common/E.mjs";
106
106
  export { NewStyleSheetAsync } from "../../../src/web/common/NewStyleSheetAsync.mjs";
107
107
  export { NewStyleSheetSync } from "../../../src/web/common/NewStyleSheetSync.mjs";
108
+ export { WC_DefineCustomElement } from "../../../src/web/common/WC_DefineCustomElement.mjs";
108
109
  export { IsInViewPortSignal } from "../../../src/web/signals/IsInViewPortSignal.mjs";
109
110
  export { ObserverSignal } from "../../../src/web/signals/ObserverSignal.mjs";
110
111
  export { WC_litRef } from "../../../src/web/signals/WC_litRef.mjs";
@@ -67,6 +67,7 @@ export { CSS } from "../../../src/web/common/CSS.mjs";
67
67
  export { E } from "../../../src/web/common/E.mjs";
68
68
  export { NewStyleSheetAsync } from "../../../src/web/common/NewStyleSheetAsync.mjs";
69
69
  export { NewStyleSheetSync } from "../../../src/web/common/NewStyleSheetSync.mjs";
70
+ export { WC_DefineCustomElement } from "../../../src/web/common/WC_DefineCustomElement.mjs";
70
71
  export { IsInViewPortSignal } from "../../../src/web/signals/IsInViewPortSignal.mjs";
71
72
  export { ObserverSignal } from "../../../src/web/signals/ObserverSignal.mjs";
72
73
  export { WC_litRef } from "../../../src/web/signals/WC_litRef.mjs";
@@ -29,7 +29,7 @@
29
29
  * }} STANDARD
30
30
  * @template {(BASE_CONSTRUCTOR) & {
31
31
  * tagName: string;
32
- * extendIs: string;
32
+ * extendIsValue: string;
33
33
  * observedAttributes?: STANDARD["observedAttributes"];
34
34
  * namedSlots?: STANDARD["namedSlots"];
35
35
  * props?: STANDARD["props"];
@@ -68,7 +68,7 @@
68
68
  * })=>OBJ;
69
69
  * }) & {
70
70
  * tagName:string;
71
- * extendIs:string;
71
+ * extendIsValue:string;
72
72
  * namedSlots: STANDARD["namedSlots"];
73
73
  * observedAttributes: STANDARD["observedAttributes"];
74
74
  * createNamedSlot: typeof WC_createNamedSlot<STANDARD>;
@@ -86,7 +86,9 @@
86
86
  * @returns {RET}
87
87
  * @example
88
88
  * export MyWebComponent extends WC_extendsA(HTMLElement, {...options}){
89
- * static create = this.define('my-webcomponent');
89
+ * static create = WC_DefineCustomElement('my-webcomponent', this);
90
+ * // you can skip the defining with WC_DefineCustomElement if the class are meant to be extended abstract;
91
+ * // or if you want to opt out from using `lit-html` template;
90
92
  * }
91
93
  */
92
94
  export function WC_extendsA<BASE_CONSTRUCTOR extends new (...args: any[]) => HTMLElement, STANDARD extends {
@@ -97,7 +99,7 @@ export function WC_extendsA<BASE_CONSTRUCTOR extends new (...args: any[]) => HTM
97
99
  props?: Record<string, keyof TypeMap | (new (...args: any[]) => any)>;
98
100
  }, CREATEARGS extends (BASE_CONSTRUCTOR) & {
99
101
  tagName: string;
100
- extendIs: string;
102
+ extendIsValue: string;
101
103
  observedAttributes?: STANDARD["observedAttributes"];
102
104
  namedSlots?: STANDARD["namedSlots"];
103
105
  props?: STANDARD["props"];
@@ -121,7 +123,7 @@ export function WC_extendsA<BASE_CONSTRUCTOR extends new (...args: any[]) => HTM
121
123
  }) => OBJ;
122
124
  }) & {
123
125
  tagName: string;
124
- extendIs: string;
126
+ extendIsValue: string;
125
127
  namedSlots: STANDARD["namedSlots"];
126
128
  observedAttributes: STANDARD["observedAttributes"];
127
129
  createNamedSlot: typeof WC_createNamedSlot<STANDARD>;
@@ -29,7 +29,7 @@
29
29
  * }} STANDARD
30
30
  * @template {(BASE_CONSTRUCTOR) & {
31
31
  * tagName: string;
32
- * extendIs: string;
32
+ * extendIsValue: string;
33
33
  * observedAttributes?: STANDARD["observedAttributes"];
34
34
  * namedSlots?: STANDARD["namedSlots"];
35
35
  * props?: STANDARD["props"];
@@ -70,7 +70,7 @@
70
70
  * })=>OBJ;
71
71
  * }) & {
72
72
  * tagName:string;
73
- * extendIs:string;
73
+ * extendIsValue:string;
74
74
  * namedSlots: STANDARD["namedSlots"];
75
75
  * observedAttributes: STANDARD["observedAttributes"];
76
76
  * createNamedSlot: typeof WC_createNamedSlot<STANDARD>;
@@ -86,6 +86,12 @@
86
86
  * @param {BASE_CONSTRUCTOR} Base
87
87
  * @param {STANDARD} [staticMember]
88
88
  * @returns {RET}
89
+ * @example
90
+ * export MyWebComponent extends WC_extendsA(HTMLElement, {...options}){
91
+ * static create = WC_DefineCustomElement('my-webcomponent', this);
92
+ * // you can skip the defining if the class are meant to be extended abstract;
93
+ * // or if you want to opt out from using `lit-html` template;
94
+ * }
89
95
  */
90
96
  export function WC_extendsB<BASE_CONSTRUCTOR extends new (...args: any[]) => HTMLElement, STANDARD extends {
91
97
  class?: string;
@@ -95,7 +101,7 @@ export function WC_extendsB<BASE_CONSTRUCTOR extends new (...args: any[]) => HTM
95
101
  props?: Record<string, keyof TypeMap | (new (...args: any[]) => any)>;
96
102
  }, CREATEARGS extends (BASE_CONSTRUCTOR) & {
97
103
  tagName: string;
98
- extendIs: string;
104
+ extendIsValue: string;
99
105
  observedAttributes?: STANDARD["observedAttributes"];
100
106
  namedSlots?: STANDARD["namedSlots"];
101
107
  props?: STANDARD["props"];
@@ -121,7 +127,7 @@ export function WC_extendsB<BASE_CONSTRUCTOR extends new (...args: any[]) => HTM
121
127
  }) => OBJ;
122
128
  }) & {
123
129
  tagName: string;
124
- extendIs: string;
130
+ extendIsValue: string;
125
131
  namedSlots: STANDARD["namedSlots"];
126
132
  observedAttributes: STANDARD["observedAttributes"];
127
133
  createNamedSlot: typeof WC_createNamedSlot<STANDARD>;
@@ -1,12 +1,10 @@
1
1
  /**
2
2
  * @description
3
3
  * - typesafe factory generator for creating element of `WC_extendsA`/`WC_extendsB` class;
4
- * - this function is returned by static method `.define`;
5
- * >- bind it with static property;
6
4
  * - uses `lit-html` under the hood;
7
5
  * @template {(new (...args: any[]) => HTMLElement) & {
8
6
  * tagName: string;
9
- * extendIs: string;
7
+ * extendIsValue: string;
10
8
  * observedAttributes?: readonly string[];
11
9
  * namedSlots?: readonly string[];
12
10
  * props?: Record<string, keyof TypeMap|(new (...args:any[])=>any)>;
@@ -29,17 +27,14 @@
29
27
  * },
30
28
  * )=>InstanceType<BASE_CONSTRUCTOR>}
31
29
  * @example
32
- * // webcomponent context via `WC_extends`
33
- * static createElement = this.define(...args);
34
- * //
35
30
  */
36
31
  export function WC_createElement_bind<BASE_CONSTRUCTOR extends (new (...args: any[]) => HTMLElement) & {
37
32
  tagName: string;
38
- extendIs: string;
33
+ extendIsValue: string;
39
34
  observedAttributes?: readonly string[];
40
35
  namedSlots?: readonly string[];
41
36
  props?: Record<string, keyof TypeMap | (new (...args: any[]) => any)>;
42
- }>({ tagName, extendIs, namedSlots }: BASE_CONSTRUCTOR): (param?: {
37
+ }>({ tagName, extendIsValue, namedSlots }: BASE_CONSTRUCTOR): (param?: {
43
38
  attrs?: BASE_CONSTRUCTOR["observedAttributes"] extends readonly string[] ? Partial<Record<ArrayToKeys<BASE_CONSTRUCTOR["observedAttributes"]>, string>> : undefined;
44
39
  props?: { [K in keyof NonNullable<BASE_CONSTRUCTOR["props"]>]: NonNullable<BASE_CONSTRUCTOR["props"]>[K] extends keyof TypeMap ? TypeMap[NonNullable<BASE_CONSTRUCTOR["props"]>[K]] : InstanceType<NonNullable<BASE_CONSTRUCTOR["props"]>[K]>; };
45
40
  children?: (slotName: Record<ArrayToKeys<BASE_CONSTRUCTOR["namedSlots"]>, string>) => TemplateResult;
@@ -0,0 +1,48 @@
1
+ /**
2
+ * @import {WC_TagName_type} from '../common/WC_TagName_type.mjs'
3
+ */
4
+ /**
5
+ * @typedef {typeof import('../../function/IsTypeOf.mjs').TypeMap} TypeMap
6
+ */
7
+ /**
8
+ * @description
9
+ * - helper funtion for wecomponent instantiator;
10
+ * - it uses WC_createElement_bind, which uses `lit-html`;
11
+ * - alternatively, if you want to create a baseline component that are not to be , you can just
12
+ * @template {new (...args: any[]) => HTMLElement} BASE_CONSTRUCTOR
13
+ * @template {{
14
+ * class?:string;
15
+ * style?:string;
16
+ * observedAttributes?: readonly string[];
17
+ * namedSlots?: readonly string[];
18
+ * props?: Record<string, keyof TypeMap|(new (...args:any[])=>any)>;
19
+ * }} STANDARD
20
+ * @template {(BASE_CONSTRUCTOR) & {
21
+ * tagName: string;
22
+ * extendIsValue: string;
23
+ * observedAttributes?: STANDARD["observedAttributes"];
24
+ * namedSlots?: STANDARD["namedSlots"];
25
+ * props?: STANDARD["props"];
26
+ * }} CREATEARGS
27
+ * @template {string} TAG
28
+ * @param {WC_TagName_type<TAG>} tagName
29
+ * @param {CREATEARGS} classRef
30
+ * @param {ElementDefinitionOptions} elementDefinitionOptions
31
+ * @returns {ReturnType<typeof WC_createElement_bind<CREATEARGS>>}
32
+ */
33
+ export function WC_DefineCustomElement<BASE_CONSTRUCTOR extends new (...args: any[]) => HTMLElement, STANDARD extends {
34
+ class?: string;
35
+ style?: string;
36
+ observedAttributes?: readonly string[];
37
+ namedSlots?: readonly string[];
38
+ props?: Record<string, keyof TypeMap | (new (...args: any[]) => any)>;
39
+ }, CREATEARGS extends (BASE_CONSTRUCTOR) & {
40
+ tagName: string;
41
+ extendIsValue: string;
42
+ observedAttributes?: STANDARD["observedAttributes"];
43
+ namedSlots?: STANDARD["namedSlots"];
44
+ props?: STANDARD["props"];
45
+ }, TAG extends string>(tagName: WC_TagName_type<TAG>, classRef: CREATEARGS, elementDefinitionOptions: ElementDefinitionOptions): ReturnType<typeof WC_createElement_bind<CREATEARGS>>;
46
+ export type TypeMap = typeof import("../../function/IsTypeOf.mjs").TypeMap;
47
+ import type { WC_TagName_type } from '../common/WC_TagName_type.mjs';
48
+ import { WC_createElement_bind } from '../bindings/WC_createElement_bind.mjs';
@@ -215,6 +215,7 @@ export { CSS } from '../../../src/web/common/CSS.mjs';
215
215
  export { E } from '../../../src/web/common/E.mjs';
216
216
  export { NewStyleSheetAsync } from '../../../src/web/common/NewStyleSheetAsync.mjs';
217
217
  export { NewStyleSheetSync } from '../../../src/web/common/NewStyleSheetSync.mjs';
218
+ export { WC_DefineCustomElement } from '../../../src/web/common/WC_DefineCustomElement.mjs';
218
219
  /**
219
220
  * @template {string} TAG
220
221
  * @typedef {import('../../../src/web/common/WC_TagName_type.mjs').WC_TagName_type<TAG>} WC_TagName_type
@@ -177,6 +177,7 @@ export { CSS } from '../../../src/web/common/CSS.mjs';
177
177
  export { E } from '../../../src/web/common/E.mjs';
178
178
  export { NewStyleSheetAsync } from '../../../src/web/common/NewStyleSheetAsync.mjs';
179
179
  export { NewStyleSheetSync } from '../../../src/web/common/NewStyleSheetSync.mjs';
180
+ export { WC_DefineCustomElement } from '../../../src/web/common/WC_DefineCustomElement.mjs';
180
181
  /**
181
182
  * @template {string} TAG
182
183
  * @typedef {import('../../../src/web/common/WC_TagName_type.mjs').WC_TagName_type<TAG>} WC_TagName_type
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vivth",
3
- "version": "1.5.2",
3
+ "version": "1.5.3",
4
4
  "description": "library primitives",
5
5
  "devDependencies": {
6
6
  "@types/bun": "^1.3.3",
@@ -39,7 +39,7 @@ import { WC_createNamedSlot } from './bindings/WC_createNamedSlot.mjs';
39
39
  * }} STANDARD
40
40
  * @template {(BASE_CONSTRUCTOR) & {
41
41
  * tagName: string;
42
- * extendIs: string;
42
+ * extendIsValue: string;
43
43
  * observedAttributes?: STANDARD["observedAttributes"];
44
44
  * namedSlots?: STANDARD["namedSlots"];
45
45
  * props?: STANDARD["props"];
@@ -78,7 +78,7 @@ import { WC_createNamedSlot } from './bindings/WC_createNamedSlot.mjs';
78
78
  * })=>OBJ;
79
79
  * }) & {
80
80
  * tagName:string;
81
- * extendIs:string;
81
+ * extendIsValue:string;
82
82
  * namedSlots: STANDARD["namedSlots"];
83
83
  * observedAttributes: STANDARD["observedAttributes"];
84
84
  * createNamedSlot: typeof WC_createNamedSlot<STANDARD>;
@@ -96,7 +96,9 @@ import { WC_createNamedSlot } from './bindings/WC_createNamedSlot.mjs';
96
96
  * @returns {RET}
97
97
  * @example
98
98
  * export MyWebComponent extends WC_extendsA(HTMLElement, {...options}){
99
- * static create = this.define('my-webcomponent');
99
+ * static create = WC_DefineCustomElement('my-webcomponent', this);
100
+ * // you can skip the defining with WC_DefineCustomElement if the class are meant to be extended abstract;
101
+ * // or if you want to opt out from using `lit-html` template;
100
102
  * }
101
103
  */
102
104
  export function WC_extendsA(Base, staticMember = /** @type {any} */ ({})) {
@@ -38,7 +38,7 @@ import { WC_createNamedSlot } from './bindings/WC_createNamedSlot.mjs';
38
38
  * }} STANDARD
39
39
  * @template {(BASE_CONSTRUCTOR) & {
40
40
  * tagName: string;
41
- * extendIs: string;
41
+ * extendIsValue: string;
42
42
  * observedAttributes?: STANDARD["observedAttributes"];
43
43
  * namedSlots?: STANDARD["namedSlots"];
44
44
  * props?: STANDARD["props"];
@@ -79,7 +79,7 @@ import { WC_createNamedSlot } from './bindings/WC_createNamedSlot.mjs';
79
79
  * })=>OBJ;
80
80
  * }) & {
81
81
  * tagName:string;
82
- * extendIs:string;
82
+ * extendIsValue:string;
83
83
  * namedSlots: STANDARD["namedSlots"];
84
84
  * observedAttributes: STANDARD["observedAttributes"];
85
85
  * createNamedSlot: typeof WC_createNamedSlot<STANDARD>;
@@ -95,6 +95,12 @@ import { WC_createNamedSlot } from './bindings/WC_createNamedSlot.mjs';
95
95
  * @param {BASE_CONSTRUCTOR} Base
96
96
  * @param {STANDARD} [staticMember]
97
97
  * @returns {RET}
98
+ * @example
99
+ * export MyWebComponent extends WC_extendsA(HTMLElement, {...options}){
100
+ * static create = WC_DefineCustomElement('my-webcomponent', this);
101
+ * // you can skip the defining if the class are meant to be extended abstract;
102
+ * // or if you want to opt out from using `lit-html` template;
103
+ * }
98
104
  */
99
105
  export function WC_extendsB(Base, staticMember = /** @type {any} */ ({})) {
100
106
  const { class: class_ = '', style = '', observedAttributes = [], namedSlots = [] } = staticMember;
@@ -30,12 +30,10 @@ const getChildrenData = (namedSlots, childrenDataArgsPlaceholder) => {
30
30
  /**
31
31
  * @description
32
32
  * - typesafe factory generator for creating element of `WC_extendsA`/`WC_extendsB` class;
33
- * - this function is returned by static method `.define`;
34
- * >- bind it with static property;
35
33
  * - uses `lit-html` under the hood;
36
34
  * @template {(new (...args: any[]) => HTMLElement) & {
37
35
  * tagName: string;
38
- * extendIs: string;
36
+ * extendIsValue: string;
39
37
  * observedAttributes?: readonly string[];
40
38
  * namedSlots?: readonly string[];
41
39
  * props?: Record<string, keyof TypeMap|(new (...args:any[])=>any)>;
@@ -58,11 +56,8 @@ const getChildrenData = (namedSlots, childrenDataArgsPlaceholder) => {
58
56
  * },
59
57
  * )=>InstanceType<BASE_CONSTRUCTOR>}
60
58
  * @example
61
- * // webcomponent context via `WC_extends`
62
- * static createElement = this.define(...args);
63
- * //
64
59
  */
65
- export function WC_createElement_bind({ tagName, extendIs, namedSlots = [] }) {
60
+ export function WC_createElement_bind({ tagName, extendIsValue, namedSlots = [] }) {
66
61
  /**
67
62
  * @type {Record<string, string>|undefined}
68
63
  */
@@ -72,13 +67,13 @@ export function WC_createElement_bind({ tagName, extendIs, namedSlots = [] }) {
72
67
  * @type {InstanceType<BASE_CONSTRUCTOR>}
73
68
  */
74
69
  let element;
75
- if (!extendIs) {
70
+ if (!extendIsValue) {
76
71
  // @ts-expect-error
77
72
  element = document.createElement(tagName);
78
73
  } else {
79
74
  // @ts-expect-error
80
75
  element = document.createElement(tagName, {
81
- is: extendIs,
76
+ is: extendIsValue,
82
77
  });
83
78
  }
84
79
  if (attrs) {
@@ -0,0 +1,46 @@
1
+ // @ts-check
2
+
3
+ import { WC_createElement_bind } from '../bindings/WC_createElement_bind.mjs';
4
+
5
+ /**
6
+ * @import {WC_TagName_type} from '../common/WC_TagName_type.mjs'
7
+ */
8
+ /**
9
+ * @typedef {typeof import('../../function/IsTypeOf.mjs').TypeMap} TypeMap
10
+ */
11
+ /**
12
+ * @description
13
+ * - helper funtion for wecomponent instantiator;
14
+ * - it uses WC_createElement_bind, which uses `lit-html`;
15
+ * - alternatively, if you want to create a baseline component that are not to be , you can just
16
+ * @template {new (...args: any[]) => HTMLElement} BASE_CONSTRUCTOR
17
+ * @template {{
18
+ * class?:string;
19
+ * style?:string;
20
+ * observedAttributes?: readonly string[];
21
+ * namedSlots?: readonly string[];
22
+ * props?: Record<string, keyof TypeMap|(new (...args:any[])=>any)>;
23
+ * }} STANDARD
24
+ * @template {(BASE_CONSTRUCTOR) & {
25
+ * tagName: string;
26
+ * extendIsValue: string;
27
+ * observedAttributes?: STANDARD["observedAttributes"];
28
+ * namedSlots?: STANDARD["namedSlots"];
29
+ * props?: STANDARD["props"];
30
+ * }} CREATEARGS
31
+ * @template {string} TAG
32
+ * @param {WC_TagName_type<TAG>} tagName
33
+ * @param {CREATEARGS} classRef
34
+ * @param {ElementDefinitionOptions} elementDefinitionOptions
35
+ * @returns {ReturnType<typeof WC_createElement_bind<CREATEARGS>>}
36
+ */
37
+ export function WC_DefineCustomElement(tagName, classRef, elementDefinitionOptions) {
38
+ if (elementDefinitionOptions && elementDefinitionOptions.extends) {
39
+ classRef.tagName = elementDefinitionOptions.extends;
40
+ classRef.extendIsValue = tagName;
41
+ } else {
42
+ classRef.tagName = tagName;
43
+ }
44
+ customElements.define(tagName, classRef, elementDefinitionOptions);
45
+ return WC_createElement_bind(classRef);
46
+ }