@supersoniks/concorde 4.9.0 → 4.9.2
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/build-infos.json +1 -1
- package/concorde-core.bundle.js +195 -195
- package/concorde-core.es.js +3390 -3370
- package/dist/concorde-core.bundle.js +195 -195
- package/dist/concorde-core.es.js +3390 -3370
- package/dist/docs-mock-api-sw.js +3 -1
- package/dist/docs-mock-api-sw.js.map +2 -2
- package/dist/js/core/decorators/api.js +64 -12
- package/dist/js/core/decorators/api.js.map +1 -1
- package/dist/js/core/utils/HTML.js +4 -5
- package/dist/js/core/utils/HTML.js.map +1 -1
- package/dist/robots.txt +15 -1
- package/dist/types/core/decorators/api.d.ts +14 -1
- package/dist/types/core/decorators/api.d.ts.map +1 -1
- package/dist/types/core/utils/HTML.d.ts.map +1 -1
- package/docs/assets/{index-t0-i22oI.css → index-Bnp7gVaA.css} +1 -1
- package/docs/assets/{index-BEgZEIbv.js → index-hElUgV9_.js} +894 -552
- package/docs/crawl/core/components/functional/date/date.html +190 -0
- package/docs/crawl/core/components/functional/fetch/fetch.html +109 -0
- package/docs/crawl/core/components/functional/if/if.html +27 -0
- package/docs/crawl/core/components/functional/list/list.html +70 -0
- package/docs/crawl/core/components/functional/mix/mix.html +45 -0
- package/docs/crawl/core/components/functional/queue/queue.html +96 -0
- package/docs/crawl/core/components/functional/router/router.html +106 -0
- package/docs/crawl/core/components/functional/sdui/sdui.html +269 -0
- package/docs/crawl/core/components/functional/states/states.html +66 -0
- package/docs/crawl/core/components/functional/submit/submit.html +160 -0
- package/docs/crawl/core/components/functional/subscriber/subscriber.html +67 -0
- package/docs/crawl/core/components/functional/value/value.html +51 -0
- package/docs/crawl/core/components/ui/alert/alert.html +110 -0
- package/docs/crawl/core/components/ui/alert-messages/alert-messages.html +23 -0
- package/docs/crawl/core/components/ui/badge/badge.html +119 -0
- package/docs/crawl/core/components/ui/button/button.html +149 -0
- package/docs/crawl/core/components/ui/captcha/captcha.html +30 -0
- package/docs/crawl/core/components/ui/card/card.html +99 -0
- package/docs/crawl/core/components/ui/divider/divider.html +58 -0
- package/docs/crawl/core/components/ui/form/checkbox/checkbox.html +73 -0
- package/docs/crawl/core/components/ui/form/fieldset/fieldset.html +135 -0
- package/docs/crawl/core/components/ui/form/form-actions/form-actions.html +79 -0
- package/docs/crawl/core/components/ui/form/form-layout/form-layout.html +62 -0
- package/docs/crawl/core/components/ui/form/input/input.html +109 -0
- package/docs/crawl/core/components/ui/form/input-autocomplete/input-autocomplete.html +106 -0
- package/docs/crawl/core/components/ui/form/radio/radio.html +56 -0
- package/docs/crawl/core/components/ui/form/select/select.html +73 -0
- package/docs/crawl/core/components/ui/form/switch/switch.html +56 -0
- package/docs/crawl/core/components/ui/form/textarea/textarea.html +59 -0
- package/docs/crawl/core/components/ui/group/group.html +82 -0
- package/docs/crawl/core/components/ui/icon/icon.html +133 -0
- package/docs/crawl/core/components/ui/image/image.html +110 -0
- package/docs/crawl/core/components/ui/link/link.html +42 -0
- package/docs/crawl/core/components/ui/loader/loader.html +50 -0
- package/docs/crawl/core/components/ui/menu/menu.html +322 -0
- package/docs/crawl/core/components/ui/modal/modal.html +117 -0
- package/docs/crawl/core/components/ui/pop/pop.html +102 -0
- package/docs/crawl/core/components/ui/progress/progress.html +58 -0
- package/docs/crawl/core/components/ui/table/table.html +413 -0
- package/docs/crawl/core/components/ui/toast/toast.html +122 -0
- package/docs/crawl/core/components/ui/tooltip/tooltip.html +79 -0
- package/docs/crawl/docs/_core-concept/dataFlow.html +166 -0
- package/docs/crawl/docs/_core-concept/overview.html +66 -0
- package/docs/crawl/docs/_core-concept/subscriber.html +75 -0
- package/docs/crawl/docs/_decorators/ancestor-attribute.html +116 -0
- package/docs/crawl/docs/_decorators/auto-subscribe.html +202 -0
- package/docs/crawl/docs/_decorators/bind.html +141 -0
- package/docs/crawl/docs/_decorators/get.html +120 -0
- package/docs/crawl/docs/_decorators/handle.html +165 -0
- package/docs/crawl/docs/_decorators/on-assign.html +355 -0
- package/docs/crawl/docs/_decorators/patch.html +52 -0
- package/docs/crawl/docs/_decorators/post.html +102 -0
- package/docs/crawl/docs/_decorators/publish.html +61 -0
- package/docs/crawl/docs/_decorators/put.html +49 -0
- package/docs/crawl/docs/_decorators/subscribe.html +109 -0
- package/docs/crawl/docs/_decorators/wait-for-ancestors.html +137 -0
- package/docs/crawl/docs/_directives/sub.html +93 -0
- package/docs/crawl/docs/_getting-started/ai-agents.html +134 -0
- package/docs/crawl/docs/_getting-started/concorde-manual-install.html +100 -0
- package/docs/crawl/docs/_getting-started/concorde-outside.html +58 -0
- package/docs/crawl/docs/_getting-started/create-a-component.html +111 -0
- package/docs/crawl/docs/_getting-started/my-first-component.html +189 -0
- package/docs/crawl/docs/_getting-started/my-first-subscriber.html +110 -0
- package/docs/crawl/docs/_getting-started/pubsub.html +62 -0
- package/docs/crawl/docs/_getting-started/start.html +76 -0
- package/docs/crawl/docs/_getting-started/theming.html +85 -0
- package/docs/crawl/docs/_misc/api-configuration.html +149 -0
- package/docs/crawl/docs/_misc/dataProviderKey.html +135 -0
- package/docs/crawl/docs/_misc/docs-mock-api.html +146 -0
- package/docs/crawl/docs/_misc/dynamic-path.html +180 -0
- package/docs/crawl/docs/_misc/endpoint.html +50 -0
- package/docs/crawl/docs/_misc/html-integration.html +47 -0
- package/docs/crawl/hubs/decorators.html +467 -0
- package/docs/crawl/hubs/form-components.html +357 -0
- package/docs/crawl/hubs/remote-data.html +374 -0
- package/docs/crawl/index.html +99 -0
- package/docs/docs-mock-api-sw.js +3 -1
- package/docs/docs-mock-api-sw.js.map +2 -2
- package/docs/index.html +3 -3
- package/docs/llms-full.txt +5423 -0
- package/docs/llms.txt +102 -0
- package/docs/robots.txt +15 -1
- package/docs/sitemap.xml +231 -0
- package/docs/src/docs/_decorators/ancestor-attribute.md +56 -8
- package/docs/src/docs/_decorators/get.md +47 -1
- package/docs/src/docs/search/docs-search.json +92 -2
- package/docs/src/tsconfig.declarations.json +22 -0
- package/docs/src/tsconfig.emit.json +23 -0
- package/docs/src/tsconfig.json +3 -285
- package/index.html +1 -0
- package/package.json +1 -1
- package/public/docs-mock-api-sw.js +3 -1
- package/public/docs-mock-api-sw.js.map +2 -2
- package/public/robots.txt +15 -1
- package/scripts/generate-crawl-docs.mjs +569 -0
- package/scripts/post-build-docs.js +18 -14
- package/src/core/decorators/api.spec.ts +74 -4
- package/src/core/decorators/api.ts +103 -20
- package/src/core/decorators/subscriber/ancestorAttribute.spec.ts +42 -0
- package/src/core/utils/HTML.ts +4 -5
- package/src/docs/_decorators/get.md +47 -1
- package/src/docs/components/docs-demo-sources.ts +7 -2
- package/src/docs/example/decorators-demo-geo.ts +5 -0
- package/src/docs/example/decorators-demo-subscribe-publish-get-demos.ts +72 -31
- package/src/docs/mock-api/router.ts +3 -1
- package/src/docs/search/docs-search.json +92 -2
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="fr" data-crawl-url="https://concorde.supersoniks.org/crawl/docs/_core-concept/dataFlow.html" data-doc-id="docs/_core-concept/dataFlow">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
+
<title>Data flow — Concorde</title>
|
|
7
|
+
<meta name="description" content="Recommended patterns for new Concorde apps (Lit + TypeScript). Under the hood, data lives in a DataProvider store (legacy Publisher API: Legacy: Sharing data).">
|
|
8
|
+
<meta name="keywords" content="Concorde, supersoniks, docs/_core-concept/dataFlow, dataFlow, Data flow, concept, DataProvider, get, set, dp, DataProviderKey, sub(key), @subscribe, @state, @ancestorAttribute">
|
|
9
|
+
<meta name="concorde-doc-id" content="docs/_core-concept/dataFlow">
|
|
10
|
+
<link rel="canonical" href="https://concorde.supersoniks.org/crawl/docs/_core-concept/dataFlow.html">
|
|
11
|
+
</head>
|
|
12
|
+
<body>
|
|
13
|
+
<header>
|
|
14
|
+
<p><a href="../../index.html">Concorde documentation (crawl)</a> · <a href="https://concorde.supersoniks.org/#docs/_core-concept/dataFlow.md/dataFlow" rel="nofollow">interactive version</a></p>
|
|
15
|
+
</header>
|
|
16
|
+
<main>
|
|
17
|
+
<article>
|
|
18
|
+
<p class="doc-lead" id="doc-summary"><strong>Concorde concept — Data flow</strong>. Recommended patterns for new Concorde apps (Lit + TypeScript). Under the hood, data lives in a DataProvider store (legacy Publisher API: Legacy: Sharing data). <span>Doc ID: <code>docs/_core-concept/dataFlow</code>. Keywords: Concorde, supersoniks, docs/_core-concept/dataFlow, dataFlow, Data flow, concept, DataProvider, get, set, dp, DataProviderKey, sub(key), @subscribe, @state, @ancestorAttribute. URL: <a href="https://concorde.supersoniks.org/crawl/docs/_core-concept/dataFlow.html">https://concorde.supersoniks.org/crawl/docs/_core-concept/dataFlow.html</a>.</span></p>
|
|
19
|
+
<h1 id="data-flow">Data flow</h1>
|
|
20
|
+
<p>Recommended patterns for new Concorde apps (Lit + TypeScript). Under the hood, data lives in a <strong>DataProvider</strong> store (legacy <strong>Publisher</strong> API: <a href="../_getting-started/pubsub.html#pubsub">Legacy: Sharing data</a>).</p>
|
|
21
|
+
<h2 id="quick-map">Quick map</h2>
|
|
22
|
+
<table>
|
|
23
|
+
<thead>
|
|
24
|
+
<tr>
|
|
25
|
+
<th>Need</th>
|
|
26
|
+
<th>Use</th>
|
|
27
|
+
</tr>
|
|
28
|
+
</thead>
|
|
29
|
+
<tbody><tr>
|
|
30
|
+
<td>Read/write in code</td>
|
|
31
|
+
<td><code>get</code> / <code>set</code> / <code>dp</code> + <code>DataProviderKey</code> (static paths only)</td>
|
|
32
|
+
</tr>
|
|
33
|
+
<tr>
|
|
34
|
+
<td>Reactive Lit template</td>
|
|
35
|
+
<td><code>sub(key)</code> or <code>@subscribe</code></td>
|
|
36
|
+
</tr>
|
|
37
|
+
<tr>
|
|
38
|
+
<td>Read component state from store</td>
|
|
39
|
+
<td><code>@subscribe</code> + <code>DataProviderKey<T, U></code> + <code>@state</code></td>
|
|
40
|
+
</tr>
|
|
41
|
+
<tr>
|
|
42
|
+
<td>Inherit ancestor attributes</td>
|
|
43
|
+
<td><code>@ancestorAttribute</code></td>
|
|
44
|
+
</tr>
|
|
45
|
+
<tr>
|
|
46
|
+
<td>Write from component state</td>
|
|
47
|
+
<td><code>@publish</code></td>
|
|
48
|
+
</tr>
|
|
49
|
+
<tr>
|
|
50
|
+
<td>React to assignments</td>
|
|
51
|
+
<td><code>@handle</code></td>
|
|
52
|
+
</tr>
|
|
53
|
+
<tr>
|
|
54
|
+
<td>HTTP GET</td>
|
|
55
|
+
<td><code>@get</code> + <code>Endpoint</code>, or <code>sonic-list</code> / <code>sonic-queue</code> with <code>fetch</code></td>
|
|
56
|
+
</tr>
|
|
57
|
+
<tr>
|
|
58
|
+
<td>HTTP POST (body from store)</td>
|
|
59
|
+
<td><code>@post</code> + <code>Endpoint</code> + body <code>DataProviderKey</code></td>
|
|
60
|
+
</tr>
|
|
61
|
+
<tr>
|
|
62
|
+
<td>HTTP PUT / PATCH (body from store)</td>
|
|
63
|
+
<td><code>@put</code> / <code>@patch</code> — same model as <code>@post</code></td>
|
|
64
|
+
</tr>
|
|
65
|
+
<tr>
|
|
66
|
+
<td>Forms</td>
|
|
67
|
+
<td><code>formDataProvider</code> + <code>name</code> on fields</td>
|
|
68
|
+
</tr>
|
|
69
|
+
<tr>
|
|
70
|
+
<td>Offline doc demos</td>
|
|
71
|
+
<td><code>serviceURL="/docs-mock-api"</code> — <a href="../_misc/docs-mock-api.html#docs-mock-api">Local API demos</a></td>
|
|
72
|
+
</tr>
|
|
73
|
+
</tbody></table>
|
|
74
|
+
<p>Skill: <code>concorde-get-set-dp</code> in the package <code>ai/</code> folder.</p>
|
|
75
|
+
<h2 id="dataproviderkey">DataProviderKey</h2>
|
|
76
|
+
<pre><code class="language-typescript">import { DataProviderKey } from "@supersoniks/concorde/dataProviderKey";
|
|
77
|
+
import { dp, get, set } from "@supersoniks/concorde/utils";
|
|
78
|
+
|
|
79
|
+
const cartKey = new DataProviderKey&lt;{ items: string[] }&gt;("cart");
|
|
80
|
+
|
|
81
|
+
set(cartKey, { items: [] });
|
|
82
|
+
dp(cartKey.items).set(["a", "b"]);
|
|
83
|
+
get(cartKey);
|
|
84
|
+
</code></pre>
|
|
85
|
+
<p>Dynamic paths (<code>users.${userId}</code>) → decorators or <code>sub()</code> — not <code>get("users.${id}")</code> in imperative code. Resolution rules: <a href="../_misc/dynamic-path.html#dynamic-path">Dynamic path placeholders</a>.</p>
|
|
86
|
+
<p><a href="../_misc/dataProviderKey.html#dataProviderKey">DataProviderKey</a></p>
|
|
87
|
+
<h2 id="decorators">Decorators</h2>
|
|
88
|
+
<table>
|
|
89
|
+
<thead>
|
|
90
|
+
<tr>
|
|
91
|
+
<th>Decorator</th>
|
|
92
|
+
<th>Role</th>
|
|
93
|
+
</tr>
|
|
94
|
+
</thead>
|
|
95
|
+
<tbody><tr>
|
|
96
|
+
<td><code>@subscribe</code></td>
|
|
97
|
+
<td>Read-only property from store — <a href="../_getting-started/my-first-component.html#my-first-component">data configuration</a> (type + key + scope)</td>
|
|
98
|
+
</tr>
|
|
99
|
+
<tr>
|
|
100
|
+
<td><code>@publish</code></td>
|
|
101
|
+
<td>Push property writes to store</td>
|
|
102
|
+
</tr>
|
|
103
|
+
<tr>
|
|
104
|
+
<td><code>@handle</code></td>
|
|
105
|
+
<td>Method called on assignment</td>
|
|
106
|
+
</tr>
|
|
107
|
+
<tr>
|
|
108
|
+
<td><code>@ancestorAttribute</code></td>
|
|
109
|
+
<td>Copy ancestor HTML attribute onto property</td>
|
|
110
|
+
</tr>
|
|
111
|
+
<tr>
|
|
112
|
+
<td><code>@get</code></td>
|
|
113
|
+
<td>HTTP GET into <code>ApiResult&lt;T&gt;</code></td>
|
|
114
|
+
</tr>
|
|
115
|
+
<tr>
|
|
116
|
+
<td><code>@post</code></td>
|
|
117
|
+
<td>HTTP POST into <code>ApiResult&lt;T&gt;</code> (body from a publisher)</td>
|
|
118
|
+
</tr>
|
|
119
|
+
<tr>
|
|
120
|
+
<td><code>@put</code> / <code>@patch</code></td>
|
|
121
|
+
<td>HTTP PUT / PATCH into <code>ApiResult&lt;T&gt;</code></td>
|
|
122
|
+
</tr>
|
|
123
|
+
</tbody></table>
|
|
124
|
+
<p>Walkthrough: <a href="../_getting-started/my-first-component.html#my-first-component">My first component</a></p>
|
|
125
|
+
<h2 id="http-and-lists">HTTP and lists</h2>
|
|
126
|
+
<ul>
|
|
127
|
+
<li><a href="../_decorators/get.html#get">@get</a> — single GET on a component</li>
|
|
128
|
+
<li><a href="../_decorators/post.html#post">@post</a> — POST with body read from a <code>DataProviderKey</code></li>
|
|
129
|
+
<li><a href="../_decorators/put.html#put">@put</a> · <a href="../_decorators/patch.html#patch">@patch</a> — PUT / PATCH (same options as <code>@post</code>)</li>
|
|
130
|
+
<li><a href="../../core/components/functional/list/list.html#list">List</a> — <code>fetch</code> + <code>key="data"</code> + <code>/docs-mock-api/api/users</code></li>
|
|
131
|
+
<li><a href="../../core/components/functional/queue/queue.html#queue">Queue</a> — lazy <code>offset=$offset&per_page=$limit</code> + optional <code>dataFilterProvider</code> (form → query)</li>
|
|
132
|
+
</ul>
|
|
133
|
+
<h2 id="starter-kit">Starter kit</h2>
|
|
134
|
+
<pre><code class="language-bash">npx @supersoniks/create-concorde-ts-starter my-app
|
|
135
|
+
</code></pre>
|
|
136
|
+
<p>Interactive routes mirror these patterns (<code>/concepts/*</code>, <code>/demo/*</code>).</p>
|
|
137
|
+
<h2 id="legacy-integration">Legacy integration</h2>
|
|
138
|
+
<table>
|
|
139
|
+
<thead>
|
|
140
|
+
<tr>
|
|
141
|
+
<th>Topic</th>
|
|
142
|
+
<th>Page</th>
|
|
143
|
+
</tr>
|
|
144
|
+
</thead>
|
|
145
|
+
<tbody><tr>
|
|
146
|
+
<td><code>Subscriber</code> / <code>Fetcher</code> mixins on app code</td>
|
|
147
|
+
<td><a href="./subscriber.html#subscriber">Legacy: Subscriber mixin</a>, <a href="../_getting-started/my-first-subscriber.html#my-first-subscriber">Legacy: My first subscriber</a></td>
|
|
148
|
+
</tr>
|
|
149
|
+
<tr>
|
|
150
|
+
<td><code>data-bind</code> HTML (plain HTML hosts)</td>
|
|
151
|
+
<td><a href="../_misc/html-integration.html#html-integration">HTML integration</a> — doc demos use Lit in <code>src/docs/example/</code></td>
|
|
152
|
+
</tr>
|
|
153
|
+
<tr>
|
|
154
|
+
<td><code>@onAssign</code></td>
|
|
155
|
+
<td><a href="../_decorators/on-assign.html#on-assign">@onAssign</a> (prefer <code>@handle</code>)</td>
|
|
156
|
+
</tr>
|
|
157
|
+
<tr>
|
|
158
|
+
<td><code>sonic-fetch</code> alone</td>
|
|
159
|
+
<td><a href="../../core/components/functional/fetch/fetch.html#fetch">Fetch</a></td>
|
|
160
|
+
</tr>
|
|
161
|
+
</tbody></table>
|
|
162
|
+
|
|
163
|
+
</article>
|
|
164
|
+
</main>
|
|
165
|
+
</body>
|
|
166
|
+
</html>
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="fr" data-crawl-url="https://concorde.supersoniks.org/crawl/docs/_core-concept/overview.html" data-doc-id="docs/_core-concept/overview">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
+
<title>lit + tailwind + vite — Concorde</title>
|
|
7
|
+
<meta name="description" content="Some notes for an overview of Concorde's functioning">
|
|
8
|
+
<meta name="keywords" content="Concorde, supersoniks, docs/_core-concept/overview, overview, lit + tailwind + vite, concept, DataProvider, custom elements, reactive properties">
|
|
9
|
+
<meta name="concorde-doc-id" content="docs/_core-concept/overview">
|
|
10
|
+
<link rel="canonical" href="https://concorde.supersoniks.org/crawl/docs/_core-concept/overview.html">
|
|
11
|
+
</head>
|
|
12
|
+
<body>
|
|
13
|
+
<header>
|
|
14
|
+
<p><a href="../../index.html">Concorde documentation (crawl)</a> · <a href="https://concorde.supersoniks.org/#docs/_core-concept/overview.md/overview" rel="nofollow">interactive version</a></p>
|
|
15
|
+
</header>
|
|
16
|
+
<main>
|
|
17
|
+
<article>
|
|
18
|
+
<p class="doc-lead" id="doc-summary"><strong>Concorde concept — lit + tailwind + vite</strong>. Some notes for an overview of Concorde's functioning <span>Doc ID: <code>docs/_core-concept/overview</code>. Keywords: Concorde, supersoniks, docs/_core-concept/overview, overview, lit + tailwind + vite, concept, DataProvider, custom elements, reactive properties. URL: <a href="https://concorde.supersoniks.org/crawl/docs/_core-concept/overview.html">https://concorde.supersoniks.org/crawl/docs/_core-concept/overview.html</a>.</span></p>
|
|
19
|
+
<h1 id="lit--tailwind--vite">lit + tailwind + vite</h1>
|
|
20
|
+
<p><strong>Some notes for an overview of Concorde's functioning</strong></p>
|
|
21
|
+
<h2 id="standard-web-components">Standard Web components</h2>
|
|
22
|
+
<p>A web component is simply a <strong>custom HTML element</strong> created using web standards:</p>
|
|
23
|
+
<p><strong>web component</strong> = <a href="https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_custom_elements">Custom Elements</a> + <a href="https://developer.mozilla.org/fr/docs/Web/Web_Components/Using_shadow_DOM">shadowDom</a> + <a href="https://developer.mozilla.org/fr/docs/Web/HTML/Element/template">HTML templates</a></p>
|
|
24
|
+
<h2 id="lit-library">Lit Library</h2>
|
|
25
|
+
<p>Concorde components are written using the lightweight Lit library: <a href="https://lit.dev/">https://lit.dev/</a>.</p>
|
|
26
|
+
<p>A good portion of the elements documented on the Lit website are standard JavaScript concepts (e.g., <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes#mix-ins">mixins</a>, <a href="https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Template_literals#gabarits_%C3%A9tiquet%C3%A9s">tagged template literals</a>).</p>
|
|
27
|
+
<p>The <strong>library simplifies the writing of web components</strong> by automating certain tasks:</p>
|
|
28
|
+
<ul>
|
|
29
|
+
<li>Creation of an <strong>open mode shadow DOM</strong> (the component is accessible from the outside via its shadow root property).</li>
|
|
30
|
+
<li><a href="https://lit.dev/docs/components/rendering/">Rendering function</a> based on <a href="https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Template_literals#gabarits_%C3%A9tiquet%C3%A9s">tagged template literals</a></li>
|
|
31
|
+
<li><a href="https://lit.dev/docs/components/properties/">Reactive properties</a> that trigger rendering when modified.</li>
|
|
32
|
+
</ul>
|
|
33
|
+
<p>Our use of Lit rarely goes beyond this <a href="https://lit.dev/playground/#sample=examples/hello-world">hello world</a></p>
|
|
34
|
+
<h2 id="typescript-language">Typescript Language</h2>
|
|
35
|
+
<p>We write the components in <a href="https://www.typescriptlang.org/docs/handbook/typescript-in-5-minutes.html">TypeScript</a>, which is then compiled into JS.</p>
|
|
36
|
+
<p>Static and inferred typing provides stronger validation of the program's functioning during compilation.
|
|
37
|
+
However, we often use the "any" type due to time constraints.</p>
|
|
38
|
+
<p>Lit uses TypeScript to simplify development through metadata:</p>
|
|
39
|
+
<ul>
|
|
40
|
+
<li>Simplified declaration of <code>custom elements</code> via @customElement</li>
|
|
41
|
+
<li>Generation of <code>reactive properties</code> via @property.</li>
|
|
42
|
+
</ul>
|
|
43
|
+
<p>☢️<strong>Warning</strong>:</p>
|
|
44
|
+
<ul>
|
|
45
|
+
<li>During development, we operate in interpreted mode, which is faster but allows errors that won't pass during the build.</li>
|
|
46
|
+
<li>It is important to <strong>build a distribution before pushing the code</strong> to ensure everything is fine.</li>
|
|
47
|
+
</ul>
|
|
48
|
+
<h2 id="compatibility-with-classic-js-libraries">Compatibility with Classic JS Libraries</h2>
|
|
49
|
+
<p>Compatibility issues may arise when using JS libraries, particularly regarding DOM traversal.
|
|
50
|
+
This is because these libraries are blocked from traversing the DOM due to the presence of the shadow DOM.
|
|
51
|
+
Here are some examples of things that may cause problems:</p>
|
|
52
|
+
<ul>
|
|
53
|
+
<li>Latest FontAwesome in SVG mode, icons are not replaced</li>
|
|
54
|
+
<li>Libraries associated with jQuery</li>
|
|
55
|
+
<li>document.getElementById</li>
|
|
56
|
+
<li>...</li>
|
|
57
|
+
</ul>
|
|
58
|
+
<h2 id="topics-to-explore-for-further-learning">Topics to Explore for Further Learning</h2>
|
|
59
|
+
<p><a href="../_getting-started/create-a-component.html#create-a-component">🧱 Creating components</a></p>
|
|
60
|
+
<p><a href="../_getting-started/theming.html#theming">🎨 Adding styles</a></p>
|
|
61
|
+
<p><a href="../_getting-started/pubsub.html#pubsub">🥨 Sharing data</a></p>
|
|
62
|
+
|
|
63
|
+
</article>
|
|
64
|
+
</main>
|
|
65
|
+
</body>
|
|
66
|
+
</html>
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="fr" data-crawl-url="https://concorde.supersoniks.org/crawl/docs/_core-concept/subscriber.html" data-doc-id="docs/_core-concept/subscriber">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
+
<title>Legacy: Subscriber mixin — Concorde</title>
|
|
7
|
+
<meta name="description" content="> New app components: My first component and Data flow — extend LitElement with decorators (@subscribe, @ancestorAttribute, …). This mixin remains in core components (sonic-list, sonic-fetch, …) and l">
|
|
8
|
+
<meta name="keywords" content="Concorde, supersoniks, docs/_core-concept/subscriber, subscriber, Legacy: Subscriber mixin, concept, DataProvider, LitElement, @subscribe, @ancestorAttribute, sonic-list, sonic-fetch, dataProvider, subDataProvider = 'address.of.my.data', props">
|
|
9
|
+
<meta name="concorde-doc-id" content="docs/_core-concept/subscriber">
|
|
10
|
+
<link rel="canonical" href="https://concorde.supersoniks.org/crawl/docs/_core-concept/subscriber.html">
|
|
11
|
+
</head>
|
|
12
|
+
<body>
|
|
13
|
+
<header>
|
|
14
|
+
<p><a href="../../index.html">Concorde documentation (crawl)</a> · <a href="https://concorde.supersoniks.org/#docs/_core-concept/subscriber.md/subscriber" rel="nofollow">interactive version</a></p>
|
|
15
|
+
</header>
|
|
16
|
+
<main>
|
|
17
|
+
<article>
|
|
18
|
+
<p class="doc-lead" id="doc-summary"><strong>Concorde concept — Legacy: Subscriber mixin</strong>. > New app components: My first component and Data flow — extend LitElement with decorators (@subscribe, @ancestorAttribute, …). This mixin remains in core components (sonic-list, sonic-fetch, …) and l <span>Doc ID: <code>docs/_core-concept/subscriber</code>. Keywords: Concorde, supersoniks, docs/_core-concept/subscriber, subscriber, Legacy: Subscriber mixin, concept, DataProvider, LitElement, @subscribe, @ancestorAttribute, sonic-list, sonic-fetch, dataProvider, subDataProvider = 'address.of.my.data', props. URL: <a href="https://concorde.supersoniks.org/crawl/docs/_core-concept/subscriber.html">https://concorde.supersoniks.org/crawl/docs/_core-concept/subscriber.html</a>.</span></p>
|
|
19
|
+
<h1 id="legacy-subscriber-mixin">Legacy: Subscriber mixin</h1>
|
|
20
|
+
<blockquote>
|
|
21
|
+
<p><strong>New app components:</strong> <a href="../_getting-started/my-first-component.html#my-first-component">My first component</a> and <a href="./dataFlow.html#dataFlow">Data flow</a> — extend <code>LitElement</code> with decorators (<code>@subscribe</code>, <code>@ancestorAttribute</code>, …). This mixin remains in <strong>core</strong> components (<code>sonic-list</code>, <code>sonic-fetch</code>, …) and <a href="../_getting-started/my-first-subscriber.html#my-first-subscriber">legacy tutorials</a>.</p>
|
|
22
|
+
</blockquote>
|
|
23
|
+
<p>The Subscriber mixin was commonly extended by Concorde core components and older destination components. Pure UI components usually don't extend it, especially those outside of form components.</p>
|
|
24
|
+
<h2 id="dataprovider-attribute-automatic-filling-of-subscriber-properties">DataProvider Attribute: Automatic Filling of Subscriber Properties</h2>
|
|
25
|
+
<p>Upon being added to the DOM (connectedCallback), subscribers search for the first occurrence of the <code>dataProvider</code> attribute in their parent's HTML structure.</p>
|
|
26
|
+
<p>The value of this attribute is the DataProvider path (see <a href="./dataFlow.html#dataFlow">Data flow</a> and <a href="../_misc/dataProviderKey.html#dataProviderKey">DataProviderKey</a>; legacy API: <a href="../_getting-started/pubsub.html#pubsub">Sharing Data</a>).</p>
|
|
27
|
+
<p>The subscriber then subscribes to the publisher as a data template to be filled.</p>
|
|
28
|
+
<p>The reactive properties of the component reflect in real-time the properties with the same name in the publisher.</p>
|
|
29
|
+
<p>This functionality is commonly used in the generic components <a href="../../core/components/functional/fetch/fetch.html#fetch">fetch</a>, <a href="../../core/components/functional/queue/queue.html#queue">queue</a>, and <a href="../../core/components/functional/list/list.html#list">list</a>.</p>
|
|
30
|
+
<p>If the subscriber is inside another subscriber, it can subscribe to a data of its parent using the attribute <code>subDataProvider = 'address.of.my.data'</code> instead of the parent's data. This allows for dynamic behavior.</p>
|
|
31
|
+
<h2 id="automated-translation">Automated Translation</h2>
|
|
32
|
+
<p>In a similar manner, searching for ancestor attributes can be used to configure automatic translation for any property starting with "wording" and ending with a label identifier recognized by the wordingProvider API.</p>
|
|
33
|
+
<p>Normally, this API is globally configured and not within the component. Therefore, remember to prefix translatable label identifiers present in the ticketing system, for example, with "wording".</p>
|
|
34
|
+
<h2 id="reactive-property-props">Reactive Property <code>props</code></h2>
|
|
35
|
+
<p>The value of this property can be provided as a JSON object or any other value. This value is then assigned to the associated publisher via the <code>dataProvider</code> attribute. As a result, the reactive properties of all subscribers associated with the same <code>dataProvider</code> are filled as mentioned above.</p>
|
|
36
|
+
<h2 id="disabling-automatic-filling-of-reactive-properties">Disabling Automatic Filling of Reactive Properties</h2>
|
|
37
|
+
<p>It is possible to disable the automatic filling of reactive properties in a particular component. To do so, set the variable <code>noAutoFill = true</code> in the component's class. However, the reactive property <code>props</code> will still be updated.</p>
|
|
38
|
+
<p>For example, <code>sonic-subscriber</code> and <code>sonic-fetch</code> have this attribute because they do not have reactive properties.</p>
|
|
39
|
+
<p><strong>☢ CAUTION:</strong> When creating an object of type Subscriber or Fetcher, make sure to use the mixins and not directly extend the concrete fetch component (<code>sonic-fetch</code>) and subscriber component (<code>sonic-subscriber</code>). This is because the <code>noAutofill = true</code> attribute is set in those components.</p>
|
|
40
|
+
<p><strong>TIPS:</strong>
|
|
41
|
+
If you disable automatic filling, you will likely make the rendering dynamic by writing expressions like <code>this.props.my.subproperty</code>. If <code>props</code> is updated, the rendering will be triggered. However, if <code>this.props.my.subproperty</code> is directly modified, the rendering will not be triggered. To achieve more reactivity, you can enable rendering when any subproperty is modified. Simply set the variable <code>renderOnPropsInternalChange = true</code> in the class that implements the corresponding mixin.</p>
|
|
42
|
+
<h2 id="data-binding">Data Binding</h2>
|
|
43
|
+
<p>Suppose that:</p>
|
|
44
|
+
<ul>
|
|
45
|
+
<li>You have a subscriber subscribed to a publisher via its <code>dataProvider</code> attribute.</li>
|
|
46
|
+
<li>The published data has the following structure:</li>
|
|
47
|
+
</ul>
|
|
48
|
+
<pre><code class="language-javascript">{"img": { "avatar": "my-avatar.jpg", "caption": "look at my smile" }, "email": "an.email@example.com" }
|
|
49
|
+
</code></pre>
|
|
50
|
+
<ul>
|
|
51
|
+
<li>We want to keep the display of an image and its <code>title</code> attribute up to date, as well as a "contact" button to email the person in the photo. The content of the subscriber could be as follows:</li>
|
|
52
|
+
</ul>
|
|
53
|
+
<p>In a <strong>Lit</strong> app, use the same data with <a href="../_getting-started/my-first-component.html#my-first-component">data configuration</a> (<code>@subscribe</code> + <code>DataProviderKey</code>) on a small row component — see <code>docs-user</code> in <code>src/docs/example/users.ts</code>.</p>
|
|
54
|
+
<p>For <strong>HTML-only</strong> embedding (no Lit), attribute binding is described in <a href="../_misc/html-integration.html#html-integration">HTML integration</a> and in the Legacy <a href="./subscriber.html#subscriber">Subscriber mixin</a> pages.</p>
|
|
55
|
+
<p>This pattern also illustrates:</p>
|
|
56
|
+
<ul>
|
|
57
|
+
<li>Binding to subproperties using dot syntax, as done for the <code>src</code> attribute of the <code>img</code> tag.</li>
|
|
58
|
+
<li>Using a simple expression to include the property within a string, as in creating a <code>mailto</code> link.</li>
|
|
59
|
+
<li>Using formatting functions, as in the <code>title</code> attribute of the <code>img</code> tag. You can find (and add) formatting functions in the <code>core/utils/Format.ts</code> file.</li>
|
|
60
|
+
<li>Writing for properties that are in camel case. Convert everything to lowercase and add hyphens. Note that <code>innerHTML</code> (or <code>outerHTML</code>) is a special case where no hyphens are added between each letter.</li>
|
|
61
|
+
</ul>
|
|
62
|
+
<p><strong>Note:</strong> Data binding implies that updating the <code>img.src</code> data via the publisher will change the photo without any additional calls.</p>
|
|
63
|
+
<p><strong>Special Variables:</strong></p>
|
|
64
|
+
<ul>
|
|
65
|
+
<li><code>_self_</code> targets the root of the data. This is useful, for example, when the data is a pure string.</li>
|
|
66
|
+
<li><code>_parent_</code> targets the parent publisher of the current publisher, if any. For example, the subscribers of lists have the complete data of the list as their parent.</li>
|
|
67
|
+
<li><code>_metadata_</code> is only used in the case of <em>sonic-list</em> at the moment. In a simple list, <code>_metadata_</code> see the (list)[] component for further details</li>
|
|
68
|
+
</ul>
|
|
69
|
+
<p><strong>Disabling this functionality:</strong>
|
|
70
|
+
You can disable data binding if it is not needed by calling <code>DataBinding.disable()</code>.</p>
|
|
71
|
+
|
|
72
|
+
</article>
|
|
73
|
+
</main>
|
|
74
|
+
</body>
|
|
75
|
+
</html>
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="fr" data-crawl-url="https://concorde.supersoniks.org/crawl/docs/_decorators/ancestor-attribute.html" data-doc-id="docs/_decorators/ancestor-attribute">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
+
<title>@ancestorAttribute — Concorde</title>
|
|
7
|
+
<meta name="description" content="The @ancestorAttribute decorator automatically injects the value of an ancestor's attribute into a class property at the time of connectedCallback.">
|
|
8
|
+
<meta name="keywords" content="Concorde, supersoniks, docs/_decorators/ancestor-attribute, ancestor-attribute, @ancestorAttribute, decorator, ancestorAttribute, connectedCallback, HTML.getAncestorAttributeValue, dataProvider, testAttribute, dynamic: false, formDataProvider, wordingProvider">
|
|
9
|
+
<meta name="concorde-doc-id" content="docs/_decorators/ancestor-attribute">
|
|
10
|
+
<link rel="canonical" href="https://concorde.supersoniks.org/crawl/docs/_decorators/ancestor-attribute.html">
|
|
11
|
+
</head>
|
|
12
|
+
<body>
|
|
13
|
+
<header>
|
|
14
|
+
<p><a href="../../index.html">Concorde documentation (crawl)</a> · <a href="https://concorde.supersoniks.org/#docs/_decorators/ancestor-attribute.md/ancestor-attribute" rel="nofollow">interactive version</a></p>
|
|
15
|
+
</header>
|
|
16
|
+
<main>
|
|
17
|
+
<article>
|
|
18
|
+
<p class="doc-lead" id="doc-summary"><strong>Concorde decorator — @ancestorAttribute</strong>. The @ancestorAttribute decorator automatically injects the value of an ancestor's attribute into a class property at the time of connectedCallback. <span>Doc ID: <code>docs/_decorators/ancestor-attribute</code>. Keywords: Concorde, supersoniks, docs/_decorators/ancestor-attribute, ancestor-attribute, @ancestorAttribute, decorator, ancestorAttribute, connectedCallback, HTML.getAncestorAttributeValue, dataProvider, testAttribute, dynamic: false, formDataProvider, wordingProvider. URL: <a href="https://concorde.supersoniks.org/crawl/docs/_decorators/ancestor-attribute.html">https://concorde.supersoniks.org/crawl/docs/_decorators/ancestor-attribute.html</a>.</span></p>
|
|
19
|
+
<h1 id="ancestorattribute">@ancestorAttribute</h1>
|
|
20
|
+
<p>The <code>@ancestorAttribute</code> decorator automatically injects the value of an ancestor's attribute into a class property at the time of <code>connectedCallback</code>.</p>
|
|
21
|
+
<h2 id="principle">Principle</h2>
|
|
22
|
+
<p>This decorator uses <code>HTML.getAncestorAttributeValue</code> to traverse up the DOM tree from the current element and find the first ancestor that has the specified attribute. The value of this attribute is then assigned to the decorated property.</p>
|
|
23
|
+
<h2 id="usage">Usage</h2>
|
|
24
|
+
<h3 id="import">Import</h3>
|
|
25
|
+
<pre><code class="language-typescript">import { ancestorAttribute } from "@supersoniks/concorde/decorators";
|
|
26
|
+
</code></pre>
|
|
27
|
+
<h3 id="basic-example">Basic example</h3>
|
|
28
|
+
<p>The component reads <code>dataProvider</code> and <code>testAttribute</code> from its ancestor wrapper. By default (<code>dynamic: false</code>), values are read once at connect.</p>
|
|
29
|
+
<pre><code class="language-typescript">import { html, LitElement } from "lit";
|
|
30
|
+
import { customElement } from "lit/decorators.js";
|
|
31
|
+
import { ancestorAttribute } from "@supersoniks/concorde/decorators";
|
|
32
|
+
|
|
33
|
+
@customElement("demo-ancestor-attribute")
|
|
34
|
+
export class DemoAncestorAttribute extends LitElement {
|
|
35
|
+
@ancestorAttribute("dataProvider")
|
|
36
|
+
dataProvider: string | null = null;
|
|
37
|
+
|
|
38
|
+
@ancestorAttribute("testAttribute")
|
|
39
|
+
testAttribute: string | null = null;
|
|
40
|
+
|
|
41
|
+
render() {
|
|
42
|
+
return html`
|
|
43
|
+
<p>dataProvider: <strong>${this.dataProvider ?? "null"}</strong></p>
|
|
44
|
+
<p>testAttribute: <strong>${this.testAttribute ?? "null"}</strong></p>
|
|
45
|
+
`;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
</code></pre>
|
|
49
|
+
<pre><code><div dataProvider="demoDataProvider" testAttribute="test-value-123">
|
|
50
|
+
<docs-demo-sources for="demo-ancestor-attribute"></docs-demo-sources>
|
|
51
|
+
<demo-ancestor-attribute></demo-ancestor-attribute>
|
|
52
|
+
</div>
|
|
53
|
+
</code></pre>
|
|
54
|
+
<h2 id="use-cases">Use cases</h2>
|
|
55
|
+
<p>This decorator is particularly useful for:</p>
|
|
56
|
+
<ul>
|
|
57
|
+
<li><strong>Retrieving the <code>dataProvider</code></strong> from an ancestor without having to pass it explicitly</li>
|
|
58
|
+
<li><strong>Retrieving the <code>formDataProvider</code></strong> in form components</li>
|
|
59
|
+
<li><strong>Retrieving the <code>wordingProvider</code></strong> for translation</li>
|
|
60
|
+
<li><strong>Retrieving any other attribute</strong> defined on an ancestor</li>
|
|
61
|
+
</ul>
|
|
62
|
+
<h2 id="behavior">Behavior</h2>
|
|
63
|
+
<ul>
|
|
64
|
+
<li>The search starts from the current element and traverses up the DOM tree</li>
|
|
65
|
+
<li>The injection happens automatically at the time of <code>connectedCallback</code></li>
|
|
66
|
+
<li>By default (<code>dynamic: false</code>), the value is read once at connect time and is not updated afterward</li>
|
|
67
|
+
<li>With <code>{ dynamic: true }</code>, the property stays in sync when:<ul>
|
|
68
|
+
<li>an ancestor <strong>changes</strong> the attribute value</li>
|
|
69
|
+
<li>a <strong>closer</strong> ancestor <strong>gains</strong> the attribute (that value wins)</li>
|
|
70
|
+
<li>the <strong>nearest</strong> ancestor <strong>loses</strong> the attribute (falls back to the next one up, or <code>null</code>)</li>
|
|
71
|
+
</ul>
|
|
72
|
+
</li>
|
|
73
|
+
<li>When <code>dynamic</code> is enabled, updates also propagate to <code>@subscribe</code> / <code>@bind</code> paths that depend on the decorated property (e.g. <code>${dataProvider}</code>)</li>
|
|
74
|
+
</ul>
|
|
75
|
+
<h3 id="dynamic-mode">Dynamic mode</h3>
|
|
76
|
+
<p>Use <code>{ dynamic: true }</code> when the decorated property must follow the DOM. With Lit, add <strong><code>@state()</code></strong> on the same property so template updates are visible when the observer assigns a new value.</p>
|
|
77
|
+
<p>The live demo below shows only the resolved attribute value — no store, no reparenting.</p>
|
|
78
|
+
<pre><code class="language-typescript">@customElement("demo-ancestor-attribute-dynamic")
|
|
79
|
+
export class DemoAncestorAttributeDynamic extends LitElement {
|
|
80
|
+
@ancestorAttribute("dataProvider", { dynamic: true })
|
|
81
|
+
@state()
|
|
82
|
+
dataProvider: string | null = null;
|
|
83
|
+
|
|
84
|
+
render() {
|
|
85
|
+
return html`
|
|
86
|
+
&lt;p&gt;Nearest ancestor: &lt;strong&gt;${this.dataProvider ?? "null"}&lt;/strong&gt;&lt;/p&gt;
|
|
87
|
+
`;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
</code></pre>
|
|
91
|
+
<p>Try in the demo:</p>
|
|
92
|
+
<ul>
|
|
93
|
+
<li><strong>parent-a</strong> / <strong>parent-b</strong> — change the value on the direct parent</li>
|
|
94
|
+
<li><strong>Remove parent attr</strong> — falls back to <strong>outer</strong></li>
|
|
95
|
+
<li><strong>Add closer</strong> — a wrapper with <code>from-closer</code> becomes the nearest ancestor</li>
|
|
96
|
+
<li><strong>Remove closer</strong> — back to parent or outer</li>
|
|
97
|
+
<li><strong>Remove outer attr</strong> — if parent has no attribute either, the child shows <code>null</code></li>
|
|
98
|
+
</ul>
|
|
99
|
+
<pre><code><docs-demo-sources for="demo-ancestor-attribute-dynamic-section"></docs-demo-sources>
|
|
100
|
+
<demo-ancestor-attribute-dynamic-section></demo-ancestor-attribute-dynamic-section>
|
|
101
|
+
</code></pre>
|
|
102
|
+
<p>Static mode (default) — read once at connect, no observer:</p>
|
|
103
|
+
<pre><code class="language-typescript">@ancestorAttribute("dataProvider")
|
|
104
|
+
dataProvider: string | null = null;
|
|
105
|
+
</code></pre>
|
|
106
|
+
<h2 id="notes">Notes</h2>
|
|
107
|
+
<ul>
|
|
108
|
+
<li>This decorator works with any component that has a <code>connectedCallback</code> method (such as <code>LitElement</code> or components extending <code>Subscriber</code>)</li>
|
|
109
|
+
<li>The search also traverses Shadow DOM if necessary</li>
|
|
110
|
+
<li>If multiple ancestors have the attribute, the closest one will be used</li>
|
|
111
|
+
</ul>
|
|
112
|
+
|
|
113
|
+
</article>
|
|
114
|
+
</main>
|
|
115
|
+
</body>
|
|
116
|
+
</html>
|