@supersoniks/concorde 1.1.2 → 1.1.5
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 +42 -1
- package/core/components/functional/fetch/fetch.d.ts +7 -3
- package/core/components/functional/fetch/fetch.js +6 -2
- package/core/components/functional/list/list.d.ts +10 -8
- package/core/components/functional/list/list.js +18 -9
- package/core/components/functional/queue/queue.d.ts +3 -1
- package/core/components/functional/queue/queue.js +13 -4
- package/core/components/functional/router/redirect.js +1 -1
- package/core/components/functional/states/states.js +2 -0
- package/core/components/functional/submit/submit.d.ts +1 -1
- package/core/components/functional/submit/submit.js +6 -7
- 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/theme/theme-collection/core-variables.js +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/mixins/Fetcher.d.ts +8 -2
- package/core/mixins/Fetcher.js +9 -4
- package/core/mixins/Subscriber.js +4 -1
- package/core/utils/DataBindObserver.js +11 -7
- package/core/utils/PublisherProxy.d.mts +14 -0
- package/core/utils/PublisherProxy.mjs +33 -2
- package/package.json +5 -1
|
@@ -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 {};
|
|
@@ -4,36 +4,41 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
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
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import { html, LitElement,
|
|
7
|
+
import { html, LitElement, nothing } from "lit";
|
|
8
8
|
import { customElement, property } from "lit/decorators.js";
|
|
9
|
-
import { unsafeHTML } from "lit/directives/unsafe-html.js";
|
|
10
9
|
import { repeat } from "lit/directives/repeat.js";
|
|
11
10
|
import { animate } from "@lit-labs/motion";
|
|
12
11
|
import Objects from "@supersoniks/concorde/core/utils/Objects";
|
|
13
12
|
import "@supersoniks/concorde/core/components/ui/icon/icon";
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
error: "warning-circled-outline",
|
|
18
|
-
info: "info-empty",
|
|
19
|
-
};
|
|
13
|
+
import { unsafeHTML } from "lit/directives/unsafe-html.js";
|
|
14
|
+
import { styleMap } from "lit/directives/style-map.js";
|
|
15
|
+
import "./toast-item";
|
|
20
16
|
let SonicToast = class SonicToast extends LitElement {
|
|
21
17
|
constructor() {
|
|
22
18
|
super(...arguments);
|
|
23
19
|
this.toasts = [];
|
|
24
20
|
}
|
|
21
|
+
createRenderRoot() {
|
|
22
|
+
return this;
|
|
23
|
+
}
|
|
25
24
|
render() {
|
|
26
|
-
|
|
25
|
+
let styles = {
|
|
26
|
+
pointerEvents: "none",
|
|
27
|
+
width: "calc(100% - 2.5rem)",
|
|
28
|
+
maxWidth: "64ch",
|
|
29
|
+
gap: "1rem",
|
|
30
|
+
display: "flex",
|
|
31
|
+
};
|
|
32
|
+
if (window.parent == window) {
|
|
33
|
+
styles = Object.assign(Object.assign({}, styles), { position: "fixed", bottom: "1.25rem", right: "1.25rem", zIndex: "999", flexDirection: "column-reverse" });
|
|
34
|
+
}
|
|
35
|
+
// ${window.parent == window ? "fixed-area" : ""}
|
|
27
36
|
if (!this.toasts)
|
|
28
37
|
return nothing;
|
|
29
|
-
|
|
30
|
-
return html `<div
|
|
31
|
-
style=${"margin-top:" + marginTop}
|
|
32
|
-
class="sonic-toast-area ${window.parent == window ? "fixed-area" : ""}"
|
|
33
|
-
>
|
|
38
|
+
return html `<div aria-live="polite" style=${styleMap(styles)}>
|
|
34
39
|
${repeat(this.toasts, (item) => item.id, (item) => html `
|
|
35
|
-
<
|
|
36
|
-
|
|
40
|
+
<sonic-toast-item status=${item.status} ?ghost=${item.ghost} ?preserve=${item.preserve} id=${item.id}
|
|
41
|
+
@hide=${() => this.removeItem(item)}
|
|
37
42
|
${animate({
|
|
38
43
|
keyframeOptions: {
|
|
39
44
|
duration: 250,
|
|
@@ -51,22 +56,8 @@ let SonicToast = class SonicToast extends LitElement {
|
|
|
51
56
|
stabilizeOut: true,
|
|
52
57
|
})}
|
|
53
58
|
>
|
|
54
|
-
${item.
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
<div class="sonic-toast-text">
|
|
58
|
-
${item.title ? html `<div class="sonic-toast-title">${item.title}</div>` : ""}
|
|
59
|
-
${item.text ? unsafeHTML(item.text) : ""}
|
|
60
|
-
<slot></slot>
|
|
61
|
-
</div>
|
|
62
|
-
|
|
63
|
-
${true //!item.ghost
|
|
64
|
-
? html `<button class="sonic-toast-close" @click=${() => this.removeItem(item)}>
|
|
65
|
-
<sonic-icon prefix="iconoir" name="cancel"></sonic-icon>
|
|
66
|
-
</button>`
|
|
67
|
-
: ""}
|
|
68
|
-
${!item.preserve ? this.autoRemoveItem(item) : ""}
|
|
69
|
-
</div>
|
|
59
|
+
${item.text ? unsafeHTML(item.text) : ""}
|
|
60
|
+
</sonic-toast-item>
|
|
70
61
|
`)}
|
|
71
62
|
</div>`;
|
|
72
63
|
}
|
|
@@ -87,7 +78,7 @@ let SonicToast = class SonicToast extends LitElement {
|
|
|
87
78
|
// Ajoute le toast à la liste
|
|
88
79
|
let toastComponent = document.querySelector("sonic-toast");
|
|
89
80
|
const nextId = new Date().valueOf();
|
|
90
|
-
const interactiveRegExp = new RegExp(
|
|
81
|
+
const interactiveRegExp = new RegExp("</a>|</button>");
|
|
91
82
|
const hasInteractive = interactiveRegExp.test(conf.text);
|
|
92
83
|
const currentToast = {
|
|
93
84
|
id: nextId,
|
|
@@ -96,7 +87,6 @@ let SonicToast = class SonicToast extends LitElement {
|
|
|
96
87
|
status: conf.status,
|
|
97
88
|
preserve: hasInteractive ? true : conf.preserve,
|
|
98
89
|
ghost: conf.ghost,
|
|
99
|
-
marginTop: conf.marginTop,
|
|
100
90
|
};
|
|
101
91
|
if (toastComponent.toasts.length > 0) {
|
|
102
92
|
let toastA = Object.assign({}, currentToast);
|
|
@@ -113,142 +103,7 @@ let SonicToast = class SonicToast extends LitElement {
|
|
|
113
103
|
removeItem(item) {
|
|
114
104
|
this.toasts = this.toasts.filter((i) => i != item);
|
|
115
105
|
}
|
|
116
|
-
autoRemoveItem(item) {
|
|
117
|
-
setTimeout(() => {
|
|
118
|
-
this.removeItem(item);
|
|
119
|
-
}, 4200);
|
|
120
|
-
}
|
|
121
106
|
};
|
|
122
|
-
SonicToast.styles = [
|
|
123
|
-
css `
|
|
124
|
-
* {
|
|
125
|
-
box-sizing: border-box;
|
|
126
|
-
}
|
|
127
|
-
:host {
|
|
128
|
-
display: contents;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
.sonic-toast-area {
|
|
132
|
-
pointer-events: none;
|
|
133
|
-
width: calc(100% - 2.5rem);
|
|
134
|
-
max-width: 40ch;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
.fixed-area {
|
|
138
|
-
position: fixed;
|
|
139
|
-
top: 1.25rem;
|
|
140
|
-
right: 1.25rem;
|
|
141
|
-
z-index: 999;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
.sonic-toast {
|
|
145
|
-
--sc-toast-status-color: transparent;
|
|
146
|
-
position: relative;
|
|
147
|
-
pointer-events: auto;
|
|
148
|
-
background: var(--sc-base-800);
|
|
149
|
-
color: var(--sc-base);
|
|
150
|
-
box-shadow: var(--sc-shadow);
|
|
151
|
-
border-radius: var(--sc-rounded);
|
|
152
|
-
padding: 1em 2rem 1em 1em;
|
|
153
|
-
font-size: 0.85em;
|
|
154
|
-
line-height: 1.25;
|
|
155
|
-
display: flex;
|
|
156
|
-
gap: 0.5rem;
|
|
157
|
-
max-height: 10rem;
|
|
158
|
-
overflow: auto;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
.sonic-toast + .sonic-toast {
|
|
162
|
-
margin-top: 1rem;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
.sonic-toast-text {
|
|
166
|
-
align-self: center;
|
|
167
|
-
margin-top: auto;
|
|
168
|
-
margin-bottom: auto;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
::slotted(a),
|
|
172
|
-
.sonic-toast-text a {
|
|
173
|
-
color: inherit;
|
|
174
|
-
text-decoration: underline;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
/*BUTTON CLOSE*/
|
|
178
|
-
.sonic-toast-close {
|
|
179
|
-
all: unset;
|
|
180
|
-
position: absolute;
|
|
181
|
-
pointer-events:initial;
|
|
182
|
-
right: 0.5em;
|
|
183
|
-
top: 0.5em;
|
|
184
|
-
width: 1.5rem;
|
|
185
|
-
height: 1.5rem;
|
|
186
|
-
cursor: pointer;
|
|
187
|
-
display: inline-flex;
|
|
188
|
-
align-items: center;
|
|
189
|
-
justify-content: center;
|
|
190
|
-
border-radius: 50%;
|
|
191
|
-
text-align: center;
|
|
192
|
-
opacity: 0.5;
|
|
193
|
-
background: rgba(0, 0, 0, 0);
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
.sonic-toast-close:focus,
|
|
197
|
-
.sonic-toast-close:hover {
|
|
198
|
-
opacity: 1;
|
|
199
|
-
background: rgba(0, 0, 0, 0.075);
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
.sonic-toast-close svg {
|
|
203
|
-
width: 1rem;
|
|
204
|
-
height: 1rem;
|
|
205
|
-
object-fit: contain;
|
|
206
|
-
object-position: center center;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
/*Title*/
|
|
210
|
-
.sonic-toast-title {
|
|
211
|
-
font-weight: bold;
|
|
212
|
-
margin-bottom: 0.25em;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
/*STATUS*/
|
|
216
|
-
.success {
|
|
217
|
-
--sc-toast-status-color: var(--sc-success);
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
.error {
|
|
221
|
-
--sc-toast-status-color: var(--sc-danger);
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
.warning {
|
|
225
|
-
--sc-toast-status-color: var(--sc-warning);
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
.info {
|
|
229
|
-
--sc-toast-status-color: var(--sc-info);
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
.success,
|
|
233
|
-
.error,
|
|
234
|
-
.info,
|
|
235
|
-
.warning {
|
|
236
|
-
border-top: 2px solid var(--sc-toast-status-color, curentColor);
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
.info .sonic-toast-icon,
|
|
240
|
-
.error .sonic-toast-icon,
|
|
241
|
-
.success .sonic-toast-icon,
|
|
242
|
-
.warning .sonic-toast-icon {
|
|
243
|
-
color: var(--sc-toast-status-color, curentColor);
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
.ghost {
|
|
247
|
-
opacity: 0.85;
|
|
248
|
-
pointer-events: none;
|
|
249
|
-
}
|
|
250
|
-
`,
|
|
251
|
-
];
|
|
252
107
|
__decorate([
|
|
253
108
|
property({ type: Array })
|
|
254
109
|
], SonicToast.prototype, "toasts", void 0);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/core/mixins/Fetcher.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import API from "@supersoniks/concorde/core/utils/api";
|
|
2
|
+
import "../components/ui/button/button";
|
|
2
3
|
import { SubscriberInterface } from "./Subscriber";
|
|
3
4
|
declare type Constructor<T> = new (...args: any[]) => T;
|
|
4
5
|
declare const Fetcher: <T extends Constructor<SubscriberInterface>>(superClass: T) => {
|
|
@@ -36,7 +37,7 @@ declare const Fetcher: <T extends Constructor<SubscriberInterface>>(superClass:
|
|
|
36
37
|
* Elles sont ensuite injectées dans le publisher en accord avec la cible définie dans la propriété key
|
|
37
38
|
* Un Toast est affiché si le chargement échoue
|
|
38
39
|
*/
|
|
39
|
-
|
|
40
|
+
_fetchData(): Promise<void>;
|
|
40
41
|
disconnectedCallback(): void;
|
|
41
42
|
connectedCallback(): void;
|
|
42
43
|
/**
|
|
@@ -48,13 +49,18 @@ declare const Fetcher: <T extends Constructor<SubscriberInterface>>(superClass:
|
|
|
48
49
|
getAncestorAttributeValue(attributeName: string): string;
|
|
49
50
|
hasAncestorAttribute(attributeName: string): boolean;
|
|
50
51
|
querySelectorAll(selector: string): NodeListOf<Element>;
|
|
52
|
+
/**
|
|
53
|
+
* isFirstLoad vaut true jusqu'au premier chargement de données
|
|
54
|
+
*/
|
|
51
55
|
publisher: any;
|
|
52
56
|
dataProvider: String;
|
|
53
57
|
noShadowDom: string | null;
|
|
54
58
|
debug: HTMLElement | null;
|
|
55
59
|
defferedDebug: boolean | null;
|
|
56
60
|
makeShadow(props: Record<string, any>, value: any): any;
|
|
57
|
-
dispatchEvent(event: Event): void;
|
|
61
|
+
dispatchEvent(event: Event): void; /**
|
|
62
|
+
* IObserver est l'intersection observer qui permet de charger les données au scroll si l'attribut lazyload est renseigné
|
|
63
|
+
*/
|
|
58
64
|
setAttribute(name: string, value: string): void;
|
|
59
65
|
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions | undefined): void;
|
|
60
66
|
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions | undefined): void;
|
package/core/mixins/Fetcher.js
CHANGED
|
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
import { Loader } from "../components/ui/loader/loader";
|
|
11
11
|
import { SonicToast } from "../components/ui/toast/toast";
|
|
12
12
|
import API from "@supersoniks/concorde/core/utils/api";
|
|
13
|
+
import "../components/ui/button/button";
|
|
13
14
|
import Objects from "../utils/Objects";
|
|
14
15
|
const Fetcher = (superClass) => {
|
|
15
16
|
class FetcherElement extends superClass {
|
|
@@ -51,7 +52,7 @@ const Fetcher = (superClass) => {
|
|
|
51
52
|
* Elles sont ensuite injectées dans le publisher en accord avec la cible définie dans la propriété key
|
|
52
53
|
* Un Toast est affiché si le chargement échoue
|
|
53
54
|
*/
|
|
54
|
-
|
|
55
|
+
_fetchData() {
|
|
55
56
|
return __awaiter(this, void 0, void 0, function* () {
|
|
56
57
|
if (!this.isFetchEnabled)
|
|
57
58
|
return;
|
|
@@ -86,10 +87,13 @@ const Fetcher = (superClass) => {
|
|
|
86
87
|
});
|
|
87
88
|
}
|
|
88
89
|
disconnectedCallback() {
|
|
90
|
+
var _a;
|
|
89
91
|
super.disconnectedCallback();
|
|
92
|
+
(_a = this.publisher) === null || _a === void 0 ? void 0 : _a.offInvalidate(() => this._fetchData());
|
|
90
93
|
this.isFirstLoad = false;
|
|
91
94
|
}
|
|
92
95
|
connectedCallback() {
|
|
96
|
+
var _a;
|
|
93
97
|
this.noShadowDom = "";
|
|
94
98
|
if (!this.isFetchEnabled) {
|
|
95
99
|
super.connectedCallback();
|
|
@@ -101,9 +105,10 @@ const Fetcher = (superClass) => {
|
|
|
101
105
|
if (this.props) {
|
|
102
106
|
this.publisher.set(this.props);
|
|
103
107
|
}
|
|
108
|
+
(_a = this.publisher) === null || _a === void 0 ? void 0 : _a.onInvalidate(() => this._fetchData());
|
|
104
109
|
const lazyLoad = this.getAncestorAttributeValue("lazyload");
|
|
105
110
|
if (lazyLoad === null) {
|
|
106
|
-
this.
|
|
111
|
+
this._fetchData();
|
|
107
112
|
}
|
|
108
113
|
}
|
|
109
114
|
/**
|
|
@@ -131,13 +136,13 @@ const Fetcher = (superClass) => {
|
|
|
131
136
|
this.iObserver.observe(elt);
|
|
132
137
|
}
|
|
133
138
|
else if (this.isFirstLoad) {
|
|
134
|
-
this.
|
|
139
|
+
this._fetchData();
|
|
135
140
|
}
|
|
136
141
|
}
|
|
137
142
|
onIntersection(entries) {
|
|
138
143
|
for (const e of entries) {
|
|
139
144
|
if (e.isIntersecting && this.isFirstLoad) {
|
|
140
|
-
this.
|
|
145
|
+
this._fetchData();
|
|
141
146
|
}
|
|
142
147
|
}
|
|
143
148
|
}
|
|
@@ -52,6 +52,9 @@ const Subscriber = (superClass) => {
|
|
|
52
52
|
* Cela se fait à l'initialisation uniquement et n'est pas modifiable lors de la vie du composant.
|
|
53
53
|
*/
|
|
54
54
|
this.noShadowDom = null;
|
|
55
|
+
/**
|
|
56
|
+
* Permet de mapper un nom de propriété de donnée source vars une propriété du subscriber à la volée
|
|
57
|
+
*/
|
|
55
58
|
this.propertyMap = null;
|
|
56
59
|
this.title = "";
|
|
57
60
|
/**
|
|
@@ -82,7 +85,7 @@ const Subscriber = (superClass) => {
|
|
|
82
85
|
this.args = args;
|
|
83
86
|
}
|
|
84
87
|
/**
|
|
85
|
-
*
|
|
88
|
+
* retourne un objet contenant les propriétés de value + celle de props si elle ne sont pas déjà dans value.
|
|
86
89
|
*/
|
|
87
90
|
makeShadow(props, value) {
|
|
88
91
|
if (typeof value == "object" && value !== null) {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import Objects from "@supersoniks/concorde/core/utils/Objects";
|
|
2
1
|
import Format from "@supersoniks/concorde/core/utils/Format";
|
|
3
2
|
import HTML from "@supersoniks/concorde/core/utils/HTML";
|
|
4
3
|
import { PublisherManager } from "@supersoniks/concorde/core/utils/PublisherProxy.mjs";
|
|
@@ -189,9 +188,12 @@ export default class DataBindObserver {
|
|
|
189
188
|
*/
|
|
190
189
|
if (values.length == 1 && bindedVariablesDescriptor.variables[0].join(".") == expression.substring(1)) {
|
|
191
190
|
let value = values[0];
|
|
192
|
-
if (
|
|
193
|
-
|
|
194
|
-
|
|
191
|
+
if (value === null
|
|
192
|
+
// ||
|
|
193
|
+
// ( Objects.isObject(value) &&
|
|
194
|
+
// value.hasOwnProperty("__value") &&
|
|
195
|
+
// (Objects.isUndefindOrNull(value.__value) || value.__value === "") )
|
|
196
|
+
) {
|
|
195
197
|
value = "";
|
|
196
198
|
}
|
|
197
199
|
rec[propertyToUpdate] = value;
|
|
@@ -203,9 +205,11 @@ export default class DataBindObserver {
|
|
|
203
205
|
for (let i = 0; i < values.length; i++) {
|
|
204
206
|
let value = values[i];
|
|
205
207
|
let variable = bindedVariablesDescriptor.variables[i];
|
|
206
|
-
if (
|
|
207
|
-
|
|
208
|
-
|
|
208
|
+
if (value === null
|
|
209
|
+
// Objects.isObject(value) &&
|
|
210
|
+
// value.hasOwnProperty("__value") &&
|
|
211
|
+
// Objects.isUndefindOrNull(value.__value)
|
|
212
|
+
) {
|
|
209
213
|
hasUndeterminatedValue = true;
|
|
210
214
|
value = undefined;
|
|
211
215
|
}
|