@supersoniks/concorde 1.1.5 → 1.1.8

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/cli.js CHANGED
@@ -58,41 +58,6 @@ function enableShortPaths() {
58
58
  }
59
59
  }
60
60
 
61
- function createConcordeTsApp() {
62
- const { execSync } = require('child_process');
63
- const runCommand = command => {
64
- try {
65
- execSync(command, { stdio: "inherit" });
66
- } catch (e) {
67
- console.error(`Failed to execute ${command}`, e);
68
- return false;
69
- }
70
- return true;
71
- }
72
- const repoName = process.argv[2];
73
- const gitCheckoutCommand = `git clone --depth 1 https://github.com/ladigitale/concorde-ts-starter ${repoName}`;
74
- const removeDotGitCommand = `rm -rf ${repoName}/.git`;
75
- const installDepsCommand = `cd ${repoName} && yarn install`
76
- const enableShortPathCmd = `cd ${repoName} && npx concorde enable-short-paths`;
77
- console.log(`Cloning repository with name ${repoName}`);
78
- const checkout = runCommand(gitCheckoutCommand)
79
- if (!checkout) process.exit(-1);
80
-
81
- const removeDotGit = runCommand(removeDotGitCommand);
82
- if (!removeDotGit) process.exit(-1);
83
-
84
- console.log(`installing dependencies for ${repoName}`);
85
- const installDeps = runCommand(installDepsCommand);
86
- if (!installDeps) process.exit(-1);
87
-
88
- const enableShortPath = runCommand(enableShortPathCmd);
89
- if (!enableShortPath) process.exit(-1);
90
-
91
-
92
- console.log("Congratulations! You are ready. Follow the following commands to start");
93
- console.log(`cd ${repoName} && yarn dev`);
94
-
95
- }
96
61
  switch (process.argv[2]) {
97
62
  case "enable-short-paths":
98
63
  enableShortPaths();
@@ -105,6 +70,5 @@ switch (process.argv[2]) {
105
70
  console.log("Usage: npx concorde <command>");
106
71
  console.log("Commands:");
107
72
  console.log(" enable-short-paths");
108
- console.log(" create-concorde-ts-app projectName");
109
73
  break;
110
74
  }
@@ -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;
@@ -64,6 +65,6 @@ export declare class List extends List_base {
64
65
  */
65
66
  idKey: string;
66
67
  connectedCallback(): void;
67
- render(): import("lit-html").TemplateResult<1>;
68
+ render(): import("lit-html/directive").DirectiveResult<typeof import("lit-html/directives/template-content").TemplateContentDirective>;
68
69
  }
69
70
  export {};
@@ -48,11 +48,15 @@ let List = class List extends Fetcher(Subscriber(TemplatesContainer(LitElement))
48
48
  this.defferedDebug = this.hasAttribute("debug") || null;
49
49
  this.isDefaultLoaderEnabled = false;
50
50
  this.isFetchEnabled = this.hasAttribute("fetch");
51
+ if (this.isFetchEnabled)
52
+ this.isLoading = true;
51
53
  super.connectedCallback();
52
54
  }
53
55
  render() {
54
56
  if (this.isLoading && !Array.isArray(this.props))
55
- return html `<sonic-loader mode="inline"></sonic-loader>`;
57
+ return this.templateParts["skeleton"]
58
+ ? templateContent(this.templateParts["skeleton"])
59
+ : html `<sonic-loader mode="inline"></sonic-loader>`;
56
60
  // si props est une string on considère qu'il n'y a pas de résultats
57
61
  if (typeof this.props == "string") {
58
62
  return html `<div class="sonic-no-result-container">
@@ -61,7 +65,7 @@ let List = class List extends Fetcher(Subscriber(TemplatesContainer(LitElement))
61
65
  </div>`;
62
66
  }
63
67
  // si props est un objet mais qu'il n'y a pas de contenu on retourn une div vide (nécessaire pour le lazyload)
64
- if (!Objects.isObject(this.props) || Object.keys(this.props).length == 0) {
68
+ if (!Objects.isObject(this.props)) {
65
69
  return html `<div></div>`;
66
70
  }
67
71
  let props = this.props;
@@ -75,6 +79,10 @@ let List = class List extends Fetcher(Subscriber(TemplatesContainer(LitElement))
75
79
  props = [props];
76
80
  }
77
81
  }
82
+ // On peut définir un template spécifique si le résultat est un tableau vide
83
+ if (props.length == 0 && this.templateParts["no-item"]) {
84
+ return templateContent(this.templateParts["no-item"]);
85
+ }
78
86
  // Resultats
79
87
  let templateCount = this.templateList.length;
80
88
  let counter = -1;
@@ -146,7 +146,10 @@ let Queue = Queue_1 = class Queue extends Subscriber(LitElement) {
146
146
  if (!Array.isArray(this.props))
147
147
  return nothing;
148
148
  return html `
149
- ${repeat(this.props, (item) => item.id, (item) => html `
149
+ ${repeat(this.props, (item) => item.id, (item, index) => {
150
+ var _a;
151
+ let templates = index == 0 ? this.templates : (_a = this.templates) === null || _a === void 0 ? void 0 : _a.filter(elt => elt.getAttribute("data-value") != "no-item");
152
+ return html `
150
153
  <sonic-list
151
154
  fetch
152
155
  .itemPropertyMap=${this.itemPropertyMap}
@@ -156,10 +159,11 @@ let Queue = Queue_1 = class Queue extends Subscriber(LitElement) {
156
159
  @loading=${this.resetDuration}
157
160
  dataProvider="${item.dataProvider}"
158
161
  idKey=${this.idKey}
159
- .templates=${this.templates}
162
+ .templates=${templates}
160
163
  >
161
164
  </sonic-list>
162
- `)}
165
+ `;
166
+ })}
163
167
  `;
164
168
  }
165
169
  };
@@ -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();
@@ -18,7 +18,12 @@ declare const Button_base: {
18
18
  updateDataValue(): void;
19
19
  error: true | null;
20
20
  autofocus: true | null;
21
- disabled: true | null;
21
+ disabled: true | null; /**
22
+ * Un bouton simple avec deux slots, un nommé préfix et un nomé suffix de manière à pouvoir mettre (par exemple) une icone avant ou après le contenu.
23
+ * * L'objet et ses slot sont en display flex avec direction / alignement et justifications configurables
24
+ * * Le bouton est comparable au badge car il possèdent tous les deux les propriétés *type* (primary...), *variant*(outline, ghost), size(xs...)...
25
+ * * Le bouton possède cependant et notamment une propriété href contrairement à un badge
26
+ */
22
27
  required: true | null;
23
28
  formDataProvider: string;
24
29
  props: any;
@@ -99,6 +104,10 @@ export declare class Button extends Button_base {
99
104
  hasSuffix: boolean;
100
105
  prefixes: HTMLElement[];
101
106
  suffixes: HTMLElement[];
107
+ /**
108
+ * target
109
+ */
110
+ target: "_self" | "_blank" | null;
102
111
  /**
103
112
  * L'url
104
113
  */
@@ -11,6 +11,7 @@ import { styleMap } from "lit/directives/style-map.js";
11
11
  import FormElement from "@supersoniks/concorde/core/mixins/FormElement";
12
12
  import FormCheckable from "@supersoniks/concorde/core/mixins/FormCheckable";
13
13
  import Subscriber from "@supersoniks/concorde/core/mixins/Subscriber";
14
+ import { ifDefined } from "lit/directives/if-defined.js";
14
15
  /**
15
16
  * Un bouton simple avec deux slots, un nommé préfix et un nomé suffix de manière à pouvoir mettre (par exemple) une icone avant ou après le contenu.
16
17
  * * L'objet et ses slot sont en display flex avec direction / alignement et justifications configurables
@@ -65,6 +66,10 @@ let Button = class Button extends FormCheckable(FormElement(Subscriber(LitElemen
65
66
  this.loading = false;
66
67
  this.hasPrefix = false;
67
68
  this.hasSuffix = false;
69
+ /**
70
+ * target
71
+ */
72
+ this.target = null;
68
73
  /**
69
74
  * L'url
70
75
  */
@@ -155,7 +160,7 @@ let Button = class Button extends FormCheckable(FormElement(Subscriber(LitElemen
155
160
  </button>
156
161
  `;
157
162
  return this.href
158
- ? html `<a href="${this.href}" @click=${this.pushState ? this.handlePushState : null}>${btn}</a>`
163
+ ? html `<a href="${this.href}" target=${ifDefined(this.target)} @click=${this.pushState ? this.handlePushState : null}>${btn}</a>`
159
164
  : html `${btn}`;
160
165
  }
161
166
  onSlotChange() {
@@ -540,6 +545,9 @@ __decorate([
540
545
  __decorate([
541
546
  queryAssignedElements({ flatten: true, slot: 'suffix' })
542
547
  ], Button.prototype, "suffixes", void 0);
548
+ __decorate([
549
+ property({ type: String })
550
+ ], Button.prototype, "target", void 0);
543
551
  __decorate([
544
552
  property({ type: String })
545
553
  ], Button.prototype, "href", null);
@@ -4,7 +4,7 @@ export const coreVariables = css `
4
4
  /* --sc-rfs: 16px; */
5
5
 
6
6
  /* polices*/
7
- --sc-font-family-base: "neue-haas-unica", -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", Roboto,
7
+ --sc-font-family-base: "Inter var", -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", Roboto,
8
8
  "Helvetica Neue", Arial, sans-serif;
9
9
  --sc-font-weight-base: 400;
10
10
  --sc-font-style-base: inherit;
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
  /**
@@ -56,6 +56,7 @@ const Fetcher = (superClass) => {
56
56
  return __awaiter(this, void 0, void 0, function* () {
57
57
  if (!this.isFetchEnabled)
58
58
  return;
59
+ this.api = new API(this.getApiConfiguration());
59
60
  if (!this.api)
60
61
  return;
61
62
  if (!this.dataProvider)
@@ -89,7 +90,7 @@ const Fetcher = (superClass) => {
89
90
  disconnectedCallback() {
90
91
  var _a;
91
92
  super.disconnectedCallback();
92
- (_a = this.publisher) === null || _a === void 0 ? void 0 : _a.offInvalidate(() => this._fetchData());
93
+ (_a = this.publisher) === null || _a === void 0 ? void 0 : _a.offInvalidate(this.onInvalidate);
93
94
  this.isFirstLoad = false;
94
95
  }
95
96
  connectedCallback() {
@@ -101,11 +102,11 @@ const Fetcher = (superClass) => {
101
102
  }
102
103
  super.connectedCallback();
103
104
  this.key = this.getAncestorAttributeValue("key");
104
- this.api = new API(this.getApiConfiguration());
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,15 @@ 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
+ }
16
19
  static observe(element) {
20
+ if (!DataBindObserver.enabled)
21
+ return;
17
22
  if (DataBindObserver.observedElements.has(element))
18
23
  return;
19
24
  let obs = new MutationObserver(DataBindObserver.onMutation);
@@ -252,5 +257,12 @@ export default class DataBindObserver {
252
257
  * Maintient la liste des éléments observés de manière à pouvoir les désinscrire quand ils sont supprimés.
253
258
  */
254
259
  DataBindObserver.observedElements = new Map();
260
+ /**
261
+ * Commencer à observer un élément html.
262
+ */
263
+ DataBindObserver.enabled = true;
255
264
  DataBindObserver.publisherListeners = new Map();
256
265
  DataBindObserver.observe(document.documentElement);
266
+ let win = window;
267
+ if (!win.SonicDataBindObserver)
268
+ win.SonicDataBindObserver = DataBindObserver;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@supersoniks/concorde",
3
- "version": "1.1.5",
3
+ "version": "1.1.8",
4
4
  "customElements": "custom-elements.json",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -169,7 +169,5 @@
169
169
  "./utils/api": "./core/utils/api",
170
170
  "./index": "./index"
171
171
  },
172
- "bin": {
173
- "concorde": "./cli.js"
174
- }
172
+ "bin": "./bin/cli.js"
175
173
  }