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,97 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Dbm from "../../index.js";
|
|
3
|
+
|
|
4
|
+
export default class CommandButton extends Dbm.react.BaseObject {
|
|
5
|
+
_construct() {
|
|
6
|
+
super._construct();
|
|
7
|
+
|
|
8
|
+
this._callback_clickBound = this._callback_click.bind(this);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
_callback_click(aEvent) {
|
|
12
|
+
//console.log("_callback_click");
|
|
13
|
+
//console.log(aEvent);
|
|
14
|
+
|
|
15
|
+
let command = this.getPropValue("command");
|
|
16
|
+
|
|
17
|
+
command.perform(this, aEvent);
|
|
18
|
+
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
_performClone(aChild, aProps) {
|
|
22
|
+
|
|
23
|
+
if(aChild instanceof Array) {
|
|
24
|
+
let returnArray = [];
|
|
25
|
+
|
|
26
|
+
let currentArray = aChild;
|
|
27
|
+
let currentArrayLength = currentArray.length;
|
|
28
|
+
for(let i = 0; i < currentArrayLength; i++) {
|
|
29
|
+
let currentChild = currentArray[i];
|
|
30
|
+
returnArray.push(this._performClone(currentChild, aProps));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return returnArray;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
let newProps = aProps;
|
|
37
|
+
/*
|
|
38
|
+
//MENOTE: this is a more generalized version, but we never pass in className in this function
|
|
39
|
+
if(aChild && aChild.props && aChild.props.className) {
|
|
40
|
+
newProps = {...aProps};
|
|
41
|
+
|
|
42
|
+
if(aProps.className) {
|
|
43
|
+
newProps.className = aProps.className + " " + aChild.props.className;
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
newProps.className = aChild.props.className;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
*/
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
let callArray = [aChild, newProps];
|
|
53
|
+
|
|
54
|
+
if(aChild && aChild.props) {
|
|
55
|
+
let firstChildChildren = aChild.props.children;
|
|
56
|
+
if(!firstChildChildren) {
|
|
57
|
+
//MENOTE: do nothing
|
|
58
|
+
}
|
|
59
|
+
else if(firstChildChildren instanceof Array) {
|
|
60
|
+
callArray = callArray.concat(firstChildChildren);
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
callArray.push(firstChildChildren);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return React.cloneElement.apply(React, callArray);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
_renderMainElement() {
|
|
71
|
+
|
|
72
|
+
let children = Dbm.utils.ArrayFunctions.singleOrArray(this.getPropValue("children"));
|
|
73
|
+
|
|
74
|
+
let replacedChildren = [];
|
|
75
|
+
|
|
76
|
+
let currentArray = children;
|
|
77
|
+
let currentArrayLength = currentArray.length;
|
|
78
|
+
for(let i = 0; i < currentArrayLength; i++) {
|
|
79
|
+
let currentChild = currentArray[i];
|
|
80
|
+
if(currentChild) {
|
|
81
|
+
if(typeof(currentChild) === "string") {
|
|
82
|
+
replacedChildren.push(React.createElement("span"), {"onClick": this._callback_clickBound, onKeyDown: function(aEvent) {if(aEvent.key === "Enter") aEvent.target.click()}}, currentChild);
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
replacedChildren.push(this._performClone(currentChild, {"onClick": this._callback_clickBound, onKeyDown: function(aEvent) {if(aEvent.key === "Enter") aEvent.target.click()}}));
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
replacedChildren.push(currentChild);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
return React.createElement(React.Fragment, {}, replacedChildren);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
package/react/login/LoginForm.js
CHANGED
|
@@ -87,7 +87,7 @@ export default class LoginForm extends Dbm.react.BaseObject {
|
|
|
87
87
|
|
|
88
88
|
_renderMainElement() {
|
|
89
89
|
|
|
90
|
-
return this._createMainElement("div", {},
|
|
90
|
+
return this._createMainElement("div", {className: "content-narrow"},
|
|
91
91
|
React.createElement("div", {className: "body-text"},
|
|
92
92
|
React.createElement("div", {"className": ""},
|
|
93
93
|
React.createElement("label", {className: "standard-field-label"},
|
package/react/source/index.js
CHANGED
|
@@ -1 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
import Dbm from "../../index.js";
|
|
2
|
+
|
|
3
|
+
export {default as ContextVariableSource} from "./ContextVariableSource.js";
|
|
4
|
+
|
|
5
|
+
export let contextVariable = function(aPath) {
|
|
6
|
+
let newSource = new Dbm.react.source.ContextVariableSource();
|
|
7
|
+
newSource.item.path = aPath;
|
|
8
|
+
|
|
9
|
+
return newSource;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export let blockData = function(aPath) {
|
|
13
|
+
//METODO: check if blockdata is a source
|
|
14
|
+
return contextVariable("blockData." + aPath);
|
|
15
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import Dbm from "../../index.js";
|
|
2
|
+
|
|
3
|
+
export default class Link extends Dbm.react.BaseObject {
|
|
4
|
+
_construct() {
|
|
5
|
+
super._construct();
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
_renderMainElement() {
|
|
9
|
+
|
|
10
|
+
let url = this.getPropValue("href");
|
|
11
|
+
let prefix = this.getPropValue("prefix");
|
|
12
|
+
if(prefix) {
|
|
13
|
+
url = prefix + url;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return this._createMainElement("a", {href: url}, this.getPropValue("children"));
|
|
17
|
+
}
|
|
18
|
+
}
|
package/react/text/index.js
CHANGED
package/site/SiteDataLoader.js
CHANGED
package/tracking/Controller.js
CHANGED
package/utils/ArrayFunctions.js
CHANGED
|
@@ -1,9 +1,135 @@
|
|
|
1
|
-
|
|
1
|
+
import Dbm from "../index.js";
|
|
2
|
+
|
|
3
|
+
export const range = function(aStartValue, aEndValue, aStepValue = 1, aIncludeEndValue = true) {
|
|
4
|
+
|
|
5
|
+
let returnArray = new Array();
|
|
6
|
+
|
|
7
|
+
let loopCompare;
|
|
8
|
+
|
|
9
|
+
if(aStepValue > 0) {
|
|
10
|
+
if(aIncludeEndValue) {
|
|
11
|
+
loopCompare = function(aIndex, aLimit) {
|
|
12
|
+
return aIndex <= aLimit;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
loopCompare = function(aIndex, aLimit) {
|
|
17
|
+
return aIndex < aLimit;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
if(aIncludeEndValue) {
|
|
23
|
+
loopCompare = function(aIndex, aLimit) {
|
|
24
|
+
return aIndex >= aLimit;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
loopCompare = function(aIndex, aLimit) {
|
|
29
|
+
return aIndex > aLimit;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
for(let i = aStartValue; loopCompare(i, aEndValue); i += aStepValue) {
|
|
35
|
+
returnArray.push(i);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return returnArray;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export const removeDuplicates = function(aArray) {
|
|
2
42
|
let returnArray = [];
|
|
43
|
+
|
|
44
|
+
let currentArray = aArray;
|
|
45
|
+
let currentArrayLength = currentArray.length;
|
|
46
|
+
for(let i = 0; i < currentArrayLength; i++) {
|
|
47
|
+
let currentValue = currentArray[i];
|
|
48
|
+
if(returnArray.indexOf(currentValue) === -1) {
|
|
49
|
+
returnArray.push(currentValue);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return returnArray;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export const singleOrArray = function(aData) {
|
|
57
|
+
if(aData === null || aData === undefined) {
|
|
58
|
+
return [];
|
|
59
|
+
}
|
|
60
|
+
else if(aData instanceof Array) {
|
|
61
|
+
return aData;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return [aData];
|
|
65
|
+
}
|
|
3
66
|
|
|
67
|
+
export const removeValues = function(aArray, aRemoveValues) {
|
|
68
|
+
let returnArray = new Array();
|
|
69
|
+
|
|
70
|
+
let currentArray = aArray;
|
|
71
|
+
let currentArrayLength = currentArray.length;
|
|
72
|
+
for(let i = 0; i < currentArrayLength; i++) {
|
|
73
|
+
let currentValue = currentArray[i];
|
|
74
|
+
if(aRemoveValues.indexOf(currentValue) === -1) {
|
|
75
|
+
returnArray.push(currentValue);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
4
79
|
return returnArray;
|
|
5
80
|
}
|
|
6
81
|
|
|
7
|
-
export
|
|
82
|
+
export const trimArray = function(aArray, aMode = 3) {
|
|
83
|
+
|
|
84
|
+
if(aMode > 0) {
|
|
85
|
+
//METODO: use mode
|
|
86
|
+
if(aArray) {
|
|
87
|
+
let currentArray = aArray;
|
|
88
|
+
let currentArrayLength = currentArray.length;
|
|
89
|
+
for(let i = 0; i < currentArrayLength; i++) {
|
|
90
|
+
let currentString = currentArray[i];
|
|
91
|
+
|
|
92
|
+
if(typeof(currentString) === "string") {
|
|
93
|
+
currentArray[i] = currentString.trim();
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
8
99
|
return aArray;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export const arrayOrSeparatedString = function(aData, aSeparator = ",", aTrim = 3) {
|
|
103
|
+
if(aData === null || aData === undefined) {
|
|
104
|
+
return [];
|
|
105
|
+
}
|
|
106
|
+
else if(aData instanceof Array) {
|
|
107
|
+
return aData;
|
|
108
|
+
}
|
|
109
|
+
else if(typeof(aData) === "string") {
|
|
110
|
+
if(aData === "") {
|
|
111
|
+
return [];
|
|
112
|
+
}
|
|
113
|
+
return trimArray(aData.split(aSeparator));
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
console.error(aData + " is not array or string.");
|
|
117
|
+
return [];
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export const filterByField = function(aArray, aField, aValue) {
|
|
121
|
+
let returnArray = [];
|
|
122
|
+
|
|
123
|
+
let currentArray = aArray;
|
|
124
|
+
let currentArrayLength = currentArray.length;
|
|
125
|
+
for(let i = 0; i < currentArrayLength; i++) {
|
|
126
|
+
let currentItem = aArray[i];
|
|
127
|
+
let currentValue = Dbm.objectPath(aArray[i], aField);
|
|
128
|
+
console.log(currentValue, aValue);
|
|
129
|
+
if(currentValue === aValue) {
|
|
130
|
+
returnArray.push(currentItem);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return returnArray;
|
|
9
135
|
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
export let createScaledImageUrl = function(aImageData, aWantedWidth) {
|
|
2
|
+
if(!aImageData || !aImageData["url"]) {
|
|
3
|
+
return null;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
let url = aImageData["url"];
|
|
7
|
+
if(url.substring(url.length-4).toLowerCase() === ".svg") {
|
|
8
|
+
return url;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
if(aImageData["resizeUrl"]) {
|
|
12
|
+
let scaleToWidth = Math.min(
|
|
13
|
+
Math.round(window.devicePixelRatio*aWantedWidth),
|
|
14
|
+
Math.max(
|
|
15
|
+
100,
|
|
16
|
+
100*Math.round(window.devicePixelRatio*window.innerWidth/100)
|
|
17
|
+
)
|
|
18
|
+
);
|
|
19
|
+
url = aImageData["resizeUrl"].split("{scale}").join("width=" + scaleToWidth);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return url;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export let createCoverScaledImageUrl = function(aImageData, aWantedWidth, aWantedHeight) {
|
|
26
|
+
if(!aImageData || !aImageData["url"]) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
let url = aImageData["url"];
|
|
31
|
+
if(url.substring(url.length-4).toLowerCase() === ".svg") {
|
|
32
|
+
return url;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if(aImageData["resizeUrl"]) {
|
|
36
|
+
let scaleToWidth = Math.min(
|
|
37
|
+
Math.round(window.devicePixelRatio*aWantedWidth),
|
|
38
|
+
Math.max(
|
|
39
|
+
100,
|
|
40
|
+
100*Math.round(window.devicePixelRatio*window.innerWidth/100)
|
|
41
|
+
)
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
let scaleToHeight = Math.round(aWantedHeight*scaleToWidth/aWantedWidth);
|
|
45
|
+
|
|
46
|
+
url = aImageData["resizeUrl"].split("{scale}").join("width=" + scaleToWidth + ",height=" + scaleToHeight + ",fit=cover");
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return url;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export let createContainScaledImageUrl = function(aImageData, aWantedWidth, aWantedHeight) {
|
|
53
|
+
if(!aImageData || !aImageData["url"]) {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
let url = aImageData["url"];
|
|
58
|
+
if(url.substring(url.length-4).toLowerCase() === ".svg") {
|
|
59
|
+
return url;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if(aImageData["resizeUrl"]) {
|
|
63
|
+
let scaleToWidth = Math.min(
|
|
64
|
+
Math.round(window.devicePixelRatio*aWantedWidth),
|
|
65
|
+
Math.max(
|
|
66
|
+
100,
|
|
67
|
+
100*Math.round(window.devicePixelRatio*window.innerWidth/100)
|
|
68
|
+
)
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
let scaleToHeight = Math.round(aWantedHeight*scaleToWidth/aWantedWidth);
|
|
72
|
+
|
|
73
|
+
url = aImageData["resizeUrl"].split("{scale}").join("width=" + scaleToWidth + ",height=" + scaleToHeight + ",fit=contain");
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return url;
|
|
77
|
+
}
|
package/utils/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export * as ArrayFunctions from "./ArrayFunctions.js";
|
|
2
2
|
export * as NumberFunctions from "./NumberFunctions.js";
|
|
3
|
-
export * as StringFunctions from "./StringFunctions.js";
|
|
3
|
+
export * as StringFunctions from "./StringFunctions.js";
|
|
4
|
+
export * as UrlFunctions from "./UrlFunctions.js";
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import Dbm from "../../index.js";
|
|
3
|
-
|
|
4
|
-
export default class EditorBlockName extends Dbm.react.BaseObject {
|
|
5
|
-
_construct() {
|
|
6
|
-
super._construct();
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
_renderMainElement() {
|
|
10
|
-
|
|
11
|
-
let textSource = new Dbm.react.source.ContextVariableSource();
|
|
12
|
-
textSource.item.path = "moduleData.editorData.name";
|
|
13
|
-
|
|
14
|
-
return React.createElement("div", {"className": "editor-block-box editor-block-box-padding text-align-center"},
|
|
15
|
-
Dbm.react.text.text(textSource),
|
|
16
|
-
);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|