@dmsi/wedgekit-react 0.0.160 → 0.0.162

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.
Files changed (58) hide show
  1. package/dist/{chunk-NMVSRA5Y.js → chunk-4XA32LKR.js} +2 -3
  2. package/dist/{chunk-4T7F5BZZ.js → chunk-6LN6QT6M.js} +1 -1
  3. package/dist/{chunk-5GOJRLQO.js → chunk-FCREADUH.js} +1 -1
  4. package/dist/{chunk-IDN3IN2A.js → chunk-M3433XEJ.js} +9 -2
  5. package/dist/{chunk-YR7JUKYO.js → chunk-RLK4TBXR.js} +1 -1
  6. package/dist/{chunk-4NCDT5ZY.js → chunk-SBSHZ327.js} +1 -1
  7. package/dist/components/CalendarRange.cjs +2 -3
  8. package/dist/components/CalendarRange.js +1 -1
  9. package/dist/components/DataGridCell.cjs +1 -1
  10. package/dist/components/DataGridCell.js +3 -3
  11. package/dist/components/DataTable.cjs +1 -2
  12. package/dist/components/DataTable.js +1 -3
  13. package/dist/components/DateInput.cjs +12 -6
  14. package/dist/components/DateInput.js +3 -3
  15. package/dist/components/DateRangeInput.cjs +12 -6
  16. package/dist/components/DateRangeInput.js +3 -3
  17. package/dist/components/EditingContext.cjs +1 -2
  18. package/dist/components/EditingContext.js +1 -2
  19. package/dist/components/HorizontalDivider.js +8 -3
  20. package/dist/components/Menu.cjs +1 -1
  21. package/dist/components/Menu.js +2 -2
  22. package/dist/components/MobileDataGrid.cjs +7 -3
  23. package/dist/components/MobileDataGrid.js +7 -3
  24. package/dist/components/Modal.cjs +1 -1
  25. package/dist/components/Modal.js +2 -2
  26. package/dist/components/NavigationTabs.cjs +4 -4
  27. package/dist/components/NavigationTabs.js +4 -4
  28. package/dist/components/PDFViewer.cjs +1 -1
  29. package/dist/components/PDFViewer.js +2 -2
  30. package/dist/components/Radio.js +133 -5
  31. package/dist/components/Time.cjs +1 -1
  32. package/dist/components/Time.js +1 -1
  33. package/dist/components/WorldpayIframe.js +6 -3
  34. package/dist/components/index.cjs +29 -1041
  35. package/dist/components/index.js +3 -19
  36. package/dist/index.css +0 -6
  37. package/dist/utils/index.cjs +9 -2
  38. package/dist/utils/index.js +1 -1
  39. package/package.json +1 -1
  40. package/src/components/CalendarRange.tsx +15 -9
  41. package/src/components/DataTable.tsx +1 -3
  42. package/src/components/EditingContext.tsx +4 -3
  43. package/src/components/MobileDataGrid.tsx +12 -4
  44. package/src/components/NavigationTabs.tsx +1 -1
  45. package/src/components/index.ts +0 -1
  46. package/src/utils/date.ts +65 -35
  47. package/src/utils.ts +1 -1
  48. package/dist/chunk-BATIOCXB.js +0 -138
  49. package/dist/chunk-EPQLWHCL.js +0 -11
  50. package/dist/chunk-NT2ZKA4W.js +0 -266
  51. package/dist/chunk-RUTYNLKS.js +0 -112
  52. package/dist/chunk-WFGKIR5A.js +0 -9
  53. package/dist/components/PaymentOnAccountModal.cjs +0 -2381
  54. package/dist/components/PaymentOnAccountModal.js +0 -35
  55. package/dist/components/SelectPaymentMethod.cjs +0 -1355
  56. package/dist/components/SelectPaymentMethod.js +0 -22
  57. package/src/components/PaymentOnAccountModal.tsx +0 -121
  58. package/src/components/SelectPaymentMethod.tsx +0 -315
