@supersoniks/concorde 1.1.43 → 1.1.45
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 +9 -7
- package/concorde-core.bundle.js +20 -20
- package/concorde-core.es.js +987 -804
- package/core/_types/types.d.ts +13 -8
- package/core/_types/types.js +1 -0
- package/core/components/functional/date/date.d.ts +2 -2
- package/core/components/functional/date/date.js +10 -10
- package/core/components/functional/example/example.d.ts +1 -1
- package/core/components/functional/fetch/fetch.d.ts +8 -6
- package/core/components/functional/list/list.d.ts +16 -8
- package/core/components/functional/list/list.js +29 -14
- package/core/components/functional/mix/mix.d.ts +5 -5
- package/core/components/functional/mix/mix.js +11 -8
- package/core/components/functional/queue/queue.d.ts +13 -4
- package/core/components/functional/queue/queue.js +33 -27
- package/core/components/functional/router/redirect.d.ts +2 -2
- package/core/components/functional/router/redirect.js +2 -6
- package/core/components/functional/router/router.d.ts +1 -1
- package/core/components/functional/router/router.js +22 -13
- package/core/components/functional/sdui/SDUIDescriptorTransformer.d.ts +0 -1
- package/core/components/functional/sdui/SDUIDescriptorTransformer.js +35 -36
- package/core/components/functional/sdui/sdui-utils.js +11 -11
- package/core/components/functional/sdui/sdui.d.ts +11 -10
- package/core/components/functional/sdui/sdui.js +33 -34
- package/core/components/functional/sdui/types.d.ts +8 -8
- package/core/components/functional/states/states.d.ts +3 -3
- package/core/components/functional/states/states.js +9 -8
- package/core/components/functional/submit/submit.d.ts +1 -1
- package/core/components/functional/submit/submit.js +16 -16
- package/core/components/functional/subscriber/subscriber.d.ts +1 -1
- package/core/components/functional/value/value.d.ts +1 -1
- package/core/components/functional/value/value.js +3 -2
- package/core/components/ui/_css/size.d.ts +1 -1
- package/core/components/ui/button/button.d.ts +6 -4
- package/core/components/ui/button/button.js +34 -30
- package/core/components/ui/captcha/captcha.d.ts +2 -2
- package/core/components/ui/captcha/captcha.js +2 -2
- package/core/components/ui/card/card-header.js +5 -1
- package/core/components/ui/card/card.js +7 -5
- package/core/components/ui/form/checkbox/checkbox.d.ts +36 -12
- package/core/components/ui/form/fieldset/fieldset.d.ts +1 -1
- package/core/components/ui/form/form-layout/form-layout.d.ts +1 -1
- package/core/components/ui/form/input/input.d.ts +14 -9
- package/core/components/ui/form/input/input.js +2 -2
- package/core/components/ui/form/input/password-helper.d.ts +1 -1
- package/core/components/ui/form/input/password-helper.js +1 -1
- package/core/components/ui/form/input/same-value-helper.d.ts +1 -1
- package/core/components/ui/form/input/same-value-helper.js +2 -2
- package/core/components/ui/form/input-autocomplete/input-autocomplete.d.ts +1 -1
- package/core/components/ui/form/input-autocomplete/input-autocomplete.js +1 -1
- package/core/components/ui/form/select/select.d.ts +5 -4
- package/core/components/ui/form/select/select.js +24 -12
- package/core/components/ui/form/textarea/textarea.d.ts +11 -9
- package/core/components/ui/form/textarea/textarea.js +1 -1
- package/core/components/ui/group/group.js +8 -2
- package/core/components/ui/icon/icons.js +15 -13
- package/core/components/ui/loader/loader.d.ts +1 -1
- package/core/components/ui/loader/loader.js +1 -1
- package/core/components/ui/menu/menu.js +15 -16
- package/core/components/ui/modal/modal.d.ts +1 -1
- package/core/components/ui/modal/modal.js +1 -1
- package/core/components/ui/pop/pop.d.ts +6 -5
- package/core/components/ui/pop/pop.js +76 -46
- package/core/components/ui/table/table-tbody.js +1 -1
- package/core/components/ui/theme/theme.js +15 -13
- package/core/components/ui/toast/message-subscriber.d.ts +12 -9
- package/core/components/ui/toast/message-subscriber.js +10 -8
- package/core/components/ui/toast/toast.d.ts +1 -1
- package/core/components/ui/toast/toast.js +7 -8
- package/core/components/ui/toast/types.d.ts +3 -2
- package/core/components/ui/tooltip/tooltip.js +4 -4
- package/core/components/ui/ui.d.ts +1 -1
- package/core/components/ui/ui.js +1 -1
- package/core/mixins/Fetcher.d.ts +15 -17
- package/core/mixins/Fetcher.js +19 -10
- package/core/mixins/FormCheckable.d.ts +8 -5
- package/core/mixins/FormCheckable.js +21 -19
- package/core/mixins/FormElement.d.ts +10 -7
- package/core/mixins/FormElement.js +24 -23
- package/core/mixins/FormInput.d.ts +16 -10
- package/core/mixins/FormInput.js +1 -1
- package/core/mixins/Subscriber.d.ts +8 -6
- package/core/mixins/Subscriber.js +24 -23
- package/core/mixins/TemplatesContainer.d.ts +2 -1
- package/core/mixins/TemplatesContainer.js +2 -2
- package/core/utils/Arrays.js +12 -9
- package/core/utils/DataBindObserver.d.ts +4 -4
- package/core/utils/DataBindObserver.js +26 -28
- package/core/utils/HTML.d.ts +1 -1
- package/core/utils/HTML.js +2 -2
- package/core/utils/LocationHandler.js +10 -10
- package/core/utils/Objects.js +10 -4
- package/core/utils/PublisherProxy.d.ts +21 -15
- package/core/utils/PublisherProxy.js +67 -63
- package/core/utils/api.d.ts +40 -32
- package/core/utils/api.js +127 -32
- package/mixins.d.ts +25 -19
- package/package.json +11 -6
- package/core/components/ui/taxonomy/taxonomy.d.ts +0 -44
- package/core/components/ui/taxonomy/taxonomy.js +0 -115
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { FormElementInterface } from "@supersoniks/concorde/core/mixins/FormElement";
|
|
2
|
-
|
|
2
|
+
import { MixinArgsType } from "../_types/types";
|
|
3
|
+
type Constructor<T> = new (...args: MixinArgsType[]) => T;
|
|
3
4
|
declare const Form: <T extends Constructor<FormElementInterface>>(superClass: T) => {
|
|
4
|
-
new (...args:
|
|
5
|
+
new (...args: MixinArgsType[]): {
|
|
5
6
|
/**
|
|
6
7
|
* Voir la mixin FormElement.
|
|
7
8
|
*/
|
|
@@ -56,9 +57,11 @@ declare const Form: <T extends Constructor<FormElementInterface>>(superClass: T)
|
|
|
56
57
|
ariaLabel?: string | undefined;
|
|
57
58
|
_name: string;
|
|
58
59
|
name: string;
|
|
59
|
-
props:
|
|
60
|
-
propertyMap:
|
|
60
|
+
props: import("../_types/types").CoreJSType;
|
|
61
|
+
propertyMap: object;
|
|
61
62
|
isConnected: boolean;
|
|
63
|
+
children: HTMLCollection;
|
|
64
|
+
appendChild(node: Node): Node;
|
|
62
65
|
getAncestorAttributeValue(attributeName: string): string;
|
|
63
66
|
hasAncestorAttribute(attributeName: string): boolean;
|
|
64
67
|
querySelectorAll(selector: string): NodeListOf<Element>;
|
|
@@ -77,7 +80,7 @@ declare const Form: <T extends Constructor<FormElementInterface>>(superClass: T)
|
|
|
77
80
|
getApiConfiguration(): import("../utils/api").APIConfiguration;
|
|
78
81
|
requestUpdate(): void;
|
|
79
82
|
getAttribute(name: string): string;
|
|
80
|
-
hasAttribute(attributeName:
|
|
83
|
+
hasAttribute(attributeName: string): boolean;
|
|
81
84
|
};
|
|
82
85
|
} & T;
|
|
83
86
|
export default Form;
|
|
@@ -37,9 +37,9 @@ const Form = (superClass) => {
|
|
|
37
37
|
*/
|
|
38
38
|
this._checked = null;
|
|
39
39
|
this.updateAllChecked = () => {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
const name = this.getAttribute("name");
|
|
41
|
+
const checkAllPublisher = this.getCheckAllPublisher();
|
|
42
|
+
const formPublisher = this.getFormPublisher();
|
|
43
43
|
if (!(checkAllPublisher === null || checkAllPublisher === void 0 ? void 0 : checkAllPublisher.hasCheckAll.get())) {
|
|
44
44
|
return;
|
|
45
45
|
}
|
|
@@ -54,11 +54,11 @@ const Form = (superClass) => {
|
|
|
54
54
|
else if (checkAllPublisher.checkMode.get() == "noneChecked" || checkAllPublisher.checkMode.get() == null) {
|
|
55
55
|
checkAllPublisher.checkMode = "someUnchecked";
|
|
56
56
|
}
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
const currentValues = formPublisher[name].get();
|
|
58
|
+
const allValues = checkAllPublisher.values.get();
|
|
59
59
|
if (allValues && allValues.length) {
|
|
60
60
|
let checkedCount = allValues.length;
|
|
61
|
-
for (
|
|
61
|
+
for (const p of allValues) {
|
|
62
62
|
if (currentValues.indexOf(p) == -1) {
|
|
63
63
|
checkedCount -= 1;
|
|
64
64
|
}
|
|
@@ -108,7 +108,7 @@ const Form = (superClass) => {
|
|
|
108
108
|
if (!this.value)
|
|
109
109
|
return;
|
|
110
110
|
// On check l'élément si il est cheched dans le formPublisher
|
|
111
|
-
|
|
111
|
+
const formPublisher = this.getFormPublisher();
|
|
112
112
|
if (formPublisher && this.name) {
|
|
113
113
|
let currentValue = formPublisher[this.name].get();
|
|
114
114
|
if (this.radio || this.unique) {
|
|
@@ -131,13 +131,13 @@ const Form = (superClass) => {
|
|
|
131
131
|
set checked(checked) {
|
|
132
132
|
this.setCheckedValue(checked);
|
|
133
133
|
if (this.checksAll()) {
|
|
134
|
-
|
|
134
|
+
const checkAllPublisher = this.getCheckAllPublisher();
|
|
135
135
|
if (checkAllPublisher) {
|
|
136
136
|
if (this.checked === true)
|
|
137
137
|
checkAllPublisher.checkMode = "allChecked";
|
|
138
138
|
else if (this.checked === null) {
|
|
139
139
|
checkAllPublisher.checkMode = "noneChecked";
|
|
140
|
-
|
|
140
|
+
const formPublisher = this.getFormPublisher();
|
|
141
141
|
if (formPublisher) {
|
|
142
142
|
formPublisher[this.name] = [];
|
|
143
143
|
}
|
|
@@ -151,9 +151,9 @@ const Form = (superClass) => {
|
|
|
151
151
|
const input = (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector("input");
|
|
152
152
|
if (!input || input.checkValidity())
|
|
153
153
|
return;
|
|
154
|
-
|
|
154
|
+
const formPublisher = this.getFormPublisher();
|
|
155
155
|
if (formPublisher) {
|
|
156
|
-
|
|
156
|
+
const value = formPublisher[this.name].get();
|
|
157
157
|
if ((this.unique || this.radio) && value !== null && value.toString().length > 0)
|
|
158
158
|
return;
|
|
159
159
|
formPublisher.isFormValid = false;
|
|
@@ -187,7 +187,7 @@ const Form = (superClass) => {
|
|
|
187
187
|
* Le comportement est ici modifié fonction de son mode (checkbox, radio, unique)
|
|
188
188
|
*/
|
|
189
189
|
getValueForFormPublisher() {
|
|
190
|
-
|
|
190
|
+
const formPublisher = this.getFormPublisher();
|
|
191
191
|
if (!formPublisher)
|
|
192
192
|
return null;
|
|
193
193
|
let currentValue = formPublisher[this.name].get();
|
|
@@ -201,7 +201,7 @@ const Form = (superClass) => {
|
|
|
201
201
|
currentValue = [];
|
|
202
202
|
}
|
|
203
203
|
currentValue = currentValue.slice(0);
|
|
204
|
-
|
|
204
|
+
const idx = currentValue.indexOf(this.value);
|
|
205
205
|
if (this.checked === true && idx === -1 && !this.checksAll())
|
|
206
206
|
currentValue.push(this.value);
|
|
207
207
|
if (this.checked === null && idx !== -1) {
|
|
@@ -230,7 +230,7 @@ const Form = (superClass) => {
|
|
|
230
230
|
if (!this.formDataProvider)
|
|
231
231
|
this.formDataProvider = this.getAncestorAttributeValue("formDataProvider");
|
|
232
232
|
const formDataProvider = this.formDataProvider;
|
|
233
|
-
|
|
233
|
+
const name = this.getAttribute("name");
|
|
234
234
|
if (!formDataProvider || !name) {
|
|
235
235
|
return null;
|
|
236
236
|
}
|
|
@@ -238,11 +238,11 @@ const Form = (superClass) => {
|
|
|
238
238
|
}
|
|
239
239
|
disconnectedCallback() {
|
|
240
240
|
super.disconnectedCallback();
|
|
241
|
-
|
|
241
|
+
const checkAllPublisher = this.getCheckAllPublisher();
|
|
242
242
|
if (checkAllPublisher) {
|
|
243
243
|
checkAllPublisher.checkMode.offAssign(this.onChecksAllRequest);
|
|
244
244
|
if (!this.checksAll()) {
|
|
245
|
-
|
|
245
|
+
const values = checkAllPublisher.values.get().slice(0);
|
|
246
246
|
const idx = values.indexOf(this.value);
|
|
247
247
|
if (idx != -1) {
|
|
248
248
|
values.splice(idx, 1);
|
|
@@ -256,12 +256,14 @@ const Form = (superClass) => {
|
|
|
256
256
|
super.connectedCallback();
|
|
257
257
|
const formPublisher = this.getFormPublisher();
|
|
258
258
|
if (formPublisher && this.name) {
|
|
259
|
-
|
|
260
|
-
if (publisherValueForName &&
|
|
259
|
+
const publisherValueForName = formPublisher[this.name].get();
|
|
260
|
+
if (publisherValueForName &&
|
|
261
|
+
Array.isArray(publisherValueForName) &&
|
|
262
|
+
publisherValueForName.indexOf(this.value) !== -1) {
|
|
261
263
|
this.checked = true;
|
|
262
264
|
}
|
|
263
265
|
}
|
|
264
|
-
|
|
266
|
+
const checkAllPublisher = this.getCheckAllPublisher();
|
|
265
267
|
if (checkAllPublisher) {
|
|
266
268
|
checkAllPublisher.checkMode.onAssign(this.onChecksAllRequest);
|
|
267
269
|
if (this.checksAll()) {
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { SubscriberInterface } from "@supersoniks/concorde/core/mixins/Subscriber";
|
|
2
|
-
import { PublisherInterface } from "../_types/types";
|
|
3
|
-
|
|
2
|
+
import { PublisherInterface, CoreJSType } from "../_types/types";
|
|
3
|
+
import { MixinArgsType } from "../_types/types";
|
|
4
|
+
type Constructor<T> = new (...args: MixinArgsType[]) => T;
|
|
5
|
+
type FormElementValue = string | string[] | object | null | undefined;
|
|
4
6
|
export interface FormElementInterface extends SubscriberInterface {
|
|
5
7
|
getFormPublisher(): PublisherInterface;
|
|
6
8
|
updateDataValue(): void;
|
|
7
9
|
handleChange(e?: Event): void;
|
|
8
10
|
handleBlur(e?: Event): void;
|
|
9
|
-
getValueForFormPublisher():
|
|
11
|
+
getValueForFormPublisher(): FormElementValue;
|
|
12
|
+
validateFormElement(): void;
|
|
10
13
|
focus?: () => void;
|
|
11
14
|
shadowRoot?: ShadowRoot;
|
|
12
15
|
error: boolean;
|
|
@@ -16,12 +19,12 @@ export interface FormElementInterface extends SubscriberInterface {
|
|
|
16
19
|
formDataProvider: string;
|
|
17
20
|
ariaLabelledby?: string;
|
|
18
21
|
ariaLabel?: string;
|
|
19
|
-
_value:
|
|
20
|
-
get value():
|
|
21
|
-
set value(value:
|
|
22
|
+
_value: FormElementValue;
|
|
23
|
+
get value(): FormElementValue;
|
|
24
|
+
set value(value: FormElementValue);
|
|
22
25
|
_name: string;
|
|
23
26
|
get name(): string;
|
|
24
27
|
set name(value: string);
|
|
25
28
|
}
|
|
26
|
-
declare const Form: <T extends Constructor<SubscriberInterface<
|
|
29
|
+
declare const Form: <T extends Constructor<SubscriberInterface<CoreJSType>>>(superClass: T) => Constructor<FormElementInterface> & T;
|
|
27
30
|
export default Form;
|
|
@@ -43,7 +43,7 @@ const Form = (superClass) => {
|
|
|
43
43
|
this.setFormValueFromPublisher(value);
|
|
44
44
|
};
|
|
45
45
|
this.onFormDataInValidate = () => {
|
|
46
|
-
|
|
46
|
+
const formPublisher = this.getFormPublisher();
|
|
47
47
|
if (!(formPublisher && formPublisher.isFormValid.get())) {
|
|
48
48
|
return;
|
|
49
49
|
}
|
|
@@ -59,11 +59,13 @@ const Form = (superClass) => {
|
|
|
59
59
|
this._name = value;
|
|
60
60
|
this.requestUpdate();
|
|
61
61
|
}
|
|
62
|
-
validateFormElement() {
|
|
62
|
+
validateFormElement() {
|
|
63
|
+
//Implémentation dans une sous classe
|
|
64
|
+
}
|
|
63
65
|
updateDataValue() {
|
|
64
|
-
|
|
66
|
+
const name = this.getAttribute("name");
|
|
65
67
|
if (name) {
|
|
66
|
-
|
|
68
|
+
const formPublisher = this.getFormPublisher();
|
|
67
69
|
if (formPublisher) {
|
|
68
70
|
formPublisher[name] = this.getValueForFormPublisher();
|
|
69
71
|
this.setFormValueFromPublisher(formPublisher[name].get());
|
|
@@ -104,12 +106,11 @@ const Form = (superClass) => {
|
|
|
104
106
|
return this._value;
|
|
105
107
|
}
|
|
106
108
|
set value(value) {
|
|
107
|
-
if (this.name == "nom" && value && Objects.deepEqual(value, {})) {
|
|
108
|
-
console.trace(this);
|
|
109
|
-
}
|
|
110
109
|
if (value == null)
|
|
111
110
|
value = "";
|
|
112
|
-
if (Objects.isObject(value) &&
|
|
111
|
+
if (Objects.isObject(value) &&
|
|
112
|
+
Object.prototype.hasOwnProperty.call(value, "__value") &&
|
|
113
|
+
value._value == undefined)
|
|
113
114
|
value = "";
|
|
114
115
|
if (this._value == value)
|
|
115
116
|
return;
|
|
@@ -119,7 +120,7 @@ const Form = (superClass) => {
|
|
|
119
120
|
}
|
|
120
121
|
initPublisher() {
|
|
121
122
|
let formPublisher = this.getFormPublisher();
|
|
122
|
-
|
|
123
|
+
const value = this.hasAncestorAttribute("initFromPublisher") && this._name && formPublisher[this._name].get()
|
|
123
124
|
? formPublisher[this._name].get()
|
|
124
125
|
: this.getAttribute("value");
|
|
125
126
|
if (this._name && this.publisher)
|
|
@@ -160,35 +161,35 @@ const Form = (superClass) => {
|
|
|
160
161
|
* En appuyant sur la touche "Up", le déplacement inverse est effectué.
|
|
161
162
|
*/
|
|
162
163
|
addKeyboardNavigation() {
|
|
163
|
-
|
|
164
|
+
const keyboardLoopIds = this.getAncestorAttributeValue("data-keyboard-nav");
|
|
164
165
|
if (!keyboardLoopIds)
|
|
165
166
|
return;
|
|
166
|
-
|
|
167
|
-
|
|
167
|
+
const split = keyboardLoopIds.split(" ");
|
|
168
|
+
const keyboardLoopId = split[0];
|
|
168
169
|
if (!keyboardLoopId)
|
|
169
170
|
return;
|
|
170
|
-
for (
|
|
171
|
+
for (const keyboardLoopId2 of split) {
|
|
171
172
|
if (!keyboardLoops.has(keyboardLoopId2)) {
|
|
172
173
|
keyboardLoops.set(keyboardLoopId2, []);
|
|
173
174
|
}
|
|
174
|
-
|
|
175
|
+
const keyboardLoop = keyboardLoops.get(keyboardLoopId2);
|
|
175
176
|
if ((keyboardLoop === null || keyboardLoop === void 0 ? void 0 : keyboardLoop.indexOf(this)) == -1) {
|
|
176
177
|
keyboardLoop.push(this);
|
|
177
178
|
}
|
|
178
179
|
}
|
|
179
|
-
|
|
180
|
+
const keyboardLoop = keyboardLoops.get(keyboardLoopId);
|
|
180
181
|
this.addEventListener("keydown", (e) => {
|
|
181
182
|
var _a;
|
|
182
183
|
const keyboardEvent = e;
|
|
183
184
|
if (!["ArrowDown", "ArrowUp"].includes(keyboardEvent.key))
|
|
184
185
|
return;
|
|
185
|
-
|
|
186
|
-
|
|
186
|
+
const selector = "input:not([disabled]), button:not([disabled]), select:not([disabled]), textarea:not([disabled])";
|
|
187
|
+
const loop = keyboardLoop === null || keyboardLoop === void 0 ? void 0 : keyboardLoop.filter((el) => {
|
|
187
188
|
var _a;
|
|
188
|
-
|
|
189
|
+
const child = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector(selector);
|
|
189
190
|
if (!child)
|
|
190
191
|
return false;
|
|
191
|
-
|
|
192
|
+
const cpStyle = window.getComputedStyle(child);
|
|
192
193
|
return (cpStyle.display !== "none" &&
|
|
193
194
|
cpStyle.display !== "" &&
|
|
194
195
|
cpStyle.pointerEvents != "none" &&
|
|
@@ -197,7 +198,7 @@ const Form = (superClass) => {
|
|
|
197
198
|
});
|
|
198
199
|
let next = null;
|
|
199
200
|
if (keyboardEvent.key == "ArrowDown" && loop) {
|
|
200
|
-
|
|
201
|
+
const index = loop.indexOf(this);
|
|
201
202
|
if (index == loop.length - 1) {
|
|
202
203
|
next = loop[0];
|
|
203
204
|
}
|
|
@@ -206,7 +207,7 @@ const Form = (superClass) => {
|
|
|
206
207
|
}
|
|
207
208
|
}
|
|
208
209
|
else if (keyboardEvent.key == "ArrowUp" && loop) {
|
|
209
|
-
|
|
210
|
+
const index = loop.indexOf(this);
|
|
210
211
|
if (index == 0) {
|
|
211
212
|
next = loop[loop.length - 1];
|
|
212
213
|
}
|
|
@@ -214,7 +215,7 @@ const Form = (superClass) => {
|
|
|
214
215
|
next = loop[index - 1];
|
|
215
216
|
}
|
|
216
217
|
}
|
|
217
|
-
|
|
218
|
+
const elt = (_a = next === null || next === void 0 ? void 0 : next.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector(selector);
|
|
218
219
|
if (elt && elt.focus) {
|
|
219
220
|
elt.focus();
|
|
220
221
|
e.preventDefault();
|
|
@@ -230,7 +231,7 @@ const Form = (superClass) => {
|
|
|
230
231
|
super.disconnectedCallback();
|
|
231
232
|
if (this._name && this.publisher)
|
|
232
233
|
this.publisher[this._name].offAssign(this.onValueAssign);
|
|
233
|
-
|
|
234
|
+
const formPublisher = this.getFormPublisher();
|
|
234
235
|
if (this._name && formPublisher) {
|
|
235
236
|
formPublisher[this._name].offAssign(this.onFormValueAssign);
|
|
236
237
|
formPublisher.offInvalidate(this.onFormDataInValidate);
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { FormElementInterface } from "@supersoniks/concorde/core/mixins/FormElement";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import { MixinArgsType } from "../_types/types";
|
|
3
|
+
type Constructor<T> = new (...args: MixinArgsType[]) => T;
|
|
4
|
+
type Type = "button" | "checkbox" | "color" | "date" | "datetime-local" | "email" | "file" | "hidden" | "image" | "month" | "number" | "password" | "radio" | "range" | "reset" | "search" | "submit" | "tel" | "text" | "time" | "url" | "week";
|
|
4
5
|
declare const Form: <T extends Constructor<FormElementInterface>>(superClass: T) => {
|
|
5
|
-
new (...args:
|
|
6
|
+
new (...args: MixinArgsType[]): {
|
|
6
7
|
validateFormElement(): void;
|
|
7
8
|
forceAutoFill: boolean;
|
|
8
9
|
/**
|
|
@@ -21,7 +22,7 @@ declare const Form: <T extends Constructor<FormElementInterface>>(superClass: T)
|
|
|
21
22
|
updateDataValue(): void;
|
|
22
23
|
handleChange(e?: Event | undefined): void;
|
|
23
24
|
handleBlur(e?: Event | undefined): void;
|
|
24
|
-
getValueForFormPublisher():
|
|
25
|
+
getValueForFormPublisher(): string | object | string[] | null | undefined;
|
|
25
26
|
focus?: (() => void) | undefined;
|
|
26
27
|
shadowRoot?: ShadowRoot | undefined;
|
|
27
28
|
error: boolean;
|
|
@@ -31,15 +32,20 @@ declare const Form: <T extends Constructor<FormElementInterface>>(superClass: T)
|
|
|
31
32
|
formDataProvider: string;
|
|
32
33
|
ariaLabelledby?: string | undefined;
|
|
33
34
|
ariaLabel?: string | undefined;
|
|
34
|
-
_value: string | null;
|
|
35
|
-
value: string | null;
|
|
35
|
+
_value: string | object | string[] | null | undefined;
|
|
36
|
+
value: string | object | string[] | null | undefined;
|
|
36
37
|
_name: string;
|
|
37
38
|
name: string;
|
|
38
|
-
props:
|
|
39
|
-
propertyMap:
|
|
39
|
+
props: import("../_types/types").CoreJSType;
|
|
40
|
+
propertyMap: object;
|
|
40
41
|
isConnected: boolean;
|
|
42
|
+
children: HTMLCollection;
|
|
43
|
+
appendChild(node: Node): Node;
|
|
41
44
|
getAncestorAttributeValue(attributeName: string): string;
|
|
42
|
-
hasAncestorAttribute(attributeName: string): boolean;
|
|
45
|
+
hasAncestorAttribute(attributeName: string): boolean; /**
|
|
46
|
+
* Le type De l'input, comme en html cependant tous les types ne sont pas actuellements compatibles en raison du style en vigueur
|
|
47
|
+
* On peut essayer text, date, color, email par exemple, mais pas radio/checkbox/range a priori
|
|
48
|
+
*/
|
|
43
49
|
querySelectorAll(selector: string): NodeListOf<Element>;
|
|
44
50
|
publisher: any;
|
|
45
51
|
dataProvider: string | null;
|
|
@@ -57,7 +63,7 @@ declare const Form: <T extends Constructor<FormElementInterface>>(superClass: T)
|
|
|
57
63
|
connectedCallback(): void;
|
|
58
64
|
requestUpdate(): void;
|
|
59
65
|
getAttribute(name: string): string;
|
|
60
|
-
hasAttribute(attributeName:
|
|
66
|
+
hasAttribute(attributeName: string): boolean;
|
|
61
67
|
disconnectedCallback(): void;
|
|
62
68
|
};
|
|
63
69
|
} & T;
|
package/core/mixins/FormInput.js
CHANGED
|
@@ -22,7 +22,7 @@ const Form = (superClass) => {
|
|
|
22
22
|
const input = (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector("input");
|
|
23
23
|
if (!input || input.checkValidity())
|
|
24
24
|
return;
|
|
25
|
-
|
|
25
|
+
const formPublisher = this.getFormPublisher();
|
|
26
26
|
if (formPublisher)
|
|
27
27
|
formPublisher.isFormValid = false;
|
|
28
28
|
input.reportValidity();
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { APIConfiguration } from "@supersoniks/concorde/core/utils/api";
|
|
2
2
|
import { LitElement } from "lit";
|
|
3
|
-
import { PublisherInterface, TypeAndRecordOfType } from "@supersoniks/concorde/core/_types/types";
|
|
4
|
-
|
|
5
|
-
export interface SubscriberInterface<PropsType =
|
|
3
|
+
import { PublisherInterface, TypeAndRecordOfType, MixinArgsType, CoreJSType } from "@supersoniks/concorde/core/_types/types";
|
|
4
|
+
type Constructor<T> = new (...args: MixinArgsType[]) => T;
|
|
5
|
+
export interface SubscriberInterface<PropsType = CoreJSType> {
|
|
6
6
|
props: PropsType | null;
|
|
7
|
-
propertyMap:
|
|
7
|
+
propertyMap: object;
|
|
8
8
|
isConnected: boolean;
|
|
9
|
+
children: HTMLCollection;
|
|
10
|
+
appendChild(node: Node): Node;
|
|
9
11
|
getAncestorAttributeValue(attributeName: string): string;
|
|
10
12
|
hasAncestorAttribute(attributeName: string): boolean;
|
|
11
13
|
querySelectorAll(selector: string): NodeListOf<Element>;
|
|
@@ -26,8 +28,8 @@ export interface SubscriberInterface<PropsType = any> {
|
|
|
26
28
|
connectedCallback(): void;
|
|
27
29
|
requestUpdate(): void;
|
|
28
30
|
getAttribute(name: string): string;
|
|
29
|
-
hasAttribute(attributeName:
|
|
31
|
+
hasAttribute(attributeName: string): boolean;
|
|
30
32
|
disconnectedCallback(): void;
|
|
31
33
|
}
|
|
32
|
-
declare const Subscriber: <PropsType =
|
|
34
|
+
declare const Subscriber: <PropsType = CoreJSType, T extends Constructor<LitElement> = Constructor<LitElement>>(superClass: T, type?: PropsType | undefined) => Constructor<SubscriberInterface<PropsType>> & T;
|
|
33
35
|
export default Subscriber;
|
|
@@ -54,7 +54,7 @@ const Subscriber = (superClass, type) => {
|
|
|
54
54
|
this.noAutoFill = false;
|
|
55
55
|
this.forceAutoFill = false;
|
|
56
56
|
/**
|
|
57
|
-
*
|
|
57
|
+
* Passer ce paramètre à true permet de ne pas mettre à jour le composant lors d'un changement de interne de la propriété nommé props.
|
|
58
58
|
*/
|
|
59
59
|
this.renderOnPropsInternalChange = false;
|
|
60
60
|
/**
|
|
@@ -132,8 +132,9 @@ const Subscriber = (superClass, type) => {
|
|
|
132
132
|
}
|
|
133
133
|
updated(_changedProperties) {
|
|
134
134
|
super.updated(_changedProperties);
|
|
135
|
-
|
|
136
|
-
|
|
135
|
+
const ref = this.shadowRoot || this;
|
|
136
|
+
const children = [...ref.children].filter((child) => child.tagName != "STYLE");
|
|
137
|
+
const display = this.displayContents ? "contents" : children.length == 0 ? "none" : null;
|
|
137
138
|
if (display)
|
|
138
139
|
this.style.display = display;
|
|
139
140
|
else
|
|
@@ -141,12 +142,12 @@ const Subscriber = (superClass, type) => {
|
|
|
141
142
|
}
|
|
142
143
|
connectedCallback() {
|
|
143
144
|
if (this.hasAttribute("lazyRendering")) {
|
|
144
|
-
|
|
145
|
+
const options = {
|
|
145
146
|
root: null,
|
|
146
147
|
rootMargin: Math.max(window.innerWidth * 0.1, window.innerHeight * 0.1) + "px",
|
|
147
148
|
};
|
|
148
149
|
let firstView = true;
|
|
149
|
-
|
|
150
|
+
const iObserver = new IntersectionObserver((entries) => {
|
|
150
151
|
for (const e of entries) {
|
|
151
152
|
if (firstView && e.isIntersecting) {
|
|
152
153
|
firstView = false;
|
|
@@ -183,7 +184,7 @@ const Subscriber = (superClass, type) => {
|
|
|
183
184
|
if (this.hasAttribute("debug") && !this.defferedDebug) {
|
|
184
185
|
if (!this.debug) {
|
|
185
186
|
this.debug = document.createElement("div");
|
|
186
|
-
|
|
187
|
+
const style = this.debug.style;
|
|
187
188
|
style.position = "fixed";
|
|
188
189
|
style.top = "0";
|
|
189
190
|
style.right = "0";
|
|
@@ -248,24 +249,24 @@ const Subscriber = (superClass, type) => {
|
|
|
248
249
|
*/
|
|
249
250
|
getApiConfiguration() {
|
|
250
251
|
const token = this.getAncestorAttributeValue("token");
|
|
251
|
-
|
|
252
|
-
|
|
252
|
+
const addHTTPResponse = this.getAncestorAttributeValue("addHTTPResponse") != null;
|
|
253
|
+
const serviceURL = this.getAncestorAttributeValue("serviceURL");
|
|
253
254
|
let userName = null;
|
|
254
255
|
let password = null;
|
|
255
|
-
|
|
256
|
+
const tokenProvider = this.getAncestorAttributeValue("tokenProvider");
|
|
257
|
+
const authToken = this.getAncestorAttributeValue("eventsApiToken");
|
|
256
258
|
if (!token) {
|
|
257
259
|
userName = this.getAncestorAttributeValue("userName");
|
|
258
260
|
password = this.getAncestorAttributeValue("password");
|
|
259
|
-
tokenProvider = this.getAncestorAttributeValue("tokenProvider");
|
|
260
261
|
}
|
|
261
|
-
|
|
262
|
-
return { serviceURL, token, userName, password, tokenProvider, addHTTPResponse, credentials };
|
|
262
|
+
const credentials = this.getAncestorAttributeValue("credentials") || undefined;
|
|
263
|
+
return { serviceURL, token, userName, password, authToken, tokenProvider, addHTTPResponse, credentials };
|
|
263
264
|
}
|
|
264
265
|
initWording() {
|
|
265
266
|
return __awaiter(this, void 0, void 0, function* () {
|
|
266
267
|
let hasWording = false;
|
|
267
268
|
const propNames = Object.getOwnPropertyNames(this.constructor.prototype);
|
|
268
|
-
for (
|
|
269
|
+
for (const p of propNames) {
|
|
269
270
|
if (p.indexOf("wording_") == 0) {
|
|
270
271
|
hasWording = true;
|
|
271
272
|
break;
|
|
@@ -273,15 +274,15 @@ const Subscriber = (superClass, type) => {
|
|
|
273
274
|
}
|
|
274
275
|
if (!hasWording)
|
|
275
276
|
return;
|
|
276
|
-
|
|
277
|
-
|
|
277
|
+
const publisher = PublisherManager.getInstance().get("sonic-wording");
|
|
278
|
+
const wordingProvider = this.getAncestorAttributeValue("wordingProvider");
|
|
278
279
|
const api = new API(this.getApiConfiguration());
|
|
279
280
|
if (wordingProvider) {
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
for (
|
|
281
|
+
const wordings = [];
|
|
282
|
+
const wordingsAll = [];
|
|
283
|
+
for (const p of propNames) {
|
|
283
284
|
if (p.indexOf("wording_") == 0) {
|
|
284
|
-
|
|
285
|
+
const p8 = p.substring(8);
|
|
285
286
|
if (!publisher.get()[p]) {
|
|
286
287
|
publisher[p] = "...";
|
|
287
288
|
wordings.push(p8);
|
|
@@ -290,8 +291,8 @@ const Subscriber = (superClass, type) => {
|
|
|
290
291
|
}
|
|
291
292
|
}
|
|
292
293
|
if (wordings.length > 0) {
|
|
293
|
-
|
|
294
|
-
for (
|
|
294
|
+
const result = (yield api.post(wordingProvider, { labels: wordings }));
|
|
295
|
+
for (const elt in result) {
|
|
295
296
|
publisher["wording_" + elt] = result[elt];
|
|
296
297
|
}
|
|
297
298
|
}
|
|
@@ -309,7 +310,7 @@ const Subscriber = (superClass, type) => {
|
|
|
309
310
|
if (this.noShadowDom === "" || this.getAttribute("noShadowDom") === "") {
|
|
310
311
|
return this;
|
|
311
312
|
}
|
|
312
|
-
|
|
313
|
+
const shadowRoot = super.createRenderRoot();
|
|
313
314
|
DataBindObserver.observe(shadowRoot);
|
|
314
315
|
return shadowRoot;
|
|
315
316
|
}
|
|
@@ -336,7 +337,7 @@ const Subscriber = (superClass, type) => {
|
|
|
336
337
|
let pub = mng.get(publisherId);
|
|
337
338
|
this.dataProvider = publisherId;
|
|
338
339
|
if (this.hasAttribute("subDataProvider")) {
|
|
339
|
-
|
|
340
|
+
const dataPath = this.getAttribute("subDataProvider");
|
|
340
341
|
this.dataProvider = publisherId + "/" + dataPath;
|
|
341
342
|
pub = Objects.traverse(pub, dataPath.split("."));
|
|
342
343
|
mng.set(this.dataProvider, pub);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { LitElement } from "lit";
|
|
2
|
-
|
|
2
|
+
import { MixinArgsType } from "../_types/types";
|
|
3
|
+
type Constructor<T> = new (...args: MixinArgsType[]) => T;
|
|
3
4
|
export declare class TemplatesContainerInterface extends LitElement {
|
|
4
5
|
connectedCallback(): void;
|
|
5
6
|
templateParts: Record<string, HTMLTemplateElement>;
|
|
@@ -39,8 +39,8 @@ const TemplatesContainer = (superClass) => {
|
|
|
39
39
|
this.templatePartsList = [];
|
|
40
40
|
}
|
|
41
41
|
connectedCallback() {
|
|
42
|
-
|
|
43
|
-
for (
|
|
42
|
+
const templates = this.templates || [...this.querySelectorAll("template")];
|
|
43
|
+
for (const t of templates) {
|
|
44
44
|
if (t.hasAttribute(this.templateValueAttribute)) {
|
|
45
45
|
this.templateParts[t.getAttribute(this.templateValueAttribute)] = t;
|
|
46
46
|
this.templatePartsList.push(t);
|
package/core/utils/Arrays.js
CHANGED
|
@@ -16,6 +16,7 @@ class Arrays {
|
|
|
16
16
|
/**
|
|
17
17
|
* Fournie une fonction to1D qui transforme un tableau 2D en un tableau 1D par concaténation
|
|
18
18
|
*/
|
|
19
|
+
/*eslint-disable @typescript-eslint/no-explicit-any*/
|
|
19
20
|
static from2d(source) {
|
|
20
21
|
return {
|
|
21
22
|
to1D: () => {
|
|
@@ -25,6 +26,7 @@ class Arrays {
|
|
|
25
26
|
},
|
|
26
27
|
};
|
|
27
28
|
}
|
|
29
|
+
/*eslint-enable @typescript-eslint/no-explicit-any*/
|
|
28
30
|
/**
|
|
29
31
|
* Fournie des méthodes pour manipuler un tableau
|
|
30
32
|
* A l'écriture cela permet d'avoir des phrases du type:
|
|
@@ -32,6 +34,7 @@ class Arrays {
|
|
|
32
34
|
* puis data.everyItem().has().same().value().forkey("key");
|
|
33
35
|
* Peu mieux faire. ou voir a remplacer un jour par loadHash par exemple.
|
|
34
36
|
**/
|
|
37
|
+
/*eslint-disable @typescript-eslint/no-explicit-any*/
|
|
35
38
|
static from(source) {
|
|
36
39
|
return {
|
|
37
40
|
/**Obtenir le tableau final*/
|
|
@@ -47,7 +50,7 @@ class Arrays {
|
|
|
47
50
|
forKey: (key) => {
|
|
48
51
|
if (source.length < 1)
|
|
49
52
|
return true;
|
|
50
|
-
|
|
53
|
+
const first = (source[0] || {})[key];
|
|
51
54
|
return source.every((item) => (item || {})[key] == first);
|
|
52
55
|
},
|
|
53
56
|
};
|
|
@@ -89,14 +92,14 @@ class Arrays {
|
|
|
89
92
|
group: () => {
|
|
90
93
|
return {
|
|
91
94
|
byKey: (key) => {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
for (
|
|
95
|
-
|
|
95
|
+
const result = [];
|
|
96
|
+
const keys = new Map();
|
|
97
|
+
for (const item of source) {
|
|
98
|
+
const value = item[key];
|
|
96
99
|
if (!keys.has(value)) {
|
|
97
|
-
|
|
100
|
+
const idx = result.length;
|
|
98
101
|
keys.set(value, idx);
|
|
99
|
-
|
|
102
|
+
const pushable = { items: [] };
|
|
100
103
|
pushable[key] = value;
|
|
101
104
|
result.push(pushable);
|
|
102
105
|
}
|
|
@@ -111,7 +114,7 @@ class Arrays {
|
|
|
111
114
|
duplicates: () => {
|
|
112
115
|
return {
|
|
113
116
|
forKey: (key) => {
|
|
114
|
-
|
|
117
|
+
const set = [...new Set(source.map((item) => item[key]))];
|
|
115
118
|
return Arrays.from(set.map((value) => source.find((item) => item[key] == value)));
|
|
116
119
|
},
|
|
117
120
|
};
|
|
@@ -121,7 +124,7 @@ class Arrays {
|
|
|
121
124
|
havingSameValue: () => {
|
|
122
125
|
return {
|
|
123
126
|
forKey: (key) => {
|
|
124
|
-
|
|
127
|
+
const areValuesDifferentForKey = (compared1, key) => (compared2) => compared1[key] != compared2[key];
|
|
125
128
|
return Arrays.from(source.filter((elt) => toRemoveFromSource.every(areValuesDifferentForKey(elt, key))));
|
|
126
129
|
},
|
|
127
130
|
};
|