dbm 1.3.0 → 1.4.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/css/icons.css CHANGED
@@ -8,6 +8,11 @@
8
8
  height: var(--standard-icon-size, 24px);
9
9
  }
10
10
 
11
+ .field-icon {
12
+ width: var(--field-icon-size, 16px);
13
+ height: var(--field-icon-size, 16px);
14
+ }
15
+
11
16
  .standard-icon-color {
12
17
  filter: url("#standard-icon-color");
13
18
  }
@@ -32,16 +32,19 @@ export default class Relations extends Dbm.graphapi.webclient.decode.DecodeBaseO
32
32
  if(!typeItem) {
33
33
  typeItem = new Dbm.repository.Item();
34
34
  typeItem.setValue("objects", []);
35
+ typeItem.setValue("relations", []);
35
36
  currentRelationsItem.setValue(currentType, typeItem);
36
37
  }
37
38
 
38
- if(this._isRelationValid(currentRelationData["startAt"], currentRelationData["endAt"])) {
39
- let newArray = [].concat(typeItem["objects"]);
40
- newArray.push(Dbm.getInstance().repository.getItem(currentRelationData["id"]));
41
- typeItem["objects"] = newArray;
42
- //METODO: set up relations
39
+ let relation = Dbm.getRepositoryItem(currentRelationData["relationId"]);
40
+ if(typeItem.relations.indexOf(relation) === -1) {
41
+ let linkedItem = Dbm.getRepositoryItem(currentRelationData["id"]);
42
+ //METODO: add data to relation
43
+ if(this._isRelationValid(currentRelationData["startAt"], currentRelationData["endAt"])) {
44
+ typeItem.addToArray("objects", linkedItem);
45
+ typeItem.addToArray("relations", relation);
46
+ }
43
47
  }
44
-
45
48
  }
46
49
  }
47
50
 
@@ -62,14 +65,18 @@ export default class Relations extends Dbm.graphapi.webclient.decode.DecodeBaseO
62
65
  if(!typeItem) {
63
66
  typeItem = new Dbm.repository.Item();
64
67
  typeItem.setValue("objects", []);
68
+ typeItem.setValue("relations", []);
65
69
  currentRelationsItem.setValue(currentType, typeItem);
66
70
  }
67
71
 
68
- if(this._isRelationValid(currentRelationData["startAt"], currentRelationData["endAt"])) {
69
- let newArray = [].concat(typeItem["objects"]);
70
- newArray.push(Dbm.getInstance().repository.getItem(currentRelationData["id"]));
71
- typeItem["objects"] = newArray;
72
- //METODO: set up relations
72
+ let relation = Dbm.getRepositoryItem(currentRelationData["relationId"]);
73
+ if(typeItem.relations.indexOf(relation) === -1) {
74
+ let linkedItem = Dbm.getRepositoryItem(currentRelationData["id"]);
75
+ //METODO: add data to relation
76
+ if(this._isRelationValid(currentRelationData["startAt"], currentRelationData["endAt"])) {
77
+ typeItem.addToArray("objects", linkedItem);
78
+ typeItem.addToArray("relations", relation);
79
+ }
73
80
  }
74
81
  }
75
82
  }
@@ -0,0 +1,65 @@
1
+ import Dbm from "../index.js";
2
+
3
+ export default class JsonLoader extends Dbm.core.BaseObject {
4
+
5
+ _construct() {
6
+
7
+ super._construct();
8
+
9
+ this.item.setValue("url", null);
10
+ this.item.setValue("element", null);
11
+
12
+ this.item.setValue("width", 0);
13
+ this.item.setValue("height", 0);
14
+
15
+ this._callback_loadedBound = this._callback_loaded.bind(this);
16
+ this._callback_loadingErrorBound = this._callback_loadingError.bind(this);
17
+
18
+ this.item.setValue("status", Dbm.loading.LoadingStatus.NOT_STARTED);
19
+ }
20
+
21
+ get completed() {
22
+ let status = this.item.status;
23
+ return (status === Dbm.loading.LoadingStatus.LOADED || status === Dbm.loading.LoadingStatus.ERROR);
24
+ }
25
+
26
+ setUrl(aUrl) {
27
+ this.item.url = aUrl;
28
+
29
+ return this;
30
+ }
31
+
32
+ _callback_loaded(aEvent) {
33
+ console.log(aEvent, this.item.element);
34
+
35
+ this.item.width = this.item.element.naturalWidth;
36
+ this.item.height = this.item.element.naturalHeight;
37
+
38
+ this.item.status = Dbm.loading.LoadingStatus.LOADED;
39
+ }
40
+
41
+ _callback_loadingError(aEvent) {
42
+ console.log(aEvent);
43
+
44
+ this.item.status = Dbm.loading.LoadingStatus.ERROR;
45
+ }
46
+
47
+ load() {
48
+
49
+ if(this.item.status !== Dbm.loading.LoadingStatus.NOT_STARTED) {
50
+ return this;
51
+ }
52
+
53
+ let image = new Image();
54
+ image.addEventListener("load", this._callback_loadedBound);
55
+ image.addEventListener("error", this._callback_loadingErrorBound);
56
+
57
+ this.item.element = image;
58
+
59
+ this.item.status = Dbm.loading.LoadingStatus.LOADING;
60
+ image.src = this.item.url;
61
+ console.log(image);
62
+
63
+ return this;
64
+ }
65
+ }
package/loading/index.js CHANGED
@@ -1,11 +1,12 @@
1
1
  import Dbm from "../index.js";
