@supersoniks/concorde 4.5.2 → 4.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.gitlab-ci.yml +23 -0
- package/README.md +106 -55
- package/ai/AGENTS.md +52 -0
- package/ai/README.md +30 -0
- package/ai/cursor/rules/concorde-menu.mdc +15 -0
- package/ai/cursor/rules/concorde-scope.mdc +14 -0
- package/ai/cursor/rules/concorde-theme.mdc +13 -0
- package/ai/cursor/rules/concorde.mdc +49 -0
- package/ai/jetbrains/rules/concorde.md +39 -0
- package/ai/skills/concorde/SKILL.md +220 -0
- package/ai/skills/concorde-get-set-dp/SKILL.md +194 -0
- package/ai/skills/concorde-imports/SKILL.md +78 -0
- package/ai/skills/concorde-menu/SKILL.md +74 -0
- package/ai/skills/concorde-scope/SKILL.md +70 -0
- package/ai/skills/concorde-theme/SKILL.md +46 -0
- package/build-infos.json +1 -1
- package/concorde-core.bundle.js +159 -159
- package/concorde-core.es.js +1915 -1809
- package/dist/altcha-widget.js +2662 -0
- package/dist/concorde-core.bundle.js +159 -159
- package/dist/concorde-core.es.js +1915 -1809
- 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 +37 -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/Subscriber.ts +2 -0
- package/src/core/decorators/subscriber/handle.disambig.spec.ts +20 -0
- package/src/core/decorators/subscriber/handle.skip.spec.ts +37 -0
- package/src/core/decorators/subscriber/handle.ts +128 -0
- package/src/core/decorators/subscriber/onAssign.ts +94 -4
- package/src/core/directives/DataProvider.sub.spec.ts +96 -0
- package/src/core/directives/DataProvider.ts +109 -40
- package/src/core/utils/PublisherProxy.ts +33 -18
- package/src/core/utils/dataProviderKey.ts +23 -0
- package/src/core/utils/publisherPathKey.spec.ts +58 -0
- package/src/decorators.ts +6 -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 +20 -17
- package/src/docs/_decorators/get.md +7 -4
- package/src/docs/_decorators/handle.md +171 -0
- package/src/docs/_decorators/on-assign.md +99 -47
- 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 +38 -5
- 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 +142 -12
- 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 +43 -7
- package/src/docs/search/docs-search.json +4193 -858
- 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 +96 -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,297 @@
|
|
|
1
|
+
import { html, LitElement, nothing } from "lit";
|
|
2
|
+
import { customElement, property, state } from "lit/decorators.js";
|
|
3
|
+
import {
|
|
4
|
+
ancestorAttribute,
|
|
5
|
+
subscribe,
|
|
6
|
+
} from "@supersoniks/concorde/core/decorators/Subscriber";
|
|
7
|
+
import { DataProviderKey } from "@supersoniks/concorde/core/utils/dataProviderKey";
|
|
8
|
+
import { DOCS_MOCK_JOKES_SERVICE } from "../mock-api/urls";
|
|
9
|
+
import {
|
|
10
|
+
docsJokeCheckboxFilterKey,
|
|
11
|
+
docsJokeInputFilterKey,
|
|
12
|
+
docsJokeRadioFilterKey,
|
|
13
|
+
docsJokeSelectFilterKey,
|
|
14
|
+
docsJokeSwitchFilterKey,
|
|
15
|
+
} from "./docs-provider-keys";
|
|
16
|
+
import { tailwind } from "../tailwind";
|
|
17
|
+
|
|
18
|
+
import "../../core/components/functional/queue/queue";
|
|
19
|
+
import "../../core/components/ui/form/input/input";
|
|
20
|
+
import "../../core/components/ui/form/select/select";
|
|
21
|
+
import "../../core/components/ui/form/checkbox/checkbox";
|
|
22
|
+
import "../../core/components/ui/form/radio/radio";
|
|
23
|
+
import "../../core/components/ui/form/switch/switch";
|
|
24
|
+
|
|
25
|
+
type JokeRow = {
|
|
26
|
+
joke: string;
|
|
27
|
+
setup?: string;
|
|
28
|
+
delivery?: string;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const jokeRowKey = new DataProviderKey<
|
|
32
|
+
JokeRow,
|
|
33
|
+
{ dataProvider: string | null }
|
|
34
|
+
>("${dataProvider}");
|
|
35
|
+
|
|
36
|
+
const filterFieldKey = new DataProviderKey<
|
|
37
|
+
string,
|
|
38
|
+
{ filterProvider: string; field: string }
|
|
39
|
+
>("${filterProvider}.${field}");
|
|
40
|
+
|
|
41
|
+
@customElement("docs-joke-item")
|
|
42
|
+
export class DocsJokeItem extends LitElement {
|
|
43
|
+
static styles = [tailwind];
|
|
44
|
+
|
|
45
|
+
@ancestorAttribute("dataProvider")
|
|
46
|
+
dataProvider: string | null = null;
|
|
47
|
+
|
|
48
|
+
@subscribe(jokeRowKey)
|
|
49
|
+
@state()
|
|
50
|
+
row: JokeRow | null = null;
|
|
51
|
+
|
|
52
|
+
render() {
|
|
53
|
+
const r = this.row;
|
|
54
|
+
if (!r) return nothing;
|
|
55
|
+
return html`
|
|
56
|
+
<div
|
|
57
|
+
class="space-y-1 border-0 border-b border-dotted border-neutral-300 py-3"
|
|
58
|
+
>
|
|
59
|
+
<div>${r.joke}</div>
|
|
60
|
+
${r.setup
|
|
61
|
+
? html`<div class="text-sm text-neutral-500">${r.setup}</div>`
|
|
62
|
+
: nothing}
|
|
63
|
+
${r.delivery
|
|
64
|
+
? html`<div class="text-sm text-neutral-500">${r.delivery}</div>`
|
|
65
|
+
: nothing}
|
|
66
|
+
</div>
|
|
67
|
+
`;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
@customElement("docs-joke-filter-caption")
|
|
72
|
+
export class DocsJokeFilterCaption extends LitElement {
|
|
73
|
+
@property() filterProvider = "";
|
|
74
|
+
@property() field = "";
|
|
75
|
+
@property() label = "";
|
|
76
|
+
|
|
77
|
+
@subscribe(filterFieldKey)
|
|
78
|
+
@state()
|
|
79
|
+
value = "";
|
|
80
|
+
|
|
81
|
+
render() {
|
|
82
|
+
return html`
|
|
83
|
+
<p class="my-4 block text-xl font-bold">
|
|
84
|
+
${this.label} « <span class="text-info">${this.value || "…"}</span> » :
|
|
85
|
+
</p>
|
|
86
|
+
`;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
@customElement("docs-joke-queue")
|
|
91
|
+
export class DocsJokeQueue extends LitElement {
|
|
92
|
+
@property() filterProvider = "";
|
|
93
|
+
@property() expression = "joke/Any?amount=10&lang=fr";
|
|
94
|
+
|
|
95
|
+
private jokeItem = () => html`<docs-joke-item></docs-joke-item>`;
|
|
96
|
+
|
|
97
|
+
render() {
|
|
98
|
+
return html`
|
|
99
|
+
<sonic-queue
|
|
100
|
+
lazyload
|
|
101
|
+
dataProviderExpression=${this.expression}
|
|
102
|
+
dataFilterProvider=${this.filterProvider}
|
|
103
|
+
serviceURL=${DOCS_MOCK_JOKES_SERVICE}
|
|
104
|
+
key="jokes"
|
|
105
|
+
.items=${this.jokeItem}
|
|
106
|
+
></sonic-queue>
|
|
107
|
+
`;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
@customElement("docs-joke-search-demo")
|
|
112
|
+
export class DocsJokeSearchDemo extends LitElement {
|
|
113
|
+
static styles = [tailwind];
|
|
114
|
+
|
|
115
|
+
render() {
|
|
116
|
+
return html`
|
|
117
|
+
<sonic-input
|
|
118
|
+
formDataProvider=${docsJokeInputFilterKey.path}
|
|
119
|
+
name="contains"
|
|
120
|
+
value="chien"
|
|
121
|
+
class="mb-4"
|
|
122
|
+
></sonic-input>
|
|
123
|
+
<docs-joke-filter-caption
|
|
124
|
+
filterProvider=${docsJokeInputFilterKey.path}
|
|
125
|
+
field="contains"
|
|
126
|
+
label="Blagues trouvées pour"
|
|
127
|
+
></docs-joke-filter-caption>
|
|
128
|
+
<docs-joke-queue
|
|
129
|
+
filterProvider=${docsJokeInputFilterKey.path}
|
|
130
|
+
expression="joke/Any?amount=10&lang=fr"
|
|
131
|
+
></docs-joke-queue>
|
|
132
|
+
`;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
@customElement("docs-joke-lang-demo")
|
|
137
|
+
export class DocsJokeLangDemo extends LitElement {
|
|
138
|
+
static styles = [tailwind];
|
|
139
|
+
|
|
140
|
+
render() {
|
|
141
|
+
return html`
|
|
142
|
+
<sonic-select
|
|
143
|
+
formDataProvider=${docsJokeSelectFilterKey.path}
|
|
144
|
+
name="lang"
|
|
145
|
+
value="fr"
|
|
146
|
+
>
|
|
147
|
+
<option value="fr">fr</option>
|
|
148
|
+
<option value="en">en</option>
|
|
149
|
+
</sonic-select>
|
|
150
|
+
<docs-joke-filter-caption
|
|
151
|
+
filterProvider=${docsJokeSelectFilterKey.path}
|
|
152
|
+
field="lang"
|
|
153
|
+
label="Blagues pour la langue"
|
|
154
|
+
></docs-joke-filter-caption>
|
|
155
|
+
<docs-joke-queue
|
|
156
|
+
filterProvider=${docsJokeSelectFilterKey.path}
|
|
157
|
+
expression="joke/Any?amount=10"
|
|
158
|
+
></docs-joke-queue>
|
|
159
|
+
`;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
const jokeQueueRow = (row: JokeRow) => html`
|
|
164
|
+
<div class="border-0 border-b border-neutral-300 py-3 leading-tight">
|
|
165
|
+
<div>${row.joke}</div>
|
|
166
|
+
${row.setup ? html`<div class="font-bold">${row.setup}</div>` : nothing}
|
|
167
|
+
${row.delivery ? html`<div>${row.delivery}</div>` : nothing}
|
|
168
|
+
</div>
|
|
169
|
+
`;
|
|
170
|
+
|
|
171
|
+
const BLACKLIST_CONTROLS = html`
|
|
172
|
+
<sonic-checkbox name="blacklistFlags" value="nsfw">nsfw</sonic-checkbox>
|
|
173
|
+
<sonic-checkbox name="blacklistFlags" value="religious">religious</sonic-checkbox>
|
|
174
|
+
<sonic-checkbox name="blacklistFlags" value="political">political</sonic-checkbox>
|
|
175
|
+
<sonic-checkbox name="blacklistFlags" value="racist" checked>racist</sonic-checkbox>
|
|
176
|
+
<sonic-checkbox name="blacklistFlags" value="sexist" checked>sexist</sonic-checkbox>
|
|
177
|
+
<sonic-checkbox name="blacklistFlags" value="explicit">explicit</sonic-checkbox>
|
|
178
|
+
`;
|
|
179
|
+
|
|
180
|
+
/** Checkbox — « Remove following jokes » (blacklistFlags → mock API). */
|
|
181
|
+
@customElement("docs-joke-blacklist-demo")
|
|
182
|
+
export class DocsJokeBlacklistDemo extends LitElement {
|
|
183
|
+
static styles = [tailwind];
|
|
184
|
+
|
|
185
|
+
private items = jokeQueueRow;
|
|
186
|
+
|
|
187
|
+
render() {
|
|
188
|
+
return html`
|
|
189
|
+
<p class="my-4 block text-xl font-bold">Remove following jokes :</p>
|
|
190
|
+
<div
|
|
191
|
+
formDataProvider=${docsJokeCheckboxFilterKey.path}
|
|
192
|
+
class="mb-3 grid grid-cols-2 gap-x-6 gap-y-2 lg:grid-cols-3"
|
|
193
|
+
>
|
|
194
|
+
${BLACKLIST_CONTROLS}
|
|
195
|
+
</div>
|
|
196
|
+
<sonic-queue
|
|
197
|
+
lazyload
|
|
198
|
+
dataProviderExpression="joke/Any?offset=$offset&limit=$limit&lang=en"
|
|
199
|
+
dataFilterProvider=${docsJokeCheckboxFilterKey.path}
|
|
200
|
+
serviceURL=${DOCS_MOCK_JOKES_SERVICE}
|
|
201
|
+
key="jokes"
|
|
202
|
+
limit="5"
|
|
203
|
+
class="grid max-h-96 overflow-y-auto"
|
|
204
|
+
.items=${this.items}
|
|
205
|
+
debug
|
|
206
|
+
></sonic-queue>
|
|
207
|
+
`;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/** Radio group — same API, single `blacklistFlags` value. */
|
|
212
|
+
@customElement("docs-joke-blacklist-radio-demo")
|
|
213
|
+
export class DocsJokeBlacklistRadioDemo extends LitElement {
|
|
214
|
+
static styles = [tailwind];
|
|
215
|
+
|
|
216
|
+
private items = jokeQueueRow;
|
|
217
|
+
|
|
218
|
+
render() {
|
|
219
|
+
return html`
|
|
220
|
+
<p class="my-4 block text-xl font-bold">Remove following jokes :</p>
|
|
221
|
+
<div
|
|
222
|
+
formDataProvider=${docsJokeRadioFilterKey.path}
|
|
223
|
+
class="mb-3 grid grid-cols-2 gap-x-6 gap-y-2 lg:grid-cols-3"
|
|
224
|
+
>
|
|
225
|
+
<sonic-radio name="blacklistFlags" value="nsfw">nsfw</sonic-radio>
|
|
226
|
+
<sonic-radio name="blacklistFlags" value="religious"
|
|
227
|
+
>religious</sonic-radio
|
|
228
|
+
>
|
|
229
|
+
<sonic-radio name="blacklistFlags" value="political"
|
|
230
|
+
>political</sonic-radio
|
|
231
|
+
>
|
|
232
|
+
<sonic-radio name="blacklistFlags" value="racist" checked
|
|
233
|
+
>racist</sonic-radio
|
|
234
|
+
>
|
|
235
|
+
<sonic-radio name="blacklistFlags" value="sexist">sexist</sonic-radio>
|
|
236
|
+
<sonic-radio name="blacklistFlags" value="explicit"
|
|
237
|
+
>explicit</sonic-radio
|
|
238
|
+
>
|
|
239
|
+
</div>
|
|
240
|
+
<sonic-queue
|
|
241
|
+
lazyload
|
|
242
|
+
dataProviderExpression="joke/Any?offset=$offset&limit=$limit&lang=en"
|
|
243
|
+
dataFilterProvider="jokeFilterRadio"
|
|
244
|
+
serviceURL=${DOCS_MOCK_JOKES_SERVICE}
|
|
245
|
+
key="jokes"
|
|
246
|
+
limit="5"
|
|
247
|
+
class="grid max-h-96 overflow-y-auto"
|
|
248
|
+
.items=${this.items}
|
|
249
|
+
debug
|
|
250
|
+
></sonic-queue>
|
|
251
|
+
`;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/** Switch — same blacklist filter. */
|
|
256
|
+
@customElement("docs-joke-blacklist-switch-demo")
|
|
257
|
+
export class DocsJokeBlacklistSwitchDemo extends LitElement {
|
|
258
|
+
static styles = [tailwind];
|
|
259
|
+
|
|
260
|
+
private items = jokeQueueRow;
|
|
261
|
+
|
|
262
|
+
render() {
|
|
263
|
+
return html`
|
|
264
|
+
<p class="my-4 block text-xl font-bold">Remove following jokes :</p>
|
|
265
|
+
<div
|
|
266
|
+
formDataProvider=${docsJokeSwitchFilterKey.path}
|
|
267
|
+
class="mb-3 grid grid-cols-2 gap-x-6 gap-y-2 lg:grid-cols-3"
|
|
268
|
+
>
|
|
269
|
+
<sonic-switch name="blacklistFlags" value="nsfw">nsfw</sonic-switch>
|
|
270
|
+
<sonic-switch name="blacklistFlags" value="religious"
|
|
271
|
+
>religious</sonic-switch
|
|
272
|
+
>
|
|
273
|
+
<sonic-switch name="blacklistFlags" value="political"
|
|
274
|
+
>political</sonic-switch
|
|
275
|
+
>
|
|
276
|
+
<sonic-switch name="blacklistFlags" value="racist" checked
|
|
277
|
+
>racist</sonic-switch
|
|
278
|
+
>
|
|
279
|
+
<sonic-switch name="blacklistFlags" value="sexist">sexist</sonic-switch>
|
|
280
|
+
<sonic-switch name="blacklistFlags" value="explicit"
|
|
281
|
+
>explicit</sonic-switch
|
|
282
|
+
>
|
|
283
|
+
</div>
|
|
284
|
+
<sonic-queue
|
|
285
|
+
lazyload
|
|
286
|
+
dataProviderExpression="joke/Any?offset=$offset&limit=$limit&lang=en"
|
|
287
|
+
dataFilterProvider=${docsJokeSwitchFilterKey.path}
|
|
288
|
+
serviceURL=${DOCS_MOCK_JOKES_SERVICE}
|
|
289
|
+
key="jokes"
|
|
290
|
+
limit="5"
|
|
291
|
+
class="grid max-h-96 overflow-y-auto"
|
|
292
|
+
.items=${this.items}
|
|
293
|
+
debug
|
|
294
|
+
></sonic-queue>
|
|
295
|
+
`;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { html, LitElement, nothing } from "lit";
|
|
2
|
+
import { customElement } from "lit/decorators.js";
|
|
3
|
+
import { tailwind } from "../tailwind";
|
|
4
|
+
|
|
5
|
+
import "../../core/components/functional/list/list";
|
|
6
|
+
import "../../core/components/ui/image/image";
|
|
7
|
+
|
|
8
|
+
const GRID_PROPS = [
|
|
9
|
+
{ id: "1" },
|
|
10
|
+
{ id: "2" },
|
|
11
|
+
{ id: "3" },
|
|
12
|
+
{ id: "4" },
|
|
13
|
+
{ id: "5" },
|
|
14
|
+
{ id: "6" },
|
|
15
|
+
{ id: "7" },
|
|
16
|
+
{ id: "8" },
|
|
17
|
+
{ id: "9" },
|
|
18
|
+
];
|
|
19
|
+
|
|
20
|
+
const TEMPLATE_KEY_PROPS = [
|
|
21
|
+
{ id: "1", default: "The first template with no data-value is used" },
|
|
22
|
+
{ id: "2", default: "The second template with no data-value is used" },
|
|
23
|
+
{ id: "3", default: "Back to the first template with no data-value" },
|
|
24
|
+
{ id: "4", tpl: "custom-tpl-danger" },
|
|
25
|
+
{ id: "5", tpl: "custom-tpl-info" },
|
|
26
|
+
{ id: "6", tpl: "custom-tpl-success" },
|
|
27
|
+
{ id: "7", tpl: "Non-valid tpl name, Back to the first template with no data-value" },
|
|
28
|
+
];
|
|
29
|
+
|
|
30
|
+
const TPL_PARTS: Record<string, (item: { id: string }) => ReturnType<typeof html>> = {
|
|
31
|
+
"custom-tpl-danger": (item) => html`
|
|
32
|
+
<div class="rounded border border-danger p-2 text-danger">
|
|
33
|
+
${item.id} :
|
|
34
|
+
data-value : <b>custom-tpl-danger</b>
|
|
35
|
+
</div>
|
|
36
|
+
`,
|
|
37
|
+
"custom-tpl-info": (item) => html`
|
|
38
|
+
<div class="rounded border border-info p-2 text-info">
|
|
39
|
+
${item.id} :
|
|
40
|
+
data-value : <b>custom-tpl-info</b>
|
|
41
|
+
</div>
|
|
42
|
+
`,
|
|
43
|
+
"custom-tpl-success": (item) => html`
|
|
44
|
+
<div class="rounded border border-success p-2 text-success">
|
|
45
|
+
${item.id} :
|
|
46
|
+
data-value : <b>custom-tpl-success</b>
|
|
47
|
+
</div>
|
|
48
|
+
`,
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
@customElement("docs-list-alternate-demo")
|
|
52
|
+
export class DocsListAlternateDemo extends LitElement {
|
|
53
|
+
static styles = [tailwind];
|
|
54
|
+
|
|
55
|
+
private items = (item: { id: string }, meta: { even?: boolean }) =>
|
|
56
|
+
meta.even
|
|
57
|
+
? html`<div class="bg-neutral-100 p-3 text-center">
|
|
58
|
+
${item.id}
|
|
59
|
+
<div class="text-xs">1st template</div>
|
|
60
|
+
</div>`
|
|
61
|
+
: html`<div class="bg-neutral-100 p-3 text-center text-info">
|
|
62
|
+
${item.id}
|
|
63
|
+
<div class="text-xs">2nd template</div>
|
|
64
|
+
</div>`;
|
|
65
|
+
|
|
66
|
+
render() {
|
|
67
|
+
return html`
|
|
68
|
+
<sonic-list
|
|
69
|
+
dataProvider="listTemplateExample"
|
|
70
|
+
class="grid grid-cols-3 gap-4"
|
|
71
|
+
.props=${GRID_PROPS}
|
|
72
|
+
.items=${this.items}
|
|
73
|
+
debug
|
|
74
|
+
></sonic-list>
|
|
75
|
+
`;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
@customElement("docs-list-template-key-demo")
|
|
80
|
+
export class DocsListTemplateKeyDemo extends LitElement {
|
|
81
|
+
static styles = [tailwind];
|
|
82
|
+
|
|
83
|
+
render() {
|
|
84
|
+
let counter = -1;
|
|
85
|
+
const items = (item: (typeof TEMPLATE_KEY_PROPS)[number]) => {
|
|
86
|
+
const tplName = item.tpl;
|
|
87
|
+
const part = tplName ? TPL_PARTS[tplName] : undefined;
|
|
88
|
+
if (part) {
|
|
89
|
+
counter = -1;
|
|
90
|
+
return part(item);
|
|
91
|
+
}
|
|
92
|
+
counter++;
|
|
93
|
+
return counter % 2 === 0
|
|
94
|
+
? html`<div class="rounded border p-2 text-neutral-900">
|
|
95
|
+
${item.id} :
|
|
96
|
+
<b>First</b> template with no <b>data-value</b> attribute
|
|
97
|
+
</div>`
|
|
98
|
+
: html`<div class="rounded border p-2 text-neutral-400">
|
|
99
|
+
${item.id} :
|
|
100
|
+
<b>Second</b> template with no <b>data-value</b> attribute <br />
|
|
101
|
+
Used when it <b>follows</b> another row with <b>no tpl</b> in props
|
|
102
|
+
</div>`;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
return html`
|
|
106
|
+
<sonic-list
|
|
107
|
+
templateKey="tpl"
|
|
108
|
+
class="grid gap-3"
|
|
109
|
+
dataProvider="TemplateKeyExample"
|
|
110
|
+
.props=${TEMPLATE_KEY_PROPS}
|
|
111
|
+
.items=${items}
|
|
112
|
+
debug
|
|
113
|
+
></sonic-list>
|
|
114
|
+
`;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
@customElement("docs-list-separator-demo")
|
|
119
|
+
export class DocsListSeparatorDemo extends LitElement {
|
|
120
|
+
private items = (item: { id: string }) => html`${item.id}`;
|
|
121
|
+
private separator = () => html` 🤜 `;
|
|
122
|
+
private noItems = () =>
|
|
123
|
+
html`<p class="text-neutral-500">No items (noItems callback)</p>`;
|
|
124
|
+
|
|
125
|
+
render() {
|
|
126
|
+
return html`
|
|
127
|
+
<sonic-list
|
|
128
|
+
dataProvider="ListSeparatorDemo"
|
|
129
|
+
.props=${[{ id: "1" }, { id: "2" }, { id: "3" }]}
|
|
130
|
+
.items=${this.items}
|
|
131
|
+
.separator=${this.separator}
|
|
132
|
+
debug
|
|
133
|
+
></sonic-list>
|
|
134
|
+
<hr class="my-6 border-neutral-200" />
|
|
135
|
+
<sonic-list
|
|
136
|
+
dataProvider="ListEmptyDemo"
|
|
137
|
+
.props=${[]}
|
|
138
|
+
.items=${this.items}
|
|
139
|
+
.noItems=${this.noItems}
|
|
140
|
+
debug
|
|
141
|
+
></sonic-list>
|
|
142
|
+
`;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
@customElement("docs-list-extract-values-demo")
|
|
147
|
+
export class DocsListExtractValuesDemo extends LitElement {
|
|
148
|
+
static styles = [tailwind];
|
|
149
|
+
|
|
150
|
+
private items = (item: { key: string; value: string }) => html`
|
|
151
|
+
<div class="flex items-center gap-3">
|
|
152
|
+
<span class="w-24 font-bold">${item.key}</span>
|
|
153
|
+
<span>${item.value}</span>
|
|
154
|
+
${item.key === "avatar"
|
|
155
|
+
? html`<sonic-image
|
|
156
|
+
src=${item.value}
|
|
157
|
+
rounded="full"
|
|
158
|
+
ratio="1/1"
|
|
159
|
+
class="w-20 block"
|
|
160
|
+
></sonic-image>`
|
|
161
|
+
: nothing}
|
|
162
|
+
</div>
|
|
163
|
+
`;
|
|
164
|
+
|
|
165
|
+
render() {
|
|
166
|
+
return html`
|
|
167
|
+
<sonic-list
|
|
168
|
+
debug
|
|
169
|
+
fetch
|
|
170
|
+
serviceURL="/docs-mock-api"
|
|
171
|
+
dataProvider="list-extract-values-test"
|
|
172
|
+
endPoint="api/users/2"
|
|
173
|
+
key="data"
|
|
174
|
+
extractValues
|
|
175
|
+
.items=${this.items}
|
|
176
|
+
></sonic-list>
|
|
177
|
+
`;
|
|
178
|
+
}
|
|
179
|
+
}
|