@cocreate/events 1.27.4 → 1.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/automated.yml +5 -6
- package/CHANGELOG.md +19 -0
- package/package.json +1 -1
- package/src/index.js +56 -48
|
@@ -22,13 +22,13 @@ jobs:
|
|
|
22
22
|
runs-on: ubuntu-latest
|
|
23
23
|
steps:
|
|
24
24
|
- name: Checkout
|
|
25
|
-
uses: actions/checkout@
|
|
25
|
+
uses: actions/checkout@v4
|
|
26
26
|
- name: Setup Node.js
|
|
27
|
-
uses: actions/setup-node@
|
|
27
|
+
uses: actions/setup-node@v4
|
|
28
28
|
with:
|
|
29
|
-
node-version:
|
|
29
|
+
node-version: 22 # Required for the latest semantic-release plugins
|
|
30
30
|
- name: Semantic Release
|
|
31
|
-
uses: cycjimmy/semantic-release-action@
|
|
31
|
+
uses: cycjimmy/semantic-release-action@v4 # Update to v4 for better Node 20+ support
|
|
32
32
|
id: semantic
|
|
33
33
|
with:
|
|
34
34
|
extra_plugins: |
|
|
@@ -36,9 +36,8 @@ jobs:
|
|
|
36
36
|
@semantic-release/git
|
|
37
37
|
@semantic-release/github
|
|
38
38
|
env:
|
|
39
|
-
GITHUB_TOKEN: "${{ secrets.
|
|
39
|
+
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" # Use the built-in token if possible
|
|
40
40
|
NPM_TOKEN: "${{ secrets.NPM_TOKEN }}"
|
|
41
41
|
outputs:
|
|
42
42
|
new_release_published: "${{ steps.semantic.outputs.new_release_published }}"
|
|
43
43
|
new_release_version: "${{ steps.semantic.outputs.new_release_version }}"
|
|
44
|
-
|
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
# [1.29.0](https://github.com/CoCreate-app/CoCreate-events/compare/v1.28.0...v1.29.0) (2026-01-17)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* setInterval attribute ([f64f9bc](https://github.com/CoCreate-app/CoCreate-events/commit/f64f9bcc93248c0451b8dcc468d1f0162f3101ea))
|
|
7
|
+
|
|
8
|
+
# [1.28.0](https://github.com/CoCreate-app/CoCreate-events/compare/v1.27.4...v1.28.0) (2026-01-17)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* update worklow ([e8f4c2d](https://github.com/CoCreate-app/CoCreate-events/commit/e8f4c2dc8c3a799adf0be238bab5a4ed9ac08915))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Features
|
|
17
|
+
|
|
18
|
+
* once attribute for intersectionObserver ([e58bfee](https://github.com/CoCreate-app/CoCreate-events/commit/e58bfeec8122a176179ec1b9a03557dbe80765d8))
|
|
19
|
+
|
|
1
20
|
## [1.27.4](https://github.com/CoCreate-app/CoCreate-events/compare/v1.27.3...v1.27.4) (2025-10-11)
|
|
2
21
|
|
|
3
22
|
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -91,7 +91,7 @@ const CoCreateEvents = {
|
|
|
91
91
|
}
|
|
92
92
|
});
|
|
93
93
|
|
|
94
|
-
let selector = `[${prefix}], [${prefix}-key], [${prefix}-attribute], [${prefix}-value], [${prefix}-action], [${prefix}-query]
|
|
94
|
+
let selector = `[${prefix}], [${prefix}-key], [${prefix}-attribute], [${prefix}-value], [${prefix}-action], [${prefix}-query]`;
|
|
95
95
|
|
|
96
96
|
observer.init({
|
|
97
97
|
name: "CoCreateEventattributes",
|
|
@@ -149,19 +149,6 @@ const CoCreateEvents = {
|
|
|
149
149
|
|
|
150
150
|
if (!events || !isEventable) continue;
|
|
151
151
|
|
|
152
|
-
// let originalSelector = ""; // i think we need to extract the selector and remove the operators
|
|
153
|
-
// if (originalSelector) {
|
|
154
|
-
// observer.init({
|
|
155
|
-
// types: ["addedNodes"],
|
|
156
|
-
// callback: function (mutation) {
|
|
157
|
-
// const els = el.queryElements();
|
|
158
|
-
// if (els && els.includes(mutation.target)) {
|
|
159
|
-
// self.__updateElements();
|
|
160
|
-
// }
|
|
161
|
-
// }
|
|
162
|
-
// });
|
|
163
|
-
// }
|
|
164
|
-
|
|
165
152
|
if (events.includes("onload")) {
|
|
166
153
|
this.__updateElements(el, prefix);
|
|
167
154
|
}
|
|
@@ -245,19 +232,22 @@ const CoCreateEvents = {
|
|
|
245
232
|
? threshold.filter((value) => value >= 0 && value <= 1)
|
|
246
233
|
: [0];
|
|
247
234
|
|
|
235
|
+
// Returns true if attribute is present AND does not equal "false"
|
|
236
|
+
const onceAttr = el.getAttribute(`${prefix}-once`);
|
|
237
|
+
const once = onceAttr !== null && onceAttr !== "false";
|
|
238
|
+
|
|
248
239
|
// Create IntersectionObserver
|
|
249
240
|
const intersectionObserver = new IntersectionObserver(
|
|
250
241
|
(entries) => {
|
|
251
242
|
entries.forEach((entry) => {
|
|
252
243
|
const isVisible = entry.isIntersecting;
|
|
253
244
|
|
|
254
|
-
// Determine if
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
if (isVisible) {
|
|
245
|
+
// Determine if we should trigger based on the "trigger" attribute
|
|
246
|
+
if (
|
|
247
|
+
(trigger === "visible" && isVisible) ||
|
|
248
|
+
(trigger === "not-visible" && !isVisible) ||
|
|
249
|
+
trigger === "both"
|
|
250
|
+
) {
|
|
261
251
|
// Set an attribute to reflect visibility state
|
|
262
252
|
el.setAttribute(
|
|
263
253
|
`${prefix}-is-visible`,
|
|
@@ -268,12 +258,11 @@ const CoCreateEvents = {
|
|
|
268
258
|
self.__updateElements(
|
|
269
259
|
el,
|
|
270
260
|
prefix
|
|
271
|
-
// {
|
|
272
|
-
// isVisible,
|
|
273
|
-
// intersectionRatio:
|
|
274
|
-
// entry.intersectionRatio
|
|
275
|
-
// }
|
|
276
261
|
);
|
|
262
|
+
// Disconnect if once is true
|
|
263
|
+
if (once) {
|
|
264
|
+
intersectionObserver.unobserve(entry.target);
|
|
265
|
+
}
|
|
277
266
|
}
|
|
278
267
|
});
|
|
279
268
|
},
|
|
@@ -360,23 +349,7 @@ const CoCreateEvents = {
|
|
|
360
349
|
null,
|
|
361
350
|
prefixes[prefix].events
|
|
362
351
|
);
|
|
363
|
-
|
|
364
|
-
// let selector = `[${prefix}], [${prefix}-key], [${prefix}-value], [${prefix}-query]`
|
|
365
|
-
|
|
366
|
-
// let parentElement = target.parentElement;
|
|
367
|
-
// if (parentElement) {
|
|
368
|
-
// do {
|
|
369
|
-
// parentElement = parentElement.closest(selector)
|
|
370
|
-
// if (parentElement) {
|
|
371
|
-
// self.__updateElements(parentElement, prefix, null, prefixes[prefix].events);
|
|
372
|
-
// parentElement = parentElement.parentElement
|
|
373
|
-
// }
|
|
374
|
-
// }
|
|
375
|
-
// while (parentElement)
|
|
376
|
-
|
|
377
|
-
// }
|
|
378
352
|
}
|
|
379
|
-
// }, 500);
|
|
380
353
|
}
|
|
381
354
|
}
|
|
382
355
|
},
|
|
@@ -411,9 +384,48 @@ const CoCreateEvents = {
|
|
|
411
384
|
// });
|
|
412
385
|
// }
|
|
413
386
|
|
|
414
|
-
|
|
415
|
-
|
|
387
|
+
let interval = element.getAttribute(`${prefix}-setInterval`);
|
|
388
|
+
if (interval !== null) {
|
|
389
|
+
let intervalMs = parseInt(interval, 10) || 0;
|
|
390
|
+
if (!element.eventsInterval) {
|
|
391
|
+
element.eventsInterval = {};
|
|
392
|
+
}
|
|
393
|
+
let intervalEntry = element.eventsInterval[prefix];
|
|
394
|
+
if (intervalMs > 0) {
|
|
395
|
+
if (!intervalEntry || intervalEntry.delay !== intervalMs) {
|
|
396
|
+
if (intervalEntry) {
|
|
397
|
+
clearInterval(intervalEntry.id);
|
|
398
|
+
}
|
|
399
|
+
element.eventsInterval[prefix] = {
|
|
400
|
+
delay: intervalMs,
|
|
401
|
+
id: setInterval(() => {
|
|
402
|
+
if (!element.isConnected) {
|
|
403
|
+
const entry =
|
|
404
|
+
element.eventsInterval &&
|
|
405
|
+
element.eventsInterval[prefix];
|
|
406
|
+
if (entry) {
|
|
407
|
+
clearInterval(entry.id);
|
|
408
|
+
delete element.eventsInterval[prefix];
|
|
409
|
+
}
|
|
410
|
+
return;
|
|
411
|
+
}
|
|
412
|
+
self.__updateElements(
|
|
413
|
+
element,
|
|
414
|
+
prefix,
|
|
415
|
+
target,
|
|
416
|
+
events,
|
|
417
|
+
params
|
|
418
|
+
);
|
|
419
|
+
}, intervalMs)
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
} else if (intervalEntry) {
|
|
423
|
+
clearInterval(intervalEntry.id);
|
|
424
|
+
delete element.eventsInterval[prefix];
|
|
425
|
+
}
|
|
426
|
+
}
|
|
416
427
|
|
|
428
|
+
let delay = element.getAttribute(`${prefix}-setTimeout`);
|
|
417
429
|
if (delay) {
|
|
418
430
|
delay = parseInt(delay, 10) || 0;
|
|
419
431
|
if (delay > 0) {
|
|
@@ -439,9 +451,6 @@ const CoCreateEvents = {
|
|
|
439
451
|
let targetPosition = element.getAttribute(
|
|
440
452
|
`${prefix}-insert-adjacent`
|
|
441
453
|
);
|
|
442
|
-
// targetAttribute = checkMediaQueries(targetAttribute)
|
|
443
|
-
// if (targetAttribute === false)
|
|
444
|
-
// return
|
|
445
454
|
|
|
446
455
|
let onEvent = element.getAttribute(`${prefix}-on`);
|
|
447
456
|
if (onEvent) {
|
|
@@ -466,7 +475,6 @@ const CoCreateEvents = {
|
|
|
466
475
|
}
|
|
467
476
|
}
|
|
468
477
|
|
|
469
|
-
// if (!key || !values)
|
|
470
478
|
if (!key) return;
|
|
471
479
|
} else {
|
|
472
480
|
values = element.getAttribute(`${prefix}-value`);
|