@bunnyapp/components 1.8.0-beta.15 → 1.8.0-beta.16

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
@@ -1288,7 +1288,7 @@ const DEFAULT_CONFIG = {
1288
1288
  };
1289
1289
 
1290
1290
  // This will be replaced at build time by rollup-plugin-replace
1291
- const PACKAGE_VERSION = '1.8.0-beta.14';
1291
+ const PACKAGE_VERSION = '1.8.0-beta.15';
1292
1292
  const createRequestHeaders = (token) => {
1293
1293
  const headers = createClientDevHeaders({ token });
1294
1294
  // Add the components version header
@@ -20568,6 +20568,7 @@ function PaymentProvider({ children, quote: maskedQuote, invoice: maskedInvoice,
20568
20568
  const [isPaid, setIsPaid] = react.useState(false);
20569
20569
  const [isPaying, setIsPaying] = react.useState(false);
20570
20570
  const [isApprovingHold, setIsApprovingHold] = react.useState(false);
20571
+ const [isSaving, setIsSaving] = react.useState(false);
20571
20572
  const getAmountDue = () => {
20572
20573
  return quote ? getQuoteAmountDue(quote) : invoice === null || invoice === void 0 ? void 0 : invoice.amountDue;
20573
20574
  };
@@ -20608,6 +20609,8 @@ function PaymentProvider({ children, quote: maskedQuote, invoice: maskedInvoice,
20608
20609
  setIsPaying,
20609
20610
  isApprovingHold,
20610
20611
  setIsApprovingHold,
20612
+ isSaving,
20613
+ setIsSaving,
20611
20614
  }, children: children }));
20612
20615
  }
20613
20616
 
@@ -21111,7 +21114,7 @@ function Pay(props = {}) {
21111
21114
  const isMobile = useIsMobile();
21112
21115
  const { onPaymentSuccess, onPaymentHoldSuccess, onSavePaymentMethod, paymentHoldPrecondition } = usePaymentFormCallbacks();
21113
21116
  const selectedPlugin = useSelectedPlugin();
21114
- const { quoteId, invoiceId, paymentHold, paymentType, setIsPaid, setIsPaying, setIsApprovingHold } = usePayable();
21117
+ const { quoteId, invoiceId, paymentHold, paymentType, setIsPaid, setIsPaying, setIsApprovingHold, setIsSaving } = usePayable();
21115
21118
  const accountId = useAccountId();
21116
21119
  const { defaultPaymentMethod } = usePaymentMethod({ accountId });
21117
21120
  const [showPaymentDetailsForm, setShowPaymentDetailsForm] = useShowPaymentDetails();
@@ -21194,6 +21197,10 @@ function Pay(props = {}) {
21194
21197
  setIsApprovingHold(isApprovingHold);
21195
21198
  return () => setIsApprovingHold(false);
21196
21199
  }, [isApprovingHold, setIsApprovingHold]);
21200
+ react.useEffect(() => {
21201
+ setIsSaving(isSaving);
21202
+ return () => setIsSaving(false);
21203
+ }, [isSaving, setIsSaving]);
21197
21204
  return (jsxRuntime.jsx(antd.Button, { className: "bunny-w-full", disabled: isPaying || isApprovingHold || isSaving || disabled, loading: isPaying || isApprovingHold || isSaving, onClick: handlePayment, size: isMobile ? 'large' : 'middle', type: "primary", children: paymentButtonText }));
21198
21205
  }
21199
21206
 
@@ -21286,7 +21293,8 @@ const [PaymentMethodFormVisibilityProvider, usePaymentMethodFormVisibility] = cr
21286
21293
  function Cancel() {
21287
21294
  const isMobile = useIsMobile();
21288
21295
  const [, setShowPaymentMethodForm] = useShowPaymentDetails();
21289
- return (jsxRuntime.jsx(antd.Button, { className: "bunny-w-full", size: isMobile ? 'large' : 'middle', onClick: () => setShowPaymentMethodForm(false), children: "Cancel" }));
21296
+ const { isApprovingHold, isPaying, isSaving } = usePayable();
21297
+ return (jsxRuntime.jsx(antd.Button, { className: "bunny-w-full", size: isMobile ? 'large' : 'middle', onClick: () => setShowPaymentMethodForm(false), disabled: isApprovingHold || isPaying || isSaving, children: "Cancel" }));
21290
21298
  }
