@supersoniks/concorde 1.1.42 → 1.1.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components.js +2 -3
- package/concorde-core.bundle.js +37 -35
- package/concorde-core.es.js +5081 -4317
- package/core/_types/types.d.ts +26 -0
- package/core/_types/types.js +1 -0
- package/core/components/functional/date/date.d.ts +13 -5
- package/core/components/functional/date/date.js +48 -29
- package/core/components/functional/example/example.d.ts +1 -1
- package/core/components/functional/example/example.js +1 -1
- package/core/components/functional/fetch/fetch.d.ts +40 -3
- package/core/components/functional/fetch/fetch.js +2 -6
- package/core/components/functional/functional.d.ts +2 -0
- package/core/components/functional/functional.js +2 -0
- package/core/components/functional/if/if.d.ts +3 -0
- package/core/components/functional/if/if.js +6 -12
- package/core/components/functional/if/if.test.d.ts +1 -0
- package/core/components/functional/if/if.test.js +44 -0
- package/core/components/functional/list/list.d.ts +32 -8
- package/core/components/functional/list/list.js +33 -40
- package/core/components/functional/mix/mix.d.ts +22 -0
- package/core/components/functional/mix/mix.js +99 -0
- package/core/components/functional/queue/queue.d.ts +16 -3
- package/core/components/functional/queue/queue.js +71 -15
- package/core/components/functional/router/redirect.d.ts +10 -1
- package/core/components/functional/router/redirect.js +5 -6
- package/core/components/functional/router/router.d.ts +15 -1
- package/core/components/functional/router/router.js +1 -6
- package/core/components/functional/sdui/SDUIDescriptorTransformer.d.ts +1 -1
- package/core/components/functional/sdui/SDUIDescriptorTransformer.js +24 -12
- package/core/components/functional/sdui/default-library.json +108 -0
- package/core/components/functional/sdui/sdui-utils.d.ts +5 -0
- package/core/components/functional/sdui/sdui-utils.js +63 -0
- package/core/components/functional/sdui/sdui.d.ts +16 -9
- package/core/components/functional/sdui/sdui.js +52 -25
- package/core/components/functional/sdui/types.d.ts +4 -2
- package/core/components/functional/states/states.d.ts +19 -3
- package/core/components/functional/states/states.js +7 -12
- package/core/components/functional/submit/submit.d.ts +16 -1
- package/core/components/functional/submit/submit.js +87 -17
- package/core/components/functional/subscriber/subscriber.d.ts +4 -1
- package/core/components/functional/subscriber/subscriber.js +1 -6
- package/core/components/functional/value/value.d.ts +7 -0
- package/core/components/functional/value/value.js +26 -0
- package/core/components/ui/_css/scroll.js +6 -7
- package/core/components/ui/_css/size.d.ts +1 -0
- package/core/components/ui/_css/size.js +3 -1
- package/core/components/ui/alert/alert.d.ts +2 -2
- package/core/components/ui/alert/alert.js +11 -16
- package/core/components/ui/badge/badge.d.ts +3 -1
- package/core/components/ui/badge/badge.js +36 -22
- package/core/components/ui/button/button.d.ts +23 -20
- package/core/components/ui/button/button.js +59 -42
- package/core/components/ui/captcha/captcha.d.ts +14 -2
- package/core/components/ui/captcha/captcha.js +17 -12
- package/core/components/ui/card/card-footer.js +1 -8
- package/core/components/ui/card/card-header-descripton.js +3 -9
- package/core/components/ui/card/card-header.js +1 -6
- package/core/components/ui/card/card-main.js +0 -5
- package/core/components/ui/card/card.d.ts +1 -1
- package/core/components/ui/card/card.js +28 -12
- package/core/components/ui/divider/divider.d.ts +2 -0
- package/core/components/ui/divider/divider.js +43 -16
- package/core/components/ui/form/checkbox/checkbox.d.ts +53 -16
- package/core/components/ui/form/checkbox/checkbox.js +53 -28
- package/core/components/ui/form/css/form-control.d.ts +2 -0
- package/core/components/ui/form/css/form-control.js +145 -67
- package/core/components/ui/form/fieldset/fieldset.d.ts +8 -1
- package/core/components/ui/form/fieldset/fieldset.js +45 -8
- package/core/components/ui/form/fieldset/legend-description.js +0 -5
- package/core/components/ui/form/fieldset/legend.js +3 -6
- package/core/components/ui/form/form-actions/form-actions.d.ts +2 -0
- package/core/components/ui/form/form-actions/form-actions.js +26 -11
- package/core/components/ui/form/form-layout/form-layout.d.ts +5 -2
- package/core/components/ui/form/form-layout/form-layout.js +31 -9
- package/core/components/ui/form/input/input.d.ts +15 -18
- package/core/components/ui/form/input/input.js +87 -52
- package/core/components/ui/form/input/password-helper.d.ts +1 -1
- package/core/components/ui/form/input/password-helper.js +3 -2
- package/core/components/ui/form/input/same-value-helper.d.ts +1 -1
- package/core/components/ui/form/input/same-value-helper.js +1 -0
- package/core/components/ui/form/input-autocomplete/input-autocomplete.d.ts +2 -3
- package/core/components/ui/form/input-autocomplete/input-autocomplete.js +2 -6
- package/core/components/ui/form/radio/radio.d.ts +6 -0
- package/core/components/ui/form/radio/radio.js +7 -12
- package/core/components/ui/form/select/select.d.ts +23 -7
- package/core/components/ui/form/select/select.js +69 -38
- package/core/components/ui/form/textarea/textarea.d.ts +13 -13
- package/core/components/ui/form/textarea/textarea.js +29 -36
- package/core/components/ui/group/group.d.ts +11 -1
- package/core/components/ui/group/group.js +79 -17
- package/core/components/ui/icon/icon.d.ts +10 -3
- package/core/components/ui/icon/icon.js +16 -15
- package/core/components/ui/icon/icons.js +11 -8
- package/core/components/ui/icon/icons.json +1 -1
- package/core/components/ui/image/image.js +0 -5
- package/core/components/ui/link/link.d.ts +1 -1
- package/core/components/ui/link/link.js +2 -6
- package/core/components/ui/loader/loader.js +2 -8
- package/core/components/ui/menu/menu-item.js +4 -9
- package/core/components/ui/menu/menu.d.ts +9 -1
- package/core/components/ui/menu/menu.js +183 -27
- package/core/components/ui/modal/modal-actions.js +1 -6
- package/core/components/ui/modal/modal-close.d.ts +1 -0
- package/core/components/ui/modal/modal-close.js +14 -10
- package/core/components/ui/modal/modal-content.js +0 -5
- package/core/components/ui/modal/modal-subtitle.js +2 -6
- package/core/components/ui/modal/modal-title.js +0 -5
- package/core/components/ui/modal/modal.d.ts +7 -7
- package/core/components/ui/modal/modal.js +36 -36
- package/core/components/ui/pop/pop.d.ts +6 -5
- package/core/components/ui/pop/pop.js +44 -44
- package/core/components/ui/progress/progress.js +34 -32
- package/core/components/ui/table/table-caption.js +5 -10
- package/core/components/ui/table/table-tbody.js +10 -14
- package/core/components/ui/table/table-td.d.ts +2 -0
- package/core/components/ui/table/table-td.js +8 -5
- package/core/components/ui/table/table-tfoot.js +5 -7
- package/core/components/ui/table/table-th.d.ts +2 -0
- package/core/components/ui/table/table-th.js +12 -9
- package/core/components/ui/table/table-thead.js +1 -6
- package/core/components/ui/table/table-tr.js +4 -6
- package/core/components/ui/table/table.d.ts +0 -3
- package/core/components/ui/table/table.js +14 -31
- package/core/components/ui/taxonomy/taxonomy.d.ts +6 -3
- package/core/components/ui/taxonomy/taxonomy.js +9 -9
- package/core/components/ui/theme/theme-collection/core-variables.js +13 -11
- package/core/components/ui/theme/theme-collection/dark.js +1 -1
- package/core/components/ui/theme/theme.d.ts +1 -6
- package/core/components/ui/theme/theme.js +7 -36
- package/core/components/ui/toast/message-subscriber.d.ts +13 -7
- package/core/components/ui/toast/toast-item.js +1 -1
- package/core/components/ui/toast/toast.d.ts +2 -1
- package/core/components/ui/toast/toast.js +29 -14
- package/core/components/ui/tooltip/tooltip.d.ts +1 -0
- package/core/components/ui/tooltip/tooltip.js +35 -14
- package/core/components/ui/ui.js +0 -3
- package/core/core.js +5 -6
- package/core/mixins/Fetcher.d.ts +19 -10
- package/core/mixins/Fetcher.js +26 -10
- package/core/mixins/FormCheckable.d.ts +17 -8
- package/core/mixins/FormCheckable.js +177 -22
- package/core/mixins/FormElement.d.ts +12 -7
- package/core/mixins/FormElement.js +42 -26
- package/core/mixins/FormInput.d.ts +8 -4
- package/core/mixins/FormInput.js +4 -3
- package/core/mixins/Subscriber.d.ts +7 -5
- package/core/mixins/Subscriber.js +34 -32
- package/core/utils/Arrays.d.ts +15 -15
- package/core/utils/DataBindObserver.d.ts +16 -9
- package/core/utils/DataBindObserver.js +23 -28
- package/core/utils/Electron.d.ts +5 -1
- package/core/utils/Electron.js +4 -2
- package/core/utils/HTML.d.ts +9 -2
- package/core/utils/HTML.js +22 -3
- package/core/utils/LocationHandler.d.ts +6 -5
- package/core/utils/LocationHandler.js +19 -8
- package/core/utils/Objects.d.ts +7 -4
- package/core/utils/Objects.js +28 -6
- package/core/utils/{PublisherProxy.d.mts → PublisherProxy.d.ts} +40 -31
- package/core/utils/{PublisherProxy.mjs → PublisherProxy.js} +54 -28
- package/core/utils/Utils.d.ts +3 -0
- package/core/utils/Utils.js +18 -0
- package/core/utils/api.d.ts +39 -7
- package/core/utils/api.js +45 -32
- package/img/concorde-logo.svg +1 -0
- package/img/concorde.png +0 -0
- package/img/concorde_def.png +0 -0
- package/mixins.d.ts +36 -18
- package/mixins.js +3 -4
- package/package.json +45 -10
- package/svg/regular/plane.svg +1 -0
- package/svg/solid/plane.svg +1 -0
- package/test-utils/TestUtils.d.ts +4 -0
- package/test-utils/TestUtils.js +12 -0
- package/utils.d.ts +3 -1
- package/utils.js +7 -5
- package/core/components/functional/configuration/configuration.d.ts +0 -5
- package/core/components/functional/configuration/configuration.js +0 -22
- package/core/components/ui/tabs/tab.d.ts +0 -6
- package/core/components/ui/tabs/tab.js +0 -46
- package/core/components/ui/tabs/tabs.d.ts +0 -15
- package/core/components/ui/tabs/tabs.js +0 -129
|
@@ -4,7 +4,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import { PublisherManager } from "@supersoniks/concorde/core/utils/PublisherProxy
|
|
7
|
+
import { PublisherManager } from "@supersoniks/concorde/core/utils/PublisherProxy";
|
|
8
8
|
import { property } from "lit/decorators.js";
|
|
9
9
|
import Objects from "@supersoniks/concorde/core/utils/Objects";
|
|
10
10
|
const keyboardLoops = new Map();
|
|
@@ -26,9 +26,6 @@ const Form = (superClass) => {
|
|
|
26
26
|
this.required = false;
|
|
27
27
|
this.forceAutoFill = false;
|
|
28
28
|
this.disabled = null;
|
|
29
|
-
this.onValueAssign = null;
|
|
30
|
-
this.onFormValueAssign = null;
|
|
31
|
-
this.onFormDataInValidate = null;
|
|
32
29
|
this.formDataProvider = "";
|
|
33
30
|
/**
|
|
34
31
|
* Le nom du champ avec des caractéristiques similaire à un input html classique.
|
|
@@ -46,7 +43,8 @@ const Form = (superClass) => {
|
|
|
46
43
|
this.setFormValueFromPublisher(value);
|
|
47
44
|
};
|
|
48
45
|
this.onFormDataInValidate = () => {
|
|
49
|
-
|
|
46
|
+
let formPublisher = this.getFormPublisher();
|
|
47
|
+
if (!(formPublisher && formPublisher.isFormValid.get())) {
|
|
50
48
|
return;
|
|
51
49
|
}
|
|
52
50
|
this.validateFormElement();
|
|
@@ -63,23 +61,23 @@ const Form = (superClass) => {
|
|
|
63
61
|
}
|
|
64
62
|
validateFormElement() { }
|
|
65
63
|
updateDataValue() {
|
|
66
|
-
|
|
64
|
+
let name = this.getAttribute("name");
|
|
65
|
+
if (name) {
|
|
67
66
|
let formPublisher = this.getFormPublisher();
|
|
68
67
|
if (formPublisher) {
|
|
69
|
-
formPublisher[
|
|
70
|
-
this.setFormValueFromPublisher(formPublisher[
|
|
68
|
+
formPublisher[name] = this.getValueForFormPublisher();
|
|
69
|
+
this.setFormValueFromPublisher(formPublisher[name].get());
|
|
71
70
|
}
|
|
72
71
|
}
|
|
73
72
|
}
|
|
74
73
|
getFormPublisher() {
|
|
75
|
-
if (!this.formDataProvider)
|
|
74
|
+
if (!this.formDataProvider)
|
|
76
75
|
this.formDataProvider = this.getAncestorAttributeValue("formDataProvider");
|
|
77
|
-
}
|
|
78
76
|
if (this.formDataProvider) {
|
|
79
77
|
return PublisherManager.get(this.formDataProvider);
|
|
80
78
|
}
|
|
81
|
-
|
|
82
|
-
|
|
79
|
+
return null;
|
|
80
|
+
//else return this.publisher;
|
|
83
81
|
}
|
|
84
82
|
/**
|
|
85
83
|
* Mise en forme de la valeur fournie au formPublisher associé au composant
|
|
@@ -106,10 +104,13 @@ const Form = (superClass) => {
|
|
|
106
104
|
return this._value;
|
|
107
105
|
}
|
|
108
106
|
set value(value) {
|
|
109
|
-
if (
|
|
110
|
-
|
|
107
|
+
if (this.name == "nom" && value && Objects.deepEqual(value, {})) {
|
|
108
|
+
console.trace(this);
|
|
109
|
+
}
|
|
111
110
|
if (value == null)
|
|
112
|
-
|
|
111
|
+
value = "";
|
|
112
|
+
if (Objects.isObject(value) && value.hasOwnProperty("__value") && value.value == undefined)
|
|
113
|
+
value = "";
|
|
113
114
|
if (this._value == value)
|
|
114
115
|
return;
|
|
115
116
|
this._value = value;
|
|
@@ -117,9 +118,12 @@ const Form = (superClass) => {
|
|
|
117
118
|
this.requestUpdate();
|
|
118
119
|
}
|
|
119
120
|
initPublisher() {
|
|
121
|
+
let formPublisher = this.getFormPublisher();
|
|
122
|
+
let value = this.hasAncestorAttribute("initFromPublisher") && this._name && formPublisher[this._name].get()
|
|
123
|
+
? formPublisher[this._name].get()
|
|
124
|
+
: this.getAttribute("value");
|
|
120
125
|
if (this._name && this.publisher)
|
|
121
126
|
this.publisher[this._name].offAssign(this.onValueAssign);
|
|
122
|
-
let formPublisher = this.getFormPublisher();
|
|
123
127
|
if (this._name && formPublisher)
|
|
124
128
|
formPublisher[this._name].offAssign(this.onFormValueAssign);
|
|
125
129
|
super.initPublisher();
|
|
@@ -127,15 +131,17 @@ const Form = (superClass) => {
|
|
|
127
131
|
this._name = this.getAttribute("name");
|
|
128
132
|
if (!this.value)
|
|
129
133
|
this._value = this.getAttribute("value");
|
|
130
|
-
this.updateDataValue();
|
|
131
134
|
if (this.publisher && this._name) {
|
|
132
135
|
this.publisher[this._name].onAssign(this.onValueAssign);
|
|
133
136
|
}
|
|
134
137
|
formPublisher = this.getFormPublisher();
|
|
135
138
|
if (this._name && formPublisher) {
|
|
136
139
|
formPublisher[this._name].onAssign(this.onFormValueAssign);
|
|
137
|
-
formPublisher.onInvalidate(
|
|
140
|
+
formPublisher.onInvalidate(this.onFormDataInValidate);
|
|
138
141
|
}
|
|
142
|
+
this.updateDataValue();
|
|
143
|
+
if (value)
|
|
144
|
+
this.value = value;
|
|
139
145
|
}
|
|
140
146
|
handleBlur() {
|
|
141
147
|
this.touched = true;
|
|
@@ -166,17 +172,20 @@ const Form = (superClass) => {
|
|
|
166
172
|
keyboardLoops.set(keyboardLoopId2, []);
|
|
167
173
|
}
|
|
168
174
|
let keyboardLoop = keyboardLoops.get(keyboardLoopId2);
|
|
169
|
-
if (keyboardLoop.indexOf(this) == -1) {
|
|
175
|
+
if ((keyboardLoop === null || keyboardLoop === void 0 ? void 0 : keyboardLoop.indexOf(this)) == -1) {
|
|
170
176
|
keyboardLoop.push(this);
|
|
171
177
|
}
|
|
172
178
|
}
|
|
173
179
|
let keyboardLoop = keyboardLoops.get(keyboardLoopId);
|
|
174
180
|
this.addEventListener("keydown", (e) => {
|
|
175
|
-
|
|
181
|
+
var _a;
|
|
182
|
+
const keyboardEvent = e;
|
|
183
|
+
if (!["ArrowDown", "ArrowUp"].includes(keyboardEvent.key))
|
|
176
184
|
return;
|
|
177
185
|
let selector = "input:not([disabled]), button:not([disabled]), select:not([disabled]), textarea:not([disabled])";
|
|
178
|
-
let loop = keyboardLoop.filter((el) => {
|
|
179
|
-
|
|
186
|
+
let loop = keyboardLoop === null || keyboardLoop === void 0 ? void 0 : keyboardLoop.filter((el) => {
|
|
187
|
+
var _a;
|
|
188
|
+
let child = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector(selector);
|
|
180
189
|
if (!child)
|
|
181
190
|
return false;
|
|
182
191
|
let cpStyle = window.getComputedStyle(child);
|
|
@@ -187,7 +196,7 @@ const Form = (superClass) => {
|
|
|
187
196
|
child.getBoundingClientRect().width > 0);
|
|
188
197
|
});
|
|
189
198
|
let next = null;
|
|
190
|
-
if (
|
|
199
|
+
if (keyboardEvent.key == "ArrowDown" && loop) {
|
|
191
200
|
let index = loop.indexOf(this);
|
|
192
201
|
if (index == loop.length - 1) {
|
|
193
202
|
next = loop[0];
|
|
@@ -196,7 +205,7 @@ const Form = (superClass) => {
|
|
|
196
205
|
next = loop[index + 1];
|
|
197
206
|
}
|
|
198
207
|
}
|
|
199
|
-
else if (
|
|
208
|
+
else if (keyboardEvent.key == "ArrowUp" && loop) {
|
|
200
209
|
let index = loop.indexOf(this);
|
|
201
210
|
if (index == 0) {
|
|
202
211
|
next = loop[loop.length - 1];
|
|
@@ -205,14 +214,15 @@ const Form = (superClass) => {
|
|
|
205
214
|
next = loop[index - 1];
|
|
206
215
|
}
|
|
207
216
|
}
|
|
208
|
-
let elt = next.shadowRoot.querySelector(selector);
|
|
209
|
-
if (elt) {
|
|
217
|
+
let elt = (_a = next === null || next === void 0 ? void 0 : next.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector(selector);
|
|
218
|
+
if (elt && elt.focus) {
|
|
210
219
|
elt.focus();
|
|
211
220
|
e.preventDefault();
|
|
212
221
|
}
|
|
213
222
|
});
|
|
214
223
|
}
|
|
215
224
|
connectedCallback() {
|
|
225
|
+
this.formDataProvider = this.getAncestorAttributeValue("formDataProvider");
|
|
216
226
|
super.connectedCallback();
|
|
217
227
|
this.addKeyboardNavigation();
|
|
218
228
|
}
|
|
@@ -245,6 +255,12 @@ const Form = (superClass) => {
|
|
|
245
255
|
__decorate([
|
|
246
256
|
property({ type: Boolean })
|
|
247
257
|
], FormElement.prototype, "disabled", void 0);
|
|
258
|
+
__decorate([
|
|
259
|
+
property({ type: String, attribute: "data-aria-label" })
|
|
260
|
+
], FormElement.prototype, "ariaLabel", void 0);
|
|
261
|
+
__decorate([
|
|
262
|
+
property({ type: String, attribute: "data-aria-labelledby" })
|
|
263
|
+
], FormElement.prototype, "ariaLabelledby", void 0);
|
|
248
264
|
__decorate([
|
|
249
265
|
property()
|
|
250
266
|
], FormElement.prototype, "name", null);
|
|
@@ -19,16 +19,20 @@ declare const Form: <T extends Constructor<FormElementInterface>>(superClass: T)
|
|
|
19
19
|
autocomplete?: "url" | "name" | "language" | "on" | "tel" | "email" | "honorific-prefix" | "given-name" | "additional-name" | "family-name" | "honorific-suffix" | "nickname" | "username" | "new-password" | "current-password" | "one-time-code" | "organization-title" | "organization" | "street-address" | "address-line1" | "address-line2" | "address-line3" | "address-level4" | "address-level3" | "address-level2" | "address-level1" | "country" | "country-name" | "postal-code" | "cc-name" | "cc-given-name" | "cc-additional-name" | "cc-family-name" | "cc-number" | "cc-exp" | "cc-exp-month" | "cc-exp-year" | "cc-csc" | "cc-type" | "transaction-currency" | "transaction-amount" | "bday" | "bday-day" | "bday-month" | "bday-year" | "sex" | "tel-country-code" | "tel-national" | "tel-area-code" | "tel-local" | "tel-extension" | "impp" | "photo" | undefined;
|
|
20
20
|
getFormPublisher(): any;
|
|
21
21
|
updateDataValue(): void;
|
|
22
|
-
handleChange(e?:
|
|
23
|
-
handleBlur(e?:
|
|
22
|
+
handleChange(e?: Event | undefined): void;
|
|
23
|
+
handleBlur(e?: Event | undefined): void;
|
|
24
24
|
getValueForFormPublisher(): any;
|
|
25
|
+
focus?: (() => void) | undefined;
|
|
26
|
+
shadowRoot?: ShadowRoot | undefined;
|
|
25
27
|
error: boolean;
|
|
26
28
|
autofocus: boolean;
|
|
27
29
|
required: boolean;
|
|
28
30
|
disabled: true | null;
|
|
29
31
|
formDataProvider: string;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
+
ariaLabelledby?: string | undefined;
|
|
33
|
+
ariaLabel?: string | undefined;
|
|
34
|
+
_value: string | null;
|
|
35
|
+
value: string | null;
|
|
32
36
|
_name: string;
|
|
33
37
|
name: string;
|
|
34
38
|
props: any;
|
package/core/mixins/FormInput.js
CHANGED
|
@@ -19,11 +19,12 @@ const Form = (superClass) => {
|
|
|
19
19
|
}
|
|
20
20
|
validateFormElement() {
|
|
21
21
|
var _a;
|
|
22
|
-
const
|
|
23
|
-
const input = (_a = that.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector("input");
|
|
22
|
+
const input = (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector("input");
|
|
24
23
|
if (!input || input.checkValidity())
|
|
25
24
|
return;
|
|
26
|
-
this.getFormPublisher()
|
|
25
|
+
let formPublisher = this.getFormPublisher();
|
|
26
|
+
if (formPublisher)
|
|
27
|
+
formPublisher.isFormValid = false;
|
|
27
28
|
input.reportValidity();
|
|
28
29
|
}
|
|
29
30
|
set type(value) {
|
|
@@ -1,19 +1,21 @@
|
|
|
1
|
-
import { LitElement } from "lit";
|
|
2
1
|
import { APIConfiguration } from "@supersoniks/concorde/core/utils/api";
|
|
2
|
+
import { LitElement } from "lit";
|
|
3
|
+
import { PublisherInterface, TypeAndRecordOfType } from "@supersoniks/concorde/core/_types/types";
|
|
3
4
|
declare type Constructor<T> = new (...args: any[]) => T;
|
|
4
|
-
export interface SubscriberInterface {
|
|
5
|
-
props:
|
|
5
|
+
export interface SubscriberInterface<PropsType = any> {
|
|
6
|
+
props: PropsType | null;
|
|
6
7
|
propertyMap: Object;
|
|
7
8
|
isConnected: boolean;
|
|
8
9
|
getAncestorAttributeValue(attributeName: string): string;
|
|
9
10
|
hasAncestorAttribute(attributeName: string): boolean;
|
|
10
11
|
querySelectorAll(selector: string): NodeListOf<Element>;
|
|
11
|
-
publisher:
|
|
12
|
+
publisher: TypeAndRecordOfType<PublisherInterface<PropsType>>;
|
|
12
13
|
dataProvider: string | null;
|
|
13
14
|
noShadowDom: string | null;
|
|
14
15
|
debug: HTMLElement | null;
|
|
15
16
|
defferedDebug: boolean | null;
|
|
16
17
|
displayContents: boolean;
|
|
18
|
+
shadowRoot?: ShadowRoot;
|
|
17
19
|
dispatchEvent(event: Event): void;
|
|
18
20
|
setAttribute(name: string, value: string): void;
|
|
19
21
|
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
|
|
@@ -27,5 +29,5 @@ export interface SubscriberInterface {
|
|
|
27
29
|
hasAttribute(attributeName: String): boolean;
|
|
28
30
|
disconnectedCallback(): void;
|
|
29
31
|
}
|
|
30
|
-
declare const Subscriber: <T extends Constructor<LitElement
|
|
32
|
+
declare const Subscriber: <PropsType = any, T extends Constructor<LitElement> = any>(superClass: T, type?: PropsType | undefined) => Constructor<SubscriberInterface<PropsType>> & T;
|
|
31
33
|
export default Subscriber;
|
|
@@ -13,12 +13,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
13
13
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
14
14
|
});
|
|
15
15
|
};
|
|
16
|
-
import { PublisherManager } from "@supersoniks/concorde/core/utils/PublisherProxy.mjs";
|
|
17
|
-
import { property } from "lit/decorators.js";
|
|
18
16
|
import API from "@supersoniks/concorde/core/utils/api";
|
|
19
|
-
import HTML from "@supersoniks/concorde/core/utils/HTML";
|
|
20
17
|
import DataBindObserver from "@supersoniks/concorde/core/utils/DataBindObserver";
|
|
18
|
+
import HTML from "@supersoniks/concorde/core/utils/HTML";
|
|
21
19
|
import Objects from "@supersoniks/concorde/core/utils/Objects";
|
|
20
|
+
import { PublisherManager } from "@supersoniks/concorde/core/utils/PublisherProxy";
|
|
21
|
+
import { property } from "lit/decorators.js";
|
|
22
22
|
let keepDebugOnMouseOut = false;
|
|
23
23
|
let debugs = new Set();
|
|
24
24
|
//Pour référence
|
|
@@ -36,13 +36,14 @@ let debugs = new Set();
|
|
|
36
36
|
// return this.shadowRoot || this;
|
|
37
37
|
// }
|
|
38
38
|
// }
|
|
39
|
-
const Subscriber = (superClass) => {
|
|
39
|
+
const Subscriber = (superClass, type) => {
|
|
40
40
|
/**
|
|
41
41
|
* La mixin Subscriber permet lier un composant à un publisher.
|
|
42
42
|
* La liaison à un publisher se fait via l'attribut *dataProvider* du composant qui représente ce que l'on obtient en appellant PublisherManager.get(dataProvider).
|
|
43
43
|
* les propriétés du composant sont automatiquement remplies avec les propriétés du même nom dans les données du publisher.
|
|
44
44
|
* Le composant est automatiquement mis à jour lorsque les données du publisher sont mises à jour.
|
|
45
45
|
*/
|
|
46
|
+
type;
|
|
46
47
|
class SubscriberElement extends superClass {
|
|
47
48
|
constructor(...args) {
|
|
48
49
|
super();
|
|
@@ -90,8 +91,10 @@ const Subscriber = (superClass) => {
|
|
|
90
91
|
/**
|
|
91
92
|
* On assign est enregistré car c'est un écouteur du publisher qui doit être délié lorsque l'objet est déconnecté du dom.
|
|
92
93
|
*/
|
|
93
|
-
this.onAssign =
|
|
94
|
-
|
|
94
|
+
this.onAssign = (v) => {
|
|
95
|
+
this.props = v;
|
|
96
|
+
};
|
|
97
|
+
args;
|
|
95
98
|
}
|
|
96
99
|
/**
|
|
97
100
|
* va de parent en parent pour trouver un attribut
|
|
@@ -107,11 +110,10 @@ const Subscriber = (superClass) => {
|
|
|
107
110
|
* @returns valeur de l'attribut ou null si l'attribut n'est pas trouvé
|
|
108
111
|
*/
|
|
109
112
|
getAncestorAttributeValue(attributeName) {
|
|
110
|
-
|
|
111
|
-
return HTML.getAncestorAttributeValue(node, attributeName);
|
|
113
|
+
return HTML.getAncestorAttributeValue(this, attributeName);
|
|
112
114
|
}
|
|
113
115
|
get props() {
|
|
114
|
-
if (!this.publisher)
|
|
116
|
+
if (this._props !== null || !this.publisher)
|
|
115
117
|
return this._props;
|
|
116
118
|
return this.publisher.get();
|
|
117
119
|
}
|
|
@@ -119,12 +121,11 @@ const Subscriber = (superClass) => {
|
|
|
119
121
|
if (typeof value == "string" && ["{", "["].includes(value.trim().charAt(0))) {
|
|
120
122
|
value = JSON.parse(value);
|
|
121
123
|
}
|
|
122
|
-
if (value ==
|
|
123
|
-
|
|
124
|
-
if (!this.publisher)
|
|
125
|
-
this.initPublisher();
|
|
124
|
+
if (value == this._props)
|
|
125
|
+
return;
|
|
126
126
|
this._props = value;
|
|
127
|
-
if (this.publisher)
|
|
127
|
+
// if (!this.publisher) this.initPublisher();
|
|
128
|
+
if (this.publisher && this.publisher.get() != value) {
|
|
128
129
|
this.publisher.set(value);
|
|
129
130
|
}
|
|
130
131
|
this.requestUpdate();
|
|
@@ -165,18 +166,20 @@ const Subscriber = (superClass) => {
|
|
|
165
166
|
SubscriberElement.instanceCounter++;
|
|
166
167
|
}
|
|
167
168
|
disconnectedCallback() {
|
|
169
|
+
var _a;
|
|
168
170
|
this.removeDebugger();
|
|
169
171
|
super.disconnectedCallback();
|
|
170
172
|
if (this.publisher) {
|
|
171
173
|
this.publisher.stopTemplateFilling(this);
|
|
172
|
-
this.publisher.offInternalMutation(this.requestUpdate
|
|
174
|
+
this.publisher.offInternalMutation(this.requestUpdate);
|
|
173
175
|
}
|
|
174
176
|
if (this.wordingPublisher)
|
|
175
177
|
this.wordingPublisher.stopTemplateFilling(this);
|
|
176
178
|
if (this.onAssign)
|
|
177
|
-
this.publisher.offAssign(this.onAssign);
|
|
179
|
+
(_a = this.publisher) === null || _a === void 0 ? void 0 : _a.offAssign(this.onAssign);
|
|
178
180
|
}
|
|
179
181
|
addDebugger() {
|
|
182
|
+
var _a;
|
|
180
183
|
if (this.hasAttribute("debug") && !this.defferedDebug) {
|
|
181
184
|
if (!this.debug) {
|
|
182
185
|
this.debug = document.createElement("div");
|
|
@@ -195,10 +198,11 @@ const Subscriber = (superClass) => {
|
|
|
195
198
|
style.zIndex = "99999999";
|
|
196
199
|
style.maxHeight = "calc(100vh - 32px)";
|
|
197
200
|
style.fontFamily = "Consolas, monospace";
|
|
198
|
-
style.maxWidth = "50vw";
|
|
201
|
+
style.maxWidth = "min(50vw,25rem)";
|
|
199
202
|
style.fontSize = "12px";
|
|
200
203
|
style.minWidth = "300px";
|
|
201
204
|
style.overflowWrap = "break-word";
|
|
205
|
+
style.resize = "vertical";
|
|
202
206
|
}
|
|
203
207
|
this.addEventListener("click", (e) => {
|
|
204
208
|
if (!e.ctrlKey)
|
|
@@ -207,8 +211,7 @@ const Subscriber = (superClass) => {
|
|
|
207
211
|
keepDebugOnMouseOut = !keepDebugOnMouseOut;
|
|
208
212
|
});
|
|
209
213
|
if (this.dataProvider) {
|
|
210
|
-
|
|
211
|
-
win[this.dataProvider] = this.publisher;
|
|
214
|
+
window[this.dataProvider] = this.publisher;
|
|
212
215
|
}
|
|
213
216
|
this.addEventListener("mouseover", () => {
|
|
214
217
|
if (!keepDebugOnMouseOut)
|
|
@@ -220,13 +223,14 @@ const Subscriber = (superClass) => {
|
|
|
220
223
|
if (!keepDebugOnMouseOut)
|
|
221
224
|
this.removeDebugger();
|
|
222
225
|
});
|
|
223
|
-
this.publisher.onInternalMutation(() => {
|
|
226
|
+
(_a = this.publisher) === null || _a === void 0 ? void 0 : _a.onInternalMutation(() => {
|
|
227
|
+
var _a;
|
|
224
228
|
this.debug.innerHTML = `🤖 DataProvider : "<b style="font-weight:bold;color:#fff;">${this.dataProvider}</b>"<br>
|
|
225
229
|
<div style="font-size:10px;border-top:1px dashed;margin-top:5px;padding-left:23px;opacity:.6;padding-top:5px;">
|
|
226
230
|
Variable disponible dans la console<br>
|
|
227
231
|
ctrl + Clique : épingler / désépingler
|
|
228
232
|
</div>
|
|
229
|
-
<pre style="margin-top:10px;background:transparent;padding:0;font-size:inherit;color:inherit;">${JSON.stringify(this.publisher.get(), null, " ")}</pre>`;
|
|
233
|
+
<pre style="margin-top:10px;background:transparent;padding:0;font-size:inherit;color:inherit;">${JSON.stringify((_a = this.publisher) === null || _a === void 0 ? void 0 : _a.get(), null, " ")}</pre>`;
|
|
230
234
|
});
|
|
231
235
|
}
|
|
232
236
|
}
|
|
@@ -244,6 +248,7 @@ const Subscriber = (superClass) => {
|
|
|
244
248
|
*/
|
|
245
249
|
getApiConfiguration() {
|
|
246
250
|
const token = this.getAncestorAttributeValue("token");
|
|
251
|
+
let addHTTPResponse = this.getAncestorAttributeValue("addHTTPResponse") != null;
|
|
247
252
|
let serviceURL = this.getAncestorAttributeValue("serviceURL");
|
|
248
253
|
let userName = null;
|
|
249
254
|
let password = null;
|
|
@@ -253,7 +258,8 @@ const Subscriber = (superClass) => {
|
|
|
253
258
|
password = this.getAncestorAttributeValue("password");
|
|
254
259
|
tokenProvider = this.getAncestorAttributeValue("tokenProvider");
|
|
255
260
|
}
|
|
256
|
-
|
|
261
|
+
let credentials = this.getAncestorAttributeValue("credentials") || undefined;
|
|
262
|
+
return { serviceURL, token, userName, password, tokenProvider, addHTTPResponse, credentials };
|
|
257
263
|
}
|
|
258
264
|
initWording() {
|
|
259
265
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -339,17 +345,14 @@ const Subscriber = (superClass) => {
|
|
|
339
345
|
this.publisher = pub;
|
|
340
346
|
}
|
|
341
347
|
if (this.publisher) {
|
|
342
|
-
this.
|
|
343
|
-
this.
|
|
344
|
-
}
|
|
345
|
-
this.publisher.onAssign(this.onAssign);
|
|
348
|
+
if (this._props) {
|
|
349
|
+
this.publisher.set(this._props);
|
|
350
|
+
}
|
|
346
351
|
if (!this.noAutoFill)
|
|
347
352
|
this.publisher.startTemplateFilling(this);
|
|
348
353
|
if (this.renderOnPropsInternalChange)
|
|
349
354
|
this.publisher.onInternalMutation(this.requestUpdate);
|
|
350
|
-
|
|
351
|
-
this.publisher.set(this._props);
|
|
352
|
-
}
|
|
355
|
+
this.publisher.onAssign(this.onAssign);
|
|
353
356
|
}
|
|
354
357
|
}
|
|
355
358
|
}
|
|
@@ -381,6 +384,5 @@ const Subscriber = (superClass) => {
|
|
|
381
384
|
return SubscriberElement;
|
|
382
385
|
};
|
|
383
386
|
export default Subscriber;
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
win.SonicPublisherManager = PublisherManager;
|
|
387
|
+
if (!window.SonicPublisherManager)
|
|
388
|
+
window.SonicPublisherManager = PublisherManager;
|
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
|
};
|
|
@@ -1,12 +1,19 @@
|
|
|
1
|
+
import { PublisherInterface, PublisherContentType } from "@supersoniks/concorde/core/_types/types";
|
|
2
|
+
import { SearchableDomElement } from "@supersoniks/concorde/core/utils/HTML";
|
|
1
3
|
declare type BindedVariablesDescriptor = {
|
|
2
|
-
expression:
|
|
4
|
+
expression: string;
|
|
3
5
|
variables: Array<Array<string>>;
|
|
4
6
|
};
|
|
5
7
|
declare type DataBindItem = {
|
|
6
8
|
propertyToUpdate: string;
|
|
7
9
|
bindedVariablesDescriptor: BindedVariablesDescriptor;
|
|
8
10
|
};
|
|
11
|
+
declare type PublisherListenerConfig<ValueType extends PublisherContentType = any> = {
|
|
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[]): any;
|
|
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 {};
|