@cocreate/render 1.4.1 → 1.5.2
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/CHANGELOG.md +28 -0
- package/docs/index.html +1 -1
- package/package.json +4 -4
- package/src/index.js +9 -25
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,31 @@
|
|
|
1
|
+
## [1.5.2](https://github.com/CoCreate-app/CoCreate-render/compare/v1.5.1...v1.5.2) (2022-02-01)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* update dependency versions ([f8026f4](https://github.com/CoCreate-app/CoCreate-render/commit/f8026f4620d82b51e46c30ff3b6ccae46d56bb29))
|
|
7
|
+
|
|
8
|
+
## [1.5.1](https://github.com/CoCreate-app/CoCreate-render/compare/v1.5.0...v1.5.1) (2022-01-16)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* removeElement relocated to its owwn coomponent @cocreate/remove ([0ddf532](https://github.com/CoCreate-app/CoCreate-render/commit/0ddf532c289aa365b727d8faeddeffb9be6949c9))
|
|
14
|
+
|
|
15
|
+
# [1.5.0](https://github.com/CoCreate-app/CoCreate-render/compare/v1.4.2...v1.5.0) (2022-01-02)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Features
|
|
19
|
+
|
|
20
|
+
* removeElement now supports remove-target, remove-closest ([154d637](https://github.com/CoCreate-app/CoCreate-render/commit/154d63761e2c76e5cf8499524583d2e3bbf4c94f))
|
|
21
|
+
|
|
22
|
+
## [1.4.2](https://github.com/CoCreate-app/CoCreate-render/compare/v1.4.1...v1.4.2) (2022-01-01)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Bug Fixes
|
|
26
|
+
|
|
27
|
+
* get-value attribute value now supports a selector added # to all values currently in get-value attributes ([75f7a90](https://github.com/CoCreate-app/CoCreate-render/commit/75f7a9070c02c3221fa128d90c0176bb94f2df79))
|
|
28
|
+
|
|
1
29
|
## [1.4.1](https://github.com/CoCreate-app/CoCreate-render/compare/v1.4.0...v1.4.1) (2022-01-01)
|
|
2
30
|
|
|
3
31
|
|
package/docs/index.html
CHANGED
|
@@ -248,7 +248,7 @@
|
|
|
248
248
|
<div class="svSplitter svHorizontal"> </div>
|
|
249
249
|
|
|
250
250
|
<div class="svPanel">
|
|
251
|
-
<iframe get-value="demo" frameBorder="0" height="100%" width="100%" class="min-width:300px"></iframe>
|
|
251
|
+
<iframe get-value="#demo" frameBorder="0" height="100%" width="100%" class="min-width:300px"></iframe>
|
|
252
252
|
</div>
|
|
253
253
|
|
|
254
254
|
</div>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/render",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.2",
|
|
4
4
|
"description": "A simple render component in vanilla javascript. Easily configured using HTML5 attributes and/or JavaScript API.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"render",
|
|
@@ -61,8 +61,8 @@
|
|
|
61
61
|
"webpack-log": "^3.0.1"
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
|
-
"@cocreate/actions": "^1.3.
|
|
65
|
-
"@cocreate/api": "^1.2.
|
|
66
|
-
"@cocreate/docs": "^1.2.
|
|
64
|
+
"@cocreate/actions": "^1.3.28",
|
|
65
|
+
"@cocreate/api": "^1.2.22",
|
|
66
|
+
"@cocreate/docs": "^1.2.65"
|
|
67
67
|
}
|
|
68
68
|
}
|
package/src/index.js
CHANGED
|
@@ -34,11 +34,11 @@ const CoCreateRender = {
|
|
|
34
34
|
try {
|
|
35
35
|
if (!path) return data;
|
|
36
36
|
|
|
37
|
-
let keys = path.split('.')
|
|
37
|
+
let keys = path.split('.');
|
|
38
38
|
let newObject = data;
|
|
39
39
|
|
|
40
40
|
for (var i = keys.length - 1; i >= 0; i--) {
|
|
41
|
-
newObject = {[keys[i]]: newObject}
|
|
41
|
+
newObject = {[keys[i]]: newObject};
|
|
42
42
|
}
|
|
43
43
|
return newObject;
|
|
44
44
|
|
|
@@ -57,12 +57,12 @@ const CoCreateRender = {
|
|
|
57
57
|
let variables = inputValue.match(/{{([A-Za-z0-9_.,\[\]\- ]*)}}/g);
|
|
58
58
|
if (variables) {
|
|
59
59
|
variables.forEach((attr) => {
|
|
60
|
-
let value = self.__getValue(data, attr)
|
|
60
|
+
let value = self.__getValue(data, attr);
|
|
61
61
|
if (value && typeof(value) !== "object") {
|
|
62
62
|
isPass = true;
|
|
63
63
|
inputValue = inputValue.replace(attr, value);
|
|
64
64
|
}
|
|
65
|
-
})
|
|
65
|
+
});
|
|
66
66
|
|
|
67
67
|
if (isPass) {
|
|
68
68
|
resultValue = inputValue;
|
|
@@ -101,14 +101,14 @@ const CoCreateRender = {
|
|
|
101
101
|
|
|
102
102
|
self.setValue([cloneEl], r_data);
|
|
103
103
|
template.insertAdjacentHTML('beforebegin', cloneEl.outerHTML);
|
|
104
|
-
})
|
|
104
|
+
});
|
|
105
105
|
}
|
|
106
106
|
},
|
|
107
107
|
|
|
108
108
|
cloneEl: function(template) {
|
|
109
109
|
let cloneEl = template.cloneNode(true);
|
|
110
110
|
cloneEl.classList.remove('template');
|
|
111
|
-
let templateId = cloneEl.getAttribute('template_id')
|
|
111
|
+
let templateId = cloneEl.getAttribute('template_id');
|
|
112
112
|
cloneEl.removeAttribute('template_id');
|
|
113
113
|
cloneEl.setAttribute('templateId', templateId);
|
|
114
114
|
return cloneEl;
|
|
@@ -151,10 +151,10 @@ const CoCreateRender = {
|
|
|
151
151
|
|
|
152
152
|
data: function({selector, data, elements}) {
|
|
153
153
|
if (selector) {
|
|
154
|
-
let template = document.querySelector(selector)
|
|
154
|
+
let template = document.querySelector(selector);
|
|
155
155
|
if (!template) return;
|
|
156
156
|
if (template.classList.contains('template')) {
|
|
157
|
-
this.render(template, data)
|
|
157
|
+
this.render(template, data);
|
|
158
158
|
}
|
|
159
159
|
else
|
|
160
160
|
this.setValue([template], data, template);
|
|
@@ -164,23 +164,7 @@ const CoCreateRender = {
|
|
|
164
164
|
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
function removeElement(btn) {
|
|
170
|
-
let element = btn.closest('[templateid]');
|
|
171
|
-
if (element)
|
|
172
|
-
element.remove();
|
|
173
|
-
document.dispatchEvent(new CustomEvent('removeElement', {detail: {}}));
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
action.init({
|
|
177
|
-
action: "removeElement",
|
|
178
|
-
endEvent: "removeElement",
|
|
179
|
-
callback: (btn, data) => {
|
|
180
|
-
removeElement(btn);
|
|
181
|
-
}
|
|
182
|
-
});
|
|
183
|
-
|
|
167
|
+
};
|
|
184
168
|
|
|
185
169
|
function renderKey(element) {
|
|
186
170
|
const form = element.closest("form") || document;
|