@cocreate/state 1.24.1 → 1.24.3
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 +18 -0
- package/docs/index.html +328 -323
- package/package.json +10 -14
- package/src/index.js +18 -25
- package/webpack.config.js +65 -90
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,21 @@
|
|
|
1
|
+
## [1.24.3](https://github.com/CoCreate-app/CoCreate-state/compare/v1.24.2...v1.24.3) (2025-04-30)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* added css-loader ([510a7db](https://github.com/CoCreate-app/CoCreate-state/commit/510a7db900864ea22da8a5da541bdd9e7d51a44d))
|
|
7
|
+
* update query attributes ([49b7f7d](https://github.com/CoCreate-app/CoCreate-state/commit/49b7f7d9e8ea846fd28e779dd6b4735677c03ad9))
|
|
8
|
+
* updated cocreate modules versions ([d7d2be5](https://github.com/CoCreate-app/CoCreate-state/commit/d7d2be55f00e1d90a46c65a2604a84c51690500e))
|
|
9
|
+
* webpack.config and devdependencies ([3e9b1df](https://github.com/CoCreate-app/CoCreate-state/commit/3e9b1df0a41f209fc818a2b73144a57f229eb264))
|
|
10
|
+
|
|
11
|
+
## [1.24.2](https://github.com/CoCreate-app/CoCreate-state/compare/v1.24.1...v1.24.2) (2025-04-11)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Bug Fixes
|
|
15
|
+
|
|
16
|
+
* renamed statedAttributes to state in local storage. ([610f591](https://github.com/CoCreate-app/CoCreate-state/commit/610f5916069ee773ee4bc020430892c869088d0b))
|
|
17
|
+
* update observer observe param to type and and attributeName to attributeFilter ([42d8a89](https://github.com/CoCreate-app/CoCreate-state/commit/42d8a89ce2b32ee5d17b8a1498e40bd4503416a9))
|
|
18
|
+
|
|
1
19
|
## [1.24.1](https://github.com/CoCreate-app/CoCreate-state/compare/v1.24.0...v1.24.1) (2025-01-18)
|
|
2
20
|
|
|
3
21
|
|
package/docs/index.html
CHANGED
|
@@ -1,334 +1,339 @@
|
|
|
1
1
|
<!DOCTYPE html>
|
|
2
2
|
<html lang="en">
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
<meta
|
|
24
|
-
property="og:image"
|
|
25
|
-
content="https://cdn.cocreate.app/docs/state.png"
|
|
26
|
-
/>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
7
|
+
<title>CoCreate-state Documentation | CoCreateJS</title>
|
|
8
|
+
<link
|
|
9
|
+
rel="icon"
|
|
10
|
+
type="image/png"
|
|
11
|
+
sizes="32x32"
|
|
12
|
+
href="https://cocreate.app/images/favicon.ico" />
|
|
13
|
+
<meta
|
|
14
|
+
name="description"
|
|
15
|
+
content="Data attributes which can be used for components in CoCreate framework combined as a group of attributes that dynamically change attributes & fetch custom data" />
|
|
16
|
+
<meta
|
|
17
|
+
name="keywords"
|
|
18
|
+
content="helper classes, utility classes, css framework, css library, inline style classes" />
|
|
19
|
+
<meta name="robots" content="index,follow" />
|
|
20
|
+
<meta
|
|
21
|
+
property="og:image"
|
|
22
|
+
content="https://cdn.cocreate.app/docs/state.png" />
|
|
27
23
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
</head>
|
|
24
|
+
<link
|
|
25
|
+
rel="stylesheet"
|
|
26
|
+
href="../index.css"
|
|
27
|
+
array="files"
|
|
28
|
+
object="60888216117c640e7596303f"
|
|
29
|
+
key="src"
|
|
30
|
+
type="text/css"
|
|
31
|
+
save="true" />
|
|
32
|
+
<link rel="manifest" href="/manifest.webmanifest" />
|
|
33
|
+
</head>
|
|
39
34
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
<pre><code class="language-bash">npm i @cocreate/state</code></pre>
|
|
152
|
-
<p class="padding:10px_0px line-height:1.5">
|
|
153
|
-
Or you can use cdn link:
|
|
154
|
-
</p>
|
|
155
|
-
<pre><code class="language-html"><script>https://cdn.cocreate.app/state/latest/CoCreate-state.min.js</script></code></pre>
|
|
35
|
+
<body>
|
|
36
|
+
<!-- Navbar -->
|
|
37
|
+
<nav
|
|
38
|
+
class="width:100% display:flex align-items:center background:transparent padding-top:10px padding-bottom:10px"
|
|
39
|
+
content_id="content"
|
|
40
|
+
scroll="sticky-nav,"
|
|
41
|
+
scroll-up="5"
|
|
42
|
+
scroll-down="5"
|
|
43
|
+
path="../"
|
|
44
|
+
src="../components/navbar.html"></nav>
|
|
45
|
+
<sidenav
|
|
46
|
+
id="menuL"
|
|
47
|
+
class="position:fixed top:0px left:0px overflow:hidden background:whitesmoke height:100vh width:0px width:300px@xl"
|
|
48
|
+
resizable
|
|
49
|
+
resize-query="[content_id='content']"
|
|
50
|
+
resize-property="margin-left"
|
|
51
|
+
resize-value="width">
|
|
52
|
+
<menu
|
|
53
|
+
array="files"
|
|
54
|
+
object="603717b07de7fb350ae9fec8"
|
|
55
|
+
key="src"></menu>
|
|
56
|
+
<div resize="right"></div>
|
|
57
|
+
</sidenav>
|
|
58
|
+
<main
|
|
59
|
+
class="padding-top:15px padding:15px@lg@xl"
|
|
60
|
+
content_id="content"
|
|
61
|
+
id="cocreate-state">
|
|
62
|
+
<div
|
|
63
|
+
class="display:flex flex-wrap:wrap justify-content:space-between position:relative margin:10px">
|
|
64
|
+
<div class="display:flex align-items:center">
|
|
65
|
+
<h2>CoCreate-state</h2>
|
|
66
|
+
</div>
|
|
67
|
+
<div
|
|
68
|
+
class="display:flex align-items:center font-size:20px position:absolute right:0 padding:5px background:white">
|
|
69
|
+
<div
|
|
70
|
+
class="display:flex align-items:center transition:0.3s padding-left:10px"
|
|
71
|
+
share-network="true"
|
|
72
|
+
share-text="Data attributes which can be used for components in CoCreate framework combined as a group of attributes that dynamically change attributes & fetch custom data"
|
|
73
|
+
share-title="CoCreate-state"
|
|
74
|
+
share-height="600"
|
|
75
|
+
share-width="700"
|
|
76
|
+
share-media="https://cdn.cocreate.app/docs/state.png"
|
|
77
|
+
hover="display:block!important"
|
|
78
|
+
hover-query=".social-networks">
|
|
79
|
+
<div class="display:none social-networks">
|
|
80
|
+
<a
|
|
81
|
+
class="margin-right:15px"
|
|
82
|
+
share-network="twitter"
|
|
83
|
+
title="Share on twitter"
|
|
84
|
+
><i src="/assets/svg/twitter.svg"></i
|
|
85
|
+
></a>
|
|
86
|
+
<a
|
|
87
|
+
class="margin-right:15px"
|
|
88
|
+
share-network="facebook"
|
|
89
|
+
title="Share on Facebook"
|
|
90
|
+
><i src="/assets/svg/facebook.svg"></i
|
|
91
|
+
></a>
|
|
92
|
+
<a
|
|
93
|
+
class="margin-right:15px"
|
|
94
|
+
share-network="instagram"
|
|
95
|
+
title="Share on instagram"
|
|
96
|
+
><i src="/assets/svg/instagram.svg"></i
|
|
97
|
+
></a>
|
|
98
|
+
</div>
|
|
99
|
+
<a
|
|
100
|
+
class="margin-right:15px"
|
|
101
|
+
share-network="share"
|
|
102
|
+
title="Share on share"
|
|
103
|
+
><i src="/assets/svg/share-alt.svg"></i
|
|
104
|
+
></a>
|
|
105
|
+
</div>
|
|
106
|
+
<a
|
|
107
|
+
href="https://github.com/CoCreate-app/CoCreate-state"
|
|
108
|
+
target="_blank"
|
|
109
|
+
class="margin-right:15px"
|
|
110
|
+
><i src="/assets/svg/github.svg"></i
|
|
111
|
+
></a>
|
|
112
|
+
</div>
|
|
113
|
+
</div>
|
|
114
|
+
<h1
|
|
115
|
+
class="max-width:500px margin:20px_10px line-height:1.5 font-size:16px font-weight:100">
|
|
116
|
+
Data attributes which can be used for components in CoCreate
|
|
117
|
+
framework combined as a group of attributes that dynamically
|
|
118
|
+
change attributes & fetch custom data.
|
|
119
|
+
</h1>
|
|
120
|
+
<div id="state-section" class="display:flex flex-wrap:wrap">
|
|
121
|
+
<div
|
|
122
|
+
class="flex-grow:1 width:400px width:300px@xs padding:0px_10px margin-top:60px">
|
|
123
|
+
<div
|
|
124
|
+
id="state-install"
|
|
125
|
+
class="border-bottom:1px_solid_lightgrey"
|
|
126
|
+
scroll
|
|
127
|
+
scroll-intersect="color:dodgerblue"
|
|
128
|
+
scroll-query="#state-install-section">
|
|
129
|
+
<span
|
|
130
|
+
class="display:flex align-items:center width:fit-content"
|
|
131
|
+
hover="display:block!important"
|
|
132
|
+
hover-query="[href='#state-install']">
|
|
133
|
+
<h2 class="padding:5px_0px">Install</h2>
|
|
134
|
+
<a
|
|
135
|
+
class="margin-left:10px display:none"
|
|
136
|
+
href="#state-install"
|
|
137
|
+
><i src="/assets/svg/link.svg"></i
|
|
138
|
+
></a>
|
|
139
|
+
</span>
|
|
140
|
+
</div>
|
|
141
|
+
<pre><code class="language-bash">npm i @cocreate/state</code></pre>
|
|
142
|
+
<p class="padding:10px_0px line-height:1.5">
|
|
143
|
+
Or you can use cdn link:
|
|
144
|
+
</p>
|
|
145
|
+
<pre><code class="language-html"><script>https://cdn.cocreate.app/state/latest/CoCreate-state.min.js</script></code></pre>
|
|
156
146
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
147
|
+
<div
|
|
148
|
+
id="state-usage"
|
|
149
|
+
class="margin-top:80px border-bottom:1px_solid_lightgrey"
|
|
150
|
+
scroll
|
|
151
|
+
scroll-intersect="color:dodgerblue"
|
|
152
|
+
scroll-query="#state-usage-section">
|
|
153
|
+
<span
|
|
154
|
+
class="display:flex align-items:center width:fit-content"
|
|
155
|
+
hover="display:block!important"
|
|
156
|
+
hover-query="[href='#state-usage']">
|
|
157
|
+
<h2 class="padding:5px_0px">Usage</h2>
|
|
158
|
+
<a
|
|
159
|
+
class="margin-left:10px display:none"
|
|
160
|
+
href="#state-usage"
|
|
161
|
+
><i src="/assets/svg/link.svg"></i
|
|
162
|
+
></a>
|
|
163
|
+
</span>
|
|
164
|
+
</div>
|
|
165
|
+
<div class="">
|
|
166
|
+
<p class="padding:10px_0px line-height:1.5">
|
|
167
|
+
This is state usage
|
|
168
|
+
</p>
|
|
177
169
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
170
|
+
<div class="flex-grow:1 min-width:300px width:100%">
|
|
171
|
+
<pre><code class="language-html"><div></div></code></pre>
|
|
172
|
+
</div>
|
|
173
|
+
<p class="padding:10px_0px line-height:1.5">
|
|
174
|
+
This is state usage
|
|
175
|
+
</p>
|
|
176
|
+
<p class="padding:10px_0px line-height:1.5">
|
|
177
|
+
This is state usage
|
|
178
|
+
</p>
|
|
179
|
+
</div>
|
|
180
|
+
<div
|
|
181
|
+
id="state-attributes"
|
|
182
|
+
class="margin-top:80px border-bottom:1px_solid_lightgrey"
|
|
183
|
+
scroll
|
|
184
|
+
scroll-intersect="color:dodgerblue"
|
|
185
|
+
scroll-query="#state-attributes-section">
|
|
186
|
+
<span
|
|
187
|
+
class="display:flex align-items:center width:fit-content"
|
|
188
|
+
hover="display:block!important"
|
|
189
|
+
hover-query="[href='#state-attributes']">
|
|
190
|
+
<h2 class="padding:5px_0px">Attributes</h2>
|
|
191
|
+
<a
|
|
192
|
+
class="margin-left:10px display:none"
|
|
193
|
+
href="#state-attributes"
|
|
194
|
+
><i src="/assets/svg/link.svg"></i
|
|
195
|
+
></a>
|
|
196
|
+
</span>
|
|
197
|
+
</div>
|
|
198
|
+
<ul class="list-style-type:none">
|
|
199
|
+
<li
|
|
200
|
+
class="padding:15px_0px border-bottom:1px_solid_lightgrey">
|
|
201
|
+
<h4>
|
|
202
|
+
<span>state</span>
|
|
203
|
+
<span class="cocreate-badge success"
|
|
204
|
+
>string</span
|
|
205
|
+
>
|
|
206
|
+
<span class="cocreate-badge warning"
|
|
207
|
+
>optional</span
|
|
208
|
+
>
|
|
209
|
+
</h4>
|
|
210
|
+
<p>state-attribute</p>
|
|
211
|
+
</li>
|
|
212
|
+
<li
|
|
213
|
+
class="padding:15px_0px border-bottom:1px_solid_lightgrey">
|
|
214
|
+
<h4>
|
|
215
|
+
<span>state</span>
|
|
216
|
+
<span class="cocreate-badge success"
|
|
217
|
+
>string</span
|
|
218
|
+
>
|
|
219
|
+
<span class="cocreate-badge warning"
|
|
220
|
+
>optional</span
|
|
221
|
+
>
|
|
222
|
+
</h4>
|
|
223
|
+
<p>state-attribute</p>
|
|
224
|
+
</li>
|
|
225
|
+
</ul>
|
|
226
|
+
</div>
|
|
221
227
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
</div>
|
|
228
|
+
<div
|
|
229
|
+
class="flex-grow:1 width:300px padding:0px_10px margin-top:60px border-bottom:1px_solid_lightgrey">
|
|
230
|
+
<!-- SandBox -->
|
|
231
|
+
<div
|
|
232
|
+
id="state-demo"
|
|
233
|
+
class="border-bottom:1px_solid_lightgrey"
|
|
234
|
+
scroll
|
|
235
|
+
scroll-intersect="color:dodgerblue"
|
|
236
|
+
scroll-query="#state-demo-section">
|
|
237
|
+
<span
|
|
238
|
+
class="display:flex align-items:center width:fit-content"
|
|
239
|
+
hover="display:block!important"
|
|
240
|
+
hover-query="[href='#state-demo']">
|
|
241
|
+
<h2 class="padding:5px_0px">Demo</h2>
|
|
242
|
+
<a
|
|
243
|
+
class="margin-left:10px display:none"
|
|
244
|
+
href="#state-demo"
|
|
245
|
+
><i src="/assets/svg/link.svg"></i
|
|
246
|
+
></a>
|
|
247
|
+
</span>
|
|
248
|
+
</div>
|
|
249
|
+
<div
|
|
250
|
+
class="position:sticky top:0 padding:15px_0px height:100vh">
|
|
251
|
+
<!-- SandBox -->
|
|
252
|
+
<div
|
|
253
|
+
class="display:flex flex-direction:column position:relative overflow:hidden card border-radius:2px width:auto height:600px margin-top:20px"
|
|
254
|
+
id="playground">
|
|
255
|
+
<div
|
|
256
|
+
id="demo-code"
|
|
257
|
+
resizable
|
|
258
|
+
class="position:relative height:50%">
|
|
259
|
+
<textarea
|
|
260
|
+
type="code"
|
|
261
|
+
lang="html"
|
|
262
|
+
array="demos"
|
|
263
|
+
object=""
|
|
264
|
+
key="demo"
|
|
265
|
+
save="false"
|
|
266
|
+
id="demo"
|
|
267
|
+
class="height:100% width:100% outline:none border:none resize:none padding:5px"></textarea>
|
|
268
|
+
<div
|
|
269
|
+
resize="bottom"
|
|
270
|
+
class="background:lightgrey"></div>
|
|
271
|
+
</div>
|
|
267
272
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
</div>
|
|
273
|
+
<div
|
|
274
|
+
id="demo-preview"
|
|
275
|
+
class="position:relative overflow:auto background-color:white">
|
|
276
|
+
<div class="demopreview padding:20px"></div>
|
|
277
|
+
</div>
|
|
274
278
|
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
279
|
+
<div
|
|
280
|
+
class="font-size:20px position:absolute top:10px right:10px opacity:0.6">
|
|
281
|
+
<a
|
|
282
|
+
class="margin-right:10px"
|
|
283
|
+
id="eye"
|
|
284
|
+
show="#eye-slash"
|
|
285
|
+
hide="#eye, #demo-preview"
|
|
286
|
+
toggle="code-height"
|
|
287
|
+
toggle-query="#demo-code"
|
|
288
|
+
><i
|
|
289
|
+
class="height:18px"
|
|
290
|
+
src="/assets/svg/eye.svg"></i
|
|
291
|
+
></a>
|
|
292
|
+
<a
|
|
293
|
+
class="margin-right:10px"
|
|
294
|
+
hidden
|
|
295
|
+
id="eye-slash"
|
|
296
|
+
show="#eye, #demo-preview"
|
|
297
|
+
hide="#eye-slash"
|
|
298
|
+
toggle="code-height"
|
|
299
|
+
toggle-query="#demo-code"
|
|
300
|
+
><i src="/assets/svg/eye-slash.svg"></i
|
|
301
|
+
></a>
|
|
302
|
+
<a
|
|
303
|
+
class="margin-right:10px"
|
|
304
|
+
id="code"
|
|
305
|
+
show="#code-slash"
|
|
306
|
+
hide="#code, #demo-code"
|
|
307
|
+
><i src="/assets/svg/code.svg"></i
|
|
308
|
+
></a>
|
|
309
|
+
<a
|
|
310
|
+
class="margin-right:10px"
|
|
311
|
+
hidden
|
|
312
|
+
id="code-slash"
|
|
313
|
+
show="#code, #demo-code"
|
|
314
|
+
hide="#code-slash"
|
|
315
|
+
><i
|
|
316
|
+
class="height:18px"
|
|
317
|
+
src="/assets/svg/code.svg"></i
|
|
318
|
+
></a>
|
|
319
|
+
<a
|
|
320
|
+
class="margin-right:5px"
|
|
321
|
+
fullscreen
|
|
322
|
+
fullscreen-query="#playground"></a>
|
|
323
|
+
</div>
|
|
324
|
+
</div>
|
|
325
|
+
<!-- End SandBox -->
|
|
326
|
+
</div>
|
|
327
|
+
</div>
|
|
328
|
+
</div>
|
|
329
|
+
<button
|
|
330
|
+
href="https://github.com/CoCreate-app/CoCreate-state/tree/master/docs/index.html?message=docs%3A%20describe%20your%20change..."
|
|
331
|
+
target="_blank"
|
|
332
|
+
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)">
|
|
333
|
+
<i src="../assets/svg/pencil-alt.svg"></i>
|
|
334
|
+
</button>
|
|
335
|
+
</main>
|
|
331
336
|
|
|
332
|
-
|
|
333
|
-
|
|
337
|
+
<script src="https://CoCreate.app/dist/CoCreate.js"></script>
|
|
338
|
+
</body>
|
|
334
339
|
</html>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/state",
|
|
3
|
-
"version": "1.24.
|
|
3
|
+
"version": "1.24.3",
|
|
4
4
|
"description": "Data attributes which can be used for components in CoCreate framework combined as a group of attributes that dynamically change attributes & fetch custom data.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"state",
|
|
@@ -45,24 +45,20 @@
|
|
|
45
45
|
},
|
|
46
46
|
"main": "./src/index.js",
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"clean-webpack-plugin": "^3.0.0",
|
|
52
|
-
"file-loader": "^6.2.0",
|
|
48
|
+
"css-loader": "^5.1.3",
|
|
49
|
+
"esbuild": "^0.25.2",
|
|
50
|
+
"esbuild-loader": "^4.3.0",
|
|
53
51
|
"mini-css-extract-plugin": "^1.5.0",
|
|
54
|
-
"style-loader": "^3.3.1",
|
|
55
|
-
"terser-webpack-plugin": "^5.1.1",
|
|
56
52
|
"webpack": "^5.24.4",
|
|
57
53
|
"webpack-cli": "^4.5.0",
|
|
58
54
|
"webpack-log": "^3.0.1"
|
|
59
55
|
},
|
|
60
56
|
"dependencies": {
|
|
61
|
-
"@cocreate/actions": "^1.
|
|
62
|
-
"@cocreate/crud-client": "^1.
|
|
63
|
-
"@cocreate/element-prototype": "^1.
|
|
64
|
-
"@cocreate/local-storage": "^1.
|
|
65
|
-
"@cocreate/observer": "^1.
|
|
66
|
-
"@cocreate/uuid": "^1.
|
|
57
|
+
"@cocreate/actions": "^1.21.0",
|
|
58
|
+
"@cocreate/crud-client": "^1.34.1",
|
|
59
|
+
"@cocreate/element-prototype": "^1.29.0",
|
|
60
|
+
"@cocreate/local-storage": "^1.16.1",
|
|
61
|
+
"@cocreate/observer": "^1.18.0",
|
|
62
|
+
"@cocreate/uuid": "^1.12.0"
|
|
67
63
|
}
|
|
68
64
|
}
|
package/src/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "@cocreate/element-prototype";
|
|
2
|
-
import
|
|
3
|
-
import
|
|
2
|
+
import Observer from "@cocreate/observer";
|
|
3
|
+
import Action from "@cocreate/actions";
|
|
4
4
|
import uid from "@cocreate/uuid";
|
|
5
5
|
import localStorage from "@cocreate/local-storage";
|
|
6
6
|
|
|
@@ -8,7 +8,7 @@ function init() {
|
|
|
8
8
|
let elements = document.querySelectorAll("[state_id]");
|
|
9
9
|
initElements(elements);
|
|
10
10
|
window.addEventListener("storage", function (e) {
|
|
11
|
-
if (e.key == "
|
|
11
|
+
if (e.key == "state") {
|
|
12
12
|
elements = document.querySelectorAll(
|
|
13
13
|
'[state_id]:not([state-onstoragechange="false"])'
|
|
14
14
|
);
|
|
@@ -32,7 +32,7 @@ function initElement(element) {
|
|
|
32
32
|
let state_id = element.getAttribute("state_id");
|
|
33
33
|
if (!state_id) return;
|
|
34
34
|
|
|
35
|
-
let statedAttributes = localStorage.getItem("
|
|
35
|
+
let statedAttributes = localStorage.getItem("state");
|
|
36
36
|
|
|
37
37
|
if (!statedAttributes || statedAttributes.length == 0) return;
|
|
38
38
|
statedAttributes = JSON.parse(statedAttributes);
|
|
@@ -104,17 +104,14 @@ async function _setAttributeValue(element, attribute, value, isOverwrite) {
|
|
|
104
104
|
async function stateAttributes(element) {
|
|
105
105
|
let statedAttributes = {};
|
|
106
106
|
try {
|
|
107
|
-
const storedAttributes = localStorage.getItem("
|
|
107
|
+
const storedAttributes = localStorage.getItem("state");
|
|
108
108
|
if (storedAttributes) {
|
|
109
109
|
statedAttributes = JSON.parse(storedAttributes);
|
|
110
110
|
}
|
|
111
111
|
} catch (error) {
|
|
112
|
-
console.error(
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
);
|
|
116
|
-
// Optionally reset `statedAttributes` in localStorage to ensure valid data:
|
|
117
|
-
localStorage.setItem("statedAttributes", JSON.stringify({}));
|
|
112
|
+
console.error("Failed to parse state from localStorage:", error);
|
|
113
|
+
// Optionally reset `state` in localStorage to ensure valid data:
|
|
114
|
+
localStorage.setItem("state", JSON.stringify({}));
|
|
118
115
|
}
|
|
119
116
|
let elements = [];
|
|
120
117
|
|
|
@@ -159,10 +156,9 @@ async function stateAttributes(element) {
|
|
|
159
156
|
);
|
|
160
157
|
}
|
|
161
158
|
|
|
162
|
-
if (!changeState)
|
|
163
|
-
localStorage.setItem("statedAttributes", statedAttributes);
|
|
159
|
+
if (!changeState) localStorage.setItem("state", statedAttributes);
|
|
164
160
|
|
|
165
|
-
|
|
161
|
+
element.dispatchEvent(
|
|
166
162
|
new CustomEvent("stateEnd", {
|
|
167
163
|
detail: {}
|
|
168
164
|
})
|
|
@@ -205,14 +201,14 @@ function _getStateId(attrValues, state_to) {
|
|
|
205
201
|
|
|
206
202
|
window.onload = function () {
|
|
207
203
|
if (!history.length) {
|
|
208
|
-
const statedAttributes = localStorage.getItem("
|
|
204
|
+
const statedAttributes = localStorage.getItem("state") || "";
|
|
209
205
|
history.replaceState(
|
|
210
206
|
{ statedAttributes, url: location.href, title: document.title },
|
|
211
207
|
document.title,
|
|
212
208
|
location.href
|
|
213
209
|
);
|
|
214
210
|
} else if (!history.state || history.state.url !== location.href) {
|
|
215
|
-
const statedAttributes = localStorage.getItem("
|
|
211
|
+
const statedAttributes = localStorage.getItem("state") || "";
|
|
216
212
|
history.pushState(
|
|
217
213
|
{ statedAttributes, url: location.href, title: document.title },
|
|
218
214
|
document.title,
|
|
@@ -224,10 +220,7 @@ window.onload = function () {
|
|
|
224
220
|
window.addEventListener("popstate", function (event) {
|
|
225
221
|
if (event.state) {
|
|
226
222
|
if (event.state.statedAttributes) {
|
|
227
|
-
localStorage.setItem(
|
|
228
|
-
"statedAttributes",
|
|
229
|
-
event.state.statedAttributes
|
|
230
|
-
);
|
|
223
|
+
localStorage.setItem("state", event.state.statedAttributes);
|
|
231
224
|
let elements = document.querySelectorAll("[state_id]");
|
|
232
225
|
initElements(elements);
|
|
233
226
|
}
|
|
@@ -243,20 +236,20 @@ window.addEventListener("popstate", function (event) {
|
|
|
243
236
|
}
|
|
244
237
|
});
|
|
245
238
|
|
|
246
|
-
|
|
239
|
+
Observer.init({
|
|
247
240
|
name: "CoCreateState",
|
|
248
|
-
|
|
241
|
+
types: ["addedNodes"],
|
|
249
242
|
selector: "[state_id]",
|
|
250
243
|
callback: function (mutation) {
|
|
251
244
|
initElement(mutation.target);
|
|
252
245
|
}
|
|
253
246
|
});
|
|
254
247
|
|
|
255
|
-
|
|
248
|
+
Action.init({
|
|
256
249
|
name: "state",
|
|
257
250
|
endEvent: "stateEnd",
|
|
258
|
-
callback: (
|
|
259
|
-
stateAttributes(
|
|
251
|
+
callback: (action) => {
|
|
252
|
+
stateAttributes(action.element);
|
|
260
253
|
}
|
|
261
254
|
});
|
|
262
255
|
|
package/webpack.config.js
CHANGED
|
@@ -1,90 +1,65 @@
|
|
|
1
|
-
const path = require("path")
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
const {
|
|
5
|
-
|
|
6
|
-
module.exports = (env, argv) => {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
parallel: true,
|
|
67
|
-
// sourceMap: true, // Must be set to true if using source-maps in production
|
|
68
|
-
terserOptions: {
|
|
69
|
-
// https://github.com/webpack-contrib/terser-webpack-plugin#terseroptions
|
|
70
|
-
// extractComments: 'all',
|
|
71
|
-
compress: {
|
|
72
|
-
drop_console: true,
|
|
73
|
-
},
|
|
74
|
-
},
|
|
75
|
-
}),
|
|
76
|
-
],
|
|
77
|
-
splitChunks: {
|
|
78
|
-
chunks: "all",
|
|
79
|
-
minSize: 200,
|
|
80
|
-
// maxSize: 99999,
|
|
81
|
-
//minChunks: 1,
|
|
82
|
-
|
|
83
|
-
cacheGroups: {
|
|
84
|
-
defaultVendors: false,
|
|
85
|
-
},
|
|
86
|
-
},
|
|
87
|
-
},
|
|
88
|
-
}
|
|
89
|
-
return config
|
|
90
|
-
}
|
|
1
|
+
const path = require("path");
|
|
2
|
+
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
|
3
|
+
const { EsbuildPlugin } = require("esbuild-loader");
|
|
4
|
+
const { FileUploader } = require("@cocreate/webpack");
|
|
5
|
+
|
|
6
|
+
module.exports = async (env, argv) => {
|
|
7
|
+
const isProduction = argv && argv.mode === "production";
|
|
8
|
+
const config = {
|
|
9
|
+
entry: {
|
|
10
|
+
"CoCreate-state": "./src/index.js"
|
|
11
|
+
},
|
|
12
|
+
output: {
|
|
13
|
+
path: path.resolve(__dirname, "dist"),
|
|
14
|
+
filename: isProduction ? "[name].min.js" : "[name].js",
|
|
15
|
+
libraryExport: "default",
|
|
16
|
+
library: ["CoCreate", "state"],
|
|
17
|
+
clean: true
|
|
18
|
+
},
|
|
19
|
+
plugins: [
|
|
20
|
+
new MiniCssExtractPlugin({
|
|
21
|
+
filename: isProduction ? "[name].min.css" : "[name].css"
|
|
22
|
+
}),
|
|
23
|
+
new FileUploader(env, argv)
|
|
24
|
+
],
|
|
25
|
+
mode: isProduction ? "production" : "development",
|
|
26
|
+
devtool: isProduction ? "source-map" : "eval-source-map",
|
|
27
|
+
module: {
|
|
28
|
+
rules: [
|
|
29
|
+
{
|
|
30
|
+
test: /.js$/,
|
|
31
|
+
exclude: /node_modules/,
|
|
32
|
+
use: {
|
|
33
|
+
loader: "esbuild-loader",
|
|
34
|
+
options: {
|
|
35
|
+
loader: "js",
|
|
36
|
+
target: "es2017"
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
test: /.css$/i,
|
|
42
|
+
use: [MiniCssExtractPlugin.loader, "css-loader"]
|
|
43
|
+
}
|
|
44
|
+
]
|
|
45
|
+
},
|
|
46
|
+
optimization: {
|
|
47
|
+
minimize: isProduction,
|
|
48
|
+
minimizer: [
|
|
49
|
+
new EsbuildPlugin({
|
|
50
|
+
target: "es2017",
|
|
51
|
+
css: true
|
|
52
|
+
})
|
|
53
|
+
],
|
|
54
|
+
splitChunks: {
|
|
55
|
+
cacheGroups: {
|
|
56
|
+
defaultVendors: false
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
performance: {
|
|
61
|
+
hints: isProduction ? "warning" : false
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
return config;
|
|
65
|
+
};
|