@supersoniks/concorde 1.1.44 → 1.1.46

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.
Files changed (54) hide show
  1. package/README.md +9 -7
  2. package/concorde-core.bundle.js +39 -24
  3. package/concorde-core.es.js +907 -320
  4. package/core/components/functional/fetch/fetch.d.ts +2 -1
  5. package/core/components/functional/list/list.d.ts +3 -1
  6. package/core/components/functional/list/list.js +12 -7
  7. package/core/components/functional/queue/queue.d.ts +9 -2
  8. package/core/components/functional/queue/queue.js +131 -67
  9. package/core/components/functional/router/router.js +13 -4
  10. package/core/components/functional/sdui/sdui.d.ts +3 -2
  11. package/core/components/functional/sdui/sdui.js +1 -1
  12. package/core/components/functional/states/states.js +1 -0
  13. package/core/components/functional/value/value.js +3 -2
  14. package/core/components/ui/alert/alert.d.ts +3 -0
  15. package/core/components/ui/alert/alert.js +33 -1
  16. package/core/components/ui/badge/badge.d.ts +1 -1
  17. package/core/components/ui/badge/badge.js +9 -3
  18. package/core/components/ui/button/button.d.ts +1 -0
  19. package/core/components/ui/button/button.js +32 -28
  20. package/core/components/ui/form/checkbox/checkbox.d.ts +3 -0
  21. package/core/components/ui/form/checkbox/checkbox.js +14 -3
  22. package/core/components/ui/form/css/form-control.d.ts +1 -0
  23. package/core/components/ui/form/css/form-control.js +17 -0
  24. package/core/components/ui/form/input/input.d.ts +5 -3
  25. package/core/components/ui/form/input/input.js +47 -3
  26. package/core/components/ui/form/input-autocomplete/input-autocomplete.d.ts +93 -13
  27. package/core/components/ui/form/input-autocomplete/input-autocomplete.js +181 -52
  28. package/core/components/ui/form/select/select.js +16 -4
  29. package/core/components/ui/form/textarea/textarea.d.ts +1 -0
  30. package/core/components/ui/group/group.js +7 -1
  31. package/core/components/ui/icon/icon.js +1 -1
  32. package/core/components/ui/modal/modal-close.js +2 -3
  33. package/core/components/ui/modal/modal-content.js +1 -0
  34. package/core/components/ui/modal/modal.d.ts +8 -0
  35. package/core/components/ui/modal/modal.js +34 -6
  36. package/core/components/ui/pop/pop.d.ts +5 -4
  37. package/core/components/ui/pop/pop.js +85 -44
  38. package/core/components/ui/theme/theme-collection/core-variables.js +18 -9
  39. package/core/components/ui/theme/theme.js +8 -3
  40. package/core/components/ui/tooltip/tooltip.js +3 -3
  41. package/core/mixins/Fetcher.d.ts +2 -1
  42. package/core/mixins/Fetcher.js +42 -10
  43. package/core/mixins/FormCheckable.d.ts +1 -0
  44. package/core/mixins/FormElement.d.ts +1 -0
  45. package/core/mixins/FormElement.js +6 -2
  46. package/core/mixins/FormInput.d.ts +1 -0
  47. package/core/mixins/Subscriber.d.ts +1 -0
  48. package/core/mixins/Subscriber.js +17 -12
  49. package/core/utils/PublisherProxy.d.ts +30 -3
  50. package/core/utils/PublisherProxy.js +218 -6
  51. package/core/utils/api.d.ts +29 -3
  52. package/core/utils/api.js +117 -24
  53. package/mixins.d.ts +4 -1
  54. package/package.json +7 -2
package/core/utils/api.js CHANGED
@@ -12,34 +12,61 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
12
12
  import HTML from "@supersoniks/concorde/core/utils/HTML";
13
13
  import Objects from "@supersoniks/concorde/core/utils/Objects";
