@supersoniks/concorde 4.6.0 → 4.7.3
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 +273 -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 +152 -152
- package/concorde-core.es.js +1853 -1689
- package/dist/altcha-widget.js +2662 -0
- package/dist/concorde-core.bundle.js +152 -152
- package/dist/concorde-core.es.js +1853 -1689
- 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/decorators/api.spec.ts +8 -1
- package/src/core/decorators/api.ts +126 -15
- package/src/core/directives/DataProvider.sub.spec.ts +96 -0
- package/src/core/directives/DataProvider.ts +109 -40
- package/src/core/utils/HTML.ts +42 -10
- 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
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { css, html, LitElement, nothing } from "lit";
|
|
2
|
+
import { customElement, property, state } from "lit/decorators.js";
|
|
3
|
+
import { unsafeHTML } from "lit/directives/unsafe-html.js";
|
|
4
|
+
import { tailwind } from "../tailwind";
|
|
5
|
+
import { docsSourceLinks } from "./docs-source-link";
|
|
6
|
+
import {
|
|
7
|
+
DOCS_LIT_DEMO_REGISTRY,
|
|
8
|
+
type DocsLitDemoConfig,
|
|
9
|
+
} from "./docs-demo-sources";
|
|
10
|
+
|
|
11
|
+
import "../prism/prism";
|
|
12
|
+
import { prismCSS } from "../prism";
|
|
13
|
+
import * as Prism from "prismjs";
|
|
14
|
+
import "prismjs/components/prism-typescript";
|
|
15
|
+
|
|
16
|
+
import { DOCS_LIT_DEMO_RAW } from "./docs-lit-demo-raw";
|
|
17
|
+
|
|
18
|
+
/** Class body for `liveTag`: from `@customElement("…")` through the line before the next `@customElement`. */
|
|
19
|
+
export function excerptForCustomElement(
|
|
20
|
+
source: string,
|
|
21
|
+
liveTag: string,
|
|
22
|
+
): string | null {
|
|
23
|
+
const lines = source.split("\n");
|
|
24
|
+
const needle = `@customElement("${liveTag}")`;
|
|
25
|
+
let start = -1;
|
|
26
|
+
for (let i = 0; i < lines.length; i++) {
|
|
27
|
+
if (lines[i].includes(needle)) {
|
|
28
|
+
start = i;
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
if (start < 0) return null;
|
|
33
|
+
|
|
34
|
+
let end = lines.length;
|
|
35
|
+
for (let i = start + 1; i < lines.length; i++) {
|
|
36
|
+
if (lines[i].includes("@customElement(")) {
|
|
37
|
+
end = i;
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return lines.slice(start, end).join("\n");
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function excerptLines(
|
|
45
|
+
source: string,
|
|
46
|
+
start?: number,
|
|
47
|
+
end?: number,
|
|
48
|
+
): string {
|
|
49
|
+
const lines = source.split("\n");
|
|
50
|
+
if (!start && !end) return source;
|
|
51
|
+
const from = Math.max(1, start ?? 1) - 1;
|
|
52
|
+
const to = end ?? lines.length;
|
|
53
|
+
return lines.slice(from, to).join("\n");
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function resolveDemoExcerpt(
|
|
57
|
+
raw: string,
|
|
58
|
+
liveTag: string,
|
|
59
|
+
cfg: DocsLitDemoConfig,
|
|
60
|
+
): string {
|
|
61
|
+
const auto = excerptForCustomElement(raw, liveTag);
|
|
62
|
+
if (auto) return auto;
|
|
63
|
+
if (cfg.excerptStart != null || cfg.excerptEnd != null) {
|
|
64
|
+
return excerptLines(raw, cfg.excerptStart, cfg.excerptEnd);
|
|
65
|
+
}
|
|
66
|
+
return raw;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function highlightTs(code: string): string {
|
|
70
|
+
return Prism.highlight(code, Prism.languages.typescript, "typescript");
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const tagName = "docs-lit-demo";
|
|
74
|
+
|
|
75
|
+
@customElement(tagName)
|
|
76
|
+
export class DocsLitDemo extends LitElement {
|
|
77
|
+
static styles = [
|
|
78
|
+
tailwind,
|
|
79
|
+
prismCSS,
|
|
80
|
+
css`
|
|
81
|
+
:host {
|
|
82
|
+
display: block;
|
|
83
|
+
margin: 1.1rem 0;
|
|
84
|
+
}
|
|
85
|
+
pre {
|
|
86
|
+
font-size: 13px !important;
|
|
87
|
+
}
|
|
88
|
+
.preview {
|
|
89
|
+
border: 1px solid var(--sc-border, #e5e5e5);
|
|
90
|
+
border-radius: 0.375rem;
|
|
91
|
+
padding: 1rem;
|
|
92
|
+
margin-bottom: 0.75rem;
|
|
93
|
+
}
|
|
94
|
+
`,
|
|
95
|
+
];
|
|
96
|
+
|
|
97
|
+
/** Registry key = live custom element tag name */
|
|
98
|
+
@property({ attribute: "for" }) forTag = "";
|
|
99
|
+
|
|
100
|
+
@property({ type: Boolean }) showCode = true;
|
|
101
|
+
|
|
102
|
+
@state() private highlighted = "";
|
|
103
|
+
|
|
104
|
+
private liveHost?: HTMLDivElement;
|
|
105
|
+
|
|
106
|
+
private get config(): DocsLitDemoConfig | undefined {
|
|
107
|
+
return DOCS_LIT_DEMO_REGISTRY[this.forTag];
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
connectedCallback() {
|
|
111
|
+
super.connectedCallback();
|
|
112
|
+
const cfg = this.config;
|
|
113
|
+
if (!cfg?.sources[0]) return;
|
|
114
|
+
|
|
115
|
+
const raw = DOCS_LIT_DEMO_RAW[cfg.sources[0].path];
|
|
116
|
+
if (!raw) {
|
|
117
|
+
console.warn(`[docs-lit-demo] No raw source for ${cfg.sources[0].path}`);
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const liveTag = cfg.liveTag ?? this.forTag;
|
|
122
|
+
const excerpt = resolveDemoExcerpt(raw, liveTag, cfg);
|
|
123
|
+
this.highlighted = highlightTs(excerpt);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
render() {
|
|
127
|
+
const cfg = this.config;
|
|
128
|
+
if (!cfg) return nothing;
|
|
129
|
+
|
|
130
|
+
const liveTag = cfg.liveTag ?? this.forTag;
|
|
131
|
+
|
|
132
|
+
return html`
|
|
133
|
+
${docsSourceLinks(cfg.sources)}
|
|
134
|
+
<div class="preview" data-live-host></div>
|
|
135
|
+
${this.showCode && this.highlighted
|
|
136
|
+
? html`
|
|
137
|
+
<pre
|
|
138
|
+
class="rounded-md custom-scroll language-typescript overflow-auto"
|
|
139
|
+
><code>${unsafeHTML(this.highlighted)}</code></pre>
|
|
140
|
+
`
|
|
141
|
+
: nothing}
|
|
142
|
+
`;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
firstUpdated() {
|
|
146
|
+
super.firstUpdated();
|
|
147
|
+
this.mountLiveDemo();
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
updated(changed: Map<string, unknown>) {
|
|
151
|
+
super.updated(changed);
|
|
152
|
+
if (changed.has("forTag")) this.mountLiveDemo();
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
private mountLiveDemo() {
|
|
156
|
+
const cfg = this.config;
|
|
157
|
+
const tag = cfg?.liveTag ?? this.forTag;
|
|
158
|
+
const host = this.renderRoot.querySelector(
|
|
159
|
+
"[data-live-host]",
|
|
160
|
+
) as HTMLDivElement | null;
|
|
161
|
+
if (!host || !tag) return;
|
|
162
|
+
const existing = host.firstElementChild;
|
|
163
|
+
if (existing?.tagName.toLowerCase() === tag && existing.isConnected) return;
|
|
164
|
+
host.replaceChildren(document.createElement(tag));
|
|
165
|
+
}
|
|
166
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { html, nothing } from "lit";
|
|
2
|
+
import "../../core/components/ui/button/button";
|
|
3
|
+
import "../../core/components/ui/icon/icon";
|
|
4
|
+
|
|
5
|
+
declare const __DOCS_EDITOR_AVAILABLE__: boolean;
|
|
6
|
+
|
|
7
|
+
export type DocsSource = {
|
|
8
|
+
path: string;
|
|
9
|
+
line?: number;
|
|
10
|
+
column?: number;
|
|
11
|
+
label?: string;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const editorAvailable =
|
|
15
|
+
import.meta.env.DEV &&
|
|
16
|
+
typeof __DOCS_EDITOR_AVAILABLE__ !== "undefined" &&
|
|
17
|
+
__DOCS_EDITOR_AVAILABLE__;
|
|
18
|
+
|
|
19
|
+
function openDocsSource(source: DocsSource, event: Event) {
|
|
20
|
+
event.preventDefault();
|
|
21
|
+
if (!editorAvailable) return;
|
|
22
|
+
|
|
23
|
+
const params = new URLSearchParams({
|
|
24
|
+
path: source.path,
|
|
25
|
+
line: String(source.line ?? 1),
|
|
26
|
+
column: String(source.column ?? 1),
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
void fetch(`/__docs/open?${params}`).catch(() => {
|
|
30
|
+
console.warn("[docs] Could not open in editor:", source.path);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function docsSourceLink(source: DocsSource) {
|
|
35
|
+
if (!editorAvailable) return nothing;
|
|
36
|
+
const label = source.label ?? source.path.split("/").pop() ?? "source";
|
|
37
|
+
return html`
|
|
38
|
+
<sonic-button
|
|
39
|
+
variant="link"
|
|
40
|
+
size="2xs"
|
|
41
|
+
type="neutral"
|
|
42
|
+
title=${source.path}
|
|
43
|
+
@click=${(e: Event) => openDocsSource(source, e)}
|
|
44
|
+
>
|
|
45
|
+
<sonic-icon
|
|
46
|
+
library="heroicons"
|
|
47
|
+
name="arrow-top-right-on-square"
|
|
48
|
+
class="w-3 h-3 opacity-70"
|
|
49
|
+
></sonic-icon>
|
|
50
|
+
${label}
|
|
51
|
+
</sonic-button>
|
|
52
|
+
`;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function docsSourceLinks(sources: DocsSource[]) {
|
|
56
|
+
if (!editorAvailable || sources.length === 0) return nothing;
|
|
57
|
+
return html`
|
|
58
|
+
<div
|
|
59
|
+
class="flex flex-wrap items-center gap-x-1 gap-y-1 mb-4 pb-3 border-b border-neutral-200/80 dark:border-neutral-700/80"
|
|
60
|
+
>
|
|
61
|
+
<span class="text-xs uppercase tracking-wide text-neutral-400 mr-1"
|
|
62
|
+
>Source</span
|
|
63
|
+
>
|
|
64
|
+
${sources.map((s, i) =>
|
|
65
|
+
i === 0
|
|
66
|
+
? docsSourceLink(s)
|
|
67
|
+
: html`<span class="text-neutral-300 dark:text-neutral-600">·</span
|
|
68
|
+
>${docsSourceLink(s)}`,
|
|
69
|
+
)}
|
|
70
|
+
</div>
|
|
71
|
+
`;
|
|
72
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/** Doc page hash for `router.md` (markdown anchor, before demo sub-routes). */
|
|
2
|
+
export const DOC_ROUTER_PAGE_HASH =
|
|
3
|
+
"#core/components/functional/router/router.md/router";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Doc site hash: `#<markdown-path>/<page-anchor>[#<in-page-demo-route>]`
|
|
7
|
+
* e.g. `#core/.../router.md/router#home` — second `#` is for sonic-router demos only.
|
|
8
|
+
*/
|
|
9
|
+
export function parseDocsLocation(location: string): {
|
|
10
|
+
/** Path for markdown fetch (no leading `#`). */
|
|
11
|
+
url: string;
|
|
12
|
+
/** Page anchor (last segment before demo sub-hash). */
|
|
13
|
+
anchor: string;
|
|
14
|
+
/** In-page route segment after a second `#` (router demos). */
|
|
15
|
+
demoSubHash: string;
|
|
16
|
+
/** Full doc page hash including anchor, without demo sub-hash. */
|
|
17
|
+
pageHash: string;
|
|
18
|
+
} {
|
|
19
|
+
const sharpIdx = location.indexOf("#");
|
|
20
|
+
if (sharpIdx < 0) {
|
|
21
|
+
return { url: "", anchor: "", demoSubHash: "", pageHash: "" };
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
let hashBody = location.substring(sharpIdx + 1);
|
|
25
|
+
let demoSubHash = "";
|
|
26
|
+
const nested = hashBody.lastIndexOf("#");
|
|
27
|
+
if (nested > 0) {
|
|
28
|
+
demoSubHash = hashBody.substring(nested + 1);
|
|
29
|
+
hashBody = hashBody.substring(0, nested);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const parts = hashBody.split("/").filter(Boolean);
|
|
33
|
+
const anchor = decodeURIComponent(parts.pop() || "");
|
|
34
|
+
const url = parts.join("/");
|
|
35
|
+
|
|
36
|
+
return {
|
|
37
|
+
url,
|
|
38
|
+
anchor,
|
|
39
|
+
demoSubHash,
|
|
40
|
+
pageHash: hashBody ? `#${hashBody}` : "",
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** Navigate inside the current doc page without reloading markdown. */
|
|
45
|
+
export function setDocsDemoSubHash(subRoute: string, pageHash?: string): void {
|
|
46
|
+
const loc = document.location;
|
|
47
|
+
const base =
|
|
48
|
+
pageHash ||
|
|
49
|
+
parseDocsLocation(loc.pathname + loc.search + loc.hash).pageHash ||
|
|
50
|
+
loc.hash;
|
|
51
|
+
const sub = subRoute.replace(/^#/, "");
|
|
52
|
+
const nextHash = sub ? `${base}#${sub}` : base;
|
|
53
|
+
history.replaceState(history.state, "", `${loc.pathname}${loc.search}${nextHash}`);
|
|
54
|
+
}
|
package/src/docs/docs.ts
CHANGED
|
@@ -1,8 +1,20 @@
|
|
|
1
|
+
import "./example/docs-provider-keys";
|
|
1
2
|
import "./layout";
|
|
2
3
|
import "./search/search";
|
|
3
4
|
import "./search/page";
|
|
4
5
|
import "./search/markdown-renderer";
|
|
5
6
|
import "./code";
|
|
7
|
+
import "./components/docs-demo-sources";
|
|
8
|
+
import "./components/docs-lit-demo";
|
|
6
9
|
import "./header/header";
|
|
7
10
|
import "./navigation/navigation";
|
|
8
11
|
import "./example/users";
|
|
12
|
+
import "./example/docs-users-list";
|
|
13
|
+
import "./example/docs-user-two-scopes";
|
|
14
|
+
import "./example/docs-joke-demos";
|
|
15
|
+
import "./example/docs-queue-demos";
|
|
16
|
+
import "./example/docs-toggle-demos";
|
|
17
|
+
import "./example/docs-list-demos";
|
|
18
|
+
import "./example/docs-router-demos";
|
|
19
|
+
import "./example/docs-submit-demos";
|
|
20
|
+
import "./example/docs-api-config-demos";
|
|
@@ -3,11 +3,13 @@ import { customElement, property, state } from "lit/decorators.js";
|
|
|
3
3
|
import { bind } from "@supersoniks/concorde/decorators";
|
|
4
4
|
import { DataProviderKey } from "@supersoniks/concorde/core/utils/dataProviderKey";
|
|
5
5
|
import { sub } from "@supersoniks/concorde/directives";
|
|
6
|
+
import { get, set } from "@supersoniks/concorde/core/utils/PublisherProxy";
|
|
6
7
|
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
bindReflectDemoKey,
|
|
9
|
+
demoDataKey,
|
|
10
|
+
demoUsersAltKey,
|
|
11
|
+
demoUsersKey,
|
|
12
|
+
} from "./docs-provider-keys";
|
|
11
13
|
import { tailwind } from "../tailwind";
|
|
12
14
|
import "./decorators-demo-init";
|
|
13
15
|
|
|
@@ -41,14 +43,14 @@ export class DemoBind extends LitElement {
|
|
|
41
43
|
}
|
|
42
44
|
|
|
43
45
|
updateData() {
|
|
44
|
-
const
|
|
45
|
-
const
|
|
46
|
-
const
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
46
|
+
const users = get(demoUsersKey);
|
|
47
|
+
const randomIndex = Math.floor(Math.random() * users.length);
|
|
48
|
+
const randomUser = users[randomIndex];
|
|
49
|
+
const data = get(demoDataKey);
|
|
50
|
+
set(demoDataKey, {
|
|
51
|
+
...data,
|
|
52
|
+
count: data.count + 1,
|
|
53
|
+
user: { name: `${randomUser.firstName} ${randomUser.lastName}` },
|
|
52
54
|
});
|
|
53
55
|
}
|
|
54
56
|
}
|
|
@@ -71,7 +73,7 @@ export class DemoBindReflect extends LitElement {
|
|
|
71
73
|
}
|
|
72
74
|
|
|
73
75
|
resetData() {
|
|
74
|
-
|
|
76
|
+
set(bindReflectDemoKey, { count: 0 });
|
|
75
77
|
}
|
|
76
78
|
render() {
|
|
77
79
|
return html`
|
|
@@ -91,11 +93,6 @@ export class DemoBindReflect extends LitElement {
|
|
|
91
93
|
}
|
|
92
94
|
}
|
|
93
95
|
|
|
94
|
-
type BindReflectDemoData = { count: number };
|
|
95
|
-
const bindReflectDemoKey = new DataProviderKey<BindReflectDemoData>(
|
|
96
|
-
"bindReflectDemo",
|
|
97
|
-
);
|
|
98
|
-
|
|
99
96
|
@customElement("demo-bind-key")
|
|
100
97
|
export class DemoBindKey extends LitElement {
|
|
101
98
|
static styles = [tailwind];
|
|
@@ -106,7 +103,7 @@ export class DemoBindKey extends LitElement {
|
|
|
106
103
|
|
|
107
104
|
connectedCallback() {
|
|
108
105
|
super.connectedCallback();
|
|
109
|
-
|
|
106
|
+
set(bindReflectDemoKey, { count: 0 });
|
|
110
107
|
}
|
|
111
108
|
|
|
112
109
|
render() {
|
|
@@ -126,7 +123,8 @@ export class DemoBindDynamic extends LitElement {
|
|
|
126
123
|
static styles = [tailwind];
|
|
127
124
|
|
|
128
125
|
@property({ type: String })
|
|
129
|
-
dataProvider:
|
|
126
|
+
dataProvider: typeof demoUsersKey.path | typeof demoUsersAltKey.path =
|
|
127
|
+
demoUsersKey.path;
|
|
130
128
|
|
|
131
129
|
@property({ type: Number })
|
|
132
130
|
userIndex: number = 1;
|
|
@@ -141,36 +139,33 @@ export class DemoBindDynamic extends LitElement {
|
|
|
141
139
|
|
|
142
140
|
updateDataProvider(e: Event) {
|
|
143
141
|
this.dataProvider = (e.target as HTMLSelectElement).value as
|
|
144
|
-
|
|
|
145
|
-
|
|
|
142
|
+
| typeof demoUsersKey.path
|
|
143
|
+
| typeof demoUsersAltKey.path;
|
|
146
144
|
}
|
|
147
145
|
|
|
148
146
|
updateCurrentUserData() {
|
|
149
|
-
const
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
const currentUser = userPublisher.get() || {};
|
|
168
|
-
userPublisher.set({
|
|
169
|
-
...currentUser,
|
|
147
|
+
const key =
|
|
148
|
+
this.dataProvider === demoUsersAltKey.path ? demoUsersAltKey : demoUsersKey;
|
|
149
|
+
const users = [...get(key)];
|
|
150
|
+
const randomNames = [
|
|
151
|
+
{ firstName: "Alice", lastName: "Wonder" },
|
|
152
|
+
{ firstName: "Bob", lastName: "Builder" },
|
|
153
|
+
{ firstName: "Charlie", lastName: "Chaplin" },
|
|
154
|
+
{ firstName: "Diana", lastName: "Prince" },
|
|
155
|
+
{ firstName: "Eve", lastName: "Adams" },
|
|
156
|
+
];
|
|
157
|
+
const randomName =
|
|
158
|
+
randomNames[Math.floor(Math.random() * randomNames.length)];
|
|
159
|
+
const randomEmail = `${randomName.firstName.toLowerCase()}.${randomName.lastName.toLowerCase()}@example.com`;
|
|
160
|
+
const idx = this.userIndex;
|
|
161
|
+
if (users[idx]) {
|
|
162
|
+
users[idx] = {
|
|
163
|
+
...users[idx],
|
|
170
164
|
firstName: randomName.firstName,
|
|
171
165
|
lastName: randomName.lastName,
|
|
172
166
|
email: randomEmail,
|
|
173
|
-
}
|
|
167
|
+
};
|
|
168
|
+
set(key, users);
|
|
174
169
|
}
|
|
175
170
|
}
|
|
176
171
|
|
|
@@ -182,8 +177,8 @@ export class DemoBindDynamic extends LitElement {
|
|
|
182
177
|
label="Users set"
|
|
183
178
|
@change=${this.updateDataProvider}
|
|
184
179
|
>
|
|
185
|
-
<option value
|
|
186
|
-
<option value
|
|
180
|
+
<option value=${demoUsersKey.path}>First set of users</option>
|
|
181
|
+
<option value=${demoUsersAltKey.path}>Second set of users</option>
|
|
187
182
|
</sonic-select>
|
|
188
183
|
<sonic-input
|
|
189
184
|
type="number"
|
|
@@ -2,13 +2,14 @@ import type { APIConfiguration } from "@supersoniks/concorde/core/utils/api";
|
|
|
2
2
|
import type { ApiGetResult } from "@supersoniks/concorde/core/utils/api";
|
|
3
3
|
import { Endpoint } from "@supersoniks/concorde/core/utils/endpoint";
|
|
4
4
|
import { DataProviderKey } from "@supersoniks/concorde/core/utils/dataProviderKey";
|
|
5
|
-
import {
|
|
5
|
+
import { get, set } from "@supersoniks/concorde/core/utils/PublisherProxy";
|
|
6
6
|
import "./decorators-demo-init";
|
|
7
|
+
import { DOCS_MOCK_GEO_SERVICE } from "../mock-api/urls";
|
|
7
8
|
|
|
8
9
|
export type GeoCommuneRow = { nom: string; code: string };
|
|
9
10
|
|
|
10
11
|
export const geoApiDemoConfiguration: APIConfiguration = {
|
|
11
|
-
serviceURL:
|
|
12
|
+
serviceURL: DOCS_MOCK_GEO_SERVICE,
|
|
12
13
|
token: null,
|
|
13
14
|
userName: null,
|
|
14
15
|
password: null,
|
|
@@ -16,13 +17,10 @@ export const geoApiDemoConfiguration: APIConfiguration = {
|
|
|
16
17
|
tokenProvider: null,
|
|
17
18
|
};
|
|
18
19
|
|
|
19
|
-
const docsDemoGeoApiConfigurationId = "docsDemoGeoApiConfiguration";
|
|
20
|
-
PublisherManager.get(docsDemoGeoApiConfigurationId).set(
|
|
21
|
-
geoApiDemoConfiguration,
|
|
22
|
-
);
|
|
23
|
-
|
|
24
20
|
export const docsDemoGeoApiConfigurationKey =
|
|
25
|
-
new DataProviderKey<APIConfiguration>(
|
|
21
|
+
new DataProviderKey<APIConfiguration>("docsDemoGeoApiConfiguration");
|
|
22
|
+
|
|
23
|
+
set(docsDemoGeoApiConfigurationKey, geoApiDemoConfiguration);
|
|
26
24
|
|
|
27
25
|
export const geoCommunesApiGetEndpoint = new Endpoint<GeoCommuneRow[]>(
|
|
28
26
|
"communes?limit=5&fields=nom,code",
|
|
@@ -31,10 +29,17 @@ export const geoCommunesApiGetEndpoint = new Endpoint<GeoCommuneRow[]>(
|
|
|
31
29
|
export const docsDemoDynApiConfKeyTemplate =
|
|
32
30
|
new DataProviderKey<APIConfiguration>("docsDemoDynApiConf${configSlot}");
|
|
33
31
|
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
export const docsDemoDynApiConfAKey = new DataProviderKey<APIConfiguration>(
|
|
33
|
+
"docsDemoDynApiConfA",
|
|
34
|
+
);
|
|
35
|
+
export const docsDemoDynApiConfBKey = new DataProviderKey<APIConfiguration>(
|
|
36
|
+
"docsDemoDynApiConfB",
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
set(docsDemoDynApiConfAKey, geoApiDemoConfiguration);
|
|
40
|
+
set(docsDemoDynApiConfBKey, {
|
|
36
41
|
...geoApiDemoConfiguration,
|
|
37
|
-
serviceURL:
|
|
42
|
+
serviceURL: DOCS_MOCK_GEO_SERVICE,
|
|
38
43
|
});
|
|
39
44
|
|
|
40
45
|
export const geoCommunesApiGetEndpointDynamic = new Endpoint<GeoCommuneRow[]>(
|