@dooboostore/simple-web-component 1.0.42 → 1.0.44
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 +689 -85
- package/dist/cjs/SwcAppEngine.js +3 -1
- package/dist/cjs/SwcAppEngine.js.map +2 -2
- package/dist/cjs/decorators/addEventListener.js +10 -0
- package/dist/cjs/decorators/addEventListener.js.map +2 -2
- package/dist/cjs/decorators/applyAttribute.js +41 -30
- package/dist/cjs/decorators/applyAttribute.js.map +2 -2
- package/dist/cjs/decorators/applyClass.js +66 -23
- package/dist/cjs/decorators/applyClass.js.map +3 -3
- package/dist/cjs/decorators/applyNode.js +176 -107
- package/dist/cjs/decorators/applyNode.js.map +2 -2
- package/dist/cjs/decorators/applyProperty.js +21 -30
- package/dist/cjs/decorators/applyProperty.js.map +2 -2
- package/dist/cjs/decorators/applySlot.js +11 -2
- package/dist/cjs/decorators/applySlot.js.map +2 -2
- package/dist/cjs/decorators/applyStyle.js +48 -17
- package/dist/cjs/decorators/applyStyle.js.map +3 -3
- package/dist/cjs/decorators/{changedAttributeThis.js → changedAttribute.js} +6 -6
- package/dist/cjs/decorators/changedAttribute.js.map +7 -0
- package/dist/cjs/decorators/elementDefine.js +37 -6
- package/dist/cjs/decorators/elementDefine.js.map +3 -3
- package/dist/cjs/decorators/emitCustomEvent.js +58 -42
- package/dist/cjs/decorators/emitCustomEvent.js.map +2 -2
- package/dist/cjs/decorators/index.js +1 -1
- package/dist/cjs/decorators/index.js.map +2 -2
- package/dist/cjs/decorators/publishSwcAppMessage.js +37 -23
- package/dist/cjs/decorators/publishSwcAppMessage.js.map +3 -3
- package/dist/cjs/decorators/query.js +96 -145
- package/dist/cjs/decorators/query.js.map +3 -3
- package/dist/cjs/decorators/queryAll.js +104 -131
- package/dist/cjs/decorators/queryAll.js.map +3 -3
- package/dist/cjs/decorators/subscribeSwcAppMessageWhileConnected.js +2 -0
- package/dist/cjs/decorators/subscribeSwcAppMessageWhileConnected.js.map +2 -2
- package/dist/cjs/decorators/subscribeSwcAppRouteChangeWhileConnected.js +2 -0
- package/dist/cjs/decorators/subscribeSwcAppRouteChangeWhileConnected.js.map +2 -2
- package/dist/cjs/elements/SwcAppMixin.js +17 -2
- package/dist/cjs/elements/SwcAppMixin.js.map +2 -2
- package/dist/cjs/examples/RxJSOperatorsExample.js +285 -0
- package/dist/cjs/examples/RxJSOperatorsExample.js.map +7 -0
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/router/ElementRouter.js +4 -0
- package/dist/cjs/router/ElementRouter.js.map +2 -2
- package/dist/esm/SwcAppEngine.js +3 -1
- package/dist/esm/SwcAppEngine.js.map +2 -2
- package/dist/esm/decorators/addEventListener.js +10 -0
- package/dist/esm/decorators/addEventListener.js.map +2 -2
- package/dist/esm/decorators/applyAttribute.js +41 -30
- package/dist/esm/decorators/applyAttribute.js.map +2 -2
- package/dist/esm/decorators/applyClass.js +66 -23
- package/dist/esm/decorators/applyClass.js.map +3 -3
- package/dist/esm/decorators/applyNode.js +176 -107
- package/dist/esm/decorators/applyNode.js.map +2 -2
- package/dist/esm/decorators/applyProperty.js +21 -30
- package/dist/esm/decorators/applyProperty.js.map +2 -2
- package/dist/esm/decorators/applySlot.js +11 -2
- package/dist/esm/decorators/applySlot.js.map +2 -2
- package/dist/esm/decorators/applyStyle.js +48 -17
- package/dist/esm/decorators/applyStyle.js.map +3 -3
- package/dist/esm/decorators/{changedAttributeThis.js → changedAttribute.js} +3 -3
- package/dist/esm/decorators/changedAttribute.js.map +7 -0
- package/dist/esm/decorators/elementDefine.js +35 -4
- package/dist/esm/decorators/elementDefine.js.map +2 -2
- package/dist/esm/decorators/emitCustomEvent.js +58 -42
- package/dist/esm/decorators/emitCustomEvent.js.map +2 -2
- package/dist/esm/decorators/index.js +1 -1
- package/dist/esm/decorators/index.js.map +1 -1
- package/dist/esm/decorators/publishSwcAppMessage.js +37 -23
- package/dist/esm/decorators/publishSwcAppMessage.js.map +3 -3
- package/dist/esm/decorators/query.js +96 -145
- package/dist/esm/decorators/query.js.map +3 -3
- package/dist/esm/decorators/queryAll.js +104 -131
- package/dist/esm/decorators/queryAll.js.map +3 -3
- package/dist/esm/decorators/subscribeSwcAppMessageWhileConnected.js +2 -0
- package/dist/esm/decorators/subscribeSwcAppMessageWhileConnected.js.map +2 -2
- package/dist/esm/decorators/subscribeSwcAppRouteChangeWhileConnected.js +2 -0
- package/dist/esm/decorators/subscribeSwcAppRouteChangeWhileConnected.js.map +2 -2
- package/dist/esm/elements/SwcAppMixin.js +18 -3
- package/dist/esm/elements/SwcAppMixin.js.map +2 -2
- package/dist/esm/examples/RxJSOperatorsExample.js +266 -0
- package/dist/esm/examples/RxJSOperatorsExample.js.map +7 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/router/ElementRouter.js +4 -0
- package/dist/esm/router/ElementRouter.js.map +2 -2
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +900 -578
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +4 -4
- package/dist/types/SwcAppEngine.d.ts.map +1 -1
- package/dist/types/decorators/addEventListener.d.ts +22 -14
- package/dist/types/decorators/addEventListener.d.ts.map +1 -1
- package/dist/types/decorators/applyAttribute.d.ts +61 -20
- package/dist/types/decorators/applyAttribute.d.ts.map +1 -1
- package/dist/types/decorators/applyClass.d.ts +22 -36
- package/dist/types/decorators/applyClass.d.ts.map +1 -1
- package/dist/types/decorators/applyNode.d.ts +178 -30
- package/dist/types/decorators/applyNode.d.ts.map +1 -1
- package/dist/types/decorators/applyProperty.d.ts +53 -18
- package/dist/types/decorators/applyProperty.d.ts.map +1 -1
- package/dist/types/decorators/applySlot.d.ts +6 -0
- package/dist/types/decorators/applySlot.d.ts.map +1 -1
- package/dist/types/decorators/applyStyle.d.ts +13 -7
- package/dist/types/decorators/applyStyle.d.ts.map +1 -1
- package/dist/types/decorators/{changedAttributeThis.d.ts → changedAttribute.d.ts} +2 -2
- package/dist/types/decorators/changedAttribute.d.ts.map +1 -0
- package/dist/types/decorators/elementDefine.d.ts.map +1 -1
- package/dist/types/decorators/emitCustomEvent.d.ts +20 -10
- package/dist/types/decorators/emitCustomEvent.d.ts.map +1 -1
- package/dist/types/decorators/index.d.ts +1 -1
- package/dist/types/decorators/index.d.ts.map +1 -1
- package/dist/types/decorators/publishSwcAppMessage.d.ts +19 -0
- package/dist/types/decorators/publishSwcAppMessage.d.ts.map +1 -1
- package/dist/types/decorators/query.d.ts +3 -26
- package/dist/types/decorators/query.d.ts.map +1 -1
- package/dist/types/decorators/queryAll.d.ts +3 -20
- package/dist/types/decorators/queryAll.d.ts.map +1 -1
- package/dist/types/decorators/subscribeSwcAppMessageWhileConnected.d.ts +1 -0
- package/dist/types/decorators/subscribeSwcAppMessageWhileConnected.d.ts.map +1 -1
- package/dist/types/decorators/subscribeSwcAppRouteChangeWhileConnected.d.ts +2 -0
- package/dist/types/decorators/subscribeSwcAppRouteChangeWhileConnected.d.ts.map +1 -1
- package/dist/types/elements/SwcAppMixin.d.ts +4 -4
- package/dist/types/elements/SwcAppMixin.d.ts.map +1 -1
- package/dist/types/examples/RxJSOperatorsExample.d.ts +94 -0
- package/dist/types/examples/RxJSOperatorsExample.d.ts.map +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/router/ElementRouter.d.ts.map +1 -1
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +900 -578
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +4 -4
- package/package.json +7 -9
- package/src/SwcAppEngine.ts +3 -1
- package/src/decorators/addEventListener.ts +35 -24
- package/src/decorators/applyAttribute.ts +167 -65
- package/src/decorators/applyClass.ts +113 -17
- package/src/decorators/applyNode.ts +383 -102
- package/src/decorators/applyProperty.ts +99 -65
- package/src/decorators/applySlot.ts +24 -10
- package/src/decorators/applyStyle.ts +83 -13
- package/src/decorators/{changedAttributeThis.ts → changedAttribute.ts} +1 -1
- package/src/decorators/elementDefine.ts +47 -4
- package/src/decorators/emitCustomEvent.ts +62 -35
- package/src/decorators/index.ts +1 -1
- package/src/decorators/publishSwcAppMessage.ts +71 -27
- package/src/decorators/query.ts +90 -159
- package/src/decorators/queryAll.ts +92 -134
- package/src/decorators/subscribeSwcAppMessageWhileConnected.ts +1 -0
- package/src/decorators/subscribeSwcAppRouteChangeWhileConnected.ts +3 -1
- package/src/elements/SwcAppMixin.ts +43 -24
- package/src/examples/RxJSOperatorsExample.ts +279 -0
- package/src/index.ts +2 -0
- package/src/router/ElementRouter.ts +4 -0
- package/dist/cjs/decorators/changedAttributeThis.js.map +0 -7
- package/dist/esm/decorators/changedAttributeThis.js.map +0 -7
- package/dist/types/decorators/changedAttributeThis.d.ts.map +0 -1
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Example: Using RxJS-like Operators with @addEventListener
|
|
3
|
+
*
|
|
4
|
+
* This example demonstrates how to use debounceTime, throttleTime, and distinctUntilChanged
|
|
5
|
+
* operators with the @addEventListener decorator.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { elementDefine, addEventListener } from '../decorators';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Example 1: Search Component with Debounce
|
|
12
|
+
*
|
|
13
|
+
* Waits 1 second after user stops typing before performing search.
|
|
14
|
+
* Prevents excessive API calls during typing.
|
|
15
|
+
*/
|
|
16
|
+
@elementDefine('search-component')
|
|
17
|
+
export class SearchComponent extends HTMLElement {
|
|
18
|
+
private results: any[] = [];
|
|
19
|
+
|
|
20
|
+
@addEventListener('$this', 'input', { debounceTime: 1000 })
|
|
21
|
+
async onSearchInput(event: Event) {
|
|
22
|
+
const input = event.target as HTMLInputElement;
|
|
23
|
+
const query = input.value.trim();
|
|
24
|
+
|
|
25
|
+
if (query.length > 2) {
|
|
26
|
+
try {
|
|
27
|
+
// Simulate API call
|
|
28
|
+
const response = await fetch(`/api/search?q=${encodeURIComponent(query)}`);
|
|
29
|
+
this.results = await response.json();
|
|
30
|
+
this.renderResults();
|
|
31
|
+
} catch (error) {
|
|
32
|
+
console.error('Search failed:', error);
|
|
33
|
+
}
|
|
34
|
+
} else {
|
|
35
|
+
this.results = [];
|
|
36
|
+
this.renderResults();
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
private renderResults() {
|
|
41
|
+
// Render search results
|
|
42
|
+
console.log('Rendering results:', this.results);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Example 2: Window Resize Handler with Throttle
|
|
48
|
+
*
|
|
49
|
+
* Recalculates layout at most 4 times per second (every 250ms).
|
|
50
|
+
* Prevents performance issues from excessive resize calculations.
|
|
51
|
+
*/
|
|
52
|
+
@elementDefine('responsive-layout')
|
|
53
|
+
export class ResponsiveLayout extends HTMLElement {
|
|
54
|
+
@addEventListener('$window', 'resize', { throttleTime: 250 })
|
|
55
|
+
onWindowResize(event: Event) {
|
|
56
|
+
const width = window.innerWidth;
|
|
57
|
+
const height = window.innerHeight;
|
|
58
|
+
|
|
59
|
+
console.log(`Window resized to: ${width}x${height}`);
|
|
60
|
+
this.updateLayout(width, height);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
private updateLayout(width: number, height: number) {
|
|
64
|
+
// Update layout based on new dimensions
|
|
65
|
+
if (width < 768) {
|
|
66
|
+
this.classList.add('mobile');
|
|
67
|
+
this.classList.remove('desktop');
|
|
68
|
+
} else {
|
|
69
|
+
this.classList.add('desktop');
|
|
70
|
+
this.classList.remove('mobile');
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Example 3: Form Input with Debounce + Distinct
|
|
77
|
+
*
|
|
78
|
+
* Validates field only when:
|
|
79
|
+
* 1. User stops typing (debounce 300ms)
|
|
80
|
+
* 2. AND the value actually changed (distinct)
|
|
81
|
+
*/
|
|
82
|
+
@elementDefine('form-input')
|
|
83
|
+
export class FormInput extends HTMLElement {
|
|
84
|
+
@addEventListener('$this', 'input', {
|
|
85
|
+
debounceTime: 300,
|
|
86
|
+
distinctUntilChanged: true
|
|
87
|
+
})
|
|
88
|
+
onFormInput(event: Event) {
|
|
89
|
+
const input = event.target as HTMLInputElement;
|
|
90
|
+
const fieldName = input.name;
|
|
91
|
+
const value = input.value;
|
|
92
|
+
|
|
93
|
+
console.log(`Validating ${fieldName}: ${value}`);
|
|
94
|
+
this.validateField(fieldName, value);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
private validateField(name: string, value: string) {
|
|
98
|
+
// Perform validation
|
|
99
|
+
const isValid = value.length > 0;
|
|
100
|
+
console.log(`Field ${name} is ${isValid ? 'valid' : 'invalid'}`);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Example 4: Scroll Event with Throttle
|
|
106
|
+
*
|
|
107
|
+
* Checks if user scrolled to bottom at most 10 times per second.
|
|
108
|
+
* Prevents excessive "load more" API calls.
|
|
109
|
+
*/
|
|
110
|
+
@elementDefine('infinite-scroll')
|
|
111
|
+
export class InfiniteScroll extends HTMLElement {
|
|
112
|
+
private isLoading = false;
|
|
113
|
+
|
|
114
|
+
@addEventListener('$window', 'scroll', { throttleTime: 100 })
|
|
115
|
+
onScroll(event: Event) {
|
|
116
|
+
if (this.isLoading) return;
|
|
117
|
+
|
|
118
|
+
if (this.isNearBottom()) {
|
|
119
|
+
console.log('Near bottom, loading more content...');
|
|
120
|
+
this.loadMoreContent();
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
private isNearBottom(): boolean {
|
|
125
|
+
const scrollTop = window.scrollY;
|
|
126
|
+
const windowHeight = window.innerHeight;
|
|
127
|
+
const documentHeight = document.documentElement.scrollHeight;
|
|
128
|
+
|
|
129
|
+
return scrollTop + windowHeight >= documentHeight - 500;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
private async loadMoreContent() {
|
|
133
|
+
this.isLoading = true;
|
|
134
|
+
try {
|
|
135
|
+
// Simulate API call
|
|
136
|
+
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
137
|
+
console.log('Content loaded');
|
|
138
|
+
} finally {
|
|
139
|
+
this.isLoading = false;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Example 5: Custom Comparison with Distinct
|
|
146
|
+
*
|
|
147
|
+
* Only fires when the input value length changes.
|
|
148
|
+
* Ignores changes that don't affect the length.
|
|
149
|
+
*/
|
|
150
|
+
@elementDefine('length-tracker')
|
|
151
|
+
export class LengthTracker extends HTMLElement {
|
|
152
|
+
@addEventListener('$this', 'input', {
|
|
153
|
+
distinctUntilChanged: (prev: any, curr: any) => {
|
|
154
|
+
// Only consider it changed if the length differs
|
|
155
|
+
return prev?.length === curr?.length;
|
|
156
|
+
}
|
|
157
|
+
})
|
|
158
|
+
onInputChange(event: Event) {
|
|
159
|
+
const input = event.target as HTMLInputElement;
|
|
160
|
+
const length = input.value.length;
|
|
161
|
+
|
|
162
|
+
console.log(`Input length changed to: ${length}`);
|
|
163
|
+
this.updateLengthDisplay(length);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
private updateLengthDisplay(length: number) {
|
|
167
|
+
// Update UI with new length
|
|
168
|
+
const display = this.querySelector('.length-display');
|
|
169
|
+
if (display) {
|
|
170
|
+
display.textContent = `${length} characters`;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Example 6: Complex Scenario - Auto-save with Multiple Operators
|
|
177
|
+
*
|
|
178
|
+
* Combines debounce and distinct for intelligent auto-save:
|
|
179
|
+
* - Waits 2 seconds after user stops typing
|
|
180
|
+
* - Only saves if content actually changed
|
|
181
|
+
* - Prevents unnecessary save operations
|
|
182
|
+
*/
|
|
183
|
+
@elementDefine('auto-save-editor')
|
|
184
|
+
export class AutoSaveEditor extends HTMLElement {
|
|
185
|
+
private lastSavedContent = '';
|
|
186
|
+
|
|
187
|
+
@addEventListener('$this', 'input', {
|
|
188
|
+
debounceTime: 2000,
|
|
189
|
+
distinctUntilChanged: (prev: any, curr: any) => {
|
|
190
|
+
// Consider changed if the content is different
|
|
191
|
+
return prev === curr;
|
|
192
|
+
}
|
|
193
|
+
})
|
|
194
|
+
async onContentChange(event: Event) {
|
|
195
|
+
const textarea = event.target as HTMLTextAreaElement;
|
|
196
|
+
const content = textarea.value;
|
|
197
|
+
|
|
198
|
+
if (content !== this.lastSavedContent) {
|
|
199
|
+
console.log('Auto-saving content...');
|
|
200
|
+
await this.saveContent(content);
|
|
201
|
+
this.lastSavedContent = content;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
private async saveContent(content: string) {
|
|
206
|
+
try {
|
|
207
|
+
// Simulate API call
|
|
208
|
+
const response = await fetch('/api/save', {
|
|
209
|
+
method: 'POST',
|
|
210
|
+
headers: { 'Content-Type': 'application/json' },
|
|
211
|
+
body: JSON.stringify({ content })
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
if (response.ok) {
|
|
215
|
+
console.log('Content saved successfully');
|
|
216
|
+
this.showSaveIndicator();
|
|
217
|
+
}
|
|
218
|
+
} catch (error) {
|
|
219
|
+
console.error('Save failed:', error);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
private showSaveIndicator() {
|
|
224
|
+
const indicator = this.querySelector('.save-indicator');
|
|
225
|
+
if (indicator) {
|
|
226
|
+
indicator.classList.add('show');
|
|
227
|
+
setTimeout(() => indicator.classList.remove('show'), 2000);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Example 7: Keyboard Shortcut Handler with Throttle
|
|
234
|
+
*
|
|
235
|
+
* Prevents rapid repeated execution of keyboard shortcuts.
|
|
236
|
+
*/
|
|
237
|
+
@elementDefine('keyboard-handler')
|
|
238
|
+
export class KeyboardHandler extends HTMLElement {
|
|
239
|
+
@addEventListener('$document', 'keydown', {
|
|
240
|
+
throttleTime: 500,
|
|
241
|
+
filter: (event: KeyboardEvent) => {
|
|
242
|
+
// Only handle Ctrl+S or Cmd+S
|
|
243
|
+
return (event.ctrlKey || event.metaKey) && event.key === 's';
|
|
244
|
+
}
|
|
245
|
+
})
|
|
246
|
+
onSaveShortcut(event: KeyboardEvent) {
|
|
247
|
+
event.preventDefault();
|
|
248
|
+
console.log('Save shortcut triggered');
|
|
249
|
+
this.handleSave();
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
private handleSave() {
|
|
253
|
+
// Handle save operation
|
|
254
|
+
console.log('Saving...');
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Example 8: Mouse Move Tracking with Throttle
|
|
260
|
+
*
|
|
261
|
+
* Tracks mouse position at most 10 times per second.
|
|
262
|
+
* Useful for analytics or interactive features.
|
|
263
|
+
*/
|
|
264
|
+
@elementDefine('mouse-tracker')
|
|
265
|
+
export class MouseTracker extends HTMLElement {
|
|
266
|
+
@addEventListener('$document', 'mousemove', { throttleTime: 100 })
|
|
267
|
+
onMouseMove(event: MouseEvent) {
|
|
268
|
+
const x = event.clientX;
|
|
269
|
+
const y = event.clientY;
|
|
270
|
+
|
|
271
|
+
// Update cursor position indicator
|
|
272
|
+
this.updateCursorPosition(x, y);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
private updateCursorPosition(x: number, y: number) {
|
|
276
|
+
// Update UI with cursor position
|
|
277
|
+
console.log(`Cursor at: ${x}, ${y}`);
|
|
278
|
+
}
|
|
279
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -15,6 +15,8 @@ export * from './utils/Utils';
|
|
|
15
15
|
// Config
|
|
16
16
|
export * from './config/config';
|
|
17
17
|
|
|
18
|
+
export * from './SwcAppEngine'
|
|
19
|
+
|
|
18
20
|
// Registration Factory
|
|
19
21
|
export default async (w: Window, other?: (((w: Window) => Promise<CustomElementConstructor> | CustomElementConstructor) | any) []) => {
|
|
20
22
|
const cr = await defineSwcAppAll(w);
|
|
@@ -7,6 +7,10 @@ export class ElementRouter extends Router {
|
|
|
7
7
|
|
|
8
8
|
constructor(config: RouterConfig) {
|
|
9
9
|
super(config);
|
|
10
|
+
if (config.firstUrl) {
|
|
11
|
+
this._history.push({ url: config.firstUrl, data: null, title: undefined });
|
|
12
|
+
this._currentIndex = 0;
|
|
13
|
+
}
|
|
10
14
|
}
|
|
11
15
|
|
|
12
16
|
// Override pushState to manage internal history
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/decorators/changedAttributeThis.ts"],
|
|
4
|
-
"sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\n\nexport const ON_ATTRIBUTE_CHANGED_METADATA_KEY = Symbol.for('simple-web-component:on-attribute-changed');\n\nexport interface ChangedAttributeThisOptions {\n type?: typeof Number | typeof Boolean | typeof String;\n while?: 'connected';\n}\n\nexport interface ChangedAttributeThisMetadata {\n attributeName: string;\n propertyKey: string | symbol;\n options: ChangedAttributeThisOptions;\n}\n\nconst convertValue = (val: any, type: any): any => {\n if (val === null || val === undefined) return val;\n if (type === Number) return Number(val);\n if (type === Boolean) return val === 'false' || val === '0' ? false : true;\n return val;\n};\n\n/**\n * @changedAttributeThis decorator - fires when any attribute on $this changes\n */\nexport function changedAttributeThis(attributeName?: string, options: ChangedAttributeThisOptions = {}): MethodDecorator {\n return (target: Object, propertyKey: string | symbol) => {\n const constructor = target.constructor;\n let metaList = ReflectUtils.getOwnMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor) as ChangedAttributeThisMetadata[];\n if (!metaList) {\n metaList = [];\n ReflectUtils.defineMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, metaList, constructor);\n }\n\n const name = attributeName || String(propertyKey);\n metaList.push({\n attributeName: name,\n propertyKey,\n options\n });\n };\n}\n\nexport const getChangedAttributeMetadata = (target: any): ChangedAttributeThisMetadata[] | 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, ChangedAttributeThisMetadata[]> => {\n const constructor = target instanceof Function ? target : target.constructor;\n const metaList = ReflectUtils.findAllMetadata<ChangedAttributeThisMetadata[]>(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor) || [];\n\n const result = new Map<string, ChangedAttributeThisMetadata[]>();\n metaList.forEach(meta => {\n meta.forEach(item => {\n if (!result.has(item.attributeName)) {\n result.set(item.attributeName, []);\n }\n result.get(item.attributeName)!.push(item);\n });\n });\n return result;\n};\n\nexport const convertAttributeValue = (val: any, type?: typeof Number | typeof Boolean | typeof String): any => {\n return convertValue(val, type);\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA6B;AAEtB,MAAM,oCAAoC,OAAO,IAAI,2CAA2C;AAavG,MAAM,eAAe,CAAC,KAAU,SAAmB;AACjD,MAAI,QAAQ,QAAQ,QAAQ,OAAW,QAAO;AAC9C,MAAI,SAAS,OAAQ,QAAO,OAAO,GAAG;AACtC,MAAI,SAAS,QAAS,QAAO,QAAQ,WAAW,QAAQ,MAAM,QAAQ;AACtE,SAAO;AACT;AAKO,SAAS,qBAAqB,eAAwB,UAAuC,CAAC,GAAoB;AACvH,SAAO,CAAC,QAAgB,gBAAiC;AACvD,UAAM,cAAc,OAAO;AAC3B,QAAI,WAAW,yBAAa,eAAe,mCAAmC,WAAW;AACzF,QAAI,CAAC,UAAU;AACb,iBAAW,CAAC;AACZ,+BAAa,eAAe,mCAAmC,UAAU,WAAW;AAAA,IACtF;AAEA,UAAM,OAAO,iBAAiB,OAAO,WAAW;AAChD,aAAS,KAAK;AAAA,MACZ,eAAe;AAAA,MACf;AAAA,MACA;AAAA,IACF,CAAC;AAAA,EACH;AACF;AAEO,MAAM,8BAA8B,CAAC,WAA4D;AACtG,QAAM,cAAc,kBAAkB,WAAW,SAAS,OAAO;AACjE,SAAO,yBAAa,YAAY,mCAAmC,WAAW;AAChF;AAEO,MAAM,kCAAkC,CAAC,WAA6D;AAC3G,QAAM,cAAc,kBAAkB,WAAW,SAAS,OAAO;AACjE,QAAM,WAAW,yBAAa,gBAAgD,mCAAmC,WAAW,KAAK,CAAC;AAElI,QAAM,SAAS,oBAAI,IAA4C;AAC/D,WAAS,QAAQ,UAAQ;AACvB,SAAK,QAAQ,UAAQ;AACnB,UAAI,CAAC,OAAO,IAAI,KAAK,aAAa,GAAG;AACnC,eAAO,IAAI,KAAK,eAAe,CAAC,CAAC;AAAA,MACnC;AACA,aAAO,IAAI,KAAK,aAAa,EAAG,KAAK,IAAI;AAAA,IAC3C,CAAC;AAAA,EACH,CAAC;AACD,SAAO;AACT;AAEO,MAAM,wBAAwB,CAAC,KAAU,SAA+D;AAC7G,SAAO,aAAa,KAAK,IAAI;AAC/B;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/decorators/changedAttributeThis.ts"],
|
|
4
|
-
"sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\n\nexport const ON_ATTRIBUTE_CHANGED_METADATA_KEY = Symbol.for('simple-web-component:on-attribute-changed');\n\nexport interface ChangedAttributeThisOptions {\n type?: typeof Number | typeof Boolean | typeof String;\n while?: 'connected';\n}\n\nexport interface ChangedAttributeThisMetadata {\n attributeName: string;\n propertyKey: string | symbol;\n options: ChangedAttributeThisOptions;\n}\n\nconst convertValue = (val: any, type: any): any => {\n if (val === null || val === undefined) return val;\n if (type === Number) return Number(val);\n if (type === Boolean) return val === 'false' || val === '0' ? false : true;\n return val;\n};\n\n/**\n * @changedAttributeThis decorator - fires when any attribute on $this changes\n */\nexport function changedAttributeThis(attributeName?: string, options: ChangedAttributeThisOptions = {}): MethodDecorator {\n return (target: Object, propertyKey: string | symbol) => {\n const constructor = target.constructor;\n let metaList = ReflectUtils.getOwnMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor) as ChangedAttributeThisMetadata[];\n if (!metaList) {\n metaList = [];\n ReflectUtils.defineMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, metaList, constructor);\n }\n\n const name = attributeName || String(propertyKey);\n metaList.push({\n attributeName: name,\n propertyKey,\n options\n });\n };\n}\n\nexport const getChangedAttributeMetadata = (target: any): ChangedAttributeThisMetadata[] | 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, ChangedAttributeThisMetadata[]> => {\n const constructor = target instanceof Function ? target : target.constructor;\n const metaList = ReflectUtils.findAllMetadata<ChangedAttributeThisMetadata[]>(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor) || [];\n\n const result = new Map<string, ChangedAttributeThisMetadata[]>();\n metaList.forEach(meta => {\n meta.forEach(item => {\n if (!result.has(item.attributeName)) {\n result.set(item.attributeName, []);\n }\n result.get(item.attributeName)!.push(item);\n });\n });\n return result;\n};\n\nexport const convertAttributeValue = (val: any, type?: typeof Number | typeof Boolean | typeof String): any => {\n return convertValue(val, type);\n};\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,oBAAoB;AAEtB,MAAM,oCAAoC,OAAO,IAAI,2CAA2C;AAavG,MAAM,eAAe,CAAC,KAAU,SAAmB;AACjD,MAAI,QAAQ,QAAQ,QAAQ,OAAW,QAAO;AAC9C,MAAI,SAAS,OAAQ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