@schematichq/schematic-components 1.0.3 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10956,27 +10956,26 @@ var JSONApiResponse = class {
10956
10956
  }
10957
10957
  };
10958
10958
 
10959
- // src/api/checkoutexternal/models/BillingCreditResponseData.ts
10960
- function BillingCreditResponseDataFromJSON(json) {
10961
- return BillingCreditResponseDataFromJSONTyped(json, false);
10959
+ // src/api/checkoutexternal/models/BillingProductResponseData.ts
10960
+ function BillingProductResponseDataFromJSON(json) {
10961
+ return BillingProductResponseDataFromJSONTyped(json, false);
10962
10962
  }
10963
- function BillingCreditResponseDataFromJSONTyped(json, ignoreDiscriminator) {
10963
+ function BillingProductResponseDataFromJSONTyped(json, ignoreDiscriminator) {
10964
10964
  if (json == null) {
10965
10965
  return json;
10966
10966
  }
10967
10967
  return {
10968
- burnStrategy: json["burn_strategy"],
10968
+ accountId: json["account_id"],
10969
10969
  createdAt: new Date(json["created_at"]),
10970
- defaultExpiryUnit: json["default_expiry_unit"],
10971
- defaultExpiryUnitCount: json["default_expiry_unit_count"] == null ? void 0 : json["default_expiry_unit_count"],
10972
- defaultRolloverPolicy: json["default_rollover_policy"],
10973
- description: json["description"],
10974
- icon: json["icon"] == null ? void 0 : json["icon"],
10975
- id: json["id"],
10970
+ currency: json["currency"],
10971
+ environmentId: json["environment_id"],
10972
+ externalId: json["external_id"],
10973
+ isActive: json["is_active"],
10976
10974
  name: json["name"],
10977
- pluralName: json["plural_name"] == null ? void 0 : json["plural_name"],
10978
- pricePerUnit: json["price_per_unit"],
10979
- singularName: json["singular_name"] == null ? void 0 : json["singular_name"],
10975
+ price: json["price"],
10976
+ priceDecimal: json["price_decimal"] == null ? void 0 : json["price_decimal"],
10977
+ productId: json["product_id"],
10978
+ quantity: json["quantity"],
10980
10979
  updatedAt: new Date(json["updated_at"])
10981
10980
  };
10982
10981
  }
@@ -11000,6 +10999,33 @@ function BillingPriceResponseDataFromJSONTyped(json, ignoreDiscriminator) {
11000
10999
  };
11001
11000
  }
11002
11001
 
11002
+ // src/api/checkoutexternal/models/BillingCreditResponseData.ts
11003
+ function BillingCreditResponseDataFromJSON(json) {
11004
+ return BillingCreditResponseDataFromJSONTyped(json, false);
11005
+ }
11006
+ function BillingCreditResponseDataFromJSONTyped(json, ignoreDiscriminator) {
11007
+ if (json == null) {
11008
+ return json;
11009
+ }
11010
+ return {
11011
+ burnStrategy: json["burn_strategy"],
11012
+ createdAt: new Date(json["created_at"]),
11013
+ defaultExpiryUnit: json["default_expiry_unit"],
11014
+ defaultExpiryUnitCount: json["default_expiry_unit_count"] == null ? void 0 : json["default_expiry_unit_count"],
11015
+ defaultRolloverPolicy: json["default_rollover_policy"],
11016
+ description: json["description"],
11017
+ icon: json["icon"] == null ? void 0 : json["icon"],
11018
+ id: json["id"],
11019
+ monthlyPrice: json["monthly_price"] == null ? void 0 : BillingPriceResponseDataFromJSON(json["monthly_price"]),
11020
+ name: json["name"],
11021
+ pluralName: json["plural_name"] == null ? void 0 : json["plural_name"],
11022
+ product: json["product"] == null ? void 0 : BillingProductResponseDataFromJSON(json["product"]),
11023
+ singularName: json["singular_name"] == null ? void 0 : json["singular_name"],
11024
+ updatedAt: new Date(json["updated_at"]),
11025
+ yearlyPrice: json["yearly_price"] == null ? void 0 : BillingPriceResponseDataFromJSON(json["yearly_price"])
11026
+ };
11027
+ }
11028
+
11003
11029
  // src/api/checkoutexternal/models/BillingProductPriceTierResponseData.ts
11004
11030
  function BillingProductPriceTierResponseDataFromJSON(json) {
11005
11031
  return BillingProductPriceTierResponseDataFromJSONTyped(json, false);
@@ -11112,30 +11138,6 @@ function BillingProductForSubscriptionResponseDataFromJSONTyped(json, ignoreDisc
11112
11138
  };
11113
11139
  }
11114
11140
 
11115
- // src/api/checkoutexternal/models/BillingProductResponseData.ts
11116
- function BillingProductResponseDataFromJSON(json) {
11117
- return BillingProductResponseDataFromJSONTyped(json, false);
11118
- }
11119
- function BillingProductResponseDataFromJSONTyped(json, ignoreDiscriminator) {
11120
- if (json == null) {
11121
- return json;
11122
- }
11123
- return {
11124
- accountId: json["account_id"],
11125
- createdAt: new Date(json["created_at"]),
11126
- currency: json["currency"],
11127
- environmentId: json["environment_id"],
11128
- externalId: json["external_id"],
11129
- isActive: json["is_active"],
11130
- name: json["name"],
11131
- price: json["price"],
11132
- priceDecimal: json["price_decimal"] == null ? void 0 : json["price_decimal"],
11133
- productId: json["product_id"],
11134
- quantity: json["quantity"],
11135
- updatedAt: new Date(json["updated_at"])
11136
- };
11137
- }
11138
-
11139
11141
  // src/api/checkoutexternal/models/BillingSubscriptionDiscountView.ts
11140
11142
  function BillingSubscriptionDiscountViewFromJSON(json) {
11141
11143
  return BillingSubscriptionDiscountViewFromJSONTyped(json, false);
@@ -11808,6 +11810,7 @@ function PlanEntitlementResponseDataFromJSONTyped(json, ignoreDiscriminator) {
11808
11810
  return json;
11809
11811
  }
11810
11812
  return {
11813
+ consumptionRate: json["consumption_rate"] == null ? void 0 : json["consumption_rate"],
11811
11814
  createdAt: new Date(json["created_at"]),
11812
11815
  environmentId: json["environment_id"],
11813
11816
  feature: json["feature"] == null ? void 0 : FeatureResponseDataFromJSON(json["feature"]),
@@ -11994,6 +11997,7 @@ function UsageBasedEntitlementResponseDataFromJSONTyped(json, ignoreDiscriminato
11994
11997
  return json;
11995
11998
  }
11996
11999
  return {
12000
+ consumptionRate: json["consumption_rate"] == null ? void 0 : json["consumption_rate"],
11997
12001
  featureId: json["feature_id"],
11998
12002
  meteredPrice: json["metered_price"] == null ? void 0 : BillingPriceViewFromJSON(json["metered_price"]),
11999
12003
  metricPeriod: json["metric_period"] == null ? void 0 : json["metric_period"],
@@ -12994,36 +12998,35 @@ var JSONApiResponse2 = class {
12994
12998
  }
12995
12999
  };
12996
13000
 
12997
- // src/api/componentspublic/models/BillingCreditResponseData.ts
12998
- function BillingCreditResponseDataFromJSON2(json) {
12999
- return BillingCreditResponseDataFromJSONTyped3(json, false);
13001
+ // src/api/componentspublic/models/BillingProductResponseData.ts
13002
+ function BillingProductResponseDataFromJSON2(json) {
13003
+ return BillingProductResponseDataFromJSONTyped4(json, false);
13000
13004
  }
13001
- function BillingCreditResponseDataFromJSONTyped3(json, ignoreDiscriminator) {
13005
+ function BillingProductResponseDataFromJSONTyped4(json, ignoreDiscriminator) {
13002
13006
  if (json == null) {
13003
13007
  return json;
13004
13008
  }
13005
13009
  return {
13006
- burnStrategy: json["burn_strategy"],
13010
+ accountId: json["account_id"],
13007
13011
  createdAt: new Date(json["created_at"]),
13008
- defaultExpiryUnit: json["default_expiry_unit"],
13009
- defaultExpiryUnitCount: json["default_expiry_unit_count"] == null ? void 0 : json["default_expiry_unit_count"],
13010
- defaultRolloverPolicy: json["default_rollover_policy"],
13011
- description: json["description"],
13012
- icon: json["icon"] == null ? void 0 : json["icon"],
13013
- id: json["id"],
13012
+ currency: json["currency"],
13013
+ environmentId: json["environment_id"],
13014
+ externalId: json["external_id"],
13015
+ isActive: json["is_active"],
13014
13016
  name: json["name"],
13015
- pluralName: json["plural_name"] == null ? void 0 : json["plural_name"],
13016
- pricePerUnit: json["price_per_unit"],
13017
- singularName: json["singular_name"] == null ? void 0 : json["singular_name"],
13017
+ price: json["price"],
13018
+ priceDecimal: json["price_decimal"] == null ? void 0 : json["price_decimal"],
13019
+ productId: json["product_id"],
13020
+ quantity: json["quantity"],
13018
13021
  updatedAt: new Date(json["updated_at"])
13019
13022
  };
13020
13023
  }
13021
13024
 
13022
13025
  // src/api/componentspublic/models/BillingPriceResponseData.ts
13023
13026
  function BillingPriceResponseDataFromJSON2(json) {
13024
- return BillingPriceResponseDataFromJSONTyped6(json, false);
13027
+ return BillingPriceResponseDataFromJSONTyped7(json, false);
13025
13028
  }
13026
- function BillingPriceResponseDataFromJSONTyped6(json, ignoreDiscriminator) {
13029
+ function BillingPriceResponseDataFromJSONTyped7(json, ignoreDiscriminator) {
13027
13030
  if (json == null) {
13028
13031
  return json;
13029
13032
  }
@@ -13038,6 +13041,33 @@ function BillingPriceResponseDataFromJSONTyped6(json, ignoreDiscriminator) {
13038
13041
  };
13039
13042
  }
13040
13043
 
13044
+ // src/api/componentspublic/models/BillingCreditResponseData.ts
13045
+ function BillingCreditResponseDataFromJSON2(json) {
13046
+ return BillingCreditResponseDataFromJSONTyped3(json, false);
13047
+ }
13048
+ function BillingCreditResponseDataFromJSONTyped3(json, ignoreDiscriminator) {
13049
+ if (json == null) {
13050
+ return json;
13051
+ }
13052
+ return {
13053
+ burnStrategy: json["burn_strategy"],
13054
+ createdAt: new Date(json["created_at"]),
13055
+ defaultExpiryUnit: json["default_expiry_unit"],
13056
+ defaultExpiryUnitCount: json["default_expiry_unit_count"] == null ? void 0 : json["default_expiry_unit_count"],
13057
+ defaultRolloverPolicy: json["default_rollover_policy"],
13058
+ description: json["description"],
13059
+ icon: json["icon"] == null ? void 0 : json["icon"],
13060
+ id: json["id"],
13061
+ monthlyPrice: json["monthly_price"] == null ? void 0 : BillingPriceResponseDataFromJSON2(json["monthly_price"]),
13062
+ name: json["name"],
13063
+ pluralName: json["plural_name"] == null ? void 0 : json["plural_name"],
13064
+ product: json["product"] == null ? void 0 : BillingProductResponseDataFromJSON2(json["product"]),
13065
+ singularName: json["singular_name"] == null ? void 0 : json["singular_name"],
13066
+ updatedAt: new Date(json["updated_at"]),
13067
+ yearlyPrice: json["yearly_price"] == null ? void 0 : BillingPriceResponseDataFromJSON2(json["yearly_price"])
13068
+ };
13069
+ }
13070
+
13041
13071
  // src/api/componentspublic/models/BillingProductPriceTierResponseData.ts
13042
13072
  function BillingProductPriceTierResponseDataFromJSON2(json) {
13043
13073
  return BillingProductPriceTierResponseDataFromJSONTyped4(json, false);
@@ -13117,30 +13147,6 @@ function BillingProductDetailResponseDataFromJSONTyped5(json, ignoreDiscriminato
13117
13147
  };
13118
13148
  }
13119
13149
 
13120
- // src/api/componentspublic/models/BillingProductResponseData.ts
13121
- function BillingProductResponseDataFromJSON2(json) {
13122
- return BillingProductResponseDataFromJSONTyped3(json, false);
13123
- }
13124
- function BillingProductResponseDataFromJSONTyped3(json, ignoreDiscriminator) {
13125
- if (json == null) {
13126
- return json;
13127
- }
13128
- return {
13129
- accountId: json["account_id"],
13130
- createdAt: new Date(json["created_at"]),
13131
- currency: json["currency"],
13132
- environmentId: json["environment_id"],
13133
- externalId: json["external_id"],
13134
- isActive: json["is_active"],
13135
- name: json["name"],
13136
- price: json["price"],
13137
- priceDecimal: json["price_decimal"] == null ? void 0 : json["price_decimal"],
13138
- productId: json["product_id"],
13139
- quantity: json["quantity"],
13140
- updatedAt: new Date(json["updated_at"])
13141
- };
13142
- }
13143
-
13144
13150
  // src/api/componentspublic/models/CompatiblePlans.ts
13145
13151
  function CompatiblePlansFromJSON2(json) {
13146
13152
  return CompatiblePlansFromJSONTyped3(json, false);
@@ -13447,6 +13453,7 @@ function PlanEntitlementResponseDataFromJSONTyped4(json, ignoreDiscriminator) {
13447
13453
  return json;
13448
13454
  }
13449
13455
  return {
13456
+ consumptionRate: json["consumption_rate"] == null ? void 0 : json["consumption_rate"],
13450
13457
  createdAt: new Date(json["created_at"]),
13451
13458
  environmentId: json["environment_id"],
13452
13459
  feature: json["feature"] == null ? void 0 : FeatureResponseDataFromJSON2(json["feature"]),
@@ -13729,7 +13736,7 @@ var EmbedProvider = ({
13729
13736
  });
13730
13737
  const customHeaders = (0, import_react12.useMemo)(
13731
13738
  () => ({
13732
- "X-Schematic-Components-Version": "1.0.3",
13739
+ "X-Schematic-Components-Version": "1.0.4",
13733
13740
  "X-Schematic-Session-ID": sessionIdRef.current
13734
13741
  }),
13735
13742
  []
@@ -17200,6 +17207,14 @@ var CheckoutDialog = ({ top = 0 }) => {
17200
17207
  )
17201
17208
  );
17202
17209
  const [willTrial, setWillTrial] = (0, import_react29.useState)(false);
17210
+ const selectedPlanCompatibility = (0, import_react29.useMemo)(() => {
17211
+ if (!data?.addOnCompatibilities || !selectedPlan?.id) {
17212
+ return null;
17213
+ }
17214
+ return data.addOnCompatibilities.find(
17215
+ (compat) => compat.sourcePlanId === selectedPlan.id
17216
+ );
17217
+ }, [data?.addOnCompatibilities, selectedPlan?.id]);
17203
17218
  const [addOns, setAddOns] = (0, import_react29.useState)(() => {
17204
17219
  if (isCheckoutData(data)) {
17205
17220
  return availableAddOns.map((addOn) => ({
@@ -17212,6 +17227,24 @@ var CheckoutDialog = ({ top = 0 }) => {
17212
17227
  return [];
17213
17228
  });
17214
17229
  const hasActiveAddOns = addOns.some((addOn) => addOn.isSelected);
17230
+ (0, import_react29.useEffect)(() => {
17231
+ setAddOns((prevAddOns) => {
17232
+ return prevAddOns.filter((availAddOn) => {
17233
+ if (!selectedPlanCompatibility || !selectedPlanCompatibility.compatiblePlanIds?.length) {
17234
+ return true;
17235
+ }
17236
+ return selectedPlanCompatibility?.compatiblePlanIds.includes(
17237
+ availAddOn.id
17238
+ );
17239
+ }).map((addOn) => {
17240
+ const prevAddOn = prevAddOns.find((prev2) => prev2.id === addOn.id);
17241
+ return {
17242
+ ...addOn,
17243
+ isSelected: prevAddOn?.isSelected ?? false
17244
+ };
17245
+ });
17246
+ });
17247
+ }, [selectedPlanCompatibility, selectedPlan?.id]);
17215
17248
  const [usageBasedEntitlements, setUsageBasedEntitlements] = (0, import_react29.useState)(
17216
17249
  () => (selectedPlan?.entitlements || []).reduce(
17217
17250
  createActiveUsageBasedEntitlementsReducer(
@@ -17253,7 +17286,7 @@ var CheckoutDialog = ({ top = 0 }) => {
17253
17286
  name: t2("Quantity")
17254
17287
  });
17255
17288
  }
17256
- if (availableAddOns.length > 0) {
17289
+ if (addOns.length > 0) {
17257
17290
  stages.push({
17258
17291
  id: "addons",
17259
17292
  name: t2("Add-ons"),
@@ -17272,7 +17305,7 @@ var CheckoutDialog = ({ top = 0 }) => {
17272
17305
  }, [
17273
17306
  t2,
17274
17307
  availablePlans,
17275
- availableAddOns,
17308
+ addOns,
17276
17309
  payInAdvanceEntitlements,
17277
17310
  willTrial,
17278
17311
  requiresPayment
@@ -14,17 +14,6 @@ import { RefAttributes } from 'react';
14
14
  import { RuleSet } from 'styled-components';
15
15
  import { Substitute } from 'styled-components/dist/types';
16
16
 
17
- /**
18
- * Schematic API
19
- * Schematic API
20
- *
21
- * The version of the OpenAPI document: 0.1
22
- *
23
- *
24
- * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
25
- * https://openapi-generator.tech
26
- * Do not edit the class manually.
27
- */
28
17
  /**
29
18
  *
30
19
  * @export
@@ -79,6 +68,12 @@ declare interface BillingCreditResponseData {
79
68
  * @memberof BillingCreditResponseData
80
69
  */
81
70
  id: string;
71
+ /**
72
+ *
73
+ * @type {BillingPriceResponseData}
74
+ * @memberof BillingCreditResponseData
75
+ */
76
+ monthlyPrice?: BillingPriceResponseData;
82
77
  /**
83
78
  *
84
79
  * @type {string}
@@ -93,10 +88,10 @@ declare interface BillingCreditResponseData {
93
88
  pluralName?: string | null;
94
89
  /**
95
90
  *
96
- * @type {number}
91
+ * @type {BillingProductResponseData}
97
92
  * @memberof BillingCreditResponseData
98
93
  */
99
- pricePerUnit: number;
94
+ product?: BillingProductResponseData;
100
95
  /**
101
96
  *
102
97
  * @type {string}
@@ -109,19 +104,14 @@ declare interface BillingCreditResponseData {
109
104
  * @memberof BillingCreditResponseData
110
105
  */
111
106
  updatedAt: Date;
107
+ /**
108
+ *
109
+ * @type {BillingPriceResponseData}
110
+ * @memberof BillingCreditResponseData
111
+ */
112
+ yearlyPrice?: BillingPriceResponseData;
112
113
  }
113
114
 
114
- /**
115
- * Schematic API
116
- * Schematic API
117
- *
118
- * The version of the OpenAPI document: 0.1
119
- *
120
- *
121
- * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
122
- * https://openapi-generator.tech
123
- * Do not edit the class manually.
124
- */
125
115
  /**
126
116
  *
127
117
  * @export
@@ -176,6 +166,12 @@ declare interface BillingCreditResponseData_2 {
176
166
  * @memberof BillingCreditResponseData
177
167
  */
178
168
  id: string;
169
+ /**
170
+ *
171
+ * @type {BillingPriceResponseData}
172
+ * @memberof BillingCreditResponseData
173
+ */
174
+ monthlyPrice?: BillingPriceResponseData_2;
179
175
  /**
180
176
  *
181
177
  * @type {string}
@@ -190,10 +186,10 @@ declare interface BillingCreditResponseData_2 {
190
186
  pluralName?: string | null;
191
187
  /**
192
188
  *
193
- * @type {number}
189
+ * @type {BillingProductResponseData}
194
190
  * @memberof BillingCreditResponseData
195
191
  */
196
- pricePerUnit: number;
192
+ product?: BillingProductResponseData_2;
197
193
  /**
198
194
  *
199
195
  * @type {string}
@@ -206,6 +202,12 @@ declare interface BillingCreditResponseData_2 {
206
202
  * @memberof BillingCreditResponseData
207
203
  */
208
204
  updatedAt: Date;
205
+ /**
206
+ *
207
+ * @type {BillingPriceResponseData}
208
+ * @memberof BillingCreditResponseData
209
+ */
210
+ yearlyPrice?: BillingPriceResponseData_2;
209
211
  }
210
212
 
211
213
  /**
@@ -4757,6 +4759,12 @@ declare interface PlanDetailResponseData {
4757
4759
  * @interface PlanEntitlementResponseData
4758
4760
  */
4759
4761
  declare interface PlanEntitlementResponseData {
4762
+ /**
4763
+ *
4764
+ * @type {number}
4765
+ * @memberof PlanEntitlementResponseData
4766
+ */
4767
+ consumptionRate?: number | null;
4760
4768
  /**
4761
4769
  *
4762
4770
  * @type {Date}
@@ -4903,6 +4911,12 @@ declare interface PlanEntitlementResponseData {
4903
4911
  * @interface PlanEntitlementResponseData
4904
4912
  */
4905
4913
  declare interface PlanEntitlementResponseData_2 {
4914
+ /**
4915
+ *
4916
+ * @type {number}
4917
+ * @memberof PlanEntitlementResponseData
4918
+ */
4919
+ consumptionRate?: number | null;
4906
4920
  /**
4907
4921
  *
4908
4922
  * @type {Date}
@@ -6638,6 +6652,12 @@ declare interface UpdatePaymentMethodResponse {
6638
6652
  * @interface UsageBasedEntitlementResponseData
6639
6653
  */
6640
6654
  declare interface UsageBasedEntitlementResponseData {
6655
+ /**
6656
+ *
6657
+ * @type {number}
6658
+ * @memberof UsageBasedEntitlementResponseData
6659
+ */
6660
+ consumptionRate?: number | null;
6641
6661
  /**
6642
6662
  *
6643
6663
  * @type {string}
@@ -10899,27 +10899,26 @@ var JSONApiResponse = class {
10899
10899
  }
10900
10900
  };
10901
10901
 
10902
- // src/api/checkoutexternal/models/BillingCreditResponseData.ts
10903
- function BillingCreditResponseDataFromJSON(json) {
10904
- return BillingCreditResponseDataFromJSONTyped(json, false);
10902
+ // src/api/checkoutexternal/models/BillingProductResponseData.ts
10903
+ function BillingProductResponseDataFromJSON(json) {
10904
+ return BillingProductResponseDataFromJSONTyped(json, false);
10905
10905
  }
10906
- function BillingCreditResponseDataFromJSONTyped(json, ignoreDiscriminator) {
10906
+ function BillingProductResponseDataFromJSONTyped(json, ignoreDiscriminator) {
10907
10907
  if (json == null) {
10908
10908
  return json;
10909
10909
  }
10910
10910
  return {
10911
- burnStrategy: json["burn_strategy"],
10911
+ accountId: json["account_id"],
10912
10912
  createdAt: new Date(json["created_at"]),
10913
- defaultExpiryUnit: json["default_expiry_unit"],
10914
- defaultExpiryUnitCount: json["default_expiry_unit_count"] == null ? void 0 : json["default_expiry_unit_count"],
10915
- defaultRolloverPolicy: json["default_rollover_policy"],
10916
- description: json["description"],
10917
- icon: json["icon"] == null ? void 0 : json["icon"],
10918
- id: json["id"],
10913
+ currency: json["currency"],
10914
+ environmentId: json["environment_id"],
10915
+ externalId: json["external_id"],
10916
+ isActive: json["is_active"],
10919
10917
  name: json["name"],
10920
- pluralName: json["plural_name"] == null ? void 0 : json["plural_name"],
10921
- pricePerUnit: json["price_per_unit"],
10922
- singularName: json["singular_name"] == null ? void 0 : json["singular_name"],
10918
+ price: json["price"],
10919
+ priceDecimal: json["price_decimal"] == null ? void 0 : json["price_decimal"],
10920
+ productId: json["product_id"],
10921
+ quantity: json["quantity"],
10923
10922
  updatedAt: new Date(json["updated_at"])
10924
10923
  };
10925
10924
  }
@@ -10943,6 +10942,33 @@ function BillingPriceResponseDataFromJSONTyped(json, ignoreDiscriminator) {
10943
10942
  };
10944
10943
  }
10945
10944
 
10945
+ // src/api/checkoutexternal/models/BillingCreditResponseData.ts
10946
+ function BillingCreditResponseDataFromJSON(json) {
10947
+ return BillingCreditResponseDataFromJSONTyped(json, false);
10948
+ }
10949
+ function BillingCreditResponseDataFromJSONTyped(json, ignoreDiscriminator) {
10950
+ if (json == null) {
10951
+ return json;
10952
+ }
10953
+ return {
10954
+ burnStrategy: json["burn_strategy"],
10955
+ createdAt: new Date(json["created_at"]),
10956
+ defaultExpiryUnit: json["default_expiry_unit"],
10957
+ defaultExpiryUnitCount: json["default_expiry_unit_count"] == null ? void 0 : json["default_expiry_unit_count"],
10958
+ defaultRolloverPolicy: json["default_rollover_policy"],
10959
+ description: json["description"],
10960
+ icon: json["icon"] == null ? void 0 : json["icon"],
10961
+ id: json["id"],
10962
+ monthlyPrice: json["monthly_price"] == null ? void 0 : BillingPriceResponseDataFromJSON(json["monthly_price"]),
10963
+ name: json["name"],
10964
+ pluralName: json["plural_name"] == null ? void 0 : json["plural_name"],
10965
+ product: json["product"] == null ? void 0 : BillingProductResponseDataFromJSON(json["product"]),
10966
+ singularName: json["singular_name"] == null ? void 0 : json["singular_name"],
10967
+ updatedAt: new Date(json["updated_at"]),
10968
+ yearlyPrice: json["yearly_price"] == null ? void 0 : BillingPriceResponseDataFromJSON(json["yearly_price"])
10969
+ };
10970
+ }
10971
+
10946
10972
  // src/api/checkoutexternal/models/BillingProductPriceTierResponseData.ts
10947
10973
  function BillingProductPriceTierResponseDataFromJSON(json) {
10948
10974
  return BillingProductPriceTierResponseDataFromJSONTyped(json, false);
@@ -11055,30 +11081,6 @@ function BillingProductForSubscriptionResponseDataFromJSONTyped(json, ignoreDisc
11055
11081
  };
11056
11082
  }
11057
11083
 
11058
- // src/api/checkoutexternal/models/BillingProductResponseData.ts
11059
- function BillingProductResponseDataFromJSON(json) {
11060
- return BillingProductResponseDataFromJSONTyped(json, false);
11061
- }
11062
- function BillingProductResponseDataFromJSONTyped(json, ignoreDiscriminator) {
11063
- if (json == null) {
11064
- return json;
11065
- }
11066
- return {
11067
- accountId: json["account_id"],
11068
- createdAt: new Date(json["created_at"]),
11069
- currency: json["currency"],
11070
- environmentId: json["environment_id"],
11071
- externalId: json["external_id"],
11072
- isActive: json["is_active"],
11073
- name: json["name"],
11074
- price: json["price"],
11075
- priceDecimal: json["price_decimal"] == null ? void 0 : json["price_decimal"],
11076
- productId: json["product_id"],
11077
- quantity: json["quantity"],
11078
- updatedAt: new Date(json["updated_at"])
11079
- };
11080
- }
11081
-
11082
11084
  // src/api/checkoutexternal/models/BillingSubscriptionDiscountView.ts
11083
11085
  function BillingSubscriptionDiscountViewFromJSON(json) {
11084
11086
  return BillingSubscriptionDiscountViewFromJSONTyped(json, false);
@@ -11751,6 +11753,7 @@ function PlanEntitlementResponseDataFromJSONTyped(json, ignoreDiscriminator) {
11751
11753
  return json;
11752
11754
  }
11753
11755
  return {
11756
+ consumptionRate: json["consumption_rate"] == null ? void 0 : json["consumption_rate"],
11754
11757
  createdAt: new Date(json["created_at"]),
11755
11758
  environmentId: json["environment_id"],
11756
11759
  feature: json["feature"] == null ? void 0 : FeatureResponseDataFromJSON(json["feature"]),
@@ -11937,6 +11940,7 @@ function UsageBasedEntitlementResponseDataFromJSONTyped(json, ignoreDiscriminato
11937
11940
  return json;
11938
11941
  }
11939
11942
  return {
11943
+ consumptionRate: json["consumption_rate"] == null ? void 0 : json["consumption_rate"],
11940
11944
  featureId: json["feature_id"],
11941
11945
  meteredPrice: json["metered_price"] == null ? void 0 : BillingPriceViewFromJSON(json["metered_price"]),
11942
11946
  metricPeriod: json["metric_period"] == null ? void 0 : json["metric_period"],
@@ -12937,36 +12941,35 @@ var JSONApiResponse2 = class {
12937
12941
  }
12938
12942
  };
12939
12943
 
12940
- // src/api/componentspublic/models/BillingCreditResponseData.ts
12941
- function BillingCreditResponseDataFromJSON2(json) {
12942
- return BillingCreditResponseDataFromJSONTyped3(json, false);
12944
+ // src/api/componentspublic/models/BillingProductResponseData.ts
12945
+ function BillingProductResponseDataFromJSON2(json) {
12946
+ return BillingProductResponseDataFromJSONTyped4(json, false);
12943
12947
  }
12944
- function BillingCreditResponseDataFromJSONTyped3(json, ignoreDiscriminator) {
12948
+ function BillingProductResponseDataFromJSONTyped4(json, ignoreDiscriminator) {
12945
12949
  if (json == null) {
12946
12950
  return json;
12947
12951
  }
12948
12952
  return {
12949
- burnStrategy: json["burn_strategy"],
12953
+ accountId: json["account_id"],
12950
12954
  createdAt: new Date(json["created_at"]),
12951
- defaultExpiryUnit: json["default_expiry_unit"],
12952
- defaultExpiryUnitCount: json["default_expiry_unit_count"] == null ? void 0 : json["default_expiry_unit_count"],
12953
- defaultRolloverPolicy: json["default_rollover_policy"],
12954
- description: json["description"],
12955
- icon: json["icon"] == null ? void 0 : json["icon"],
12956
- id: json["id"],
12955
+ currency: json["currency"],
12956
+ environmentId: json["environment_id"],
12957
+ externalId: json["external_id"],
12958
+ isActive: json["is_active"],
12957
12959
  name: json["name"],
12958
- pluralName: json["plural_name"] == null ? void 0 : json["plural_name"],
12959
- pricePerUnit: json["price_per_unit"],
12960
- singularName: json["singular_name"] == null ? void 0 : json["singular_name"],
12960
+ price: json["price"],
12961
+ priceDecimal: json["price_decimal"] == null ? void 0 : json["price_decimal"],
12962
+ productId: json["product_id"],
12963
+ quantity: json["quantity"],
12961
12964
  updatedAt: new Date(json["updated_at"])
12962
12965
  };
12963
12966
  }
12964
12967
 
12965
12968
  // src/api/componentspublic/models/BillingPriceResponseData.ts
12966
12969
  function BillingPriceResponseDataFromJSON2(json) {
12967
- return BillingPriceResponseDataFromJSONTyped6(json, false);
12970
+ return BillingPriceResponseDataFromJSONTyped7(json, false);
12968
12971
  }
12969
- function BillingPriceResponseDataFromJSONTyped6(json, ignoreDiscriminator) {
12972
+ function BillingPriceResponseDataFromJSONTyped7(json, ignoreDiscriminator) {
12970
12973
  if (json == null) {
12971
12974
  return json;
12972
12975
  }
@@ -12981,6 +12984,33 @@ function BillingPriceResponseDataFromJSONTyped6(json, ignoreDiscriminator) {
12981
12984
  };
12982
12985
  }
12983
12986
 
12987
+ // src/api/componentspublic/models/BillingCreditResponseData.ts
12988
+ function BillingCreditResponseDataFromJSON2(json) {
12989
+ return BillingCreditResponseDataFromJSONTyped3(json, false);
12990
+ }
12991
+ function BillingCreditResponseDataFromJSONTyped3(json, ignoreDiscriminator) {
12992
+ if (json == null) {
12993
+ return json;
12994
+ }
12995
+ return {
12996
+ burnStrategy: json["burn_strategy"],
12997
+ createdAt: new Date(json["created_at"]),
12998
+ defaultExpiryUnit: json["default_expiry_unit"],
12999
+ defaultExpiryUnitCount: json["default_expiry_unit_count"] == null ? void 0 : json["default_expiry_unit_count"],
13000
+ defaultRolloverPolicy: json["default_rollover_policy"],
13001
+ description: json["description"],
13002
+ icon: json["icon"] == null ? void 0 : json["icon"],
13003
+ id: json["id"],
13004
+ monthlyPrice: json["monthly_price"] == null ? void 0 : BillingPriceResponseDataFromJSON2(json["monthly_price"]),
13005
+ name: json["name"],
13006
+ pluralName: json["plural_name"] == null ? void 0 : json["plural_name"],
13007
+ product: json["product"] == null ? void 0 : BillingProductResponseDataFromJSON2(json["product"]),
13008
+ singularName: json["singular_name"] == null ? void 0 : json["singular_name"],
13009
+ updatedAt: new Date(json["updated_at"]),
13010
+ yearlyPrice: json["yearly_price"] == null ? void 0 : BillingPriceResponseDataFromJSON2(json["yearly_price"])
13011
+ };
13012
+ }
13013
+
12984
13014
  // src/api/componentspublic/models/BillingProductPriceTierResponseData.ts
12985
13015
  function BillingProductPriceTierResponseDataFromJSON2(json) {
12986
13016
  return BillingProductPriceTierResponseDataFromJSONTyped4(json, false);
@@ -13060,30 +13090,6 @@ function BillingProductDetailResponseDataFromJSONTyped5(json, ignoreDiscriminato
13060
13090
  };
13061
13091
  }
13062
13092
 
13063
- // src/api/componentspublic/models/BillingProductResponseData.ts
13064
- function BillingProductResponseDataFromJSON2(json) {
13065
- return BillingProductResponseDataFromJSONTyped3(json, false);
13066
- }
13067
- function BillingProductResponseDataFromJSONTyped3(json, ignoreDiscriminator) {
13068
- if (json == null) {
13069
- return json;
13070
- }
13071
- return {
13072
- accountId: json["account_id"],
13073
- createdAt: new Date(json["created_at"]),
13074
- currency: json["currency"],
13075
- environmentId: json["environment_id"],
13076
- externalId: json["external_id"],
13077
- isActive: json["is_active"],
13078
- name: json["name"],
13079
- price: json["price"],
13080
- priceDecimal: json["price_decimal"] == null ? void 0 : json["price_decimal"],
13081
- productId: json["product_id"],
13082
- quantity: json["quantity"],
13083
- updatedAt: new Date(json["updated_at"])
13084
- };
13085
- }
13086
-
13087
13093
  // src/api/componentspublic/models/CompatiblePlans.ts
13088
13094
  function CompatiblePlansFromJSON2(json) {
13089
13095
  return CompatiblePlansFromJSONTyped3(json, false);
@@ -13390,6 +13396,7 @@ function PlanEntitlementResponseDataFromJSONTyped4(json, ignoreDiscriminator) {
13390
13396
  return json;
13391
13397
  }
13392
13398
  return {
13399
+ consumptionRate: json["consumption_rate"] == null ? void 0 : json["consumption_rate"],
13393
13400
  createdAt: new Date(json["created_at"]),
13394
13401
  environmentId: json["environment_id"],
13395
13402
  feature: json["feature"] == null ? void 0 : FeatureResponseDataFromJSON2(json["feature"]),
@@ -13672,7 +13679,7 @@ var EmbedProvider = ({
13672
13679
  });
13673
13680
  const customHeaders = useMemo3(
13674
13681
  () => ({
13675
- "X-Schematic-Components-Version": "1.0.3",
13682
+ "X-Schematic-Components-Version": "1.0.4",
13676
13683
  "X-Schematic-Session-ID": sessionIdRef.current
13677
13684
  }),
13678
13685
  []
@@ -17153,6 +17160,14 @@ var CheckoutDialog = ({ top = 0 }) => {
17153
17160
  )
17154
17161
  );
17155
17162
  const [willTrial, setWillTrial] = useState9(false);
17163
+ const selectedPlanCompatibility = useMemo8(() => {
17164
+ if (!data?.addOnCompatibilities || !selectedPlan?.id) {
17165
+ return null;
17166
+ }
17167
+ return data.addOnCompatibilities.find(
17168
+ (compat) => compat.sourcePlanId === selectedPlan.id
17169
+ );
17170
+ }, [data?.addOnCompatibilities, selectedPlan?.id]);
17156
17171
  const [addOns, setAddOns] = useState9(() => {
17157
17172
  if (isCheckoutData(data)) {
17158
17173
  return availableAddOns.map((addOn) => ({
@@ -17165,6 +17180,24 @@ var CheckoutDialog = ({ top = 0 }) => {
17165
17180
  return [];
17166
17181
  });
17167
17182
  const hasActiveAddOns = addOns.some((addOn) => addOn.isSelected);
17183
+ useEffect5(() => {
17184
+ setAddOns((prevAddOns) => {
17185
+ return prevAddOns.filter((availAddOn) => {
17186
+ if (!selectedPlanCompatibility || !selectedPlanCompatibility.compatiblePlanIds?.length) {
17187
+ return true;
17188
+ }
17189
+ return selectedPlanCompatibility?.compatiblePlanIds.includes(
17190
+ availAddOn.id
17191
+ );
17192
+ }).map((addOn) => {
17193
+ const prevAddOn = prevAddOns.find((prev2) => prev2.id === addOn.id);
17194
+ return {
17195
+ ...addOn,
17196
+ isSelected: prevAddOn?.isSelected ?? false
17197
+ };
17198
+ });
17199
+ });
17200
+ }, [selectedPlanCompatibility, selectedPlan?.id]);
17168
17201
  const [usageBasedEntitlements, setUsageBasedEntitlements] = useState9(
17169
17202
  () => (selectedPlan?.entitlements || []).reduce(
17170
17203
  createActiveUsageBasedEntitlementsReducer(
@@ -17206,7 +17239,7 @@ var CheckoutDialog = ({ top = 0 }) => {
17206
17239
  name: t2("Quantity")
17207
17240
  });
17208
17241
  }
17209
- if (availableAddOns.length > 0) {
17242
+ if (addOns.length > 0) {
17210
17243
  stages.push({
17211
17244
  id: "addons",
17212
17245
  name: t2("Add-ons"),
@@ -17225,7 +17258,7 @@ var CheckoutDialog = ({ top = 0 }) => {
17225
17258
  }, [
17226
17259
  t2,
17227
17260
  availablePlans,
17228
- availableAddOns,
17261
+ addOns,
17229
17262
  payInAdvanceEntitlements,
17230
17263
  willTrial,
17231
17264
  requiresPayment
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@schematichq/schematic-components",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "main": "dist/schematic-components.cjs.js",
5
5
  "module": "dist/schematic-components.esm.js",
6
6
  "types": "dist/schematic-components.d.ts",