@supersoniks/concorde 1.0.5 → 1.0.8
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 +16 -8
- package/cli.js +69 -0
- package/core/components/functional/date/date.d.ts +34 -0
- package/core/components/functional/date/date.js +187 -0
- package/core/components/functional/example/example.d.ts +7 -0
- package/core/components/functional/example/example.js +25 -0
- package/core/components/functional/fetch/fetch.d.ts +49 -0
- package/core/components/functional/fetch/fetch.js +38 -0
- package/core/components/functional/functional.d.ts +11 -0
- package/core/components/functional/functional.js +11 -0
- package/core/components/functional/if/if.d.ts +12 -0
- package/core/components/functional/if/if.js +43 -0
- package/core/components/functional/list/list.d.ts +67 -0
- package/core/components/functional/list/list.js +132 -0
- package/core/components/functional/queue/queue.d.ts +42 -0
- package/core/components/functional/queue/queue.js +184 -0
- package/core/components/functional/router/redirect.d.ts +18 -0
- package/core/components/functional/router/redirect.js +57 -0
- package/core/components/functional/router/router.d.ts +26 -0
- package/core/components/functional/router/router.js +104 -0
- package/core/components/functional/states/states.d.ts +28 -0
- package/core/components/functional/states/states.js +139 -0
- package/core/components/functional/submit/submit.d.ts +24 -0
- package/core/components/functional/submit/submit.js +108 -0
- package/{types/core/components → core/components/functional/subscriber}/subscriber.d.ts +5 -1
- package/core/components/functional/subscriber/subscriber.js +30 -0
- package/core/components/ui/alert/alert.d.ts +20 -0
- package/core/components/ui/alert/alert.js +150 -0
- package/core/components/ui/badge/badge.d.ts +24 -0
- package/core/components/ui/badge/badge.js +177 -0
- package/core/components/ui/button/button.d.ts +125 -0
- package/core/components/ui/button/button.js +558 -0
- package/core/components/ui/divider/divider.d.ts +11 -0
- package/core/components/ui/divider/divider.js +144 -0
- package/core/components/ui/form/checkbox/checkbox.d.ts +120 -0
- package/core/components/ui/form/checkbox/checkbox.js +203 -0
- package/core/components/ui/form/css/form-control.d.ts +1 -0
- package/core/components/ui/form/css/form-control.js +219 -0
- package/core/components/ui/form/fieldset/fieldset.d.ts +15 -0
- package/core/components/ui/form/fieldset/fieldset.js +70 -0
- package/core/components/ui/form/fieldset/legend.d.ts +11 -0
- package/core/components/ui/form/fieldset/legend.js +92 -0
- package/core/components/ui/form/form-layout/form-actions.d.ts +6 -0
- package/core/components/ui/form/form-layout/form-actions.js +23 -0
- package/core/components/ui/form/form-layout/form-layout.d.ts +9 -0
- package/core/components/ui/form/form-layout/form-layout.js +58 -0
- package/core/components/ui/form/input/input.d.ts +84 -0
- package/core/components/ui/form/input/input.js +180 -0
- package/core/components/ui/form/radio/radio.d.ts +12 -0
- package/core/components/ui/form/radio/radio.js +55 -0
- package/core/components/ui/form/select/select.d.ts +39 -0
- package/core/components/ui/form/select/select.js +220 -0
- package/core/components/ui/form/textarea/textarea.d.ts +69 -0
- package/core/components/ui/form/textarea/textarea.js +150 -0
- package/core/components/ui/group/group.d.ts +6 -0
- package/core/components/ui/group/group.js +57 -0
- package/core/components/ui/icon/icon.d.ts +17 -0
- package/core/components/ui/icon/icon.js +93 -0
- package/core/components/ui/icon/icons.d.ts +13 -0
- package/core/components/ui/icon/icons.js +25 -0
- package/core/components/ui/icon/icons.json +1 -0
- package/core/components/ui/image/image.d.ts +14 -0
- package/core/components/ui/image/image.js +152 -0
- package/core/components/ui/link/link.d.ts +16 -0
- package/core/components/ui/link/link.js +70 -0
- package/core/components/ui/loader/loader.d.ts +20 -0
- package/core/components/ui/loader/loader.js +94 -0
- package/{types → core}/components/ui/loader/styles/fixed.d.ts +0 -0
- package/core/components/ui/loader/styles/fixed.js +57 -0
- package/{types → core}/components/ui/loader/styles/inline.d.ts +0 -0
- package/core/components/ui/loader/styles/inline.js +71 -0
- package/core/components/ui/menu/menu-item.d.ts +5 -0
- package/core/components/ui/menu/menu-item.js +37 -0
- package/core/components/ui/menu/menu.d.ts +26 -0
- package/core/components/ui/menu/menu.js +125 -0
- package/core/components/ui/modal/modal-actions.d.ts +7 -0
- package/core/components/ui/modal/modal-actions.js +46 -0
- package/core/components/ui/modal/modal-close.d.ts +6 -0
- package/core/components/ui/modal/modal-close.js +38 -0
- package/core/components/ui/modal/modal-content.d.ts +5 -0
- package/core/components/ui/modal/modal-content.js +29 -0
- package/core/components/ui/modal/modal-subtitle.d.ts +5 -0
- package/core/components/ui/modal/modal-subtitle.js +33 -0
- package/core/components/ui/modal/modal-title.d.ts +5 -0
- package/core/components/ui/modal/modal-title.js +33 -0
- package/core/components/ui/modal/modal.d.ts +36 -0
- package/core/components/ui/modal/modal.js +325 -0
- package/core/components/ui/pop/pop.d.ts +28 -0
- package/core/components/ui/pop/pop.js +223 -0
- package/core/components/ui/tabs/tab.d.ts +6 -0
- package/core/components/ui/tabs/tab.js +46 -0
- package/core/components/ui/tabs/tabs.d.ts +14 -0
- package/core/components/ui/tabs/tabs.js +127 -0
- package/core/components/ui/taxonomy/taxonomy.d.ts +41 -0
- package/core/components/ui/taxonomy/taxonomy.js +113 -0
- package/core/components/ui/theme/css/tailwind.css +3 -0
- package/core/components/ui/theme/css/tailwind.d.ts +2 -0
- package/core/components/ui/theme/theme-collection/core-variables.d.ts +1 -0
- package/core/components/ui/theme/theme-collection/core-variables.js +50 -0
- package/{types/components → core/components/ui}/theme/theme-collection/dark.d.ts +0 -0
- package/core/components/ui/theme/theme-collection/dark.js +41 -0
- package/{types/components → core/components/ui}/theme/theme-collection/light.d.ts +0 -0
- package/core/components/ui/theme/theme-collection/light.js +35 -0
- package/core/components/ui/theme/theme.d.ts +11 -0
- package/core/components/ui/theme/theme.js +105 -0
- package/core/components/ui/toast/message-subscriber.d.ts +17 -0
- package/core/components/ui/toast/message-subscriber.js +85 -0
- package/{types → core}/components/ui/toast/toast.d.ts +10 -8
- package/core/components/ui/toast/toast.js +260 -0
- package/core/components/ui/tooltip/tooltip.d.ts +7 -0
- package/core/components/ui/tooltip/tooltip.js +68 -0
- package/core/components/ui/ui.d.ts +27 -0
- package/core/components/ui/ui.js +34 -0
- package/core/core.d.ts +3 -0
- package/core/core.js +7 -0
- package/core/mixins/Fetcher.d.ts +69 -0
- package/core/mixins/Fetcher.js +147 -0
- package/core/mixins/FormCheckable.d.ts +72 -0
- package/core/mixins/FormCheckable.js +144 -0
- package/core/mixins/FormElement.d.ts +21 -0
- package/core/mixins/FormElement.js +229 -0
- package/core/mixins/FormInput.d.ts +49 -0
- package/core/mixins/FormInput.js +33 -0
- package/core/mixins/Subscriber.d.ts +30 -0
- package/core/mixins/Subscriber.js +379 -0
- package/core/mixins/TemplatesContainer.d.ts +12 -0
- package/core/mixins/TemplatesContainer.js +60 -0
- package/core/mixins/mixins.d.ts +6 -0
- package/core/mixins/mixins.js +6 -0
- package/core/utils/Arrays.d.ts +97 -0
- package/core/utils/Arrays.js +136 -0
- package/core/utils/DataBindObserver.d.ts +74 -0
- package/core/utils/DataBindObserver.js +252 -0
- package/core/utils/Format.d.ts +11 -0
- package/core/utils/Format.js +22 -0
- package/core/utils/HTML.d.ts +13 -0
- package/core/utils/HTML.js +26 -0
- package/core/utils/LocationHandler.d.ts +44 -0
- package/core/utils/LocationHandler.js +96 -0
- package/core/utils/Objects.d.ts +23 -0
- package/core/utils/Objects.js +63 -0
- package/core/utils/PublisherProxy.d.mts +110 -0
- package/core/utils/PublisherProxy.mjs +365 -0
- package/core/utils/api.d.ts +66 -0
- package/core/utils/api.js +145 -0
- package/package.json +179 -21
- package/LICENSE +0 -43
- package/dist/concorde.bundle.js +0 -3620
- package/types/components/event/event-card/event-card.d.ts +0 -10
- package/types/components/event/event-title/event-title.d.ts +0 -7
- package/types/components/event/event.d.ts +0 -8
- package/types/components/giftcards/giftcard/giftcard.d.ts +0 -15
- package/types/components/illustration/illustration.d.ts +0 -16
- package/types/components/product/prices-form/price-button/price-button.d.ts +0 -25
- package/types/components/product/prices-form/prices-form.d.ts +0 -23
- package/types/components/theme/theme-collection/bootstrap5.d.ts +0 -1
- package/types/components/theme/theme-collection/dracula.d.ts +0 -1
- package/types/components/theme/theme.d.ts +0 -8
- package/types/components/ui/button/button.d.ts +0 -13
- package/types/components/ui/loader/loader.d.ts +0 -15
- package/types/components/ui/modal/modal.d.ts +0 -17
- package/types/components/ui/tooltip/tooltip.d.ts +0 -9
- package/types/core/components/fetch.d.ts +0 -6
- package/types/core/components/list.d.ts +0 -9
- package/types/core/components/queue.d.ts +0 -15
- package/types/core/components/taxonomy.d.ts +0 -13
- package/types/core/components/text-formatted.d.ts +0 -15
- package/types/core/components/text.d.ts +0 -9
- package/types/core/core.d.ts +0 -7
- package/types/core/mixins/Fetcher.d.ts +0 -9
- package/types/core/mixins/Subscriber.d.ts +0 -13
- package/types/core/utils/api.d.ts +0 -16
- package/types/index.d.ts +0 -12
- package/types/styles/button/button.d.ts +0 -1
- package/types/styles/prose/prose.d.ts +0 -2
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { LitElement } from "lit";
|
|
1
|
+
import { LitElement, nothing } from "lit";
|
|
2
|
+
import "@supersoniks/concorde/core/components/ui/icon/icon";
|
|
2
3
|
declare type ToastStatus = "success" | "error" | "info";
|
|
3
4
|
declare type Toast = {
|
|
4
5
|
id?: number;
|
|
@@ -6,22 +7,23 @@ declare type Toast = {
|
|
|
6
7
|
title?: string;
|
|
7
8
|
status?: ToastStatus;
|
|
8
9
|
preserve?: boolean;
|
|
9
|
-
|
|
10
|
+
ghost?: boolean;
|
|
11
|
+
marginTop?: string;
|
|
10
12
|
};
|
|
11
|
-
declare
|
|
12
|
-
export declare class SonicToast extends SonicToast_base {
|
|
13
|
+
export declare class SonicToast extends LitElement {
|
|
13
14
|
static styles: import("lit").CSSResult[];
|
|
14
15
|
toasts: Toast[];
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
render(): import("lit-html").TemplateResult<1>;
|
|
16
|
+
render(): import("lit-html").TemplateResult<1> | typeof nothing;
|
|
17
|
+
static removeAll(): void;
|
|
18
18
|
static add(conf: Toast): {
|
|
19
19
|
id: number;
|
|
20
20
|
text: string;
|
|
21
21
|
title: string | undefined;
|
|
22
22
|
status: ToastStatus | undefined;
|
|
23
23
|
preserve: boolean | undefined;
|
|
24
|
-
|
|
24
|
+
ghost: boolean | undefined;
|
|
25
|
+
marginTop: string | undefined;
|
|
26
|
+
} | null;
|
|
25
27
|
removeItem(item: Toast): void;
|
|
26
28
|
autoRemoveItem(item: Toast): void;
|
|
27
29
|
}
|
|
@@ -0,0 +1,260 @@
|
|
|
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 } from "lit/decorators.js";
|
|
9
|
+
import { unsafeHTML } from "lit/directives/unsafe-html.js";
|
|
10
|
+
import { repeat } from "lit/directives/repeat.js";
|
|
11
|
+
import { animate } from "@lit-labs/motion";
|
|
12
|
+
import Objects from "@supersoniks/concorde/core/utils/Objects";
|
|
13
|
+
import "@supersoniks/concorde/core/components/ui/icon/icon";
|
|
14
|
+
const icon = {
|
|
15
|
+
warning: "warning-circled-outline",
|
|
16
|
+
success: "check-circled-outline",
|
|
17
|
+
error: "warning-circled-outline",
|
|
18
|
+
info: "info-empty",
|
|
19
|
+
};
|
|
20
|
+
let SonicToast = class SonicToast extends LitElement {
|
|
21
|
+
constructor() {
|
|
22
|
+
super(...arguments);
|
|
23
|
+
this.toasts = [];
|
|
24
|
+
}
|
|
25
|
+
render() {
|
|
26
|
+
var _a;
|
|
27
|
+
if (!this.toasts)
|
|
28
|
+
return nothing;
|
|
29
|
+
let marginTop = ((_a = this.toasts[0]) === null || _a === void 0 ? void 0 : _a.marginTop) || "0";
|
|
30
|
+
return html `<div
|
|
31
|
+
style=${"margin-top:" + marginTop}
|
|
32
|
+
class="sonic-toast-area ${window.parent == window ? "fixed-area" : ""}"
|
|
33
|
+
>
|
|
34
|
+
${repeat(this.toasts, (item) => item.id, (item) => html `
|
|
35
|
+
<div
|
|
36
|
+
class="sonic-toast ${item.status} ${item.ghost ? "ghost" : ""}"
|
|
37
|
+
${animate({
|
|
38
|
+
keyframeOptions: {
|
|
39
|
+
duration: 250,
|
|
40
|
+
easing: `cubic-bezier(0.250, 0.250, 0.420, 1.225)`,
|
|
41
|
+
},
|
|
42
|
+
in: [{ transform: "translateY(0) scale(1.25)", boxShadow: "0 0 0 rgba(0,0,0,0)", opacity: 0 }],
|
|
43
|
+
out: [
|
|
44
|
+
{
|
|
45
|
+
transform: "scale(.90) ",
|
|
46
|
+
opacity: 0,
|
|
47
|
+
duration: 3000,
|
|
48
|
+
easing: `ease-in-out`,
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
stabilizeOut: true,
|
|
52
|
+
})}
|
|
53
|
+
>
|
|
54
|
+
${item.status &&
|
|
55
|
+
html `<sonic-icon prefix="iconoir" name=${icon[item.status]} class="sonic-toast-icon" size="2xl"></sonic-icon>`}
|
|
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>
|
|
70
|
+
`)}
|
|
71
|
+
</div>`;
|
|
72
|
+
}
|
|
73
|
+
static removeAll() {
|
|
74
|
+
let toastComponent = document.querySelector("sonic-toast");
|
|
75
|
+
if (!toastComponent)
|
|
76
|
+
return;
|
|
77
|
+
toastComponent.toasts = toastComponent.toasts.filter((item) => item.ghost);
|
|
78
|
+
}
|
|
79
|
+
// ADD TOAST
|
|
80
|
+
static add(conf) {
|
|
81
|
+
// Init toast area si absente (au <sonic-theme> ou <body< à défaut)
|
|
82
|
+
if (!document.querySelector("sonic-toast")) {
|
|
83
|
+
let toastComponent = document.createElement("sonic-toast");
|
|
84
|
+
let container = document.querySelector("sonic-theme") || document.body;
|
|
85
|
+
container.prepend(toastComponent);
|
|
86
|
+
}
|
|
87
|
+
// Ajoute le toast à la liste
|
|
88
|
+
let toastComponent = document.querySelector("sonic-toast");
|
|
89
|
+
const nextId = new Date().valueOf();
|
|
90
|
+
const currentToast = {
|
|
91
|
+
id: nextId,
|
|
92
|
+
text: conf.text,
|
|
93
|
+
title: conf.title,
|
|
94
|
+
status: conf.status,
|
|
95
|
+
preserve: conf.preserve,
|
|
96
|
+
ghost: conf.ghost,
|
|
97
|
+
marginTop: conf.marginTop,
|
|
98
|
+
};
|
|
99
|
+
if (toastComponent.toasts.length > 0) {
|
|
100
|
+
let toastA = Object.assign({}, currentToast);
|
|
101
|
+
let toastB = Object.assign({}, toastComponent.toasts[toastComponent.toasts.length - 1]);
|
|
102
|
+
toastA.id = toastB.id = 0;
|
|
103
|
+
if (!currentToast.preserve && Objects.shallowEqual(toastA, toastB)) {
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
toastComponent.toasts = [...toastComponent.toasts, currentToast];
|
|
108
|
+
return currentToast;
|
|
109
|
+
}
|
|
110
|
+
// Remove Toast
|
|
111
|
+
removeItem(item) {
|
|
112
|
+
this.toasts = this.toasts.filter((i) => i != item);
|
|
113
|
+
}
|
|
114
|
+
autoRemoveItem(item) {
|
|
115
|
+
setTimeout(() => {
|
|
116
|
+
this.removeItem(item);
|
|
117
|
+
}, 4200);
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
SonicToast.styles = [
|
|
121
|
+
css `
|
|
122
|
+
* {
|
|
123
|
+
box-sizing: border-box;
|
|
124
|
+
}
|
|
125
|
+
:host {
|
|
126
|
+
display: contents;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.sonic-toast-area {
|
|
130
|
+
pointer-events: none;
|
|
131
|
+
width: calc(100% - 2.5rem);
|
|
132
|
+
max-width: 40ch;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.fixed-area {
|
|
136
|
+
position: fixed;
|
|
137
|
+
top: 1.25rem;
|
|
138
|
+
right: 1.25rem;
|
|
139
|
+
z-index: 999;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.sonic-toast {
|
|
143
|
+
--sc-toast-status-color: transparent;
|
|
144
|
+
position: relative;
|
|
145
|
+
pointer-events: auto;
|
|
146
|
+
background: var(--sc-base-800);
|
|
147
|
+
color: var(--sc-base);
|
|
148
|
+
box-shadow: var(--sc-shadow);
|
|
149
|
+
border-radius: var(--sc-rounded);
|
|
150
|
+
padding: 1em 2rem 1em 1em;
|
|
151
|
+
font-size: 0.85em;
|
|
152
|
+
line-height: 1.25;
|
|
153
|
+
display: flex;
|
|
154
|
+
gap: 0.5rem;
|
|
155
|
+
max-height: 10rem;
|
|
156
|
+
overflow: auto;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
.sonic-toast + .sonic-toast {
|
|
160
|
+
margin-top: 1rem;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
.sonic-toast-text {
|
|
164
|
+
align-self: center;
|
|
165
|
+
margin-top: auto;
|
|
166
|
+
margin-bottom: auto;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
::slotted(a),
|
|
170
|
+
.sonic-toast-text a {
|
|
171
|
+
color: inherit;
|
|
172
|
+
text-decoration: underline;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/*BUTTON CLOSE*/
|
|
176
|
+
.sonic-toast-close {
|
|
177
|
+
all: unset;
|
|
178
|
+
position: absolute;
|
|
179
|
+
pointer-events:initial;
|
|
180
|
+
right: 0.5em;
|
|
181
|
+
top: 0.5em;
|
|
182
|
+
width: 1.5rem;
|
|
183
|
+
height: 1.5rem;
|
|
184
|
+
cursor: pointer;
|
|
185
|
+
display: inline-flex;
|
|
186
|
+
align-items: center;
|
|
187
|
+
justify-content: center;
|
|
188
|
+
border-radius: 50%;
|
|
189
|
+
text-align: center;
|
|
190
|
+
opacity: 0.5;
|
|
191
|
+
background: rgba(0, 0, 0, 0);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
.sonic-toast-close:focus,
|
|
195
|
+
.sonic-toast-close:hover {
|
|
196
|
+
opacity: 1;
|
|
197
|
+
background: rgba(0, 0, 0, 0.075);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
.sonic-toast-close svg {
|
|
201
|
+
width: 1rem;
|
|
202
|
+
height: 1rem;
|
|
203
|
+
object-fit: contain;
|
|
204
|
+
object-position: center center;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/*Title*/
|
|
208
|
+
.sonic-toast-title {
|
|
209
|
+
font-weight: bold;
|
|
210
|
+
margin-bottom: 0.25em;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/*STATUS*/
|
|
214
|
+
.success {
|
|
215
|
+
--sc-toast-status-color: var(--sc-success);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
.error {
|
|
219
|
+
--sc-toast-status-color: var(--sc-danger);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
.warning {
|
|
223
|
+
--sc-toast-status-color: var(--sc-warning);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
.info {
|
|
227
|
+
--sc-toast-status-color: var(--sc-info);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
.success,
|
|
231
|
+
.error,
|
|
232
|
+
.info,
|
|
233
|
+
.warning {
|
|
234
|
+
border-top: 2px solid var(--sc-toast-status-color, curentColor);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
.info .sonic-toast-icon,
|
|
238
|
+
.error .sonic-toast-icon,
|
|
239
|
+
.success .sonic-toast-icon,
|
|
240
|
+
.warning .sonic-toast-icon {
|
|
241
|
+
color: var(--sc-toast-status-color, curentColor);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
.ghost {
|
|
245
|
+
opacity: 0.85;
|
|
246
|
+
pointer-events: none;
|
|
247
|
+
}
|
|
248
|
+
`,
|
|
249
|
+
];
|
|
250
|
+
__decorate([
|
|
251
|
+
property({ type: Array })
|
|
252
|
+
], SonicToast.prototype, "toasts", void 0);
|
|
253
|
+
SonicToast = __decorate([
|
|
254
|
+
customElement("sonic-toast")
|
|
255
|
+
], SonicToast);
|
|
256
|
+
export { SonicToast };
|
|
257
|
+
if (typeof window !== "undefined") {
|
|
258
|
+
let win = window;
|
|
259
|
+
win.SonicToast = SonicToast;
|
|
260
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
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 } from "lit";
|
|
8
|
+
import { customElement, property } from "lit/decorators.js";
|
|
9
|
+
let Tooltip = class Tooltip extends LitElement {
|
|
10
|
+
constructor() {
|
|
11
|
+
super(...arguments);
|
|
12
|
+
this.tooltipText = "";
|
|
13
|
+
this.disabled = false;
|
|
14
|
+
}
|
|
15
|
+
render() {
|
|
16
|
+
let disabledClass = this.disabled || this.tooltipText == "" ? "disabled" : "";
|
|
17
|
+
return html `<div
|
|
18
|
+
data-tooltip-text="${this.tooltipText.trim().replace(" ", " ")}"
|
|
19
|
+
class="tooltip ${disabledClass}"
|
|
20
|
+
>
|
|
21
|
+
<slot></slot>
|
|
22
|
+
</div>`;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
Tooltip.styles = [
|
|
26
|
+
css `
|
|
27
|
+
.tooltip {
|
|
28
|
+
position: relative;
|
|
29
|
+
display: flex;
|
|
30
|
+
align-items: center;
|
|
31
|
+
text-align: center;
|
|
32
|
+
}
|
|
33
|
+
.tooltip:before {
|
|
34
|
+
position: absolute;
|
|
35
|
+
content: attr(data-tooltip-text);
|
|
36
|
+
font-size: 0.85rem;
|
|
37
|
+
display: block;
|
|
38
|
+
opacity: 0;
|
|
39
|
+
pointer-events: none;
|
|
40
|
+
bottom: calc(100% + 0.25rem);
|
|
41
|
+
left: 50%;
|
|
42
|
+
transform: translateX(-50%);
|
|
43
|
+
background: var(--sc-base-content, #111827);
|
|
44
|
+
padding: 0.25rem;
|
|
45
|
+
border-radius: 0.25rem;
|
|
46
|
+
color: var(--sc-base, #fff);
|
|
47
|
+
z-index: 999;
|
|
48
|
+
display: none;
|
|
49
|
+
line-height: 1.1;
|
|
50
|
+
width: max-content;
|
|
51
|
+
max-width: 20rem;
|
|
52
|
+
}
|
|
53
|
+
.tooltip:not(.disabled):hover:before {
|
|
54
|
+
opacity: 1;
|
|
55
|
+
display: block;
|
|
56
|
+
}
|
|
57
|
+
`,
|
|
58
|
+
];
|
|
59
|
+
__decorate([
|
|
60
|
+
property({ type: String })
|
|
61
|
+
], Tooltip.prototype, "tooltipText", void 0);
|
|
62
|
+
__decorate([
|
|
63
|
+
property({ type: Boolean })
|
|
64
|
+
], Tooltip.prototype, "disabled", void 0);
|
|
65
|
+
Tooltip = __decorate([
|
|
66
|
+
customElement("sonic-tooltip")
|
|
67
|
+
], Tooltip);
|
|
68
|
+
export { Tooltip };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import "./theme/theme";
|
|
2
|
+
import "./badge/badge";
|
|
3
|
+
import "./button/button";
|
|
4
|
+
import "./link/link";
|
|
5
|
+
import "./form/input/input";
|
|
6
|
+
import "./form/checkbox/checkbox";
|
|
7
|
+
import "./form/radio/radio";
|
|
8
|
+
import "./form/select/select";
|
|
9
|
+
import "./form/textarea/textarea";
|
|
10
|
+
import "./form/fieldset/fieldset";
|
|
11
|
+
import "./form/fieldset/legend";
|
|
12
|
+
import "./form/form-layout/form-layout";
|
|
13
|
+
import "./group/group";
|
|
14
|
+
import "./icon/icon";
|
|
15
|
+
import "./image/image";
|
|
16
|
+
import "./loader/loader";
|
|
17
|
+
import "./taxonomy/taxonomy";
|
|
18
|
+
import "./menu/menu";
|
|
19
|
+
import "./menu/menu-item";
|
|
20
|
+
import "./tabs/tabs";
|
|
21
|
+
import "./tabs/tab";
|
|
22
|
+
import "./modal/modal";
|
|
23
|
+
import "./alert/alert";
|
|
24
|
+
import "./toast/toast";
|
|
25
|
+
import "./tooltip/tooltip";
|
|
26
|
+
import "./pop/pop";
|
|
27
|
+
import "./divider/divider";
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// Theme
|
|
2
|
+
import "./theme/theme";
|
|
3
|
+
// Base
|
|
4
|
+
import "./badge/badge";
|
|
5
|
+
import "./button/button";
|
|
6
|
+
import "./link/link";
|
|
7
|
+
// FORMS
|
|
8
|
+
import "./form/input/input";
|
|
9
|
+
import "./form/checkbox/checkbox";
|
|
10
|
+
import "./form/radio/radio";
|
|
11
|
+
import "./form/select/select";
|
|
12
|
+
import "./form/textarea/textarea";
|
|
13
|
+
import "./form/fieldset/fieldset";
|
|
14
|
+
import "./form/fieldset/legend";
|
|
15
|
+
import "./form/form-layout/form-layout";
|
|
16
|
+
import "./group/group";
|
|
17
|
+
// MISC
|
|
18
|
+
import "./icon/icon";
|
|
19
|
+
import "./image/image";
|
|
20
|
+
import "./loader/loader";
|
|
21
|
+
import "./taxonomy/taxonomy";
|
|
22
|
+
//Menu
|
|
23
|
+
import "./menu/menu";
|
|
24
|
+
import "./menu/menu-item";
|
|
25
|
+
//Tabs
|
|
26
|
+
import "./tabs/tabs";
|
|
27
|
+
import "./tabs/tab";
|
|
28
|
+
// Misc
|
|
29
|
+
import "./modal/modal";
|
|
30
|
+
import "./alert/alert";
|
|
31
|
+
import "./toast/toast";
|
|
32
|
+
import "./tooltip/tooltip";
|
|
33
|
+
import "./pop/pop";
|
|
34
|
+
import "./divider/divider";
|
package/core/core.d.ts
ADDED
package/core/core.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import "./components/functional/functional";
|
|
2
|
+
import "./components/ui/ui";
|
|
3
|
+
import "./mixins/mixins";
|
|
4
|
+
import { PublisherManager } from "@supersoniks/concorde/core/utils/PublisherProxy.mjs";
|
|
5
|
+
let win = window;
|
|
6
|
+
if (!win.PublisherManager)
|
|
7
|
+
win.SonicPublisherManager = PublisherManager;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import API from "@supersoniks/concorde/core/utils/api";
|
|
2
|
+
import { SubscriberInterface } from "./Subscriber";
|
|
3
|
+
declare type Constructor<T> = new (...args: any[]) => T;
|
|
4
|
+
declare const Fetcher: <T extends Constructor<SubscriberInterface>>(superClass: T) => {
|
|
5
|
+
new (...args: any[]): {
|
|
6
|
+
api: API | null;
|
|
7
|
+
/**
|
|
8
|
+
* Après le chargement des données on traverse l'objet reçu en fonctione de la cible exprimées dans cette propriété avec la dot syntaxe.
|
|
9
|
+
* C'est cette donnée cible qui est injectée dans les pros et donc disponible via le publisher disponible globalement via PublisherManager.get(dataProvider)
|
|
10
|
+
*/
|
|
11
|
+
key: String;
|
|
12
|
+
/**
|
|
13
|
+
* isFirstLoad vaut true jusqu'au premier chargement de données
|
|
14
|
+
*/
|
|
15
|
+
isFirstLoad: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* isLoading vaut true pendant le chargement des données
|
|
18
|
+
*/
|
|
19
|
+
isLoading: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* IObserver est l'intersection observer qui permet de charger les données au scroll si l'attribut lazyload est renseigné
|
|
22
|
+
*/
|
|
23
|
+
iObserver: IntersectionObserver | null;
|
|
24
|
+
/**
|
|
25
|
+
* un loader est affiché par défaut si l'attribut noLoader n'est pas renseigné
|
|
26
|
+
*/
|
|
27
|
+
isDefaultLoaderEnabled: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* On peut désactiver le fetch programmatiquement via cette propriété.
|
|
30
|
+
* Cela est le cas pour le composant sonic-list qui ne fetch que si l'attribut fetch est renseigné
|
|
31
|
+
*/
|
|
32
|
+
isFetchEnabled: boolean;
|
|
33
|
+
/**
|
|
34
|
+
*
|
|
35
|
+
* C'est ici que les données sont chargées via l'utilitaire API
|
|
36
|
+
* Elles sont ensuite injectées dans le publisher en accord avec la cible définie dans la propriété key
|
|
37
|
+
* Un Toast est affiché si le chargement échoue
|
|
38
|
+
*/
|
|
39
|
+
_fetchEventData(): Promise<void>;
|
|
40
|
+
disconnectedCallback(): void;
|
|
41
|
+
connectedCallback(): void;
|
|
42
|
+
/**
|
|
43
|
+
* Première update, le comportement de lazyload est géré ici a l'aide d'un intersection observer.
|
|
44
|
+
*/
|
|
45
|
+
firstUpdated(): void;
|
|
46
|
+
onIntersection(entries: IntersectionObserverEntry[]): void;
|
|
47
|
+
props: any;
|
|
48
|
+
getAncestorAttributeValue(attributeName: string): string;
|
|
49
|
+
hasAncestorAttribute(attributeName: string): boolean;
|
|
50
|
+
querySelectorAll(selector: string): NodeListOf<Element>;
|
|
51
|
+
publisher: any;
|
|
52
|
+
dataProvider: String;
|
|
53
|
+
noShadowDom: string | null;
|
|
54
|
+
debug: HTMLElement | null;
|
|
55
|
+
defferedDebug: boolean | null;
|
|
56
|
+
makeShadow(props: Record<string, any>, value: any): any;
|
|
57
|
+
dispatchEvent(event: Event): void;
|
|
58
|
+
setAttribute(name: string, value: string): void;
|
|
59
|
+
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions | undefined): void;
|
|
60
|
+
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions | undefined): void;
|
|
61
|
+
removeAttribute(name: string): void;
|
|
62
|
+
initPublisher(): void;
|
|
63
|
+
getApiConfiguration(): import("@supersoniks/concorde/core/utils/api").APIConfiguration;
|
|
64
|
+
requestUpdate(): void;
|
|
65
|
+
getAttribute(name: string): string;
|
|
66
|
+
hasAttribute(attributeName: String): boolean;
|
|
67
|
+
};
|
|
68
|
+
} & T;
|
|
69
|
+
export default Fetcher;
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { Loader } from "../components/ui/loader/loader";
|
|
11
|
+
import { SonicToast } from "../components/ui/toast/toast";
|
|
12
|
+
import API from "@supersoniks/concorde/core/utils/api";
|
|
13
|
+
import Objects from "../utils/Objects";
|
|
14
|
+
const Fetcher = (superClass) => {
|
|
15
|
+
class FetcherElement extends superClass {
|
|
16
|
+
constructor(...args) {
|
|
17
|
+
super();
|
|
18
|
+
this.api = null;
|
|
19
|
+
/**
|
|
20
|
+
* Après le chargement des données on traverse l'objet reçu en fonctione de la cible exprimées dans cette propriété avec la dot syntaxe.
|
|
21
|
+
* C'est cette donnée cible qui est injectée dans les pros et donc disponible via le publisher disponible globalement via PublisherManager.get(dataProvider)
|
|
22
|
+
*/
|
|
23
|
+
this.key = "";
|
|
24
|
+
/**
|
|
25
|
+
* isFirstLoad vaut true jusqu'au premier chargement de données
|
|
26
|
+
*/
|
|
27
|
+
this.isFirstLoad = true;
|
|
28
|
+
/**
|
|
29
|
+
* isLoading vaut true pendant le chargement des données
|
|
30
|
+
*/
|
|
31
|
+
this.isLoading = false;
|
|
32
|
+
/**
|
|
33
|
+
* IObserver est l'intersection observer qui permet de charger les données au scroll si l'attribut lazyload est renseigné
|
|
34
|
+
*/
|
|
35
|
+
this.iObserver = null;
|
|
36
|
+
/**
|
|
37
|
+
* un loader est affiché par défaut si l'attribut noLoader n'est pas renseigné
|
|
38
|
+
*/
|
|
39
|
+
this.isDefaultLoaderEnabled = true;
|
|
40
|
+
/**
|
|
41
|
+
* On peut désactiver le fetch programmatiquement via cette propriété.
|
|
42
|
+
* Cela est le cas pour le composant sonic-list qui ne fetch que si l'attribut fetch est renseigné
|
|
43
|
+
*/
|
|
44
|
+
this.isFetchEnabled = true;
|
|
45
|
+
args;
|
|
46
|
+
this.dataProvider = "";
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
*
|
|
50
|
+
* C'est ici que les données sont chargées via l'utilitaire API
|
|
51
|
+
* Elles sont ensuite injectées dans le publisher en accord avec la cible définie dans la propriété key
|
|
52
|
+
* Un Toast est affiché si le chargement échoue
|
|
53
|
+
*/
|
|
54
|
+
_fetchEventData() {
|
|
55
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
56
|
+
if (!this.isFetchEnabled)
|
|
57
|
+
return;
|
|
58
|
+
if (!this.api)
|
|
59
|
+
return;
|
|
60
|
+
if (!this.dataProvider)
|
|
61
|
+
return;
|
|
62
|
+
this.dispatchEvent(new CustomEvent("loading", { detail: this }));
|
|
63
|
+
this.isLoading = true;
|
|
64
|
+
this.requestUpdate();
|
|
65
|
+
let data;
|
|
66
|
+
let hasLoader = this.isDefaultLoaderEnabled && !this.hasAttribute("noLoader");
|
|
67
|
+
if (hasLoader)
|
|
68
|
+
Loader.show();
|
|
69
|
+
data = yield this.api.get(this.getAttribute("endPoint") || this.dataProvider);
|
|
70
|
+
if (!data) {
|
|
71
|
+
SonicToast.add({ text: "Network Error", status: "error" });
|
|
72
|
+
this.isLoading = false;
|
|
73
|
+
if (hasLoader)
|
|
74
|
+
Loader.hide();
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
if (hasLoader)
|
|
78
|
+
Loader.hide();
|
|
79
|
+
if (this.key) {
|
|
80
|
+
data = Objects.traverse(data, this.key.split("."));
|
|
81
|
+
}
|
|
82
|
+
this.props = data;
|
|
83
|
+
this.dispatchEvent(new CustomEvent("load", { detail: this }));
|
|
84
|
+
this.isFirstLoad = false;
|
|
85
|
+
this.isLoading = false;
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
disconnectedCallback() {
|
|
89
|
+
super.disconnectedCallback();
|
|
90
|
+
this.isFirstLoad = false;
|
|
91
|
+
}
|
|
92
|
+
connectedCallback() {
|
|
93
|
+
this.noShadowDom = "";
|
|
94
|
+
if (!this.isFetchEnabled) {
|
|
95
|
+
super.connectedCallback();
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
super.connectedCallback();
|
|
99
|
+
this.key = this.getAncestorAttributeValue("key");
|
|
100
|
+
this.api = new API(this.getApiConfiguration());
|
|
101
|
+
if (this.props) {
|
|
102
|
+
this.publisher.set(this.props);
|
|
103
|
+
}
|
|
104
|
+
const lazyLoad = this.getAncestorAttributeValue("lazyload");
|
|
105
|
+
if (lazyLoad === null) {
|
|
106
|
+
this._fetchEventData();
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Première update, le comportement de lazyload est géré ici a l'aide d'un intersection observer.
|
|
111
|
+
*/
|
|
112
|
+
firstUpdated() {
|
|
113
|
+
const lazyLoad = this.getAncestorAttributeValue("lazyload");
|
|
114
|
+
if (lazyLoad === null) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
let options = {
|
|
118
|
+
root: null,
|
|
119
|
+
rootMargin: Math.max(window.innerWidth, window.innerHeight) + "px",
|
|
120
|
+
};
|
|
121
|
+
this.iObserver = new IntersectionObserver((entries) => this.onIntersection(entries), options);
|
|
122
|
+
let that = this;
|
|
123
|
+
let elt = that.shadowRoot ? that.shadowRoot.children[0] : that.children[0];
|
|
124
|
+
if (elt && elt.nodeName.toLocaleLowerCase() == "slot")
|
|
125
|
+
elt = elt.children[0];
|
|
126
|
+
if (!elt || elt.nodeName.toLocaleLowerCase() == "template") {
|
|
127
|
+
elt = document.createElement("span");
|
|
128
|
+
that.appendChild(elt);
|
|
129
|
+
}
|
|
130
|
+
if (elt) {
|
|
131
|
+
this.iObserver.observe(elt);
|
|
132
|
+
}
|
|
133
|
+
else if (this.isFirstLoad) {
|
|
134
|
+
this._fetchEventData();
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
onIntersection(entries) {
|
|
138
|
+
for (const e of entries) {
|
|
139
|
+
if (e.isIntersecting && this.isFirstLoad) {
|
|
140
|
+
this._fetchEventData();
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return FetcherElement; // as Constructor<SubscriberInterface> & T;
|
|
146
|
+
};
|
|
147
|
+
export default Fetcher;
|