@supersoniks/concorde 1.1.42 → 1.1.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components.js +2 -3
- package/concorde-core.bundle.js +37 -35
- package/concorde-core.es.js +5283 -4453
- package/core/_types/types.d.ts +31 -0
- package/core/_types/types.js +2 -0
- package/core/components/functional/date/date.d.ts +13 -5
- package/core/components/functional/date/date.js +57 -38
- package/core/components/functional/example/example.d.ts +1 -1
- package/core/components/functional/example/example.js +1 -1
- package/core/components/functional/fetch/fetch.d.ts +45 -6
- package/core/components/functional/fetch/fetch.js +2 -6
- package/core/components/functional/functional.d.ts +2 -0
- package/core/components/functional/functional.js +2 -0
- package/core/components/functional/if/if.d.ts +3 -0
- package/core/components/functional/if/if.js +6 -12
- package/core/components/functional/if/if.test.d.ts +1 -0
- package/core/components/functional/if/if.test.js +44 -0
- package/core/components/functional/list/list.d.ts +44 -12
- package/core/components/functional/list/list.js +54 -49
- package/core/components/functional/mix/mix.d.ts +22 -0
- package/core/components/functional/mix/mix.js +102 -0
- package/core/components/functional/queue/queue.d.ts +27 -5
- package/core/components/functional/queue/queue.js +88 -26
- package/core/components/functional/router/redirect.d.ts +11 -2
- package/core/components/functional/router/redirect.js +7 -12
- package/core/components/functional/router/router.d.ts +15 -1
- package/core/components/functional/router/router.js +11 -16
- package/core/components/functional/sdui/SDUIDescriptorTransformer.d.ts +1 -2
- package/core/components/functional/sdui/SDUIDescriptorTransformer.js +56 -45
- package/core/components/functional/sdui/default-library.json +108 -0
- package/core/components/functional/sdui/sdui-utils.d.ts +5 -0
- package/core/components/functional/sdui/sdui-utils.js +63 -0
- package/core/components/functional/sdui/sdui.d.ts +21 -13
- package/core/components/functional/sdui/sdui.js +70 -44
- package/core/components/functional/sdui/types.d.ts +10 -8
- package/core/components/functional/states/states.d.ts +20 -4
- package/core/components/functional/states/states.js +15 -20
- package/core/components/functional/submit/submit.d.ts +16 -1
- package/core/components/functional/submit/submit.js +95 -25
- package/core/components/functional/subscriber/subscriber.d.ts +4 -1
- package/core/components/functional/subscriber/subscriber.js +1 -6
- package/core/components/functional/value/value.d.ts +7 -0
- package/core/components/functional/value/value.js +26 -0
- package/core/components/ui/_css/scroll.js +6 -7
- package/core/components/ui/_css/size.d.ts +1 -0
- package/core/components/ui/_css/size.js +3 -1
- package/core/components/ui/alert/alert.d.ts +2 -2
- package/core/components/ui/alert/alert.js +11 -16
- package/core/components/ui/badge/badge.d.ts +3 -1
- package/core/components/ui/badge/badge.js +36 -22
- package/core/components/ui/button/button.d.ts +28 -23
- package/core/components/ui/button/button.js +60 -43
- package/core/components/ui/captcha/captcha.d.ts +14 -2
- package/core/components/ui/captcha/captcha.js +18 -13
- package/core/components/ui/card/card-footer.js +1 -8
- package/core/components/ui/card/card-header-descripton.js +3 -9
- package/core/components/ui/card/card-header.js +6 -7
- package/core/components/ui/card/card-main.js +0 -5
- package/core/components/ui/card/card.d.ts +1 -1
- package/core/components/ui/card/card.js +30 -12
- package/core/components/ui/divider/divider.d.ts +2 -0
- package/core/components/ui/divider/divider.js +43 -16
- package/core/components/ui/form/checkbox/checkbox.d.ts +86 -25
- package/core/components/ui/form/checkbox/checkbox.js +53 -28
- package/core/components/ui/form/css/form-control.d.ts +2 -0
- package/core/components/ui/form/css/form-control.js +145 -67
- package/core/components/ui/form/fieldset/fieldset.d.ts +8 -1
- package/core/components/ui/form/fieldset/fieldset.js +45 -8
- package/core/components/ui/form/fieldset/legend-description.js +0 -5
- package/core/components/ui/form/fieldset/legend.js +3 -6
- package/core/components/ui/form/form-actions/form-actions.d.ts +2 -0
- package/core/components/ui/form/form-actions/form-actions.js +26 -11
- package/core/components/ui/form/form-layout/form-layout.d.ts +5 -2
- package/core/components/ui/form/form-layout/form-layout.js +31 -9
- package/core/components/ui/form/input/input.d.ts +26 -24
- package/core/components/ui/form/input/input.js +87 -52
- package/core/components/ui/form/input/password-helper.d.ts +1 -1
- package/core/components/ui/form/input/password-helper.js +4 -3
- package/core/components/ui/form/input/same-value-helper.d.ts +1 -1
- package/core/components/ui/form/input/same-value-helper.js +3 -2
- package/core/components/ui/form/input-autocomplete/input-autocomplete.d.ts +2 -3
- package/core/components/ui/form/input-autocomplete/input-autocomplete.js +2 -6
- package/core/components/ui/form/radio/radio.d.ts +6 -0
- package/core/components/ui/form/radio/radio.js +7 -12
- package/core/components/ui/form/select/select.d.ts +25 -8
- package/core/components/ui/form/select/select.js +72 -41
- package/core/components/ui/form/textarea/textarea.d.ts +21 -19
- package/core/components/ui/form/textarea/textarea.js +29 -36
- package/core/components/ui/group/group.d.ts +11 -1
- package/core/components/ui/group/group.js +79 -17
- package/core/components/ui/icon/icon.d.ts +10 -3
- package/core/components/ui/icon/icon.js +16 -15
- package/core/components/ui/icon/icons.js +25 -20
- package/core/components/ui/icon/icons.json +1 -1
- package/core/components/ui/image/image.js +0 -5
- package/core/components/ui/link/link.d.ts +1 -1
- package/core/components/ui/link/link.js +2 -6
- package/core/components/ui/loader/loader.d.ts +1 -1
- package/core/components/ui/loader/loader.js +3 -9
- package/core/components/ui/menu/menu-item.js +4 -9
- package/core/components/ui/menu/menu.d.ts +9 -1
- package/core/components/ui/menu/menu.js +182 -27
- package/core/components/ui/modal/modal-actions.js +1 -6
- package/core/components/ui/modal/modal-close.d.ts +1 -0
- package/core/components/ui/modal/modal-close.js +14 -10
- package/core/components/ui/modal/modal-content.js +0 -5
- package/core/components/ui/modal/modal-subtitle.js +2 -6
- package/core/components/ui/modal/modal-title.js +0 -5
- package/core/components/ui/modal/modal.d.ts +7 -7
- package/core/components/ui/modal/modal.js +37 -37
- package/core/components/ui/pop/pop.d.ts +6 -5
- package/core/components/ui/pop/pop.js +57 -57
- package/core/components/ui/progress/progress.js +34 -32
- package/core/components/ui/table/table-caption.js +5 -10
- package/core/components/ui/table/table-tbody.js +10 -14
- package/core/components/ui/table/table-td.d.ts +2 -0
- package/core/components/ui/table/table-td.js +8 -5
- package/core/components/ui/table/table-tfoot.js +5 -7
- package/core/components/ui/table/table-th.d.ts +2 -0
- package/core/components/ui/table/table-th.js +12 -9
- package/core/components/ui/table/table-thead.js +1 -6
- package/core/components/ui/table/table-tr.js +4 -6
- package/core/components/ui/table/table.d.ts +0 -3
- package/core/components/ui/table/table.js +14 -31
- package/core/components/ui/theme/theme-collection/core-variables.js +13 -11
- package/core/components/ui/theme/theme-collection/dark.js +1 -1
- package/core/components/ui/theme/theme.d.ts +1 -6
- package/core/components/ui/theme/theme.js +19 -46
- package/core/components/ui/toast/message-subscriber.d.ts +16 -7
- package/core/components/ui/toast/message-subscriber.js +10 -8
- package/core/components/ui/toast/toast-item.js +1 -1
- package/core/components/ui/toast/toast.d.ts +3 -2
- package/core/components/ui/toast/toast.js +33 -19
- package/core/components/ui/toast/types.d.ts +3 -2
- package/core/components/ui/tooltip/tooltip.d.ts +1 -0
- package/core/components/ui/tooltip/tooltip.js +36 -15
- package/core/components/ui/ui.d.ts +1 -1
- package/core/components/ui/ui.js +1 -4
- package/core/core.js +5 -6
- package/core/mixins/Fetcher.d.ts +20 -13
- package/core/mixins/Fetcher.js +44 -19
- package/core/mixins/FormCheckable.d.ts +25 -13
- package/core/mixins/FormCheckable.js +180 -23
- package/core/mixins/FormElement.d.ts +17 -9
- package/core/mixins/FormElement.js +56 -39
- package/core/mixins/FormInput.d.ts +22 -12
- package/core/mixins/FormInput.js +4 -3
- package/core/mixins/Subscriber.d.ts +12 -8
- package/core/mixins/Subscriber.js +51 -48
- package/core/mixins/TemplatesContainer.d.ts +2 -1
- package/core/mixins/TemplatesContainer.js +2 -2
- package/core/utils/Arrays.d.ts +15 -15
- package/core/utils/Arrays.js +12 -9
- package/core/utils/DataBindObserver.d.ts +18 -11
- package/core/utils/DataBindObserver.js +47 -54
- package/core/utils/Electron.d.ts +5 -1
- package/core/utils/Electron.js +4 -2
- package/core/utils/HTML.d.ts +9 -2
- package/core/utils/HTML.js +24 -5
- package/core/utils/LocationHandler.d.ts +6 -5
- package/core/utils/LocationHandler.js +27 -16
- package/core/utils/Objects.d.ts +7 -4
- package/core/utils/Objects.js +37 -9
- package/core/utils/{PublisherProxy.d.mts → PublisherProxy.d.ts} +49 -34
- package/core/utils/{PublisherProxy.mjs → PublisherProxy.js} +107 -77
- package/core/utils/Utils.d.ts +3 -0
- package/core/utils/Utils.js +18 -0
- package/core/utils/api.d.ts +26 -9
- package/core/utils/api.js +62 -45
- package/img/concorde-logo.svg +1 -0
- package/img/concorde.png +0 -0
- package/img/concorde_def.png +0 -0
- package/mixins.d.ts +53 -29
- package/mixins.js +3 -4
- package/package.json +51 -12
- package/svg/regular/plane.svg +1 -0
- package/svg/solid/plane.svg +1 -0
- package/test-utils/TestUtils.d.ts +4 -0
- package/test-utils/TestUtils.js +12 -0
- package/utils.d.ts +3 -1
- package/utils.js +7 -5
- package/core/components/functional/configuration/configuration.d.ts +0 -5
- package/core/components/functional/configuration/configuration.js +0 -22
- package/core/components/ui/tabs/tab.d.ts +0 -6
- package/core/components/ui/tabs/tab.js +0 -46
- package/core/components/ui/tabs/tabs.d.ts +0 -15
- package/core/components/ui/tabs/tabs.js +0 -129
- package/core/components/ui/taxonomy/taxonomy.d.ts +0 -41
- package/core/components/ui/taxonomy/taxonomy.js +0 -115
package/core/utils/Arrays.d.ts
CHANGED
|
@@ -2,19 +2,19 @@ declare class Arrays {
|
|
|
2
2
|
/**
|
|
3
3
|
* Vérifie si les deux tableaux ont le même contenu
|
|
4
4
|
*/
|
|
5
|
-
static areEqual(array1: Array<
|
|
5
|
+
static areEqual<U>(array1: Array<U>, array2: Array<U>): boolean;
|
|
6
6
|
/**
|
|
7
7
|
* Fournie une fonction to1D qui transforme un tableau 2D en un tableau 1D par concaténation
|
|
8
8
|
*/
|
|
9
|
-
static from2d(source:
|
|
9
|
+
static from2d(source: any): {
|
|
10
10
|
to1D: () => {
|
|
11
11
|
/**Obtenir le tableau final*/
|
|
12
|
-
get: () =>
|
|
12
|
+
get: () => any;
|
|
13
13
|
everyItem: () => {
|
|
14
14
|
has: () => {
|
|
15
15
|
same: () => {
|
|
16
16
|
value: () => {
|
|
17
|
-
forKey: (key: string) =>
|
|
17
|
+
forKey: (key: string) => any;
|
|
18
18
|
};
|
|
19
19
|
};
|
|
20
20
|
};
|
|
@@ -28,10 +28,10 @@ declare class Arrays {
|
|
|
28
28
|
};
|
|
29
29
|
};
|
|
30
30
|
map: (f: (elt: Record<string, any>) => any) => any;
|
|
31
|
-
filter: (f: (elt:
|
|
32
|
-
find: (f: (elt: Record<string, any>) => any) =>
|
|
33
|
-
some: (f: (elt: Record<string, any>) => any) =>
|
|
34
|
-
every: (f: (elt: Record<string, any>) => any) =>
|
|
31
|
+
filter: (f: (elt: any) => any) => any;
|
|
32
|
+
find: (f: (elt: Record<string, any>) => any) => any;
|
|
33
|
+
some: (f: (elt: Record<string, any>) => any) => any;
|
|
34
|
+
every: (f: (elt: Record<string, any>) => any) => any;
|
|
35
35
|
group: () => {
|
|
36
36
|
byKey: (key: string) => any;
|
|
37
37
|
};
|
|
@@ -54,14 +54,14 @@ declare class Arrays {
|
|
|
54
54
|
* puis data.everyItem().has().same().value().forkey("key");
|
|
55
55
|
* Peu mieux faire. ou voir a remplacer un jour par loadHash par exemple.
|
|
56
56
|
**/
|
|
57
|
-
static from(source:
|
|
57
|
+
static from(source: any): {
|
|
58
58
|
/**Obtenir le tableau final*/
|
|
59
|
-
get: () =>
|
|
59
|
+
get: () => any;
|
|
60
60
|
everyItem: () => {
|
|
61
61
|
has: () => {
|
|
62
62
|
same: () => {
|
|
63
63
|
value: () => {
|
|
64
|
-
forKey: (key: string) =>
|
|
64
|
+
forKey: (key: string) => any;
|
|
65
65
|
};
|
|
66
66
|
};
|
|
67
67
|
};
|
|
@@ -75,10 +75,10 @@ declare class Arrays {
|
|
|
75
75
|
};
|
|
76
76
|
};
|
|
77
77
|
map: (f: (elt: Record<string, any>) => any) => any;
|
|
78
|
-
filter: (f: (elt:
|
|
79
|
-
find: (f: (elt: Record<string, any>) => any) =>
|
|
80
|
-
some: (f: (elt: Record<string, any>) => any) =>
|
|
81
|
-
every: (f: (elt: Record<string, any>) => any) =>
|
|
78
|
+
filter: (f: (elt: any) => any) => any;
|
|
79
|
+
find: (f: (elt: Record<string, any>) => any) => any;
|
|
80
|
+
some: (f: (elt: Record<string, any>) => any) => any;
|
|
81
|
+
every: (f: (elt: Record<string, any>) => any) => any;
|
|
82
82
|
group: () => {
|
|
83
83
|
byKey: (key: string) => any;
|
|
84
84
|
};
|
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,12 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { PublisherInterface, PublisherContentType } from "@supersoniks/concorde/core/_types/types";
|
|
2
|
+
import { SearchableDomElement } from "@supersoniks/concorde/core/utils/HTML";
|
|
3
|
+
type BindedVariablesDescriptor = {
|
|
4
|
+
expression: string;
|
|
3
5
|
variables: Array<Array<string>>;
|
|
4
6
|
};
|
|
5
|
-
|
|
7
|
+
type DataBindItem = {
|
|
6
8
|
propertyToUpdate: string;
|
|
7
9
|
bindedVariablesDescriptor: BindedVariablesDescriptor;
|
|
8
10
|
};
|
|
11
|
+
type PublisherListenerConfig<ValueType extends PublisherContentType = PublisherContentType> = {
|
|
12
|
+
publisher: PublisherInterface<ValueType>;
|
|
13
|
+
onAssign: (value?: ValueType) => void;
|
|
14
|
+
};
|
|
9
15
|
/**
|
|
16
|
+
*
|
|
10
17
|
* 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.
|
|
11
18
|
* Pour cela un MutationObserver est créé pour observer les changements d'attributs de l'élément.
|
|
12
19
|
* On peut alors ecrire ce genre de choses de manière a lier dynamiquement les données du publisher à l'élément html.
|
|
@@ -18,28 +25,28 @@ export default class DataBindObserver {
|
|
|
18
25
|
/**
|
|
19
26
|
* Maintient la liste des éléments observés de manière à pouvoir les désinscrire quand ils sont supprimés.
|
|
20
27
|
*/
|
|
21
|
-
static observedElements: Map<
|
|
28
|
+
static observedElements: Map<SearchableDomElement, MutationObserver>;
|
|
22
29
|
/**
|
|
23
30
|
* Commencer à observer un élément html.
|
|
24
31
|
*/
|
|
25
32
|
static enabled: boolean;
|
|
26
33
|
static disable(): void;
|
|
27
|
-
static observe(element:
|
|
34
|
+
static observe(element: SearchableDomElement): void;
|
|
28
35
|
/**
|
|
29
36
|
* Arrêter à observer un élément html.
|
|
30
37
|
*/
|
|
31
|
-
static unObserve(element:
|
|
38
|
+
static unObserve(element: SearchableDomElement): void;
|
|
32
39
|
static onAdded(elt: HTMLElement): void;
|
|
33
40
|
static onRemoved(elt: HTMLElement): void;
|
|
34
41
|
/**
|
|
35
42
|
* Callback appelé par le MutationObserver
|
|
36
43
|
*/
|
|
37
44
|
static onMutation(list: MutationRecord[]): void;
|
|
38
|
-
static publisherListeners: Map<
|
|
45
|
+
static publisherListeners: Map<SearchableDomElement, PublisherListenerConfig[]>;
|
|
39
46
|
/**
|
|
40
47
|
* La liaison avec le publisher supprimée ici.
|
|
41
48
|
*/
|
|
42
|
-
static removePublisherListeners(target:
|
|
49
|
+
static removePublisherListeners(target: SearchableDomElement): void;
|
|
43
50
|
/**
|
|
44
51
|
*
|
|
45
52
|
* Cette fonction prend l'expression fournie et trouves toutes les occurences du type $.clef1.clef2.clef3 ou $a.b par exemple.
|
|
@@ -59,18 +66,18 @@ export default class DataBindObserver {
|
|
|
59
66
|
* Cela représente la propriété à mettre à jour sur l'élément lors de la modification d'une des variables liées dans le publicheur.
|
|
60
67
|
* * Propriété "bindedVariablesDescriptor" du DataBindItem : voir la fonction getVariablesDescriptor
|
|
61
68
|
*/
|
|
62
|
-
static getDataBindItems(element:
|
|
69
|
+
static getDataBindItems(element: SearchableDomElement): DataBindItem[];
|
|
63
70
|
/**
|
|
64
71
|
* Cette fonction récuperer le (sous) publisher a l'adresse donnée.
|
|
65
72
|
* Si l'une des clef de l'adresse est _self_, on garde le publisher courant et on passe à la suite.
|
|
66
73
|
* Ceci est un cas spécial, c'est pour ça qu'on utilisa pes Objects.traverse.
|
|
67
74
|
* Il y a toujours un publisher quelque soit l'adresse ce qui permet de cibler des valeurs qui n'existent pas encore
|
|
68
75
|
*/
|
|
69
|
-
static getSubPublisher(pub:
|
|
76
|
+
static getSubPublisher<T extends PublisherContentType>(pub: PublisherInterface<T>, pathArray?: string[]): PublisherInterface;
|
|
70
77
|
/**
|
|
71
78
|
* La liaison avec le publisher est faite ici.
|
|
72
79
|
* TODO Sans doute factoriser
|
|
73
80
|
*/
|
|
74
|
-
static addPublisherListeners(target:
|
|
81
|
+
static addPublisherListeners(target: SearchableDomElement): void;
|
|
75
82
|
}
|
|
76
83
|
export {};
|
|
@@ -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.
|
|
@@ -23,14 +24,16 @@ export default class DataBindObserver {
|
|
|
23
24
|
return;
|
|
24
25
|
if (DataBindObserver.observedElements.has(element))
|
|
25
26
|
return;
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
const obs = new MutationObserver(DataBindObserver.onMutation);
|
|
28
|
+
const opt = {};
|
|
28
29
|
opt.childList = true;
|
|
29
30
|
opt.subtree = true;
|
|
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
|
/**
|
|
@@ -39,7 +42,7 @@ export default class DataBindObserver {
|
|
|
39
42
|
static unObserve(element) {
|
|
40
43
|
if (!element)
|
|
41
44
|
return;
|
|
42
|
-
|
|
45
|
+
const observer = this.observedElements.get(element);
|
|
43
46
|
if (!observer)
|
|
44
47
|
return;
|
|
45
48
|
observer.disconnect();
|
|
@@ -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
|
}
|
|
@@ -67,18 +68,16 @@ export default class DataBindObserver {
|
|
|
67
68
|
* Callback appelé par le MutationObserver
|
|
68
69
|
*/
|
|
69
70
|
static onMutation(list) {
|
|
70
|
-
for (
|
|
71
|
+
for (const l of list) {
|
|
71
72
|
switch (l.type) {
|
|
72
73
|
case "attributes":
|
|
73
74
|
DataBindObserver.addPublisherListeners(l.target);
|
|
74
75
|
break;
|
|
75
76
|
case "childList":
|
|
76
|
-
|
|
77
|
-
var removed = l.removedNodes;
|
|
78
|
-
added.forEach((elt) => {
|
|
77
|
+
l.addedNodes.forEach((elt) => {
|
|
79
78
|
DataBindObserver.onAdded(elt);
|
|
80
79
|
});
|
|
81
|
-
|
|
80
|
+
l.removedNodes.forEach((elt) => {
|
|
82
81
|
DataBindObserver.onRemoved(elt);
|
|
83
82
|
});
|
|
84
83
|
break;
|
|
@@ -89,12 +88,13 @@ export default class DataBindObserver {
|
|
|
89
88
|
* La liaison avec le publisher supprimée ici.
|
|
90
89
|
*/
|
|
91
90
|
static removePublisherListeners(target) {
|
|
92
|
-
|
|
91
|
+
const conf = DataBindObserver.publisherListeners.get(target);
|
|
93
92
|
if (!conf)
|
|
94
93
|
return;
|
|
95
94
|
DataBindObserver.publisherListeners.delete(target);
|
|
96
95
|
conf.forEach((currentConf) => {
|
|
97
|
-
|
|
96
|
+
var _a;
|
|
97
|
+
(_a = currentConf.publisher) === null || _a === void 0 ? void 0 : _a.offAssign(currentConf.onAssign);
|
|
98
98
|
});
|
|
99
99
|
}
|
|
100
100
|
/**
|
|
@@ -128,12 +128,14 @@ export default class DataBindObserver {
|
|
|
128
128
|
* * Propriété "bindedVariablesDescriptor" du DataBindItem : voir la fonction getVariablesDescriptor
|
|
129
129
|
*/
|
|
130
130
|
static getDataBindItems(element) {
|
|
131
|
+
if (!("attributes" in element))
|
|
132
|
+
return [];
|
|
131
133
|
return Array.from(element.attributes)
|
|
132
134
|
.filter((attribute) => attribute.name.indexOf("::") == 0)
|
|
133
135
|
.map((e) => {
|
|
134
|
-
|
|
136
|
+
const name = e.name.substring(2);
|
|
135
137
|
return {
|
|
136
|
-
propertyToUpdate: name.replace(
|
|
138
|
+
propertyToUpdate: name.replace(/-((html)|\w)/g, (match) => match.substring(1).toUpperCase()),
|
|
137
139
|
bindedVariablesDescriptor: DataBindObserver.getVariablesDescriptor(e.value),
|
|
138
140
|
};
|
|
139
141
|
});
|
|
@@ -145,9 +147,13 @@ export default class DataBindObserver {
|
|
|
145
147
|
* Il y a toujours un publisher quelque soit l'adresse ce qui permet de cibler des valeurs qui n'existent pas encore
|
|
146
148
|
*/
|
|
147
149
|
static getSubPublisher(pub, pathArray) {
|
|
148
|
-
|
|
150
|
+
if (!pathArray)
|
|
151
|
+
return pub;
|
|
152
|
+
for (const key of pathArray) {
|
|
149
153
|
if (key == "_self_")
|
|
150
154
|
continue;
|
|
155
|
+
if (!pub)
|
|
156
|
+
return null;
|
|
151
157
|
pub = pub[key];
|
|
152
158
|
}
|
|
153
159
|
return pub;
|
|
@@ -161,13 +167,12 @@ export default class DataBindObserver {
|
|
|
161
167
|
/**
|
|
162
168
|
* On récupère le publisher viea le dataProvider d'un ancêtre de l'élément.
|
|
163
169
|
*/
|
|
164
|
-
|
|
165
|
-
let dataProviderId = HTML.getAncestorAttributeValue(node.parentNode || node.host || node, "dataProvider");
|
|
170
|
+
const dataProviderId = HTML.getAncestorAttributeValue((target.parentNode || target.host || target), "dataProvider");
|
|
166
171
|
if (!dataProviderId)
|
|
167
172
|
return;
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
173
|
+
const publisher = PublisherManager.getInstance().get(dataProviderId);
|
|
174
|
+
const dataBindItems = DataBindObserver.getDataBindItems(target);
|
|
175
|
+
const conf = [];
|
|
171
176
|
/**
|
|
172
177
|
* Pour chaque attribut => dataBindItems on fait la liaison avec les (sous) publishers associés aux variables extraites
|
|
173
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".
|
|
@@ -176,18 +181,19 @@ export default class DataBindObserver {
|
|
|
176
181
|
* Attentions, les Objets/tableaus sont rendus en chaine avant l'interprétation dans ce cas.
|
|
177
182
|
*/
|
|
178
183
|
dataBindItems.forEach((dataBindItem) => {
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
for (
|
|
182
|
-
|
|
184
|
+
const bindedVariablesDescriptor = dataBindItem.bindedVariablesDescriptor;
|
|
185
|
+
const propertyToUpdate = dataBindItem.propertyToUpdate;
|
|
186
|
+
for (const value of bindedVariablesDescriptor.variables) {
|
|
187
|
+
const publisherPathArray = value;
|
|
183
188
|
let pub = publisher;
|
|
184
189
|
pub = DataBindObserver.getSubPublisher(publisher, publisherPathArray);
|
|
185
|
-
|
|
186
|
-
|
|
190
|
+
const rec = target;
|
|
191
|
+
const currentConf = {
|
|
187
192
|
publisher: pub,
|
|
188
193
|
onAssign: () => {
|
|
189
|
-
|
|
190
|
-
|
|
194
|
+
const values = bindedVariablesDescriptor.variables.map((dataPath) => {
|
|
195
|
+
var _a;
|
|
196
|
+
return (_a = DataBindObserver.getSubPublisher(publisher, dataPath)) === null || _a === void 0 ? void 0 : _a.get();
|
|
191
197
|
});
|
|
192
198
|
let expression = bindedVariablesDescriptor.expression;
|
|
193
199
|
let hasUndeterminatedValue = false;
|
|
@@ -213,35 +219,23 @@ export default class DataBindObserver {
|
|
|
213
219
|
*/
|
|
214
220
|
for (let i = 0; i < values.length; i++) {
|
|
215
221
|
let value = values[i];
|
|
216
|
-
|
|
217
|
-
if (value === null
|
|
218
|
-
// Objects.isObject(value) &&
|
|
219
|
-
// value.hasOwnProperty("__value") &&
|
|
220
|
-
// Objects.isUndefindOrNull(value.__value)
|
|
221
|
-
) {
|
|
222
|
+
const variable = bindedVariablesDescriptor.variables[i];
|
|
223
|
+
if (value === null) {
|
|
222
224
|
hasUndeterminatedValue = true;
|
|
223
225
|
value = undefined;
|
|
224
226
|
}
|
|
225
227
|
expression = expression.replace("$" + variable.join("."), value);
|
|
226
228
|
}
|
|
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
229
|
if (expression.indexOf("|") != -1) {
|
|
236
|
-
|
|
230
|
+
const funcDelimiterIdx = expression.indexOf("|");
|
|
237
231
|
if (funcDelimiterIdx == 0) {
|
|
238
232
|
expression = Format.js(expression.substring(1));
|
|
239
233
|
}
|
|
240
234
|
else {
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
expression = hasUndeterminatedValue ? "" :
|
|
235
|
+
const funcName = expression.substring(0, funcDelimiterIdx);
|
|
236
|
+
const funcArgs = expression.substring(funcDelimiterIdx + 1);
|
|
237
|
+
const fmtFunc = Format[funcName];
|
|
238
|
+
expression = hasUndeterminatedValue ? "" : fmtFunc ? fmtFunc(funcArgs) : expression;
|
|
245
239
|
}
|
|
246
240
|
}
|
|
247
241
|
else {
|
|
@@ -250,7 +244,7 @@ export default class DataBindObserver {
|
|
|
250
244
|
rec[propertyToUpdate] = expression;
|
|
251
245
|
},
|
|
252
246
|
};
|
|
253
|
-
pub.onAssign(currentConf.onAssign);
|
|
247
|
+
pub === null || pub === void 0 ? void 0 : pub.onAssign(currentConf.onAssign);
|
|
254
248
|
conf.push(currentConf);
|
|
255
249
|
}
|
|
256
250
|
});
|
|
@@ -267,6 +261,5 @@ DataBindObserver.observedElements = new Map();
|
|
|
267
261
|
DataBindObserver.enabled = true;
|
|
268
262
|
DataBindObserver.publisherListeners = new Map();
|
|
269
263
|
DataBindObserver.observe(document.documentElement);
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
win.SonicDataBindObserver = DataBindObserver;
|
|
264
|
+
if (!window.SonicDataBindObserver)
|
|
265
|
+
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 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,24 +27,43 @@ 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
|
* */
|
|
44
63
|
static loadJS(src) {
|
|
45
64
|
return __awaiter(this, void 0, void 0, function* () {
|
|
46
65
|
const p = new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
|
|
47
|
-
|
|
66
|
+
const script = document.createElement("script");
|
|
48
67
|
script.src = src;
|
|
49
68
|
script.onload = () => resolve(true);
|
|
50
69
|
script.onerror = () => resolve(true);
|
|
@@ -59,7 +78,7 @@ class HTML {
|
|
|
59
78
|
static loadCSS(src) {
|
|
60
79
|
return __awaiter(this, void 0, void 0, function* () {
|
|
61
80
|
const p = new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
|
|
62
|
-
|
|
81
|
+
const cssnode = document.createElement("link");
|
|
63
82
|
cssnode.type = "text/css";
|
|
64
83
|
cssnode.rel = "stylesheet";
|
|
65
84
|
cssnode.href = src;
|
|
@@ -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
|