@bunnyapp/components 1.7.0-beta.10 → 1.7.0-beta.14

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
@@ -6,7 +6,6 @@ var icons = require('@ant-design/icons');
6
6
  var antd = require('antd');
7
7
  var reactQuery = require('@tanstack/react-query');
8
8
  var request$1 = require('graphql-request');
9
- var theme = require('antd/lib/theme/index.js');
10
9
  var recoil = require('recoil');
11
10
  var graphql$1 = require('graphql');
12
11
  var reactStripeJs = require('@stripe/react-stripe-js');
@@ -1281,7 +1280,7 @@ const DEFAULT_CONFIG = {
1281
1280
  };
1282
1281
 
1283
1282
  // This will be replaced at build time by rollup-plugin-replace
1284
- const PACKAGE_VERSION = '1.7.0-beta.9';
1283
+ const PACKAGE_VERSION = '1.7.0-beta.13';
1285
1284
  const createRequestHeaders = (token) => {
1286
1285
  const headers = createClientDevHeaders({ token });
1287
1286
  // Add the components version header
@@ -2274,7 +2273,7 @@ function ContextualWrapper({ children, darkMode, configProviderProps, }) {
2274
2273
  };
2275
2274
  }, [branding, isMobile]);
2276
2275
  const defaultTheme = {
2277
- algorithm: darkMode ? theme.darkAlgorithm : theme.defaultAlgorithm,
2276
+ algorithm: darkMode ? antd.theme.darkAlgorithm : antd.theme.defaultAlgorithm,
2278
2277
  token: {
2279
2278
  borderRadius: 4,
2280
2279
  colorPrimary: entityBranding.brandColor,
@@ -19760,6 +19759,9 @@ const PaymentForm_PaymentMethodsFragment = t(`
19760
19759
  fragment PaymentForm_PaymentMethodsFragment on PaymentMethod {
19761
19760
  ...MiniCreditCard_PaymentMethodFragment
19762
19761
  id
19762
+ plugin {
19763
+ id
19764
+ }
19763
19765
  }
19764
19766
  `, [MiniCreditCard_PaymentMethodFragment]);
19765
19767
 
@@ -21140,7 +21142,7 @@ function useRemovePaymentMethod(onRemovePaymentMethod, onError) {
21140
21142
  const token = useToken();
21141
21143
  const { apiHost } = react.useContext(BunnyContext);
21142
21144
  const removePaymentMethod = react.useCallback(async (data) => {
21143
- const plugin = paymentPlugins === null || paymentPlugins === void 0 ? void 0 : paymentPlugins.find(paymentPlugin => { var _a; return String(paymentPlugin.id) === ((_a = data === null || data === void 0 ? void 0 : data.plugin) === null || _a === void 0 ? void 0 : _a.id); });
21145
+ const plugin = paymentPlugins === null || paymentPlugins === void 0 ? void 0 : paymentPlugins.find(paymentPlugin => { var _a; return String(paymentPlugin.id) === String((_a = data === null || data === void 0 ? void 0 : data.plugin) === null || _a === void 0 ? void 0 : _a.id); });
21144
21146
  if (data && plugin) {
21145
21147
  await invokePlugin({
21146
21148
  plugin: plugin, // TODO: type the plugin
@@ -21160,17 +21162,21 @@ function useRemovePaymentMethod(onRemovePaymentMethod, onError) {
21160
21162
  accountId,
21161
21163
  }),
21162
21164
  });
21163
- onRemovePaymentMethod === null || onRemovePaymentMethod === void 0 ? void 0 : onRemovePaymentMethod();
21165
+ onRemovePaymentMethod === null || onRemovePaymentMethod === void 0 ? void 0 : onRemovePaymentMethod(data);
21164
21166
  })
21165
21167
  .catch((error) => {
21166
21168
  showErrorNotification(error.message, 'Error removing payment method');
21167
21169
  });
21168
21170
  }
21169
21171
  else {
21170
- const availablePlugins = paymentPlugins === null || paymentPlugins === void 0 ? void 0 : paymentPlugins.map((plugin) => { var _a, _b, _c; return (_c = (_b = (_a = plugin.components) === null || _a === void 0 ? void 0 : _a.frontend) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.name; });
21172
+ const availablePlugins = paymentPlugins === null || paymentPlugins === void 0 ? void 0 : paymentPlugins.map(plugin => {
21173
+ var _a, _b;
21174
+ const components = plugin.components;
21175
+ return (_b = (_a = components === null || components === void 0 ? void 0 : components.frontend) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.name;
21176
+ });
21171
21177
  onError === null || onError === void 0 ? void 0 : onError(`Either the payment method was not found or the plugin was not present. Available plugins: ${availablePlugins === null || availablePlugins === void 0 ? void 0 : availablePlugins.join(', ')}`);
21172
21178
  }
21173
- }, [paymentPlugins, token, apiHost, queryClient]);
21179
+ }, [paymentPlugins, token, apiHost, queryClient, onRemovePaymentMethod, accountId, onError]);
21174
21180
  return removePaymentMethod;
