@supersoniks/concorde 1.0.7 → 1.1.1

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 (175) hide show
  1. package/README.md +16 -8
  2. package/cli.js +69 -0
  3. package/core/components/functional/date/date.d.ts +34 -0
  4. package/core/components/functional/date/date.js +187 -0
  5. package/core/components/functional/example/example.d.ts +7 -0
  6. package/core/components/functional/example/example.js +25 -0
  7. package/core/components/functional/fetch/fetch.d.ts +49 -0
  8. package/core/components/functional/fetch/fetch.js +38 -0
  9. package/core/components/functional/functional.d.ts +11 -0
  10. package/core/components/functional/functional.js +11 -0
  11. package/core/components/functional/if/if.d.ts +12 -0
  12. package/core/components/functional/if/if.js +43 -0
  13. package/core/components/functional/list/list.d.ts +67 -0
  14. package/core/components/functional/list/list.js +132 -0
  15. package/core/components/functional/queue/queue.d.ts +42 -0
  16. package/core/components/functional/queue/queue.js +184 -0
  17. package/core/components/functional/router/redirect.d.ts +18 -0
  18. package/core/components/functional/router/redirect.js +57 -0
  19. package/core/components/functional/router/router.d.ts +26 -0
  20. package/core/components/functional/router/router.js +104 -0
  21. package/core/components/functional/states/states.d.ts +28 -0
  22. package/core/components/functional/states/states.js +139 -0
  23. package/core/components/functional/submit/submit.d.ts +24 -0
  24. package/core/components/functional/submit/submit.js +108 -0
  25. package/{types/core/components → core/components/functional/subscriber}/subscriber.d.ts +5 -1
  26. package/core/components/functional/subscriber/subscriber.js +30 -0
  27. package/core/components/ui/alert/alert.d.ts +20 -0
  28. package/core/components/ui/alert/alert.js +150 -0
  29. package/core/components/ui/badge/badge.d.ts +24 -0
  30. package/core/components/ui/badge/badge.js +177 -0
  31. package/core/components/ui/button/button.d.ts +125 -0
  32. package/core/components/ui/button/button.js +558 -0
  33. package/core/components/ui/divider/divider.d.ts +11 -0
  34. package/core/components/ui/divider/divider.js +144 -0
  35. package/core/components/ui/form/checkbox/checkbox.d.ts +120 -0
  36. package/core/components/ui/form/checkbox/checkbox.js +203 -0
  37. package/core/components/ui/form/css/form-control.d.ts +1 -0
  38. package/core/components/ui/form/css/form-control.js +219 -0
  39. package/core/components/ui/form/fieldset/fieldset.d.ts +15 -0
  40. package/core/components/ui/form/fieldset/fieldset.js +70 -0
  41. package/core/components/ui/form/fieldset/legend.d.ts +11 -0
  42. package/core/components/ui/form/fieldset/legend.js +92 -0
  43. package/core/components/ui/form/form-layout/form-actions.d.ts +6 -0
  44. package/core/components/ui/form/form-layout/form-actions.js +23 -0
  45. package/core/components/ui/form/form-layout/form-layout.d.ts +9 -0
  46. package/core/components/ui/form/form-layout/form-layout.js +58 -0
  47. package/core/components/ui/form/input/input.d.ts +84 -0
  48. package/core/components/ui/form/input/input.js +180 -0
  49. package/core/components/ui/form/radio/radio.d.ts +12 -0
  50. package/core/components/ui/form/radio/radio.js +55 -0
  51. package/core/components/ui/form/select/select.d.ts +39 -0
  52. package/core/components/ui/form/select/select.js +220 -0
  53. package/core/components/ui/form/textarea/textarea.d.ts +69 -0
  54. package/core/components/ui/form/textarea/textarea.js +150 -0
  55. package/core/components/ui/group/group.d.ts +6 -0
  56. package/core/components/ui/group/group.js +57 -0
  57. package/core/components/ui/icon/icon.d.ts +17 -0
  58. package/core/components/ui/icon/icon.js +93 -0
  59. package/core/components/ui/icon/icons.d.ts +13 -0
  60. package/core/components/ui/icon/icons.js +25 -0
  61. package/core/components/ui/icon/icons.json +1 -0
  62. package/core/components/ui/image/image.d.ts +14 -0
  63. package/core/components/ui/image/image.js +152 -0
  64. package/core/components/ui/link/link.d.ts +16 -0
  65. package/core/components/ui/link/link.js +70 -0
  66. package/core/components/ui/loader/loader.d.ts +20 -0
  67. package/core/components/ui/loader/loader.js +94 -0
  68. package/{types → core}/components/ui/loader/styles/fixed.d.ts +0 -0
  69. package/core/components/ui/loader/styles/fixed.js +57 -0
  70. package/{types → core}/components/ui/loader/styles/inline.d.ts +0 -0
  71. package/core/components/ui/loader/styles/inline.js +71 -0
  72. package/core/components/ui/menu/menu-item.d.ts +5 -0
  73. package/core/components/ui/menu/menu-item.js +37 -0
  74. package/core/components/ui/menu/menu.d.ts +26 -0
  75. package/core/components/ui/menu/menu.js +125 -0
  76. package/core/components/ui/modal/modal-actions.d.ts +7 -0
  77. package/core/components/ui/modal/modal-actions.js +46 -0
  78. package/core/components/ui/modal/modal-close.d.ts +6 -0
  79. package/core/components/ui/modal/modal-close.js +38 -0
  80. package/core/components/ui/modal/modal-content.d.ts +5 -0
  81. package/core/components/ui/modal/modal-content.js +29 -0
  82. package/core/components/ui/modal/modal-subtitle.d.ts +5 -0
  83. package/core/components/ui/modal/modal-subtitle.js +33 -0
  84. package/core/components/ui/modal/modal-title.d.ts +5 -0
  85. package/core/components/ui/modal/modal-title.js +33 -0
  86. package/core/components/ui/modal/modal.d.ts +36 -0
  87. package/core/components/ui/modal/modal.js +325 -0
  88. package/core/components/ui/pop/pop.d.ts +28 -0
  89. package/core/components/ui/pop/pop.js +223 -0
  90. package/core/components/ui/tabs/tab.d.ts +6 -0
  91. package/core/components/ui/tabs/tab.js +46 -0
  92. package/core/components/ui/tabs/tabs.d.ts +14 -0
  93. package/core/components/ui/tabs/tabs.js +127 -0
  94. package/core/components/ui/taxonomy/taxonomy.d.ts +41 -0
  95. package/core/components/ui/taxonomy/taxonomy.js +113 -0
  96. package/core/components/ui/theme/css/tailwind.css +3 -0
  97. package/core/components/ui/theme/css/tailwind.d.ts +2 -0
  98. package/core/components/ui/theme/theme-collection/core-variables.d.ts +1 -0
  99. package/core/components/ui/theme/theme-collection/core-variables.js +50 -0
  100. package/{types/components → core/components/ui}/theme/theme-collection/dark.d.ts +0 -0
  101. package/core/components/ui/theme/theme-collection/dark.js +41 -0
  102. package/{types/components → core/components/ui}/theme/theme-collection/light.d.ts +0 -0
  103. package/core/components/ui/theme/theme-collection/light.js +35 -0
  104. package/core/components/ui/theme/theme.d.ts +11 -0
  105. package/core/components/ui/theme/theme.js +105 -0
  106. package/core/components/ui/toast/message-subscriber.d.ts +17 -0
  107. package/core/components/ui/toast/message-subscriber.js +85 -0
  108. package/{types → core}/components/ui/toast/toast.d.ts +10 -8
  109. package/core/components/ui/toast/toast.js +260 -0
  110. package/core/components/ui/tooltip/tooltip.d.ts +7 -0
  111. package/core/components/ui/tooltip/tooltip.js +68 -0
  112. package/core/components/ui/ui.d.ts +27 -0
  113. package/core/components/ui/ui.js +34 -0
  114. package/core/core.d.ts +3 -0
  115. package/core/core.js +7 -0
  116. package/core/mixins/Fetcher.d.ts +69 -0
  117. package/core/mixins/Fetcher.js +147 -0
  118. package/core/mixins/FormCheckable.d.ts +72 -0
  119. package/core/mixins/FormCheckable.js +144 -0
  120. package/core/mixins/FormElement.d.ts +21 -0
  121. package/core/mixins/FormElement.js +229 -0
  122. package/core/mixins/FormInput.d.ts +49 -0
  123. package/core/mixins/FormInput.js +33 -0
  124. package/core/mixins/Subscriber.d.ts +30 -0
  125. package/core/mixins/Subscriber.js +379 -0
  126. package/core/mixins/TemplatesContainer.d.ts +12 -0
  127. package/core/mixins/TemplatesContainer.js +60 -0
  128. package/core/mixins/mixins.d.ts +6 -0
  129. package/core/mixins/mixins.js +6 -0
  130. package/core/utils/Arrays.d.ts +97 -0
  131. package/core/utils/Arrays.js +136 -0
  132. package/core/utils/DataBindObserver.d.ts +74 -0
  133. package/core/utils/DataBindObserver.js +252 -0
  134. package/core/utils/Format.d.ts +11 -0
  135. package/core/utils/Format.js +22 -0
  136. package/core/utils/HTML.d.ts +13 -0
  137. package/core/utils/HTML.js +26 -0
  138. package/core/utils/LocationHandler.d.ts +44 -0
  139. package/core/utils/LocationHandler.js +96 -0
  140. package/core/utils/Objects.d.ts +23 -0
  141. package/core/utils/Objects.js +63 -0
  142. package/core/utils/PublisherProxy.d.mts +110 -0
  143. package/core/utils/PublisherProxy.mjs +371 -0
  144. package/core/utils/api.d.ts +66 -0
  145. package/core/utils/api.js +145 -0
  146. package/package.json +159 -21
  147. package/LICENSE +0 -43
  148. package/dist/concorde.bundle.js +0 -3620
  149. package/types/components/event/event-card/event-card.d.ts +0 -10
  150. package/types/components/event/event-title/event-title.d.ts +0 -7
  151. package/types/components/event/event.d.ts +0 -8
  152. package/types/components/giftcards/giftcard/giftcard.d.ts +0 -15
  153. package/types/components/illustration/illustration.d.ts +0 -16
  154. package/types/components/product/prices-form/price-button/price-button.d.ts +0 -25
  155. package/types/components/product/prices-form/prices-form.d.ts +0 -23
  156. package/types/components/theme/theme-collection/bootstrap5.d.ts +0 -1
  157. package/types/components/theme/theme-collection/dracula.d.ts +0 -1
  158. package/types/components/theme/theme.d.ts +0 -8
  159. package/types/components/ui/button/button.d.ts +0 -13
  160. package/types/components/ui/loader/loader.d.ts +0 -15
  161. package/types/components/ui/modal/modal.d.ts +0 -17
  162. package/types/components/ui/tooltip/tooltip.d.ts +0 -9
  163. package/types/core/components/fetch.d.ts +0 -6
  164. package/types/core/components/list.d.ts +0 -9
  165. package/types/core/components/queue.d.ts +0 -15
  166. package/types/core/components/taxonomy.d.ts +0 -13
  167. package/types/core/components/text-formatted.d.ts +0 -15
  168. package/types/core/components/text.d.ts +0 -9
  169. package/types/core/core.d.ts +0 -7
  170. package/types/core/mixins/Fetcher.d.ts +0 -9
  171. package/types/core/mixins/Subscriber.d.ts +0 -13
  172. package/types/core/utils/api.d.ts +0 -16
  173. package/types/index.d.ts +0 -12
  174. package/types/styles/button/button.d.ts +0 -1
  175. package/types/styles/prose/prose.d.ts +0 -2
