@supersoniks/concorde 2.0.2 → 2.0.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/README.md +1 -0
- package/concorde-core.bundle.js +748 -690
- package/concorde-core.es.js +3897 -3116
- package/core/_types/types.d.ts +2 -4
- package/core/components/functional/date/date.d.ts +4 -2
- package/core/components/functional/date/date.js +28 -13
- package/core/components/functional/fetch/fetch.d.ts +9 -10
- package/core/components/functional/fetch/fetch.js +21 -5
- package/core/components/functional/list/list.d.ts +7 -10
- package/core/components/functional/list/list.js +19 -4
- package/core/components/functional/queue/queue.d.ts +3 -2
- package/core/components/functional/queue/queue.js +66 -61
- package/core/components/functional/router/router.d.ts +1 -0
- package/core/components/functional/router/router.js +12 -1
- package/core/components/functional/sdui/sdui.d.ts +2 -7
- package/core/components/functional/submit/submit.js +11 -4
- package/core/components/ui/_css/scroll.js +13 -11
- package/core/components/ui/_css/size.js +1 -1
- package/core/components/ui/alert/alert.d.ts +14 -3
- package/core/components/ui/alert/alert.js +34 -4
- package/core/components/ui/badge/badge.js +10 -3
- package/core/components/ui/button/button.d.ts +19 -10
- package/core/components/ui/button/button.js +77 -22
- package/core/components/ui/captcha/captcha.d.ts +5 -4
- package/core/components/ui/captcha/captcha.js +33 -9
- package/core/components/ui/divider/divider.d.ts +2 -0
- package/core/components/ui/divider/divider.js +17 -2
- package/core/components/ui/form/checkbox/checkbox.d.ts +24 -9
- package/core/components/ui/form/checkbox/checkbox.js +4 -6
- package/core/components/ui/form/css/form-control.js +40 -7
- package/core/components/ui/form/fieldset/fieldset.d.ts +1 -0
- package/core/components/ui/form/fieldset/fieldset.js +14 -1
- package/core/components/ui/form/fieldset/legend-description.js +3 -3
- package/core/components/ui/form/fieldset/legend.js +2 -8
- package/core/components/ui/form/input/input.d.ts +4 -5
- package/core/components/ui/form/input/input.js +17 -13
- package/core/components/ui/form/input-autocomplete/input-autocomplete.d.ts +3 -5
- package/core/components/ui/form/input-autocomplete/input-autocomplete.js +9 -9
- package/core/components/ui/form/select/select.d.ts +4 -1
- package/core/components/ui/form/select/select.js +25 -18
- package/core/components/ui/form/textarea/textarea.d.ts +4 -5
- package/core/components/ui/form/textarea/textarea.js +19 -10
- package/core/components/ui/group/group.js +3 -3
- package/core/components/ui/icon/icon.js +2 -1
- package/core/components/ui/icon/icons.d.ts +0 -4
- package/core/components/ui/icon/icons.js +3 -16
- package/core/components/ui/link/link.d.ts +5 -2
- package/core/components/ui/link/link.js +31 -2
- package/core/components/ui/loader/loader.d.ts +4 -1
- package/core/components/ui/loader/loader.js +11 -3
- package/core/components/ui/loader/styles/inline.js +14 -16
- package/core/components/ui/menu/menu-item.js +2 -1
- package/core/components/ui/menu/menu.js +6 -22
- package/core/components/ui/modal/modal-close.js +2 -1
- package/core/components/ui/modal/modal.d.ts +13 -1
- package/core/components/ui/modal/modal.js +70 -10
- package/core/components/ui/pop/pop.d.ts +9 -3
- package/core/components/ui/pop/pop.js +46 -23
- package/core/components/ui/table/table-tr.d.ts +10 -2
- package/core/components/ui/table/table-tr.js +30 -2
- package/core/components/ui/table/table.d.ts +1 -0
- package/core/components/ui/table/table.js +7 -1
- package/core/components/ui/theme/theme-collection/core-variables.js +8 -19
- package/core/components/ui/theme/theme.d.ts +6 -0
- package/core/components/ui/theme/theme.js +11 -13
- package/core/components/ui/toast/message-subscriber.d.ts +0 -8
- package/core/components/ui/toast/message-subscriber.js +0 -46
- package/core/components/ui/toast/toast-item.js +31 -40
- package/core/components/ui/toast/toast.d.ts +5 -1
- package/core/components/ui/toast/toast.js +80 -13
- package/core/components/ui/tooltip/tooltip.d.ts +3 -1
- package/core/components/ui/tooltip/tooltip.js +22 -0
- package/core/decorators/Subscriber.d.ts +3 -3
- package/core/decorators/Subscriber.js +64 -21
- package/core/directives/DataProvider.d.ts +12 -7
- package/core/directives/DataProvider.js +23 -8
- package/core/directives/Wording.d.ts +42 -0
- package/core/directives/Wording.js +202 -0
- package/core/mixins/Fetcher.d.ts +8 -11
- package/core/mixins/Fetcher.js +38 -22
- package/core/mixins/FormCheckable.d.ts +1 -4
- package/core/mixins/FormElement.d.ts +1 -0
- package/core/mixins/FormElement.js +3 -6
- package/core/mixins/FormInput.d.ts +3 -5
- package/core/mixins/FormInput.js +4 -0
- package/core/mixins/Subscriber.d.ts +0 -4
- package/core/mixins/Subscriber.js +13 -89
- package/core/mixins/TemplatesContainer.js +9 -0
- package/core/utils/Format.d.ts +1 -0
- package/core/utils/Format.js +16 -0
- package/core/utils/HTML.d.ts +13 -0
- package/core/utils/HTML.js +42 -3
- package/core/utils/Objects.d.ts +1 -0
- package/core/utils/Objects.js +5 -0
- package/core/utils/PublisherProxy.d.ts +16 -10
- package/core/utils/PublisherProxy.js +100 -64
- package/core/utils/Utils.d.ts +1 -0
- package/core/utils/Utils.js +5 -0
- package/core/utils/api.d.ts +26 -0
- package/core/utils/api.js +135 -3
- package/mixins.d.ts +6 -16
- package/package.json +7 -2
|
@@ -14,10 +14,6 @@ let MessageSubscriber = class MessageSubscriber extends Subscriber(LitElement, {
|
|
|
14
14
|
constructor() {
|
|
15
15
|
super(...arguments);
|
|
16
16
|
this._messages = [];
|
|
17
|
-
this.success = null;
|
|
18
|
-
this.status = null;
|
|
19
|
-
this._message = "";
|
|
20
|
-
this._data = ""; //👍 quel plaisir mmmm.... 😭😭😭
|
|
21
17
|
}
|
|
22
18
|
get messages() {
|
|
23
19
|
return this._messages;
|
|
@@ -31,55 +27,13 @@ let MessageSubscriber = class MessageSubscriber extends Subscriber(LitElement, {
|
|
|
31
27
|
SonicToast.add({ text: message.content || "", status: message.status });
|
|
32
28
|
});
|
|
33
29
|
}
|
|
34
|
-
get message() {
|
|
35
|
-
return this._message;
|
|
36
|
-
}
|
|
37
|
-
set message(value) {
|
|
38
|
-
this._message = value;
|
|
39
|
-
if (!this.message)
|
|
40
|
-
return;
|
|
41
|
-
if (this.props?.success !== false)
|
|
42
|
-
return;
|
|
43
|
-
if (this.props?.public_message)
|
|
44
|
-
return;
|
|
45
|
-
//OUi OUi il faut afficher "message" que si success est parfaitement égal à false et qu'il n'y a rien dans public_message.
|
|
46
|
-
SonicToast.add({ text: this.message, status: "error" });
|
|
47
|
-
}
|
|
48
|
-
get data() {
|
|
49
|
-
return this._data;
|
|
50
|
-
}
|
|
51
|
-
set data(value) {
|
|
52
|
-
this._data = value;
|
|
53
|
-
const toastOptions = { text: "Votre produit a bien été ajouté", status: "success" };
|
|
54
|
-
if (Array.isArray(this.data) && this.props?.success === true)
|
|
55
|
-
SonicToast.add(toastOptions);
|
|
56
|
-
if (this.data == "" && this.props?.status === true)
|
|
57
|
-
SonicToast.add(toastOptions);
|
|
58
|
-
if (this.props?.success !== false)
|
|
59
|
-
return;
|
|
60
|
-
if (this.props?.public_message)
|
|
61
|
-
return;
|
|
62
|
-
SonicToast.add({ text: this.data, status: "error" });
|
|
63
|
-
}
|
|
64
30
|
render() {
|
|
65
31
|
return nothing;
|
|
66
32
|
}
|
|
67
33
|
};
|
|
68
|
-
__decorate([
|
|
69
|
-
property({ type: Boolean })
|
|
70
|
-
], MessageSubscriber.prototype, "success", void 0);
|
|
71
|
-
__decorate([
|
|
72
|
-
property({ type: Boolean })
|
|
73
|
-
], MessageSubscriber.prototype, "status", void 0);
|
|
74
34
|
__decorate([
|
|
75
35
|
property({ type: Array })
|
|
76
36
|
], MessageSubscriber.prototype, "messages", null);
|
|
77
|
-
__decorate([
|
|
78
|
-
property({ type: String })
|
|
79
|
-
], MessageSubscriber.prototype, "message", null);
|
|
80
|
-
__decorate([
|
|
81
|
-
property()
|
|
82
|
-
], MessageSubscriber.prototype, "data", null);
|
|
83
37
|
MessageSubscriber = __decorate([
|
|
84
38
|
customElement(tagName)
|
|
85
39
|
], MessageSubscriber);
|
|
@@ -26,13 +26,15 @@ let SonicToastItem = class SonicToastItem extends LitElement {
|
|
|
26
26
|
this.ghost = false;
|
|
27
27
|
this.preserve = false;
|
|
28
28
|
this.dismissForever = false;
|
|
29
|
-
this.maxHeight =
|
|
29
|
+
this.maxHeight = "10rem";
|
|
30
30
|
this.visible = true;
|
|
31
31
|
}
|
|
32
|
+
// @queryAssignedElements({flatten: true, slot: main"})
|
|
33
|
+
// textSlot!: HTMLElement[];
|
|
32
34
|
render() {
|
|
33
35
|
// check if the toast is dismissed
|
|
34
36
|
if (this.dismissForever) {
|
|
35
|
-
const dismissed = localStorage.getItem(
|
|
37
|
+
const dismissed = localStorage.getItem("sonic-toast-dismissed") || "{}";
|
|
36
38
|
const dismissedObj = JSON.parse(dismissed);
|
|
37
39
|
if (dismissedObj[this.id]) {
|
|
38
40
|
return nothing;
|
|
@@ -41,39 +43,32 @@ let SonicToastItem = class SonicToastItem extends LitElement {
|
|
|
41
43
|
if (!this.visible) {
|
|
42
44
|
return nothing;
|
|
43
45
|
}
|
|
44
|
-
return html `<div
|
|
45
|
-
class="sonic-toast
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
${this.status &&
|
|
54
|
-
html `<sonic-icon name=${icon[this.status]} class="sonic-toast-icon" size="2xl"></sonic-icon>`}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
<div class="sonic-toast-text">
|
|
58
|
-
${this.title ? html `<div class="sonic-toast-title">${this.title}</div>` : ""}
|
|
59
|
-
${this.text ? unsafeHTML(this.text) : ""}
|
|
46
|
+
return html `<div class="sonic-toast ${this.status} ${this.ghost ? "ghost" : ""}">
|
|
47
|
+
<button aria-label="Close" class="sonic-toast-close" @click=${() => this.hide()}>
|
|
48
|
+
<sonic-icon name="cancel" size="lg"></sonic-icon>
|
|
49
|
+
</button>
|
|
50
|
+
<div class="sonic-toast-content custom-scroll" style="max-height: ${this.maxHeight} ;">
|
|
51
|
+
${this.status && html `<sonic-icon name=${icon[this.status]} class="sonic-toast-icon" size="2xl"></sonic-icon>`}
|
|
52
|
+
|
|
53
|
+
<div class="sonic-toast-text">
|
|
54
|
+
${this.title ? html `<div class="sonic-toast-title">${this.title}</div>` : ""} ${this.text ? unsafeHTML(this.text) : ""}
|
|
60
55
|
<slot></slot>
|
|
61
|
-
</div>
|
|
62
|
-
|
|
63
|
-
${!this.preserve ? this.autoHide() : ""}
|
|
64
56
|
</div>
|
|
57
|
+
|
|
58
|
+
${!this.preserve ? this.autoHide() : ""}
|
|
59
|
+
</div>
|
|
65
60
|
</div>`;
|
|
66
61
|
}
|
|
67
62
|
hide() {
|
|
68
|
-
if (!this.closest(
|
|
63
|
+
if (!this.closest("sonic-toast")) {
|
|
69
64
|
this.visible = false;
|
|
70
65
|
}
|
|
71
66
|
if (this.dismissForever) {
|
|
72
67
|
// set in local Storage an Object with the id as key and if it's dismissed as value
|
|
73
|
-
const dismissed = localStorage.getItem(
|
|
68
|
+
const dismissed = localStorage.getItem("sonic-toast-dismissed") || "{}";
|
|
74
69
|
const dismissedObj = JSON.parse(dismissed);
|
|
75
70
|
dismissedObj[this.id] = true;
|
|
76
|
-
localStorage.setItem(
|
|
71
|
+
localStorage.setItem("sonic-toast-dismissed", JSON.stringify(dismissedObj));
|
|
77
72
|
}
|
|
78
73
|
this.dispatchEvent(new CustomEvent("hide", { bubbles: true }));
|
|
79
74
|
}
|
|
@@ -83,7 +78,7 @@ let SonicToastItem = class SonicToastItem extends LitElement {
|
|
|
83
78
|
autoHide() {
|
|
84
79
|
setTimeout(() => {
|
|
85
80
|
this.hide();
|
|
86
|
-
},
|
|
81
|
+
}, 6000);
|
|
87
82
|
}
|
|
88
83
|
};
|
|
89
84
|
SonicToastItem.styles = [
|
|
@@ -115,7 +110,7 @@ SonicToastItem.styles = [
|
|
|
115
110
|
.sonic-toast {
|
|
116
111
|
position: relative;
|
|
117
112
|
pointer-events: auto;
|
|
118
|
-
overflow:hidden;
|
|
113
|
+
overflow: hidden;
|
|
119
114
|
line-height: 1.25;
|
|
120
115
|
color: var(--sc-toast-color);
|
|
121
116
|
box-shadow: var(--sc-toast-shadow);
|
|
@@ -128,14 +123,14 @@ SonicToastItem.styles = [
|
|
|
128
123
|
display: flex;
|
|
129
124
|
gap: 0.5rem;
|
|
130
125
|
overflow: auto;
|
|
131
|
-
position:relative;
|
|
132
|
-
}
|
|
126
|
+
position: relative;
|
|
127
|
+
}
|
|
133
128
|
|
|
134
129
|
.sonic-toast-text {
|
|
135
130
|
align-self: center;
|
|
136
131
|
margin-top: auto;
|
|
137
132
|
margin-bottom: auto;
|
|
138
|
-
max-width:70ch;
|
|
133
|
+
max-width: 70ch;
|
|
139
134
|
line-height: 1.2;
|
|
140
135
|
}
|
|
141
136
|
|
|
@@ -153,20 +148,19 @@ SonicToastItem.styles = [
|
|
|
153
148
|
|
|
154
149
|
::slotted(li),
|
|
155
150
|
.sonic-toast-text li {
|
|
156
|
-
margin-bottom: .15em !important;
|
|
151
|
+
margin-bottom: 0.15em !important;
|
|
157
152
|
}
|
|
158
153
|
|
|
159
|
-
::slotted(
|
|
154
|
+
::slotted(:is(p, ul, ol, hr, h1, h2, h3, h4, h5, h6):last-child),
|
|
160
155
|
.sonic-toast-text > :is(p, ul, ol, hr, h1, h2, h3, h4, h5, h6):last-child {
|
|
161
156
|
margin-bottom: 0 !important;
|
|
162
|
-
}
|
|
163
|
-
|
|
157
|
+
}
|
|
164
158
|
|
|
165
159
|
/*BUTTON CLOSE*/
|
|
166
160
|
.sonic-toast-close {
|
|
167
161
|
all: unset;
|
|
168
162
|
position: absolute;
|
|
169
|
-
z-index:4;
|
|
163
|
+
z-index: 4;
|
|
170
164
|
pointer-events: initial;
|
|
171
165
|
right: 0.5em;
|
|
172
166
|
top: 0.5em;
|
|
@@ -245,7 +239,7 @@ SonicToastItem.styles = [
|
|
|
245
239
|
border-radius: var(--sc-toast-rounded);
|
|
246
240
|
background-color: var(--sc-toast-status-color);
|
|
247
241
|
}
|
|
248
|
-
|
|
242
|
+
|
|
249
243
|
.sonic-toast:hover:before {
|
|
250
244
|
opacity: 0.025;
|
|
251
245
|
}
|
|
@@ -258,17 +252,14 @@ SonicToastItem.styles = [
|
|
|
258
252
|
}
|
|
259
253
|
|
|
260
254
|
.sonic-toast-icon {
|
|
261
|
-
position:sticky;
|
|
262
|
-
top:0;
|
|
255
|
+
position: sticky;
|
|
256
|
+
top: 0;
|
|
263
257
|
}
|
|
264
258
|
|
|
265
259
|
.ghost {
|
|
266
260
|
opacity: 0.85;
|
|
267
261
|
pointer-events: none;
|
|
268
262
|
}
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
263
|
`,
|
|
273
264
|
];
|
|
274
265
|
__decorate([
|
|
@@ -4,9 +4,12 @@ import "@supersoniks/concorde/core/components/ui/toast/toast-item";
|
|
|
4
4
|
import { Toast } from "@supersoniks/concorde/core/components/ui/toast/types";
|
|
5
5
|
export declare class SonicToast extends LitElement {
|
|
6
6
|
toasts: Toast[];
|
|
7
|
+
static delegateToasts: boolean;
|
|
7
8
|
createRenderRoot(): this;
|
|
8
9
|
render(): import("lit-html").TemplateResult<1> | typeof nothing;
|
|
9
10
|
static removeAll(): void;
|
|
11
|
+
static instance?: SonicToast;
|
|
12
|
+
static getInstance(): SonicToast;
|
|
10
13
|
static add(conf: Toast): {
|
|
11
14
|
id: string | number;
|
|
12
15
|
text: string;
|
|
@@ -15,7 +18,8 @@ export declare class SonicToast extends LitElement {
|
|
|
15
18
|
preserve: boolean | undefined;
|
|
16
19
|
ghost: boolean | undefined;
|
|
17
20
|
dismissForever: boolean | undefined;
|
|
18
|
-
} | null;
|
|
21
|
+
} | null | undefined;
|
|
22
|
+
static handleExistingToastDelegation(): void;
|
|
19
23
|
static removeItem(toastToRemove?: Toast): void;
|
|
20
24
|
removeItem(toastToRemove?: Toast): void;
|
|
21
25
|
}
|
|
@@ -4,6 +4,7 @@ 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
|
+
var SonicToast_1;
|
|
7
8
|
import { html, LitElement, nothing } from "lit";
|
|
8
9
|
import { customElement, property } from "lit/decorators.js";
|
|
9
10
|
import { repeat } from "lit/directives/repeat.js";
|
|
@@ -14,8 +15,9 @@ import { ifDefined } from "lit/directives/if-defined.js";
|
|
|
14
15
|
import { unsafeHTML } from "lit/directives/unsafe-html.js";
|
|
15
16
|
import { styleMap } from "lit/directives/style-map.js";
|
|
16
17
|
import "@supersoniks/concorde/core/components/ui/toast/toast-item";
|
|
18
|
+
import { Theme } from "@supersoniks/concorde/core/components/ui/theme/theme";
|
|
17
19
|
const tagName = "sonic-toast";
|
|
18
|
-
let SonicToast = class SonicToast extends LitElement {
|
|
20
|
+
let SonicToast = SonicToast_1 = class SonicToast extends LitElement {
|
|
19
21
|
constructor() {
|
|
20
22
|
super(...arguments);
|
|
21
23
|
this.toasts = [];
|
|
@@ -45,6 +47,7 @@ let SonicToast = class SonicToast extends LitElement {
|
|
|
45
47
|
};
|
|
46
48
|
}
|
|
47
49
|
// ${window.parent == window ? "fixed-area" : ""}
|
|
50
|
+
SonicToast_1.handleExistingToastDelegation();
|
|
48
51
|
if (!this.toasts)
|
|
49
52
|
return nothing;
|
|
50
53
|
return html `<div aria-live="polite" style=${styleMap(styles)}>
|
|
@@ -82,21 +85,32 @@ let SonicToast = class SonicToast extends LitElement {
|
|
|
82
85
|
</div>`;
|
|
83
86
|
}
|
|
84
87
|
static removeAll() {
|
|
85
|
-
|
|
88
|
+
if (SonicToast_1.delegateToasts) {
|
|
89
|
+
SonicToast_1.handleExistingToastDelegation();
|
|
90
|
+
window.parent.postMessage({ type: "removeAllToasts" }, "*");
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
const toastComponent = SonicToast_1.getInstance();
|
|
86
94
|
if (!toastComponent)
|
|
87
95
|
return;
|
|
88
96
|
toastComponent.toasts = toastComponent.toasts.filter((item) => item.ghost);
|
|
89
97
|
}
|
|
90
|
-
|
|
98
|
+
static getInstance() {
|
|
99
|
+
if (SonicToast_1.instance)
|
|
100
|
+
return SonicToast_1.instance;
|
|
101
|
+
SonicToast_1.instance = document.createElement("sonic-toast");
|
|
102
|
+
Theme.getPopContainer().prepend(SonicToast_1.instance);
|
|
103
|
+
return SonicToast_1.instance;
|
|
104
|
+
}
|
|
91
105
|
static add(conf) {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
container.prepend(toastComponent);
|
|
106
|
+
if (SonicToast_1.delegateToasts) {
|
|
107
|
+
SonicToast_1.handleExistingToastDelegation();
|
|
108
|
+
window.parent.postMessage({ type: "addToast", toast: conf }, "*");
|
|
109
|
+
return;
|
|
97
110
|
}
|
|
111
|
+
// Init toast area si absente (au <sonic-theme> ou <body< à défaut)
|
|
112
|
+
const toastComponent = SonicToast_1.getInstance();
|
|
98
113
|
// Ajoute le toast à la liste
|
|
99
|
-
const toastComponent = document.querySelector("sonic-toast");
|
|
100
114
|
const nextId = conf.id ?? new Date().valueOf();
|
|
101
115
|
const interactiveRegExp = new RegExp("</a>|</.*?button>|</.*?input>|</.*?textarea>|</.*?select>");
|
|
102
116
|
const hasInteractive = interactiveRegExp.test(conf.text);
|
|
@@ -117,7 +131,7 @@ let SonicToast = class SonicToast extends LitElement {
|
|
|
117
131
|
return null;
|
|
118
132
|
}
|
|
119
133
|
}
|
|
120
|
-
if (toastComponent
|
|
134
|
+
if (toastComponent?.toasts.length) {
|
|
121
135
|
const toastA = { ...currentToast };
|
|
122
136
|
for (const toast of toastComponent.toasts) {
|
|
123
137
|
const toastB = { ...toast };
|
|
@@ -127,11 +141,25 @@ let SonicToast = class SonicToast extends LitElement {
|
|
|
127
141
|
}
|
|
128
142
|
}
|
|
129
143
|
}
|
|
130
|
-
|
|
144
|
+
if (toastComponent) {
|
|
145
|
+
toastComponent.toasts = [...toastComponent.toasts, currentToast];
|
|
146
|
+
}
|
|
131
147
|
return currentToast;
|
|
132
148
|
}
|
|
149
|
+
static handleExistingToastDelegation() {
|
|
150
|
+
if (!this.delegateToasts)
|
|
151
|
+
return;
|
|
152
|
+
const toastComponent = SonicToast_1.getInstance();
|
|
153
|
+
window.parent.postMessage({ type: "addToasts", toasts: toastComponent.toasts }, "*");
|
|
154
|
+
toastComponent.toasts = [];
|
|
155
|
+
}
|
|
133
156
|
static removeItem(toastToRemove) {
|
|
134
|
-
|
|
157
|
+
if (SonicToast_1.delegateToasts) {
|
|
158
|
+
SonicToast_1.handleExistingToastDelegation();
|
|
159
|
+
window.parent.postMessage({ type: "removeToast", toast: toastToRemove }, "*");
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
const toastComponent = SonicToast_1.getInstance();
|
|
135
163
|
if (!toastComponent)
|
|
136
164
|
return;
|
|
137
165
|
toastComponent.removeItem(toastToRemove);
|
|
@@ -147,13 +175,52 @@ let SonicToast = class SonicToast extends LitElement {
|
|
|
147
175
|
});
|
|
148
176
|
}
|
|
149
177
|
};
|
|
178
|
+
SonicToast.delegateToasts = false;
|
|
150
179
|
__decorate([
|
|
151
180
|
property({ type: Array })
|
|
152
181
|
], SonicToast.prototype, "toasts", void 0);
|
|
153
|
-
SonicToast = __decorate([
|
|
182
|
+
SonicToast = SonicToast_1 = __decorate([
|
|
154
183
|
customElement(tagName)
|
|
155
184
|
], SonicToast);
|
|
156
185
|
export { SonicToast };
|
|
157
186
|
if (typeof window !== "undefined") {
|
|
158
187
|
window.SonicToast = SonicToast;
|
|
159
188
|
}
|
|
189
|
+
/**
|
|
190
|
+
* Handles the context of iframes and performs necessary actions based on received messages.
|
|
191
|
+
*/
|
|
192
|
+
function handleIframeContexts() {
|
|
193
|
+
const onPostMessage = (e) => {
|
|
194
|
+
if (e.data.type == "querySonicToastAvailability") {
|
|
195
|
+
e.source.postMessage({ type: "sonicToastAvailable" }, "*");
|
|
196
|
+
}
|
|
197
|
+
if (e.data.type == "sonicToastAvailable") {
|
|
198
|
+
SonicToast.delegateToasts = true;
|
|
199
|
+
SonicToast.handleExistingToastDelegation();
|
|
200
|
+
}
|
|
201
|
+
if (e.data.type == "addToasts") {
|
|
202
|
+
SonicToast.getInstance().toasts = [...SonicToast.getInstance().toasts, ...e.data.toasts];
|
|
203
|
+
}
|
|
204
|
+
if (e.data.type == "removeAllToasts") {
|
|
205
|
+
SonicToast.removeAll();
|
|
206
|
+
}
|
|
207
|
+
if (e.data.type == "removeToast") {
|
|
208
|
+
SonicToast.removeItem(e.data.toast);
|
|
209
|
+
}
|
|
210
|
+
if (e.data.type == "addToast") {
|
|
211
|
+
SonicToast.add(e.data.toast);
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
const isIframe = !(window.parent == window);
|
|
215
|
+
window.addEventListener("message", onPostMessage, false);
|
|
216
|
+
if (isIframe) {
|
|
217
|
+
window.parent.postMessage({ type: "querySonicToastAvailability" }, "*");
|
|
218
|
+
}
|
|
219
|
+
// tell iframes that sonic-toast is available
|
|
220
|
+
if (!isIframe) {
|
|
221
|
+
for (const iframe of document.querySelectorAll("iframe")) {
|
|
222
|
+
iframe.contentWindow?.postMessage({ type: "sonicToastAvailable" }, "*");
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
handleIframeContexts();
|
|
@@ -2,7 +2,9 @@ import { LitElement } from "lit";
|
|
|
2
2
|
export declare class Tooltip extends LitElement {
|
|
3
3
|
static styles: import("lit").CSSResult[];
|
|
4
4
|
label: string;
|
|
5
|
-
placement?: "top" | "bottom" | "left" | "right";
|
|
5
|
+
placement?: "top" | "top-start" | "top-end" | "bottom" | "left" | "right";
|
|
6
6
|
disabled: boolean;
|
|
7
|
+
focusable: boolean;
|
|
8
|
+
connectedCallback(): void;
|
|
7
9
|
render(): import("lit-html").TemplateResult<1>;
|
|
8
10
|
}
|
|
@@ -12,6 +12,13 @@ let Tooltip = class Tooltip extends LitElement {
|
|
|
12
12
|
super(...arguments);
|
|
13
13
|
this.label = "";
|
|
14
14
|
this.disabled = false;
|
|
15
|
+
this.focusable = false;
|
|
16
|
+
}
|
|
17
|
+
connectedCallback() {
|
|
18
|
+
if (this.focusable) {
|
|
19
|
+
this.setAttribute("tabindex", "0");
|
|
20
|
+
}
|
|
21
|
+
super.connectedCallback();
|
|
15
22
|
}
|
|
16
23
|
render() {
|
|
17
24
|
const disabledClass = this.disabled || this.label == "" ? "disabled" : "";
|
|
@@ -49,6 +56,7 @@ Tooltip.styles = [
|
|
|
49
56
|
white-space: pre-line;
|
|
50
57
|
font-weight: var(--sc-tooltip-fw);
|
|
51
58
|
}
|
|
59
|
+
:host(:focus-within) .tooltip:not(.disabled):before,
|
|
52
60
|
.tooltip:not(.disabled):hover:before {
|
|
53
61
|
opacity: 1;
|
|
54
62
|
display: block;
|
|
@@ -61,6 +69,17 @@ Tooltip.styles = [
|
|
|
61
69
|
transform: translateX(-50%);
|
|
62
70
|
}
|
|
63
71
|
|
|
72
|
+
:host([placement="top-end"]) .tooltip:before {
|
|
73
|
+
bottom: calc(100% + 0.25rem);
|
|
74
|
+
right: 0;
|
|
75
|
+
transform: translateX(0);
|
|
76
|
+
}
|
|
77
|
+
:host([placement="top-start"]) .tooltip:before {
|
|
78
|
+
bottom: calc(100% + 0.25rem);
|
|
79
|
+
left: 0;
|
|
80
|
+
transform: translateX(0);
|
|
81
|
+
}
|
|
82
|
+
|
|
64
83
|
:host([placement="bottom"]) .tooltip:before {
|
|
65
84
|
top: calc(100% + 0.25rem);
|
|
66
85
|
left: 50%;
|
|
@@ -89,6 +108,9 @@ __decorate([
|
|
|
89
108
|
__decorate([
|
|
90
109
|
property({ type: Boolean })
|
|
91
110
|
], Tooltip.prototype, "disabled", void 0);
|
|
111
|
+
__decorate([
|
|
112
|
+
property({ type: Boolean })
|
|
113
|
+
], Tooltip.prototype, "focusable", void 0);
|
|
92
114
|
Tooltip = __decorate([
|
|
93
115
|
customElement(tagName)
|
|
94
116
|
], Tooltip);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare function bind(value: string): (target:
|
|
2
|
-
export declare function onAssign(values: Array<string>): (target:
|
|
1
|
+
export declare function bind(value: string): (target: unknown, propertyKey: string) => void;
|
|
2
|
+
export declare function onAssign(...values: Array<string>): (target: unknown, _propertyKey: string, descriptor: PropertyDescriptor) => void;
|
|
3
3
|
export declare function autoSubscribe(): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
|
|
4
|
-
export declare function autoFill(values: string[]): (target:
|
|
4
|
+
export declare function autoFill(values: string[]): (target: unknown) => void;
|
|
@@ -1,4 +1,38 @@
|
|
|
1
|
-
import { Objects
|
|
1
|
+
import { Objects } from "@supersoniks/concorde/utils";
|
|
2
|
+
import { PublisherManager } from "../utils/PublisherProxy";
|
|
3
|
+
function onConnected(callback) {
|
|
4
|
+
if (!this.__connectedCallbackCalls__)
|
|
5
|
+
this.__connectedCallbackCalls__ = new Set();
|
|
6
|
+
this.__connectedCallbackCalls__.add(callback);
|
|
7
|
+
}
|
|
8
|
+
function __onDisconnected__(callback) {
|
|
9
|
+
if (!this.__disconnectedCallbackCalls__)
|
|
10
|
+
this.__disconnectedCallbackCalls__ = new Set();
|
|
11
|
+
this.__disconnectedCallbackCalls__.add(callback);
|
|
12
|
+
}
|
|
13
|
+
function setSubscribable(target) {
|
|
14
|
+
if (target.__is__setSubscribable__)
|
|
15
|
+
return;
|
|
16
|
+
target.__is__setSubscribable__ = true;
|
|
17
|
+
target.__onConnected__ = onConnected;
|
|
18
|
+
target.__onDisconnected__ = __onDisconnected__;
|
|
19
|
+
// target.offConnected = onConnected;
|
|
20
|
+
// target.offDisconnected = __onDisconnected__;
|
|
21
|
+
const originalConnectedCallback = target.connectedCallback;
|
|
22
|
+
target.connectedCallback = function () {
|
|
23
|
+
originalConnectedCallback.call(this);
|
|
24
|
+
if (this.__connectedCallbackCalls__) {
|
|
25
|
+
this.__connectedCallbackCalls__.forEach((callback) => callback(this));
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
const originalDisconnectedCallback = target.disconnectedCallback;
|
|
29
|
+
target.disconnectedCallback = function () {
|
|
30
|
+
originalDisconnectedCallback.call(this);
|
|
31
|
+
if (this.__disconnectedCallbackCalls__) {
|
|
32
|
+
this.__disconnectedCallbackCalls__.forEach((callback) => callback(this));
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
}
|
|
2
36
|
export function bind(value) {
|
|
3
37
|
const split = value.split(".");
|
|
4
38
|
if (split.length == 0) {
|
|
@@ -10,19 +44,22 @@ export function bind(value) {
|
|
|
10
44
|
let publisher = PublisherManager.get(dataProvider);
|
|
11
45
|
publisher = Objects.traverse(publisher, split);
|
|
12
46
|
return function (target, propertyKey) {
|
|
47
|
+
if (!target)
|
|
48
|
+
return;
|
|
13
49
|
let onAssign;
|
|
14
|
-
target
|
|
50
|
+
setSubscribable(target);
|
|
51
|
+
target.__onConnected__((component) => {
|
|
15
52
|
onAssign = (value) => {
|
|
16
53
|
component[propertyKey] = value;
|
|
17
54
|
};
|
|
18
55
|
publisher.onAssign(onAssign);
|
|
19
56
|
});
|
|
20
|
-
target.
|
|
57
|
+
target.__onDisconnected__(() => {
|
|
21
58
|
publisher.offAssign(onAssign);
|
|
22
59
|
});
|
|
23
60
|
};
|
|
24
61
|
}
|
|
25
|
-
export function onAssign(values) {
|
|
62
|
+
export function onAssign(...values) {
|
|
26
63
|
const onAssignValues = [];
|
|
27
64
|
const confs = [];
|
|
28
65
|
for (let i = 0; i < values.length; i++) {
|
|
@@ -42,17 +79,17 @@ export function onAssign(values) {
|
|
|
42
79
|
};
|
|
43
80
|
confs.push({ publisher, onAssign, callbacks });
|
|
44
81
|
}
|
|
45
|
-
return function (target,
|
|
46
|
-
|
|
82
|
+
return function (target, _propertyKey, descriptor) {
|
|
83
|
+
setSubscribable(target);
|
|
47
84
|
let callback;
|
|
48
|
-
target.
|
|
85
|
+
target.__onConnected__((component) => {
|
|
49
86
|
for (const conf of confs) {
|
|
50
87
|
callback = descriptor.value.bind(component);
|
|
51
88
|
conf.callbacks.add(callback);
|
|
52
89
|
conf.publisher.onAssign(conf.onAssign);
|
|
53
90
|
}
|
|
54
91
|
});
|
|
55
|
-
target.
|
|
92
|
+
target.__onDisconnected__(() => {
|
|
56
93
|
for (const conf of confs) {
|
|
57
94
|
conf.callbacks.delete(callback);
|
|
58
95
|
conf.publisher.offAssign(conf.onAssign);
|
|
@@ -62,21 +99,28 @@ export function onAssign(values) {
|
|
|
62
99
|
}
|
|
63
100
|
export function autoSubscribe() {
|
|
64
101
|
return function (target, propertyKey, descriptor) {
|
|
65
|
-
|
|
66
|
-
propertyKey;
|
|
67
|
-
if (propertyKey != "render")
|
|
68
|
-
throw new Error("autoSubscribe can only be used on render method");
|
|
102
|
+
let renderId = 0;
|
|
69
103
|
const originalMethod = descriptor.value;
|
|
70
104
|
const originalDC = target.constructor.prototype.disconnectedCallback;
|
|
71
105
|
target.constructor.prototype.disconnectedCallback = function () {
|
|
72
106
|
originalDC.apply(this);
|
|
73
107
|
this.__removeAutoSubscribe__();
|
|
74
108
|
};
|
|
109
|
+
const originalConnectedCallback = target.connectedCallback;
|
|
110
|
+
target.connectedCallback = function () {
|
|
111
|
+
originalConnectedCallback?.call(this);
|
|
112
|
+
this[propertyKey]();
|
|
113
|
+
};
|
|
75
114
|
descriptor.value = function (...args) {
|
|
76
|
-
const subscriber = this;
|
|
77
115
|
let publishers = new Set();
|
|
78
116
|
const onAssign = () => {
|
|
79
|
-
|
|
117
|
+
renderId++;
|
|
118
|
+
const id = renderId;
|
|
119
|
+
window.queueMicrotask(() => {
|
|
120
|
+
if (id !== renderId)
|
|
121
|
+
return;
|
|
122
|
+
this[propertyKey]();
|
|
123
|
+
});
|
|
80
124
|
};
|
|
81
125
|
//on désabone les publishers du rendu précédant
|
|
82
126
|
publishers.forEach((publisher) => {
|
|
@@ -100,6 +144,7 @@ export function autoSubscribe() {
|
|
|
100
144
|
}
|
|
101
145
|
export function autoFill(values) {
|
|
102
146
|
return function (target) {
|
|
147
|
+
setSubscribable(target);
|
|
103
148
|
for (const value of values) {
|
|
104
149
|
const split = value.split(".");
|
|
105
150
|
if (split.length == 0) {
|
|
@@ -108,15 +153,13 @@ export function autoFill(values) {
|
|
|
108
153
|
const dataProvider = split.shift() || "";
|
|
109
154
|
let publisher = PublisherManager.get(dataProvider);
|
|
110
155
|
publisher = Objects.traverse(publisher, split);
|
|
111
|
-
|
|
112
|
-
target.prototype.connectedCallbackCalls = new Set();
|
|
113
|
-
target.prototype.connectedCallbackCalls.add((component) => {
|
|
156
|
+
target.__onConnected__((component) => {
|
|
114
157
|
publisher.startTemplateFilling(component);
|
|
115
158
|
});
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
159
|
+
target.__onDisconnected__(() => {
|
|
160
|
+
(component) => {
|
|
161
|
+
publisher.stopTemplateFilling(component);
|
|
162
|
+
};
|
|
120
163
|
});
|
|
121
164
|
}
|
|
122
165
|
};
|
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
import { AsyncDirective } from "lit/async-directive.js";
|
|
2
|
-
|
|
2
|
+
import { PublisherProxy } from "@supersoniks/concorde/core/utils/PublisherProxy";
|
|
3
|
+
import { SearchableDomElement } from "../utils/HTML";
|
|
4
|
+
type Observable = PublisherProxy | string | (() => unknown);
|
|
3
5
|
declare class ObserveDirective extends AsyncDirective {
|
|
4
|
-
observables: Set<
|
|
6
|
+
observables: Set<PublisherProxy>;
|
|
5
7
|
unsubscribe(): void;
|
|
6
8
|
observable?: Observable;
|
|
9
|
+
node?: SearchableDomElement;
|
|
10
|
+
constructor(partInfo: any);
|
|
7
11
|
render(observable: Observable): symbol;
|
|
8
12
|
onAssign: (v: unknown) => void;
|
|
9
13
|
subscribe(observable: Observable): void;
|
|
10
14
|
disconnected(): void;
|
|
11
15
|
reconnected(): void;
|
|
12
16
|
}
|
|
13
|
-
export declare const subscribe: (observable:
|
|
14
|
-
export declare const sub: (observable:
|
|
15
|
-
export declare const get: (id:
|
|
16
|
-
export declare const dataProvider: (id: any) => any;
|
|
17
|
-
export declare const dp: (id: any) => any;
|
|
17
|
+
export declare const subscribe: (observable: Observable) => import("lit-html/directive").DirectiveResult<typeof ObserveDirective>;
|
|
18
|
+
export declare const sub: (observable: Observable) => import("lit-html/directive").DirectiveResult<typeof ObserveDirective>;
|
|
19
|
+
export declare const get: (id: Observable) => any;
|
|
20
|
+
export declare const dataProvider: (id: Observable, defaultValue?: any) => any;
|
|
21
|
+
export declare const dp: (id: Observable, defaultValue?: any) => any;
|
|
22
|
+
export declare const set: (id: Observable, value: unknown) => void;
|
|
18
23
|
export {};
|