@cocreate/elements 1.26.0 → 1.26.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 +21 -0
- package/docs/index.html +2 -2
- package/package.json +8 -8
- package/src/index.js +27 -14
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,24 @@
|
|
|
1
|
+
## [1.26.2](https://github.com/CoCreate-app/CoCreate-elements/compare/v1.26.1...v1.26.2) (2023-11-12)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* await renderValue ([b08c609](https://github.com/CoCreate-app/CoCreate-elements/commit/b08c6093c9f6451ea7d54d20811aff81fd276cec))
|
|
7
|
+
* bump dependencies for latest features ([fdbaa9a](https://github.com/CoCreate-app/CoCreate-elements/commit/fdbaa9adb52b50b9e5db149e0c76472e0ea51d88))
|
|
8
|
+
* crud listeners ([68c014e](https://github.com/CoCreate-app/CoCreate-elements/commit/68c014eaa99eaf5fc2de45c8ebdce58bc36fba97))
|
|
9
|
+
* improve removeNodes ([f34e0cf](https://github.com/CoCreate-app/CoCreate-elements/commit/f34e0cfb43367ddcd2dd2b80422e9ade7d69a7f1))
|
|
10
|
+
* removed dead code ([22cb1fb](https://github.com/CoCreate-app/CoCreate-elements/commit/22cb1fb810a8ff5b4b61d4746cfe23b9cf6adefd))
|
|
11
|
+
* set $filter.index ([c51ffa8](https://github.com/CoCreate-app/CoCreate-elements/commit/c51ffa8aca3182fa4b9b85a76c226852614470b4))
|
|
12
|
+
* typo in handeling form ([71361e2](https://github.com/CoCreate-app/CoCreate-elements/commit/71361e2423231767138dd35cf62e7c443a823130))
|
|
13
|
+
|
|
14
|
+
## [1.26.1](https://github.com/CoCreate-app/CoCreate-elements/compare/v1.26.0...v1.26.1) (2023-11-09)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
|
|
19
|
+
* meta name typo ([8e53dbe](https://github.com/CoCreate-app/CoCreate-elements/commit/8e53dbedf631f30ebb143837ff3c8ee9919cad8d))
|
|
20
|
+
* update crud methods ([09d988a](https://github.com/CoCreate-app/CoCreate-elements/commit/09d988aa0497622f131102966b94e9817fa7a495))
|
|
21
|
+
|
|
1
22
|
# [1.26.0](https://github.com/CoCreate-app/CoCreate-elements/compare/v1.25.2...v1.26.0) (2023-11-03)
|
|
2
23
|
|
|
3
24
|
|
package/docs/index.html
CHANGED
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
7
7
|
<meta
|
|
8
|
-
|
|
8
|
+
name="description"
|
|
9
9
|
content="Fetch content into any html element by using attributes to query data stored in CoCreate headless CMS. If data is changed it will instantly reflect in html tags" />
|
|
10
10
|
<meta
|
|
11
|
-
|
|
11
|
+
name="keywords"
|
|
12
12
|
content="helper classes, utility classes, css framework, css library, inline style classes" />
|
|
13
13
|
<meta name="robots" content="index,follow" />
|
|
14
14
|
<meta
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/elements",
|
|
3
|
-
"version": "1.26.
|
|
3
|
+
"version": "1.26.2",
|
|
4
4
|
"description": "Fetch content into any html element by using html5 attributes to query data stored in CoCreate headless CMS. If data is changed it will instantly reflect in html tags as changes are broadcasted in realtime",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"elements",
|
|
@@ -58,12 +58,12 @@
|
|
|
58
58
|
"webpack-log": "^3.0.1"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@cocreate/actions": "^1.12.
|
|
62
|
-
"@cocreate/crud-client": "^1.28.
|
|
63
|
-
"@cocreate/element-prototype": "^1.
|
|
64
|
-
"@cocreate/filter": "^1.23.
|
|
65
|
-
"@cocreate/observer": "^1.11.
|
|
66
|
-
"@cocreate/render": "^1.
|
|
67
|
-
"@cocreate/utils": "^1.
|
|
61
|
+
"@cocreate/actions": "^1.12.3",
|
|
62
|
+
"@cocreate/crud-client": "^1.28.14",
|
|
63
|
+
"@cocreate/element-prototype": "^1.13.0",
|
|
64
|
+
"@cocreate/filter": "^1.23.8",
|
|
65
|
+
"@cocreate/observer": "^1.11.9",
|
|
66
|
+
"@cocreate/render": "^1.30.1",
|
|
67
|
+
"@cocreate/utils": "^1.27.1"
|
|
68
68
|
}
|
|
69
69
|
}
|
package/src/index.js
CHANGED
|
@@ -38,7 +38,6 @@ const keys = new Map();
|
|
|
38
38
|
const forms = new Map();
|
|
39
39
|
const debounce = new Map();
|
|
40
40
|
|
|
41
|
-
/** */
|
|
42
41
|
async function init(element) {
|
|
43
42
|
if (element && !(element instanceof HTMLCollection) && !Array.isArray(element))
|
|
44
43
|
element = [element]
|
|
@@ -49,7 +48,7 @@ async function init(element) {
|
|
|
49
48
|
|
|
50
49
|
let dataObjects = new Map();
|
|
51
50
|
for (let i = 0; i < element.length; i++) {
|
|
52
|
-
if (elements.has(element[i]) || element.tagName === 'FORM')
|
|
51
|
+
if (elements.has(element[i]) || element[i].tagName === 'FORM')
|
|
53
52
|
continue
|
|
54
53
|
|
|
55
54
|
let data = await initElement(element[i]);
|
|
@@ -161,7 +160,7 @@ function getObject(element) {
|
|
|
161
160
|
}
|
|
162
161
|
}
|
|
163
162
|
|
|
164
|
-
if (data.object || data.object === '') {
|
|
163
|
+
if (data.object || data.object === '' || data.key || data.key === '') {
|
|
165
164
|
if (!data.array || data.array && !data.array.length) return
|
|
166
165
|
data.type = 'object'
|
|
167
166
|
} else if (data.index || data.index === '') {
|
|
@@ -224,6 +223,9 @@ async function read(element, data, dataKey) {
|
|
|
224
223
|
if (!data)
|
|
225
224
|
data = { ...keys.get(dataKey).dataKey.object }
|
|
226
225
|
|
|
226
|
+
if (!data.$filter && (!data[data.type] || !data[data.type].length))
|
|
227
|
+
return
|
|
228
|
+
|
|
227
229
|
if (!(element instanceof HTMLCollection) && !Array.isArray(element))
|
|
228
230
|
element = [element]
|
|
229
231
|
|
|
@@ -301,7 +303,7 @@ async function setData(element, data) {
|
|
|
301
303
|
if (isRead == "false" || isCrdt == "true") continue;
|
|
302
304
|
if (isListen == "false" && !data.method.endsWith('.read')) continue;
|
|
303
305
|
}
|
|
304
|
-
// TODO: update
|
|
306
|
+
// TODO: object.update data returned from server will not include $operator
|
|
305
307
|
el.setValue(value);
|
|
306
308
|
}
|
|
307
309
|
}
|
|
@@ -331,12 +333,13 @@ async function filterData(element, data, type, key) {
|
|
|
331
333
|
|
|
332
334
|
if (element.getFilter && data.method && !data.method.endsWith('.read'))
|
|
333
335
|
await checkFilters(element, data, type)
|
|
334
|
-
else if (element.renderValue)
|
|
335
|
-
element.renderValue(data);
|
|
336
|
-
|
|
337
|
-
else if (data)
|
|
336
|
+
else if (element.renderValue) {
|
|
337
|
+
await element.renderValue(data);
|
|
338
|
+
} else if (data)
|
|
338
339
|
element.setValue(data)
|
|
339
340
|
|
|
341
|
+
filter.filters.get(element).index = data.$filter.index
|
|
342
|
+
|
|
340
343
|
const evt = new CustomEvent('fetchedData', { bubbles: true });
|
|
341
344
|
element.dispatchEvent(evt);
|
|
342
345
|
}
|
|
@@ -855,6 +858,8 @@ async function remove(element) {
|
|
|
855
858
|
let key = elements.get(element[i])
|
|
856
859
|
if (key) {
|
|
857
860
|
keys.get(key).elements.delete(element[i])
|
|
861
|
+
if (!keys.get(key).elements.size)
|
|
862
|
+
keys.delete(key)
|
|
858
863
|
}
|
|
859
864
|
elements.delete(element[i])
|
|
860
865
|
forms.delete(element[i])
|
|
@@ -862,13 +867,20 @@ async function remove(element) {
|
|
|
862
867
|
|
|
863
868
|
let key = elements.get(element[i])
|
|
864
869
|
if (key) {
|
|
870
|
+
if (element[i].getFilter)
|
|
871
|
+
filter.filters.delete(element[i])
|
|
865
872
|
keys.get(key).elements.delete(element[i])
|
|
866
873
|
elements.delete(element[i])
|
|
874
|
+
if (!keys.get(key).elements.size)
|
|
875
|
+
keys.delete(key)
|
|
876
|
+
|
|
867
877
|
// debounce.delete(key)
|
|
868
878
|
let form = element[i].closest('form')
|
|
869
879
|
form = forms.get(form)
|
|
870
880
|
if (form) {
|
|
871
881
|
form.elements.delete(element[i])
|
|
882
|
+
if (!form.elements.size)
|
|
883
|
+
forms.delete(form)
|
|
872
884
|
}
|
|
873
885
|
}
|
|
874
886
|
}
|
|
@@ -876,12 +888,12 @@ async function remove(element) {
|
|
|
876
888
|
}
|
|
877
889
|
|
|
878
890
|
function initSocket() {
|
|
879
|
-
const
|
|
880
|
-
const
|
|
891
|
+
const type = ["storage", "database", "array", "index", "object", 'filter'];
|
|
892
|
+
const method = ['create', 'update', 'delete'];
|
|
881
893
|
|
|
882
|
-
for (let i = 0; i <
|
|
883
|
-
for (let j = 0; j <
|
|
884
|
-
const action =
|
|
894
|
+
for (let i = 0; i < type.length; i++) {
|
|
895
|
+
for (let j = 0; j < method.length; j++) {
|
|
896
|
+
const action = type[i] + '.' + method[j];
|
|
885
897
|
|
|
886
898
|
CRUD.listen(action, function (data) {
|
|
887
899
|
setData(null, data);
|
|
@@ -1049,7 +1061,8 @@ Observer.init({
|
|
|
1049
1061
|
// }, 3000);
|
|
1050
1062
|
// debounce.set(mutation.target, delayTimer)
|
|
1051
1063
|
// } else
|
|
1052
|
-
if (mutation.target.hasAttribute('render-clone'))
|
|
1064
|
+
if (mutation.target.hasAttribute('render-clone'))
|
|
1065
|
+
return
|
|
1053
1066
|
remove(mutation.target)
|
|
1054
1067
|
}
|
|
1055
1068
|
});
|