@cocreate/events 1.22.1 → 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,35 @@
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
+
21
+ # [1.23.0](https://github.com/CoCreate-app/CoCreate-events/compare/v1.22.1...v1.23.0) (2024-09-21)
22
+
23
+
24
+ ### Bug Fixes
25
+
26
+ * observer-target attribute ([92593d3](https://github.com/CoCreate-app/CoCreate-events/commit/92593d32c4b53fe97dab511e44dd1c9f345d708e))
27
+
28
+
29
+ ### Features
30
+
31
+ * *-insert-adjacent attribute to apply value using insertAdjacentHTML() ([3d2151d](https://github.com/CoCreate-app/CoCreate-events/commit/3d2151d91d56ad53df006343e4f18b3aa1a99b1d))
32
+
1
33
  ## [1.22.1](https://github.com/CoCreate-app/CoCreate-events/compare/v1.22.0...v1.22.1) (2024-08-24)
2
34
 
3
35
 
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.22.1",
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'],
@@ -146,7 +146,10 @@ const CoCreateEvents = {
146
146
  if (events.includes('observer')) {
147
147
  let target;
148
148
  for (let attribute of el.attributes) {
149
- if ([`${prefix}-selector`, `${prefix}-closest`, `${prefix}-parent`, `${prefix}-next`, `${prefix}-previous`].includes(attribute.name)) {
149
+ if (attribute.name === 'observe-target') {
150
+ target = attribute.value
151
+ break;
152
+ } else if ([`${prefix}-selector`, `${prefix}-closest`, `${prefix}-parent`, `${prefix}-next`, `${prefix}-previous`].includes(attribute.name)) {
150
153
  target = attribute.value
151
154
  break;
152
155
  }
@@ -154,7 +157,7 @@ const CoCreateEvents = {
154
157
  if (target)
155
158
  observer.init({
156
159
  observe: ['addedNodes'],
157
- target,
160
+ selector: target,
158
161
  callback: function (mutation) {
159
162
  self.__updateElements(el, prefix, mutation.target);
160
163
  }
@@ -198,20 +201,20 @@ const CoCreateEvents = {
198
201
  // return;
199
202
  self.__updateElements(target, prefix, null, prefixes[prefix].events);
200
203
 
201
- 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]`
202
205
 
203
- let parentElement = target.parentElement;
204
- if (parentElement) {
205
- do {
206
- parentElement = parentElement.closest(selector)
207
- if (parentElement) {
208
- self.__updateElements(parentElement, prefix, null, prefixes[prefix].events);
209
- parentElement = parentElement.parentElement
210
- }
211
- }
212
- 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)
213
216
 
214
- }
217
+ // }
215
218
 
216
219
  }
217
220
  // }, 500);
@@ -221,139 +224,157 @@ const CoCreateEvents = {
221
224
  }
222
225
  },
223
226
 
224
- __updateElements: async function (element, prefix, target, events) {
227
+ __updateElements: async function (el, prefix, target, events) {
225
228
  const self = this;
226
- // TODO: support empty value when prefix-attribute defined, add and remove the attribute
227
- let targetAttribute = element.getAttribute(`${prefix}-attribute`);
228
- // targetAttribute = checkMediaQueries(targetAttribute)
229
- // if (targetAttribute === false)
230
- // return
231
-
232
- let onEvent = element.getAttribute(`${prefix}-on`)
233
- if (onEvent) {
234
- await new Promise((resolve, reject) => {
235
- const handleEvent = () => {
236
- document.removeEventListener(onEvent, handleEvent);
237
- resolve();
238
- };
239
- document.addEventListener(onEvent, handleEvent);
240
- });
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
+ })
241
236
  }
242
237
 
243
- let values
244
- if (prefix === 'localstorage') {
245
- let key = element.getAttribute('localstorage-get')
246
- if (key) {
247
- values = localStorage.getItem(key)
248
- } else if (key = element.getAttribute('localstorage-set')) {
249
- values = await element.getValue()
250
- if (values)
251
- 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
+ });
252
255
  }
253
256
 
254
- // if (!key || !values)
255
- if (!key)
256
- return
257
- } else {
258
- values = element.getAttribute(`${prefix}-value`) || element.getAttribute(`${prefix}-if-value`) || element.getAttribute(prefix);
259
- }
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
+ }
260
267
 
261
- if (values) {
262
- if (typeof values === 'string')
263
- values = values.split(',');
264
- else if (!Array.isArray(values))
265
- values = [values]
266
- } else {
267
- values = await element.getValue()
268
- if (!Array.isArray(values))
269
- values = [values]
270
- }
268
+ // if (!key || !values)
269
+ if (!key)
270
+ return
271
+ } else {
271
272
 
272
- if (targetAttribute && !values || values.length === 0)
273
- return;
273
+ values = element.getAttribute(`${prefix}-value`)
274
274
 
275
- let ifCondition = element.getAttribute(`${prefix}-if`);
276
- 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())
277
281
 
278
- let ifValue = element.getAttribute(`${prefix}-if-value`)
279
- if (!ifValue && ifValue !== "")
280
- ifValue = await element.getValue() || values //values // await element.getValue()
281
- else if (ifValue || ifValue === "")
282
- ifValue = [ifValue]
283
- else
284
- ifValue = values
282
+ if (elementValues.length)
283
+ values = elementValues
284
+ }
285
+ }
285
286
 
286
- if (!Array.isArray(ifValue))
287
- ifValue = [ifValue]
287
+ if (values === null)
288
+ values = element.getAttribute(`${prefix}-if-value`)
289
+ if (values === null)
290
+ values = element.getAttribute(prefix);
288
291
 
289
- //TODO: improved resize toggling of values
290
- // let hasCondition = this.elements2.get(element)
291
- if (ifCondition && evaluateCondition(ifCondition, ifValue)) {
292
+ }
292
293
 
293
- // if (hasCondition && hasCondition.condition === ifCondition) {
294
- // return
295
- // } else
296
- // this.elements2.set(element, { condition: ifCondition })
297
- } else if (elseCondition && evaluateCondition(elseCondition, ifValue)) {
298
- // if (hasCondition && hasCondition.condition === elseCondition) {
299
- // return
300
- // } else
301
- // this.elements2.set(element, { condition: elseCondition })
302
- } else if (ifCondition || elseCondition) {
303
- return
304
- }
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
+ }
305
304
 
306
- let targetText = element.getAttribute(`${prefix}-text`);
307
- let targetHtml = element.getAttribute(`${prefix}-html`);
308
- let targetKey = element.getAttribute(`${prefix}-key`);
305
+ if (targetAttribute && !values || values.length === 0)
306
+ return;
309
307
 
310
- let targetGroup = element.getAttribute(`${prefix}-group`);
311
- if (targetGroup) {
312
- document.querySelectorAll(`[${prefix}-group="${targetGroup}"]`).forEach((el) => {
313
- let groupValue = el.getAttribute(`${prefix}-value`) || el.getAttribute(prefix);
314
- let groupValues = groupValue.split(',');
315
- if (!groupValues || groupValues.length == 0) {
316
- return;
317
- }
308
+ let ifCondition = element.getAttribute(`${prefix}-if`);
309
+ let elseCondition = element.getAttribute(`${prefix}-else`);
318
310
 
319
- groupValues = groupValues.map(x => x.trim());
320
- let groupAttribute = el.getAttribute(`${prefix}-attribute`) || 'class';
321
- // groupAttribute = checkMediaQueries(groupAttribute)
322
- // if (!groupAttribute)
323
- // 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
324
318
 
325
- let groupKey = el.getAttribute(`${prefix}-key`)
319
+ if (!Array.isArray(ifValue))
320
+ ifValue = [ifValue]
326
321
 
327
- // el.removeAttribute(prefix)
328
- self.setValue(prefix, el, groupAttribute, groupValues, groupKey, 'deactivate', events)
329
- let targetElements = queryElements({ el, prefix });
330
- for (let i = 0; i < targetElements.length; i++)
331
- self.setValue(prefix, targetElements[i], groupAttribute, groupValues, groupKey, 'deactivate', events)
322
+ //TODO: improved resize toggling of values
323
+ // let hasCondition = this.elements2.get(element)
324
+ if (ifCondition && evaluateCondition(ifCondition, ifValue)) {
332
325
 
333
- });
334
- }
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
+ }
335
338
 
336
- // 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`);
337
342
 
338
- values = values.map(x => {
339
- if (typeof x === 'string')
340
- x = x.trim(); // Update x with the trimmed value
341
- let prop = element.getAttribute(`${prefix}-property`);
342
- if (prop) {
343
- 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', '')
344
348
  }
345
- return x; // Return the updated x
346
- });
347
349
 
348
- let targetElements = queryElements({ element, prefix });
349
- if (targetElements === false)
350
- 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
+ });
351
364
 
352
- for (let i = 0; i < targetElements.length; i++) {
353
- if (!targetAttribute && targetAttribute !== '' && ['click', 'focus', 'blur'].includes(prefix)) {
354
- targetElements[i][prefix]()
355
- } else
356
- this.setValue(prefix, targetElements[i], targetAttribute, values, targetKey, null, events)
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
+ }
377
+ }
357
378
  }
358
379
 
359
380
  document.dispatchEvent(new CustomEvent(`${prefix}End`, {
@@ -362,11 +383,11 @@ const CoCreateEvents = {
362
383
 
363
384
  },
364
385
 
365
- setValue: async function (prefix, element, attrName, values, key, deactivate, events) {
386
+ setValue: async function (prefix, element, attrName, values, key, deactivate, events, targetPosition) {
366
387
  if (events && events.includes('mouseout')) {
367
388
  if (element.matches(':hover')) {
368
389
  element.addEventListener('mouseout', () => {
369
- this.setValue(prefix, element, attrName, values, key, deactivate, events);
390
+ this.setValue(prefix, element, attrName, values, key, deactivate, events, targetPosition);
370
391
  }, { once: true });
371
392
  return;
372
393
  }
@@ -403,13 +424,7 @@ const CoCreateEvents = {
403
424
  } else {
404
425
  if (attrName === 'value') {
405
426
  oldValue = await element.getValue()
406
- } else if (attrName === 'text') {
407
- attrValues = element.getAttribute(attrName).split(' ').map(x => x.trim());
408
- oldValue = values.filter(x => attrValues.includes(x))[0] || '';
409
- } else if (attrName === 'html') {
410
- attrValues = element.getAttribute(attrName).split(' ').map(x => x.trim());
411
- oldValue = values.filter(x => attrValues.includes(x))[0] || '';
412
- } else if (element.getAttribute(attrName)) {
427
+ } else if (attrName === 'text' || attrName === 'html' || element.getAttribute(attrName)) {
413
428
  attrValues = element.getAttribute(attrName).split(' ').map(x => x.trim());
414
429
  oldValue = values.filter(x => attrValues.includes(x))[0] || '';
415
430
  }
@@ -430,19 +445,27 @@ const CoCreateEvents = {
430
445
  }
431
446
  } else if (attrName === 'value') {
432
447
  element.setValue(newValue);
433
- } else if (['$click', '$focus', '$blur'].includes(attrName)) {
448
+ } else if (['$click', '$focus', '$blur', '$save', '$read'].includes(attrName)) {
434
449
  element[attrName.substring(1)]()
435
450
  } else if (attrName) {
436
- 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);
456
+ } else if (targetPosition) {
457
+ if (targetPosition === 'replace') {
458
+ element.insertAdjacentHTML('beforebegin', newValue); // Insert before oldElement
459
+ element.remove(); // Remove oldElement
460
+ } else
461
+ element.insertAdjacentHTML(targetPosition, newValue);
437
462
  } else {
438
463
  if (!attrName && ['click', 'focus', 'blur'].includes(newValue)) {
439
464
  element[newValue]()
440
465
  } else if (['click', 'focus', 'blur'].includes(attrName)) {
441
466
  element[attrName]()
442
467
  }
443
-
444
468
  }
445
-
446
469
  }
447
470
  }
448
471
  },
@@ -621,7 +644,9 @@ function checkCondition(condition, value) {
621
644
  result = value === condition;
622
645
  }
623
646
 
624
- return isNegated ? !result : result;
647
+ result = isNegated ? !result : result;
648
+ return result
649
+
625
650
  }
626
651
 
627
652
  function parseCondition(condition) {