@inappstory/slide-api 0.1.52 → 0.1.53

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/dist/index.d.cts CHANGED
@@ -1639,6 +1639,7 @@ declare class WidgetBase<WidgetOptions extends WidgetOptionsBase> {
1639
1639
  protected localData: Record<string, any>;
1640
1640
  protected firstOpenTime: number;
1641
1641
  protected id: string;
1642
+ protected linkedLayers: Array<string>;
1642
1643
  startReadyPromise: Promise<void>;
1643
1644
  private startReadyResolve;
1644
1645
  constructor(element: HTMLElement, options: Partial<WidgetOptions>, _widgetCallbacks: WidgetCallbacks, widgetDeps: WidgetDeps, elementIdGetter?: (element: HTMLElement) => string, slideGetter?: (element: HTMLElement) => HTMLElement);
@@ -1677,6 +1678,7 @@ declare class WidgetBase<WidgetOptions extends WidgetOptionsBase> {
1677
1678
  onWidgetComplete(): void;
1678
1679
  onWidgetRequirePauseUI(): void;
1679
1680
  onWidgetRequireResumeUI(): void;
1681
+ protected _showWidgetLinkedLayer(layers: Array<HTMLElement>, widgetLayerIndex?: number, withStatEvent?: boolean): void;
1680
1682
  protected _showLayer(layers: Array<HTMLElement>, selectIndex: number, withStatEvent?: boolean): void;
1681
1683
  protected _statEventLayoutShow(layoutIndex: number): void;
1682
1684
  static onRefreshUserData<Widget extends WidgetBase<WidgetOptions>, WidgetOptions extends WidgetOptionsBase>(element: HTMLElement, localData: Record<string, any>): void;
package/dist/index.d.ts CHANGED
@@ -1639,6 +1639,7 @@ declare class WidgetBase<WidgetOptions extends WidgetOptionsBase> {
1639
1639
  protected localData: Record<string, any>;
1640
1640
  protected firstOpenTime: number;
1641
1641
  protected id: string;
1642
+ protected linkedLayers: Array<string>;
1642
1643
  startReadyPromise: Promise<void>;
1643
1644
  private startReadyResolve;
1644
1645
  constructor(element: HTMLElement, options: Partial<WidgetOptions>, _widgetCallbacks: WidgetCallbacks, widgetDeps: WidgetDeps, elementIdGetter?: (element: HTMLElement) => string, slideGetter?: (element: HTMLElement) => HTMLElement);
@@ -1677,6 +1678,7 @@ declare class WidgetBase<WidgetOptions extends WidgetOptionsBase> {
1677
1678
  onWidgetComplete(): void;
1678
1679
  onWidgetRequirePauseUI(): void;
1679
1680
  onWidgetRequireResumeUI(): void;
1681
+ protected _showWidgetLinkedLayer(layers: Array<HTMLElement>, widgetLayerIndex?: number, withStatEvent?: boolean): void;
1680
1682
  protected _showLayer(layers: Array<HTMLElement>, selectIndex: number, withStatEvent?: boolean): void;
1681
1683
  protected _statEventLayoutShow(layoutIndex: number): void;
1682
1684
  static onRefreshUserData<Widget extends WidgetBase<WidgetOptions>, WidgetOptions extends WidgetOptionsBase>(element: HTMLElement, localData: Record<string, any>): void;
package/dist/index.js CHANGED
@@ -7673,6 +7673,7 @@ class WidgetBase {
7673
7673
  localData = null;
7674
7674
  firstOpenTime = 0;
7675
7675
  id;
7676
+ linkedLayers;
7676
7677
  startReadyPromise = null;
7677
7678
  startReadyResolve = null;
7678
7679
  constructor(element, options, _widgetCallbacks, widgetDeps, elementIdGetter, slideGetter) {
@@ -7696,6 +7697,7 @@ class WidgetBase {
7696
7697
  this.disableTimer = getTagData(this.slide, "disableTimer") === "1";
7697
7698
  this.cardId = getValueOrException(getTagDataAsNumber(this.slide, "id"), "Empty cardId");
7698
7699
  this.cardType = getValueOrException(getTagDataAsNumber(this.slide, "cardType"), "Empty card type");
7700
+ this.linkedLayers = getValueOrDefault(getTagDataAsJson(this.element, "linkedLayers"), []);
7699
7701
  this.widgetDeps.getLayoutDirection();
7700
7702
  this.element.dir = this.layoutDirection;
7701
7703
  if (this.element.parentElement != null) {
@@ -7868,6 +7870,14 @@ class WidgetBase {
7868
7870
  onWidgetRequireResumeUI() {
7869
7871
  this._widgetCallbacks.onWidgetRequireResumeUI(this.cardId, this.slideIndex);
7870
7872
  }
7873
+ _showWidgetLinkedLayer(layers, widgetLayerIndex = 0, withStatEvent = false) {
7874
+ if (Array.isArray(this.linkedLayers) && this.linkedLayers[widgetLayerIndex] != null) {
7875
+ const selectedIndex = layers.findIndex(layer => getTagData(layer, "layerId") === this.linkedLayers[widgetLayerIndex]);
7876
+ if (selectedIndex !== -1) {
7877
+ this._showLayer(layers, selectedIndex, withStatEvent);
7878
+ }
7879
+ }
7880
+ }
7871
7881
  _showLayer(layers, selectIndex, withStatEvent = false) {
7872
7882
  if (this.widgetDeps.slideApiDeps.isExistsShowLayer()) {
7873
7883
  this.widgetDeps.slideApiDeps.showLayer(selectIndex);
@@ -8391,9 +8401,7 @@ class WidgetTimer extends WidgetBase {
8391
8401
  this.widgetDeps.slideApiDeps.showNextSlide(0);
8392
8402
  break;
8393
8403
  case TimerCompletionAction.ShowLayer: {
8394
- if (this.layers[1] != null) {
8395
- this._showLayer(this.layers, 1);
8396
- }
8404
+ this._showWidgetLinkedLayer(this.layers);
8397
8405
  }
8398
8406
  }
8399
8407
  }
@@ -18084,9 +18092,7 @@ class WidgetBarcode extends WidgetBase {
18084
18092
  this.widgetDeps.slideApiDeps.showToast(this.promocodeExhaustedNotificationText);
18085
18093
  }
18086
18094
  showPromocodeExhaustedLayer() {
18087
- if (this.layers[1] != null) {
18088
- this._showLayer(this.layers, 1);
18089
- }
18095
+ this._showWidgetLinkedLayer(this.layers);
18090
18096
  }
18091
18097
  static api = {
18092
18098
  widgetClassName: WidgetBarcode.widgetClassName,
@@ -18391,9 +18397,7 @@ class WidgetCopy extends WidgetBase {
18391
18397
  this.widgetDeps.slideApiDeps.showToast(this.promocodeExhaustedNotificationText);
18392
18398
  }
18393
18399
  showPromocodeExhaustedLayer() {
18394
- if (this.layers[1] != null) {
18395
- this._showLayer(this.layers, 1);
18396
- }
18400
+ this._showWidgetLinkedLayer(this.layers);
18397
18401
  }
18398
18402
  static api = {
18399
18403
  widgetClassName: WidgetCopy.widgetClassName,
@@ -18634,9 +18638,7 @@ class WidgetDataInput extends WidgetBase {
18634
18638
  }
18635
18639
  }
18636
18640
  showLayer() {
18637
- if (this.layers[1] != null) {
18638
- this._showLayer(this.layers, 1);
18639
- }
18641
+ this._showWidgetLinkedLayer(this.layers);
18640
18642
  }
18641
18643
  static api = {
18642
18644
  widgetClassName: WidgetDataInput.widgetClassName,
@@ -18718,9 +18720,7 @@ class WidgetDateCountdown extends WidgetBase {
18718
18720
  this._showLayer(this.layers, 0);
18719
18721
  }
18720
18722
  else {
18721
- if (this.layers[1] != null) {
18722
- this._showLayer(this.layers, 1);
18723
- }
18723
+ this._showWidgetLinkedLayer(this.layers);
18724
18724
  }
18725
18725
  }
18726
18726
  onPause() {
@@ -18803,9 +18803,7 @@ class WidgetDateCountdown extends WidgetBase {
18803
18803
  }
18804
18804
  else {
18805
18805
  this.pendingUpdate = false;
18806
- if (this.layers[1] != null) {
18807
- this._showLayer(this.layers, 1);
18808
- }
18806
+ this._showWidgetLinkedLayer(this.layers);
18809
18807
  }
18810
18808
  if (this.pendingUpdate) {
18811
18809
  this.env.requestAnimationFrame(() => this.updateTimer());
@@ -19622,15 +19620,9 @@ class WidgetPollLayers extends WidgetBase {
19622
19620
  this.selectedVariant = index;
19623
19621
  this.localData["_pl_g_" + this.elementId + "_sa"] = index;
19624
19622
  this.element.classList.add("done");
19625
- // main
19626
- let layerIndex = 0;
19627
- if (index === 0) {
19628
- layerIndex = 1;
19629
- }
19630
- else if (index === 1) {
19631
- layerIndex = 2;
19623
+ if (index === 0 || index === 1) {
19624
+ this._showWidgetLinkedLayer(this.layers, index, userAction);
19632
19625
  }
19633
- this._showLayer(this.layers, layerIndex, userAction);
19634
19626
  this.startReadyPromise.then(() => {
19635
19627
  if (this.disableTimer) {
19636
19628
  this.onWidgetComplete();
@@ -24274,7 +24266,7 @@ class WidgetShare extends WidgetBase {
24274
24266
  super.onRefreshUserData(localData);
24275
24267
  if (this.withLayer) {
24276
24268
  if (this.isDone()) {
24277
- this._showLayer(this.layers, 1);
24269
+ this._showWidgetLinkedLayer(this.layers);
24278
24270
  }
24279
24271
  else {
24280
24272
  this._showLayer(this.layers, 0);
@@ -24339,7 +24331,7 @@ class WidgetShare extends WidgetBase {
24339
24331
  }
24340
24332
  this._statEventShare(isSuccess, null);
24341
24333
  if (isSuccess && this.withLayer) {
24342
- this._showLayer(this.layers, 1, true);
24334
+ this._showWidgetLinkedLayer(this.layers, 0, true);
24343
24335
  }
24344
24336
  if (this.disableTimer) {
24345
24337
  this.onWidgetComplete();