@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
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import Format from "@supersoniks/concorde/core/utils/Format";
|
|
2
2
|
import HTML from "@supersoniks/concorde/core/utils/HTML";
|
|
3
|
-
import { PublisherManager } from "@supersoniks/concorde/core/utils/PublisherProxy
|
|
3
|
+
import { PublisherManager } from "@supersoniks/concorde/core/utils/PublisherProxy";
|
|
4
4
|
/**
|
|
5
|
+
*
|
|
5
6
|
* En appelant DataBindObserver.observe(HTMLElement) sun un élément html, tout les éléments peuvent être liés à au publisher a l'adresse déterminée parl'attribut dataProvider de l'un de ses ancêtres.
|
|
6
7
|
* Pour cela un MutationObserver est créé pour observer les changements d'attributs de l'élément.
|
|
7
8
|
* On peut alors ecrire ce genre de choses de manière a lier dynamiquement les données du publisher à l'élément html.
|
|
@@ -30,7 +31,9 @@ export default class DataBindObserver {
|
|
|
30
31
|
opt.attributes = true;
|
|
31
32
|
opt.attributeFilter = ["data-bind"];
|
|
32
33
|
obs.observe(element, opt);
|
|
33
|
-
element
|
|
34
|
+
element
|
|
35
|
+
.querySelectorAll("[data-bind]")
|
|
36
|
+
.forEach((e) => DataBindObserver.addPublisherListeners(e));
|
|
34
37
|
DataBindObserver.observedElements.set(element, obs);
|
|
35
38
|
}
|
|
36
39
|
/**
|
|
@@ -57,9 +60,7 @@ export default class DataBindObserver {
|
|
|
57
60
|
if (elt.hasAttribute && elt.hasAttribute("data-bind"))
|
|
58
61
|
DataBindObserver.removePublisherListeners(elt);
|
|
59
62
|
if (elt.querySelectorAll)
|
|
60
|
-
elt
|
|
61
|
-
.querySelectorAll("[data-bind]")
|
|
62
|
-
.forEach((e) => DataBindObserver.removePublisherListeners(e));
|
|
63
|
+
elt.querySelectorAll("[data-bind]").forEach((e) => DataBindObserver.removePublisherListeners(e));
|
|
63
64
|
else
|
|
64
65
|
elt.childNodes.forEach((elt) => DataBindObserver.onRemoved(elt));
|
|
65
66
|
}
|
|
@@ -94,7 +95,8 @@ export default class DataBindObserver {
|
|
|
94
95
|
return;
|
|
95
96
|
DataBindObserver.publisherListeners.delete(target);
|
|
96
97
|
conf.forEach((currentConf) => {
|
|
97
|
-
|
|
98
|
+
var _a;
|
|
99
|
+
(_a = currentConf.publisher) === null || _a === void 0 ? void 0 : _a.offAssign(currentConf.onAssign);
|
|
98
100
|
});
|
|
99
101
|
}
|
|
100
102
|
/**
|
|
@@ -128,6 +130,8 @@ export default class DataBindObserver {
|
|
|
128
130
|
* * Propriété "bindedVariablesDescriptor" du DataBindItem : voir la fonction getVariablesDescriptor
|
|
129
131
|
*/
|
|
130
132
|
static getDataBindItems(element) {
|
|
133
|
+
if (!("attributes" in element))
|
|
134
|
+
return [];
|
|
131
135
|
return Array.from(element.attributes)
|
|
132
136
|
.filter((attribute) => attribute.name.indexOf("::") == 0)
|
|
133
137
|
.map((e) => {
|
|
@@ -145,9 +149,13 @@ export default class DataBindObserver {
|
|
|
145
149
|
* Il y a toujours un publisher quelque soit l'adresse ce qui permet de cibler des valeurs qui n'existent pas encore
|
|
146
150
|
*/
|
|
147
151
|
static getSubPublisher(pub, pathArray) {
|
|
152
|
+
if (!pathArray)
|
|
153
|
+
return pub;
|
|
148
154
|
for (let key of pathArray) {
|
|
149
155
|
if (key == "_self_")
|
|
150
156
|
continue;
|
|
157
|
+
if (!pub)
|
|
158
|
+
return null;
|
|
151
159
|
pub = pub[key];
|
|
152
160
|
}
|
|
153
161
|
return pub;
|
|
@@ -161,8 +169,7 @@ export default class DataBindObserver {
|
|
|
161
169
|
/**
|
|
162
170
|
* On récupère le publisher viea le dataProvider d'un ancêtre de l'élément.
|
|
163
171
|
*/
|
|
164
|
-
let
|
|
165
|
-
let dataProviderId = HTML.getAncestorAttributeValue(node.parentNode || node.host || node, "dataProvider");
|
|
172
|
+
let dataProviderId = HTML.getAncestorAttributeValue((target.parentNode || target.host || target), "dataProvider");
|
|
166
173
|
if (!dataProviderId)
|
|
167
174
|
return;
|
|
168
175
|
let publisher = PublisherManager.getInstance().get(dataProviderId);
|
|
@@ -187,7 +194,8 @@ export default class DataBindObserver {
|
|
|
187
194
|
publisher: pub,
|
|
188
195
|
onAssign: () => {
|
|
189
196
|
let values = bindedVariablesDescriptor.variables.map((dataPath) => {
|
|
190
|
-
|
|
197
|
+
var _a;
|
|
198
|
+
return (_a = DataBindObserver.getSubPublisher(publisher, dataPath)) === null || _a === void 0 ? void 0 : _a.get();
|
|
191
199
|
});
|
|
192
200
|
let expression = bindedVariablesDescriptor.expression;
|
|
193
201
|
let hasUndeterminatedValue = false;
|
|
@@ -214,24 +222,12 @@ export default class DataBindObserver {
|
|
|
214
222
|
for (let i = 0; i < values.length; i++) {
|
|
215
223
|
let value = values[i];
|
|
216
224
|
let variable = bindedVariablesDescriptor.variables[i];
|
|
217
|
-
if (value === null
|
|
218
|
-
// Objects.isObject(value) &&
|
|
219
|
-
// value.hasOwnProperty("__value") &&
|
|
220
|
-
// Objects.isUndefindOrNull(value.__value)
|
|
221
|
-
) {
|
|
225
|
+
if (value === null) {
|
|
222
226
|
hasUndeterminatedValue = true;
|
|
223
227
|
value = undefined;
|
|
224
228
|
}
|
|
225
229
|
expression = expression.replace("$" + variable.join("."), value);
|
|
226
230
|
}
|
|
227
|
-
/**
|
|
228
|
-
* Ce bout de code doit être un relicat
|
|
229
|
-
*/
|
|
230
|
-
// if (Objects.isObject(expression) && !expression.hasOwnProperty("__value")) {
|
|
231
|
-
// rec[propertyToUpdate] = expression;
|
|
232
|
-
// return;
|
|
233
|
-
// } else if (Objects.isObject(expression) && !expression.__value) expression = "";
|
|
234
|
-
// else
|
|
235
231
|
if (expression.indexOf("|") != -1) {
|
|
236
232
|
let funcDelimiterIdx = expression.indexOf("|");
|
|
237
233
|
if (funcDelimiterIdx == 0) {
|
|
@@ -240,8 +236,8 @@ export default class DataBindObserver {
|
|
|
240
236
|
else {
|
|
241
237
|
let funcName = expression.substring(0, funcDelimiterIdx);
|
|
242
238
|
let funcArgs = expression.substring(funcDelimiterIdx + 1);
|
|
243
|
-
let
|
|
244
|
-
expression = hasUndeterminatedValue ? "" :
|
|
239
|
+
let fmtFunc = Format[funcName];
|
|
240
|
+
expression = hasUndeterminatedValue ? "" : fmtFunc ? fmtFunc(funcArgs) : expression;
|
|
245
241
|
}
|
|
246
242
|
}
|
|
247
243
|
else {
|
|
@@ -250,7 +246,7 @@ export default class DataBindObserver {
|
|
|
250
246
|
rec[propertyToUpdate] = expression;
|
|
251
247
|
},
|
|
252
248
|
};
|
|
253
|
-
pub.onAssign(currentConf.onAssign);
|
|
249
|
+
pub === null || pub === void 0 ? void 0 : pub.onAssign(currentConf.onAssign);
|
|
254
250
|
conf.push(currentConf);
|
|
255
251
|
}
|
|
256
252
|
});
|
|
@@ -267,6 +263,5 @@ DataBindObserver.observedElements = new Map();
|
|
|
267
263
|
DataBindObserver.enabled = true;
|
|
268
264
|
DataBindObserver.publisherListeners = new Map();
|
|
269
265
|
DataBindObserver.observe(document.documentElement);
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
win.SonicDataBindObserver = DataBindObserver;
|
|
266
|
+
if (!window.SonicDataBindObserver)
|
|
267
|
+
window.SonicDataBindObserver = DataBindObserver;
|
package/core/utils/Electron.d.ts
CHANGED
package/core/utils/Electron.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
export default class Electron {
|
|
2
2
|
static fixBlankLink(link) {
|
|
3
3
|
const electronStr = "electron";
|
|
4
|
-
const electron = typeof require ==
|
|
4
|
+
const electron = typeof require == "undefined" ? null : require(electronStr);
|
|
5
5
|
if (typeof electron && link.target == "_blank") {
|
|
6
|
-
link.addEventListener("click", () => {
|
|
6
|
+
link.addEventListener("click", () => {
|
|
7
|
+
electron === null || electron === void 0 ? void 0 : electron.shell.openExternal(link.href);
|
|
8
|
+
});
|
|
7
9
|
}
|
|
8
10
|
}
|
|
9
11
|
}
|
package/core/utils/HTML.d.ts
CHANGED
|
@@ -1,15 +1,22 @@
|
|
|
1
|
+
export declare type SearchableDomElement = HTMLElement | ShadowRoot;
|
|
1
2
|
declare class HTML {
|
|
2
3
|
/**
|
|
3
4
|
* retourne la langue de la page courante telle que défini via l'attribut lang de la balise html
|
|
4
5
|
*/
|
|
5
6
|
static getLanguage(): string;
|
|
6
|
-
static getCookies():
|
|
7
|
+
static getCookies(): Record<string, string>;
|
|
7
8
|
/**
|
|
8
9
|
* Va de parent en parent en partant de node pour trouver un attribut
|
|
9
10
|
* @param attributeName nom de l'attribut
|
|
10
11
|
* @returns valeur de l'attribut ou null si l'attribut n'est pas trouvé
|
|
11
12
|
*/
|
|
12
|
-
static getAncestorAttributeValue(node:
|
|
13
|
+
static getAncestorAttributeValue(node: SearchableDomElement | null, attributeName: string): string | null;
|
|
14
|
+
/**
|
|
15
|
+
* Va de parent en parent en partant de node pour trouver un attribut
|
|
16
|
+
* @param attributeName nom de l'attribut
|
|
17
|
+
* @returns valeur de l'attribut ou null si l'attribut n'est pas trouvé
|
|
18
|
+
*/
|
|
19
|
+
static getClosestForm(node: SearchableDomElement): SearchableDomElement | null;
|
|
13
20
|
/**
|
|
14
21
|
* Lance le chargement d'un js et retourne une promise qui resoud à true lorsque le chargement à réussi et à false, sinon.
|
|
15
22
|
* */
|
package/core/utils/HTML.js
CHANGED
|
@@ -27,17 +27,36 @@ class HTML {
|
|
|
27
27
|
* @returns valeur de l'attribut ou null si l'attribut n'est pas trouvé
|
|
28
28
|
*/
|
|
29
29
|
static getAncestorAttributeValue(node, attributeName) {
|
|
30
|
-
|
|
30
|
+
if (!node)
|
|
31
|
+
return null;
|
|
32
|
+
while (!("hasAttribute" in node && node.hasAttribute(attributeName))) {
|
|
31
33
|
const newNode = node.parentNode || node.host;
|
|
32
34
|
if (!newNode)
|
|
33
35
|
break;
|
|
34
|
-
node = node.parentNode || node.host;
|
|
36
|
+
node = (node.parentNode || node.host);
|
|
35
37
|
}
|
|
36
|
-
if (!node
|
|
38
|
+
if (!("hasAttribute" in node)) {
|
|
37
39
|
return null;
|
|
38
40
|
}
|
|
39
41
|
return node.getAttribute(attributeName);
|
|
40
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* Va de parent en parent en partant de node pour trouver un attribut
|
|
45
|
+
* @param attributeName nom de l'attribut
|
|
46
|
+
* @returns valeur de l'attribut ou null si l'attribut n'est pas trouvé
|
|
47
|
+
*/
|
|
48
|
+
static getClosestForm(node) {
|
|
49
|
+
while (!(node.nodeName && node.nodeName.toLowerCase() === "form")) {
|
|
50
|
+
const newNode = node.parentNode || node.host;
|
|
51
|
+
if (!newNode)
|
|
52
|
+
break;
|
|
53
|
+
node = (node.parentNode || node.host);
|
|
54
|
+
}
|
|
55
|
+
if (!node.nodeName) {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
return node;
|
|
59
|
+
}
|
|
41
60
|
/**
|
|
42
61
|
* Lance le chargement d'un js et retourne une promise qui resoud à true lorsque le chargement à réussi et à false, sinon.
|
|
43
62
|
* */
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
declare type Listener = {
|
|
2
2
|
location: string;
|
|
3
3
|
};
|
|
4
|
-
declare type ActivableLink = {
|
|
5
|
-
location
|
|
6
|
-
href
|
|
7
|
-
|
|
4
|
+
declare type ActivableLink = HTMLElement & {
|
|
5
|
+
location?: string;
|
|
6
|
+
href?: string;
|
|
7
|
+
goBack?: string | null;
|
|
8
|
+
autoActive?: "strict" | "partial" | "disabled";
|
|
8
9
|
setAttribute(name: string, value: string): void;
|
|
9
10
|
removeAttribute(name: string): void;
|
|
10
11
|
};
|
|
@@ -34,7 +35,7 @@ export default class LocationHandler {
|
|
|
34
35
|
* Si l'attribut replaceState est présent la naviguation se fait via un replaceState
|
|
35
36
|
* Voir link et button pour les exemples d'implémentation
|
|
36
37
|
**/
|
|
37
|
-
static changeFromComponent(component:
|
|
38
|
+
static changeFromComponent(component: ActivableLink): void;
|
|
38
39
|
/**
|
|
39
40
|
*
|
|
40
41
|
* @param component ActivableLink
|
|
@@ -39,6 +39,7 @@ export default class LocationHandler {
|
|
|
39
39
|
LocationHandler.listen();
|
|
40
40
|
}
|
|
41
41
|
LocationHandler.listeners.push(listener);
|
|
42
|
+
listener.location = this.prevURL;
|
|
42
43
|
}
|
|
43
44
|
/**
|
|
44
45
|
*
|
|
@@ -49,24 +50,34 @@ export default class LocationHandler {
|
|
|
49
50
|
* Voir link et button pour les exemples d'implémentation
|
|
50
51
|
**/
|
|
51
52
|
static changeFromComponent(component) {
|
|
52
|
-
|
|
53
|
+
const goBack = component.goBack;
|
|
54
|
+
const referrer = document.referrer;
|
|
55
|
+
if (goBack !== null && goBack !== undefined) {
|
|
53
56
|
const origin = document.location.origin;
|
|
54
|
-
let urlDest =
|
|
55
|
-
|
|
57
|
+
let urlDest = goBack || origin;
|
|
58
|
+
const isHTTP = referrer.indexOf("http") == 0;
|
|
59
|
+
const isNotSameOrigin = isHTTP ? new URL(referrer).origin != origin : false;
|
|
60
|
+
const isReferrerEmpty = referrer == "";
|
|
61
|
+
const isFirstPage = history.length < 3; // imparfait mais variabsle selon les situations
|
|
62
|
+
const isFallbackNoReferer = isReferrerEmpty && isFirstPage; // fallback pour ff qui a parfois un referer nulle ex : drupal 9
|
|
63
|
+
const isNotSameURL = urlDest != document.location.href;
|
|
64
|
+
const goToURLDest = (isNotSameOrigin && isNotSameURL) || isFallbackNoReferer;
|
|
65
|
+
if (goToURLDest) {
|
|
56
66
|
let state = history.state || {};
|
|
57
67
|
state.concorde = state.concorde || {};
|
|
58
|
-
state.concorde.hasDoneHistoryBack = true;
|
|
68
|
+
state.concorde.hasDoneHistoryBack = true;
|
|
59
69
|
history.pushState(state, document.title);
|
|
60
70
|
history.back();
|
|
61
71
|
document.location.replace(urlDest);
|
|
62
72
|
}
|
|
63
|
-
else
|
|
73
|
+
else {
|
|
64
74
|
history.back();
|
|
75
|
+
}
|
|
65
76
|
return;
|
|
66
77
|
}
|
|
67
|
-
let to = component.getAttribute("to");
|
|
78
|
+
let to = component.getAttribute("to") || "";
|
|
68
79
|
if (!to)
|
|
69
|
-
to = component.href;
|
|
80
|
+
to = component.href || "";
|
|
70
81
|
if (!to)
|
|
71
82
|
return;
|
|
72
83
|
if (to.indexOf("#") == 0) {
|
|
@@ -102,7 +113,7 @@ export default class LocationHandler {
|
|
|
102
113
|
return;
|
|
103
114
|
if (component.href && component.href.indexOf("http") != 0) {
|
|
104
115
|
let url1 = new URL(component.href, document.location.href);
|
|
105
|
-
let url2 = new URL(component.location, document.location.origin);
|
|
116
|
+
let url2 = new URL(component.location || "", document.location.origin);
|
|
106
117
|
let isActive = false;
|
|
107
118
|
if (component.autoActive == "strict") {
|
|
108
119
|
isActive = url1.pathname == url2.pathname && url1.hash == url2.hash && url1.search == url2.search;
|
package/core/utils/Objects.d.ts
CHANGED
|
@@ -1,24 +1,27 @@
|
|
|
1
|
+
import { TypeAndRecordOfType } from "../_types/types";
|
|
1
2
|
declare class Objects {
|
|
2
3
|
/**
|
|
3
4
|
* Effectue une comparaison d'égalité non profonde entre deux objets.
|
|
4
5
|
*/
|
|
5
|
-
static shallowEqual(object1: any, object2: any): boolean;
|
|
6
|
+
static shallowEqual(object1: any, object2: any, useStrictComparaison?: boolean): boolean;
|
|
6
7
|
/**
|
|
7
8
|
* Effectue une comparaison d'égalité profonde entre deux objets.
|
|
8
9
|
*/
|
|
9
|
-
static deepEqual(object1: any, object2: any): boolean;
|
|
10
|
+
static deepEqual(object1: any, object2: any, useStrictComparaison?: boolean): boolean;
|
|
10
11
|
/**
|
|
11
12
|
* @returns true si l'objet est un objet ou un tableau (qui est un objet). mais false si null (car sinon typeof null "object")
|
|
12
13
|
*/
|
|
13
|
-
static isObject(object:
|
|
14
|
+
static isObject<T>(object: T): boolean;
|
|
14
15
|
/**
|
|
15
16
|
* @returns true si l'argument est null ou undefined
|
|
16
17
|
*/
|
|
17
|
-
static isUndefindOrNull(object:
|
|
18
|
+
static isUndefindOrNull<T>(object: T): boolean;
|
|
18
19
|
/**
|
|
19
20
|
* traverse l'objet pour obtenir la valeur a l'adresse donnée via le tableau de clés pathArray.
|
|
20
21
|
* 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.
|
|
21
22
|
*/
|
|
22
23
|
static traverse(obj: any, pathArray: string[], extendValues?: boolean): any;
|
|
24
|
+
static getURLSearchArray(sourceObject?: TypeAndRecordOfType<string>, prefix?: string): string[];
|
|
25
|
+
static getURLSearchString(sourceObject: TypeAndRecordOfType<string>): string;
|
|
23
26
|
}
|
|
24
27
|
export default Objects;
|
package/core/utils/Objects.js
CHANGED
|
@@ -2,14 +2,17 @@ class Objects {
|
|
|
2
2
|
/**
|
|
3
3
|
* Effectue une comparaison d'égalité non profonde entre deux objets.
|
|
4
4
|
*/
|
|
5
|
-
static shallowEqual(object1, object2) {
|
|
5
|
+
static shallowEqual(object1, object2, useStrictComparaison = true) {
|
|
6
6
|
const keys1 = Object.keys(object1);
|
|
7
7
|
const keys2 = Object.keys(object2);
|
|
8
|
-
if (keys1.length !== keys2.length) {
|
|
8
|
+
if (keys1.length !== keys2.length && useStrictComparaison) {
|
|
9
9
|
return false;
|
|
10
10
|
}
|
|
11
11
|
for (let key of keys1) {
|
|
12
|
-
|
|
12
|
+
const val1 = object1[key];
|
|
13
|
+
const val2 = object2[key];
|
|
14
|
+
const areEqual = useStrictComparaison ? val1 !== val2 : val1 != val2;
|
|
15
|
+
if (areEqual) {
|
|
13
16
|
return false;
|
|
14
17
|
}
|
|
15
18
|
}
|
|
@@ -18,17 +21,18 @@ class Objects {
|
|
|
18
21
|
/**
|
|
19
22
|
* Effectue une comparaison d'égalité profonde entre deux objets.
|
|
20
23
|
*/
|
|
21
|
-
static deepEqual(object1, object2) {
|
|
24
|
+
static deepEqual(object1, object2, useStrictComparaison = true) {
|
|
22
25
|
const keys1 = Object.keys(object1);
|
|
23
26
|
const keys2 = Object.keys(object2);
|
|
24
|
-
if (keys1.length !== keys2.length) {
|
|
27
|
+
if (keys1.length !== keys2.length && useStrictComparaison) {
|
|
25
28
|
return false;
|
|
26
29
|
}
|
|
27
30
|
for (const key of keys1) {
|
|
28
31
|
const val1 = object1[key];
|
|
29
32
|
const val2 = object2[key];
|
|
30
33
|
const areObjects = Objects.isObject(val1) && Objects.isObject(val2);
|
|
31
|
-
|
|
34
|
+
const areEqual = useStrictComparaison ? val1 !== val2 : val1 != val2;
|
|
35
|
+
if ((areObjects && !Objects.deepEqual(val1, val2)) || (!areObjects && areEqual)) {
|
|
32
36
|
return false;
|
|
33
37
|
}
|
|
34
38
|
}
|
|
@@ -65,5 +69,23 @@ class Objects {
|
|
|
65
69
|
}
|
|
66
70
|
return obj;
|
|
67
71
|
}
|
|
72
|
+
static getURLSearchArray(sourceObject, prefix = "") {
|
|
73
|
+
let arr = [];
|
|
74
|
+
for (let key in sourceObject) {
|
|
75
|
+
let value = sourceObject[key];
|
|
76
|
+
if (prefix)
|
|
77
|
+
key = prefix + "[" + key + "]";
|
|
78
|
+
if (Objects.isObject(value)) {
|
|
79
|
+
arr = [...arr, ...this.getURLSearchArray(value, key)];
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
arr.push(`${key}=${value}`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return arr;
|
|
86
|
+
}
|
|
87
|
+
static getURLSearchString(sourceObject) {
|
|
88
|
+
return Objects.getURLSearchArray(sourceObject, "").join("&");
|
|
89
|
+
}
|
|
68
90
|
}
|
|
69
91
|
export default Objects;
|
|
@@ -1,18 +1,23 @@
|
|
|
1
|
+
declare type CoreJSType = Object | string | number | boolean | BigInt | undefined | null | symbol;
|
|
2
|
+
declare type PublisherContentType = CoreJSType & {
|
|
3
|
+
__value?: any;
|
|
4
|
+
} & Record<string, any>;
|
|
1
5
|
/**
|
|
2
6
|
* Custom Proxy contient les méthodes des publishers retournés par PublisherManager.get(publisherId) qui seront utilisées couramment
|
|
3
7
|
*/
|
|
4
|
-
export class PublisherProxy {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
_invalidateListeners_: Set<
|
|
9
|
-
_assignListeners_: Set<
|
|
10
|
-
_mutationListeners_: Set<
|
|
11
|
-
_fillListeners_: Set<
|
|
12
|
-
_templateFillListeners_: Set<
|
|
8
|
+
export declare class PublisherProxy<T extends PublisherContentType = any> {
|
|
9
|
+
_proxies_: Map<string, PublisherProxy>;
|
|
10
|
+
_value_: T;
|
|
11
|
+
_key_: string;
|
|
12
|
+
_invalidateListeners_: Set<VoidFunction>;
|
|
13
|
+
_assignListeners_: Set<(value: T) => void>;
|
|
14
|
+
_mutationListeners_: Set<VoidFunction>;
|
|
15
|
+
_fillListeners_: Set<unknown>;
|
|
16
|
+
_templateFillListeners_: Set<unknown>;
|
|
13
17
|
_lockInternalMutationPublishing_: boolean;
|
|
14
|
-
parent:
|
|
15
|
-
root:
|
|
18
|
+
parent: PublisherProxy | null;
|
|
19
|
+
root: PublisherProxy;
|
|
20
|
+
constructor(target: T, parentProxPub: PublisherProxy | null);
|
|
16
21
|
/**
|
|
17
22
|
* Supprime le proxy et ses sous proxy
|
|
18
23
|
* Supprime les écouteurs associés
|
|
@@ -25,38 +30,38 @@ export class PublisherProxy {
|
|
|
25
30
|
_publishInternalMutation_(lockInternalMutationsTransmission?: boolean): void;
|
|
26
31
|
_publishAssignement_(lockInternalMutationsTransmission?: boolean): void;
|
|
27
32
|
_publishInvalidation_(): void;
|
|
28
|
-
_publishDynamicFilling_(key:
|
|
29
|
-
_publishTemplateFilling_(key:
|
|
33
|
+
_publishDynamicFilling_(key: string, value: any): void;
|
|
34
|
+
_publishTemplateFilling_(key: string, value: any): void;
|
|
30
35
|
/**
|
|
31
36
|
* Appel la fonction "handler" (passée en paramettre) lorsque la valeur gérée par le proxy change par assignation
|
|
32
37
|
* hanlder reçois alors la nouvelle valeur interne du proxy en paramètre
|
|
33
38
|
*/
|
|
34
|
-
onAssign(handler:
|
|
39
|
+
onAssign(handler: (value: T) => void): void;
|
|
35
40
|
/**
|
|
36
41
|
* Stop les appels de la fonction "handler" (passée en paramettre) lorsque la valeur gérée par le proxy change par assignation
|
|
37
42
|
*/
|
|
38
|
-
offAssign(handler:
|
|
43
|
+
offAssign(handler: (value: T) => void): void;
|
|
39
44
|
/**
|
|
40
45
|
* Appel la fonction "handler" (passée en paramettre) lorsque la donnée est flaggée comme invalide
|
|
41
46
|
*/
|
|
42
|
-
onInvalidate(handler:
|
|
47
|
+
onInvalidate(handler: VoidFunction | undefined): void;
|
|
43
48
|
/**
|
|
44
49
|
* Stop les appels de la fonction "handler" (passée en paramettre) lorsque la donnée est flaggée comme invalide
|
|
45
50
|
*/
|
|
46
|
-
offInvalidate(handler:
|
|
51
|
+
offInvalidate(handler: VoidFunction | undefined): void;
|
|
47
52
|
/**
|
|
48
53
|
* Flag les données comme étant invalides
|
|
49
54
|
*/
|
|
50
|
-
invalidate(
|
|
55
|
+
invalidate(): void;
|
|
51
56
|
/**
|
|
52
57
|
* Appel la fonction "handler" (passée en paramettre) lorsque quelque chose change la valeur gérée par le proxy quelque soit la profondeur de la donnée
|
|
53
58
|
*
|
|
54
59
|
*/
|
|
55
|
-
onInternalMutation(handler:
|
|
60
|
+
onInternalMutation(handler: VoidFunction | undefined): void;
|
|
56
61
|
/**
|
|
57
62
|
* Stop les Appels de la fonction "handler" (passée en paramettre) lorsque quelque chose change la valeur gérée par le proxy quelque soit la profondeur de la donnée
|
|
58
63
|
*/
|
|
59
|
-
offInternalMutation(handler:
|
|
64
|
+
offInternalMutation(handler: VoidFunction | undefined): void;
|
|
60
65
|
/**
|
|
61
66
|
* Maintient le remplissage de l'objet / tableau "handler" passé en paramètre avec les valeurs du proxy
|
|
62
67
|
* Remplit uniquement les valeurs déjà présentes dans l'objet / tableau passé en paramètre
|
|
@@ -75,19 +80,21 @@ export class PublisherProxy {
|
|
|
75
80
|
/**
|
|
76
81
|
* Assigne une nouvelle valeur au proxy ce qui déclenche la transmission de la donnée en fonction des "écouteurs" associés
|
|
77
82
|
*/
|
|
78
|
-
set(newValue:
|
|
83
|
+
set(newValue: T, lockInternalMutationsTransmission?: boolean): boolean;
|
|
79
84
|
/**
|
|
80
85
|
* Extraire la valeur actuelle du proxy
|
|
81
86
|
*/
|
|
82
|
-
get():
|
|
87
|
+
get(): T;
|
|
83
88
|
}
|
|
84
89
|
/**
|
|
85
90
|
* Utilitaires de gestion des Publisher
|
|
86
91
|
* Obtenir, replacer ou supprimer un Publisher
|
|
87
92
|
*
|
|
88
93
|
*/
|
|
89
|
-
export class PublisherManager {
|
|
90
|
-
static instance: null;
|
|
94
|
+
export declare class PublisherManager {
|
|
95
|
+
static instance: PublisherManager | null;
|
|
96
|
+
publishers: Map<string, Publisher<any>>;
|
|
97
|
+
constructor();
|
|
91
98
|
/**
|
|
92
99
|
* PublisherManager est un singleton
|
|
93
100
|
*/
|
|
@@ -96,29 +103,31 @@ export class PublisherManager {
|
|
|
96
103
|
* shortcut static pour obtenir un publisher vias sont id/adresse sans taper getInstance.
|
|
97
104
|
* Si le publisher n'existe pas, il est créé.
|
|
98
105
|
*/
|
|
99
|
-
static get(id:
|
|
106
|
+
static get(id: string): any;
|
|
100
107
|
/**
|
|
101
108
|
* shortcut static pour supprimer un publisher de la liste et appel également delete sur le publisher ce qui le supprime, de même que ses sous publishers
|
|
102
109
|
*/
|
|
103
|
-
static delete(id:
|
|
104
|
-
publishers: Map<any, any>;
|
|
110
|
+
static delete(id: string): boolean;
|
|
105
111
|
/**
|
|
106
112
|
* Obtenir un publisher vias sont id/adresse
|
|
107
113
|
* Si le publisher n'existe pas, il est créé.
|
|
108
114
|
*/
|
|
109
|
-
get(id:
|
|
115
|
+
get(id: string): any;
|
|
110
116
|
/**
|
|
111
117
|
* Remplace un publisher pour l'id fourni par un autre.
|
|
112
118
|
* L'autre publisher n'est pas supprimé.
|
|
113
119
|
*/
|
|
114
|
-
set(id:
|
|
120
|
+
set(id: string, publisher: Publisher): void;
|
|
115
121
|
/**
|
|
116
122
|
* supprimer un publisher de la liste et appel également delete sur le publisher ce qui le supprime, de même que ses sous publishers
|
|
117
123
|
*/
|
|
118
|
-
delete(id:
|
|
124
|
+
delete(id: string): boolean;
|
|
119
125
|
}
|
|
120
126
|
/**
|
|
121
127
|
* Le Proxy Javascript
|
|
122
128
|
*/
|
|
123
|
-
export default class Publisher extends PublisherProxy {
|
|
129
|
+
export default class Publisher<T extends PublisherContentType = any> extends PublisherProxy<T> {
|
|
130
|
+
constructor(target: T, parentProxPub?: PublisherProxy | null);
|
|
131
|
+
getProperty<U, K extends keyof U>(o: U, propertyName: K): U[K];
|
|
124
132
|
}
|
|
133
|
+
export {};
|