21175
21181
  }
21176
21182
 
@@ -1,6 +1,8 @@
1
1
  import FormattedInvoice from '@/types/FormattedInvoice';
2
2
  import Invoice from '@/types/Invoice';
3
- import { FragmentOf } from 'gql.tada';
3
+ import { FragmentOf, ResultOf } from 'gql.tada';
4
+ import { PaymentForm_PaymentMethodsFragment } from './fragments/PaymentForm_PaymentMethodsFragment';
5
+ type PaymentMethodFragment = ResultOf<typeof PaymentForm_PaymentMethodsFragment>;
4
6
  export declare const PaymentForm_QuoteFragment: import("gql.tada").TadaDocumentNode<{
5
7
  id: string | null;
6
8
  currencyId: string;
@@ -18,7 +20,7 @@ export declare function PaymentForm({ invoice, quote: maskedQuote, onPaymentSucc
18
20
  onPaymentSuccess?: (response: any) => void;
19
21
  onPaymentHoldSuccess?: (response: any) => void;
20
22
  onSavePaymentMethod?: (response: any) => void;
21
- onRemovePaymentMethod?: () => void;
23
+ onRemovePaymentMethod?: (paymentMethod: PaymentMethodFragment) => void;
22
24
  onSetDefaultPaymentMethod?: () => void;
23
25
  accountId?: string;
24
26
  overrideToken?: string;
@@ -28,3 +30,4 @@ export declare function PaymentForm({ invoice, quote: maskedQuote, onPaymentSucc
28
30
  amountToHold?: number;
29
31
  };
30
32
  }): import("react/jsx-runtime").JSX.Element | null;
33
+ export {};
@@ -3,6 +3,9 @@ export declare const PaymentForm_PaymentMethodsFragment: import("gql.tada").Tada
3
3
  MiniCreditCard_PaymentMethodFragment: "PaymentMethod";
4
4
  };
5
5
  id: string;
6
+ plugin: {
7
+ id: string;
8
+ } | null;
6
9
  }, {}, {
7
10
  fragment: "PaymentForm_PaymentMethodsFragment";
8
11
  on: "PaymentMethod";
@@ -1,2 +1,5 @@
1
- declare function useRemovePaymentMethod(onRemovePaymentMethod?: () => void, onError?: (message: string) => void): (data: any) => Promise<void>;
1
+ import { ResultOf } from 'gql.tada';
2
+ import { PaymentForm_PaymentMethodsFragment } from '../fragments/PaymentForm_PaymentMethodsFragment';
3
+ type PaymentMethodFragment = ResultOf<typeof PaymentForm_PaymentMethodsFragment>;
4
+ declare function useRemovePaymentMethod(onRemovePaymentMethod?: (paymentMethod: PaymentMethodFragment) => void, onError?: (message: string) => void): (data: PaymentMethodFragment) => Promise<void>;
2
5
  export default useRemovePaymentMethod;
@@ -1,4 +1,4 @@
1
- import { Rule } from "antd/lib/form/index";
1
+ import type { Rule } from "antd/es/form";
2
2
  import { ReactElement } from "react";
3
3
  import { IconName } from "@fortawesome/free-solid-svg-icons";
4
4
  import TableColumn from "./TableColumn";
package/dist/esm/index.js CHANGED
@@ -1,10 +1,9 @@
1
1
  import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
2
2
  import { useState, useEffect, isValidElement, createContext, useContext, useMemo, createElement, useRef, useCallback, Fragment as Fragment$1 } from 'react';
3
3
  import { WarningOutlined, CheckCircleOutlined, CreditCardOutlined, EllipsisOutlined, BankOutlined, DownloadOutlined, SearchOutlined, CloseOutlined, CheckCircleFilled, InfoCircleOutlined } from '@ant-design/icons';
4
- import { notification, ConfigProvider, Tag, Button, Dropdown, Typography, theme as theme$1, Input, Modal, Checkbox, Skeleton, Collapse, Spin, Form, Tooltip, Drawer, Card as Card$1, Select, Divider, Popconfirm, Table, Radio, Space, Switch } from 'antd';
4
+ import { notification, theme, ConfigProvider, Tag, Button, Dropdown, Typography, Input, Modal, Checkbox, Skeleton, Collapse, Spin, Form, Tooltip, Drawer, Card as Card$1, Select, Divider, Popconfirm, Table, Radio, Space, Switch } from 'antd';
5
5
  import { QueryClient, QueryCache, QueryClientProvider, useQuery, useMutation, useQueryClient, keepPreviousData } from '@tanstack/react-query';
6
6
  import request$1 from 'graphql-request';
7
- import theme from 'antd/lib/theme/index.js';
8
7
  import { RecoilRoot } from 'recoil';
9
8
  import { print } from 'graphql';
10
9
  import { useElements, useStripe, Elements, PaymentElement } from '@stripe/react-stripe-js';
@@ -1279,7 +1278,7 @@ const DEFAULT_CONFIG = {
1279
1278
  };
1280
1279
 
1281
1280
  // This will be replaced at build time by rollup-plugin-replace
1282
- const PACKAGE_VERSION = '1.7.0-beta.9';
1281
+ const PACKAGE_VERSION = '1.7.0-beta.13';
1283
1282
  const createRequestHeaders = (token) => {
1284
1283
  const headers = createClientDevHeaders({ token });
1285
1284
  // Add the components version header
@@ -19758,6 +19757,9 @@ const PaymentForm_PaymentMethodsFragment = t(`
19758
19757
  fragment PaymentForm_PaymentMethodsFragment on PaymentMethod {
19759
19758
  ...MiniCreditCard_PaymentMethodFragment
19760
19759
  id
19760
+ plugin {
19761
+ id
19762
+ }
19761
19763
  }
19762
19764
  `, [MiniCreditCard_PaymentMethodFragment]);
19763
19765
 
@@ -20187,7 +20189,7 @@ const getQuoteAmountDue = (maskedQuote) => {
20187
20189
  return quote.amountDue || quote.amount;
20188
20190
  };
20189
20191
 
20190
- const { useToken: useAntdToken$1 } = theme$1;
20192
+ const { useToken: useAntdToken$1 } = theme;
20191
20193
  const createPaymentMethod = async ({ paymentMethodId, plugin, token, apiHost, accountId, }) => {
20192
20194
  const response = await invokePlugin({
20193
20195
  plugin,
@@ -21138,7 +21140,7 @@ function useRemovePaymentMethod(onRemovePaymentMethod, onError) {
21138
21140
  const token = useToken();
21139
21141
  const { apiHost } = useContext(BunnyContext);
21140
21142
  const removePaymentMethod = useCallback(async (data) => {
21141
- const plugin = paymentPlugins === null || paymentPlugins === void 0 ? void 0 : paymentPlugins.find(paymentPlugin => { var _a; return String(paymentPlugin.id) === ((_a = data === null || data === void 0 ? void 0 : data.plugin) === null || _a === void 0 ? void 0 : _a.id); });
21143
+ const plugin = paymentPlugins === null || paymentPlugins === void 0 ? void 0 : paymentPlugins.find(paymentPlugin => { var _a; return String(paymentPlugin.id) === String((_a = data === null || data === void 0 ? void 0 : data.plugin) === null || _a === void 0 ? void 0 : _a.id); });
21142
21144
  if (data && plugin) {
21143
21145
  await invokePlugin({
21144
21146
  plugin: plugin, // TODO: type the plugin
@@ -21158,17 +21160,21 @@ function useRemovePaymentMethod(onRemovePaymentMethod, onError) {
21158
21160
  accountId,
21159
21161
  }),
21160
21162
  });
21161
- onRemovePaymentMethod === null || onRemovePaymentMethod === void 0 ? void 0 : onRemovePaymentMethod();
21163
+ onRemovePaymentMethod === null || onRemovePaymentMethod === void 0 ? void 0 : onRemovePaymentMethod(data);
21162
21164
  })
21163
21165
  .catch((error) => {
21164
21166
  showErrorNotification(error.message, 'Error removing payment method');
21165
21167
  });
21166
21168
  }
21167
21169
  else {
21168
- const availablePlugins = paymentPlugins === null || paymentPlugins === void 0 ? void 0 : paymentPlugins.map((plugin) => { var _a, _b, _c; return (_c = (_b = (_a = plugin.components) === null || _a === void 0 ? void 0 : _a.frontend) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.name; });
21170
+ const availablePlugins = paymentPlugins === null || paymentPlugins === void 0 ? void 0 : paymentPlugins.map(plugin => {
21171
+ var _a, _b;
21172
+ const components = plugin.components;
21173
+ return (_b = (_a = components === null || components === void 0 ? void 0 : components.frontend) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.name;
21174
+ });
21169
21175
  onError === null || onError === void 0 ? void 0 : onError(`Either the payment method was not found or the plugin was not present. Available plugins: ${availablePlugins === null || availablePlugins === void 0 ? void 0 : availablePlugins.join(', ')}`);
21170
21176
  }
21171
- }, [paymentPlugins, token, apiHost, queryClient]);
21177
+ }, [paymentPlugins, token, apiHost, queryClient, onRemovePaymentMethod, accountId, onError]);
21172
21178
  return removePaymentMethod;
21173
21179
  }
21174
21180
 
@@ -21488,7 +21494,7 @@ const MarkupContainer = defaultStyled.div `
21488
21494
  width: 100%;
21489
21495
  }
21490
21496
  `;
21491
- const { useToken: useAntdToken } = theme$1;
21497
+ const { useToken: useAntdToken } = theme;
21492
21498
  const InvoiceQuoteView = ({ children, formattedInvoice, html, backButtonName, onBackButtonClick, onDownloadError, targetUrl, }) => {
21493
21499
  const downloadFile = useDownloadFile(formattedInvoice === null || formattedInvoice === void 0 ? void 0 : formattedInvoice.id, onDownloadError);
21494
21500
  const { apiHost } = useContext(BunnyContext);
@@ -1,6 +1,8 @@
1
1
  import FormattedInvoice from '@/types/FormattedInvoice';
2
2
  import Invoice from '@/types/Invoice';
3
- import { FragmentOf } from 'gql.tada';
3
+ import { FragmentOf, ResultOf } from 'gql.tada';
4
+ import { PaymentForm_PaymentMethodsFragment } from './fragments/PaymentForm_PaymentMethodsFragment';
5
+ type PaymentMethodFragment = ResultOf<typeof PaymentForm_PaymentMethodsFragment>;
4
6
  export declare const PaymentForm_QuoteFragment: import("gql.tada").TadaDocumentNode<{
5
7
  id: string | null;
6
8
  currencyId: string;
@@ -18,7 +20,7 @@ export declare function PaymentForm({ invoice, quote: maskedQuote, onPaymentSucc
18
20
  onPaymentSuccess?: (response: any) => void;
19
21
  onPaymentHoldSuccess?: (response: any) => void;
20
22
  onSavePaymentMethod?: (response: any) => void;
21
- onRemovePaymentMethod?: () => void;
23
+ onRemovePaymentMethod?: (paymentMethod: PaymentMethodFragment) => void;
22
24
  onSetDefaultPaymentMethod?: () => void;
23
25
  accountId?: string;
24
26
  overrideToken?: string;
@@ -28,3 +30,4 @@ export declare function PaymentForm({ invoice, quote: maskedQuote, onPaymentSucc
28
30
  amountToHold?: number;
29
31
  };
30
32
  }): import("react/jsx-runtime").JSX.Element | null;
33
+ export {};
@@ -3,6 +3,9 @@ export declare const PaymentForm_PaymentMethodsFragment: import("gql.tada").Tada
3
3
  MiniCreditCard_PaymentMethodFragment: "PaymentMethod";
4
4
  };
5
5
  id: string;
6
+ plugin: {
7
+ id: string;
8
+ } | null;
6
9
  }, {}, {
7
10
  fragment: "PaymentForm_PaymentMethodsFragment";
8
11
  on: "PaymentMethod";
@@ -1,2 +1,5 @@
1
- declare function useRemovePaymentMethod(onRemovePaymentMethod?: () => void, onError?: (message: string) => void): (data: any) => Promise<void>;
1
+ import { ResultOf } from 'gql.tada';
2
+ import { PaymentForm_PaymentMethodsFragment } from '../fragments/PaymentForm_PaymentMethodsFragment';
3
+ type PaymentMethodFragment = ResultOf<typeof PaymentForm_PaymentMethodsFragment>;
4
+ declare function useRemovePaymentMethod(onRemovePaymentMethod?: (paymentMethod: PaymentMethodFragment) => void, onError?: (message: string) => void): (data: PaymentMethodFragment) => Promise<void>;
2
5
  export default useRemovePaymentMethod;
@@ -1,4 +1,4 @@
1
- import { Rule } from "antd/lib/form/index";
1
+ import type { Rule } from "antd/es/form";
2
2
  import { ReactElement } from "react";
3
3
  import { IconName } from "@fortawesome/free-solid-svg-icons";
4
4
  import TableColumn from "./TableColumn";
package/dist/index.d.ts CHANGED
@@ -3,7 +3,7 @@ import FormattedInvoice from '@/types/FormattedInvoice';
3
3
  import { FormattedQuote } from '@/types/FormattedQuote';
4
4
  import { Transaction, TransactionKind } from '@/types/Transaction';
5
5
  import * as gql_tada from 'gql.tada';
6
- import { FragmentOf } from 'gql.tada';
6
+ import { FragmentOf, ResultOf } from 'gql.tada';
7
7
  import Invoice$1 from '@/types/Invoice';
8
8
  import { QueryClient } from '@tanstack/react-query';
9
9
  import { ThemeConfig } from 'antd';
@@ -79,6 +79,21 @@ declare function Quotes({ className, columns, filter, filterQuotes, sort, noQuot
79
79
  noQuotesMessage?: string;
80
80
  }): react_jsx_runtime.JSX.Element;
81
81
 
82
+ declare const PaymentForm_PaymentMethodsFragment: gql_tada.TadaDocumentNode<{
83
+ [$tada.fragmentRefs]: {
84
+ MiniCreditCard_PaymentMethodFragment: "PaymentMethod";
85
+ };
86
+ id: string;
87
+ plugin: {
88
+ id: string;
89
+ } | null;
90
+ }, {}, {
91
+ fragment: "PaymentForm_PaymentMethodsFragment";
92
+ on: "PaymentMethod";
93
+ masked: true;
94
+ }>;
95
+
96
+ type PaymentMethodFragment = ResultOf<typeof PaymentForm_PaymentMethodsFragment>;
82
97
  declare const PaymentForm_QuoteFragment: gql_tada.TadaDocumentNode<{
83
98
  id: string | null;
84
99
  currencyId: string;
@@ -96,7 +111,7 @@ declare function PaymentForm({ invoice, quote: maskedQuote, onPaymentSuccess, on
96
111
  onPaymentSuccess?: (response: any) => void;
97
112
  onPaymentHoldSuccess?: (response: any) => void;
98
113
  onSavePaymentMethod?: (response: any) => void;
99
- onRemovePaymentMethod?: () => void;
114
+ onRemovePaymentMethod?: (paymentMethod: PaymentMethodFragment) => void;
100
115
  onSetDefaultPaymentMethod?: () => void;
101
116
  accountId?: string;
102
117
  overrideToken?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bunnyapp/components",
3
- "version": "1.7.0-beta.10",
3
+ "version": "1.7.0-beta.14",
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",