@schematichq/schematic-components 0.6.2 → 0.6.4

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
 
@@ -3946,6 +3946,7 @@ var VISIBLE_ENTITLEMENT_COUNT = 4;
3946
3946
  var MAX_VISIBLE_INVOICE_COUNT = 12;
3947
3947
  var DEBOUNCE_TIMEOUT = 250;
3948
3948
  var DEFAULT_CURRENCY = "USD";
3949
+ var MAXIMUM_SIGNIFICANT_DIGITS = 6;
3949
3950
 
3950
3951
  // src/hooks/useAvailablePlans.ts
3951
3952
  var import_react10 = require("react");
@@ -12249,8 +12250,7 @@ var en_default = {
12249
12250
  "Current plan": "Current plan",
12250
12251
  "Current usage exceeds the limit of this plan.": "Current usage exceeds the limit of this plan.",
12251
12252
  "Currently using": "Currently using {{quantity}} {{unit}}",
12252
- "Custom Plan Price": "Custom price",
12253
- "Custom Plan CTA": "Talk to support",
12253
+ "Custom price": "Custom price",
12254
12254
  Discount: "Discount",
12255
12255
  "Due today": "Due today",
12256
12256
  "Edit payment method": "Edit payment method",
@@ -12306,6 +12306,7 @@ var en_default = {
12306
12306
  "Subscribe and close": "Subscribe and close",
12307
12307
  Subscription: "Subscription",
12308
12308
  "Subscription canceled": "Subscription canceled",
12309
+ "Talk to support": "Talk to support",
12309
12310
  Trial: "Trial",
12310
12311
  "Trial ends in": "Trial ends in {{days}} days",
12311
12312
  "Trial plan": "Try free for {{days}} days",
@@ -13106,7 +13107,7 @@ var EmbedProvider = ({
13106
13107
  (0, import_react11.useEffect)(() => {
13107
13108
  if (accessToken) {
13108
13109
  const { headers = {} } = apiConfig ?? {};
13109
- headers["X-Schematic-Components-Version"] = "0.6.2";
13110
+ headers["X-Schematic-Components-Version"] = "0.6.4";
13110
13111
  headers["X-Schematic-Session-ID"] = sessionIdRef.current;
13111
13112
  const config = new Configuration({
13112
13113
  ...apiConfig,
@@ -13321,17 +13322,21 @@ function formatCurrency(amount, currency) {
13321
13322
  return `$${formatted}${symbol}`;
13322
13323
  };
13323
13324
  if (dollars >= 1e6) {
13324
- return formatValue(dollars / 1e6, "M");
13325
- } else if (dollars >= 1e3) {
13325
+ formatValue(dollars / 1e6, "M");
13326
+ }
13327
+ if (dollars >= 1e3) {
13326
13328
  return formatValue(dollars / 1e3, "k");
13327
- } else {
13328
- return new Intl.NumberFormat("en-US", {
13329
- style: "currency",
13330
- currency: resolvedCurrency,
13331
- minimumSignificantDigits: 1,
13332
- maximumSignificantDigits: 4
13333
- }).format(dollars);
13334
13329
  }
13330
+ const hasManySignificantDigits = /[1-9]/.test(
13331
+ (amount % 1).toFixed(MAXIMUM_SIGNIFICANT_DIGITS)
13332
+ );
13333
+ return new Intl.NumberFormat("en-US", {
13334
+ style: "currency",
13335
+ currency: resolvedCurrency,
13336
+ ...hasManySignificantDigits && {
13337
+ minimumSignificantDigits: 1
13338
+ }
13339
+ }).format(dollars);
13335
13340
  } catch (error) {
13336
13341
  console.error("Error formatting currency", error);
13337
13342
  return new Intl.NumberFormat("en-US", {
@@ -14668,6 +14673,7 @@ var Container2 = dt(Box)`
14668
14673
  display: block;
14669
14674
  font-size: ${TEXT_BASE_SIZE}px;
14670
14675
  width: 100%;
14676
+ height: 100%;
14671
14677
 
14672
14678
  *,
14673
14679
  *::before,
@@ -14700,6 +14706,7 @@ var Root = (0, import_react22.forwardRef)(
14700
14706
  Root.displayName = "Root";
14701
14707
 
14702
14708
  // src/components/layout/viewport/Viewport.tsx
14709
+ var import_debounce2 = __toESM(require_debounce());
14703
14710
  var import_react30 = require("react");
14704
14711
  var import_react_dom2 = require("react-dom");
14705
14712
 
@@ -16145,12 +16152,19 @@ var AddOns = ({ addOns, toggle, isLoading, period }) => {
16145
16152
  $position: "absolute",
16146
16153
  $right: "1rem",
16147
16154
  $top: "1rem",
16148
- $fontSize: "0.75rem",
16149
- $color: hexToHSL(theme.primary).l > 50 ? "#000000" : "#FFFFFF",
16150
16155
  $backgroundColor: theme.primary,
16151
16156
  $borderRadius: "9999px",
16152
16157
  $padding: "0.125rem 0.85rem",
16153
- children: t2("Active")
16158
+ children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
16159
+ Text,
16160
+ {
16161
+ $font: theme.typography.text.fontFamily,
16162
+ $size: 0.75 * theme.typography.text.fontSize,
16163
+ $weight: theme.typography.text.fontWeight,
16164
+ $color: hexToHSL(theme.primary).l > 50 ? "#000000" : "#FFFFFF",
16165
+ children: t2("Active")
16166
+ }
16167
+ )
16154
16168
  }
16155
16169
  )
16156
16170
  ] }),
@@ -16619,6 +16633,7 @@ var Plan = ({
16619
16633
  (entitlement) => !!entitlement.priceBehavior
16620
16634
  );
16621
16635
  const isUsageBasedPlan = planPrice === 0 && hasUsageBasedEntitlements;
16636
+ const headerPriceFontStyle = plan.custom || isUsageBasedPlan ? theme.typography.heading3 : theme.typography.heading2;
16622
16637
  return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
16623
16638
  Flex,
16624
16639
  {
@@ -16672,11 +16687,11 @@ var Plan = ({
16672
16687
  /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
16673
16688
  Text,
16674
16689
  {
16675
- $font: theme.typography.heading2.fontFamily,
16676
- $size: theme.typography.heading2.fontSize,
16677
- $weight: theme.typography.heading2.fontWeight,
16678
- $color: theme.typography.heading2.color,
16679
- children: plan.custom ? plan.customPlanConfig?.priceText ? plan.customPlanConfig.priceText : t2("Custom Plan Price") : isUsageBasedPlan ? t2("Usage-based") : formatCurrency(planPrice ?? 0, planCurrency)
16690
+ $font: headerPriceFontStyle.fontFamily,
16691
+ $size: headerPriceFontStyle.fontSize,
16692
+ $weight: headerPriceFontStyle.fontWeight,
16693
+ $color: headerPriceFontStyle.color,
16694
+ children: plan.custom ? plan.customPlanConfig?.priceText ? plan.customPlanConfig.priceText : t2("Custom price") : isUsageBasedPlan ? t2("Usage-based") : formatCurrency(planPrice ?? 0, planCurrency)
16680
16695
  }
16681
16696
  ),
16682
16697
  !plan.custom && !isUsageBasedPlan && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
@@ -16699,12 +16714,19 @@ var Plan = ({
16699
16714
  $position: "absolute",
16700
16715
  $right: "1rem",
16701
16716
  $top: "1rem",
16702
- $fontSize: "0.75rem",
16703
- $color: hexToHSL(theme.primary).l > 50 ? "#000000" : "#FFFFFF",
16704
16717
  $backgroundColor: theme.primary,
16705
16718
  $borderRadius: "9999px",
16706
16719
  $padding: "0.125rem 0.85rem",
16707
- children: t2("Active")
16720
+ children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
16721
+ Text,
16722
+ {
16723
+ $font: theme.typography.text.fontFamily,
16724
+ $size: 0.75 * theme.typography.text.fontSize,
16725
+ $weight: theme.typography.text.fontWeight,
16726
+ $color: hexToHSL(theme.primary).l > 50 ? "#000000" : "#FFFFFF",
16727
+ children: t2("Active")
16728
+ }
16729
+ )
16708
16730
  }
16709
16731
  )
16710
16732
  ]
@@ -16946,7 +16968,7 @@ var Plan = ({
16946
16968
  {
16947
16969
  href: plan.customPlanConfig?.ctaWebSite ?? "#",
16948
16970
  target: "_blank",
16949
- children: plan.customPlanConfig?.ctaText ?? t2("Custom Plan CTA")
16971
+ children: plan.customPlanConfig?.ctaText ?? t2("Talk to support")
16950
16972
  }
16951
16973
  ) : !plan.valid ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
16952
16974
  Tooltip,
@@ -18219,16 +18241,19 @@ var Viewport = (0, import_react30.forwardRef)(
18219
18241
  const canCheckout = data.capabilities?.checkout ?? true;
18220
18242
  (0, import_react30.useLayoutEffect)(() => {
18221
18243
  const parent = portal || document.body;
18222
- setTop(
18223
- Math.abs(
18244
+ const setModalY = (0, import_debounce2.default)(() => {
18245
+ const value = Math.abs(
18224
18246
  (parent === document.body ? window.scrollY : parent.scrollTop) ?? 0
18225
- )
18226
- );
18247
+ );
18248
+ setTop(value);
18249
+ }, 250);
18227
18250
  parent.style.overflow = layout === "checkout" || layout === "unsubscribe" || layout === "payment" ? "hidden" : "";
18251
+ window.addEventListener("scroll", setModalY);
18228
18252
  return () => {
18253
+ window.removeEventListener("scroll", setModalY);
18229
18254
  parent.style.overflow = "";
18230
18255
  };
18231
- }, [layout, portal]);
18256
+ }, [portal, layout]);
18232
18257
  return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(import_jsx_runtime26.Fragment, { children: [
18233
18258
  /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(StyledViewport, { ref, ...props, children: [
18234
18259
  /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(RenderLayout, { children }),
@@ -18719,6 +18744,7 @@ var import_react34 = require("react");
18719
18744
  // src/components/elements/metered-features/styles.ts
18720
18745
  var Container4 = dt(Flex)`
18721
18746
  flex-direction: column;
18747
+ gap: 1rem;
18722
18748
 
18723
18749
  &:last-child {
18724
18750
  overflow: hidden;
@@ -18743,6 +18769,15 @@ var Container4 = dt(Flex)`
18743
18769
  `;
18744
18770
  }}
18745
18771
  }
18772
+
18773
+ ${({ theme }) => {
18774
+ return theme.sectionLayout === "separate" && lt`
18775
+ ${Element}:not(:is(${FussyChild})) {
18776
+ border-bottom-left-radius: 0;
18777
+ border-bottom-right-radius: 0;
18778
+ }
18779
+ `;
18780
+ }}
18746
18781
  `;
18747
18782
 
18748
18783
  // src/components/elements/metered-features/MeteredFeatures.tsx
@@ -18837,6 +18872,10 @@ var MeteredFeatures = (0, import_react34.forwardRef)(({ className, ...rest }, re
18837
18872
  $alignItems: "center",
18838
18873
  $padding: `${0.4375 * theme.card.padding / TEXT_BASE_SIZE}rem ${theme.card.padding / TEXT_BASE_SIZE}rem`,
18839
18874
  $backgroundColor: isLightBackground ? darken(theme.card.background, 0.05) : lighten(theme.card.background, 0.1),
18875
+ ...theme.sectionLayout === "separate" && {
18876
+ $borderBottomLeftRadius: `${theme.card.borderRadius / TEXT_BASE_SIZE}rem`,
18877
+ $borderBottomRightRadius: `${theme.card.borderRadius / TEXT_BASE_SIZE}rem`
18878
+ },
18840
18879
  children: [
18841
18880
  /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
18842
18881
  Text,
@@ -19695,6 +19734,7 @@ var PlanManager = (0, import_react38.forwardRef)(({ children, className, portal,
19695
19734
  const isTrialSubscription = billingSubscription?.status === "trialing";
19696
19735
  const willSubscriptionCancel = billingSubscription?.cancelAtPeriodEnd;
19697
19736
  const isUsageBasedPlan = currentPlan?.planPrice === 0 && usageBasedEntitlements.length > 0;
19737
+ const headerPriceFontStyle = isUsageBasedPlan ? theme.typography.heading3 : theme.typography[props.header.price.fontStyle];
19698
19738
  return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_jsx_runtime34.Fragment, { children: [
19699
19739
  isTrialSubscription && !willSubscriptionCancel ? /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
19700
19740
  Box,
@@ -19816,10 +19856,10 @@ var PlanManager = (0, import_react38.forwardRef)(({ children, className, portal,
19816
19856
  /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
19817
19857
  Text,
19818
19858
  {
19819
- $font: theme.typography[props.header.price.fontStyle].fontFamily,
19820
- $size: theme.typography[props.header.price.fontStyle].fontSize,
19821
- $weight: theme.typography[props.header.price.fontStyle].fontWeight,
19822
- $color: theme.typography[props.header.price.fontStyle].color,
19859
+ $font: headerPriceFontStyle.fontFamily,
19860
+ $size: headerPriceFontStyle.fontSize,
19861
+ $weight: headerPriceFontStyle.fontWeight,
19862
+ $color: headerPriceFontStyle.color,
19823
19863
  children: isUsageBasedPlan ? t2("Usage-based") : formatCurrency(
19824
19864
  currentPlan.planPrice,
19825
19865
  subscriptionCurrency
@@ -20186,6 +20226,7 @@ var PricingTable = (0, import_react39.forwardRef)(({ children, className, ...res
20186
20226
  (entitlement) => !!entitlement.priceBehavior
20187
20227
  );
20188
20228
  const isUsageBasedPlan = planPrice === 0 && hasUsageBasedEntitlements;
20229
+ const headerPriceFontStyle = plan.custom || isUsageBasedPlan ? theme.typography.heading3 : theme.typography[props.plans.name.fontStyle];
20189
20230
  return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
20190
20231
  Flex,
20191
20232
  {
@@ -20234,11 +20275,11 @@ var PricingTable = (0, import_react39.forwardRef)(({ children, className, ...res
20234
20275
  /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
20235
20276
  Text,
20236
20277
  {
20237
- $font: theme.typography[props.plans.name.fontStyle].fontFamily,
20238
- $size: theme.typography[props.plans.name.fontStyle].fontSize,
20239
- $weight: theme.typography[props.plans.name.fontStyle].fontWeight,
20240
- $color: theme.typography[props.plans.name.fontStyle].color,
20241
- children: plan.custom ? plan.customPlanConfig?.priceText ? plan.customPlanConfig.priceText : t2("Custom Plan Price") : isUsageBasedPlan ? t2("Usage-based") : formatCurrency(planPrice ?? 0, planCurrency)
20278
+ $font: headerPriceFontStyle.fontFamily,
20279
+ $size: headerPriceFontStyle.fontSize,
20280
+ $weight: headerPriceFontStyle.fontWeight,
20281
+ $color: headerPriceFontStyle.color,
20282
+ children: plan.custom ? plan.customPlanConfig?.priceText ? plan.customPlanConfig.priceText : t2("Custom price") : isUsageBasedPlan ? t2("Usage-based") : formatCurrency(planPrice ?? 0, planCurrency)
20242
20283
  }
20243
20284
  ),
20244
20285
  !plan.custom && !isUsageBasedPlan && /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
@@ -20261,12 +20302,19 @@ var PricingTable = (0, import_react39.forwardRef)(({ children, className, ...res
20261
20302
  $position: "absolute",
20262
20303
  $right: "1rem",
20263
20304
  $top: "1rem",
20264
- $fontSize: "0.75rem",
20265
- $color: hexToHSL(theme.primary).l > 50 ? "#000000" : "#FFFFFF",
20266
20305
  $backgroundColor: theme.primary,
20267
20306
  $borderRadius: "9999px",
20268
20307
  $padding: "0.125rem 0.85rem",
20269
- children: trialEndDays ? t2("Trial ends in", { days: trialEndDays }) : t2("Active")
20308
+ children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
20309
+ Text,
20310
+ {
20311
+ $font: theme.typography.text.fontFamily,
20312
+ $size: 0.75 * theme.typography.text.fontSize,
20313
+ $weight: theme.typography.text.fontWeight,
20314
+ $color: hexToHSL(theme.primary).l > 50 ? "#000000" : "#FFFFFF",
20315
+ children: trialEndDays ? t2("Trial ends in", { days: trialEndDays }) : t2("Active")
20316
+ }
20317
+ )
20270
20318
  }
20271
20319
  )
20272
20320
  ]
@@ -20523,7 +20571,7 @@ var PricingTable = (0, import_react39.forwardRef)(({ children, className, ...res
20523
20571
  {
20524
20572
  href: plan.customPlanConfig?.ctaWebSite ?? "#",
20525
20573
  target: "_blank",
20526
- children: plan.customPlanConfig?.ctaText ?? t2("Custom Plan CTA")
20574
+ children: plan.customPlanConfig?.ctaText ?? t2("Talk to support")
20527
20575
  }
20528
20576
  ) : !plan.valid ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
20529
20577
  Tooltip,
@@ -20641,12 +20689,19 @@ var PricingTable = (0, import_react39.forwardRef)(({ children, className, ...res
20641
20689
  $position: "absolute",
20642
20690
  $right: "1rem",
20643
20691
  $top: "1rem",
20644
- $fontSize: "0.75rem",
20645
- $color: hexToHSL(theme.primary).l > 50 ? "#000000" : "#FFFFFF",
20646
20692
  $backgroundColor: theme.primary,
20647
20693
  $borderRadius: "9999px",
20648
20694
  $padding: "0.125rem 0.85rem",
20649
- children: t2("Active")
20695
+ children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
20696
+ Text,
20697
+ {
20698
+ $font: theme.typography.text.fontFamily,
20699
+ $size: 0.75 * theme.typography.text.fontSize,
20700
+ $weight: theme.typography.text.fontWeight,
20701
+ $color: hexToHSL(theme.primary).l > 50 ? "#000000" : "#FFFFFF",
20702
+ children: t2("Active")
20703
+ }
20704
+ )
20650
20705
  }
20651
20706
  )
20652
20707
  ] }),
@@ -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
 
@@ -3896,6 +3896,7 @@ var VISIBLE_ENTITLEMENT_COUNT = 4;
3896
3896
  var MAX_VISIBLE_INVOICE_COUNT = 12;
3897
3897
  var DEBOUNCE_TIMEOUT = 250;
3898
3898
  var DEFAULT_CURRENCY = "USD";
3899
+ var MAXIMUM_SIGNIFICANT_DIGITS = 6;
3899
3900
 
3900
3901
  // src/hooks/useAvailablePlans.ts
3901
3902
  import { useCallback as useCallback2, useMemo as useMemo2 } from "react";
@@ -12199,8 +12200,7 @@ var en_default = {
12199
12200
  "Current plan": "Current plan",
12200
12201
  "Current usage exceeds the limit of this plan.": "Current usage exceeds the limit of this plan.",
12201
12202
  "Currently using": "Currently using {{quantity}} {{unit}}",
12202
- "Custom Plan Price": "Custom price",
12203
- "Custom Plan CTA": "Talk to support",
12203
+ "Custom price": "Custom price",
12204
12204
  Discount: "Discount",
12205
12205
  "Due today": "Due today",
12206
12206
  "Edit payment method": "Edit payment method",
@@ -12256,6 +12256,7 @@ var en_default = {
12256
12256
  "Subscribe and close": "Subscribe and close",
12257
12257
  Subscription: "Subscription",
12258
12258
  "Subscription canceled": "Subscription canceled",
12259
+ "Talk to support": "Talk to support",
12259
12260
  Trial: "Trial",
12260
12261
  "Trial ends in": "Trial ends in {{days}} days",
12261
12262
  "Trial plan": "Try free for {{days}} days",
@@ -13056,7 +13057,7 @@ var EmbedProvider = ({
13056
13057
  useEffect2(() => {
13057
13058
  if (accessToken) {
13058
13059
  const { headers = {} } = apiConfig ?? {};
13059
- headers["X-Schematic-Components-Version"] = "0.6.2";
13060
+ headers["X-Schematic-Components-Version"] = "0.6.4";
13060
13061
  headers["X-Schematic-Session-ID"] = sessionIdRef.current;
13061
13062
  const config = new Configuration({
13062
13063
  ...apiConfig,
@@ -13271,17 +13272,21 @@ function formatCurrency(amount, currency) {
13271
13272
  return `$${formatted}${symbol}`;
13272
13273
  };
13273
13274
  if (dollars >= 1e6) {
13274
- return formatValue(dollars / 1e6, "M");
13275
- } else if (dollars >= 1e3) {
13275
+ formatValue(dollars / 1e6, "M");
13276
+ }
13277
+ if (dollars >= 1e3) {
13276
13278
  return formatValue(dollars / 1e3, "k");
13277
- } else {
13278
- return new Intl.NumberFormat("en-US", {
13279
- style: "currency",
13280
- currency: resolvedCurrency,
13281
- minimumSignificantDigits: 1,
13282
- maximumSignificantDigits: 4
13283
- }).format(dollars);
13284
13279
  }
13280
+ const hasManySignificantDigits = /[1-9]/.test(
13281
+ (amount % 1).toFixed(MAXIMUM_SIGNIFICANT_DIGITS)
13282
+ );
13283
+ return new Intl.NumberFormat("en-US", {
13284
+ style: "currency",
13285
+ currency: resolvedCurrency,
13286
+ ...hasManySignificantDigits && {
13287
+ minimumSignificantDigits: 1
13288
+ }
13289
+ }).format(dollars);
13285
13290
  } catch (error) {
13286
13291
  console.error("Error formatting currency", error);
13287
13292
  return new Intl.NumberFormat("en-US", {
@@ -14618,6 +14623,7 @@ var Container2 = dt(Box)`
14618
14623
  display: block;
14619
14624
  font-size: ${TEXT_BASE_SIZE}px;
14620
14625
  width: 100%;
14626
+ height: 100%;
14621
14627
 
14622
14628
  *,
14623
14629
  *::before,
@@ -14650,6 +14656,7 @@ var Root = forwardRef5(
14650
14656
  Root.displayName = "Root";
14651
14657
 
14652
14658
  // src/components/layout/viewport/Viewport.tsx
14659
+ var import_debounce2 = __toESM(require_debounce());
14653
14660
  import { forwardRef as forwardRef6, useLayoutEffect as useLayoutEffect6, useState as useState11 } from "react";
14654
14661
  import { createPortal as createPortal2 } from "react-dom";
14655
14662
 
@@ -16105,12 +16112,19 @@ var AddOns = ({ addOns, toggle, isLoading, period }) => {
16105
16112
  $position: "absolute",
16106
16113
  $right: "1rem",
16107
16114
  $top: "1rem",
16108
- $fontSize: "0.75rem",
16109
- $color: hexToHSL(theme.primary).l > 50 ? "#000000" : "#FFFFFF",
16110
16115
  $backgroundColor: theme.primary,
16111
16116
  $borderRadius: "9999px",
16112
16117
  $padding: "0.125rem 0.85rem",
16113
- children: t2("Active")
16118
+ children: /* @__PURE__ */ jsx14(
16119
+ Text,
16120
+ {
16121
+ $font: theme.typography.text.fontFamily,
16122
+ $size: 0.75 * theme.typography.text.fontSize,
16123
+ $weight: theme.typography.text.fontWeight,
16124
+ $color: hexToHSL(theme.primary).l > 50 ? "#000000" : "#FFFFFF",
16125
+ children: t2("Active")
16126
+ }
16127
+ )
16114
16128
  }
16115
16129
  )
16116
16130
  ] }),
@@ -16579,6 +16593,7 @@ var Plan = ({
16579
16593
  (entitlement) => !!entitlement.priceBehavior
16580
16594
  );
16581
16595
  const isUsageBasedPlan = planPrice === 0 && hasUsageBasedEntitlements;
16596
+ const headerPriceFontStyle = plan.custom || isUsageBasedPlan ? theme.typography.heading3 : theme.typography.heading2;
16582
16597
  return /* @__PURE__ */ jsxs12(
16583
16598
  Flex,
16584
16599
  {
@@ -16632,11 +16647,11 @@ var Plan = ({
16632
16647
  /* @__PURE__ */ jsx17(
16633
16648
  Text,
16634
16649
  {
16635
- $font: theme.typography.heading2.fontFamily,
16636
- $size: theme.typography.heading2.fontSize,
16637
- $weight: theme.typography.heading2.fontWeight,
16638
- $color: theme.typography.heading2.color,
16639
- children: plan.custom ? plan.customPlanConfig?.priceText ? plan.customPlanConfig.priceText : t2("Custom Plan Price") : isUsageBasedPlan ? t2("Usage-based") : formatCurrency(planPrice ?? 0, planCurrency)
16650
+ $font: headerPriceFontStyle.fontFamily,
16651
+ $size: headerPriceFontStyle.fontSize,
16652
+ $weight: headerPriceFontStyle.fontWeight,
16653
+ $color: headerPriceFontStyle.color,
16654
+ children: plan.custom ? plan.customPlanConfig?.priceText ? plan.customPlanConfig.priceText : t2("Custom price") : isUsageBasedPlan ? t2("Usage-based") : formatCurrency(planPrice ?? 0, planCurrency)
16640
16655
  }
16641
16656
  ),
16642
16657
  !plan.custom && !isUsageBasedPlan && /* @__PURE__ */ jsxs12(
@@ -16659,12 +16674,19 @@ var Plan = ({
16659
16674
  $position: "absolute",
16660
16675
  $right: "1rem",
16661
16676
  $top: "1rem",
16662
- $fontSize: "0.75rem",
16663
- $color: hexToHSL(theme.primary).l > 50 ? "#000000" : "#FFFFFF",
16664
16677
  $backgroundColor: theme.primary,
16665
16678
  $borderRadius: "9999px",
16666
16679
  $padding: "0.125rem 0.85rem",
16667
- children: t2("Active")
16680
+ children: /* @__PURE__ */ jsx17(
16681
+ Text,
16682
+ {
16683
+ $font: theme.typography.text.fontFamily,
16684
+ $size: 0.75 * theme.typography.text.fontSize,
16685
+ $weight: theme.typography.text.fontWeight,
16686
+ $color: hexToHSL(theme.primary).l > 50 ? "#000000" : "#FFFFFF",
16687
+ children: t2("Active")
16688
+ }
16689
+ )
16668
16690
  }
16669
16691
  )
16670
16692
  ]
@@ -16906,7 +16928,7 @@ var Plan = ({
16906
16928
  {
16907
16929
  href: plan.customPlanConfig?.ctaWebSite ?? "#",
16908
16930
  target: "_blank",
16909
- children: plan.customPlanConfig?.ctaText ?? t2("Custom Plan CTA")
16931
+ children: plan.customPlanConfig?.ctaText ?? t2("Talk to support")
16910
16932
  }
16911
16933
  ) : !plan.valid ? /* @__PURE__ */ jsx17(
16912
16934
  Tooltip,
@@ -18183,16 +18205,19 @@ var Viewport = forwardRef6(
18183
18205
  const canCheckout = data.capabilities?.checkout ?? true;
18184
18206
  useLayoutEffect6(() => {
18185
18207
  const parent = portal || document.body;
18186
- setTop(
18187
- Math.abs(
18208
+ const setModalY = (0, import_debounce2.default)(() => {
18209
+ const value = Math.abs(
18188
18210
  (parent === document.body ? window.scrollY : parent.scrollTop) ?? 0
18189
- )
18190
- );
18211
+ );
18212
+ setTop(value);
18213
+ }, 250);
18191
18214
  parent.style.overflow = layout === "checkout" || layout === "unsubscribe" || layout === "payment" ? "hidden" : "";
18215
+ window.addEventListener("scroll", setModalY);
18192
18216
  return () => {
18217
+ window.removeEventListener("scroll", setModalY);
18193
18218
  parent.style.overflow = "";
18194
18219
  };
18195
- }, [layout, portal]);
18220
+ }, [portal, layout]);
18196
18221
  return /* @__PURE__ */ jsxs20(Fragment9, { children: [
18197
18222
  /* @__PURE__ */ jsxs20(StyledViewport, { ref, ...props, children: [
18198
18223
  /* @__PURE__ */ jsx26(RenderLayout, { children }),
@@ -18683,6 +18708,7 @@ import { forwardRef as forwardRef9, useMemo as useMemo10, useRef as useRef8 } fr
18683
18708
  // src/components/elements/metered-features/styles.ts
18684
18709
  var Container4 = dt(Flex)`
18685
18710
  flex-direction: column;
18711
+ gap: 1rem;
18686
18712
 
18687
18713
  &:last-child {
18688
18714
  overflow: hidden;
@@ -18707,6 +18733,15 @@ var Container4 = dt(Flex)`
18707
18733
  `;
18708
18734
  }}
18709
18735
  }
18736
+
18737
+ ${({ theme }) => {
18738
+ return theme.sectionLayout === "separate" && lt`
18739
+ ${Element}:not(:is(${FussyChild})) {
18740
+ border-bottom-left-radius: 0;
18741
+ border-bottom-right-radius: 0;
18742
+ }
18743
+ `;
18744
+ }}
18710
18745
  `;
18711
18746
 
18712
18747
  // src/components/elements/metered-features/MeteredFeatures.tsx
@@ -18801,6 +18836,10 @@ var MeteredFeatures = forwardRef9(({ className, ...rest }, ref) => {
18801
18836
  $alignItems: "center",
18802
18837
  $padding: `${0.4375 * theme.card.padding / TEXT_BASE_SIZE}rem ${theme.card.padding / TEXT_BASE_SIZE}rem`,
18803
18838
  $backgroundColor: isLightBackground ? darken(theme.card.background, 0.05) : lighten(theme.card.background, 0.1),
18839
+ ...theme.sectionLayout === "separate" && {
18840
+ $borderBottomLeftRadius: `${theme.card.borderRadius / TEXT_BASE_SIZE}rem`,
18841
+ $borderBottomRightRadius: `${theme.card.borderRadius / TEXT_BASE_SIZE}rem`
18842
+ },
18804
18843
  children: [
18805
18844
  /* @__PURE__ */ jsx30(
18806
18845
  Text,
@@ -19659,6 +19698,7 @@ var PlanManager = forwardRef11(({ children, className, portal, ...rest }, ref) =
19659
19698
  const isTrialSubscription = billingSubscription?.status === "trialing";
19660
19699
  const willSubscriptionCancel = billingSubscription?.cancelAtPeriodEnd;
19661
19700
  const isUsageBasedPlan = currentPlan?.planPrice === 0 && usageBasedEntitlements.length > 0;
19701
+ const headerPriceFontStyle = isUsageBasedPlan ? theme.typography.heading3 : theme.typography[props.header.price.fontStyle];
19662
19702
  return /* @__PURE__ */ jsxs27(Fragment11, { children: [
19663
19703
  isTrialSubscription && !willSubscriptionCancel ? /* @__PURE__ */ jsxs27(
19664
19704
  Box,
@@ -19780,10 +19820,10 @@ var PlanManager = forwardRef11(({ children, className, portal, ...rest }, ref) =
19780
19820
  /* @__PURE__ */ jsx34(
19781
19821
  Text,
19782
19822
  {
19783
- $font: theme.typography[props.header.price.fontStyle].fontFamily,
19784
- $size: theme.typography[props.header.price.fontStyle].fontSize,
19785
- $weight: theme.typography[props.header.price.fontStyle].fontWeight,
19786
- $color: theme.typography[props.header.price.fontStyle].color,
19823
+ $font: headerPriceFontStyle.fontFamily,
19824
+ $size: headerPriceFontStyle.fontSize,
19825
+ $weight: headerPriceFontStyle.fontWeight,
19826
+ $color: headerPriceFontStyle.color,
19787
19827
  children: isUsageBasedPlan ? t2("Usage-based") : formatCurrency(
19788
19828
  currentPlan.planPrice,
19789
19829
  subscriptionCurrency
@@ -20150,6 +20190,7 @@ var PricingTable = forwardRef12(({ children, className, ...rest }, ref) => {
20150
20190
  (entitlement) => !!entitlement.priceBehavior
20151
20191
  );
20152
20192
  const isUsageBasedPlan = planPrice === 0 && hasUsageBasedEntitlements;
20193
+ const headerPriceFontStyle = plan.custom || isUsageBasedPlan ? theme.typography.heading3 : theme.typography[props.plans.name.fontStyle];
20153
20194
  return /* @__PURE__ */ jsxs28(
20154
20195
  Flex,
20155
20196
  {
@@ -20198,11 +20239,11 @@ var PricingTable = forwardRef12(({ children, className, ...rest }, ref) => {
20198
20239
  /* @__PURE__ */ jsx35(
20199
20240
  Text,
20200
20241
  {
20201
- $font: theme.typography[props.plans.name.fontStyle].fontFamily,
20202
- $size: theme.typography[props.plans.name.fontStyle].fontSize,
20203
- $weight: theme.typography[props.plans.name.fontStyle].fontWeight,
20204
- $color: theme.typography[props.plans.name.fontStyle].color,
20205
- children: plan.custom ? plan.customPlanConfig?.priceText ? plan.customPlanConfig.priceText : t2("Custom Plan Price") : isUsageBasedPlan ? t2("Usage-based") : formatCurrency(planPrice ?? 0, planCurrency)
20242
+ $font: headerPriceFontStyle.fontFamily,
20243
+ $size: headerPriceFontStyle.fontSize,
20244
+ $weight: headerPriceFontStyle.fontWeight,
20245
+ $color: headerPriceFontStyle.color,
20246
+ children: plan.custom ? plan.customPlanConfig?.priceText ? plan.customPlanConfig.priceText : t2("Custom price") : isUsageBasedPlan ? t2("Usage-based") : formatCurrency(planPrice ?? 0, planCurrency)
20206
20247
  }
20207
20248
  ),
20208
20249
  !plan.custom && !isUsageBasedPlan && /* @__PURE__ */ jsxs28(
@@ -20225,12 +20266,19 @@ var PricingTable = forwardRef12(({ children, className, ...rest }, ref) => {
20225
20266
  $position: "absolute",
20226
20267
  $right: "1rem",
20227
20268
  $top: "1rem",
20228
- $fontSize: "0.75rem",
20229
- $color: hexToHSL(theme.primary).l > 50 ? "#000000" : "#FFFFFF",
20230
20269
  $backgroundColor: theme.primary,
20231
20270
  $borderRadius: "9999px",
20232
20271
  $padding: "0.125rem 0.85rem",
20233
- children: trialEndDays ? t2("Trial ends in", { days: trialEndDays }) : t2("Active")
20272
+ children: /* @__PURE__ */ jsx35(
20273
+ Text,
20274
+ {
20275
+ $font: theme.typography.text.fontFamily,
20276
+ $size: 0.75 * theme.typography.text.fontSize,
20277
+ $weight: theme.typography.text.fontWeight,
20278
+ $color: hexToHSL(theme.primary).l > 50 ? "#000000" : "#FFFFFF",
20279
+ children: trialEndDays ? t2("Trial ends in", { days: trialEndDays }) : t2("Active")
20280
+ }
20281
+ )
20234
20282
  }
20235
20283
  )
20236
20284
  ]
@@ -20487,7 +20535,7 @@ var PricingTable = forwardRef12(({ children, className, ...rest }, ref) => {
20487
20535
  {
20488
20536
  href: plan.customPlanConfig?.ctaWebSite ?? "#",
20489
20537
  target: "_blank",
20490
- children: plan.customPlanConfig?.ctaText ?? t2("Custom Plan CTA")
20538
+ children: plan.customPlanConfig?.ctaText ?? t2("Talk to support")
20491
20539
  }
20492
20540
  ) : !plan.valid ? /* @__PURE__ */ jsx35(
20493
20541
  Tooltip,
@@ -20605,12 +20653,19 @@ var PricingTable = forwardRef12(({ children, className, ...rest }, ref) => {
20605
20653
  $position: "absolute",
20606
20654
  $right: "1rem",
20607
20655
  $top: "1rem",
20608
- $fontSize: "0.75rem",
20609
- $color: hexToHSL(theme.primary).l > 50 ? "#000000" : "#FFFFFF",
20610
20656
  $backgroundColor: theme.primary,
20611
20657
  $borderRadius: "9999px",
20612
20658
  $padding: "0.125rem 0.85rem",
20613
- children: t2("Active")
20659
+ children: /* @__PURE__ */ jsx35(
20660
+ Text,
20661
+ {
20662
+ $font: theme.typography.text.fontFamily,
20663
+ $size: 0.75 * theme.typography.text.fontSize,
20664
+ $weight: theme.typography.text.fontWeight,
20665
+ $color: hexToHSL(theme.primary).l > 50 ? "#000000" : "#FFFFFF",
20666
+ children: t2("Active")
20667
+ }
20668
+ )
20614
20669
  }
20615
20670
  )
20616
20671
  ] }),
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.4",
4
4
  "main": "dist/schematic-components.cjs.js",
5
5
  "module": "dist/schematic-components.esm.js",
6
6
  "types": "dist/schematic-components.d.ts",