@dmsi/wedgekit-react 0.0.161 → 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.
@@ -4,21 +4,6 @@ import {
4
4
  import {
5
5
  Select
6
6
  } from "../chunk-XH65MD2C.js";
7
- import {
8
- PaymentOnAccountModal
9
- } from "../chunk-WFLOAGEI.js";
10
- import "../chunk-NT2ZKA4W.js";
11
- import "../chunk-WFGKIR5A.js";
12
- import "../chunk-BATIOCXB.js";
13
- import "../chunk-FCREADUH.js";
14
- import "../chunk-4RJKB7LC.js";
15
- import "../chunk-C4JGTH6G.js";
16
- import "../chunk-SYEJVSE4.js";
17
- import "../chunk-R7ELP5C5.js";
18
- import "../chunk-ZFOANBWG.js";
19
- import "../chunk-PLMGI5K5.js";
20
- import "../chunk-AZ7LVLOK.js";
21
- import "../chunk-EPQLWHCL.js";
22
7
  import {
23
8
  Checkbox
24
9
  } from "../chunk-WFQEE2OO.js";
@@ -1124,7 +1109,6 @@ export {
1124
1109
  Menu,
1125
1110
  MenuOption,
1126
1111
  Paragraph,
1127
- PaymentOnAccountModal,
1128
1112
  Search,
1129
1113
  Select,
1130
1114
  Subheader,
package/dist/index.css CHANGED
@@ -1872,9 +1872,6 @@
1872
1872
  .py-\[calc\(var\(--spacing-mobile-component-padding\)_\+_3px\)\] {
1873
1873
  padding-block: calc(var(--spacing-mobile-component-padding) + 3px);
1874
1874
  }
1875
- .py-desktop-component-padding {
1876
- padding-block: var(--spacing-desktop-component-padding);
1877
- }
1878
1875
  .py-mobile-component-gap {
1879
1876
  padding-block: var(--spacing-mobile-component-gap);
1880
1877
  }
@@ -1893,9 +1890,6 @@
1893
1890
  .pt-\[7px\] {
1894
1891
  padding-top: 7px;
1895
1892
  }
1896
- .pr-desktop-component-padding {
1897
- padding-right: var(--spacing-desktop-component-padding);
1898
- }
1899
1893
  .pb-2 {
1900
1894
  padding-bottom: calc(var(--spacing) * 2);
1901
1895
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dmsi/wedgekit-react",
3
3
  "private": false,
4
- "version": "0.0.161",
4
+ "version": "0.0.162",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "build": "tsup",
@@ -18,6 +18,5 @@ export { MenuOption } from "./MenuOption";
18
18
  export { Search } from "./Search";
19
19
  export { Tooltip } from "./Tooltip";
20
20
  export { Input } from "./Input";
21
- export { PaymentOnAccountModal } from "./PaymentOnAccountModal";
22
21
  export { Accordion } from "./Accordion";
23
22
  export { Card } from "./Card";
@@ -1,138 +0,0 @@
1
- import {
2
- Paragraph
3
- } from "./chunk-HVI3CL7Y.js";
4
- import {
5
- baseTransition,
6
- componentGap
7
- } from "./chunk-RDLEIAQU.js";
8
- import {
9
- __objRest,
10
- __spreadValues
11
- } from "./chunk-ORMEWXMH.js";
12
-
13
- // src/components/Radio.tsx
14
- import clsx from "clsx";
15
- import { jsx, jsxs } from "react/jsx-runtime";
16
- var Radio = (_a) => {
17
- var _b = _a, {
18
- className,
19
- label,
20
- error,
21
- disabled,
22
- checked,
23
- readOnly,
24
- id,
25
- testid
26
- } = _b, props = __objRest(_b, [
27
- "className",
28
- "label",
29
- "error",
30
- "disabled",
31
- "checked",
32
- "readOnly",
33
- "id",
34
- "testid"
35
- ]);
36
- const radioId = id;
37
- const paragraphColor = disabled ? "text-primary-disabled" : error ? "text-primary-error" : "text-primary-normal";
38
- const defaultClassName = clsx(
39
- !error && !disabled && "border-border-primary-normal peer-hover:border-border-action-hover peer-hover:bg-background-action-secondary-hover peer-focus:border-border-action-hover peer-focus:bg-background-action-secondary-hover peer-active:border-border-action-active peer-active:bg-background-action-secondary-active peer-checked:border-0 peer-checked:bg-background-action-secondary-hover"
40
- );
41
- const errorClassName = clsx(
42
- error && !disabled && "border-border-action-critical-normal peer-hover:border-border-action-critical-hover peer-hover:bg-background-action-critical-secondary-hover peer-focus:border-border-action-critical-hover peer-focus:bg-background-action-critical-secondary-hover peer-active:border-border-action-critical-active peer-active:bg-background-action-secondary-active peer-checked:bg-background-action-critical-secondary-hover peer-checked:border-0 "
43
- );
44
- const disabledClassName = clsx(
45
- disabled && "peer-disabled:bg-background-action-secondary-disabled peer-disabled:border-border-primary-normal peer-checked:border-0"
46
- );
47
- const readonlyClassName = clsx(
48
- readOnly && "peer-read-only:bg-background-action-secondary-disabled peer-read-only:border-border-primary-normal peer-checked:border-0"
49
- );
50
- return /* @__PURE__ */ jsxs(
51
- "label",
52
- {
53
- htmlFor: radioId,
54
- className: clsx(
55
- "flex items-center",
56
- componentGap,
57
- disabled ? "cursor-default" : "cursor-pointer",
58
- className
59
- ),
60
- children: [
61
- /* @__PURE__ */ jsxs("div", { className: "relative", children: [
62
- /* @__PURE__ */ jsx(
63
- "input",
64
- __spreadValues({
65
- id: radioId,
66
- "data-testid": testid,
67
- type: "radio",
68
- className: "sr-only peer",
69
- disabled,
70
- checked,
71
- readOnly
72
- }, props)
73
- ),
74
- /* @__PURE__ */ jsx(
75
- "div",
76
- {
77
- className: clsx(
78
- "size-6 rounded-full border flex items-center justify-center",
79
- baseTransition,
80
- defaultClassName,
81
- errorClassName,
82
- disabledClassName,
83
- readonlyClassName
84
- ),
85
- children: checked && /* @__PURE__ */ jsx(
86
- RadioIcon,
87
- {
88
- className: clsx(
89
- "transition-colors",
90
- !error && !disabled && "text-icon-on-action-secondary-normal hover:text-icon-on-action-secondary-hover active:text-icon-on-action-secondary-active peer-hover:text-icon-on-action-secondary-hover peer-focus:text-icon-on-action-secondary-hover peer-active:text-icon-on-action-secondary-active",
91
- error && !disabled && "text-icon-action-critical-secondary-normal hover:text-icon-action-critical-secondary-hover active:text-icon-action-critical-secondary-active peer-hover:text-icon-action-critical-secondary-hover peer-focus:text-icon-action-critical-secondary-hover peer-active:text-icon-action-critical-secondary-active",
92
- disabled && "text-icon-on-action-secondary-disabled",
93
- readOnly && "text-icon-on-action-secondary-disabled"
94
- )
95
- }
96
- )
97
- }
98
- )
99
- ] }),
100
- label && /* @__PURE__ */ jsx(Paragraph, { id: radioId ? `${radioId}-label` : void 0, testid: testid ? `${testid}-label` : void 0, padded: true, color: paragraphColor, children: label })
101
- ]
102
- }
103
- );
104
- };
105
- Radio.displayName = "Radio";
106
- var RadioIcon = ({ className }) => {
107
- return /* @__PURE__ */ jsxs(
108
- "svg",
109
- {
110
- className,
111
- xmlns: "http://www.w3.org/2000/svg",
112
- width: "24",
113
- height: "24",
114
- viewBox: "0 0 24 24",
115
- fill: "none",
116
- children: [
117
- /* @__PURE__ */ jsx(
118
- "rect",
119
- {
120
- x: "1",
121
- y: "1",
122
- width: "22",
123
- height: "22",
124
- rx: "11",
125
- stroke: "currentColor",
126
- strokeWidth: "2"
127
- }
128
- ),
129
- /* @__PURE__ */ jsx("rect", { x: "4", y: "4", width: "16", height: "16", rx: "8", fill: "currentColor" })
130
- ]
131
- }
132
- );
133
- };
134
- RadioIcon.displayName = "RadioIcon";
135
-
136
- export {
137
- Radio
138
- };
@@ -1,11 +0,0 @@
1
- // src/components/HorizontalDivider.tsx
2
- import clsx from "clsx";
3
- import { jsx } from "react/jsx-runtime";
4
- function HorizontalDivider({ id, testid, hideOnMobile }) {
5
- const hideOnMobileStyle = clsx(hideOnMobile && "hidden desktop:block");
6
- return /* @__PURE__ */ jsx("hr", { id, "data-testid": testid, className: clsx("w-full border-t border-border-primary-normal", hideOnMobileStyle) });
7
- }
8
-
9
- export {
10
- HorizontalDivider
11
- };
@@ -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,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
- };
@@ -1,112 +0,0 @@
1
- import {
2
- SelectPaymentMethod
3
- } from "./chunk-NT2ZKA4W.js";
4
- import {
5
- Modal
6
- } from "./chunk-FCREADUH.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
- };