@supersoniks/concorde 1.1.47 → 1.1.48
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 +16 -16
- package/concorde-core.es.js +254 -96
- package/core/components/functional/fetch/fetch.d.ts +4 -0
- package/core/components/functional/list/list.d.ts +4 -0
- package/core/components/functional/queue/queue.d.ts +2 -0
- package/core/components/functional/queue/queue.js +37 -11
- package/core/components/functional/sdui/sdui.d.ts +4 -0
- package/core/components/ui/badge/badge.js +3 -4
- package/core/components/ui/button/button.d.ts +4 -0
- package/core/components/ui/form/checkbox/checkbox.d.ts +8 -0
- package/core/components/ui/form/css/form-control.js +7 -5
- package/core/components/ui/form/form-layout/form-layout.js +3 -1
- package/core/components/ui/form/input/input.d.ts +8 -1
- package/core/components/ui/form/input/input.js +10 -3
- package/core/components/ui/form/input-autocomplete/input-autocomplete.d.ts +102 -13
- package/core/components/ui/form/input-autocomplete/input-autocomplete.js +212 -53
- package/core/components/ui/form/textarea/textarea.d.ts +4 -0
- package/core/components/ui/modal/modal.d.ts +2 -0
- package/core/components/ui/modal/modal.js +6 -3
- package/core/components/ui/pop/pop.js +17 -6
- package/core/decorators/Subscriber.d.ts +3 -0
- package/core/decorators/Subscriber.js +78 -0
- package/core/mixins/Fetcher.d.ts +7 -1
- package/core/mixins/FormCheckable.d.ts +4 -0
- package/core/mixins/FormElement.d.ts +1 -0
- package/core/mixins/FormElement.js +6 -2
- package/core/mixins/FormInput.d.ts +5 -4
- package/core/mixins/Subscriber.d.ts +4 -0
- package/core/mixins/Subscriber.js +30 -4
- package/mixins.d.ts +12 -0
- package/package.json +2 -2
- package/concorde-customer.bundle.js +0 -129
- package/concorde-customer.es.js +0 -22004
|
@@ -4,111 +4,261 @@ 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 { html, LitElement, css } from "lit";
|
|
8
|
-
import { customElement, property } from "lit/decorators.js";
|
|
9
|
-
import { Subscriber, TemplatesContainer } from "@supersoniks/concorde/mixins";
|
|
7
|
+
import { html, LitElement, css, nothing } from "lit";
|
|
8
|
+
import { customElement, property, queryAssignedNodes, state, } from "lit/decorators.js";
|
|
9
|
+
import { FormInput, FormElement, Subscriber, TemplatesContainer, } from "@supersoniks/concorde/mixins";
|
|
10
10
|
import "@supersoniks/concorde/core/components/ui/form/input/input";
|
|
11
11
|
import "@supersoniks/concorde/core/components/ui/pop/pop";
|
|
12
12
|
import "@supersoniks/concorde/core/components/functional/queue/queue";
|
|
13
13
|
import "@supersoniks/concorde/core/components/ui/menu/menu-item";
|
|
14
14
|
import { ifDefined } from "lit/directives/if-defined.js";
|
|
15
|
+
import { PublisherManager } from "@supersoniks/concorde/utils";
|
|
16
|
+
import { customScroll } from "@supersoniks/concorde/core/components/ui/_css/scroll";
|
|
17
|
+
import { ResizeController } from "@lit-labs/observers/resize_controller.js";
|
|
15
18
|
/**
|
|
16
19
|
* Input avec autocomplete. Propose des valeurs à partir d'un sonic-queue.
|
|
17
20
|
* L'input permet de filtrer les choix de valeurs dans le sonic-pop.
|
|
18
21
|
* La valeur de cet input est ensuite retransmit au premier via un dataProvider.
|
|
19
22
|
*/
|
|
20
|
-
let InputAutocomplete = class InputAutocomplete extends TemplatesContainer(Subscriber(LitElement)) {
|
|
23
|
+
let InputAutocomplete = class InputAutocomplete extends TemplatesContainer(FormInput(FormElement(Subscriber(LitElement)))) {
|
|
21
24
|
constructor() {
|
|
22
25
|
super(...arguments);
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
+
/**
|
|
27
|
+
* Possibles mutualisation avec text
|
|
28
|
+
*/
|
|
29
|
+
this.size = "md";
|
|
26
30
|
this.placeholder = "";
|
|
27
31
|
this.filteredFields = "";
|
|
28
32
|
this.readonly = null;
|
|
29
33
|
this.dataProviderExpression = "";
|
|
30
34
|
this.key = "";
|
|
31
|
-
this.
|
|
32
|
-
this.
|
|
35
|
+
this.searchParameter = "";
|
|
36
|
+
this.hasInputPrefix = false;
|
|
37
|
+
this._resizeController = new ResizeController(this, {});
|
|
38
|
+
/**
|
|
39
|
+
* Les dataProviders
|
|
40
|
+
*/
|
|
41
|
+
this.searchDataProvider = "";
|
|
42
|
+
this.initSearchDataProvider = "";
|
|
43
|
+
this.queueDataProvider = "";
|
|
44
|
+
this.initQueueDataProvider = "";
|
|
45
|
+
this.lastValidSearch = "";
|
|
46
|
+
this.updateSearchParameter = (value) => {
|
|
47
|
+
if (value == "") {
|
|
48
|
+
this.lastValidSearch = "";
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
this.queryQueueListItem(this.queueDataProvider, this.findSelection, this.setSearchFromSelection);
|
|
52
|
+
};
|
|
53
|
+
this.initSearchParameter = () => {
|
|
54
|
+
this.queryQueueListItem(this.initQueueDataProvider, this.findSelection, this.setSearchFromSelection);
|
|
55
|
+
};
|
|
56
|
+
this.selectListItem = (listItem) => {
|
|
57
|
+
var _a;
|
|
58
|
+
(_a = this.formValuePublisher) === null || _a === void 0 ? void 0 : _a.set(listItem[this.name]);
|
|
59
|
+
};
|
|
60
|
+
this.findSearchedItem = (listItem) => {
|
|
61
|
+
var _a;
|
|
62
|
+
return (listItem[this.searchParameter || this.name] == ((_a = this.searchPublisher) === null || _a === void 0 ? void 0 : _a.get()));
|
|
63
|
+
};
|
|
64
|
+
this.findSelection = (listItem) => {
|
|
65
|
+
return listItem[this.name] == this.value;
|
|
66
|
+
};
|
|
67
|
+
this.setSearchFromSelection = (listItem) => {
|
|
68
|
+
var _a;
|
|
69
|
+
this.lastValidSearch = listItem[this.searchParameter || this.name];
|
|
70
|
+
(_a = this.searchPublisher) === null || _a === void 0 ? void 0 : _a.set(this.lastValidSearch);
|
|
71
|
+
};
|
|
72
|
+
this.updateActiveSelection = () => {
|
|
73
|
+
var _a, _b, _c;
|
|
74
|
+
this.queryQueueListItem(this.queueDataProvider, this.findSearchedItem, this.selectListItem);
|
|
75
|
+
if (!this.select &&
|
|
76
|
+
this.lastValidSearch &&
|
|
77
|
+
this.lastValidSearch != ((_a = this.searchPublisher) === null || _a === void 0 ? void 0 : _a.get()) &&
|
|
78
|
+
((_b = this.formValuePublisher) === null || _b === void 0 ? void 0 : _b.get())) {
|
|
79
|
+
(_c = this.formValuePublisher) === null || _c === void 0 ? void 0 : _c.set("");
|
|
80
|
+
}
|
|
81
|
+
};
|
|
33
82
|
}
|
|
34
|
-
|
|
35
|
-
|
|
83
|
+
/**
|
|
84
|
+
* Les fonctions de gestion
|
|
85
|
+
*/
|
|
86
|
+
hasSlotOrProps() {
|
|
87
|
+
var _a;
|
|
88
|
+
this.hasInputPrefix = !!((_a = this.slotInputPrefixNodes) === null || _a === void 0 ? void 0 : _a.length);
|
|
36
89
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
90
|
+
connectedCallback() {
|
|
91
|
+
var _a, _b, _c;
|
|
92
|
+
super.connectedCallback();
|
|
93
|
+
/**
|
|
94
|
+
* Nom de la valeur de recherche
|
|
95
|
+
* Si non défini, on utilise name
|
|
96
|
+
**/
|
|
97
|
+
const searchParameter = this.searchParameter || this.name;
|
|
98
|
+
/**
|
|
99
|
+
* Nommage des différents dataProviders utilisés
|
|
100
|
+
*/
|
|
101
|
+
const formDataProvider = this.getAncestorAttributeValue("formDataProvider");
|
|
102
|
+
const dpPrefix = formDataProvider + "__autocomplete";
|
|
103
|
+
this.initSearchDataProvider = `${dpPrefix}_init_search__`;
|
|
104
|
+
this.initQueueDataProvider = `${dpPrefix}_init_queue__`;
|
|
105
|
+
this.searchDataProvider = `${dpPrefix}_search__`;
|
|
106
|
+
this.queueDataProvider = `${dpPrefix}_queue__`;
|
|
107
|
+
/**
|
|
108
|
+
* Les publishers utilisés plusieurs fois dans la classe son miss en propriétés privées de la classe
|
|
109
|
+
*/
|
|
110
|
+
const getPublisher = PublisherManager.get;
|
|
111
|
+
this.searchPublisher = getPublisher(this.searchDataProvider)[searchParameter];
|
|
112
|
+
this.formValuePublisher = getPublisher(formDataProvider)[this.name];
|
|
113
|
+
this.countPublisher = getPublisher(this.queueDataProvider).resultCount;
|
|
114
|
+
this.initCountPublisher = getPublisher(this.initQueueDataProvider).resultCount;
|
|
115
|
+
/**
|
|
116
|
+
* Si une valeur est fourrnie a l'initialisation, un queue spécifique appelle le service avec le name founi en paramètre
|
|
117
|
+
* Pour récupérer la valeur de searchParameter correspondante et renseigner l'input
|
|
118
|
+
**/
|
|
119
|
+
if (this.value) {
|
|
120
|
+
PublisherManager.get(this.initSearchDataProvider)[this.name] = this.value;
|
|
121
|
+
}
|
|
122
|
+
(_a = this.initCountPublisher) === null || _a === void 0 ? void 0 : _a.onAssign(this.initSearchParameter);
|
|
123
|
+
/**
|
|
124
|
+
* Lorsque la sélection change, on met à jour la valeur de recherche
|
|
125
|
+
*/
|
|
126
|
+
(_b = this.formValuePublisher) === null || _b === void 0 ? void 0 : _b.onAssign(this.updateSearchParameter);
|
|
127
|
+
/**
|
|
128
|
+
* Lorsque La valeur de recherche change, que le composant n'est pas en mode select
|
|
129
|
+
* et qu'elle est différente de la derniere recherche valide on désactive la selection
|
|
130
|
+
*/
|
|
131
|
+
(_c = this.countPublisher) === null || _c === void 0 ? void 0 : _c.onAssign(this.updateActiveSelection);
|
|
42
132
|
}
|
|
43
|
-
|
|
44
|
-
|
|
133
|
+
disconnectedCallback() {
|
|
134
|
+
var _a, _b, _c;
|
|
135
|
+
super.disconnectedCallback();
|
|
136
|
+
(_a = this.initCountPublisher) === null || _a === void 0 ? void 0 : _a.offAssign(this.initSearchParameter);
|
|
137
|
+
(_b = this.formValuePublisher) === null || _b === void 0 ? void 0 : _b.offAssign(this.updateSearchParameter);
|
|
138
|
+
(_c = this.countPublisher) === null || _c === void 0 ? void 0 : _c.offAssign(this.updateActiveSelection);
|
|
139
|
+
const getPublisher = PublisherManager.get;
|
|
140
|
+
getPublisher(this.initSearchDataProvider).delete();
|
|
141
|
+
getPublisher(this.initQueueDataProvider).delete();
|
|
142
|
+
getPublisher(this.searchDataProvider).delete();
|
|
143
|
+
getPublisher(this.queueDataProvider).delete();
|
|
45
144
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
145
|
+
queryQueueListItem(queueDataProvider, itemFinder, itemMutator) {
|
|
146
|
+
const queuePublisher = PublisherManager.get(queueDataProvider);
|
|
147
|
+
let listItem;
|
|
148
|
+
const listsDescriptors = queuePublisher.get();
|
|
149
|
+
if (!Array.isArray(listsDescriptors))
|
|
150
|
+
return;
|
|
151
|
+
for (const listDescriptor of listsDescriptors) {
|
|
152
|
+
const list = PublisherManager.get(listDescriptor.dataProvider).get();
|
|
153
|
+
if (!Array.isArray(list))
|
|
154
|
+
continue;
|
|
155
|
+
listItem = list.find(itemFinder);
|
|
156
|
+
if (listItem) {
|
|
157
|
+
break;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
if (listItem) {
|
|
161
|
+
itemMutator(listItem);
|
|
162
|
+
}
|
|
51
163
|
}
|
|
52
|
-
|
|
53
|
-
|
|
164
|
+
setSelectionRange(start, end) {
|
|
165
|
+
var _a;
|
|
166
|
+
(_a = this.querySelector("sonic-input")) === null || _a === void 0 ? void 0 : _a.setSelectionRange(start, end);
|
|
54
167
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
this.
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
168
|
+
handleHide() {
|
|
169
|
+
var _a, _b, _c;
|
|
170
|
+
if (!this.select)
|
|
171
|
+
return;
|
|
172
|
+
if (((_a = this.searchPublisher) === null || _a === void 0 ? void 0 : _a.get()) == "") {
|
|
173
|
+
this.lastValidSearch = "";
|
|
174
|
+
(_b = this.formValuePublisher) === null || _b === void 0 ? void 0 : _b.set("");
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
(_c = this.searchPublisher) === null || _c === void 0 ? void 0 : _c.set(this.lastValidSearch);
|
|
64
178
|
}
|
|
65
179
|
render() {
|
|
66
180
|
return html `
|
|
67
|
-
<sonic-pop noToggle style="display:block;">
|
|
181
|
+
<sonic-pop noToggle style="display:block;" @hide=${this.handleHide}>
|
|
68
182
|
<sonic-input
|
|
183
|
+
dataProvider="${this.initSearchDataProvider + Math.random()}"
|
|
184
|
+
formDataProvider="${this.searchDataProvider}"
|
|
69
185
|
type="search"
|
|
70
|
-
data-keyboard-nav="nav
|
|
186
|
+
data-keyboard-nav="${this.getAttribute("data-keyboard-nav") || ""}"
|
|
71
187
|
label="${ifDefined(this.label)}"
|
|
72
188
|
description="${ifDefined(this.description)}"
|
|
73
|
-
name="${ifDefined(this.name)}"
|
|
74
|
-
|
|
189
|
+
name="${ifDefined(this.searchParameter || this.name)}"
|
|
190
|
+
placeholder="${ifDefined(this.placeholder)}"
|
|
191
|
+
?readonly="${this.readonly}"
|
|
75
192
|
autocomplete="off"
|
|
76
193
|
clearable
|
|
77
|
-
|
|
78
|
-
|
|
194
|
+
inlineContent
|
|
195
|
+
size=${this.size}
|
|
196
|
+
>
|
|
197
|
+
<slot
|
|
198
|
+
name="prefix"
|
|
199
|
+
slot="prefix"
|
|
200
|
+
@slotchange=${this.hasSlotOrProps}
|
|
201
|
+
></slot>
|
|
202
|
+
|
|
203
|
+
${this.select
|
|
204
|
+
? html `
|
|
205
|
+
<sonic-icon
|
|
206
|
+
slot="suffix"
|
|
207
|
+
class="select-chevron"
|
|
208
|
+
name="nav-arrow-down"
|
|
209
|
+
.size=${this.size}
|
|
210
|
+
></sonic-icon>
|
|
211
|
+
`
|
|
212
|
+
: nothing}
|
|
213
|
+
</sonic-input>
|
|
214
|
+
<sonic-menu
|
|
215
|
+
slot="content"
|
|
216
|
+
class="custom-scroll"
|
|
217
|
+
style="${this.offsetWidth ? `width: ${this.offsetWidth}px` : ""}"
|
|
218
|
+
>
|
|
79
219
|
<sonic-queue
|
|
220
|
+
dataProvider="${this.queueDataProvider}"
|
|
80
221
|
filteredFields=${this.filteredFields}
|
|
81
222
|
dataProviderExpression="${this.dataProviderExpression}"
|
|
82
|
-
dataFilterProvider="${this.
|
|
223
|
+
dataFilterProvider="${this.searchDataProvider}"
|
|
83
224
|
key="${this.key}"
|
|
84
225
|
.templates=${this.templateList}
|
|
85
226
|
displayContents
|
|
86
227
|
>
|
|
87
228
|
</sonic-queue>
|
|
229
|
+
<sonic-queue
|
|
230
|
+
noLazyload
|
|
231
|
+
dataProvider="${this.initQueueDataProvider}"
|
|
232
|
+
filteredFields=${this.filteredFields}
|
|
233
|
+
dataProviderExpression="${this.dataProviderExpression}"
|
|
234
|
+
dataFilterProvider="${this.initSearchDataProvider}"
|
|
235
|
+
key="${this.key}"
|
|
236
|
+
displayContents
|
|
237
|
+
>
|
|
238
|
+
</sonic-queue>
|
|
88
239
|
</sonic-menu>
|
|
89
240
|
</sonic-pop>
|
|
90
241
|
`;
|
|
91
242
|
}
|
|
92
243
|
};
|
|
93
244
|
InputAutocomplete.styles = [
|
|
245
|
+
customScroll,
|
|
94
246
|
css `
|
|
95
247
|
:host {
|
|
96
248
|
display: block;
|
|
97
249
|
}
|
|
250
|
+
|
|
251
|
+
sonic-menu {
|
|
252
|
+
display: block;
|
|
253
|
+
max-height: clamp(20rem, 55vh, 35rem);
|
|
254
|
+
min-width: 14rem;
|
|
255
|
+
width: 100%;
|
|
256
|
+
}
|
|
98
257
|
`,
|
|
99
258
|
];
|
|
100
259
|
__decorate([
|
|
101
|
-
property()
|
|
102
|
-
], InputAutocomplete.prototype, "
|
|
103
|
-
__decorate([
|
|
104
|
-
property()
|
|
105
|
-
], InputAutocomplete.prototype, "forceAutoFill", void 0);
|
|
106
|
-
__decorate([
|
|
107
|
-
property()
|
|
108
|
-
], InputAutocomplete.prototype, "description", null);
|
|
109
|
-
__decorate([
|
|
110
|
-
property()
|
|
111
|
-
], InputAutocomplete.prototype, "label", null);
|
|
260
|
+
property({ type: String })
|
|
261
|
+
], InputAutocomplete.prototype, "size", void 0);
|
|
112
262
|
__decorate([
|
|
113
263
|
property({ type: String })
|
|
114
264
|
], InputAutocomplete.prototype, "placeholder", void 0);
|
|
@@ -121,12 +271,21 @@ __decorate([
|
|
|
121
271
|
__decorate([
|
|
122
272
|
property({ type: String })
|
|
123
273
|
], InputAutocomplete.prototype, "dataProviderExpression", void 0);
|
|
274
|
+
__decorate([
|
|
275
|
+
property({ type: Boolean })
|
|
276
|
+
], InputAutocomplete.prototype, "select", void 0);
|
|
124
277
|
__decorate([
|
|
125
278
|
property({ type: String })
|
|
126
279
|
], InputAutocomplete.prototype, "key", void 0);
|
|
127
280
|
__decorate([
|
|
128
281
|
property({ type: String })
|
|
129
|
-
], InputAutocomplete.prototype, "
|
|
282
|
+
], InputAutocomplete.prototype, "searchParameter", void 0);
|
|
283
|
+
__decorate([
|
|
284
|
+
queryAssignedNodes({ slot: "prefix" })
|
|
285
|
+
], InputAutocomplete.prototype, "slotInputPrefixNodes", void 0);
|
|
286
|
+
__decorate([
|
|
287
|
+
state()
|
|
288
|
+
], InputAutocomplete.prototype, "hasInputPrefix", void 0);
|
|
130
289
|
InputAutocomplete = __decorate([
|
|
131
290
|
customElement("sonic-input-autocomplete")
|
|
132
291
|
], InputAutocomplete);
|
|
@@ -56,6 +56,10 @@ declare const Textarea_base: {
|
|
|
56
56
|
hasAttribute(attributeName: string): boolean;
|
|
57
57
|
disconnectedCallback(): void;
|
|
58
58
|
getBoundingClientRect(): DOMRect;
|
|
59
|
+
onConnected(callback: (component: any) => void): void;
|
|
60
|
+
offConnected(callback: (component: any) => void): void;
|
|
61
|
+
onDisconnected(callback: (component: any) => void): void;
|
|
62
|
+
offDisconnected(callback: (component: any) => void): void;
|
|
59
63
|
};
|
|
60
64
|
} & (new (...args: any[]) => import("@supersoniks/concorde/core/mixins/FormElement").FormElementInterface) & (new (...args: any[]) => import("@supersoniks/concorde/core/mixins/Subscriber").SubscriberInterface<import("../../../../_types/types").CoreJSType>) & typeof LitElement;
|
|
61
65
|
export declare class Textarea extends Textarea_base {
|
|
@@ -11,6 +11,8 @@ declare type ModalCreateOptions = {
|
|
|
11
11
|
paddingY?: string;
|
|
12
12
|
width?: string;
|
|
13
13
|
maxWidth?: string;
|
|
14
|
+
height?: string;
|
|
15
|
+
maxHeight?: string;
|
|
14
16
|
removeOnHide?: boolean;
|
|
15
17
|
};
|
|
16
18
|
declare const Modal_base: (new (...args: any[]) => import("@supersoniks/concorde/core/mixins/Subscriber").SubscriberInterface<import("@supersoniks/concorde/core/_types/types").CoreJSType>) & typeof LitElement;
|
|
@@ -41,6 +41,10 @@ let Modal = class Modal extends Subscriber(LitElement) {
|
|
|
41
41
|
modal.maxWidth = options === null || options === void 0 ? void 0 : options.maxWidth;
|
|
42
42
|
if (options.width)
|
|
43
43
|
modal.width = options === null || options === void 0 ? void 0 : options.width;
|
|
44
|
+
if (options.maxHeight)
|
|
45
|
+
modal.maxHeight = options === null || options === void 0 ? void 0 : options.maxHeight;
|
|
46
|
+
if (options.height)
|
|
47
|
+
modal.height = options === null || options === void 0 ? void 0 : options.height;
|
|
44
48
|
if (options.paddingX)
|
|
45
49
|
modal.style.setProperty("--sc-modal-px", options === null || options === void 0 ? void 0 : options.paddingX);
|
|
46
50
|
if (options.paddingY)
|
|
@@ -48,8 +52,7 @@ let Modal = class Modal extends Subscriber(LitElement) {
|
|
|
48
52
|
if (options.zIndex)
|
|
49
53
|
modal.style.setProperty("--sc-modal-z-index", options === null || options === void 0 ? void 0 : options.zIndex);
|
|
50
54
|
// inner content
|
|
51
|
-
modal.innerHTML =
|
|
52
|
-
`<sonic-modal-close></sonic-modal-close><sonic-modal-content>${options.content}</sonic-modal-content>` || "";
|
|
55
|
+
modal.innerHTML = `<sonic-modal-close></sonic-modal-close><sonic-modal-content>${options.content}</sonic-modal-content>` || "";
|
|
53
56
|
const container = document.querySelector("sonic-theme") || document.body;
|
|
54
57
|
container.appendChild(modal);
|
|
55
58
|
modal.show();
|
|
@@ -182,7 +185,7 @@ Modal.styles = [
|
|
|
182
185
|
--sc-modal-py: 2.5rem;
|
|
183
186
|
--sc-modal-px: 1.5rem;
|
|
184
187
|
--sc-modal-max-w: min(100vw, 64ch);
|
|
185
|
-
--sc-modal-max-h:
|
|
188
|
+
--sc-modal-max-h: 85vh;
|
|
186
189
|
--sc-modal-rounded: var(--sc-rounded-lg);
|
|
187
190
|
--sc-modal-z-index: 990;
|
|
188
191
|
}
|
|
@@ -51,11 +51,13 @@ let Pop = Pop_1 = class Pop extends LitElement {
|
|
|
51
51
|
this.lastContentY = 0;
|
|
52
52
|
this.runPositioningLoop();
|
|
53
53
|
}
|
|
54
|
+
this.dispatchEvent(new CustomEvent("show"));
|
|
54
55
|
}
|
|
55
56
|
_hide() {
|
|
56
57
|
this.open = false;
|
|
57
58
|
this.popContent.setAttribute("tabindex", "-1");
|
|
58
59
|
this.positioningRuns = false;
|
|
60
|
+
this.dispatchEvent(new CustomEvent("hide"));
|
|
59
61
|
}
|
|
60
62
|
_handleClosePop(e) {
|
|
61
63
|
const path = e.composedPath();
|
|
@@ -66,7 +68,8 @@ let Pop = Pop_1 = class Pop extends LitElement {
|
|
|
66
68
|
const isCloseManual = HTML.getAncestorAttributeValue(target, "data-on-select") === "keep";
|
|
67
69
|
if (e.type == "pointerdown" && popContainsTarget)
|
|
68
70
|
return;
|
|
69
|
-
if (e.type == "click" &&
|
|
71
|
+
if (e.type == "click" &&
|
|
72
|
+
((popContainsTarget && isCloseManual) || !popContentContainsTarget))
|
|
70
73
|
return;
|
|
71
74
|
pop._hide();
|
|
72
75
|
});
|
|
@@ -143,9 +146,11 @@ let Pop = Pop_1 = class Pop extends LitElement {
|
|
|
143
146
|
x = xRight;
|
|
144
147
|
if (contentRect.y < shiftPadding && placement == "top")
|
|
145
148
|
y = yBottom;
|
|
146
|
-
if (contentRect.x + contentRect.width > window.innerWidth - shiftPadding &&
|
|
149
|
+
if (contentRect.x + contentRect.width > window.innerWidth - shiftPadding &&
|
|
150
|
+
placement == "right")
|
|
147
151
|
x = xLeft;
|
|
148
|
-
if (contentRect.y + contentRect.height > window.innerHeight - shiftPadding &&
|
|
152
|
+
if (contentRect.y + contentRect.height > window.innerHeight - shiftPadding &&
|
|
153
|
+
placement == "bottom")
|
|
149
154
|
y = yTop;
|
|
150
155
|
this.lastContentX += x - contentRect.x;
|
|
151
156
|
this.lastContentY += y - contentRect.y;
|
|
@@ -161,10 +166,12 @@ let Pop = Pop_1 = class Pop extends LitElement {
|
|
|
161
166
|
this.lastContentY += -contentRect.y;
|
|
162
167
|
}
|
|
163
168
|
if (contentRect.x + contentRect.width > window.innerWidth) {
|
|
164
|
-
this.lastContentX +=
|
|
169
|
+
this.lastContentX +=
|
|
170
|
+
window.innerWidth - (contentRect.x + contentRect.width);
|
|
165
171
|
}
|
|
166
172
|
if (contentRect.y + contentRect.height > window.innerHeight) {
|
|
167
|
-
this.lastContentY +=
|
|
173
|
+
this.lastContentY +=
|
|
174
|
+
window.innerHeight - (contentRect.y + contentRect.height);
|
|
168
175
|
}
|
|
169
176
|
Object.assign(this.popContent.style, {
|
|
170
177
|
left: `${this.lastContentX}px`,
|
|
@@ -173,7 +180,11 @@ let Pop = Pop_1 = class Pop extends LitElement {
|
|
|
173
180
|
}
|
|
174
181
|
render() {
|
|
175
182
|
return html `
|
|
176
|
-
<slot
|
|
183
|
+
<slot
|
|
184
|
+
@click=${this._toggle}
|
|
185
|
+
@keydown=${this._toggle}
|
|
186
|
+
class="contents"
|
|
187
|
+
></slot>
|
|
177
188
|
<slot
|
|
178
189
|
name="content"
|
|
179
190
|
tabindex="-1"
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare function bind(value: string): (target: any, propertyKey: string) => void;
|
|
2
|
+
export declare function onAssign(values: Array<string>): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
|
|
3
|
+
export declare function autoFill(value: string): (target: any) => void;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { Objects, PublisherManager } from "@supersoniks/concorde/utils";
|
|
2
|
+
export function bind(value) {
|
|
3
|
+
const split = value.split(".");
|
|
4
|
+
if (split.length == 0) {
|
|
5
|
+
return function () {
|
|
6
|
+
//Empty def function
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
const dataProvider = split.shift() || "";
|
|
10
|
+
let publisher = PublisherManager.get(dataProvider);
|
|
11
|
+
publisher = Objects.traverse(publisher, split);
|
|
12
|
+
return function (target, propertyKey) {
|
|
13
|
+
let onAssign;
|
|
14
|
+
target.onConnected((component) => {
|
|
15
|
+
onAssign = (value) => {
|
|
16
|
+
component[propertyKey] = value;
|
|
17
|
+
};
|
|
18
|
+
publisher.onAssign(onAssign);
|
|
19
|
+
});
|
|
20
|
+
target.onDisconnected(() => {
|
|
21
|
+
publisher.offAssign(onAssign);
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export function onAssign(values) {
|
|
26
|
+
const onAssignValues = [];
|
|
27
|
+
const confs = [];
|
|
28
|
+
let callback;
|
|
29
|
+
for (let i = 0; i < values.length; i++) {
|
|
30
|
+
const value = values[i];
|
|
31
|
+
const split = value.split(".");
|
|
32
|
+
if (split.length == 0) {
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
const dataProvider = split.shift() || "";
|
|
36
|
+
let publisher = PublisherManager.get(dataProvider);
|
|
37
|
+
publisher = Objects.traverse(publisher, split);
|
|
38
|
+
const onAssign = (value) => {
|
|
39
|
+
onAssignValues[i] = value;
|
|
40
|
+
if (onAssignValues.filter((v) => v !== null).length == values.length)
|
|
41
|
+
callback(...onAssignValues);
|
|
42
|
+
};
|
|
43
|
+
confs.push({ publisher, onAssign });
|
|
44
|
+
}
|
|
45
|
+
return function (target, propertyKey, descriptor) {
|
|
46
|
+
propertyKey;
|
|
47
|
+
target.onConnected((component) => {
|
|
48
|
+
callback = descriptor.value.bind(component);
|
|
49
|
+
for (const conf of confs) {
|
|
50
|
+
conf.publisher.onAssign(conf.onAssign);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
target.onDisconnected(() => {
|
|
54
|
+
for (const conf of confs) {
|
|
55
|
+
conf.publisher.offAssign(conf.onAssign);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
export function autoFill(value) {
|
|
61
|
+
const split = value.split(".");
|
|
62
|
+
if (split.length == 0) {
|
|
63
|
+
return function () {
|
|
64
|
+
//Empty def function
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
const dataProvider = split.shift() || "";
|
|
68
|
+
let publisher = PublisherManager.get(dataProvider);
|
|
69
|
+
publisher = Objects.traverse(publisher, split);
|
|
70
|
+
return function (target) {
|
|
71
|
+
target.prototype.connectedCallbackCalls.add((component) => {
|
|
72
|
+
publisher.startTemplateFilling(component);
|
|
73
|
+
});
|
|
74
|
+
target.prototype.disconnectedCallbackCalls.add((component) => {
|
|
75
|
+
publisher.stopTemplateFilling(component);
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
}
|
package/core/mixins/Fetcher.d.ts
CHANGED
|
@@ -70,7 +70,9 @@ declare const Fetcher: <T extends Constructor<SubscriberInterface<PropsType>>, P
|
|
|
70
70
|
debug: HTMLElement | null;
|
|
71
71
|
defferedDebug: boolean | null;
|
|
72
72
|
displayContents: boolean;
|
|
73
|
-
shadowRoot?: ShadowRoot | undefined;
|
|
73
|
+
shadowRoot?: ShadowRoot | undefined; /**
|
|
74
|
+
* isFirstLoad vaut true jusqu'au premier chargement de données
|
|
75
|
+
*/
|
|
74
76
|
dispatchEvent(event: Event): void;
|
|
75
77
|
setAttribute(name: string, value: string): void;
|
|
76
78
|
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions | undefined): void;
|
|
@@ -82,6 +84,10 @@ declare const Fetcher: <T extends Constructor<SubscriberInterface<PropsType>>, P
|
|
|
82
84
|
getAttribute(name: string): string;
|
|
83
85
|
hasAttribute(attributeName: string): boolean;
|
|
84
86
|
getBoundingClientRect(): DOMRect;
|
|
87
|
+
onConnected(callback: (component: any) => void): void;
|
|
88
|
+
offConnected(callback: (component: any) => void): void;
|
|
89
|
+
onDisconnected(callback: (component: any) => void): void;
|
|
90
|
+
offDisconnected(callback: (component: any) => void): void;
|
|
85
91
|
};
|
|
86
92
|
} & T;
|
|
87
93
|
export default Fetcher;
|
|
@@ -82,6 +82,10 @@ declare const Form: <T extends Constructor<FormElementInterface>>(superClass: T)
|
|
|
82
82
|
getAttribute(name: string): string;
|
|
83
83
|
hasAttribute(attributeName: string): boolean;
|
|
84
84
|
getBoundingClientRect(): DOMRect;
|
|
85
|
+
onConnected(callback: (component: any) => void): void;
|
|
86
|
+
offConnected(callback: (component: any) => void): void;
|
|
87
|
+
onDisconnected(callback: (component: any) => void): void;
|
|
88
|
+
offDisconnected(callback: (component: any) => void): void;
|
|
85
89
|
};
|
|
86
90
|
} & T;
|
|
87
91
|
export default Form;
|
|
@@ -11,6 +11,7 @@ export interface FormElementInterface extends SubscriberInterface {
|
|
|
11
11
|
getValueForFormPublisher(): FormElementValue;
|
|
12
12
|
validateFormElement(): void;
|
|
13
13
|
focus?: () => void;
|
|
14
|
+
forceAutoFill: boolean;
|
|
14
15
|
shadowRoot?: ShadowRoot;
|
|
15
16
|
error: boolean;
|
|
16
17
|
autofocus: boolean;
|
|
@@ -74,7 +74,8 @@ const Form = (superClass) => {
|
|
|
74
74
|
}
|
|
75
75
|
getFormPublisher() {
|
|
76
76
|
if (!this.formDataProvider)
|
|
77
|
-
this.formDataProvider =
|
|
77
|
+
this.formDataProvider =
|
|
78
|
+
this.getAncestorAttributeValue("formDataProvider");
|
|
78
79
|
if (this.formDataProvider) {
|
|
79
80
|
return PublisherManager.get(this.formDataProvider);
|
|
80
81
|
}
|
|
@@ -120,7 +121,9 @@ const Form = (superClass) => {
|
|
|
120
121
|
}
|
|
121
122
|
initPublisher() {
|
|
122
123
|
let formPublisher = this.getFormPublisher();
|
|
123
|
-
const value = this.hasAncestorAttribute("initFromPublisher") &&
|
|
124
|
+
const value = this.hasAncestorAttribute("initFromPublisher") &&
|
|
125
|
+
this._name &&
|
|
126
|
+
formPublisher[this._name].get()
|
|
124
127
|
? formPublisher[this._name].get()
|
|
125
128
|
: this.getAttribute("value");
|
|
126
129
|
if (this._name && this.publisher)
|
|
@@ -219,6 +222,7 @@ const Form = (superClass) => {
|
|
|
219
222
|
if (elt && elt.focus) {
|
|
220
223
|
elt.focus();
|
|
221
224
|
e.preventDefault();
|
|
225
|
+
e.stopPropagation();
|
|
222
226
|
}
|
|
223
227
|
});
|
|
224
228
|
}
|
|
@@ -42,10 +42,7 @@ declare const Form: <T extends Constructor<FormElementInterface>>(superClass: T)
|
|
|
42
42
|
children: HTMLCollection;
|
|
43
43
|
appendChild(node: Node): Node;
|
|
44
44
|
getAncestorAttributeValue(attributeName: string): string;
|
|
45
|
-
hasAncestorAttribute(attributeName: string): boolean;
|
|
46
|
-
* Le type De l'input, comme en html cependant tous les types ne sont pas actuellements compatibles en raison du style en vigueur
|
|
47
|
-
* On peut essayer text, date, color, email par exemple, mais pas radio/checkbox/range a priori
|
|
48
|
-
*/
|
|
45
|
+
hasAncestorAttribute(attributeName: string): boolean;
|
|
49
46
|
querySelectorAll(selector: string): NodeListOf<Element>;
|
|
50
47
|
publisher: any;
|
|
51
48
|
dataProvider: string | null;
|
|
@@ -66,6 +63,10 @@ declare const Form: <T extends Constructor<FormElementInterface>>(superClass: T)
|
|
|
66
63
|
hasAttribute(attributeName: string): boolean;
|
|
67
64
|
disconnectedCallback(): void;
|
|
68
65
|
getBoundingClientRect(): DOMRect;
|
|
66
|
+
onConnected(callback: (component: any) => void): void;
|
|
67
|
+
offConnected(callback: (component: any) => void): void;
|
|
68
|
+
onDisconnected(callback: (component: any) => void): void;
|
|
69
|
+
offDisconnected(callback: (component: any) => void): void;
|
|
69
70
|
};
|
|
70
71
|
} & T;
|
|
71
72
|
export default Form;
|
|
@@ -31,6 +31,10 @@ export interface SubscriberInterface<PropsType = CoreJSType> {
|
|
|
31
31
|
hasAttribute(attributeName: string): boolean;
|
|
32
32
|
disconnectedCallback(): void;
|
|
33
33
|
getBoundingClientRect(): DOMRect;
|
|
34
|
+
onConnected(callback: (component: any) => void): void;
|
|
35
|
+
offConnected(callback: (component: any) => void): void;
|
|
36
|
+
onDisconnected(callback: (component: any) => void): void;
|
|
37
|
+
offDisconnected(callback: (component: any) => void): void;
|
|
34
38
|
}
|
|
35
39
|
declare const Subscriber: <PropsType = CoreJSType, T extends Constructor<LitElement> = Constructor<LitElement>>(superClass: T, type?: PropsType | undefined) => Constructor<SubscriberInterface<PropsType>> & T;
|
|
36
40
|
export default Subscriber;
|