@schematichq/schematic-components 0.6.2 → 0.6.3

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.
@@ -2167,7 +2167,7 @@ var require_debounce = __commonJS({
2167
2167
  var FUNC_ERROR_TEXT = "Expected a function";
2168
2168
  var nativeMax = Math.max;
2169
2169
  var nativeMin = Math.min;
2170
- function debounce2(func, wait, options) {
2170
+ function debounce3(func, wait, options) {
2171
2171
  var lastArgs, lastThis, maxWait, result, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true;
2172
2172
  if (typeof func != "function") {
2173
2173
  throw new TypeError(FUNC_ERROR_TEXT);
@@ -2248,7 +2248,7 @@ var require_debounce = __commonJS({
2248
2248
  debounced.flush = flush;
2249
2249
  return debounced;
2250
2250
  }
2251
- module2.exports = debounce2;
2251
+ module2.exports = debounce3;
2252
2252
  }
2253
2253
  });
2254
2254
 
@@ -13106,7 +13106,7 @@ var EmbedProvider = ({
13106
13106
  (0, import_react11.useEffect)(() => {
13107
13107
  if (accessToken) {
13108
13108
  const { headers = {} } = apiConfig ?? {};
13109
- headers["X-Schematic-Components-Version"] = "0.6.2";
13109
+ headers["X-Schematic-Components-Version"] = "0.6.3";
13110
13110
  headers["X-Schematic-Session-ID"] = sessionIdRef.current;
13111
13111
  const config = new Configuration({
13112
13112
  ...apiConfig,
@@ -14668,6 +14668,7 @@ var Container2 = dt(Box)`
14668
14668
  display: block;
14669
14669
  font-size: ${TEXT_BASE_SIZE}px;
14670
14670
  width: 100%;
14671
+ height: 100%;
14671
14672
 
14672
14673
  *,
14673
14674
  *::before,
@@ -14700,6 +14701,7 @@ var Root = (0, import_react22.forwardRef)(
14700
14701
  Root.displayName = "Root";
14701
14702
 
14702
14703
  // src/components/layout/viewport/Viewport.tsx
14704
+ var import_debounce2 = __toESM(require_debounce());
14703
14705
  var import_react30 = require("react");
14704
14706
  var import_react_dom2 = require("react-dom");
14705
14707
 
@@ -18219,16 +18221,19 @@ var Viewport = (0, import_react30.forwardRef)(
18219
18221
  const canCheckout = data.capabilities?.checkout ?? true;
18220
18222
  (0, import_react30.useLayoutEffect)(() => {
18221
18223
  const parent = portal || document.body;
18222
- setTop(
18223
- Math.abs(
18224
+ const setModalY = (0, import_debounce2.default)(() => {
18225
+ const value = Math.abs(
18224
18226
  (parent === document.body ? window.scrollY : parent.scrollTop) ?? 0
18225
- )
18226
- );
18227
+ );
18228
+ setTop(value);
18229
+ }, 250);
18227
18230
  parent.style.overflow = layout === "checkout" || layout === "unsubscribe" || layout === "payment" ? "hidden" : "";
18231
+ window.addEventListener("scroll", setModalY);
18228
18232
  return () => {
18233
+ window.removeEventListener("scroll", setModalY);
18229
18234
  parent.style.overflow = "";
18230
18235
  };
18231
- }, [layout, portal]);
18236
+ }, [portal, layout]);
18232
18237
  return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(import_jsx_runtime26.Fragment, { children: [
18233
18238
  /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(StyledViewport, { ref, ...props, children: [
18234
18239
  /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(RenderLayout, { children }),
@@ -2167,7 +2167,7 @@ var require_debounce = __commonJS({
2167
2167
  var FUNC_ERROR_TEXT = "Expected a function";
2168
2168
  var nativeMax = Math.max;
2169
2169
  var nativeMin = Math.min;
2170
- function debounce2(func, wait, options) {
2170
+ function debounce3(func, wait, options) {
2171
2171
  var lastArgs, lastThis, maxWait, result, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true;
2172
2172
  if (typeof func != "function") {
2173
2173
  throw new TypeError(FUNC_ERROR_TEXT);
@@ -2248,7 +2248,7 @@ var require_debounce = __commonJS({
2248
2248
  debounced.flush = flush;
2249
2249
  return debounced;
2250
2250
  }
2251
- module.exports = debounce2;
2251
+ module.exports = debounce3;
2252
2252
  }
2253
2253
  });
2254
2254
 
@@ -13056,7 +13056,7 @@ var EmbedProvider = ({
13056
13056
  useEffect2(() => {
13057
13057
  if (accessToken) {
13058
13058
  const { headers = {} } = apiConfig ?? {};
13059
- headers["X-Schematic-Components-Version"] = "0.6.2";
13059
+ headers["X-Schematic-Components-Version"] = "0.6.3";
13060
13060
  headers["X-Schematic-Session-ID"] = sessionIdRef.current;
13061
13061
  const config = new Configuration({
13062
13062
  ...apiConfig,
@@ -14618,6 +14618,7 @@ var Container2 = dt(Box)`
14618
14618
  display: block;
14619
14619
  font-size: ${TEXT_BASE_SIZE}px;
14620
14620
  width: 100%;
14621
+ height: 100%;
14621
14622
 
14622
14623
  *,
14623
14624
  *::before,
@@ -14650,6 +14651,7 @@ var Root = forwardRef5(
14650
14651
  Root.displayName = "Root";
14651
14652
 
14652
14653
  // src/components/layout/viewport/Viewport.tsx
14654
+ var import_debounce2 = __toESM(require_debounce());
14653
14655
  import { forwardRef as forwardRef6, useLayoutEffect as useLayoutEffect6, useState as useState11 } from "react";
14654
14656
  import { createPortal as createPortal2 } from "react-dom";
14655
14657
 
@@ -18183,16 +18185,19 @@ var Viewport = forwardRef6(
18183
18185
  const canCheckout = data.capabilities?.checkout ?? true;
18184
18186
  useLayoutEffect6(() => {
18185
18187
  const parent = portal || document.body;
18186
- setTop(
18187
- Math.abs(
18188
+ const setModalY = (0, import_debounce2.default)(() => {
18189
+ const value = Math.abs(
18188
18190
  (parent === document.body ? window.scrollY : parent.scrollTop) ?? 0
18189
- )
18190
- );
18191
+ );
18192
+ setTop(value);
18193
+ }, 250);
18191
18194
  parent.style.overflow = layout === "checkout" || layout === "unsubscribe" || layout === "payment" ? "hidden" : "";
18195
+ window.addEventListener("scroll", setModalY);
18192
18196
  return () => {
18197
+ window.removeEventListener("scroll", setModalY);
18193
18198
  parent.style.overflow = "";
18194
18199
  };
18195
- }, [layout, portal]);
18200
+ }, [portal, layout]);
18196
18201
  return /* @__PURE__ */ jsxs20(Fragment9, { children: [
18197
18202
  /* @__PURE__ */ jsxs20(StyledViewport, { ref, ...props, children: [
18198
18203
  /* @__PURE__ */ jsx26(RenderLayout, { children }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@schematichq/schematic-components",
3
- "version": "0.6.2",
3
+ "version": "0.6.3",
4
4
  "main": "dist/schematic-components.cjs.js",
5
5
  "module": "dist/schematic-components.esm.js",
6
6
  "types": "dist/schematic-components.d.ts",