@cocreate/render 1.28.6 → 1.29.0
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 +20 -0
- package/package.json +1 -1
- package/src/index.js +17 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
1
|
+
# [1.29.0](https://github.com/CoCreate-app/CoCreate-render/compare/v1.28.7...v1.29.0) (2023-10-22)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* selector handling ([7eb4a25](https://github.com/CoCreate-app/CoCreate-render/commit/7eb4a253068be29c9094afa9f9bf548b3b7f666d))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* ObjectId() returns an object containg the parts iof the _id along with a toString() function ([7f35dd1](https://github.com/CoCreate-app/CoCreate-render/commit/7f35dd14649ff02ec89f61ca8c3e36d5ba37c226))
|
|
12
|
+
|
|
13
|
+
## [1.28.7](https://github.com/CoCreate-app/CoCreate-render/compare/v1.28.6...v1.28.7) (2023-10-19)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Bug Fixes
|
|
17
|
+
|
|
18
|
+
* clears render element if index = 0 and crate and update not true ([90e4946](https://github.com/CoCreate-app/CoCreate-render/commit/90e4946cf579e5030d51c2e180f61b5a03ebbc33))
|
|
19
|
+
* declartion of render functions using object spread ([b3e3977](https://github.com/CoCreate-app/CoCreate-render/commit/b3e397747e18cc6fe52c0838b465adcaafaea416))
|
|
20
|
+
|
|
1
21
|
## [1.28.6](https://github.com/CoCreate-app/CoCreate-render/compare/v1.28.5...v1.28.6) (2023-10-17)
|
|
2
22
|
|
|
3
23
|
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -48,7 +48,7 @@ function init(element) {
|
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
async function render({ source, element, data, key, index, currentIndex, update, remove }) {
|
|
51
|
+
async function render({ source, element, selector, data, key, index, currentIndex, update, remove }) {
|
|
52
52
|
if (!element) {
|
|
53
53
|
if (source) {
|
|
54
54
|
element = queryElements({ element: source, prefix: 'render' })
|
|
@@ -64,7 +64,8 @@ async function render({ source, element, data, key, index, currentIndex, update,
|
|
|
64
64
|
if (!element) {
|
|
65
65
|
element = source.querySelector('template, [template], .template, [render]');
|
|
66
66
|
}
|
|
67
|
-
}
|
|
67
|
+
} else if (selector)
|
|
68
|
+
element = queryElements({ selector })
|
|
68
69
|
|
|
69
70
|
if (!element) return;
|
|
70
71
|
}
|
|
@@ -194,9 +195,18 @@ async function renderTemplate(template, data, key, index, keyPath) {
|
|
|
194
195
|
else if (Array.isArray(data))
|
|
195
196
|
renderData = data
|
|
196
197
|
|
|
197
|
-
if (!renderData)
|
|
198
|
+
if (!renderData && data)
|
|
199
|
+
if (Array.isArray(data))
|
|
200
|
+
renderData = data
|
|
201
|
+
else
|
|
202
|
+
renderData = [data]
|
|
203
|
+
|
|
204
|
+
else if (!renderData)
|
|
205
|
+
return
|
|
206
|
+
|
|
198
207
|
|
|
199
|
-
|
|
208
|
+
let isInsert = data.$filter && (data.$filter.create || data.$filter.update)
|
|
209
|
+
if (!isInsert && index === 0) {
|
|
200
210
|
for (const [key, element] of template.clones) {
|
|
201
211
|
renderedNodes.delete(element)
|
|
202
212
|
element.remove()
|
|
@@ -525,6 +535,8 @@ async function renderValue(node, data, placeholder, renderAs, renderedNode) {
|
|
|
525
535
|
match = output.match(/{{(.*?)}}/);
|
|
526
536
|
if (match) {
|
|
527
537
|
let value
|
|
538
|
+
if (match[1].includes('status'))
|
|
539
|
+
console.log('test')
|
|
528
540
|
try {
|
|
529
541
|
let Data = JSON.parse('{' + match[1].replace(/'/g, '"') + '}');
|
|
530
542
|
if (Data.storage || Data.database || Data.array || Data.object || Data.index) {
|
|
@@ -578,7 +590,7 @@ function getRenderValue(node, data, key, renderAs) {
|
|
|
578
590
|
} else if (key.includes('renderAs')) {
|
|
579
591
|
value = renderAs
|
|
580
592
|
} else if (key === 'object' || key === '_id')
|
|
581
|
-
value = ObjectId()
|
|
593
|
+
value = ObjectId().toString()
|
|
582
594
|
else if (key === 'uuid')
|
|
583
595
|
value = uuid.generate(6)
|
|
584
596
|
else if (parent.source)
|