@betterstore/react 0.5.22 → 0.5.23

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.js CHANGED
@@ -26314,14 +26314,9 @@ function getWindowScrollBarX(element, rect) {
26314
26314
  return rect.left + leftScroll;
26315
26315
  }
26316
26316
 
26317
- function getHTMLOffset(documentElement, scroll, ignoreScrollbarX) {
26318
- if (ignoreScrollbarX === void 0) {
26319
- ignoreScrollbarX = false;
26320
- }
26317
+ function getHTMLOffset(documentElement, scroll) {
26321
26318
  const htmlRect = documentElement.getBoundingClientRect();
26322
- const x = htmlRect.left + scroll.scrollLeft - (ignoreScrollbarX ? 0 :
26323
- // RTL <body> scrollbar.
26324
- getWindowScrollBarX(documentElement, htmlRect));
26319
+ const x = htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect);
26325
26320
  const y = htmlRect.top + scroll.scrollTop;
26326
26321
  return {
26327
26322
  x,
@@ -26360,7 +26355,7 @@ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
26360
26355
  offsets.y = offsetRect.y + offsetParent.clientTop;
26361
26356
  }
26362
26357
  }
26363
- const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll, true) : createCoords(0);
26358
+ const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
26364
26359
  return {
26365
26360
  width: rect.width * scale.x,
26366
26361
  height: rect.height * scale.y,
@@ -26394,6 +26389,10 @@ function getDocumentRect(element) {
26394
26389
  };
26395
26390
  }
26396
26391
 
26392
+ // Safety check: ensure the scrollbar space is reasonable in case this
26393
+ // calculation is affected by unusual styles.
26394
+ // Most scrollbars leave 15-18px of space.
26395
+ const SCROLLBAR_MAX = 25;
26397
26396
  function getViewportRect(element, strategy) {
26398
26397
  const win = getWindow(element);
26399
26398
  const html = getDocumentElement(element);
@@ -26411,6 +26410,24 @@ function getViewportRect(element, strategy) {
26411
26410
  y = visualViewport.offsetTop;
26412
26411
  }
26413
26412
  }
26413
+ const windowScrollbarX = getWindowScrollBarX(html);
26414
+ // <html> `overflow: hidden` + `scrollbar-gutter: stable` reduces the
26415
+ // visual width of the <html> but this is not considered in the size
26416
+ // of `html.clientWidth`.
26417
+ if (windowScrollbarX <= 0) {
26418
+ const doc = html.ownerDocument;
26419
+ const body = doc.body;
26420
+ const bodyStyles = getComputedStyle(body);
26421
+ const bodyMarginInline = doc.compatMode === 'CSS1Compat' ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0;
26422
+ const clippingStableScrollbarWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline);
26423
+ if (clippingStableScrollbarWidth <= SCROLLBAR_MAX) {
26424
+ width -= clippingStableScrollbarWidth;
26425
+ }
26426
+ } else if (windowScrollbarX <= SCROLLBAR_MAX) {
26427
+ // If the <body> scrollbar is on the left, the width needs to be extended
26428
+ // by the scrollbar amount so there isn't extra space on the right.
26429
+ width += windowScrollbarX;
26430
+ }
26414
26431
  return {
26415
26432
  width,
26416
26433
  height,
package/dist/index.mjs CHANGED
@@ -26294,14 +26294,9 @@ function getWindowScrollBarX(element, rect) {
26294
26294
  return rect.left + leftScroll;
26295
26295
  }
26296
26296
 
26297
- function getHTMLOffset(documentElement, scroll, ignoreScrollbarX) {
26298
- if (ignoreScrollbarX === void 0) {
26299
- ignoreScrollbarX = false;
26300
- }
26297
+ function getHTMLOffset(documentElement, scroll) {
26301
26298
  const htmlRect = documentElement.getBoundingClientRect();
26302
- const x = htmlRect.left + scroll.scrollLeft - (ignoreScrollbarX ? 0 :
26303
- // RTL <body> scrollbar.
26304
- getWindowScrollBarX(documentElement, htmlRect));
26299
+ const x = htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect);
26305
26300
  const y = htmlRect.top + scroll.scrollTop;
26306
26301
  return {
26307
26302
  x,
@@ -26340,7 +26335,7 @@ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
26340
26335
  offsets.y = offsetRect.y + offsetParent.clientTop;
26341
26336
  }
26342
26337
  }
26343
- const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll, true) : createCoords(0);
26338
+ const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
26344
26339
  return {
26345
26340
  width: rect.width * scale.x,
26346
26341
  height: rect.height * scale.y,
@@ -26374,6 +26369,10 @@ function getDocumentRect(element) {
26374
26369
  };
26375
26370
  }
26376
26371
 
26372
+ // Safety check: ensure the scrollbar space is reasonable in case this
26373
+ // calculation is affected by unusual styles.
26374
+ // Most scrollbars leave 15-18px of space.
26375
+ const SCROLLBAR_MAX = 25;
26377
26376
  function getViewportRect(element, strategy) {
26378
26377
  const win = getWindow(element);
26379
26378
  const html = getDocumentElement(element);
@@ -26391,6 +26390,24 @@ function getViewportRect(element, strategy) {
26391
26390
  y = visualViewport.offsetTop;
26392
26391
  }
26393
26392
  }
26393
+ const windowScrollbarX = getWindowScrollBarX(html);
26394
+ // <html> `overflow: hidden` + `scrollbar-gutter: stable` reduces the
26395
+ // visual width of the <html> but this is not considered in the size
26396
+ // of `html.clientWidth`.
26397
+ if (windowScrollbarX <= 0) {
26398
+ const doc = html.ownerDocument;
26399
+ const body = doc.body;
26400
+ const bodyStyles = getComputedStyle(body);
26401
+ const bodyMarginInline = doc.compatMode === 'CSS1Compat' ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0;
26402
+ const clippingStableScrollbarWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline);
26403
+ if (clippingStableScrollbarWidth <= SCROLLBAR_MAX) {
26404
+ width -= clippingStableScrollbarWidth;
26405
+ }
26406
+ } else if (windowScrollbarX <= SCROLLBAR_MAX) {
26407
+ // If the <body> scrollbar is on the left, the width needs to be extended
26408
+ // by the scrollbar amount so there isn't extra space on the right.
26409
+ width += windowScrollbarX;
26410
+ }
26394
26411
  return {
26395
26412
  width,
26396
26413
  height,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@betterstore/react",
3
- "version": "0.5.22",
3
+ "version": "0.5.23",
4
4
  "private": false,
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -78,7 +78,7 @@
78
78
  "world_countries_lists": "^3.2.0",
79
79
  "zod": "^3.25.30",
80
80
  "zustand": "^5.0.5",
81
- "@betterstore/sdk": "0.5.22"
81
+ "@betterstore/sdk": "0.5.23"
82
82
  },
83
83
  "publishConfig": {
84
84
  "access": "public"