@btndprojects/loam-ui-native 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +55 -2
- package/dist/accordion/index.js +3 -0
- package/dist/adaptive/index.js +2 -0
- package/dist/alert/index.js +3 -0
- package/dist/analyzer/index.js +6 -0
- package/dist/announcement/index.js +6 -0
- package/dist/audio-player/index.js +3 -0
- package/dist/avatar/index.js +3 -0
- package/dist/avatar-group/index.js +3 -0
- package/dist/badge/index.js +5 -0
- package/dist/banner/index.js +2 -0
- package/dist/board/index.js +7 -0
- package/dist/button/index.js +5 -0
- package/dist/camera-permission/index.js +13 -0
- package/dist/capture-result/index.js +18 -0
- package/dist/card/index.js +4 -0
- package/dist/card-form/index.js +10 -0
- package/dist/carousel/index.js +2 -0
- package/dist/chart/index.js +6 -0
- package/dist/charts/index.js +7 -0
- package/dist/checkbox/index.js +7 -0
- package/dist/checklist/index.js +10 -0
- package/dist/checkout/index.js +13 -0
- package/dist/chip/index.js +7 -0
- package/dist/chunk-223Q2T2Q.js +229 -0
- package/dist/chunk-2A5NIQAK.js +254 -0
- package/dist/chunk-2GK6PHGE.js +363 -0
- package/dist/chunk-2WUTXHMU.js +1 -0
- package/dist/chunk-2ZZ7TDJ4.js +324 -0
- package/dist/chunk-35OFI3JG.js +499 -0
- package/dist/chunk-3ARE4TES.js +195 -0
- package/dist/chunk-3ECPOSKO.js +1 -0
- package/dist/chunk-3ENTMPQY.js +229 -0
- package/dist/chunk-3HJH6FF4.js +98 -0
- package/dist/chunk-3NMD74ZU.js +4 -0
- package/dist/chunk-3WPW4KUN.js +182 -0
- package/dist/chunk-423B7SPN.js +993 -0
- package/dist/chunk-47FWHGUN.js +394 -0
- package/dist/chunk-4BXMXBJO.js +141 -0
- package/dist/chunk-4DS5ZWVC.js +83 -0
- package/dist/chunk-4GBOGOTV.js +295 -0
- package/dist/chunk-4SZYY6AN.js +99 -0
- package/dist/chunk-4YIP3CWS.js +237 -0
- package/dist/chunk-4YQOR7JM.js +204 -0
- package/dist/chunk-4ZAHCY44.js +177 -0
- package/dist/chunk-52X2VYTD.js +228 -0
- package/dist/chunk-5P26LBDL.js +1 -0
- package/dist/chunk-5XLRYDAX.js +1 -0
- package/dist/chunk-5YNTNN5A.js +177 -0
- package/dist/chunk-6HT2LP62.js +504 -0
- package/dist/chunk-6N33LFQA.js +35 -0
- package/dist/chunk-6X6PQ443.js +432 -0
- package/dist/chunk-7CFF4HXS.js +126 -0
- package/dist/chunk-7O2FMUPT.js +755 -0
- package/dist/chunk-AI4DWZCD.js +162 -0
- package/dist/chunk-AWJOCGFZ.js +213 -0
- package/dist/chunk-AZRX6SAC.js +285 -0
- package/dist/chunk-B54QE2FN.js +1 -0
- package/dist/chunk-BC475SJH.js +1 -0
- package/dist/chunk-BEDBFJND.js +202 -0
- package/dist/chunk-BTTFCMKG.js +166 -0
- package/dist/chunk-BV3B2HYZ.js +1635 -0
- package/dist/chunk-C2NTXVWM.js +98 -0
- package/dist/chunk-CDRZHT42.js +424 -0
- package/dist/chunk-CJ5EOYZE.js +62 -0
- package/dist/chunk-CUMUNPXY.js +128 -0
- package/dist/chunk-CUS3ZSCU.js +1 -0
- package/dist/chunk-CYRBHQQZ.js +411 -0
- package/dist/chunk-DHWADYZX.js +144 -0
- package/dist/chunk-DKCSPATL.js +1 -0
- package/dist/chunk-DM5QUKKO.js +326 -0
- package/dist/chunk-DYBH2I6W.js +1 -0
- package/dist/chunk-DZ255O2F.js +1 -0
- package/dist/chunk-E35BPSGW.js +1 -0
- package/dist/chunk-EJBDRVIH.js +166 -0
- package/dist/chunk-F43NP42L.js +1 -0
- package/dist/chunk-F5XNPWS7.js +1024 -0
- package/dist/chunk-FMYDDECK.js +1521 -0
- package/dist/chunk-G3HOYSF7.js +1 -0
- package/dist/chunk-GDKZTW34.js +395 -0
- package/dist/chunk-GL7B2DOW.js +134 -0
- package/dist/chunk-GNNJ4GCC.js +471 -0
- package/dist/chunk-GNZ56EUI.js +1 -0
- package/dist/chunk-H6NIOQHK.js +346 -0
- package/dist/chunk-H6PC7RDA.js +1 -0
- package/dist/chunk-HET4LLMX.js +129 -0
- package/dist/chunk-HPPW424V.js +334 -0
- package/dist/chunk-HQOQIBJI.js +1 -0
- package/dist/chunk-HU2EQNRZ.js +44 -0
- package/dist/chunk-HZ6CNMAF.js +870 -0
- package/dist/chunk-IIQTAY3J.js +715 -0
- package/dist/chunk-ITTYJZWX.js +271 -0
- package/dist/chunk-IVNRBPGC.js +1018 -0
- package/dist/chunk-J4KLDGI4.js +1 -0
- package/dist/chunk-J7Q7VCVC.js +254 -0
- package/dist/chunk-JDEOITQ2.js +1 -0
- package/dist/chunk-JNH2TYIN.js +96 -0
- package/dist/chunk-JNY4ZHAR.js +634 -0
- package/dist/chunk-JRLTGLN4.js +1 -0
- package/dist/chunk-JTRJJLKL.js +1 -0
- package/dist/chunk-JUAMLEHX.js +379 -0
- package/dist/chunk-JXJB2X6M.js +131 -0
- package/dist/chunk-KMI5ML5I.js +262 -0
- package/dist/chunk-KTAC4MGE.js +4 -0
- package/dist/chunk-LAECSR4H.js +178 -0
- package/dist/chunk-LK4BCSGX.js +1 -0
- package/dist/chunk-LOE5YNN3.js +470 -0
- package/dist/chunk-LRJNDEIA.js +302 -0
- package/dist/chunk-LSS54GLJ.js +116 -0
- package/dist/chunk-LZLHELAG.js +137 -0
- package/dist/chunk-M2LUXGKZ.js +1 -0
- package/dist/chunk-MOUJOP55.js +425 -0
- package/dist/chunk-N32RGOA5.js +159 -0
- package/dist/chunk-N5ZNE2YE.js +1 -0
- package/dist/chunk-NBNCBML6.js +1 -0
- package/dist/chunk-NKB7BZYK.js +167 -0
- package/dist/chunk-NQYBUO3K.js +1795 -0
- package/dist/chunk-NY2U3PBI.js +59 -0
- package/dist/chunk-O4AEHWII.js +464 -0
- package/dist/chunk-O7AE6DAF.js +146 -0
- package/dist/chunk-OETCUXQP.js +134 -0
- package/dist/chunk-OOPPQH27.js +179 -0
- package/dist/chunk-OPXFZ4Y5.js +204 -0
- package/dist/chunk-P23EQNRQ.js +338 -0
- package/dist/chunk-PJXUJYS6.js +248 -0
- package/dist/chunk-PNWUWOBF.js +1 -0
- package/dist/chunk-PUPM2YGF.js +376 -0
- package/dist/chunk-PZXZJBMP.js +620 -0
- package/dist/chunk-Q72LJOVE.js +169 -0
- package/dist/chunk-QCDXZBC5.js +247 -0
- package/dist/chunk-QDYDBCFP.js +197 -0
- package/dist/chunk-QJJ6MADV.js +274 -0
- package/dist/chunk-QKXCPTFS.js +349 -0
- package/dist/chunk-QWCMU5B2.js +860 -0
- package/dist/chunk-RIBDXGUG.js +108 -0
- package/dist/chunk-RJQOOHT2.js +214 -0
- package/dist/chunk-RNGLIHFA.js +191 -0
- package/dist/chunk-RQ3HASCC.js +6 -0
- package/dist/chunk-RSOJT5YW.js +124 -0
- package/dist/chunk-RTIKSY6A.js +1 -0
- package/dist/chunk-RUZHTGKB.js +237 -0
- package/dist/chunk-RW6ZL2FQ.js +284 -0
- package/dist/chunk-S7F6XLTK.js +540 -0
- package/dist/chunk-SBMNWWBV.js +155 -0
- package/dist/chunk-SDTQPRRB.js +1 -0
- package/dist/chunk-SYNOJOQO.js +377 -0
- package/dist/chunk-T753XT36.js +1 -0
- package/dist/chunk-TKQYWZ5V.js +196 -0
- package/dist/chunk-TKVFVF5D.js +95 -0
- package/dist/chunk-TOXAGRDQ.js +144 -0
- package/dist/chunk-TUTI5HOZ.js +112 -0
- package/dist/chunk-U7TFM2JA.js +140 -0
- package/dist/chunk-UC2WGUP3.js +627 -0
- package/dist/chunk-UWFLYMAR.js +1126 -0
- package/dist/chunk-UWSZB7BJ.js +1 -0
- package/dist/chunk-UYG5L34B.js +87 -0
- package/dist/chunk-VBOXAEPI.js +336 -0
- package/dist/chunk-VCDBXW5H.js +188 -0
- package/dist/chunk-VCXPHHDS.js +1 -0
- package/dist/chunk-VEAYTRPX.js +414 -0
- package/dist/chunk-VFCUIDRT.js +1 -0
- package/dist/chunk-VQHPQEUH.js +273 -0
- package/dist/chunk-VXDZFJGP.js +874 -0
- package/dist/chunk-WS56BL3D.js +1 -0
- package/dist/chunk-WSW6ZFAQ.js +98 -0
- package/dist/chunk-XNUVB5OL.js +375 -0
- package/dist/chunk-XOSCY2CW.js +242 -0
- package/dist/chunk-XXXEFXY5.js +99 -0
- package/dist/chunk-Y5CSSPV4.js +1 -0
- package/dist/chunk-Y6DU4J47.js +1 -0
- package/dist/chunk-YC6WORFL.js +535 -0
- package/dist/chunk-YDGVJETP.js +60 -0
- package/dist/chunk-YF4NSSMT.js +366 -0
- package/dist/chunk-YG3ZJHGU.js +223 -0
- package/dist/chunk-YIJ55TBC.js +1 -0
- package/dist/chunk-YKZ4RZZF.js +1 -0
- package/dist/chunk-YLLCXTMC.js +37 -0
- package/dist/chunk-YTA74UZR.js +1 -0
- package/dist/chunk-YTFKPRUK.js +845 -0
- package/dist/chunk-Z7H7VSFZ.js +323 -0
- package/dist/chunk-ZK2H4O5P.js +1 -0
- package/dist/chunk-ZVFE5QGU.js +524 -0
- package/dist/coachmark/index.js +4 -0
- package/dist/code-block/index.js +4 -0
- package/dist/color-field/index.js +7 -0
- package/dist/commerce/index.js +20 -0
- package/dist/connectivity/index.js +2 -0
- package/dist/context-menu/index.js +5 -0
- package/dist/copy-button/index.js +3 -0
- package/dist/data-grid/index.js +24 -0
- package/dist/date-range-picker/index.js +13 -0
- package/dist/description-list/index.js +2 -0
- package/dist/dialog/index.js +3 -0
- package/dist/empty-state/index.js +3 -0
- package/dist/error-summary/index.js +3 -0
- package/dist/fab/index.js +2 -0
- package/dist/file-upload/index.js +9 -0
- package/dist/filter-bar/index.js +8 -0
- package/dist/flow-run/index.js +14 -0
- package/dist/form/index.js +3 -0
- package/dist/gallery/index.js +2 -0
- package/dist/header/index.js +5 -0
- package/dist/hold-to-confirm/index.js +4 -0
- package/dist/index.d.ts +22883 -0
- package/dist/index.js +158 -0
- package/dist/infinite-list/index.js +2 -0
- package/dist/inline-edit/index.js +5 -0
- package/dist/input/index.js +5 -0
- package/dist/interactions/index.js +2 -0
- package/dist/invoice/index.js +10 -0
- package/dist/kbd/index.js +1 -0
- package/dist/keyboard/index.js +3 -0
- package/dist/list-row/index.js +7 -0
- package/dist/log-viewer/index.js +2 -0
- package/dist/map-view/index.js +3 -0
- package/dist/markdown/index.js +6 -0
- package/dist/metric/index.js +4 -0
- package/dist/money/index.js +3 -0
- package/dist/nav-drawer/index.js +2 -0
- package/dist/navigation/index.js +2 -0
- package/dist/notification-center/index.js +16 -0
- package/dist/number-roll/index.js +3 -0
- package/dist/one-handed/index.js +5 -0
- package/dist/os-surfaces/index.js +3 -0
- package/dist/otp/index.js +7 -0
- package/dist/page-header/index.js +1 -0
- package/dist/payment-method/index.js +12 -0
- package/dist/payment-status/index.js +16 -0
- package/dist/permission/index.js +2 -0
- package/dist/picker/index.js +7 -0
- package/dist/progress/index.js +5 -0
- package/dist/pull-to-refresh/index.js +4 -0
- package/dist/radio-group/index.js +6 -0
- package/dist/rating/index.js +2 -0
- package/dist/receivables/index.js +20 -0
- package/dist/refund/index.js +16 -0
- package/dist/save-status/index.js +3 -0
- package/dist/scroll-area/index.js +1 -0
- package/dist/search-bar/index.js +5 -0
- package/dist/segmented-control/index.js +5 -0
- package/dist/sheet/index.js +4 -0
- package/dist/skeleton/index.js +2 -0
- package/dist/slider/index.js +5 -0
- package/dist/spinner/index.js +2 -0
- package/dist/split-button/index.js +7 -0
- package/dist/spotlight/index.js +2 -0
- package/dist/stage-timeline/index.js +4 -0
- package/dist/status-dot/index.js +2 -0
- package/dist/stepper/index.js +6 -0
- package/dist/streaming-text/index.js +3 -0
- package/dist/survey/index.js +19 -0
- package/dist/switch/index.js +5 -0
- package/dist/system-state/index.js +4 -0
- package/dist/tab-bar/index.js +2 -0
- package/dist/tabs/index.js +2 -0
- package/dist/textarea/index.js +6 -0
- package/dist/thinking/index.js +2 -0
- package/dist/timeline/index.js +4 -0
- package/dist/toast/index.js +2 -0
- package/dist/toolbar/index.js +2 -0
- package/dist/tour/index.js +11 -0
- package/dist/truncation-notice/index.js +2 -0
- package/dist/update-notice/index.js +11 -0
- package/dist/video-player/index.js +2 -0
- package/dist/viewfinder/index.js +5 -0
- package/dist/widget/index.js +4 -0
- package/dist/wizard/index.js +6 -0
- package/package.json +76 -3
|
@@ -0,0 +1,845 @@
|
|
|
1
|
+
import { RadioGroup, RadioGroupItem } from './chunk-4YIP3CWS.js';
|
|
2
|
+
import { SegmentedControl } from './chunk-5YNTNN5A.js';
|
|
3
|
+
import { Checkbox } from './chunk-JXJB2X6M.js';
|
|
4
|
+
import { Amount, PriceRow } from './chunk-VBOXAEPI.js';
|
|
5
|
+
import { Chip } from './chunk-AI4DWZCD.js';
|
|
6
|
+
import { TextField } from './chunk-ITTYJZWX.js';
|
|
7
|
+
import { Badge } from './chunk-SBMNWWBV.js';
|
|
8
|
+
import { Alert } from './chunk-OETCUXQP.js';
|
|
9
|
+
import { Button } from './chunk-3ARE4TES.js';
|
|
10
|
+
import { Icon } from './chunk-TKVFVF5D.js';
|
|
11
|
+
import * as React from 'react';
|
|
12
|
+
import { View, Text } from 'react-native';
|
|
13
|
+
import { createStyleSheet, useLoamTheme, useStyles } from '@btndprojects/loam-theme-native';
|
|
14
|
+
import { ARRIVAL, refundRemaining, refundLedger, REFUND_REASONS, money, parseAmount, clampRefund, REFUND_FRACTIONS, refundFraction, evidenceTone, evidenceLabel, disputeWorthDefending, DISPUTE_ACCEPT_THRESHOLD_MINOR } from '@btndprojects/loam-pay';
|
|
15
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
16
|
+
|
|
17
|
+
var REFUND_STATE = {
|
|
18
|
+
requested: { label: "Requested", variant: "neutral" },
|
|
19
|
+
processing: { label: "Processing", variant: "info" },
|
|
20
|
+
sent: { label: "Sent", variant: "info" },
|
|
21
|
+
arrived: { label: "Arrived", variant: "good" },
|
|
22
|
+
failed: { label: "Failed", variant: "danger" }
|
|
23
|
+
};
|
|
24
|
+
function RefundStatus({ state, label }) {
|
|
25
|
+
const meta = REFUND_STATE[state];
|
|
26
|
+
return /* @__PURE__ */ jsx(Badge, { variant: meta.variant, size: "sm", dot: true, children: label ?? meta.label });
|
|
27
|
+
}
|
|
28
|
+
function RefundArrivalNote({
|
|
29
|
+
method,
|
|
30
|
+
window: text,
|
|
31
|
+
inline = false,
|
|
32
|
+
style
|
|
33
|
+
}) {
|
|
34
|
+
const theme = useLoamTheme();
|
|
35
|
+
const { styles } = useStyles(sheet);
|
|
36
|
+
const body = text ?? ARRIVAL[method];
|
|
37
|
+
return /* @__PURE__ */ jsxs(View, { style: [inline ? styles.arrivalInline : styles.arrivalBlock, style], children: [
|
|
38
|
+
/* @__PURE__ */ jsx(
|
|
39
|
+
Icon,
|
|
40
|
+
{
|
|
41
|
+
name: "clock",
|
|
42
|
+
size: theme.icon.sm,
|
|
43
|
+
color: inline ? theme.color.text3 : theme.color.infoOnSoft
|
|
44
|
+
}
|
|
45
|
+
),
|
|
46
|
+
/* @__PURE__ */ jsx(Text, { style: inline ? styles.arrivalInlineBody : styles.arrivalBlockBody, children: body })
|
|
47
|
+
] });
|
|
48
|
+
}
|
|
49
|
+
function RefundRemainingNote({
|
|
50
|
+
charge,
|
|
51
|
+
currency,
|
|
52
|
+
label = "still refundable",
|
|
53
|
+
locale,
|
|
54
|
+
style
|
|
55
|
+
}) {
|
|
56
|
+
const { styles } = useStyles(sheet);
|
|
57
|
+
const code = currency ?? charge.currency ?? "USD";
|
|
58
|
+
return /* @__PURE__ */ jsxs(View, { style: [styles.remaining, style], children: [
|
|
59
|
+
/* @__PURE__ */ jsx(
|
|
60
|
+
Amount,
|
|
61
|
+
{
|
|
62
|
+
minor: refundRemaining(charge),
|
|
63
|
+
currency: code,
|
|
64
|
+
size: "sm",
|
|
65
|
+
weight: "bold",
|
|
66
|
+
locale
|
|
67
|
+
}
|
|
68
|
+
),
|
|
69
|
+
/* @__PURE__ */ jsx(Text, { style: styles.remainingWord, children: "of" }),
|
|
70
|
+
/* @__PURE__ */ jsx(Amount, { minor: charge.amountMinor, currency: code, size: "sm", locale }),
|
|
71
|
+
/* @__PURE__ */ jsx(Text, { style: styles.remainingWord, children: label })
|
|
72
|
+
] });
|
|
73
|
+
}
|
|
74
|
+
function RefundLedger({
|
|
75
|
+
charge,
|
|
76
|
+
next = 0,
|
|
77
|
+
currency,
|
|
78
|
+
caption,
|
|
79
|
+
locale,
|
|
80
|
+
style
|
|
81
|
+
}) {
|
|
82
|
+
const { styles } = useStyles(sheet);
|
|
83
|
+
const code = currency ?? charge.currency ?? "USD";
|
|
84
|
+
const rows = refundLedger(charge, next);
|
|
85
|
+
return /* @__PURE__ */ jsxs(View, { style: [styles.ledger, style], children: [
|
|
86
|
+
/* @__PURE__ */ jsx(Text, { style: styles.overline, children: caption ?? `Refund ledger \xB7 ${code}` }),
|
|
87
|
+
rows.map((row) => /* @__PURE__ */ jsx(
|
|
88
|
+
PriceRow,
|
|
89
|
+
{
|
|
90
|
+
label: row.label,
|
|
91
|
+
minor: row.amountMinor,
|
|
92
|
+
currency: code,
|
|
93
|
+
tone: row.tone === "good" ? "good" : void 0,
|
|
94
|
+
strong: row.strong,
|
|
95
|
+
rule: row.strong,
|
|
96
|
+
noSymbol: true,
|
|
97
|
+
locale
|
|
98
|
+
},
|
|
99
|
+
row.label
|
|
100
|
+
))
|
|
101
|
+
] });
|
|
102
|
+
}
|
|
103
|
+
function RefundReasonList({
|
|
104
|
+
value,
|
|
105
|
+
onChange,
|
|
106
|
+
reasons = REFUND_REASONS,
|
|
107
|
+
label = "Reason",
|
|
108
|
+
showNotes = true
|
|
109
|
+
}) {
|
|
110
|
+
const { styles } = useStyles(sheet);
|
|
111
|
+
return /* @__PURE__ */ jsx(
|
|
112
|
+
RadioGroup,
|
|
113
|
+
{
|
|
114
|
+
label,
|
|
115
|
+
value: value ?? void 0,
|
|
116
|
+
onValueChange: (next) => onChange(next),
|
|
117
|
+
children: reasons.map(([id, text, note]) => /* @__PURE__ */ jsxs(View, { style: styles.reasonRow, children: [
|
|
118
|
+
/* @__PURE__ */ jsx(RadioGroupItem, { value: id, label: text, accessibilityLabel: `${text}. ${note}` }),
|
|
119
|
+
showNotes ? /* @__PURE__ */ jsx(Text, { style: styles.reasonNote, children: note }) : null
|
|
120
|
+
] }, id))
|
|
121
|
+
}
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
function RefundAmountField({
|
|
125
|
+
valueMinor,
|
|
126
|
+
onChangeMinor,
|
|
127
|
+
remaining,
|
|
128
|
+
currency,
|
|
129
|
+
label = "Refund amount",
|
|
130
|
+
hint,
|
|
131
|
+
error,
|
|
132
|
+
fractions = REFUND_FRACTIONS,
|
|
133
|
+
disabled = false,
|
|
134
|
+
locale,
|
|
135
|
+
style
|
|
136
|
+
}) {
|
|
137
|
+
const { styles } = useStyles(sheet);
|
|
138
|
+
const [draft, setDraft] = React.useState(null);
|
|
139
|
+
const display = draft ?? money(valueMinor, currency, { noSymbol: true, locale });
|
|
140
|
+
const maxText = money(remaining, currency, { locale });
|
|
141
|
+
const chips = fractions === false ? [] : fractions;
|
|
142
|
+
return /* @__PURE__ */ jsxs(View, { style: [styles.amountBlock, style], children: [
|
|
143
|
+
/* @__PURE__ */ jsx(
|
|
144
|
+
TextField,
|
|
145
|
+
{
|
|
146
|
+
label,
|
|
147
|
+
hint: hint ?? `Up to ${maxText}.`,
|
|
148
|
+
error,
|
|
149
|
+
value: display,
|
|
150
|
+
editable: !disabled,
|
|
151
|
+
inputMode: "decimal",
|
|
152
|
+
autoComplete: "off",
|
|
153
|
+
autoCorrect: false,
|
|
154
|
+
keyboardType: "decimal-pad",
|
|
155
|
+
onChangeText: (text) => {
|
|
156
|
+
setDraft(text);
|
|
157
|
+
const parsed = parseAmount(text, currency);
|
|
158
|
+
onChangeMinor(clampRefund(parsed ?? 0, remaining));
|
|
159
|
+
},
|
|
160
|
+
onBlur: () => setDraft(null)
|
|
161
|
+
}
|
|
162
|
+
),
|
|
163
|
+
chips.length > 0 ? /* @__PURE__ */ jsx(View, { style: styles.chipRow, children: chips.map((percent) => {
|
|
164
|
+
const target = refundFraction(percent, remaining);
|
|
165
|
+
return /* @__PURE__ */ jsx(
|
|
166
|
+
Chip,
|
|
167
|
+
{
|
|
168
|
+
variant: "filter",
|
|
169
|
+
size: "sm",
|
|
170
|
+
disabled,
|
|
171
|
+
selected: !disabled && valueMinor === target && remaining > 0,
|
|
172
|
+
accessibilityLabel: `Refund ${percent}% \u2014 ${money(target, currency, { locale })}`,
|
|
173
|
+
onSelectedChange: () => {
|
|
174
|
+
setDraft(null);
|
|
175
|
+
onChangeMinor(target);
|
|
176
|
+
},
|
|
177
|
+
children: `${percent}%`
|
|
178
|
+
},
|
|
179
|
+
percent
|
|
180
|
+
);
|
|
181
|
+
}) }) : null
|
|
182
|
+
] });
|
|
183
|
+
}
|
|
184
|
+
var sheet = createStyleSheet((theme) => ({
|
|
185
|
+
arrivalBlock: {
|
|
186
|
+
flexDirection: "row",
|
|
187
|
+
alignItems: "flex-start",
|
|
188
|
+
gap: theme.space.s2,
|
|
189
|
+
padding: theme.space.s3,
|
|
190
|
+
borderRadius: theme.radius.md,
|
|
191
|
+
// The soft tint always carries its tone edge: it collapses to the plain
|
|
192
|
+
// surface under high contrast, where the edge is all that draws it.
|
|
193
|
+
borderWidth: theme.borderWidth.base,
|
|
194
|
+
borderColor: theme.edge.info,
|
|
195
|
+
backgroundColor: theme.color.infoSoft
|
|
196
|
+
},
|
|
197
|
+
arrivalBlockBody: {
|
|
198
|
+
flexShrink: 1,
|
|
199
|
+
fontFamily: theme.font.sans,
|
|
200
|
+
fontSize: theme.type.footnote.fontSize,
|
|
201
|
+
lineHeight: theme.type.footnote.fontSize * theme.lineHeight.normal,
|
|
202
|
+
color: theme.color.infoOnSoft
|
|
203
|
+
},
|
|
204
|
+
arrivalInline: { flexDirection: "row", alignItems: "flex-start", gap: theme.space.s2 },
|
|
205
|
+
arrivalInlineBody: {
|
|
206
|
+
flexShrink: 1,
|
|
207
|
+
fontFamily: theme.font.sans,
|
|
208
|
+
fontSize: theme.type.footnote.fontSize,
|
|
209
|
+
lineHeight: theme.type.footnote.fontSize * theme.lineHeight.normal,
|
|
210
|
+
color: theme.color.text2
|
|
211
|
+
},
|
|
212
|
+
remaining: {
|
|
213
|
+
flexDirection: "row",
|
|
214
|
+
flexWrap: "wrap",
|
|
215
|
+
alignItems: "baseline",
|
|
216
|
+
gap: theme.space.s1
|
|
217
|
+
},
|
|
218
|
+
remainingWord: {
|
|
219
|
+
fontFamily: theme.font.sans,
|
|
220
|
+
fontSize: theme.type.footnote.fontSize,
|
|
221
|
+
lineHeight: theme.type.footnote.lineHeight,
|
|
222
|
+
color: theme.color.text2
|
|
223
|
+
},
|
|
224
|
+
ledger: {
|
|
225
|
+
alignSelf: "stretch",
|
|
226
|
+
gap: theme.space.s2,
|
|
227
|
+
padding: theme.space.s4,
|
|
228
|
+
borderRadius: theme.radius.md,
|
|
229
|
+
borderWidth: theme.borderWidth.base,
|
|
230
|
+
borderColor: theme.color.border,
|
|
231
|
+
backgroundColor: theme.color.surface2
|
|
232
|
+
},
|
|
233
|
+
overline: {
|
|
234
|
+
fontFamily: theme.font.sans,
|
|
235
|
+
fontWeight: theme.fontWeight.bold,
|
|
236
|
+
fontSize: theme.type.caption2.fontSize,
|
|
237
|
+
lineHeight: theme.type.caption2.lineHeight,
|
|
238
|
+
letterSpacing: theme.tracking.caps,
|
|
239
|
+
textTransform: "uppercase",
|
|
240
|
+
color: theme.color.text3
|
|
241
|
+
},
|
|
242
|
+
reasonRow: { gap: theme.space[2] },
|
|
243
|
+
reasonNote: {
|
|
244
|
+
marginStart: theme.space.s7,
|
|
245
|
+
fontFamily: theme.font.sans,
|
|
246
|
+
fontSize: theme.type.caption1.fontSize,
|
|
247
|
+
lineHeight: theme.type.caption1.fontSize * theme.lineHeight.normal,
|
|
248
|
+
color: theme.color.text3
|
|
249
|
+
},
|
|
250
|
+
amountBlock: { alignSelf: "stretch", gap: theme.space.s2 },
|
|
251
|
+
chipRow: {
|
|
252
|
+
flexDirection: "row",
|
|
253
|
+
flexWrap: "wrap",
|
|
254
|
+
alignItems: "center",
|
|
255
|
+
gap: theme.space.s1
|
|
256
|
+
}
|
|
257
|
+
}));
|
|
258
|
+
function RefundConfirmation({
|
|
259
|
+
charge,
|
|
260
|
+
result,
|
|
261
|
+
method,
|
|
262
|
+
currency,
|
|
263
|
+
title = "Refund issued",
|
|
264
|
+
refundAnotherLabel = "Refund another charge",
|
|
265
|
+
onRefundAnother,
|
|
266
|
+
actions,
|
|
267
|
+
locale,
|
|
268
|
+
style
|
|
269
|
+
}) {
|
|
270
|
+
const theme = useLoamTheme();
|
|
271
|
+
const { styles } = useStyles(sheet2);
|
|
272
|
+
const code = currency ?? charge.currency ?? "USD";
|
|
273
|
+
return /* @__PURE__ */ jsxs(
|
|
274
|
+
View,
|
|
275
|
+
{
|
|
276
|
+
role: "status",
|
|
277
|
+
accessibilityLiveRegion: "polite",
|
|
278
|
+
accessibilityLabel: title,
|
|
279
|
+
style: [styles.panel, style],
|
|
280
|
+
...{ "aria-live": "polite" },
|
|
281
|
+
children: [
|
|
282
|
+
/* @__PURE__ */ jsxs(View, { style: styles.confirmHead, children: [
|
|
283
|
+
/* @__PURE__ */ jsx(
|
|
284
|
+
View,
|
|
285
|
+
{
|
|
286
|
+
"aria-hidden": true,
|
|
287
|
+
accessibilityElementsHidden: true,
|
|
288
|
+
importantForAccessibility: "no-hide-descendants",
|
|
289
|
+
style: styles.checkPlate,
|
|
290
|
+
children: /* @__PURE__ */ jsx(
|
|
291
|
+
Icon,
|
|
292
|
+
{
|
|
293
|
+
name: "check",
|
|
294
|
+
size: theme.icon.md,
|
|
295
|
+
color: theme.color.goodOnSoft,
|
|
296
|
+
strokeWidth: theme.icon.strokeBold
|
|
297
|
+
}
|
|
298
|
+
)
|
|
299
|
+
}
|
|
300
|
+
),
|
|
301
|
+
/* @__PURE__ */ jsx(Text, { accessibilityRole: "header", style: styles.title, children: title }),
|
|
302
|
+
/* @__PURE__ */ jsx(Amount, { minor: result.amountMinor, currency: code, size: "hero", locale }),
|
|
303
|
+
/* @__PURE__ */ jsxs(View, { style: styles.confirmMeta, children: [
|
|
304
|
+
/* @__PURE__ */ jsx(RefundStatus, { state: result.state }),
|
|
305
|
+
result.issuedLabel ? /* @__PURE__ */ jsx(Text, { style: styles.meta, children: result.issuedLabel }) : null,
|
|
306
|
+
result.refundId ? /* @__PURE__ */ jsx(Text, { style: styles.mono, children: result.refundId }) : null
|
|
307
|
+
] })
|
|
308
|
+
] }),
|
|
309
|
+
/* @__PURE__ */ jsx(RefundArrivalNote, { method }),
|
|
310
|
+
/* @__PURE__ */ jsx(RefundLedger, { charge, next: result.amountMinor, currency: code, locale }),
|
|
311
|
+
/* @__PURE__ */ jsxs(View, { style: styles.actionRow, children: [
|
|
312
|
+
onRefundAnother ? /* @__PURE__ */ jsx(Button, { variant: "outline", onPress: onRefundAnother, children: refundAnotherLabel }) : null,
|
|
313
|
+
actions
|
|
314
|
+
] })
|
|
315
|
+
]
|
|
316
|
+
}
|
|
317
|
+
);
|
|
318
|
+
}
|
|
319
|
+
function RefundPanel({
|
|
320
|
+
charge,
|
|
321
|
+
method,
|
|
322
|
+
mode,
|
|
323
|
+
amountMinor,
|
|
324
|
+
reason,
|
|
325
|
+
notify,
|
|
326
|
+
currency,
|
|
327
|
+
title = "Refund",
|
|
328
|
+
chargeLabel,
|
|
329
|
+
error,
|
|
330
|
+
result,
|
|
331
|
+
busy = false,
|
|
332
|
+
notifyLabel = "Email the customer",
|
|
333
|
+
irreversibleNote = "A refund cannot be undone. Check the amount before you issue it.",
|
|
334
|
+
onModeChange,
|
|
335
|
+
onAmountChange,
|
|
336
|
+
onReasonChange,
|
|
337
|
+
onNotifyChange,
|
|
338
|
+
onSubmit,
|
|
339
|
+
onRefundAnother,
|
|
340
|
+
locale,
|
|
341
|
+
style
|
|
342
|
+
}) {
|
|
343
|
+
const theme = useLoamTheme();
|
|
344
|
+
const { styles } = useStyles(sheet2);
|
|
345
|
+
const code = currency ?? charge.currency ?? "USD";
|
|
346
|
+
const remaining = refundRemaining(charge);
|
|
347
|
+
const effective = mode === "full" ? remaining : amountMinor;
|
|
348
|
+
const reasonRow = reason === null ? void 0 : REFUND_REASONS.find(([id]) => id === reason);
|
|
349
|
+
if (result) {
|
|
350
|
+
return /* @__PURE__ */ jsx(
|
|
351
|
+
RefundConfirmation,
|
|
352
|
+
{
|
|
353
|
+
charge,
|
|
354
|
+
result,
|
|
355
|
+
method,
|
|
356
|
+
currency: code,
|
|
357
|
+
onRefundAnother,
|
|
358
|
+
locale,
|
|
359
|
+
style
|
|
360
|
+
}
|
|
361
|
+
);
|
|
362
|
+
}
|
|
363
|
+
return /* @__PURE__ */ jsxs(View, { role: "region", accessibilityLabel: title, style: [styles.panel, style], children: [
|
|
364
|
+
/* @__PURE__ */ jsxs(View, { style: styles.header, children: [
|
|
365
|
+
/* @__PURE__ */ jsxs(View, { style: styles.headerRow, children: [
|
|
366
|
+
/* @__PURE__ */ jsx(Text, { accessibilityRole: "header", style: styles.title, children: title }),
|
|
367
|
+
charge.receiptId ? /* @__PURE__ */ jsx(View, { style: styles.pushEnd, children: /* @__PURE__ */ jsx(Text, { style: styles.mono, children: charge.receiptId }) }) : null
|
|
368
|
+
] }),
|
|
369
|
+
chargeLabel ? /* @__PURE__ */ jsx(Text, { style: styles.chargeLabel, children: chargeLabel }) : null,
|
|
370
|
+
/* @__PURE__ */ jsx(RefundRemainingNote, { charge, currency: code, locale })
|
|
371
|
+
] }),
|
|
372
|
+
onModeChange ? /* @__PURE__ */ jsx(
|
|
373
|
+
SegmentedControl,
|
|
374
|
+
{
|
|
375
|
+
value: mode,
|
|
376
|
+
onValueChange: (next) => onModeChange(next),
|
|
377
|
+
items: [
|
|
378
|
+
{ value: "full", label: "Full" },
|
|
379
|
+
{ value: "partial", label: "Partial" }
|
|
380
|
+
]
|
|
381
|
+
}
|
|
382
|
+
) : /* @__PURE__ */ jsx(
|
|
383
|
+
Stated,
|
|
384
|
+
{
|
|
385
|
+
label: mode === "full" ? "Full refund" : "Partial refund",
|
|
386
|
+
overline: "Amount mode"
|
|
387
|
+
}
|
|
388
|
+
),
|
|
389
|
+
mode === "full" ? /* @__PURE__ */ jsxs(View, { style: styles.fullBox, children: [
|
|
390
|
+
/* @__PURE__ */ jsx(Text, { style: styles.fullLabel, children: "Refunding the full remaining balance" }),
|
|
391
|
+
/* @__PURE__ */ jsx(View, { style: styles.pushEnd, children: /* @__PURE__ */ jsx(Amount, { minor: remaining, currency: code, size: "lg", weight: "bold", locale }) })
|
|
392
|
+
] }) : onAmountChange ? /* @__PURE__ */ jsx(
|
|
393
|
+
RefundAmountField,
|
|
394
|
+
{
|
|
395
|
+
valueMinor: amountMinor,
|
|
396
|
+
onChangeMinor: onAmountChange,
|
|
397
|
+
remaining,
|
|
398
|
+
currency: code,
|
|
399
|
+
locale
|
|
400
|
+
}
|
|
401
|
+
) : /* @__PURE__ */ jsxs(View, { style: styles.fullBox, children: [
|
|
402
|
+
/* @__PURE__ */ jsx(Text, { style: styles.fullLabel, children: "Refunding" }),
|
|
403
|
+
/* @__PURE__ */ jsx(View, { style: styles.pushEnd, children: /* @__PURE__ */ jsx(Amount, { minor: amountMinor, currency: code, size: "lg", weight: "bold", locale }) })
|
|
404
|
+
] }),
|
|
405
|
+
onReasonChange ? /* @__PURE__ */ jsx(RefundReasonList, { value: reason, onChange: onReasonChange }) : /* @__PURE__ */ jsx(
|
|
406
|
+
Stated,
|
|
407
|
+
{
|
|
408
|
+
overline: "Reason",
|
|
409
|
+
label: reasonRow ? reasonRow[1] : "Not stated",
|
|
410
|
+
note: reasonRow ? reasonRow[2] : void 0
|
|
411
|
+
}
|
|
412
|
+
),
|
|
413
|
+
onNotifyChange ? /* @__PURE__ */ jsxs(View, { style: styles.notifyRow, children: [
|
|
414
|
+
/* @__PURE__ */ jsx(
|
|
415
|
+
Checkbox,
|
|
416
|
+
{
|
|
417
|
+
checked: notify,
|
|
418
|
+
onCheckedChange: (next) => onNotifyChange(next),
|
|
419
|
+
accessibilityLabel: notifyLabel
|
|
420
|
+
}
|
|
421
|
+
),
|
|
422
|
+
/* @__PURE__ */ jsx(Text, { style: styles.notifyLabel, children: notifyLabel })
|
|
423
|
+
] }) : /* @__PURE__ */ jsx(
|
|
424
|
+
Stated,
|
|
425
|
+
{
|
|
426
|
+
overline: "Customer email",
|
|
427
|
+
label: notify ? `${notifyLabel} \u2014 yes` : `${notifyLabel} \u2014 no`
|
|
428
|
+
}
|
|
429
|
+
),
|
|
430
|
+
/* @__PURE__ */ jsx(RefundLedger, { charge, next: effective, currency: code, locale }),
|
|
431
|
+
/* @__PURE__ */ jsx(RefundArrivalNote, { method }),
|
|
432
|
+
error ? /* @__PURE__ */ jsx(Alert, { tone: "danger", title: error }) : null,
|
|
433
|
+
/* @__PURE__ */ jsxs(View, { style: styles.commitBlock, children: [
|
|
434
|
+
/* @__PURE__ */ jsxs(View, { style: styles.irreversibleRow, children: [
|
|
435
|
+
/* @__PURE__ */ jsx(Icon, { name: "alert-circle", size: theme.icon.sm, color: theme.color.text3 }),
|
|
436
|
+
/* @__PURE__ */ jsx(Text, { style: styles.irreversible, children: irreversibleNote })
|
|
437
|
+
] }),
|
|
438
|
+
/* @__PURE__ */ jsx(Button, { loading: busy, onPress: onSubmit, children: `Refund ${money(effective, code, { locale })}` })
|
|
439
|
+
] })
|
|
440
|
+
] });
|
|
441
|
+
}
|
|
442
|
+
function Stated({
|
|
443
|
+
overline,
|
|
444
|
+
label,
|
|
445
|
+
note
|
|
446
|
+
}) {
|
|
447
|
+
const { styles } = useStyles(sheet2);
|
|
448
|
+
return /* @__PURE__ */ jsxs(View, { style: styles.stated, children: [
|
|
449
|
+
/* @__PURE__ */ jsx(Text, { style: styles.overline, children: overline }),
|
|
450
|
+
/* @__PURE__ */ jsx(Text, { style: styles.statedValue, children: label }),
|
|
451
|
+
note ? /* @__PURE__ */ jsx(Text, { style: styles.statedNote, children: note }) : null
|
|
452
|
+
] });
|
|
453
|
+
}
|
|
454
|
+
var sheet2 = createStyleSheet((theme) => ({
|
|
455
|
+
panel: {
|
|
456
|
+
alignSelf: "stretch",
|
|
457
|
+
gap: theme.space.s5,
|
|
458
|
+
padding: theme.space.s5,
|
|
459
|
+
borderRadius: theme.radius.lg,
|
|
460
|
+
borderWidth: theme.borderWidth.base,
|
|
461
|
+
borderColor: theme.color.border,
|
|
462
|
+
backgroundColor: theme.color.surface
|
|
463
|
+
},
|
|
464
|
+
header: { gap: theme.space.s1 },
|
|
465
|
+
headerRow: {
|
|
466
|
+
flexDirection: "row",
|
|
467
|
+
flexWrap: "wrap",
|
|
468
|
+
alignItems: "baseline",
|
|
469
|
+
gap: theme.space.s2
|
|
470
|
+
},
|
|
471
|
+
title: {
|
|
472
|
+
fontFamily: theme.font.display,
|
|
473
|
+
fontWeight: theme.font.displayWeight,
|
|
474
|
+
fontSize: theme.type.title3.fontSize,
|
|
475
|
+
lineHeight: theme.type.title3.lineHeight,
|
|
476
|
+
letterSpacing: theme.type.title3.letterSpacing,
|
|
477
|
+
color: theme.color.text
|
|
478
|
+
},
|
|
479
|
+
pushEnd: { marginStart: "auto" },
|
|
480
|
+
mono: {
|
|
481
|
+
fontFamily: theme.font.mono,
|
|
482
|
+
fontVariant: ["tabular-nums"],
|
|
483
|
+
fontSize: theme.type.caption1.fontSize,
|
|
484
|
+
lineHeight: theme.type.caption1.lineHeight,
|
|
485
|
+
color: theme.color.text3
|
|
486
|
+
},
|
|
487
|
+
chargeLabel: {
|
|
488
|
+
fontFamily: theme.font.sans,
|
|
489
|
+
fontSize: theme.type.footnote.fontSize,
|
|
490
|
+
lineHeight: theme.type.footnote.fontSize * theme.lineHeight.normal,
|
|
491
|
+
color: theme.color.text2
|
|
492
|
+
},
|
|
493
|
+
fullBox: {
|
|
494
|
+
flexDirection: "row",
|
|
495
|
+
flexWrap: "wrap",
|
|
496
|
+
alignItems: "baseline",
|
|
497
|
+
gap: theme.space.s2,
|
|
498
|
+
padding: theme.space.s4,
|
|
499
|
+
borderRadius: theme.radius.md,
|
|
500
|
+
borderWidth: theme.borderWidth.base,
|
|
501
|
+
borderColor: theme.color.border,
|
|
502
|
+
backgroundColor: theme.color.surface2
|
|
503
|
+
},
|
|
504
|
+
fullLabel: {
|
|
505
|
+
fontFamily: theme.font.sans,
|
|
506
|
+
fontSize: theme.type.footnote.fontSize,
|
|
507
|
+
lineHeight: theme.type.footnote.lineHeight,
|
|
508
|
+
color: theme.color.text2
|
|
509
|
+
},
|
|
510
|
+
notifyRow: { flexDirection: "row", alignItems: "center", gap: theme.space.s2 },
|
|
511
|
+
notifyLabel: {
|
|
512
|
+
flexShrink: 1,
|
|
513
|
+
fontFamily: theme.font.sans,
|
|
514
|
+
fontSize: theme.type.footnote.fontSize,
|
|
515
|
+
lineHeight: theme.type.footnote.lineHeight,
|
|
516
|
+
color: theme.color.text
|
|
517
|
+
},
|
|
518
|
+
stated: { gap: theme.space[2] },
|
|
519
|
+
overline: {
|
|
520
|
+
fontFamily: theme.font.sans,
|
|
521
|
+
fontWeight: theme.fontWeight.bold,
|
|
522
|
+
fontSize: theme.type.caption2.fontSize,
|
|
523
|
+
lineHeight: theme.type.caption2.lineHeight,
|
|
524
|
+
letterSpacing: theme.tracking.caps,
|
|
525
|
+
textTransform: "uppercase",
|
|
526
|
+
color: theme.color.text3
|
|
527
|
+
},
|
|
528
|
+
statedValue: {
|
|
529
|
+
fontFamily: theme.font.sans,
|
|
530
|
+
fontWeight: theme.fontWeight.semibold,
|
|
531
|
+
fontSize: theme.type.footnote.fontSize,
|
|
532
|
+
lineHeight: theme.type.footnote.lineHeight,
|
|
533
|
+
color: theme.color.text
|
|
534
|
+
},
|
|
535
|
+
statedNote: {
|
|
536
|
+
fontFamily: theme.font.sans,
|
|
537
|
+
fontSize: theme.type.caption1.fontSize,
|
|
538
|
+
lineHeight: theme.type.caption1.fontSize * theme.lineHeight.normal,
|
|
539
|
+
color: theme.color.text3
|
|
540
|
+
},
|
|
541
|
+
commitBlock: { gap: theme.space.s2 },
|
|
542
|
+
irreversibleRow: { flexDirection: "row", alignItems: "flex-start", gap: theme.space.s2 },
|
|
543
|
+
irreversible: {
|
|
544
|
+
flexShrink: 1,
|
|
545
|
+
fontFamily: theme.font.sans,
|
|
546
|
+
fontSize: theme.type.caption1.fontSize,
|
|
547
|
+
lineHeight: theme.type.caption1.fontSize * theme.lineHeight.normal,
|
|
548
|
+
color: theme.color.text3
|
|
549
|
+
},
|
|
550
|
+
confirmHead: { alignItems: "center", gap: theme.space.s3 },
|
|
551
|
+
checkPlate: {
|
|
552
|
+
width: theme.ctl.iconBtn,
|
|
553
|
+
height: theme.ctl.iconBtn,
|
|
554
|
+
alignItems: "center",
|
|
555
|
+
justifyContent: "center",
|
|
556
|
+
borderRadius: theme.radius.full,
|
|
557
|
+
// The soft tint always carries its tone edge.
|
|
558
|
+
borderWidth: theme.borderWidth.base,
|
|
559
|
+
borderColor: theme.edge.good,
|
|
560
|
+
backgroundColor: theme.color.goodSoft
|
|
561
|
+
},
|
|
562
|
+
confirmMeta: {
|
|
563
|
+
flexDirection: "row",
|
|
564
|
+
flexWrap: "wrap",
|
|
565
|
+
alignItems: "center",
|
|
566
|
+
justifyContent: "center",
|
|
567
|
+
gap: theme.space.s2
|
|
568
|
+
},
|
|
569
|
+
meta: {
|
|
570
|
+
fontFamily: theme.font.sans,
|
|
571
|
+
fontSize: theme.type.footnote.fontSize,
|
|
572
|
+
lineHeight: theme.type.footnote.lineHeight,
|
|
573
|
+
color: theme.color.text3
|
|
574
|
+
},
|
|
575
|
+
actionRow: {
|
|
576
|
+
flexDirection: "row",
|
|
577
|
+
flexWrap: "wrap",
|
|
578
|
+
alignItems: "center",
|
|
579
|
+
gap: theme.space.s2
|
|
580
|
+
}
|
|
581
|
+
}));
|
|
582
|
+
var BADGE_VARIANT = {
|
|
583
|
+
info: "info",
|
|
584
|
+
good: "good",
|
|
585
|
+
warn: "warn",
|
|
586
|
+
danger: "danger",
|
|
587
|
+
"text-3": "neutral"
|
|
588
|
+
};
|
|
589
|
+
var EVIDENCE_ICON = {
|
|
590
|
+
have: "check-circle",
|
|
591
|
+
missing: "alert-circle",
|
|
592
|
+
"n/a": "minus"
|
|
593
|
+
};
|
|
594
|
+
function DisputeDeadline({
|
|
595
|
+
dispute,
|
|
596
|
+
urgentAt = 3,
|
|
597
|
+
locale,
|
|
598
|
+
style
|
|
599
|
+
}) {
|
|
600
|
+
const theme = useLoamTheme();
|
|
601
|
+
const { styles } = useStyles(sheet3);
|
|
602
|
+
const urgent = dispute.daysLeft <= urgentAt;
|
|
603
|
+
const ink = urgent ? theme.color.dangerOnSoft : theme.color.warnOnSoft;
|
|
604
|
+
return /* @__PURE__ */ jsxs(
|
|
605
|
+
View,
|
|
606
|
+
{
|
|
607
|
+
style: [
|
|
608
|
+
styles.deadline,
|
|
609
|
+
{
|
|
610
|
+
// A soft tint always carries its tone edge.
|
|
611
|
+
borderColor: urgent ? theme.edge.danger : theme.edge.warn,
|
|
612
|
+
backgroundColor: urgent ? theme.color.dangerSoft : theme.color.warnSoft
|
|
613
|
+
},
|
|
614
|
+
style
|
|
615
|
+
],
|
|
616
|
+
children: [
|
|
617
|
+
/* @__PURE__ */ jsxs(View, { children: [
|
|
618
|
+
/* @__PURE__ */ jsx(Text, { style: [styles.daysLeft, { color: ink }], children: `${dispute.daysLeft} ${dispute.daysLeft === 1 ? "day" : "days"}` }),
|
|
619
|
+
/* @__PURE__ */ jsx(Text, { style: [styles.daysNote, { color: ink }], children: `to respond \xB7 evidence due ${dispute.due}` })
|
|
620
|
+
] }),
|
|
621
|
+
/* @__PURE__ */ jsxs(View, { style: styles.factGrid, children: [
|
|
622
|
+
/* @__PURE__ */ jsxs(View, { style: styles.fact, children: [
|
|
623
|
+
/* @__PURE__ */ jsx(Text, { style: [styles.factTerm, { color: ink }], children: "Disputed" }),
|
|
624
|
+
/* @__PURE__ */ jsx(
|
|
625
|
+
Amount,
|
|
626
|
+
{
|
|
627
|
+
minor: dispute.amountMinor,
|
|
628
|
+
currency: dispute.currency,
|
|
629
|
+
size: "lg",
|
|
630
|
+
weight: "bold",
|
|
631
|
+
locale
|
|
632
|
+
}
|
|
633
|
+
)
|
|
634
|
+
] }),
|
|
635
|
+
/* @__PURE__ */ jsxs(View, { style: styles.fact, children: [
|
|
636
|
+
/* @__PURE__ */ jsx(Text, { style: [styles.factTerm, { color: ink }], children: "Network fee" }),
|
|
637
|
+
/* @__PURE__ */ jsx(Text, { style: styles.factValueNum, children: money(dispute.feeMinor, dispute.currency, { locale }) })
|
|
638
|
+
] }),
|
|
639
|
+
/* @__PURE__ */ jsxs(View, { style: styles.fact, children: [
|
|
640
|
+
/* @__PURE__ */ jsx(Text, { style: [styles.factTerm, { color: ink }], children: "Reason" }),
|
|
641
|
+
/* @__PURE__ */ jsx(Text, { style: styles.factValue, children: `${dispute.reason} \xB7 ${dispute.network}` })
|
|
642
|
+
] }),
|
|
643
|
+
/* @__PURE__ */ jsxs(View, { style: styles.fact, children: [
|
|
644
|
+
/* @__PURE__ */ jsx(Text, { style: [styles.factTerm, { color: ink }], children: "Opened" }),
|
|
645
|
+
/* @__PURE__ */ jsx(Text, { style: styles.factValue, children: dispute.opened })
|
|
646
|
+
] })
|
|
647
|
+
] })
|
|
648
|
+
]
|
|
649
|
+
}
|
|
650
|
+
);
|
|
651
|
+
}
|
|
652
|
+
function DisputeEvidenceRow({
|
|
653
|
+
item,
|
|
654
|
+
attachLabel = "Attach",
|
|
655
|
+
onAttach,
|
|
656
|
+
style
|
|
657
|
+
}) {
|
|
658
|
+
const theme = useLoamTheme();
|
|
659
|
+
const { styles } = useStyles(sheet3);
|
|
660
|
+
const tone = evidenceTone(item.state);
|
|
661
|
+
const glyphColor = tone === "good" ? theme.color.good : tone === "warn" ? theme.color.warn : theme.color.text3;
|
|
662
|
+
return /* @__PURE__ */ jsxs(View, { role: "listitem", style: [styles.evidenceRow, style], children: [
|
|
663
|
+
/* @__PURE__ */ jsx(Icon, { name: EVIDENCE_ICON[item.state], size: theme.icon.sm, color: glyphColor }),
|
|
664
|
+
/* @__PURE__ */ jsxs(View, { style: styles.evidenceBody, children: [
|
|
665
|
+
/* @__PURE__ */ jsx(Text, { style: styles.evidenceLabel, children: item.label }),
|
|
666
|
+
/* @__PURE__ */ jsx(Text, { style: styles.evidenceNote, children: item.note })
|
|
667
|
+
] }),
|
|
668
|
+
/* @__PURE__ */ jsxs(View, { style: styles.evidenceTrail, children: [
|
|
669
|
+
/* @__PURE__ */ jsx(Badge, { style: styles.rowBadge, variant: BADGE_VARIANT[tone], size: "sm", children: evidenceLabel(item.state) }),
|
|
670
|
+
item.state === "missing" && onAttach ? /* @__PURE__ */ jsx(Button, { size: "xs", variant: "outline", leadingIcon: "upload", onPress: () => onAttach(item), children: attachLabel }) : null
|
|
671
|
+
] })
|
|
672
|
+
] });
|
|
673
|
+
}
|
|
674
|
+
function DisputePanel({
|
|
675
|
+
dispute,
|
|
676
|
+
title = "Chargeback",
|
|
677
|
+
description = "The amount and the network fee have already left the account. Submitting evidence asks the network to reverse the first of those; the fee is not refundable either way, and the network decides \u2014 not us.",
|
|
678
|
+
submitLabel = "Submit evidence",
|
|
679
|
+
acceptLabel = "Accept the dispute",
|
|
680
|
+
canSubmit = true,
|
|
681
|
+
busy = false,
|
|
682
|
+
showGuidance = true,
|
|
683
|
+
onSubmitEvidence,
|
|
684
|
+
onAccept,
|
|
685
|
+
onAttach,
|
|
686
|
+
locale,
|
|
687
|
+
style
|
|
688
|
+
}) {
|
|
689
|
+
const theme = useLoamTheme();
|
|
690
|
+
const { styles } = useStyles(sheet3);
|
|
691
|
+
const worth = disputeWorthDefending(dispute.amountMinor);
|
|
692
|
+
const threshold = money(DISPUTE_ACCEPT_THRESHOLD_MINOR, dispute.currency, { locale });
|
|
693
|
+
return /* @__PURE__ */ jsxs(View, { role: "region", accessibilityLabel: title, style: [styles.panel, style], children: [
|
|
694
|
+
/* @__PURE__ */ jsxs(View, { style: styles.header, children: [
|
|
695
|
+
/* @__PURE__ */ jsx(Text, { accessibilityRole: "header", style: styles.title, children: title }),
|
|
696
|
+
/* @__PURE__ */ jsx(DisputeDeadline, { dispute, locale }),
|
|
697
|
+
/* @__PURE__ */ jsx(Text, { style: styles.description, children: description })
|
|
698
|
+
] }),
|
|
699
|
+
/* @__PURE__ */ jsxs(View, { style: styles.evidenceBlock, children: [
|
|
700
|
+
/* @__PURE__ */ jsx(Text, { style: styles.overline, children: "Evidence" }),
|
|
701
|
+
/* @__PURE__ */ jsx(View, { role: "list", accessibilityRole: "list", children: dispute.evidence.map((item) => /* @__PURE__ */ jsx(DisputeEvidenceRow, { item, onAttach }, item.label)) })
|
|
702
|
+
] }),
|
|
703
|
+
showGuidance ? /* @__PURE__ */ jsxs(View, { style: styles.guidanceRow, children: [
|
|
704
|
+
/* @__PURE__ */ jsx(Icon, { name: "info", size: theme.icon.sm, color: theme.color.text3 }),
|
|
705
|
+
/* @__PURE__ */ jsx(Text, { style: styles.guidance, children: (worth ? `Above ${threshold} this is usually worth defending \u2014 the amount at stake exceeds the staff time a response costs.` : `Below ${threshold} the staff time spent defending this usually exceeds the amount at stake. Accepting is a legitimate answer, not a loss.`) + (canSubmit ? "" : " Some evidence is still missing; submitting now sends what is attached.") })
|
|
706
|
+
] }) : null,
|
|
707
|
+
/* @__PURE__ */ jsxs(View, { style: styles.actionRow, children: [
|
|
708
|
+
/* @__PURE__ */ jsx(Button, { loading: busy, onPress: onSubmitEvidence, children: submitLabel }),
|
|
709
|
+
/* @__PURE__ */ jsx(Button, { variant: "outline", onPress: onAccept, children: acceptLabel })
|
|
710
|
+
] })
|
|
711
|
+
] });
|
|
712
|
+
}
|
|
713
|
+
var sheet3 = createStyleSheet((theme) => ({
|
|
714
|
+
panel: {
|
|
715
|
+
alignSelf: "stretch",
|
|
716
|
+
gap: theme.space.s5,
|
|
717
|
+
padding: theme.space.s5,
|
|
718
|
+
borderRadius: theme.radius.lg,
|
|
719
|
+
borderWidth: theme.borderWidth.base,
|
|
720
|
+
borderColor: theme.color.border,
|
|
721
|
+
backgroundColor: theme.color.surface
|
|
722
|
+
},
|
|
723
|
+
header: { gap: theme.space.s3 },
|
|
724
|
+
title: {
|
|
725
|
+
fontFamily: theme.font.display,
|
|
726
|
+
fontWeight: theme.font.displayWeight,
|
|
727
|
+
fontSize: theme.type.title3.fontSize,
|
|
728
|
+
lineHeight: theme.type.title3.lineHeight,
|
|
729
|
+
letterSpacing: theme.type.title3.letterSpacing,
|
|
730
|
+
color: theme.color.text
|
|
731
|
+
},
|
|
732
|
+
description: {
|
|
733
|
+
fontFamily: theme.font.sans,
|
|
734
|
+
fontSize: theme.type.footnote.fontSize,
|
|
735
|
+
lineHeight: theme.type.footnote.fontSize * theme.lineHeight.normal,
|
|
736
|
+
color: theme.color.text2
|
|
737
|
+
},
|
|
738
|
+
deadline: {
|
|
739
|
+
gap: theme.space.s4,
|
|
740
|
+
padding: theme.space.s4,
|
|
741
|
+
borderRadius: theme.radius.md,
|
|
742
|
+
borderWidth: theme.borderWidth.base
|
|
743
|
+
},
|
|
744
|
+
daysLeft: {
|
|
745
|
+
fontFamily: theme.font.sans,
|
|
746
|
+
fontWeight: theme.fontWeight.bold,
|
|
747
|
+
fontVariant: ["tabular-nums"],
|
|
748
|
+
fontSize: theme.fontSize[32],
|
|
749
|
+
lineHeight: theme.fontSize[32] * theme.lineHeight.tight
|
|
750
|
+
},
|
|
751
|
+
daysNote: {
|
|
752
|
+
fontFamily: theme.font.sans,
|
|
753
|
+
fontSize: theme.type.footnote.fontSize,
|
|
754
|
+
lineHeight: theme.type.footnote.lineHeight
|
|
755
|
+
},
|
|
756
|
+
factGrid: {
|
|
757
|
+
flexDirection: "row",
|
|
758
|
+
flexWrap: "wrap",
|
|
759
|
+
columnGap: theme.space.s5,
|
|
760
|
+
rowGap: theme.space.s2
|
|
761
|
+
},
|
|
762
|
+
fact: { gap: theme.space[2] },
|
|
763
|
+
// No `color` here: the fact terms are inked by the caller with the *tint's*
|
|
764
|
+
// own measured ink (`dangerOnSoft` / `warnOnSoft`), the same one the days-left
|
|
765
|
+
// figure uses. They used to be `theme.color.text3`, and `--text-3` is measured
|
|
766
|
+
// against the neutral surface ramp only — on this banner's tint it read 4.20:1
|
|
767
|
+
// on `--danger-soft` and 3.78:1 on `--warn-soft` in dark mode, 28 axe
|
|
768
|
+
// `color-contrast` nodes from one style (seven deadlines x four terms).
|
|
769
|
+
factTerm: {
|
|
770
|
+
fontFamily: theme.font.sans,
|
|
771
|
+
fontWeight: theme.fontWeight.bold,
|
|
772
|
+
fontSize: theme.type.caption2.fontSize,
|
|
773
|
+
lineHeight: theme.type.caption2.lineHeight,
|
|
774
|
+
letterSpacing: theme.tracking.caps,
|
|
775
|
+
textTransform: "uppercase"
|
|
776
|
+
},
|
|
777
|
+
factValue: {
|
|
778
|
+
fontFamily: theme.font.sans,
|
|
779
|
+
fontSize: theme.type.footnote.fontSize,
|
|
780
|
+
lineHeight: theme.type.footnote.lineHeight,
|
|
781
|
+
color: theme.color.text
|
|
782
|
+
},
|
|
783
|
+
factValueNum: {
|
|
784
|
+
fontFamily: theme.font.sans,
|
|
785
|
+
fontWeight: theme.fontWeight.bold,
|
|
786
|
+
fontVariant: ["tabular-nums"],
|
|
787
|
+
fontSize: theme.type.footnote.fontSize,
|
|
788
|
+
lineHeight: theme.type.footnote.lineHeight,
|
|
789
|
+
color: theme.color.text
|
|
790
|
+
},
|
|
791
|
+
evidenceBlock: { gap: theme.space.s2 },
|
|
792
|
+
overline: {
|
|
793
|
+
fontFamily: theme.font.sans,
|
|
794
|
+
fontWeight: theme.fontWeight.bold,
|
|
795
|
+
fontSize: theme.type.caption2.fontSize,
|
|
796
|
+
lineHeight: theme.type.caption2.lineHeight,
|
|
797
|
+
letterSpacing: theme.tracking.caps,
|
|
798
|
+
textTransform: "uppercase",
|
|
799
|
+
color: theme.color.text3
|
|
800
|
+
},
|
|
801
|
+
evidenceRow: {
|
|
802
|
+
flexDirection: "row",
|
|
803
|
+
flexWrap: "wrap",
|
|
804
|
+
alignItems: "flex-start",
|
|
805
|
+
gap: theme.space.s3,
|
|
806
|
+
paddingVertical: theme.space.s3,
|
|
807
|
+
borderTopWidth: theme.borderWidth.base,
|
|
808
|
+
borderTopColor: theme.color.border
|
|
809
|
+
},
|
|
810
|
+
// A floor, so the row wraps the badge and Attach under the text rather than
|
|
811
|
+
// squeezing the note to a 126px column beside them.
|
|
812
|
+
evidenceBody: { flexGrow: 1, flexShrink: 1, flexBasis: theme.panel.xs, gap: theme.space[2] },
|
|
813
|
+
evidenceLabel: {
|
|
814
|
+
fontFamily: theme.font.sans,
|
|
815
|
+
fontWeight: theme.fontWeight.semibold,
|
|
816
|
+
fontSize: theme.type.footnote.fontSize,
|
|
817
|
+
lineHeight: theme.type.footnote.lineHeight,
|
|
818
|
+
color: theme.color.text
|
|
819
|
+
},
|
|
820
|
+
evidenceNote: {
|
|
821
|
+
fontFamily: theme.font.sans,
|
|
822
|
+
fontSize: theme.type.caption1.fontSize,
|
|
823
|
+
lineHeight: theme.type.caption1.fontSize * theme.lineHeight.normal,
|
|
824
|
+
color: theme.color.text3
|
|
825
|
+
},
|
|
826
|
+
evidenceTrail: { flexDirection: "row", alignItems: "center", gap: theme.space.s2 },
|
|
827
|
+
guidanceRow: { flexDirection: "row", alignItems: "flex-start", gap: theme.space.s2 },
|
|
828
|
+
guidance: {
|
|
829
|
+
flexShrink: 1,
|
|
830
|
+
fontFamily: theme.font.sans,
|
|
831
|
+
fontSize: theme.type.caption1.fontSize,
|
|
832
|
+
lineHeight: theme.type.caption1.fontSize * theme.lineHeight.normal,
|
|
833
|
+
color: theme.color.text3
|
|
834
|
+
},
|
|
835
|
+
actionRow: {
|
|
836
|
+
flexDirection: "row",
|
|
837
|
+
flexWrap: "wrap",
|
|
838
|
+
alignItems: "center",
|
|
839
|
+
gap: theme.space.s2
|
|
840
|
+
},
|
|
841
|
+
// Badge hugs with `flex-start`, which pins it to the top of this centred row.
|
|
842
|
+
rowBadge: { alignSelf: "center" }
|
|
843
|
+
}));
|
|
844
|
+
|
|
845
|
+
export { DisputeDeadline, DisputeEvidenceRow, DisputePanel, RefundAmountField, RefundArrivalNote, RefundConfirmation, RefundLedger, RefundPanel, RefundReasonList, RefundRemainingNote, RefundStatus };
|