@supersoniks/concorde 1.1.42 → 1.1.43

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 (182) hide show
  1. package/components.js +2 -3
  2. package/concorde-core.bundle.js +37 -35
  3. package/concorde-core.es.js +5081 -4317
  4. package/core/_types/types.d.ts +26 -0
  5. package/core/_types/types.js +1 -0
  6. package/core/components/functional/date/date.d.ts +13 -5
  7. package/core/components/functional/date/date.js +48 -29
  8. package/core/components/functional/example/example.d.ts +1 -1
  9. package/core/components/functional/example/example.js +1 -1
  10. package/core/components/functional/fetch/fetch.d.ts +40 -3
  11. package/core/components/functional/fetch/fetch.js +2 -6
  12. package/core/components/functional/functional.d.ts +2 -0
  13. package/core/components/functional/functional.js +2 -0
  14. package/core/components/functional/if/if.d.ts +3 -0
  15. package/core/components/functional/if/if.js +6 -12
  16. package/core/components/functional/if/if.test.d.ts +1 -0
  17. package/core/components/functional/if/if.test.js +44 -0
  18. package/core/components/functional/list/list.d.ts +32 -8
  19. package/core/components/functional/list/list.js +33 -40
  20. package/core/components/functional/mix/mix.d.ts +22 -0
  21. package/core/components/functional/mix/mix.js +99 -0
  22. package/core/components/functional/queue/queue.d.ts +16 -3
  23. package/core/components/functional/queue/queue.js +71 -15
  24. package/core/components/functional/router/redirect.d.ts +10 -1
  25. package/core/components/functional/router/redirect.js +5 -6
  26. package/core/components/functional/router/router.d.ts +15 -1
  27. package/core/components/functional/router/router.js +1 -6
  28. package/core/components/functional/sdui/SDUIDescriptorTransformer.d.ts +1 -1
  29. package/core/components/functional/sdui/SDUIDescriptorTransformer.js +24 -12
  30. package/core/components/functional/sdui/default-library.json +108 -0
  31. package/core/components/functional/sdui/sdui-utils.d.ts +5 -0
  32. package/core/components/functional/sdui/sdui-utils.js +63 -0
  33. package/core/components/functional/sdui/sdui.d.ts +16 -9
  34. package/core/components/functional/sdui/sdui.js +52 -25
  35. package/core/components/functional/sdui/types.d.ts +4 -2
  36. package/core/components/functional/states/states.d.ts +19 -3
  37. package/core/components/functional/states/states.js +7 -12
  38. package/core/components/functional/submit/submit.d.ts +16 -1
  39. package/core/components/functional/submit/submit.js +87 -17
  40. package/core/components/functional/subscriber/subscriber.d.ts +4 -1
  41. package/core/components/functional/subscriber/subscriber.js +1 -6
  42. package/core/components/functional/value/value.d.ts +7 -0
  43. package/core/components/functional/value/value.js +26 -0
  44. package/core/components/ui/_css/scroll.js +6 -7
  45. package/core/components/ui/_css/size.d.ts +1 -0
  46. package/core/components/ui/_css/size.js +3 -1
  47. package/core/components/ui/alert/alert.d.ts +2 -2
  48. package/core/components/ui/alert/alert.js +11 -16
  49. package/core/components/ui/badge/badge.d.ts +3 -1
  50. package/core/components/ui/badge/badge.js +36 -22
  51. package/core/components/ui/button/button.d.ts +23 -20
  52. package/core/components/ui/button/button.js +59 -42
  53. package/core/components/ui/captcha/captcha.d.ts +14 -2
  54. package/core/components/ui/captcha/captcha.js +17 -12
  55. package/core/components/ui/card/card-footer.js +1 -8
  56. package/core/components/ui/card/card-header-descripton.js +3 -9
  57. package/core/components/ui/card/card-header.js +1 -6
  58. package/core/components/ui/card/card-main.js +0 -5
  59. package/core/components/ui/card/card.d.ts +1 -1
  60. package/core/components/ui/card/card.js +28 -12
  61. package/core/components/ui/divider/divider.d.ts +2 -0
  62. package/core/components/ui/divider/divider.js +43 -16
  63. package/core/components/ui/form/checkbox/checkbox.d.ts +53 -16
  64. package/core/components/ui/form/checkbox/checkbox.js +53 -28
  65. package/core/components/ui/form/css/form-control.d.ts +2 -0
  66. package/core/components/ui/form/css/form-control.js +145 -67
  67. package/core/components/ui/form/fieldset/fieldset.d.ts +8 -1
  68. package/core/components/ui/form/fieldset/fieldset.js +45 -8
  69. package/core/components/ui/form/fieldset/legend-description.js +0 -5
  70. package/core/components/ui/form/fieldset/legend.js +3 -6
  71. package/core/components/ui/form/form-actions/form-actions.d.ts +2 -0
  72. package/core/components/ui/form/form-actions/form-actions.js +26 -11
  73. package/core/components/ui/form/form-layout/form-layout.d.ts +5 -2
  74. package/core/components/ui/form/form-layout/form-layout.js +31 -9
  75. package/core/components/ui/form/input/input.d.ts +15 -18
  76. package/core/components/ui/form/input/input.js +87 -52
  77. package/core/components/ui/form/input/password-helper.d.ts +1 -1
  78. package/core/components/ui/form/input/password-helper.js +3 -2
  79. package/core/components/ui/form/input/same-value-helper.d.ts +1 -1
  80. package/core/components/ui/form/input/same-value-helper.js +1 -0
  81. package/core/components/ui/form/input-autocomplete/input-autocomplete.d.ts +2 -3
  82. package/core/components/ui/form/input-autocomplete/input-autocomplete.js +2 -6
  83. package/core/components/ui/form/radio/radio.d.ts +6 -0
  84. package/core/components/ui/form/radio/radio.js +7 -12
  85. package/core/components/ui/form/select/select.d.ts +23 -7
  86. package/core/components/ui/form/select/select.js +69 -38
  87. package/core/components/ui/form/textarea/textarea.d.ts +13 -13
  88. package/core/components/ui/form/textarea/textarea.js +29 -36
  89. package/core/components/ui/group/group.d.ts +11 -1
  90. package/core/components/ui/group/group.js +79 -17
  91. package/core/components/ui/icon/icon.d.ts +10 -3
  92. package/core/components/ui/icon/icon.js +16 -15
  93. package/core/components/ui/icon/icons.js +11 -8
  94. package/core/components/ui/icon/icons.json +1 -1
  95. package/core/components/ui/image/image.js +0 -5
  96. package/core/components/ui/link/link.d.ts +1 -1
  97. package/core/components/ui/link/link.js +2 -6
  98. package/core/components/ui/loader/loader.js +2 -8
  99. package/core/components/ui/menu/menu-item.js +4 -9
  100. package/core/components/ui/menu/menu.d.ts +9 -1
  101. package/core/components/ui/menu/menu.js +183 -27
  102. package/core/components/ui/modal/modal-actions.js +1 -6
  103. package/core/components/ui/modal/modal-close.d.ts +1 -0
  104. package/core/components/ui/modal/modal-close.js +14 -10
  105. package/core/components/ui/modal/modal-content.js +0 -5
  106. package/core/components/ui/modal/modal-subtitle.js +2 -6
  107. package/core/components/ui/modal/modal-title.js +0 -5
  108. package/core/components/ui/modal/modal.d.ts +7 -7
  109. package/core/components/ui/modal/modal.js +36 -36
  110. package/core/components/ui/pop/pop.d.ts +6 -5
  111. package/core/components/ui/pop/pop.js +44 -44
  112. package/core/components/ui/progress/progress.js +34 -32
  113. package/core/components/ui/table/table-caption.js +5 -10
  114. package/core/components/ui/table/table-tbody.js +10 -14
  115. package/core/components/ui/table/table-td.d.ts +2 -0
  116. package/core/components/ui/table/table-td.js +8 -5
  117. package/core/components/ui/table/table-tfoot.js +5 -7
  118. package/core/components/ui/table/table-th.d.ts +2 -0
  119. package/core/components/ui/table/table-th.js +12 -9
  120. package/core/components/ui/table/table-thead.js +1 -6
  121. package/core/components/ui/table/table-tr.js +4 -6
  122. package/core/components/ui/table/table.d.ts +0 -3
  123. package/core/components/ui/table/table.js +14 -31
  124. package/core/components/ui/taxonomy/taxonomy.d.ts +6 -3
  125. package/core/components/ui/taxonomy/taxonomy.js +9 -9
  126. package/core/components/ui/theme/theme-collection/core-variables.js +13 -11
  127. package/core/components/ui/theme/theme-collection/dark.js +1 -1
  128. package/core/components/ui/theme/theme.d.ts +1 -6
  129. package/core/components/ui/theme/theme.js +7 -36
  130. package/core/components/ui/toast/message-subscriber.d.ts +13 -7
  131. package/core/components/ui/toast/toast-item.js +1 -1
  132. package/core/components/ui/toast/toast.d.ts +2 -1
  133. package/core/components/ui/toast/toast.js +29 -14
  134. package/core/components/ui/tooltip/tooltip.d.ts +1 -0
  135. package/core/components/ui/tooltip/tooltip.js +35 -14
  136. package/core/components/ui/ui.js +0 -3
  137. package/core/core.js +5 -6
  138. package/core/mixins/Fetcher.d.ts +19 -10
  139. package/core/mixins/Fetcher.js +26 -10
  140. package/core/mixins/FormCheckable.d.ts +17 -8
  141. package/core/mixins/FormCheckable.js +177 -22
  142. package/core/mixins/FormElement.d.ts +12 -7
  143. package/core/mixins/FormElement.js +42 -26
  144. package/core/mixins/FormInput.d.ts +8 -4
  145. package/core/mixins/FormInput.js +4 -3
  146. package/core/mixins/Subscriber.d.ts +7 -5
  147. package/core/mixins/Subscriber.js +34 -32
  148. package/core/utils/Arrays.d.ts +15 -15
  149. package/core/utils/DataBindObserver.d.ts +16 -9
  150. package/core/utils/DataBindObserver.js +23 -28
  151. package/core/utils/Electron.d.ts +5 -1
  152. package/core/utils/Electron.js +4 -2
  153. package/core/utils/HTML.d.ts +9 -2
  154. package/core/utils/HTML.js +22 -3
  155. package/core/utils/LocationHandler.d.ts +6 -5
  156. package/core/utils/LocationHandler.js +19 -8
  157. package/core/utils/Objects.d.ts +7 -4
  158. package/core/utils/Objects.js +28 -6
  159. package/core/utils/{PublisherProxy.d.mts → PublisherProxy.d.ts} +40 -31
  160. package/core/utils/{PublisherProxy.mjs → PublisherProxy.js} +54 -28
  161. package/core/utils/Utils.d.ts +3 -0
  162. package/core/utils/Utils.js +18 -0
  163. package/core/utils/api.d.ts +39 -7
  164. package/core/utils/api.js +45 -32
  165. package/img/concorde-logo.svg +1 -0
  166. package/img/concorde.png +0 -0
  167. package/img/concorde_def.png +0 -0
  168. package/mixins.d.ts +36 -18
  169. package/mixins.js +3 -4
  170. package/package.json +45 -10
  171. package/svg/regular/plane.svg +1 -0
  172. package/svg/solid/plane.svg +1 -0
  173. package/test-utils/TestUtils.d.ts +4 -0
  174. package/test-utils/TestUtils.js +12 -0
  175. package/utils.d.ts +3 -1
  176. package/utils.js +7 -5
  177. package/core/components/functional/configuration/configuration.d.ts +0 -5
  178. package/core/components/functional/configuration/configuration.js +0 -22
  179. package/core/components/ui/tabs/tab.d.ts +0 -6
  180. package/core/components/ui/tabs/tab.js +0 -46
  181. package/core/components/ui/tabs/tabs.d.ts +0 -15
  182. package/core/components/ui/tabs/tabs.js +0 -129
