@schematichq/schematic-components 0.6.1 → 0.6.2

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.
@@ -3945,6 +3945,7 @@ var TEXT_BASE_SIZE = 16;
3945
3945
  var VISIBLE_ENTITLEMENT_COUNT = 4;
3946
3946
  var MAX_VISIBLE_INVOICE_COUNT = 12;
3947
3947
  var DEBOUNCE_TIMEOUT = 250;
3948
+ var DEFAULT_CURRENCY = "USD";
3948
3949
 
3949
3950
  // src/hooks/useAvailablePlans.ts
3950
3951
  var import_react10 = require("react");
@@ -13105,7 +13106,7 @@ var EmbedProvider = ({
13105
13106
  (0, import_react11.useEffect)(() => {
13106
13107
  if (accessToken) {
13107
13108
  const { headers = {} } = apiConfig ?? {};
13108
- headers["X-Schematic-Components-Version"] = "0.6.1";
13109
+ headers["X-Schematic-Components-Version"] = "0.6.2";
13109
13110
  headers["X-Schematic-Session-ID"] = sessionIdRef.current;
13110
13111
  const config = new Configuration({
13111
13112
  ...apiConfig,
@@ -13173,9 +13174,12 @@ var import_pluralize = __toESM(require_pluralize());
13173
13174
  var getFeatureName = (feature, count = 0) => {
13174
13175
  const shouldBePlural = count === 0 || count > 1;
13175
13176
  const { name, singularName, pluralName } = feature;
13176
- if (pluralName && shouldBePlural) return pluralName;
13177
- if (singularName)
13177
+ if (pluralName && shouldBePlural) {
13178
+ return pluralName;
13179
+ }
13180
+ if (singularName) {
13178
13181
  return shouldBePlural ? (0, import_pluralize.default)(singularName, count) : singularName;
13182
+ }
13179
13183
  return (0, import_pluralize.default)(name, count);
13180
13184
  };
13181
13185
 
@@ -13296,15 +13300,14 @@ function shortenPeriod(period) {
13296
13300
  }
13297
13301
 
13298
13302
  // src/utils/string.ts
13299
- var DEFAULT_CURRENCY = "USD";
13300
13303
  function camelToHyphen(str) {
13301
13304
  return str.replace(/([a-z][A-Z])/g, (g2) => `${g2[0]}-${g2[1].toLowerCase()}`);
13302
13305
  }
13303
13306
  function formatNumber(num) {
13304
13307
  return new Intl.NumberFormat("en-US").format(num);
13305
13308
  }
13306
- function formatCurrency(amount, currency = DEFAULT_CURRENCY) {
13307
- const nonEmptyCurrency = currency ? currency.toUpperCase() : DEFAULT_CURRENCY;
13309
+ function formatCurrency(amount, currency) {
13310
+ const resolvedCurrency = (currency || DEFAULT_CURRENCY).toUpperCase();
13308
13311
  try {
13309
13312
  const dollars = amount / 100;
13310
13313
  const formatValue = (value, symbol) => {
@@ -13312,8 +13315,8 @@ function formatCurrency(amount, currency = DEFAULT_CURRENCY) {
13312
13315
  if (formatted.endsWith(".0")) {
13313
13316
  formatted = formatted.slice(0, -2);
13314
13317
  }
13315
- if (nonEmptyCurrency !== DEFAULT_CURRENCY) {
13316
- return `${nonEmptyCurrency}${formatted}${symbol}`;
13318
+ if (resolvedCurrency !== DEFAULT_CURRENCY) {
13319
+ return `${resolvedCurrency}${formatted}${symbol}`;
13317
13320
  }
13318
13321
  return `$${formatted}${symbol}`;
13319
13322
  };
@@ -13324,14 +13327,16 @@ function formatCurrency(amount, currency = DEFAULT_CURRENCY) {
13324
13327
  } else {
13325
13328
  return new Intl.NumberFormat("en-US", {
13326
13329
  style: "currency",
13327
- currency: nonEmptyCurrency
13330
+ currency: resolvedCurrency,
13331
+ minimumSignificantDigits: 1,
13332
+ maximumSignificantDigits: 4
13328
13333
  }).format(dollars);
13329
13334
  }
13330
13335
  } catch (error) {
13331
13336
  console.error("Error formatting currency", error);
13332
13337
  return new Intl.NumberFormat("en-US", {
13333
13338
  style: "currency",
13334
- currency: nonEmptyCurrency
13339
+ currency: resolvedCurrency
13335
13340
  }).format(amount / 100);
13336
13341
  }
13337
13342
  }
@@ -14583,7 +14588,6 @@ var StyledCard = dt.div(({ theme }) => {
14583
14588
  const borderRadius = `${theme.card.borderRadius / TEXT_BASE_SIZE}rem`;
14584
14589
  return lt`
14585
14590
  position: relative;
14586
- overflow: hidden;
14587
14591
 
14588
14592
  ${theme.sectionLayout === "merged" ? `&:not(:has(${FussyChild}))` : `${Element}:not(:is(${FussyChild}))`} {
14589
14593
  color: ${theme.typography.text.color};
@@ -14661,7 +14665,9 @@ var import_react22 = require("react");
14661
14665
  var Container2 = dt(Box)`
14662
14666
  all: initial;
14663
14667
  box-sizing: border-box;
14668
+ display: block;
14664
14669
  font-size: ${TEXT_BASE_SIZE}px;
14670
+ width: 100%;
14665
14671
 
14666
14672
  *,
14667
14673
  *::before,
@@ -16609,6 +16615,10 @@ var Plan = ({
16609
16615
  const count = entitlementCounts[plan.id];
16610
16616
  const isExpanded = count.limit > VISIBLE_ENTITLEMENT_COUNT;
16611
16617
  const { price: planPrice, currency: planCurrency } = (period === "month" ? plan.monthlyPrice : period === "year" && plan.yearlyPrice) || {};
16618
+ const hasUsageBasedEntitlements = plan.entitlements.some(
16619
+ (entitlement) => !!entitlement.priceBehavior
16620
+ );
16621
+ const isUsageBasedPlan = planPrice === 0 && hasUsageBasedEntitlements;
16612
16622
  return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
16613
16623
  Flex,
16614
16624
  {
@@ -16666,10 +16676,10 @@ var Plan = ({
16666
16676
  $size: theme.typography.heading2.fontSize,
16667
16677
  $weight: theme.typography.heading2.fontWeight,
16668
16678
  $color: theme.typography.heading2.color,
16669
- children: plan.custom ? plan.customPlanConfig?.priceText ? plan.customPlanConfig.priceText : t2("Custom Plan Price") : formatCurrency(planPrice ?? 0, planCurrency)
16679
+ children: plan.custom ? plan.customPlanConfig?.priceText ? plan.customPlanConfig.priceText : t2("Custom Plan Price") : isUsageBasedPlan ? t2("Usage-based") : formatCurrency(planPrice ?? 0, planCurrency)
16670
16680
  }
16671
16681
  ),
16672
- !plan.custom && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
16682
+ !plan.custom && !isUsageBasedPlan && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
16673
16683
  Text,
16674
16684
  {
16675
16685
  $font: theme.typography.heading2.fontFamily,
@@ -18239,11 +18249,10 @@ Viewport.displayName = "Viewport";
18239
18249
  var import_react31 = require("react");
18240
18250
  var import_jsx_runtime27 = require("react/jsx-runtime");
18241
18251
  var Details = ({
18242
- details,
18243
18252
  shouldWrapChildren,
18253
+ featureUsage,
18244
18254
  ...props
18245
18255
  }) => {
18246
- const { featureUsage, usageData } = details;
18247
18256
  const {
18248
18257
  allocation,
18249
18258
  feature,
@@ -18252,7 +18261,7 @@ var Details = ({
18252
18261
  softLimit,
18253
18262
  monthlyUsageBasedPrice,
18254
18263
  yearlyUsageBasedPrice
18255
- } = featureUsage || {};
18264
+ } = featureUsage;
18256
18265
  const { t: t2 } = useTranslation();
18257
18266
  const theme = nt();
18258
18267
  const { data } = useEmbed();
@@ -18304,25 +18313,23 @@ var Details = ({
18304
18313
  if (!feature) {
18305
18314
  return;
18306
18315
  }
18307
- if (usageData) {
18308
- let acc;
18309
- if (priceBehavior === "pay_in_advance" && typeof data.company?.plan?.planPeriod === "string" && typeof price === "number") {
18310
- acc = `${formatCurrency(price, currency)}/${getFeatureName(feature, 1)}/${shortenPeriod(data.company.plan.planPeriod)}`;
18311
- } else if ((priceBehavior === "pay_as_you_go" || priceBehavior === "overage") && typeof usage === "number") {
18312
- acc = `${usage} ${getFeatureName(feature, usage)} ${t2("used")}`;
18313
- }
18314
- if (acc) {
18315
- if (priceBehavior === "pay_in_advance" && typeof price === "number" && typeof allocation === "number") {
18316
- acc += ` \u2022 ${formatCurrency(price * allocation, currency)}`;
18317
- } else if (priceBehavior === "pay_as_you_go" && typeof price === "number" && typeof usage === "number") {
18318
- acc += ` \u2022 ${formatCurrency(price * usage, currency)}`;
18319
- } else if (priceBehavior === "overage" && typeof price === "number" && typeof usage === "number" && typeof softLimit === "number") {
18320
- const cost = price * (usage - softLimit);
18321
- const period = feature.featureType === "event" && typeof data.company?.plan?.planPeriod === "string" ? `/${shortenPeriod(data.company.plan.planPeriod)}` : "";
18322
- acc += cost > 0 ? ` \u2022 ${t2("Overage")}: ${formatCurrency(cost)}${period}` : ` \u2022 ${`${formatCurrency(price)}/${getFeatureName(feature, 1)}`} ${t2("overage fee")}`;
18323
- }
18324
- return acc;
18316
+ let acc;
18317
+ if (priceBehavior === "pay_in_advance" && typeof data.company?.plan?.planPeriod === "string" && typeof price === "number") {
18318
+ acc = `${formatCurrency(price, currency)}/${getFeatureName(feature, 1)}/${shortenPeriod(data.company.plan.planPeriod)}`;
18319
+ } else if ((priceBehavior === "pay_as_you_go" || priceBehavior === "overage") && typeof usage === "number") {
18320
+ acc = `${usage} ${getFeatureName(feature, usage)} ${t2("used")}`;
18321
+ }
18322
+ if (acc) {
18323
+ if (priceBehavior === "pay_in_advance" && typeof price === "number" && typeof allocation === "number") {
18324
+ acc += ` \u2022 ${formatCurrency(price * allocation, currency)}`;
18325
+ } else if (priceBehavior === "pay_as_you_go" && typeof price === "number" && typeof usage === "number") {
18326
+ acc += ` \u2022 ${formatCurrency(price * usage, currency)}`;
18327
+ } else if (priceBehavior === "overage" && typeof price === "number" && typeof usage === "number" && typeof softLimit === "number") {
18328
+ const cost = price * (usage - softLimit);
18329
+ const period = feature.featureType === "event" && typeof data.company?.plan?.planPeriod === "string" ? `/${shortenPeriod(data.company.plan.planPeriod)}` : "";
18330
+ acc += cost > 0 ? ` \u2022 ${t2("Overage")}: ${formatCurrency(cost)}${period}` : ` \u2022 ${`${formatCurrency(price)}/${getFeatureName(feature, 1)}`} ${t2("overage fee")}`;
18325
18331
  }
18332
+ return acc;
18326
18333
  }
18327
18334
  if (typeof usage === "number") {
18328
18335
  return typeof allocation === "number" ? t2("usage.limited", {
@@ -18341,8 +18348,7 @@ var Details = ({
18341
18348
  price,
18342
18349
  currency,
18343
18350
  softLimit,
18344
- usage,
18345
- usageData
18351
+ usage
18346
18352
  ]);
18347
18353
  if (!text) {
18348
18354
  return null;
@@ -18420,38 +18426,28 @@ var IncludedFeatures = (0, import_react32.forwardRef)(({ className, ...rest }, r
18420
18426
  const shouldWrapChildren = useWrapChildren(elements.current);
18421
18427
  const isLightBackground = useIsLightBackground();
18422
18428
  const [showCount, setShowCount] = (0, import_react32.useState)(VISIBLE_ENTITLEMENT_COUNT);
18423
- const orderedFeatureUsage = props.visibleFeatures?.reduce(
18424
- (acc, id) => {
18425
- const mappedFeatureUsage = data.featureUsage?.features.find(
18426
- (usage) => usage.feature?.id === id
18427
- );
18428
- if (mappedFeatureUsage) {
18429
- acc.push(mappedFeatureUsage);
18430
- }
18431
- return acc;
18432
- },
18433
- []
18434
- );
18435
- const entitlements = (orderedFeatureUsage || data.featureUsage?.features || []).reduce(
18436
- (acc, usage) => {
18437
- const mappedUsageData = data.activeUsageBasedEntitlements.find(
18438
- (entitlement) => entitlement.featureId === usage.feature?.id
18439
- );
18440
- acc.push({
18441
- featureUsage: usage,
18442
- usageData: mappedUsageData
18443
- });
18444
- return acc;
18445
- },
18446
- []
18447
- );
18448
- const featureListSize = entitlements.length;
18429
+ const featureUsage = (0, import_react32.useMemo)(() => {
18430
+ const orderedFeatureUsage = props.visibleFeatures?.reduce(
18431
+ (acc, id) => {
18432
+ const mappedFeatureUsage = data.featureUsage?.features.find(
18433
+ (usage) => usage.feature?.id === id
18434
+ );
18435
+ if (mappedFeatureUsage) {
18436
+ acc.push(mappedFeatureUsage);
18437
+ }
18438
+ return acc;
18439
+ },
18440
+ []
18441
+ );
18442
+ return orderedFeatureUsage || data.featureUsage?.features || [];
18443
+ }, [props.visibleFeatures, data.featureUsage?.features]);
18444
+ const featureListSize = featureUsage.length;
18449
18445
  const handleToggleShowAll = () => {
18450
18446
  setShowCount(
18451
18447
  (prev2) => prev2 > VISIBLE_ENTITLEMENT_COUNT ? VISIBLE_ENTITLEMENT_COUNT : featureListSize
18452
18448
  );
18453
18449
  };
18454
- const shouldShowFeatures = entitlements.length > 0 || data.company?.plan || (data.company?.addOns ?? []).length > 0 || false;
18450
+ const shouldShowFeatures = featureUsage.length > 0 || data.company?.plan || (data.company?.addOns ?? []).length > 0 || false;
18455
18451
  if (!shouldShowFeatures) {
18456
18452
  return null;
18457
18453
  }
@@ -18476,8 +18472,8 @@ var IncludedFeatures = (0, import_react32.forwardRef)(({ className, ...rest }, r
18476
18472
  children: props.header.text
18477
18473
  }
18478
18474
  ) }),
18479
- entitlements.slice(0, showCount).map((entitlement, index) => {
18480
- const { entitlementExpirationDate, feature } = entitlement.featureUsage || {};
18475
+ featureUsage.slice(0, showCount).map((usage, index) => {
18476
+ const feature = usage.feature;
18481
18477
  const shouldShowDetails = feature?.name && (feature?.featureType === "event" || feature?.featureType === "trait");
18482
18478
  return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
18483
18479
  Flex,
@@ -18521,7 +18517,7 @@ var IncludedFeatures = (0, import_react32.forwardRef)(({ className, ...rest }, r
18521
18517
  children: feature.name
18522
18518
  }
18523
18519
  ),
18524
- props.entitlementExpiration.isVisible && entitlementExpirationDate && /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
18520
+ props.entitlementExpiration.isVisible && usage.entitlementExpirationDate && /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
18525
18521
  Text,
18526
18522
  {
18527
18523
  $font: theme.typography[props.entitlementExpiration.fontStyle].fontFamily,
@@ -18532,7 +18528,7 @@ var IncludedFeatures = (0, import_react32.forwardRef)(({ className, ...rest }, r
18532
18528
  children: [
18533
18529
  "Expires",
18534
18530
  " ",
18535
- toPrettyDate(entitlementExpirationDate, {
18531
+ toPrettyDate(usage.entitlementExpirationDate, {
18536
18532
  month: "short"
18537
18533
  })
18538
18534
  ]
@@ -18544,7 +18540,7 @@ var IncludedFeatures = (0, import_react32.forwardRef)(({ className, ...rest }, r
18544
18540
  shouldShowDetails && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
18545
18541
  Details,
18546
18542
  {
18547
- details: entitlement,
18543
+ featureUsage: usage,
18548
18544
  shouldWrapChildren,
18549
18545
  ...props
18550
18546
  }
@@ -18724,6 +18720,18 @@ var import_react34 = require("react");
18724
18720
  var Container4 = dt(Flex)`
18725
18721
  flex-direction: column;
18726
18722
 
18723
+ &:last-child {
18724
+ overflow: hidden;
18725
+
18726
+ ${({ theme }) => {
18727
+ const borderRadius = `${theme.card.borderRadius / TEXT_BASE_SIZE}rem`;
18728
+ return lt`
18729
+ border-bottom-left-radius: ${borderRadius};
18730
+ border-bottom-right-radius: ${borderRadius};
18731
+ `;
18732
+ }}
18733
+ }
18734
+
18727
18735
  &:not(:last-child) {
18728
18736
  ${({ theme }) => {
18729
18737
  const { l: l2 } = hexToHSL(theme.card.background);
@@ -18772,8 +18780,8 @@ var MeteredFeatures = (0, import_react34.forwardRef)(({ className, ...rest }, re
18772
18780
  const theme = nt();
18773
18781
  const { data, setLayout, setSelected } = useEmbed();
18774
18782
  const isLightBackground = useIsLightBackground();
18775
- const meteredFeatures = (0, import_react34.useMemo)(() => {
18776
- return (props.visibleFeatures ? props.visibleFeatures.reduce(
18783
+ const featureUsage = (0, import_react34.useMemo)(() => {
18784
+ const orderedFeatureUsage = props.visibleFeatures?.reduce(
18777
18785
  (acc, id) => {
18778
18786
  const mappedFeatureUsage = data.featureUsage?.features.find(
18779
18787
  (usage) => usage.feature?.id === id
@@ -18784,16 +18792,17 @@ var MeteredFeatures = (0, import_react34.forwardRef)(({ className, ...rest }, re
18784
18792
  return acc;
18785
18793
  },
18786
18794
  []
18787
- ) : data.featureUsage?.features || []).filter(
18795
+ );
18796
+ return (orderedFeatureUsage || data.featureUsage?.features || []).filter(
18788
18797
  (usage) => usage.feature?.featureType === "event" || usage.feature?.featureType === "trait"
18789
18798
  );
18790
18799
  }, [props.visibleFeatures, data.featureUsage?.features]);
18791
18800
  const planPeriod = data.company?.plan?.planPeriod;
18792
- const shouldShowFeatures = meteredFeatures.length > 0 || data.company?.plan || (data.company?.addOns ?? []).length > 0 || false;
18801
+ const shouldShowFeatures = featureUsage.length > 0 || data.company?.plan || (data.company?.addOns ?? []).length > 0 || false;
18793
18802
  if (!shouldShowFeatures) {
18794
18803
  return null;
18795
18804
  }
18796
- return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Container4, { ref, className, children: meteredFeatures.map(
18805
+ return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Container4, { ref, className, children: featureUsage.map(
18797
18806
  ({
18798
18807
  feature,
18799
18808
  priceBehavior,
@@ -18807,7 +18816,7 @@ var MeteredFeatures = (0, import_react34.forwardRef)(({ className, ...rest }, re
18807
18816
  const limit = softLimit ?? allocation ?? 0;
18808
18817
  const isOverage = priceBehavior === "overage" && typeof softLimit === "number" && typeof usage === "number" && usage > softLimit;
18809
18818
  const { price, currency } = (planPeriod === "month" ? monthlyUsageBasedPrice : planPeriod === "year" && yearlyUsageBasedPrice) || {};
18810
- const progressBar = props.isVisible && typeof usage === "number" && priceBehavior !== "pay_as_you_go" && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
18819
+ const progressBar = props.isVisible && typeof usage === "number" && limit > 0 && priceBehavior !== "pay_as_you_go" && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
18811
18820
  ProgressBar,
18812
18821
  {
18813
18822
  progress: (isOverage ? softLimit / usage : usage / limit) * 100,
@@ -19685,6 +19694,7 @@ var PlanManager = (0, import_react38.forwardRef)(({ children, className, portal,
19685
19694
  const subscriptionCurrency = billingSubscription?.currency;
19686
19695
  const isTrialSubscription = billingSubscription?.status === "trialing";
19687
19696
  const willSubscriptionCancel = billingSubscription?.cancelAtPeriodEnd;
19697
+ const isUsageBasedPlan = currentPlan?.planPrice === 0 && usageBasedEntitlements.length > 0;
19688
19698
  return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_jsx_runtime34.Fragment, { children: [
19689
19699
  isTrialSubscription && !willSubscriptionCancel ? /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
19690
19700
  Box,
@@ -19810,13 +19820,13 @@ var PlanManager = (0, import_react38.forwardRef)(({ children, className, portal,
19810
19820
  $size: theme.typography[props.header.price.fontStyle].fontSize,
19811
19821
  $weight: theme.typography[props.header.price.fontStyle].fontWeight,
19812
19822
  $color: theme.typography[props.header.price.fontStyle].color,
19813
- children: formatCurrency(
19823
+ children: isUsageBasedPlan ? t2("Usage-based") : formatCurrency(
19814
19824
  currentPlan.planPrice,
19815
19825
  subscriptionCurrency
19816
19826
  )
19817
19827
  }
19818
19828
  ),
19819
- /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
19829
+ !isUsageBasedPlan && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
19820
19830
  Text,
19821
19831
  {
19822
19832
  $font: theme.typography[props.header.price.fontStyle].fontFamily,
@@ -20172,6 +20182,10 @@ var PricingTable = (0, import_react39.forwardRef)(({ children, className, ...res
20172
20182
  const { price: planPrice, currency: planCurrency } = (selectedPeriod === "month" ? plan.monthlyPrice : selectedPeriod === "year" && plan.yearlyPrice) || {};
20173
20183
  const count = entitlementCounts[plan.id];
20174
20184
  const isExpanded = count.limit > VISIBLE_ENTITLEMENT_COUNT;
20185
+ const hasUsageBasedEntitlements = plan.entitlements.some(
20186
+ (entitlement) => !!entitlement.priceBehavior
20187
+ );
20188
+ const isUsageBasedPlan = planPrice === 0 && hasUsageBasedEntitlements;
20175
20189
  return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
20176
20190
  Flex,
20177
20191
  {
@@ -20224,10 +20238,10 @@ var PricingTable = (0, import_react39.forwardRef)(({ children, className, ...res
20224
20238
  $size: theme.typography[props.plans.name.fontStyle].fontSize,
20225
20239
  $weight: theme.typography[props.plans.name.fontStyle].fontWeight,
20226
20240
  $color: theme.typography[props.plans.name.fontStyle].color,
20227
- children: plan.custom ? plan.customPlanConfig?.priceText ? plan.customPlanConfig.priceText : t2("Custom Plan Price") : formatCurrency(planPrice ?? 0, planCurrency)
20241
+ children: plan.custom ? plan.customPlanConfig?.priceText ? plan.customPlanConfig.priceText : t2("Custom Plan Price") : isUsageBasedPlan ? t2("Usage-based") : formatCurrency(planPrice ?? 0, planCurrency)
20228
20242
  }
20229
20243
  ),
20230
- !plan.custom && /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
20244
+ !plan.custom && !isUsageBasedPlan && /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
20231
20245
  Text,
20232
20246
  {
20233
20247
  $font: theme.typography[props.plans.name.fontStyle].fontFamily,
@@ -2253,7 +2253,7 @@ var require_debounce = __commonJS({
2253
2253
  });
2254
2254
 
2255
2255
  // src/components/elements/included-features/IncludedFeatures.tsx
2256
- import { forwardRef as forwardRef7, useRef as useRef7, useState as useState12 } from "react";
2256
+ import { forwardRef as forwardRef7, useMemo as useMemo9, useRef as useRef7, useState as useState12 } from "react";
2257
2257
 
2258
2258
  // node_modules/react-i18next/dist/es/Trans.js
2259
2259
  import { useContext } from "react";
@@ -3895,6 +3895,7 @@ var TEXT_BASE_SIZE = 16;
3895
3895
  var VISIBLE_ENTITLEMENT_COUNT = 4;
3896
3896
  var MAX_VISIBLE_INVOICE_COUNT = 12;
3897
3897
  var DEBOUNCE_TIMEOUT = 250;
3898
+ var DEFAULT_CURRENCY = "USD";
3898
3899
 
3899
3900
  // src/hooks/useAvailablePlans.ts
3900
3901
  import { useCallback as useCallback2, useMemo as useMemo2 } from "react";
@@ -13055,7 +13056,7 @@ var EmbedProvider = ({
13055
13056
  useEffect2(() => {
13056
13057
  if (accessToken) {
13057
13058
  const { headers = {} } = apiConfig ?? {};
13058
- headers["X-Schematic-Components-Version"] = "0.6.1";
13059
+ headers["X-Schematic-Components-Version"] = "0.6.2";
13059
13060
  headers["X-Schematic-Session-ID"] = sessionIdRef.current;
13060
13061
  const config = new Configuration({
13061
13062
  ...apiConfig,
@@ -13123,9 +13124,12 @@ var import_pluralize = __toESM(require_pluralize());
13123
13124
  var getFeatureName = (feature, count = 0) => {
13124
13125
  const shouldBePlural = count === 0 || count > 1;
13125
13126
  const { name, singularName, pluralName } = feature;
13126
- if (pluralName && shouldBePlural) return pluralName;
13127
- if (singularName)
13127
+ if (pluralName && shouldBePlural) {
13128
+ return pluralName;
13129
+ }
13130
+ if (singularName) {
13128
13131
  return shouldBePlural ? (0, import_pluralize.default)(singularName, count) : singularName;
13132
+ }
13129
13133
  return (0, import_pluralize.default)(name, count);
13130
13134
  };
13131
13135
 
@@ -13246,15 +13250,14 @@ function shortenPeriod(period) {
13246
13250
  }
13247
13251
 
13248
13252
  // src/utils/string.ts
13249
- var DEFAULT_CURRENCY = "USD";
13250
13253
  function camelToHyphen(str) {
13251
13254
  return str.replace(/([a-z][A-Z])/g, (g2) => `${g2[0]}-${g2[1].toLowerCase()}`);
13252
13255
  }
13253
13256
  function formatNumber(num) {
13254
13257
  return new Intl.NumberFormat("en-US").format(num);
13255
13258
  }
13256
- function formatCurrency(amount, currency = DEFAULT_CURRENCY) {
13257
- const nonEmptyCurrency = currency ? currency.toUpperCase() : DEFAULT_CURRENCY;
13259
+ function formatCurrency(amount, currency) {
13260
+ const resolvedCurrency = (currency || DEFAULT_CURRENCY).toUpperCase();
13258
13261
  try {
13259
13262
  const dollars = amount / 100;
13260
13263
  const formatValue = (value, symbol) => {
@@ -13262,8 +13265,8 @@ function formatCurrency(amount, currency = DEFAULT_CURRENCY) {
13262
13265
  if (formatted.endsWith(".0")) {
13263
13266
  formatted = formatted.slice(0, -2);
13264
13267
  }
13265
- if (nonEmptyCurrency !== DEFAULT_CURRENCY) {
13266
- return `${nonEmptyCurrency}${formatted}${symbol}`;
13268
+ if (resolvedCurrency !== DEFAULT_CURRENCY) {
13269
+ return `${resolvedCurrency}${formatted}${symbol}`;
13267
13270
  }
13268
13271
  return `$${formatted}${symbol}`;
13269
13272
  };
@@ -13274,14 +13277,16 @@ function formatCurrency(amount, currency = DEFAULT_CURRENCY) {
13274
13277
  } else {
13275
13278
  return new Intl.NumberFormat("en-US", {
13276
13279
  style: "currency",
13277
- currency: nonEmptyCurrency
13280
+ currency: resolvedCurrency,
13281
+ minimumSignificantDigits: 1,
13282
+ maximumSignificantDigits: 4
13278
13283
  }).format(dollars);
13279
13284
  }
13280
13285
  } catch (error) {
13281
13286
  console.error("Error formatting currency", error);
13282
13287
  return new Intl.NumberFormat("en-US", {
13283
13288
  style: "currency",
13284
- currency: nonEmptyCurrency
13289
+ currency: resolvedCurrency
13285
13290
  }).format(amount / 100);
13286
13291
  }
13287
13292
  }
@@ -14533,7 +14538,6 @@ var StyledCard = dt.div(({ theme }) => {
14533
14538
  const borderRadius = `${theme.card.borderRadius / TEXT_BASE_SIZE}rem`;
14534
14539
  return lt`
14535
14540
  position: relative;
14536
- overflow: hidden;
14537
14541
 
14538
14542
  ${theme.sectionLayout === "merged" ? `&:not(:has(${FussyChild}))` : `${Element}:not(:is(${FussyChild}))`} {
14539
14543
  color: ${theme.typography.text.color};
@@ -14611,7 +14615,9 @@ import { forwardRef as forwardRef5 } from "react";
14611
14615
  var Container2 = dt(Box)`
14612
14616
  all: initial;
14613
14617
  box-sizing: border-box;
14618
+ display: block;
14614
14619
  font-size: ${TEXT_BASE_SIZE}px;
14620
+ width: 100%;
14615
14621
 
14616
14622
  *,
14617
14623
  *::before,
@@ -16569,6 +16575,10 @@ var Plan = ({
16569
16575
  const count = entitlementCounts[plan.id];
16570
16576
  const isExpanded = count.limit > VISIBLE_ENTITLEMENT_COUNT;
16571
16577
  const { price: planPrice, currency: planCurrency } = (period === "month" ? plan.monthlyPrice : period === "year" && plan.yearlyPrice) || {};
16578
+ const hasUsageBasedEntitlements = plan.entitlements.some(
16579
+ (entitlement) => !!entitlement.priceBehavior
16580
+ );
16581
+ const isUsageBasedPlan = planPrice === 0 && hasUsageBasedEntitlements;
16572
16582
  return /* @__PURE__ */ jsxs12(
16573
16583
  Flex,
16574
16584
  {
@@ -16626,10 +16636,10 @@ var Plan = ({
16626
16636
  $size: theme.typography.heading2.fontSize,
16627
16637
  $weight: theme.typography.heading2.fontWeight,
16628
16638
  $color: theme.typography.heading2.color,
16629
- children: plan.custom ? plan.customPlanConfig?.priceText ? plan.customPlanConfig.priceText : t2("Custom Plan Price") : formatCurrency(planPrice ?? 0, planCurrency)
16639
+ children: plan.custom ? plan.customPlanConfig?.priceText ? plan.customPlanConfig.priceText : t2("Custom Plan Price") : isUsageBasedPlan ? t2("Usage-based") : formatCurrency(planPrice ?? 0, planCurrency)
16630
16640
  }
16631
16641
  ),
16632
- !plan.custom && /* @__PURE__ */ jsxs12(
16642
+ !plan.custom && !isUsageBasedPlan && /* @__PURE__ */ jsxs12(
16633
16643
  Text,
16634
16644
  {
16635
16645
  $font: theme.typography.heading2.fontFamily,
@@ -18203,11 +18213,10 @@ Viewport.displayName = "Viewport";
18203
18213
  import { useMemo as useMemo8 } from "react";
18204
18214
  import { jsx as jsx27, jsxs as jsxs21 } from "react/jsx-runtime";
18205
18215
  var Details = ({
18206
- details,
18207
18216
  shouldWrapChildren,
18217
+ featureUsage,
18208
18218
  ...props
18209
18219
  }) => {
18210
- const { featureUsage, usageData } = details;
18211
18220
  const {
18212
18221
  allocation,
18213
18222
  feature,
@@ -18216,7 +18225,7 @@ var Details = ({
18216
18225
  softLimit,
18217
18226
  monthlyUsageBasedPrice,
18218
18227
  yearlyUsageBasedPrice
18219
- } = featureUsage || {};
18228
+ } = featureUsage;
18220
18229
  const { t: t2 } = useTranslation();
18221
18230
  const theme = nt();
18222
18231
  const { data } = useEmbed();
@@ -18268,25 +18277,23 @@ var Details = ({
18268
18277
  if (!feature) {
18269
18278
  return;
18270
18279
  }
18271
- if (usageData) {
18272
- let acc;
18273
- if (priceBehavior === "pay_in_advance" && typeof data.company?.plan?.planPeriod === "string" && typeof price === "number") {
18274
- acc = `${formatCurrency(price, currency)}/${getFeatureName(feature, 1)}/${shortenPeriod(data.company.plan.planPeriod)}`;
18275
- } else if ((priceBehavior === "pay_as_you_go" || priceBehavior === "overage") && typeof usage === "number") {
18276
- acc = `${usage} ${getFeatureName(feature, usage)} ${t2("used")}`;
18277
- }
18278
- if (acc) {
18279
- if (priceBehavior === "pay_in_advance" && typeof price === "number" && typeof allocation === "number") {
18280
- acc += ` \u2022 ${formatCurrency(price * allocation, currency)}`;
18281
- } else if (priceBehavior === "pay_as_you_go" && typeof price === "number" && typeof usage === "number") {
18282
- acc += ` \u2022 ${formatCurrency(price * usage, currency)}`;
18283
- } else if (priceBehavior === "overage" && typeof price === "number" && typeof usage === "number" && typeof softLimit === "number") {
18284
- const cost = price * (usage - softLimit);
18285
- const period = feature.featureType === "event" && typeof data.company?.plan?.planPeriod === "string" ? `/${shortenPeriod(data.company.plan.planPeriod)}` : "";
18286
- acc += cost > 0 ? ` \u2022 ${t2("Overage")}: ${formatCurrency(cost)}${period}` : ` \u2022 ${`${formatCurrency(price)}/${getFeatureName(feature, 1)}`} ${t2("overage fee")}`;
18287
- }
18288
- return acc;
18280
+ let acc;
18281
+ if (priceBehavior === "pay_in_advance" && typeof data.company?.plan?.planPeriod === "string" && typeof price === "number") {
18282
+ acc = `${formatCurrency(price, currency)}/${getFeatureName(feature, 1)}/${shortenPeriod(data.company.plan.planPeriod)}`;
18283
+ } else if ((priceBehavior === "pay_as_you_go" || priceBehavior === "overage") && typeof usage === "number") {
18284
+ acc = `${usage} ${getFeatureName(feature, usage)} ${t2("used")}`;
18285
+ }
18286
+ if (acc) {
18287
+ if (priceBehavior === "pay_in_advance" && typeof price === "number" && typeof allocation === "number") {
18288
+ acc += ` \u2022 ${formatCurrency(price * allocation, currency)}`;
18289
+ } else if (priceBehavior === "pay_as_you_go" && typeof price === "number" && typeof usage === "number") {
18290
+ acc += ` \u2022 ${formatCurrency(price * usage, currency)}`;
18291
+ } else if (priceBehavior === "overage" && typeof price === "number" && typeof usage === "number" && typeof softLimit === "number") {
18292
+ const cost = price * (usage - softLimit);
18293
+ const period = feature.featureType === "event" && typeof data.company?.plan?.planPeriod === "string" ? `/${shortenPeriod(data.company.plan.planPeriod)}` : "";
18294
+ acc += cost > 0 ? ` \u2022 ${t2("Overage")}: ${formatCurrency(cost)}${period}` : ` \u2022 ${`${formatCurrency(price)}/${getFeatureName(feature, 1)}`} ${t2("overage fee")}`;
18289
18295
  }
18296
+ return acc;
18290
18297
  }
18291
18298
  if (typeof usage === "number") {
18292
18299
  return typeof allocation === "number" ? t2("usage.limited", {
@@ -18305,8 +18312,7 @@ var Details = ({
18305
18312
  price,
18306
18313
  currency,
18307
18314
  softLimit,
18308
- usage,
18309
- usageData
18315
+ usage
18310
18316
  ]);
18311
18317
  if (!text) {
18312
18318
  return null;
@@ -18384,38 +18390,28 @@ var IncludedFeatures = forwardRef7(({ className, ...rest }, ref) => {
18384
18390
  const shouldWrapChildren = useWrapChildren(elements.current);
18385
18391
  const isLightBackground = useIsLightBackground();
18386
18392
  const [showCount, setShowCount] = useState12(VISIBLE_ENTITLEMENT_COUNT);
18387
- const orderedFeatureUsage = props.visibleFeatures?.reduce(
18388
- (acc, id) => {
18389
- const mappedFeatureUsage = data.featureUsage?.features.find(
18390
- (usage) => usage.feature?.id === id
18391
- );
18392
- if (mappedFeatureUsage) {
18393
- acc.push(mappedFeatureUsage);
18394
- }
18395
- return acc;
18396
- },
18397
- []
18398
- );
18399
- const entitlements = (orderedFeatureUsage || data.featureUsage?.features || []).reduce(
18400
- (acc, usage) => {
18401
- const mappedUsageData = data.activeUsageBasedEntitlements.find(
18402
- (entitlement) => entitlement.featureId === usage.feature?.id
18403
- );
18404
- acc.push({
18405
- featureUsage: usage,
18406
- usageData: mappedUsageData
18407
- });
18408
- return acc;
18409
- },
18410
- []
18411
- );
18412
- const featureListSize = entitlements.length;
18393
+ const featureUsage = useMemo9(() => {
18394
+ const orderedFeatureUsage = props.visibleFeatures?.reduce(
18395
+ (acc, id) => {
18396
+ const mappedFeatureUsage = data.featureUsage?.features.find(
18397
+ (usage) => usage.feature?.id === id
18398
+ );
18399
+ if (mappedFeatureUsage) {
18400
+ acc.push(mappedFeatureUsage);
18401
+ }
18402
+ return acc;
18403
+ },
18404
+ []
18405
+ );
18406
+ return orderedFeatureUsage || data.featureUsage?.features || [];
18407
+ }, [props.visibleFeatures, data.featureUsage?.features]);
18408
+ const featureListSize = featureUsage.length;
18413
18409
  const handleToggleShowAll = () => {
18414
18410
  setShowCount(
18415
18411
  (prev2) => prev2 > VISIBLE_ENTITLEMENT_COUNT ? VISIBLE_ENTITLEMENT_COUNT : featureListSize
18416
18412
  );
18417
18413
  };
18418
- const shouldShowFeatures = entitlements.length > 0 || data.company?.plan || (data.company?.addOns ?? []).length > 0 || false;
18414
+ const shouldShowFeatures = featureUsage.length > 0 || data.company?.plan || (data.company?.addOns ?? []).length > 0 || false;
18419
18415
  if (!shouldShowFeatures) {
18420
18416
  return null;
18421
18417
  }
@@ -18440,8 +18436,8 @@ var IncludedFeatures = forwardRef7(({ className, ...rest }, ref) => {
18440
18436
  children: props.header.text
18441
18437
  }
18442
18438
  ) }),
18443
- entitlements.slice(0, showCount).map((entitlement, index) => {
18444
- const { entitlementExpirationDate, feature } = entitlement.featureUsage || {};
18439
+ featureUsage.slice(0, showCount).map((usage, index) => {
18440
+ const feature = usage.feature;
18445
18441
  const shouldShowDetails = feature?.name && (feature?.featureType === "event" || feature?.featureType === "trait");
18446
18442
  return /* @__PURE__ */ jsxs22(
18447
18443
  Flex,
@@ -18485,7 +18481,7 @@ var IncludedFeatures = forwardRef7(({ className, ...rest }, ref) => {
18485
18481
  children: feature.name
18486
18482
  }
18487
18483
  ),
18488
- props.entitlementExpiration.isVisible && entitlementExpirationDate && /* @__PURE__ */ jsxs22(
18484
+ props.entitlementExpiration.isVisible && usage.entitlementExpirationDate && /* @__PURE__ */ jsxs22(
18489
18485
  Text,
18490
18486
  {
18491
18487
  $font: theme.typography[props.entitlementExpiration.fontStyle].fontFamily,
@@ -18496,7 +18492,7 @@ var IncludedFeatures = forwardRef7(({ className, ...rest }, ref) => {
18496
18492
  children: [
18497
18493
  "Expires",
18498
18494
  " ",
18499
- toPrettyDate(entitlementExpirationDate, {
18495
+ toPrettyDate(usage.entitlementExpirationDate, {
18500
18496
  month: "short"
18501
18497
  })
18502
18498
  ]
@@ -18508,7 +18504,7 @@ var IncludedFeatures = forwardRef7(({ className, ...rest }, ref) => {
18508
18504
  shouldShowDetails && /* @__PURE__ */ jsx28(
18509
18505
  Details,
18510
18506
  {
18511
- details: entitlement,
18507
+ featureUsage: usage,
18512
18508
  shouldWrapChildren,
18513
18509
  ...props
18514
18510
  }
@@ -18682,12 +18678,24 @@ var Invoices = forwardRef8(({ className, data, ...rest }, ref) => {
18682
18678
  Invoices.displayName = "Invoices";
18683
18679
 
18684
18680
  // src/components/elements/metered-features/MeteredFeatures.tsx
18685
- import { forwardRef as forwardRef9, useMemo as useMemo9, useRef as useRef8 } from "react";
18681
+ import { forwardRef as forwardRef9, useMemo as useMemo10, useRef as useRef8 } from "react";
18686
18682
 
18687
18683
  // src/components/elements/metered-features/styles.ts
18688
18684
  var Container4 = dt(Flex)`
18689
18685
  flex-direction: column;
18690
18686
 
18687
+ &:last-child {
18688
+ overflow: hidden;
18689
+
18690
+ ${({ theme }) => {
18691
+ const borderRadius = `${theme.card.borderRadius / TEXT_BASE_SIZE}rem`;
18692
+ return lt`
18693
+ border-bottom-left-radius: ${borderRadius};
18694
+ border-bottom-right-radius: ${borderRadius};
18695
+ `;
18696
+ }}
18697
+ }
18698
+
18691
18699
  &:not(:last-child) {
18692
18700
  ${({ theme }) => {
18693
18701
  const { l: l2 } = hexToHSL(theme.card.background);
@@ -18736,8 +18744,8 @@ var MeteredFeatures = forwardRef9(({ className, ...rest }, ref) => {
18736
18744
  const theme = nt();
18737
18745
  const { data, setLayout, setSelected } = useEmbed();
18738
18746
  const isLightBackground = useIsLightBackground();
18739
- const meteredFeatures = useMemo9(() => {
18740
- return (props.visibleFeatures ? props.visibleFeatures.reduce(
18747
+ const featureUsage = useMemo10(() => {
18748
+ const orderedFeatureUsage = props.visibleFeatures?.reduce(
18741
18749
  (acc, id) => {
18742
18750
  const mappedFeatureUsage = data.featureUsage?.features.find(
18743
18751
  (usage) => usage.feature?.id === id
@@ -18748,16 +18756,17 @@ var MeteredFeatures = forwardRef9(({ className, ...rest }, ref) => {
18748
18756
  return acc;
18749
18757
  },
18750
18758
  []
18751
- ) : data.featureUsage?.features || []).filter(
18759
+ );
18760
+ return (orderedFeatureUsage || data.featureUsage?.features || []).filter(
18752
18761
  (usage) => usage.feature?.featureType === "event" || usage.feature?.featureType === "trait"
18753
18762
  );
18754
18763
  }, [props.visibleFeatures, data.featureUsage?.features]);
18755
18764
  const planPeriod = data.company?.plan?.planPeriod;
18756
- const shouldShowFeatures = meteredFeatures.length > 0 || data.company?.plan || (data.company?.addOns ?? []).length > 0 || false;
18765
+ const shouldShowFeatures = featureUsage.length > 0 || data.company?.plan || (data.company?.addOns ?? []).length > 0 || false;
18757
18766
  if (!shouldShowFeatures) {
18758
18767
  return null;
18759
18768
  }
18760
- return /* @__PURE__ */ jsx30(Container4, { ref, className, children: meteredFeatures.map(
18769
+ return /* @__PURE__ */ jsx30(Container4, { ref, className, children: featureUsage.map(
18761
18770
  ({
18762
18771
  feature,
18763
18772
  priceBehavior,
@@ -18771,7 +18780,7 @@ var MeteredFeatures = forwardRef9(({ className, ...rest }, ref) => {
18771
18780
  const limit = softLimit ?? allocation ?? 0;
18772
18781
  const isOverage = priceBehavior === "overage" && typeof softLimit === "number" && typeof usage === "number" && usage > softLimit;
18773
18782
  const { price, currency } = (planPeriod === "month" ? monthlyUsageBasedPrice : planPeriod === "year" && yearlyUsageBasedPrice) || {};
18774
- const progressBar = props.isVisible && typeof usage === "number" && priceBehavior !== "pay_as_you_go" && /* @__PURE__ */ jsx30(
18783
+ const progressBar = props.isVisible && typeof usage === "number" && limit > 0 && priceBehavior !== "pay_as_you_go" && /* @__PURE__ */ jsx30(
18775
18784
  ProgressBar,
18776
18785
  {
18777
18786
  progress: (isOverage ? softLimit / usage : usage / limit) * 100,
@@ -18995,10 +19004,10 @@ var MeteredFeatures = forwardRef9(({ className, ...rest }, ref) => {
18995
19004
  MeteredFeatures.displayName = "MeteredFeatures";
18996
19005
 
18997
19006
  // src/components/elements/payment-method/PaymentMethod.tsx
18998
- import { forwardRef as forwardRef10, useMemo as useMemo11 } from "react";
19007
+ import { forwardRef as forwardRef10, useMemo as useMemo12 } from "react";
18999
19008
 
19000
19009
  // src/components/elements/payment-method/PaymentMethodElement.tsx
19001
- import { useMemo as useMemo10 } from "react";
19010
+ import { useMemo as useMemo11 } from "react";
19002
19011
  import { jsx as jsx31, jsxs as jsxs25 } from "react/jsx-runtime";
19003
19012
  var PaymentElement2 = ({
19004
19013
  iconName,
@@ -19173,7 +19182,7 @@ var PaymentListElement = ({
19173
19182
  const isLightBackground = useIsLightBackground();
19174
19183
  const { iconName, iconTitle, label, paymentLast4 } = getPaymentMethodData(paymentMethod);
19175
19184
  const iconStyles = getIconStyles({ size: "lg", theme });
19176
- const expirationDate = useMemo10(() => {
19185
+ const expirationDate = useMemo11(() => {
19177
19186
  const { cardExpMonth, cardExpYear } = paymentMethod;
19178
19187
  if (!cardExpMonth && !cardExpYear) {
19179
19188
  return "";
@@ -19288,10 +19297,10 @@ var resolveDesignProps4 = (props) => {
19288
19297
  var PaymentMethod = forwardRef10(({ children, className, portal, allowEdit = true, ...rest }, ref) => {
19289
19298
  const props = resolveDesignProps4(rest);
19290
19299
  const { data, setLayout } = useEmbed();
19291
- const paymentMethod = useMemo11(() => {
19300
+ const paymentMethod = useMemo12(() => {
19292
19301
  return data.subscription?.paymentMethod;
19293
19302
  }, [data.subscription?.paymentMethod]);
19294
- const monthsToExpiration = useMemo11(() => {
19303
+ const monthsToExpiration = useMemo12(() => {
19295
19304
  let expiration;
19296
19305
  if (typeof paymentMethod?.cardExpYear === "number" && typeof paymentMethod?.cardExpMonth === "number") {
19297
19306
  const today = /* @__PURE__ */ new Date();
@@ -19318,7 +19327,7 @@ PaymentMethod.displayName = "PaymentMethod";
19318
19327
 
19319
19328
  // src/components/elements/payment-method/PaymentMethodDetails.tsx
19320
19329
  import { Elements } from "@stripe/react-stripe-js";
19321
- import { useCallback as useCallback10, useEffect as useEffect7, useMemo as useMemo12, useState as useState14 } from "react";
19330
+ import { useCallback as useCallback10, useEffect as useEffect7, useMemo as useMemo13, useState as useState14 } from "react";
19322
19331
  import { jsx as jsx33, jsxs as jsxs26 } from "react/jsx-runtime";
19323
19332
  var resolveDesignProps5 = () => {
19324
19333
  return {
@@ -19352,7 +19361,7 @@ var PaymentMethodDetails = ({
19352
19361
  setPaymentMethod(data.subscription.paymentMethod);
19353
19362
  }
19354
19363
  }, [data.subscription?.paymentMethod]);
19355
- const monthsToExpiration = useMemo12(() => {
19364
+ const monthsToExpiration = useMemo13(() => {
19356
19365
  let expiration;
19357
19366
  if (typeof paymentMethod?.cardExpYear === "number" && typeof paymentMethod?.cardExpMonth === "number") {
19358
19367
  const today = /* @__PURE__ */ new Date();
@@ -19584,7 +19593,7 @@ var PaymentMethodDetails = ({
19584
19593
  };
19585
19594
 
19586
19595
  // src/components/elements/plan-manager/PlanManager.tsx
19587
- import { forwardRef as forwardRef11, useMemo as useMemo13 } from "react";
19596
+ import { forwardRef as forwardRef11, useMemo as useMemo14 } from "react";
19588
19597
  import { Fragment as Fragment11, jsx as jsx34, jsxs as jsxs27 } from "react/jsx-runtime";
19589
19598
  var resolveDesignProps6 = (props) => {
19590
19599
  return {
@@ -19638,7 +19647,7 @@ var PlanManager = forwardRef11(({ children, className, portal, ...rest }, ref) =
19638
19647
  []
19639
19648
  );
19640
19649
  const billingSubscription = data.company?.billingSubscription;
19641
- const trialEndDays = useMemo13(() => {
19650
+ const trialEndDays = useMemo14(() => {
19642
19651
  const trialEnd = billingSubscription?.trialEnd;
19643
19652
  const trialEndDate = trialEnd ? new Date(trialEnd * 1e3) : /* @__PURE__ */ new Date();
19644
19653
  const todayDate = /* @__PURE__ */ new Date();
@@ -19649,6 +19658,7 @@ var PlanManager = forwardRef11(({ children, className, portal, ...rest }, ref) =
19649
19658
  const subscriptionCurrency = billingSubscription?.currency;
19650
19659
  const isTrialSubscription = billingSubscription?.status === "trialing";
19651
19660
  const willSubscriptionCancel = billingSubscription?.cancelAtPeriodEnd;
19661
+ const isUsageBasedPlan = currentPlan?.planPrice === 0 && usageBasedEntitlements.length > 0;
19652
19662
  return /* @__PURE__ */ jsxs27(Fragment11, { children: [
19653
19663
  isTrialSubscription && !willSubscriptionCancel ? /* @__PURE__ */ jsxs27(
19654
19664
  Box,
@@ -19774,13 +19784,13 @@ var PlanManager = forwardRef11(({ children, className, portal, ...rest }, ref) =
19774
19784
  $size: theme.typography[props.header.price.fontStyle].fontSize,
19775
19785
  $weight: theme.typography[props.header.price.fontStyle].fontWeight,
19776
19786
  $color: theme.typography[props.header.price.fontStyle].color,
19777
- children: formatCurrency(
19787
+ children: isUsageBasedPlan ? t2("Usage-based") : formatCurrency(
19778
19788
  currentPlan.planPrice,
19779
19789
  subscriptionCurrency
19780
19790
  )
19781
19791
  }
19782
19792
  ),
19783
- /* @__PURE__ */ jsx34(
19793
+ !isUsageBasedPlan && /* @__PURE__ */ jsx34(
19784
19794
  Text,
19785
19795
  {
19786
19796
  $font: theme.typography[props.header.price.fontStyle].fontFamily,
@@ -20136,6 +20146,10 @@ var PricingTable = forwardRef12(({ children, className, ...rest }, ref) => {
20136
20146
  const { price: planPrice, currency: planCurrency } = (selectedPeriod === "month" ? plan.monthlyPrice : selectedPeriod === "year" && plan.yearlyPrice) || {};
20137
20147
  const count = entitlementCounts[plan.id];
20138
20148
  const isExpanded = count.limit > VISIBLE_ENTITLEMENT_COUNT;
20149
+ const hasUsageBasedEntitlements = plan.entitlements.some(
20150
+ (entitlement) => !!entitlement.priceBehavior
20151
+ );
20152
+ const isUsageBasedPlan = planPrice === 0 && hasUsageBasedEntitlements;
20139
20153
  return /* @__PURE__ */ jsxs28(
20140
20154
  Flex,
20141
20155
  {
@@ -20188,10 +20202,10 @@ var PricingTable = forwardRef12(({ children, className, ...rest }, ref) => {
20188
20202
  $size: theme.typography[props.plans.name.fontStyle].fontSize,
20189
20203
  $weight: theme.typography[props.plans.name.fontStyle].fontWeight,
20190
20204
  $color: theme.typography[props.plans.name.fontStyle].color,
20191
- children: plan.custom ? plan.customPlanConfig?.priceText ? plan.customPlanConfig.priceText : t2("Custom Plan Price") : formatCurrency(planPrice ?? 0, planCurrency)
20205
+ children: plan.custom ? plan.customPlanConfig?.priceText ? plan.customPlanConfig.priceText : t2("Custom Plan Price") : isUsageBasedPlan ? t2("Usage-based") : formatCurrency(planPrice ?? 0, planCurrency)
20192
20206
  }
20193
20207
  ),
20194
- !plan.custom && /* @__PURE__ */ jsxs28(
20208
+ !plan.custom && !isUsageBasedPlan && /* @__PURE__ */ jsxs28(
20195
20209
  Text,
20196
20210
  {
20197
20211
  $font: theme.typography[props.plans.name.fontStyle].fontFamily,
@@ -20778,7 +20792,7 @@ var UnsubscribeButton = forwardRef13(({ children, className, ...rest }, ref) =>
20778
20792
  UnsubscribeButton.displayName = "UnsubscribeButton";
20779
20793
 
20780
20794
  // src/components/elements/upcoming-bill/UpcomingBill.tsx
20781
- import { forwardRef as forwardRef14, useMemo as useMemo14 } from "react";
20795
+ import { forwardRef as forwardRef14, useMemo as useMemo15 } from "react";
20782
20796
  import { jsx as jsx37, jsxs as jsxs29 } from "react/jsx-runtime";
20783
20797
  function resolveDesignProps9(props) {
20784
20798
  return {
@@ -20804,7 +20818,7 @@ var UpcomingBill = forwardRef14(({ className, ...rest }, ref) => {
20804
20818
  const theme = nt();
20805
20819
  const { data } = useEmbed();
20806
20820
  const isLightBackground = useIsLightBackground();
20807
- const { upcomingInvoice, discounts } = useMemo14(() => {
20821
+ const { upcomingInvoice, discounts } = useMemo15(() => {
20808
20822
  const discounts2 = (data.subscription?.discounts || []).map((discount) => ({
20809
20823
  amountOff: discount.amountOff,
20810
20824
  couponId: discount.couponId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@schematichq/schematic-components",
3
- "version": "0.6.1",
3
+ "version": "0.6.2",
4
4
  "main": "dist/schematic-components.cjs.js",
5
5
  "module": "dist/schematic-components.esm.js",
6
6
  "types": "dist/schematic-components.d.ts",