@cocreate/events 1.23.0 → 1.24.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,23 @@
1
+ # [1.24.0](https://github.com/CoCreate-app/CoCreate-events/compare/v1.23.0...v1.24.0) (2024-11-04)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * check for value attibutes has empty string indicating that the a value attribute exists and that the value will not be retrieved using getValue() ([c79a0b3](https://github.com/CoCreate-app/CoCreate-events/commit/c79a0b338378b46613e9ba3b5b98c71e040ecbc7))
7
+ * if events ([afaf496](https://github.com/CoCreate-app/CoCreate-events/commit/afaf496cf01eb6a013e050952a08a530d5e63e67))
8
+ * observer taget has been renamed to selector ([fae2134](https://github.com/CoCreate-app/CoCreate-events/commit/fae2134873fea89480a7c28920d4277691d7109a))
9
+ * pretier.config.js and file formating ([f31afac](https://github.com/CoCreate-app/CoCreate-events/commit/f31afac19f6e4875866f6e090e2aa861a453639c))
10
+ * selected group handling ([975008a](https://github.com/CoCreate-app/CoCreate-events/commit/975008a568f8983772a76ae843298fb5cfcc807c))
11
+ * temporarily commented checking for parent events ([09d0394](https://github.com/CoCreate-app/CoCreate-events/commit/09d0394b946306862153ca5164b08e1440cbbb63))
12
+
13
+
14
+ ### Features
15
+
16
+ * add prettier.config.js and format files ([558b874](https://github.com/CoCreate-app/CoCreate-events/commit/558b8748cb2ba34d479680acb1c25f359283d817))
17
+ * add prettier.config.js and format files ([9920bd7](https://github.com/CoCreate-app/CoCreate-events/commit/9920bd7ebe78ddeb41524377307b08b6271f45b8))
18
+ * handle action and replace ([25fc93c](https://github.com/CoCreate-app/CoCreate-events/commit/25fc93cc8846a4571903e556ec16acd9acf74be1))
19
+ * improved gropu support ([a4b10f8](https://github.com/CoCreate-app/CoCreate-events/commit/a4b10f82a4fbefb42d08346a72bd4731d3c8b71c))
20
+
1
21
  # [1.23.0](https://github.com/CoCreate-app/CoCreate-events/compare/v1.22.1...v1.23.0) (2024-09-21)
2
22
 
3
23
 
package/docs/index.html CHANGED
@@ -1,173 +1,181 @@
1
1
  <!DOCTYPE html>
2
2
  <html lang="en">
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-events 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="A simple HTML5 and pure javascript component. Easy configuration using HTML5 attributes or Javscript api and highly styleable." />
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/events.png" />
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-events Documentation | CoCreateJS</title>
8
+ <link
9
+ rel="icon"
10
+ type="image/png"
11
+ sizes="32x32"
12
+ href="https://cocreate.app/images/favicon.ico"
13
+ />
14
+ <meta
15
+ name="description"
16
+ content="A simple HTML5 and pure javascript component. Easy configuration using HTML5 attributes or Javscript api and highly styleable."
17
+ />
18
+ <meta
19
+ name="keywords"
20
+ content="helper classes, utility classes, css framework, css library, inline style classes"
21
+ />
22
+ <meta name="robots" content="index,follow" />
23
+ <meta
24
+ property="og:image"
25
+ content="https://cdn.cocreate.app/docs/events.png"
26
+ />
23
27
 
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>
28
+ <link
29
+ rel="stylesheet"
30
+ href="../index.css"
31
+ array="files"
32
+ object="60888216117c640e7596303f"
33
+ key="src"
34
+ type="text/css"
35
+ save="true"
36
+ />
37
+ <link rel="manifest" href="/manifest.webmanifest" />
38
+ </head>
34
39
 
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-selector="[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-events">
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-events</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="Enter decription here"
73
- share-title="testing im a title"
74
- share-height="600"
75
- share-width="700"
76
- share-media="https://cdn.cocreate.app/docs/events.png"
77
- hover="display:block!important"
78
- hover-selector=".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-events"
108
- target="_blank"
109
- class="margin-right:15px"
110
- ><i src="/assets/svg/github.svg"></i
111
- ></a>
112
- </div>
40
+ <body>
41
+ <!-- Navbar -->
42
+ <nav
43
+ class="width:100% display:flex align-items:center background:transparent padding-top:10px padding-bottom:10px"
44
+ content_id="content"
45
+ scroll="sticky-nav,"
46
+ scroll-up="5"
47
+ scroll-down="5"
48
+ path="../"
49
+ src="../components/navbar.html"
50
+ ></nav>
51
+ <sidenav
52
+ id="menuL"
53
+ class="position:fixed top:0px left:0px overflow:hidden background:whitesmoke height:100vh width:0px width:300px@xl"
54
+ resizable
55
+ resize-selector="[content_id='content']"
56
+ resize-property="margin-left"
57
+ resize-value="width"
58
+ >
59
+ <menu array="files" object="603717b07de7fb350ae9fec8" key="src"></menu>
60
+ <div resize="right"></div>
61
+ </sidenav>
62
+ <main
63
+ class="padding-top:15px padding:15px@lg@xl"
64
+ content_id="content"
65
+ id="cocreate-events"
66
+ >
67
+ <div
68
+ class="display:flex flex-wrap:wrap justify-content:space-between position:relative margin:10px"
69
+ >
70
+ <div class="display:flex align-items:center">
71
+ <h2>CoCreate-events</h2>
72
+ </div>
73
+ <div
74
+ class="display:flex align-items:center font-size:20px position:absolute right:0 padding:5px background:white"
75
+ >
76
+ <div
77
+ class="display:flex align-items:center transition:0.3s padding-left:10px"
78
+ share-network="true"
79
+ share-text="Enter decription here"
80
+ share-title="testing im a title"
81
+ share-height="600"
82
+ share-width="700"
83
+ share-media="https://cdn.cocreate.app/docs/events.png"
84
+ hover="display:block!important"
85
+ hover-selector=".social-networks"
86
+ >
87
+ <div class="display:none social-networks">
88
+ <a
89
+ class="margin-right:15px"
90
+ share-network="twitter"
91
+ title="Share on twitter"
92
+ ><i src="/assets/svg/twitter.svg"></i
93
+ ></a>
94
+ <a
95
+ class="margin-right:15px"
96
+ share-network="facebook"
97
+ title="Share on Facebook"
98
+ ><i src="/assets/svg/facebook.svg"></i
99
+ ></a>
100
+ <a
101
+ class="margin-right:15px"
102
+ share-network="instagram"
103
+ title="Share on instagram"
104
+ ><i src="/assets/svg/instagram.svg"></i
105
+ ></a>
113
106
  </div>
114
- <h1
115
- class="max-width:500px margin:20px_10px line-height:1.5 font-size:16px font-weight:100">
116
- It is used to change values in classes or specific attributes,
117
- its name describes its functionality events.
118
- </h1>
119
- <div id="events-section" class="display:flex flex-wrap:wrap">
120
- <div
121
- class="flex-grow:1 width:400px width:300px@xs padding:0px_10px margin-top:60px">
122
- <div
123
- id="events-install"
124
- class="border-bottom:1px_solid_lightgrey"
125
- scroll
126
- scroll-intersect="color:dodgerblue"
127
- scroll-selector="#events-install-section">
128
- <span
129
- class="display:flex align-items:center width:fit-content"
130
- hover="display:block!important"
131
- hover-selector="[href='#events-install']">
132
- <h2 class="padding:5px_0px">Install</h2>
133
- <a
134
- class="margin-left:10px display:none"
135
- href="#events-install"
136
- ><i src="/assets/svg/link.svg"></i
137
- ></a>
138
- </span>
139
- </div>
140
- <pre><code class="language-bash">npm i @cocreate/events</code></pre>
141
- <p class="padding:10px_0px line-height:1.5">
142
- Or you can use cdn link:
143
- </p>
144
- <pre><code class="language-html">&lt;script&gt;https://cdn.cocreate.app/events/latest/CoCreate-events.min.js&lt;/script&gt;</code></pre>
107
+ <a
108
+ class="margin-right:15px"
109
+ share-network="share"
110
+ title="Share on share"
111
+ ><i src="/assets/svg/share-alt.svg"></i
112
+ ></a>
113
+ </div>
114
+ <a
115
+ href="https://github.com/CoCreate-app/CoCreate-events"
116
+ target="_blank"
117
+ class="margin-right:15px"
118
+ ><i src="/assets/svg/github.svg"></i
119
+ ></a>
120
+ </div>
121
+ </div>
122
+ <h1
123
+ class="max-width:500px margin:20px_10px line-height:1.5 font-size:16px font-weight:100"
124
+ >
125
+ It is used to change values in classes or specific attributes, its name
126
+ describes its functionality events.
127
+ </h1>
128
+ <div id="events-section" class="display:flex flex-wrap:wrap">
129
+ <div
130
+ class="flex-grow:1 width:400px width:300px@xs padding:0px_10px margin-top:60px"
131
+ >
132
+ <div
133
+ id="events-install"
134
+ class="border-bottom:1px_solid_lightgrey"
135
+ scroll
136
+ scroll-intersect="color:dodgerblue"
137
+ scroll-selector="#events-install-section"
138
+ >
139
+ <span
140
+ class="display:flex align-items:center width:fit-content"
141
+ hover="display:block!important"
142
+ hover-selector="[href='#events-install']"
143
+ >
144
+ <h2 class="padding:5px_0px">Install</h2>
145
+ <a class="margin-left:10px display:none" href="#events-install"
146
+ ><i src="/assets/svg/link.svg"></i
147
+ ></a>
148
+ </span>
149
+ </div>
150
+ <pre><code class="language-bash">npm i @cocreate/events</code></pre>
151
+ <p class="padding:10px_0px line-height:1.5">
152
+ Or you can use cdn link:
153
+ </p>
154
+ <pre><code class="language-html">&lt;script&gt;https://cdn.cocreate.app/events/latest/CoCreate-events.min.js&lt;/script&gt;</code></pre>
145
155
 
146
- <div
147
- id="events-usage"
148
- class="margin-top:80px border-bottom:1px_solid_lightgrey"
149
- scroll
150
- scroll-intersect="color:dodgerblue"
151
- scroll-selector="#events-usage-section">
152
- <span
153
- class="display:flex align-items:center width:fit-content"
154
- hover="display:block!important"
155
- hover-selector="[href='#events-usage']">
156
- <h2 class="padding:5px_0px">Usage</h2>
157
- <a
158
- class="margin-left:10px display:none"
159
- href="#events-usage"
160
- ><i src="/assets/svg/link.svg"></i
161
- ></a>
162
- </span>
163
- </div>
164
- <div class="">
165
- <p class="padding:10px_0px line-height:1.5">
166
- This is events usage
167
- </p>
156
+ <div
157
+ id="events-usage"
158
+ class="margin-top:80px border-bottom:1px_solid_lightgrey"
159
+ scroll
160
+ scroll-intersect="color:dodgerblue"
161
+ scroll-selector="#events-usage-section"
162
+ >
163
+ <span
164
+ class="display:flex align-items:center width:fit-content"
165
+ hover="display:block!important"
166
+ hover-selector="[href='#events-usage']"
167
+ >
168
+ <h2 class="padding:5px_0px">Usage</h2>
169
+ <a class="margin-left:10px display:none" href="#events-usage"
170
+ ><i src="/assets/svg/link.svg"></i
171
+ ></a>
172
+ </span>
173
+ </div>
174
+ <div class="">
175
+ <p class="padding:10px_0px line-height:1.5">This is events usage</p>
168
176
 
169
- <div class="flex-grow:1 min-width:300px width:100%">
170
- <pre>
177
+ <div class="flex-grow:1 min-width:300px width:100%">
178
+ <pre>
171
179
  <code class="language-js">
172
180
  &#x3C;article&#x3E;
173
181
  &#x3C;div id=&#x22;div-01&#x22; class=&#x22;vdom-item&#x22;&#x3E;Here is div-01 i should get class hidden
@@ -191,206 +199,179 @@
191
199
  &#x3C;div class=&#x22;vdom-item&#x22; id=&#x22;hey&#x22; data-test=&#x22;&#x22; events-attribute=&#x27;data-test&#x27; events=&#x22;active, other, hi, jean&#x22; &#x3E;some content&#x3C;/div&#x3E;
192
200
  </code>
193
201
  </pre>
194
- </div>
195
- <p class="padding:10px_0px line-height:1.5">
196
- This is events usage
197
- </p>
198
- </div>
199
- <div
200
- id="events-attributes"
201
- class="margin-top:80px border-bottom:1px_solid_lightgrey"
202
- scroll
203
- scroll-intersect="color:dodgerblue"
204
- scroll-selector="#events-attributes-section">
205
- <span
206
- class="display:flex align-items:center width:fit-content"
207
- hover="display:block!important"
208
- hover-selector="[href='#events-attributes']">
209
- <h2 class="padding:5px_0px">Attributes</h2>
210
- <a
211
- class="margin-left:10px display:none"
212
- href="#events-attributes"
213
- ><i src="/assets/svg/link.svg"></i
214
- ></a>
215
- </span>
216
- </div>
217
- <ul class="list-style-type:none">
218
- <li
219
- class="padding:15px_0px border-bottom:1px_solid_lightgrey">
220
- <h4>
221
- <span>events</span>
222
- <span class="cocreate-badge success"
223
- >string</span
224
- >
225
- <span class="cocreate-badge danger"
226
- >required</span
227
- >
228
- </h4>
229
- <p>
230
- It is used to initialize the element, and this
231
- attribute is added to the specific attribute if
232
- it is defined, by default the class attribute is
233
- used
234
- </p>
235
- </li>
236
- <li
237
- class="padding:15px_0px border-bottom:1px_solid_lightgrey">
238
- <h4>
239
- <span>events-attribute</span>
240
- <span class="cocreate-badge success"
241
- >string</span
242
- >
243
- <span class="cocreate-badge warning"
244
- >optional</span
245
- >
246
- </h4>
247
- <p>
248
- Add or remove values, by default the class
249
- attribute is used
250
- </p>
251
- </li>
252
- <li
253
- class="padding:15px_0px border-bottom:1px_solid_lightgrey">
254
- <h4>
255
- <span>events-selector</span>
256
- <span class="cocreate-badge success"
257
- >string</span
258
- >
259
- <span class="cocreate-badge warning"
260
- >optional</span
261
- >
262
- </h4>
263
- <p>
264
- Apply events functionality to a specific element
265
- </p>
266
- </li>
267
- <li
268
- class="padding:15px_0px border-bottom:1px_solid_lightgrey">
269
- <h4>
270
- <span>events-closest</span>
271
- <span class="cocreate-badge success"
272
- >string</span
273
- >
274
- <span class="cocreate-badge warning"
275
- >optional</span
276
- >
277
- </h4>
278
- <p>
279
- Apply events functionality to a closset element
280
- </p>
281
- </li>
282
- </ul>
283
- </div>
202
+ </div>
203
+ <p class="padding:10px_0px line-height:1.5">This is events usage</p>
204
+ </div>
205
+ <div
206
+ id="events-attributes"
207
+ class="margin-top:80px border-bottom:1px_solid_lightgrey"
208
+ scroll
209
+ scroll-intersect="color:dodgerblue"
210
+ scroll-selector="#events-attributes-section"
211
+ >
212
+ <span
213
+ class="display:flex align-items:center width:fit-content"
214
+ hover="display:block!important"
215
+ hover-selector="[href='#events-attributes']"
216
+ >
217
+ <h2 class="padding:5px_0px">Attributes</h2>
218
+ <a class="margin-left:10px display:none" href="#events-attributes"
219
+ ><i src="/assets/svg/link.svg"></i
220
+ ></a>
221
+ </span>
222
+ </div>
223
+ <ul class="list-style-type:none">
224
+ <li class="padding:15px_0px border-bottom:1px_solid_lightgrey">
225
+ <h4>
226
+ <span>events</span>
227
+ <span class="cocreate-badge success">string</span>
228
+ <span class="cocreate-badge danger">required</span>
229
+ </h4>
230
+ <p>
231
+ It is used to initialize the element, and this attribute is
232
+ added to the specific attribute if it is defined, by default the
233
+ class attribute is used
234
+ </p>
235
+ </li>
236
+ <li class="padding:15px_0px border-bottom:1px_solid_lightgrey">
237
+ <h4>
238
+ <span>events-attribute</span>
239
+ <span class="cocreate-badge success">string</span>
240
+ <span class="cocreate-badge warning">optional</span>
241
+ </h4>
242
+ <p>
243
+ Add or remove values, by default the class attribute is used
244
+ </p>
245
+ </li>
246
+ <li class="padding:15px_0px border-bottom:1px_solid_lightgrey">
247
+ <h4>
248
+ <span>events-selector</span>
249
+ <span class="cocreate-badge success">string</span>
250
+ <span class="cocreate-badge warning">optional</span>
251
+ </h4>
252
+ <p>Apply events functionality to a specific element</p>
253
+ </li>
254
+ <li class="padding:15px_0px border-bottom:1px_solid_lightgrey">
255
+ <h4>
256
+ <span>events-closest</span>
257
+ <span class="cocreate-badge success">string</span>
258
+ <span class="cocreate-badge warning">optional</span>
259
+ </h4>
260
+ <p>Apply events functionality to a closset element</p>
261
+ </li>
262
+ </ul>
263
+ </div>
284
264
 
285
- <div
286
- class="flex-grow:1 width:300px padding:0px_10px margin-top:60px border-bottom:1px_solid_lightgrey">
287
- <!-- SandBox -->
288
- <div
289
- id="events-demo"
290
- class="border-bottom:1px_solid_lightgrey"
291
- scroll
292
- scroll-intersect="color:dodgerblue"
293
- scroll-selector="#events-demo-section">
294
- <span
295
- class="display:flex align-items:center width:fit-content"
296
- hover="display:block!important"
297
- hover-selector="[href='#events-demo']">
298
- <h2 class="padding:5px_0px">Demo</h2>
299
- <a
300
- class="margin-left:10px display:none"
301
- href="#events-demo"
302
- ><i src="/assets/svg/link.svg"></i
303
- ></a>
304
- </span>
305
- </div>
306
- <div
307
- class="position:sticky top:0 padding:15px_0px height:100vh">
308
- <!-- SandBox -->
309
- <div
310
- class="display:flex flex-direction:column position:relative overflow:hidden card border-radius:2px width:auto height:600px margin-top:20px"
311
- id="playground">
312
- <div
313
- id="demo-code"
314
- resizable
315
- class="position:relative height:50%">
316
- <textarea
317
- type="code"
318
- lang="html"
319
- array="demos"
320
- object=""
321
- key="demo"
322
- save="false"
323
- id="demo"
324
- class="height:100% width:100% outline:none border:none resize:none padding:5px"></textarea>
325
- <div
326
- resize="bottom"
327
- class="background:lightgrey"></div>
328
- </div>
265
+ <div
266
+ class="flex-grow:1 width:300px padding:0px_10px margin-top:60px border-bottom:1px_solid_lightgrey"
267
+ >
268
+ <!-- SandBox -->
269
+ <div
270
+ id="events-demo"
271
+ class="border-bottom:1px_solid_lightgrey"
272
+ scroll
273
+ scroll-intersect="color:dodgerblue"
274
+ scroll-selector="#events-demo-section"
275
+ >
276
+ <span
277
+ class="display:flex align-items:center width:fit-content"
278
+ hover="display:block!important"
279
+ hover-selector="[href='#events-demo']"
280
+ >
281
+ <h2 class="padding:5px_0px">Demo</h2>
282
+ <a class="margin-left:10px display:none" href="#events-demo"
283
+ ><i src="/assets/svg/link.svg"></i
284
+ ></a>
285
+ </span>
286
+ </div>
287
+ <div class="position:sticky top:0 padding:15px_0px height:100vh">
288
+ <!-- SandBox -->
289
+ <div
290
+ class="display:flex flex-direction:column position:relative overflow:hidden card border-radius:2px width:auto height:600px margin-top:20px"
291
+ id="playground"
292
+ >
293
+ <div
294
+ id="demo-code"
295
+ resizable
296
+ class="position:relative height:50%"
297
+ >
298
+ <textarea
299
+ type="code"
300
+ lang="html"
301
+ array="demos"
302
+ object=""
303
+ key="demo"
304
+ save="false"
305
+ id="demo"
306
+ class="height:100% width:100% outline:none border:none resize:none padding:5px"
307
+ ></textarea>
308
+ <div resize="bottom" class="background:lightgrey"></div>
309
+ </div>
329
310
 
330
- <div
331
- id="demo-preview"
332
- class="position:relative overflow:auto background-color:white">
333
- <div class="demopreview padding:20px"></div>
334
- </div>
311
+ <div
312
+ id="demo-preview"
313
+ class="position:relative overflow:auto background-color:white"
314
+ >
315
+ <div class="demopreview padding:20px"></div>
316
+ </div>
335
317
 
336
- <div
337
- class="font-size:20px position:absolute top:10px right:10px opacity:0.6">
338
- <a
339
- class="margin-right:10px"
340
- id="eye"
341
- show="#eye-slash"
342
- hide="#eye, #demo-preview"
343
- events="code-height"
344
- events-selector="#demo-code"
345
- ><i
346
- class="height:18px"
347
- src="/assets/svg/eye.svg"></i
348
- ></a>
349
- <a
350
- class="margin-right:10px"
351
- hidden
352
- id="eye-slash"
353
- show="#eye, #demo-preview"
354
- hide="#eye-slash"
355
- events="code-height"
356
- events-selector="#demo-code"
357
- ><i src="/assets/svg/eye-slash.svg"></i
358
- ></a>
359
- <a
360
- class="margin-right:10px"
361
- id="code"
362
- show="#code-slash"
363
- hide="#code, #demo-code"
364
- ><i src="/assets/svg/code.svg"></i
365
- ></a>
366
- <a
367
- class="margin-right:10px"
368
- hidden
369
- id="code-slash"
370
- show="#code, #demo-code"
371
- hide="#code-slash"
372
- ><i
373
- class="height:18px"
374
- src="/assets/svg/code.svg"></i
375
- ></a>
376
- <a
377
- class="margin-right:5px"
378
- fullscreen
379
- fullscreen-selector="#playground"></a>
380
- </div>
381
- </div>
382
- <!-- End SandBox -->
383
- </div>
384
- </div>
318
+ <div
319
+ class="font-size:20px position:absolute top:10px right:10px opacity:0.6"
320
+ >
321
+ <a
322
+ class="margin-right:10px"
323
+ id="eye"
324
+ show="#eye-slash"
325
+ hide="#eye, #demo-preview"
326
+ events="code-height"
327
+ events-selector="#demo-code"
328
+ ><i class="height:18px" src="/assets/svg/eye.svg"></i
329
+ ></a>
330
+ <a
331
+ class="margin-right:10px"
332
+ hidden
333
+ id="eye-slash"
334
+ show="#eye, #demo-preview"
335
+ hide="#eye-slash"
336
+ events="code-height"
337
+ events-selector="#demo-code"
338
+ ><i src="/assets/svg/eye-slash.svg"></i
339
+ ></a>
340
+ <a
341
+ class="margin-right:10px"
342
+ id="code"
343
+ show="#code-slash"
344
+ hide="#code, #demo-code"
345
+ ><i src="/assets/svg/code.svg"></i
346
+ ></a>
347
+ <a
348
+ class="margin-right:10px"
349
+ hidden
350
+ id="code-slash"
351
+ show="#code, #demo-code"
352
+ hide="#code-slash"
353
+ ><i class="height:18px" src="/assets/svg/code.svg"></i
354
+ ></a>
355
+ <a
356
+ class="margin-right:5px"
357
+ fullscreen
358
+ fullscreen-selector="#playground"
359
+ ></a>
360
+ </div>
385
361
  </div>
386
- <button
387
- href="https://github.com/CoCreate-app/CoCreate-events/tree/master/docs/index.html?message=docs%3A%20describe%20your%20change..."
388
- target="_blank"
389
- 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)">
390
- <i class="height:20px" src="../assets/svg/pencil-alt.svg"></i>
391
- </button>
392
- </main>
362
+ <!-- End SandBox -->
363
+ </div>
364
+ </div>
365
+ </div>
366
+ <button
367
+ href="https://github.com/CoCreate-app/CoCreate-events/tree/master/docs/index.html?message=docs%3A%20describe%20your%20change..."
368
+ target="_blank"
369
+ 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)"
370
+ >
371
+ <i src="../assets/svg/pencil-alt.svg"></i>
372
+ </button>
373
+ </main>
393
374
 
394
- <script src="https://CoCreate.app/dist/CoCreate.js"></script>
395
- </body>
375
+ <script src="https://CoCreate.app/dist/CoCreate.js"></script>
376
+ </body>
396
377
  </html>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/events",
3
- "version": "1.23.0",
3
+ "version": "1.24.0",
4
4
  "description": "A simple events component in vanilla javascript. Easily configured using HTML5 attributes and/or JavaScript API.",
5
5
  "keywords": [
6
6
  "events",
@@ -0,0 +1,16 @@
1
+ module.exports = {
2
+ tabWidth: 4,
3
+ semi: true,
4
+ trailingComma: "none",
5
+ bracketSameLine: true,
6
+ useTabs: true,
7
+ overrides: [
8
+ {
9
+ files: ["*.json", "*.yml", "*.yaml"],
10
+ options: {
11
+ tabWidth: 2,
12
+ useTabs: false
13
+ },
14
+ }
15
+ ],
16
+ };
package/src/index.js CHANGED
@@ -63,7 +63,7 @@ const CoCreateEvents = {
63
63
  observer.init({
64
64
  name: 'CoCreateEventName',
65
65
  observe: ['addedNodes'],
66
- target: `[event-name]`,
66
+ selector: `[event-name]`,
67
67
  callback: function (mutation) {
68
68
  let name = mutation.target.getAttribute('event-name')
69
69
  self.initPrefix(name);
@@ -89,13 +89,13 @@ const CoCreateEvents = {
89
89
  name: 'CoCreateEventattributes',
90
90
  observe: ['attributes', 'addedNodes'],
91
91
  attributeName: [`${prefix}-events`],
92
- target: selector,
92
+ selector: selector,
93
93
  callback: function (mutation) {
94
94
  self.initElements([mutation.target], prefix, events)
95
95
  }
96
96
  });
97
97
 
98
- if (events.includes('observer')) {
98
+ if (events && events.includes('observer')) {
99
99
  observer.init({
100
100
  name: 'observerAttributes',
101
101
  observe: ['attributes'],
@@ -157,7 +157,7 @@ const CoCreateEvents = {
157
157
  if (target)
158
158
  observer.init({
159
159
  observe: ['addedNodes'],
160
- target,
160
+ selector: target,
161
161
  callback: function (mutation) {
162
162
  self.__updateElements(el, prefix, mutation.target);
163
163
  }
@@ -201,20 +201,20 @@ const CoCreateEvents = {
201
201
  // return;
202
202
  self.__updateElements(target, prefix, null, prefixes[prefix].events);
203
203
 
204
- let selector = `[${prefix}], [${prefix}-key], [${prefix}-value], [${prefix}-selector], [${prefix}-closest], [${prefix}-parent], [${prefix}-next], [${prefix}-previous]`
204
+ // let selector = `[${prefix}], [${prefix}-key], [${prefix}-value], [${prefix}-selector], [${prefix}-closest], [${prefix}-parent], [${prefix}-next], [${prefix}-previous]`
205
205
 
206
- let parentElement = target.parentElement;
207
- if (parentElement) {
208
- do {
209
- parentElement = parentElement.closest(selector)
210
- if (parentElement) {
211
- self.__updateElements(parentElement, prefix, null, prefixes[prefix].events);
212
- parentElement = parentElement.parentElement
213
- }
214
- }
215
- while (parentElement)
206
+ // let parentElement = target.parentElement;
207
+ // if (parentElement) {
208
+ // do {
209
+ // parentElement = parentElement.closest(selector)
210
+ // if (parentElement) {
211
+ // self.__updateElements(parentElement, prefix, null, prefixes[prefix].events);
212
+ // parentElement = parentElement.parentElement
213
+ // }
214
+ // }
215
+ // while (parentElement)
216
216
 
217
- }
217
+ // }
218
218
 
219
219
  }
220
220
  // }, 500);
@@ -224,141 +224,156 @@ const CoCreateEvents = {
224
224
  }
225
225
  },
226
226
 
227
- __updateElements: async function (element, prefix, target, events) {
227
+ __updateElements: async function (el, prefix, target, events) {
228
228
  const self = this;
229
- // TODO: support empty value when prefix-attribute defined, add and remove the attribute
230
- let targetAttribute = element.getAttribute(`${prefix}-attribute`);
231
- let targetPosition = element.getAttribute(`${prefix}-insert-adjacent`);
232
- // targetAttribute = checkMediaQueries(targetAttribute)
233
- // if (targetAttribute === false)
234
- // return
235
-
236
- let onEvent = element.getAttribute(`${prefix}-on`)
237
- if (onEvent) {
238
- await new Promise((resolve, reject) => {
239
- const handleEvent = () => {
240
- document.removeEventListener(onEvent, handleEvent);
241
- resolve();
242
- };
243
- document.addEventListener(onEvent, handleEvent);
244
- });
229
+ let elements = [el]
230
+ let targetGroup = el.getAttribute(`${prefix}-group`);
231
+ if (targetGroup) {
232
+ document.querySelectorAll(`[${prefix}-group="${targetGroup}"]`).forEach((element) => {
233
+ if (element !== el)
234
+ elements.push(element)
235
+ })
245
236
  }
246
237
 
247
- let values
248
- if (prefix === 'localstorage') {
249
- let key = element.getAttribute('localstorage-get')
250
- if (key) {
251
- values = localStorage.getItem(key)
252
- } else if (key = element.getAttribute('localstorage-set')) {
253
- values = await element.getValue()
254
- if (values)
255
- localStorage.setItem(key, values)
238
+ for (let element of elements) {
239
+ // TODO: support empty value when prefix-attribute defined, add and remove the attribute
240
+ let targetAttribute = element.getAttribute(`${prefix}-attribute`);
241
+ let targetPosition = element.getAttribute(`${prefix}-insert-adjacent`);
242
+ // targetAttribute = checkMediaQueries(targetAttribute)
243
+ // if (targetAttribute === false)
244
+ // return
245
+
246
+ let onEvent = element.getAttribute(`${prefix}-on`)
247
+ if (onEvent) {
248
+ await new Promise((resolve, reject) => {
249
+ const handleEvent = () => {
250
+ document.removeEventListener(onEvent, handleEvent);
251
+ resolve();
252
+ };
253
+ document.addEventListener(onEvent, handleEvent);
254
+ });
256
255
  }
257
256
 
258
- // if (!key || !values)
259
- if (!key)
260
- return
261
- } else {
262
- values = element.getAttribute(`${prefix}-value`) || element.getAttribute(`${prefix}-if-value`) || element.getAttribute(prefix);
263
- }
257
+ let values
258
+ if (prefix === 'localstorage') {
259
+ let key = element.getAttribute('localstorage-get')
260
+ if (key) {
261
+ values = localStorage.getItem(key)
262
+ } else if (key = element.getAttribute('localstorage-set')) {
263
+ values = await element.getValue()
264
+ if (values)
265
+ localStorage.setItem(key, values)
266
+ }
264
267
 
265
- if (values) {
266
- if (typeof values === 'string')
267
- values = values.split(',');
268
- else if (!Array.isArray(values))
269
- values = [values]
270
- } else {
271
- values = await element.getValue()
272
- if (!Array.isArray(values))
273
- values = [values]
274
- }
268
+ // if (!key || !values)
269
+ if (!key)
270
+ return
271
+ } else {
275
272
 
276
- if (targetAttribute && !values || values.length === 0)
277
- return;
273
+ values = element.getAttribute(`${prefix}-value`)
278
274
 
279
- let ifCondition = element.getAttribute(`${prefix}-if`);
280
- let elseCondition = element.getAttribute(`${prefix}-else`);
275
+ if (values === null) {
276
+ let valueElements = queryElements({ element, prefix: `${prefix}-value` });
277
+ if (valueElements) {
278
+ let elementValues = []
279
+ for (let i = 0; i < valueElements.length; i++)
280
+ elementValues.push(valueElements[i].getValue())
281
281
 
282
- let ifValue = element.getAttribute(`${prefix}-if-value`)
283
- if (!ifValue && ifValue !== "")
284
- ifValue = await element.getValue() || values //values // await element.getValue()
285
- else if (ifValue || ifValue === "")
286
- ifValue = [ifValue]
287
- else
288
- ifValue = values
282
+ if (elementValues.length)
283
+ values = elementValues
284
+ }
285
+ }
289
286
 
290
- if (!Array.isArray(ifValue))
291
- ifValue = [ifValue]
287
+ if (values === null)
288
+ values = element.getAttribute(`${prefix}-if-value`)
289
+ if (values === null)
290
+ values = element.getAttribute(prefix);
292
291
 
293
- //TODO: improved resize toggling of values
294
- // let hasCondition = this.elements2.get(element)
295
- if (ifCondition && evaluateCondition(ifCondition, ifValue)) {
292
+ }
296
293
 
297
- // if (hasCondition && hasCondition.condition === ifCondition) {
298
- // return
299
- // } else
300
- // this.elements2.set(element, { condition: ifCondition })
301
- } else if (elseCondition && evaluateCondition(elseCondition, ifValue)) {
302
- // if (hasCondition && hasCondition.condition === elseCondition) {
303
- // return
304
- // } else
305
- // this.elements2.set(element, { condition: elseCondition })
306
- } else if (ifCondition || elseCondition) {
307
- return
308
- }
294
+ if (values || values === '') {
295
+ if (typeof values === 'string')
296
+ values = values.split(',');
297
+ else if (!Array.isArray(values))
298
+ values = [values]
299
+ } else {
300
+ values = await element.getValue()
301
+ if (!Array.isArray(values))
302
+ values = [values]
303
+ }
309
304
 
310
- let targetText = element.getAttribute(`${prefix}-text`);
311
- let targetHtml = element.getAttribute(`${prefix}-html`);
312
- let targetKey = element.getAttribute(`${prefix}-key`);
305
+ if (targetAttribute && !values || values.length === 0)
306
+ return;
313
307
 
314
- let targetGroup = element.getAttribute(`${prefix}-group`);
315
- if (targetGroup) {
316
- document.querySelectorAll(`[${prefix}-group="${targetGroup}"]`).forEach((el) => {
317
- let groupValue = el.getAttribute(`${prefix}-value`) || el.getAttribute(prefix);
318
- let groupValues = groupValue.split(',');
319
- if (!groupValues || groupValues.length == 0) {
320
- return;
321
- }
308
+ let ifCondition = element.getAttribute(`${prefix}-if`);
309
+ let elseCondition = element.getAttribute(`${prefix}-else`);
322
310
 
323
- groupValues = groupValues.map(x => x.trim());
324
- let groupAttribute = el.getAttribute(`${prefix}-attribute`) || 'class';
325
- let groupPosition = el.getAttribute(`${prefix}-insert-adjacent`);
326
- // groupAttribute = checkMediaQueries(groupAttribute)
327
- // if (!groupAttribute)
328
- // return
311
+ let ifValue = element.getAttribute(`${prefix}-if-value`)
312
+ if (!ifValue && ifValue !== "")
313
+ ifValue = await element.getValue() || values //values // await element.getValue()
314
+ else if (ifValue || ifValue === "")
315
+ ifValue = [ifValue]
316
+ else
317
+ ifValue = values
329
318
 
330
- let groupKey = el.getAttribute(`${prefix}-key`)
319
+ if (!Array.isArray(ifValue))
320
+ ifValue = [ifValue]
331
321
 
332
- // el.removeAttribute(prefix)
333
- self.setValue(prefix, el, groupAttribute, groupValues, groupKey, 'deactivate', events, groupPosition)
334
- let targetElements = queryElements({ el, prefix });
335
- for (let i = 0; i < targetElements.length; i++)
336
- self.setValue(prefix, targetElements[i], groupAttribute, groupValues, groupKey, 'deactivate', events, groupPosition)
322
+ //TODO: improved resize toggling of values
323
+ // let hasCondition = this.elements2.get(element)
324
+ if (ifCondition && evaluateCondition(ifCondition, ifValue)) {
337
325
 
338
- });
339
- }
326
+ // if (hasCondition && hasCondition.condition === ifCondition) {
327
+ // return
328
+ // } else
329
+ // this.elements2.set(element, { condition: ifCondition })
330
+ } else if (elseCondition && evaluateCondition(elseCondition, ifValue)) {
331
+ // if (hasCondition && hasCondition.condition === elseCondition) {
332
+ // return
333
+ // } else
334
+ // this.elements2.set(element, { condition: elseCondition })
335
+ } else if (ifCondition || elseCondition) {
336
+ return
337
+ }
340
338
 
341
- // values = values.map(x => x.trim());
339
+ let targetText = element.getAttribute(`${prefix}-text`);
340
+ let targetHtml = element.getAttribute(`${prefix}-html`);
341
+ let targetKey = element.getAttribute(`${prefix}-key`);
342
342
 
343
- values = values.map(x => {
344
- if (typeof x === 'string')
345
- x = x.trim(); // Update x with the trimmed value
346
- let prop = element.getAttribute(`${prefix}-property`);
347
- if (prop) {
348
- x = `${prop}:${x}`; // Update x with prop if it exists
343
+ if (prefix === 'selected') {
344
+ if (el !== element)
345
+ element.removeAttribute('selected')
346
+ else
347
+ element.setAttribute('selected', '')
349
348
  }
350
- return x; // Return the updated x
351
- });
352
349
 
353
- let targetElements = queryElements({ element, prefix });
354
- if (targetElements === false)
355
- targetElements = [element]
350
+ let deactivate = false
351
+ if (el !== element)
352
+ deactivate = true
353
+ // values = values.map(x => x.trim());
354
+
355
+ values = values.map(x => {
356
+ if (typeof x === 'string')
357
+ x = x.trim(); // Update x with the trimmed value
358
+ let prop = element.getAttribute(`${prefix}-property`);
359
+ if (prop) {
360
+ x = `${prop}:${x}`; // Update x with prop if it exists
361
+ }
362
+ return x; // Return the updated x
363
+ });
356
364
 
357
- for (let i = 0; i < targetElements.length; i++) {
358
- if (!targetAttribute && targetAttribute !== '' && ['click', 'focus', 'blur'].includes(prefix)) {
359
- targetElements[i][prefix]()
360
- } else {
361
- this.setValue(prefix, targetElements[i], targetAttribute, values, targetKey, null, events, targetPosition)
365
+ let targetElements = queryElements({ element, prefix });
366
+ if (targetElements === false)
367
+ targetElements = [element]
368
+ let action = element.getAttribute(`${prefix}-action`)
369
+ for (let i = 0; i < targetElements.length; i++) {
370
+ if (action) {
371
+ targetElements[i][action]()
372
+ } else if (!targetAttribute && targetAttribute !== '' && ['click', 'focus', 'blur'].includes(prefix)) {
373
+ targetElements[i][prefix]()
374
+ } else {
375
+ this.setValue(prefix, targetElements[i], targetAttribute, values, targetKey, deactivate, events, targetPosition)
376
+ }
362
377
  }
363
378
  }
364
379
 
@@ -409,13 +424,7 @@ const CoCreateEvents = {
409
424
  } else {
410
425
  if (attrName === 'value') {
411
426
  oldValue = await element.getValue()
412
- } else if (attrName === 'text') {
413
- attrValues = element.getAttribute(attrName).split(' ').map(x => x.trim());
414
- oldValue = values.filter(x => attrValues.includes(x))[0] || '';
415
- } else if (attrName === 'html') {
416
- attrValues = element.getAttribute(attrName).split(' ').map(x => x.trim());
417
- oldValue = values.filter(x => attrValues.includes(x))[0] || '';
418
- } else if (element.getAttribute(attrName)) {
427
+ } else if (attrName === 'text' || attrName === 'html' || element.getAttribute(attrName)) {
419
428
  attrValues = element.getAttribute(attrName).split(' ').map(x => x.trim());
420
429
  oldValue = values.filter(x => attrValues.includes(x))[0] || '';
421
430
  }
@@ -436,12 +445,20 @@ const CoCreateEvents = {
436
445
  }
437
446
  } else if (attrName === 'value') {
438
447
  element.setValue(newValue);
439
- } else if (['$click', '$focus', '$blur'].includes(attrName)) {
448
+ } else if (['$click', '$focus', '$blur', '$save', '$read'].includes(attrName)) {
440
449
  element[attrName.substring(1)]()
441
450
  } else if (attrName) {
442
- element.setAttribute(attrName, newValue);
451
+ // TODO: removeAttribute vs setting empty value, how best to define. operator $remove ???
452
+ if (newValue === '' && element.hasAttribute(attrName))
453
+ element.removeAttribute(attrName);
454
+ else
455
+ element.setAttribute(attrName, newValue);
443
456
  } else if (targetPosition) {
444
- element.insertAdjacentHTML(targetPosition, newValue);
457
+ if (targetPosition === 'replace') {
458
+ element.insertAdjacentHTML('beforebegin', newValue); // Insert before oldElement
459
+ element.remove(); // Remove oldElement
460
+ } else
461
+ element.insertAdjacentHTML(targetPosition, newValue);
445
462
  } else {
446
463
  if (!attrName && ['click', 'focus', 'blur'].includes(newValue)) {
447
464
  element[newValue]()
@@ -627,7 +644,9 @@ function checkCondition(condition, value) {
627
644
  result = value === condition;
628
645
  }
629
646
 
630
- return isNegated ? !result : result;
647
+ result = isNegated ? !result : result;
648
+ return result
649
+
631
650
  }
632
651
 
633
652
  function parseCondition(condition) {