@@ -1,8 +1,9 @@
1
- import API from "@supersoniks/concorde/core/utils/api";
1
+ /// <reference types="node" />
2
2
  import "@supersoniks/concorde/core/components/ui/button/button";
3
3
  import { SubscriberInterface } from "@supersoniks/concorde/core/mixins/Subscriber";
4
+ import API from "@supersoniks/concorde/core/utils/api";
4
5
  declare type Constructor<T> = new (...args: any[]) => T;
5
- declare const Fetcher: <T extends Constructor<SubscriberInterface>>(superClass: T) => {
6
+ declare const Fetcher: <PropsType = any, T extends Constructor<SubscriberInterface<PropsType>> = any>(superClass: T, propsType?: PropsType | undefined) => {
6
7
  new (...args: any[]): {
7
8
  api: API | null;
8
9
  /**
@@ -33,6 +34,9 @@ declare const Fetcher: <T extends Constructor<SubscriberInterface>>(superClass:
33
34
  isFetchEnabled: boolean;
34
35
  _endPoint: string;
35
36
  endPoint: string;
37
+ requestId: number;
38
+ refetchEveryMs: number;
39
+ refetchTimeOutId?: NodeJS.Timeout | undefined;
36
40
  /**
37
41
  *
38
42
  * C'est ici que les données sont chargées via l'utilitaire API
@@ -40,7 +44,7 @@ declare const Fetcher: <T extends Constructor<SubscriberInterface>>(superClass:
40
44
  * Un Toast est affiché si le chargement échoue
41
45
  */
42
46
  _fetchData(): Promise<void>;
43
- onInvalidate: any;
47
+ onInvalidate?: (() => void) | undefined;
44
48
  disconnectedCallback(): void;
45
49
  connectedCallback(): void;
46
50
  /**
@@ -48,27 +52,32 @@ declare const Fetcher: <T extends Constructor<SubscriberInterface>>(superClass:
48
52
  */
49
53
  firstUpdated(): void;
50
54
  onIntersection(entries: IntersectionObserverEntry[]): void;
51
- props: any;
55
+ props: PropsType | null;
52
56
  propertyMap: Object;
53
57
  isConnected: boolean;
54
- getAncestorAttributeValue(attributeName: string): string; /**
55
- * Après le chargement des données on traverse l'objet reçu en fonctione de la cible exprimées dans cette propriété avec la dot syntaxe.
56
- * C'est cette donnée cible qui est injectée dans les pros et donc disponible via le publisher disponible globalement via PublisherManager.get(dataProvider)
57
- */
58
+ getAncestorAttributeValue(attributeName: string): string;
58
59
  hasAncestorAttribute(attributeName: string): boolean;
59
60
  querySelectorAll(selector: string): NodeListOf<Element>;
60
61
  publisher: any;
61
62
  dataProvider: string | null;
62
- noShadowDom: string | null;
63
+ noShadowDom: string | null; /**
64
+ * isFirstLoad vaut true jusqu'au premier chargement de données
65
+ */
63
66
  debug: HTMLElement | null;
64
67
  defferedDebug: boolean | null;
65
68
  displayContents: boolean;
69
+ shadowRoot?: ShadowRoot | undefined; /**
70
+ * isLoading vaut true pendant le chargement des données
71
+ */
66
72
  dispatchEvent(event: Event): void;
67
73
  setAttribute(name: string, value: string): void;
68
74
  addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions | undefined): void;
69
75
  removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions | undefined): void;
70
76
  removeAttribute(name: string): void;
71
- initPublisher(): void;
77
+ initPublisher(): void; /**
78
+ * On peut désactiver le fetch programmatiquement via cette propriété.
79
+ * Cela est le cas pour le composant sonic-list qui ne fetch que si l'attribut fetch est renseigné
80
+ */
72
81
  getApiConfiguration(): import("@supersoniks/concorde/core/utils/api").APIConfiguration;
73
82
  requestUpdate(): void;
74
83
  getAttribute(name: string): string;
@@ -13,14 +13,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
13
13
  step((generator = generator.apply(thisArg, _arguments || [])).next());
14
14
  });
