@supersoniks/concorde 4.2.1 → 4.3.0
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 +163 -0
- package/build-infos.json +1 -1
- package/concorde-core.bundle.js +175 -171
- package/concorde-core.es.js +2490 -2246
- package/dist/concorde-core.bundle.js +175 -171
- package/dist/concorde-core.es.js +2490 -2246
- package/package.json +22 -1
- package/php/get-challenge.php +34 -0
- package/php/some-service.php +42 -0
- package/scripts/pre-build.mjs +4 -0
- package/src/core/_types/endpoint.ts +4 -0
- package/src/core/_types/key.ts +1 -0
- package/src/core/components/functional/example/example.ts +38 -6
- package/src/core/decorators/Subscriber.ts +2 -0
- package/src/core/decorators/api.spec.ts +150 -0
- package/src/core/decorators/api.ts +244 -0
- package/src/core/decorators/subscriber/bind.ts +57 -145
- package/src/core/decorators/subscriber/dynamicPath.ts +77 -0
- package/src/core/decorators/subscriber/dynamicPropertyWatch.ts +105 -0
- package/src/core/decorators/subscriber/onAssign.ts +11 -147
- package/src/core/decorators/subscriber/publish.spec.ts +21 -0
- package/src/core/decorators/subscriber/publish.ts +148 -0
- package/src/core/decorators/subscriber/publisherPath.ts +13 -0
- package/src/core/decorators/subscriber/subscribe.spec.ts +21 -0
- package/src/core/decorators/subscriber/subscribe.ts +32 -0
- package/src/core/decorators/subscriber/subscribe.type-test.ts +32 -0
- package/src/core/utils/api.ts +83 -15
- package/src/core/utils/dataProviderKey.spec.ts +34 -0
- package/src/core/utils/dataProviderKey.ts +86 -0
- package/src/core/utils/endpoint.spec.ts +41 -0
- package/src/core/utils/endpoint.ts +87 -0
- package/src/decorators.ts +14 -0
- package/src/docs/{_misc → _decorators}/ancestor-attribute.md +15 -31
- package/src/docs/_decorators/bind.md +164 -0
- package/src/docs/_decorators/get.md +65 -0
- package/src/docs/_decorators/publish.md +54 -0
- package/src/docs/_decorators/subscribe.md +36 -0
- package/src/docs/_misc/dataProviderKey.md +135 -0
- package/src/docs/_misc/endpoint.md +42 -0
- package/src/docs/example/decorators-demo-bind-demos.ts +210 -0
- package/src/docs/example/decorators-demo-geo.ts +45 -0
- package/src/docs/example/decorators-demo-init.ts +228 -0
- package/src/docs/example/decorators-demo-subscribe-publish-get-demos.ts +324 -0
- package/src/docs/example/decorators-demo.ts +12 -459
- package/src/docs/navigation/navigation.ts +27 -10
- package/src/docs/search/docs-search.json +1059 -609
- package/src/tsconfig-model.json +1 -1
- package/src/tsconfig.json +65 -1
- package/src/tsconfig.tsbuildinfo +1 -1
- package/src/utils.ts +8 -1
- package/vite.config.mts +11 -0
- package/src/docs/_misc/bind.md +0 -362
- /package/src/docs/{_misc → _decorators}/auto-subscribe.md +0 -0
- /package/src/docs/{_misc → _decorators}/on-assign.md +0 -0
- /package/src/docs/{_misc → _decorators}/wait-for-ancestors.md +0 -0
|
@@ -1,242 +1,21 @@
|
|
|
1
1
|
import { html, LitElement } from "lit";
|
|
2
2
|
import { customElement, property, state } from "lit/decorators.js";
|
|
3
3
|
import {
|
|
4
|
-
bind,
|
|
5
4
|
ancestorAttribute,
|
|
6
5
|
onAssign,
|
|
7
6
|
autoSubscribe,
|
|
8
7
|
awaitConnectedAncestors,
|
|
9
8
|
dispatchConnectedEvent,
|
|
10
9
|
} from "@supersoniks/concorde/decorators";
|
|
11
|
-
import { sub } from "@supersoniks/concorde/directives";
|
|
12
10
|
import {
|
|
13
11
|
PublisherManager,
|
|
14
12
|
PublisherProxy,
|
|
15
13
|
} from "@supersoniks/concorde/core/utils/PublisherProxy";
|
|
16
14
|
import { Objects } from "@supersoniks/concorde/utils";
|
|
17
15
|
import { tailwind } from "../tailwind";
|
|
16
|
+
import "./decorators-demo-bind-demos";
|
|
17
|
+
import "./decorators-demo-subscribe-publish-get-demos";
|
|
18
18
|
|
|
19
|
-
const demoSectionClasses =
|
|
20
|
-
"my-6 rounded-2xl border border-neutral-200 dark:border-neutral-800 bg-neutral-0 dark:bg-neutral-900/40 px-6 py-6 md:px-8 md:py-8 space-y-4 shadow-sm";
|
|
21
|
-
|
|
22
|
-
const ensurePublisherValue = <T>(
|
|
23
|
-
publisherId: string,
|
|
24
|
-
defaultValue: T
|
|
25
|
-
): void => {
|
|
26
|
-
const publisher = PublisherManager.get(publisherId);
|
|
27
|
-
const currentValue =
|
|
28
|
-
typeof publisher.get === "function" ? publisher.get() : undefined;
|
|
29
|
-
|
|
30
|
-
const isUnset =
|
|
31
|
-
currentValue === undefined ||
|
|
32
|
-
currentValue === null ||
|
|
33
|
-
(typeof currentValue === "object" &&
|
|
34
|
-
!Array.isArray(currentValue) &&
|
|
35
|
-
Object.keys(currentValue).length === 0);
|
|
36
|
-
|
|
37
|
-
if (isUnset) {
|
|
38
|
-
publisher.set(defaultValue as T);
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
const initializeDecoratorsDemoData = () => {
|
|
43
|
-
ensurePublisherValue("demoData", {
|
|
44
|
-
title: "Initial Title",
|
|
45
|
-
user: { name: "Initial User" },
|
|
46
|
-
count: 0,
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
ensurePublisherValue("demoUser", {
|
|
50
|
-
name: "Demo User",
|
|
51
|
-
email: "demo@example.com",
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
ensurePublisherValue("demoSettings", {
|
|
55
|
-
theme: "light",
|
|
56
|
-
language: "en",
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
ensurePublisherValue("autoValue1", 10);
|
|
60
|
-
ensurePublisherValue("autoValue2", 20);
|
|
61
|
-
ensurePublisherValue("waitAncestorDemo", { message: "Context from ancestor" });
|
|
62
|
-
|
|
63
|
-
ensurePublisherValue("combinedData", { title: "Combined Title" });
|
|
64
|
-
ensurePublisherValue("combinedUser", { name: "Combined User" });
|
|
65
|
-
ensurePublisherValue("combinedSettings", { theme: "dark" });
|
|
66
|
-
|
|
67
|
-
ensurePublisherValue("reflectData", {
|
|
68
|
-
title: "Initial Reflected Title",
|
|
69
|
-
count: 0,
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
ensurePublisherValue("dynamicProfiles", {
|
|
73
|
-
alpha: { info: { title: "Profil Alpha" } },
|
|
74
|
-
beta: { info: { title: "Profil Beta" } },
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
ensurePublisherValue("dynamicProfilesAlt", {
|
|
78
|
-
alpha: { info: { title: "Profil Alpha (Alt)" } },
|
|
79
|
-
beta: { info: { title: "Profil Beta (Alt)" } },
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
ensurePublisherValue("demoUsers", [
|
|
83
|
-
{
|
|
84
|
-
id: 1,
|
|
85
|
-
firstName: "Alice",
|
|
86
|
-
lastName: "Smith",
|
|
87
|
-
email: "alice.smith@example.com",
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
id: 2,
|
|
91
|
-
firstName: "Bob",
|
|
92
|
-
lastName: "Johnson",
|
|
93
|
-
email: "bob.johnson@example.com",
|
|
94
|
-
},
|
|
95
|
-
{
|
|
96
|
-
id: 3,
|
|
97
|
-
firstName: "Carol",
|
|
98
|
-
lastName: "Williams",
|
|
99
|
-
email: "carol.williams@example.com",
|
|
100
|
-
},
|
|
101
|
-
{
|
|
102
|
-
id: 4,
|
|
103
|
-
firstName: "David",
|
|
104
|
-
lastName: "Brown",
|
|
105
|
-
email: "david.brown@example.com",
|
|
106
|
-
},
|
|
107
|
-
{
|
|
108
|
-
id: 5,
|
|
109
|
-
firstName: "Eve",
|
|
110
|
-
lastName: "Jones",
|
|
111
|
-
email: "eve.jones@example.com",
|
|
112
|
-
},
|
|
113
|
-
{
|
|
114
|
-
id: 6,
|
|
115
|
-
firstName: "Frank",
|
|
116
|
-
lastName: "Garcia",
|
|
117
|
-
email: "frank.garcia@example.com",
|
|
118
|
-
},
|
|
119
|
-
{
|
|
120
|
-
id: 7,
|
|
121
|
-
firstName: "Grace",
|
|
122
|
-
lastName: "Miller",
|
|
123
|
-
email: "grace.miller@example.com",
|
|
124
|
-
},
|
|
125
|
-
{
|
|
126
|
-
id: 8,
|
|
127
|
-
firstName: "Henry",
|
|
128
|
-
lastName: "Davis",
|
|
129
|
-
email: "henry.davis@example.com",
|
|
130
|
-
},
|
|
131
|
-
{
|
|
132
|
-
id: 9,
|
|
133
|
-
firstName: "Ivy",
|
|
134
|
-
lastName: "Martinez",
|
|
135
|
-
email: "ivy.martinez@example.com",
|
|
136
|
-
},
|
|
137
|
-
{
|
|
138
|
-
id: 10,
|
|
139
|
-
firstName: "Jack",
|
|
140
|
-
lastName: "Taylor",
|
|
141
|
-
email: "jack.taylor@example.com",
|
|
142
|
-
},
|
|
143
|
-
]);
|
|
144
|
-
|
|
145
|
-
ensurePublisherValue("demoUsersAlt", [
|
|
146
|
-
{
|
|
147
|
-
id: 11,
|
|
148
|
-
firstName: "Sophie",
|
|
149
|
-
lastName: "Lindquist",
|
|
150
|
-
email: "sophie.lindquist@example.com",
|
|
151
|
-
},
|
|
152
|
-
{
|
|
153
|
-
id: 12,
|
|
154
|
-
firstName: "Mateo",
|
|
155
|
-
lastName: "Ortega",
|
|
156
|
-
email: "mateo.ortega@example.com",
|
|
157
|
-
},
|
|
158
|
-
{
|
|
159
|
-
id: 13,
|
|
160
|
-
firstName: "Jin",
|
|
161
|
-
lastName: "Park",
|
|
162
|
-
email: "jin.park@example.com",
|
|
163
|
-
},
|
|
164
|
-
{
|
|
165
|
-
id: 14,
|
|
166
|
-
firstName: "Fatima",
|
|
167
|
-
lastName: "El-Sayed",
|
|
168
|
-
email: "fatima.el-sayed@example.com",
|
|
169
|
-
},
|
|
170
|
-
{
|
|
171
|
-
id: 15,
|
|
172
|
-
firstName: "Lars",
|
|
173
|
-
lastName: "Johansson",
|
|
174
|
-
email: "lars.johansson@example.com",
|
|
175
|
-
},
|
|
176
|
-
{
|
|
177
|
-
id: 16,
|
|
178
|
-
firstName: "Amara",
|
|
179
|
-
lastName: "Singh",
|
|
180
|
-
email: "amara.singh@example.com",
|
|
181
|
-
},
|
|
182
|
-
{
|
|
183
|
-
id: 17,
|
|
184
|
-
firstName: "Zuri",
|
|
185
|
-
lastName: "Okafor",
|
|
186
|
-
email: "zuri.okafor@example.com",
|
|
187
|
-
},
|
|
188
|
-
{
|
|
189
|
-
id: 18,
|
|
190
|
-
firstName: "Luca",
|
|
191
|
-
lastName: "Rossi",
|
|
192
|
-
email: "luca.rossi@example.com",
|
|
193
|
-
},
|
|
194
|
-
{
|
|
195
|
-
id: 19,
|
|
196
|
-
firstName: "Ava",
|
|
197
|
-
lastName: "Murphy",
|
|
198
|
-
email: "ava.murphy@example.com",
|
|
199
|
-
},
|
|
200
|
-
{
|
|
201
|
-
id: 20,
|
|
202
|
-
firstName: "Noah",
|
|
203
|
-
lastName: "Keller",
|
|
204
|
-
email: "noah.keller@example.com",
|
|
205
|
-
},
|
|
206
|
-
]);
|
|
207
|
-
|
|
208
|
-
ensurePublisherValue("demoUsersSettings", [
|
|
209
|
-
{ theme: "light", language: "en" },
|
|
210
|
-
{ theme: "dark", language: "fr" },
|
|
211
|
-
{ theme: "auto", language: "es" },
|
|
212
|
-
{ theme: "light", language: "en" },
|
|
213
|
-
{ theme: "dark", language: "fr" },
|
|
214
|
-
{ theme: "auto", language: "es" },
|
|
215
|
-
{ theme: "light", language: "en" },
|
|
216
|
-
{ theme: "dark", language: "fr" },
|
|
217
|
-
{ theme: "auto", language: "es" },
|
|
218
|
-
{ theme: "light", language: "en" },
|
|
219
|
-
]);
|
|
220
|
-
|
|
221
|
-
ensurePublisherValue("demoUsersAltSettings", [
|
|
222
|
-
{ theme: "dark", language: "de" },
|
|
223
|
-
{ theme: "light", language: "it" },
|
|
224
|
-
{ theme: "auto", language: "ja" },
|
|
225
|
-
{ theme: "dark", language: "pt" },
|
|
226
|
-
{ theme: "light", language: "ru" },
|
|
227
|
-
{ theme: "auto", language: "zh" },
|
|
228
|
-
{ theme: "dark", language: "ar" },
|
|
229
|
-
{ theme: "light", language: "sv" },
|
|
230
|
-
{ theme: "auto", language: "nl" },
|
|
231
|
-
{ theme: "dark", language: "pl" },
|
|
232
|
-
]);
|
|
233
|
-
};
|
|
234
|
-
|
|
235
|
-
initializeDecoratorsDemoData();
|
|
236
|
-
|
|
237
|
-
/**
|
|
238
|
-
* Demo component showcasing @ancestorAttribute decorator
|
|
239
|
-
*/
|
|
240
19
|
@customElement("demo-ancestor-attribute")
|
|
241
20
|
export class DemoAncestorAttribute extends LitElement {
|
|
242
21
|
@ancestorAttribute("dataProvider")
|
|
@@ -261,192 +40,6 @@ export class DemoAncestorAttribute extends LitElement {
|
|
|
261
40
|
}
|
|
262
41
|
}
|
|
263
42
|
|
|
264
|
-
/**
|
|
265
|
-
* Demo component showcasing @bind decorator
|
|
266
|
-
*/
|
|
267
|
-
@customElement("demo-bind")
|
|
268
|
-
export class DemoBind extends LitElement {
|
|
269
|
-
static styles = [tailwind];
|
|
270
|
-
|
|
271
|
-
@bind("demoData.firstName")
|
|
272
|
-
@state()
|
|
273
|
-
firstName = "";
|
|
274
|
-
|
|
275
|
-
@bind("demoData.lastName")
|
|
276
|
-
@state()
|
|
277
|
-
lastName: string = "";
|
|
278
|
-
|
|
279
|
-
@bind("demoData.count")
|
|
280
|
-
@state()
|
|
281
|
-
count: number = 0;
|
|
282
|
-
|
|
283
|
-
render() {
|
|
284
|
-
return html`
|
|
285
|
-
<div>
|
|
286
|
-
<sonic-button @click=${this.updateData}>Update Data</sonic-button>
|
|
287
|
-
</div>
|
|
288
|
-
<div class="p-3">
|
|
289
|
-
<p>Title: <strong>${this.firstName || "Not set"}</strong></p>
|
|
290
|
-
<p>User Name: <strong>${this.lastName || "Not set"}</strong></p>
|
|
291
|
-
<p>Number of updates: <strong>${this.count}</strong></p>
|
|
292
|
-
</div>
|
|
293
|
-
`;
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
updateData() {
|
|
297
|
-
const demoData = PublisherManager.get("demoData");
|
|
298
|
-
const demoUsers = PublisherManager.get("demoUsers");
|
|
299
|
-
const randomIndex = Math.floor(Math.random() * demoUsers.get().length);
|
|
300
|
-
const randomUser = demoUsers.get()[randomIndex];
|
|
301
|
-
demoData.set({
|
|
302
|
-
firstName: randomUser.firstName,
|
|
303
|
-
lastName: randomUser.lastName,
|
|
304
|
-
count: (demoData.count.get() || 0) + 1,
|
|
305
|
-
});
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
/**
|
|
310
|
-
* Demo component showcasing @bind decorator with reflect option
|
|
311
|
-
*/
|
|
312
|
-
@customElement("demo-bind-reflect")
|
|
313
|
-
export class DemoBindReflect extends LitElement {
|
|
314
|
-
static styles = [tailwind];
|
|
315
|
-
|
|
316
|
-
@bind("bindReflectDemo.count", { reflect: true })
|
|
317
|
-
@state()
|
|
318
|
-
withReflect: number = 0;
|
|
319
|
-
|
|
320
|
-
@bind("bindReflectDemo.count")
|
|
321
|
-
@state()
|
|
322
|
-
withoutReflect: number = 0;
|
|
323
|
-
// initialize the publisher data
|
|
324
|
-
connectedCallback() {
|
|
325
|
-
super.connectedCallback();
|
|
326
|
-
this.resetData();
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
resetData() {
|
|
330
|
-
PublisherManager.get("bindReflectDemo").set({ count: 0 });
|
|
331
|
-
}
|
|
332
|
-
render() {
|
|
333
|
-
return html`
|
|
334
|
-
<div class="mb-3">
|
|
335
|
-
from publisher : ${sub("bindReflectDemo.count")} <br />
|
|
336
|
-
from component with reflect : ${this.withReflect} <br />
|
|
337
|
-
from component without reflect : ${this.withoutReflect}
|
|
338
|
-
</div>
|
|
339
|
-
<sonic-button @click=${() => this.withReflect++}
|
|
340
|
-
>Increment with reflect</sonic-button
|
|
341
|
-
>
|
|
342
|
-
<sonic-button @click=${() => this.withoutReflect++}
|
|
343
|
-
>Increment without reflect</sonic-button
|
|
344
|
-
>
|
|
345
|
-
<sonic-button @click=${this.resetData}>Reset publisher data</sonic-button>
|
|
346
|
-
`;
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
/**
|
|
351
|
-
* Demo component showcasing @bind decorator with dynamic dataProvider/id
|
|
352
|
-
*/
|
|
353
|
-
@customElement("demo-bind-dynamic")
|
|
354
|
-
export class DemoBindDynamic extends LitElement {
|
|
355
|
-
static styles = [tailwind];
|
|
356
|
-
|
|
357
|
-
@property({ type: String })
|
|
358
|
-
dataProvider: "demoUsers" | "demoUsersAlt" = "demoUsers";
|
|
359
|
-
|
|
360
|
-
@property({ type: Number })
|
|
361
|
-
userIndex: number = 1;
|
|
362
|
-
|
|
363
|
-
@bind("${dataProvider}.${userIndex}")
|
|
364
|
-
@state()
|
|
365
|
-
user: any = {};
|
|
366
|
-
|
|
367
|
-
updateUserIndex(e: Event) {
|
|
368
|
-
this.userIndex = parseInt((e.target as HTMLInputElement).value);
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
updateDataProvider(e: Event) {
|
|
372
|
-
this.dataProvider = (e.target as HTMLSelectElement).value as
|
|
373
|
-
| "demoUsers"
|
|
374
|
-
| "demoUsersAlt";
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
updateCurrentUserData() {
|
|
378
|
-
const usersPublisher = PublisherManager.get(this.dataProvider);
|
|
379
|
-
const userPublisher = Objects.traverse(usersPublisher, [
|
|
380
|
-
String(this.userIndex),
|
|
381
|
-
]) as PublisherProxy;
|
|
382
|
-
|
|
383
|
-
if (userPublisher) {
|
|
384
|
-
// Générer de nouvelles données aléatoires
|
|
385
|
-
const randomNames = [
|
|
386
|
-
{ firstName: "Alice", lastName: "Wonder" },
|
|
387
|
-
{ firstName: "Bob", lastName: "Builder" },
|
|
388
|
-
{ firstName: "Charlie", lastName: "Chaplin" },
|
|
389
|
-
{ firstName: "Diana", lastName: "Prince" },
|
|
390
|
-
{ firstName: "Eve", lastName: "Adams" },
|
|
391
|
-
];
|
|
392
|
-
|
|
393
|
-
const randomName =
|
|
394
|
-
randomNames[Math.floor(Math.random() * randomNames.length)];
|
|
395
|
-
const randomEmail = `${randomName.firstName.toLowerCase()}.${randomName.lastName.toLowerCase()}@example.com`;
|
|
396
|
-
|
|
397
|
-
// Mettre à jour l'utilisateur directement
|
|
398
|
-
const currentUser = userPublisher.get() || {};
|
|
399
|
-
userPublisher.set({
|
|
400
|
-
...currentUser,
|
|
401
|
-
firstName: randomName.firstName,
|
|
402
|
-
lastName: randomName.lastName,
|
|
403
|
-
email: randomEmail,
|
|
404
|
-
});
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
render() {
|
|
409
|
-
return html`
|
|
410
|
-
<div class="flex flex-col gap-2">
|
|
411
|
-
<sonic-select
|
|
412
|
-
.value=${this.dataProvider}
|
|
413
|
-
label="Users set"
|
|
414
|
-
@change=${this.updateDataProvider}
|
|
415
|
-
>
|
|
416
|
-
<option value="demoUsers">First set of users</option>
|
|
417
|
-
<option value="demoUsersAlt">Second set of users</option>
|
|
418
|
-
</sonic-select>
|
|
419
|
-
<sonic-input
|
|
420
|
-
type="number"
|
|
421
|
-
.value=${this.userIndex}
|
|
422
|
-
@input=${this.updateUserIndex}
|
|
423
|
-
min="0"
|
|
424
|
-
max="9"
|
|
425
|
-
label="Index"
|
|
426
|
-
class="block"
|
|
427
|
-
>
|
|
428
|
-
</sonic-input>
|
|
429
|
-
<sonic-button @click=${this.updateCurrentUserData}
|
|
430
|
-
>Update current user data</sonic-button
|
|
431
|
-
>
|
|
432
|
-
<div class="flex flex-col gap-2 border p-2">
|
|
433
|
-
<div>
|
|
434
|
-
<sonic-icon name="user" library="heroicons"></sonic-icon>
|
|
435
|
-
${this.user?.firstName} ${this.user?.lastName}
|
|
436
|
-
</div>
|
|
437
|
-
<div>
|
|
438
|
-
<sonic-icon name="envelope" library="heroicons"></sonic-icon>
|
|
439
|
-
${this.user?.email}
|
|
440
|
-
</div>
|
|
441
|
-
</div>
|
|
442
|
-
</div>
|
|
443
|
-
`;
|
|
444
|
-
}
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
/**
|
|
448
|
-
* Demo component showcasing @onAssign decorator
|
|
449
|
-
*/
|
|
450
43
|
@customElement("demo-on-assign")
|
|
451
44
|
export class DemoOnAssign extends LitElement {
|
|
452
45
|
static styles = [tailwind];
|
|
@@ -498,9 +91,6 @@ export class DemoOnAssign extends LitElement {
|
|
|
498
91
|
}
|
|
499
92
|
}
|
|
500
93
|
|
|
501
|
-
/**
|
|
502
|
-
* Demo component showcasing @onAssign decorator with dynamic paths
|
|
503
|
-
*/
|
|
504
94
|
@customElement("demo-on-assign-dynamic")
|
|
505
95
|
export class DemoOnAssignDynamic extends LitElement {
|
|
506
96
|
static styles = [tailwind];
|
|
@@ -516,7 +106,7 @@ export class DemoOnAssignDynamic extends LitElement {
|
|
|
516
106
|
|
|
517
107
|
@onAssign(
|
|
518
108
|
"${dataProvider}.${userIndex}",
|
|
519
|
-
"${dataProvider}Settings.${userIndex}"
|
|
109
|
+
"${dataProvider}Settings.${userIndex}",
|
|
520
110
|
)
|
|
521
111
|
handleUserDataReady(user: any, settings: any) {
|
|
522
112
|
this.user = user;
|
|
@@ -536,7 +126,7 @@ export class DemoOnAssignDynamic extends LitElement {
|
|
|
536
126
|
updateCurrentUserData() {
|
|
537
127
|
const usersPublisher = PublisherManager.get(this.dataProvider);
|
|
538
128
|
const settingsPublisher = PublisherManager.get(
|
|
539
|
-
`${this.dataProvider}Settings
|
|
129
|
+
`${this.dataProvider}Settings`,
|
|
540
130
|
);
|
|
541
131
|
const userPublisher = Objects.traverse(usersPublisher, [
|
|
542
132
|
String(this.userIndex),
|
|
@@ -546,7 +136,6 @@ export class DemoOnAssignDynamic extends LitElement {
|
|
|
546
136
|
]) as PublisherProxy;
|
|
547
137
|
|
|
548
138
|
if (userPublisher && settingPublisher) {
|
|
549
|
-
// Générer de nouvelles données aléatoires
|
|
550
139
|
const randomNames = [
|
|
551
140
|
{ firstName: "Alice", lastName: "Wonder" },
|
|
552
141
|
{ firstName: "Bob", lastName: "Builder" },
|
|
@@ -565,7 +154,6 @@ export class DemoOnAssignDynamic extends LitElement {
|
|
|
565
154
|
const randomLanguage =
|
|
566
155
|
randomLanguages[Math.floor(Math.random() * randomLanguages.length)];
|
|
567
156
|
|
|
568
|
-
// Mettre à jour l'utilisateur directement
|
|
569
157
|
const currentUser = userPublisher.get() || {};
|
|
570
158
|
userPublisher.set({
|
|
571
159
|
...currentUser,
|
|
@@ -574,7 +162,6 @@ export class DemoOnAssignDynamic extends LitElement {
|
|
|
574
162
|
email: randomEmail,
|
|
575
163
|
});
|
|
576
164
|
|
|
577
|
-
// Mettre à jour les settings directement
|
|
578
165
|
settingPublisher.set({
|
|
579
166
|
theme: randomTheme,
|
|
580
167
|
language: randomLanguage,
|
|
@@ -621,9 +208,6 @@ export class DemoOnAssignDynamic extends LitElement {
|
|
|
621
208
|
}
|
|
622
209
|
}
|
|
623
210
|
|
|
624
|
-
/**
|
|
625
|
-
* Demo component showcasing @autoSubscribe decorator
|
|
626
|
-
*/
|
|
627
211
|
@customElement("demo-auto-subscribe")
|
|
628
212
|
export class DemoAutoSubscribe extends LitElement {
|
|
629
213
|
static styles = [tailwind];
|
|
@@ -660,10 +244,6 @@ export class DemoAutoSubscribe extends LitElement {
|
|
|
660
244
|
}
|
|
661
245
|
}
|
|
662
246
|
|
|
663
|
-
/**
|
|
664
|
-
* Parent component for awaitConnectedAncestors demo.
|
|
665
|
-
* Registered via customElements.define() on button click (not @customElement).
|
|
666
|
-
*/
|
|
667
247
|
@dispatchConnectedEvent()
|
|
668
248
|
export class DemoWaitAncestorContainer extends LitElement {
|
|
669
249
|
render() {
|
|
@@ -671,10 +251,6 @@ export class DemoWaitAncestorContainer extends LitElement {
|
|
|
671
251
|
}
|
|
672
252
|
}
|
|
673
253
|
|
|
674
|
-
/**
|
|
675
|
-
* Demo component showcasing @awaitConnectedAncestors decorator (child).
|
|
676
|
-
* Uses CSS selector: tag + attribute.
|
|
677
|
-
*/
|
|
678
254
|
@customElement("demo-wait-ancestor-value")
|
|
679
255
|
@awaitConnectedAncestors("demo-wait-ancestor-container[dataProvider]")
|
|
680
256
|
export class DemoWaitAncestorValue extends LitElement {
|
|
@@ -699,10 +275,6 @@ export class DemoWaitAncestorValue extends LitElement {
|
|
|
699
275
|
}
|
|
700
276
|
}
|
|
701
277
|
|
|
702
|
-
/**
|
|
703
|
-
* Demo section with button to register parent component on demand.
|
|
704
|
-
* Demonstrates that the child waits until the parent is defined.
|
|
705
|
-
*/
|
|
706
278
|
@customElement("demo-wait-ancestors-section")
|
|
707
279
|
export class DemoWaitAncestorsSection extends LitElement {
|
|
708
280
|
static styles = [tailwind];
|
|
@@ -716,7 +288,7 @@ export class DemoWaitAncestorsSection extends LitElement {
|
|
|
716
288
|
}
|
|
717
289
|
customElements.define(
|
|
718
290
|
"demo-wait-ancestor-container",
|
|
719
|
-
DemoWaitAncestorContainer
|
|
291
|
+
DemoWaitAncestorContainer,
|
|
720
292
|
);
|
|
721
293
|
this.parentRegistered = true;
|
|
722
294
|
}
|
|
@@ -740,8 +312,6 @@ export class DemoWaitAncestorsSection extends LitElement {
|
|
|
740
312
|
}
|
|
741
313
|
}
|
|
742
314
|
|
|
743
|
-
// --- Multiple ancestors demo ---
|
|
744
|
-
|
|
745
315
|
@dispatchConnectedEvent()
|
|
746
316
|
export class DemoWaitAncestorOuter extends LitElement {
|
|
747
317
|
render() {
|
|
@@ -775,15 +345,13 @@ export class DemoWaitAncestorValueMulti extends LitElement {
|
|
|
775
345
|
DataProvider from ancestor:
|
|
776
346
|
<strong>${this.dataProvider || "—"}</strong>
|
|
777
347
|
</p>
|
|
778
|
-
<p>
|
|
348
|
+
<p>
|
|
349
|
+
Initialized at: ${this.initializedAt || "(waiting for both ancestors…)"}
|
|
350
|
+
</p>
|
|
779
351
|
`;
|
|
780
352
|
}
|
|
781
353
|
}
|
|
782
354
|
|
|
783
|
-
/**
|
|
784
|
-
* Demo: child waits for multiple ancestors.
|
|
785
|
-
* Register outer first, then inner — child initializes only when both are ready.
|
|
786
|
-
*/
|
|
787
355
|
@customElement("demo-wait-ancestors-multi-section")
|
|
788
356
|
export class DemoWaitAncestorsMultiSection extends LitElement {
|
|
789
357
|
static styles = [tailwind];
|
|
@@ -832,8 +400,6 @@ export class DemoWaitAncestorsMultiSection extends LitElement {
|
|
|
832
400
|
}
|
|
833
401
|
}
|
|
834
402
|
|
|
835
|
-
// --- Ancestors already connected demo ---
|
|
836
|
-
|
|
837
403
|
@customElement("demo-wait-ancestor-ready")
|
|
838
404
|
@dispatchConnectedEvent()
|
|
839
405
|
export class DemoWaitAncestorReady extends LitElement {
|
|
@@ -857,19 +423,12 @@ export class DemoWaitAncestorValueReady extends LitElement {
|
|
|
857
423
|
|
|
858
424
|
render() {
|
|
859
425
|
return html`
|
|
860
|
-
<p>
|
|
861
|
-
DataProvider: <strong>${this.dataProvider || "—"}</strong>
|
|
862
|
-
</p>
|
|
426
|
+
<p>DataProvider: <strong>${this.dataProvider || "—"}</strong></p>
|
|
863
427
|
<p>Initialized at: ${this.initializedAt}</p>
|
|
864
428
|
`;
|
|
865
429
|
}
|
|
866
430
|
}
|
|
867
431
|
|
|
868
|
-
/**
|
|
869
|
-
* Demo: ancestors already connected at load.
|
|
870
|
-
* Parent is defined with @customElement. Child is added dynamically — it
|
|
871
|
-
* initializes immediately because the ancestor is already ready.
|
|
872
|
-
*/
|
|
873
432
|
@customElement("demo-wait-ancestors-ready-section")
|
|
874
433
|
export class DemoWaitAncestorsReadySection extends LitElement {
|
|
875
434
|
static styles = [tailwind];
|
|
@@ -884,8 +443,8 @@ export class DemoWaitAncestorsReadySection extends LitElement {
|
|
|
884
443
|
return html`
|
|
885
444
|
<div class="space-y-4">
|
|
886
445
|
<p class="text-sm text-neutral-600 dark:text-neutral-400">
|
|
887
|
-
Parent
|
|
888
|
-
|
|
446
|
+
Parent défini au chargement. Ajout dynamique de l’enfant — initialisation
|
|
447
|
+
immédiate si l’ancêtre est prêt.
|
|
889
448
|
</p>
|
|
890
449
|
<sonic-button ?disabled=${this.childInDom} @click=${this.addChild}>
|
|
891
450
|
${this.childInDom ? "Child added" : "Add child dynamically"}
|
|
@@ -900,10 +459,6 @@ export class DemoWaitAncestorsReadySection extends LitElement {
|
|
|
900
459
|
}
|
|
901
460
|
}
|
|
902
461
|
|
|
903
|
-
/**
|
|
904
|
-
* Demo: parent and child both in DOM from start, parent defined at load.
|
|
905
|
-
* Child initializes immediately (no delay) because ancestor is already ready.
|
|
906
|
-
*/
|
|
907
462
|
@customElement("demo-wait-ancestors-static-section")
|
|
908
463
|
export class DemoWaitAncestorsStaticSection extends LitElement {
|
|
909
464
|
static styles = [tailwind];
|
|
@@ -911,8 +466,7 @@ export class DemoWaitAncestorsStaticSection extends LitElement {
|
|
|
911
466
|
render() {
|
|
912
467
|
return html`
|
|
913
468
|
<p class="text-sm text-neutral-600 dark:text-neutral-400 mb-4">
|
|
914
|
-
Parent
|
|
915
|
-
because the ancestor is already defined and connected.
|
|
469
|
+
Parent et enfant présents dès le chargement — pas de délai.
|
|
916
470
|
</p>
|
|
917
471
|
<demo-wait-ancestor-ready dataProvider="waitAncestorDemo">
|
|
918
472
|
<demo-wait-ancestor-value-ready></demo-wait-ancestor-value-ready>
|
|
@@ -920,4 +474,3 @@ export class DemoWaitAncestorsStaticSection extends LitElement {
|
|
|
920
474
|
`;
|
|
921
475
|
}
|
|
922
476
|
}
|
|
923
|
-
|
|
@@ -54,10 +54,6 @@ export class DocsNavigation extends LitElement {
|
|
|
54
54
|
label: "Submit",
|
|
55
55
|
href: "#core/components/functional/submit/submit.md/submit",
|
|
56
56
|
},
|
|
57
|
-
{
|
|
58
|
-
label: "Submit",
|
|
59
|
-
href: "#core/components/functional/submit/submit.md/submit",
|
|
60
|
-
},
|
|
61
57
|
//{label: "Subscriber", href: "#core/components/functional/subscriber/subscriber.md/subscriber"},
|
|
62
58
|
{
|
|
63
59
|
label: "Value",
|
|
@@ -129,26 +125,47 @@ export class DocsNavigation extends LitElement {
|
|
|
129
125
|
label: "Tooltip",
|
|
130
126
|
href: "#core/components/ui/tooltip/tooltip.md/tooltip",
|
|
131
127
|
},
|
|
132
|
-
"
|
|
128
|
+
"Decorators",
|
|
133
129
|
{
|
|
134
130
|
label: "@ancestorAttribute",
|
|
135
|
-
href: "#docs/
|
|
131
|
+
href: "#docs/_decorators/ancestor-attribute.md/ancestor-attribute",
|
|
136
132
|
},
|
|
137
133
|
{
|
|
138
134
|
label: "@bind",
|
|
139
|
-
href: "#docs/
|
|
135
|
+
href: "#docs/_decorators/bind.md/bind",
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
label: "@subscribe",
|
|
139
|
+
href: "#docs/_decorators/subscribe.md/subscribe",
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
label: "@publish",
|
|
143
|
+
href: "#docs/_decorators/publish.md/publish",
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
label: "@get",
|
|
147
|
+
href: "#docs/_decorators/get.md/get",
|
|
140
148
|
},
|
|
141
149
|
{
|
|
142
150
|
label: "@onAssign",
|
|
143
|
-
href: "#docs/
|
|
151
|
+
href: "#docs/_decorators/on-assign.md/on-assign",
|
|
144
152
|
},
|
|
145
153
|
{
|
|
146
154
|
label: "@autoSubscribe",
|
|
147
|
-
href: "#docs/
|
|
155
|
+
href: "#docs/_decorators/auto-subscribe.md/auto-subscribe",
|
|
148
156
|
},
|
|
149
157
|
{
|
|
150
158
|
label: "@awaitConnectedAncestors",
|
|
151
|
-
href: "#docs/
|
|
159
|
+
href: "#docs/_decorators/wait-for-ancestors.md/wait-for-ancestors",
|
|
160
|
+
},
|
|
161
|
+
"Misc",
|
|
162
|
+
{
|
|
163
|
+
label: "DataProviderKey",
|
|
164
|
+
href: "#docs/_misc/dataProviderKey.md/dataProviderKey",
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
label: "Endpoint",
|
|
168
|
+
href: "#docs/_misc/endpoint.md/endpoint",
|
|
152
169
|
},
|
|
153
170
|
{
|
|
154
171
|
label: "Templates Demo",
|