@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
package/core/mixins/Fetcher.js
CHANGED
|
@@ -13,14 +13,15 @@ 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 "@supersoniks/concorde/core/components/ui/button/button";
|
|
16
17
|
import { Loader } from "@supersoniks/concorde/core/components/ui/loader/loader";
|
|
17
18
|
import { SonicToast } from "@supersoniks/concorde/core/components/ui/toast/toast";
|
|
18
19
|
import API from "@supersoniks/concorde/core/utils/api";
|
|
19
|
-
import "@supersoniks/concorde/core/components/ui/button/button";
|
|
20
|
-
import { PublisherManager } from "@supersoniks/concorde/utils";
|
|
21
20
|
import Objects from "@supersoniks/concorde/core/utils/Objects";
|
|
21
|
+
import { PublisherManager } from "@supersoniks/concorde/utils";
|
|
22
22
|
import { property } from "lit/decorators.js";
|
|
23
|
-
const Fetcher = (superClass) => {
|
|
23
|
+
const Fetcher = (superClass, propsType) => {
|
|
24
|
+
propsType;
|
|
24
25
|
class FetcherElement extends superClass {
|
|
25
26
|
constructor(...args) {
|
|
26
27
|
super();
|
|
@@ -52,9 +53,17 @@ const Fetcher = (superClass) => {
|
|
|
52
53
|
*/
|
|
53
54
|
this.isFetchEnabled = true;
|
|
54
55
|
this._endPoint = "";
|
|
56
|
+
this.requestId = 0;
|
|
57
|
+
this.refetchEveryMs = 0;
|
|
55
58
|
args;
|
|
56
59
|
this.dataProvider = "";
|
|
57
60
|
}
|
|
61
|
+
get props() {
|
|
62
|
+
return super.props;
|
|
63
|
+
}
|
|
64
|
+
set props(value) {
|
|
65
|
+
super.props = value;
|
|
66
|
+
}
|
|
58
67
|
set endPoint(value) {
|
|
59
68
|
this._endPoint = value;
|
|
60
69
|
if (this.isConnected)
|
|
@@ -80,12 +89,13 @@ const Fetcher = (superClass) => {
|
|
|
80
89
|
this.dispatchEvent(new CustomEvent("loading", { detail: this }));
|
|
81
90
|
this.isLoading = true;
|
|
82
91
|
this.requestUpdate();
|
|
83
|
-
|
|
84
|
-
let hasLoader = this.isDefaultLoaderEnabled && !this.hasAttribute("noLoader");
|
|
92
|
+
const hasLoader = this.isDefaultLoaderEnabled && !this.hasAttribute("noLoader");
|
|
85
93
|
if (hasLoader)
|
|
86
94
|
Loader.show();
|
|
87
|
-
|
|
88
|
-
|
|
95
|
+
const headerData = PublisherManager.getInstance()
|
|
96
|
+
.get(this.getAncestorAttributeValue("headersDataProvider"))
|
|
97
|
+
.get();
|
|
98
|
+
let data = yield this.api.get(this.endPoint || this.dataProvider || "", headerData);
|
|
89
99
|
// Je garde ça mais normalement ça n'arrive jamais
|
|
90
100
|
if (!data) {
|
|
91
101
|
SonicToast.add({ text: "Network Error", status: "error" });
|
|
@@ -101,38 +111,45 @@ const Fetcher = (superClass) => {
|
|
|
101
111
|
if (hasLoader)
|
|
102
112
|
Loader.hide();
|
|
103
113
|
if (this.key) {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
114
|
+
const response = data._sonic_http_response_;
|
|
115
|
+
/* preserveOtherKeys s'exprime lorsque le paramètre "key" est défini
|
|
116
|
+
* Conserve les autres propriétés de l'objet reçu, en plus des propriétés définies sous "key"
|
|
117
|
+
*/
|
|
118
|
+
data = Objects.traverse(data, this.key.split("."), this.hasAttribute("preserveOtherKeys"));
|
|
119
|
+
if (data && Objects.isObject(data) && response)
|
|
107
120
|
data._sonic_http_response_ = response;
|
|
108
121
|
}
|
|
109
122
|
this.props = data;
|
|
110
123
|
this.dispatchEvent(new CustomEvent("load", { detail: this }));
|
|
111
124
|
this.isFirstLoad = false;
|
|
112
125
|
this.isLoading = false;
|
|
126
|
+
if (this.refetchEveryMs && this.isConnected) {
|
|
127
|
+
this.refetchTimeOutId = setTimeout(() => this._fetchData(), this.refetchEveryMs);
|
|
128
|
+
}
|
|
113
129
|
});
|
|
114
130
|
}
|
|
115
131
|
disconnectedCallback() {
|
|
116
132
|
var _a;
|
|
117
133
|
super.disconnectedCallback();
|
|
118
134
|
(_a = this.publisher) === null || _a === void 0 ? void 0 : _a.offInvalidate(this.onInvalidate);
|
|
135
|
+
clearTimeout(this.refetchTimeOutId);
|
|
119
136
|
this.isFirstLoad = false;
|
|
120
137
|
}
|
|
121
138
|
connectedCallback() {
|
|
122
139
|
var _a;
|
|
123
|
-
this.noShadowDom = "";
|
|
140
|
+
// this.noShadowDom = "";
|
|
124
141
|
if (!this.isFetchEnabled) {
|
|
125
142
|
super.connectedCallback();
|
|
126
143
|
return;
|
|
127
144
|
}
|
|
128
145
|
super.connectedCallback();
|
|
129
|
-
this.key = this.
|
|
146
|
+
this.key = this.getAttribute("key");
|
|
130
147
|
if (this.props) {
|
|
131
148
|
this.publisher.set(this.props);
|
|
132
149
|
}
|
|
133
150
|
this.onInvalidate = () => this._fetchData();
|
|
134
151
|
(_a = this.publisher) === null || _a === void 0 ? void 0 : _a.onInvalidate(this.onInvalidate);
|
|
135
|
-
const lazyLoad = this.
|
|
152
|
+
const lazyLoad = this.getAttribute("lazyload");
|
|
136
153
|
if (lazyLoad === null) {
|
|
137
154
|
this._fetchData();
|
|
138
155
|
}
|
|
@@ -141,22 +158,21 @@ const Fetcher = (superClass) => {
|
|
|
141
158
|
* Première update, le comportement de lazyload est géré ici a l'aide d'un intersection observer.
|
|
142
159
|
*/
|
|
143
160
|
firstUpdated() {
|
|
144
|
-
const lazyLoad = this.
|
|
161
|
+
const lazyLoad = this.getAttribute("lazyload");
|
|
145
162
|
if (lazyLoad === null) {
|
|
146
163
|
return;
|
|
147
164
|
}
|
|
148
|
-
|
|
165
|
+
const options = {
|
|
149
166
|
root: null,
|
|
150
167
|
rootMargin: Math.max(window.innerWidth, window.innerHeight) + "px",
|
|
151
168
|
};
|
|
152
169
|
this.iObserver = new IntersectionObserver((entries) => this.onIntersection(entries), options);
|
|
153
|
-
let
|
|
154
|
-
let elt = that.shadowRoot ? that.shadowRoot.children[0] : that.children[0];
|
|
170
|
+
let elt = this.shadowRoot ? this.shadowRoot.children[0] : this.children[0];
|
|
155
171
|
if (elt && elt.nodeName.toLocaleLowerCase() == "slot")
|
|
156
172
|
elt = elt.children[0];
|
|
157
173
|
if (!elt || elt.nodeName.toLocaleLowerCase() == "template") {
|
|
158
174
|
elt = document.createElement("span");
|
|
159
|
-
|
|
175
|
+
this.appendChild(elt);
|
|
160
176
|
}
|
|
161
177
|
if (elt) {
|
|
162
178
|
this.iObserver.observe(elt);
|
|
@@ -173,9 +189,18 @@ const Fetcher = (superClass) => {
|
|
|
173
189
|
}
|
|
174
190
|
}
|
|
175
191
|
}
|
|
192
|
+
__decorate([
|
|
193
|
+
property()
|
|
194
|
+
], FetcherElement.prototype, "props", null);
|
|
176
195
|
__decorate([
|
|
177
196
|
property({ type: String })
|
|
178
197
|
], FetcherElement.prototype, "endPoint", null);
|
|
179
|
-
|
|
198
|
+
__decorate([
|
|
199
|
+
property()
|
|
200
|
+
], FetcherElement.prototype, "requestId", void 0);
|
|
201
|
+
__decorate([
|
|
202
|
+
property({ type: Number })
|
|
203
|
+
], FetcherElement.prototype, "refetchEveryMs", void 0);
|
|
204
|
+
return FetcherElement; //as Constructor<SubscriberInterface> & T;
|
|
180
205
|
};
|
|
181
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
|
*/
|
|
@@ -16,13 +17,15 @@ declare const Form: <T extends Constructor<FormElementInterface>>(superClass: T)
|
|
|
16
17
|
Active le mode radio
|
|
17
18
|
*/
|
|
18
19
|
radio: true | null;
|
|
20
|
+
unCheckOnDisconnect: boolean;
|
|
19
21
|
/**
|
|
20
22
|
* propriété checked avec des caractéristiques similaire à un input html classique.
|
|
21
23
|
*/
|
|
22
|
-
_checked: true | null;
|
|
23
|
-
checked: true | null;
|
|
24
|
+
_checked: true | null | "indeterminate";
|
|
25
|
+
checked: true | "indeterminate" | null;
|
|
24
26
|
validateFormElement(): void;
|
|
25
|
-
|
|
27
|
+
checksAll(): boolean;
|
|
28
|
+
setCheckedValue(checked: true | null | "indeterminate"): void;
|
|
26
29
|
handleChange(): void;
|
|
27
30
|
/**
|
|
28
31
|
* Voir la mixin FormElement
|
|
@@ -34,21 +37,31 @@ declare const Form: <T extends Constructor<FormElementInterface>>(superClass: T)
|
|
|
34
37
|
* Le comportement est modifié de la manière suivante :
|
|
35
38
|
* L'état du composant (checked) est mis à jour en fonction de la valeur fournie par le publisher associé au composant / en fonction de sont mode (radio, unique)
|
|
36
39
|
*/
|
|
37
|
-
setFormValueFromPublisher(value:
|
|
38
|
-
|
|
40
|
+
setFormValueFromPublisher(value: string | Array<string | null> | null): void;
|
|
41
|
+
getCheckAllPublisher(): any;
|
|
42
|
+
updateAllChecked: () => void;
|
|
43
|
+
onChecksAllRequest: (value: string) => void;
|
|
44
|
+
disconnectedCallback(): void;
|
|
45
|
+
connectedCallback(): void;
|
|
39
46
|
getFormPublisher(): any;
|
|
40
47
|
updateDataValue(): void;
|
|
41
|
-
handleBlur(e?:
|
|
48
|
+
handleBlur(e?: Event | undefined): void;
|
|
49
|
+
focus?: (() => void) | undefined;
|
|
50
|
+
shadowRoot?: ShadowRoot | undefined;
|
|
42
51
|
error: boolean;
|
|
43
52
|
autofocus: boolean;
|
|
44
53
|
required: boolean;
|
|
45
54
|
disabled: true | null;
|
|
46
55
|
formDataProvider: string;
|
|
56
|
+
ariaLabelledby?: string | undefined;
|
|
57
|
+
ariaLabel?: string | undefined;
|
|
47
58
|
_name: string;
|
|
48
59
|
name: string;
|
|
49
|
-
props:
|
|
50
|
-
propertyMap:
|
|
60
|
+
props: import("../_types/types").CoreJSType;
|
|
61
|
+
propertyMap: object;
|
|
51
62
|
isConnected: boolean;
|
|
63
|
+
children: HTMLCollection;
|
|
64
|
+
appendChild(node: Node): Node;
|
|
52
65
|
getAncestorAttributeValue(attributeName: string): string;
|
|
53
66
|
hasAncestorAttribute(attributeName: string): boolean;
|
|
54
67
|
querySelectorAll(selector: string): NodeListOf<Element>;
|
|
@@ -63,12 +76,11 @@ declare const Form: <T extends Constructor<FormElementInterface>>(superClass: T)
|
|
|
63
76
|
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions | undefined): void;
|
|
64
77
|
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions | undefined): void;
|
|
65
78
|
removeAttribute(name: string): void;
|
|
79
|
+
initPublisher(): void;
|
|
66
80
|
getApiConfiguration(): import("../utils/api").APIConfiguration;
|
|
67
|
-
connectedCallback(): void;
|
|
68
81
|
requestUpdate(): void;
|
|
69
82
|
getAttribute(name: string): string;
|
|
70
|
-
hasAttribute(attributeName:
|
|
71
|
-
disconnectedCallback(): void;
|
|
83
|
+
hasAttribute(attributeName: string): boolean;
|
|
72
84
|
};
|
|
73
85
|
} & T;
|
|
74
86
|
export default Form;
|
|
@@ -5,6 +5,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
7
|
import { property } from "lit/decorators.js";
|
|
8
|
+
import { PublisherManager } from "@supersoniks/concorde/utils";
|
|
8
9
|
const Form = (superClass) => {
|
|
9
10
|
/**
|
|
10
11
|
* FormCheckable ajoute un comportement de sélection (checked) a tout FormElement qui utilise cette mixin.
|
|
@@ -30,21 +31,98 @@ const Form = (superClass) => {
|
|
|
30
31
|
Active le mode radio
|
|
31
32
|
*/
|
|
32
33
|
this.radio = null;
|
|
34
|
+
this.unCheckOnDisconnect = false;
|
|
33
35
|
/**
|
|
34
36
|
* propriété checked avec des caractéristiques similaire à un input html classique.
|
|
35
37
|
*/
|
|
36
38
|
this._checked = null;
|
|
39
|
+
this.updateAllChecked = () => {
|
|
40
|
+
const name = this.getAttribute("name");
|
|
41
|
+
const checkAllPublisher = this.getCheckAllPublisher();
|
|
42
|
+
const formPublisher = this.getFormPublisher();
|
|
43
|
+
if (!(checkAllPublisher === null || checkAllPublisher === void 0 ? void 0 : checkAllPublisher.hasCheckAll.get())) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (!this.checksAll() && checkAllPublisher && formPublisher && name) {
|
|
47
|
+
if (!formPublisher[this.name].get().length) {
|
|
48
|
+
checkAllPublisher.checkMode = "noneChecked";
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
else if (this.checked === null) {
|
|
52
|
+
checkAllPublisher.checkMode = "someUnchecked";
|
|
53
|
+
}
|
|
54
|
+
else if (checkAllPublisher.checkMode.get() == "noneChecked" || checkAllPublisher.checkMode.get() == null) {
|
|
55
|
+
checkAllPublisher.checkMode = "someUnchecked";
|
|
56
|
+
}
|
|
57
|
+
const currentValues = formPublisher[name].get();
|
|
58
|
+
const allValues = checkAllPublisher.values.get();
|
|
59
|
+
if (allValues && allValues.length) {
|
|
60
|
+
let checkedCount = allValues.length;
|
|
61
|
+
for (const p of allValues) {
|
|
62
|
+
if (currentValues.indexOf(p) == -1) {
|
|
63
|
+
checkedCount -= 1;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if (checkedCount == allValues.length) {
|
|
67
|
+
checkAllPublisher.checkMode = "allChecked";
|
|
68
|
+
}
|
|
69
|
+
if (checkedCount == 0) {
|
|
70
|
+
checkAllPublisher.checkMode = "noneChecked";
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
if (allValues.indexOf(this.value) == -1) {
|
|
74
|
+
this.checked = null;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
this.onChecksAllRequest = (value) => {
|
|
79
|
+
this.removeAttribute("allChecked");
|
|
80
|
+
this.removeAttribute("indeterminate");
|
|
81
|
+
if (value == "allChecked") {
|
|
82
|
+
this.checked = true;
|
|
83
|
+
this.setAttribute("allChecked", "");
|
|
84
|
+
}
|
|
85
|
+
if (value == "noneChecked") {
|
|
86
|
+
this.checked = null;
|
|
87
|
+
}
|
|
88
|
+
if (value == "someUnchecked") {
|
|
89
|
+
if (this.checksAll())
|
|
90
|
+
this.checked = "indeterminate";
|
|
91
|
+
this.setAttribute("indeterminate", "");
|
|
92
|
+
}
|
|
93
|
+
};
|
|
37
94
|
}
|
|
38
95
|
get value() {
|
|
39
96
|
return this._value;
|
|
40
97
|
}
|
|
41
|
-
set value(
|
|
98
|
+
set value(newValue) {
|
|
99
|
+
if (this.value == newValue)
|
|
100
|
+
return;
|
|
42
101
|
if (this.hasAttribute("value") && !this.forceAutoFill)
|
|
43
|
-
|
|
44
|
-
if (this._value ==
|
|
102
|
+
newValue = this.getAttribute("value");
|
|
103
|
+
if (this._value == newValue)
|
|
45
104
|
return;
|
|
46
|
-
|
|
47
|
-
|
|
105
|
+
if (newValue == null)
|
|
106
|
+
return;
|
|
107
|
+
this._value = newValue;
|
|
108
|
+
if (!this.value)
|
|
109
|
+
return;
|
|
110
|
+
// On check l'élément si il est cheched dans le formPublisher
|
|
111
|
+
const formPublisher = this.getFormPublisher();
|
|
112
|
+
if (formPublisher && this.name) {
|
|
113
|
+
let currentValue = formPublisher[this.name].get();
|
|
114
|
+
if (this.radio || this.unique) {
|
|
115
|
+
this.checked = currentValue == newValue ? true : null;
|
|
116
|
+
}
|
|
117
|
+
if (!Array.isArray(currentValue)) {
|
|
118
|
+
currentValue = [];
|
|
119
|
+
}
|
|
120
|
+
if (currentValue.indexOf(newValue) != -1)
|
|
121
|
+
this.checked = true;
|
|
122
|
+
}
|
|
123
|
+
//On mets à jour la valeur dans la donnée si l'élément est checked
|
|
124
|
+
if (this.checked == true)
|
|
125
|
+
this.updateDataValue();
|
|
48
126
|
this.requestUpdate();
|
|
49
127
|
}
|
|
50
128
|
get checked() {
|
|
@@ -52,18 +130,38 @@ const Form = (superClass) => {
|
|
|
52
130
|
}
|
|
53
131
|
set checked(checked) {
|
|
54
132
|
this.setCheckedValue(checked);
|
|
133
|
+
if (this.checksAll()) {
|
|
134
|
+
const checkAllPublisher = this.getCheckAllPublisher();
|
|
135
|
+
if (checkAllPublisher) {
|
|
136
|
+
if (this.checked === true)
|
|
137
|
+
checkAllPublisher.checkMode = "allChecked";
|
|
138
|
+
else if (this.checked === null) {
|
|
139
|
+
checkAllPublisher.checkMode = "noneChecked";
|
|
140
|
+
const formPublisher = this.getFormPublisher();
|
|
141
|
+
if (formPublisher) {
|
|
142
|
+
formPublisher[this.name] = [];
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
this.requestUpdate();
|
|
55
148
|
}
|
|
56
149
|
validateFormElement() {
|
|
57
150
|
var _a;
|
|
58
|
-
const
|
|
59
|
-
const input = (_a = that.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector("input");
|
|
151
|
+
const input = (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector("input");
|
|
60
152
|
if (!input || input.checkValidity())
|
|
61
153
|
return;
|
|
62
|
-
|
|
63
|
-
if (
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
154
|
+
const formPublisher = this.getFormPublisher();
|
|
155
|
+
if (formPublisher) {
|
|
156
|
+
const value = formPublisher[this.name].get();
|
|
157
|
+
if ((this.unique || this.radio) && value !== null && value.toString().length > 0)
|
|
158
|
+
return;
|
|
159
|
+
formPublisher.isFormValid = false;
|
|
160
|
+
input.reportValidity();
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
checksAll() {
|
|
164
|
+
return this.hasAttribute("checksAll");
|
|
67
165
|
}
|
|
68
166
|
setCheckedValue(checked) {
|
|
69
167
|
if (this._checked == checked)
|
|
@@ -71,6 +169,7 @@ const Form = (superClass) => {
|
|
|
71
169
|
this._checked = checked;
|
|
72
170
|
this.updateDataValue();
|
|
73
171
|
this.requestUpdate();
|
|
172
|
+
setTimeout(() => this.updateAllChecked(), 1);
|
|
74
173
|
// Désactivation du checked sur le publisher
|
|
75
174
|
// Pas sur de l'utilité mais provoque un bug
|
|
76
175
|
// if (this.publisher && !this.radio && !this.unique) {
|
|
@@ -78,7 +177,8 @@ const Form = (superClass) => {
|
|
|
78
177
|
// }
|
|
79
178
|
}
|
|
80
179
|
handleChange() {
|
|
81
|
-
|
|
180
|
+
const newCheckedValue = this.checked === true ? (!this.radio ? null : true) : true;
|
|
181
|
+
this.checked = newCheckedValue;
|
|
82
182
|
const event = new Event("change");
|
|
83
183
|
this.dispatchEvent(event);
|
|
84
184
|
}
|
|
@@ -87,23 +187,26 @@ const Form = (superClass) => {
|
|
|
87
187
|
* Le comportement est ici modifié fonction de son mode (checkbox, radio, unique)
|
|
88
188
|
*/
|
|
89
189
|
getValueForFormPublisher() {
|
|
90
|
-
|
|
91
|
-
|
|
190
|
+
const formPublisher = this.getFormPublisher();
|
|
191
|
+
if (!formPublisher)
|
|
192
|
+
return null;
|
|
193
|
+
let currentValue = formPublisher[this.name].get();
|
|
92
194
|
if (this.radio) {
|
|
93
|
-
return this.checked && this.value != null ? this.value : currentValue;
|
|
195
|
+
return this.checked === true && this.value != null ? this.value : currentValue;
|
|
94
196
|
}
|
|
95
197
|
if (this.unique) {
|
|
96
|
-
return this.checked && this.value != null ? this.value : null;
|
|
198
|
+
return this.checked === true && this.value != null ? this.value : null;
|
|
97
199
|
}
|
|
98
200
|
if (!Array.isArray(currentValue)) {
|
|
99
201
|
currentValue = [];
|
|
100
202
|
}
|
|
101
203
|
currentValue = currentValue.slice(0);
|
|
102
|
-
|
|
103
|
-
if (this.checked === true && idx === -1)
|
|
204
|
+
const idx = currentValue.indexOf(this.value);
|
|
205
|
+
if (this.checked === true && idx === -1 && !this.checksAll())
|
|
104
206
|
currentValue.push(this.value);
|
|
105
|
-
if (this.checked === null && idx !== -1)
|
|
207
|
+
if (this.checked === null && idx !== -1) {
|
|
106
208
|
currentValue.splice(idx, 1);
|
|
209
|
+
}
|
|
107
210
|
return currentValue;
|
|
108
211
|
}
|
|
109
212
|
/**
|
|
@@ -118,15 +221,66 @@ const Form = (superClass) => {
|
|
|
118
221
|
}
|
|
119
222
|
if (!Array.isArray(value))
|
|
120
223
|
value = [];
|
|
224
|
+
if (this.checksAll()) {
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
121
227
|
this.checked = value.indexOf(this.value) !== -1 ? true : null;
|
|
122
228
|
}
|
|
123
|
-
|
|
124
|
-
|
|
229
|
+
getCheckAllPublisher() {
|
|
230
|
+
if (!this.formDataProvider)
|
|
231
|
+
this.formDataProvider = this.getAncestorAttributeValue("formDataProvider");
|
|
232
|
+
const formDataProvider = this.formDataProvider;
|
|
233
|
+
const name = this.getAttribute("name");
|
|
234
|
+
if (!formDataProvider || !name) {
|
|
235
|
+
return null;
|
|
236
|
+
}
|
|
237
|
+
return PublisherManager.get(formDataProvider + "/" + name + "/_available_values_");
|
|
238
|
+
}
|
|
239
|
+
disconnectedCallback() {
|
|
240
|
+
super.disconnectedCallback();
|
|
241
|
+
const checkAllPublisher = this.getCheckAllPublisher();
|
|
242
|
+
if (checkAllPublisher) {
|
|
243
|
+
checkAllPublisher.checkMode.offAssign(this.onChecksAllRequest);
|
|
244
|
+
if (!this.checksAll()) {
|
|
245
|
+
const values = checkAllPublisher.values.get().slice(0);
|
|
246
|
+
const idx = values.indexOf(this.value);
|
|
247
|
+
if (idx != -1) {
|
|
248
|
+
values.splice(idx, 1);
|
|
249
|
+
checkAllPublisher.values = values;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
setTimeout(() => this.updateAllChecked(), 1);
|
|
254
|
+
}
|
|
255
|
+
connectedCallback() {
|
|
256
|
+
super.connectedCallback();
|
|
257
|
+
const formPublisher = this.getFormPublisher();
|
|
258
|
+
if (formPublisher && this.name) {
|
|
259
|
+
const publisherValueForName = formPublisher[this.name].get();
|
|
260
|
+
if (publisherValueForName &&
|
|
261
|
+
Array.isArray(publisherValueForName) &&
|
|
262
|
+
publisherValueForName.indexOf(this.value) !== -1) {
|
|
263
|
+
this.checked = true;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
const checkAllPublisher = this.getCheckAllPublisher();
|
|
267
|
+
if (checkAllPublisher) {
|
|
268
|
+
checkAllPublisher.checkMode.onAssign(this.onChecksAllRequest);
|
|
269
|
+
if (this.checksAll()) {
|
|
270
|
+
checkAllPublisher.hasCheckAll = true;
|
|
271
|
+
}
|
|
272
|
+
if (!checkAllPublisher.values.get()) {
|
|
273
|
+
checkAllPublisher.values = [];
|
|
274
|
+
}
|
|
275
|
+
if (!this.checksAll()) {
|
|
276
|
+
checkAllPublisher.values = [...checkAllPublisher.values.get(), this.value];
|
|
277
|
+
}
|
|
278
|
+
}
|
|
125
279
|
if (!this.hasAttribute("checked")) {
|
|
126
280
|
return;
|
|
127
281
|
}
|
|
128
282
|
if (!this.publisher || this.publisher.get().checked !== false) {
|
|
129
|
-
this.checked = true;
|
|
283
|
+
setTimeout(() => (this.checked = true), 1);
|
|
130
284
|
}
|
|
131
285
|
}
|
|
132
286
|
}
|
|
@@ -142,6 +296,9 @@ const Form = (superClass) => {
|
|
|
142
296
|
__decorate([
|
|
143
297
|
property({ type: Boolean })
|
|
144
298
|
], FormCheckable.prototype, "radio", void 0);
|
|
299
|
+
__decorate([
|
|
300
|
+
property({ type: Boolean })
|
|
301
|
+
], FormCheckable.prototype, "unCheckOnDisconnect", void 0);
|
|
145
302
|
__decorate([
|
|
146
303
|
property()
|
|
147
304
|
], FormCheckable.prototype, "checked", null);
|
|
@@ -1,22 +1,30 @@
|
|
|
1
1
|
import { SubscriberInterface } from "@supersoniks/concorde/core/mixins/Subscriber";
|
|
2
|
-
|
|
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;
|
|
3
6
|
export interface FormElementInterface extends SubscriberInterface {
|
|
4
|
-
getFormPublisher():
|
|
7
|
+
getFormPublisher(): PublisherInterface;
|
|
5
8
|
updateDataValue(): void;
|
|
6
|
-
handleChange(e?:
|
|
7
|
-
handleBlur(e?:
|
|
8
|
-
getValueForFormPublisher():
|
|
9
|
+
handleChange(e?: Event): void;
|
|
10
|
+
handleBlur(e?: Event): void;
|
|
11
|
+
getValueForFormPublisher(): FormElementValue;
|
|
12
|
+
validateFormElement(): void;
|
|
13
|
+
focus?: () => void;
|
|
14
|
+
shadowRoot?: ShadowRoot;
|
|
9
15
|
error: boolean;
|
|
10
16
|
autofocus: boolean;
|
|
11
17
|
required: boolean;
|
|
12
18
|
disabled: true | null;
|
|
13
19
|
formDataProvider: string;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
20
|
+
ariaLabelledby?: string;
|
|
21
|
+
ariaLabel?: string;
|
|
22
|
+
_value: FormElementValue;
|
|
23
|
+
get value(): FormElementValue;
|
|
24
|
+
set value(value: FormElementValue);
|
|
17
25
|
_name: string;
|
|
18
26
|
get name(): string;
|
|
19
27
|
set name(value: string);
|
|
20
28
|
}
|
|
21
|
-
declare const Form: <T extends Constructor<SubscriberInterface
|
|
29
|
+
declare const Form: <T extends Constructor<SubscriberInterface<CoreJSType>>>(superClass: T) => Constructor<FormElementInterface> & T;
|
|
22
30
|
export default Form;
|