@cocreate/render 1.4.2 → 1.5.3

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 CHANGED
@@ -1,3 +1,31 @@
1
+ ## [1.5.3](https://github.com/CoCreate-app/CoCreate-render/compare/v1.5.2...v1.5.3) (2022-02-03)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * replaced show and hide class hidden with attribute hidden ([15448e8](https://github.com/CoCreate-app/CoCreate-render/commit/15448e86e709233da2bc80222aaf71a7b8266a23))
7
+
8
+ ## [1.5.2](https://github.com/CoCreate-app/CoCreate-render/compare/v1.5.1...v1.5.2) (2022-02-01)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * update dependency versions ([f8026f4](https://github.com/CoCreate-app/CoCreate-render/commit/f8026f4620d82b51e46c30ff3b6ccae46d56bb29))
14
+
15
+ ## [1.5.1](https://github.com/CoCreate-app/CoCreate-render/compare/v1.5.0...v1.5.1) (2022-01-16)
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * removeElement relocated to its owwn coomponent @cocreate/remove ([0ddf532](https://github.com/CoCreate-app/CoCreate-render/commit/0ddf532c289aa365b727d8faeddeffb9be6949c9))
21
+
22
+ # [1.5.0](https://github.com/CoCreate-app/CoCreate-render/compare/v1.4.2...v1.5.0) (2022-01-02)
23
+
24
+
25
+ ### Features
26
+
27
+ * removeElement now supports remove-target, remove-closest ([154d637](https://github.com/CoCreate-app/CoCreate-render/commit/154d63761e2c76e5cf8499524583d2e3bbf4c94f))
28
+
1
29
  ## [1.4.2](https://github.com/CoCreate-app/CoCreate-render/compare/v1.4.1...v1.4.2) (2022-01-01)
2
30
 
3
31
 
package/docs/index.html CHANGED
@@ -235,7 +235,7 @@
235
235
  <div class="container svColumn overflow:hidden card position:relative border-radius:2px width:auto height:100%" id="sandbox">
236
236
  <div class="font-size:20px position:absolute top:10px right:10px opacity:0.6">
237
237
  <a class="margin-right:10px" id="code" show="#preview" hide="#code, #view"><i class="far fa-eye"></i></a>
238
- <a class="margin-right:10px hidden" id="preview" show="#code, #view" hide="#preview"><i class="fas fa-code"></i></a>
238
+ <a class="margin-right:10px" id="preview" show="#code, #view" hide="#preview" hidden><i class="fas fa-code"></i></a>
239
239
  <a class="margin-right:5px" fullscreen target="#playground"><i class="fas fa-expand"></i></a>
240
240
  </div>
241
241
  <div class="svRow">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/render",
3
- "version": "1.4.2",
3
+ "version": "1.5.3",
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.25",
65
- "@cocreate/api": "^1.2.18",
66
- "@cocreate/docs": "^1.2.62"
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;