@@ -0,0 +1,379 @@
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
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
8
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
9
+ return new (P || (P = Promise))(function (resolve, reject) {
10
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
11
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
12
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
13
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
14
+ });
15
+ };
16
+ import { PublisherManager } from "@supersoniks/concorde/core/utils/PublisherProxy.mjs";
17
+ import { property } from "lit/decorators.js";
18
+ import "@supersoniks/concorde/core/components/ui/icon/icon";
19
+ import API from "@supersoniks/concorde/core/utils/api";
20
+ import HTML from "@supersoniks/concorde/core/utils/HTML";
21
+ import DataBindObserver from "@supersoniks/concorde/core/utils/DataBindObserver";
22
+ import Objects from "../utils/Objects";
23
+ let keepDebugOnMouseOut = false;
24
+ let debugs = new Set();
25
+ //Pour référence
26
+ // export class Subscribable extends HTMLElement {
27
+ // constructor() {
28
+ // super();
29
+ // }
30
+ // requestUpdate(name?: PropertyKey, oldValue?: unknown, options?: PropertyDeclaration): void{name;oldValue;options;}
31
+ // protected updated(changedProperties: Map<string, PropertyDeclaration>): void {
32
+ // changedProperties;
33
+ // }
34
+ // connectedCallback(): void {}
35
+ // disconnectedCallback(): void {}
36
+ // protected createRenderRoot(): Element | ShadowRoot {
37
+ // return this.shadowRoot || this;
38
+ // }
39
+ // }
40
+ const Subscriber = (superClass) => {
41
+ /**
42
+ * La mixin Subscriber permet lier un composant à un publisher.
43
+ * La liaison à un publisher se fait via l'attribut *dataProvider* du composant qui représente ce que l'on obtient en appellant PublisherManager.get(dataProvider).
44
+ * les propriétés du composant sont automatiquement remplies avec les propriétés du même nom dans les données du publisher.
45
+ * Le composant est automatiquement mis à jour lorsque les données du publisher sont mises à jour.
46
+ */
47
+ class SubscriberElement extends superClass {
48
+ constructor(...args) {
49
+ super();
50
+ /**
51
+ * Par défaut on chée un shadow dom mais on peut demander à ne pas en avoir via cette propriété et un attribut associé.
52
+ * Cela se fait à l'initialisation uniquement et n'est pas modifiable lors de la vie du composant.
53
+ */
54
+ this.noShadowDom = null;
55
+ this.title = "";
56
+ /**
57
+ * L'id / l'adresse du publisher accessible via PublisherManager.get(dataProvider)
58
+ */
59
+ this.dataProvider = null;
60
+ /**
61
+ * On peut utiliser cette fonction pour lier un publisher spécifique au composant si besoin.
62
+ * voir l'utilisation dans list.ts
63
+ */
64
+ this.bindPublisher = null;
65
+ /**
66
+ * Les props du composant.
67
+ * Elles sont injectées en profondeur dans le publisher pour permettre la mutualisation des données entre les composants.
68
+ * Par conséquent l'assignation de ces propriété avec une chaine json (html classic), ou un objet / un tableaun remplie les données du publisher.
69
+ * Les propriétés des subscribers associés au même dataProvider sont donc "remplies" avec ces données, voir aussi le dataBinding à ce sujet.
70
+ */
71
+ this._props = null;
72
+ this.defferedDebug = null;
73
+ /**
74
+ * Ajoute un debugger au composant pour afficher en temps réel les données présentes dans sont publisher
75
+ */
76
+ this.debug = null;
77
+ /**
78
+ * On assign est enregistré car c'est un écouteur du publisher qui doit être délié lorsque l'objet est déconnecté du dom.
79
+ */
80
+ this.onAssign = null;
81
+ this.args = args;
82
+ }
83
+ /**
84
+ * retourn un objet contenant les propriétés de value + celle de props si elle ne sont pas déjà dans value.
85
+ */
86
+ makeShadow(props, value) {
87
+ if (typeof value == "object" && value !== null) {
88
+ let newValue = Array.isArray(value) ? [] : {};
89
+ Object.assign(newValue, value);
90
+ value = newValue;
91
+ for (let key in props) {
92
+ if (!value[key])
93
+ value[key] = props[key];
94
+ }
95
+ }
96
+ return value;
97
+ }
98
+ /**
99
+ * va de parent en parent pour trouver un attribut
100
+ * @param attributeName nom de l'attribut
101
+ * @returns true si l'attribut est trouvé
102
+ */
103
+ hasAncestorAttribute(attributeName) {
104
+ return this.getAncestorAttributeValue(attributeName) != null;
105
+ }
106
+ /**
107
+ * Va de parent en parent pour trouver un attribut
108
+ * @param attributeName nom de l'attribut
109
+ * @returns valeur de l'attribut ou null si l'attribut n'est pas trouvé
110
+ */
111
+ getAncestorAttributeValue(attributeName) {
112
+ let node = this;
113
+ return HTML.getAncestorAttributeValue(node, attributeName);
114
+ }
115
+ get props() {
116
+ if (!this.publisher)
117
+ return this._props;
118
+ return this.publisher.get();
119
+ }
120
+ set props(value) {
121
+ if (typeof value == "string" && ["{", "["].includes(value.trim().charAt(0))) {
122
+ value = JSON.parse(value);
123
+ }
124
+ if (value == null || value === "")
125
+ value = {};
126
+ if (!this.publisher)
127
+ this.initPublisher();
128
+ this._props = value;
129
+ if (this.publisher) {
130
+ this.publisher.set(value);
131
+ }
132
+ this.requestUpdate();
133
+ }
134
+ updated(_changedProperties) {
135
+ super.updated(_changedProperties);
136
+ if (this.shadowRoot) {
137
+ if (this.shadowRoot.children.length == 0)
138
+ this.style.display = "none";
139
+ else
140
+ this.style.removeProperty("display");
141
+ }
142
+ else {
143
+ if (this.children.length == 0)
144
+ this.style.display = "none";
145
+ else
146
+ this.style.removeProperty("display");
147
+ }
148
+ }
149
+ connectedCallback() {
150
+ if (this.hasAttribute("lazyRendering")) {
151
+ let options = {
152
+ root: null,
153
+ rootMargin: Math.max(window.innerWidth * 0.1, window.innerHeight * 0.1) + "px",
154
+ };
155
+ let firstView = true;
156
+ let iObserver = new IntersectionObserver((entries) => {
157
+ for (const e of entries) {
158
+ if (firstView && e.isIntersecting) {
159
+ firstView = false;
160
+ this.initWording();
161
+ this.initPublisher();
162
+ }
163
+ }
164
+ }, options);
165
+ iObserver.observe(this);
166
+ }
167
+ else {
168
+ this.initWording();
169
+ this.initPublisher();
170
+ }
171
+ this.addDebugger();
172
+ super.connectedCallback();
173
+ SubscriberElement.instanceCounter++;
174
+ }
175
+ disconnectedCallback() {
176
+ this.removeDebugger();
177
+ super.disconnectedCallback();
178
+ if (this.publisher)
179
+ this.publisher.stopTemplateFilling(this);
180
+ if (this.onAssign)
181
+ this.publisher.offAssign(this.onAssign);
182
+ }
183
+ addDebugger() {
184
+ if (this.hasAttribute("debug") && !this.defferedDebug) {
185
+ if (!this.debug) {
186
+ this.debug = document.createElement("div");
187
+ let style = this.debug.style;
188
+ style.position = "fixed";
189
+ style.top = "0";
190
+ style.right = "0";
191
+ style.margin = "auto";
192
+ style.borderRadius = ".7rem";
193
+ style.backgroundColor = "#0f1729";
194
+ style.color = "#c5d4f9";
195
+ style.padding = "16px 16px";
196
+ style.margin = "16px 16px";
197
+ style.boxShadow = "0 10px 30px -18px rgba(0,0,0,.3)";
198
+ style.overflowY = "auto";
199
+ style.zIndex = "99999999";
200
+ style.maxHeight = "calc(100vh - 32px)";
201
+ style.fontFamily = "Consolas, monospace";
202
+ style.maxWidth = "50vw";
203
+ style.fontSize = "12px";
204
+ style.minWidth = "300px";
205
+ style.overflowWrap = "break-word";
206
+ }
207
+ this.addEventListener("click", (e) => {
208
+ if (!e.ctrlKey)
209
+ return;
210
+ e.preventDefault();
211
+ keepDebugOnMouseOut = !keepDebugOnMouseOut;
212
+ });
213
+ if (this.dataProvider) {
214
+ let win = window;
215
+ win[this.dataProvider] = this.publisher;
216
+ }
217
+ this.addEventListener("mouseover", () => {
218
+ if (!keepDebugOnMouseOut)
219
+ this.removeDebugger();
220
+ document.body.appendChild(this.debug);
221
+ debugs.add(this.debug);
222
+ });
223
+ this.addEventListener("mouseout", () => {
224
+ if (!keepDebugOnMouseOut)
225
+ this.removeDebugger();
226
+ });
227
+ this.publisher.onInternalMutation(() => {
228
+ this.debug.innerHTML = `🤖 DataProvider : "<b style="font-weight:bold;color:#fff;">${this.dataProvider}</b>"<br>
229
+ <div style="font-size:10px;border-top:1px dashed;margin-top:5px;padding-left:23px;opacity:.6;padding-top:5px;">
230
+ Variable disponible dans la console<br>
231
+ ctrl + Clique : épingler / désépingler
232
+ </div>
233
+ <pre style="margin-top:10px;background:transparent;padding:0;font-size:inherit;color:inherit;">${JSON.stringify(this.publisher.get(), null, " ")}</pre>`;
234
+ });
235
+ }
236
+ }
237
+ removeDebugger() {
238
+ debugs.forEach((debug) => {
239
+ if (document.body.contains(debug))
240
+ document.body.removeChild(debug);
241
+ });
242
+ debugs = new Set();
243
+ }
244
+ /**
245
+ * Petite fonction utilitaire pour retourner la configuration a passer à l'utilitaire API
246
+ * Utilisée pour la configuration du wording / de la traduction ainsi que par le mixin fetcher par exemple
247
+ * A voir si on le bouge dans un utilitaire
248
+ */
249
+ getApiConfiguration() {
250
+ const token = this.getAncestorAttributeValue("token");
251
+ let serviceURL = this.getAncestorAttributeValue("serviceURL");
252
+ let userName = null;
253
+ let password = null;
254
+ let tokenProvider = null;
255
+ if (!token) {
256
+ userName = this.getAncestorAttributeValue("userName");
257
+ password = this.getAncestorAttributeValue("password");
258
+ tokenProvider = this.getAncestorAttributeValue("tokenProvider");
259
+ }
260
+ return { serviceURL, token, userName, password, tokenProvider };
261
+ }
262
+ /**
263
+ * Initialise le remplisage automatique des traductions / du wording
264
+ * Un publisher spécifique est créé pour le composant à l'adresse "sonic-wording"
265
+ * Le composant recherche la valeur de l'attribute "wordingProvider" que contient le point d'accès à l'api de traduction / libellés
266
+ * Il utilise ce service et le publisher créé pour remplir automatiquement toutes les propriétés préfixées avec "wording_".
267
+ */
268
+ initWording() {
269
+ return __awaiter(this, void 0, void 0, function* () {
270
+ let hasWording = false;
271
+ const propNames = Object.getOwnPropertyNames(this.constructor.prototype);
272
+ for (let p of propNames) {
273
+ if (p.indexOf("wording_") == 0) {
274
+ hasWording = true;
275
+ break;
276
+ }
277
+ }
278
+ if (!hasWording)
279
+ return;
280
+ let publisher = PublisherManager.getInstance().get("sonic-wording");
281
+ let wordingProvider = this.getAncestorAttributeValue("wordingProvider");
282
+ const api = new API(this.getApiConfiguration());
283
+ if (wordingProvider) {
284
+ let wordings = [];
285
+ let wordingsAll = [];
286
+ for (let p of propNames) {
287
+ if (p.indexOf("wording_") == 0) {
288
+ let p8 = p.substring(8);
289
+ if (!publisher.get()[p]) {
290
+ publisher[p] = "...";
291
+ wordings.push(p8);
292
+ }
293
+ wordingsAll.push(p8);
294
+ }
295
+ }
296
+ if (wordings.length > 0) {
297
+ let result = yield api.post(wordingProvider, { labels: wordings });
298
+ for (let elt in result) {
299
+ publisher["wording_" + elt] = result[elt];
300
+ }
301
+ }
302
+ publisher.startTemplateFilling(this);
303
+ }
304
+ });
305
+ }
306
+ /**
307
+ *
308
+ * Fonction native de lit surchargée pour la gestion du mode noShadowDom
309
+ * Le comportement de data binding est également créé ici va l'utilitaire DataBindObserver
310
+ */
311
+ createRenderRoot() {
312
+ if (this.noShadowDom === "" || this.getAttribute("noShadowDom") === "") {
313
+ return this;
314
+ }
315
+ let shadowRoot = super.createRenderRoot();
316
+ DataBindObserver.observe(shadowRoot);
317
+ return shadowRoot;
318
+ }
319
+ initPublisher() {
320
+ if (!document)
321
+ return;
322
+ if (this.publisher) {
323
+ this.publisher.stopTemplateFilling(this);
324
+ if (this.onAssign)
325
+ this.publisher.offAssign(this.onAssign);
326
+ }
327
+ const mng = PublisherManager.getInstance();
328
+ if (!this.dataProvider)
329
+ this.dataProvider = this.getAncestorAttributeValue("dataProvider");
330
+ let publisherId = this.dataProvider;
331
+ if (!publisherId && this._props) {
332
+ this.dataProvider = publisherId = "__subscriber__" + SubscriberElement.instanceCounter;
333
+ }
334
+ if (publisherId) {
335
+ if (this.bindPublisher) {
336
+ mng.set(publisherId, this.bindPublisher());
337
+ }
338
+ let pub = mng.get(publisherId);
339
+ this.dataProvider = publisherId;
340
+ if (this.hasAttribute("subDataProvider")) {
341
+ let dataPath = this.getAttribute("subDataProvider");
342
+ this.dataProvider = publisherId + "/" + dataPath;
343
+ pub = Objects.traverse(pub, dataPath.split("."));
344
+ this.publisher = pub;
345
+ }
346
+ this.publisher = pub;
347
+ }
348
+ // this.publisher = this.bindPublisher();
349
+ if (this.publisher) {
350
+ this.onAssign = () => {
351
+ this.requestUpdate();
352
+ };
353
+ this.publisher.onAssign(this.onAssign);
354
+ this.publisher.startTemplateFilling(this);
355
+ if (this._props) {
356
+ this.publisher.set(this._props);
357
+ }
358
+ }
359
+ }
360
+ }
361
+ SubscriberElement.instanceCounter = 0;
362
+ __decorate([
363
+ property({ type: String, attribute: "data-title" })
364
+ ], SubscriberElement.prototype, "title", void 0);
365
+ __decorate([
366
+ property({ reflect: true })
367
+ ], SubscriberElement.prototype, "dataProvider", void 0);
368
+ __decorate([
369
+ property()
370
+ ], SubscriberElement.prototype, "bindPublisher", void 0);
371
+ __decorate([
372
+ property()
373
+ ], SubscriberElement.prototype, "props", null);
374
+ return SubscriberElement;
375
+ };
376
+ export default Subscriber;
377
+ let win = window;
378
+ if (!win.SonicPublisherManager)
379
+ win.SonicPublisherManager = PublisherManager;
@@ -0,0 +1,12 @@
1
+ import { LitElement } from "lit";
2
+ declare type Constructor<T> = new (...args: any[]) => T;
3
+ export declare class TemplatesContainerInterface extends LitElement {
4
+ connectedCallback(): void;
5
+ templateParts: Record<string, HTMLTemplateElement>;
6
+ templatePartsList: HTMLTemplateElement[];
7
+ templates: HTMLTemplateElement[];
8
+ templateList: HTMLTemplateElement[];
9
+ templateValueAttribute: string;
10
+ }
11
+ declare const TemplatesContainer: <T extends Constructor<LitElement>>(superClass: T) => Constructor<TemplatesContainerInterface> & T;
12
+ export default TemplatesContainer;
@@ -0,0 +1,60 @@
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
+ import { LitElement } from "lit";
9
+ const TemplatesContainer = (superClass) => {
10
+ /**
11
+ * Mixin pour mutualiser la gestion des templates dans différents composants (list, router, date, states...)
12
+ * Les templates sont soit dans aus sein du composant dans la déclaration html, soit renseignés via l'attribut "templates"
13
+ */
14
+ class TemplatesContainerElement extends superClass {
15
+ constructor() {
16
+ super(...arguments);
17
+ /**
18
+ * On peut passer directement un tableu de template au composant via sont attribut.
19
+ * Voir utilisation dans le composant queue qui permet de ne pas doubler les balises templates à la déclaration.
20
+ */
21
+ this.templates = null;
22
+ /**
23
+ * C'est le nom de l'attribut qui permet de regrouper les templates possédant cet attributs dans templateParts et templatePartsList.
24
+ * Ceux qui n'ont pas cet attribut sont stockés dans templateList
25
+ */
26
+ this.templateValueAttribute = "data-value";
27
+ /**
28
+ * Tableau contenant tous les templates qui n'on pas d'attribut templateValueAttribute
29
+ */
30
+ this.templateList = [];
31
+ /**
32
+ * Objet contenant tous les templates qui ont un attribut templateValueAttribute.
33
+ * Les clefs sont la valeur de l'attribut du template dont le nom est la valeur de templateValueAttribute.
34
+ */
35
+ this.templateParts = {};
36
+ /**
37
+ * Comme template parts mais sous forme de tableau, sans les clefs.
38
+ */
39
+ this.templatePartsList = [];
40
+ }
41
+ connectedCallback() {
42
+ let templates = this.templates || [...this.querySelectorAll("template")];
43
+ for (let t of templates) {
44
+ if (t.hasAttribute(this.templateValueAttribute)) {
45
+ this.templateParts[t.getAttribute(this.templateValueAttribute)] = t;
46
+ this.templatePartsList.push(t);
47
+ }
48
+ }
49
+ this.templateList = templates.filter((t) => !t.getAttribute("data-value"));
50
+ if (this.templateList.length == 0)
51
+ this.templateList = templates;
52
+ super.connectedCallback();
53
+ }
54
+ }
55
+ __decorate([
56
+ property({ type: Array })
57
+ ], TemplatesContainerElement.prototype, "templates", void 0);
58
+ return TemplatesContainerElement;
59
+ };
60
+ export default TemplatesContainer;
@@ -0,0 +1,6 @@
1
+ import "./Fetcher";
2
+ import "./FormCheckable";
3
+ import "./FormElement";
4
+ import "./FormInput";
5
+ import "./Subscriber";
6
+ import "./TemplatesContainer";
@@ -0,0 +1,6 @@
1
+ import "./Fetcher";
2
+ import "./FormCheckable";
3
+ import "./FormElement";
4
+ import "./FormInput";
5
+ import "./Subscriber";
6
+ import "./TemplatesContainer";
@@ -0,0 +1,97 @@
1
+ declare class Arrays {
2
+ /**
3
+ * Vérifie si les deux tableaux ont le même contenu
4
+ */
5
+ static areEqual(array1: Array<any>, array2: Array<any>): boolean;
6
+ /**
7
+ * Fournie une fonction to1D qui transforme un tableau 2D en un tableau 1D par concaténation
8
+ */
9
+ static from2d(source: Array<Array<Record<string, any>>>): {
10
+ to1D: () => {
11
+ /**Obtenir le tableau final*/
12
+ get: () => Record<string, any>[];
13
+ everyItem: () => {
14
+ has: () => {
15
+ same: () => {
16
+ value: () => {
17
+ forKey: (key: string) => boolean;
18
+ };
19
+ };
20
+ };
21
+ value: () => {
22
+ forKey: (key: string) => any;
23
+ };
24
+ copy: () => {
25
+ fromKey: (atKey: string) => {
26
+ toKey: (toKey: string) => void;
27
+ };
28
+ };
29
+ };
30
+ map: (f: (elt: Record<string, any>) => any) => any;
31
+ filter: (f: (elt: Record<string, any>) => any) => any;
32
+ find: (f: (elt: Record<string, any>) => any) => Record<string, any> | undefined;
33
+ some: (f: (elt: Record<string, any>) => any) => boolean;
34
+ every: (f: (elt: Record<string, any>) => any) => boolean;
35
+ group: () => {
36
+ byKey: (key: string) => any;
37
+ };
38
+ without: () => {
39
+ duplicates: () => {
40
+ forKey: (key: string) => any;
41
+ };
42
+ itemsIn: (toRemoveFromSource: Record<string, any>[]) => {
43
+ havingSameValue: () => {
44
+ forKey: (key: string) => any;
45
+ };
46
+ };
47
+ };
48
+ };
49
+ };
50
+ /**
51
+ * Fournie des méthodes pour manipuler un tableau
52
+ * A l'écriture cela permet d'avoir des phrases du type:
53
+ * let data = Arrays.from(mon tableau)
54
+ * puis data.everyItem().has().same().value().forkey("key");
55
+ * Peu mieux faire. ou voir a remplacer un jour par loadHash par exemple.
56
+ **/
57
+ static from(source: Array<Record<string, any>>): {
58
+ /**Obtenir le tableau final*/
59
+ get: () => Record<string, any>[];
60
+ everyItem: () => {
61
+ has: () => {
62
+ same: () => {
63
+ value: () => {
64
+ forKey: (key: string) => boolean;
65
+ };
66
+ };
67
+ };
68
+ value: () => {
69
+ forKey: (key: string) => any;
70
+ };
71
+ copy: () => {
72
+ fromKey: (atKey: string) => {
73
+ toKey: (toKey: string) => void;
74
+ };
75
+ };
76
+ };
77
+ map: (f: (elt: Record<string, any>) => any) => any;
78
+ filter: (f: (elt: Record<string, any>) => any) => any;
79
+ find: (f: (elt: Record<string, any>) => any) => Record<string, any> | undefined;
80
+ some: (f: (elt: Record<string, any>) => any) => boolean;
81
+ every: (f: (elt: Record<string, any>) => any) => boolean;
82
+ group: () => {
83
+ byKey: (key: string) => any;
84
+ };
85
+ without: () => {
86
+ duplicates: () => {
87
+ forKey: (key: string) => any;
88
+ };
89
+ itemsIn: (toRemoveFromSource: Array<Record<string, any>>) => {
90
+ havingSameValue: () => {
91
+ forKey: (key: string) => any;
92
+ };
93
+ };
94
+ };
95
+ };
96
+ }
97
+ export default Arrays;