jpf 4.2.14 → 4.2.16
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/kendo/Menu/Menu.js.map +1 -1
- package/dist/framework/ViewModel.js +5 -3
- package/dist/framework/ViewModel.js.map +1 -1
- package/package.json +2 -1
- package/src/controls/codeMirror/HtmlEditor/HtmlEditor.ts +149 -0
- package/src/controls/codeMirror/JsonEditor/JsonEditor.ts +132 -0
- package/src/controls/codeMirror/index.ts +2 -0
- package/src/controls/custom/FileSelector/FileSelector.ts +70 -0
- package/src/controls/custom/LabeledControl/LabeledControl.ts +54 -0
- package/src/controls/custom/ListItem/ListItem.ts +91 -0
- package/src/controls/custom/index.ts +3 -0
- package/src/controls/html/Button/Button.ts +66 -0
- package/src/controls/html/Div/Div.ts +37 -0
- package/src/controls/html/Image/Image.ts +42 -0
- package/src/controls/html/Input/Input.ts +223 -0
- package/src/controls/html/Select/Select.ts +142 -0
- package/src/controls/html/Span/Span.ts +35 -0
- package/src/controls/html/index.ts +6 -0
- package/src/controls/index.ts +15 -0
- package/src/controls/jsonViewAwesome/index.ts +1 -0
- package/src/controls/jsonViewAwesome/jsonFormatter/JsonFormatter.ts +87 -0
- package/src/controls/kendo/Chart/Chart.ts +97 -0
- package/src/controls/kendo/Culture/Culture.ts +32 -0
- package/src/controls/kendo/DataSource/DataSource.ts +4 -0
- package/src/controls/kendo/Dialog/Dialog.ts +64 -0
- package/src/controls/kendo/Editor/Editor.ts +138 -0
- package/src/controls/kendo/Grid/Grid.ts +286 -0
- package/src/controls/kendo/Menu/Menu.ts +125 -0
- package/src/controls/kendo/ObservableObject/ObservableObject.ts +45 -0
- package/src/controls/kendo/Tree/Tree.ts +147 -0
- package/src/controls/kendo/index.ts +9 -0
- package/src/controls/leaflet/LabelControl/LabelControl.ts +42 -0
- package/src/controls/leaflet/Map/Map.ts +177 -0
- package/src/controls/leaflet/OpenStreetMapTileLayer/OpenStreetMapTileLayer.ts +19 -0
- package/src/controls/leaflet/PointerEvent/PointerEvent.ts +9 -0
- package/src/controls/leaflet/index.ts +4 -0
- package/src/controls/svg/Circle/Circle.ts +34 -0
- package/src/controls/svg/Ellipse/Ellipse.ts +36 -0
- package/src/controls/svg/ForeignObject/ForeignObject.ts +38 -0
- package/src/controls/svg/Group/Group.ts +38 -0
- package/src/controls/svg/Line/Line.ts +36 -0
- package/src/controls/svg/Pattern/Pattern.ts +49 -0
- package/src/controls/svg/Polygon/Polygon.ts +31 -0
- package/src/controls/svg/Polyline/Polyline.ts +31 -0
- package/src/controls/svg/Rectangle/Rectangle.ts +36 -0
- package/src/controls/svg/Svg/Svg.ts +43 -0
- package/src/controls/svg/Text/Text.ts +38 -0
- package/src/controls/svg/Title/Title.ts +28 -0
- package/src/controls/svg/index.ts +13 -0
- package/src/controls/svg/svg.ts +20 -0
- package/src/framework/View.ts +213 -0
- package/src/framework/ViewModel.ts +525 -0
- package/src/framework/attributes.ts +92 -0
- package/src/framework/event.ts +98 -0
- package/src/framework/observable.ts +80 -0
- package/src/framework/style.ts +3271 -0
- package/src/framework/types.ts +277 -0
- package/src/framework/userAgent.ts +51 -0
- package/src/index.ts +14 -0
- package/src/utilities/blob/blob.ts +19 -0
- package/src/utilities/cookie/cookie.ts +28 -0
- package/src/utilities/dataReaderTable/dataReaderTable.ts +34 -0
- package/src/utilities/fetch/fetch.ts +179 -0
- package/src/utilities/float/float.ts +3 -0
- package/src/utilities/formData/formData.ts +12 -0
- package/src/utilities/html/html.ts +8 -0
- package/src/utilities/htmlElement/htmlElement.ts +15 -0
- package/src/utilities/image/image.ts +1 -0
- package/src/utilities/index.ts +37 -0
- package/src/utilities/integer/integer.ts +31 -0
- package/src/utilities/key/key.ts +7 -0
- package/src/utilities/navigator/navigator.ts +7 -0
- package/src/utilities/notification/notification.ts +88 -0
- package/src/utilities/querystring/querystring.ts +61 -0
- package/src/utilities/router/router.ts +124 -0
- package/src/utilities/stylesheet/stylesheet.ts +58 -0
- package/src/utilities/uniqueId/uniqueId.ts +5 -0
- package/src/utilities/webSocket/webSocket.ts +72 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { View, IView, registerView } from "../../../framework/View";
|
|
2
|
+
import { Properties , extendProperties, ViewModel } from "../../../framework/ViewModel";
|
|
3
|
+
import { Subscribable } from "knockout";
|
|
4
|
+
|
|
5
|
+
export interface DivProperties extends Properties {
|
|
6
|
+
children?: Array<IView> | Subscribable<Array<IView>>;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export class DivView extends View<DivProperties> {
|
|
10
|
+
constructor(properties: DivProperties) {
|
|
11
|
+
super(
|
|
12
|
+
{
|
|
13
|
+
tagName: "div",
|
|
14
|
+
properties: extendProperties(
|
|
15
|
+
{
|
|
16
|
+
viewType: "Div"
|
|
17
|
+
},
|
|
18
|
+
properties
|
|
19
|
+
),
|
|
20
|
+
children: properties.children
|
|
21
|
+
},
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function divView(properties: DivProperties): DivView {
|
|
27
|
+
return new DivView(properties);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export class DivViewModel extends ViewModel<DivProperties> implements DivProperties{
|
|
31
|
+
children?: Array<IView> | Subscribable<Array<IView>>;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
registerView(
|
|
35
|
+
DivViewModel,
|
|
36
|
+
DivView
|
|
37
|
+
)
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { View, registerView } from "../../../framework/View";
|
|
2
|
+
import { ViewModel, Properties, extendProperties } from "../../../framework/ViewModel";
|
|
3
|
+
import { Subscribable } from "knockout";
|
|
4
|
+
|
|
5
|
+
export interface ImageProperties extends Properties {
|
|
6
|
+
src: string | Subscribable<string>;
|
|
7
|
+
alt: string | Subscribable<string>;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export class ImageView extends View<ImageProperties> {
|
|
11
|
+
constructor(properties: ImageProperties) {
|
|
12
|
+
super(
|
|
13
|
+
{
|
|
14
|
+
tagName: "img",
|
|
15
|
+
properties: extendProperties(
|
|
16
|
+
{
|
|
17
|
+
viewType: "Image",
|
|
18
|
+
attributes: {
|
|
19
|
+
src: properties.src,
|
|
20
|
+
alt: properties.alt
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
properties
|
|
24
|
+
)
|
|
25
|
+
}
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function imageView(properties: ImageProperties) {
|
|
31
|
+
return new ImageView(properties);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export class ImageViewModel extends ViewModel<ImageProperties> implements ImageProperties{
|
|
35
|
+
src: string | Subscribable<string>;
|
|
36
|
+
alt: string | Subscribable<string>;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
registerView(
|
|
40
|
+
ImageViewModel,
|
|
41
|
+
ImageView
|
|
42
|
+
);
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import { isSubscribable, unwrap, isObservable } from "knockout";
|
|
2
|
+
import { View, registerView } from "../../../framework/View";
|
|
3
|
+
import { ViewModel, Properties, extendProperties, isNullOrUndefined } from "../../../framework/ViewModel";
|
|
4
|
+
import { ObservableProperty, observableProperty, isObservableProperty } from "../../../framework/observable";
|
|
5
|
+
import { isInteger } from "../../../utilities/integer/integer";
|
|
6
|
+
import { isFloat } from "../../../utilities/float/float";
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
export type InputType = "text" | "checkbox" | "file" | "integer" | "float" | "range" | "radio";
|
|
10
|
+
|
|
11
|
+
export enum ValueUpdateModeEnum {
|
|
12
|
+
OnChange = 1,
|
|
13
|
+
OnInput = 2
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface InputProperties<TValue> extends Properties {
|
|
17
|
+
value?: TValue | ObservableProperty<TValue>;
|
|
18
|
+
inputValidator?: (event: Event, inputViewModel: InputProperties<TValue>, value: string) => Promise<boolean>;
|
|
19
|
+
placeholder?: string | ObservableProperty<string>;
|
|
20
|
+
valueUpdateMode?: ValueUpdateModeEnum;
|
|
21
|
+
min?: number;
|
|
22
|
+
max?: number;
|
|
23
|
+
step?: number;
|
|
24
|
+
type?: InputType;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export class InputView<TValue> extends View<InputProperties<TValue>> {
|
|
28
|
+
constructor(properties: InputProperties<TValue>) {
|
|
29
|
+
super(
|
|
30
|
+
{
|
|
31
|
+
tagName: "input",
|
|
32
|
+
properties: extendProperties(
|
|
33
|
+
{
|
|
34
|
+
viewType: "Input"
|
|
35
|
+
},
|
|
36
|
+
properties
|
|
37
|
+
)
|
|
38
|
+
}
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
//Protected members
|
|
43
|
+
protected build() {
|
|
44
|
+
super.build();
|
|
45
|
+
|
|
46
|
+
const element = this.element;
|
|
47
|
+
const viewModel = this.properties;
|
|
48
|
+
if (!viewModel.valueUpdateMode) {
|
|
49
|
+
viewModel.valueUpdateMode = ValueUpdateModeEnum.OnChange;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const input = this.element as HTMLInputElement;
|
|
53
|
+
input.type = viewModel.type;
|
|
54
|
+
|
|
55
|
+
if (!isNullOrUndefined(viewModel.min)) {
|
|
56
|
+
input.min = viewModel.min as any;
|
|
57
|
+
}
|
|
58
|
+
if (!isNullOrUndefined(viewModel.max)) {
|
|
59
|
+
input.max = viewModel.max as any;
|
|
60
|
+
}
|
|
61
|
+
if (!isNullOrUndefined(viewModel.step)) {
|
|
62
|
+
input.step = viewModel.step as any;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
switch (viewModel.type) {
|
|
66
|
+
case "checkbox":
|
|
67
|
+
input.checked = unwrap(viewModel.value) as unknown as boolean;
|
|
68
|
+
if (isObservable(viewModel.value)) {
|
|
69
|
+
this.subscriptions.push(
|
|
70
|
+
viewModel.value.subscribe((value: TValue) => {
|
|
71
|
+
input.checked = value as unknown as boolean;
|
|
72
|
+
})
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
break;
|
|
77
|
+
|
|
78
|
+
case "file":
|
|
79
|
+
//An input type file can not be set.
|
|
80
|
+
break;
|
|
81
|
+
|
|
82
|
+
case "radio":
|
|
83
|
+
input.checked = input.value === unwrap(viewModel.value);
|
|
84
|
+
if (isSubscribable(viewModel.value)) {
|
|
85
|
+
this.subscriptions.push(
|
|
86
|
+
viewModel.value.subscribe((value) => {
|
|
87
|
+
input.checked = input.value === (value as any as string);
|
|
88
|
+
})
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
break;
|
|
92
|
+
|
|
93
|
+
default:
|
|
94
|
+
const value = unwrap(viewModel.value);
|
|
95
|
+
if (value) {
|
|
96
|
+
input.value = value as unknown as string;
|
|
97
|
+
}
|
|
98
|
+
if (isObservable(viewModel.value)) {
|
|
99
|
+
this.subscriptions.push(
|
|
100
|
+
viewModel.value.subscribe((value: TValue) => {
|
|
101
|
+
input.value = value as unknown as string;
|
|
102
|
+
})
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const placeholder = unwrap(viewModel.placeholder) as unknown as string;
|
|
108
|
+
if (placeholder) {
|
|
109
|
+
input.placeholder = placeholder;
|
|
110
|
+
}
|
|
111
|
+
if (isSubscribable(viewModel.placeholder)) {
|
|
112
|
+
this.subscriptions.push(
|
|
113
|
+
viewModel.placeholder.subscribe((placeholder) => {
|
|
114
|
+
if (placeholder) {
|
|
115
|
+
input.placeholder = placeholder;
|
|
116
|
+
} else {
|
|
117
|
+
input.removeAttribute("placeholder");
|
|
118
|
+
}
|
|
119
|
+
})
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (this.properties.valueUpdateMode === ValueUpdateModeEnum.OnChange) {
|
|
124
|
+
this.element.addEventListener(
|
|
125
|
+
"change",
|
|
126
|
+
handleEvent
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (this.properties.valueUpdateMode === ValueUpdateModeEnum.OnInput || viewModel.inputValidator) {
|
|
131
|
+
this.element.addEventListener(
|
|
132
|
+
"input",
|
|
133
|
+
handleEvent
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
async function handleEvent(event: Event) {
|
|
138
|
+
let newValue = null;
|
|
139
|
+
switch (viewModel.type) {
|
|
140
|
+
case "checkbox":
|
|
141
|
+
newValue = input.checked;
|
|
142
|
+
break;
|
|
143
|
+
|
|
144
|
+
case "file":
|
|
145
|
+
newValue = input.files;
|
|
146
|
+
break;
|
|
147
|
+
|
|
148
|
+
case "radio":
|
|
149
|
+
const name = element.getAttribute("name");
|
|
150
|
+
if (name) {
|
|
151
|
+
const selectedRadioButton = document.querySelector("input[type='radio'][name='" + name + "']:checked") as HTMLInputElement;
|
|
152
|
+
if (selectedRadioButton) {
|
|
153
|
+
newValue = selectedRadioButton.value;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
break;
|
|
157
|
+
|
|
158
|
+
default:
|
|
159
|
+
newValue = input.value as any as TValue;
|
|
160
|
+
if (newValue + "" === "") {
|
|
161
|
+
newValue = null;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
if (viewModel.inputValidator) {
|
|
166
|
+
if (!await viewModel.inputValidator(event, viewModel, newValue as any as string)) {
|
|
167
|
+
input.value = unwrap(viewModel.value) as any as string;
|
|
168
|
+
return;
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
if (viewModel.type === "integer") {
|
|
173
|
+
if (isInteger(newValue)) {
|
|
174
|
+
newValue = parseInt(newValue);
|
|
175
|
+
} else {
|
|
176
|
+
input.value = unwrap(viewModel.value) as any as string;
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
if (viewModel.type === "float") {
|
|
182
|
+
if (isFloat(newValue)) {
|
|
183
|
+
newValue = parseFloat(newValue);
|
|
184
|
+
} else {
|
|
185
|
+
input.value = unwrap(viewModel.value) as any as string;
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
//if validation has succeeded we set the viewModel value
|
|
191
|
+
if (isObservableProperty(viewModel.value)) {
|
|
192
|
+
if ((event.type === "change" && viewModel.valueUpdateMode === ValueUpdateModeEnum.OnChange) ||
|
|
193
|
+
(event.type === "input" && viewModel.valueUpdateMode === ValueUpdateModeEnum.OnInput)) {
|
|
194
|
+
viewModel.value.set(newValue);
|
|
195
|
+
} else {
|
|
196
|
+
viewModel.value.set(newValue, false);
|
|
197
|
+
}
|
|
198
|
+
} else if (isObservable(viewModel.value)) {
|
|
199
|
+
viewModel.value(newValue);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export function inputView<TValue>(properties: InputProperties<TValue>) {
|
|
206
|
+
return new InputView<TValue>(properties);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
export class InputViewModel<TValue> extends ViewModel<InputProperties<TValue>> implements InputProperties<TValue> {
|
|
210
|
+
value?: TValue | ObservableProperty<TValue>;
|
|
211
|
+
inputValidator?: (event: Event, inputViewModel: InputProperties<TValue>, value: string) => Promise<boolean>;
|
|
212
|
+
placeholder?: string | ObservableProperty<string>;
|
|
213
|
+
valueUpdateMode?: ValueUpdateModeEnum;
|
|
214
|
+
min?: number;
|
|
215
|
+
max?: number;
|
|
216
|
+
step?: number;
|
|
217
|
+
type?: InputType;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
registerView(
|
|
221
|
+
InputViewModel,
|
|
222
|
+
InputView
|
|
223
|
+
);
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { unwrap, isSubscribable } from "knockout";
|
|
2
|
+
import { View, registerView } from "../../../framework/View";
|
|
3
|
+
import { ViewModel, Properties, extendProperties } from "../../../framework/ViewModel";
|
|
4
|
+
import { ObservableProperty, ObservableArrayProperty, isObservableProperty, observableArrayProperty, observableProperty } from "../../../framework/observable";
|
|
5
|
+
|
|
6
|
+
export interface SelectProperties<TItem, TValue, TSetter = TValue> extends Properties {
|
|
7
|
+
value?: TValue | ObservableProperty<TValue, TSetter>;
|
|
8
|
+
items?: Array<TItem> | ObservableArrayProperty<TItem>;
|
|
9
|
+
textFunction: (item: TItem) => string;
|
|
10
|
+
valueFunction: (item: TItem) => TValue;
|
|
11
|
+
setFunction?: (item: TItem) => TSetter;
|
|
12
|
+
inputValidator?: (event: Event, selectViewModel: SelectProperties<TItem, TValue, TSetter>, value: TValue) => Promise<boolean>;
|
|
13
|
+
emptyItemText?: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export class SelectView<TItem, TValue, TSetter = TValue> extends View<SelectProperties<TItem, TValue, TSetter>> {
|
|
17
|
+
constructor(properties: SelectProperties<TItem, TValue, TSetter>) {
|
|
18
|
+
super(
|
|
19
|
+
{
|
|
20
|
+
tagName: "select",
|
|
21
|
+
properties: extendProperties(
|
|
22
|
+
{
|
|
23
|
+
viewType: "Select"
|
|
24
|
+
},
|
|
25
|
+
properties
|
|
26
|
+
)
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
//Protected members
|
|
32
|
+
protected build() {
|
|
33
|
+
super.build();
|
|
34
|
+
const select = this.element as HTMLSelectElement;
|
|
35
|
+
|
|
36
|
+
const viewModel = this.properties;
|
|
37
|
+
|
|
38
|
+
this.setItems(unwrap(viewModel.items) as Array<TItem>);
|
|
39
|
+
if (isSubscribable(viewModel.items)) {
|
|
40
|
+
this.subscriptions.push(
|
|
41
|
+
viewModel.items.subscribe((items) => {
|
|
42
|
+
this.setItems(items);
|
|
43
|
+
})
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
this.setSelectedValue(unwrap(viewModel.value) as TValue);
|
|
48
|
+
if (isSubscribable(viewModel.value)) {
|
|
49
|
+
this.subscriptions.push(
|
|
50
|
+
viewModel.value.subscribe((value) => {
|
|
51
|
+
this.setSelectedValue(value);
|
|
52
|
+
})
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
this.element.addEventListener(
|
|
57
|
+
"change",
|
|
58
|
+
async (event: Event) => {
|
|
59
|
+
let selectedValue = select.value as any as TValue;
|
|
60
|
+
let selectedItem: TItem = null;
|
|
61
|
+
if (selectedValue + "" === "") {
|
|
62
|
+
selectedValue = null;
|
|
63
|
+
} else {
|
|
64
|
+
selectedItem = this.itemDictionary[selectedValue.toString()];
|
|
65
|
+
selectedValue = this.properties.valueFunction(selectedItem);
|
|
66
|
+
}
|
|
67
|
+
if (viewModel.inputValidator) {
|
|
68
|
+
if (!await viewModel.inputValidator(event, viewModel, selectedValue)) {
|
|
69
|
+
select.value = unwrap(viewModel.value) as any as string;
|
|
70
|
+
return;
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (isObservableProperty(viewModel.value)) {
|
|
75
|
+
if (viewModel.setFunction) {
|
|
76
|
+
const setValue = viewModel.setFunction(selectedItem);
|
|
77
|
+
viewModel.value.set(setValue);
|
|
78
|
+
} else {
|
|
79
|
+
viewModel.value.set(selectedValue as any);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
private itemDictionary: { [key: string]: TItem };
|
|
87
|
+
|
|
88
|
+
private setItems(items: Array<TItem>) {
|
|
89
|
+
if (this.element) {
|
|
90
|
+
this.itemDictionary = {};
|
|
91
|
+
if (items) {
|
|
92
|
+
const select = this.element as HTMLSelectElement;
|
|
93
|
+
select.innerHTML = null;
|
|
94
|
+
if (this.properties.emptyItemText) {
|
|
95
|
+
const emptyOption = document.createElement("option") as HTMLOptionElement;
|
|
96
|
+
emptyOption.value = "";
|
|
97
|
+
emptyOption.text = this.properties.emptyItemText;
|
|
98
|
+
select.options.add(emptyOption);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
items.forEach((item: TItem) => {
|
|
102
|
+
const value = this.properties.valueFunction(item).toString();
|
|
103
|
+
this.itemDictionary[value] = item;
|
|
104
|
+
var option = document.createElement("option") as HTMLOptionElement;
|
|
105
|
+
option.value = value;
|
|
106
|
+
option.text = this.properties.textFunction(item);
|
|
107
|
+
select.options.add(option);
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
private setSelectedValue(value: TValue) {
|
|
114
|
+
if (this.element) {
|
|
115
|
+
const select = this.element as HTMLSelectElement;
|
|
116
|
+
if (value === null || value === undefined) {
|
|
117
|
+
select.value = "";
|
|
118
|
+
} else {
|
|
119
|
+
select.value = value.toString();
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export function selectView<TItem, TValue, TSetter = TValue>(properties: SelectProperties<TItem, TValue, TSetter>) {
|
|
126
|
+
return new SelectView(properties);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export class SelectViewModel<TItem, TValue, TSetter = TValue> extends ViewModel<SelectProperties<TItem,TValue,TSetter>> implements SelectProperties<TItem, TValue, TSetter> {
|
|
130
|
+
value?: TValue | ObservableProperty<TValue, TSetter>;
|
|
131
|
+
items?: Array<TItem> | ObservableArrayProperty<TItem>;
|
|
132
|
+
textFunction: (item: TItem) => string;
|
|
133
|
+
valueFunction: (item: TItem) => TValue;
|
|
134
|
+
setFunction?: (item: TItem) => TSetter;
|
|
135
|
+
inputValidator?: (event: Event, selectViewModel: SelectProperties<TItem, TValue, TSetter>, value: TValue) => Promise<boolean>;
|
|
136
|
+
emptyItemText?: string;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
registerView(
|
|
140
|
+
SelectViewModel,
|
|
141
|
+
SelectView
|
|
142
|
+
);
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { View, registerView } from "../../../framework/View";
|
|
2
|
+
import { ViewModel, Properties, extendProperties } from "../../../framework/ViewModel";
|
|
3
|
+
|
|
4
|
+
export interface SpanProperties extends Properties {
|
|
5
|
+
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export class SpanView extends View<SpanProperties> {
|
|
9
|
+
constructor(properties: SpanProperties) {
|
|
10
|
+
super(
|
|
11
|
+
{
|
|
12
|
+
tagName: "span",
|
|
13
|
+
properties: extendProperties(
|
|
14
|
+
{
|
|
15
|
+
viewType: "Span"
|
|
16
|
+
},
|
|
17
|
+
properties
|
|
18
|
+
)
|
|
19
|
+
}
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function spanView(properties: SpanProperties) {
|
|
25
|
+
return new SpanView(properties);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export class SpanViewModel extends ViewModel<SpanProperties> implements SpanProperties {
|
|
29
|
+
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
registerView(
|
|
33
|
+
SpanViewModel,
|
|
34
|
+
SpanView
|
|
35
|
+
);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as codeMirror from "./codeMirror/index";
|
|
2
|
+
import * as custom from "./custom/index";
|
|
3
|
+
import * as html from "./html/index";
|
|
4
|
+
import * as jsonViewAwesome from "./jsonViewAwesome/index";
|
|
5
|
+
import * as kendo from "./kendo/index";
|
|
6
|
+
import * as leaflet from "./leaflet/index";
|
|
7
|
+
import * as svg from "./svg/index";
|
|
8
|
+
|
|
9
|
+
export { codeMirror };
|
|
10
|
+
export { custom };
|
|
11
|
+
export { html };
|
|
12
|
+
export { jsonViewAwesome };
|
|
13
|
+
export { kendo };
|
|
14
|
+
export { leaflet };
|
|
15
|
+
export { svg };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./jsonFormatter/JsonFormatter";
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { View, registerView } from "../../../framework/View";
|
|
2
|
+
import { ViewModel, Properties, extendProperties } from "../../../framework/ViewModel";
|
|
3
|
+
import { Subscribable, unwrap, isObservable } from "knockout";
|
|
4
|
+
import { JSONFormatter } from "json-viewer-awesome/lib/json-formatter";
|
|
5
|
+
|
|
6
|
+
export interface JsonFormatterProperties extends Properties {
|
|
7
|
+
json: object | Subscribable<object>;
|
|
8
|
+
showArrayIndex?: boolean;
|
|
9
|
+
quotesOnKeys?: boolean;
|
|
10
|
+
displayDataTypes?: boolean;
|
|
11
|
+
displayObjectSize?: boolean;
|
|
12
|
+
sortKeys?: boolean;
|
|
13
|
+
collapsed?: boolean;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export class JsonFormatterView extends View<JsonFormatterProperties> {
|
|
17
|
+
constructor(properties: JsonFormatterProperties) {
|
|
18
|
+
super(
|
|
19
|
+
{
|
|
20
|
+
tagName: "div",
|
|
21
|
+
properties: extendProperties(
|
|
22
|
+
{
|
|
23
|
+
viewType: "JsonFormatter"
|
|
24
|
+
},
|
|
25
|
+
properties
|
|
26
|
+
)
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
build(): void {
|
|
32
|
+
super.build();
|
|
33
|
+
|
|
34
|
+
const viewModel = this.properties;
|
|
35
|
+
this.setJson(unwrap(viewModel.json));
|
|
36
|
+
if (isObservable(viewModel.json)) {
|
|
37
|
+
this.subscriptions.push(
|
|
38
|
+
viewModel.json.subscribe((json) => {
|
|
39
|
+
this.setJson(json);
|
|
40
|
+
})
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
private setJson(json: object) {
|
|
46
|
+
if (json) {
|
|
47
|
+
if (typeof json === "object") {
|
|
48
|
+
const jsonFormatter = new JSONFormatter({
|
|
49
|
+
showArrayIndex: this.properties.showArrayIndex,
|
|
50
|
+
quotesOnKeys: this.properties.quotesOnKeys,
|
|
51
|
+
displayDataTypes: this.properties.displayDataTypes,
|
|
52
|
+
displayObjectSize: this.properties.displayObjectSize,
|
|
53
|
+
sortKeys: false,
|
|
54
|
+
collapsed: true,
|
|
55
|
+
iconStyle: 0,
|
|
56
|
+
theme: undefined,
|
|
57
|
+
src: json
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
this.element.replaceChildren(jsonFormatter.render());
|
|
61
|
+
} else {
|
|
62
|
+
this.element.innerHTML = (json as any).toString();
|
|
63
|
+
}
|
|
64
|
+
} else {
|
|
65
|
+
this.empty();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export function jsonFormatterView(properties: JsonFormatterProperties) {
|
|
71
|
+
return new JsonFormatterView(properties);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export class JsonFormatterViewModel extends ViewModel<JsonFormatterProperties> implements JsonFormatterProperties {
|
|
75
|
+
json: object | Subscribable<object>;
|
|
76
|
+
showArrayIndex?: boolean;
|
|
77
|
+
quotesOnKeys?: boolean;
|
|
78
|
+
displayDataTypes?: boolean;
|
|
79
|
+
displayObjectSize?: boolean;
|
|
80
|
+
sortKeys?: boolean;
|
|
81
|
+
collapsed?: boolean;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
registerView(
|
|
85
|
+
JsonFormatterViewModel,
|
|
86
|
+
JsonFormatterView
|
|
87
|
+
);
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import * as kendo from "@progress/kendo-ui/js/dataviz/chart/chart.js";
|
|
2
|
+
import { View } from "../../../framework/View";
|
|
3
|
+
import { Properties, extendProperties} from "../../../framework/ViewModel";
|
|
4
|
+
import { Subscribable, unwrap, isSubscribable } from "knockout";
|
|
5
|
+
|
|
6
|
+
export interface ChartProperties extends Properties {
|
|
7
|
+
data?: Array<any> | Subscribable<Array<any>>;
|
|
8
|
+
chartArea?: kendo.dataviz.ui.ChartChartArea | undefined;
|
|
9
|
+
series?: kendo.dataviz.ui.ChartSeriesItem[] | Subscribable<kendo.dataviz.ui.ChartSeriesItem[]>;
|
|
10
|
+
categoryAxis?: kendo.dataviz.ui.ChartCategoryAxisItem | kendo.dataviz.ui.ChartCategoryAxisItem[] | Subscribable<kendo.dataviz.ui.ChartCategoryAxisItem | kendo.dataviz.ui.ChartCategoryAxisItem[]>;
|
|
11
|
+
valueAxis?: kendo.dataviz.ui.ChartValueAxisItem | kendo.dataviz.ui.ChartValueAxisItem[] | undefined;
|
|
12
|
+
legend?: kendo.dataviz.ui.ChartLegend | undefined;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export class ChartView extends View<ChartProperties>{
|
|
16
|
+
constructor(properties: ChartProperties) {
|
|
17
|
+
super(
|
|
18
|
+
{
|
|
19
|
+
tagName: "div",
|
|
20
|
+
properties: extendProperties(
|
|
21
|
+
{
|
|
22
|
+
viewType: "KendoChart"
|
|
23
|
+
},
|
|
24
|
+
properties
|
|
25
|
+
)
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
private chart: kendo.dataviz.ui.Chart;
|
|
31
|
+
private dataSource: kendo.data.DataSource;
|
|
32
|
+
|
|
33
|
+
build(): void {
|
|
34
|
+
super.build();
|
|
35
|
+
|
|
36
|
+
const viewModel = this.properties;
|
|
37
|
+
|
|
38
|
+
if (viewModel.data) {
|
|
39
|
+
this.dataSource = new kendo.data.DataSource(
|
|
40
|
+
{
|
|
41
|
+
data: unwrap(viewModel.data)
|
|
42
|
+
}
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (isSubscribable(viewModel.data)) {
|
|
47
|
+
this.subscriptions.push(
|
|
48
|
+
viewModel.data.subscribe((data) => {
|
|
49
|
+
this.dataSource.data(data);
|
|
50
|
+
})
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
setTimeout(() => {
|
|
55
|
+
this.chart = new kendo.dataviz.ui.Chart(
|
|
56
|
+
this.element,
|
|
57
|
+
{
|
|
58
|
+
autoBind: false,
|
|
59
|
+
legend: viewModel.legend,
|
|
60
|
+
dataSource: this.dataSource,
|
|
61
|
+
chartArea: viewModel.chartArea,
|
|
62
|
+
series: unwrap(viewModel.series),
|
|
63
|
+
categoryAxis: unwrap(viewModel.categoryAxis),
|
|
64
|
+
valueAxis: viewModel.valueAxis
|
|
65
|
+
}
|
|
66
|
+
);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
if (isSubscribable(viewModel.series)) {
|
|
70
|
+
this.subscriptions.push(
|
|
71
|
+
viewModel.series.subscribe((series) => {
|
|
72
|
+
if (this.chart) {
|
|
73
|
+
this.chart.setOptions({
|
|
74
|
+
series: series
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
})
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (isSubscribable(viewModel.categoryAxis)) {
|
|
82
|
+
this.subscriptions.push(
|
|
83
|
+
viewModel.categoryAxis.subscribe((categoryAxis) => {
|
|
84
|
+
if (this.chart) {
|
|
85
|
+
this.chart.setOptions({
|
|
86
|
+
categoryAxis: categoryAxis
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
})
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export function chartView(properties: ChartProperties) {
|
|
96
|
+
return new ChartView(properties);
|
|
97
|
+
}
|