jpf 4.2.15 → 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/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.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AAG,EAAE,CAAC;yBACrB;wBACD,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;qBAClD;iBACJ;qBAAM;oBAEH,aAAa,CAAC,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;iBACnD;YACL,CAAC,CAAC,CAAC;SACN;QAED,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IACxC,CAAC;CACJ;AAED,MAAM,UAAU,QAAQ,CAAC,UAA0B;IAC/C,OAAO,IAAI,QAAQ,CAAC,UAAU,CAAC,CAAC;AACpC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jpf",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.16",
|
|
4
4
|
"description": "Javascript Presentation Foundation",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mvvm",
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
"types": "dist/index.d.ts",
|
|
26
26
|
"files": [
|
|
27
27
|
"dist",
|
|
28
|
+
"src",
|
|
28
29
|
"LICENSE.md",
|
|
29
30
|
"package.json",
|
|
30
31
|
"README.md"
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { View, registerView } from "../../../framework/View";
|
|
2
|
+
import { Properties, ViewModel, extendProperties } from "../../../framework/ViewModel";
|
|
3
|
+
import { unwrap, isObservable } from "knockout";
|
|
4
|
+
import { isObservableProperty, observableProperty, ObservableProperty } from "../../../framework/observable";
|
|
5
|
+
import { EditorView, basicSetup } from "codemirror";
|
|
6
|
+
import { EditorState } from "@codemirror/state";
|
|
7
|
+
import { keymap } from "@codemirror/view";
|
|
8
|
+
import { html } from "@codemirror/lang-html";
|
|
9
|
+
import { indentWithTab } from "@codemirror/commands";
|
|
10
|
+
import { foldAll } from "@codemirror/language";
|
|
11
|
+
import { ButtonView } from "../../html/Button/Button";
|
|
12
|
+
import { prettifyHtml } from "../../../utilities/html/html";
|
|
13
|
+
import { DivView } from "../../html/Div/Div";
|
|
14
|
+
|
|
15
|
+
export interface HtmlEditorProperties extends Properties {
|
|
16
|
+
value?: string | ObservableProperty<string>;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export class HtmlEditorView extends View<HtmlEditorProperties> {
|
|
20
|
+
constructor(properties: HtmlEditorProperties) {
|
|
21
|
+
super(
|
|
22
|
+
{
|
|
23
|
+
tagName: "div",
|
|
24
|
+
properties: extendProperties(
|
|
25
|
+
{
|
|
26
|
+
viewType: "HtmlEditor",
|
|
27
|
+
attributes: {
|
|
28
|
+
tabindex: 1
|
|
29
|
+
},
|
|
30
|
+
style: {
|
|
31
|
+
display: "flex",
|
|
32
|
+
flexDirection: "column",
|
|
33
|
+
border: "1px solid #a3d0e4"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
properties
|
|
37
|
+
)
|
|
38
|
+
}
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
private editor: EditorView;
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
build(): void {
|
|
46
|
+
super.build();
|
|
47
|
+
|
|
48
|
+
const viewModel = this.properties;
|
|
49
|
+
const foldAllButton = new ButtonView({
|
|
50
|
+
content: "Collapse all",
|
|
51
|
+
style: {
|
|
52
|
+
margin: "3px"
|
|
53
|
+
},
|
|
54
|
+
eventListeners: {
|
|
55
|
+
click: {
|
|
56
|
+
listener: () => {
|
|
57
|
+
foldAll(this.editor);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
const formatButton = new ButtonView({
|
|
64
|
+
content: "Format",
|
|
65
|
+
style: {
|
|
66
|
+
margin: "3px"
|
|
67
|
+
},
|
|
68
|
+
eventListeners: {
|
|
69
|
+
click: {
|
|
70
|
+
listener: () => {
|
|
71
|
+
var formattedHtml = prettifyHtml(this.editor.state.doc.toString());
|
|
72
|
+
this.editor.dispatch({ changes: { from: 0, to: this.editor.state.doc.length, insert: formattedHtml } });
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
const saveButton = new ButtonView({
|
|
79
|
+
content: "Save",
|
|
80
|
+
style: {
|
|
81
|
+
margin: "3px"
|
|
82
|
+
},
|
|
83
|
+
eventListeners: {
|
|
84
|
+
click: {
|
|
85
|
+
listener: () => {
|
|
86
|
+
if (isObservableProperty(viewModel.value)) {
|
|
87
|
+
viewModel.value.set(this.editor.state.doc.toString());
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
const buttons = new DivView({
|
|
95
|
+
style: {
|
|
96
|
+
display: "flex"
|
|
97
|
+
},
|
|
98
|
+
children: [
|
|
99
|
+
foldAllButton,
|
|
100
|
+
formatButton,
|
|
101
|
+
saveButton
|
|
102
|
+
]
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
this.element.appendChild(buttons.render());
|
|
106
|
+
|
|
107
|
+
const state = EditorState.create({
|
|
108
|
+
extensions: [
|
|
109
|
+
basicSetup,
|
|
110
|
+
html(),
|
|
111
|
+
EditorView.lineWrapping,
|
|
112
|
+
keymap.of([indentWithTab])
|
|
113
|
+
]
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
this.editor = new EditorView({
|
|
117
|
+
state: state,
|
|
118
|
+
parent: this.element,
|
|
119
|
+
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
this.editor.dom.style.overflow = "auto";
|
|
123
|
+
|
|
124
|
+
//Set the initial value;
|
|
125
|
+
this.editor.dispatch({ changes: { from: 0, to: this.editor.state.doc.length, insert: unwrap(viewModel.value) as any as string } });
|
|
126
|
+
|
|
127
|
+
//Found out if the viewModel property is observable.
|
|
128
|
+
if (isObservable(viewModel.value)) {
|
|
129
|
+
this.subscriptions.push(
|
|
130
|
+
viewModel.value.subscribe((html: string) => {
|
|
131
|
+
this.editor.dispatch({ changes: { from: 0, to: this.editor.state.doc.length, insert: html } });
|
|
132
|
+
})
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export function htmlEditorView(properties: HtmlEditorProperties) {
|
|
139
|
+
return new HtmlEditorView(properties);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export class HtmlEditorViewModel extends ViewModel<HtmlEditorProperties> implements HtmlEditorProperties {
|
|
143
|
+
value?: string | ObservableProperty<string>;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
registerView(
|
|
147
|
+
HtmlEditorViewModel,
|
|
148
|
+
HtmlEditorView
|
|
149
|
+
)
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { View, registerView } from "../../../framework/View";
|
|
2
|
+
import { Properties, ViewModel, extendProperties } from "../../../framework/ViewModel";
|
|
3
|
+
import { unwrap, isObservable } from "knockout";
|
|
4
|
+
import { isObservableProperty, observableProperty, ObservableProperty } from "../../../framework/observable";
|
|
5
|
+
import { EditorView, basicSetup } from "codemirror";
|
|
6
|
+
import { EditorState } from "@codemirror/state"
|
|
7
|
+
import { keymap } from "@codemirror/view";
|
|
8
|
+
import { json } from "@codemirror/lang-json";
|
|
9
|
+
import { indentWithTab } from "@codemirror/commands";
|
|
10
|
+
import { foldAll } from "@codemirror/language";
|
|
11
|
+
import { ButtonView } from "../../html/Button/Button";
|
|
12
|
+
import { DivView } from "../../html/Div/Div";
|
|
13
|
+
|
|
14
|
+
export interface JsonEditorProperties extends Properties {
|
|
15
|
+
value?: string | ObservableProperty<string>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export class JsonEditorView extends View<JsonEditorProperties> {
|
|
19
|
+
constructor(properties: JsonEditorProperties) {
|
|
20
|
+
super(
|
|
21
|
+
{
|
|
22
|
+
tagName: "div",
|
|
23
|
+
properties: extendProperties(
|
|
24
|
+
{
|
|
25
|
+
viewType: "JsonEditor",
|
|
26
|
+
attributes: {
|
|
27
|
+
tabindex: 1
|
|
28
|
+
},
|
|
29
|
+
style: {
|
|
30
|
+
display: "flex",
|
|
31
|
+
flexDirection: "column",
|
|
32
|
+
border: "1px solid #a3d0e4"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
properties
|
|
36
|
+
)
|
|
37
|
+
}
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
private editor: EditorView;
|
|
42
|
+
|
|
43
|
+
build(): void {
|
|
44
|
+
super.build();
|
|
45
|
+
|
|
46
|
+
const viewModel = this.properties;
|
|
47
|
+
const foldAllButton = new ButtonView({
|
|
48
|
+
content: "Collapse all",
|
|
49
|
+
style: {
|
|
50
|
+
margin: "3px"
|
|
51
|
+
},
|
|
52
|
+
eventListeners: {
|
|
53
|
+
click: {
|
|
54
|
+
listener: () => {
|
|
55
|
+
foldAll(this.editor);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
const saveButton = new ButtonView({
|
|
62
|
+
content: "Save",
|
|
63
|
+
style: {
|
|
64
|
+
margin: "3px"
|
|
65
|
+
},
|
|
66
|
+
eventListeners: {
|
|
67
|
+
click: {
|
|
68
|
+
listener: () => {
|
|
69
|
+
if (isObservableProperty(viewModel.value)) {
|
|
70
|
+
viewModel.value.set(this.editor.state.doc.toString());
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
const buttons = new DivView({
|
|
78
|
+
style: {
|
|
79
|
+
display: "flex"
|
|
80
|
+
},
|
|
81
|
+
children: [
|
|
82
|
+
foldAllButton,
|
|
83
|
+
saveButton
|
|
84
|
+
]
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
this.element.appendChild(buttons.render());
|
|
88
|
+
|
|
89
|
+
const state = EditorState.create({
|
|
90
|
+
extensions: [
|
|
91
|
+
basicSetup,
|
|
92
|
+
json(),
|
|
93
|
+
EditorView.lineWrapping,
|
|
94
|
+
keymap.of([indentWithTab])
|
|
95
|
+
]
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
this.editor = new EditorView({
|
|
99
|
+
state: state,
|
|
100
|
+
parent: this.element,
|
|
101
|
+
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
this.editor.dom.style.overflow = "auto";
|
|
105
|
+
|
|
106
|
+
//Set the initial value;
|
|
107
|
+
this.editor.dispatch({ changes: { from: 0, to: this.editor.state.doc.length, insert: unwrap(viewModel.value) as any as string } });
|
|
108
|
+
|
|
109
|
+
//Found out if the viewModel property is observable.
|
|
110
|
+
if (isObservable(viewModel.value)) {
|
|
111
|
+
this.subscriptions.push(
|
|
112
|
+
viewModel.value.subscribe((html: string) => {
|
|
113
|
+
this.editor.dispatch({ changes: { from: 0, to: this.editor.state.doc.length, insert: html } });
|
|
114
|
+
})
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export function jsonEditorView(properties: JsonEditorProperties) {
|
|
121
|
+
return new JsonEditorView(properties);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
export class JsonEditorViewModel extends ViewModel<JsonEditorProperties> implements JsonEditorProperties {
|
|
126
|
+
value?: string | ObservableProperty<string>;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
registerView(
|
|
130
|
+
JsonEditorViewModel,
|
|
131
|
+
JsonEditorView
|
|
132
|
+
)
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { ViewModel, Properties, extendProperties } from "../../../framework/ViewModel";
|
|
2
|
+
import { View, registerView } from "../../../framework/View";
|
|
3
|
+
import { ButtonProperties , ButtonView } from "../../html/Button/Button";
|
|
4
|
+
import { InputView, InputProperties } from "../../html/Input/Input";
|
|
5
|
+
|
|
6
|
+
export interface FileSelectorProperties extends Properties {
|
|
7
|
+
button?: ButtonProperties;
|
|
8
|
+
inputFile: InputProperties<FileList>;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export class FileSelectorView extends View<FileSelectorProperties> {
|
|
12
|
+
constructor(properties: FileSelectorProperties) {
|
|
13
|
+
super(
|
|
14
|
+
{
|
|
15
|
+
tagName: "div",
|
|
16
|
+
properties: extendProperties(
|
|
17
|
+
{
|
|
18
|
+
viewType: "FileSelector"
|
|
19
|
+
},
|
|
20
|
+
properties
|
|
21
|
+
)
|
|
22
|
+
}
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
protected build(): void {
|
|
27
|
+
super.build();
|
|
28
|
+
|
|
29
|
+
const viewModel = this.properties;
|
|
30
|
+
|
|
31
|
+
var fileInput = new InputView(viewModel.inputFile).render();
|
|
32
|
+
|
|
33
|
+
this.element.appendChild(fileInput);
|
|
34
|
+
|
|
35
|
+
if (viewModel.button) {
|
|
36
|
+
const button = new ButtonView(
|
|
37
|
+
extendProperties(
|
|
38
|
+
viewModel.button,
|
|
39
|
+
{
|
|
40
|
+
eventListeners: {
|
|
41
|
+
click: {
|
|
42
|
+
listener: () => {
|
|
43
|
+
var mouseEvent = document.createEvent("MouseEvent");
|
|
44
|
+
mouseEvent.initEvent("click", false, false);
|
|
45
|
+
fileInput.dispatchEvent(mouseEvent);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
)
|
|
51
|
+
).render();
|
|
52
|
+
|
|
53
|
+
this.element.appendChild(button);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function fileSelectorView(properties: FileSelectorProperties){
|
|
59
|
+
return new FileSelectorView(properties);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export class FileSelectorViewModel extends ViewModel<FileSelectorProperties> implements FileSelectorProperties {
|
|
63
|
+
button?: ButtonProperties;
|
|
64
|
+
inputFile: InputProperties<FileList>;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
registerView(
|
|
68
|
+
FileSelectorViewModel,
|
|
69
|
+
FileSelectorView
|
|
70
|
+
);
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { ViewModel, Properties, extendProperties } from "../../../framework/ViewModel"
|
|
2
|
+
import { View, IView, registerView } from "../../../framework/View";
|
|
3
|
+
import { DivView } from "../../html/Div/Div";
|
|
4
|
+
|
|
5
|
+
export interface LabeledViewProperties extends Properties {
|
|
6
|
+
labelProperties: Properties;
|
|
7
|
+
view: IView;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export class LabeledControlView extends View<LabeledViewProperties> {
|
|
11
|
+
constructor(properties: LabeledViewProperties) {
|
|
12
|
+
super(
|
|
13
|
+
{
|
|
14
|
+
tagName: "div",
|
|
15
|
+
properties: extendProperties(
|
|
16
|
+
{
|
|
17
|
+
viewType: "LabeledControl",
|
|
18
|
+
style: {
|
|
19
|
+
display: "flex",
|
|
20
|
+
alignItems: "center"
|
|
21
|
+
},
|
|
22
|
+
classNames: ["o-labled-control"]
|
|
23
|
+
},
|
|
24
|
+
properties
|
|
25
|
+
),
|
|
26
|
+
children: [
|
|
27
|
+
new DivView(
|
|
28
|
+
extendProperties(
|
|
29
|
+
properties.labelProperties,
|
|
30
|
+
{
|
|
31
|
+
viewType: "Label"
|
|
32
|
+
}
|
|
33
|
+
)
|
|
34
|
+
),
|
|
35
|
+
properties.view
|
|
36
|
+
]
|
|
37
|
+
}
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function labeledControlView(properties: LabeledViewProperties) {
|
|
43
|
+
return new LabeledControlView(properties);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export class LabeledControlViewModel extends ViewModel<LabeledViewProperties> implements LabeledViewProperties {
|
|
47
|
+
labelProperties: Properties;
|
|
48
|
+
view: IView;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
registerView(
|
|
52
|
+
LabeledControlViewModel,
|
|
53
|
+
LabeledControlView
|
|
54
|
+
)
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { isObservable, unwrap } from "knockout";
|
|
2
|
+
import { View, getView, registerView } from "../../../framework/View";
|
|
3
|
+
import { ViewModel, Properties, extendProperties } from "../../../framework/ViewModel";
|
|
4
|
+
|
|
5
|
+
//Do not change property names since they have to correspond to kendo listItems
|
|
6
|
+
//so this type can be used in kendo list controls like menu and tree
|
|
7
|
+
|
|
8
|
+
export interface ListItemProperties extends Properties {
|
|
9
|
+
id: number | string;
|
|
10
|
+
text?: string | ViewModel;
|
|
11
|
+
select?: () => void;
|
|
12
|
+
order?: number | string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface HierarchicalListItemProperties extends ListItemProperties {
|
|
16
|
+
parentId?: number | string;
|
|
17
|
+
expanded?: boolean;
|
|
18
|
+
items?: Array<HierarchicalListItemProperties>;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export class ListItemView extends View<ListItemProperties> {
|
|
22
|
+
constructor(properties: ListItemProperties) {
|
|
23
|
+
super(
|
|
24
|
+
{
|
|
25
|
+
tagName: "div",
|
|
26
|
+
properties: extendProperties(
|
|
27
|
+
{
|
|
28
|
+
viewType: "ListItem"
|
|
29
|
+
},
|
|
30
|
+
properties
|
|
31
|
+
)
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
build(): void {
|
|
37
|
+
super.build();
|
|
38
|
+
|
|
39
|
+
const viewModel = this.properties;
|
|
40
|
+
|
|
41
|
+
if (isObservable(viewModel.text)) {
|
|
42
|
+
this.setContent(unwrap(viewModel.text));
|
|
43
|
+
this.subscriptions.push(
|
|
44
|
+
viewModel.text.subscribe((content) => {
|
|
45
|
+
this.setContent(content);
|
|
46
|
+
})
|
|
47
|
+
);
|
|
48
|
+
} else {
|
|
49
|
+
this.setContent(viewModel.text);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
private setContent(content: string | ViewModel) {
|
|
54
|
+
if (typeof content === "string") {
|
|
55
|
+
this.element.innerHTML = content;
|
|
56
|
+
} else if (content instanceof ViewModel) {
|
|
57
|
+
this.setChildren(getView(content));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function listItemView(properties: ListItemProperties) {
|
|
63
|
+
return new ListItemView(properties);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export class ListItemViewModel extends ViewModel<ListItemProperties> implements ListItemProperties {
|
|
67
|
+
id: number | string;
|
|
68
|
+
text?: string | ViewModel;
|
|
69
|
+
select?: () => void;
|
|
70
|
+
order?: number | string;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
registerView(
|
|
74
|
+
ListItemViewModel,
|
|
75
|
+
ListItemView
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
export class HierarchicalListItemViewModel extends ViewModel<HierarchicalListItemProperties> implements HierarchicalListItemProperties{
|
|
79
|
+
id: number | string;
|
|
80
|
+
text?: string | ViewModel;
|
|
81
|
+
select?: () => void;
|
|
82
|
+
order?: number | string;
|
|
83
|
+
parentId?: number | string;
|
|
84
|
+
expanded?: boolean;
|
|
85
|
+
items?: Array<HierarchicalListItemProperties>;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
registerView(
|
|
89
|
+
HierarchicalListItemViewModel,
|
|
90
|
+
ListItemView
|
|
91
|
+
)
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { unwrap, Subscribable, isSubscribable } from "knockout";
|
|
2
|
+
import { ViewModel, Properties, extendProperties } from "../../../framework/ViewModel"
|
|
3
|
+
import { View, getView, registerView } from "../../../framework/View";
|
|
4
|
+
|
|
5
|
+
export interface ButtonProperties extends Properties {
|
|
6
|
+
content?: string | ViewModel | Subscribable<string | ViewModel>;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export class ButtonView extends View<ButtonProperties> {
|
|
10
|
+
constructor(properties: ButtonProperties) {
|
|
11
|
+
super(
|
|
12
|
+
{
|
|
13
|
+
tagName: "button",
|
|
14
|
+
properties: extendProperties(
|
|
15
|
+
{
|
|
16
|
+
viewType: "Button"
|
|
17
|
+
},
|
|
18
|
+
properties
|
|
19
|
+
)
|
|
20
|
+
}
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
build(): void {
|
|
25
|
+
super.build();
|
|
26
|
+
|
|
27
|
+
const viewModel = this.properties;
|
|
28
|
+
if (viewModel.content) {
|
|
29
|
+
if (isSubscribable(viewModel.content)) {
|
|
30
|
+
this.buildContent(unwrap(viewModel.content));
|
|
31
|
+
this.subscriptions.push(
|
|
32
|
+
viewModel.content.subscribe((content) => {
|
|
33
|
+
this.buildContent(content);
|
|
34
|
+
})
|
|
35
|
+
);
|
|
36
|
+
} else {
|
|
37
|
+
this.buildContent(viewModel.content);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
private buildContent(content: string | ViewModel) {
|
|
43
|
+
if (content == null || content === undefined) {
|
|
44
|
+
this.element.innerText = null;
|
|
45
|
+
}
|
|
46
|
+
else if (typeof content === "string") {
|
|
47
|
+
this.element.innerText = content;
|
|
48
|
+
}
|
|
49
|
+
else if (content instanceof ViewModel) {
|
|
50
|
+
this.setChildren(getView(content as ViewModel));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function buttonView(properties: ButtonProperties): ButtonView {
|
|
56
|
+
return new ButtonView(properties);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export class ButtonViewModel extends ViewModel<ButtonProperties> implements ButtonProperties{
|
|
60
|
+
content?: string | ViewModel | Subscribable<string | ViewModel>;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
registerView(
|
|
64
|
+
ButtonViewModel,
|
|
65
|
+
ButtonView
|
|
66
|
+
);
|
|
@@ -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
|
+
);
|