@supersoniks/concorde 3.1.33 → 3.1.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@supersoniks/concorde",
3
- "version": "3.1.33",
3
+ "version": "3.1.35",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "",
@@ -1,4 +1,4 @@
1
- import { html, LitElement, nothing } from "lit";
1
+ import { html, LitElement, nothing, PropertyValues } from "lit";
2
2
  import { customElement, property } from "lit/decorators.js";
3
3
  import Subscriber from "@supersoniks/concorde/core/mixins/Subscriber";
4
4
  import { map } from "lit/directives/map.js";
@@ -62,6 +62,7 @@ export default class Queue extends Subscriber(LitElement, {} as QueueProps) {
62
62
  }
63
63
  this.filterPublisher?.offInternalMutation(this.updateFilteredContent);
64
64
  // reset internal state
65
+
65
66
  this.props = null;
66
67
  this.limit = 5;
67
68
  this.offset = 0;
@@ -77,6 +78,8 @@ export default class Queue extends Subscriber(LitElement, {} as QueueProps) {
77
78
  static instanceCounter = 0;
78
79
  instanceId = 0;
79
80
  localStorage = "disabled";
81
+
82
+
80
83
  async connectedCallback() {
81
84
  this.instanceId = Queue.instanceCounter++;
82
85
  this.localStorage = this.getAttribute("localStorage") || this.localStorage;
@@ -181,6 +184,23 @@ export default class Queue extends Subscriber(LitElement, {} as QueueProps) {
181
184
  this.isFirstRequest = false;
182
185
  };
183
186
 
187
+ protected updated(_changedProperties: PropertyValues): void {
188
+
189
+ if(Math.abs(this.scrollX - window.scrollX) > 10 || Math.abs(this.scrollY - window.scrollY) > 10){
190
+ window.scrollTo(this.scrollX, this.scrollY);
191
+ }
192
+ //Hack pour éviter que le scroll ne retourne en haut si safari
193
+ window.requestAnimationFrame(() => {
194
+ if(Math.abs(this.scrollX - window.scrollX) > 10 || Math.abs(this.scrollY - window.scrollY) > 10){
195
+ window.scrollTo(this.scrollX, this.scrollY);
196
+ }
197
+ });
198
+
199
+ super.updated(_changedProperties);
200
+ }
201
+
202
+
203
+
184
204
  /**
185
205
  * Cette expression est utilisée comme modèle par le composant Queue pour renseigngner le dataProvider de la [liste](./?path=/docs/core-components-functional-list-list--basic) créée.
186
206
  * * l'expression *$offset* est alors remplacée par le numéro de l'élément à partir duquel démarrer
@@ -280,15 +300,27 @@ export default class Queue extends Subscriber(LitElement, {} as QueueProps) {
280
300
  ];
281
301
  newProps.resultCount = this.resultCount;
282
302
  newProps.lastFetchedData = e?.detail.fetchedData || {};
303
+
283
304
  this.props = newProps;
284
305
  this.lastRequestTime = new Date().getTime();
285
306
  }
307
+
308
+ scrollY = 0;
309
+ scrollX = 0;
310
+
286
311
  render() {
287
- if (!Array.isArray(this.props)) return nothing;
312
+ if (!Array.isArray(this.props)){
313
+ return nothing;
314
+ }
315
+
316
+ this.scrollX = window.scrollX;
317
+ this.scrollY = window.scrollY;
318
+
288
319
  let lazyload = !this.noLazyload;
289
320
  if (this.props.length == 1) {
290
321
  lazyload = false;
291
322
  }
323
+ this.style.display = "block";
292
324
  return html`
293
325
  ${map(this.props, (item, index) => {
294
326
  const templates =
@@ -4,7 +4,7 @@ import HTML from "@supersoniks/concorde/core/utils/HTML";
4
4
  import Objects from "@supersoniks/concorde/core/utils/Objects";
5
5
  import { PublisherManager } from "@supersoniks/concorde/core/utils/PublisherProxy";
6
6
  import { LitElement, PropertyValues } from "lit";
7
- import { property } from "lit/decorators.js";
7
+ import { property, state } from "lit/decorators.js";
8
8
  import WordingDirective from "../directives/Wording";
9
9
  import {
10
10
  PublisherInterface,
@@ -33,6 +33,7 @@ export interface SubscriberInterface<PropsType = CoreJSType> {
33
33
  defferedDebug: boolean | null;
34
34
  displayContents: boolean;
35
35
  shadowRoot?: ShadowRoot;
36
+ shouldRenderLazy: boolean;
36
37
  dispatchEvent(event: Event): void;
37
38
  setAttribute(name: string, value: string): void;
38
39
  addEventListener(
@@ -166,6 +167,8 @@ const Subscriber = <
166
167
  }
167
168
  this.requestUpdate();
168
169
  }
170
+
171
+
169
172
  protected updated(_changedProperties: PropertyValues): void {
170
173
  super.updated(_changedProperties);
171
174
  const ref = this.shadowRoot || this;
@@ -180,6 +183,7 @@ const Subscriber = <
180
183
  if (display) this.style.display = display;
181
184
  else this.style.removeProperty("display");
182
185
  }
186
+ @state() shouldRenderLazy = true;
183
187
  connectedCallback() {
184
188
  SubscriberElement.instanceCounter++;
185
189
  if (this.hasAttribute("lazyRendering")) {
@@ -193,11 +197,11 @@ const Subscriber = <
193
197
  const iObserver = new IntersectionObserver((entries) => {
194
198
  for (const e of entries) {
195
199
  if (firstView && e.isIntersecting) {
196
- this.addDebugger();
197
200
  firstView = false;
198
- this.initWording();
199
- this.initPublisher();
200
201
  iObserver.disconnect();
202
+ this.initWording();
203
+ this.shouldRenderLazy = false;
204
+ this.startPublisher();
201
205
  break;
202
206
  }
203
207
  }
@@ -205,10 +209,13 @@ const Subscriber = <
205
209
  iObserver.observe(this);
206
210
  } else {
207
211
  this.initWording();
208
- this.initPublisher();
209
- this.addDebugger();
212
+ this.shouldRenderLazy = false;
210
213
  }
214
+
215
+ this.initPublisher();
216
+ this.addDebugger();
211
217
  super.connectedCallback();
218
+
212
219
  }
213
220
 
214
221
  disconnectedCallback() {
@@ -336,6 +343,8 @@ const Subscriber = <
336
343
  this.props = v;
337
344
  };
338
345
 
346
+
347
+
339
348
  initPublisher() {
340
349
  if (!document) return;
341
350
  if (this.publisher) {
@@ -372,6 +381,14 @@ const Subscriber = <
372
381
  }
373
382
  this.publisher = pub;
374
383
  }
384
+ if(this.hasAttribute("lazyRendering")) {
385
+ return;
386
+ }
387
+ else{
388
+ this.startPublisher();
389
+ }
390
+ }
391
+ startPublisher() {
375
392
  if (this.publisher) {
376
393
  if (this._props) {
377
394
  this.publisher.set(this._props);