dbm 1.0.6 → 1.1.1
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/flow/controllers/index.js +1 -0
- package/flow/controllers/select/SingleSelection.js +65 -0
- package/flow/controllers/select/index.js +1 -0
- package/flow/index.js +1 -0
- package/flow/updatefunctions/basic/Length.js +20 -0
- package/flow/updatefunctions/basic/PropertyOf.js +21 -0
- package/flow/updatefunctions/basic/index.js +17 -0
- package/flow/updatefunctions/dom/ElementPosition.js +1 -1
- package/flow/updatefunctions/dom/HorizontalFlip.js +5 -6
- package/flow/updatefunctions/dom/StyleObject.js +1 -1
- package/flow/updatefunctions/logic/Condition.js +12 -1
- package/flow/updatefunctions/logic/Invert.js +18 -0
- package/flow/updatefunctions/logic/Switch.js +6 -0
- package/flow/updatefunctions/logic/index.js +8 -0
- package/graphapi/webclient/GraphApi.js +4 -0
- package/graphapi/webclient/WebSocketConnection.js +23 -8
- package/graphapi/webclient/decode/index.js +16 -0
- package/package.json +1 -1
- package/react/BaseObject.js +18 -7
- package/react/ChildFunctions.js +27 -0
- package/react/admin/EditPage.js +41 -1
- package/react/admin/{Editor.js → editor/Editor.js} +27 -11
- package/react/admin/{EditorBlock.js → editor/EditorBlock.js} +15 -4
- package/react/admin/editor/EditorBlockFields.js +23 -0
- package/react/admin/editor/EditorBlockName.js +28 -0
- package/react/admin/editor/fields/CheckboxField.js +54 -0
- package/react/admin/editor/fields/ImageField.js +137 -0
- package/react/admin/editor/fields/RichTextField.js +75 -0
- package/react/admin/editor/fields/TextField.js +53 -0
- package/react/admin/editor/fields/index.js +4 -0
- package/react/admin/editor/index.js +6 -0
- package/react/admin/index.js +3 -4
- package/react/animation/AnimatedElement.js +22 -0
- package/react/animation/AnimationController.js +53 -0
- package/react/animation/index.js +22 -0
- package/react/area/HasData.js +5 -0
- package/react/area/InsertElement.js +1 -1
- package/react/area/List.js +46 -0
- package/react/area/OpenCloseExpandableArea.js +14 -5
- package/react/area/ResponsiveLayout.js +48 -0
- package/react/area/index.js +12 -1
- package/react/blocks/Image.js +17 -0
- package/react/blocks/index.js +69 -55
- package/react/cookies/CookieSettings.js +1 -1
- package/react/form/Checkbox.js +2 -1
- package/react/form/FileDropArea.js +92 -0
- package/react/form/FormField.js +1 -0
- package/react/form/LabelledArea.js +22 -0
- package/react/form/index.js +3 -1
- package/react/image/CoverScaledImage.js +32 -0
- package/react/image/Image.js +37 -0
- package/react/image/LocalImage.js +42 -0
- package/react/image/WidthScaledImage.js +30 -0
- package/react/image/index.js +4 -0
- package/react/index.js +6 -1
- package/react/interaction/CommandButton.js +97 -0
- package/react/interaction/index.js +3 -0
- package/react/login/LoginForm.js +1 -1
- package/react/source/index.js +15 -1
- package/react/text/Link.js +18 -0
- package/react/text/index.js +1 -0
- package/site/SiteDataLoader.js +1 -1
- package/tracking/Controller.js +1 -1
- package/utils/ArrayFunctions.js +128 -2
- package/utils/UrlFunctions.js +77 -0
- package/utils/index.js +2 -1
- package/react/admin/EditorBlockName.js +0 -19
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Dbm from "../../index.js";
|
|
3
|
+
|
|
4
|
+
export default class List extends Dbm.react.BaseObject {
|
|
5
|
+
_construct() {
|
|
6
|
+
super._construct();
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
_renderMainElement() {
|
|
10
|
+
//console.log("List::_renderMainElement");
|
|
11
|
+
//console.log(this);
|
|
12
|
+
|
|
13
|
+
let items = this.getPropValue("items");
|
|
14
|
+
let children = this.getPropValue("children");
|
|
15
|
+
let keyField = this.getPropValue("keyField");
|
|
16
|
+
if(!keyField) {
|
|
17
|
+
keyField = "id";
|
|
18
|
+
}
|
|
19
|
+
let as = this.getPropValue("as");
|
|
20
|
+
if(!as) {
|
|
21
|
+
as = "item";
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
let slots = Dbm.react.ChildFunctions.splitIntoSlots(children);
|
|
25
|
+
|
|
26
|
+
let spacingElement = slots.spacing;
|
|
27
|
+
let mainChildren = slots.main;
|
|
28
|
+
|
|
29
|
+
let currentArray = items;
|
|
30
|
+
let currentArrayLength = currentArray.length;
|
|
31
|
+
let newChildren = [];
|
|
32
|
+
for(let i = 0; i < currentArrayLength; i++) {
|
|
33
|
+
if(spacingElement && i > 0) {
|
|
34
|
+
newChildren.push(React.createElement(React.Fragment, {key: "spacing" + (i-1)}, spacingElement));
|
|
35
|
+
}
|
|
36
|
+
let currentItem = currentArray[i];
|
|
37
|
+
let values = {};
|
|
38
|
+
values[as] = currentItem;
|
|
39
|
+
let key = Dbm.objectPath(currentItem, keyField);
|
|
40
|
+
newChildren.push(React.createElement(Dbm.react.context.AddContextVariables, {key: key, values: values}, mainChildren));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return React.createElement(React.Fragment, {}, newChildren);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
@@ -7,17 +7,22 @@ export default class OpenCloseExpandableArea extends Dbm.react.BaseObject {
|
|
|
7
7
|
|
|
8
8
|
let startValue = this.getPropValue("startState") === "open";
|
|
9
9
|
let openProperty = this.getDynamicProp("open", startValue);
|
|
10
|
+
|
|
11
|
+
let invert = Dbm.flow.updatefunctions.logic.invert(openProperty);
|
|
12
|
+
this.item.requireProperty("ariaHidden", !openProperty.value);
|
|
10
13
|
|
|
11
14
|
let switchValue = Dbm.flow.updatefunctions.logic.switchValue(openProperty).addCase(false, 0).addCase(true, 1);
|
|
12
15
|
let animateValueObject = Dbm.flow.animateValue(switchValue.output.properties.value);
|
|
13
16
|
let transformToStyle = Dbm.flow.updatefunctions.basic.transformValue(animateValueObject.properties.output, this._transformToStyle.bind(this));
|
|
14
17
|
|
|
15
18
|
this.item.requireProperty("animationStyle", {}).connectInput(transformToStyle.output.properties.value);
|
|
19
|
+
|
|
20
|
+
this.item.setValue("animation", Dbm.react.animation.connectedAnimation(transformToStyle.output.properties.value));
|
|
16
21
|
}
|
|
17
22
|
|
|
18
23
|
_transformToStyle(aEnvelope) {
|
|
19
|
-
console.log("_transformToStyle");
|
|
20
|
-
console.log(aEnvelope, this, this.item.element);
|
|
24
|
+
//console.log("_transformToStyle");
|
|
25
|
+
//console.log(aEnvelope, this, this.item.element);
|
|
21
26
|
|
|
22
27
|
if(aEnvelope === 0) {
|
|
23
28
|
return {"height": "0px", "overflow": "hidden"};
|
|
@@ -32,10 +37,14 @@ export default class OpenCloseExpandableArea extends Dbm.react.BaseObject {
|
|
|
32
37
|
_renderMainElement() {
|
|
33
38
|
//console.log("OpenCloseExpandableArea::_renderMainElement");
|
|
34
39
|
//console.log(this);
|
|
40
|
+
|
|
41
|
+
let openProperty = this.getDynamicProp("open");
|
|
35
42
|
|
|
36
|
-
return this._createMainElement(Dbm.react.
|
|
37
|
-
React.createElement(
|
|
38
|
-
this.
|
|
43
|
+
return this._createMainElement(Dbm.react.animation.AnimatedElement, {"className": "animation-element", "controller": this.item.animation.item, "aria-hidden": this.item.properties.ariaHidden},
|
|
44
|
+
React.createElement(Dbm.react.context.AddContextVariables, {"values": {"open": openProperty}},
|
|
45
|
+
React.createElement("div", {"ref": this.createRef("element")},
|
|
46
|
+
this.getPropValue("children")
|
|
47
|
+
)
|
|
39
48
|
)
|
|
40
49
|
);
|
|
41
50
|
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import Dbm from "../../index.js";
|
|
2
|
+
import React from "react";
|
|
3
|
+
|
|
4
|
+
export default class ResponsiveLayout extends Dbm.core.BaseObject {
|
|
5
|
+
_construct() {
|
|
6
|
+
super._construct();
|
|
7
|
+
|
|
8
|
+
this.item.setValue("widthElement", null);
|
|
9
|
+
|
|
10
|
+
let elementSize = new Dbm.flow.updatefunctions.dom.ElementSize();
|
|
11
|
+
this.item.setValue("elementSize", elementSize);
|
|
12
|
+
|
|
13
|
+
elementSize.input.properties.element.connectInput(this.item.properties.widthElement);
|
|
14
|
+
elementSize.start();
|
|
15
|
+
|
|
16
|
+
let layoutSwitch = new Dbm.flow.updatefunctions.logic.RangeSwitch();
|
|
17
|
+
layoutSwitch.input.properties.value.connectInput(elementSize.output.properties.width);
|
|
18
|
+
|
|
19
|
+
this.item.setValue("layoutSwitch", layoutSwitch)
|
|
20
|
+
|
|
21
|
+
this.item.setValue("element", null);
|
|
22
|
+
this.item.properties.element.connectInput(layoutSwitch.output.properties.value);
|
|
23
|
+
|
|
24
|
+
let refToProperty = new Dbm.react.RefToProperty();
|
|
25
|
+
refToProperty.property = this.item.properties.widthElement;
|
|
26
|
+
this.item.setValue("ref/widthElement", refToProperty);
|
|
27
|
+
|
|
28
|
+
this.item.setValue("mainElement", React.createElement("div", {ref: refToProperty},
|
|
29
|
+
React.createElement(Dbm.react.area.InsertElement, {element: this.item.properties.element})
|
|
30
|
+
));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
setDefaultLayout(aElement) {
|
|
34
|
+
this.item.layoutSwitch.input.defaultValue = React.createElement(React.Fragment, {"key": "default"}, aElement);
|
|
35
|
+
|
|
36
|
+
return this;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
addLayout(aElement, aMinSize = null, aMaxSize = null) {
|
|
40
|
+
this.item.layoutSwitch.addValueForRange(React.createElement(React.Fragment, {"key": "layout_" + this.item.layoutSwitch.input.ranges.length}, aElement), aMinSize, aMaxSize);
|
|
41
|
+
|
|
42
|
+
return this;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
get mainElement() {
|
|
46
|
+
return this.item.mainElement;
|
|
47
|
+
}
|
|
48
|
+
}
|
package/react/area/index.js
CHANGED
|
@@ -1,4 +1,15 @@
|
|
|
1
|
+
import Dbm from "../../index.js";
|
|
2
|
+
|
|
1
3
|
export {default as InsertElement} from "./InsertElement.js";
|
|
2
4
|
export {default as HasData} from "./HasData.js";
|
|
3
5
|
export {default as ScrollActivatedArea} from "./ScrollActivatedArea.js";
|
|
4
|
-
export {default as OpenCloseExpandableArea} from "./OpenCloseExpandableArea.js";
|
|
6
|
+
export {default as OpenCloseExpandableArea} from "./OpenCloseExpandableArea.js";
|
|
7
|
+
export {default as ResponsiveLayout} from "./ResponsiveLayout.js";
|
|
8
|
+
export {default as List} from "./List.js";
|
|
9
|
+
|
|
10
|
+
export let responsiveLayout = function(aDefaultLayout) {
|
|
11
|
+
let newResponsiveLayout = new Dbm.react.area.ResponsiveLayout();
|
|
12
|
+
newResponsiveLayout.setDefaultLayout(aDefaultLayout);
|
|
13
|
+
|
|
14
|
+
return newResponsiveLayout;
|
|
15
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Dbm from "../../index.js";
|
|
3
|
+
|
|
4
|
+
export default class Image extends Dbm.react.BaseObject {
|
|
5
|
+
_construct() {
|
|
6
|
+
super._construct();
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
_renderMainElement() {
|
|
10
|
+
|
|
11
|
+
let url = Dbm.utils.UrlFunctions.createScaledImageUrl(Dbm.objectPath(this.context, "blockData.file"), 800);
|
|
12
|
+
|
|
13
|
+
return this._createMainElement("div", {},
|
|
14
|
+
React.createElement(Dbm.react.image.Image, {elementType: "img", className: "full-width", src: url, alt: Dbm.react.source.blockData("caption")} )
|
|
15
|
+
)
|
|
16
|
+
}
|
|
17
|
+
}
|
package/react/blocks/index.js
CHANGED
|
@@ -1,10 +1,31 @@
|
|
|
1
1
|
import Dbm from "../../index.js";
|
|
2
2
|
import {createElement} from "react";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
export {default as Image} from "./Image.js";
|
|
5
|
+
|
|
6
|
+
export let createToolConfiguration = function(aId, aName, aInitialData = {}, aSanitizeSettings = {}, aIcon = null) {
|
|
7
|
+
|
|
8
|
+
class DynamicEditorBlock extends Dbm.react.admin.editor.EditorBlock {
|
|
9
|
+
|
|
10
|
+
_construct() {
|
|
11
|
+
super._construct();
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
static get toolbox() {
|
|
15
|
+
|
|
16
|
+
return {
|
|
17
|
+
title: aName,
|
|
18
|
+
icon: aIcon
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
static get sanitize() {
|
|
23
|
+
return aSanitizeSettings;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
5
26
|
|
|
6
27
|
let returnObject = {
|
|
7
|
-
"class":
|
|
28
|
+
"class": DynamicEditorBlock,
|
|
8
29
|
"config": {
|
|
9
30
|
"module": aId,
|
|
10
31
|
"name": aName,
|
|
@@ -14,76 +35,69 @@ let createToolConfiguration = function(aId, aName, aInitialData = {}, aIcon = nu
|
|
|
14
35
|
"toolbox": {
|
|
15
36
|
title: aName,
|
|
16
37
|
icon: aIcon
|
|
17
|
-
}
|
|
38
|
+
}
|
|
18
39
|
}
|
|
19
40
|
|
|
20
41
|
return returnObject;
|
|
21
42
|
}
|
|
22
43
|
|
|
23
|
-
export let
|
|
24
|
-
|
|
25
|
-
let displayNameModule = new Dbm.react.modules.ModuleCreator();
|
|
44
|
+
export let registerEditorBlock = function(aModuleName, aName, aEditorModule = null, aInitialData = {}, aSanitizeSettings = {}) {
|
|
26
45
|
|
|
27
|
-
|
|
28
|
-
|
|
46
|
+
if(!aEditorModule) {
|
|
47
|
+
aEditorModule = getDefaultEditorModule();
|
|
48
|
+
}
|
|
29
49
|
|
|
30
50
|
let editorConfigItem = Dbm.getInstance().repository.getItem("editorjs");
|
|
31
51
|
let tools = editorConfigItem.tools ? {...editorConfigItem.tools} : {};
|
|
32
52
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
let editorItem = new Dbm.repository.Item();
|
|
37
|
-
editorItem.setValue("controller", displayNameModule);
|
|
38
|
-
editorItem.register("moduleCreators/blocks/editor/" + moduleName);
|
|
53
|
+
let editorItem = new Dbm.repository.Item();
|
|
54
|
+
editorItem.setValue("controller", aEditorModule);
|
|
55
|
+
editorItem.register("moduleCreators/blocks/editor/" + aModuleName);
|
|
39
56
|
|
|
40
|
-
|
|
41
|
-
elementItem.setValue("element", createElement(Dbm.react.cookies.CookieSettings));
|
|
42
|
-
elementItem.register("blocks/" + moduleName);
|
|
57
|
+
tools[aModuleName] = createToolConfiguration(aModuleName, aName, aInitialData, aSanitizeSettings);
|
|
43
58
|
|
|
44
|
-
|
|
45
|
-
|
|
59
|
+
editorConfigItem.setValue("tools", tools);
|
|
60
|
+
}
|
|
46
61
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
62
|
+
export let registerFrontBlock = function(aModuleName, aElement) {
|
|
63
|
+
|
|
64
|
+
let elementItem = new Dbm.repository.Item();
|
|
65
|
+
elementItem.setValue("element", aElement);
|
|
66
|
+
elementItem.register("blocks/" + aModuleName);
|
|
67
|
+
}
|
|
53
68
|
|
|
54
|
-
|
|
55
|
-
elementItem.setValue("element", createElement(Dbm.react.login.LoginForm));
|
|
56
|
-
elementItem.register("blocks/" + moduleName);
|
|
69
|
+
export let registerBlock = function(aModuleName, aName, aElement, aEditorElement = null, aInitialData = {}, aSanitizeSettings = {}) {
|
|
57
70
|
|
|
58
|
-
|
|
71
|
+
let editorModule;
|
|
72
|
+
if(!aEditorElement) {
|
|
73
|
+
editorModule = getDefaultEditorModule();
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
editorModule = new Dbm.react.modules.ModuleCreator();
|
|
77
|
+
editorModule.setMainElement(aEditorElement);
|
|
59
78
|
}
|
|
60
79
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
let
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
)
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
let
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
let elementItem = new Dbm.repository.Item();
|
|
77
|
-
elementItem.setValue("element",
|
|
78
|
-
createElement("div", {},
|
|
79
|
-
createElement("div", {contentEditable: true}, "test"),
|
|
80
|
-
createElement("input", {})
|
|
81
|
-
)
|
|
82
|
-
);
|
|
83
|
-
elementItem.register("blocks/" + moduleName);
|
|
84
|
-
|
|
85
|
-
tools[moduleName] = createToolConfiguration(moduleName, "Test");
|
|
80
|
+
registerEditorBlock(aModuleName, aName, editorModule, aInitialData, aSanitizeSettings);
|
|
81
|
+
registerFrontBlock(aModuleName, aElement);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export let getDefaultEditorModule = function() {
|
|
85
|
+
let moduleItem = Dbm.getInstance().repository.getItem("editorjs");
|
|
86
|
+
|
|
87
|
+
let displayNameModule = moduleItem.defaultEditor;
|
|
88
|
+
if(!displayNameModule) {
|
|
89
|
+
displayNameModule = new Dbm.react.modules.ModuleCreator();
|
|
90
|
+
|
|
91
|
+
let displayNameEditor = createElement(Dbm.react.admin.editor.EditorBlockName, {});
|
|
92
|
+
displayNameModule.setMainElement(displayNameEditor);
|
|
93
|
+
|
|
94
|
+
moduleItem.setValue("defaultEditor", displayNameModule);
|
|
86
95
|
}
|
|
87
96
|
|
|
88
|
-
|
|
97
|
+
return displayNameModule;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export let registerAllBlocks = function() {
|
|
101
|
+
registerBlock("cookie/settings", "Cookie settings", createElement(Dbm.react.cookies.CookieSettings));
|
|
102
|
+
registerBlock("login/loginForm", "Login form", createElement(Dbm.react.login.LoginForm));
|
|
89
103
|
}
|
|
@@ -95,7 +95,7 @@ export default class CookieSettings extends Dbm.react.BaseObject {
|
|
|
95
95
|
return aSetting.element;
|
|
96
96
|
})
|
|
97
97
|
|
|
98
|
-
return this._createMainElement("div", {},
|
|
98
|
+
return this._createMainElement("div", {"className": "content-narrow"},
|
|
99
99
|
React.createElement("div", {className: "body-text"},
|
|
100
100
|
React.createElement("div", {"className": "flex-row small-item-spacing"},
|
|
101
101
|
React.createElement("div", {"className": "flex-row-item"},
|
package/react/form/Checkbox.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import React from "react";
|
|
1
2
|
import Dbm from "../../index.js";
|
|
2
3
|
|
|
3
4
|
export default class Checkbox extends Dbm.react.BaseObject {
|
|
@@ -11,7 +12,7 @@ export default class Checkbox extends Dbm.react.BaseObject {
|
|
|
11
12
|
|
|
12
13
|
_callback_change(aEvent) {
|
|
13
14
|
//console.log("_callback_change");
|
|
14
|
-
//console.log(aEvent);
|
|
15
|
+
//console.log(aEvent, this);
|
|
15
16
|
|
|
16
17
|
let checked = aEvent.target.checked;
|
|
17
18
|
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Dbm from "../../index.js";
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
export default class FileDropArea extends Dbm.react.BaseObject {
|
|
6
|
+
|
|
7
|
+
_construct() {
|
|
8
|
+
super._construct();
|
|
9
|
+
|
|
10
|
+
this._id = "dropField" + Dbm.getInstance().getNextId();
|
|
11
|
+
this.item.requireProperty("dropHighlightClass", "");
|
|
12
|
+
let classNameAdd = Dbm.flow.updatefunctions.logic.add("file-drop-area display-block cursor-pointer", this.item.properties.dropHighlightClass)
|
|
13
|
+
|
|
14
|
+
this.item.setValue("classNameAdd", classNameAdd);
|
|
15
|
+
this.item.requireProperty("fullClass", "").connectInput(classNameAdd.output.properties.result);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
_handleFiles(aFiles) {
|
|
19
|
+
console.log("_handleFiles");
|
|
20
|
+
console.log(aFiles);
|
|
21
|
+
|
|
22
|
+
let command = this.getPropValue("changeCommands");
|
|
23
|
+
|
|
24
|
+
command.perform(this, aFiles);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
_highlight(aEvent) {
|
|
28
|
+
aEvent.preventDefault()
|
|
29
|
+
aEvent.stopPropagation()
|
|
30
|
+
|
|
31
|
+
this.item.setValue("dropHighlightClass", "drop-file-highlight");
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
_unhighlight(aEvent) {
|
|
35
|
+
aEvent.preventDefault()
|
|
36
|
+
aEvent.stopPropagation()
|
|
37
|
+
|
|
38
|
+
this.item.setValue("dropHighlightClass", "");
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
_handleDrop(aEvent) {
|
|
42
|
+
console.log("_handleDrop");
|
|
43
|
+
|
|
44
|
+
aEvent.preventDefault()
|
|
45
|
+
aEvent.stopPropagation()
|
|
46
|
+
|
|
47
|
+
this.item.setValue("dropHighlightClass", "");
|
|
48
|
+
|
|
49
|
+
let dataTransfer = aEvent.dataTransfer;
|
|
50
|
+
let files = dataTransfer.files;
|
|
51
|
+
|
|
52
|
+
this._handleFiles(files);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
_handleChange(aEvent) {
|
|
56
|
+
console.log("_handleChange");
|
|
57
|
+
|
|
58
|
+
this._handleFiles(aEvent.target.files);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
_selectFiles() {
|
|
62
|
+
var input = document.createElement('input');
|
|
63
|
+
input.type = 'file';
|
|
64
|
+
|
|
65
|
+
let accept = this.getPropValue("accept");
|
|
66
|
+
if(accept) {
|
|
67
|
+
input.accept = accept;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
input.addEventListener("change", (aEvent) => {this._handleChange(aEvent)});
|
|
71
|
+
input.click();
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
_renderMainElement() {
|
|
75
|
+
|
|
76
|
+
return this._createMainElement(Dbm.react.BaseObject, {
|
|
77
|
+
role: "button",
|
|
78
|
+
tabIndex: 0,
|
|
79
|
+
className: this.item.properties.fullClass,
|
|
80
|
+
onDragEnter: (aEvent) => {this._highlight(aEvent);},
|
|
81
|
+
onDragOver: (aEvent) => {this._highlight(aEvent);},
|
|
82
|
+
onDragLeave: (aEvent) => {this._unhighlight(aEvent);},
|
|
83
|
+
onDrop: (aEvent) => {this._handleDrop(aEvent);},
|
|
84
|
+
onKeyDown: function(aEvent) {console.log(aEvent); if(aEvent.key === "Enter") aEvent.target.click()},
|
|
85
|
+
onClick: (aEvent) => {this._selectFiles();}
|
|
86
|
+
},
|
|
87
|
+
this.getPropValue("children")
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
|
package/react/form/FormField.js
CHANGED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Dbm from "../../index.js";
|
|
3
|
+
|
|
4
|
+
export default class LabelledArea extends Dbm.react.BaseObject {
|
|
5
|
+
_construct() {
|
|
6
|
+
super._construct();
|
|
7
|
+
|
|
8
|
+
this.getDynamicProp("label", "");
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
_renderMainElement() {
|
|
12
|
+
|
|
13
|
+
return this._createMainElement("div", {},
|
|
14
|
+
React.createElement("label", {"className": "standard-field-label", "htmlFor": this.getProp("for")},
|
|
15
|
+
Dbm.react.text.text(this.getDynamicProp("label"))
|
|
16
|
+
),
|
|
17
|
+
React.createElement("div", {"className": "spacing micro"}),
|
|
18
|
+
this.getPropValue("children")
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
package/react/form/index.js
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
export {default as Checkbox} from "./Checkbox.js";
|
|
2
|
-
export {default as FormField} from "./FormField.js";
|
|
2
|
+
export {default as FormField} from "./FormField.js";
|
|
3
|
+
export {default as LabelledArea} from "./LabelledArea.js";
|
|
4
|
+
export {default as FileDropArea} from "./FileDropArea.js";
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import Dbm from "../../index.js";
|
|
2
|
+
import React from "react";
|
|
3
|
+
|
|
4
|
+
export default class CoverScaledImage extends Dbm.react.BaseObject {
|
|
5
|
+
_construct() {
|
|
6
|
+
super._construct();
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
_removedUsedProps(aProps) {
|
|
10
|
+
delete aProps["image"];
|
|
11
|
+
delete aProps["targetWidth"];
|
|
12
|
+
delete aProps["targetHeight"];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
_renderMainElement() {
|
|
16
|
+
|
|
17
|
+
let image = this.getPropValue("image");
|
|
18
|
+
let width = this.getPropValue("targetWidth");
|
|
19
|
+
let height = this.getPropValue("targetHeight");
|
|
20
|
+
let url = Dbm.utils.UrlFunctions.createCoverScaledImageUrl(image, width, height);
|
|
21
|
+
|
|
22
|
+
let newProps = this._copyProps({src: url});
|
|
23
|
+
|
|
24
|
+
let elementType = this.getPropValue("elementType");
|
|
25
|
+
if(elementType) {
|
|
26
|
+
newProps["elementType"] = elementType;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return React.createElement(Dbm.react.image.Image, newProps, this.getPropValue("children"));
|
|
30
|
+
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import Dbm from "../../index.js";
|
|
2
|
+
|
|
3
|
+
export default class Image extends Dbm.react.BaseObject {
|
|
4
|
+
_construct() {
|
|
5
|
+
super._construct();
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
_removedUsedProps(aProps) {
|
|
9
|
+
let elementType = this.getPropValue("elementType");
|
|
10
|
+
|
|
11
|
+
let isDiv = (elementType !== "img");
|
|
12
|
+
if(isDiv) {
|
|
13
|
+
delete aProps["src"];
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
_renderMainElement() {
|
|
18
|
+
|
|
19
|
+
let src = this.getPropValue("src");
|
|
20
|
+
let elementType = this.getPropValue("elementType");
|
|
21
|
+
|
|
22
|
+
let isDiv = (elementType !== "img");
|
|
23
|
+
if(isDiv) {
|
|
24
|
+
let imageStyle = {
|
|
25
|
+
"backgroundImage": "url(" + src + ")"
|
|
26
|
+
};
|
|
27
|
+
let className = "image";
|
|
28
|
+
|
|
29
|
+
return this._createMainElement("div", {style: imageStyle, className: className}, this.getPropValue("children"));
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
let className = "image";
|
|
33
|
+
return this._createMainElement("img", {src: src, className: className});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import Dbm from "../../index.js";
|
|
2
|
+
|
|
3
|
+
export default class LocalImage extends Dbm.react.BaseObject {
|
|
4
|
+
_construct() {
|
|
5
|
+
super._construct();
|
|
6
|
+
|
|
7
|
+
this.item.requireProperty("url", null);
|
|
8
|
+
let fileProp = this.getDynamicProp("file");
|
|
9
|
+
|
|
10
|
+
Dbm.flow.addUpdateCommand(fileProp, Dbm.commands.callFunction(this._fileChanged.bind(this)));
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
_fileChanged() {
|
|
14
|
+
|
|
15
|
+
let file = this.getPropValue("file");
|
|
16
|
+
|
|
17
|
+
if(file) {
|
|
18
|
+
let fileReader = new FileReader();
|
|
19
|
+
fileReader.onload = (function(aEvent) {
|
|
20
|
+
this._fileLoaded(file, fileReader.result);
|
|
21
|
+
}).bind(this);
|
|
22
|
+
fileReader.readAsDataURL(file);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
this.item.setValue("url", null);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
_fileLoaded(aFile, aData) {
|
|
30
|
+
this.item.setValue("url", aData);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
_removedUsedProps(aProps) {
|
|
34
|
+
delete aProps["file"];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
_renderMainElement() {
|
|
38
|
+
|
|
39
|
+
return this._createMainElement(Dbm.react.image.Image, {src: this.item.properties.url}, this.getPropValue("children"));
|
|
40
|
+
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import Dbm from "../../index.js";
|
|
2
|
+
import React from "react";
|
|
3
|
+
|
|
4
|
+
export default class WidthScaledImage extends Dbm.react.BaseObject {
|
|
5
|
+
_construct() {
|
|
6
|
+
super._construct();
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
_removedUsedProps(aProps) {
|
|
10
|
+
delete aProps["image"];
|
|
11
|
+
delete aProps["targetWidth"];
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
_renderMainElement() {
|
|
15
|
+
|
|
16
|
+
let image = this.getPropValue("image");
|
|
17
|
+
let width = this.getPropValue("targetWidth");
|
|
18
|
+
let url = Dbm.utils.UrlFunctions.createScaledImageUrl(image, width);
|
|
19
|
+
|
|
20
|
+
let newProps = this._copyProps({src: url});
|
|
21
|
+
|
|
22
|
+
let elementType = this.getPropValue("elementType");
|
|
23
|
+
if(elementType) {
|
|
24
|
+
newProps["elementType"] = elementType;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return React.createElement(Dbm.react.image.Image, newProps, this.getPropValue("children"));
|
|
28
|
+
|
|
29
|
+
}
|
|
30
|
+
}
|
package/react/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export {default as BaseObject} from "./BaseObject.js";
|
|
2
2
|
export {default as RefToProperty} from "./RefToProperty.js";
|
|
3
3
|
|
|
4
|
+
export * as ChildFunctions from "./ChildFunctions.js";
|
|
5
|
+
|
|
4
6
|
export * as modules from "./modules/index.js";
|
|
5
7
|
export * as admin from "./admin/index.js";
|
|
6
8
|
export * as blocks from "./blocks/index.js";
|
|
@@ -10,4 +12,7 @@ export * as area from "./area/index.js";
|
|
|
10
12
|
export * as context from "./context/index.js";
|
|
11
13
|
export * as source from "./source/index.js";
|
|
12
14
|
export * as text from "./text/index.js";
|
|
13
|
-
export * as login from "./login/index.js";
|
|
15
|
+
export * as login from "./login/index.js";
|
|
16
|
+
export * as image from "./image/index.js";
|
|
17
|
+
export * as animation from "./animation/index.js";
|
|
18
|
+
export * as interaction from "./interaction/index.js";
|