@dooboostore/simple-web-component 1.0.27 → 1.0.28

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dooboostore/simple-web-component",
3
- "version": "1.0.27",
3
+ "version": "1.0.28",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "./dist/cjs/index.js",
@@ -92,9 +92,9 @@
92
92
  "webpack": "^5.93.0",
93
93
  "webpack-cli": "^5.1.4",
94
94
  "webpack-dev-server": "^5.2.0",
95
- "@dooboostore/core": "1.0.30",
96
- "@dooboostore/core-web": "1.0.10",
97
95
  "@dooboostore/core-node": "1.0.12",
96
+ "@dooboostore/core-web": "1.0.10",
97
+ "@dooboostore/core": "1.0.30",
98
98
  "@dooboostore/simple-boot": "1.0.54"
99
99
  },
100
100
  "scripts": {
@@ -1,5 +1,5 @@
1
1
  import { ReflectUtils } from '@dooboostore/core';
2
- import { SpecialSelector, SwcQueryOptions } from '../types';
2
+ import { SpecialSelector, SwcQueryOptions, HelperHostSet } from '../types';
3
3
 
4
4
  export interface AddEventListenerBaseOptions extends EventListenerOptions {
5
5
  capture?: boolean;
@@ -10,6 +10,7 @@ export interface AddEventListenerBaseOptions extends EventListenerOptions {
10
10
  preventDefault?: boolean;
11
11
  removeOnDisconnected?: boolean;
12
12
  delegate?: boolean;
13
+ filter?: (target: Event | CustomEvent, helper: HelperHostSet) => boolean;
13
14
  }
14
15
 
15
16
  export interface AddEventListenerMetadata {
@@ -53,3 +54,12 @@ export const getAddEventListenerMetadata = (target: any): AddEventListenerMetada
53
54
  export function addEventListenerHost(type: string, options?: AddEventListenerBaseOptions & SwcQueryOptions): MethodDecorator {
54
55
  return addEventListener(':host', type, options);
55
56
  }
57
+
58
+ /**
59
+ * @addEventListenerAppHost decorator - simplified version of @addEventListener for :appHost selector
60
+ * Usage: @addEventListenerAppHost('click')
61
+ * Usage: @addEventListenerAppHost('click', { stopPropagation: true })
62
+ */
63
+ export function addEventListenerAppHost(type: string, options?: AddEventListenerBaseOptions & SwcQueryOptions): MethodDecorator {
64
+ return addEventListener(':appHost', type, options);
65
+ }
@@ -396,6 +396,13 @@ export const elementDefine =
396
396
  const { selector, options } = meta;
397
397
  const matchedEl = (event.target as HTMLElement).closest(selector);
398
398
  if (matchedEl && (br as any).contains(matchedEl)) {
399
+ // Apply filter if specified
400
+ if (options.filter) {
401
+ const helper = SwcUtils.getHelperAndHostSet(currentWin, matchedEl);
402
+ if (!options.filter(event, helper)) {
403
+ continue; // Skip this listener if filter returns false
404
+ }
405
+ }
399
406
  if (options.stopPropagation) event.stopPropagation();
400
407
  if (options.stopImmediatePropagation) event.stopImmediatePropagation();
401
408
  if (options.preventDefault) event.preventDefault();
@@ -454,6 +461,13 @@ export const elementDefine =
454
461
 
455
462
  bindTargets.forEach(t => {
456
463
  const handler = async (event: Event) => {
464
+ // Apply filter if specified
465
+ if (options.filter) {
466
+ const helper = SwcUtils.getHelperAndHostSet(currentWin, t as HTMLElement);
467
+ if (!options.filter(event, helper)) {
468
+ return; // Skip if filter returns false
469
+ }
470
+ }
457
471
  if (options.stopPropagation) event.stopPropagation();
458
472
  if (options.stopImmediatePropagation) event.stopImmediatePropagation();
459
473
  if (options.preventDefault) event.preventDefault();