@supersoniks/concorde 3.1.4 → 3.1.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@supersoniks/concorde",
3
- "version": "3.1.4",
3
+ "version": "3.1.6",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "",
@@ -32,4 +32,7 @@ export const fontSize = css`
32
32
  :host([size="2xl"]) {
33
33
  --sc-fs: 1.5rem;
34
34
  }
35
+ :host([size="inherit"]) {
36
+ --sc-fs: 1em;
37
+ }
35
38
  `;
@@ -1,7 +1,14 @@
1
- import {html, LitElement, css, PropertyValues} from "lit";
2
- import {styleMap} from "lit/directives/style-map.js";
3
- import {customElement, property, queryAssignedElements, state, query} from "lit/decorators.js";
1
+ import { html, LitElement, css, PropertyValues } from "lit";
2
+ import { styleMap } from "lit/directives/style-map.js";
3
+ import {
4
+ customElement,
5
+ property,
6
+ queryAssignedElements,
7
+ state,
8
+ query,
9
+ } from "lit/decorators.js";
4
10
  import "@supersoniks/concorde/core/components/ui/menu/menu-item";
11
+ import { Size } from "../_css/size";
5
12
  const tagName = "sonic-menu";
6
13
 
7
14
  @customElement(tagName)
@@ -64,12 +71,28 @@ export class MenuItems extends LitElement {
64
71
  display: none !important;
65
72
  }
66
73
  :host([scrollable][direction="row"].shadow-right) {
67
- -webkit-mask-image: linear-gradient(to left, rgba(0, 0, 0, 0), rgba(0, 0, 0, 1) 10%);
68
- mask-image: linear-gradient(to left, rgba(0, 0, 0, 0), rgba(0, 0, 0, 1) 10%);
74
+ -webkit-mask-image: linear-gradient(
75
+ to left,
76
+ rgba(0, 0, 0, 0),
77
+ rgba(0, 0, 0, 1) 10%
78
+ );
79
+ mask-image: linear-gradient(
80
+ to left,
81
+ rgba(0, 0, 0, 0),
82
+ rgba(0, 0, 0, 1) 10%
83
+ );
69
84
  }
70
85
  :host([scrollable][direction="row"].shadow-left) {
71
- -webkit-mask-image: linear-gradient(to right, rgba(0, 0, 0, 0), rgba(0, 0, 0, 1) 10%);
72
- mask-image: linear-gradient(to right, rgba(0, 0, 0, 0), rgba(0, 0, 0, 1) 10%);
86
+ -webkit-mask-image: linear-gradient(
87
+ to right,
88
+ rgba(0, 0, 0, 0),
89
+ rgba(0, 0, 0, 1) 10%
90
+ );
91
+ mask-image: linear-gradient(
92
+ to right,
93
+ rgba(0, 0, 0, 0),
94
+ rgba(0, 0, 0, 1) 10%
95
+ );
73
96
  }
74
97
  :host([scrollable][direction="row"].shadow-left.shadow-right) {
75
98
  -webkit-mask-image: linear-gradient(
@@ -79,19 +102,53 @@ export class MenuItems extends LitElement {
79
102
  rgba(0, 0, 0, 1) 90%,
80
103
  rgba(0, 0, 0, 0) 100%
81
104
  );
82
- mask-image: linear-gradient(to right, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 1) 10%, rgba(0, 0, 0, 1) 90%, rgba(0, 0, 0, 0) 100%);
105
+ mask-image: linear-gradient(
106
+ to right,
107
+ rgba(0, 0, 0, 0) 0%,
108
+ rgba(0, 0, 0, 1) 10%,
109
+ rgba(0, 0, 0, 1) 90%,
110
+ rgba(0, 0, 0, 0) 100%
111
+ );
83
112
  }
