@cocreate/elements 1.27.1 → 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 CHANGED
@@ -1,3 +1,29 @@
1
+ # [1.29.0](https://github.com/CoCreate-app/CoCreate-elements/compare/v1.28.0...v1.29.0) (2023-11-25)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * update licensing details ([9f9b839](https://github.com/CoCreate-app/CoCreate-elements/commit/9f9b8390e751604de9f7e361e15e47e2a72093a6))
7
+
8
+
9
+ ### Features
10
+
11
+ * upgrade dependencies for latest features and fixes ([83cbf98](https://github.com/CoCreate-app/CoCreate-elements/commit/83cbf9831f526b9c4c436d9502d432836b44d922))
12
+
13
+ # [1.28.0](https://github.com/CoCreate-app/CoCreate-elements/compare/v1.27.1...v1.28.0) (2023-11-25)
14
+
15
+
16
+ ### Bug Fixes
17
+
18
+ * conditions to update elements from broadcasted incoming data ([756b798](https://github.com/CoCreate-app/CoCreate-elements/commit/756b7984b6e46a6d03214a88fca130e4df02aaef))
19
+ * pass attributes renamed to state ([83c741e](https://github.com/CoCreate-app/CoCreate-elements/commit/83c741e6cdd88635957ff3d16193a4e95f8999d5))
20
+ * update nav, edit button and css path ([ac50546](https://github.com/CoCreate-app/CoCreate-elements/commit/ac50546b7deccd3adbb2a6b224b02a3b35cec671))
21
+
22
+
23
+ ### Features
24
+
25
+ * upgrade dependencies for latest features and fixes ([baebd69](https://github.com/CoCreate-app/CoCreate-elements/commit/baebd69e9db0831a1060d8e03d96bb3f123d8c3e))
26
+
1
27
  ## [1.27.1](https://github.com/CoCreate-app/CoCreate-elements/compare/v1.27.0...v1.27.1) (2023-11-22)
2
28
 
3
29
 
package/README.md CHANGED
@@ -39,12 +39,12 @@ $ yarn install @cocreate/elements
39
39
 
40
40
  # Table of Contents
41
41
 
42
- - [Table of Contents](#table-of-contents)
43
- - [Announcements](#announcements)
44
- - [Roadmap](#roadmap)
45
- - [How to Contribute](#how-to-contribute)
46
- - [About](#about)
47
- - [License](#license)
42
+ - [Table of Contents](#table-of-contents)
43
+ - [Announcements](#announcements)
44
+ - [Roadmap](#roadmap)
45
+ - [How to Contribute](#how-to-contribute)
46
+ - [About](#about)
47
+ - [License](#license)
48
48
 
49
49
  <a name="announcements"></a>
50
50
 
@@ -78,8 +78,14 @@ We want this library to be community-driven, and CoCreate led. We need your help
78
78
 
79
79
  We appreciate your continued support, thank you!
80
80
 
81
-
82
81
  <a name="license"></a>
82
+
83
83
  # License
84
84
 
85
- [The MIT License (MIT)](https://github.com/CoCreate-app/CoCreate-elements/blob/master/LICENSE)
85
+ This software is dual-licensed under the GNU Affero General Public License version 3 (AGPLv3) and a commercial license.
86
+
87
+ - **Open Source Use**: For open-source projects and non-commercial use, this software is available under the AGPLv3. The AGPLv3 allows you to freely use, modify, and distribute this software, provided that all modifications and derivative works are also licensed under the AGPLv3. For the full license text, see the [LICENSE file](https://github.com/CoCreate-app/CoCreate-element/blob/master/LICENSE).
88
+
89
+ - **Commercial Use**: For-profit companies and individuals intending to use this software for commercial purposes must obtain a commercial license. The commercial license is available when you sign up for an API key on our [website](https://cocreate.app). This license permits proprietary use and modification of the software without the copyleft requirements of the AGPLv3. It is ideal for integrating this software into proprietary commercial products and applications.
90
+
91
+ If you have not purchased a commercial license and intend to use this software for commercial purposes, you are required to sign up for an API key on our website.
package/docs/index.html CHANGED
@@ -25,7 +25,7 @@
25
25
  href="https://cocreate.app/images/favicon.ico" />
26
26
  <link
27
27
  rel="stylesheet"
28
- href="/docs/index.css"
28
+ href="../index.css"
29
29
  array="files"
30
30
  object="60888216117c640e7596303f"
31
31
  key="src"
@@ -35,15 +35,15 @@
35
35
  </head>
36
36
 
37
37
  <body>
38
+ <!-- Navbar -->
38
39
  <nav
39
- class="nav display:flex align-items:center left:0px background:whitesmoke padding-top:10px padding-bottom:10px"
40
+ class="width:100% display:flex align-items:center background:transparent padding-top:10px padding-bottom:10px"
40
41
  content_id="content"
41
- scroll="sticky-nav,hide-nav"
42
- scroll-up="10"
43
- scroll-down="10"
44
- array="files"
45
- object="60395ef42b3ac232657040fd"
46
- key="src"></nav>
42
+ scroll="sticky-nav,"
43
+ scroll-up="5"
44
+ scroll-down="5"
45
+ path="../"
46
+ src="../components/navbar.html"></nav>
47
47
  <sidenav
48
48
  id="menuL"
49
49
  class="position:fixed top:0px left:0px overflow:hidden background:whitesmoke height:100vh width:0px width:300px@xl"
@@ -354,10 +354,8 @@
354
354
  <button
355
355
  href="https://github.com/CoCreate-app/CoCreate-elements/tree/master/docs/index.html?message=docs%3A%20describe%20your%20change..."
356
356
  target="_blank"
357
- class="position:fixed bottom:15px right:15px padding:15px background:dodgerblue color:#fff font-size:1.5rem grow-hover border-radius:50% border-width:0 box-shadow:0px_2px_10px_0px_rgba(0,_0,_0,_0.4)">
358
- <i
359
- class="height:20px fill:#505050"
360
- src="/assets/svg/pencil-alt.svg"></i>
357
+ class="display:flex justify-content:center align-items:center position:fixed bottom:15px right:15px height:50px width:50px border-radius:50% box-shadow:0px_2px_10px_0px_rgba(0,_0,_0,_0.4)">
358
+ <i class="height:20px" src="../assets/svg/pencil-alt.svg"></i>
361
359
  </button>
362
360
  </main>
363
361
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/elements",
3
- "version": "1.27.1",
3
+ "version": "1.29.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",
@@ -58,12 +58,12 @@
58
58
  "webpack-log": "^3.0.1"
59
59
  },
60
60
  "dependencies": {
61
- "@cocreate/actions": "^1.12.4",
62
- "@cocreate/crud-client": "^1.29.0",
63
- "@cocreate/element-prototype": "^1.13.2",
64
- "@cocreate/filter": "^1.25.0",
65
- "@cocreate/observer": "^1.12.0",
66
- "@cocreate/render": "^1.32.0",
67
- "@cocreate/utils": "^1.27.4"
61
+ "@cocreate/actions": "^1.14.0",
62
+ "@cocreate/crud-client": "^1.31.0",
63
+ "@cocreate/element-prototype": "^1.15.0",
64
+ "@cocreate/filter": "^1.27.0",
65
+ "@cocreate/observer": "^1.14.0",
66
+ "@cocreate/render": "^1.35.0",
67
+ "@cocreate/utils": "^1.29.0"
68
68
  }
69
69
  }
package/src/form.js CHANGED
@@ -3,14 +3,19 @@ import { getAttributeNames, ObjectId } from '@cocreate/utils';
3
3
  import Action from '@cocreate/actions';
4
4
  import '@cocreate/element-prototype';
5
5
 
6
+
6
7
  /**
7
- * @param elements
8
- */
8
+ * Initializes form elements. If no parameter is provided, or null is passed, it queries and initializes all form elements.
9
+ * It can also initialize a single form element or an array of form elements.
10
+ *
11
+ * @param {(Element|Element[]|null)} [elements] - Optional. A single form element, an array of form elements, or null.
12
+ * - If null or omitted, the function queries and initializes all form elements.
13
+ * - If a single form element is provided, it initializes that element.
14
+ * - If an array of form elements is provided, each element in the array is initialized.
15
+ */
9
16
  function init(elements) {
10
- // Returns an array of elements.
11
17
  if (!elements)
12
18
  elements = document.querySelectorAll('form');
13
- // If elements is an array of elements returns an array of elements.
14
19
  else if (!Array.isArray(elements))
15
20
  elements = [elements]
16
21
  for (let element of elements) {
@@ -79,7 +84,7 @@ function disableAutoFill(element) {
79
84
  }
80
85
 
81
86
  /**
82
- * @param btn
87
+ * @param form
83
88
  */
84
89
  function reset(form) {
85
90
  let formElements = new Map();
package/src/index.js CHANGED
@@ -38,6 +38,20 @@ const keys = new Map();
38
38
  const forms = new Map();
39
39
  const debounce = new Map();
40
40
 
41
+ /**
42
+ * Initializes elements with specific CRUD attributes. If no parameter is provided, it queries and initializes all elements
43
+ * that have certain CRUD-related attributes. It can also initialize a single element or an array of elements.
44
+ *
45
+ * Attributes used for initialization are:
46
+ * - storage: Specifies the storage mechanism.
47
+ * - database: Indicates the database to interact with.
48
+ * - array: Defines the array to be used.
49
+ * - render-json: Determines how JSON data is rendered.
50
+ *
51
+ * @param {(Element|Element[])} [elements] - Optional. A single element or an array of elements to initialize.
52
+ * If omitted, the function queries and initializes all elements containing
53
+ * any of these CRUD attributes: "storage", "database", "array", "render-json".
54
+ */
41
55
  async function init(element) {
42
56
  if (element && !(element instanceof HTMLCollection) && !Array.isArray(element))
43
57
  element = [element]
@@ -505,24 +519,32 @@ function getDataKeys(data) {
505
519
  }
506
520
  if (Array.isArray(sortedKey.data[key]) && Array.isArray(data[key])) {
507
521
  // if key is object check _id
508
- const matches = sortedKey.data[key].some(value => {
509
- if (key === 'object') {
510
- return data[key].some(obj => {
511
- if (data.array.includes('users'))
512
- console.log('users')
513
- if (data.array.includes('questions'))
514
- console.log('questions')
515
-
516
- return obj._id === value._id
517
- });
518
- } else {
519
- return data[key].includes(value)
522
+ if (key === 'object' && sortedKey.data.$filter)
523
+ hasMatch = true
524
+ else {
525
+ const matches = sortedKey.data[key].some(value => {
526
+ if (key === 'object') {
527
+ return data[key].some(obj => {
528
+ if (data.array.includes('users'))
529
+ console.log('users')
530
+ if (data.array.includes('questions'))
531
+ console.log('questions')
532
+
533
+ return obj._id === value._id
534
+ });
535
+ } else {
536
+ return data[key].includes(value)
537
+ }
538
+ });
539
+
540
+ if (!matches) {
541
+ hasMatch = false;
542
+ break;
520
543
  }
521
- });
522
- if (!matches) {
523
- hasMatch = false;
524
- break;
544
+
525
545
  }
546
+
547
+
526
548
  } else if (sortedKey.data[key] !== data[key]) {
527
549
  hasMatch = false;
528
550
  break;
@@ -796,51 +818,51 @@ function setTypeValue(element, data) {
796
818
  setData(Array.from(elements.keys()), data)
797
819
 
798
820
 
799
- // const pass_ids = new Map();
821
+ // const state_ids = new Map();
800
822
 
801
- // let pass_id = form.getAttribute('pass_id');
802
- // if (pass_id) {
803
- // // Set pass_ids to pass_ids if array is not set
823
+ // let state_id = form.getAttribute('state_id');
824
+ // if (state_id) {
825
+ // // Set state_ids to state_ids if array is not set
804
826
  // if (form.getAttribute('array') == array)
805
- // pass_ids.set(pass_id, '');
827
+ // state_ids.set(state_id, '');
806
828
  // }
807
829
 
808
830
  // let objectId = el.getAttribute('object');
809
831
  // let key = el.getAttribute('key')
810
- // // set object and pass_id attributes to the object id if the object id is pending
832
+ // // set object and state_id attributes to the object id if the object id is pending
811
833
  // if (key && (objectId == '' || objectId == 'pending')) {
812
834
  // el.setAttribute('object', id);
813
835
  // // Set the id attribute of the element
814
836
  // if (key == '_id')
815
837
  // el.setValue(id)
816
- // let pass_id = el.getAttribute('pass_id');
817
- // // Set the pass id to the pass_ids.
818
- // if (pass_id) {
819
- // pass_ids.set(pass_id, '');
838
+ // let state_id = el.getAttribute('state_id');
839
+ // // Set the state id to the state_ids.
840
+ // if (state_id) {
841
+ // state_ids.set(state_id, '');
820
842
  // }
821
843
 
822
- // if (el.hasAttribute('pass-object')) {
823
- // let passObjectId = el.getAttribute('pass-object');
824
- // // Set the pass object id if not set.
825
- // if (passObjectId == '') {
826
- // el.setAttribute('pass-object', id);
827
- // let pass_id = el.getAttribute('pass_id');
828
- // // Set the pass id to the pass_ids.
829
- // if (pass_id) {
830
- // pass_ids.set(pass_id, '');
844
+ // if (el.hasAttribute('state-object')) {
845
+ // let stateObjectId = el.getAttribute('state-object');
846
+ // // Set the state object id if not set.
847
+ // if (stateObjectId == '') {
848
+ // el.setAttribute('state-object', id);
849
+ // let state_id = el.getAttribute('state_id');
850
+ // // Set the state id to the state_ids.
851
+ // if (state_id) {
852
+ // state_ids.set(state_id, '');
831
853
  // }
832
854
  // }
833
855
  // }
834
856
 
835
- // // Set the object attribute of all pass_ids to the object attribute of all pass_ids
836
- // if (pass_ids.size > 0) {
837
- // for (let key of pass_ids.keys()) {
838
- // let passEls = document.querySelectorAll(`[pass_id="${key}"]`)
839
- // for (let passEl of passEls) {
840
- // // if (passEl.getAttribute('array') == array){
841
- // // Set the object id attribute to the passEl s object if it is not set.
842
- // if (passEl.getAttribute('object') == '') {
843
- // passEl.setAttribute('object', id);
857
+ // // Set the object attribute of all state_ids to the object attribute of all state_ids
858
+ // if (state_ids.size > 0) {
859
+ // for (let key of state_ids.keys()) {
860
+ // let stateEls = document.querySelectorAll(`[state_id="${key}"]`)
861
+ // for (let stateEl of stateEls) {
862
+ // // if (stateEl.getAttribute('array') == array){
863
+ // // Set the object id attribute to the stateEl s object if it is not set.
864
+ // if (stateEl.getAttribute('object') == '') {
865
+ // stateEl.setAttribute('object', id);
844
866
  // }
845
867
  // // }
846
868
  // }