@supersoniks/concorde 1.1.43 → 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/concorde-core.bundle.js +18 -18
- package/concorde-core.es.js +805 -739
- 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 +25 -13
- 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 +12 -3
- package/core/components/functional/queue/queue.js +28 -22
- 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 +10 -10
- 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 +10 -9
- package/core/components/functional/sdui/sdui.js +32 -33
- 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 +8 -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/ui/_css/size.d.ts +1 -1
- package/core/components/ui/button/button.d.ts +6 -4
- package/core/components/ui/button/button.js +2 -2
- 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/select/select.d.ts +5 -4
- package/core/components/ui/form/select/select.js +8 -8
- 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 +1 -1
- 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 +1 -1
- package/core/components/ui/pop/pop.js +13 -13
- 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 +1 -1
- 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 +19 -18
- 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 +16 -31
- package/core/utils/api.js +26 -22
- package/mixins.d.ts +25 -19
- package/package.json +9 -5
- package/core/components/ui/taxonomy/taxonomy.d.ts +0 -44
- package/core/components/ui/taxonomy/taxonomy.js +0 -115
package/core/mixins/Fetcher.d.ts
CHANGED
|
@@ -2,15 +2,18 @@
|
|
|
2
2
|
import "@supersoniks/concorde/core/components/ui/button/button";
|
|
3
3
|
import { SubscriberInterface } from "@supersoniks/concorde/core/mixins/Subscriber";
|
|
4
4
|
import API from "@supersoniks/concorde/core/utils/api";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
import { PublisherContentType } from "../_types/types";
|
|
6
|
+
import { MixinArgsType } from "../_types/types";
|
|
7
|
+
import { ResultTypeInterface } from "@supersoniks/concorde/core/utils/api";
|
|
8
|
+
type Constructor<T> = new (...args: MixinArgsType[]) => T;
|
|
9
|
+
declare const Fetcher: <T extends Constructor<SubscriberInterface<PropsType>>, PropsType extends PublisherContentType = PublisherContentType>(superClass: T, propsType?: PropsType | undefined) => {
|
|
10
|
+
new (...args: MixinArgsType[]): {
|
|
8
11
|
api: API | null;
|
|
9
12
|
/**
|
|
10
13
|
* Après le chargement des données on traverse l'objet reçu en fonctione de la cible exprimées dans cette propriété avec la dot syntaxe.
|
|
11
14
|
* C'est cette donnée cible qui est injectée dans les pros et donc disponible via le publisher disponible globalement via PublisherManager.get(dataProvider)
|
|
12
15
|
*/
|
|
13
|
-
key:
|
|
16
|
+
key: string;
|
|
14
17
|
/**
|
|
15
18
|
* isFirstLoad vaut true jusqu'au premier chargement de données
|
|
16
19
|
*/
|
|
@@ -33,6 +36,7 @@ declare const Fetcher: <PropsType = any, T extends Constructor<SubscriberInterfa
|
|
|
33
36
|
*/
|
|
34
37
|
isFetchEnabled: boolean;
|
|
35
38
|
_endPoint: string;
|
|
39
|
+
props: (PropsType & ResultTypeInterface) | null;
|
|
36
40
|
endPoint: string;
|
|
37
41
|
requestId: number;
|
|
38
42
|
refetchEveryMs: number;
|
|
@@ -52,36 +56,30 @@ declare const Fetcher: <PropsType = any, T extends Constructor<SubscriberInterfa
|
|
|
52
56
|
*/
|
|
53
57
|
firstUpdated(): void;
|
|
54
58
|
onIntersection(entries: IntersectionObserverEntry[]): void;
|
|
55
|
-
|
|
56
|
-
propertyMap: Object;
|
|
59
|
+
propertyMap: object;
|
|
57
60
|
isConnected: boolean;
|
|
61
|
+
children: HTMLCollection;
|
|
62
|
+
appendChild(node: Node): Node;
|
|
58
63
|
getAncestorAttributeValue(attributeName: string): string;
|
|
59
64
|
hasAncestorAttribute(attributeName: string): boolean;
|
|
60
65
|
querySelectorAll(selector: string): NodeListOf<Element>;
|
|
61
66
|
publisher: any;
|
|
62
67
|
dataProvider: string | null;
|
|
63
|
-
noShadowDom: string | null;
|
|
64
|
-
* isFirstLoad vaut true jusqu'au premier chargement de données
|
|
65
|
-
*/
|
|
68
|
+
noShadowDom: string | null;
|
|
66
69
|
debug: HTMLElement | null;
|
|
67
70
|
defferedDebug: boolean | null;
|
|
68
71
|
displayContents: boolean;
|
|
69
|
-
shadowRoot?: ShadowRoot | undefined;
|
|
70
|
-
* isLoading vaut true pendant le chargement des données
|
|
71
|
-
*/
|
|
72
|
+
shadowRoot?: ShadowRoot | undefined;
|
|
72
73
|
dispatchEvent(event: Event): void;
|
|
73
74
|
setAttribute(name: string, value: string): void;
|
|
74
75
|
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions | undefined): void;
|
|
75
76
|
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions | undefined): void;
|
|
76
77
|
removeAttribute(name: string): void;
|
|
77
|
-
initPublisher(): void;
|
|
78
|
-
* On peut désactiver le fetch programmatiquement via cette propriété.
|
|
79
|
-
* Cela est le cas pour le composant sonic-list qui ne fetch que si l'attribut fetch est renseigné
|
|
80
|
-
*/
|
|
78
|
+
initPublisher(): void;
|
|
81
79
|
getApiConfiguration(): import("@supersoniks/concorde/core/utils/api").APIConfiguration;
|
|
82
80
|
requestUpdate(): void;
|
|
83
81
|
getAttribute(name: string): string;
|
|
84
|
-
hasAttribute(attributeName:
|
|
82
|
+
hasAttribute(attributeName: string): boolean;
|
|
85
83
|
};
|
|
86
84
|
} & T;
|
|
87
85
|
export default Fetcher;
|
package/core/mixins/Fetcher.js
CHANGED
|
@@ -58,6 +58,12 @@ const Fetcher = (superClass, propsType) => {
|
|
|
58
58
|
args;
|
|
59
59
|
this.dataProvider = "";
|
|
60
60
|
}
|
|
61
|
+
get props() {
|
|
62
|
+
return super.props;
|
|
63
|
+
}
|
|
64
|
+
set props(value) {
|
|
65
|
+
super.props = value;
|
|
66
|
+
}
|
|
61
67
|
set endPoint(value) {
|
|
62
68
|
this._endPoint = value;
|
|
63
69
|
if (this.isConnected)
|
|
@@ -83,12 +89,13 @@ const Fetcher = (superClass, propsType) => {
|
|
|
83
89
|
this.dispatchEvent(new CustomEvent("loading", { detail: this }));
|
|
84
90
|
this.isLoading = true;
|
|
85
91
|
this.requestUpdate();
|
|
86
|
-
|
|
87
|
-
let hasLoader = this.isDefaultLoaderEnabled && !this.hasAttribute("noLoader");
|
|
92
|
+
const hasLoader = this.isDefaultLoaderEnabled && !this.hasAttribute("noLoader");
|
|
88
93
|
if (hasLoader)
|
|
89
94
|
Loader.show();
|
|
90
|
-
|
|
91
|
-
|
|
95
|
+
const headerData = PublisherManager.getInstance()
|
|
96
|
+
.get(this.getAncestorAttributeValue("headersDataProvider"))
|
|
97
|
+
.get();
|
|
98
|
+
let data = yield this.api.get(this.endPoint || this.dataProvider || "", headerData);
|
|
92
99
|
// Je garde ça mais normalement ça n'arrive jamais
|
|
93
100
|
if (!data) {
|
|
94
101
|
SonicToast.add({ text: "Network Error", status: "error" });
|
|
@@ -104,7 +111,7 @@ const Fetcher = (superClass, propsType) => {
|
|
|
104
111
|
if (hasLoader)
|
|
105
112
|
Loader.hide();
|
|
106
113
|
if (this.key) {
|
|
107
|
-
|
|
114
|
+
const response = data._sonic_http_response_;
|
|
108
115
|
/* preserveOtherKeys s'exprime lorsque le paramètre "key" est défini
|
|
109
116
|
* Conserve les autres propriétés de l'objet reçu, en plus des propriétés définies sous "key"
|
|
110
117
|
*/
|
|
@@ -155,18 +162,17 @@ const Fetcher = (superClass, propsType) => {
|
|
|
155
162
|
if (lazyLoad === null) {
|
|
156
163
|
return;
|
|
157
164
|
}
|
|
158
|
-
|
|
165
|
+
const options = {
|
|
159
166
|
root: null,
|
|
160
167
|
rootMargin: Math.max(window.innerWidth, window.innerHeight) + "px",
|
|
161
168
|
};
|
|
162
169
|
this.iObserver = new IntersectionObserver((entries) => this.onIntersection(entries), options);
|
|
163
|
-
let
|
|
164
|
-
let elt = this.shadowRoot ? this.shadowRoot.children[0] : that.children[0];
|
|
170
|
+
let elt = this.shadowRoot ? this.shadowRoot.children[0] : this.children[0];
|
|
165
171
|
if (elt && elt.nodeName.toLocaleLowerCase() == "slot")
|
|
166
172
|
elt = elt.children[0];
|
|
167
173
|
if (!elt || elt.nodeName.toLocaleLowerCase() == "template") {
|
|
168
174
|
elt = document.createElement("span");
|
|
169
|
-
|
|
175
|
+
this.appendChild(elt);
|
|
170
176
|
}
|
|
171
177
|
if (elt) {
|
|
172
178
|
this.iObserver.observe(elt);
|
|
@@ -183,6 +189,9 @@ const Fetcher = (superClass, propsType) => {
|
|
|
183
189
|
}
|
|
184
190
|
}
|
|
185
191
|
}
|
|
192
|
+
__decorate([
|
|
193
|
+
property()
|
|
194
|
+
], FetcherElement.prototype, "props", null);
|
|
186
195
|
__decorate([
|
|
187
196
|
property({ type: String })
|
|
188
197
|
], FetcherElement.prototype, "endPoint", null);
|
|
@@ -192,6 +201,6 @@ const Fetcher = (superClass, propsType) => {
|
|
|
192
201
|
__decorate([
|
|
193
202
|
property({ type: Number })
|
|
194
203
|
], FetcherElement.prototype, "refetchEveryMs", void 0);
|
|
195
|
-
return FetcherElement; //
|
|
204
|
+
return FetcherElement; //as Constructor<SubscriberInterface> & T;
|
|
196
205
|
};
|
|
197
206
|
export default Fetcher;
|
|
@@ -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;
|