-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathElement.d.ts
119 lines (118 loc) · 3.84 KB
/
Element.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
import { IObservable } from 'react-observing';
/**
* Used to render a native element
* - Allow or not content
*/
type THtml<D = any> = {
/** This instance id */
id: IObservable<string>;
tag: IObservable<string>;
/** This instance name */
name: IObservable<string>;
type: IObservable<'html'>;
/** If this init undefined, this will not receive children, drop inside will throw a error */
children: IObservable<TElement[] | undefined>;
style: IObservable<{
name: IObservable<string>;
value: IObservable<string | number | boolean>;
}[] | undefined>;
attributes: IObservable<{
name: IObservable<string>;
value: IObservable<string | number | boolean | undefined | null>;
}[] | undefined>;
/** Extra data can be passed here, things like a full instance or extra information */
customData?: D;
};
/**
* Used to render or edit a text
* - Do not allow content
*/
type TText<D = any> = {
/**
* This instance id
* > **Text.id**
*/
id: IObservable<string>;
/** This instance name */
name: IObservable<string>;
/** Store the text */
text: IObservable<string>;
/** If the type is slot, the slot will be only a placeholder in the screen */
type: IObservable<'text'>;
/** Extra data can be passed here, things like a full instance or extra information */
customData?: D;
};
/**
* Used to render a slot element
* - Do not allow content
*/
type TSlot<D = any> = {
/**
* This instance id
* > **Slot.id**
*/
id: IObservable<string>;
/** This instance name */
name: IObservable<string>;
/**
* Reference component id
* > **Component.id**
*/
componentId: IObservable<string>;
/** If the type is slot, the slot will be only a placeholder in the screen */
type: IObservable<'slot'>;
/** Extra data can be passed here, things like a full instance or extra information */
customData?: D;
};
/**
* Used to store the slot content
* - Allow content
*/
type TSlotContent<D = any> = {
/**
* This instance id
* > **SlotContent.id**
*/
id: IObservable<string>;
/** If the type is slot-content, the slot will accept and render elements in the screen */
type: IObservable<'slot-content'>;
children: IObservable<TElement[]>;
/**
* Reference slot id
* > **Slot.id**
*/
referenceSlotId: IObservable<string>;
/** Extra data can be passed here, things like a full instance or extra information */
customData?: D;
};
/**
* Used to group native elements, slot and other components
* - Allow content
*/
type TComponent<D = any> = {
/**
* This instance id
* > **Component.id**
*/
id: IObservable<string>;
/** This instance name */
name: IObservable<string>;
type: IObservable<'component'>;
/**
* Referenced component id
* > **ReferenceComponent.id**
*/
referenceComponentId: IObservable<string>;
/**
* Here must have the content of this instance for the reference component slot
*/
slots: IObservable<TSlotContent[] | undefined>;
/** Extra data can be passed here, things like a full instance or extra information */
customData?: D;
};
export type TElementTypesParents = 'html' | 'component' | 'slot-content';
export type TElementTypesDefault = 'html' | 'component' | 'slot' | 'text';
export type TElementTypesAll = 'html' | 'component' | 'slot' | 'slot-content' | 'text';
export type TElement<T extends TElementTypesAll = TElementTypesDefault, D = any> = T extends 'html' ? THtml<D> : T extends 'slot' ? TSlot<D> : T extends 'text' ? TText<D> : T extends 'slot-content' ? TSlotContent<D> : TComponent<D>;
export type TParentElement<T extends TElementTypesParents = TElementTypesParents, D = any> = T extends 'html' ? THtml<D> : T extends 'slot-content' ? TSlotContent<D> : TComponent<D>;
export {};