@supersoniks/concorde 3.1.1 → 3.1.3
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/build-infos.json +1 -1
- package/concorde-core.bundle.js +132 -47
- package/concorde-core.es.js +188 -65
- package/dist/concorde-core.bundle.js +132 -47
- package/dist/concorde-core.es.js +188 -65
- package/dist/img/paul_metrand.jpg +0 -0
- package/dist/img/paul_metrand_xs.jpg +0 -0
- package/package.json +1 -1
- package/src/core/_types/types.ts +1 -0
- package/src/core/components/functional/submit/submit.ts +4 -3
- package/src/core/components/ui/captcha/captcha.ts +34 -16
- package/src/core/components/ui/form/input-autocomplete/input-autocomplete.ts +102 -35
- package/src/core/utils/PublisherProxy.ts +3 -2
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {Subscriber} from "@supersoniks/concorde/mixins";
|
|
2
|
-
import {PublisherManager} from "@supersoniks/concorde/utils";
|
|
3
|
-
import {html, LitElement} from "lit";
|
|
4
|
-
import {customElement, property} from "lit/decorators.js";
|
|
5
|
-
import {ConcordeWindow} from "@supersoniks/concorde/core/_types/types";
|
|
1
|
+
import { Subscriber } from "@supersoniks/concorde/mixins";
|
|
2
|
+
import { PublisherManager } from "@supersoniks/concorde/utils";
|
|
3
|
+
import { html, LitElement } from "lit";
|
|
4
|
+
import { customElement, property } from "lit/decorators.js";
|
|
5
|
+
import { ConcordeWindow } from "@supersoniks/concorde/core/_types/types";
|
|
6
6
|
import Publisher from "@supersoniks/concorde/core/utils/PublisherProxy";
|
|
7
7
|
|
|
8
8
|
declare const window: ConcordeWindow;
|
|
@@ -41,7 +41,8 @@ export class Captcha extends Subscriber(LitElement) {
|
|
|
41
41
|
}
|
|
42
42
|
super.connectedCallback();
|
|
43
43
|
this.formPublisher = PublisherManager.get(
|
|
44
|
-
this.getAncestorAttributeValue("headersDataProvider") ??
|
|
44
|
+
this.getAncestorAttributeValue("headersDataProvider") ??
|
|
45
|
+
this.getAncestorAttributeValue("formDataProvider")
|
|
45
46
|
);
|
|
46
47
|
|
|
47
48
|
// add css to document to force z-index
|
|
@@ -52,15 +53,24 @@ export class Captcha extends Subscriber(LitElement) {
|
|
|
52
53
|
document.head.appendChild(style);
|
|
53
54
|
}
|
|
54
55
|
|
|
55
|
-
if (
|
|
56
|
+
if (
|
|
57
|
+
this.formPublisher &&
|
|
58
|
+
!(this.formPublisher.captchaToken as Publisher<string>).get()
|
|
59
|
+
) {
|
|
56
60
|
this.formPublisher.needsCaptchaValidation = true;
|
|
57
|
-
(this.formPublisher.captchaToken as Publisher<string>).onAssign(
|
|
61
|
+
(this.formPublisher.captchaToken as Publisher<string>).onAssign(
|
|
62
|
+
this.onCaptchaTokenChanged
|
|
63
|
+
);
|
|
58
64
|
}
|
|
59
65
|
}
|
|
60
66
|
disconnectedCallback(): void {
|
|
61
67
|
if (this.formPublisher) {
|
|
62
|
-
(this.formPublisher.captchaToken as Publisher<string>).offAssign(
|
|
68
|
+
(this.formPublisher.captchaToken as Publisher<string>).offAssign(
|
|
69
|
+
this.onCaptchaTokenChanged
|
|
70
|
+
);
|
|
71
|
+
this.formPublisher.captchaToken = "";
|
|
63
72
|
}
|
|
73
|
+
|
|
64
74
|
super.disconnectedCallback();
|
|
65
75
|
}
|
|
66
76
|
requestToken() {
|
|
@@ -68,17 +78,25 @@ export class Captcha extends Subscriber(LitElement) {
|
|
|
68
78
|
|
|
69
79
|
// On récupère l'action liée au recaptcha,
|
|
70
80
|
// et on vérifie qu'il ne contienne que des caractères alpha-numériques, underscore et slash
|
|
71
|
-
const action = (
|
|
72
|
-
|
|
81
|
+
const action = (
|
|
82
|
+
this.action ??
|
|
83
|
+
this.formPublisher.captchaAction?.get() ??
|
|
84
|
+
"submit"
|
|
85
|
+
).replace(/[^\w_/]/g, "_");
|
|
86
|
+
const method = (
|
|
87
|
+
this.formPublisher.captchaMethod?.get() ?? "POST"
|
|
88
|
+
).toUpperCase();
|
|
73
89
|
delete this.formPublisher.captchaAction;
|
|
74
90
|
delete this.formPublisher.captchaMethod;
|
|
75
91
|
|
|
76
92
|
window.grecaptcha.ready(() => {
|
|
77
|
-
window.grecaptcha
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
93
|
+
window.grecaptcha
|
|
94
|
+
.execute(this.key, { action: method + "//" + action })
|
|
95
|
+
.then((token: string) => {
|
|
96
|
+
if (this.formPublisher) {
|
|
97
|
+
this.formPublisher.captchaToken = token;
|
|
98
|
+
}
|
|
99
|
+
});
|
|
82
100
|
});
|
|
83
101
|
}
|
|
84
102
|
|
|
@@ -1,17 +1,27 @@
|
|
|
1
|
-
import {html, LitElement, css, nothing} from "lit";
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { html, LitElement, css, nothing } from "lit";
|
|
2
|
+
import {
|
|
3
|
+
customElement,
|
|
4
|
+
property,
|
|
5
|
+
queryAssignedNodes,
|
|
6
|
+
state,
|
|
7
|
+
} from "lit/decorators.js";
|
|
8
|
+
import {
|
|
9
|
+
FormInput,
|
|
10
|
+
FormElement,
|
|
11
|
+
Subscriber,
|
|
12
|
+
TemplatesContainer,
|
|
13
|
+
} from "@supersoniks/concorde/mixins";
|
|
4
14
|
import "@supersoniks/concorde/core/components/ui/form/input/input";
|
|
5
15
|
import "@supersoniks/concorde/core/components/ui/pop/pop";
|
|
6
16
|
import "@supersoniks/concorde/core/components/functional/queue/queue";
|
|
7
17
|
import "@supersoniks/concorde/core/components/ui/menu/menu-item";
|
|
8
|
-
import {ifDefined} from "lit/directives/if-defined.js";
|
|
9
|
-
import {PublisherManager} from "@supersoniks/concorde/utils";
|
|
10
|
-
import {PublisherProxy} from "@supersoniks/concorde/core/utils/PublisherProxy";
|
|
11
|
-
import {Size} from "../../_css/size";
|
|
12
|
-
import {Input} from "@supersoniks/concorde/core/components/ui/form/input/input";
|
|
13
|
-
import {customScroll} from "@supersoniks/concorde/core/components/ui/_css/scroll";
|
|
14
|
-
import {ResizeController} from "@lit-labs/observers/resize-controller.js";
|
|
18
|
+
import { ifDefined } from "lit/directives/if-defined.js";
|
|
19
|
+
import { PublisherManager } from "@supersoniks/concorde/utils";
|
|
20
|
+
import { PublisherProxy } from "@supersoniks/concorde/core/utils/PublisherProxy";
|
|
21
|
+
import { Size } from "../../_css/size";
|
|
22
|
+
import { Input } from "@supersoniks/concorde/core/components/ui/form/input/input";
|
|
23
|
+
import { customScroll } from "@supersoniks/concorde/core/components/ui/_css/scroll";
|
|
24
|
+
import { ResizeController } from "@lit-labs/observers/resize-controller.js";
|
|
15
25
|
|
|
16
26
|
type ListItem = Record<string, string>;
|
|
17
27
|
|
|
@@ -21,7 +31,9 @@ type ListItem = Record<string, string>;
|
|
|
21
31
|
* La valeur de cet input est ensuite retransmit au premier via un dataProvider.
|
|
22
32
|
*/
|
|
23
33
|
@customElement("sonic-input-autocomplete")
|
|
24
|
-
export class InputAutocomplete extends TemplatesContainer(
|
|
34
|
+
export class InputAutocomplete extends TemplatesContainer(
|
|
35
|
+
FormInput(FormElement(Subscriber(LitElement)))
|
|
36
|
+
) {
|
|
25
37
|
static styles = [
|
|
26
38
|
customScroll,
|
|
27
39
|
css`
|
|
@@ -41,20 +53,20 @@ export class InputAutocomplete extends TemplatesContainer(FormInput(FormElement(
|
|
|
41
53
|
/**
|
|
42
54
|
* Possibles mutualisation avec text
|
|
43
55
|
*/
|
|
44
|
-
@property({type: String}) size: Size = "md";
|
|
45
|
-
@property({type: String}) placeholder = "";
|
|
56
|
+
@property({ type: String }) size: Size = "md";
|
|
57
|
+
@property({ type: String }) placeholder = "";
|
|
46
58
|
@property() filteredFields = "";
|
|
47
|
-
@property({type: Boolean}) readonly: boolean | null = null;
|
|
59
|
+
@property({ type: Boolean }) readonly: boolean | null = null;
|
|
48
60
|
|
|
49
|
-
@property({type: String}) dataProviderExpression = "";
|
|
50
|
-
@property({type: Boolean}) select?: boolean;
|
|
51
|
-
@property({type: String}) key = "";
|
|
61
|
+
@property({ type: String }) dataProviderExpression = "";
|
|
62
|
+
@property({ type: Boolean }) select?: boolean;
|
|
63
|
+
@property({ type: String }) key = "";
|
|
52
64
|
/** The parameter name to use in dataProviderExpression route */
|
|
53
|
-
@property({type: String}) searchParameter = "";
|
|
65
|
+
@property({ type: String }) searchParameter = "";
|
|
54
66
|
/** The property name to search in the dataProviderExpression result, use "_self" if result is a string list */
|
|
55
|
-
@property({type: String}) propertyName = "";
|
|
67
|
+
@property({ type: String }) propertyName = "";
|
|
56
68
|
|
|
57
|
-
@queryAssignedNodes({slot: "prefix", flatten: true})
|
|
69
|
+
@queryAssignedNodes({ slot: "prefix", flatten: true })
|
|
58
70
|
slotInputPrefixNodes!: Array<Node>;
|
|
59
71
|
|
|
60
72
|
@state() hasInputPrefix = false;
|
|
@@ -88,9 +100,14 @@ export class InputAutocomplete extends TemplatesContainer(FormInput(FormElement(
|
|
|
88
100
|
private updateSearchParameter = (value: string) => {
|
|
89
101
|
if (value == "") {
|
|
90
102
|
this.lastValidSearch = "";
|
|
103
|
+
|
|
91
104
|
return;
|
|
92
105
|
}
|
|
93
|
-
const found = this.queryQueueListItem(
|
|
106
|
+
const found = this.queryQueueListItem(
|
|
107
|
+
this.queueDataProvider,
|
|
108
|
+
this.findSelection,
|
|
109
|
+
this.setSearchFromSelection
|
|
110
|
+
);
|
|
94
111
|
// Si la liste de this.queueDataProvider est bien initialisée, mais qu'aucun item ne correspond à la recherche
|
|
95
112
|
// On affiche quand même la valeur dans le champ de recherche, car il provient directement du formDataProvider
|
|
96
113
|
if (found === false) {
|
|
@@ -100,31 +117,58 @@ export class InputAutocomplete extends TemplatesContainer(FormInput(FormElement(
|
|
|
100
117
|
};
|
|
101
118
|
|
|
102
119
|
private initSearchParameter = () => {
|
|
103
|
-
this.queryQueueListItem(
|
|
120
|
+
this.queryQueueListItem(
|
|
121
|
+
this.initQueueDataProvider,
|
|
122
|
+
this.findSelection,
|
|
123
|
+
this.setSearchFromSelection
|
|
124
|
+
);
|
|
104
125
|
};
|
|
105
126
|
|
|
106
127
|
private selectListItem = (listItem: ListItem) => {
|
|
107
|
-
const value =
|
|
128
|
+
const value =
|
|
129
|
+
this.propertyName === "_self"
|
|
130
|
+
? listItem
|
|
131
|
+
: listItem[this.propertyName || this.name];
|
|
108
132
|
this.formValuePublisher?.set(value);
|
|
109
133
|
};
|
|
110
134
|
|
|
111
135
|
private findSearchedItem = (listItem: ListItem) => {
|
|
112
|
-
|
|
136
|
+
console.log(this.propertyName);
|
|
137
|
+
|
|
138
|
+
const value =
|
|
139
|
+
this.propertyName === "_self"
|
|
140
|
+
? listItem
|
|
141
|
+
: listItem[this.propertyName || this.searchParameter || this.name];
|
|
113
142
|
return value == this.searchPublisher?.get();
|
|
114
143
|
};
|
|
115
144
|
|
|
116
145
|
private findSelection = (listItem: ListItem) => {
|
|
117
|
-
const value =
|
|
146
|
+
const value =
|
|
147
|
+
this.propertyName === "_self"
|
|
148
|
+
? listItem
|
|
149
|
+
: listItem[this.propertyName || this.name];
|
|
118
150
|
return value == this.value;
|
|
119
151
|
};
|
|
120
152
|
|
|
121
153
|
private setSearchFromSelection = (listItem: ListItem) => {
|
|
122
|
-
this.lastValidSearch =
|
|
154
|
+
this.lastValidSearch =
|
|
155
|
+
this.propertyName === "_self"
|
|
156
|
+
? listItem
|
|
157
|
+
: listItem[this.searchParameter || this.propertyName || this.name];
|
|
123
158
|
this.searchPublisher?.set(this.lastValidSearch);
|
|
124
159
|
};
|
|
125
160
|
private updateActiveSelection = () => {
|
|
126
|
-
this.queryQueueListItem(
|
|
127
|
-
|
|
161
|
+
this.queryQueueListItem(
|
|
162
|
+
this.queueDataProvider,
|
|
163
|
+
this.findSearchedItem,
|
|
164
|
+
this.selectListItem
|
|
165
|
+
);
|
|
166
|
+
if (
|
|
167
|
+
!this.select &&
|
|
168
|
+
this.lastValidSearch &&
|
|
169
|
+
this.lastValidSearch != this.searchPublisher?.get() &&
|
|
170
|
+
this.formValuePublisher?.get()
|
|
171
|
+
) {
|
|
128
172
|
this.formValuePublisher?.set("");
|
|
129
173
|
}
|
|
130
174
|
};
|
|
@@ -153,10 +197,14 @@ export class InputAutocomplete extends TemplatesContainer(FormInput(FormElement(
|
|
|
153
197
|
* Les publishers utilisés plusieurs fois dans la classe son miss en propriétés privées de la classe
|
|
154
198
|
*/
|
|
155
199
|
const getPublisher = PublisherManager.get;
|
|
156
|
-
this.searchPublisher = getPublisher(this.searchDataProvider)[
|
|
200
|
+
this.searchPublisher = getPublisher(this.searchDataProvider)[
|
|
201
|
+
searchParameter
|
|
202
|
+
];
|
|
157
203
|
this.formValuePublisher = getPublisher(formDataProvider)[this.name];
|
|
158
204
|
this.countPublisher = getPublisher(this.queueDataProvider).resultCount;
|
|
159
|
-
this.initCountPublisher = getPublisher(
|
|
205
|
+
this.initCountPublisher = getPublisher(
|
|
206
|
+
this.initQueueDataProvider
|
|
207
|
+
).resultCount;
|
|
160
208
|
|
|
161
209
|
/**
|
|
162
210
|
* Si une valeur est fourrnie a l'initialisation, un queue spécifique appelle le service avec le name founi en paramètre
|
|
@@ -198,7 +246,11 @@ export class InputAutocomplete extends TemplatesContainer(FormInput(FormElement(
|
|
|
198
246
|
*
|
|
199
247
|
* @return bool|undefined True if item found, false otherwise, undefined if result is not a list
|
|
200
248
|
*/
|
|
201
|
-
queryQueueListItem(
|
|
249
|
+
queryQueueListItem(
|
|
250
|
+
queueDataProvider: string,
|
|
251
|
+
itemFinder: (listItem: ListItem) => boolean,
|
|
252
|
+
itemMutator: (listItem: ListItem) => void
|
|
253
|
+
) {
|
|
202
254
|
const queuePublisher = PublisherManager.get(queueDataProvider);
|
|
203
255
|
let listItem: ListItem | undefined;
|
|
204
256
|
const listsDescriptors = queuePublisher.get();
|
|
@@ -250,20 +302,35 @@ export class InputAutocomplete extends TemplatesContainer(FormInput(FormElement(
|
|
|
250
302
|
inlineContent
|
|
251
303
|
size=${this.size}
|
|
252
304
|
>
|
|
253
|
-
<slot
|
|
305
|
+
<slot
|
|
306
|
+
name="prefix"
|
|
307
|
+
slot="prefix"
|
|
308
|
+
@slotchange=${this.hasSlotOrProps}
|
|
309
|
+
></slot>
|
|
254
310
|
|
|
255
311
|
${this.select
|
|
256
|
-
? html`
|
|
312
|
+
? html`
|
|
313
|
+
<sonic-icon
|
|
314
|
+
slot="suffix"
|
|
315
|
+
class="select-chevron"
|
|
316
|
+
name="nav-arrow-down"
|
|
317
|
+
.size=${this.size}
|
|
318
|
+
></sonic-icon>
|
|
319
|
+
`
|
|
257
320
|
: nothing}
|
|
258
321
|
</sonic-input>
|
|
259
|
-
<sonic-menu
|
|
322
|
+
<sonic-menu
|
|
323
|
+
slot="content"
|
|
324
|
+
class="custom-scroll"
|
|
325
|
+
style="${this.offsetWidth ? `width: ${this.offsetWidth}px` : ""}"
|
|
326
|
+
>
|
|
260
327
|
<sonic-queue
|
|
261
328
|
dataProvider="${this.queueDataProvider}"
|
|
262
329
|
filteredFields=${this.filteredFields}
|
|
263
330
|
dataProviderExpression="${this.dataProviderExpression}"
|
|
264
331
|
dataFilterProvider="${this.searchDataProvider}"
|
|
265
332
|
key="${this.key}"
|
|
266
|
-
.templates=${this.templateList}
|
|
333
|
+
.templates=${this.templateList.concat(this.templatePartsList)}
|
|
267
334
|
displayContents
|
|
268
335
|
>
|
|
269
336
|
</sonic-queue>
|
|
@@ -77,8 +77,9 @@ export class PublisherProxy<T = any> {
|
|
|
77
77
|
* Supprime les écouteurs associés
|
|
78
78
|
*/
|
|
79
79
|
delete() {
|
|
80
|
-
for (const
|
|
81
|
-
|
|
80
|
+
for (const key in this._proxies_.keys()) {
|
|
81
|
+
if ((key as string) == "_parent_") continue;
|
|
82
|
+
this._proxies_.get(key)?.delete();
|
|
82
83
|
}
|
|
83
84
|
this._invalidateListeners_.clear();
|
|
84
85
|
this._assignListeners_.clear();
|