tempest-react-sdk 0.35.0 → 0.36.0
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/README.md +72 -70
- package/dist/audio/audio-output.cjs +2 -0
- package/dist/audio/audio-output.cjs.map +1 -0
- package/dist/audio/audio-output.js +17 -0
- package/dist/audio/audio-output.js.map +1 -0
- package/dist/audio/audio-player.cjs +1 -1
- package/dist/audio/audio-player.cjs.map +1 -1
- package/dist/audio/audio-player.js +21 -20
- package/dist/audio/audio-player.js.map +1 -1
- package/dist/audio/audio-recorder.cjs +2 -0
- package/dist/audio/audio-recorder.cjs.map +1 -0
- package/dist/audio/audio-recorder.js +30 -0
- package/dist/audio/audio-recorder.js.map +1 -0
- package/dist/audio/duration.cjs +2 -0
- package/dist/audio/duration.cjs.map +1 -0
- package/dist/audio/duration.js +10 -0
- package/dist/audio/duration.js.map +1 -0
- package/dist/audio/level-meter.cjs +2 -0
- package/dist/audio/level-meter.cjs.map +1 -0
- package/dist/audio/level-meter.js +34 -0
- package/dist/audio/level-meter.js.map +1 -0
- package/dist/audio/media-access.cjs +2 -0
- package/dist/audio/media-access.cjs.map +1 -0
- package/dist/audio/media-access.js +51 -0
- package/dist/audio/media-access.js.map +1 -0
- package/dist/audio/use-audio-recorder.cjs +2 -0
- package/dist/audio/use-audio-recorder.cjs.map +1 -0
- package/dist/audio/use-audio-recorder.js +94 -0
- package/dist/audio/use-audio-recorder.js.map +1 -0
- package/dist/audio/use-audio.cjs.map +1 -1
- package/dist/audio/use-audio.js.map +1 -1
- package/dist/audio/use-microphone.cjs +2 -0
- package/dist/audio/use-microphone.cjs.map +1 -0
- package/dist/audio/use-microphone.js +54 -0
- package/dist/audio/use-microphone.js.map +1 -0
- package/dist/audio/wav.cjs +2 -0
- package/dist/audio/wav.cjs.map +1 -0
- package/dist/audio/wav.js +49 -0
- package/dist/audio/wav.js.map +1 -0
- package/dist/auth/passkey.cjs +2 -0
- package/dist/auth/passkey.cjs.map +1 -0
- package/dist/auth/passkey.js +171 -0
- package/dist/auth/passkey.js.map +1 -0
- package/dist/auth/use-passkey.cjs +2 -0
- package/dist/auth/use-passkey.cjs.map +1 -0
- package/dist/auth/use-passkey.js +120 -0
- package/dist/auth/use-passkey.js.map +1 -0
- package/dist/br/PixQRCode.cjs +2 -0
- package/dist/br/PixQRCode.cjs.map +1 -0
- package/dist/br/PixQRCode.js +70 -0
- package/dist/br/PixQRCode.js.map +1 -0
- package/dist/br/PixQRCode.module.cjs +2 -0
- package/dist/br/PixQRCode.module.cjs.map +1 -0
- package/dist/br/PixQRCode.module.js +15 -0
- package/dist/br/PixQRCode.module.js.map +1 -0
- package/dist/br/boleto.cjs +2 -0
- package/dist/br/boleto.cjs.map +1 -0
- package/dist/br/boleto.js +225 -0
- package/dist/br/boleto.js.map +1 -0
- package/dist/br/holidays.cjs +2 -0
- package/dist/br/holidays.cjs.map +1 -0
- package/dist/br/holidays.js +148 -0
- package/dist/br/holidays.js.map +1 -0
- package/dist/br/nfe.cjs +2 -0
- package/dist/br/nfe.cjs.map +1 -0
- package/dist/br/nfe.js +104 -0
- package/dist/br/nfe.js.map +1 -0
- package/dist/br/pix.cjs +2 -0
- package/dist/br/pix.cjs.map +1 -0
- package/dist/br/pix.js +148 -0
- package/dist/br/pix.js.map +1 -0
- package/dist/br.cjs +1 -1
- package/dist/br.cjs.map +1 -1
- package/dist/br.d.ts +878 -0
- package/dist/br.js +7 -2
- package/dist/br.js.map +1 -1
- package/dist/capture/barcode.cjs +2 -0
- package/dist/capture/barcode.cjs.map +1 -0
- package/dist/capture/barcode.js +59 -0
- package/dist/capture/barcode.js.map +1 -0
- package/dist/capture/media-recorder.cjs +2 -0
- package/dist/capture/media-recorder.cjs.map +1 -0
- package/dist/capture/media-recorder.js +64 -0
- package/dist/capture/media-recorder.js.map +1 -0
- package/dist/capture/use-barcode-scanner.cjs +2 -0
- package/dist/capture/use-barcode-scanner.cjs.map +1 -0
- package/dist/capture/use-barcode-scanner.js +86 -0
- package/dist/capture/use-barcode-scanner.js.map +1 -0
- package/dist/capture/use-screen-capture.cjs +2 -0
- package/dist/capture/use-screen-capture.cjs.map +1 -0
- package/dist/capture/use-screen-capture.js +79 -0
- package/dist/capture/use-screen-capture.js.map +1 -0
- package/dist/capture/use-speech-recognition.cjs +2 -0
- package/dist/capture/use-speech-recognition.cjs.map +1 -0
- package/dist/capture/use-speech-recognition.js +118 -0
- package/dist/capture/use-speech-recognition.js.map +1 -0
- package/dist/capture/use-torch.cjs +2 -0
- package/dist/capture/use-torch.cjs.map +1 -0
- package/dist/capture/use-torch.js +33 -0
- package/dist/capture/use-torch.js.map +1 -0
- package/dist/capture/use-video-recorder.cjs +2 -0
- package/dist/capture/use-video-recorder.cjs.map +1 -0
- package/dist/capture/use-video-recorder.js +90 -0
- package/dist/capture/use-video-recorder.js.map +1 -0
- package/dist/capture/video-recorder.cjs +2 -0
- package/dist/capture/video-recorder.cjs.map +1 -0
- package/dist/capture/video-recorder.js +31 -0
- package/dist/capture/video-recorder.js.map +1 -0
- package/dist/components/AIChat/AIChat.cjs +1 -1
- package/dist/components/AIChat/AIChat.cjs.map +1 -1
- package/dist/components/AIChat/AIChat.js +93 -97
- package/dist/components/AIChat/AIChat.js.map +1 -1
- package/dist/components/AIChat/AIChatComposer.cjs +1 -1
- package/dist/components/AIChat/AIChatComposer.cjs.map +1 -1
- package/dist/components/AIChat/AIChatComposer.js +2 -1
- package/dist/components/AIChat/AIChatComposer.js.map +1 -1
- package/dist/components/AIChat/AIChatTurn.cjs +2 -2
- package/dist/components/AIChat/AIChatTurn.js +6 -6
- package/dist/components/AIChat/AIChatTurn.js.map +1 -1
- package/dist/components/Alert/Alert.module.cjs.map +1 -1
- package/dist/components/Alert/Alert.module.js.map +1 -1
- package/dist/components/AudioPlayer/AudioPlayer.cjs +2 -0
- package/dist/components/AudioPlayer/AudioPlayer.cjs.map +1 -0
- package/dist/components/AudioPlayer/AudioPlayer.js +123 -0
- package/dist/components/AudioPlayer/AudioPlayer.js.map +1 -0
- package/dist/components/AudioPlayer/AudioPlayer.module.cjs +2 -0
- package/dist/components/AudioPlayer/AudioPlayer.module.cjs.map +1 -0
- package/dist/components/AudioPlayer/AudioPlayer.module.js +12 -0
- package/dist/components/AudioPlayer/AudioPlayer.module.js.map +1 -0
- package/dist/components/AudioRecorder/AudioRecorder.cjs +2 -0
- package/dist/components/AudioRecorder/AudioRecorder.cjs.map +1 -0
- package/dist/components/AudioRecorder/AudioRecorder.js +179 -0
- package/dist/components/AudioRecorder/AudioRecorder.js.map +1 -0
- package/dist/components/AudioRecorder/AudioRecorder.module.cjs +2 -0
- package/dist/components/AudioRecorder/AudioRecorder.module.cjs.map +1 -0
- package/dist/components/AudioRecorder/AudioRecorder.module.js +19 -0
- package/dist/components/AudioRecorder/AudioRecorder.module.js.map +1 -0
- package/dist/components/Badge/Badge.module.cjs.map +1 -1
- package/dist/components/Badge/Badge.module.js.map +1 -1
- package/dist/components/BarcodeScanner/BarcodeScanner.cjs +2 -0
- package/dist/components/BarcodeScanner/BarcodeScanner.cjs.map +1 -0
- package/dist/components/BarcodeScanner/BarcodeScanner.js +123 -0
- package/dist/components/BarcodeScanner/BarcodeScanner.js.map +1 -0
- package/dist/components/BarcodeScanner/BarcodeScanner.module.cjs +2 -0
- package/dist/components/BarcodeScanner/BarcodeScanner.module.cjs.map +1 -0
- package/dist/components/BarcodeScanner/BarcodeScanner.module.js +22 -0
- package/dist/components/BarcodeScanner/BarcodeScanner.module.js.map +1 -0
- package/dist/components/BottomNavigation/BottomNavigation.module.cjs.map +1 -1
- package/dist/components/BottomNavigation/BottomNavigation.module.js.map +1 -1
- package/dist/components/Button/Button.module.cjs.map +1 -1
- package/dist/components/Button/Button.module.js.map +1 -1
- package/dist/components/Combobox/Combobox.module.cjs.map +1 -1
- package/dist/components/Combobox/Combobox.module.js.map +1 -1
- package/dist/components/DataTable/DataTable.cjs +1 -1
- package/dist/components/DataTable/DataTable.cjs.map +1 -1
- package/dist/components/DataTable/DataTable.js +203 -66
- package/dist/components/DataTable/DataTable.js.map +1 -1
- package/dist/components/DataTable/DataTable.module.cjs +1 -1
- package/dist/components/DataTable/DataTable.module.cjs.map +1 -1
- package/dist/components/DataTable/DataTable.module.js +9 -3
- package/dist/components/DataTable/DataTable.module.js.map +1 -1
- package/dist/components/DataTable/EditableCell.cjs +2 -0
- package/dist/components/DataTable/EditableCell.cjs.map +1 -0
- package/dist/components/DataTable/EditableCell.js +77 -0
- package/dist/components/DataTable/EditableCell.js.map +1 -0
- package/dist/components/DataTable/edit-labels.cjs +2 -0
- package/dist/components/DataTable/edit-labels.cjs.map +1 -0
- package/dist/components/DataTable/edit-labels.js +11 -0
- package/dist/components/DataTable/edit-labels.js.map +1 -0
- package/dist/components/DateRangePicker/DateRangePicker.module.cjs.map +1 -1
- package/dist/components/DateRangePicker/DateRangePicker.module.js.map +1 -1
- package/dist/components/MultiSelect/MultiSelect.module.cjs.map +1 -1
- package/dist/components/MultiSelect/MultiSelect.module.js.map +1 -1
- package/dist/components/NavigationRail/NavigationRail.module.cjs.map +1 -1
- package/dist/components/NavigationRail/NavigationRail.module.js.map +1 -1
- package/dist/components/SyncStatusBadge/SyncStatusBadge.cjs +1 -1
- package/dist/components/SyncStatusBadge/SyncStatusBadge.cjs.map +1 -1
- package/dist/components/SyncStatusBadge/SyncStatusBadge.js +33 -32
- package/dist/components/SyncStatusBadge/SyncStatusBadge.js.map +1 -1
- package/dist/components/Toast/ToastProvider.cjs +1 -1
- package/dist/components/Toast/ToastProvider.cjs.map +1 -1
- package/dist/components/Toast/ToastProvider.js +1 -2
- package/dist/components/Toast/ToastProvider.js.map +1 -1
- package/dist/hooks/use-announce.cjs +2 -0
- package/dist/hooks/use-announce.cjs.map +1 -0
- package/dist/hooks/use-announce.js +50 -0
- package/dist/hooks/use-announce.js.map +1 -0
- package/dist/hooks/use-media-devices.cjs +2 -0
- package/dist/hooks/use-media-devices.cjs.map +1 -0
- package/dist/hooks/use-media-devices.js +46 -0
- package/dist/hooks/use-media-devices.js.map +1 -0
- package/dist/hooks/use-media-permission.cjs +2 -0
- package/dist/hooks/use-media-permission.cjs.map +1 -0
- package/dist/hooks/use-media-permission.js +33 -0
- package/dist/hooks/use-media-permission.js.map +1 -0
- package/dist/http/resumable-upload.cjs +2 -0
- package/dist/http/resumable-upload.cjs.map +1 -0
- package/dist/http/resumable-upload.js +249 -0
- package/dist/http/resumable-upload.js.map +1 -0
- package/dist/styles.css +1 -1
- package/dist/tempest-react-sdk.cjs +1 -1
- package/dist/tempest-react-sdk.d.ts +2485 -29
- package/dist/tempest-react-sdk.js +268 -244
- package/dist/vision/use-camera-stream.cjs +1 -1
- package/dist/vision/use-camera-stream.cjs.map +1 -1
- package/dist/vision/use-camera-stream.js +40 -57
- package/dist/vision/use-camera-stream.js.map +1 -1
- package/dist/vision.cjs +1 -1
- package/dist/vision.d.ts +25 -3
- package/dist/vision.js +19 -19
- package/package.json +1 -1
package/dist/br.d.ts
CHANGED
|
@@ -3,6 +3,162 @@ import { JSX } from 'react';
|
|
|
3
3
|
import { ReactElement } from 'react';
|
|
4
4
|
import { ReactNode } from 'react';
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Move a date by a number of working days.
|
|
8
|
+
*
|
|
9
|
+
* `n` days forward means `n` calls to {@link nextBusinessDay}; a negative `n`
|
|
10
|
+
* walks backwards the same way. `n === 0` returns the day unchanged **even when it
|
|
11
|
+
* is not a working day** — snapping silently would hide the case a caller most
|
|
12
|
+
* needs to see.
|
|
13
|
+
*
|
|
14
|
+
* @param date - `YYYY-MM-DD` or a `Date`.
|
|
15
|
+
* @param days - Working days to add. May be negative.
|
|
16
|
+
* @param options - See {@link BusinessDayOptions}.
|
|
17
|
+
* @returns Local midnight of the resulting day.
|
|
18
|
+
* @throws {RangeError} On a malformed input, or on a calendar with no working days.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* addBusinessDays("2026-04-01", 2); // 2026-04-06 — skips Good Friday and the weekend
|
|
22
|
+
*/
|
|
23
|
+
export declare function addBusinessDays(date: DateInput, days: number, options?: BusinessDayOptions): Date;
|
|
24
|
+
|
|
25
|
+
/** What the two parsers return. Narrow on `kind`. */
|
|
26
|
+
export declare type Boleto = BoletoBanco | BoletoArrecadacao;
|
|
27
|
+
|
|
28
|
+
/** An arrecadação/convênio slip — utilities, taxes, traffic fines. */
|
|
29
|
+
export declare interface BoletoArrecadacao {
|
|
30
|
+
kind: "arrecadacao";
|
|
31
|
+
/** 44 digits, always starting with `8`. */
|
|
32
|
+
codigoBarras: string;
|
|
33
|
+
/** 48 digits, in four blocks of twelve. */
|
|
34
|
+
linhaDigitavel: string;
|
|
35
|
+
/** Position 2. See {@link segmentoLabel}. */
|
|
36
|
+
segmento: number;
|
|
37
|
+
/** Human label, or `null` for a value the layout does not define. */
|
|
38
|
+
segmentoLabel: string | null;
|
|
39
|
+
/** Position 3: `6`/`8` mean real money, `7`/`9` mean a reference quantity. */
|
|
40
|
+
identificacaoValor: number;
|
|
41
|
+
/** Which modulo position 3 selects for the general check digit. */
|
|
42
|
+
dvModulo: 10 | 11;
|
|
43
|
+
/** The general check digit, position 4. */
|
|
44
|
+
dv: string;
|
|
45
|
+
/** Reais, or `null` when position 3 says the field is a reference, not money. */
|
|
46
|
+
valor: number | null;
|
|
47
|
+
/** The raw 11-digit value field, useful when {@link valor} is `null`. */
|
|
48
|
+
valorRaw: string;
|
|
49
|
+
/**
|
|
50
|
+
* Positions 16-19 — the 4-digit code FEBRABAN assigns the company — or, on
|
|
51
|
+
* segmento 6, positions 16-23, which are the first eight CNPJ digits.
|
|
52
|
+
*/
|
|
53
|
+
empresa: string;
|
|
54
|
+
/** `true` when {@link empresa} is a CNPJ prefix rather than a FEBRABAN code. */
|
|
55
|
+
empresaIsCnpj: boolean;
|
|
56
|
+
/** 25 digits, or 21 when the CNPJ took four of them. Issuer-defined. */
|
|
57
|
+
campoLivre: string;
|
|
58
|
+
/**
|
|
59
|
+
* Due date read from the first eight digits of the campo livre.
|
|
60
|
+
*
|
|
61
|
+
* The layout says a due date, **if present**, must sit there as `AAAAMMDD` —
|
|
62
|
+
* but the field is optional and nothing marks its presence, so a campo livre
|
|
63
|
+
* that merely looks like a date lands here too. Treat it as a hint for a UI,
|
|
64
|
+
* never as the date a payment settles against.
|
|
65
|
+
*/
|
|
66
|
+
vencimentoCampoLivre: Date | null;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** A cobrança boleto — the kind a bank issues against an invoice. */
|
|
70
|
+
export declare interface BoletoBanco {
|
|
71
|
+
kind: "banco";
|
|
72
|
+
/** 44 digits. */
|
|
73
|
+
codigoBarras: string;
|
|
74
|
+
/** 47 digits. */
|
|
75
|
+
linhaDigitavel: string;
|
|
76
|
+
/** 3-digit bank code in the clearing house, e.g. `"341"`. */
|
|
77
|
+
banco: string;
|
|
78
|
+
/** 1 digit. `"9"` is BRL; nothing else is in use. */
|
|
79
|
+
moeda: string;
|
|
80
|
+
/** `"Real"` for `"9"`, `null` for anything else. */
|
|
81
|
+
moedaLabel: string | null;
|
|
82
|
+
/** The general check digit, position 5 of the barcode. */
|
|
83
|
+
dv: string;
|
|
84
|
+
/** Raw 4-digit field. `0` means the boleto carries no due date. */
|
|
85
|
+
fatorVencimento: number;
|
|
86
|
+
/** Due date, or `null` when the fator is `0`. */
|
|
87
|
+
vencimento: Date | null;
|
|
88
|
+
/** Which epoch {@link vencimento} was resolved under. `null` when there is none. */
|
|
89
|
+
vencimentoEpoch: Exclude<BoletoEpoch, "auto"> | null;
|
|
90
|
+
/** Reais. `0` when the issuer left the amount for the payer to fill in. */
|
|
91
|
+
valor: number;
|
|
92
|
+
/** 25 digits the issuing bank defines. Not interpretable without its manual. */
|
|
93
|
+
campoLivre: string;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Resolve a fator de vencimento to a calendar date.
|
|
98
|
+
*
|
|
99
|
+
* The field is four digits of days since a base date, and it has had **two** base
|
|
100
|
+
* dates: 1997-10-07 until the counter saturated at 9999 on 2025-02-21, then
|
|
101
|
+
* 2022-05-29 from 2025-02-22, when FEBRABAN restarted it at 1000.
|
|
102
|
+
*
|
|
103
|
+
* !!! danger "The two epochs are genuinely ambiguous"
|
|
104
|
+
* Every fator from 1000 to 9999 has a reading under each base — 1997-10-07
|
|
105
|
+
* gives a date in `2000-07-03 … 2025-02-21`, 2022-05-29 gives one in
|
|
106
|
+
* `2025-02-22 … 2049-10-14`. Nothing in the barcode says which. `"auto"`
|
|
107
|
+
* picks whichever lands nearer `reference`, which is right for the case that
|
|
108
|
+
* matters (a slip being paid now) and wrong for an archive sweep. Pass
|
|
109
|
+
* `"legacy"` or `"current"` when you know.
|
|
110
|
+
*
|
|
111
|
+
* @param fator - The raw 4-digit field as a number. `0` means "no due date".
|
|
112
|
+
* @param options - Epoch selection. Default `"auto"` against `new Date()`.
|
|
113
|
+
* @returns Local midnight of the due date, or `null` when `fator` is `0`.
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* boletoDueDate(1000, { epoch: "legacy" }); // 2000-07-03
|
|
117
|
+
* boletoDueDate(1000, { epoch: "current" }); // 2025-02-22
|
|
118
|
+
*/
|
|
119
|
+
export declare function boletoDueDate(fator: number, options?: BoletoOptions): {
|
|
120
|
+
date: Date;
|
|
121
|
+
epoch: Exclude<BoletoEpoch, "auto">;
|
|
122
|
+
} | null;
|
|
123
|
+
|
|
124
|
+
/** Which base date the fator de vencimento counts from. See {@link boletoDueDate}. */
|
|
125
|
+
export declare type BoletoEpoch = "auto" | "legacy" | "current";
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* A boleto string could not be read, or failed a check digit.
|
|
129
|
+
*
|
|
130
|
+
* Its own class so a scanner screen can tell "this is not a boleto" apart from a
|
|
131
|
+
* bug, and so the message can be shown to the operator as-is.
|
|
132
|
+
*/
|
|
133
|
+
export declare class BoletoError extends Error {
|
|
134
|
+
constructor(message: string);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* The two incompatible layouts that share the 44-digit barcode.
|
|
139
|
+
*
|
|
140
|
+
* `"banco"` is the cobrança boleto every bank issues; `"arrecadacao"` is the
|
|
141
|
+
* concessionária/tributo slip, which starts with `8` and lays out its 44 digits
|
|
142
|
+
* completely differently — same length, different meaning for every field.
|
|
143
|
+
*/
|
|
144
|
+
export declare type BoletoKind = "banco" | "arrecadacao";
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Which layout a string is in, without throwing.
|
|
148
|
+
*
|
|
149
|
+
* @param value - A barcode or typed line, masked or not.
|
|
150
|
+
* @returns The layout, or `null` when the length is not 44, 47 or 48.
|
|
151
|
+
*/
|
|
152
|
+
export declare function boletoKind(value: string): BoletoKind | null;
|
|
153
|
+
|
|
154
|
+
/** Options shared by every parser here. */
|
|
155
|
+
export declare interface BoletoOptions {
|
|
156
|
+
/** Fator de vencimento epoch. Default `"auto"`. */
|
|
157
|
+
epoch?: BoletoEpoch;
|
|
158
|
+
/** Date `"auto"` measures proximity against. Default `new Date()`. */
|
|
159
|
+
reference?: Date;
|
|
160
|
+
}
|
|
161
|
+
|
|
6
162
|
/**
|
|
7
163
|
* Clickable choropleth map of Brazil's 27 federative units. Renders the bundled
|
|
8
164
|
* simplified UF GeoJSON as SVG paths — **no external tiles or paid API**. Click
|
|
@@ -226,6 +382,85 @@ export declare interface BrUfGeometry {
|
|
|
226
382
|
coordinates: Ring[] | Ring[][];
|
|
227
383
|
}
|
|
228
384
|
|
|
385
|
+
/** Options shared by the calendar helpers. */
|
|
386
|
+
export declare interface BusinessDayOptions {
|
|
387
|
+
/**
|
|
388
|
+
* Which kinds count as non-working. Default `["national", "banking"]`, i.e.
|
|
389
|
+
* the Bacen calendar — the right default for anything money moves through.
|
|
390
|
+
* Pass `["national"]` for a labour-law calendar.
|
|
391
|
+
*/
|
|
392
|
+
kinds?: readonly HolidayKind[];
|
|
393
|
+
/**
|
|
394
|
+
* Extra non-working days, as `YYYY-MM-DD` or `Date`. This is where state and
|
|
395
|
+
* municipal holidays go: they are **not** in the built-in table and never will
|
|
396
|
+
* be — there are 5 570 municipalities, each free to declare its own.
|
|
397
|
+
*/
|
|
398
|
+
extra?: readonly DateInput[];
|
|
399
|
+
/**
|
|
400
|
+
* Days of the week that are not worked, `0` = Sunday. Default `[0, 6]`.
|
|
401
|
+
*/
|
|
402
|
+
weekend?: readonly number[];
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
/** A fiscal access key taken apart. */
|
|
406
|
+
export declare interface ChaveNFe {
|
|
407
|
+
/** Federative unit of the issuer, resolved from {@link cUF}. */
|
|
408
|
+
uf: UF;
|
|
409
|
+
/** The raw 2-digit IBGE code, positions 1-2. */
|
|
410
|
+
cUF: string;
|
|
411
|
+
/** Positions 3-6, `AAMM` — the two-digit year and the month of issue. */
|
|
412
|
+
anoMes: string;
|
|
413
|
+
/** Four-digit year derived from {@link anoMes}. */
|
|
414
|
+
ano: number;
|
|
415
|
+
/** Month of issue, 1-12. */
|
|
416
|
+
mes: number;
|
|
417
|
+
/** Positions 7-20, the issuer's CNPJ. */
|
|
418
|
+
cnpj: string;
|
|
419
|
+
/** Positions 21-22, `mod`. `"55"` is an NF-e, `"65"` an NFC-e. */
|
|
420
|
+
modelo: string;
|
|
421
|
+
/** Human label for {@link modelo}, or `null` for a model outside the table. */
|
|
422
|
+
modeloLabel: string | null;
|
|
423
|
+
/** Positions 23-25. */
|
|
424
|
+
serie: string;
|
|
425
|
+
/** Positions 26-34, `nNF`. */
|
|
426
|
+
numero: string;
|
|
427
|
+
/** Position 35, `tpEmis`. */
|
|
428
|
+
tipoEmissao: string;
|
|
429
|
+
/** Human label for {@link tipoEmissao}, or `null` for a value outside the table. */
|
|
430
|
+
tipoEmissaoLabel: string | null;
|
|
431
|
+
/** Positions 36-43, `cNF` — the issuer's random code. */
|
|
432
|
+
codigoNumerico: string;
|
|
433
|
+
/** Position 44, `cDV`. */
|
|
434
|
+
dv: string;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
/**
|
|
438
|
+
* The check digit a 43-digit key body requires.
|
|
439
|
+
*
|
|
440
|
+
* Módulo 11: each digit is multiplied by weights cycling `2…9` from right to
|
|
441
|
+
* left, the products are summed, and the digit is `11 - (sum mod 11)` — except
|
|
442
|
+
* that a remainder of `0` or `1` yields `0`, since `11` and `10` do not fit one
|
|
443
|
+
* position.
|
|
444
|
+
*
|
|
445
|
+
* Note this is the **fiscal** flavour of módulo 11. The cobrança boleto resolves
|
|
446
|
+
* those same remainders to `1`; see `mod11DacCobranca` in `./boleto`.
|
|
447
|
+
*
|
|
448
|
+
* @param body - The first 43 digits of the key.
|
|
449
|
+
* @returns The check digit, 0-9.
|
|
450
|
+
* @throws {ChaveNFeError} When `body` is not exactly 43 digits.
|
|
451
|
+
*/
|
|
452
|
+
export declare function chaveNFeCheckDigit(body: string): number;
|
|
453
|
+
|
|
454
|
+
/**
|
|
455
|
+
* A 44-digit fiscal access key could not be read.
|
|
456
|
+
*
|
|
457
|
+
* Its own class so a scanner screen can tell a bad key apart from a bug and show
|
|
458
|
+
* the message to the operator unchanged.
|
|
459
|
+
*/
|
|
460
|
+
export declare class ChaveNFeError extends Error {
|
|
461
|
+
constructor(message: string);
|
|
462
|
+
}
|
|
463
|
+
|
|
229
464
|
/** A `{ value, label }` option, handy for `<Select>` / `<Combobox>`. */
|
|
230
465
|
export declare interface Choice {
|
|
231
466
|
value: string;
|
|
@@ -241,6 +476,16 @@ export declare function citiesByUf(uf: string): string[];
|
|
|
241
476
|
/** `{ value, label }` options for every city in a UF (value === label). */
|
|
242
477
|
export declare function cityChoices(uf: string): Choice[];
|
|
243
478
|
|
|
479
|
+
/**
|
|
480
|
+
* Convert a 44-digit barcode to its typed line — 47 digits, or 48 for `8…`.
|
|
481
|
+
*
|
|
482
|
+
* @param value - 44 digits.
|
|
483
|
+
* @returns The typed line, check digits included.
|
|
484
|
+
* @throws {BoletoError} On a bad length or a general check digit that does not
|
|
485
|
+
* recompute.
|
|
486
|
+
*/
|
|
487
|
+
export declare function codigoBarrasToLinhaDigitavel(value: string): string;
|
|
488
|
+
|
|
244
489
|
/** Maps a numeric value to a CSS color string. */
|
|
245
490
|
export declare type ColorScale = (value: number) => string;
|
|
246
491
|
|
|
@@ -256,9 +501,43 @@ declare interface Coordinate {
|
|
|
256
501
|
longitude: number;
|
|
257
502
|
}
|
|
258
503
|
|
|
504
|
+
/** Anything these helpers accept as a day. */
|
|
505
|
+
export declare type DateInput = Date | string;
|
|
506
|
+
|
|
259
507
|
/** Diverging palette (red ↔ neutral ↔ blue), for signed metrics. */
|
|
260
508
|
export declare const DIVERGING_RDBU: readonly ["#b2182b", "#ef8a62", "#fddbc7", "#d1e5f0", "#67a9cf", "#2166ac"];
|
|
261
509
|
|
|
510
|
+
/**
|
|
511
|
+
* Easter Sunday in the Gregorian calendar.
|
|
512
|
+
*
|
|
513
|
+
* The anonymous Gregorian computus (Meeus/Jones/Butcher): pure integer
|
|
514
|
+
* arithmetic over the year, no tables and no dependency. It is exact for every
|
|
515
|
+
* Gregorian year, which is why the four movable Brazilian holidays are derived
|
|
516
|
+
* from it rather than listed.
|
|
517
|
+
*
|
|
518
|
+
* @param year - Gregorian year.
|
|
519
|
+
* @returns Local midnight of Easter Sunday.
|
|
520
|
+
*
|
|
521
|
+
* @example
|
|
522
|
+
* easterSunday(2026); // 2026-04-05
|
|
523
|
+
*/
|
|
524
|
+
export declare function easterSunday(year: number): Date;
|
|
525
|
+
|
|
526
|
+
/**
|
|
527
|
+
* Invert {@link boletoDueDate}: the fator that encodes a due date.
|
|
528
|
+
*
|
|
529
|
+
* @param date - The due date. Only its local calendar day is used.
|
|
530
|
+
* @param epoch - Base date to count from. Default `"current"`, the epoch in force
|
|
531
|
+
* since 2025-02-22 and therefore the one a boleto issued today must use.
|
|
532
|
+
* @returns The 4-digit fator.
|
|
533
|
+
* @throws {BoletoError} When the date falls outside the 1000-9999 window of that
|
|
534
|
+
* epoch, because no fator can represent it.
|
|
535
|
+
*
|
|
536
|
+
* @example
|
|
537
|
+
* fatorVencimento(new Date(2025, 1, 22)); // 1000
|
|
538
|
+
*/
|
|
539
|
+
export declare function fatorVencimento(date: Date, epoch?: Exclude<BoletoEpoch, "auto">): number;
|
|
540
|
+
|
|
262
541
|
/** A ready-to-use mapping from coordinates to viewport pixels. */
|
|
263
542
|
declare interface FittedProjection {
|
|
264
543
|
/** Project a coordinate to a pixel inside the viewport. */
|
|
@@ -271,6 +550,35 @@ declare interface FittedProjection {
|
|
|
271
550
|
height: number;
|
|
272
551
|
}
|
|
273
552
|
|
|
553
|
+
/**
|
|
554
|
+
* Group a key in blocks of four, the way a DANFE prints it.
|
|
555
|
+
*
|
|
556
|
+
* @param chave - The key, masked or not.
|
|
557
|
+
* @returns Eleven groups of four digits separated by spaces, or the input
|
|
558
|
+
* unchanged when it is not 44 digits — this is a display helper, not a validator.
|
|
559
|
+
*
|
|
560
|
+
* @example
|
|
561
|
+
* formatChaveNFe("35260112345678000195550010000001231123456784");
|
|
562
|
+
* // "3526 0112 3456 7800 0195 5500 1000 0001 2311 2345 6784"
|
|
563
|
+
*/
|
|
564
|
+
export declare function formatChaveNFe(chave: string): string;
|
|
565
|
+
|
|
566
|
+
/**
|
|
567
|
+
* Group a typed line the way it is printed, so a human can read it back.
|
|
568
|
+
*
|
|
569
|
+
* 47 digits become `AAABC.CCCCD EEEEE.EEEEEF GGGGG.GGGGGH I JJJJKKKKKKKKKK`;
|
|
570
|
+
* 48 digits become four blocks of twelve. Anything else is returned untouched —
|
|
571
|
+
* this is a display helper, not a validator.
|
|
572
|
+
*
|
|
573
|
+
* @param value - A typed line, masked or not.
|
|
574
|
+
* @returns The grouped string.
|
|
575
|
+
*
|
|
576
|
+
* @example
|
|
577
|
+
* formatLinhaDigitavel("34191090086459218110900000463074184410000002000");
|
|
578
|
+
* // "34191.09008 64592.181109 00000.463074 1 84410000002000"
|
|
579
|
+
*/
|
|
580
|
+
export declare function formatLinhaDigitavel(value: string): string;
|
|
581
|
+
|
|
274
582
|
/**
|
|
275
583
|
* Forward-geocode a municipality by name (accent-insensitive), optionally scoped
|
|
276
584
|
* to a UF. Returns every exact-name match — the same name can occur in several
|
|
@@ -301,12 +609,98 @@ export declare interface GeoMarker extends Coordinate {
|
|
|
301
609
|
/** Look up a single state by acronym (case-insensitive). Returns `null` if unknown. */
|
|
302
610
|
export declare function getState(uf: string): BrazilState | null;
|
|
303
611
|
|
|
612
|
+
/** One non-working day in a given year. */
|
|
613
|
+
export declare interface Holiday {
|
|
614
|
+
/** `YYYY-MM-DD` in the local calendar. */
|
|
615
|
+
date: string;
|
|
616
|
+
/** Portuguese name, as the law or the Bacen calendar spells it. */
|
|
617
|
+
name: string;
|
|
618
|
+
kind: HolidayKind;
|
|
619
|
+
/** `true` when the date is derived from Easter rather than fixed. */
|
|
620
|
+
movable: boolean;
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
/**
|
|
624
|
+
* How binding a non-working day is.
|
|
625
|
+
*
|
|
626
|
+
* - `"national"` — a feriado nacional in federal law. Nobody works, and a
|
|
627
|
+
* deadline that lands here moves.
|
|
628
|
+
* - `"banking"` — not a statutory holiday, but a day the national financial
|
|
629
|
+
* system does not operate: Carnaval (Monday and Tuesday), Sexta-feira da
|
|
630
|
+
* Paixão and Corpus Christi. Bank branches are shut and compensation does not
|
|
631
|
+
* run, so a boleto or a TED dated here settles later — but an employer may
|
|
632
|
+
* legally require work, which is why the two kinds are separate.
|
|
633
|
+
*/
|
|
634
|
+
export declare type HolidayKind = "national" | "banking";
|
|
635
|
+
|
|
636
|
+
/**
|
|
637
|
+
* Every national non-working day in a year, ordered by date.
|
|
638
|
+
*
|
|
639
|
+
* **What is here:** the nine feriados nacionais in federal law (Lei 662/1949 as
|
|
640
|
+
* amended by Lei 10.607/2002, Lei 6.802/1980 for 12 October, and Lei 14.759/2023
|
|
641
|
+
* for 20 November, which is why that one only appears from 2024), plus the four
|
|
642
|
+
* movable days the national financial system observes.
|
|
643
|
+
*
|
|
644
|
+
* **What is deliberately not here**, and will not be:
|
|
645
|
+
*
|
|
646
|
+
* - **State and municipal holidays.** A data magna varies by state and each of the
|
|
647
|
+
* 5 570 municipalities may declare its own, including up to four religious
|
|
648
|
+
* days. No table can be both complete and current; pass them through
|
|
649
|
+
* `options.extra`.
|
|
650
|
+
* - **Ponto facultativo.** A federal decree that lets public servants off is not a
|
|
651
|
+
* holiday and binds nobody else, so it changes no deadline.
|
|
652
|
+
* - **Pre-2002 history.** The table encodes the law as it stands today. Asking for
|
|
653
|
+
* 1998 returns today's set shifted to 1998, not what was in force then.
|
|
654
|
+
*
|
|
655
|
+
* Carnaval, Sexta-feira da Paixão and Corpus Christi are the interesting case:
|
|
656
|
+
* none of them is a feriado nacional in federal law, yet CMN Resolução 4.880/2020
|
|
657
|
+
* closes the banks on all four days, so a payment cannot settle. They are returned
|
|
658
|
+
* with `kind: "banking"` — counted by default, and excluded by passing
|
|
659
|
+
* `kinds: ["national"]`.
|
|
660
|
+
*
|
|
661
|
+
* @param year - Gregorian year.
|
|
662
|
+
* @returns The holidays of that year, ascending by date.
|
|
663
|
+
*
|
|
664
|
+
* @example
|
|
665
|
+
* holidaysFor(2026).filter((holiday) => holiday.kind === "national").length; // 9
|
|
666
|
+
*/
|
|
667
|
+
export declare function holidaysFor(year: number): Holiday[];
|
|
668
|
+
|
|
304
669
|
/**
|
|
305
670
|
* Interpolate a palette at `t ∈ [0, 1]`, blending between the two nearest
|
|
306
671
|
* stops. `t <= 0` → first color, `t >= 1` → last.
|
|
307
672
|
*/
|
|
308
673
|
export declare function interpolatePalette(palette: readonly string[], t: number): string;
|
|
309
674
|
|
|
675
|
+
/**
|
|
676
|
+
* Whether a date is a working day: not a weekend, not a holiday.
|
|
677
|
+
*
|
|
678
|
+
* @param date - `YYYY-MM-DD` or a `Date`.
|
|
679
|
+
* @param options - See {@link BusinessDayOptions}.
|
|
680
|
+
* @returns `true` when work happens on that day.
|
|
681
|
+
* @throws {RangeError} On a malformed string or an Invalid Date.
|
|
682
|
+
*
|
|
683
|
+
* @example
|
|
684
|
+
* isBusinessDay("2026-04-03"); // false — Sexta-feira da Paixão
|
|
685
|
+
*/
|
|
686
|
+
export declare function isBusinessDay(date: DateInput, options?: BusinessDayOptions): boolean;
|
|
687
|
+
|
|
688
|
+
/**
|
|
689
|
+
* Whether a date is a national holiday.
|
|
690
|
+
*
|
|
691
|
+
* @param date - `YYYY-MM-DD` or a `Date`. Only the local calendar day matters.
|
|
692
|
+
* @param options - See {@link BusinessDayOptions}. `weekend` is ignored here — a
|
|
693
|
+
* Sunday is not a holiday, it is a Sunday.
|
|
694
|
+
* @returns `true` when the day is in the table (or in `extra`).
|
|
695
|
+
* @throws {RangeError} On a malformed string or an Invalid Date.
|
|
696
|
+
*
|
|
697
|
+
* @example
|
|
698
|
+
* isHoliday("2026-11-20"); // true
|
|
699
|
+
* isHoliday("2026-02-17"); // true — Carnaval
|
|
700
|
+
* isHoliday("2026-02-17", { kinds: ["national"] }); // false
|
|
701
|
+
*/
|
|
702
|
+
export declare function isHoliday(date: DateInput, options?: BusinessDayOptions): boolean;
|
|
703
|
+
|
|
310
704
|
/** True when `city` exists within `uf` (both case-insensitive). */
|
|
311
705
|
export declare function isValidCity(uf: string, city: string): boolean;
|
|
312
706
|
|
|
@@ -319,6 +713,15 @@ export declare interface LegendItem {
|
|
|
319
713
|
label: ReactNode;
|
|
320
714
|
}
|
|
321
715
|
|
|
716
|
+
/**
|
|
717
|
+
* Convert a typed line to its 44-digit barcode.
|
|
718
|
+
*
|
|
719
|
+
* @param value - 47 or 48 digits.
|
|
720
|
+
* @returns The 44-digit barcode.
|
|
721
|
+
* @throws {BoletoError} On a bad length or a check digit that does not recompute.
|
|
722
|
+
*/
|
|
723
|
+
export declare function linhaDigitavelToCodigoBarras(value: string): string;
|
|
724
|
+
|
|
322
725
|
/** All 27 federative units, sorted by name. */
|
|
323
726
|
export declare function listStates(): readonly BrazilState[];
|
|
324
727
|
|
|
@@ -398,6 +801,58 @@ export declare interface MapMarkersProps {
|
|
|
398
801
|
onMarkerClick?: (marker: GeoMarker, index: number) => void;
|
|
399
802
|
}
|
|
400
803
|
|
|
804
|
+
/**
|
|
805
|
+
* DAC módulo 10, FEBRABAN flavour.
|
|
806
|
+
*
|
|
807
|
+
* Multipliers cycle `2, 1, 2, 1, …` from right to left; the **digits** of each
|
|
808
|
+
* product are summed individually (so `6 × 2 = 12` contributes `1 + 2`); the DAC
|
|
809
|
+
* is `10 - (sum mod 10)`, and `0` when that remainder is `0`.
|
|
810
|
+
*
|
|
811
|
+
* Ported from "Layout Padrão de Arrecadação/Recebimento com Utilização do Código
|
|
812
|
+
* de Barras", FEBRABAN version 07 (effective 2023-03-01), section 07 — whose own
|
|
813
|
+
* worked example gives `01230067896 → 3`.
|
|
814
|
+
*
|
|
815
|
+
* @param value - Digits only.
|
|
816
|
+
* @returns The check digit, 0-9.
|
|
817
|
+
* @throws {BoletoError} When `value` is empty or holds a non-digit.
|
|
818
|
+
*/
|
|
819
|
+
export declare function mod10Dac(value: string): number;
|
|
820
|
+
|
|
821
|
+
/**
|
|
822
|
+
* DAC módulo 11 for an **arrecadação** barcode — position 4 of a `8…` slip.
|
|
823
|
+
*
|
|
824
|
+
* Same weights and same subtraction as {@link mod11DacCobranca}, but a remainder
|
|
825
|
+
* of `0` or `1` resolves to **`0`**.
|
|
826
|
+
*
|
|
827
|
+
* Ported from the FEBRABAN version 07 layout, section 10, and pinned by that
|
|
828
|
+
* document's own worked example: the 43-digit sequence
|
|
829
|
+
* `8220000215048200974123220154098290108605940` sums to 705, `705 mod 11 = 1`,
|
|
830
|
+
* and the barcode the spec prints carries `0` in position 4.
|
|
831
|
+
*
|
|
832
|
+
* @param value - The 43 digits of the barcode with position 4 removed.
|
|
833
|
+
* @returns The check digit, 0 or 2-9.
|
|
834
|
+
* @throws {BoletoError} When `value` is empty or holds a non-digit.
|
|
835
|
+
*/
|
|
836
|
+
export declare function mod11DacArrecadacao(value: string): number;
|
|
837
|
+
|
|
838
|
+
/**
|
|
839
|
+
* DAC módulo 11 for a **cobrança** barcode — position 5 of a bank boleto.
|
|
840
|
+
*
|
|
841
|
+
* Weights cycle `2…9` from right to left, the products are summed whole, and the
|
|
842
|
+
* DAC is `11 - (sum mod 11)`. A remainder of `0`, `1` or `10` would put `11`, `10`
|
|
843
|
+
* or `1` in a one-digit field, and FEBRABAN resolves all three to **`1`**.
|
|
844
|
+
*
|
|
845
|
+
* That last rule is where cobrança and arrecadação disagree — see
|
|
846
|
+
* {@link mod11DacArrecadacao}, which resolves the same remainders to `0`. Using
|
|
847
|
+
* one flavour on the other layout produces a check digit that is wrong exactly
|
|
848
|
+
* 3 times in 11, which is why they are separate functions here.
|
|
849
|
+
*
|
|
850
|
+
* @param value - The 43 digits of the barcode with position 5 removed.
|
|
851
|
+
* @returns The check digit, 1-9.
|
|
852
|
+
* @throws {BoletoError} When `value` is empty or holds a non-digit.
|
|
853
|
+
*/
|
|
854
|
+
export declare function mod11DacCobranca(value: string): number;
|
|
855
|
+
|
|
401
856
|
/** A municipality identified for selection callbacks. */
|
|
402
857
|
export declare interface Municipality {
|
|
403
858
|
/** 7-digit IBGE code. */
|
|
@@ -493,18 +948,408 @@ export declare interface NearestMunicipality extends MunicipalityCentroid {
|
|
|
493
948
|
*/
|
|
494
949
|
export declare function nearestMunicipality(coord: Coordinate): Promise<NearestMunicipality | null>;
|
|
495
950
|
|
|
951
|
+
/**
|
|
952
|
+
* The first working day strictly after a date.
|
|
953
|
+
*
|
|
954
|
+
* Strictly after: calling it on a Wednesday returns Thursday, never the same
|
|
955
|
+
* Wednesday. That is what a "prazo de D+1" means, and it makes the function safe
|
|
956
|
+
* to call in a loop.
|
|
957
|
+
*
|
|
958
|
+
* @param date - `YYYY-MM-DD` or a `Date`.
|
|
959
|
+
* @param options - See {@link BusinessDayOptions}.
|
|
960
|
+
* @returns Local midnight of the next working day.
|
|
961
|
+
* @throws {RangeError} On a malformed input, or when `options` marked so many days
|
|
962
|
+
* off that no working day exists within {@link MAX_WALK_DAYS}.
|
|
963
|
+
*
|
|
964
|
+
* @example
|
|
965
|
+
* nextBusinessDay("2026-12-24"); // 2026-12-28 — the 25th is Natal, then a weekend
|
|
966
|
+
*/
|
|
967
|
+
export declare function nextBusinessDay(date: DateInput, options?: BusinessDayOptions): Date;
|
|
968
|
+
|
|
969
|
+
/** A key after normalisation, ready to go into the payload. */
|
|
970
|
+
export declare interface NormalizedPixKey {
|
|
971
|
+
type: PixKeyType;
|
|
972
|
+
/** The exact string written into the BR Code. */
|
|
973
|
+
value: string;
|
|
974
|
+
}
|
|
975
|
+
|
|
976
|
+
/**
|
|
977
|
+
* Validate a Pix key and return the exact string to write into the payload.
|
|
978
|
+
*
|
|
979
|
+
* Normalisation per type: CPF and CNPJ lose their mask, a phone becomes E.164
|
|
980
|
+
* with the `+55` country code, an EVP is lower-cased, and an e-mail is
|
|
981
|
+
* lower-cased because DICT stores it that way — a key that differs only in case
|
|
982
|
+
* would otherwise fail to resolve.
|
|
983
|
+
*
|
|
984
|
+
* All validation lives in {@link pixKeyType}; past that gate the normalisation is
|
|
985
|
+
* total, which is why the phone branch strips a country code purely on length
|
|
986
|
+
* rather than re-checking the shape.
|
|
987
|
+
*
|
|
988
|
+
* @param key - Raw key, masked or not.
|
|
989
|
+
* @returns The type and the normalised value.
|
|
990
|
+
* @throws {PixError} When the key matches no accepted format, or when a document
|
|
991
|
+
* key fails its check digits.
|
|
992
|
+
*
|
|
993
|
+
* @example
|
|
994
|
+
* normalizePixKey("123.456.789-09"); // { type: "cpf", value: "12345678909" }
|
|
995
|
+
* normalizePixKey("(11) 98765-4321"); // { type: "phone", value: "+5511987654321" }
|
|
996
|
+
*/
|
|
997
|
+
export declare function normalizePixKey(key: string): NormalizedPixKey;
|
|
998
|
+
|
|
496
999
|
/**
|
|
497
1000
|
* Normalize an acronym to canonical uppercase form, or `null` if it is not a
|
|
498
1001
|
* valid UF. `"sp"` → `"SP"`, `"xx"` → `null`.
|
|
499
1002
|
*/
|
|
500
1003
|
export declare function normalizeUf(value: string): UF | null;
|
|
501
1004
|
|
|
1005
|
+
/**
|
|
1006
|
+
* Read a 44-digit fiscal access key into its fields.
|
|
1007
|
+
*
|
|
1008
|
+
* The layout is fixed and shared by every document type that carries a key —
|
|
1009
|
+
* NF-e, NFC-e, CT-e, MDF-e — so `modelo` is what tells you which one you are
|
|
1010
|
+
* holding, not the length.
|
|
1011
|
+
*
|
|
1012
|
+
* ```text
|
|
1013
|
+
* 35 2601 12345678000195 55 001 000000123 1 12345678 4
|
|
1014
|
+
* cUF AAMM CNPJ mod série nNF tp cNF cDV
|
|
1015
|
+
* ```
|
|
1016
|
+
*
|
|
1017
|
+
* @param chave - The key, with or without the spaces a DANFE prints.
|
|
1018
|
+
* @returns The parsed key.
|
|
1019
|
+
* @throws {ChaveNFeError} On a length other than 44, an unknown `cUF`, a month
|
|
1020
|
+
* outside 1-12, or a check digit that does not recompute.
|
|
1021
|
+
*
|
|
1022
|
+
* @example
|
|
1023
|
+
* const { uf, cnpj, numero, modeloLabel } = parseChaveNFe(scanned);
|
|
1024
|
+
*/
|
|
1025
|
+
export declare function parseChaveNFe(chave: string): ChaveNFe;
|
|
1026
|
+
|
|
1027
|
+
/**
|
|
1028
|
+
* Read a 44-digit barcode — either layout — into its fields.
|
|
1029
|
+
*
|
|
1030
|
+
* The first digit picks the layout: `8` is an arrecadação/convênio slip, anything
|
|
1031
|
+
* else is a cobrança boleto. They are **not** variants of one format; every field
|
|
1032
|
+
* moves. Narrow the result on `kind` before touching it.
|
|
1033
|
+
*
|
|
1034
|
+
* @param value - 44 digits. Spaces and punctuation are ignored.
|
|
1035
|
+
* @param options - Fator de vencimento epoch. See {@link boletoDueDate}.
|
|
1036
|
+
* @returns The parsed boleto, with the matching typed line filled in.
|
|
1037
|
+
* @throws {BoletoError} On a length other than 44, on a general check digit that
|
|
1038
|
+
* does not recompute, or on an arrecadação slip whose position 3 is out of spec.
|
|
1039
|
+
*
|
|
1040
|
+
* @example
|
|
1041
|
+
* const boleto = parseCodigoBarras(scanned);
|
|
1042
|
+
* if (boleto.kind === "banco") console.log(boleto.valor, boleto.vencimento);
|
|
1043
|
+
*/
|
|
1044
|
+
export declare function parseCodigoBarras(value: string, options?: BoletoOptions): Boleto;
|
|
1045
|
+
|
|
1046
|
+
/**
|
|
1047
|
+
* Read a typed line — 47 digits for a bank boleto, 48 for an arrecadação slip.
|
|
1048
|
+
*
|
|
1049
|
+
* Both layouts interleave check digits with the data, so the function rebuilds the
|
|
1050
|
+
* 44-digit barcode as it goes and every DV is verified: the three (bank) or four
|
|
1051
|
+
* (arrecadação) block digits, plus the general one.
|
|
1052
|
+
*
|
|
1053
|
+
* @param value - 47 or 48 digits. The usual `.`, ` ` and `-` are ignored.
|
|
1054
|
+
* @param options - Fator de vencimento epoch. See {@link boletoDueDate}.
|
|
1055
|
+
* @returns The parsed boleto, with the barcode filled in.
|
|
1056
|
+
* @throws {BoletoError} On a length other than 47 or 48, or on any check digit
|
|
1057
|
+
* that does not recompute.
|
|
1058
|
+
*
|
|
1059
|
+
* @example
|
|
1060
|
+
* const boleto = parseLinhaDigitavel("34191.09008 64592.181109 00000.463074 1 84410000002000");
|
|
1061
|
+
*/
|
|
1062
|
+
export declare function parseLinhaDigitavel(value: string, options?: BoletoOptions): Boleto;
|
|
1063
|
+
|
|
1064
|
+
/** Options for {@link parsePixPayload}. */
|
|
1065
|
+
export declare interface ParsePixOptions {
|
|
1066
|
+
/**
|
|
1067
|
+
* Throw when the checksum does not match. Default `true`.
|
|
1068
|
+
*
|
|
1069
|
+
* Turn it off only to inspect a payload you already know is broken: a BR Code
|
|
1070
|
+
* whose CRC fails has been corrupted in transit, and the account it now points
|
|
1071
|
+
* at is not the account the payee published.
|
|
1072
|
+
*/
|
|
1073
|
+
requireCrc?: boolean;
|
|
1074
|
+
}
|
|
1075
|
+
|
|
1076
|
+
/**
|
|
1077
|
+
* Read a Pix "Copia e Cola" payload back into its parts.
|
|
1078
|
+
*
|
|
1079
|
+
* Tolerant by design: tags the SDK does not know about are kept verbatim in
|
|
1080
|
+
* {@link PixData.fields} instead of raising, because PSPs do add their own
|
|
1081
|
+
* templates and a reader that rejects them is useless in production. What is
|
|
1082
|
+
* *not* tolerated is a broken frame — a length prefix that runs off the end, a
|
|
1083
|
+
* missing tag 63 — or a checksum mismatch, which means the string was corrupted
|
|
1084
|
+
* and no longer names the account the payee published.
|
|
1085
|
+
*
|
|
1086
|
+
* @param payload - The copia-e-cola string. Surrounding whitespace is ignored.
|
|
1087
|
+
* @param options - See {@link ParsePixOptions}.
|
|
1088
|
+
* @returns The decoded payload.
|
|
1089
|
+
* @throws {PixError} On a malformed frame, a missing CRC tag, a tag 26 that is
|
|
1090
|
+
* not a Pix account, or — unless `requireCrc` is `false` — a CRC mismatch.
|
|
1091
|
+
*
|
|
1092
|
+
* @example
|
|
1093
|
+
* const data = parsePixPayload(copied);
|
|
1094
|
+
* console.log(data.key, data.amount, data.txid);
|
|
1095
|
+
*/
|
|
1096
|
+
export declare function parsePixPayload(payload: string, options?: ParsePixOptions): PixData;
|
|
1097
|
+
|
|
1098
|
+
/**
|
|
1099
|
+
* CRC-16/CCITT-FALSE of a string, as four upper-case hex characters.
|
|
1100
|
+
*
|
|
1101
|
+
* Bitwise rather than table-driven: 200-odd characters at 8 shifts each is
|
|
1102
|
+
* nothing, and a 256-entry table is 2 KB of payload every consumer of the `/br`
|
|
1103
|
+
* entry would carry.
|
|
1104
|
+
*
|
|
1105
|
+
* The input is taken as UTF-8 bytes. A Pix payload is ASCII by construction —
|
|
1106
|
+
* {@link pixPayload} rejects anything else — but the function is exported and a
|
|
1107
|
+
* caller may hand it arbitrary text, and hashing UTF-16 code units would then
|
|
1108
|
+
* disagree with every other implementation.
|
|
1109
|
+
*
|
|
1110
|
+
* @param input - Bytes to run through the register.
|
|
1111
|
+
* @returns Four upper-case hex characters, zero-padded.
|
|
1112
|
+
*
|
|
1113
|
+
* @example
|
|
1114
|
+
* pixCrc16("123456789"); // "29B1" — the catalogue check value
|
|
1115
|
+
*/
|
|
1116
|
+
export declare function pixCrc16(input: string): string;
|
|
1117
|
+
|
|
1118
|
+
/** A payload taken apart again. */
|
|
1119
|
+
export declare interface PixData {
|
|
1120
|
+
/** `"dynamic"` when tag 26 carried a URL instead of a key. */
|
|
1121
|
+
kind: "static" | "dynamic";
|
|
1122
|
+
/** Present on a static payload. */
|
|
1123
|
+
key?: string;
|
|
1124
|
+
keyType?: PixKeyType;
|
|
1125
|
+
/** Present on a dynamic payload. */
|
|
1126
|
+
url?: string;
|
|
1127
|
+
merchantName: string;
|
|
1128
|
+
merchantCity: string;
|
|
1129
|
+
/** Reais. `undefined` when the payer chooses the amount. */
|
|
1130
|
+
amount?: number;
|
|
1131
|
+
/** ISO 4217 numeric. `"986"` for BRL. */
|
|
1132
|
+
currency: string;
|
|
1133
|
+
countryCode: string;
|
|
1134
|
+
merchantCategoryCode: string;
|
|
1135
|
+
/** `"***"` on a reusable static QR that identifies no single transaction. */
|
|
1136
|
+
txid?: string;
|
|
1137
|
+
description?: string;
|
|
1138
|
+
postalCode?: string;
|
|
1139
|
+
/** Tag 01 read as `"12"`. */
|
|
1140
|
+
oneTime: boolean;
|
|
1141
|
+
/** The four hex characters that closed the payload. */
|
|
1142
|
+
crc: string;
|
|
1143
|
+
/** Whether those four characters match a recomputed CRC. */
|
|
1144
|
+
crcValid: boolean;
|
|
1145
|
+
/** Every top-level TLV, in payload order, unknown tags included. */
|
|
1146
|
+
fields: PixField[];
|
|
1147
|
+
}
|
|
1148
|
+
|
|
1149
|
+
/** A BR Code that carries a URL the wallet fetches to learn the amount. */
|
|
1150
|
+
export declare interface PixDynamicInput {
|
|
1151
|
+
kind: "dynamic";
|
|
1152
|
+
/**
|
|
1153
|
+
* `payloadLocation` — the https URL the wallet GETs, **without** the scheme,
|
|
1154
|
+
* exactly as BACEN specifies (`pix.example.com/qr/v2/abc`).
|
|
1155
|
+
*/
|
|
1156
|
+
url: string;
|
|
1157
|
+
merchantName: string;
|
|
1158
|
+
merchantCity: string;
|
|
1159
|
+
postalCode?: string;
|
|
1160
|
+
/** Single-use QR. Defaults to `true`, which is what a dynamic QR normally is. */
|
|
1161
|
+
oneTime?: boolean;
|
|
1162
|
+
}
|
|
1163
|
+
|
|
502
1164
|
/** A pixel coordinate inside the plotting viewport. */
|
|
503
1165
|
declare interface PixelPoint {
|
|
504
1166
|
x: number;
|
|
505
1167
|
y: number;
|
|
506
1168
|
}
|
|
507
1169
|
|
|
1170
|
+
/**
|
|
1171
|
+
* A Pix payload could not be built or read.
|
|
1172
|
+
*
|
|
1173
|
+
* Its own class so a caller can tell "the operator typed a bad key" apart from a
|
|
1174
|
+
* bug, and so an `ErrorBoundary` can render a form error instead of a crash.
|
|
1175
|
+
*/
|
|
1176
|
+
export declare class PixError extends Error {
|
|
1177
|
+
constructor(message: string);
|
|
1178
|
+
}
|
|
1179
|
+
|
|
1180
|
+
/** One TLV as it appeared in a payload, unknown tags included. */
|
|
1181
|
+
export declare interface PixField {
|
|
1182
|
+
/** Two-character tag, e.g. `"59"`. */
|
|
1183
|
+
id: string;
|
|
1184
|
+
/** Raw value, still encoded when the tag is itself a template. */
|
|
1185
|
+
value: string;
|
|
1186
|
+
}
|
|
1187
|
+
|
|
1188
|
+
/** Everything `pixPayload` accepts. */
|
|
1189
|
+
export declare type PixInput = PixStaticInput | PixDynamicInput;
|
|
1190
|
+
|
|
1191
|
+
/** The five key formats DICT accepts. */
|
|
1192
|
+
export declare type PixKeyType = "cpf" | "cnpj" | "email" | "phone" | "evp";
|
|
1193
|
+
|
|
1194
|
+
/**
|
|
1195
|
+
* Classify a Pix key, or `null` when it matches no accepted format.
|
|
1196
|
+
*
|
|
1197
|
+
* !!! warning "CPF and a national phone number are both eleven digits"
|
|
1198
|
+
* `"11987654321"` is a valid mobile number and could be a CPF. The check
|
|
1199
|
+
* digits break the tie: an 11-digit string is a CPF when its DV validates and
|
|
1200
|
+
* a phone otherwise. Pass phone keys as `+5511987654321` to remove the guess
|
|
1201
|
+
* entirely.
|
|
1202
|
+
*
|
|
1203
|
+
* @param key - Raw key, masked or not.
|
|
1204
|
+
* @returns The key type, or `null`.
|
|
1205
|
+
*/
|
|
1206
|
+
export declare function pixKeyType(key: string): PixKeyType | null;
|
|
1207
|
+
|
|
1208
|
+
/**
|
|
1209
|
+
* Build a Pix "Copia e Cola" payload — the string behind a Pix QR code.
|
|
1210
|
+
*
|
|
1211
|
+
* The format is EMVCo MPM: a flat list of `ID + 2-digit length + value` triples,
|
|
1212
|
+
* closed by tag 63 holding a CRC-16/CCITT-FALSE over **everything before it,
|
|
1213
|
+
* including the literal `6304` header of tag 63 itself**. That last detail is the
|
|
1214
|
+
* one implementations get wrong; see {@link pixCrc16}.
|
|
1215
|
+
*
|
|
1216
|
+
* Two shapes come out of here:
|
|
1217
|
+
*
|
|
1218
|
+
* - **static** — tag 26 carries the key, so the QR is self-contained and can be
|
|
1219
|
+
* printed. Amount optional; a txid of `"***"` means "identifies no single
|
|
1220
|
+
* transaction", which is what a reusable poster QR wants.
|
|
1221
|
+
* - **dynamic** — tag 26 carries a URL instead, and the wallet fetches the amount
|
|
1222
|
+
* and payee from the PSP. Use it when the value is per-order. Defaults to
|
|
1223
|
+
* single-use (tag 01 = `12`).
|
|
1224
|
+
*
|
|
1225
|
+
* The distinction matters and is not cosmetic: a static QR settles against
|
|
1226
|
+
* whatever the payer typed, a dynamic one against what the PSP served, so a
|
|
1227
|
+
* charge that must reconcile to a cent needs the dynamic form.
|
|
1228
|
+
*
|
|
1229
|
+
* @param input - Static or dynamic payload description.
|
|
1230
|
+
* @returns The full payload, CRC included, ready to render as a QR or to copy.
|
|
1231
|
+
* @throws {PixError} On an unrecognised key, a field over its length cap, a
|
|
1232
|
+
* non-positive amount, or text that is not representable in the BR Code.
|
|
1233
|
+
*
|
|
1234
|
+
* @example
|
|
1235
|
+
* pixPayload({
|
|
1236
|
+
* key: "12345678909",
|
|
1237
|
+
* merchantName: "Loja Tempest",
|
|
1238
|
+
* merchantCity: "São Paulo",
|
|
1239
|
+
* amount: 25.5,
|
|
1240
|
+
* txid: "PEDIDO123",
|
|
1241
|
+
* });
|
|
1242
|
+
*/
|
|
1243
|
+
export declare function pixPayload(input: PixInput): string;
|
|
1244
|
+
|
|
1245
|
+
/**
|
|
1246
|
+
* A Pix QR code with the copia-e-cola string next to it.
|
|
1247
|
+
*
|
|
1248
|
+
* The two affordances belong together: a QR is unusable on the device that is
|
|
1249
|
+
* *showing* it, which is exactly where a mobile checkout puts it, so every real
|
|
1250
|
+
* Pix screen ends up needing the copyable string as well. Rendering only the
|
|
1251
|
+
* symbol is the single most common mistake in a Pix flow.
|
|
1252
|
+
*
|
|
1253
|
+
* Everything is computed locally — {@link pixPayload} builds the string and the
|
|
1254
|
+
* SDK's own encoder draws the symbol — so the key, the amount and the txid never
|
|
1255
|
+
* leave the page. A QR-image service would receive all three.
|
|
1256
|
+
*
|
|
1257
|
+
* @throws {PixError} When neither `pix` nor `payload` is given, when both are, or
|
|
1258
|
+
* when `pix` fails validation. A bad key is a programming or data error rather
|
|
1259
|
+
* than a state to render, so it surfaces; wrap the screen in `ErrorBoundary` when
|
|
1260
|
+
* the values come from user input.
|
|
1261
|
+
*
|
|
1262
|
+
* @example
|
|
1263
|
+
* <PixQRCode
|
|
1264
|
+
* pix={{
|
|
1265
|
+
* key: "loja@tempest.dev",
|
|
1266
|
+
* merchantName: "Loja Tempest",
|
|
1267
|
+
* merchantCity: "São Paulo",
|
|
1268
|
+
* amount: 25.5,
|
|
1269
|
+
* txid: "PEDIDO123",
|
|
1270
|
+
* }}
|
|
1271
|
+
* amountLabel="R$ 25,50"
|
|
1272
|
+
* payeeLabel="Loja Tempest"
|
|
1273
|
+
* />
|
|
1274
|
+
*
|
|
1275
|
+
* @example
|
|
1276
|
+
* <PixQRCode payload={charge.brcode} level="Q" size={220} />
|
|
1277
|
+
*/
|
|
1278
|
+
export declare function PixQRCode({ pix, payload, size, level, showCopy, amountLabel, payeeLabel, labels, onCopied, className, ...rest }: PixQRCodeProps): JSX.Element;
|
|
1279
|
+
|
|
1280
|
+
/** Strings the component renders, so an app can translate them. */
|
|
1281
|
+
export declare interface PixQRCodeLabels {
|
|
1282
|
+
/** Accessible name of the symbol. */
|
|
1283
|
+
qr: string;
|
|
1284
|
+
/** Copy button, idle. */
|
|
1285
|
+
copy: string;
|
|
1286
|
+
/** Copy button, just clicked. */
|
|
1287
|
+
copied: string;
|
|
1288
|
+
}
|
|
1289
|
+
|
|
1290
|
+
export declare interface PixQRCodeProps extends Omit<HTMLAttributes<HTMLDivElement>, "children"> {
|
|
1291
|
+
/**
|
|
1292
|
+
* Build the payload from its parts. Mutually exclusive with {@link payload}.
|
|
1293
|
+
*/
|
|
1294
|
+
pix?: PixInput;
|
|
1295
|
+
/**
|
|
1296
|
+
* A payload your PSP already produced, used verbatim.
|
|
1297
|
+
*
|
|
1298
|
+
* Prefer this for a dynamic charge: the PSP signed that string, and rebuilding
|
|
1299
|
+
* it here from parsed parts would only add a way to get it wrong.
|
|
1300
|
+
*/
|
|
1301
|
+
payload?: string;
|
|
1302
|
+
/** Rendered side of the symbol in px, quiet zone included. Default `192`. */
|
|
1303
|
+
size?: number;
|
|
1304
|
+
/**
|
|
1305
|
+
* Error-correction level. Default `"M"`.
|
|
1306
|
+
*
|
|
1307
|
+
* A printed QR that will be photographed at an angle scans better at `"Q"` or
|
|
1308
|
+
* `"H"`; the cost is a denser symbol, so raise the size with it.
|
|
1309
|
+
*/
|
|
1310
|
+
level?: QRErrorCorrection;
|
|
1311
|
+
/** Render the copia-e-cola line and its copy button. Default `true`. */
|
|
1312
|
+
showCopy?: boolean;
|
|
1313
|
+
/** Amount caption, e.g. `"R$ 25,50"`. Rendered above the symbol when set. */
|
|
1314
|
+
amountLabel?: string;
|
|
1315
|
+
/** Payee caption. Rendered under the amount when set. */
|
|
1316
|
+
payeeLabel?: string;
|
|
1317
|
+
labels?: Partial<PixQRCodeLabels>;
|
|
1318
|
+
/** Called after the payload reaches the clipboard. */
|
|
1319
|
+
onCopied?: () => void;
|
|
1320
|
+
}
|
|
1321
|
+
|
|
1322
|
+
/** A BR Code that carries the key — the one you print on a poster. */
|
|
1323
|
+
export declare interface PixStaticInput {
|
|
1324
|
+
kind?: "static";
|
|
1325
|
+
/** CPF, CNPJ, e-mail, phone or EVP. Validated and normalised. */
|
|
1326
|
+
key: string;
|
|
1327
|
+
/** Payee name. Truncated by the spec at 25 characters — longer throws. */
|
|
1328
|
+
merchantName: string;
|
|
1329
|
+
/** Payee city. Truncated by the spec at 15 characters — longer throws. */
|
|
1330
|
+
merchantCity: string;
|
|
1331
|
+
/** Amount in BRL. Omit for a payer-chooses-the-value QR. */
|
|
1332
|
+
amount?: number;
|
|
1333
|
+
/** Reference the PSP echoes back, `[A-Za-z0-9]{1,25}`. Defaults to `"***"`. */
|
|
1334
|
+
txid?: string;
|
|
1335
|
+
/** Free text shown by some wallets. Goes into tag 26, sub-tag 02. */
|
|
1336
|
+
description?: string;
|
|
1337
|
+
/** CEP, digits only. Optional tag 61. */
|
|
1338
|
+
postalCode?: string;
|
|
1339
|
+
/** Single-use QR: sets tag 01 to `"12"` instead of `"11"`. */
|
|
1340
|
+
oneTime?: boolean;
|
|
1341
|
+
}
|
|
1342
|
+
|
|
1343
|
+
/**
|
|
1344
|
+
* The fixed tables of ISO/IEC 18004, transcribed.
|
|
1345
|
+
*
|
|
1346
|
+
* They are data, not logic: the standard specifies them and there is nothing to
|
|
1347
|
+
* derive. They live apart from {@link ./qr-encode} so the algorithm reads as
|
|
1348
|
+
* algorithm and a typo in a table stays findable.
|
|
1349
|
+
*/
|
|
1350
|
+
/** Error correction level, by how much of the symbol it can lose and survive. */
|
|
1351
|
+
declare type QRErrorCorrection = "L" | "M" | "Q" | "H";
|
|
1352
|
+
|
|
508
1353
|
/**
|
|
509
1354
|
* Discrete scale: split `[min, max]` into `palette.length` equal buckets and
|
|
510
1355
|
* return the bucket's color (a classic choropleth "quantize" scale).
|
|
@@ -618,4 +1463,37 @@ export declare type UF = "AC" | "AL" | "AP" | "AM" | "BA" | "CE" | "DF" | "ES" |
|
|
|
618
1463
|
/** `{ value: uf, label: name }` options for every state, for a `<Select>`. */
|
|
619
1464
|
export declare function ufChoices(): Choice[];
|
|
620
1465
|
|
|
1466
|
+
/**
|
|
1467
|
+
* Whether a boleto string is internally consistent.
|
|
1468
|
+
*
|
|
1469
|
+
* Checks every digit the layout can check — the block DVs of a typed line and the
|
|
1470
|
+
* general DV in both representations. It says nothing about whether the boleto
|
|
1471
|
+
* exists, is registered, or is still payable: only a bank can answer that. What it
|
|
1472
|
+
* *does* catch is the common failure, a mistyped or truncated line.
|
|
1473
|
+
*
|
|
1474
|
+
* @param value - A barcode (44) or typed line (47/48), masked or not.
|
|
1475
|
+
* @returns `true` when everything recomputes.
|
|
1476
|
+
*
|
|
1477
|
+
* @example
|
|
1478
|
+
* if (!validateBoleto(input)) setError("Confira a linha digitável.");
|
|
1479
|
+
*/
|
|
1480
|
+
export declare function validateBoleto(value: string): boolean;
|
|
1481
|
+
|
|
1482
|
+
/**
|
|
1483
|
+
* Whether a fiscal access key is well formed.
|
|
1484
|
+
*
|
|
1485
|
+
* Three things have to hold: 44 digits, a `cUF` that is a real federative unit,
|
|
1486
|
+
* and a check digit that recomputes. It says nothing about whether the document
|
|
1487
|
+
* exists or was authorised — only SEFAZ can answer that — but it catches the
|
|
1488
|
+
* failure that actually happens, a key transcribed by hand or truncated by a
|
|
1489
|
+
* spreadsheet.
|
|
1490
|
+
*
|
|
1491
|
+
* @param chave - The key, with or without the spaces a DANFE prints.
|
|
1492
|
+
* @returns `true` when all three hold.
|
|
1493
|
+
*
|
|
1494
|
+
* @example
|
|
1495
|
+
* if (!validateChaveNFe(input)) setError("Chave inválida.");
|
|
1496
|
+
*/
|
|
1497
|
+
export declare function validateChaveNFe(chave: string): boolean;
|
|
1498
|
+
|
|
621
1499
|
export { }
|