@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.cjs CHANGED
@@ -7675,6 +7675,7 @@ class WidgetBase {
7675
7675
  localData = null;
7676
7676
  firstOpenTime = 0;
7677
7677
  id;
7678
+ linkedLayers;
7678
7679
  startReadyPromise = null;
7679
7680
  startReadyResolve = null;
7680
7681
  constructor(element, options, _widgetCallbacks, widgetDeps, elementIdGetter, slideGetter) {
@@ -7698,6 +7699,7 @@ class WidgetBase {
7698
7699
  this.disableTimer = getTagData(this.slide, "disableTimer") === "1";
7699
7700
  this.cardId = getValueOrException(getTagDataAsNumber(this.slide, "id"), "Empty cardId");
7700
7701
  this.cardType = getValueOrException(getTagDataAsNumber(this.slide, "cardType"), "Empty card type");
7702
+ this.linkedLayers = getValueOrDefault(getTagDataAsJson(this.element, "linkedLayers"), []);
7701
7703
  this.widgetDeps.getLayoutDirection();
7702
7704
  this.element.dir = this.layoutDirection;
7703
7705
  if (this.element.parentElement != null) {
@@ -7870,6 +7872,14 @@ class WidgetBase {
7870
7872
  onWidgetRequireResumeUI() {
7871
7873
  this._widgetCallbacks.onWidgetRequireResumeUI(this.cardId, this.slideIndex);
7872
7874
  }
7875
+ _showWidgetLinkedLayer(layers, widgetLayerIndex = 0, withStatEvent = false) {
7876
+ if (Array.isArray(this.linkedLayers) && this.linkedLayers[widgetLayerIndex] != null) {
7877
+ const selectedIndex = layers.findIndex(layer => getTagData(layer, "layerId") === this.linkedLayers[widgetLayerIndex]);
7878
+ if (selectedIndex !== -1) {
7879
+ this._showLayer(layers, selectedIndex, withStatEvent);
7880
+ }
7881
+ }
7882
+ }
7873
7883
  _showLayer(layers, selectIndex, withStatEvent = false) {
7874
7884
  if (this.widgetDeps.slideApiDeps.isExistsShowLayer()) {
7875
7885
  this.widgetDeps.slideApiDeps.showLayer(selectIndex);
@@ -8393,9 +8403,7 @@ class WidgetTimer extends WidgetBase {
8393
8403
  this.widgetDeps.slideApiDeps.showNextSlide(0);
8394
8404
  break;
8395
8405
  case TimerCompletionAction.ShowLayer: {
8396
- if (this.layers[1] != null) {
8397
- this._showLayer(this.layers, 1);
8398
- }
8406
+ this._showWidgetLinkedLayer(this.layers);
8399
8407
  }
8400
8408
  }
8401
8409
  }
@@ -18086,9 +18094,7 @@ class WidgetBarcode extends WidgetBase {
18086
18094
  this.widgetDeps.slideApiDeps.showToast(this.promocodeExhaustedNotificationText);
18087
18095
  }
18088
18096
  showPromocodeExhaustedLayer() {
18089
- if (this.layers[1] != null) {
18090
- this._showLayer(this.layers, 1);
18091
- }
18097
+ this._showWidgetLinkedLayer(this.layers);
18092
18098
  }
18093
18099
  static api = {
18094
18100
  widgetClassName: WidgetBarcode.widgetClassName,
@@ -18393,9 +18399,7 @@ class WidgetCopy extends WidgetBase {
18393
18399
  this.widgetDeps.slideApiDeps.showToast(this.promocodeExhaustedNotificationText);
18394
18400
  }
18395
18401
  showPromocodeExhaustedLayer() {
18396
- if (this.layers[1] != null) {
18397
- this._showLayer(this.layers, 1);
18398
- }
18402
+ this._showWidgetLinkedLayer(this.layers);
18399
18403
  }
18400
18404
  static api = {
18401
18405
  widgetClassName: WidgetCopy.widgetClassName,
@@ -18636,9 +18640,7 @@ class WidgetDataInput extends WidgetBase {
18636
18640
  }
18637
18641
  }
18638
18642
  showLayer() {
18639
- if (this.layers[1] != null) {
18640
- this._showLayer(this.layers, 1);
18641
- }
18643
+ this._showWidgetLinkedLayer(this.layers);
18642
18644
  }
18643
18645
  static api = {
18644
18646
  widgetClassName: WidgetDataInput.widgetClassName,
@@ -18720,9 +18722,7 @@ class WidgetDateCountdown extends WidgetBase {
18720
18722
  this._showLayer(this.layers, 0);
18721
18723
  }
18722
18724
  else {
18723
- if (this.layers[1] != null) {
18724
- this._showLayer(this.layers, 1);
18725
- }
18725
+ this._showWidgetLinkedLayer(this.layers);
18726
18726
  }
18727
18727
  }
18728
18728
  onPause() {
@@ -18805,9 +18805,7 @@ class WidgetDateCountdown extends WidgetBase {
18805
18805
  }
18806
18806
  else {
18807
18807
  this.pendingUpdate = false;
18808
- if (this.layers[1] != null) {
18809
- this._showLayer(this.layers, 1);
18810
- }
18808
+ this._showWidgetLinkedLayer(this.layers);
18811
18809
  }
18812
18810
  if (this.pendingUpdate) {
18813
18811
  this.env.requestAnimationFrame(() => this.updateTimer());
@@ -19624,15 +19622,9 @@ class WidgetPollLayers extends WidgetBase {
19624
19622
  this.selectedVariant = index;
19625
19623
  this.localData["_pl_g_" + this.elementId + "_sa"] = index;
19626
19624
  this.element.classList.add("done");
19627
- // main
19628
- let layerIndex = 0;
19629
- if (index === 0) {
19630
- layerIndex = 1;
19631
- }
19632
- else if (index === 1) {
19633
- layerIndex = 2;
19625
+ if (index === 0 || index === 1) {
19626
+ this._showWidgetLinkedLayer(this.layers, index, userAction);
19634
19627
  }
19635
- this._showLayer(this.layers, layerIndex, userAction);
19636
19628
  this.startReadyPromise.then(() => {
19637
19629
  if (this.disableTimer) {
19638
19630
  this.onWidgetComplete();
@@ -24276,7 +24268,7 @@ class WidgetShare extends WidgetBase {
24276
24268
  super.onRefreshUserData(localData);
24277
24269
  if (this.withLayer) {
24278
24270
  if (this.isDone()) {
24279
- this._showLayer(this.layers, 1);
24271
+ this._showWidgetLinkedLayer(this.layers);
24280
24272
  }
24281
24273
  else {
24282
24274
  this._showLayer(this.layers, 0);
@@ -24341,7 +24333,7 @@ class WidgetShare extends WidgetBase {
24341
24333
  }
24342
24334
  this._statEventShare(isSuccess, null);
24343
24335
  if (isSuccess && this.withLayer) {
24344
- this._showLayer(this.layers, 1, true);
24336
+ this._showWidgetLinkedLayer(this.layers, 0, true);
24345
24337
  }
24346
24338
  if (this.disableTimer) {
24347
24339
  this.onWidgetComplete();