14
14
  class API {
15
+ set token(token) {
16
+ this._token = token;
17
+ if (!token) {
18
+ API.tokens.delete(this.serviceURL);
19
+ return;
20
+ }
21
+ if (API.invalidTokens.includes(token))
22
+ return;
23
+ API.tokens.set(this.serviceURL, token);
24
+ }
25
+ get token() {
26
+ // si le token est marqué invalide, on utilise utilise la dernière version valide connue du token pour ce serviceURL
27
+ return API.invalidTokens.includes(this._token) ? API.tokens.get(this.serviceURL) : this._token;
28
+ }
29
+ handleInvalidToken(token) {
30
+ if (!token)
31
+ return;
32
+ if (API.invalidTokens.includes(token))
33
+ return;
34
+ API.invalidTokens.push(token);
35
+ this.token = null;
36
+ }
15
37
  constructor(config) {
16
38
  /**
17
39
  * Le endPoint pour obtenir le bearer token qui sera concaténé à l'url du service
18
40
  */
19
41
  this.addHTTPResponse = false;
42
+ this.cache = "default";
20
43
  this.serviceURL = config.serviceURL;
21
44
  if (!this.serviceURL)
22
45
  this.serviceURL = document.location.origin;
23
46
  this.userName = config.userName;
24
47
  this.password = config.password;
25
- this.token = config.token;
48
+ if (config.token)
49
+ this.token = config.token;
26
50
  this.tokenProvider = config.tokenProvider;
51
+ this.authToken = config.authToken;
27
52
  this.addHTTPResponse = config.addHTTPResponse || false;
28
53
  this.credentials = config.credentials;
54
+ this.cache = config.cache || "default";
29
55
  }
30
- handleResult(fetchResult) {
56
+ handleResult(fetchResult, lastCall) {
31
57
  var _a;
32
58
  return __awaiter(this, void 0, void 0, function* () {
33
59
  this.lastResult = fetchResult;
34
- const contentType = (_a = fetchResult === null || fetchResult === void 0 ? void 0 : fetchResult.headers.get("content-type")) === null || _a === void 0 ? void 0 : _a.toLowerCase();
60
+ const contentType = (_a = fetchResult.headers.get("content-type")) === null || _a === void 0 ? void 0 : _a.toLowerCase();
61
+ const httpCode = fetchResult.status;
35
62
  let result = {};
36
- if (contentType && contentType.indexOf("text/") == 0) {
37
- const str = yield (fetchResult === null || fetchResult === void 0 ? void 0 : fetchResult.text());
63
+ if (!contentType || contentType.indexOf("text/") == 0) {
64
+ const str = yield fetchResult.text();
38
65
  result = { text: str };
39
66
  }
40
67
  else {
41
68
  try {
42
- result = yield (fetchResult === null || fetchResult === void 0 ? void 0 : fetchResult.json());
69
+ result = yield fetchResult.json();
43
70
  }
44
71
  catch (e) {
45
72
  result = {};
@@ -48,6 +75,15 @@ class API {
48
75
  if (this.addHTTPResponse && Objects.isObject(result)) {
49
76
  result._sonic_http_response_ = fetchResult;
50
77
  }
78
+ if (httpCode === 498 && !API.failledTokenUpdates.has(this.serviceURL)) {
79
+ this.handleInvalidToken(this.token);
80
+ if (lastCall.apiMethod === "get") {
81
+ result = yield this[lastCall.apiMethod](lastCall.path, lastCall.additionalHeaders);
82
+ }
83
+ else {
84
+ result = yield this[lastCall.apiMethod](lastCall.path, lastCall.data, lastCall.method, lastCall.additionalHeaders);
85
+ }
86
+ }
51
87
  return result;
52
88
  });
53
89
  }
@@ -62,39 +98,63 @@ class API {
62
98
  this.token = API.tokens.get(this.serviceURL);
63
99
  return;
64
100
  }
65
- if (!this.userName || !this.password || !this.tokenProvider)
101
+ if (!this.tokenProvider)
66
102
  return;
67
- const headers = {
68
- Authorization: "Basic " + window.btoa(unescape(encodeURIComponent(this.userName + ":" + this.password))),
69
- };
70
- const result = yield fetch(this.computeURL(this.tokenProvider), {
103
+ let headers = {};
104
+ if (this.userName && this.password) {
105
+ headers = {
106
+ Authorization: "Basic " + window.btoa(unescape(encodeURIComponent(this.userName + ":" + this.password))),
107
+ };
108
+ }
109
+ else if (this.authToken) {
110
+ headers = {
111
+ Authorization: "Bearer " + this.authToken,
112
+ };
113
+ }
114
+ const serviceURL = new URL(this.serviceURL);
115
+ const serviceHost = serviceURL.protocol + "//" + serviceURL.host;
116
+ const result = yield fetch(this.computeURL(this.tokenProvider, { serviceHost: serviceHost }), {
71
117
  headers: headers,
72
118
  credentials: this.credentials,
73
119
  });
74
120
  try {
75
121
  const json = yield result.json();
76
- this.token = json.token;
77
- API.tokens.set(this.serviceURL, this.token);
122
+ const newToken = json.token;
123
+ if (newToken) {
124
+ this.token = json.token;
125
+ }
126
+ else {
127
+ API.failledTokenUpdates.set(this.serviceURL, true);
128
+ }
78
129
  }
79
130
  catch (e) {
80
- console.log("Problème au moment du parsing du json au retour de l'authentification");
131
+ API.failledTokenUpdates.set(this.serviceURL, true);
81
132
  }
82
133
  });
83
134
  }
84
135
  get(path, additionalHeaders) {
85
136
  return __awaiter(this, void 0, void 0, function* () {
137
+ const lastCall = {
138
+ apiMethod: "get",
139
+ path: path,
140
+ additionalHeaders: additionalHeaders,
141
+ };
86
142
  const headers = yield this.createHeaders(additionalHeaders);
87
143
  const url = this.computeURL(path);
88
- if (!API.loadingGetPromises.has(url)) {
144
+ const mapKey = JSON.stringify({
145
+ url: url,
146
+ headers: headers,
147
+ });
148
+ if (!API.loadingGetPromises.has(mapKey)) {
89
149
  const promise = new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
90
- const result = yield fetch(url, { headers: headers, credentials: this.credentials });
91
- const handledResult = yield this.handleResult(result);
150
+ const result = yield fetch(url, { headers: headers, credentials: this.credentials, cache: this.cache });
151
+ const handledResult = yield this.handleResult(result, lastCall);
92
152
  resolve(handledResult);
93
153
  }));
94
- API.loadingGetPromises.set(url, promise);
154
+ API.loadingGetPromises.set(mapKey, promise);
95
155
  }
96
- const result = (yield API.loadingGetPromises.get(url));
97
- API.loadingGetPromises.delete(url);
156
+ const result = (yield API.loadingGetPromises.get(mapKey));
157
+ API.loadingGetPromises.delete(mapKey);
98
158
  return result;
99
159
  });
100
160
  }
@@ -118,14 +178,32 @@ class API {
118
178
  /**
119
179
  * Concatène le serviceURL et le endpoint donné en paramètre
120
180
  */
121
- computeURL(path) {
122
- return (this.serviceURL + "/" + path).replace(/([^(https?:)])\/{2,}/g, "$1/");
181
+ computeURL(path, query = {}) {
182
+ let url = "";
183
+ if (path.startsWith("http"))
184
+ url = path;
185
+ else
186
+ url = this.serviceURL + "/" + path;
187
+ if (!url.startsWith("http"))
188
+ url = window.location.origin + url;
189
+ const computedUrl = new URL(url);
190
+ for (const key in query) {
191
+ computedUrl.searchParams.set(key, query[key]);
192
+ }
193
+ return computedUrl.toString().replace(/([^(https?:)])\/{2,}/g, "$1/");
123
194
  }
124
195
  /*
125
196
  * Envoie des données au endPoint passé en paramètre. par défaut en POST
126
197
  */
127
198
  send(path, data, method = "POST", additionalHeaders) {
128
199
  return __awaiter(this, void 0, void 0, function* () {
200
+ const lastCall = {
201
+ apiMethod: "send",
202
+ path: path,
203
+ additionalHeaders: additionalHeaders,
204
+ method: method,
205
+ data: data,
206
+ };
129
207
  const headers = yield this.createHeaders(additionalHeaders);
130
208
  headers["Accept"] = "application/json";
131
209
  headers["Content-Type"] = "application/json";
@@ -135,7 +213,7 @@ class API {
135
213
  method: method,
136
214
  body: JSON.stringify(data),
137
215
  });
138
- return (yield this.handleResult(result));
216
+ return (yield this.handleResult(result, lastCall));
139
217
  });
140
218
  }
141
219
  /**
@@ -143,6 +221,13 @@ class API {
143
221
  */
144
222
  submitFormData(path, data, method = "POST", additionalHeaders) {
145
223
  return __awaiter(this, void 0, void 0, function* () {
224
+ const lastCall = {
225
+ apiMethod: "submitFormData",
226
+ path: path,
227
+ additionalHeaders: additionalHeaders,
228
+ method: method,
229
+ data: data,
230
+ };
146
231
  const headers = yield this.createHeaders(additionalHeaders);
147
232
  headers["Accept"] = "application/json";
148
233
  const formData = new FormData();
@@ -155,7 +240,7 @@ class API {
155
240
  method: method,
156
241
  body: formData,
157
242
  });
158
- return (yield this.handleResult(result));
243
+ return (yield this.handleResult(result, lastCall));
159
244
  });
160
245
  }
161
246
  /**
@@ -191,4 +276,12 @@ API.loadingGetPromises = new Map();
191
276
  * Tableau static des tokens stokés en memoire vive (comportement à revoir à l'occasion)
192
277
  */
193
278
  API.tokens = new Map();
279
+ /**
280
+ * Tableau stockant l'ensemble des tokens invalides
281
+ */
282
+ API.invalidTokens = [];
283
+ /**
284
+ * Tableau static des tentatives échouées de récupération auto du token
285
+ */
286
+ API.failledTokenUpdates = new Map();
194
287
  export default API;
package/mixins.d.ts CHANGED
@@ -18,7 +18,7 @@ export declare const Fetcher: <T extends new (...args: any[]) => mySubscriber.Su
18
18
  onInvalidate?: (() => void) | undefined;
19
19
  disconnectedCallback(): void;
20
20
  connectedCallback(): void;
21
- firstUpdated(): void;
21
+ handleLazyLoad(): void;
22
22
  onIntersection(entries: IntersectionObserverEntry[]): void;
23
23
  propertyMap: object;
24
24
  isConnected: boolean;
@@ -44,6 +44,7 @@ export declare const Fetcher: <T extends new (...args: any[]) => mySubscriber.Su
44
44
  requestUpdate(): void;
45
45
  getAttribute(name: string): string;
46
46
  hasAttribute(attributeName: string): boolean;
47
+ getBoundingClientRect(): DOMRect;
47
48
  };
48
49
  } & T;
49
50
  export declare const FormCheckable: <T extends new (...args: any[]) => myFormElement.FormElementInterface>(superClass: T) => {
@@ -105,6 +106,7 @@ export declare const FormCheckable: <T extends new (...args: any[]) => myFormEle
105
106
  requestUpdate(): void;
106
107
  getAttribute(name: string): string;
107
108
  hasAttribute(attributeName: string): boolean;
109
+ getBoundingClientRect(): DOMRect;
108
110
  };
109
111
  } & T;
