@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/README.md +48 -1
- package/dist/cjs/decorators/addEventListener.js +4 -0
- package/dist/cjs/decorators/addEventListener.js.map +2 -2
- package/dist/cjs/decorators/elementDefine.js +12 -0
- package/dist/cjs/decorators/elementDefine.js.map +2 -2
- package/dist/esm/decorators/addEventListener.js +4 -0
- package/dist/esm/decorators/addEventListener.js.map +2 -2
- package/dist/esm/decorators/elementDefine.js +12 -0
- package/dist/esm/decorators/elementDefine.js.map +2 -2
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +16 -0
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +2 -2
- package/dist/types/decorators/addEventListener.d.ts +8 -1
- package/dist/types/decorators/addEventListener.d.ts.map +1 -1
- package/dist/types/decorators/elementDefine.d.ts.map +1 -1
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +16 -0
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +2 -2
- package/package.json +3 -3
- package/src/decorators/addEventListener.ts +11 -1
- package/src/decorators/elementDefine.ts +14 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SpecialSelector, SwcQueryOptions } from '../types';
|
|
1
|
+
import { SpecialSelector, SwcQueryOptions, HelperHostSet } from '../types';
|
|
2
2
|
export interface AddEventListenerBaseOptions extends EventListenerOptions {
|
|
3
3
|
capture?: boolean;
|
|
4
4
|
once?: boolean;
|
|
@@ -8,6 +8,7 @@ export interface AddEventListenerBaseOptions extends EventListenerOptions {
|
|
|
8
8
|
preventDefault?: boolean;
|
|
9
9
|
removeOnDisconnected?: boolean;
|
|
10
10
|
delegate?: boolean;
|
|
11
|
+
filter?: (target: Event | CustomEvent, helper: HelperHostSet) => boolean;
|
|
11
12
|
}
|
|
12
13
|
export interface AddEventListenerMetadata {
|
|
13
14
|
propertyKey: string | symbol;
|
|
@@ -29,4 +30,10 @@ export declare const getAddEventListenerMetadata: (target: any) => AddEventListe
|
|
|
29
30
|
* Usage: @addEventListenerHost('click', { stopPropagation: true })
|
|
30
31
|
*/
|
|
31
32
|
export declare function addEventListenerHost(type: string, options?: AddEventListenerBaseOptions & SwcQueryOptions): MethodDecorator;
|
|
33
|
+
/**
|
|
34
|
+
* @addEventListenerAppHost decorator - simplified version of @addEventListener for :appHost selector
|
|
35
|
+
* Usage: @addEventListenerAppHost('click')
|
|
36
|
+
* Usage: @addEventListenerAppHost('click', { stopPropagation: true })
|
|
37
|
+
*/
|
|
38
|
+
export declare function addEventListenerAppHost(type: string, options?: AddEventListenerBaseOptions & SwcQueryOptions): MethodDecorator;
|
|
32
39
|
//# sourceMappingURL=addEventListener.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addEventListener.d.ts","sourceRoot":"","sources":["../../../src/decorators/addEventListener.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"addEventListener.d.ts","sourceRoot":"","sources":["../../../src/decorators/addEventListener.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE3E,MAAM,WAAW,2BAA4B,SAAQ,oBAAoB;IACvE,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,KAAK,GAAG,WAAW,EAAE,MAAM,EAAE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AAG,CAAC;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,eAAgB,SAAQ,IAAI,CAAC,aAAa,EAAE,QAAQ,CAAC;IACpE,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,gBAAgB,GAAI,QAAQ,GAAG,KAAG,eAAe,GAAG,SAGhE,CAAC;AAEF,eAAO,MAAM,UAAU,GAAI,MAAM,GAAG,SAiEnC,CAAC;AA4JF,eAAO,MAAM,aAAa,GACvB,MAAM,MAAM,EAAE,SAAQ,OAAO,CAAC,aAAa,CAAM,KAAG,
|
|
1
|
+
{"version":3,"file":"elementDefine.d.ts","sourceRoot":"","sources":["../../../src/decorators/elementDefine.ts"],"names":[],"mappings":"AAiBA,eAAO,MAAM,kBAAkB,eAAoD,CAAC;AAEpF,MAAM,WAAW,aAAa;IAC5B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC9B,qBAAqB,CAAC,EAAE,GAAG,CAAC;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,eAAgB,SAAQ,IAAI,CAAC,aAAa,EAAE,QAAQ,CAAC;IACpE,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,gBAAgB,GAAI,QAAQ,GAAG,KAAG,eAAe,GAAG,SAGhE,CAAC;AAEF,eAAO,MAAM,UAAU,GAAI,MAAM,GAAG,SAiEnC,CAAC;AA4JF,eAAO,MAAM,aAAa,GACvB,MAAM,MAAM,EAAE,SAAQ,OAAO,CAAC,aAAa,CAAM,KAAG,cAuUpD,CAAC"}
|
|
@@ -1149,6 +1149,7 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
1149
1149
|
addClass: () => addClass,
|
|
1150
1150
|
addClassHost: () => addClassHost,
|
|
1151
1151
|
addEventListener: () => addEventListener,
|
|
1152
|
+
addEventListenerAppHost: () => addEventListenerAppHost,
|
|
1152
1153
|
addEventListenerHost: () => addEventListenerHost,
|
|
1153
1154
|
allAppHost: () => allAppHost,
|
|
1154
1155
|
allFirstAppHost: () => allFirstAppHost,
|
|
@@ -5887,6 +5888,9 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
5887
5888
|
function addEventListenerHost(type, options) {
|
|
5888
5889
|
return addEventListener(":host", type, options);
|
|
5889
5890
|
}
|
|
5891
|
+
function addEventListenerAppHost(type, options) {
|
|
5892
|
+
return addEventListener(":appHost", type, options);
|
|
5893
|
+
}
|
|
5890
5894
|
|
|
5891
5895
|
// src/decorators/lifecycles.ts
|
|
5892
5896
|
var ON_INITIALIZE_METADATA_KEY = Symbol.for("simple-web-component:on-constructor");
|
|
@@ -7681,6 +7685,12 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
7681
7685
|
const { selector, options } = meta;
|
|
7682
7686
|
const matchedEl = event.target.closest(selector);
|
|
7683
7687
|
if (matchedEl && br.contains(matchedEl)) {
|
|
7688
|
+
if (options.filter) {
|
|
7689
|
+
const helper = SwcUtils.getHelperAndHostSet(currentWin, matchedEl);
|
|
7690
|
+
if (!options.filter(event, helper)) {
|
|
7691
|
+
continue;
|
|
7692
|
+
}
|
|
7693
|
+
}
|
|
7684
7694
|
if (options.stopPropagation) event.stopPropagation();
|
|
7685
7695
|
if (options.stopImmediatePropagation) event.stopImmediatePropagation();
|
|
7686
7696
|
if (options.preventDefault) event.preventDefault();
|
|
@@ -7735,6 +7745,12 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
7735
7745
|
}
|
|
7736
7746
|
bindTargets.forEach((t) => {
|
|
7737
7747
|
const handler = async (event) => {
|
|
7748
|
+
if (options.filter) {
|
|
7749
|
+
const helper = SwcUtils.getHelperAndHostSet(currentWin, t);
|
|
7750
|
+
if (!options.filter(event, helper)) {
|
|
7751
|
+
return;
|
|
7752
|
+
}
|
|
7753
|
+
}
|
|
7738
7754
|
if (options.stopPropagation) event.stopPropagation();
|
|
7739
7755
|
if (options.stopImmediatePropagation) event.stopImmediatePropagation();
|
|
7740
7756
|
if (options.preventDefault) event.preventDefault();
|