@supersoniks/concorde 4.9.1 → 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 +106 -106
- package/concorde-core.es.js +4 -7
- package/dist/concorde-core.bundle.js +106 -106
- package/dist/concorde-core.es.js +4 -7
- package/dist/docs-mock-api-sw.js +1 -0
- 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/utils/HTML.d.ts.map +1 -1
- package/docs/assets/{index-CZLTFws2.css → index-Bnp7gVaA.css} +1 -1
- package/docs/assets/{index-nkkwC13U.js → index-hElUgV9_.js} +505 -438
- 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 -2
- 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/get.md +47 -1
- package/docs/src/docs/search/docs-search.json +31 -1
- package/index.html +1 -0
- package/package.json +1 -1
- package/public/docs-mock-api-sw.js +1 -0
- 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/subscriber/ancestorAttribute.spec.ts +42 -0
- package/src/core/utils/HTML.ts +4 -5
- package/src/docs/search/docs-search.json +61 -1
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="fr" data-crawl-url="https://concorde.supersoniks.org/crawl/core/components/functional/router/router.html" data-doc-id="core/components/functional/router/router">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
+
<title>Router — Concorde</title>
|
|
7
|
+
<meta name="description" content="sonic-router watches document.location (pathname + hash) and renders the matching view.">
|
|
8
|
+
<meta name="keywords" content="Concorde, supersoniks, core/components/functional/router/router, router, Router, functional component, sonic-router, web component, document.location, .routes, .items, fallback, , pathname + hash, #home, #…/router.md/router, #…/router#home, href">
|
|
9
|
+
<meta name="concorde-doc-id" content="core/components/functional/router/router">
|
|
10
|
+
<link rel="canonical" href="https://concorde.supersoniks.org/crawl/core/components/functional/router/router.html">
|
|
11
|
+
</head>
|
|
12
|
+
<body>
|
|
13
|
+
<header>
|
|
14
|
+
<p><a href="../../../../index.html">Concorde documentation (crawl)</a> · <a href="https://concorde.supersoniks.org/#core/components/functional/router/router.md/router" rel="nofollow">interactive version</a></p>
|
|
15
|
+
</header>
|
|
16
|
+
<main>
|
|
17
|
+
<article>
|
|
18
|
+
<p class="doc-lead" id="doc-summary"><strong>Concorde functional component — Router</strong>. sonic-router watches document.location (pathname + hash) and renders the matching view. <span>Doc ID: <code>core/components/functional/router/router</code>. Keywords: Concorde, supersoniks, core/components/functional/router/router, router, Router, functional component, sonic-router, web component, document.location, .routes, .items, fallback, , pathname + hash, #home, #…/router.md/router, #…/router#home, href. URL: <a href="https://concorde.supersoniks.org/crawl/core/components/functional/router/router.html">https://concorde.supersoniks.org/crawl/core/components/functional/router/router.html</a>.</span></p>
|
|
19
|
+
<h1 id="router">Router</h1>
|
|
20
|
+
<p><strong>sonic-router</strong> watches <code>document.location</code> (pathname + hash) and renders the matching view.</p>
|
|
21
|
+
<p>From a <strong>Lit</strong> parent, pass a <strong><code>.routes</code></strong> map (property binding — same rule as <a href="../list/list.html#list"><code>.items</code> on list</a>): keys are path patterns, values are render functions. Use <strong><code>fallback</code></strong> when nothing matches.</p>
|
|
22
|
+
<p>Legacy HTML <strong><code><template data-route="…"></code></strong> remains for hosts without Lit — <a href="../../../../docs/_misc/html-integration.html#html-integration">HTML integration</a>.</p>
|
|
23
|
+
<h2 id="static-routes-no-parameters">Static routes (no parameters)</h2>
|
|
24
|
+
<p>Route keys are matched against <code>pathname + hash</code>. A simple hash route <code>#home</code> matches when the location contains that segment.</p>
|
|
25
|
+
<p>On the <strong>doc site</strong>, the page URL is already a hash (<code>../../../../…/router.html#router</code>). Demos append a <strong>second</strong> hash for in-page routes (<code>#…/router#home</code>), use <strong><code>href</code> + <code>autoActive="strict"</code></strong> on <code>sonic-button</code> for the active state, and <code>history.replaceState</code> on click so markdown is not reloaded (<code>setDocsDemoSubHash</code> in <code>src/docs/docs-location.ts</code>).</p>
|
|
26
|
+
<p><docs-lit-demo for="docs-router-basic-demo"></docs-lit-demo></p>
|
|
27
|
+
<pre><code class="language-typescript">@state()
|
|
28
|
+
private routes = {
|
|
29
|
+
"#home": () => html`<div>Home</div>`,
|
|
30
|
+
"#about": () => html`<div>About</div>`,
|
|
31
|
+
fallback: () => html`<div>Not found</div>`,
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
html`
|
|
35
|
+
<sonic-button href="#home">Home</sonic-button>
|
|
36
|
+
<sonic-router .routes=${this.routes}></sonic-router>
|
|
37
|
+
`;
|
|
38
|
+
</code></pre>
|
|
39
|
+
<table>
|
|
40
|
+
<thead>
|
|
41
|
+
<tr>
|
|
42
|
+
<th>Key</th>
|
|
43
|
+
<th>When it runs</th>
|
|
44
|
+
</tr>
|
|
45
|
+
</thead>
|
|
46
|
+
<tbody><tr>
|
|
47
|
+
<td><code>"#home"</code>, <code>"#about"</code>, …</td>
|
|
48
|
+
<td><code>RegExp</code> or <a href="https://www.npmjs.com/package/url-pattern">url-pattern</a> test succeeds on current location</td>
|
|
49
|
+
</tr>
|
|
50
|
+
<tr>
|
|
51
|
+
<td><strong><code>fallback</code></strong></td>
|
|
52
|
+
<td>No other route matched (not an attribute — a key on the same object)</td>
|
|
53
|
+
</tr>
|
|
54
|
+
</tbody></table>
|
|
55
|
+
<h2 id="routes-with-parameters">Routes with parameters</h2>
|
|
56
|
+
<p>Two styles (see <code>router.demo.ts</code> and <code>docs-router-params-demo</code>):</p>
|
|
57
|
+
<h3 id="url-pattern-name">Url-pattern (<code>:name</code>)</h3>
|
|
58
|
+
<p>Key uses <strong><code>:param</code></strong> segments. The render function receives an <strong>object</strong> <code>{ param: string }</code>.</p>
|
|
59
|
+
<p><docs-lit-demo for="docs-router-params-demo"></docs-lit-demo></p>
|
|
60
|
+
<pre><code class="language-typescript">"#couleur/:id": ({ id }) => html`<p>Colour id: ${id}</p>`,
|
|
61
|
+
</code></pre>
|
|
62
|
+
<h3 id="regexp-capturing-groups">RegExp (capturing groups)</h3>
|
|
63
|
+
<p>Key is a <strong>RegExp</strong> string with <code>(\d+)</code> / <code>(\w+)</code> groups. The render function receives an <strong>array</strong> of captured strings (in order).</p>
|
|
64
|
+
<pre><code class="language-typescript">"#products/(\\d+)/(\\w+)": ([productId, slug]) =>
|
|
65
|
+
html`<p>Product ${productId}, slug ${slug}</p>`,
|
|
66
|
+
</code></pre>
|
|
67
|
+
<p>With parameters you usually render data directly in Lit (<code>${id}</code>). The old <strong><code><template data-route></code> + <code>dataProviderExpression</code></strong> pattern scoped a <code>dataProvider</code> for <code>data-bind</code> / fetch children — prefer <strong><code>@subscribe</code></strong> or explicit props when using <code>.routes</code>.</p>
|
|
68
|
+
<h2 id="routes-binding"><code>.routes</code> binding</h2>
|
|
69
|
+
<p>Always use <strong><code>.routes=${…}</code></strong> in Lit templates: route handlers are functions and must be set as <strong>properties</strong>, not HTML attributes.</p>
|
|
70
|
+
<h2 id="optional-attributes">Optional attributes</h2>
|
|
71
|
+
<table>
|
|
72
|
+
<thead>
|
|
73
|
+
<tr>
|
|
74
|
+
<th>Attribute</th>
|
|
75
|
+
<th>Role</th>
|
|
76
|
+
</tr>
|
|
77
|
+
</thead>
|
|
78
|
+
<tbody><tr>
|
|
79
|
+
<td><strong><code>basePath</code></strong></td>
|
|
80
|
+
<td>Prefix for pattern matching (default allows optional leading segments)</td>
|
|
81
|
+
</tr>
|
|
82
|
+
<tr>
|
|
83
|
+
<td><strong><code>fallBackRoute</code></strong></td>
|
|
84
|
+
<td>If set and no template/route matches, navigates to this URL (redirect). Distinct from <strong><code>routes.fallback</code></strong> which only renders content</td>
|
|
85
|
+
</tr>
|
|
86
|
+
</tbody></table>
|
|
87
|
+
<h2 id="sonic-redirect"><code>sonic-redirect</code></h2>
|
|
88
|
+
<p>Separate component: redirect when data appears on a publisher (login steps, wizards). Not part of the <code>.routes</code> map.</p>
|
|
89
|
+
<pre><code><sonic-redirect to="./router.html#router#data-is-set" dataProvider="stupid-data-set-id" onData="theData"></sonic-redirect>
|
|
90
|
+
<div class="flex gap-2 mb-4" formDataProvider="stupid-data-set-id">
|
|
91
|
+
<sonic-button radio name="theData" value="Some Data" size="xs">
|
|
92
|
+
Enter data
|
|
93
|
+
</sonic-button>
|
|
94
|
+
<sonic-button radio name="theData" value="" href="javascript:history.back();" size="xs">
|
|
95
|
+
Delete the data and do a history.back()
|
|
96
|
+
</sonic-button>
|
|
97
|
+
</div>
|
|
98
|
+
</code></pre>
|
|
99
|
+
<p>Example: combine with <strong><code>.routes</code></strong> and <strong>submit</strong> for login / logout / profile steps.</p>
|
|
100
|
+
<h2 id="package-demo">Package demo</h2>
|
|
101
|
+
<p><code>sonic-router-demo</code> (<code>router.demo.ts</code>) — home, user profile (<code>#user/:id/:slug</code>), products RegExp, <strong>fallback</strong> 404.</p>
|
|
102
|
+
|
|
103
|
+
</article>
|
|
104
|
+
</main>
|
|
105
|
+
</body>
|
|
106
|
+
</html>
|
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="fr" data-crawl-url="https://concorde.supersoniks.org/crawl/core/components/functional/sdui/sdui.html" data-doc-id="core/components/functional/sdui/sdui">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
+
<title>SDUI — Concorde</title>
|
|
7
|
+
<meta name="description" content="SDUI stands for Server Driven User Interfaces.">
|
|
8
|
+
<meta name="keywords" content="Concorde, supersoniks, core/components/functional/sdui/sdui, sdui, SDUI, functional component, sonic-sdui, web component, Server Driven User Interfaces, props, contents">
|
|
9
|
+
<meta name="concorde-doc-id" content="core/components/functional/sdui/sdui">
|
|
10
|
+
<link rel="canonical" href="https://concorde.supersoniks.org/crawl/core/components/functional/sdui/sdui.html">
|
|
11
|
+
</head>
|
|
12
|
+
<body>
|
|
13
|
+
<header>
|
|
14
|
+
<p><a href="../../../../index.html">Concorde documentation (crawl)</a> · <a href="https://concorde.supersoniks.org/#core/components/functional/sdui/sdui.md/sdui" rel="nofollow">interactive version</a></p>
|
|
15
|
+
</header>
|
|
16
|
+
<main>
|
|
17
|
+
<article>
|
|
18
|
+
<p class="doc-lead" id="doc-summary"><strong>Concorde functional component — SDUI</strong>. SDUI stands for Server Driven User Interfaces. <span>Doc ID: <code>core/components/functional/sdui/sdui</code>. Keywords: Concorde, supersoniks, core/components/functional/sdui/sdui, sdui, SDUI, functional component, sonic-sdui, web component, Server Driven User Interfaces, props, contents. URL: <a href="https://concorde.supersoniks.org/crawl/core/components/functional/sdui/sdui.html">https://concorde.supersoniks.org/crawl/core/components/functional/sdui/sdui.html</a>.</span></p>
|
|
19
|
+
<h1 id="sdui">SDUI</h1>
|
|
20
|
+
<h2 id="what-is-sdui">What is SDUI?</h2>
|
|
21
|
+
<p>SDUI stands for <code>Server Driven User Interfaces</code>.
|
|
22
|
+
Basically, it generates a user interface based on a JSON SDUI Descriptor.</p>
|
|
23
|
+
<h3 id="subscriber-extension">Subscriber extension:</h3>
|
|
24
|
+
<p>SDUI extends the mixin <a href="../../../../docs/_core-concept/subscriber.html#subscriber">Subscriber</a>.
|
|
25
|
+
This means that you must set a dataProvider with an id pointing to the publisher that will hold your SDUI Descriptor.
|
|
26
|
+
This also means that it has a reactive property named <code>props</code> that you can set with the JSON SDUI Descriptor in order to configure it.</p>
|
|
27
|
+
<h3 id="fetcher-extension">Fetcher extension:</h3>
|
|
28
|
+
<p>SDUI extends the mixin Fetcher as <a href="../fetch/fetch.html#fetch">Fetch</a> and <a href="../list/list.html#list">List</a>.</p>
|
|
29
|
+
<p>In this case, it will parse the JSON coming from the request.
|
|
30
|
+
The JSON must comply with the SDUI descriptor format.</p>
|
|
31
|
+
<p>As a fetcher, invalidating the publisher or updating the endpoint will trigger a new fetch and update accordingly.</p>
|
|
32
|
+
<h3 id="rendering">Rendering:</h3>
|
|
33
|
+
<p>It has no shadowdom, and its display style is set to <code>contents</code>, so an empty SDUI has the fewest impact on the layout.</p>
|
|
34
|
+
<h2 id="sdui-descriptor">SDUI descriptor</h2>
|
|
35
|
+
<h3 id="typescript-definition">TypeScript definition:</h3>
|
|
36
|
+
<pre><code class="language-typescript">export type SDUIDescriptor = {
|
|
37
|
+
js?: Array&lt;string&gt;;
|
|
38
|
+
css?: Array&lt;string&gt;;
|
|
39
|
+
library?: Record&lt;string, SDUINode&gt;;
|
|
40
|
+
nodes?: Array&lt;SDUINode&gt;;
|
|
41
|
+
};
|
|
42
|
+
</code></pre>
|
|
43
|
+
<h3 id="meaning-of-the-keys">Meaning of the keys:</h3>
|
|
44
|
+
<ul>
|
|
45
|
+
<li><strong>js</strong>: An array of URLs pointing to JavaScript files to load.</li>
|
|
46
|
+
<li><strong>css</strong>: An array of URLs pointing to CSS files to load.</li>
|
|
47
|
+
<li><strong>library</strong>: A record of SDUINode definitions intended to be used as a model for other nodes. The keys of the record can be used as the libraryKey of the node. This node will then specialize the model with its own descriptor.</li>
|
|
48
|
+
<li><strong>nodes</strong>: An array of SDUINode descriptors. Each SDUINode will result in an HTMLElement added to the root of the component.</li>
|
|
49
|
+
</ul>
|
|
50
|
+
<h2 id="sduinode">SDUINode</h2>
|
|
51
|
+
<h3 id="descriptor">Descriptor</h3>
|
|
52
|
+
<p>An SDUINode represents an HTMLElement.</p>
|
|
53
|
+
<p>TypeScript definition:</p>
|
|
54
|
+
<pre><code class="language-typescript">export type SDUINode = {
|
|
55
|
+
markup?: string;
|
|
56
|
+
tagName?: string;
|
|
57
|
+
attributes?: Record&lt;string, string&gt;;
|
|
58
|
+
nodes?: Array&lt;SDUINode&gt;;
|
|
59
|
+
innerHTML?: string;
|
|
60
|
+
prefix?: string;
|
|
61
|
+
suffix?: string;
|
|
62
|
+
libraryKey?: string;
|
|
63
|
+
contentElementSelector?: string;
|
|
64
|
+
parentElementSelector?: string;
|
|
65
|
+
};
|
|
66
|
+
</code></pre>
|
|
67
|
+
<p>Summary of properties:</p>
|
|
68
|
+
<ul>
|
|
69
|
+
<li><strong>markup</strong>: Use it if you prefer to define your node entirely using an HTML string.</li>
|
|
70
|
+
<li><strong>tagName</strong>: The tag name of the HTML element.</li>
|
|
71
|
+
<li><strong>attributes</strong>: A string key/value pair storing each attribute name/value of the HTML element created.</li>
|
|
72
|
+
<li><strong>nodes</strong>: An array of SDUINode descriptors. The children of the HTMLElement are created this way.</li>
|
|
73
|
+
<li><strong>innerHTML</strong>: The inner HTML of the current node is defined here if needed.</li>
|
|
74
|
+
<li><strong>prefix</strong>: Use it if you want to wrap the component with some HTML string in conjunction with the suffix.</li>
|
|
75
|
+
<li><strong>suffix</strong>: Use it if you want to wrap the component with some HTML string in conjunction with the prefix.</li>
|
|
76
|
+
<li><strong>libraryKey</strong>: An identifier that points to an SDUINode to be used as a model for this node.</li>
|
|
77
|
+
<li><strong>contentElementSelector</strong>: For SDUINodes defined in the library only. It is a CSS selector that defines where child nodes are added.</li>
|
|
78
|
+
<li><strong>parentElementSelector</strong>: If the current node, as a future child, has a <code>parentElementSelector</code> attribute, it is added to the node corresponding to the associated CSS selector rather than directly to the element.</li>
|
|
79
|
+
</ul>
|
|
80
|
+
<h3 id="markup">Markup</h3>
|
|
81
|
+
<p>Use it if you prefer to define your node entirely using an HTML string.</p>
|
|
82
|
+
<pre><code><sonic-sdui
|
|
83
|
+
dataProvider="sdui-markup-example"
|
|
84
|
+
props='{
|
|
85
|
+
"nodes":[
|
|
86
|
+
{
|
|
87
|
+
"markup":"keep shouting <sonic-badge>foo</sonic-badge> <sonic-badge>bar</sonic-badge> !"
|
|
88
|
+
}
|
|
89
|
+
]}'
|
|
90
|
+
></sonic-sdui>
|
|
91
|
+
</code></pre>
|
|
92
|
+
<h3 id="tag-name">Tag name</h3>
|
|
93
|
+
<p>Here we use the field <code>tagName</code> of SDUINode to create an element with tag name <code>sonic-input</code>.</p>
|
|
94
|
+
<pre><code><sonic-sdui
|
|
95
|
+
dataProvider="sdui-tagName-example"
|
|
96
|
+
props='{
|
|
97
|
+
"nodes":[
|
|
98
|
+
{
|
|
99
|
+
"tagName":"sonic-input"
|
|
100
|
+
}
|
|
101
|
+
]}'
|
|
102
|
+
></sonic-sdui>
|
|
103
|
+
</code></pre>
|
|
104
|
+
<h3 id="attributes">Attributes</h3>
|
|
105
|
+
<p>A string key/value pair storing each attribute name/value of the HTML element created.
|
|
106
|
+
As no tag name is defined, a div element is created.
|
|
107
|
+
Here we define the style attribute to create a tiny red square.</p>
|
|
108
|
+
<pre><code><sonic-sdui
|
|
109
|
+
dataProvider="sdui-attributes-example"
|
|
110
|
+
props='{
|
|
111
|
+
"nodes":[{
|
|
112
|
+
"attributes":{
|
|
113
|
+
"style":"width:50px;height:10px;background:red;"
|
|
114
|
+
}
|
|
115
|
+
}]
|
|
116
|
+
}'
|
|
117
|
+
></sonic-sdui>
|
|
118
|
+
</code></pre>
|
|
119
|
+
<h3 id="nodes">Nodes</h3>
|
|
120
|
+
<p>Children of the current node can be added using the field <code>nodes</code> recursively.</p>
|
|
121
|
+
<pre><code><sonic-sdui
|
|
122
|
+
dataProvider="sdui-nodes-example"
|
|
123
|
+
props='{
|
|
124
|
+
"nodes":[{
|
|
125
|
+
"nodes":[
|
|
126
|
+
{"innerHTML":"A"},
|
|
127
|
+
{
|
|
128
|
+
"prefix":"B",
|
|
129
|
+
"nodes":[
|
|
130
|
+
{"innerHTML":"👉 B.1"},
|
|
131
|
+
{"innerHTML":"👉 B.2"}
|
|
132
|
+
]
|
|
133
|
+
}
|
|
134
|
+
]
|
|
135
|
+
}]
|
|
136
|
+
}'
|
|
137
|
+
></sonic-sdui>
|
|
138
|
+
</code></pre>
|
|
139
|
+
<h3 id="innerhtml">InnerHTML</h3>
|
|
140
|
+
<p>As no tag name is defined, a div element is created, and then we use <code>innerHTML</code> to add content to it.</p>
|
|
141
|
+
<pre><code><sonic-sdui
|
|
142
|
+
dataProvider="sdui-html-example"
|
|
143
|
+
props='{
|
|
144
|
+
"nodes":[{
|
|
145
|
+
"innerHTML":"keep shouting <sonic-badge>foo</sonic-badge> <sonic-badge>bar</sonic-badge> !"
|
|
146
|
+
}]
|
|
147
|
+
}'
|
|
148
|
+
></sonic-sdui>
|
|
149
|
+
</code></pre>
|
|
150
|
+
<h3 id="prefix-and-suffix">Prefix and suffix</h3>
|
|
151
|
+
<p>Use them if you want to wrap the component with some HTML string.</p>
|
|
152
|
+
<pre><code><sonic-sdui
|
|
153
|
+
dataProvider="sdui-prefixSuffix-example"
|
|
154
|
+
props='{
|
|
155
|
+
"nodes":[{
|
|
156
|
+
"prefix":"👇",
|
|
157
|
+
"suffix":"☝️",
|
|
158
|
+
"innerHTML":"The node content"
|
|
159
|
+
}]
|
|
160
|
+
}'
|
|
161
|
+
></sonic-sdui>
|
|
162
|
+
</code></pre>
|
|
163
|
+
<h3 id="library-key-and-contentelementselector">Library key and contentElementSelector</h3>
|
|
164
|
+
<p>The libraryKey of SDUINode is an identifier that points to an SDUINode description in the library to be used as a model for this node.</p>
|
|
165
|
+
<p>Note that the SDUI has a default library containing some basic component definitions useful for form declaration (see default-library.json).</p>
|
|
166
|
+
<p>This example uses the library key <code>submit</code> which points to a <code>sonic-submit</code> containing a button also coming from the library.</p>
|
|
167
|
+
<p>The element named <code>button</code> in the library is a <code>sonic-button</code> of type <code>success</code> containing a check icon as a prefix.</p>
|
|
168
|
+
<p>Since the <code>submit</code> library element contains an attribute <code>contentElementSelector</code> with the value <code>sonic-button</code>, the "injected content" is put inside the button.</p>
|
|
169
|
+
<p>We used <code>innerHTML</code> for the sake of simplicity, but you can use nodes to add any complex content.</p>
|
|
170
|
+
<pre><code><sonic-sdui dataProvider="sdui-library-example" props='
|
|
171
|
+
{
|
|
172
|
+
"nodes":[
|
|
173
|
+
{
|
|
174
|
+
"libraryKey":"submit",
|
|
175
|
+
"innerHTML":"Injected content"
|
|
176
|
+
}
|
|
177
|
+
]
|
|
178
|
+
}
|
|
179
|
+
'></sonic-sdui>
|
|
180
|
+
</code></pre>
|
|
181
|
+
<h3 id="parentelementselector">parentElementSelector</h3>
|
|
182
|
+
<p>This special field lets you inject the content at any place in the HTML flow already set inside the parent SDUI component by using a CSS selector.</p>
|
|
183
|
+
<p>⚠️ Note that it doesn't work with top-level nodes.</p>
|
|
184
|
+
<pre><code><sonic-sdui dataProvider="sdui-parentElementSelector-example" props='
|
|
185
|
+
{
|
|
186
|
+
"nodes":[
|
|
187
|
+
{
|
|
188
|
+
"nodes":[
|
|
189
|
+
{
|
|
190
|
+
"prefix":"👇 Selected parent element",
|
|
191
|
+
"suffix":"☝️ End of selected parent element",
|
|
192
|
+
"tagName":"span"
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
"parentElementSelector":"span",
|
|
196
|
+
"innerHTML":"Content having a parentElementSelector attribute"
|
|
197
|
+
}
|
|
198
|
+
]
|
|
199
|
+
}
|
|
200
|
+
]
|
|
201
|
+
}
|
|
202
|
+
'></sonic-sdui>
|
|
203
|
+
</code></pre>
|
|
204
|
+
<h3 id="fetch-example">Fetch example:</h3>
|
|
205
|
+
<pre><code><sonic-sdui dataProvider="sdui-fetch-example" endPoint="/src/core/components/functional/sdui/example.json"></sonic-sdui>
|
|
206
|
+
</code></pre>
|
|
207
|
+
<h2 id="transformers">Transformers:</h2>
|
|
208
|
+
<p>The transformers let you transform the structure of the SDUI Descriptor into a new one before parsing and rendering it.</p>
|
|
209
|
+
<p>To enable it, you must fill the <code>transformation</code> attribute of the component with a URL pointing to a Transform descriptor.</p>
|
|
210
|
+
<pre><code class="language-typescript">export type SDUITransformDescription = {
|
|
211
|
+
library?: Record&lt;string, SDUINode&gt;;
|
|
212
|
+
transforms: Array&lt;SDUITransformAction&gt;;
|
|
213
|
+
};
|
|
214
|
+
</code></pre>
|
|
215
|
+
<h3 id="the-library">The library:</h3>
|
|
216
|
+
<p>Each key of the library will be merged with the current library in the SDUI Descriptor, by replacing or creating items library key by key.</p>
|
|
217
|
+
<h3 id="the-transform-actions">The transform actions:</h3>
|
|
218
|
+
<p>Each transform represents an action that will be done on the SDUI descriptor before the creation of the entire UI.</p>
|
|
219
|
+
<pre><code class="language-typescript">export type SDUITransformAction = {
|
|
220
|
+
action: SDUITransformActionName;
|
|
221
|
+
patterns?: Array&lt;SDUINode&gt;;
|
|
222
|
+
after?: SDUINode;
|
|
223
|
+
before?: SDUINode;
|
|
224
|
+
in?: SDUINode;
|
|
225
|
+
ui?: SDUINode;
|
|
226
|
+
};
|
|
227
|
+
</code></pre>
|
|
228
|
+
<p>The action that will be done is a verb:</p>
|
|
229
|
+
<pre><code class="language-typescript">export type SDUITransformActionName = "remap" | "unwrap" | "wrap" | "delete" | "insert" | "move";
|
|
230
|
+
</code></pre>
|
|
231
|
+
<ul>
|
|
232
|
+
<li><strong>remap</strong>: The properties (tagName, innerHTML, etc.) of the targeted SDUINode will be created/changed according to their presence in the <code>ui</code> (SDUINode) property of the transformAction.</li>
|
|
233
|
+
<li><strong>unwrap</strong>: Replaces the targeted SDUINode in place with its children.</li>
|
|
234
|
+
<li><strong>wrap</strong>: Groups all SDUINodes targeted by the patterns into the new SDUINode described in the <code>ui</code> prop of the transformAction.</li>
|
|
235
|
+
<li><strong>delete</strong>: Deletes the targeted item.</li>
|
|
236
|
+
<li><strong>insert</strong>: Inserts a new SDUINode described by the <code>ui</code> prop into the flow. The position of insertion depends on the presence of the attributes <code>before</code>, <code>after</code>, <code>in</code>, which is a pattern to target an existing SDUINode.</li>
|
|
237
|
+
</ul>
|
|
238
|
+
<h2 id="misc-tricks">Misc Tricks:</h2>
|
|
239
|
+
<h3 id="sduikey">sduiKey</h3>
|
|
240
|
+
<p>This is an HTML attribute to set on the component if needed. In this case, the component will not treat its props value directly as an SDUI descriptor. Internally, it will basically extract the SDUIDescriptor by doing something like this: <code>const sduiDescriptor = this.props[this.sduikey]</code>.</p>
|
|
241
|
+
<h3 id="messagekey">messageKey</h3>
|
|
242
|
+
<p>This is an HTML attribute to set on the component if needed. In this case, the component will automatically create a <code>sonic-toast-message-subscriber</code> component. The data found in <code>props[messageKey]</code> will be treated as the data expected by the <code>sonic-toast-message-subscriber</code>. So, by respecting the format of data supported by this component, you will be able to show multiple toasts in the result of a request.</p>
|
|
243
|
+
<p>Example of JSON with <code>messageKey</code>=<code>messages</code>:</p>
|
|
244
|
+
<pre><code class="language-typescript">{
|
|
245
|
+
"messages": [{
|
|
246
|
+
"content": "The product has been added to your cart",
|
|
247
|
+
"status": "success",
|
|
248
|
+
"type": "public"
|
|
249
|
+
}]
|
|
250
|
+
}
|
|
251
|
+
</code></pre>
|
|
252
|
+
<h3 id="library">library</h3>
|
|
253
|
+
<p>This is an HTML attribute to set on the component if needed. You can set a URL pointing to a JSON describing a library with the same structure as the library in the SDUIDescriptor. The component will simply override its library with the given one.</p>
|
|
254
|
+
<h2 id="playground">Playground</h2>
|
|
255
|
+
<p>Here is a little playground to let you test some simple tricks.</p>
|
|
256
|
+
<pre><code><sonic-textarea
|
|
257
|
+
rows="10"
|
|
258
|
+
onChange="SonicPublisherManager.get('sdui-playground').set(JSON.parse(this.value))"
|
|
259
|
+
value='{"nodes":[{"tagName":"div", "innerHTML":"test"}]}'
|
|
260
|
+
>
|
|
261
|
+
</sonic-textarea>
|
|
262
|
+
<sonic-sdui dataProvider="sdui-playground" props='{"nodes":[{"tagName":"div", "innerHTML":"test"}]}'>
|
|
263
|
+
</sonic-sdui>
|
|
264
|
+
</code></pre>
|
|
265
|
+
|
|
266
|
+
</article>
|
|
267
|
+
</main>
|
|
268
|
+
</body>
|
|
269
|
+
</html>
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="fr" data-crawl-url="https://concorde.supersoniks.org/crawl/core/components/functional/states/states.html" data-doc-id="core/components/functional/states/states">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
+
<title>States — Concorde</title>
|
|
7
|
+
<meta name="description" content="* It loops over its child templates and tests if the regexp contained in the *data-value* attribute matches the value of the property">
|
|
8
|
+
<meta name="keywords" content="Concorde, supersoniks, core/components/functional/states/states, states, States, functional component, sonic-states, web component">
|
|
9
|
+
<meta name="concorde-doc-id" content="core/components/functional/states/states">
|
|
10
|
+
<link rel="canonical" href="https://concorde.supersoniks.org/crawl/core/components/functional/states/states.html">
|
|
11
|
+
</head>
|
|
12
|
+
<body>
|
|
13
|
+
<header>
|
|
14
|
+
<p><a href="../../../../index.html">Concorde documentation (crawl)</a> · <a href="https://concorde.supersoniks.org/#core/components/functional/states/states.md/states" rel="nofollow">interactive version</a></p>
|
|
15
|
+
</header>
|
|
16
|
+
<main>
|
|
17
|
+
<article>
|
|
18
|
+
<p class="doc-lead" id="doc-summary"><strong>Concorde functional component — States</strong>. * It loops over its child templates and tests if the regexp contained in the *data-value* attribute matches the value of the property <span>Doc ID: <code>core/components/functional/states/states</code>. Keywords: Concorde, supersoniks, core/components/functional/states/states, states, States, functional component, sonic-states, web component. URL: <a href="https://concorde.supersoniks.org/crawl/core/components/functional/states/states.html">https://concorde.supersoniks.org/crawl/core/components/functional/states/states.html</a>.</span></p>
|
|
19
|
+
<h1 id="states">States</h1>
|
|
20
|
+
<h3 id="sonic-states-displays-different-states-depending-on-the-value-of-a-sub-property-of-its-dataprovider-data-path-attribute-in-dot-notation">sonic-states displays different states depending on the value of a sub-property of its dataProvider (data-path attribute in dot notation):</h3>
|
|
21
|
+
<ul>
|
|
22
|
+
<li>It loops over its child templates and tests if the regexp contained in the <em>data-value</em> attribute matches the value of the property</li>
|
|
23
|
+
<li>If so, the content of the corresponding template is displayed as a state.</li>
|
|
24
|
+
<li>If the attribute dataProviderExpression is provided the content is surrounded by a div:</li>
|
|
25
|
+
<li>The "dataProvider" attribute of this div is the result of calling the replace function on the property value with the regexp and dataproviderExpression as parameters.</li>
|
|
26
|
+
<li>The subscribers/fetch... of the template will refer to this dataProvider</li>
|
|
27
|
+
<li>You can also use url-pattern expressions for the route parameters, see the examples</li>
|
|
28
|
+
<li> <strong>Examples</strong></li>
|
|
29
|
+
<li>With ma.property= 2 :</li>
|
|
30
|
+
<li>RegExp data-value = (\d+) and dataproviderExpression = /user/$1 the dataProvider attribute will be "/user/2"</li>
|
|
31
|
+
<li>url-pattern data-value = :id and dataproviderExpression = /user/:id the dataProvider attribute will be "/user/2</li>
|
|
32
|
+
</ul>
|
|
33
|
+
<h2 id="basic">Basic</h2>
|
|
34
|
+
<pre><code><div class="flex gap-2 items-center" formDataProvider="states-basic-example">
|
|
35
|
+
<sonic-button radio name="selection" value="#home" checked size="xs">Home</sonic-button>
|
|
36
|
+
<sonic-button radio name="selection" value="#about" size="xs">About</sonic-button>
|
|
37
|
+
<sonic-button radio name="selection" value="#work" size="xs">Work</sonic-button>
|
|
38
|
+
<sonic-button radio name="selection" value="#contact" size="xs">Contact</sonic-button>
|
|
39
|
+
</div>
|
|
40
|
+
<div class="text-center text-neutral-700 border rounded text-4xl my-6 p-3 ">
|
|
41
|
+
<sonic-states dataProvider="states-basic-example" data-path="selection">
|
|
42
|
+
<template data-value="#home">Home
|
|
43
|
+
</code></pre>
|
|
44
|
+
<h2 id="regexp">Regexp</h2>
|
|
45
|
+
<p>When using <strong>capturing groups ()</strong> the stored values are accessible via the <strong>dataProviderExpression</strong><br><strong>e.g.</strong>, data-value="#couleur_<b class="text-danger">(\d+)</b>" => dataProviderExpression="api/unknown/<b class="text-danger">$1</b>"</p>
|
|
46
|
+
<pre><code><div serviceURL="/docs-mock-api">
|
|
47
|
+
<sonic-list formDataProvider="states-regexp-example" fetch dataProvider="api/unknown" key="data" class="flex gap-2 items-center" >
|
|
48
|
+
<template>
|
|
49
|
+
<sonic-button radio size="xs" name="selection" data-bind ::value="#couleur_$id">
|
|
50
|
+
<span data-bind ::inner-html="ucFirst|$name"></span>
|
|
51
|
+
</sonic-button>
|
|
52
|
+
</code></pre>
|
|
53
|
+
<h2 id="url-pattern">Url-pattern</h2>
|
|
54
|
+
<p>Same as RegExp but using <a href="https://www.npmjs.com/package/url-pattern" target="_blank">url patterns</a><br><strong>e.g.</strong>, data-value="#couleur_<b class="text-danger">:id</b>" => dataProviderExpression="api/unknown/<b class="text-danger">:id</b>"</p>
|
|
55
|
+
<pre><code><div serviceURL="/docs-mock-api">
|
|
56
|
+
<sonic-list formDataProvider="states-regexp-example" fetch dataProvider="api/unknown" key="data" class="flex gap-2 items-center" >
|
|
57
|
+
<template>
|
|
58
|
+
<sonic-button radio size="xs" name="selection" data-bind ::value="#couleur_$id">
|
|
59
|
+
<span data-bind ::inner-html="ucFirst|$name"></span>
|
|
60
|
+
</sonic-button>
|
|
61
|
+
</code></pre>
|
|
62
|
+
|
|
63
|
+
</article>
|
|
64
|
+
</main>
|
|
65
|
+
</body>
|
|
66
|
+
</html>
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="fr" data-crawl-url="https://concorde.supersoniks.org/crawl/core/components/functional/submit/submit.html" data-doc-id="core/components/functional/submit/submit">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
+
<title>Submit — Concorde</title>
|
|
7
|
+
<meta name="description" content="> Live demos: <docs-lit-demo> + src/docs/example/docs-submit-demos.ts. Use Local API demos (serviceURL="/docs-mock-api").">
|
|
8
|
+
<meta name="keywords" content="Concorde, supersoniks, core/components/functional/submit/submit, submit, Submit, functional component, sonic-submit, web component, , src/docs/example/docs-submit-demos.ts, serviceURL="/docs-mock-api", serviceURL, dataProvider, endPoint, onClick, onEnterKey, formDataProvider, sonic-input">
|
|
9
|
+
<meta name="concorde-doc-id" content="core/components/functional/submit/submit">
|
|
10
|
+
<link rel="canonical" href="https://concorde.supersoniks.org/crawl/core/components/functional/submit/submit.html">
|
|
11
|
+
</head>
|
|
12
|
+
<body>
|
|
13
|
+
<header>
|
|
14
|
+
<p><a href="../../../../index.html">Concorde documentation (crawl)</a> · <a href="https://concorde.supersoniks.org/#core/components/functional/submit/submit.md/submit" rel="nofollow">interactive version</a></p>
|
|
15
|
+
</header>
|
|
16
|
+
<main>
|
|
17
|
+
<article>
|
|
18
|
+
<p class="doc-lead" id="doc-summary"><strong>Concorde functional component — Submit</strong>. > Live demos: <docs-lit-demo> + src/docs/example/docs-submit-demos.ts. Use Local API demos (serviceURL="/docs-mock-api"). <span>Doc ID: <code>core/components/functional/submit/submit</code>. Keywords: Concorde, supersoniks, core/components/functional/submit/submit, submit, Submit, functional component, sonic-submit, web component, , src/docs/example/docs-submit-demos.ts, serviceURL="/docs-mock-api", serviceURL, dataProvider, endPoint, onClick, onEnterKey, formDataProvider, sonic-input. URL: <a href="https://concorde.supersoniks.org/crawl/core/components/functional/submit/submit.html">https://concorde.supersoniks.org/crawl/core/components/functional/submit/submit.html</a>.</span></p>
|
|
19
|
+
<h1 id="submit">Submit</h1>
|
|
20
|
+
<blockquote>
|
|
21
|
+
<p><strong>Live demos:</strong> <code><docs-lit-demo></code> + <code>src/docs/example/docs-submit-demos.ts</code>. Use <a href="../../../../docs/_misc/docs-mock-api.html#docs-mock-api">Local API demos</a> (<code>serviceURL="/docs-mock-api"</code>).</p>
|
|
22
|
+
</blockquote>
|
|
23
|
+
<h2 id="overview">Overview</h2>
|
|
24
|
+
<p><strong>sonic-submit</strong> sends the <strong>formDataProvider</strong> publisher to a REST endpoint (same configuration model as <a href="../fetch/fetch.html#fetch">fetch</a>: <code>serviceURL</code> on an ancestor, path via <code>dataProvider</code> or <code>endPoint</code>).</p>
|
|
25
|
+
<table>
|
|
26
|
+
<thead>
|
|
27
|
+
<tr>
|
|
28
|
+
<th>Trigger</th>
|
|
29
|
+
<th>Attribute</th>
|
|
30
|
+
</tr>
|
|
31
|
+
</thead>
|
|
32
|
+
<tbody><tr>
|
|
33
|
+
<td>Click inside the slot</td>
|
|
34
|
+
<td><code>onClick</code></td>
|
|
35
|
+
</tr>
|
|
36
|
+
<tr>
|
|
37
|
+
<td>Enter in a focused field inside the slot</td>
|
|
38
|
+
<td><code>onEnterKey</code></td>
|
|
39
|
+
</tr>
|
|
40
|
+
</tbody></table>
|
|
41
|
+
<table>
|
|
42
|
+
<thead>
|
|
43
|
+
<tr>
|
|
44
|
+
<th>Data / API</th>
|
|
45
|
+
<th>Attribute / property</th>
|
|
46
|
+
<th>Notes</th>
|
|
47
|
+
</tr>
|
|
48
|
+
</thead>
|
|
49
|
+
<tbody><tr>
|
|
50
|
+
<td>Form fields</td>
|
|
51
|
+
<td><code>formDataProvider</code> on ancestor</td>
|
|
52
|
+
<td>Filled by <code>sonic-input</code>, <code>sonic-select</code>, etc. via <code>name</code></td>
|
|
53
|
+
</tr>
|
|
54
|
+
<tr>
|
|
55
|
+
<td>Result after call</td>
|
|
56
|
+
<td><code>submitResultDataProvider</code> on ancestor</td>
|
|
57
|
+
<td>Whole result object (after optional <code>submit-result-key</code>)</td>
|
|
58
|
+
</tr>
|
|
59
|
+
<tr>
|
|
60
|
+
<td>Slice of JSON result</td>
|
|
61
|
+
<td><code>submit-result-key</code> on <strong>sonic-submit</strong></td>
|
|
62
|
+
<td>Dot path, e.g. <code>data</code> when the API returns <code>{ data: { … } }</code></td>
|
|
63
|
+
</tr>
|
|
64
|
+
<tr>
|
|
65
|
+
<td>HTTP verb</td>
|
|
66
|
+
<td><code>method</code> on <strong>sonic-submit</strong></td>
|
|
67
|
+
<td><code>post</code> (default), <code>put</code>, <code>patch</code>, <code>delete</code>, <code>get</code> — not inherited from <code>sonic-scope</code></td>
|
|
68
|
+
</tr>
|
|
69
|
+
<tr>
|
|
70
|
+
<td>Path override</td>
|
|
71
|
+
<td><code>endPoint</code> on <strong>sonic-submit</strong></td>
|
|
72
|
+
<td>Wins over ancestor <code>dataProvider</code></td>
|
|
73
|
+
</tr>
|
|
74
|
+
<tr>
|
|
75
|
+
<td>JSON vs multipart</td>
|
|
76
|
+
<td><code>sendAsFormData</code> on <strong>sonic-submit</strong></td>
|
|
77
|
+
<td><code>FormData</code> body, still expects JSON response</td>
|
|
78
|
+
</tr>
|
|
79
|
+
<tr>
|
|
80
|
+
<td>Reset publishers</td>
|
|
81
|
+
<td><code>clearedDataOnSuccess</code> on ancestor</td>
|
|
82
|
+
<td>Space-separated <code>DataProviderKey.path</code> values; runs when a <strong>result object</strong> is returned (including error payloads with <code>messages</code>)</td>
|
|
83
|
+
</tr>
|
|
84
|
+
<tr>
|
|
85
|
+
<td>Browser form POST</td>
|
|
86
|
+
<td><code>native</code> on <strong>sonic-submit</strong></td>
|
|
87
|
+
<td>See <a href="#native-html-form">Native HTML form</a></td>
|
|
88
|
+
</tr>
|
|
89
|
+
<tr>
|
|
90
|
+
<td>Result event</td>
|
|
91
|
+
<td>—</td>
|
|
92
|
+
<td>Bubbles <code>submit</code> <code>CustomEvent</code> with <code>detail</code> = result</td>
|
|
93
|
+
</tr>
|
|
94
|
+
<tr>
|
|
95
|
+
<td>Credential Management API</td>
|
|
96
|
+
<td><code>usernameKey</code>, <code>passwordKey</code> on <strong>sonic-submit</strong></td>
|
|
97
|
+
<td>After a <strong>successful</strong> HTTP response, stores login if those keys exist in the payload (defaults: <code>username</code>, <code>password</code>)</td>
|
|
98
|
+
</tr>
|
|
99
|
+
<tr>
|
|
100
|
+
<td>ALTCHA / captcha</td>
|
|
101
|
+
<td><code>needsCaptchaValidation</code> on form/header publisher</td>
|
|
102
|
+
<td>Defers send until token is set — see <a href="../../ui/captcha/captcha.html#captcha">Captcha</a></td>
|
|
103
|
+
</tr>
|
|
104
|
+
</tbody></table>
|
|
105
|
+
<p>While a REST submit runs, the slot is wrapped with <code>data-disabled</code> (faded, no pointer events). With <strong><code>native</code></strong>, validation and loader still run, then the browser performs a normal form submission.</p>
|
|
106
|
+
<h2 id="form-and-result-handling">Form and result handling</h2>
|
|
107
|
+
<p>POST to mock <code>api/register</code>; result publisher <code>submit-example-result</code>.</p>
|
|
108
|
+
<p><docs-lit-demo for="docs-submit-demo"></docs-lit-demo></p>
|
|
109
|
+
<h2 id="native-html-form">Native HTML form</h2>
|
|
110
|
+
<p>With <strong><code>native</code></strong>, Concorde does <strong>not</strong> call <code>fetch</code>. After form validation it:</p>
|
|
111
|
+
<ol>
|
|
112
|
+
<li>Copies <strong>formDataProvider</strong> values into matching <code><input></code> / <code><select></code> / <code><textarea></code> inside the closest <strong><code><form></code></strong> (creates hidden inputs if needed).</li>
|
|
113
|
+
<li>Programmatically clicks a hidden native <code>type="submit"</code> control (<code>name</code> / <code>value</code> on <strong>sonic-submit</strong> if you need them).</li>
|
|
114
|
+
</ol>
|
|
115
|
+
<p>Use a real <code><form action="…" method="post"></code> ancestor. For SPAs, a named <strong><code>target</code></strong> (e.g. iframe) avoids leaving the doc page.</p>
|
|
116
|
+
<p><docs-lit-demo for="docs-submit-native-demo"></docs-lit-demo></p>
|
|
117
|
+
<h2 id="sendasformdata">sendAsFormData</h2>
|
|
118
|
+
<p>Sends fields as <strong><code>multipart/form-data</code></strong> instead of <code>application/json</code> (response is still parsed as JSON).</p>
|
|
119
|
+
<p><docs-lit-demo for="docs-submit-formdata-demo"></docs-lit-demo></p>
|
|
120
|
+
<h2 id="submit-result-key">submit-result-key</h2>
|
|
121
|
+
<p>When the API wraps the payload (e.g. <code>{ data: { id, token } }</code>), set <strong><code>submit-result-key="data"</code></strong> on <strong>sonic-submit</strong> so <strong>submitResultDataProvider</strong> receives only the inner object.</p>
|
|
122
|
+
<p><docs-lit-demo for="docs-submit-result-key-demo"></docs-lit-demo></p>
|
|
123
|
+
<p>Mock endpoint: <code>POST /docs-mock-api/api/register/nested</code>.</p>
|
|
124
|
+
<h2 id="cleareddataonsuccess">clearedDataOnSuccess</h2>
|
|
125
|
+
<p>Lists one or more publisher ids (space-separated). After the API returns a result object, each is set to <code>{}</code> — useful to reset the form publisher.</p>
|
|
126
|
+
<p><docs-lit-demo for="docs-submit-clear-demo"></docs-lit-demo></p>
|
|
127
|
+
<h2 id="custom-submit-event">Custom <code>submit</code> event</h2>
|
|
128
|
+
<p>Listen for the bubbling <strong><code>submit</code></strong> event; <strong><code>event.detail</code></strong> is the same result written to <strong>submitResultDataProvider</strong> (if configured).</p>
|
|
129
|
+
<p><docs-lit-demo for="docs-submit-event-demo"></docs-lit-demo></p>
|
|
130
|
+
<h2 id="endpoint-vs-dataprovider">endPoint vs dataProvider</h2>
|
|
131
|
+
<p>Ancestor <strong><code>dataProvider</code></strong> is the default path; <strong><code>endPoint</code></strong> on <strong>sonic-submit</strong> overrides it for that button only.</p>
|
|
132
|
+
<p><docs-lit-demo for="docs-submit-endpoint-demo"></docs-lit-demo></p>
|
|
133
|
+
<h2 id="methodget">method="get"</h2>
|
|
134
|
+
<p>Appends publisher fields as a query string on the endpoint, then performs a GET. The mock route <code>api/register/echo</code> returns the query for inspection.</p>
|
|
135
|
+
<p><docs-lit-demo for="docs-submit-get-demo"></docs-lit-demo></p>
|
|
136
|
+
<h2 id="dot-notation-formdataprovider-shape">dot notation (formDataProvider shape)</h2>
|
|
137
|
+
<p>You can use dot notation in <strong><code>name</code></strong> on form controls; the publisher stores nested objects:</p>
|
|
138
|
+
<pre><code><sonic-scope formDataProvider="submit-example-dot-notation">
|
|
139
|
+
<div class="grid grid-cols-2 gap-4 mb-4 ">
|
|
140
|
+
<sonic-input required name="email.value" type="email" value="eve.holt@reqres.in"></sonic-input>
|
|
141
|
+
<sonic-input required type="password" name="details.password.value" value="pistol"></sonic-input>
|
|
142
|
+
</div>
|
|
143
|
+
</sonic-scope>
|
|
144
|
+
</code></pre>
|
|
145
|
+
<p>Stored shape:</p>
|
|
146
|
+
<pre><code class="language-typescript">{
|
|
147
|
+
email: { value: "eve.holt@reqres.in" },
|
|
148
|
+
details: { password: { value: "pistol" } }
|
|
149
|
+
}
|
|
150
|
+
</code></pre>
|
|
151
|
+
<h2 id="related">Related</h2>
|
|
152
|
+
<ul>
|
|
153
|
+
<li><a href="../../ui/captcha/captcha.html#captcha">Captcha</a> — submit waits for <code>captchaToken</code> when validation is required.</li>
|
|
154
|
+
<li><a href="../../../../docs/_misc/html-integration.html#html-integration">HTML integration</a> — legacy <code>data-bind</code> result blocks; prefer <strong>submitResultDataProvider</strong> + <code>@subscribe</code> in Lit demos.</li>
|
|
155
|
+
</ul>
|
|
156
|
+
|
|
157
|
+
</article>
|
|
158
|
+
</main>
|
|
159
|
+
</body>
|
|
160
|
+
</html>
|