jpf 5.0.62 → 5.0.63
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 +4 -5
- package/dist/controls/codeMirror/Editor/Editor.js +8 -9
- package/dist/controls/codeMirror/Editor/Editor.js.map +1 -1
- package/dist/controls/custom/FileSelector/FileSelector.d.ts +3 -4
- package/dist/controls/custom/FileSelector/FileSelector.js +5 -6
- package/dist/controls/custom/FileSelector/FileSelector.js.map +1 -1
- package/dist/controls/custom/LabeledControl/LabeledControl.d.ts +5 -6
- package/dist/controls/custom/LabeledControl/LabeledControl.js +3 -4
- package/dist/controls/custom/LabeledControl/LabeledControl.js.map +1 -1
- package/dist/controls/custom/ListItem/ListItem.d.ts +8 -9
- package/dist/controls/custom/ListItem/ListItem.js +8 -9
- package/dist/controls/custom/ListItem/ListItem.js.map +1 -1
- package/dist/controls/html/Button/Button.d.ts +6 -7
- package/dist/controls/html/Button/Button.js +8 -9
- package/dist/controls/html/Button/Button.js.map +1 -1
- package/dist/controls/html/Div/Div.d.ts +4 -5
- package/dist/controls/html/Div/Div.js +2 -3
- package/dist/controls/html/Div/Div.js.map +1 -1
- package/dist/controls/html/Image/Image.d.ts +4 -5
- package/dist/controls/html/Image/Image.js +2 -3
- package/dist/controls/html/Image/Image.js.map +1 -1
- package/dist/controls/html/Input/Input.d.ts +4 -5
- package/dist/controls/html/Input/Input.js +23 -23
- package/dist/controls/html/Input/Input.js.map +1 -1
- package/dist/controls/html/Select/Select.d.ts +4 -5
- package/dist/controls/html/Select/Select.js +15 -16
- package/dist/controls/html/Select/Select.js.map +1 -1
- package/dist/controls/html/Span/Span.d.ts +3 -4
- package/dist/controls/html/Span/Span.js +2 -3
- package/dist/controls/html/Span/Span.js.map +1 -1
- package/dist/controls/jsonViewerAwesome/jsonFormatter/JsonFormatter.d.ts +4 -5
- package/dist/controls/jsonViewerAwesome/jsonFormatter/JsonFormatter.js +7 -8
- package/dist/controls/jsonViewerAwesome/jsonFormatter/JsonFormatter.js.map +1 -1
- package/dist/controls/kendo/Chart/Chart.d.ts +3 -4
- package/dist/controls/kendo/Chart/Chart.js +9 -10
- package/dist/controls/kendo/Chart/Chart.js.map +1 -1
- package/dist/controls/kendo/Editor/Editor.d.ts +3 -4
- package/dist/controls/kendo/Editor/Editor.js +13 -14
- package/dist/controls/kendo/Editor/Editor.js.map +1 -1
- package/dist/controls/kendo/Grid/Grid.d.ts +4 -5
- package/dist/controls/kendo/Grid/Grid.js +12 -13
- package/dist/controls/kendo/Grid/Grid.js.map +1 -1
- package/dist/controls/kendo/Menu/Menu.d.ts +3 -4
- package/dist/controls/kendo/Menu/Menu.js +9 -10
- package/dist/controls/kendo/Menu/Menu.js.map +1 -1
- package/dist/controls/kendo/Treeview/Treeview.d.ts +3 -4
- package/dist/controls/kendo/Treeview/Treeview.js +9 -10
- package/dist/controls/kendo/Treeview/Treeview.js.map +1 -1
- package/dist/controls/leaflet/LabelControl/LabelControl.d.ts +2 -3
- package/dist/controls/leaflet/LabelControl/LabelControl.js +1 -2
- package/dist/controls/leaflet/LabelControl/LabelControl.js.map +1 -1
- package/dist/controls/leaflet/Map/Map.d.ts +4 -5
- package/dist/controls/leaflet/Map/Map.js +9 -10
- package/dist/controls/leaflet/Map/Map.js.map +1 -1
- package/dist/controls/svg/Circle/Circle.d.ts +3 -4
- package/dist/controls/svg/Circle/Circle.js +1 -2
- package/dist/controls/svg/Circle/Circle.js.map +1 -1
- package/dist/controls/svg/Ellipse/Ellipse.d.ts +3 -4
- package/dist/controls/svg/Ellipse/Ellipse.js +1 -2
- package/dist/controls/svg/Ellipse/Ellipse.js.map +1 -1
- package/dist/controls/svg/ForeignObject/ForeignObject.d.ts +3 -4
- package/dist/controls/svg/ForeignObject/ForeignObject.js +1 -2
- package/dist/controls/svg/ForeignObject/ForeignObject.js.map +1 -1
- package/dist/controls/svg/Group/Group.d.ts +3 -4
- package/dist/controls/svg/Group/Group.js +1 -2
- package/dist/controls/svg/Group/Group.js.map +1 -1
- package/dist/controls/svg/Line/Line.d.ts +3 -4
- package/dist/controls/svg/Line/Line.js +1 -2
- package/dist/controls/svg/Line/Line.js.map +1 -1
- package/dist/controls/svg/Pattern/Pattern.d.ts +3 -4
- package/dist/controls/svg/Pattern/Pattern.js +1 -2
- package/dist/controls/svg/Pattern/Pattern.js.map +1 -1
- package/dist/controls/svg/Polygon/Polygon.d.ts +3 -4
- package/dist/controls/svg/Polygon/Polygon.js +3 -4
- package/dist/controls/svg/Polygon/Polygon.js.map +1 -1
- package/dist/controls/svg/Polyline/Polyline.d.ts +3 -4
- package/dist/controls/svg/Polyline/Polyline.js +1 -2
- package/dist/controls/svg/Polyline/Polyline.js.map +1 -1
- package/dist/controls/svg/Rectangle/Rectangle.d.ts +3 -4
- package/dist/controls/svg/Rectangle/Rectangle.js +1 -2
- package/dist/controls/svg/Rectangle/Rectangle.js.map +1 -1
- package/dist/controls/svg/Svg/Svg.d.ts +3 -4
- package/dist/controls/svg/Svg/Svg.js +1 -2
- package/dist/controls/svg/Svg/Svg.js.map +1 -1
- package/dist/controls/svg/Text/Text.d.ts +3 -4
- package/dist/controls/svg/Text/Text.js +1 -2
- package/dist/controls/svg/Text/Text.js.map +1 -1
- package/dist/controls/svg/Title/Title.d.ts +3 -4
- package/dist/controls/svg/Title/Title.js +1 -2
- package/dist/controls/svg/Title/Title.js.map +1 -1
- package/dist/controls/svg/svg.d.ts +1 -1
- package/dist/controls/svg/svg.js +5 -5
- package/dist/controls/svg/svg.js.map +1 -1
- package/dist/framework/attributes.d.ts +1 -1
- package/dist/framework/css.d.ts +1 -4
- package/dist/framework/element.d.ts +48 -15
- package/dist/framework/element.js +279 -29
- package/dist/framework/element.js.map +1 -1
- package/dist/framework/observable.d.ts +41 -0
- package/dist/framework/observable.js +46 -0
- package/dist/framework/observable.js.map +1 -0
- package/dist/framework/observablelmplementations.d.ts +1 -24
- package/dist/framework/observablelmplementations.js +0 -110
- package/dist/framework/observablelmplementations.js.map +1 -1
- package/dist/framework/properties.d.ts +1 -40
- package/dist/framework/properties.js +0 -265
- package/dist/framework/properties.js.map +1 -1
- package/dist/framework/style.d.ts +1 -328
- package/dist/index.d.ts +2 -4
- package/dist/index.js +3 -5
- package/dist/index.js.map +1 -1
- package/dist/utilities/object/object.d.ts +5 -0
- package/dist/utilities/object/object.js +47 -0
- package/dist/utilities/object/object.js.map +1 -0
- package/dist/utilities/value/value.d.ts +1 -0
- package/dist/utilities/value/value.js +7 -0
- package/dist/utilities/value/value.js.map +1 -0
- package/package.json +1 -1
- package/src/controls/codeMirror/Editor/Editor.ts +9 -11
- package/src/controls/custom/FileSelector/FileSelector.ts +5 -6
- package/src/controls/custom/LabeledControl/LabeledControl.ts +5 -6
- package/src/controls/custom/ListItem/ListItem.ts +13 -15
- package/src/controls/html/Button/Button.ts +13 -15
- package/src/controls/html/Div/Div.ts +4 -5
- package/src/controls/html/Image/Image.ts +4 -5
- package/src/controls/html/Input/Input.ts +21 -22
- package/src/controls/html/Select/Select.ts +16 -18
- package/src/controls/html/Span/Span.ts +3 -4
- package/src/controls/jsonViewerAwesome/jsonFormatter/JsonFormatter.ts +10 -12
- package/src/controls/kendo/Chart/Chart.ts +17 -19
- package/src/controls/kendo/Editor/Editor.ts +14 -16
- package/src/controls/kendo/Grid/Grid.ts +13 -15
- package/src/controls/kendo/Menu/Menu.ts +11 -13
- package/src/controls/kendo/Treeview/Treeview.ts +9 -11
- package/src/controls/leaflet/LabelControl/LabelControl.ts +4 -5
- package/src/controls/leaflet/Map/Map.ts +10 -12
- package/src/controls/svg/Circle/Circle.ts +3 -4
- package/src/controls/svg/Ellipse/Ellipse.ts +3 -4
- package/src/controls/svg/ForeignObject/ForeignObject.ts +3 -4
- package/src/controls/svg/Group/Group.ts +3 -4
- package/src/controls/svg/Line/Line.ts +3 -4
- package/src/controls/svg/Pattern/Pattern.ts +3 -4
- package/src/controls/svg/Polygon/Polygon.ts +4 -6
- package/src/controls/svg/Polyline/Polyline.ts +3 -4
- package/src/controls/svg/Rectangle/Rectangle.ts +3 -4
- package/src/controls/svg/Svg/Svg.ts +3 -4
- package/src/controls/svg/Text/Text.ts +3 -4
- package/src/controls/svg/Title/Title.ts +3 -4
- package/src/controls/svg/svg.ts +5 -6
- package/src/framework/attributes.ts +1 -47
- package/src/framework/css.ts +3 -5
- package/src/framework/element.ts +380 -44
- package/src/framework/observable.ts +100 -0
- package/src/framework/observablelmplementations.ts +135 -135
- package/src/framework/properties.ts +1 -342
- package/src/framework/style.ts +1556 -1556
- package/src/index.ts +2 -4
- package/src/utilities/object/object.ts +56 -0
- package/src/utilities/value/value.ts +3 -0
- package/src/framework/observableInterfaces.ts +0 -39
|
@@ -1,135 +1,135 @@
|
|
|
1
|
-
import { ISubscribable, IComputed, IObservableValue, IObservableArray, IObservableMap, IObservableSet } from "./observableInterfaces";
|
|
2
|
-
|
|
3
|
-
export const implementations = {
|
|
4
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
5
|
-
unwrap: <TValue>(value: TValue | ISubscribable<TValue>): TValue => {
|
|
6
|
-
throw "Unwrap is not implemented";
|
|
7
|
-
},
|
|
8
|
-
|
|
9
|
-
isComputed: (value): value is IComputed<unknown> => {
|
|
10
|
-
throw "isComputed is not implemented";
|
|
11
|
-
},
|
|
12
|
-
|
|
13
|
-
isObservableValue: (value): value is IObservableValue => {
|
|
14
|
-
throw "isObservableValue is not implemented";
|
|
15
|
-
},
|
|
16
|
-
|
|
17
|
-
isObservableArray: (value): value is IObservableArray => {
|
|
18
|
-
throw "isObservableArray is not implemented";
|
|
19
|
-
},
|
|
20
|
-
|
|
21
|
-
isObservableMap: <TKey, TItem>(value): value is IObservableMap<TKey, TItem> => {
|
|
22
|
-
throw "isObservableMap is not implemented";
|
|
23
|
-
},
|
|
24
|
-
|
|
25
|
-
isObservableSet: <TItem>(value): value is IObservableSet<TItem> => {
|
|
26
|
-
throw "isObservableSet is not implemented";
|
|
27
|
-
},
|
|
28
|
-
|
|
29
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
30
|
-
computed: <TComputed>(func: () => TComputed): IComputed<TComputed> => {
|
|
31
|
-
throw "computed is not implemented";
|
|
32
|
-
},
|
|
33
|
-
|
|
34
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
35
|
-
observableValue: <TValue, TSetter = TValue>(value?: TValue | null, setter?: (value: TSetter, observableValue: IObservableValue<TValue, TSetter>) => void): IObservableValue<TValue, TSetter> => {
|
|
36
|
-
throw "observableValue is not implemented";
|
|
37
|
-
},
|
|
38
|
-
|
|
39
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
40
|
-
observableArray: <TItem = unknown, TSetter = Array<TItem>>(initialValues?: Array<TItem> | null, setter?: (value: TSetter, observableArray: IObservableArray<TItem, TSetter>) => void): IObservableArray<TItem, TSetter> => {
|
|
41
|
-
throw "observableArray is not implemented"
|
|
42
|
-
},
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
46
|
-
observableMap: <TKey = unknown, TItem = unknown>(initialValues?): IObservableMap<TKey, TItem> => {
|
|
47
|
-
throw "observableMap is not implemented"
|
|
48
|
-
},
|
|
49
|
-
|
|
50
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
51
|
-
observableSet: <TItem = unknown>(initialValues): IObservableSet<TItem> => {
|
|
52
|
-
throw "observableMap is not implemented"
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export function unwrap<TValue>(value: TValue | ISubscribable<TValue>): TValue {
|
|
58
|
-
return implementations.unwrap(value);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export function isComputed(value): value is IComputed<unknown> {
|
|
62
|
-
return implementations.isComputed(value);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export function isObservableValue(value): value is IObservableValue {
|
|
66
|
-
return implementations.isObservableValue(value);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export function isObservableArray(value): value is IObservableArray {
|
|
70
|
-
return implementations.isObservableArray(value);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export function isObservableMap<TKey, TItem>(value): value is IObservableMap<TKey, TItem> {
|
|
74
|
-
return implementations.isObservableMap(value);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export function isObservableSet<TItem>(value): value is IObservableSet<TItem> {
|
|
78
|
-
return implementations.isObservableSet(value);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export function computed<TComputed>(func: () => TComputed): IComputed<TComputed> {
|
|
82
|
-
return implementations.computed(func);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export function observableValue<TValue, TSetter = TValue>(value?: TValue | null, setter?: (value: TSetter, observableValue: IObservableValue<TValue, TSetter>) => void): IObservableValue<TValue, TSetter> {
|
|
86
|
-
return implementations.observableValue(value, setter);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
export function isSubscribable<TValue>(value: unknown): value is ISubscribable<TValue> {
|
|
90
|
-
return implementations.isComputed(value)
|
|
91
|
-
|| implementations.isObservableValue(value)
|
|
92
|
-
|| implementations.isObservableArray(value)
|
|
93
|
-
|| implementations.isObservableMap(value)
|
|
94
|
-
|| implementations.isObservableSet(value);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export function executeHandlerOnContext(context: object, handler: (context) => void, alreadyProcessedContexts?: Set<object>) {
|
|
98
|
-
if (!alreadyProcessedContexts) {
|
|
99
|
-
alreadyProcessedContexts = new Set();
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
if (!context || typeof context !== "object" || alreadyProcessedContexts.has(context)) {
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
//Add the context to the alreadyProcessedContext to prevent processing the same object twice.
|
|
107
|
-
alreadyProcessedContexts.add(context);
|
|
108
|
-
|
|
109
|
-
//Find out if the object is an array
|
|
110
|
-
if (Array.isArray(context)) {
|
|
111
|
-
for (const arrayEntry of context as Array<unknown>) {
|
|
112
|
-
if (typeof arrayEntry === "object") {
|
|
113
|
-
executeHandlerOnContext(arrayEntry, handler, alreadyProcessedContexts);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
} else {
|
|
117
|
-
if (isSubscribable(context)) {
|
|
118
|
-
const unwrapped = unwrap(context);
|
|
119
|
-
if (typeof unwrapped === "object") {
|
|
120
|
-
executeHandlerOnContext(unwrapped, handler, alreadyProcessedContexts);
|
|
121
|
-
}
|
|
122
|
-
} else {
|
|
123
|
-
//Call the handler on the object.
|
|
124
|
-
handler(context);
|
|
125
|
-
|
|
126
|
-
//Find out if the object has properties of type object
|
|
127
|
-
for (const key of Object.keys(context)) {
|
|
128
|
-
const property = context[key];
|
|
129
|
-
if (property && typeof property === "object") {
|
|
130
|
-
executeHandlerOnContext(property, handler, alreadyProcessedContexts);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
}
|
|
1
|
+
//import { ISubscribable, IComputed, IObservableValue, IObservableArray, IObservableMap, IObservableSet } from "./observableInterfaces";
|
|
2
|
+
|
|
3
|
+
//export const implementations = {
|
|
4
|
+
// // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
5
|
+
// unwrap: <TValue>(value: TValue | ISubscribable<TValue>): TValue => {
|
|
6
|
+
// throw "Unwrap is not implemented";
|
|
7
|
+
// },
|
|
8
|
+
|
|
9
|
+
// isComputed: (value): value is IComputed<unknown> => {
|
|
10
|
+
// throw "isComputed is not implemented";
|
|
11
|
+
// },
|
|
12
|
+
|
|
13
|
+
// isObservableValue: (value): value is IObservableValue => {
|
|
14
|
+
// throw "isObservableValue is not implemented";
|
|
15
|
+
// },
|
|
16
|
+
|
|
17
|
+
// isObservableArray: (value): value is IObservableArray => {
|
|
18
|
+
// throw "isObservableArray is not implemented";
|
|
19
|
+
// },
|
|
20
|
+
|
|
21
|
+
// isObservableMap: <TKey, TItem>(value): value is IObservableMap<TKey, TItem> => {
|
|
22
|
+
// throw "isObservableMap is not implemented";
|
|
23
|
+
// },
|
|
24
|
+
|
|
25
|
+
// isObservableSet: <TItem>(value): value is IObservableSet<TItem> => {
|
|
26
|
+
// throw "isObservableSet is not implemented";
|
|
27
|
+
// },
|
|
28
|
+
|
|
29
|
+
// // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
30
|
+
// computed: <TComputed>(func: () => TComputed): IComputed<TComputed> => {
|
|
31
|
+
// throw "computed is not implemented";
|
|
32
|
+
// },
|
|
33
|
+
|
|
34
|
+
// // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
35
|
+
// observableValue: <TValue, TSetter = TValue>(value?: TValue | null, setter?: (value: TSetter, observableValue: IObservableValue<TValue, TSetter>) => void): IObservableValue<TValue, TSetter> => {
|
|
36
|
+
// throw "observableValue is not implemented";
|
|
37
|
+
// },
|
|
38
|
+
|
|
39
|
+
// // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
40
|
+
// observableArray: <TItem = unknown, TSetter = Array<TItem>>(initialValues?: Array<TItem> | null, setter?: (value: TSetter, observableArray: IObservableArray<TItem, TSetter>) => void): IObservableArray<TItem, TSetter> => {
|
|
41
|
+
// throw "observableArray is not implemented"
|
|
42
|
+
// },
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
// // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
46
|
+
// observableMap: <TKey = unknown, TItem = unknown>(initialValues?): IObservableMap<TKey, TItem> => {
|
|
47
|
+
// throw "observableMap is not implemented"
|
|
48
|
+
// },
|
|
49
|
+
|
|
50
|
+
// // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
51
|
+
// observableSet: <TItem = unknown>(initialValues): IObservableSet<TItem> => {
|
|
52
|
+
// throw "observableMap is not implemented"
|
|
53
|
+
// }
|
|
54
|
+
|
|
55
|
+
//}
|
|
56
|
+
|
|
57
|
+
//export function unwrap<TValue>(value: TValue | ISubscribable<TValue>): TValue {
|
|
58
|
+
// return implementations.unwrap(value);
|
|
59
|
+
//}
|
|
60
|
+
|
|
61
|
+
//export function isComputed(value): value is IComputed<unknown> {
|
|
62
|
+
// return implementations.isComputed(value);
|
|
63
|
+
//}
|
|
64
|
+
|
|
65
|
+
//export function isObservableValue(value): value is IObservableValue {
|
|
66
|
+
// return implementations.isObservableValue(value);
|
|
67
|
+
//}
|
|
68
|
+
|
|
69
|
+
//export function isObservableArray(value): value is IObservableArray {
|
|
70
|
+
// return implementations.isObservableArray(value);
|
|
71
|
+
//}
|
|
72
|
+
|
|
73
|
+
//export function isObservableMap<TKey, TItem>(value): value is IObservableMap<TKey, TItem> {
|
|
74
|
+
// return implementations.isObservableMap(value);
|
|
75
|
+
//}
|
|
76
|
+
|
|
77
|
+
//export function isObservableSet<TItem>(value): value is IObservableSet<TItem> {
|
|
78
|
+
// return implementations.isObservableSet(value);
|
|
79
|
+
//}
|
|
80
|
+
|
|
81
|
+
//export function computed<TComputed>(func: () => TComputed): IComputed<TComputed> {
|
|
82
|
+
// return implementations.computed(func);
|
|
83
|
+
//}
|
|
84
|
+
|
|
85
|
+
//export function observableValue<TValue, TSetter = TValue>(value?: TValue | null, setter?: (value: TSetter, observableValue: IObservableValue<TValue, TSetter>) => void): IObservableValue<TValue, TSetter> {
|
|
86
|
+
// return implementations.observableValue(value, setter);
|
|
87
|
+
//}
|
|
88
|
+
|
|
89
|
+
//export function isSubscribable<TValue>(value: unknown): value is ISubscribable<TValue> {
|
|
90
|
+
// return implementations.isComputed(value)
|
|
91
|
+
// || implementations.isObservableValue(value)
|
|
92
|
+
// || implementations.isObservableArray(value)
|
|
93
|
+
// || implementations.isObservableMap(value)
|
|
94
|
+
// || implementations.isObservableSet(value);
|
|
95
|
+
//}
|
|
96
|
+
|
|
97
|
+
//export function executeHandlerOnContext(context: object, handler: (context) => void, alreadyProcessedContexts?: Set<object>) {
|
|
98
|
+
// if (!alreadyProcessedContexts) {
|
|
99
|
+
// alreadyProcessedContexts = new Set();
|
|
100
|
+
// }
|
|
101
|
+
|
|
102
|
+
// if (!context || typeof context !== "object" || alreadyProcessedContexts.has(context)) {
|
|
103
|
+
// return;
|
|
104
|
+
// }
|
|
105
|
+
|
|
106
|
+
// //Add the context to the alreadyProcessedContext to prevent processing the same object twice.
|
|
107
|
+
// alreadyProcessedContexts.add(context);
|
|
108
|
+
|
|
109
|
+
// //Find out if the object is an array
|
|
110
|
+
// if (Array.isArray(context)) {
|
|
111
|
+
// for (const arrayEntry of context as Array<unknown>) {
|
|
112
|
+
// if (typeof arrayEntry === "object") {
|
|
113
|
+
// executeHandlerOnContext(arrayEntry, handler, alreadyProcessedContexts);
|
|
114
|
+
// }
|
|
115
|
+
// }
|
|
116
|
+
// } else {
|
|
117
|
+
// if (isSubscribable(context)) {
|
|
118
|
+
// const unwrapped = unwrap(context);
|
|
119
|
+
// if (typeof unwrapped === "object") {
|
|
120
|
+
// executeHandlerOnContext(unwrapped, handler, alreadyProcessedContexts);
|
|
121
|
+
// }
|
|
122
|
+
// } else {
|
|
123
|
+
// //Call the handler on the object.
|
|
124
|
+
// handler(context);
|
|
125
|
+
|
|
126
|
+
// //Find out if the object has properties of type object
|
|
127
|
+
// for (const key of Object.keys(context)) {
|
|
128
|
+
// const property = context[key];
|
|
129
|
+
// if (property && typeof property === "object") {
|
|
130
|
+
// executeHandlerOnContext(property, handler, alreadyProcessedContexts);
|
|
131
|
+
// }
|
|
132
|
+
// }
|
|
133
|
+
// }
|
|
134
|
+
// }
|
|
135
|
+
//}
|
|
@@ -1,344 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
import { IAttributes } from "./attributes";
|
|
3
|
-
import { IStyle as Style, IStyleSubscribable as StyleSubscribable } from "./style";
|
|
4
|
-
import { ISubscribable, IDisposer } from "./observableInterfaces";
|
|
5
|
-
import { isSubscribable, unwrap, executeHandlerOnContext } from "./observablelmplementations";
|
|
1
|
+
|
|
6
2
|
|
|
7
|
-
export interface IWebSocketMessageHandler {
|
|
8
|
-
handleWebSocketMessage: (message: unknown) => void;
|
|
9
|
-
}
|
|
10
3
|
|
|
11
|
-
export interface IProperties {
|
|
12
|
-
attributes?: IAttributes;
|
|
13
|
-
classNames?: Array<string> | ISubscribable<Array<string>>;
|
|
14
|
-
style?: Style | StyleSubscribable;
|
|
15
|
-
visible?: boolean | ISubscribable<boolean>;
|
|
16
|
-
disabled?: boolean | ISubscribable<boolean>;
|
|
17
|
-
innerHtml?: string | ISubscribable<string>;
|
|
18
|
-
textContent?: string | ISubscribable<string>;
|
|
19
|
-
addViewModelToDataObject?: boolean;
|
|
20
|
-
userSelectable?: boolean;
|
|
21
|
-
eventListeners?: Array<IEventListener>;
|
|
22
|
-
elementType?: string;
|
|
23
|
-
focused?: boolean | ISubscribable<boolean>;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export abstract class Properties implements IProperties {
|
|
27
|
-
protected setProperties<TProperties>(object: object, properties?: TProperties) {
|
|
28
|
-
if (properties) {
|
|
29
|
-
Object.keys(properties).forEach((property) => {
|
|
30
|
-
object[property] = properties[property];
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
attributes?: IAttributes;
|
|
36
|
-
classNames?: Array<string> | ISubscribable<Array<string>>;
|
|
37
|
-
style?: Style | StyleSubscribable;
|
|
38
|
-
visible?: boolean | ISubscribable<boolean>;
|
|
39
|
-
disabled?: boolean | ISubscribable<boolean>;
|
|
40
|
-
innerHtml?: string | ISubscribable<string>;
|
|
41
|
-
textContent?: string | ISubscribable<string>;
|
|
42
|
-
addViewModelToDataObject?: boolean;
|
|
43
|
-
userSelectable?: boolean;
|
|
44
|
-
eventListeners?: Array<IEventListener>;
|
|
45
|
-
elementType?: string;
|
|
46
|
-
focused?: boolean | ISubscribable<boolean>;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
//#region Properties helper functions
|
|
50
|
-
|
|
51
|
-
export function handleWebSocketMessage(context: object, message: unknown) {
|
|
52
|
-
executeHandlerOnContext(
|
|
53
|
-
context,
|
|
54
|
-
(context) => {
|
|
55
|
-
const webSocketMessageHandler = context as IWebSocketMessageHandler;
|
|
56
|
-
if (webSocketMessageHandler.handleWebSocketMessage && typeof webSocketMessageHandler.handleWebSocketMessage === "function") {
|
|
57
|
-
//Call the handleWebSocketMessage method
|
|
58
|
-
webSocketMessageHandler.handleWebSocketMessage(message);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export function isNullOrUndefined(value): boolean {
|
|
65
|
-
return value === null || typeof value === "undefined";
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export function extendProperties<TTarget = IProperties, TOverwritingProperties = TTarget, TPreserveExistingProperties = TTarget>(target: TTarget, preserveExisting: TPreserveExistingProperties, overWriteExisting?: TOverwritingProperties): TTarget {
|
|
69
|
-
if (overWriteExisting || preserveExisting) {
|
|
70
|
-
target = target || {} as TTarget;
|
|
71
|
-
|
|
72
|
-
if (typeof preserveExisting === "object") {
|
|
73
|
-
Object.keys(preserveExisting).forEach((key) => {
|
|
74
|
-
//Check if the target object does not already have a property with the given key
|
|
75
|
-
if (!target.hasOwnProperty(key) || typeof target[key] === "undefined") {
|
|
76
|
-
target[key] = preserveExisting[key];
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
if (typeof overWriteExisting === "object") {
|
|
82
|
-
Object.keys(overWriteExisting).forEach((key) => {
|
|
83
|
-
target[key] = overWriteExisting[key];
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
return target;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
//Functions to bind the Properties to a html element
|
|
92
|
-
export function applyBindings(properties: IProperties, element: HTMLElement, disposers: Array<IDisposer>) {
|
|
93
|
-
element.setAttribute("elementtype", properties.elementType || "Element");
|
|
94
|
-
|
|
95
|
-
if (properties.classNames) {
|
|
96
|
-
applyClassesToElement(unwrap(properties.classNames), true, element);
|
|
97
|
-
if (isSubscribable(properties.classNames)) {
|
|
98
|
-
const disposer = properties.classNames.subscribe((classNames) => {
|
|
99
|
-
applyClassesToElement(classNames, true, element);
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
if (disposers) {
|
|
103
|
-
disposers.push(disposer);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
if (properties.attributes) {
|
|
109
|
-
Object.keys(properties.attributes).forEach((key) => {
|
|
110
|
-
const value = properties.attributes[key];
|
|
111
|
-
applyAttributeToElement(key as keyof IAttributes, unwrap(value), element);
|
|
112
|
-
|
|
113
|
-
if (isSubscribable(value)) {
|
|
114
|
-
const disposer = value.subscribe((value: string) => {
|
|
115
|
-
applyAttributeToElement(key as keyof IAttributes, value, element);
|
|
116
|
-
});
|
|
117
|
-
if (disposers) {
|
|
118
|
-
disposers.push(disposer);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
if (properties.style) {
|
|
125
|
-
Object.keys(properties.style).forEach((key) => {
|
|
126
|
-
const style = properties.style[key];
|
|
127
|
-
|
|
128
|
-
element.style[key] = unwrap(style);
|
|
129
|
-
if (isSubscribable(style)) {
|
|
130
|
-
const disposer = style.subscribe((style) => {
|
|
131
|
-
element.style[key] = style;
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
if (disposers) {
|
|
135
|
-
disposers.push(disposer);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
if (!isNullOrUndefined(properties.innerHtml)) {
|
|
142
|
-
|
|
143
|
-
element.innerHTML = unwrap(properties.innerHtml);
|
|
144
|
-
|
|
145
|
-
if (isSubscribable(properties.innerHtml)) {
|
|
146
|
-
const disposer = properties.innerHtml.subscribe((innerHtml: string) => {
|
|
147
|
-
element.innerHTML = innerHtml;
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
if (disposers) {
|
|
151
|
-
disposers.push(disposer);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
if (!isNullOrUndefined(properties.textContent)) {
|
|
157
|
-
|
|
158
|
-
const textContent = unwrap(properties.textContent);
|
|
159
|
-
|
|
160
|
-
if (element.hasChildNodes() && element.childNodes.length === 1 && element.childNodes[0].nodeType === 3) {
|
|
161
|
-
element.firstChild.nodeValue = textContent;
|
|
162
|
-
} else {
|
|
163
|
-
element.textContent = unwrap(properties.textContent);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
if (isSubscribable(properties.textContent)) {
|
|
167
|
-
const disposer = properties.textContent.subscribe((textContent) => {
|
|
168
|
-
if (element.hasChildNodes() && element.childNodes.length === 1 && element.childNodes[0].nodeType === 3) {
|
|
169
|
-
element.firstChild.nodeValue = textContent;
|
|
170
|
-
} else {
|
|
171
|
-
element.textContent = unwrap(properties.textContent);
|
|
172
|
-
}
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
if (disposers) {
|
|
176
|
-
disposers.push(disposer);
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
//Find out if the element is none selectable
|
|
182
|
-
if (properties.userSelectable === false) {
|
|
183
|
-
applyEventListenerToElement({
|
|
184
|
-
type: Event,
|
|
185
|
-
name: "selectstart",
|
|
186
|
-
handler: () => { return false; },
|
|
187
|
-
passive: true
|
|
188
|
-
},
|
|
189
|
-
element
|
|
190
|
-
);
|
|
191
|
-
element.style.userSelect = "none";
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
if (properties.addViewModelToDataObject) {
|
|
195
|
-
if (!element["data"]) {
|
|
196
|
-
element["data"] = {};
|
|
197
|
-
}
|
|
198
|
-
element["data"].viewModel = properties;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
if (properties.eventListeners) {
|
|
202
|
-
applyEventListenersToElement(properties.eventListeners, element);
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
applyVisibilityToElement(unwrap(properties.visible), element);
|
|
206
|
-
if (isSubscribable(properties.visible)) {
|
|
207
|
-
const disposer = properties.visible.subscribe((visible) => {
|
|
208
|
-
applyVisibilityToElement(visible, element);
|
|
209
|
-
});
|
|
210
|
-
|
|
211
|
-
if (disposers) {
|
|
212
|
-
disposers.push(disposer);
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
applyDisabledToElement(unwrap(properties.disabled), element);
|
|
217
|
-
if (isSubscribable(properties.disabled)) {
|
|
218
|
-
const disposer = properties.disabled.subscribe((disabled) => {
|
|
219
|
-
applyDisabledToElement(disabled, element);
|
|
220
|
-
});
|
|
221
|
-
|
|
222
|
-
if (disposers) {
|
|
223
|
-
disposers.push(disposer);
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
applyFocusToElement(unwrap(properties.focused), element);
|
|
228
|
-
if (isSubscribable(properties.focused)) {
|
|
229
|
-
const disposer = properties.focused.subscribe((focused) => {
|
|
230
|
-
applyFocusToElement(focused, element);
|
|
231
|
-
});
|
|
232
|
-
|
|
233
|
-
if (disposers) {
|
|
234
|
-
disposers.push(disposer);
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
function applyVisibilityToElement(visible: boolean, element: HTMLElement) {
|
|
240
|
-
if (visible === false) {
|
|
241
|
-
element.classList.add("hidden");
|
|
242
|
-
} else {
|
|
243
|
-
element.classList.remove("hidden");
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
function applyDisabledToElement(disabled: boolean, element: HTMLElement) {
|
|
248
|
-
if (disabled) {
|
|
249
|
-
element.setAttribute("disabled", "disabled");
|
|
250
|
-
} else {
|
|
251
|
-
element.removeAttribute("disabled");
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
function applyEventListenersToElement(eventListeners: Array<IEventListener>, element: HTMLElement) {
|
|
256
|
-
if (!element.addEventListener) {
|
|
257
|
-
throw new Error("Your browser does not support addEventListener");
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
if (eventListeners) {
|
|
261
|
-
eventListeners.forEach((eventListener) => {
|
|
262
|
-
applyEventListenerToElement(eventListener, element);
|
|
263
|
-
});
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
function applyEventListenerToElement(eventListener: IEventListener, element: HTMLElement) {
|
|
268
|
-
const type = eventListener.type;
|
|
269
|
-
const name = eventListener.name;
|
|
270
|
-
let handler = eventListener.handler;
|
|
271
|
-
const options: AddEventListenerOptions = {
|
|
272
|
-
passive: eventListener.passive || false,
|
|
273
|
-
once: eventListener.once || false
|
|
274
|
-
};
|
|
275
|
-
|
|
276
|
-
if (!type) {
|
|
277
|
-
throw new Error("type is mandatory");
|
|
278
|
-
}
|
|
279
|
-
if (!name) {
|
|
280
|
-
throw new Error("name is mandatory");
|
|
281
|
-
}
|
|
282
|
-
if (!handler) {
|
|
283
|
-
throw new Error("handler is mandatory");
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
if (name === "dragstart") {
|
|
287
|
-
element.setAttribute("draggable", "true");
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
if (eventListener.type === KeyboardEvent) {
|
|
291
|
-
handler = (event: KeyboardEvent) => {
|
|
292
|
-
if (eventListener.altKey && !event.altKey) {
|
|
293
|
-
return;
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
if (eventListener.shiftKey && !event.shiftKey) {
|
|
297
|
-
return;
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
if (eventListener.ctrlKey && !event.ctrlKey) {
|
|
301
|
-
return;
|
|
302
|
-
}
|
|
303
|
-
if (eventListener.key && eventListener.key !== event.key) {
|
|
304
|
-
return;
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
handler(event);
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
//Add the event listener to the element
|
|
313
|
-
element.addEventListener(name, handler, options);
|
|
314
|
-
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
function applyClassesToElement(classNames: string[], replace: boolean, element: HTMLElement) {
|
|
318
|
-
//If all existing classes need to be replace we reset the classes object to an empty object
|
|
319
|
-
if (replace) {
|
|
320
|
-
element.className = "";
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
//Add all the classNames to the classes object
|
|
324
|
-
if (classNames) {
|
|
325
|
-
classNames.forEach((className) => {
|
|
326
|
-
element.classList.add(className);
|
|
327
|
-
});
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
function applyAttributeToElement(name: keyof IAttributes, value: string, element: HTMLElement) {
|
|
332
|
-
if (isNullOrUndefined(value)) {
|
|
333
|
-
element.removeAttribute(name);
|
|
334
|
-
} else {
|
|
335
|
-
element.setAttribute(name, value);
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
function applyFocusToElement(focused: boolean, element: HTMLElement) {
|
|
340
|
-
if (focused) {
|
|
341
|
-
element.focus();
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
//#endregion
|