@supersoniks/concorde 1.1.41 → 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/README.md +0 -0
- package/cli.js +0 -0
- package/components.d.ts +0 -0
- package/components.js +2 -3
- package/concorde-core.bundle.js +37 -42
- package/concorde-core.es.js +5702 -4823
- 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 +20 -9
- package/core/components/functional/sdui/sdui.js +64 -24
- package/core/components/functional/sdui/types.d.ts +4 -2
- package/core/components/functional/sdui/types.js +0 -0
- package/core/components/functional/sonic-scope/sonic-scope.d.ts +0 -0
- package/core/components/functional/sonic-scope/sonic-scope.js +0 -0
- 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.d.ts +0 -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/_css/type.d.ts +0 -0
- package/core/components/ui/_css/type.js +0 -0
- 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.d.ts +0 -0
- package/core/components/ui/card/card-footer.js +1 -8
- package/core/components/ui/card/card-header-descripton.d.ts +0 -0
- package/core/components/ui/card/card-header-descripton.js +3 -9
- package/core/components/ui/card/card-header.d.ts +0 -0
- package/core/components/ui/card/card-header.js +1 -6
- package/core/components/ui/card/card-main.d.ts +0 -0
- 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 +44 -17
- package/core/components/ui/form/checkbox/checkbox.d.ts +53 -16
- package/core/components/ui/form/checkbox/checkbox.js +54 -29
- 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.d.ts +0 -0
- package/core/components/ui/form/fieldset/legend-description.js +0 -5
- package/core/components/ui/form/fieldset/legend.d.ts +0 -0
- package/core/components/ui/form/fieldset/legend.js +4 -7
- 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 +89 -54
- package/core/components/ui/form/input/password-helper.d.ts +7 -1
- package/core/components/ui/form/input/password-helper.js +33 -10
- 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 +34 -0
- package/core/components/ui/form/input-autocomplete/input-autocomplete.js +133 -0
- 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 +71 -40
- package/core/components/ui/form/textarea/textarea.d.ts +13 -13
- package/core/components/ui/form/textarea/textarea.js +31 -38
- 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.d.ts +0 -0
- package/core/components/ui/icon/icons.js +11 -8
- package/core/components/ui/icon/icons.json +1 -1
- package/core/components/ui/image/image.d.ts +0 -0
- 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 +0 -0
- package/core/components/ui/loader/loader.js +2 -8
- package/core/components/ui/loader/styles/fixed.d.ts +0 -0
- package/core/components/ui/loader/styles/fixed.js +0 -0
- package/core/components/ui/loader/styles/inline.d.ts +0 -0
- package/core/components/ui/loader/styles/inline.js +0 -0
- package/core/components/ui/menu/menu-item.d.ts +0 -0
- 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.d.ts +0 -0
- 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.d.ts +0 -0
- package/core/components/ui/modal/modal-content.js +0 -5
- package/core/components/ui/modal/modal-subtitle.d.ts +0 -0
- package/core/components/ui/modal/modal-subtitle.js +2 -6
- package/core/components/ui/modal/modal-title.d.ts +0 -0
- 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 +2 -1
- package/core/components/ui/pop/pop.js +11 -10
- package/core/components/ui/progress/progress.d.ts +0 -0
- package/core/components/ui/progress/progress.js +34 -32
- package/core/components/ui/table/table-caption.d.ts +0 -0
- package/core/components/ui/table/table-caption.js +5 -10
- package/core/components/ui/table/table-tbody.d.ts +0 -0
- 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.d.ts +0 -0
- 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.d.ts +0 -0
- package/core/components/ui/table/table-thead.js +1 -6
- package/core/components/ui/table/table-tr.d.ts +0 -0
- 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/css/tailwind.css +0 -0
- package/core/components/ui/theme/css/tailwind.d.ts +0 -0
- package/core/components/ui/theme/theme-collection/core-variables.d.ts +0 -0
- package/core/components/ui/theme/theme-collection/core-variables.js +13 -11
- package/core/components/ui/theme/theme-collection/dark.d.ts +0 -0
- package/core/components/ui/theme/theme-collection/dark.js +1 -1
- package/core/components/ui/theme/theme-collection/light.d.ts +0 -0
- package/core/components/ui/theme/theme-collection/light.js +0 -0
- 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/message-subscriber.js +0 -0
- package/core/components/ui/toast/toast-item.d.ts +0 -0
- 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/toast/types.d.ts +0 -0
- package/core/components/ui/toast/types.js +0 -0
- package/core/components/ui/tooltip/tooltip.d.ts +1 -0
- package/core/components/ui/tooltip/tooltip.js +35 -14
- package/core/components/ui/ui.d.ts +1 -0
- package/core/components/ui/ui.js +1 -3
- package/core/core.d.ts +0 -0
- 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/mixins/TemplatesContainer.d.ts +0 -0
- package/core/mixins/TemplatesContainer.js +0 -0
- package/core/mixins/mixins.d.ts +0 -0
- package/core/mixins/mixins.js +0 -0
- package/core/utils/Arrays.d.ts +15 -15
- package/core/utils/Arrays.js +0 -0
- 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/Format.d.ts +0 -0
- package/core/utils/Format.js +0 -0
- 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 +47 -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
|
@@ -5,6 +5,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
7
|
import { property } from "lit/decorators.js";
|
|
8
|
+
import { PublisherManager } from "@supersoniks/concorde/utils";
|
|
8
9
|
const Form = (superClass) => {
|
|
9
10
|
/**
|
|
10
11
|
* FormCheckable ajoute un comportement de sélection (checked) a tout FormElement qui utilise cette mixin.
|
|
@@ -30,21 +31,98 @@ const Form = (superClass) => {
|
|
|
30
31
|
Active le mode radio
|
|
31
32
|
*/
|
|
32
33
|
this.radio = null;
|
|
34
|
+
this.unCheckOnDisconnect = false;
|
|
33
35
|
/**
|
|
34
36
|
* propriété checked avec des caractéristiques similaire à un input html classique.
|
|
35
37
|
*/
|
|
36
38
|
this._checked = null;
|
|
39
|
+
this.updateAllChecked = () => {
|
|
40
|
+
let name = this.getAttribute("name");
|
|
41
|
+
let checkAllPublisher = this.getCheckAllPublisher();
|
|
42
|
+
let formPublisher = this.getFormPublisher();
|
|
43
|
+
if (!(checkAllPublisher === null || checkAllPublisher === void 0 ? void 0 : checkAllPublisher.hasCheckAll.get())) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (!this.checksAll() && checkAllPublisher && formPublisher && name) {
|
|
47
|
+
if (!formPublisher[this.name].get().length) {
|
|
48
|
+
checkAllPublisher.checkMode = "noneChecked";
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
else if (this.checked === null) {
|
|
52
|
+
checkAllPublisher.checkMode = "someUnchecked";
|
|
53
|
+
}
|
|
54
|
+
else if (checkAllPublisher.checkMode.get() == "noneChecked" || checkAllPublisher.checkMode.get() == null) {
|
|
55
|
+
checkAllPublisher.checkMode = "someUnchecked";
|
|
56
|
+
}
|
|
57
|
+
let currentValues = formPublisher[name].get();
|
|
58
|
+
let allValues = checkAllPublisher.values.get();
|
|
59
|
+
if (allValues && allValues.length) {
|
|
60
|
+
let checkedCount = allValues.length;
|
|
61
|
+
for (let p of allValues) {
|
|
62
|
+
if (currentValues.indexOf(p) == -1) {
|
|
63
|
+
checkedCount -= 1;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if (checkedCount == allValues.length) {
|
|
67
|
+
checkAllPublisher.checkMode = "allChecked";
|
|
68
|
+
}
|
|
69
|
+
if (checkedCount == 0) {
|
|
70
|
+
checkAllPublisher.checkMode = "noneChecked";
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
if (allValues.indexOf(this.value) == -1) {
|
|
74
|
+
this.checked = null;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
this.onChecksAllRequest = (value) => {
|
|
79
|
+
this.removeAttribute("allChecked");
|
|
80
|
+
this.removeAttribute("indeterminate");
|
|
81
|
+
if (value == "allChecked") {
|
|
82
|
+
this.checked = true;
|
|
83
|
+
this.setAttribute("allChecked", "");
|
|
84
|
+
}
|
|
85
|
+
if (value == "noneChecked") {
|
|
86
|
+
this.checked = null;
|
|
87
|
+
}
|
|
88
|
+
if (value == "someUnchecked") {
|
|
89
|
+
if (this.checksAll())
|
|
90
|
+
this.checked = "indeterminate";
|
|
91
|
+
this.setAttribute("indeterminate", "");
|
|
92
|
+
}
|
|
93
|
+
};
|
|
37
94
|
}
|
|
38
95
|
get value() {
|
|
39
96
|
return this._value;
|
|
40
97
|
}
|
|
41
|
-
set value(
|
|
98
|
+
set value(newValue) {
|
|
99
|
+
if (this.value == newValue)
|
|
100
|
+
return;
|
|
42
101
|
if (this.hasAttribute("value") && !this.forceAutoFill)
|
|
43
|
-
|
|
44
|
-
if (this._value ==
|
|
102
|
+
newValue = this.getAttribute("value");
|
|
103
|
+
if (this._value == newValue)
|
|
45
104
|
return;
|
|
46
|
-
|
|
47
|
-
|
|
105
|
+
if (newValue == null)
|
|
106
|
+
return;
|
|
107
|
+
this._value = newValue;
|
|
108
|
+
if (!this.value)
|
|
109
|
+
return;
|
|
110
|
+
// On check l'élément si il est cheched dans le formPublisher
|
|
111
|
+
let formPublisher = this.getFormPublisher();
|
|
112
|
+
if (formPublisher && this.name) {
|
|
113
|
+
let currentValue = formPublisher[this.name].get();
|
|
114
|
+
if (this.radio || this.unique) {
|
|
115
|
+
this.checked = currentValue == newValue ? true : null;
|
|
116
|
+
}
|
|
117
|
+
if (!Array.isArray(currentValue)) {
|
|
118
|
+
currentValue = [];
|
|
119
|
+
}
|
|
120
|
+
if (currentValue.indexOf(newValue) != -1)
|
|
121
|
+
this.checked = true;
|
|
122
|
+
}
|
|
123
|
+
//On mets à jour la valeur dans la donnée si l'élément est checked
|
|
124
|
+
if (this.checked == true)
|
|
125
|
+
this.updateDataValue();
|
|
48
126
|
this.requestUpdate();
|
|
49
127
|
}
|
|
50
128
|
get checked() {
|
|
@@ -52,18 +130,38 @@ const Form = (superClass) => {
|
|
|
52
130
|
}
|
|
53
131
|
set checked(checked) {
|
|
54
132
|
this.setCheckedValue(checked);
|
|
133
|
+
if (this.checksAll()) {
|
|
134
|
+
let checkAllPublisher = this.getCheckAllPublisher();
|
|
135
|
+
if (checkAllPublisher) {
|
|
136
|
+
if (this.checked === true)
|
|
137
|
+
checkAllPublisher.checkMode = "allChecked";
|
|
138
|
+
else if (this.checked === null) {
|
|
139
|
+
checkAllPublisher.checkMode = "noneChecked";
|
|
140
|
+
let formPublisher = this.getFormPublisher();
|
|
141
|
+
if (formPublisher) {
|
|
142
|
+
formPublisher[this.name] = [];
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
this.requestUpdate();
|
|
55
148
|
}
|
|
56
149
|
validateFormElement() {
|
|
57
150
|
var _a;
|
|
58
|
-
const
|
|
59
|
-
const input = (_a = that.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector("input");
|
|
151
|
+
const input = (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector("input");
|
|
60
152
|
if (!input || input.checkValidity())
|
|
61
153
|
return;
|
|
62
|
-
let
|
|
63
|
-
if (
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
154
|
+
let formPublisher = this.getFormPublisher();
|
|
155
|
+
if (formPublisher) {
|
|
156
|
+
let value = formPublisher[this.name].get();
|
|
157
|
+
if ((this.unique || this.radio) && value !== null && value.toString().length > 0)
|
|
158
|
+
return;
|
|
159
|
+
formPublisher.isFormValid = false;
|
|
160
|
+
input.reportValidity();
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
checksAll() {
|
|
164
|
+
return this.hasAttribute("checksAll");
|
|
67
165
|
}
|
|
68
166
|
setCheckedValue(checked) {
|
|
69
167
|
if (this._checked == checked)
|
|
@@ -71,6 +169,7 @@ const Form = (superClass) => {
|
|
|
71
169
|
this._checked = checked;
|
|
72
170
|
this.updateDataValue();
|
|
73
171
|
this.requestUpdate();
|
|
172
|
+
setTimeout(() => this.updateAllChecked(), 1);
|
|
74
173
|
// Désactivation du checked sur le publisher
|
|
75
174
|
// Pas sur de l'utilité mais provoque un bug
|
|
76
175
|
// if (this.publisher && !this.radio && !this.unique) {
|
|
@@ -78,7 +177,8 @@ const Form = (superClass) => {
|
|
|
78
177
|
// }
|
|
79
178
|
}
|
|
80
179
|
handleChange() {
|
|
81
|
-
|
|
180
|
+
const newCheckedValue = this.checked === true ? (!this.radio ? null : true) : true;
|
|
181
|
+
this.checked = newCheckedValue;
|
|
82
182
|
const event = new Event("change");
|
|
83
183
|
this.dispatchEvent(event);
|
|
84
184
|
}
|
|
@@ -87,23 +187,26 @@ const Form = (superClass) => {
|
|
|
87
187
|
* Le comportement est ici modifié fonction de son mode (checkbox, radio, unique)
|
|
88
188
|
*/
|
|
89
189
|
getValueForFormPublisher() {
|
|
90
|
-
let
|
|
91
|
-
|
|
190
|
+
let formPublisher = this.getFormPublisher();
|
|
191
|
+
if (!formPublisher)
|
|
192
|
+
return null;
|
|
193
|
+
let currentValue = formPublisher[this.name].get();
|
|
92
194
|
if (this.radio) {
|
|
93
|
-
return this.checked && this.value != null ? this.value : currentValue;
|
|
195
|
+
return this.checked === true && this.value != null ? this.value : currentValue;
|
|
94
196
|
}
|
|
95
197
|
if (this.unique) {
|
|
96
|
-
return this.checked && this.value != null ? this.value : null;
|
|
198
|
+
return this.checked === true && this.value != null ? this.value : null;
|
|
97
199
|
}
|
|
98
200
|
if (!Array.isArray(currentValue)) {
|
|
99
201
|
currentValue = [];
|
|
100
202
|
}
|
|
101
203
|
currentValue = currentValue.slice(0);
|
|
102
204
|
let idx = currentValue.indexOf(this.value);
|
|
103
|
-
if (this.checked === true && idx === -1)
|
|
205
|
+
if (this.checked === true && idx === -1 && !this.checksAll())
|
|
104
206
|
currentValue.push(this.value);
|
|
105
|
-
if (this.checked === null && idx !== -1)
|
|
207
|
+
if (this.checked === null && idx !== -1) {
|
|
106
208
|
currentValue.splice(idx, 1);
|
|
209
|
+
}
|
|
107
210
|
return currentValue;
|
|
108
211
|
}
|
|
109
212
|
/**
|
|
@@ -118,15 +221,64 @@ const Form = (superClass) => {
|
|
|
118
221
|
}
|
|
119
222
|
if (!Array.isArray(value))
|
|
120
223
|
value = [];
|
|
224
|
+
if (this.checksAll()) {
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
121
227
|
this.checked = value.indexOf(this.value) !== -1 ? true : null;
|
|
122
228
|
}
|
|
123
|
-
|
|
124
|
-
|
|
229
|
+
getCheckAllPublisher() {
|
|
230
|
+
if (!this.formDataProvider)
|
|
231
|
+
this.formDataProvider = this.getAncestorAttributeValue("formDataProvider");
|
|
232
|
+
const formDataProvider = this.formDataProvider;
|
|
233
|
+
let name = this.getAttribute("name");
|
|
234
|
+
if (!formDataProvider || !name) {
|
|
235
|
+
return null;
|
|
236
|
+
}
|
|
237
|
+
return PublisherManager.get(formDataProvider + "/" + name + "/_available_values_");
|
|
238
|
+
}
|
|
239
|
+
disconnectedCallback() {
|
|
240
|
+
super.disconnectedCallback();
|
|
241
|
+
let checkAllPublisher = this.getCheckAllPublisher();
|
|
242
|
+
if (checkAllPublisher) {
|
|
243
|
+
checkAllPublisher.checkMode.offAssign(this.onChecksAllRequest);
|
|
244
|
+
if (!this.checksAll()) {
|
|
245
|
+
let values = checkAllPublisher.values.get().slice(0);
|
|
246
|
+
const idx = values.indexOf(this.value);
|
|
247
|
+
if (idx != -1) {
|
|
248
|
+
values.splice(idx, 1);
|
|
249
|
+
checkAllPublisher.values = values;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
setTimeout(() => this.updateAllChecked(), 1);
|
|
254
|
+
}
|
|
255
|
+
connectedCallback() {
|
|
256
|
+
super.connectedCallback();
|
|
257
|
+
const formPublisher = this.getFormPublisher();
|
|
258
|
+
if (formPublisher && this.name) {
|
|
259
|
+
let publisherValueForName = formPublisher[this.name].get();
|
|
260
|
+
if (publisherValueForName && publisherValueForName.indexOf(this.value) !== -1) {
|
|
261
|
+
this.checked = true;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
let checkAllPublisher = this.getCheckAllPublisher();
|
|
265
|
+
if (checkAllPublisher) {
|
|
266
|
+
checkAllPublisher.checkMode.onAssign(this.onChecksAllRequest);
|
|
267
|
+
if (this.checksAll()) {
|
|
268
|
+
checkAllPublisher.hasCheckAll = true;
|
|
269
|
+
}
|
|
270
|
+
if (!checkAllPublisher.values.get()) {
|
|
271
|
+
checkAllPublisher.values = [];
|
|
272
|
+
}
|
|
273
|
+
if (!this.checksAll()) {
|
|
274
|
+
checkAllPublisher.values = [...checkAllPublisher.values.get(), this.value];
|
|
275
|
+
}
|
|
276
|
+
}
|
|
125
277
|
if (!this.hasAttribute("checked")) {
|
|
126
278
|
return;
|
|
127
279
|
}
|
|
128
280
|
if (!this.publisher || this.publisher.get().checked !== false) {
|
|
129
|
-
this.checked = true;
|
|
281
|
+
setTimeout(() => (this.checked = true), 1);
|
|
130
282
|
}
|
|
131
283
|
}
|
|
132
284
|
}
|
|
@@ -142,6 +294,9 @@ const Form = (superClass) => {
|
|
|
142
294
|
__decorate([
|
|
143
295
|
property({ type: Boolean })
|
|
144
296
|
], FormCheckable.prototype, "radio", void 0);
|
|
297
|
+
__decorate([
|
|
298
|
+
property({ type: Boolean })
|
|
299
|
+
], FormCheckable.prototype, "unCheckOnDisconnect", void 0);
|
|
145
300
|
__decorate([
|
|
146
301
|
property()
|
|
147
302
|
], FormCheckable.prototype, "checked", null);
|
|
@@ -1,22 +1,27 @@
|
|
|
1
1
|
import { SubscriberInterface } from "@supersoniks/concorde/core/mixins/Subscriber";
|
|
2
|
+
import { PublisherInterface } from "../_types/types";
|
|
2
3
|
declare type Constructor<T> = new (...args: any[]) => T;
|
|
3
4
|
export interface FormElementInterface extends SubscriberInterface {
|
|
4
|
-
getFormPublisher():
|
|
5
|
+
getFormPublisher(): PublisherInterface;
|
|
5
6
|
updateDataValue(): void;
|
|
6
|
-
handleChange(e?:
|
|
7
|
-
handleBlur(e?:
|
|
7
|
+
handleChange(e?: Event): void;
|
|
8
|
+
handleBlur(e?: Event): void;
|
|
8
9
|
getValueForFormPublisher(): any;
|
|
10
|
+
focus?: () => void;
|
|
11
|
+
shadowRoot?: ShadowRoot;
|
|
9
12
|
error: boolean;
|
|
10
13
|
autofocus: boolean;
|
|
11
14
|
required: boolean;
|
|
12
15
|
disabled: true | null;
|
|
13
16
|
formDataProvider: string;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
+
ariaLabelledby?: string;
|
|
18
|
+
ariaLabel?: string;
|
|
19
|
+
_value: string | null;
|
|
20
|
+
get value(): string | null;
|
|
21
|
+
set value(value: string | null);
|
|
17
22
|
_name: string;
|
|
18
23
|
get name(): string;
|
|
19
24
|
set name(value: string);
|
|
20
25
|
}
|
|
21
|
-
declare const Form: <T extends Constructor<SubscriberInterface
|
|
26
|
+
declare const Form: <T extends Constructor<SubscriberInterface<any>>>(superClass: T) => Constructor<FormElementInterface> & T;
|
|
22
27
|
export default Form;
|
|
@@ -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;
|