@supersoniks/concorde 1.0.7 → 1.1.1
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 +371 -0
- package/core/utils/api.d.ts +66 -0
- package/core/utils/api.js +145 -0
- package/package.json +159 -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
|
@@ -0,0 +1,139 @@
|
|
|
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 { LitElement, html } from "lit";
|
|
8
|
+
import { customElement, property } from "lit/decorators.js";
|
|
9
|
+
import Subscriber from "@supersoniks/concorde/core/mixins/Subscriber";
|
|
10
|
+
import { templateContent } from "lit/directives/template-content.js";
|
|
11
|
+
import { repeat } from "lit/directives/repeat.js";
|
|
12
|
+
import Objects from "@supersoniks/concorde/core/utils/Objects";
|
|
13
|
+
import UrlPattern from "url-pattern";
|
|
14
|
+
import TemplatesContainer from "@supersoniks/concorde/core/mixins/TemplatesContainer";
|
|
15
|
+
/**
|
|
16
|
+
* ### sonic-states affiche des états différents en fonction de la valeur d'une sous propriété de son dataProvider (attribut data-path en dot notation):
|
|
17
|
+
* * Il boucle sur ses template enfants et test si la regexp contenue dans l'attribut *data-value* match la valeur de la propriété
|
|
18
|
+
* * Si oui le contenu du template correspontant est affiché comme état.
|
|
19
|
+
* * Si l'attribut dataProviderExpression est fourni le contenu est entouré d'une div :
|
|
20
|
+
* * L'attribut "dataProvider" de cette div est le resultat de l'appel à la fonction replace sur valeur de la propriété avec comme paramettres la regexp et dataproviderExpression.
|
|
21
|
+
* * Les subscribers/fetch... du template se réfèrerons à ce dataProvider
|
|
22
|
+
* * On peut également utiliser les des expressions du type url-pattern pour les paramètres de la route voir les exemples
|
|
23
|
+
*
|
|
24
|
+
* **Exemples**
|
|
25
|
+
* Avec ma.propriete= 2 :
|
|
26
|
+
* * RegExp data-value = (\d+) et dataproviderExpression = /user/$1 l'attribut dataProvider vaudra "/user/2"
|
|
27
|
+
* * url-pattern data-value = :id et dataproviderExpression = /user/:id l'attribut dataProvider vaudra "/user/2"
|
|
28
|
+
*
|
|
29
|
+
*/
|
|
30
|
+
let SonicStates = class SonicStates extends Subscriber(TemplatesContainer(LitElement)) {
|
|
31
|
+
constructor() {
|
|
32
|
+
super(...arguments);
|
|
33
|
+
this.state = "";
|
|
34
|
+
this.inverted = false;
|
|
35
|
+
this.statePath = "";
|
|
36
|
+
this.onAssign = null;
|
|
37
|
+
}
|
|
38
|
+
connectedCallback() {
|
|
39
|
+
super.connectedCallback();
|
|
40
|
+
if (this.hasAttribute("data-path")) {
|
|
41
|
+
this.statePath = this.getAttribute("data-path");
|
|
42
|
+
}
|
|
43
|
+
if (this.statePath) {
|
|
44
|
+
this.statePublisher = this.publisher;
|
|
45
|
+
let split = this.statePath.split(".");
|
|
46
|
+
for (let s of split) {
|
|
47
|
+
this.statePublisher = this.statePublisher[s];
|
|
48
|
+
}
|
|
49
|
+
this.onAssign = (value) => {
|
|
50
|
+
this.state = value;
|
|
51
|
+
this.requestUpdate();
|
|
52
|
+
};
|
|
53
|
+
this.statePublisher.onAssign(this.onAssign);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
disconnectedCallback() {
|
|
57
|
+
if (this.statePath)
|
|
58
|
+
this.statePublisher.offAssign(this.onAssign);
|
|
59
|
+
super.disconnectedCallback();
|
|
60
|
+
}
|
|
61
|
+
render() {
|
|
62
|
+
let templates = [];
|
|
63
|
+
let state = this.state;
|
|
64
|
+
if ((!Array.isArray(state) && Objects.isObject(state)) || state === undefined) {
|
|
65
|
+
state = "";
|
|
66
|
+
}
|
|
67
|
+
for (let t of this.templatePartsList) {
|
|
68
|
+
let path = t.getAttribute(this.templateValueAttribute);
|
|
69
|
+
let stateToMatch = state;
|
|
70
|
+
if (this.inverted) {
|
|
71
|
+
stateToMatch = path;
|
|
72
|
+
path = state;
|
|
73
|
+
}
|
|
74
|
+
if (path == "")
|
|
75
|
+
path = this.inverted ? ".*?" : "^$";
|
|
76
|
+
let regexp = new RegExp(path);
|
|
77
|
+
if (regexp.test(stateToMatch)) {
|
|
78
|
+
templates.push(t);
|
|
79
|
+
t.removeAttribute("mode");
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
let urlPattern = new UrlPattern(path);
|
|
83
|
+
if (urlPattern.names.length > 0 && urlPattern.match(stateToMatch)) {
|
|
84
|
+
t.setAttribute("mode", "patternMatching");
|
|
85
|
+
templates.push(t);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return html `${repeat(templates, (template, index) => {
|
|
90
|
+
template;
|
|
91
|
+
return index + new Date().getTime();
|
|
92
|
+
}, (template) => {
|
|
93
|
+
var _a;
|
|
94
|
+
if (template.title)
|
|
95
|
+
document.title = template.title;
|
|
96
|
+
if (template.hasAttribute("dataProviderExpression")) {
|
|
97
|
+
let dataProviderExpression = template.getAttribute("dataProviderExpression");
|
|
98
|
+
let dataProvider = "";
|
|
99
|
+
let stateToMatch = state;
|
|
100
|
+
let path = template.getAttribute(this.templateValueAttribute);
|
|
101
|
+
if (this.inverted) {
|
|
102
|
+
stateToMatch = path;
|
|
103
|
+
path = state;
|
|
104
|
+
}
|
|
105
|
+
if (path == "")
|
|
106
|
+
path = this.inverted ? "*" : "^$";
|
|
107
|
+
if (template.getAttribute("mode") == "patternMatching") {
|
|
108
|
+
const matcher = new UrlPattern(path);
|
|
109
|
+
const filler = new UrlPattern(dataProviderExpression);
|
|
110
|
+
dataProvider = filler.stringify(matcher.match(stateToMatch));
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
const regexp = new RegExp(path);
|
|
114
|
+
let match = (stateToMatch + "").match(regexp);
|
|
115
|
+
if (match) {
|
|
116
|
+
dataProvider = (_a = match.shift()) === null || _a === void 0 ? void 0 : _a.replace(regexp, dataProviderExpression);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return html `<div style="display:contents" dataProvider="${dataProvider}">${templateContent(template)}</div>`;
|
|
120
|
+
}
|
|
121
|
+
return templateContent(template);
|
|
122
|
+
})}`;
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
__decorate([
|
|
126
|
+
property()
|
|
127
|
+
], SonicStates.prototype, "state", void 0);
|
|
128
|
+
__decorate([
|
|
129
|
+
property({ type: Boolean, reflect: true })
|
|
130
|
+
], SonicStates.prototype, "inverted", void 0);
|
|
131
|
+
SonicStates = __decorate([
|
|
132
|
+
customElement("sonic-states")
|
|
133
|
+
], SonicStates);
|
|
134
|
+
export { SonicStates };
|
|
135
|
+
//Ajout pour custom-elements-manifesy pour storybook notamment
|
|
136
|
+
try {
|
|
137
|
+
customElements.define("sonic-states", SonicStates);
|
|
138
|
+
}
|
|
139
|
+
catch (e) { }
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import "@supersoniks/concorde/core/components/ui/button/button";
|
|
2
|
+
import API from "@supersoniks/concorde/core/utils/api";
|
|
3
|
+
import { LitElement } from "lit";
|
|
4
|
+
declare const Submit_base: (new (...args: any[]) => import("@supersoniks/concorde/core/mixins/Subscriber").SubscriberInterface) & typeof LitElement;
|
|
5
|
+
/**
|
|
6
|
+
* ###L'élément submit permet d'envoyer des données en rest
|
|
7
|
+
* * Les données envoyées sont celles présentes dans le publisher dont l'adresse est renseignée via l'attribut *formDataProvider*.
|
|
8
|
+
* Cet attribut est également utilisé par les éléments de form comme *sonic-input*, ou *sonic-select*, qui remplissent ce publisher avec leur attribut *value* en fonction de leur attribut *name*
|
|
9
|
+
* * L'api est configuré à la manière d'un fetcher.
|
|
10
|
+
* * L'attribut *method* permet de choisir la méthode d'envoie : *put/delete/post*, *post* étant la méthode par défaut.
|
|
11
|
+
* * Si l'attribut *onClick* est présent, les données sont envoyées quand on click dans son contenu
|
|
12
|
+
* * Si l'attribut *onEnterKey* est présent, les données sont envoyées quand on appuie sur la touche entrée d'un élément contenu dans le *sonic-submit* ayant le focus
|
|
13
|
+
* * Pendant l'envoi, les éléments *sonic-submit* ayant le même attribut *dataProvider* ont la propriété *disabled="disabled"* ce qui a pour effet de désactiver leur contenu
|
|
14
|
+
* * L'attribut *clearedDataOnSuccess* peut être utilisé pour vider les données des dataProvider correspondants lorsque l'appel à l'api a fourni un résultat.
|
|
15
|
+
*/
|
|
16
|
+
export declare class Submit extends Submit_base {
|
|
17
|
+
static styles: import("lit").CSSResult;
|
|
18
|
+
disabled: "disabled" | "" | null;
|
|
19
|
+
api: API | null;
|
|
20
|
+
connectedCallback(): void;
|
|
21
|
+
submit(): Promise<void>;
|
|
22
|
+
protected render(): unknown;
|
|
23
|
+
}
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,108 @@
|
|
|
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
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
8
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
9
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
10
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
11
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
12
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
13
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
import { customElement, property } from "lit/decorators.js";
|
|
17
|
+
import { PublisherManager } from "@supersoniks/concorde/core/utils/PublisherProxy.mjs";
|
|
18
|
+
import "@supersoniks/concorde/core/components/ui/button/button";
|
|
19
|
+
import Subscriber from "@supersoniks/concorde/core/mixins/Subscriber";
|
|
20
|
+
import API from "@supersoniks/concorde/core/utils/api";
|
|
21
|
+
import { Loader } from "@supersoniks/concorde/core/components/ui/loader/loader";
|
|
22
|
+
import { css, html, LitElement } from "lit";
|
|
23
|
+
/**
|
|
24
|
+
* ###L'élément submit permet d'envoyer des données en rest
|
|
25
|
+
* * Les données envoyées sont celles présentes dans le publisher dont l'adresse est renseignée via l'attribut *formDataProvider*.
|
|
26
|
+
* Cet attribut est également utilisé par les éléments de form comme *sonic-input*, ou *sonic-select*, qui remplissent ce publisher avec leur attribut *value* en fonction de leur attribut *name*
|
|
27
|
+
* * L'api est configuré à la manière d'un fetcher.
|
|
28
|
+
* * L'attribut *method* permet de choisir la méthode d'envoie : *put/delete/post*, *post* étant la méthode par défaut.
|
|
29
|
+
* * Si l'attribut *onClick* est présent, les données sont envoyées quand on click dans son contenu
|
|
30
|
+
* * Si l'attribut *onEnterKey* est présent, les données sont envoyées quand on appuie sur la touche entrée d'un élément contenu dans le *sonic-submit* ayant le focus
|
|
31
|
+
* * Pendant l'envoi, les éléments *sonic-submit* ayant le même attribut *dataProvider* ont la propriété *disabled="disabled"* ce qui a pour effet de désactiver leur contenu
|
|
32
|
+
* * L'attribut *clearedDataOnSuccess* peut être utilisé pour vider les données des dataProvider correspondants lorsque l'appel à l'api a fourni un résultat.
|
|
33
|
+
*/
|
|
34
|
+
let Submit = class Submit extends Subscriber(LitElement) {
|
|
35
|
+
constructor() {
|
|
36
|
+
super(...arguments);
|
|
37
|
+
this.disabled = null;
|
|
38
|
+
this.api = null;
|
|
39
|
+
}
|
|
40
|
+
connectedCallback() {
|
|
41
|
+
if (this.hasAttribute("onClick"))
|
|
42
|
+
this.addEventListener("click", () => this.submit());
|
|
43
|
+
if (this.hasAttribute("onEnterKey"))
|
|
44
|
+
this.addEventListener("keydown", (e) => {
|
|
45
|
+
if (e.key === "Enter")
|
|
46
|
+
this.submit();
|
|
47
|
+
});
|
|
48
|
+
super.connectedCallback();
|
|
49
|
+
this.api = new API(this.getApiConfiguration());
|
|
50
|
+
}
|
|
51
|
+
submit() {
|
|
52
|
+
var _a, _b, _c, _d, _e;
|
|
53
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
54
|
+
this.publisher.disabled = '';
|
|
55
|
+
let method = ((_a = this.getAttribute("method")) === null || _a === void 0 ? void 0 : _a.toLocaleLowerCase()) || "post";
|
|
56
|
+
let postData = PublisherManager.getInstance().get(this.getAncestorAttributeValue("formDataProvider")).get();
|
|
57
|
+
let result = null;
|
|
58
|
+
let dp = this.getAncestorAttributeValue("dataProvider");
|
|
59
|
+
Loader.show();
|
|
60
|
+
switch (method) {
|
|
61
|
+
case "put":
|
|
62
|
+
result = yield ((_b = this.api) === null || _b === void 0 ? void 0 : _b.put(dp, postData));
|
|
63
|
+
break;
|
|
64
|
+
case "delete":
|
|
65
|
+
result = yield ((_c = this.api) === null || _c === void 0 ? void 0 : _c.delete(dp, postData));
|
|
66
|
+
break;
|
|
67
|
+
case "get":
|
|
68
|
+
result = yield ((_d = this.api) === null || _d === void 0 ? void 0 : _d.get(dp));
|
|
69
|
+
break;
|
|
70
|
+
default:
|
|
71
|
+
result = yield ((_e = this.api) === null || _e === void 0 ? void 0 : _e.post(dp, postData));
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
Loader.hide();
|
|
75
|
+
if (!result)
|
|
76
|
+
result = { messages: [{ content: "Network Error", status: "error" }] };
|
|
77
|
+
let clearedDataProvider = this.getAncestorAttributeValue("clearedDataOnSuccess");
|
|
78
|
+
if (clearedDataProvider) {
|
|
79
|
+
clearedDataProvider.split(" ").forEach(dataProvider => PublisherManager.getInstance().get(dataProvider).set({}));
|
|
80
|
+
}
|
|
81
|
+
PublisherManager.getInstance().get(this.getAncestorAttributeValue("submitResultDataProvider")).set(result);
|
|
82
|
+
this.publisher.disabled = null;
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
render() {
|
|
86
|
+
let disabled = this.disabled === "" || this.disabled === "disabled" ? "disabled" : "";
|
|
87
|
+
return html `<div class="${disabled}"><slot></slot></div>`;
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
Submit.styles = css `
|
|
91
|
+
.disabled {
|
|
92
|
+
opacity: 0.3;
|
|
93
|
+
pointer-events: none;
|
|
94
|
+
user-select: none;
|
|
95
|
+
}
|
|
96
|
+
`;
|
|
97
|
+
__decorate([
|
|
98
|
+
property({ type: String })
|
|
99
|
+
], Submit.prototype, "disabled", void 0);
|
|
100
|
+
Submit = __decorate([
|
|
101
|
+
customElement("sonic-submit")
|
|
102
|
+
], Submit);
|
|
103
|
+
export { Submit };
|
|
104
|
+
//Ajout pour la creation du cem notamment pour Storybook
|
|
105
|
+
try {
|
|
106
|
+
customElements.define("sonic-submit", Submit);
|
|
107
|
+
}
|
|
108
|
+
catch (e) { }
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { LitElement } from "lit";
|
|
2
|
-
declare const SonicSubscriber_base: (new (...args: any[]) => import("
|
|
2
|
+
declare const SonicSubscriber_base: (new (...args: any[]) => import("@supersoniks/concorde/core/mixins/Subscriber").SubscriberInterface) & typeof LitElement;
|
|
3
|
+
/**
|
|
4
|
+
* Voir la partie dédiée dans *MISCALLENOUS*
|
|
5
|
+
*/
|
|
3
6
|
export declare class SonicSubscriber extends SonicSubscriber_base {
|
|
7
|
+
connectedCallback(): void;
|
|
4
8
|
render(): import("lit-html").TemplateResult<1>;
|
|
5
9
|
}
|
|
6
10
|
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
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 } from "lit";
|
|
8
|
+
import { customElement } from "lit/decorators.js";
|
|
9
|
+
import Subscriber from "@supersoniks/concorde/core/mixins/Subscriber";
|
|
10
|
+
/**
|
|
11
|
+
* Voir la partie dédiée dans *MISCALLENOUS*
|
|
12
|
+
*/
|
|
13
|
+
let SonicSubscriber = class SonicSubscriber extends Subscriber(LitElement) {
|
|
14
|
+
connectedCallback() {
|
|
15
|
+
this.noShadowDom = "";
|
|
16
|
+
super.connectedCallback();
|
|
17
|
+
}
|
|
18
|
+
render() {
|
|
19
|
+
return html ` <slot></slot> `;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
SonicSubscriber = __decorate([
|
|
23
|
+
customElement("sonic-subscriber")
|
|
24
|
+
], SonicSubscriber);
|
|
25
|
+
export { SonicSubscriber };
|
|
26
|
+
//Ajout pour Storybook
|
|
27
|
+
try {
|
|
28
|
+
customElements.define("sonic-subscriber", SonicSubscriber);
|
|
29
|
+
}
|
|
30
|
+
catch (e) { }
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { LitElement } from "lit";
|
|
2
|
+
/**
|
|
3
|
+
* Affiche un message en ligne.
|
|
4
|
+
* Soit par ses simples attributs "label" et "text", soit par son slot pour des messages plus complexes.
|
|
5
|
+
*/
|
|
6
|
+
export declare class Alert extends LitElement {
|
|
7
|
+
static styles: import("lit").CSSResult[];
|
|
8
|
+
/**
|
|
9
|
+
* Titre du message d'erreur
|
|
10
|
+
*/
|
|
11
|
+
label: string;
|
|
12
|
+
/**
|
|
13
|
+
* Peut être renseigné dans le slot pour créer des messages plus complexes
|
|
14
|
+
*/
|
|
15
|
+
text: string;
|
|
16
|
+
size: "xs" | "sm" | "md" | "lg";
|
|
17
|
+
background: boolean;
|
|
18
|
+
status: "default" | "error" | "warning" | "primary" | "info";
|
|
19
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
20
|
+
}
|
|
@@ -0,0 +1,150 @@
|
|
|
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
|
+
const icon = {
|
|
10
|
+
warning: "warning-circled-outline",
|
|
11
|
+
success: "check-circled-outline",
|
|
12
|
+
error: "warning-circled-outline",
|
|
13
|
+
info: "info-empty",
|
|
14
|
+
default: "info-empty",
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Affiche un message en ligne.
|
|
18
|
+
* Soit par ses simples attributs "label" et "text", soit par son slot pour des messages plus complexes.
|
|
19
|
+
*/
|
|
20
|
+
let Alert = class Alert extends LitElement {
|
|
21
|
+
constructor() {
|
|
22
|
+
super(...arguments);
|
|
23
|
+
/**
|
|
24
|
+
* Titre du message d'erreur
|
|
25
|
+
*/
|
|
26
|
+
this.label = "";
|
|
27
|
+
/**
|
|
28
|
+
* Peut être renseigné dans le slot pour créer des messages plus complexes
|
|
29
|
+
*/
|
|
30
|
+
this.text = "";
|
|
31
|
+
this.size = "md";
|
|
32
|
+
this.background = false;
|
|
33
|
+
this.status = "default";
|
|
34
|
+
}
|
|
35
|
+
render() {
|
|
36
|
+
return html `<div part="alert" class="alert">
|
|
37
|
+
<div>
|
|
38
|
+
${this.status && html `<sonic-icon prefix="iconoir" name=${icon[this.status]}></sonic-icon>`}
|
|
39
|
+
</div>
|
|
40
|
+
<div >
|
|
41
|
+
${this.label ? html `<span class="alert-title">${this.label} :</span>` : nothing}
|
|
42
|
+
${this.text} <slot><slot>
|
|
43
|
+
</div>
|
|
44
|
+
</div>`;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
Alert.styles = [
|
|
48
|
+
css `
|
|
49
|
+
:host {
|
|
50
|
+
--sc-alert-color: inherit;
|
|
51
|
+
--sc-alert-rounded: var(--sc-rounded);
|
|
52
|
+
--sc-alert-fw: var(--sc-font-weight-base);
|
|
53
|
+
--sc-alert-fst: var(--sc-font-style-base);
|
|
54
|
+
--sc-alert-fs: 1rem;
|
|
55
|
+
--sc-alert-title-fw: bold;
|
|
56
|
+
|
|
57
|
+
display: block;
|
|
58
|
+
font-size: var(--sc-alert-fs);
|
|
59
|
+
font-weight: var(--sc-alert-fw);
|
|
60
|
+
font-style: var(--sc-alert-fst);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.alert {
|
|
64
|
+
color: var(--sc-alert-color);
|
|
65
|
+
position: relative;
|
|
66
|
+
display: flex;
|
|
67
|
+
gap: 0.4em;
|
|
68
|
+
line-height: 1.2;
|
|
69
|
+
border-radius: var(--sc-alert-rounded);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.alert-title {
|
|
73
|
+
font-weight: var(--sc-alert-title-fw);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
:host([status="warning"]) .alert {
|
|
77
|
+
--sc-alert-color: var(--sc-warning);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
:host([status="error"]) .alert {
|
|
81
|
+
--sc-alert-color: var(--sc-danger);
|
|
82
|
+
}
|
|
83
|
+
:host([status="info"]) .alert {
|
|
84
|
+
--sc-alert-color: var(--sc-info);
|
|
85
|
+
}
|
|
86
|
+
:host([status="success"]) .alert {
|
|
87
|
+
--sc-alert-color: var(--sc-success);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/*background*/
|
|
91
|
+
:host([background]) .alert {
|
|
92
|
+
background: var(--sc-base);
|
|
93
|
+
padding: 0.8em 1.15em;
|
|
94
|
+
}
|
|
95
|
+
:host([background]) .alert:before {
|
|
96
|
+
background-color: currentColor;
|
|
97
|
+
content: "";
|
|
98
|
+
display: block;
|
|
99
|
+
position: absolute;
|
|
100
|
+
left: 0;
|
|
101
|
+
top: 0;
|
|
102
|
+
right: 0;
|
|
103
|
+
bottom: 0;
|
|
104
|
+
opacity: 0.08;
|
|
105
|
+
border-radius: var(--sc-alert-rounded);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/*SIZE*/
|
|
109
|
+
:host([size="xs"]) {
|
|
110
|
+
--sc-alert-fs: 0.75rem;
|
|
111
|
+
}
|
|
112
|
+
:host([size="sm"]) {
|
|
113
|
+
--sc-alert-fs: 0.85rem;
|
|
114
|
+
}
|
|
115
|
+
:host([size="lg"]) {
|
|
116
|
+
--sc-alert-fs: 1.2rem;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/*Rounded*/
|
|
120
|
+
:host([size="xs"]) .alert {
|
|
121
|
+
--sc-alert-rounded: var(--sc-rounded-sm);
|
|
122
|
+
}
|
|
123
|
+
:host([size="sm"]) .alert {
|
|
124
|
+
--sc-alert-rounded: var(--sc-rounded-sm);
|
|
125
|
+
}
|
|
126
|
+
`,
|
|
127
|
+
];
|
|
128
|
+
__decorate([
|
|
129
|
+
property({ type: String })
|
|
130
|
+
], Alert.prototype, "label", void 0);
|
|
131
|
+
__decorate([
|
|
132
|
+
property({ type: String })
|
|
133
|
+
], Alert.prototype, "text", void 0);
|
|
134
|
+
__decorate([
|
|
135
|
+
property({ type: String, reflect: true })
|
|
136
|
+
], Alert.prototype, "size", void 0);
|
|
137
|
+
__decorate([
|
|
138
|
+
property({ type: Boolean, reflect: true })
|
|
139
|
+
], Alert.prototype, "background", void 0);
|
|
140
|
+
__decorate([
|
|
141
|
+
property({ type: String, reflect: true })
|
|
142
|
+
], Alert.prototype, "status", void 0);
|
|
143
|
+
Alert = __decorate([
|
|
144
|
+
customElement("sonic-alert")
|
|
145
|
+
], Alert);
|
|
146
|
+
export { Alert };
|
|
147
|
+
try {
|
|
148
|
+
customElements.define("sonic-alert", Alert);
|
|
149
|
+
}
|
|
150
|
+
catch (e) { }
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { LitElement } from "lit";
|
|
2
|
+
/**
|
|
3
|
+
* Un badge simple avec deux slots, un nommé prefix et un nomé suffix de manière à pouvoir mettre (par exemple) une icone avant ou après le contenu.
|
|
4
|
+
* * Le badge est comparable au bouton car il possèdent tous les deux les propriétés *type* (primary...), *variant*(outline, ghost), size(xs...)...
|
|
5
|
+
* * Le badge n'est pas interactif contrairement au bouton
|
|
6
|
+
*/
|
|
7
|
+
export declare class Badge extends LitElement {
|
|
8
|
+
static styles: import("lit").CSSResult[];
|
|
9
|
+
/**
|
|
10
|
+
* Le type change surtout la couleur composant
|
|
11
|
+
*/
|
|
12
|
+
type: "default" | "primary" | "warning" | "danger" | "success" | "info";
|
|
13
|
+
/**
|
|
14
|
+
* Le composant par defaut sans se paramètre à forte afordance
|
|
15
|
+
* * gost : composant super léger visuellement
|
|
16
|
+
* * outline : composant légé avec une bordure
|
|
17
|
+
*/
|
|
18
|
+
variant: "default" | "outline" | "ghost";
|
|
19
|
+
/**
|
|
20
|
+
* Taille du composant, implique notamment des modifications de typo et de marge interne
|
|
21
|
+
*/
|
|
22
|
+
size: "xs" | "sm" | "md" | "lg" | "xl";
|
|
23
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
24
|
+
}
|