110
112
  import * as myFormElement from "@supersoniks/concorde/core/mixins/FormElement";
@@ -165,6 +167,7 @@ export declare const FormInput: <T extends new (...args: any[]) => myFormElement
165
167
  getAttribute(name: string): string;
166
168
  hasAttribute(attributeName: string): boolean;
167
169
  disconnectedCallback(): void;
170
+ getBoundingClientRect(): DOMRect;
168
171
  };
169
172
  } & T;
170
173
  import * as mySubscriber from "@supersoniks/concorde/core/mixins/Subscriber";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@supersoniks/concorde",
3
- "version": "1.1.44",
3
+ "version": "1.1.46",
4
4
  "customElements": "custom-elements.json",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -9,8 +9,10 @@
9
9
  "dependencies": {
10
10
  "@lit-labs/motion": "^1.0.1",
11
11
  "@lit-labs/observers": "^1.0.1",
12
+ "@tailwindcss/container-queries": "^0.1.1",
12
13
  "@types/prismjs": "^1.26.0",
13
14
  "chart.js": "^3.9.1",
15
+ "iframe-resizer": "^4.3.6",
14
16
  "intl": "^1.2.5",
15
17
  "jsbarcode": "^3.11.5",
16
18
  "lit": "^2.2.3",
@@ -20,6 +22,7 @@
20
22
  },
