@supersoniks/concorde 4.6.0 → 4.7.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/.gitlab-ci.yml +23 -0
- package/README.md +106 -55
- package/ai/AGENTS.md +52 -0
- package/ai/README.md +30 -0
- package/ai/cursor/rules/concorde-menu.mdc +15 -0
- package/ai/cursor/rules/concorde-scope.mdc +14 -0
- package/ai/cursor/rules/concorde-theme.mdc +13 -0
- package/ai/cursor/rules/concorde.mdc +49 -0
- package/ai/jetbrains/rules/concorde.md +39 -0
- package/ai/skills/concorde/SKILL.md +220 -0
- package/ai/skills/concorde-get-set-dp/SKILL.md +194 -0
- package/ai/skills/concorde-imports/SKILL.md +78 -0
- package/ai/skills/concorde-menu/SKILL.md +74 -0
- package/ai/skills/concorde-scope/SKILL.md +70 -0
- package/ai/skills/concorde-theme/SKILL.md +46 -0
- package/build-infos.json +1 -1
- package/concorde-core.bundle.js +127 -127
- package/concorde-core.es.js +1435 -1364
- package/dist/altcha-widget.js +2662 -0
- package/dist/concorde-core.bundle.js +127 -127
- package/dist/concorde-core.es.js +1435 -1364
- package/dist/docs-mock-api-sw.js +589 -0
- package/dist/docs-mock-api-sw.js.map +7 -0
- package/docs/altcha-widget.js +2662 -0
- package/docs/assets/index-D9pxaQYK.js +7508 -0
- package/docs/assets/index-t0-i22oI.css +1 -0
- package/docs/docs-mock-api-sw.js +589 -0
- package/docs/docs-mock-api-sw.js.map +7 -0
- package/docs/index.html +2 -2
- package/docs/src/core/components/functional/fetch/fetch.md +13 -11
- package/docs/src/core/components/functional/if/if.md +4 -11
- package/docs/src/core/components/functional/list/list.md +60 -194
- package/docs/src/core/components/functional/queue/queue.md +70 -85
- package/docs/src/core/components/functional/router/router.md +62 -97
- package/docs/src/core/components/functional/states/states.md +2 -2
- package/docs/src/core/components/functional/submit/submit.md +86 -55
- package/docs/src/core/components/ui/captcha/captcha.md +2 -2
- package/docs/src/core/components/ui/card/card.md +1 -1
- package/docs/src/core/components/ui/form/checkbox/checkbox.md +5 -32
- package/docs/src/core/components/ui/form/input/input.md +5 -30
- package/docs/src/core/components/ui/form/input-autocomplete/input-autocomplete.md +6 -4
- package/docs/src/core/components/ui/form/radio/radio.md +5 -32
- package/docs/src/core/components/ui/form/select/select.md +5 -31
- package/docs/src/core/components/ui/form/switch/switch.md +5 -32
- package/docs/src/core/components/ui/loader/loader.md +1 -13
- package/docs/src/core/components/ui/table/table.md +3 -3
- package/docs/src/docs/_core-concept/dataFlow.md +73 -0
- package/docs/src/docs/_core-concept/subscriber.md +9 -10
- package/docs/src/docs/_decorators/ancestor-attribute.md +4 -3
- package/docs/src/docs/_decorators/auto-subscribe.md +19 -16
- package/docs/src/docs/_decorators/bind.md +20 -17
- package/docs/src/docs/_decorators/get.md +7 -4
- package/docs/src/docs/_decorators/handle.md +171 -0
- package/docs/src/docs/_decorators/on-assign.md +99 -73
- package/docs/src/docs/_decorators/publish.md +2 -1
- package/docs/src/docs/_decorators/subscribe.md +70 -9
- package/docs/src/docs/_decorators/wait-for-ancestors.md +13 -10
- package/docs/src/docs/_directives/sub.md +91 -0
- package/docs/src/docs/_getting-started/ai-agents.md +56 -0
- package/docs/src/docs/_getting-started/concorde-manual-install.md +133 -0
- package/docs/src/docs/_getting-started/concorde-outside.md +13 -123
- package/docs/src/docs/_getting-started/create-a-component.md +2 -0
- package/docs/src/docs/_getting-started/my-first-component.md +236 -0
- package/docs/src/docs/_getting-started/my-first-subscriber.md +29 -83
- package/docs/src/docs/_getting-started/pubsub.md +21 -134
- package/docs/src/docs/_getting-started/start.md +26 -18
- package/docs/src/docs/_misc/api-configuration.md +79 -0
- package/docs/src/docs/_misc/dataProviderKey.md +38 -5
- package/docs/src/docs/_misc/docs-mock-api.md +60 -0
- package/docs/src/docs/_misc/endpoint.md +2 -1
- package/docs/src/docs/_misc/html-integration.md +13 -0
- package/docs/src/docs/search/docs-search.json +4163 -873
- package/docs/src/tsconfig.json +380 -317
- package/gitlab/job_tests.sh +55 -0
- package/package.json +34 -3
- package/public/altcha-widget.js +2662 -0
- package/public/docs-mock-api-sw.js +589 -0
- package/public/docs-mock-api-sw.js.map +7 -0
- package/scripts/ai-init.mjs +167 -0
- package/scripts/docs-mock-api-vite-plugin.ts +116 -0
- package/scripts/docs-open-in-editor-plugin.ts +130 -0
- package/scripts/pre-publish.mjs +2 -1
- package/src/core/components/functional/example/example.ts +1 -1
- package/src/core/components/functional/fetch/fetch.md +13 -11
- package/src/core/components/functional/if/if.md +4 -11
- package/src/core/components/functional/list/list.demo.ts +4 -4
- package/src/core/components/functional/list/list.md +60 -194
- package/src/core/components/functional/list/list.ts +8 -7
- package/src/core/components/functional/queue/queue.demo.ts +1 -1
- package/src/core/components/functional/queue/queue.md +70 -85
- package/src/core/components/functional/queue/queue.ts +4 -4
- package/src/core/components/functional/router/router.md +62 -97
- package/src/core/components/functional/router/router.ts +1 -1
- package/src/core/components/functional/states/states.md +2 -2
- package/src/core/components/functional/submit/submit.md +86 -55
- package/src/core/components/functional/submit/submit.ts +10 -3
- package/src/core/components/ui/captcha/captcha.md +2 -2
- package/src/core/components/ui/card/card.md +1 -1
- package/src/core/components/ui/form/checkbox/checkbox.md +5 -32
- package/src/core/components/ui/form/input/input.md +5 -30
- package/src/core/components/ui/form/input-autocomplete/input-autocomplete.md +6 -4
- package/src/core/components/ui/form/radio/radio.md +5 -32
- package/src/core/components/ui/form/select/select.md +5 -31
- package/src/core/components/ui/form/switch/switch.md +5 -32
- package/src/core/components/ui/loader/loader.md +1 -13
- package/src/core/components/ui/table/table.md +3 -3
- package/src/core/directives/DataProvider.sub.spec.ts +96 -0
- package/src/core/directives/DataProvider.ts +109 -40
- package/src/core/utils/PublisherProxy.ts +33 -18
- package/src/core/utils/dataProviderKey.ts +23 -0
- package/src/core/utils/publisherPathKey.spec.ts +58 -0
- package/src/docs/_core-concept/dataFlow.md +73 -0
- package/src/docs/_core-concept/subscriber.md +9 -10
- package/src/docs/_decorators/ancestor-attribute.md +4 -3
- package/src/docs/_decorators/auto-subscribe.md +19 -16
- package/src/docs/_decorators/bind.md +19 -16
- package/src/docs/_decorators/get.md +7 -4
- package/src/docs/_decorators/handle.md +15 -13
- package/src/docs/_decorators/on-assign.md +53 -53
- package/src/docs/_decorators/publish.md +2 -1
- package/src/docs/_decorators/subscribe.md +70 -9
- package/src/docs/_decorators/wait-for-ancestors.md +13 -10
- package/src/docs/_directives/sub.md +91 -0
- package/src/docs/_getting-started/ai-agents.md +56 -0
- package/src/docs/_getting-started/concorde-manual-install.md +133 -0
- package/src/docs/_getting-started/concorde-outside.md +13 -123
- package/src/docs/_getting-started/create-a-component.md +2 -0
- package/src/docs/_getting-started/my-first-component.md +236 -0
- package/src/docs/_getting-started/my-first-subscriber.md +29 -83
- package/src/docs/_getting-started/pubsub.md +21 -134
- package/src/docs/_getting-started/start.md +26 -18
- package/src/docs/_misc/api-configuration.md +79 -0
- package/src/docs/_misc/dataProviderKey.md +34 -1
- package/src/docs/_misc/docs-mock-api.md +60 -0
- package/src/docs/_misc/endpoint.md +2 -1
- package/src/docs/_misc/html-integration.md +13 -0
- package/src/docs/code.ts +58 -12
- package/src/docs/components/docs-demo-sources.ts +397 -0
- package/src/docs/components/docs-lit-demo-raw.ts +28 -0
- package/src/docs/components/docs-lit-demo.ts +166 -0
- package/src/docs/components/docs-source-link.ts +72 -0
- package/src/docs/docs-location.ts +54 -0
- package/src/docs/docs.ts +12 -0
- package/src/docs/example/decorators-demo-bind-demos.ts +41 -46
- package/src/docs/example/decorators-demo-geo.ts +16 -11
- package/src/docs/example/decorators-demo-init.ts +2 -228
- package/src/docs/example/decorators-demo-subscribe-publish-get-demos.ts +54 -14
- package/src/docs/example/decorators-demo.ts +71 -70
- package/src/docs/example/docs-api-config-demos.ts +234 -0
- package/src/docs/example/docs-joke-demos.ts +297 -0
- package/src/docs/example/docs-list-demos.ts +179 -0
- package/src/docs/example/docs-provider-keys.ts +315 -0
- package/src/docs/example/docs-queue-demos.ts +114 -0
- package/src/docs/example/docs-router-demos.ts +89 -0
- package/src/docs/example/docs-submit-demos.ts +455 -0
- package/src/docs/example/docs-toggle-demos.ts +73 -0
- package/src/docs/example/docs-user-two-scopes.ts +37 -0
- package/src/docs/example/docs-users-list.ts +71 -0
- package/src/docs/example/users.ts +41 -24
- package/src/docs/mock-api/api-config-mock.ts +152 -0
- package/src/docs/mock-api/fixtures.ts +377 -0
- package/src/docs/mock-api/register.ts +25 -0
- package/src/docs/mock-api/router.ts +234 -0
- package/src/docs/mock-api/service-worker.ts +23 -0
- package/src/docs/mock-api/urls.ts +11 -0
- package/src/docs/navigation/navigation.ts +39 -7
- package/src/docs/search/docs-search.json +4021 -936
- package/src/docs/search/markdown-renderer.ts +7 -3
- package/src/docs/search/page.ts +11 -14
- package/src/docs/search/sonic-code-markdown.spec.ts +29 -0
- package/src/docs/search/sonic-code-markdown.ts +28 -0
- package/src/docs.ts +4 -0
- package/src/tsconfig.json +87 -0
- package/src/tsconfig.tsbuildinfo +1 -1
- package/vite.config.mts +8 -0
- package/docs/assets/index-CaysOMFz.js +0 -5046
- package/docs/assets/index-D8mGoXzF.css +0 -1
- package/docs/src/docs/_misc/templates-demo.md +0 -19
- package/src/docs/_misc/templates-demo.md +0 -19
|
@@ -1,228 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export const ensurePublisherValue = <T>(
|
|
4
|
-
publisherId: string,
|
|
5
|
-
defaultValue: T,
|
|
6
|
-
): void => {
|
|
7
|
-
const publisher = PublisherManager.get(publisherId);
|
|
8
|
-
const currentValue =
|
|
9
|
-
typeof publisher.get === "function" ? publisher.get() : undefined;
|
|
10
|
-
|
|
11
|
-
const isUnset =
|
|
12
|
-
currentValue === undefined ||
|
|
13
|
-
currentValue === null ||
|
|
14
|
-
(typeof currentValue === "object" &&
|
|
15
|
-
!Array.isArray(currentValue) &&
|
|
16
|
-
Object.keys(currentValue).length === 0);
|
|
17
|
-
|
|
18
|
-
if (isUnset) {
|
|
19
|
-
publisher.set(defaultValue as T);
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export const initializeDecoratorsDemoData = () => {
|
|
24
|
-
ensurePublisherValue("demoData", {
|
|
25
|
-
title: "Initial Title",
|
|
26
|
-
user: { name: "Initial User" },
|
|
27
|
-
count: 0,
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
ensurePublisherValue("demoUser", {
|
|
31
|
-
name: "Demo User",
|
|
32
|
-
email: "demo@example.com",
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
ensurePublisherValue("demoSettings", {
|
|
36
|
-
theme: "light",
|
|
37
|
-
language: "en",
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
ensurePublisherValue("demoUserSettings", {
|
|
41
|
-
theme: "light",
|
|
42
|
-
language: "en",
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
ensurePublisherValue("autoValue1", 10);
|
|
46
|
-
ensurePublisherValue("autoValue2", 20);
|
|
47
|
-
ensurePublisherValue("waitAncestorDemo", {
|
|
48
|
-
message: "Context from ancestor",
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
ensurePublisherValue("combinedData", { title: "Combined Title" });
|
|
52
|
-
ensurePublisherValue("combinedUser", { name: "Combined User" });
|
|
53
|
-
ensurePublisherValue("combinedSettings", { theme: "dark" });
|
|
54
|
-
|
|
55
|
-
ensurePublisherValue("reflectData", {
|
|
56
|
-
title: "Initial Reflected Title",
|
|
57
|
-
count: 0,
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
ensurePublisherValue("publishDemo", {
|
|
61
|
-
email: "",
|
|
62
|
-
message: "",
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
ensurePublisherValue("dynamicProfiles", {
|
|
66
|
-
alpha: { info: { title: "Profil Alpha" } },
|
|
67
|
-
beta: { info: { title: "Profil Beta" } },
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
ensurePublisherValue("dynamicProfilesAlt", {
|
|
71
|
-
alpha: { info: { title: "Profil Alpha (Alt)" } },
|
|
72
|
-
beta: { info: { title: "Profil Beta (Alt)" } },
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
ensurePublisherValue("demoUsers", [
|
|
76
|
-
{
|
|
77
|
-
id: 1,
|
|
78
|
-
firstName: "Alice",
|
|
79
|
-
lastName: "Smith",
|
|
80
|
-
email: "alice.smith@example.com",
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
id: 2,
|
|
84
|
-
firstName: "Bob",
|
|
85
|
-
lastName: "Johnson",
|
|
86
|
-
email: "bob.johnson@example.com",
|
|
87
|
-
},
|
|
88
|
-
{
|
|
89
|
-
id: 3,
|
|
90
|
-
firstName: "Carol",
|
|
91
|
-
lastName: "Williams",
|
|
92
|
-
email: "carol.williams@example.com",
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
id: 4,
|
|
96
|
-
firstName: "David",
|
|
97
|
-
lastName: "Brown",
|
|
98
|
-
email: "david.brown@example.com",
|
|
99
|
-
},
|
|
100
|
-
{
|
|
101
|
-
id: 5,
|
|
102
|
-
firstName: "Eve",
|
|
103
|
-
lastName: "Jones",
|
|
104
|
-
email: "eve.jones@example.com",
|
|
105
|
-
},
|
|
106
|
-
{
|
|
107
|
-
id: 6,
|
|
108
|
-
firstName: "Frank",
|
|
109
|
-
lastName: "Garcia",
|
|
110
|
-
email: "frank.garcia@example.com",
|
|
111
|
-
},
|
|
112
|
-
{
|
|
113
|
-
id: 7,
|
|
114
|
-
firstName: "Grace",
|
|
115
|
-
lastName: "Miller",
|
|
116
|
-
email: "grace.miller@example.com",
|
|
117
|
-
},
|
|
118
|
-
{
|
|
119
|
-
id: 8,
|
|
120
|
-
firstName: "Henry",
|
|
121
|
-
lastName: "Davis",
|
|
122
|
-
email: "henry.davis@example.com",
|
|
123
|
-
},
|
|
124
|
-
{
|
|
125
|
-
id: 9,
|
|
126
|
-
firstName: "Ivy",
|
|
127
|
-
lastName: "Martinez",
|
|
128
|
-
email: "ivy.martinez@example.com",
|
|
129
|
-
},
|
|
130
|
-
{
|
|
131
|
-
id: 10,
|
|
132
|
-
firstName: "Jack",
|
|
133
|
-
lastName: "Taylor",
|
|
134
|
-
email: "jack.taylor@example.com",
|
|
135
|
-
},
|
|
136
|
-
]);
|
|
137
|
-
|
|
138
|
-
ensurePublisherValue("demoUsersAlt", [
|
|
139
|
-
{
|
|
140
|
-
id: 11,
|
|
141
|
-
firstName: "Sophie",
|
|
142
|
-
lastName: "Lindquist",
|
|
143
|
-
email: "sophie.lindquist@example.com",
|
|
144
|
-
},
|
|
145
|
-
{
|
|
146
|
-
id: 12,
|
|
147
|
-
firstName: "Mateo",
|
|
148
|
-
lastName: "Ortega",
|
|
149
|
-
email: "mateo.ortega@example.com",
|
|
150
|
-
},
|
|
151
|
-
{
|
|
152
|
-
id: 13,
|
|
153
|
-
firstName: "Jin",
|
|
154
|
-
lastName: "Park",
|
|
155
|
-
email: "jin.park@example.com",
|
|
156
|
-
},
|
|
157
|
-
{
|
|
158
|
-
id: 14,
|
|
159
|
-
firstName: "Fatima",
|
|
160
|
-
lastName: "El-Sayed",
|
|
161
|
-
email: "fatima.el-sayed@example.com",
|
|
162
|
-
},
|
|
163
|
-
{
|
|
164
|
-
id: 15,
|
|
165
|
-
firstName: "Lars",
|
|
166
|
-
lastName: "Johansson",
|
|
167
|
-
email: "lars.johansson@example.com",
|
|
168
|
-
},
|
|
169
|
-
{
|
|
170
|
-
id: 16,
|
|
171
|
-
firstName: "Amara",
|
|
172
|
-
lastName: "Singh",
|
|
173
|
-
email: "amara.singh@example.com",
|
|
174
|
-
},
|
|
175
|
-
{
|
|
176
|
-
id: 17,
|
|
177
|
-
firstName: "Zuri",
|
|
178
|
-
lastName: "Okafor",
|
|
179
|
-
email: "zuri.okafor@example.com",
|
|
180
|
-
},
|
|
181
|
-
{
|
|
182
|
-
id: 18,
|
|
183
|
-
firstName: "Luca",
|
|
184
|
-
lastName: "Rossi",
|
|
185
|
-
email: "luca.rossi@example.com",
|
|
186
|
-
},
|
|
187
|
-
{
|
|
188
|
-
id: 19,
|
|
189
|
-
firstName: "Ava",
|
|
190
|
-
lastName: "Murphy",
|
|
191
|
-
email: "ava.murphy@example.com",
|
|
192
|
-
},
|
|
193
|
-
{
|
|
194
|
-
id: 20,
|
|
195
|
-
firstName: "Noah",
|
|
196
|
-
lastName: "Keller",
|
|
197
|
-
email: "noah.keller@example.com",
|
|
198
|
-
},
|
|
199
|
-
]);
|
|
200
|
-
|
|
201
|
-
ensurePublisherValue("demoUsersSettings", [
|
|
202
|
-
{ theme: "light", language: "en" },
|
|
203
|
-
{ theme: "dark", language: "fr" },
|
|
204
|
-
{ theme: "auto", language: "es" },
|
|
205
|
-
{ theme: "light", language: "en" },
|
|
206
|
-
{ theme: "dark", language: "fr" },
|
|
207
|
-
{ theme: "auto", language: "es" },
|
|
208
|
-
{ theme: "light", language: "en" },
|
|
209
|
-
{ theme: "dark", language: "fr" },
|
|
210
|
-
{ theme: "auto", language: "es" },
|
|
211
|
-
{ theme: "light", language: "en" },
|
|
212
|
-
]);
|
|
213
|
-
|
|
214
|
-
ensurePublisherValue("demoUsersAltSettings", [
|
|
215
|
-
{ theme: "dark", language: "de" },
|
|
216
|
-
{ theme: "light", language: "it" },
|
|
217
|
-
{ theme: "auto", language: "ja" },
|
|
218
|
-
{ theme: "dark", language: "pt" },
|
|
219
|
-
{ theme: "light", language: "ru" },
|
|
220
|
-
{ theme: "auto", language: "zh" },
|
|
221
|
-
{ theme: "dark", language: "ar" },
|
|
222
|
-
{ theme: "light", language: "sv" },
|
|
223
|
-
{ theme: "auto", language: "nl" },
|
|
224
|
-
{ theme: "dark", language: "pl" },
|
|
225
|
-
]);
|
|
226
|
-
};
|
|
227
|
-
|
|
228
|
-
initializeDecoratorsDemoData();
|
|
1
|
+
/** Default doc demo store values — keys in @docs-provider-keys.ts, writes via `set()`. */
|
|
2
|
+
import "./docs-provider-keys";
|
|
@@ -7,7 +7,15 @@ import type {
|
|
|
7
7
|
} from "@supersoniks/concorde/core/utils/api";
|
|
8
8
|
import { DataProviderKey } from "@supersoniks/concorde/core/utils/dataProviderKey";
|
|
9
9
|
import { sub } from "@supersoniks/concorde/directives";
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
get as storeGet,
|
|
12
|
+
set,
|
|
13
|
+
} from "@supersoniks/concorde/core/utils/PublisherProxy";
|
|
14
|
+
import { publishDemoKey } from "./docs-provider-keys";
|
|
15
|
+
import {
|
|
16
|
+
docsDemoDynApiConfAKey,
|
|
17
|
+
docsDemoDynApiConfBKey,
|
|
18
|
+
} from "./decorators-demo-geo";
|
|
11
19
|
import { tailwind } from "../tailwind";
|
|
12
20
|
import "./decorators-demo-init";
|
|
13
21
|
import {
|
|
@@ -24,8 +32,6 @@ type PublishDemoData = {
|
|
|
24
32
|
message: string;
|
|
25
33
|
};
|
|
26
34
|
|
|
27
|
-
const publishDemoKey = new DataProviderKey<PublishDemoData>("publishDemo");
|
|
28
|
-
|
|
29
35
|
@customElement("demo-publish")
|
|
30
36
|
export class DemoPublish extends LitElement {
|
|
31
37
|
static styles = [tailwind];
|
|
@@ -40,7 +46,7 @@ export class DemoPublish extends LitElement {
|
|
|
40
46
|
|
|
41
47
|
connectedCallback() {
|
|
42
48
|
super.connectedCallback();
|
|
43
|
-
|
|
49
|
+
set(publishDemoKey, { email: "", message: "" });
|
|
44
50
|
}
|
|
45
51
|
|
|
46
52
|
render() {
|
|
@@ -72,8 +78,8 @@ export class DemoPublish extends LitElement {
|
|
|
72
78
|
>
|
|
73
79
|
Published values (from sub):
|
|
74
80
|
</p>
|
|
75
|
-
<p>Email: ${sub(
|
|
76
|
-
<p>Message: ${sub(
|
|
81
|
+
<p>Email: ${sub(publishDemoKey.email) || "—"}</p>
|
|
82
|
+
<p>Message: ${sub(publishDemoKey.message) || "—"}</p>
|
|
77
83
|
</div>
|
|
78
84
|
</div>
|
|
79
85
|
`;
|
|
@@ -95,7 +101,7 @@ export class DemoApiGet extends LitElement {
|
|
|
95
101
|
<div class="space-y-2">
|
|
96
102
|
<p class="text-sm text-neutral-600 dark:text-neutral-400">
|
|
97
103
|
<code>@get</code> — même service que
|
|
98
|
-
<code>sonic-queue</code> (<code
|
|
104
|
+
<code>sonic-queue</code> (<code>/docs-mock-api/geo/</code>).
|
|
99
105
|
Propriété typée <code>ApiGetResult<T></code>.
|
|
100
106
|
</p>
|
|
101
107
|
${status != null
|
|
@@ -138,10 +144,10 @@ export class DemoApiGetConfigurationKey extends LitElement {
|
|
|
138
144
|
geoApiPayloadDyn?: ApiGetResult<GeoCommuneRow[]>;
|
|
139
145
|
|
|
140
146
|
private touchCurrentConfigPublisher() {
|
|
141
|
-
const
|
|
142
|
-
|
|
143
|
-
const cur =
|
|
144
|
-
|
|
147
|
+
const key =
|
|
148
|
+
this.configSlot === "A" ? docsDemoDynApiConfAKey : docsDemoDynApiConfBKey;
|
|
149
|
+
const cur = storeGet(key) as APIConfiguration;
|
|
150
|
+
set(key, {
|
|
145
151
|
...cur,
|
|
146
152
|
blockUntilDone: !cur.blockUntilDone,
|
|
147
153
|
});
|
|
@@ -275,6 +281,41 @@ export class DemoApiGetPublishSubscribe extends LitElement {
|
|
|
275
281
|
|
|
276
282
|
type User = { firstName: string; lastName: string; email: string };
|
|
277
283
|
|
|
284
|
+
const demoUsersSubKey = new DataProviderKey<User, { userIndex: number }>(
|
|
285
|
+
"demoUsers.${userIndex}",
|
|
286
|
+
);
|
|
287
|
+
|
|
288
|
+
@customElement("demo-sub-template")
|
|
289
|
+
export class DemoSubTemplate extends LitElement {
|
|
290
|
+
static styles = [tailwind];
|
|
291
|
+
|
|
292
|
+
@property({ type: Number })
|
|
293
|
+
userIndex = 0;
|
|
294
|
+
|
|
295
|
+
render() {
|
|
296
|
+
return html`
|
|
297
|
+
<div class="space-y-4">
|
|
298
|
+
<p class="text-sm text-neutral-600 dark:text-neutral-400">
|
|
299
|
+
<code>sub(demoUsersSubKey.email)</code> — same dynamic path as
|
|
300
|
+
<code>@subscribe</code>, reactive in the template.
|
|
301
|
+
</p>
|
|
302
|
+
<sonic-input
|
|
303
|
+
type="number"
|
|
304
|
+
.value=${String(this.userIndex)}
|
|
305
|
+
@input=${(e: Event) =>
|
|
306
|
+
(this.userIndex = parseInt((e.target as HTMLInputElement).value))}
|
|
307
|
+
min="0"
|
|
308
|
+
max="9"
|
|
309
|
+
label="User index"
|
|
310
|
+
></sonic-input>
|
|
311
|
+
<p class="rounded border border-neutral-200 dark:border-neutral-700 p-3">
|
|
312
|
+
Email: <strong>${sub(demoUsersSubKey.email) || "—"}</strong>
|
|
313
|
+
</p>
|
|
314
|
+
</div>
|
|
315
|
+
`;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
|
|
278
319
|
@customElement("demo-subscribe-dynamic")
|
|
279
320
|
export class DemoSubscribeDynamic extends LitElement {
|
|
280
321
|
static styles = [tailwind];
|
|
@@ -336,9 +377,8 @@ export class DemoHandle extends LitElement {
|
|
|
336
377
|
}
|
|
337
378
|
|
|
338
379
|
incrementCount() {
|
|
339
|
-
const
|
|
340
|
-
|
|
341
|
-
publisher.set({ ...data, count: data.count + 1 });
|
|
380
|
+
const data = storeGet(demoDataKey);
|
|
381
|
+
set(demoDataKey, { ...data, count: data.count + 1 });
|
|
342
382
|
}
|
|
343
383
|
|
|
344
384
|
render() {
|
|
@@ -7,11 +7,20 @@ import {
|
|
|
7
7
|
awaitConnectedAncestors,
|
|
8
8
|
dispatchConnectedEvent,
|
|
9
9
|
} from "@supersoniks/concorde/decorators";
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
PublisherProxy,
|
|
13
|
-
} from "@supersoniks/concorde/core/utils/PublisherProxy";
|
|
10
|
+
import type { PublisherProxy } from "@supersoniks/concorde/core/utils/PublisherProxy";
|
|
11
|
+
import { get, set } from "@supersoniks/concorde/core/utils/PublisherProxy";
|
|
14
12
|
import { Objects } from "@supersoniks/concorde/utils";
|
|
13
|
+
import {
|
|
14
|
+
autoValue1Key,
|
|
15
|
+
autoValue2Key,
|
|
16
|
+
demoUserKey,
|
|
17
|
+
demoUserSettingsKey,
|
|
18
|
+
demoUsersAltKey,
|
|
19
|
+
demoUsersAltSettingsKey,
|
|
20
|
+
demoUsersKey,
|
|
21
|
+
demoUsersSettingsKey,
|
|
22
|
+
waitAncestorDemoKey,
|
|
23
|
+
} from "./docs-provider-keys";
|
|
15
24
|
import { tailwind } from "../tailwind";
|
|
16
25
|
import "./decorators-demo-bind-demos";
|
|
17
26
|
import "./decorators-demo-subscribe-publish-get-demos";
|
|
@@ -76,15 +85,12 @@ export class DemoOnAssign extends LitElement {
|
|
|
76
85
|
}
|
|
77
86
|
|
|
78
87
|
updateData() {
|
|
79
|
-
const user = PublisherManager.get("demoUser");
|
|
80
|
-
const userSettings = PublisherManager.get("demoUserSettings");
|
|
81
88
|
const userNumber = Math.floor(Math.random() * 100);
|
|
82
|
-
|
|
89
|
+
set(demoUserKey, {
|
|
83
90
|
name: `User n°${userNumber}`,
|
|
84
91
|
email: `user-${userNumber}@example.com`,
|
|
85
92
|
});
|
|
86
|
-
|
|
87
|
-
userSettings.set({
|
|
93
|
+
set(demoUserSettingsKey, {
|
|
88
94
|
theme: ["light", "dark", "auto"][Math.floor(Math.random() * 3)],
|
|
89
95
|
language: ["en", "fr", "es"][Math.floor(Math.random() * 3)],
|
|
90
96
|
});
|
|
@@ -96,7 +102,8 @@ export class DemoOnAssignDynamic extends LitElement {
|
|
|
96
102
|
static styles = [tailwind];
|
|
97
103
|
|
|
98
104
|
@property({ type: String })
|
|
99
|
-
dataProvider:
|
|
105
|
+
dataProvider: typeof demoUsersKey.path | typeof demoUsersAltKey.path =
|
|
106
|
+
demoUsersKey.path;
|
|
100
107
|
|
|
101
108
|
@property({ type: Number })
|
|
102
109
|
userIndex: number = 0;
|
|
@@ -119,62 +126,56 @@ export class DemoOnAssignDynamic extends LitElement {
|
|
|
119
126
|
|
|
120
127
|
updateDataProvider(e: Event) {
|
|
121
128
|
this.dataProvider = (e.target as HTMLSelectElement).value as
|
|
122
|
-
|
|
|
123
|
-
|
|
|
129
|
+
| typeof demoUsersKey.path
|
|
130
|
+
| typeof demoUsersAltKey.path;
|
|
124
131
|
}
|
|
125
132
|
|
|
126
133
|
updateCurrentUserData() {
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
])
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
settingPublisher.set({
|
|
166
|
-
theme: randomTheme,
|
|
167
|
-
language: randomLanguage,
|
|
168
|
-
});
|
|
169
|
-
}
|
|
134
|
+
const usersKey =
|
|
135
|
+
this.dataProvider === demoUsersAltKey.path ? demoUsersAltKey : demoUsersKey;
|
|
136
|
+
const settingsKey =
|
|
137
|
+
this.dataProvider === demoUsersAltKey.path
|
|
138
|
+
? demoUsersAltSettingsKey
|
|
139
|
+
: demoUsersSettingsKey;
|
|
140
|
+
const users = [...get(usersKey)];
|
|
141
|
+
const settings = [...get(settingsKey)];
|
|
142
|
+
const idx = this.userIndex;
|
|
143
|
+
if (!users[idx] || !settings[idx]) return;
|
|
144
|
+
|
|
145
|
+
const randomNames = [
|
|
146
|
+
{ firstName: "Alice", lastName: "Wonder" },
|
|
147
|
+
{ firstName: "Bob", lastName: "Builder" },
|
|
148
|
+
{ firstName: "Charlie", lastName: "Chaplin" },
|
|
149
|
+
{ firstName: "Diana", lastName: "Prince" },
|
|
150
|
+
{ firstName: "Eve", lastName: "Adams" },
|
|
151
|
+
];
|
|
152
|
+
const randomThemes = ["light", "dark", "auto"];
|
|
153
|
+
const randomLanguages = ["en", "fr", "es", "de", "it"];
|
|
154
|
+
const randomName =
|
|
155
|
+
randomNames[Math.floor(Math.random() * randomNames.length)];
|
|
156
|
+
const randomEmail = `${randomName.firstName.toLowerCase()}.${randomName.lastName.toLowerCase()}@example.com`;
|
|
157
|
+
|
|
158
|
+
users[idx] = {
|
|
159
|
+
...users[idx],
|
|
160
|
+
firstName: randomName.firstName,
|
|
161
|
+
lastName: randomName.lastName,
|
|
162
|
+
email: randomEmail,
|
|
163
|
+
};
|
|
164
|
+
settings[idx] = {
|
|
165
|
+
theme: randomThemes[Math.floor(Math.random() * randomThemes.length)],
|
|
166
|
+
language:
|
|
167
|
+
randomLanguages[Math.floor(Math.random() * randomLanguages.length)],
|
|
168
|
+
};
|
|
169
|
+
set(usersKey, users);
|
|
170
|
+
set(settingsKey, settings);
|
|
170
171
|
}
|
|
171
172
|
|
|
172
173
|
render() {
|
|
173
174
|
return html`
|
|
174
175
|
<div class="flex flex-col gap-2">
|
|
175
176
|
<sonic-select label="Users set" @change=${this.updateDataProvider}>
|
|
176
|
-
<option value
|
|
177
|
-
<option value
|
|
177
|
+
<option value=${demoUsersKey.path}>First set of users</option>
|
|
178
|
+
<option value=${demoUsersAltKey.path}>Second set of users</option>
|
|
178
179
|
</sonic-select>
|
|
179
180
|
<sonic-input
|
|
180
181
|
type="number"
|
|
@@ -217,8 +218,8 @@ export class DemoAutoSubscribe extends LitElement {
|
|
|
217
218
|
|
|
218
219
|
@autoSubscribe()
|
|
219
220
|
updateDisplay() {
|
|
220
|
-
const value1 =
|
|
221
|
-
const value2 =
|
|
221
|
+
const value1 = get(autoValue1Key) || 0;
|
|
222
|
+
const value2 = get(autoValue2Key) || 0;
|
|
222
223
|
|
|
223
224
|
this.computedValue = value1 + value2;
|
|
224
225
|
this.displayText = `${value1} + ${value2} = ${this.computedValue}`;
|
|
@@ -228,19 +229,19 @@ export class DemoAutoSubscribe extends LitElement {
|
|
|
228
229
|
return html`
|
|
229
230
|
<p><strong>${this.displayText}</strong></p>
|
|
230
231
|
<div>
|
|
231
|
-
<sonic-button @click=${() => this.randomizeValue("autoValue1")}
|
|
232
|
-
Randomize Value 1
|
|
233
|
-
|
|
234
|
-
<sonic-button @click=${() => this.randomizeValue("autoValue2")}
|
|
232
|
+
<sonic-button @click=${() => this.randomizeValue("autoValue1")}
|
|
233
|
+
>Randomize Value 1</sonic-button
|
|
234
|
+
>
|
|
235
|
+
<sonic-button @click=${() => this.randomizeValue("autoValue2")}
|
|
235
236
|
Randomize Value 2
|
|
236
237
|
</sonic-button>
|
|
237
238
|
</div>
|
|
238
239
|
`;
|
|
239
240
|
}
|
|
240
241
|
|
|
241
|
-
randomizeValue(
|
|
242
|
-
const
|
|
243
|
-
|
|
242
|
+
randomizeValue(which: "autoValue1" | "autoValue2") {
|
|
243
|
+
const key = which === "autoValue1" ? autoValue1Key : autoValue2Key;
|
|
244
|
+
set(key, Math.floor(Math.random() * 100));
|
|
244
245
|
}
|
|
245
246
|
}
|
|
246
247
|
|
|
@@ -304,7 +305,7 @@ export class DemoWaitAncestorsSection extends LitElement {
|
|
|
304
305
|
? "Parent already registered"
|
|
305
306
|
: "Register parent component"}
|
|
306
307
|
</sonic-button>
|
|
307
|
-
<demo-wait-ancestor-container dataProvider
|
|
308
|
+
<demo-wait-ancestor-container dataProvider=${waitAncestorDemoKey.path}>
|
|
308
309
|
<demo-wait-ancestor-value></demo-wait-ancestor-value>
|
|
309
310
|
</demo-wait-ancestor-container>
|
|
310
311
|
</div>
|
|
@@ -391,7 +392,7 @@ export class DemoWaitAncestorsMultiSection extends LitElement {
|
|
|
391
392
|
</sonic-button>
|
|
392
393
|
</div>
|
|
393
394
|
<demo-wait-ancestor-outer>
|
|
394
|
-
<demo-wait-ancestor-inner dataProvider
|
|
395
|
+
<demo-wait-ancestor-inner dataProvider=${waitAncestorDemoKey.path}>
|
|
395
396
|
<demo-wait-ancestor-value-multi></demo-wait-ancestor-value-multi>
|
|
396
397
|
</demo-wait-ancestor-inner>
|
|
397
398
|
</demo-wait-ancestor-outer>
|
|
@@ -449,7 +450,7 @@ export class DemoWaitAncestorsReadySection extends LitElement {
|
|
|
449
450
|
<sonic-button ?disabled=${this.childInDom} @click=${this.addChild}>
|
|
450
451
|
${this.childInDom ? "Child added" : "Add child dynamically"}
|
|
451
452
|
</sonic-button>
|
|
452
|
-
<demo-wait-ancestor-ready dataProvider
|
|
453
|
+
<demo-wait-ancestor-ready dataProvider=${waitAncestorDemoKey.path}>
|
|
453
454
|
${this.childInDom
|
|
454
455
|
? html`<demo-wait-ancestor-value-ready></demo-wait-ancestor-value-ready>`
|
|
455
456
|
: html``}
|
|
@@ -468,7 +469,7 @@ export class DemoWaitAncestorsStaticSection extends LitElement {
|
|
|
468
469
|
<p class="text-sm text-neutral-600 dark:text-neutral-400 mb-4">
|
|
469
470
|
Parent et enfant présents dès le chargement — pas de délai.
|
|
470
471
|
</p>
|
|
471
|
-
<demo-wait-ancestor-ready dataProvider
|
|
472
|
+
<demo-wait-ancestor-ready dataProvider=${waitAncestorDemoKey.path}>
|
|
472
473
|
<demo-wait-ancestor-value-ready></demo-wait-ancestor-value-ready>
|
|
473
474
|
</demo-wait-ancestor-ready>
|
|
474
475
|
`;
|