@dooboostore/simple-web-component 1.0.24 → 1.0.26
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 +162 -33
- package/dist/cjs/decorators/addEventListener.js +1 -1
- package/dist/cjs/decorators/addEventListener.js.map +2 -2
- package/dist/cjs/decorators/applyAttribute.js +148 -0
- package/dist/cjs/decorators/applyAttribute.js.map +7 -0
- package/dist/cjs/decorators/applyClass.js +164 -0
- package/dist/cjs/decorators/applyClass.js.map +7 -0
- package/dist/cjs/decorators/applyNode.js +87 -194
- package/dist/cjs/decorators/applyNode.js.map +2 -2
- package/dist/cjs/decorators/{style.js → applyStyle.js} +50 -60
- package/dist/cjs/decorators/applyStyle.js.map +7 -0
- package/dist/cjs/decorators/attribute.js +10 -16
- package/dist/cjs/decorators/attribute.js.map +2 -2
- package/dist/cjs/decorators/changedAttributeHost.js +1 -1
- package/dist/cjs/decorators/changedAttributeHost.js.map +2 -2
- package/dist/cjs/decorators/elementDefine.js +14 -23
- package/dist/cjs/decorators/elementDefine.js.map +2 -2
- package/dist/cjs/decorators/emitCustomEvent.js +5 -2
- package/dist/cjs/decorators/emitCustomEvent.js.map +2 -2
- package/dist/cjs/decorators/index.js +3 -3
- package/dist/cjs/decorators/index.js.map +2 -2
- package/dist/cjs/decorators/lifecycles.js +9 -9
- package/dist/cjs/decorators/lifecycles.js.map +2 -2
- package/dist/cjs/decorators/query.js +1 -1
- package/dist/cjs/decorators/query.js.map +2 -2
- package/dist/cjs/decorators/queryAll.js +1 -1
- package/dist/cjs/decorators/queryAll.js.map +2 -2
- package/dist/cjs/elements/SwcAppEngine.js +19 -4
- package/dist/cjs/elements/SwcAppEngine.js.map +2 -2
- package/dist/cjs/elements/SwcAppMixin.js +2 -0
- package/dist/cjs/elements/SwcAppMixin.js.map +2 -2
- package/dist/cjs/utils/Utils.js +1 -1
- package/dist/cjs/utils/Utils.js.map +2 -2
- package/dist/esm/decorators/addEventListener.js +1 -1
- package/dist/esm/decorators/addEventListener.js.map +2 -2
- package/dist/esm/decorators/applyAttribute.js +129 -0
- package/dist/esm/decorators/applyAttribute.js.map +7 -0
- package/dist/esm/decorators/applyClass.js +145 -0
- package/dist/esm/decorators/applyClass.js.map +7 -0
- package/dist/esm/decorators/applyNode.js +87 -194
- package/dist/esm/decorators/applyNode.js.map +2 -2
- package/dist/esm/decorators/{style.js → applyStyle.js} +47 -57
- package/dist/esm/decorators/applyStyle.js.map +7 -0
- package/dist/esm/decorators/attribute.js +10 -16
- package/dist/esm/decorators/attribute.js.map +2 -2
- package/dist/esm/decorators/changedAttributeHost.js +1 -1
- package/dist/esm/decorators/changedAttributeHost.js.map +2 -2
- package/dist/esm/decorators/elementDefine.js +14 -23
- package/dist/esm/decorators/elementDefine.js.map +2 -2
- package/dist/esm/decorators/emitCustomEvent.js +5 -2
- package/dist/esm/decorators/emitCustomEvent.js.map +2 -2
- package/dist/esm/decorators/index.js +3 -3
- package/dist/esm/decorators/index.js.map +1 -1
- package/dist/esm/decorators/lifecycles.js +9 -9
- package/dist/esm/decorators/lifecycles.js.map +2 -2
- package/dist/esm/decorators/query.js +1 -1
- package/dist/esm/decorators/query.js.map +2 -2
- package/dist/esm/decorators/queryAll.js +1 -1
- package/dist/esm/decorators/queryAll.js.map +2 -2
- package/dist/esm/elements/SwcAppEngine.js +19 -4
- package/dist/esm/elements/SwcAppEngine.js.map +2 -2
- package/dist/esm/elements/SwcAppMixin.js +2 -0
- package/dist/esm/elements/SwcAppMixin.js.map +2 -2
- package/dist/esm/utils/Utils.js +1 -1
- package/dist/esm/utils/Utils.js.map +2 -2
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +2853 -574
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +4 -4
- package/dist/types/decorators/addEventListener.d.ts.map +1 -1
- package/dist/types/decorators/applyAttribute.d.ts +22 -0
- package/dist/types/decorators/applyAttribute.d.ts.map +1 -0
- package/dist/types/decorators/applyClass.d.ts +65 -0
- package/dist/types/decorators/applyClass.d.ts.map +1 -0
- package/dist/types/decorators/applyNode.d.ts +15 -123
- package/dist/types/decorators/applyNode.d.ts.map +1 -1
- package/dist/types/decorators/applyStyle.d.ts +21 -0
- package/dist/types/decorators/applyStyle.d.ts.map +1 -0
- package/dist/types/decorators/attribute.d.ts +10 -19
- package/dist/types/decorators/attribute.d.ts.map +1 -1
- package/dist/types/decorators/changedAttributeHost.d.ts.map +1 -1
- package/dist/types/decorators/elementDefine.d.ts.map +1 -1
- package/dist/types/decorators/emitCustomEvent.d.ts +1 -1
- package/dist/types/decorators/emitCustomEvent.d.ts.map +1 -1
- package/dist/types/decorators/index.d.ts +3 -3
- package/dist/types/decorators/index.d.ts.map +1 -1
- package/dist/types/decorators/lifecycles.d.ts.map +1 -1
- package/dist/types/decorators/query.d.ts.map +1 -1
- package/dist/types/decorators/queryAll.d.ts.map +1 -1
- package/dist/types/elements/SwcAppEngine.d.ts +7 -0
- package/dist/types/elements/SwcAppEngine.d.ts.map +1 -1
- package/dist/types/elements/SwcAppMixin.d.ts +1 -1
- package/dist/types/elements/SwcAppMixin.d.ts.map +1 -1
- package/dist/types/utils/Utils.d.ts.map +1 -1
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +2853 -574
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +4 -4
- package/package.json +2 -2
- package/src/decorators/addEventListener.ts +1 -1
- package/src/decorators/applyAttribute.ts +147 -0
- package/src/decorators/applyClass.ts +158 -0
- package/src/decorators/applyNode.ts +112 -330
- package/src/decorators/applyStyle.ts +128 -0
- package/src/decorators/attribute.ts +21 -55
- package/src/decorators/changedAttributeHost.ts +1 -1
- package/src/decorators/elementDefine.ts +18 -39
- package/src/decorators/emitCustomEvent.ts +6 -3
- package/src/decorators/index.ts +3 -3
- package/src/decorators/lifecycles.ts +9 -11
- package/src/decorators/query.ts +1 -1
- package/src/decorators/queryAll.ts +1 -1
- package/src/elements/SwcAppEngine.ts +32 -4
- package/src/elements/SwcAppMixin.ts +2 -0
- package/src/utils/Utils.ts +2 -1
- package/dist/cjs/decorators/classList.js +0 -177
- package/dist/cjs/decorators/classList.js.map +0 -7
- package/dist/cjs/decorators/setAttribute.js +0 -111
- package/dist/cjs/decorators/setAttribute.js.map +0 -7
- package/dist/cjs/decorators/style.js.map +0 -7
- package/dist/esm/decorators/classList.js +0 -158
- package/dist/esm/decorators/classList.js.map +0 -7
- package/dist/esm/decorators/setAttribute.js +0 -92
- package/dist/esm/decorators/setAttribute.js.map +0 -7
- package/dist/esm/decorators/style.js.map +0 -7
- package/dist/types/decorators/classList.d.ts +0 -71
- package/dist/types/decorators/classList.d.ts.map +0 -1
- package/dist/types/decorators/setAttribute.d.ts +0 -23
- package/dist/types/decorators/setAttribute.d.ts.map +0 -1
- package/dist/types/decorators/style.d.ts +0 -58
- package/dist/types/decorators/style.d.ts.map +0 -1
- package/src/decorators/classList.ts +0 -234
- package/src/decorators/setAttribute.ts +0 -114
- package/src/decorators/style.ts +0 -185
package/README.md
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
# @dooboostore/simple-web-component (SWC)
|
|
2
|
+
[](https://www.npmjs.com/package/@dooboostore/simple-web-component)
|
|
3
|
+
[](https://github.com/dooboostore-develop/packages/actions/workflows/main.yaml)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
2
5
|
|
|
3
6
|
> **"Pure, Standards-Compliant, and Blazing Fast Web Components Framework."**
|
|
4
7
|
|
|
5
|
-
`simple-web-component` (SWC) is a minimalist library designed for building high-performance Web Components and Single Page Applications (SPA). It
|
|
8
|
+
`simple-web-component` (SWC) is a minimalist library designed for building high-performance Web Components and Single Page Applications (SPA). It follows a **Pure Architecture** that adheres strictly to browser standards, avoiding heavy Proxy traps or Virtual DOM overhead.
|
|
6
9
|
|
|
7
10
|
---
|
|
8
11
|
|
|
@@ -265,7 +268,7 @@ Bidirectional attribute binding with automatic type conversion on `:host` elemen
|
|
|
265
268
|
|
|
266
269
|
All usage patterns support automatic field-name-to-attribute-name conversion:
|
|
267
270
|
- Without parentheses: `@attributeHost` - uses field name as attribute name
|
|
268
|
-
- Empty parentheses: `@attributeHost()` - uses field name as attribute name
|
|
271
|
+
- Empty parentheses: `@attributeHost()` - uses field name as attribute name
|
|
269
272
|
- Options only: `@attributeHost({ connectedInitialize: true })` - uses field name as attribute name
|
|
270
273
|
- Custom name: `@attributeHost('custom-name')` - explicit attribute name
|
|
271
274
|
- Custom name + options: `@attributeHost('custom-name', { type: Boolean })` - both specified
|
|
@@ -319,7 +322,48 @@ class ReactiveInput extends HTMLElement {
|
|
|
319
322
|
}
|
|
320
323
|
```
|
|
321
324
|
|
|
322
|
-
#### 12. `@
|
|
325
|
+
#### 12. `@applyAttribute(selector, action?, options?)` - Universal Attribute Manipulation
|
|
326
|
+
|
|
327
|
+
Universal decorator for handling attributes with flexible strategies.
|
|
328
|
+
|
|
329
|
+
```typescript
|
|
330
|
+
@elementDefine('attribute-demo')
|
|
331
|
+
class AttributeDemo extends HTMLElement {
|
|
332
|
+
private status = 'active';
|
|
333
|
+
private priority = 1;
|
|
334
|
+
|
|
335
|
+
// Set attribute (replace all)
|
|
336
|
+
@applyAttribute('.status', 'set')
|
|
337
|
+
setStatus() {
|
|
338
|
+
return { 'data-status': this.status, 'aria-busy': 'false' };
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
// Update attribute (merge)
|
|
342
|
+
@applyAttribute('.priority', 'update')
|
|
343
|
+
updatePriority() {
|
|
344
|
+
return { 'data-priority': this.priority.toString() };
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
// Remove attribute
|
|
348
|
+
@applyAttribute('.temp', 'remove')
|
|
349
|
+
removeTemp() {
|
|
350
|
+
return ['data-temp'];
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
@onConnectedInnerHtml
|
|
354
|
+
render() {
|
|
355
|
+
return `
|
|
356
|
+
<div class="status">Status: ${this.status}</div>
|
|
357
|
+
<div class="priority">Priority: ${this.priority}</div>
|
|
358
|
+
<div class="temp">Temporary</div>
|
|
359
|
+
`;
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
**Convenience Methods** (specific actions):
|
|
365
|
+
|
|
366
|
+
#### 12a. `@setAttribute(selector, name, options?)` - Set Single Attribute
|
|
323
367
|
Reflect method's return value to a target element's DOM attribute. One-way binding (class → DOM).
|
|
324
368
|
|
|
325
369
|
```typescript
|
|
@@ -370,13 +414,35 @@ class StatusBadge extends HTMLElement {
|
|
|
370
414
|
- `@setAttribute(selector, attributeName, options?)`
|
|
371
415
|
- Returns method's value → reflects to target's attribute
|
|
372
416
|
|
|
417
|
+
#### 12c. `@updateAttribute(selector, name, options?)` - Update Attribute
|
|
418
|
+
|
|
419
|
+
Merge return value with existing attributes instead of replacing.
|
|
420
|
+
|
|
421
|
+
```typescript
|
|
422
|
+
@updateAttribute(':host', 'data-modified')
|
|
423
|
+
updateModifiedTime() {
|
|
424
|
+
return new Date().toISOString();
|
|
425
|
+
}
|
|
426
|
+
```
|
|
427
|
+
|
|
428
|
+
#### 12d. `@removeAttribute(selector, name, options?)` - Remove Attribute
|
|
429
|
+
|
|
430
|
+
Remove specific attributes from target elements.
|
|
431
|
+
|
|
432
|
+
```typescript
|
|
433
|
+
@removeAttribute('.disabled-item', 'data-active')
|
|
434
|
+
removeActive() {
|
|
435
|
+
return true; // Remove if truthy
|
|
436
|
+
}
|
|
437
|
+
```
|
|
438
|
+
|
|
373
439
|
**Selectors:**
|
|
374
440
|
- `':host'` - The component itself
|
|
375
441
|
- `'#element-id'` - Element by ID
|
|
376
442
|
- `'.class-name'` - Element by class
|
|
377
443
|
- `selector` - Any CSS selector
|
|
378
444
|
|
|
379
|
-
####
|
|
445
|
+
#### 12e. `@setAttributeHost(name, options?)` - Shorthand for `:host`
|
|
380
446
|
Simplified version of `@setAttribute` that always targets `:host`.
|
|
381
447
|
|
|
382
448
|
```typescript
|
|
@@ -939,7 +1005,7 @@ class MyComponent extends HTMLElement {
|
|
|
939
1005
|
```
|
|
940
1006
|
|
|
941
1007
|
**Return Types by Position:**
|
|
942
|
-
- `beforeBegin`, `afterBegin`, `beforeEnd`, `afterEnd`: **Node | Node[]**
|
|
1008
|
+
- `beforeBegin`, `afterBegin`, `beforeEnd`, `afterEnd`: **Node | Node[]**
|
|
943
1009
|
- `replace`: **Node**
|
|
944
1010
|
- `replaceChildren`: **Node | Node[]**
|
|
945
1011
|
- `innerHtml`: **string**
|
|
@@ -964,7 +1030,44 @@ class MyComponent extends HTMLElement {
|
|
|
964
1030
|
|
|
965
1031
|
**All functions accept optional `doc` parameter for SSR support.**
|
|
966
1032
|
|
|
967
|
-
#### 20. `@
|
|
1033
|
+
#### 20. `@applyStyle(selector, action?, options?)` - Universal Style Manipulation
|
|
1034
|
+
|
|
1035
|
+
Universal decorator for style operations with flexible strategies.
|
|
1036
|
+
|
|
1037
|
+
```typescript
|
|
1038
|
+
@elementDefine('style-demo')
|
|
1039
|
+
class StyleDemo extends HTMLElement {
|
|
1040
|
+
private isDark = false;
|
|
1041
|
+
|
|
1042
|
+
// Set styles (replace all inline styles)
|
|
1043
|
+
@applyStyle('.panel', 'set')
|
|
1044
|
+
setDarkMode() {
|
|
1045
|
+
return this.isDark ? {
|
|
1046
|
+
backgroundColor: '#222',
|
|
1047
|
+
color: '#fff'
|
|
1048
|
+
} : {
|
|
1049
|
+
backgroundColor: '#fff',
|
|
1050
|
+
color: '#000'
|
|
1051
|
+
};
|
|
1052
|
+
}
|
|
1053
|
+
|
|
1054
|
+
// Update styles (merge with existing)
|
|
1055
|
+
@applyStyle('.btn', 'update')
|
|
1056
|
+
addBtnStyle() {
|
|
1057
|
+
return { padding: '10px', cursor: 'pointer' };
|
|
1058
|
+
}
|
|
1059
|
+
|
|
1060
|
+
// Remove styles (delete properties)
|
|
1061
|
+
@applyStyle('.temp', 'remove')
|
|
1062
|
+
clearTempStyle() {
|
|
1063
|
+
return ['transition', 'transform'];
|
|
1064
|
+
}
|
|
1065
|
+
}
|
|
1066
|
+
```
|
|
1067
|
+
|
|
1068
|
+
**Convenience Methods** (specific actions):
|
|
1069
|
+
|
|
1070
|
+
#### 20a. `@setStyle(selector, options?)` / `@updateStyle(selector, options?)` / `@removeStyle(selector, options?)`
|
|
968
1071
|
|
|
969
1072
|
Manipulate CSS styles on elements with full Shadow DOM support.
|
|
970
1073
|
|
|
@@ -1044,16 +1147,45 @@ clearHostStyle() {
|
|
|
1044
1147
|
|
|
1045
1148
|
---
|
|
1046
1149
|
|
|
1047
|
-
#### 21. `@
|
|
1150
|
+
#### 21. `@applyClass(selector, action?, options?)` - Universal Class Manipulation
|
|
1151
|
+
|
|
1152
|
+
Universal decorator for class operations with flexible strategies.
|
|
1153
|
+
|
|
1154
|
+
```typescript
|
|
1155
|
+
@elementDefine('class-demo')
|
|
1156
|
+
class ClassDemo extends HTMLElement {
|
|
1157
|
+
private isActive = false;
|
|
1158
|
+
private isLoading = false;
|
|
1159
|
+
|
|
1160
|
+
@applyClass('.item', 'set')
|
|
1161
|
+
setClasses() {
|
|
1162
|
+
return this.isActive ? ['active', 'highlight'] : ['inactive'];
|
|
1163
|
+
}
|
|
1164
|
+
|
|
1165
|
+
@applyClass('.spinner', 'update')
|
|
1166
|
+
updateSpinner() {
|
|
1167
|
+
return this.isLoading ? ['spinning', 'visible'] : ['hidden'];
|
|
1168
|
+
}
|
|
1169
|
+
|
|
1170
|
+
@applyClass('.temp', 'remove')
|
|
1171
|
+
removeTempClasses() {
|
|
1172
|
+
return ['temporary', 'debug'];
|
|
1173
|
+
}
|
|
1174
|
+
}
|
|
1175
|
+
```
|
|
1176
|
+
|
|
1177
|
+
**Convenience Methods** (specific actions):
|
|
1178
|
+
|
|
1179
|
+
#### 21a. `@setClass(selector, options?)` / `@addClass(selector, options?)` / `@removeClass(selector, options?)` / `@toggleClass(selector, options?)` / `@updateClass(selector, options?)`
|
|
1048
1180
|
|
|
1049
1181
|
Manipulate CSS classes on elements declaratively with Shadow DOM support.
|
|
1050
1182
|
|
|
1051
1183
|
**Core Features:**
|
|
1052
|
-
- `@
|
|
1053
|
-
- `@
|
|
1054
|
-
- `@
|
|
1055
|
-
- `@
|
|
1056
|
-
- `@
|
|
1184
|
+
- `@addClass` - Add classes
|
|
1185
|
+
- `@removeClass` - Remove classes
|
|
1186
|
+
- `@toggleClass` - Toggle classes (returns boolean or bool array)
|
|
1187
|
+
- `@setClass` - Replace all classes
|
|
1188
|
+
- `@updateClass` - Merge with existing classes
|
|
1057
1189
|
- `root` option for DOM layer targeting
|
|
1058
1190
|
- Support for multiple elements
|
|
1059
1191
|
|
|
@@ -1062,22 +1194,22 @@ Manipulate CSS classes on elements declaratively with Shadow DOM support.
|
|
|
1062
1194
|
class TabComponent extends HTMLElement {
|
|
1063
1195
|
activeTab = 'home';
|
|
1064
1196
|
|
|
1065
|
-
@
|
|
1197
|
+
@addClass('.tab', { root: 'shadow' })
|
|
1066
1198
|
addTabClasses() {
|
|
1067
1199
|
return ['interactive', 'focusable'];
|
|
1068
1200
|
}
|
|
1069
1201
|
|
|
1070
|
-
@
|
|
1202
|
+
@toggleClass('.tab', { root: 'shadow' })
|
|
1071
1203
|
toggleActiveTab() {
|
|
1072
1204
|
return this.activeTab === 'home'; // Returns boolean for all matched elements
|
|
1073
1205
|
}
|
|
1074
1206
|
|
|
1075
|
-
@
|
|
1207
|
+
@removeClass('.tab-inactive', { root: 'shadow' })
|
|
1076
1208
|
removeInactiveClass() {
|
|
1077
1209
|
return ['disabled'];
|
|
1078
1210
|
}
|
|
1079
1211
|
|
|
1080
|
-
@
|
|
1212
|
+
@setClass('.tab-pane', { root: 'shadow' })
|
|
1081
1213
|
updateTabPane() {
|
|
1082
1214
|
return [`pane-${this.activeTab}`, 'content'];
|
|
1083
1215
|
}
|
|
@@ -1104,32 +1236,32 @@ class TabComponent extends HTMLElement {
|
|
|
1104
1236
|
Note: `:host` selector targets the component itself (boundary), so `root` option is ignored.
|
|
1105
1237
|
|
|
1106
1238
|
All Host variants support three usage patterns:
|
|
1107
|
-
- Without parentheses: `@
|
|
1108
|
-
- With empty parentheses: `@
|
|
1109
|
-
- With options: `@
|
|
1239
|
+
- Without parentheses: `@setClassHost` setHostClasses() { ... }
|
|
1240
|
+
- With empty parentheses: `@setClassHost()` setHostClasses() { ... }
|
|
1241
|
+
- With options: `@setClassHost({ ... })` setHostClasses() { ... }
|
|
1110
1242
|
|
|
1111
1243
|
```typescript
|
|
1112
|
-
@
|
|
1244
|
+
@addClassHost
|
|
1113
1245
|
addHostClasses() {
|
|
1114
1246
|
return ['component', 'interactive'];
|
|
1115
1247
|
}
|
|
1116
1248
|
|
|
1117
|
-
@
|
|
1249
|
+
@removeClassHost()
|
|
1118
1250
|
removeHostClasses() {
|
|
1119
1251
|
return ['loading'];
|
|
1120
1252
|
}
|
|
1121
1253
|
|
|
1122
|
-
@
|
|
1254
|
+
@toggleClassHost()
|
|
1123
1255
|
toggleHostClass() {
|
|
1124
1256
|
return this.isOpen; // Apply 'open' class if true
|
|
1125
1257
|
}
|
|
1126
1258
|
|
|
1127
|
-
@
|
|
1259
|
+
@setClassHost
|
|
1128
1260
|
setHostClasses() {
|
|
1129
1261
|
return this.isOpen ? ['open', 'expanded'] : ['closed'];
|
|
1130
1262
|
}
|
|
1131
1263
|
|
|
1132
|
-
@
|
|
1264
|
+
@updateClassHost()
|
|
1133
1265
|
updateHostClasses() {
|
|
1134
1266
|
return ['visible'];
|
|
1135
1267
|
}
|
|
@@ -1145,14 +1277,14 @@ Marks a class as a **Singleton** in the `<swc-app>` DI container for **construct
|
|
|
1145
1277
|
**Two DI Mechanisms:**
|
|
1146
1278
|
|
|
1147
1279
|
1. **Lifecycle DI** (`@onBeforeConnected`, etc.) - ❌ NO `@Sim` needed
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1280
|
+
- Works on any `@elementDefine` component
|
|
1281
|
+
- Services injected via method parameters
|
|
1282
|
+
- Can be used outside `<swc-app>`
|
|
1151
1283
|
|
|
1152
1284
|
2. **Constructor DI** - ✅ `@Sim` REQUIRED
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1285
|
+
- Only works inside `<swc-app>` boundary
|
|
1286
|
+
- Both provider AND consumer need `@Sim`
|
|
1287
|
+
- Singleton pattern within the app
|
|
1156
1288
|
|
|
1157
1289
|
**Example: Both Approaches**
|
|
1158
1290
|
|
|
@@ -2169,9 +2301,6 @@ class UserListPage extends HTMLElement {
|
|
|
2169
2301
|
}
|
|
2170
2302
|
}
|
|
2171
2303
|
|
|
2172
|
-
@classList('active')
|
|
2173
|
-
isActive = false;
|
|
2174
|
-
|
|
2175
2304
|
@onConnectedInnerHtml
|
|
2176
2305
|
render() {
|
|
2177
2306
|
return `
|
|
@@ -24,7 +24,7 @@ __export(addEventListener_exports, {
|
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(addEventListener_exports);
|
|
26
26
|
var import_core = require("@dooboostore/core");
|
|
27
|
-
const ADD_EVENT_LISTENER_METADATA_KEY = Symbol("simple-web-component:add-event-listener");
|
|
27
|
+
const ADD_EVENT_LISTENER_METADATA_KEY = Symbol.for("simple-web-component:add-event-listener");
|
|
28
28
|
function addEventListener(selectorOrTarget, type, options = {}) {
|
|
29
29
|
return (targetObj, propertyKey, descriptor) => {
|
|
30
30
|
const constructor = targetObj.constructor;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/decorators/addEventListener.ts"],
|
|
4
|
-
"sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { SpecialSelector, SwcQueryOptions } from '../types';\n\nexport interface AddEventListenerBaseOptions extends EventListenerOptions {\n capture?: boolean;\n once?: boolean;\n passive?: boolean;\n stopPropagation?: boolean;\n stopImmediatePropagation?: boolean;\n preventDefault?: boolean;\n removeOnDisconnected?: boolean;\n delegate?: boolean;\n}\n\nexport interface AddEventListenerMetadata {\n propertyKey: string | symbol;\n selector: string;\n type: string;\n options: AddEventListenerBaseOptions & SwcQueryOptions & { delegate?: boolean };\n}\n\nexport const ADD_EVENT_LISTENER_METADATA_KEY = Symbol('simple-web-component:add-event-listener');\n\nexport function addEventListener(target: SpecialSelector, type: string, options?: AddEventListenerBaseOptions): MethodDecorator;\nexport function addEventListener(selector: string, type: string, options?: AddEventListenerBaseOptions & SwcQueryOptions & { delegate?: boolean }): MethodDecorator;\n/**\n * @addEventListener decorator to bind events to elements.\n */\nexport function addEventListener(selectorOrTarget: string, type: string, options: any = {}): MethodDecorator {\n return (targetObj: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const constructor = targetObj.constructor;\n\n let listeners = ReflectUtils.getMetadata<AddEventListenerMetadata[]>(ADD_EVENT_LISTENER_METADATA_KEY, constructor);\n if (!listeners) {\n listeners = [];\n ReflectUtils.defineMetadata(ADD_EVENT_LISTENER_METADATA_KEY, listeners, constructor);\n }\n\n listeners.push({ propertyKey, selector: selectorOrTarget, type, options });\n };\n}\n\nexport const getAddEventListenerMetadata = (target: any): AddEventListenerMetadata[] | undefined => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getMetadata(ADD_EVENT_LISTENER_METADATA_KEY, constructor);\n};\n\n/**\n * @addEventListenerHost decorator - simplified version of @addEventListener for :host selector\n * Usage: @addEventListenerHost('click')\n * Usage: @addEventListenerHost('click', { stopPropagation: true })\n */\nexport function addEventListenerHost(type: string, options?: AddEventListenerBaseOptions & SwcQueryOptions): MethodDecorator {\n return addEventListener(':host', type, options);\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA6B;AAqBtB,MAAM,kCAAkC,OAAO,yCAAyC;
|
|
4
|
+
"sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { SpecialSelector, SwcQueryOptions } from '../types';\n\nexport interface AddEventListenerBaseOptions extends EventListenerOptions {\n capture?: boolean;\n once?: boolean;\n passive?: boolean;\n stopPropagation?: boolean;\n stopImmediatePropagation?: boolean;\n preventDefault?: boolean;\n removeOnDisconnected?: boolean;\n delegate?: boolean;\n}\n\nexport interface AddEventListenerMetadata {\n propertyKey: string | symbol;\n selector: string;\n type: string;\n options: AddEventListenerBaseOptions & SwcQueryOptions & { delegate?: boolean };\n}\n\nexport const ADD_EVENT_LISTENER_METADATA_KEY = Symbol.for('simple-web-component:add-event-listener');\n\nexport function addEventListener(target: SpecialSelector, type: string, options?: AddEventListenerBaseOptions): MethodDecorator;\nexport function addEventListener(selector: string, type: string, options?: AddEventListenerBaseOptions & SwcQueryOptions & { delegate?: boolean }): MethodDecorator;\n/**\n * @addEventListener decorator to bind events to elements.\n */\nexport function addEventListener(selectorOrTarget: string, type: string, options: any = {}): MethodDecorator {\n return (targetObj: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const constructor = targetObj.constructor;\n\n let listeners = ReflectUtils.getMetadata<AddEventListenerMetadata[]>(ADD_EVENT_LISTENER_METADATA_KEY, constructor);\n if (!listeners) {\n listeners = [];\n ReflectUtils.defineMetadata(ADD_EVENT_LISTENER_METADATA_KEY, listeners, constructor);\n }\n\n listeners.push({ propertyKey, selector: selectorOrTarget, type, options });\n };\n}\n\nexport const getAddEventListenerMetadata = (target: any): AddEventListenerMetadata[] | undefined => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getMetadata(ADD_EVENT_LISTENER_METADATA_KEY, constructor);\n};\n\n/**\n * @addEventListenerHost decorator - simplified version of @addEventListener for :host selector\n * Usage: @addEventListenerHost('click')\n * Usage: @addEventListenerHost('click', { stopPropagation: true })\n */\nexport function addEventListenerHost(type: string, options?: AddEventListenerBaseOptions & SwcQueryOptions): MethodDecorator {\n return addEventListener(':host', type, options);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA6B;AAqBtB,MAAM,kCAAkC,OAAO,IAAI,yCAAyC;AAO5F,SAAS,iBAAiB,kBAA0B,MAAc,UAAe,CAAC,GAAoB;AAC3G,SAAO,CAAC,WAAmB,aAA8B,eAAmC;AAC1F,UAAM,cAAc,UAAU;AAE9B,QAAI,YAAY,yBAAa,YAAwC,iCAAiC,WAAW;AACjH,QAAI,CAAC,WAAW;AACd,kBAAY,CAAC;AACb,+BAAa,eAAe,iCAAiC,WAAW,WAAW;AAAA,IACrF;AAEA,cAAU,KAAK,EAAE,aAAa,UAAU,kBAAkB,MAAM,QAAQ,CAAC;AAAA,EAC3E;AACF;AAEO,MAAM,8BAA8B,CAAC,WAAwD;AAClG,QAAM,cAAc,kBAAkB,WAAW,SAAS,OAAO;AACjE,SAAO,yBAAa,YAAY,iCAAiC,WAAW;AAC9E;AAOO,SAAS,qBAAqB,MAAc,SAA0E;AAC3H,SAAO,iBAAiB,SAAS,MAAM,OAAO;AAChD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,148 @@
|
|
|
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 applyAttribute_exports = {};
|
|
19
|
+
__export(applyAttribute_exports, {
|
|
20
|
+
ATTRIBUTE_APPLY_METADATA_KEY: () => ATTRIBUTE_APPLY_METADATA_KEY,
|
|
21
|
+
applyAttribute: () => applyAttribute,
|
|
22
|
+
applyAttributeHost: () => applyAttributeHost,
|
|
23
|
+
findAllAttributeApplyMetadata: () => findAllAttributeApplyMetadata,
|
|
24
|
+
removeAttribute: () => removeAttribute,
|
|
25
|
+
removeAttributeHost: () => removeAttributeHost,
|
|
26
|
+
setAttribute: () => setAttribute,
|
|
27
|
+
setAttributeHost: () => setAttributeHost,
|
|
28
|
+
updateAttribute: () => updateAttribute,
|
|
29
|
+
updateAttributeHost: () => updateAttributeHost
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(applyAttribute_exports);
|
|
32
|
+
var import_core = require("@dooboostore/core");
|
|
33
|
+
var import_elementDefine = require("./elementDefine");
|
|
34
|
+
var import_Utils = require("../utils/Utils");
|
|
35
|
+
const ATTRIBUTE_APPLY_METADATA_KEY = Symbol.for("simple-web-component:attribute-apply");
|
|
36
|
+
function createAttributeDecorator(action) {
|
|
37
|
+
return (selector, nameOrOptions, options = {}) => {
|
|
38
|
+
return (target, propertyKey, descriptor) => {
|
|
39
|
+
const constructor = target.constructor;
|
|
40
|
+
let metaList = import_core.ReflectUtils.getOwnMetadata(ATTRIBUTE_APPLY_METADATA_KEY, constructor);
|
|
41
|
+
if (!metaList) {
|
|
42
|
+
metaList = /* @__PURE__ */ new Map();
|
|
43
|
+
import_core.ReflectUtils.defineMetadata(ATTRIBUTE_APPLY_METADATA_KEY, metaList, constructor);
|
|
44
|
+
}
|
|
45
|
+
let attributeName = typeof nameOrOptions === "string" ? nameOrOptions : void 0;
|
|
46
|
+
let finalOptions = options;
|
|
47
|
+
if (typeof nameOrOptions === "object" && nameOrOptions !== null) {
|
|
48
|
+
finalOptions = nameOrOptions;
|
|
49
|
+
}
|
|
50
|
+
metaList.set(propertyKey, {
|
|
51
|
+
propertyKey,
|
|
52
|
+
selector,
|
|
53
|
+
action,
|
|
54
|
+
options: { ...finalOptions, name: attributeName }
|
|
55
|
+
});
|
|
56
|
+
const original = descriptor.value;
|
|
57
|
+
descriptor.value = async function(...args) {
|
|
58
|
+
(0, import_elementDefine.ensureInit)(this);
|
|
59
|
+
const res = await original.apply(this, args);
|
|
60
|
+
if (res !== void 0) {
|
|
61
|
+
const win = this.ownerDocument?.defaultView || window;
|
|
62
|
+
const host = this;
|
|
63
|
+
const hostSet = { ...import_Utils.SwcUtils.getHelperAndHostSet(win, host), $this: this };
|
|
64
|
+
const r = finalOptions.root || "auto";
|
|
65
|
+
const targetEls = [];
|
|
66
|
+
const applyRoot = (t) => {
|
|
67
|
+
if (!t || !(t instanceof win.HTMLElement)) return;
|
|
68
|
+
targetEls.push(t);
|
|
69
|
+
};
|
|
70
|
+
if (selector === ":parentHost") applyRoot(hostSet.$parentHost);
|
|
71
|
+
else if (selector === ":appHost") applyRoot(hostSet.$appHost);
|
|
72
|
+
else if (selector === ":firstHost") applyRoot(hostSet.$firstHost);
|
|
73
|
+
else if (selector === ":lastHost") applyRoot(hostSet.$lastHost);
|
|
74
|
+
else if (selector === ":firstAppHost") applyRoot(hostSet.$firstAppHost);
|
|
75
|
+
else if (selector === ":lastAppHost") applyRoot(hostSet.$lastAppHost);
|
|
76
|
+
else if (selector === ":hosts") hostSet.$hosts.forEach(applyRoot);
|
|
77
|
+
else if (selector === ":appHosts") hostSet.$appHosts.forEach(applyRoot);
|
|
78
|
+
else if (selector === ":host" || !selector) applyRoot(host);
|
|
79
|
+
else {
|
|
80
|
+
const targetRoot = r === "auto" ? host.shadowRoot || host : r === "shadow" ? host.shadowRoot : host;
|
|
81
|
+
if (targetRoot) {
|
|
82
|
+
const found = targetRoot.querySelectorAll(selector);
|
|
83
|
+
if (found) targetEls.push(...Array.from(found));
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
targetEls.forEach((targetEl) => {
|
|
87
|
+
const resolvedRes = typeof res === "function" ? res(targetEl, hostSet) : res;
|
|
88
|
+
if (action === "set" || action === "update") {
|
|
89
|
+
if (attributeName) {
|
|
90
|
+
if (resolvedRes === null || resolvedRes === void 0 || resolvedRes === false) {
|
|
91
|
+
targetEl.removeAttribute(attributeName);
|
|
92
|
+
} else {
|
|
93
|
+
targetEl.setAttribute(attributeName, resolvedRes === true ? "" : String(resolvedRes));
|
|
94
|
+
}
|
|
95
|
+
} else if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
|
|
96
|
+
Object.entries(resolvedRes).forEach(([attr, val]) => {
|
|
97
|
+
const finalVal = typeof val === "function" ? val(targetEl, hostSet) : val;
|
|
98
|
+
if (finalVal === null || finalVal === void 0 || finalVal === false) {
|
|
99
|
+
targetEl.removeAttribute(attr);
|
|
100
|
+
} else {
|
|
101
|
+
targetEl.setAttribute(attr, finalVal === true ? "" : String(finalVal));
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
} else if (action === "remove") {
|
|
106
|
+
if (attributeName) {
|
|
107
|
+
targetEl.removeAttribute(attributeName);
|
|
108
|
+
} else if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
|
|
109
|
+
Object.entries(resolvedRes).forEach(([attr, val]) => {
|
|
110
|
+
const shouldRemove = typeof val === "function" ? val(targetEl, hostSet) : !!val;
|
|
111
|
+
if (shouldRemove) targetEl.removeAttribute(attr);
|
|
112
|
+
});
|
|
113
|
+
} else {
|
|
114
|
+
const attrs = Array.isArray(resolvedRes) ? resolvedRes : [resolvedRes];
|
|
115
|
+
attrs.forEach((a) => targetEl.removeAttribute(String(a)));
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
return res;
|
|
121
|
+
};
|
|
122
|
+
return descriptor;
|
|
123
|
+
};
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
function applyAttribute(selector, action = "update", options = {}) {
|
|
127
|
+
return createAttributeDecorator(action)(selector, options);
|
|
128
|
+
}
|
|
129
|
+
const setAttribute = (selector, nameOrOptions, options = {}) => createAttributeDecorator("set")(selector, nameOrOptions, options);
|
|
130
|
+
const updateAttribute = (selector, nameOrOptions, options = {}) => createAttributeDecorator("update")(selector, nameOrOptions, options);
|
|
131
|
+
const removeAttribute = (selector, nameOrOptions, options = {}) => createAttributeDecorator("remove")(selector, nameOrOptions, options);
|
|
132
|
+
function applyAttributeHost(action = "update", options = {}) {
|
|
133
|
+
return createAttributeDecorator(action)(":host", options);
|
|
134
|
+
}
|
|
135
|
+
const setAttributeHost = (nameOrOptions, options = {}) => createAttributeDecorator("set")(":host", nameOrOptions, options);
|
|
136
|
+
const updateAttributeHost = (nameOrOptions, options = {}) => createAttributeDecorator("update")(":host", nameOrOptions, options);
|
|
137
|
+
const removeAttributeHost = (nameOrOptions, options = {}) => createAttributeDecorator("remove")(":host", nameOrOptions, options);
|
|
138
|
+
const findAllAttributeApplyMetadata = (target) => {
|
|
139
|
+
const result = /* @__PURE__ */ new Map();
|
|
140
|
+
const maps = import_core.ReflectUtils.findAllMetadata(ATTRIBUTE_APPLY_METADATA_KEY, target);
|
|
141
|
+
maps.forEach((map) => {
|
|
142
|
+
if (map instanceof Map) {
|
|
143
|
+
map.forEach((v, k) => result.set(k, v));
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
return result;
|
|
147
|
+
};
|
|
148
|
+
//# sourceMappingURL=applyAttribute.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/decorators/applyAttribute.ts"],
|
|
4
|
+
"sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { ensureInit } from './elementDefine';\nimport { SwcUtils } from '../utils/Utils';\nimport { SwcQueryOptions, HelperHostSet } from '../types';\n\nexport type AttributeAction = 'set' | 'update' | 'remove';\n\nexport interface AttributeApplyOptions extends SwcQueryOptions {\n name?: string;\n}\n\nexport interface AttributeApplyMetadata {\n propertyKey: string | symbol;\n selector: string;\n action: AttributeAction;\n options: AttributeApplyOptions;\n}\n\nexport const ATTRIBUTE_APPLY_METADATA_KEY = Symbol.for('simple-web-component:attribute-apply');\n\nfunction createAttributeDecorator(action: AttributeAction) {\n return (selector: string, nameOrOptions?: string | AttributeApplyOptions, options: AttributeApplyOptions = {}): MethodDecorator => {\n return (target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const constructor = target.constructor;\n let metaList = ReflectUtils.getOwnMetadata(ATTRIBUTE_APPLY_METADATA_KEY, constructor) as Map<string | symbol, AttributeApplyMetadata>;\n if (!metaList) {\n metaList = new Map<string | symbol, AttributeApplyMetadata>();\n ReflectUtils.defineMetadata(ATTRIBUTE_APPLY_METADATA_KEY, metaList, constructor);\n }\n\n let attributeName = typeof nameOrOptions === 'string' ? nameOrOptions : undefined;\n let finalOptions = options;\n \n if (typeof nameOrOptions === 'object' && nameOrOptions !== null) {\n finalOptions = nameOrOptions as AttributeApplyOptions;\n }\n\n metaList.set(propertyKey, { \n propertyKey, \n selector, \n action, \n options: { ...finalOptions, name: attributeName } \n });\n\n const original = descriptor.value;\n descriptor.value = async function (...args: any[]) {\n ensureInit(this);\n const res = await (original as any).apply(this, args);\n if (res !== undefined) {\n const win = (this as any).ownerDocument?.defaultView || window;\n const host = this as unknown as HTMLElement;\n const hostSet = { ...SwcUtils.getHelperAndHostSet(win, host), $this: this };\n const r = finalOptions.root || 'auto';\n const targetEls: HTMLElement[] = [];\n\n const applyRoot = (t: any) => {\n if (!t || !(t instanceof win.HTMLElement)) return;\n targetEls.push(t);\n };\n\n if (selector === ':parentHost') applyRoot(hostSet.$parentHost);\n else if (selector === ':appHost') applyRoot(hostSet.$appHost);\n else if (selector === ':firstHost') applyRoot(hostSet.$firstHost);\n else if (selector === ':lastHost') applyRoot(hostSet.$lastHost);\n else if (selector === ':firstAppHost') applyRoot(hostSet.$firstAppHost);\n else if (selector === ':lastAppHost') applyRoot(hostSet.$lastAppHost);\n else if (selector === ':hosts') hostSet.$hosts.forEach(applyRoot);\n else if (selector === ':appHosts') hostSet.$appHosts.forEach(applyRoot);\n else if (selector === ':host' || !selector) applyRoot(host);\n else {\n const targetRoot = r === 'auto' ? (host.shadowRoot || host) : (r === 'shadow' ? host.shadowRoot : host);\n if (targetRoot) {\n const found = targetRoot.querySelectorAll(selector);\n if (found) targetEls.push(...(Array.from(found) as HTMLElement[]));\n }\n }\n\n targetEls.forEach(targetEl => {\n const resolvedRes = typeof res === 'function' ? (res as any)(targetEl, hostSet) : res;\n\n if (action === 'set' || action === 'update') {\n if (attributeName) {\n // Case: @setAttribute(selector, 'name')\n if (resolvedRes === null || resolvedRes === undefined || resolvedRes === false) {\n targetEl.removeAttribute(attributeName);\n } else {\n targetEl.setAttribute(attributeName, resolvedRes === true ? '' : String(resolvedRes));\n }\n } else if (typeof resolvedRes === 'object' && resolvedRes !== null && !Array.isArray(resolvedRes)) {\n // Case: @applyAttribute(selector) with Object return\n Object.entries(resolvedRes as any).forEach(([attr, val]) => {\n const finalVal = typeof val === 'function' ? val(targetEl, hostSet) : val;\n if (finalVal === null || finalVal === undefined || finalVal === false) {\n targetEl.removeAttribute(attr);\n } else {\n targetEl.setAttribute(attr, finalVal === true ? '' : String(finalVal));\n }\n });\n }\n } else if (action === 'remove') {\n if (attributeName) {\n targetEl.removeAttribute(attributeName);\n } else if (typeof resolvedRes === 'object' && resolvedRes !== null && !Array.isArray(resolvedRes)) {\n Object.entries(resolvedRes as any).forEach(([attr, val]) => {\n const shouldRemove = typeof val === 'function' ? val(targetEl, hostSet) : !!val;\n if (shouldRemove) targetEl.removeAttribute(attr);\n });\n } else {\n const attrs = Array.isArray(resolvedRes) ? resolvedRes : [resolvedRes];\n attrs.forEach(a => targetEl.removeAttribute(String(a)));\n }\n }\n });\n }\n return res;\n };\n return descriptor;\n };\n };\n}\n\nexport function applyAttribute(selector: string, action: AttributeAction = 'update', options: AttributeApplyOptions = {}): MethodDecorator {\n return createAttributeDecorator(action)(selector, options);\n}\n\nexport const setAttribute = (selector: string, nameOrOptions?: string | AttributeApplyOptions, options: AttributeApplyOptions = {}) => createAttributeDecorator('set')(selector, nameOrOptions, options);\nexport const updateAttribute = (selector: string, nameOrOptions?: string | AttributeApplyOptions, options: AttributeApplyOptions = {}) => createAttributeDecorator('update')(selector, nameOrOptions, options);\nexport const removeAttribute = (selector: string, nameOrOptions?: string | AttributeApplyOptions, options: AttributeApplyOptions = {}) => createAttributeDecorator('remove')(selector, nameOrOptions, options);\n\n// Host versions\nexport function applyAttributeHost(action: AttributeAction = 'update', options: AttributeApplyOptions = {}): MethodDecorator {\n return createAttributeDecorator(action)(':host', options);\n}\nexport const setAttributeHost = (nameOrOptions: string | AttributeApplyOptions, options: AttributeApplyOptions = {}) => createAttributeDecorator('set')(':host', nameOrOptions, options);\nexport const updateAttributeHost = (nameOrOptions: string | AttributeApplyOptions, options: AttributeApplyOptions = {}) => createAttributeDecorator('update')(':host', nameOrOptions, options);\nexport const removeAttributeHost = (nameOrOptions?: string | AttributeApplyOptions, options: AttributeApplyOptions = {}) => createAttributeDecorator('remove')(':host', nameOrOptions, options);\n\nexport const findAllAttributeApplyMetadata = (target: any): Map<string | symbol, AttributeApplyMetadata> => {\n const result = new Map<string | symbol, AttributeApplyMetadata>();\n const maps = ReflectUtils.findAllMetadata<Map<string | symbol, AttributeApplyMetadata>>(ATTRIBUTE_APPLY_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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA6B;AAC7B,2BAA2B;AAC3B,mBAAyB;AAgBlB,M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