jpf 5.0.3 → 5.0.6
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/controls/codeMirror/Editor/Editor.d.ts +19 -0
- package/dist/controls/codeMirror/Editor/Editor.js +151 -0
- package/dist/controls/codeMirror/Editor/Editor.js.map +1 -0
- package/dist/controls/codeMirror/index.d.ts +1 -2
- package/dist/controls/codeMirror/index.js +1 -2
- package/dist/controls/codeMirror/index.js.map +1 -1
- package/dist/controls/custom/FileSelector/FileSelector.d.ts +18 -18
- package/dist/controls/custom/FileSelector/FileSelector.js +47 -46
- package/dist/controls/custom/FileSelector/FileSelector.js.map +1 -1
- package/dist/controls/custom/LabeledControl/LabeledControl.d.ts +15 -15
- package/dist/controls/custom/LabeledControl/LabeledControl.js +31 -36
- package/dist/controls/custom/LabeledControl/LabeledControl.js.map +1 -1
- package/dist/controls/custom/ListItem/ListItem.d.ts +37 -36
- package/dist/controls/custom/ListItem/ListItem.js +62 -62
- package/dist/controls/custom/ListItem/ListItem.js.map +1 -1
- package/dist/controls/custom/index.d.ts +3 -3
- package/dist/controls/custom/index.js +3 -3
- package/dist/controls/html/Button/Button.d.ts +16 -16
- package/dist/controls/html/Button/Button.js +47 -50
- package/dist/controls/html/Button/Button.js.map +1 -1
- package/dist/controls/html/Div/Div.d.ts +14 -14
- package/dist/controls/html/Div/Div.js +23 -24
- package/dist/controls/html/Div/Div.js.map +1 -1
- package/dist/controls/html/Image/Image.d.ts +16 -16
- package/dist/controls/html/Image/Image.js +29 -28
- package/dist/controls/html/Image/Image.js.map +1 -1
- package/dist/controls/html/Input/Input.d.ts +34 -34
- package/dist/controls/html/Input/Input.js +166 -170
- package/dist/controls/html/Input/Input.js.map +1 -1
- package/dist/controls/html/Select/Select.d.ts +30 -30
- package/dist/controls/html/Select/Select.js +109 -110
- package/dist/controls/html/Select/Select.js.map +1 -1
- package/dist/controls/html/Span/Span.d.ts +11 -11
- package/dist/controls/html/Span/Span.js +22 -22
- package/dist/controls/html/Span/Span.js.map +1 -1
- package/dist/controls/html/index.d.ts +6 -6
- package/dist/controls/html/index.js +6 -6
- package/dist/controls/index.d.ts +14 -14
- package/dist/controls/index.js +14 -14
- package/dist/controls/index.js.map +1 -1
- package/dist/controls/{jsonViewAwesome → jsonViewerAwesome}/index.d.ts +1 -1
- package/dist/controls/{jsonViewAwesome → jsonViewerAwesome}/index.js +1 -1
- package/dist/controls/jsonViewerAwesome/index.js.map +1 -0
- package/dist/controls/jsonViewerAwesome/jsonFormatter/JsonFormatter.d.ts +28 -0
- package/dist/controls/{jsonViewAwesome → jsonViewerAwesome}/jsonFormatter/JsonFormatter.js +65 -65
- package/dist/controls/jsonViewerAwesome/jsonFormatter/JsonFormatter.js.map +1 -0
- package/dist/controls/kendo/Chart/Chart.d.ts +19 -19
- package/dist/controls/kendo/Chart/Chart.js +62 -62
- package/dist/controls/kendo/Chart/Chart.js.map +1 -1
- package/dist/controls/kendo/Culture/Culture.d.ts +1 -1
- package/dist/controls/kendo/Culture/Culture.js +25 -25
- package/dist/controls/kendo/Culture/Culture.js.map +1 -1
- package/dist/controls/kendo/DataSource/DataSource.d.ts +4 -4
- package/dist/controls/kendo/DataSource/DataSource.js +1 -1
- package/dist/controls/kendo/Editor/Editor.d.ts +14 -19
- package/dist/controls/kendo/Editor/Editor.js +94 -104
- package/dist/controls/kendo/Editor/Editor.js.map +1 -1
- package/dist/controls/kendo/Grid/Grid.d.ts +54 -54
- package/dist/controls/kendo/Grid/Grid.js +201 -218
- package/dist/controls/kendo/Grid/Grid.js.map +1 -1
- package/dist/controls/kendo/Menu/Menu.d.ts +15 -15
- package/dist/controls/kendo/Menu/Menu.js +90 -90
- package/dist/controls/kendo/Menu/Menu.js.map +1 -1
- package/dist/controls/kendo/ObservableObject/ObservableObject.d.ts +0 -5
- package/dist/controls/kendo/ObservableObject/ObservableObject.js +0 -34
- package/dist/controls/kendo/ObservableObject/ObservableObject.js.map +1 -1
- package/dist/controls/kendo/Treeview/Treeview.d.ts +17 -0
- package/dist/controls/kendo/{Tree/Tree.js → Treeview/Treeview.js} +107 -107
- package/dist/controls/kendo/Treeview/Treeview.js.map +1 -0
- package/dist/controls/kendo/Window/Window.d.ts +14 -0
- package/dist/controls/kendo/{Dialog/Dialog.js → Window/Window.js} +49 -49
- package/dist/controls/kendo/Window/Window.js.map +1 -0
- package/dist/controls/kendo/index.d.ts +8 -9
- package/dist/controls/kendo/index.js +8 -9
- package/dist/controls/kendo/index.js.map +1 -1
- package/dist/controls/leaflet/LabelControl/LabelControl.d.ts +12 -12
- package/dist/controls/leaflet/LabelControl/LabelControl.js +33 -33
- package/dist/controls/leaflet/LabelControl/LabelControl.js.map +1 -1
- package/dist/controls/leaflet/Map/Map.d.ts +45 -45
- package/dist/controls/leaflet/Map/Map.js +116 -115
- package/dist/controls/leaflet/Map/Map.js.map +1 -1
- package/dist/controls/leaflet/OpenStreetMapTileLayer/OpenStreetMapTileLayer.d.ts +8 -8
- package/dist/controls/leaflet/OpenStreetMapTileLayer/OpenStreetMapTileLayer.js +13 -13
- package/dist/controls/leaflet/OpenStreetMapTileLayer/OpenStreetMapTileLayer.js.map +1 -1
- package/dist/controls/leaflet/PointerEvent/PointerEvent.d.ts +2 -2
- package/dist/controls/leaflet/PointerEvent/PointerEvent.js +7 -7
- package/dist/controls/leaflet/PointerEvent/PointerEvent.js.map +1 -1
- package/dist/controls/leaflet/index.d.ts +4 -4
- package/dist/controls/leaflet/index.js +4 -4
- package/dist/controls/svg/Circle/Circle.d.ts +12 -12
- package/dist/controls/svg/Circle/Circle.js +20 -20
- package/dist/controls/svg/Circle/Circle.js.map +1 -1
- package/dist/controls/svg/Ellipse/Ellipse.d.ts +13 -13
- package/dist/controls/svg/Ellipse/Ellipse.js +21 -21
- package/dist/controls/svg/Ellipse/Ellipse.js.map +1 -1
- package/dist/controls/svg/ForeignObject/ForeignObject.d.ts +15 -14
- package/dist/controls/svg/ForeignObject/ForeignObject.js +21 -22
- package/dist/controls/svg/ForeignObject/ForeignObject.js.map +1 -1
- package/dist/controls/svg/Group/Group.d.ts +15 -14
- package/dist/controls/svg/Group/Group.js +21 -22
- package/dist/controls/svg/Group/Group.js.map +1 -1
- package/dist/controls/svg/Line/Line.d.ts +13 -13
- package/dist/controls/svg/Line/Line.js +21 -21
- package/dist/controls/svg/Line/Line.js.map +1 -1
- package/dist/controls/svg/Pattern/Pattern.d.ts +22 -22
- package/dist/controls/svg/Pattern/Pattern.js +22 -23
- package/dist/controls/svg/Pattern/Pattern.js.map +1 -1
- package/dist/controls/svg/Polygon/Polygon.d.ts +11 -11
- package/dist/controls/svg/Polygon/Polygon.js +20 -20
- package/dist/controls/svg/Polygon/Polygon.js.map +1 -1
- package/dist/controls/svg/Polyline/Polyline.d.ts +11 -11
- package/dist/controls/svg/Polyline/Polyline.js +19 -19
- package/dist/controls/svg/Polyline/Polyline.js.map +1 -1
- package/dist/controls/svg/Rectangle/Rectangle.d.ts +13 -13
- package/dist/controls/svg/Rectangle/Rectangle.js +21 -21
- package/dist/controls/svg/Rectangle/Rectangle.js.map +1 -1
- package/dist/controls/svg/Svg/Svg.d.ts +17 -17
- package/dist/controls/svg/Svg/Svg.js +23 -24
- package/dist/controls/svg/Svg/Svg.js.map +1 -1
- package/dist/controls/svg/Text/Text.d.ts +14 -14
- package/dist/controls/svg/Text/Text.js +22 -22
- package/dist/controls/svg/Text/Text.js.map +1 -1
- package/dist/controls/svg/Title/Title.d.ts +10 -10
- package/dist/controls/svg/Title/Title.js +16 -16
- package/dist/controls/svg/Title/Title.js.map +1 -1
- package/dist/controls/svg/index.d.ts +13 -13
- package/dist/controls/svg/index.js +13 -13
- package/dist/controls/svg/svg.d.ts +6 -6
- package/dist/controls/svg/svg.js +12 -12
- package/dist/controls/svg/svg.js.map +1 -1
- package/dist/framework/attributes.d.ts +90 -90
- package/dist/framework/attributes.js +1 -1
- package/dist/framework/{View.d.ts → element.d.ts} +61 -62
- package/dist/framework/{View.js → element.js} +157 -150
- package/dist/framework/element.js.map +1 -0
- package/dist/framework/event.d.ts +80 -80
- package/dist/framework/event.js +25 -25
- package/dist/framework/event.js.map +1 -1
- package/dist/framework/observable.d.ts +37 -12
- package/dist/framework/observable.js +66 -58
- package/dist/framework/observable.js.map +1 -1
- package/dist/framework/properties.d.ts +40 -0
- package/dist/framework/{ViewModel.js → properties.js} +303 -312
- package/dist/framework/properties.js.map +1 -0
- package/dist/framework/root.d.ts +9 -0
- package/dist/framework/root.js +38 -0
- package/dist/framework/root.js.map +1 -0
- package/dist/framework/style.d.ts +657 -658
- package/dist/framework/style.js +146 -153
- package/dist/framework/style.js.map +1 -1
- package/dist/framework/types.d.ts +87 -87
- package/dist/framework/types.js +1 -1
- package/dist/index.d.ts +12 -12
- package/dist/index.js +12 -12
- package/dist/index.js.map +1 -1
- package/dist/utilities/blob/blob.d.ts +1 -1
- package/dist/utilities/blob/blob.js +17 -17
- package/dist/utilities/blob/blob.js.map +1 -1
- package/dist/utilities/contextMenu/contextMenu.d.ts +2 -0
- package/dist/utilities/contextMenu/contextMenu.js +11 -0
- package/dist/utilities/contextMenu/contextMenu.js.map +1 -0
- package/dist/utilities/cookie/cookie.d.ts +3 -3
- package/dist/utilities/cookie/cookie.js +26 -26
- package/dist/utilities/cookie/cookie.js.map +1 -1
- package/dist/utilities/dataReaderTable/dataReaderTable.d.ts +9 -9
- package/dist/utilities/dataReaderTable/dataReaderTable.js +23 -23
- package/dist/utilities/dataReaderTable/dataReaderTable.js.map +1 -1
- package/dist/utilities/fetch/fetch.d.ts +7 -8
- package/dist/utilities/fetch/fetch.js +139 -137
- package/dist/utilities/fetch/fetch.js.map +1 -1
- package/dist/utilities/float/float.d.ts +1 -1
- package/dist/utilities/float/float.js +3 -3
- package/dist/utilities/formData/formData.d.ts +1 -1
- package/dist/utilities/formData/formData.js +11 -11
- package/dist/utilities/formData/formData.js.map +1 -1
- package/dist/utilities/formatting/formatting.d.ts +4 -0
- package/dist/utilities/formatting/formatting.js +26 -0
- package/dist/utilities/formatting/formatting.js.map +1 -0
- package/dist/utilities/htmlElement/htmlElement.d.ts +1 -1
- package/dist/utilities/htmlElement/htmlElement.js +16 -16
- package/dist/utilities/htmlElement/htmlElement.js.map +1 -1
- package/dist/utilities/image/image.d.ts +1 -1
- package/dist/utilities/image/image.js +1 -1
- package/dist/utilities/index.d.ts +40 -36
- package/dist/utilities/index.js +40 -36
- package/dist/utilities/index.js.map +1 -1
- package/dist/utilities/integer/integer.d.ts +3 -3
- package/dist/utilities/integer/integer.js +27 -27
- package/dist/utilities/integer/integer.js.map +1 -1
- package/dist/utilities/key/key.d.ts +2 -2
- package/dist/utilities/key/key.js +6 -6
- package/dist/utilities/navigator/navigator.d.ts +1 -1
- package/dist/utilities/navigator/navigator.js +8 -8
- package/dist/utilities/navigator/navigator.js.map +1 -1
- package/dist/utilities/notification/notification.d.ts +5 -5
- package/dist/utilities/notification/notification.js +66 -66
- package/dist/utilities/notification/notification.js.map +1 -1
- package/dist/utilities/querystring/querystring.d.ts +6 -6
- package/dist/utilities/querystring/querystring.js +53 -53
- package/dist/utilities/querystring/querystring.js.map +1 -1
- package/dist/utilities/router/router.d.ts +19 -19
- package/dist/utilities/router/router.js +80 -80
- package/dist/utilities/router/router.js.map +1 -1
- package/dist/utilities/stylesheet/stylesheet.d.ts +2 -2
- package/dist/utilities/stylesheet/stylesheet.js +47 -47
- package/dist/utilities/stylesheet/stylesheet.js.map +1 -1
- package/dist/utilities/uniqueId/uniqueId.d.ts +1 -1
- package/dist/utilities/uniqueId/uniqueId.js +4 -4
- package/dist/{framework → utilities/userAgent}/userAgent.d.ts +31 -31
- package/dist/{framework → utilities/userAgent}/userAgent.js +46 -46
- package/dist/utilities/userAgent/userAgent.js.map +1 -0
- package/dist/utilities/webSocket/webSocket.d.ts +1 -1
- package/dist/utilities/webSocket/webSocket.js +54 -54
- package/dist/utilities/webSocket/webSocket.js.map +1 -1
- package/package.json +15 -11
- package/src/controls/codeMirror/Editor/Editor.ts +207 -0
- package/src/controls/codeMirror/index.ts +1 -2
- package/src/controls/custom/FileSelector/FileSelector.ts +30 -28
- package/src/controls/custom/LabeledControl/LabeledControl.ts +32 -36
- package/src/controls/custom/ListItem/ListItem.ts +36 -36
- package/src/controls/html/Button/Button.ts +36 -29
- package/src/controls/html/Div/Div.ts +20 -21
- package/src/controls/html/Image/Image.ts +22 -20
- package/src/controls/html/Input/Input.ts +59 -61
- package/src/controls/html/Select/Select.ts +37 -39
- package/src/controls/html/Span/Span.ts +14 -14
- package/src/controls/index.ts +2 -2
- package/src/controls/{jsonViewAwesome → jsonViewerAwesome}/jsonFormatter/JsonFormatter.ts +23 -23
- package/src/controls/kendo/Chart/Chart.ts +34 -34
- package/src/controls/kendo/DataSource/DataSource.ts +1 -1
- package/src/controls/kendo/Editor/Editor.ts +58 -68
- package/src/controls/kendo/Grid/Grid.ts +77 -80
- package/src/controls/kendo/Menu/Menu.ts +22 -22
- package/src/controls/kendo/ObservableObject/ObservableObject.ts +45 -45
- package/src/controls/kendo/{Tree/Tree.ts → Treeview/Treeview.ts} +15 -15
- package/src/controls/kendo/{Dialog/Dialog.ts → Window/Window.ts} +21 -19
- package/src/controls/kendo/index.ts +3 -3
- package/src/controls/leaflet/LabelControl/LabelControl.ts +10 -10
- package/src/controls/leaflet/Map/Map.ts +41 -38
- package/src/controls/leaflet/OpenStreetMapTileLayer/OpenStreetMapTileLayer.ts +3 -3
- package/src/controls/svg/Circle/Circle.ts +14 -14
- package/src/controls/svg/Ellipse/Ellipse.ts +15 -15
- package/src/controls/svg/ForeignObject/ForeignObject.ts +19 -20
- package/src/controls/svg/Group/Group.ts +19 -19
- package/src/controls/svg/Line/Line.ts +15 -15
- package/src/controls/svg/Pattern/Pattern.ts +25 -25
- package/src/controls/svg/Polygon/Polygon.ts +13 -13
- package/src/controls/svg/Polyline/Polyline.ts +13 -13
- package/src/controls/svg/Rectangle/Rectangle.ts +15 -15
- package/src/controls/svg/Svg/Svg.ts +19 -19
- package/src/controls/svg/Text/Text.ts +16 -16
- package/src/controls/svg/Title/Title.ts +12 -12
- package/src/controls/svg/svg.ts +4 -4
- package/src/framework/attributes.ts +46 -46
- package/src/framework/{View.ts → element.ts} +52 -39
- package/src/framework/event.ts +7 -7
- package/src/framework/observable.ts +94 -60
- package/src/framework/properties.ts +393 -0
- package/src/framework/root.ts +45 -0
- package/src/framework/style.ts +330 -340
- package/src/index.ts +4 -4
- package/src/utilities/contextMenu/contextMenu.ts +16 -0
- package/src/utilities/fetch/fetch.ts +16 -14
- package/src/utilities/formatting/formatting.ts +29 -0
- package/src/utilities/index.ts +7 -3
- package/src/utilities/router/router.ts +3 -3
- package/dist/controls/codeMirror/HtmlEditor/HtmlEditor.d.ts +0 -16
- package/dist/controls/codeMirror/HtmlEditor/HtmlEditor.js +0 -120
- package/dist/controls/codeMirror/HtmlEditor/HtmlEditor.js.map +0 -1
- package/dist/controls/codeMirror/JsonEditor/JsonEditor.d.ts +0 -16
- package/dist/controls/codeMirror/JsonEditor/JsonEditor.js +0 -104
- package/dist/controls/codeMirror/JsonEditor/JsonEditor.js.map +0 -1
- package/dist/controls/jsonViewAwesome/index.js.map +0 -1
- package/dist/controls/jsonViewAwesome/jsonFormatter/JsonFormatter.d.ts +0 -28
- package/dist/controls/jsonViewAwesome/jsonFormatter/JsonFormatter.js.map +0 -1
- package/dist/controls/kendo/Dialog/Dialog.d.ts +0 -14
- package/dist/controls/kendo/Dialog/Dialog.js.map +0 -1
- package/dist/controls/kendo/Tree/Tree.d.ts +0 -17
- package/dist/controls/kendo/Tree/Tree.js.map +0 -1
- package/dist/framework/View.js.map +0 -1
- package/dist/framework/ViewModel.d.ts +0 -42
- package/dist/framework/ViewModel.js.map +0 -1
- package/dist/framework/userAgent.js.map +0 -1
- package/dist/utilities/html/html.d.ts +0 -1
- package/dist/utilities/html/html.js +0 -8
- package/dist/utilities/html/html.js.map +0 -1
- package/src/controls/codeMirror/HtmlEditor/HtmlEditor.ts +0 -153
- package/src/controls/codeMirror/JsonEditor/JsonEditor.ts +0 -136
- package/src/framework/ViewModel.ts +0 -528
- package/src/utilities/html/html.ts +0 -8
- /package/src/controls/{jsonViewAwesome → jsonViewerAwesome}/index.ts +0 -0
- /package/src/{framework → utilities/userAgent}/userAgent.ts +0 -0
|
@@ -1,80 +1,114 @@
|
|
|
1
|
-
|
|
1
|
+
export interface ISubscription {
|
|
2
|
+
dispose(): void;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export interface ISubscribable<TValue> {
|
|
6
|
+
subscribe(handler: (arg: TValue, prev: TValue) => void): ISubscription;
|
|
7
|
+
}
|
|
2
8
|
|
|
3
|
-
export interface
|
|
9
|
+
export interface IObservableValue<TValue = any, TSetter = TValue> extends ISubscribable<TValue> {
|
|
4
10
|
(): TValue;
|
|
5
|
-
|
|
11
|
+
setValue(value: TSetter | null): void;
|
|
12
|
+
setValueInAction(value: TSetter| null): void;
|
|
13
|
+
setInternal(value: TValue | null): void;
|
|
6
14
|
}
|
|
7
15
|
|
|
8
|
-
export
|
|
9
|
-
|
|
16
|
+
export interface IObservableArray<TItem = any, TSetter = Array<TItem>> extends Array<TItem>, ISubscribable<Array<TItem>> {
|
|
17
|
+
get(): Array<TItem>;
|
|
18
|
+
setItems(items: TSetter | null, triggerSetter?: boolean): void;
|
|
19
|
+
setInternal(items: Array<TItem> | null): void;
|
|
10
20
|
}
|
|
11
21
|
|
|
12
|
-
export
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
value = null;
|
|
16
|
-
}
|
|
17
|
-
if (isObservable(value)) {
|
|
18
|
-
internalProperty = value;
|
|
19
|
-
} else {
|
|
20
|
-
internalProperty = observable<TValue>(value);
|
|
21
|
-
}
|
|
22
|
+
export interface IComputed<TValue> extends ISubscribable<TValue> {
|
|
23
|
+
(): TValue;
|
|
24
|
+
}
|
|
22
25
|
|
|
23
|
-
|
|
24
|
-
internalProperty.extend({ notify: "always" });
|
|
25
|
-
}
|
|
26
|
+
export interface IObservableMap<TKey, TValue> {
|
|
26
27
|
|
|
27
|
-
|
|
28
|
-
const computed = pureComputed({ read: internalProperty }).extend({ notify: "always" }) as any as ObservableProperty<TValue, TSetter>;
|
|
28
|
+
}
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
if (setter && triggerSetter) {
|
|
32
|
-
setter(newValue, internalProperty);
|
|
33
|
-
} else {
|
|
34
|
-
internalProperty(newValue);
|
|
35
|
-
}
|
|
36
|
-
};
|
|
30
|
+
export interface IObservableSet<TItem> {
|
|
37
31
|
|
|
38
|
-
return computed;
|
|
39
32
|
}
|
|
40
33
|
|
|
41
|
-
export
|
|
42
|
-
|
|
43
|
-
map<TResult>(callbackfn: (value: TItem, index: number, array: TItem[]) => TResult, thisArg?: any): TResult[];
|
|
34
|
+
export function observableValue<TValue, TSetter = TValue>(value?: TValue | null, setter?: (value: TSetter, observableValue: IObservableValue<TValue, TSetter>) => void): IObservableValue<TValue, TSetter> {
|
|
35
|
+
throw "observableValue is not implemented";
|
|
44
36
|
}
|
|
45
37
|
|
|
46
|
-
export function
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
if (!items) {
|
|
50
|
-
items = [];
|
|
51
|
-
}
|
|
52
|
-
if (isObservable(items)) {
|
|
53
|
-
internalProperty = items;
|
|
54
|
-
} else {
|
|
55
|
-
internalProperty = observableArray<TItem>(items);
|
|
56
|
-
}
|
|
38
|
+
export function observableArray<TItem = any, TSetter = Array<TItem>>(initialValues?: Array<TItem> | null, setter?: (value: TSetter, observableArray: IObservableArray<TItem, TSetter>) => void): IObservableArray<TItem, TSetter> {
|
|
39
|
+
throw "observableArray is not implemented";
|
|
40
|
+
}
|
|
57
41
|
|
|
58
|
-
|
|
59
|
-
|
|
42
|
+
export function observableMap<TKey = any, TItem = any>() {
|
|
43
|
+
throw "observableMap is not implemented";
|
|
44
|
+
}
|
|
60
45
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
} else {
|
|
65
|
-
internalProperty(value);
|
|
66
|
-
}
|
|
67
|
-
};
|
|
46
|
+
export function observableSet<TItem = any>() {
|
|
47
|
+
throw "observableSet is not implemented";
|
|
48
|
+
}
|
|
68
49
|
|
|
69
|
-
computed.push = (...itemsToPush) => {
|
|
70
|
-
internalProperty.push(...itemsToPush);
|
|
71
|
-
return itemsToPush.length;
|
|
72
|
-
}
|
|
73
50
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
51
|
+
export function computed<TComputed>(func: () => TComputed): IComputed<TComputed> {
|
|
52
|
+
throw "computed is not implementd";
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function unwrap<TValue>(value: TValue | ISubscribable<TValue>): TValue {
|
|
56
|
+
throw "Unwrap is not implemented";
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function isSubscribable<TValue>(value: any): value is ISubscribable<TValue> {
|
|
60
|
+
return isComputed(value)
|
|
61
|
+
|| isObservableValue(value)
|
|
62
|
+
|| isObservableArray(value)
|
|
63
|
+
|| isObservableMap(value)
|
|
64
|
+
|| isObservableSet(value);
|
|
65
|
+
}
|
|
78
66
|
|
|
79
|
-
|
|
67
|
+
export function isComputed(value): value is IComputed<any> {
|
|
68
|
+
throw "isComputed is not implemented";
|
|
80
69
|
}
|
|
70
|
+
|
|
71
|
+
export function isObservableValue(value): value is IObservableValue {
|
|
72
|
+
throw "isObservableValue is not implemented";
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export function isObservableArray(value): value is IObservableArray {
|
|
76
|
+
throw "isObservableArray is not implemented";
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export function isObservableMap<TKey, TItem>(value): value is IObservableMap<TKey, TItem> {
|
|
80
|
+
throw "isObservableMap is not implemented";
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export function isObservableSet<TItem>(value): value is IObservableSet<TItem> {
|
|
84
|
+
throw "isObservableSet is not implemented";
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export function executeHandlerOnObject(handler: (object) => void, object: object,) {
|
|
88
|
+
//Find out if the object is an array
|
|
89
|
+
if (object.constructor === Array) {
|
|
90
|
+
for (const arrayEntry of object as Array<any>) {
|
|
91
|
+
if (typeof arrayEntry === "object") {
|
|
92
|
+
executeHandlerOnObject(handler, arrayEntry);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
} else {
|
|
96
|
+
if (isSubscribable(object)) {
|
|
97
|
+
const unwrapped = unwrap(object);
|
|
98
|
+
if (typeof unwrapped === "object") {
|
|
99
|
+
executeHandlerOnObject(handler, unwrapped);
|
|
100
|
+
}
|
|
101
|
+
} else {
|
|
102
|
+
//Call the handler on the object.
|
|
103
|
+
handler(object);
|
|
104
|
+
|
|
105
|
+
//Find out if the object has properties of type object
|
|
106
|
+
for (const key in Object.keys(object)) {
|
|
107
|
+
const property = object[key];
|
|
108
|
+
if (property && typeof property === "object") {
|
|
109
|
+
executeHandlerOnObject(handler, property);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
@@ -0,0 +1,393 @@
|
|
|
1
|
+
import { IEventListeners, IUiElementEventMap, IEventListenerOptions, IGenericEventListener, mouseEvents, touchEvents, isGlobalEvent } from "./event";
|
|
2
|
+
import { IAttributes, IAttributesSubscribable } from "./attributes";
|
|
3
|
+
import { IStyle as Style, IStyleSubscribable as StyleSubscribable } from "./style";
|
|
4
|
+
import { unwrap, executeHandlerOnObject, isSubscribable } from "./observable";
|
|
5
|
+
import { ISubscription, ISubscribable } from "./observable";
|
|
6
|
+
import { userAgent } from "../utilities/userAgent/userAgent";
|
|
7
|
+
|
|
8
|
+
export interface IWebSocketMessageHandler {
|
|
9
|
+
handleWebSocketMessage: (message: any) => void;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface IProperties {
|
|
13
|
+
attributes?: IAttributes | IAttributesSubscribable;
|
|
14
|
+
classNames?: Array<string> | ISubscribable<Array<string>>;
|
|
15
|
+
style?: Style | StyleSubscribable;
|
|
16
|
+
visible?: boolean | ISubscribable<boolean>;
|
|
17
|
+
disabled?: boolean | ISubscribable<boolean>;
|
|
18
|
+
innerHtml?: any | ISubscribable<any>;
|
|
19
|
+
textContent?: string | ISubscribable<string>;
|
|
20
|
+
addViewModelToDataObject?: boolean;
|
|
21
|
+
userSelectable?: boolean;
|
|
22
|
+
eventListeners?: IEventListeners;
|
|
23
|
+
elementType?: string;
|
|
24
|
+
focused?: boolean | ISubscribable<boolean>;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export abstract class Properties implements IProperties {
|
|
28
|
+
protected setProperties<TProperties>(object: object, properties?: TProperties) {
|
|
29
|
+
if (properties) {
|
|
30
|
+
Object.keys(properties).forEach((property) => {
|
|
31
|
+
object[property] = properties[property];
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
attributes?: IAttributes | IAttributesSubscribable;
|
|
37
|
+
classNames?: Array<string> | ISubscribable<Array<string>>;
|
|
38
|
+
style?: Style | StyleSubscribable;
|
|
39
|
+
visible?: boolean | ISubscribable<boolean>;
|
|
40
|
+
disabled?: boolean | ISubscribable<boolean>;
|
|
41
|
+
innerHtml?: any | ISubscribable<any>;
|
|
42
|
+
textContent?: string | ISubscribable<string>;
|
|
43
|
+
addViewModelToDataObject?: boolean;
|
|
44
|
+
userSelectable?: boolean;
|
|
45
|
+
eventListeners?: IEventListeners;
|
|
46
|
+
elementType?: string;
|
|
47
|
+
focused?: boolean | ISubscribable<boolean>;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
//#region Properties helper functions
|
|
51
|
+
|
|
52
|
+
export function handleWebSocketMessage(object: object, message: any) {
|
|
53
|
+
executeHandlerOnObject(
|
|
54
|
+
(object) => {
|
|
55
|
+
const webSocketMessageHandler = object as IWebSocketMessageHandler;
|
|
56
|
+
if (webSocketMessageHandler.handleWebSocketMessage && typeof webSocketMessageHandler.handleWebSocketMessage === "function") {
|
|
57
|
+
//Call the handleWebSocketMessage method
|
|
58
|
+
webSocketMessageHandler.handleWebSocketMessage(message);
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
object
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function isNullOrUndefined(value): boolean {
|
|
66
|
+
return value === null || typeof value === "undefined";
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function extendProperties<TTarget = IProperties, TOverwritingProperties = TTarget, TPreserveExistingProperties = TTarget>(target: TTarget, preserveExisting: TPreserveExistingProperties, overWriteExisting?: TOverwritingProperties): TTarget {
|
|
70
|
+
if (overWriteExisting || preserveExisting) {
|
|
71
|
+
target = target || {} as TTarget;
|
|
72
|
+
|
|
73
|
+
if (typeof preserveExisting === "object") {
|
|
74
|
+
Object.keys(preserveExisting).forEach((key) => {
|
|
75
|
+
//Check if the target object does not already have a property with the given key
|
|
76
|
+
if (!target.hasOwnProperty(key) || typeof target[key] === "undefined") {
|
|
77
|
+
target[key] = preserveExisting[key];
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (typeof overWriteExisting === "object") {
|
|
83
|
+
Object.keys(overWriteExisting).forEach((key) => {
|
|
84
|
+
target[key] = overWriteExisting[key];
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return target;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
//Functions to bind the Properties to a html element
|
|
93
|
+
export function applyBindings(properties: IProperties, element: HTMLElement, disposers: Array<ISubscription>) {
|
|
94
|
+
element.setAttribute("elementtype", properties.elementType || "Element");
|
|
95
|
+
|
|
96
|
+
if (properties.classNames) {
|
|
97
|
+
applyClassesToElement(unwrap(properties.classNames), true, element);
|
|
98
|
+
if (isSubscribable(properties.classNames)) {
|
|
99
|
+
const disposer = properties.classNames.subscribe((classNames) => {
|
|
100
|
+
applyClassesToElement(classNames, true, element);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
if (disposers) {
|
|
104
|
+
disposers.push(disposer);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (properties.attributes) {
|
|
110
|
+
Object.keys(properties.attributes).forEach((key) => {
|
|
111
|
+
var value = properties.attributes[key];
|
|
112
|
+
applyAttributeToElement(key as keyof IAttributes, unwrap(value), element);
|
|
113
|
+
|
|
114
|
+
if (isSubscribable(value)) {
|
|
115
|
+
const disposer = value.subscribe((value: string) => {
|
|
116
|
+
applyAttributeToElement(key as keyof IAttributes, value, element);
|
|
117
|
+
});
|
|
118
|
+
if (disposers) {
|
|
119
|
+
disposers.push(disposer);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
if (properties.style) {
|
|
126
|
+
Object.keys(properties.style).forEach((key) => {
|
|
127
|
+
const style = properties.style[key];
|
|
128
|
+
|
|
129
|
+
element.style[key] = unwrap(style);
|
|
130
|
+
if (isSubscribable(style)) {
|
|
131
|
+
const disposer = style.subscribe((style) => {
|
|
132
|
+
element.style[key] = style;
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
if (disposers) {
|
|
136
|
+
disposers.push(disposer);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
if (!isNullOrUndefined(properties.innerHtml)) {
|
|
143
|
+
|
|
144
|
+
element.innerHTML = unwrap(properties.innerHtml);
|
|
145
|
+
|
|
146
|
+
if (isSubscribable(properties.innerHtml)) {
|
|
147
|
+
const disposer = properties.innerHtml.subscribe((innerHtml: string) => {
|
|
148
|
+
element.innerHTML = innerHtml;
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
if (disposers) {
|
|
152
|
+
disposers.push(disposer);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
if (!isNullOrUndefined(properties.textContent)) {
|
|
158
|
+
|
|
159
|
+
const textContent = unwrap(properties.textContent);
|
|
160
|
+
|
|
161
|
+
if (element.hasChildNodes() && element.childNodes.length === 1 && element.childNodes[0].nodeType === 3) {
|
|
162
|
+
element.firstChild.nodeValue = textContent;
|
|
163
|
+
} else {
|
|
164
|
+
element.textContent = unwrap(properties.textContent);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
if (isSubscribable(properties.textContent)) {
|
|
168
|
+
const disposer = properties.textContent.subscribe((textContent) => {
|
|
169
|
+
if (element.hasChildNodes() && element.childNodes.length === 1 && element.childNodes[0].nodeType === 3) {
|
|
170
|
+
element.firstChild.nodeValue = textContent;
|
|
171
|
+
} else {
|
|
172
|
+
element.textContent = unwrap(properties.textContent);
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
if (disposers) {
|
|
177
|
+
disposers.push(disposer);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
//Find out if the element is none selectable
|
|
183
|
+
if (properties.userSelectable === false) {
|
|
184
|
+
applyEventListenerToElement("selectstart", () => { return false; }, { passive: true }, element);
|
|
185
|
+
element.style.userSelect = "none";
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
if (properties.addViewModelToDataObject) {
|
|
189
|
+
if (!element["data"]) {
|
|
190
|
+
element["data"] = {};
|
|
191
|
+
}
|
|
192
|
+
element["data"].viewModel = properties;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
if (properties.eventListeners) {
|
|
196
|
+
applyEventListenersToElement(properties, element);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
applyVisibilityToElement(unwrap(properties.visible), element);
|
|
200
|
+
if (isSubscribable(properties.visible)) {
|
|
201
|
+
const disposer = properties.visible.subscribe((visible) => {
|
|
202
|
+
applyVisibilityToElement(visible, element);
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
if (disposers) {
|
|
206
|
+
disposers.push(disposer);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
applyDisabledToElement(unwrap(properties.disabled), element);
|
|
211
|
+
if (isSubscribable(properties.disabled)) {
|
|
212
|
+
const disposer = properties.disabled.subscribe((disabled) => {
|
|
213
|
+
applyDisabledToElement(disabled, element);
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
if (disposers) {
|
|
217
|
+
disposers.push(disposer);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
applyFocusToElement(unwrap(properties.focused), element);
|
|
222
|
+
if (isSubscribable(properties.focused)) {
|
|
223
|
+
const disposer = properties.focused.subscribe((focused) => {
|
|
224
|
+
applyFocusToElement(focused, element);
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
if (disposers) {
|
|
228
|
+
disposers.push(disposer);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
function applyVisibilityToElement(visible: boolean, element: HTMLElement) {
|
|
234
|
+
if (visible === false) {
|
|
235
|
+
element.classList.add("hidden");
|
|
236
|
+
} else {
|
|
237
|
+
element.classList.remove("hidden");
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
function applyDisabledToElement(disabled: boolean, element: HTMLElement) {
|
|
242
|
+
if (disabled) {
|
|
243
|
+
element.setAttribute("disabled", "disabled");
|
|
244
|
+
} else {
|
|
245
|
+
element.removeAttribute("disabled");
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
function applyEventListenersToElement(properties: IProperties, element: HTMLElement) {
|
|
250
|
+
//Add the eventListeners to the element
|
|
251
|
+
const clickEventListeners = new Array<IGenericEventListener>();
|
|
252
|
+
const doubleClickEventListeners = new Array<IGenericEventListener>();
|
|
253
|
+
|
|
254
|
+
Object.entries(properties.eventListeners).forEach((entry) => {
|
|
255
|
+
var eventName = entry[0] as keyof IUiElementEventMap;
|
|
256
|
+
var eventListener = entry[1] as IGenericEventListener;
|
|
257
|
+
|
|
258
|
+
if (eventName === "click") {
|
|
259
|
+
clickEventListeners.push(eventListener);
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
if (eventName === "dblclick") {
|
|
263
|
+
doubleClickEventListeners.push(eventListener);
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
if (eventName === "dragstart") {
|
|
268
|
+
element.setAttribute("draggable", "true");
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
if (isGlobalEvent(eventName)) {
|
|
272
|
+
applyEventListenerToElement(
|
|
273
|
+
eventName,
|
|
274
|
+
(event: Event) => {
|
|
275
|
+
if (eventListener.options) {
|
|
276
|
+
const options = eventListener.options as IEventListenerOptions;
|
|
277
|
+
const keyEvent = event as KeyboardEvent;
|
|
278
|
+
if (options.altKey && !keyEvent.altKey) {
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
if (options.shiftKey && !keyEvent.shiftKey) {
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
if (options.ctrlKey && !keyEvent.ctrlKey) {
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
if (options.eventKey && options.eventKey !== keyEvent.key) {
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
eventListener.listener.call(properties, event);
|
|
293
|
+
},
|
|
294
|
+
eventListener.options,
|
|
295
|
+
element
|
|
296
|
+
);
|
|
297
|
+
}
|
|
298
|
+
else if (mouseEvents[eventName] && userAgent.device.supportsMouseEvents) {
|
|
299
|
+
applyEventListenerToElement(eventName, eventListener.listener, eventListener.options, element);
|
|
300
|
+
}
|
|
301
|
+
else if (touchEvents[eventName] && userAgent.device.supportsTouchEvents) {
|
|
302
|
+
applyEventListenerToElement(eventName, eventListener.listener, eventListener.options, element);
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
clickEventListeners.forEach((clickEventListener) => {
|
|
307
|
+
if (userAgent.device.supportsTouchEvents) {
|
|
308
|
+
// ReSharper disable once Html.EventNotResolved
|
|
309
|
+
applyEventListenerToElement("tap", clickEventListener.listener, clickEventListener.options, element);
|
|
310
|
+
}
|
|
311
|
+
if (userAgent.device.supportsMouseEvents) {
|
|
312
|
+
applyEventListenerToElement("click", clickEventListener.listener, clickEventListener.options, element);
|
|
313
|
+
}
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
doubleClickEventListeners.forEach((doubleClickEventListener) => {
|
|
317
|
+
if (userAgent.device.supportsTouchEvents) {
|
|
318
|
+
// ReSharper disable once Html.EventNotResolved
|
|
319
|
+
applyEventListenerToElement("dbltap", doubleClickEventListener.listener, doubleClickEventListener.options, element);
|
|
320
|
+
}
|
|
321
|
+
if (userAgent.device.supportsMouseEvents) {
|
|
322
|
+
applyEventListenerToElement("dblclick", doubleClickEventListener.listener, doubleClickEventListener.options, element);
|
|
323
|
+
}
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
function applyEventListenerToElement(type: keyof IUiElementEventMap, listener: (event: any) => any, options: IEventListenerOptions, element: HTMLElement) {
|
|
328
|
+
if (!type) {
|
|
329
|
+
throw new Error("type is mandatory");
|
|
330
|
+
}
|
|
331
|
+
if (!listener) {
|
|
332
|
+
throw new Error("listener is mandatory");
|
|
333
|
+
}
|
|
334
|
+
if (!options) {
|
|
335
|
+
options = {};
|
|
336
|
+
}
|
|
337
|
+
if (!options.passive) {
|
|
338
|
+
options.passive = false;
|
|
339
|
+
}
|
|
340
|
+
if (!options.once) {
|
|
341
|
+
options.once = false;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
if (element.addEventListener) {
|
|
345
|
+
element.addEventListener(
|
|
346
|
+
type,
|
|
347
|
+
(event) => {
|
|
348
|
+
listener.call(event);
|
|
349
|
+
},
|
|
350
|
+
{
|
|
351
|
+
passive: options.passive,
|
|
352
|
+
once: options.once
|
|
353
|
+
});
|
|
354
|
+
} else if (element["attachEvent"]) {
|
|
355
|
+
element["attachEvent"](
|
|
356
|
+
type,
|
|
357
|
+
(event) => {
|
|
358
|
+
listener(event);
|
|
359
|
+
}
|
|
360
|
+
);
|
|
361
|
+
} else {
|
|
362
|
+
throw "Your browser does not support 'addEventListener'";
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
function applyClassesToElement(classNames: string[], replace: boolean, element: HTMLElement) {
|
|
367
|
+
//If all existing classes need to be replace we reset the classes object to an empty object
|
|
368
|
+
if (replace) {
|
|
369
|
+
element.className = "";
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
//Add all the classNames to the classes object
|
|
373
|
+
if (classNames) {
|
|
374
|
+
classNames.forEach((className) => {
|
|
375
|
+
element.classList.add(className);
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
function applyAttributeToElement(name: keyof IAttributes, value: string, element: HTMLElement) {
|
|
381
|
+
if (isNullOrUndefined(value)) {
|
|
382
|
+
element.removeAttribute(name);
|
|
383
|
+
} else {
|
|
384
|
+
element.setAttribute(name, value);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
function applyFocusToElement(focused: boolean, element: HTMLElement) {
|
|
389
|
+
if (focused) {
|
|
390
|
+
element.focus();
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
//#endregion
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Element } from "./element";
|
|
2
|
+
|
|
3
|
+
export class Root {
|
|
4
|
+
constructor(rootElement: HTMLElement | string) {
|
|
5
|
+
if (rootElement instanceof HTMLElement) {
|
|
6
|
+
this.rootElement = rootElement;
|
|
7
|
+
} else {
|
|
8
|
+
rootElement = document.getElementById(rootElement);
|
|
9
|
+
if (rootElement) {
|
|
10
|
+
this.rootElement = rootElement as any as HTMLElement;
|
|
11
|
+
} else {
|
|
12
|
+
throw "RootElement with id " + rootElement + "not found";
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
private readonly rootElement: HTMLElement;
|
|
19
|
+
private view: Element;
|
|
20
|
+
|
|
21
|
+
render(view: Element) {
|
|
22
|
+
this.unmount();
|
|
23
|
+
|
|
24
|
+
this.view = view;
|
|
25
|
+
this.rootElement.appendChild(view.render());
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
unmount() {
|
|
29
|
+
if (this.view) {
|
|
30
|
+
this.view.unmount();
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
//Remove all children from the root
|
|
34
|
+
if (this.rootElement) {
|
|
35
|
+
this.rootElement.innerHTML = "";
|
|
36
|
+
while (this.rootElement.firstChild) {
|
|
37
|
+
this.rootElement.removeChild(this.rootElement.firstChild);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function createRoot(rootElement: HTMLElement | string): Root {
|
|
44
|
+
return new Root(rootElement);
|
|
45
|
+
}
|