@schematichq/schematic-components 0.7.4 → 0.7.6

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.
@@ -10794,6 +10794,7 @@ function BillingProductDetailResponseDataFromJSONTyped(json, ignoreDiscriminator
10794
10794
  currency: json["currency"],
10795
10795
  environmentId: json["environment_id"],
10796
10796
  externalId: json["external_id"],
10797
+ isActive: json["is_active"],
10797
10798
  name: json["name"],
10798
10799
  price: json["price"],
10799
10800
  priceDecimal: json["price_decimal"] == null ? void 0 : json["price_decimal"],
@@ -10853,6 +10854,7 @@ function BillingProductResponseDataFromJSONTyped(json, ignoreDiscriminator) {
10853
10854
  currency: json["currency"],
10854
10855
  environmentId: json["environment_id"],
10855
10856
  externalId: json["external_id"],
10857
+ isActive: json["is_active"],
10856
10858
  name: json["name"],
10857
10859
  price: json["price"],
10858
10860
  priceDecimal: json["price_decimal"] == null ? void 0 : json["price_decimal"],
@@ -11249,6 +11251,7 @@ function CompanyDetailResponseDataFromJSONTyped(json, ignoreDiscriminator) {
11249
11251
  BillingSubscriptionViewFromJSON
11250
11252
  ),
11251
11253
  createdAt: new Date(json["created_at"]),
11254
+ defaultPaymentMethod: json["default_payment_method"] == null ? void 0 : PaymentMethodResponseDataFromJSON(json["default_payment_method"]),
11252
11255
  entityTraits: json["entity_traits"].map(
11253
11256
  EntityTraitDetailResponseDataFromJSON
11254
11257
  ),
@@ -13190,7 +13193,7 @@ var EmbedProvider = ({
13190
13193
  (0, import_react11.useEffect)(() => {
13191
13194
  if (accessToken) {
13192
13195
  const { headers = {} } = apiConfig ?? {};
13193
- headers["X-Schematic-Components-Version"] = "0.7.4";
13196
+ headers["X-Schematic-Components-Version"] = "0.7.6";
13194
13197
  headers["X-Schematic-Session-ID"] = sessionIdRef.current;
13195
13198
  const config = new Configuration({
13196
13199
  ...apiConfig,
@@ -14447,43 +14450,61 @@ var ProgressBar = ({
14447
14450
 
14448
14451
  // src/components/ui/text/styles.ts
14449
14452
  var TextPropNames = /* @__PURE__ */ ((TextPropNames2) => {
14450
- TextPropNames2["Align"] = "$align";
14451
14453
  TextPropNames2["Font"] = "$font";
14452
14454
  TextPropNames2["Size"] = "$size";
14453
14455
  TextPropNames2["Weight"] = "$weight";
14454
14456
  TextPropNames2["Color"] = "$color";
14455
14457
  TextPropNames2["Leading"] = "$leading";
14458
+ TextPropNames2["Align"] = "$align";
14456
14459
  return TextPropNames2;
14457
14460
  })(TextPropNames || {});
14458
- var Text = dt.span.attrs(({ onClick }) => ({
14461
+ var Text = dt.span.withConfig({
14462
+ shouldForwardProp: (prop) => prop !== "display"
14463
+ }).attrs(({ onClick }) => ({
14459
14464
  ...onClick && { tabIndex: 0 }
14460
- }))`
14461
- ${({ $font }) => $font && lt`
14462
- font-family: ${$font}, sans-serif;
14463
- `};
14464
- ${({ $size }) => typeof $size !== "undefined" && lt`
14465
- font-size: ${typeof $size === "number" ? `${$size / TEXT_BASE_SIZE}rem` : $size};
14466
- `};
14467
- ${({ $weight }) => typeof $weight !== "undefined" && lt`
14468
- font-weight: ${$weight};
14469
- font-variation-settings: "wght" ${$weight};
14470
- `};
14471
- ${({ $leading }) => attr("line-height", $leading)};
14472
- ${({ $align }) => attr("text-align", $align)};
14473
- color: ${({ $color, theme }) => $color || theme.typography.text.color};
14474
-
14475
- &:focus-visible {
14476
- outline: 2px solid ${({ theme }) => theme.primary};
14477
- outline-offset: 2px;
14478
- }
14479
-
14480
- ${({ onClick }) => onClick && lt`
14481
- &:hover {
14482
- cursor: pointer;
14483
- text-decoration: underline;
14465
+ }))(
14466
+ ({
14467
+ display = "text",
14468
+ theme,
14469
+ onClick,
14470
+ $font,
14471
+ $size,
14472
+ $weight,
14473
+ $color,
14474
+ $leading = 1.35,
14475
+ $align
14476
+ }) => {
14477
+ const settings = theme.typography[display];
14478
+ const fontFamily = $font || settings.fontFamily;
14479
+ const fontSize = $size || settings.fontSize;
14480
+ const fontWeight = $weight || settings.fontWeight;
14481
+ const color = $color || settings.color;
14482
+ return lt`
14483
+ font-family: ${fontFamily}, sans-serif;
14484
+ font-size: ${typeof fontSize === "number" ? `${fontSize / TEXT_BASE_SIZE}rem` : fontSize};
14485
+ font-weight: ${fontWeight};
14486
+ font-variation-settings: "wght" ${fontWeight};
14487
+ line-height: ${$leading};
14488
+ color: ${color};
14489
+
14490
+ ${$align && lt`
14491
+ text-align: ${$align};
14492
+ `};
14493
+
14494
+ ${onClick && lt`
14495
+ &:hover {
14496
+ cursor: pointer;
14497
+ text-decoration: underline;
14498
+ }
14499
+ `}
14500
+
14501
+ &:focus-visible {
14502
+ outline: 2px solid ${({ theme: theme2 }) => theme2.primary};
14503
+ outline-offset: 2px;
14484
14504
  }
14485
- `}
14486
- `;
14505
+ `;
14506
+ }
14507
+ );
14487
14508
 
14488
14509
  // src/components/ui/tooltip/Tooltip.tsx
14489
14510
  var import_debounce = __toESM(require_debounce());
@@ -14770,7 +14791,7 @@ var Container2 = dt.div`
14770
14791
  all: initial;
14771
14792
  box-sizing: border-box;
14772
14793
  display: block;
14773
- font-size: ${TEXT_BASE_SIZE}px;
14794
+ font-size: 1rem;
14774
14795
  line-height: 1.35;
14775
14796
  width: 100%;
14776
14797
  height: 100%;
@@ -14827,6 +14848,7 @@ var StageButton = ({
14827
14848
  checkoutStages,
14828
14849
  hasAddOns,
14829
14850
  hasPayInAdvanceEntitlements,
14851
+ hasUnstagedChanges,
14830
14852
  isLoading,
14831
14853
  requiresPayment,
14832
14854
  setCheckoutStage,
@@ -14838,7 +14860,7 @@ var StageButton = ({
14838
14860
  EmbedButton,
14839
14861
  {
14840
14862
  type: "button",
14841
- disabled: isLoading || !canUpdateSubscription,
14863
+ disabled: isLoading || !hasUnstagedChanges || !canUpdateSubscription,
14842
14864
  onClick: checkout,
14843
14865
  isLoading,
14844
14866
  children: t2("Subscribe and close")
@@ -14879,7 +14901,7 @@ var StageButton = ({
14879
14901
  EmbedButton,
14880
14902
  {
14881
14903
  type: "button",
14882
- disabled: !canUpdateSubscription,
14904
+ disabled: !hasUnstagedChanges || !canUpdateSubscription,
14883
14905
  onClick: async () => {
14884
14906
  checkout();
14885
14907
  },
@@ -15005,7 +15027,7 @@ var StageButton = ({
15005
15027
  EmbedButton,
15006
15028
  {
15007
15029
  type: "button",
15008
- disabled: isLoading || !canCheckout,
15030
+ disabled: isLoading || !hasUnstagedChanges || !canCheckout,
15009
15031
  onClick: checkout,
15010
15032
  isLoading,
15011
15033
  children: canTrial ? t2("Start trial") : t2("Pay now")
@@ -15209,14 +15231,6 @@ var Sidebar = ({
15209
15231
  }
15210
15232
  }, [t2, api, hydrate, setError, setIsLoading, setLayout]);
15211
15233
  const selectedAddOns = addOns.filter((addOn) => addOn.isSelected);
15212
- const willPlanChange = typeof selectedPlan !== "undefined" && !selectedPlan.current;
15213
- const canUpdateSubscription = mode === "edit" || api !== null && (willPlanChange || // TODO: test add-on comparison for finding "changes"
15214
- selectedAddOns.length !== currentAddOns.length || !selectedAddOns.every(
15215
- (addOn) => currentAddOns.some((currentAddOn) => addOn.id === currentAddOn.id)
15216
- ) || payInAdvanceEntitlements.every(
15217
- ({ quantity, usage }) => quantity >= usage
15218
- )) && !isLoading;
15219
- const canCheckout = canUpdateSubscription && (!!data.subscription?.paymentMethod || typeof paymentMethodId === "string");
15220
15234
  const {
15221
15235
  changedUsageBasedEntitlements,
15222
15236
  addedUsageBasedEntitlements,
@@ -15273,6 +15287,7 @@ var Sidebar = ({
15273
15287
  currentUsageBasedEntitlements,
15274
15288
  usageBasedEntitlements
15275
15289
  ]);
15290
+ const willPlanChange = typeof selectedPlan !== "undefined" && !selectedPlan.current;
15276
15291
  const removedAddOns = currentAddOns.filter(
15277
15292
  (current) => !selectedAddOns.some((selected) => current.id === selected.id)
15278
15293
  );
@@ -15280,6 +15295,10 @@ var Sidebar = ({
15280
15295
  (selected) => !currentAddOns.some((current) => selected.id === current.id)
15281
15296
  );
15282
15297
  const willAddOnsChange = removedAddOns.length > 0 || addedAddOns.length > 0;
15298
+ const willPayInAdvanceEntitlementsChange = payInAdvanceEntitlements.length > 0 && payInAdvanceEntitlements.some(({ quantity, usage }) => quantity !== usage);
15299
+ const hasUnstagedChanges = willPlanChange || willAddOnsChange || willPayInAdvanceEntitlementsChange;
15300
+ const canUpdateSubscription = mode === "edit" || api !== null && !isLoading;
15301
+ const canCheckout = canUpdateSubscription && (!!data.subscription?.paymentMethod || typeof paymentMethodId === "string");
15283
15302
  const isTrialable = selectedPlan?.companyCanTrial;
15284
15303
  const today = /* @__PURE__ */ new Date();
15285
15304
  const trialEndsOn = new Date(today);
@@ -16191,6 +16210,7 @@ var Sidebar = ({
16191
16210
  checkoutStages,
16192
16211
  hasAddOns: addOns.length > 0,
16193
16212
  hasPayInAdvanceEntitlements: payInAdvanceEntitlements.length > 0,
16213
+ hasUnstagedChanges,
16194
16214
  isLoading,
16195
16215
  requiresPayment,
16196
16216
  setCheckoutStage,
@@ -19568,8 +19588,8 @@ var PaymentMethod = (0, import_react37.forwardRef)(({ children, className, porta
19568
19588
  const props = resolveDesignProps5(rest);
19569
19589
  const { data, setLayout } = useEmbed();
19570
19590
  const paymentMethod = (0, import_react37.useMemo)(() => {
19571
- return data.subscription?.paymentMethod;
19572
- }, [data.subscription?.paymentMethod]);
19591
+ return data.subscription?.paymentMethod || data.company?.defaultPaymentMethod;
19592
+ }, [data.company?.defaultPaymentMethod, data.subscription?.paymentMethod]);
19573
19593
  const monthsToExpiration = (0, import_react37.useMemo)(() => {
19574
19594
  let expiration;
19575
19595
  if (typeof paymentMethod?.cardExpYear === "number" && typeof paymentMethod?.cardExpMonth === "number") {
@@ -19627,10 +19647,10 @@ var PaymentMethodDetails = ({
19627
19647
  const [showDifferentPaymentMethods, setShowDifferentPaymentMethods] = (0, import_react38.useState)(false);
19628
19648
  const [paymentMethod, setPaymentMethod] = (0, import_react38.useState)(void 0);
19629
19649
  (0, import_react38.useEffect)(() => {
19630
- if (data.subscription?.paymentMethod) {
19631
- setPaymentMethod(data.subscription.paymentMethod);
19632
- }
19633
- }, [data.subscription?.paymentMethod]);
19650
+ setPaymentMethod(
19651
+ data.subscription?.paymentMethod || data.company?.defaultPaymentMethod
19652
+ );
19653
+ }, [data.company?.defaultPaymentMethod, data.subscription?.paymentMethod]);
19634
19654
  const monthsToExpiration = (0, import_react38.useMemo)(() => {
19635
19655
  let expiration;
19636
19656
  if (typeof paymentMethod?.cardExpYear === "number" && typeof paymentMethod?.cardExpMonth === "number") {
@@ -19687,15 +19707,31 @@ var PaymentMethodDetails = ({
19687
19707
  if (setPaymentMethodId) {
19688
19708
  setPaymentMethodId(updatePaymentMethodResponse.data.externalId);
19689
19709
  }
19690
- if (data.subscription) {
19691
- setData({
19692
- ...data,
19710
+ setData({
19711
+ ...data,
19712
+ // Optimistic update
19713
+ // If there is subscription - we have set payment method to subscription
19714
+ ...data.subscription ? {
19693
19715
  subscription: {
19694
19716
  ...data.subscription,
19695
19717
  paymentMethod: updatePaymentMethodResponse.data
19696
19718
  }
19697
- });
19698
- }
19719
+ } : {},
19720
+ ...data.company ? {
19721
+ company: {
19722
+ ...data.company,
19723
+ paymentMethods: [
19724
+ updatePaymentMethodResponse.data,
19725
+ ...data.company?.paymentMethods || []
19726
+ ],
19727
+ // Optimistic update
19728
+ // If there is no subscription - we have updated default payment method in company
19729
+ ...data.subscription ? {} : {
19730
+ defaultPaymentMethod: updatePaymentMethodResponse.data
19731
+ }
19732
+ }
19733
+ } : {}
19734
+ });
19699
19735
  } catch {
19700
19736
  setError(t2("Error updating payment method. Please try again."));
19701
19737
  } finally {
@@ -19931,7 +19967,7 @@ var PlanManager = (0, import_react39.forwardRef)(({ children, className, portal,
19931
19967
  const isTrialSubscription = billingSubscription?.status === "trialing";
19932
19968
  const willSubscriptionCancel = billingSubscription?.cancelAtPeriodEnd;
19933
19969
  const isUsageBasedPlan = currentPlan?.planPrice === 0 && usageBasedEntitlements.length > 0;
19934
- const headerPriceFontStyle = isUsageBasedPlan ? theme.typography.heading3 : theme.typography[props.header.price.fontStyle];
19970
+ const headerPriceFontStyle = isUsageBasedPlan ? "heading3" : props.header.price.fontStyle;
19935
19971
  return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(import_jsx_runtime35.Fragment, { children: [
19936
19972
  isTrialSubscription && !willSubscriptionCancel ? /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
19937
19973
  Notice,
@@ -19943,32 +19979,12 @@ var PlanManager = (0, import_react39.forwardRef)(({ children, className, portal,
19943
19979
  $textAlign: "center",
19944
19980
  $backgroundColor: isLightBackground ? darken(theme.card.background, 0.04) : lighten(theme.card.background, 0.04),
19945
19981
  children: [
19946
- /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
19947
- Text,
19948
- {
19949
- as: "h3",
19950
- $font: theme.typography.heading3.fontFamily,
19951
- $size: theme.typography.heading3.fontSize,
19952
- $weight: theme.typography.heading3.fontWeight,
19953
- $color: theme.typography.heading3.color,
19954
- children: t2("Trial ends in", { days: trialEndDays.toString() })
19955
- }
19956
- ),
19957
- /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
19958
- Text,
19959
- {
19960
- as: "p",
19961
- $font: theme.typography.text.fontFamily,
19962
- $size: 0.8125 * theme.typography.text.fontSize,
19963
- $weight: theme.typography.text.fontWeight,
19964
- $color: theme.typography.text.color,
19965
- children: data.trialPaymentMethodRequired ? t2("After the trial, subscribe") : defaultPlan ? t2("After the trial, cancel", {
19966
- defaultPlanName: defaultPlan?.name
19967
- }) : t2("After the trial, cancel no default", {
19968
- planName: currentPlan?.name
19969
- })
19970
- }
19971
- )
19982
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Text, { as: "h3", display: "heading3", children: t2("Trial ends in", { days: trialEndDays.toString() }) }),
19983
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Text, { as: "p", $size: 0.8125 * theme.typography.text.fontSize, children: data.trialPaymentMethodRequired ? t2("After the trial, subscribe") : defaultPlan ? t2("After the trial, cancel", {
19984
+ defaultPlanName: defaultPlan?.name
19985
+ }) : t2("After the trial, cancel no default", {
19986
+ planName: currentPlan?.name
19987
+ }) })
19972
19988
  ]
19973
19989
  }
19974
19990
  ) : willSubscriptionCancel && /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
@@ -19981,35 +19997,15 @@ var PlanManager = (0, import_react39.forwardRef)(({ children, className, portal,
19981
19997
  $textAlign: "center",
19982
19998
  $backgroundColor: isLightBackground ? darken(theme.card.background, 0.04) : lighten(theme.card.background, 0.04),
19983
19999
  children: [
19984
- /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
19985
- Text,
19986
- {
19987
- as: "h3",
19988
- $font: theme.typography.heading3.fontFamily,
19989
- $size: theme.typography.heading3.fontSize,
19990
- $weight: theme.typography.heading3.fontWeight,
19991
- $color: theme.typography.heading3.color,
19992
- children: t2("Subscription canceled")
19993
- }
19994
- ),
19995
- billingSubscription?.cancelAt && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
19996
- Text,
19997
- {
19998
- as: "p",
19999
- $font: theme.typography.text.fontFamily,
20000
- $size: 0.8125 * theme.typography.text.fontSize,
20001
- $weight: theme.typography.text.fontWeight,
20002
- $color: theme.typography.text.color,
20003
- children: t2("Access to plan will end on", {
20004
- date: toPrettyDate(
20005
- new Date(billingSubscription.cancelAt * 1e3),
20006
- {
20007
- month: "numeric"
20008
- }
20009
- )
20010
- })
20011
- }
20012
- )
20000
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Text, { as: "h3", display: "heading3", children: t2("Subscription canceled") }),
20001
+ billingSubscription?.cancelAt && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Text, { as: "p", $size: 0.8125 * theme.typography.text.fontSize, children: t2("Access to plan will end on", {
20002
+ date: toPrettyDate(
20003
+ new Date(billingSubscription.cancelAt * 1e3),
20004
+ {
20005
+ month: "numeric"
20006
+ }
20007
+ )
20008
+ }) })
20013
20009
  ]
20014
20010
  }
20015
20011
  ),
@@ -20031,57 +20027,18 @@ var PlanManager = (0, import_react39.forwardRef)(({ children, className, portal,
20031
20027
  $gap: "1rem",
20032
20028
  children: [
20033
20029
  /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(Flex, { $flexDirection: "column", $gap: "1rem", children: [
20034
- /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
20035
- Text,
20036
- {
20037
- as: Box,
20038
- $font: theme.typography[props.header.title.fontStyle].fontFamily,
20039
- $size: theme.typography[props.header.title.fontStyle].fontSize,
20040
- $weight: theme.typography[props.header.title.fontStyle].fontWeight,
20041
- $color: theme.typography[props.header.title.fontStyle].color,
20042
- $leading: 1,
20043
- children: currentPlan.name
20044
- }
20045
- ),
20046
- props.header.description.isVisible && currentPlan.description && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
20047
- Text,
20048
- {
20049
- as: Box,
20050
- $font: theme.typography[props.header.description.fontStyle].fontFamily,
20051
- $size: theme.typography[props.header.description.fontStyle].fontSize,
20052
- $weight: theme.typography[props.header.description.fontStyle].fontWeight,
20053
- $color: theme.typography[props.header.description.fontStyle].color,
20054
- children: currentPlan.description
20055
- }
20056
- )
20030
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Text, { display: props.header.title.fontStyle, $leading: 1, children: currentPlan.name }),
20031
+ props.header.description.isVisible && currentPlan.description && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Text, { display: props.header.description.fontStyle, children: currentPlan.description })
20057
20032
  ] }),
20058
20033
  props.header.price.isVisible && typeof currentPlan.planPrice === "number" && currentPlan.planPeriod && /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(Box, { children: [
20059
- /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
20060
- Text,
20061
- {
20062
- $font: headerPriceFontStyle.fontFamily,
20063
- $size: headerPriceFontStyle.fontSize,
20064
- $weight: headerPriceFontStyle.fontWeight,
20065
- $color: headerPriceFontStyle.color,
20066
- children: isUsageBasedPlan ? t2("Usage-based") : formatCurrency(
20067
- currentPlan.planPrice,
20068
- subscriptionCurrency
20069
- )
20070
- }
20071
- ),
20072
- !isUsageBasedPlan && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
20073
- Text,
20074
- {
20075
- $font: theme.typography[props.header.price.fontStyle].fontFamily,
20076
- $size: theme.typography[props.header.price.fontStyle].fontSize,
20077
- $weight: theme.typography[props.header.price.fontStyle].fontWeight,
20078
- $color: theme.typography[props.header.price.fontStyle].color,
20079
- children: /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("sub", { children: [
20080
- "/",
20081
- shortenPeriod(currentPlan.planPeriod)
20082
- ] })
20083
- }
20084
- )
20034
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Text, { display: headerPriceFontStyle, children: isUsageBasedPlan ? t2("Usage-based") : formatCurrency(
20035
+ currentPlan.planPrice,
20036
+ subscriptionCurrency
20037
+ ) }),
20038
+ !isUsageBasedPlan && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Text, { display: props.header.price.fontStyle, children: /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("sub", { children: [
20039
+ "/",
20040
+ shortenPeriod(currentPlan.planPeriod)
20041
+ ] }) })
20085
20042
  ] })
20086
20043
  ]
20087
20044
  }
@@ -20090,9 +20047,6 @@ var PlanManager = (0, import_react39.forwardRef)(({ children, className, portal,
20090
20047
  props.addOns.showLabel && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
20091
20048
  Text,
20092
20049
  {
20093
- $font: theme.typography.text.fontFamily,
20094
- $size: theme.typography.text.fontSize,
20095
- $weight: theme.typography.text.fontWeight,
20096
20050
  $color: isLightBackground ? darken(theme.card.background, 0.46) : lighten(theme.card.background, 0.46),
20097
20051
  $leading: 1,
20098
20052
  children: t2("Add-ons")
@@ -20106,32 +20060,14 @@ var PlanManager = (0, import_react39.forwardRef)(({ children, className, portal,
20106
20060
  $flexWrap: "wrap",
20107
20061
  $gap: "1rem",
20108
20062
  children: [
20109
- /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
20110
- Text,
20111
- {
20112
- $font: theme.typography[props.addOns.fontStyle].fontFamily,
20113
- $size: theme.typography[props.addOns.fontStyle].fontSize,
20114
- $weight: theme.typography[props.addOns.fontStyle].fontWeight,
20115
- $color: theme.typography[props.addOns.fontStyle].color,
20116
- children: addOn.name
20117
- }
20118
- ),
20119
- addOn.planPrice && addOn.planPeriod && /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
20120
- Text,
20121
- {
20122
- $font: theme.typography.text.fontFamily,
20123
- $size: theme.typography.text.fontSize,
20124
- $weight: theme.typography.text.fontWeight,
20125
- $color: theme.typography.text.color,
20126
- children: [
20127
- formatCurrency(addOn.planPrice, subscriptionCurrency),
20128
- /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("sub", { children: [
20129
- "/",
20130
- shortenPeriod(addOn.planPeriod)
20131
- ] })
20132
- ]
20133
- }
20134
- )
20063
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Text, { display: props.addOns.fontStyle, children: addOn.name }),
20064
+ addOn.planPrice && addOn.planPeriod && /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(Text, { children: [
20065
+ formatCurrency(addOn.planPrice, subscriptionCurrency),
20066
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("sub", { children: [
20067
+ "/",
20068
+ shortenPeriod(addOn.planPeriod)
20069
+ ] })
20070
+ ] })
20135
20071
  ]
20136
20072
  },
20137
20073
  addOnIndex
@@ -20141,9 +20077,6 @@ var PlanManager = (0, import_react39.forwardRef)(({ children, className, portal,
20141
20077
  /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
20142
20078
  Text,
20143
20079
  {
20144
- $font: theme.typography.text.fontFamily,
20145
- $size: theme.typography.text.fontSize,
20146
- $weight: theme.typography.text.fontWeight,
20147
20080
  $color: isLightBackground ? darken(theme.card.background, 0.46) : lighten(theme.card.background, 0.46),
20148
20081
  $leading: 1,
20149
20082
  children: t2("Usage-based")
@@ -20164,33 +20097,22 @@ var PlanManager = (0, import_react39.forwardRef)(({ children, className, portal,
20164
20097
  $flexWrap: "wrap",
20165
20098
  $gap: "1rem",
20166
20099
  children: [
20167
- /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
20168
- Text,
20169
- {
20170
- $font: theme.typography[props.addOns.fontStyle].fontFamily,
20171
- $size: theme.typography[props.addOns.fontStyle].fontSize,
20172
- $weight: theme.typography[props.addOns.fontStyle].fontWeight,
20173
- $color: theme.typography[props.addOns.fontStyle].color,
20174
- children: [
20175
- entitlement.priceBehavior === "pay_in_advance" || entitlement.priceBehavior === "overage" && limit > 0 ? /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(import_jsx_runtime35.Fragment, { children: [
20176
- limit,
20177
- " ",
20178
- getFeatureName(entitlement.feature, limit)
20179
- ] }) : entitlement.feature.name,
20180
- entitlement.priceBehavior === "overage" && entitlement.feature.featureType === "event" && currentPlan?.planPeriod && /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(import_jsx_runtime35.Fragment, { children: [
20181
- "/",
20182
- shortenPeriod(currentPlan.planPeriod)
20183
- ] })
20184
- ]
20185
- }
20186
- ),
20100
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(Text, { display: props.addOns.fontStyle, children: [
20101
+ entitlement.priceBehavior === "pay_in_advance" || entitlement.priceBehavior === "overage" && limit > 0 ? /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(import_jsx_runtime35.Fragment, { children: [
20102
+ limit,
20103
+ " ",
20104
+ getFeatureName(entitlement.feature, limit)
20105
+ ] }) : entitlement.feature.name,
20106
+ entitlement.priceBehavior === "overage" && entitlement.feature.featureType === "event" && currentPlan?.planPeriod && /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(import_jsx_runtime35.Fragment, { children: [
20107
+ "/",
20108
+ shortenPeriod(currentPlan.planPeriod)
20109
+ ] })
20110
+ ] }),
20187
20111
  /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(Flex, { $alignItems: "center", $gap: "1rem", children: [
20188
20112
  entitlement.priceBehavior === "overage" && currentPlan?.planPeriod ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
20189
20113
  Text,
20190
20114
  {
20191
- $font: theme.typography.text.fontFamily,
20192
20115
  $size: 0.875 * theme.typography.text.fontSize,
20193
- $weight: theme.typography.text.fontWeight,
20194
20116
  $color: hexToHSL(theme.typography.text.color).l > 50 ? darken(theme.typography.text.color, 0.46) : lighten(theme.typography.text.color, 0.46),
20195
20117
  children: typeof overageAmount === "number" && overageAmount > 0 ? t2("X over the limit", {
20196
20118
  amount: overageAmount
@@ -20215,9 +20137,7 @@ var PlanManager = (0, import_react39.forwardRef)(({ children, className, portal,
20215
20137
  ) : entitlement.priceBehavior === "pay_in_advance" && currentPlan?.planPeriod && /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
20216
20138
  Text,
20217
20139
  {
20218
- $font: theme.typography.text.fontFamily,
20219
20140
  $size: 0.875 * theme.typography.text.fontSize,
20220
- $weight: theme.typography.text.fontWeight,
20221
20141
  $color: hexToHSL(theme.typography.text.color).l > 50 ? darken(theme.typography.text.color, 0.46) : lighten(theme.typography.text.color, 0.46),
20222
20142
  children: [
20223
20143
  formatCurrency(
@@ -20233,25 +20153,16 @@ var PlanManager = (0, import_react39.forwardRef)(({ children, className, portal,
20233
20153
  ]
20234
20154
  }
20235
20155
  ),
20236
- amount > 0 && /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
20237
- Text,
20238
- {
20239
- $font: theme.typography.text.fontFamily,
20240
- $size: theme.typography.text.fontSize,
20241
- $weight: theme.typography.text.fontWeight,
20242
- $color: theme.typography.text.color,
20243
- children: [
20244
- formatCurrency(
20245
- (entitlement.price ?? 0) * amount,
20246
- entitlement.currency
20247
- ),
20248
- (entitlement.priceBehavior === "pay_in_advance" || entitlement.priceBehavior !== "overage") && /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("sub", { children: [
20249
- "/",
20250
- currentPlan?.planPeriod && entitlement.priceBehavior === "pay_in_advance" ? shortenPeriod(currentPlan.planPeriod) : getFeatureName(entitlement.feature, 1)
20251
- ] })
20252
- ]
20253
- }
20254
- )
20156
+ amount > 0 && /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(Text, { children: [
20157
+ formatCurrency(
20158
+ (entitlement.price ?? 0) * amount,
20159
+ entitlement.currency
20160
+ ),
20161
+ (entitlement.priceBehavior === "pay_in_advance" || entitlement.priceBehavior !== "overage") && /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("sub", { children: [
20162
+ "/",
20163
+ currentPlan?.planPeriod && entitlement.priceBehavior === "pay_in_advance" ? shortenPeriod(currentPlan.planPeriod) : getFeatureName(entitlement.feature, 1)
20164
+ ] })
20165
+ ] })
20255
20166
  ] })
20256
20167
  ]
20257
20168
  },
@@ -268,6 +268,12 @@ declare interface BillingProductDetailResponseData {
268
268
  * @memberof BillingProductDetailResponseData
269
269
  */
270
270
  externalId: string;
271
+ /**
272
+ *
273
+ * @type {boolean}
274
+ * @memberof BillingProductDetailResponseData
275
+ */
276
+ isActive: boolean;
271
277
  /**
272
278
  *
273
279
  * @type {string}
@@ -524,6 +530,12 @@ declare interface BillingProductResponseData {
524
530
  * @memberof BillingProductResponseData
525
531
  */
526
532
  externalId: string;
533
+ /**
534
+ *
535
+ * @type {boolean}
536
+ * @memberof BillingProductResponseData
537
+ */
538
+ isActive: boolean;
527
539
  /**
528
540
  *
529
541
  * @type {string}
@@ -1190,6 +1202,12 @@ declare interface CompanyDetailResponseData {
1190
1202
  * @memberof CompanyDetailResponseData
1191
1203
  */
1192
1204
  createdAt: Date;
1205
+ /**
1206
+ *
1207
+ * @type {PaymentMethodResponseData}
1208
+ * @memberof CompanyDetailResponseData
1209
+ */
1210
+ defaultPaymentMethod?: PaymentMethodResponseData;
1193
1211
  /**
1194
1212
  *
1195
1213
  * @type {Array<EntityTraitDetailResponseData>}
@@ -4722,23 +4740,24 @@ portal?: HTMLElement | null;
4722
4740
  export declare type TextElementProps = DesignProps_8;
4723
4741
 
4724
4742
  export declare enum TextPropNames {
4725
- Align = "$align",
4726
4743
  Font = "$font",
4727
4744
  Size = "$size",
4728
4745
  Weight = "$weight",
4729
4746
  Color = "$color",
4730
- Leading = "$leading"
4747
+ Leading = "$leading",
4748
+ Align = "$align"
4731
4749
  }
4732
4750
 
4733
4751
  export declare type TextPropNameTypes = `${TextPropNames}`;
4734
4752
 
4735
4753
  export declare interface TextProps {
4736
- $align?: ComponentProps["$textAlign"];
4754
+ display?: FontStyle;
4737
4755
  $font?: ComponentProps["$fontFamily"];
4738
4756
  $size?: ComponentProps["$fontSize"];
4739
4757
  $weight?: ComponentProps["$fontWeight"];
4740
4758
  $color?: ComponentProps["$color"];
4741
4759
  $leading?: ComponentProps["$lineHeight"];
4760
+ $align?: ComponentProps["$textAlign"];
4742
4761
  }
4743
4762
 
4744
4763
  export declare const Tooltip: ({ trigger, content, position, zIndex, ...rest }: TooltipProps) => JSX.Element;
@@ -10741,6 +10741,7 @@ function BillingProductDetailResponseDataFromJSONTyped(json, ignoreDiscriminator
10741
10741
  currency: json["currency"],
10742
10742
  environmentId: json["environment_id"],
10743
10743
  externalId: json["external_id"],
10744
+ isActive: json["is_active"],
10744
10745
  name: json["name"],
10745
10746
  price: json["price"],
10746
10747
  priceDecimal: json["price_decimal"] == null ? void 0 : json["price_decimal"],
@@ -10800,6 +10801,7 @@ function BillingProductResponseDataFromJSONTyped(json, ignoreDiscriminator) {
10800
10801
  currency: json["currency"],
10801
10802
  environmentId: json["environment_id"],
10802
10803
  externalId: json["external_id"],
10804
+ isActive: json["is_active"],
10803
10805
  name: json["name"],
10804
10806
  price: json["price"],
10805
10807
  priceDecimal: json["price_decimal"] == null ? void 0 : json["price_decimal"],
@@ -11196,6 +11198,7 @@ function CompanyDetailResponseDataFromJSONTyped(json, ignoreDiscriminator) {
11196
11198
  BillingSubscriptionViewFromJSON
11197
11199
  ),
11198
11200
  createdAt: new Date(json["created_at"]),
11201
+ defaultPaymentMethod: json["default_payment_method"] == null ? void 0 : PaymentMethodResponseDataFromJSON(json["default_payment_method"]),
11199
11202
  entityTraits: json["entity_traits"].map(
11200
11203
  EntityTraitDetailResponseDataFromJSON
11201
11204
  ),
@@ -13137,7 +13140,7 @@ var EmbedProvider = ({
13137
13140
  useEffect2(() => {
13138
13141
  if (accessToken) {
13139
13142
  const { headers = {} } = apiConfig ?? {};
13140
- headers["X-Schematic-Components-Version"] = "0.7.4";
13143
+ headers["X-Schematic-Components-Version"] = "0.7.6";
13141
13144
  headers["X-Schematic-Session-ID"] = sessionIdRef.current;
13142
13145
  const config = new Configuration({
13143
13146
  ...apiConfig,
@@ -14394,43 +14397,61 @@ var ProgressBar = ({
14394
14397
 
14395
14398
  // src/components/ui/text/styles.ts
14396
14399
  var TextPropNames = /* @__PURE__ */ ((TextPropNames2) => {
14397
- TextPropNames2["Align"] = "$align";
14398
14400
  TextPropNames2["Font"] = "$font";
14399
14401
  TextPropNames2["Size"] = "$size";
14400
14402
  TextPropNames2["Weight"] = "$weight";
14401
14403
  TextPropNames2["Color"] = "$color";
14402
14404
  TextPropNames2["Leading"] = "$leading";
14405
+ TextPropNames2["Align"] = "$align";
14403
14406
  return TextPropNames2;
14404
14407
  })(TextPropNames || {});
14405
- var Text = dt.span.attrs(({ onClick }) => ({
14408
+ var Text = dt.span.withConfig({
14409
+ shouldForwardProp: (prop) => prop !== "display"
14410
+ }).attrs(({ onClick }) => ({
14406
14411
  ...onClick && { tabIndex: 0 }
14407
- }))`
14408
- ${({ $font }) => $font && lt`
14409
- font-family: ${$font}, sans-serif;
14410
- `};
14411
- ${({ $size }) => typeof $size !== "undefined" && lt`
14412
- font-size: ${typeof $size === "number" ? `${$size / TEXT_BASE_SIZE}rem` : $size};
14413
- `};
14414
- ${({ $weight }) => typeof $weight !== "undefined" && lt`
14415
- font-weight: ${$weight};
14416
- font-variation-settings: "wght" ${$weight};
14417
- `};
14418
- ${({ $leading }) => attr("line-height", $leading)};
14419
- ${({ $align }) => attr("text-align", $align)};
14420
- color: ${({ $color, theme }) => $color || theme.typography.text.color};
14421
-
14422
- &:focus-visible {
14423
- outline: 2px solid ${({ theme }) => theme.primary};
14424
- outline-offset: 2px;
14425
- }
14426
-
14427
- ${({ onClick }) => onClick && lt`
14428
- &:hover {
14429
- cursor: pointer;
14430
- text-decoration: underline;
14412
+ }))(
14413
+ ({
14414
+ display = "text",
14415
+ theme,
14416
+ onClick,
14417
+ $font,
14418
+ $size,
14419
+ $weight,
14420
+ $color,
14421
+ $leading = 1.35,
14422
+ $align
14423
+ }) => {
14424
+ const settings = theme.typography[display];
14425
+ const fontFamily = $font || settings.fontFamily;
14426
+ const fontSize = $size || settings.fontSize;
14427
+ const fontWeight = $weight || settings.fontWeight;
14428
+ const color = $color || settings.color;
14429
+ return lt`
14430
+ font-family: ${fontFamily}, sans-serif;
14431
+ font-size: ${typeof fontSize === "number" ? `${fontSize / TEXT_BASE_SIZE}rem` : fontSize};
14432
+ font-weight: ${fontWeight};
14433
+ font-variation-settings: "wght" ${fontWeight};
14434
+ line-height: ${$leading};
14435
+ color: ${color};
14436
+
14437
+ ${$align && lt`
14438
+ text-align: ${$align};
14439
+ `};
14440
+
14441
+ ${onClick && lt`
14442
+ &:hover {
14443
+ cursor: pointer;
14444
+ text-decoration: underline;
14445
+ }
14446
+ `}
14447
+
14448
+ &:focus-visible {
14449
+ outline: 2px solid ${({ theme: theme2 }) => theme2.primary};
14450
+ outline-offset: 2px;
14431
14451
  }
14432
- `}
14433
- `;
14452
+ `;
14453
+ }
14454
+ );
14434
14455
 
14435
14456
  // src/components/ui/tooltip/Tooltip.tsx
14436
14457
  var import_debounce = __toESM(require_debounce());
@@ -14717,7 +14738,7 @@ var Container2 = dt.div`
14717
14738
  all: initial;
14718
14739
  box-sizing: border-box;
14719
14740
  display: block;
14720
- font-size: ${TEXT_BASE_SIZE}px;
14741
+ font-size: 1rem;
14721
14742
  line-height: 1.35;
14722
14743
  width: 100%;
14723
14744
  height: 100%;
@@ -14784,6 +14805,7 @@ var StageButton = ({
14784
14805
  checkoutStages,
14785
14806
  hasAddOns,
14786
14807
  hasPayInAdvanceEntitlements,
14808
+ hasUnstagedChanges,
14787
14809
  isLoading,
14788
14810
  requiresPayment,
14789
14811
  setCheckoutStage,
@@ -14795,7 +14817,7 @@ var StageButton = ({
14795
14817
  EmbedButton,
14796
14818
  {
14797
14819
  type: "button",
14798
- disabled: isLoading || !canUpdateSubscription,
14820
+ disabled: isLoading || !hasUnstagedChanges || !canUpdateSubscription,
14799
14821
  onClick: checkout,
14800
14822
  isLoading,
14801
14823
  children: t2("Subscribe and close")
@@ -14836,7 +14858,7 @@ var StageButton = ({
14836
14858
  EmbedButton,
14837
14859
  {
14838
14860
  type: "button",
14839
- disabled: !canUpdateSubscription,
14861
+ disabled: !hasUnstagedChanges || !canUpdateSubscription,
14840
14862
  onClick: async () => {
14841
14863
  checkout();
14842
14864
  },
@@ -14962,7 +14984,7 @@ var StageButton = ({
14962
14984
  EmbedButton,
14963
14985
  {
14964
14986
  type: "button",
14965
- disabled: isLoading || !canCheckout,
14987
+ disabled: isLoading || !hasUnstagedChanges || !canCheckout,
14966
14988
  onClick: checkout,
14967
14989
  isLoading,
14968
14990
  children: canTrial ? t2("Start trial") : t2("Pay now")
@@ -15166,14 +15188,6 @@ var Sidebar = ({
15166
15188
  }
15167
15189
  }, [t2, api, hydrate, setError, setIsLoading, setLayout]);
15168
15190
  const selectedAddOns = addOns.filter((addOn) => addOn.isSelected);
15169
- const willPlanChange = typeof selectedPlan !== "undefined" && !selectedPlan.current;
15170
- const canUpdateSubscription = mode === "edit" || api !== null && (willPlanChange || // TODO: test add-on comparison for finding "changes"
15171
- selectedAddOns.length !== currentAddOns.length || !selectedAddOns.every(
15172
- (addOn) => currentAddOns.some((currentAddOn) => addOn.id === currentAddOn.id)
15173
- ) || payInAdvanceEntitlements.every(
15174
- ({ quantity, usage }) => quantity >= usage
15175
- )) && !isLoading;
15176
- const canCheckout = canUpdateSubscription && (!!data.subscription?.paymentMethod || typeof paymentMethodId === "string");
15177
15191
  const {
15178
15192
  changedUsageBasedEntitlements,
15179
15193
  addedUsageBasedEntitlements,
@@ -15230,6 +15244,7 @@ var Sidebar = ({
15230
15244
  currentUsageBasedEntitlements,
15231
15245
  usageBasedEntitlements
15232
15246
  ]);
15247
+ const willPlanChange = typeof selectedPlan !== "undefined" && !selectedPlan.current;
15233
15248
  const removedAddOns = currentAddOns.filter(
15234
15249
  (current) => !selectedAddOns.some((selected) => current.id === selected.id)
15235
15250
  );
@@ -15237,6 +15252,10 @@ var Sidebar = ({
15237
15252
  (selected) => !currentAddOns.some((current) => selected.id === current.id)
15238
15253
  );
15239
15254
  const willAddOnsChange = removedAddOns.length > 0 || addedAddOns.length > 0;
15255
+ const willPayInAdvanceEntitlementsChange = payInAdvanceEntitlements.length > 0 && payInAdvanceEntitlements.some(({ quantity, usage }) => quantity !== usage);
15256
+ const hasUnstagedChanges = willPlanChange || willAddOnsChange || willPayInAdvanceEntitlementsChange;
15257
+ const canUpdateSubscription = mode === "edit" || api !== null && !isLoading;
15258
+ const canCheckout = canUpdateSubscription && (!!data.subscription?.paymentMethod || typeof paymentMethodId === "string");
15240
15259
  const isTrialable = selectedPlan?.companyCanTrial;
15241
15260
  const today = /* @__PURE__ */ new Date();
15242
15261
  const trialEndsOn = new Date(today);
@@ -16148,6 +16167,7 @@ var Sidebar = ({
16148
16167
  checkoutStages,
16149
16168
  hasAddOns: addOns.length > 0,
16150
16169
  hasPayInAdvanceEntitlements: payInAdvanceEntitlements.length > 0,
16170
+ hasUnstagedChanges,
16151
16171
  isLoading,
16152
16172
  requiresPayment,
16153
16173
  setCheckoutStage,
@@ -19529,8 +19549,8 @@ var PaymentMethod = forwardRef11(({ children, className, portal, allowEdit = tru
19529
19549
  const props = resolveDesignProps5(rest);
19530
19550
  const { data, setLayout } = useEmbed();
19531
19551
  const paymentMethod = useMemo12(() => {
19532
- return data.subscription?.paymentMethod;
19533
- }, [data.subscription?.paymentMethod]);
19552
+ return data.subscription?.paymentMethod || data.company?.defaultPaymentMethod;
19553
+ }, [data.company?.defaultPaymentMethod, data.subscription?.paymentMethod]);
19534
19554
  const monthsToExpiration = useMemo12(() => {
19535
19555
  let expiration;
19536
19556
  if (typeof paymentMethod?.cardExpYear === "number" && typeof paymentMethod?.cardExpMonth === "number") {
@@ -19588,10 +19608,10 @@ var PaymentMethodDetails = ({
19588
19608
  const [showDifferentPaymentMethods, setShowDifferentPaymentMethods] = useState14(false);
19589
19609
  const [paymentMethod, setPaymentMethod] = useState14(void 0);
19590
19610
  useEffect7(() => {
19591
- if (data.subscription?.paymentMethod) {
19592
- setPaymentMethod(data.subscription.paymentMethod);
19593
- }
19594
- }, [data.subscription?.paymentMethod]);
19611
+ setPaymentMethod(
19612
+ data.subscription?.paymentMethod || data.company?.defaultPaymentMethod
19613
+ );
19614
+ }, [data.company?.defaultPaymentMethod, data.subscription?.paymentMethod]);
19595
19615
  const monthsToExpiration = useMemo13(() => {
19596
19616
  let expiration;
19597
19617
  if (typeof paymentMethod?.cardExpYear === "number" && typeof paymentMethod?.cardExpMonth === "number") {
@@ -19648,15 +19668,31 @@ var PaymentMethodDetails = ({
19648
19668
  if (setPaymentMethodId) {
19649
19669
  setPaymentMethodId(updatePaymentMethodResponse.data.externalId);
19650
19670
  }
19651
- if (data.subscription) {
19652
- setData({
19653
- ...data,
19671
+ setData({
19672
+ ...data,
19673
+ // Optimistic update
19674
+ // If there is subscription - we have set payment method to subscription
19675
+ ...data.subscription ? {
19654
19676
  subscription: {
19655
19677
  ...data.subscription,
19656
19678
  paymentMethod: updatePaymentMethodResponse.data
19657
19679
  }
19658
- });
19659
- }
19680
+ } : {},
19681
+ ...data.company ? {
19682
+ company: {
19683
+ ...data.company,
19684
+ paymentMethods: [
19685
+ updatePaymentMethodResponse.data,
19686
+ ...data.company?.paymentMethods || []
19687
+ ],
19688
+ // Optimistic update
19689
+ // If there is no subscription - we have updated default payment method in company
19690
+ ...data.subscription ? {} : {
19691
+ defaultPaymentMethod: updatePaymentMethodResponse.data
19692
+ }
19693
+ }
19694
+ } : {}
19695
+ });
19660
19696
  } catch {
19661
19697
  setError(t2("Error updating payment method. Please try again."));
19662
19698
  } finally {
@@ -19892,7 +19928,7 @@ var PlanManager = forwardRef12(({ children, className, portal, ...rest }, ref) =
19892
19928
  const isTrialSubscription = billingSubscription?.status === "trialing";
19893
19929
  const willSubscriptionCancel = billingSubscription?.cancelAtPeriodEnd;
19894
19930
  const isUsageBasedPlan = currentPlan?.planPrice === 0 && usageBasedEntitlements.length > 0;
19895
- const headerPriceFontStyle = isUsageBasedPlan ? theme.typography.heading3 : theme.typography[props.header.price.fontStyle];
19931
+ const headerPriceFontStyle = isUsageBasedPlan ? "heading3" : props.header.price.fontStyle;
19896
19932
  return /* @__PURE__ */ jsxs27(Fragment11, { children: [
19897
19933
  isTrialSubscription && !willSubscriptionCancel ? /* @__PURE__ */ jsxs27(
19898
19934
  Notice,
@@ -19904,32 +19940,12 @@ var PlanManager = forwardRef12(({ children, className, portal, ...rest }, ref) =
19904
19940
  $textAlign: "center",
19905
19941
  $backgroundColor: isLightBackground ? darken(theme.card.background, 0.04) : lighten(theme.card.background, 0.04),
19906
19942
  children: [
19907
- /* @__PURE__ */ jsx35(
19908
- Text,
19909
- {
19910
- as: "h3",
19911
- $font: theme.typography.heading3.fontFamily,
19912
- $size: theme.typography.heading3.fontSize,
19913
- $weight: theme.typography.heading3.fontWeight,
19914
- $color: theme.typography.heading3.color,
19915
- children: t2("Trial ends in", { days: trialEndDays.toString() })
19916
- }
19917
- ),
19918
- /* @__PURE__ */ jsx35(
19919
- Text,
19920
- {
19921
- as: "p",
19922
- $font: theme.typography.text.fontFamily,
19923
- $size: 0.8125 * theme.typography.text.fontSize,
19924
- $weight: theme.typography.text.fontWeight,
19925
- $color: theme.typography.text.color,
19926
- children: data.trialPaymentMethodRequired ? t2("After the trial, subscribe") : defaultPlan ? t2("After the trial, cancel", {
19927
- defaultPlanName: defaultPlan?.name
19928
- }) : t2("After the trial, cancel no default", {
19929
- planName: currentPlan?.name
19930
- })
19931
- }
19932
- )
19943
+ /* @__PURE__ */ jsx35(Text, { as: "h3", display: "heading3", children: t2("Trial ends in", { days: trialEndDays.toString() }) }),
19944
+ /* @__PURE__ */ jsx35(Text, { as: "p", $size: 0.8125 * theme.typography.text.fontSize, children: data.trialPaymentMethodRequired ? t2("After the trial, subscribe") : defaultPlan ? t2("After the trial, cancel", {
19945
+ defaultPlanName: defaultPlan?.name
19946
+ }) : t2("After the trial, cancel no default", {
19947
+ planName: currentPlan?.name
19948
+ }) })
19933
19949
  ]
19934
19950
  }
19935
19951
  ) : willSubscriptionCancel && /* @__PURE__ */ jsxs27(
@@ -19942,35 +19958,15 @@ var PlanManager = forwardRef12(({ children, className, portal, ...rest }, ref) =
19942
19958
  $textAlign: "center",
19943
19959
  $backgroundColor: isLightBackground ? darken(theme.card.background, 0.04) : lighten(theme.card.background, 0.04),
19944
19960
  children: [
19945
- /* @__PURE__ */ jsx35(
19946
- Text,
19947
- {
19948
- as: "h3",
19949
- $font: theme.typography.heading3.fontFamily,
19950
- $size: theme.typography.heading3.fontSize,
19951
- $weight: theme.typography.heading3.fontWeight,
19952
- $color: theme.typography.heading3.color,
19953
- children: t2("Subscription canceled")
19954
- }
19955
- ),
19956
- billingSubscription?.cancelAt && /* @__PURE__ */ jsx35(
19957
- Text,
19958
- {
19959
- as: "p",
19960
- $font: theme.typography.text.fontFamily,
19961
- $size: 0.8125 * theme.typography.text.fontSize,
19962
- $weight: theme.typography.text.fontWeight,
19963
- $color: theme.typography.text.color,
19964
- children: t2("Access to plan will end on", {
19965
- date: toPrettyDate(
19966
- new Date(billingSubscription.cancelAt * 1e3),
19967
- {
19968
- month: "numeric"
19969
- }
19970
- )
19971
- })
19972
- }
19973
- )
19961
+ /* @__PURE__ */ jsx35(Text, { as: "h3", display: "heading3", children: t2("Subscription canceled") }),
19962
+ billingSubscription?.cancelAt && /* @__PURE__ */ jsx35(Text, { as: "p", $size: 0.8125 * theme.typography.text.fontSize, children: t2("Access to plan will end on", {
19963
+ date: toPrettyDate(
19964
+ new Date(billingSubscription.cancelAt * 1e3),
19965
+ {
19966
+ month: "numeric"
19967
+ }
19968
+ )
19969
+ }) })
19974
19970
  ]
19975
19971
  }
19976
19972
  ),
@@ -19992,57 +19988,18 @@ var PlanManager = forwardRef12(({ children, className, portal, ...rest }, ref) =
19992
19988
  $gap: "1rem",
19993
19989
  children: [
19994
19990
  /* @__PURE__ */ jsxs27(Flex, { $flexDirection: "column", $gap: "1rem", children: [
19995
- /* @__PURE__ */ jsx35(
19996
- Text,
19997
- {
19998
- as: Box,
19999
- $font: theme.typography[props.header.title.fontStyle].fontFamily,
20000
- $size: theme.typography[props.header.title.fontStyle].fontSize,
20001
- $weight: theme.typography[props.header.title.fontStyle].fontWeight,
20002
- $color: theme.typography[props.header.title.fontStyle].color,
20003
- $leading: 1,
20004
- children: currentPlan.name
20005
- }
20006
- ),
20007
- props.header.description.isVisible && currentPlan.description && /* @__PURE__ */ jsx35(
20008
- Text,
20009
- {
20010
- as: Box,
20011
- $font: theme.typography[props.header.description.fontStyle].fontFamily,
20012
- $size: theme.typography[props.header.description.fontStyle].fontSize,
20013
- $weight: theme.typography[props.header.description.fontStyle].fontWeight,
20014
- $color: theme.typography[props.header.description.fontStyle].color,
20015
- children: currentPlan.description
20016
- }
20017
- )
19991
+ /* @__PURE__ */ jsx35(Text, { display: props.header.title.fontStyle, $leading: 1, children: currentPlan.name }),
19992
+ props.header.description.isVisible && currentPlan.description && /* @__PURE__ */ jsx35(Text, { display: props.header.description.fontStyle, children: currentPlan.description })
20018
19993
  ] }),
20019
19994
  props.header.price.isVisible && typeof currentPlan.planPrice === "number" && currentPlan.planPeriod && /* @__PURE__ */ jsxs27(Box, { children: [
20020
- /* @__PURE__ */ jsx35(
20021
- Text,
20022
- {
20023
- $font: headerPriceFontStyle.fontFamily,
20024
- $size: headerPriceFontStyle.fontSize,
20025
- $weight: headerPriceFontStyle.fontWeight,
20026
- $color: headerPriceFontStyle.color,
20027
- children: isUsageBasedPlan ? t2("Usage-based") : formatCurrency(
20028
- currentPlan.planPrice,
20029
- subscriptionCurrency
20030
- )
20031
- }
20032
- ),
20033
- !isUsageBasedPlan && /* @__PURE__ */ jsx35(
20034
- Text,
20035
- {
20036
- $font: theme.typography[props.header.price.fontStyle].fontFamily,
20037
- $size: theme.typography[props.header.price.fontStyle].fontSize,
20038
- $weight: theme.typography[props.header.price.fontStyle].fontWeight,
20039
- $color: theme.typography[props.header.price.fontStyle].color,
20040
- children: /* @__PURE__ */ jsxs27("sub", { children: [
20041
- "/",
20042
- shortenPeriod(currentPlan.planPeriod)
20043
- ] })
20044
- }
20045
- )
19995
+ /* @__PURE__ */ jsx35(Text, { display: headerPriceFontStyle, children: isUsageBasedPlan ? t2("Usage-based") : formatCurrency(
19996
+ currentPlan.planPrice,
19997
+ subscriptionCurrency
19998
+ ) }),
19999
+ !isUsageBasedPlan && /* @__PURE__ */ jsx35(Text, { display: props.header.price.fontStyle, children: /* @__PURE__ */ jsxs27("sub", { children: [
20000
+ "/",
20001
+ shortenPeriod(currentPlan.planPeriod)
20002
+ ] }) })
20046
20003
  ] })
20047
20004
  ]
20048
20005
  }
@@ -20051,9 +20008,6 @@ var PlanManager = forwardRef12(({ children, className, portal, ...rest }, ref) =
20051
20008
  props.addOns.showLabel && /* @__PURE__ */ jsx35(
20052
20009
  Text,
20053
20010
  {
20054
- $font: theme.typography.text.fontFamily,
20055
- $size: theme.typography.text.fontSize,
20056
- $weight: theme.typography.text.fontWeight,
20057
20011
  $color: isLightBackground ? darken(theme.card.background, 0.46) : lighten(theme.card.background, 0.46),
20058
20012
  $leading: 1,
20059
20013
  children: t2("Add-ons")
@@ -20067,32 +20021,14 @@ var PlanManager = forwardRef12(({ children, className, portal, ...rest }, ref) =
20067
20021
  $flexWrap: "wrap",
20068
20022
  $gap: "1rem",
20069
20023
  children: [
20070
- /* @__PURE__ */ jsx35(
20071
- Text,
20072
- {
20073
- $font: theme.typography[props.addOns.fontStyle].fontFamily,
20074
- $size: theme.typography[props.addOns.fontStyle].fontSize,
20075
- $weight: theme.typography[props.addOns.fontStyle].fontWeight,
20076
- $color: theme.typography[props.addOns.fontStyle].color,
20077
- children: addOn.name
20078
- }
20079
- ),
20080
- addOn.planPrice && addOn.planPeriod && /* @__PURE__ */ jsxs27(
20081
- Text,
20082
- {
20083
- $font: theme.typography.text.fontFamily,
20084
- $size: theme.typography.text.fontSize,
20085
- $weight: theme.typography.text.fontWeight,
20086
- $color: theme.typography.text.color,
20087
- children: [
20088
- formatCurrency(addOn.planPrice, subscriptionCurrency),
20089
- /* @__PURE__ */ jsxs27("sub", { children: [
20090
- "/",
20091
- shortenPeriod(addOn.planPeriod)
20092
- ] })
20093
- ]
20094
- }
20095
- )
20024
+ /* @__PURE__ */ jsx35(Text, { display: props.addOns.fontStyle, children: addOn.name }),
20025
+ addOn.planPrice && addOn.planPeriod && /* @__PURE__ */ jsxs27(Text, { children: [
20026
+ formatCurrency(addOn.planPrice, subscriptionCurrency),
20027
+ /* @__PURE__ */ jsxs27("sub", { children: [
20028
+ "/",
20029
+ shortenPeriod(addOn.planPeriod)
20030
+ ] })
20031
+ ] })
20096
20032
  ]
20097
20033
  },
20098
20034
  addOnIndex
@@ -20102,9 +20038,6 @@ var PlanManager = forwardRef12(({ children, className, portal, ...rest }, ref) =
20102
20038
  /* @__PURE__ */ jsx35(
20103
20039
  Text,
20104
20040
  {
20105
- $font: theme.typography.text.fontFamily,
20106
- $size: theme.typography.text.fontSize,
20107
- $weight: theme.typography.text.fontWeight,
20108
20041
  $color: isLightBackground ? darken(theme.card.background, 0.46) : lighten(theme.card.background, 0.46),
20109
20042
  $leading: 1,
20110
20043
  children: t2("Usage-based")
@@ -20125,33 +20058,22 @@ var PlanManager = forwardRef12(({ children, className, portal, ...rest }, ref) =
20125
20058
  $flexWrap: "wrap",
20126
20059
  $gap: "1rem",
20127
20060
  children: [
20128
- /* @__PURE__ */ jsxs27(
20129
- Text,
20130
- {
20131
- $font: theme.typography[props.addOns.fontStyle].fontFamily,
20132
- $size: theme.typography[props.addOns.fontStyle].fontSize,
20133
- $weight: theme.typography[props.addOns.fontStyle].fontWeight,
20134
- $color: theme.typography[props.addOns.fontStyle].color,
20135
- children: [
20136
- entitlement.priceBehavior === "pay_in_advance" || entitlement.priceBehavior === "overage" && limit > 0 ? /* @__PURE__ */ jsxs27(Fragment11, { children: [
20137
- limit,
20138
- " ",
20139
- getFeatureName(entitlement.feature, limit)
20140
- ] }) : entitlement.feature.name,
20141
- entitlement.priceBehavior === "overage" && entitlement.feature.featureType === "event" && currentPlan?.planPeriod && /* @__PURE__ */ jsxs27(Fragment11, { children: [
20142
- "/",
20143
- shortenPeriod(currentPlan.planPeriod)
20144
- ] })
20145
- ]
20146
- }
20147
- ),
20061
+ /* @__PURE__ */ jsxs27(Text, { display: props.addOns.fontStyle, children: [
20062
+ entitlement.priceBehavior === "pay_in_advance" || entitlement.priceBehavior === "overage" && limit > 0 ? /* @__PURE__ */ jsxs27(Fragment11, { children: [
20063
+ limit,
20064
+ " ",
20065
+ getFeatureName(entitlement.feature, limit)
20066
+ ] }) : entitlement.feature.name,
20067
+ entitlement.priceBehavior === "overage" && entitlement.feature.featureType === "event" && currentPlan?.planPeriod && /* @__PURE__ */ jsxs27(Fragment11, { children: [
20068
+ "/",
20069
+ shortenPeriod(currentPlan.planPeriod)
20070
+ ] })
20071
+ ] }),
20148
20072
  /* @__PURE__ */ jsxs27(Flex, { $alignItems: "center", $gap: "1rem", children: [
20149
20073
  entitlement.priceBehavior === "overage" && currentPlan?.planPeriod ? /* @__PURE__ */ jsx35(
20150
20074
  Text,
20151
20075
  {
20152
- $font: theme.typography.text.fontFamily,
20153
20076
  $size: 0.875 * theme.typography.text.fontSize,
20154
- $weight: theme.typography.text.fontWeight,
20155
20077
  $color: hexToHSL(theme.typography.text.color).l > 50 ? darken(theme.typography.text.color, 0.46) : lighten(theme.typography.text.color, 0.46),
20156
20078
  children: typeof overageAmount === "number" && overageAmount > 0 ? t2("X over the limit", {
20157
20079
  amount: overageAmount
@@ -20176,9 +20098,7 @@ var PlanManager = forwardRef12(({ children, className, portal, ...rest }, ref) =
20176
20098
  ) : entitlement.priceBehavior === "pay_in_advance" && currentPlan?.planPeriod && /* @__PURE__ */ jsxs27(
20177
20099
  Text,
20178
20100
  {
20179
- $font: theme.typography.text.fontFamily,
20180
20101
  $size: 0.875 * theme.typography.text.fontSize,
20181
- $weight: theme.typography.text.fontWeight,
20182
20102
  $color: hexToHSL(theme.typography.text.color).l > 50 ? darken(theme.typography.text.color, 0.46) : lighten(theme.typography.text.color, 0.46),
20183
20103
  children: [
20184
20104
  formatCurrency(
@@ -20194,25 +20114,16 @@ var PlanManager = forwardRef12(({ children, className, portal, ...rest }, ref) =
20194
20114
  ]
20195
20115
  }
20196
20116
  ),
20197
- amount > 0 && /* @__PURE__ */ jsxs27(
20198
- Text,
20199
- {
20200
- $font: theme.typography.text.fontFamily,
20201
- $size: theme.typography.text.fontSize,
20202
- $weight: theme.typography.text.fontWeight,
20203
- $color: theme.typography.text.color,
20204
- children: [
20205
- formatCurrency(
20206
- (entitlement.price ?? 0) * amount,
20207
- entitlement.currency
20208
- ),
20209
- (entitlement.priceBehavior === "pay_in_advance" || entitlement.priceBehavior !== "overage") && /* @__PURE__ */ jsxs27("sub", { children: [
20210
- "/",
20211
- currentPlan?.planPeriod && entitlement.priceBehavior === "pay_in_advance" ? shortenPeriod(currentPlan.planPeriod) : getFeatureName(entitlement.feature, 1)
20212
- ] })
20213
- ]
20214
- }
20215
- )
20117
+ amount > 0 && /* @__PURE__ */ jsxs27(Text, { children: [
20118
+ formatCurrency(
20119
+ (entitlement.price ?? 0) * amount,
20120
+ entitlement.currency
20121
+ ),
20122
+ (entitlement.priceBehavior === "pay_in_advance" || entitlement.priceBehavior !== "overage") && /* @__PURE__ */ jsxs27("sub", { children: [
20123
+ "/",
20124
+ currentPlan?.planPeriod && entitlement.priceBehavior === "pay_in_advance" ? shortenPeriod(currentPlan.planPeriod) : getFeatureName(entitlement.feature, 1)
20125
+ ] })
20126
+ ] })
20216
20127
  ] })
20217
20128
  ]
20218
20129
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@schematichq/schematic-components",
3
- "version": "0.7.4",
3
+ "version": "0.7.6",
4
4
  "main": "dist/schematic-components.cjs.js",
5
5
  "module": "dist/schematic-components.esm.js",
6
6
  "types": "dist/schematic-components.d.ts",