@dooboostore/simple-web-component 1.0.49 → 1.0.50
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 +72 -0
- package/dist/cjs/decorators/addEventListener.js +1994 -9
- package/dist/cjs/decorators/addEventListener.js.map +2 -2
- package/dist/cjs/decorators/applyAttribute.js +10 -4
- package/dist/cjs/decorators/applyAttribute.js.map +2 -2
- package/dist/cjs/decorators/applyClass.js +10 -4
- package/dist/cjs/decorators/applyClass.js.map +2 -2
- package/dist/cjs/decorators/applyNode.js +10 -4
- package/dist/cjs/decorators/applyNode.js.map +2 -2
- package/dist/cjs/decorators/applyProperty.js +14 -8
- package/dist/cjs/decorators/applyProperty.js.map +2 -2
- package/dist/cjs/decorators/applySlot.js +6 -5
- package/dist/cjs/decorators/applySlot.js.map +2 -2
- package/dist/cjs/decorators/applyStyle.js +10 -4
- package/dist/cjs/decorators/applyStyle.js.map +2 -2
- package/dist/cjs/decorators/changedAttribute.js +22 -13
- package/dist/cjs/decorators/changedAttribute.js.map +2 -2
- package/dist/cjs/decorators/elementDefine.js +18 -3
- package/dist/cjs/decorators/elementDefine.js.map +2 -2
- package/dist/cjs/decorators/eventMedia.js +84 -0
- package/dist/cjs/decorators/eventMedia.js.map +7 -0
- package/dist/cjs/decorators/index.js +3 -0
- package/dist/cjs/decorators/index.js.map +2 -2
- package/dist/cjs/decorators/intersectionObserver.js +46 -55
- package/dist/cjs/decorators/intersectionObserver.js.map +2 -2
- package/dist/cjs/decorators/mutationObserver.js +46 -55
- package/dist/cjs/decorators/mutationObserver.js.map +2 -2
- package/dist/cjs/decorators/parameter.js +73 -0
- package/dist/cjs/decorators/parameter.js.map +7 -0
- package/dist/cjs/decorators/requestAnimationFrame.js +124 -0
- package/dist/cjs/decorators/requestAnimationFrame.js.map +7 -0
- package/dist/cjs/decorators/resizeObserver.js +46 -55
- package/dist/cjs/decorators/resizeObserver.js.map +2 -2
- package/dist/cjs/decorators/setInterval.js +46 -14
- package/dist/cjs/decorators/setInterval.js.map +2 -2
- package/dist/cjs/decorators/setTimeout.js +49 -14
- package/dist/cjs/decorators/setTimeout.js.map +2 -2
- package/dist/cjs/elements/SwcAppMixin.js +19 -3
- package/dist/cjs/elements/SwcAppMixin.js.map +2 -2
- package/dist/cjs/types/window.d.js.map +1 -1
- package/dist/esm/decorators/addEventListener.js +1994 -9
- package/dist/esm/decorators/addEventListener.js.map +2 -2
- package/dist/esm/decorators/applyAttribute.js +10 -4
- package/dist/esm/decorators/applyAttribute.js.map +2 -2
- package/dist/esm/decorators/applyClass.js +10 -4
- package/dist/esm/decorators/applyClass.js.map +2 -2
- package/dist/esm/decorators/applyNode.js +10 -4
- package/dist/esm/decorators/applyNode.js.map +2 -2
- package/dist/esm/decorators/applyProperty.js +14 -8
- package/dist/esm/decorators/applyProperty.js.map +2 -2
- package/dist/esm/decorators/applySlot.js +6 -5
- package/dist/esm/decorators/applySlot.js.map +2 -2
- package/dist/esm/decorators/applyStyle.js +10 -4
- package/dist/esm/decorators/applyStyle.js.map +2 -2
- package/dist/esm/decorators/changedAttribute.js +22 -13
- package/dist/esm/decorators/changedAttribute.js.map +2 -2
- package/dist/esm/decorators/elementDefine.js +18 -3
- package/dist/esm/decorators/elementDefine.js.map +2 -2
- package/dist/esm/decorators/eventMedia.js +66 -0
- package/dist/esm/decorators/eventMedia.js.map +7 -0
- package/dist/esm/decorators/index.js +3 -0
- package/dist/esm/decorators/index.js.map +2 -2
- package/dist/esm/decorators/intersectionObserver.js +46 -55
- package/dist/esm/decorators/intersectionObserver.js.map +2 -2
- package/dist/esm/decorators/mutationObserver.js +46 -55
- package/dist/esm/decorators/mutationObserver.js.map +2 -2
- package/dist/esm/decorators/parameter.js +54 -0
- package/dist/esm/decorators/parameter.js.map +7 -0
- package/dist/esm/decorators/requestAnimationFrame.js +105 -0
- package/dist/esm/decorators/requestAnimationFrame.js.map +7 -0
- package/dist/esm/decorators/resizeObserver.js +46 -55
- package/dist/esm/decorators/resizeObserver.js.map +2 -2
- package/dist/esm/decorators/setInterval.js +46 -15
- package/dist/esm/decorators/setInterval.js.map +2 -2
- package/dist/esm/decorators/setTimeout.js +49 -15
- package/dist/esm/decorators/setTimeout.js.map +2 -2
- package/dist/esm/elements/SwcAppMixin.js +20 -4
- package/dist/esm/elements/SwcAppMixin.js.map +2 -2
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +2813 -571
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +4 -4
- package/dist/types/decorators/addEventListener.d.ts +962 -0
- package/dist/types/decorators/addEventListener.d.ts.map +1 -1
- package/dist/types/decorators/applyAttribute.d.ts +2 -0
- package/dist/types/decorators/applyAttribute.d.ts.map +1 -1
- package/dist/types/decorators/applyClass.d.ts +2 -0
- package/dist/types/decorators/applyClass.d.ts.map +1 -1
- package/dist/types/decorators/applyNode.d.ts +2 -0
- package/dist/types/decorators/applyNode.d.ts.map +1 -1
- package/dist/types/decorators/applyProperty.d.ts +4 -0
- package/dist/types/decorators/applyProperty.d.ts.map +1 -1
- package/dist/types/decorators/applySlot.d.ts.map +1 -1
- package/dist/types/decorators/applyStyle.d.ts +2 -0
- package/dist/types/decorators/applyStyle.d.ts.map +1 -1
- package/dist/types/decorators/changedAttribute.d.ts +1 -3
- package/dist/types/decorators/changedAttribute.d.ts.map +1 -1
- package/dist/types/decorators/elementDefine.d.ts.map +1 -1
- package/dist/types/decorators/eventMedia.d.ts +25 -0
- package/dist/types/decorators/eventMedia.d.ts.map +1 -0
- package/dist/types/decorators/index.d.ts +3 -0
- package/dist/types/decorators/index.d.ts.map +1 -1
- package/dist/types/decorators/intersectionObserver.d.ts +9 -0
- package/dist/types/decorators/intersectionObserver.d.ts.map +1 -1
- package/dist/types/decorators/mutationObserver.d.ts +10 -1
- package/dist/types/decorators/mutationObserver.d.ts.map +1 -1
- package/dist/types/decorators/parameter.d.ts +35 -0
- package/dist/types/decorators/parameter.d.ts.map +1 -0
- package/dist/types/decorators/requestAnimationFrame.d.ts +47 -0
- package/dist/types/decorators/requestAnimationFrame.d.ts.map +1 -0
- package/dist/types/decorators/resizeObserver.d.ts +9 -0
- package/dist/types/decorators/resizeObserver.d.ts.map +1 -1
- package/dist/types/decorators/setInterval.d.ts +17 -5
- package/dist/types/decorators/setInterval.d.ts.map +1 -1
- package/dist/types/decorators/setTimeout.d.ts +17 -5
- package/dist/types/decorators/setTimeout.d.ts.map +1 -1
- package/dist/types/elements/SwcAppMixin.d.ts.map +1 -1
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +2813 -571
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +4 -4
- package/package.json +3 -3
- package/src/decorators/addEventListener.ts +1060 -8
- package/src/decorators/applyAttribute.ts +14 -4
- package/src/decorators/applyClass.ts +14 -4
- package/src/decorators/applyNode.ts +14 -4
- package/src/decorators/applyProperty.ts +28 -8
- package/src/decorators/applySlot.ts +6 -5
- package/src/decorators/applyStyle.ts +14 -4
- package/src/decorators/changedAttribute.ts +30 -15
- package/src/decorators/elementDefine.ts +32 -5
- package/src/decorators/eventMedia.ts +78 -0
- package/src/decorators/index.ts +3 -0
- package/src/decorators/intersectionObserver.ts +77 -61
- package/src/decorators/mutationObserver.ts +78 -61
- package/src/decorators/parameter.ts +81 -0
- package/src/decorators/requestAnimationFrame.ts +158 -0
- package/src/decorators/resizeObserver.ts +76 -60
- package/src/decorators/setInterval.ts +71 -15
- package/src/decorators/setTimeout.ts +74 -15
- package/src/elements/SwcAppMixin.ts +20 -5
- package/src/types/window.d.ts +2 -18
- package/dist/cjs/examples/RxJSOperatorsExample.js +0 -285
- package/dist/cjs/examples/RxJSOperatorsExample.js.map +0 -7
- package/dist/esm/examples/RxJSOperatorsExample.js +0 -266
- package/dist/esm/examples/RxJSOperatorsExample.js.map +0 -7
- package/dist/types/examples/RxJSOperatorsExample.d.ts +0 -94
- package/dist/types/examples/RxJSOperatorsExample.d.ts.map +0 -1
- package/src/examples/RxJSOperatorsExample.ts +0 -279
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SwcAppInterface, SwcAppMessage } from '../types';
|
|
2
|
-
import { APPLY_NODE_METADATA_KEY, findAllLifecycleMetadata, getSubscribeSwcAppMessageWhileConnectedMetadata, getSubscribeSwcAppRouteChangeWhileConnectedMetadata, ON_CONNECTED_SWC_APP_METADATA_KEY, SUBSCRIBE_SWC_APP_ROUTE_CHANGE_WHILE_CONNECTED_METADATA_KEY } from '../decorators';
|
|
2
|
+
import { APPLY_NODE_METADATA_KEY, findAllLifecycleMetadata, getSubscribeSwcAppMessageWhileConnectedMetadata, getSubscribeSwcAppRouteChangeWhileConnectedMetadata, ON_CONNECTED_SWC_APP_METADATA_KEY, SUBSCRIBE_SWC_APP_ROUTE_CHANGE_WHILE_CONNECTED_METADATA_KEY, buildSwcParameterArgs } from '../decorators';
|
|
3
3
|
import { SwcAppEngine, SwcAttributeConfigType, SwcConfigType } from '../SwcAppEngine';
|
|
4
4
|
import { debounceTimeIntervalLock, FunctionUtils, Subscription } from '@dooboostore/core';
|
|
5
5
|
import {RouterEventType, ValidUtils} from '@dooboostore/core-web';
|
|
@@ -83,8 +83,6 @@ export function SwcAppMixin<T extends { new (...args: any[]): HTMLElement }>(Bas
|
|
|
83
83
|
const routeChangeSubscribers = getSubscribeSwcAppRouteChangeWhileConnectedMetadata(instance);
|
|
84
84
|
|
|
85
85
|
if (routeChangeSubscribers.length > 0) {
|
|
86
|
-
console.log('[SWC-MIXIN] Route change subscribers found');
|
|
87
|
-
|
|
88
86
|
// Subscribers are already sorted by order from getSubscribeSwcAppRouteChangeWhileConnectedMetadata
|
|
89
87
|
// Execute subscribers in order, stop if one returns a value
|
|
90
88
|
for (const metadata of routeChangeSubscribers) {
|
|
@@ -127,7 +125,16 @@ export function SwcAppMixin<T extends { new (...args: any[]): HTMLElement }>(Bas
|
|
|
127
125
|
const filterPassed = !filter || filter(this.router!, { helper: hostSet, currentThis: instance });
|
|
128
126
|
|
|
129
127
|
if (pathMatched && filterPassed && instance[methodName]) {
|
|
130
|
-
const
|
|
128
|
+
const routeEventValue = { ...re, pathData: pathData };
|
|
129
|
+
const instanceHelperHostSet = SwcUtils.getHelperAndHostSet(this.config.window, instance);
|
|
130
|
+
const instanceHelperSet = SwcUtils.getHelperSet(this.config.window);
|
|
131
|
+
const args = buildSwcParameterArgs(instance, methodName, {
|
|
132
|
+
routerEvent: routeEventValue,
|
|
133
|
+
hostSet: instanceHelperHostSet,
|
|
134
|
+
helperHostSet: instanceHelperHostSet,
|
|
135
|
+
helperSet: instanceHelperSet
|
|
136
|
+
}, [routeEventValue]);
|
|
137
|
+
const result = extractValue(await instance[methodName](...args));
|
|
131
138
|
// if (typeof result === 'object'
|
|
132
139
|
// If handler returns a value, stop propagation to next handlers
|
|
133
140
|
if (result !== undefined && result !== null) {
|
|
@@ -348,7 +355,15 @@ export function SwcAppMixin<T extends { new (...args: any[]): HTMLElement }>(Bas
|
|
|
348
355
|
}
|
|
349
356
|
|
|
350
357
|
if (typeMatched && filterMatched && typeof instance[methodName] === 'function') {
|
|
351
|
-
instance
|
|
358
|
+
const instanceHelperHostSet = SwcUtils.getHelperAndHostSet(this.config.window, instance);
|
|
359
|
+
const instanceHelperSet = SwcUtils.getHelperSet(this.config.window);
|
|
360
|
+
const args = buildSwcParameterArgs(instance, methodName, {
|
|
361
|
+
appMessage: message,
|
|
362
|
+
hostSet: instanceHelperHostSet,
|
|
363
|
+
helperHostSet: instanceHelperHostSet,
|
|
364
|
+
helperSet: instanceHelperSet
|
|
365
|
+
}, [message]);
|
|
366
|
+
instance[methodName](...args);
|
|
352
367
|
}
|
|
353
368
|
});
|
|
354
369
|
}
|
package/src/types/window.d.ts
CHANGED
|
@@ -23,27 +23,11 @@ declare global {
|
|
|
23
23
|
history: History;
|
|
24
24
|
console: Console;
|
|
25
25
|
IntersectionObserver: typeof IntersectionObserver;
|
|
26
|
+
ResizeObserver: typeof ResizeObserver;
|
|
27
|
+
MutationObserver: typeof MutationObserver;
|
|
26
28
|
SwaggerUIBundle: any;
|
|
27
29
|
|
|
28
30
|
}
|
|
29
|
-
|
|
30
|
-
namespace Dooboostore {
|
|
31
|
-
interface PackageInfo {
|
|
32
|
-
id: string;
|
|
33
|
-
name: string;
|
|
34
|
-
description: string;
|
|
35
|
-
longDescription: string;
|
|
36
|
-
icon: string;
|
|
37
|
-
color: string;
|
|
38
|
-
features: PackageFeature[];
|
|
39
|
-
example: string;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
interface PackageFeature {
|
|
43
|
-
title: string;
|
|
44
|
-
desc: string;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
31
|
}
|
|
48
32
|
|
|
49
33
|
export {};
|
|
@@ -1,285 +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 RxJSOperatorsExample_exports = {};
|
|
19
|
-
__export(RxJSOperatorsExample_exports, {
|
|
20
|
-
AutoSaveEditor: () => AutoSaveEditor,
|
|
21
|
-
FormInput: () => FormInput,
|
|
22
|
-
InfiniteScroll: () => InfiniteScroll,
|
|
23
|
-
KeyboardHandler: () => KeyboardHandler,
|
|
24
|
-
LengthTracker: () => LengthTracker,
|
|
25
|
-
MouseTracker: () => MouseTracker,
|
|
26
|
-
ResponsiveLayout: () => ResponsiveLayout,
|
|
27
|
-
SearchComponent: () => SearchComponent
|
|
28
|
-
});
|
|
29
|
-
module.exports = __toCommonJS(RxJSOperatorsExample_exports);
|
|
30
|
-
var import_decorators = require("../decorators");
|
|
31
|
-
var __decorate = function(decorators, target, key, desc) {
|
|
32
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
33
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
34
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
35
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
36
|
-
};
|
|
37
|
-
var __metadata = function(k, v) {
|
|
38
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
39
|
-
};
|
|
40
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
41
|
-
let SearchComponent = class SearchComponent2 extends HTMLElement {
|
|
42
|
-
constructor() {
|
|
43
|
-
super(...arguments);
|
|
44
|
-
this.results = [];
|
|
45
|
-
}
|
|
46
|
-
async onSearchInput(event) {
|
|
47
|
-
const input = event.target;
|
|
48
|
-
const query = input.value.trim();
|
|
49
|
-
if (query.length > 2) {
|
|
50
|
-
try {
|
|
51
|
-
const response = await fetch(`/api/search?q=${encodeURIComponent(query)}`);
|
|
52
|
-
this.results = await response.json();
|
|
53
|
-
this.renderResults();
|
|
54
|
-
} catch (error) {
|
|
55
|
-
console.error("Search failed:", error);
|
|
56
|
-
}
|
|
57
|
-
} else {
|
|
58
|
-
this.results = [];
|
|
59
|
-
this.renderResults();
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
renderResults() {
|
|
63
|
-
console.log("Rendering results:", this.results);
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
__decorate([
|
|
67
|
-
(0, import_decorators.addEventListener)("$this", "input", { debounceTime: 1e3 }),
|
|
68
|
-
__metadata("design:type", Function),
|
|
69
|
-
__metadata("design:paramtypes", [typeof (_a = typeof Event !== "undefined" && Event) === "function" ? _a : Object]),
|
|
70
|
-
__metadata("design:returntype", Promise)
|
|
71
|
-
], SearchComponent.prototype, "onSearchInput", null);
|
|
72
|
-
SearchComponent = __decorate([
|
|
73
|
-
(0, import_decorators.elementDefine)("search-component")
|
|
74
|
-
], SearchComponent);
|
|
75
|
-
let ResponsiveLayout = class ResponsiveLayout2 extends HTMLElement {
|
|
76
|
-
onWindowResize(event) {
|
|
77
|
-
const width = window.innerWidth;
|
|
78
|
-
const height = window.innerHeight;
|
|
79
|
-
console.log(`Window resized to: ${width}x${height}`);
|
|
80
|
-
this.updateLayout(width, height);
|
|
81
|
-
}
|
|
82
|
-
updateLayout(width, height) {
|
|
83
|
-
if (width < 768) {
|
|
84
|
-
this.classList.add("mobile");
|
|
85
|
-
this.classList.remove("desktop");
|
|
86
|
-
} else {
|
|
87
|
-
this.classList.add("desktop");
|
|
88
|
-
this.classList.remove("mobile");
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
__decorate([
|
|
93
|
-
(0, import_decorators.addEventListener)("$window", "resize", { throttleTime: 250 }),
|
|
94
|
-
__metadata("design:type", Function),
|
|
95
|
-
__metadata("design:paramtypes", [typeof (_b = typeof Event !== "undefined" && Event) === "function" ? _b : Object]),
|
|
96
|
-
__metadata("design:returntype", void 0)
|
|
97
|
-
], ResponsiveLayout.prototype, "onWindowResize", null);
|
|
98
|
-
ResponsiveLayout = __decorate([
|
|
99
|
-
(0, import_decorators.elementDefine)("responsive-layout")
|
|
100
|
-
], ResponsiveLayout);
|
|
101
|
-
let FormInput = class FormInput2 extends HTMLElement {
|
|
102
|
-
onFormInput(event) {
|
|
103
|
-
const input = event.target;
|
|
104
|
-
const fieldName = input.name;
|
|
105
|
-
const value = input.value;
|
|
106
|
-
console.log(`Validating ${fieldName}: ${value}`);
|
|
107
|
-
this.validateField(fieldName, value);
|
|
108
|
-
}
|
|
109
|
-
validateField(name, value) {
|
|
110
|
-
const isValid = value.length > 0;
|
|
111
|
-
console.log(`Field ${name} is ${isValid ? "valid" : "invalid"}`);
|
|
112
|
-
}
|
|
113
|
-
};
|
|
114
|
-
__decorate([
|
|
115
|
-
(0, import_decorators.addEventListener)("$this", "input", {
|
|
116
|
-
debounceTime: 300,
|
|
117
|
-
distinctUntilChanged: true
|
|
118
|
-
}),
|
|
119
|
-
__metadata("design:type", Function),
|
|
120
|
-
__metadata("design:paramtypes", [typeof (_c = typeof Event !== "undefined" && Event) === "function" ? _c : Object]),
|
|
121
|
-
__metadata("design:returntype", void 0)
|
|
122
|
-
], FormInput.prototype, "onFormInput", null);
|
|
123
|
-
FormInput = __decorate([
|
|
124
|
-
(0, import_decorators.elementDefine)("form-input")
|
|
125
|
-
], FormInput);
|
|
126
|
-
let InfiniteScroll = class InfiniteScroll2 extends HTMLElement {
|
|
127
|
-
constructor() {
|
|
128
|
-
super(...arguments);
|
|
129
|
-
this.isLoading = false;
|
|
130
|
-
}
|
|
131
|
-
onScroll(event) {
|
|
132
|
-
if (this.isLoading)
|
|
133
|
-
return;
|
|
134
|
-
if (this.isNearBottom()) {
|
|
135
|
-
console.log("Near bottom, loading more content...");
|
|
136
|
-
this.loadMoreContent();
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
isNearBottom() {
|
|
140
|
-
const scrollTop = window.scrollY;
|
|
141
|
-
const windowHeight = window.innerHeight;
|
|
142
|
-
const documentHeight = document.documentElement.scrollHeight;
|
|
143
|
-
return scrollTop + windowHeight >= documentHeight - 500;
|
|
144
|
-
}
|
|
145
|
-
async loadMoreContent() {
|
|
146
|
-
this.isLoading = true;
|
|
147
|
-
try {
|
|
148
|
-
await new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
149
|
-
console.log("Content loaded");
|
|
150
|
-
} finally {
|
|
151
|
-
this.isLoading = false;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
};
|
|
155
|
-
__decorate([
|
|
156
|
-
(0, import_decorators.addEventListener)("$window", "scroll", { throttleTime: 100 }),
|
|
157
|
-
__metadata("design:type", Function),
|
|
158
|
-
__metadata("design:paramtypes", [typeof (_d = typeof Event !== "undefined" && Event) === "function" ? _d : Object]),
|
|
159
|
-
__metadata("design:returntype", void 0)
|
|
160
|
-
], InfiniteScroll.prototype, "onScroll", null);
|
|
161
|
-
InfiniteScroll = __decorate([
|
|
162
|
-
(0, import_decorators.elementDefine)("infinite-scroll")
|
|
163
|
-
], InfiniteScroll);
|
|
164
|
-
let LengthTracker = class LengthTracker2 extends HTMLElement {
|
|
165
|
-
onInputChange(event) {
|
|
166
|
-
const input = event.target;
|
|
167
|
-
const length = input.value.length;
|
|
168
|
-
console.log(`Input length changed to: ${length}`);
|
|
169
|
-
this.updateLengthDisplay(length);
|
|
170
|
-
}
|
|
171
|
-
updateLengthDisplay(length) {
|
|
172
|
-
const display = this.querySelector(".length-display");
|
|
173
|
-
if (display) {
|
|
174
|
-
display.textContent = `${length} characters`;
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
};
|
|
178
|
-
__decorate([
|
|
179
|
-
(0, import_decorators.addEventListener)("$this", "input", {
|
|
180
|
-
distinctUntilChanged: (prev, curr) => {
|
|
181
|
-
return prev?.length === curr?.length;
|
|
182
|
-
}
|
|
183
|
-
}),
|
|
184
|
-
__metadata("design:type", Function),
|
|
185
|
-
__metadata("design:paramtypes", [typeof (_e = typeof Event !== "undefined" && Event) === "function" ? _e : Object]),
|
|
186
|
-
__metadata("design:returntype", void 0)
|
|
187
|
-
], LengthTracker.prototype, "onInputChange", null);
|
|
188
|
-
LengthTracker = __decorate([
|
|
189
|
-
(0, import_decorators.elementDefine)("length-tracker")
|
|
190
|
-
], LengthTracker);
|
|
191
|
-
let AutoSaveEditor = class AutoSaveEditor2 extends HTMLElement {
|
|
192
|
-
constructor() {
|
|
193
|
-
super(...arguments);
|
|
194
|
-
this.lastSavedContent = "";
|
|
195
|
-
}
|
|
196
|
-
async onContentChange(event) {
|
|
197
|
-
const textarea = event.target;
|
|
198
|
-
const content = textarea.value;
|
|
199
|
-
if (content !== this.lastSavedContent) {
|
|
200
|
-
console.log("Auto-saving content...");
|
|
201
|
-
await this.saveContent(content);
|
|
202
|
-
this.lastSavedContent = content;
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
async saveContent(content) {
|
|
206
|
-
try {
|
|
207
|
-
const response = await fetch("/api/save", {
|
|
208
|
-
method: "POST",
|
|
209
|
-
headers: { "Content-Type": "application/json" },
|
|
210
|
-
body: JSON.stringify({ content })
|
|
211
|
-
});
|
|
212
|
-
if (response.ok) {
|
|
213
|
-
console.log("Content saved successfully");
|
|
214
|
-
this.showSaveIndicator();
|
|
215
|
-
}
|
|
216
|
-
} catch (error) {
|
|
217
|
-
console.error("Save failed:", error);
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
showSaveIndicator() {
|
|
221
|
-
const indicator = this.querySelector(".save-indicator");
|
|
222
|
-
if (indicator) {
|
|
223
|
-
indicator.classList.add("show");
|
|
224
|
-
setTimeout(() => indicator.classList.remove("show"), 2e3);
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
};
|
|
228
|
-
__decorate([
|
|
229
|
-
(0, import_decorators.addEventListener)("$this", "input", {
|
|
230
|
-
debounceTime: 2e3,
|
|
231
|
-
distinctUntilChanged: (prev, curr) => {
|
|
232
|
-
return prev === curr;
|
|
233
|
-
}
|
|
234
|
-
}),
|
|
235
|
-
__metadata("design:type", Function),
|
|
236
|
-
__metadata("design:paramtypes", [typeof (_f = typeof Event !== "undefined" && Event) === "function" ? _f : Object]),
|
|
237
|
-
__metadata("design:returntype", Promise)
|
|
238
|
-
], AutoSaveEditor.prototype, "onContentChange", null);
|
|
239
|
-
AutoSaveEditor = __decorate([
|
|
240
|
-
(0, import_decorators.elementDefine)("auto-save-editor")
|
|
241
|
-
], AutoSaveEditor);
|
|
242
|
-
let KeyboardHandler = class KeyboardHandler2 extends HTMLElement {
|
|
243
|
-
onSaveShortcut(event) {
|
|
244
|
-
event.preventDefault();
|
|
245
|
-
console.log("Save shortcut triggered");
|
|
246
|
-
this.handleSave();
|
|
247
|
-
}
|
|
248
|
-
handleSave() {
|
|
249
|
-
console.log("Saving...");
|
|
250
|
-
}
|
|
251
|
-
};
|
|
252
|
-
__decorate([
|
|
253
|
-
(0, import_decorators.addEventListener)("$document", "keydown", {
|
|
254
|
-
throttleTime: 500,
|
|
255
|
-
filter: (event) => {
|
|
256
|
-
return (event.ctrlKey || event.metaKey) && event.key === "s";
|
|
257
|
-
}
|
|
258
|
-
}),
|
|
259
|
-
__metadata("design:type", Function),
|
|
260
|
-
__metadata("design:paramtypes", [typeof (_g = typeof KeyboardEvent !== "undefined" && KeyboardEvent) === "function" ? _g : Object]),
|
|
261
|
-
__metadata("design:returntype", void 0)
|
|
262
|
-
], KeyboardHandler.prototype, "onSaveShortcut", null);
|
|
263
|
-
KeyboardHandler = __decorate([
|
|
264
|
-
(0, import_decorators.elementDefine)("keyboard-handler")
|
|
265
|
-
], KeyboardHandler);
|
|
266
|
-
let MouseTracker = class MouseTracker2 extends HTMLElement {
|
|
267
|
-
onMouseMove(event) {
|
|
268
|
-
const x = event.clientX;
|
|
269
|
-
const y = event.clientY;
|
|
270
|
-
this.updateCursorPosition(x, y);
|
|
271
|
-
}
|
|
272
|
-
updateCursorPosition(x, y) {
|
|
273
|
-
console.log(`Cursor at: ${x}, ${y}`);
|
|
274
|
-
}
|
|
275
|
-
};
|
|
276
|
-
__decorate([
|
|
277
|
-
(0, import_decorators.addEventListener)("$document", "mousemove", { throttleTime: 100 }),
|
|
278
|
-
__metadata("design:type", Function),
|
|
279
|
-
__metadata("design:paramtypes", [typeof (_h = typeof MouseEvent !== "undefined" && MouseEvent) === "function" ? _h : Object]),
|
|
280
|
-
__metadata("design:returntype", void 0)
|
|
281
|
-
], MouseTracker.prototype, "onMouseMove", null);
|
|
282
|
-
MouseTracker = __decorate([
|
|
283
|
-
(0, import_decorators.elementDefine)("mouse-tracker")
|
|
284
|
-
], MouseTracker);
|
|
285
|
-
//# sourceMappingURL=RxJSOperatorsExample.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/examples/RxJSOperatorsExample.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Example: Using RxJS-like Operators with @addEventListener\n * \n * This example demonstrates how to use debounceTime, throttleTime, and distinctUntilChanged\n * operators with the @addEventListener decorator.\n */\n\nimport { elementDefine, addEventListener } from '../decorators';\n\n/**\n * Example 1: Search Component with Debounce\n * \n * Waits 1 second after user stops typing before performing search.\n * Prevents excessive API calls during typing.\n */\n@elementDefine('search-component')\nexport class SearchComponent extends HTMLElement {\n private results: any[] = [];\n\n @addEventListener('$this', 'input', { debounceTime: 1000 })\n async onSearchInput(event: Event) {\n const input = event.target as HTMLInputElement;\n const query = input.value.trim();\n\n if (query.length > 2) {\n try {\n // Simulate API call\n const response = await fetch(`/api/search?q=${encodeURIComponent(query)}`);\n this.results = await response.json();\n this.renderResults();\n } catch (error) {\n console.error('Search failed:', error);\n }\n } else {\n this.results = [];\n this.renderResults();\n }\n }\n\n private renderResults() {\n // Render search results\n console.log('Rendering results:', this.results);\n }\n}\n\n/**\n * Example 2: Window Resize Handler with Throttle\n * \n * Recalculates layout at most 4 times per second (every 250ms).\n * Prevents performance issues from excessive resize calculations.\n */\n@elementDefine('responsive-layout')\nexport class ResponsiveLayout extends HTMLElement {\n @addEventListener('$window', 'resize', { throttleTime: 250 })\n onWindowResize(event: Event) {\n const width = window.innerWidth;\n const height = window.innerHeight;\n\n console.log(`Window resized to: ${width}x${height}`);\n this.updateLayout(width, height);\n }\n\n private updateLayout(width: number, height: number) {\n // Update layout based on new dimensions\n if (width < 768) {\n this.classList.add('mobile');\n this.classList.remove('desktop');\n } else {\n this.classList.add('desktop');\n this.classList.remove('mobile');\n }\n }\n}\n\n/**\n * Example 3: Form Input with Debounce + Distinct\n * \n * Validates field only when:\n * 1. User stops typing (debounce 300ms)\n * 2. AND the value actually changed (distinct)\n */\n@elementDefine('form-input')\nexport class FormInput extends HTMLElement {\n @addEventListener('$this', 'input', {\n debounceTime: 300,\n distinctUntilChanged: true\n })\n onFormInput(event: Event) {\n const input = event.target as HTMLInputElement;\n const fieldName = input.name;\n const value = input.value;\n\n console.log(`Validating ${fieldName}: ${value}`);\n this.validateField(fieldName, value);\n }\n\n private validateField(name: string, value: string) {\n // Perform validation\n const isValid = value.length > 0;\n console.log(`Field ${name} is ${isValid ? 'valid' : 'invalid'}`);\n }\n}\n\n/**\n * Example 4: Scroll Event with Throttle\n * \n * Checks if user scrolled to bottom at most 10 times per second.\n * Prevents excessive \"load more\" API calls.\n */\n@elementDefine('infinite-scroll')\nexport class InfiniteScroll extends HTMLElement {\n private isLoading = false;\n\n @addEventListener('$window', 'scroll', { throttleTime: 100 })\n onScroll(event: Event) {\n if (this.isLoading) return;\n\n if (this.isNearBottom()) {\n console.log('Near bottom, loading more content...');\n this.loadMoreContent();\n }\n }\n\n private isNearBottom(): boolean {\n const scrollTop = window.scrollY;\n const windowHeight = window.innerHeight;\n const documentHeight = document.documentElement.scrollHeight;\n\n return scrollTop + windowHeight >= documentHeight - 500;\n }\n\n private async loadMoreContent() {\n this.isLoading = true;\n try {\n // Simulate API call\n await new Promise(resolve => setTimeout(resolve, 1000));\n console.log('Content loaded');\n } finally {\n this.isLoading = false;\n }\n }\n}\n\n/**\n * Example 5: Custom Comparison with Distinct\n * \n * Only fires when the input value length changes.\n * Ignores changes that don't affect the length.\n */\n@elementDefine('length-tracker')\nexport class LengthTracker extends HTMLElement {\n @addEventListener('$this', 'input', {\n distinctUntilChanged: (prev: any, curr: any) => {\n // Only consider it changed if the length differs\n return prev?.length === curr?.length;\n }\n })\n onInputChange(event: Event) {\n const input = event.target as HTMLInputElement;\n const length = input.value.length;\n\n console.log(`Input length changed to: ${length}`);\n this.updateLengthDisplay(length);\n }\n\n private updateLengthDisplay(length: number) {\n // Update UI with new length\n const display = this.querySelector('.length-display');\n if (display) {\n display.textContent = `${length} characters`;\n }\n }\n}\n\n/**\n * Example 6: Complex Scenario - Auto-save with Multiple Operators\n * \n * Combines debounce and distinct for intelligent auto-save:\n * - Waits 2 seconds after user stops typing\n * - Only saves if content actually changed\n * - Prevents unnecessary save operations\n */\n@elementDefine('auto-save-editor')\nexport class AutoSaveEditor extends HTMLElement {\n private lastSavedContent = '';\n\n @addEventListener('$this', 'input', {\n debounceTime: 2000,\n distinctUntilChanged: (prev: any, curr: any) => {\n // Consider changed if the content is different\n return prev === curr;\n }\n })\n async onContentChange(event: Event) {\n const textarea = event.target as HTMLTextAreaElement;\n const content = textarea.value;\n\n if (content !== this.lastSavedContent) {\n console.log('Auto-saving content...');\n await this.saveContent(content);\n this.lastSavedContent = content;\n }\n }\n\n private async saveContent(content: string) {\n try {\n // Simulate API call\n const response = await fetch('/api/save', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ content })\n });\n\n if (response.ok) {\n console.log('Content saved successfully');\n this.showSaveIndicator();\n }\n } catch (error) {\n console.error('Save failed:', error);\n }\n }\n\n private showSaveIndicator() {\n const indicator = this.querySelector('.save-indicator');\n if (indicator) {\n indicator.classList.add('show');\n setTimeout(() => indicator.classList.remove('show'), 2000);\n }\n }\n}\n\n/**\n * Example 7: Keyboard Shortcut Handler with Throttle\n * \n * Prevents rapid repeated execution of keyboard shortcuts.\n */\n@elementDefine('keyboard-handler')\nexport class KeyboardHandler extends HTMLElement {\n @addEventListener('$document', 'keydown', {\n throttleTime: 500,\n filter: (event: KeyboardEvent) => {\n // Only handle Ctrl+S or Cmd+S\n return (event.ctrlKey || event.metaKey) && event.key === 's';\n }\n })\n onSaveShortcut(event: KeyboardEvent) {\n event.preventDefault();\n console.log('Save shortcut triggered');\n this.handleSave();\n }\n\n private handleSave() {\n // Handle save operation\n console.log('Saving...');\n }\n}\n\n/**\n * Example 8: Mouse Move Tracking with Throttle\n * \n * Tracks mouse position at most 10 times per second.\n * Useful for analytics or interactive features.\n */\n@elementDefine('mouse-tracker')\nexport class MouseTracker extends HTMLElement {\n @addEventListener('$document', 'mousemove', { throttleTime: 100 })\n onMouseMove(event: MouseEvent) {\n const x = event.clientX;\n const y = event.clientY;\n\n // Update cursor position indicator\n this.updateCursorPosition(x, y);\n }\n\n private updateCursorPosition(x: number, y: number) {\n // Update UI with cursor position\n console.log(`Cursor at: ${x}, ${y}`);\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;AAOA,wBAAgD;;;;;;;;;;;AASzC,IAAM,kBAAN,MAAMA,yBAAwB,YAAW;EAAzC,cAAA;;AACG,SAAA,UAAiB,CAAA;EA0B3B;EAvBE,MAAM,cAAc,OAAY;AAC9B,UAAM,QAAQ,MAAM;AACpB,UAAM,QAAQ,MAAM,MAAM,KAAI;AAE9B,QAAI,MAAM,SAAS,GAAG;AACpB,UAAI;AAEF,cAAM,WAAW,MAAM,MAAM,iBAAiB,mBAAmB,KAAK,CAAC,EAAE;AACzE,aAAK,UAAU,MAAM,SAAS,KAAI;AAClC,aAAK,cAAa;MACpB,SAAS,OAAO;AACd,gBAAQ,MAAM,kBAAkB,KAAK;MACvC;IACF,OAAO;AACL,WAAK,UAAU,CAAA;AACf,WAAK,cAAa;IACpB;EACF;EAEQ,gBAAa;AAEnB,YAAQ,IAAI,sBAAsB,KAAK,OAAO;EAChD;;AAtBM,WAAA;MADL,oCAAiB,SAAS,SAAS,EAAE,cAAc,IAAI,CAAE;;uDAC/B,UAAK,eAAL,WAAK,aAAA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D;GACD;;uDACqB,kBAAa,eAAb,mBAAa,aAAA,KAAA,MAAA,CAAA;;;AARxB,kBAAe,WAAA;MAD3B,iCAAc,kBAAkB;GACpB,eAAe;AA2BrB,IAAM,eAAN,MAAMC,sBAAqB,YAAW;EAE3C,YAAY,OAAiB;AAC3B,UAAM,IAAI,MAAM;AAChB,UAAM,IAAI,MAAM;AAGhB,SAAK,qBAAqB,GAAG,CAAC;EAChC;EAEQ,qBAAqB,GAAW,GAAS;AAE/C,YAAQ,IAAI,cAAc,CAAC,KAAK,CAAC,EAAE;EACrC;;AAXA,WAAA;MADC,oCAAiB,aAAa,aAAa,EAAE,cAAc,IAAG,CAAE;;uDAC9C,eAAU,eAAV,gBAAU,aAAA,KAAA,MAAA,CAAA;;;AAFlB,eAAY,WAAA;MADxB,iCAAc,eAAe;GACjB,YAAY;",
|
|
6
|
-
"names": ["SearchComponent", "ResponsiveLayout", "FormInput", "InfiniteScroll", "LengthTracker", "AutoSaveEditor", "KeyboardHandler", "MouseTracker"]
|
|
7
|
-
}
|
|
@@ -1,266 +0,0 @@
|
|
|
1
|
-
var __decorate = function(decorators, target, key, desc) {
|
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
|
-
var __metadata = function(k, v) {
|
|
8
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
-
};
|
|
10
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
11
|
-
import { elementDefine, addEventListener } from "../decorators/index.js";
|
|
12
|
-
let SearchComponent = class SearchComponent2 extends HTMLElement {
|
|
13
|
-
constructor() {
|
|
14
|
-
super(...arguments);
|
|
15
|
-
this.results = [];
|
|
16
|
-
}
|
|
17
|
-
async onSearchInput(event) {
|
|
18
|
-
const input = event.target;
|
|
19
|
-
const query = input.value.trim();
|
|
20
|
-
if (query.length > 2) {
|
|
21
|
-
try {
|
|
22
|
-
const response = await fetch(`/api/search?q=${encodeURIComponent(query)}`);
|
|
23
|
-
this.results = await response.json();
|
|
24
|
-
this.renderResults();
|
|
25
|
-
} catch (error) {
|
|
26
|
-
console.error("Search failed:", error);
|
|
27
|
-
}
|
|
28
|
-
} else {
|
|
29
|
-
this.results = [];
|
|
30
|
-
this.renderResults();
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
renderResults() {
|
|
34
|
-
console.log("Rendering results:", this.results);
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
__decorate([
|
|
38
|
-
addEventListener("$this", "input", { debounceTime: 1e3 }),
|
|
39
|
-
__metadata("design:type", Function),
|
|
40
|
-
__metadata("design:paramtypes", [typeof (_a = typeof Event !== "undefined" && Event) === "function" ? _a : Object]),
|
|
41
|
-
__metadata("design:returntype", Promise)
|
|
42
|
-
], SearchComponent.prototype, "onSearchInput", null);
|
|
43
|
-
SearchComponent = __decorate([
|
|
44
|
-
elementDefine("search-component")
|
|
45
|
-
], SearchComponent);
|
|
46
|
-
let ResponsiveLayout = class ResponsiveLayout2 extends HTMLElement {
|
|
47
|
-
onWindowResize(event) {
|
|
48
|
-
const width = window.innerWidth;
|
|
49
|
-
const height = window.innerHeight;
|
|
50
|
-
console.log(`Window resized to: ${width}x${height}`);
|
|
51
|
-
this.updateLayout(width, height);
|
|
52
|
-
}
|
|
53
|
-
updateLayout(width, height) {
|
|
54
|
-
if (width < 768) {
|
|
55
|
-
this.classList.add("mobile");
|
|
56
|
-
this.classList.remove("desktop");
|
|
57
|
-
} else {
|
|
58
|
-
this.classList.add("desktop");
|
|
59
|
-
this.classList.remove("mobile");
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
__decorate([
|
|
64
|
-
addEventListener("$window", "resize", { throttleTime: 250 }),
|
|
65
|
-
__metadata("design:type", Function),
|
|
66
|
-
__metadata("design:paramtypes", [typeof (_b = typeof Event !== "undefined" && Event) === "function" ? _b : Object]),
|
|
67
|
-
__metadata("design:returntype", void 0)
|
|
68
|
-
], ResponsiveLayout.prototype, "onWindowResize", null);
|
|
69
|
-
ResponsiveLayout = __decorate([
|
|
70
|
-
elementDefine("responsive-layout")
|
|
71
|
-
], ResponsiveLayout);
|
|
72
|
-
let FormInput = class FormInput2 extends HTMLElement {
|
|
73
|
-
onFormInput(event) {
|
|
74
|
-
const input = event.target;
|
|
75
|
-
const fieldName = input.name;
|
|
76
|
-
const value = input.value;
|
|
77
|
-
console.log(`Validating ${fieldName}: ${value}`);
|
|
78
|
-
this.validateField(fieldName, value);
|
|
79
|
-
}
|
|
80
|
-
validateField(name, value) {
|
|
81
|
-
const isValid = value.length > 0;
|
|
82
|
-
console.log(`Field ${name} is ${isValid ? "valid" : "invalid"}`);
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
__decorate([
|
|
86
|
-
addEventListener("$this", "input", {
|
|
87
|
-
debounceTime: 300,
|
|
88
|
-
distinctUntilChanged: true
|
|
89
|
-
}),
|
|
90
|
-
__metadata("design:type", Function),
|
|
91
|
-
__metadata("design:paramtypes", [typeof (_c = typeof Event !== "undefined" && Event) === "function" ? _c : Object]),
|
|
92
|
-
__metadata("design:returntype", void 0)
|
|
93
|
-
], FormInput.prototype, "onFormInput", null);
|
|
94
|
-
FormInput = __decorate([
|
|
95
|
-
elementDefine("form-input")
|
|
96
|
-
], FormInput);
|
|
97
|
-
let InfiniteScroll = class InfiniteScroll2 extends HTMLElement {
|
|
98
|
-
constructor() {
|
|
99
|
-
super(...arguments);
|
|
100
|
-
this.isLoading = false;
|
|
101
|
-
}
|
|
102
|
-
onScroll(event) {
|
|
103
|
-
if (this.isLoading)
|
|
104
|
-
return;
|
|
105
|
-
if (this.isNearBottom()) {
|
|
106
|
-
console.log("Near bottom, loading more content...");
|
|
107
|
-
this.loadMoreContent();
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
isNearBottom() {
|
|
111
|
-
const scrollTop = window.scrollY;
|
|
112
|
-
const windowHeight = window.innerHeight;
|
|
113
|
-
const documentHeight = document.documentElement.scrollHeight;
|
|
114
|
-
return scrollTop + windowHeight >= documentHeight - 500;
|
|
115
|
-
}
|
|
116
|
-
async loadMoreContent() {
|
|
117
|
-
this.isLoading = true;
|
|
118
|
-
try {
|
|
119
|
-
await new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
120
|
-
console.log("Content loaded");
|
|
121
|
-
} finally {
|
|
122
|
-
this.isLoading = false;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
};
|
|
126
|
-
__decorate([
|
|
127
|
-
addEventListener("$window", "scroll", { throttleTime: 100 }),
|
|
128
|
-
__metadata("design:type", Function),
|
|
129
|
-
__metadata("design:paramtypes", [typeof (_d = typeof Event !== "undefined" && Event) === "function" ? _d : Object]),
|
|
130
|
-
__metadata("design:returntype", void 0)
|
|
131
|
-
], InfiniteScroll.prototype, "onScroll", null);
|
|
132
|
-
InfiniteScroll = __decorate([
|
|
133
|
-
elementDefine("infinite-scroll")
|
|
134
|
-
], InfiniteScroll);
|
|
135
|
-
let LengthTracker = class LengthTracker2 extends HTMLElement {
|
|
136
|
-
onInputChange(event) {
|
|
137
|
-
const input = event.target;
|
|
138
|
-
const length = input.value.length;
|
|
139
|
-
console.log(`Input length changed to: ${length}`);
|
|
140
|
-
this.updateLengthDisplay(length);
|
|
141
|
-
}
|
|
142
|
-
updateLengthDisplay(length) {
|
|
143
|
-
const display = this.querySelector(".length-display");
|
|
144
|
-
if (display) {
|
|
145
|
-
display.textContent = `${length} characters`;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
};
|
|
149
|
-
__decorate([
|
|
150
|
-
addEventListener("$this", "input", {
|
|
151
|
-
distinctUntilChanged: (prev, curr) => {
|
|
152
|
-
return prev?.length === curr?.length;
|
|
153
|
-
}
|
|
154
|
-
}),
|
|
155
|
-
__metadata("design:type", Function),
|
|
156
|
-
__metadata("design:paramtypes", [typeof (_e = typeof Event !== "undefined" && Event) === "function" ? _e : Object]),
|
|
157
|
-
__metadata("design:returntype", void 0)
|
|
158
|
-
], LengthTracker.prototype, "onInputChange", null);
|
|
159
|
-
LengthTracker = __decorate([
|
|
160
|
-
elementDefine("length-tracker")
|
|
161
|
-
], LengthTracker);
|
|
162
|
-
let AutoSaveEditor = class AutoSaveEditor2 extends HTMLElement {
|
|
163
|
-
constructor() {
|
|
164
|
-
super(...arguments);
|
|
165
|
-
this.lastSavedContent = "";
|
|
166
|
-
}
|
|
167
|
-
async onContentChange(event) {
|
|
168
|
-
const textarea = event.target;
|
|
169
|
-
const content = textarea.value;
|
|
170
|
-
if (content !== this.lastSavedContent) {
|
|
171
|
-
console.log("Auto-saving content...");
|
|
172
|
-
await this.saveContent(content);
|
|
173
|
-
this.lastSavedContent = content;
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
async saveContent(content) {
|
|
177
|
-
try {
|
|
178
|
-
const response = await fetch("/api/save", {
|
|
179
|
-
method: "POST",
|
|
180
|
-
headers: { "Content-Type": "application/json" },
|
|
181
|
-
body: JSON.stringify({ content })
|
|
182
|
-
});
|
|
183
|
-
if (response.ok) {
|
|
184
|
-
console.log("Content saved successfully");
|
|
185
|
-
this.showSaveIndicator();
|
|
186
|
-
}
|
|
187
|
-
} catch (error) {
|
|
188
|
-
console.error("Save failed:", error);
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
showSaveIndicator() {
|
|
192
|
-
const indicator = this.querySelector(".save-indicator");
|
|
193
|
-
if (indicator) {
|
|
194
|
-
indicator.classList.add("show");
|
|
195
|
-
setTimeout(() => indicator.classList.remove("show"), 2e3);
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
};
|
|
199
|
-
__decorate([
|
|
200
|
-
addEventListener("$this", "input", {
|
|
201
|
-
debounceTime: 2e3,
|
|
202
|
-
distinctUntilChanged: (prev, curr) => {
|
|
203
|
-
return prev === curr;
|
|
204
|
-
}
|
|
205
|
-
}),
|
|
206
|
-
__metadata("design:type", Function),
|
|
207
|
-
__metadata("design:paramtypes", [typeof (_f = typeof Event !== "undefined" && Event) === "function" ? _f : Object]),
|
|
208
|
-
__metadata("design:returntype", Promise)
|
|
209
|
-
], AutoSaveEditor.prototype, "onContentChange", null);
|
|
210
|
-
AutoSaveEditor = __decorate([
|
|
211
|
-
elementDefine("auto-save-editor")
|
|
212
|
-
], AutoSaveEditor);
|
|
213
|
-
let KeyboardHandler = class KeyboardHandler2 extends HTMLElement {
|
|
214
|
-
onSaveShortcut(event) {
|
|
215
|
-
event.preventDefault();
|
|
216
|
-
console.log("Save shortcut triggered");
|
|
217
|
-
this.handleSave();
|
|
218
|
-
}
|
|
219
|
-
handleSave() {
|
|
220
|
-
console.log("Saving...");
|
|
221
|
-
}
|
|
222
|
-
};
|
|
223
|
-
__decorate([
|
|
224
|
-
addEventListener("$document", "keydown", {
|
|
225
|
-
throttleTime: 500,
|
|
226
|
-
filter: (event) => {
|
|
227
|
-
return (event.ctrlKey || event.metaKey) && event.key === "s";
|
|
228
|
-
}
|
|
229
|
-
}),
|
|
230
|
-
__metadata("design:type", Function),
|
|
231
|
-
__metadata("design:paramtypes", [typeof (_g = typeof KeyboardEvent !== "undefined" && KeyboardEvent) === "function" ? _g : Object]),
|
|
232
|
-
__metadata("design:returntype", void 0)
|
|
233
|
-
], KeyboardHandler.prototype, "onSaveShortcut", null);
|
|
234
|
-
KeyboardHandler = __decorate([
|
|
235
|
-
elementDefine("keyboard-handler")
|
|
236
|
-
], KeyboardHandler);
|
|
237
|
-
let MouseTracker = class MouseTracker2 extends HTMLElement {
|
|
238
|
-
onMouseMove(event) {
|
|
239
|
-
const x = event.clientX;
|
|
240
|
-
const y = event.clientY;
|
|
241
|
-
this.updateCursorPosition(x, y);
|
|
242
|
-
}
|
|
243
|
-
updateCursorPosition(x, y) {
|
|
244
|
-
console.log(`Cursor at: ${x}, ${y}`);
|
|
245
|
-
}
|
|
246
|
-
};
|
|
247
|
-
__decorate([
|
|
248
|
-
addEventListener("$document", "mousemove", { throttleTime: 100 }),
|
|
249
|
-
__metadata("design:type", Function),
|
|
250
|
-
__metadata("design:paramtypes", [typeof (_h = typeof MouseEvent !== "undefined" && MouseEvent) === "function" ? _h : Object]),
|
|
251
|
-
__metadata("design:returntype", void 0)
|
|
252
|
-
], MouseTracker.prototype, "onMouseMove", null);
|
|
253
|
-
MouseTracker = __decorate([
|
|
254
|
-
elementDefine("mouse-tracker")
|
|
255
|
-
], MouseTracker);
|
|
256
|
-
export {
|
|
257
|
-
AutoSaveEditor,
|
|
258
|
-
FormInput,
|
|
259
|
-
InfiniteScroll,
|
|
260
|
-
KeyboardHandler,
|
|
261
|
-
LengthTracker,
|
|
262
|
-
MouseTracker,
|
|
263
|
-
ResponsiveLayout,
|
|
264
|
-
SearchComponent
|
|
265
|
-
};
|
|
266
|
-
//# sourceMappingURL=RxJSOperatorsExample.js.map
|