@supersoniks/concorde 1.1.31 → 1.1.34

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.
@@ -30,6 +30,11 @@ let Select = class Select extends FormElement(Subscriber(LitElement)) {
30
30
  this.multiple = false;
31
31
  this._options = [];
32
32
  this._value = "";
33
+ /*
34
+ * TODO
35
+ * Mutualiser avec le composant textarea / input
36
+ */
37
+ this.forceAutoFill = false;
33
38
  this.hasDescription = false;
34
39
  this.hasLabel = false;
35
40
  this.hasSuffix = false;
@@ -75,6 +80,24 @@ let Select = class Select extends FormElement(Subscriber(LitElement)) {
75
80
  });
76
81
  }
77
82
  }
83
+ get description() {
84
+ return this._description;
85
+ }
86
+ set description(value) {
87
+ if (this.hasAttribute("description") && !this.forceAutoFill)
88
+ value = this.getAttribute("description");
89
+ this._description = value;
90
+ this.requestUpdate();
91
+ }
92
+ get label() {
93
+ return this._label;
94
+ }
95
+ set label(value) {
96
+ if (this.hasAttribute("label") && !this.forceAutoFill)
97
+ value = this.getAttribute("label");
98
+ this._label = value;
99
+ this.requestUpdate();
100
+ }
78
101
  updated() {
79
102
  var _a, _b, _c, _d;
80
103
  this.hasLabel = this.label || ((_a = this.slotLabelNodes) === null || _a === void 0 ? void 0 : _a.length) ? true : false;
@@ -126,7 +149,7 @@ let Select = class Select extends FormElement(Subscriber(LitElement)) {
126
149
  })}
127
150
  <slot></slot>
128
151
  </select>
129
- <sonic-icon class="select-chevron" name="nav-arrow-down" size="${this.size}"></sonic-icon>
152
+ <sonic-icon class="select-chevron" name="nav-arrow-down" size="${this.size}"></sonic-icon>
130
153
  </div>
131
154
  <slot name="suffix" @slotchange=${this.onSlotChange}></slot>
132
155
  </div>
@@ -155,7 +178,7 @@ Select.styles = [
155
178
  top: 50%;
156
179
  pointer-events: none;
157
180
  transform: translateY(-50%);
158
- color:var(--sc-input-color);
181
+ color: var(--sc-input-color);
159
182
  }
160
183
 
