@supersoniks/concorde 1.1.42 → 1.1.44
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/components.js +2 -3
- package/concorde-core.bundle.js +37 -35
- package/concorde-core.es.js +5283 -4453
- package/core/_types/types.d.ts +31 -0
- package/core/_types/types.js +2 -0
- package/core/components/functional/date/date.d.ts +13 -5
- package/core/components/functional/date/date.js +57 -38
- package/core/components/functional/example/example.d.ts +1 -1
- package/core/components/functional/example/example.js +1 -1
- package/core/components/functional/fetch/fetch.d.ts +45 -6
- package/core/components/functional/fetch/fetch.js +2 -6
- package/core/components/functional/functional.d.ts +2 -0
- package/core/components/functional/functional.js +2 -0
- package/core/components/functional/if/if.d.ts +3 -0
- package/core/components/functional/if/if.js +6 -12
- package/core/components/functional/if/if.test.d.ts +1 -0
- package/core/components/functional/if/if.test.js +44 -0
- package/core/components/functional/list/list.d.ts +44 -12
- package/core/components/functional/list/list.js +54 -49
- package/core/components/functional/mix/mix.d.ts +22 -0
- package/core/components/functional/mix/mix.js +102 -0
- package/core/components/functional/queue/queue.d.ts +27 -5
- package/core/components/functional/queue/queue.js +88 -26
- package/core/components/functional/router/redirect.d.ts +11 -2
- package/core/components/functional/router/redirect.js +7 -12
- package/core/components/functional/router/router.d.ts +15 -1
- package/core/components/functional/router/router.js +11 -16
- package/core/components/functional/sdui/SDUIDescriptorTransformer.d.ts +1 -2
- package/core/components/functional/sdui/SDUIDescriptorTransformer.js +56 -45
- package/core/components/functional/sdui/default-library.json +108 -0
- package/core/components/functional/sdui/sdui-utils.d.ts +5 -0
- package/core/components/functional/sdui/sdui-utils.js +63 -0
- package/core/components/functional/sdui/sdui.d.ts +21 -13
- package/core/components/functional/sdui/sdui.js +70 -44
- package/core/components/functional/sdui/types.d.ts +10 -8
- package/core/components/functional/states/states.d.ts +20 -4
- package/core/components/functional/states/states.js +15 -20
- package/core/components/functional/submit/submit.d.ts +16 -1
- package/core/components/functional/submit/submit.js +95 -25
- package/core/components/functional/subscriber/subscriber.d.ts +4 -1
- package/core/components/functional/subscriber/subscriber.js +1 -6
- package/core/components/functional/value/value.d.ts +7 -0
- package/core/components/functional/value/value.js +26 -0
- package/core/components/ui/_css/scroll.js +6 -7
- package/core/components/ui/_css/size.d.ts +1 -0
- package/core/components/ui/_css/size.js +3 -1
- package/core/components/ui/alert/alert.d.ts +2 -2
- package/core/components/ui/alert/alert.js +11 -16
- package/core/components/ui/badge/badge.d.ts +3 -1
- package/core/components/ui/badge/badge.js +36 -22
- package/core/components/ui/button/button.d.ts +28 -23
- package/core/components/ui/button/button.js +60 -43
- package/core/components/ui/captcha/captcha.d.ts +14 -2
- package/core/components/ui/captcha/captcha.js +18 -13
- package/core/components/ui/card/card-footer.js +1 -8
- package/core/components/ui/card/card-header-descripton.js +3 -9
- package/core/components/ui/card/card-header.js +6 -7
- package/core/components/ui/card/card-main.js +0 -5
- package/core/components/ui/card/card.d.ts +1 -1
- package/core/components/ui/card/card.js +30 -12
- package/core/components/ui/divider/divider.d.ts +2 -0
- package/core/components/ui/divider/divider.js +43 -16
- package/core/components/ui/form/checkbox/checkbox.d.ts +86 -25
- package/core/components/ui/form/checkbox/checkbox.js +53 -28
- package/core/components/ui/form/css/form-control.d.ts +2 -0
- package/core/components/ui/form/css/form-control.js +145 -67
- package/core/components/ui/form/fieldset/fieldset.d.ts +8 -1
- package/core/components/ui/form/fieldset/fieldset.js +45 -8
- package/core/components/ui/form/fieldset/legend-description.js +0 -5
- package/core/components/ui/form/fieldset/legend.js +3 -6
- package/core/components/ui/form/form-actions/form-actions.d.ts +2 -0
- package/core/components/ui/form/form-actions/form-actions.js +26 -11
- package/core/components/ui/form/form-layout/form-layout.d.ts +5 -2
- package/core/components/ui/form/form-layout/form-layout.js +31 -9
- package/core/components/ui/form/input/input.d.ts +26 -24
- package/core/components/ui/form/input/input.js +87 -52
- package/core/components/ui/form/input/password-helper.d.ts +1 -1
- package/core/components/ui/form/input/password-helper.js +4 -3
- package/core/components/ui/form/input/same-value-helper.d.ts +1 -1
- package/core/components/ui/form/input/same-value-helper.js +3 -2
- package/core/components/ui/form/input-autocomplete/input-autocomplete.d.ts +2 -3
- package/core/components/ui/form/input-autocomplete/input-autocomplete.js +2 -6
- package/core/components/ui/form/radio/radio.d.ts +6 -0
- package/core/components/ui/form/radio/radio.js +7 -12
- package/core/components/ui/form/select/select.d.ts +25 -8
- package/core/components/ui/form/select/select.js +72 -41
- package/core/components/ui/form/textarea/textarea.d.ts +21 -19
- package/core/components/ui/form/textarea/textarea.js +29 -36
- package/core/components/ui/group/group.d.ts +11 -1
- package/core/components/ui/group/group.js +79 -17
- package/core/components/ui/icon/icon.d.ts +10 -3
- package/core/components/ui/icon/icon.js +16 -15
- package/core/components/ui/icon/icons.js +25 -20
- package/core/components/ui/icon/icons.json +1 -1
- package/core/components/ui/image/image.js +0 -5
- package/core/components/ui/link/link.d.ts +1 -1
- package/core/components/ui/link/link.js +2 -6
- package/core/components/ui/loader/loader.d.ts +1 -1
- package/core/components/ui/loader/loader.js +3 -9
- package/core/components/ui/menu/menu-item.js +4 -9
- package/core/components/ui/menu/menu.d.ts +9 -1
- package/core/components/ui/menu/menu.js +182 -27
- package/core/components/ui/modal/modal-actions.js +1 -6
- package/core/components/ui/modal/modal-close.d.ts +1 -0
- package/core/components/ui/modal/modal-close.js +14 -10
- package/core/components/ui/modal/modal-content.js +0 -5
- package/core/components/ui/modal/modal-subtitle.js +2 -6
- package/core/components/ui/modal/modal-title.js +0 -5
- package/core/components/ui/modal/modal.d.ts +7 -7
- package/core/components/ui/modal/modal.js +37 -37
- package/core/components/ui/pop/pop.d.ts +6 -5
- package/core/components/ui/pop/pop.js +57 -57
- package/core/components/ui/progress/progress.js +34 -32
- package/core/components/ui/table/table-caption.js +5 -10
- package/core/components/ui/table/table-tbody.js +10 -14
- package/core/components/ui/table/table-td.d.ts +2 -0
- package/core/components/ui/table/table-td.js +8 -5
- package/core/components/ui/table/table-tfoot.js +5 -7
- package/core/components/ui/table/table-th.d.ts +2 -0
- package/core/components/ui/table/table-th.js +12 -9
- package/core/components/ui/table/table-thead.js +1 -6
- package/core/components/ui/table/table-tr.js +4 -6
- package/core/components/ui/table/table.d.ts +0 -3
- package/core/components/ui/table/table.js +14 -31
- package/core/components/ui/theme/theme-collection/core-variables.js +13 -11
- package/core/components/ui/theme/theme-collection/dark.js +1 -1
- package/core/components/ui/theme/theme.d.ts +1 -6
- package/core/components/ui/theme/theme.js +19 -46
- package/core/components/ui/toast/message-subscriber.d.ts +16 -7
- package/core/components/ui/toast/message-subscriber.js +10 -8
- package/core/components/ui/toast/toast-item.js +1 -1
- package/core/components/ui/toast/toast.d.ts +3 -2
- package/core/components/ui/toast/toast.js +33 -19
- package/core/components/ui/toast/types.d.ts +3 -2
- package/core/components/ui/tooltip/tooltip.d.ts +1 -0
- package/core/components/ui/tooltip/tooltip.js +36 -15
- package/core/components/ui/ui.d.ts +1 -1
- package/core/components/ui/ui.js +1 -4
- package/core/core.js +5 -6
- package/core/mixins/Fetcher.d.ts +20 -13
- package/core/mixins/Fetcher.js +44 -19
- package/core/mixins/FormCheckable.d.ts +25 -13
- package/core/mixins/FormCheckable.js +180 -23
- package/core/mixins/FormElement.d.ts +17 -9
- package/core/mixins/FormElement.js +56 -39
- package/core/mixins/FormInput.d.ts +22 -12
- package/core/mixins/FormInput.js +4 -3
- package/core/mixins/Subscriber.d.ts +12 -8
- package/core/mixins/Subscriber.js +51 -48
- package/core/mixins/TemplatesContainer.d.ts +2 -1
- package/core/mixins/TemplatesContainer.js +2 -2
- package/core/utils/Arrays.d.ts +15 -15
- package/core/utils/Arrays.js +12 -9
- package/core/utils/DataBindObserver.d.ts +18 -11
- package/core/utils/DataBindObserver.js +47 -54
- package/core/utils/Electron.d.ts +5 -1
- package/core/utils/Electron.js +4 -2
- package/core/utils/HTML.d.ts +9 -2
- package/core/utils/HTML.js +24 -5
- package/core/utils/LocationHandler.d.ts +6 -5
- package/core/utils/LocationHandler.js +27 -16
- package/core/utils/Objects.d.ts +7 -4
- package/core/utils/Objects.js +37 -9
- package/core/utils/{PublisherProxy.d.mts → PublisherProxy.d.ts} +49 -34
- package/core/utils/{PublisherProxy.mjs → PublisherProxy.js} +107 -77
- package/core/utils/Utils.d.ts +3 -0
- package/core/utils/Utils.js +18 -0
- package/core/utils/api.d.ts +26 -9
- package/core/utils/api.js +62 -45
- package/img/concorde-logo.svg +1 -0
- package/img/concorde.png +0 -0
- package/img/concorde_def.png +0 -0
- package/mixins.d.ts +53 -29
- package/mixins.js +3 -4
- package/package.json +51 -12
- package/svg/regular/plane.svg +1 -0
- package/svg/solid/plane.svg +1 -0
- package/test-utils/TestUtils.d.ts +4 -0
- package/test-utils/TestUtils.js +12 -0
- package/utils.d.ts +3 -1
- package/utils.js +7 -5
- package/core/components/functional/configuration/configuration.d.ts +0 -5
- package/core/components/functional/configuration/configuration.js +0 -22
- package/core/components/ui/tabs/tab.d.ts +0 -6
- package/core/components/ui/tabs/tab.js +0 -46
- package/core/components/ui/tabs/tabs.d.ts +0 -15
- package/core/components/ui/tabs/tabs.js +0 -129
- package/core/components/ui/taxonomy/taxonomy.d.ts +0 -41
- package/core/components/ui/taxonomy/taxonomy.js +0 -115
|
@@ -13,12 +13,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
13
13
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
14
14
|
});
|
|
15
15
|
};
|
|
16
|
-
import
|
|
17
|
-
import
|
|
16
|
+
import default_library from "@supersoniks/concorde/core/components/functional/sdui/default-library.json";
|
|
17
|
+
import SDUIDescriptorTransformer from "@supersoniks/concorde/core/components/functional/sdui/SDUIDescriptorTransformer";
|
|
18
18
|
import { Fetcher, Subscriber } from "@supersoniks/concorde/mixins";
|
|
19
19
|
import { HTML, Objects } from "@supersoniks/concorde/utils";
|
|
20
|
+
import { LitElement } from "lit";
|
|
21
|
+
import { customElement, property } from "lit/decorators.js";
|
|
20
22
|
const tagName = "sonic-sdui"; // For Astro.build
|
|
21
|
-
import SDUIDescriptorTransformer from "@supersoniks/concorde/core/components/functional/sdui/SDUIDescriptorTransformer";
|
|
22
23
|
/**
|
|
23
24
|
* ### sonic-sdui (Server Driven User Interface) est un fetcher chargant un JSON décrivant une interface utilisateur
|
|
24
25
|
*
|
|
@@ -37,6 +38,10 @@ import SDUIDescriptorTransformer from "@supersoniks/concorde/core/components/fun
|
|
|
37
38
|
* *
|
|
38
39
|
*/
|
|
39
40
|
let SonicSDUI = class SonicSDUI extends Fetcher(Subscriber(LitElement)) {
|
|
41
|
+
constructor() {
|
|
42
|
+
super(...arguments);
|
|
43
|
+
this.sduiDescriptor = {};
|
|
44
|
+
}
|
|
40
45
|
connectedCallback() {
|
|
41
46
|
this.noShadowDom = "";
|
|
42
47
|
this.displayContents = true;
|
|
@@ -46,22 +51,32 @@ let SonicSDUI = class SonicSDUI extends Fetcher(Subscriber(LitElement)) {
|
|
|
46
51
|
/**
|
|
47
52
|
* On peut passer la description sous form de props, sinon il faut utiliser l'attribut fetch
|
|
48
53
|
*/
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
54
|
+
willUpdate(changedProperties) {
|
|
55
|
+
if (this.props == null) {
|
|
56
|
+
this.sduiDescriptor = {};
|
|
57
|
+
}
|
|
58
|
+
{
|
|
59
|
+
const newSduiDescriptor = this.sduiKey
|
|
60
|
+
? this.props[this.sduiKey]
|
|
61
|
+
: this.props;
|
|
62
|
+
if (this.sduiDescriptor == newSduiDescriptor)
|
|
63
|
+
return;
|
|
64
|
+
this.sduiDescriptor = newSduiDescriptor;
|
|
65
|
+
this.updateContents();
|
|
66
|
+
}
|
|
67
|
+
super.willUpdate(changedProperties);
|
|
55
68
|
}
|
|
56
69
|
/**
|
|
57
|
-
* updateContents est déclenché quand les
|
|
70
|
+
* updateContents est déclenché quand les sduiDescriptor sont renseignées
|
|
58
71
|
* Le contenu du composant est regénéré en fonction du descripteur fourni
|
|
59
72
|
*/
|
|
60
73
|
updateContents() {
|
|
61
74
|
return __awaiter(this, void 0, void 0, function* () {
|
|
62
|
-
this.
|
|
63
|
-
if (!this.props)
|
|
75
|
+
if (!this.sduiDescriptor)
|
|
64
76
|
return;
|
|
77
|
+
const library = {};
|
|
78
|
+
Object.assign(library, default_library, this.sduiDescriptor.library);
|
|
79
|
+
this.sduiDescriptor.library = library;
|
|
65
80
|
this.loadAssets();
|
|
66
81
|
yield this.loadLibrary();
|
|
67
82
|
yield this.transformSDUIDescriptor();
|
|
@@ -80,28 +95,28 @@ let SonicSDUI = class SonicSDUI extends Fetcher(Subscriber(LitElement)) {
|
|
|
80
95
|
* Chargement de fichiers js et css associés si besoin
|
|
81
96
|
**/
|
|
82
97
|
loadAssets() {
|
|
83
|
-
if (!this.
|
|
98
|
+
if (!this.sduiDescriptor)
|
|
84
99
|
return;
|
|
85
|
-
if (this.
|
|
86
|
-
for (const src of this.
|
|
100
|
+
if (this.sduiDescriptor.js) {
|
|
101
|
+
for (const src of this.sduiDescriptor.js)
|
|
87
102
|
HTML.loadJS(src);
|
|
88
103
|
}
|
|
89
|
-
if (this.
|
|
90
|
-
for (const src of this.
|
|
104
|
+
if (this.sduiDescriptor.css) {
|
|
105
|
+
for (const src of this.sduiDescriptor.css)
|
|
91
106
|
HTML.loadCSS(src);
|
|
92
107
|
}
|
|
93
108
|
}
|
|
94
109
|
/**
|
|
95
|
-
* Transformation de la data fournie via
|
|
110
|
+
* Transformation de la data fournie via sduiDescriptor si il y a un attribut transformation
|
|
96
111
|
* */
|
|
97
112
|
transformSDUIDescriptor() {
|
|
98
113
|
return __awaiter(this, void 0, void 0, function* () {
|
|
99
114
|
if (!this.hasAttribute("transformation"))
|
|
100
115
|
return;
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
yield transformer.transform(this.
|
|
116
|
+
const result = yield fetch(this.getAttribute("transformation"));
|
|
117
|
+
const json = yield result.json();
|
|
118
|
+
const transformer = new SDUIDescriptorTransformer();
|
|
119
|
+
yield transformer.transform(this.sduiDescriptor, json);
|
|
105
120
|
});
|
|
106
121
|
}
|
|
107
122
|
/**
|
|
@@ -111,27 +126,33 @@ let SonicSDUI = class SonicSDUI extends Fetcher(Subscriber(LitElement)) {
|
|
|
111
126
|
return __awaiter(this, void 0, void 0, function* () {
|
|
112
127
|
if (!this.hasAttribute("library"))
|
|
113
128
|
return;
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
this.
|
|
129
|
+
const result = yield fetch(this.getAttribute("library"));
|
|
130
|
+
const json = yield result.json();
|
|
131
|
+
this.sduiDescriptor.library = json;
|
|
117
132
|
});
|
|
118
133
|
}
|
|
119
134
|
/**
|
|
120
135
|
* Point d'entrée : transformation des noeuds fournis en éléments graphiques
|
|
121
136
|
**/
|
|
122
137
|
parseRootNodes() {
|
|
123
|
-
|
|
138
|
+
this.removeChildren();
|
|
139
|
+
if (!this.sduiDescriptor)
|
|
124
140
|
return;
|
|
125
|
-
let nodes = this.
|
|
141
|
+
let nodes = this.sduiDescriptor.nodes;
|
|
126
142
|
if (!nodes)
|
|
127
|
-
|
|
143
|
+
nodes = [];
|
|
144
|
+
const messageProvider = { tagName: "sonic-toast-message-subscriber", attributes: {} };
|
|
145
|
+
if (this.messagesKey) {
|
|
146
|
+
messageProvider.attributes = { subDataProvider: this.messagesKey };
|
|
147
|
+
}
|
|
148
|
+
nodes.push(messageProvider);
|
|
128
149
|
nodes.forEach((node) => this.appendChild(this.parseChild(node)));
|
|
129
150
|
}
|
|
130
151
|
/**
|
|
131
152
|
* On parse un noeud ce qui crée un éléments graphique et ses enfants par recursivité via `handleChildNodes`
|
|
132
153
|
*/
|
|
133
154
|
parseChild(node) {
|
|
134
|
-
|
|
155
|
+
const tagName = node.tagName || "div";
|
|
135
156
|
let { element, contentElement } = this.handleLibrary(node, tagName);
|
|
136
157
|
this.handleAttributes(node, element);
|
|
137
158
|
element = this.handleMarkup(node, element);
|
|
@@ -146,7 +167,7 @@ let SonicSDUI = class SonicSDUI extends Fetcher(Subscriber(LitElement)) {
|
|
|
146
167
|
return element;
|
|
147
168
|
}
|
|
148
169
|
/**
|
|
149
|
-
* Si le noeud courant a des propriétés prefix et ou suffix il est entouré des markups fournis dans ces
|
|
170
|
+
* Si le noeud courant a des propriétés prefix et ou suffix il est entouré des markups fournis dans ces sduiDescriptor.
|
|
150
171
|
* Le tout est inclu dans une div en display contents
|
|
151
172
|
*/
|
|
152
173
|
handlePrefixSuffix(node, element) {
|
|
@@ -161,15 +182,19 @@ let SonicSDUI = class SonicSDUI extends Fetcher(Subscriber(LitElement)) {
|
|
|
161
182
|
*/
|
|
162
183
|
handleChildNodes(node, contentElement, element) {
|
|
163
184
|
if (node.nodes) {
|
|
164
|
-
|
|
165
|
-
for (
|
|
166
|
-
|
|
185
|
+
const children = node.nodes;
|
|
186
|
+
for (const child of children) {
|
|
187
|
+
const childElement = this.parseChild(child);
|
|
167
188
|
let nodeToAppendOn = contentElement;
|
|
168
189
|
if (child.parentElementSelector) {
|
|
169
190
|
nodeToAppendOn = element.querySelector(child.parentElementSelector) || contentElement;
|
|
170
191
|
}
|
|
171
192
|
if (nodeToAppendOn.shadowRoot)
|
|
172
193
|
nodeToAppendOn.shadowRoot.appendChild(childElement);
|
|
194
|
+
else if (nodeToAppendOn.tagName.toLocaleLowerCase() == "template") {
|
|
195
|
+
const template = nodeToAppendOn;
|
|
196
|
+
template.content.appendChild(childElement);
|
|
197
|
+
}
|
|
173
198
|
else
|
|
174
199
|
nodeToAppendOn.appendChild(childElement);
|
|
175
200
|
}
|
|
@@ -185,9 +210,9 @@ let SonicSDUI = class SonicSDUI extends Fetcher(Subscriber(LitElement)) {
|
|
|
185
210
|
handleLibrary(node, tagName) {
|
|
186
211
|
let element;
|
|
187
212
|
let contentElement;
|
|
188
|
-
if (node.libraryKey && this.
|
|
189
|
-
element = this.parseChild(this.
|
|
190
|
-
|
|
213
|
+
if (node.libraryKey && this.sduiDescriptor.library) {
|
|
214
|
+
element = this.parseChild(this.sduiDescriptor.library[node.libraryKey] || { tagName: "div" });
|
|
215
|
+
const selector = (this.sduiDescriptor.library[node.libraryKey] || {}).contentElementSelector;
|
|
191
216
|
if (selector)
|
|
192
217
|
contentElement = element.querySelector(selector);
|
|
193
218
|
}
|
|
@@ -199,12 +224,10 @@ let SonicSDUI = class SonicSDUI extends Fetcher(Subscriber(LitElement)) {
|
|
|
199
224
|
* Remplissage des attributs html avec les attributs fournis dans le noeud
|
|
200
225
|
*/
|
|
201
226
|
handleAttributes(node, element) {
|
|
202
|
-
|
|
203
|
-
for (
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
attr = JSON.stringify(attr);
|
|
207
|
-
}
|
|
227
|
+
const attributes = node.attributes;
|
|
228
|
+
for (const k in attributes) {
|
|
229
|
+
const attrData = attributes[k];
|
|
230
|
+
const attr = Objects.isObject(attrData) ? JSON.stringify(attrData) : attrData;
|
|
208
231
|
element.setAttribute(k, attr);
|
|
209
232
|
}
|
|
210
233
|
}
|
|
@@ -227,7 +250,7 @@ let SonicSDUI = class SonicSDUI extends Fetcher(Subscriber(LitElement)) {
|
|
|
227
250
|
if (!node.innerHTML)
|
|
228
251
|
return;
|
|
229
252
|
if (node.innerHTML.indexOf("wording_") != -1) {
|
|
230
|
-
|
|
253
|
+
const wordingProvider = this.getAncestorAttributeValue("wordingProvider");
|
|
231
254
|
(_a = this.api) === null || _a === void 0 ? void 0 : _a.post(wordingProvider, { labels: [node.innerHTML.substring(8)] }).then((value) => {
|
|
232
255
|
if (contentElement)
|
|
233
256
|
contentElement.innerHTML += value;
|
|
@@ -240,7 +263,10 @@ let SonicSDUI = class SonicSDUI extends Fetcher(Subscriber(LitElement)) {
|
|
|
240
263
|
};
|
|
241
264
|
__decorate([
|
|
242
265
|
property()
|
|
243
|
-
], SonicSDUI.prototype, "
|
|
266
|
+
], SonicSDUI.prototype, "sduiKey", void 0);
|
|
267
|
+
__decorate([
|
|
268
|
+
property()
|
|
269
|
+
], SonicSDUI.prototype, "messagesKey", void 0);
|
|
244
270
|
SonicSDUI = __decorate([
|
|
245
271
|
customElement(tagName)
|
|
246
272
|
], SonicSDUI);
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type SDUIDescriptor = {
|
|
2
2
|
js?: Array<string>;
|
|
3
3
|
css?: Array<string>;
|
|
4
4
|
library?: Record<string, SDUINode>;
|
|
5
5
|
nodes?: Array<SDUINode>;
|
|
6
6
|
};
|
|
7
|
-
export
|
|
7
|
+
export type SDUINode = {
|
|
8
8
|
libraryKey?: string;
|
|
9
9
|
markup?: string;
|
|
10
10
|
tagName?: string;
|
|
11
|
-
attributes
|
|
11
|
+
attributes?: Record<string, string>;
|
|
12
12
|
nodes?: Array<SDUINode>;
|
|
13
13
|
innerHTML?: string;
|
|
14
14
|
prefix?: string;
|
|
@@ -16,19 +16,21 @@ export declare type SDUINode = {
|
|
|
16
16
|
contentElementSelector?: string;
|
|
17
17
|
parentElementSelector?: string;
|
|
18
18
|
};
|
|
19
|
-
export
|
|
19
|
+
export type SDUITransformDescription = {
|
|
20
20
|
library?: Record<string, SDUINode>;
|
|
21
21
|
transforms: Array<SDUITransformAction>;
|
|
22
22
|
};
|
|
23
|
-
export
|
|
24
|
-
|
|
23
|
+
export type SDUITransformActionName = "remap" | "unwrap" | "wrap" | "delete" | "insert" | "move";
|
|
24
|
+
export type SDUITransformActionFunction = (transformAction: SDUITransformAction, list: SDUITransformList) => void;
|
|
25
|
+
export type SDUITransformAction = {
|
|
26
|
+
action: SDUITransformActionName;
|
|
25
27
|
patterns?: Array<SDUINode>;
|
|
26
28
|
after?: SDUINode;
|
|
27
29
|
before?: SDUINode;
|
|
28
30
|
in?: SDUINode;
|
|
29
|
-
ui?:
|
|
31
|
+
ui?: SDUINode;
|
|
30
32
|
};
|
|
31
|
-
export
|
|
33
|
+
export type SDUITransformList = Array<{
|
|
32
34
|
parent: SDUINode;
|
|
33
35
|
child: SDUINode;
|
|
34
36
|
index: number;
|
|
@@ -1,11 +1,27 @@
|
|
|
1
1
|
import { LitElement } from "lit";
|
|
2
|
-
|
|
2
|
+
import { PublisherInterface, TypeAndRecordOfType } from "@supersoniks/concorde/core/_types/types";
|
|
3
|
+
declare const SonicStates_base: (new (...args: any[]) => import("@supersoniks/concorde/core/mixins/Subscriber").SubscriberInterface<import("@supersoniks/concorde/core/_types/types").CoreJSType>) & (new (...args: any[]) => import("@supersoniks/concorde/core/mixins/TemplatesContainer").TemplatesContainerInterface) & typeof LitElement;
|
|
4
|
+
/**
|
|
5
|
+
* ### 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):
|
|
6
|
+
* * Il boucle sur ses template enfants et test si la regexp contenue dans l'attribut *data-value* match la valeur de la propriété
|
|
7
|
+
* * Si oui le contenu du template correspontant est affiché comme état.
|
|
8
|
+
* * Si l'attribut dataProviderExpression est fourni le contenu est entouré d'une div :
|
|
9
|
+
* * 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.
|
|
10
|
+
* * Les subscribers/fetch... du template se réfèrerons à ce dataProvider
|
|
11
|
+
* * On peut également utiliser les des expressions du type url-pattern pour les paramètres de la route voir les exemples
|
|
12
|
+
*
|
|
13
|
+
* **Exemples**
|
|
14
|
+
* Avec ma.propriete= 2 :
|
|
15
|
+
* * RegExp data-value = (\d+) et dataproviderExpression = /user/$1 l'attribut dataProvider vaudra "/user/2"
|
|
16
|
+
* * url-pattern data-value = :id et dataproviderExpression = /user/:id l'attribut dataProvider vaudra "/user/2"
|
|
17
|
+
*
|
|
18
|
+
*/
|
|
3
19
|
export declare class SonicStates extends SonicStates_base {
|
|
4
20
|
state: string;
|
|
5
|
-
inverted:
|
|
21
|
+
inverted: boolean;
|
|
6
22
|
statePath: string;
|
|
7
|
-
onAssign: (
|
|
8
|
-
statePublisher
|
|
23
|
+
onAssign: (value: string) => void;
|
|
24
|
+
statePublisher?: TypeAndRecordOfType<PublisherInterface<string & object>>;
|
|
9
25
|
connectedCallback(): void;
|
|
10
26
|
disconnectedCallback(): void;
|
|
11
27
|
render(): import("lit-html").TemplateResult<1>;
|
|
@@ -12,6 +12,7 @@ import { repeat } from "lit/directives/repeat.js";
|
|
|
12
12
|
import Objects from "@supersoniks/concorde/core/utils/Objects";
|
|
13
13
|
import UrlPattern from "url-pattern";
|
|
14
14
|
import TemplatesContainer from "@supersoniks/concorde/core/mixins/TemplatesContainer";
|
|
15
|
+
const tagName = "sonic-states";
|
|
15
16
|
/**
|
|
16
17
|
* ### 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
18
|
* * Il boucle sur ses template enfants et test si la regexp contenue dans l'attribut *data-value* match la valeur de la propriété
|
|
@@ -27,14 +28,16 @@ import TemplatesContainer from "@supersoniks/concorde/core/mixins/TemplatesConta
|
|
|
27
28
|
* * url-pattern data-value = :id et dataproviderExpression = /user/:id l'attribut dataProvider vaudra "/user/2"
|
|
28
29
|
*
|
|
29
30
|
*/
|
|
30
|
-
const tagName = "sonic-states";
|
|
31
31
|
let SonicStates = class SonicStates extends Subscriber(TemplatesContainer(LitElement)) {
|
|
32
32
|
constructor() {
|
|
33
33
|
super(...arguments);
|
|
34
34
|
this.state = "";
|
|
35
35
|
this.inverted = false;
|
|
36
36
|
this.statePath = "";
|
|
37
|
-
this.onAssign =
|
|
37
|
+
this.onAssign = (value) => {
|
|
38
|
+
this.state = value;
|
|
39
|
+
this.requestUpdate();
|
|
40
|
+
};
|
|
38
41
|
}
|
|
39
42
|
connectedCallback() {
|
|
40
43
|
super.connectedCallback();
|
|
@@ -43,29 +46,26 @@ let SonicStates = class SonicStates extends Subscriber(TemplatesContainer(LitEle
|
|
|
43
46
|
}
|
|
44
47
|
if (this.statePath) {
|
|
45
48
|
this.statePublisher = this.publisher;
|
|
46
|
-
|
|
47
|
-
for (
|
|
49
|
+
const split = this.statePath.split(".");
|
|
50
|
+
for (const s of split) {
|
|
48
51
|
this.statePublisher = this.statePublisher[s];
|
|
49
52
|
}
|
|
50
|
-
this.onAssign = (value) => {
|
|
51
|
-
this.state = value;
|
|
52
|
-
this.requestUpdate();
|
|
53
|
-
};
|
|
54
53
|
this.statePublisher.onAssign(this.onAssign);
|
|
55
54
|
}
|
|
56
55
|
}
|
|
57
56
|
disconnectedCallback() {
|
|
57
|
+
var _a;
|
|
58
58
|
if (this.statePath)
|
|
59
|
-
this.statePublisher.offAssign(this.onAssign);
|
|
59
|
+
(_a = this.statePublisher) === null || _a === void 0 ? void 0 : _a.offAssign(this.onAssign);
|
|
60
60
|
super.disconnectedCallback();
|
|
61
61
|
}
|
|
62
62
|
render() {
|
|
63
|
-
|
|
63
|
+
const templates = [];
|
|
64
64
|
let state = this.state;
|
|
65
65
|
if ((!Array.isArray(state) && Objects.isObject(state)) || state === undefined) {
|
|
66
66
|
state = "";
|
|
67
67
|
}
|
|
68
|
-
for (
|
|
68
|
+
for (const t of this.templatePartsList) {
|
|
69
69
|
let path = t.getAttribute(this.templateValueAttribute);
|
|
70
70
|
let stateToMatch = state;
|
|
71
71
|
if (this.inverted) {
|
|
@@ -74,13 +74,13 @@ let SonicStates = class SonicStates extends Subscriber(TemplatesContainer(LitEle
|
|
|
74
74
|
}
|
|
75
75
|
if (path == "")
|
|
76
76
|
path = this.inverted ? ".*?" : "^$";
|
|
77
|
-
|
|
77
|
+
const regexp = new RegExp(path);
|
|
78
78
|
if (regexp.test(stateToMatch)) {
|
|
79
79
|
templates.push(t);
|
|
80
80
|
t.removeAttribute("mode");
|
|
81
81
|
}
|
|
82
82
|
else {
|
|
83
|
-
|
|
83
|
+
const urlPattern = new UrlPattern(path);
|
|
84
84
|
if (urlPattern.names.length > 0 && urlPattern.match(stateToMatch)) {
|
|
85
85
|
t.setAttribute("mode", "patternMatching");
|
|
86
86
|
templates.push(t);
|
|
@@ -95,7 +95,7 @@ let SonicStates = class SonicStates extends Subscriber(TemplatesContainer(LitEle
|
|
|
95
95
|
if (template.title)
|
|
96
96
|
document.title = template.title;
|
|
97
97
|
if (template.hasAttribute("dataProviderExpression")) {
|
|
98
|
-
|
|
98
|
+
const dataProviderExpression = template.getAttribute("dataProviderExpression");
|
|
99
99
|
let dataProvider = "";
|
|
100
100
|
let stateToMatch = state;
|
|
101
101
|
let path = template.getAttribute(this.templateValueAttribute);
|
|
@@ -112,7 +112,7 @@ let SonicStates = class SonicStates extends Subscriber(TemplatesContainer(LitEle
|
|
|
112
112
|
}
|
|
113
113
|
else {
|
|
114
114
|
const regexp = new RegExp(path);
|
|
115
|
-
|
|
115
|
+
const match = (stateToMatch + "").match(regexp);
|
|
116
116
|
if (match) {
|
|
117
117
|
dataProvider = (_a = match.shift()) === null || _a === void 0 ? void 0 : _a.replace(regexp, dataProviderExpression);
|
|
118
118
|
}
|
|
@@ -133,8 +133,3 @@ SonicStates = __decorate([
|
|
|
133
133
|
customElement(tagName)
|
|
134
134
|
], SonicStates);
|
|
135
135
|
export { SonicStates };
|
|
136
|
-
//Ajout pour custom-elements-manifesy pour storybook notamment
|
|
137
|
-
try {
|
|
138
|
-
customElements.define(tagName, SonicStates);
|
|
139
|
-
}
|
|
140
|
-
catch (e) { }
|
|
@@ -1,15 +1,30 @@
|
|
|
1
1
|
import "@supersoniks/concorde/core/components/ui/button/button";
|
|
2
2
|
import API from "@supersoniks/concorde/core/utils/api";
|
|
3
3
|
import { LitElement } from "lit";
|
|
4
|
-
declare const Submit_base: (new (...args: any[]) => import("@supersoniks/concorde/core/mixins/Subscriber").SubscriberInterface) & typeof LitElement;
|
|
4
|
+
declare const Submit_base: (new (...args: any[]) => import("@supersoniks/concorde/core/mixins/Subscriber").SubscriberInterface<import("@supersoniks/concorde/core/_types/types").CoreJSType>) & 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
|
+
*/
|
|
5
16
|
export declare class Submit extends Submit_base {
|
|
6
17
|
static styles: import("lit").CSSResult;
|
|
7
18
|
submitResultKey: string | null;
|
|
8
19
|
disabled: boolean;
|
|
9
20
|
endPoint: string | null;
|
|
21
|
+
name: string;
|
|
22
|
+
value: string;
|
|
10
23
|
api: API | null;
|
|
11
24
|
connectedCallback(): void;
|
|
25
|
+
submitNativeForm(): void;
|
|
12
26
|
submit(): Promise<void>;
|
|
27
|
+
saveCredentials(username: string, password: string): Promise<void>;
|
|
13
28
|
protected render(): unknown;
|
|
14
29
|
}
|
|
15
30
|
export {};
|
|
@@ -13,14 +13,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
13
13
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
14
14
|
});
|
|
15
15
|
};
|
|
16
|
-
import { customElement, property } from "lit/decorators.js";
|
|
17
|
-
import { PublisherManager } from "@supersoniks/concorde/core/utils/PublisherProxy.mjs";
|
|
18
16
|
import "@supersoniks/concorde/core/components/ui/button/button";
|
|
17
|
+
import { Loader } from "@supersoniks/concorde/core/components/ui/loader/loader";
|
|
19
18
|
import Subscriber from "@supersoniks/concorde/core/mixins/Subscriber";
|
|
20
19
|
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
20
|
import Objects from "@supersoniks/concorde/core/utils/Objects";
|
|
21
|
+
import { PublisherManager } from "@supersoniks/concorde/core/utils/PublisherProxy";
|
|
22
|
+
import { HTML } from "@supersoniks/concorde/utils";
|
|
23
|
+
import { css, html, LitElement } from "lit";
|
|
24
|
+
import { customElement, property } from "lit/decorators.js";
|
|
25
|
+
const tagName = "sonic-submit";
|
|
24
26
|
/**
|
|
25
27
|
* ###L'élément submit permet d'envoyer des données en rest
|
|
26
28
|
* * Les données envoyées sont celles présentes dans le publisher dont l'adresse est renseignée via l'attribut *formDataProvider*.
|
|
@@ -32,13 +34,14 @@ import Objects from "@supersoniks/concorde/core/utils/Objects";
|
|
|
32
34
|
* * 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
|
|
33
35
|
* * L'attribut *clearedDataOnSuccess* peut être utilisé pour vider les données des dataProvider correspondants lorsque l'appel à l'api a fourni un résultat.
|
|
34
36
|
*/
|
|
35
|
-
const tagName = "sonic-submit";
|
|
36
37
|
let Submit = class Submit extends Subscriber(LitElement) {
|
|
37
38
|
constructor() {
|
|
38
39
|
super(...arguments);
|
|
39
40
|
this.submitResultKey = null;
|
|
40
41
|
this.disabled = false;
|
|
41
42
|
this.endPoint = null;
|
|
43
|
+
this.name = "";
|
|
44
|
+
this.value = "";
|
|
42
45
|
this.api = null;
|
|
43
46
|
}
|
|
44
47
|
connectedCallback() {
|
|
@@ -54,6 +57,42 @@ let Submit = class Submit extends Subscriber(LitElement) {
|
|
|
54
57
|
super.connectedCallback();
|
|
55
58
|
this.api = new API(this.getApiConfiguration());
|
|
56
59
|
}
|
|
60
|
+
submitNativeForm() {
|
|
61
|
+
const form = HTML.getClosestForm(this);
|
|
62
|
+
if (!form)
|
|
63
|
+
return;
|
|
64
|
+
const formDataProvider = this.getAncestorAttributeValue("formDataProvider");
|
|
65
|
+
const formData = PublisherManager.get(formDataProvider).get();
|
|
66
|
+
for (const name in formData) {
|
|
67
|
+
if (name == "isFormValid")
|
|
68
|
+
continue;
|
|
69
|
+
let control = form.querySelector('input[name="' + name + '"], select[name="' + name + '"], textarea[name="' + name + '"]');
|
|
70
|
+
if (!control) {
|
|
71
|
+
control = document.createElement("input");
|
|
72
|
+
control.type = "hidden";
|
|
73
|
+
control.name = name;
|
|
74
|
+
form.appendChild(control);
|
|
75
|
+
}
|
|
76
|
+
let value = formData[name];
|
|
77
|
+
if (Array.isArray(value))
|
|
78
|
+
value = value.join(",");
|
|
79
|
+
if (control.type === "checkbox" || control.type === "radio") {
|
|
80
|
+
if (value)
|
|
81
|
+
control.checked = true;
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
control.value = value;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
const submitButton = document.createElement("input");
|
|
88
|
+
submitButton.name = this.name;
|
|
89
|
+
submitButton.style.display = "none";
|
|
90
|
+
submitButton.value = this.value;
|
|
91
|
+
submitButton.type = "submit";
|
|
92
|
+
form.appendChild(submitButton);
|
|
93
|
+
if (submitButton)
|
|
94
|
+
submitButton.click();
|
|
95
|
+
}
|
|
57
96
|
submit() {
|
|
58
97
|
var _a, _b, _c;
|
|
59
98
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -67,24 +106,33 @@ let Submit = class Submit extends Subscriber(LitElement) {
|
|
|
67
106
|
if (this.publisher)
|
|
68
107
|
this.publisher.disabled = true;
|
|
69
108
|
formPublisher.isFormValid;
|
|
109
|
+
// support native html form
|
|
110
|
+
const native = this.hasAttribute("native");
|
|
111
|
+
if (native) {
|
|
112
|
+
this.submitNativeForm();
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
70
115
|
//
|
|
71
116
|
//Recup données
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
117
|
+
const method = ((_a = this.getAttribute("method")) === null || _a === void 0 ? void 0 : _a.toLocaleLowerCase()) || "post";
|
|
118
|
+
const sendAsFormData = this.hasAttribute("sendAsFormData");
|
|
119
|
+
const formData = formPublisher.get();
|
|
75
120
|
delete formData.isFormValid;
|
|
76
|
-
const
|
|
77
|
-
|
|
121
|
+
const headesDataProvider = this.getAncestorAttributeValue("headersDataProvider");
|
|
122
|
+
const headerPublisher = headesDataProvider ? PublisherManager.getInstance().get(headesDataProvider) : null;
|
|
123
|
+
let headerData = {};
|
|
124
|
+
if (headerPublisher)
|
|
125
|
+
headerData = headerPublisher.get();
|
|
78
126
|
let result = null;
|
|
79
|
-
|
|
80
|
-
|
|
127
|
+
const dataProvider = this.getAncestorAttributeValue("dataProvider");
|
|
128
|
+
const endPoint = this.endPoint || dataProvider;
|
|
81
129
|
Loader.show();
|
|
82
|
-
|
|
83
|
-
var _d, _e, _f, _g, _h;
|
|
130
|
+
const sendData = () => __awaiter(this, void 0, void 0, function* () {
|
|
131
|
+
var _d, _e, _f, _g, _h, _j, _k;
|
|
84
132
|
//
|
|
85
133
|
//envoi données
|
|
86
134
|
if (sendAsFormData) {
|
|
87
|
-
result = yield ((_d = this.api) === null || _d === void 0 ? void 0 : _d.submitFormData(endPoint, formData, headerData));
|
|
135
|
+
result = yield ((_d = this.api) === null || _d === void 0 ? void 0 : _d.submitFormData(endPoint, formData, method, headerData));
|
|
88
136
|
}
|
|
89
137
|
else {
|
|
90
138
|
switch (method) {
|
|
@@ -108,27 +156,35 @@ let Submit = class Submit extends Subscriber(LitElement) {
|
|
|
108
156
|
// Si result ne contient que la réponse HTTP, avec un status not ok, on ajoute un message
|
|
109
157
|
else if (result._sonic_http_response_ && !result._sonic_http_response_.ok && Object.keys(result).length === 1)
|
|
110
158
|
result.messages = [{ content: "Network Error", status: "error" }];
|
|
111
|
-
|
|
159
|
+
const clearedDataProvider = this.getAncestorAttributeValue("clearedDataOnSuccess");
|
|
112
160
|
if (clearedDataProvider) {
|
|
113
161
|
clearedDataProvider.split(" ").forEach((dataProvider) => PublisherManager.get(dataProvider).set({}));
|
|
114
162
|
}
|
|
163
|
+
const username_key = this.hasAttribute("usernameKey") ? this.getAttribute("usernameKey") : "username";
|
|
164
|
+
const password_key = this.hasAttribute("passwordKey") ? this.getAttribute("passwordKey") : "password";
|
|
165
|
+
if (((_k = (_j = this.api) === null || _j === void 0 ? void 0 : _j.lastResult) === null || _k === void 0 ? void 0 : _k.ok) && formData[username_key] && formData[password_key]) {
|
|
166
|
+
this.saveCredentials(formData[username_key], formData[password_key]);
|
|
167
|
+
}
|
|
115
168
|
if (this.submitResultKey) {
|
|
116
169
|
result = Objects.traverse(result, this.submitResultKey.split("."), true);
|
|
117
170
|
}
|
|
118
|
-
|
|
171
|
+
const submitResultDataProvider = this.getAncestorAttributeValue("submitResultDataProvider");
|
|
172
|
+
if (submitResultDataProvider)
|
|
173
|
+
PublisherManager.get(submitResultDataProvider).set(result);
|
|
119
174
|
if (this.publisher)
|
|
120
175
|
this.publisher.disabled = null;
|
|
121
176
|
});
|
|
122
|
-
|
|
177
|
+
const captchaPublisher = (headerPublisher === null || headerPublisher === void 0 ? void 0 : headerPublisher.needsCaptchaValidation.get())
|
|
123
178
|
? headerPublisher
|
|
124
179
|
: formPublisher.needsCaptchaValidation.get()
|
|
125
180
|
? formPublisher
|
|
126
181
|
: null;
|
|
127
182
|
if (captchaPublisher) {
|
|
128
183
|
captchaPublisher.captchaMethod = method;
|
|
129
|
-
captchaPublisher.captchaAction =
|
|
184
|
+
captchaPublisher.captchaAction =
|
|
185
|
+
(_c = (_b = dataProvider === null || dataProvider === void 0 ? void 0 : dataProvider.split("?")[0]) !== null && _b !== void 0 ? _b : this.getAncestorAttributeValue("formDataProvider")) !== null && _c !== void 0 ? _c : "submit";
|
|
130
186
|
captchaPublisher.captchaToken = "request_token";
|
|
131
|
-
|
|
187
|
+
const captchaAssign = (token) => {
|
|
132
188
|
if (token != "request_token") {
|
|
133
189
|
sendData();
|
|
134
190
|
// Après l'envoie des données, on supprime ce onAssign.
|
|
@@ -143,6 +199,19 @@ let Submit = class Submit extends Subscriber(LitElement) {
|
|
|
143
199
|
}
|
|
144
200
|
});
|
|
145
201
|
}
|
|
202
|
+
saveCredentials(username, password) {
|
|
203
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
204
|
+
// Check if the browser supports password credentials (and the Credential Management API)
|
|
205
|
+
if ("PasswordCredential" in window) {
|
|
206
|
+
const credential = new window.PasswordCredential({
|
|
207
|
+
id: username,
|
|
208
|
+
// name: "Carina Anand", // In case of a login, the name comes from the server.
|
|
209
|
+
password: password,
|
|
210
|
+
});
|
|
211
|
+
yield navigator.credentials.store(credential);
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
}
|
|
146
215
|
render() {
|
|
147
216
|
return html `<div ?data-disabled=${this.disabled}><slot></slot></div>`;
|
|
148
217
|
}
|
|
@@ -163,12 +232,13 @@ __decorate([
|
|
|
163
232
|
__decorate([
|
|
164
233
|
property({ type: String })
|
|
165
234
|
], Submit.prototype, "endPoint", void 0);
|
|
235
|
+
__decorate([
|
|
236
|
+
property()
|
|
237
|
+
], Submit.prototype, "name", void 0);
|
|
238
|
+
__decorate([
|
|
239
|
+
property()
|
|
240
|
+
], Submit.prototype, "value", void 0);
|
|
166
241
|
Submit = __decorate([
|
|
167
242
|
customElement(tagName)
|
|
168
243
|
], Submit);
|
|
169
244
|
export { Submit };
|
|
170
|
-
//Ajout pour la creation du cem notamment pour Storybook
|
|
171
|
-
try {
|
|
172
|
-
customElements.define(tagName, Submit);
|
|
173
|
-
}
|
|
174
|
-
catch (e) { }
|