@cocreate/local-storage 1.22.0 → 2.0.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/.github/FUNDING.yml +1 -1
- package/.github/workflows/automated.yml +18 -7
- package/CHANGELOG.md +498 -468
- package/CONTRIBUTING.md +6 -6
- package/README.md +17 -17
- package/demo/index.html +1 -1
- package/docs/index.html +8 -8
- package/package.json +5 -5
- package/src/index.js +80 -1
package/CONTRIBUTING.md
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
# Contributing to CoCreate-local-storage
|
|
2
2
|
|
|
3
|
-
This project is work of [many contributors](https://github.com/
|
|
4
|
-
You're encouraged to submit [pull requests](https://github.com/
|
|
5
|
-
[propose features and discuss issues](https://github.com/
|
|
3
|
+
This project is work of [many contributors](https://github.com/CoCreateJS/local-storage/graphs/contributors).
|
|
4
|
+
You're encouraged to submit [pull requests](https://github.com/CoCreateJS/local-storage/pulls),
|
|
5
|
+
[propose features and discuss issues](https://github.com/CoCreateJS/local-storage/issues).
|
|
6
6
|
|
|
7
7
|
In the examples below, substitute your Github username for `contributor` in URLs.
|
|
8
8
|
|
|
9
9
|
## Fork the Project
|
|
10
10
|
|
|
11
|
-
Fork the [project on Github](https://github.com/
|
|
11
|
+
Fork the [project on Github](https://github.com/CoCreateJS/local-storage) and check out your copy.
|
|
12
12
|
|
|
13
13
|
```
|
|
14
14
|
git local-storage https://github.com/contributor/CoCreate-local-storage.git
|
|
15
15
|
cd CoCreate-local-storage
|
|
16
|
-
git remote add upstream https://
|
|
16
|
+
git remote add upstream https://github.com/CoCreateJS/local-storage.git
|
|
17
17
|
```
|
|
18
18
|
|
|
19
19
|
## Create a Topic Branch
|
|
@@ -75,7 +75,7 @@ git push origin my-feature-branch
|
|
|
75
75
|
|
|
76
76
|
## Make a Pull Request
|
|
77
77
|
|
|
78
|
-
Go to [https://github.com/
|
|
78
|
+
Go to [https://github.com/CoCreateJS/local-storage](https://github.com/CoCreateJS/local-storage) and select your feature branch.
|
|
79
79
|
Click the 'Pull Request' button and fill out the form. Pull requests are usually reviewed within a few days.
|
|
80
80
|
|
|
81
81
|
## Rebase
|
package/README.md
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
# CoCreate-local-storage
|
|
2
2
|
|
|
3
|
-
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 Take it for a spin in our [playground!](https://
|
|
3
|
+
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 Take it for a spin in our [playground!](https://CoCreateJS.com/docs/local-storage)
|
|
4
4
|
|
|
5
|
-

|
|
6
|
+

|
|
7
|
+

|
|
8
|
+

|
|
9
|
+

|
|
10
10
|

|
|
11
11
|
|
|
12
|
-

|
|
13
13
|
|
|
14
|
-
## [Docs & Demo](https://
|
|
14
|
+
## [Docs & Demo](https://CoCreateJS.com/docs/local-storage)
|
|
15
15
|
|
|
16
|
-
For a complete guide and working demo refer to the [doumentation](https://
|
|
16
|
+
For a complete guide and working demo refer to the [doumentation](https://CoCreateJS.com/docs/local-storage)
|
|
17
17
|
|
|
18
18
|
## CDN
|
|
19
19
|
|
|
20
20
|
```html
|
|
21
|
-
<script src="https://cdn.
|
|
21
|
+
<script src="https://cdn.CoCreateJS.com/local-storage/latest/CoCreate-local-storage.min.js"></script>
|
|
22
22
|
```
|
|
23
23
|
|
|
24
24
|
```html
|
|
25
|
-
<script src="https://cdn.
|
|
25
|
+
<script src="https://cdn.CoCreateJS.com/local-storage/latest/CoCreate-local-storage.min.css"></script>
|
|
26
26
|
```
|
|
27
27
|
|
|
28
28
|
## NPM
|
|
@@ -50,13 +50,13 @@ $ yarn install @cocreate/local-storage
|
|
|
50
50
|
|
|
51
51
|
# Announcements
|
|
52
52
|
|
|
53
|
-
All updates to this library are documented in our [CHANGELOG](https://github.com/
|
|
53
|
+
All updates to this library are documented in our [CHANGELOG](https://github.com/CoCreateJS/local-storage/blob/master/CHANGELOG.md) and [releases](https://github.com/CoCreateJS/local-storage/releases). You may also subscribe to email for releases and breaking changes.
|
|
54
54
|
|
|
55
55
|
<a name="roadmap"></a>
|
|
56
56
|
|
|
57
57
|
# Roadmap
|
|
58
58
|
|
|
59
|
-
If you are interested in the future direction of this project, please take a look at our open [issues](https://github.com/
|
|
59
|
+
If you are interested in the future direction of this project, please take a look at our open [issues](https://github.com/CoCreateJS/local-storage/issues) and [pull requests](https://github.com/CoCreateJS/local-storage/pulls). We would love to hear your feedback.
|
|
60
60
|
|
|
61
61
|
<a name="about"></a>
|
|
62
62
|
|
|
@@ -64,7 +64,7 @@ If you are interested in the future direction of this project, please take a loo
|
|
|
64
64
|
|
|
65
65
|
CoCreate-local-storage is guided and supported by the CoCreate Developer Experience Team.
|
|
66
66
|
|
|
67
|
-
Please Email the Developer Experience Team [here](mailto:develop@
|
|
67
|
+
Please Email the Developer Experience Team [here](mailto:develop@CoCreateJS.com) in case of any queries.
|
|
68
68
|
|
|
69
69
|
CoCreate-local-storage is maintained and funded by CoCreate. The names and logos for CoCreate are trademarks of CoCreate, LLC.
|
|
70
70
|
|
|
@@ -72,9 +72,9 @@ CoCreate-local-storage is maintained and funded by CoCreate. The names and logos
|
|
|
72
72
|
|
|
73
73
|
# How to Contribute
|
|
74
74
|
|
|
75
|
-
We encourage contribution to our libraries (you might even score some nifty swag), please see our [CONTRIBUTING](https://github.com/
|
|
75
|
+
We encourage contribution to our libraries (you might even score some nifty swag), please see our [CONTRIBUTING](https://github.com/CoCreateJS/local-storage/blob/master/CONTRIBUTING.md) guide for details.
|
|
76
76
|
|
|
77
|
-
We want this library to be community-driven, and CoCreate led. We need your help to realize this goal. To help make sure we are building the right things in the right order, we ask that you create [issues](https://github.com/
|
|
77
|
+
We want this library to be community-driven, and CoCreate led. We need your help to realize this goal. To help make sure we are building the right things in the right order, we ask that you create [issues](https://github.com/CoCreateJS/local-storage/issues) and [pull requests](https://github.com/CoCreateJS/local-storage/pulls) or merely upvote or comment on existing issues or pull requests.
|
|
78
78
|
|
|
79
79
|
We appreciate your continued support, thank you!
|
|
80
80
|
|
|
@@ -82,4 +82,4 @@ We appreciate your continued support, thank you!
|
|
|
82
82
|
<a name="license"></a>
|
|
83
83
|
# License
|
|
84
84
|
|
|
85
|
-
[The MIT License (MIT)](https://github.com/
|
|
85
|
+
[The MIT License (MIT)](https://github.com/CoCreateJS/local-storage/blob/master/LICENSE)
|
package/demo/index.html
CHANGED
package/docs/index.html
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
rel="icon"
|
|
10
10
|
type="image/png"
|
|
11
11
|
sizes="32x32"
|
|
12
|
-
href="https://
|
|
12
|
+
href="https://CoCreateJS.com/images/favicon.ico" />
|
|
13
13
|
<meta
|
|
14
14
|
name="description"
|
|
15
15
|
content="Simple component to save and fetch data for inputs, textarea, selects from localstorage. easilly configuable with attributes and/or JavaScript API." />
|
|
@@ -19,13 +19,13 @@
|
|
|
19
19
|
<meta name="robots" content="index,follow" />
|
|
20
20
|
<meta
|
|
21
21
|
property="og:image"
|
|
22
|
-
content="https://cdn.
|
|
22
|
+
content="https://cdn.CoCreateJS.com/docs/local-storage.png" />
|
|
23
23
|
|
|
24
24
|
<!-- CoCreate CSS CDN-->
|
|
25
25
|
|
|
26
26
|
<link
|
|
27
27
|
rel="stylesheet"
|
|
28
|
-
href="https://ws.
|
|
28
|
+
href="https://ws.CoCreateJS.com/docs.css"
|
|
29
29
|
array="apples"
|
|
30
30
|
object="6069ff5042ef8ff5175a5c8d"
|
|
31
31
|
key="css"
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
share-title="CoCreate-local-storage"
|
|
75
75
|
share-height="600"
|
|
76
76
|
share-width="700"
|
|
77
|
-
share-media="https://cdn.
|
|
77
|
+
share-media="https://cdn.CoCreateJS.com/docs/local-storage.png"
|
|
78
78
|
hover="display:block!important"
|
|
79
79
|
hover-query=".social-networks">
|
|
80
80
|
<div class="display:none social-networks">
|
|
@@ -105,7 +105,7 @@
|
|
|
105
105
|
></a>
|
|
106
106
|
</div>
|
|
107
107
|
<a
|
|
108
|
-
href="https://github.com/
|
|
108
|
+
href="https://github.com/CoCreateJS/CoCreate-local-storage"
|
|
109
109
|
target="_blank"
|
|
110
110
|
class="margin-right:15px"
|
|
111
111
|
><i src="/assets/svg/github.svg"></i
|
|
@@ -144,7 +144,7 @@
|
|
|
144
144
|
<p class="padding:10px_0px line-height:1.5">
|
|
145
145
|
Or you can use cdn link:
|
|
146
146
|
</p>
|
|
147
|
-
<pre><code class="language-html"><script>https://cdn.
|
|
147
|
+
<pre><code class="language-html"><script>https://cdn.CoCreateJS.com/local-storage/latest/CoCreate-local-storage.min.js</script></code></pre>
|
|
148
148
|
|
|
149
149
|
<div
|
|
150
150
|
id="local-storage-usage"
|
|
@@ -329,13 +329,13 @@
|
|
|
329
329
|
</div>
|
|
330
330
|
</div>
|
|
331
331
|
<button
|
|
332
|
-
href="https://github.com/
|
|
332
|
+
href="https://github.com/CoCreateJS/CoCreate-local-storage/tree/master/docs/index.html?message=docs%3A%20describe%20your%20change..."
|
|
333
333
|
target="_blank"
|
|
334
334
|
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)">
|
|
335
335
|
<i src="../assets/svg/pencil-alt.svg"></i>
|
|
336
336
|
</button>
|
|
337
337
|
</main>
|
|
338
338
|
|
|
339
|
-
<script src="https://
|
|
339
|
+
<script src="https://CoCreateJS.com/dist/CoCreate.js"></script>
|
|
340
340
|
</body>
|
|
341
341
|
</html>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/local-storage",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.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",
|
|
@@ -22,17 +22,17 @@
|
|
|
22
22
|
},
|
|
23
23
|
"repository": {
|
|
24
24
|
"type": "git",
|
|
25
|
-
"url": "git+https://
|
|
25
|
+
"url": "git+https://github.com/CoCreateJS/local-storage.git"
|
|
26
26
|
},
|
|
27
27
|
"author": "CoCreate LLC",
|
|
28
28
|
"license": "MIT",
|
|
29
29
|
"bugs": {
|
|
30
|
-
"url": "https://github.com/
|
|
30
|
+
"url": "https://github.com/CoCreateJS/local-storage/issues"
|
|
31
31
|
},
|
|
32
|
-
"homepage": "https://
|
|
32
|
+
"homepage": "https://CoCreateJS.com/docs/local-storage",
|
|
33
33
|
"funding": {
|
|
34
34
|
"type": "GitHub Sponsors ❤",
|
|
35
|
-
"url": "https://github.com/sponsors/
|
|
35
|
+
"url": "https://github.com/sponsors/CoCreateJS"
|
|
36
36
|
},
|
|
37
37
|
"main": "./src/index.js",
|
|
38
38
|
"dependencies": {
|
package/src/index.js
CHANGED
|
@@ -4,6 +4,11 @@ import Actions from "@cocreate/actions";
|
|
|
4
4
|
let support = true;
|
|
5
5
|
const storage = new Map();
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
* @public
|
|
10
|
+
* @environment client
|
|
11
|
+
*/
|
|
7
12
|
function init() {
|
|
8
13
|
var elements = document.querySelectorAll(
|
|
9
14
|
"[localstorage-set], [localstorage-get], [sessionstorage-set], [sessionstorage-get]"
|
|
@@ -36,6 +41,8 @@ function init() {
|
|
|
36
41
|
/**
|
|
37
42
|
* Initializes a collection of elements.
|
|
38
43
|
* @param {Array<Element>} elements - An array of elements to be initialized.
|
|
44
|
+
* @public
|
|
45
|
+
* @environment client
|
|
39
46
|
*/
|
|
40
47
|
function initElements(elements) {
|
|
41
48
|
for (let element of elements) initElement(element);
|
|
@@ -44,6 +51,8 @@ function initElements(elements) {
|
|
|
44
51
|
/**
|
|
45
52
|
* Initializes a single element.
|
|
46
53
|
* @param {Element} element - The element to initialize. This function expects an 'Element' type.
|
|
54
|
+
* @public
|
|
55
|
+
* @environment client
|
|
47
56
|
*/
|
|
48
57
|
function initElement(element) {
|
|
49
58
|
const types = ["localstorage", "sessionstorage"];
|
|
@@ -104,6 +113,8 @@ function initElement(element) {
|
|
|
104
113
|
* @param key
|
|
105
114
|
* @param type - 'localstorage' or 'sessionstorage'
|
|
106
115
|
* @return { Mixed } The value associated with the key or undefined if not found.
|
|
116
|
+
* @public
|
|
117
|
+
* @environment client
|
|
107
118
|
*/
|
|
108
119
|
function getItem(key, type = "localstorage") {
|
|
109
120
|
if (support) {
|
|
@@ -117,6 +128,8 @@ function getItem(key, type = "localstorage") {
|
|
|
117
128
|
* @param key - key name to store the value under
|
|
118
129
|
* @param value - value to store
|
|
119
130
|
* @param type - 'localstorage' or 'sessionstorage'
|
|
131
|
+
* @public
|
|
132
|
+
* @environment client
|
|
120
133
|
*/
|
|
121
134
|
function setItem(key, value, type = "localstorage") {
|
|
122
135
|
try {
|
|
@@ -161,6 +174,8 @@ function setItem(key, value, type = "localstorage") {
|
|
|
161
174
|
/**
|
|
162
175
|
* @param key - The key name to delete from the storage
|
|
163
176
|
* @param type - 'localstorage' or 'sessionstorage'
|
|
177
|
+
* @public
|
|
178
|
+
* @environment client
|
|
164
179
|
*/
|
|
165
180
|
function removeItem(key, type = "localstorage") {
|
|
166
181
|
if (support) {
|
|
@@ -175,6 +190,8 @@ function removeItem(key, type = "localstorage") {
|
|
|
175
190
|
* @param action
|
|
176
191
|
*
|
|
177
192
|
* @return { undefined } No return
|
|
193
|
+
* @public
|
|
194
|
+
* @environment client
|
|
178
195
|
*/
|
|
179
196
|
async function runStorage(action) {
|
|
180
197
|
const form = action.form;
|
|
@@ -219,18 +236,33 @@ async function runStorage(action) {
|
|
|
219
236
|
);
|
|
220
237
|
}
|
|
221
238
|
|
|
239
|
+
/**
|
|
240
|
+
*
|
|
241
|
+
* @public
|
|
242
|
+
* @environment client
|
|
243
|
+
*/
|
|
222
244
|
const localStorage = {
|
|
223
245
|
getItem: (key) => getItem(key, "localstorage"),
|
|
224
246
|
setItem: (key, value) => setItem(key, value, "localstorage"),
|
|
225
247
|
removeItem: (key) => removeItem(key, "localstorage")
|
|
226
248
|
};
|
|
227
249
|
|
|
250
|
+
/**
|
|
251
|
+
*
|
|
252
|
+
* @public
|
|
253
|
+
* @environment client
|
|
254
|
+
*/
|
|
228
255
|
const sessionStorage = {
|
|
229
256
|
getItem: (key) => getItem(key, "sessionstorage"),
|
|
230
257
|
setItem: (key, value) => setItem(key, value, "sessionstorage"),
|
|
231
258
|
removeItem: (key) => removeItem(key, "sessionstorage")
|
|
232
259
|
};
|
|
233
260
|
|
|
261
|
+
/**
|
|
262
|
+
*
|
|
263
|
+
* @public
|
|
264
|
+
* @environment client
|
|
265
|
+
*/
|
|
234
266
|
function checkSupport() {
|
|
235
267
|
// Check if the browser supports Web Storage.
|
|
236
268
|
if (!("localStorage" in window) || !("sessionStorage" in window)) {
|
|
@@ -310,4 +342,51 @@ export default {
|
|
|
310
342
|
checkSupport,
|
|
311
343
|
localStorage,
|
|
312
344
|
sessionStorage
|
|
313
|
-
};
|
|
345
|
+
};
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
*
|
|
349
|
+
* @name realtime
|
|
350
|
+
* @kind member
|
|
351
|
+
* @attribute
|
|
352
|
+
* @environment client
|
|
353
|
+
*/
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* 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
|
|
357
|
+
*
|
|
358
|
+
* @module local-storage
|
|
359
|
+
* @environment client
|
|
360
|
+
*/
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* Declarative selectors recognized by this module.
|
|
364
|
+
*
|
|
365
|
+
* @name declarative-selectors
|
|
366
|
+
* @kind member
|
|
367
|
+
* @selectors
|
|
368
|
+
* @environment client
|
|
369
|
+
* @example
|
|
370
|
+
* ```json
|
|
371
|
+
* [
|
|
372
|
+
* "[localstorage-set], [sessionstorage-set]"
|
|
373
|
+
* ]
|
|
374
|
+
* ```
|
|
375
|
+
*/
|
|
376
|
+
|
|
377
|
+
/**
|
|
378
|
+
* Declarative actions supported or registered by this module.
|
|
379
|
+
*
|
|
380
|
+
* @name declarative-actions
|
|
381
|
+
* @kind member
|
|
382
|
+
* @actions
|
|
383
|
+
* @environment client
|
|
384
|
+
* @example
|
|
385
|
+
* ```json
|
|
386
|
+
* [
|
|
387
|
+
* {
|
|
388
|
+
* "name": "localStorage"
|
|
389
|
+
* }
|
|
390
|
+
* ]
|
|
391
|
+
* ```
|
|
392
|
+
*/
|