@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,2381 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __defProps = Object.defineProperties;
5
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
7
- var __getOwnPropNames = Object.getOwnPropertyNames;
8
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
9
- var __getProtoOf = Object.getPrototypeOf;
10
- var __hasOwnProp = Object.prototype.hasOwnProperty;
11
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
12
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
13
- var __spreadValues = (a, b) => {
14
- for (var prop in b || (b = {}))
15
- if (__hasOwnProp.call(b, prop))
16
- __defNormalProp(a, prop, b[prop]);
17
- if (__getOwnPropSymbols)
18
- for (var prop of __getOwnPropSymbols(b)) {
19
- if (__propIsEnum.call(b, prop))
20
- __defNormalProp(a, prop, b[prop]);
21
- }
22
- return a;
23
- };
24
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
25
- var __objRest = (source, exclude) => {
26
- var target = {};
27
- for (var prop in source)
28
- if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
29
- target[prop] = source[prop];
30
- if (source != null && __getOwnPropSymbols)
31
- for (var prop of __getOwnPropSymbols(source)) {
32
- if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
33
- target[prop] = source[prop];
34
- }
35
- return target;
36
- };
37
- var __export = (target, all) => {
38
- for (var name in all)
39
- __defProp(target, name, { get: all[name], enumerable: true });
40
- };
41
- var __copyProps = (to, from, except, desc) => {
42
- if (from && typeof from === "object" || typeof from === "function") {
43
- for (let key of __getOwnPropNames(from))
44
- if (!__hasOwnProp.call(to, key) && key !== except)
45
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
46
- }
47
- return to;
48
- };
49
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
50
- // If the importer is in node compatibility mode or this is not an ESM
51
- // file that has been converted to a CommonJS file using a Babel-
52
- // compatible transform (i.e. "__esModule" has not been set), then set
53
- // "default" to the CommonJS "module.exports" for node compatibility.
54
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
55
- mod
56
- ));
57
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
58
-
59
- // src/components/PaymentOnAccountModal.tsx
60
- var PaymentOnAccountModal_exports = {};
61
- __export(PaymentOnAccountModal_exports, {
62
- PaymentOnAccountModal: () => PaymentOnAccountModal,
63
- calculateSurcharge: () => calculateSurcharge
64
- });
65
- module.exports = __toCommonJS(PaymentOnAccountModal_exports);
66
-
67
- // src/components/Modal.tsx
68
- var import_clsx9 = __toESM(require("clsx"), 1);
69
- var import_react5 = require("react");
70
-
71
- // src/components/Heading.tsx
72
- var import_clsx2 = __toESM(require("clsx"), 1);
73
-
74
- // src/classNames.ts
75
- var import_clsx = __toESM(require("clsx"), 1);
76
- var typography = {
77
- display1: (0, import_clsx.default)(
78
- "font-sans font-semibold",
79
- "text-display-1-mobile desktop:text-display-1-desktop compact:text-display-1-desktop-compact",
80
- "leading-display-1-mobile desktop:leading-display-1-desktop"
81
- ),
82
- display2: (0, import_clsx.default)(
83
- "font-sans font-bold",
84
- "text-display-2-mobile desktop:text-display-2-desktop compact:text-display-2-desktop-compact",
85
- "leading-display-2-mobile desktop:leading-display-2-desktop"
86
- ),
87
- heading1: (0, import_clsx.default)(
88
- "font-sans font-semibold",
89
- "text-heading-1-mobile desktop:text-heading-1-desktop compact:text-heading-1-desktop-compact",
90
- "leading-heading-1-mobile desktop:leading-heading-1-desktop"
91
- ),
92
- heading2: (0, import_clsx.default)(
93
- "font-sans font-normal",
94
- "text-heading-2-mobile desktop:text-heading-2-desktop compact:text-heading-2-desktop-compact",
95
- "leading-heading-2-mobile desktop:leading-heading-2-desktop"
96
- ),
97
- heading3: (0, import_clsx.default)(
98
- "font-sans font-semibold",
99
- "text-heading-3-mobile desktop:text-heading-3-desktop compact:text-heading-3-desktop-compact",
100
- "leading-heading-3-mobile desktop:leading-heading-3-desktop"
101
- ),
102
- subheader: (0, import_clsx.default)(
103
- "font-sans font-semibold",
104
- "text-subheader-mobile desktop:text-subheader-desktop compact:text-subheader-desktop-compact",
105
- "leading-subheader-mobile desktop:leading-subheader-desktop"
106
- ),
107
- link: (0, import_clsx.default)(
108
- "font-sans font-normal",
109
- "text-link-mobile desktop:text-link-desktop compact:text-link-desktop-compact",
110
- "leading-link-mobile desktop:leading-link-desktop"
111
- ),
112
- buttonLabel: (0, import_clsx.default)(
113
- "font-sans font-semibold",
114
- "text-label-mobile desktop:text-label-desktop compact:text-label-desktop-compact",
115
- "leading-label-mobile desktop:leading-label-desktop"
116
- ),
117
- label: (0, import_clsx.default)(
118
- "font-sans font-semibold",
119
- "text-label-mobile desktop:text-label-desktop compact:text-label-desktop-compact",
120
- "leading-label-mobile desktop:leading-label-desktop"
121
- ),
122
- paragraph: (0, import_clsx.default)(
123
- "font-sans font-normal",
124
- "text-paragraph-mobile desktop:text-paragraph-desktop compact:text-paragraph-desktop-compact",
125
- "leading-paragraph-mobile desktop:leading-paragraph-desktop"
126
- ),
127
- caption: (0, import_clsx.default)(
128
- "font-sans font-normal",
129
- "text-caption-mobile desktop:text-caption-desktop compact:text-caption-desktop-compact",
130
- "leading-caption-mobile desktop:leading-caption-desktop"
131
- )
132
- };
133
- var baseTransition = (0, import_clsx.default)(
134
- "transition-colors duration-100 ease-in-out"
135
- );
136
- var componentGap = (0, import_clsx.default)(
137
- "gap-mobile-component-gap desktop:gap-desktop-component-gap compact:gap-desktop-compact-component-gap"
138
- );
139
- var paddingUsingComponentGap = (0, import_clsx.default)(
140
- "p-mobile-component-gap desktop:p-desktop-component-gap compact:p-desktop-compact-component-gap"
141
- );
142
- var paddingXUsingLayoutGroupGap = (0, import_clsx.default)(
143
- "px-mobile-layout-group-gap desktop:px-desktop-layout-group-gap compact:px-desktop-compact-layout-group-gap"
144
- );
145
- var paddingYUsingLayoutGroupGap = (0, import_clsx.default)(
146
- "py-mobile-layout-group-gap desktop:py-desktop-layout-group-gap compact:py-desktop-compact-layout-group-gap"
147
- );
148
- var componentPadding = (0, import_clsx.default)(
149
- "p-mobile-component-padding desktop:p-desktop-component-padding compact:p-desktop-compact-component-padding"
150
- );
151
- var componentPaddingBottom = (0, import_clsx.default)(
152
- "pb-mobile-component-padding desktop:pb-desktop-component-padding compact:pb-desktop-compact-component-padding"
153
- );
154
- var componentPaddingX = (0, import_clsx.default)(
155
- "px-mobile-component-padding desktop:px-desktop-component-padding compact:px-desktop-compact-component-padding"
156
- );
157
- var componentPaddingY = (0, import_clsx.default)(
158
- "py-mobile-component-padding desktop:py-desktop-component-padding compact:py-desktop-compact-component-padding"
159
- );
160
- var componentPaddingXUsingComponentGap = (0, import_clsx.default)(
161
- "px-mobile-component-gap desktop:px-desktop-component-gap compact:px-desktop-compact-component-gap"
162
- );
163
- var componentPaddingYUsingComponentGap = (0, import_clsx.default)(
164
- "py-mobile-component-gap desktop:py-desktop-component-gap compact:py-desktop-compact-component-gap"
165
- );
166
- var componentPaddingMinusBorder = (0, import_clsx.default)(
167
- "p-[calc(var(--spacing-mobile-component-padding)_-_1px)] desktop:p-[calc(var(--spacing-desktop-component-padding)_-_1px)] compact:p-[calc(var(--spacing-desktop-compact-component-padding)_-_1px)]"
168
- );
169
- var componentPaddingMinus2pxBorder = (0, import_clsx.default)(
170
- "p-[calc(var(--spacing-mobile-component-padding)_-_2px)] desktop:p-[calc(var(--spacing-desktop-component-padding)_-_2px)] compact:p-[calc(var(--spacing-desktop-compact-component-padding)_-_2px)]"
171
- );
172
- var layoutPaddding = (0, import_clsx.default)(
173
- "p-mobile-layout-padding desktop:p-desktop-layout-padding compact:p-desktop-compact-layout-padding"
174
- );
175
- var layoutPaddingBottom = (0, import_clsx.default)(
176
- "pb-mobile-layout-padding desktop:pb-desktop-layout-padding compact:pb-desktop-compact-layout-padding"
177
- );
178
- var layoutPaddingY = (0, import_clsx.default)(
179
- "py-mobile-layout-padding desktop:py-desktop-layout-padding compact:py-desktop-compact-layout-padding"
180
- );
181
- var containerPaddingX = (0, import_clsx.default)(
182
- "px-mobile-container-padding desktop:px-desktop-container-padding compact:px-desktop-compact-container-padding"
183
- );
184
- var containerPaddingY = (0, import_clsx.default)(
185
- "py-mobile-container-padding desktop:py-desktop-container-padding compact:py-desktop-compact-container-padding"
186
- );
187
- var layoutGroupGapPaddingY = (0, import_clsx.default)(
188
- "py-mobile-layout-group-gap desktop:py-desktop-layout-group-gap compact:py-desktop-compact-layout-group-gap"
189
- );
190
- var layoutGroupGap = (0, import_clsx.default)(
191
- "gap-mobile-layout-group-gap desktop:gap-desktop-layout-group-gap compact:gap-desktop-compact-layout-group-gap"
192
- );
193
- var layoutGap = (0, import_clsx.default)(
194
- "gap-mobile-layout-gap desktop:gap-desktop-layout-gap compact:gap-desktop-compact-layout-gap"
195
- );
196
- var gapUsingContainerPadding = (0, import_clsx.default)(
197
- "gap-mobile-container-padding desktop:gap-desktop-container-padding compact:gap-desktop-compact-container-padding"
198
- );
199
-
200
- // src/components/Heading.tsx
201
- var import_jsx_runtime = require("react/jsx-runtime");
202
- var Heading = (_a) => {
203
- var _b = _a, {
204
- className,
205
- children,
206
- as,
207
- color,
208
- align,
209
- variant = "heading1",
210
- id,
211
- testid
212
- } = _b, props = __objRest(_b, [
213
- "className",
214
- "children",
215
- "as",
216
- "color",
217
- "align",
218
- "variant",
219
- "id",
220
- "testid"
221
- ]);
222
- const defaultElement = variant === "heading1" ? "h1" : variant === "heading2" ? "h2" : "h3";
223
- const Element = as != null ? as : defaultElement;
224
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
225
- Element,
226
- __spreadProps(__spreadValues({
227
- id,
228
- "data-testid": testid,
229
- className: (0, import_clsx2.default)(
230
- typography[variant],
231
- className,
232
- align === "left" && "text-left",
233
- align === "center" && "text-center",
234
- align === "right" && "text-right"
235
- ),
236
- style: __spreadProps(__spreadValues({}, props.style), {
237
- color: color ? `var(--color-${color})` : void 0
238
- })
239
- }, props), {
240
- children
241
- })
242
- );
243
- };
244
- Heading.displayName = "Heading";
245
- var Heading1 = (props) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Heading, __spreadProps(__spreadValues({}, props), { variant: "heading1" }));
246
- var Heading2 = (props) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Heading, __spreadProps(__spreadValues({}, props), { variant: "heading2" }));
247
- var Heading3 = (props) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Heading, __spreadProps(__spreadValues({}, props), { variant: "heading3" }));
248
- Heading1.displayName = "Heading1";
249
- Heading2.displayName = "Heading2";
250
- Heading3.displayName = "Heading3";
251
-
252
- // src/components/Button.tsx
253
- var import_clsx3 = __toESM(require("clsx"), 1);
254
- var import_jsx_runtime2 = require("react/jsx-runtime");
255
- var Button = (_a) => {
256
- var _b = _a, {
257
- variant = "primary",
258
- as = "button",
259
- block,
260
- leftIcon,
261
- rightIcon,
262
- className,
263
- classNameLabel,
264
- disabled = false,
265
- children,
266
- iconOnly = false,
267
- colorClassName,
268
- href,
269
- id,
270
- testid
271
- } = _b, props = __objRest(_b, [
272
- "variant",
273
- "as",
274
- "block",
275
- "leftIcon",
276
- "rightIcon",
277
- "className",
278
- "classNameLabel",
279
- "disabled",
280
- "children",
281
- "iconOnly",
282
- "colorClassName",
283
- "href",
284
- "id",
285
- "testid"
286
- ]);
287
- const primaryVariantStyles = variant === "primary" && (0, import_clsx3.default)(
288
- (colorClassName == null ? void 0 : colorClassName.trim()) ? colorClassName : "text-text-on-action-primary-normal",
289
- "bg-background-action-primary-normal border-background-action-primary-normal",
290
- "hover:bg-background-action-primary-hover hover:border-background-action-primary-hover",
291
- "focus:bg-background-action-primary-hover focus:border-background-action-primary-hover focus:outline-0",
292
- "active:bg-background-action-primary-active active:border-background-action-primary-active",
293
- "disabled:bg-background-action-primary-disabled disabled:border-background-action-primary-disabled disabled:text-text-on-action-primary-disabled"
294
- );
295
- const secondaryVariantStyles = variant === "secondary" && (0, import_clsx3.default)(
296
- (colorClassName == null ? void 0 : colorClassName.trim()) ? colorClassName : "text-text-action-primary-normal",
297
- "bg-background-action-secondary-normal border-border-action-normal",
298
- "hover:bg-background-action-secondary-hover hover:border-border-action-hover hover:text-text-action-primary-hover",
299
- "focus:bg-background-action-secondary-hover focus:border-border-action-hover focus:text-text-action-primary-hover focus:outline-0",
300
- "active:bg-background-action-secondary-active active:border-border-action-active active:text-text-action-primary-active",
301
- "disabled:bg-background-action-primary-disabled disabled:border-border-action-disabled disabled:text-text-action-primary-disabled"
302
- );
303
- const tertiaryVariantStyles = variant === "tertiary" && (0, import_clsx3.default)(
304
- "bg-transparent border-transparent",
305
- iconOnly ? (colorClassName == null ? void 0 : colorClassName.trim()) ? colorClassName : "text-icon-action-primary-normal" : (colorClassName == null ? void 0 : colorClassName.trim()) ? colorClassName : "text-text-action-primary-normal",
306
- "bg-transparent border-transparent",
307
- "hover:bg-background-action-secondary-hover hover:border-background-action-secondary-hover hover:text-text-action-primary-hover",
308
- "focus:bg-background-action-secondary-hover focus:border-background-action-secondary-hover focus:text-text-action-primary-hover focus:outline-0",
309
- "active:bg-background-action-secondary-active active:border-transparent active:text-text-action-primary-active",
310
- "disabled:bg-transparent disabled:border-transparent disabled:text-text-action-primary-disabled"
311
- );
312
- const primaryCriticalVariantStyles = variant === "primary-critical" && (0, import_clsx3.default)(
313
- (colorClassName == null ? void 0 : colorClassName.trim()) ? colorClassName : "text-text-on-action-primary-normal",
314
- "bg-background-action-critical-primary-normal border-background-action-critical-primary-normal",
315
- "hover:bg-background-action-critical-primary-hover hover:border-background-action-critical-primary-hover",
316
- "focus:bg-background-action-critical-primary-hover focus:border-background-action-critical-primary-hover focus:outline-0",
317
- "active:bg-background-action-critical-primary-active active:border-background-action-critical-primary-active",
318
- "disabled:bg-background-action-critical-primary-disabled disabled:border-background-action-critical-primary-disabled disabled:text-text-on-action-primary-disabled"
319
- );
320
- const secondaryCriticalVariantStyles = variant === "secondary-critical" && (0, import_clsx3.default)(
321
- (colorClassName == null ? void 0 : colorClassName.trim()) ? colorClassName : "text-text-action-critical-normal",
322
- "bg-background-action-critical-secondary-normal border-border-action-critical-normal",
323
- "hover:bg-background-action-critical-secondary-hover hover:border-border-action-critical-hover hover:text-text-action-critical-hover",
324
- "focus:bg-background-action-critical-secondary-hover focus:border-border-action-critical-hover focus:text-text-action-critical-hover focus:outline-0",
325
- "active:bg-background-action-critical-secondary-active active:border-border-action-critical-active active:text-text-action-critical-active",
326
- "disabled:bg-background-action-critical-disabled disabled:border-border-action-critical-disabled disabled:text-text-action-critical-disabled"
327
- );
328
- const tertiaryCriticalVariantStyles = variant === "tertiary-critical" && (0, import_clsx3.default)(
329
- (colorClassName == null ? void 0 : colorClassName.trim()) ? colorClassName : "text-text-action-critical-normal",
330
- "bg-transparent border-transparent text-text-action-critical-normal",
331
- "hover:bg-background-action-critical-secondary-hover hover:border-background-action-critical-secondary-hover hover:text-text-action-critical-hover",
332
- "focus:bg-background-action-critical-secondary-hover focus:border-background-action-critical-secondary-hover focus:text-text-action-critical-hover focus:outline-0",
333
- "active:bg-background-action-critical-secondary-active active:border-background-action-critical-secondary-active active:text-text-action-critical-active",
334
- "disabled:bg-transparent disabled:border-transparent disabled:text-text-action-critical-disabled"
335
- );
336
- const navigationVarianStyles = variant === "navigation" && (0, import_clsx3.default)(
337
- (colorClassName == null ? void 0 : colorClassName.trim()) ? colorClassName : "text-text-action-primary-normal",
338
- "bg-transparent",
339
- "hover:bg-background-action-secondary-hover hover:text-text-action-primary-hover",
340
- "focus:bg-background-action-secondary-hover focus:text-text-action-primary-hover focus:outline-0",
341
- "active:bg-background-action-secondary-active active:text-text-action-primary-active",
342
- "disabled:bg-transparent disabled:text-text-on-action-primary-disabled",
343
- "flex-col",
344
- paddingUsingComponentGap
345
- );
346
- const notNavigationVariantStyles = variant !== "navigation" && (0, import_clsx3.default)("border-2 flex-row", componentPaddingMinus2pxBorder, componentGap);
347
- const buttonClasses = (0, import_clsx3.default)(
348
- disabled ? "cursor-default" : "cursor-pointer",
349
- block ? "w-full" : "w-fit",
350
- baseTransition,
351
- "rounded-sm whitespace-nowrap inline-flex items-center justify-center group/btn",
352
- primaryVariantStyles,
353
- secondaryVariantStyles,
354
- tertiaryVariantStyles,
355
- primaryCriticalVariantStyles,
356
- secondaryCriticalVariantStyles,
357
- tertiaryCriticalVariantStyles,
358
- navigationVarianStyles,
359
- notNavigationVariantStyles,
360
- className
361
- );
362
- const labelClasses = (0, import_clsx3.default)(
363
- "min-h-6 flex items-center justify-center",
364
- classNameLabel,
365
- componentPaddingXUsingComponentGap,
366
- typography.buttonLabel
367
- );
368
- const Element = href && !as ? "a" : as;
369
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
370
- Element,
371
- __spreadProps(__spreadValues({
372
- id,
373
- "data-testid": testid,
374
- type: Element === "button" ? "button" : void 0,
375
- className: buttonClasses
376
- }, props), {
377
- onClick: props.onClick,
378
- disabled,
379
- href,
380
- "data-theme": variant === "navigation" ? "brand" : void 0,
381
- children: [
382
- leftIcon && leftIcon,
383
- !iconOnly && children && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { id: id ? `${id}-label` : void 0, "data-testid": testid ? `${testid}-label` : void 0, className: labelClasses, children }),
384
- rightIcon && rightIcon
385
- ]
386
- })
387
- );
388
- };
389
- Button.displayName = "Button";
390
-
391
- // src/components/Icon.tsx
392
- var import_clsx4 = __toESM(require("clsx"), 1);
393
- var import_jsx_runtime3 = require("react/jsx-runtime");
394
- function Icon(_a) {
395
- var _b = _a, {
396
- name,
397
- size = 24,
398
- variant = "outline",
399
- testid
400
- } = _b, props = __objRest(_b, [
401
- "name",
402
- "size",
403
- "variant",
404
- "testid"
405
- ]);
406
- const variantStyle = variant === "filled" ? '"FILL" 1' : '"FILL" 0';
407
- const weightStyle = size === 16 ? '"wght" 400' : '"wght" 300';
408
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
409
- "span",
410
- __spreadProps(__spreadValues({}, props), {
411
- "data-testid": testid,
412
- className: (0, import_clsx4.default)(
413
- "icon",
414
- `icon-${size}`,
415
- // size === 16 ? "font-normal" : "font-light", // size 16 font weight is not working as normal from before
416
- props.className
417
- ),
418
- style: __spreadValues({
419
- fontVariationSettings: variantStyle + `, ${weightStyle}`
420
- }, props.style),
421
- children: name
422
- })
423
- );
424
- }
425
-
426
- // src/components/ModalHeader.tsx
427
- var import_clsx5 = __toESM(require("clsx"), 1);
428
- var import_jsx_runtime4 = require("react/jsx-runtime");
429
- var ModalHeader = ({
430
- title,
431
- hideCloseIcon,
432
- headerIcon,
433
- onClose,
434
- id,
435
- testid
436
- }) => {
437
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
438
- "div",
439
- {
440
- id,
441
- "data-testid": testid,
442
- className: (0, import_clsx5.default)(
443
- "flex justify-between items-center",
444
- layoutPaddding,
445
- layoutGroupGap
446
- ),
447
- children: [
448
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: (0, import_clsx5.default)("flex items-center", layoutGroupGap), children: [
449
- headerIcon,
450
- title && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Heading2, { id: id ? `${id}-title` : void 0, testid: testid ? `${testid}-title` : void 0, as: "p", children: title })
451
- ] }),
452
- !hideCloseIcon && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
453
- Button,
454
- {
455
- id: id ? `${id}-close-button` : void 0,
456
- testid: testid ? `${testid}-close-button` : void 0,
457
- iconOnly: true,
458
- variant: "tertiary",
459
- onClick: onClose,
460
- leftIcon: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "text-icon-primary-normal contents", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Icon, { name: "close", size: 24 }) })
461
- }
462
- )
463
- ]
464
- }
465
- );
466
- };
467
- ModalHeader.displayName = "ModalHeader";
468
-
469
- // src/components/ModalContent.tsx
470
- var import_clsx6 = __toESM(require("clsx"), 1);
471
- var import_jsx_runtime5 = require("react/jsx-runtime");
472
- function ModalContent({
473
- fixedHeightScrolling,
474
- children,
475
- id,
476
- testid
477
- }) {
478
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
479
- "div",
480
- {
481
- id,
482
- "data-testid": testid,
483
- className: (0, import_clsx6.default)(
484
- "flex-grow desktop:flex-grow-0",
485
- layoutPaddding,
486
- fixedHeightScrolling && "overflow-auto"
487
- ),
488
- children
489
- }
490
- );
491
- }
492
- ModalContent.displayName = "ModalContent";
493
-
494
- // src/components/ModalButtons.tsx
495
- var import_clsx7 = __toESM(require("clsx"), 1);
496
- var import_jsx_runtime6 = require("react/jsx-runtime");
497
- var ModalButtons = ({
498
- onClose,
499
- onContinue,
500
- customActions,
501
- id,
502
- testid
503
- }) => {
504
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
505
- "div",
506
- {
507
- id,
508
- "data-testid": testid,
509
- className: (0, import_clsx7.default)(
510
- "border-t border-neutral-300 flex justify-end",
511
- layoutPaddding,
512
- layoutGroupGap
513
- ),
514
- children: customActions != null ? customActions : /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
515
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
516
- Button,
517
- {
518
- id: id ? `${id}-close-button` : void 0,
519
- testid: testid ? `${testid}-close-button` : void 0,
520
- variant: "secondary",
521
- leftIcon: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Icon, { name: "close", size: 24 }),
522
- onClick: onClose,
523
- className: "max-sm:w-full",
524
- children: "Close"
525
- }
526
- ),
527
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
528
- Button,
529
- {
530
- id: id ? `${id}-continue-button` : void 0,
531
- testid: testid ? `${testid}-continue-button` : void 0,
532
- variant: "primary",
533
- leftIcon: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Icon, { name: "check", size: 24 }),
534
- className: "max-sm:w-full",
535
- onClick: onContinue,
536
- children: "Continue"
537
- }
538
- )
539
- ] })
540
- }
541
- );
542
- };
543
- ModalButtons.displayName = "ModalButtons";
544
-
545
- // src/components/ModalScrim.tsx
546
- var import_clsx8 = __toESM(require("clsx"), 1);
547
- var import_jsx_runtime7 = require("react/jsx-runtime");
548
- var ModalScrim = ({
549
- show = false,
550
- size = "small",
551
- children,
552
- onClick,
553
- ref,
554
- id,
555
- testid
556
- }) => {
557
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
558
- "div",
559
- {
560
- id,
561
- "data-testid": testid,
562
- className: (0, import_clsx8.default)(
563
- "overflow-y-auto h-screen transition-[visibility,opacity,background] ease-in-out duration-100 grid place-content-center desktop:p-4 group bg-neutral-600/50 fixed opacity-0",
564
- !show && " pointer-events-none",
565
- size === "small" && "p-4",
566
- "inset-0 z-50"
567
- ),
568
- onMouseDown: onClick,
569
- ref,
570
- children
571
- }
572
- );
573
- };
574
- ModalScrim.displayName = "ModalScrim";
575
-
576
- // src/components/Modal.tsx
577
- var import_react_dom = require("react-dom");
578
-
579
- // src/utils.ts
580
- function findDocumentRoot(element) {
581
- if (typeof window === "undefined" || typeof document === "undefined") {
582
- throw new Error(
583
- "findDocumentRoot can only be used in a browser environment."
584
- );
585
- }
586
- if (!element || !(element instanceof Node)) {
587
- return window.document.body;
588
- }
589
- var currentElement = element;
590
- while (currentElement && currentElement.parentNode) {
591
- if (currentElement.parentNode === document) {
592
- return document.body;
593
- } else if (currentElement.parentNode instanceof DocumentFragment) {
594
- return currentElement.parentNode;
595
- } else {
596
- currentElement = currentElement.parentNode;
597
- }
598
- }
599
- return window.document.body;
600
- }
601
-
602
- // src/components/Modal.tsx
603
- var import_react_use = require("react-use");
604
-
605
- // src/hooks/useKeydown.ts
606
- var import_react = require("react");
607
-
608
- // src/hooks/useInfiniteScroll.tsx
609
- var import_react2 = require("react");
610
-
611
- // src/hooks/useMatchesMedia.ts
612
- var import_react3 = require("react");
613
- var useMatchesMedia = (query) => {
614
- const [matches, setMatches] = (0, import_react3.useState)();
615
- (0, import_react3.useLayoutEffect)(() => {
616
- const mediaQueryList = window.matchMedia(query);
617
- const listener = () => setMatches(mediaQueryList.matches);
618
- listener();
619
- mediaQueryList.addEventListener("change", listener);
620
- return () => mediaQueryList.removeEventListener("change", listener);
621
- }, [query]);
622
- return matches;
623
- };
624
- var useMatchesMobile = () => useMatchesMedia("(width < 48rem)");
625
-
626
- // src/components/useMounted.tsx
627
- var import_react4 = require("react");
628
- var useMounted = () => {
629
- const [isMounted, setIsMounted] = (0, import_react4.useState)(false);
630
- (0, import_react4.useEffect)(() => {
631
- setIsMounted(true);
632
- return () => setIsMounted(false);
633
- }, []);
634
- return isMounted;
635
- };
636
-
637
- // src/components/Modal.tsx
638
- var import_jsx_runtime8 = require("react/jsx-runtime");
639
- var fadeInScale = (element, duration = 300) => element.animate(
640
- [
641
- { opacity: 0, transform: "scale(0.95)" },
642
- { opacity: 1, transform: "scale(1)" }
643
- ],
644
- {
645
- duration,
646
- easing: "cubic-bezier(0.4, 0, 0.2, 1)",
647
- fill: "both"
648
- }
649
- );
650
- var fadeOutScale = (element, duration = 200) => element.animate(
651
- [
652
- { opacity: 1, transform: "scale(1)" },
653
- { opacity: 0, transform: "scale(0.95)" }
654
- ],
655
- {
656
- duration,
657
- easing: "ease-in-out",
658
- fill: "both"
659
- }
660
- );
661
- var bgFadeIn = (element, duration = 300) => element.animate([{ opacity: 0 }, { opacity: 1 }], {
662
- duration,
663
- easing: "cubic-bezier(0.4, 0, 0.2, 1)",
664
- fill: "both"
665
- });
666
- var bgFadeOut = (element, duration = 200) => element.animate([{ opacity: 1 }, { opacity: 0 }], {
667
- duration,
668
- easing: "ease-in-out",
669
- fill: "both"
670
- });
671
- var whenAllAnimationsFinish = (animations, callback) => {
672
- let finishedCount = 0;
673
- animations.forEach((animation) => {
674
- animation.onfinish = () => {
675
- finishedCount += 1;
676
- if (finishedCount === animations.length) {
677
- callback();
678
- }
679
- };
680
- });
681
- };
682
- var sizes = {
683
- small: {
684
- sizeClass: "max-h-screen desktop:max-w-120 rounded-sm"
685
- },
686
- medium: {
687
- sizeClass: "desktop:max-w-180 w-screen desktop:h-fit h-screen desktop:w-full max-w-240"
688
- },
689
- large: {
690
- sizeClass: "desktop:max-w-240 w-screen desktop:h-fit h-screen desktop:w-full max-w-240"
691
- },
692
- "x-large": {
693
- sizeClass: "desktop:max-w-300 w-screen desktop:h-fit h-screen desktop:w-full max-w-240"
694
- }
695
- };
696
- var Modal = ({
697
- id,
698
- testid,
699
- title,
700
- open = false,
701
- size = "small",
702
- className,
703
- children,
704
- onClose,
705
- onContinue,
706
- closeOnBackdropClick = true,
707
- showButtons = false,
708
- hideCloseIcon = false,
709
- headerIcon,
710
- fixedHeightScrolling = false,
711
- customActions
712
- }) => {
713
- var _a;
714
- const mounted = useMounted();
715
- const modalRef = (0, import_react5.useRef)(null);
716
- const bgRef = (0, import_react5.useRef)(null);
717
- const wasOpen = (0, import_react_use.usePrevious)(open);
718
- const isMobile = useMatchesMobile();
719
- const computedFixedHeightScrolling = isMobile || fixedHeightScrolling;
720
- (0, import_react5.useEffect)(() => {
721
- if (!mounted) return;
722
- if (!modalRef.current || !bgRef.current) {
723
- console.error("Modal or background reference is not set.");
724
- return;
725
- }
726
- if (wasOpen === void 0) return;
727
- if (wasOpen && !open) {
728
- const modalAnimation = fadeOutScale(modalRef.current);
729
- const bgAnimation = bgFadeOut(bgRef.current);
730
- whenAllAnimationsFinish([modalAnimation, bgAnimation], () => {
731
- if (onClose) {
732
- onClose();
733
- }
734
- });
735
- } else if (!wasOpen && open) {
736
- fadeInScale(modalRef.current);
737
- bgFadeIn(bgRef.current);
738
- }
739
- }, [mounted, open]);
740
- const handleKeyDown = (0, import_react5.useCallback)(
741
- (e) => {
742
- if (e.key === "Escape") {
743
- if (onClose) {
744
- e.preventDefault();
745
- onClose();
746
- }
747
- }
748
- },
749
- [onClose, bgRef, modalRef]
750
- );
751
- const handleClose = (0, import_react5.useCallback)(() => {
752
- if (onClose) {
753
- onClose();
754
- }
755
- }, [onClose]);
756
- (0, import_react5.useEffect)(() => {
757
- if (open) {
758
- document.addEventListener("keyup", handleKeyDown);
759
- }
760
- return () => {
761
- document.removeEventListener("keyup", handleKeyDown);
762
- };
763
- }, [open, handleKeyDown]);
764
- (0, import_react5.useEffect)(() => {
765
- if (!open) return;
766
- const scrollY = window.scrollY;
767
- const body = document.body;
768
- body.style.position = "fixed";
769
- body.style.top = `-${scrollY}px`;
770
- body.style.left = "0";
771
- body.style.right = "0";
772
- body.style.overflow = "hidden";
773
- body.style.width = "100%";
774
- return () => {
775
- body.style.position = "";
776
- body.style.top = "";
777
- body.style.left = "";
778
- body.style.right = "";
779
- body.style.overflow = "";
780
- body.style.width = "";
781
- window.scrollTo(0, scrollY);
782
- };
783
- }, [open]);
784
- const { sizeClass } = (_a = sizes[size]) != null ? _a : sizes.small;
785
- const backgroundClickHandler = (0, import_react5.useCallback)(
786
- (e) => {
787
- const target = e.target;
788
- const currentTarget = e.currentTarget;
789
- if (currentTarget.contains(target) && currentTarget !== target) {
790
- e.stopPropagation();
791
- return;
792
- }
793
- if (open && closeOnBackdropClick) {
794
- handleClose();
795
- }
796
- },
797
- [open, closeOnBackdropClick, handleClose]
798
- );
799
- if (!mounted) {
800
- return null;
801
- }
802
- return (0, import_react_dom.createPortal)(
803
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
804
- ModalScrim,
805
- {
806
- id: id ? `${id}-scrim` : void 0,
807
- testid: testid ? `${testid}-scrim` : void 0,
808
- size,
809
- ref: bgRef,
810
- show: open,
811
- onClick: backgroundClickHandler,
812
- children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
813
- "div",
814
- {
815
- id,
816
- "data-testid": testid,
817
- ref: modalRef,
818
- className: (0, import_clsx9.default)(
819
- "bg-white shadow-md rounded-sm flex flex-col overflow-hidden w-full opacity-0 h-fit",
820
- computedFixedHeightScrolling && "desktop:max-h-[calc(100vh-32px)] desktop:h-auto",
821
- className,
822
- sizeClass
823
- ),
824
- onClick: (e) => e.stopPropagation(),
825
- children: [
826
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
827
- ModalHeader,
828
- {
829
- id: id ? `${id}-header` : void 0,
830
- testid: testid ? `${testid}-header` : void 0,
831
- title,
832
- onClose: handleClose,
833
- hideCloseIcon,
834
- headerIcon
835
- }
836
- ),
837
- children && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
838
- ModalContent,
839
- {
840
- id: id ? `${id}-content` : void 0,
841
- testid: testid ? `${testid}-content` : void 0,
842
- fixedHeightScrolling: computedFixedHeightScrolling,
843
- children
844
- }
845
- ),
846
- showButtons && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
847
- ModalButtons,
848
- {
849
- id: id ? `${id}-buttons` : void 0,
850
- testid: testid ? `${testid}-buttons` : void 0,
851
- onClose: handleClose,
852
- onContinue,
853
- customActions
854
- }
855
- )
856
- ]
857
- }
858
- )
859
- }
860
- ),
861
- findDocumentRoot(bgRef.current)
862
- );
863
- };
864
- Modal.displayName = "Modal";
865
-
866
- // src/components/Stack.tsx
867
- var import_clsx10 = __toESM(require("clsx"), 1);
868
- var import_jsx_runtime9 = require("react/jsx-runtime");
869
- var getFlexClassNames = ({ items, justify, grow }) => (0, import_clsx10.default)(
870
- "flex",
871
- items === "start" && "items-start",
872
- grow && "grow",
873
- items === "start" && "items-start",
874
- items === "center" && "items-center",
875
- items === "end" && "items-end",
876
- items === "start-center" && "items-start desktop:items-center",
877
- justify === "start" && "justify-start",
878
- justify === "center" && "justify-center",
879
- justify === "end" && "justify-end",
880
- justify === "end" && "justify-end",
881
- justify === "between" && "justify-between",
882
- justify === "around" && "justify-around"
883
- );
884
- var useGapClassNames = (sizing) => {
885
- return (0, import_clsx10.default)(
886
- sizing === "layout-group" && "gap-mobile-layout-group-gap desktop:gap-desktop-layout-group-gap compact:gap-compact-layout-group-gap",
887
- sizing === "layout" && "gap-mobile-layout-gap desktop:gap-desktop-layout-gap compact:gap-compact-layout-gap",
888
- sizing === "container" && "gap-mobile-container-gap desktop:gap-desktop-container-gap compact:gap-compact-container-gap",
889
- sizing === "component" && "gap-mobile-component-gap desktop:gap-desktop-component-gap compact:gap-compact-component-gap"
890
- );
891
- };
892
- var Stack = (_a) => {
893
- var _b = _a, {
894
- children,
895
- items,
896
- justify,
897
- grow,
898
- padding,
899
- paddingX,
900
- paddingY,
901
- margin,
902
- marginX,
903
- marginY,
904
- horizontal,
905
- horizontalMobile,
906
- elevation = 0,
907
- rounded,
908
- centered,
909
- width,
910
- minHeight,
911
- maxWidth,
912
- minWidth,
913
- height,
914
- maxHeight,
915
- borderColor,
916
- backgroundColor,
917
- sizing = "none",
918
- overflowY = "inherit",
919
- overflowX = "inherit",
920
- flexShrink,
921
- flexGrow,
922
- position,
923
- top,
924
- left,
925
- id,
926
- noGap,
927
- marginTop,
928
- marginBottom,
929
- testid
930
- } = _b, props = __objRest(_b, [
931
- "children",
932
- "items",
933
- "justify",
934
- "grow",
935
- "padding",
936
- "paddingX",
937
- "paddingY",
938
- "margin",
939
- "marginX",
940
- "marginY",
941
- "horizontal",
942
- "horizontalMobile",
943
- "elevation",
944
- "rounded",
945
- "centered",
946
- "width",
947
- "minHeight",
948
- "maxWidth",
949
- "minWidth",
950
- "height",
951
- "maxHeight",
952
- "borderColor",
953
- "backgroundColor",
954
- "sizing",
955
- "overflowY",
956
- "overflowX",
957
- "flexShrink",
958
- "flexGrow",
959
- "position",
960
- "top",
961
- "left",
962
- "id",
963
- "noGap",
964
- "marginTop",
965
- "marginBottom",
966
- "testid"
967
- ]);
968
- const flexClassNames = getFlexClassNames({ items, justify, grow });
969
- const gapClassNames = useGapClassNames(sizing);
970
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
971
- "div",
972
- __spreadProps(__spreadValues({
973
- id,
974
- "data-testid": testid
975
- }, props), {
976
- style: {
977
- height: height === "full" ? "100%" : height !== void 0 ? `${height}px` : void 0,
978
- maxHeight: maxHeight !== void 0 ? `${maxHeight}px` : void 0,
979
- minHeight: minHeight !== void 0 ? `${minHeight}px` : void 0,
980
- maxWidth: maxWidth !== void 0 ? `${maxWidth}px` : void 0,
981
- width: width !== void 0 && typeof width === "number" ? `${width}px` : void 0,
982
- minWidth: minWidth !== void 0 ? `${minWidth}px` : void 0,
983
- border: borderColor ? `1px solid var(--color-${borderColor})` : void 0,
984
- backgroundColor: backgroundColor ? `var(--color-${backgroundColor})` : void 0,
985
- flexGrow: flexGrow !== void 0 ? flexGrow : void 0,
986
- flexShrink: flexShrink !== void 0 ? flexShrink : void 0,
987
- position: position !== void 0 ? position : void 0,
988
- top: top !== void 0 ? `${top}px` : void 0,
989
- left: left !== void 0 ? `${left}px` : void 0
990
- },
991
- className: (0, import_clsx10.default)(
992
- "scrollbar-thin",
993
- "max-w-screen",
994
- width !== "fit" && "w-full",
995
- width === "full" && "w-full",
996
- width === "max" && "w-max",
997
- centered && "mx-auto",
998
- overflowY == "auto" && "overflow-y-auto",
999
- overflowY == "hidden" && "overflow-y-hidden",
1000
- overflowY == "scroll" && "overflow-y-scroll",
1001
- overflowX == "auto" && "overflow-x-auto",
1002
- overflowX == "hidden" && "overflow-x-hidden",
1003
- overflowX == "scroll" && "overflow-x-scroll",
1004
- padding && sizing === "container" && "p-mobile-container-padding desktop:p-desktop-container-padding compact:p-desktop-compact-container-padding",
1005
- padding && sizing === "layout" && "p-mobile-layout-padding desktop:p-desktop-layout-padding compact:p-desktop-compact-layout-padding",
1006
- padding && sizing === "layout-group" && "p-mobile-layout-group-padding desktop:p-desktop-layout-group-padding compact:p-desktop-compact-layout-group-padding",
1007
- padding && sizing === "component" && "p-mobile-component-padding desktop:p-desktop-component-padding compact:p-desktop-compact-component-padding",
1008
- paddingX && sizing === "container" && "px-mobile-container-padding desktop:px-desktop-container-padding compact:px-desktop-compact-container-padding",
1009
- paddingX && sizing === "layout" && "px-mobile-layout-padding desktop:px-desktop-layout-padding compact:px-desktop-compact-layout-padding",
1010
- paddingX && sizing === "layout-group" && "px-mobile-layout-group-padding desktop:px-desktop-layout-group-padding compact:px-desktop-compact-layout-group-padding",
1011
- paddingX && sizing === "component" && "px-mobile-component-padding desktop:px-desktop-component-padding compact:px-desktop-compact-component-padding",
1012
- paddingY && sizing === "container" && "py-mobile-container-padding desktop:py-desktop-container-padding compact:py-desktop-compact-container-padding",
1013
- paddingY && sizing === "layout" && "py-mobile-layout-padding desktop:py-desktop-layout-padding compact:py-desktop-compact-layout-padding",
1014
- paddingY && sizing === "layout-group" && paddingYUsingLayoutGroupGap,
1015
- paddingY && sizing === "component" && "py-mobile-component-padding desktop:py-desktop-component-padding compact:py-desktop-compact-component-padding",
1016
- margin && sizing === "container" && "m-mobile-container-padding desktop:m-desktop-container-padding compact:m-compact-container-padding",
1017
- marginX && sizing === "container" && "mx-mobile-container-padding desktop:mx-desktop-container-padding compact:mx-compact-container-padding",
1018
- marginTop && sizing === "container" && "mt-mobile-container-padding desktop:mt-desktop-container-padding compact:mt-compact-container-padding",
1019
- marginBottom && sizing === "container" && "mb-mobile-container-padding desktop:mb-desktop-container-padding compact:mb-compact-container-padding",
1020
- marginY && sizing === "container" && "my-mobile-container-padding desktop:my-desktop-container-padding compact:my-compact-container-padding",
1021
- horizontal ? "desktop:flex-row" : "desktop:flex-col",
1022
- horizontalMobile ? "flex-row" : "flex-col",
1023
- flexClassNames,
1024
- !noGap && gapClassNames,
1025
- elevation === 0 && "shadow-none",
1026
- elevation === 2 && "shadow-2",
1027
- elevation === 4 && "shadow-4",
1028
- elevation === 16 && "shadow-16",
1029
- rounded && "rounded"
1030
- ),
1031
- children
1032
- })
1033
- );
1034
- };
1035
-
1036
- // src/components/Paragraph.tsx
1037
- var import_clsx11 = __toESM(require("clsx"), 1);
1038
- var import_jsx_runtime10 = require("react/jsx-runtime");
1039
- var Paragraph = (_a) => {
1040
- var _b = _a, {
1041
- className,
1042
- color,
1043
- padded,
1044
- align = "left",
1045
- tall,
1046
- addOverflow,
1047
- children,
1048
- as = "p",
1049
- id,
1050
- testid
1051
- } = _b, props = __objRest(_b, [
1052
- "className",
1053
- "color",
1054
- "padded",
1055
- "align",
1056
- "tall",
1057
- "addOverflow",
1058
- "children",
1059
- "as",
1060
- "id",
1061
- "testid"
1062
- ]);
1063
- const Element = as;
1064
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1065
- Element,
1066
- __spreadProps(__spreadValues({
1067
- id,
1068
- "data-testid": testid
1069
- }, props), {
1070
- className: (0, import_clsx11.default)(
1071
- typography.paragraph,
1072
- className,
1073
- padded && componentPaddingXUsingComponentGap,
1074
- align === "left" && "text-left",
1075
- align === "center" && "text-center",
1076
- align === "right" && "text-right",
1077
- tall && "!leading-6",
1078
- addOverflow && "whitespace-nowrap text-ellipsis overflow-hidden"
1079
- ),
1080
- style: __spreadProps(__spreadValues({}, props.style), {
1081
- color: color ? `var(--color-${color})` : void 0
1082
- }),
1083
- children
1084
- })
1085
- );
1086
- };
1087
- Paragraph.displayName = "Paragraph";
1088
-
1089
- // src/components/Input.tsx
1090
- var import_react6 = require("react");
1091
- var import_clsx13 = __toESM(require("clsx"), 1);
1092
-
1093
- // src/components/Label.tsx
1094
- var import_clsx12 = __toESM(require("clsx"), 1);
1095
- var import_jsx_runtime11 = require("react/jsx-runtime");
1096
- var Label = (_a) => {
1097
- var _b = _a, {
1098
- as = "span",
1099
- padded,
1100
- className,
1101
- color,
1102
- align,
1103
- id,
1104
- testid
1105
- } = _b, props = __objRest(_b, [
1106
- "as",
1107
- "padded",
1108
- "className",
1109
- "color",
1110
- "align",
1111
- "id",
1112
- "testid"
1113
- ]);
1114
- const Element = as;
1115
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1116
- Element,
1117
- __spreadProps(__spreadValues({
1118
- id,
1119
- "data-testid": testid,
1120
- className: (0, import_clsx12.default)(
1121
- typography.label,
1122
- align === "left" && "text-left",
1123
- align === "center" && "text-center",
1124
- align === "right" && "text-right",
1125
- className,
1126
- padded && componentPaddingXUsingComponentGap
1127
- )
1128
- }, props), {
1129
- style: __spreadProps(__spreadValues({}, props.style), {
1130
- color: color ? `var(--color-${color})` : void 0
1131
- })
1132
- })
1133
- );
1134
- };
1135
- Label.displayName = "Label";
1136
-
1137
- // src/utils/formatting.tsx
1138
- function getDecimalPlaceholder(decimals) {
1139
- if (!decimals || decimals <= 0) {
1140
- return {};
1141
- }
1142
- return {
1143
- placeholder: `0.${"0".repeat(decimals)}`
1144
- };
1145
- }
1146
- function formatDecimalValue(value, decimals) {
1147
- if (!value || value === "") {
1148
- return "";
1149
- }
1150
- const numValue = typeof value === "string" ? parseFloat(value) : value;
1151
- if (isNaN(numValue)) {
1152
- return "";
1153
- }
1154
- if (!decimals || decimals <= 0) {
1155
- return String(Math.round(numValue));
1156
- }
1157
- return numValue.toFixed(decimals);
1158
- }
1159
- function formatCurrencyDisplay(value) {
1160
- if (!value || value === "") {
1161
- return "";
1162
- }
1163
- const parts = value.split(".");
1164
- const integerPart = parts[0];
1165
- const decimalPart = parts[1];
1166
- const formattedInteger = integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
1167
- return decimalPart !== void 0 ? `${formattedInteger}.${decimalPart}` : formattedInteger;
1168
- }
1169
-
1170
- // src/components/Input.tsx
1171
- var import_jsx_runtime12 = require("react/jsx-runtime");
1172
- var InputBase = (_a) => {
1173
- var _b = _a, {
1174
- id,
1175
- testid,
1176
- before,
1177
- after,
1178
- type,
1179
- label,
1180
- error,
1181
- className,
1182
- align = "left",
1183
- caption,
1184
- required,
1185
- selectOnFocus,
1186
- removeRoundness,
1187
- inputContainerRef,
1188
- removeBorder,
1189
- wrapperClassName,
1190
- focus,
1191
- fullWidth = true
1192
- } = _b, props = __objRest(_b, [
1193
- "id",
1194
- "testid",
1195
- "before",
1196
- "after",
1197
- "type",
1198
- "label",
1199
- "error",
1200
- "className",
1201
- "align",
1202
- "caption",
1203
- "required",
1204
- "selectOnFocus",
1205
- "removeRoundness",
1206
- "inputContainerRef",
1207
- "removeBorder",
1208
- "wrapperClassName",
1209
- "focus",
1210
- "fullWidth"
1211
- ]);
1212
- const attributes = {
1213
- "data-error": error && !focus || null,
1214
- "data-focus": focus || null
1215
- };
1216
- const inputRef = (0, import_react6.useRef)(null);
1217
- const inputId = id ? `${id}-input` : void 0;
1218
- (0, import_react6.useEffect)(() => {
1219
- var _a2;
1220
- const input = inputRef.current;
1221
- const focusHandler = () => {
1222
- input == null ? void 0 : input.select();
1223
- };
1224
- if (selectOnFocus) {
1225
- (_a2 = inputRef.current) == null ? void 0 : _a2.addEventListener("focus", focusHandler);
1226
- return () => {
1227
- input == null ? void 0 : input.removeEventListener("focus", focusHandler);
1228
- };
1229
- }
1230
- }, [selectOnFocus]);
1231
- const inputBaseClass = (0, import_clsx13.default)(
1232
- fullWidth ? "w-full" : "w-fit",
1233
- "flex flex-row items-center",
1234
- "bg-background-action-secondary-normal caret-icon-on-action-secondary-normal",
1235
- componentGap,
1236
- baseTransition,
1237
- "outline-transparent outline-2 -outline-offset-2",
1238
- componentPaddingMinusBorder,
1239
- !removeRoundness && "rounded-base",
1240
- !removeBorder && "border border-border-primary-normal",
1241
- "relative"
1242
- );
1243
- const inputFocusClass = (0, import_clsx13.default)(
1244
- "has-[[data-focus]]:border-transparent has-[[data-focus]]:outline-border-primary-focus focus-within:border-transparent focus-within:outline-border-primary-focus"
1245
- );
1246
- const inputDisabledClass = (0, import_clsx13.default)(
1247
- "has-disabled:bg-background-action-secondary-disabled"
1248
- );
1249
- const inputReadOnlyClass = (0, import_clsx13.default)(
1250
- "has-[input:not(:disabled):read-only]:outline-none has-[input:not(:disabled):read-only]:bg-transparent has-[input:not(:disabled):read-only]:border-transparent has-[input:not(:disabled):read-only]:pl-0"
1251
- );
1252
- const inputInvalidClass = (0, import_clsx13.default)(
1253
- "has-[[data-error]]:border-transparent has-[[data-error]]:not-focus-within:outline-border-primary-error has-[[data-error]]:not-focus-within:outline-1"
1254
- );
1255
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
1256
- "label",
1257
- {
1258
- id,
1259
- "data-testid": testid,
1260
- htmlFor: inputId,
1261
- ref: inputContainerRef,
1262
- className: (0, import_clsx13.default)(
1263
- "w-full flex flex-col",
1264
- "block",
1265
- "text-text-primary-normal has-disabled:text-text-primary-disabled",
1266
- componentGap
1267
- ),
1268
- style: __spreadValues({}, props.style),
1269
- children: [
1270
- label && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: (0, import_clsx13.default)("flex items-center", componentGap), children: [
1271
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1272
- Label,
1273
- {
1274
- id: id ? `${id}-label` : void 0,
1275
- className: (0, import_clsx13.default)(
1276
- props.disabled || props.readOnly ? "cursor-default" : "cursor-pointer"
1277
- ),
1278
- children: label
1279
- }
1280
- ),
1281
- required && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1282
- "span",
1283
- {
1284
- className: (0, import_clsx13.default)(typography.label, "text-text-critical-normal"),
1285
- children: "*"
1286
- }
1287
- )
1288
- ] }),
1289
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
1290
- "div",
1291
- {
1292
- className: (0, import_clsx13.default)(
1293
- inputBaseClass,
1294
- !props.disabled && inputInvalidClass,
1295
- inputFocusClass,
1296
- inputDisabledClass,
1297
- inputReadOnlyClass,
1298
- wrapperClassName
1299
- ),
1300
- children: [
1301
- before,
1302
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1303
- "input",
1304
- __spreadProps(__spreadValues(__spreadValues({
1305
- ref: (el) => {
1306
- inputRef.current = el;
1307
- },
1308
- type,
1309
- required
1310
- }, props), attributes), {
1311
- id: inputId,
1312
- "data-testid": testid ? `${testid}-input` : void 0,
1313
- className: (0, import_clsx13.default)(
1314
- "flex-1 outline-none w-full max-w-full min-h-6 min-w-0",
1315
- "[appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none",
1316
- "placeholder:text-text-secondary-normal disabled:text-text-secondary-disabled",
1317
- align === "right" && "text-right",
1318
- align === "center" && "text-center",
1319
- componentPaddingXUsingComponentGap,
1320
- typography.paragraph,
1321
- className,
1322
- props.readOnly && !props.disabled && "!px-0"
1323
- )
1324
- })
1325
- ),
1326
- after
1327
- ]
1328
- }
1329
- ),
1330
- caption && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { id: id ? `${id}-caption` : void 0, "data-testid": testid ? `${testid}-caption` : void 0, children: caption })
1331
- ]
1332
- }
1333
- );
1334
- };
1335
- var Input = (_a) => {
1336
- var _b = _a, {
1337
- variant = "default",
1338
- decimals,
1339
- uom,
1340
- removeSearchIcon,
1341
- value: propValue,
1342
- onChange,
1343
- onBlur,
1344
- onClear,
1345
- id,
1346
- testid
1347
- } = _b, props = __objRest(_b, [
1348
- "variant",
1349
- "decimals",
1350
- "uom",
1351
- "removeSearchIcon",
1352
- "value",
1353
- "onChange",
1354
- "onBlur",
1355
- "onClear",
1356
- "id",
1357
- "testid"
1358
- ]);
1359
- const [internalValue, setInternalValue] = (0, import_react6.useState)("");
1360
- const [displayValue, setDisplayValue] = (0, import_react6.useState)("");
1361
- (0, import_react6.useEffect)(() => {
1362
- var _a2;
1363
- const stringValue = (_a2 = propValue == null ? void 0 : propValue.toString()) != null ? _a2 : "";
1364
- setInternalValue(stringValue);
1365
- setDisplayValue(stringValue);
1366
- }, [propValue]);
1367
- (0, import_react6.useEffect)(() => {
1368
- var _a2;
1369
- if (variant !== "currency") {
1370
- return;
1371
- }
1372
- const stringValue = (_a2 = propValue == null ? void 0 : propValue.toString()) != null ? _a2 : "";
1373
- if (!stringValue) {
1374
- return;
1375
- }
1376
- const formatted = formatDecimalValue(stringValue, decimals != null ? decimals : 2);
1377
- setInternalValue(formatted);
1378
- setDisplayValue(formatCurrencyDisplay(formatted));
1379
- }, []);
1380
- const getInputProps = () => {
1381
- var _a2;
1382
- const baseProps = __spreadProps(__spreadValues(__spreadProps(__spreadValues({}, props), {
1383
- id
1384
- }), getDecimalPlaceholder(decimals)), {
1385
- value: propValue
1386
- });
1387
- switch (variant) {
1388
- case "search":
1389
- return __spreadProps(__spreadValues({}, baseProps), {
1390
- placeholder: (_a2 = props.placeholder) != null ? _a2 : "Search",
1391
- className: "!mr-6",
1392
- value: displayValue
1393
- });
1394
- case "finder":
1395
- return baseProps;
1396
- case "currency":
1397
- return __spreadProps(__spreadValues({}, baseProps), {
1398
- align: "right",
1399
- type: "text",
1400
- value: displayValue
1401
- });
1402
- case "percentage":
1403
- case "uom":
1404
- return __spreadProps(__spreadValues({}, baseProps), {
1405
- type: "number",
1406
- align: "right"
1407
- });
1408
- default:
1409
- return baseProps;
1410
- }
1411
- };
1412
- const getBeforeElement = () => {
1413
- if (props.before) return props.before;
1414
- switch (variant) {
1415
- case "search":
1416
- return !removeSearchIcon ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "text-icon-primary-normal contents", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Icon, { name: "search" }) }) : null;
1417
- case "currency":
1418
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "text-icon-primary-normal contents", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Icon, { name: "attach_money" }) });
1419
- default:
1420
- return null;
1421
- }
1422
- };
1423
- const getAfterElement = () => {
1424
- if (props.after) return props.after;
1425
- switch (variant) {
1426
- case "search": {
1427
- const hasValue = displayValue.length > 0;
1428
- return hasValue && !props.readOnly ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1429
- Icon,
1430
- {
1431
- id: id ? `${id}-clear-button` : void 0,
1432
- testid: testid ? `${testid}-clear-button` : void 0,
1433
- name: "close",
1434
- onClick: handleSearchReset,
1435
- className: "cursor-pointer absolute right-2 bottom-2/4 translate-y-2/4"
1436
- }
1437
- ) : null;
1438
- }
1439
- case "finder":
1440
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Icon, { name: "search" });
1441
- case "uom":
1442
- return uom ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "text-text-secondary-normal uppercase", children: uom.slice(0, 4) }) : null;
1443
- case "percentage":
1444
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "text-icon-primary-normal contents", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Icon, { name: "percent" }) });
1445
- default:
1446
- return null;
1447
- }
1448
- };
1449
- const handleSearchReset = () => {
1450
- setInternalValue("");
1451
- setDisplayValue("");
1452
- if (onChange) {
1453
- const syntheticEvent = {
1454
- target: { value: "" }
1455
- };
1456
- if (typeof onChange === "function") {
1457
- onChange(syntheticEvent);
1458
- }
1459
- }
1460
- onClear == null ? void 0 : onClear();
1461
- };
1462
- const handleChange = (e) => {
1463
- const rawValue = e.target.value;
1464
- if (variant === "currency") {
1465
- const raw = rawValue.replace(/,/g, "");
1466
- if (raw === "") {
1467
- setInternalValue("");
1468
- setDisplayValue("");
1469
- if (onChange) {
1470
- const syntheticEvent = __spreadProps(__spreadValues({}, e), {
1471
- target: __spreadProps(__spreadValues({}, e.target), { value: "" })
1472
- });
1473
- onChange(syntheticEvent);
1474
- }
1475
- return;
1476
- }
1477
- const regex = /^\d*\.?\d*$/;
1478
- if (!regex.test(raw)) return;
1479
- const parts = raw.split(".");
1480
- const currentDecimals = decimals != null ? decimals : 2;
1481
- if (parts.length === 2 && parts[1].length > currentDecimals) return;
1482
- setInternalValue(raw);
1483
- setDisplayValue(formatCurrencyDisplay(raw));
1484
- const asNumber = Number(raw);
1485
- if (!isNaN(asNumber) && onChange) {
1486
- const syntheticEvent = __spreadProps(__spreadValues({}, e), {
1487
- target: __spreadProps(__spreadValues({}, e.target), { value: asNumber.toString() })
1488
- });
1489
- onChange(syntheticEvent);
1490
- }
1491
- return;
1492
- }
1493
- setInternalValue(rawValue);
1494
- setDisplayValue(rawValue);
1495
- if (typeof onChange === "function") {
1496
- onChange(e);
1497
- }
1498
- };
1499
- const handleBlur = (e) => {
1500
- if (!internalValue) {
1501
- return;
1502
- }
1503
- if (variant === "currency") {
1504
- const formatted = formatDecimalValue(internalValue, decimals != null ? decimals : 2);
1505
- setInternalValue(formatted);
1506
- setDisplayValue(formatCurrencyDisplay(formatted));
1507
- const asNumber = Number(formatted);
1508
- if (!isNaN(asNumber) && onChange) {
1509
- const syntheticEvent = __spreadProps(__spreadValues({}, e), {
1510
- target: __spreadProps(__spreadValues({}, e.target), { value: asNumber.toString() })
1511
- });
1512
- onChange(syntheticEvent);
1513
- }
1514
- } else if (variant === "uom" || variant === "percentage") {
1515
- const formattedValue = formatDecimalValue(e.target.value, decimals);
1516
- e.target.value = formattedValue;
1517
- }
1518
- onBlur == null ? void 0 : onBlur(e);
1519
- };
1520
- const inputProps = getInputProps();
1521
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1522
- InputBase,
1523
- __spreadProps(__spreadValues({}, inputProps), {
1524
- before: getBeforeElement(),
1525
- after: getAfterElement(),
1526
- onChange: handleChange,
1527
- onBlur: handleBlur,
1528
- testid
1529
- })
1530
- );
1531
- };
1532
- Input.displayName = "Input";
1533
- var Finder = (props) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Input, __spreadProps(__spreadValues({}, props), { variant: "finder" }));
1534
- var UOM = (props) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Input, __spreadProps(__spreadValues({}, props), { variant: "uom" }));
1535
- var Currency = (props) => {
1536
- var _a;
1537
- const handleCurrencyChange = (e) => {
1538
- var _a2;
1539
- (_a2 = props.onChange) == null ? void 0 : _a2.call(props, e);
1540
- };
1541
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1542
- Input,
1543
- __spreadProps(__spreadValues({}, props), {
1544
- variant: "currency",
1545
- decimals: (_a = props.decimals) != null ? _a : 2,
1546
- onChange: handleCurrencyChange
1547
- })
1548
- );
1549
- };
1550
- var Percentage = (props) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Input, __spreadProps(__spreadValues({}, props), { variant: "percentage" }));
1551
- Finder.displayName = "Finder";
1552
- UOM.displayName = "UOM";
1553
- Currency.displayName = "Currency";
1554
- Percentage.displayName = "Percentage";
1555
-
1556
- // src/components/Card.tsx
1557
- var import_clsx14 = __toESM(require("clsx"), 1);
1558
- var import_jsx_runtime13 = require("react/jsx-runtime");
1559
- function Card(props) {
1560
- const _a = props, { children, selected, testid } = _a, rest = __objRest(_a, ["children", "selected", "testid"]);
1561
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1562
- "div",
1563
- __spreadProps(__spreadValues({}, rest), {
1564
- "data-testid": testid,
1565
- className: (0, import_clsx14.default)(
1566
- "rounded-sm p-desktop-layout-padding",
1567
- selected ? "border-2 border-border-primary-focus" : "border border-border-primary-normal",
1568
- rest.className
1569
- ),
1570
- children
1571
- })
1572
- );
1573
- }
1574
-
1575
- // src/components/PaymentOnAccountModal.tsx
1576
- var import_react8 = require("react");
1577
-
1578
- // src/components/SelectPaymentMethod.tsx
1579
- var import_react7 = require("react");
1580
-
1581
- // src/components/Accordion.tsx
1582
- var import_clsx15 = __toESM(require("clsx"), 1);
1583
- var import_jsx_runtime14 = require("react/jsx-runtime");
1584
- function Accordion(props) {
1585
- const { isOpen, onClick, className, disabled, testid } = props;
1586
- const {
1587
- title,
1588
- before,
1589
- after = /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1590
- Icon,
1591
- {
1592
- name: "expand_more",
1593
- className: (0, import_clsx15.default)(
1594
- "text-icon-primary-normal transform transition-all duration-300 ease-in-out",
1595
- isOpen ? "rotate-180" : "rotate-0"
1596
- )
1597
- }
1598
- ),
1599
- children
1600
- } = props;
1601
- function handleClick(e) {
1602
- e.stopPropagation();
1603
- e.preventDefault();
1604
- onClick == null ? void 0 : onClick();
1605
- }
1606
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
1607
- Card,
1608
- {
1609
- className: (0, import_clsx15.default)(
1610
- "overflow-hidden select-none",
1611
- { "cursor-pointer": !disabled },
1612
- className
1613
- ),
1614
- selected: isOpen,
1615
- onClick: handleClick,
1616
- testid,
1617
- children: [
1618
- /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(Stack, { sizing: "component", horizontal: true, justify: "between", items: "center", children: [
1619
- /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(Stack, { sizing: "layout-group", horizontal: true, items: "center", children: [
1620
- before,
1621
- typeof title === "string" ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Paragraph, { testid: testid ? `${testid}-title` : void 0, className: "text-text-primary-normal", children: title }) : title
1622
- ] }),
1623
- after
1624
- ] }),
1625
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1626
- "div",
1627
- {
1628
- className: (0, import_clsx15.default)("grid transition-all duration-300 ease-in-out"),
1629
- style: {
1630
- gridTemplateRows: isOpen ? "1fr" : "0fr"
1631
- },
1632
- "data-testid": testid ? `${testid}-content-container` : void 0,
1633
- children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "overflow-hidden", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1634
- "div",
1635
- {
1636
- className: (0, import_clsx15.default)(
1637
- typography.paragraph,
1638
- "text-text-primary-normal desktop:pt-desktop-layout-gap",
1639
- "flex flex-col gap-desktop-layout-gap"
1640
- ),
1641
- onClick: (e) => e.stopPropagation(),
1642
- children
1643
- }
1644
- ) })
1645
- }
1646
- )
1647
- ]
1648
- }
1649
- );
1650
- }
1651
-
1652
- // src/components/Radio.tsx
1653
- var import_clsx16 = __toESM(require("clsx"), 1);
1654
- var import_jsx_runtime15 = require("react/jsx-runtime");
1655
- var Radio = (_a) => {
1656
- var _b = _a, {
1657
- className,
1658
- label,
1659
- error,
1660
- disabled,
1661
- checked,
1662
- readOnly,
1663
- id,
1664
- testid
1665
- } = _b, props = __objRest(_b, [
1666
- "className",
1667
- "label",
1668
- "error",
1669
- "disabled",
1670
- "checked",
1671
- "readOnly",
1672
- "id",
1673
- "testid"
1674
- ]);
1675
- const radioId = id;
1676
- const paragraphColor = disabled ? "text-primary-disabled" : error ? "text-primary-error" : "text-primary-normal";
1677
- const defaultClassName = (0, import_clsx16.default)(
1678
- !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"
1679
- );
1680
- const errorClassName = (0, import_clsx16.default)(
1681
- 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 "
1682
- );
1683
- const disabledClassName = (0, import_clsx16.default)(
1684
- disabled && "peer-disabled:bg-background-action-secondary-disabled peer-disabled:border-border-primary-normal peer-checked:border-0"
1685
- );
1686
- const readonlyClassName = (0, import_clsx16.default)(
1687
- readOnly && "peer-read-only:bg-background-action-secondary-disabled peer-read-only:border-border-primary-normal peer-checked:border-0"
1688
- );
1689
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
1690
- "label",
1691
- {
1692
- htmlFor: radioId,
1693
- className: (0, import_clsx16.default)(
1694
- "flex items-center",
1695
- componentGap,
1696
- disabled ? "cursor-default" : "cursor-pointer",
1697
- className
1698
- ),
1699
- children: [
1700
- /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "relative", children: [
1701
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1702
- "input",
1703
- __spreadValues({
1704
- id: radioId,
1705
- "data-testid": testid,
1706
- type: "radio",
1707
- className: "sr-only peer",
1708
- disabled,
1709
- checked,
1710
- readOnly
1711
- }, props)
1712
- ),
1713
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1714
- "div",
1715
- {
1716
- className: (0, import_clsx16.default)(
1717
- "size-6 rounded-full border flex items-center justify-center",
1718
- baseTransition,
1719
- defaultClassName,
1720
- errorClassName,
1721
- disabledClassName,
1722
- readonlyClassName
1723
- ),
1724
- children: checked && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1725
- RadioIcon,
1726
- {
1727
- className: (0, import_clsx16.default)(
1728
- "transition-colors",
1729
- !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",
1730
- 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",
1731
- disabled && "text-icon-on-action-secondary-disabled",
1732
- readOnly && "text-icon-on-action-secondary-disabled"
1733
- )
1734
- }
1735
- )
1736
- }
1737
- )
1738
- ] }),
1739
- label && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Paragraph, { id: radioId ? `${radioId}-label` : void 0, testid: testid ? `${testid}-label` : void 0, padded: true, color: paragraphColor, children: label })
1740
- ]
1741
- }
1742
- );
1743
- };
1744
- Radio.displayName = "Radio";
1745
- var RadioIcon = ({ className }) => {
1746
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
1747
- "svg",
1748
- {
1749
- className,
1750
- xmlns: "http://www.w3.org/2000/svg",
1751
- width: "24",
1752
- height: "24",
1753
- viewBox: "0 0 24 24",
1754
- fill: "none",
1755
- children: [
1756
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1757
- "rect",
1758
- {
1759
- x: "1",
1760
- y: "1",
1761
- width: "22",
1762
- height: "22",
1763
- rx: "11",
1764
- stroke: "currentColor",
1765
- strokeWidth: "2"
1766
- }
1767
- ),
1768
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("rect", { x: "4", y: "4", width: "16", height: "16", rx: "8", fill: "currentColor" })
1769
- ]
1770
- }
1771
- );
1772
- };
1773
- RadioIcon.displayName = "RadioIcon";
1774
-
1775
- // src/components/Checkbox.tsx
1776
- var import_clsx17 = __toESM(require("clsx"), 1);
1777
- var import_jsx_runtime16 = require("react/jsx-runtime");
1778
- var Checkbox = (_a) => {
1779
- var _b = _a, {
1780
- label,
1781
- error,
1782
- disabled,
1783
- readOnly,
1784
- checked,
1785
- onChange,
1786
- indeterminate,
1787
- paragraphClassName,
1788
- id,
1789
- testid
1790
- } = _b, props = __objRest(_b, [
1791
- "label",
1792
- "error",
1793
- "disabled",
1794
- "readOnly",
1795
- "checked",
1796
- "onChange",
1797
- "indeterminate",
1798
- "paragraphClassName",
1799
- "id",
1800
- "testid"
1801
- ]);
1802
- const selected = indeterminate || checked;
1803
- const normalClassName = (0, import_clsx17.default)(
1804
- !selected && !error && !disabled && !readOnly && "border-border-primary-normal bg-background-action-secondary-normal peer-hover:border-border-action-hover peer-hover:bg-background-action-secondary-hover peer-active:border-border-action-active peer-active:bg-background-action-secondary-active"
1805
- );
1806
- const normalSelectedClassName = (0, import_clsx17.default)(
1807
- selected && !error && !disabled && !readOnly && "bg-background-action-primary-normal border-background-action-primary-normal peer-hover:bg-background-action-primary-hover peer-hover:border-background-action-primary-hover peer-active:bg-background-action-primary-active peer-active:border-background-action-primary-active"
1808
- );
1809
- const errorClassName = (0, import_clsx17.default)(
1810
- error && !selected && "bg-background-action-critical-secondary-normal border-border-action-critical-normal peer-hover:border-border-action-critical-hover peer-hover:bg-background-action-critical-secondary-hover peer-active:border-border-action-critical-active peer-active:bg-background-action-secondary-active"
1811
- );
1812
- const errorSelectedClassName = (0, import_clsx17.default)(
1813
- error && selected && "bg-background-action-critical-primary-normal border-background-action-critical-primary-normal peer-hover:bg-background-action-critical-primary-hover peer-hover:border-background-action-critical-primary-hover peer-active:bg-background-action-critical-primary-active peer-active:border-background-action-critical-primary-active"
1814
- );
1815
- const disabledClassName = (0, import_clsx17.default)(
1816
- disabled && !readOnly && "border-border-primary-normal bg-background-action-secondary-disabled peer-checked:bg-icon-on-action-primary-disabled peer-checked:border-icon-on-action-primary-disabled"
1817
- );
1818
- const readOnlyClassName = (0, import_clsx17.default)(
1819
- readOnly && "border-transparent bg-transparent peer-checked:bg-transparent peer-checked:border-transparent"
1820
- );
1821
- const checkColor = (0, import_clsx17.default)(
1822
- selected && !disabled && !readOnly && "color-icon-on-action-primary-normal peer-hover:color-icon-on-action-primary-hover peer-active:color-icon-on-action-primary-active",
1823
- selected && disabled && "color-background-action-primary-disabled"
1824
- );
1825
- return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
1826
- "label",
1827
- {
1828
- id,
1829
- "data-testid": testid,
1830
- htmlFor: id ? `${id}-input` : void 0,
1831
- className: (0, import_clsx17.default)(
1832
- "flex items-center",
1833
- componentGap,
1834
- (disabled || readOnly && error || readOnly) && "cursor-default",
1835
- !(readOnly && error) && !disabled && !readOnly && "cursor-pointer"
1836
- ),
1837
- children: [
1838
- /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "relative", children: [
1839
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1840
- "input",
1841
- __spreadValues({
1842
- id: id ? `${id}-input` : void 0,
1843
- "data-testid": testid ? `${testid}-input` : void 0,
1844
- type: "checkbox",
1845
- className: "sr-only peer",
1846
- disabled,
1847
- checked: selected,
1848
- onChange: handleOnChange,
1849
- "data-indeterminate": indeterminate
1850
- }, props)
1851
- ),
1852
- error && (readOnly || disabled) ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: (0, import_clsx17.default)("size-6", "flex items-center justify-center"), children: selected ? indeterminate ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "text-icon-primary-normal contents", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Icon, { name: "question_mark" }) }) : readOnly ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "text-success-400 contents", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Icon, { name: "check" }) }) : /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "text-icon-on-action-primary-normal contents", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Icon, { name: "check", className: "pointer-events-none" }) }) : readOnly && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "text-icon-primary-normal contents", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Icon, { name: "close" }) }) }) : /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1853
- "div",
1854
- {
1855
- className: (0, import_clsx17.default)(
1856
- "size-6 border rounded-base",
1857
- "flex items-center justify-center",
1858
- baseTransition,
1859
- normalClassName,
1860
- normalSelectedClassName,
1861
- errorClassName,
1862
- errorSelectedClassName,
1863
- disabledClassName,
1864
- readOnlyClassName,
1865
- checkColor
1866
- ),
1867
- children: selected ? indeterminate ? readOnly ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "text-icon-primary-normal contents", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Icon, { name: "question_mark" }) }) : /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "text-icon-on-action-primary-normal contents", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Icon, { name: "remove", className: "pointer-events-none" }) }) : readOnly ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "text-success-400 contents", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Icon, { name: "check" }) }) : /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "text-icon-on-action-primary-normal contents", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Icon, { name: "check", className: "pointer-events-none" }) }) : readOnly && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "text-icon-primary-normal contents", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Icon, { name: "close" }) })
1868
- }
1869
- )
1870
- ] }),
1871
- label && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1872
- Paragraph,
1873
- {
1874
- id: id ? `${id}-label` : void 0,
1875
- testid: testid ? `${testid}-label` : void 0,
1876
- as: "span",
1877
- padded: true,
1878
- className: (0, import_clsx17.default)(
1879
- "text-nowrap",
1880
- disabled && !error && "!text-text-primary-disabled",
1881
- error && !disabled && !readOnly && "!text-text-primary-error",
1882
- paragraphClassName
1883
- ),
1884
- children: label
1885
- }
1886
- )
1887
- ]
1888
- }
1889
- );
1890
- function handleOnChange(e) {
1891
- if (disabled || readOnly || readOnly && error || !onChange) {
1892
- return;
1893
- }
1894
- onChange(e);
1895
- }
1896
- };
1897
- Checkbox.displayName = "Checkbox";
1898
-
1899
- // src/components/Subheader.tsx
1900
- var import_clsx18 = __toESM(require("clsx"), 1);
1901
- var import_jsx_runtime17 = require("react/jsx-runtime");
1902
- var Subheader = (_a) => {
1903
- var _b = _a, {
1904
- className,
1905
- children,
1906
- as = "span",
1907
- align,
1908
- color,
1909
- tall,
1910
- id,
1911
- testid
1912
- } = _b, props = __objRest(_b, [
1913
- "className",
1914
- "children",
1915
- "as",
1916
- "align",
1917
- "color",
1918
- "tall",
1919
- "id",
1920
- "testid"
1921
- ]);
1922
- const Element = as;
1923
- return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
1924
- Element,
1925
- __spreadProps(__spreadValues({
1926
- id,
1927
- "data-testid": testid,
1928
- className: (0, import_clsx18.default)(
1929
- typography.subheader,
1930
- className,
1931
- align === "left" && "text-left",
1932
- align === "center" && "text-center",
1933
- align === "right" && "text-right",
1934
- tall && "!leading-6"
1935
- ),
1936
- style: __spreadProps(__spreadValues({}, props.style), {
1937
- color: color ? `var(--color-${color})` : void 0
1938
- })
1939
- }, props), {
1940
- children
1941
- })
1942
- );
1943
- };
1944
- Subheader.displayName = "Subheader";
1945
-
1946
- // src/components/HorizontalDivider.tsx
1947
- var import_clsx19 = __toESM(require("clsx"), 1);
1948
- var import_jsx_runtime18 = require("react/jsx-runtime");
1949
- function HorizontalDivider({ id, testid, hideOnMobile }) {
1950
- const hideOnMobileStyle = (0, import_clsx19.default)(hideOnMobile && "hidden desktop:block");
1951
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("hr", { id, "data-testid": testid, className: (0, import_clsx19.default)("w-full border-t border-border-primary-normal", hideOnMobileStyle) });
1952
- }
1953
-
1954
- // src/components/Spinner.tsx
1955
- var import_jsx_runtime19 = require("react/jsx-runtime");
1956
- var Spinner = ({ size = "small", testid }) => {
1957
- const dimension = size === "large" ? 48 : 24;
1958
- return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
1959
- "svg",
1960
- {
1961
- "data-testid": testid,
1962
- width: dimension,
1963
- height: dimension,
1964
- viewBox: "0 0 24 24",
1965
- xmlns: "http://www.w3.org/2000/svg",
1966
- fill: "#1D1E1E",
1967
- className: "animate-spin",
1968
- "aria-label": "Loading",
1969
- children: [
1970
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("circle", { cx: "12", cy: "4", r: "2", opacity: "1", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
1971
- "animate",
1972
- {
1973
- attributeName: "opacity",
1974
- begin: "0s",
1975
- dur: "1s",
1976
- from: "1",
1977
- to: "0",
1978
- repeatCount: "indefinite"
1979
- }
1980
- ) }),
1981
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("circle", { cx: "17.666", cy: "6.334", r: "2", opacity: "0.125", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
1982
- "animate",
1983
- {
1984
- attributeName: "opacity",
1985
- begin: "-0.875s",
1986
- dur: "1s",
1987
- from: "1",
1988
- to: "0",
1989
- repeatCount: "indefinite"
1990
- }
1991
- ) }),
1992
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("circle", { cx: "20", cy: "12", r: "2", opacity: "0.25", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
1993
- "animate",
1994
- {
1995
- attributeName: "opacity",
1996
- begin: "-0.75s",
1997
- dur: "1s",
1998
- from: "1",
1999
- to: "0",
2000
- repeatCount: "indefinite"
2001
- }
2002
- ) }),
2003
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("circle", { cx: "17.666", cy: "17.666", r: "2", opacity: "0.375", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
2004
- "animate",
2005
- {
2006
- attributeName: "opacity",
2007
- begin: "-0.625s",
2008
- dur: "1s",
2009
- from: "1",
2010
- to: "0",
2011
- repeatCount: "indefinite"
2012
- }
2013
- ) }),
2014
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("circle", { cx: "12", cy: "20", r: "2", opacity: "0.5", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
2015
- "animate",
2016
- {
2017
- attributeName: "opacity",
2018
- begin: "-0.5s",
2019
- dur: "1s",
2020
- from: "1",
2021
- to: "0",
2022
- repeatCount: "indefinite"
2023
- }
2024
- ) }),
2025
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("circle", { cx: "6.334", cy: "17.666", r: "2", opacity: "0.625", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
2026
- "animate",
2027
- {
2028
- attributeName: "opacity",
2029
- begin: "-0.375s",
2030
- dur: "1s",
2031
- from: "1",
2032
- to: "0",
2033
- repeatCount: "indefinite"
2034
- }
2035
- ) }),
2036
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("circle", { cx: "4", cy: "12", r: "2", opacity: "0.75", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
2037
- "animate",
2038
- {
2039
- attributeName: "opacity",
2040
- begin: "-0.25s",
2041
- dur: "1s",
2042
- from: "1",
2043
- to: "0",
2044
- repeatCount: "indefinite"
2045
- }
2046
- ) }),
2047
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("circle", { cx: "6.334", cy: "6.334", r: "2", opacity: "0.875", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
2048
- "animate",
2049
- {
2050
- attributeName: "opacity",
2051
- begin: "-0.125s",
2052
- dur: "1s",
2053
- from: "1",
2054
- to: "0",
2055
- repeatCount: "indefinite"
2056
- }
2057
- ) })
2058
- ]
2059
- }
2060
- );
2061
- };
2062
- Spinner.displayName = "Spinner";
2063
-
2064
- // src/components/WorldpayIframe.tsx
2065
- var import_jsx_runtime20 = require("react/jsx-runtime");
2066
- function WorldpayIframe({ url }) {
2067
- return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("iframe", { src: url, style: { width: "100%", height: "100%", flex: 1 } });
2068
- }
2069
-
2070
- // src/components/SelectPaymentMethod.tsx
2071
- var import_jsx_runtime21 = require("react/jsx-runtime");
2072
- function SelectPaymentMethod(props) {
2073
- const {
2074
- amountToPay,
2075
- selectedMethod,
2076
- onSelectMethod,
2077
- selectedCredits,
2078
- allCredits,
2079
- allowedMethods,
2080
- selectedACHBankGuid,
2081
- setSelectedACHBankGuid,
2082
- customerBanks,
2083
- onPay,
2084
- isPayLoading,
2085
- withCredits = false,
2086
- isLoadingCCiframe,
2087
- cardPaymentUrl,
2088
- testid
2089
- } = props;
2090
- const payAllWithCredits = withCredits && amountToPay <= 0;
2091
- (0, import_react7.useEffect)(() => {
2092
- if (payAllWithCredits) {
2093
- onSelectMethod("CreditsOnly");
2094
- } else {
2095
- onSelectMethod(null);
2096
- }
2097
- }, [onSelectMethod, payAllWithCredits]);
2098
- function handleToggle(method) {
2099
- onSelectMethod(method);
2100
- }
2101
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(Stack, { sizing: "layout-group", width: "full", minWidth: 400, children: [
2102
- !!(allCredits == null ? void 0 : allCredits.length) && withCredits && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2103
- CreditsSelector,
2104
- {
2105
- testid: testid ? `${testid}-credit-selector` : void 0,
2106
- selectedCredits: selectedCredits || [],
2107
- allCredits: allCredits || [],
2108
- setSelectedCredits: props.setSelectedCredits || (() => {
2109
- })
2110
- }
2111
- ),
2112
- (allowedMethods == null ? void 0 : allowedMethods.includes("ACHPayment")) && !!(customerBanks == null ? void 0 : customerBanks.length) && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2113
- ACHSelector,
2114
- {
2115
- testid: testid ? `${testid}-ach-selector` : void 0,
2116
- selectedMethod,
2117
- handleToggle,
2118
- selectedBankGuid: selectedACHBankGuid || null,
2119
- setSelectedBankGuid: setSelectedACHBankGuid || (() => {
2120
- }),
2121
- customerBanks: customerBanks || [],
2122
- onPay,
2123
- isPayLoading: isPayLoading || false,
2124
- disabled: payAllWithCredits || !amountToPay
2125
- }
2126
- ),
2127
- (allowedMethods == null ? void 0 : allowedMethods.includes("CCPayment")) && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2128
- Accordion,
2129
- {
2130
- testid: testid ? `${testid}-cc-payment` : void 0,
2131
- isOpen: !payAllWithCredits && selectedMethod === "CCPayment",
2132
- title: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2133
- Radio,
2134
- {
2135
- testid: testid ? `${testid}-cc-payment-radio` : void 0,
2136
- label: "Pay by Credit/Debit Card",
2137
- checked: !payAllWithCredits && selectedMethod === "CCPayment",
2138
- onChange: (e) => e.stopPropagation(),
2139
- disabled: payAllWithCredits || !amountToPay
2140
- }
2141
- ),
2142
- onClick: () => {
2143
- if (payAllWithCredits || !amountToPay) return;
2144
- handleToggle(selectedMethod === "CCPayment" ? null : "CCPayment");
2145
- },
2146
- disabled: payAllWithCredits || !amountToPay,
2147
- children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2148
- Stack,
2149
- {
2150
- sizing: "layout-group",
2151
- width: "full",
2152
- items: "center",
2153
- justify: "center",
2154
- style: {
2155
- flex: 1
2156
- },
2157
- minHeight: 245,
2158
- children: !isLoadingCCiframe && cardPaymentUrl ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(WorldpayIframe, { url: cardPaymentUrl }) : /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Spinner, {})
2159
- }
2160
- )
2161
- }
2162
- ),
2163
- selectedMethod === "ACHPayment" && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2164
- Button,
2165
- {
2166
- block: true,
2167
- onClick: onPay,
2168
- disabled: isPayLoading || amountToPay <= 0,
2169
- testid: testid ? `${testid}-submit-payment-button` : void 0,
2170
- children: isPayLoading ? "Processing..." : "Submit Payment"
2171
- }
2172
- ),
2173
- payAllWithCredits && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2174
- Button,
2175
- {
2176
- testid: testid ? `${testid}-submit-payment-button` : void 0,
2177
- block: true,
2178
- onClick: onPay,
2179
- disabled: isPayLoading,
2180
- children: isPayLoading ? "Processing..." : "Submit Payment"
2181
- }
2182
- )
2183
- ] });
2184
- }
2185
- function ACHSelector(props) {
2186
- const {
2187
- selectedMethod,
2188
- handleToggle,
2189
- selectedBankGuid,
2190
- setSelectedBankGuid,
2191
- customerBanks,
2192
- disabled,
2193
- testid
2194
- } = props;
2195
- function handleBankSelect(e, bankGuid) {
2196
- if (disabled) return;
2197
- e.stopPropagation();
2198
- setSelectedBankGuid(bankGuid);
2199
- handleToggle("ACHPayment");
2200
- }
2201
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_jsx_runtime21.Fragment, { children: customerBanks.map((bank) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2202
- Card,
2203
- {
2204
- testid: testid ? `${testid}-bank-${bank.CustBankGUID}` : void 0,
2205
- onClick: (e) => handleBankSelect(e, bank.CustBankGUID),
2206
- selected: !disabled && selectedMethod === "ACHPayment" && selectedBankGuid === bank.CustBankGUID,
2207
- children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2208
- Radio,
2209
- {
2210
- label: `Pay by ${bank.AccountDisplayString}`,
2211
- checked: !disabled && selectedMethod === "ACHPayment" && selectedBankGuid === bank.CustBankGUID,
2212
- disabled,
2213
- onChange: (e) => e.stopPropagation()
2214
- }
2215
- )
2216
- },
2217
- bank.CustBankGUID
2218
- )) });
2219
- }
2220
- function CreditsSelector(props) {
2221
- const { selectedCredits, allCredits, setSelectedCredits, testid } = props;
2222
- const [isOpen, setIsOpen] = (0, import_react7.useState)(true);
2223
- const handleCreditSelect = (credit) => {
2224
- if (setSelectedCredits) {
2225
- setSelectedCredits(
2226
- (prev) => prev.includes(credit) ? prev.filter((c) => c !== credit) : [...prev, credit]
2227
- );
2228
- }
2229
- };
2230
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
2231
- Accordion,
2232
- {
2233
- isOpen,
2234
- title: "Available Credits",
2235
- onClick: () => setIsOpen((prev) => !prev),
2236
- testid,
2237
- children: [
2238
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(HorizontalDivider, {}),
2239
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Stack, { sizing: "layout-group", width: "full", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2240
- Stack,
2241
- {
2242
- sizing: "layout-group",
2243
- width: "full",
2244
- overflowY: "auto",
2245
- maxHeight: 300,
2246
- children: allCredits.map((credits) => /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
2247
- Stack,
2248
- {
2249
- horizontal: true,
2250
- justify: "between",
2251
- items: "center",
2252
- sizing: "layout-group",
2253
- children: [
2254
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2255
- Stack,
2256
- {
2257
- sizing: "layout-group",
2258
- onClick: () => handleCreditSelect(credits),
2259
- paddingY: true,
2260
- flexGrow: 1,
2261
- testid: testid ? `${testid}-credit-${credits.InvoiceNumber}` : void 0,
2262
- children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2263
- Checkbox,
2264
- {
2265
- testid: testid ? `${testid}-credit-${credits.InvoiceNumber}-checkbox` : void 0,
2266
- label: credits.InvoiceNumber,
2267
- checked: selectedCredits == null ? void 0 : selectedCredits.includes(credits),
2268
- onChange: () => handleCreditSelect(credits)
2269
- }
2270
- )
2271
- }
2272
- ),
2273
- /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
2274
- Subheader,
2275
- {
2276
- testid: testid ? `${testid}-credit-${credits.InvoiceNumber}-InvoiceBalanceDue` : void 0,
2277
- className: " pr-desktop-component-padding",
2278
- children: [
2279
- "$",
2280
- formatCurrencyDisplay(
2281
- formatDecimalValue(Math.abs(credits.InvoiceBalanceDue), 2)
2282
- )
2283
- ]
2284
- }
2285
- )
2286
- ]
2287
- },
2288
- credits.AROpenGUID
2289
- ))
2290
- }
2291
- ) })
2292
- ]
2293
- }
2294
- );
2295
- }
2296
-
2297
- // src/components/PaymentOnAccountModal.tsx
2298
- var import_jsx_runtime22 = require("react/jsx-runtime");
2299
- function PaymentOnAccountModal(props) {
2300
- const {
2301
- isOpen,
2302
- paymentProps,
2303
- onClose,
2304
- onAmountChange,
2305
- cardPaymentUrl,
2306
- setCardPaymentUrl,
2307
- isLoadingCCiframe,
2308
- testid
2309
- } = props;
2310
- const [amount, setAmount] = (0, import_react8.useState)(paymentProps.amountToPay);
2311
- const { creditCardSettings, selectedMethod } = paymentProps;
2312
- (0, import_react8.useEffect)(() => {
2313
- setAmount(paymentProps.amountToPay);
2314
- }, [paymentProps.amountToPay]);
2315
- function handleAmountChange(event) {
2316
- const inputValue = event.target.value.replace(/[^0-9.-]+/g, "");
2317
- const value = +inputValue || 0;
2318
- setAmount(value);
2319
- onAmountChange == null ? void 0 : onAmountChange(value);
2320
- }
2321
- const creditCardSurcharge = (0, import_react8.useMemo)(() => {
2322
- const applySurcharge = (creditCardSettings == null ? void 0 : creditCardSettings.ApplySurcharge) || false;
2323
- if (!applySurcharge || selectedMethod !== "CCPayment") {
2324
- return 0;
2325
- }
2326
- const surchargeType = creditCardSettings == null ? void 0 : creditCardSettings.SurchargeBasisType;
2327
- const surchargeRate = (creditCardSettings == null ? void 0 : creditCardSettings.SurchargeBasisAmount) || 0;
2328
- if (surchargeType === "Percent") {
2329
- return calculateSurcharge(amount, surchargeRate);
2330
- }
2331
- if (surchargeType === "Fixed") {
2332
- return surchargeRate;
2333
- }
2334
- return 0;
2335
- }, [creditCardSettings, amount, selectedMethod]);
2336
- return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Modal, { testid, open: isOpen, onClose, title: "Payment on Account", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(Stack, { sizing: "layout-group", width: "full", children: [
2337
- selectedMethod === "CCPayment" && /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(Stack, { horizontal: true, justify: "between", items: "center", children: [
2338
- /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Paragraph, { children: "Surcharge" }),
2339
- /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(Paragraph, { testid: testid ? `${testid}-surcharge` : void 0, children: [
2340
- "$",
2341
- formatCurrencyDisplay(creditCardSurcharge.toFixed(2))
2342
- ] })
2343
- ] }),
2344
- /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Card, { className: "py-desktop-component-padding", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(Stack, { sizing: "component", justify: "between", items: "center", horizontal: true, children: [
2345
- /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Paragraph, { className: "w-full", children: "Amount to Pay" }),
2346
- /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
2347
- Input,
2348
- {
2349
- testid: testid ? `${testid}-amount-to-pay` : void 0,
2350
- type: "number",
2351
- placeholder: "$0.00",
2352
- align: "right",
2353
- value: amount === 0 ? "" : amount,
2354
- onChange: handleAmountChange,
2355
- before: "$"
2356
- }
2357
- ) })
2358
- ] }) }),
2359
- /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
2360
- SelectPaymentMethod,
2361
- __spreadProps(__spreadValues({}, paymentProps), {
2362
- testid: testid ? `${testid}-select-payment-method` : void 0,
2363
- amountToPay: amount + creditCardSurcharge,
2364
- cardPaymentUrl,
2365
- setCardPaymentUrl,
2366
- isLoadingCCiframe
2367
- })
2368
- )
2369
- ] }) });
2370
- }
2371
- function calculateSurcharge(amountInDollars, surchargeRate) {
2372
- const amountInCents = amountInDollars * 100;
2373
- const surchargeInCents = amountInCents * surchargeRate / 100;
2374
- const roundedSurchargeInCents = Math.round(surchargeInCents);
2375
- return roundedSurchargeInCents / 100;
2376
- }
2377
- // Annotate the CommonJS export names for ESM import in node:
2378
- 0 && (module.exports = {
2379
- PaymentOnAccountModal,
2380
- calculateSurcharge
2381
- });