@plaidev/karte-action-sdk 1.1.268-29083162.f59ff16d → 1.1.268-29089806.0ded74d0

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.
@@ -17457,12 +17457,12 @@ function add_css$f(target) {
17457
17457
 
17458
17458
  function get_each_context$1(ctx, list, i) {
17459
17459
  const child_ctx = ctx.slice();
17460
- child_ctx[31] = list[i];
17461
- child_ctx[33] = i;
17460
+ child_ctx[33] = list[i];
17461
+ child_ctx[35] = i;
17462
17462
  return child_ctx;
17463
17463
  }
17464
17464
 
17465
- // (174:4) {#each indicators ?? [] as indicator, i}
17465
+ // (188:4) {#each indicators ?? [] as indicator, i}
17466
17466
  function create_each_block$1(ctx) {
17467
17467
  let button;
17468
17468
  let i_1;
@@ -17472,7 +17472,7 @@ function create_each_block$1(ctx) {
17472
17472
  let dispose;
17473
17473
 
17474
17474
  function click_handler() {
17475
- return /*click_handler*/ ctx[19](/*i*/ ctx[33]);
17475
+ return /*click_handler*/ ctx[21](/*i*/ ctx[35]);
17476
17476
  }
17477
17477
 
17478
17478
  return {
@@ -17495,7 +17495,7 @@ function create_each_block$1(ctx) {
17495
17495
  attr(i_1, "style", i_1_style_value = objToStyle({
17496
17496
  .../*indicatorItemStyle*/ ctx[3],
17497
17497
  ...{
17498
- background: /*indicator*/ ctx[31].isActive ? '#555555' : '#AAAAAA'
17498
+ background: /*indicator*/ ctx[33].isActive ? '#555555' : '#AAAAAA'
17499
17499
  }
17500
17500
  }));
17501
17501
 
@@ -17521,7 +17521,7 @@ function create_each_block$1(ctx) {
17521
17521
  if (dirty[0] & /*indicatorItemStyle, indicators*/ 136 && i_1_style_value !== (i_1_style_value = objToStyle({
17522
17522
  .../*indicatorItemStyle*/ ctx[3],
17523
17523
  ...{
17524
- background: /*indicator*/ ctx[31].isActive ? '#555555' : '#AAAAAA'
17524
+ background: /*indicator*/ ctx[33].isActive ? '#555555' : '#AAAAAA'
17525
17525
  }
17526
17526
  }))) {
17527
17527
  attr(i_1, "style", i_1_style_value);
@@ -17544,8 +17544,8 @@ function create_fragment$j(ctx) {
17544
17544
  let current;
17545
17545
  let mounted;
17546
17546
  let dispose;
17547
- const default_slot_template = /*#slots*/ ctx[17].default;
17548
- const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[16], null);
17547
+ const default_slot_template = /*#slots*/ ctx[19].default;
17548
+ const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[18], null);
17549
17549
  let each_value = /*indicators*/ ctx[7] ?? [];
17550
17550
  let each_blocks = [];
17551
17551
 
@@ -17607,7 +17607,7 @@ function create_fragment$j(ctx) {
17607
17607
  default_slot.m(ul, null);
17608
17608
  }
17609
17609
 
17610
- /*ul_binding*/ ctx[18](ul);
17610
+ /*ul_binding*/ ctx[20](ul);
17611
17611
  append_hydration(div1, t);
17612
17612
  append_hydration(div1, div0);
17613
17613
 
@@ -17628,15 +17628,15 @@ function create_fragment$j(ctx) {
17628
17628
  },
17629
17629
  p(ctx, dirty) {
17630
17630
  if (default_slot) {
17631
- if (default_slot.p && (!current || dirty[0] & /*$$scope*/ 65536)) {
17631
+ if (default_slot.p && (!current || dirty[0] & /*$$scope*/ 262144)) {
17632
17632
  update_slot_base(
17633
17633
  default_slot,
17634
17634
  default_slot_template,
17635
17635
  ctx,
17636
- /*$$scope*/ ctx[16],
17636
+ /*$$scope*/ ctx[18],
17637
17637
  !current
17638
- ? get_all_dirty_from_scope(/*$$scope*/ ctx[16])
17639
- : get_slot_changes(default_slot_template, /*$$scope*/ ctx[16], dirty, null),
17638
+ ? get_all_dirty_from_scope(/*$$scope*/ ctx[18])
17639
+ : get_slot_changes(default_slot_template, /*$$scope*/ ctx[18], dirty, null),
17640
17640
  null
17641
17641
  );
17642
17642
  }
@@ -17693,7 +17693,7 @@ function create_fragment$j(ctx) {
17693
17693
  d(detaching) {
17694
17694
  if (detaching) detach(div1);
17695
17695
  if (default_slot) default_slot.d(detaching);
17696
- /*ul_binding*/ ctx[18](null);
17696
+ /*ul_binding*/ ctx[20](null);
17697
17697
  destroy_each(each_blocks, detaching);
17698
17698
  mounted = false;
17699
17699
  run_all(dispose);
@@ -17705,6 +17705,7 @@ function instance$j($$self, $$props, $$invalidate) {
17705
17705
  let indicators;
17706
17706
  let itemWidthPercentage;
17707
17707
  let style;
17708
+ let baseContainerStyle;
17708
17709
  let containerStyle;
17709
17710
  let indicatorListStyle;
17710
17711
  let indicatorItemStyle;
@@ -17718,27 +17719,25 @@ function instance$j($$self, $$props, $$invalidate) {
17718
17719
  let isDragging = false;
17719
17720
  let startX = 0;
17720
17721
  let movedX = null;
17721
- let childCount = slotElement?.children?.length ?? 0;
17722
-
17723
- const calcTransformX = (index, itemCount, _movedX) => {
17724
- if (index === 0) return undefined;
17725
-
17726
- const movingX = (() => {
17727
- let result = 0;
17728
- const itemWidth = itemWidthPercentage;
17729
- const itemMargin = (100 - itemWidthPercentage) / 2;
17730
-
17731
- const movingMap = [...Array(currentIndex + 1)].map((_, index) => {
17732
- if (index === 0) return 0;
17733
- if (index === 1 || index === itemCount - 1) return itemWidth - itemMargin;
17734
- return itemWidth;
17735
- });
17736
-
17737
- movingMap.forEach(value => result += value);
17738
- return result;
17739
- })();
17722
+ let childCount = 0;
17723
+ let transformX;
17724
+ console.log('transformX', transformX);
17725
+
17726
+ const computeTransformX = (index, itemCount, movedX, itemWidthPercentage, gap) => {
17727
+ if (index === 0) return;
17728
+ let result = 0;
17729
+ const itemMargin = (100 - itemWidthPercentage) / 2;
17730
+
17731
+ for (let i = 1; i <= index; i++) {
17732
+ if (i === 1 || i === itemCount - 1) {
17733
+ result += itemWidthPercentage - itemMargin;
17734
+ } else {
17735
+ result += itemWidthPercentage;
17736
+ }
17737
+ }
17740
17738
 
17741
- return `translateX(calc(-${movingX}% - ${(props.gap ?? 0) * index}px + ${(movedX ?? 0) * -1}px))`;
17739
+ const moved = movedX ? ` + ${-movedX}px` : '';
17740
+ return `translateX(calc(-${result}% - ${gap * index}px${moved}))`;
17742
17741
  };
17743
17742
 
17744
17743
  const handleClickIndicator = index => {
@@ -17754,6 +17753,8 @@ function instance$j($$self, $$props, $$invalidate) {
17754
17753
  };
17755
17754
 
17756
17755
  const toNext = () => {
17756
+ console.log('toNext');
17757
+
17757
17758
  if (currentIndex < childCount - 1) {
17758
17759
  $$invalidate(12, currentIndex = currentIndex + 1);
17759
17760
  } else if (props.loop) {
@@ -17829,28 +17830,36 @@ function instance$j($$self, $$props, $$invalidate) {
17829
17830
 
17830
17831
  document.removeEventListener('mousemove', handleMousemove);
17831
17832
  document.removeEventListener('mouseup', handleMouseup);
17833
+ document.removeEventListener('click', handleClick);
17832
17834
  };
17833
17835
 
17834
17836
  const handleMousedown = e => {
17835
17837
  startX = e.clientX;
17836
17838
  isDragging = false;
17837
17839
  document.addEventListener('mousemove', handleMousemove, { passive: true });
17838
- document.addEventListener('mouseup', handleMouseup, { passive: true });
17840
+ document.addEventListener('mouseup', handleMouseup, { passive: false });
17839
17841
  document.addEventListener('click', handleClick, { capture: true });
17840
17842
  };
17841
17843
 
17842
17844
  onMount$1(() => {
17843
17845
  setChildCount();
17844
- setInterval(setChildCount, 300);
17846
+
17847
+ // const childCountTimer = setInterval(setChildCount, 300);
17848
+ let autoSlideTimer;
17845
17849
 
17846
17850
  if (props.auto) {
17847
- setInterval(
17851
+ autoSlideTimer = setInterval(
17848
17852
  () => {
17849
17853
  toNext();
17850
17854
  },
17851
17855
  props.interval ?? 5000
17852
17856
  );
17853
17857
  }
17858
+
17859
+ return () => {
17860
+ // clearInterval(childCountTimer)
17861
+ if (autoSlideTimer) clearInterval(autoSlideTimer);
17862
+ };
17854
17863
  });
17855
17864
 
17856
17865
  function ul_binding($$value) {
@@ -17866,20 +17875,30 @@ function instance$j($$self, $$props, $$invalidate) {
17866
17875
  if ('layerId' in $$props) $$invalidate(0, layerId = $$props.layerId);
17867
17876
  if ('props' in $$props) $$invalidate(11, props = $$props.props);
17868
17877
  if ('overrideStyle' in $$props) $$invalidate(1, overrideStyle = $$props.overrideStyle);
17869
- if ('$$scope' in $$props) $$invalidate(16, $$scope = $$props.$$scope);
17878
+ if ('$$scope' in $$props) $$invalidate(18, $$scope = $$props.$$scope);
17870
17879
  };
17871
17880
 
17872
17881
  $$self.$$.update = () => {
17882
+ if ($$self.$$.dirty[0] & /*slotElement*/ 4) {
17883
+ if (slotElement) {
17884
+ $$invalidate(14, childCount = slotElement.children.length);
17885
+ }
17886
+ }
17887
+
17873
17888
  if ($$self.$$.dirty[0] & /*childCount, currentIndex*/ 20480) {
17874
17889
  $$invalidate(7, indicators = [...Array(childCount)].map((_, i) => ({ index: i, isActive: i === currentIndex })));
17875
17890
  }
17876
17891
 
17877
17892
  if ($$self.$$.dirty[0] & /*props*/ 2048) {
17878
- $$invalidate(15, itemWidthPercentage = props.itemWidthPercentage ?? 100);
17893
+ $$invalidate(17, itemWidthPercentage = props.itemWidthPercentage ?? 100);
17879
17894
  }
17880
17895
 
17881
- if ($$self.$$.dirty[0] & /*props, itemWidthPercentage, movedX, currentIndex, childCount*/ 63488) {
17882
- $$invalidate(5, containerStyle = objToStyle({
17896
+ if ($$self.$$.dirty[0] & /*currentIndex, childCount, movedX, itemWidthPercentage, props*/ 161792) {
17897
+ $$invalidate(15, transformX = computeTransformX(currentIndex, childCount, movedX, itemWidthPercentage, props.gap ?? 0));
17898
+ }
17899
+
17900
+ if ($$self.$$.dirty[0] & /*props, itemWidthPercentage, movedX*/ 141312) {
17901
+ $$invalidate(16, baseContainerStyle = {
17883
17902
  display: 'grid',
17884
17903
  // marginInline: `-${props.gap}px`,
17885
17904
  gap: `${props.gap}px`,
@@ -17888,8 +17907,14 @@ function instance$j($$self, $$props, $$invalidate) {
17888
17907
  gridAutoColumns: `minmax(${itemWidthPercentage}%, 1fr)`,
17889
17908
  flexShrink: 0,
17890
17909
  transition: movedX === null ? 'transform 0.5s' : undefined,
17891
- transform: calcTransformX(currentIndex, childCount),
17892
17910
  userSelect: 'none'
17911
+ });
17912
+ }
17913
+
17914
+ if ($$self.$$.dirty[0] & /*baseContainerStyle, transformX*/ 98304) {
17915
+ $$invalidate(5, containerStyle = objToStyle({
17916
+ ...baseContainerStyle,
17917
+ transform: transformX
17893
17918
  }));
17894
17919
  }
17895
17920
  };
@@ -17928,6 +17953,8 @@ function instance$j($$self, $$props, $$invalidate) {
17928
17953
  currentIndex,
17929
17954
  movedX,
17930
17955
  childCount,
17956
+ transformX,
17957
+ baseContainerStyle,
17931
17958
  itemWidthPercentage,
17932
17959
  $$scope,
17933
17960
  slots,
package/dist/index.es.js CHANGED
@@ -16150,12 +16150,12 @@ function add_css$f(target) {
16150
16150
 
16151
16151
  function get_each_context$1(ctx, list, i) {
16152
16152
  const child_ctx = ctx.slice();
16153
- child_ctx[31] = list[i];
16154
- child_ctx[33] = i;
16153
+ child_ctx[33] = list[i];
16154
+ child_ctx[35] = i;
16155
16155
  return child_ctx;
16156
16156
  }
16157
16157
 
16158
- // (174:4) {#each indicators ?? [] as indicator, i}
16158
+ // (188:4) {#each indicators ?? [] as indicator, i}
16159
16159
  function create_each_block$1(ctx) {
16160
16160
  let button;
16161
16161
  let i_1;
@@ -16165,7 +16165,7 @@ function create_each_block$1(ctx) {
16165
16165
  let dispose;
16166
16166
 
16167
16167
  function click_handler() {
16168
- return /*click_handler*/ ctx[19](/*i*/ ctx[33]);
16168
+ return /*click_handler*/ ctx[21](/*i*/ ctx[35]);
16169
16169
  }
16170
16170
 
16171
16171
  return {
@@ -16177,7 +16177,7 @@ function create_each_block$1(ctx) {
16177
16177
  attr(i_1, "style", i_1_style_value = objToStyle({
16178
16178
  .../*indicatorItemStyle*/ ctx[3],
16179
16179
  ...{
16180
- background: /*indicator*/ ctx[31].isActive ? '#555555' : '#AAAAAA'
16180
+ background: /*indicator*/ ctx[33].isActive ? '#555555' : '#AAAAAA'
16181
16181
  }
16182
16182
  }));
16183
16183
 
@@ -16203,7 +16203,7 @@ function create_each_block$1(ctx) {
16203
16203
  if (dirty[0] & /*indicatorItemStyle, indicators*/ 136 && i_1_style_value !== (i_1_style_value = objToStyle({
16204
16204
  .../*indicatorItemStyle*/ ctx[3],
16205
16205
  ...{
16206
- background: /*indicator*/ ctx[31].isActive ? '#555555' : '#AAAAAA'
16206
+ background: /*indicator*/ ctx[33].isActive ? '#555555' : '#AAAAAA'
16207
16207
  }
16208
16208
  }))) {
16209
16209
  attr(i_1, "style", i_1_style_value);
@@ -16226,8 +16226,8 @@ function create_fragment$j(ctx) {
16226
16226
  let current;
16227
16227
  let mounted;
16228
16228
  let dispose;
16229
- const default_slot_template = /*#slots*/ ctx[17].default;
16230
- const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[16], null);
16229
+ const default_slot_template = /*#slots*/ ctx[19].default;
16230
+ const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[18], null);
16231
16231
  let each_value = /*indicators*/ ctx[7] ?? [];
16232
16232
  let each_blocks = [];
16233
16233
 
@@ -16262,7 +16262,7 @@ function create_fragment$j(ctx) {
16262
16262
  default_slot.m(ul, null);
16263
16263
  }
16264
16264
 
16265
- /*ul_binding*/ ctx[18](ul);
16265
+ /*ul_binding*/ ctx[20](ul);
16266
16266
  append(div1, t);
16267
16267
  append(div1, div0);
16268
16268
 
@@ -16283,15 +16283,15 @@ function create_fragment$j(ctx) {
16283
16283
  },
16284
16284
  p(ctx, dirty) {
16285
16285
  if (default_slot) {
16286
- if (default_slot.p && (!current || dirty[0] & /*$$scope*/ 65536)) {
16286
+ if (default_slot.p && (!current || dirty[0] & /*$$scope*/ 262144)) {
16287
16287
  update_slot_base(
16288
16288
  default_slot,
16289
16289
  default_slot_template,
16290
16290
  ctx,
16291
- /*$$scope*/ ctx[16],
16291
+ /*$$scope*/ ctx[18],
16292
16292
  !current
16293
- ? get_all_dirty_from_scope(/*$$scope*/ ctx[16])
16294
- : get_slot_changes(default_slot_template, /*$$scope*/ ctx[16], dirty, null),
16293
+ ? get_all_dirty_from_scope(/*$$scope*/ ctx[18])
16294
+ : get_slot_changes(default_slot_template, /*$$scope*/ ctx[18], dirty, null),
16295
16295
  null
16296
16296
  );
16297
16297
  }
@@ -16348,7 +16348,7 @@ function create_fragment$j(ctx) {
16348
16348
  d(detaching) {
16349
16349
  if (detaching) detach(div1);
16350
16350
  if (default_slot) default_slot.d(detaching);
16351
- /*ul_binding*/ ctx[18](null);
16351
+ /*ul_binding*/ ctx[20](null);
16352
16352
  destroy_each(each_blocks, detaching);
16353
16353
  mounted = false;
16354
16354
  run_all(dispose);
@@ -16360,6 +16360,7 @@ function instance$j($$self, $$props, $$invalidate) {
16360
16360
  let indicators;
16361
16361
  let itemWidthPercentage;
16362
16362
  let style;
16363
+ let baseContainerStyle;
16363
16364
  let containerStyle;
16364
16365
  let indicatorListStyle;
16365
16366
  let indicatorItemStyle;
@@ -16373,27 +16374,25 @@ function instance$j($$self, $$props, $$invalidate) {
16373
16374
  let isDragging = false;
16374
16375
  let startX = 0;
16375
16376
  let movedX = null;
16376
- let childCount = slotElement?.children?.length ?? 0;
16377
-
16378
- const calcTransformX = (index, itemCount, _movedX) => {
16379
- if (index === 0) return undefined;
16380
-
16381
- const movingX = (() => {
16382
- let result = 0;
16383
- const itemWidth = itemWidthPercentage;
16384
- const itemMargin = (100 - itemWidthPercentage) / 2;
16385
-
16386
- const movingMap = [...Array(currentIndex + 1)].map((_, index) => {
16387
- if (index === 0) return 0;
16388
- if (index === 1 || index === itemCount - 1) return itemWidth - itemMargin;
16389
- return itemWidth;
16390
- });
16391
-
16392
- movingMap.forEach(value => result += value);
16393
- return result;
16394
- })();
16377
+ let childCount = 0;
16378
+ let transformX;
16379
+ console.log('transformX', transformX);
16380
+
16381
+ const computeTransformX = (index, itemCount, movedX, itemWidthPercentage, gap) => {
16382
+ if (index === 0) return;
16383
+ let result = 0;
16384
+ const itemMargin = (100 - itemWidthPercentage) / 2;
16385
+
16386
+ for (let i = 1; i <= index; i++) {
16387
+ if (i === 1 || i === itemCount - 1) {
16388
+ result += itemWidthPercentage - itemMargin;
16389
+ } else {
16390
+ result += itemWidthPercentage;
16391
+ }
16392
+ }
16395
16393
 
16396
- return `translateX(calc(-${movingX}% - ${(props.gap ?? 0) * index}px + ${(movedX ?? 0) * -1}px))`;
16394
+ const moved = movedX ? ` + ${-movedX}px` : '';
16395
+ return `translateX(calc(-${result}% - ${gap * index}px${moved}))`;
16397
16396
  };
16398
16397
 
16399
16398
  const handleClickIndicator = index => {
@@ -16409,6 +16408,8 @@ function instance$j($$self, $$props, $$invalidate) {
16409
16408
  };
16410
16409
 
16411
16410
  const toNext = () => {
16411
+ console.log('toNext');
16412
+
16412
16413
  if (currentIndex < childCount - 1) {
16413
16414
  $$invalidate(12, currentIndex = currentIndex + 1);
16414
16415
  } else if (props.loop) {
@@ -16484,28 +16485,36 @@ function instance$j($$self, $$props, $$invalidate) {
16484
16485
 
16485
16486
  document.removeEventListener('mousemove', handleMousemove);
16486
16487
  document.removeEventListener('mouseup', handleMouseup);
16488
+ document.removeEventListener('click', handleClick);
16487
16489
  };
16488
16490
 
16489
16491
  const handleMousedown = e => {
16490
16492
  startX = e.clientX;
16491
16493
  isDragging = false;
16492
16494
  document.addEventListener('mousemove', handleMousemove, { passive: true });
16493
- document.addEventListener('mouseup', handleMouseup, { passive: true });
16495
+ document.addEventListener('mouseup', handleMouseup, { passive: false });
16494
16496
  document.addEventListener('click', handleClick, { capture: true });
16495
16497
  };
16496
16498
 
16497
16499
  onMount$1(() => {
16498
16500
  setChildCount();
16499
- setInterval(setChildCount, 300);
16501
+
16502
+ // const childCountTimer = setInterval(setChildCount, 300);
16503
+ let autoSlideTimer;
16500
16504
 
16501
16505
  if (props.auto) {
16502
- setInterval(
16506
+ autoSlideTimer = setInterval(
16503
16507
  () => {
16504
16508
  toNext();
16505
16509
  },
16506
16510
  props.interval ?? 5000
16507
16511
  );
16508
16512
  }
16513
+
16514
+ return () => {
16515
+ // clearInterval(childCountTimer)
16516
+ if (autoSlideTimer) clearInterval(autoSlideTimer);
16517
+ };
16509
16518
  });
16510
16519
 
16511
16520
  function ul_binding($$value) {
@@ -16521,20 +16530,30 @@ function instance$j($$self, $$props, $$invalidate) {
16521
16530
  if ('layerId' in $$props) $$invalidate(0, layerId = $$props.layerId);
16522
16531
  if ('props' in $$props) $$invalidate(11, props = $$props.props);
16523
16532
  if ('overrideStyle' in $$props) $$invalidate(1, overrideStyle = $$props.overrideStyle);
16524
- if ('$$scope' in $$props) $$invalidate(16, $$scope = $$props.$$scope);
16533
+ if ('$$scope' in $$props) $$invalidate(18, $$scope = $$props.$$scope);
16525
16534
  };
16526
16535
 
16527
16536
  $$self.$$.update = () => {
16537
+ if ($$self.$$.dirty[0] & /*slotElement*/ 4) {
16538
+ if (slotElement) {
16539
+ $$invalidate(14, childCount = slotElement.children.length);
16540
+ }
16541
+ }
16542
+
16528
16543
  if ($$self.$$.dirty[0] & /*childCount, currentIndex*/ 20480) {
16529
16544
  $$invalidate(7, indicators = [...Array(childCount)].map((_, i) => ({ index: i, isActive: i === currentIndex })));
16530
16545
  }
16531
16546
 
16532
16547
  if ($$self.$$.dirty[0] & /*props*/ 2048) {
16533
- $$invalidate(15, itemWidthPercentage = props.itemWidthPercentage ?? 100);
16548
+ $$invalidate(17, itemWidthPercentage = props.itemWidthPercentage ?? 100);
16534
16549
  }
16535
16550
 
16536
- if ($$self.$$.dirty[0] & /*props, itemWidthPercentage, movedX, currentIndex, childCount*/ 63488) {
16537
- $$invalidate(5, containerStyle = objToStyle({
16551
+ if ($$self.$$.dirty[0] & /*currentIndex, childCount, movedX, itemWidthPercentage, props*/ 161792) {
16552
+ $$invalidate(15, transformX = computeTransformX(currentIndex, childCount, movedX, itemWidthPercentage, props.gap ?? 0));
16553
+ }
16554
+
16555
+ if ($$self.$$.dirty[0] & /*props, itemWidthPercentage, movedX*/ 141312) {
16556
+ $$invalidate(16, baseContainerStyle = {
16538
16557
  display: 'grid',
16539
16558
  // marginInline: `-${props.gap}px`,
16540
16559
  gap: `${props.gap}px`,
@@ -16543,8 +16562,14 @@ function instance$j($$self, $$props, $$invalidate) {
16543
16562
  gridAutoColumns: `minmax(${itemWidthPercentage}%, 1fr)`,
16544
16563
  flexShrink: 0,
16545
16564
  transition: movedX === null ? 'transform 0.5s' : undefined,
16546
- transform: calcTransformX(currentIndex, childCount),
16547
16565
  userSelect: 'none'
16566
+ });
16567
+ }
16568
+
16569
+ if ($$self.$$.dirty[0] & /*baseContainerStyle, transformX*/ 98304) {
16570
+ $$invalidate(5, containerStyle = objToStyle({
16571
+ ...baseContainerStyle,
16572
+ transform: transformX
16548
16573
  }));
16549
16574
  }
16550
16575
  };
@@ -16583,6 +16608,8 @@ function instance$j($$self, $$props, $$invalidate) {
16583
16608
  currentIndex,
16584
16609
  movedX,
16585
16610
  childCount,
16611
+ transformX,
16612
+ baseContainerStyle,
16586
16613
  itemWidthPercentage,
16587
16614
  $$scope,
16588
16615
  slots,
@@ -5478,6 +5478,7 @@ function Slider($$anchor, $$props) {
5478
5478
  const indicators = $.mutable_state();
5479
5479
  const itemWidthPercentage = $.mutable_state();
5480
5480
  const style = $.mutable_state();
5481
+ const baseContainerStyle = $.mutable_state();
5481
5482
  const containerStyle = $.mutable_state();
5482
5483
  const indicatorListStyle = $.mutable_state();
5483
5484
  const indicatorItemStyle = $.mutable_state();
@@ -5492,27 +5493,34 @@ function Slider($$anchor, $$props) {
5492
5493
  let isDragging = false;
5493
5494
  let startX = 0;
5494
5495
  let movedX = $.mutable_state(null);
5495
- let childCount = $.mutable_state($.get(slotElement)?.children?.length ?? 0);
5496
-
5497
- const calcTransformX = (index, itemCount, _movedX) => {
5498
- if (index === 0) return undefined;
5499
-
5500
- const movingX = (() => {
5501
- let result = 0;
5502
- const itemWidth = $.get(itemWidthPercentage);
5503
- const itemMargin = (100 - $.get(itemWidthPercentage)) / 2;
5504
-
5505
- const movingMap = [...Array($.get(currentIndex) + 1)].map((_, index) => {
5506
- if (index === 0) return 0;
5507
- if (index === 1 || index === itemCount - 1) return itemWidth - itemMargin;
5508
- return itemWidth;
5509
- });
5496
+ let childCount = $.mutable_state(0);
5497
+ let transformX = $.mutable_state();
5498
+
5499
+ console.log('transformX', $.get(transformX));
5500
+
5501
+ const computeTransformX = (
5502
+ index,
5503
+ itemCount,
5504
+ movedX,
5505
+ itemWidthPercentage,
5506
+ gap
5507
+ ) => {
5508
+ if (index === 0) return;
5509
+
5510
+ let result = 0;
5511
+ const itemMargin = (100 - itemWidthPercentage) / 2;
5512
+
5513
+ for (let i = 1; i <= index; i++) {
5514
+ if (i === 1 || i === itemCount - 1) {
5515
+ result += itemWidthPercentage - itemMargin;
5516
+ } else {
5517
+ result += itemWidthPercentage;
5518
+ }
5519
+ }
5510
5520
 
5511
- movingMap.forEach((value) => result += value);
5512
- return result;
5513
- })();
5521
+ const moved = movedX ? ` + ${-movedX}px` : '';
5514
5522
 
5515
- return `translateX(calc(-${movingX}% - ${(props().gap ?? 0) * index}px + ${($.get(movedX) ?? 0) * -1}px))`;
5523
+ return `translateX(calc(-${result}% - ${gap * index}px${moved}))`;
5516
5524
  };
5517
5525
 
5518
5526
  const handleClickIndicator = (index) => {
@@ -5528,6 +5536,8 @@ function Slider($$anchor, $$props) {
5528
5536
  };
5529
5537
 
5530
5538
  const toNext = () => {
5539
+ console.log('toNext');
5540
+
5531
5541
  if ($.get(currentIndex) < $.get(childCount) - 1) {
5532
5542
  $.set(currentIndex, $.get(currentIndex) + 1);
5533
5543
  } else if (props().loop) {
@@ -5603,28 +5613,42 @@ function Slider($$anchor, $$props) {
5603
5613
 
5604
5614
  document.removeEventListener('mousemove', handleMousemove);
5605
5615
  document.removeEventListener('mouseup', handleMouseup);
5616
+ document.removeEventListener('click', handleClick);
5606
5617
  };
5607
5618
 
5608
5619
  const handleMousedown = (e) => {
5609
5620
  startX = e.clientX;
5610
5621
  isDragging = false;
5611
5622
  document.addEventListener('mousemove', handleMousemove, { passive: true });
5612
- document.addEventListener('mouseup', handleMouseup, { passive: true });
5623
+ document.addEventListener('mouseup', handleMouseup, { passive: false });
5613
5624
  document.addEventListener('click', handleClick, { capture: true });
5614
5625
  };
5615
5626
 
5616
5627
  onMount$1(() => {
5617
5628
  setChildCount();
5618
- setInterval(setChildCount, 300);
5629
+
5630
+ // const childCountTimer = setInterval(setChildCount, 300);
5631
+ let autoSlideTimer;
5619
5632
 
5620
5633
  if (props().auto) {
5621
- setInterval(
5634
+ autoSlideTimer = setInterval(
5622
5635
  () => {
5623
5636
  toNext();
5624
5637
  },
5625
5638
  props().interval ?? 5000
5626
5639
  );
5627
5640
  }
5641
+
5642
+ return () => {
5643
+ // clearInterval(childCountTimer)
5644
+ if (autoSlideTimer) clearInterval(autoSlideTimer);
5645
+ };
5646
+ });
5647
+
5648
+ $.legacy_pre_effect(() => ($.get(slotElement)), () => {
5649
+ if ($.get(slotElement)) {
5650
+ $.set(childCount, $.get(slotElement).children.length);
5651
+ }
5628
5652
  });
5629
5653
 
5630
5654
  $.legacy_pre_effect(
@@ -5648,16 +5672,27 @@ function Slider($$anchor, $$props) {
5648
5672
  $.set(style, objToStyle({ overflow: 'hidden', width: '100%' }));
5649
5673
  });
5650
5674
 
5675
+ $.legacy_pre_effect(
5676
+ () => (
5677
+ $.get(currentIndex),
5678
+ $.get(childCount),
5679
+ $.get(movedX),
5680
+ $.get(itemWidthPercentage),
5681
+ $.deep_read_state(props())
5682
+ ),
5683
+ () => {
5684
+ $.set(transformX, computeTransformX($.get(currentIndex), $.get(childCount), $.get(movedX), $.get(itemWidthPercentage), props().gap ?? 0));
5685
+ }
5686
+ );
5687
+
5651
5688
  $.legacy_pre_effect(
5652
5689
  () => (
5653
5690
  $.deep_read_state(props()),
5654
5691
  $.get(itemWidthPercentage),
5655
- $.get(movedX),
5656
- $.get(currentIndex),
5657
- $.get(childCount)
5692
+ $.get(movedX)
5658
5693
  ),
5659
5694
  () => {
5660
- $.set(containerStyle, objToStyle({
5695
+ $.set(baseContainerStyle, {
5661
5696
  display: 'grid',
5662
5697
  // marginInline: `-${props.gap}px`,
5663
5698
  gap: `${props().gap}px`,
@@ -5666,8 +5701,20 @@ function Slider($$anchor, $$props) {
5666
5701
  gridAutoColumns: `minmax(${$.get(itemWidthPercentage)}%, 1fr)`,
5667
5702
  flexShrink: 0,
5668
5703
  transition: $.get(movedX) === null ? 'transform 0.5s' : undefined,
5669
- transform: calcTransformX($.get(currentIndex), $.get(childCount), $.get(movedX)),
5670
5704
  userSelect: 'none'
5705
+ });
5706
+ }
5707
+ );
5708
+
5709
+ $.legacy_pre_effect(
5710
+ () => (
5711
+ $.get(baseContainerStyle),
5712
+ $.get(transformX)
5713
+ ),
5714
+ () => {
5715
+ $.set(containerStyle, objToStyle({
5716
+ ...$.get(baseContainerStyle),
5717
+ transform: $.get(transformX)
5671
5718
  }));
5672
5719
  }
5673
5720
  );
@@ -5444,6 +5444,7 @@ function Slider($$anchor, $$props) {
5444
5444
  const indicators = $.mutable_state();
5445
5445
  const itemWidthPercentage = $.mutable_state();
5446
5446
  const style = $.mutable_state();
5447
+ const baseContainerStyle = $.mutable_state();
5447
5448
  const containerStyle = $.mutable_state();
5448
5449
  const indicatorListStyle = $.mutable_state();
5449
5450
  const indicatorItemStyle = $.mutable_state();
@@ -5458,27 +5459,34 @@ function Slider($$anchor, $$props) {
5458
5459
  let isDragging = false;
5459
5460
  let startX = 0;
5460
5461
  let movedX = $.mutable_state(null);
5461
- let childCount = $.mutable_state($.get(slotElement)?.children?.length ?? 0);
5462
-
5463
- const calcTransformX = (index, itemCount, _movedX) => {
5464
- if (index === 0) return undefined;
5465
-
5466
- const movingX = (() => {
5467
- let result = 0;
5468
- const itemWidth = $.get(itemWidthPercentage);
5469
- const itemMargin = (100 - $.get(itemWidthPercentage)) / 2;
5470
-
5471
- const movingMap = [...Array($.get(currentIndex) + 1)].map((_, index) => {
5472
- if (index === 0) return 0;
5473
- if (index === 1 || index === itemCount - 1) return itemWidth - itemMargin;
5474
- return itemWidth;
5475
- });
5462
+ let childCount = $.mutable_state(0);
5463
+ let transformX = $.mutable_state();
5464
+
5465
+ console.log('transformX', $.get(transformX));
5466
+
5467
+ const computeTransformX = (
5468
+ index,
5469
+ itemCount,
5470
+ movedX,
5471
+ itemWidthPercentage,
5472
+ gap
5473
+ ) => {
5474
+ if (index === 0) return;
5475
+
5476
+ let result = 0;
5477
+ const itemMargin = (100 - itemWidthPercentage) / 2;
5478
+
5479
+ for (let i = 1; i <= index; i++) {
5480
+ if (i === 1 || i === itemCount - 1) {
5481
+ result += itemWidthPercentage - itemMargin;
5482
+ } else {
5483
+ result += itemWidthPercentage;
5484
+ }
5485
+ }
5476
5486
 
5477
- movingMap.forEach((value) => result += value);
5478
- return result;
5479
- })();
5487
+ const moved = movedX ? ` + ${-movedX}px` : '';
5480
5488
 
5481
- return `translateX(calc(-${movingX}% - ${(props().gap ?? 0) * index}px + ${($.get(movedX) ?? 0) * -1}px))`;
5489
+ return `translateX(calc(-${result}% - ${gap * index}px${moved}))`;
5482
5490
  };
5483
5491
 
5484
5492
  const handleClickIndicator = (index) => {
@@ -5494,6 +5502,8 @@ function Slider($$anchor, $$props) {
5494
5502
  };
5495
5503
 
5496
5504
  const toNext = () => {
5505
+ console.log('toNext');
5506
+
5497
5507
  if ($.get(currentIndex) < $.get(childCount) - 1) {
5498
5508
  $.set(currentIndex, $.get(currentIndex) + 1);
5499
5509
  } else if (props().loop) {
@@ -5569,28 +5579,42 @@ function Slider($$anchor, $$props) {
5569
5579
 
5570
5580
  document.removeEventListener('mousemove', handleMousemove);
5571
5581
  document.removeEventListener('mouseup', handleMouseup);
5582
+ document.removeEventListener('click', handleClick);
5572
5583
  };
5573
5584
 
5574
5585
  const handleMousedown = (e) => {
5575
5586
  startX = e.clientX;
5576
5587
  isDragging = false;
5577
5588
  document.addEventListener('mousemove', handleMousemove, { passive: true });
5578
- document.addEventListener('mouseup', handleMouseup, { passive: true });
5589
+ document.addEventListener('mouseup', handleMouseup, { passive: false });
5579
5590
  document.addEventListener('click', handleClick, { capture: true });
5580
5591
  };
5581
5592
 
5582
5593
  onMount$1(() => {
5583
5594
  setChildCount();
5584
- setInterval(setChildCount, 300);
5595
+
5596
+ // const childCountTimer = setInterval(setChildCount, 300);
5597
+ let autoSlideTimer;
5585
5598
 
5586
5599
  if (props().auto) {
5587
- setInterval(
5600
+ autoSlideTimer = setInterval(
5588
5601
  () => {
5589
5602
  toNext();
5590
5603
  },
5591
5604
  props().interval ?? 5000
5592
5605
  );
5593
5606
  }
5607
+
5608
+ return () => {
5609
+ // clearInterval(childCountTimer)
5610
+ if (autoSlideTimer) clearInterval(autoSlideTimer);
5611
+ };
5612
+ });
5613
+
5614
+ $.legacy_pre_effect(() => ($.get(slotElement)), () => {
5615
+ if ($.get(slotElement)) {
5616
+ $.set(childCount, $.get(slotElement).children.length);
5617
+ }
5594
5618
  });
5595
5619
 
5596
5620
  $.legacy_pre_effect(
@@ -5614,16 +5638,27 @@ function Slider($$anchor, $$props) {
5614
5638
  $.set(style, objToStyle({ overflow: 'hidden', width: '100%' }));
5615
5639
  });
5616
5640
 
5641
+ $.legacy_pre_effect(
5642
+ () => (
5643
+ $.get(currentIndex),
5644
+ $.get(childCount),
5645
+ $.get(movedX),
5646
+ $.get(itemWidthPercentage),
5647
+ $.deep_read_state(props())
5648
+ ),
5649
+ () => {
5650
+ $.set(transformX, computeTransformX($.get(currentIndex), $.get(childCount), $.get(movedX), $.get(itemWidthPercentage), props().gap ?? 0));
5651
+ }
5652
+ );
5653
+
5617
5654
  $.legacy_pre_effect(
5618
5655
  () => (
5619
5656
  $.deep_read_state(props()),
5620
5657
  $.get(itemWidthPercentage),
5621
- $.get(movedX),
5622
- $.get(currentIndex),
5623
- $.get(childCount)
5658
+ $.get(movedX)
5624
5659
  ),
5625
5660
  () => {
5626
- $.set(containerStyle, objToStyle({
5661
+ $.set(baseContainerStyle, {
5627
5662
  display: 'grid',
5628
5663
  // marginInline: `-${props.gap}px`,
5629
5664
  gap: `${props().gap}px`,
@@ -5632,8 +5667,20 @@ function Slider($$anchor, $$props) {
5632
5667
  gridAutoColumns: `minmax(${$.get(itemWidthPercentage)}%, 1fr)`,
5633
5668
  flexShrink: 0,
5634
5669
  transition: $.get(movedX) === null ? 'transform 0.5s' : undefined,
5635
- transform: calcTransformX($.get(currentIndex), $.get(childCount), $.get(movedX)),
5636
5670
  userSelect: 'none'
5671
+ });
5672
+ }
5673
+ );
5674
+
5675
+ $.legacy_pre_effect(
5676
+ () => (
5677
+ $.get(baseContainerStyle),
5678
+ $.get(transformX)
5679
+ ),
5680
+ () => {
5681
+ $.set(containerStyle, objToStyle({
5682
+ ...$.get(baseContainerStyle),
5683
+ transform: $.get(transformX)
5637
5684
  }));
5638
5685
  }
5639
5686
  );
@@ -5444,6 +5444,7 @@ function Slider($$anchor, $$props) {
5444
5444
  const indicators = $.mutable_state();
5445
5445
  const itemWidthPercentage = $.mutable_state();
5446
5446
  const style = $.mutable_state();
5447
+ const baseContainerStyle = $.mutable_state();
5447
5448
  const containerStyle = $.mutable_state();
5448
5449
  const indicatorListStyle = $.mutable_state();
5449
5450
  const indicatorItemStyle = $.mutable_state();
@@ -5458,27 +5459,34 @@ function Slider($$anchor, $$props) {
5458
5459
  let isDragging = false;
5459
5460
  let startX = 0;
5460
5461
  let movedX = $.mutable_state(null);
5461
- let childCount = $.mutable_state($.get(slotElement)?.children?.length ?? 0);
5462
-
5463
- const calcTransformX = (index, itemCount, _movedX) => {
5464
- if (index === 0) return undefined;
5465
-
5466
- const movingX = (() => {
5467
- let result = 0;
5468
- const itemWidth = $.get(itemWidthPercentage);
5469
- const itemMargin = (100 - $.get(itemWidthPercentage)) / 2;
5470
-
5471
- const movingMap = [...Array($.get(currentIndex) + 1)].map((_, index) => {
5472
- if (index === 0) return 0;
5473
- if (index === 1 || index === itemCount - 1) return itemWidth - itemMargin;
5474
- return itemWidth;
5475
- });
5462
+ let childCount = $.mutable_state(0);
5463
+ let transformX = $.mutable_state();
5464
+
5465
+ console.log('transformX', $.get(transformX));
5466
+
5467
+ const computeTransformX = (
5468
+ index,
5469
+ itemCount,
5470
+ movedX,
5471
+ itemWidthPercentage,
5472
+ gap
5473
+ ) => {
5474
+ if (index === 0) return;
5475
+
5476
+ let result = 0;
5477
+ const itemMargin = (100 - itemWidthPercentage) / 2;
5478
+
5479
+ for (let i = 1; i <= index; i++) {
5480
+ if (i === 1 || i === itemCount - 1) {
5481
+ result += itemWidthPercentage - itemMargin;
5482
+ } else {
5483
+ result += itemWidthPercentage;
5484
+ }
5485
+ }
5476
5486
 
5477
- movingMap.forEach((value) => result += value);
5478
- return result;
5479
- })();
5487
+ const moved = movedX ? ` + ${-movedX}px` : '';
5480
5488
 
5481
- return `translateX(calc(-${movingX}% - ${(props().gap ?? 0) * index}px + ${($.get(movedX) ?? 0) * -1}px))`;
5489
+ return `translateX(calc(-${result}% - ${gap * index}px${moved}))`;
5482
5490
  };
5483
5491
 
5484
5492
  const handleClickIndicator = (index) => {
@@ -5494,6 +5502,8 @@ function Slider($$anchor, $$props) {
5494
5502
  };
5495
5503
 
5496
5504
  const toNext = () => {
5505
+ console.log('toNext');
5506
+
5497
5507
  if ($.get(currentIndex) < $.get(childCount) - 1) {
5498
5508
  $.set(currentIndex, $.get(currentIndex) + 1);
5499
5509
  } else if (props().loop) {
@@ -5569,28 +5579,42 @@ function Slider($$anchor, $$props) {
5569
5579
 
5570
5580
  document.removeEventListener('mousemove', handleMousemove);
5571
5581
  document.removeEventListener('mouseup', handleMouseup);
5582
+ document.removeEventListener('click', handleClick);
5572
5583
  };
5573
5584
 
5574
5585
  const handleMousedown = (e) => {
5575
5586
  startX = e.clientX;
5576
5587
  isDragging = false;
5577
5588
  document.addEventListener('mousemove', handleMousemove, { passive: true });
5578
- document.addEventListener('mouseup', handleMouseup, { passive: true });
5589
+ document.addEventListener('mouseup', handleMouseup, { passive: false });
5579
5590
  document.addEventListener('click', handleClick, { capture: true });
5580
5591
  };
5581
5592
 
5582
5593
  onMount$1(() => {
5583
5594
  setChildCount();
5584
- setInterval(setChildCount, 300);
5595
+
5596
+ // const childCountTimer = setInterval(setChildCount, 300);
5597
+ let autoSlideTimer;
5585
5598
 
5586
5599
  if (props().auto) {
5587
- setInterval(
5600
+ autoSlideTimer = setInterval(
5588
5601
  () => {
5589
5602
  toNext();
5590
5603
  },
5591
5604
  props().interval ?? 5000
5592
5605
  );
5593
5606
  }
5607
+
5608
+ return () => {
5609
+ // clearInterval(childCountTimer)
5610
+ if (autoSlideTimer) clearInterval(autoSlideTimer);
5611
+ };
5612
+ });
5613
+
5614
+ $.legacy_pre_effect(() => ($.get(slotElement)), () => {
5615
+ if ($.get(slotElement)) {
5616
+ $.set(childCount, $.get(slotElement).children.length);
5617
+ }
5594
5618
  });
5595
5619
 
5596
5620
  $.legacy_pre_effect(
@@ -5614,16 +5638,27 @@ function Slider($$anchor, $$props) {
5614
5638
  $.set(style, objToStyle({ overflow: 'hidden', width: '100%' }));
5615
5639
  });
5616
5640
 
5641
+ $.legacy_pre_effect(
5642
+ () => (
5643
+ $.get(currentIndex),
5644
+ $.get(childCount),
5645
+ $.get(movedX),
5646
+ $.get(itemWidthPercentage),
5647
+ $.deep_read_state(props())
5648
+ ),
5649
+ () => {
5650
+ $.set(transformX, computeTransformX($.get(currentIndex), $.get(childCount), $.get(movedX), $.get(itemWidthPercentage), props().gap ?? 0));
5651
+ }
5652
+ );
5653
+
5617
5654
  $.legacy_pre_effect(
5618
5655
  () => (
5619
5656
  $.deep_read_state(props()),
5620
5657
  $.get(itemWidthPercentage),
5621
- $.get(movedX),
5622
- $.get(currentIndex),
5623
- $.get(childCount)
5658
+ $.get(movedX)
5624
5659
  ),
5625
5660
  () => {
5626
- $.set(containerStyle, objToStyle({
5661
+ $.set(baseContainerStyle, {
5627
5662
  display: 'grid',
5628
5663
  // marginInline: `-${props.gap}px`,
5629
5664
  gap: `${props().gap}px`,
@@ -5632,8 +5667,20 @@ function Slider($$anchor, $$props) {
5632
5667
  gridAutoColumns: `minmax(${$.get(itemWidthPercentage)}%, 1fr)`,
5633
5668
  flexShrink: 0,
5634
5669
  transition: $.get(movedX) === null ? 'transform 0.5s' : undefined,
5635
- transform: calcTransformX($.get(currentIndex), $.get(childCount), $.get(movedX)),
5636
5670
  userSelect: 'none'
5671
+ });
5672
+ }
5673
+ );
5674
+
5675
+ $.legacy_pre_effect(
5676
+ () => (
5677
+ $.get(baseContainerStyle),
5678
+ $.get(transformX)
5679
+ ),
5680
+ () => {
5681
+ $.set(containerStyle, objToStyle({
5682
+ ...$.get(baseContainerStyle),
5683
+ transform: $.get(transformX)
5637
5684
  }));
5638
5685
  }
5639
5686
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plaidev/karte-action-sdk",
3
- "version": "1.1.268-29083162.f59ff16d",
3
+ "version": "1.1.268-29089806.0ded74d0",
4
4
  "author": "Plaid Inc.",
5
5
  "license": "Apache-2.0",
6
6
  "module": "./dist/index.es.js",