@supersoniks/concorde 1.1.43 → 1.1.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/concorde-core.bundle.js +18 -18
- package/concorde-core.es.js +805 -739
- package/core/_types/types.d.ts +13 -8
- package/core/_types/types.js +1 -0
- package/core/components/functional/date/date.d.ts +2 -2
- package/core/components/functional/date/date.js +10 -10
- package/core/components/functional/example/example.d.ts +1 -1
- package/core/components/functional/fetch/fetch.d.ts +8 -6
- package/core/components/functional/list/list.d.ts +16 -8
- package/core/components/functional/list/list.js +25 -13
- package/core/components/functional/mix/mix.d.ts +5 -5
- package/core/components/functional/mix/mix.js +11 -8
- package/core/components/functional/queue/queue.d.ts +12 -3
- package/core/components/functional/queue/queue.js +28 -22
- package/core/components/functional/router/redirect.d.ts +2 -2
- package/core/components/functional/router/redirect.js +2 -6
- package/core/components/functional/router/router.d.ts +1 -1
- package/core/components/functional/router/router.js +10 -10
- package/core/components/functional/sdui/SDUIDescriptorTransformer.d.ts +0 -1
- package/core/components/functional/sdui/SDUIDescriptorTransformer.js +35 -36
- package/core/components/functional/sdui/sdui-utils.js +11 -11
- package/core/components/functional/sdui/sdui.d.ts +10 -9
- package/core/components/functional/sdui/sdui.js +32 -33
- package/core/components/functional/sdui/types.d.ts +8 -8
- package/core/components/functional/states/states.d.ts +3 -3
- package/core/components/functional/states/states.js +8 -8
- package/core/components/functional/submit/submit.d.ts +1 -1
- package/core/components/functional/submit/submit.js +16 -16
- package/core/components/functional/subscriber/subscriber.d.ts +1 -1
- package/core/components/functional/value/value.d.ts +1 -1
- package/core/components/ui/_css/size.d.ts +1 -1
- package/core/components/ui/button/button.d.ts +6 -4
- package/core/components/ui/button/button.js +2 -2
- package/core/components/ui/captcha/captcha.d.ts +2 -2
- package/core/components/ui/captcha/captcha.js +2 -2
- package/core/components/ui/card/card-header.js +5 -1
- package/core/components/ui/card/card.js +7 -5
- package/core/components/ui/form/checkbox/checkbox.d.ts +36 -12
- package/core/components/ui/form/fieldset/fieldset.d.ts +1 -1
- package/core/components/ui/form/form-layout/form-layout.d.ts +1 -1
- package/core/components/ui/form/input/input.d.ts +14 -9
- package/core/components/ui/form/input/input.js +2 -2
- package/core/components/ui/form/input/password-helper.d.ts +1 -1
- package/core/components/ui/form/input/password-helper.js +1 -1
- package/core/components/ui/form/input/same-value-helper.d.ts +1 -1
- package/core/components/ui/form/input/same-value-helper.js +2 -2
- package/core/components/ui/form/input-autocomplete/input-autocomplete.d.ts +1 -1
- package/core/components/ui/form/select/select.d.ts +5 -4
- package/core/components/ui/form/select/select.js +8 -8
- package/core/components/ui/form/textarea/textarea.d.ts +11 -9
- package/core/components/ui/form/textarea/textarea.js +1 -1
- package/core/components/ui/group/group.js +1 -1
- package/core/components/ui/icon/icons.js +15 -13
- package/core/components/ui/loader/loader.d.ts +1 -1
- package/core/components/ui/loader/loader.js +1 -1
- package/core/components/ui/menu/menu.js +15 -16
- package/core/components/ui/modal/modal.d.ts +1 -1
- package/core/components/ui/modal/modal.js +1 -1
- package/core/components/ui/pop/pop.d.ts +1 -1
- package/core/components/ui/pop/pop.js +13 -13
- package/core/components/ui/table/table-tbody.js +1 -1
- package/core/components/ui/theme/theme.js +15 -13
- package/core/components/ui/toast/message-subscriber.d.ts +12 -9
- package/core/components/ui/toast/message-subscriber.js +10 -8
- package/core/components/ui/toast/toast.d.ts +1 -1
- package/core/components/ui/toast/toast.js +7 -8
- package/core/components/ui/toast/types.d.ts +3 -2
- package/core/components/ui/tooltip/tooltip.js +1 -1
- package/core/components/ui/ui.d.ts +1 -1
- package/core/components/ui/ui.js +1 -1
- package/core/mixins/Fetcher.d.ts +15 -17
- package/core/mixins/Fetcher.js +19 -10
- package/core/mixins/FormCheckable.d.ts +8 -5
- package/core/mixins/FormCheckable.js +21 -19
- package/core/mixins/FormElement.d.ts +10 -7
- package/core/mixins/FormElement.js +24 -23
- package/core/mixins/FormInput.d.ts +16 -10
- package/core/mixins/FormInput.js +1 -1
- package/core/mixins/Subscriber.d.ts +8 -6
- package/core/mixins/Subscriber.js +19 -18
- package/core/mixins/TemplatesContainer.d.ts +2 -1
- package/core/mixins/TemplatesContainer.js +2 -2
- package/core/utils/Arrays.js +12 -9
- package/core/utils/DataBindObserver.d.ts +4 -4
- package/core/utils/DataBindObserver.js +26 -28
- package/core/utils/HTML.d.ts +1 -1
- package/core/utils/HTML.js +2 -2
- package/core/utils/LocationHandler.js +10 -10
- package/core/utils/Objects.js +10 -4
- package/core/utils/PublisherProxy.d.ts +21 -15
- package/core/utils/PublisherProxy.js +67 -63
- package/core/utils/api.d.ts +16 -31
- package/core/utils/api.js +26 -22
- package/mixins.d.ts +25 -19
- package/package.json +9 -5
- package/core/components/ui/taxonomy/taxonomy.d.ts +0 -44
- package/core/components/ui/taxonomy/taxonomy.js +0 -115
|
@@ -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.
|
|
@@ -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,20 +72,20 @@ 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 (
|
|
88
|
+
for (const name in patternAttributes) {
|
|
90
89
|
if (!nodeAttributes || !this.stringMatchesExpression(nodeAttributes[name], patternAttributes[name])) {
|
|
91
90
|
return false;
|
|
92
91
|
}
|
|
@@ -100,7 +99,7 @@ export default class SDUIDescriptorTransformer {
|
|
|
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);
|
|
@@ -113,18 +112,18 @@ export default class SDUIDescriptorTransformer {
|
|
|
113
112
|
*/
|
|
114
113
|
wrap(transformAction, list) {
|
|
115
114
|
var _a, _b, _c, _d, _e, _f;
|
|
116
|
-
|
|
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
128
|
(_e = list[0].parent.nodes) === null || _e === void 0 ? void 0 : _e.splice(idx, 1);
|
|
130
129
|
(_f = list[0].parent.nodes) === null || _f === void 0 ? void 0 : _f.splice(idx, 0, wrapper);
|
|
@@ -135,14 +134,14 @@ 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
139
|
let list = [];
|
|
141
140
|
if (transformAction.after)
|
|
142
141
|
list = this.getNodesMatchingPatterns([transformAction.after], this.sduiDescriptor);
|
|
143
142
|
if (transformAction.before)
|
|
144
143
|
list = this.getNodesMatchingPatterns([transformAction.before], this.sduiDescriptor);
|
|
145
|
-
|
|
144
|
+
const element = list[0];
|
|
146
145
|
if (element) {
|
|
147
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);
|
|
148
147
|
}
|
|
@@ -154,35 +153,35 @@ export default class SDUIDescriptorTransformer {
|
|
|
154
153
|
*/
|
|
155
154
|
remap(transformAction, list) {
|
|
156
155
|
var _a, _b, _c;
|
|
157
|
-
for (
|
|
158
|
-
|
|
156
|
+
for (const item of list) {
|
|
157
|
+
const newUI = Object.assign({}, transformAction.ui);
|
|
159
158
|
if (!newUI.attributes) {
|
|
160
159
|
newUI.attributes = {};
|
|
161
160
|
}
|
|
162
|
-
|
|
161
|
+
const childAttributes = item.child.attributes;
|
|
163
162
|
if (childAttributes) {
|
|
164
|
-
for (
|
|
165
|
-
if (!
|
|
163
|
+
for (const key in childAttributes) {
|
|
164
|
+
if (!Object.prototype.hasOwnProperty.call(newUI.attributes, "key"))
|
|
166
165
|
newUI.attributes[key] = childAttributes[key];
|
|
167
166
|
}
|
|
168
167
|
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
for (
|
|
173
|
-
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])
|
|
174
173
|
newUIDynamic[key] = childDynamic[key];
|
|
175
174
|
}
|
|
176
175
|
if (!newUI.nodes) {
|
|
177
176
|
newUI.nodes = [];
|
|
178
177
|
}
|
|
179
|
-
|
|
178
|
+
const childNodes = item.child.nodes;
|
|
180
179
|
if (childNodes) {
|
|
181
|
-
for (
|
|
180
|
+
for (const node of childNodes) {
|
|
182
181
|
newUI.nodes.push(node);
|
|
183
182
|
}
|
|
184
183
|
}
|
|
185
|
-
|
|
184
|
+
const idx = ((_a = item.parent.nodes) === null || _a === void 0 ? void 0 : _a.indexOf(item.child)) || -1;
|
|
186
185
|
if (idx != -1) {
|
|
187
186
|
(_b = item.parent.nodes) === null || _b === void 0 ? void 0 : _b.splice(idx, 1);
|
|
188
187
|
(_c = item.parent.nodes) === null || _c === void 0 ? void 0 : _c.splice(idx, 0, newUI);
|
|
@@ -195,7 +194,7 @@ export default class SDUIDescriptorTransformer {
|
|
|
195
194
|
delete(transformAction, list) {
|
|
196
195
|
var _a;
|
|
197
196
|
transformAction;
|
|
198
|
-
for (
|
|
197
|
+
for (const item of list) {
|
|
199
198
|
(_a = item.parent.nodes) === null || _a === void 0 ? void 0 : _a.splice(item.parent.nodes.indexOf(item.child), 1);
|
|
200
199
|
}
|
|
201
200
|
}
|
|
@@ -205,7 +204,7 @@ export default class SDUIDescriptorTransformer {
|
|
|
205
204
|
*/
|
|
206
205
|
insert(transformAction, list) {
|
|
207
206
|
var _a;
|
|
208
|
-
|
|
207
|
+
const positionType = transformAction.after ? "after" : transformAction.before ? "before" : "in";
|
|
209
208
|
list = [];
|
|
210
209
|
if (transformAction.after) {
|
|
211
210
|
list = this.getNodesMatchingPatterns([transformAction.after], this.sduiDescriptor);
|
|
@@ -216,7 +215,7 @@ export default class SDUIDescriptorTransformer {
|
|
|
216
215
|
else if (transformAction.in) {
|
|
217
216
|
list = this.getNodesMatchingPatterns([transformAction.in], this.sduiDescriptor);
|
|
218
217
|
}
|
|
219
|
-
|
|
218
|
+
const node = list[0];
|
|
220
219
|
if (node) {
|
|
221
220
|
if (positionType == "in") {
|
|
222
221
|
if (!node.child.nodes)
|
|
@@ -2,14 +2,14 @@ export default class SDUIUtils {
|
|
|
2
2
|
static toJson(nodes) {
|
|
3
3
|
const desc = {};
|
|
4
4
|
desc.nodes = [];
|
|
5
|
-
for (
|
|
5
|
+
for (const node of nodes) {
|
|
6
6
|
const parsedChild = SDUIUtils.parseNode(node);
|
|
7
7
|
if (parsedChild) {
|
|
8
8
|
desc.nodes.push(parsedChild);
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
const dataStr = "data:text/json;charset=utf-8," + encodeURIComponent(JSON.stringify(desc, null, 2));
|
|
12
|
+
const dlAnchorElem = document.createElement("a");
|
|
13
13
|
dlAnchorElem.setAttribute("href", dataStr);
|
|
14
14
|
dlAnchorElem.setAttribute("download", "sdui.json");
|
|
15
15
|
document.body.appendChild(dlAnchorElem);
|
|
@@ -18,30 +18,30 @@ export default class SDUIUtils {
|
|
|
18
18
|
return JSON.stringify(desc, null, 4);
|
|
19
19
|
}
|
|
20
20
|
static parseNode(node) {
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
const sdui = {};
|
|
22
|
+
const nodeType = node.nodeType;
|
|
23
23
|
if (nodeType == Node.ELEMENT_NODE) {
|
|
24
|
-
|
|
24
|
+
const name = node.nodeName.toLowerCase();
|
|
25
25
|
sdui.tagName = name;
|
|
26
|
-
|
|
26
|
+
const element = node;
|
|
27
27
|
sdui.attributes = {};
|
|
28
28
|
const attributes = element.attributes;
|
|
29
29
|
const attrLength = attributes.length;
|
|
30
30
|
for (let i = 0; i < attrLength; i++) {
|
|
31
|
-
|
|
31
|
+
const attribute = attributes.item(i);
|
|
32
32
|
if (attribute)
|
|
33
33
|
sdui.attributes[attribute.name] = attribute.value;
|
|
34
34
|
}
|
|
35
35
|
let childNodes = element.childNodes;
|
|
36
36
|
let children = element.children;
|
|
37
37
|
if (name == "template") {
|
|
38
|
-
|
|
38
|
+
const template = node;
|
|
39
39
|
childNodes = template.content.childNodes;
|
|
40
40
|
children = template.content.children;
|
|
41
41
|
}
|
|
42
42
|
if (children.length > 0) {
|
|
43
43
|
sdui.nodes = [];
|
|
44
|
-
for (
|
|
44
|
+
for (const ch of childNodes) {
|
|
45
45
|
const parsedChild = SDUIUtils.parseNode(ch);
|
|
46
46
|
if (parsedChild) {
|
|
47
47
|
sdui.nodes.push(parsedChild);
|
|
@@ -53,7 +53,7 @@ export default class SDUIUtils {
|
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
if (nodeType == Node.TEXT_NODE) {
|
|
56
|
-
|
|
56
|
+
const content = (node.textContent || "").trim();
|
|
57
57
|
if (!content)
|
|
58
58
|
return null;
|
|
59
59
|
sdui.markup = content;
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { LitElement } from "lit";
|
|
2
|
+
import { LitElement, PropertyValues } from "lit";
|
|
3
3
|
declare const SonicSDUI_base: {
|
|
4
4
|
new (...args: any[]): {
|
|
5
|
-
api: import("../../../utils/api").default
|
|
6
|
-
key:
|
|
5
|
+
api: import("../../../utils/api").default | null;
|
|
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;
|
|
14
15
|
requestId: number;
|
|
15
16
|
refetchEveryMs: number;
|
|
@@ -20,9 +21,10 @@ declare const SonicSDUI_base: {
|
|
|
20
21
|
connectedCallback(): void;
|
|
21
22
|
firstUpdated(): void;
|
|
22
23
|
onIntersection(entries: IntersectionObserverEntry[]): void;
|
|
23
|
-
|
|
24
|
-
propertyMap: Object;
|
|
24
|
+
propertyMap: object;
|
|
25
25
|
isConnected: boolean;
|
|
26
|
+
children: HTMLCollection;
|
|
27
|
+
appendChild(node: Node): Node;
|
|
26
28
|
getAncestorAttributeValue(attributeName: string): string;
|
|
27
29
|
hasAncestorAttribute(attributeName: string): boolean;
|
|
28
30
|
querySelectorAll(selector: string): NodeListOf<Element>;
|
|
@@ -42,9 +44,9 @@ declare const SonicSDUI_base: {
|
|
|
42
44
|
getApiConfiguration(): import("../../../utils/api").APIConfiguration;
|
|
43
45
|
requestUpdate(): void;
|
|
44
46
|
getAttribute(name: string): string;
|
|
45
|
-
hasAttribute(attributeName:
|
|
47
|
+
hasAttribute(attributeName: string): boolean;
|
|
46
48
|
};
|
|
47
|
-
} & (new (...args: any[]) => import("../../../mixins/Subscriber").SubscriberInterface<
|
|
49
|
+
} & (new (...args: any[]) => import("../../../mixins/Subscriber").SubscriberInterface<import("../../../_types/types").CoreJSType>) & typeof LitElement;
|
|
48
50
|
/**
|
|
49
51
|
* ### sonic-sdui (Server Driven User Interface) est un fetcher chargant un JSON décrivant une interface utilisateur
|
|
50
52
|
*
|
|
@@ -70,8 +72,7 @@ export declare class SonicSDUI extends SonicSDUI_base {
|
|
|
70
72
|
/**
|
|
71
73
|
* On peut passer la description sous form de props, sinon il faut utiliser l'attribut fetch
|
|
72
74
|
*/
|
|
73
|
-
|
|
74
|
-
set props(value: any);
|
|
75
|
+
willUpdate(changedProperties: PropertyValues): void;
|
|
75
76
|
/**
|
|
76
77
|
* updateContents est déclenché quand les sduiDescriptor sont renseignées
|
|
77
78
|
* Le contenu du composant est regénéré en fonction du descripteur fourni
|
|
@@ -51,18 +51,20 @@ let SonicSDUI = class SonicSDUI extends Fetcher(Subscriber(LitElement)) {
|
|
|
51
51
|
/**
|
|
52
52
|
* On peut passer la description sous form de props, sinon il faut utiliser l'attribut fetch
|
|
53
53
|
*/
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
54
|
+
willUpdate(changedProperties) {
|
|
55
|
+
if (this.props == null) {
|
|
56
|
+
this.sduiDescriptor = {};
|
|
57
|
+
}
|
|
58
|
+
{
|
|
59
|
+
const newSduiDescriptor = this.sduiKey
|
|
60
|
+
? this.props[this.sduiKey]
|
|
61
|
+
: this.props;
|
|
62
|
+
if (this.sduiDescriptor == newSduiDescriptor)
|
|
63
|
+
return;
|
|
64
|
+
this.sduiDescriptor = newSduiDescriptor;
|
|
65
|
+
this.updateContents();
|
|
66
|
+
}
|
|
67
|
+
super.willUpdate(changedProperties);
|
|
66
68
|
}
|
|
67
69
|
/**
|
|
68
70
|
* updateContents est déclenché quand les sduiDescriptor sont renseignées
|
|
@@ -72,7 +74,7 @@ let SonicSDUI = class SonicSDUI extends Fetcher(Subscriber(LitElement)) {
|
|
|
72
74
|
return __awaiter(this, void 0, void 0, function* () {
|
|
73
75
|
if (!this.sduiDescriptor)
|
|
74
76
|
return;
|
|
75
|
-
|
|
77
|
+
const library = {};
|
|
76
78
|
Object.assign(library, default_library, this.sduiDescriptor.library);
|
|
77
79
|
this.sduiDescriptor.library = library;
|
|
78
80
|
this.loadAssets();
|
|
@@ -111,9 +113,9 @@ let SonicSDUI = class SonicSDUI extends Fetcher(Subscriber(LitElement)) {
|
|
|
111
113
|
return __awaiter(this, void 0, void 0, function* () {
|
|
112
114
|
if (!this.hasAttribute("transformation"))
|
|
113
115
|
return;
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
116
|
+
const result = yield fetch(this.getAttribute("transformation"));
|
|
117
|
+
const json = yield result.json();
|
|
118
|
+
const transformer = new SDUIDescriptorTransformer();
|
|
117
119
|
yield transformer.transform(this.sduiDescriptor, json);
|
|
118
120
|
});
|
|
119
121
|
}
|
|
@@ -124,8 +126,8 @@ let SonicSDUI = class SonicSDUI extends Fetcher(Subscriber(LitElement)) {
|
|
|
124
126
|
return __awaiter(this, void 0, void 0, function* () {
|
|
125
127
|
if (!this.hasAttribute("library"))
|
|
126
128
|
return;
|
|
127
|
-
|
|
128
|
-
|
|
129
|
+
const result = yield fetch(this.getAttribute("library"));
|
|
130
|
+
const json = yield result.json();
|
|
129
131
|
this.sduiDescriptor.library = json;
|
|
130
132
|
});
|
|
131
133
|
}
|
|
@@ -139,7 +141,7 @@ let SonicSDUI = class SonicSDUI extends Fetcher(Subscriber(LitElement)) {
|
|
|
139
141
|
let nodes = this.sduiDescriptor.nodes;
|
|
140
142
|
if (!nodes)
|
|
141
143
|
nodes = [];
|
|
142
|
-
|
|
144
|
+
const messageProvider = { tagName: "sonic-toast-message-subscriber", attributes: {} };
|
|
143
145
|
if (this.messagesKey) {
|
|
144
146
|
messageProvider.attributes = { subDataProvider: this.messagesKey };
|
|
145
147
|
}
|
|
@@ -150,7 +152,7 @@ let SonicSDUI = class SonicSDUI extends Fetcher(Subscriber(LitElement)) {
|
|
|
150
152
|
* On parse un noeud ce qui crée un éléments graphique et ses enfants par recursivité via `handleChildNodes`
|
|
151
153
|
*/
|
|
152
154
|
parseChild(node) {
|
|
153
|
-
|
|
155
|
+
const tagName = node.tagName || "div";
|
|
154
156
|
let { element, contentElement } = this.handleLibrary(node, tagName);
|
|
155
157
|
this.handleAttributes(node, element);
|
|
156
158
|
element = this.handleMarkup(node, element);
|
|
@@ -180,9 +182,9 @@ let SonicSDUI = class SonicSDUI extends Fetcher(Subscriber(LitElement)) {
|
|
|
180
182
|
*/
|
|
181
183
|
handleChildNodes(node, contentElement, element) {
|
|
182
184
|
if (node.nodes) {
|
|
183
|
-
|
|
184
|
-
for (
|
|
185
|
-
|
|
185
|
+
const children = node.nodes;
|
|
186
|
+
for (const child of children) {
|
|
187
|
+
const childElement = this.parseChild(child);
|
|
186
188
|
let nodeToAppendOn = contentElement;
|
|
187
189
|
if (child.parentElementSelector) {
|
|
188
190
|
nodeToAppendOn = element.querySelector(child.parentElementSelector) || contentElement;
|
|
@@ -190,7 +192,7 @@ let SonicSDUI = class SonicSDUI extends Fetcher(Subscriber(LitElement)) {
|
|
|
190
192
|
if (nodeToAppendOn.shadowRoot)
|
|
191
193
|
nodeToAppendOn.shadowRoot.appendChild(childElement);
|
|
192
194
|
else if (nodeToAppendOn.tagName.toLocaleLowerCase() == "template") {
|
|
193
|
-
|
|
195
|
+
const template = nodeToAppendOn;
|
|
194
196
|
template.content.appendChild(childElement);
|
|
195
197
|
}
|
|
196
198
|
else
|
|
@@ -210,7 +212,7 @@ let SonicSDUI = class SonicSDUI extends Fetcher(Subscriber(LitElement)) {
|
|
|
210
212
|
let contentElement;
|
|
211
213
|
if (node.libraryKey && this.sduiDescriptor.library) {
|
|
212
214
|
element = this.parseChild(this.sduiDescriptor.library[node.libraryKey] || { tagName: "div" });
|
|
213
|
-
|
|
215
|
+
const selector = (this.sduiDescriptor.library[node.libraryKey] || {}).contentElementSelector;
|
|
214
216
|
if (selector)
|
|
215
217
|
contentElement = element.querySelector(selector);
|
|
216
218
|
}
|
|
@@ -222,10 +224,10 @@ let SonicSDUI = class SonicSDUI extends Fetcher(Subscriber(LitElement)) {
|
|
|
222
224
|
* Remplissage des attributs html avec les attributs fournis dans le noeud
|
|
223
225
|
*/
|
|
224
226
|
handleAttributes(node, element) {
|
|
225
|
-
|
|
226
|
-
for (
|
|
227
|
-
|
|
228
|
-
|
|
227
|
+
const attributes = node.attributes;
|
|
228
|
+
for (const k in attributes) {
|
|
229
|
+
const attrData = attributes[k];
|
|
230
|
+
const attr = Objects.isObject(attrData) ? JSON.stringify(attrData) : attrData;
|
|
229
231
|
element.setAttribute(k, attr);
|
|
230
232
|
}
|
|
231
233
|
}
|
|
@@ -248,7 +250,7 @@ let SonicSDUI = class SonicSDUI extends Fetcher(Subscriber(LitElement)) {
|
|
|
248
250
|
if (!node.innerHTML)
|
|
249
251
|
return;
|
|
250
252
|
if (node.innerHTML.indexOf("wording_") != -1) {
|
|
251
|
-
|
|
253
|
+
const wordingProvider = this.getAncestorAttributeValue("wordingProvider");
|
|
252
254
|
(_a = this.api) === null || _a === void 0 ? void 0 : _a.post(wordingProvider, { labels: [node.innerHTML.substring(8)] }).then((value) => {
|
|
253
255
|
if (contentElement)
|
|
254
256
|
contentElement.innerHTML += value;
|
|
@@ -265,9 +267,6 @@ __decorate([
|
|
|
265
267
|
__decorate([
|
|
266
268
|
property()
|
|
267
269
|
], SonicSDUI.prototype, "messagesKey", void 0);
|
|
268
|
-
__decorate([
|
|
269
|
-
property()
|
|
270
|
-
], SonicSDUI.prototype, "props", null);
|
|
271
270
|
SonicSDUI = __decorate([
|
|
272
271
|
customElement(tagName)
|
|
273
272
|
], SonicSDUI);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type SDUIDescriptor = {
|
|
2
2
|
js?: Array<string>;
|
|
3
3
|
css?: Array<string>;
|
|
4
4
|
library?: Record<string, SDUINode>;
|
|
5
5
|
nodes?: Array<SDUINode>;
|
|
6
6
|
};
|
|
7
|
-
export
|
|
7
|
+
export type SDUINode = {
|
|
8
8
|
libraryKey?: string;
|
|
9
9
|
markup?: string;
|
|
10
10
|
tagName?: string;
|
|
@@ -16,21 +16,21 @@ export declare type SDUINode = {
|
|
|
16
16
|
contentElementSelector?: string;
|
|
17
17
|
parentElementSelector?: string;
|
|
18
18
|
};
|
|
19
|
-
export
|
|
19
|
+
export type SDUITransformDescription = {
|
|
20
20
|
library?: Record<string, SDUINode>;
|
|
21
21
|
transforms: Array<SDUITransformAction>;
|
|
22
22
|
};
|
|
23
|
-
export
|
|
24
|
-
export
|
|
25
|
-
export
|
|
23
|
+
export type SDUITransformActionName = "remap" | "unwrap" | "wrap" | "delete" | "insert" | "move";
|
|
24
|
+
export type SDUITransformActionFunction = (transformAction: SDUITransformAction, list: SDUITransformList) => void;
|
|
25
|
+
export type SDUITransformAction = {
|
|
26
26
|
action: SDUITransformActionName;
|
|
27
27
|
patterns?: Array<SDUINode>;
|
|
28
28
|
after?: SDUINode;
|
|
29
29
|
before?: SDUINode;
|
|
30
30
|
in?: SDUINode;
|
|
31
|
-
ui?:
|
|
31
|
+
ui?: SDUINode;
|
|
32
32
|
};
|
|
33
|
-
export
|
|
33
|
+
export type SDUITransformList = Array<{
|
|
34
34
|
parent: SDUINode;
|
|
35
35
|
child: SDUINode;
|
|
36
36
|
index: number;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { LitElement } from "lit";
|
|
2
2
|
import { PublisherInterface, TypeAndRecordOfType } from "@supersoniks/concorde/core/_types/types";
|
|
3
|
-
declare const SonicStates_base: (new (...args: any[]) => import("@supersoniks/concorde/core/mixins/Subscriber").SubscriberInterface<
|
|
3
|
+
declare const SonicStates_base: (new (...args: any[]) => import("@supersoniks/concorde/core/mixins/Subscriber").SubscriberInterface<import("@supersoniks/concorde/core/_types/types").CoreJSType>) & (new (...args: any[]) => import("@supersoniks/concorde/core/mixins/TemplatesContainer").TemplatesContainerInterface) & typeof LitElement;
|
|
4
4
|
/**
|
|
5
5
|
* ### sonic-states affiche des états différents en fonction de la valeur d'une sous propriété de son dataProvider (attribut data-path en dot notation):
|
|
6
6
|
* * Il boucle sur ses template enfants et test si la regexp contenue dans l'attribut *data-value* match la valeur de la propriété
|
|
@@ -18,10 +18,10 @@ declare const SonicStates_base: (new (...args: any[]) => import("@supersoniks/co
|
|
|
18
18
|
*/
|
|
19
19
|
export declare class SonicStates extends SonicStates_base {
|
|
20
20
|
state: string;
|
|
21
|
-
inverted:
|
|
21
|
+
inverted: boolean;
|
|
22
22
|
statePath: string;
|
|
23
23
|
onAssign: (value: string) => void;
|
|
24
|
-
statePublisher?: TypeAndRecordOfType<PublisherInterface<string &
|
|
24
|
+
statePublisher?: TypeAndRecordOfType<PublisherInterface<string & object>>;
|
|
25
25
|
connectedCallback(): void;
|
|
26
26
|
disconnectedCallback(): void;
|
|
27
27
|
render(): import("lit-html").TemplateResult<1>;
|
|
@@ -46,8 +46,8 @@ let SonicStates = class SonicStates extends Subscriber(TemplatesContainer(LitEle
|
|
|
46
46
|
}
|
|
47
47
|
if (this.statePath) {
|
|
48
48
|
this.statePublisher = this.publisher;
|
|
49
|
-
|
|
50
|
-
for (
|
|
49
|
+
const split = this.statePath.split(".");
|
|
50
|
+
for (const s of split) {
|
|
51
51
|
this.statePublisher = this.statePublisher[s];
|
|
52
52
|
}
|
|
53
53
|
this.statePublisher.onAssign(this.onAssign);
|
|
@@ -60,12 +60,12 @@ let SonicStates = class SonicStates extends Subscriber(TemplatesContainer(LitEle
|
|
|
60
60
|
super.disconnectedCallback();
|
|
61
61
|
}
|
|
62
62
|
render() {
|
|
63
|
-
|
|
63
|
+
const templates = [];
|
|
64
64
|
let state = this.state;
|
|
65
65
|
if ((!Array.isArray(state) && Objects.isObject(state)) || state === undefined) {
|
|
66
66
|
state = "";
|
|
67
67
|
}
|
|
68
|
-
for (
|
|
68
|
+
for (const t of this.templatePartsList) {
|
|
69
69
|
let path = t.getAttribute(this.templateValueAttribute);
|
|
70
70
|
let stateToMatch = state;
|
|
71
71
|
if (this.inverted) {
|
|
@@ -74,13 +74,13 @@ let SonicStates = class SonicStates extends Subscriber(TemplatesContainer(LitEle
|
|
|
74
74
|
}
|
|
75
75
|
if (path == "")
|
|
76
76
|
path = this.inverted ? ".*?" : "^$";
|
|
77
|
-
|
|
77
|
+
const regexp = new RegExp(path);
|
|
78
78
|
if (regexp.test(stateToMatch)) {
|
|
79
79
|
templates.push(t);
|
|
80
80
|
t.removeAttribute("mode");
|
|
81
81
|
}
|
|
82
82
|
else {
|
|
83
|
-
|
|
83
|
+
const urlPattern = new UrlPattern(path);
|
|
84
84
|
if (urlPattern.names.length > 0 && urlPattern.match(stateToMatch)) {
|
|
85
85
|
t.setAttribute("mode", "patternMatching");
|
|
86
86
|
templates.push(t);
|
|
@@ -95,7 +95,7 @@ let SonicStates = class SonicStates extends Subscriber(TemplatesContainer(LitEle
|
|
|
95
95
|
if (template.title)
|
|
96
96
|
document.title = template.title;
|
|
97
97
|
if (template.hasAttribute("dataProviderExpression")) {
|
|
98
|
-
|
|
98
|
+
const dataProviderExpression = template.getAttribute("dataProviderExpression");
|
|
99
99
|
let dataProvider = "";
|
|
100
100
|
let stateToMatch = state;
|
|
101
101
|
let path = template.getAttribute(this.templateValueAttribute);
|
|
@@ -112,7 +112,7 @@ let SonicStates = class SonicStates extends Subscriber(TemplatesContainer(LitEle
|
|
|
112
112
|
}
|
|
113
113
|
else {
|
|
114
114
|
const regexp = new RegExp(path);
|
|
115
|
-
|
|
115
|
+
const match = (stateToMatch + "").match(regexp);
|
|
116
116
|
if (match) {
|
|
117
117
|
dataProvider = (_a = match.shift()) === null || _a === void 0 ? void 0 : _a.replace(regexp, dataProviderExpression);
|
|
118
118
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "@supersoniks/concorde/core/components/ui/button/button";
|
|
2
2
|
import API from "@supersoniks/concorde/core/utils/api";
|
|
3
3
|
import { LitElement } from "lit";
|
|
4
|
-
declare const Submit_base: (new (...args: any[]) => import("@supersoniks/concorde/core/mixins/Subscriber").SubscriberInterface<
|
|
4
|
+
declare const Submit_base: (new (...args: any[]) => import("@supersoniks/concorde/core/mixins/Subscriber").SubscriberInterface<import("@supersoniks/concorde/core/_types/types").CoreJSType>) & typeof LitElement;
|
|
5
5
|
/**
|
|
6
6
|
* ###L'élément submit permet d'envoyer des données en rest
|
|
7
7
|
* * Les données envoyées sont celles présentes dans le publisher dont l'adresse est renseignée via l'attribut *formDataProvider*.
|