2
2
  export {default as ScriptLoader} from "./ScriptLoader.js";
3
3
  export {default as JsonLoader} from "./JsonLoader.js";
4
+ export {default as ImageLoader} from "./ImageLoader.js";
4
5
  export * as LoadingStatus from "./LoadingStatus.js";
5
6
 
6
7
  export * as node from "./node/index.js";
7
8
 
8
- export let loadScript = function(aUrl) {
9
+ export const loadScript = function(aUrl) {
9
10
 
10
11
  let loaderName = "loader-" + aUrl;
11
12
  let loaderItem = Dbm.getInstance().repository.getItemIfExists(loaderName);
@@ -22,5 +23,30 @@ export let loadScript = function(aUrl) {
22
23
 
23
24
  loader.load();
24
25
 
26
+ return loader;
27
+ }
28
+
29
+ export const getImageLoader = function(aUrl) {
30
+ let loaderName = "imageLoader-" + aUrl;
31
+ let loaderItem = Dbm.getInstance().repository.getItemIfExists(loaderName);
32
+
33
+ let loader;
34
+ if(!loaderItem) {
35
+ loader = new Dbm.loading.ImageLoader();
36
+ loader.item.register(loaderName);
37
+ loader.setUrl(aUrl);
38
+ }
39
+ else {
40
+ loader = loaderItem.controller;
41
+ }
42
+
43
+ return loader;
44
+ }
45
+
46
+ export const loadImage = function(aUrl) {
47
+
48
+ let loader = getImageLoader(aUrl);
49
+ loader.load();
50
+
25
51
  return loader;
26
52
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dbm",
3
- "version": "1.3.0",
3
+ "version": "1.4.1",
4
4
  "main": "index.js",
5
5
  "type": "module",
6
6
  "exports": {
@@ -14,8 +14,10 @@
14
14
  "description": "",
15
15
  "dependencies": {
16
16
  "@tweenjs/tween.js": "^25.0.0",
17
- "js-cookie": "^3.0.5",
18
- "react": "^18.3.1",
19
- "react-dom": "^18.3.1"
17
+ "js-cookie": "^3.0.5"
18
+ },
19
+ "peerDependencies": {
20
+ "react": ">=18",
21
+ "react-dom": ">=18"
20
22
  }
21
23
  }
@@ -164,7 +164,10 @@ export default class BaseObject extends Component {
164
164
  _copyProps(aProps) {
165
165
  let newProps = {...aProps};
166
166
 
167
- for(let objectName in this.props) {
167
+ let incomingProps = {...this.props};
168
+ this._removedUsedProps(incomingProps);
169
+
170
+ for(let objectName in incomingProps) {
168
171
  let currentValue = this.getPropValue(objectName);
169
172
  switch(objectName) {
170
173
  case "className":
@@ -203,8 +206,7 @@ export default class BaseObject extends Component {
203
206
  break;
204
207
  }
205
208
  }
206
-
207
- this._removedUsedProps(newProps);
209
+
208
210
  return newProps;
209
211
  }
210
212
 
@@ -101,13 +101,13 @@ export default class CreatePage extends Dbm.react.BaseObject {
101
101
  {"type": "setUrl", "data": {"value": fullUrl}}
102
102
  ]
103
103
 
104
- let request = Dbm.getInstance().repository.getItem("graphApi").controller.createItem(["page"], "public", changes);
104
+ let request = Dbm.getGraphApi().createItem(["page"], "public", changes);
105
105
 
106
106
  Dbm.flow.addUpdateCommand(request.properties.status, Dbm.commands.callFunction(this._pageCreated.bind(this), [fullUrl]));
107
107
  }
108
108
 
109
109
  _pageCreated(aUrl) {
110
- Dbm.getInstance().repository.getItem("siteNavigation").controller.navigate(aUrl);
110
+ Dbm.getRepositoryItem("siteNavigation").controller.navigate(aUrl);
111
111
  }
112
112
 
113
113
  _renderMainElement() {
@@ -10,10 +10,10 @@ export default class MultipleRelations extends Dbm.react.BaseObject {
10
10
  let visibility = this.getPropValueWithDefault("visibility", "private");
11
11
 
12
12
  this.item.requireProperty("items", []);
13
+ this.item.requireProperty("loaded", false);
13
14
 
14
- let graphApi = Dbm.getInstance().repository.getItem("graphApi").controller;
15
15
  {
16
- let request = graphApi.requestRange(
16
+ let request = Dbm.getGraphApi().requestRange(
17
17
  [
18
18
  {"type": "byObjectType", "objectType": objectType},
19
19
  {"type": "includeDraft"},
@@ -25,33 +25,31 @@ export default class MultipleRelations extends Dbm.react.BaseObject {
25
25
 
26
26
  Dbm.flow.addUpdateCommandWhenMatched(request.properties.status, Dbm.loading.LoadingStatus.LOADED, Dbm.commands.callFunction(this._itemsLoaded.bind(this), [request]));
27
27
  }
28
+
29
+ //console.log(this._getEditor());
28
30
  }
29
31
 
30
32
  _itemsLoaded(aRequest) {
31
- let options = [];
33
+ console.log("_itemsLoaded");
34
+ console.log(aRequest);
32
35
 
33
- let nameField = this.getPropValue("nameField");
34
- if(!nameField) {
35
- nameField = "name";
36
- }
36
+ let nameField = this.getPropValueWithDefault("nameField", "name");
37
37
 
38
38
  let currentArray = [].concat(aRequest.items);
39
39
  Dbm.utils.ArrayFunctions.sortOnField(currentArray, nameField);
40
40
 
41
41
  this.item.items = currentArray;
42
+ this.item.loaded = true;
42
43
  }
43
44
 
44
- _add(aItem) {
45
- console.log("_add");
46
- console.log(aItem);
47
-
45
+ _getEditor() {
48
46
  let itemEditor = this.context.itemEditor;
49
47
 
50
48
  let direction = this.getPropValue("direction");
51
49
  let relationType = this.getPropValue("relationType");
52
50
  let objectType = this.getPropValue("objectType");
53
51
 
54
- let editor;
52
+ let editor = null;
55
53
  if(direction === "in") {
56
54
  editor = itemEditor.getAdminMultipleIncomingRelationsEditor(relationType, objectType);
57
55
  }
@@ -62,6 +60,15 @@ export default class MultipleRelations extends Dbm.react.BaseObject {
62
60
  console.error("Unknown direction", direction, this);
63
61
  }
64
62
 
63
+ return editor;
64
+ }
65
+
66
+ _add(aItem) {
67
+ console.log("_add");
68
+ console.log(aItem);
69
+
70
+ let editor = this._getEditor();
71
+
65
72
  let newValues = [].concat(editor.value);
66
73
  newValues.push(aItem.id);
67
74
  editor.value = newValues;
@@ -71,22 +78,7 @@ export default class MultipleRelations extends Dbm.react.BaseObject {
71
78
  console.log("_remove");
72
79
  console.log(aId);
73
80
 
74
- let itemEditor = this.context.itemEditor;
75
-
76
- let direction = this.getPropValue("direction");
77
- let relationType = this.getPropValue("relationType");
78
- let objectType = this.getPropValue("objectType");
79
-
80
- let editor;
81
- if(direction === "in") {
82
- editor = itemEditor.getAdminMultipleIncomingRelationsEditor(relationType, objectType);
83
- }
84
- else if(direction === "out") {
85
- editor = itemEditor.getAdminMultipleOutgoingRelationsEditor(relationType, objectType);
86
- }
87
- else {
88
- console.error("Unknown direction", direction, this);
89
- }
81
+ let editor = this._getEditor();
90
82
 
91
83
  let newValues = [].concat(editor.value);
92
84
 
@@ -100,61 +92,56 @@ export default class MultipleRelations extends Dbm.react.BaseObject {
100
92
 
101
93
  _renderMainElement() {
102
94
 
103
- let id = this.context.item.id;
104
-
105
95
  let label = this.getPropValue("label");
106
96
  let direction = this.getPropValue("direction");
107
97
  let relationType = this.getPropValue("relationType");
108
98
  let objectType = this.getPropValue("objectType");
109
- let children = this.getPropValue("children");
110
99
 
111
100
  return React.createElement("div", {},
112
101
  React.createElement(Dbm.react.form.LabelledArea, {label: label}),
113
- React.createElement(Dbm.react.area.HasData, {check: this.item.properties.items, checkType: "notEmpty"},
114
- React.createElement("div")
115
- ),
116
- React.createElement("div", {"className": "standard-alternating-rows"},
117
- React.createElement(Dbm.react.admin.editorsgroup.EditMultipleRelations, {"direction": direction, "relationType": relationType, "objectType": objectType},
118
- React.createElement(Dbm.react.area.List, {items: Dbm.react.source.contextVariable("valueEditor.editValue.value")},
119
- React.createElement("div", {"className": "flex-row small-item-spacing justify-between"},
120
- React.createElement("div", {"className": "flex-row"},
121
- React.createElement(Dbm.react.context.AddItemByIdToContext, {id: Dbm.react.source.contextVariable("item")},
122
- Dbm.react.text.text(Dbm.react.source.item("name"))
123
- )
124
- ),
125
- React.createElement("div", {"className": "flex-row"},
126
- React.createElement(Dbm.react.interaction.CommandButton, {"commands": [Dbm.commands.callFunction(this._remove.bind(this), [Dbm.react.source.contextVariable("item")])]},
127
- React.createElement("div", {},
128
-
129
- "Remove"
102
+ React.createElement(Dbm.react.area.HasData, {check: this.item.properties.loaded},
103
+ React.createElement("div", {},
104
+ React.createElement("div", {"className": "standard-alternating-rows"},
105
+ React.createElement(Dbm.react.admin.editorsgroup.EditMultipleRelations, {"direction": direction, "relationType": relationType, "objectType": objectType},
106
+ React.createElement(Dbm.react.area.List, {items: Dbm.react.source.contextVariable("valueEditor.editValue.value")},
107
+ React.createElement("div", {"className": "flex-row small-item-spacing justify-between"},
108
+ React.createElement("div", {"className": "flex-row"},
109
+ React.createElement(Dbm.react.context.AddItemByIdToContext, {id: Dbm.react.source.item()},
110
+ Dbm.react.text.text(Dbm.react.source.item("name"))
111
+ )
112
+ ),
113
+ React.createElement("div", {"className": "flex-row"},
114
+ React.createElement(Dbm.react.interaction.CommandButton, {"commands": [Dbm.commands.callFunction(this._remove.bind(this), [Dbm.react.source.item()])]},
115
+ React.createElement(Dbm.react.image.Image, {"src": "/assets/img/icons/remove.svg", "className": "background-contain cursor-pointer action-icon-color field-icon"})
116
+ )
130
117
  )
131
118
  )
132
119
  )
133
120
  )
134
- )
135
- )
136
- ),
137
- React.createElement("div", {"className": "spacing small"}),
138
- React.createElement("div", {"className": "flex-row"},
139
- React.createElement(Dbm.react.form.Dropdown, {"position": "right"},
140
- React.createElement("div", {"data-slot": "button", "className": "action-button action-button-padding"},
141
- "Add"
142
121
  ),
143
- React.createElement("div", {"className": "dropdown-menu-max-height standard-dropdown"},
144
- React.createElement(Dbm.react.area.List, {items: this.item.properties.items, "as": "relatedItem"},
145
- React.createElement(Dbm.react.interaction.CommandButton, {"commands": [
146
- Dbm.commands.callFunction(this._add.bind(this), [Dbm.react.source.contextVariable("relatedItem")]),
147
- Dbm.commands.setProperty(Dbm.react.source.contextVariable("open"), false)
148
- ]},
149
- React.createElement("div", {className: "standard-dropdown-row standard-dropdown-row-padding hover-row cursor-pointer"},
150
- Dbm.react.text.text(Dbm.react.source.contextVariable("relatedItem.name"))
151
- )
122
+ React.createElement("div", {"className": "spacing small"}),
123
+ React.createElement("div", {"className": "flex-row"},
124
+ React.createElement(Dbm.react.form.Dropdown, {"position": "right"},
125
+ React.createElement("div", {"data-slot": "button", "className": "action-button action-button-padding"},
126
+ "Add"
152
127
  ),
128
+ React.createElement("div", {"className": "dropdown-menu-max-height standard-dropdown"},
129
+ React.createElement(Dbm.react.area.List, {items: this.item.properties.items, "as": "relatedItem"},
130
+ React.createElement(Dbm.react.interaction.CommandButton, {"commands": [
131
+ Dbm.commands.callFunction(this._add.bind(this), [Dbm.react.source.contextVariable("relatedItem")]),
132
+ Dbm.commands.setProperty(Dbm.react.source.contextVariable("open"), false)
133
+ ]},
134
+ React.createElement("div", {className: "standard-dropdown-row standard-dropdown-row-padding hover-row cursor-pointer"},
135
+ Dbm.react.text.text(Dbm.react.source.contextVariable("relatedItem.name"))
136
+ )
137
+ ),
138
+ )
139
+ )
153
140
  )
154
141
  )
155
142
  )
156
-
157
- )
143
+ ),
144
+
158
145
  )
159
146
  }
160
147
  }
@@ -7,6 +7,7 @@ export default class InsertElement extends Dbm.react.BaseObject {
7
7
  }
8
8
 
9
9
  _removedUsedProps(aProps) {
10
+ //console.log("_removedUsedProps");
10
11
  delete aProps["element"];
11
12
  }
12
13
 
@@ -20,7 +21,7 @@ export default class InsertElement extends Dbm.react.BaseObject {
20
21
  return React.createElement("div", {}, "No element set");
21
22
  }
22
23
 
23
- let props = this._copyProps(this.props);
24
+ let props = this._copyProps(element.props);
24
25
 
25
26
  let returnElement = Dbm.react.ChildFunctions.clone(element, props);
26
27
  return returnElement;
@@ -66,6 +66,7 @@ export default class AskAQuestion extends Dbm.react.BaseObject {
66
66
  let currentRow = new Dbm.repository.Item();
67
67
  currentRow.setId("_dbmInternal/row" + Dbm.getInstance().getNextId());
68
68
  currentRow.setValue("item", currentItem);
69
+ console.log(">>>>>>>", this._getOpenProperty(i));
69
70
  currentRow.setValue("element", React.createElement(Dbm.react.blocks.faq.HelpSectionRowItem, {"open": this._getOpenProperty(i), "startState": (i === 0 ? "open" : "close")}));
70
71
  rows.push(currentRow);
71
72
  }
@@ -0,0 +1,84 @@
1
+ import Dbm from "../../../index.js";
2
+ import React from "react";
3
+
4
+ export default class ImageGallery extends Dbm.react.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
+ elementSize.input.properties.element.connectInput(this.item.properties.widthElement);
13
+ elementSize.start();
14
+ this.item.requireProperty("width", 0).connectInput(elementSize.output.properties.width);
15
+
16
+ let images = this.getPropValue("images");
17
+
18
+
19
+ this.item.requireProperty("sections", []);
20
+
21
+ let allLoaded = Dbm.flow.updatefunctions.logic.allAtValue(Dbm.loading.LoadingStatus.LOADED);
22
+ this.item.requireProperty("loaded", false);
23
+ Dbm.flow.runWhenMatched(this.item.properties.loaded, true, Dbm.commands.callFunction(this._loaded.bind(this)));
24
+
25
+ let urlPath = this.getPropValueWithDefault("urlPath", "url");
26
+
27
+ let imageLoaders = [];
28
+ let currentArray = images;
29
+ let currentArrayLength = currentArray.length;
30
+ for(let i = 0; i < currentArrayLength; i++) {
31
+ let currentData = currentArray[i];
32
+ console.log(currentData);
33
+ let currentUrl = Dbm.objectPath(currentData, urlPath);
34
+ console.log(currentUrl);
35
+ let loader = Dbm.loading.loadImage(currentUrl);
36
+ imageLoaders.push(loader.item);
37
+ allLoaded.addCheck(loader.item.properties.status);
38
+ }
39
+ this.item.setValue("images", imageLoaders);
40
+
41
+ this.item.properties.loaded.connectInput(allLoaded.output.properties.value);
42
+ }
43
+
44
+ _removedUsedProps(aProps) {
45
+ delete aProps["images"];
46
+ delete aProps["urlPath"];
47
+ }
48
+
49
+ _loaded() {
50
+ console.log("loaded");
51
+ console.log(this.item.images);
52
+
53
+ let groups = Dbm.utils.ArrayFunctions.splitArray(this.item.images, 4);
54
+
55
+ let length = groups.length;
56
+ if(length > 1 && groups[length - 1].length === 1) {
57
+ let last = groups[length-1];
58
+ let prev = groups[length-2];
59
+
60
+ let lastInPrevious = prev.pop();
61
+ last.unshift(lastInPrevious);
62
+ }
63
+
64
+ let sections = [];
65
+ let currentArray = groups;
66
+ let currentArrayLength = currentArray.length;
67
+ for(let i = 0; i < currentArrayLength; i++) {
68
+ let section = React.createElement(Dbm.react.image.gallery.ImageGallerySection, {"images": currentArray[i], width: this.item.properties.width, spacing: 20});
69
+ sections.push({"id": i, "element": section});
70
+ }
71
+
72
+ this.item.sections = sections;
73
+ }
74
+
75
+ _renderMainElement() {
76
+
77
+ return this._createMainElement("div", {ref: this.createRef("widthElement")},
78
+ React.createElement(Dbm.react.area.List, {items: this.item.properties.sections},
79
+ React.createElement(Dbm.react.area.InsertElement, {"element": Dbm.react.source.item("element")}),
80
+ React.createElement("div", {"data-slot": "spacing", "className": "spacing", "style": {"height": 20}})
81
+ )
82
+ );
83
+ }
84
+ }
@@ -0,0 +1,220 @@
1
+ import Dbm from "../../../index.js";
2
+ import React from "react";
3
+
4
+ export default class ImageGallerySection extends Dbm.react.BaseObject {
5
+ _construct() {
6
+ super._construct();
7
+
8
+ let images = this.getPropValue("images");
9
+ console.log("images>>>>>", images);
10
+ }
11
+
12
+ _removedUsedProps(aProps) {
13
+ delete aProps["images"];
14
+ }
15
+
16
+ createLayout2(aImages, aSpacing = 20, aWidth = 800) {
17
+
18
+ let width1 = aImages[0].width;
19
+ let width2 = aImages[1].width;
20
+
21
+ let height1 = aImages[0].height;
22
+ let height2 = aImages[1].height;
23
+
24
+ let minHeight = Math.min(height1, height2);
25
+ let heightRatio1 = (minHeight / height1);
26
+ let heightRatio2 = (minHeight / height2);
27
+
28
+ let scaledWidth1 = width1*heightRatio1;
29
+ let scaledWidth2 = width2*heightRatio2;
30
+
31
+ let totalWidth = (scaledWidth1+scaledWidth2);
32
+ let widthRatio1 = (scaledWidth1/totalWidth);
33
+ let widthRatio2 = (scaledWidth2/totalWidth);
34
+
35
+ let newWidth1 = (aWidth-aSpacing)*widthRatio1;
36
+ let newWidth2 = (aWidth-aSpacing)*widthRatio2;
37
+
38
+ let newHeight1 = (height1/width1)*newWidth1;
39
+ let newHeight2 = (height2/width2)*newWidth2;
40
+
41
+ console.log(newWidth1, newHeight1, newWidth2, newHeight2);
42
+
43
+ let layout = React.createElement("div", {className: "flex-row"},
44
+ React.createElement("div", {className: "flex-row-item", style: {"width": newWidth1, "height": newHeight1}},
45
+ React.createElement(Dbm.react.image.Image, {"src": aImages[0].url, "className": "full-size background-cover"})
46
+ ),
47
+ React.createElement("div", {className: "flex-row-item", style: {"width": aSpacing}}),
48
+ React.createElement("div", {className: "flex-row-item", style: {"width": newWidth2, "height": newHeight2}},
49
+ React.createElement(Dbm.react.image.Image, {"src": aImages[1].url, "className": "full-size background-cover"})
50
+ ),
51
+ );
52
+
53
+ return layout;
54
+ }
55
+
56
+ createLayout3(aImages, aSpacing = 20, aWidth = 800) {
57
+
58
+ let width1 = aImages[0].width;
59
+ let width2 = aImages[1].width;
60
+ let width3 = aImages[2].width;
61
+
62
+ let height1 = aImages[0].height;
63
+ let height2 = aImages[1].height;
64
+ let height3 = aImages[2].height;
65
+
66
+ let minHeight = Math.min(height1, height2, height3);
67
+ let heightRatio1 = (minHeight / height1);
68
+ let heightRatio2 = (minHeight / height2);
69
+ let heightRatio3 = (minHeight / height3);
70
+
71
+ let scaledWidth1 = width1*heightRatio1;
72
+ let scaledWidth2 = width2*heightRatio2;
73
+ let scaledWidth3 = width3*heightRatio3;
74
+
75
+ let totalWidth = (scaledWidth1+scaledWidth2+scaledWidth3);
76
+ let widthRatio1 = (scaledWidth1/totalWidth);
77
+ let widthRatio2 = (scaledWidth2/totalWidth);
78
+ let widthRatio3 = (scaledWidth3/totalWidth);
79
+
80
+ let newWidth1 = (aWidth-2*aSpacing)*widthRatio1;
81
+ let newWidth2 = (aWidth-2*aSpacing)*widthRatio2;
82
+ let newWidth3 = (aWidth-2*aSpacing)*widthRatio3;
83
+
84
+ let newHeight1 = (height1/width1)*newWidth1;
85
+ let newHeight2 = (height2/width2)*newWidth2;
86
+ let newHeight3 = (height3/width3)*newWidth3;
87
+
88
+ console.log(newWidth1, newHeight1, newWidth2, newHeight2, newWidth3, newHeight3);
89
+
90
+ let layout = React.createElement("div", {className: "flex-row"},
91
+ React.createElement("div", {className: "flex-row-item", style: {"width": newWidth1, "height": newHeight1}},
92
+ React.createElement(Dbm.react.image.Image, {"src": aImages[0].url, "className": "full-size background-cover"})
93
+ ),
94
+ React.createElement("div", {className: "flex-row-item", style: {"width": aSpacing}}),
95
+ React.createElement("div", {className: "flex-row-item", style: {"width": newWidth2, "height": newHeight2}},
96
+ React.createElement(Dbm.react.image.Image, {"src": aImages[1].url, "className": "full-size background-cover"})
97
+ ),
98
+ React.createElement("div", {className: "flex-row-item", style: {"width": aSpacing}}),
99
+ React.createElement("div", {className: "flex-row-item", style: {"width": newWidth3, "height": newHeight3}},
100
+ React.createElement(Dbm.react.image.Image, {"src": aImages[2].url, "className": "full-size background-cover"})
101
+ ),
102
+ );
103
+
104
+ return layout;
105
+ }
106
+
107
+ createLayout4(aImages, aSpacing = 20, aWidth = 800) {
108
+ let width1 = aImages[0].width;
109
+ let width2 = aImages[1].width;
110
+ let width3 = aImages[2].width;
111
+ let width4 = aImages[3].width;
112
+
113
+ let height1 = aImages[0].height;
114
+ let height2 = aImages[1].height;
115
+ let height3 = aImages[2].height;
116
+ let height4 = aImages[3].height;
117
+
118
+ let innerP = (height3/width3)/((height2/width2)+(height3/width3));
119
+
120
+ let fullWidth = (aWidth-aSpacing);
121
+ let p = (fullWidth*(height1/width1)-aSpacing+innerP*aSpacing*(height2/width2))/(fullWidth*((height4/width4)+innerP*(height2/width2)+(height1/width1)))
122
+
123
+ let innerWidth = fullWidth*p-aSpacing;
124
+
125
+ let newWidth1 = (1-p)*fullWidth;
126
+ let newWidth2 = (innerWidth)*innerP;
127
+ let newWidth3 = (innerWidth)*(1-innerP);
128
+ let newWidth4 = (p)*fullWidth;
129
+
130
+ let newHeight1 = (height1/width1)*newWidth1;
131
+ let newHeight2 = (height2/width2)*newWidth2;
132
+ let newHeight3 = (height3/width3)*newWidth3;
133
+ let newHeight4 = (height4/width4)*newWidth4;
134
+
135
+ let layout = React.createElement("div", {className: "flex-row"},
136
+ React.createElement("div", {className: "flex-row-item", style: {"width": newWidth1, "height": newHeight1}},
137
+ React.createElement(Dbm.react.image.Image, {"src": aImages[0].url, "className": "full-size background-cover"})
138
+ ),
139
+ React.createElement("div", {className: "flex-row-item", style: {"width": aSpacing}}),
140
+ React.createElement("div", {className: "flex-row-item"},
141
+ React.createElement("div", {className: "flex-row"},
142
+ React.createElement("div", {className: "flex-row-item", style: {"width": newWidth2, "height": newHeight2}},
143
+ React.createElement(Dbm.react.image.Image, {"src": aImages[1].url, "className": "full-size background-cover"})
144
+ ),
145
+ React.createElement("div", {className: "flex-row-item", style: {"width": aSpacing}}),
146
+ React.createElement("div", {className: "flex-row-item", style: {"width": newWidth3, "height": newHeight3}},
147
+ React.createElement(Dbm.react.image.Image, {"src": aImages[2].url, "className": "full-size background-cover"})
148
+ ),
149
+ ),
150
+ React.createElement("div", {style: {"height": aSpacing}}),
151
+ React.createElement("div", {className: "flex-row-item", style: {"width": newWidth4, "height": newHeight4}},
152
+ React.createElement(Dbm.react.image.Image, {"src": aImages[3].url, "className": "full-size background-cover"})
153
+ ),
154
+ ),
155
+ );
156
+
157
+ return layout;
158
+ }
159
+
160
+ _renderMainElement() {
161
+
162
+ let images = this.getPropValue("images");
163
+ let width = this.getPropValueWithDefault("width", 800);
164
+ let spacing = this.getPropValueWithDefault("spacing", 20);
165
+
166
+ let layout = null;
167
+ switch(images.length) {
168
+ case 2:
169
+ layout = this.createLayout2(images, spacing, width);
170
+ break;
171
+ case 3:
172
+ layout = this.createLayout3(images, spacing, width);
173
+ break;
174
+ case 4:
175
+ layout = this.createLayout4(images, spacing, width);
176
+ break;
177
+ }
178
+
179
+ return this._createMainElement("div", {},
180
+ layout
181
+ );
182
+ }
183
+
184
+ /*
185
+ createLayout4(aImages, aSpacing = 20, aWidth = 800) {
186
+ let width1 = aImages[0].width;
187
+ let width2 = aImages[1].width;
188
+ let width3 = aImages[2].width;
189
+ let width4 = aImages[3].width;
190
+
191
+ let height1 = aImages[0].height;
192
+ let height2 = aImages[1].height;
193
+ let height3 = aImages[2].height;
194
+ let height4 = aImages[3].height;
195
+
196
+ let innerP = (height2/width2)/((height1/width1)+(height2/width2));
197
+ let innerWidth = aWidth-aSpacing;
198
+
199
+ let newWidth1 = (innerWidth)*innerP;
200
+ let newWidth2 = (innerWidth)*(1-innerP);
201
+
202
+ let newHeight1 = (height1/width1)*newWidth1;
203
+ let newHeight2 = (height2/width2)*newWidth2;
204
+
205
+ console.log(innerP);
206
+
207
+ let layout = React.createElement("div", {className: "flex-row"},
208
+ React.createElement("div", {className: "flex-row-item", style: {"width": newWidth1, "height": newHeight1}},
209
+ React.createElement(Dbm.react.image.Image, {"src": aImages[0].url, "className": "full-size background-cover"})
210
+ ),
211
+ React.createElement("div", {className: "flex-row-item", style: {"width": aSpacing}}),
212
+ React.createElement("div", {className: "flex-row-item", style: {"width": newWidth2, "height": newHeight2}},
213
+ React.createElement(Dbm.react.image.Image, {"src": aImages[1].url, "className": "full-size background-cover"})
214
+ ),
215
+ );
216
+
217
+ return layout;
218
+ }
219
+ */
220
+ }
@@ -0,0 +1,2 @@
1
+ export {default as ImageGallery} from "./ImageGallery.js";
2
+ export {default as ImageGallerySection} from "./ImageGallerySection.js";
@@ -2,4 +2,6 @@ export {default as Image} from "./Image.js";
2
2
  export {default as WidthScaledImage} from "./WidthScaledImage.js";
3
3
  export {default as CoverScaledImage} from "./CoverScaledImage.js";
4
4
  export {default as ContainScaledImage} from "./ContainScaledImage.js";
5
- export {default as LocalImage} from "./LocalImage.js";
5
+ export {default as LocalImage} from "./LocalImage.js";
6
+
7
+ export * as gallery from "./gallery/index.js";
package/react/index.js CHANGED
@@ -17,3 +17,4 @@ export * as image from "./image/index.js";
17
17
  export * as animation from "./animation/index.js";
18
18
  export * as interaction from "./interaction/index.js";
19
19
  export * as thirdparty from "./thirdparty/index.js";
20
+ export * as svg from "./svg/index.js";
@@ -0,0 +1,22 @@
1
+ import Dbm from "../../index.js";
2
+ import React from "react";
3
+
4
+ export default class GlobalFilters extends Dbm.react.BaseObject {
5
+ _construct() {
6
+ super._construct();
7
+ }
8
+
9
+ _renderMainElement() {
10
+
11
+ let colorFilters = Dbm.getRepositoryItem("globalSvg");
12
+ colorFilters.requireProperty("filters", []);
13
+
14
+ return this._createMainElement("svg", {xmlns: "http://www.w3.org/2000/svg", style: {display: "none"}},
15
+ React.createElement("defs", null,
16
+ React.createElement(Dbm.react.area.List, {items: colorFilters.properties.filters},
17
+ React.createElement(Dbm.react.area.InsertElement, {element: Dbm.react.source.item("element")})
18
+ )
19
+ )
20
+ );
21
+ }
22
+ }
@@ -0,0 +1,25 @@
1
+ import Dbm from "../../index.js";
2
+ import React from "react";
3
+
4
+ export default class MatrixFilter extends Dbm.react.BaseObject {
5
+ _construct() {
6
+ super._construct();
7
+ }
8
+
9
+ _removedUsedProps(aProps) {
10
+ delete aProps["id"];
11
+ delete aProps["matrix"];
12
+ }
13
+
14
+ _renderMainElement() {
15
+
16
+ let id = this.getPropValue("id");
17
+ let matrix = this.getPropValue("matrix");
18
+
19
+ console.log(id);
20
+
21
+ return this._createMainElement("filter", {id: id},
22
+ React.createElement("feColorMatrix", {type: "matrix", values: matrix})
23
+ );
24
+ }
25
+ }
@@ -0,0 +1,43 @@
1
+ import Dbm from "../../index.js";
2
+ import React from "react";
3
+
4
+ export {default as GlobalFilters} from "./GlobalFilters.js";
5
+ export {default as MatrixFilter} from "./MatrixFilter.js";
6
+
7
+ export const addGlobalRgbColorFilter = function(aName, aR, aG, aB) {
8
+
9
+ let colorFilters = Dbm.getRepositoryItem("globalSvg");
10
+ colorFilters.requireProperty("filters", []);
11
+
12
+ let item = Dbm.getRepositoryItem("globalSvg/filters/" + aName);
13
+ item.setValue("element", React.createElement(Dbm.react.svg.MatrixFilter, {"id": aName, "matrix": Dbm.utils.svg.ColorMatrixFunctions.floodColor(aR, aG, aB)}));
14
+
15
+ let filters = [].concat(colorFilters.filters);
16
+ filters.push(item);
17
+ colorFilters.filters = filters;
18
+
19
+ return item;
20
+ }
21
+
22
+ export const addGlobalHexColorFilter = function(aName, aColor) {
23
+ let value;
24
+
25
+ if (typeof aColor === "number") {
26
+ value = aColor;
27
+ }
28
+ else {
29
+ let hex = aColor.replace(/^#/, '');
30
+
31
+ if(hex.length === 3) {
32
+ hex = hex.split('').map(c => c + c).join('');
33
+ }
34
+
35
+ value = parseInt(hex, 16);
36
+ }
37
+
38
+ let r = (value >> 16) & 255;
39
+ let g = (value >> 8) & 255;
40
+ let b = value & 255;
41
+
42
+ return addGlobalRgbColorFilter(aName, r, g, b)
43
+ }
@@ -71,4 +71,32 @@ export default class Item extends Dbm.core.LifeCycleObject {
71
71
  }
72
72
  return this.properties[aName];
73
73
  }
74
+
75
+ addToArray(aName, aValue) {
76
+ let currentArray = this[aName];
77
+ if(!currentArray) {
78
+ this.setValue(aName, [aValue]);
79
+ }
80
+ else {
81
+ currentArray = [].concat(currentArray);
82
+ currentArray.push(aValue);
83
+ this[aName] = currentArray;
84
+ }
85
+
86
+ return this;
87
+ }
88
+
89
+ removeFromArray(aName, aValue) {
90
+ let currentArray = this[aName];
91
+ if(currentArray) {
92
+ let index = currentArray.indexOf(aValue);
93
+ if(index !== -1) {
94
+ currentArray = [].concat(currentArray);
95
+ currentArray.splice(index, 1);
96
+ this[aName] = currentArray;
97
+ }
98
+ }
99
+
100
+ return this;
101
+ }
74
102
  }
package/utils/index.js CHANGED
@@ -9,4 +9,5 @@ export * as LevenshteinDistance from "./LevenshteinDistance.js";
9
9
  export {default as MultidimensionalArrayHolder} from "./MultidimensionalArrayHolder.js";
10
10
  export {default as ArrayOperationResult} from "./ArrayOperationResult.js";
11
11
 
12
- export * as thirdparty from "./thirdparty/index.js";
12
+ export * as thirdparty from "./thirdparty/index.js";
13
+ export * as svg from "./svg/index.js";
@@ -0,0 +1,12 @@
1
+ import Dbm from "../../index.js";
2
+
3
+ export const floodColor = function(aR, aG, aB, aNumberOfDecimals = 4) {
4
+ let values = "";
5
+
6
+ values += "0 0 0 0 " + (aR/255).toFixed(aNumberOfDecimals) + " ";
7
+ values += "0 0 0 0 " + (aG/255).toFixed(aNumberOfDecimals) + " ";
8
+ values += "0 0 0 0 " + (aB/255).toFixed(aNumberOfDecimals) + " ";
9
+ values += "0 0 0 1 0";
10
+
11
+ return values;
12
+ }
@@ -0,0 +1 @@
1
+ export * as ColorMatrixFunctions from "./ColorMatrixFunctions.js";