@supersoniks/concorde 1.1.42 → 1.1.43
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 +5081 -4317
- package/core/_types/types.d.ts +26 -0
- package/core/_types/types.js +1 -0
- package/core/components/functional/date/date.d.ts +13 -5
- package/core/components/functional/date/date.js +48 -29
- 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 +40 -3
- 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 +32 -8
- package/core/components/functional/list/list.js +33 -40
- package/core/components/functional/mix/mix.d.ts +22 -0
- package/core/components/functional/mix/mix.js +99 -0
- package/core/components/functional/queue/queue.d.ts +16 -3
- package/core/components/functional/queue/queue.js +71 -15
- package/core/components/functional/router/redirect.d.ts +10 -1
- package/core/components/functional/router/redirect.js +5 -6
- package/core/components/functional/router/router.d.ts +15 -1
- package/core/components/functional/router/router.js +1 -6
- package/core/components/functional/sdui/SDUIDescriptorTransformer.d.ts +1 -1
- package/core/components/functional/sdui/SDUIDescriptorTransformer.js +24 -12
- 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 +16 -9
- package/core/components/functional/sdui/sdui.js +52 -25
- package/core/components/functional/sdui/types.d.ts +4 -2
- package/core/components/functional/states/states.d.ts +19 -3
- package/core/components/functional/states/states.js +7 -12
- package/core/components/functional/submit/submit.d.ts +16 -1
- package/core/components/functional/submit/submit.js +87 -17
- 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 +23 -20
- package/core/components/ui/button/button.js +59 -42
- package/core/components/ui/captcha/captcha.d.ts +14 -2
- package/core/components/ui/captcha/captcha.js +17 -12
- 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 +1 -6
- 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 +28 -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 +53 -16
- 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 +15 -18
- 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 +3 -2
- package/core/components/ui/form/input/same-value-helper.d.ts +1 -1
- package/core/components/ui/form/input/same-value-helper.js +1 -0
- 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 +23 -7
- package/core/components/ui/form/select/select.js +69 -38
- package/core/components/ui/form/textarea/textarea.d.ts +13 -13
- 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 +11 -8
- 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.js +2 -8
- 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 +183 -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 +36 -36
- package/core/components/ui/pop/pop.d.ts +6 -5
- package/core/components/ui/pop/pop.js +44 -44
- 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/taxonomy/taxonomy.d.ts +6 -3
- package/core/components/ui/taxonomy/taxonomy.js +9 -9
- 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 +7 -36
- package/core/components/ui/toast/message-subscriber.d.ts +13 -7
- package/core/components/ui/toast/toast-item.js +1 -1
- package/core/components/ui/toast/toast.d.ts +2 -1
- package/core/components/ui/toast/toast.js +29 -14
- package/core/components/ui/tooltip/tooltip.d.ts +1 -0
- package/core/components/ui/tooltip/tooltip.js +35 -14
- package/core/components/ui/ui.js +0 -3
- package/core/core.js +5 -6
- package/core/mixins/Fetcher.d.ts +19 -10
- package/core/mixins/Fetcher.js +26 -10
- package/core/mixins/FormCheckable.d.ts +17 -8
- package/core/mixins/FormCheckable.js +177 -22
- package/core/mixins/FormElement.d.ts +12 -7
- package/core/mixins/FormElement.js +42 -26
- package/core/mixins/FormInput.d.ts +8 -4
- package/core/mixins/FormInput.js +4 -3
- package/core/mixins/Subscriber.d.ts +7 -5
- package/core/mixins/Subscriber.js +34 -32
- package/core/utils/Arrays.d.ts +15 -15
- package/core/utils/DataBindObserver.d.ts +16 -9
- package/core/utils/DataBindObserver.js +23 -28
- 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 +22 -3
- package/core/utils/LocationHandler.d.ts +6 -5
- package/core/utils/LocationHandler.js +19 -8
- package/core/utils/Objects.d.ts +7 -4
- package/core/utils/Objects.js +28 -6
- package/core/utils/{PublisherProxy.d.mts → PublisherProxy.d.ts} +40 -31
- package/core/utils/{PublisherProxy.mjs → PublisherProxy.js} +54 -28
- package/core/utils/Utils.d.ts +3 -0
- package/core/utils/Utils.js +18 -0
- package/core/utils/api.d.ts +39 -7
- package/core/utils/api.js +45 -32
- package/img/concorde-logo.svg +1 -0
- package/img/concorde.png +0 -0
- package/img/concorde_def.png +0 -0
- package/mixins.d.ts +36 -18
- package/mixins.js +3 -4
- package/package.json +45 -10
- 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/mixins/Fetcher.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="node" />
|
|
2
2
|
import "@supersoniks/concorde/core/components/ui/button/button";
|
|
3
3
|
import { SubscriberInterface } from "@supersoniks/concorde/core/mixins/Subscriber";
|
|
4
|
+
import API from "@supersoniks/concorde/core/utils/api";
|
|
4
5
|
declare type Constructor<T> = new (...args: any[]) => T;
|
|
5
|
-
declare const Fetcher: <T extends Constructor<SubscriberInterface>>(superClass: T) => {
|
|
6
|
+
declare const Fetcher: <PropsType = any, T extends Constructor<SubscriberInterface<PropsType>> = any>(superClass: T, propsType?: PropsType | undefined) => {
|
|
6
7
|
new (...args: any[]): {
|
|
7
8
|
api: API | null;
|
|
8
9
|
/**
|
|
@@ -33,6 +34,9 @@ declare const Fetcher: <T extends Constructor<SubscriberInterface>>(superClass:
|
|
|
33
34
|
isFetchEnabled: boolean;
|
|
34
35
|
_endPoint: string;
|
|
35
36
|
endPoint: string;
|
|
37
|
+
requestId: number;
|
|
38
|
+
refetchEveryMs: number;
|
|
39
|
+
refetchTimeOutId?: NodeJS.Timeout | undefined;
|
|
36
40
|
/**
|
|
37
41
|
*
|
|
38
42
|
* C'est ici que les données sont chargées via l'utilitaire API
|
|
@@ -40,7 +44,7 @@ declare const Fetcher: <T extends Constructor<SubscriberInterface>>(superClass:
|
|
|
40
44
|
* Un Toast est affiché si le chargement échoue
|
|
41
45
|
*/
|
|
42
46
|
_fetchData(): Promise<void>;
|
|
43
|
-
onInvalidate
|
|
47
|
+
onInvalidate?: (() => void) | undefined;
|
|
44
48
|
disconnectedCallback(): void;
|
|
45
49
|
connectedCallback(): void;
|
|
46
50
|
/**
|
|
@@ -48,27 +52,32 @@ declare const Fetcher: <T extends Constructor<SubscriberInterface>>(superClass:
|
|
|
48
52
|
*/
|
|
49
53
|
firstUpdated(): void;
|
|
50
54
|
onIntersection(entries: IntersectionObserverEntry[]): void;
|
|
51
|
-
props:
|
|
55
|
+
props: PropsType | null;
|
|
52
56
|
propertyMap: Object;
|
|
53
57
|
isConnected: boolean;
|
|
54
|
-
getAncestorAttributeValue(attributeName: string): string;
|
|
55
|
-
* 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.
|
|
56
|
-
* 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)
|
|
57
|
-
*/
|
|
58
|
+
getAncestorAttributeValue(attributeName: string): string;
|
|
58
59
|
hasAncestorAttribute(attributeName: string): boolean;
|
|
59
60
|
querySelectorAll(selector: string): NodeListOf<Element>;
|
|
60
61
|
publisher: any;
|
|
61
62
|
dataProvider: string | null;
|
|
62
|
-
noShadowDom: string | null;
|
|
63
|
+
noShadowDom: string | null; /**
|
|
64
|
+
* isFirstLoad vaut true jusqu'au premier chargement de données
|
|
65
|
+
*/
|
|
63
66
|
debug: HTMLElement | null;
|
|
64
67
|
defferedDebug: boolean | null;
|
|
65
68
|
displayContents: boolean;
|
|
69
|
+
shadowRoot?: ShadowRoot | undefined; /**
|
|
70
|
+
* isLoading vaut true pendant le chargement des données
|
|
71
|
+
*/
|
|
66
72
|
dispatchEvent(event: Event): void;
|
|
67
73
|
setAttribute(name: string, value: string): void;
|
|
68
74
|
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions | undefined): void;
|
|
69
75
|
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions | undefined): void;
|
|
70
76
|
removeAttribute(name: string): void;
|
|
71
|
-
initPublisher(): 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
|
+
*/
|
|
72
81
|
getApiConfiguration(): import("@supersoniks/concorde/core/utils/api").APIConfiguration;
|
|
73
82
|
requestUpdate(): void;
|
|
74
83
|
getAttribute(name: string): string;
|
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,6 +53,8 @@ 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
|
}
|
|
@@ -102,37 +105,44 @@ const Fetcher = (superClass) => {
|
|
|
102
105
|
Loader.hide();
|
|
103
106
|
if (this.key) {
|
|
104
107
|
let response = data._sonic_http_response_;
|
|
105
|
-
|
|
106
|
-
|
|
108
|
+
/* preserveOtherKeys s'exprime lorsque le paramètre "key" est défini
|
|
109
|
+
* Conserve les autres propriétés de l'objet reçu, en plus des propriétés définies sous "key"
|
|
110
|
+
*/
|
|
111
|
+
data = Objects.traverse(data, this.key.split("."), this.hasAttribute("preserveOtherKeys"));
|
|
112
|
+
if (data && Objects.isObject(data) && response)
|
|
107
113
|
data._sonic_http_response_ = response;
|
|
108
114
|
}
|
|
109
115
|
this.props = data;
|
|
110
116
|
this.dispatchEvent(new CustomEvent("load", { detail: this }));
|
|
111
117
|
this.isFirstLoad = false;
|
|
112
118
|
this.isLoading = false;
|
|
119
|
+
if (this.refetchEveryMs && this.isConnected) {
|
|
120
|
+
this.refetchTimeOutId = setTimeout(() => this._fetchData(), this.refetchEveryMs);
|
|
121
|
+
}
|
|
113
122
|
});
|
|
114
123
|
}
|
|
115
124
|
disconnectedCallback() {
|
|
116
125
|
var _a;
|
|
117
126
|
super.disconnectedCallback();
|
|
118
127
|
(_a = this.publisher) === null || _a === void 0 ? void 0 : _a.offInvalidate(this.onInvalidate);
|
|
128
|
+
clearTimeout(this.refetchTimeOutId);
|
|
119
129
|
this.isFirstLoad = false;
|
|
120
130
|
}
|
|
121
131
|
connectedCallback() {
|
|
122
132
|
var _a;
|
|
123
|
-
this.noShadowDom = "";
|
|
133
|
+
// this.noShadowDom = "";
|
|
124
134
|
if (!this.isFetchEnabled) {
|
|
125
135
|
super.connectedCallback();
|
|
126
136
|
return;
|
|
127
137
|
}
|
|
128
138
|
super.connectedCallback();
|
|
129
|
-
this.key = this.
|
|
139
|
+
this.key = this.getAttribute("key");
|
|
130
140
|
if (this.props) {
|
|
131
141
|
this.publisher.set(this.props);
|
|
132
142
|
}
|
|
133
143
|
this.onInvalidate = () => this._fetchData();
|
|
134
144
|
(_a = this.publisher) === null || _a === void 0 ? void 0 : _a.onInvalidate(this.onInvalidate);
|
|
135
|
-
const lazyLoad = this.
|
|
145
|
+
const lazyLoad = this.getAttribute("lazyload");
|
|
136
146
|
if (lazyLoad === null) {
|
|
137
147
|
this._fetchData();
|
|
138
148
|
}
|
|
@@ -141,7 +151,7 @@ const Fetcher = (superClass) => {
|
|
|
141
151
|
* Première update, le comportement de lazyload est géré ici a l'aide d'un intersection observer.
|
|
142
152
|
*/
|
|
143
153
|
firstUpdated() {
|
|
144
|
-
const lazyLoad = this.
|
|
154
|
+
const lazyLoad = this.getAttribute("lazyload");
|
|
145
155
|
if (lazyLoad === null) {
|
|
146
156
|
return;
|
|
147
157
|
}
|
|
@@ -151,7 +161,7 @@ const Fetcher = (superClass) => {
|
|
|
151
161
|
};
|
|
152
162
|
this.iObserver = new IntersectionObserver((entries) => this.onIntersection(entries), options);
|
|
153
163
|
let that = this;
|
|
154
|
-
let elt =
|
|
164
|
+
let elt = this.shadowRoot ? this.shadowRoot.children[0] : that.children[0];
|
|
155
165
|
if (elt && elt.nodeName.toLocaleLowerCase() == "slot")
|
|
156
166
|
elt = elt.children[0];
|
|
157
167
|
if (!elt || elt.nodeName.toLocaleLowerCase() == "template") {
|
|
@@ -176,6 +186,12 @@ const Fetcher = (superClass) => {
|
|
|
176
186
|
__decorate([
|
|
177
187
|
property({ type: String })
|
|
178
188
|
], FetcherElement.prototype, "endPoint", null);
|
|
189
|
+
__decorate([
|
|
190
|
+
property()
|
|
191
|
+
], FetcherElement.prototype, "requestId", void 0);
|
|
192
|
+
__decorate([
|
|
193
|
+
property({ type: Number })
|
|
194
|
+
], FetcherElement.prototype, "refetchEveryMs", void 0);
|
|
179
195
|
return FetcherElement; // as Constructor<SubscriberInterface> & T;
|
|
180
196
|
};
|
|
181
197
|
export default Fetcher;
|
|
@@ -16,13 +16,15 @@ declare const Form: <T extends Constructor<FormElementInterface>>(superClass: T)
|
|
|
16
16
|
Active le mode radio
|
|
17
17
|
*/
|
|
18
18
|
radio: true | null;
|
|
19
|
+
unCheckOnDisconnect: boolean;
|
|
19
20
|
/**
|
|
20
21
|
* propriété checked avec des caractéristiques similaire à un input html classique.
|
|
21
22
|
*/
|
|
22
|
-
_checked: true | null;
|
|
23
|
-
checked: true | null;
|
|
23
|
+
_checked: true | null | "indeterminate";
|
|
24
|
+
checked: true | "indeterminate" | null;
|
|
24
25
|
validateFormElement(): void;
|
|
25
|
-
|
|
26
|
+
checksAll(): boolean;
|
|
27
|
+
setCheckedValue(checked: true | null | "indeterminate"): void;
|
|
26
28
|
handleChange(): void;
|
|
27
29
|
/**
|
|
28
30
|
* Voir la mixin FormElement
|
|
@@ -34,16 +36,24 @@ declare const Form: <T extends Constructor<FormElementInterface>>(superClass: T)
|
|
|
34
36
|
* Le comportement est modifié de la manière suivante :
|
|
35
37
|
* 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
38
|
*/
|
|
37
|
-
setFormValueFromPublisher(value:
|
|
38
|
-
|
|
39
|
+
setFormValueFromPublisher(value: string | Array<string | null> | null): void;
|
|
40
|
+
getCheckAllPublisher(): any;
|
|
41
|
+
updateAllChecked: () => void;
|
|
42
|
+
onChecksAllRequest: (value: string) => void;
|
|
43
|
+
disconnectedCallback(): void;
|
|
44
|
+
connectedCallback(): void;
|
|
39
45
|
getFormPublisher(): any;
|
|
40
46
|
updateDataValue(): void;
|
|
41
|
-
handleBlur(e?:
|
|
47
|
+
handleBlur(e?: Event | undefined): void;
|
|
48
|
+
focus?: (() => void) | undefined;
|
|
49
|
+
shadowRoot?: ShadowRoot | undefined;
|
|
42
50
|
error: boolean;
|
|
43
51
|
autofocus: boolean;
|
|
44
52
|
required: boolean;
|
|
45
53
|
disabled: true | null;
|
|
46
54
|
formDataProvider: string;
|
|
55
|
+
ariaLabelledby?: string | undefined;
|
|
56
|
+
ariaLabel?: string | undefined;
|
|
47
57
|
_name: string;
|
|
48
58
|
name: string;
|
|
49
59
|
props: any;
|
|
@@ -63,12 +73,11 @@ declare const Form: <T extends Constructor<FormElementInterface>>(superClass: T)
|
|
|
63
73
|
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions | undefined): void;
|
|
64
74
|
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions | undefined): void;
|
|
65
75
|
removeAttribute(name: string): void;
|
|
76
|
+
initPublisher(): void;
|
|
66
77
|
getApiConfiguration(): import("../utils/api").APIConfiguration;
|
|
67
|
-
connectedCallback(): void;
|
|
68
78
|
requestUpdate(): void;
|
|
69
79
|
getAttribute(name: string): string;
|
|
70
80
|
hasAttribute(attributeName: String): boolean;
|
|
71
|
-
disconnectedCallback(): void;
|
|
72
81
|
};
|
|
73
82
|
} & T;
|
|
74
83
|
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
|
+
let name = this.getAttribute("name");
|
|
41
|
+
let checkAllPublisher = this.getCheckAllPublisher();
|
|
42
|
+
let 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
|
+
let currentValues = formPublisher[name].get();
|
|
58
|
+
let allValues = checkAllPublisher.values.get();
|
|
59
|
+
if (allValues && allValues.length) {
|
|
60
|
+
let checkedCount = allValues.length;
|
|
61
|
+
for (let 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
|
+
let 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
|
+
let 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
|
+
let 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
|
-
let
|
|
63
|
-
if (
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
154
|
+
let formPublisher = this.getFormPublisher();
|
|
155
|
+
if (formPublisher) {
|
|
156
|
+
let 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
|
-
let
|
|
91
|
-
|
|
190
|
+
let 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
204
|
let idx = currentValue.indexOf(this.value);
|
|
103
|
-
if (this.checked === true && idx === -1)
|
|
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,64 @@ 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
|
+
let 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
|
+
let checkAllPublisher = this.getCheckAllPublisher();
|
|
242
|
+
if (checkAllPublisher) {
|
|
243
|
+
checkAllPublisher.checkMode.offAssign(this.onChecksAllRequest);
|
|
244
|
+
if (!this.checksAll()) {
|
|
245
|
+
let 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
|
+
let publisherValueForName = formPublisher[this.name].get();
|
|
260
|
+
if (publisherValueForName && publisherValueForName.indexOf(this.value) !== -1) {
|
|
261
|
+
this.checked = true;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
let checkAllPublisher = this.getCheckAllPublisher();
|
|
265
|
+
if (checkAllPublisher) {
|
|
266
|
+
checkAllPublisher.checkMode.onAssign(this.onChecksAllRequest);
|
|
267
|
+
if (this.checksAll()) {
|
|
268
|
+
checkAllPublisher.hasCheckAll = true;
|
|
269
|
+
}
|
|
270
|
+
if (!checkAllPublisher.values.get()) {
|
|
271
|
+
checkAllPublisher.values = [];
|
|
272
|
+
}
|
|
273
|
+
if (!this.checksAll()) {
|
|
274
|
+
checkAllPublisher.values = [...checkAllPublisher.values.get(), this.value];
|
|
275
|
+
}
|
|
276
|
+
}
|
|
125
277
|
if (!this.hasAttribute("checked")) {
|
|
126
278
|
return;
|
|
127
279
|
}
|
|
128
280
|
if (!this.publisher || this.publisher.get().checked !== false) {
|
|
129
|
-
this.checked = true;
|
|
281
|
+
setTimeout(() => (this.checked = true), 1);
|
|
130
282
|
}
|
|
131
283
|
}
|
|
132
284
|
}
|
|
@@ -142,6 +294,9 @@ const Form = (superClass) => {
|
|
|
142
294
|
__decorate([
|
|
143
295
|
property({ type: Boolean })
|
|
144
296
|
], FormCheckable.prototype, "radio", void 0);
|
|
297
|
+
__decorate([
|
|
298
|
+
property({ type: Boolean })
|
|
299
|
+
], FormCheckable.prototype, "unCheckOnDisconnect", void 0);
|
|
145
300
|
__decorate([
|
|
146
301
|
property()
|
|
147
302
|
], FormCheckable.prototype, "checked", null);
|
|
@@ -1,22 +1,27 @@
|
|
|
1
1
|
import { SubscriberInterface } from "@supersoniks/concorde/core/mixins/Subscriber";
|
|
2
|
+
import { PublisherInterface } from "../_types/types";
|
|
2
3
|
declare type Constructor<T> = new (...args: any[]) => T;
|
|
3
4
|
export interface FormElementInterface extends SubscriberInterface {
|
|
4
|
-
getFormPublisher():
|
|
5
|
+
getFormPublisher(): PublisherInterface;
|
|
5
6
|
updateDataValue(): void;
|
|
6
|
-
handleChange(e?:
|
|
7
|
-
handleBlur(e?:
|
|
7
|
+
handleChange(e?: Event): void;
|
|
8
|
+
handleBlur(e?: Event): void;
|
|
8
9
|
getValueForFormPublisher(): any;
|
|
10
|
+
focus?: () => void;
|
|
11
|
+
shadowRoot?: ShadowRoot;
|
|
9
12
|
error: boolean;
|
|
10
13
|
autofocus: boolean;
|
|
11
14
|
required: boolean;
|
|
12
15
|
disabled: true | null;
|
|
13
16
|
formDataProvider: string;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
+
ariaLabelledby?: string;
|
|
18
|
+
ariaLabel?: string;
|
|
19
|
+
_value: string | null;
|
|
20
|
+
get value(): string | null;
|
|
21
|
+
set value(value: string | null);
|
|
17
22
|
_name: string;
|
|
18
23
|
get name(): string;
|
|
19
24
|
set name(value: string);
|
|
20
25
|
}
|
|
21
|
-
declare const Form: <T extends Constructor<SubscriberInterface
|
|
26
|
+
declare const Form: <T extends Constructor<SubscriberInterface<any>>>(superClass: T) => Constructor<FormElementInterface> & T;
|
|
22
27
|
export default Form;
|