@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
|
@@ -133,7 +133,8 @@ const Subscriber = (superClass, type) => {
|
|
|
133
133
|
updated(_changedProperties) {
|
|
134
134
|
super.updated(_changedProperties);
|
|
135
135
|
let ref = this.shadowRoot || this;
|
|
136
|
-
|
|
136
|
+
const children = [...ref.children].filter((child) => child.tagName != "STYLE");
|
|
137
|
+
let display = this.displayContents ? "contents" : children.length == 0 ? "none" : null;
|
|
137
138
|
if (display)
|
|
138
139
|
this.style.display = display;
|
|
139
140
|
else
|
|
@@ -141,12 +142,12 @@ const Subscriber = (superClass, type) => {
|
|
|
141
142
|
}
|
|
142
143
|
connectedCallback() {
|
|
143
144
|
if (this.hasAttribute("lazyRendering")) {
|
|
144
|
-
|
|
145
|
+
const options = {
|
|
145
146
|
root: null,
|
|
146
147
|
rootMargin: Math.max(window.innerWidth * 0.1, window.innerHeight * 0.1) + "px",
|
|
147
148
|
};
|
|
148
149
|
let firstView = true;
|
|
149
|
-
|
|
150
|
+
const iObserver = new IntersectionObserver((entries) => {
|
|
150
151
|
for (const e of entries) {
|
|
151
152
|
if (firstView && e.isIntersecting) {
|
|
152
153
|
firstView = false;
|
|
@@ -183,7 +184,7 @@ const Subscriber = (superClass, type) => {
|
|
|
183
184
|
if (this.hasAttribute("debug") && !this.defferedDebug) {
|
|
184
185
|
if (!this.debug) {
|
|
185
186
|
this.debug = document.createElement("div");
|
|
186
|
-
|
|
187
|
+
const style = this.debug.style;
|
|
187
188
|
style.position = "fixed";
|
|
188
189
|
style.top = "0";
|
|
189
190
|
style.right = "0";
|
|
@@ -248,8 +249,8 @@ const Subscriber = (superClass, type) => {
|
|
|
248
249
|
*/
|
|
249
250
|
getApiConfiguration() {
|
|
250
251
|
const token = this.getAncestorAttributeValue("token");
|
|
251
|
-
|
|
252
|
-
|
|
252
|
+
const addHTTPResponse = this.getAncestorAttributeValue("addHTTPResponse") != null;
|
|
253
|
+
const serviceURL = this.getAncestorAttributeValue("serviceURL");
|
|
253
254
|
let userName = null;
|
|
254
255
|
let password = null;
|
|
255
256
|
let tokenProvider = null;
|
|
@@ -258,14 +259,14 @@ const Subscriber = (superClass, type) => {
|
|
|
258
259
|
password = this.getAncestorAttributeValue("password");
|
|
259
260
|
tokenProvider = this.getAncestorAttributeValue("tokenProvider");
|
|
260
261
|
}
|
|
261
|
-
|
|
262
|
+
const credentials = this.getAncestorAttributeValue("credentials") || undefined;
|
|
262
263
|
return { serviceURL, token, userName, password, tokenProvider, addHTTPResponse, credentials };
|
|
263
264
|
}
|
|
264
265
|
initWording() {
|
|
265
266
|
return __awaiter(this, void 0, void 0, function* () {
|
|
266
267
|
let hasWording = false;
|
|
267
268
|
const propNames = Object.getOwnPropertyNames(this.constructor.prototype);
|
|
268
|
-
for (
|
|
269
|
+
for (const p of propNames) {
|
|
269
270
|
if (p.indexOf("wording_") == 0) {
|
|
270
271
|
hasWording = true;
|
|
271
272
|
break;
|
|
@@ -273,15 +274,15 @@ const Subscriber = (superClass, type) => {
|
|
|
273
274
|
}
|
|
274
275
|
if (!hasWording)
|
|
275
276
|
return;
|
|
276
|
-
|
|
277
|
-
|
|
277
|
+
const publisher = PublisherManager.getInstance().get("sonic-wording");
|
|
278
|
+
const wordingProvider = this.getAncestorAttributeValue("wordingProvider");
|
|
278
279
|
const api = new API(this.getApiConfiguration());
|
|
279
280
|
if (wordingProvider) {
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
for (
|
|
281
|
+
const wordings = [];
|
|
282
|
+
const wordingsAll = [];
|
|
283
|
+
for (const p of propNames) {
|
|
283
284
|
if (p.indexOf("wording_") == 0) {
|
|
284
|
-
|
|
285
|
+
const p8 = p.substring(8);
|
|
285
286
|
if (!publisher.get()[p]) {
|
|
286
287
|
publisher[p] = "...";
|
|
287
288
|
wordings.push(p8);
|
|
@@ -290,8 +291,8 @@ const Subscriber = (superClass, type) => {
|
|
|
290
291
|
}
|
|
291
292
|
}
|
|
292
293
|
if (wordings.length > 0) {
|
|
293
|
-
|
|
294
|
-
for (
|
|
294
|
+
const result = (yield api.post(wordingProvider, { labels: wordings }));
|
|
295
|
+
for (const elt in result) {
|
|
295
296
|
publisher["wording_" + elt] = result[elt];
|
|
296
297
|
}
|
|
297
298
|
}
|
|
@@ -309,7 +310,7 @@ const Subscriber = (superClass, type) => {
|
|
|
309
310
|
if (this.noShadowDom === "" || this.getAttribute("noShadowDom") === "") {
|
|
310
311
|
return this;
|
|
311
312
|
}
|
|
312
|
-
|
|
313
|
+
const shadowRoot = super.createRenderRoot();
|
|
313
314
|
DataBindObserver.observe(shadowRoot);
|
|
314
315
|
return shadowRoot;
|
|
315
316
|
}
|
|
@@ -336,7 +337,7 @@ const Subscriber = (superClass, type) => {
|
|
|
336
337
|
let pub = mng.get(publisherId);
|
|
337
338
|
this.dataProvider = publisherId;
|
|
338
339
|
if (this.hasAttribute("subDataProvider")) {
|
|
339
|
-
|
|
340
|
+
const dataPath = this.getAttribute("subDataProvider");
|
|
340
341
|
this.dataProvider = publisherId + "/" + dataPath;
|
|
341
342
|
pub = Objects.traverse(pub, dataPath.split("."));
|
|
342
343
|
mng.set(this.dataProvider, pub);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { LitElement } from "lit";
|
|
2
|
-
|
|
2
|
+
import { MixinArgsType } from "../_types/types";
|
|
3
|
+
type Constructor<T> = new (...args: MixinArgsType[]) => T;
|
|
3
4
|
export declare class TemplatesContainerInterface extends LitElement {
|
|
4
5
|
connectedCallback(): void;
|
|
5
6
|
templateParts: Record<string, HTMLTemplateElement>;
|
|
@@ -39,8 +39,8 @@ const TemplatesContainer = (superClass) => {
|
|
|
39
39
|
this.templatePartsList = [];
|
|
40
40
|
}
|
|
41
41
|
connectedCallback() {
|
|
42
|
-
|
|
43
|
-
for (
|
|
42
|
+
const templates = this.templates || [...this.querySelectorAll("template")];
|
|
43
|
+
for (const t of templates) {
|
|
44
44
|
if (t.hasAttribute(this.templateValueAttribute)) {
|
|
45
45
|
this.templateParts[t.getAttribute(this.templateValueAttribute)] = t;
|
|
46
46
|
this.templatePartsList.push(t);
|
package/core/utils/Arrays.js
CHANGED
|
@@ -16,6 +16,7 @@ class Arrays {
|
|
|
16
16
|
/**
|
|
17
17
|
* Fournie une fonction to1D qui transforme un tableau 2D en un tableau 1D par concaténation
|
|
18
18
|
*/
|
|
19
|
+
/*eslint-disable @typescript-eslint/no-explicit-any*/
|
|
19
20
|
static from2d(source) {
|
|
20
21
|
return {
|
|
21
22
|
to1D: () => {
|
|
@@ -25,6 +26,7 @@ class Arrays {
|
|
|
25
26
|
},
|
|
26
27
|
};
|
|
27
28
|
}
|
|
29
|
+
/*eslint-enable @typescript-eslint/no-explicit-any*/
|
|
28
30
|
/**
|
|
29
31
|
* Fournie des méthodes pour manipuler un tableau
|
|
30
32
|
* A l'écriture cela permet d'avoir des phrases du type:
|
|
@@ -32,6 +34,7 @@ class Arrays {
|
|
|
32
34
|
* puis data.everyItem().has().same().value().forkey("key");
|
|
33
35
|
* Peu mieux faire. ou voir a remplacer un jour par loadHash par exemple.
|
|
34
36
|
**/
|
|
37
|
+
/*eslint-disable @typescript-eslint/no-explicit-any*/
|
|
35
38
|
static from(source) {
|
|
36
39
|
return {
|
|
37
40
|
/**Obtenir le tableau final*/
|
|
@@ -47,7 +50,7 @@ class Arrays {
|
|
|
47
50
|
forKey: (key) => {
|
|
48
51
|
if (source.length < 1)
|
|
49
52
|
return true;
|
|
50
|
-
|
|
53
|
+
const first = (source[0] || {})[key];
|
|
51
54
|
return source.every((item) => (item || {})[key] == first);
|
|
52
55
|
},
|
|
53
56
|
};
|
|
@@ -89,14 +92,14 @@ class Arrays {
|
|
|
89
92
|
group: () => {
|
|
90
93
|
return {
|
|
91
94
|
byKey: (key) => {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
for (
|
|
95
|
-
|
|
95
|
+
const result = [];
|
|
96
|
+
const keys = new Map();
|
|
97
|
+
for (const item of source) {
|
|
98
|
+
const value = item[key];
|
|
96
99
|
if (!keys.has(value)) {
|
|
97
|
-
|
|
100
|
+
const idx = result.length;
|
|
98
101
|
keys.set(value, idx);
|
|
99
|
-
|
|
102
|
+
const pushable = { items: [] };
|
|
100
103
|
pushable[key] = value;
|
|
101
104
|
result.push(pushable);
|
|
102
105
|
}
|
|
@@ -111,7 +114,7 @@ class Arrays {
|
|
|
111
114
|
duplicates: () => {
|
|
112
115
|
return {
|
|
113
116
|
forKey: (key) => {
|
|
114
|
-
|
|
117
|
+
const set = [...new Set(source.map((item) => item[key]))];
|
|
115
118
|
return Arrays.from(set.map((value) => source.find((item) => item[key] == value)));
|
|
116
119
|
},
|
|
117
120
|
};
|
|
@@ -121,7 +124,7 @@ class Arrays {
|
|
|
121
124
|
havingSameValue: () => {
|
|
122
125
|
return {
|
|
123
126
|
forKey: (key) => {
|
|
124
|
-
|
|
127
|
+
const areValuesDifferentForKey = (compared1, key) => (compared2) => compared1[key] != compared2[key];
|
|
125
128
|
return Arrays.from(source.filter((elt) => toRemoveFromSource.every(areValuesDifferentForKey(elt, key))));
|
|
126
129
|
},
|
|
127
130
|
};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { PublisherInterface, PublisherContentType } from "@supersoniks/concorde/core/_types/types";
|
|
2
2
|
import { SearchableDomElement } from "@supersoniks/concorde/core/utils/HTML";
|
|
3
|
-
|
|
3
|
+
type BindedVariablesDescriptor = {
|
|
4
4
|
expression: string;
|
|
5
5
|
variables: Array<Array<string>>;
|
|
6
6
|
};
|
|
7
|
-
|
|
7
|
+
type DataBindItem = {
|
|
8
8
|
propertyToUpdate: string;
|
|
9
9
|
bindedVariablesDescriptor: BindedVariablesDescriptor;
|
|
10
10
|
};
|
|
11
|
-
|
|
11
|
+
type PublisherListenerConfig<ValueType extends PublisherContentType = PublisherContentType> = {
|
|
12
12
|
publisher: PublisherInterface<ValueType>;
|
|
13
13
|
onAssign: (value?: ValueType) => void;
|
|
14
14
|
};
|
|
@@ -73,7 +73,7 @@ export default class DataBindObserver {
|
|
|
73
73
|
* Ceci est un cas spécial, c'est pour ça qu'on utilisa pes Objects.traverse.
|
|
74
74
|
* Il y a toujours un publisher quelque soit l'adresse ce qui permet de cibler des valeurs qui n'existent pas encore
|
|
75
75
|
*/
|
|
76
|
-
static getSubPublisher<T extends PublisherContentType>(pub: PublisherInterface<T>, pathArray?: string[]):
|
|
76
|
+
static getSubPublisher<T extends PublisherContentType>(pub: PublisherInterface<T>, pathArray?: string[]): PublisherInterface;
|
|
77
77
|
/**
|
|
78
78
|
* La liaison avec le publisher est faite ici.
|
|
79
79
|
* TODO Sans doute factoriser
|
|
@@ -24,8 +24,8 @@ export default class DataBindObserver {
|
|
|
24
24
|
return;
|
|
25
25
|
if (DataBindObserver.observedElements.has(element))
|
|
26
26
|
return;
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
const obs = new MutationObserver(DataBindObserver.onMutation);
|
|
28
|
+
const opt = {};
|
|
29
29
|
opt.childList = true;
|
|
30
30
|
opt.subtree = true;
|
|
31
31
|
opt.attributes = true;
|
|
@@ -42,7 +42,7 @@ export default class DataBindObserver {
|
|
|
42
42
|
static unObserve(element) {
|
|
43
43
|
if (!element)
|
|
44
44
|
return;
|
|
45
|
-
|
|
45
|
+
const observer = this.observedElements.get(element);
|
|
46
46
|
if (!observer)
|
|
47
47
|
return;
|
|
48
48
|
observer.disconnect();
|
|
@@ -68,18 +68,16 @@ export default class DataBindObserver {
|
|
|
68
68
|
* Callback appelé par le MutationObserver
|
|
69
69
|
*/
|
|
70
70
|
static onMutation(list) {
|
|
71
|
-
for (
|
|
71
|
+
for (const l of list) {
|
|
72
72
|
switch (l.type) {
|
|
73
73
|
case "attributes":
|
|
74
74
|
DataBindObserver.addPublisherListeners(l.target);
|
|
75
75
|
break;
|
|
76
76
|
case "childList":
|
|
77
|
-
|
|
78
|
-
var removed = l.removedNodes;
|
|
79
|
-
added.forEach((elt) => {
|
|
77
|
+
l.addedNodes.forEach((elt) => {
|
|
80
78
|
DataBindObserver.onAdded(elt);
|
|
81
79
|
});
|
|
82
|
-
|
|
80
|
+
l.removedNodes.forEach((elt) => {
|
|
83
81
|
DataBindObserver.onRemoved(elt);
|
|
84
82
|
});
|
|
85
83
|
break;
|
|
@@ -90,7 +88,7 @@ export default class DataBindObserver {
|
|
|
90
88
|
* La liaison avec le publisher supprimée ici.
|
|
91
89
|
*/
|
|
92
90
|
static removePublisherListeners(target) {
|
|
93
|
-
|
|
91
|
+
const conf = DataBindObserver.publisherListeners.get(target);
|
|
94
92
|
if (!conf)
|
|
95
93
|
return;
|
|
96
94
|
DataBindObserver.publisherListeners.delete(target);
|
|
@@ -135,9 +133,9 @@ export default class DataBindObserver {
|
|
|
135
133
|
return Array.from(element.attributes)
|
|
136
134
|
.filter((attribute) => attribute.name.indexOf("::") == 0)
|
|
137
135
|
.map((e) => {
|
|
138
|
-
|
|
136
|
+
const name = e.name.substring(2);
|
|
139
137
|
return {
|
|
140
|
-
propertyToUpdate: name.replace(
|
|
138
|
+
propertyToUpdate: name.replace(/-((html)|\w)/g, (match) => match.substring(1).toUpperCase()),
|
|
141
139
|
bindedVariablesDescriptor: DataBindObserver.getVariablesDescriptor(e.value),
|
|
142
140
|
};
|
|
143
141
|
});
|
|
@@ -151,7 +149,7 @@ export default class DataBindObserver {
|
|
|
151
149
|
static getSubPublisher(pub, pathArray) {
|
|
152
150
|
if (!pathArray)
|
|
153
151
|
return pub;
|
|
154
|
-
for (
|
|
152
|
+
for (const key of pathArray) {
|
|
155
153
|
if (key == "_self_")
|
|
156
154
|
continue;
|
|
157
155
|
if (!pub)
|
|
@@ -169,12 +167,12 @@ export default class DataBindObserver {
|
|
|
169
167
|
/**
|
|
170
168
|
* On récupère le publisher viea le dataProvider d'un ancêtre de l'élément.
|
|
171
169
|
*/
|
|
172
|
-
|
|
170
|
+
const dataProviderId = HTML.getAncestorAttributeValue((target.parentNode || target.host || target), "dataProvider");
|
|
173
171
|
if (!dataProviderId)
|
|
174
172
|
return;
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
173
|
+
const publisher = PublisherManager.getInstance().get(dataProviderId);
|
|
174
|
+
const dataBindItems = DataBindObserver.getDataBindItems(target);
|
|
175
|
+
const conf = [];
|
|
178
176
|
/**
|
|
179
177
|
* Pour chaque attribut => dataBindItems on fait la liaison avec les (sous) publishers associés aux variables extraites
|
|
180
178
|
* Lorsqu'une assignation est faite sur un des publishers liés, on met à jour la propriété de target dont le nom est renseigne dans l'attribut "propertyToUpdate du databindItem".
|
|
@@ -183,17 +181,17 @@ export default class DataBindObserver {
|
|
|
183
181
|
* Attentions, les Objets/tableaus sont rendus en chaine avant l'interprétation dans ce cas.
|
|
184
182
|
*/
|
|
185
183
|
dataBindItems.forEach((dataBindItem) => {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
for (
|
|
189
|
-
|
|
184
|
+
const bindedVariablesDescriptor = dataBindItem.bindedVariablesDescriptor;
|
|
185
|
+
const propertyToUpdate = dataBindItem.propertyToUpdate;
|
|
186
|
+
for (const value of bindedVariablesDescriptor.variables) {
|
|
187
|
+
const publisherPathArray = value;
|
|
190
188
|
let pub = publisher;
|
|
191
189
|
pub = DataBindObserver.getSubPublisher(publisher, publisherPathArray);
|
|
192
|
-
|
|
193
|
-
|
|
190
|
+
const rec = target;
|
|
191
|
+
const currentConf = {
|
|
194
192
|
publisher: pub,
|
|
195
193
|
onAssign: () => {
|
|
196
|
-
|
|
194
|
+
const values = bindedVariablesDescriptor.variables.map((dataPath) => {
|
|
197
195
|
var _a;
|
|
198
196
|
return (_a = DataBindObserver.getSubPublisher(publisher, dataPath)) === null || _a === void 0 ? void 0 : _a.get();
|
|
199
197
|
});
|
|
@@ -221,7 +219,7 @@ export default class DataBindObserver {
|
|
|
221
219
|
*/
|
|
222
220
|
for (let i = 0; i < values.length; i++) {
|
|
223
221
|
let value = values[i];
|
|
224
|
-
|
|
222
|
+
const variable = bindedVariablesDescriptor.variables[i];
|
|
225
223
|
if (value === null) {
|
|
226
224
|
hasUndeterminatedValue = true;
|
|
227
225
|
value = undefined;
|
|
@@ -229,14 +227,14 @@ export default class DataBindObserver {
|
|
|
229
227
|
expression = expression.replace("$" + variable.join("."), value);
|
|
230
228
|
}
|
|
231
229
|
if (expression.indexOf("|") != -1) {
|
|
232
|
-
|
|
230
|
+
const funcDelimiterIdx = expression.indexOf("|");
|
|
233
231
|
if (funcDelimiterIdx == 0) {
|
|
234
232
|
expression = Format.js(expression.substring(1));
|
|
235
233
|
}
|
|
236
234
|
else {
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
235
|
+
const funcName = expression.substring(0, funcDelimiterIdx);
|
|
236
|
+
const funcArgs = expression.substring(funcDelimiterIdx + 1);
|
|
237
|
+
const fmtFunc = Format[funcName];
|
|
240
238
|
expression = hasUndeterminatedValue ? "" : fmtFunc ? fmtFunc(funcArgs) : expression;
|
|
241
239
|
}
|
|
242
240
|
}
|
package/core/utils/HTML.d.ts
CHANGED
package/core/utils/HTML.js
CHANGED
|
@@ -63,7 +63,7 @@ class HTML {
|
|
|
63
63
|
static loadJS(src) {
|
|
64
64
|
return __awaiter(this, void 0, void 0, function* () {
|
|
65
65
|
const p = new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
|
|
66
|
-
|
|
66
|
+
const script = document.createElement("script");
|
|
67
67
|
script.src = src;
|
|
68
68
|
script.onload = () => resolve(true);
|
|
69
69
|
script.onerror = () => resolve(true);
|
|
@@ -78,7 +78,7 @@ class HTML {
|
|
|
78
78
|
static loadCSS(src) {
|
|
79
79
|
return __awaiter(this, void 0, void 0, function* () {
|
|
80
80
|
const p = new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
|
|
81
|
-
|
|
81
|
+
const cssnode = document.createElement("link");
|
|
82
82
|
cssnode.type = "text/css";
|
|
83
83
|
cssnode.rel = "stylesheet";
|
|
84
84
|
cssnode.href = src;
|
|
@@ -10,7 +10,7 @@ export default class LocationHandler {
|
|
|
10
10
|
if (!LocationHandler.listening) {
|
|
11
11
|
return;
|
|
12
12
|
}
|
|
13
|
-
|
|
13
|
+
const newURL = (_a = document.location) === null || _a === void 0 ? void 0 : _a.href.replace(document.location.origin, "");
|
|
14
14
|
if (LocationHandler.prevURL && LocationHandler.prevURL != newURL) {
|
|
15
15
|
LocationHandler.prevURL = newURL;
|
|
16
16
|
LocationHandler.listeners.forEach((listener) => {
|
|
@@ -23,7 +23,7 @@ export default class LocationHandler {
|
|
|
23
23
|
* Arrête l'écoute des changements de location pour le listener fournit
|
|
24
24
|
*/
|
|
25
25
|
static offChange(listener) {
|
|
26
|
-
|
|
26
|
+
const idx = LocationHandler.listeners.indexOf(listener);
|
|
27
27
|
if (idx == -1)
|
|
28
28
|
return;
|
|
29
29
|
LocationHandler.listeners.splice(idx, 1);
|
|
@@ -54,7 +54,7 @@ export default class LocationHandler {
|
|
|
54
54
|
const referrer = document.referrer;
|
|
55
55
|
if (goBack !== null && goBack !== undefined) {
|
|
56
56
|
const origin = document.location.origin;
|
|
57
|
-
|
|
57
|
+
const urlDest = goBack || origin;
|
|
58
58
|
const isHTTP = referrer.indexOf("http") == 0;
|
|
59
59
|
const isNotSameOrigin = isHTTP ? new URL(referrer).origin != origin : false;
|
|
60
60
|
const isReferrerEmpty = referrer == "";
|
|
@@ -63,7 +63,7 @@ export default class LocationHandler {
|
|
|
63
63
|
const isNotSameURL = urlDest != document.location.href;
|
|
64
64
|
const goToURLDest = (isNotSameOrigin && isNotSameURL) || isFallbackNoReferer;
|
|
65
65
|
if (goToURLDest) {
|
|
66
|
-
|
|
66
|
+
const state = history.state || {};
|
|
67
67
|
state.concorde = state.concorde || {};
|
|
68
68
|
state.concorde.hasDoneHistoryBack = true;
|
|
69
69
|
history.pushState(state, document.title);
|
|
@@ -84,11 +84,11 @@ export default class LocationHandler {
|
|
|
84
84
|
document.location.hash = to.substring(1);
|
|
85
85
|
return;
|
|
86
86
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
87
|
+
const url = new URL(to, document.location.href);
|
|
88
|
+
const split = url.pathname.split("/");
|
|
89
|
+
const newPathName = [];
|
|
90
90
|
let prevSp = "";
|
|
91
|
-
for (
|
|
91
|
+
for (const sp of split) {
|
|
92
92
|
if (sp != prevSp)
|
|
93
93
|
newPathName.push(sp);
|
|
94
94
|
prevSp = sp;
|
|
@@ -112,8 +112,8 @@ export default class LocationHandler {
|
|
|
112
112
|
if (component.autoActive == "disabled")
|
|
113
113
|
return;
|
|
114
114
|
if (component.href && component.href.indexOf("http") != 0) {
|
|
115
|
-
|
|
116
|
-
|
|
115
|
+
const url1 = new URL(component.href, document.location.href);
|
|
116
|
+
const url2 = new URL(component.location || "", document.location.origin);
|
|
117
117
|
let isActive = false;
|
|
118
118
|
if (component.autoActive == "strict") {
|
|
119
119
|
isActive = url1.pathname == url2.pathname && url1.hash == url2.hash && url1.search == url2.search;
|
package/core/utils/Objects.js
CHANGED
|
@@ -2,13 +2,14 @@ class Objects {
|
|
|
2
2
|
/**
|
|
3
3
|
* Effectue une comparaison d'égalité non profonde entre deux objets.
|
|
4
4
|
*/
|
|
5
|
+
/*eslint-disable @typescript-eslint/no-explicit-any*/
|
|
5
6
|
static shallowEqual(object1, object2, useStrictComparaison = true) {
|
|
6
7
|
const keys1 = Object.keys(object1);
|
|
7
8
|
const keys2 = Object.keys(object2);
|
|
8
9
|
if (keys1.length !== keys2.length && useStrictComparaison) {
|
|
9
10
|
return false;
|
|
10
11
|
}
|
|
11
|
-
for (
|
|
12
|
+
for (const key of keys1) {
|
|
12
13
|
const val1 = object1[key];
|
|
13
14
|
const val2 = object2[key];
|
|
14
15
|
const areEqual = useStrictComparaison ? val1 !== val2 : val1 != val2;
|
|
@@ -18,9 +19,11 @@ class Objects {
|
|
|
18
19
|
}
|
|
19
20
|
return true;
|
|
20
21
|
}
|
|
22
|
+
/*eslint-enable @typescript-eslint/no-explicit-any*/
|
|
21
23
|
/**
|
|
22
24
|
* Effectue une comparaison d'égalité profonde entre deux objets.
|
|
23
25
|
*/
|
|
26
|
+
/*eslint-disable @typescript-eslint/no-explicit-any*/
|
|
24
27
|
static deepEqual(object1, object2, useStrictComparaison = true) {
|
|
25
28
|
const keys1 = Object.keys(object1);
|
|
26
29
|
const keys2 = Object.keys(object2);
|
|
@@ -38,6 +41,7 @@ class Objects {
|
|
|
38
41
|
}
|
|
39
42
|
return true;
|
|
40
43
|
}
|
|
44
|
+
/*eslint-enable @typescript-eslint/no-explicit-any*/
|
|
41
45
|
/**
|
|
42
46
|
* @returns true si l'objet est un objet ou un tableau (qui est un objet). mais false si null (car sinon typeof null "object")
|
|
43
47
|
*/
|
|
@@ -54,9 +58,10 @@ class Objects {
|
|
|
54
58
|
* traverse l'objet pour obtenir la valeur a l'adresse donnée via le tableau de clés pathArray.
|
|
55
59
|
* Si extendValues = true, les propriétés des objets parents sont copiées au fur et a mesure de la descente dans la hierarchie, avant l'assignation des propriétés de l'objet lui même.
|
|
56
60
|
*/
|
|
61
|
+
/*eslint-disable @typescript-eslint/no-explicit-any*/
|
|
57
62
|
static traverse(obj, pathArray, extendValues = false) {
|
|
58
|
-
for (
|
|
59
|
-
|
|
63
|
+
for (const key of pathArray) {
|
|
64
|
+
const newObj = obj[key];
|
|
60
65
|
if (newObj === undefined) {
|
|
61
66
|
return undefined;
|
|
62
67
|
}
|
|
@@ -69,10 +74,11 @@ class Objects {
|
|
|
69
74
|
}
|
|
70
75
|
return obj;
|
|
71
76
|
}
|
|
77
|
+
/*eslint-enable @typescript-eslint/no-explicit-any*/
|
|
72
78
|
static getURLSearchArray(sourceObject, prefix = "") {
|
|
73
79
|
let arr = [];
|
|
74
80
|
for (let key in sourceObject) {
|
|
75
|
-
|
|
81
|
+
const value = sourceObject[key];
|
|
76
82
|
if (prefix)
|
|
77
83
|
key = prefix + "[" + key + "]";
|
|
78
84
|
if (Objects.isObject(value)) {
|
|
@@ -1,19 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
/**
|
|
2
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
3
|
+
* Merci de laisser ce fichier sans la moindre dépendance en dehors de types du ceur.
|
|
4
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
5
|
+
* **/
|
|
6
|
+
import { CoreJSType, PublisherContentType } from "../_types/types";
|
|
7
|
+
type DynamicFillingListener = any;
|
|
8
|
+
type TemplateFillingListener = {
|
|
9
|
+
propertyMap: Record<string, string>;
|
|
10
|
+
} & DynamicFillingListener;
|
|
5
11
|
/**
|
|
6
12
|
* Custom Proxy contient les méthodes des publishers retournés par PublisherManager.get(publisherId) qui seront utilisées couramment
|
|
7
13
|
*/
|
|
8
|
-
export declare class PublisherProxy<T
|
|
14
|
+
export declare class PublisherProxy<T = any> {
|
|
9
15
|
_proxies_: Map<string, PublisherProxy>;
|
|
10
16
|
_value_: T;
|
|
11
17
|
_key_: string;
|
|
12
18
|
_invalidateListeners_: Set<VoidFunction>;
|
|
13
19
|
_assignListeners_: Set<(value: T) => void>;
|
|
14
20
|
_mutationListeners_: Set<VoidFunction>;
|
|
15
|
-
_fillListeners_: Set<
|
|
16
|
-
_templateFillListeners_: Set<
|
|
21
|
+
_fillListeners_: Set<Record<string, CoreJSType>>;
|
|
22
|
+
_templateFillListeners_: Set<any>;
|
|
17
23
|
_lockInternalMutationPublishing_: boolean;
|
|
18
24
|
parent: PublisherProxy | null;
|
|
19
25
|
root: PublisherProxy;
|
|
@@ -30,8 +36,8 @@ export declare class PublisherProxy<T extends PublisherContentType = any> {
|
|
|
30
36
|
_publishInternalMutation_(lockInternalMutationsTransmission?: boolean): void;
|
|
31
37
|
_publishAssignement_(lockInternalMutationsTransmission?: boolean): void;
|
|
32
38
|
_publishInvalidation_(): void;
|
|
33
|
-
_publishDynamicFilling_(key: string, value:
|
|
34
|
-
_publishTemplateFilling_(key: string, value:
|
|
39
|
+
_publishDynamicFilling_(key: string, value: CoreJSType): void;
|
|
40
|
+
_publishTemplateFilling_(key: string, value: CoreJSType): void;
|
|
35
41
|
/**
|
|
36
42
|
* Appel la fonction "handler" (passée en paramettre) lorsque la valeur gérée par le proxy change par assignation
|
|
37
43
|
* hanlder reçois alors la nouvelle valeur interne du proxy en paramètre
|
|
@@ -66,17 +72,17 @@ export declare class PublisherProxy<T extends PublisherContentType = any> {
|
|
|
66
72
|
* Maintient le remplissage de l'objet / tableau "handler" passé en paramètre avec les valeurs du proxy
|
|
67
73
|
* Remplit uniquement les valeurs déjà présentes dans l'objet / tableau passé en paramètre
|
|
68
74
|
*/
|
|
69
|
-
startTemplateFilling(handler:
|
|
75
|
+
startTemplateFilling(handler: TemplateFillingListener): void;
|
|
70
76
|
/**
|
|
71
77
|
* Arrête de maintenir le remplissage de l'objet / tableau "handler" passé en paramètre avec les valeurs du proxy
|
|
72
78
|
*/
|
|
73
|
-
stopTemplateFilling(handler:
|
|
79
|
+
stopTemplateFilling(handler: TemplateFillingListener): void;
|
|
74
80
|
/**
|
|
75
81
|
* Maintient le remplissage de l'objet / tableau "handler" passé en paramètre avec les valeurs du proxy
|
|
76
82
|
* Remplit toute valeur qu'elle soit présente ou pas initialement dans l'objet
|
|
77
83
|
*/
|
|
78
|
-
startDynamicFilling(handler:
|
|
79
|
-
stopDynamicFilling(handler:
|
|
84
|
+
startDynamicFilling(handler: DynamicFillingListener): void;
|
|
85
|
+
stopDynamicFilling(handler: DynamicFillingListener): void;
|
|
80
86
|
/**
|
|
81
87
|
* Assigne une nouvelle valeur au proxy ce qui déclenche la transmission de la donnée en fonction des "écouteurs" associés
|
|
82
88
|
*/
|
|
@@ -93,7 +99,7 @@ export declare class PublisherProxy<T extends PublisherContentType = any> {
|
|
|
93
99
|
*/
|
|
94
100
|
export declare class PublisherManager {
|
|
95
101
|
static instance: PublisherManager | null;
|
|
96
|
-
publishers: Map<string, Publisher<
|
|
102
|
+
publishers: Map<string, Publisher<PublisherContentType>>;
|
|
97
103
|
constructor();
|
|
98
104
|
/**
|
|
99
105
|
* PublisherManager est un singleton
|
|
@@ -126,7 +132,7 @@ export declare class PublisherManager {
|
|
|
126
132
|
/**
|
|
127
133
|
* Le Proxy Javascript
|
|
128
134
|
*/
|
|
129
|
-
export default class Publisher<T
|
|
135
|
+
export default class Publisher<T = PublisherContentType> extends PublisherProxy<T> {
|
|
130
136
|
constructor(target: T, parentProxPub?: PublisherProxy | null);
|
|
131
137
|
getProperty<U, K extends keyof U>(o: U, propertyName: K): U[K];
|
|
132
138
|
}
|