161
184
  option {
@@ -163,7 +186,6 @@ Select.styles = [
163
186
  color: var(--sc-base-content);
164
187
  background: var(--sc-base);
165
188
  }
166
-
167
189
  `,
168
190
  ];
169
191
  __decorate([
@@ -188,11 +210,14 @@ __decorate([
188
210
  property()
189
211
  ], Select.prototype, "value", null);
190
212
  __decorate([
191
- property({ type: String })
192
- ], Select.prototype, "label", void 0);
213
+ property({ type: Boolean })
214
+ ], Select.prototype, "forceAutoFill", void 0);
193
215
  __decorate([
194
- property({ type: String })
195
- ], Select.prototype, "description", void 0);
216
+ property()
217
+ ], Select.prototype, "description", null);
218
+ __decorate([
219
+ property()
220
+ ], Select.prototype, "label", null);
196
221
  __decorate([
197
222
  queryAssignedNodes({ slot: "label" })
198
223
  ], Select.prototype, "slotLabelNodes", void 0);
@@ -2,7 +2,13 @@ import { LitElement } from "lit";
2
2
  declare const Textarea_base: {
3
3
  new (...args: any[]): {
4
4
  validateFormElement(): void;
5
+ forceAutoFill: boolean;
6
+ _type: "number" | "search" | "file" | "button" | "password" | "url" | "color" | "hidden" | "time" | "image" | "text" | "reset" | "submit" | "month" | "week" | "checkbox" | "radio" | "range" | "tel" | "email" | "date" | "datetime-local";
5
7
  type: "number" | "search" | "file" | "button" | "password" | "url" | "color" | "hidden" | "time" | "image" | "text" | "reset" | "submit" | "month" | "week" | "checkbox" | "radio" | "range" | "tel" | "email" | "date" | "datetime-local";
8
+ _description?: string | undefined;
9
+ description: string | undefined;
10
+ _label?: string | undefined;
11
+ label: string | undefined;
6
12
  tabindex?: number | undefined;
7
13
  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;
8
14
  getFormPublisher(): any;
@@ -53,8 +59,6 @@ export declare class Textarea extends Textarea_base {
53
59
  wrap?: "hard" | "soft";
54
60
  readonly: boolean;
55
61
  placeholder?: string;
56
- label?: string;
57
- description?: string;
58
62
  slotLabelNodes: Array<Node>;
59
63
  slotDescriptionNodes: Array<Node>;
60
64
  slotSuffixNodes: Array<Node>;
@@ -70,7 +70,8 @@ let Textarea = class Textarea extends FormInput(FormElement(Subscriber(LitElemen
70
70
  wrap=${ifDefined(this.wrap)}
71
71
  placeholder="${this.placeholder}"
72
72
  class="form-element textarea custom-scroll"
73
- >${this.value}</textarea
73
+ >
74
+ ${this.value}</textarea
74
75
  >
75
76
  </div>
76
77
 
@@ -113,12 +114,6 @@ __decorate([
113
114
  __decorate([
114
115
  property({ type: String })
115
116
  ], Textarea.prototype, "placeholder", void 0);
116
- __decorate([
117
- property({ type: String })
118
- ], Textarea.prototype, "label", void 0);
119
- __decorate([
120
- property({ type: String })
121
- ], Textarea.prototype, "description", void 0);
122
117
  __decorate([
123
118
  queryAssignedNodes({ slot: "label" })
124
119
  ], Textarea.prototype, "slotLabelNodes", void 0);
@@ -7,11 +7,7 @@ declare const Form: <T extends Constructor<FormElementInterface>>(superClass: T)
7
7
  */
8
8
  _value: string | null;
9
9
  value: string | null;
10
- /**
11
- * Voir la mixin FormElement
12
- */
13
- _name: string;
14
- name: string;
10
+ forceAutoFill: boolean;
15
11
  /**
16
12
  * comme radio,mais peut être désélectionné après sélection
17
13
  */
@@ -48,6 +44,8 @@ declare const Form: <T extends Constructor<FormElementInterface>>(superClass: T)
48
44
  required: boolean;
49
45
  disabled: true | null;
50
46
  formDataProvider: string;
47
+ _name: string;
48
+ name: string;
51
49
  props: any;
52
50
  isConnected: boolean;
53
51
  getAncestorAttributeValue(attributeName: string): string;
@@ -21,10 +21,7 @@ const Form = (superClass) => {
21
21
  * Voir la mixin FormElement.
22
22
  */
23
23
  this._value = "";
24
- /**
25
- * Voir la mixin FormElement
26
- */
27
- this._name = "";
24
+ this.forceAutoFill = false;
28
25
  /**
29
26
  * comme radio,mais peut être désélectionné après sélection
30
27
  */
@@ -42,7 +39,7 @@ const Form = (superClass) => {
42
39
  return this._value;
43
40
  }
44
41
  set value(value) {
45
- if (this.hasAttribute("value"))
42
+ if (this.hasAttribute("value") && !this.forceAutoFill)
46
43
  value = this.getAttribute("value");
47
44
  if (this._value == value)
48
45
  return;
@@ -50,14 +47,6 @@ const Form = (superClass) => {
50
47
  this.updateDataValue();
51
48
  this.requestUpdate();
52
49
  }
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
50
  get checked() {
62
51
  return this._checked;
63
52
  }
@@ -71,7 +60,7 @@ const Form = (superClass) => {
71
60
  if (!input || input.checkValidity())
72
61
  return;
73
62
  let value = this.getFormPublisher()[this.name].get();
74
- if ((this.unique || this.radio) && (value !== null && value.toString().length > 0))
63
+ if ((this.unique || this.radio) && value !== null && value.toString().length > 0)
75
64
  return;
76
65
  this.getFormPublisher().isFormValid = false;
77
66
  input.reportValidity();
@@ -144,7 +133,7 @@ const Form = (superClass) => {
144
133
  ], FormCheckable.prototype, "value", null);
145
134
  __decorate([
146
135
  property()
147
- ], FormCheckable.prototype, "name", null);
136
+ ], FormCheckable.prototype, "forceAutoFill", void 0);
148
137
  __decorate([
149
138
  property({ type: Boolean })
150
139
  ], FormCheckable.prototype, "unique", void 0);
@@ -24,6 +24,7 @@ const Form = (superClass) => {
24
24
  this.error = false;
25
25
  this.autofocus = false;
26
26
  this.required = false;
27
+ this.forceAutoFill = false;
27
28
  this.disabled = null;
28
29
  this.onValueAssign = null;
29
30
  this.onFormValueAssign = null;
@@ -55,7 +56,10 @@ const Form = (superClass) => {
55
56
  return this._name;
56
57
  }
57
58
  set name(value) {
59
+ if (this.hasAttribute("name") && !this.forceAutoFill)
60
+ value = this.getAttribute("name");
58
61
  this._name = value;
62
+ this.requestUpdate();
59
63
  }
60
64
  validateFormElement() { }
61
65
  updateDataValue() {
@@ -235,6 +239,9 @@ const Form = (superClass) => {
235
239
  __decorate([
236
240
  property({ type: Boolean })
237
241
  ], FormElement.prototype, "required", void 0);
242
+ __decorate([
243
+ property()
244
+ ], FormElement.prototype, "forceAutoFill", void 0);
238
245
  __decorate([
239
246
  property({ type: Boolean })
240
247
  ], FormElement.prototype, "disabled", void 0);
@@ -1,13 +1,20 @@
1
1
  import { FormElementInterface } from "@supersoniks/concorde/core/mixins/FormElement";
2
2
  declare type Constructor<T> = new (...args: any[]) => T;
3
+ declare type Type = "button" | "checkbox" | "color" | "date" | "datetime-local" | "email" | "file" | "hidden" | "image" | "month" | "number" | "password" | "radio" | "range" | "reset" | "search" | "submit" | "tel" | "text" | "time" | "url" | "week";
3
4
  declare const Form: <T extends Constructor<FormElementInterface>>(superClass: T) => {
4
5
  new (...args: any[]): {
5
6
  validateFormElement(): void;
7
+ forceAutoFill: boolean;
6
8
  /**
7
9
  * Le type De l'input, comme en html cependant tous les types ne sont pas actuellements compatibles en raison du style en vigueur
8
10
  * On peut essayer text, date, color, email par exemple, mais pas radio/checkbox/range a priori
9
11
  */
10
- type: "button" | "checkbox" | "color" | "date" | "datetime-local" | "email" | "file" | "hidden" | "image" | "month" | "number" | "password" | "radio" | "range" | "reset" | "search" | "submit" | "tel" | "text" | "time" | "url" | "week";
12
+ _type: Type;
13
+ type: Type;
14
+ _description?: string | undefined;
15
+ description: string | undefined;
16
+ _label?: string | undefined;
17
+ label: string | undefined;
11
18
  tabindex?: number | undefined;
12
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;
13
20
  getFormPublisher(): any;
@@ -20,10 +27,6 @@ declare const Form: <T extends Constructor<FormElementInterface>>(superClass: T)
20
27
  required: boolean;
21
28
  disabled: true | null;
22
29
  formDataProvider: string;
23
- /**
24
- * Le type De l'input, comme en html cependant tous les types ne sont pas actuellements compatibles en raison du style en vigueur
25
- * On peut essayer text, date, color, email par exemple, mais pas radio/checkbox/range a priori
26
- */
27
30
  _value: any;
28
31
  value: any;
29
32
  _name: string;
@@ -9,11 +9,12 @@ const Form = (superClass) => {
9
9
  class FormInput extends superClass {
10
10
  constructor(...args) {
11
11
  super();
12
+ this.forceAutoFill = false;
12
13
  /**
13
14
  * Le type De l'input, comme en html cependant tous les types ne sont pas actuellements compatibles en raison du style en vigueur
14
15
  * On peut essayer text, date, color, email par exemple, mais pas radio/checkbox/range a priori
15
16
  */
16
- this.type = "text";
17
+ this._type = "text";
17
18
  args;
18
19
  }
19
20
  validateFormElement() {
@@ -25,10 +26,46 @@ const Form = (superClass) => {
25
26
  this.getFormPublisher().isFormValid = false;
26
27
  input.reportValidity();
27
28
  }
29
+ set type(value) {
30
+ if (this.hasAttribute("type") && !this.forceAutoFill)
31
+ value = this.getAttribute("type");
32
+ this._type = value;
33
+ this.requestUpdate();
34
+ }
35
+ get type() {
36
+ return this._type;
37
+ }
38
+ get description() {
39
+ return this._description;
40
+ }
41
+ set description(value) {
42
+ if (this.hasAttribute("description") && !this.forceAutoFill)
43
+ value = this.getAttribute("description");
44
+ this._description = value;
45
+ this.requestUpdate();
46
+ }
47
+ get label() {
48
+ return this._label;
49
+ }
50
+ set label(value) {
51
+ if (this.hasAttribute("label") && !this.forceAutoFill)
52
+ value = this.getAttribute("label");
53
+ this._label = value;
54
+ this.requestUpdate();
55
+ }
28
56
  }
57
+ __decorate([
58
+ property()
59
+ ], FormInput.prototype, "forceAutoFill", void 0);
29
60
  __decorate([
30
61
  property({ type: String })
31
- ], FormInput.prototype, "type", void 0);
62
+ ], FormInput.prototype, "type", null);
63
+ __decorate([
64
+ property()
65
+ ], FormInput.prototype, "description", null);
66
+ __decorate([
67
+ property()
68
+ ], FormInput.prototype, "label", null);
32
69
  __decorate([
33
70
  property({ type: Number })
34
71
  ], FormInput.prototype, "tabindex", void 0);
@@ -50,6 +50,7 @@ const Subscriber = (superClass) => {
50
50
  * noAutoFill permet de désactiver le remplissage automatique des propriétés par le publisher dans le cas ou on utilise "props" seulement ou le dataBinding par exemple
51
51
  */
52
52
  this.noAutoFill = false;
53
+ this.forceAutoFill = false;
53
54
  /**
54
55
  *
55
56
  */
@@ -361,6 +362,9 @@ const Subscriber = (superClass) => {
361
362
  __decorate([
362
363
  property({ type: Boolean })
363
364
  ], SubscriberElement.prototype, "noAutoFill", void 0);
365
+ __decorate([
366
+ property({ type: Boolean })
367
+ ], SubscriberElement.prototype, "forceAutoFill", void 0);
364
368
  __decorate([
365
369
  property({ type: Object })
366
370
  ], SubscriberElement.prototype, "propertyMap", void 0);
@@ -50,6 +50,10 @@ declare class API {
50
50
  */
51
51
  computeURL(path: String): string;
52
52
  send(path: String, data: any, method?: string, additionalHeaders?: HeadersInit): Promise<any>;
53
+ /**
54
+ * Agit comme une soumission de formulaire, mais attends un json en réponse
55
+ */
56
+ submitFormData(path: String, data: any, method?: string, additionalHeaders?: HeadersInit): Promise<any>;
53
57
  /**
54
58
  * Appel send en utilisant le méthode PUT
55
59
  */
package/core/utils/api.js CHANGED
@@ -95,7 +95,6 @@ class API {
95
95
  */
96
96
  send(path, data, method = "POST", additionalHeaders) {
97
97
  return __awaiter(this, void 0, void 0, function* () {
98
- yield this.auth();
99
98
  let headers = yield this.createHeaders(additionalHeaders);
100
99
  headers["Accept"] = "application/json";
101
100
  headers["Content-Type"] = "application/json";
@@ -114,6 +113,31 @@ class API {
114
113
  }
115
114
  });
116
115
  }
116
+ /**
117
+ * Agit comme une soumission de formulaire, mais attends un json en réponse
118
+ */
119
+ submitFormData(path, data, method = "POST", additionalHeaders) {
120
+ return __awaiter(this, void 0, void 0, function* () {
121
+ let headers = yield this.createHeaders(additionalHeaders);
122
+ headers["Accept"] = "application/json";
123
+ let formData = new FormData();
124
+ for (let z in data)
125
+ formData.set(z, data[z]);
126
+ let result = yield fetch(this.computeURL(path), {
127
+ headers: headers,
128
+ method: method,
129
+ body: formData,
130
+ });
131
+ try {
132
+ let json = yield result.json();
133
+ json._sonic_http_response_ = result;
134
+ return json;
135
+ }
136
+ catch (e) {
137
+ return { _sonic_http_response_: result };
138
+ }
139
+ });
140
+ }
117
141
  /**
118
142
  * Appel send en utilisant le méthode PUT
119
143
  */
package/mixins.d.ts CHANGED
@@ -41,8 +41,7 @@ export declare const FormCheckable: <T extends new (...args: any[]) => myFormEle
41
41
  new (...args: any[]): {
42
42
  _value: string | null;
43
43
  value: string | null;
44
- _name: string;
45
- name: string;
44
+ forceAutoFill: boolean;
46
45
  unique: true | null;
47
46
  radio: true | null;
48
47
  _checked: true | null;
@@ -61,6 +60,8 @@ export declare const FormCheckable: <T extends new (...args: any[]) => myFormEle
61
60
  required: boolean;
62
61
  disabled: true | null;
63
62
  formDataProvider: string;
63
+ _name: string;
64
+ name: string;
64
65
  props: any;
65
66
  isConnected: boolean;
66
67
  getAncestorAttributeValue(attributeName: string): string;
@@ -89,7 +90,13 @@ export declare const FormElement: <T extends new (...args: any[]) => mySubscribe
89
90
  export declare const FormInput: <T extends new (...args: any[]) => myFormElement.FormElementInterface>(superClass: T) => {
90
91
  new (...args: any[]): {
91
92
  validateFormElement(): void;
93
+ forceAutoFill: boolean;
94
+ _type: "number" | "search" | "file" | "button" | "password" | "url" | "color" | "hidden" | "time" | "image" | "text" | "reset" | "submit" | "month" | "week" | "checkbox" | "radio" | "range" | "tel" | "email" | "date" | "datetime-local";
92
95
  type: "number" | "search" | "file" | "button" | "password" | "url" | "color" | "hidden" | "time" | "image" | "text" | "reset" | "submit" | "month" | "week" | "checkbox" | "radio" | "range" | "tel" | "email" | "date" | "datetime-local";
96
+ _description?: string | undefined;
97
+ description: string | undefined;
98
+ _label?: string | undefined;
99
+ label: string | undefined;
93
100
  tabindex?: number | undefined;
94
101
  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;
95
102
  getFormPublisher(): any;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@supersoniks/concorde",
3
- "version": "1.1.31",
3
+ "version": "1.1.34",
4
4
  "customElements": "custom-elements.json",
5
5
  "license": "MIT",
6
6
  "publishConfig": {