yandel 1.2.0 → 1.2.2
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/index.d.ts +2 -1
- package/dist/index.js +9 -1
- package/dist/node.d.ts +5 -55
- package/dist/node.js +44 -12
- package/dist/tags.d.ts +1 -1
- package/dist/tags.js +1 -1
- package/package.json +3 -2
- package/types/index.d.ts +225 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference path="../types/index.d.ts" preserve="true" />
|
|
2
|
+
export { Component, createContext, createRoot, EffectHandler, Portal, Stores, ValidNode, ValidNodeChild, ValidTemplateReturn, FutureNode, } from "./node";
|
|
2
3
|
export * from "./tags";
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference path="../types/index.d.ts" preserve="true"/>
|
|
2
|
+
export { Component, createContext, createRoot,
|
|
3
|
+
// Element,
|
|
4
|
+
// ElementRef,
|
|
5
|
+
// HTMLProps,
|
|
6
|
+
// HTMLTags,
|
|
7
|
+
Portal,
|
|
8
|
+
// StateHandler,
|
|
9
|
+
Stores, } from "./node";
|
|
2
10
|
export * from "./tags";
|
package/dist/node.d.ts
CHANGED
|
@@ -1,62 +1,12 @@
|
|
|
1
|
-
type HTMLExcludedProperties = `aria${string}` | "tagName" | "shadowRoot" | "slot" | "classList" | "style" | "attributes" | "attributeStyleMap" | "ATTRIBUTE_NODE" | "CDATA_SECTION_NODE" | "COMMENT_NODE" | "childElementCount" | "childNodes" | "children" | "isConnected" | "ownerDocument" | "lastChild" | "lastElement" | "nextElementSibling" | "nextSibling" | "previousElementSibling" | "previousSibling" | "parentElement" | "parent" | "outerContent" | "firstChild" | "firstElementChild" | "lastChild" | "lastElementChild" | "innerHTML" | "outerHTML" | "innerContent" | "textContent" | `DOCUMENT_${string}` | "NOTATION_NODE" | "PROCESSING_INSTRUCTION_NODE" | "CONTENT_NODE" | "ELEMENT_NODE" | "TEXT_NODE" | `ENTITY_${string}`;
|
|
2
|
-
type AriaWidgetProperties = "aria-autocomplete" | "aria-checked" | "aria-disabled" | "aria-errormessage" | "aria-expanded" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-label" | "aria-level" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-placeholder" | "aria-pressed" | "aria-readonly" | "aria-required" | "aria-selected" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext";
|
|
3
|
-
type AriaLiveRegionProperties = "aria-busy" | "aria-live" | "aria-relevant" | "aria-atomic";
|
|
4
|
-
type AriaDragAndDropProperties = "aria-dropeffect" | "aria-grabbed";
|
|
5
|
-
type AriaRelatonshipProperties = "aria-activedescendant" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-describedby" | "aria-description" | "aria-details" | "aria-errormessage" | "aria-flowto" | "aria-labelledby" | "aria-owns" | "aria-posinset" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-setsize";
|
|
6
|
-
type AriaGlobalProperties = "aria-atomic" | "aria-busy" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-description" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-live" | "aria-owns" | "aria-relevant" | "aria-roledescription";
|
|
7
|
-
type AriaProps = AriaWidgetProperties | AriaDragAndDropProperties | AriaLiveRegionProperties | AriaRelatonshipProperties | AriaGlobalProperties;
|
|
8
|
-
type AriaBoolean = "true" | "false";
|
|
9
|
-
type AriaValue = Exclude<string, AriaBoolean>;
|
|
10
|
-
type AriaValueMap = Partial<Record<AriaProps, AriaBoolean | AriaValue>>;
|
|
11
|
-
type KeyedObject = Record<string | symbol | number, any>;
|
|
12
|
-
type HTMLTags = keyof HTMLElementTagNameMap;
|
|
13
|
-
type HTMLSVGTags = keyof SVGElementTagNameMap;
|
|
14
|
-
type Element<K extends HTMLTags = HTMLTags> = HTMLElementTagNameMap[K];
|
|
15
|
-
type SVGElement<K extends HTMLSVGTags = HTMLSVGTags> = SVGElementTagNameMap[K];
|
|
16
|
-
interface SwitchableNode<T extends Node> {
|
|
17
|
-
switch(t: T): boolean;
|
|
18
|
-
}
|
|
19
|
-
type FutureNode = () => ValidNodeChild;
|
|
20
1
|
type ValidNode = Node | Component | Component<KeyedObject> | FutureNode;
|
|
21
2
|
type ValidNodeChild = ValidNode | null | string;
|
|
22
3
|
type ValidTemplateReturn = ValidNodeChild | ValidNodeChild[];
|
|
4
|
+
type FutureNode = () => ValidNodeChild;
|
|
23
5
|
type EffectHandler = (() => void) | (() => () => void);
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
};
|
|
27
|
-
type Styles = Partial<CSSStyleDeclaration>;
|
|
28
|
-
interface ElementOverridedProperties extends AriaValueMap {
|
|
29
|
-
style?: Styles;
|
|
30
|
-
}
|
|
31
|
-
type AnyElement<T extends HTMLTags | HTMLSVGTags = HTMLTags> = T extends HTMLTags ? Element<T> : T extends HTMLSVGTags ? SVGElement<T> : never;
|
|
32
|
-
type AnyProps<T extends HTMLTags | HTMLSVGTags = HTMLTags> = T extends HTMLTags ? HTMLProps<T> : T extends HTMLSVGTags ? SVGProps<T> : never;
|
|
33
|
-
type ElementRef<T extends HTMLTags | HTMLSVGTags = HTMLTags> = Stores<(T extends HTMLTags ? HTMLElementTagNameMap[T] : T extends HTMLSVGTags ? SVGElementTagNameMap[T] : never) | undefined>;
|
|
34
|
-
interface ElementProps<T extends HTMLTags | HTMLSVGTags = HTMLTags> {
|
|
35
|
-
ref?: ElementRef<T>;
|
|
36
|
-
key?: string | number | symbol;
|
|
37
|
-
}
|
|
38
|
-
type ExcludeProperties<T> = {
|
|
39
|
-
[K in keyof T as K extends HTMLExcludedProperties ? never : K]: T[K];
|
|
40
|
-
};
|
|
41
|
-
type HTMLProps<T extends HTMLTags> = Partial<ExcludeProperties<ExcludeFunctions<Element<T>>>> & ElementProps<T> & ElementOverridedProperties;
|
|
42
|
-
type SVGAttributeValue = string | number;
|
|
43
|
-
type NormalizeSVGProp<T> = T extends SVGAnimatedLength ? SVGAttributeValue : T extends SVGAnimatedAngle ? SVGAttributeValue : T extends SVGAnimatedBoolean ? SVGAttributeValue : T extends SVGAnimatedEnumeration ? SVGAttributeValue : T extends SVGAnimatedInteger ? SVGAttributeValue : T extends SVGAnimatedNumber ? SVGAttributeValue : T extends SVGAnimatedPreserveAspectRatio ? SVGAttributeValue : T extends SVGAnimatedRect ? SVGAttributeValue : T extends SVGAnimatedString ? SVGAttributeValue : T extends SVGAnimatedTransformList ? SVGAttributeValue : T extends SVGPointList ? SVGAttributeValue : T;
|
|
44
|
-
type SVGRawProps<T extends HTMLSVGTags> = ExcludeProperties<ExcludeFunctions<SVGElementTagNameMap[T]>>;
|
|
45
|
-
interface SVGOverridedProperties {
|
|
46
|
-
fill?: string;
|
|
47
|
-
"fill-opacity"?: string;
|
|
48
|
-
stroke?: string;
|
|
49
|
-
"stroke-width"?: SVGAttributeValue;
|
|
50
|
-
"stroke-linecap"?: "butt" | "round" | "square";
|
|
51
|
-
"stroke-linejoin"?: "miter" | "round" | "bevel";
|
|
52
|
-
d?: string;
|
|
53
|
-
"stroke-dasharray"?: SVGAttributeValue;
|
|
6
|
+
interface SwitchableNode<T extends Node> {
|
|
7
|
+
switch(t: T): boolean;
|
|
54
8
|
}
|
|
55
|
-
|
|
56
|
-
[K in keyof SVGRawProps<T>]: NormalizeSVGProp<SVGRawProps<T>[K]>;
|
|
57
|
-
}> & ElementProps<T> & ElementOverridedProperties & SVGOverridedProperties;
|
|
58
|
-
type StateHandler<S extends KeyedObject | undefined = undefined> = S | ((l: S) => S);
|
|
59
|
-
declare const enum NodeType {
|
|
9
|
+
declare enum NodeType {
|
|
60
10
|
Tag = 0,
|
|
61
11
|
Content = 1,
|
|
62
12
|
Parent = 2,
|
|
@@ -138,4 +88,4 @@ declare function createRoot<T extends HTMLElement>(root: T): {
|
|
|
138
88
|
render: (...children: ValidNodeChild[]) => void;
|
|
139
89
|
};
|
|
140
90
|
declare function createContext<T extends KeyedObject>(): Context<T>;
|
|
141
|
-
export { Component, createContext, createRoot, EffectHandler,
|
|
91
|
+
export { Component, createContext, createRoot, EffectHandler, Node, Portal, Stores, TagNode, ValidNode, ValidNodeChild, ValidTemplateReturn, FutureNode, };
|
package/dist/node.js
CHANGED
|
@@ -64,6 +64,13 @@ const SVG_TAGS = new Set([
|
|
|
64
64
|
"use",
|
|
65
65
|
"view",
|
|
66
66
|
]);
|
|
67
|
+
var NodeType;
|
|
68
|
+
(function (NodeType) {
|
|
69
|
+
NodeType[NodeType["Tag"] = 0] = "Tag";
|
|
70
|
+
NodeType[NodeType["Content"] = 1] = "Content";
|
|
71
|
+
NodeType[NodeType["Parent"] = 2] = "Parent";
|
|
72
|
+
NodeType[NodeType["Component"] = 3] = "Component";
|
|
73
|
+
})(NodeType || (NodeType = {}));
|
|
67
74
|
class Stores {
|
|
68
75
|
#_stores;
|
|
69
76
|
constructor(s) {
|
|
@@ -147,16 +154,16 @@ class Node {
|
|
|
147
154
|
this.$typeof = t;
|
|
148
155
|
}
|
|
149
156
|
get isTag() {
|
|
150
|
-
return this.$typeof ===
|
|
157
|
+
return this.$typeof === NodeType.Tag;
|
|
151
158
|
}
|
|
152
159
|
get isContent() {
|
|
153
|
-
return this.$typeof ===
|
|
160
|
+
return this.$typeof === NodeType.Content;
|
|
154
161
|
}
|
|
155
162
|
get isParent() {
|
|
156
|
-
return this.$typeof ===
|
|
163
|
+
return this.$typeof === NodeType.Parent;
|
|
157
164
|
}
|
|
158
165
|
get isComponent() {
|
|
159
|
-
return this.$typeof ===
|
|
166
|
+
return this.$typeof === NodeType.Component;
|
|
160
167
|
}
|
|
161
168
|
get deleted() {
|
|
162
169
|
return this._deleted;
|
|
@@ -181,7 +188,7 @@ class ContentNode extends Node {
|
|
|
181
188
|
_content;
|
|
182
189
|
_dom = undefined;
|
|
183
190
|
constructor(content) {
|
|
184
|
-
super(
|
|
191
|
+
super(NodeType.Content);
|
|
185
192
|
this._content = content;
|
|
186
193
|
this.needs_update = true;
|
|
187
194
|
}
|
|
@@ -334,7 +341,8 @@ function _remove_html_prop(dom, props, prop) {
|
|
|
334
341
|
}
|
|
335
342
|
catch (error) { }
|
|
336
343
|
}
|
|
337
|
-
|
|
344
|
+
else
|
|
345
|
+
dom.removeAttribute(prop);
|
|
338
346
|
}
|
|
339
347
|
function _get_props_diff(a, b) {
|
|
340
348
|
const _to_remove = {};
|
|
@@ -410,7 +418,7 @@ class TagNode extends Node {
|
|
|
410
418
|
key = undefined;
|
|
411
419
|
index_length = 0;
|
|
412
420
|
constructor(tag, props, children) {
|
|
413
|
-
super(
|
|
421
|
+
super(NodeType.Tag);
|
|
414
422
|
this.tag = tag;
|
|
415
423
|
this._props = props;
|
|
416
424
|
if (this._props && "key" in this._props) {
|
|
@@ -431,6 +439,10 @@ class TagNode extends Node {
|
|
|
431
439
|
_clear_props(this._dom, diff.remove);
|
|
432
440
|
_apply_props(this._dom, diff.apply);
|
|
433
441
|
this._props = nprops;
|
|
442
|
+
if (this.tag === "input" &&
|
|
443
|
+
!("value" in diff.apply && "value" in diff.remove)) {
|
|
444
|
+
this._dom.value = "";
|
|
445
|
+
}
|
|
434
446
|
}
|
|
435
447
|
else {
|
|
436
448
|
this._props = nprops;
|
|
@@ -516,8 +528,17 @@ class TagNode extends Node {
|
|
|
516
528
|
_apply_props(this._dom, this._props);
|
|
517
529
|
}
|
|
518
530
|
}
|
|
519
|
-
else
|
|
520
|
-
|
|
531
|
+
else {
|
|
532
|
+
// DOM not created yet
|
|
533
|
+
if (this._props) {
|
|
534
|
+
if (t.props)
|
|
535
|
+
this._diff_dom_props(t.props);
|
|
536
|
+
}
|
|
537
|
+
else {
|
|
538
|
+
this._props = t.props ? t.props : undefined;
|
|
539
|
+
}
|
|
540
|
+
this.create();
|
|
541
|
+
}
|
|
521
542
|
}
|
|
522
543
|
else {
|
|
523
544
|
// Tag has changed
|
|
@@ -550,7 +571,7 @@ class ParentNode extends Node {
|
|
|
550
571
|
_children = undefined;
|
|
551
572
|
child_length = 0;
|
|
552
573
|
constructor(root, children) {
|
|
553
|
-
super(
|
|
574
|
+
super(NodeType.Parent);
|
|
554
575
|
this.dom = root;
|
|
555
576
|
this._children = children;
|
|
556
577
|
}
|
|
@@ -615,7 +636,7 @@ class ComponentNode extends Node {
|
|
|
615
636
|
_children = undefined;
|
|
616
637
|
child_length = 0;
|
|
617
638
|
constructor(template) {
|
|
618
|
-
super(
|
|
639
|
+
super(NodeType.Component);
|
|
619
640
|
this._template = template;
|
|
620
641
|
getInternals(this._template).switch(this);
|
|
621
642
|
this.needs_update = true;
|
|
@@ -1264,4 +1285,15 @@ function createRoot(root) {
|
|
|
1264
1285
|
function createContext() {
|
|
1265
1286
|
return new Context();
|
|
1266
1287
|
}
|
|
1267
|
-
export { Component, createContext, createRoot,
|
|
1288
|
+
export { Component, createContext, createRoot,
|
|
1289
|
+
// Element,
|
|
1290
|
+
// ElementRef,
|
|
1291
|
+
// HTMLProps,
|
|
1292
|
+
// HTMLTags,
|
|
1293
|
+
// HTMLSVGTags,
|
|
1294
|
+
// SVGProps,
|
|
1295
|
+
Node, Portal,
|
|
1296
|
+
// StateHandler,
|
|
1297
|
+
Stores,
|
|
1298
|
+
// Styles,
|
|
1299
|
+
TagNode, };
|
package/dist/tags.d.ts
CHANGED
package/dist/tags.js
CHANGED
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yandel",
|
|
3
3
|
"description": "A reactive lightweight TS frontend framework",
|
|
4
|
-
"version": "1.2.
|
|
4
|
+
"version": "1.2.2",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"files": [
|
|
8
|
-
"dist"
|
|
8
|
+
"dist",
|
|
9
|
+
"types"
|
|
9
10
|
],
|
|
10
11
|
"scripts": {
|
|
11
12
|
"build": "tsc",
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
type HTMLExcludedProperties =
|
|
2
|
+
| `aria${string}`
|
|
3
|
+
| "tagName"
|
|
4
|
+
| "shadowRoot"
|
|
5
|
+
| "slot"
|
|
6
|
+
| "classList"
|
|
7
|
+
| "style"
|
|
8
|
+
| "attributes"
|
|
9
|
+
| "attributeStyleMap"
|
|
10
|
+
| "ATTRIBUTE_NODE"
|
|
11
|
+
| "CDATA_SECTION_NODE"
|
|
12
|
+
| "COMMENT_NODE"
|
|
13
|
+
| "childElementCount"
|
|
14
|
+
| "childNodes"
|
|
15
|
+
| "children"
|
|
16
|
+
| "isConnected"
|
|
17
|
+
| "ownerDocument"
|
|
18
|
+
| "lastChild"
|
|
19
|
+
| "lastElement"
|
|
20
|
+
| "nextElementSibling"
|
|
21
|
+
| "nextSibling"
|
|
22
|
+
| "previousElementSibling"
|
|
23
|
+
| "previousSibling"
|
|
24
|
+
| "parentElement"
|
|
25
|
+
| "parent"
|
|
26
|
+
| "outerContent"
|
|
27
|
+
| "firstChild"
|
|
28
|
+
| "firstElementChild"
|
|
29
|
+
| "lastChild"
|
|
30
|
+
| "lastElementChild"
|
|
31
|
+
| "innerHTML"
|
|
32
|
+
| "outerHTML"
|
|
33
|
+
| "innerContent"
|
|
34
|
+
| "textContent"
|
|
35
|
+
| `DOCUMENT_${string}`
|
|
36
|
+
| "NOTATION_NODE"
|
|
37
|
+
| "PROCESSING_INSTRUCTION_NODE"
|
|
38
|
+
| "CONTENT_NODE"
|
|
39
|
+
| "ELEMENT_NODE"
|
|
40
|
+
| "TEXT_NODE"
|
|
41
|
+
| `ENTITY_${string}`;
|
|
42
|
+
type AriaWidgetProperties =
|
|
43
|
+
| "aria-autocomplete"
|
|
44
|
+
| "aria-checked"
|
|
45
|
+
| "aria-disabled"
|
|
46
|
+
| "aria-errormessage"
|
|
47
|
+
| "aria-expanded"
|
|
48
|
+
| "aria-haspopup"
|
|
49
|
+
| "aria-hidden"
|
|
50
|
+
| "aria-invalid"
|
|
51
|
+
| "aria-label"
|
|
52
|
+
| "aria-level"
|
|
53
|
+
| "aria-modal"
|
|
54
|
+
| "aria-multiline"
|
|
55
|
+
| "aria-multiselectable"
|
|
56
|
+
| "aria-orientation"
|
|
57
|
+
| "aria-placeholder"
|
|
58
|
+
| "aria-pressed"
|
|
59
|
+
| "aria-readonly"
|
|
60
|
+
| "aria-required"
|
|
61
|
+
| "aria-selected"
|
|
62
|
+
| "aria-sort"
|
|
63
|
+
| "aria-valuemax"
|
|
64
|
+
| "aria-valuemin"
|
|
65
|
+
| "aria-valuenow"
|
|
66
|
+
| "aria-valuetext";
|
|
67
|
+
type AriaLiveRegionProperties =
|
|
68
|
+
| "aria-busy"
|
|
69
|
+
| "aria-live"
|
|
70
|
+
| "aria-relevant"
|
|
71
|
+
| "aria-atomic";
|
|
72
|
+
type AriaDragAndDropProperties = "aria-dropeffect" | "aria-grabbed";
|
|
73
|
+
type AriaRelatonshipProperties =
|
|
74
|
+
| "aria-activedescendant"
|
|
75
|
+
| "aria-colcount"
|
|
76
|
+
| "aria-colindex"
|
|
77
|
+
| "aria-colspan"
|
|
78
|
+
| "aria-controls"
|
|
79
|
+
| "aria-describedby"
|
|
80
|
+
| "aria-description"
|
|
81
|
+
| "aria-details"
|
|
82
|
+
| "aria-errormessage"
|
|
83
|
+
| "aria-flowto"
|
|
84
|
+
| "aria-labelledby"
|
|
85
|
+
| "aria-owns"
|
|
86
|
+
| "aria-posinset"
|
|
87
|
+
| "aria-rowcount"
|
|
88
|
+
| "aria-rowindex"
|
|
89
|
+
| "aria-rowspan"
|
|
90
|
+
| "aria-setsize";
|
|
91
|
+
type AriaGlobalProperties =
|
|
92
|
+
| "aria-atomic"
|
|
93
|
+
| "aria-busy"
|
|
94
|
+
| "aria-controls"
|
|
95
|
+
| "aria-current"
|
|
96
|
+
| "aria-describedby"
|
|
97
|
+
| "aria-description"
|
|
98
|
+
| "aria-details"
|
|
99
|
+
| "aria-disabled"
|
|
100
|
+
| "aria-dropeffect"
|
|
101
|
+
| "aria-errormessage"
|
|
102
|
+
| "aria-flowto"
|
|
103
|
+
| "aria-grabbed"
|
|
104
|
+
| "aria-haspopup"
|
|
105
|
+
| "aria-hidden"
|
|
106
|
+
| "aria-invalid"
|
|
107
|
+
| "aria-keyshortcuts"
|
|
108
|
+
| "aria-label"
|
|
109
|
+
| "aria-labelledby"
|
|
110
|
+
| "aria-live"
|
|
111
|
+
| "aria-owns"
|
|
112
|
+
| "aria-relevant"
|
|
113
|
+
| "aria-roledescription";
|
|
114
|
+
type AriaProps =
|
|
115
|
+
| AriaWidgetProperties
|
|
116
|
+
| AriaDragAndDropProperties
|
|
117
|
+
| AriaLiveRegionProperties
|
|
118
|
+
| AriaRelatonshipProperties
|
|
119
|
+
| AriaGlobalProperties;
|
|
120
|
+
type AriaBoolean = "true" | "false";
|
|
121
|
+
type AriaValue = Exclude<string, AriaBoolean>;
|
|
122
|
+
type AriaValueMap = Partial<Record<AriaProps, AriaBoolean | AriaValue>>;
|
|
123
|
+
type KeyedObject = Record<string | symbol | number, any>;
|
|
124
|
+
type HTMLTags = keyof HTMLElementTagNameMap;
|
|
125
|
+
type HTMLSVGTags = keyof SVGElementTagNameMap;
|
|
126
|
+
type YElement<K extends HTMLTags = HTMLTags> = HTMLElementTagNameMap[K];
|
|
127
|
+
type YSVGElement<K extends HTMLSVGTags = HTMLSVGTags> = SVGElementTagNameMap[K];
|
|
128
|
+
|
|
129
|
+
type ExcludeFunctions<T> = {
|
|
130
|
+
[K in keyof T as T[K] extends Function ? never : K]: T[K];
|
|
131
|
+
};
|
|
132
|
+
type Styles = Partial<CSSStyleDeclaration>;
|
|
133
|
+
interface ElementOverridedProperties extends AriaValueMap {
|
|
134
|
+
style?: Styles;
|
|
135
|
+
}
|
|
136
|
+
type AnyElement<T extends HTMLTags | HTMLSVGTags = HTMLTags> =
|
|
137
|
+
T extends HTMLTags
|
|
138
|
+
? YElement<T>
|
|
139
|
+
: T extends HTMLSVGTags
|
|
140
|
+
? YSVGElement<T>
|
|
141
|
+
: never;
|
|
142
|
+
type AnyProps<T extends HTMLTags | HTMLSVGTags = HTMLTags> = T extends HTMLTags
|
|
143
|
+
? HTMLProps<T>
|
|
144
|
+
: T extends HTMLSVGTags
|
|
145
|
+
? SVGProps<T>
|
|
146
|
+
: never;
|
|
147
|
+
interface Stores<T> {
|
|
148
|
+
get stores(): T;
|
|
149
|
+
}
|
|
150
|
+
type ElementRef<T extends HTMLTags | HTMLSVGTags = HTMLTags> = Stores<
|
|
151
|
+
| (T extends HTMLTags
|
|
152
|
+
? HTMLElementTagNameMap[T]
|
|
153
|
+
: T extends HTMLSVGTags
|
|
154
|
+
? SVGElementTagNameMap[T]
|
|
155
|
+
: never)
|
|
156
|
+
| undefined
|
|
157
|
+
>;
|
|
158
|
+
interface ElementProps<T extends HTMLTags | HTMLSVGTags = HTMLTags> {
|
|
159
|
+
ref?: ElementRef<T>;
|
|
160
|
+
key?: string | number | symbol;
|
|
161
|
+
}
|
|
162
|
+
type ExcludeProperties<T> = {
|
|
163
|
+
[K in keyof T as K extends HTMLExcludedProperties ? never : K]: T[K];
|
|
164
|
+
};
|
|
165
|
+
type HTMLProps<T extends HTMLTags> = Partial<
|
|
166
|
+
ExcludeProperties<ExcludeFunctions<YElement<T>>>
|
|
167
|
+
> &
|
|
168
|
+
ElementProps<T> &
|
|
169
|
+
ElementOverridedProperties;
|
|
170
|
+
|
|
171
|
+
type SVGAttributeValue = string | number;
|
|
172
|
+
|
|
173
|
+
type NormalizeSVGProp<T> = T extends SVGAnimatedLength
|
|
174
|
+
? SVGAttributeValue
|
|
175
|
+
: T extends SVGAnimatedAngle
|
|
176
|
+
? SVGAttributeValue
|
|
177
|
+
: T extends SVGAnimatedBoolean
|
|
178
|
+
? SVGAttributeValue
|
|
179
|
+
: T extends SVGAnimatedEnumeration
|
|
180
|
+
? SVGAttributeValue
|
|
181
|
+
: T extends SVGAnimatedInteger
|
|
182
|
+
? SVGAttributeValue
|
|
183
|
+
: T extends SVGAnimatedNumber
|
|
184
|
+
? SVGAttributeValue
|
|
185
|
+
: T extends SVGAnimatedPreserveAspectRatio
|
|
186
|
+
? SVGAttributeValue
|
|
187
|
+
: T extends SVGAnimatedRect
|
|
188
|
+
? SVGAttributeValue
|
|
189
|
+
: T extends SVGAnimatedString
|
|
190
|
+
? SVGAttributeValue
|
|
191
|
+
: T extends SVGAnimatedTransformList
|
|
192
|
+
? SVGAttributeValue
|
|
193
|
+
: T extends SVGPointList
|
|
194
|
+
? SVGAttributeValue
|
|
195
|
+
: T;
|
|
196
|
+
|
|
197
|
+
type SVGRawProps<T extends HTMLSVGTags> = ExcludeProperties<
|
|
198
|
+
ExcludeFunctions<SVGElementTagNameMap[T]>
|
|
199
|
+
>;
|
|
200
|
+
interface SVGOverridedProperties {
|
|
201
|
+
fill?: string;
|
|
202
|
+
"fill-opacity"?: string;
|
|
203
|
+
stroke?: string;
|
|
204
|
+
"stroke-width"?: SVGAttributeValue;
|
|
205
|
+
"stroke-linecap"?: "butt" | "round" | "square";
|
|
206
|
+
"stroke-linejoin"?: "miter" | "round" | "bevel";
|
|
207
|
+
d?: string;
|
|
208
|
+
"stroke-dasharray"?: SVGAttributeValue;
|
|
209
|
+
}
|
|
210
|
+
type SVGProps<T extends HTMLSVGTags> = Partial<{
|
|
211
|
+
[K in keyof SVGRawProps<T>]: NormalizeSVGProp<SVGRawProps<T>[K]>;
|
|
212
|
+
}> &
|
|
213
|
+
ElementProps<T> &
|
|
214
|
+
ElementOverridedProperties &
|
|
215
|
+
SVGOverridedProperties;
|
|
216
|
+
type StateHandler<S extends KeyedObject | undefined = undefined> =
|
|
217
|
+
| S
|
|
218
|
+
| ((l: S) => S);
|
|
219
|
+
|
|
220
|
+
// declare abstract class Component<S extends KeyedObject | void = void> {
|
|
221
|
+
// protected get state(): S;
|
|
222
|
+
// protected setState(h: StateHandler<S extends void ? undefined : S>): void;
|
|
223
|
+
// public render(): ValidTemplateReturn;
|
|
224
|
+
// public delete(): void;
|
|
225
|
+
// }
|