@dooboostore/simple-web-component 1.0.21 → 1.0.23
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 +1113 -95
- package/dist/cjs/decorators/addEventListener.js +4 -0
- package/dist/cjs/decorators/addEventListener.js.map +2 -2
- package/dist/cjs/decorators/applyNode.js +174 -0
- package/dist/cjs/decorators/applyNode.js.map +7 -0
- package/dist/cjs/decorators/attribute.js +30 -10
- package/dist/cjs/decorators/attribute.js.map +3 -3
- package/dist/cjs/decorators/{changedAttribute.js → changedAttributeHost.js} +6 -6
- package/dist/cjs/decorators/changedAttributeHost.js.map +7 -0
- package/dist/cjs/decorators/classList.js +45 -15
- package/dist/cjs/decorators/classList.js.map +2 -2
- package/dist/cjs/decorators/elementDefine.js +107 -57
- package/dist/cjs/decorators/elementDefine.js.map +2 -2
- package/dist/cjs/decorators/emitCustomEvent.js +4 -3
- package/dist/cjs/decorators/emitCustomEvent.js.map +2 -2
- package/dist/cjs/decorators/index.js +2 -4
- package/dist/cjs/decorators/index.js.map +2 -2
- package/dist/cjs/decorators/lifecycles.js +29 -0
- package/dist/cjs/decorators/lifecycles.js.map +2 -2
- package/dist/cjs/decorators/query.js +5 -1
- package/dist/cjs/decorators/query.js.map +2 -2
- package/dist/cjs/decorators/queryAll.js +5 -1
- package/dist/cjs/decorators/queryAll.js.map +2 -2
- package/dist/cjs/decorators/setAttribute.js +5 -1
- package/dist/cjs/decorators/setAttribute.js.map +2 -2
- package/dist/cjs/decorators/style.js +39 -13
- package/dist/cjs/decorators/style.js.map +2 -2
- package/dist/cjs/elements/SwcAppEngine.js.map +2 -2
- package/dist/cjs/elements/SwcAppMixin.js.map +2 -2
- package/dist/cjs/elements/SwcAsync.js +2 -2
- package/dist/cjs/elements/SwcAsync.js.map +2 -2
- package/dist/cjs/elements/SwcChoose.js +2 -2
- package/dist/cjs/elements/SwcChoose.js.map +2 -2
- package/dist/cjs/elements/SwcIf.js +2 -2
- package/dist/cjs/elements/SwcIf.js.map +2 -2
- package/dist/cjs/elements/SwcLoop.js +2 -2
- package/dist/cjs/elements/SwcLoop.js.map +2 -2
- package/dist/cjs/elements/register.js +6 -5
- package/dist/cjs/elements/register.js.map +2 -2
- package/dist/cjs/index.js +6 -18
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/types.js.map +2 -2
- package/dist/cjs/utils/TemplateUtils.js +6 -0
- package/dist/cjs/utils/TemplateUtils.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/applyNode.js +155 -0
- package/dist/esm/decorators/applyNode.js.map +7 -0
- package/dist/esm/decorators/attribute.js +30 -10
- package/dist/esm/decorators/attribute.js.map +3 -3
- package/dist/esm/decorators/{changedAttribute.js → changedAttributeHost.js} +3 -3
- package/dist/esm/decorators/changedAttributeHost.js.map +7 -0
- package/dist/esm/decorators/classList.js +45 -15
- package/dist/esm/decorators/classList.js.map +2 -2
- package/dist/esm/decorators/elementDefine.js +106 -56
- package/dist/esm/decorators/elementDefine.js.map +2 -2
- package/dist/esm/decorators/emitCustomEvent.js +4 -3
- package/dist/esm/decorators/emitCustomEvent.js.map +2 -2
- package/dist/esm/decorators/index.js +2 -4
- package/dist/esm/decorators/index.js.map +2 -2
- package/dist/esm/decorators/lifecycles.js +29 -0
- package/dist/esm/decorators/lifecycles.js.map +2 -2
- package/dist/esm/decorators/query.js +5 -1
- package/dist/esm/decorators/query.js.map +2 -2
- package/dist/esm/decorators/queryAll.js +5 -1
- package/dist/esm/decorators/queryAll.js.map +2 -2
- package/dist/esm/decorators/setAttribute.js +5 -1
- package/dist/esm/decorators/setAttribute.js.map +2 -2
- package/dist/esm/decorators/style.js +39 -13
- package/dist/esm/decorators/style.js.map +2 -2
- package/dist/esm/elements/SwcAppEngine.js.map +2 -2
- package/dist/esm/elements/SwcAppMixin.js.map +2 -2
- package/dist/esm/elements/SwcAsync.js +2 -2
- package/dist/esm/elements/SwcAsync.js.map +2 -2
- package/dist/esm/elements/SwcChoose.js +2 -2
- package/dist/esm/elements/SwcChoose.js.map +2 -2
- package/dist/esm/elements/SwcIf.js +2 -2
- package/dist/esm/elements/SwcIf.js.map +2 -2
- package/dist/esm/elements/SwcLoop.js +2 -2
- package/dist/esm/elements/SwcLoop.js.map +2 -2
- package/dist/esm/elements/register.js +6 -5
- package/dist/esm/elements/register.js.map +2 -2
- package/dist/esm/index.js +6 -18
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/types.js.map +2 -2
- package/dist/esm/utils/TemplateUtils.js +6 -0
- package/dist/esm/utils/TemplateUtils.js.map +2 -2
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +385 -206
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +4 -4
- package/dist/types/decorators/addEventListener.d.ts +6 -0
- package/dist/types/decorators/addEventListener.d.ts.map +1 -1
- package/dist/types/decorators/applyNode.d.ts +121 -0
- package/dist/types/decorators/applyNode.d.ts.map +1 -0
- package/dist/types/decorators/attribute.d.ts +6 -0
- package/dist/types/decorators/attribute.d.ts.map +1 -1
- package/dist/types/decorators/{changedAttribute.d.ts → changedAttributeHost.d.ts} +6 -2
- package/dist/types/decorators/changedAttributeHost.d.ts.map +1 -0
- package/dist/types/decorators/classList.d.ts +32 -5
- package/dist/types/decorators/classList.d.ts.map +1 -1
- package/dist/types/decorators/elementDefine.d.ts.map +1 -1
- package/dist/types/decorators/emitCustomEvent.d.ts +14 -2
- package/dist/types/decorators/emitCustomEvent.d.ts.map +1 -1
- package/dist/types/decorators/index.d.ts +2 -4
- package/dist/types/decorators/index.d.ts.map +1 -1
- package/dist/types/decorators/lifecycles.d.ts +16 -0
- package/dist/types/decorators/lifecycles.d.ts.map +1 -1
- package/dist/types/decorators/query.d.ts +6 -3
- package/dist/types/decorators/query.d.ts.map +1 -1
- package/dist/types/decorators/queryAll.d.ts +6 -0
- package/dist/types/decorators/queryAll.d.ts.map +1 -1
- package/dist/types/decorators/setAttribute.d.ts +5 -0
- package/dist/types/decorators/setAttribute.d.ts.map +1 -1
- package/dist/types/decorators/style.d.ts +28 -3
- package/dist/types/decorators/style.d.ts.map +1 -1
- package/dist/types/elements/SwcAppEngine.d.ts.map +1 -1
- package/dist/types/elements/SwcAppMixin.d.ts.map +1 -1
- package/dist/types/elements/register.d.ts +1 -1
- package/dist/types/elements/register.d.ts.map +1 -1
- package/dist/types/index.d.ts +3 -15
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/types.d.ts +2 -1
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/utils/TemplateUtils.d.ts +5 -0
- package/dist/types/utils/TemplateUtils.d.ts.map +1 -1
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +385 -206
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +4 -4
- package/package.json +3 -3
- package/src/decorators/addEventListener.ts +9 -0
- package/src/decorators/applyNode.ts +290 -0
- package/src/decorators/attribute.ts +46 -12
- package/src/decorators/{changedAttribute.ts → changedAttributeHost.ts} +5 -1
- package/src/decorators/classList.ts +71 -16
- package/src/decorators/elementDefine.ts +130 -63
- package/src/decorators/emitCustomEvent.ts +13 -5
- package/src/decorators/index.ts +2 -4
- package/src/decorators/lifecycles.ts +43 -1
- package/src/decorators/query.ts +9 -2
- package/src/decorators/queryAll.ts +9 -0
- package/src/decorators/setAttribute.ts +8 -0
- package/src/decorators/style.ts +64 -13
- package/src/elements/SwcAppEngine.ts +1 -0
- package/src/elements/SwcAppMixin.ts +2 -1
- package/src/elements/SwcAsync.ts +2 -2
- package/src/elements/SwcChoose.ts +2 -2
- package/src/elements/SwcIf.ts +2 -2
- package/src/elements/SwcLoop.ts +2 -2
- package/src/elements/register.ts +7 -5
- package/src/index.ts +8 -17
- package/src/types.ts +2 -1
- package/src/utils/TemplateUtils.ts +9 -0
- package/dist/cjs/decorators/appendChild.js +0 -92
- package/dist/cjs/decorators/appendChild.js.map +0 -7
- package/dist/cjs/decorators/changedAttribute.js.map +0 -7
- package/dist/cjs/decorators/onConnectedInnerHtml.js +0 -48
- package/dist/cjs/decorators/onConnectedInnerHtml.js.map +0 -7
- package/dist/cjs/decorators/replaceChildren.js +0 -79
- package/dist/cjs/decorators/replaceChildren.js.map +0 -7
- package/dist/esm/decorators/appendChild.js +0 -73
- package/dist/esm/decorators/appendChild.js.map +0 -7
- package/dist/esm/decorators/changedAttribute.js.map +0 -7
- package/dist/esm/decorators/onConnectedInnerHtml.js +0 -29
- package/dist/esm/decorators/onConnectedInnerHtml.js.map +0 -7
- package/dist/esm/decorators/replaceChildren.js +0 -60
- package/dist/esm/decorators/replaceChildren.js.map +0 -7
- package/dist/types/decorators/appendChild.d.ts +0 -17
- package/dist/types/decorators/appendChild.d.ts.map +0 -1
- package/dist/types/decorators/changedAttribute.d.ts.map +0 -1
- package/dist/types/decorators/onConnectedInnerHtml.d.ts +0 -15
- package/dist/types/decorators/onConnectedInnerHtml.d.ts.map +0 -1
- package/dist/types/decorators/replaceChildren.d.ts +0 -9
- package/dist/types/decorators/replaceChildren.d.ts.map +0 -1
- package/src/decorators/appendChild.ts +0 -86
- package/src/decorators/onConnectedInnerHtml.ts +0 -42
- package/src/decorators/replaceChildren.ts +0 -64
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { changedAttributeHost } from '../decorators/changedAttributeHost';
|
|
2
2
|
import { SwcUtils } from '../utils/Utils';
|
|
3
3
|
import { FunctionUtils } from '@dooboostore/core';
|
|
4
4
|
|
|
@@ -36,7 +36,7 @@ export class SwcChoose extends HTMLTemplateElement {
|
|
|
36
36
|
FunctionUtils.execute({ script, context: this, args });
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
@
|
|
39
|
+
@changedAttributeHost('on-get-value')
|
|
40
40
|
private refresh() {
|
|
41
41
|
const script = this.getAttribute('on-get-value');
|
|
42
42
|
if (!script) {
|
package/src/elements/SwcIf.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { changedAttributeHost } from '../decorators/changedAttributeHost';
|
|
2
2
|
import { SwcUtils } from '../utils/Utils';
|
|
3
3
|
import { FunctionUtils } from '@dooboostore/core';
|
|
4
4
|
|
|
@@ -36,7 +36,7 @@ export class SwcIf extends HTMLTemplateElement {
|
|
|
36
36
|
FunctionUtils.execute({ script, context: this, args });
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
@
|
|
39
|
+
@changedAttributeHost('on-get-value')
|
|
40
40
|
private refreshValue() {
|
|
41
41
|
const script = this.getAttribute('on-get-value');
|
|
42
42
|
if (!script) {
|
package/src/elements/SwcLoop.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { changedAttributeHost } from '../decorators/changedAttributeHost';
|
|
2
2
|
import { SwcUtils } from '../utils/Utils';
|
|
3
3
|
import { FunctionUtils } from '@dooboostore/core';
|
|
4
4
|
|
|
@@ -41,7 +41,7 @@ export class SwcLoop extends HTMLTemplateElement {
|
|
|
41
41
|
this._nodeGroups = [];
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
@
|
|
44
|
+
@changedAttributeHost('on-get-value')
|
|
45
45
|
private refreshValue() {
|
|
46
46
|
const script = this.getAttribute('on-get-value');
|
|
47
47
|
if (!script) {
|
package/src/elements/register.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { elementDefine } from '../decorators/elementDefine';
|
|
|
2
2
|
import { SwcAppMixin } from './SwcAppMixin';
|
|
3
3
|
import { SwcUtils } from '../utils/Utils';
|
|
4
4
|
import { FunctionUtils } from '@dooboostore/core';
|
|
5
|
-
import {
|
|
5
|
+
import { changedAttributeHost } from '../decorators/changedAttributeHost';
|
|
6
6
|
|
|
7
7
|
export const registerAllElements = (w: any) => {
|
|
8
8
|
const {
|
|
@@ -179,7 +179,7 @@ export const registerAllElements = (w: any) => {
|
|
|
179
179
|
FunctionUtils.execute({ script, context: this, args });
|
|
180
180
|
}
|
|
181
181
|
|
|
182
|
-
@
|
|
182
|
+
@changedAttributeHost('on-get-value')
|
|
183
183
|
private refreshValue() {
|
|
184
184
|
const script = this.getAttribute('on-get-value');
|
|
185
185
|
if (!script) {
|
|
@@ -294,7 +294,7 @@ export const registerAllElements = (w: any) => {
|
|
|
294
294
|
this._nodeGroups = [];
|
|
295
295
|
}
|
|
296
296
|
|
|
297
|
-
@
|
|
297
|
+
@changedAttributeHost('on-get-value')
|
|
298
298
|
private refreshValue() {
|
|
299
299
|
const script = this.getAttribute('on-get-value');
|
|
300
300
|
if (!script) {
|
|
@@ -405,7 +405,7 @@ export const registerAllElements = (w: any) => {
|
|
|
405
405
|
FunctionUtils.execute({ script, context: this, args });
|
|
406
406
|
}
|
|
407
407
|
|
|
408
|
-
@
|
|
408
|
+
@changedAttributeHost('on-get-value')
|
|
409
409
|
private refresh() {
|
|
410
410
|
const script = this.getAttribute('on-get-value');
|
|
411
411
|
if (!script) {
|
|
@@ -496,7 +496,7 @@ export const registerAllElements = (w: any) => {
|
|
|
496
496
|
FunctionUtils.execute({ script, context: this, args });
|
|
497
497
|
}
|
|
498
498
|
|
|
499
|
-
@
|
|
499
|
+
@changedAttributeHost('on-get-value')
|
|
500
500
|
private refresh() {
|
|
501
501
|
const script = this.getAttribute('on-get-value');
|
|
502
502
|
if (!script) return;
|
|
@@ -732,4 +732,6 @@ export const registerAllElements = (w: any) => {
|
|
|
732
732
|
@elementDefine('swc-app-body', { extends: 'body', window: w })
|
|
733
733
|
class SwcAppBody extends SwcAppMixin(HTMLBodyElement) {}
|
|
734
734
|
|
|
735
|
+
|
|
736
|
+
return []
|
|
735
737
|
};
|
package/src/index.ts
CHANGED
|
@@ -1,21 +1,9 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
2
|
import { registerAllElements } from './elements/register';
|
|
3
|
+
import {ConstructorType} from "@dooboostore/core";
|
|
3
4
|
|
|
4
5
|
// Decorators
|
|
5
|
-
export * from './decorators
|
|
6
|
-
export * from './decorators/attribute';
|
|
7
|
-
export * from './decorators/setAttribute';
|
|
8
|
-
export * from './decorators/changedAttribute';
|
|
9
|
-
export { onConnectedInnerHtml } from './decorators/onConnectedInnerHtml';
|
|
10
|
-
export * from './decorators/replaceChildren';
|
|
11
|
-
export * from './decorators/appendChild';
|
|
12
|
-
export * from './decorators/classList';
|
|
13
|
-
export * from './decorators/style';
|
|
14
|
-
export * from './decorators/emitCustomEvent';
|
|
15
|
-
export * from './decorators/lifecycles';
|
|
16
|
-
export * from './decorators/query';
|
|
17
|
-
export * from './decorators/queryAll';
|
|
18
|
-
export * from './decorators/addEventListener';
|
|
6
|
+
export * from './decorators';
|
|
19
7
|
|
|
20
8
|
// Types
|
|
21
9
|
export * from './types';
|
|
@@ -28,9 +16,12 @@ export * from './utils/TemplateUtils';
|
|
|
28
16
|
export * from './config/config';
|
|
29
17
|
|
|
30
18
|
// Registration Factory
|
|
31
|
-
export default (w: Window, other?: ((w: Window) =>
|
|
19
|
+
export default (w: Window, other?: ((w: Window) => ConstructorType<any>)[]): ConstructorType<any>[] => {
|
|
32
20
|
registerAllElements(w);
|
|
33
|
-
other?.
|
|
34
|
-
fn(w);
|
|
21
|
+
const r = other?.map(fn => {
|
|
22
|
+
const a = fn(w);
|
|
23
|
+
// console.log('l', fn, a)
|
|
24
|
+
return a;
|
|
35
25
|
});
|
|
26
|
+
return r??[];
|
|
36
27
|
};
|
package/src/types.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { SimpleApplication } from '@dooboostore/simple-boot/SimpleApplication';
|
|
2
2
|
import { Router } from '@dooboostore/core-web';
|
|
3
|
+
import {SwcAttributeConfigType} from "./elements/SwcAppEngine";
|
|
3
4
|
|
|
4
5
|
export enum InjectSituationType {
|
|
5
6
|
HOST_SET = 'SIMPLE_WEB_COMPONENT://HOSTSET',
|
|
@@ -45,6 +46,6 @@ export type HelperHostSet = HelperSet & HostSet;
|
|
|
45
46
|
export interface SwcAppInterface extends HTMLElement {
|
|
46
47
|
simpleApplication?: SimpleApplication;
|
|
47
48
|
router?: Router;
|
|
48
|
-
connect(config?:
|
|
49
|
+
connect(config?: SwcAttributeConfigType): Promise<void>;
|
|
49
50
|
routing(path: string): Promise<void>;
|
|
50
51
|
}
|
|
@@ -22,6 +22,14 @@ export namespace TemplateUtils {
|
|
|
22
22
|
return document.createTextNode(raw);
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
+
/**
|
|
26
|
+
* Tagged template function to create a Comment node from string.
|
|
27
|
+
*/
|
|
28
|
+
export const commentNode = (strings: TemplateStringsArray, ...values: any[]): Comment => {
|
|
29
|
+
const raw = strings.reduce((acc, str, i) => acc + str + (values[i] !== undefined ? values[i] : ''), '');
|
|
30
|
+
return document.createComment(raw);
|
|
31
|
+
};
|
|
32
|
+
|
|
25
33
|
/**
|
|
26
34
|
* Generic element creator using a configuration object and attribute map.
|
|
27
35
|
*/
|
|
@@ -64,6 +72,7 @@ export namespace TemplateUtils {
|
|
|
64
72
|
|
|
65
73
|
export const htmlFragment = TemplateUtils.htmlFragment;
|
|
66
74
|
export const textNode = TemplateUtils.textNode;
|
|
75
|
+
export const commentNode = TemplateUtils.commentNode;
|
|
67
76
|
export const createElement = TemplateUtils.createElement;
|
|
68
77
|
export const htmlDivElement = TemplateUtils.htmlDivElement;
|
|
69
78
|
export const htmlSpanElement = TemplateUtils.htmlSpanElement;
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var appendChild_exports = {};
|
|
19
|
-
__export(appendChild_exports, {
|
|
20
|
-
APPEND_CHILD_METADATA_KEY: () => APPEND_CHILD_METADATA_KEY,
|
|
21
|
-
appendChild: () => appendChild,
|
|
22
|
-
findAllAppendChildMetadata: () => findAllAppendChildMetadata
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(appendChild_exports);
|
|
25
|
-
var import_core = require("@dooboostore/core");
|
|
26
|
-
var import_elementDefine = require("./elementDefine");
|
|
27
|
-
const APPEND_CHILD_METADATA_KEY = Symbol("simple-web-component:append-child");
|
|
28
|
-
const normalizeNodes = (res, doc) => {
|
|
29
|
-
const items = Array.isArray(res) ? res : [res];
|
|
30
|
-
return items.map((it) => {
|
|
31
|
-
if (it instanceof Node)
|
|
32
|
-
return it;
|
|
33
|
-
return doc.createTextNode(it !== void 0 && it !== null ? String(it) : "");
|
|
34
|
-
});
|
|
35
|
-
};
|
|
36
|
-
function appendChild(selector, options = { position: "beforeEnd" }) {
|
|
37
|
-
return (target, propertyKey, descriptor) => {
|
|
38
|
-
const constructor = target.constructor;
|
|
39
|
-
let metaList = import_core.ReflectUtils.getOwnMetadata(APPEND_CHILD_METADATA_KEY, constructor);
|
|
40
|
-
if (!metaList) {
|
|
41
|
-
metaList = /* @__PURE__ */ new Map();
|
|
42
|
-
import_core.ReflectUtils.defineMetadata(APPEND_CHILD_METADATA_KEY, metaList, constructor);
|
|
43
|
-
}
|
|
44
|
-
metaList.set(propertyKey, { propertyKey, selector, options });
|
|
45
|
-
const original = descriptor.value;
|
|
46
|
-
descriptor.value = async function(...args) {
|
|
47
|
-
(0, import_elementDefine.ensureInit)(this);
|
|
48
|
-
const res = await original.apply(this, args);
|
|
49
|
-
if (res !== void 0) {
|
|
50
|
-
const conf = (0, import_elementDefine.getElementConfig)(this);
|
|
51
|
-
const currentWin = this._resolveWindow?.(conf) || (typeof window !== "undefined" ? window : void 0);
|
|
52
|
-
const currentDoc = currentWin.document;
|
|
53
|
-
let targetEl = null;
|
|
54
|
-
if (selector === ":host" || !selector) {
|
|
55
|
-
targetEl = this;
|
|
56
|
-
} else {
|
|
57
|
-
targetEl = (this.shadowRoot || this).querySelector(selector);
|
|
58
|
-
}
|
|
59
|
-
if (targetEl) {
|
|
60
|
-
const nodes = normalizeNodes(res, currentDoc);
|
|
61
|
-
const pos = options.position || "beforeEnd";
|
|
62
|
-
if (typeof res === "string") {
|
|
63
|
-
targetEl.insertAdjacentText(pos, res);
|
|
64
|
-
} else if (Array.isArray(res) && res.every((n) => typeof n === "string")) {
|
|
65
|
-
targetEl.insertAdjacentText(pos, res.join(""));
|
|
66
|
-
} else {
|
|
67
|
-
if (pos === "beforeEnd")
|
|
68
|
-
targetEl.append(...nodes);
|
|
69
|
-
else if (pos === "afterBegin")
|
|
70
|
-
targetEl.prepend(...nodes);
|
|
71
|
-
else if (pos === "beforeBegin")
|
|
72
|
-
targetEl.before(...nodes);
|
|
73
|
-
else if (pos === "afterEnd")
|
|
74
|
-
targetEl.after(...nodes);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
return res;
|
|
79
|
-
};
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
const findAllAppendChildMetadata = (target) => {
|
|
83
|
-
const result = /* @__PURE__ */ new Map();
|
|
84
|
-
const maps = import_core.ReflectUtils.findAllMetadata(APPEND_CHILD_METADATA_KEY, target);
|
|
85
|
-
maps.forEach((map) => {
|
|
86
|
-
if (map instanceof Map) {
|
|
87
|
-
map.forEach((v, k) => result.set(k, v));
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
return result;
|
|
91
|
-
};
|
|
92
|
-
//# sourceMappingURL=appendChild.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/decorators/appendChild.ts"],
|
|
4
|
-
"sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { ensureInit, getElementConfig } from './elementDefine';\n\nexport type AppendChildPosition = 'beforeBegin' | 'afterBegin' | 'beforeEnd' | 'afterEnd';\n\nexport interface AppendChildOptions {\n position?: AppendChildPosition;\n}\n\nexport interface AppendChildMetadata {\n propertyKey: string | symbol;\n selector: string;\n options: AppendChildOptions;\n}\n\nexport const APPEND_CHILD_METADATA_KEY = Symbol('simple-web-component:append-child');\n\nconst normalizeNodes = (res: any, doc: Document): Node[] => {\n const items = Array.isArray(res) ? res : [res];\n return items.map(it => {\n if (it instanceof Node) return it;\n return doc.createTextNode(it !== undefined && it !== null ? String(it) : '');\n });\n};\n\n/**\n * @appendChild decorator to surgically add nodes to a target element.\n * Usage: @appendChild('#list') addItem() { return '<li>New Item</li>'; }\n */\nexport function appendChild(selector: string, options: AppendChildOptions = { position: 'beforeEnd' }): MethodDecorator {\n return (target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const constructor = target.constructor;\n let metaList = ReflectUtils.getOwnMetadata(APPEND_CHILD_METADATA_KEY, constructor) as Map<string | symbol, AppendChildMetadata>;\n if (!metaList) {\n metaList = new Map<string | symbol, AppendChildMetadata>();\n ReflectUtils.defineMetadata(APPEND_CHILD_METADATA_KEY, metaList, constructor);\n }\n metaList.set(propertyKey, { propertyKey, selector, options });\n\n const original = descriptor.value;\n descriptor.value = async function (...args: any[]) {\n ensureInit(this);\n const res = await original.apply(this, args);\n if (res !== undefined) {\n const conf = getElementConfig(this);\n const currentWin = (this as any)._resolveWindow?.(conf) || ((typeof window !== 'undefined' ? window : undefined) as Window);\n const currentDoc = currentWin.document;\n\n let targetEl: HTMLElement | null = null;\n if (selector === ':host' || !selector) {\n targetEl = this as any;\n } else {\n targetEl = (this.shadowRoot || (this as any)).querySelector(selector);\n }\n\n if (targetEl) {\n const nodes = normalizeNodes(res, currentDoc);\n const pos = options.position || 'beforeEnd';\n\n if (typeof res === 'string') {\n targetEl.insertAdjacentText(pos as InsertPosition, res);\n } else if (Array.isArray(res) && res.every(n => typeof n === 'string')) {\n targetEl.insertAdjacentText(pos as InsertPosition, res.join(''));\n } else {\n if (pos === 'beforeEnd') targetEl.append(...nodes);\n else if (pos === 'afterBegin') targetEl.prepend(...nodes);\n else if (pos === 'beforeBegin') targetEl.before(...nodes);\n else if (pos === 'afterEnd') targetEl.after(...nodes);\n }\n }\n }\n return res;\n };\n };\n}\n\nexport const findAllAppendChildMetadata = (target: any): Map<string | symbol, AppendChildMetadata> => {\n const result = new Map<string | symbol, AppendChildMetadata>();\n const maps = ReflectUtils.findAllMetadata<Map<string | symbol, AppendChildMetadata>>(APPEND_CHILD_METADATA_KEY, target);\n maps.forEach(map => {\n if (map instanceof Map) {\n map.forEach((v, k) => result.set(k, v));\n }\n });\n return result;\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;AAAA;;;;;;;kBAA6B;AAC7B,2BAA6C;AActC,MAAM,4BAA4B,OAAO,mCAAmC;AAEnF,MAAM,iBAAiB,CAAC,KAAU,QAAyB;AACzD,QAAM,QAAQ,MAAM,QAAQ,GAAG,IAAI,MAAM,CAAC,GAAG;AAC7C,SAAO,MAAM,IAAI,QAAK;AACpB,QAAI,cAAc;AAAM,aAAO;AAC/B,WAAO,IAAI,eAAe,OAAO,UAAa,OAAO,OAAO,OAAO,EAAE,IAAI,EAAE;EAC7E,CAAC;AACH;AAMM,SAAU,YAAY,UAAkB,UAA8B,EAAE,UAAU,YAAW,GAAE;AACnG,SAAO,CAAC,QAAgB,aAA8B,eAAkC;AACtF,UAAM,cAAc,OAAO;AAC3B,QAAI,WAAW,yBAAa,eAAe,2BAA2B,WAAW;AACjF,QAAI,CAAC,UAAU;AACb,iBAAW,oBAAI,IAAG;AAClB,+BAAa,eAAe,2BAA2B,UAAU,WAAW;IAC9E;AACA,aAAS,IAAI,aAAa,EAAE,aAAa,UAAU,QAAO,CAAE;AAE5D,UAAM,WAAW,WAAW;AAC5B,eAAW,QAAQ,kBAAmB,MAAW;AAC/C,2CAAW,IAAI;AACf,YAAM,MAAM,MAAM,SAAS,MAAM,MAAM,IAAI;AAC3C,UAAI,QAAQ,QAAW;AACrB,cAAM,WAAO,uCAAiB,IAAI;AAClC,cAAM,aAAc,KAAa,iBAAiB,IAAI,MAAO,OAAO,WAAW,cAAc,SAAS;AACtG,cAAM,aAAa,WAAW;AAE9B,YAAI,WAA+B;AACnC,YAAI,aAAa,WAAW,CAAC,UAAU;AACrC,qBAAW;QACb,OAAO;AACL,sBAAY,KAAK,cAAe,MAAc,cAAc,QAAQ;QACtE;AAEA,YAAI,UAAU;AACZ,gBAAM,QAAQ,eAAe,KAAK,UAAU;AAC5C,gBAAM,MAAM,QAAQ,YAAY;AAEhC,cAAI,OAAO,QAAQ,UAAU;AAC3B,qBAAS,mBAAmB,KAAuB,GAAG;UACxD,WAAW,MAAM,QAAQ,GAAG,KAAK,IAAI,MAAM,OAAK,OAAO,MAAM,QAAQ,GAAG;AACtE,qBAAS,mBAAmB,KAAuB,IAAI,KAAK,EAAE,CAAC;UACjE,OAAO;AACL,gBAAI,QAAQ;AAAa,uBAAS,OAAO,GAAG,KAAK;qBACxC,QAAQ;AAAc,uBAAS,QAAQ,GAAG,KAAK;qBAC/C,QAAQ;AAAe,uBAAS,OAAO,GAAG,KAAK;qBAC/C,QAAQ;AAAY,uBAAS,MAAM,GAAG,KAAK;UACtD;QACF;MACF;AACA,aAAO;IACT;EACF;AACF;AAEO,MAAM,6BAA6B,CAAC,WAA0D;AACnG,QAAM,SAAS,oBAAI,IAAG;AACtB,QAAM,OAAO,yBAAa,gBAA2D,2BAA2B,MAAM;AACtH,OAAK,QAAQ,SAAM;AACjB,QAAI,eAAe,KAAK;AACtB,UAAI,QAAQ,CAAC,GAAG,MAAM,OAAO,IAAI,GAAG,CAAC,CAAC;IACxC;EACF,CAAC;AACD,SAAO;AACT;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/decorators/changedAttribute.ts"],
|
|
4
|
-
"sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\n\nexport const ON_ATTRIBUTE_CHANGED_METADATA_KEY = Symbol('simple-web-component:on-attribute-changed');\n\nexport function changedAttribute(attributeName?: string): MethodDecorator {\n return (target: Object, propertyKey: string | symbol) => {\n const constructor = target.constructor;\n let meta = ReflectUtils.getOwnMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor) as Map<string, (string | symbol)[]>;\n if (!meta) {\n meta = new Map<string, (string | symbol)[]>();\n ReflectUtils.defineMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, meta, constructor);\n }\n\n const name = attributeName || String(propertyKey);\n let methods = meta.get(name);\n if (!methods) {\n methods = [];\n meta.set(name, methods);\n }\n if (!methods.includes(propertyKey)) methods.push(propertyKey);\n };\n}\n\nexport const getChangedAttributeMetadata = (target: any): Map<string, (string | symbol)[]> | undefined => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor);\n};\n\nexport const findAllAttributeChangedMetadata = (target: any): Map<string, (string | symbol)[]> => {\n return ReflectUtils.findAllMapMetadata<string, string | symbol>(ON_ATTRIBUTE_CHANGED_METADATA_KEY, target);\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA6B;AAEtB,MAAM,oCAAoC,OAAO,2CAA2C;AAE5F,SAAS,iBAAiB,eAAyC;AACxE,SAAO,CAAC,QAAgB,gBAAiC;AACvD,UAAM,cAAc,OAAO;AAC3B,QAAI,OAAO,yBAAa,eAAe,mCAAmC,WAAW;AACrF,QAAI,CAAC,MAAM;AACT,aAAO,oBAAI,IAAiC;AAC5C,+BAAa,eAAe,mCAAmC,MAAM,WAAW;AAAA,IAClF;AAEA,UAAM,OAAO,iBAAiB,OAAO,WAAW;AAChD,QAAI,UAAU,KAAK,IAAI,IAAI;AAC3B,QAAI,CAAC,SAAS;AACZ,gBAAU,CAAC;AACX,WAAK,IAAI,MAAM,OAAO;AAAA,IACxB;AACA,QAAI,CAAC,QAAQ,SAAS,WAAW,EAAG,SAAQ,KAAK,WAAW;AAAA,EAC9D;AACF;AAEO,MAAM,8BAA8B,CAAC,WAA8D;AACxG,QAAM,cAAc,kBAAkB,WAAW,SAAS,OAAO;AACjE,SAAO,yBAAa,YAAY,mCAAmC,WAAW;AAChF;AAEO,MAAM,kCAAkC,CAAC,WAAkD;AAChG,SAAO,yBAAa,mBAA4C,mCAAmC,MAAM;AAC3G;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var onConnectedInnerHtml_exports = {};
|
|
19
|
-
__export(onConnectedInnerHtml_exports, {
|
|
20
|
-
INNER_HTML_METADATA_KEY: () => INNER_HTML_METADATA_KEY,
|
|
21
|
-
getOnConnectedInnerHtmlMetadata: () => getOnConnectedInnerHtmlMetadata,
|
|
22
|
-
onConnectedInnerHtml: () => onConnectedInnerHtml
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(onConnectedInnerHtml_exports);
|
|
25
|
-
var import_core = require("@dooboostore/core");
|
|
26
|
-
const INNER_HTML_METADATA_KEY = Symbol("simple-web-component:inner-html");
|
|
27
|
-
function onConnectedInnerHtml(arg1, arg2, arg3) {
|
|
28
|
-
const decorator = (options, target, propertyKey) => {
|
|
29
|
-
const constructor = target.constructor;
|
|
30
|
-
let list = import_core.ReflectUtils.getMetadata(INNER_HTML_METADATA_KEY, constructor);
|
|
31
|
-
if (!list) {
|
|
32
|
-
list = [];
|
|
33
|
-
import_core.ReflectUtils.defineMetadata(INNER_HTML_METADATA_KEY, list, constructor);
|
|
34
|
-
}
|
|
35
|
-
list.push({ propertyKey, options });
|
|
36
|
-
};
|
|
37
|
-
if (arg2) {
|
|
38
|
-
return decorator({}, arg1, arg2);
|
|
39
|
-
}
|
|
40
|
-
return (target, propertyKey) => {
|
|
41
|
-
decorator(arg1 || {}, target, propertyKey);
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
const getOnConnectedInnerHtmlMetadata = (target) => {
|
|
45
|
-
const constructor = target instanceof Function ? target : target.constructor;
|
|
46
|
-
return import_core.ReflectUtils.getMetadata(INNER_HTML_METADATA_KEY, constructor);
|
|
47
|
-
};
|
|
48
|
-
//# sourceMappingURL=onConnectedInnerHtml.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/decorators/onConnectedInnerHtml.ts"],
|
|
4
|
-
"sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\n\nexport interface InnerHtmlOptions {\n useShadow?: boolean;\n}\n\nexport interface InnerHtmlMetadata {\n propertyKey: string | symbol;\n options: InnerHtmlOptions;\n}\n\nexport const INNER_HTML_METADATA_KEY = Symbol('simple-web-component:inner-html');\n\n/**\n * @onConnectedInnerHtml decorator to define the initial HTML content when connected.\n */\nexport function onConnectedInnerHtml(options: InnerHtmlOptions): MethodDecorator;\nexport function onConnectedInnerHtml(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function onConnectedInnerHtml(arg1?: InnerHtmlOptions | Object, arg2?: string | symbol, arg3?: PropertyDescriptor): MethodDecorator | void {\n const decorator = (options: InnerHtmlOptions, target: Object, propertyKey: string | symbol) => {\n const constructor = target.constructor;\n let list = ReflectUtils.getMetadata<InnerHtmlMetadata[]>(INNER_HTML_METADATA_KEY, constructor);\n if (!list) {\n list = [];\n ReflectUtils.defineMetadata(INNER_HTML_METADATA_KEY, list, constructor);\n }\n list.push({ propertyKey, options });\n };\n\n if (arg2) {\n return decorator({}, arg1!, arg2);\n }\n\n return (target: Object, propertyKey: string | symbol) => {\n decorator((arg1 as InnerHtmlOptions) || {}, target, propertyKey);\n };\n}\n\nexport const getOnConnectedInnerHtmlMetadata = (target: any): InnerHtmlMetadata[] | undefined => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getMetadata(INNER_HTML_METADATA_KEY, constructor);\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA6B;AAWtB,MAAM,0BAA0B,OAAO,iCAAiC;AAOxE,SAAS,qBAAqB,MAAkC,MAAwB,MAAmD;AAChJ,QAAM,YAAY,CAAC,SAA2B,QAAgB,gBAAiC;AAC7F,UAAM,cAAc,OAAO;AAC3B,QAAI,OAAO,yBAAa,YAAiC,yBAAyB,WAAW;AAC7F,QAAI,CAAC,MAAM;AACT,aAAO,CAAC;AACR,+BAAa,eAAe,yBAAyB,MAAM,WAAW;AAAA,IACxE;AACA,SAAK,KAAK,EAAE,aAAa,QAAQ,CAAC;AAAA,EACpC;AAEA,MAAI,MAAM;AACR,WAAO,UAAU,CAAC,GAAG,MAAO,IAAI;AAAA,EAClC;AAEA,SAAO,CAAC,QAAgB,gBAAiC;AACvD,cAAW,QAA6B,CAAC,GAAG,QAAQ,WAAW;AAAA,EACjE;AACF;AAEO,MAAM,kCAAkC,CAAC,WAAiD;AAC/F,QAAM,cAAc,kBAAkB,WAAW,SAAS,OAAO;AACjE,SAAO,yBAAa,YAAY,yBAAyB,WAAW;AACtE;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var replaceChildren_exports = {};
|
|
19
|
-
__export(replaceChildren_exports, {
|
|
20
|
-
REPLACE_CHILDREN_METADATA_KEY: () => REPLACE_CHILDREN_METADATA_KEY,
|
|
21
|
-
findAllReplaceChildrenMetadata: () => findAllReplaceChildrenMetadata,
|
|
22
|
-
getReplaceChildrenMetadata: () => getReplaceChildrenMetadata,
|
|
23
|
-
replaceChildren: () => replaceChildren
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(replaceChildren_exports);
|
|
26
|
-
var import_core = require("@dooboostore/core");
|
|
27
|
-
var import_elementDefine = require("./elementDefine");
|
|
28
|
-
const REPLACE_CHILDREN_METADATA_KEY = Symbol("simple-web-component:replace-children");
|
|
29
|
-
function replaceChildren(selector) {
|
|
30
|
-
return (target, propertyKey, descriptor) => {
|
|
31
|
-
const constructor = target.constructor;
|
|
32
|
-
let meta = import_core.ReflectUtils.getOwnMetadata(REPLACE_CHILDREN_METADATA_KEY, constructor);
|
|
33
|
-
if (!meta) {
|
|
34
|
-
meta = /* @__PURE__ */ new Map();
|
|
35
|
-
import_core.ReflectUtils.defineMetadata(REPLACE_CHILDREN_METADATA_KEY, meta, constructor);
|
|
36
|
-
}
|
|
37
|
-
meta.set(propertyKey, selector);
|
|
38
|
-
const original = descriptor.value;
|
|
39
|
-
descriptor.value = async function(...args) {
|
|
40
|
-
(0, import_elementDefine.ensureInit)(this);
|
|
41
|
-
const res = await original.apply(this, args);
|
|
42
|
-
if (res !== void 0) {
|
|
43
|
-
const conf = (0, import_elementDefine.getElementConfig)(this);
|
|
44
|
-
const currentWin = this._resolveWindow?.(conf) || (typeof window !== "undefined" ? window : void 0);
|
|
45
|
-
const currentDoc = currentWin.document;
|
|
46
|
-
let targetEl = null;
|
|
47
|
-
if (selector === ":host" || !selector) {
|
|
48
|
-
targetEl = this;
|
|
49
|
-
} else {
|
|
50
|
-
targetEl = (this.shadowRoot || this).querySelector(selector);
|
|
51
|
-
}
|
|
52
|
-
if (targetEl) {
|
|
53
|
-
if (typeof res === "string") {
|
|
54
|
-
targetEl.textContent = res;
|
|
55
|
-
} else {
|
|
56
|
-
const nodes = Array.isArray(res) ? res.map((n) => typeof n === "string" ? currentDoc.createTextNode(n) : n) : [res];
|
|
57
|
-
targetEl.replaceChildren(...nodes);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
return res;
|
|
62
|
-
};
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
const getReplaceChildrenMetadata = (target) => {
|
|
66
|
-
const constructor = target instanceof Function ? target : target.constructor;
|
|
67
|
-
return import_core.ReflectUtils.getMetadata(REPLACE_CHILDREN_METADATA_KEY, constructor);
|
|
68
|
-
};
|
|
69
|
-
const findAllReplaceChildrenMetadata = (target) => {
|
|
70
|
-
const result = /* @__PURE__ */ new Map();
|
|
71
|
-
const maps = import_core.ReflectUtils.findAllMetadata(REPLACE_CHILDREN_METADATA_KEY, target);
|
|
72
|
-
maps.forEach((map) => {
|
|
73
|
-
if (map instanceof Map) {
|
|
74
|
-
map.forEach((v, k) => result.set(k, v));
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
return result;
|
|
78
|
-
};
|
|
79
|
-
//# sourceMappingURL=replaceChildren.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/decorators/replaceChildren.ts"],
|
|
4
|
-
"sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { ensureInit, getElementConfig } from './elementDefine';\n\nexport const REPLACE_CHILDREN_METADATA_KEY = Symbol('simple-web-component:replace-children');\n\n/**\n * @replaceChildren decorator to surgically replace children of a target element.\n * Usage: @replaceChildren('#container') renderPart() { return '<div>New Content</div>'; }\n */\nexport function replaceChildren(selector: string): MethodDecorator {\n return (target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const constructor = target.constructor;\n let meta = ReflectUtils.getOwnMetadata(REPLACE_CHILDREN_METADATA_KEY, constructor) as Map<string | symbol, string>;\n if (!meta) {\n meta = new Map<string | symbol, string>();\n ReflectUtils.defineMetadata(REPLACE_CHILDREN_METADATA_KEY, meta, constructor);\n }\n meta.set(propertyKey, selector);\n\n const original = descriptor.value;\n descriptor.value = async function (...args: any[]) {\n ensureInit(this);\n const res = await original.apply(this, args);\n if (res !== undefined) {\n const conf = getElementConfig(this);\n const currentWin = (this as any)._resolveWindow?.(conf) || ((typeof window !== 'undefined' ? window : undefined) as Window);\n const currentDoc = currentWin.document;\n\n let targetEl: Element | null = null;\n if (selector === ':host' || !selector) {\n targetEl = this as any;\n } else {\n targetEl = (this.shadowRoot || (this as any)).querySelector(selector);\n }\n\n if (targetEl) {\n if (typeof res === 'string') {\n targetEl.textContent = res;\n } else {\n const nodes: Node[] = Array.isArray(res) ? res.map(n => (typeof n === 'string' ? currentDoc.createTextNode(n) : n)) : [res as Node];\n (targetEl as any).replaceChildren(...nodes);\n }\n }\n }\n return res;\n };\n };\n}\n\nexport const getReplaceChildrenMetadata = (target: any): Map<string | symbol, string> | undefined => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getMetadata(REPLACE_CHILDREN_METADATA_KEY, constructor);\n};\n\nexport const findAllReplaceChildrenMetadata = (target: any): Map<string | symbol, string> => {\n const result = new Map<string | symbol, string>();\n const maps = ReflectUtils.findAllMetadata<Map<string | symbol, string>>(REPLACE_CHILDREN_METADATA_KEY, target);\n maps.forEach(map => {\n if (map instanceof Map) {\n map.forEach((v, k) => result.set(k, v));\n }\n });\n return result;\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA6B;AAC7B,2BAA6C;AAEtC,MAAM,gCAAgC,OAAO,uCAAuC;AAMpF,SAAS,gBAAgB,UAAmC;AACjE,SAAO,CAAC,QAAgB,aAA8B,eAAmC;AACvF,UAAM,cAAc,OAAO;AAC3B,QAAI,OAAO,yBAAa,eAAe,+BAA+B,WAAW;AACjF,QAAI,CAAC,MAAM;AACT,aAAO,oBAAI,IAA6B;AACxC,+BAAa,eAAe,+BAA+B,MAAM,WAAW;AAAA,IAC9E;AACA,SAAK,IAAI,aAAa,QAAQ;AAE9B,UAAM,WAAW,WAAW;AAC5B,eAAW,QAAQ,kBAAmB,MAAa;AACjD,2CAAW,IAAI;AACf,YAAM,MAAM,MAAM,SAAS,MAAM,MAAM,IAAI;AAC3C,UAAI,QAAQ,QAAW;AACrB,cAAM,WAAO,uCAAiB,IAAI;AAClC,cAAM,aAAc,KAAa,iBAAiB,IAAI,MAAO,OAAO,WAAW,cAAc,SAAS;AACtG,cAAM,aAAa,WAAW;AAE9B,YAAI,WAA2B;AAC/B,YAAI,aAAa,WAAW,CAAC,UAAU;AACrC,qBAAW;AAAA,QACb,OAAO;AACL,sBAAY,KAAK,cAAe,MAAc,cAAc,QAAQ;AAAA,QACtE;AAEA,YAAI,UAAU;AACZ,cAAI,OAAO,QAAQ,UAAU;AAC3B,qBAAS,cAAc;AAAA,UACzB,OAAO;AACL,kBAAM,QAAgB,MAAM,QAAQ,GAAG,IAAI,IAAI,IAAI,OAAM,OAAO,MAAM,WAAW,WAAW,eAAe,CAAC,IAAI,CAAE,IAAI,CAAC,GAAW;AAClI,YAAC,SAAiB,gBAAgB,GAAG,KAAK;AAAA,UAC5C;AAAA,QACF;AAAA,MACF;AACA,aAAO;AAAA,IACT;AAAA,EACF;AACF;AAEO,MAAM,6BAA6B,CAAC,WAA0D;AACnG,QAAM,cAAc,kBAAkB,WAAW,SAAS,OAAO;AACjE,SAAO,yBAAa,YAAY,+BAA+B,WAAW;AAC5E;AAEO,MAAM,iCAAiC,CAAC,WAA8C;AAC3F,QAAM,SAAS,oBAAI,IAA6B;AAChD,QAAM,OAAO,yBAAa,gBAA8C,+BAA+B,MAAM;AAC7G,OAAK,QAAQ,SAAO;AAClB,QAAI,eAAe,KAAK;AACtB,UAAI,QAAQ,CAAC,GAAG,MAAM,OAAO,IAAI,GAAG,CAAC,CAAC;AAAA,IACxC;AAAA,EACF,CAAC;AACD,SAAO;AACT;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { ReflectUtils } from "@dooboostore/core";
|
|
2
|
-
import { ensureInit, getElementConfig } from "./elementDefine.js";
|
|
3
|
-
const APPEND_CHILD_METADATA_KEY = Symbol("simple-web-component:append-child");
|
|
4
|
-
const normalizeNodes = (res, doc) => {
|
|
5
|
-
const items = Array.isArray(res) ? res : [res];
|
|
6
|
-
return items.map((it) => {
|
|
7
|
-
if (it instanceof Node)
|
|
8
|
-
return it;
|
|
9
|
-
return doc.createTextNode(it !== void 0 && it !== null ? String(it) : "");
|
|
10
|
-
});
|
|
11
|
-
};
|
|
12
|
-
function appendChild(selector, options = { position: "beforeEnd" }) {
|
|
13
|
-
return (target, propertyKey, descriptor) => {
|
|
14
|
-
const constructor = target.constructor;
|
|
15
|
-
let metaList = ReflectUtils.getOwnMetadata(APPEND_CHILD_METADATA_KEY, constructor);
|
|
16
|
-
if (!metaList) {
|
|
17
|
-
metaList = /* @__PURE__ */ new Map();
|
|
18
|
-
ReflectUtils.defineMetadata(APPEND_CHILD_METADATA_KEY, metaList, constructor);
|
|
19
|
-
}
|
|
20
|
-
metaList.set(propertyKey, { propertyKey, selector, options });
|
|
21
|
-
const original = descriptor.value;
|
|
22
|
-
descriptor.value = async function(...args) {
|
|
23
|
-
ensureInit(this);
|
|
24
|
-
const res = await original.apply(this, args);
|
|
25
|
-
if (res !== void 0) {
|
|
26
|
-
const conf = getElementConfig(this);
|
|
27
|
-
const currentWin = this._resolveWindow?.(conf) || (typeof window !== "undefined" ? window : void 0);
|
|
28
|
-
const currentDoc = currentWin.document;
|
|
29
|
-
let targetEl = null;
|
|
30
|
-
if (selector === ":host" || !selector) {
|
|
31
|
-
targetEl = this;
|
|
32
|
-
} else {
|
|
33
|
-
targetEl = (this.shadowRoot || this).querySelector(selector);
|
|
34
|
-
}
|
|
35
|
-
if (targetEl) {
|
|
36
|
-
const nodes = normalizeNodes(res, currentDoc);
|
|
37
|
-
const pos = options.position || "beforeEnd";
|
|
38
|
-
if (typeof res === "string") {
|
|
39
|
-
targetEl.insertAdjacentText(pos, res);
|
|
40
|
-
} else if (Array.isArray(res) && res.every((n) => typeof n === "string")) {
|
|
41
|
-
targetEl.insertAdjacentText(pos, res.join(""));
|
|
42
|
-
} else {
|
|
43
|
-
if (pos === "beforeEnd")
|
|
44
|
-
targetEl.append(...nodes);
|
|
45
|
-
else if (pos === "afterBegin")
|
|
46
|
-
targetEl.prepend(...nodes);
|
|
47
|
-
else if (pos === "beforeBegin")
|
|
48
|
-
targetEl.before(...nodes);
|
|
49
|
-
else if (pos === "afterEnd")
|
|
50
|
-
targetEl.after(...nodes);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
return res;
|
|
55
|
-
};
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
const findAllAppendChildMetadata = (target) => {
|
|
59
|
-
const result = /* @__PURE__ */ new Map();
|
|
60
|
-
const maps = ReflectUtils.findAllMetadata(APPEND_CHILD_METADATA_KEY, target);
|
|
61
|
-
maps.forEach((map) => {
|
|
62
|
-
if (map instanceof Map) {
|
|
63
|
-
map.forEach((v, k) => result.set(k, v));
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
return result;
|
|
67
|
-
};
|
|
68
|
-
export {
|
|
69
|
-
APPEND_CHILD_METADATA_KEY,
|
|
70
|
-
appendChild,
|
|
71
|
-
findAllAppendChildMetadata
|
|
72
|
-
};
|
|
73
|
-
//# sourceMappingURL=appendChild.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/decorators/appendChild.ts"],
|
|
4
|
-
"sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { ensureInit, getElementConfig } from './elementDefine';\n\nexport type AppendChildPosition = 'beforeBegin' | 'afterBegin' | 'beforeEnd' | 'afterEnd';\n\nexport interface AppendChildOptions {\n position?: AppendChildPosition;\n}\n\nexport interface AppendChildMetadata {\n propertyKey: string | symbol;\n selector: string;\n options: AppendChildOptions;\n}\n\nexport const APPEND_CHILD_METADATA_KEY = Symbol('simple-web-component:append-child');\n\nconst normalizeNodes = (res: any, doc: Document): Node[] => {\n const items = Array.isArray(res) ? res : [res];\n return items.map(it => {\n if (it instanceof Node) return it;\n return doc.createTextNode(it !== undefined && it !== null ? String(it) : '');\n });\n};\n\n/**\n * @appendChild decorator to surgically add nodes to a target element.\n * Usage: @appendChild('#list') addItem() { return '<li>New Item</li>'; }\n */\nexport function appendChild(selector: string, options: AppendChildOptions = { position: 'beforeEnd' }): MethodDecorator {\n return (target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const constructor = target.constructor;\n let metaList = ReflectUtils.getOwnMetadata(APPEND_CHILD_METADATA_KEY, constructor) as Map<string | symbol, AppendChildMetadata>;\n if (!metaList) {\n metaList = new Map<string | symbol, AppendChildMetadata>();\n ReflectUtils.defineMetadata(APPEND_CHILD_METADATA_KEY, metaList, constructor);\n }\n metaList.set(propertyKey, { propertyKey, selector, options });\n\n const original = descriptor.value;\n descriptor.value = async function (...args: any[]) {\n ensureInit(this);\n const res = await original.apply(this, args);\n if (res !== undefined) {\n const conf = getElementConfig(this);\n const currentWin = (this as any)._resolveWindow?.(conf) || ((typeof window !== 'undefined' ? window : undefined) as Window);\n const currentDoc = currentWin.document;\n\n let targetEl: HTMLElement | null = null;\n if (selector === ':host' || !selector) {\n targetEl = this as any;\n } else {\n targetEl = (this.shadowRoot || (this as any)).querySelector(selector);\n }\n\n if (targetEl) {\n const nodes = normalizeNodes(res, currentDoc);\n const pos = options.position || 'beforeEnd';\n\n if (typeof res === 'string') {\n targetEl.insertAdjacentText(pos as InsertPosition, res);\n } else if (Array.isArray(res) && res.every(n => typeof n === 'string')) {\n targetEl.insertAdjacentText(pos as InsertPosition, res.join(''));\n } else {\n if (pos === 'beforeEnd') targetEl.append(...nodes);\n else if (pos === 'afterBegin') targetEl.prepend(...nodes);\n else if (pos === 'beforeBegin') targetEl.before(...nodes);\n else if (pos === 'afterEnd') targetEl.after(...nodes);\n }\n }\n }\n return res;\n };\n };\n}\n\nexport const findAllAppendChildMetadata = (target: any): Map<string | symbol, AppendChildMetadata> => {\n const result = new Map<string | symbol, AppendChildMetadata>();\n const maps = ReflectUtils.findAllMetadata<Map<string | symbol, AppendChildMetadata>>(APPEND_CHILD_METADATA_KEY, target);\n maps.forEach(map => {\n if (map instanceof Map) {\n map.forEach((v, k) => result.set(k, v));\n }\n });\n return result;\n};\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,oBAAoB;AAC7B,SAAS,YAAY,wBAAwB;AActC,MAAM,4BAA4B,OAAO,mCAAmC;AAEnF,MAAM,iBAAiB,CAAC,KAAU,QAAyB;AACzD,QAAM,QAAQ,MAAM,QAAQ,GAAG,IAAI,MAAM,CAAC,GAAG;AAC7C,SAAO,MAAM,IAAI,QAAK;AACpB,QAAI,cAAc;AAAM,aAAO;AAC/B,WAAO,IAAI,eAAe,OAAO,UAAa,OAAO,OAAO,OAAO,EAAE,IAAI,EAAE;EAC7E,CAAC;AACH;AAMM,SAAU,YAAY,UAAkB,UAA8B,EAAE,UAAU,YAAW,GAAE;AACnG,SAAO,CAAC,QAAgB,aAA8B,eAAkC;AACtF,UAAM,cAAc,OAAO;AAC3B,QAAI,WAAW,aAAa,eAAe,2BAA2B,WAAW;AACjF,QAAI,CAAC,UAAU;AACb,iBAAW,oBAAI,IAAG;AAClB,mBAAa,eAAe,2BAA2B,UAAU,WAAW;IAC9E;AACA,aAAS,IAAI,aAAa,EAAE,aAAa,UAAU,QAAO,CAAE;AAE5D,UAAM,WAAW,WAAW;AAC5B,eAAW,QAAQ,kBAAmB,MAAW;AAC/C,iBAAW,IAAI;AACf,YAAM,MAAM,MAAM,SAAS,MAAM,MAAM,IAAI;AAC3C,UAAI,QAAQ,QAAW;AACrB,cAAM,OAAO,iBAAiB,IAAI;AAClC,cAAM,aAAc,KAAa,iBAAiB,IAAI,MAAO,OAAO,WAAW,cAAc,SAAS;AACtG,cAAM,aAAa,WAAW;AAE9B,YAAI,WAA+B;AACnC,YAAI,aAAa,WAAW,CAAC,UAAU;AACrC,qBAAW;QACb,OAAO;AACL,sBAAY,KAAK,cAAe,MAAc,cAAc,QAAQ;QACtE;AAEA,YAAI,UAAU;AACZ,gBAAM,QAAQ,eAAe,KAAK,UAAU;AAC5C,gBAAM,MAAM,QAAQ,YAAY;AAEhC,cAAI,OAAO,QAAQ,UAAU;AAC3B,qBAAS,mBAAmB,KAAuB,GAAG;UACxD,WAAW,MAAM,QAAQ,GAAG,KAAK,IAAI,MAAM,OAAK,OAAO,MAAM,QAAQ,GAAG;AACtE,qBAAS,mBAAmB,KAAuB,IAAI,KAAK,EAAE,CAAC;UACjE,OAAO;AACL,gBAAI,QAAQ;AAAa,uBAAS,OAAO,GAAG,KAAK;qBACxC,QAAQ;AAAc,uBAAS,QAAQ,GAAG,KAAK;qBAC/C,QAAQ;AAAe,uBAAS,OAAO,GAAG,KAAK;qBAC/C,QAAQ;AAAY,uBAAS,MAAM,GAAG,KAAK;UACtD;QACF;MACF;AACA,aAAO;IACT;EACF;AACF;AAEO,MAAM,6BAA6B,CAAC,WAA0D;AACnG,QAAM,SAAS,oBAAI,IAAG;AACtB,QAAM,OAAO,aAAa,gBAA2D,2BAA2B,MAAM;AACtH,OAAK,QAAQ,SAAM;AACjB,QAAI,eAAe,KAAK;AACtB,UAAI,QAAQ,CAAC,GAAG,MAAM,OAAO,IAAI,GAAG,CAAC,CAAC;IACxC;EACF,CAAC;AACD,SAAO;AACT;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/decorators/changedAttribute.ts"],
|
|
4
|
-
"sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\n\nexport const ON_ATTRIBUTE_CHANGED_METADATA_KEY = Symbol('simple-web-component:on-attribute-changed');\n\nexport function changedAttribute(attributeName?: string): MethodDecorator {\n return (target: Object, propertyKey: string | symbol) => {\n const constructor = target.constructor;\n let meta = ReflectUtils.getOwnMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor) as Map<string, (string | symbol)[]>;\n if (!meta) {\n meta = new Map<string, (string | symbol)[]>();\n ReflectUtils.defineMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, meta, constructor);\n }\n\n const name = attributeName || String(propertyKey);\n let methods = meta.get(name);\n if (!methods) {\n methods = [];\n meta.set(name, methods);\n }\n if (!methods.includes(propertyKey)) methods.push(propertyKey);\n };\n}\n\nexport const getChangedAttributeMetadata = (target: any): Map<string, (string | symbol)[]> | undefined => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor);\n};\n\nexport const findAllAttributeChangedMetadata = (target: any): Map<string, (string | symbol)[]> => {\n return ReflectUtils.findAllMapMetadata<string, string | symbol>(ON_ATTRIBUTE_CHANGED_METADATA_KEY, target);\n};\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,oBAAoB;AAEtB,MAAM,oCAAoC,OAAO,2CAA2C;AAE5F,SAAS,iBAAiB,eAAyC;AACxE,SAAO,CAAC,QAAgB,gBAAiC;AACvD,UAAM,cAAc,OAAO;AAC3B,QAAI,OAAO,aAAa,eAAe,mCAAmC,WAAW;AACrF,QAAI,CAAC,MAAM;AACT,aAAO,oBAAI,IAAiC;AAC5C,mBAAa,eAAe,mCAAmC,MAAM,WAAW;AAAA,IAClF;AAEA,UAAM,OAAO,iBAAiB,OAAO,WAAW;AAChD,QAAI,UAAU,KAAK,IAAI,IAAI;AAC3B,QAAI,CAAC,SAAS;AACZ,gBAAU,CAAC;AACX,WAAK,IAAI,MAAM,OAAO;AAAA,IACxB;AACA,QAAI,CAAC,QAAQ,SAAS,WAAW,EAAG,SAAQ,KAAK,WAAW;AAAA,EAC9D;AACF;AAEO,MAAM,8BAA8B,CAAC,WAA8D;AACxG,QAAM,cAAc,kBAAkB,WAAW,SAAS,OAAO;AACjE,SAAO,aAAa,YAAY,mCAAmC,WAAW;AAChF;AAEO,MAAM,kCAAkC,CAAC,WAAkD;AAChG,SAAO,aAAa,mBAA4C,mCAAmC,MAAM;AAC3G;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { ReflectUtils } from "@dooboostore/core";
|
|
2
|
-
const INNER_HTML_METADATA_KEY = Symbol("simple-web-component:inner-html");
|
|
3
|
-
function onConnectedInnerHtml(arg1, arg2, arg3) {
|
|
4
|
-
const decorator = (options, target, propertyKey) => {
|
|
5
|
-
const constructor = target.constructor;
|
|
6
|
-
let list = ReflectUtils.getMetadata(INNER_HTML_METADATA_KEY, constructor);
|
|
7
|
-
if (!list) {
|
|
8
|
-
list = [];
|
|
9
|
-
ReflectUtils.defineMetadata(INNER_HTML_METADATA_KEY, list, constructor);
|
|
10
|
-
}
|
|
11
|
-
list.push({ propertyKey, options });
|
|
12
|
-
};
|
|
13
|
-
if (arg2) {
|
|
14
|
-
return decorator({}, arg1, arg2);
|
|
15
|
-
}
|
|
16
|
-
return (target, propertyKey) => {
|
|
17
|
-
decorator(arg1 || {}, target, propertyKey);
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
const getOnConnectedInnerHtmlMetadata = (target) => {
|
|
21
|
-
const constructor = target instanceof Function ? target : target.constructor;
|
|
22
|
-
return ReflectUtils.getMetadata(INNER_HTML_METADATA_KEY, constructor);
|
|
23
|
-
};
|
|
24
|
-
export {
|
|
25
|
-
INNER_HTML_METADATA_KEY,
|
|
26
|
-
getOnConnectedInnerHtmlMetadata,
|
|
27
|
-
onConnectedInnerHtml
|
|
28
|
-
};
|
|
29
|
-
//# sourceMappingURL=onConnectedInnerHtml.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/decorators/onConnectedInnerHtml.ts"],
|
|
4
|
-
"sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\n\nexport interface InnerHtmlOptions {\n useShadow?: boolean;\n}\n\nexport interface InnerHtmlMetadata {\n propertyKey: string | symbol;\n options: InnerHtmlOptions;\n}\n\nexport const INNER_HTML_METADATA_KEY = Symbol('simple-web-component:inner-html');\n\n/**\n * @onConnectedInnerHtml decorator to define the initial HTML content when connected.\n */\nexport function onConnectedInnerHtml(options: InnerHtmlOptions): MethodDecorator;\nexport function onConnectedInnerHtml(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function onConnectedInnerHtml(arg1?: InnerHtmlOptions | Object, arg2?: string | symbol, arg3?: PropertyDescriptor): MethodDecorator | void {\n const decorator = (options: InnerHtmlOptions, target: Object, propertyKey: string | symbol) => {\n const constructor = target.constructor;\n let list = ReflectUtils.getMetadata<InnerHtmlMetadata[]>(INNER_HTML_METADATA_KEY, constructor);\n if (!list) {\n list = [];\n ReflectUtils.defineMetadata(INNER_HTML_METADATA_KEY, list, constructor);\n }\n list.push({ propertyKey, options });\n };\n\n if (arg2) {\n return decorator({}, arg1!, arg2);\n }\n\n return (target: Object, propertyKey: string | symbol) => {\n decorator((arg1 as InnerHtmlOptions) || {}, target, propertyKey);\n };\n}\n\nexport const getOnConnectedInnerHtmlMetadata = (target: any): InnerHtmlMetadata[] | undefined => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getMetadata(INNER_HTML_METADATA_KEY, constructor);\n};\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,oBAAoB;AAWtB,MAAM,0BAA0B,OAAO,iCAAiC;AAOxE,SAAS,qBAAqB,MAAkC,MAAwB,MAAmD;AAChJ,QAAM,YAAY,CAAC,SAA2B,QAAgB,gBAAiC;AAC7F,UAAM,cAAc,OAAO;AAC3B,QAAI,OAAO,aAAa,YAAiC,yBAAyB,WAAW;AAC7F,QAAI,CAAC,MAAM;AACT,aAAO,CAAC;AACR,mBAAa,eAAe,yBAAyB,MAAM,WAAW;AAAA,IACxE;AACA,SAAK,KAAK,EAAE,aAAa,QAAQ,CAAC;AAAA,EACpC;AAEA,MAAI,MAAM;AACR,WAAO,UAAU,CAAC,GAAG,MAAO,IAAI;AAAA,EAClC;AAEA,SAAO,CAAC,QAAgB,gBAAiC;AACvD,cAAW,QAA6B,CAAC,GAAG,QAAQ,WAAW;AAAA,EACjE;AACF;AAEO,MAAM,kCAAkC,CAAC,WAAiD;AAC/F,QAAM,cAAc,kBAAkB,WAAW,SAAS,OAAO;AACjE,SAAO,aAAa,YAAY,yBAAyB,WAAW;AACtE;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|