21291
21299
 
21292
21300
  const CardIcon = ({ className }) => {
@@ -21298,16 +21306,17 @@ const PaymentMethodSelector = () => {
21298
21306
  const accountId = useAccountId();
21299
21307
  const { paymentPlugins } = usePaymentPlugins(accountId);
21300
21308
  const [selectedPluginId, setSelectedPluginId] = useSelectedPluginId();
21301
- return (jsxRuntime.jsx("div", { className: "bunny-flex bunny-flex-col bunny-gap-2", children: paymentPlugins === null || paymentPlugins === void 0 ? void 0 : paymentPlugins.map((plugin, index) => (jsxRuntime.jsx(PaymentOption, { name: plugin.name, onClick: setSelectedPluginId, paymentPluginId: plugin.id, selected: selectedPluginId === plugin.id }, index))) }));
21309
+ const { isSaving, isPaying, isApprovingHold } = usePayable();
21310
+ return (jsxRuntime.jsx("div", { className: "bunny-flex bunny-flex-col bunny-gap-2", children: paymentPlugins === null || paymentPlugins === void 0 ? void 0 : paymentPlugins.map((plugin, index) => (jsxRuntime.jsx(PaymentOption, { name: plugin.name, onClick: setSelectedPluginId, paymentPluginId: plugin.id, selected: selectedPluginId === plugin.id, disabled: isSaving || isPaying || isApprovingHold }, index))) }));
21302
21311
  };
21303
- const PaymentOption = ({ selected, paymentPluginId, onClick, name, }) => {
21312
+ const PaymentOption = ({ selected, paymentPluginId, onClick, name, disabled, }) => {
21304
21313
  const { brandColor } = useBrand();
21305
21314
  const { darkMode } = react.useContext(BunnyContext);
21306
21315
  const isAch = name === null || name === void 0 ? void 0 : name.toLowerCase().includes('ach');
21307
21316
  const isCard = name === null || name === void 0 ? void 0 : name.toLowerCase().includes('card');
21308
21317
  return (jsxRuntime.jsxs(PaymentOptionContainer, { "$brandColor": brandColor, "$selected": selected, className: `bunny-flex bunny-justify-between bunny-items-center bunny-cursor-pointer bunny-py-2 bunny-rounded bunny-border-solid ${darkMode
21309
21318
  ? `var(--row-background-dark) border-gray-500`
21310
- : 'bunny-bg-slate-50 bunny-border-slate-200'} bunny-border`, onClick: () => onClick(paymentPluginId), children: [jsxRuntime.jsxs("div", { className: "bunny-flex bunny-gap-2 bunny-items-center bunny-pl-4", children: [jsxRuntime.jsx(antd.Checkbox, { checked: selected, className: darkMode ? 'border-gray-400' : '' }), jsxRuntime.jsx(Text$B, { children: name })] }), isAch ? (jsxRuntime.jsx(icons.BankOutlined, { className: "bunny-pr-4" })) : isCard ? (jsxRuntime.jsx(CardIcon, { className: "bunny-pr-4" })) : (jsxRuntime.jsx(CardIcon, { className: "bunny-pr-4" }))] }));
21319
+ : 'bunny-bg-slate-50 bunny-border-slate-200'} bunny-border`, onClick: () => !disabled && onClick(paymentPluginId), children: [jsxRuntime.jsxs("div", { className: "bunny-flex bunny-gap-2 bunny-items-center bunny-pl-4", children: [jsxRuntime.jsx(antd.Checkbox, { checked: selected, className: darkMode ? 'border-gray-400' : '' }), jsxRuntime.jsx(Text$B, { children: name })] }), isAch ? (jsxRuntime.jsx(icons.BankOutlined, { className: "bunny-pr-4" })) : isCard ? (jsxRuntime.jsx(CardIcon, { className: "bunny-pr-4" })) : (jsxRuntime.jsx(CardIcon, { className: "bunny-pr-4" }))] }));
21311
21320
  };
21312
21321
  const PaymentOptionContainer = defaultStyled.div `
21313
21322
  transition: border 0.3s ease;
@@ -21328,6 +21337,7 @@ function Save() {
21328
21337
  const isMobile = useIsMobile();
21329
21338
  const { onSavePaymentMethod } = usePaymentFormCallbacks();
21330
21339
  const [_, setShowPaymentDetailsForm] = useShowPaymentDetails();
21340
+ const { setIsSaving } = usePayable();
21331
21341
  const { save: handleSave, isSaving } = useSave({
21332
21342
  accountId,
21333
21343
  onSaveSuccess: (response) => {
@@ -21337,6 +21347,10 @@ function Save() {
21337
21347
  onSaveError: handleAllErrorFormats$1,
21338
21348
  invalidatePaymentMethodsQuery: true,
21339
21349
  });
21350
+ react.useEffect(() => {
21351
+ setIsSaving(isSaving);
21352
+ return () => setIsSaving(false);
21353
+ }, [isSaving, setIsSaving]);
21340
21354
  const saveButtonText = isSaving ? 'Saving' : 'Save';
21341
21355
  return (jsxRuntime.jsx(antd.Button, { className: "bunny-w-full", disabled: isSaving, loading: isSaving, onClick: handleSave, size: isMobile ? 'large' : 'middle', type: "primary", children: saveButtonText }));
21342
21356
  }
@@ -17,6 +17,8 @@ declare const PayableProvider: ({ value, children }: {
17
17
  setIsPaying: React.Dispatch<React.SetStateAction<boolean>>;
18
18
  isApprovingHold: boolean;
19
19
  setIsApprovingHold: React.Dispatch<React.SetStateAction<boolean>>;
20
+ isSaving: boolean;
21
+ setIsSaving: React.Dispatch<React.SetStateAction<boolean>>;
20
22
  };
21
23
  children?: import("react").ReactNode;
22
24
  }) => import("react/jsx-runtime").JSX.Element, usePayable: () => {
@@ -35,6 +37,8 @@ declare const PayableProvider: ({ value, children }: {
35
37
  setIsPaying: React.Dispatch<React.SetStateAction<boolean>>;
36
38
  isApprovingHold: boolean;
37
39
  setIsApprovingHold: React.Dispatch<React.SetStateAction<boolean>>;
40
+ isSaving: boolean;
41
+ setIsSaving: React.Dispatch<React.SetStateAction<boolean>>;
38
42
  };
39
43
  export { PayableProvider, usePayable, };
40
44
  export declare const PaymentProvider_QuoteFragment: import("gql.tada").TadaDocumentNode<{
package/dist/esm/index.js CHANGED
@@ -1286,7 +1286,7 @@ const DEFAULT_CONFIG = {
1286
1286
  };
1287
1287
 
1288
1288
  // This will be replaced at build time by rollup-plugin-replace
1289
- const PACKAGE_VERSION = '1.8.0-beta.14';
1289
+ const PACKAGE_VERSION = '1.8.0-beta.15';
1290
1290
  const createRequestHeaders = (token) => {
1291
1291
  const headers = createClientDevHeaders({ token });
1292
1292
  // Add the components version header
@@ -20566,6 +20566,7 @@ function PaymentProvider({ children, quote: maskedQuote, invoice: maskedInvoice,
20566
20566
  const [isPaid, setIsPaid] = useState(false);
20567
20567
  const [isPaying, setIsPaying] = useState(false);
20568
20568
  const [isApprovingHold, setIsApprovingHold] = useState(false);
20569
+ const [isSaving, setIsSaving] = useState(false);
20569
20570
  const getAmountDue = () => {
20570
20571
  return quote ? getQuoteAmountDue(quote) : invoice === null || invoice === void 0 ? void 0 : invoice.amountDue;
20571
20572
  };
@@ -20606,6 +20607,8 @@ function PaymentProvider({ children, quote: maskedQuote, invoice: maskedInvoice,
20606
20607
  setIsPaying,
20607
20608
  isApprovingHold,
20608
20609
  setIsApprovingHold,
20610
+ isSaving,
20611
+ setIsSaving,
20609
20612
  }, children: children }));
20610
20613
  }
20611
20614
 
@@ -21109,7 +21112,7 @@ function Pay(props = {}) {
21109
21112
  const isMobile = useIsMobile();
21110
21113
  const { onPaymentSuccess, onPaymentHoldSuccess, onSavePaymentMethod, paymentHoldPrecondition } = usePaymentFormCallbacks();
21111
21114
  const selectedPlugin = useSelectedPlugin();
21112
- const { quoteId, invoiceId, paymentHold, paymentType, setIsPaid, setIsPaying, setIsApprovingHold } = usePayable();
21115
+ const { quoteId, invoiceId, paymentHold, paymentType, setIsPaid, setIsPaying, setIsApprovingHold, setIsSaving } = usePayable();
21113
21116
  const accountId = useAccountId();
21114
21117
  const { defaultPaymentMethod } = usePaymentMethod({ accountId });
21115
21118
  const [showPaymentDetailsForm, setShowPaymentDetailsForm] = useShowPaymentDetails();
@@ -21192,6 +21195,10 @@ function Pay(props = {}) {
21192
21195
  setIsApprovingHold(isApprovingHold);
21193
21196
  return () => setIsApprovingHold(false);
21194
21197
  }, [isApprovingHold, setIsApprovingHold]);
21198
+ useEffect(() => {
21199
+ setIsSaving(isSaving);
21200
+ return () => setIsSaving(false);
21201
+ }, [isSaving, setIsSaving]);
21195
21202
  return (jsx(Button, { className: "bunny-w-full", disabled: isPaying || isApprovingHold || isSaving || disabled, loading: isPaying || isApprovingHold || isSaving, onClick: handlePayment, size: isMobile ? 'large' : 'middle', type: "primary", children: paymentButtonText }));
21196
21203
  }
21197
21204
 
@@ -21284,7 +21291,8 @@ const [PaymentMethodFormVisibilityProvider, usePaymentMethodFormVisibility] = cr
21284
21291
  function Cancel() {
21285
21292
  const isMobile = useIsMobile();
21286
21293
  const [, setShowPaymentMethodForm] = useShowPaymentDetails();
21287
- return (jsx(Button, { className: "bunny-w-full", size: isMobile ? 'large' : 'middle', onClick: () => setShowPaymentMethodForm(false), children: "Cancel" }));
21294
+ const { isApprovingHold, isPaying, isSaving } = usePayable();
21295
+ return (jsx(Button, { className: "bunny-w-full", size: isMobile ? 'large' : 'middle', onClick: () => setShowPaymentMethodForm(false), disabled: isApprovingHold || isPaying || isSaving, children: "Cancel" }));
21288
21296
  }
21289
21297
 
21290
21298
  const CardIcon = ({ className }) => {
@@ -21296,16 +21304,17 @@ const PaymentMethodSelector = () => {
21296
21304
  const accountId = useAccountId();
21297
21305
  const { paymentPlugins } = usePaymentPlugins(accountId);
21298
21306
  const [selectedPluginId, setSelectedPluginId] = useSelectedPluginId();
21299
- return (jsx("div", { className: "bunny-flex bunny-flex-col bunny-gap-2", children: paymentPlugins === null || paymentPlugins === void 0 ? void 0 : paymentPlugins.map((plugin, index) => (jsx(PaymentOption, { name: plugin.name, onClick: setSelectedPluginId, paymentPluginId: plugin.id, selected: selectedPluginId === plugin.id }, index))) }));
21307
+ const { isSaving, isPaying, isApprovingHold } = usePayable();
21308
+ return (jsx("div", { className: "bunny-flex bunny-flex-col bunny-gap-2", children: paymentPlugins === null || paymentPlugins === void 0 ? void 0 : paymentPlugins.map((plugin, index) => (jsx(PaymentOption, { name: plugin.name, onClick: setSelectedPluginId, paymentPluginId: plugin.id, selected: selectedPluginId === plugin.id, disabled: isSaving || isPaying || isApprovingHold }, index))) }));
21300
21309
  };
21301
- const PaymentOption = ({ selected, paymentPluginId, onClick, name, }) => {
21310
+ const PaymentOption = ({ selected, paymentPluginId, onClick, name, disabled, }) => {
21302
21311
  const { brandColor } = useBrand();
21303
21312
  const { darkMode } = useContext(BunnyContext);
21304
21313
  const isAch = name === null || name === void 0 ? void 0 : name.toLowerCase().includes('ach');
21305
21314
  const isCard = name === null || name === void 0 ? void 0 : name.toLowerCase().includes('card');
21306
21315
  return (jsxs(PaymentOptionContainer, { "$brandColor": brandColor, "$selected": selected, className: `bunny-flex bunny-justify-between bunny-items-center bunny-cursor-pointer bunny-py-2 bunny-rounded bunny-border-solid ${darkMode
21307
21316
  ? `var(--row-background-dark) border-gray-500`
21308
- : 'bunny-bg-slate-50 bunny-border-slate-200'} bunny-border`, onClick: () => onClick(paymentPluginId), children: [jsxs("div", { className: "bunny-flex bunny-gap-2 bunny-items-center bunny-pl-4", children: [jsx(Checkbox, { checked: selected, className: darkMode ? 'border-gray-400' : '' }), jsx(Text$B, { children: name })] }), isAch ? (jsx(BankOutlined, { className: "bunny-pr-4" })) : isCard ? (jsx(CardIcon, { className: "bunny-pr-4" })) : (jsx(CardIcon, { className: "bunny-pr-4" }))] }));
21317
+ : 'bunny-bg-slate-50 bunny-border-slate-200'} bunny-border`, onClick: () => !disabled && onClick(paymentPluginId), children: [jsxs("div", { className: "bunny-flex bunny-gap-2 bunny-items-center bunny-pl-4", children: [jsx(Checkbox, { checked: selected, className: darkMode ? 'border-gray-400' : '' }), jsx(Text$B, { children: name })] }), isAch ? (jsx(BankOutlined, { className: "bunny-pr-4" })) : isCard ? (jsx(CardIcon, { className: "bunny-pr-4" })) : (jsx(CardIcon, { className: "bunny-pr-4" }))] }));
21309
21318
  };
21310
21319
  const PaymentOptionContainer = defaultStyled.div `
21311
21320
  transition: border 0.3s ease;
@@ -21326,6 +21335,7 @@ function Save() {
21326
21335
  const isMobile = useIsMobile();
21327
21336
  const { onSavePaymentMethod } = usePaymentFormCallbacks();
21328
21337
  const [_, setShowPaymentDetailsForm] = useShowPaymentDetails();
21338
+ const { setIsSaving } = usePayable();
21329
21339
  const { save: handleSave, isSaving } = useSave({
21330
21340
  accountId,
21331
21341
  onSaveSuccess: (response) => {
@@ -21335,6 +21345,10 @@ function Save() {
21335
21345
  onSaveError: handleAllErrorFormats$1,
21336
21346
  invalidatePaymentMethodsQuery: true,
21337
21347
  });
21348
+ useEffect(() => {
21349
+ setIsSaving(isSaving);
21350
+ return () => setIsSaving(false);
21351
+ }, [isSaving, setIsSaving]);
21338
21352
  const saveButtonText = isSaving ? 'Saving' : 'Save';
21339
21353
  return (jsx(Button, { className: "bunny-w-full", disabled: isSaving, loading: isSaving, onClick: handleSave, size: isMobile ? 'large' : 'middle', type: "primary", children: saveButtonText }));
21340
21354
  }
@@ -17,6 +17,8 @@ declare const PayableProvider: ({ value, children }: {
17
17
  setIsPaying: React.Dispatch<React.SetStateAction<boolean>>;
18
18
  isApprovingHold: boolean;
19
19
  setIsApprovingHold: React.Dispatch<React.SetStateAction<boolean>>;
20
+ isSaving: boolean;
21
+ setIsSaving: React.Dispatch<React.SetStateAction<boolean>>;
20
22
  };
21
23
  children?: import("react").ReactNode;
22
24
  }) => import("react/jsx-runtime").JSX.Element, usePayable: () => {
@@ -35,6 +37,8 @@ declare const PayableProvider: ({ value, children }: {
35
37
  setIsPaying: React.Dispatch<React.SetStateAction<boolean>>;
36
38
  isApprovingHold: boolean;
37
39
  setIsApprovingHold: React.Dispatch<React.SetStateAction<boolean>>;
40
+ isSaving: boolean;
41
+ setIsSaving: React.Dispatch<React.SetStateAction<boolean>>;
38
42
  };
39
43
  export { PayableProvider, usePayable, };
40
44
  export declare const PaymentProvider_QuoteFragment: import("gql.tada").TadaDocumentNode<{
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bunnyapp/components",
3
- "version": "1.8.0-beta.15",
3
+ "version": "1.8.0-beta.16",
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",