@tonconnect/ui 2.3.0-beta.0 → 2.3.0-beta.1

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/lib/index.mjs CHANGED
@@ -90,7 +90,7 @@ function createRoot(fn, detachedOwner) {
90
90
  owned: null,
91
91
  cleanups: null,
92
92
  context: null,
93
- owner: detachedOwner === void 0 ? owner : detachedOwner
93
+ owner: detachedOwner || owner
94
94
  }, updateFn = unowned ? fn : () => fn(() => untrack(() => cleanNode(root)));
95
95
  Owner = root;
96
96
  Listener = null;
@@ -180,9 +180,9 @@ function createResource(pSource, pFetcher, pOptions) {
180
180
  }
181
181
  function completeLoad(v, err) {
182
182
  runUpdates(() => {
183
- if (err === void 0)
183
+ if (!err)
184
184
  setValue(() => v);
185
- setState(err !== void 0 ? "errored" : "ready");
185
+ setState(err ? "errored" : "ready");
186
186
  setError(err);
187
187
  for (const c2 of contexts.keys())
188
188
  c2.decrement();
@@ -191,7 +191,7 @@ function createResource(pSource, pFetcher, pOptions) {
191
191
  }
192
192
  function read() {
193
193
  const c2 = SuspenseContext, v = value(), err = error();
194
- if (err !== void 0 && !pr)
194
+ if (err && !pr)
195
195
  throw err;
196
196
  if (Listener && !Listener.user && c2) {
197
197
  createComputed(() => {
@@ -271,8 +271,6 @@ function batch(fn) {
271
271
  return runUpdates(fn, false);
272
272
  }
273
273
  function untrack(fn) {
274
- if (Listener === null)
275
- return fn();
276
274
  const listener = Listener;
277
275
  Listener = null;
278
276
  try {
@@ -507,9 +505,8 @@ function runUpdates(fn, init) {
507
505
  completeUpdates(wait);
508
506
  return res;
509
507
  } catch (err) {
510
- if (!wait)
508
+ if (!Updates)
511
509
  Effects = null;
512
- Updates = null;
513
510
  handleError(err);
514
511
  }
515
512
  }
@@ -7308,18 +7305,18 @@ const NotificationsStyled = styled(Notifications)`
7308
7305
  margin-top: 20px;
7309
7306
  }
7310
7307
  `;
7311
- function getSide(placement) {
7312
- return placement.split("-")[0];
7313
- }
7314
7308
  function getAlignment(placement) {
7315
7309
  return placement.split("-")[1];
7316
7310
  }
7317
- function getMainAxisFromPlacement(placement) {
7318
- return ["top", "bottom"].includes(getSide(placement)) ? "x" : "y";
7319
- }
7320
7311
  function getLengthFromAxis(axis) {
7321
7312
  return axis === "y" ? "height" : "width";
7322
7313
  }
7314
+ function getSide(placement) {
7315
+ return placement.split("-")[0];
7316
+ }
7317
+ function getMainAxisFromPlacement(placement) {
7318
+ return ["top", "bottom"].includes(getSide(placement)) ? "x" : "y";
7319
+ }
7323
7320
  function computeCoordsFromPlacement(_ref, placement, rtl) {
7324
7321
  let {
7325
7322
  reference,
@@ -7559,14 +7556,14 @@ const max$1 = Math.max;
7559
7556
  function within(min$1$1, value, max$1$1) {
7560
7557
  return max$1(min$1$1, min$1(value, max$1$1));
7561
7558
  }
7562
- const hash$1 = {
7559
+ const oppositeSideMap = {
7563
7560
  left: "right",
7564
7561
  right: "left",
7565
7562
  bottom: "top",
7566
7563
  top: "bottom"
7567
7564
  };
7568
7565
  function getOppositePlacement(placement) {
7569
- return placement.replace(/left|right|bottom|top/g, (matched) => hash$1[matched]);
7566
+ return placement.replace(/left|right|bottom|top/g, (side) => oppositeSideMap[side]);
7570
7567
  }
7571
7568
  function getAlignmentSides(placement, rects, rtl) {
7572
7569
  if (rtl === void 0) {
@@ -7584,17 +7581,46 @@ function getAlignmentSides(placement, rects, rtl) {
7584
7581
  cross: getOppositePlacement(mainAlignmentSide)
7585
7582
  };
7586
7583
  }
7587
- const hash = {
7584
+ const oppositeAlignmentMap = {
7588
7585
  start: "end",
7589
7586
  end: "start"
7590
7587
  };
7591
7588
  function getOppositeAlignmentPlacement(placement) {
7592
- return placement.replace(/start|end/g, (matched) => hash[matched]);
7589
+ return placement.replace(/start|end/g, (alignment) => oppositeAlignmentMap[alignment]);
7593
7590
  }
7594
7591
  function getExpandedPlacements(placement) {
7595
7592
  const oppositePlacement = getOppositePlacement(placement);
7596
7593
  return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
7597
7594
  }
7595
+ function getSideList(side, isStart, rtl) {
7596
+ const lr = ["left", "right"];
7597
+ const rl = ["right", "left"];
7598
+ const tb = ["top", "bottom"];
7599
+ const bt = ["bottom", "top"];
7600
+ switch (side) {
7601
+ case "top":
7602
+ case "bottom":
7603
+ if (rtl)
7604
+ return isStart ? rl : lr;
7605
+ return isStart ? lr : rl;
7606
+ case "left":
7607
+ case "right":
7608
+ return isStart ? tb : bt;
7609
+ default:
7610
+ return [];
7611
+ }
7612
+ }
7613
+ function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
7614
+ const alignment = getAlignment(placement);
7615
+ let list = getSideList(getSide(placement), direction === "start", rtl);
7616
+ if (alignment) {
7617
+ list = list.map((side) => side + "-" + alignment);
7618
+ if (flipAlignment) {
7619
+ list = list.concat(list.map(getOppositeAlignmentPlacement));
7620
+ }
7621
+ }
7622
+ return list;
7623
+ }
7598
7624
  const flip = function(options) {
7599
7625
  if (options === void 0) {
7600
7626
  options = {};
@@ -7618,17 +7644,23 @@ const flip = function(options) {
7618
7644
  crossAxis: checkCrossAxis = true,
7619
7645
  fallbackPlacements: specifiedFallbackPlacements,
7620
7646
  fallbackStrategy = "bestFit",
7647
+ fallbackAxisSideDirection = "none",
7621
7648
  flipAlignment = true
7622
7649
  } = _a3, detectOverflowOptions = __objRest(_a3, [
7623
7650
  "mainAxis",
7624
7651
  "crossAxis",
7625
7652
  "fallbackPlacements",
7626
7653
  "fallbackStrategy",
7654
+ "fallbackAxisSideDirection",
7627
7655
  "flipAlignment"
7628
7656
  ]);
7629
7657
  const side = getSide(placement);
7630
- const isBasePlacement = side === initialPlacement;
7658
+ const isBasePlacement = getSide(initialPlacement) === initialPlacement;
7659
+ const rtl = yield platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating);
7631
7660
  const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
7661
+ if (!specifiedFallbackPlacements && fallbackAxisSideDirection !== "none") {
7662
+ fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
7663
+ }
7632
7664
  const placements = [initialPlacement, ...fallbackPlacements];
7633
7665
  const overflow = yield detectOverflow(middlewareArguments, detectOverflowOptions);
7634
7666
  const overflows = [];
@@ -7640,7 +7672,7 @@ const flip = function(options) {
7640
7672
  const {
7641
7673
  main,
7642
7674
  cross
7643
- } = getAlignmentSides(placement, rects, yield platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating));
7675
+ } = getAlignmentSides(placement, rects, rtl);
7644
7676
  overflows.push(overflow[main], overflow[cross]);
7645
7677
  }
7646
7678
  overflowsData = [...overflowsData, {
@@ -7648,8 +7680,8 @@ const flip = function(options) {
7648
7680
  overflows
7649
7681
  }];
7650
7682
  if (!overflows.every((side2) => side2 <= 0)) {
7651
- var _middlewareData$flip$, _middlewareData$flip2;
7652
- const nextIndex = ((_middlewareData$flip$ = (_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) != null ? _middlewareData$flip$ : 0) + 1;
7683
+ var _middlewareData$flip2;
7684
+ const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
7653
7685
  const nextPlacement = placements[nextIndex];
7654
7686
  if (nextPlacement) {
7655
7687
  return {
@@ -7808,7 +7840,7 @@ function isOverflowElement(element) {
7808
7840
  overflowY,
7809
7841
  display
7810
7842
  } = getComputedStyle$1(element);
7811
- return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX) && !["inline", "contents"].includes(display);
7843
+ return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !["inline", "contents"].includes(display);
7812
7844
  }
7813
7845
  function isTableElement(element) {
7814
7846
  return ["table", "td", "th"].includes(getNodeName(element));
@@ -7833,28 +7865,43 @@ function isLastTraversableNode(node) {
7833
7865
  const min = Math.min;
7834
7866
  const max = Math.max;
7835
7867
  const round = Math.round;
7868
+ function getCssDimensions(element) {
7869
+ const css = getComputedStyle$1(element);
7870
+ let width = parseFloat(css.width);
7871
+ let height = parseFloat(css.height);
7872
+ const offsetWidth = element.offsetWidth;
7873
+ const offsetHeight = element.offsetHeight;
7874
+ const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
7875
+ if (shouldFallback) {
7876
+ width = offsetWidth;
7877
+ height = offsetHeight;
7878
+ }
7879
+ return {
7880
+ width,
7881
+ height,
7882
+ fallback: shouldFallback
7883
+ };
7884
+ }
7885
+ function unwrapElement(element) {
7886
+ return !isElement(element) ? element.contextElement : element;
7887
+ }
7836
7888
  const FALLBACK_SCALE = {
7837
7889
  x: 1,
7838
7890
  y: 1
7839
7891
  };
7840
7892
  function getScale(element) {
7841
- const domElement = !isElement(element) && element.contextElement ? element.contextElement : isElement(element) ? element : null;
7842
- if (!domElement) {
7893
+ const domElement = unwrapElement(element);
7894
+ if (!isHTMLElement(domElement)) {
7843
7895
  return FALLBACK_SCALE;
7844
7896
  }
7845
7897
  const rect = domElement.getBoundingClientRect();
7846
- const css = getComputedStyle$1(domElement);
7847
- if (css.boxSizing !== "border-box") {
7848
- if (!isHTMLElement(domElement)) {
7849
- return FALLBACK_SCALE;
7850
- }
7851
- return {
7852
- x: domElement.offsetWidth > 0 ? round(rect.width) / domElement.offsetWidth || 1 : 1,
7853
- y: domElement.offsetHeight > 0 ? round(rect.height) / domElement.offsetHeight || 1 : 1
7854
- };
7855
- }
7856
- let x = rect.width / parseFloat(css.width);
7857
- let y = rect.height / parseFloat(css.height);
7898
+ const {
7899
+ width,
7900
+ height,
7901
+ fallback
7902
+ } = getCssDimensions(domElement);
7903
+ let x = (fallback ? round(rect.width) : rect.width) / width;
7904
+ let y = (fallback ? round(rect.height) : rect.height) / height;
7858
7905
  if (!x || !Number.isFinite(x)) {
7859
7906
  x = 1;
7860
7907
  }
@@ -7867,7 +7914,7 @@ function getScale(element) {
7867
7914
  };
7868
7915
  }
7869
7916
  function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
7870
- var _win$visualViewport$o, _win$visualViewport, _win$visualViewport$o2, _win$visualViewport2;
7917
+ var _win$visualViewport, _win$visualViewport2;
7871
7918
  if (includeScale === void 0) {
7872
7919
  includeScale = false;
7873
7920
  }
@@ -7875,6 +7922,7 @@ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetPar
7875
7922
  isFixedStrategy = false;
7876
7923
  }
7877
7924
  const clientRect = element.getBoundingClientRect();
7925
+ const domElement = unwrapElement(element);
7878
7926
  let scale = FALLBACK_SCALE;
7879
7927
  if (includeScale) {
7880
7928
  if (offsetParent) {
@@ -7885,12 +7933,31 @@ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetPar
7885
7933
  scale = getScale(element);
7886
7934
  }
7887
7935
  }
7888
- const win = isElement(element) ? getWindow(element) : window;
7936
+ const win = domElement ? getWindow(domElement) : window;
7889
7937
  const addVisualOffsets = !isLayoutViewport() && isFixedStrategy;
7890
- const x = (clientRect.left + (addVisualOffsets ? (_win$visualViewport$o = (_win$visualViewport = win.visualViewport) == null ? void 0 : _win$visualViewport.offsetLeft) != null ? _win$visualViewport$o : 0 : 0)) / scale.x;
7891
- const y = (clientRect.top + (addVisualOffsets ? (_win$visualViewport$o2 = (_win$visualViewport2 = win.visualViewport) == null ? void 0 : _win$visualViewport2.offsetTop) != null ? _win$visualViewport$o2 : 0 : 0)) / scale.y;
7892
- const width = clientRect.width / scale.x;
7893
- const height = clientRect.height / scale.y;
7938
+ let x = (clientRect.left + (addVisualOffsets ? ((_win$visualViewport = win.visualViewport) == null ? void 0 : _win$visualViewport.offsetLeft) || 0 : 0)) / scale.x;
7939
+ let y = (clientRect.top + (addVisualOffsets ? ((_win$visualViewport2 = win.visualViewport) == null ? void 0 : _win$visualViewport2.offsetTop) || 0 : 0)) / scale.y;
7940
+ let width = clientRect.width / scale.x;
7941
+ let height = clientRect.height / scale.y;
7942
+ if (domElement) {
7943
+ const win2 = getWindow(domElement);
7944
+ const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
7945
+ let currentIFrame = win2.frameElement;
7946
+ while (currentIFrame && offsetParent && offsetWin !== win2) {
7947
+ const iframeScale = getScale(currentIFrame);
7948
+ const iframeRect = currentIFrame.getBoundingClientRect();
7949
+ const css = getComputedStyle(currentIFrame);
7950
+ iframeRect.x += (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
7951
+ iframeRect.y += (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
7952
+ x *= iframeScale.x;
7953
+ y *= iframeScale.y;
7954
+ width *= iframeScale.x;
7955
+ height *= iframeScale.y;
7956
+ x += iframeRect.x;
7957
+ y += iframeRect.y;
7958
+ currentIFrame = getWindow(currentIFrame).frameElement;
7959
+ }
7960
+ }
7894
7961
  return {
7895
7962
  width,
7896
7963
  height,
@@ -7987,17 +8054,7 @@ function getOffsetParent(element) {
7987
8054
  return offsetParent || getContainingBlock(element) || window2;
7988
8055
  }
7989
8056
  function getDimensions(element) {
7990
- if (isHTMLElement(element)) {
7991
- return {
7992
- width: element.offsetWidth,
7993
- height: element.offsetHeight
7994
- };
7995
- }
7996
- const rect = getBoundingClientRect(element);
7997
- return {
7998
- width: rect.width,
7999
- height: rect.height
8000
- };
8057
+ return getCssDimensions(element);
8001
8058
  }
8002
8059
  function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
8003
8060
  let {
@@ -12448,7 +12505,7 @@ class TonConnectUITracker {
12448
12505
  }
12449
12506
  }
12450
12507
  }
12451
- const tonConnectUiVersion = "2.3.0-beta.0";
12508
+ const tonConnectUiVersion = "2.3.0-beta.1";
12452
12509
  class TonConnectUI {
12453
12510
  constructor(options) {
12454
12511
  __publicField(this, "walletInfoStorage", new WalletInfoStorage());