84
113
  :host([scrollable][direction="column"].shadow-top) {
85
- -webkit-mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0), rgba(0, 0, 0, 1) 10%);
86
- mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0), rgba(0, 0, 0, 1) 10%);
114
+ -webkit-mask-image: linear-gradient(
115
+ to bottom,
116
+ rgba(0, 0, 0, 0),
117
+ rgba(0, 0, 0, 1) 10%
118
+ );
119
+ mask-image: linear-gradient(
120
+ to bottom,
121
+ rgba(0, 0, 0, 0),
122
+ rgba(0, 0, 0, 1) 10%
123
+ );
87
124
  }
88
125
  :host([scrollable][direction="column"].shadow-bottom) {
89
- -webkit-mask-image: linear-gradient(to top, rgba(0, 0, 0, 0), rgba(0, 0, 0, 1) 10%);
90
- mask-image: linear-gradient(to top, rgba(0, 0, 0, 0), rgba(0, 0, 0, 1) 10%);
126
+ -webkit-mask-image: linear-gradient(
127
+ to top,
128
+ rgba(0, 0, 0, 0),
129
+ rgba(0, 0, 0, 1) 10%
130
+ );
131
+ mask-image: linear-gradient(
132
+ to top,
133
+ rgba(0, 0, 0, 0),
134
+ rgba(0, 0, 0, 1) 10%
135
+ );
91
136
  }
92
137
  :host([scrollable][direction="column"].shadow-top.shadow-bottom) {
93
- -webkit-mask-image: linear-gradient(to top, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 1) 10%, rgba(0, 0, 0, 1) 90%, rgba(0, 0, 0, 0) 100%);
94
- mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 1) 10%, rgba(0, 0, 0, 1) 90%, rgba(0, 0, 0, 0) 100%);
138
+ -webkit-mask-image: linear-gradient(
139
+ to top,
140
+ rgba(0, 0, 0, 0) 0%,
141
+ rgba(0, 0, 0, 1) 10%,
142
+ rgba(0, 0, 0, 1) 90%,
143
+ rgba(0, 0, 0, 0) 100%
144
+ );
145
+ mask-image: linear-gradient(
146
+ to bottom,
147
+ rgba(0, 0, 0, 0) 0%,
148
+ rgba(0, 0, 0, 1) 10%,
149
+ rgba(0, 0, 0, 1) 90%,
150
+ rgba(0, 0, 0, 0) 100%
151
+ );
95
152
  }
