@bunnyapp/components 1.7.0-beta.39 → 1.7.0-beta.40

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.
package/dist/cjs/index.js CHANGED
@@ -1283,7 +1283,7 @@ const DEFAULT_CONFIG = {
1283
1283
  };
1284
1284
 
1285
1285
  // This will be replaced at build time by rollup-plugin-replace
1286
- const PACKAGE_VERSION = '1.7.0-beta.38';
1286
+ const PACKAGE_VERSION = '1.7.0-beta.39';
1287
1287
  const createRequestHeaders = (token) => {
1288
1288
  const headers = createClientDevHeaders({ token });
1289
1289
  // Add the components version header
@@ -26399,6 +26399,8 @@ const PriceListCardButton = ({ disableSelectCurrentPlan, isPriceListCurrentSubsc
26399
26399
  return (jsxRuntime.jsx("div", { className: "bunny-flex bunny-flex-col bunny-grow bunny-w-full bunny-gap-3", children: jsxRuntime.jsx(antd.Button, { className: "bunny-w-full", disabled: disableSelectCurrentPlan, type: isSelected ? 'primary' : 'default', children: createButtonText() }) }));
26400
26400
  };
26401
26401
 
26402
+ const [DefaultBillingPeriodProvider, useDefaultBillingPeriod] = createValueContext();
26403
+
26402
26404
  const BillingPeriodSelector = ({ availableBillingPeriods, onChangeBillingPeriod, products, selectedBillingPeriod, selectedProduct, onChangeProduct, }) => {
26403
26405
  const { secondaryColor, brandColor } = useBrand();
26404
26406
  const isMobile = useIsMobile();
@@ -27867,6 +27869,7 @@ const PriceListSelector = ({ arePlanChangeOptionsLoading, areSubscriptionsLoadin
27867
27869
  const { isInPreviewMode } = useSubscriptionProps();
27868
27870
  const maskedUpgradingSubscription = useUpgradingSubscription();
27869
27871
  const { selectedPriceList, onChangeSelectedPriceList, onClearQuote } = react.useContext(QuoteContext);
27872
+ const defaultBillingPeriod = useDefaultBillingPeriod();
27870
27873
  // Read fragment
27871
27874
  const upgradingSubscription = readFragment(PriceListSelectorUpgradingSubscription_SubscriptionFragment, maskedUpgradingSubscription);
27872
27875
  // Local state
@@ -27925,6 +27928,10 @@ const PriceListSelector = ({ arePlanChangeOptionsLoading, areSubscriptionsLoadin
27925
27928
  var _a, _b, _c;
27926
27929
  const initialAvailableBillingPeriods = createAvailableBillingPeriods(priceListChangeOptions === null || priceListChangeOptions === void 0 ? void 0 : priceListChangeOptions.priceLists, initialProduct, upgradingSubscription // TODO: set type properly later
27927
27930
  );
27931
+ const defaultBillingPeriodIsAvailable = initialAvailableBillingPeriods === null || initialAvailableBillingPeriods === void 0 ? void 0 : initialAvailableBillingPeriods.includes(billingPeriodConverter(defaultBillingPeriod));
27932
+ if (defaultBillingPeriod && defaultBillingPeriodIsAvailable) {
27933
+ return defaultBillingPeriod;
27934
+ }
27928
27935
  const periodMonthsConverted = periodMonthsConverter((_b = (_a = upgradingSubscription === null || upgradingSubscription === void 0 ? void 0 : upgradingSubscription.priceList) === null || _a === void 0 ? void 0 : _a.periodMonths) !== null && _b !== void 0 ? _b : null);
27929
27936
  if ((upgradingSubscription === null || upgradingSubscription === void 0 ? void 0 : upgradingSubscription.priceList) &&
27930
27937
  periodMonthsConverted &&
@@ -29610,7 +29617,7 @@ const getSubscriptions = async ({ apiHost, isInPreviewMode, token, }) => {
29610
29617
  };
29611
29618
 
29612
29619
  const showInfoNotification = useInfoNotification();
29613
- const UpgradeWrapper = ({ onChangePlanCancel, handlePortalErrors, upgradingSubscriptionId, isInPreviewMode, productId, className, shadow = 'md', onPaymentMethodSaved, onPaymentMethodRemoved, }) => {
29620
+ const UpgradeWrapper = ({ onChangePlanCancel, handlePortalErrors, onPaymentMethodSaved, onPaymentMethodRemoved, upgradingSubscriptionId, isInPreviewMode, productId, className, shadow = 'md', defaultBillingPeriod, }) => {
29614
29621
  var _a, _b, _c;
29615
29622
  // Context
29616
29623
  const token = useToken();
@@ -29642,7 +29649,7 @@ const UpgradeWrapper = ({ onChangePlanCancel, handlePortalErrors, upgradingSubsc
29642
29649
  productId,
29643
29650
  className,
29644
29651
  shadow,
29645
- }, children: jsxRuntime.jsx(UpgradingSubscriptionIdProvider, { initialValue: upgradingSubscriptionId, children: jsxRuntime.jsx(UpgradingSubscriptionProvider, { value: upgradingSubscription, children: jsxRuntime.jsx(OnPaymentMethodSavedProvider, { value: onPaymentMethodSaved, children: jsxRuntime.jsx(OnPaymentMethodRemovedProvider, { value: onPaymentMethodRemoved, children: jsxRuntime.jsx(QuoteProvider, { children: jsxRuntime.jsx(UpgradeContent, { onChangePlanCancel: onChangePlanCancel, handlePortalErrors: handlePortalErrors, subscriptions: (_c = subscriptionsData === null || subscriptionsData === void 0 ? void 0 : subscriptionsData.subscriptions) === null || _c === void 0 ? void 0 : _c.nodes, subscriptionsAreLoading: subscriptionsAreLoading }) }) }) }) }) }) }));
29652
+ }, children: jsxRuntime.jsx(UpgradingSubscriptionIdProvider, { initialValue: upgradingSubscriptionId, children: jsxRuntime.jsx(UpgradingSubscriptionProvider, { value: upgradingSubscription, children: jsxRuntime.jsx(OnPaymentMethodSavedProvider, { value: onPaymentMethodSaved, children: jsxRuntime.jsx(OnPaymentMethodRemovedProvider, { value: onPaymentMethodRemoved, children: jsxRuntime.jsx(DefaultBillingPeriodProvider, { value: defaultBillingPeriod, children: jsxRuntime.jsx(QuoteProvider, { children: jsxRuntime.jsx(UpgradeContent, { onChangePlanCancel: onChangePlanCancel, handlePortalErrors: handlePortalErrors, subscriptions: (_c = subscriptionsData === null || subscriptionsData === void 0 ? void 0 : subscriptionsData.subscriptions) === null || _c === void 0 ? void 0 : _c.nodes, subscriptionsAreLoading: subscriptionsAreLoading }) }) }) }) }) }) }) }));
29646
29653
  };
29647
29654
  const UpgradeContent = ({ onChangePlanCancel, handlePortalErrors, subscriptions, subscriptionsAreLoading, }) => {
29648
29655
  // Context
@@ -1,12 +1,17 @@
1
- declare const UpgradeWrapper: ({ onChangePlanCancel, handlePortalErrors, upgradingSubscriptionId, isInPreviewMode, productId, className, shadow, onPaymentMethodSaved, onPaymentMethodRemoved, }: {
1
+ import { BillingPeriod } from '@/graphql-codegen/exportedScalarTypes';
2
+ declare const UpgradeWrapper: ({ onChangePlanCancel, handlePortalErrors, onPaymentMethodSaved, onPaymentMethodRemoved, upgradingSubscriptionId, isInPreviewMode, productId, className, shadow, defaultBillingPeriod, }: {
2
3
  onChangePlanCancel: () => void;
3
4
  handlePortalErrors?: (error: any) => void;
5
+ onPaymentMethodSaved?: (paymentMethodId: string) => void;
6
+ onPaymentMethodRemoved?: (paymentMethodId: string) => void;
4
7
  upgradingSubscriptionId?: string;
5
8
  isInPreviewMode: boolean;
6
9
  productId: string | undefined;
7
10
  className?: string;
8
11
  shadow?: "none" | "sm" | "md" | "lg";
9
- onPaymentMethodSaved?: (paymentMethodId: string) => void;
10
- onPaymentMethodRemoved?: (paymentMethodId: string) => void;
12
+ /**
13
+ * If provided and the billing period is available, the billing period selector will default to this value.
14
+ */
15
+ defaultBillingPeriod?: BillingPeriod;
11
16
  }) => import("react/jsx-runtime").JSX.Element | null;
12
17
  export default UpgradeWrapper;
@@ -0,0 +1,4 @@
1
+ export declare const DefaultBillingPeriodProvider: ({ value, children }: {
2
+ value: "MONTHLY" | "QUARTERLY" | "SEMI_ANNUAL" | "ANNUAL" | "ONCE" | undefined;
3
+ children?: import("react").ReactNode;
4
+ }) => import("react/jsx-runtime").JSX.Element, useDefaultBillingPeriod: () => "MONTHLY" | "QUARTERLY" | "SEMI_ANNUAL" | "ANNUAL" | "ONCE" | undefined;
package/dist/esm/index.js CHANGED
@@ -1281,7 +1281,7 @@ const DEFAULT_CONFIG = {
1281
1281
  };
1282
1282
 
1283
1283
  // This will be replaced at build time by rollup-plugin-replace
1284
- const PACKAGE_VERSION = '1.7.0-beta.38';
1284
+ const PACKAGE_VERSION = '1.7.0-beta.39';
1285
1285
  const createRequestHeaders = (token) => {
1286
1286
  const headers = createClientDevHeaders({ token });
1287
1287
  // Add the components version header
@@ -26397,6 +26397,8 @@ const PriceListCardButton = ({ disableSelectCurrentPlan, isPriceListCurrentSubsc
26397
26397
  return (jsx("div", { className: "bunny-flex bunny-flex-col bunny-grow bunny-w-full bunny-gap-3", children: jsx(Button, { className: "bunny-w-full", disabled: disableSelectCurrentPlan, type: isSelected ? 'primary' : 'default', children: createButtonText() }) }));
26398
26398
  };
26399
26399
 
26400
+ const [DefaultBillingPeriodProvider, useDefaultBillingPeriod] = createValueContext();
26401
+
26400
26402
  const BillingPeriodSelector = ({ availableBillingPeriods, onChangeBillingPeriod, products, selectedBillingPeriod, selectedProduct, onChangeProduct, }) => {
26401
26403
  const { secondaryColor, brandColor } = useBrand();
26402
26404
  const isMobile = useIsMobile();
@@ -27865,6 +27867,7 @@ const PriceListSelector = ({ arePlanChangeOptionsLoading, areSubscriptionsLoadin
27865
27867
  const { isInPreviewMode } = useSubscriptionProps();
27866
27868
  const maskedUpgradingSubscription = useUpgradingSubscription();
27867
27869
  const { selectedPriceList, onChangeSelectedPriceList, onClearQuote } = useContext(QuoteContext);
27870
+ const defaultBillingPeriod = useDefaultBillingPeriod();
27868
27871
  // Read fragment
27869
27872
  const upgradingSubscription = readFragment(PriceListSelectorUpgradingSubscription_SubscriptionFragment, maskedUpgradingSubscription);
27870
27873
  // Local state
@@ -27923,6 +27926,10 @@ const PriceListSelector = ({ arePlanChangeOptionsLoading, areSubscriptionsLoadin
27923
27926
  var _a, _b, _c;
27924
27927
  const initialAvailableBillingPeriods = createAvailableBillingPeriods(priceListChangeOptions === null || priceListChangeOptions === void 0 ? void 0 : priceListChangeOptions.priceLists, initialProduct, upgradingSubscription // TODO: set type properly later
27925
27928
  );
27929
+ const defaultBillingPeriodIsAvailable = initialAvailableBillingPeriods === null || initialAvailableBillingPeriods === void 0 ? void 0 : initialAvailableBillingPeriods.includes(billingPeriodConverter(defaultBillingPeriod));
27930
+ if (defaultBillingPeriod && defaultBillingPeriodIsAvailable) {
27931
+ return defaultBillingPeriod;
27932
+ }
27926
27933
  const periodMonthsConverted = periodMonthsConverter((_b = (_a = upgradingSubscription === null || upgradingSubscription === void 0 ? void 0 : upgradingSubscription.priceList) === null || _a === void 0 ? void 0 : _a.periodMonths) !== null && _b !== void 0 ? _b : null);
27927
27934
  if ((upgradingSubscription === null || upgradingSubscription === void 0 ? void 0 : upgradingSubscription.priceList) &&
27928
27935
  periodMonthsConverted &&
@@ -29608,7 +29615,7 @@ const getSubscriptions = async ({ apiHost, isInPreviewMode, token, }) => {
29608
29615
  };
29609
29616
 
29610
29617
  const showInfoNotification = useInfoNotification();
29611
- const UpgradeWrapper = ({ onChangePlanCancel, handlePortalErrors, upgradingSubscriptionId, isInPreviewMode, productId, className, shadow = 'md', onPaymentMethodSaved, onPaymentMethodRemoved, }) => {
29618
+ const UpgradeWrapper = ({ onChangePlanCancel, handlePortalErrors, onPaymentMethodSaved, onPaymentMethodRemoved, upgradingSubscriptionId, isInPreviewMode, productId, className, shadow = 'md', defaultBillingPeriod, }) => {
29612
29619
  var _a, _b, _c;
29613
29620
  // Context
29614
29621
  const token = useToken();
@@ -29640,7 +29647,7 @@ const UpgradeWrapper = ({ onChangePlanCancel, handlePortalErrors, upgradingSubsc
29640
29647
  productId,
29641
29648
  className,
29642
29649
  shadow,
29643
- }, children: jsx(UpgradingSubscriptionIdProvider, { initialValue: upgradingSubscriptionId, children: jsx(UpgradingSubscriptionProvider, { value: upgradingSubscription, children: jsx(OnPaymentMethodSavedProvider, { value: onPaymentMethodSaved, children: jsx(OnPaymentMethodRemovedProvider, { value: onPaymentMethodRemoved, children: jsx(QuoteProvider, { children: jsx(UpgradeContent, { onChangePlanCancel: onChangePlanCancel, handlePortalErrors: handlePortalErrors, subscriptions: (_c = subscriptionsData === null || subscriptionsData === void 0 ? void 0 : subscriptionsData.subscriptions) === null || _c === void 0 ? void 0 : _c.nodes, subscriptionsAreLoading: subscriptionsAreLoading }) }) }) }) }) }) }));
29650
+ }, children: jsx(UpgradingSubscriptionIdProvider, { initialValue: upgradingSubscriptionId, children: jsx(UpgradingSubscriptionProvider, { value: upgradingSubscription, children: jsx(OnPaymentMethodSavedProvider, { value: onPaymentMethodSaved, children: jsx(OnPaymentMethodRemovedProvider, { value: onPaymentMethodRemoved, children: jsx(DefaultBillingPeriodProvider, { value: defaultBillingPeriod, children: jsx(QuoteProvider, { children: jsx(UpgradeContent, { onChangePlanCancel: onChangePlanCancel, handlePortalErrors: handlePortalErrors, subscriptions: (_c = subscriptionsData === null || subscriptionsData === void 0 ? void 0 : subscriptionsData.subscriptions) === null || _c === void 0 ? void 0 : _c.nodes, subscriptionsAreLoading: subscriptionsAreLoading }) }) }) }) }) }) }) }));
29644
29651
  };
29645
29652
  const UpgradeContent = ({ onChangePlanCancel, handlePortalErrors, subscriptions, subscriptionsAreLoading, }) => {
29646
29653
  // Context
@@ -1,12 +1,17 @@
1
- declare const UpgradeWrapper: ({ onChangePlanCancel, handlePortalErrors, upgradingSubscriptionId, isInPreviewMode, productId, className, shadow, onPaymentMethodSaved, onPaymentMethodRemoved, }: {
1
+ import { BillingPeriod } from '@/graphql-codegen/exportedScalarTypes';
2
+ declare const UpgradeWrapper: ({ onChangePlanCancel, handlePortalErrors, onPaymentMethodSaved, onPaymentMethodRemoved, upgradingSubscriptionId, isInPreviewMode, productId, className, shadow, defaultBillingPeriod, }: {
2
3
  onChangePlanCancel: () => void;
3
4
  handlePortalErrors?: (error: any) => void;
5
+ onPaymentMethodSaved?: (paymentMethodId: string) => void;
6
+ onPaymentMethodRemoved?: (paymentMethodId: string) => void;
4
7
  upgradingSubscriptionId?: string;
5
8
  isInPreviewMode: boolean;
6
9
  productId: string | undefined;
7
10
  className?: string;
8
11
  shadow?: "none" | "sm" | "md" | "lg";
9
- onPaymentMethodSaved?: (paymentMethodId: string) => void;
10
- onPaymentMethodRemoved?: (paymentMethodId: string) => void;
12
+ /**
13
+ * If provided and the billing period is available, the billing period selector will default to this value.
14
+ */
15
+ defaultBillingPeriod?: BillingPeriod;
11
16
  }) => import("react/jsx-runtime").JSX.Element | null;
12
17
  export default UpgradeWrapper;
@@ -0,0 +1,4 @@
1
+ export declare const DefaultBillingPeriodProvider: ({ value, children }: {
2
+ value: "MONTHLY" | "QUARTERLY" | "SEMI_ANNUAL" | "ANNUAL" | "ONCE" | undefined;
3
+ children?: import("react").ReactNode;
4
+ }) => import("react/jsx-runtime").JSX.Element, useDefaultBillingPeriod: () => "MONTHLY" | "QUARTERLY" | "SEMI_ANNUAL" | "ANNUAL" | "ONCE" | undefined;
package/dist/index.d.ts CHANGED
@@ -8,6 +8,7 @@ import Invoice$1 from '@/types/Invoice';
8
8
  import { QueryClient } from '@tanstack/react-query';
9
9
  import { ThemeConfig } from 'antd';
10
10
  import react from 'react';
11
+ import { BillingPeriod } from '@/graphql-codegen/exportedScalarTypes';
11
12
 
12
13
  type ShadowType = "shadow-none" | "shadow-sm" | "shadow-md" | "shadow-lg" | "shadow-xl";
13
14
 
@@ -240,16 +241,20 @@ declare const SubscriptionsWrapper: ({ handlePortalErrors, companyName, isInPrev
240
241
  onPaymentMethodRemoved?: (paymentMethodId: string) => void;
241
242
  }) => react_jsx_runtime.JSX.Element;
242
243
 
243
- declare const UpgradeWrapper: ({ onChangePlanCancel, handlePortalErrors, upgradingSubscriptionId, isInPreviewMode, productId, className, shadow, onPaymentMethodSaved, onPaymentMethodRemoved, }: {
244
+ declare const UpgradeWrapper: ({ onChangePlanCancel, handlePortalErrors, onPaymentMethodSaved, onPaymentMethodRemoved, upgradingSubscriptionId, isInPreviewMode, productId, className, shadow, defaultBillingPeriod, }: {
244
245
  onChangePlanCancel: () => void;
245
246
  handlePortalErrors?: (error: any) => void;
247
+ onPaymentMethodSaved?: (paymentMethodId: string) => void;
248
+ onPaymentMethodRemoved?: (paymentMethodId: string) => void;
246
249
  upgradingSubscriptionId?: string;
247
250
  isInPreviewMode: boolean;
248
251
  productId: string | undefined;
249
252
  className?: string;
250
253
  shadow?: "none" | "sm" | "md" | "lg";
251
- onPaymentMethodSaved?: (paymentMethodId: string) => void;
252
- onPaymentMethodRemoved?: (paymentMethodId: string) => void;
254
+ /**
255
+ * If provided and the billing period is available, the billing period selector will default to this value.
256
+ */
257
+ defaultBillingPeriod?: BillingPeriod;
253
258
  }) => react_jsx_runtime.JSX.Element | null;
254
259
 
255
260
  declare const BillingDetails: ({ className, countryListFilter, hideBillingDetailsForm, hidePaymentMethodForm, isCardEnabled, isUpgradeFromTrial, shadow, onSavePaymentMethod, onPaymentMethodRemoved, }: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bunnyapp/components",
3
- "version": "1.7.0-beta.39",
3
+ "version": "1.7.0-beta.40",
4
4
  "description": "Components from the Bunny portal to embed Bunny UI functionality into your application.",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",