@cocreate/elements 1.34.5 → 1.35.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 CHANGED
@@ -1,3 +1,10 @@
1
+ # [1.35.0](https://github.com/CoCreate-app/CoCreate-elements/compare/v1.34.5...v1.35.0) (2024-03-18)
2
+
3
+
4
+ ### Features
5
+
6
+ * observe form for new inputs and setAttribute ([527d1bd](https://github.com/CoCreate-app/CoCreate-elements/commit/527d1bd490ae28655006918fe8d8a99fb210cbde))
7
+
1
8
  ## [1.34.5](https://github.com/CoCreate-app/CoCreate-elements/compare/v1.34.4...v1.34.5) (2024-02-20)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/elements",
3
- "version": "1.34.5",
3
+ "version": "1.35.0",
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",
package/src/fetchSrc.js CHANGED
@@ -178,32 +178,6 @@ function base64ToArrayBuffer(base64) {
178
178
  return bytes.buffer; // Return ArrayBuffer
179
179
  }
180
180
 
181
- const videoStreamConfig = {
182
- title: "Video Title",
183
- totalDuration: 3600, // Total duration of the video in seconds
184
- 'content-type': "video/mp4",
185
- segments: [
186
- {
187
- _id: 1,
188
- src: "http://example.com/video/chunk1.mp4", // src stored using file path
189
- storage: '', // src stored using crud path
190
- array: '', // src stored using crud path
191
- object: '', // src stored using crud path
192
- key: '', // src stored using crud path
193
- start: 0, // Start time of this chunk in seconds
194
- end: 10, // End time of this chunk in seconds
195
- duration: 10,
196
- codec: "h.264",
197
- resolution: {
198
- width: 1920,
199
- height: 1080
200
- },
201
- bitrate: "5000kbps",
202
- },
203
- // Repeat for each chunk
204
- ]
205
- }
206
-
207
181
  observer.init({
208
182
  name: 'CoCreateSrc',
209
183
  observe: ['addedNodes'],
package/src/form.js CHANGED
@@ -18,7 +18,18 @@ function init(elements) {
18
18
  elements = document.querySelectorAll('form');
19
19
  else if (!Array.isArray(elements))
20
20
  elements = [elements]
21
+
21
22
  for (let element of elements) {
23
+ Observer.init({
24
+ name: 'CoCreateFormElements',
25
+ observe: ['addedNodes'],
26
+ target: '[storage], [database], [array], [index], [object], [key]',
27
+ callback: function (mutation) {
28
+ if (element == mutation.target.form)
29
+ setAttribute(element, [mutation.target])
30
+ }
31
+ });
32
+
22
33
  runObjectId(element);
23
34
  setAttribute(element);
24
35
  disableAutoFill(element);
@@ -43,7 +54,6 @@ function runObjectId(form) {
43
54
  // Add a array to the array list.
44
55
  if (array && !arrays.includes(array))
45
56
  arrays.push(array)
46
-
47
57
  }
48
58
  // Sets the object id for each array in the array.
49
59
  for (let i = 0; i < arrays.length; i++) {
@@ -55,8 +65,9 @@ function runObjectId(form) {
55
65
  /**
56
66
  * @param form
57
67
  */
58
- function setAttribute(form) {
59
- let elements = form.querySelectorAll('[storage], [database], [array], [index], [object], [key]');
68
+ function setAttribute(form, elements) {
69
+ if (!elements)
70
+ elements = form.querySelectorAll('[storage], [database], [array], [index], [object], [key]');
60
71
 
61
72
  for (let attribute of form.attributes) {
62
73
  let variable = window.CoCreateConfig.attributes[attribute.name]