21
23
  "devDependencies": {
22
24
  "@tailwindcss/typography": "^0.5.2",
25
+ "@types/iframe-resizer": "^3.5.9",
23
26
  "@types/intl": "^1.2.0",
24
27
  "@types/jest": "^29.2.6",
25
28
  "@types/node": "^18.11.18",
@@ -73,6 +76,8 @@
73
76
  "./functional/sdui/SDUIDescriptorTransformer": "./core/components/functional/sdui/SDUIDescriptorTransformer.js",
74
77
  "./core/components/functional/sdui/default-library.json": "./core/components/functional/sdui/default-library.json",
75
78
  "./functional/sdui/default-library.json": "./core/components/functional/sdui/default-library.json",
79
+ "./core/components/functional/sdui/example.json": "./core/components/functional/sdui/example.json",
80
+ "./functional/sdui/example.json": "./core/components/functional/sdui/example.json",
76
81
  "./core/components/functional/sdui/sdui-utils": "./core/components/functional/sdui/sdui-utils.js",
77
82
  "./functional/sdui/sdui-utils": "./core/components/functional/sdui/sdui-utils.js",
78
83
  "./core/components/functional/sdui/sdui": "./core/components/functional/sdui/sdui.js",
@@ -260,13 +265,13 @@
260
265
  "./docs/navigation/navigation": "./docs/navigation/navigation.js",
261
266
  "./docs/navigation": "./docs/navigation/navigation.js",
262
267
  "./docs/prism/index": "./docs/prism/index.js",
263
- "./docs/search/doc-search.json": "./docs/search/doc-search.json",
264
268
  "./docs/search/docs-search.json": "./docs/search/docs-search.json",
265
269
  "./docs/search/markdown-renderer": "./docs/search/markdown-renderer.js",
266
270
  "./docs/search/page": "./docs/search/page.js",
267
271
  "./docs/search/search": "./docs/search/search.js",
268
272
  "./docs/search": "./docs/search/search.js",
269
273
  "./index-billetterie": "./index-billetterie.js",
274
+ "./index-customer": "./index-customer.js",
270
275
  "./index-shared": "./index-shared.js",
271
276
  "./index": "./index.js",
272
277
  "./test-utils/TestUtils": "./test-utils/TestUtils.js",