@supersoniks/concorde 1.1.4 → 1.1.7
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/cli.js +6 -1
- package/core/components/functional/fetch/fetch.d.ts +9 -3
- package/core/components/functional/fetch/fetch.js +10 -2
- package/core/components/functional/list/list.d.ts +10 -8
- package/core/components/functional/list/list.js +11 -8
- package/core/components/functional/queue/queue.d.ts +2 -1
- package/core/components/functional/queue/queue.js +8 -4
- package/core/components/functional/router/redirect.js +1 -1
- package/core/components/functional/states/states.js +2 -0
- package/core/components/functional/subscriber/subscriber.d.ts +1 -0
- package/core/components/functional/subscriber/subscriber.js +4 -0
- package/core/components/ui/alert/alert.js +6 -0
- package/core/components/ui/button/button.js +4 -1
- package/core/components/ui/icon/icons.json +1 -1
- package/core/components/ui/toast/toast-item.d.ts +16 -0
- package/core/components/ui/toast/toast-item.js +243 -0
- package/core/components/ui/toast/toast.d.ts +4 -15
- package/core/components/ui/toast/toast.js +24 -169
- package/core/components/ui/toast/types.d.ts +9 -0
- package/core/components/ui/toast/types.js +1 -0
- package/core/core.js +4 -1
- package/core/mixins/Fetcher.d.ts +9 -2
- package/core/mixins/Fetcher.js +10 -4
- package/core/mixins/Subscriber.js +23 -9
- package/core/utils/DataBindObserver.d.ts +2 -0
- package/core/utils/DataBindObserver.js +28 -10
- package/core/utils/PublisherProxy.d.mts +14 -0
- package/core/utils/PublisherProxy.mjs +33 -2
- package/package.json +6 -4
package/cli.js
CHANGED
|
@@ -57,10 +57,15 @@ function enableShortPaths() {
|
|
|
57
57
|
console.log("✔️ Go and look to tsconfig.json to see generated paths");
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
|
+
|
|
60
61
|
switch (process.argv[2]) {
|
|
61
62
|
case "enable-short-paths":
|
|
62
63
|
enableShortPaths();
|
|
63
|
-
|
|
64
|
+
break;
|
|
65
|
+
case "create-concorde-ts-app":
|
|
66
|
+
createConcordeTsApp();
|
|
67
|
+
break;
|
|
68
|
+
|
|
64
69
|
default:
|
|
65
70
|
console.log("Usage: npx concorde <command>");
|
|
66
71
|
console.log("Commands:");
|
|
@@ -8,7 +8,8 @@ declare const Fetch_base: {
|
|
|
8
8
|
iObserver: IntersectionObserver | null;
|
|
9
9
|
isDefaultLoaderEnabled: boolean;
|
|
10
10
|
isFetchEnabled: boolean;
|
|
11
|
-
|
|
11
|
+
_fetchData(): Promise<void>;
|
|
12
|
+
onInvalidate: any;
|
|
12
13
|
disconnectedCallback(): void;
|
|
13
14
|
connectedCallback(): void;
|
|
14
15
|
firstUpdated(): void;
|
|
@@ -37,12 +38,17 @@ declare const Fetch_base: {
|
|
|
37
38
|
} & (new (...args: any[]) => import("@supersoniks/concorde/core/mixins/Subscriber").SubscriberInterface) & typeof LitElement;
|
|
38
39
|
/**
|
|
39
40
|
* ###Fetch charge un contenu via un appel d'api web.
|
|
40
|
-
* *
|
|
41
|
-
* *
|
|
41
|
+
* * Fetch etendsles mixins Fetcher et Subscriber
|
|
42
|
+
* * On indique notamment la route de l'api avec l'attribut `endpoint` dans la balise du composant.
|
|
43
|
+
* * Si l'attribut `endpoint` n'est pas disponible le composant utilise la valeur de `dataProvider` "ancêtre" le plus proche.
|
|
44
|
+
* * L'attribut `key` peut être renseigné pour cibler une sous partie de la donnée chargée.
|
|
45
|
+
* Par exemple si la données est `{ma:{data:{a:1,b:2}}}` on peut ecrire `key="ma.data"`. Dans ce cas la données disponible dans le composant sera `{a:1, b:2}`
|
|
42
46
|
* * Les propriétés réactives de tout composants étendant [subscriber](./?path=/docs/miscallenous-🔔-subscriber--page) avec le même dataProvider seront renseignées avec les propriétés de l'objet chargé via l'api.
|
|
43
47
|
* * L'affichage du loader peut être désactivé en ajoutant l'attribut *noLoader* à la balise du composant.
|
|
48
|
+
* * On peut appler la methode invalidate() sur son publishe pour declencher le rechargement des données
|
|
44
49
|
*/
|
|
45
50
|
export declare class Fetch extends Fetch_base {
|
|
51
|
+
noAutofill: boolean;
|
|
46
52
|
static styles: import("lit").CSSResult[];
|
|
47
53
|
render(): import("lit-html").TemplateResult<1>;
|
|
48
54
|
}
|
|
@@ -10,12 +10,20 @@ import Subscriber from "@supersoniks/concorde/core/mixins/Subscriber";
|
|
|
10
10
|
import Fetcher from "@supersoniks/concorde/core/mixins/Fetcher";
|
|
11
11
|
/**
|
|
12
12
|
* ###Fetch charge un contenu via un appel d'api web.
|
|
13
|
-
* *
|
|
14
|
-
* *
|
|
13
|
+
* * Fetch etendsles mixins Fetcher et Subscriber
|
|
14
|
+
* * On indique notamment la route de l'api avec l'attribut `endpoint` dans la balise du composant.
|
|
15
|
+
* * Si l'attribut `endpoint` n'est pas disponible le composant utilise la valeur de `dataProvider` "ancêtre" le plus proche.
|
|
16
|
+
* * L'attribut `key` peut être renseigné pour cibler une sous partie de la donnée chargée.
|
|
17
|
+
* Par exemple si la données est `{ma:{data:{a:1,b:2}}}` on peut ecrire `key="ma.data"`. Dans ce cas la données disponible dans le composant sera `{a:1, b:2}`
|
|
15
18
|
* * Les propriétés réactives de tout composants étendant [subscriber](./?path=/docs/miscallenous-🔔-subscriber--page) avec le même dataProvider seront renseignées avec les propriétés de l'objet chargé via l'api.
|
|
16
19
|
* * L'affichage du loader peut être désactivé en ajoutant l'attribut *noLoader* à la balise du composant.
|
|
20
|
+
* * On peut appler la methode invalidate() sur son publishe pour declencher le rechargement des données
|
|
17
21
|
*/
|
|
18
22
|
let Fetch = class Fetch extends Fetcher(Subscriber(LitElement)) {
|
|
23
|
+
constructor() {
|
|
24
|
+
super(...arguments);
|
|
25
|
+
this.noAutofill = true;
|
|
26
|
+
}
|
|
19
27
|
render() {
|
|
20
28
|
return html `<slot></slot>`;
|
|
21
29
|
}
|
|
@@ -10,7 +10,8 @@ declare const List_base: {
|
|
|
10
10
|
iObserver: IntersectionObserver | null;
|
|
11
11
|
isDefaultLoaderEnabled: boolean;
|
|
12
12
|
isFetchEnabled: boolean;
|
|
13
|
-
|
|
13
|
+
_fetchData(): Promise<void>;
|
|
14
|
+
onInvalidate: any;
|
|
14
15
|
disconnectedCallback(): void;
|
|
15
16
|
connectedCallback(): void;
|
|
16
17
|
firstUpdated(): void;
|
|
@@ -40,15 +41,16 @@ declare const List_base: {
|
|
|
40
41
|
/**
|
|
41
42
|
* ### List boucle sur sa propriété "props" et crée des éléments a partir des données en bouclant également sur ses templates.
|
|
42
43
|
*
|
|
43
|
-
* * Si le composant possède un attribut *fetch
|
|
44
|
-
*
|
|
45
|
-
*
|
|
44
|
+
* * Si le composant possède un attribut *fetch*, il charge un contenu via un appel d'api web comme le fait [fetch](./?path=/docs/core-components-functional-fetch--basic)
|
|
45
|
+
* * La proriété *key* (issue du fetcher) permet de cibler une propriété particulière du retour de l'api.
|
|
46
46
|
* * Chaque élément créé est englobé dans un objet [Subscriber](./?path=/docs/miscallenous-🔔-subscriber--page)
|
|
47
|
-
* un dataProvider y est associé a l'adresse suivante *dataProvider-de-la-liste$/*index-
|
|
48
|
-
* Les
|
|
47
|
+
* un dataProvider y est associé a l'adresse suivante *dataProvider-de-la-liste$/*index-de-la-ligne-courante*
|
|
48
|
+
* Les données de la ligne sont donc disponible pour les élements internes (subscribers, data-binding)
|
|
49
49
|
* * Lors du chargement un objet loader inline est affiché.
|
|
50
|
-
* * Si le résultat de la requête
|
|
51
|
-
*
|
|
50
|
+
* * Si le résultat de la requête est un objet, il est imbriqué dans un tableau pour garantir le fonctionnement.
|
|
51
|
+
* Cependant, si l'attribut `extractValues` est présent, les valeurs des propriétés de l'objet sont mises dans dans un tableau pour le rendu.
|
|
52
|
+
* * La propriété _key_ est ajoutés à la donnée de chaque item. Elle contient l'index dans le cas d'un liste simple ou la clés associée à la valeur si `extractValues` est définit.
|
|
53
|
+
* * On peut appler la methode invalidate() sur son publishe pour declencher le rechargement des données
|
|
52
54
|
*/
|
|
53
55
|
export declare class List extends List_base {
|
|
54
56
|
static styles: import("lit").CSSResult[];
|
|
@@ -18,15 +18,16 @@ import TemplatesContainer from "@supersoniks/concorde/core/mixins/TemplatesConta
|
|
|
18
18
|
/**
|
|
19
19
|
* ### List boucle sur sa propriété "props" et crée des éléments a partir des données en bouclant également sur ses templates.
|
|
20
20
|
*
|
|
21
|
-
* * Si le composant possède un attribut *fetch
|
|
22
|
-
*
|
|
23
|
-
*
|
|
21
|
+
* * Si le composant possède un attribut *fetch*, il charge un contenu via un appel d'api web comme le fait [fetch](./?path=/docs/core-components-functional-fetch--basic)
|
|
22
|
+
* * La proriété *key* (issue du fetcher) permet de cibler une propriété particulière du retour de l'api.
|
|
24
23
|
* * Chaque élément créé est englobé dans un objet [Subscriber](./?path=/docs/miscallenous-🔔-subscriber--page)
|
|
25
|
-
* un dataProvider y est associé a l'adresse suivante *dataProvider-de-la-liste$/*index-
|
|
26
|
-
* Les
|
|
24
|
+
* un dataProvider y est associé a l'adresse suivante *dataProvider-de-la-liste$/*index-de-la-ligne-courante*
|
|
25
|
+
* Les données de la ligne sont donc disponible pour les élements internes (subscribers, data-binding)
|
|
27
26
|
* * Lors du chargement un objet loader inline est affiché.
|
|
28
|
-
* * Si le résultat de la requête
|
|
29
|
-
*
|
|
27
|
+
* * Si le résultat de la requête est un objet, il est imbriqué dans un tableau pour garantir le fonctionnement.
|
|
28
|
+
* Cependant, si l'attribut `extractValues` est présent, les valeurs des propriétés de l'objet sont mises dans dans un tableau pour le rendu.
|
|
29
|
+
* * La propriété _key_ est ajoutés à la donnée de chaque item. Elle contient l'index dans le cas d'un liste simple ou la clés associée à la valeur si `extractValues` est définit.
|
|
30
|
+
* * On peut appler la methode invalidate() sur son publishe pour declencher le rechargement des données
|
|
30
31
|
*/
|
|
31
32
|
let List = class List extends Fetcher(Subscriber(TemplatesContainer(LitElement))) {
|
|
32
33
|
constructor() {
|
|
@@ -84,7 +85,9 @@ let List = class List extends Fetcher(Subscriber(TemplatesContainer(LitElement))
|
|
|
84
85
|
counter++;
|
|
85
86
|
if (hasCustomTemplate)
|
|
86
87
|
counter = -1;
|
|
87
|
-
let
|
|
88
|
+
let key = extractValues ? item.key : index;
|
|
89
|
+
let pub = this.publisher[key];
|
|
90
|
+
pub._key_ = key + "";
|
|
88
91
|
return (item &&
|
|
89
92
|
html `
|
|
90
93
|
<sonic-subscriber
|
|
@@ -10,7 +10,7 @@ declare const Queue_base: (new (...args: any[]) => import("@supersoniks/concorde
|
|
|
10
10
|
* Les valeurs renseignées dans ce publisher sont ajoutées en get à chaque requête
|
|
11
11
|
* * la proriété *key* peut être utilisé pour cibler une propriété particulière du retour de l'api.
|
|
12
12
|
*/
|
|
13
|
-
export
|
|
13
|
+
export default class Queue extends Queue_base {
|
|
14
14
|
templates: Array<HTMLTemplateElement> | null;
|
|
15
15
|
lastRequestTime: number;
|
|
16
16
|
key: String;
|
|
@@ -20,6 +20,7 @@ export declare class Queue extends Queue_base {
|
|
|
20
20
|
*/
|
|
21
21
|
targetRequestDuration: number;
|
|
22
22
|
limit: number;
|
|
23
|
+
offset: number;
|
|
23
24
|
static instanceCounter: number;
|
|
24
25
|
connectedCallback(): void;
|
|
25
26
|
filterPublisher: PublisherProxy | null;
|
|
@@ -36,6 +36,7 @@ let Queue = Queue_1 = class Queue extends Subscriber(LitElement) {
|
|
|
36
36
|
* Cette valeur est mise à jour ensuite par Queue pour chauq lot pour se rapprocher tanque possible de *targetRequestDuration*
|
|
37
37
|
*/
|
|
38
38
|
this.limit = 5;
|
|
39
|
+
this.offset = 0;
|
|
39
40
|
this.filterPublisher = null;
|
|
40
41
|
this.filterTimeoutId = undefined;
|
|
41
42
|
/**
|
|
@@ -90,7 +91,7 @@ let Queue = Queue_1 = class Queue extends Subscriber(LitElement) {
|
|
|
90
91
|
}
|
|
91
92
|
next(e) {
|
|
92
93
|
var _a, _b;
|
|
93
|
-
let offset =
|
|
94
|
+
let offset = this.offset;
|
|
94
95
|
const newTime = new Date().getTime();
|
|
95
96
|
const requestDuration = newTime - this.lastRequestTime;
|
|
96
97
|
if (e) {
|
|
@@ -102,7 +103,7 @@ let Queue = Queue_1 = class Queue extends Subscriber(LitElement) {
|
|
|
102
103
|
this.props = [];
|
|
103
104
|
}
|
|
104
105
|
else {
|
|
105
|
-
const props =
|
|
106
|
+
const props = this.props;
|
|
106
107
|
const item = props[props.length - 1];
|
|
107
108
|
offset = parseInt(item.offset.toString()) + parseInt(item.limit.toString());
|
|
108
109
|
}
|
|
@@ -124,7 +125,7 @@ let Queue = Queue_1 = class Queue extends Subscriber(LitElement) {
|
|
|
124
125
|
this.listDataProviders.push(dataProvider);
|
|
125
126
|
this.currentScrollPosition = (_b = document.scrollingElement) === null || _b === void 0 ? void 0 : _b.scrollTop;
|
|
126
127
|
this.props = [
|
|
127
|
-
...
|
|
128
|
+
...this.props,
|
|
128
129
|
{
|
|
129
130
|
id: searchParams.toString() + "/" + this.props.length,
|
|
130
131
|
dataProvider: dataProvider,
|
|
@@ -172,6 +173,9 @@ __decorate([
|
|
|
172
173
|
__decorate([
|
|
173
174
|
property()
|
|
174
175
|
], Queue.prototype, "limit", void 0);
|
|
176
|
+
__decorate([
|
|
177
|
+
property()
|
|
178
|
+
], Queue.prototype, "offset", void 0);
|
|
175
179
|
__decorate([
|
|
176
180
|
property({ type: String })
|
|
177
181
|
], Queue.prototype, "dataProviderExpression", void 0);
|
|
@@ -181,7 +185,7 @@ __decorate([
|
|
|
181
185
|
Queue = Queue_1 = __decorate([
|
|
182
186
|
customElement("sonic-queue")
|
|
183
187
|
], Queue);
|
|
184
|
-
export
|
|
188
|
+
export default Queue;
|
|
185
189
|
//Ajout pour custom-elements-manifesy pour storybook notamment
|
|
186
190
|
try {
|
|
187
191
|
customElements.define("sonic-queue", Queue);
|
|
@@ -41,7 +41,7 @@ let SonicRedirect = class SonicRedirect extends Subscriber(LitElement) {
|
|
|
41
41
|
return;
|
|
42
42
|
let onDataPath = this.getAttribute("onData").split(".");
|
|
43
43
|
let searchedData = Objects.traverse(this.props, onDataPath);
|
|
44
|
-
if (searchedData) {
|
|
44
|
+
if (searchedData && !(Objects.isObject(searchedData) && searchedData)) {
|
|
45
45
|
LocationHandler.changeFromComponent(this);
|
|
46
46
|
}
|
|
47
47
|
}
|
|
@@ -37,6 +37,7 @@ let SonicStates = class SonicStates extends Subscriber(TemplatesContainer(LitEle
|
|
|
37
37
|
}
|
|
38
38
|
connectedCallback() {
|
|
39
39
|
super.connectedCallback();
|
|
40
|
+
console.log("BB");
|
|
40
41
|
if (this.hasAttribute("data-path")) {
|
|
41
42
|
this.statePath = this.getAttribute("data-path");
|
|
42
43
|
}
|
|
@@ -64,6 +65,7 @@ let SonicStates = class SonicStates extends Subscriber(TemplatesContainer(LitEle
|
|
|
64
65
|
if ((!Array.isArray(state) && Objects.isObject(state)) || state === undefined) {
|
|
65
66
|
state = "";
|
|
66
67
|
}
|
|
68
|
+
console.log(state);
|
|
67
69
|
for (let t of this.templatePartsList) {
|
|
68
70
|
let path = t.getAttribute(this.templateValueAttribute);
|
|
69
71
|
let stateToMatch = state;
|
|
@@ -4,6 +4,7 @@ declare const SonicSubscriber_base: (new (...args: any[]) => import("@supersonik
|
|
|
4
4
|
* Voir la partie dédiée dans *MISCALLENOUS*
|
|
5
5
|
*/
|
|
6
6
|
export declare class SonicSubscriber extends SonicSubscriber_base {
|
|
7
|
+
noAutofill: boolean;
|
|
7
8
|
connectedCallback(): void;
|
|
8
9
|
render(): import("lit-html").TemplateResult<1>;
|
|
9
10
|
}
|
|
@@ -11,6 +11,10 @@ import Subscriber from "@supersoniks/concorde/core/mixins/Subscriber";
|
|
|
11
11
|
* Voir la partie dédiée dans *MISCALLENOUS*
|
|
12
12
|
*/
|
|
13
13
|
let SonicSubscriber = class SonicSubscriber extends Subscriber(LitElement) {
|
|
14
|
+
constructor() {
|
|
15
|
+
super(...arguments);
|
|
16
|
+
this.noAutofill = true;
|
|
17
|
+
}
|
|
14
18
|
connectedCallback() {
|
|
15
19
|
this.noShadowDom = "";
|
|
16
20
|
super.connectedCallback();
|
|
@@ -103,7 +103,13 @@ Alert.styles = [
|
|
|
103
103
|
bottom: 0;
|
|
104
104
|
opacity: 0.08;
|
|
105
105
|
border-radius: var(--sc-alert-rounded);
|
|
106
|
+
pointer-events:none;
|
|
106
107
|
}
|
|
108
|
+
:host([background]) > div {
|
|
109
|
+
z-index:2;
|
|
110
|
+
position:relative;
|
|
111
|
+
}
|
|
112
|
+
|
|
107
113
|
|
|
108
114
|
/*SIZE*/
|
|
109
115
|
:host([size="xs"]) {
|
|
@@ -151,7 +151,7 @@ let Button = class Button extends FormCheckable(FormElement(Subscriber(LitElemen
|
|
|
151
151
|
<slot @slotchange=${this.onSlotChange} part="prefix" name="prefix"></slot>
|
|
152
152
|
<slot part="main" class="main-slot"></slot>
|
|
153
153
|
<slot @slotchange=${this.onSlotChange} part="suffix" name="suffix"></slot>
|
|
154
|
-
${this.loading == true ? html `<sonic-icon prefix="
|
|
154
|
+
${this.loading == true ? html `<sonic-icon prefix="feather" name="loader" class="loader"></sonic-icon>` : ""}
|
|
155
155
|
</button>
|
|
156
156
|
`;
|
|
157
157
|
return this.href
|
|
@@ -282,6 +282,9 @@ Button.styles = [
|
|
|
282
282
|
}
|
|
283
283
|
|
|
284
284
|
/*SIZE*/
|
|
285
|
+
:host([size="2xs"]) {
|
|
286
|
+
--sc-btn-fs: 0.6rem;
|
|
287
|
+
}
|
|
285
288
|
:host([size="xs"]) {
|
|
286
289
|
--sc-btn-fs: 0.75rem;
|
|
287
290
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"iconoir":{"cancel":"<svg width=\"24\" height=\"24\" stroke-width=\"1.5\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n<path d=\"M6.75827 17.2426L12.0009 12M17.2435 6.75736L12.0009 12M12.0009 12L6.75827 6.75736M12.0009 12L17.2435 17.2426\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n</svg>\n","check-circled-outline":"<svg width=\"24\" height=\"24\" stroke-width=\"1.5\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n<path d=\"M7 12.5L10 15.5L17 8.5\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n<path d=\"M12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22Z\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n</svg>\n","check":"<svg width=\"24\" height=\"24\" stroke-width=\"1.5\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n<path d=\"M5 13L9 17L19 7\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n</svg>\n","emoji-think-left":"<svg width=\"24\" height=\"24\" stroke-width=\"1.5\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n<path d=\"M10 15H7M2 12C2 17.5228 6.47715 22 12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12Z\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n<path d=\"M8.5 9C8.22386 9 8 8.77614 8 8.5C8 8.22386 8.22386 8 8.5 8C8.77614 8 9 8.22386 9 8.5C9 8.77614 8.77614 9 8.5 9Z\" fill=\"currentColor\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n<path d=\"M15.5 9C15.2239 9 15 8.77614 15 8.5C15 8.22386 15.2239 8 15.5 8C15.7761 8 16 8.22386 16 8.5C16 8.77614 15.7761 9 15.5 9Z\" fill=\"currentColor\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n</svg>\n","info-empty":"<svg width=\"24\" height=\"24\" stroke-width=\"1.5\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n<path d=\"M12 11.5V16.5\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n<path d=\"M12 7.51L12.01 7.49889\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n<path d=\"M12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22Z\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n</svg>\n","more-vert":"<svg width=\"24\" height=\"24\" stroke-width=\"1.5\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n<path d=\"M12 12.5C12.2761 12.5 12.5 12.2761 12.5 12C12.5 11.7239 12.2761 11.5 12 11.5C11.7239 11.5 11.5 11.7239 11.5 12C11.5 12.2761 11.7239 12.5 12 12.5Z\" fill=\"currentColor\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n<path d=\"M12 18.5C12.2761 18.5 12.5 18.2761 12.5 18C12.5 17.7239 12.2761 17.5 12 17.5C11.7239 17.5 11.5 17.7239 11.5 18C11.5 18.2761 11.7239 18.5 12 18.5Z\" fill=\"currentColor\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n<path d=\"M12 6.5C12.2761 6.5 12.5 6.27614 12.5 6C12.5 5.72386 12.2761 5.5 12 5.5C11.7239 5.5 11.5 5.72386 11.5 6C11.5 6.27614 11.7239 6.5 12 6.5Z\" fill=\"currentColor\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n</svg>\n","nav-arrow-down":"<svg width=\"24\" height=\"24\" stroke-width=\"1.5\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n<path d=\"M6 9L12 15L18 9\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n</svg>\n","warning-circled-outline":"<svg width=\"24\" height=\"24\" stroke-width=\"1.5\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n<path d=\"M12 7L12 13\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n<path d=\"M12 17.01L12.01 16.9989\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n<path d=\"M12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22Z\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n</svg>\n"}}
|
|
1
|
+
{"iconoir":{"cancel":"<svg width=\"24\" height=\"24\" stroke-width=\"1.5\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n<path d=\"M6.75827 17.2426L12.0009 12M17.2435 6.75736L12.0009 12M12.0009 12L6.75827 6.75736M12.0009 12L17.2435 17.2426\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n</svg>\n","check-circled-outline":"<svg width=\"24\" height=\"24\" stroke-width=\"1.5\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n<path d=\"M7 12.5L10 15.5L17 8.5\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n<path d=\"M12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22Z\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n</svg>\n","check":"<svg width=\"24\" height=\"24\" stroke-width=\"1.5\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n<path d=\"M5 13L9 17L19 7\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n</svg>\n","emoji-think-left":"<svg width=\"24\" height=\"24\" stroke-width=\"1.5\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n<path d=\"M10 15H7M2 12C2 17.5228 6.47715 22 12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12Z\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n<path d=\"M8.5 9C8.22386 9 8 8.77614 8 8.5C8 8.22386 8.22386 8 8.5 8C8.77614 8 9 8.22386 9 8.5C9 8.77614 8.77614 9 8.5 9Z\" fill=\"currentColor\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n<path d=\"M15.5 9C15.2239 9 15 8.77614 15 8.5C15 8.22386 15.2239 8 15.5 8C15.7761 8 16 8.22386 16 8.5C16 8.77614 15.7761 9 15.5 9Z\" fill=\"currentColor\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n</svg>\n","info-empty":"<svg width=\"24\" height=\"24\" stroke-width=\"1.5\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n<path d=\"M12 11.5V16.5\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n<path d=\"M12 7.51L12.01 7.49889\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n<path d=\"M12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22Z\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n</svg>\n","loader":"","more-vert":"<svg width=\"24\" height=\"24\" stroke-width=\"1.5\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n<path d=\"M12 12.5C12.2761 12.5 12.5 12.2761 12.5 12C12.5 11.7239 12.2761 11.5 12 11.5C11.7239 11.5 11.5 11.7239 11.5 12C11.5 12.2761 11.7239 12.5 12 12.5Z\" fill=\"currentColor\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n<path d=\"M12 18.5C12.2761 18.5 12.5 18.2761 12.5 18C12.5 17.7239 12.2761 17.5 12 17.5C11.7239 17.5 11.5 17.7239 11.5 18C11.5 18.2761 11.7239 18.5 12 18.5Z\" fill=\"currentColor\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n<path d=\"M12 6.5C12.2761 6.5 12.5 6.27614 12.5 6C12.5 5.72386 12.2761 5.5 12 5.5C11.7239 5.5 11.5 5.72386 11.5 6C11.5 6.27614 11.7239 6.5 12 6.5Z\" fill=\"currentColor\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n</svg>\n","nav-arrow-down":"<svg width=\"24\" height=\"24\" stroke-width=\"1.5\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n<path d=\"M6 9L12 15L18 9\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n</svg>\n","warning-circled-outline":"<svg width=\"24\" height=\"24\" stroke-width=\"1.5\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n<path d=\"M12 7L12 13\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n<path d=\"M12 17.01L12.01 16.9989\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n<path d=\"M12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22Z\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n</svg>\n"}}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { LitElement, nothing } from "lit";
|
|
2
|
+
import "./types";
|
|
3
|
+
import { ToastStatus } from "./types";
|
|
4
|
+
export declare class SonicToastItem extends LitElement {
|
|
5
|
+
static styles: import("lit").CSSResult[];
|
|
6
|
+
title: string;
|
|
7
|
+
text: string;
|
|
8
|
+
status: ToastStatus;
|
|
9
|
+
ghost: boolean;
|
|
10
|
+
preserve: boolean;
|
|
11
|
+
visible: boolean;
|
|
12
|
+
render(): import("lit-html").TemplateResult<1> | typeof nothing;
|
|
13
|
+
hide(): void;
|
|
14
|
+
show(): void;
|
|
15
|
+
autoHide(): void;
|
|
16
|
+
}
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { html, LitElement, css, nothing } from "lit";
|
|
8
|
+
import { customElement, property, state } from "lit/decorators.js";
|
|
9
|
+
import { unsafeHTML } from "lit/directives/unsafe-html.js";
|
|
10
|
+
import "./types";
|
|
11
|
+
const icon = {
|
|
12
|
+
warning: "warning-circled-outline",
|
|
13
|
+
success: "check-circled-outline",
|
|
14
|
+
error: "warning-circled-outline",
|
|
15
|
+
info: "info-empty",
|
|
16
|
+
};
|
|
17
|
+
let SonicToastItem = class SonicToastItem extends LitElement {
|
|
18
|
+
constructor() {
|
|
19
|
+
super(...arguments);
|
|
20
|
+
this.title = "";
|
|
21
|
+
this.text = "";
|
|
22
|
+
this.status = "";
|
|
23
|
+
this.ghost = false;
|
|
24
|
+
this.preserve = false;
|
|
25
|
+
this.visible = true;
|
|
26
|
+
}
|
|
27
|
+
render() {
|
|
28
|
+
if (!this.visible) {
|
|
29
|
+
return nothing;
|
|
30
|
+
}
|
|
31
|
+
return html `<div
|
|
32
|
+
class="sonic-toast ${this.status} ${this.ghost ? "ghost" : ""}"
|
|
33
|
+
|
|
34
|
+
>
|
|
35
|
+
${this.status &&
|
|
36
|
+
html `<sonic-icon prefix="iconoir" name=${icon[this.status]} class="sonic-toast-icon" size="2xl"></sonic-icon>`}
|
|
37
|
+
|
|
38
|
+
<button aria-label="Close" class="sonic-toast-close" @click=${() => this.hide()}>
|
|
39
|
+
<sonic-icon prefix="iconoir" name="cancel" size="lg"></sonic-icon>
|
|
40
|
+
</button>
|
|
41
|
+
|
|
42
|
+
<div class="sonic-toast-text">
|
|
43
|
+
${this.title ? html `<div class="sonic-toast-title">${this.title}</div>` : ""}
|
|
44
|
+
${this.text ? unsafeHTML(this.text) : ""}
|
|
45
|
+
<slot></slot>
|
|
46
|
+
</div>
|
|
47
|
+
|
|
48
|
+
${!this.preserve ? this.autoHide() : ""}
|
|
49
|
+
</div>`;
|
|
50
|
+
}
|
|
51
|
+
hide() {
|
|
52
|
+
if (!this.closest('sonic-toast')) {
|
|
53
|
+
this.visible = false;
|
|
54
|
+
}
|
|
55
|
+
this.dispatchEvent(new CustomEvent("hide", { bubbles: true }));
|
|
56
|
+
}
|
|
57
|
+
show() {
|
|
58
|
+
this.visible = true;
|
|
59
|
+
}
|
|
60
|
+
autoHide() {
|
|
61
|
+
setTimeout(() => {
|
|
62
|
+
this.hide();
|
|
63
|
+
}, 4200);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
SonicToastItem.styles = [
|
|
67
|
+
css `
|
|
68
|
+
* {
|
|
69
|
+
box-sizing: border-box;
|
|
70
|
+
}
|
|
71
|
+
:host {
|
|
72
|
+
display: block;
|
|
73
|
+
pointer-events: auto;
|
|
74
|
+
--sc-toast-status-color: transparent;
|
|
75
|
+
--sc-toast-color: var(--sc-base-content);
|
|
76
|
+
--sc-toast-bg: var(--sc-base);
|
|
77
|
+
--sc-toast-rounded: var(--sc-rounded-md);
|
|
78
|
+
--sc-toast-shadow: var(--sc-shadow-lg);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.sonic-toast-area {
|
|
82
|
+
pointer-events: none;
|
|
83
|
+
width: calc(100% - 2.5rem);
|
|
84
|
+
max-width: 64ch;
|
|
85
|
+
gap: 1rem;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.fixed-area {
|
|
89
|
+
position: fixed;
|
|
90
|
+
bottom: 1.25rem;
|
|
91
|
+
right: 1.25rem;
|
|
92
|
+
z-index: 999;
|
|
93
|
+
display: flex;
|
|
94
|
+
flex-direction: column-reverse;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.sonic-toast {
|
|
98
|
+
position: relative;
|
|
99
|
+
pointer-events: auto;
|
|
100
|
+
background: var(--sc-toast-bg);
|
|
101
|
+
color: var(--sc-toast-color);
|
|
102
|
+
box-shadow: var(--sc-toast-shadow);
|
|
103
|
+
border-radius: var(--sc-toast-rounded);
|
|
104
|
+
padding: 1em 2.5rem 1em 1em;
|
|
105
|
+
line-height: 1.25;
|
|
106
|
+
display: flex;
|
|
107
|
+
gap: 0.5rem;
|
|
108
|
+
max-height: 10rem;
|
|
109
|
+
overflow: auto;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.sonic-toast-text {
|
|
113
|
+
align-self: center;
|
|
114
|
+
margin-top: auto;
|
|
115
|
+
margin-bottom: auto;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
::slotted(a),
|
|
119
|
+
.sonic-toast-text a {
|
|
120
|
+
color: inherit;
|
|
121
|
+
text-decoration: underline;
|
|
122
|
+
text-underline-offset: 0.15rem;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/*BUTTON CLOSE*/
|
|
126
|
+
.sonic-toast-close {
|
|
127
|
+
all: unset;
|
|
128
|
+
position: absolute;
|
|
129
|
+
pointer-events: initial;
|
|
130
|
+
right: 0.5em;
|
|
131
|
+
top: 0.5em;
|
|
132
|
+
width: 1.5rem;
|
|
133
|
+
height: 1.5rem;
|
|
134
|
+
cursor: pointer;
|
|
135
|
+
display: inline-flex;
|
|
136
|
+
align-items: center;
|
|
137
|
+
justify-content: center;
|
|
138
|
+
border-radius: 50%;
|
|
139
|
+
text-align: center;
|
|
140
|
+
opacity: 0.5;
|
|
141
|
+
background: rgba(0, 0, 0, 0);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.sonic-toast-close:focus,
|
|
145
|
+
.sonic-toast-close:hover {
|
|
146
|
+
opacity: 1;
|
|
147
|
+
background: rgba(0, 0, 0, 0.075);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.sonic-toast-close svg {
|
|
151
|
+
width: 1rem;
|
|
152
|
+
height: 1rem;
|
|
153
|
+
object-fit: contain;
|
|
154
|
+
object-position: center center;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/*Title*/
|
|
158
|
+
.sonic-toast-title {
|
|
159
|
+
font-weight: bold;
|
|
160
|
+
font-size: 1.15rem;
|
|
161
|
+
margin: 0.15em 0 0.25em;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/*STATUS*/
|
|
165
|
+
.success {
|
|
166
|
+
--sc-toast-status-color: var(--sc-success);
|
|
167
|
+
--sc-toast-title-color: var(--sc-toast-status-color);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
.error {
|
|
171
|
+
--sc-toast-status-color: var(--sc-danger);
|
|
172
|
+
--sc-toast-title-color: var(--sc-toast-status-color);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
.warning {
|
|
176
|
+
--sc-toast-status-color: var(--sc-warning);
|
|
177
|
+
--sc-toast-title-color: var(--sc-toast-status-color);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
.info {
|
|
181
|
+
--sc-toast-status-color: var(--sc-info);
|
|
182
|
+
--sc-toast-title-color: var(--sc-toast-status-color);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
.success,
|
|
186
|
+
.error,
|
|
187
|
+
.info,
|
|
188
|
+
.warning {
|
|
189
|
+
border-top: 3px solid var(--sc-toast-status-color, curentColor);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
.sonic-toast:before {
|
|
193
|
+
background-color: var(--sc-toast-status-color);
|
|
194
|
+
content: "";
|
|
195
|
+
display: block;
|
|
196
|
+
position: absolute;
|
|
197
|
+
left: 0;
|
|
198
|
+
top: 0;
|
|
199
|
+
right: 0;
|
|
200
|
+
bottom: 0;
|
|
201
|
+
opacity: 0.05;
|
|
202
|
+
pointer-events: none;
|
|
203
|
+
transition: 0.2s;
|
|
204
|
+
border-radius: var(--sc-toast-status-color);
|
|
205
|
+
}
|
|
206
|
+
.sonic-toast:hover:before {
|
|
207
|
+
opacity: 0.025;
|
|
208
|
+
}
|
|
209
|
+
.info .sonic-toast-icon,
|
|
210
|
+
.error .sonic-toast-icon,
|
|
211
|
+
.success .sonic-toast-icon,
|
|
212
|
+
.warning .sonic-toast-icon {
|
|
213
|
+
color: var(--sc-toast-status-color, curentColor);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
.ghost {
|
|
217
|
+
opacity: 0.85;
|
|
218
|
+
pointer-events: none;
|
|
219
|
+
}
|
|
220
|
+
`,
|
|
221
|
+
];
|
|
222
|
+
__decorate([
|
|
223
|
+
property({ type: String })
|
|
224
|
+
], SonicToastItem.prototype, "title", void 0);
|
|
225
|
+
__decorate([
|
|
226
|
+
property({ type: String })
|
|
227
|
+
], SonicToastItem.prototype, "text", void 0);
|
|
228
|
+
__decorate([
|
|
229
|
+
property({ type: String })
|
|
230
|
+
], SonicToastItem.prototype, "status", void 0);
|
|
231
|
+
__decorate([
|
|
232
|
+
property({ type: Boolean })
|
|
233
|
+
], SonicToastItem.prototype, "ghost", void 0);
|
|
234
|
+
__decorate([
|
|
235
|
+
property({ type: Boolean })
|
|
236
|
+
], SonicToastItem.prototype, "preserve", void 0);
|
|
237
|
+
__decorate([
|
|
238
|
+
state()
|
|
239
|
+
], SonicToastItem.prototype, "visible", void 0);
|
|
240
|
+
SonicToastItem = __decorate([
|
|
241
|
+
customElement("sonic-toast-item")
|
|
242
|
+
], SonicToastItem);
|
|
243
|
+
export { SonicToastItem };
|
|
@@ -1,30 +1,19 @@
|
|
|
1
1
|
import { LitElement, nothing } from "lit";
|
|
2
2
|
import "@supersoniks/concorde/core/components/ui/icon/icon";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
id?: number;
|
|
6
|
-
text: string;
|
|
7
|
-
title?: string;
|
|
8
|
-
status?: ToastStatus;
|
|
9
|
-
preserve?: boolean;
|
|
10
|
-
ghost?: boolean;
|
|
11
|
-
marginTop?: string;
|
|
12
|
-
};
|
|
3
|
+
import "./toast-item";
|
|
4
|
+
import { Toast } from "./types";
|
|
13
5
|
export declare class SonicToast extends LitElement {
|
|
14
|
-
static styles: import("lit").CSSResult[];
|
|
15
6
|
toasts: Toast[];
|
|
7
|
+
createRenderRoot(): this;
|
|
16
8
|
render(): import("lit-html").TemplateResult<1> | typeof nothing;
|
|
17
9
|
static removeAll(): void;
|
|
18
10
|
static add(conf: Toast): {
|
|
19
11
|
id: number;
|
|
20
12
|
text: string;
|
|
21
13
|
title: string | undefined;
|
|
22
|
-
status: ToastStatus | undefined;
|
|
14
|
+
status: import("./types").ToastStatus | undefined;
|
|
23
15
|
preserve: boolean | undefined;
|
|
24
16
|
ghost: boolean | undefined;
|
|
25
|
-
marginTop: string | undefined;
|
|
26
17
|
} | null;
|
|
27
18
|
removeItem(item: Toast): void;
|
|
28
|
-
autoRemoveItem(item: Toast): void;
|
|
29
19
|
}
|
|
30
|
-
export {};
|