@schematichq/schematic-components 1.4.0 → 1.4.1

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.
@@ -7431,6 +7431,7 @@ function BillingCreditBundleViewFromJSONTyped(json, ignoreDiscriminator) {
7431
7431
  expiryType: json["expiry_type"],
7432
7432
  expiryUnit: json["expiry_unit"],
7433
7433
  expiryUnitCount: json["expiry_unit_count"] == null ? void 0 : json["expiry_unit_count"],
7434
+ hasGrants: json["has_grants"],
7434
7435
  id: json["id"],
7435
7436
  name: json["name"],
7436
7437
  pluralName: json["plural_name"] == null ? void 0 : json["plural_name"],
@@ -7601,6 +7602,7 @@ function BillingProductForSubscriptionResponseDataFromJSONTyped(json, ignoreDisc
7601
7602
  }
7602
7603
  return {
7603
7604
  billingScheme: json["billing_scheme"],
7605
+ billingThreshold: json["billing_threshold"] == null ? void 0 : json["billing_threshold"],
7604
7606
  createdAt: new Date(json["created_at"]),
7605
7607
  currency: json["currency"],
7606
7608
  environmentId: json["environment_id"],
@@ -7619,6 +7621,7 @@ function BillingProductForSubscriptionResponseDataFromJSONTyped(json, ignoreDisc
7619
7621
  ),
7620
7622
  quantity: json["quantity"],
7621
7623
  subscriptionId: json["subscription_id"],
7624
+ subscriptionItemExternalId: json["subscription_item_external_id"] == null ? void 0 : json["subscription_item_external_id"],
7622
7625
  updatedAt: new Date(json["updated_at"]),
7623
7626
  usageType: json["usage_type"]
7624
7627
  };
@@ -8381,6 +8384,7 @@ function PlanEntitlementResponseDataFromJSONTyped(json, ignoreDiscriminator) {
8381
8384
  return json;
8382
8385
  }
8383
8386
  return {
8387
+ billingThreshold: json["billing_threshold"] == null ? void 0 : json["billing_threshold"],
8384
8388
  consumptionRate: json["consumption_rate"] == null ? void 0 : json["consumption_rate"],
8385
8389
  createdAt: new Date(json["created_at"]),
8386
8390
  environmentId: json["environment_id"],
@@ -8596,6 +8600,9 @@ function CreditCompanyGrantViewFromJSONTyped(json, ignoreDiscriminator) {
8596
8600
  creditIcon: json["credit_icon"] == null ? void 0 : json["credit_icon"],
8597
8601
  creditName: json["credit_name"],
8598
8602
  expiresAt: json["expires_at"] == null ? void 0 : new Date(json["expires_at"]),
8603
+ expiryType: json["expiry_type"] == null ? void 0 : json["expiry_type"],
8604
+ expiryUnit: json["expiry_unit"] == null ? void 0 : json["expiry_unit"],
8605
+ expiryUnitCount: json["expiry_unit_count"] == null ? void 0 : json["expiry_unit_count"],
8599
8606
  grantReason: json["grant_reason"],
8600
8607
  id: json["id"],
8601
8608
  planId: json["plan_id"] == null ? void 0 : json["plan_id"],
@@ -8623,6 +8630,7 @@ function UsageBasedEntitlementResponseDataFromJSONTyped(json, ignoreDiscriminato
8623
8630
  return json;
8624
8631
  }
8625
8632
  return {
8633
+ billingThreshold: json["billing_threshold"] == null ? void 0 : json["billing_threshold"],
8626
8634
  consumptionRate: json["consumption_rate"] == null ? void 0 : json["consumption_rate"],
8627
8635
  featureId: json["feature_id"],
8628
8636
  meteredPrice: json["metered_price"] == null ? void 0 : BillingPriceViewFromJSON(json["metered_price"]),
@@ -10193,6 +10201,7 @@ function PlanEntitlementResponseDataFromJSONTyped5(json, ignoreDiscriminator) {
10193
10201
  return json;
10194
10202
  }
10195
10203
  return {
10204
+ billingThreshold: json["billing_threshold"] == null ? void 0 : json["billing_threshold"],
10196
10205
  consumptionRate: json["consumption_rate"] == null ? void 0 : json["consumption_rate"],
10197
10206
  createdAt: new Date(json["created_at"]),
10198
10207
  environmentId: json["environment_id"],
@@ -10282,7 +10291,8 @@ function PublicPlansResponseDataFromJSONTyped(json, ignoreDiscriminator) {
10282
10291
  addOnCompatibilities: json["add_on_compatibilities"].map(
10283
10292
  CompatiblePlansFromJSON2
10284
10293
  ),
10285
- capabilities: json["capabilities"] == null ? void 0 : ComponentCapabilitiesFromJSON2(json["capabilities"])
10294
+ capabilities: json["capabilities"] == null ? void 0 : ComponentCapabilitiesFromJSON2(json["capabilities"]),
10295
+ showPeriodToggle: json["show_period_toggle"]
10286
10296
  };
10287
10297
  }
10288
10298
 
@@ -10480,7 +10490,7 @@ var EmbedProvider = ({
10480
10490
  });
10481
10491
  const customHeaders = (0, import_react12.useMemo)(
10482
10492
  () => ({
10483
- "X-Schematic-Components-Version": "1.4.0",
10493
+ "X-Schematic-Components-Version": "1.4.1",
10484
10494
  "X-Schematic-Session-ID": sessionIdRef.current
10485
10495
  }),
10486
10496
  []
@@ -11185,7 +11195,6 @@ var Button = dt.button(
11185
11195
  ${() => $selfAlignment && lt`
11186
11196
  align-self: ${$selfAlignment};
11187
11197
  `}
11188
- gap: 0.5rem;
11189
11198
  width: ${$fullWidth ? "100%" : "fit-content"};
11190
11199
  border: 1px solid transparent;
11191
11200
  transition: 0.1s;
@@ -11289,6 +11298,9 @@ var Button = dt.button(
11289
11298
  &::before {
11290
11299
  content: "";
11291
11300
  ${loaderStyles({ $color: theme[$color], $size, $isLoading })}
11301
+ ${$isLoading && lt`
11302
+ margin-right: 0.5rem;
11303
+ `}
11292
11304
  }
11293
11305
 
11294
11306
  &:disabled {
@@ -14214,7 +14226,7 @@ var Usage = ({ entitlements, updateQuantity, period }) => {
14214
14226
  $size: "lg",
14215
14227
  type: "number",
14216
14228
  value: entitlement.quantity,
14217
- min: 1,
14229
+ min: 0,
14218
14230
  autoFocus: true,
14219
14231
  onFocus: (event) => {
14220
14232
  event.target.select();
@@ -14222,7 +14234,7 @@ var Usage = ({ entitlements, updateQuantity, period }) => {
14222
14234
  onChange: (event) => {
14223
14235
  event.preventDefault();
14224
14236
  const value = parseInt(event.target.value);
14225
- if (!isNaN(value) && value > 0) {
14237
+ if (!isNaN(value)) {
14226
14238
  updateQuantity(entitlement.id, value);
14227
14239
  }
14228
14240
  }
@@ -14301,7 +14313,7 @@ var createActiveUsageBasedEntitlementsReducer = (entitlements, period) => (acc,
14301
14313
  const featureUsage = entitlements.find(
14302
14314
  (usage2) => usage2.feature?.id === entitlement.feature?.id
14303
14315
  );
14304
- const allocation = featureUsage?.allocation || 1;
14316
+ const allocation = featureUsage?.allocation || 0;
14305
14317
  const usage = featureUsage?.usage || 0;
14306
14318
  acc.push({
14307
14319
  ...entitlement,
@@ -14314,7 +14326,7 @@ var createActiveUsageBasedEntitlementsReducer = (entitlements, period) => (acc,
14314
14326
  };
14315
14327
  var CheckoutDialog = ({ top = 0 }) => {
14316
14328
  const { t: t2 } = useTranslation();
14317
- const { data, checkoutState, previewCheckout } = useEmbed();
14329
+ const { data, settings, isPending, checkoutState, previewCheckout } = useEmbed();
14318
14330
  const isLightBackground = useIsLightBackground();
14319
14331
  const contentRef = (0, import_react30.useRef)(null);
14320
14332
  const checkoutRef = (0, import_react30.useRef)(null);
@@ -14328,16 +14340,6 @@ var CheckoutDialog = ({ top = 0 }) => {
14328
14340
  );
14329
14341
  const [isLoading, setIsLoading] = (0, import_react30.useState)(false);
14330
14342
  const [error, setError] = (0, import_react30.useState)();
14331
- const currentPeriod = (0, import_react30.useMemo)(
14332
- () => checkoutState?.period || isCheckoutData(data) && data.company?.plan?.planPeriod || "month",
14333
- [data, checkoutState?.period]
14334
- );
14335
- const [planPeriod, setPlanPeriod] = (0, import_react30.useState)(currentPeriod);
14336
- const {
14337
- plans: availablePlans,
14338
- addOns: availableAddOns,
14339
- periods: availablePeriods
14340
- } = useAvailablePlans(planPeriod);
14341
14343
  const {
14342
14344
  currentPlanId,
14343
14345
  currentEntitlements,
@@ -14359,6 +14361,18 @@ var CheckoutDialog = ({ top = 0 }) => {
14359
14361
  trialPaymentMethodRequired: false
14360
14362
  };
14361
14363
  }, [data]);
14364
+ const currentPeriod = (0, import_react30.useMemo)(
14365
+ () => checkoutState?.period || isCheckoutData(data) && data.company?.plan?.planPeriod || "month",
14366
+ [data, checkoutState?.period]
14367
+ );
14368
+ const [planPeriod, setPlanPeriod] = (0, import_react30.useState)(currentPeriod);
14369
+ const {
14370
+ plans: availablePlans,
14371
+ addOns: availableAddOns,
14372
+ periods: availablePeriods
14373
+ } = useAvailablePlans(planPeriod, {
14374
+ useSelectedPeriod: showPeriodToggle
14375
+ });
14362
14376
  const [selectedPlan, setSelectedPlan] = (0, import_react30.useState)(
14363
14377
  () => {
14364
14378
  return availablePlans.find(
@@ -14506,20 +14520,8 @@ var CheckoutDialog = ({ top = 0 }) => {
14506
14520
  if (checkoutState?.credits) {
14507
14521
  return "credits";
14508
14522
  }
14509
- if (checkoutState?.planId !== currentPlanId) {
14510
- const hasUsageStage = checkoutStages.some(
14511
- (stage) => stage.id === "usage"
14512
- );
14513
- const hasAddonsStage = checkoutStages.some(
14514
- (stage) => stage.id === "addons"
14515
- );
14516
- const hasAddonsUsageStage = checkoutStages.some(
14517
- (stage) => stage.id === "addonsUsage"
14518
- );
14519
- if (hasUsageStage) return "usage";
14520
- if (hasAddonsStage) return "addons";
14521
- if (hasAddonsUsageStage) return "addonsUsage";
14522
- return "plan";
14523
+ if (typeof checkoutState?.planId !== "undefined" && checkoutState.planId !== currentPlanId) {
14524
+ return checkoutStages.some((stage) => stage.id === "usage") ? "usage" : checkoutStages.some((stage) => stage.id === "addons") ? "addons" : checkoutStages.some((stage) => stage.id === "addonsUsage") ? "addonsUsage" : checkoutStages.some((stage) => stage.id === "credits") ? "credits" : "plan";
14523
14525
  }
14524
14526
  return "plan";
14525
14527
  });
@@ -14658,7 +14660,7 @@ var CheckoutDialog = ({ top = 0 }) => {
14658
14660
  ...entitlement,
14659
14661
  allocation: entitlement.valueNumeric || 0,
14660
14662
  usage: 0,
14661
- quantity: entitlement.priceBehavior === "pay_in_advance" /* PayInAdvance */ ? 1 : 0
14663
+ quantity: 0
14662
14664
  });
14663
14665
  }
14664
14666
  return acc;
@@ -14927,7 +14929,17 @@ var CheckoutDialog = ({ top = 0 }) => {
14927
14929
  ]
14928
14930
  }
14929
14931
  ),
14930
- checkoutStage === "plan" && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
14932
+ isPending ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
14933
+ Flex,
14934
+ {
14935
+ $width: "100%",
14936
+ $height: "100%",
14937
+ $alignItems: "center",
14938
+ $justifyContent: "center",
14939
+ $padding: `${settings.theme.card.padding / TEXT_BASE_SIZE}rem`,
14940
+ children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Loader, { $size: "2xl" })
14941
+ }
14942
+ ) : checkoutStage === "plan" ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
14931
14943
  Plan,
14932
14944
  {
14933
14945
  isLoading,
@@ -14938,8 +14950,7 @@ var CheckoutDialog = ({ top = 0 }) => {
14938
14950
  shouldTrial,
14939
14951
  showPeriodToggle
14940
14952
  }
14941
- ),
14942
- checkoutStage === "usage" && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
14953
+ ) : checkoutStage === "usage" ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
14943
14954
  Usage,
14944
14955
  {
14945
14956
  isLoading,
@@ -14948,8 +14959,7 @@ var CheckoutDialog = ({ top = 0 }) => {
14948
14959
  entitlements: payInAdvanceEntitlements,
14949
14960
  updateQuantity: updateUsageBasedEntitlementQuantity
14950
14961
  }
14951
- ),
14952
- checkoutStage === "addons" && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
14962
+ ) : checkoutStage === "addons" ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
14953
14963
  AddOns,
14954
14964
  {
14955
14965
  isLoading,
@@ -14957,8 +14967,7 @@ var CheckoutDialog = ({ top = 0 }) => {
14957
14967
  addOns,
14958
14968
  toggle: (id) => toggleAddOn(id)
14959
14969
  }
14960
- ),
14961
- checkoutStage === "addonsUsage" && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
14970
+ ) : checkoutStage === "addonsUsage" ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
14962
14971
  Usage,
14963
14972
  {
14964
14973
  isLoading,
@@ -14967,16 +14976,14 @@ var CheckoutDialog = ({ top = 0 }) => {
14967
14976
  entitlements: addOnUsageBasedEntitlements,
14968
14977
  updateQuantity: updateAddOnEntitlementQuantity
14969
14978
  }
14970
- ),
14971
- checkoutStage === "credits" && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
14979
+ ) : checkoutStage === "credits" ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
14972
14980
  Credits,
14973
14981
  {
14974
14982
  isLoading,
14975
14983
  bundles: creditBundles,
14976
14984
  updateCount: updateCreditBundleCount
14977
14985
  }
14978
- ),
14979
- checkoutStage === "checkout" && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
14986
+ ) : checkoutStage === "checkout" && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
14980
14987
  Checkout,
14981
14988
  {
14982
14989
  isPaymentMethodRequired,
@@ -18678,6 +18685,7 @@ var PricingTable = (0, import_react51.forwardRef)(
18678
18685
  const { t: t2 } = useTranslation();
18679
18686
  const { data, settings, isPending, hydratePublic } = useEmbed();
18680
18687
  const { currentPeriod, showPeriodToggle, isStandalone } = (0, import_react51.useMemo)(() => {
18688
+ const showPeriodToggle2 = data?.showPeriodToggle ?? props.showPeriodToggle;
18681
18689
  if (isCheckoutData(data)) {
18682
18690
  const billingSubscription = data.company?.billingSubscription;
18683
18691
  const isTrialSubscription = billingSubscription?.status === "trialing";
@@ -18686,7 +18694,7 @@ var PricingTable = (0, import_react51.forwardRef)(
18686
18694
  currentPeriod: data.company?.plan?.planPeriod || "month",
18687
18695
  currentAddOns: data.company?.addOns || [],
18688
18696
  canCheckout: data.capabilities?.checkout ?? true,
18689
- showPeriodToggle: data.showPeriodToggle ?? props.showPeriodToggle,
18697
+ showPeriodToggle: showPeriodToggle2,
18690
18698
  isTrialSubscription,
18691
18699
  willSubscriptionCancel,
18692
18700
  isStandalone: false
@@ -18696,7 +18704,7 @@ var PricingTable = (0, import_react51.forwardRef)(
18696
18704
  currentPeriod: "month",
18697
18705
  currentAddOns: [],
18698
18706
  canCheckout: true,
18699
- showPeriodToggle: props.showPeriodToggle,
18707
+ showPeriodToggle: showPeriodToggle2,
18700
18708
  isTrialSubscription: false,
18701
18709
  willSubscriptionCancel: false,
18702
18710
  isStandalone: true
@@ -18732,7 +18740,7 @@ var PricingTable = (0, import_react51.forwardRef)(
18732
18740
  (0, import_react51.useEffect)(() => {
18733
18741
  setEntitlementCounts(plans.reduce(entitlementCountsReducer, {}));
18734
18742
  }, [plans]);
18735
- if (isStandalone && isPending) {
18743
+ if (isPending) {
18736
18744
  return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
18737
18745
  Flex,
18738
18746
  {
@@ -85,6 +85,12 @@ declare interface BillingCreditBundleView {
85
85
  * @memberof BillingCreditBundleView
86
86
  */
87
87
  expiryUnitCount?: number | null;
88
+ /**
89
+ *
90
+ * @type {boolean}
91
+ * @memberof BillingCreditBundleView
92
+ */
93
+ hasGrants: boolean;
88
94
  /**
89
95
  *
90
96
  * @type {string}
@@ -911,6 +917,12 @@ declare interface BillingProductForSubscriptionResponseData {
911
917
  * @memberof BillingProductForSubscriptionResponseData
912
918
  */
913
919
  billingScheme: string;
920
+ /**
921
+ *
922
+ * @type {number}
923
+ * @memberof BillingProductForSubscriptionResponseData
924
+ */
925
+ billingThreshold?: number | null;
914
926
  /**
915
927
  *
916
928
  * @type {Date}
@@ -1007,6 +1019,12 @@ declare interface BillingProductForSubscriptionResponseData {
1007
1019
  * @memberof BillingProductForSubscriptionResponseData
1008
1020
  */
1009
1021
  subscriptionId: string;
1022
+ /**
1023
+ *
1024
+ * @type {string}
1025
+ * @memberof BillingProductForSubscriptionResponseData
1026
+ */
1027
+ subscriptionItemExternalId?: string | null;
1010
1028
  /**
1011
1029
  *
1012
1030
  * @type {Date}
@@ -3006,6 +3024,24 @@ declare interface CreditCompanyGrantView {
3006
3024
  * @memberof CreditCompanyGrantView
3007
3025
  */
3008
3026
  expiresAt?: Date | null;
3027
+ /**
3028
+ *
3029
+ * @type {string}
3030
+ * @memberof CreditCompanyGrantView
3031
+ */
3032
+ expiryType?: string | null;
3033
+ /**
3034
+ *
3035
+ * @type {string}
3036
+ * @memberof CreditCompanyGrantView
3037
+ */
3038
+ expiryUnit?: string | null;
3039
+ /**
3040
+ *
3041
+ * @type {number}
3042
+ * @memberof CreditCompanyGrantView
3043
+ */
3044
+ expiryUnitCount?: number | null;
3009
3045
  /**
3010
3046
  *
3011
3047
  * @type {string}
@@ -5532,6 +5568,12 @@ declare interface PlanDetailResponseData {
5532
5568
  * @interface PlanEntitlementResponseData
5533
5569
  */
5534
5570
  declare interface PlanEntitlementResponseData {
5571
+ /**
5572
+ *
5573
+ * @type {number}
5574
+ * @memberof PlanEntitlementResponseData
5575
+ */
5576
+ billingThreshold?: number | null;
5535
5577
  /**
5536
5578
  *
5537
5579
  * @type {number}
@@ -5684,6 +5726,12 @@ declare interface PlanEntitlementResponseData {
5684
5726
  * @interface PlanEntitlementResponseData
5685
5727
  */
5686
5728
  declare interface PlanEntitlementResponseData_2 {
5729
+ /**
5730
+ *
5731
+ * @type {number}
5732
+ * @memberof PlanEntitlementResponseData
5733
+ */
5734
+ billingThreshold?: number | null;
5687
5735
  /**
5688
5736
  *
5689
5737
  * @type {number}
@@ -6573,6 +6621,12 @@ declare interface PublicPlansResponseData {
6573
6621
  * @memberof PublicPlansResponseData
6574
6622
  */
6575
6623
  capabilities?: ComponentCapabilities_2;
6624
+ /**
6625
+ *
6626
+ * @type {boolean}
6627
+ * @memberof PublicPlansResponseData
6628
+ */
6629
+ showPeriodToggle: boolean;
6576
6630
  }
6577
6631
 
6578
6632
  declare interface RequestContext {
@@ -7474,6 +7528,12 @@ declare interface UsageBasedEntitlement extends PlanEntitlementResponseData_2 {
7474
7528
  * @interface UsageBasedEntitlementResponseData
7475
7529
  */
7476
7530
  declare interface UsageBasedEntitlementResponseData {
7531
+ /**
7532
+ *
7533
+ * @type {number}
7534
+ * @memberof UsageBasedEntitlementResponseData
7535
+ */
7536
+ billingThreshold?: number | null;
7477
7537
  /**
7478
7538
  *
7479
7539
  * @type {number}
@@ -7372,6 +7372,7 @@ function BillingCreditBundleViewFromJSONTyped(json, ignoreDiscriminator) {
7372
7372
  expiryType: json["expiry_type"],
7373
7373
  expiryUnit: json["expiry_unit"],
7374
7374
  expiryUnitCount: json["expiry_unit_count"] == null ? void 0 : json["expiry_unit_count"],
7375
+ hasGrants: json["has_grants"],
7375
7376
  id: json["id"],
7376
7377
  name: json["name"],
7377
7378
  pluralName: json["plural_name"] == null ? void 0 : json["plural_name"],
@@ -7542,6 +7543,7 @@ function BillingProductForSubscriptionResponseDataFromJSONTyped(json, ignoreDisc
7542
7543
  }
7543
7544
  return {
7544
7545
  billingScheme: json["billing_scheme"],
7546
+ billingThreshold: json["billing_threshold"] == null ? void 0 : json["billing_threshold"],
7545
7547
  createdAt: new Date(json["created_at"]),
7546
7548
  currency: json["currency"],
7547
7549
  environmentId: json["environment_id"],
@@ -7560,6 +7562,7 @@ function BillingProductForSubscriptionResponseDataFromJSONTyped(json, ignoreDisc
7560
7562
  ),
7561
7563
  quantity: json["quantity"],
7562
7564
  subscriptionId: json["subscription_id"],
7565
+ subscriptionItemExternalId: json["subscription_item_external_id"] == null ? void 0 : json["subscription_item_external_id"],
7563
7566
  updatedAt: new Date(json["updated_at"]),
7564
7567
  usageType: json["usage_type"]
7565
7568
  };
@@ -8322,6 +8325,7 @@ function PlanEntitlementResponseDataFromJSONTyped(json, ignoreDiscriminator) {
8322
8325
  return json;
8323
8326
  }
8324
8327
  return {
8328
+ billingThreshold: json["billing_threshold"] == null ? void 0 : json["billing_threshold"],
8325
8329
  consumptionRate: json["consumption_rate"] == null ? void 0 : json["consumption_rate"],
8326
8330
  createdAt: new Date(json["created_at"]),
8327
8331
  environmentId: json["environment_id"],
@@ -8537,6 +8541,9 @@ function CreditCompanyGrantViewFromJSONTyped(json, ignoreDiscriminator) {
8537
8541
  creditIcon: json["credit_icon"] == null ? void 0 : json["credit_icon"],
8538
8542
  creditName: json["credit_name"],
8539
8543
  expiresAt: json["expires_at"] == null ? void 0 : new Date(json["expires_at"]),
8544
+ expiryType: json["expiry_type"] == null ? void 0 : json["expiry_type"],
8545
+ expiryUnit: json["expiry_unit"] == null ? void 0 : json["expiry_unit"],
8546
+ expiryUnitCount: json["expiry_unit_count"] == null ? void 0 : json["expiry_unit_count"],
8540
8547
  grantReason: json["grant_reason"],
8541
8548
  id: json["id"],
8542
8549
  planId: json["plan_id"] == null ? void 0 : json["plan_id"],
@@ -8564,6 +8571,7 @@ function UsageBasedEntitlementResponseDataFromJSONTyped(json, ignoreDiscriminato
8564
8571
  return json;
8565
8572
  }
8566
8573
  return {
8574
+ billingThreshold: json["billing_threshold"] == null ? void 0 : json["billing_threshold"],
8567
8575
  consumptionRate: json["consumption_rate"] == null ? void 0 : json["consumption_rate"],
8568
8576
  featureId: json["feature_id"],
8569
8577
  meteredPrice: json["metered_price"] == null ? void 0 : BillingPriceViewFromJSON(json["metered_price"]),
@@ -10134,6 +10142,7 @@ function PlanEntitlementResponseDataFromJSONTyped5(json, ignoreDiscriminator) {
10134
10142
  return json;
10135
10143
  }
10136
10144
  return {
10145
+ billingThreshold: json["billing_threshold"] == null ? void 0 : json["billing_threshold"],
10137
10146
  consumptionRate: json["consumption_rate"] == null ? void 0 : json["consumption_rate"],
10138
10147
  createdAt: new Date(json["created_at"]),
10139
10148
  environmentId: json["environment_id"],
@@ -10223,7 +10232,8 @@ function PublicPlansResponseDataFromJSONTyped(json, ignoreDiscriminator) {
10223
10232
  addOnCompatibilities: json["add_on_compatibilities"].map(
10224
10233
  CompatiblePlansFromJSON2
10225
10234
  ),
10226
- capabilities: json["capabilities"] == null ? void 0 : ComponentCapabilitiesFromJSON2(json["capabilities"])
10235
+ capabilities: json["capabilities"] == null ? void 0 : ComponentCapabilitiesFromJSON2(json["capabilities"]),
10236
+ showPeriodToggle: json["show_period_toggle"]
10227
10237
  };
10228
10238
  }
10229
10239
 
@@ -10421,7 +10431,7 @@ var EmbedProvider = ({
10421
10431
  });
10422
10432
  const customHeaders = useMemo3(
10423
10433
  () => ({
10424
- "X-Schematic-Components-Version": "1.4.0",
10434
+ "X-Schematic-Components-Version": "1.4.1",
10425
10435
  "X-Schematic-Session-ID": sessionIdRef.current
10426
10436
  }),
10427
10437
  []
@@ -11126,7 +11136,6 @@ var Button = dt.button(
11126
11136
  ${() => $selfAlignment && lt`
11127
11137
  align-self: ${$selfAlignment};
11128
11138
  `}
11129
- gap: 0.5rem;
11130
11139
  width: ${$fullWidth ? "100%" : "fit-content"};
11131
11140
  border: 1px solid transparent;
11132
11141
  transition: 0.1s;
@@ -11230,6 +11239,9 @@ var Button = dt.button(
11230
11239
  &::before {
11231
11240
  content: "";
11232
11241
  ${loaderStyles({ $color: theme[$color], $size, $isLoading })}
11242
+ ${$isLoading && lt`
11243
+ margin-right: 0.5rem;
11244
+ `}
11233
11245
  }
11234
11246
 
11235
11247
  &:disabled {
@@ -14165,7 +14177,7 @@ var Usage = ({ entitlements, updateQuantity, period }) => {
14165
14177
  $size: "lg",
14166
14178
  type: "number",
14167
14179
  value: entitlement.quantity,
14168
- min: 1,
14180
+ min: 0,
14169
14181
  autoFocus: true,
14170
14182
  onFocus: (event) => {
14171
14183
  event.target.select();
@@ -14173,7 +14185,7 @@ var Usage = ({ entitlements, updateQuantity, period }) => {
14173
14185
  onChange: (event) => {
14174
14186
  event.preventDefault();
14175
14187
  const value = parseInt(event.target.value);
14176
- if (!isNaN(value) && value > 0) {
14188
+ if (!isNaN(value)) {
14177
14189
  updateQuantity(entitlement.id, value);
14178
14190
  }
14179
14191
  }
@@ -14252,7 +14264,7 @@ var createActiveUsageBasedEntitlementsReducer = (entitlements, period) => (acc,
14252
14264
  const featureUsage = entitlements.find(
14253
14265
  (usage2) => usage2.feature?.id === entitlement.feature?.id
14254
14266
  );
14255
- const allocation = featureUsage?.allocation || 1;
14267
+ const allocation = featureUsage?.allocation || 0;
14256
14268
  const usage = featureUsage?.usage || 0;
14257
14269
  acc.push({
14258
14270
  ...entitlement,
@@ -14265,7 +14277,7 @@ var createActiveUsageBasedEntitlementsReducer = (entitlements, period) => (acc,
14265
14277
  };
14266
14278
  var CheckoutDialog = ({ top = 0 }) => {
14267
14279
  const { t: t2 } = useTranslation();
14268
- const { data, checkoutState, previewCheckout } = useEmbed();
14280
+ const { data, settings, isPending, checkoutState, previewCheckout } = useEmbed();
14269
14281
  const isLightBackground = useIsLightBackground();
14270
14282
  const contentRef = useRef6(null);
14271
14283
  const checkoutRef = useRef6(null);
@@ -14279,16 +14291,6 @@ var CheckoutDialog = ({ top = 0 }) => {
14279
14291
  );
14280
14292
  const [isLoading, setIsLoading] = useState9(false);
14281
14293
  const [error, setError] = useState9();
14282
- const currentPeriod = useMemo9(
14283
- () => checkoutState?.period || isCheckoutData(data) && data.company?.plan?.planPeriod || "month",
14284
- [data, checkoutState?.period]
14285
- );
14286
- const [planPeriod, setPlanPeriod] = useState9(currentPeriod);
14287
- const {
14288
- plans: availablePlans,
14289
- addOns: availableAddOns,
14290
- periods: availablePeriods
14291
- } = useAvailablePlans(planPeriod);
14292
14294
  const {
14293
14295
  currentPlanId,
14294
14296
  currentEntitlements,
@@ -14310,6 +14312,18 @@ var CheckoutDialog = ({ top = 0 }) => {
14310
14312
  trialPaymentMethodRequired: false
14311
14313
  };
14312
14314
  }, [data]);
14315
+ const currentPeriod = useMemo9(
14316
+ () => checkoutState?.period || isCheckoutData(data) && data.company?.plan?.planPeriod || "month",
14317
+ [data, checkoutState?.period]
14318
+ );
14319
+ const [planPeriod, setPlanPeriod] = useState9(currentPeriod);
14320
+ const {
14321
+ plans: availablePlans,
14322
+ addOns: availableAddOns,
14323
+ periods: availablePeriods
14324
+ } = useAvailablePlans(planPeriod, {
14325
+ useSelectedPeriod: showPeriodToggle
14326
+ });
14313
14327
  const [selectedPlan, setSelectedPlan] = useState9(
14314
14328
  () => {
14315
14329
  return availablePlans.find(
@@ -14457,20 +14471,8 @@ var CheckoutDialog = ({ top = 0 }) => {
14457
14471
  if (checkoutState?.credits) {
14458
14472
  return "credits";
14459
14473
  }
14460
- if (checkoutState?.planId !== currentPlanId) {
14461
- const hasUsageStage = checkoutStages.some(
14462
- (stage) => stage.id === "usage"
14463
- );
14464
- const hasAddonsStage = checkoutStages.some(
14465
- (stage) => stage.id === "addons"
14466
- );
14467
- const hasAddonsUsageStage = checkoutStages.some(
14468
- (stage) => stage.id === "addonsUsage"
14469
- );
14470
- if (hasUsageStage) return "usage";
14471
- if (hasAddonsStage) return "addons";
14472
- if (hasAddonsUsageStage) return "addonsUsage";
14473
- return "plan";
14474
+ if (typeof checkoutState?.planId !== "undefined" && checkoutState.planId !== currentPlanId) {
14475
+ return checkoutStages.some((stage) => stage.id === "usage") ? "usage" : checkoutStages.some((stage) => stage.id === "addons") ? "addons" : checkoutStages.some((stage) => stage.id === "addonsUsage") ? "addonsUsage" : checkoutStages.some((stage) => stage.id === "credits") ? "credits" : "plan";
14474
14476
  }
14475
14477
  return "plan";
14476
14478
  });
@@ -14609,7 +14611,7 @@ var CheckoutDialog = ({ top = 0 }) => {
14609
14611
  ...entitlement,
14610
14612
  allocation: entitlement.valueNumeric || 0,
14611
14613
  usage: 0,
14612
- quantity: entitlement.priceBehavior === "pay_in_advance" /* PayInAdvance */ ? 1 : 0
14614
+ quantity: 0
14613
14615
  });
14614
14616
  }
14615
14617
  return acc;
@@ -14878,7 +14880,17 @@ var CheckoutDialog = ({ top = 0 }) => {
14878
14880
  ]
14879
14881
  }
14880
14882
  ),
14881
- checkoutStage === "plan" && /* @__PURE__ */ jsx20(
14883
+ isPending ? /* @__PURE__ */ jsx20(
14884
+ Flex,
14885
+ {
14886
+ $width: "100%",
14887
+ $height: "100%",
14888
+ $alignItems: "center",
14889
+ $justifyContent: "center",
14890
+ $padding: `${settings.theme.card.padding / TEXT_BASE_SIZE}rem`,
14891
+ children: /* @__PURE__ */ jsx20(Loader, { $size: "2xl" })
14892
+ }
14893
+ ) : checkoutStage === "plan" ? /* @__PURE__ */ jsx20(
14882
14894
  Plan,
14883
14895
  {
14884
14896
  isLoading,
@@ -14889,8 +14901,7 @@ var CheckoutDialog = ({ top = 0 }) => {
14889
14901
  shouldTrial,
14890
14902
  showPeriodToggle
14891
14903
  }
14892
- ),
14893
- checkoutStage === "usage" && /* @__PURE__ */ jsx20(
14904
+ ) : checkoutStage === "usage" ? /* @__PURE__ */ jsx20(
14894
14905
  Usage,
14895
14906
  {
14896
14907
  isLoading,
@@ -14899,8 +14910,7 @@ var CheckoutDialog = ({ top = 0 }) => {
14899
14910
  entitlements: payInAdvanceEntitlements,
14900
14911
  updateQuantity: updateUsageBasedEntitlementQuantity
14901
14912
  }
14902
- ),
14903
- checkoutStage === "addons" && /* @__PURE__ */ jsx20(
14913
+ ) : checkoutStage === "addons" ? /* @__PURE__ */ jsx20(
14904
14914
  AddOns,
14905
14915
  {
14906
14916
  isLoading,
@@ -14908,8 +14918,7 @@ var CheckoutDialog = ({ top = 0 }) => {
14908
14918
  addOns,
14909
14919
  toggle: (id) => toggleAddOn(id)
14910
14920
  }
14911
- ),
14912
- checkoutStage === "addonsUsage" && /* @__PURE__ */ jsx20(
14921
+ ) : checkoutStage === "addonsUsage" ? /* @__PURE__ */ jsx20(
14913
14922
  Usage,
14914
14923
  {
14915
14924
  isLoading,
@@ -14918,16 +14927,14 @@ var CheckoutDialog = ({ top = 0 }) => {
14918
14927
  entitlements: addOnUsageBasedEntitlements,
14919
14928
  updateQuantity: updateAddOnEntitlementQuantity
14920
14929
  }
14921
- ),
14922
- checkoutStage === "credits" && /* @__PURE__ */ jsx20(
14930
+ ) : checkoutStage === "credits" ? /* @__PURE__ */ jsx20(
14923
14931
  Credits,
14924
14932
  {
14925
14933
  isLoading,
14926
14934
  bundles: creditBundles,
14927
14935
  updateCount: updateCreditBundleCount
14928
14936
  }
14929
- ),
14930
- checkoutStage === "checkout" && /* @__PURE__ */ jsx20(
14937
+ ) : checkoutStage === "checkout" && /* @__PURE__ */ jsx20(
14931
14938
  Checkout,
14932
14939
  {
14933
14940
  isPaymentMethodRequired,
@@ -18639,6 +18646,7 @@ var PricingTable = forwardRef12(
18639
18646
  const { t: t2 } = useTranslation();
18640
18647
  const { data, settings, isPending, hydratePublic } = useEmbed();
18641
18648
  const { currentPeriod, showPeriodToggle, isStandalone } = useMemo26(() => {
18649
+ const showPeriodToggle2 = data?.showPeriodToggle ?? props.showPeriodToggle;
18642
18650
  if (isCheckoutData(data)) {
18643
18651
  const billingSubscription = data.company?.billingSubscription;
18644
18652
  const isTrialSubscription = billingSubscription?.status === "trialing";
@@ -18647,7 +18655,7 @@ var PricingTable = forwardRef12(
18647
18655
  currentPeriod: data.company?.plan?.planPeriod || "month",
18648
18656
  currentAddOns: data.company?.addOns || [],
18649
18657
  canCheckout: data.capabilities?.checkout ?? true,
18650
- showPeriodToggle: data.showPeriodToggle ?? props.showPeriodToggle,
18658
+ showPeriodToggle: showPeriodToggle2,
18651
18659
  isTrialSubscription,
18652
18660
  willSubscriptionCancel,
18653
18661
  isStandalone: false
@@ -18657,7 +18665,7 @@ var PricingTable = forwardRef12(
18657
18665
  currentPeriod: "month",
18658
18666
  currentAddOns: [],
18659
18667
  canCheckout: true,
18660
- showPeriodToggle: props.showPeriodToggle,
18668
+ showPeriodToggle: showPeriodToggle2,
18661
18669
  isTrialSubscription: false,
18662
18670
  willSubscriptionCancel: false,
18663
18671
  isStandalone: true
@@ -18693,7 +18701,7 @@ var PricingTable = forwardRef12(
18693
18701
  useEffect8(() => {
18694
18702
  setEntitlementCounts(plans.reduce(entitlementCountsReducer, {}));
18695
18703
  }, [plans]);
18696
- if (isStandalone && isPending) {
18704
+ if (isPending) {
18697
18705
  return /* @__PURE__ */ jsx46(
18698
18706
  Flex,
18699
18707
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@schematichq/schematic-components",
3
- "version": "1.4.0",
3
+ "version": "1.4.1",
4
4
  "main": "dist/schematic-components.cjs.js",
5
5
  "module": "dist/schematic-components.esm.js",
6
6
  "types": "dist/schematic-components.d.ts",
@@ -37,21 +37,21 @@
37
37
  "i18next": "^25.4.0",
38
38
  "lodash": "^4.17.21",
39
39
  "pako": "^2.1.0",
40
- "react-i18next": "^15.7.0",
40
+ "react-i18next": "^15.7.1",
41
41
  "styled-components": "^6.1.19",
42
42
  "uuid": "^11.1.0"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@eslint/js": "^9.33.0",
46
46
  "@eslint/json": "^0.13.0",
47
- "@eslint/markdown": "^7.1.0",
47
+ "@eslint/markdown": "^7.2.0",
48
48
  "@microsoft/api-extractor": "^7.52.11",
49
- "@openapitools/openapi-generator-cli": "^2.22.0",
49
+ "@openapitools/openapi-generator-cli": "^2.23.0",
50
50
  "@stripe/react-stripe-js": "^3.9.1",
51
51
  "@types/jest": "^30.0.0",
52
52
  "@types/lodash": "^4.17.20",
53
53
  "@types/pako": "^2.0.4",
54
- "@types/react": "^19.1.10",
54
+ "@types/react": "^19.1.11",
55
55
  "@types/react-dom": "^19.1.7",
56
56
  "esbuild": "^0.25.9",
57
57
  "eslint": "^9.33.0",