@supersoniks/concorde 1.0.5 → 1.0.8
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 +16 -8
- package/cli.js +69 -0
- package/core/components/functional/date/date.d.ts +34 -0
- package/core/components/functional/date/date.js +187 -0
- package/core/components/functional/example/example.d.ts +7 -0
- package/core/components/functional/example/example.js +25 -0
- package/core/components/functional/fetch/fetch.d.ts +49 -0
- package/core/components/functional/fetch/fetch.js +38 -0
- package/core/components/functional/functional.d.ts +11 -0
- package/core/components/functional/functional.js +11 -0
- package/core/components/functional/if/if.d.ts +12 -0
- package/core/components/functional/if/if.js +43 -0
- package/core/components/functional/list/list.d.ts +67 -0
- package/core/components/functional/list/list.js +132 -0
- package/core/components/functional/queue/queue.d.ts +42 -0
- package/core/components/functional/queue/queue.js +184 -0
- package/core/components/functional/router/redirect.d.ts +18 -0
- package/core/components/functional/router/redirect.js +57 -0
- package/core/components/functional/router/router.d.ts +26 -0
- package/core/components/functional/router/router.js +104 -0
- package/core/components/functional/states/states.d.ts +28 -0
- package/core/components/functional/states/states.js +139 -0
- package/core/components/functional/submit/submit.d.ts +24 -0
- package/core/components/functional/submit/submit.js +108 -0
- package/{types/core/components → core/components/functional/subscriber}/subscriber.d.ts +5 -1
- package/core/components/functional/subscriber/subscriber.js +30 -0
- package/core/components/ui/alert/alert.d.ts +20 -0
- package/core/components/ui/alert/alert.js +150 -0
- package/core/components/ui/badge/badge.d.ts +24 -0
- package/core/components/ui/badge/badge.js +177 -0
- package/core/components/ui/button/button.d.ts +125 -0
- package/core/components/ui/button/button.js +558 -0
- package/core/components/ui/divider/divider.d.ts +11 -0
- package/core/components/ui/divider/divider.js +144 -0
- package/core/components/ui/form/checkbox/checkbox.d.ts +120 -0
- package/core/components/ui/form/checkbox/checkbox.js +203 -0
- package/core/components/ui/form/css/form-control.d.ts +1 -0
- package/core/components/ui/form/css/form-control.js +219 -0
- package/core/components/ui/form/fieldset/fieldset.d.ts +15 -0
- package/core/components/ui/form/fieldset/fieldset.js +70 -0
- package/core/components/ui/form/fieldset/legend.d.ts +11 -0
- package/core/components/ui/form/fieldset/legend.js +92 -0
- package/core/components/ui/form/form-layout/form-actions.d.ts +6 -0
- package/core/components/ui/form/form-layout/form-actions.js +23 -0
- package/core/components/ui/form/form-layout/form-layout.d.ts +9 -0
- package/core/components/ui/form/form-layout/form-layout.js +58 -0
- package/core/components/ui/form/input/input.d.ts +84 -0
- package/core/components/ui/form/input/input.js +180 -0
- package/core/components/ui/form/radio/radio.d.ts +12 -0
- package/core/components/ui/form/radio/radio.js +55 -0
- package/core/components/ui/form/select/select.d.ts +39 -0
- package/core/components/ui/form/select/select.js +220 -0
- package/core/components/ui/form/textarea/textarea.d.ts +69 -0
- package/core/components/ui/form/textarea/textarea.js +150 -0
- package/core/components/ui/group/group.d.ts +6 -0
- package/core/components/ui/group/group.js +57 -0
- package/core/components/ui/icon/icon.d.ts +17 -0
- package/core/components/ui/icon/icon.js +93 -0
- package/core/components/ui/icon/icons.d.ts +13 -0
- package/core/components/ui/icon/icons.js +25 -0
- package/core/components/ui/icon/icons.json +1 -0
- package/core/components/ui/image/image.d.ts +14 -0
- package/core/components/ui/image/image.js +152 -0
- package/core/components/ui/link/link.d.ts +16 -0
- package/core/components/ui/link/link.js +70 -0
- package/core/components/ui/loader/loader.d.ts +20 -0
- package/core/components/ui/loader/loader.js +94 -0
- package/{types → core}/components/ui/loader/styles/fixed.d.ts +0 -0
- package/core/components/ui/loader/styles/fixed.js +57 -0
- package/{types → core}/components/ui/loader/styles/inline.d.ts +0 -0
- package/core/components/ui/loader/styles/inline.js +71 -0
- package/core/components/ui/menu/menu-item.d.ts +5 -0
- package/core/components/ui/menu/menu-item.js +37 -0
- package/core/components/ui/menu/menu.d.ts +26 -0
- package/core/components/ui/menu/menu.js +125 -0
- package/core/components/ui/modal/modal-actions.d.ts +7 -0
- package/core/components/ui/modal/modal-actions.js +46 -0
- package/core/components/ui/modal/modal-close.d.ts +6 -0
- package/core/components/ui/modal/modal-close.js +38 -0
- package/core/components/ui/modal/modal-content.d.ts +5 -0
- package/core/components/ui/modal/modal-content.js +29 -0
- package/core/components/ui/modal/modal-subtitle.d.ts +5 -0
- package/core/components/ui/modal/modal-subtitle.js +33 -0
- package/core/components/ui/modal/modal-title.d.ts +5 -0
- package/core/components/ui/modal/modal-title.js +33 -0
- package/core/components/ui/modal/modal.d.ts +36 -0
- package/core/components/ui/modal/modal.js +325 -0
- package/core/components/ui/pop/pop.d.ts +28 -0
- package/core/components/ui/pop/pop.js +223 -0
- package/core/components/ui/tabs/tab.d.ts +6 -0
- package/core/components/ui/tabs/tab.js +46 -0
- package/core/components/ui/tabs/tabs.d.ts +14 -0
- package/core/components/ui/tabs/tabs.js +127 -0
- package/core/components/ui/taxonomy/taxonomy.d.ts +41 -0
- package/core/components/ui/taxonomy/taxonomy.js +113 -0
- package/core/components/ui/theme/css/tailwind.css +3 -0
- package/core/components/ui/theme/css/tailwind.d.ts +2 -0
- package/core/components/ui/theme/theme-collection/core-variables.d.ts +1 -0
- package/core/components/ui/theme/theme-collection/core-variables.js +50 -0
- package/{types/components → core/components/ui}/theme/theme-collection/dark.d.ts +0 -0
- package/core/components/ui/theme/theme-collection/dark.js +41 -0
- package/{types/components → core/components/ui}/theme/theme-collection/light.d.ts +0 -0
- package/core/components/ui/theme/theme-collection/light.js +35 -0
- package/core/components/ui/theme/theme.d.ts +11 -0
- package/core/components/ui/theme/theme.js +105 -0
- package/core/components/ui/toast/message-subscriber.d.ts +17 -0
- package/core/components/ui/toast/message-subscriber.js +85 -0
- package/{types → core}/components/ui/toast/toast.d.ts +10 -8
- package/core/components/ui/toast/toast.js +260 -0
- package/core/components/ui/tooltip/tooltip.d.ts +7 -0
- package/core/components/ui/tooltip/tooltip.js +68 -0
- package/core/components/ui/ui.d.ts +27 -0
- package/core/components/ui/ui.js +34 -0
- package/core/core.d.ts +3 -0
- package/core/core.js +7 -0
- package/core/mixins/Fetcher.d.ts +69 -0
- package/core/mixins/Fetcher.js +147 -0
- package/core/mixins/FormCheckable.d.ts +72 -0
- package/core/mixins/FormCheckable.js +144 -0
- package/core/mixins/FormElement.d.ts +21 -0
- package/core/mixins/FormElement.js +229 -0
- package/core/mixins/FormInput.d.ts +49 -0
- package/core/mixins/FormInput.js +33 -0
- package/core/mixins/Subscriber.d.ts +30 -0
- package/core/mixins/Subscriber.js +379 -0
- package/core/mixins/TemplatesContainer.d.ts +12 -0
- package/core/mixins/TemplatesContainer.js +60 -0
- package/core/mixins/mixins.d.ts +6 -0
- package/core/mixins/mixins.js +6 -0
- package/core/utils/Arrays.d.ts +97 -0
- package/core/utils/Arrays.js +136 -0
- package/core/utils/DataBindObserver.d.ts +74 -0
- package/core/utils/DataBindObserver.js +252 -0
- package/core/utils/Format.d.ts +11 -0
- package/core/utils/Format.js +22 -0
- package/core/utils/HTML.d.ts +13 -0
- package/core/utils/HTML.js +26 -0
- package/core/utils/LocationHandler.d.ts +44 -0
- package/core/utils/LocationHandler.js +96 -0
- package/core/utils/Objects.d.ts +23 -0
- package/core/utils/Objects.js +63 -0
- package/core/utils/PublisherProxy.d.mts +110 -0
- package/core/utils/PublisherProxy.mjs +365 -0
- package/core/utils/api.d.ts +66 -0
- package/core/utils/api.js +145 -0
- package/package.json +179 -21
- package/LICENSE +0 -43
- package/dist/concorde.bundle.js +0 -3620
- package/types/components/event/event-card/event-card.d.ts +0 -10
- package/types/components/event/event-title/event-title.d.ts +0 -7
- package/types/components/event/event.d.ts +0 -8
- package/types/components/giftcards/giftcard/giftcard.d.ts +0 -15
- package/types/components/illustration/illustration.d.ts +0 -16
- package/types/components/product/prices-form/price-button/price-button.d.ts +0 -25
- package/types/components/product/prices-form/prices-form.d.ts +0 -23
- package/types/components/theme/theme-collection/bootstrap5.d.ts +0 -1
- package/types/components/theme/theme-collection/dracula.d.ts +0 -1
- package/types/components/theme/theme.d.ts +0 -8
- package/types/components/ui/button/button.d.ts +0 -13
- package/types/components/ui/loader/loader.d.ts +0 -15
- package/types/components/ui/modal/modal.d.ts +0 -17
- package/types/components/ui/tooltip/tooltip.d.ts +0 -9
- package/types/core/components/fetch.d.ts +0 -6
- package/types/core/components/list.d.ts +0 -9
- package/types/core/components/queue.d.ts +0 -15
- package/types/core/components/taxonomy.d.ts +0 -13
- package/types/core/components/text-formatted.d.ts +0 -15
- package/types/core/components/text.d.ts +0 -9
- package/types/core/core.d.ts +0 -7
- package/types/core/mixins/Fetcher.d.ts +0 -9
- package/types/core/mixins/Subscriber.d.ts +0 -13
- package/types/core/utils/api.d.ts +0 -16
- package/types/index.d.ts +0 -12
- package/types/styles/button/button.d.ts +0 -1
- package/types/styles/prose/prose.d.ts +0 -2
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { FormElementInterface } from "@supersoniks/concorde/core/mixins/FormElement";
|
|
2
|
+
declare type Constructor<T> = new (...args: any[]) => T;
|
|
3
|
+
declare const Form: <T extends Constructor<FormElementInterface>>(superClass: T) => {
|
|
4
|
+
new (...args: any[]): {
|
|
5
|
+
/**
|
|
6
|
+
* Voir la mixin FormElement.
|
|
7
|
+
*/
|
|
8
|
+
_value: string | null;
|
|
9
|
+
value: string | null;
|
|
10
|
+
/**
|
|
11
|
+
* Voir la mixin FormElement
|
|
12
|
+
*/
|
|
13
|
+
_name: string;
|
|
14
|
+
name: string;
|
|
15
|
+
/**
|
|
16
|
+
* comme radio,mais peut être désélectionné après sélection
|
|
17
|
+
*/
|
|
18
|
+
unique: true | null;
|
|
19
|
+
/**
|
|
20
|
+
Active le mode radio
|
|
21
|
+
*/
|
|
22
|
+
radio: true | null;
|
|
23
|
+
/**
|
|
24
|
+
* propriété checked avec des caractéristiques similaire à un input html classique.
|
|
25
|
+
*/
|
|
26
|
+
_checked: true | null;
|
|
27
|
+
checked: true | null;
|
|
28
|
+
setCheckedValue(checked: true | null): void;
|
|
29
|
+
handleChange(): void;
|
|
30
|
+
/**
|
|
31
|
+
* Voir la mixin FormElement
|
|
32
|
+
* Le comportement est ici modifié fonction de son mode (checkbox, radio, unique)
|
|
33
|
+
*/
|
|
34
|
+
getValueForFormPublisher(): any;
|
|
35
|
+
/**
|
|
36
|
+
* Voir la mixin FormElement
|
|
37
|
+
* Le comportement est modifié de la manière suivante :
|
|
38
|
+
* L'état du composant (checked) est mis à jour en fonction de la valeur fournie par le publisher associé au composant / en fonction de sont mode (radio, unique)
|
|
39
|
+
*/
|
|
40
|
+
setFormValueFromPublisher(value: any): void;
|
|
41
|
+
initPublisher(): void;
|
|
42
|
+
getFormPublisher(): any;
|
|
43
|
+
updateDataValue(): void;
|
|
44
|
+
error: true | null;
|
|
45
|
+
autofocus: true | null;
|
|
46
|
+
disabled: true | null;
|
|
47
|
+
required: true | null;
|
|
48
|
+
formDataProvider: string;
|
|
49
|
+
props: any;
|
|
50
|
+
getAncestorAttributeValue(attributeName: string): string;
|
|
51
|
+
hasAncestorAttribute(attributeName: string): boolean;
|
|
52
|
+
querySelectorAll(selector: string): NodeListOf<Element>;
|
|
53
|
+
publisher: any;
|
|
54
|
+
dataProvider: String;
|
|
55
|
+
noShadowDom: string | null;
|
|
56
|
+
debug: HTMLElement | null;
|
|
57
|
+
defferedDebug: boolean | null;
|
|
58
|
+
makeShadow(props: Record<string, any>, value: any): any;
|
|
59
|
+
dispatchEvent(event: Event): void;
|
|
60
|
+
setAttribute(name: string, value: string): void;
|
|
61
|
+
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions | undefined): void;
|
|
62
|
+
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions | undefined): void;
|
|
63
|
+
removeAttribute(name: string): void;
|
|
64
|
+
getApiConfiguration(): import("../utils/api").APIConfiguration;
|
|
65
|
+
connectedCallback(): void;
|
|
66
|
+
requestUpdate(): void;
|
|
67
|
+
getAttribute(name: string): string;
|
|
68
|
+
hasAttribute(attributeName: String): boolean;
|
|
69
|
+
disconnectedCallback(): void;
|
|
70
|
+
};
|
|
71
|
+
} & T;
|
|
72
|
+
export default Form;
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
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
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { property } from "lit/decorators.js";
|
|
8
|
+
const Form = (superClass) => {
|
|
9
|
+
/**
|
|
10
|
+
* FormCheckable ajoute un comportement de sélection (checked) a tout FormElement qui utilise cette mixin.
|
|
11
|
+
* Il est notamment utilisé par sonic-checkbox, sonic-radio et sonic-button
|
|
12
|
+
* * Par défaut le fonctionnement est celui d'une checkbox classique.
|
|
13
|
+
* * Dans ce cas, a la sélection, formPublisher[this.name] = [this.value, ...autres valeurs d'élémen,ts sélectionnés ayant le même nom];
|
|
14
|
+
* * En activant le mode radio à l'aide du flag dédié, un seul FormElement ayant la même propriété name peut être sélectionné à la fois.
|
|
15
|
+
* * Dans ce cas, a la sélection, formPublisher[this.name] = this.value;
|
|
16
|
+
*/
|
|
17
|
+
class FormCheckable extends superClass {
|
|
18
|
+
constructor() {
|
|
19
|
+
super(...arguments);
|
|
20
|
+
/**
|
|
21
|
+
* Voir la mixin FormElement.
|
|
22
|
+
*/
|
|
23
|
+
this._value = "";
|
|
24
|
+
/**
|
|
25
|
+
* Voir la mixin FormElement
|
|
26
|
+
*/
|
|
27
|
+
this._name = "";
|
|
28
|
+
/**
|
|
29
|
+
* comme radio,mais peut être désélectionné après sélection
|
|
30
|
+
*/
|
|
31
|
+
this.unique = null;
|
|
32
|
+
/**
|
|
33
|
+
Active le mode radio
|
|
34
|
+
*/
|
|
35
|
+
this.radio = null;
|
|
36
|
+
/**
|
|
37
|
+
* propriété checked avec des caractéristiques similaire à un input html classique.
|
|
38
|
+
*/
|
|
39
|
+
this._checked = null;
|
|
40
|
+
}
|
|
41
|
+
get value() {
|
|
42
|
+
return this._value;
|
|
43
|
+
}
|
|
44
|
+
set value(value) {
|
|
45
|
+
if (this.hasAttribute("value"))
|
|
46
|
+
value = this.getAttribute("value");
|
|
47
|
+
if (this._value == value)
|
|
48
|
+
return;
|
|
49
|
+
this._value = value;
|
|
50
|
+
this.updateDataValue();
|
|
51
|
+
this.requestUpdate();
|
|
52
|
+
}
|
|
53
|
+
get name() {
|
|
54
|
+
return this._name;
|
|
55
|
+
}
|
|
56
|
+
set name(value) {
|
|
57
|
+
if (this.hasAttribute("name"))
|
|
58
|
+
value = this.getAttribute("name");
|
|
59
|
+
this._name = value;
|
|
60
|
+
}
|
|
61
|
+
get checked() {
|
|
62
|
+
return this._checked;
|
|
63
|
+
}
|
|
64
|
+
set checked(checked) {
|
|
65
|
+
this.setCheckedValue(checked);
|
|
66
|
+
}
|
|
67
|
+
setCheckedValue(checked) {
|
|
68
|
+
if (this._checked == checked)
|
|
69
|
+
return;
|
|
70
|
+
this._checked = checked;
|
|
71
|
+
this.updateDataValue();
|
|
72
|
+
this.requestUpdate();
|
|
73
|
+
if (this.publisher && !this.radio && !this.unique) {
|
|
74
|
+
this.publisher.checked = this._checked;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
handleChange() {
|
|
78
|
+
this.checked = this.checked ? (!this.radio ? null : true) : true;
|
|
79
|
+
const event = new Event("change");
|
|
80
|
+
this.dispatchEvent(event);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Voir la mixin FormElement
|
|
84
|
+
* Le comportement est ici modifié fonction de son mode (checkbox, radio, unique)
|
|
85
|
+
*/
|
|
86
|
+
getValueForFormPublisher() {
|
|
87
|
+
let publisher = this.getFormPublisher();
|
|
88
|
+
let currentValue = publisher[this.name].get();
|
|
89
|
+
if (this.unique || this.radio) {
|
|
90
|
+
return this.checked && this.value != null ? this.value : currentValue;
|
|
91
|
+
}
|
|
92
|
+
if (!Array.isArray(currentValue)) {
|
|
93
|
+
currentValue = [];
|
|
94
|
+
}
|
|
95
|
+
currentValue = currentValue.slice(0);
|
|
96
|
+
let idx = currentValue.indexOf(this.value);
|
|
97
|
+
if (this.checked === true && idx === -1)
|
|
98
|
+
currentValue.push(this.value);
|
|
99
|
+
if (this.checked === null && idx !== -1)
|
|
100
|
+
currentValue.splice(idx, 1);
|
|
101
|
+
return currentValue;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Voir la mixin FormElement
|
|
105
|
+
* Le comportement est modifié de la manière suivante :
|
|
106
|
+
* L'état du composant (checked) est mis à jour en fonction de la valeur fournie par le publisher associé au composant / en fonction de sont mode (radio, unique)
|
|
107
|
+
*/
|
|
108
|
+
setFormValueFromPublisher(value) {
|
|
109
|
+
if (this.unique || this.radio) {
|
|
110
|
+
this.checked = this.value == value ? true : null;
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
if (!Array.isArray(value))
|
|
114
|
+
value = [];
|
|
115
|
+
this.checked = value.indexOf(this.value) !== -1 ? true : null;
|
|
116
|
+
}
|
|
117
|
+
initPublisher() {
|
|
118
|
+
super.initPublisher();
|
|
119
|
+
if (!this.hasAttribute("checked")) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
if (!this.publisher || this.publisher.get().checked !== false) {
|
|
123
|
+
this.checked = true;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
__decorate([
|
|
128
|
+
property()
|
|
129
|
+
], FormCheckable.prototype, "value", null);
|
|
130
|
+
__decorate([
|
|
131
|
+
property()
|
|
132
|
+
], FormCheckable.prototype, "name", null);
|
|
133
|
+
__decorate([
|
|
134
|
+
property({ type: Boolean })
|
|
135
|
+
], FormCheckable.prototype, "unique", void 0);
|
|
136
|
+
__decorate([
|
|
137
|
+
property({ type: Boolean })
|
|
138
|
+
], FormCheckable.prototype, "radio", void 0);
|
|
139
|
+
__decorate([
|
|
140
|
+
property()
|
|
141
|
+
], FormCheckable.prototype, "checked", null);
|
|
142
|
+
return FormCheckable;
|
|
143
|
+
};
|
|
144
|
+
export default Form;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { SubscriberInterface } from "@supersoniks/concorde/core/mixins/Subscriber";
|
|
2
|
+
declare type Constructor<T> = new (...args: any[]) => T;
|
|
3
|
+
export interface FormElementInterface extends SubscriberInterface {
|
|
4
|
+
getFormPublisher(): any;
|
|
5
|
+
updateDataValue(): void;
|
|
6
|
+
handleChange(e?: any): void;
|
|
7
|
+
getValueForFormPublisher(): any;
|
|
8
|
+
error: true | null;
|
|
9
|
+
autofocus: true | null;
|
|
10
|
+
disabled: true | null;
|
|
11
|
+
required: true | null;
|
|
12
|
+
formDataProvider: string;
|
|
13
|
+
_value: any;
|
|
14
|
+
get value(): any;
|
|
15
|
+
set value(value: any);
|
|
16
|
+
_name: string;
|
|
17
|
+
get name(): string;
|
|
18
|
+
set name(value: string);
|
|
19
|
+
}
|
|
20
|
+
declare const Form: <T extends Constructor<SubscriberInterface>>(superClass: T) => Constructor<FormElementInterface> & T;
|
|
21
|
+
export default Form;
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
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
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { PublisherManager } from "@supersoniks/concorde/core/utils/PublisherProxy.mjs";
|
|
8
|
+
import { property } from "lit/decorators.js";
|
|
9
|
+
import Objects from "../utils/Objects";
|
|
10
|
+
const keyboardLoops = new Map();
|
|
11
|
+
const Form = (superClass) => {
|
|
12
|
+
/**
|
|
13
|
+
* ## FormElement est la mixin utilisée par les éléments de formulaire de concorde ainsi que par le composant sonic-button.
|
|
14
|
+
* * La propriété value est remplie automatiquement a l'aide de l'attribut name renseigné, ceci en prenant la valeur de la propriété du même nom dans les données du dataprovider associé.
|
|
15
|
+
* * Par défault lorsque l'on édite l'input, la valeur est également mise à jour via le même dataprovider
|
|
16
|
+
* * On peut cependant décider de mettre à jour la donnée à une autre adresse en renseignent l'attribut *formDataProvider*.
|
|
17
|
+
* * Par conséquent, on peut par exemple le lier à un composant *queue* (via sa propriété *dataFilterProvider*) de manière à appeller en auto une api avec des filtres.
|
|
18
|
+
*
|
|
19
|
+
*/
|
|
20
|
+
class FormElement extends superClass {
|
|
21
|
+
constructor(...args) {
|
|
22
|
+
super();
|
|
23
|
+
this.error = null;
|
|
24
|
+
this.autofocus = null;
|
|
25
|
+
this.disabled = null;
|
|
26
|
+
this.required = null;
|
|
27
|
+
this.onValueAssign = null;
|
|
28
|
+
this.onFormValueAssign = null;
|
|
29
|
+
this.formDataProvider = "";
|
|
30
|
+
/**
|
|
31
|
+
* Le nom du champ avec des caractéristiques similaire à un input html classique.
|
|
32
|
+
*/
|
|
33
|
+
this._name = "";
|
|
34
|
+
/**
|
|
35
|
+
* La valeur du champ avec des caractéristiques similaire à un input html classique :
|
|
36
|
+
*/
|
|
37
|
+
this._value = "";
|
|
38
|
+
args;
|
|
39
|
+
this.onValueAssign = (value) => {
|
|
40
|
+
this.setValueFromPublisher(value);
|
|
41
|
+
};
|
|
42
|
+
this.onFormValueAssign = (value) => {
|
|
43
|
+
this.setFormValueFromPublisher(value);
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
get name() {
|
|
47
|
+
return this._name;
|
|
48
|
+
}
|
|
49
|
+
set name(value) {
|
|
50
|
+
this._name = value;
|
|
51
|
+
}
|
|
52
|
+
updateDataValue() {
|
|
53
|
+
if (this._name) {
|
|
54
|
+
let formPublisher = this.getFormPublisher();
|
|
55
|
+
if (formPublisher) {
|
|
56
|
+
formPublisher[this._name] = this.getValueForFormPublisher();
|
|
57
|
+
this.setFormValueFromPublisher(formPublisher[this.name].get());
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
getFormPublisher() {
|
|
62
|
+
if (!this.formDataProvider) {
|
|
63
|
+
this.formDataProvider = this.getAncestorAttributeValue("formDataProvider");
|
|
64
|
+
}
|
|
65
|
+
if (this.formDataProvider) {
|
|
66
|
+
return PublisherManager.get(this.formDataProvider);
|
|
67
|
+
}
|
|
68
|
+
else
|
|
69
|
+
return this.publisher;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Mise en forme de la valeur fournie au formPublisher associé au composant
|
|
73
|
+
* Destinée à être surchargée si besoin (cf Form-checkable)
|
|
74
|
+
*/
|
|
75
|
+
getValueForFormPublisher() {
|
|
76
|
+
return this.value;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Mise à jour de la valeur interne du composant en fonction de la valeur venant du publisher associé au composant
|
|
80
|
+
* Destinée à être surchargée si besoin (cf Form-checkable)
|
|
81
|
+
*/
|
|
82
|
+
setValueFromPublisher(value) {
|
|
83
|
+
this.value = value;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Mise à jour de la valeur interne du composant en fonction de la valeur venant du formPublisher associé au composant
|
|
87
|
+
* Destinée à être surchargée si besoin (cf Form-checkable)
|
|
88
|
+
*/
|
|
89
|
+
setFormValueFromPublisher(value) {
|
|
90
|
+
this.value = value;
|
|
91
|
+
}
|
|
92
|
+
get value() {
|
|
93
|
+
return this._value;
|
|
94
|
+
}
|
|
95
|
+
set value(value) {
|
|
96
|
+
if (Objects.isObject(value) && value.hasOwnProperty("__value") && value.value == undefined)
|
|
97
|
+
return;
|
|
98
|
+
if (value == null)
|
|
99
|
+
return;
|
|
100
|
+
if (this._value == value)
|
|
101
|
+
return;
|
|
102
|
+
this._value = value;
|
|
103
|
+
this.updateDataValue();
|
|
104
|
+
this.requestUpdate();
|
|
105
|
+
}
|
|
106
|
+
initPublisher() {
|
|
107
|
+
if (this._name && this.publisher)
|
|
108
|
+
this.publisher[this._name].offAssign(this.onValueAssign);
|
|
109
|
+
let formPublisher = this.getFormPublisher();
|
|
110
|
+
if (this._name && formPublisher)
|
|
111
|
+
formPublisher[this._name].offAssign(this.onFormValueAssign);
|
|
112
|
+
super.initPublisher();
|
|
113
|
+
if (!this.name)
|
|
114
|
+
this._name = this.getAttribute("name");
|
|
115
|
+
if (!this.value)
|
|
116
|
+
this._value = this.getAttribute("value");
|
|
117
|
+
this.updateDataValue();
|
|
118
|
+
if (this.publisher && this._name) {
|
|
119
|
+
this.publisher[this._name].onAssign(this.onValueAssign);
|
|
120
|
+
}
|
|
121
|
+
formPublisher = this.getFormPublisher();
|
|
122
|
+
if (this._name && formPublisher)
|
|
123
|
+
formPublisher[this._name].onAssign(this.onFormValueAssign);
|
|
124
|
+
}
|
|
125
|
+
handleChange(e) {
|
|
126
|
+
this.value = e.target.value;
|
|
127
|
+
const event = new Event("change");
|
|
128
|
+
this.dispatchEvent(event);
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Ajoute un comportement de navigation au clavier pour les éléments de formulaire
|
|
132
|
+
* data-keyboard-nav peut contenir plusieurs valeurs qui identifient les boucles de navigation auquelles est attaché cet élément.
|
|
133
|
+
* Les valeurs sont séparées par des espaces.
|
|
134
|
+
* En appuyant sur la touche "Down", le composant va se déplacer dans la boucle de navigation correspondante en suivant le flux.
|
|
135
|
+
* En appuyant sur la touche "Up", le déplacement inverse est effectué.
|
|
136
|
+
*/
|
|
137
|
+
addKeyboardNavigation() {
|
|
138
|
+
let keyboardLoopIds = this.getAncestorAttributeValue("data-keyboard-nav");
|
|
139
|
+
if (!keyboardLoopIds)
|
|
140
|
+
return;
|
|
141
|
+
let split = keyboardLoopIds.split(" ");
|
|
142
|
+
let keyboardLoopId = split[0];
|
|
143
|
+
if (!keyboardLoopId)
|
|
144
|
+
return;
|
|
145
|
+
for (let keyboardLoopId2 of split) {
|
|
146
|
+
if (!keyboardLoops.has(keyboardLoopId2)) {
|
|
147
|
+
keyboardLoops.set(keyboardLoopId2, []);
|
|
148
|
+
}
|
|
149
|
+
let keyboardLoop = keyboardLoops.get(keyboardLoopId2);
|
|
150
|
+
if (keyboardLoop.indexOf(this) == -1) {
|
|
151
|
+
keyboardLoop.push(this);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
let keyboardLoop = keyboardLoops.get(keyboardLoopId);
|
|
155
|
+
this.addEventListener("keydown", (e) => {
|
|
156
|
+
if (!["ArrowDown", "ArrowUp"].includes(e.key))
|
|
157
|
+
return;
|
|
158
|
+
let selector = "input:not([disabled]), button:not([disabled]), select:not([disabled]), textarea:not([disabled])";
|
|
159
|
+
let loop = keyboardLoop.filter((el) => {
|
|
160
|
+
let child = el.shadowRoot.querySelector(selector);
|
|
161
|
+
if (!child)
|
|
162
|
+
return false;
|
|
163
|
+
let cpStyle = window.getComputedStyle(child);
|
|
164
|
+
return (cpStyle.display !== "none" &&
|
|
165
|
+
cpStyle.display !== "" &&
|
|
166
|
+
cpStyle.pointerEvents != "none" &&
|
|
167
|
+
cpStyle.visibility !== "hidden" &&
|
|
168
|
+
child.getBoundingClientRect().width > 0);
|
|
169
|
+
});
|
|
170
|
+
let next = null;
|
|
171
|
+
if (e.key == "ArrowDown") {
|
|
172
|
+
let index = loop.indexOf(this);
|
|
173
|
+
if (index == loop.length - 1) {
|
|
174
|
+
next = loop[0];
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
next = loop[index + 1];
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
else if (e.key == "ArrowUp") {
|
|
181
|
+
let index = loop.indexOf(this);
|
|
182
|
+
if (index == 0) {
|
|
183
|
+
next = loop[loop.length - 1];
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
next = loop[index - 1];
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
let elt = next.shadowRoot.querySelector(selector);
|
|
190
|
+
if (elt) {
|
|
191
|
+
elt.focus();
|
|
192
|
+
e.preventDefault();
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
connectedCallback() {
|
|
197
|
+
super.connectedCallback();
|
|
198
|
+
this.addKeyboardNavigation();
|
|
199
|
+
}
|
|
200
|
+
disconnectedCallback() {
|
|
201
|
+
super.disconnectedCallback();
|
|
202
|
+
if (this._name && this.publisher)
|
|
203
|
+
this.publisher[this._name].offAssign(this.onValueAssign);
|
|
204
|
+
let formPublisher = this.getFormPublisher();
|
|
205
|
+
if (this._name && formPublisher)
|
|
206
|
+
formPublisher[this._name].offAssign(this.onFormValueAssign);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
__decorate([
|
|
210
|
+
property({ type: Boolean })
|
|
211
|
+
], FormElement.prototype, "error", void 0);
|
|
212
|
+
__decorate([
|
|
213
|
+
property({ type: Boolean })
|
|
214
|
+
], FormElement.prototype, "autofocus", void 0);
|
|
215
|
+
__decorate([
|
|
216
|
+
property({ type: Boolean })
|
|
217
|
+
], FormElement.prototype, "disabled", void 0);
|
|
218
|
+
__decorate([
|
|
219
|
+
property({ type: Boolean })
|
|
220
|
+
], FormElement.prototype, "required", void 0);
|
|
221
|
+
__decorate([
|
|
222
|
+
property()
|
|
223
|
+
], FormElement.prototype, "name", null);
|
|
224
|
+
__decorate([
|
|
225
|
+
property()
|
|
226
|
+
], FormElement.prototype, "value", null);
|
|
227
|
+
return FormElement;
|
|
228
|
+
};
|
|
229
|
+
export default Form;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { FormElementInterface } from "@supersoniks/concorde/core/mixins/FormElement";
|
|
2
|
+
declare type Constructor<T> = new (...args: any[]) => T;
|
|
3
|
+
declare const Form: <T extends Constructor<FormElementInterface>>(superClass: T) => {
|
|
4
|
+
new (...args: any[]): {
|
|
5
|
+
/**
|
|
6
|
+
* Le type De l'input, comme en html cependant tous les types ne sont pas actuellements compatibles en raison du style en vigueur
|
|
7
|
+
* On peut essayer text, date, color, email par exemple, mais pas radio/checkbox/range a priori
|
|
8
|
+
*/
|
|
9
|
+
type: "button" | "checkbox" | "color" | "date" | "datetime-local" | "email" | "file" | "hidden" | "image" | "month" | "number" | "password" | "radio" | "range" | "reset" | "search" | "submit" | "tel" | "text" | "time" | "url" | "week";
|
|
10
|
+
tabindex: string | null;
|
|
11
|
+
autocomplete: "on" | "name" | "honorific-prefix" | "given-name" | "additional-name" | "family-name" | "honorific-suffix" | "nickname" | "email" | "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" | "language" | "bday" | "bday-day" | "bday-month" | "bday-year" | "sex" | "tel" | "tel-country-code" | "tel-national" | "tel-area-code" | "tel-local" | "tel-extension" | "impp" | "url" | "photo" | null;
|
|
12
|
+
getFormPublisher(): any;
|
|
13
|
+
updateDataValue(): void;
|
|
14
|
+
handleChange(e?: any): void;
|
|
15
|
+
getValueForFormPublisher(): any;
|
|
16
|
+
error: true | null;
|
|
17
|
+
autofocus: true | null;
|
|
18
|
+
disabled: true | null;
|
|
19
|
+
required: true | null;
|
|
20
|
+
formDataProvider: string;
|
|
21
|
+
_value: any;
|
|
22
|
+
value: any;
|
|
23
|
+
_name: string;
|
|
24
|
+
name: string;
|
|
25
|
+
props: any;
|
|
26
|
+
getAncestorAttributeValue(attributeName: string): string;
|
|
27
|
+
hasAncestorAttribute(attributeName: string): boolean;
|
|
28
|
+
querySelectorAll(selector: string): NodeListOf<Element>;
|
|
29
|
+
publisher: any;
|
|
30
|
+
dataProvider: String;
|
|
31
|
+
noShadowDom: string | null;
|
|
32
|
+
debug: HTMLElement | null;
|
|
33
|
+
defferedDebug: boolean | null;
|
|
34
|
+
makeShadow(props: Record<string, any>, value: any): any;
|
|
35
|
+
dispatchEvent(event: Event): void;
|
|
36
|
+
setAttribute(name: string, value: string): void;
|
|
37
|
+
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions | undefined): void;
|
|
38
|
+
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions | undefined): void;
|
|
39
|
+
removeAttribute(name: string): void;
|
|
40
|
+
initPublisher(): void;
|
|
41
|
+
getApiConfiguration(): import("../utils/api").APIConfiguration;
|
|
42
|
+
connectedCallback(): void;
|
|
43
|
+
requestUpdate(): void;
|
|
44
|
+
getAttribute(name: string): string;
|
|
45
|
+
hasAttribute(attributeName: String): boolean;
|
|
46
|
+
disconnectedCallback(): void;
|
|
47
|
+
};
|
|
48
|
+
} & T;
|
|
49
|
+
export default Form;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
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
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { property } from "lit/decorators.js";
|
|
8
|
+
const Form = (superClass) => {
|
|
9
|
+
class FormInput extends superClass {
|
|
10
|
+
constructor(...args) {
|
|
11
|
+
super();
|
|
12
|
+
/**
|
|
13
|
+
* Le type De l'input, comme en html cependant tous les types ne sont pas actuellements compatibles en raison du style en vigueur
|
|
14
|
+
* On peut essayer text, date, color, email par exemple, mais pas radio/checkbox/range a priori
|
|
15
|
+
*/
|
|
16
|
+
this.type = "text";
|
|
17
|
+
this.tabindex = null;
|
|
18
|
+
this.autocomplete = null;
|
|
19
|
+
args;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
__decorate([
|
|
23
|
+
property({ type: String })
|
|
24
|
+
], FormInput.prototype, "type", void 0);
|
|
25
|
+
__decorate([
|
|
26
|
+
property({ type: String })
|
|
27
|
+
], FormInput.prototype, "tabindex", void 0);
|
|
28
|
+
__decorate([
|
|
29
|
+
property({ type: String })
|
|
30
|
+
], FormInput.prototype, "autocomplete", void 0);
|
|
31
|
+
return FormInput;
|
|
32
|
+
};
|
|
33
|
+
export default Form;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { LitElement } from "lit";
|
|
2
|
+
import "@supersoniks/concorde/core/components/ui/icon/icon";
|
|
3
|
+
import { APIConfiguration } from "@supersoniks/concorde/core/utils/api";
|
|
4
|
+
declare type Constructor<T> = new (...args: any[]) => T;
|
|
5
|
+
export interface SubscriberInterface {
|
|
6
|
+
props: any;
|
|
7
|
+
getAncestorAttributeValue(attributeName: string): string;
|
|
8
|
+
hasAncestorAttribute(attributeName: string): boolean;
|
|
9
|
+
querySelectorAll(selector: string): NodeListOf<Element>;
|
|
10
|
+
publisher: any;
|
|
11
|
+
dataProvider: String;
|
|
12
|
+
noShadowDom: string | null;
|
|
13
|
+
debug: HTMLElement | null;
|
|
14
|
+
defferedDebug: boolean | null;
|
|
15
|
+
makeShadow(props: Record<string, any>, value: any): any;
|
|
16
|
+
dispatchEvent(event: Event): void;
|
|
17
|
+
setAttribute(name: string, value: string): void;
|
|
18
|
+
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
|
|
19
|
+
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
|
|
20
|
+
removeAttribute(name: string): void;
|
|
21
|
+
initPublisher(): void;
|
|
22
|
+
getApiConfiguration(): APIConfiguration;
|
|
23
|
+
connectedCallback(): void;
|
|
24
|
+
requestUpdate(): void;
|
|
25
|
+
getAttribute(name: string): string;
|
|
26
|
+
hasAttribute(attributeName: String): boolean;
|
|
27
|
+
disconnectedCallback(): void;
|
|
28
|
+
}
|
|
29
|
+
declare const Subscriber: <T extends Constructor<LitElement>>(superClass: T) => Constructor<SubscriberInterface> & T;
|
|
30
|
+
export default Subscriber;
|