96
153
  `,
97
154
  ];
@@ -100,36 +157,47 @@ export class MenuItems extends LitElement {
100
157
  * Taille du composant, peut avoir un effet sur ses composants enfants
101
158
  * tels que les dividers / boutons,... qui n'auraient pas d'attribut size précisés.
102
159
  */
103
- @property({type: String, reflect: true}) size: "" | "xs" | "sm" | "lg" = "";
160
+ @property({ type: String, reflect: true }) size?: Size;
104
161
  /**
105
162
  * Direction
106
163
  */
107
- @property({type: String, reflect: true}) direction: "row" | "column" = "column";
108
- @property({type: String}) gap = "var(--sc-menu-gap)";
164
+ @property({ type: String, reflect: true }) direction: "row" | "column" =
165
+ "column";
166
+ @property({ type: String }) gap = "var(--sc-menu-gap)";
109
167
 
110
- @property({type: String, reflect: true}) align: "center" | "left" | "right" = "left";
168
+ @property({ type: String, reflect: true }) align:
169
+ | "center"
170
+ | "left"
171
+ | "right" = "left";
111
172
 
112
173
  /**
113
174
  * Ombre
114
175
  */
115
- @property({type: String, reflect: true}) shadow: "" | "sm" | "md" | "lg" | "xl" | "none" | null = null;
116
-
117
- @property({type: String}) moreShape: "square" | "circle" = "circle";
118
- @property({type: Boolean}) scrollable = false;
176
+ @property({ type: String, reflect: true }) shadow:
177
+ | ""
178
+ | "sm"
179
+ | "md"
180
+ | "lg"
181
+ | "xl"
182
+ | "none"
183
+ | null = null;
184
+
185
+ @property({ type: String }) moreShape: "square" | "circle" = "circle";
186
+ @property({ type: Boolean }) scrollable = false;
119
187
 
120
188
  observer: ResizeObserver | null = null;
121
189
 
122
190
  /**
123
191
  * Propriété min-width du bouton
124
192
  */
125
- @property({type: String}) minWidth = "0";
193
+ @property({ type: String }) minWidth = "0";
126
194
 
127
195
  @query("menu") menu!: HTMLElement;
128
196
 
129
- @queryAssignedElements({selector: "sonic-menu-item"})
197
+ @queryAssignedElements({ selector: "sonic-menu-item" })
130
198
  menuChildren!: Array<HTMLElement>;
131
199
 
132
- @queryAssignedElements({slot: "more", selector: "*"})
200
+ @queryAssignedElements({ slot: "more", selector: "*" })
133
201
  moreElements!: Array<HTMLElement>;
134
202
  @state() hasMoreElements = false;
135
203
 
@@ -248,7 +316,10 @@ export class MenuItems extends LitElement {
248
316
  }
249
317
 
250
318
  if (this.align) {
251
- if (elt.getAttribute("shape") != "square" && elt.getAttribute("shape") != "circle") {
319
+ if (
320
+ elt.getAttribute("shape") != "square" &&
321
+ elt.getAttribute("shape") != "circle"
322
+ ) {
252
323
  elt.setAttribute("align", this.align);
253
324
  }
254
325
  }
@@ -279,11 +350,26 @@ export class MenuItems extends LitElement {
279
350
  marginLeft: isMenuRow ? "" : ".55em",
280
351
  };
281
352
 
282
- return html`<menu part="menu" class="shadowable" style=${styleMap(menuStyles)}>
353
+ return html`<menu
354
+ part="menu"
355
+ class="shadowable"
356
+ style=${styleMap(menuStyles)}
357
+ >
283
358
  <slot @slotchange=${this.mainSlotChange}></slot>
284
- <sonic-pop style=${styleMap(popStyles)} class=${!this.hasMoreElements ? "hidden" : ""}>
285
- <sonic-menu-item style=${styleMap(popBtnStyles)} class="more-btn" shape=${this.moreShape} align="center">
286
- <sonic-icon size="xl" name=${isMenuRow ? "more-vert" : "more-horiz"}></sonic-icon>
359
+ <sonic-pop
360
+ style=${styleMap(popStyles)}
361
+ class=${!this.hasMoreElements ? "hidden" : ""}
362
+ >
363
+ <sonic-menu-item
364
+ style=${styleMap(popBtnStyles)}
365
+ class="more-btn"
366
+ shape=${this.moreShape}
367
+ align="center"
368
+ >
369
+ <sonic-icon
370
+ size="xl"
371
+ name=${isMenuRow ? "more-vert" : "more-horiz"}
372
+ ></sonic-icon>
287
373
  </sonic-menu-item>
288
374
  <slot name="more" @slotchange=${this.checkIfMore} slot="content"></slot>
289
375
  </sonic-pop>
@@ -2,8 +2,8 @@
2
2
  /* eslint no-async-promise-executor: 0 */ // --> OFF
3
3
  import HTML from "@supersoniks/concorde/core/utils/HTML";
4
4
  import Objects from "@supersoniks/concorde/core/utils/Objects";
5
- import {CoreJSType} from "@supersoniks/concorde/core/_types/types";
6
- import {PublisherManager} from "./PublisherProxy";
5
+ import { CoreJSType } from "@supersoniks/concorde/core/_types/types";
6
+ import { PublisherManager } from "./PublisherProxy";
7
7
 
8
8
  export type APIConfiguration = {
9
9
  serviceURL: string | null;
@@ -19,7 +19,10 @@ export type APIConfiguration = {
19
19
  cache?: RequestCache;
20
20
  };
21
21
  export type CallState = "loading" | "done" | "error" | undefined;
22
- export type ResultTypeInterface = CoreJSType & {_sonic_http_response_?: Response; text?: string};
22
+ export type ResultTypeInterface = CoreJSType & {
23
+ _sonic_http_response_?: Response;
24
+ text?: string;
25
+ };
23
26
  export type APICall = {
24
27
  apiMethod: "get" | "send" | "submitFormData";
25
28
  path: string;
@@ -66,7 +69,9 @@ class API {
66
69
  }
67
70
  get token() {
68
71
  // si le token est marqué invalide, on utilise utilise la dernière version valide connue du token pour ce serviceURL
69
- return API.invalidTokens.includes(this._token) ? API.tokens.get(this.serviceURL) : this._token;
72
+ return API.invalidTokens.includes(this._token)
73
+ ? API.tokens.get(this.serviceURL)
74
+ : this._token;
70
75
  }
71
76
  /**
72
77
  * Le endPoint pour obtenir le bearer token qui sera concaténé à l'url du service
@@ -135,7 +140,10 @@ class API {
135
140
  this.credentials = config.credentials;
136
141
  this.cache = config.cache || "default";
137
142
  }
138
- async handleResult(fetchResult: Response, lastCall: APICall): Promise<ResultTypeInterface> {
143
+ async handleResult(
144
+ fetchResult: Response,
145
+ lastCall: APICall
146
+ ): Promise<ResultTypeInterface> {
139
147
  API.firstCallDoneFlags.set(this.serviceURL, "done");
140
148
  this.lastResult = fetchResult;
141
149
  const contentType = fetchResult.headers.get("content-type")?.toLowerCase();
@@ -144,7 +152,7 @@ class API {
144
152
  let result: ResultTypeInterface = {};
145
153
  if (!contentType || contentType.indexOf("text/") == 0) {
146
154
  const str = await fetchResult.text();
147
- result = {text: str} as typeof result;
155
+ result = { text: str } as typeof result;
148
156
  } else {
149
157
  try {
150
158
  result = await fetchResult.json();
@@ -159,9 +167,17 @@ class API {
159
167
  if (httpCode === 498 && !API.failledTokenUpdates.has(this.serviceURL)) {
160
168
  this.handleInvalidToken(this.token);
161
169
  if (lastCall.apiMethod === "get") {
162
- result = await this[lastCall.apiMethod](lastCall.path, lastCall.additionalHeaders);
170
+ result = await this[lastCall.apiMethod](
171
+ lastCall.path,
172
+ lastCall.additionalHeaders
173
+ );
163
174
  } else {
164
- result = await this[lastCall.apiMethod](lastCall.path, lastCall.data, lastCall.method, lastCall.additionalHeaders);
175
+ result = await this[lastCall.apiMethod](
176
+ lastCall.path,
177
+ lastCall.data,
178
+ lastCall.method,
179
+ lastCall.additionalHeaders
180
+ );
165
181
  }
166
182
  }
167
183
 
@@ -182,7 +198,11 @@ class API {
182
198
  let headers = {};
183
199
  if (this.userName && this.password) {
184
200
  headers = {
185
- Authorization: "Basic " + window.btoa(unescape(encodeURIComponent(this.userName + ":" + this.password))),
201
+ Authorization:
202
+ "Basic " +
203
+ window.btoa(
204
+ unescape(encodeURIComponent(this.userName + ":" + this.password))
205
+ ),
186
206
  };
187
207
  } else if (this.authToken) {
188
208
  headers = {
@@ -192,10 +212,15 @@ class API {
192
212
 
193
213
  const serviceURL = new URL(this.serviceURL as string);
194
214
  const serviceHost = serviceURL.protocol + "//" + serviceURL.host;
195
- const result = await fetch(this.computeURL(this.tokenProvider as string, {serviceHost: serviceHost}), {
196
- headers: headers,
197
- credentials: this.credentials,
198
- });
215
+ const result = await fetch(
216
+ this.computeURL(this.tokenProvider as string, {
217
+ serviceHost: serviceHost,
218
+ }),
219
+ {
220
+ headers: headers,
221
+ credentials: this.credentials,
222
+ }
223
+ );
199
224
 
200
225
  try {
201
226
  const json = await result.json();
@@ -221,7 +246,6 @@ class API {
221
246
  async localGet<T>(dataProvider: string, searchString: string) {
222
247
  const publisher = PublisherManager.get(dataProvider);
223
248
 
224
- console.log(publisher);
225
249
  const searchParams = new URLSearchParams(searchString.split("?")[1] || "");
226
250
  const dataObject = publisher.get();
227
251
  let data = [];
@@ -248,18 +272,21 @@ class API {
248
272
  searchParams.delete("limit");
249
273
  searchParams.delete("offset");
250
274
  }
251
- if (searchParams.size === 0) return data.slice(offset, offset + limit) as T & ResultTypeInterface;
275
+ if (searchParams.size === 0)
276
+ return data.slice(offset, offset + limit) as T & ResultTypeInterface;
252
277
  for (const [key, value] of searchParams.entries()) {
253
278
  const values = value.split(",").map((s) => s.trim());
254
279
  for (const v of values) {
255
280
  for (const item of data) {
256
281
  //si l'item est une valeur primitive on regarde si vaue correspond à item simplement
257
282
  if (typeof item !== "object") {
258
- if (!isNaN(+value)) {
259
- if (item == value) {
283
+ if (!isNaN(+item)) {
284
+ if (item === value) {
260
285
  result.push(item);
261
286
  }
262
- } else if (item.toString().includes(value)) {
287
+ } else if (
288
+ item.toString().toLowerCase().includes(value.toLowerCase())
289
+ ) {
263
290
  result.push(item);
264
291
  }
265
292
  } else {
@@ -269,12 +296,14 @@ class API {
269
296
  if (!record[key]) continue;
270
297
 
271
298
  //si la valeur est un nombre, on compare les valeurs directement
272
- if (!isNaN(+v)) {
273
- if (record[key] == v) {
299
+ if (!isNaN(+(record[key] as string))) {
300
+ if (record[key] === v) {
274
301
  result.push(item);
275
302
  }
276
303
  } else {
277
- if (record[key]?.toString().toLowerCase().includes(v.toLowerCase())) {
304
+ if (
305
+ record[key]?.toString().toLowerCase().includes(v.toLowerCase())
306
+ ) {
278
307
  result.push(item);
279
308
  }
280
309
  }
@@ -295,7 +324,11 @@ class API {
295
324
  resolve(true);
296
325
  } else {
297
326
  const loop = () => {
298
- if (![undefined, "loading"].includes(API.firstCallDoneFlags.get(this.serviceURL))) {
327
+ if (
328
+ ![undefined, "loading"].includes(
329
+ API.firstCallDoneFlags.get(this.serviceURL)
330
+ )
331
+ ) {
299
332
  resolve(true);
300
333
  } else {
301
334
  window.requestAnimationFrame(loop);
@@ -331,7 +364,11 @@ class API {
331
364
  if (!API.loadingGetPromises.has(mapKey)) {
332
365
  const promise = new Promise(async (resolve) => {
333
366
  try {
334
- const result = await fetch(url, {headers: headers, credentials: this.credentials, cache: this.cache});
367
+ const result = await fetch(url, {
368
+ headers: headers,
369
+ credentials: this.credentials,
370
+ cache: this.cache,
371
+ });
335
372
  const handledResult = await this.handleResult(result, lastCall);
336
373
  resolve(handledResult);
337
374
  } catch (e) {
@@ -380,7 +417,12 @@ class API {
380
417
  /*
381
418
  * Envoie des données au endPoint passé en paramètre. par défaut en POST
382
419
  */
383
- async send<T, SendType = CoreJSType>(path: string, data: SendType, method = "POST", additionalHeaders?: HeadersInit) {
420
+ async send<T, SendType = CoreJSType>(
421
+ path: string,
422
+ data: SendType,
423
+ method = "POST",
424
+ additionalHeaders?: HeadersInit
425
+ ) {
384
426
  const lastCall: APICall = {
385
427
  apiMethod: "send",
386
428
  path: path,
@@ -398,13 +440,19 @@ class API {
398
440
  method: method,
399
441
  body: JSON.stringify(data),
400
442
  });
401
- return (await this.handleResult(result, lastCall)) as T & ResultTypeInterface;
443
+ return (await this.handleResult(result, lastCall)) as T &
444
+ ResultTypeInterface;
402
445
  }
403
446
 
404
447
  /**
405
448
  * Agit comme une soumission de formulaire, mais attends un json en réponse
406
449
  */
407
- async submitFormData<T, SendType = CoreJSType>(path: string, data: SendType, method = "POST", additionalHeaders?: HeadersInit) {
450
+ async submitFormData<T, SendType = CoreJSType>(
451
+ path: string,
452
+ data: SendType,
453
+ method = "POST",
454
+ additionalHeaders?: HeadersInit
455
+ ) {
408
456
  const lastCall: APICall = {
409
457
  apiMethod: "submitFormData",
410
458
  path: path,
@@ -415,7 +463,7 @@ class API {
415
463
  const headers = await this.createHeaders(additionalHeaders);
416
464
  headers["Accept"] = "application/json";
417
465
  const formData = new FormData();
418
- const dynamicData = data as unknown as {[property: string]: string};
466
+ const dynamicData = data as unknown as { [property: string]: string };
419
467
  for (const z in dynamicData) formData.set(z, dynamicData[z]);
420
468
  const result = await fetch(this.computeURL(path), {
421
469
  headers: headers,
@@ -423,33 +471,50 @@ class API {
423
471
  method: method,
424
472
  body: formData,
425
473
  });
426
- return (await this.handleResult(result, lastCall)) as T & ResultTypeInterface;
474
+ return (await this.handleResult(result, lastCall)) as T &
475
+ ResultTypeInterface;
427
476
  }
428
477
 
429
478
  /**
430
479
  * Appel send en utilisant le méthode PUT
431
480
  */
432
- async put<T, SendType = CoreJSType>(path: string, data: SendType, additionalHeaders?: HeadersInit) {
481
+ async put<T, SendType = CoreJSType>(
482
+ path: string,
483
+ data: SendType,
484
+ additionalHeaders?: HeadersInit
485
+ ) {
433
486
  return this.send<T, SendType>(path, data, "PUT", additionalHeaders);
434
487
  }
435
488
 
436
489
  /**
437
490
  * Appel send en utilisant le méthode POST
438
491
  */
439
- async post<T, SendType = CoreJSType>(path: string, data: SendType, additionalHeaders?: HeadersInit) {
492
+ async post<T, SendType = CoreJSType>(
493
+ path: string,
494
+ data: SendType,
495
+ additionalHeaders?: HeadersInit
496
+ ) {
440
497
  return this.send<T, SendType>(path, data, "POST", additionalHeaders);
441
498
  }
442
499
  /**
443
500
  * Appel send en utilisant le méthode PATCH
444
501
  */
445
- async patch<T, SendType = CoreJSType>(path: string, data: SendType, additionalHeaders?: HeadersInit) {
502
+ async patch<T, SendType = CoreJSType>(
503
+ path: string,
504
+ data: SendType,
505
+ additionalHeaders?: HeadersInit
506
+ ) {
446
507
  return this.send<T, SendType>(path, data, "PATCH", additionalHeaders);
447
508
  }
448
509
 
449
510
  /**
450
511
  * Appel send en utilisant le méthode delete
451
512
  */
452
- async delete<T, SendType = CoreJSType>(path: string, data: SendType, additionalHeaders?: HeadersInit) {
513
+ async delete<T, SendType = CoreJSType>(
514
+ path: string,
515
+ data: SendType,
516
+ additionalHeaders?: HeadersInit
517
+ ) {
453
518
  return this.send<T, SendType>(path, data, "delete", additionalHeaders);
454
519
  }
455
520
  }