@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
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
import { LitElement } from "lit";
|
|
2
|
-
declare const SonicRouter_base: (new (...args: any[]) => import("@supersoniks/concorde/core/mixins/Subscriber").SubscriberInterface) & (new (...args: any[]) => import("@supersoniks/concorde/core/mixins/TemplatesContainer").TemplatesContainerInterface) & typeof LitElement;
|
|
2
|
+
declare const SonicRouter_base: (new (...args: any[]) => import("@supersoniks/concorde/core/mixins/Subscriber").SubscriberInterface<import("../../../_types/types").CoreJSType>) & (new (...args: any[]) => import("@supersoniks/concorde/core/mixins/TemplatesContainer").TemplatesContainerInterface) & typeof LitElement;
|
|
3
|
+
/**
|
|
4
|
+
* ### Le router observe les modification document.location et met à jour sa vu de la manière suivante :
|
|
5
|
+
* * Il boucle sur ses template enfants et test si la regexp contenue dans l'attribut *data-route* match document.location
|
|
6
|
+
* * Si oui le contenu du template est affiché
|
|
7
|
+
* * Si l'attribut dataProviderExpression est fourni le contenu est entouré d'une div :
|
|
8
|
+
* * L'attribut "dataProvider" de cette div est le resultat de l'appel à la fonction replace sur la propriété location avec comme paramettres la regexpe et dataproviderExpression.
|
|
9
|
+
* * On peut également utiliser les des expressions du type url-pattern pour les paramètres de la route voir les exemples
|
|
10
|
+
* * les subscribers/fetch... du template ser réfèrerons à ce dataProvider
|
|
11
|
+
*
|
|
12
|
+
* **Exemples **
|
|
13
|
+
* Avec location = /youpla/utilisateur/2 :
|
|
14
|
+
* * RegExp : data-route = /utilisateur/(\d+) et dataproviderExpression = /user/$1 l'attribut dataProvider vaudra "/user/2"
|
|
15
|
+
* * url-pattern : /*utilisateur/:id et dataproviderExpression = /user/:id l'attribut dataProvider vaudra "/user/2"
|
|
16
|
+
*/
|
|
3
17
|
export declare class SonicRouter extends SonicRouter_base {
|
|
4
18
|
templateValueAttribute: string;
|
|
5
19
|
connectedCallback(): void;
|
|
@@ -12,6 +12,7 @@ import LocationHandler from "@supersoniks/concorde/core/utils/LocationHandler";
|
|
|
12
12
|
import { repeat } from "lit/directives/repeat.js";
|
|
13
13
|
import UrlPattern from "url-pattern";
|
|
14
14
|
import TemplatesContainer from "@supersoniks/concorde/core/mixins/TemplatesContainer";
|
|
15
|
+
const tagName = "sonic-router";
|
|
15
16
|
/**
|
|
16
17
|
* ### Le router observe les modification document.location et met à jour sa vu de la manière suivante :
|
|
17
18
|
* * Il boucle sur ses template enfants et test si la regexp contenue dans l'attribut *data-route* match document.location
|
|
@@ -26,7 +27,6 @@ import TemplatesContainer from "@supersoniks/concorde/core/mixins/TemplatesConta
|
|
|
26
27
|
* * RegExp : data-route = /utilisateur/(\d+) et dataproviderExpression = /user/$1 l'attribut dataProvider vaudra "/user/2"
|
|
27
28
|
* * url-pattern : /*utilisateur/:id et dataproviderExpression = /user/:id l'attribut dataProvider vaudra "/user/2"
|
|
28
29
|
*/
|
|
29
|
-
const tagName = "sonic-router";
|
|
30
30
|
let SonicRouter = class SonicRouter extends Subscriber(TemplatesContainer(LitElement)) {
|
|
31
31
|
constructor() {
|
|
32
32
|
super(...arguments);
|
|
@@ -50,11 +50,11 @@ let SonicRouter = class SonicRouter extends Subscriber(TemplatesContainer(LitEle
|
|
|
50
50
|
return this._location;
|
|
51
51
|
}
|
|
52
52
|
render() {
|
|
53
|
-
|
|
54
|
-
for (
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
53
|
+
const templates = [];
|
|
54
|
+
for (const t of this.templatePartsList) {
|
|
55
|
+
const path = t.getAttribute(this.templateValueAttribute) || "";
|
|
56
|
+
const regexp = new RegExp(path);
|
|
57
|
+
const urlPattern = new UrlPattern(path);
|
|
58
58
|
if (regexp.test(this.location)) {
|
|
59
59
|
templates.push(t);
|
|
60
60
|
}
|
|
@@ -72,17 +72,17 @@ let SonicRouter = class SonicRouter extends Subscriber(TemplatesContainer(LitEle
|
|
|
72
72
|
document.title = template.title;
|
|
73
73
|
if (template.hasAttribute("dataProviderExpression")) {
|
|
74
74
|
let dataProvider = "";
|
|
75
|
-
|
|
75
|
+
const dataProviderExpression = template.getAttribute("dataProviderExpression") || "";
|
|
76
76
|
if (template.getAttribute("mode") == "patternMatching") {
|
|
77
|
-
const matcher = new UrlPattern(template.getAttribute(this.templateValueAttribute));
|
|
77
|
+
const matcher = new UrlPattern(template.getAttribute(this.templateValueAttribute) || "");
|
|
78
78
|
const filler = new UrlPattern(dataProviderExpression);
|
|
79
79
|
dataProvider = filler.stringify(matcher.match(this.location));
|
|
80
80
|
}
|
|
81
81
|
else {
|
|
82
|
-
const regexp = new RegExp(template.getAttribute(this.templateValueAttribute));
|
|
83
|
-
|
|
82
|
+
const regexp = new RegExp(template.getAttribute(this.templateValueAttribute) || "");
|
|
83
|
+
const match = (this.location + "").match(regexp);
|
|
84
84
|
if (match) {
|
|
85
|
-
dataProvider = (_a = match.shift()) === null || _a === void 0 ? void 0 : _a.replace(regexp, dataProviderExpression);
|
|
85
|
+
dataProvider = ((_a = match.shift()) === null || _a === void 0 ? void 0 : _a.replace(regexp, dataProviderExpression)) || "";
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
return html `<div style="display:contents" dataProvider="${dataProvider}">${templateContent(template)}</div>`;
|
|
@@ -98,8 +98,3 @@ SonicRouter = __decorate([
|
|
|
98
98
|
customElement(tagName)
|
|
99
99
|
], SonicRouter);
|
|
100
100
|
export { SonicRouter };
|
|
101
|
-
//Ajout pour la creation du cem notamment pour Storybook
|
|
102
|
-
try {
|
|
103
|
-
customElements.define(tagName, SonicRouter);
|
|
104
|
-
}
|
|
105
|
-
catch (e) { }
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { SDUINode, SDUITransformDescription, SDUITransformAction, SDUITransformList, SDUIDescriptor } from "@supersoniks/concorde/core/components/functional/sdui/types";
|
|
2
2
|
export default class SDUIDescriptorTransformer {
|
|
3
3
|
sduiDescriptor?: SDUIDescriptor;
|
|
4
|
-
constructor();
|
|
5
4
|
/**
|
|
6
5
|
* Tranform un SDUIDescriptor via une SDUITransformDescription
|
|
7
6
|
* Attention fonction non pure : la sduiDescriptor est modifiée en place.
|
|
@@ -32,7 +31,7 @@ export default class SDUIDescriptorTransformer {
|
|
|
32
31
|
/**
|
|
33
32
|
* Pour chaque élément de la liste, remplace l'élément par ses enfants
|
|
34
33
|
*/
|
|
35
|
-
|
|
34
|
+
unwrap(transformAction: SDUITransformAction, list: SDUITransformList): void;
|
|
36
35
|
/**
|
|
37
36
|
* Regroupe tous les éléments de la liste dans l'élément fourni via la prop `ui` de transformAction
|
|
38
37
|
* L'élément créé est inséré en lieu et place du premier élément de la liste
|
|
@@ -8,7 +8,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
export default class SDUIDescriptorTransformer {
|
|
11
|
-
constructor() { }
|
|
12
11
|
/**
|
|
13
12
|
* Tranform un SDUIDescriptor via une SDUITransformDescription
|
|
14
13
|
* Attention fonction non pure : la sduiDescriptor est modifiée en place.
|
|
@@ -21,11 +20,11 @@ export default class SDUIDescriptorTransformer {
|
|
|
21
20
|
return __awaiter(this, void 0, void 0, function* () {
|
|
22
21
|
this.sduiDescriptor = sduiDescriptor;
|
|
23
22
|
if (this.sduiDescriptor.library) {
|
|
24
|
-
for (
|
|
23
|
+
for (const key in transformDescriptor.library) {
|
|
25
24
|
this.sduiDescriptor.library[key] = transformDescriptor.library[key];
|
|
26
25
|
}
|
|
27
26
|
}
|
|
28
|
-
for (
|
|
27
|
+
for (const item of transformDescriptor.transforms) {
|
|
29
28
|
this.transformAction(item);
|
|
30
29
|
}
|
|
31
30
|
});
|
|
@@ -36,7 +35,7 @@ export default class SDUIDescriptorTransformer {
|
|
|
36
35
|
* Voir le détail des actions de transformations dns les fonctions appellées dans le switch.
|
|
37
36
|
*/
|
|
38
37
|
transformAction(transformAction) {
|
|
39
|
-
|
|
38
|
+
const uis = this.getNodesMatchingPatterns(transformAction.patterns, this.sduiDescriptor);
|
|
40
39
|
this[transformAction.action](transformAction, uis);
|
|
41
40
|
}
|
|
42
41
|
/**
|
|
@@ -47,13 +46,13 @@ export default class SDUIDescriptorTransformer {
|
|
|
47
46
|
return [];
|
|
48
47
|
if (!node)
|
|
49
48
|
return [];
|
|
50
|
-
|
|
49
|
+
const nodes = node.nodes;
|
|
51
50
|
if (!nodes)
|
|
52
51
|
return [];
|
|
53
52
|
let result = [];
|
|
54
53
|
let index = 0;
|
|
55
|
-
for (
|
|
56
|
-
for (
|
|
54
|
+
for (const pattern of patterns) {
|
|
55
|
+
for (const child of nodes) {
|
|
57
56
|
if (this.nodeMatchesPattern(pattern, child)) {
|
|
58
57
|
result.push({ parent: node, child: child, index: index });
|
|
59
58
|
}
|
|
@@ -73,21 +72,21 @@ export default class SDUIDescriptorTransformer {
|
|
|
73
72
|
* Return true si le pattern match avec le noeud, false sinon.
|
|
74
73
|
*/
|
|
75
74
|
nodeMatchesPattern(pattern, node) {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
for (
|
|
75
|
+
const patternDynamic = pattern;
|
|
76
|
+
const nodeDynamic = node;
|
|
77
|
+
const keys = ["libraryKey", "innerHTML", "prefix", "suffix", "markup"];
|
|
78
|
+
for (const key of keys) {
|
|
80
79
|
if (!this.stringMatchesExpression(nodeDynamic[key], patternDynamic[key])) {
|
|
81
80
|
return false;
|
|
82
81
|
}
|
|
83
82
|
}
|
|
84
|
-
|
|
85
|
-
|
|
83
|
+
const patternAttributes = pattern.attributes;
|
|
84
|
+
const nodeAttributes = node.attributes;
|
|
86
85
|
if (patternAttributes && !nodeAttributes)
|
|
87
86
|
return false;
|
|
88
87
|
if (patternAttributes) {
|
|
89
|
-
for (
|
|
90
|
-
if (!this.stringMatchesExpression(nodeAttributes[name], patternAttributes[name])) {
|
|
88
|
+
for (const name in patternAttributes) {
|
|
89
|
+
if (!nodeAttributes || !this.stringMatchesExpression(nodeAttributes[name], patternAttributes[name])) {
|
|
91
90
|
return false;
|
|
92
91
|
}
|
|
93
92
|
}
|
|
@@ -97,10 +96,10 @@ export default class SDUIDescriptorTransformer {
|
|
|
97
96
|
/**
|
|
98
97
|
* Pour chaque élément de la liste, remplace l'élément par ses enfants
|
|
99
98
|
*/
|
|
100
|
-
|
|
99
|
+
unwrap(transformAction, list) {
|
|
101
100
|
var _a, _b;
|
|
102
101
|
transformAction;
|
|
103
|
-
for (
|
|
102
|
+
for (const item of list) {
|
|
104
103
|
(_a = item.parent.nodes) === null || _a === void 0 ? void 0 : _a.splice(item.parent.nodes.indexOf(item.child), 1);
|
|
105
104
|
if (item.child.nodes) {
|
|
106
105
|
(_b = item.parent.nodes) === null || _b === void 0 ? void 0 : _b.splice(item.parent.nodes.indexOf(item.child), 0, ...item.child.nodes);
|
|
@@ -112,22 +111,22 @@ export default class SDUIDescriptorTransformer {
|
|
|
112
111
|
* L'élément créé est inséré en lieu et place du premier élément de la liste
|
|
113
112
|
*/
|
|
114
113
|
wrap(transformAction, list) {
|
|
115
|
-
var _a, _b, _c, _d, _e;
|
|
116
|
-
|
|
114
|
+
var _a, _b, _c, _d, _e, _f;
|
|
115
|
+
const wrapper = Object.assign({}, transformAction.ui);
|
|
117
116
|
if (!wrapper.nodes)
|
|
118
117
|
wrapper.nodes = [];
|
|
119
118
|
let i = 0;
|
|
120
|
-
for (
|
|
119
|
+
for (const item of list) {
|
|
121
120
|
(_a = wrapper.nodes) === null || _a === void 0 ? void 0 : _a.push(item.child);
|
|
122
121
|
if (i > 0) {
|
|
123
122
|
(_b = item.parent.nodes) === null || _b === void 0 ? void 0 : _b.splice(item.parent.nodes.indexOf(item.child), 1);
|
|
124
123
|
}
|
|
125
124
|
i++;
|
|
126
125
|
}
|
|
127
|
-
|
|
126
|
+
const idx = (_d = (_c = list[0]) === null || _c === void 0 ? void 0 : _c.parent.nodes) === null || _d === void 0 ? void 0 : _d.indexOf(list[0].child);
|
|
128
127
|
if (idx) {
|
|
129
|
-
(
|
|
130
|
-
(
|
|
128
|
+
(_e = list[0].parent.nodes) === null || _e === void 0 ? void 0 : _e.splice(idx, 1);
|
|
129
|
+
(_f = list[0].parent.nodes) === null || _f === void 0 ? void 0 : _f.splice(idx, 0, wrapper);
|
|
131
130
|
}
|
|
132
131
|
}
|
|
133
132
|
/**
|
|
@@ -135,12 +134,16 @@ export default class SDUIDescriptorTransformer {
|
|
|
135
134
|
*/
|
|
136
135
|
move(transformAction, list) {
|
|
137
136
|
var _a, _b;
|
|
138
|
-
for (
|
|
137
|
+
for (const item of list) {
|
|
139
138
|
(_a = item.parent.nodes) === null || _a === void 0 ? void 0 : _a.splice(item.parent.nodes.indexOf(item.child), 1);
|
|
140
|
-
let
|
|
141
|
-
|
|
139
|
+
let list = [];
|
|
140
|
+
if (transformAction.after)
|
|
141
|
+
list = this.getNodesMatchingPatterns([transformAction.after], this.sduiDescriptor);
|
|
142
|
+
if (transformAction.before)
|
|
143
|
+
list = this.getNodesMatchingPatterns([transformAction.before], this.sduiDescriptor);
|
|
144
|
+
const element = list[0];
|
|
142
145
|
if (element) {
|
|
143
|
-
(_b = element.parent.nodes) === null || _b === void 0 ? void 0 : _b.splice(element.parent.nodes.indexOf(element.child) + (
|
|
146
|
+
(_b = element.parent.nodes) === null || _b === void 0 ? void 0 : _b.splice(element.parent.nodes.indexOf(element.child) + (transformAction.after ? 1 : 0), 0, item.child);
|
|
144
147
|
}
|
|
145
148
|
}
|
|
146
149
|
}
|
|
@@ -150,36 +153,35 @@ export default class SDUIDescriptorTransformer {
|
|
|
150
153
|
*/
|
|
151
154
|
remap(transformAction, list) {
|
|
152
155
|
var _a, _b, _c;
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
let newUI = Object.assign({}, transformAction.ui);
|
|
156
|
+
for (const item of list) {
|
|
157
|
+
const newUI = Object.assign({}, transformAction.ui);
|
|
156
158
|
if (!newUI.attributes) {
|
|
157
159
|
newUI.attributes = {};
|
|
158
160
|
}
|
|
159
|
-
|
|
161
|
+
const childAttributes = item.child.attributes;
|
|
160
162
|
if (childAttributes) {
|
|
161
|
-
for (
|
|
162
|
-
if (!
|
|
163
|
+
for (const key in childAttributes) {
|
|
164
|
+
if (!Object.prototype.hasOwnProperty.call(newUI.attributes, "key"))
|
|
163
165
|
newUI.attributes[key] = childAttributes[key];
|
|
164
166
|
}
|
|
165
167
|
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
for (
|
|
170
|
-
if (!
|
|
168
|
+
const keys = ["libraryKey", "innerHTML", "prefix", "suffix", "markup"];
|
|
169
|
+
const childDynamic = item.child;
|
|
170
|
+
const newUIDynamic = newUI;
|
|
171
|
+
for (const key of keys) {
|
|
172
|
+
if (!Object.prototype.hasOwnProperty.call(newUI, key) && childDynamic[key])
|
|
171
173
|
newUIDynamic[key] = childDynamic[key];
|
|
172
174
|
}
|
|
173
175
|
if (!newUI.nodes) {
|
|
174
176
|
newUI.nodes = [];
|
|
175
177
|
}
|
|
176
|
-
|
|
178
|
+
const childNodes = item.child.nodes;
|
|
177
179
|
if (childNodes) {
|
|
178
|
-
for (
|
|
180
|
+
for (const node of childNodes) {
|
|
179
181
|
newUI.nodes.push(node);
|
|
180
182
|
}
|
|
181
183
|
}
|
|
182
|
-
|
|
184
|
+
const idx = ((_a = item.parent.nodes) === null || _a === void 0 ? void 0 : _a.indexOf(item.child)) || -1;
|
|
183
185
|
if (idx != -1) {
|
|
184
186
|
(_b = item.parent.nodes) === null || _b === void 0 ? void 0 : _b.splice(idx, 1);
|
|
185
187
|
(_c = item.parent.nodes) === null || _c === void 0 ? void 0 : _c.splice(idx, 0, newUI);
|
|
@@ -192,7 +194,7 @@ export default class SDUIDescriptorTransformer {
|
|
|
192
194
|
delete(transformAction, list) {
|
|
193
195
|
var _a;
|
|
194
196
|
transformAction;
|
|
195
|
-
for (
|
|
197
|
+
for (const item of list) {
|
|
196
198
|
(_a = item.parent.nodes) === null || _a === void 0 ? void 0 : _a.splice(item.parent.nodes.indexOf(item.child), 1);
|
|
197
199
|
}
|
|
198
200
|
}
|
|
@@ -202,9 +204,18 @@ export default class SDUIDescriptorTransformer {
|
|
|
202
204
|
*/
|
|
203
205
|
insert(transformAction, list) {
|
|
204
206
|
var _a;
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
207
|
+
const positionType = transformAction.after ? "after" : transformAction.before ? "before" : "in";
|
|
208
|
+
list = [];
|
|
209
|
+
if (transformAction.after) {
|
|
210
|
+
list = this.getNodesMatchingPatterns([transformAction.after], this.sduiDescriptor);
|
|
211
|
+
}
|
|
212
|
+
else if (transformAction.before) {
|
|
213
|
+
list = this.getNodesMatchingPatterns([transformAction.before], this.sduiDescriptor);
|
|
214
|
+
}
|
|
215
|
+
else if (transformAction.in) {
|
|
216
|
+
list = this.getNodesMatchingPatterns([transformAction.in], this.sduiDescriptor);
|
|
217
|
+
}
|
|
218
|
+
const node = list[0];
|
|
208
219
|
if (node) {
|
|
209
220
|
if (positionType == "in") {
|
|
210
221
|
if (!node.child.nodes)
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
{
|
|
2
|
+
"checkbox": {
|
|
3
|
+
"tagName": "sonic-checkbox"
|
|
4
|
+
},
|
|
5
|
+
"date": {
|
|
6
|
+
"tagName": "sonic-input",
|
|
7
|
+
"attributes": {
|
|
8
|
+
"type": "date"
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
"fieldset": {
|
|
12
|
+
"tagName": "sonic-fieldset",
|
|
13
|
+
"nodes": [{ "libraryKey": "formLayout" }],
|
|
14
|
+
"contentElementSelector": "sonic-form-layout"
|
|
15
|
+
},
|
|
16
|
+
"managed_file": {
|
|
17
|
+
"tagName": "sonic-input",
|
|
18
|
+
"attributes": {
|
|
19
|
+
"variant": "ghost",
|
|
20
|
+
"type": "file"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"password": {
|
|
24
|
+
"tagName": "sonic-input",
|
|
25
|
+
"attributes": {
|
|
26
|
+
"type": "password"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"radio": {
|
|
30
|
+
"tagName": "sonic-radio"
|
|
31
|
+
},
|
|
32
|
+
"select": {
|
|
33
|
+
"tagName": "sonic-select"
|
|
34
|
+
},
|
|
35
|
+
"textarea": {
|
|
36
|
+
"tagName": "sonic-textarea"
|
|
37
|
+
},
|
|
38
|
+
"textfield": {
|
|
39
|
+
"tagName": "sonic-input",
|
|
40
|
+
"attributes": {
|
|
41
|
+
"type": "text"
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"hidden": {
|
|
45
|
+
"tagName": "sonic-input",
|
|
46
|
+
"attributes": {
|
|
47
|
+
"type": "hidden"
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"button": {
|
|
51
|
+
"tagName": "sonic-button"
|
|
52
|
+
},
|
|
53
|
+
"form": {
|
|
54
|
+
"tagName": "sonic-submit",
|
|
55
|
+
"attributes": {
|
|
56
|
+
"onEnterKey": true
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
"submit": {
|
|
60
|
+
"tagName": "sonic-submit",
|
|
61
|
+
"attributes": {
|
|
62
|
+
"onClick": true
|
|
63
|
+
},
|
|
64
|
+
"contentElementSelector": "sonic-button",
|
|
65
|
+
"nodes": [
|
|
66
|
+
{
|
|
67
|
+
"libraryKey": "button",
|
|
68
|
+
"attributes": { "type": "success" },
|
|
69
|
+
"nodes": [
|
|
70
|
+
{
|
|
71
|
+
"tagName": "sonic-icon",
|
|
72
|
+
"attributes": {
|
|
73
|
+
"name": "check",
|
|
74
|
+
"slot": "prefix"
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
]
|
|
78
|
+
}
|
|
79
|
+
]
|
|
80
|
+
},
|
|
81
|
+
"email": {
|
|
82
|
+
"tagName": "sonic-input",
|
|
83
|
+
"attributes": {
|
|
84
|
+
"type": "email"
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
"formItemContainer": {
|
|
88
|
+
"tagName": "div",
|
|
89
|
+
"attributes": {
|
|
90
|
+
"class": "form-item-container"
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
"formLayout": {
|
|
94
|
+
"tagName": "sonic-form-layout"
|
|
95
|
+
},
|
|
96
|
+
"formActions": {
|
|
97
|
+
"tagName": "sonic-form-actions"
|
|
98
|
+
},
|
|
99
|
+
"passwordHelper": {
|
|
100
|
+
"tagName": "sonic-password-helper"
|
|
101
|
+
},
|
|
102
|
+
"sameValueHelper": {
|
|
103
|
+
"tagName": "sonic-same-value-helper"
|
|
104
|
+
},
|
|
105
|
+
"divider": {
|
|
106
|
+
"tagName": "sonic-divider"
|
|
107
|
+
}
|
|
108
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
export default class SDUIUtils {
|
|
2
|
+
static toJson(nodes) {
|
|
3
|
+
const desc = {};
|
|
4
|
+
desc.nodes = [];
|
|
5
|
+
for (const node of nodes) {
|
|
6
|
+
const parsedChild = SDUIUtils.parseNode(node);
|
|
7
|
+
if (parsedChild) {
|
|
8
|
+
desc.nodes.push(parsedChild);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
const dataStr = "data:text/json;charset=utf-8," + encodeURIComponent(JSON.stringify(desc, null, 2));
|
|
12
|
+
const dlAnchorElem = document.createElement("a");
|
|
13
|
+
dlAnchorElem.setAttribute("href", dataStr);
|
|
14
|
+
dlAnchorElem.setAttribute("download", "sdui.json");
|
|
15
|
+
document.body.appendChild(dlAnchorElem);
|
|
16
|
+
dlAnchorElem.click();
|
|
17
|
+
dlAnchorElem.remove();
|
|
18
|
+
return JSON.stringify(desc, null, 4);
|
|
19
|
+
}
|
|
20
|
+
static parseNode(node) {
|
|
21
|
+
const sdui = {};
|
|
22
|
+
const nodeType = node.nodeType;
|
|
23
|
+
if (nodeType == Node.ELEMENT_NODE) {
|
|
24
|
+
const name = node.nodeName.toLowerCase();
|
|
25
|
+
sdui.tagName = name;
|
|
26
|
+
const element = node;
|
|
27
|
+
sdui.attributes = {};
|
|
28
|
+
const attributes = element.attributes;
|
|
29
|
+
const attrLength = attributes.length;
|
|
30
|
+
for (let i = 0; i < attrLength; i++) {
|
|
31
|
+
const attribute = attributes.item(i);
|
|
32
|
+
if (attribute)
|
|
33
|
+
sdui.attributes[attribute.name] = attribute.value;
|
|
34
|
+
}
|
|
35
|
+
let childNodes = element.childNodes;
|
|
36
|
+
let children = element.children;
|
|
37
|
+
if (name == "template") {
|
|
38
|
+
const template = node;
|
|
39
|
+
childNodes = template.content.childNodes;
|
|
40
|
+
children = template.content.children;
|
|
41
|
+
}
|
|
42
|
+
if (children.length > 0) {
|
|
43
|
+
sdui.nodes = [];
|
|
44
|
+
for (const ch of childNodes) {
|
|
45
|
+
const parsedChild = SDUIUtils.parseNode(ch);
|
|
46
|
+
if (parsedChild) {
|
|
47
|
+
sdui.nodes.push(parsedChild);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
else if (element.innerHTML) {
|
|
52
|
+
sdui.innerHTML = element.innerHTML;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
if (nodeType == Node.TEXT_NODE) {
|
|
56
|
+
const content = (node.textContent || "").trim();
|
|
57
|
+
if (!content)
|
|
58
|
+
return null;
|
|
59
|
+
sdui.markup = content;
|
|
60
|
+
}
|
|
61
|
+
return sdui;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -1,25 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { LitElement, PropertyValues } from "lit";
|
|
3
3
|
declare const SonicSDUI_base: {
|
|
4
4
|
new (...args: any[]): {
|
|
5
5
|
api: import("../../../utils/api").default | null;
|
|
6
|
-
key:
|
|
6
|
+
key: string;
|
|
7
7
|
isFirstLoad: boolean;
|
|
8
8
|
isLoading: boolean;
|
|
9
9
|
iObserver: IntersectionObserver | null;
|
|
10
10
|
isDefaultLoaderEnabled: boolean;
|
|
11
11
|
isFetchEnabled: boolean;
|
|
12
12
|
_endPoint: string;
|
|
13
|
+
props: (import("../../../_types/types").PublisherContentType & import("../../../utils/api").ResultTypeInterface) | null;
|
|
13
14
|
endPoint: string;
|
|
15
|
+
requestId: number;
|
|
16
|
+
refetchEveryMs: number;
|
|
17
|
+
refetchTimeOutId?: NodeJS.Timeout | undefined;
|
|
14
18
|
_fetchData(): Promise<void>;
|
|
15
|
-
onInvalidate
|
|
19
|
+
onInvalidate?: (() => void) | undefined;
|
|
16
20
|
disconnectedCallback(): void;
|
|
17
21
|
connectedCallback(): void;
|
|
18
22
|
firstUpdated(): void;
|
|
19
23
|
onIntersection(entries: IntersectionObserverEntry[]): void;
|
|
20
|
-
|
|
21
|
-
propertyMap: Object;
|
|
24
|
+
propertyMap: object;
|
|
22
25
|
isConnected: boolean;
|
|
26
|
+
children: HTMLCollection;
|
|
27
|
+
appendChild(node: Node): Node;
|
|
23
28
|
getAncestorAttributeValue(attributeName: string): string;
|
|
24
29
|
hasAncestorAttribute(attributeName: string): boolean;
|
|
25
30
|
querySelectorAll(selector: string): NodeListOf<Element>;
|
|
@@ -29,6 +34,7 @@ declare const SonicSDUI_base: {
|
|
|
29
34
|
debug: HTMLElement | null;
|
|
30
35
|
defferedDebug: boolean | null;
|
|
31
36
|
displayContents: boolean;
|
|
37
|
+
shadowRoot?: ShadowRoot | undefined;
|
|
32
38
|
dispatchEvent(event: Event): void;
|
|
33
39
|
setAttribute(name: string, value: string): void;
|
|
34
40
|
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions | undefined): void;
|
|
@@ -38,9 +44,9 @@ declare const SonicSDUI_base: {
|
|
|
38
44
|
getApiConfiguration(): import("../../../utils/api").APIConfiguration;
|
|
39
45
|
requestUpdate(): void;
|
|
40
46
|
getAttribute(name: string): string;
|
|
41
|
-
hasAttribute(attributeName:
|
|
47
|
+
hasAttribute(attributeName: string): boolean;
|
|
42
48
|
};
|
|
43
|
-
} & (new (...args: any[]) => import("../../../mixins/Subscriber").SubscriberInterface) & typeof LitElement;
|
|
49
|
+
} & (new (...args: any[]) => import("../../../mixins/Subscriber").SubscriberInterface<import("../../../_types/types").CoreJSType>) & typeof LitElement;
|
|
44
50
|
/**
|
|
45
51
|
* ### sonic-sdui (Server Driven User Interface) est un fetcher chargant un JSON décrivant une interface utilisateur
|
|
46
52
|
*
|
|
@@ -60,13 +66,15 @@ declare const SonicSDUI_base: {
|
|
|
60
66
|
*/
|
|
61
67
|
export declare class SonicSDUI extends SonicSDUI_base {
|
|
62
68
|
connectedCallback(): void;
|
|
69
|
+
sduiKey?: string;
|
|
70
|
+
messagesKey?: string;
|
|
71
|
+
private sduiDescriptor;
|
|
63
72
|
/**
|
|
64
73
|
* On peut passer la description sous form de props, sinon il faut utiliser l'attribut fetch
|
|
65
74
|
*/
|
|
66
|
-
|
|
67
|
-
set props(value: SDUIDescriptor);
|
|
75
|
+
willUpdate(changedProperties: PropertyValues): void;
|
|
68
76
|
/**
|
|
69
|
-
* updateContents est déclenché quand les
|
|
77
|
+
* updateContents est déclenché quand les sduiDescriptor sont renseignées
|
|
70
78
|
* Le contenu du composant est regénéré en fonction du descripteur fourni
|
|
71
79
|
*/
|
|
72
80
|
updateContents(): Promise<void>;
|
|
@@ -79,7 +87,7 @@ export declare class SonicSDUI extends SonicSDUI_base {
|
|
|
79
87
|
**/
|
|
80
88
|
private loadAssets;
|
|
81
89
|
/**
|
|
82
|
-
* Transformation de la data fournie via
|
|
90
|
+
* Transformation de la data fournie via sduiDescriptor si il y a un attribut transformation
|
|
83
91
|
* */
|
|
84
92
|
private transformSDUIDescriptor;
|
|
85
93
|
/**
|
|
@@ -95,7 +103,7 @@ export declare class SonicSDUI extends SonicSDUI_base {
|
|
|
95
103
|
*/
|
|
96
104
|
private parseChild;
|
|
97
105
|
/**
|
|
98
|
-
* Si le noeud courant a des propriétés prefix et ou suffix il est entouré des markups fournis dans ces
|
|
106
|
+
* Si le noeud courant a des propriétés prefix et ou suffix il est entouré des markups fournis dans ces sduiDescriptor.
|
|
99
107
|
* Le tout est inclu dans une div en display contents
|
|
100
108
|
*/
|
|
101
109
|
private handlePrefixSuffix;
|