@cocreate/local-storage 1.11.0 → 1.12.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,22 @@
1
+ # [1.12.0](https://github.com/CoCreate-app/CoCreate-local-storage/compare/v1.11.1...v1.12.0) (2023-11-25)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * update nav, edit button and css path ([2bc7891](https://github.com/CoCreate-app/CoCreate-local-storage/commit/2bc78915b8bfb1d06ae109419acdbcd392c0f9c4))
7
+
8
+
9
+ ### Features
10
+
11
+ * upgrade dependencies for latest features and fixes ([85889c5](https://github.com/CoCreate-app/CoCreate-local-storage/commit/85889c578d45a5394cd606eabd8cc2ce59dd351a))
12
+
13
+ ## [1.11.1](https://github.com/CoCreate-app/CoCreate-local-storage/compare/v1.11.0...v1.11.1) (2023-11-22)
14
+
15
+
16
+ ### Bug Fixes
17
+
18
+ * return if element was handled by events ([f8c654e](https://github.com/CoCreate-app/CoCreate-local-storage/commit/f8c654edd0a271406332217ccafcb80df74318db))
19
+
1
20
  # [1.11.0](https://github.com/CoCreate-app/CoCreate-local-storage/compare/v1.10.11...v1.11.0) (2023-11-19)
2
21
 
3
22
 
package/docs/index.html CHANGED
@@ -37,15 +37,15 @@
37
37
  </head>
38
38
 
39
39
  <body>
40
+ <!-- Navbar -->
40
41
  <nav
41
- class="nav display:flex align-items:center left:0px background:whitesmoke padding-top:10px padding-bottom:10px"
42
+ class="width:100% display:flex align-items:center background:transparent padding-top:10px padding-bottom:10px"
42
43
  content_id="content"
43
- scroll="sticky-nav,hide-nav"
44
- scroll-up="10"
45
- scroll-down="10"
46
- array="files"
47
- object="60395ef42b3ac232657040fd"
48
- key="src"></nav>
44
+ scroll="sticky-nav,"
45
+ scroll-up="5"
46
+ scroll-down="5"
47
+ path="../"
48
+ src="../components/navbar.html"></nav>
49
49
  <sidenav
50
50
  id="menuL"
51
51
  class="position:fixed top:0px left:0px overflow:hidden background:whitesmoke height:100vh width:0px width:300px@xl"
@@ -356,10 +356,8 @@
356
356
  <button
357
357
  href="https://github.com/CoCreate-app/CoCreate-local-storage/tree/master/docs/index.html?message=docs%3A%20describe%20your%20change..."
358
358
  target="_blank"
359
- 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)">
360
- <i
361
- class="height:20px fill:#505050"
362
- src="/assets/svg/pencil-alt.svg"></i>
359
+ 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)">
360
+ <i class="height:20px" src="../assets/svg/pencil-alt.svg"></i>
363
361
  </button>
364
362
  </main>
365
363
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/local-storage",
3
- "version": "1.11.0",
3
+ "version": "1.12.0",
4
4
  "description": "A Simple component similar to CoCreate-input & CoCreate-fetch which Save and fetch data for inputs, textarea, selects from localstorage. Easily configured using HTML5 attributes and/or JavaScript API",
5
5
  "keywords": [
6
6
  "local-storage",
@@ -58,7 +58,7 @@
58
58
  "webpack-log": "^3.0.1"
59
59
  },
60
60
  "dependencies": {
61
- "@cocreate/actions": "^1.12.4",
62
- "@cocreate/observer": "^1.12.0"
61
+ "@cocreate/actions": "^1.13.0",
62
+ "@cocreate/observer": "^1.13.0"
63
63
  }
64
64
  }
package/src/index.js CHANGED
@@ -5,21 +5,19 @@ const CoCreateLocalStorage = {
5
5
  support: true,
6
6
  storage: new Map(),
7
7
 
8
- /**
9
- * Listen for storage events and update elements if needed. This is called on window. storage and when it's time to get / set data
10
- */
11
8
  init: function () {
12
9
  const self = this
13
10
  var elements = document.querySelectorAll('[localstorage-set], [localstorage-get]');
14
11
  this.initElements(elements)
15
- /**
16
- * @param e
17
- */
12
+
18
13
  window.addEventListener('storage', function (e) {
19
14
  elements = document.querySelectorAll(`[localstorage-get="${e.key}"]`)
20
15
  for (let element of elements) {
16
+ // TODO: return if localstorage-selector, etc...
17
+ // - Decide how best to handle, considering localstorage is also handled by event.
18
+ if (element.hasAttribute('localstorage-attribute') || element.hasAttribute('localstorage-value') || element.hasAttribute('localstorage-key'))
19
+ return
21
20
  let value = self.getItem(e.key)
22
- // Set the value of the element.
23
21
  if (value != null) {
24
22
  element.setValue(value)
25
23
  }
@@ -28,18 +26,18 @@ const CoCreateLocalStorage = {
28
26
  },
29
27
 
30
28
  /**
31
- * @param elements
32
- */
29
+ * Initializes a collection of elements.
30
+ * @param {Array<Element>} elements - An array of elements to be initialized.
31
+ */
33
32
  initElements: function (elements) {
34
33
  for (let element of elements)
35
34
  this.initElement(element)
36
35
  },
37
36
 
38
37
  /**
39
- * @param element
40
- *
41
- * @return { Object } The binding
42
- */
38
+ * Initializes a single element.
39
+ * @param {Element} element - The element to initialize. This function expects an 'Element' type.
40
+ */
43
41
  initElement: function (element) {
44
42
  this.getItem(element)
45
43
  element.addEventListener('input', (e) => {