jpf 5.0.95 → 5.0.96
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 +2 -2
- package/dist/controls/codeMirror/Editor/Editor.js +2 -3
- package/dist/controls/codeMirror/Editor/Editor.js.map +1 -1
- package/dist/controls/custom/FileSelector/FileSelector.d.ts +2 -2
- package/dist/controls/custom/FileSelector/FileSelector.js +2 -3
- package/dist/controls/custom/FileSelector/FileSelector.js.map +1 -1
- package/dist/controls/custom/LabeledControl/LabeledControl.d.ts +3 -3
- package/dist/controls/custom/LabeledControl/LabeledControl.js +2 -3
- package/dist/controls/custom/LabeledControl/LabeledControl.js.map +1 -1
- package/dist/controls/custom/ListItem/ListItem.d.ts +6 -6
- package/dist/controls/custom/ListItem/ListItem.js +11 -8
- package/dist/controls/custom/ListItem/ListItem.js.map +1 -1
- package/dist/controls/html/Button/Button.d.ts +4 -4
- package/dist/controls/html/Button/Button.js +7 -5
- package/dist/controls/html/Button/Button.js.map +1 -1
- package/dist/controls/html/Div/Div.d.ts +2 -2
- 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 +2 -2
- 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 +2 -2
- package/dist/controls/html/Input/Input.js +2 -3
- package/dist/controls/html/Input/Input.js.map +1 -1
- package/dist/controls/html/Select/Select.d.ts +2 -2
- package/dist/controls/html/Select/Select.js +2 -3
- package/dist/controls/html/Select/Select.js.map +1 -1
- package/dist/controls/html/Span/Span.d.ts +2 -2
- 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 +2 -2
- package/dist/controls/jsonViewerAwesome/jsonFormatter/JsonFormatter.js +2 -3
- package/dist/controls/jsonViewerAwesome/jsonFormatter/JsonFormatter.js.map +1 -1
- package/dist/controls/kendo/Grid/Grid.d.ts +2 -2
- package/dist/controls/kendo/Grid/Grid.js +2 -3
- package/dist/controls/kendo/Grid/Grid.js.map +1 -1
- package/dist/controls/kendo/Menu/Menu.js +13 -10
- package/dist/controls/kendo/Menu/Menu.js.map +1 -1
- package/dist/controls/kendo/Treeview/Treeview.d.ts +3 -3
- package/dist/controls/kendo/Treeview/Treeview.js +12 -9
- package/dist/controls/kendo/Treeview/Treeview.js.map +1 -1
- package/dist/controls/leaflet/LabelControl/LabelControl.d.ts +2 -2
- package/dist/controls/leaflet/LabelControl/LabelControl.js +8 -8
- package/dist/controls/leaflet/LabelControl/LabelControl.js.map +1 -1
- package/dist/controls/leaflet/Map/Map.d.ts +2 -2
- package/dist/controls/leaflet/Map/Map.js +2 -3
- package/dist/controls/leaflet/Map/Map.js.map +1 -1
- package/dist/framework/element.d.ts +1 -15
- package/dist/framework/element.js +8 -26
- package/dist/framework/element.js.map +1 -1
- package/package.json +1 -1
- package/src/controls/codeMirror/Editor/Editor.ts +3 -4
- package/src/controls/custom/FileSelector/FileSelector.ts +3 -4
- package/src/controls/custom/LabeledControl/LabeledControl.ts +4 -5
- package/src/controls/custom/ListItem/ListItem.ts +16 -13
- package/src/controls/html/Button/Button.ts +13 -11
- package/src/controls/html/Div/Div.ts +3 -4
- package/src/controls/html/Image/Image.ts +3 -4
- package/src/controls/html/Input/Input.ts +3 -4
- package/src/controls/html/Select/Select.ts +3 -4
- package/src/controls/html/Span/Span.ts +3 -4
- package/src/controls/jsonViewerAwesome/jsonFormatter/JsonFormatter.ts +3 -4
- package/src/controls/kendo/Grid/Grid.ts +3 -4
- package/src/controls/kendo/Menu/Menu.ts +16 -14
- package/src/controls/kendo/Treeview/Treeview.ts +21 -18
- package/src/controls/leaflet/LabelControl/LabelControl.ts +11 -11
- package/src/controls/leaflet/Map/Map.ts +3 -4
- package/src/framework/element.ts +37 -25
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Element, getElement, addToDictionary,
|
|
1
|
+
import { Element, getElement, addToDictionary, IElementProperties, extendProperties, isRegisteredViewModel } from "../../../framework/element";
|
|
2
2
|
import { ISubscribable, observable } from "../../../framework/observable";
|
|
3
3
|
|
|
4
4
|
export interface IButtonProperties extends IElementProperties {
|
|
5
|
-
content?: string |
|
|
5
|
+
content?: string | object | ISubscribable<string | object>;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
export class ButtonElement extends Element<IButtonProperties> {
|
|
@@ -12,8 +12,8 @@ export class ButtonElement extends Element<IButtonProperties> {
|
|
|
12
12
|
tagName: "button",
|
|
13
13
|
properties: extendProperties(
|
|
14
14
|
{
|
|
15
|
-
target:properties,
|
|
16
|
-
preserveExisting:{
|
|
15
|
+
target: properties,
|
|
16
|
+
preserveExisting: {
|
|
17
17
|
elementType: "ButtonElement"
|
|
18
18
|
}
|
|
19
19
|
}
|
|
@@ -39,15 +39,18 @@ export class ButtonElement extends Element<IButtonProperties> {
|
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
private buildContent(content
|
|
42
|
+
private buildContent(content) {
|
|
43
43
|
if (content == null || content === undefined) {
|
|
44
44
|
this.htmlElement.innerText = null;
|
|
45
45
|
}
|
|
46
46
|
else if (typeof content === "string") {
|
|
47
47
|
this.htmlElement.innerText = content;
|
|
48
48
|
}
|
|
49
|
-
else if (content
|
|
50
|
-
|
|
49
|
+
else if (isRegisteredViewModel(content)) {
|
|
50
|
+
const element = getElement(content)
|
|
51
|
+
if (element) {
|
|
52
|
+
this.setChildren(element);
|
|
53
|
+
}
|
|
51
54
|
}
|
|
52
55
|
}
|
|
53
56
|
}
|
|
@@ -56,12 +59,11 @@ export function createButton(properties: IButtonProperties) {
|
|
|
56
59
|
return new ButtonElement(properties);
|
|
57
60
|
}
|
|
58
61
|
|
|
59
|
-
export class ButtonProperties
|
|
62
|
+
export class ButtonProperties implements IButtonProperties {
|
|
60
63
|
constructor(properties: IButtonProperties) {
|
|
61
|
-
|
|
62
|
-
this.setProperties(this, properties);
|
|
64
|
+
Object.assign(this, properties);
|
|
63
65
|
}
|
|
64
|
-
content?: string |
|
|
66
|
+
content?: string | object | ISubscribable<string | object>;
|
|
65
67
|
}
|
|
66
68
|
|
|
67
69
|
addToDictionary(
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Element,
|
|
1
|
+
import { Element, IElement, IElementProperties, extendProperties, addToDictionary } from "../../../framework/element";
|
|
2
2
|
import { ISubscribable } from "../../../framework/observable";
|
|
3
3
|
|
|
4
4
|
export interface IDivProperties extends IElementProperties {
|
|
@@ -27,10 +27,9 @@ export function createDiv(properties: IDivProperties) {
|
|
|
27
27
|
return new DivElement(properties);
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
export class DivProperties
|
|
30
|
+
export class DivProperties implements IDivProperties {
|
|
31
31
|
constructor(properties: IDivProperties) {
|
|
32
|
-
|
|
33
|
-
this.setProperties(this, properties);
|
|
32
|
+
Object.assign(this, properties);
|
|
34
33
|
}
|
|
35
34
|
children?: Array<IElement> | ISubscribable<Array<IElement>>;
|
|
36
35
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Element, addToDictionary,
|
|
1
|
+
import { Element, addToDictionary, IElementProperties, extendProperties } from "../../../framework/element";
|
|
2
2
|
import { ISubscribable } from "../../../framework/observable";
|
|
3
3
|
|
|
4
4
|
export interface IImageProperties extends IElementProperties {
|
|
@@ -34,10 +34,9 @@ export function createImage(properties: IImageProperties) {
|
|
|
34
34
|
return new ImageElement(properties);
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
export class ImageProperties
|
|
37
|
+
export class ImageProperties implements IImageProperties {
|
|
38
38
|
constructor(properties: IImageProperties) {
|
|
39
|
-
|
|
40
|
-
this.setProperties(this, properties);
|
|
39
|
+
Object.assign(this, properties);
|
|
41
40
|
}
|
|
42
41
|
src: string | ISubscribable<string>;
|
|
43
42
|
alt: string | ISubscribable<string>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Element, addToDictionary,
|
|
1
|
+
import { Element, addToDictionary, IElementProperties, extendProperties } from "../../../framework/element";
|
|
2
2
|
import { isInteger } from "../../../utilities/integer/integer";
|
|
3
3
|
import { isFloat } from "../../../utilities/float/float";
|
|
4
4
|
import { ISubscribable, observable } from "../../../framework/observable";
|
|
@@ -206,10 +206,9 @@ export function createInput<TValue>(properties: IInputProperties<TValue>) {
|
|
|
206
206
|
return new InputElement<TValue>(properties);
|
|
207
207
|
}
|
|
208
208
|
|
|
209
|
-
export class InputProperties<TValue>
|
|
209
|
+
export class InputProperties<TValue> implements IInputProperties<TValue> {
|
|
210
210
|
constructor(properties: IInputProperties<TValue>) {
|
|
211
|
-
|
|
212
|
-
this.setProperties(this, properties);
|
|
211
|
+
Object.assign(this, properties);
|
|
213
212
|
}
|
|
214
213
|
|
|
215
214
|
value?: TValue | ISubscribable<TValue>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Element, addToDictionary,
|
|
1
|
+
import { Element, addToDictionary, IElementProperties, extendProperties } from "../../../framework/element";
|
|
2
2
|
import { ISubscribable, observable } from "../../../framework/observable";
|
|
3
3
|
|
|
4
4
|
export interface ISelectProperties<TItem, TValue, TSetter = TValue> extends IElementProperties {
|
|
@@ -129,10 +129,9 @@ export function createSelect<TItem, TValue, TSetter = TValue>(properties: ISelec
|
|
|
129
129
|
return new SelectElement(properties);
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
-
export class SelectProperties<TItem, TValue, TSetter = TValue>
|
|
132
|
+
export class SelectProperties<TItem, TValue, TSetter = TValue> implements ISelectProperties<TItem, TValue, TSetter> {
|
|
133
133
|
constructor(properties: ISelectProperties<TItem, TValue, TSetter>) {
|
|
134
|
-
|
|
135
|
-
this.setProperties(this, properties);
|
|
134
|
+
Object.assign(this, properties);
|
|
136
135
|
}
|
|
137
136
|
name: string;
|
|
138
137
|
value?: TValue | ISubscribable<TValue>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Element, addToDictionary,
|
|
1
|
+
import { Element, addToDictionary, IElementProperties, extendProperties } from "../../../framework/element";
|
|
2
2
|
|
|
3
3
|
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
4
4
|
export interface ISpanProperties extends IElementProperties {
|
|
@@ -27,10 +27,9 @@ export function createSpan(properties: ISpanProperties) {
|
|
|
27
27
|
return new SpanElement(properties);
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
export class SpanProperties
|
|
30
|
+
export class SpanProperties implements ISpanProperties {
|
|
31
31
|
constructor(properties: SpanProperties) {
|
|
32
|
-
|
|
33
|
-
this.setProperties(this, properties);
|
|
32
|
+
Object.assign(this, properties);
|
|
34
33
|
}
|
|
35
34
|
}
|
|
36
35
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Element,
|
|
1
|
+
import { Element, IElementProperties, extendProperties, addToDictionary } from "../../../framework/element";
|
|
2
2
|
import { JSONFormatter } from "json-viewer-awesome/lib/json-formatter";
|
|
3
3
|
import { ISubscribable, observable } from "../../../framework/observable";
|
|
4
4
|
|
|
@@ -72,10 +72,9 @@ export function createJsonFormatter(properties: IJsonFormatterProperties) {
|
|
|
72
72
|
return new JsonFormatterElement(properties);
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
export class JsonFormatterProperties
|
|
75
|
+
export class JsonFormatterProperties implements IJsonFormatterProperties {
|
|
76
76
|
constructor(properties: IJsonFormatterProperties) {
|
|
77
|
-
|
|
78
|
-
this.setProperties(this, properties);
|
|
77
|
+
Object.assign(this, properties);
|
|
79
78
|
}
|
|
80
79
|
json: object | ISubscribable<object>;
|
|
81
80
|
showArrayIndex?: boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as kendo from "@progress/kendo-ui/js/kendo.grid.js";
|
|
2
|
-
import { Element,
|
|
2
|
+
import { Element, IElementProperties, extendProperties, addToDictionary } from "../../../framework/element";
|
|
3
3
|
import { ISubscribable, observable } from "../../../framework/observable";
|
|
4
4
|
|
|
5
5
|
export interface IGridProperties<TItem> extends IElementProperties {
|
|
@@ -259,10 +259,9 @@ export function getSelectedDataItems<TItem>(grid: kendo.ui.Grid): Array<TItem> {
|
|
|
259
259
|
return selectedDataItems;
|
|
260
260
|
}
|
|
261
261
|
|
|
262
|
-
export class GridProperties<TItem = unknown>
|
|
262
|
+
export class GridProperties<TItem = unknown> implements IGridProperties<TItem> {
|
|
263
263
|
constructor(properties: IGridProperties<TItem>) {
|
|
264
|
-
|
|
265
|
-
this.setProperties(this, properties);
|
|
264
|
+
Object.assign(this, properties);
|
|
266
265
|
}
|
|
267
266
|
|
|
268
267
|
items?: Array<TItem> | ISubscribable<Array<TItem>>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as kendo from "@progress/kendo-ui/js/kendo.menu.js";
|
|
2
|
-
import { Element,
|
|
3
|
-
import {
|
|
2
|
+
import { Element, IElementProperties, extendProperties, applyBindings, getElement, isRegisteredViewModel } from "../../../framework/element";
|
|
3
|
+
import { IHierarchicalListItemProperties } from "../../custom/ListItem/ListItem";
|
|
4
4
|
import { ISubscribable, observable } from "../../../framework/observable";
|
|
5
5
|
const getContent = "getContent";
|
|
6
6
|
|
|
@@ -43,24 +43,26 @@ export class MenuElement extends Element<IMenuProperties> {
|
|
|
43
43
|
"dataBound",
|
|
44
44
|
(event) => {
|
|
45
45
|
//Find all menuitems that needs to be post rendered.
|
|
46
|
-
event.sender.wrapper.find(".k-menu-item[postrender]").each((index,
|
|
47
|
-
const uid =
|
|
48
|
-
const hierarchicalListItemViewModel = this.dataSource.getByUid(uid) as unknown as
|
|
46
|
+
event.sender.wrapper.find(".k-menu-item[postrender]").each((index, htmlElement: HTMLElement) => {
|
|
47
|
+
const uid = htmlElement.getAttribute("data-uid");
|
|
48
|
+
const hierarchicalListItemViewModel = this.dataSource.getByUid(uid) as unknown as IHierarchicalListItemProperties;
|
|
49
49
|
if (hierarchicalListItemViewModel) {
|
|
50
|
-
applyBindings(hierarchicalListItemViewModel,
|
|
51
|
-
|
|
50
|
+
applyBindings(hierarchicalListItemViewModel, htmlElement);
|
|
52
51
|
|
|
53
52
|
if (hierarchicalListItemViewModel[getContent]) {
|
|
54
53
|
const content = hierarchicalListItemViewModel[getContent]();
|
|
55
|
-
if (content
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
54
|
+
if (isRegisteredViewModel(content)) {
|
|
55
|
+
const element = getElement(content);
|
|
56
|
+
if (element) {
|
|
57
|
+
const firstChild = htmlElement.firstElementChild as HTMLElement;
|
|
58
|
+
firstChild.style.padding = "0";
|
|
59
|
+
firstChild.innerHTML = "";
|
|
60
|
+
firstChild.appendChild(element.render());
|
|
61
|
+
}
|
|
60
62
|
}
|
|
61
63
|
}
|
|
62
64
|
}
|
|
63
|
-
|
|
65
|
+
htmlElement.removeAttribute("postrender");
|
|
64
66
|
});
|
|
65
67
|
}
|
|
66
68
|
);
|
|
@@ -82,7 +84,7 @@ export class MenuElement extends Element<IMenuProperties> {
|
|
|
82
84
|
if (listItems) {
|
|
83
85
|
//Add all visible menuItems to a dictionary
|
|
84
86
|
listItems.forEach((listItem) => {
|
|
85
|
-
if (listItem
|
|
87
|
+
if (isRegisteredViewModel(listItem)) {
|
|
86
88
|
listItem["attr"] = { postrender: true };
|
|
87
89
|
}
|
|
88
90
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import * as kendo from "@progress/kendo-ui/js/kendo.treeview.js";
|
|
2
|
-
import { Element,
|
|
3
|
-
import {
|
|
2
|
+
import { Element, IElementProperties, extendProperties, applyBindings, isRegisteredViewModel, getElement } from "../../../framework/element";
|
|
3
|
+
import { IHierarchicalListItemProperties } from "../../custom/ListItem/ListItem";
|
|
4
4
|
import { ISubscribable, observable } from "../../../framework/observable";
|
|
5
5
|
const getContent = "getContent";
|
|
6
6
|
|
|
7
7
|
export interface ITreeviewProperties extends IElementProperties {
|
|
8
|
-
items?: Array<
|
|
9
|
-
selectedItem?:
|
|
8
|
+
items?: Array<IHierarchicalListItemProperties> | ISubscribable<Array<IHierarchicalListItemProperties>>;
|
|
9
|
+
selectedItem?: IHierarchicalListItemProperties | ISubscribable<IHierarchicalListItemProperties>;
|
|
10
10
|
select?: (dataItem: unknown) => void;
|
|
11
11
|
}
|
|
12
12
|
export class TreeviewElement extends Element<ITreeviewProperties> {
|
|
@@ -62,30 +62,33 @@ export class TreeviewElement extends Element<ITreeviewProperties> {
|
|
|
62
62
|
if (selectedItem) {
|
|
63
63
|
event.sender.wrapper.find(".k-treeview-item").each((index, element: HTMLElement) => {
|
|
64
64
|
const uid = element.getAttribute("data-uid");
|
|
65
|
-
const hierarchicalListItemViewModel = this.dataSource.getByUid(uid) as unknown as
|
|
65
|
+
const hierarchicalListItemViewModel = this.dataSource.getByUid(uid) as unknown as IHierarchicalListItemProperties;
|
|
66
66
|
if (hierarchicalListItemViewModel.id === selectedItem.id) {
|
|
67
67
|
event.sender.select(element);
|
|
68
68
|
}
|
|
69
69
|
});
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
event.sender.wrapper.find(".k-treeview-item[postrender]").each((index,
|
|
73
|
-
const uid =
|
|
74
|
-
const hierarchicalListItemViewModel = this.dataSource.getByUid(uid) as unknown as
|
|
72
|
+
event.sender.wrapper.find(".k-treeview-item[postrender]").each((index, htmlElement: HTMLElement) => {
|
|
73
|
+
const uid = htmlElement.getAttribute("data-uid");
|
|
74
|
+
const hierarchicalListItemViewModel = this.dataSource.getByUid(uid) as unknown as IHierarchicalListItemProperties;
|
|
75
75
|
if (hierarchicalListItemViewModel) {
|
|
76
|
-
applyBindings(hierarchicalListItemViewModel,
|
|
76
|
+
applyBindings(hierarchicalListItemViewModel, htmlElement);
|
|
77
77
|
|
|
78
78
|
if (hierarchicalListItemViewModel[getContent]) {
|
|
79
79
|
const content = hierarchicalListItemViewModel[getContent]();
|
|
80
|
-
if (content
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
80
|
+
if (isRegisteredViewModel(content)) {
|
|
81
|
+
const element = getElement(content);
|
|
82
|
+
if (element) {
|
|
83
|
+
const firstChild = htmlElement.firstElementChild as HTMLElement;
|
|
84
|
+
firstChild.style.padding = "0";
|
|
85
|
+
firstChild.innerHTML = "";
|
|
86
|
+
firstChild.appendChild(element.render());
|
|
87
|
+
}
|
|
85
88
|
}
|
|
86
89
|
}
|
|
87
90
|
}
|
|
88
|
-
|
|
91
|
+
htmlElement.removeAttribute("postrender");
|
|
89
92
|
});
|
|
90
93
|
}
|
|
91
94
|
);
|
|
@@ -100,9 +103,9 @@ export class TreeviewElement extends Element<ITreeviewProperties> {
|
|
|
100
103
|
}
|
|
101
104
|
}
|
|
102
105
|
|
|
103
|
-
private buildItems(listItems: Array<
|
|
104
|
-
const itemDictionary: { [id: string]:
|
|
105
|
-
const topLevelItems = new Array<
|
|
106
|
+
private buildItems(listItems: Array<IHierarchicalListItemProperties>) {
|
|
107
|
+
const itemDictionary: { [id: string]: IHierarchicalListItemProperties } = {};
|
|
108
|
+
const topLevelItems = new Array<IHierarchicalListItemProperties>();
|
|
106
109
|
|
|
107
110
|
if (listItems) {
|
|
108
111
|
//Add all visible menuItems to a dictionary
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as leaflet from "leaflet";
|
|
2
|
-
import { IElement, getElement,
|
|
2
|
+
import { IElement, getElement, IElementProperties, isRegisteredViewModel } from "../../../framework/element";
|
|
3
3
|
|
|
4
4
|
export interface ILeafletLabelControlOptions extends leaflet.ControlOptions {
|
|
5
|
-
content: string | IElement |
|
|
5
|
+
content: string | IElement | IElementProperties
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
export class LeafletLabelControl extends leaflet.Control {
|
|
@@ -12,23 +12,23 @@ export class LeafletLabelControl extends leaflet.Control {
|
|
|
12
12
|
this.content = options.content;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
private readonly content: string | IElement |
|
|
15
|
+
private readonly content: string | IElement | IElementProperties;
|
|
16
16
|
|
|
17
17
|
onAdd(): HTMLElement {
|
|
18
18
|
const div = document.createElement("div");
|
|
19
19
|
|
|
20
|
-
let
|
|
21
|
-
if (this.content
|
|
22
|
-
|
|
23
|
-
if (
|
|
24
|
-
div.appendChild(
|
|
20
|
+
let element;
|
|
21
|
+
if (typeof this.content === "object" && isRegisteredViewModel(this.content)) {
|
|
22
|
+
element = getElement(this.content);
|
|
23
|
+
if (element) {
|
|
24
|
+
div.appendChild(element.render());
|
|
25
25
|
}
|
|
26
26
|
} else if (typeof this.content === "string") {
|
|
27
27
|
div.innerText = this.content;
|
|
28
28
|
} else {
|
|
29
|
-
|
|
30
|
-
if (
|
|
31
|
-
div.appendChild(
|
|
29
|
+
element = this.content as IElement;
|
|
30
|
+
if (element.render) {
|
|
31
|
+
div.appendChild(element.render());
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ISubscribable, observable } from "../../../framework/observable";
|
|
2
2
|
import * as leaflet from "leaflet";
|
|
3
|
-
import { Element, addToDictionary,
|
|
3
|
+
import { Element, addToDictionary, IElementProperties, extendProperties } from "../../../framework/element";
|
|
4
4
|
|
|
5
5
|
export interface IMapProperties extends IElementProperties {
|
|
6
6
|
renderer?: leaflet.Renderer;
|
|
@@ -164,10 +164,9 @@ export function createMap(properties: IMapProperties) {
|
|
|
164
164
|
|
|
165
165
|
export const burtonville: leaflet.LatLngExpression = [50.283939, 5.964070];
|
|
166
166
|
|
|
167
|
-
export class MapProperties
|
|
167
|
+
export class MapProperties implements IMapProperties {
|
|
168
168
|
constructor(properties: IMapProperties) {
|
|
169
|
-
|
|
170
|
-
this.setProperties(this, properties);
|
|
169
|
+
Object.assign(this, properties);
|
|
171
170
|
}
|
|
172
171
|
|
|
173
172
|
renderer?: leaflet.Renderer;
|
package/src/framework/element.ts
CHANGED
|
@@ -255,28 +255,28 @@ export class Element<TElementProperties extends IElementProperties = IElementPro
|
|
|
255
255
|
// #endregion
|
|
256
256
|
|
|
257
257
|
// #region ElementProperties Class definition
|
|
258
|
-
export abstract class ElementProperties implements IElementProperties {
|
|
259
|
-
protected setProperties<TProperties>(object: object, properties?: TProperties) {
|
|
260
|
-
if (properties) {
|
|
261
|
-
Object.keys(properties).forEach((property) => {
|
|
262
|
-
object[property] = properties[property];
|
|
263
|
-
});
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
attributes?: IAttributes;
|
|
268
|
-
classNames?: Array<string> | IClassNames | ISubscribable<IClassNames>;
|
|
269
|
-
style?: IStyle;
|
|
270
|
-
visible?: boolean | ISubscribable<boolean>;
|
|
271
|
-
disabled?: boolean | ISubscribable<boolean>;
|
|
272
|
-
innerHtml?: string | ISubscribable<string>;
|
|
273
|
-
textContent?: string | ISubscribable<string>;
|
|
274
|
-
addViewModelToDataObject?: boolean;
|
|
275
|
-
userSelectable?: boolean;
|
|
276
|
-
eventListeners?: Array<IEventListener>;
|
|
277
|
-
elementType?: string;
|
|
278
|
-
focused?: boolean | ISubscribable<boolean>;
|
|
279
|
-
}
|
|
258
|
+
//export abstract class ElementProperties implements IElementProperties {
|
|
259
|
+
// protected setProperties<TProperties>(object: object, properties?: TProperties) {
|
|
260
|
+
// if (properties) {
|
|
261
|
+
// Object.keys(properties).forEach((property) => {
|
|
262
|
+
// object[property] = properties[property];
|
|
263
|
+
// });
|
|
264
|
+
// }
|
|
265
|
+
// }
|
|
266
|
+
|
|
267
|
+
// attributes?: IAttributes;
|
|
268
|
+
// classNames?: Array<string> | IClassNames | ISubscribable<IClassNames>;
|
|
269
|
+
// style?: IStyle;
|
|
270
|
+
// visible?: boolean | ISubscribable<boolean>;
|
|
271
|
+
// disabled?: boolean | ISubscribable<boolean>;
|
|
272
|
+
// innerHtml?: string | ISubscribable<string>;
|
|
273
|
+
// textContent?: string | ISubscribable<string>;
|
|
274
|
+
// addViewModelToDataObject?: boolean;
|
|
275
|
+
// userSelectable?: boolean;
|
|
276
|
+
// eventListeners?: Array<IEventListener>;
|
|
277
|
+
// elementType?: string;
|
|
278
|
+
// focused?: boolean | ISubscribable<boolean>;
|
|
279
|
+
//}
|
|
280
280
|
// #endregion
|
|
281
281
|
|
|
282
282
|
//#region Element helper functions
|
|
@@ -593,11 +593,15 @@ export function addToDictionary(viewModel: Function, view: Function) {
|
|
|
593
593
|
elementDictionary.set(viewModel, view);
|
|
594
594
|
}
|
|
595
595
|
|
|
596
|
+
export function isRegisteredViewModel(viewModel: object): boolean {
|
|
597
|
+
return viewModel && viewModel.constructor && elementDictionary.has(viewModel.constructor);
|
|
598
|
+
}
|
|
599
|
+
|
|
596
600
|
export function getElement(viewModel: object): IElement {
|
|
597
601
|
if (viewModel && viewModel.constructor) {
|
|
598
|
-
const
|
|
599
|
-
if (
|
|
600
|
-
return new
|
|
602
|
+
const view = elementDictionary.get(viewModel.constructor);
|
|
603
|
+
if (view.prototype) {
|
|
604
|
+
return new view(viewModel);
|
|
601
605
|
}
|
|
602
606
|
//if (typeof element === "function") {
|
|
603
607
|
// return element(viewModel);
|
|
@@ -613,4 +617,12 @@ export function render(viewModel: object): HTMLElement {
|
|
|
613
617
|
}
|
|
614
618
|
return null;
|
|
615
619
|
}
|
|
620
|
+
|
|
621
|
+
//export function setProperties(object: object, properties?: object) {
|
|
622
|
+
// if (properties) {
|
|
623
|
+
// Object.keys(properties).forEach((property) => {
|
|
624
|
+
// object[property] = properties[property];
|
|
625
|
+
// });
|
|
626
|
+
// }
|
|
627
|
+
//}
|
|
616
628
|
//#endregion
|