@@ -1,266 +0,0 @@
1
- import {
2
- WorldpayIframe
3
- } from "./chunk-WFGKIR5A.js";
4
- import {
5
- Radio
6
- } from "./chunk-BATIOCXB.js";
7
- import {
8
- Spinner
9
- } from "./chunk-PLMGI5K5.js";
10
- import {
11
- HorizontalDivider
12
- } from "./chunk-EPQLWHCL.js";
13
- import {
14
- Checkbox
15
- } from "./chunk-WFQEE2OO.js";
16
- import {
17
- formatCurrencyDisplay,
18
- formatDecimalValue
19
- } from "./chunk-5UH6QUFB.js";
20
- import {
21
- Subheader
22
- } from "./chunk-CYZL57LH.js";
23
- import {
24
- Accordion
25
- } from "./chunk-WSS2DFTP.js";
26
- import {
27
- Stack
28
- } from "./chunk-N6JVLYEE.js";
29
- import {
30
- Card
31
- } from "./chunk-4LXG6QNT.js";
32
- import {
33
- Button
34
- } from "./chunk-FKMKHLQH.js";
35
-
36
- // src/components/SelectPaymentMethod.tsx
37
- import { useEffect, useState } from "react";
38
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
39
- function SelectPaymentMethod(props) {
40
- const {
41
- amountToPay,
42
- selectedMethod,
43
- onSelectMethod,
44
- selectedCredits,
45
- allCredits,
46
- allowedMethods,
47
- selectedACHBankGuid,
48
- setSelectedACHBankGuid,
49
- customerBanks,
50
- onPay,
51
- isPayLoading,
52
- withCredits = false,
53
- isLoadingCCiframe,
54
- cardPaymentUrl,
55
- testid
56
- } = props;
57
- const payAllWithCredits = withCredits && amountToPay <= 0;
58
- useEffect(() => {
59
- if (payAllWithCredits) {
60
- onSelectMethod("CreditsOnly");
61
- } else {
62
- onSelectMethod(null);
63
- }
64
- }, [onSelectMethod, payAllWithCredits]);
65
- function handleToggle(method) {
66
- onSelectMethod(method);
67
- }
68
- return /* @__PURE__ */ jsxs(Stack, { sizing: "layout-group", width: "full", minWidth: 400, children: [
69
- !!(allCredits == null ? void 0 : allCredits.length) && withCredits && /* @__PURE__ */ jsx(
70
- CreditsSelector,
71
- {
72
- testid: testid ? `${testid}-credit-selector` : void 0,
73
- selectedCredits: selectedCredits || [],
74
- allCredits: allCredits || [],
75
- setSelectedCredits: props.setSelectedCredits || (() => {
76
- })
77
- }
78
- ),
79
- (allowedMethods == null ? void 0 : allowedMethods.includes("ACHPayment")) && !!(customerBanks == null ? void 0 : customerBanks.length) && /* @__PURE__ */ jsx(
80
- ACHSelector,
81
- {
82
- testid: testid ? `${testid}-ach-selector` : void 0,
83
- selectedMethod,
84
- handleToggle,
85
- selectedBankGuid: selectedACHBankGuid || null,
86
- setSelectedBankGuid: setSelectedACHBankGuid || (() => {
87
- }),
88
- customerBanks: customerBanks || [],
89
- onPay,
90
- isPayLoading: isPayLoading || false,
91
- disabled: payAllWithCredits || !amountToPay
92
- }
93
- ),
94
- (allowedMethods == null ? void 0 : allowedMethods.includes("CCPayment")) && /* @__PURE__ */ jsx(
95
- Accordion,
96
- {
97
- testid: testid ? `${testid}-cc-payment` : void 0,
98
- isOpen: !payAllWithCredits && selectedMethod === "CCPayment",
99
- title: /* @__PURE__ */ jsx(
100
- Radio,
101
- {
102
- testid: testid ? `${testid}-cc-payment-radio` : void 0,
103
- label: "Pay by Credit/Debit Card",
104
- checked: !payAllWithCredits && selectedMethod === "CCPayment",
105
- onChange: (e) => e.stopPropagation(),
106
- disabled: payAllWithCredits || !amountToPay
107
- }
108
- ),
109
- onClick: () => {
110
- if (payAllWithCredits || !amountToPay) return;
111
- handleToggle(selectedMethod === "CCPayment" ? null : "CCPayment");
112
- },
113
- disabled: payAllWithCredits || !amountToPay,
114
- children: /* @__PURE__ */ jsx(
115
- Stack,
116
- {
117
- sizing: "layout-group",
118
- width: "full",
119
- items: "center",
120
- justify: "center",
121
- style: {
122
- flex: 1
123
- },
124
- minHeight: 245,
125
- children: !isLoadingCCiframe && cardPaymentUrl ? /* @__PURE__ */ jsx(WorldpayIframe, { url: cardPaymentUrl }) : /* @__PURE__ */ jsx(Spinner, {})
126
- }
127
- )
128
- }
129
- ),
130
- selectedMethod === "ACHPayment" && /* @__PURE__ */ jsx(
131
- Button,
132
- {
133
- block: true,
134
- onClick: onPay,
135
- disabled: isPayLoading || amountToPay <= 0,
136
- testid: testid ? `${testid}-submit-payment-button` : void 0,
137
- children: isPayLoading ? "Processing..." : "Submit Payment"
138
- }
139
- ),
140
- payAllWithCredits && /* @__PURE__ */ jsx(
141
- Button,
142
- {
143
- testid: testid ? `${testid}-submit-payment-button` : void 0,
144
- block: true,
145
- onClick: onPay,
146
- disabled: isPayLoading,
147
- children: isPayLoading ? "Processing..." : "Submit Payment"
148
- }
149
- )
150
- ] });
151
- }
152
- function ACHSelector(props) {
153
- const {
154
- selectedMethod,
155
- handleToggle,
156
- selectedBankGuid,
157
- setSelectedBankGuid,
158
- customerBanks,
159
- disabled,
160
- testid
161
- } = props;
162
- function handleBankSelect(e, bankGuid) {
163
- if (disabled) return;
164
- e.stopPropagation();
165
- setSelectedBankGuid(bankGuid);
166
- handleToggle("ACHPayment");
167
- }
168
- return /* @__PURE__ */ jsx(Fragment, { children: customerBanks.map((bank) => /* @__PURE__ */ jsx(
169
- Card,
170
- {
171
- testid: testid ? `${testid}-bank-${bank.CustBankGUID}` : void 0,
172
- onClick: (e) => handleBankSelect(e, bank.CustBankGUID),
173
- selected: !disabled && selectedMethod === "ACHPayment" && selectedBankGuid === bank.CustBankGUID,
174
- children: /* @__PURE__ */ jsx(
175
- Radio,
176
- {
177
- label: `Pay by ${bank.AccountDisplayString}`,
178
- checked: !disabled && selectedMethod === "ACHPayment" && selectedBankGuid === bank.CustBankGUID,
179
- disabled,
180
- onChange: (e) => e.stopPropagation()
181
- }
182
- )
183
- },
184
- bank.CustBankGUID
185
- )) });
186
- }
187
- function CreditsSelector(props) {
188
- const { selectedCredits, allCredits, setSelectedCredits, testid } = props;
189
- const [isOpen, setIsOpen] = useState(true);
190
- const handleCreditSelect = (credit) => {
191
- if (setSelectedCredits) {
192
- setSelectedCredits(
193
- (prev) => prev.includes(credit) ? prev.filter((c) => c !== credit) : [...prev, credit]
194
- );
195
- }
196
- };
197
- return /* @__PURE__ */ jsxs(
198
- Accordion,
199
- {
200
- isOpen,
201
- title: "Available Credits",
202
- onClick: () => setIsOpen((prev) => !prev),
203
- testid,
204
- children: [
205
- /* @__PURE__ */ jsx(HorizontalDivider, {}),
206
- /* @__PURE__ */ jsx(Stack, { sizing: "layout-group", width: "full", children: /* @__PURE__ */ jsx(
207
- Stack,
208
- {
209
- sizing: "layout-group",
210
- width: "full",
211
- overflowY: "auto",
212
- maxHeight: 300,
213
- children: allCredits.map((credits) => /* @__PURE__ */ jsxs(
214
- Stack,
215
- {
216
- horizontal: true,
217
- justify: "between",
218
- items: "center",
219
- sizing: "layout-group",
220
- children: [
221
- /* @__PURE__ */ jsx(
222
- Stack,
223
- {
224
- sizing: "layout-group",
225
- onClick: () => handleCreditSelect(credits),
226
- paddingY: true,
227
- flexGrow: 1,
228
- testid: testid ? `${testid}-credit-${credits.InvoiceNumber}` : void 0,
229
- children: /* @__PURE__ */ jsx(
230
- Checkbox,
231
- {
232
- testid: testid ? `${testid}-credit-${credits.InvoiceNumber}-checkbox` : void 0,
233
- label: credits.InvoiceNumber,
234
- checked: selectedCredits == null ? void 0 : selectedCredits.includes(credits),
235
- onChange: () => handleCreditSelect(credits)
236
- }
237
- )
238
- }
239
- ),
240
- /* @__PURE__ */ jsxs(
241
- Subheader,
242
- {
243
- testid: testid ? `${testid}-credit-${credits.InvoiceNumber}-InvoiceBalanceDue` : void 0,
244
- className: " pr-desktop-component-padding",
245
- children: [
246
- "$",
247
- formatCurrencyDisplay(
248
- formatDecimalValue(Math.abs(credits.InvoiceBalanceDue), 2)
249
- )
250
- ]
251
- }
252
- )
253
- ]
254
- },
255
- credits.AROpenGUID
256
- ))
257
- }
258
- ) })
259
- ]
260
- }
261
- );
262
- }
263
-
264
- export {
265
- SelectPaymentMethod
266
- };
@@ -1,112 +0,0 @@
1
- import {
2
- SelectPaymentMethod
3
- } from "./chunk-NT2ZKA4W.js";
4
- import {
5
- Modal
6
- } from "./chunk-5GOJRLQO.js";
7
- import {
8
- Input
9
- } from "./chunk-4T3DRGLF.js";
10
- import {
11
- formatCurrencyDisplay
12
- } from "./chunk-5UH6QUFB.js";
13
- import {
14
- Stack
15
- } from "./chunk-N6JVLYEE.js";
16
- import {
17
- Card
18
- } from "./chunk-4LXG6QNT.js";
19
- import {
20
- Paragraph
21
- } from "./chunk-HVI3CL7Y.js";
22
- import {
23
- __spreadProps,
24
- __spreadValues
25
- } from "./chunk-ORMEWXMH.js";
26
-
27
- // src/components/PaymentOnAccountModal.tsx
28
- import { useEffect, useMemo, useState } from "react";
29
- import { jsx, jsxs } from "react/jsx-runtime";
30
- function PaymentOnAccountModal(props) {
31
- const {
32
- isOpen,
33
- paymentProps,
34
- onClose,
35
- onAmountChange,
36
- cardPaymentUrl,
37
- setCardPaymentUrl,
38
- isLoadingCCiframe,
39
- testid
40
- } = props;
41
- const [amount, setAmount] = useState(paymentProps.amountToPay);
42
- const { creditCardSettings, selectedMethod } = paymentProps;
43
- useEffect(() => {
44
- setAmount(paymentProps.amountToPay);
45
- }, [paymentProps.amountToPay]);
46
- function handleAmountChange(event) {
47
- const inputValue = event.target.value.replace(/[^0-9.-]+/g, "");
48
- const value = +inputValue || 0;
49
- setAmount(value);
50
- onAmountChange == null ? void 0 : onAmountChange(value);
51
- }
52
- const creditCardSurcharge = useMemo(() => {
53
- const applySurcharge = (creditCardSettings == null ? void 0 : creditCardSettings.ApplySurcharge) || false;
54
- if (!applySurcharge || selectedMethod !== "CCPayment") {
55
- return 0;
56
- }
57
- const surchargeType = creditCardSettings == null ? void 0 : creditCardSettings.SurchargeBasisType;
58
- const surchargeRate = (creditCardSettings == null ? void 0 : creditCardSettings.SurchargeBasisAmount) || 0;
59
- if (surchargeType === "Percent") {
60
- return calculateSurcharge(amount, surchargeRate);
61
- }
62
- if (surchargeType === "Fixed") {
63
- return surchargeRate;
64
- }
65
- return 0;
66
- }, [creditCardSettings, amount, selectedMethod]);
67
- return /* @__PURE__ */ jsx(Modal, { testid, open: isOpen, onClose, title: "Payment on Account", children: /* @__PURE__ */ jsxs(Stack, { sizing: "layout-group", width: "full", children: [
68
- selectedMethod === "CCPayment" && /* @__PURE__ */ jsxs(Stack, { horizontal: true, justify: "between", items: "center", children: [
69
- /* @__PURE__ */ jsx(Paragraph, { children: "Surcharge" }),
70
- /* @__PURE__ */ jsxs(Paragraph, { testid: testid ? `${testid}-surcharge` : void 0, children: [
71
- "$",
72
- formatCurrencyDisplay(creditCardSurcharge.toFixed(2))
73
- ] })
74
- ] }),
75
- /* @__PURE__ */ jsx(Card, { className: "py-desktop-component-padding", children: /* @__PURE__ */ jsxs(Stack, { sizing: "component", justify: "between", items: "center", horizontal: true, children: [
76
- /* @__PURE__ */ jsx(Paragraph, { className: "w-full", children: "Amount to Pay" }),
77
- /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
78
- Input,
79
- {
80
- testid: testid ? `${testid}-amount-to-pay` : void 0,
81
- type: "number",
82
- placeholder: "$0.00",
83
- align: "right",
84
- value: amount === 0 ? "" : amount,
85
- onChange: handleAmountChange,
86
- before: "$"
87
- }
88
- ) })
89
- ] }) }),
90
- /* @__PURE__ */ jsx(
91
- SelectPaymentMethod,
92
- __spreadProps(__spreadValues({}, paymentProps), {
93
- testid: testid ? `${testid}-select-payment-method` : void 0,
94
- amountToPay: amount + creditCardSurcharge,
95
- cardPaymentUrl,
96
- setCardPaymentUrl,
97
- isLoadingCCiframe
98
- })
99
- )
100
- ] }) });
101
- }
102
- function calculateSurcharge(amountInDollars, surchargeRate) {
103
- const amountInCents = amountInDollars * 100;
104
- const surchargeInCents = amountInCents * surchargeRate / 100;
105
- const roundedSurchargeInCents = Math.round(surchargeInCents);
106
- return roundedSurchargeInCents / 100;
107
- }
108
-
109
- export {
110
- PaymentOnAccountModal,
111
- calculateSurcharge
112
- };
@@ -1,9 +0,0 @@
1
- // src/components/WorldpayIframe.tsx
2
- import { jsx } from "react/jsx-runtime";
3
- function WorldpayIframe({ url }) {
4
- return /* @__PURE__ */ jsx("iframe", { src: url, style: { width: "100%", height: "100%", flex: 1 } });
5
- }
6
-
7
- export {
8
- WorldpayIframe
9
- };