15
15
  };
16
+ import "@supersoniks/concorde/core/components/ui/button/button";
16
17
  import { Loader } from "@supersoniks/concorde/core/components/ui/loader/loader";
17
18
  import { SonicToast } from "@supersoniks/concorde/core/components/ui/toast/toast";
18
19
  import API from "@supersoniks/concorde/core/utils/api";
19
- import "@supersoniks/concorde/core/components/ui/button/button";
20
- import { PublisherManager } from "@supersoniks/concorde/utils";
21
20
  import Objects from "@supersoniks/concorde/core/utils/Objects";
21
+ import { PublisherManager } from "@supersoniks/concorde/utils";
22
22
  import { property } from "lit/decorators.js";
23
- const Fetcher = (superClass) => {
23
+ const Fetcher = (superClass, propsType) => {
24
+ propsType;
24
25
  class FetcherElement extends superClass {
25
26
  constructor(...args) {
26
27
  super();
@@ -52,6 +53,8 @@ const Fetcher = (superClass) => {
52
53
  */
53
54
  this.isFetchEnabled = true;
54
55
  this._endPoint = "";
56
+ this.requestId = 0;
57
+ this.refetchEveryMs = 0;
55
58
  args;
56
59
  this.dataProvider = "";
57
60
  }
@@ -102,37 +105,44 @@ const Fetcher = (superClass) => {
102
105
  Loader.hide();
103
106
  if (this.key) {
104
107
  let response = data._sonic_http_response_;
105
- data = Objects.traverse(data, this.key.split("."), false);
106
- if (data && Objects.isObject(data))
108
+ /* preserveOtherKeys s'exprime lorsque le paramètre "key" est défini
109
+ * Conserve les autres propriétés de l'objet reçu, en plus des propriétés définies sous "key"
110
+ */
111
+ data = Objects.traverse(data, this.key.split("."), this.hasAttribute("preserveOtherKeys"));
112
+ if (data && Objects.isObject(data) && response)
107
113
  data._sonic_http_response_ = response;
108
114
  }
109
115
  this.props = data;
110
116
  this.dispatchEvent(new CustomEvent("load", { detail: this }));
111
117
  this.isFirstLoad = false;
112
118
  this.isLoading = false;
119
+ if (this.refetchEveryMs && this.isConnected) {
120
+ this.refetchTimeOutId = setTimeout(() => this._fetchData(), this.refetchEveryMs);
121
+ }
113
122
  });
114
123
  }
115
124
  disconnectedCallback() {
116
125
  var _a;
117
126
  super.disconnectedCallback();
118
127
  (_a = this.publisher) === null || _a === void 0 ? void 0 : _a.offInvalidate(this.onInvalidate);
128
+ clearTimeout(this.refetchTimeOutId);
119
129
  this.isFirstLoad = false;
120
130
  }
121
131
  connectedCallback() {
122
132
  var _a;
123
- this.noShadowDom = "";
133
+ // this.noShadowDom = "";
124
134
  if (!this.isFetchEnabled) {
125
135
  super.connectedCallback();
126
136
  return;
127
137
  }
128
138
  super.connectedCallback();
129
- this.key = this.getAncestorAttributeValue("key");
139
+ this.key = this.getAttribute("key");
130
140
  if (this.props) {
131
141
  this.publisher.set(this.props);
132
142
  }
133
143
  this.onInvalidate = () => this._fetchData();
134
144
  (_a = this.publisher) === null || _a === void 0 ? void 0 : _a.onInvalidate(this.onInvalidate);
135
- const lazyLoad = this.getAncestorAttributeValue("lazyload");
145
+ const lazyLoad = this.getAttribute("lazyload");
136
146
  if (lazyLoad === null) {
137
147
  this._fetchData();
138
148
  }
@@ -141,7 +151,7 @@ const Fetcher = (superClass) => {
141
151
  * Première update, le comportement de lazyload est géré ici a l'aide d'un intersection observer.
142
152
  */
143
153
  firstUpdated() {
144
- const lazyLoad = this.getAncestorAttributeValue("lazyload");
154
+ const lazyLoad = this.getAttribute("lazyload");
145
155
  if (lazyLoad === null) {
146
156
  return;
147
157
  }
@@ -151,7 +161,7 @@ const Fetcher = (superClass) => {
151
161
  };
152
162
  this.iObserver = new IntersectionObserver((entries) => this.onIntersection(entries), options);
153
163
  let that = this;
154
- let elt = that.shadowRoot ? that.shadowRoot.children[0] : that.children[0];
164
+ let elt = this.shadowRoot ? this.shadowRoot.children[0] : that.children[0];
155
165
  if (elt && elt.nodeName.toLocaleLowerCase() == "slot")
156
166
  elt = elt.children[0];
157
167
  if (!elt || elt.nodeName.toLocaleLowerCase() == "template") {
@@ -176,6 +186,12 @@ const Fetcher = (superClass) => {
176
186
  __decorate([
177
187
  property({ type: String })
178
188
  ], FetcherElement.prototype, "endPoint", null);
189
+ __decorate([
190
+ property()
191
+ ], FetcherElement.prototype, "requestId", void 0);
192
+ __decorate([
193
+ property({ type: Number })
194
+ ], FetcherElement.prototype, "refetchEveryMs", void 0);
179
195
  return FetcherElement; // as Constructor<SubscriberInterface> & T;
180
196
  };
181
197
  export default Fetcher;
@@ -16,13 +16,15 @@ declare const Form: <T extends Constructor<FormElementInterface>>(superClass: T)
16
16
  Active le mode radio
17
17
  */
18
18
  radio: true | null;
19
+ unCheckOnDisconnect: boolean;
19
20
  /**
20
21
  * propriété checked avec des caractéristiques similaire à un input html classique.
21
22
  */
22
- _checked: true | null;
23
- checked: true | null;
23
+ _checked: true | null | "indeterminate";
24
+ checked: true | "indeterminate" | null;
24
25
  validateFormElement(): void;
25
- setCheckedValue(checked: true | null): void;
26
+ checksAll(): boolean;
27
+ setCheckedValue(checked: true | null | "indeterminate"): void;
26
28
  handleChange(): void;
27
29
  /**
28
30
  * Voir la mixin FormElement
@@ -34,16 +36,24 @@ declare const Form: <T extends Constructor<FormElementInterface>>(superClass: T)
34
36
  * Le comportement est modifié de la manière suivante :
35
37
  * 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)
36
38
  */
37
- setFormValueFromPublisher(value: any): void;
38
- initPublisher(): void;
39
+ setFormValueFromPublisher(value: string | Array<string | null> | null): void;
40
+ getCheckAllPublisher(): any;
41
+ updateAllChecked: () => void;
42
+ onChecksAllRequest: (value: string) => void;
43
+ disconnectedCallback(): void;
44
+ connectedCallback(): void;
39
45
  getFormPublisher(): any;
40
46
  updateDataValue(): void;
41
- handleBlur(e?: any): void;
47
+ handleBlur(e?: Event | undefined): void;
48
+ focus?: (() => void) | undefined;
49
+ shadowRoot?: ShadowRoot | undefined;
42
50
  error: boolean;
43
51
  autofocus: boolean;
44
52
  required: boolean;
45
53
  disabled: true | null;
46
54
  formDataProvider: string;
55
+ ariaLabelledby?: string | undefined;
56
+ ariaLabel?: string | undefined;
47
57
  _name: string;
48
58
  name: string;
49
59
  props: any;
@@ -63,12 +73,11 @@ declare const Form: <T extends Constructor<FormElementInterface>>(superClass: T)
63
73
  addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions | undefined): void;
64
74
  removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions | undefined): void;
65
75
  removeAttribute(name: string): void;
76
+ initPublisher(): void;
66
77
  getApiConfiguration(): import("../utils/api").APIConfiguration;
67
- connectedCallback(): void;
68
78
  requestUpdate(): void;
69
79
  getAttribute(name: string): string;
70
80
  hasAttribute(attributeName: String): boolean;
71
- disconnectedCallback(): void;
72
81
  };
73
82
  } & T;
74
83
  export default Form;
@@ -5,6 +5,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
7
  import { property } from "lit/decorators.js";
8
+ import { PublisherManager } from "@supersoniks/concorde/utils";
8
9
  const Form = (superClass) => {
9
10
  /**
10
11
  * FormCheckable ajoute un comportement de sélection (checked) a tout FormElement qui utilise cette mixin.
@@ -30,21 +31,98 @@ const Form = (superClass) => {
30
31
  Active le mode radio
31
32
  */
32
33
  this.radio = null;
34
+ this.unCheckOnDisconnect = false;
33
35
  /**
34
36
  * propriété checked avec des caractéristiques similaire à un input html classique.
35
37
  */
36
38
  this._checked = null;
39
+ this.updateAllChecked = () => {
40
+ let name = this.getAttribute("name");
41
+ let checkAllPublisher = this.getCheckAllPublisher();
42
+ let formPublisher = this.getFormPublisher();
43
+ if (!(checkAllPublisher === null || checkAllPublisher === void 0 ? void 0 : checkAllPublisher.hasCheckAll.get())) {
44
+ return;
45
+ }
46
+ if (!this.checksAll() && checkAllPublisher && formPublisher && name) {
47
+ if (!formPublisher[this.name].get().length) {
48
+ checkAllPublisher.checkMode = "noneChecked";
49
+ return;
50
+ }
51
+ else if (this.checked === null) {
52
+ checkAllPublisher.checkMode = "someUnchecked";
53
+ }
54
+ else if (checkAllPublisher.checkMode.get() == "noneChecked" || checkAllPublisher.checkMode.get() == null) {
55
+ checkAllPublisher.checkMode = "someUnchecked";
56
+ }
57
+ let currentValues = formPublisher[name].get();
58
+ let allValues = checkAllPublisher.values.get();
59
+ if (allValues && allValues.length) {
60
+ let checkedCount = allValues.length;
61
+ for (let p of allValues) {
62
+ if (currentValues.indexOf(p) == -1) {
63
+ checkedCount -= 1;
64
+ }
65
+ }
66
+ if (checkedCount == allValues.length) {
67
+ checkAllPublisher.checkMode = "allChecked";
68
+ }
69
+ if (checkedCount == 0) {
70
+ checkAllPublisher.checkMode = "noneChecked";
71
+ }
72
+ }
73
+ if (allValues.indexOf(this.value) == -1) {
74
+ this.checked = null;
75
+ }
76
+ }
77
+ };
78
+ this.onChecksAllRequest = (value) => {
79
+ this.removeAttribute("allChecked");
80
+ this.removeAttribute("indeterminate");
81
+ if (value == "allChecked") {
82
+ this.checked = true;
83
+ this.setAttribute("allChecked", "");
84
+ }
85
+ if (value == "noneChecked") {
86
+ this.checked = null;
87
+ }
88
+ if (value == "someUnchecked") {
89
+ if (this.checksAll())
90
+ this.checked = "indeterminate";
91
+ this.setAttribute("indeterminate", "");
92
+ }
93
+ };
37
94
  }
38
95
  get value() {
39
96
  return this._value;
40
97
  }
41
- set value(value) {
98
+ set value(newValue) {
99
+ if (this.value == newValue)
100
+ return;
42
101
  if (this.hasAttribute("value") && !this.forceAutoFill)
43
- value = this.getAttribute("value");
44
- if (this._value == value)
102
+ newValue = this.getAttribute("value");
103
+ if (this._value == newValue)
45
104
  return;
46
- this._value = value;
47
- this.updateDataValue();
105
+ if (newValue == null)
106
+ return;
107
+ this._value = newValue;
108
+ if (!this.value)
109
+ return;
110
+ // On check l'élément si il est cheched dans le formPublisher
111
+ let formPublisher = this.getFormPublisher();
112
+ if (formPublisher && this.name) {
113
+ let currentValue = formPublisher[this.name].get();
114
+ if (this.radio || this.unique) {
115
+ this.checked = currentValue == newValue ? true : null;
116
+ }
117
+ if (!Array.isArray(currentValue)) {
118
+ currentValue = [];
119
+ }
120
+ if (currentValue.indexOf(newValue) != -1)
121
+ this.checked = true;
122
+ }
123
+ //On mets à jour la valeur dans la donnée si l'élément est checked
124
+ if (this.checked == true)
125
+ this.updateDataValue();
48
126
  this.requestUpdate();
49
127
  }
50
128
  get checked() {
@@ -52,18 +130,38 @@ const Form = (superClass) => {
52
130
  }
53
131
  set checked(checked) {
54
132
  this.setCheckedValue(checked);
133
+ if (this.checksAll()) {
134
+ let checkAllPublisher = this.getCheckAllPublisher();
135
+ if (checkAllPublisher) {
136
+ if (this.checked === true)
137
+ checkAllPublisher.checkMode = "allChecked";
138
+ else if (this.checked === null) {
139
+ checkAllPublisher.checkMode = "noneChecked";
140
+ let formPublisher = this.getFormPublisher();
141
+ if (formPublisher) {
142
+ formPublisher[this.name] = [];
143
+ }
144
+ }
145
+ }
146
+ }
147
+ this.requestUpdate();
55
148
  }
56
149
  validateFormElement() {
57
150
  var _a;
58
- const that = this;
59
- const input = (_a = that.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector("input");
151
+ const input = (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector("input");
60
152
  if (!input || input.checkValidity())
61
153
  return;
62
- let value = this.getFormPublisher()[this.name].get();
63
- if ((this.unique || this.radio) && value !== null && value.toString().length > 0)
64
- return;
65
- this.getFormPublisher().isFormValid = false;
66
- input.reportValidity();
154
+ let formPublisher = this.getFormPublisher();
155
+ if (formPublisher) {
156
+ let value = formPublisher[this.name].get();
157
+ if ((this.unique || this.radio) && value !== null && value.toString().length > 0)
158
+ return;
159
+ formPublisher.isFormValid = false;
160
+ input.reportValidity();
161
+ }
162
+ }
163
+ checksAll() {
164
+ return this.hasAttribute("checksAll");
67
165
  }
68
166
  setCheckedValue(checked) {
69
167
  if (this._checked == checked)
@@ -71,6 +169,7 @@ const Form = (superClass) => {
71
169
  this._checked = checked;
72
170
  this.updateDataValue();
73
171
  this.requestUpdate();
172
+ setTimeout(() => this.updateAllChecked(), 1);
74
173
  // Désactivation du checked sur le publisher
75
174
  // Pas sur de l'utilité mais provoque un bug
76
175
  // if (this.publisher && !this.radio && !this.unique) {
@@ -78,7 +177,8 @@ const Form = (superClass) => {
78
177
  // }
79
178
  }
80
179
  handleChange() {
81
- this.checked = this.checked ? (!this.radio ? null : true) : true;
180
+ const newCheckedValue = this.checked === true ? (!this.radio ? null : true) : true;
181
+ this.checked = newCheckedValue;
82
182
  const event = new Event("change");
83
183
  this.dispatchEvent(event);
84
184
  }
@@ -87,23 +187,26 @@ const Form = (superClass) => {
87
187
  * Le comportement est ici modifié fonction de son mode (checkbox, radio, unique)
88
188
  */
89
189
  getValueForFormPublisher() {
90
- let publisher = this.getFormPublisher();
91
- let currentValue = publisher[this.name].get();
190
+ let formPublisher = this.getFormPublisher();
191
+ if (!formPublisher)
192
+ return null;
193
+ let currentValue = formPublisher[this.name].get();
92
194
  if (this.radio) {
93
- return this.checked && this.value != null ? this.value : currentValue;
195
+ return this.checked === true && this.value != null ? this.value : currentValue;
94
196
  }
95
197
  if (this.unique) {
96
- return this.checked && this.value != null ? this.value : null;
198
+ return this.checked === true && this.value != null ? this.value : null;
97
199
  }
98
200
  if (!Array.isArray(currentValue)) {
99
201
  currentValue = [];
100
202
  }
101
203
  currentValue = currentValue.slice(0);
102
204
  let idx = currentValue.indexOf(this.value);
103
- if (this.checked === true && idx === -1)
205
+ if (this.checked === true && idx === -1 && !this.checksAll())
104
206
  currentValue.push(this.value);
105
- if (this.checked === null && idx !== -1)
207
+ if (this.checked === null && idx !== -1) {
106
208
  currentValue.splice(idx, 1);
209
+ }
107
210
  return currentValue;
108
211
  }
109
212
  /**
@@ -118,15 +221,64 @@ const Form = (superClass) => {
118
221
  }
119
222
  if (!Array.isArray(value))
120
223
  value = [];
224
+ if (this.checksAll()) {
225
+ return;
226
+ }
121
227
  this.checked = value.indexOf(this.value) !== -1 ? true : null;
122
228
  }
123
- initPublisher() {
124
- super.initPublisher();
229
+ getCheckAllPublisher() {
230
+ if (!this.formDataProvider)
231
+ this.formDataProvider = this.getAncestorAttributeValue("formDataProvider");
232
+ const formDataProvider = this.formDataProvider;
233
+ let name = this.getAttribute("name");
234
+ if (!formDataProvider || !name) {
235
+ return null;
236
+ }
237
+ return PublisherManager.get(formDataProvider + "/" + name + "/_available_values_");
238
+ }
239
+ disconnectedCallback() {
240
+ super.disconnectedCallback();
241
+ let checkAllPublisher = this.getCheckAllPublisher();
242
+ if (checkAllPublisher) {
243
+ checkAllPublisher.checkMode.offAssign(this.onChecksAllRequest);
244
+ if (!this.checksAll()) {
245
+ let values = checkAllPublisher.values.get().slice(0);
246
+ const idx = values.indexOf(this.value);
247
+ if (idx != -1) {
248
+ values.splice(idx, 1);
249
+ checkAllPublisher.values = values;
250
+ }
251
+ }
252
+ }
253
+ setTimeout(() => this.updateAllChecked(), 1);
254
+ }
255
+ connectedCallback() {
256
+ super.connectedCallback();
257
+ const formPublisher = this.getFormPublisher();
258
+ if (formPublisher && this.name) {
259
+ let publisherValueForName = formPublisher[this.name].get();
260
+ if (publisherValueForName && publisherValueForName.indexOf(this.value) !== -1) {
261
+ this.checked = true;
262
+ }
263
+ }
264
+ let checkAllPublisher = this.getCheckAllPublisher();
265
+ if (checkAllPublisher) {
266
+ checkAllPublisher.checkMode.onAssign(this.onChecksAllRequest);
267
+ if (this.checksAll()) {
268
+ checkAllPublisher.hasCheckAll = true;
269
+ }
270
+ if (!checkAllPublisher.values.get()) {
271
+ checkAllPublisher.values = [];
272
+ }
273
+ if (!this.checksAll()) {
274
+ checkAllPublisher.values = [...checkAllPublisher.values.get(), this.value];
275
+ }
276
+ }
125
277
  if (!this.hasAttribute("checked")) {
126
278
  return;
127
279
  }
128
280
  if (!this.publisher || this.publisher.get().checked !== false) {
129
- this.checked = true;
281
+ setTimeout(() => (this.checked = true), 1);
130
282
  }
131
283
  }
132
284
  }
@@ -142,6 +294,9 @@ const Form = (superClass) => {
142
294
  __decorate([
143
295
  property({ type: Boolean })
144
296
  ], FormCheckable.prototype, "radio", void 0);
297
+ __decorate([
298
+ property({ type: Boolean })
299
+ ], FormCheckable.prototype, "unCheckOnDisconnect", void 0);
145
300
  __decorate([
146
301
  property()
147
302
  ], FormCheckable.prototype, "checked", null);
@@ -1,22 +1,27 @@
1
1
  import { SubscriberInterface } from "@supersoniks/concorde/core/mixins/Subscriber";
2
+ import { PublisherInterface } from "../_types/types";
2
3
  declare type Constructor<T> = new (...args: any[]) => T;
3
4
  export interface FormElementInterface extends SubscriberInterface {
4
- getFormPublisher(): any;
5
+ getFormPublisher(): PublisherInterface;
5
6
  updateDataValue(): void;
6
- handleChange(e?: any): void;
7
- handleBlur(e?: any): void;
7
+ handleChange(e?: Event): void;
8
+ handleBlur(e?: Event): void;
8
9
  getValueForFormPublisher(): any;
10
+ focus?: () => void;
11
+ shadowRoot?: ShadowRoot;
9
12
  error: boolean;
10
13
  autofocus: boolean;
11
14
  required: boolean;
12
15
  disabled: true | null;
13
16
  formDataProvider: string;
14
- _value: any;
15
- get value(): any;
16
- set value(value: any);
17
+ ariaLabelledby?: string;
18
+ ariaLabel?: string;
19
+ _value: string | null;
20
+ get value(): string | null;
21
+ set value(value: string | null);
17
22
  _name: string;
18
23
  get name(): string;
19
24
  set name(value: string);
20
25
  }
21
- declare const Form: <T extends Constructor<SubscriberInterface>>(superClass: T) => Constructor<FormElementInterface> & T;
26
+ declare const Form: <T extends Constructor<SubscriberInterface<any>>>(superClass: T) => Constructor<FormElementInterface> & T;
22
27
  export default Form;