@dooboostore/simple-web-component 1.0.22 → 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 +361 -19
- package/dist/cjs/decorators/applyNode.js +98 -24
- package/dist/cjs/decorators/applyNode.js.map +2 -2
- package/dist/cjs/decorators/attribute.js +0 -1
- package/dist/cjs/decorators/attribute.js.map +2 -2
- package/dist/cjs/decorators/classList.js +39 -19
- package/dist/cjs/decorators/classList.js.map +2 -2
- package/dist/cjs/decorators/elementDefine.js +1 -2
- package/dist/cjs/decorators/elementDefine.js.map +2 -2
- package/dist/cjs/decorators/index.js +0 -1
- package/dist/cjs/decorators/index.js.map +2 -2
- package/dist/cjs/decorators/lifecycles.js +25 -0
- package/dist/cjs/decorators/lifecycles.js.map +2 -2
- package/dist/cjs/decorators/query.js.map +2 -2
- package/dist/cjs/decorators/style.js +39 -13
- package/dist/cjs/decorators/style.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/applyNode.js +98 -24
- package/dist/esm/decorators/applyNode.js.map +2 -2
- package/dist/esm/decorators/attribute.js +0 -1
- package/dist/esm/decorators/attribute.js.map +2 -2
- package/dist/esm/decorators/classList.js +39 -19
- package/dist/esm/decorators/classList.js.map +2 -2
- package/dist/esm/decorators/elementDefine.js +1 -2
- package/dist/esm/decorators/elementDefine.js.map +2 -2
- package/dist/esm/decorators/index.js +0 -1
- package/dist/esm/decorators/index.js.map +2 -2
- package/dist/esm/decorators/lifecycles.js +25 -0
- package/dist/esm/decorators/lifecycles.js.map +2 -2
- package/dist/esm/decorators/query.js.map +2 -2
- package/dist/esm/decorators/style.js +39 -13
- package/dist/esm/decorators/style.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 +204 -81
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +3 -3
- package/dist/types/decorators/applyNode.d.ts +84 -1
- package/dist/types/decorators/applyNode.d.ts.map +1 -1
- package/dist/types/decorators/classList.d.ts +12 -10
- package/dist/types/decorators/classList.d.ts.map +1 -1
- package/dist/types/decorators/elementDefine.d.ts.map +1 -1
- package/dist/types/decorators/index.d.ts +0 -1
- package/dist/types/decorators/index.d.ts.map +1 -1
- package/dist/types/decorators/lifecycles.d.ts +14 -0
- package/dist/types/decorators/lifecycles.d.ts.map +1 -1
- package/dist/types/decorators/query.d.ts +0 -3
- package/dist/types/decorators/query.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/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 +204 -81
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +3 -3
- package/package.json +3 -3
- package/src/decorators/applyNode.ts +199 -36
- package/src/decorators/attribute.ts +1 -1
- package/src/decorators/classList.ts +45 -22
- package/src/decorators/elementDefine.ts +1 -2
- package/src/decorators/index.ts +0 -1
- package/src/decorators/lifecycles.ts +40 -0
- package/src/decorators/query.ts +0 -2
- package/src/decorators/style.ts +64 -13
- package/src/utils/TemplateUtils.ts +9 -0
- package/dist/cjs/decorators/onConnectedInnerHtml.js +0 -48
- package/dist/cjs/decorators/onConnectedInnerHtml.js.map +0 -7
- package/dist/esm/decorators/onConnectedInnerHtml.js +0 -29
- package/dist/esm/decorators/onConnectedInnerHtml.js.map +0 -7
- package/dist/types/decorators/onConnectedInnerHtml.d.ts +0 -15
- package/dist/types/decorators/onConnectedInnerHtml.d.ts.map +0 -1
- package/src/decorators/onConnectedInnerHtml.ts +0 -42
package/src/decorators/style.ts
CHANGED
|
@@ -1,19 +1,24 @@
|
|
|
1
1
|
import { ReflectUtils } from '@dooboostore/core';
|
|
2
2
|
import { ensureInit } from './elementDefine';
|
|
3
3
|
import { SwcUtils } from '../utils/Utils';
|
|
4
|
+
import { SwcQueryOptions } from '../types';
|
|
4
5
|
|
|
5
6
|
export type StyleAction = 'set' | 'update' | 'remove';
|
|
6
7
|
|
|
8
|
+
export interface StyleOptions extends SwcQueryOptions {
|
|
9
|
+
}
|
|
10
|
+
|
|
7
11
|
export interface StyleMetadata {
|
|
8
12
|
propertyKey: string | symbol;
|
|
9
13
|
selector: string;
|
|
10
14
|
action: StyleAction;
|
|
15
|
+
options: StyleOptions;
|
|
11
16
|
}
|
|
12
17
|
|
|
13
18
|
export const STYLE_METADATA_KEY = Symbol('simple-web-component:style');
|
|
14
19
|
|
|
15
20
|
function createStyleDecorator(action: StyleAction) {
|
|
16
|
-
return (selector: string): MethodDecorator => {
|
|
21
|
+
return (selector: string, options: StyleOptions = {}): MethodDecorator => {
|
|
17
22
|
return (target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {
|
|
18
23
|
const constructor = target.constructor;
|
|
19
24
|
let metaList = ReflectUtils.getOwnMetadata(STYLE_METADATA_KEY, constructor) as Map<string | symbol, StyleMetadata>;
|
|
@@ -21,21 +26,43 @@ function createStyleDecorator(action: StyleAction) {
|
|
|
21
26
|
metaList = new Map<string | symbol, StyleMetadata>();
|
|
22
27
|
ReflectUtils.defineMetadata(STYLE_METADATA_KEY, metaList, constructor);
|
|
23
28
|
}
|
|
24
|
-
metaList.set(propertyKey, { propertyKey, selector, action });
|
|
29
|
+
metaList.set(propertyKey, { propertyKey, selector, action, options });
|
|
25
30
|
|
|
26
31
|
const original = descriptor.value;
|
|
27
32
|
descriptor.value = async function (...args: any[]) {
|
|
28
33
|
ensureInit(this);
|
|
29
34
|
const res = await original.apply(this, args);
|
|
30
35
|
if (res !== undefined) {
|
|
36
|
+
const r = options.root || 'auto';
|
|
31
37
|
const hostSet = SwcUtils.getHostSet(this as any);
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
else
|
|
38
|
+
const targetEls: HTMLElement[] = [];
|
|
39
|
+
|
|
40
|
+
if (selector === ':host' || !selector) {
|
|
41
|
+
targetEls.push(this as any);
|
|
42
|
+
} else if (selector === ':parentHost') {
|
|
43
|
+
if (hostSet.$parentHost) targetEls.push(hostSet.$parentHost);
|
|
44
|
+
} else if (selector === ':appHost') {
|
|
45
|
+
if (hostSet.$appHost) targetEls.push(hostSet.$appHost);
|
|
46
|
+
} else {
|
|
47
|
+
if (r === 'shadow') {
|
|
48
|
+
const found = this.shadowRoot?.querySelectorAll(selector);
|
|
49
|
+
if (found) targetEls.push(...found);
|
|
50
|
+
} else if (r === 'light') {
|
|
51
|
+
const found = (this as any).querySelectorAll(selector);
|
|
52
|
+
if (found) targetEls.push(...found);
|
|
53
|
+
} else if (r === 'all') {
|
|
54
|
+
const sFound = this.shadowRoot?.querySelectorAll(selector);
|
|
55
|
+
const lFound = (this as any).querySelectorAll(selector);
|
|
56
|
+
if (sFound) targetEls.push(...sFound);
|
|
57
|
+
if (lFound) targetEls.push(...lFound);
|
|
58
|
+
} else {
|
|
59
|
+
// auto
|
|
60
|
+
const found = (this.shadowRoot || (this as any)).querySelectorAll(selector);
|
|
61
|
+
if (found) targetEls.push(...found);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
37
64
|
|
|
38
|
-
|
|
65
|
+
targetEls.forEach(targetEl => {
|
|
39
66
|
if (action === 'set') {
|
|
40
67
|
targetEl.style.cssText = '';
|
|
41
68
|
if (typeof res === 'object' && res !== null) {
|
|
@@ -49,9 +76,9 @@ function createStyleDecorator(action: StyleAction) {
|
|
|
49
76
|
}
|
|
50
77
|
} else if (action === 'remove') {
|
|
51
78
|
const props = Array.isArray(res) ? res : [res];
|
|
52
|
-
props.forEach(p => targetEl
|
|
79
|
+
props.forEach(p => targetEl.style.removeProperty(String(p)));
|
|
53
80
|
}
|
|
54
|
-
}
|
|
81
|
+
});
|
|
55
82
|
}
|
|
56
83
|
return res;
|
|
57
84
|
};
|
|
@@ -62,20 +89,44 @@ function createStyleDecorator(action: StyleAction) {
|
|
|
62
89
|
/**
|
|
63
90
|
* @setStyle decorator to surgically set styles on a target element (replaces all existing styles).
|
|
64
91
|
* Usage: @setStyle('#box') getStyles() { return { color: 'red', display: 'block' }; }
|
|
92
|
+
* Usage: @setStyle('#box', { root: 'shadow' }) getStyles() { return { color: 'red' }; }
|
|
65
93
|
*/
|
|
66
|
-
export const setStyle = createStyleDecorator('set');
|
|
94
|
+
export const setStyle = (selector: string, options: StyleOptions = {}) => createStyleDecorator('set')(selector, options);
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* @setStyleHost decorator - simplified version of @setStyle for :host selector.
|
|
98
|
+
* Usage: @setStyleHost getStyles() { return { color: 'red', display: 'block' }; }
|
|
99
|
+
* Usage: @setStyleHost({ root: 'shadow' }) getStyles() { return { color: 'red' }; }
|
|
100
|
+
*/
|
|
101
|
+
export const setStyleHost = (options: StyleOptions = {}) => createStyleDecorator('set')(':host', options);
|
|
67
102
|
|
|
68
103
|
/**
|
|
69
104
|
* @updateStyle decorator to surgically update styles on a target element (merges with existing styles).
|
|
70
105
|
* Usage: @updateStyle('#box') updateStyles() { return { color: 'blue' }; }
|
|
106
|
+
* Usage: @updateStyle('#box', { root: 'shadow' }) updateStyles() { return { color: 'blue' }; }
|
|
107
|
+
*/
|
|
108
|
+
export const updateStyle = (selector: string, options: StyleOptions = {}) => createStyleDecorator('update')(selector, options);
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* @updateStyleHost decorator - simplified version of @updateStyle for :host selector.
|
|
112
|
+
* Usage: @updateStyleHost updateStyles() { return { color: 'blue' }; }
|
|
113
|
+
* Usage: @updateStyleHost({ root: 'shadow' }) updateStyles() { return { color: 'blue' }; }
|
|
71
114
|
*/
|
|
72
|
-
export const
|
|
115
|
+
export const updateStyleHost = (options: StyleOptions = {}) => createStyleDecorator('update')(':host', options);
|
|
73
116
|
|
|
74
117
|
/**
|
|
75
118
|
* @removeStyle decorator to surgically remove styles from a target element.
|
|
76
119
|
* Usage: @removeStyle('#box') clearStyles() { return ['color', 'display']; }
|
|
120
|
+
* Usage: @removeStyle('#box', { root: 'shadow' }) clearStyles() { return ['color']; }
|
|
121
|
+
*/
|
|
122
|
+
export const removeStyle = (selector: string, options: StyleOptions = {}) => createStyleDecorator('remove')(selector, options);
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* @removeStyleHost decorator - simplified version of @removeStyle for :host selector.
|
|
126
|
+
* Usage: @removeStyleHost clearStyles() { return ['color', 'display']; }
|
|
127
|
+
* Usage: @removeStyleHost({ root: 'shadow' }) clearStyles() { return ['color']; }
|
|
77
128
|
*/
|
|
78
|
-
export const
|
|
129
|
+
export const removeStyleHost = (options: StyleOptions = {}) => createStyleDecorator('remove')(':host', options);
|
|
79
130
|
|
|
80
131
|
export const findAllStyleMetadata = (target: any): Map<string | symbol, StyleMetadata> => {
|
|
81
132
|
const result = new Map<string | symbol, StyleMetadata>();
|
|
@@ -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,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,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
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export interface InnerHtmlOptions {
|
|
2
|
-
useShadow?: boolean;
|
|
3
|
-
}
|
|
4
|
-
export interface InnerHtmlMetadata {
|
|
5
|
-
propertyKey: string | symbol;
|
|
6
|
-
options: InnerHtmlOptions;
|
|
7
|
-
}
|
|
8
|
-
export declare const INNER_HTML_METADATA_KEY: unique symbol;
|
|
9
|
-
/**
|
|
10
|
-
* @onConnectedInnerHtml decorator to define the initial HTML content when connected.
|
|
11
|
-
*/
|
|
12
|
-
export declare function onConnectedInnerHtml(options: InnerHtmlOptions): MethodDecorator;
|
|
13
|
-
export declare function onConnectedInnerHtml(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;
|
|
14
|
-
export declare const getOnConnectedInnerHtmlMetadata: (target: any) => InnerHtmlMetadata[] | undefined;
|
|
15
|
-
//# sourceMappingURL=onConnectedInnerHtml.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"onConnectedInnerHtml.d.ts","sourceRoot":"","sources":["../../../src/decorators/onConnectedInnerHtml.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,gBAAgB;IAC/B,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,iBAAiB;IAChC,WAAW,EAAE,MAAM,GAAG,MAAM,CAAC;IAC7B,OAAO,EAAE,gBAAgB,CAAC;CAC3B;AAED,eAAO,MAAM,uBAAuB,eAA4C,CAAC;AAEjF;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,gBAAgB,GAAG,eAAe,CAAC;AACjF,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE,UAAU,EAAE,kBAAkB,GAAG,IAAI,CAAC;AAqBzH,eAAO,MAAM,+BAA+B,GAAI,QAAQ,GAAG,KAAG,iBAAiB,EAAE,GAAG,SAGnF,CAAC"}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { ReflectUtils } from '@dooboostore/core';
|
|
2
|
-
|
|
3
|
-
export interface InnerHtmlOptions {
|
|
4
|
-
useShadow?: boolean;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export interface InnerHtmlMetadata {
|
|
8
|
-
propertyKey: string | symbol;
|
|
9
|
-
options: InnerHtmlOptions;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export const INNER_HTML_METADATA_KEY = Symbol('simple-web-component:inner-html');
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* @onConnectedInnerHtml decorator to define the initial HTML content when connected.
|
|
16
|
-
*/
|
|
17
|
-
export function onConnectedInnerHtml(options: InnerHtmlOptions): MethodDecorator;
|
|
18
|
-
export function onConnectedInnerHtml(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;
|
|
19
|
-
export function onConnectedInnerHtml(arg1?: InnerHtmlOptions | Object, arg2?: string | symbol, arg3?: PropertyDescriptor): MethodDecorator | void {
|
|
20
|
-
const decorator = (options: InnerHtmlOptions, target: Object, propertyKey: string | symbol) => {
|
|
21
|
-
const constructor = target.constructor;
|
|
22
|
-
let list = ReflectUtils.getMetadata<InnerHtmlMetadata[]>(INNER_HTML_METADATA_KEY, constructor);
|
|
23
|
-
if (!list) {
|
|
24
|
-
list = [];
|
|
25
|
-
ReflectUtils.defineMetadata(INNER_HTML_METADATA_KEY, list, constructor);
|
|
26
|
-
}
|
|
27
|
-
list.push({ propertyKey, options });
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
if (arg2) {
|
|
31
|
-
return decorator({}, arg1!, arg2);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
return (target: Object, propertyKey: string | symbol) => {
|
|
35
|
-
decorator((arg1 as InnerHtmlOptions) || {}, target, propertyKey);
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export const getOnConnectedInnerHtmlMetadata = (target: any): InnerHtmlMetadata[] | undefined => {
|
|
40
|
-
const constructor = target instanceof Function ? target : target.constructor;
|
|
41
|
-
return ReflectUtils.getMetadata(INNER_HTML_METADATA_KEY, constructor);
|
|
42
|
-
};
|