@veevarts/design-system 2.1.0-beta.6 → 2.1.0-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +5 -5
- package/dist/index.js +2924 -2845
- package/dist/patterns/InstallmentSchedule/types.d.ts +29 -5
- package/dist/patterns/InstallmentSchedule/utils.d.ts +6 -0
- package/dist/patterns/PaymentSubAmountInput/PaymentSubAmountInput.d.ts +2 -0
- package/dist/patterns/shared/useDecimalDraft.d.ts +33 -0
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
export type InstallmentScheduleMode = 'automatic' | 'manual';
|
|
3
3
|
export type InstallmentFrequency = 'weekly' | 'monthly' | 'quarterly' | 'annual';
|
|
4
|
-
export type InstallmentStatus = 'scheduled' | 'paid' | 'payment_due' | 'overdue' | 'failed' | 'refunded' | 'disputed' | 'canceled' | 'processing' | 'pending_confirmation';
|
|
4
|
+
export type InstallmentStatus = 'scheduled' | 'paid' | 'payment_due' | 'overdue' | 'failed' | 'refunded' | 'partially_refunded' | 'disputed' | 'canceled' | 'processing' | 'pending_confirmation';
|
|
5
5
|
export type ScheduledInstallment = {
|
|
6
6
|
id: string;
|
|
7
7
|
name?: string | null;
|
|
@@ -13,9 +13,22 @@ export type ScheduledInstallment = {
|
|
|
13
13
|
* or an ISO timestamp (shown in the viewer's timezone). Named after the
|
|
14
14
|
* field the commitments API already returns for this, so installments
|
|
15
15
|
* passed straight through from the API carry it without any mapping.
|
|
16
|
-
* `InstallmentTable` shows it on
|
|
16
|
+
* `InstallmentTable` shows it on rows whose payment happened (`paid`,
|
|
17
|
+
* `partially_refunded`, `refunded`) and on no other status; omit it to
|
|
18
|
+
* show none.
|
|
17
19
|
*/
|
|
18
20
|
fulfilledAt?: string | null;
|
|
21
|
+
/**
|
|
22
|
+
* FR-1422 — how much of the installment was refunded, in the same units as
|
|
23
|
+
* `amount` (a major-unit number: `50` is $50.00). `InstallmentTable`
|
|
24
|
+
* formats it with its own `currency` and `locale` and shows it as
|
|
25
|
+
* "Refunded $50.00" under the amount of a `partially_refunded` row.
|
|
26
|
+
*
|
|
27
|
+
* Ignored on every other status: a `refunded` row gave the whole amount
|
|
28
|
+
* back, so its amount and badge already say it. Also ignored when missing,
|
|
29
|
+
* zero or negative, so a row never reads "Refunded $0.00".
|
|
30
|
+
*/
|
|
31
|
+
refundedAmount?: number | null;
|
|
19
32
|
};
|
|
20
33
|
export type AutomaticScheduleSettings = {
|
|
21
34
|
numberOfInstallments: number;
|
|
@@ -120,8 +133,18 @@ export type InstallmentTableLabels = {
|
|
|
120
133
|
installmentId?: string;
|
|
121
134
|
amount?: string;
|
|
122
135
|
scheduledDate?: string;
|
|
123
|
-
/**
|
|
136
|
+
/**
|
|
137
|
+
* Prefix of the paid date shown under the scheduled date of a row whose
|
|
138
|
+
* payment happened: "Paid on Jun 3, 2026".
|
|
139
|
+
*/
|
|
124
140
|
paidOn?: string;
|
|
141
|
+
/** FR-1422 — text of the `partially_refunded` status badge. Defaults to "Partially refunded". */
|
|
142
|
+
partiallyRefunded?: string;
|
|
143
|
+
/**
|
|
144
|
+
* FR-1422 — prefix of the refunded amount shown under the amount of a
|
|
145
|
+
* `partially_refunded` row: "Refunded $50.00". Defaults to "Refunded".
|
|
146
|
+
*/
|
|
147
|
+
refundedAmount?: string;
|
|
125
148
|
status?: string;
|
|
126
149
|
actions?: string;
|
|
127
150
|
payNow?: string;
|
|
@@ -151,8 +174,9 @@ export type InstallmentTableProps = {
|
|
|
151
174
|
/**
|
|
152
175
|
* FR-1619 — statuses for which the Pay Now button is NOT rendered on a row.
|
|
153
176
|
* Typed with the `InstallmentStatus` union so consumers get compile-time
|
|
154
|
-
* safety on status keys.
|
|
155
|
-
*
|
|
177
|
+
* safety on status keys. A Pay Now button that IS rendered is still
|
|
178
|
+
* disabled on a row whose payment already happened (`paid`,
|
|
179
|
+
* `partially_refunded`, `refunded`). Defaults to `[]`.
|
|
156
180
|
*/
|
|
157
181
|
payNowHiddenStatuses?: InstallmentStatus[];
|
|
158
182
|
showSavedIndicator?: boolean;
|
|
@@ -28,3 +28,9 @@ export declare function hasManualRowErrors(errors: ManualRowErrors): boolean;
|
|
|
28
28
|
* where the generator put it.
|
|
29
29
|
*/
|
|
30
30
|
export declare function applyFirstInstallmentDateOverride(installments: ScheduledInstallment[], firstInstallmentDateOverride?: string): ScheduledInstallment[];
|
|
31
|
+
/**
|
|
32
|
+
* Whether the installment's payment already happened: it was paid, and may
|
|
33
|
+
* since have been refunded in part or in full. Such a row is a record of money
|
|
34
|
+
* that moved, so it cannot be paid again, edited or deleted.
|
|
35
|
+
*/
|
|
36
|
+
export declare function isSettledInstallment(status: ScheduledInstallment['status']): boolean;
|
|
@@ -10,6 +10,8 @@ export interface PaymentSubAmountInputProps {
|
|
|
10
10
|
defaultValue?: string;
|
|
11
11
|
/** Fires on every keystroke with the raw string. */
|
|
12
12
|
onChange?: (next: string) => void;
|
|
13
|
+
/** Fires when the amount field loses focus. */
|
|
14
|
+
onBlur?: () => void;
|
|
13
15
|
/** Placeholder shown when value is empty (e.g. "$150.00"). */
|
|
14
16
|
placeholder?: string;
|
|
15
17
|
isDisabled?: boolean;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Keeps the text a cashier typed into a money input separate from the number
|
|
3
|
+
* the host holds.
|
|
4
|
+
*
|
|
5
|
+
* A money input whose display is `String(value)` loses what the cashier is
|
|
6
|
+
* mid-way through typing: `'40.'` parses to `40` and is re-rendered as `'40'`,
|
|
7
|
+
* so the next `0` produces `'400'` and `'40.00'` ends up read as 4000. The hook
|
|
8
|
+
* keeps the typed string and shows it while it still parses to `value` (the
|
|
9
|
+
* echo of the cashier's own keystroke). When the host holds a number the draft
|
|
10
|
+
* does not represent (a reset, a prefill, a host that ignores the keystroke),
|
|
11
|
+
* the input shows `format(value)` instead, so the host stays in control.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Whether `text` is one amount, possibly partial, in a currency with
|
|
15
|
+
* `fractionDigits` minor digits: digits, then at most one `.` or `,` followed
|
|
16
|
+
* by at most `fractionDigits` digits (`''`, `'40'`, `'40.'`, `'40,5'`, `'.5'`).
|
|
17
|
+
* Anything else would show one amount while emitting another, because
|
|
18
|
+
* `parseFloat` reads only a prefix and `,` is the decimal separator: `'40.5.9'`
|
|
19
|
+
* and `'4a'` would emit 40.5 and 4, and `'1,000'` would emit 1. Callers reject
|
|
20
|
+
* such a keystroke instead of storing it, so the input keeps what it showed.
|
|
21
|
+
*/
|
|
22
|
+
export declare const isDecimalDraft: (text: string, fractionDigits: number) => boolean;
|
|
23
|
+
/** Parses a typed amount (`'40.5'`, `'40,5'`, `'40.'`); `null` when there is no number yet (`''`, `'.'`, `','`). */
|
|
24
|
+
export declare const parseDecimalDraft: (draft: string) => number | null;
|
|
25
|
+
export interface DecimalDraft {
|
|
26
|
+
/** The text to show in the input. */
|
|
27
|
+
draft: string;
|
|
28
|
+
/** Stores the text the cashier typed. */
|
|
29
|
+
setDraft: (next: string) => void;
|
|
30
|
+
/** Rewrites the draft in its canonical form (`'40.'` → `'40'`) without changing its value. */
|
|
31
|
+
normalize: () => void;
|
|
32
|
+
}
|
|
33
|
+
export declare const useDecimalDraft: (value: number | null | undefined, format: (value: number | null | undefined) => string) => DecimalDraft;
|