@schematichq/schematic-components 2.10.2 → 2.10.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7293,7 +7293,7 @@ function BillingCreditBundleViewFromJSONTyped(json, ignoreDiscriminator) {
7293
7293
  creditIcon: json["credit_icon"] == null ? void 0 : json["credit_icon"],
7294
7294
  creditId: json["credit_id"],
7295
7295
  creditName: json["credit_name"],
7296
- currencyPrices: json["currency_prices"] == null ? void 0 : json["currency_prices"].map(
7296
+ currencyPrices: json["currency_prices"].map(
7297
7297
  CreditBundleCurrencyPriceFromJSON
7298
7298
  ),
7299
7299
  expiryType: BillingCreditExpiryTypeFromJSON(json["expiry_type"]),
@@ -7445,6 +7445,20 @@ function BillingCreditResponseDataFromJSONTyped(json, ignoreDiscriminator) {
7445
7445
  };
7446
7446
  }
7447
7447
 
7448
+ // src/api/checkoutexternal/models/CreditCurrencyPrice.ts
7449
+ function CreditCurrencyPriceFromJSON(json) {
7450
+ return CreditCurrencyPriceFromJSONTyped(json, false);
7451
+ }
7452
+ function CreditCurrencyPriceFromJSONTyped(json, ignoreDiscriminator) {
7453
+ if (json == null) {
7454
+ return json;
7455
+ }
7456
+ return {
7457
+ currency: json["currency"],
7458
+ price: json["price"] == null ? void 0 : BillingPriceViewFromJSON(json["price"])
7459
+ };
7460
+ }
7461
+
7448
7462
  // src/api/checkoutexternal/models/BillingCreditView.ts
7449
7463
  function BillingCreditViewFromJSON(json) {
7450
7464
  return BillingCreditViewFromJSONTyped(json, false);
@@ -7458,6 +7472,9 @@ function BillingCreditViewFromJSONTyped(json, ignoreDiscriminator) {
7458
7472
  burnStrategy: BillingCreditBurnStrategyFromJSON(json["burn_strategy"]),
7459
7473
  costEditable: json["cost_editable"],
7460
7474
  createdAt: new Date(json["created_at"]),
7475
+ currencyPrices: json["currency_prices"].map(
7476
+ CreditCurrencyPriceFromJSON
7477
+ ),
7461
7478
  defaultExpiryUnit: BillingCreditExpiryUnitFromJSON(
7462
7479
  json["default_expiry_unit"]
7463
7480
  ),
@@ -10599,9 +10616,9 @@ function BillingTiersModeFromJSONTyped4(json, ignoreDiscriminator) {
10599
10616
 
10600
10617
  // src/api/componentspublic/models/BillingPriceView.ts
10601
10618
  function BillingPriceViewFromJSON2(json) {
10602
- return BillingPriceViewFromJSONTyped8(json, false);
10619
+ return BillingPriceViewFromJSONTyped9(json, false);
10603
10620
  }
10604
- function BillingPriceViewFromJSONTyped8(json, ignoreDiscriminator) {
10621
+ function BillingPriceViewFromJSONTyped9(json, ignoreDiscriminator) {
10605
10622
  if (json == null) {
10606
10623
  return json;
10607
10624
  }
@@ -10634,6 +10651,20 @@ function BillingPriceViewFromJSONTyped8(json, ignoreDiscriminator) {
10634
10651
  };
10635
10652
  }
10636
10653
 
10654
+ // src/api/componentspublic/models/CreditCurrencyPrice.ts
10655
+ function CreditCurrencyPriceFromJSON2(json) {
10656
+ return CreditCurrencyPriceFromJSONTyped3(json, false);
10657
+ }
10658
+ function CreditCurrencyPriceFromJSONTyped3(json, ignoreDiscriminator) {
10659
+ if (json == null) {
10660
+ return json;
10661
+ }
10662
+ return {
10663
+ currency: json["currency"],
10664
+ price: json["price"] == null ? void 0 : BillingPriceViewFromJSON2(json["price"])
10665
+ };
10666
+ }
10667
+
10637
10668
  // src/api/componentspublic/models/BillingCreditView.ts
10638
10669
  function BillingCreditViewFromJSON2(json) {
10639
10670
  return BillingCreditViewFromJSONTyped3(json, false);
@@ -10647,6 +10678,9 @@ function BillingCreditViewFromJSONTyped3(json, ignoreDiscriminator) {
10647
10678
  burnStrategy: BillingCreditBurnStrategyFromJSON2(json["burn_strategy"]),
10648
10679
  costEditable: json["cost_editable"],
10649
10680
  createdAt: new Date(json["created_at"]),
10681
+ currencyPrices: json["currency_prices"].map(
10682
+ CreditCurrencyPriceFromJSON2
10683
+ ),
10650
10684
  defaultExpiryUnit: BillingCreditExpiryUnitFromJSON2(
10651
10685
  json["default_expiry_unit"]
10652
10686
  ),
@@ -11518,6 +11552,17 @@ function getAddOnPrice(addOn, period = "month", currency) {
11518
11552
  return { ...billingPrice, price: getPriceValue(billingPrice) };
11519
11553
  }
11520
11554
  }
11555
+ function planSupportsCurrency(plan, currency) {
11556
+ if (!currency) return true;
11557
+ const target = currency.toLowerCase();
11558
+ if (plan.currencyPrices?.length) {
11559
+ return plan.currencyPrices.some(
11560
+ (cp) => cp.currency.toLowerCase() === target
11561
+ );
11562
+ }
11563
+ const legacyCurrency = plan.monthlyPrice?.currency ?? plan.yearlyPrice?.currency ?? plan.oneTimePrice?.currency;
11564
+ return !legacyCurrency || legacyCurrency.toLowerCase() === target;
11565
+ }
11521
11566
  function getEntitlementPrice(entitlement, period = "month", currency) {
11522
11567
  const currencyPrices = "valueType" in entitlement ? entitlement.currencyPrices : "entitlementType" in entitlement ? entitlement.planEntitlement?.currencyPrices : void 0;
11523
11568
  let source;
@@ -11675,6 +11720,13 @@ function buildAddOnRequestBody(options) {
11675
11720
  return acc;
11676
11721
  }, []);
11677
11722
  }
11723
+ function isScheduledCheckoutConflictMessage(message) {
11724
+ if (typeof message !== "string") {
11725
+ return false;
11726
+ }
11727
+ const m2 = message.toLowerCase();
11728
+ return m2.includes("scheduled downgrade") || m2.includes("scheduled checkout");
11729
+ }
11678
11730
  function buildCreditBundlesRequestBody(creditBundles) {
11679
11731
  return creditBundles.reduce(
11680
11732
  (acc, { id, count }) => {
@@ -12770,7 +12822,7 @@ var reducer = (state, action) => {
12770
12822
  // src/context/EmbedProvider.tsx
12771
12823
  var import_jsx_runtime2 = require("react/jsx-runtime");
12772
12824
  var getCustomHeaders = (sessionId) => ({
12773
- "X-Schematic-Components-Version": "2.10.2",
12825
+ "X-Schematic-Components-Version": "2.10.3",
12774
12826
  "X-Schematic-Session-ID": sessionId
12775
12827
  });
12776
12828
  var normalizeCurrencyFilter = (filter2) => {
@@ -14147,7 +14199,7 @@ var Icon3 = ({
14147
14199
 
14148
14200
  // src/components/ui/input/styles.ts
14149
14201
  var Input = yt.input(({ theme, $size = "md", $variant = "filled" }) => {
14150
- const isLightBackground = useIsLightBackground();
14202
+ const isLightBackground = isLightColor(theme.card.background);
14151
14203
  return pt`
14152
14204
  font-family: "Inter", sans-serif;
14153
14205
  font-weight: 500;
@@ -16199,17 +16251,20 @@ var CheckoutDialog = ({ top }) => {
16199
16251
  const [isLoading, setIsLoading] = (0, import_react33.useState)(false);
16200
16252
  const [error, setError] = (0, import_react33.useState)();
16201
16253
  const [isModal, setIsModal] = (0, import_react33.useState)(true);
16202
- const { featureUsage, showPeriodToggle, trialPaymentMethodRequired } = (0, import_react33.useMemo)(() => {
16203
- return {
16204
- featureUsage: data?.featureUsage ? data.featureUsage.features : [],
16205
- showPeriodToggle: data?.displaySettings?.showPeriodToggle ?? true,
16206
- trialPaymentMethodRequired: data?.trialPaymentMethodRequired === true
16207
- };
16208
- }, [
16209
- data?.featureUsage,
16210
- data?.displaySettings?.showPeriodToggle,
16211
- data?.trialPaymentMethodRequired
16212
- ]);
16254
+ const { featureUsage, showPeriodToggle, trialPaymentMethodRequired } = (
16255
+ // eslint-disable-next-line react-hooks/preserve-manual-memoization
16256
+ (0, import_react33.useMemo)(() => {
16257
+ return {
16258
+ featureUsage: data?.featureUsage ? data.featureUsage.features : [],
16259
+ showPeriodToggle: data?.displaySettings?.showPeriodToggle ?? true,
16260
+ trialPaymentMethodRequired: data?.trialPaymentMethodRequired === true
16261
+ };
16262
+ }, [
16263
+ data?.featureUsage,
16264
+ data?.displaySettings?.showPeriodToggle,
16265
+ data?.trialPaymentMethodRequired
16266
+ ])
16267
+ );
16213
16268
  const getValidatedPeriod = () => {
16214
16269
  const requestedPeriod = checkoutState?.period || data?.company?.plan?.planPeriod || "month";
16215
16270
  if (checkoutState?.planId) {
@@ -16565,12 +16620,9 @@ var CheckoutDialog = ({ top }) => {
16565
16620
  return;
16566
16621
  }
16567
16622
  }
16568
- if (err2.response.status === 409) {
16569
- switch (data2.error) {
16570
- case "cannot purchase pay-in-advance entitlements while a scheduled downgrade is pending; cancel the scheduled downgrade first":
16571
- setError(t3("Downgrade pending."));
16572
- return;
16573
- }
16623
+ if (err2.response.status === 409 && isScheduledCheckoutConflictMessage(data2?.error)) {
16624
+ setError(t3("Downgrade pending."));
16625
+ return;
16574
16626
  }
16575
16627
  setError(
16576
16628
  t3("Error retrieving plan details. Please try again in a moment.")
@@ -16798,6 +16850,9 @@ var CheckoutDialog = ({ top }) => {
16798
16850
  (0, import_react33.useEffect)(() => {
16799
16851
  setAddOns((prevAddOns) => {
16800
16852
  return availableAddOns.filter((availAddOn) => {
16853
+ if (hasCurrency && !planSupportsCurrency(availAddOn, selectedCurrency)) {
16854
+ return false;
16855
+ }
16801
16856
  if (!selectedPlan) {
16802
16857
  return true;
16803
16858
  }
@@ -16816,7 +16871,13 @@ var CheckoutDialog = ({ top }) => {
16816
16871
  };
16817
16872
  });
16818
16873
  });
16819
- }, [data?.addOnCompatibilities, availableAddOns, selectedPlan]);
16874
+ }, [
16875
+ data?.addOnCompatibilities,
16876
+ availableAddOns,
16877
+ selectedPlan,
16878
+ hasCurrency,
16879
+ selectedCurrency
16880
+ ]);
16820
16881
  (0, import_react33.useLayoutEffect)(() => {
16821
16882
  const element = dialogRef.current;
16822
16883
  if (layout !== "checkout" || !element) {
@@ -18616,9 +18677,29 @@ var SubscriptionSidebar = (0, import_react40.forwardRef)(
18616
18677
  setIsLoading(false);
18617
18678
  setLayout("portal");
18618
18679
  }
18619
- } catch {
18680
+ } catch (err2) {
18620
18681
  setIsLoading(false);
18621
18682
  setLayout("checkout");
18683
+ if (err2 instanceof ResponseError) {
18684
+ if (err2.response.status === 401) {
18685
+ setError(t3("Session expired. Please refresh and try again."));
18686
+ return;
18687
+ }
18688
+ let data2;
18689
+ try {
18690
+ data2 = await err2.response.json();
18691
+ } catch {
18692
+ data2 = void 0;
18693
+ }
18694
+ if (err2.response.status === 409 && isScheduledCheckoutConflictMessage(data2?.error)) {
18695
+ setError(
18696
+ t3(
18697
+ "Downgrade pending. Cancel the scheduled downgrade before making another change."
18698
+ )
18699
+ );
18700
+ return;
18701
+ }
18702
+ }
18622
18703
  setError(
18623
18704
  t3("Error processing payment. Please try a different payment method.")
18624
18705
  );
@@ -21277,7 +21358,7 @@ var registerWrapper = function registerWrapper2(stripe, startTime) {
21277
21358
  }
21278
21359
  stripe._registerWrapper({
21279
21360
  name: "stripe-js",
21280
- version: "9.3.1",
21361
+ version: "9.4.0",
21281
21362
  startTime
21282
21363
  });
21283
21364
  };
@@ -21355,7 +21436,7 @@ var initStripe = function initStripe2(maybeStripe, args, startTime) {
21355
21436
  var version = runtimeVersionToUrlVersion(maybeStripe.version);
21356
21437
  var expectedVersion = RELEASE_TRAIN;
21357
21438
  if (isTestKey && version !== expectedVersion) {
21358
- console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("9.3.1", " expected Stripe.js@").concat(expectedVersion, ". This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning"));
21439
+ console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("9.4.0", " expected Stripe.js@").concat(expectedVersion, ". This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning"));
21359
21440
  }
21360
21441
  var stripe = maybeStripe.apply(void 0, args);
21361
21442
  registerWrapper(stripe, startTime);
@@ -23263,9 +23344,25 @@ var PricingTable = (0, import_react55.forwardRef)(({ className, ...rest }, ref)
23263
23344
  const showCurrencySelector = currencies.length > 1;
23264
23345
  const hasCurrency = currencies.length > 1 || hasCurrencyFilter;
23265
23346
  const hasNoUsableCurrency = currencies.length === 0;
23266
- const { plans, addOns, periods } = useAvailablePlans(selectedPeriod, {
23347
+ const {
23348
+ plans: allPlans,
23349
+ addOns: allAddOns,
23350
+ periods
23351
+ } = useAvailablePlans(selectedPeriod, {
23267
23352
  useSelectedPeriod: showPeriodToggle
23268
23353
  });
23354
+ const plans = (0, import_react55.useMemo)(
23355
+ () => hasCurrency ? allPlans.filter(
23356
+ (plan) => planSupportsCurrency(plan, selectedCurrency)
23357
+ ) : allPlans,
23358
+ [allPlans, hasCurrency, selectedCurrency]
23359
+ );
23360
+ const addOns = (0, import_react55.useMemo)(
23361
+ () => hasCurrency ? allAddOns.filter(
23362
+ (addOn) => planSupportsCurrency(addOn, selectedCurrency)
23363
+ ) : allAddOns,
23364
+ [allAddOns, hasCurrency, selectedCurrency]
23365
+ );
23269
23366
  const [entitlementCounts, setEntitlementCounts] = (0, import_react55.useState)(
23270
23367
  () => plans.reduce(entitlementCountsReducer, {})
23271
23368
  );
@@ -104,7 +104,7 @@ declare interface BillingCreditBundleView {
104
104
  * @type {Array<CreditBundleCurrencyPrice>}
105
105
  * @memberof BillingCreditBundleView
106
106
  */
107
- currencyPrices?: Array<CreditBundleCurrencyPrice>;
107
+ currencyPrices: Array<CreditBundleCurrencyPrice>;
108
108
  /**
109
109
  *
110
110
  * @type {BillingCreditExpiryType}
@@ -550,6 +550,12 @@ declare interface BillingCreditView {
550
550
  * @memberof BillingCreditView
551
551
  */
552
552
  createdAt: Date;
553
+ /**
554
+ *
555
+ * @type {Array<CreditCurrencyPrice>}
556
+ * @memberof BillingCreditView
557
+ */
558
+ currencyPrices: Array<CreditCurrencyPrice>;
553
559
  /**
554
560
  *
555
561
  * @type {BillingCreditExpiryUnit}
@@ -672,6 +678,12 @@ declare interface BillingCreditView_2 {
672
678
  * @memberof BillingCreditView
673
679
  */
674
680
  createdAt: Date;
681
+ /**
682
+ *
683
+ * @type {Array<CreditCurrencyPrice>}
684
+ * @memberof BillingCreditView
685
+ */
686
+ currencyPrices: Array<CreditCurrencyPrice_2>;
675
687
  /**
676
688
  *
677
689
  * @type {BillingCreditExpiryUnit}
@@ -4934,6 +4946,46 @@ declare interface CreditCompanyGrantView {
4934
4946
  zeroedOutReason?: BillingCreditGrantZeroedOutReason | null;
4935
4947
  }
4936
4948
 
4949
+ /**
4950
+ *
4951
+ * @export
4952
+ * @interface CreditCurrencyPrice
4953
+ */
4954
+ declare interface CreditCurrencyPrice {
4955
+ /**
4956
+ *
4957
+ * @type {string}
4958
+ * @memberof CreditCurrencyPrice
4959
+ */
4960
+ currency: string;
4961
+ /**
4962
+ *
4963
+ * @type {BillingPriceView}
4964
+ * @memberof CreditCurrencyPrice
4965
+ */
4966
+ price?: BillingPriceView;
4967
+ }
4968
+
4969
+ /**
4970
+ *
4971
+ * @export
4972
+ * @interface CreditCurrencyPrice
4973
+ */
4974
+ declare interface CreditCurrencyPrice_2 {
4975
+ /**
4976
+ *
4977
+ * @type {string}
4978
+ * @memberof CreditCurrencyPrice
4979
+ */
4980
+ currency: string;
4981
+ /**
4982
+ *
4983
+ * @type {BillingPriceView}
4984
+ * @memberof CreditCurrencyPrice
4985
+ */
4986
+ price?: BillingPriceView_2;
4987
+ }
4988
+
4937
4989
  /**
4938
4990
  *
4939
4991
  * @export
@@ -7208,7 +7208,7 @@ function BillingCreditBundleViewFromJSONTyped(json, ignoreDiscriminator) {
7208
7208
  creditIcon: json["credit_icon"] == null ? void 0 : json["credit_icon"],
7209
7209
  creditId: json["credit_id"],
7210
7210
  creditName: json["credit_name"],
7211
- currencyPrices: json["currency_prices"] == null ? void 0 : json["currency_prices"].map(
7211
+ currencyPrices: json["currency_prices"].map(
7212
7212
  CreditBundleCurrencyPriceFromJSON
7213
7213
  ),
7214
7214
  expiryType: BillingCreditExpiryTypeFromJSON(json["expiry_type"]),
@@ -7360,6 +7360,20 @@ function BillingCreditResponseDataFromJSONTyped(json, ignoreDiscriminator) {
7360
7360
  };
7361
7361
  }
7362
7362
 
7363
+ // src/api/checkoutexternal/models/CreditCurrencyPrice.ts
7364
+ function CreditCurrencyPriceFromJSON(json) {
7365
+ return CreditCurrencyPriceFromJSONTyped(json, false);
7366
+ }
7367
+ function CreditCurrencyPriceFromJSONTyped(json, ignoreDiscriminator) {
7368
+ if (json == null) {
7369
+ return json;
7370
+ }
7371
+ return {
7372
+ currency: json["currency"],
7373
+ price: json["price"] == null ? void 0 : BillingPriceViewFromJSON(json["price"])
7374
+ };
7375
+ }
7376
+
7363
7377
  // src/api/checkoutexternal/models/BillingCreditView.ts
7364
7378
  function BillingCreditViewFromJSON(json) {
7365
7379
  return BillingCreditViewFromJSONTyped(json, false);
@@ -7373,6 +7387,9 @@ function BillingCreditViewFromJSONTyped(json, ignoreDiscriminator) {
7373
7387
  burnStrategy: BillingCreditBurnStrategyFromJSON(json["burn_strategy"]),
7374
7388
  costEditable: json["cost_editable"],
7375
7389
  createdAt: new Date(json["created_at"]),
7390
+ currencyPrices: json["currency_prices"].map(
7391
+ CreditCurrencyPriceFromJSON
7392
+ ),
7376
7393
  defaultExpiryUnit: BillingCreditExpiryUnitFromJSON(
7377
7394
  json["default_expiry_unit"]
7378
7395
  ),
@@ -10514,9 +10531,9 @@ function BillingTiersModeFromJSONTyped4(json, ignoreDiscriminator) {
10514
10531
 
10515
10532
  // src/api/componentspublic/models/BillingPriceView.ts
10516
10533
  function BillingPriceViewFromJSON2(json) {
10517
- return BillingPriceViewFromJSONTyped8(json, false);
10534
+ return BillingPriceViewFromJSONTyped9(json, false);
10518
10535
  }
10519
- function BillingPriceViewFromJSONTyped8(json, ignoreDiscriminator) {
10536
+ function BillingPriceViewFromJSONTyped9(json, ignoreDiscriminator) {
10520
10537
  if (json == null) {
10521
10538
  return json;
10522
10539
  }
@@ -10549,6 +10566,20 @@ function BillingPriceViewFromJSONTyped8(json, ignoreDiscriminator) {
10549
10566
  };
10550
10567
  }
10551
10568
 
10569
+ // src/api/componentspublic/models/CreditCurrencyPrice.ts
10570
+ function CreditCurrencyPriceFromJSON2(json) {
10571
+ return CreditCurrencyPriceFromJSONTyped3(json, false);
10572
+ }
10573
+ function CreditCurrencyPriceFromJSONTyped3(json, ignoreDiscriminator) {
10574
+ if (json == null) {
10575
+ return json;
10576
+ }
10577
+ return {
10578
+ currency: json["currency"],
10579
+ price: json["price"] == null ? void 0 : BillingPriceViewFromJSON2(json["price"])
10580
+ };
10581
+ }
10582
+
10552
10583
  // src/api/componentspublic/models/BillingCreditView.ts
10553
10584
  function BillingCreditViewFromJSON2(json) {
10554
10585
  return BillingCreditViewFromJSONTyped3(json, false);
@@ -10562,6 +10593,9 @@ function BillingCreditViewFromJSONTyped3(json, ignoreDiscriminator) {
10562
10593
  burnStrategy: BillingCreditBurnStrategyFromJSON2(json["burn_strategy"]),
10563
10594
  costEditable: json["cost_editable"],
10564
10595
  createdAt: new Date(json["created_at"]),
10596
+ currencyPrices: json["currency_prices"].map(
10597
+ CreditCurrencyPriceFromJSON2
10598
+ ),
10565
10599
  defaultExpiryUnit: BillingCreditExpiryUnitFromJSON2(
10566
10600
  json["default_expiry_unit"]
10567
10601
  ),
@@ -11433,6 +11467,17 @@ function getAddOnPrice(addOn, period = "month", currency) {
11433
11467
  return { ...billingPrice, price: getPriceValue(billingPrice) };
11434
11468
  }
11435
11469
  }
11470
+ function planSupportsCurrency(plan, currency) {
11471
+ if (!currency) return true;
11472
+ const target = currency.toLowerCase();
11473
+ if (plan.currencyPrices?.length) {
11474
+ return plan.currencyPrices.some(
11475
+ (cp) => cp.currency.toLowerCase() === target
11476
+ );
11477
+ }
11478
+ const legacyCurrency = plan.monthlyPrice?.currency ?? plan.yearlyPrice?.currency ?? plan.oneTimePrice?.currency;
11479
+ return !legacyCurrency || legacyCurrency.toLowerCase() === target;
11480
+ }
11436
11481
  function getEntitlementPrice(entitlement, period = "month", currency) {
11437
11482
  const currencyPrices = "valueType" in entitlement ? entitlement.currencyPrices : "entitlementType" in entitlement ? entitlement.planEntitlement?.currencyPrices : void 0;
11438
11483
  let source;
@@ -11590,6 +11635,13 @@ function buildAddOnRequestBody(options) {
11590
11635
  return acc;
11591
11636
  }, []);
11592
11637
  }
11638
+ function isScheduledCheckoutConflictMessage(message) {
11639
+ if (typeof message !== "string") {
11640
+ return false;
11641
+ }
11642
+ const m2 = message.toLowerCase();
11643
+ return m2.includes("scheduled downgrade") || m2.includes("scheduled checkout");
11644
+ }
11593
11645
  function buildCreditBundlesRequestBody(creditBundles) {
11594
11646
  return creditBundles.reduce(
11595
11647
  (acc, { id, count }) => {
@@ -12685,7 +12737,7 @@ var reducer = (state, action) => {
12685
12737
  // src/context/EmbedProvider.tsx
12686
12738
  import { jsx, jsxs } from "react/jsx-runtime";
12687
12739
  var getCustomHeaders = (sessionId) => ({
12688
- "X-Schematic-Components-Version": "2.10.2",
12740
+ "X-Schematic-Components-Version": "2.10.3",
12689
12741
  "X-Schematic-Session-ID": sessionId
12690
12742
  });
12691
12743
  var normalizeCurrencyFilter = (filter2) => {
@@ -14068,7 +14120,7 @@ var Icon3 = ({
14068
14120
 
14069
14121
  // src/components/ui/input/styles.ts
14070
14122
  var Input = yt.input(({ theme, $size = "md", $variant = "filled" }) => {
14071
- const isLightBackground = useIsLightBackground();
14123
+ const isLightBackground = isLightColor(theme.card.background);
14072
14124
  return pt`
14073
14125
  font-family: "Inter", sans-serif;
14074
14126
  font-weight: 500;
@@ -16133,17 +16185,20 @@ var CheckoutDialog = ({ top }) => {
16133
16185
  const [isLoading, setIsLoading] = useState8(false);
16134
16186
  const [error, setError] = useState8();
16135
16187
  const [isModal, setIsModal] = useState8(true);
16136
- const { featureUsage, showPeriodToggle, trialPaymentMethodRequired } = useMemo10(() => {
16137
- return {
16138
- featureUsage: data?.featureUsage ? data.featureUsage.features : [],
16139
- showPeriodToggle: data?.displaySettings?.showPeriodToggle ?? true,
16140
- trialPaymentMethodRequired: data?.trialPaymentMethodRequired === true
16141
- };
16142
- }, [
16143
- data?.featureUsage,
16144
- data?.displaySettings?.showPeriodToggle,
16145
- data?.trialPaymentMethodRequired
16146
- ]);
16188
+ const { featureUsage, showPeriodToggle, trialPaymentMethodRequired } = (
16189
+ // eslint-disable-next-line react-hooks/preserve-manual-memoization
16190
+ useMemo10(() => {
16191
+ return {
16192
+ featureUsage: data?.featureUsage ? data.featureUsage.features : [],
16193
+ showPeriodToggle: data?.displaySettings?.showPeriodToggle ?? true,
16194
+ trialPaymentMethodRequired: data?.trialPaymentMethodRequired === true
16195
+ };
16196
+ }, [
16197
+ data?.featureUsage,
16198
+ data?.displaySettings?.showPeriodToggle,
16199
+ data?.trialPaymentMethodRequired
16200
+ ])
16201
+ );
16147
16202
  const getValidatedPeriod = () => {
16148
16203
  const requestedPeriod = checkoutState?.period || data?.company?.plan?.planPeriod || "month";
16149
16204
  if (checkoutState?.planId) {
@@ -16499,12 +16554,9 @@ var CheckoutDialog = ({ top }) => {
16499
16554
  return;
16500
16555
  }
16501
16556
  }
16502
- if (err2.response.status === 409) {
16503
- switch (data2.error) {
16504
- case "cannot purchase pay-in-advance entitlements while a scheduled downgrade is pending; cancel the scheduled downgrade first":
16505
- setError(t3("Downgrade pending."));
16506
- return;
16507
- }
16557
+ if (err2.response.status === 409 && isScheduledCheckoutConflictMessage(data2?.error)) {
16558
+ setError(t3("Downgrade pending."));
16559
+ return;
16508
16560
  }
16509
16561
  setError(
16510
16562
  t3("Error retrieving plan details. Please try again in a moment.")
@@ -16732,6 +16784,9 @@ var CheckoutDialog = ({ top }) => {
16732
16784
  useEffect5(() => {
16733
16785
  setAddOns((prevAddOns) => {
16734
16786
  return availableAddOns.filter((availAddOn) => {
16787
+ if (hasCurrency && !planSupportsCurrency(availAddOn, selectedCurrency)) {
16788
+ return false;
16789
+ }
16735
16790
  if (!selectedPlan) {
16736
16791
  return true;
16737
16792
  }
@@ -16750,7 +16805,13 @@ var CheckoutDialog = ({ top }) => {
16750
16805
  };
16751
16806
  });
16752
16807
  });
16753
- }, [data?.addOnCompatibilities, availableAddOns, selectedPlan]);
16808
+ }, [
16809
+ data?.addOnCompatibilities,
16810
+ availableAddOns,
16811
+ selectedPlan,
16812
+ hasCurrency,
16813
+ selectedCurrency
16814
+ ]);
16754
16815
  useLayoutEffect4(() => {
16755
16816
  const element = dialogRef.current;
16756
16817
  if (layout !== "checkout" || !element) {
@@ -18562,9 +18623,29 @@ var SubscriptionSidebar = forwardRef7(
18562
18623
  setIsLoading(false);
18563
18624
  setLayout("portal");
18564
18625
  }
18565
- } catch {
18626
+ } catch (err2) {
18566
18627
  setIsLoading(false);
18567
18628
  setLayout("checkout");
18629
+ if (err2 instanceof ResponseError) {
18630
+ if (err2.response.status === 401) {
18631
+ setError(t3("Session expired. Please refresh and try again."));
18632
+ return;
18633
+ }
18634
+ let data2;
18635
+ try {
18636
+ data2 = await err2.response.json();
18637
+ } catch {
18638
+ data2 = void 0;
18639
+ }
18640
+ if (err2.response.status === 409 && isScheduledCheckoutConflictMessage(data2?.error)) {
18641
+ setError(
18642
+ t3(
18643
+ "Downgrade pending. Cancel the scheduled downgrade before making another change."
18644
+ )
18645
+ );
18646
+ return;
18647
+ }
18648
+ }
18568
18649
  setError(
18569
18650
  t3("Error processing payment. Please try a different payment method.")
18570
18651
  );
@@ -21223,7 +21304,7 @@ var registerWrapper = function registerWrapper2(stripe, startTime) {
21223
21304
  }
21224
21305
  stripe._registerWrapper({
21225
21306
  name: "stripe-js",
21226
- version: "9.3.1",
21307
+ version: "9.4.0",
21227
21308
  startTime
21228
21309
  });
21229
21310
  };
@@ -21301,7 +21382,7 @@ var initStripe = function initStripe2(maybeStripe, args, startTime) {
21301
21382
  var version = runtimeVersionToUrlVersion(maybeStripe.version);
21302
21383
  var expectedVersion = RELEASE_TRAIN;
21303
21384
  if (isTestKey && version !== expectedVersion) {
21304
- console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("9.3.1", " expected Stripe.js@").concat(expectedVersion, ". This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning"));
21385
+ console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("9.4.0", " expected Stripe.js@").concat(expectedVersion, ". This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning"));
21305
21386
  }
21306
21387
  var stripe = maybeStripe.apply(void 0, args);
21307
21388
  registerWrapper(stripe, startTime);
@@ -22315,6 +22396,7 @@ import {
22315
22396
  forwardRef as forwardRef15,
22316
22397
  useCallback as useCallback14,
22317
22398
  useEffect as useEffect9,
22399
+ useMemo as useMemo26,
22318
22400
  useState as useState19
22319
22401
  } from "react";
22320
22402
 
@@ -23215,9 +23297,25 @@ var PricingTable = forwardRef15(({ className, ...rest }, ref) => {
23215
23297
  const showCurrencySelector = currencies.length > 1;
23216
23298
  const hasCurrency = currencies.length > 1 || hasCurrencyFilter;
23217
23299
  const hasNoUsableCurrency = currencies.length === 0;
23218
- const { plans, addOns, periods } = useAvailablePlans(selectedPeriod, {
23300
+ const {
23301
+ plans: allPlans,
23302
+ addOns: allAddOns,
23303
+ periods
23304
+ } = useAvailablePlans(selectedPeriod, {
23219
23305
  useSelectedPeriod: showPeriodToggle
23220
23306
  });
23307
+ const plans = useMemo26(
23308
+ () => hasCurrency ? allPlans.filter(
23309
+ (plan) => planSupportsCurrency(plan, selectedCurrency)
23310
+ ) : allPlans,
23311
+ [allPlans, hasCurrency, selectedCurrency]
23312
+ );
23313
+ const addOns = useMemo26(
23314
+ () => hasCurrency ? allAddOns.filter(
23315
+ (addOn) => planSupportsCurrency(addOn, selectedCurrency)
23316
+ ) : allAddOns,
23317
+ [allAddOns, hasCurrency, selectedCurrency]
23318
+ );
23221
23319
  const [entitlementCounts, setEntitlementCounts] = useState19(
23222
23320
  () => plans.reduce(entitlementCountsReducer, {})
23223
23321
  );
@@ -23448,7 +23546,7 @@ var TextElement = forwardRef16(({ children, className, ...rest }, ref) => {
23448
23546
  TextElement.displayName = "Text";
23449
23547
 
23450
23548
  // src/components/elements/unsubscribe-button/UnsubscribeButton.tsx
23451
- import { forwardRef as forwardRef17, useMemo as useMemo26 } from "react";
23549
+ import { forwardRef as forwardRef17, useMemo as useMemo27 } from "react";
23452
23550
  import { jsx as jsx59 } from "react/jsx-runtime";
23453
23551
  var buttonStyles = {
23454
23552
  primary: {
@@ -23479,7 +23577,7 @@ var UnsubscribeButton = forwardRef17(({ children, className, ...rest }, ref) =>
23479
23577
  const props = resolveDesignProps10(rest);
23480
23578
  const { t: t3 } = useTranslation();
23481
23579
  const { data, setLayout } = useEmbed();
23482
- const hasActiveSubscription = useMemo26(() => {
23580
+ const hasActiveSubscription = useMemo27(() => {
23483
23581
  return data?.subscription && data.subscription.status !== "cancelled" && !data.subscription.cancelAt;
23484
23582
  }, [data?.subscription]);
23485
23583
  if (!hasActiveSubscription) {
@@ -23514,7 +23612,7 @@ var UnsubscribeButton = forwardRef17(({ children, className, ...rest }, ref) =>
23514
23612
  UnsubscribeButton.displayName = "UnsubscribeButton";
23515
23613
 
23516
23614
  // src/components/elements/upcoming-bill/UpcomingBill.tsx
23517
- import { forwardRef as forwardRef18, useCallback as useCallback15, useEffect as useEffect10, useMemo as useMemo27, useState as useState20 } from "react";
23615
+ import { forwardRef as forwardRef18, useCallback as useCallback15, useEffect as useEffect10, useMemo as useMemo28, useState as useState20 } from "react";
23518
23616
  import { jsx as jsx60, jsxs as jsxs44 } from "react/jsx-runtime";
23519
23617
  function resolveDesignProps11(props) {
23520
23618
  return {
@@ -23543,7 +23641,7 @@ var UpcomingBill = forwardRef18(({ className, ...rest }, ref) => {
23543
23641
  const [error, setError] = useState20();
23544
23642
  const [upcomingInvoice, setUpcomingInvoice] = useState20(data?.upcomingInvoice);
23545
23643
  const [balances, setBalances] = useState20([]);
23546
- const discounts = useMemo27(() => {
23644
+ const discounts = useMemo28(() => {
23547
23645
  return (data?.subscription?.discounts || []).map((discount) => ({
23548
23646
  couponId: discount.couponId,
23549
23647
  customerFacingCode: discount.customerFacingCode || void 0,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@schematichq/schematic-components",
3
- "version": "2.10.2",
3
+ "version": "2.10.3",
4
4
  "main": "dist/schematic-components.cjs.js",
5
5
  "module": "dist/schematic-components.esm.js",
6
6
  "types": "dist/schematic-components.d.ts",
@@ -34,7 +34,7 @@
34
34
  },
35
35
  "dependencies": {
36
36
  "@schematichq/schematic-icons": "^0.5.4",
37
- "@stripe/stripe-js": "^9.3.1",
37
+ "@stripe/stripe-js": "^9.4.0",
38
38
  "i18next": "^26.0.8",
39
39
  "lodash": "^4.18.1",
40
40
  "pako": "^2.1.0",
@@ -48,7 +48,7 @@
48
48
  "@eslint/markdown": "^8.0.1",
49
49
  "@microsoft/api-extractor": "^7.58.7",
50
50
  "@openapitools/openapi-generator-cli": "^2.32.0",
51
- "@stripe/react-stripe-js": "^6.2.0",
51
+ "@stripe/react-stripe-js": "^6.3.0",
52
52
  "@swc/core": "^1.15.30",
53
53
  "@testing-library/dom": "^10.4.1",
54
54
  "@testing-library/jest-dom": "^6.9.1",
@@ -59,20 +59,20 @@
59
59
  "@types/react-dom": "^19.2.3",
60
60
  "@vitest/browser": "^4.1.5",
61
61
  "esbuild": "^0.28.0",
62
- "eslint": "^10.2.0",
62
+ "eslint": "^10.3.0",
63
63
  "eslint-import-resolver-typescript": "^4.4.4",
64
64
  "eslint-plugin-import-x": "^4.16.2",
65
65
  "eslint-plugin-react": "^7.37.5",
66
- "eslint-plugin-react-hooks": "^7.0.1",
67
- "globals": "^17.5.0",
66
+ "eslint-plugin-react-hooks": "^7.1.1",
67
+ "globals": "^17.6.0",
68
68
  "happy-dom": "^20.9.0",
69
- "jsdom": "^29.1.0",
70
- "msw": "^2.13.4",
69
+ "jsdom": "^29.1.1",
70
+ "msw": "^2.14.2",
71
71
  "prettier": "^3.8.3",
72
72
  "react": "^19.2.5",
73
73
  "react-dom": "^19.2.5",
74
74
  "typescript": "^6.0.3",
75
- "typescript-eslint": "^8.59.1",
75
+ "typescript-eslint": "^8.59.2",
76
76
  "vitest": "^4.1.5"
77
77
  },
78
78
  "peerDependencies": {