@cocreate/local-storage 1.11.1 → 1.13.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 +19 -0
- package/docs/index.html +9 -11
- package/package.json +3 -3
- package/src/index.js +9 -13
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
# [1.13.0](https://github.com/CoCreate-app/CoCreate-local-storage/compare/v1.12.0...v1.13.0) (2023-11-25)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* upgrade dependencies for latest features and fixes ([f511bf3](https://github.com/CoCreate-app/CoCreate-local-storage/commit/f511bf38c1dfa70e79a60fb0f96c1fbafe97f192))
|
|
7
|
+
|
|
8
|
+
# [1.12.0](https://github.com/CoCreate-app/CoCreate-local-storage/compare/v1.11.1...v1.12.0) (2023-11-25)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* update nav, edit button and css path ([2bc7891](https://github.com/CoCreate-app/CoCreate-local-storage/commit/2bc78915b8bfb1d06ae109419acdbcd392c0f9c4))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Features
|
|
17
|
+
|
|
18
|
+
* upgrade dependencies for latest features and fixes ([85889c5](https://github.com/CoCreate-app/CoCreate-local-storage/commit/85889c578d45a5394cd606eabd8cc2ce59dd351a))
|
|
19
|
+
|
|
1
20
|
## [1.11.1](https://github.com/CoCreate-app/CoCreate-local-storage/compare/v1.11.0...v1.11.1) (2023-11-22)
|
|
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="
|
|
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,
|
|
44
|
-
scroll-up="
|
|
45
|
-
scroll-down="
|
|
46
|
-
|
|
47
|
-
|
|
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
|
|
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.
|
|
3
|
+
"version": "1.13.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.
|
|
62
|
-
"@cocreate/observer": "^1.
|
|
61
|
+
"@cocreate/actions": "^1.14.0",
|
|
62
|
+
"@cocreate/observer": "^1.14.0"
|
|
63
63
|
}
|
|
64
64
|
}
|
package/src/index.js
CHANGED
|
@@ -5,23 +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.
|
|
21
18
|
if (element.hasAttribute('localstorage-attribute') || element.hasAttribute('localstorage-value') || element.hasAttribute('localstorage-key'))
|
|
22
19
|
return
|
|
23
20
|
let value = self.getItem(e.key)
|
|
24
|
-
// Set the value of the element.
|
|
25
21
|
if (value != null) {
|
|
26
22
|
element.setValue(value)
|
|
27
23
|
}
|
|
@@ -30,18 +26,18 @@ const CoCreateLocalStorage = {
|
|
|
30
26
|
},
|
|
31
27
|
|
|
32
28
|
/**
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
* Initializes a collection of elements.
|
|
30
|
+
* @param {Array<Element>} elements - An array of elements to be initialized.
|
|
31
|
+
*/
|
|
35
32
|
initElements: function (elements) {
|
|
36
33
|
for (let element of elements)
|
|
37
34
|
this.initElement(element)
|
|
38
35
|
},
|
|
39
36
|
|
|
40
37
|
/**
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
*/
|
|
38
|
+
* Initializes a single element.
|
|
39
|
+
* @param {Element} element - The element to initialize. This function expects an 'Element' type.
|
|
40
|
+
*/
|
|
45
41
|
initElement: function (element) {
|
|
46
42
|
this.getItem(element)
|
|
47
43
|
element.addEventListener('input', (e) => {
|