@supersoniks/concorde 1.1.6 → 1.1.7

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.
@@ -9,6 +9,7 @@ declare const Fetch_base: {
9
9
  isDefaultLoaderEnabled: boolean;
10
10
  isFetchEnabled: boolean;
11
11
  _fetchData(): Promise<void>;
12
+ onInvalidate: any;
12
13
  disconnectedCallback(): void;
13
14
  connectedCallback(): void;
14
15
  firstUpdated(): void;
@@ -47,6 +48,7 @@ declare const Fetch_base: {
47
48
  * * On peut appler la methode invalidate() sur son publishe pour declencher le rechargement des données
48
49
  */
49
50
  export declare class Fetch extends Fetch_base {
51
+ noAutofill: boolean;
50
52
  static styles: import("lit").CSSResult[];
51
53
  render(): import("lit-html").TemplateResult<1>;
52
54
  }
@@ -20,6 +20,10 @@ import Fetcher from "@supersoniks/concorde/core/mixins/Fetcher";
20
20
  * * On peut appler la methode invalidate() sur son publishe pour declencher le rechargement des données
21
21
  */
22
22
  let Fetch = class Fetch extends Fetcher(Subscriber(LitElement)) {
23
+ constructor() {
24
+ super(...arguments);
25
+ this.noAutofill = true;
26
+ }
23
27
  render() {
24
28
  return html `<slot></slot>`;
25
29
  }
@@ -11,6 +11,7 @@ declare const List_base: {
11
11
  isDefaultLoaderEnabled: boolean;
12
12
  isFetchEnabled: boolean;
13
13
  _fetchData(): Promise<void>;
14
+ onInvalidate: any;
14
15
  disconnectedCallback(): void;
15
16
  connectedCallback(): void;
16
17
  firstUpdated(): void;
@@ -4,6 +4,7 @@ declare const SonicSubscriber_base: (new (...args: any[]) => import("@supersonik
4
4
  * Voir la partie dédiée dans *MISCALLENOUS*
5
5
  */
6
6
  export declare class SonicSubscriber extends SonicSubscriber_base {
7
+ noAutofill: boolean;
7
8
  connectedCallback(): void;
8
9
  render(): import("lit-html").TemplateResult<1>;
9
10
  }
@@ -11,6 +11,10 @@ import Subscriber from "@supersoniks/concorde/core/mixins/Subscriber";
11
11
  * Voir la partie dédiée dans *MISCALLENOUS*
12
12
  */
13
13
  let SonicSubscriber = class SonicSubscriber extends Subscriber(LitElement) {
14
+ constructor() {
15
+ super(...arguments);
16
+ this.noAutofill = true;
17
+ }
14
18
  connectedCallback() {
15
19
  this.noShadowDom = "";
16
20
  super.connectedCallback();
package/core/core.js CHANGED
@@ -2,6 +2,9 @@ import "./components/functional/functional";
2
2
  import "./components/ui/ui";
3
3
  import "./mixins/mixins";
4
4
  import { PublisherManager } from "@supersoniks/concorde/core/utils/PublisherProxy.mjs";
5
+ import DataBindObserver from "./utils/DataBindObserver";
5
6
  let win = window;
6
- if (!win.PublisherManager)
7
+ if (!win.SonicPublisherManager)
7
8
  win.SonicPublisherManager = PublisherManager;
9
+ if (!win.SonicDataBindObserver)
10
+ win.SonicDataBindObserver = DataBindObserver;
@@ -38,6 +38,7 @@ declare const Fetcher: <T extends Constructor<SubscriberInterface>>(superClass:
38
38
  * Un Toast est affiché si le chargement échoue
39
39
  */
40
40
  _fetchData(): Promise<void>;
41
+ onInvalidate: any;
41
42
  disconnectedCallback(): void;
42
43
  connectedCallback(): void;
43
44
  /**
@@ -89,7 +89,7 @@ const Fetcher = (superClass) => {
89
89
  disconnectedCallback() {
90
90
  var _a;
91
91
  super.disconnectedCallback();
92
- (_a = this.publisher) === null || _a === void 0 ? void 0 : _a.offInvalidate(() => this._fetchData());
92
+ (_a = this.publisher) === null || _a === void 0 ? void 0 : _a.offInvalidate(this.onInvalidate);
93
93
  this.isFirstLoad = false;
94
94
  }
95
95
  connectedCallback() {
@@ -105,7 +105,8 @@ const Fetcher = (superClass) => {
105
105
  if (this.props) {
106
106
  this.publisher.set(this.props);
107
107
  }
108
- (_a = this.publisher) === null || _a === void 0 ? void 0 : _a.onInvalidate(() => this._fetchData());
108
+ this.onInvalidate = () => this._fetchData();
109
+ (_a = this.publisher) === null || _a === void 0 ? void 0 : _a.onInvalidate(this.onInvalidate);
109
110
  const lazyLoad = this.getAncestorAttributeValue("lazyload");
110
111
  if (lazyLoad === null) {
111
112
  this._fetchData();
@@ -47,6 +47,14 @@ const Subscriber = (superClass) => {
47
47
  class SubscriberElement extends superClass {
48
48
  constructor(...args) {
49
49
  super();
50
+ /**
51
+ * noAutoFill permet de désactiver le remplissage automatique des propriétés par le publisher dans le cas ou on utilise "props" seulement ou le dataBinding par exemple
52
+ */
53
+ this.noAutoFill = false;
54
+ /**
55
+ *
56
+ */
57
+ this.renderOnPropsInternalChange = false;
50
58
  /**
51
59
  * 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
60
  * Cela se fait à l'initialisation uniquement et n'est pas modifiable lors de la vie du composant.
@@ -179,8 +187,12 @@ const Subscriber = (superClass) => {
179
187
  disconnectedCallback() {
180
188
  this.removeDebugger();
181
189
  super.disconnectedCallback();
182
- if (this.publisher)
190
+ if (this.publisher) {
183
191
  this.publisher.stopTemplateFilling(this);
192
+ this.publisher.offInternalMutation(this.requestUpdate());
193
+ }
194
+ if (this.wordingPublisher)
195
+ this.wordingPublisher.stopTemplateFilling(this);
184
196
  if (this.onAssign)
185
197
  this.publisher.offAssign(this.onAssign);
186
198
  }
@@ -263,12 +275,6 @@ const Subscriber = (superClass) => {
263
275
  }
264
276
  return { serviceURL, token, userName, password, tokenProvider };
265
277
  }
266
- /**
267
- * Initialise le remplisage automatique des traductions / du wording
268
- * Un publisher spécifique est créé pour le composant à l'adresse "sonic-wording"
269
- * Le composant recherche la valeur de l'attribute "wordingProvider" que contient le point d'accès à l'api de traduction / libellés
270
- * Il utilise ce service et le publisher créé pour remplir automatiquement toutes les propriétés préfixées avec "wording_".
271
- */
272
278
  initWording() {
273
279
  return __awaiter(this, void 0, void 0, function* () {
274
280
  let hasWording = false;
@@ -304,6 +310,7 @@ const Subscriber = (superClass) => {
304
310
  }
305
311
  }
306
312
  publisher.startTemplateFilling(this);
313
+ this.wordingPublisher = publisher;
307
314
  }
308
315
  });
309
316
  }
@@ -325,6 +332,7 @@ const Subscriber = (superClass) => {
325
332
  return;
326
333
  if (this.publisher) {
327
334
  this.publisher.stopTemplateFilling(this);
335
+ this.publisher.offInternalMutation(this.requestUpdate);
328
336
  if (this.onAssign)
329
337
  this.publisher.offAssign(this.onAssign);
330
338
  }
@@ -355,7 +363,10 @@ const Subscriber = (superClass) => {
355
363
  this.requestUpdate();
356
364
  };
357
365
  this.publisher.onAssign(this.onAssign);
358
- this.publisher.startTemplateFilling(this);
366
+ if (!this.noAutoFill)
367
+ this.publisher.startTemplateFilling(this);
368
+ if (this.renderOnPropsInternalChange)
369
+ this.publisher.onInternalMutation(this.requestUpdate);
359
370
  if (this._props) {
360
371
  this.publisher.set(this._props);
361
372
  }
@@ -22,6 +22,8 @@ export default class DataBindObserver {
22
22
  /**
23
23
  * Commencer à observer un élément html.
24
24
  */
25
+ static enabled: boolean;
26
+ static disable(): void;
25
27
  static observe(element: HTMLElement): void;
26
28
  /**
27
29
  * Arrêter à observer un élément html.
@@ -10,10 +10,17 @@ import { PublisherManager } from "@supersoniks/concorde/core/utils/PublisherProx
10
10
  * Voir la doc de subscriber à ce sujet car il l'utilise par défaut.
11
11
  */
12
12
  export default class DataBindObserver {
13
- /**
14
- * Commencer à observer un élément html.
15
- */
13
+ static disable() {
14
+ if (!this.enabled)
15
+ return;
16
+ this.enabled = false;
17
+ Array.from(DataBindObserver.observedElements.keys()).forEach((k) => DataBindObserver.unObserve(k));
18
+ console.log("disabled");
19
+ }
16
20
  static observe(element) {
21
+ if (!DataBindObserver.enabled)
22
+ return;
23
+ console.log("Observe");
17
24
  if (DataBindObserver.observedElements.has(element))
18
25
  return;
19
26
  let obs = new MutationObserver(DataBindObserver.onMutation);
@@ -252,5 +259,12 @@ export default class DataBindObserver {
252
259
  * Maintient la liste des éléments observés de manière à pouvoir les désinscrire quand ils sont supprimés.
253
260
  */
254
261
  DataBindObserver.observedElements = new Map();
262
+ /**
263
+ * Commencer à observer un élément html.
264
+ */
265
+ DataBindObserver.enabled = true;
255
266
  DataBindObserver.publisherListeners = new Map();
256
267
  DataBindObserver.observe(document.documentElement);
268
+ let win = window;
269
+ if (!win.SonicDataBindObserver)
270
+ win.SonicDataBindObserver = DataBindObserver;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@supersoniks/concorde",
3
- "version": "1.1.6",
3
+ "version": "1.1.7",
4
4
  "customElements": "custom-elements.json",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
package/bin/cli.js DELETED
@@ -1,35 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const { execSync } = require('child_process');
4
- const runCommand = command => {
5
- try {
6
- execSync(command, { stdio: "inherit" });
7
- } catch (e) {
8
- console.error(`Failed to execute ${command}`, e);
9
- return false;
10
- }
11
- return true;
12
- }
13
- const repoName = process.argv[2];
14
- const gitCheckoutCommand = `git clone --depth 1 https://github.com/ladigitale/concorde-ts-starter ${repoName}`;
15
- const removeDotGitCommand = `rm -rf ${repoName}/.git`;
16
- const installDepsCommand = `cd ${repoName} && yarn install`
17
- const enableShortPathCmd = `cd ${repoName} && npx concorde enable-short-paths`;
18
- console.log(`Cloning repository with name ${repoName}`);
19
- const checkout = runCommand(gitCheckoutCommand)
20
- if (!checkout) process.exit(-1);
21
-
22
- const removeDotGit = runCommand(removeDotGitCommand);
23
- if (!removeDotGit) process.exit(-1);
24
-
25
- console.log(`installing dependencies for ${repoName}`);
26
- const installDeps = runCommand(installDepsCommand);
27
- if (!installDeps) process.exit(-1);
28
-
29
- const enableShortPath = runCommand(enableShortPathCmd);
30
- if (!enableShortPath) process.exit(-1);
31
-
32
-
33
- console.log("Congratulations! You are ready. Follow the following commands to start");
34
- console.log(`cd ${repoName} && yarn dev`);
35
-