@schematichq/schematic-components 0.3.9 → 0.3.10

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.
@@ -2641,7 +2641,7 @@ var registerWrapper = function registerWrapper2(stripe, startTime) {
2641
2641
  }
2642
2642
  stripe._registerWrapper({
2643
2643
  name: "stripe-js",
2644
- version: "4.7.0",
2644
+ version: "4.8.0",
2645
2645
  startTime
2646
2646
  });
2647
2647
  };
@@ -7264,9 +7264,6 @@ function BillingProductDetailResponseDataFromJSONTyped(json, ignoreDiscriminator
7264
7264
  return json;
7265
7265
  }
7266
7266
  return {
7267
- prices: json["Prices"].map(
7268
- BillingPriceResponseDataFromJSON
7269
- ),
7270
7267
  accountId: json["account_id"],
7271
7268
  createdAt: new Date(json["created_at"]),
7272
7269
  currency: json["currency"],
@@ -7274,6 +7271,9 @@ function BillingProductDetailResponseDataFromJSONTyped(json, ignoreDiscriminator
7274
7271
  externalId: json["external_id"],
7275
7272
  name: json["name"],
7276
7273
  price: json["price"],
7274
+ prices: json["prices"].map(
7275
+ BillingPriceResponseDataFromJSON
7276
+ ),
7277
7277
  productId: json["product_id"],
7278
7278
  quantity: json["quantity"],
7279
7279
  updatedAt: new Date(json["updated_at"])
@@ -7289,7 +7289,6 @@ function BillingProductForSubscriptionResponseDataFromJSONTyped(json, ignoreDisc
7289
7289
  return json;
7290
7290
  }
7291
7291
  return {
7292
- accountId: json["account_id"],
7293
7292
  createdAt: new Date(json["created_at"]),
7294
7293
  currency: json["currency"],
7295
7294
  environmentId: json["environment_id"],
@@ -7314,16 +7313,111 @@ function BillingSubscriptionResponseDataFromJSONTyped(json, ignoreDiscriminator)
7314
7313
  return json;
7315
7314
  }
7316
7315
  return {
7316
+ companyId: json["company_id"] == null ? void 0 : json["company_id"],
7317
+ createdAt: new Date(json["created_at"]),
7317
7318
  currency: json["currency"],
7319
+ customerExternalId: json["customer_external_id"],
7318
7320
  expiredAt: json["expired_at"] == null ? void 0 : new Date(json["expired_at"]),
7319
- externalId: json["external_id"],
7320
7321
  id: json["id"],
7321
7322
  interval: json["interval"],
7322
- totalPrice: json["total_price"],
7323
+ metadata: json["metadata"] == null ? void 0 : json["metadata"],
7324
+ periodEnd: json["period_end"],
7325
+ periodStart: json["period_start"],
7326
+ status: json["status"],
7327
+ subscriptionExternalId: json["subscription_external_id"],
7328
+ totalPrice: json["total_price"]
7329
+ };
7330
+ }
7331
+
7332
+ // src/api/models/InvoiceResponseData.ts
7333
+ function InvoiceResponseDataFromJSON(json) {
7334
+ return InvoiceResponseDataFromJSONTyped(json, false);
7335
+ }
7336
+ function InvoiceResponseDataFromJSONTyped(json, ignoreDiscriminator) {
7337
+ if (json == null) {
7338
+ return json;
7339
+ }
7340
+ return {
7341
+ amountDue: json["amount_due"],
7342
+ amountPaid: json["amount_paid"],
7343
+ amountRemaining: json["amount_remaining"],
7344
+ collectionMethod: json["collection_method"],
7345
+ companyId: json["company_id"] == null ? void 0 : json["company_id"],
7346
+ createdAt: new Date(json["created_at"]),
7347
+ currency: json["currency"],
7348
+ customerExternalId: json["customer_external_id"],
7349
+ dueDate: json["due_date"] == null ? void 0 : new Date(json["due_date"]),
7350
+ environmentId: json["environment_id"],
7351
+ externalId: json["external_id"] == null ? void 0 : json["external_id"],
7352
+ id: json["id"],
7353
+ paymentMethodExternalId: json["payment_method_external_id"] == null ? void 0 : json["payment_method_external_id"],
7354
+ subscriptionExternalId: json["subscription_external_id"] == null ? void 0 : json["subscription_external_id"],
7355
+ subtotal: json["subtotal"],
7356
+ updatedAt: new Date(json["updated_at"]),
7357
+ url: json["url"] == null ? void 0 : json["url"]
7358
+ };
7359
+ }
7360
+
7361
+ // src/api/models/PaymentMethodResponseData.ts
7362
+ function PaymentMethodResponseDataFromJSON(json) {
7363
+ return PaymentMethodResponseDataFromJSONTyped(json, false);
7364
+ }
7365
+ function PaymentMethodResponseDataFromJSONTyped(json, ignoreDiscriminator) {
7366
+ if (json == null) {
7367
+ return json;
7368
+ }
7369
+ return {
7370
+ accountLast4: json["account_last4"] == null ? void 0 : json["account_last4"],
7371
+ accountName: json["account_name"] == null ? void 0 : json["account_name"],
7372
+ bankName: json["bank_name"] == null ? void 0 : json["bank_name"],
7373
+ billingEmail: json["billing_email"] == null ? void 0 : json["billing_email"],
7374
+ billingName: json["billing_name"] == null ? void 0 : json["billing_name"],
7375
+ cardBrand: json["card_brand"] == null ? void 0 : json["card_brand"],
7376
+ cardExpMonth: json["card_exp_month"] == null ? void 0 : json["card_exp_month"],
7377
+ cardExpYear: json["card_exp_year"] == null ? void 0 : json["card_exp_year"],
7378
+ cardLast4: json["card_last4"] == null ? void 0 : json["card_last4"],
7379
+ companyId: json["company_id"] == null ? void 0 : json["company_id"],
7380
+ createdAt: new Date(json["created_at"]),
7381
+ customerExternalId: json["customer_external_id"],
7382
+ environmentId: json["environment_id"],
7383
+ externalId: json["external_id"],
7384
+ id: json["id"],
7385
+ paymentMethodType: json["payment_method_type"],
7386
+ subscriptionExternalId: json["subscription_external_id"] == null ? void 0 : json["subscription_external_id"],
7323
7387
  updatedAt: new Date(json["updated_at"])
7324
7388
  };
7325
7389
  }
7326
7390
 
7391
+ // src/api/models/BillingSubscriptionView.ts
7392
+ function BillingSubscriptionViewFromJSON(json) {
7393
+ return BillingSubscriptionViewFromJSONTyped(json, false);
7394
+ }
7395
+ function BillingSubscriptionViewFromJSONTyped(json, ignoreDiscriminator) {
7396
+ if (json == null) {
7397
+ return json;
7398
+ }
7399
+ return {
7400
+ companyId: json["company_id"] == null ? void 0 : json["company_id"],
7401
+ createdAt: new Date(json["created_at"]),
7402
+ currency: json["currency"],
7403
+ customerExternalId: json["customer_external_id"],
7404
+ expiredAt: json["expired_at"] == null ? void 0 : new Date(json["expired_at"]),
7405
+ id: json["id"],
7406
+ interval: json["interval"],
7407
+ latestInvoice: json["latest_invoice"] == null ? void 0 : InvoiceResponseDataFromJSON(json["latest_invoice"]),
7408
+ metadata: json["metadata"] == null ? void 0 : json["metadata"],
7409
+ paymentMethod: json["payment_method"] == null ? void 0 : PaymentMethodResponseDataFromJSON(json["payment_method"]),
7410
+ periodEnd: json["period_end"],
7411
+ periodStart: json["period_start"],
7412
+ products: json["products"].map(
7413
+ BillingProductForSubscriptionResponseDataFromJSON
7414
+ ),
7415
+ status: json["status"],
7416
+ subscriptionExternalId: json["subscription_external_id"],
7417
+ totalPrice: json["total_price"]
7418
+ };
7419
+ }
7420
+
7327
7421
  // src/api/models/ChangeSubscriptionRequestBody.ts
7328
7422
  function ChangeSubscriptionRequestBodyToJSON(value) {
7329
7423
  if (value == null) {
@@ -7475,7 +7569,7 @@ function CompanyDetailResponseDataFromJSONTyped(json, ignoreDiscriminator) {
7475
7569
  CompanyPlanWithBillingSubViewFromJSON
7476
7570
  ),
7477
7571
  billingSubscriptions: json["billing_subscriptions"].map(
7478
- BillingSubscriptionResponseDataFromJSON
7572
+ BillingSubscriptionViewFromJSON
7479
7573
  ),
7480
7574
  createdAt: new Date(json["created_at"]),
7481
7575
  entityTraits: json["entity_traits"].map(
@@ -7783,65 +7877,6 @@ function CompanyPlanDetailResponseDataFromJSONTyped(json, ignoreDiscriminator) {
7783
7877
  };
7784
7878
  }
7785
7879
 
7786
- // src/api/models/InvoiceResponseData.ts
7787
- function InvoiceResponseDataFromJSON(json) {
7788
- return InvoiceResponseDataFromJSONTyped(json, false);
7789
- }
7790
- function InvoiceResponseDataFromJSONTyped(json, ignoreDiscriminator) {
7791
- if (json == null) {
7792
- return json;
7793
- }
7794
- return {
7795
- amountDue: json["amount_due"],
7796
- amountPaid: json["amount_paid"],
7797
- amountRemaining: json["amount_remaining"],
7798
- collectionMethod: json["collection_method"],
7799
- companyId: json["company_id"] == null ? void 0 : json["company_id"],
7800
- createdAt: new Date(json["created_at"]),
7801
- currency: json["currency"],
7802
- customerExternalId: json["customer_external_id"],
7803
- dueDate: json["due_date"] == null ? void 0 : new Date(json["due_date"]),
7804
- environmentId: json["environment_id"],
7805
- externalId: json["external_id"] == null ? void 0 : json["external_id"],
7806
- id: json["id"],
7807
- paymentMethodExternalId: json["payment_method_external_id"] == null ? void 0 : json["payment_method_external_id"],
7808
- subscriptionExternalId: json["subscription_external_id"] == null ? void 0 : json["subscription_external_id"],
7809
- subtotal: json["subtotal"],
7810
- updatedAt: new Date(json["updated_at"]),
7811
- url: json["url"] == null ? void 0 : json["url"]
7812
- };
7813
- }
7814
-
7815
- // src/api/models/PaymentMethodResponseData.ts
7816
- function PaymentMethodResponseDataFromJSON(json) {
7817
- return PaymentMethodResponseDataFromJSONTyped(json, false);
7818
- }
7819
- function PaymentMethodResponseDataFromJSONTyped(json, ignoreDiscriminator) {
7820
- if (json == null) {
7821
- return json;
7822
- }
7823
- return {
7824
- accountLast4: json["account_last4"] == null ? void 0 : json["account_last4"],
7825
- accountName: json["account_name"] == null ? void 0 : json["account_name"],
7826
- bankName: json["bank_name"] == null ? void 0 : json["bank_name"],
7827
- billingEmail: json["billing_email"] == null ? void 0 : json["billing_email"],
7828
- billingName: json["billing_name"] == null ? void 0 : json["billing_name"],
7829
- cardBrand: json["card_brand"] == null ? void 0 : json["card_brand"],
7830
- cardExpMonth: json["card_exp_month"] == null ? void 0 : json["card_exp_month"],
7831
- cardExpYear: json["card_exp_year"] == null ? void 0 : json["card_exp_year"],
7832
- cardLast4: json["card_last4"] == null ? void 0 : json["card_last4"],
7833
- companyId: json["company_id"] == null ? void 0 : json["company_id"],
7834
- createdAt: new Date(json["created_at"]),
7835
- customerExternalId: json["customer_external_id"],
7836
- environmentId: json["environment_id"],
7837
- externalId: json["external_id"],
7838
- id: json["id"],
7839
- paymentMethodType: json["payment_method_type"],
7840
- subscriptionExternalId: json["subscription_external_id"] == null ? void 0 : json["subscription_external_id"],
7841
- updatedAt: new Date(json["updated_at"])
7842
- };
7843
- }
7844
-
7845
7880
  // src/api/models/CompanySubscriptionResponseData.ts
7846
7881
  function CompanySubscriptionResponseDataFromJSON(json) {
7847
7882
  return CompanySubscriptionResponseDataFromJSONTyped(json, false);
@@ -7866,6 +7901,19 @@ function CompanySubscriptionResponseDataFromJSONTyped(json, ignoreDiscriminator)
7866
7901
  };
7867
7902
  }
7868
7903
 
7904
+ // src/api/models/ComponentCapabilities.ts
7905
+ function ComponentCapabilitiesFromJSON(json) {
7906
+ return ComponentCapabilitiesFromJSONTyped(json, false);
7907
+ }
7908
+ function ComponentCapabilitiesFromJSONTyped(json, ignoreDiscriminator) {
7909
+ if (json == null) {
7910
+ return json;
7911
+ }
7912
+ return {
7913
+ checkout: json["checkout"]
7914
+ };
7915
+ }
7916
+
7869
7917
  // src/api/models/ComponentResponseData.ts
7870
7918
  function ComponentResponseDataFromJSON(json) {
7871
7919
  return ComponentResponseDataFromJSONTyped(json, false);
@@ -7944,9 +7992,13 @@ function ComponentHydrateResponseDataFromJSONTyped(json, ignoreDiscriminator) {
7944
7992
  return json;
7945
7993
  }
7946
7994
  return {
7995
+ activeAddOns: json["active_add_ons"].map(
7996
+ CompanyPlanDetailResponseDataFromJSON
7997
+ ),
7947
7998
  activePlans: json["active_plans"].map(
7948
7999
  CompanyPlanDetailResponseDataFromJSON
7949
8000
  ),
8001
+ capabilities: json["capabilities"] == null ? void 0 : ComponentCapabilitiesFromJSON(json["capabilities"]),
7950
8002
  company: json["company"] == null ? void 0 : CompanyDetailResponseDataFromJSON(json["company"]),
7951
8003
  component: json["component"] == null ? void 0 : ComponentResponseDataFromJSON(json["component"]),
7952
8004
  featureUsage: json["feature_usage"] == null ? void 0 : FeatureUsageDetailResponseDataFromJSON(json["feature_usage"]),
@@ -8751,6 +8803,7 @@ function parseEditorState(data) {
8751
8803
  var EmbedContext = (0, import_react2.createContext)({
8752
8804
  api: null,
8753
8805
  data: {
8806
+ activeAddOns: [],
8754
8807
  activePlans: []
8755
8808
  },
8756
8809
  nodes: [],
@@ -8781,6 +8834,7 @@ var EmbedProvider = ({
8781
8834
  return {
8782
8835
  api: null,
8783
8836
  data: {
8837
+ activeAddOns: [],
8784
8838
  activePlans: []
8785
8839
  },
8786
8840
  nodes: [],
@@ -8882,7 +8936,7 @@ var EmbedProvider = ({
8882
8936
  (0, import_react2.useEffect)(() => {
8883
8937
  if (accessToken) {
8884
8938
  const { headers = {} } = apiConfig ?? {};
8885
- headers["X-Schematic-Components-Version"] = "0.3.9";
8939
+ headers["X-Schematic-Components-Version"] = "0.3.10";
8886
8940
  headers["X-Schematic-Session-ID"] = sessionIdRef.current;
8887
8941
  const config = new Configuration({
8888
8942
  ...apiConfig,
@@ -9946,7 +10000,8 @@ var CheckoutDialog = () => {
9946
10000
  document.body.style.overflow = "";
9947
10001
  };
9948
10002
  }, []);
9949
- const allowCheckout = api && selectedPlan && (selectedPlan.id !== currentPlan?.id || planPeriod !== currentPlan.planPeriod) && (paymentMethod && !showPaymentForm || paymentMethodId) && !isLoading;
10003
+ const canUpdateSubscription = api && selectedPlan && (selectedPlan.id !== currentPlan?.id || planPeriod !== currentPlan.planPeriod) && !isLoading;
10004
+ const canCheckout = canUpdateSubscription && (paymentMethod && !showPaymentForm || paymentMethodId);
9950
10005
  return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(Modal, { size: "lg", children: [
9951
10006
  /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ModalHeader, { bordered: true, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(Flex, { $gap: "1rem", children: [
9952
10007
  /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(Flex, { $gap: "0.5rem", $alignItems: "center", children: [
@@ -10467,7 +10522,7 @@ var CheckoutDialog = () => {
10467
10522
  /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
10468
10523
  Flex,
10469
10524
  {
10470
- ...allowCheckout && {
10525
+ ...canCheckout && {
10471
10526
  $opacity: "0.625",
10472
10527
  $textDecoration: "line-through"
10473
10528
  },
@@ -10500,7 +10555,7 @@ var CheckoutDialog = () => {
10500
10555
  ]
10501
10556
  }
10502
10557
  ),
10503
- allowCheckout && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(Box, { $marginBottom: "1rem", children: [
10558
+ canCheckout && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(Box, { $marginBottom: "1rem", children: [
10504
10559
  /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
10505
10560
  Box,
10506
10561
  {
@@ -10693,7 +10748,7 @@ var CheckoutDialog = () => {
10693
10748
  EmbedButton,
10694
10749
  {
10695
10750
  isLoading,
10696
- ...allowCheckout ? {
10751
+ ...canUpdateSubscription ? {
10697
10752
  onClick: async () => {
10698
10753
  if (!data.component?.id) {
10699
10754
  return;
@@ -10722,9 +10777,9 @@ var CheckoutDialog = () => {
10722
10777
  ) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
10723
10778
  EmbedButton,
10724
10779
  {
10725
- disabled: isLoading || !allowCheckout,
10780
+ disabled: isLoading || !canCheckout,
10726
10781
  isLoading,
10727
- ...allowCheckout && { onClick: checkout },
10782
+ ...canCheckout && { onClick: checkout },
10728
10783
  children: "Pay now"
10729
10784
  }
10730
10785
  ),
@@ -11752,12 +11807,12 @@ var resolveDesignProps5 = (props) => {
11752
11807
  var PlanManager = (0, import_react19.forwardRef)(({ children, className, portal, ...rest }, ref) => {
11753
11808
  const props = resolveDesignProps5(rest);
11754
11809
  const theme = nt();
11755
- const { data, layout, mode, setLayout } = useEmbed();
11810
+ const { data, layout, setLayout } = useEmbed();
11756
11811
  const isLightBackground = useIsLightBackground();
11757
11812
  const { currentPlan, canChangePlan, addOns } = {
11758
- currentPlan: data.company?.plan,
11759
- canChangePlan: (mode === "edit" || data.stripeEmbed?.publishableKey && data.company?.plan?.billingProductId) && data.activePlans.length > 0,
11760
- addOns: data.company?.addOns || []
11813
+ addOns: data.company?.addOns || [],
11814
+ canChangePlan: data.capabilities?.checkout ?? true,
11815
+ currentPlan: data.company?.plan
11761
11816
  };
11762
11817
  return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
11763
11818
  Element,
@@ -12088,6 +12143,7 @@ var ComponentTree = () => {
12088
12143
  setChildren(nodes.map(renderer));
12089
12144
  }, [nodes]);
12090
12145
  if (error) {
12146
+ console.error(error);
12091
12147
  return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Error2, { message: error.message });
12092
12148
  }
12093
12149
  if (import_react22.Children.count(children) === 0) {
@@ -117,12 +117,6 @@ declare interface BillingPriceResponseData {
117
117
  * @interface BillingProductDetailResponseData
118
118
  */
119
119
  declare interface BillingProductDetailResponseData {
120
- /**
121
- *
122
- * @type {Array<BillingPriceResponseData>}
123
- * @memberof BillingProductDetailResponseData
124
- */
125
- prices: Array<BillingPriceResponseData>;
126
120
  /**
127
121
  *
128
122
  * @type {string}
@@ -165,6 +159,12 @@ declare interface BillingProductDetailResponseData {
165
159
  * @memberof BillingProductDetailResponseData
166
160
  */
167
161
  price: number;
162
+ /**
163
+ *
164
+ * @type {Array<BillingPriceResponseData>}
165
+ * @memberof BillingProductDetailResponseData
166
+ */
167
+ prices: Array<BillingPriceResponseData>;
168
168
  /**
169
169
  *
170
170
  * @type {string}
@@ -202,12 +202,6 @@ declare interface BillingProductDetailResponseData {
202
202
  * @interface BillingProductForSubscriptionResponseData
203
203
  */
204
204
  declare interface BillingProductForSubscriptionResponseData {
205
- /**
206
- *
207
- * @type {string}
208
- * @memberof BillingProductForSubscriptionResponseData
209
- */
210
- accountId: string;
211
205
  /**
212
206
  *
213
207
  * @type {Date}
@@ -304,19 +298,31 @@ declare interface BillingSubscriptionResponseData {
304
298
  * @type {string}
305
299
  * @memberof BillingSubscriptionResponseData
306
300
  */
307
- currency: string;
301
+ companyId?: string | null;
308
302
  /**
309
303
  *
310
304
  * @type {Date}
311
305
  * @memberof BillingSubscriptionResponseData
312
306
  */
313
- expiredAt?: Date | null;
307
+ createdAt: Date;
314
308
  /**
315
309
  *
316
310
  * @type {string}
317
311
  * @memberof BillingSubscriptionResponseData
318
312
  */
319
- externalId: string;
313
+ currency: string;
314
+ /**
315
+ *
316
+ * @type {string}
317
+ * @memberof BillingSubscriptionResponseData
318
+ */
319
+ customerExternalId: string;
320
+ /**
321
+ *
322
+ * @type {Date}
323
+ * @memberof BillingSubscriptionResponseData
324
+ */
325
+ expiredAt?: Date | null;
320
326
  /**
321
327
  *
322
328
  * @type {string}
@@ -329,18 +335,146 @@ declare interface BillingSubscriptionResponseData {
329
335
  * @memberof BillingSubscriptionResponseData
330
336
  */
331
337
  interval: string;
338
+ /**
339
+ *
340
+ * @type {object}
341
+ * @memberof BillingSubscriptionResponseData
342
+ */
343
+ metadata?: object;
344
+ /**
345
+ *
346
+ * @type {number}
347
+ * @memberof BillingSubscriptionResponseData
348
+ */
349
+ periodEnd: number;
350
+ /**
351
+ *
352
+ * @type {number}
353
+ * @memberof BillingSubscriptionResponseData
354
+ */
355
+ periodStart: number;
356
+ /**
357
+ *
358
+ * @type {string}
359
+ * @memberof BillingSubscriptionResponseData
360
+ */
361
+ status: string;
362
+ /**
363
+ *
364
+ * @type {string}
365
+ * @memberof BillingSubscriptionResponseData
366
+ */
367
+ subscriptionExternalId: string;
332
368
  /**
333
369
  *
334
370
  * @type {number}
335
371
  * @memberof BillingSubscriptionResponseData
336
372
  */
337
373
  totalPrice: number;
374
+ }
375
+
376
+ /**
377
+ *
378
+ * @export
379
+ * @interface BillingSubscriptionView
380
+ */
381
+ declare interface BillingSubscriptionView {
382
+ /**
383
+ *
384
+ * @type {string}
385
+ * @memberof BillingSubscriptionView
386
+ */
387
+ companyId?: string | null;
338
388
  /**
339
389
  *
340
390
  * @type {Date}
341
- * @memberof BillingSubscriptionResponseData
391
+ * @memberof BillingSubscriptionView
342
392
  */
343
- updatedAt: Date;
393
+ createdAt: Date;
394
+ /**
395
+ *
396
+ * @type {string}
397
+ * @memberof BillingSubscriptionView
398
+ */
399
+ currency: string;
400
+ /**
401
+ *
402
+ * @type {string}
403
+ * @memberof BillingSubscriptionView
404
+ */
405
+ customerExternalId: string;
406
+ /**
407
+ *
408
+ * @type {Date}
409
+ * @memberof BillingSubscriptionView
410
+ */
411
+ expiredAt?: Date | null;
412
+ /**
413
+ *
414
+ * @type {string}
415
+ * @memberof BillingSubscriptionView
416
+ */
417
+ id: string;
418
+ /**
419
+ *
420
+ * @type {string}
421
+ * @memberof BillingSubscriptionView
422
+ */
423
+ interval: string;
424
+ /**
425
+ *
426
+ * @type {InvoiceResponseData}
427
+ * @memberof BillingSubscriptionView
428
+ */
429
+ latestInvoice?: InvoiceResponseData;
430
+ /**
431
+ *
432
+ * @type {object}
433
+ * @memberof BillingSubscriptionView
434
+ */
435
+ metadata?: object;
436
+ /**
437
+ *
438
+ * @type {PaymentMethodResponseData}
439
+ * @memberof BillingSubscriptionView
440
+ */
441
+ paymentMethod?: PaymentMethodResponseData;
442
+ /**
443
+ *
444
+ * @type {number}
445
+ * @memberof BillingSubscriptionView
446
+ */
447
+ periodEnd: number;
448
+ /**
449
+ *
450
+ * @type {number}
451
+ * @memberof BillingSubscriptionView
452
+ */
453
+ periodStart: number;
454
+ /**
455
+ *
456
+ * @type {Array<BillingProductForSubscriptionResponseData>}
457
+ * @memberof BillingSubscriptionView
458
+ */
459
+ products: Array<BillingProductForSubscriptionResponseData>;
460
+ /**
461
+ *
462
+ * @type {string}
463
+ * @memberof BillingSubscriptionView
464
+ */
465
+ status: string;
466
+ /**
467
+ *
468
+ * @type {string}
469
+ * @memberof BillingSubscriptionView
470
+ */
471
+ subscriptionExternalId: string;
472
+ /**
473
+ *
474
+ * @type {number}
475
+ * @memberof BillingSubscriptionView
476
+ */
477
+ totalPrice: number;
344
478
  }
345
479
 
346
480
  declare class BlobApiResponse {
@@ -521,10 +655,10 @@ declare interface CompanyDetailResponseData {
521
655
  addOns: Array<CompanyPlanWithBillingSubView>;
522
656
  /**
523
657
  *
524
- * @type {Array<BillingSubscriptionResponseData>}
658
+ * @type {Array<BillingSubscriptionView>}
525
659
  * @memberof CompanyDetailResponseData
526
660
  */
527
- billingSubscriptions: Array<BillingSubscriptionResponseData>;
661
+ billingSubscriptions: Array<BillingSubscriptionView>;
528
662
  /**
529
663
  *
530
664
  * @type {Date}
@@ -844,18 +978,55 @@ declare interface CompanySubscriptionResponseData {
844
978
  totalPrice: number;
845
979
  }
846
980
 
981
+ /**
982
+ * Schematic API
983
+ * Schematic API
984
+ *
985
+ * The version of the OpenAPI document: 0.1
986
+ *
987
+ *
988
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
989
+ * https://openapi-generator.tech
990
+ * Do not edit the class manually.
991
+ */
992
+ /**
993
+ *
994
+ * @export
995
+ * @interface ComponentCapabilities
996
+ */
997
+ declare interface ComponentCapabilities {
998
+ /**
999
+ *
1000
+ * @type {boolean}
1001
+ * @memberof ComponentCapabilities
1002
+ */
1003
+ checkout: boolean;
1004
+ }
1005
+
847
1006
  /**
848
1007
  * The returned resource
849
1008
  * @export
850
1009
  * @interface ComponentHydrateResponseData
851
1010
  */
852
1011
  declare interface ComponentHydrateResponseData {
1012
+ /**
1013
+ *
1014
+ * @type {Array<CompanyPlanDetailResponseData>}
1015
+ * @memberof ComponentHydrateResponseData
1016
+ */
1017
+ activeAddOns: Array<CompanyPlanDetailResponseData>;
853
1018
  /**
854
1019
  *
855
1020
  * @type {Array<CompanyPlanDetailResponseData>}
856
1021
  * @memberof ComponentHydrateResponseData
857
1022
  */
858
1023
  activePlans: Array<CompanyPlanDetailResponseData>;
1024
+ /**
1025
+ *
1026
+ * @type {ComponentCapabilities}
1027
+ * @memberof ComponentHydrateResponseData
1028
+ */
1029
+ capabilities?: ComponentCapabilities;
859
1030
  /**
860
1031
  *
861
1032
  * @type {CompanyDetailResponseData}
@@ -2601,7 +2601,7 @@ var registerWrapper = function registerWrapper2(stripe, startTime) {
2601
2601
  }
2602
2602
  stripe._registerWrapper({
2603
2603
  name: "stripe-js",
2604
- version: "4.7.0",
2604
+ version: "4.8.0",
2605
2605
  startTime
2606
2606
  });
2607
2607
  };
@@ -7224,9 +7224,6 @@ function BillingProductDetailResponseDataFromJSONTyped(json, ignoreDiscriminator
7224
7224
  return json;
7225
7225
  }
7226
7226
  return {
7227
- prices: json["Prices"].map(
7228
- BillingPriceResponseDataFromJSON
7229
- ),
7230
7227
  accountId: json["account_id"],
7231
7228
  createdAt: new Date(json["created_at"]),
7232
7229
  currency: json["currency"],
@@ -7234,6 +7231,9 @@ function BillingProductDetailResponseDataFromJSONTyped(json, ignoreDiscriminator
7234
7231
  externalId: json["external_id"],
7235
7232
  name: json["name"],
7236
7233
  price: json["price"],
7234
+ prices: json["prices"].map(
7235
+ BillingPriceResponseDataFromJSON
7236
+ ),
7237
7237
  productId: json["product_id"],
7238
7238
  quantity: json["quantity"],
7239
7239
  updatedAt: new Date(json["updated_at"])
@@ -7249,7 +7249,6 @@ function BillingProductForSubscriptionResponseDataFromJSONTyped(json, ignoreDisc
7249
7249
  return json;
7250
7250
  }
7251
7251
  return {
7252
- accountId: json["account_id"],
7253
7252
  createdAt: new Date(json["created_at"]),
7254
7253
  currency: json["currency"],
7255
7254
  environmentId: json["environment_id"],
@@ -7274,16 +7273,111 @@ function BillingSubscriptionResponseDataFromJSONTyped(json, ignoreDiscriminator)
7274
7273
  return json;
7275
7274
  }
7276
7275
  return {
7276
+ companyId: json["company_id"] == null ? void 0 : json["company_id"],
7277
+ createdAt: new Date(json["created_at"]),
7277
7278
  currency: json["currency"],
7279
+ customerExternalId: json["customer_external_id"],
7278
7280
  expiredAt: json["expired_at"] == null ? void 0 : new Date(json["expired_at"]),
7279
- externalId: json["external_id"],
7280
7281
  id: json["id"],
7281
7282
  interval: json["interval"],
7282
- totalPrice: json["total_price"],
7283
+ metadata: json["metadata"] == null ? void 0 : json["metadata"],
7284
+ periodEnd: json["period_end"],
7285
+ periodStart: json["period_start"],
7286
+ status: json["status"],
7287
+ subscriptionExternalId: json["subscription_external_id"],
7288
+ totalPrice: json["total_price"]
7289
+ };
7290
+ }
7291
+
7292
+ // src/api/models/InvoiceResponseData.ts
7293
+ function InvoiceResponseDataFromJSON(json) {
7294
+ return InvoiceResponseDataFromJSONTyped(json, false);
7295
+ }
7296
+ function InvoiceResponseDataFromJSONTyped(json, ignoreDiscriminator) {
7297
+ if (json == null) {
7298
+ return json;
7299
+ }
7300
+ return {
7301
+ amountDue: json["amount_due"],
7302
+ amountPaid: json["amount_paid"],
7303
+ amountRemaining: json["amount_remaining"],
7304
+ collectionMethod: json["collection_method"],
7305
+ companyId: json["company_id"] == null ? void 0 : json["company_id"],
7306
+ createdAt: new Date(json["created_at"]),
7307
+ currency: json["currency"],
7308
+ customerExternalId: json["customer_external_id"],
7309
+ dueDate: json["due_date"] == null ? void 0 : new Date(json["due_date"]),
7310
+ environmentId: json["environment_id"],
7311
+ externalId: json["external_id"] == null ? void 0 : json["external_id"],
7312
+ id: json["id"],
7313
+ paymentMethodExternalId: json["payment_method_external_id"] == null ? void 0 : json["payment_method_external_id"],
7314
+ subscriptionExternalId: json["subscription_external_id"] == null ? void 0 : json["subscription_external_id"],
7315
+ subtotal: json["subtotal"],
7316
+ updatedAt: new Date(json["updated_at"]),
7317
+ url: json["url"] == null ? void 0 : json["url"]
7318
+ };
7319
+ }
7320
+
7321
+ // src/api/models/PaymentMethodResponseData.ts
7322
+ function PaymentMethodResponseDataFromJSON(json) {
7323
+ return PaymentMethodResponseDataFromJSONTyped(json, false);
7324
+ }
7325
+ function PaymentMethodResponseDataFromJSONTyped(json, ignoreDiscriminator) {
7326
+ if (json == null) {
7327
+ return json;
7328
+ }
7329
+ return {
7330
+ accountLast4: json["account_last4"] == null ? void 0 : json["account_last4"],
7331
+ accountName: json["account_name"] == null ? void 0 : json["account_name"],
7332
+ bankName: json["bank_name"] == null ? void 0 : json["bank_name"],
7333
+ billingEmail: json["billing_email"] == null ? void 0 : json["billing_email"],
7334
+ billingName: json["billing_name"] == null ? void 0 : json["billing_name"],
7335
+ cardBrand: json["card_brand"] == null ? void 0 : json["card_brand"],
7336
+ cardExpMonth: json["card_exp_month"] == null ? void 0 : json["card_exp_month"],
7337
+ cardExpYear: json["card_exp_year"] == null ? void 0 : json["card_exp_year"],
7338
+ cardLast4: json["card_last4"] == null ? void 0 : json["card_last4"],
7339
+ companyId: json["company_id"] == null ? void 0 : json["company_id"],
7340
+ createdAt: new Date(json["created_at"]),
7341
+ customerExternalId: json["customer_external_id"],
7342
+ environmentId: json["environment_id"],
7343
+ externalId: json["external_id"],
7344
+ id: json["id"],
7345
+ paymentMethodType: json["payment_method_type"],
7346
+ subscriptionExternalId: json["subscription_external_id"] == null ? void 0 : json["subscription_external_id"],
7283
7347
  updatedAt: new Date(json["updated_at"])
7284
7348
  };
7285
7349
  }
7286
7350
 
7351
+ // src/api/models/BillingSubscriptionView.ts
7352
+ function BillingSubscriptionViewFromJSON(json) {
7353
+ return BillingSubscriptionViewFromJSONTyped(json, false);
7354
+ }
7355
+ function BillingSubscriptionViewFromJSONTyped(json, ignoreDiscriminator) {
7356
+ if (json == null) {
7357
+ return json;
7358
+ }
7359
+ return {
7360
+ companyId: json["company_id"] == null ? void 0 : json["company_id"],
7361
+ createdAt: new Date(json["created_at"]),
7362
+ currency: json["currency"],
7363
+ customerExternalId: json["customer_external_id"],
7364
+ expiredAt: json["expired_at"] == null ? void 0 : new Date(json["expired_at"]),
7365
+ id: json["id"],
7366
+ interval: json["interval"],
7367
+ latestInvoice: json["latest_invoice"] == null ? void 0 : InvoiceResponseDataFromJSON(json["latest_invoice"]),
7368
+ metadata: json["metadata"] == null ? void 0 : json["metadata"],
7369
+ paymentMethod: json["payment_method"] == null ? void 0 : PaymentMethodResponseDataFromJSON(json["payment_method"]),
7370
+ periodEnd: json["period_end"],
7371
+ periodStart: json["period_start"],
7372
+ products: json["products"].map(
7373
+ BillingProductForSubscriptionResponseDataFromJSON
7374
+ ),
7375
+ status: json["status"],
7376
+ subscriptionExternalId: json["subscription_external_id"],
7377
+ totalPrice: json["total_price"]
7378
+ };
7379
+ }
7380
+
7287
7381
  // src/api/models/ChangeSubscriptionRequestBody.ts
7288
7382
  function ChangeSubscriptionRequestBodyToJSON(value) {
7289
7383
  if (value == null) {
@@ -7435,7 +7529,7 @@ function CompanyDetailResponseDataFromJSONTyped(json, ignoreDiscriminator) {
7435
7529
  CompanyPlanWithBillingSubViewFromJSON
7436
7530
  ),
7437
7531
  billingSubscriptions: json["billing_subscriptions"].map(
7438
- BillingSubscriptionResponseDataFromJSON
7532
+ BillingSubscriptionViewFromJSON
7439
7533
  ),
7440
7534
  createdAt: new Date(json["created_at"]),
7441
7535
  entityTraits: json["entity_traits"].map(
@@ -7743,65 +7837,6 @@ function CompanyPlanDetailResponseDataFromJSONTyped(json, ignoreDiscriminator) {
7743
7837
  };
7744
7838
  }
7745
7839
 
7746
- // src/api/models/InvoiceResponseData.ts
7747
- function InvoiceResponseDataFromJSON(json) {
7748
- return InvoiceResponseDataFromJSONTyped(json, false);
7749
- }
7750
- function InvoiceResponseDataFromJSONTyped(json, ignoreDiscriminator) {
7751
- if (json == null) {
7752
- return json;
7753
- }
7754
- return {
7755
- amountDue: json["amount_due"],
7756
- amountPaid: json["amount_paid"],
7757
- amountRemaining: json["amount_remaining"],
7758
- collectionMethod: json["collection_method"],
7759
- companyId: json["company_id"] == null ? void 0 : json["company_id"],
7760
- createdAt: new Date(json["created_at"]),
7761
- currency: json["currency"],
7762
- customerExternalId: json["customer_external_id"],
7763
- dueDate: json["due_date"] == null ? void 0 : new Date(json["due_date"]),
7764
- environmentId: json["environment_id"],
7765
- externalId: json["external_id"] == null ? void 0 : json["external_id"],
7766
- id: json["id"],
7767
- paymentMethodExternalId: json["payment_method_external_id"] == null ? void 0 : json["payment_method_external_id"],
7768
- subscriptionExternalId: json["subscription_external_id"] == null ? void 0 : json["subscription_external_id"],
7769
- subtotal: json["subtotal"],
7770
- updatedAt: new Date(json["updated_at"]),
7771
- url: json["url"] == null ? void 0 : json["url"]
7772
- };
7773
- }
7774
-
7775
- // src/api/models/PaymentMethodResponseData.ts
7776
- function PaymentMethodResponseDataFromJSON(json) {
7777
- return PaymentMethodResponseDataFromJSONTyped(json, false);
7778
- }
7779
- function PaymentMethodResponseDataFromJSONTyped(json, ignoreDiscriminator) {
7780
- if (json == null) {
7781
- return json;
7782
- }
7783
- return {
7784
- accountLast4: json["account_last4"] == null ? void 0 : json["account_last4"],
7785
- accountName: json["account_name"] == null ? void 0 : json["account_name"],
7786
- bankName: json["bank_name"] == null ? void 0 : json["bank_name"],
7787
- billingEmail: json["billing_email"] == null ? void 0 : json["billing_email"],
7788
- billingName: json["billing_name"] == null ? void 0 : json["billing_name"],
7789
- cardBrand: json["card_brand"] == null ? void 0 : json["card_brand"],
7790
- cardExpMonth: json["card_exp_month"] == null ? void 0 : json["card_exp_month"],
7791
- cardExpYear: json["card_exp_year"] == null ? void 0 : json["card_exp_year"],
7792
- cardLast4: json["card_last4"] == null ? void 0 : json["card_last4"],
7793
- companyId: json["company_id"] == null ? void 0 : json["company_id"],
7794
- createdAt: new Date(json["created_at"]),
7795
- customerExternalId: json["customer_external_id"],
7796
- environmentId: json["environment_id"],
7797
- externalId: json["external_id"],
7798
- id: json["id"],
7799
- paymentMethodType: json["payment_method_type"],
7800
- subscriptionExternalId: json["subscription_external_id"] == null ? void 0 : json["subscription_external_id"],
7801
- updatedAt: new Date(json["updated_at"])
7802
- };
7803
- }
7804
-
7805
7840
  // src/api/models/CompanySubscriptionResponseData.ts
7806
7841
  function CompanySubscriptionResponseDataFromJSON(json) {
7807
7842
  return CompanySubscriptionResponseDataFromJSONTyped(json, false);
@@ -7826,6 +7861,19 @@ function CompanySubscriptionResponseDataFromJSONTyped(json, ignoreDiscriminator)
7826
7861
  };
7827
7862
  }
7828
7863
 
7864
+ // src/api/models/ComponentCapabilities.ts
7865
+ function ComponentCapabilitiesFromJSON(json) {
7866
+ return ComponentCapabilitiesFromJSONTyped(json, false);
7867
+ }
7868
+ function ComponentCapabilitiesFromJSONTyped(json, ignoreDiscriminator) {
7869
+ if (json == null) {
7870
+ return json;
7871
+ }
7872
+ return {
7873
+ checkout: json["checkout"]
7874
+ };
7875
+ }
7876
+
7829
7877
  // src/api/models/ComponentResponseData.ts
7830
7878
  function ComponentResponseDataFromJSON(json) {
7831
7879
  return ComponentResponseDataFromJSONTyped(json, false);
@@ -7904,9 +7952,13 @@ function ComponentHydrateResponseDataFromJSONTyped(json, ignoreDiscriminator) {
7904
7952
  return json;
7905
7953
  }
7906
7954
  return {
7955
+ activeAddOns: json["active_add_ons"].map(
7956
+ CompanyPlanDetailResponseDataFromJSON
7957
+ ),
7907
7958
  activePlans: json["active_plans"].map(
7908
7959
  CompanyPlanDetailResponseDataFromJSON
7909
7960
  ),
7961
+ capabilities: json["capabilities"] == null ? void 0 : ComponentCapabilitiesFromJSON(json["capabilities"]),
7910
7962
  company: json["company"] == null ? void 0 : CompanyDetailResponseDataFromJSON(json["company"]),
7911
7963
  component: json["component"] == null ? void 0 : ComponentResponseDataFromJSON(json["component"]),
7912
7964
  featureUsage: json["feature_usage"] == null ? void 0 : FeatureUsageDetailResponseDataFromJSON(json["feature_usage"]),
@@ -8711,6 +8763,7 @@ function parseEditorState(data) {
8711
8763
  var EmbedContext = createContext({
8712
8764
  api: null,
8713
8765
  data: {
8766
+ activeAddOns: [],
8714
8767
  activePlans: []
8715
8768
  },
8716
8769
  nodes: [],
@@ -8741,6 +8794,7 @@ var EmbedProvider = ({
8741
8794
  return {
8742
8795
  api: null,
8743
8796
  data: {
8797
+ activeAddOns: [],
8744
8798
  activePlans: []
8745
8799
  },
8746
8800
  nodes: [],
@@ -8842,7 +8896,7 @@ var EmbedProvider = ({
8842
8896
  useEffect(() => {
8843
8897
  if (accessToken) {
8844
8898
  const { headers = {} } = apiConfig ?? {};
8845
- headers["X-Schematic-Components-Version"] = "0.3.9";
8899
+ headers["X-Schematic-Components-Version"] = "0.3.10";
8846
8900
  headers["X-Schematic-Session-ID"] = sessionIdRef.current;
8847
8901
  const config = new Configuration({
8848
8902
  ...apiConfig,
@@ -9906,7 +9960,8 @@ var CheckoutDialog = () => {
9906
9960
  document.body.style.overflow = "";
9907
9961
  };
9908
9962
  }, []);
9909
- const allowCheckout = api && selectedPlan && (selectedPlan.id !== currentPlan?.id || planPeriod !== currentPlan.planPeriod) && (paymentMethod && !showPaymentForm || paymentMethodId) && !isLoading;
9963
+ const canUpdateSubscription = api && selectedPlan && (selectedPlan.id !== currentPlan?.id || planPeriod !== currentPlan.planPeriod) && !isLoading;
9964
+ const canCheckout = canUpdateSubscription && (paymentMethod && !showPaymentForm || paymentMethodId);
9910
9965
  return /* @__PURE__ */ jsxs6(Modal, { size: "lg", children: [
9911
9966
  /* @__PURE__ */ jsx9(ModalHeader, { bordered: true, children: /* @__PURE__ */ jsxs6(Flex, { $gap: "1rem", children: [
9912
9967
  /* @__PURE__ */ jsxs6(Flex, { $gap: "0.5rem", $alignItems: "center", children: [
@@ -10427,7 +10482,7 @@ var CheckoutDialog = () => {
10427
10482
  /* @__PURE__ */ jsx9(
10428
10483
  Flex,
10429
10484
  {
10430
- ...allowCheckout && {
10485
+ ...canCheckout && {
10431
10486
  $opacity: "0.625",
10432
10487
  $textDecoration: "line-through"
10433
10488
  },
@@ -10460,7 +10515,7 @@ var CheckoutDialog = () => {
10460
10515
  ]
10461
10516
  }
10462
10517
  ),
10463
- allowCheckout && /* @__PURE__ */ jsxs6(Box, { $marginBottom: "1rem", children: [
10518
+ canCheckout && /* @__PURE__ */ jsxs6(Box, { $marginBottom: "1rem", children: [
10464
10519
  /* @__PURE__ */ jsx9(
10465
10520
  Box,
10466
10521
  {
@@ -10653,7 +10708,7 @@ var CheckoutDialog = () => {
10653
10708
  EmbedButton,
10654
10709
  {
10655
10710
  isLoading,
10656
- ...allowCheckout ? {
10711
+ ...canUpdateSubscription ? {
10657
10712
  onClick: async () => {
10658
10713
  if (!data.component?.id) {
10659
10714
  return;
@@ -10682,9 +10737,9 @@ var CheckoutDialog = () => {
10682
10737
  ) : /* @__PURE__ */ jsx9(
10683
10738
  EmbedButton,
10684
10739
  {
10685
- disabled: isLoading || !allowCheckout,
10740
+ disabled: isLoading || !canCheckout,
10686
10741
  isLoading,
10687
- ...allowCheckout && { onClick: checkout },
10742
+ ...canCheckout && { onClick: checkout },
10688
10743
  children: "Pay now"
10689
10744
  }
10690
10745
  ),
@@ -11716,12 +11771,12 @@ var resolveDesignProps5 = (props) => {
11716
11771
  var PlanManager = forwardRef9(({ children, className, portal, ...rest }, ref) => {
11717
11772
  const props = resolveDesignProps5(rest);
11718
11773
  const theme = nt();
11719
- const { data, layout, mode, setLayout } = useEmbed();
11774
+ const { data, layout, setLayout } = useEmbed();
11720
11775
  const isLightBackground = useIsLightBackground();
11721
11776
  const { currentPlan, canChangePlan, addOns } = {
11722
- currentPlan: data.company?.plan,
11723
- canChangePlan: (mode === "edit" || data.stripeEmbed?.publishableKey && data.company?.plan?.billingProductId) && data.activePlans.length > 0,
11724
- addOns: data.company?.addOns || []
11777
+ addOns: data.company?.addOns || [],
11778
+ canChangePlan: data.capabilities?.checkout ?? true,
11779
+ currentPlan: data.company?.plan
11725
11780
  };
11726
11781
  return /* @__PURE__ */ jsxs13(
11727
11782
  Element,
@@ -12052,6 +12107,7 @@ var ComponentTree = () => {
12052
12107
  setChildren(nodes.map(renderer));
12053
12108
  }, [nodes]);
12054
12109
  if (error) {
12110
+ console.error(error);
12055
12111
  return /* @__PURE__ */ jsx22(Error2, { message: error.message });
12056
12112
  }
12057
12113
  if (Children.count(children) === 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@schematichq/schematic-components",
3
- "version": "0.3.9",
3
+ "version": "0.3.10",
4
4
  "main": "dist/schematic-components.cjs.js",
5
5
  "module": "dist/schematic-components.esm.js",
6
6
  "types": "dist/schematic-components.d.ts",