@microsoft/fast-html 1.0.0-alpha.29 → 1.0.0-alpha.30

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.
@@ -0,0 +1,126 @@
1
+ import { __awaiter, __decorate, __metadata } from "tslib";
2
+ import { RenderableFASTElement, TemplateElement } from "@microsoft/fast-html";
3
+ import { attr, FASTElement, observable } from "@microsoft/fast-element";
4
+ // Track lifecycle callbacks for testing
5
+ export const lifecycleEvents = [];
6
+ // Track hydration complete
7
+ export let hydrationCompleteEmitted = false;
8
+ // Configure lifecycle callbacks
9
+ TemplateElement.config({
10
+ elementDidRegister(name) {
11
+ lifecycleEvents.push({ callback: "elementDidRegister", name });
12
+ },
13
+ templateWillUpdate(name) {
14
+ lifecycleEvents.push({ callback: "templateWillUpdate", name });
15
+ },
16
+ templateDidUpdate(name) {
17
+ lifecycleEvents.push({ callback: "templateDidUpdate", name });
18
+ },
19
+ elementDidDefine(name) {
20
+ lifecycleEvents.push({ callback: "elementDidDefine", name });
21
+ },
22
+ elementWillHydrate(name) {
23
+ lifecycleEvents.push({ callback: "elementWillHydrate", name });
24
+ },
25
+ elementDidHydrate(name) {
26
+ lifecycleEvents.push({ callback: "elementDidHydrate", name });
27
+ },
28
+ hydrationComplete() {
29
+ lifecycleEvents.push({ callback: "hydrationComplete" });
30
+ hydrationCompleteEmitted = true;
31
+ },
32
+ });
33
+ // Simple element with basic property
34
+ class SimpleElement extends FASTElement {
35
+ constructor() {
36
+ super(...arguments);
37
+ this.message = "Hello";
38
+ }
39
+ }
40
+ __decorate([
41
+ attr,
42
+ __metadata("design:type", String)
43
+ ], SimpleElement.prototype, "message", void 0);
44
+ RenderableFASTElement(SimpleElement).defineAsync({
45
+ name: "simple-element",
46
+ templateOptions: "defer-and-hydrate",
47
+ });
48
+ // Complex element with multiple properties and methods
49
+ class ComplexElement extends FASTElement {
50
+ constructor() {
51
+ super(...arguments);
52
+ this.title = "Complex";
53
+ this.count = 0;
54
+ this.items = [];
55
+ }
56
+ increment() {
57
+ this.count++;
58
+ }
59
+ addItem(item) {
60
+ this.items = [...this.items, item];
61
+ }
62
+ }
63
+ __decorate([
64
+ attr,
65
+ __metadata("design:type", String)
66
+ ], ComplexElement.prototype, "title", void 0);
67
+ __decorate([
68
+ observable,
69
+ __metadata("design:type", Number)
70
+ ], ComplexElement.prototype, "count", void 0);
71
+ __decorate([
72
+ observable,
73
+ __metadata("design:type", Array)
74
+ ], ComplexElement.prototype, "items", void 0);
75
+ RenderableFASTElement(ComplexElement).defineAsync({
76
+ name: "complex-element",
77
+ templateOptions: "defer-and-hydrate",
78
+ });
79
+ // Nested element
80
+ class NestedElement extends FASTElement {
81
+ constructor() {
82
+ super(...arguments);
83
+ this.label = "Nested";
84
+ }
85
+ }
86
+ __decorate([
87
+ attr,
88
+ __metadata("design:type", String)
89
+ ], NestedElement.prototype, "label", void 0);
90
+ RenderableFASTElement(NestedElement).defineAsync({
91
+ name: "nested-element",
92
+ templateOptions: "defer-and-hydrate",
93
+ });
94
+ // Element with deferred hydration
95
+ class DeferredElement extends FASTElement {
96
+ constructor() {
97
+ super(...arguments);
98
+ this.status = "pending";
99
+ }
100
+ prepare() {
101
+ return __awaiter(this, void 0, void 0, function* () {
102
+ // Simulate async work
103
+ yield new Promise(resolve => setTimeout(resolve, 100));
104
+ this.status = "ready";
105
+ });
106
+ }
107
+ }
108
+ __decorate([
109
+ attr,
110
+ __metadata("design:type", String)
111
+ ], DeferredElement.prototype, "status", void 0);
112
+ RenderableFASTElement(DeferredElement).defineAsync({
113
+ name: "deferred-element",
114
+ templateOptions: "defer-and-hydrate",
115
+ });
116
+ // Define templates
117
+ TemplateElement.options({
118
+ "complex-element": {
119
+ observerMap: "all",
120
+ },
121
+ }).define({
122
+ name: "f-template",
123
+ });
124
+ // Make lifecycleEvents available globally for testing
125
+ window.lifecycleEvents = lifecycleEvents;
126
+ window.getHydrationCompleteStatus = () => hydrationCompleteEmitted;